/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/@magenta/music@1.23.1/dist/magentamusic.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=293)}([function(t,e,n){"use strict";n.r(e),n.d(e,"AdadeltaOptimizer",(function(){return Wt})),n.d(e,"AdagradOptimizer",(function(){return Ht})),n.d(e,"AdamOptimizer",(function(){return Xt})),n.d(e,"AdamaxOptimizer",(function(){return Zt})),n.d(e,"MomentumOptimizer",(function(){return ee})),n.d(e,"Optimizer",(function(){return Ut})),n.d(e,"RMSPropOptimizer",(function(){return ne})),n.d(e,"SGDOptimizer",(function(){return te})),n.d(e,"Tensor",(function(){return H.a})),n.d(e,"TensorBuffer",(function(){return H.b})),n.d(e,"Variable",(function(){return H.c})),n.d(e,"Rank",(function(){return re.a})),n.d(e,"sumOutType",(function(){return re.b})),n.d(e,"upcastType",(function(){return re.c})),n.d(e,"abs",(function(){return ie.b})),n.d(e,"acos",(function(){return ie.c})),n.d(e,"acosh",(function(){return ie.d})),n.d(e,"add",(function(){return ie.e})),n.d(e,"addN",(function(){return ie.f})),n.d(e,"all",(function(){return ie.h})),n.d(e,"any",(function(){return ie.i})),n.d(e,"argMax",(function(){return ie.j})),n.d(e,"argMin",(function(){return ie.k})),n.d(e,"asin",(function(){return ie.l})),n.d(e,"asinh",(function(){return ie.m})),n.d(e,"atan",(function(){return ie.n})),n.d(e,"atan2",(function(){return ie.o})),n.d(e,"atanh",(function(){return ie.p})),n.d(e,"avgPool",(function(){return ie.q})),n.d(e,"avgPool3d",(function(){return ie.r})),n.d(e,"basicLSTMCell",(function(){return ie.s})),n.d(e,"batchToSpaceND",(function(){return ie.x})),n.d(e,"batchNorm",(function(){return ie.t})),n.d(e,"batchNorm2d",(function(){return ie.u})),n.d(e,"batchNorm3d",(function(){return ie.v})),n.d(e,"batchNorm4d",(function(){return ie.w})),n.d(e,"broadcastTo",(function(){return ie.z})),n.d(e,"buffer",(function(){return ie.A})),n.d(e,"cast",(function(){return ie.B})),n.d(e,"ceil",(function(){return ie.C})),n.d(e,"clipByValue",(function(){return ie.D})),n.d(e,"clone",(function(){return ie.E})),n.d(e,"complex",(function(){return ie.F})),n.d(e,"concat",(function(){return ie.G})),n.d(e,"concat1d",(function(){return ie.H})),n.d(e,"concat2d",(function(){return ie.I})),n.d(e,"concat3d",(function(){return ie.J})),n.d(e,"concat4d",(function(){return ie.K})),n.d(e,"conv1d",(function(){return ie.L})),n.d(e,"conv2d",(function(){return ie.M})),n.d(e,"conv2dTranspose",(function(){return ie.N})),n.d(e,"conv3d",(function(){return ie.O})),n.d(e,"conv3dTranspose",(function(){return ie.P})),n.d(e,"cos",(function(){return ie.Q})),n.d(e,"cosh",(function(){return ie.R})),n.d(e,"cumsum",(function(){return ie.T})),n.d(e,"depthToSpace",(function(){return ie.U})),n.d(e,"depthwiseConv2d",(function(){return ie.V})),n.d(e,"diag",(function(){return ie.W})),n.d(e,"dilation2d",(function(){return ie.X})),n.d(e,"div",(function(){return ie.Y})),n.d(e,"divNoNan",(function(){return ie.Z})),n.d(e,"dot",(function(){return ie.bb})),n.d(e,"elu",(function(){return ie.db})),n.d(e,"equal",(function(){return ie.fb})),n.d(e,"erf",(function(){return ie.hb})),n.d(e,"exp",(function(){return ie.ib})),n.d(e,"expandDims",(function(){return ie.jb})),n.d(e,"expm1",(function(){return ie.kb})),n.d(e,"eye",(function(){return ie.lb})),n.d(e,"fill",(function(){return ie.nb})),n.d(e,"floor",(function(){return ie.ob})),n.d(e,"floorDiv",(function(){return ie.pb})),n.d(e,"gather",(function(){return ie.rb})),n.d(e,"greater",(function(){return ie.tb})),n.d(e,"greaterEqual",(function(){return ie.ub})),n.d(e,"imag",(function(){return ie.yb})),n.d(e,"isFinite",(function(){return ie.Cb})),n.d(e,"isInf",(function(){return ie.Db})),n.d(e,"isNaN",(function(){return ie.Eb})),n.d(e,"leakyRelu",(function(){return ie.Fb})),n.d(e,"less",(function(){return ie.Gb})),n.d(e,"lessEqual",(function(){return ie.Hb})),n.d(e,"linspace",(function(){return ie.Lb})),n.d(e,"localResponseNormalization",(function(){return ie.Mb})),n.d(e,"log",(function(){return ie.Nb})),n.d(e,"log1p",(function(){return ie.Ob})),n.d(e,"logSigmoid",(function(){return ie.Pb})),n.d(e,"logSoftmax",(function(){return ie.Qb})),n.d(e,"logSumExp",(function(){return ie.Rb})),n.d(e,"logicalAnd",(function(){return ie.Sb})),n.d(e,"logicalNot",(function(){return ie.Tb})),n.d(e,"logicalOr",(function(){return ie.Ub})),n.d(e,"logicalXor",(function(){return ie.Vb})),n.d(e,"matMul",(function(){return ie.Xb})),n.d(e,"max",(function(){return ie.Yb})),n.d(e,"maxPool",(function(){return ie.Zb})),n.d(e,"maxPool3d",(function(){return ie.ac})),n.d(e,"maxPoolWithArgmax",(function(){return ie.bc})),n.d(e,"maximum",(function(){return ie.cc})),n.d(e,"mean",(function(){return ie.ec})),n.d(e,"min",(function(){return ie.fc})),n.d(e,"minimum",(function(){return ie.gc})),n.d(e,"mirrorPad",(function(){return ie.ic})),n.d(e,"mod",(function(){return ie.jc})),n.d(e,"moments",(function(){return ie.lc})),n.d(e,"mul",(function(){return ie.nc})),n.d(e,"multiRNNCell",(function(){return ie.pc})),n.d(e,"multinomial",(function(){return ie.qc})),n.d(e,"neg",(function(){return ie.rc})),n.d(e,"notEqual",(function(){return ie.tc})),n.d(e,"oneHot",(function(){return ie.vc})),n.d(e,"ones",(function(){return ie.wc})),n.d(e,"onesLike",(function(){return ie.xc})),n.d(e,"outerProduct",(function(){return ie.zc})),n.d(e,"pad",(function(){return ie.Ac})),n.d(e,"pad1d",(function(){return ie.Bc})),n.d(e,"pad2d",(function(){return ie.Cc})),n.d(e,"pad3d",(function(){return ie.Dc})),n.d(e,"pad4d",(function(){return ie.Ec})),n.d(e,"pool",(function(){return ie.Fc})),n.d(e,"pow",(function(){return ie.Gc})),n.d(e,"prelu",(function(){return ie.Ic})),n.d(e,"print",(function(){return ie.Jc})),n.d(e,"prod",(function(){return ie.Kc})),n.d(e,"rand",(function(){return ie.Lc})),n.d(e,"randomGamma",(function(){return ie.Mc})),n.d(e,"randomNormal",(function(){return ie.Nc})),n.d(e,"randomUniform",(function(){return ie.Oc})),n.d(e,"range",(function(){return ie.Pc})),n.d(e,"real",(function(){return ie.Qc})),n.d(e,"reciprocal",(function(){return ie.Rc})),n.d(e,"relu",(function(){return ie.Sc})),n.d(e,"relu6",(function(){return ie.Tc})),n.d(e,"reshape",(function(){return ie.Uc})),n.d(e,"reverse",(function(){return ie.Vc})),n.d(e,"reverse1d",(function(){return ie.Wc})),n.d(e,"reverse2d",(function(){return ie.Xc})),n.d(e,"reverse3d",(function(){return ie.Yc})),n.d(e,"reverse4d",(function(){return ie.Zc})),n.d(e,"round",(function(){return ie.bd})),n.d(e,"rsqrt",(function(){return ie.cd})),n.d(e,"scalar",(function(){return ie.dd})),n.d(e,"selu",(function(){return ie.fd})),n.d(e,"separableConv2d",(function(){return ie.gd})),n.d(e,"setdiff1dAsync",(function(){return ie.hd})),n.d(e,"sigmoid",(function(){return ie.id})),n.d(e,"sign",(function(){return ie.jd})),n.d(e,"sin",(function(){return ie.ld})),n.d(e,"sinh",(function(){return ie.md})),n.d(e,"slice",(function(){return ie.nd})),n.d(e,"slice1d",(function(){return ie.od})),n.d(e,"slice2d",(function(){return ie.pd})),n.d(e,"slice3d",(function(){return ie.qd})),n.d(e,"slice4d",(function(){return ie.rd})),n.d(e,"softmax",(function(){return ie.sd})),n.d(e,"softplus",(function(){return ie.td})),n.d(e,"spaceToBatchND",(function(){return ie.ud})),n.d(e,"fft",(function(){return ie.mb})),n.d(e,"ifft",(function(){return ie.xb})),n.d(e,"irfft",(function(){return ie.Bb})),n.d(e,"rfft",(function(){return ie.ad})),n.d(e,"split",(function(){return ie.xd})),n.d(e,"sqrt",(function(){return ie.yd})),n.d(e,"square",(function(){return ie.zd})),n.d(e,"squaredDifference",(function(){return ie.Ad})),n.d(e,"squeeze",(function(){return ie.Cd})),n.d(e,"stack",(function(){return ie.Dd})),n.d(e,"step",(function(){return ie.Ed})),n.d(e,"stridedSlice",(function(){return ie.Fd})),n.d(e,"sub",(function(){return ie.Gd})),n.d(e,"sum",(function(){return ie.Id})),n.d(e,"tan",(function(){return ie.Jd})),n.d(e,"tanh",(function(){return ie.Kd})),n.d(e,"tensor",(function(){return ie.Ld})),n.d(e,"tensor1d",(function(){return ie.Md})),n.d(e,"tensor2d",(function(){return ie.Nd})),n.d(e,"tensor3d",(function(){return ie.Od})),n.d(e,"tensor4d",(function(){return ie.Pd})),n.d(e,"tensor5d",(function(){return ie.Qd})),n.d(e,"tensor6d",(function(){return ie.Rd})),n.d(e,"tile",(function(){return ie.Sd})),n.d(e,"topk",(function(){return ie.Td})),n.d(e,"truncatedNormal",(function(){return ie.Vd})),n.d(e,"unique",(function(){return ie.Wd})),n.d(e,"unsortedSegmentSum",(function(){return ie.Xd})),n.d(e,"unstack",(function(){return ie.Yd})),n.d(e,"variable",(function(){return ie.Zd})),n.d(e,"where",(function(){return ie.ae})),n.d(e,"whereAsync",(function(){return ie.be})),n.d(e,"zeros",(function(){return ie.ce})),n.d(e,"zerosLike",(function(){return ie.de})),n.d(e,"booleanMaskAsync",(function(){return ie.y})),n.d(e,"equalStrict",(function(){return ie.gb})),n.d(e,"greaterEqualStrict",(function(){return ie.vb})),n.d(e,"greaterStrict",(function(){return ie.wb})),n.d(e,"lessEqualStrict",(function(){return ie.Ib})),n.d(e,"lessStrict",(function(){return ie.Jb})),n.d(e,"notEqualStrict",(function(){return ie.uc})),n.d(e,"addStrict",(function(){return ie.g})),n.d(e,"divStrict",(function(){return ie.ab})),n.d(e,"maximumStrict",(function(){return ie.dc})),n.d(e,"minimumStrict",(function(){return ie.hc})),n.d(e,"modStrict",(function(){return ie.kc})),n.d(e,"mulStrict",(function(){return ie.oc})),n.d(e,"powStrict",(function(){return ie.Hc})),n.d(e,"squaredDifferenceStrict",(function(){return ie.Bd})),n.d(e,"subStrict",(function(){return ie.Hd})),n.d(e,"transpose",(function(){return ie.Ud})),n.d(e,"norm",(function(){return ie.sc})),n.d(e,"movingAverage",(function(){return ie.mc})),n.d(e,"scatterND",(function(){return ie.ed})),n.d(e,"sparseToDense",(function(){return ie.vd})),n.d(e,"gatherND",(function(){return ie.sb})),n.d(e,"dropout",(function(){return ie.cb})),n.d(e,"enclosingPowerOfTwo",(function(){return ie.eb})),n.d(e,"cosineWindow",(function(){return ie.S})),n.d(e,"inTopKAsync",(function(){return ie.Ab})),n.d(e,"op",(function(){return ie.yc})),n.d(e,"OP_SCOPE_SUFFIX",(function(){return ie.a})),n.d(e,"image",(function(){return ie.zb})),n.d(e,"linalg",(function(){return ie.Kb})),n.d(e,"losses",(function(){return ie.Wb})),n.d(e,"spectral",(function(){return ie.wd})),n.d(e,"fused",(function(){return ie.qb})),n.d(e,"signal",(function(){return ie.kd})),n.d(e,"Reduction",(function(){return se.a})),n.d(e,"train",(function(){return oe})),n.d(e,"enableProdMode",(function(){return Rt.g})),n.d(e,"enableDebugMode",(function(){return Rt.f})),n.d(e,"disableDeprecationWarnings",(function(){return Rt.c})),n.d(e,"deprecationWarn",(function(){return Rt.b})),n.d(e,"disposeVariables",(function(){return Rt.e})),n.d(e,"engine",(function(){return Rt.h})),n.d(e,"memory",(function(){return Rt.m})),n.d(e,"profile",(function(){return Rt.n})),n.d(e,"tidy",(function(){return Rt.t})),n.d(e,"dispose",(function(){return Rt.d})),n.d(e,"keep",(function(){return Rt.l})),n.d(e,"time",(function(){return Rt.u})),n.d(e,"setBackend",(function(){return Rt.r})),n.d(e,"ready",(function(){return Rt.o})),n.d(e,"getBackend",(function(){return Rt.k})),n.d(e,"removeBackend",(function(){return Rt.q})),n.d(e,"findBackend",(function(){return Rt.i})),n.d(e,"findBackendFactory",(function(){return Rt.j})),n.d(e,"registerBackend",(function(){return Rt.p})),n.d(e,"backend",(function(){return Rt.a})),n.d(e,"setPlatform",(function(){return Rt.s})),n.d(e,"getKernel",(function(){return wt.c})),n.d(e,"getGradient",(function(){return wt.b})),n.d(e,"getKernelsForBackend",(function(){return wt.d})),n.d(e,"registerKernel",(function(){return wt.f})),n.d(e,"registerGradient",(function(){return wt.e})),n.d(e,"unregisterKernel",(function(){return wt.h})),n.d(e,"unregisterGradient",(function(){return wt.g})),n.d(e,"copyRegisteredKernels",(function(){return wt.a})),n.d(e,"customGrad",(function(){return qt.a})),n.d(e,"grad",(function(){return qt.b})),n.d(e,"grads",(function(){return qt.c})),n.d(e,"valueAndGrad",(function(){return qt.d})),n.d(e,"valueAndGrads",(function(){return qt.e})),n.d(e,"variableGrads",(function(){return qt.f})),n.d(e,"Environment",(function(){return h.b})),n.d(e,"env",(function(){return h.c})),n.d(e,"ENV",(function(){return h.a})),n.d(e,"version_core",(function(){return Dt})),n.d(e,"nextFrame",(function(){return ue.a})),n.d(e,"browser",(function(){return s})),n.d(e,"io",(function(){return r})),n.d(e,"math",(function(){return i})),n.d(e,"serialization",(function(){return o})),n.d(e,"test_util",(function(){return jt})),n.d(e,"util",(function(){return Mt})),n.d(e,"backend_util",(function(){return u})),n.d(e,"tensor_util",(function(){return Et})),n.d(e,"slice_util",(function(){return Ct})),n.d(e,"gather_util",(function(){return a})),n.d(e,"scatter_util",(function(){return Tt})),n.d(e,"device_util",(function(){return Ge})),n.d(e,"kernel_impls",(function(){return c})),n.d(e,"KernelBackend",(function(){return tn.b})),n.d(e,"DataStorage",(function(){return tn.a})),n.d(e,"Abs",(function(){return vt.a})),n.d(e,"Acos",(function(){return vt.b})),n.d(e,"Acosh",(function(){return vt.c})),n.d(e,"Add",(function(){return vt.d})),n.d(e,"AddN",(function(){return vt.e})),n.d(e,"All",(function(){return vt.f})),n.d(e,"Any",(function(){return vt.g})),n.d(e,"ArgMax",(function(){return vt.h})),n.d(e,"ArgMin",(function(){return vt.i})),n.d(e,"Asin",(function(){return vt.j})),n.d(e,"Asinh",(function(){return vt.k})),n.d(e,"Atan",(function(){return vt.l})),n.d(e,"Atanh",(function(){return vt.n})),n.d(e,"Atan2",(function(){return vt.m})),n.d(e,"AvgPool",(function(){return vt.o})),n.d(e,"AvgPoolBackprop",(function(){return vt.r})),n.d(e,"AvgPool3D",(function(){return vt.p})),n.d(e,"AvgPool3DBackprop",(function(){return vt.q})),n.d(e,"BatchMatMul",(function(){return vt.s})),n.d(e,"BatchToSpaceND",(function(){return vt.t})),n.d(e,"BroadcastTo",(function(){return vt.u})),n.d(e,"Cast",(function(){return vt.v})),n.d(e,"Ceil",(function(){return vt.w})),n.d(e,"ClipByValue",(function(){return vt.x})),n.d(e,"Complex",(function(){return vt.y})),n.d(e,"Concat",(function(){return vt.z})),n.d(e,"Conv2D",(function(){return vt.A})),n.d(e,"Conv2DBackpropFilter",(function(){return vt.B})),n.d(e,"Conv2DBackpropInput",(function(){return vt.C})),n.d(e,"Conv3D",(function(){return vt.D})),n.d(e,"Conv3DBackpropFilterV2",(function(){return vt.E})),n.d(e,"Conv3DBackpropInputV2",(function(){return vt.F})),n.d(e,"Cos",(function(){return vt.G})),n.d(e,"Cosh",(function(){return vt.H})),n.d(e,"Cumsum",(function(){return vt.J})),n.d(e,"CropAndResize",(function(){return vt.I})),n.d(e,"DepthToSpace",(function(){return vt.K})),n.d(e,"DepthwiseConv2dNative",(function(){return vt.L})),n.d(e,"DepthwiseConv2dNativeBackpropFilter",(function(){return vt.M})),n.d(e,"DepthwiseConv2dNativeBackpropInput",(function(){return vt.N})),n.d(e,"Diag",(function(){return vt.O})),n.d(e,"Dilation2D",(function(){return vt.P})),n.d(e,"Dilation2DBackpropInput",(function(){return vt.R})),n.d(e,"Dilation2DBackpropFilter",(function(){return vt.Q})),n.d(e,"Div",(function(){return vt.S})),n.d(e,"Elu",(function(){return vt.T})),n.d(e,"EluGrad",(function(){return vt.U})),n.d(e,"Erf",(function(){return vt.W})),n.d(e,"Equal",(function(){return vt.V})),n.d(e,"Exp",(function(){return vt.X})),n.d(e,"Expm1",(function(){return vt.Y})),n.d(e,"FFT",(function(){return vt.Z})),n.d(e,"Fill",(function(){return vt.ab})),n.d(e,"FlipLeftRight",(function(){return vt.bb})),n.d(e,"Floor",(function(){return vt.cb})),n.d(e,"FloorDiv",(function(){return vt.db})),n.d(e,"FusedBatchNorm",(function(){return vt.fb})),n.d(e,"GatherV2",(function(){return vt.jb})),n.d(e,"GatherNd",(function(){return vt.ib})),n.d(e,"Greater",(function(){return vt.kb})),n.d(e,"GreaterEqual",(function(){return vt.lb})),n.d(e,"Identity",(function(){return vt.nb})),n.d(e,"IFFT",(function(){return vt.mb})),n.d(e,"Imag",(function(){return vt.ob})),n.d(e,"IsFinite",(function(){return vt.pb})),n.d(e,"IsInf",(function(){return vt.qb})),n.d(e,"IsNan",(function(){return vt.rb})),n.d(e,"Less",(function(){return vt.ub})),n.d(e,"LessEqual",(function(){return vt.vb})),n.d(e,"LinSpace",(function(){return vt.wb})),n.d(e,"Log",(function(){return vt.xb})),n.d(e,"Log1p",(function(){return vt.yb})),n.d(e,"LogicalAnd",(function(){return vt.Ab})),n.d(e,"LogicalNot",(function(){return vt.Bb})),n.d(e,"LogicalOr",(function(){return vt.Cb})),n.d(e,"LogSoftmax",(function(){return vt.zb})),n.d(e,"LRN",(function(){return vt.sb})),n.d(e,"LRNBackprop",(function(){return vt.tb})),n.d(e,"Max",(function(){return vt.Db})),n.d(e,"Maximum",(function(){return vt.Jb})),n.d(e,"MaxPool",(function(){return vt.Eb})),n.d(e,"MaxPoolBackprop",(function(){return vt.Hb})),n.d(e,"MaxPool3D",(function(){return vt.Fb})),n.d(e,"MaxPool3DBackprop",(function(){return vt.Gb})),n.d(e,"MaxPoolWithArgmax",(function(){return vt.Ib})),n.d(e,"Mean",(function(){return vt.Kb})),n.d(e,"Min",(function(){return vt.Lb})),n.d(e,"Minimum",(function(){return vt.Mb})),n.d(e,"MirrorPad",(function(){return vt.Nb})),n.d(e,"Mod",(function(){return vt.Ob})),n.d(e,"Multiply",(function(){return vt.Pb})),n.d(e,"Negate",(function(){return vt.Qb})),n.d(e,"NotEqual",(function(){return vt.Ub})),n.d(e,"NonMaxSuppressionV3",(function(){return vt.Rb})),n.d(e,"NonMaxSuppressionV4",(function(){return vt.Sb})),n.d(e,"NonMaxSuppressionV5",(function(){return vt.Tb})),n.d(e,"OnesLike",(function(){return vt.Wb})),n.d(e,"OneHot",(function(){return vt.Vb})),n.d(e,"PadV2",(function(){return vt.Xb})),n.d(e,"Pool",(function(){return vt.Yb})),n.d(e,"Pow",(function(){return vt.Zb})),n.d(e,"Prelu",(function(){return vt.ac})),n.d(e,"Prod",(function(){return vt.bc})),n.d(e,"Range",(function(){return vt.cc})),n.d(e,"Real",(function(){return vt.dc})),n.d(e,"Reciprocal",(function(){return vt.ec})),n.d(e,"Relu",(function(){return vt.fc})),n.d(e,"Reshape",(function(){return vt.hc})),n.d(e,"ResizeNearestNeighbor",(function(){return vt.kc})),n.d(e,"ResizeNearestNeighborGrad",(function(){return vt.lc})),n.d(e,"ResizeBilinear",(function(){return vt.ic})),n.d(e,"ResizeBilinearGrad",(function(){return vt.jc})),n.d(e,"Relu6",(function(){return vt.gc})),n.d(e,"Reverse",(function(){return vt.mc})),n.d(e,"Round",(function(){return vt.oc})),n.d(e,"Rsqrt",(function(){return vt.pc})),n.d(e,"ScatterNd",(function(){return vt.qc})),n.d(e,"SelectV2",(function(){return vt.rc})),n.d(e,"Selu",(function(){return vt.sc})),n.d(e,"Slice",(function(){return vt.xc})),n.d(e,"Sin",(function(){return vt.vc})),n.d(e,"Sinh",(function(){return vt.wc})),n.d(e,"Sign",(function(){return vt.uc})),n.d(e,"Sigmoid",(function(){return vt.tc})),n.d(e,"Softplus",(function(){return vt.zc})),n.d(e,"Sqrt",(function(){return vt.Dc})),n.d(e,"Sum",(function(){return vt.Jc})),n.d(e,"SpaceToBatchND",(function(){return vt.Ac})),n.d(e,"SplitV",(function(){return vt.Cc})),n.d(e,"Softmax",(function(){return vt.yc})),n.d(e,"SquaredDifference",(function(){return vt.Fc})),n.d(e,"Square",(function(){return vt.Ec})),n.d(e,"Sub",(function(){return vt.Ic})),n.d(e,"SparseToDense",(function(){return vt.Bc})),n.d(e,"StridedSlice",(function(){return vt.Hc})),n.d(e,"Tan",(function(){return vt.Kc})),n.d(e,"Tanh",(function(){return vt.Lc})),n.d(e,"Tile",(function(){return vt.Mc})),n.d(e,"TopK",(function(){return vt.Nc})),n.d(e,"Transpose",(function(){return vt.Oc})),n.d(e,"Unique",(function(){return vt.Pc})),n.d(e,"Unpack",(function(){return vt.Qc})),n.d(e,"UnsortedSegmentSum",(function(){return vt.Rc})),n.d(e,"ZerosLike",(function(){return vt.Sc})),n.d(e,"Step",(function(){return vt.Gc})),n.d(e,"FromPixels",(function(){return vt.eb})),n.d(e,"RotateWithOffset",(function(){return vt.nc})),n.d(e,"_FusedMatMul",(function(){return vt.Tc})),n.d(e,"FusedConv2D",(function(){return vt.gb})),n.d(e,"FusedDepthwiseConv2D",(function(){return vt.hb}));var r={};n.r(r),n.d(r,"copyModel",(function(){return $})),n.d(r,"listModels",(function(){return z})),n.d(r,"moveModel",(function(){return B})),n.d(r,"removeModel",(function(){return L})),n.d(r,"browserFiles",(function(){return J})),n.d(r,"browserHTTPRequest",(function(){return ut})),n.d(r,"concatenateArrayBuffers",(function(){return d.d})),n.d(r,"decodeWeights",(function(){return d.e})),n.d(r,"encodeWeights",(function(){return d.f})),n.d(r,"fromMemory",(function(){return ht})),n.d(r,"getLoadHandlers",(function(){return b})),n.d(r,"getModelArtifactsInfoForJSON",(function(){return d.g})),n.d(r,"getSaveHandlers",(function(){return g})),n.d(r,"http",(function(){return ot})),n.d(r,"isHTTPScheme",(function(){return st})),n.d(r,"loadWeights",(function(){return nt})),n.d(r,"registerLoadRouter",(function(){return m})),n.d(r,"registerSaveRouter",(function(){return f})),n.d(r,"weightsLoaderFactory",(function(){return rt})),n.d(r,"withSaveHandler",(function(){return dt}));var i={};n.r(i),n.d(i,"confusionMatrix",(function(){return yt}));var s={};n.r(s),n.d(s,"toPixels",(function(){return Ot})),n.d(s,"fromPixels",(function(){return St}));var a={};n.r(a),n.d(a,"prepareAndValidate",(function(){return kt}));var o={};n.r(o),n.d(o,"Serializable",(function(){return At})),n.d(o,"SerializationMap",(function(){return Nt})),n.d(o,"registerClass",(function(){return It}));var u={};n.r(u),n.d(u,"axesAreInnerMostDims",(function(){return he.b})),n.d(u,"combineLocations",(function(){return he.c})),n.d(u,"computeOutAndReduceShapes",(function(){return he.d})),n.d(u,"expandShapeToKeepDim",(function(){return he.e})),n.d(u,"assertAxesAreInnerMostDims",(function(){return he.a})),n.d(u,"getAxesPermutation",(function(){return he.f})),n.d(u,"getUndoAxesPermutation",(function(){return he.h})),n.d(u,"getInnerMostAxes",(function(){return he.g})),n.d(u,"getBroadcastDims",(function(){return de.b})),n.d(u,"getReductionAxes",(function(){return de.c})),n.d(u,"assertAndGetBroadcastShape",(function(){return de.a})),n.d(u,"assertParamsConsistent",(function(){return pe.a})),n.d(u,"computeOutShape",(function(){return pe.b})),n.d(u,"computeDilation2DInfo",(function(){return fe.d})),n.d(u,"computePool2DInfo",(function(){return fe.e})),n.d(u,"computePool3DInfo",(function(){return fe.f})),n.d(u,"computeConv2DInfo",(function(){return fe.a})),n.d(u,"computeConv3DInfo",(function(){return fe.b})),n.d(u,"computeDefaultPad",(function(){return fe.c})),n.d(u,"tupleValuesAreOne",(function(){return fe.i})),n.d(u,"eitherStridesOrDilationsAreOne",(function(){return fe.h})),n.d(u,"convertConv2DDataFormat",(function(){return fe.g})),n.d(u,"getFusedDyActivation",(function(){return me.c})),n.d(u,"getFusedBiasGradient",(function(){return me.b})),n.d(u,"applyActivation",(function(){return me.a})),n.d(u,"shouldFuse",(function(){return me.d})),n.d(u,"PARALLELIZE_THRESHOLD",(function(){return ge.a})),n.d(u,"computeOptimalWindowSize",(function(){return ge.b})),n.d(u,"slice_util",(function(){return Ct})),n.d(u,"upcastType",(function(){return re.c})),n.d(u,"getImageCenter",(function(){return be})),n.d(u,"getReshaped",(function(){return ye})),n.d(u,"getPermuted",(function(){return ve})),n.d(u,"getReshapedPermuted",(function(){return we})),n.d(u,"getSliceBeginCoords",(function(){return xe})),n.d(u,"getSliceSize",(function(){return _e})),n.d(u,"prepareAndValidate",(function(){return kt})),n.d(u,"validateUpdateShape",(function(){return Tt.validateUpdateShape})),n.d(u,"validateInput",(function(){return Tt.validateInput})),n.d(u,"calculateShapes",(function(){return Tt.calculateShapes})),n.d(u,"SELU_SCALEALPHA",(function(){return Oe})),n.d(u,"SELU_SCALE",(function(){return Se})),n.d(u,"ERF_P",(function(){return ke})),n.d(u,"ERF_A1",(function(){return Te})),n.d(u,"ERF_A2",(function(){return Ce})),n.d(u,"ERF_A3",(function(){return Ae})),n.d(u,"ERF_A4",(function(){return Ne})),n.d(u,"ERF_A5",(function(){return Ie})),n.d(u,"warn",(function(){return Ee})),n.d(u,"log",(function(){return je})),n.d(u,"mergeRealAndImagArrays",(function(){return Me})),n.d(u,"splitRealAndImagArrays",(function(){return De})),n.d(u,"complexWithEvenIndex",(function(){return Re})),n.d(u,"complexWithOddIndex",(function(){return Pe})),n.d(u,"getComplexWithIndex",(function(){return Fe})),n.d(u,"assignToTypedArray",(function(){return ze})),n.d(u,"exponents",(function(){return Le})),n.d(u,"exponent",(function(){return $e})),n.d(u,"prepareSplitSize",(function(){return Be.a})),n.d(u,"segment_util",(function(){return qe})),n.d(u,"castTensor",(function(){return Ve})),n.d(u,"reshapeTensor",(function(){return Ue})),n.d(u,"linspaceImpl",(function(){return We}));var c={};n.r(c),n.d(c,"nonMaxSuppressionV3Impl",(function(){return He.a})),n.d(c,"nonMaxSuppressionV4Impl",(function(){return He.b})),n.d(c,"nonMaxSuppressionV5Impl",(function(){return He.c})),n.d(c,"split",(function(){return Qe})),n.d(c,"tile",(function(){return Xe})),n.d(c,"topkImpl",(function(){return Je})),n.d(c,"whereImpl",(function(){return Ze.a}));var l=n(5),h=(n(145),n(26)),d=n(38);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class p{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==p.instance&&(p.instance=new p),p.instance}static registerSaveRouter(t){p.getInstance().saveRouters.push(t)}static registerLoadRouter(t){p.getInstance().loadRouters.push(t)}static getSaveHandlers(t){return p.getHandlers(t,"save")}static getLoadHandlers(t,e){return p.getHandlers(t,"load",e)}static getHandlers(t,e,n){const r=[];return("load"===e?p.getInstance().loadRouters:p.getInstance().saveRouters).forEach(e=>{const i=e(t,n);null!==i&&r.push(i)}),r}}const f=t=>p.registerSaveRouter(t),m=t=>p.registerLoadRouter(t),g=t=>p.getSaveHandlers(t),b=(t,e)=>p.getLoadHandlers(t,e)
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */;function y(){if(!Object(h.c)().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const t="undefined"==typeof window?self:window,e=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB||t.shimIndexedDB;if(null==e)throw new Error("The current browser does not appear to support IndexedDB.");return e}function v(t){const e=t.result;e.createObjectStore("models_store",{keyPath:"modelPath"}),e.createObjectStore("model_info_store",{keyPath:"modelPath"})}class w{constructor(t){if(this.indexedDB=y(),null==t||!t)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=t}async save(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,t)}async load(){return this.databaseAction(this.modelPath)}databaseAction(t,e){return new Promise((t,n)=>{const r=this.indexedDB.open("tensorflowjs",1);r.onupgradeneeded=()=>v(r),r.onsuccess=()=>{const i=r.result;if(null==e){const e=i.transaction("models_store","readonly"),r=e.objectStore("models_store").get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return i.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));t(r.result.modelArtifacts)},r.onerror=t=>(i.close(),n(r.error)),e.oncomplete=()=>i.close()}else{const r=Object(d.g)(e),s=i.transaction("model_info_store","readwrite");let a=s.objectStore("model_info_store");const o=a.put({modelPath:this.modelPath,modelArtifactsInfo:r});let u;o.onsuccess=()=>{u=i.transaction("models_store","readwrite");const o=u.objectStore("models_store").put({modelPath:this.modelPath,modelArtifacts:e,modelArtifactsInfo:r});o.onsuccess=()=>t({modelArtifactsInfo:r}),o.onerror=t=>{a=s.objectStore("model_info_store");const e=a.delete(this.modelPath);e.onsuccess=()=>(i.close(),n(o.error)),e.onerror=t=>(i.close(),n(o.error))}},o.onerror=t=>(i.close(),n(o.error)),s.oncomplete=()=>{null==u?i.close():u.oncomplete=()=>i.close()}}},r.onerror=t=>n(r.error)})}}w.URL_SCHEME="indexeddb://";const x=t=>{return Object(h.c)().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(w.URL_SCHEME)?(e=t.slice(w.URL_SCHEME.length),new w(e)):null;var e};p.registerSaveRouter(x),p.registerLoadRouter(x);class _{constructor(){this.indexedDB=y()}async listModels(){return new Promise((t,e)=>{const n=this.indexedDB.open("tensorflowjs",1);n.onupgradeneeded=()=>v(n),n.onsuccess=()=>{const r=n.result,i=r.transaction("model_info_store","readonly"),s=i.objectStore("model_info_store").getAll();s.onsuccess=()=>{const e={};for(const t of s.result)e[t.modelPath]=t.modelArtifactsInfo;t(e)},s.onerror=t=>(r.close(),e(s.error)),i.oncomplete=()=>r.close()},n.onerror=t=>e(n.error)})}async removeModel(t){var e;return t=(e=t).startsWith(w.URL_SCHEME)?e.slice(w.URL_SCHEME.length):e,new Promise((e,n)=>{const r=this.indexedDB.open("tensorflowjs",1);r.onupgradeneeded=()=>v(r),r.onsuccess=()=>{const i=r.result,s=i.transaction("model_info_store","readwrite"),a=s.objectStore("model_info_store"),o=a.get(t);let u;o.onsuccess=()=>{if(null==o.result)return i.close(),n(new Error(`Cannot find model with path '${t}' in IndexedDB.`));{const r=a.delete(t),s=()=>{u=i.transaction("models_store","readwrite");const r=u.objectStore("models_store").delete(t);r.onsuccess=()=>e(o.result.modelArtifactsInfo),r.onerror=t=>n(o.error)};r.onsuccess=s,r.onerror=t=>(s(),i.close(),n(o.error))}},o.onerror=t=>(i.close(),n(o.error)),s.oncomplete=()=>{null==u?i.close():u.oncomplete=()=>i.close()}},r.onerror=t=>n(r.error)})}}var O=n(7);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const S="tensorflowjs_models",k="info",T="model_topology",C="weight_specs",A="weight_data",N="model_metadata";function I(t){return{info:[S,t,k].join("/"),topology:[S,t,T].join("/"),weightSpecs:[S,t,C].join("/"),weightData:[S,t,A].join("/"),modelMetadata:[S,t,N].join("/")}}function E(t){const e=t.split("/");if(e.length<3)throw new Error("Invalid key format: "+t);return e.slice(1,e.length-1).join("/")}class j{constructor(t){if(!Object(h.c)().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==t||!t)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=t,this.keys=I(this.modelPath)}async save(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const e=JSON.stringify(t.modelTopology),n=JSON.stringify(t.weightSpecs),r=Object(d.g)(t);try{return this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,e),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,Object(d.a)(t.weightData)),this.LS.setItem(this.keys.modelMetadata,JSON.stringify({format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,userDefinedMetadata:t.userDefinedMetadata})),{modelArtifactsInfo:r}}catch(t){throw this.LS.removeItem(this.keys.info),this.LS.removeItem(this.keys.topology),this.LS.removeItem(this.keys.weightSpecs),this.LS.removeItem(this.keys.weightData),this.LS.removeItem(this.keys.modelMetadata),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 t=JSON.parse(this.LS.getItem(this.keys.info));if(null==t)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if("JSON"!==t.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const e={},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.`);e.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.`);e.weightSpecs=r;const i=this.LS.getItem(this.keys.modelMetadata);if(null!=i){const t=JSON.parse(i);e.format=t.format,e.generatedBy=t.generatedBy,e.convertedBy=t.convertedBy,e.userDefinedMetadata=t.userDefinedMetadata}const s=this.LS.getItem(this.keys.weightData);if(null==s)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return e.weightData=Object(d.b)(s),e}}j.URL_SCHEME="localstorage://";const M=t=>{return Object(h.c)().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(j.URL_SCHEME)?(e=t.slice(j.URL_SCHEME.length),new j(e)):null;var e};p.registerSaveRouter(M),p.registerLoadRouter(M);class D{constructor(){Object(O.b)(Object(h.c)().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),Object(O.b)("undefined"==typeof window||void 0!==window.localStorage,()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){const t={},e=S+"/",n="/"+k;for(let r=0;r<this.LS.length;++r){const i=this.LS.key(r);if(i.startsWith(e)&&i.endsWith(n)){t[E(i)]=JSON.parse(this.LS.getItem(i))}}return t}async removeModel(t){var e;const n=I(t=(e=t).startsWith(j.URL_SCHEME)?e.slice(j.URL_SCHEME.length):e);if(null==this.LS.getItem(n.info))throw new Error(`Cannot find model at path '${t}'`);const r=JSON.parse(this.LS.getItem(n.info));return this.LS.removeItem(n.info),this.LS.removeItem(n.topology),this.LS.removeItem(n.weightSpecs),this.LS.removeItem(n.weightData),r}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class R{constructor(){this.managers={}}static getInstance(){return null==R.instance&&(R.instance=new R),R.instance}static registerManager(t,e){Object(O.b)(null!=t,()=>"scheme must not be undefined or null."),t.endsWith("://")&&(t=t.slice(0,t.indexOf("://"))),Object(O.b)(t.length>0,()=>"scheme must not be an empty string.");const n=R.getInstance();Object(O.b)(null==n.managers[t],()=>`A model store manager is already registered for scheme '${t}'.`),n.managers[t]=e}static getManager(t){const e=this.getInstance().managers[t];if(null==e)throw new Error(`Cannot find model manager for scheme '${t}'`);return e}static getSchemes(){return Object.keys(this.getInstance().managers)}}function P(t){if(-1===t.indexOf("://"))throw new Error("The url string provided does not contain a scheme. Supported schemes are: "+R.getSchemes().join(","));return{scheme:t.split("://")[0],path:t.split("://")[1]}}async function F(t,e,n=!1){Object(O.b)(t!==e,()=>`Old path and new path are the same: '${t}'`);const r=p.getLoadHandlers(t);Object(O.b)(r.length>0,()=>`Copying failed because no load handler is found for source URL ${t}.`),Object(O.b)(r.length<2,()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${t}.`);const i=r[0],s=p.getSaveHandlers(e);Object(O.b)(s.length>0,()=>`Copying failed because no save handler is found for destination URL ${e}.`),Object(O.b)(s.length<2,()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${e}.`);const a=s[0],o=P(t).scheme,u=P(t).path,c=o===P(t).scheme,l=await i.load();n&&c&&await R.getManager(o).removeModel(u);const h=await a.save(l);return n&&!c&&await R.getManager(o).removeModel(u),h.modelArtifactsInfo}async function z(){const t=R.getSchemes(),e={};for(const n of t){const t=await R.getManager(n).listModels();for(const r in t){e[n+"://"+r]=t[r]}}return e}async function L(t){const e=P(t);return R.getManager(e.scheme).removeModel(e.path)}async function $(t,e){return F(t,e,!1)}async function B(t,e){return F(t,e,!0)}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class q{fetch(t,e){return fetch(t,e)}now(){return performance.now()}encode(t,e){if("utf-8"!==e&&"utf8"!==e)throw new Error("Browser's encoder only supports utf-8, but got "+e);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(t)}decode(t,e){return new TextDecoder(e).decode(t)}}if(Object(h.c)().get("IS_BROWSER")){Object(h.c)().setPlatform("browser",new q);try{R.registerManager(j.URL_SCHEME,new D)}catch(t){}try{R.registerManager(w.URL_SCHEME,new _)}catch(t){}}n(298);var V=n(39),U=n(12),W=n(71),G=n(157),H=n(6);
/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
Object(l.b)();const K={buffer:V.a,cast:U.a,clone:W.a,print:G.a};Object(H.e)(K);function Q(t){return new Promise(t=>setTimeout(t)).then(t)}class X{constructor(t){if(!Object(h.c)().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");t.startsWith(X.URL_SCHEME)&&(t=t.slice(X.URL_SCHEME.length)),null!=t&&0!==t.length||(t="model"),this.modelTopologyFileName=t+".json",this.weightDataFileName=t+".weights.bin"}async save(t){if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");const e=window.URL.createObjectURL(new Blob([t.weightData],{type:"application/octet-stream"}));if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{const n=[{paths:["./"+this.weightDataFileName],weights:t.weightSpecs}],r={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,weightsManifest:n},i=window.URL.createObjectURL(new Blob([JSON.stringify(r)],{type:"application/json"})),s=null==this.jsonAnchor?document.createElement("a"):this.jsonAnchor;if(s.download=this.modelTopologyFileName,s.href=i,await Q(()=>s.dispatchEvent(new MouseEvent("click"))),null!=t.weightData){const t=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;t.download=this.weightDataFileName,t.href=e,await Q(()=>t.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:Object(d.g)(t)}}}}X.URL_SCHEME="downloads://";class Y{constructor(t){if(null==t||t.length<1)throw new Error("When calling browserFiles, at least 1 file is required, but received "+t);this.files=t}async load(){const t=this.files[0],e=this.files.slice(1);return new Promise((n,r)=>{const i=new FileReader;i.onload=i=>{const s=JSON.parse(i.target.result),a=s.modelTopology;if(null==a)return void r(new Error("modelTopology field is missing from file "+t.name));0===e.length&&n({modelTopology:a});const o=s.weightsManifest;if(null==o)return void r(new Error("weightManifest field is missing from file "+t.name));let u;try{u=this.checkManifestAndWeightFiles(o,e)}catch(t){return void r(t)}const c=[],l=[],h=[];o.forEach(t=>{t.paths.forEach(t=>{l.push(t),h.push(null)}),c.push(...t.weights)}),o.forEach(t=>{t.paths.forEach(t=>{const e=new FileReader;e.onload=e=>{const r=e.target.result,i=l.indexOf(t);h[i]=r,-1===h.indexOf(null)&&n({modelTopology:a,weightSpecs:c,weightData:Object(d.d)(h),format:s.format,generatedBy:s.generatedBy,convertedBy:s.convertedBy,userDefinedMetadata:s.userDefinedMetadata})},e.onerror=e=>r(`Failed to weights data from file of path '${t}'.`),e.readAsArrayBuffer(u[t])})})},i.onerror=e=>r(`Failed to read model topology and weights manifest JSON from file '${t.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),i.readAsText(t)})}checkManifestAndWeightFiles(t,e){const n=[],r=e.map(t=>Object(d.c)(t.name)),i={};for(const s of t)s.paths.forEach(t=>{const s=Object(d.c)(t);if(-1!==n.indexOf(s))throw new Error(`Duplicate file basename found in weights manifest: '${s}'`);if(n.push(s),-1===r.indexOf(s))throw new Error(`Weight file with basename '${s}' is not provided.`);i[t]=e[r.indexOf(s)]});if(n.length!==e.length)throw new Error(`Mismatch in the number of files in weights manifest (${n.length}) and the number of weight files provided (${e.length}).`);return i}}function J(t){return new Y(t)}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function Z(t,e,n,r){!function(t){Object(O.b)(null!=t&&Array.isArray(t)&&t.length>0,()=>"promises must be a none empty array")}(t),function(t,e){Object(O.b)(t>=0&&t<=1,()=>"Progress fraction must be in range [0, 1], but got startFraction "+t),Object(O.b)(e>=0&&e<=1,()=>"Progress fraction must be in range [0, 1], but got endFraction "+e),Object(O.b)(e>=t,()=>`startFraction must be no more than endFraction, but got startFraction ${t} and endFraction `+e)}(n=null==n?0:n,r=null==r?1:r);let i=0;return Promise.all(t.map(s=>(s.then(s=>{const a=n+ ++i/t.length*(r-n);return e(a),s}),s)))}p.registerSaveRouter(t=>Object(h.c)().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(X.URL_SCHEME)?function(t="model"){return new X(t)}(t.slice(X.URL_SCHEME.length)):null);var tt=n(152);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */async function et(t,e){null==e&&(e={});const n=null==e.fetchFunc?Object(h.c)().platform.fetch:e.fetchFunc,r=t.map(t=>n(t,e.requestInit,{isBinary:!0})),i=(null==e.onProgress?await Promise.all(r):await Z(r,e.onProgress,0,.5)).map(t=>t.arrayBuffer());return null==e.onProgress?await Promise.all(i):await Z(i,e.onProgress,.5,1)}async function nt(t,e="",n,r){return rt(t=>et(t,{requestInit:r}))(t,e,n)}function rt(t){return async(e,n="",r)=>{const i=e.map(()=>!1),s={},a=null!=r?r.map(()=>!1):[],o=[];if(e.forEach((t,e)=>{let n=0;t.weights.forEach(t=>{const u="quantization"in t?t.quantization.dtype:t.dtype,c=tt.a[u]*O.N(t.shape),l=()=>{i[e]=!0,null==s[e]&&(s[e]=[]),s[e].push({manifestEntry:t,groupOffset:n,sizeBytes:c})};null!=r?r.forEach((e,n)=>{e===t.name&&(l(),a[n]=!0)}):l(),o.push(t.name),n+=c})}),!a.every(t=>t)){const t=r.filter((t,e)=>!a[e]);throw new Error("Could not find weights in manifest with names: "+t.join(", ")+". \nManifest JSON has weights with names: "+o.join(", ")+".")}const u=i.reduce((t,e,n)=>(e&&t.push(n),t),[]),c=[];u.forEach(t=>{e[t].paths.forEach(t=>{const e=n+(n.endsWith("/")?"":"/")+t;c.push(e)})});const l=await t(c),h={};let p=0;return u.forEach(t=>{const n=e[t].paths.length;let r=0;for(let t=0;t<n;t++)r+=l[p+t].byteLength;const i=new ArrayBuffer(r),a=new Uint8Array(i);let o=0;for(let t=0;t<n;t++){const e=new Uint8Array(l[p+t]);a.set(e,o),o+=e.byteLength}s[t].forEach(t=>{const e=i.slice(t.groupOffset,t.groupOffset+t.sizeBytes),n=Object(d.e)(e,[t.manifestEntry]);for(const t in n)h[t]=n[t]}),p+=n}),h}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class it{constructor(t,e){if(this.DEFAULT_METHOD="POST",null==e&&(e={}),this.weightPathPrefix=e.weightPathPrefix,this.onProgress=e.onProgress,this.weightUrlConverter=e.weightUrlConverter,null!=e.fetchFunc?(Object(O.b)("function"==typeof e.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=e.fetchFunc):this.fetch=Object(h.c)().platform.fetch,Object(O.b)(null!=t&&t.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(t)&&Object(O.b)(2===t.length,()=>`URL paths for http must have a length of 2, (actual length is ${t.length}).`),this.path=t,null!=e.requestInit&&null!=e.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=e.requestInit||{}}async save(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");const e=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);e.body=new FormData;const n=[{paths:["./model.weights.bin"],weights:t.weightSpecs}],r={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,userDefinedMetadata:t.userDefinedMetadata,weightsManifest:n};e.body.append("model.json",new Blob([JSON.stringify(r)],{type:"application/json"}),"model.json"),null!=t.weightData&&e.body.append("model.weights.bin",new Blob([t.weightData],{type:"application/octet-stream"}),"model.weights.bin");const i=await this.fetch(this.path,e);if(i.ok)return{modelArtifactsInfo:Object(d.g)(t),responses:[i]};throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status "+i.status+".")}async load(){const t=await this.fetch(this.path,this.requestInit);if(!t.ok)throw new Error(`Request to ${this.path} failed with status code `+t.status+". Please verify this URL points to the model JSON of the model to load.");let e;try{e=await t.json()}catch(t){let e=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?e+=" 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.":e+=" Please make sure the server is serving valid JSON for this request.",new Error(e)}const n=e.modelTopology,r=e.weightsManifest,i=e.generatedBy,s=e.convertedBy,a=e.format,o=e.userDefinedMetadata;if(null==n&&null==r)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);let u,c;if(null!=r){const t=await this.loadWeights(r);[u,c]=t}const l={modelTopology:n,weightSpecs:u,weightData:c,userDefinedMetadata:o,generatedBy:i,convertedBy:s,format:a},h=e.modelInitializer;return h&&(l.modelInitializer=h),l}async loadWeights(t){const e=Array.isArray(this.path)?this.path[1]:this.path,[n,r]=function(t){const e=t.lastIndexOf("/"),n=t.lastIndexOf("?"),r=t.substring(0,e),i=n>e?t.substring(n):"";return[r+"/",i]}(e),i=this.weightPathPrefix||n,s=[];for(const e of t)s.push(...e.weights);const a=[],o=[];for(const e of t)for(const t of e.paths)null!=this.weightUrlConverter?o.push(this.weightUrlConverter(t)):a.push(i+t+r);this.weightUrlConverter&&a.push(...await Promise.all(o));const u=await et(a,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[s,Object(d.d)(u)]}}function st(t){return null!=t.match(it.URL_SCHEME_REGEX)}it.URL_SCHEME_REGEX=/^https?:\/\//;const at=(t,e)=>{if("undefined"==typeof fetch&&(null==e||null==e.fetchFunc))return null;{let n=!0;if(n=Array.isArray(t)?t.every(t=>st(t)):st(t),n)return ot(t,e)}return null};function ot(t,e){return new it(t,e)}function ut(t,e){return ot(t,e)}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */p.registerSaveRouter(at),p.registerLoadRouter(at);class ct{constructor(t){this.modelArtifacts=t}async load(){return this.modelArtifacts}}class lt{constructor(t){this.saveHandler=t}async save(t){return this.saveHandler(t)}}function ht(t,e,n,r){if(1===arguments.length){return null!=t.modelTopology||null!=t.weightSpecs?new ct(t):(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 ct({modelTopology:t}))}return 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 ct({modelTopology:t,weightSpecs:e,weightData:n,trainingConfig:r})}function dt(t){return new lt(t)}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var pt=n(1),ft=n(29),mt=n(115),gt=n(4),bt=n(31);const yt=Object(gt.b)({confusionMatrix_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n){const r=Object(pt.a)(t,"labels","confusionMatrix"),i=Object(pt.a)(e,"predictions","confusionMatrix");O.b(null==n||n>0&&Number.isInteger(n),()=>"If provided, numClasses must be a positive integer, but got "+n),O.b(1===r.rank,()=>"Expected the rank of labels to be 1, but got "+r.rank),O.b(1===i.rank,()=>"Expected the rank of predictions to be 1, but got "+i.rank),O.b(r.shape[0]===i.shape[0],()=>`Mismatch in the number of examples: ${r.shape[0]} vs. ${i.shape[0]}. Labels and predictions should have the same number of elements.`),O.b(n>0&&Number.isInteger(n),()=>"numClasses is required to be a positive integer, but got "+n);const s=Object(mt.a)(Object(U.a)(r,"int32"),n),a=Object(mt.a)(Object(U.a)(i,"int32"),n),o=Object(bt.a)(s),u=Object(ft.a)(o,a);return Object(U.a)(u,"int32")}});
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var vt=n(3),wt=n(74),xt=n(188);
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
let _t;async function Ot(t,e){let n=Object(pt.a)(t,"img","toPixels");if(!(t instanceof H.a)){const t=n;n=Object(U.a)(t,"int32"),t.dispose()}if(2!==n.rank&&3!==n.rank)throw new Error(`toPixels only supports rank 2 or 3 tensors, got rank ${n.rank}.`);const[r,i]=n.shape.slice(0,2),s=2===n.rank?1:n.shape[2];if(s>4||2===s)throw new Error("toPixels only supports depth of size 1, 3 or 4 but got "+s);if("float32"!==n.dtype&&"int32"!==n.dtype)throw new Error(`Unsupported type for toPixels: ${n.dtype}. Please use float32 or int32 tensors.`);const a=await n.data(),o="float32"===n.dtype?255:1,u=new Uint8ClampedArray(i*r*4);for(let t=0;t<r*i;++t){const e=[0,0,0,255];for(let r=0;r<s;r++){const i=a[t*s+r];if("float32"===n.dtype){if(i<0||i>1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${i}.`)}else if("int32"===n.dtype&&(i<0||i>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${i}.`);1===s?(e[0]=i*o,e[1]=i*o,e[2]=i*o):e[r]=i*o}const r=4*t;u[r+0]=Math.round(e[0]),u[r+1]=Math.round(e[1]),u[r+2]=Math.round(e[2]),u[r+3]=Math.round(e[3])}if(null!=e){e.width=i,e.height=r;const t=e.getContext("2d"),n=new ImageData(u,i,r);t.putImageData(n,0,0)}return n!==t&&n.dispose(),u}const St=Object(gt.b)({fromPixels_:function(t,e=3){if(e>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==t)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let n=!1,r=!1,i=!1,s=!1,a=!1;if(t.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&t instanceof ImageData)r=!0;else if("undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement)i=!0;else if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement)s=!0;else{if(null==t.getContext)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 "+t.constructor.name);a=!0}if(i){const e=2;if(i&&t.readyState<e)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element.")}if(null!=Object(wt.c)(vt.eb,l.a.backendName)){const n={pixels:t},r={numChannels:e};return l.a.runKernel(vt.eb,n,r)}const[o,u]=i?[t.videoWidth,t.videoHeight]:[t.width,t.height];let c,h;if(a?c=t.getContext("2d").getImageData(0,0,o,u).data:r||n?c=t.data:(s||i)&&(null==_t&&(_t=document.createElement("canvas").getContext("2d")),_t.canvas.width=o,_t.canvas.height=u,_t.drawImage(t,0,0,o,u),c=_t.getImageData(0,0,o,u).data),4===e)h=new Int32Array(c);else{const t=o*u;h=new Int32Array(t*e);for(let n=0;n<t;n++)for(let t=0;t<e;++t)h[n*e+t]=c[4*n+t]}const d=[u,o,e];return Object(xt.a)(h,d,"int32")}});function kt(t,e){if(t.rank<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${t.rank}.`);if(e.rank<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${e.rank}.`);if("int32"!==e.dtype)throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.shape[e.rank-1]>t.rank)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${e.shape[e.rank-1]} vs. ${t.rank}`);if(0===t.size)throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${t.shape}.`);const n=e.shape,r=n[n.length-1];let i=1;for(let t=0;t<n.length-1;++t)i*=n[t];const s=t.shape,a=n.slice();a.pop();let o=1;for(let e=r;e<t.rank;++e)o*=s[e],a.push(s[e]);const u=[...Object(O.j)(t.shape).map(t=>t/o),1].slice(0,r);return[a,i,o,u]}var Tt=n(121),Ct=n(52);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class At{getClassName(){return this.constructor.className}static fromConfig(t,e){return new t(e)}}class Nt{constructor(){this.classNameMap={}}static getMap(){return null==Nt.instance&&(Nt.instance=new Nt),Nt.instance}static register(t){Nt.getMap().classNameMap[t.className]=[t,t.fromConfig]}}function It(t){Object(O.b)(null!=t.className,()=>"Class being registered does not have the static className property defined."),Object(O.b)("string"==typeof t.className,()=>"className is required to be a string, but got type "+typeof t.className),Object(O.b)(t.className.length>0,()=>"Class being registered has an empty-string as its className, which is disallowed."),Nt.register(t)}var Et=n(25),jt=n(143),Mt=n(10);
/** @license See the LICENSE file. */
const Dt="2.7.0";var Rt=n(22),Pt=n(13),Ft=n(16),zt=n(9),Lt=n(35),$t=n(27),Bt=n(23),qt=n(33),Vt=n(15);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class Ut extends At{minimize(t,e=!1,n){const{value:r,grads:i}=this.computeGradients(t,n);if(null!=n){const t=n.map(t=>({name:t.name,tensor:i[t.name]}));this.applyGradients(t)}else this.applyGradients(i);return Object(Rt.d)(i),e?r:(r.dispose(),null)}get iterations(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(t,e){return Object(qt.f)(t,e)}dispose(){null!=this.iterations_&&Object(Rt.d)(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:Object(Vt.a)(this.iterations_,"int32")}}async getWeights(){throw new Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(t){throw new Error("setWeights() is not implemented for this optimizer class "+this.getClassName())}async extractIterations(t){return this.iterations_=(await t[0].tensor.data())[0],t.slice(1)}}Object.defineProperty(Ut,Symbol.hasInstance,{value:t=>null!=t.minimize&&null!=t.computeGradients&&null!=t.applyGradients});
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class Wt extends Ut{constructor(t,e,n=null){super(),this.learningRate=t,this.rho=e,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],null==n&&(this.epsilon=l.a.backend.epsilon())}applyGradients(t){(Array.isArray(t)?t.map(t=>t.name):Object.keys(t)).forEach((e,n)=>{const r=l.a.registeredVariables[e];null==this.accumulatedGrads[n]&&(this.accumulatedGrads[n]={originalName:e+"/accum_grad",variable:Object(Rt.t)(()=>Object(Bt.a)(r).variable(!1))}),null==this.accumulatedUpdates[n]&&(this.accumulatedUpdates[n]={originalName:e+"/accum_var",variable:Object(Rt.t)(()=>Object(Bt.a)(r).variable(!1))});const i=Array.isArray(t)?t[n].tensor:t[e];if(null==i)return;const s=this.accumulatedGrads[n].variable,a=this.accumulatedUpdates[n].variable;Object(Rt.t)(()=>{const t=Object(Pt.a)(Object(zt.a)(s,this.rho),Object(zt.a)(Object($t.a)(i),1-this.rho)),e=Object(zt.a)(Object(Ft.a)(Object(Lt.a)(Object(Pt.a)(a,this.epsilon)),Object(Lt.a)(Object(Pt.a)(s,this.epsilon))),i),n=Object(Pt.a)(Object(zt.a)(a,this.rho),Object(zt.a)(Object($t.a)(e),1-this.rho));s.assign(t),a.assign(n);const o=Object(Pt.a)(Object(zt.a)(e,-this.learningRate),r);r.assign(o)})}),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&(Object(Rt.d)(this.accumulatedGrads.map(t=>t.variable)),Object(Rt.d)(this.accumulatedUpdates.map(t=>t.variable)))}async getWeights(){const t=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(t.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(t){const e=(t=await this.extractIterations(t)).length/2;this.accumulatedGrads=t.slice(0,e).map(t=>({originalName:t.name,variable:t.tensor.variable(!1)})),this.accumulatedUpdates=t.slice(e,2*e).map(t=>({originalName:t.name,variable:t.tensor.variable(!1)}))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(t,e){return new t(e.learningRate,e.rho,e.epsilon)}}Wt.className="Adadelta",It(Wt);var Gt=n(123);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Ht extends Ut{constructor(t,e=.1){super(),this.learningRate=t,this.initialAccumulatorValue=e,this.accumulatedGrads=[]}applyGradients(t){(Array.isArray(t)?t.map(t=>t.name):Object.keys(t)).forEach((e,n)=>{const r=l.a.registeredVariables[e];if(null==this.accumulatedGrads[n]){const t=!1;this.accumulatedGrads[n]={originalName:e+"/accumulator",variable:Object(Rt.t)(()=>Object(Gt.a)(r.shape,this.initialAccumulatorValue).variable(t))}}const i=Array.isArray(t)?t[n].tensor:t[e];if(null==i)return;const s=this.accumulatedGrads[n].variable;Object(Rt.t)(()=>{const t=Object(Pt.a)(s,Object($t.a)(i));s.assign(t);const e=Object(Pt.a)(Object(zt.a)(Object(Ft.a)(i,Object(Lt.a)(Object(Pt.a)(t,l.a.backend.epsilon()))),-this.learningRate),r);r.assign(e)})}),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&Object(Rt.d)(this.accumulatedGrads.map(t=>t.variable))}async getWeights(){return[await this.saveIterations()].concat(this.accumulatedGrads.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(t){t=await this.extractIterations(t);this.accumulatedGrads=t.map(t=>({originalName:t.name,variable:t.tensor.variable(!1)}))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(t,e){return new t(e.learningRate,e.initialAccumulatorValue)}}Ht.className="Adagrad",It(Ht);var Kt=n(44),Qt=n(14);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class Xt extends Ut{constructor(t,e,n,r=null){super(),this.learningRate=t,this.beta1=e,this.beta2=n,this.epsilon=r,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],Object(Rt.t)(()=>{this.accBeta1=Object(Vt.a)(e).variable(),this.accBeta2=Object(Vt.a)(n).variable()}),null==r&&(this.epsilon=l.a.backend.epsilon())}applyGradients(t){const e=Array.isArray(t)?t.map(t=>t.name):Object.keys(t);Object(Rt.t)(()=>{const n=Object(Qt.a)(1,this.accBeta1),r=Object(Qt.a)(1,this.accBeta2);e.forEach((e,i)=>{const s=l.a.registeredVariables[e];null==this.accumulatedFirstMoment[i]&&(this.accumulatedFirstMoment[i]={originalName:e+"/m",variable:Object(Rt.t)(()=>Object(Bt.a)(s).variable(!1))}),null==this.accumulatedSecondMoment[i]&&(this.accumulatedSecondMoment[i]={originalName:e+"/v",variable:Object(Rt.t)(()=>Object(Bt.a)(s).variable(!1))});const a=Array.isArray(t)?t[i].tensor:t[e];if(null==a)return;const o=this.accumulatedFirstMoment[i].variable,u=this.accumulatedSecondMoment[i].variable,c=Object(Pt.a)(Object(zt.a)(o,this.beta1),Object(zt.a)(a,1-this.beta1)),h=Object(Pt.a)(Object(zt.a)(u,this.beta2),Object(zt.a)(Object($t.a)(a),1-this.beta2)),d=Object(Ft.a)(c,n),p=Object(Ft.a)(h,r);o.assign(c),u.assign(h);const f=Object(Pt.a)(Object(zt.a)(Object(Ft.a)(d,Object(Pt.a)(Object(Lt.a)(p),this.epsilon)),-this.learningRate),s);s.assign(f)}),this.accBeta1.assign(Object(zt.a)(this.accBeta1,this.beta1)),this.accBeta2.assign(Object(zt.a)(this.accBeta2,this.beta2))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&Object(Rt.d)(this.accumulatedFirstMoment.map(t=>t.variable)),null!=this.accumulatedSecondMoment&&Object(Rt.d)(this.accumulatedSecondMoment.map(t=>t.variable))}async getWeights(){const t=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(t.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(t){t=await this.extractIterations(t),Object(Rt.t)(()=>{this.accBeta1.assign(Object(Kt.a)(this.beta1,this.iterations_+1)),this.accBeta2.assign(Object(Kt.a)(this.beta2,this.iterations_+1))});const e=t.length/2;this.accumulatedFirstMoment=t.slice(0,e).map(t=>({originalName:t.name,variable:t.tensor.variable(!1)})),this.accumulatedSecondMoment=t.slice(e,2*e).map(t=>({originalName:t.name,variable:t.tensor.variable(!1)}))}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}static fromConfig(t,e){return new t(e.learningRate,e.beta1,e.beta2,e.epsilon)}}Xt.className="Adam",It(Xt);var Yt=n(41),Jt=n(68);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class Zt extends Ut{constructor(t,e,n,r=null,i=0){super(),this.learningRate=t,this.beta1=e,this.beta2=n,this.epsilon=r,this.decay=i,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],Object(Rt.t)(()=>{this.iteration=Object(Vt.a)(0).variable(),this.accBeta1=Object(Vt.a)(e).variable()}),null==r&&(this.epsilon=l.a.backend.epsilon())}applyGradients(t){const e=Array.isArray(t)?t.map(t=>t.name):Object.keys(t);Object(Rt.t)(()=>{const n=Object(Qt.a)(1,this.accBeta1),r=Object(Ft.a)(-this.learningRate,Object(Pt.a)(Object(zt.a)(this.iteration,this.decay),1));e.forEach((e,i)=>{const s=l.a.registeredVariables[e];null==this.accumulatedFirstMoment[i]&&(this.accumulatedFirstMoment[i]={originalName:e+"/m",variable:Object(Bt.a)(s).variable(!1)}),null==this.accumulatedWeightedInfNorm[i]&&(this.accumulatedWeightedInfNorm[i]={originalName:e+"/v",variable:Object(Bt.a)(s).variable(!1)});const a=Array.isArray(t)?t[i].tensor:t[e];if(null==a)return;const o=this.accumulatedFirstMoment[i].variable,u=this.accumulatedWeightedInfNorm[i].variable,c=Object(Pt.a)(Object(zt.a)(o,this.beta1),Object(zt.a)(a,1-this.beta1)),h=Object(zt.a)(u,this.beta2),d=Object(Yt.a)(a),p=Object(Jt.a)(h,d);o.assign(c),u.assign(p);const f=Object(Pt.a)(Object(zt.a)(Object(Ft.a)(r,n),Object(Ft.a)(c,Object(Pt.a)(p,this.epsilon))),s);s.assign(f)}),this.iteration.assign(Object(Pt.a)(this.iteration,1)),this.accBeta1.assign(Object(zt.a)(this.accBeta1,this.beta1))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&Object(Rt.d)(this.accumulatedFirstMoment.map(t=>t.variable)),null!=this.accumulatedWeightedInfNorm&&Object(Rt.d)(this.accumulatedWeightedInfNorm.map(t=>t.variable))}async getWeights(){throw new Error("getWeights() is not implemented for Adamax yet.")}async setWeights(t){throw new Error("setWeights() is not implemented for Adamax yet.")}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}}static fromConfig(t,e){return new t(e.learningRate,e.beta1,e.beta2,e.epsilon,e.decay)}}Zt.className="Adamax",It(Zt);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class te extends Ut{constructor(t){super(),this.learningRate=t,this.setLearningRate(t)}applyGradients(t){(Array.isArray(t)?t.map(t=>t.name):Object.keys(t)).forEach((e,n)=>{const r=Array.isArray(t)?t[n].tensor:t[e];if(null==r)return;const i=l.a.registeredVariables[e];Object(Rt.t)(()=>{const t=Object(Pt.a)(Object(zt.a)(this.c,r),i);i.assign(t)})}),this.incrementIterations()}setLearningRate(t){this.learningRate=t,null!=this.c&&this.c.dispose(),this.c=Object(Rt.l)(Object(Vt.a)(-t))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(t){if(0!==(t=await this.extractIterations(t)).length)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(t,e){return new t(e.learningRate)}}te.className="SGD",It(te);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class ee extends te{constructor(t,e,n=!1){super(t),this.learningRate=t,this.momentum=e,this.useNesterov=n,this.accumulations=[],this.m=Object(Vt.a)(this.momentum)}applyGradients(t){(Array.isArray(t)?t.map(t=>t.name):Object.keys(t)).forEach((e,n)=>{const r=l.a.registeredVariables[e];if(null==this.accumulations[n]){const t=!1;this.accumulations[n]={originalName:e+"/momentum",variable:Object(Rt.t)(()=>Object(Bt.a)(r).variable(t))}}const i=this.accumulations[n].variable,s=Array.isArray(t)?t[n].tensor:t[e];null!=s&&Object(Rt.t)(()=>{let t;const e=Object(Pt.a)(Object(zt.a)(this.m,i),s);t=this.useNesterov?Object(Pt.a)(Object(zt.a)(this.c,Object(Pt.a)(s,Object(zt.a)(e,this.m))),r):Object(Pt.a)(Object(zt.a)(this.c,e),r),i.assign(e),r.assign(t)})}),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&Object(Rt.d)(this.accumulations.map(t=>t.variable))}setMomentum(t){this.momentum=t}async getWeights(){return[await this.saveIterations()].concat(this.accumulations.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(t){t=await this.extractIterations(t);this.accumulations=t.map(t=>({originalName:t.name,variable:t.tensor.variable(!1)}))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(t,e){return new t(e.learningRate,e.momentum,e.useNesterov)}}ee.className="Momentum",It(ee);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class ne extends Ut{constructor(t,e=.9,n=0,r=null,i=!1){if(super(),this.learningRate=t,this.decay=e,this.momentum=n,this.epsilon=r,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=i,null==r&&(this.epsilon=l.a.backend.epsilon()),null==t)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(t){(Array.isArray(t)?t.map(t=>t.name):Object.keys(t)).forEach((e,n)=>{const r=l.a.registeredVariables[e];null==this.accumulatedMeanSquares[n]&&(this.accumulatedMeanSquares[n]={originalName:e+"/rms",variable:Object(Rt.t)(()=>Object(Bt.a)(r).variable(!1))}),null==this.accumulatedMoments[n]&&(this.accumulatedMoments[n]={originalName:e+"/momentum",variable:Object(Rt.t)(()=>Object(Bt.a)(r).variable(!1))}),null==this.accumulatedMeanGrads[n]&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:e+"/mg",variable:Object(Rt.t)(()=>Object(Bt.a)(r).variable(!1))});const i=Array.isArray(t)?t[n].tensor:t[e];if(null==i)return;const s=this.accumulatedMeanSquares[n].variable,a=this.accumulatedMoments[n].variable;Object(Rt.t)(()=>{const t=Object(Pt.a)(Object(zt.a)(s,this.decay),Object(zt.a)(Object($t.a)(i),1-this.decay));if(this.centered){const e=this.accumulatedMeanGrads[n].variable,o=Object(Pt.a)(Object(zt.a)(e,this.decay),Object(zt.a)(i,1-this.decay)),u=Object(Ft.a)(Object(zt.a)(i,this.learningRate),Object(Lt.a)(Object(Qt.a)(t,Object(Pt.a)(Object($t.a)(o),this.epsilon)))),c=Object(Pt.a)(Object(zt.a)(a,this.momentum),u);s.assign(t),e.assign(o),a.assign(c);const l=Object(Qt.a)(r,c);r.assign(l)}else{const t=Object(Pt.a)(Object(zt.a)(s,this.decay),Object(zt.a)(Object($t.a)(i),1-this.decay)),e=Object(Pt.a)(Object(zt.a)(a,this.momentum),Object(Ft.a)(Object(zt.a)(i,this.learningRate),Object(Lt.a)(Object(Pt.a)(t,this.epsilon))));s.assign(t),a.assign(e);const n=Object(Qt.a)(r,e);r.assign(n)}})}),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&Object(Rt.d)(this.accumulatedMeanSquares.map(t=>t.variable)),null!=this.accumulatedMeanGrads&&this.centered&&Object(Rt.d)(this.accumulatedMeanGrads.map(t=>t.variable)),null!=this.accumulatedMoments&&Object(Rt.d)(this.accumulatedMoments.map(t=>t.variable))}async getWeights(){const t=[...this.accumulatedMeanSquares,...this.accumulatedMoments];return this.centered&&t.push(...this.accumulatedMeanGrads),[await this.saveIterations()].concat(t.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(t){t=await this.extractIterations(t);const e=this.centered?t.length/3:t.length/2;this.accumulatedMeanSquares=t.slice(0,e).map(t=>({originalName:t.name,variable:t.tensor.variable(!1)})),this.accumulatedMoments=t.slice(e,2*e).map(t=>({originalName:t.name,variable:t.tensor.variable(!1)})),this.centered&&(this.accumulatedMeanGrads=t.slice(2*e,3*e).map(t=>({originalName:t.name,variable:t.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}}static fromConfig(t,e){return new t(e.learningRate,e.decay,e.momentum,e.epsilon,e.centered)}}ne.className="RMSProp",It(ne);var re=n(97),ie=n(19),se=n(34);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class ae{static sgd(t){return new te(t)}static momentum(t,e,n=!1){return new ee(t,e,n)}static rmsprop(t,e=.9,n=0,r=null,i=!1){return new ne(t,e,n,r,i)}static adam(t=.001,e=.9,n=.999,r=null){return new Xt(t,e,n,r)}static adadelta(t=.001,e=.95,n=null){return new Wt(t,e,n)}static adamax(t=.002,e=.9,n=.999,r=null,i=0){return new Zt(t,e,n,r,i)}static adagrad(t,e=.1){return new Ht(t,e)}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const oe={sgd:ae.sgd,momentum:ae.momentum,adadelta:ae.adadelta,adagrad:ae.adagrad,rmsprop:ae.rmsprop,adamax:ae.adamax,adam:ae.adam};var ue=n(253),ce=n(77),le=n(58),he=n(24),de=n(18),pe=n(148),fe=n(20),me=n(42),ge=n(171);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function be(t,e,n){return[n*("number"==typeof t?t:t[0]),e*("number"==typeof t?t:t[1])]}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function ye(t,e,n,r=!0){let i=[];if(r)i=i.concat(e.slice(0)),i.push(t[0]/n),i=i.concat(t.slice(1));else{i=i.concat(t[0]);const n=e.length;for(let r=0;r<n;++r)i=i.concat([t[r+1]/e[r],e[r]]);i=i.concat(t.slice(n+1))}return i}function ve(t,e,n=!0){const r=[];if(n){r.push(e);for(let n=e+1;n<t;++n)n<=2*e?(r.push(n),r.push(n-(e+1))):r.push(n)}else{const n=[],i=[];for(let r=1;r<t;++r)r>=2*e+1||r%2==1?i.push(r):n.push(r);r.push(...n),r.push(0),r.push(...i)}return r}function we(t,e,n,r=!0){const i=[];r?i.push(t[0]/n):i.push(t[0]*n);for(let n=1;n<t.length;++n)n<=e.length?r?i.push(e[n-1]*t[n]):i.push(t[n]/e[n-1]):i.push(t[n]);return i}function xe(t,e){const n=[0];for(let r=0;r<e;++r)n.push(t[r][0]);return n}function _e(t,e,n){const r=t.slice(0,1);for(let i=0;i<n;++i)r.push(t[i+1]-e[i][0]-e[i][1]);return r}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Oe=1.7580993408473768,Se=1.0507009873554805,ke=.3275911,Te=.254829592,Ce=-.284496736,Ae=1.421413741,Ne=-1.453152027,Ie=1.061405429;
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function Ee(...t){Object(h.c)().getBool("IS_TEST")||console.warn(...t)}function je(...t){Object(h.c)().getBool("IS_TEST")||console.log(...t)}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function Me(t,e){if(t.length!==e.length)throw new Error(`Cannot merge real and imag arrays of different lengths. real:${t.length}, imag: ${e.length}.`);const n=new Float32Array(2*t.length);for(let r=0;r<n.length;r+=2)n[r]=t[r/2],n[r+1]=e[r/2];return n}function De(t){const e=new Float32Array(t.length/2),n=new Float32Array(t.length/2);for(let r=0;r<t.length;r+=2)e[r/2]=t[r],n[r/2]=t[r+1];return{real:e,imag:n}}function Re(t){const e=Math.ceil(t.length/4),n=new Float32Array(e),r=new Float32Array(e);for(let e=0;e<t.length;e+=4)n[Math.floor(e/4)]=t[e],r[Math.floor(e/4)]=t[e+1];return{real:n,imag:r}}function Pe(t){const e=Math.floor(t.length/4),n=new Float32Array(e),r=new Float32Array(e);for(let e=2;e<t.length;e+=4)n[Math.floor(e/4)]=t[e],r[Math.floor(e/4)]=t[e+1];return{real:n,imag:r}}function Fe(t,e){return{real:t[2*e],imag:t[2*e+1]}}function ze(t,e,n,r){t[2*r]=e,t[2*r+1]=n}function Le(t,e){const n=new Float32Array(t/2),r=new Float32Array(t/2);for(let i=0;i<Math.ceil(t/2);i++){const s=(e?2:-2)*Math.PI*(i/t);n[i]=Math.cos(s),r[i]=Math.sin(s)}return{real:n,imag:r}}function $e(t,e,n){const r=(n?2:-2)*Math.PI*(t/e);return{real:Math.cos(r),imag:Math.sin(r)}}var Be=n(187),qe=n(170);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function Ve(t,e,n){if("complex64"===e){if("complex64"===t.dtype)return t.clone();const e=Object(le.a)(t.shape),r=Object(U.a)(t,"float32"),i=n.complex(r,e);return e.dispose(),r.dispose(),i}if(!Object(O.p)(t.dtype,e))return l.a.makeTensorFromDataId(t.dataId,t.shape,e);if("complex64"===t.dtype){const r=n.real(t),i=Object(U.a)(r,e);return r.dispose(),i}if("int32"===e)return n.int(t);if("bool"===e){const e=Object(Vt.a)(0,t.dtype),r=n.notEqual(t,e);return e.dispose(),r}throw new Error(`Error in Cast: failed to cast ${t.dtype} to ${e}`)}function Ue(t,e){return l.a.makeTensorFromDataId(t.dataId,e,t.dtype)}function We(t,e,n){const r=(e-t)/(n-1),i=Object(O.F)(n,"float32");i[0]=t;for(let t=1;t<i.length;t++)i[t]=i[t-1]+r;return Object(ce.a)(i,"float32")}var Ge=n(156),He=n(80),Ke=n(28);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function Qe(t,e,n){const r=new Array(t.rank).fill(0),i=t.shape.slice();return e.map(e=>{const s=[...i];s[n]=e;const a=Object(Ke.a)(t,r,s);return r[n]+=e,a})}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function Xe(t,e){const n=new Array(t.rank);for(let r=0;r<n.length;r++)n[r]=t.shape[r]*e[r];const r=Object(V.a)(n,t.dtype);for(let e=0;e<r.values.length;++e){const n=r.indexToLoc(e),i=new Array(t.rank);for(let e=0;e<i.length;e++)i[e]=n[e]%t.shape[e];const s=t.locToIndex(i);r.values[e]=t.values[s]}return r.toTensor()}var Ye=n(64);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function Je(t,e,n,r,i){const s=e[e.length-1],[a,o]=[t.length/s,s],u=Object(O.o)(n,a*r),c=Object(O.o)("int32",a*r);for(let e=0;e<a;e++){const n=e*o,i=t.subarray(n,n+o),s=[];for(let t=0;t<i.length;t++)s.push({value:i[t],index:t});s.sort((t,e)=>e.value-t.value);const a=e*r,l=u.subarray(a,a+r),h=c.subarray(a,a+r);for(let t=0;t<r;t++)l[t]=s[t].value,h[t]=s[t].index}const l=e.slice();return l[l.length-1]=r,[Object(Ye.a)(u,l,n),Object(Ye.a)(c,l,"int32")]}var Ze=n(192),tn=n(147),en=n(85);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const nn={kernelName:vt.a,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(zt.a)(t,Object(en.a)(Object(U.a)(n,"float32"),-1))}}};var rn=n(30);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const sn={kernelName:vt.b,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const e=Object($t.a)(Object(U.a)(n,"float32")),r=Object(Lt.a)(Object(Qt.a)(Object(Vt.a)(1),e));return Object(rn.a)(Object(Ft.a)(t,r))}}}},an={kernelName:vt.c,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const e=Object(Lt.a)(Object(Qt.a)(Object($t.a)(Object(U.a)(n,"float32")),1));return Object(Ft.a)(t,e)}}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var on=n(8),un=n(21);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const cn={kernelName:vt.d,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,r]=e,i=de.a(n.shape,r.shape);return{a:()=>{let e=t;const r=de.c(n.shape,i);return r.length>0&&(e=Object(un.a)(e,r)),Object(on.a)(e,n.shape)},b:()=>{let e=t;const n=de.c(r.shape,i);return n.length>0&&(e=Object(un.a)(e,n)),Object(on.a)(e,r.shape)}}}},ln={kernelName:vt.e,saveAllInputs:!0,gradFunc:(t,e)=>{const n={};return e.forEach((e,r)=>{n[r]=()=>t.clone()}),n}},hn={kernelName:vt.h,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(Bt.a)(n)}}},dn={kernelName:vt.i,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(Bt.a)(n)}}},pn={kernelName:vt.j,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(Ft.a)(t,Object(Lt.a)(Object(Qt.a)(Object(Vt.a)(1),Object($t.a)(Object(U.a)(n,"float32")))))}}},fn={kernelName:vt.k,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const e=Object(Lt.a)(Object(Pt.a)(Object(Vt.a)(1),Object($t.a)(Object(U.a)(n,"float32"))));return Object(Ft.a)(t,e)}}}},mn={kernelName:vt.m,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,r]=e,i=Object(de.a)(n.shape,r.shape);return{a:()=>{const e=Object(Pt.a)(Object($t.a)(n),Object($t.a)(r));let s=Object(zt.a)(t,Object(Ft.a)(r,e));const a=Object(de.c)(n.shape,i);return a.length>0&&(s=Object(un.a)(s,a)),Object(on.a)(s,n.shape)},b:()=>{const e=Object(Pt.a)(Object($t.a)(n),Object($t.a)(r));let s=Object(rn.a)(Object(zt.a)(t,Object(Ft.a)(n,e)));const a=Object(de.c)(r.shape,i);return a.length>0&&(s=Object(un.a)(s,a)),Object(on.a)(s,r.shape)}}}},gn={kernelName:vt.l,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(Ft.a)(t,Object(Pt.a)(Object($t.a)(Object(U.a)(n,"float32")),1))}}},bn={kernelName:vt.n,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(Ft.a)(t,Object(Qt.a)(Object(Vt.a)(1),Object($t.a)(Object(U.a)(n,"float32"))))}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const yn=Object(gt.b)({avgPool3dBackprop_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,r,i=[1,1,1],s,a){const o=Object(pt.a)(t,"dy","avgPool3dBackprop"),u=Object(pt.a)(e,"input","avgPool3dBackprop");let c=o,h=u,d=!1;4===u.rank&&(d=!0,c=Object(on.a)(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),h=Object(on.a)(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]])),O.b(5===c.rank,()=>"Error in avgPool3dBackprop: dy must be rank 5 but got rank "+c.rank+"."),O.b(5===h.rank,()=>"Error in avgPool3dBackprop: input must be rank 5 but got rank "+h.rank+"."),O.b(fe.h(r,i),()=>`Error in avgPool3dBackprop: Either strides or dilations must be 1. Got strides ${r} and dilations '${i}'`),null!=a&&O.b(O.v(s),()=>`Error in maxPool3dBackprop: pad must be an integer when using, dimRoundingMode ${a} but got pad ${s}.`);const p={dy:c,input:h},f={filterSize:n,strides:r,dilations:i,pad:s,dimRoundingMode:a},m=l.a.runKernelFunc(t=>{const e=fe.f(h.shape,n,r,i,s,a);return t.avgPool3dBackprop(c,h,e)},p,null,vt.q,f);return d?Object(on.a)(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}}),vn={kernelName:vt.p,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[r]=e,{filterSize:i,strides:s,dilations:a,pad:o,dimRoundingMode:u}=n,c=null==a?[1,1,1]:a;return{x:()=>yn(t,r,i,s,c,o,u)}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const wn=Object(gt.b)({avgPoolBackprop_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,r,i){const s=Object(pt.a)(t,"dy","avgPoolBackprop"),a=Object(pt.a)(e,"input","avgPoolBackprop");O.b(a.rank===s.rank,()=>`Rank of input (${a.rank}) does not match rank of dy (${s.rank})`);let o=a,u=s,c=!1;3===a.rank&&(c=!0,o=Object(on.a)(a,[1,a.shape[0],a.shape[1],a.shape[2]]),u=Object(on.a)(s,[1,s.shape[0],s.shape[1],s.shape[2]])),O.b(4===u.rank,()=>"Error in avgPoolBackprop: dy must be rank 4 but got rank "+u.rank+"."),O.b(4===o.rank,()=>"Error in avgPoolBackprop: input must be rank 4 but got rank "+o.rank+".");const h={dy:u,input:o},d={filterSize:n,strides:r,pad:i},p=l.a.runKernelFunc(t=>{const e=fe.e(o.shape,n,r,1,i);return t.avgPoolBackprop(u,o,e)},h,null,vt.r,d);return c?Object(on.a)(p,[p.shape[1],p.shape[2],p.shape[3]]):p}}),xn={kernelName:vt.o,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[r]=e,{filterSize:i,strides:s,pad:a}=n;return{x:()=>wn(t,r,i,s,a)}}},_n={kernelName:vt.s,inputsToSave:["a","b"],gradFunc:(t,e,n)=>{const[r,i]=e,{transposeA:s,transposeB:a}=n;return s||a?!s&&a?{a:()=>Object(ft.a)(t,i,!1,!1),b:()=>Object(ft.a)(t,r,!0,!1)}:s&&!a?{a:()=>Object(ft.a)(i,t,!1,!0),b:()=>Object(ft.a)(r,t,!1,!1)}:{a:()=>Object(ft.a)(i,t,!0,!0),b:()=>Object(ft.a)(t,r,!0,!0)}:{a:()=>Object(ft.a)(t,i,!1,!0),b:()=>Object(ft.a)(r,t,!0,!1)}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var On=n(105);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Sn={kernelName:vt.t,gradFunc:(t,e,n)=>{const{blockShape:r,crops:i}=n;return{x:()=>Object(On.a)(t,r,i)}}},kn={kernelName:vt.u,gradFunc:(t,e,n)=>{const r=n,i=r.inputShape,s=r.shape,a=Array.from(s);for(let t=i.length-1;t>=0;t--)if(i[t]===s[t])a[t]=1;else if(1!==i[t])throw new Error(`broadcastTo(): [${i}] cannot be broadcast to [${s}].`);const o=[];for(let t=0;t<a.length;t++)a[t]>1&&o.push(t);return{x:()=>Object(un.a)(t,o,!0)}}},Tn={kernelName:vt.v,gradFunc:t=>({x:()=>t.clone()})},Cn={kernelName:vt.w,gradFunc:t=>({x:()=>Object(Bt.a)(t)})};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var An=n(56),Nn=n(57),In=n(62),En=n(37);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const jn={kernelName:vt.x,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[r]=e,{clipValueMin:i,clipValueMax:s}=n;return{x:()=>Object(En.a)(Object(In.a)(Object(An.a)(r,i),Object(Nn.a)(r,s)),t,Object(Bt.a)(t))}}};var Mn=n(78);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Dn={kernelName:vt.z,saveAllInputs:!0,gradFunc:(t,e,n)=>{const r=e.map(t=>t.shape),{axis:i}=n,s=Object(O.I)(i,e[0].shape)[0],a=r.map(t=>t[s]);return Object(Mn.a)(t,a,s).map(t=>()=>t)}};var Rn=n(144),Pn=n(142);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const Fn={kernelName:vt.A,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const[r,i]=e,{dilations:s,strides:a,pad:o,dataFormat:u}=n;return O.b(fe.i(s),()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`),{x:()=>Object(Pn.a)(r.shape,t,i,a,o,u),filter:()=>Object(Rn.a)(r,t,i.shape,a,o,u)}}};var zn=n(69);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Ln={kernelName:vt.C,inputsToSave:["dy","filter"],gradFunc:(t,e,n)=>{const[r,i]=e,{strides:s,pad:a,dataFormat:o,dimRoundingMode:u}=n;return{dy:()=>Object(zn.a)(t,i,s,a,o,1,u),filter:()=>Object(Rn.a)(t,r,i.shape,s,a,o,u)}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const $n=Object(gt.b)({conv3DBackpropFilter_:function(t,e,n,r,i){let s=t;4===t.rank&&(s=Object(on.a)(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]));let a=e;4===a.rank&&(a=Object(on.a)(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]])),O.b(5===s.rank,()=>"Error in conv3dDerFilter: input must be rank 5, but got shape "+s.shape+"."),O.b(5===a.rank,()=>"Error in conv3dDerFilter: dy must be rank 5, but got shape "+a.shape+"."),O.b(5===n.length,()=>"Error in conv3dDerFilter: filterShape must be length 5, but got "+n+"."),O.b(s.shape[4]===n[3],()=>`Error in conv3dDerFilter: depth of input ${s.shape[4]}) must match input depth in filter (${n[3]}.`),O.b(a.shape[4]===n[4],()=>`Error in conv3dDerFilter: depth of dy (${a.shape[4]}) must match output depth for filter (${n[4]}).`);const o={x:s,dy:a},u={strides:r,pad:i,filterShape:n};return l.a.runKernelFunc(t=>{const e=fe.b(s.shape,n,r,1,i);return t.conv3dDerFilter(s,a,e)},o,null,vt.E,u)}});var Bn=n(206);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const qn={kernelName:vt.D,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const{dilations:r,strides:i,pad:s}=n;O.b(Object(fe.i)(r),()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`);const[a,o]=e;return{x:()=>Object(Bn.a)(a.shape,t,o,i,s),filter:()=>$n(a,t,o.shape,i,s)}}};var Vn=n(184);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Un={kernelName:vt.G,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(zt.a)(Object(rn.a)(Object(Vn.a)(Object(U.a)(n,"float32"))),t)}}};var Wn=n(185);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Gn={kernelName:vt.H,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(zt.a)(Object(Wn.a)(Object(U.a)(n,"float32")),t)}}};var Hn=n(126);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Kn={kernelName:vt.J,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[r]=e,{axis:i,exclusive:s,reverse:a}=n;return{x:()=>{const e=Object(he.f)([i],r.rank);let n=Object(Hn.a)(t,i,s,!a);return null!=e&&(n=Object(bt.a)(n,e)),n}}}};var Qn=n(210),Xn=n(209);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const Yn={kernelName:vt.L,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const{dilations:r,strides:i,pad:s,dimRoundingMode:a}=n,o=null==r?[1,1]:r;O.b(fe.i(o),()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${o}'`);const[u,c]=e;return O.b(4===u.rank,()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${u.rank}.`),O.b(4===c.rank,()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${c.rank}.`),O.b(u.shape[3]===c.shape[2],()=>`Error in gradient of depthwiseConv2d: number of input channels (${u.shape[3]}) must match the inChannels dimension in filter ${c.shape[2]}.`),O.b(fe.h(i,o),()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be  1. Got strides ${i} and dilations '${o}'.`),null!=a&&O.b(O.v(s),()=>`Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode ${a} but got pad ${s}.`),{x:()=>Object(Xn.a)(u.shape,t,c,i,s,r,a),filter:()=>Object(Qn.a)(u,t,c.shape,i,s,r,a)}}},Jn={kernelName:vt.P,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const[r,i]=e,s={x:r,filter:i,dy:t},a={x:r,filter:i,dy:t};return{x:()=>l.a.runKernel(vt.R,s,n),filter:()=>l.a.runKernel(vt.Q,a,n)}}},Zn={kernelName:vt.S,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,r]=e,i=de.a(n.shape,r.shape);return{a:()=>{const e=Object(Ft.a)(t,Object(U.a)(r,"float32")),s=de.c(n.shape,i);return s.length>0?Object(on.a)(Object(un.a)(e,s),n.shape):e},b:()=>{let e=Object(zt.a)(t,Object(U.a)(n,"float32"));const s=de.c(r.shape,i);s.length>0&&(e=Object(on.a)(Object(un.a)(e,s),r.shape));const a=Object($t.a)(r);return Object(rn.a)(Object(Ft.a)(e,Object(U.a)(a,"float32")))}}}},tr={kernelName:vt.T,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e,r=e=>e.eluDer(t,n),i={dy:t,y:n};return{x:()=>l.a.runKernelFunc(r,i,null,vt.U)}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var er=n(40);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const nr={kernelName:vt.W,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e,r=Object(zt.a)(Object(er.a)(Object(rn.a)(Object($t.a)(n))),2/Math.sqrt(Math.PI));return{x:()=>Object(zt.a)(t,r)}}},rr={kernelName:vt.X,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(zt.a)(t,n)}}},ir={kernelName:vt.Y,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(zt.a)(t,Object(er.a)(n))}}},sr={kernelName:vt.cb,gradFunc:t=>({x:()=>Object(Bt.a)(t)})},ar={kernelName:vt.db,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,r]=e,i=Object(de.a)(n.shape,r.shape);return{a:()=>{const e=Object(Ft.a)(t,Object(U.a)(r,"float32")),s=Object(de.c)(n.shape,i);return s.length>0?Object(on.a)(Object(un.a)(e,s),n.shape):e},b:()=>{let e=Object(zt.a)(t,Object(U.a)(n,"float32"));const s=Object(de.c)(r.shape,i);s.length>0&&(e=Object(on.a)(Object(un.a)(e,s),r.shape));const a=Object($t.a)(r);return Object(rn.a)(Object(Ft.a)(e,Object(U.a)(a,"float32")))}}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var or=n(181),ur=n(88);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const cr={kernelName:vt.fb,inputsToSave:["x","mean","variance","scale"],gradFunc:(t,e,n)=>{const{varianceEpsilon:r}=n,[i,s,a,o]=e,u=null==o?Object(Vt.a)(1):o,c=Object(de.c)(s.shape,i.shape),l=[];if(1===s.rank){for(let t=0;t<i.shape.length-1;++t)l.push(i.shape[t]);l.push(1)}const h=Object(Qt.a)(i,s),d=Object(zt.a)(t,u),p=Object(or.a)(Object(Pt.a)(a,Object(Vt.a)(r))),f=Object(zt.a)(Object(zt.a)(Object(zt.a)(p,p),p),Object(Vt.a)(-.5));return{x:()=>1===s.rank?Object(on.a)(Object(zt.a)(Object(zt.a)(t,Object(ur.a)(Object(on.a)(p,[1,1,1,s.shape[0]]),l)),u),i.shape):Object(on.a)(Object(zt.a)(Object(zt.a)(t,p),u),i.shape),mean:()=>{let t=Object(zt.a)(Object(zt.a)(p,Object(Vt.a)(-1)),d);return 1===s.rank&&(t=Object(un.a)(t,c)),Object(on.a)(t,s.shape)},variance:()=>{let t=Object(zt.a)(Object(zt.a)(f,h),d);return 1===s.rank&&(t=Object(un.a)(t,c)),Object(on.a)(t,s.shape)},scale:()=>{const e=Object(zt.a)(h,p);let n=Object(zt.a)(t,e);return 1===s.rank&&(n=Object(un.a)(n,c)),Object(on.a)(n,s.shape)},offset:()=>{let e=t;return 1===s.rank&&(e=Object(un.a)(e,c)),Object(on.a)(e,s.shape)}}}};var lr=n(137);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const hr={kernelName:vt.jb,inputsToSave:["x","indices"],gradFunc:(t,e,n)=>{const[r,i]=e,{axis:s}=n,a=Object(O.I)(s,r.shape)[0];return{x:()=>{const e=r.shape,n=i.size,o=e.slice(0,a),u=o.length,c=e.slice(s,e.length).slice(1),l=c.length,h=dr(0,u),d=dr(u+1,u+1+l),p=pr([o,[n],c]),f=Object(on.a)(t,p),m=Object(on.a)(i,[n]),g=pr([[u],h,d]),b=Object(bt.a)(f,g);let y=Object(lr.a)(b,m,r.shape[a]);const v=Object(he.h)(g);return y=Object(bt.a)(y,v),y},indices:()=>i}}};function dr(t,e){const n=[];for(let r=t;r<e;++r)n.push(r);return n}function pr(t){const e=[];for(let n=0;n<t.length;++n)for(let r=0;r<t[n].length;++r)e.push(t[n][r]);return e}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const fr={kernelName:vt.lb,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,r]=e;return{a:()=>Object(Bt.a)(n),b:()=>Object(Bt.a)(r)}}},mr={kernelName:vt.nb,gradFunc:t=>({x:()=>Object(U.a)(t,"float32")})},gr={kernelName:vt.pb,gradFunc:t=>({x:()=>Object(Bt.a)(t)})},br={kernelName:vt.qb,gradFunc:t=>({x:()=>Object(Bt.a)(t)})},yr={kernelName:vt.rb,gradFunc:t=>({x:()=>Object(Bt.a)(t)})},vr={kernelName:vt.yb,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(Ft.a)(t,Object(Pt.a)(n,1))}}},wr={kernelName:vt.xb,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(Ft.a)(t,Object(U.a)(n,"float32"))}}},xr={kernelName:vt.zb,inputsToSave:[],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[r]=e,{axis:i}=n;return{logits:()=>{const e=Object(er.a)(r);return Object(Qt.a)(t,Object(zt.a)(Object(un.a)(t,i,!0),e))}}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const _r=Object(gt.b)({localResponseNormalizationBackprop_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,r=5,i=1,s=1,a=.5){const o={x:t,y:e,dy:n},u={depthRadius:r,bias:i,alpha:s,beta:a};return l.a.runKernelFunc(o=>o.LRNGrad(n,t,e,r,i,s,a),o,null,vt.tb,u)}}),Or={kernelName:vt.sb,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[r,i]=e,{depthRadius:s,bias:a,alpha:o,beta:u}=n;return{x:()=>_r(r,i,t,s,a,o,u)}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var Sr=n(82);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function kr(t,e,n,r){return e.rank<n.rank&&(e=Object(on.a)(e,he.e(e.shape,r))),t.rank<n.rank&&(t=Object(on.a)(t,he.e(t.shape,r))),{x:()=>Object(zt.a)(t,Object(U.a)(Object(Sr.a)(n,e),t.dtype))}}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Tr={kernelName:vt.Db,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const r=n,{reductionIndices:i}=r,s=e[0],a=kr(t,e[1],s,O.I(i,s.shape));return{x:()=>a.x()}}};var Cr=n(101);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Ar={kernelName:vt.Jb,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,r]=e;return{a:()=>Object(zt.a)(t,Object(U.a)(Object(An.a)(n,r),"float32")),b:()=>Object(zt.a)(t,Object(U.a)(Object(Cr.a)(n,r),"float32"))}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Nr=Object(gt.b)({maxPool3dBackprop_:function(t,e,n,r,i,s=[1,1,1],a,o){const u=Object(pt.a)(t,"dy","maxPool3dBackprop"),c=Object(pt.a)(e,"input","maxPool3dBackprop"),h=Object(pt.a)(n,"output","maxPool3dBackprop");let d=u,p=c,f=h,m=!1;4===c.rank&&(m=!0,d=Object(on.a)(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]]),p=Object(on.a)(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]]),f=Object(on.a)(h,[1,h.shape[0],h.shape[1],h.shape[2],h.shape[3]])),O.b(5===d.rank,()=>"Error in maxPool3dBackprop: dy must be rank 5 but got rank "+d.rank+"."),O.b(5===p.rank,()=>"Error in maxPool3dBackprop: input must be rank 5 but got rank "+p.rank+"."),O.b(5===f.rank,()=>"Error in maxPool3dBackprop: output must be rank 5 but got rank "+f.rank+"."),O.b(fe.h(i,s),()=>`Error in maxPool3dBackprop: Either strides or dilations must be 1. Got strides ${i} and dilations '${s}'`),null!=o&&O.b(O.v(a),()=>`Error in maxPool3dBackprop: pad must be an integer when using, dimRoundingMode ${o} but got pad ${a}.`);const g={dy:d,input:p,output:f},b={filterSize:r,strides:i,dilations:s,pad:a,dimRoundingMode:o},y=l.a.runKernelFunc(t=>{const e=fe.f(p.shape,r,i,s,a,o);return t.maxPool3dBackprop(d,p,f,e)},g,null,vt.Gb,b);return m?Object(on.a)(y,[y.shape[1],y.shape[2],y.shape[3],y.shape[4]]):y}}),Ir={kernelName:vt.Fb,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[r,i]=e,{filterSize:s,strides:a,dilations:o,pad:u,dimRoundingMode:c}=n,l=null==o?[1,1,1]:o;return{x:()=>Nr(t,r,i,s,a,l,u,c)}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Er=Object(gt.b)({maxPoolBackprop_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,r,i,s,a){const o=Object(pt.a)(t,"dy","maxPoolBackprop"),u=Object(pt.a)(e,"input","maxPoolBackprop"),c=Object(pt.a)(n,"output","maxPoolBackprop");O.b(u.rank===o.rank,()=>`Rank of input (${u.rank}) does not match rank of dy (${o.rank})`),O.b(4===o.rank,()=>"Error in maxPoolBackprop: dy must be rank 4 but got rank "+o.rank+"."),O.b(4===u.rank,()=>"Error in maxPoolBackprop: input must be rank 4 but got rank "+u.rank+"."),null!=a&&O.b(O.v(s),()=>`Error in maxPoolBackprop: pad must be an integer when using, dimRoundingMode ${a} but got pad ${s}.`);const h={dy:o,input:u,output:c},d={filterSize:r,strides:i,pad:s,dimRoundingMode:a};return l.a.runKernelFunc(t=>{const e=fe.e(u.shape,r,i,1,s,a);return t.maxPoolBackprop(o,u,c,e)},h,null,vt.Hb,d)}}),jr={kernelName:vt.Eb,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[r,i]=e,{filterSize:s,strides:a,pad:o}=n;return{x:()=>Er(t,r,i,s,a,o)}}},Mr={kernelName:vt.Lb,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const r=n,{axis:i}=r,[s,a]=e,o=kr(t,a,s,O.I(i,s.shape));return{x:()=>o.x()}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var Dr=n(46);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Rr={kernelName:vt.Mb,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,r]=e;return{a:()=>Object(zt.a)(t,Object(U.a)(Object(Nn.a)(n,r),"float32")),b:()=>Object(zt.a)(t,Object(U.a)(Object(Dr.a)(n,r),"float32"))}}},Pr={kernelName:vt.Nb,inputsToSave:["x"],gradFunc:(t,e,n)=>{const r=e[0],{paddings:i}=n,s=i.map(t=>t[0]);return{x:()=>Object(Ke.a)(t,s,r.shape)}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var Fr=n(128);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const zr={kernelName:vt.Ob,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,r]=e,i=Object(de.a)(n.shape,r.shape);return{a:()=>{const e=Object(de.c)(n.shape,i);return e.length>0?Object(on.a)(Object(un.a)(t,e),n.shape):t},b:()=>{const e=Object(zt.a)(t,Object(rn.a)(Object(Fr.a)(Object(Ft.a)(n,r)))),s=Object(de.c)(r.shape,i);return s.length>0?Object(on.a)(Object(un.a)(e,s),r.shape):e}}}},Lr={kernelName:vt.Pb,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,r]=e,i=Object(de.a)(n.shape,r.shape);return{a:()=>{const e=Object(zt.a)(t,Object(U.a)(r,"float32")),s=Object(de.c)(n.shape,i);return s.length>0?Object(on.a)(Object(un.a)(e,s),n.shape):e},b:()=>{const e=Object(zt.a)(t,Object(U.a)(n,"float32")),s=Object(de.c)(r.shape,i);return s.length>0?Object(on.a)(Object(un.a)(e,s),r.shape):e}}}},$r={kernelName:vt.Qb,gradFunc:t=>({x:()=>Object(rn.a)(t)})},Br={kernelName:vt.Vb,inputsToSave:["indices"],gradFunc:(t,e)=>{const n=e[0];return{indices:()=>Object(le.a)(n.shape,"float32")}}},qr={kernelName:vt.Wb,gradFunc:t=>({x:()=>Object(Bt.a)(t)})},Vr={kernelName:vt.Xb,inputsToSave:["x"],gradFunc:(t,e,n)=>{const r=e[0],{paddings:i}=n,s=i.map(t=>t[0]);return{x:()=>Object(Ke.a)(t,s,r.shape)}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var Ur=n(76);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Wr={kernelName:vt.Zb,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(t,e)=>{const[n,r,i]=e,s=n,a=r,o=de.a(s.shape,a.shape);return{a:()=>{const e=Object(U.a)(a,"float32");let n=Object(zt.a)(t,Object(zt.a)(e,Object(Kt.a)(s,Object(Qt.a)(e,Object(Vt.a)(1)))));const r=de.c(s.shape,o);return r.length>0&&(n=Object(un.a)(n,r)),Object(on.a)(n,s.shape)},b:()=>{const e=Object(Dr.a)(s,0),n=Object(En.a)(e,Object(Ur.a)(s),Object(Bt.a)(s));let r=Object(zt.a)(t,Object(zt.a)(i,n));const u=de.c(a.shape,o);return u.length>0&&(r=Object(un.a)(r,u)),Object(on.a)(r,a.shape)}}}},Gr={kernelName:vt.ac,inputsToSave:["x","alpha"],gradFunc:(t,e)=>{const[n,r]=e,i=Object(Dr.a)(n,0);return{x:()=>Object(En.a)(i,t,Object(zt.a)(t,r)),alpha:()=>{let e=Object(En.a)(i,Object(Bt.a)(t),Object(zt.a)(t,n));const s=Object(de.c)(r.shape,t.shape);return s.length>0&&(e=Object(un.a)(e,s)),Object(on.a)(e,r.shape)}}}},Hr={kernelName:vt.ec,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(Ft.a)(t,Object(rn.a)(Object($t.a)(n)))}}},Kr={kernelName:vt.gc,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e,r=Object(zt.a)(Object(Nn.a)(n,6),Object(en.a)(n));return{x:()=>Object(zt.a)(t,Object(U.a)(r,"float32"))}}},Qr={kernelName:vt.fc,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(zt.a)(t,Object(U.a)(Object(en.a)(n),"float32"))}}},Xr={kernelName:vt.hc,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(on.a)(t,n.shape)}}},Yr={kernelName:vt.ic,inputsToSave:["images"],gradFunc:(t,e,n)=>{const[r]=e,i=e=>{const{alignCorners:i}=n;return e.resizeBilinearBackprop(t,r,i)},s={images:r};return{images:()=>l.a.runKernelFunc(i,s,null,vt.jc,n)}}},Jr={kernelName:vt.kc,inputsToSave:["images"],gradFunc:(t,e,n)=>{const[r]=e,i=e=>{const{alignCorners:i}=n;return e.resizeNearestNeighborBackprop(t,r,i)},s={images:r};return{images:()=>l.a.runKernelFunc(i,s,null,vt.lc,n)}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var Zr=n(45);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const ti={kernelName:vt.mc,gradFunc:(t,e,n)=>{const{dims:r}=n,i=Object(O.I)(r,t.shape);return{x:()=>Object(Zr.a)(t,i)}}},ei={kernelName:vt.oc,gradFunc:t=>({x:()=>Object(Bt.a)(t)})},ni={kernelName:vt.pc,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(rn.a)(Object(Ft.a)(t,Object(zt.a)(Object(Kt.a)(n,1.5),2)))}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var ri=n(102);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const ii={kernelName:vt.rc,inputsToSave:["condition"],gradFunc:(t,e)=>{const[n]=e;return{condition:()=>Object(U.a)(Object(Bt.a)(n),"float32"),t:()=>Object(zt.a)(t,Object(U.a)(n,t.dtype)),e:()=>Object(zt.a)(t,Object(U.a)(Object(ri.a)(n),t.dtype))}}},si={kernelName:vt.sc,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const e=Object(Dr.a)(n,Object(Vt.a)(0)),r=Object(Vt.a)(Oe),i=Object(Vt.a)(Se),s=Object(zt.a)(t,i),a=Object(zt.a)(Object(zt.a)(t,r),Object(er.a)(Object(U.a)(n,"float32")));return Object(En.a)(e,s,a)}}}},ai={kernelName:vt.tc,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(zt.a)(t,Object(zt.a)(n,Object(Qt.a)(Object(Vt.a)(1),n)))}}},oi={kernelName:vt.uc,gradFunc:t=>({x:()=>Object(Bt.a)(t)})};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var ui=n(125);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const ci={kernelName:vt.vc,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(zt.a)(Object(ui.a)(Object(U.a)(n,"float32")),t)}}};var li=n(165);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const hi={kernelName:vt.wc,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(zt.a)(Object(li.a)(Object(U.a)(n,"float32")),t)}}};var di=n(59);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const pi={kernelName:vt.xc,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[r]=e,{begin:i,size:s}=n,a=r.shape,[o,u]=Object(Ct.parseSliceParams)(r,i,s),c=[];for(let e=0;e<t.rank;e++)c.push([o[e],a[e]-o[e]-u[e]]);return{x:()=>Object(di.a)(t,c)}}},fi={kernelName:vt.yc,outputsToSave:[!0],gradFunc:(t,e,n)=>{const[r]=e,{dim:i}=n,s=Object(zt.a)(t,r);return{logits:()=>Object(Qt.a)(s,Object(zt.a)(Object(un.a)(s,[i],!0),r))}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var mi=n(87);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const gi={kernelName:vt.zc,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(zt.a)(t,Object(mi.a)(n))}}};var bi=n(98);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const yi={kernelName:vt.Ac,gradFunc:(t,e,n)=>{const{blockShape:r,paddings:i}=n;return{x:()=>Object(bi.a)(t,r,i)}}};var vi=n(32);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const wi={kernelName:vt.Cc,gradFunc:(t,e,n)=>{const{axis:r}=n;return{x:()=>Object(vi.a)(t,r)}}},xi={kernelName:vt.Dc,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(Ft.a)(t,Object(zt.a)(Object(Lt.a)(Object(U.a)(n,"float32")),2))}}},_i={kernelName:vt.Ec,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(zt.a)(t,Object(zt.a)(Object(U.a)(n,"float32"),2))}}},Oi={kernelName:vt.Fc,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,r]=e,i=Object(Vt.a)(2);return{a:()=>Object(zt.a)(t,Object(zt.a)(i,Object(Qt.a)(n,r))),b:()=>Object(zt.a)(t,Object(zt.a)(i,Object(Qt.a)(r,n)))}}},Si={kernelName:vt.Gc,gradFunc:t=>({x:()=>Object(Bt.a)(t)})},ki={kernelName:vt.Ic,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,r]=e,i=de.a(n.shape,r.shape);return{a:()=>{let e=t;const r=de.c(n.shape,i);return r.length>0&&(e=Object(un.a)(e,r)),Object(on.a)(e,n.shape)},b:()=>{let e=t;const n=de.c(r.shape,i);return n.length>0&&(e=Object(un.a)(e,n)),Object(on.a)(Object(rn.a)(e),r.shape)}}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var Ti=n(83);
/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Ci={kernelName:vt.Jc,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[r]=e,i=r.shape.slice(),{axis:s}=n;Object(O.I)(s,r.shape).forEach(t=>{i[t]=1});const a=Object(on.a)(t,i),o=Object(zt.a)(a,Object(Ti.a)(r.shape,"float32"));return{x:()=>o}}},Ai={kernelName:vt.Kc,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(Ft.a)(t,Object($t.a)(Object(ui.a)(n)))}}},Ni={kernelName:vt.Lc,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>Object(zt.a)(Object(Qt.a)(Object(Vt.a)(1),Object($t.a)(n)),t)}}},Ii={kernelName:vt.Mc,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[r]=e,{reps:i}=n;return{x:()=>{let e=Object(Bt.a)(r);if(1===r.rank)for(let n=0;n<i[0];++n)e=Object(Pt.a)(e,Object(Ke.a)(t,[n*r.shape[0]],[r.shape[0]]));else if(2===r.rank)for(let n=0;n<i[0];++n)for(let s=0;s<i[1];++s)e=Object(Pt.a)(e,Object(Ke.a)(t,[n*r.shape[0],s*r.shape[1]],[r.shape[0],r.shape[1]]));else if(3===r.rank)for(let n=0;n<i[0];++n)for(let s=0;s<i[1];++s)for(let a=0;a<i[2];++a)e=Object(Pt.a)(e,Object(Ke.a)(t,[n*r.shape[0],s*r.shape[1],a*r.shape[2]],[r.shape[0],r.shape[1],r.shape[2]]));else{if(4!==r.rank)throw new Error("Gradient for tile operation is not implemented for rank-"+r.rank+" tensors yet.");for(let n=0;n<i[0];++n)for(let s=0;s<i[1];++s)for(let a=0;a<i[2];++a)for(let o=0;o<i[3];++o)e=Object(Pt.a)(e,Object(Ke.a)(t,[n*r.shape[0],s*r.shape[1],a*r.shape[2],o*r.shape[3]],[r.shape[0],r.shape[1],r.shape[2],r.shape[3]]))}return e}}}},Ei={kernelName:vt.Oc,gradFunc:(t,e,n)=>{const r=n,{perm:i}=r,s=he.h(i);return{x:()=>Object(bt.a)(t,s)}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var ji=n(63);
/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Mi={kernelName:vt.Qc,gradFunc:(t,e,n)=>{const r=n,{axis:i}=r;return{value:()=>Object(ji.a)(t,i)}}};var Di=n(49),Ri=n(99);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const Pi=[nn,sn,an,cn,ln,hn,dn,pn,fn,mn,gn,bn,vn,xn,_n,Sn,kn,Tn,Cn,jn,Dn,Ln,Fn,qn,Un,Gn,Kn,Yn,Jn,Zn,tr,nr,rr,ir,ar,sr,cr,hr,fr,mr,gr,br,yr,vr,wr,xr,Or,Tr,Tr,Ar,Ir,jr,Mr,Rr,Pr,zr,Lr,$r,Br,qr,Vr,Vr,Wr,Gr,Hr,Kr,Qr,Xr,Yr,Jr,ti,ei,ni,ii,si,ai,oi,ci,hi,pi,fi,gi,yi,yi,wi,wi,xi,Oi,_i,Si,ki,Ci,Ai,Ni,Ii,Ei,Mi,{kernelName:vt.Rc,inputsToSave:["segmentIds"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>function(t,e){const n=Object(Jt.a)(e,Object(Bt.a)(e)),r=Object(Ri.a)(t,n);let i=Object(An.a)(e,Object(Vt.a)(0,"int32"));const s=r.rank-i.rank;for(let t=0;t<s;++t)i=Object(Di.a)(i,t+1);i=Object(In.a)(i,Object(Ti.a)(r.shape,"bool"));const a=Object(Bt.a)(r);return Object(En.a)(i,r,a)}(t,n)}}},{kernelName:vt.Sc,gradFunc:t=>({x:()=>Object(Bt.a)(t)})}];
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */for(const t of Pi)Object(wt.e)(t);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.abs=function(){return this.throwIfDisposed(),Object(Yt.a)(this)};var Fi=n(218);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.acos=function(){return this.throwIfDisposed(),Object(Fi.a)(this)};var zi=n(219);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.acosh=function(){return this.throwIfDisposed(),Object(zi.a)(this)};var Li=n(250);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.addStrict=function(t){return this.throwIfDisposed(),Object(Li.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.add=function(t){return this.throwIfDisposed(),Object(Pt.a)(this,t)};var $i=n(158);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.all=function(t,e){return this.throwIfDisposed(),Object($i.a)(this,t,e)};var Bi=n(159);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.any=function(t,e){return this.throwIfDisposed(),Object(Bi.a)(this,t,e)};var qi=n(160);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.argMax=function(t){return this.throwIfDisposed(),Object(qi.a)(this,t)};var Vi=n(161);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.argMin=function(t){return this.throwIfDisposed(),Object(Vi.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.asScalar=function(){return this.throwIfDisposed(),Object(O.b)(1===this.size,()=>"The array must have only 1 element."),Object(on.a)(this,[])},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.asType=function(t){return this.throwIfDisposed(),Object(U.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.as1D=function(){return this.throwIfDisposed(),Object(on.a)(this,[this.size])},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.as2D=function(t,e){return this.throwIfDisposed(),Object(on.a)(this,[t,e])},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.as3D=function(t,e,n){return this.throwIfDisposed(),Object(on.a)(this,[t,e,n])},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.as4D=function(t,e,n,r){return this.throwIfDisposed(),Object(on.a)(this,[t,e,n,r])},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.as5D=function(t,e,n,r,i){return this.throwIfDisposed(),Object(on.a)(this,[t,e,n,r,i])};var Ui=n(221);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.asin=function(){return this.throwIfDisposed(),Object(Ui.a)(this)};var Wi=n(222);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.asinh=function(){return this.throwIfDisposed(),Object(Wi.a)(this)};var Gi=n(223);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.atan=function(){return this.throwIfDisposed(),Object(Gi.a)(this)};var Hi=n(162);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.atan2=function(t){return this.throwIfDisposed(),Object(Hi.a)(this,t)};var Ki=n(224);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.atanh=function(){return this.throwIfDisposed(),Object(Ki.a)(this)};var Qi=n(124);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.avgPool=function(t,e,n,r){return this.throwIfDisposed(),Object(Qi.a)(this,t,e,n,r)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.batchToSpaceND=function(t,e){return this.throwIfDisposed(),Object(bi.a)(this,t,e)};var Xi=n(86);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.batchNorm=function(t,e,n,r,i){return this.throwIfDisposed(),Object(Xi.a)(this,t,e,n,r,i)};var Yi=n(113);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.broadcastTo=function(t){return this.throwIfDisposed(),Object(Yi.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.cast=function(t){return this.throwIfDisposed(),Object(U.a)(this,t)};var Ji=n(226);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.ceil=function(){return this.throwIfDisposed(),Object(Ji.a)(this)};var Zi=n(227);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.clipByValue=function(t,e){return this.throwIfDisposed(),Object(Zi.a)(this,t,e)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.concat=function(t,e){return this.throwIfDisposed(),t instanceof H.a&&(t=[t]),Object(vi.a)([this,...t],e)};var ts=n(163);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.conv1d=function(t,e,n,r,i,s){return this.throwIfDisposed(),Object(ts.a)(this,t,e,n,r,i,s)};var es=n(164);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.conv2dTranspose=function(t,e,n,r,i){return this.throwIfDisposed(),Object(es.a)(this,t,e,n,r,i)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.conv2d=function(t,e,n,r,i,s){return this.throwIfDisposed(),Object(zn.a)(this,t,e,n,r,i,s)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.cos=function(){return this.throwIfDisposed(),Object(ui.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.cosh=function(){return this.throwIfDisposed(),Object(li.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.cumsum=function(t,e,n){return this.throwIfDisposed(),Object(Hn.a)(this,t,e,n)};var ns=n(166);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.depthToSpace=function(t,e){return this.throwIfDisposed(),Object(ns.a)(this,t,e)};var rs=n(81);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.depthwiseConv2D=function(t,e,n,r,i,s){return Object(Rt.b)("depthwiseConv2D is deprecated, use depthwiseConv2d instead"),this.throwIfDisposed(),Object(rs.a)(this,t,e,n,r,i,s)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.depthwiseConv2d=function(t,e,n,r,i,s){return this.throwIfDisposed(),Object(rs.a)(this,t,e,n,r,i,s)};var is=n(167);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.dilation2d=function(t,e,n,r,i){return this.throwIfDisposed(),Object(is.a)(this,t,e,n,r,i)};var ss=n(168);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.divNoNan=function(t){return this.throwIfDisposed(),Object(ss.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.divStrict=function(t){return this.throwIfDisposed(),Object(Li.b)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.div=function(t){return this.throwIfDisposed(),Object(Ft.a)(this,t)};var as=n(169);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.dot=function(t){return this.throwIfDisposed(),Object(as.a)(this,t)};var os=n(127);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.elu=function(){return this.throwIfDisposed(),Object(os.a)(this)};var us=n(249);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.equalStrict=function(t){return this.throwIfDisposed(),Object(us.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.equal=function(t){return this.throwIfDisposed(),Object(Sr.a)(this,t)};var cs=n(229);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.erf=function(){return this.throwIfDisposed(),Object(cs.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.exp=function(){return this.throwIfDisposed(),Object(er.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.expandDims=function(t){return this.throwIfDisposed(),Object(Di.a)(this,t)};var ls=n(230);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.expm1=function(){return this.throwIfDisposed(),Object(ls.a)(this)};var hs=n(135);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.fft=function(){return this.throwIfDisposed(),Object(hs.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.flatten=function(){return this.throwIfDisposed(),Object(on.a)(this,[this.size])},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.floor=function(){return this.throwIfDisposed(),Object(Fr.a)(this)};var ds=n(122);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.floorDiv=function(t){return this.throwIfDisposed(),Object(ds.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.gather=function(t,e){return this.throwIfDisposed(),Object(Ri.a)(this,t,e)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.greaterEqualStrict=function(t){return this.throwIfDisposed(),Object(us.b)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.greaterEqual=function(t){return this.throwIfDisposed(),Object(An.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.greaterStrict=function(t){return this.throwIfDisposed(),Object(us.c)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.greater=function(t){return this.throwIfDisposed(),Object(Dr.a)(this,t)};var ps=n(116);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.ifft=function(){return this.throwIfDisposed(),Object(ps.a)(this)};var fs=n(186);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.irfft=function(){return this.throwIfDisposed(),Object(fs.a)(this)};var ms=n(231);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.isFinite=function(){return this.throwIfDisposed(),Object(ms.a)(this)};var gs=n(232);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.isInf=function(){return this.throwIfDisposed(),Object(gs.a)(this)};var bs=n(233);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.isNaN=function(){return this.throwIfDisposed(),Object(bs.a)(this)};var ys=n(172);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.leakyRelu=function(t){return this.throwIfDisposed(),Object(ys.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.lessEqualStrict=function(t){return this.throwIfDisposed(),Object(us.d)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.lessEqual=function(t){return this.throwIfDisposed(),Object(Nn.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.lessStrict=function(t){return this.throwIfDisposed(),Object(us.e)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.less=function(t){return this.throwIfDisposed(),Object(Cr.a)(this,t)};var vs=n(173);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.localResponseNormalization=function(t,e,n,r){return this.throwIfDisposed(),Object(vs.a)(this,t,e,n,r)};var ws=n(235);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.logSigmoid=function(){return this.throwIfDisposed(),Object(ws.a)(this)};var xs=n(236);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.logSoftmax=function(t){return this.throwIfDisposed(),Object(xs.a)(this,t)};var _s=n(129);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.logSumExp=function(t,e){return this.throwIfDisposed(),Object(_s.a)(this,t,e)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.log=function(){return this.throwIfDisposed(),Object(Ur.a)(this)};var Os=n(174);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.log1p=function(){return this.throwIfDisposed(),Object(Os.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.logicalAnd=function(t){return this.throwIfDisposed(),Object(In.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.logicalNot=function(){return this.throwIfDisposed(),Object(ri.a)(this)};var Ss=n(130);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.logicalOr=function(t){return this.throwIfDisposed(),Object(Ss.a)(this,t)};var ks=n(176);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.logicalXor=function(t){return this.throwIfDisposed(),Object(ks.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.matMul=function(t,e,n){return this.throwIfDisposed(),Object(ft.a)(this,t,e,n)};var Ts=n(131);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.maxPool=function(t,e,n,r){return this.throwIfDisposed(),Object(Ts.a)(this,t,e,n,r)};var Cs=n(72);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.max=function(t,e){return this.throwIfDisposed(),Object(Cs.a)(this,t,e)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.maximumStrict=function(t){return this.throwIfDisposed(),Object(Li.c)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.maximum=function(t){return this.throwIfDisposed(),Object(Jt.a)(this,t)};var As=n(93);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.mean=function(t,e){return this.throwIfDisposed(),Object(As.a)(this,t,e)};var Ns=n(114);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.min=function(t,e){return this.throwIfDisposed(),Object(Ns.a)(this,t,e)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.minimumStrict=function(t){return this.throwIfDisposed(),Object(Li.d)(this,t)};var Is=n(103);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.minimum=function(t){return this.throwIfDisposed(),Object(Is.a)(this,t)};var Es=n(177);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.mirrorPad=function(t,e){return this.throwIfDisposed(),Object(Es.a)(this,t,e)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.modStrict=function(t){return this.throwIfDisposed(),Object(Li.e)(this,t)};var js=n(132);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.mod=function(t){return this.throwIfDisposed(),Object(js.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.mulStrict=function(t){return this.throwIfDisposed(),Object(Li.f)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.mul=function(t){return this.throwIfDisposed(),Object(zt.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.neg=function(){return this.throwIfDisposed(),Object(rn.a)(this)};var Ms=n(138);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.norm=function(t,e,n){return this.throwIfDisposed(),Object(Ms.a)(this,t,e,n)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.notEqualStrict=function(t){return this.throwIfDisposed(),Object(us.f)(this,t)};var Ds=n(104);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.notEqual=function(t){return this.throwIfDisposed(),Object(Ds.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.oneHot=function(t,e=1,n=0){return this.throwIfDisposed(),Object(mt.a)(this,t,e,n)};var Rs=n(240);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.onesLike=function(){return this.throwIfDisposed(),Object(Rs.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.pad=function(t,e){return this.throwIfDisposed(),Object(di.a)(this,t,e)};var Ps=n(178);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.pool=function(t,e,n,r,i){return this.throwIfDisposed(),Object(Ps.a)(this,t,e,n,r,i)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.powStrict=function(t){return this.throwIfDisposed(),Object(Li.g)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.pow=function(t){return this.throwIfDisposed(),Object(Kt.a)(this,t)};var Fs=n(133);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.prelu=function(t){return this.throwIfDisposed(),Object(Fs.a)(this,t)};var zs=n(179);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.prod=function(t,e){return this.throwIfDisposed(),Object(zs.a)(this,t,e)};var Ls=n(241);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.reciprocal=function(){return this.throwIfDisposed(),Object(Ls.a)(this)};var $s=n(84);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.relu=function(){return this.throwIfDisposed(),Object($s.a)(this)};var Bs=n(134);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.relu6=function(){return this.throwIfDisposed(),Object(Bs.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.reshapeAs=function(t){return this.throwIfDisposed(),Object(on.a)(this,t.shape)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.reshape=function(t){return this.throwIfDisposed(),Object(on.a)(this,t)};var qs=n(208);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.resizeBilinear=function(t,e){return this.throwIfDisposed(),Object(qs.a)(this,t,e)};var Vs=n(207);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.resizeNearestNeighbor=function(t,e){return this.throwIfDisposed(),Object(Vs.a)(this,t,e)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.reverse=function(t){return this.throwIfDisposed(),Object(Zr.a)(this,t)};var Us=n(136);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.rfft=function(){return this.throwIfDisposed(),Object(Us.a)(this)};var Ws=n(242);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.round=function(){return this.throwIfDisposed(),Object(Ws.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.rsqrt=function(){return this.throwIfDisposed(),Object(or.a)(this)};var Gs=n(182);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.selu=function(){return this.throwIfDisposed(),Object(Gs.a)(this)};var Hs=n(183);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.separableConv2d=function(t,e,n,r,i,s){return this.throwIfDisposed(),Object(Hs.a)(this,t,e,n,r,i,s)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.sigmoid=function(){return this.throwIfDisposed(),Object(mi.a)(this)};var Ks=n(244);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.sign=function(){return this.throwIfDisposed(),Object(Ks.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.sin=function(){return this.throwIfDisposed(),Object(Vn.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.sinh=function(){return this.throwIfDisposed(),Object(Wn.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.slice=function(t,e){return this.throwIfDisposed(),Object(Ke.a)(this,t,e)};var Qs=n(245);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.softmax=function(t){return this.throwIfDisposed(),Object(Qs.a)(this,t)};var Xs=n(175);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.softplus=function(){return this.throwIfDisposed(),Object(Xs.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.spaceToBatchND=function(t,e){return this.throwIfDisposed(),Object(On.a)(this,t,e)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.split=function(t,e){return this.throwIfDisposed(),Object(Mn.a)(this,t,e)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.sqrt=function(){return this.throwIfDisposed(),Object(Lt.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.square=function(){return this.throwIfDisposed(),Object($t.a)(this)};var Ys=n(106);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.squaredDifference=function(t){return this.throwIfDisposed(),Object(Ys.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.squaredDifferenceStrict=function(t){return this.throwIfDisposed(),Object(Li.h)(this,t)};var Js=n(107);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.squeeze=function(t){return this.throwIfDisposed(),Object(Js.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.stack=function(t,e){this.throwIfDisposed();const n=t instanceof H.a?[this,t]:[this,...t];return Object(ji.a)(n,e)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.step=function(t){return this.throwIfDisposed(),Object(en.a)(this,t)};var Zs=n(246);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.stridedSlice=function(t,e,n,r,i,s,a,o){return this.throwIfDisposed(),Object(Zs.a)(this,t,e,n,r,i,s,a,o)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.subStrict=function(t){return this.throwIfDisposed(),Object(Li.i)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.sub=function(t){return this.throwIfDisposed(),Object(Qt.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.sum=function(t,e){return this.throwIfDisposed(),Object(un.a)(this,t,e)};var ta=n(247);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.tan=function(){return this.throwIfDisposed(),Object(ta.a)(this)};var ea=n(149);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.tanh=function(){return this.throwIfDisposed(),Object(ea.a)(this)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.tile=function(t){return this.throwIfDisposed(),Object(ur.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.toBool=function(){return this.throwIfDisposed(),Object(U.a)(this,"bool")},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.toFloat=function(){return this.throwIfDisposed(),Object(U.a)(this,"float32")},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.toInt=function(){return this.throwIfDisposed(),Object(U.a)(this,"int32")};var na=n(189);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.topk=function(t,e){return this.throwIfDisposed(),Object(na.a)(this,t,e)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.transpose=function(t){return this.throwIfDisposed(),Object(bt.a)(this,t)};var ra=n(190);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.unique=function(t){return this.throwIfDisposed(),Object(ra.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.unsortedSegmentSum=function(t,e){return this.throwIfDisposed(),Object(lr.a)(this,t,e)};var ia=n(108);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */H.a.prototype.unstack=function(t){return this.throwIfDisposed(),Object(ia.a)(this,t)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.where=function(t,e){return this.throwIfDisposed(),Object(En.a)(t,this,e)},
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
H.a.prototype.zerosLike=function(){return this.throwIfDisposed(),Object(Bt.a)(this)}},function(t,e,n){"use strict";n.d(e,"c",(function(){return u})),n.d(e,"a",(function(){return l})),n.d(e,"b",(function(){return h}));var r=n(5),i=n(26),s=n(6),a=n(7),o=n(10);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function u(t,e){let n=t;if(Object(a.A)(t))return"string"===e?[]:[t.length];if(!Array.isArray(t))return[];const r=[];for(;Array.isArray(n)||Object(a.A)(n)&&"string"!==e;)r.push(n.length),n=n[0];return Array.isArray(t)&&Object(i.c)().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&function t(e,n,r){if(r=r||[],!Array.isArray(e)&&!Object(a.A)(e))return void Object(a.b)(0===n.length,()=>`Element arr[${r.join("][")}] is a primitive, but should be an array/TypedArray of ${n[0]} elements`);Object(a.b)(n.length>0,()=>`Element arr[${r.join("][")}] should be a primitive, but is an array of ${e.length} elements`),Object(a.b)(e.length===n[0],()=>`Element arr[${r.join("][")}] should have ${n[0]} elements, but has ${e.length} elements`);const i=n.slice(1);for(let n=0;n<e.length;++n)t(e[n],i,r.concat(n))}(t,r,[]),r}function c(t,e,n,r){if(null!=t&&("numeric"!==t&&t!==e||"numeric"===t&&"string"===e))throw new Error(`Argument '${n}' passed to '${r}' must be ${t} tensor, but got ${e} tensor`)}function l(t,e,n,i="numeric"){if(t instanceof s.a)return c(i,t.dtype,e,n),t;let l=Object(a.r)(t);if("string"!==l&&["bool","int32","float32"].indexOf(i)>=0&&(l=i),c(i,l,e,n),null==t||!Object(a.A)(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t){const r=null==t?"null":t.constructor.name;throw new Error(`Argument '${e}' passed to '${n}' must be a Tensor or TensorLike, but got '${r}'`)}const h=u(t,l);Object(a.A)(t)||Array.isArray(t)||(t=[t]);const d="string"!==l?Object(o.toTypedArray)(t,l):Object(a.m)(t,[],!0);return r.a.makeTensor(d,h,l)}function h(t,e,n,r="numeric"){if(!Array.isArray(t))throw new Error(`Argument ${e} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return t.map((t,r)=>l(t,`${e}[${r}]`,n),r)}},function(t,e,n){"use strict";n.d(e,"d",(function(){return i})),n.d(e,"e",(function(){return s})),n.d(e,"f",(function(){return a})),n.d(e,"b",(function(){return o})),n.d(e,"g",(function(){return c})),n.d(e,"c",(function(){return l})),n.d(e,"a",(function(){return h}));var r=n(0);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function i(t,e,n,i,a){const o=e.inputParams[t];if(o&&void 0!==o.inputIndexStart){const t=o.inputIndexStart,u=0===o.inputIndexEnd?void 0:void 0===o.inputIndexEnd?t+1:o.inputIndexEnd;if("tensor"===o.type)return s(e.inputNames[o.inputIndexStart],n,i,a);if("tensors"===o.type){return e.inputNames.slice(t,u).map(t=>s(t,n,i,a))}const c=s(e.inputNames.slice(t)[0],n,i,a),l=c.dataSync();return"number"===o.type?l[0]:r.util.toNestedArray(c.shape,l)}const u=e.attrParams[t];return u&&u.value}function s(t,e,n,r){const[i,s]=c(t);if(null!=r){const t=r.getHashTableHandleByName(i);if(null!=t)return t}const a=n.currentContextIds.find(t=>!!e[u(i,t)]);return void 0!==a?e[u(i,a)][s]:void 0}function a(t,e,n){return e[u(t,n.currentContextId)]}function o(t,e){const[n,r]=c(t);return[u(n,e&&e.currentContextId),r]}function u(t,e){return e?`${t}-${e}`:t}function c(t){const e=t.split(":");if(1===e.length)return[t,0];return[e[0],Number(e[e.length-1])]}function l(t,e,n){let r=i("pad",t,e,n);if("explicit"===r){r=i("explicitPaddings",t,e,n);const s=[[0,0],[0,0],[0,0],[0,0]];for(let t=0;t<4;t++)s[t][0]=r[2*t],s[t][1]=r[2*t+1];return s}return r}function h(t){return t.kept?t:Object(r.clone)(t)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return r})),n.d(e,"b",(function(){return i})),n.d(e,"c",(function(){return s})),n.d(e,"d",(function(){return a})),n.d(e,"e",(function(){return o})),n.d(e,"f",(function(){return u})),n.d(e,"g",(function(){return c})),n.d(e,"h",(function(){return l})),n.d(e,"i",(function(){return h})),n.d(e,"j",(function(){return d})),n.d(e,"k",(function(){return p})),n.d(e,"l",(function(){return f})),n.d(e,"n",(function(){return m})),n.d(e,"m",(function(){return g})),n.d(e,"o",(function(){return b})),n.d(e,"r",(function(){return y})),n.d(e,"p",(function(){return v})),n.d(e,"q",(function(){return w})),n.d(e,"s",(function(){return x})),n.d(e,"t",(function(){return _})),n.d(e,"u",(function(){return O})),n.d(e,"v",(function(){return S})),n.d(e,"w",(function(){return k})),n.d(e,"x",(function(){return T})),n.d(e,"y",(function(){return C})),n.d(e,"z",(function(){return A})),n.d(e,"A",(function(){return N})),n.d(e,"B",(function(){return I})),n.d(e,"C",(function(){return E})),n.d(e,"D",(function(){return j})),n.d(e,"E",(function(){return M})),n.d(e,"F",(function(){return D})),n.d(e,"G",(function(){return R})),n.d(e,"H",(function(){return P})),n.d(e,"J",(function(){return F})),n.d(e,"I",(function(){return z})),n.d(e,"K",(function(){return L})),n.d(e,"L",(function(){return $})),n.d(e,"M",(function(){return B})),n.d(e,"N",(function(){return q})),n.d(e,"O",(function(){return V})),n.d(e,"P",(function(){return U})),n.d(e,"R",(function(){return W})),n.d(e,"Q",(function(){return G})),n.d(e,"S",(function(){return H})),n.d(e,"T",(function(){return K})),n.d(e,"U",(function(){return Q})),n.d(e,"W",(function(){return X})),n.d(e,"V",(function(){return Y})),n.d(e,"X",(function(){return J})),n.d(e,"Y",(function(){return Z})),n.d(e,"Z",(function(){return tt})),n.d(e,"ab",(function(){return et})),n.d(e,"bb",(function(){return nt})),n.d(e,"cb",(function(){return rt})),n.d(e,"db",(function(){return it})),n.d(e,"fb",(function(){return st})),n.d(e,"jb",(function(){return at})),n.d(e,"ib",(function(){return ot})),n.d(e,"kb",(function(){return ut})),n.d(e,"lb",(function(){return ct})),n.d(e,"nb",(function(){return lt})),n.d(e,"mb",(function(){return ht})),n.d(e,"ob",(function(){return dt})),n.d(e,"pb",(function(){return pt})),n.d(e,"qb",(function(){return ft})),n.d(e,"rb",(function(){return mt})),n.d(e,"ub",(function(){return gt})),n.d(e,"vb",(function(){return bt})),n.d(e,"wb",(function(){return yt})),n.d(e,"xb",(function(){return vt})),n.d(e,"yb",(function(){return wt})),n.d(e,"Ab",(function(){return xt})),n.d(e,"Bb",(function(){return _t})),n.d(e,"Cb",(function(){return Ot})),n.d(e,"zb",(function(){return St})),n.d(e,"sb",(function(){return kt})),n.d(e,"tb",(function(){return Tt})),n.d(e,"Db",(function(){return Ct})),n.d(e,"Jb",(function(){return At})),n.d(e,"Eb",(function(){return Nt})),n.d(e,"Hb",(function(){return It})),n.d(e,"Fb",(function(){return Et})),n.d(e,"Gb",(function(){return jt})),n.d(e,"Ib",(function(){return Mt})),n.d(e,"Kb",(function(){return Dt})),n.d(e,"Lb",(function(){return Rt})),n.d(e,"Mb",(function(){return Pt})),n.d(e,"Nb",(function(){return Ft})),n.d(e,"Ob",(function(){return zt})),n.d(e,"Pb",(function(){return Lt})),n.d(e,"Qb",(function(){return $t})),n.d(e,"Ub",(function(){return Bt})),n.d(e,"Rb",(function(){return qt})),n.d(e,"Sb",(function(){return Vt})),n.d(e,"Tb",(function(){return Ut})),n.d(e,"Wb",(function(){return Wt})),n.d(e,"Vb",(function(){return Gt})),n.d(e,"Xb",(function(){return Ht})),n.d(e,"Yb",(function(){return Kt})),n.d(e,"Zb",(function(){return Qt})),n.d(e,"ac",(function(){return Xt})),n.d(e,"bc",(function(){return Yt})),n.d(e,"cc",(function(){return Jt})),n.d(e,"dc",(function(){return Zt})),n.d(e,"ec",(function(){return te})),n.d(e,"fc",(function(){return ee})),n.d(e,"hc",(function(){return ne})),n.d(e,"kc",(function(){return re})),n.d(e,"lc",(function(){return ie})),n.d(e,"ic",(function(){return se})),n.d(e,"jc",(function(){return ae})),n.d(e,"gc",(function(){return oe})),n.d(e,"mc",(function(){return ue})),n.d(e,"oc",(function(){return ce})),n.d(e,"pc",(function(){return le})),n.d(e,"qc",(function(){return he})),n.d(e,"rc",(function(){return de})),n.d(e,"sc",(function(){return pe})),n.d(e,"xc",(function(){return fe})),n.d(e,"vc",(function(){return me})),n.d(e,"wc",(function(){return ge})),n.d(e,"uc",(function(){return be})),n.d(e,"tc",(function(){return ye})),n.d(e,"zc",(function(){return ve})),n.d(e,"Dc",(function(){return we})),n.d(e,"Jc",(function(){return xe})),n.d(e,"Ac",(function(){return _e})),n.d(e,"Cc",(function(){return Oe})),n.d(e,"yc",(function(){return Se})),n.d(e,"Fc",(function(){return ke})),n.d(e,"Ec",(function(){return Te})),n.d(e,"Ic",(function(){return Ce})),n.d(e,"Bc",(function(){return Ae})),n.d(e,"Hc",(function(){return Ne})),n.d(e,"Kc",(function(){return Ie})),n.d(e,"Lc",(function(){return Ee})),n.d(e,"Mc",(function(){return je})),n.d(e,"Nc",(function(){return Me})),n.d(e,"Oc",(function(){return De})),n.d(e,"Pc",(function(){return Re})),n.d(e,"Qc",(function(){return Pe})),n.d(e,"Rc",(function(){return Fe})),n.d(e,"Sc",(function(){return ze})),n.d(e,"Gc",(function(){return Le})),n.d(e,"eb",(function(){return $e})),n.d(e,"nc",(function(){return Be})),n.d(e,"Tc",(function(){return qe})),n.d(e,"gb",(function(){return Ve})),n.d(e,"hb",(function(){return Ue}));const r="Abs",i="Acos",s="Acosh",a="Add",o="AddN",u="All",c="Any",l="ArgMax",h="ArgMin",d="Asin",p="Asinh",f="Atan",m="Atanh",g="Atan2",b="AvgPool",y="AvgPoolBackprop",v="AvgPool3D",w="AvgPool3DBackprop",x="BatchMatMul",_="BatchToSpaceND",O="BroadcastTo",S="Cast",k="Ceil",T="ClipByValue",C="Complex",A="Concat",N="Conv2D",I="Conv2DBackpropFilter",E="Conv2DBackpropInput",j="Conv3D",M="Conv3DBackpropFilterV2",D="Conv3DBackpropInputV2",R="Cos",P="Cosh",F="Cumsum",z="CropAndResize",L="DepthToSpace",$="DepthwiseConv2dNative",B="DepthwiseConv2dNativeBackpropFilter",q="DepthwiseConv2dNativeBackpropInput",V="Diag",U="Dilation2D",W="Dilation2DBackpropInput",G="Dilation2DBackpropFilter",H="Div",K="Elu",Q="EluGrad",X="Erf",Y="Equal",J="Exp",Z="Expm1",tt="FFT",et="Fill",nt="FlipLeftRight",rt="Floor",it="FloorDiv",st="FusedBatchNorm",at="GatherV2",ot="GatherNd",ut="Greater",ct="GreaterEqual",lt="Identity",ht="IFFT",dt="Imag",pt="IsFinite",ft="IsInf",mt="IsNan",gt="Less",bt="LessEqual",yt="LinSpace",vt="Log",wt="Log1p",xt="LogicalAnd",_t="LogicalNot",Ot="LogicalOr",St="LogSoftmax",kt="LRN",Tt="LRNBackprop",Ct="Max",At="Maximum",Nt="MaxPool",It="MaxPoolBackprop",Et="MaxPool3D",jt="MaxPool3DBackprop",Mt="MaxPoolWithArgmax",Dt="Mean",Rt="Min",Pt="Minimum",Ft="MirrorPad",zt="Mod",Lt="Multiply",$t="Negate",Bt="NotEqual",qt="NonMaxSuppressionV3",Vt="NonMaxSuppressionV4",Ut="NonMaxSuppressionV5",Wt="OnesLike",Gt="OneHot",Ht="PadV2",Kt="Pool",Qt="Pow",Xt="Prelu",Yt="Prod",Jt="Range",Zt="Real",te="Reciprocal",ee="Relu",ne="Reshape",re="ResizeNearestNeighbor",ie="ResizeNearestNeighborGrad",se="ResizeBilinear",ae="ResizeBilinearGrad",oe="Relu6",ue="Reverse",ce="Round",le="Rsqrt",he="ScatterNd",de="SelectV2",pe="Selu",fe="Slice",me="Sin",ge="Sinh",be="Sign",ye="Sigmoid",ve="Softplus",we="Sqrt",xe="Sum",_e="SpaceToBatchND",Oe="SplitV",Se="Softmax",ke="SquaredDifference",Te="Square",Ce="Sub",Ae="SparseToDense",Ne="StridedSlice",Ie="Tan",Ee="Tanh",je="Tile",Me="TopK",De="Transpose",Re="Unique",Pe="Unpack",Fe="UnsortedSegmentSum",ze="ZerosLike",Le="Step",$e="FromPixels",Be="RotateWithOffset",qe="_FusedMatMul",Ve="FusedConv2D",Ue="FusedDepthwiseConv2D"},function(t,e,n){"use strict";n.d(e,"a",(function(){return s})),n.d(e,"b",(function(){return a}));var r=n(5),i=n(7);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const s="__op";function a(t){const e=Object.keys(t);if(1!==e.length)throw new Error("Please provide an object with a single key (operation name) mapping to a function. Got an object with "+e.length+" keys.");let n=e[0];const a=t[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=s;const o=(...t)=>{r.a.startScope(n);try{const e=a(...t);return Object(i.x)(e)&&console.error("Cannot return a Promise inside of tidy."),r.a.endScope(e),e}catch(t){throw r.a.endScope(null),t}};return Object.defineProperty(o,"name",{value:n,configurable:!0}),o}},function(t,e,n){"use strict";n.d(e,"b",(function(){return b})),n.d(e,"a",(function(){return y}));var r=n(147),i=n(26),s=n(151),a=n(3),o=n(74),u=n(7);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class c{constructor(t,e){this.backendTimer=t,this.logger=e,null==e&&(this.logger=new h)}profileKernel(t,e,n){let r;const i=this.backendTimer.time(()=>{r=n()});for(let e=0;e<r.length;e++){const n=r[e];n.data().then(e=>{l(e,n.dtype,t)})}return{kernelName:t,outputs:r,inputs:e,timeMs:i.then(t=>t.kernelMs),extraInfo:i.then(t=>null!=t.getExtraProfileInfo?t.getExtraProfileInfo():"")}}logKernelProfile(t){const{kernelName:e,outputs:n,timeMs:r,inputs:i,extraInfo:s}=t;n.forEach(t=>{Promise.all([t.data(),r,s]).then(n=>{this.logger.logKernelProfile(e,t,n[0],n[1],i,n[2])})})}}function l(t,e,n){if("float32"!==e)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(isNaN(r)||!isFinite(r))return console.warn(`Found ${r} in the result of '${n}'`),!0}return!1}class h{logKernelProfile(t,e,n,r,i,s){const a="number"==typeof r?u.L(r+"ms",9):r.error,o=u.L(t,25),c=e.rank,l=e.size,h=u.L(e.shape.toString(),14);let d="";for(const t in i){const n=i[t];if(null!=n){const r=n.shape||e.shape,i=r.length;d+=`${t}: ${i}D ${i>0?r:""} `}}console.log(`%c${o}\t%c${a}\t%c${c}D ${h}\t%c${l}\t%c${d}\t%c${s}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var d=n(6),p=n(25),f=n(10);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class m{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}}dispose(){for(const t in this.registeredVariables)this.registeredVariables[t].dispose()}}class g{constructor(t){this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new m}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then(()=>{});if(null!=this.backendInstance)return;const t=this.getSortedBackends();for(let e=0;e<t.length;e++){const n=t[e];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:t,asyncInit:e}=this.initializeBackendsAndReturnBest();if(e)throw new Error(`The highest priority backend '${t}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(t)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(t){if(!(t in this.registry)){if(!(t in this.registryFactory))return null;{const{asyncInit:e}=this.initializeBackend(t);if(e)return null}}return this.registry[t]}findBackendFactory(t){return t in this.registryFactory?this.registryFactory[t].factory:null}registerBackend(t,e,n=1){return t in this.registryFactory?(console.warn(t+" backend was already registered. Reusing existing backend factory."),!1):(this.registryFactory[t]={factory:e,priority:n},!0)}async setBackend(t){if(null==this.registryFactory[t])throw new Error(`Backend name '${t}' not found in registry`);if(this.backendName=t,null==this.registry[t]){this.backendInstance=null;const{success:e,asyncInit:n}=this.initializeBackend(t);if(!(n?await e:e))return!1}return this.backendInstance=this.registry[t],this.setupRegisteredKernels(),this.profiler=new c(this.backendInstance),!0}setupRegisteredKernels(){Object(o.d)(this.backendName).forEach(t=>{null!=t.setupFunc&&t.setupFunc(this.backendInstance)})}disposeRegisteredKernels(t){Object(o.d)(t).forEach(e=>{null!=e.disposeFunc&&e.disposeFunc(this.registry[t])})}initializeBackend(t){const e=this.registryFactory[t];if(null==e)throw new Error(`Cannot initialize backend ${t}, no registration found.`);try{const n=e.factory();if(!n||n instanceof r.b||"function"!=typeof n.then)return this.registry[t]=n,{success:!0,asyncInit:!1};{const e=++this.pendingBackendInitId,r=n.then(n=>!(e<this.pendingBackendInitId)&&(this.registry[t]=n,this.pendingBackendInit=null,!0)).catch(n=>(e<this.pendingBackendInitId||(this.pendingBackendInit=null,console.warn(`Initialization of backend ${t} failed`),console.warn(n.stack||n.message)),!1));return this.pendingBackendInit=r,{success:r,asyncInit:!0}}}catch(e){return console.warn(`Initialization of backend ${t} failed`),console.warn(e.stack||e.message),{success:!1,asyncInit:!1}}}removeBackend(t){if(!(t in this.registryFactory))throw new Error(t+" backend not found in registry");this.backendName===t&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,t in this.registry&&(this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t]),delete this.registryFactory[t],this.backendName===t&&(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((t,e)=>this.registryFactory[e].priority-this.registryFactory[t].priority)}initializeBackendsAndReturnBest(){const t=this.getSortedBackends();for(let e=0;e<t.length;e++){const n=t[e],{success:r,asyncInit:i}=this.initializeBackend(n);if(i||r)return{name:n,asyncInit:i}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(t,e){const n=this.state.tensorInfo.get(e),r=n.backend,i=this.readSync(e);r.disposeData(e),n.backend=t,t.move(e,i,n.shape,n.dtype),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(t,e){let n,r=null;if(null==e){if("function"!=typeof t)throw new Error("Please provide a function to tidy()");e=t}else{if("string"!=typeof t&&!(t instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof e)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");r=t}return this.scopedRun(()=>this.startScope(r),()=>this.endScope(n),()=>(n=e(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n))}scopedRun(t,e,n){t();try{const t=n();return e(),t}catch(t){throw e(),t}}nextTensorId(){return g.nextTensorId++}nextVariableId(){return g.nextVariableId++}clone(t){const e=this.makeTensorFromDataId(t.dataId,t.shape,t.dtype),n={x:t};return this.addTapeNode(this.state.activeScope.name,n,[e],t=>({x:()=>{const e={x:t},n={dtype:"float32"};return y.runKernelFunc(e=>e.cast(t,"float32"),e,null,a.v,n)}}),[],{}),e}runKernel(t,e,n,r,i){return this.runKernelFunc(null,e,null,t,n,r,i)}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(t,e,n){const r=this.backend.numDataIds();let i=0;n.forEach(t=>{i+="complex64"===t.dtype?3:1});const s=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],a=r-e-i-s;if(a>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${a} data ids) after running '${t}'`)}runKernelFunc(t,e,n,r,i,s,a){let u,c=[];const l=this.isTapeOn();null==r&&(r=null!=this.state.activeScope?this.state.activeScope.name:"");const h=this.state.numBytes,d=this.state.numTensors;let p;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);const f=Object(o.c)(r,this.backendName);let m,g;if(null!=f)p=()=>{const t=this.backend.numDataIds();m=f.kernelFunc({inputs:e,attrs:i,backend:this.backend});const n=Array.isArray(m)?m:[m];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(r,t,n);const o=n.map(({dataId:t,shape:e,dtype:n})=>this.makeTensorFromDataId(t,e,n));if(l){let t=this.getTensorsForGradient(r,e,o);if(null==t){null==a&&(a=[]);const e=o.filter((t,e)=>a[e]);t=(s||[]).slice().concat(e)}c=this.saveTensorsForBackwardMode(t)}return o};else{const e=t=>{l&&(c=t.map(t=>this.keep(this.clone(t))))};p=()=>{const n=this.backend.numDataIds();m=this.tidy(()=>t(this.backend,e));const i=Array.isArray(m)?m:[m];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(r,n,i),i}}return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(g=this.profiler.profileKernel(r,e,()=>p()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(g),u=g.outputs):u=p()}),l&&this.addTapeNode(r,e,u,n,c,i),this.state.profiling&&this.state.activeProfile.kernels.push({name:r,bytesAdded:this.state.numBytes-h,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-d,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(e).map(t=>null!=e[t]?e[t].shape:null),outputShapes:u.map(t=>t.shape),kernelTimeMs:g.timeMs,extraInfo:g.extraInfo}),Array.isArray(m)?u:u[0]}saveTensorsForBackwardMode(t){return t.map(t=>this.keep(this.clone(t)))}getTensorsForGradient(t,e,n){const r=Object(o.b)(t);if(null!=r){const t=r.inputsToSave||[],i=r.outputsToSave||[];let s;r.saveAllInputs?(u.b(Array.isArray(e),()=>"saveAllInputs is true, expected inputs to be an array."),s=Object.keys(e).map(t=>e[t])):s=t.map(t=>e[t]);const a=n.filter((t,e)=>i[e]);return s.concat(a)}return null}makeTensor(t,e,n,r){if(null==t)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;let i=t;"string"===n&&u.z(t[0])&&(i=t.map(t=>f.encodeString(t)));const s=r.write(i,e,n),a=new d.a(e,n,s,this.nextTensorId());if(this.incRef(a,r),"string"===n){const t=this.state.tensorInfo.get(s),e=Object(u.f)(i);this.state.numBytes+=e-t.bytes,t.bytes=e}return a}makeTensorFromDataId(t,e,n,r){n=n||"float32";const i=new d.a(e,n,t,this.nextTensorId());return this.incRef(i,r),i}makeVariable(t,e=!0,n,r){n=n||this.nextVariableId().toString(),null!=r&&r!==t.dtype&&(t=t.cast(r));const i=new d.c(t,e,n,this.nextTensorId());if(null!=this.state.registeredVariables[i.name])throw new Error(`Variable with name ${i.name} was already registered`);return this.state.registeredVariables[i.name]=i,this.incRef(i,this.backend),i}incRef(t,e){const n=this.state.tensorInfo.has(t.dataId)?this.state.tensorInfo.get(t.dataId).refCount:0;if(this.state.numTensors++,"string"===t.dtype&&this.state.numStringTensors++,0===n){this.state.numDataBuffers++;let n=0;"complex64"!==t.dtype&&"string"!==t.dtype&&(n=t.size*u.g(t.dtype)),this.state.tensorInfo.set(t.dataId,{backend:e||this.backend,dtype:t.dtype,shape:t.shape,bytes:n,refCount:0}),this.state.numBytes+=n}this.state.tensorInfo.get(t.dataId).refCount++,t instanceof d.c||this.track(t)}disposeTensor(t){if(!this.state.tensorInfo.has(t.dataId))return;this.state.numTensors--,"string"===t.dtype&&this.state.numStringTensors--;const e=this.state.tensorInfo.get(t.dataId);e.refCount<=1?("complex64"!==t.dtype&&(this.state.numBytes-=e.bytes),this.state.numDataBuffers--,e.backend.disposeData(t.dataId),this.state.tensorInfo.delete(t.dataId)):this.state.tensorInfo.get(t.dataId).refCount--}disposeVariables(){for(const t in this.state.registeredVariables){const e=this.state.registeredVariables[t];this.disposeVariable(e)}}disposeVariable(t){this.disposeTensor(t),null!=this.state.registeredVariables[t.name]&&delete this.state.registeredVariables[t.name]}memory(){const t=this.backend.memory();return t.numTensors=this.state.numTensors,t.numDataBuffers=this.state.numDataBuffers,t.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(t.unreliable=!0,null==t.reasons&&(t.reasons=[]),t.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),t}async profile(t){this.state.profiling=!0;const e=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await t(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map(t=>t.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-e,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const t of this.state.activeProfile.kernels)t.kernelTimeMs=await t.kernelTimeMs,t.extraInfo=await t.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(t,e,n,r,i,s){const a={id:this.state.nextTapeNodeId++,kernelName:t,inputs:e,outputs:n,saved:i},c=Object(o.b)(t);null!=c&&(r=c.gradFunc),null!=r&&(a.gradient=t=>(t=t.map((t,e)=>{if(null==t){const t=n[e],r=u.F(t.size,t.dtype);return this.makeTensor(r,t.shape,t.dtype)}return t}),r(t.length>1?t:t[0],i,s))),this.state.activeTape.push(a)}keep(t){return t.kept=!0,t}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(t){const e={track:[],name:"unnamed scope",id:this.state.nextScopeId++};t&&(e.name=t),this.state.scopeStack.push(e),this.state.activeScope=e}endScope(t){const e=Object(p.getTensorsInContainer)(t),n=new Set(e.map(t=>t.id));for(let t=0;t<this.state.activeScope.track.length;t++){const e=this.state.activeScope.track[t];e.kept||n.has(e.id)||e.dispose()}const r=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],e.forEach(t=>{t.kept||t.scopeId!==r.id||this.track(t)})}gradients(t,e,n,r=!1){if(u.b(e.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 i=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",t));u.b(i instanceof d.a,()=>"The result y returned by f() must be a tensor.");const s=function(t,e,n){const r={},i={};for(let t=0;t<e.length;t++)r[e[t].id]=!0;for(let n=0;n<t.length;n++){const s=t[n],a=s.inputs;for(const t in a){const n=a[t];let o=!1;for(let t=0;t<e.length;t++)if(r[n.id]){s.outputs.forEach(t=>r[t.id]=!0),o=!0,i[s.id]=!0;break}if(o)break}}const s={};s[n.id]=!0;const a={};for(let e=t.length-1;e>=0;e--){const n=t[e],r=n.inputs;for(let t=0;t<n.outputs.length;t++)if(s[n.outputs[t].id]){for(const t in r)s[r[t].id]=!0,a[n.id]=!0;break}}const o=[];for(let e=0;e<t.length;e++){const n=t[e];if(i[n.id]&&a[n.id]){const t={};for(const e in n.inputs){const i=n.inputs[e];r[i.id]&&(t[e]=i)}const e=Object.assign({},n);e.inputs=t,e.outputs=n.outputs,o.push(e)}}return o}(this.state.activeTape,e,i);if(!r&&0===s.length&&e.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 t={};t[i.id]=null==n?function(t){const e=Object(u.D)(Object(u.N)(t),"float32");return y.makeTensor(e,t,"float32")}(i.shape):n,function(t,e,n,r){for(let i=e.length-1;i>=0;i--){const s=e[i],a=[];if(s.outputs.forEach(e=>{const n=t[e.id];null!=n?a.push(n):a.push(null)}),null==s.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`);const o=s.gradient(a);for(const e in s.inputs){if(!(e in o))throw new Error(`Cannot backprop through input ${e}. Available gradients found: ${Object.keys(o)}.`);const i=n(()=>o[e]());if("float32"!==i.dtype)throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${e} must have 'float32' dtype, but has '${i.dtype}'`);const a=s.inputs[e];if(!u.a(i.shape,a.shape))throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${e}' has shape '${i.shape}', which does not match the shape of the input '${a.shape}'`);if(null==t[a.id])t[a.id]=i;else{const e=t[a.id];t[a.id]=r(e,i),e.dispose()}}}}(t,s,t=>this.tidy(t),v);const r=e.map(e=>t[e.id]);return 0===this.state.gradientDepth&&(this.state.activeTape.forEach(t=>{for(const e of t.saved)e.dispose()}),this.state.activeTape=null),{value:i,grads:r}})}customGrad(t){return u.b(u.u(t),()=>"The f passed in customGrad(f) must be a function."),(...e)=>{let n;u.b(e.every(t=>t instanceof d.a),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");const r={};return e.forEach((t,e)=>{r[e]=t}),this.runKernelFunc((r,i)=>(n=t(...e,i),u.b(n.value instanceof d.a,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),u.b(u.u(n.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),n.value),r,(t,r)=>{const i=n.gradFunc(t,r),s=Array.isArray(i)?i:[i];u.b(s.length===e.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(...)."),u.b(s.every(t=>t instanceof d.a),()=>"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 a={};return s.forEach((t,e)=>{a[e]=()=>t}),a})}}readSync(t){return this.state.tensorInfo.get(t).backend.readSync(t)}read(t){return this.state.tensorInfo.get(t).backend.read(t)}async time(t){const e=Object(f.now)(),n=await this.backend.time(t);return n.wallMs=Object(f.now)()-e,n}track(t){return null!=this.state.activeScope&&(t.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(t)),t}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new m;for(const t in this.registry)this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}function b(){const t=Object(s.b)();if(null==t._tfengine){const e=new i.b(t);t._tfengine=new g(e)}return Object(i.d)(t._tfengine.ENV),Object(d.f)(()=>t._tfengine),t._tfengine}g.nextTensorId=0,g.nextVariableId=0;const y=b();function v(t,e){const n={a:t,b:e};return y.runKernelFunc((n,r)=>{const i=n.add(t,e);return r([t,e]),i},n,null,a.d)}},function(t,e,n){"use strict";n.d(e,"b",(function(){return c})),n.d(e,"f",(function(){return p})),n.d(e,"e",(function(){return f})),n.d(e,"d",(function(){return m})),n.d(e,"a",(function(){return g})),n.d(e,"c",(function(){return b}));var r=n(7);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function i(t,e,n,i){const u=Object(r.j)(e),c=function(t,e,n,i){const a=Object(r.N)(e),u=i[i.length-1],c=new Array(u).fill(0),l=e.length,h="complex64"===n?o(t):t;if(l>1)for(let t=0;t<a/u;t++){const e=t*u;for(let t=0;t<u;t++)c[t]=Math.max(c[t],s(h[e+t],0,n).length)}return c}(t,e,n,u),l=e.length,h=function t(e,n,r,i,u,c=!0){const l="complex64"===r?2:1,h=n[0],d=n.length;if(0===d){if("complex64"===r){return[s(o(e)[0],0,r)]}return"bool"===r?[a(e[0])]:[e[0].toString()]}if(1===d){if(h>20){const t=3*l;let n=Array.from(e.slice(0,t)),i=Array.from(e.slice((h-3)*l,h*l));return"complex64"===r&&(n=o(n),i=o(i)),["["+n.map((t,e)=>s(t,u[e],r)).join(", ")+", ..., "+i.map((t,e)=>s(t,u[h-3+e],r)).join(", ")+"]"]}return["["+("complex64"===r?o(e):Array.from(e)).map((t,e)=>s(t,u[e],r)).join(", ")+"]"]}const p=n.slice(1),f=i.slice(1),m=i[0]*l,g=[];if(h>20){for(let n=0;n<3;n++){const i=n*m,s=i+m;g.push(...t(e.slice(i,s),p,r,f,u,!1))}g.push("...");for(let n=h-3;n<h;n++){const i=n*m,s=i+m;g.push(...t(e.slice(i,s),p,r,f,u,n===h-1))}}else for(let n=0;n<h;n++){const i=n*m,s=i+m;g.push(...t(e.slice(i,s),p,r,f,u,n===h-1))}const b=2===d?",":"";g[0]="["+g[0]+b;for(let t=1;t<g.length-1;t++)g[t]=" "+g[t]+b;let y=",\n";for(let t=2;t<d;t++)y+="\n";return g[g.length-1]=" "+g[g.length-1]+"]"+(c?"":y),g}(t,e,n,u,c),d=["Tensor"];return i&&(d.push("  dtype: "+n),d.push("  rank: "+l),d.push(`  shape: [${e}]`),d.push("  values:")),d.push(h.map(t=>"    "+t).join("\n")),d.join("\n")}function s(t,e,n){let i;return i=Array.isArray(t)?parseFloat(t[0].toFixed(7))+" + "+parseFloat(t[1].toFixed(7))+"j":Object(r.z)(t)?`'${t}'`:"bool"===n?a(t):parseFloat(t.toFixed(7)).toString(),Object(r.L)(i,e)}function a(t){return 0===t?"false":"true"}function o(t){const e=[];for(let n=0;n<t.length;n+=2)e.push([t[n],t[n+1]]);return e}var u=n(10);
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class c{constructor(t,e,n){if(this.dtype=e,this.shape=t.slice(),this.size=r.N(t),null!=n){const t=n.length;r.b(t===this.size,()=>`Length of values '${t}' does not match the size inferred by the shape '${this.size}'.`)}if("complex64"===e)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||r.n(e,this.size),this.strides=Object(r.j)(t)}set(t,...e){0===e.length&&(e=[0]),r.b(e.length===this.rank,()=>`The number of provided coordinates (${e.length}) must match the rank (${this.rank})`);const n=this.locToIndex(e);this.values[n]=t}get(...t){0===t.length&&(t=[0]);let e=0;for(const n of t){if(n<0||n>=this.shape[e]){const e=`Requested out of range element at ${t}.   Buffer shape=`+this.shape;throw new Error(e)}e++}let n=t[t.length-1];for(let e=0;e<t.length-1;++e)n+=this.strides[e]*t[e];return this.values[n]}locToIndex(t){if(0===this.rank)return 0;if(1===this.rank)return t[0];let e=t[t.length-1];for(let n=0;n<t.length-1;++n)e+=this.strides[n]*t[n];return e}indexToLoc(t){if(0===this.rank)return[];if(1===this.rank)return[t];const e=new Array(this.shape.length);for(let n=0;n<e.length-1;++n)e[n]=Math.floor(t/this.strides[n]),t-=e[n]*this.strides[n];return e[e.length-1]=t,e}get rank(){return this.shape.length}toTensor(){return l().makeTensor(this.values,this.shape,this.dtype)}}let l=null,h=null,d=null;function p(t){l=t}function f(t){h=t}function m(t){d=t}class g{constructor(t,e,n,i){this.kept=!1,this.isDisposedInternal=!1,this.shape=t.slice(),this.dtype=e||"float32",this.size=r.N(t),this.strides=Object(r.j)(t),this.dataId=n,this.id=i,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){const t=await this.data();return h.buffer(this.shape,this.dtype,t)}bufferSync(){return h.buffer(this.shape,this.dtype,this.dataSync())}async array(){const t=await this.data();return Object(r.S)(this.shape,t)}arraySync(){return Object(r.S)(this.shape,this.dataSync())}async data(){this.throwIfDisposed();const t=l().read(this.dataId);if("string"===this.dtype){const e=await t;try{return e.map(t=>u.decodeString(t))}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return t}dataSync(){this.throwIfDisposed();const t=l().readSync(this.dataId);if("string"===this.dtype)try{return t.map(t=>u.decodeString(t))}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return t}async bytes(){this.throwIfDisposed();const t=await l().read(this.dataId);return"string"===this.dtype?t:new Uint8Array(t.buffer)}dispose(){this.isDisposed||(l().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(t=!1){return h.print(this,t)}clone(){return this.throwIfDisposed(),h.clone(this)}toString(t=!1){return i(this.dataSync(),this.shape,this.dtype,t)}cast(t){return this.throwIfDisposed(),h.cast(this,t)}variable(t=!0,e,n){return this.throwIfDisposed(),l().makeVariable(this,t,e,n)}}Object.defineProperty(g,Symbol.hasInstance,{value:t=>!!t&&null!=t.data&&null!=t.dataSync&&null!=t.throwIfDisposed});class b extends g{constructor(t,e,n,r){super(t.shape,t.dtype,t.dataId,r),this.trainable=e,this.name=n}assign(t){if(t.dtype!==this.dtype)throw new Error(`dtype of the new value (${t.dtype}) and previous value (${this.dtype}) must match`);if(!r.a(t.shape,this.shape))throw new Error(`shape of the new value (${t.shape}) and previous value (${this.shape}) must match`);l().disposeTensor(this),this.dataId=t.dataId,l().incRef(this,null)}dispose(){l().disposeVariable(this),this.isDisposedInternal=!0}}Object.defineProperty(b,Symbol.hasInstance,{value:t=>t instanceof g&&null!=t.assign&&t.assign instanceof Function})},function(t,e,n){"use strict";
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function r(t){let e=t.length,n=0,r=0;for(;e>0;)r=Math.random()*e|0,e--,n=t[e],t[e]=t[r],t[r]=n}function i(t,e,n){return Math.max(t,Math.min(e,n))}function s(t){return t%2==0?t:t+1}function a(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n];return e}function o(t,e){const n=Math.random();return e*n+(1-n)*t}function u(t,e){let n=0;for(let r=0;r<t.length;r++){const i=Number(t[r])-Number(e[r]);n+=i*i}return n}function c(t,e){if(!t)throw new Error("string"==typeof e?e:e())}function l(t,e,n=""){c(m(t,e),()=>n+` Shapes ${t} and ${e} must match`)}function h(t){c(null!=t,()=>"The input to the tensor constructor must be a non-null value.")}function d(t,e=[],n=!1){if(null==e&&(e=[]),Array.isArray(t)||I(t)&&!n)for(let r=0;r<t.length;++r)d(t[r],e,n);else e.push(t);return e}function p(t){if(0===t.length)return 1;let e=t[0];for(let n=1;n<t.length;n++)e*=t[n];return e}function f(t){return 0===t.length}function m(t,e){if(t===e)return!0;if(null==t||null==e)return!1;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function g(t){return t%1==0}function b(t){if(null!=Math.tanh)return Math.tanh(t);if(t===1/0)return 1;if(t===-1/0)return-1;{const e=Math.exp(2*t);return(e-1)/(e+1)}}function y(t){const e=Math.ceil(Math.sqrt(t));return[e,Math.ceil(t/e)]}function v(t){const e=new Uint32Array(t);for(let n=0;n<t;++n)e[n]=n;return r(e),e}function w(t,e){return e<=t.length?t:t+" ".repeat(e-t.length)}function x(t,e=(t=>0),n){return new Promise((r,i)=>{let s=0;const a=()=>{if(t())return void r();s++;const o=e(s);null!=n&&s>=n?i():setTimeout(a,o)};a()})}function _(t,e){let n=1,r=-1;for(let e=0;e<t.length;++e)if(t[e]>=0)n*=t[e];else if(-1===t[e]){if(-1!==r)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${e}`);r=e}else if(t[e]<0)throw Error(`Shapes can not be < 0. Found ${t[e]} at dim ${e}`);if(-1===r){if(e>0&&e!==n)throw Error(`Size(${e}) must match the product of shape ${t}`);return t}if(0===n)throw Error(`Cannot infer the missing size in [${t}] when there are 0 elements`);if(e%n!=0)throw Error(`The implicit shape can't be a fractional number. Got ${e} / ${n}`);const i=t.slice();return i[r]=e/n,i}function O(t,e){const n=e.length;return c((t=null==t?e.map((t,e)=>e):[].concat(t)).every(t=>t>=-n&&t<n),()=>`All values in axis param must be in range [-${n}, ${n}) but got axis `+t),c(t.every(t=>g(t)),()=>"All values in axis param must be integers but got axis "+t),t.map(t=>t<0?n+t:t)}function S(t,e){const n=[],r=[],i=null!=e&&Array.isArray(e)&&0===e.length,s=null==e||i?null:O(e,t).sort();let a=0;for(let e=0;e<t.length;++e){if(null!=s){if(s[a]===e&&1!==t[e])throw new Error(`Can't squeeze axis ${e} since its dim '${t[e]}' is not 1`);(null==s[a]||s[a]>e)&&1===t[e]&&(n.push(t[e]),r.push(e)),s[a]<=e&&a++}1!==t[e]&&(n.push(t[e]),r.push(e))}return{newShape:n,keptDims:r}}function k(t,e){let n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else{if("bool"!==t)throw new Error("Unknown data type "+t);n=new Uint8Array(e)}return n}function T(t,e){let n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else if("bool"===t)n=new Uint8Array(e);else{if("string"!==t)throw new Error("Unknown data type "+t);n=new Array(e)}return n}function C(t,e){for(let n=0;n<t.length;n++){const r=t[n];if(isNaN(r)||!isFinite(r))throw Error(`A tensor of type ${e} being uploaded contains ${r}.`)}}function A(t){return"bool"===t||"complex64"===t||"float32"===t||"int32"===t||"string"===t}function N(t,e){return"complex64"!==e&&(("float32"!==e||"complex64"===t)&&(("int32"!==e||"float32"===t||"complex64"===t)&&("bool"!==e||"bool"!==t)))}function I(t){return t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array}function E(t){if("float32"===t||"int32"===t)return 4;if("complex64"===t)return 8;if("bool"===t)return 1;throw new Error("Unknown dtype "+t)}function j(t){if(null==t)return 0;let e=0;return t.forEach(t=>e+=t.length),e}function M(t){return"string"==typeof t||t instanceof String}function D(t){return"boolean"==typeof t}function R(t){return"number"==typeof t}function P(t){return Array.isArray(t)?P(t[0]):t instanceof Float32Array?"float32":t instanceof Int32Array||t instanceof Uint8Array?"int32":R(t)?"float32":M(t)?"string":D(t)?"bool":"float32"}function F(t){return!!(t&&t.constructor&&t.call&&t.apply)}function z(t,e){for(let n=e;n<t;++n)if(t%n==0)return n;return t}function L(t){const e=t.length;if(e<2)return[];const n=new Array(e-1);n[e-2]=t[e-1];for(let r=e-3;r>=0;--r)n[r]=n[r+1]*t[r+1];return n}function $(t,e){if(0===t.length)return e[0];const n=t.reduce((t,e)=>t*e);if(0===n)return[];if(n!==e.length)throw new Error(`[${t}] does not match the input size ${e.length}.`);return function t(e,n,r){const i=new Array;if(1===n.length){const t=n[0];for(let n=0;n<t;n++)i[n]=r[e+n]}else{const s=n[0],a=n.slice(1),o=a.reduce((t,e)=>t*e);for(let n=0;n<s;n++)i[n]=t(e+n*o,a,r)}return i}(0,t,e)}function B(t,e){const n=q(t,e);for(let t=0;t<n.length;t++)n[t]=1;return n}function q(t,e){if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e)return new Uint8Array(t);throw new Error("Unknown data type "+e)}function V(t,e){const n=t.reduce((t,e)=>t*e,1);if(null==e||"float32"===e)return $(t,new Float32Array(n));if("int32"===e)return $(t,new Int32Array(n));if("bool"===e)return $(t,new Uint8Array(n));throw new Error("Unknown data type "+e)}function U(t){t.forEach(e=>{c(Number.isInteger(e)&&e>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${t}].`)})}function W(t,e,n){if(0===e)return 0;if(1===e)return t[0];let r=t[t.length-1];for(let e=0;e<t.length-1;++e)r+=n[e]*t[e];return r}function G(t,e,n){if(0===e)return[];if(1===e)return[t];const r=new Array(e);for(let e=0;e<r.length-1;++e)r[e]=Math.floor(t/n[e]),t-=r[e]*n[e];return r[r.length-1]=t,r}function H(t){return t&&t.then&&"function"==typeof t.then}n.d(e,"M",(function(){return r})),n.d(e,"i",(function(){return i})),n.d(e,"H",(function(){return s})),n.d(e,"Q",(function(){return a})),n.d(e,"J",(function(){return o})),n.d(e,"l",(function(){return u})),n.d(e,"b",(function(){return c})),n.d(e,"e",(function(){return l})),n.d(e,"d",(function(){return h})),n.d(e,"m",(function(){return d})),n.d(e,"N",(function(){return p})),n.d(e,"y",(function(){return f})),n.d(e,"a",(function(){return m})),n.d(e,"v",(function(){return g})),n.d(e,"R",(function(){return b})),n.d(e,"O",(function(){return y})),n.d(e,"k",(function(){return v})),n.d(e,"L",(function(){return w})),n.d(e,"K",(function(){return x})),n.d(e,"s",(function(){return _})),n.d(e,"I",(function(){return O})),n.d(e,"P",(function(){return S})),n.d(e,"o",(function(){return k})),n.d(e,"n",(function(){return T})),n.d(e,"h",(function(){return C})),n.d(e,"B",(function(){return A})),n.d(e,"p",(function(){return N})),n.d(e,"A",(function(){return I})),n.d(e,"g",(function(){return E})),n.d(e,"f",(function(){return j})),n.d(e,"z",(function(){return M})),n.d(e,"t",(function(){return D})),n.d(e,"w",(function(){return R})),n.d(e,"r",(function(){return P})),n.d(e,"u",(function(){return F})),n.d(e,"G",(function(){return z})),n.d(e,"j",(function(){return L})),n.d(e,"S",(function(){return $})),n.d(e,"D",(function(){return B})),n.d(e,"F",(function(){return q})),n.d(e,"E",(function(){return V})),n.d(e,"c",(function(){return U})),n.d(e,"C",(function(){return W})),n.d(e,"q",(function(){return G})),n.d(e,"x",(function(){return H}))},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4);const u=Object(o.b)({reshape_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){const n=Object(s.a)(t,"x","reshape",null),o={x:n},u={shape:e};return r.a.runKernelFunc((t,r)=>(e=a.s(e,n.size),a.b(n.size===a.N(e),()=>"new shape and old shape must have the same number of elements."),r([n]),t.reshape(n,e)),o,null,i.hc,u)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(4);const u=Object(o.b)({mul_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","mul"),o=Object(a.a)(e,"b","mul");[n,o]=Object(s.makeTypesMatch)(n,o);const u={a:n,b:o};return r.a.runKernelFunc((t,e)=>{const r=t.multiply(n,o);return e([n,o]),r},u,null,i.Pb)}})},function(t,e,n){"use strict";n.r(e),n.d(e,"createScalarValue",(function(){return s})),n.d(e,"toTypedArray",(function(){return a})),n.d(e,"now",(function(){return o})),n.d(e,"fetch",(function(){return u})),n.d(e,"encodeString",(function(){return c})),n.d(e,"decodeString",(function(){return l}));var r=n(26),i=n(7);
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function s(t,e){return"string"===e?c(t):a([t],e)}function a(t,e){if("string"===e)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(t)&&(t=i.m(t)),Object(r.c)().getBool("DEBUG")&&i.h(t,e),function(t,e){return t instanceof Float32Array&&"float32"===e||t instanceof Int32Array&&"int32"===e||t instanceof Uint8Array&&"bool"===e}(t,e))return t;if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e){const e=new Uint8Array(t.length);for(let n=0;n<e.length;++n)0!==Math.round(t[n])&&(e[n]=1);return e}throw new Error("Unknown data type "+e)}function o(){return Object(r.c)().platform.now()}function u(t,e){return Object(r.c)().platform.fetch(t,e)}function c(t,e="utf-8"){return e=e||"utf-8",Object(r.c)().platform.encode(t,e)}function l(t,e="utf-8"){return e=e||"utf-8",Object(r.c)().platform.decode(t,e)}n.d(e,"shuffle",(function(){return i.M})),n.d(e,"clamp",(function(){return i.i})),n.d(e,"nearestLargerEven",(function(){return i.H})),n.d(e,"sum",(function(){return i.Q})),n.d(e,"randUniform",(function(){return i.J})),n.d(e,"distSquared",(function(){return i.l})),n.d(e,"assert",(function(){return i.b})),n.d(e,"assertShapesMatch",(function(){return i.e})),n.d(e,"assertNonNull",(function(){return i.d})),n.d(e,"flatten",(function(){return i.m})),n.d(e,"sizeFromShape",(function(){return i.N})),n.d(e,"isScalarShape",(function(){return i.y})),n.d(e,"arraysEqual",(function(){return i.a})),n.d(e,"isInt",(function(){return i.v})),n.d(e,"tanh",(function(){return i.R})),n.d(e,"sizeToSquarishShape",(function(){return i.O})),n.d(e,"createShuffledIndices",(function(){return i.k})),n.d(e,"rightPad",(function(){return i.L})),n.d(e,"repeatedTry",(function(){return i.K})),n.d(e,"inferFromImplicitShape",(function(){return i.s})),n.d(e,"parseAxisParam",(function(){return i.I})),n.d(e,"squeezeShape",(function(){return i.P})),n.d(e,"getTypedArrayFromDType",(function(){return i.o})),n.d(e,"getArrayFromDType",(function(){return i.n})),n.d(e,"checkConversionForErrors",(function(){return i.h})),n.d(e,"isValidDtype",(function(){return i.B})),n.d(e,"hasEncodingLoss",(function(){return i.p})),n.d(e,"isTypedArray",(function(){return i.A})),n.d(e,"bytesPerElement",(function(){return i.g})),n.d(e,"bytesFromStringArray",(function(){return i.f})),n.d(e,"isString",(function(){return i.z})),n.d(e,"isBoolean",(function(){return i.t})),n.d(e,"isNumber",(function(){return i.w})),n.d(e,"inferDtype",(function(){return i.r})),n.d(e,"isFunction",(function(){return i.u})),n.d(e,"nearestDivisor",(function(){return i.G})),n.d(e,"computeStrides",(function(){return i.j})),n.d(e,"toNestedArray",(function(){return i.S})),n.d(e,"makeOnesTypedArray",(function(){return i.D})),n.d(e,"makeZerosTypedArray",(function(){return i.F})),n.d(e,"makeZerosNestedTypedArray",(function(){return i.E})),n.d(e,"assertNonNegativeIntegerDimensions",(function(){return i.c})),n.d(e,"locToIndex",(function(){return i.C})),n.d(e,"indexToLoc",(function(){return i.q})),n.d(e,"isPromise",(function(){return i.x}))},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(0);
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function i(t,e){Array.isArray(t)||(t=[t]),t.forEach(t=>{null!=t&&r.util.assert("complex64"!==t.dtype,()=>e+" does not support complex64 tensors in the CPU backend.")})}},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4);const u=Object(o.b)({cast_:
/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){const n=Object(s.a)(t,"x","cast");if(!a.B(e))throw new Error("Failed to cast to unknown dtype "+e);if("string"===e&&"string"!==n.dtype||"string"!==e&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");const o={x:n},u={dtype:e};return r.a.runKernelFunc(t=>t.cast(n,e),o,null,i.v,u)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(4);const u=Object(o.b)({add_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","add"),o=Object(a.a)(e,"b","add");[n,o]=Object(s.makeTypesMatch)(n,o);const u={a:n,b:o};return r.a.runKernelFunc((t,e)=>{const r=t.add(n,o);return e([n,o]),r},u,null,i.d)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(4);const u=Object(o.b)({sub_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","sub"),o=Object(a.a)(e,"b","sub");[n,o]=Object(s.makeTypesMatch)(n,o);const u={a:n,b:o};return r.a.runKernelFunc((t,e)=>{const r=t.subtract(n,o);return e([n,o]),r},u,null,i.Ic)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));var r=n(7),i=n(47);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function s(t,e){if((Object(r.A)(t)&&"string"!==e||Array.isArray(t))&&"complex64"!==e)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===e&&Object(r.A)(t)&&!(t instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return Object(i.a)(t,[],[],e)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(122),u=n(4);const c=Object(u.b)({div_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","div"),u=Object(a.a)(e,"b","div");if([n,u]=Object(s.makeTypesMatch)(n,u),"int32"===n.dtype&&"int32"===u.dtype)return Object(o.a)(n,u);const c={a:n,b:u};return r.a.runKernelFunc((t,e)=>{const r=t.realDivide(n,u);return e([n,u]),r},c,null,i.S,{})}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return s})),n.d(e,"b",(function(){return a}));var r=n(0),i=n(11);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function s(t,e,n){return({inputs:s,attrs:a,backend:o})=>{const{x:u}=s;if(Object(i.a)(u,t),"string"===u.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const c=o,l=c.data.get(u.dataId).values,h=r.util.sizeFromShape(u.shape),d=n||u.dtype,p=r.util.getArrayFromDType(d,h);for(let t=0;t<h;++t)p[t]=e(l[t],a);return c.makeTensorInfo(u.shape,d,p)}}function a(t,e,n){return({inputs:r,attrs:s,backend:a})=>{const{x:o}=r;if(Object(i.a)(o,t),"string"===o.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const u=a,c=u.data.get(o.dataId).values,l=n||o.dtype,h=e(c,l,s);return u.makeTensorInfo(o.shape,l,h)}}},function(t,e,n){"use strict";
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function r(t,e){const n=t.length,r=[];for(let i=0;i<n;i++){const s=n-1-i,a=t[s]||1;(e[e.length-1-i]||1)>1&&1===a&&r.unshift(s)}return r}function i(t,e){const n=[];for(let r=0;r<e.length;r++){const i=t[t.length-r-1],s=e.length-r-1,a=e[s];(null==i||1===i&&a>1)&&n.unshift(s)}return n}function s(t,e){const n=[],r=Math.max(t.length,e.length);for(let i=0;i<r;i++){let r=t[t.length-i-1];null==r&&(r=1);let s=e[e.length-i-1];if(null==s&&(s=1),1===r)n.unshift(s);else if(1===s)n.unshift(r);else{if(r!==s){throw Error(`Operands could not be broadcast together with shapes ${t} and ${e}.`)}n.unshift(r)}}return n}n.d(e,"b",(function(){return r})),n.d(e,"c",(function(){return i})),n.d(e,"a",(function(){return s}))},function(t,e,n){"use strict";n.d(e,"b",(function(){return i.a})),n.d(e,"c",(function(){return s.a})),n.d(e,"d",(function(){return a.a})),n.d(e,"e",(function(){return o.a})),n.d(e,"f",(function(){return u.a})),n.d(e,"h",(function(){return c.a})),n.d(e,"i",(function(){return l.a})),n.d(e,"j",(function(){return h.a})),n.d(e,"k",(function(){return d.a})),n.d(e,"l",(function(){return p.a})),n.d(e,"m",(function(){return f.a})),n.d(e,"n",(function(){return m.a})),n.d(e,"o",(function(){return g.a})),n.d(e,"p",(function(){return b.a})),n.d(e,"q",(function(){return y.a})),n.d(e,"r",(function(){return v.a})),n.d(e,"s",(function(){return A})),n.d(e,"x",(function(){return N.a})),n.d(e,"t",(function(){return I.a})),n.d(e,"u",(function(){return j})),n.d(e,"v",(function(){return M})),n.d(e,"w",(function(){return D})),n.d(e,"z",(function(){return R.a})),n.d(e,"A",(function(){return P.a})),n.d(e,"B",(function(){return F.a})),n.d(e,"C",(function(){return z.a})),n.d(e,"D",(function(){return L.a})),n.d(e,"E",(function(){return $.a})),n.d(e,"F",(function(){return B.a})),n.d(e,"G",(function(){return x.a})),n.d(e,"H",(function(){return q})),n.d(e,"I",(function(){return V})),n.d(e,"J",(function(){return U})),n.d(e,"K",(function(){return W})),n.d(e,"L",(function(){return G.a})),n.d(e,"M",(function(){return H.a})),n.d(e,"N",(function(){return K.a})),n.d(e,"O",(function(){return Q.a})),n.d(e,"P",(function(){return Y})),n.d(e,"Q",(function(){return J.a})),n.d(e,"R",(function(){return Z.a})),n.d(e,"T",(function(){return tt.a})),n.d(e,"U",(function(){return et.a})),n.d(e,"V",(function(){return nt.a})),n.d(e,"W",(function(){return at})),n.d(e,"X",(function(){return ot.a})),n.d(e,"Y",(function(){return ut.a})),n.d(e,"Z",(function(){return ct.a})),n.d(e,"bb",(function(){return lt.a})),n.d(e,"db",(function(){return ht.a})),n.d(e,"fb",(function(){return dt.a})),n.d(e,"hb",(function(){return pt.a})),n.d(e,"ib",(function(){return ft.a})),n.d(e,"jb",(function(){return mt.a})),n.d(e,"kb",(function(){return gt.a})),n.d(e,"lb",(function(){return yt})),n.d(e,"nb",(function(){return vt.a})),n.d(e,"ob",(function(){return wt.a})),n.d(e,"pb",(function(){return xt.a})),n.d(e,"rb",(function(){return _t.a})),n.d(e,"tb",(function(){return Ot.a})),n.d(e,"ub",(function(){return St.a})),n.d(e,"yb",(function(){return kt.a})),n.d(e,"Cb",(function(){return Tt.a})),n.d(e,"Db",(function(){return Ct.a})),n.d(e,"Eb",(function(){return At.a})),n.d(e,"Fb",(function(){return Nt.a})),n.d(e,"Gb",(function(){return It.a})),n.d(e,"Hb",(function(){return Et.a})),n.d(e,"Lb",(function(){return jt.a})),n.d(e,"Mb",(function(){return Mt.a})),n.d(e,"Nb",(function(){return Dt.a})),n.d(e,"Ob",(function(){return Rt.a})),n.d(e,"Pb",(function(){return Pt.a})),n.d(e,"Qb",(function(){return Ft.a})),n.d(e,"Rb",(function(){return zt.a})),n.d(e,"Sb",(function(){return Lt.a})),n.d(e,"Tb",(function(){return $t.a})),n.d(e,"Ub",(function(){return Bt.a})),n.d(e,"Vb",(function(){return qt.a})),n.d(e,"Xb",(function(){return _.a})),n.d(e,"Yb",(function(){return Vt.a})),n.d(e,"Zb",(function(){return Ut.a})),n.d(e,"ac",(function(){return Wt.a})),n.d(e,"bc",(function(){return Gt.a})),n.d(e,"cc",(function(){return Ht.a})),n.d(e,"ec",(function(){return Kt.a})),n.d(e,"fc",(function(){return Qt.a})),n.d(e,"gc",(function(){return Xt.a})),n.d(e,"ic",(function(){return Yt.a})),n.d(e,"jc",(function(){return Jt.a})),n.d(e,"lc",(function(){return ne})),n.d(e,"nc",(function(){return O.a})),n.d(e,"pc",(function(){return re})),n.d(e,"qc",(function(){return ie.a})),n.d(e,"rc",(function(){return se.a})),n.d(e,"tc",(function(){return ae.a})),n.d(e,"vc",(function(){return oe.a})),n.d(e,"wc",(function(){return ue.a})),n.d(e,"xc",(function(){return ce.a})),n.d(e,"zc",(function(){return le})),n.d(e,"Ac",(function(){return he.a})),n.d(e,"Bc",(function(){return de})),n.d(e,"Cc",(function(){return pe})),n.d(e,"Dc",(function(){return fe})),n.d(e,"Ec",(function(){return me})),n.d(e,"Fc",(function(){return ge.a})),n.d(e,"Gc",(function(){return be.a})),n.d(e,"Ic",(function(){return ye.a})),n.d(e,"Jc",(function(){return ve.a})),n.d(e,"Kc",(function(){return we.a})),n.d(e,"Lc",(function(){return xe})),n.d(e,"Mc",(function(){return Oe})),n.d(e,"Nc",(function(){return Se})),n.d(e,"Oc",(function(){return ke.a})),n.d(e,"Pc",(function(){return Te.a})),n.d(e,"Qc",(function(){return Ce.a})),n.d(e,"Rc",(function(){return Ae.a})),n.d(e,"Sc",(function(){return Ne.a})),n.d(e,"Tc",(function(){return Ie.a})),n.d(e,"Uc",(function(){return st.a})),n.d(e,"Vc",(function(){return Ee.a})),n.d(e,"Wc",(function(){return je})),n.d(e,"Xc",(function(){return Me})),n.d(e,"Yc",(function(){return De})),n.d(e,"Zc",(function(){return Re})),n.d(e,"bd",(function(){return Pe.a})),n.d(e,"cd",(function(){return Fe.a})),n.d(e,"dd",(function(){return ze.a})),n.d(e,"fd",(function(){return Le.a})),n.d(e,"gd",(function(){return $e.a})),n.d(e,"hd",(function(){return Be.a})),n.d(e,"id",(function(){return k.a})),n.d(e,"jd",(function(){return qe.a})),n.d(e,"ld",(function(){return Ve.a})),n.d(e,"md",(function(){return Ue.a})),n.d(e,"nd",(function(){return T.a})),n.d(e,"od",(function(){return We})),n.d(e,"pd",(function(){return Ge})),n.d(e,"qd",(function(){return He})),n.d(e,"rd",(function(){return Ke})),n.d(e,"sd",(function(){return Qe.a})),n.d(e,"td",(function(){return Xe.a})),n.d(e,"ud",(function(){return Ye.a})),n.d(e,"mb",(function(){return Je.a})),n.d(e,"xb",(function(){return Ze.a})),n.d(e,"Bb",(function(){return tn.a})),n.d(e,"ad",(function(){return en.a})),n.d(e,"xd",(function(){return nn.a})),n.d(e,"yd",(function(){return rn.a})),n.d(e,"zd",(function(){return te.a})),n.d(e,"Ad",(function(){return sn.a})),n.d(e,"Cd",(function(){return an.a})),n.d(e,"Dd",(function(){return on.a})),n.d(e,"Ed",(function(){return un.a})),n.d(e,"Fd",(function(){return cn.a})),n.d(e,"Gd",(function(){return ee.a})),n.d(e,"Id",(function(){return ln.a})),n.d(e,"Jd",(function(){return hn.a})),n.d(e,"Kd",(function(){return C.a})),n.d(e,"Ld",(function(){return dn.a})),n.d(e,"Md",(function(){return pn.a})),n.d(e,"Nd",(function(){return mn})),n.d(e,"Od",(function(){return gn.a})),n.d(e,"Pd",(function(){return bn})),n.d(e,"Qd",(function(){return yn})),n.d(e,"Rd",(function(){return vn})),n.d(e,"Sd",(function(){return bt.a})),n.d(e,"Td",(function(){return wn.a})),n.d(e,"Vd",(function(){return xn.a})),n.d(e,"Wd",(function(){return _n.a})),n.d(e,"Xd",(function(){return On.a})),n.d(e,"Yd",(function(){return Sn.a})),n.d(e,"Zd",(function(){return kn})),n.d(e,"ae",(function(){return Tn.a})),n.d(e,"be",(function(){return Cn.a})),n.d(e,"ce",(function(){return An.a})),n.d(e,"de",(function(){return Nn.a})),n.d(e,"y",(function(){return In})),n.d(e,"gb",(function(){return En.a})),n.d(e,"vb",(function(){return En.b})),n.d(e,"wb",(function(){return En.c})),n.d(e,"Ib",(function(){return En.d})),n.d(e,"Jb",(function(){return En.e})),n.d(e,"uc",(function(){return En.f})),n.d(e,"g",(function(){return jn.a})),n.d(e,"ab",(function(){return jn.b})),n.d(e,"dc",(function(){return jn.c})),n.d(e,"hc",(function(){return jn.d})),n.d(e,"kc",(function(){return jn.e})),n.d(e,"oc",(function(){return jn.f})),n.d(e,"Hc",(function(){return jn.g})),n.d(e,"Bd",(function(){return jn.h})),n.d(e,"Hd",(function(){return jn.i})),n.d(e,"Ud",(function(){return Mn.a})),n.d(e,"sc",(function(){return Dn.a})),n.d(e,"mc",(function(){return Pn})),n.d(e,"ed",(function(){return Fn.a})),n.d(e,"vd",(function(){return zn.a})),n.d(e,"sb",(function(){return Ln.a})),n.d(e,"cb",(function(){return Bn})),n.d(e,"eb",(function(){return qn})),n.d(e,"S",(function(){return Vn})),n.d(e,"Ab",(function(){return Un})),n.d(e,"yc",(function(){return S.b})),n.d(e,"a",(function(){return S.a})),n.d(e,"zb",(function(){return Pr})),n.d(e,"Kb",(function(){return Fr})),n.d(e,"Wb",(function(){return zr})),n.d(e,"wd",(function(){return Dr})),n.d(e,"qb",(function(){return r})),n.d(e,"kd",(function(){return Rr}));var r={};n.r(r),n.d(r,"conv2d",(function(){return Yn})),n.d(r,"depthwiseConv2d",(function(){return tr})),n.d(r,"matMul",(function(){return er}));var i=n(41),s=n(218),a=n(219),o=n(13),u=n(220),c=n(158),l=n(159),h=n(160),d=n(161),p=n(221),f=n(222),m=n(223),g=n(162),b=n(224),y=n(124),v=n(225),w=n(1),x=n(32),_=n(29),O=n(9),S=n(4),k=n(87),T=n(28),C=n(149);const A=Object(S.b)({basicLSTMCell_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,r,i,s){const a=Object(w.a)(t,"forgetBias","basicLSTMCell"),u=Object(w.a)(e,"lstmKernel","basicLSTMCell"),c=Object(w.a)(n,"lstmBias","basicLSTMCell"),l=Object(w.a)(r,"data","basicLSTMCell"),h=Object(w.a)(i,"c","basicLSTMCell"),d=Object(w.a)(s,"h","basicLSTMCell"),p=Object(x.a)([l,d],1),f=Object(_.a)(p,u),m=Object(o.a)(f,c),g=m.shape[0],b=m.shape[1]/4,y=[g,b],v=Object(T.a)(m,[0,0],y),S=Object(T.a)(m,[0,b],y),A=Object(T.a)(m,[0,2*b],y),N=Object(T.a)(m,[0,3*b],y),I=Object(o.a)(Object(O.a)(Object(k.a)(v),Object(C.a)(S)),Object(O.a)(h,Object(k.a)(Object(o.a)(a,A))));return[I,Object(O.a)(Object(C.a)(I),Object(k.a)(N))]}});var N=n(98),I=n(86),E=n(7);const j=Object(S.b)({batchNorm2d_:function(t,e,n,r,i,s){const a=Object(w.a)(t,"x","batchNorm"),o=Object(w.a)(e,"mean","batchNorm"),u=Object(w.a)(n,"variance","batchNorm");let c,l;return null!=i&&(c=Object(w.a)(i,"scale","batchNorm")),null!=r&&(l=Object(w.a)(r,"offset","batchNorm")),E.b(2===a.rank,()=>"Error in batchNorm2D: x must be rank 2 but got rank "+a.rank+"."),E.b(2===o.rank||1===o.rank,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${o.rank}.`),E.b(2===u.rank||1===u.rank,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${u.rank}.`),null!=c&&E.b(2===c.rank||1===c.rank,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${c.rank}.`),null!=l&&E.b(2===l.rank||1===l.rank,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${l.rank}.`),Object(I.a)(a,o,u,l,c,s)}});const M=Object(S.b)({batchNorm3d_:function(t,e,n,r,i,s){const a=Object(w.a)(t,"x","batchNorm"),o=Object(w.a)(e,"mean","batchNorm"),u=Object(w.a)(n,"variance","batchNorm");let c,l;return null!=i&&(c=Object(w.a)(i,"scale","batchNorm")),null!=r&&(l=Object(w.a)(r,"offset","batchNorm")),E.b(3===a.rank,()=>"Error in batchNorm3D: x must be rank 3 but got rank "+a.rank+"."),E.b(3===o.rank||1===o.rank,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${o.rank}.`),E.b(3===u.rank||1===u.rank,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${u.rank}.`),null!=c&&E.b(3===c.rank||1===c.rank,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${c.rank}.`),null!=l&&E.b(3===l.rank||1===l.rank,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${l.rank}.`),Object(I.a)(a,o,u,l,c,s)}});const D=Object(S.b)({batchNorm4d_:function(t,e,n,r,i,s){const a=Object(w.a)(t,"x","batchNorm"),o=Object(w.a)(e,"mean","batchNorm"),u=Object(w.a)(n,"variance","batchNorm");let c,l;return null!=i&&(c=Object(w.a)(i,"scale","batchNorm")),null!=r&&(l=Object(w.a)(r,"offset","batchNorm")),E.b(4===a.rank,()=>"Error in batchNorm4D: x must be rank 4 but got rank "+a.rank+"."),E.b(4===o.rank||1===o.rank,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${o.rank}.`),E.b(4===u.rank||1===u.rank,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${u.rank}.`),null!=c&&E.b(4===c.rank||1===c.rank,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${c.rank}.`),null!=l&&E.b(4===l.rank||1===l.rank,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${l.rank}.`),Object(I.a)(a,o,u,l,c,s)}});var R=n(113),P=n(39),F=n(12),z=n(226),L=n(227),$=n(71),B=n(51);const q=Object(S.b)({concat1d_:function(t){return Object(x.a)(t,0)}});const V=Object(S.b)({concat2d_:function(t,e){return Object(x.a)(t,e)}});const U=Object(S.b)({concat3d_:function(t,e){return Object(x.a)(t,e)}});const W=Object(S.b)({concat4d_:function(t,e){return Object(x.a)(t,e)}});var G=n(163),H=n(69),K=n(164),Q=n(228),X=n(206);const Y=Object(S.b)({conv3dTranspose_:function(t,e,n,r,i){const s=Object(w.a)(t,"x","conv3dTranspose"),a=Object(w.a)(e,"filter","conv3dTranspose");return Object(X.a)(n,s,a,r,i)}});var J=n(125),Z=n(165),tt=n(126),et=n(166),nt=n(81),rt=n(5),it=n(3),st=n(8);const at=Object(S.b)({diag_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(w.a)(t,"x","diag"),n={x:e};return rt.a.runKernelFunc(n=>{const r=Object(st.a)(e,[e.size]),i=n.diag(r),s=[...t.shape,...t.shape];return Object(st.a)(i,s)},n,null,it.O)}});var ot=n(167),ut=n(16),ct=n(168),lt=n(169),ht=n(127),dt=n(82),pt=n(229),ft=n(40),mt=n(49),gt=n(230),bt=n(88);const yt=Object(S.b)({eye_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,r="float32"){null==e&&(e=t);const i=Object(P.a)([t,e],r),s=t<=e?t:e;for(let t=0;t<s;++t)i.set(1,t,t);const a=Object(st.a)(i.toTensor(),[t,e]);if(null==n)return a;if(1===n.length)return Object(bt.a)(Object(mt.a)(a,0),[n[0],1,1]);if(2===n.length)return Object(bt.a)(Object(mt.a)(Object(mt.a)(a,0),0),[n[0],n[1],1,1]);if(3===n.length)return Object(bt.a)(Object(mt.a)(Object(mt.a)(Object(mt.a)(a,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.`)}});var vt=n(123),wt=n(128),xt=n(122),_t=n(99),Ot=n(46),St=n(56),kt=n(100),Tt=n(231),Ct=n(232),At=n(233),Nt=n(172),It=n(101),Et=n(57),jt=n(234),Mt=n(173),Dt=n(76),Rt=n(174),Pt=n(235),Ft=n(236),zt=n(129),Lt=n(62),$t=n(102),Bt=n(130),qt=n(176),Vt=n(72),Ut=n(131),Wt=n(237),Gt=n(238),Ht=n(68),Kt=n(93),Qt=n(114),Xt=n(103),Yt=n(177),Jt=n(132),Zt=n(24),te=n(27),ee=n(14);const ne=Object(S.b)({moments_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=null,n=!1){t=Object(w.a)(t,"x","moments");const r=Object(E.I)(e,t.shape),i=Object(Kt.a)(t,r,n);let s=i.shape;n||(s=Object(Zt.e)(i.shape,r));const a=Object(te.a)(Object(ee.a)(Object(F.a)(t,"float32"),Object(st.a)(i,s)));return{mean:i,variance:Object(Kt.a)(a,r,n)}}});const re=Object(S.b)({multiRNNCell_:function(t,e,n,r){const i=Object(w.a)(e,"data","multiRNNCell"),s=Object(w.b)(n,"c","multiRNNCell"),a=Object(w.b)(r,"h","multiRNNCell");let o=i;const u=[];for(let e=0;e<t.length;e++){const n=t[e](o,s[e],a[e]);u.push(n[0]),u.push(n[1]),o=n[1]}const c=[],l=[];for(let t=0;t<u.length;t+=2)c.push(u[t]),l.push(u[t+1]);return[c,l]}});var ie=n(239),se=n(30),ae=n(104),oe=n(115),ue=n(83),ce=n(240);const le=Object(S.b)({outerProduct_:function(t,e){const n=Object(w.a)(t,"v1","outerProduct"),r=Object(w.a)(e,"v2","outerProduct");E.b(1===n.rank&&1===r.rank,()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${r.rank}.`);const i=Object(st.a)(n,[-1,1]),s=Object(st.a)(r,[1,-1]);return Object(_.a)(i,s)}});var he=n(59);const de=Object(S.b)({pad1d_:function(t,e,n=0){return Object(E.b)(2===e.length,()=>"Invalid number of paddings. Must be length of 2."),Object(he.a)(t,[e],n)}});const pe=Object(S.b)({pad2d_:function(t,e,n=0){return Object(E.b)(2===e.length&&2===e[0].length&&2===e[1].length,()=>"Invalid number of paddings. Must be length of 2 each."),Object(he.a)(t,e,n)}});const fe=Object(S.b)({pad3d_:function(t,e,n=0){return Object(E.b)(3===e.length&&2===e[0].length&&2===e[1].length&&2===e[2].length,()=>"Invalid number of paddings. Must be length of 2 each."),Object(he.a)(t,e,n)}});const me=Object(S.b)({pad4d_:function(t,e,n=0){return Object(E.b)(4===e.length&&2===e[0].length&&2===e[1].length&&2===e[2].length&&2===e[3].length,()=>"Invalid number of paddings. Must be length of 2 each."),Object(he.a)(t,e,n)}});var ge=n(178),be=n(44),ye=n(133),ve=n(157),we=n(179);const xe=Object(S.b)({rand_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n){const r=Object(E.N)(t);let i=null;if(null==n||"float32"===n)i=new Float32Array(r);else if("int32"===n)i=new Int32Array(r);else{if("bool"!==n)throw new Error("Unknown data type "+n);i=new Uint8Array(r)}for(let t=0;t<r;t++)i[t]=e();return rt.a.makeTensor(i,t,n)}});var _e=n(109);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Oe=Object(S.b)({randomGamma_:function(t,e,n=1,r="float32",i){if(null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error("Unsupported data type "+r);const s=new _e.b(e,n,r,i),a=Object(P.a)(t,r);for(let t=0;t<a.values.length;t++)a.values[t]=s.nextValue();return a.toTensor()}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Se=Object(S.b)({randomNormal_:function(t,e=0,n=1,r,i){if(null!=r&&"bool"===r)throw new Error("Unsupported data type "+r);const s=new _e.a(e,n,r,!1,i),a=Object(P.a)(t,r);for(let t=0;t<a.values.length;t++)a.values[t]=s.nextValue();return a.toTensor()}});var ke=n(180),Te=n(150),Ce=n(94),Ae=n(241),Ne=n(84),Ie=n(134),Ee=n(45);const je=Object(S.b)({reverse1d_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(w.a)(t,"x","reverse");return E.b(1===e.rank,()=>`Error in reverse1D: x must be rank 1 but got rank ${e.rank}.`),Object(Ee.a)(e,0)}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Me=Object(S.b)({reverse2d_:function(t,e){const n=Object(w.a)(t,"x","reverse");return E.b(2===n.rank,()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`),Object(Ee.a)(n,e)}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const De=Object(S.b)({reverse3d_:function(t,e){const n=Object(w.a)(t,"x","reverse");return E.b(3===n.rank,()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`),Object(Ee.a)(n,e)}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Re=Object(S.b)({reverse4d_:function(t,e){const n=Object(w.a)(t,"x","reverse");return E.b(4===n.rank,()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`),Object(Ee.a)(n,e)}});var Pe=n(242),Fe=n(181),ze=n(15),Le=n(182),$e=n(183),Be=n(243),qe=n(244),Ve=n(184),Ue=n(185);const We=Object(S.b)({slice1d_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n){const r=Object(w.a)(t,"x","slice1d");return E.b(1===r.rank,()=>`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`),Object(T.a)(r,[e],[n])}});
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Ge=Object(S.b)({slice2d_:function(t,e,n){const r=Object(w.a)(t,"x","slice2d");return E.b(2===r.rank,()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`),Object(T.a)(r,e,n)}});
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const He=Object(S.b)({slice3d_:function(t,e,n){const r=Object(w.a)(t,"x","slice3d");return E.b(3===r.rank,()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`),Object(T.a)(r,e,n)}});
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Ke=Object(S.b)({slice4d_:function(t,e,n){const r=Object(w.a)(t,"x","slice4d");return E.b(4===r.rank,()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`),Object(T.a)(r,e,n)}});var Qe=n(245),Xe=n(175),Ye=n(105),Je=n(135),Ze=n(116),tn=n(186),en=n(136),nn=n(78),rn=n(35),sn=n(106),an=n(107),on=n(63),un=n(85),cn=n(246),ln=n(21),hn=n(247),dn=n(64),pn=n(77),fn=n(47);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function mn(t,e,n){if(Object(E.d)(t),null!=e&&2!==e.length)throw new Error("tensor2d() requires shape to have two numbers");const r=Object(w.c)(t,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==e)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return Object(fn.a)(t,e,r,n)}var gn=n(188);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function bn(t,e,n){if(Object(E.d)(t),null!=e&&4!==e.length)throw new Error("tensor4d() requires shape to have four numbers");const r=Object(w.c)(t,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==e)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return Object(fn.a)(t,e,r,n)}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function yn(t,e,n){if(Object(E.d)(t),null!=e&&5!==e.length)throw new Error("tensor5d() requires shape to have five numbers");const r=Object(w.c)(t,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==e)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return Object(fn.a)(t,e,r,n)}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function vn(t,e,n){if(Object(E.d)(t),null!=e&&6!==e.length)throw new Error("tensor6d() requires shape to have six numbers");const r=Object(w.c)(t,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==e)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return e=e||r,Object(fn.a)(t,e,r,n)}var wn=n(189),xn=n(248),_n=n(190),On=n(137),Sn=n(108);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function kn(t,e=!0,n,r){return rt.a.makeVariable(t,e,n,r)}var Tn=n(37),Cn=n(191),An=n(58),Nn=n(23);const In=
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
async function(t,e,n){const r=Object(w.a)(t,"tensor","boolMask"),i=Object(w.a)(e,"mask","boolMask","bool"),s=null==n?0:n,a=i.rank,o=r.shape;E.b(a>0,()=>"mask cannot be scalar"),E.e(o.slice(s,s+a),i.shape,"mask's shape must match the first K dimensions of tensor's shape,");let u=1;for(let t=s;t<s+a;t++)u*=o[t];const c=o.slice(0,s).concat([u],o.slice(s+a)),l=Object(st.a)(r,c),h=Object(st.a)(i,[-1]),d=await Object(Cn.a)(h),p=Object(an.a)(d,[1]),f=Object(_t.a)(l,p,s);return t!==r&&r.dispose(),e!==i&&i.dispose(),p.dispose(),l.dispose(),h.dispose(),d.dispose(),f};var En=n(249),jn=n(250),Mn=n(31),Dn=n(138),Rn=n(25);const Pn=Object(S.b)({movingAverage_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,r,i=!0){const s=Object(w.a)(t,"v","movingAverage"),a=Object(w.a)(e,"x","movingAverage"),u=Object(w.a)(n,"decay","movingAverage");Object(Rn.assertTypesMatch)(s,a),E.b(E.a(s.shape,a.shape),()=>"Shape mismatch in v and x");const c=Object(ze.a)(1),l=Object(ee.a)(c,u);let h=Object(O.a)(Object(ee.a)(a,s),l);if(i){E.b(null!=r,()=>"When using zeroDebias: true, step is required.");const t=Object(w.a)(r,"step","movingAverage");h=Object(ut.a)(h,Object(ee.a)(c,Object(be.a)(u,t)))}return Object(o.a)(s,h)}});var Fn=n(251),zn=n(271),Ln=n(252),$n=n(6);const Bn=Object(S.b)({dropout_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,r){const i=Object(w.a)(t,"x","dropout");if(E.b("float32"===i.dtype,()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${i.dtype} tensor instead.`),E.b(e>=0&&e<1,()=>`rate must be a float in the range [0, 1), but got ${e}.`),0===e)return t instanceof $n.a?i.clone():i;const s=
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){if(null==e)return t.shape.slice();if(E.a(t.shape,e))return e;if(t.shape.length===e.length){const n=[];for(let r=0;r<t.shape.length;r++)null==e[r]&&null!=t.shape[r]?n.push(t.shape[r]):n.push(e[r]);return n}return e}(i,n),a=1-e,u=Object(ut.a)(Object(wt.a)(Object(o.a)(Object(ke.a)(s,0,1,"float32",r),a)),a);return Object(O.a)(i,u)}});
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function qn(t){return Math.floor(Math.pow(2,Math.ceil(Math.log(t)/Math.log(2))))}function Vn(t,e,n){const r=1-t%2,i=new Float32Array(t);for(let s=0;s<t;++s){const a=2*Math.PI*s/(t+r-1);i[s]=e-n*Math.cos(a)}return Object(pn.a)(i,"float32")}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Un=async function(t,e,n=1){const r=Object(w.a)(t,"predictions","inTopK"),i=Object(w.a)(e,"targets","inTopK");Object(E.b)(r.rank>1,()=>"inTopK() expects the predictions to be of rank 2 or higher, but got "+r.rank),Object(E.b)(r.rank-1===i.rank,()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${r.rank} and targets rank ${i.rank}`),Object(E.e)(r.shape.slice(0,r.shape.length-1),i.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");const s=r.shape[r.shape.length-1];Object(E.b)(n>0&&n<=s,()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${s}), but got ${n}`);const a=await r.data(),o=await i.data(),[u,c]=[a.length/s,s],l=Object(E.o)("bool",u);for(let t=0;t<u;t++){const e=t*c,r=a.subarray(e,e+c),i=[];for(let t=0;t<r.length;t++)i.push({value:r[t],index:t});i.sort((t,e)=>e.value-t.value),l[t]=0;for(let e=0;e<n;e++)if(i[e].index===o[t]){l[t]=1;break}}return t!==r&&r.dispose(),e!==i&&i.dispose(),Object(dn.a)(l,i.shape,"bool")};var Wn=n(33),Gn=n(18),Hn=n(144),Kn=n(142),Qn=n(20),Xn=n(42);const Yn=Object(S.b)({fusedConv2d_:
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function({x:t,filter:e,strides:n,pad:r,dataFormat:i="NHWC",dilations:s=[1,1],dimRoundingMode:a,bias:u,activation:c="linear",preluActivationWeights:l}){if(c=c||"linear",!1===Object(Xn.d)(rt.a.state.gradientDepth,c)){let h=Object(H.a)(t,e,n,r,i,s,a);return null!=u&&(h=Object(o.a)(h,u)),Object(Xn.a)(h,c,l)}const h=Object(w.a)(t,"x","conv2d"),d=Object(w.a)(e,"filter","conv2d");let p=h,f=!1;3===h.rank&&(f=!0,p=Object(st.a)(h,[1,h.shape[0],h.shape[1],h.shape[2]])),E.b(4===p.rank,()=>"Error in fused conv2d: input must be rank 4, but got rank "+p.rank+"."),E.b(4===d.rank,()=>"Error in fused conv2d: filter must be rank 4, but got rank "+d.rank+"."),null!=a&&E.b(E.v(r),()=>`Error in fused conv2d: pad must be an integer when using, dimRoundingMode ${a} but got pad ${r}.`),E.b(p.shape[3]===d.shape[2],()=>`Error in conv2d: depth of input (${p.shape[3]}) must match input depth for filter ${d.shape[2]}.`),E.b(Qn.h(n,s),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${s}'`),E.b("NHWC"===i,()=>`Error in conv2d: got dataFormat of ${i} but only NHWC is currently supported.`);const m=Qn.a(p.shape,d.shape,n,s,r,a);let g,b;null!=u&&(g=Object(w.a)(u,"bias","fused conv2d"),[g]=Object(Rn.makeTypesMatch)(g,h),Gn.a(m.outShape,g.shape)),null!=l&&(b=Object(w.a)(l,"prelu weights","fused conv2d"));const y=(t,e)=>{const[i,a,o,u]=e,l=Object(Xn.c)(t,o,c);E.b(Qn.i(s),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`);const h=[Object(Kn.a)(a.shape,l,i,n,r),Object(Hn.a)(a,l,i.shape,n,r)];if(null!=u){const t=Object(Xn.b)(u,l);h.push(t)}return h},v=t=>t.fusedConv2d({input:p,filter:d,convInfo:m,bias:g,activation:c,preluActivationWeights:b}),x={x:p,filter:d,bias:g,preluActivationWeights:b},_={strides:n,pad:r,dataFormat:i,dilations:s,dimRoundingMode:a,activation:c};if(null==u){return Object(Wn.a)((t,e,n)=>{let r=rt.a.runKernelFunc(v,x,null,it.gb,_);return n([e,t,r]),f&&(r=Object(st.a)(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:y}})(p,d)}return Object(Wn.a)((t,e,n,r)=>{let i=rt.a.runKernelFunc(v,x,null,it.gb,_);return r([e,t,i,n]),f&&(i=Object(st.a)(i,[i.shape[1],i.shape[2],i.shape[3]])),{value:i,gradFunc:y}})(p,d,g)}});var Jn=n(210),Zn=n(209);const tr=Object(S.b)({fusedDepthwiseConv2d_:
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function({x:t,filter:e,strides:n,pad:r,dataFormat:i="NHWC",dilations:s=[1,1],dimRoundingMode:a,bias:u,activation:c="linear",preluActivationWeights:l}){if(!1===Object(Xn.d)(rt.a.state.gradientDepth,c)){let h=Object(nt.a)(t,e,n,r,i,s,a);return null!=u&&(h=Object(o.a)(h,u)),Object(Xn.a)(h,c,l)}const h=Object(w.a)(t,"x","depthwiseConv2d"),d=Object(w.a)(e,"filter","depthwiseConv2d");let p=h,f=!1;3===h.rank&&(f=!0,p=Object(st.a)(h,[1,h.shape[0],h.shape[1],h.shape[2]])),E.b(4===p.rank,()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${p.rank}.`),E.b(4===d.rank,()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${d.rank}.`),E.b(p.shape[3]===d.shape[2],()=>`Error in fused depthwiseConv2d: number of input channels (${p.shape[3]}) must match the inChannels dimension in filter ${d.shape[2]}.`),null==s&&(s=[1,1]),E.b(Qn.h(n,s),()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${s}'`),null!=a&&E.b(E.v(r),()=>`Error in fused depthwiseConv2d: pad must be an integer when using dimRoundingMode ${a} but got pad ${r}.`);const m=Qn.a(p.shape,d.shape,n,s,r,a,!0);let g,b;null!=u&&(g=Object(w.a)(u,"bias","fused conv2d"),[g]=Object(Rn.makeTypesMatch)(g,h),Gn.a(m.outShape,g.shape)),null!=l&&(b=Object(w.a)(l,"prelu weights","fused depthwiseConv2d"));const y=(t,e)=>{E.b(Qn.i(s),()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${s}'`);const[i,o,u,l]=e,h=Object(Xn.c)(t,u,c),d=Object(Zn.a)(o.shape,h,i,n,r,s,a),p=Object(Jn.a)(o,h,i.shape,n,r,s,a);if(null!=l){return[d,p,Object(Xn.b)(g,h)]}return[d,p]},v=t=>t.fusedDepthwiseConv2D({input:p,filter:d,convInfo:m,bias:g,activation:c,preluActivationWeights:b}),x={x:p,filter:d,bias:g,preluActivationWeights:b},_={strides:n,pad:r,dataFormat:i,dilations:s,dimRoundingMode:a,activation:c};if(null==u){return Object(Wn.a)((t,e,n)=>{let r=rt.a.runKernelFunc(v,x,null,it.hb,_);return n([e,t,r]),f&&(r=Object(st.a)(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:y}})(p,d)}return Object(Wn.a)((t,e,n,r)=>{let i=rt.a.runKernelFunc(v,x,null,it.hb,_);return r([e,t,i,n]),f&&(i=Object(st.a)(i,[i.shape[1],i.shape[2],i.shape[3]])),{value:i,gradFunc:y}})(p,d,g)}});
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const er=Object(S.b)({fusedMatMul_:function({a:t,b:e,transposeA:n=!1,transposeB:r=!1,bias:i,activation:s="linear",preluActivationWeights:a}){if(!1===Object(Xn.d)(rt.a.state.gradientDepth,s)){let u=Object(_.a)(t,e,n,r);return null!=i&&(u=Object(o.a)(u,i)),Object(Xn.a)(u,s,a)}let u=Object(w.a)(t,"a","fused matMul"),c=Object(w.a)(e,"b","fused matMul");[u,c]=Object(Rn.makeTypesMatch)(u,c);const l=n?u.shape[u.rank-2]:u.shape[u.rank-1],h=r?c.shape[c.rank-1]:c.shape[c.rank-2],d=n?u.shape[u.rank-1]:u.shape[u.rank-2],p=r?c.shape[c.rank-2]:c.shape[c.rank-1],f=u.shape.slice(0,-2),m=c.shape.slice(0,-2),g=E.N(f),b=E.N(m);E.b(u.rank>=2&&c.rank>=2&&u.rank===c.rank,()=>`Error in fused matMul: inputs must have the same rank of at least 2, got ranks ${u.rank} and ${c.rank}.`),E.b(E.a(f,m),()=>`Error in fused matMul: outer dimensions (${f}) and (${m}) of Tensors with shapes ${u.shape} and `+c.shape+" must match."),E.b(l===h,()=>`Error in fused matMul: inner shapes (${l}) and (${h}) of Tensors with shapes ${u.shape} and ${c.shape} and transposeA=${n} and transposeB=${r} must match.`);const y=u.shape.slice(0,-2).concat([d,p]),v=n?Object(st.a)(u,[g,l,d]):Object(st.a)(u,[g,d,l]),x=r?Object(st.a)(c,[b,p,h]):Object(st.a)(c,[b,h,p]);let O,S;null!=i&&(O=Object(w.a)(i,"bias","fused matMul"),[O]=Object(Rn.makeTypesMatch)(O,u),Gn.a(y,O.shape)),null!=a&&(S=Object(w.a)(a,"prelu weights","fused matMul"));const k=(t,e)=>{const[a,o,u,c]=e,l=Object(Xn.c)(Object(st.a)(t,u.shape),u,s);let h,d;if(n||r?!n&&r?(h=Object(_.a)(l,o,!1,!1),d=Object(_.a)(l,a,!0,!1)):n&&!r?(h=Object(_.a)(o,l,!1,!0),d=Object(_.a)(a,l,!1,!1)):(h=Object(_.a)(o,l,!0,!0),d=Object(_.a)(l,a,!0,!0)):(h=Object(_.a)(l,o,!1,!0),d=Object(_.a)(a,l,!0,!1)),null!=i){return[h,d,Object(Xn.b)(c,l)]}return[h,d]},T=t=>t.fusedBatchMatMul({a:v,b:x,transposeA:n,transposeB:r,bias:O,activation:s,preluActivationWeights:S}),C={a:v,b:x,bias:O,preluActivationWeights:S},A={transposeA:n,transposeB:r,activation:s};if(null==i){return Object(Wn.a)((t,e,n)=>{const r=rt.a.runKernelFunc(T,C,null,it.Tc,A);return n([t,e,r]),{value:Object(st.a)(r,y),gradFunc:k}})(v,x)}return Object(Wn.a)((t,e,n,r)=>{const i=rt.a.runKernelFunc(T,C,null,it.Tc,A);return r([t,e,i,n]),{value:Object(st.a)(i,y),gradFunc:k}})(v,x,O)}});
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const nr=Object(S.b)({hammingWindow_:function(t){return Vn(t,.54,.46)}});
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const rr=Object(S.b)({hannWindow_:function(t){return Vn(t,.5,.5)}});
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const ir=Object(S.b)({frame_:function(t,e,n,r=!1,i=0){let s=0;const a=[];for(;s+e<=t.size;)a.push(Object(T.a)(t,s,e)),s+=n;if(r)for(;s<t.size;){const r=s+e-t.size,o=Object(x.a)([Object(T.a)(t,s,e-r),Object(vt.a)([r],i)]);a.push(o),s+=n}return 0===a.length?mn([],[0,e]):Object(st.a)(Object(x.a)(a),[a.length,e])}});
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const sr=Object(S.b)({stft_:function(t,e,n,r,i=rr){null==r&&(r=qn(e));const s=ir(t,e,n),a=Object(O.a)(s,i(e)),o=[];for(let t=0;t<s.shape[0];t++)o.push(Object(en.a)(Object(T.a)(a,[t,0],[1,e]),r));return Object(x.a)(o)}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const ar=Object(S.b)({cropAndResize_:function(t,e,n,r,i,s){const a=Object(w.a)(t,"image","cropAndResize"),o=Object(w.a)(e,"boxes","cropAndResize","float32"),u=Object(w.a)(n,"boxInd","cropAndResize","int32");i=i||"bilinear",s=s||0;const c=o.shape[0];E.b(4===a.rank,()=>`Error in cropAndResize: image must be rank 4,but got rank ${a.rank}.`),E.b(2===o.rank&&4===o.shape[1],()=>`Error in cropAndResize: boxes must be have size [${c},4] but had shape ${o.shape}.`),E.b(1===u.rank&&u.shape[0]===c,()=>`Error in cropAndResize: boxInd must be have size [${c}] but had shape ${o.shape}.`),E.b(2===r.length,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`),E.b(r[0]>=1&&r[1]>=1,()=>"cropSize must be atleast [1,1], but was "+r),E.b("bilinear"===i||"nearest"===i,()=>"method must be bilinear or nearest, but was "+i);const l={image:a,boxes:o,boxInd:u},h={method:i,extrapolationValue:s,cropSize:r};return rt.a.runKernelFunc(t=>t.cropAndResize(a,o,u,r,i,s),l,null,it.I,h)}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const or=Object(S.b)({flipLeftRight_:function(t){const e=Object(w.a)(t,"image","flipLeftRight","float32");E.b(4===e.rank,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`);const n={image:e};return rt.a.runKernel(it.bb,n,{})}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const ur=Object(S.b)({rotateWithOffset_:function(t,e,n=0,r=.5){const i=Object(w.a)(t,"image","rotateWithOffset","float32");E.b(4===i.rank,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${i.rank}.`);const s={image:i},a={radians:e,fillValue:n,center:r};return rt.a.runKernel(it.nc,s,a)}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function cr(t,e,n,r,i,s){null==r&&(r=.5),null==i&&(i=Number.NEGATIVE_INFINITY),null==s&&(s=0);const a=t.shape[0];return n=Math.min(n,a),E.b(0<=r&&r<=1,()=>`iouThreshold must be in [0, 1], but was '${r}'`),E.b(2===t.rank,()=>`boxes must be a 2D tensor, but was of rank '${t.rank}'`),E.b(4===t.shape[1],()=>"boxes must have 4 columns, but 2nd dimension was "+t.shape[1]),E.b(1===e.rank,()=>"scores must be a 1D tensor"),E.b(e.shape[0]===a,()=>`scores has incompatible shape with boxes. Expected ${a}, but was `+e.shape[0]),E.b(0<=s&&s<=1,()=>`softNmsSigma must be in [0, 1], but was '${s}'`),{maxOutputSize:n,iouThreshold:r,scoreThreshold:i,softNmsSigma:s}}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const lr=Object(S.b)({nonMaxSuppression_:function(t,e,n,r=.5,i=Number.NEGATIVE_INFINITY){const s=Object(w.a)(t,"boxes","nonMaxSuppression"),a=Object(w.a)(e,"scores","nonMaxSuppression"),o=cr(s,a,n,r,i);n=o.maxOutputSize,r=o.iouThreshold,i=o.scoreThreshold;const u={maxOutputSize:n,iouThreshold:r,scoreThreshold:i};return rt.a.runKernelFunc(t=>t.nonMaxSuppression(s,a,n,r,i),{boxes:s,scores:a},null,it.Rb,u)}});var hr=n(80);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const dr=async function(t,e,n,r=.5,i=Number.NEGATIVE_INFINITY){const s=Object(w.a)(t,"boxes","nonMaxSuppressionAsync"),a=Object(w.a)(e,"scores","nonMaxSuppressionAsync"),o=cr(s,a,n,r,i);n=o.maxOutputSize,r=o.iouThreshold,i=o.scoreThreshold;const u=await Promise.all([s.data(),a.data()]),c=u[0],l=u[1],h=Object(hr.a)(c,l,n,r,i);return s!==t&&s.dispose(),a!==e&&a.dispose(),h};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const pr=Object(S.b)({nonMaxSuppressionWithScore_:function(t,e,n,r=.5,i=Number.NEGATIVE_INFINITY,s=0){const a=Object(w.a)(t,"boxes","nonMaxSuppression"),o=Object(w.a)(e,"scores","nonMaxSuppression"),u=cr(a,o,n,r,i,s),c={boxes:a,scores:o},l={maxOutputSize:n=u.maxOutputSize,iouThreshold:r=u.iouThreshold,scoreThreshold:i=u.scoreThreshold,softNmsSigma:s=u.softNmsSigma},h=rt.a.runKernel(it.Tb,c,l);return{selectedIndices:h[0],selectedScores:h[1]}}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const fr=async function(t,e,n,r=.5,i=Number.NEGATIVE_INFINITY,s=0){const a=Object(w.a)(t,"boxes","nonMaxSuppressionAsync"),o=Object(w.a)(e,"scores","nonMaxSuppressionAsync"),u=cr(a,o,n,r,i,s);n=u.maxOutputSize,r=u.iouThreshold,i=u.scoreThreshold,s=u.softNmsSigma;const c=await Promise.all([a.data(),o.data()]),l=c[0],h=c[1],d=Object(hr.c)(l,h,n,r,i,s);return a!==t&&a.dispose(),o!==e&&o.dispose(),d};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const mr=Object(S.b)({nonMaxSuppressionPadded_:function(t,e,n,r=.5,i=Number.NEGATIVE_INFINITY,s=!1){const a=Object(w.a)(t,"boxes","nonMaxSuppression"),o=Object(w.a)(e,"scores","nonMaxSuppression"),u=cr(a,o,n,r,i,null),c={boxes:a,scores:o},l={maxOutputSize:u.maxOutputSize,iouThreshold:u.iouThreshold,scoreThreshold:u.scoreThreshold,padToMaxOutputSize:s},h=rt.a.runKernel(it.Sb,c,l);return{selectedIndices:h[0],validOutputs:h[1]}}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const gr=async function(t,e,n,r=.5,i=Number.NEGATIVE_INFINITY,s=!1){const a=Object(w.a)(t,"boxes","nonMaxSuppressionAsync"),o=Object(w.a)(e,"scores","nonMaxSuppressionAsync"),u=cr(a,o,n,r,i,null),c=u.maxOutputSize,l=u.iouThreshold,h=u.scoreThreshold,[d,p]=await Promise.all([a.data(),o.data()]),f=Object(hr.b)(d,p,c,l,h,s);return a!==t&&a.dispose(),o!==e&&o.dispose(),f};var br=n(208),yr=n(207);const vr=Object(S.b)({bandPart_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n){Object(E.b)(e%1==0,()=>`bandPart(): numLower must be an integer, got ${e}.`),Object(E.b)(n%1==0,()=>`bandPart(): numUpper must be an integer, got ${n}.`);const r=Object(w.a)(t,"a","bandPart");Object(E.b)(r.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`);const i=r.shape,[s,a]=r.shape.slice(-2);if(!(e<=s))throw new Error(`bandPart(): numLower (${e}) must not be greater than the number of rows (${s}).`);if(!(n<=a))throw new Error(`bandPart(): numUpper (${n}) must not be greater than the number of columns (${a}).`);e<0&&(e=s),n<0&&(n=a);const o=Object(st.a)(Object(Te.a)(0,s,1,"int32"),[-1,1]),u=Object(Te.a)(0,a,1,"int32"),c=Object(ee.a)(o,u),l=Object(Lt.a)(Object(Et.a)(c,Object(ze.a)(+e,"int32")),Object(St.a)(c,Object(ze.a)(-n,"int32"))),h=Object(An.a)([s,a],r.dtype);return Object(st.a)(Object(on.a)(Object(Sn.a)(Object(st.a)(r,[-1,s,a])).map(t=>Object(Tn.a)(l,t,h))),i)}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const wr=Object(S.b)({gramSchmidt_:function(t){let e;if(Array.isArray(t)){e=!1,Object(E.b)(null!=t&&t.length>0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");const n=t[0].shape[0];for(let e=1;e<t.length;++e)Object(E.b)(t[e].shape[0]===n,()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${t[e].shape[0]} vs. ${n})`)}else e=!0,t=Object(nn.a)(t,t.shape[0],0).map(t=>Object(an.a)(t,[0]));Object(E.b)(t.length<=t[0].shape[0],()=>`Gram-Schmidt: Number of vectors (${t.length}) exceeds number of dimensions (${t[0].shape[0]}).`);const n=[],r=t;for(let e=0;e<t.length;++e)n.push(rt.a.tidy(()=>{let t=r[e];if(e>0)for(let r=0;r<e;++r){const e=Object(O.a)(Object(ln.a)(Object(O.a)(n[r],t)),n[r]);t=Object(ee.a)(t,e)}return Object(ut.a)(t,Object(Dn.a)(t,"euclidean"))}));return e?Object(on.a)(n,0):n}});var xr=n(22);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function _r(t,e=!1){return rt.a.tidy(()=>{Object(E.b)(2===t.shape.length,()=>`qr2d() requires a 2D Tensor, but got a ${t.shape.length}D Tensor.`);const n=t.shape[0],r=t.shape[1];let i=yt(n),s=Object($.a)(t);const a=mn([[1]],[1,1]);let o=Object($.a)(a);const u=n>=r?r:n;for(let t=0;t<u;++t){const e=s,u=o,c=i;[o,s,i]=rt.a.tidy(()=>{const e=Object(T.a)(s,[t,t],[n-t,1]),u=Object(Dn.a)(e),c=Object(T.a)(s,[t,t],[1,1]),l=Object(Tn.a)(Object(Ot.a)(c,0),mn([[-1]]),mn([[1]])),h=Object(ee.a)(c,Object(O.a)(l,u)),d=Object(ut.a)(e,h);o=1===d.shape[0]?Object($.a)(a):Object(x.a)([a,Object(T.a)(d,[1,0],[d.shape[0]-1,d.shape[1]])],0);const p=Object(se.a)(Object(ut.a)(Object(_.a)(l,h),u)),f=Object(T.a)(s,[t,0],[n-t,r]),m=Object(O.a)(p,o),g=Object(Mn.a)(o);if(0===t)s=Object(ee.a)(f,Object(_.a)(m,Object(_.a)(g,f)));else{const e=Object(ee.a)(f,Object(_.a)(m,Object(_.a)(g,f)));s=Object(x.a)([Object(T.a)(s,[0,0],[t,r]),e],0)}const b=Object(Mn.a)(m),y=Object(T.a)(i,[0,t],[n,i.shape[1]-t]);if(0===t)i=Object(ee.a)(y,Object(_.a)(Object(_.a)(y,o),b));else{const e=Object(ee.a)(y,Object(_.a)(Object(_.a)(y,o),b));i=Object(x.a)([Object(T.a)(i,[0,0],[n,t]),e],1)}return[o,s,i]}),Object(xr.d)([e,u,c])}return!e&&n>r&&(i=Object(T.a)(i,[0,0],[n,r]),s=Object(T.a)(s,[0,0],[r,r])),[i,s]})}const Or=Object(S.b)({qr_:function(t,e=!1){if(Object(E.b)(t.rank>=2,()=>"qr() requires input tensor to have a rank >= 2, but got rank "+t.rank),2===t.rank)return _r(t,e);{const n=t.shape.slice(0,t.shape.length-2).reduce((t,e)=>t*e),r=Object(Sn.a)(Object(st.a)(t,[n,t.shape[t.shape.length-2],t.shape[t.shape.length-1]]),0),i=[],s=[];r.forEach(t=>{const[n,r]=_r(t,e);i.push(n),s.push(r)});return[Object(st.a)(Object(on.a)(i,0),t.shape),Object(st.a)(Object(on.a)(s,0),t.shape)]}}});var Sr=n(34);const kr=Object(S.b)({computeWeightedLoss_:function(t,e,n=Sr.a.SUM_BY_NONZERO_WEIGHTS){const r=Object(w.a)(t,"losses","computeWeightedLoss");let i=null;null!=e&&(i=Object(w.a)(e,"weights","computeWeightedLoss"));const s=null==i?r:Object(O.a)(r,i);if(n===Sr.a.NONE)return s;if(n===Sr.a.SUM)return Object(ln.a)(s);if(n===Sr.a.MEAN){if(null==i)return Object(Kt.a)(s);{const t=r.size/i.size,e=Object(ut.a)(Object(ln.a)(s),Object(ln.a)(i));return t>1?Object(ut.a)(e,Object(ze.a)(t)):e}}if(n===Sr.a.SUM_BY_NONZERO_WEIGHTS){if(null==i)return Object(ut.a)(Object(ln.a)(s),Object(ze.a)(r.size));{const t=Object(O.a)(i,Object(ue.a)(r.shape)),e=Object(F.a)(Object(ln.a)(Object(ae.a)(t,Object(ze.a)(0))),"float32");return Object(ut.a)(Object(ln.a)(s),e)}}throw Error("Unknown reduction: "+n)}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Tr=Object(S.b)({absoluteDifference_:function(t,e,n,r=Sr.a.SUM_BY_NONZERO_WEIGHTS){const s=Object(w.a)(t,"labels","absoluteDifference"),a=Object(w.a)(e,"predictions","absoluteDifference");let o=null;null!=n&&(o=Object(w.a)(n,"weights","absoluteDifference")),Object(E.e)(s.shape,a.shape,"Error in absoluteDifference: ");const u=Object(i.a)(Object(ee.a)(s,a));return kr(u,o,r)}});const Cr=Object(S.b)({cosineDistance_:function(t,e,n,r,i=Sr.a.SUM_BY_NONZERO_WEIGHTS){const s=Object(w.a)(t,"labels","cosineDistance"),a=Object(w.a)(e,"predictions","cosineDistance");let o=null;null!=r&&(o=Object(w.a)(r,"weights","cosineDistance")),Object(E.e)(s.shape,a.shape,"Error in cosineDistance: ");const u=Object(ze.a)(1),c=Object(ee.a)(u,Object(ln.a)(Object(O.a)(s,a),n,!0));return kr(c,o,i)}});const Ar=Object(S.b)({hingeLoss_:function(t,e,n,r=Sr.a.SUM_BY_NONZERO_WEIGHTS){let i=Object(w.a)(t,"labels","hingeLoss");const s=Object(w.a)(e,"predictions","hingeLoss");let a=null;null!=n&&(a=Object(w.a)(n,"weights","hingeLoss")),Object(E.e)(i.shape,s.shape,"Error in hingeLoss: ");const o=Object(ze.a)(1);i=Object(ee.a)(Object(O.a)(Object(ze.a)(2),i),o);const u=Object(Ne.a)(Object(ee.a)(o,Object(O.a)(i,s)));return kr(u,a,r)}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Nr=Object(S.b)({huberLoss_:function(t,e,n,r=1,s=Sr.a.SUM_BY_NONZERO_WEIGHTS){const a=Object(w.a)(t,"labels","huberLoss"),u=Object(w.a)(e,"predictions","huberLoss");let c=null;null!=n&&(c=Object(w.a)(n,"weights","huberLoss")),Object(E.e)(a.shape,u.shape,"Error in huberLoss: ");const l=Object(ze.a)(r),h=Object(i.a)(Object(ee.a)(u,a)),d=Object(Xt.a)(h,l),p=Object(ee.a)(h,d),f=Object(o.a)(Object(O.a)(Object(ze.a)(.5),Object(te.a)(d)),Object(O.a)(l,p));return kr(f,c,s)}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Ir=Object(S.b)({logLoss_:function(t,e,n,r=1e-7,i=Sr.a.SUM_BY_NONZERO_WEIGHTS){const s=Object(w.a)(t,"labels","logLoss"),a=Object(w.a)(e,"predictions","logLoss");let u=null;null!=n&&(u=Object(w.a)(n,"weights","logLoss")),Object(E.e)(s.shape,a.shape,"Error in logLoss: ");const c=Object(ze.a)(1),l=Object(ze.a)(r),h=Object(se.a)(Object(O.a)(s,Object(Dt.a)(Object(o.a)(a,l)))),d=Object(O.a)(Object(ee.a)(c,s),Object(Dt.a)(Object(o.a)(Object(ee.a)(c,a),l))),p=Object(ee.a)(h,d);return kr(p,u,i)}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Er=Object(S.b)({meanSquaredError_:function(t,e,n,r=Sr.a.SUM_BY_NONZERO_WEIGHTS){const i=Object(w.a)(t,"labels","meanSquaredError"),s=Object(w.a)(e,"predictions","meanSquaredError");let a=null;null!=n&&(a=Object(w.a)(n,"weights","meanSquaredError")),Object(E.e)(i.shape,s.shape,"Error in meanSquaredError: ");const o=Object(sn.a)(i,s);return kr(o,a,r)}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const jr=Object(S.b)({sigmoidCrossEntropy_:function(t,e,n,r=0,s=Sr.a.SUM_BY_NONZERO_WEIGHTS){let a=Object(w.a)(t,"multiClassLabels","sigmoidCrossEntropy");const u=Object(w.a)(e,"logits","sigmoidCrossEntropy");let c=null;if(null!=n&&(c=Object(w.a)(n,"weights","sigmoidCrossEntropy")),Object(E.e)(a.shape,u.shape,"Error in sigmoidCrossEntropy: "),r>0){const t=Object(ze.a)(r),e=Object(ze.a)(1),n=Object(ze.a)(.5);a=Object(o.a)(Object(O.a)(a,Object(ee.a)(e,t)),Object(O.a)(n,t))}const l=function(t,e){const n=Object(w.a)(t,"labels","sigmoidCrossEntropyWithLogits"),r=Object(w.a)(e,"logits","sigmoidCrossEntropyWithLogits");Object(E.e)(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");const s=Object(Ne.a)(r),a=Object(O.a)(r,n),u=Object(Rt.a)(Object(ft.a)(Object(se.a)(Object(i.a)(r))));return Object(o.a)(Object(ee.a)(s,a),u)}(a,u);return kr(l,c,s)}});
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Mr=Object(S.b)({softmaxCrossEntropy_:function(t,e,n,r=0,i=Sr.a.SUM_BY_NONZERO_WEIGHTS){let s=Object(w.a)(t,"onehotLabels","softmaxCrossEntropy");const a=Object(w.a)(e,"logits","softmaxCrossEntropy");let u=null;if(null!=n&&(u=Object(w.a)(n,"weights","softmaxCrossEntropy")),Object(E.e)(s.shape,a.shape,"Error in softmaxCrossEntropy: "),r>0){const t=Object(ze.a)(r),e=Object(ze.a)(1),n=Object(ze.a)(s.shape[1]);s=Object(o.a)(Object(O.a)(s,Object(ee.a)(e,t)),Object(ut.a)(t,n))}const c=function(t,e,n=-1){if(-1===n&&(n=e.rank-1),n!==e.rank-1)throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${e.rank} and dim was `+n);return Object(Wn.a)((t,e,r)=>{const i=Object(zt.a)(e,[n],!0),s=Object(ee.a)(Object(F.a)(e,"float32"),i);r([t,s]);const a=Object(se.a)(Object(O.a)(s,t));return{value:Object(ln.a)(a,[n]),gradFunc:(t,e)=>{const[r,i]=e,s=Object(Zt.e)(t.shape,[n]);return[Object(O.a)(Object(st.a)(t,s),Object(ee.a)(Object(F.a)(r,"float32"),Object(ft.a)(i))),Object(O.a)(Object(st.a)(t,s),Object(ee.a)(Object(ft.a)(i),Object(F.a)(r,"float32")))]}}})(t,e)}(s,a);return kr(c,u,i)}}),Dr={fft:Je.a,ifft:Ze.a,rfft:en.a,irfft:tn.a},Rr={hammingWindow:nr,hannWindow:rr,frame:ir,stft:sr},Pr={flipLeftRight:or,resizeNearestNeighbor:yr.a,resizeBilinear:br.a,rotateWithOffset:ur,cropAndResize:ar,nonMaxSuppression:lr,nonMaxSuppressionAsync:dr,nonMaxSuppressionWithScore:pr,nonMaxSuppressionWithScoreAsync:fr,nonMaxSuppressionPadded:mr,nonMaxSuppressionPaddedAsync:gr},Fr={bandPart:vr,gramSchmidt:wr,qr:Or},zr={absoluteDifference:Tr,computeWeightedLoss:kr,cosineDistance:Cr,hingeLoss:Ar,huberLoss:Nr,logLoss:Ir,meanSquaredError:Er,sigmoidCrossEntropy:jr,softmaxCrossEntropy:Mr};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */},function(t,e,n){"use strict";n.d(e,"d",(function(){return i})),n.d(e,"e",(function(){return s})),n.d(e,"f",(function(){return a})),n.d(e,"a",(function(){return o})),n.d(e,"b",(function(){return u})),n.d(e,"c",(function(){return c})),n.d(e,"i",(function(){return f})),n.d(e,"h",(function(){return m})),n.d(e,"g",(function(){return g}));var r=n(7);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function i(t,e,n,r,i="NHWC",s){return o(t,[...e,t[3]],n,s,r,null,null,g(i))}function s(t,e,n,r,i,s,a="channelsLast"){const[u,c]=l(e);let h;if("channelsLast"===a)h=[u,c,t[3],t[3]];else{if("channelsFirst"!==a)throw new Error("Unknown dataFormat "+a);h=[u,c,t[1],t[1]]}return o(t,h,n,r,i,s,!1,a)}function a(t,e,n,r,i,s,a="NDHWC"){const[o,c,l]=h(e);let d,p;if("NDHWC"===a)p="channelsLast",d=[o,c,l,t[4],t[4]];else{if("NCDHW"!==a)throw new Error("Unknown dataFormat "+a);p="channelsFirst",d=[o,c,l,t[1],t[1]]}return u(t,d,n,r,i,!1,p,s)}function o(t,e,n,i,s,a,o=!1,u="channelsLast"){let[h,f,m,g]=[-1,-1,-1,-1];if("channelsLast"===u)[h,f,m,g]=t;else{if("channelsFirst"!==u)throw new Error("Unknown dataFormat "+u);[h,g,f,m]=t}const[b,y,,v]=e,[w,x]=l(n),[_,O]=l(i),S=d(b,_),k=d(y,O),{padInfo:T,outHeight:C,outWidth:A}=function(t,e,n,i,s,a,o,u,l){let h,d,f;if("number"==typeof t){h={top:t,bottom:t,left:t,right:t,type:0===t?"VALID":"NUMBER"};const s=function(t,e,n,i,s){null==i&&(i=c(t,e,n));const a=t[0],o=t[1],u=p((a-e+2*i)/n+1,s);r.b(r.v(u),()=>`The output # of rows (${u}) must be an integer. Change the stride and/or zero pad parameters`);const l=p((o-e+2*i)/n+1,s);return r.b(r.v(l),()=>`The output # of columns (${l}) must be an integer. Change the stride and/or zero pad parameters`),[u,l]}([e,n],a,i,t,u);d=s[0],f=s[1]}else if("same"===t){d=Math.ceil(e/i),f=Math.ceil(n/s);const t=Math.max(0,(d-1)*i+a-e),r=Math.max(0,(f-1)*s+o-n),u=Math.floor(t/2),c=t-u,l=Math.floor(r/2);h={top:u,bottom:c,left:l,right:r-l,type:"SAME"}}else if("valid"===t)h={top:0,bottom:0,left:0,right:0,type:"VALID"},d=Math.ceil((e-a+1)/i),f=Math.ceil((n-o+1)/s);else{if("object"!=typeof t)throw Error("Unknown padding parameter: "+t);{const r="channelsLast"===l?t[1][0]:t[2][0],c="channelsLast"===l?t[1][1]:t[2][1],m="channelsLast"===l?t[2][0]:t[3][0],g="channelsLast"===l?t[2][1]:t[3][1];h={top:r,bottom:c,left:m,right:g,type:0===r&&0===c&&0===m&&0===g?"VALID":"EXPLICIT"},d=p((e-a+r+c)/i+1,u),f=p((n-o+m+g)/s+1,u)}}return{padInfo:h,outHeight:d,outWidth:f}}(s,f,m,w,x,S,k,a,u),N=o?v*g:v;let I;return"channelsFirst"===u?I=[h,N,C,A]:"channelsLast"===u&&(I=[h,C,A,N]),{batchSize:h,dataFormat:u,inHeight:f,inWidth:m,inChannels:g,outHeight:C,outWidth:A,outChannels:N,padInfo:T,strideHeight:w,strideWidth:x,filterHeight:b,filterWidth:y,effectiveFilterHeight:S,effectiveFilterWidth:k,dilationHeight:_,dilationWidth:O,inShape:t,outShape:I,filterShape:e}}function u(t,e,n,i,s,a=!1,o="channelsLast",u){let[l,f,m,g,b]=[-1,-1,-1,-1,-1];if("channelsLast"===o)[l,f,m,g,b]=t;else{if("channelsFirst"!==o)throw new Error("Unknown dataFormat "+o);[l,b,f,m,g]=t}const[y,v,w,,x]=e,[_,O,S]=h(n),[k,T,C]=h(i),A=d(y,k),N=d(v,T),I=d(w,C),{padInfo:E,outDepth:j,outHeight:M,outWidth:D}=function(t,e,n,i,s,a,o,u,l,h,d){let f,m,g,b;if("number"==typeof t){f={top:t,bottom:t,left:t,right:t,front:t,back:t,type:0===t?"VALID":"NUMBER"};const a=function(t,e,n,i,s,a){null==s&&(s=c(t,e,i));const o=t[0],u=t[1],l=t[2],h=p((o-e+2*s)/i+1,a);r.b(r.v(h),()=>`The output # of depths (${h}) must be an integer. Change the stride and/or zero pad parameters`);const d=p((u-e+2*s)/i+1,a);r.b(r.v(d),()=>`The output # of rows (${d}) must be an integer. Change the stride and/or zero pad parameters`);const f=p((l-e+2*s)/i+1,a);return r.b(r.v(f),()=>`The output # of columns (${f}) must be an integer. Change the stride and/or zero pad parameters`),[h,d,f,n]}([e,n,i,1],u,1,s,t,d);m=a[0],g=a[1],b=a[2]}else if("same"===t){m=Math.ceil(e/s),g=Math.ceil(n/a),b=Math.ceil(i/o);const t=(m-1)*s+u-e,r=(g-1)*a+l-n,c=(b-1)*o+h-i,d=Math.floor(t/2),p=t-d,y=Math.floor(r/2),v=r-y,w=Math.floor(c/2);f={top:y,bottom:v,left:w,right:c-w,front:d,back:p,type:"SAME"}}else{if("valid"!==t)throw Error("Unknown padding parameter: "+t);f={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},m=Math.ceil((e-u+1)/s),g=Math.ceil((n-l+1)/a),b=Math.ceil((i-h+1)/o)}return{padInfo:f,outDepth:m,outHeight:g,outWidth:b}}(s,f,m,g,_,O,S,A,N,I,u),R=a?x*b:x;let P;return"channelsFirst"===o?P=[l,R,j,M,D]:"channelsLast"===o&&(P=[l,j,M,D,R]),{batchSize:l,dataFormat:o,inDepth:f,inHeight:m,inWidth:g,inChannels:b,outDepth:j,outHeight:M,outWidth:D,outChannels:R,padInfo:E,strideDepth:_,strideHeight:O,strideWidth:S,filterDepth:y,filterHeight:v,filterWidth:w,effectiveFilterDepth:A,effectiveFilterHeight:N,effectiveFilterWidth:I,dilationDepth:k,dilationHeight:T,dilationWidth:C,inShape:t,outShape:P,filterShape:e}}function c(t,e,n,r=1){const i=d(e,r);return Math.floor((t[0]*(n-1)-n+i)/2)}function l(t){return"number"==typeof t?[t,t,t]:2===t.length?[t[0],t[1],1]:t}function h(t){return"number"==typeof t?[t,t,t]:t}function d(t,e){return e<=1?t:t+(t-1)*(e-1)}function p(t,e){if(!e)return t;switch(e){case"round":return Math.round(t);case"ceil":return Math.ceil(t);case"floor":return Math.floor(t);default:throw new Error("Unknown roundingMode "+e)}}function f(t){const[e,n,r]=l(t);return 1===e&&1===n&&1===r}function m(t,e){return f(t)||f(e)}function g(t){if("NHWC"===t)return"channelsLast";if("NCHW"===t)return"channelsFirst";throw new Error("Unknown dataFormat "+t)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return d}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(24),u=n(12),c=n(4),l=n(8),h=n(31);const d=Object(c.b)({sum_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=null,n=!1){let c=Object(s.a)(t,"x","sum");"bool"===c.dtype&&(c=Object(u.a)(c,"int32"));const d={x:c},p={axis:e,keepDims:n};return r.a.runKernelFunc((t,r)=>{r([c]);const i=Object(a.I)(e,c.shape),s=Object(o.f)(i,c.rank);let u=i,d=c;null!=s&&(d=Object(h.a)(c,s),u=Object(o.g)(u.length,c.rank));let p=t.sum(d,u);if(n){const t=Object(o.e)(p.shape,i);p=Object(l.a)(p,t)}return p},d,null,i.Jc,p)}})},function(t,e,n){"use strict";n.d(e,"g",(function(){return o})),n.d(e,"f",(function(){return u})),n.d(e,"c",(function(){return c})),n.d(e,"b",(function(){return l})),n.d(e,"e",(function(){return h})),n.d(e,"h",(function(){return d})),n.d(e,"m",(function(){return p})),n.d(e,"n",(function(){return f})),n.d(e,"t",(function(){return m})),n.d(e,"d",(function(){return g})),n.d(e,"l",(function(){return b})),n.d(e,"u",(function(){return y})),n.d(e,"r",(function(){return v})),n.d(e,"o",(function(){return w})),n.d(e,"k",(function(){return x})),n.d(e,"q",(function(){return _})),n.d(e,"i",(function(){return O})),n.d(e,"j",(function(){return S})),n.d(e,"p",(function(){return k})),n.d(e,"a",(function(){return T})),n.d(e,"s",(function(){return C}));var r=n(5),i=n(26),s=n(6),a=n(25);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function o(){Object(i.c)().set("PROD",!0)}function u(){Object(i.c)().set("DEBUG",!0)}function c(){Object(i.c)().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function l(t){Object(i.c)().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(t+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function h(){r.a.disposeVariables()}function d(){return r.a}function p(){return r.a.memory()}function f(t){return r.a.profile(t)}function m(t,e){return r.a.tidy(t,e)}function g(t){Object(a.getTensorsInContainer)(t).forEach(t=>t.dispose())}function b(t){return r.a.keep(t)}function y(t){return r.a.time(t)}function v(t){return r.a.setBackend(t)}function w(){return r.a.ready()}function x(){return r.a.backendName}function _(t){r.a.removeBackend(t)}function O(t){return r.a.findBackend(t)}function S(t){return r.a.findBackendFactory(t)}function k(t,e,n=1){return r.a.registerBackend(t,e,n)}function T(){return r.a.backend}function C(t,e){Object(i.c)().setPlatform(t,e)}Object(s.d)(l)},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({zerosLike_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","zerosLike"),n={x:e};return r.a.runKernelFunc(t=>t.zerosLike(e),n,null,i.Sc)}})},function(t,e,n){"use strict";n.d(e,"b",(function(){return i})),n.d(e,"c",(function(){return s})),n.d(e,"d",(function(){return a})),n.d(e,"e",(function(){return o})),n.d(e,"a",(function(){return u})),n.d(e,"f",(function(){return c})),n.d(e,"h",(function(){return l})),n.d(e,"g",(function(){return h}));var r=n(7);
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function i(t,e){for(let n=0;n<t.length;++n)if(t[t.length-n-1]!==e-1-n)return!1;return!0}function s(t,e,n){const r=t.length+e.length,i=[];let s=0,a=0;for(let o=0;o<r;o++)-1===n.indexOf(o)?i.push(t[s++]):i.push(e[a++]);return i}function a(t,e){const n=[],r=t.length;for(let i=0;i<r;i++)-1===e.indexOf(i)&&n.push(t[i]);return[n,e.map(e=>t[e])]}function o(t,e){return s(t,e.map(t=>1),e)}function u(t,e,n){r.b(i(e,n),()=>t+" supports only inner-most axes for now. "+`Got axes ${e} and rank-${n} input.`)}function c(t,e){if(i(t,e))return null;const n=[];for(let r=0;r<e;++r)-1===t.indexOf(r)&&n.push(r);return t.forEach(t=>n.push(t)),n}function l(t){return t.map((t,e)=>[e,t]).sort((t,e)=>t[1]-e[1]).map(t=>t[0])}function h(t,e){const n=[];for(let r=e-t;r<e;++r)n.push(r);return n}},function(t,e,n){"use strict";n.r(e),n.d(e,"makeTypesMatch",(function(){return a})),n.d(e,"assertTypesMatch",(function(){return o})),n.d(e,"isTensorInList",(function(){return u})),n.d(e,"getTensorsInContainer",(function(){return c}));var r=n(6),i=n(97),s=n(7);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function a(t,e){if(t.dtype===e.dtype)return[t,e];const n=Object(i.c)(t.dtype,e.dtype);return[t.cast(n),e.cast(n)]}function o(t,e){Object(s.b)(t.dtype===e.dtype,()=>`The dtypes of the first(${t.dtype}) and second(${e.dtype}) input must match`)}function u(t,e){return e.some(e=>e.id===t.id)}function c(t){const e=[];return function t(e,n,i){if(null==e)return;if(e instanceof r.a)return void n.push(e);if(s=e,!Array.isArray(s)&&"object"!=typeof s)return;var s;const a=e;for(const e in a){const r=a[e];i.has(r)||(i.add(r),t(r,n,i))}}(t,e,new Set),e}},function(t,e,n){"use strict";n.d(e,"b",(function(){return i})),n.d(e,"c",(function(){return s})),n.d(e,"a",(function(){return a})),n.d(e,"d",(function(){return o}));var r=n(7);
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class i{constructor(t){this.global=t,this.flags={},this.flagRegistry={},this.urlFlags={},this.populateURLFlags()}setPlatform(t,e){null!=this.platform&&console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`),this.platformName=t,this.platform=e}registerFlag(t,e,n){if(this.flagRegistry[t]={evaluationFn:e,setHook:n},null!=this.urlFlags[t]){const e=this.urlFlags[t];console.warn(`Setting feature override from URL ${t}: ${e}.`),this.set(t,e)}}async getAsync(t){return t in this.flags||(this.flags[t]=await this.evaluateFlag(t)),this.flags[t]}get(t){if(t in this.flags)return this.flags[t];const e=this.evaluateFlag(t);if(Object(r.x)(e))throw new Error(`Flag ${t} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[t]=e,this.flags[t]}getNumber(t){return this.get(t)}getBool(t){return this.get(t)}getFlags(){return this.flags}get features(){return this.flags}set(t,e){if(null==this.flagRegistry[t])throw new Error(`Cannot set flag ${t} as it has not been registered.`);this.flags[t]=e,null!=this.flagRegistry[t].setHook&&this.flagRegistry[t].setHook(e)}evaluateFlag(t){if(null==this.flagRegistry[t])throw new Error(`Cannot evaluate flag '${t}': no evaluation function found.`);return this.flagRegistry[t].evaluationFn()}setFlags(t){this.flags=Object.assign({},t)}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 t=function(t){const e={};return t.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(t,...n)=>(function(t,e,n){t[decodeURIComponent(e)]=decodeURIComponent(n||"")}(e,n[0],n[1]),n.join("="))),e}(this.global.location.search);if("tfjsflags"in t){t.tfjsflags.split(",").forEach(t=>{const[e,n]=t.split(":");this.urlFlags[e]=function(t,e){if("true"===(e=e.toLowerCase())||"false"===e)return"true"===e;if(""+ +e===e)return+e;throw new Error(`Could not parse value flag value ${e} for flag ${t}.`)}(e,n)})}}}function s(){return a}let a=null;function o(t){a=t}},function(t,e,n){"use strict";n.d(e,"a",(function(){return a}));var r=n(5),i=n(1),s=n(4);const a=Object(s.b)({square_:
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(i.a)(t,"x","square"),n=[e];return r.a.runKernelFunc((t,n)=>(n([e]),t.square(e)),{x:e},null,"Square",{},n,[])}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(4),o=n(52);const u=Object(a.b)({slice_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n){const a=Object(s.a)(t,"x","slice");if(0===a.rank)throw new Error("Slicing scalar is not possible");const u={x:a},c={begin:e,size:n};return r.a.runKernelFunc((t,r)=>{const[i,s]=o.parseSliceParams(a,e,n);return o.assertParamsValid(a,i,s),r([a]),t.slice(a,i,s)},u,null,i.xc,c)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(7),u=n(4),c=n(8);const l=Object(u.b)({matMul_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n=!1,u=!1){let l=Object(a.a)(t,"a","matMul"),h=Object(a.a)(e,"b","matMul");[l,h]=Object(s.makeTypesMatch)(l,h);const d={a:l,b:h},p={transposeA:n,transposeB:u};return r.a.runKernelFunc((t,e)=>{e([l,h]);const r=n?l.shape[l.rank-2]:l.shape[l.rank-1],i=u?h.shape[h.rank-1]:h.shape[h.rank-2],s=n?l.shape[l.rank-1]:l.shape[l.rank-2],a=u?h.shape[h.rank-2]:h.shape[h.rank-1],d=l.shape.slice(0,-2),p=h.shape.slice(0,-2),f=o.N(d),m=o.N(p),g=f===m||1===f||1===m;o.b(l.rank>=2&&h.rank>=2&&g,()=>`Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input batch dimensions of (${d}) and (${p}).`),o.b(r===i,()=>`Error in matMul: inner shapes (${r}) and (${i}) of Tensors with shapes ${l.shape} and ${h.shape} and transposeA=${n} and transposeB=${u} must match.`);const b=(f>m?d:p).concat([s,a]),y=n?Object(c.a)(l,[f,r,s]):Object(c.a)(l,[f,s,r]),v=u?Object(c.a)(h,[m,a,i]):Object(c.a)(h,[m,i,a]),w=t.batchMatMul(y,v,n,u);return Object(c.a)(w,b)},d,null,i.s,p)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({neg_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","neg"),n={x:e};return r.a.runKernelFunc(t=>t.neg(e),n,null,i.Qb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4);const u=Object(o.b)({transpose_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){const n=Object(s.a)(t,"x","transpose");if(null==e&&(e=n.shape.map((t,e)=>e).reverse()),a.b(n.rank===e.length,()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${e}.`),e.forEach(t=>{a.b(t>=0&&t<n.rank,()=>"All entries in 'perm' must be between 0 and "+(n.rank-1)+" but got "+e)}),n.rank<=1)return n.clone();const o={x:n},u={perm:e};return r.a.runKernelFunc(t=>t.transpose(n,e),o,null,i.Oc,u)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(148),u=n(4),c=n(64);const l=Object(u.b)({concat_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=0){Object(a.b)(t.length>=1,()=>"Pass at least one tensor to concat");let n=Object(s.b)(t,"tensors","concat");"complex64"===n[0].dtype&&n.forEach(t=>{if("complex64"!==t.dtype)throw new Error(`Cannot concatenate complex64 tensors with a tensor\n          with dtype ${t.dtype}. `)});const u=n,l={axis:e};return r.a.runKernelFunc((t,r)=>{const i=Object(a.I)(e,n[0].shape)[0],s=Object(o.b)(n.map(t=>t.shape),i);if(0===Object(a.N)(s))return Object(c.a)([],s);if(n=n.filter(t=>t.size>0),1===n.length)return n[0];const u=n.map(t=>t.shape);Object(o.a)(u,i);const l=t.concat(n,i);return r(n),l},u,null,i.z,l)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return d})),n.d(e,"f",(function(){return h})),n.d(e,"d",(function(){return c})),n.d(e,"e",(function(){return l})),n.d(e,"b",(function(){return o})),n.d(e,"c",(function(){return u}));var r=n(5),i=n(6),s=n(1),a=n(7);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function o(t){return a.b(a.u(t),()=>"The f passed in grad(f) must be a function"),(e,n)=>{const i=Object(s.a)(e,"x","tf.grad",null),o=null!=n?Object(s.a)(n,"dy","tf.grad"):null;return r.a.tidy(()=>{const{value:e,grads:n}=r.a.gradients(()=>t(i),[i],o);return null!=o&&a.e(e.shape,o.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),p(n),n[0]})}}function u(t){return a.b(a.u(t),()=>"The f passed in grads(f) must be a function"),(e,n)=>{a.b(Array.isArray(e),()=>"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s");const i=Object(s.b)(e,"args","tf.grads",null),o=null!=n?Object(s.a)(n,"dy","tf.grads"):null;return r.a.tidy(()=>{const{value:e,grads:n}=r.a.gradients(()=>t(...i),i,o);return null!=o&&a.e(e.shape,o.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),p(n),n})}}function c(t){return a.b(a.u(t),()=>"The f passed in valueAndGrad(f) must be a function"),(e,n)=>{a.b(e instanceof i.a,()=>"The x passed in valueAndGrad(f)(x) must be a tensor"),a.b(null==n||n instanceof i.a,()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor");const{grads:s,value:o}=r.a.gradients(()=>t(e),[e],n);return p(s),{grad:s[0],value:o}}}function l(t){return a.b(a.u(t),()=>"The f passed in valueAndGrads(f) must be a function"),(e,n)=>{a.b(Array.isArray(e)&&e.every(t=>t instanceof i.a),()=>"The args passed in valueAndGrads(f)(args) must be array of tensors"),a.b(null==n||n instanceof i.a,()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor");const s=r.a.gradients(()=>t(...e),e,n);return null!=n&&a.e(s.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),p(s.grads),s}}function h(t,e){a.b(a.u(t),()=>"The f passed in variableGrads(f) must be a function"),a.b(null==e||Array.isArray(e)&&e.every(t=>t instanceof i.c),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");const n=null!=e;if(!n){e=[];for(const t in r.a.registeredVariables)e.push(r.a.registeredVariables[t])}const s=n?e.filter(t=>!t.trainable):null,o=e.length;e=e.filter(t=>t.trainable),a.b(e.length>0,()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${o} variables is trainable.`);const{value:u,grads:c}=r.a.gradients(t,e,null,!0);a.b(c.some(t=>null!=t),()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."),a.b(0===u.rank,()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${u.rank} tensor`);const l={};return e.forEach((t,e)=>{null!=c[e]&&(l[t.name]=c[e])}),null!=s&&s.forEach(t=>l[t.name]=null),{value:u,grads:l}}function d(t){return r.a.customGrad(t)}function p(t){if(t.filter(t=>null==t).length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that\n    the f you passed encloses all operations that lead from x to y.")}},function(t,e,n){"use strict";
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
var r;n.d(e,"a",(function(){return r})),function(t){t[t.NONE=0]="NONE",t[t.MEAN=1]="MEAN",t[t.SUM=2]="SUM",t[t.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(r||(r={}))},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({sqrt_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","sqrt"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.sqrt(e);return n([e]),r},n,null,i.Dc)}})},function(t,e,n){"use strict";n.r(e),n.d(e,"AdadeltaOptimizer",(function(){return l.AdadeltaOptimizer})),n.d(e,"AdagradOptimizer",(function(){return l.AdagradOptimizer})),n.d(e,"AdamOptimizer",(function(){return l.AdamOptimizer})),n.d(e,"AdamaxOptimizer",(function(){return l.AdamaxOptimizer})),n.d(e,"MomentumOptimizer",(function(){return l.MomentumOptimizer})),n.d(e,"Optimizer",(function(){return l.Optimizer})),n.d(e,"RMSPropOptimizer",(function(){return l.RMSPropOptimizer})),n.d(e,"SGDOptimizer",(function(){return l.SGDOptimizer})),n.d(e,"Tensor",(function(){return l.Tensor})),n.d(e,"TensorBuffer",(function(){return l.TensorBuffer})),n.d(e,"Variable",(function(){return l.Variable})),n.d(e,"Rank",(function(){return l.Rank})),n.d(e,"sumOutType",(function(){return l.sumOutType})),n.d(e,"upcastType",(function(){return l.upcastType})),n.d(e,"abs",(function(){return l.abs})),n.d(e,"acos",(function(){return l.acos})),n.d(e,"acosh",(function(){return l.acosh})),n.d(e,"add",(function(){return l.add})),n.d(e,"addN",(function(){return l.addN})),n.d(e,"all",(function(){return l.all})),n.d(e,"any",(function(){return l.any})),n.d(e,"argMax",(function(){return l.argMax})),n.d(e,"argMin",(function(){return l.argMin})),n.d(e,"asin",(function(){return l.asin})),n.d(e,"asinh",(function(){return l.asinh})),n.d(e,"atan",(function(){return l.atan})),n.d(e,"atan2",(function(){return l.atan2})),n.d(e,"atanh",(function(){return l.atanh})),n.d(e,"avgPool",(function(){return l.avgPool})),n.d(e,"avgPool3d",(function(){return l.avgPool3d})),n.d(e,"basicLSTMCell",(function(){return l.basicLSTMCell})),n.d(e,"batchToSpaceND",(function(){return l.batchToSpaceND})),n.d(e,"batchNorm",(function(){return l.batchNorm})),n.d(e,"batchNorm2d",(function(){return l.batchNorm2d})),n.d(e,"batchNorm3d",(function(){return l.batchNorm3d})),n.d(e,"batchNorm4d",(function(){return l.batchNorm4d})),n.d(e,"broadcastTo",(function(){return l.broadcastTo})),n.d(e,"buffer",(function(){return l.buffer})),n.d(e,"cast",(function(){return l.cast})),n.d(e,"ceil",(function(){return l.ceil})),n.d(e,"clipByValue",(function(){return l.clipByValue})),n.d(e,"clone",(function(){return l.clone})),n.d(e,"complex",(function(){return l.complex})),n.d(e,"concat",(function(){return l.concat})),n.d(e,"concat1d",(function(){return l.concat1d})),n.d(e,"concat2d",(function(){return l.concat2d})),n.d(e,"concat3d",(function(){return l.concat3d})),n.d(e,"concat4d",(function(){return l.concat4d})),n.d(e,"conv1d",(function(){return l.conv1d})),n.d(e,"conv2d",(function(){return l.conv2d})),n.d(e,"conv2dTranspose",(function(){return l.conv2dTranspose})),n.d(e,"conv3d",(function(){return l.conv3d})),n.d(e,"conv3dTranspose",(function(){return l.conv3dTranspose})),n.d(e,"cos",(function(){return l.cos})),n.d(e,"cosh",(function(){return l.cosh})),n.d(e,"cumsum",(function(){return l.cumsum})),n.d(e,"depthToSpace",(function(){return l.depthToSpace})),n.d(e,"depthwiseConv2d",(function(){return l.depthwiseConv2d})),n.d(e,"diag",(function(){return l.diag})),n.d(e,"dilation2d",(function(){return l.dilation2d})),n.d(e,"div",(function(){return l.div})),n.d(e,"divNoNan",(function(){return l.divNoNan})),n.d(e,"dot",(function(){return l.dot})),n.d(e,"elu",(function(){return l.elu})),n.d(e,"equal",(function(){return l.equal})),n.d(e,"erf",(function(){return l.erf})),n.d(e,"exp",(function(){return l.exp})),n.d(e,"expandDims",(function(){return l.expandDims})),n.d(e,"expm1",(function(){return l.expm1})),n.d(e,"eye",(function(){return l.eye})),n.d(e,"fill",(function(){return l.fill})),n.d(e,"floor",(function(){return l.floor})),n.d(e,"floorDiv",(function(){return l.floorDiv})),n.d(e,"gather",(function(){return l.gather})),n.d(e,"greater",(function(){return l.greater})),n.d(e,"greaterEqual",(function(){return l.greaterEqual})),n.d(e,"imag",(function(){return l.imag})),n.d(e,"isFinite",(function(){return l.isFinite})),n.d(e,"isInf",(function(){return l.isInf})),n.d(e,"isNaN",(function(){return l.isNaN})),n.d(e,"leakyRelu",(function(){return l.leakyRelu})),n.d(e,"less",(function(){return l.less})),n.d(e,"lessEqual",(function(){return l.lessEqual})),n.d(e,"linspace",(function(){return l.linspace})),n.d(e,"localResponseNormalization",(function(){return l.localResponseNormalization})),n.d(e,"log",(function(){return l.log})),n.d(e,"log1p",(function(){return l.log1p})),n.d(e,"logSigmoid",(function(){return l.logSigmoid})),n.d(e,"logSoftmax",(function(){return l.logSoftmax})),n.d(e,"logSumExp",(function(){return l.logSumExp})),n.d(e,"logicalAnd",(function(){return l.logicalAnd})),n.d(e,"logicalNot",(function(){return l.logicalNot})),n.d(e,"logicalOr",(function(){return l.logicalOr})),n.d(e,"logicalXor",(function(){return l.logicalXor})),n.d(e,"matMul",(function(){return l.matMul})),n.d(e,"max",(function(){return l.max})),n.d(e,"maxPool",(function(){return l.maxPool})),n.d(e,"maxPool3d",(function(){return l.maxPool3d})),n.d(e,"maxPoolWithArgmax",(function(){return l.maxPoolWithArgmax})),n.d(e,"maximum",(function(){return l.maximum})),n.d(e,"mean",(function(){return l.mean})),n.d(e,"min",(function(){return l.min})),n.d(e,"minimum",(function(){return l.minimum})),n.d(e,"mirrorPad",(function(){return l.mirrorPad})),n.d(e,"mod",(function(){return l.mod})),n.d(e,"moments",(function(){return l.moments})),n.d(e,"mul",(function(){return l.mul})),n.d(e,"multiRNNCell",(function(){return l.multiRNNCell})),n.d(e,"multinomial",(function(){return l.multinomial})),n.d(e,"neg",(function(){return l.neg})),n.d(e,"notEqual",(function(){return l.notEqual})),n.d(e,"oneHot",(function(){return l.oneHot})),n.d(e,"ones",(function(){return l.ones})),n.d(e,"onesLike",(function(){return l.onesLike})),n.d(e,"outerProduct",(function(){return l.outerProduct})),n.d(e,"pad",(function(){return l.pad})),n.d(e,"pad1d",(function(){return l.pad1d})),n.d(e,"pad2d",(function(){return l.pad2d})),n.d(e,"pad3d",(function(){return l.pad3d})),n.d(e,"pad4d",(function(){return l.pad4d})),n.d(e,"pool",(function(){return l.pool})),n.d(e,"pow",(function(){return l.pow})),n.d(e,"prelu",(function(){return l.prelu})),n.d(e,"print",(function(){return l.print})),n.d(e,"prod",(function(){return l.prod})),n.d(e,"rand",(function(){return l.rand})),n.d(e,"randomGamma",(function(){return l.randomGamma})),n.d(e,"randomNormal",(function(){return l.randomNormal})),n.d(e,"randomUniform",(function(){return l.randomUniform})),n.d(e,"range",(function(){return l.range})),n.d(e,"real",(function(){return l.real})),n.d(e,"reciprocal",(function(){return l.reciprocal})),n.d(e,"relu",(function(){return l.relu})),n.d(e,"relu6",(function(){return l.relu6})),n.d(e,"reshape",(function(){return l.reshape})),n.d(e,"reverse",(function(){return l.reverse})),n.d(e,"reverse1d",(function(){return l.reverse1d})),n.d(e,"reverse2d",(function(){return l.reverse2d})),n.d(e,"reverse3d",(function(){return l.reverse3d})),n.d(e,"reverse4d",(function(){return l.reverse4d})),n.d(e,"round",(function(){return l.round})),n.d(e,"rsqrt",(function(){return l.rsqrt})),n.d(e,"scalar",(function(){return l.scalar})),n.d(e,"selu",(function(){return l.selu})),n.d(e,"separableConv2d",(function(){return l.separableConv2d})),n.d(e,"setdiff1dAsync",(function(){return l.setdiff1dAsync})),n.d(e,"sigmoid",(function(){return l.sigmoid})),n.d(e,"sign",(function(){return l.sign})),n.d(e,"sin",(function(){return l.sin})),n.d(e,"sinh",(function(){return l.sinh})),n.d(e,"slice",(function(){return l.slice})),n.d(e,"slice1d",(function(){return l.slice1d})),n.d(e,"slice2d",(function(){return l.slice2d})),n.d(e,"slice3d",(function(){return l.slice3d})),n.d(e,"slice4d",(function(){return l.slice4d})),n.d(e,"softmax",(function(){return l.softmax})),n.d(e,"softplus",(function(){return l.softplus})),n.d(e,"spaceToBatchND",(function(){return l.spaceToBatchND})),n.d(e,"fft",(function(){return l.fft})),n.d(e,"ifft",(function(){return l.ifft})),n.d(e,"irfft",(function(){return l.irfft})),n.d(e,"rfft",(function(){return l.rfft})),n.d(e,"split",(function(){return l.split})),n.d(e,"sqrt",(function(){return l.sqrt})),n.d(e,"square",(function(){return l.square})),n.d(e,"squaredDifference",(function(){return l.squaredDifference})),n.d(e,"squeeze",(function(){return l.squeeze})),n.d(e,"stack",(function(){return l.stack})),n.d(e,"step",(function(){return l.step})),n.d(e,"stridedSlice",(function(){return l.stridedSlice})),n.d(e,"sub",(function(){return l.sub})),n.d(e,"sum",(function(){return l.sum})),n.d(e,"tan",(function(){return l.tan})),n.d(e,"tanh",(function(){return l.tanh})),n.d(e,"tensor",(function(){return l.tensor})),n.d(e,"tensor1d",(function(){return l.tensor1d})),n.d(e,"tensor2d",(function(){return l.tensor2d})),n.d(e,"tensor3d",(function(){return l.tensor3d})),n.d(e,"tensor4d",(function(){return l.tensor4d})),n.d(e,"tensor5d",(function(){return l.tensor5d})),n.d(e,"tensor6d",(function(){return l.tensor6d})),n.d(e,"tile",(function(){return l.tile})),n.d(e,"topk",(function(){return l.topk})),n.d(e,"truncatedNormal",(function(){return l.truncatedNormal})),n.d(e,"unique",(function(){return l.unique})),n.d(e,"unsortedSegmentSum",(function(){return l.unsortedSegmentSum})),n.d(e,"unstack",(function(){return l.unstack})),n.d(e,"variable",(function(){return l.variable})),n.d(e,"where",(function(){return l.where})),n.d(e,"whereAsync",(function(){return l.whereAsync})),n.d(e,"zeros",(function(){return l.zeros})),n.d(e,"zerosLike",(function(){return l.zerosLike})),n.d(e,"booleanMaskAsync",(function(){return l.booleanMaskAsync})),n.d(e,"equalStrict",(function(){return l.equalStrict})),n.d(e,"greaterEqualStrict",(function(){return l.greaterEqualStrict})),n.d(e,"greaterStrict",(function(){return l.greaterStrict})),n.d(e,"lessEqualStrict",(function(){return l.lessEqualStrict})),n.d(e,"lessStrict",(function(){return l.lessStrict})),n.d(e,"notEqualStrict",(function(){return l.notEqualStrict})),n.d(e,"addStrict",(function(){return l.addStrict})),n.d(e,"divStrict",(function(){return l.divStrict})),n.d(e,"maximumStrict",(function(){return l.maximumStrict})),n.d(e,"minimumStrict",(function(){return l.minimumStrict})),n.d(e,"modStrict",(function(){return l.modStrict})),n.d(e,"mulStrict",(function(){return l.mulStrict})),n.d(e,"powStrict",(function(){return l.powStrict})),n.d(e,"squaredDifferenceStrict",(function(){return l.squaredDifferenceStrict})),n.d(e,"subStrict",(function(){return l.subStrict})),n.d(e,"transpose",(function(){return l.transpose})),n.d(e,"norm",(function(){return l.norm})),n.d(e,"movingAverage",(function(){return l.movingAverage})),n.d(e,"scatterND",(function(){return l.scatterND})),n.d(e,"sparseToDense",(function(){return l.sparseToDense})),n.d(e,"gatherND",(function(){return l.gatherND})),n.d(e,"dropout",(function(){return l.dropout})),n.d(e,"enclosingPowerOfTwo",(function(){return l.enclosingPowerOfTwo})),n.d(e,"cosineWindow",(function(){return l.cosineWindow})),n.d(e,"inTopKAsync",(function(){return l.inTopKAsync})),n.d(e,"op",(function(){return l.op})),n.d(e,"OP_SCOPE_SUFFIX",(function(){return l.OP_SCOPE_SUFFIX})),n.d(e,"image",(function(){return l.image})),n.d(e,"linalg",(function(){return l.linalg})),n.d(e,"losses",(function(){return l.losses})),n.d(e,"spectral",(function(){return l.spectral})),n.d(e,"fused",(function(){return l.fused})),n.d(e,"signal",(function(){return l.signal})),n.d(e,"Reduction",(function(){return l.Reduction})),n.d(e,"train",(function(){return l.train})),n.d(e,"enableProdMode",(function(){return l.enableProdMode})),n.d(e,"enableDebugMode",(function(){return l.enableDebugMode})),n.d(e,"disableDeprecationWarnings",(function(){return l.disableDeprecationWarnings})),n.d(e,"deprecationWarn",(function(){return l.deprecationWarn})),n.d(e,"disposeVariables",(function(){return l.disposeVariables})),n.d(e,"engine",(function(){return l.engine})),n.d(e,"memory",(function(){return l.memory})),n.d(e,"profile",(function(){return l.profile})),n.d(e,"tidy",(function(){return l.tidy})),n.d(e,"dispose",(function(){return l.dispose})),n.d(e,"keep",(function(){return l.keep})),n.d(e,"time",(function(){return l.time})),n.d(e,"setBackend",(function(){return l.setBackend})),n.d(e,"ready",(function(){return l.ready})),n.d(e,"getBackend",(function(){return l.getBackend})),n.d(e,"removeBackend",(function(){return l.removeBackend})),n.d(e,"findBackend",(function(){return l.findBackend})),n.d(e,"findBackendFactory",(function(){return l.findBackendFactory})),n.d(e,"registerBackend",(function(){return l.registerBackend})),n.d(e,"backend",(function(){return l.backend})),n.d(e,"setPlatform",(function(){return l.setPlatform})),n.d(e,"getKernel",(function(){return l.getKernel})),n.d(e,"getGradient",(function(){return l.getGradient})),n.d(e,"getKernelsForBackend",(function(){return l.getKernelsForBackend})),n.d(e,"registerKernel",(function(){return l.registerKernel})),n.d(e,"registerGradient",(function(){return l.registerGradient})),n.d(e,"unregisterKernel",(function(){return l.unregisterKernel})),n.d(e,"unregisterGradient",(function(){return l.unregisterGradient})),n.d(e,"copyRegisteredKernels",(function(){return l.copyRegisteredKernels})),n.d(e,"customGrad",(function(){return l.customGrad})),n.d(e,"grad",(function(){return l.grad})),n.d(e,"grads",(function(){return l.grads})),n.d(e,"valueAndGrad",(function(){return l.valueAndGrad})),n.d(e,"valueAndGrads",(function(){return l.valueAndGrads})),n.d(e,"variableGrads",(function(){return l.variableGrads})),n.d(e,"Environment",(function(){return l.Environment})),n.d(e,"env",(function(){return l.env})),n.d(e,"ENV",(function(){return l.ENV})),n.d(e,"version_core",(function(){return l.version_core})),n.d(e,"nextFrame",(function(){return l.nextFrame})),n.d(e,"browser",(function(){return l.browser})),n.d(e,"io",(function(){return l.io})),n.d(e,"math",(function(){return l.math})),n.d(e,"serialization",(function(){return l.serialization})),n.d(e,"test_util",(function(){return l.test_util})),n.d(e,"util",(function(){return l.util})),n.d(e,"backend_util",(function(){return l.backend_util})),n.d(e,"tensor_util",(function(){return l.tensor_util})),n.d(e,"slice_util",(function(){return l.slice_util})),n.d(e,"gather_util",(function(){return l.gather_util})),n.d(e,"scatter_util",(function(){return l.scatter_util})),n.d(e,"device_util",(function(){return l.device_util})),n.d(e,"kernel_impls",(function(){return l.kernel_impls})),n.d(e,"KernelBackend",(function(){return l.KernelBackend})),n.d(e,"DataStorage",(function(){return l.DataStorage})),n.d(e,"Abs",(function(){return l.Abs})),n.d(e,"Acos",(function(){return l.Acos})),n.d(e,"Acosh",(function(){return l.Acosh})),n.d(e,"Add",(function(){return l.Add})),n.d(e,"AddN",(function(){return l.AddN})),n.d(e,"All",(function(){return l.All})),n.d(e,"Any",(function(){return l.Any})),n.d(e,"ArgMax",(function(){return l.ArgMax})),n.d(e,"ArgMin",(function(){return l.ArgMin})),n.d(e,"Asin",(function(){return l.Asin})),n.d(e,"Asinh",(function(){return l.Asinh})),n.d(e,"Atan",(function(){return l.Atan})),n.d(e,"Atanh",(function(){return l.Atanh})),n.d(e,"Atan2",(function(){return l.Atan2})),n.d(e,"AvgPool",(function(){return l.AvgPool})),n.d(e,"AvgPoolBackprop",(function(){return l.AvgPoolBackprop})),n.d(e,"AvgPool3D",(function(){return l.AvgPool3D})),n.d(e,"AvgPool3DBackprop",(function(){return l.AvgPool3DBackprop})),n.d(e,"BatchMatMul",(function(){return l.BatchMatMul})),n.d(e,"BatchToSpaceND",(function(){return l.BatchToSpaceND})),n.d(e,"BroadcastTo",(function(){return l.BroadcastTo})),n.d(e,"Cast",(function(){return l.Cast})),n.d(e,"Ceil",(function(){return l.Ceil})),n.d(e,"ClipByValue",(function(){return l.ClipByValue})),n.d(e,"Complex",(function(){return l.Complex})),n.d(e,"Concat",(function(){return l.Concat})),n.d(e,"Conv2D",(function(){return l.Conv2D})),n.d(e,"Conv2DBackpropFilter",(function(){return l.Conv2DBackpropFilter})),n.d(e,"Conv2DBackpropInput",(function(){return l.Conv2DBackpropInput})),n.d(e,"Conv3D",(function(){return l.Conv3D})),n.d(e,"Conv3DBackpropFilterV2",(function(){return l.Conv3DBackpropFilterV2})),n.d(e,"Conv3DBackpropInputV2",(function(){return l.Conv3DBackpropInputV2})),n.d(e,"Cos",(function(){return l.Cos})),n.d(e,"Cosh",(function(){return l.Cosh})),n.d(e,"Cumsum",(function(){return l.Cumsum})),n.d(e,"CropAndResize",(function(){return l.CropAndResize})),n.d(e,"DepthToSpace",(function(){return l.DepthToSpace})),n.d(e,"DepthwiseConv2dNative",(function(){return l.DepthwiseConv2dNative})),n.d(e,"DepthwiseConv2dNativeBackpropFilter",(function(){return l.DepthwiseConv2dNativeBackpropFilter})),n.d(e,"DepthwiseConv2dNativeBackpropInput",(function(){return l.DepthwiseConv2dNativeBackpropInput})),n.d(e,"Diag",(function(){return l.Diag})),n.d(e,"Dilation2D",(function(){return l.Dilation2D})),n.d(e,"Dilation2DBackpropInput",(function(){return l.Dilation2DBackpropInput})),n.d(e,"Dilation2DBackpropFilter",(function(){return l.Dilation2DBackpropFilter})),n.d(e,"Div",(function(){return l.Div})),n.d(e,"Elu",(function(){return l.Elu})),n.d(e,"EluGrad",(function(){return l.EluGrad})),n.d(e,"Erf",(function(){return l.Erf})),n.d(e,"Equal",(function(){return l.Equal})),n.d(e,"Exp",(function(){return l.Exp})),n.d(e,"Expm1",(function(){return l.Expm1})),n.d(e,"FFT",(function(){return l.FFT})),n.d(e,"Fill",(function(){return l.Fill})),n.d(e,"FlipLeftRight",(function(){return l.FlipLeftRight})),n.d(e,"Floor",(function(){return l.Floor})),n.d(e,"FloorDiv",(function(){return l.FloorDiv})),n.d(e,"FusedBatchNorm",(function(){return l.FusedBatchNorm})),n.d(e,"GatherV2",(function(){return l.GatherV2})),n.d(e,"GatherNd",(function(){return l.GatherNd})),n.d(e,"Greater",(function(){return l.Greater})),n.d(e,"GreaterEqual",(function(){return l.GreaterEqual})),n.d(e,"Identity",(function(){return l.Identity})),n.d(e,"IFFT",(function(){return l.IFFT})),n.d(e,"Imag",(function(){return l.Imag})),n.d(e,"IsFinite",(function(){return l.IsFinite})),n.d(e,"IsInf",(function(){return l.IsInf})),n.d(e,"IsNan",(function(){return l.IsNan})),n.d(e,"Less",(function(){return l.Less})),n.d(e,"LessEqual",(function(){return l.LessEqual})),n.d(e,"LinSpace",(function(){return l.LinSpace})),n.d(e,"Log",(function(){return l.Log})),n.d(e,"Log1p",(function(){return l.Log1p})),n.d(e,"LogicalAnd",(function(){return l.LogicalAnd})),n.d(e,"LogicalNot",(function(){return l.LogicalNot})),n.d(e,"LogicalOr",(function(){return l.LogicalOr})),n.d(e,"LogSoftmax",(function(){return l.LogSoftmax})),n.d(e,"LRN",(function(){return l.LRN})),n.d(e,"LRNBackprop",(function(){return l.LRNBackprop})),n.d(e,"Max",(function(){return l.Max})),n.d(e,"Maximum",(function(){return l.Maximum})),n.d(e,"MaxPool",(function(){return l.MaxPool})),n.d(e,"MaxPoolBackprop",(function(){return l.MaxPoolBackprop})),n.d(e,"MaxPool3D",(function(){return l.MaxPool3D})),n.d(e,"MaxPool3DBackprop",(function(){return l.MaxPool3DBackprop})),n.d(e,"MaxPoolWithArgmax",(function(){return l.MaxPoolWithArgmax})),n.d(e,"Mean",(function(){return l.Mean})),n.d(e,"Min",(function(){return l.Min})),n.d(e,"Minimum",(function(){return l.Minimum})),n.d(e,"MirrorPad",(function(){return l.MirrorPad})),n.d(e,"Mod",(function(){return l.Mod})),n.d(e,"Multiply",(function(){return l.Multiply})),n.d(e,"Negate",(function(){return l.Negate})),n.d(e,"NotEqual",(function(){return l.NotEqual})),n.d(e,"NonMaxSuppressionV3",(function(){return l.NonMaxSuppressionV3})),n.d(e,"NonMaxSuppressionV4",(function(){return l.NonMaxSuppressionV4})),n.d(e,"NonMaxSuppressionV5",(function(){return l.NonMaxSuppressionV5})),n.d(e,"OnesLike",(function(){return l.OnesLike})),n.d(e,"OneHot",(function(){return l.OneHot})),n.d(e,"PadV2",(function(){return l.PadV2})),n.d(e,"Pool",(function(){return l.Pool})),n.d(e,"Pow",(function(){return l.Pow})),n.d(e,"Prelu",(function(){return l.Prelu})),n.d(e,"Prod",(function(){return l.Prod})),n.d(e,"Range",(function(){return l.Range})),n.d(e,"Real",(function(){return l.Real})),n.d(e,"Reciprocal",(function(){return l.Reciprocal})),n.d(e,"Relu",(function(){return l.Relu})),n.d(e,"Reshape",(function(){return l.Reshape})),n.d(e,"ResizeNearestNeighbor",(function(){return l.ResizeNearestNeighbor})),n.d(e,"ResizeNearestNeighborGrad",(function(){return l.ResizeNearestNeighborGrad})),n.d(e,"ResizeBilinear",(function(){return l.ResizeBilinear})),n.d(e,"ResizeBilinearGrad",(function(){return l.ResizeBilinearGrad})),n.d(e,"Relu6",(function(){return l.Relu6})),n.d(e,"Reverse",(function(){return l.Reverse})),n.d(e,"Round",(function(){return l.Round})),n.d(e,"Rsqrt",(function(){return l.Rsqrt})),n.d(e,"ScatterNd",(function(){return l.ScatterNd})),n.d(e,"SelectV2",(function(){return l.SelectV2})),n.d(e,"Selu",(function(){return l.Selu})),n.d(e,"Slice",(function(){return l.Slice})),n.d(e,"Sin",(function(){return l.Sin})),n.d(e,"Sinh",(function(){return l.Sinh})),n.d(e,"Sign",(function(){return l.Sign})),n.d(e,"Sigmoid",(function(){return l.Sigmoid})),n.d(e,"Softplus",(function(){return l.Softplus})),n.d(e,"Sqrt",(function(){return l.Sqrt})),n.d(e,"Sum",(function(){return l.Sum})),n.d(e,"SpaceToBatchND",(function(){return l.SpaceToBatchND})),n.d(e,"SplitV",(function(){return l.SplitV})),n.d(e,"Softmax",(function(){return l.Softmax})),n.d(e,"SquaredDifference",(function(){return l.SquaredDifference})),n.d(e,"Square",(function(){return l.Square})),n.d(e,"Sub",(function(){return l.Sub})),n.d(e,"SparseToDense",(function(){return l.SparseToDense})),n.d(e,"StridedSlice",(function(){return l.StridedSlice})),n.d(e,"Tan",(function(){return l.Tan})),n.d(e,"Tanh",(function(){return l.Tanh})),n.d(e,"Tile",(function(){return l.Tile})),n.d(e,"TopK",(function(){return l.TopK})),n.d(e,"Transpose",(function(){return l.Transpose})),n.d(e,"Unique",(function(){return l.Unique})),n.d(e,"Unpack",(function(){return l.Unpack})),n.d(e,"UnsortedSegmentSum",(function(){return l.UnsortedSegmentSum})),n.d(e,"ZerosLike",(function(){return l.ZerosLike})),n.d(e,"Step",(function(){return l.Step})),n.d(e,"FromPixels",(function(){return l.FromPixels})),n.d(e,"RotateWithOffset",(function(){return l.RotateWithOffset})),n.d(e,"_FusedMatMul",(function(){return l._FusedMatMul})),n.d(e,"FusedConv2D",(function(){return l.FusedConv2D})),n.d(e,"FusedDepthwiseConv2D",(function(){return l.FusedDepthwiseConv2D})),n.d(e,"CallbackList",(function(){return Fe})),n.d(e,"CustomCallback",(function(){return $e})),n.d(e,"History",(function(){return Le})),n.d(e,"Callback",(function(){return Wa})),n.d(e,"callbacks",(function(){return Qa})),n.d(e,"EarlyStopping",(function(){return Ka})),n.d(e,"InputSpec",(function(){return ke})),n.d(e,"SymbolicTensor",(function(){return Te})),n.d(e,"LayersModel",(function(){return Yn})),n.d(e,"input",(function(){return sr})),n.d(e,"loadLayersModel",(function(){return ir})),n.d(e,"model",(function(){return nr})),n.d(e,"registerCallbackConstructor",(function(){return ar})),n.d(e,"sequential",(function(){return rr})),n.d(e,"RNN",(function(){return ii})),n.d(e,"Sequential",(function(){return er})),n.d(e,"LayerVariable",(function(){return _e})),n.d(e,"version_layers",(function(){return On})),n.d(e,"constraints",(function(){return r})),n.d(e,"initializers",(function(){return i})),n.d(e,"layers",(function(){return s})),n.d(e,"metrics",(function(){return a})),n.d(e,"models",(function(){return o})),n.d(e,"regularizers",(function(){return u})),n.d(e,"GraphModel",(function(){return Vc})),n.d(e,"loadGraphModel",(function(){return Uc})),n.d(e,"deregisterOp",(function(){return Za.a})),n.d(e,"registerOp",(function(){return Za.c})),n.d(e,"version_converter",(function(){return Wc})),n.d(e,"data",(function(){return c})),n.d(e,"version",(function(){return wp}));var r={};n.r(r),n.d(r,"maxNorm",(function(){return W})),n.d(r,"unitNorm",(function(){return G})),n.d(r,"nonNeg",(function(){return H})),n.d(r,"minMaxNorm",(function(){return K}));var i={};n.r(i),n.d(i,"zeros",(function(){return Jt})),n.d(i,"ones",(function(){return Zt})),n.d(i,"constant",(function(){return te})),n.d(i,"randomUniform",(function(){return ee})),n.d(i,"randomNormal",(function(){return ne})),n.d(i,"truncatedNormal",(function(){return re})),n.d(i,"identity",(function(){return ie})),n.d(i,"varianceScaling",(function(){return se})),n.d(i,"glorotUniform",(function(){return ae})),n.d(i,"glorotNormal",(function(){return oe})),n.d(i,"heNormal",(function(){return ue})),n.d(i,"heUniform",(function(){return ce})),n.d(i,"leCunNormal",(function(){return le})),n.d(i,"leCunUniform",(function(){return he})),n.d(i,"orthogonal",(function(){return de}));var s={};n.r(s),n.d(s,"inputLayer",(function(){return hs})),n.d(s,"elu",(function(){return ds})),n.d(s,"reLU",(function(){return ps})),n.d(s,"leakyReLU",(function(){return fs})),n.d(s,"prelu",(function(){return ms})),n.d(s,"softmax",(function(){return gs})),n.d(s,"thresholdedReLU",(function(){return bs})),n.d(s,"conv1d",(function(){return ys})),n.d(s,"conv2d",(function(){return vs})),n.d(s,"conv2dTranspose",(function(){return ws})),n.d(s,"conv3d",(function(){return xs})),n.d(s,"separableConv2d",(function(){return _s})),n.d(s,"cropping2D",(function(){return Os})),n.d(s,"upSampling2d",(function(){return Ss})),n.d(s,"depthwiseConv2d",(function(){return ks})),n.d(s,"activation",(function(){return Ts})),n.d(s,"dense",(function(){return Cs})),n.d(s,"dropout",(function(){return As})),n.d(s,"spatialDropout1d",(function(){return Ns})),n.d(s,"flatten",(function(){return Is})),n.d(s,"repeatVector",(function(){return Es})),n.d(s,"reshape",(function(){return js})),n.d(s,"permute",(function(){return Ms})),n.d(s,"embedding",(function(){return Ds})),n.d(s,"add",(function(){return Rs})),n.d(s,"average",(function(){return Ps})),n.d(s,"concatenate",(function(){return Fs})),n.d(s,"maximum",(function(){return zs})),n.d(s,"minimum",(function(){return Ls})),n.d(s,"multiply",(function(){return $s})),n.d(s,"dot",(function(){return Bs})),n.d(s,"batchNormalization",(function(){return qs})),n.d(s,"layerNormalization",(function(){return Vs})),n.d(s,"zeroPadding2d",(function(){return Us})),n.d(s,"averagePooling1d",(function(){return Ws})),n.d(s,"avgPool1d",(function(){return Gs})),n.d(s,"avgPooling1d",(function(){return Hs})),n.d(s,"averagePooling2d",(function(){return Ks})),n.d(s,"avgPool2d",(function(){return Qs})),n.d(s,"avgPooling2d",(function(){return Xs})),n.d(s,"averagePooling3d",(function(){return Ys})),n.d(s,"avgPool3d",(function(){return Js})),n.d(s,"avgPooling3d",(function(){return Zs})),n.d(s,"globalAveragePooling1d",(function(){return ta})),n.d(s,"globalAveragePooling2d",(function(){return ea})),n.d(s,"globalMaxPooling1d",(function(){return na})),n.d(s,"globalMaxPooling2d",(function(){return ra})),n.d(s,"maxPooling1d",(function(){return ia})),n.d(s,"maxPooling2d",(function(){return sa})),n.d(s,"maxPooling3d",(function(){return aa})),n.d(s,"gru",(function(){return oa})),n.d(s,"gruCell",(function(){return ua})),n.d(s,"lstm",(function(){return ca})),n.d(s,"lstmCell",(function(){return la})),n.d(s,"simpleRNN",(function(){return ha})),n.d(s,"simpleRNNCell",(function(){return da})),n.d(s,"convLstm2d",(function(){return pa})),n.d(s,"convLstm2dCell",(function(){return fa})),n.d(s,"rnn",(function(){return ma})),n.d(s,"stackedRNNCells",(function(){return ga})),n.d(s,"bidirectional",(function(){return ba})),n.d(s,"timeDistributed",(function(){return ya})),n.d(s,"globalMaxPool1d",(function(){return va})),n.d(s,"globalMaxPool2d",(function(){return wa})),n.d(s,"maxPool1d",(function(){return xa})),n.d(s,"maxPool2d",(function(){return _a})),n.d(s,"Layer",(function(){return Ie})),n.d(s,"RNN",(function(){return ii})),n.d(s,"RNNCell",(function(){return si})),n.d(s,"input",(function(){return sr})),n.d(s,"gaussianNoise",(function(){return Oa})),n.d(s,"gaussianDropout",(function(){return Sa})),n.d(s,"alphaDropout",(function(){return ka})),n.d(s,"masking",(function(){return Ta}));var a={};n.r(a),n.d(a,"binaryAccuracy",(function(){return Ca})),n.d(a,"binaryCrossentropy",(function(){return Aa})),n.d(a,"sparseCategoricalAccuracy",(function(){return Na})),n.d(a,"categoricalAccuracy",(function(){return Ia})),n.d(a,"categoricalCrossentropy",(function(){return Ea})),n.d(a,"precision",(function(){return ja})),n.d(a,"recall",(function(){return Ma})),n.d(a,"cosineProximity",(function(){return Da})),n.d(a,"meanAbsoluteError",(function(){return Ra})),n.d(a,"meanAbsolutePercentageError",(function(){return Pa})),n.d(a,"MAPE",(function(){return Fa})),n.d(a,"mape",(function(){return za})),n.d(a,"meanSquaredError",(function(){return La})),n.d(a,"MSE",(function(){return $a})),n.d(a,"mse",(function(){return Ba}));var o={};n.r(o),n.d(o,"modelFromJSON",(function(){return Zn}));var u={};n.r(u),n.d(u,"l1l2",(function(){return qa})),n.d(u,"l1",(function(){return Va})),n.d(u,"l2",(function(){return Ua}));var c={};n.r(c),n.d(c,"array",(function(){return Yc})),n.d(c,"Dataset",(function(){return Qc})),n.d(c,"zip",(function(){return Jc})),n.d(c,"CSVDataset",(function(){return al})),n.d(c,"TextLineDataset",(function(){return tl})),n.d(c,"csv",(function(){return gl})),n.d(c,"func",(function(){return bl})),n.d(c,"generator",(function(){return yl})),n.d(c,"microphone",(function(){return wl})),n.d(c,"webcam",(function(){return vl})),n.d(c,"FileDataSource",(function(){return fl})),n.d(c,"URLDataSource",(function(){return ml})),n.d(c,"version_data",(function(){return xl}));var l=n(0);
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */let h;function d(){return null==h&&(h=Object(l.backend)().epsilon()),h}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
class p extends Error{constructor(t){super(t),Object.setPrototypeOf(this,p.prototype)}}class f extends Error{constructor(t){super(t),Object.setPrototypeOf(this,f.prototype)}}class m extends Error{constructor(t){super(t),Object.setPrototypeOf(this,m.prototype)}}class g extends Error{constructor(t){super(t),Object.setPrototypeOf(this,g.prototype)}}class b extends Error{constructor(t){super(t),Object.setPrototypeOf(this,b.prototype)}}Error;
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function y(t,e){if(Array.isArray(t)){let n=[];for(let r=0;r<e;r++)n=n.concat(t);return n}{const n=new Array(e);return n.fill(t),n}}function v(t,e){if(!t)throw new b(e)}function w(t,e){let n=0;for(const r of t)r===e&&n++;return n}function x(t){return 1===t.length?t[0]:t}function _(t){return Array.isArray(t)?t:[t]}function O(t){const e=t.replace(/(.)([A-Z][a-z0-9]+)/g,"$1_$2").replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase();return"_"!==e[0]?e:"private"+e}function S(t){return t.length<=1||-1===t.indexOf("_")?t:t.replace(/[_]+(\w|$)/g,(t,e)=>e.toUpperCase())}let k={};function T(t){if(null==t)return null;const e={};return e.className=t.getClassName(),e.config=t.getConfig(),e}function C(t,e={},n={},r="object",i=!1){if("string"==typeof t){const i=t;let s;if(i in n)s=n[i];else if(i in k)s=k[i];else if(s=e[i],null==s)throw new m(`Unknown ${r}: ${t}. This may be due to one of the following reasons:\n1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return s}{const s=t;if(null==s.className||null==s.config)throw new m(r+": Improper config format: "+JSON.stringify(s)+".\n'className' and 'config' must set.");const a=s.className;let o,u;if(a in n?[o,u]=n[a]:a in k?[o,u]=k.className:a in e&&([o,u]=e[a]),null==o)throw new m(`Unknown ${r}: ${a}. This may be due to one of the following reasons:\n1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(null!=u){const t={};for(const e of Object.keys(k))t[e]=k[e];for(const e of Object.keys(n))t[e]=n[e];s.config.customObjects=t;const e=Object.assign({},k);for(const t of Object.keys(n))k[t]=n[t];!function t(e){if(null!=e&&"object"==typeof e)if(Array.isArray(e))e.forEach(e=>t(e));else{const n=Object.keys(e);for(const r of n){const n=e[r];null!=n&&"object"==typeof n&&(Array.isArray(n)||"ndarray"!==n.type||"number"!=typeof n.value?t(n):e[r]=n.value)}}}(s.config);const r=u(o,s.config,n,i);return k=Object.assign({},e),r}{const t=Object.assign({},k);for(const t of Object.keys(n))k[t]=n[t];const e=new o(s.config);return k=Object.assign({},t),e}}}function A(t,e){return-1*function(t,e){return t<e?-1:t>e?1:0}(t,e)}function N(t){if(null==t)return t;const e=[];for(const n of t)-1===e.indexOf(n)&&e.push(n);return e}function I(t){if(null==t)throw new m("Invalid value in obj: "+JSON.stringify(t));for(const e in t)if(t.hasOwnProperty(e))return!1;return!0}function E(t,e,n){if(null!=n&&t.indexOf(n)<0)throw new m(`${n} is not a valid ${e}.  Valid values are ${t} or null/undefined.`)}function j(t,e,n=0,r=1/0){return v(n>=0),v(r>=n),Array.isArray(t)&&t.length>=n&&t.length<=r&&t.every(t=>typeof t===e)}function M(t,e){Array.isArray(t)?(l.util.assert(t.length>0,()=>e+" is unexpectedly an empty array."),t.forEach((t,n)=>M(t,`element ${n+1} of ${e}`))):l.util.assert(Number.isInteger(t)&&t>0,()=>`Expected ${e} to be a positive integer, but got `+function t(e){return null===e?"null":Array.isArray(e)?"["+e.map(e=>t(e)).join(",")+"]":"string"==typeof e?`"${e}"`:""+e}(t)+".")}function D(t){return"relu"===t?"relu":"linear"===t?"linear":"elu"===t?"elu":null}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
function R(t,e){return Object(l.tidy)(()=>l.sqrt(l.sum(l.mul(t,t),e,!0)))}class P extends l.serialization.Serializable{getConfig(){return{}}}class F extends P{constructor(t){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=null!=t.maxValue?t.maxValue:this.defaultMaxValue,this.axis=null!=t.axis?t.axis:this.defaultAxis}apply(t){return Object(l.tidy)(()=>{const e=R(t,this.axis),n=l.clipByValue(e,0,this.maxValue);return l.mul(t,l.div(n,l.add(d(),e)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}F.className="MaxNorm",l.serialization.registerClass(F);class z extends P{constructor(t){super(),this.defaultAxis=0,this.axis=null!=t.axis?t.axis:this.defaultAxis}apply(t){return Object(l.tidy)(()=>l.div(t,l.add(d(),R(t,this.axis))))}getConfig(){return{axis:this.axis}}}z.className="UnitNorm",l.serialization.registerClass(z);class L extends P{apply(t){return l.relu(t)}}L.className="NonNeg",l.serialization.registerClass(L);class $ extends P{constructor(t){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=null!=t.minValue?t.minValue:this.defaultMinValue,this.maxValue=null!=t.maxValue?t.maxValue:this.defaultMaxValue,this.rate=null!=t.rate?t.rate:this.defaultRate,this.axis=null!=t.axis?t.axis:this.defaultAxis}apply(t){return Object(l.tidy)(()=>{const e=R(t,this.axis),n=l.add(l.mul(this.rate,l.clipByValue(e,this.minValue,this.maxValue)),l.mul(1-this.rate,e));return l.mul(t,l.div(n,l.add(d(),e)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}$.className="MinMaxNorm",l.serialization.registerClass($);const B={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function q(t){return T(t)}function V(t,e={}){return C(t,l.serialization.SerializationMap.getMap().classNameMap,e,"constraint")}function U(t){if(null==t)return null;if("string"==typeof t){return V({className:t in B?B[t]:t,config:{}})}return t instanceof P?t:V(t)}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function W(t){return new F(t)}function G(t){return new z(t)}function H(){return new L}function K(t){return new $(t)}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */const Q=["channelsFirst","channelsLast"],X=["valid","same","causal"],Y=["max","avg"],J=["sum","mul","concat","ave"],Z=new Map;function tt(t){E(Q,"DataFormat",t)}function et(t){E(X,"PaddingMode",t)}function nt(t){E(Y,"PoolMode",t)}const rt=[];function it(t,e){rt.push(t);try{const t=e();return rt.pop(),t}catch(t){throw rt.pop(),t}}function st(t){if(!ut(t))throw new Error("Not a valid tensor name: '"+t+"'");return(0===rt.length?"":rt.join("/")+"/")+t}function at(t){if(!ut(t))throw new Error("Not a valid tensor name: '"+t+"'");Z.has(t)||Z.set(t,0);const e=Z.get(t);if(Z.set(t,Z.get(t)+1),e>0){const n=`${t}_${e}`;return Z.set(n,1),n}return t}const ot=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function ut(t){return!!t.match(ot)}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function ct(t,e,n){null==e&&(e=0),null==n&&(n=t.length);let r=1;for(let i=e;i<n;++i)r*=t[i];return r}function lt(t){return t=Array.isArray(t)?new Float32Array(t):t,Object(l.tensor1d)(t)}function ht(t){return l.min(lt(t)).dataSync()[0]}function dt(t){return l.max(lt(t)).dataSync()[0]}function pt(t,e){if(e<t)throw new m(`end (${e}) < begin (${t}) is forbidden.`);const n=[];for(let r=t;r<e;++r)n.push(r);return n}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function ft(t,e){return t.asType(e)}function mt(t,e=-1){const n=t.shape.slice();return e<0&&(e=n.length+e+1),n.splice(e,0,1),t.reshape(n)}function gt(t,e,n){return Object(l.tidy)(()=>{switch(t.rank){case 1:return l.slice1d(t,e,n);case 2:return l.slice2d(t,[e,0],[n,t.shape[1]]);case 3:return l.slice3d(t,[e,0,0],[n,t.shape[1],t.shape[2]]);case 4:return l.slice4d(t,[e,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3]]);case 5:return l.slice(t,[e,0,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3],t.shape[4]]);case 6:return l.slice(t,[e,0,0,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3],t.shape[4],t.shape[5]]);default:throw new m("sliceAlongFirstAxis() received an unsupported tensor rank: "+t.rank)}})}function bt(t,e,n){return Object(l.tidy)(()=>{switch(t.rank){case 1:return l.slice1d(t,e,n);case 2:return l.slice2d(t,[0,e],[t.shape[0],n]);case 3:return l.slice3d(t,[0,0,e],[t.shape[0],t.shape[1],n]);case 4:return l.slice4d(t,[0,0,0,e],[t.shape[0],t.shape[1],t.shape[2],n]);default:throw new m("sliceAlongLastAxis() received an unsupported tensor rank: "+t.rank)}})}function yt(t,e,n,r){return Object(l.tidy)(()=>{switch(t.rank){case 1:return l.slice1d(t,e,n);case 2:switch(r){case 1:return gt(t,e,n);case 2:return bt(t,e,n);default:throw new m("The axis is not within the rank of the tensor "+r)}case 3:switch(r){case 1:return gt(t,e,n);case 2:return l.slice3d(t,[0,e,0],[t.shape[0],n,t.shape[2]]);case 3:return bt(t,e,n);default:throw new m("The axis is not within the rank of the tensor "+r)}case 4:switch(r){case 1:return gt(t,e,n);case 2:return l.slice4d(t,[0,e,0,0],[t.shape[0],n,t.shape[2],t.shape[3]]);case 3:return l.slice4d(t,[0,0,e,0],[t.shape[0],t.shape[1],n,t.shape[3]]);case 4:return bt(t,e,n);default:throw new m("The axis is not within the rank of the tensor "+r)}default:throw new m("sliceAlongLastAxis() received an unsupported tensor rank: "+t.rank)}})}function vt(t,e=-1){let n;return e<0&&(n=t[0].rank,e=0!==n?n:0),e===t[0].rank&&(e=-1),l.concat(t,e)}function wt(t,e){switch(t.rank){case 1:return l.concat1d([t,e]);case 2:return l.concat2d([t,e],0);case 3:return l.concat3d([t,e],0);case 4:return l.concat4d([t,e],0);default:throw new m("concatAlongFirstAxis() received an unsupported tensor rank: "+t.rank)}}function xt(t,e){if(Array.isArray(e)||(e=[e]),t.rank!==e.length)throw new m(`The length of input n (${e.length}) does not match the number of dimensions in input x (${t.rank})`);return l.tile(t,e)}function _t(t,e=0,n=1,r,i){return l.randomNormal(t,e,n,r,i)}function Ot(t,e,n,r){if(t.rank<2||e.rank<2)throw new g(`dot requires both inputs to be rank >= 2 but got x shape = ${t.shape} and y shape = ${e.shape}`);if(e.rank>=3){if(t.shape.slice(-1)[0]!==e.shape.slice(-2)[0])throw new g(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${t.shape} and  y shape = `+e.shape)}if(2===t.rank&&2===e.rank){const i=!1,s=!1;return l.fused.matMul({a:t,b:e,transposeA:i,transposeB:s,bias:r?Tt(t.rank,r,"channelsLast"):null,activation:n})}{const i=t.shape.slice(),s=i.pop();t=t.reshape([-1,s]);const a=e.shape.slice(),o=a.pop(),u=a.pop(),c=[...a,o],h=Array.from({length:e.rank},(t,n)=>0===n?e.rank-2:n<=e.rank-2?n-1:n);e=e.transpose(h).reshape([u,-1]);const d=[...i,...c],p=!1,f=!1;return l.fused.matMul({a:t,b:e,transposeA:p,transposeB:f,bias:r?Tt(t.rank,r,"channelsLast"):null,activation:n}).reshape(d)}}function St(t,e,n){return Object(l.tidy)(()=>(e=Array.isArray(e)?Object(l.tensor1d)(e,"int32"):e.toInt(),l.gather(t,e,n)))}function kt(t){return l.mul(t,t)}function Tt(t,e,n){const r=e.shape;if(1!==e.rank&&e.rank!==t)throw new m("Unexpected bias dimensions: "+e.rank+"; expected it to be 1 or "+t);if(5===t){if("channelsFirst"===n)return 1===r.length?e.reshape([1,r[0],1,1,1]):e.reshape([1,r[3],r[0],r[1],r[2]]);if("channelsLast"===n)return 1===r.length?e.reshape([1,1,1,1,r[0]]):e.reshape([1].concat(r))}else if(4===t){if("channelsFirst"===n)return 1===r.length?e.reshape([1,r[0],1,1]):e.reshape([1,r[2],r[0],r[1]]);if("channelsLast"===n)return 1===r.length?e.reshape([1,1,1,r[0]]):e.reshape([1].concat(r))}else if(3===t){if("channelsFirst"===n)return 1===r.length?e.reshape([1,r[0],1]):e.reshape([1,r[1],r[0]]);if("channelsLast"===n)return 1===r.length?e.reshape([1,1,r[0]]):e.reshape([1].concat(r))}else if(t<3)return e;throw new m("Unsupported input rank by biasAdd: "+e.rank)}function Ct(t,e,n){return Object(l.tidy)(()=>(null==n&&(n="channelsLast"),tt(n),t.add(Tt(t.rank,e,n))))}function At(t,e,n,r){return Object(l.tidy)(()=>l.dropout(t,e,n,r))}function Nt(t,e,n=!1){return n?t():e()}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */const It=["fanIn","fanOut","fanAvg"],Et=["normal","uniform","truncatedNormal"];class jt extends l.serialization.Serializable{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}}class Mt extends jt{apply(t,e){return Object(l.zeros)(t,e)}}Mt.className="Zeros",l.serialization.registerClass(Mt);class Dt extends jt{apply(t,e){return Object(l.ones)(t,e)}}Dt.className="Ones",l.serialization.registerClass(Dt);class Rt extends jt{constructor(t){if(super(),"object"!=typeof t)throw new m("Expected argument of type ConstantConfig but got "+t);if(void 0===t.value)throw new m("config must have value set but got "+t);this.value=t.value}apply(t,e){return Object(l.tidy)(()=>Object(l.mul)(Object(l.scalar)(this.value),Object(l.ones)(t,e)))}getConfig(){return{value:this.value}}}Rt.className="Constant",l.serialization.registerClass(Rt);class Pt extends jt{constructor(t){super(),this.DEFAULT_MINVAL=-.05,this.DEFAULT_MAXVAL=.05,this.minval=t.minval||this.DEFAULT_MINVAL,this.maxval=t.maxval||this.DEFAULT_MAXVAL,this.seed=t.seed}apply(t,e){return Object(l.randomUniform)(t,this.minval,this.maxval,e)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}Pt.className="RandomUniform",l.serialization.registerClass(Pt);class Ft extends jt{constructor(t){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=t.mean||this.DEFAULT_MEAN,this.stddev=t.stddev||this.DEFAULT_STDDEV,this.seed=t.seed}apply(t,e){if("float32"!==(e=e||"float32")&&"int32"!==e)throw new g(`randomNormal does not support dType ${e}.`);return _t(t,this.mean,this.stddev,e,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}Ft.className="RandomNormal",l.serialization.registerClass(Ft);class zt extends jt{constructor(t){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=t.mean||this.DEFAULT_MEAN,this.stddev=t.stddev||this.DEFAULT_STDDEV,this.seed=t.seed}apply(t,e){if("float32"!==(e=e||"float32")&&"int32"!==e)throw new g(`truncatedNormal does not support dType ${e}.`);return Object(l.truncatedNormal)(t,this.mean,this.stddev,e,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}zt.className="TruncatedNormal",l.serialization.registerClass(zt);class Lt extends jt{constructor(t){super(),this.gain=null!=t.gain?t.gain:1}apply(t,e){return Object(l.tidy)(()=>{if(2!==t.length||t[0]!==t[1])throw new m("Identity matrix initializer can only be used for 2D square matrices.");return Object(l.mul)(this.gain,Object(l.eye)(t[0]))})}getConfig(){return{gain:this.gain}}}Lt.className="Identity",l.serialization.registerClass(Lt);class $t extends jt{constructor(t){if(super(),t.scale<0)throw new m("scale must be a positive float. Got: "+t.scale);
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
var e;this.scale=null==t.scale?1:t.scale,this.mode=null==t.mode?"fanIn":t.mode,e=this.mode,E(It,"FanMode",e),this.distribution=null==t.distribution?"normal":t.distribution,function(t){E(Et,"Distribution",t)}(this.distribution),this.seed=t.seed}apply(t,e){const n=function(t,e="channelsLast"){let n,r;if(tt(e),2===t.length)n=t[0],r=t[1];else if(-1!==[3,4,5].indexOf(t.length)){if("channelsFirst"===e){const e=ct(t,2);n=t[1]*e,r=t[0]*e}else if("channelsLast"===e){const e=ct(t,0,t.length-2);n=t[t.length-2]*e,r=t[t.length-1]*e}}else{const e=ct(t);n=Math.sqrt(e),r=Math.sqrt(e)}return[n,r]}(t),r=n[0],i=n[1];let s=this.scale;if("fanIn"===this.mode?s/=Math.max(1,r):"fanOut"===this.mode?s/=Math.max(1,i):s/=Math.max(1,(r+i)/2),"normal"===this.distribution){const n=Math.sqrt(s);if("float32"!==(e=e||"float32")&&"int32"!==e)throw new g(`${this.getClassName()} does not support dType ${e}.`);return Object(l.truncatedNormal)(t,0,n,e,this.seed)}{const n=Math.sqrt(3*s);return Object(l.randomUniform)(t,-n,n,e)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}$t.className="VarianceScaling",l.serialization.registerClass($t);class Bt extends $t{constructor(t){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:null==t?null:t.seed})}getClassName(){return $t.className}}Bt.className="GlorotUniform",l.serialization.registerClass(Bt);class qt extends $t{constructor(t){super({scale:1,mode:"fanAvg",distribution:"normal",seed:null==t?null:t.seed})}getClassName(){return $t.className}}qt.className="GlorotNormal",l.serialization.registerClass(qt);class Vt extends $t{constructor(t){super({scale:2,mode:"fanIn",distribution:"normal",seed:null==t?null:t.seed})}getClassName(){return $t.className}}Vt.className="HeNormal",l.serialization.registerClass(Vt);class Ut extends $t{constructor(t){super({scale:2,mode:"fanIn",distribution:"uniform",seed:null==t?null:t.seed})}getClassName(){return $t.className}}Ut.className="HeUniform",l.serialization.registerClass(Ut);class Wt extends $t{constructor(t){super({scale:1,mode:"fanIn",distribution:"normal",seed:null==t?null:t.seed})}getClassName(){return $t.className}}Wt.className="LeCunNormal",l.serialization.registerClass(Wt);class Gt extends $t{constructor(t){super({scale:1,mode:"fanIn",distribution:"uniform",seed:null==t?null:t.seed})}getClassName(){return $t.className}}Gt.className="LeCunNormal",l.serialization.registerClass(Gt);class Ht extends jt{constructor(t){if(super(),this.DEFAULT_GAIN=1,this.gain=null==t.gain?this.DEFAULT_GAIN:t.gain,this.seed=t.seed,null!=this.seed)throw new g("Random seed is not implemented for Orthogonal Initializer yet.")}apply(t,e){return Object(l.tidy)(()=>{if(t.length<2)throw new g("Shape must be at least 2D.");t[0]*t[1]>2e3&&console.warn(`Orthogonal initializer is being called on a matrix with more than 2000 (${t[0]*t[1]}) elements: Slowness may result.`);const e=_t(t[0]>t[1]?[t[1],t[0]]:t,0,1,"float32");let n=l.linalg.gramSchmidt(e);return t[0]>t[1]&&(n=n.transpose()),Object(l.mul)(this.gain,n)})}getConfig(){return{gain:this.gain,seed:this.seed}}}Ht.className="Orthogonal",l.serialization.registerClass(Ht);const Kt={constant:"Constant",glorotNormal:"GlorotNormal",glorotUniform:"GlorotUniform",heNormal:"HeNormal",heUniform:"HeUniform",identity:"Identity",leCunNormal:"LeCunNormal",leCunUniform:"LeCunUniform",ones:"Ones",orthogonal:"Orthogonal",randomNormal:"RandomNormal",randomUniform:"RandomUniform",truncatedNormal:"TruncatedNormal",varianceScaling:"VarianceScaling",zeros:"Zeros"};function Qt(t,e={}){return C(t,l.serialization.SerializationMap.getMap().classNameMap,e,"initializer")}function Xt(t){return T(t)}function Yt(t){if("string"==typeof t){const e=t in Kt?Kt[t]:t;if("GlorotNormal"===e)return new qt;if("GlorotUniform"===e)return new Bt;if("HeNormal"===e)return new Vt;if("HeUniform"===e)return new Ut;if("LeCunNormal"===e)return new Wt;if("LeCunUniform"===e)return new Gt;{const t={};return t.className=e,t.config={},Qt(t)}}return t instanceof jt?t:Qt(t)}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function Jt(){return new Mt}function Zt(){return new Dt}function te(t){return new Rt(t)}function ee(t){return new Pt(t)}function ne(t){return new Ft(t)}function re(t){return new zt(t)}function ie(t){return new Lt(t)}function se(t){return new $t(t)}function ae(t){return new Bt(t)}function oe(t){return new qt(t)}function ue(t){return new Vt(t)}function ce(t){return new Ut(t)}function le(t){return new Wt(t)}function he(t){return new Gt(t)}function de(t){return new Ht(t)}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */let pe=0;function fe(){return pe++}const me={};function ge(t=""){return t in me||(me[t]=0),me[t]+=1,t+me[t].toString()}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function be(t){return Array.isArray(t)&&Array.isArray(t[0])}function ye(t){return 0===t.length?[]:Array.isArray(t[0])?t:[t]}function ve(t){let e;if(Array.isArray(t)){if(1!==t.length)throw new m("Expected Tensor length to be 1; got "+t.length);e=t[0]}else e=t;return e}function we(t){if(Array.isArray(t)&&Array.isArray(t[0])){if(1===t.length)return(t=t)[0];throw new m("Expected exactly 1 Shape; got "+t.length)}return t}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function xe(t){let e=0;for(const n of t)0===n.shape.length?e+=1:e+=n.shape.reduce((t,e)=>t*e);return e}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */class _e{constructor(t,e="float32",n="Variable",r=!0,i=null){this.dtype=null==e?"float32":e,this.shape=t.shape,this.id=fe(),n=null==n?"Variable":n,this.originalName=st(n),this.name=at(this.originalName),this.trainable_=r,this.constraint=i,this.val=l.variable(t,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(t){return this.assertNotDisposed(),function(t,e){if(t.shape.toString()!==e.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(t.shape)+" vs. "+JSON.stringify(e.shape))}(this.val,t),this.val.id!==t.id&&(this.val.assign(t),null!=this.constraint&&this.val.assign(this.constraint.apply(this.val))),this}dispose(){this.assertNotDisposed(),this.val.dispose()}assertNotDisposed(){if(this.val.isDisposed)throw new Error(`LayersVariable ${this.name} is already disposed.`)}get trainable(){return this.trainable_}set trainable(t){this.trainable_=t,this.val.trainable=t}}function Oe(t){return t.map(t=>t.read())}function Se(t){t.forEach(t=>{t[0].write(t[1])})}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
class ke{constructor(t){this.dtype=t.dtype,this.shape=t.shape,null!=t.shape?this.ndim=t.shape.length:this.ndim=t.ndim,this.maxNDim=t.maxNDim,this.minNDim=t.minNDim,this.axes=t.axes||{}}}class Te{constructor(t,e,n,r,i,s,a){this.dtype=t,this.shape=e,this.sourceLayer=n,this.inputs=r,this.callArgs=i,this.outputTensorIndex=a,this.id=fe(),null!=s&&(this.originalName=st(s),this.name=at(this.originalName)),this.rank=e.length}}let Ce=0;class Ae{constructor(t,e){this.callArgs=e,this.id=Ce++,this.outboundLayer=t.outboundLayer,this.inboundLayers=t.inboundLayers,this.nodeIndices=t.nodeIndices,this.tensorIndices=t.tensorIndices,this.inputTensors=t.inputTensors,this.outputTensors=t.outputTensors,this.inputMasks=t.inputMasks,this.outputMasks=t.outputMasks,this.inputShapes=t.inputShapes,this.outputShapes=t.outputShapes;for(const e of t.inboundLayers)null!=e&&e.outboundNodes.push(this);t.outboundLayer.inboundNodes.push(this)}getConfig(){const t=[];for(const e of this.inboundLayers)null!=e?t.push(e.name):t.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:t,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let Ne=0;class Ie extends l.serialization.Serializable{constructor(t={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=Ne++,this.activityRegularizer=null,this.inputSpec=null,this.supportsMasking=!1,this._trainableWeights=[],this._nonTrainableWeights=[],this._losses=[],this._updates=[],this._built=!1,this.inboundNodes=[],this.outboundNodes=[];let e=t.name;if(!e){const t=this.getClassName();e=O(t)+"_"+ge(t)}if(this.name=e,this.trainable_=null==t.trainable||t.trainable,null!=t.inputShape||null!=t.batchInputShape){let e;if(null!=t.batchInputShape)e=t.batchInputShape;else if(null!=t.inputShape){let n=null;null!=t.batchSize&&(n=t.batchSize),e=[n].concat(t.inputShape)}this.batchInputShape=e;let n=t.dtype;null==n&&(n=t.inputDType),null==n&&(n="float32"),this.dtype=n}null!=t.weights?this.initialWeights=t.weights:this.initialWeights=null,this._refCount=null,this.fastWeightInitDuringBuild=!1}static nodeKey(t,e){return t.name+"_ib-"+e.toString()}getNodeAtIndex(t,e){if(0===this.inboundNodes.length)throw new f(`The layer has never been called and thus has no defined ${e}.`);if(this.inboundNodes.length<=t)throw new m(`Asked to get ${e} at node ${t}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[t]}getInputAt(t){return x(this.getNodeAtIndex(t,"input").inputTensors)}getOutputAt(t){return x(this.getNodeAtIndex(t,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new p("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use `getInputAt(nodeIndex)` instead.');if(0===this.inboundNodes.length)throw new p("Layer "+this.name+" is not connected, no input to return.");return x(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(0===this.inboundNodes.length)throw new p("Layer "+this.name+" has no inbound nodes.");if(this.inboundNodes.length>1)throw new p("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `getOutputAt(nodeIndex)` instead.');return x(this.getNodeAtIndex(0,"output").outputTensors)}get losses(){return this._losses}calculateLosses(){return this.losses.map(t=>t())}get updates(){return this._updates}get built(){return this._built}set built(t){this._built=t}get trainable(){return this.trainable_}set trainable(t){this._trainableWeights.forEach(e=>e.trainable=t),this.trainable_=t}get trainableWeights(){return this.trainable_?this._trainableWeights.filter(t=>t.trainable):[]}set trainableWeights(t){this._trainableWeights=t}get nonTrainableWeights(){return this.trainable?this._trainableWeights.filter(t=>!t.trainable).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)}set nonTrainableWeights(t){this._nonTrainableWeights=t}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}get stateful(){return this._stateful}resetStates(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")}assertInputCompatibility(t){if(t=_(t),null==this.inputSpec||0===this.inputSpec.length)return;const e=_(this.inputSpec);if(t.length!==e.length)throw new m(`Layer ${this.name} expects ${e.length} inputs, but it received ${t.length} input tensors. Input received: `+t);for(let n=0;n<t.length;n++){const r=t[n],i=e[n];if(null==i)continue;const s=r.rank;if(null!=i.ndim&&s!==i.ndim)throw new m(`Input ${n} is incompatible with layer ${this.name}: expected ndim=${i.ndim}, found ndim=${s}`);if(null!=i.maxNDim&&s>i.maxNDim)throw new m(`Input ${n} is incompatible with layer ${this.name}: expected max_ndim=${i.maxNDim}, found ndim=${s}`);if(null!=i.minNDim&&s<i.minNDim)throw new m(`Input ${n} is incompatible with layer ${this.name}: expected min_ndim=${i.minNDim}, found ndim=${s}.`);if(null!=i.dtype&&r.dtype!==i.dtype)throw new m(`Input ${n} is incompatible with layer ${this.name} : expected dtype=${i.dtype}, found dtype=${r.dtype}.`);if(i.axes){const t=r.shape;for(const e in i.axes){const r=Number(e),s=i.axes[e],a=r>=0?t[r]:t[t.length+r];if(null!=s&&-1===[s,null].indexOf(a))throw new m(`Input ${n} is incompatible with layer ${this.name}: expected axis ${r} of input shape to have value ${s} but got shape ${t}.`)}}if(null!=i.shape)for(let t=0;t<i.shape.length;++t){const e=i.shape[t],s=r.shape[t];if(null!=e&&null!=s&&e!==s)throw new m(`Input ${n} is incompatible with layer ${this.name}: expected shape=${i.shape}, found shape=${r.shape}.`)}}}call(t,e){return t}invokeCallHook(t,e){null!=this._callHook&&this._callHook(t,e)}setCallHook(t){this._callHook=t}clearCallHook(){this._callHook=null}apply(t,e){e=e||{},this.assertNotDisposed();const n=_(t);let r=!0;for(const t of n)if(!(t instanceof Te)){r=!1;break}let i=!0;for(const t of n)if(t instanceof Te){i=!1;break}if(r===i)throw new m("Arguments to apply() must be all SymbolicTensors or all Tensors");return it(this.name,()=>{if(!this.built){this.assertInputCompatibility(t);const e=[];for(const n of _(t))e.push(n.shape);this.build(x(e)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),null===this._refCount&&i&&(this._refCount=1)}if(this.assertInputCompatibility(t),i){let r=this.call(t,e);const i=_(r),s=[];for(let t of i)-1!==n.indexOf(t)&&(t=t.clone()),s.push(t);if(r=x(s),null!=this.activityRegularizer)throw new g("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return r}{const n=function(t){t=_(t);const e=[];for(const n of t)e.push(n.shape);return x(e)}(t),r=this.computeOutputShape(n);let i;const s="float32";if(this.warnOnIncompatibleInputShape(Array.isArray(t)?n[0]:n),i=null!=r&&r.length>0&&Array.isArray(r[0])?r.map((n,r)=>new Te(s,n,this,_(t),e,this.name,r)):new Te(s,r,this,_(t),e,this.name),this.addInboundNode(t,i,null,null,n,r,e),this._refCount++,null!=this.activityRegularizer)throw new g("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return i}})}warnOnIncompatibleInputShape(t){if(null!=this.batchInputShape)if(t.length!==this.batchInputShape.length)console.warn("The rank of the input tensor provided (shape: "+JSON.stringify(t)+") does not match that of the "+`batchInputShape (${JSON.stringify(this.batchInputShape)}) of the layer `+this.name);else{let e=!1;this.batchInputShape.forEach((n,r)=>{null!=n&&null!=t[r]&&t[r]!==n&&(e=!0)}),e&&console.warn(`The shape of the input tensor (${JSON.stringify(t)}) does not match the expectation of layer ${this.name}: `+JSON.stringify(this.batchInputShape))}}get outputShape(){if(null==this.inboundNodes||0===this.inboundNodes.length)throw new p(`The layer ${this.name} has never been called and thus has no defined output shape.`);const t=[];for(const e of this.inboundNodes){const n=JSON.stringify(e.outputShapes);-1===t.indexOf(n)&&t.push(n)}if(1===t.length){const t=this.inboundNodes[0].outputShapes;return Array.isArray(t)&&Array.isArray(t[0])&&1===t.length?t[0]:t}throw new p(`The layer ${this.name} has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.`)}countParams(){if(!this.built)throw new f(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return xe(this.weights)}build(t){this.built=!0}getWeights(t=!1){return Oe(t?this.trainableWeights:this.weights)}setWeights(t){Object(l.tidy)(()=>{const e=this.weights;if(e.length!==t.length)throw new m(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${t.length}, but the layer was expecting ${e.length} weights. Provided weights: ${t}...`);if(0===e.length)return;const n=[],r=Oe(e);for(let i=0;i<r.length;++i){const s=r[i],a=e[i],o=t[i];if(!l.util.arraysEqual(s.shape,o.shape))throw new m(`Layer weight shape ${s.shape} not compatible with provided weight shape `+o.shape);n.push([a,o])}Se(n)})}addWeight(t,e,n,r,i,s,a){if(-1!==this._addedWeightNames.indexOf(t))throw new m(`Duplicate weight name ${t} for layer ${this.name}`);this._addedWeightNames.push(t),null==n&&(n="float32"),this.fastWeightInitDuringBuild&&(r=Yt("zeros"));const o=r.apply(e,n),u=new _e(o,n,t,s,a);return o.dispose(),null!=i&&this.addLoss(()=>i.apply(u.read())),null==s&&(s=!0),s?this._trainableWeights.push(u):this._nonTrainableWeights.push(u),u}setFastWeightInitDuringBuild(t){this.fastWeightInitDuringBuild=t}addLoss(t){null==t||Array.isArray(t)&&0===t.length||(t=_(t),void 0!==this._losses&&null!==this._losses&&this.losses.push(...t))}computeOutputShape(t){return t}computeMask(t,e){if(!this.supportsMasking){if(null!=e){if(!Array.isArray(e))throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);e.forEach(t=>{if(null!=t)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)})}return null}return e}addInboundNode(t,e,n,r,i,s,a=null){const o=_(t);e=_(e),n=_(n),r=_(r),i=ye(i),s=ye(s);const u=[],c=[],l=[];for(const t of o)u.push(t.sourceLayer),c.push(t.nodeIndex),l.push(t.tensorIndex);new Ae({outboundLayer:this,inboundLayers:u,nodeIndices:c,tensorIndices:l,inputTensors:o,outputTensors:e,inputMasks:n,outputMasks:r,inputShapes:i,outputShapes:s},a);for(let t=0;t<e.length;t++)e[t].sourceLayer=this,e[t].nodeIndex=this.inboundNodes.length-1,e[t].tensorIndex=t}getConfig(){const t={name:this.name,trainable:this.trainable};return null!=this.batchInputShape&&(t.batchInputShape=this.batchInputShape),null!=this.dtype&&(t.dtype=this.dtype),t}disposeWeights(){return this.weights.forEach(t=>t.dispose()),this.weights.length}assertNotDisposed(){if(0===this._refCount)throw new Error(`Layer '${this.name}' is already disposed.`)}dispose(){if(!this.built)throw new Error(`Cannot dispose Layer ${this.name} because it has not been built yet.`);if(null===this._refCount)throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let t=0;return 0==--this._refCount&&(t=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:t}}}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
class Ee extends Ie{constructor(t){if(super({dtype:t.dtype,name:null!=t.name?t.name:ge("input").toString()}),null==t.batchSize&&(t.batchSize=null),null==t.sparse&&(t.sparse=!1),this.trainable=!1,this.built=!0,this.sparse=t.sparse,null!=t.inputShape&&null!=t.batchInputShape)throw new m("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time.");let e=t.batchInputShape;if(null==e){if(null==t.inputShape)throw new m("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");e=[t.batchSize].concat(t.inputShape)}else if(null!=t.batchSize)throw new m("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer.");const n=t.dtype||"float32";this.batchInputShape=e,this.dtype=n,this.inputSpec=[{shape:e}];const r=new Te(this.dtype,this.batchInputShape,this,[],{},this.name);r.nodeIndex=0,r.tensorIndex=0,new Ae({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[r],outputTensors:[r],inputMasks:[null],outputMasks:[null],inputShapes:[e],outputShapes:[e]})}apply(t,e){throw new m("Cannot pass any input to an InputLayer's apply() method. InputLayer name: "+this.name)}dispose(){return{refCountAfterDispose:this._refCount,numDisposedVariables:0}}getConfig(){return{batchInputShape:this.batchInputShape,dtype:this.dtype,sparse:this.sparse,name:this.name}}}function je(t){if(null==t.batchShape&&null==t.shape)throw new Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension.");if(null!=t.batchShape&&null!=t.shape)throw new m("Please provide either a `shape` or `batchShape` argument to Input, but not both.");let e=t.batchShape;null!=t.shape&&null==e&&(e=[null].concat(t.shape));let n=t.dtype;null==n&&(n="float32");return new Ee({batchInputShape:e,name:t.name,dtype:n,sparse:t.sparse}).inboundNodes[0].outputTensors[0]}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */async function Me(t){if(null==t)return;const e=[],n=[],r=[];for(const i in t){const s=t[i];if("number"!=typeof s){const t=s;e.push(t.data()),n.push(i),r.push(t)}}if(e.length>0){const i=await Promise.all(e);for(let e=0;e<i.length;++e)t[n[e]]=i[e][0];Object(l.dispose)(r)}}function De(t){if(null!=t)for(const e in t){const n=t[e];"number"!=typeof n&&n.dispose()}}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */var Re;Ee.className="InputLayer",l.serialization.registerClass(Ee),function(t){t[t.SILENT=0]="SILENT",t[t.VERBOSE=1]="VERBOSE"}(Re||(Re={}));class Pe{constructor(){this.validationData=null}setParams(t){this.params=t}async onEpochBegin(t,e){}async onEpochEnd(t,e){}async onBatchBegin(t,e){}async onBatchEnd(t,e){}async onTrainBegin(t){}async onTrainEnd(t){}setModel(t){}}class Fe{constructor(t,e=10){null==t&&(t=[]),this.callbacks=t,this.queueLength=e}append(t){this.callbacks.push(t)}setParams(t){for(const e of this.callbacks)e.setParams(t)}setModel(t){for(const e of this.callbacks)e.setModel(t)}async onEpochBegin(t,e){null==e&&(e={});for(const n of this.callbacks)await n.onEpochBegin(t,e)}async onEpochEnd(t,e){null==e&&(e={});for(const n of this.callbacks)await n.onEpochEnd(t,e)}async onBatchBegin(t,e){null==e&&(e={});for(const n of this.callbacks)await n.onBatchBegin(t,e)}async onBatchEnd(t,e){null==e&&(e={});for(const n of this.callbacks)await n.onBatchEnd(t,e)}async onTrainBegin(t){null==t&&(t={});for(const e of this.callbacks)await e.onTrainBegin(t)}async onTrainEnd(t){null==t&&(t={});for(const e of this.callbacks)await e.onTrainEnd(t)}}class ze extends Pe{constructor(){super()}async onEpochBegin(t){this.seen=0,this.totals={}}async onBatchEnd(t,e){null==e&&(e={});const n=null==e.size?0:e.size;this.seen+=n;for(const t in e){const r=e[t];if("number"==typeof r)this.totals.hasOwnProperty(t)||(this.totals[t]=0),this.totals[t]=this.totals[t]+r*n;else{let e;t in this.totals?e=this.totals[t]:this.totals[t]=0;const i=Object(l.tidy)(()=>Object(l.add)(this.totals[t],Object(l.mul)(r,n)));this.totals[t]=i,null!=e&&e.dispose()}}}async onEpochEnd(t,e){if(null!=e)for(const t of this.params.metrics)null!=this.totals[t]&&("number"==typeof this.totals[t]?e[t]=this.totals[t]/this.seen:Object(l.tidy)(()=>{const n=Object(l.mul)(Object(l.div)(1,this.seen),this.totals[t]);e[t]=n,this.totals[t].dispose(),Object(l.keep)(e[t])}))}}class Le extends Pe{async onTrainBegin(t){this.epoch=[],this.history={}}async onEpochEnd(t,e){null==e&&(e={}),this.epoch.push(t);for(const t in e)null==this.history[t]&&(this.history[t]=[]),this.history[t].push(e[t])}async syncData(){const t=[],e=[],n=[];for(const r in this.history){const i=this.history[r];for(let s=0;s<i.length;++s)if("number"!=typeof i[s]){const a=i[s];t.push(a.data()),e.push(r),n.push(s)}}const r=await Promise.all(t);for(let t=0;t<r.length;++t){this.history[e[t]][n[t]].dispose(),this.history[e[t]][n[t]]=r[t][0]}}}class $e extends Pe{constructor(t,e){if(super(),this.currentEpoch=0,this.yieldEvery=e||"auto","auto"===this.yieldEvery&&(this.yieldEvery=125),"never"===this.yieldEvery&&null!=t.onYield)throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback");l.util.isNumber(this.yieldEvery)&&(this.maybeWait=function(t,e){let n,r=l.util.now();return(...i)=>{const s=l.util.now();return s-r<e||(r=s,n=t(...i)),n}}(this.maybeWait.bind(this),this.yieldEvery)),this.trainBegin=t.onTrainBegin,this.trainEnd=t.onTrainEnd,this.epochBegin=t.onEpochBegin,this.epochEnd=t.onEpochEnd,this.batchBegin=t.onBatchBegin,this.batchEnd=t.onBatchEnd,this.yield=t.onYield}async maybeWait(t,e,n){const r=[];null!=this.yield&&(await Me(n),r.push(this.yield(t,e,n))),r.push(Object(l.nextFrame)()),await Promise.all(r)}async onEpochBegin(t,e){this.currentEpoch=t,null!=this.epochBegin&&(await Me(e),await this.epochBegin(t,e))}async onEpochEnd(t,e){const n=[];null!=this.epochEnd&&(await Me(e),n.push(this.epochEnd(t,e))),"epoch"===this.yieldEvery&&n.push(Object(l.nextFrame)()),await Promise.all(n)}async onBatchBegin(t,e){null!=this.batchBegin&&(await Me(e),await this.batchBegin(t,e))}async onBatchEnd(t,e){const n=[];null!=this.batchEnd&&(await Me(e),n.push(this.batchEnd(t,e))),"batch"===this.yieldEvery?n.push(Object(l.nextFrame)()):l.util.isNumber(this.yieldEvery)&&n.push(this.maybeWait(this.currentEpoch,t,e)),await Promise.all(n)}async onTrainBegin(t){null!=this.trainBegin&&(await Me(t),await this.trainBegin(t))}async onTrainEnd(t){null!=this.trainEnd&&(await Me(t),await this.trainEnd(t))}}function Be(t,e){if(null==t&&(t={}),t instanceof Pe)return[t];if(Array.isArray(t)&&t[0]instanceof Pe)return t;return _(t).map(t=>new $e(t,e))}class qe{constructor(){}static registerCallbackConstructor(t,e){l.util.assert(t>=0&&Number.isInteger(t),()=>"Verbosity level is expected to be an integer >= 0, but got "+t),qe.checkForDuplicate(e),null==qe.constructors[t]&&(qe.constructors[t]=[]),qe.constructors[t].push(e)}static checkForDuplicate(t){for(const e in qe.constructors){qe.constructors[+e].forEach(e=>{if(e===t)throw new m("Duplicate callback constructor.")})}}static clear(){qe.constructors={}}static createCallbacks(t){const e=[];for(const n in qe.constructors){const r=+n;t>=r&&e.push(...qe.constructors[r])}return e.map(t=>new t)}}function Ve(t,e,n,r,i,s,a,o,u){const c=new Le,l=[new ze,...qe.createCallbacks(e)];null!=t&&l.push(...t),l.push(c);const h=new Fe(l);return h.setParams({epochs:n,initialEpoch:r,samples:i,steps:s,batchSize:a,verbose:e,doValidation:o,metrics:u}),{callbackList:h,history:c}}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function Ue(t,e={},n=!1){return C(t,l.serialization.SerializationMap.getMap().classNameMap,e,"layer",n)}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function We(t,e){return Object(l.tidy)(()=>{"float32"!==t.dtype&&(t=t.asType("float32"));const n=l.sum(kt(t),e,!0),r=l.fill(n.shape,d()),i=l.sqrt(l.maximum(n,r));return l.div(t,i)})}function Ge(t,e){return Object(l.tidy)(()=>l.mean(kt(l.sub(e,t)),-1))}function He(t,e){return Object(l.tidy)(()=>l.mean(l.abs(l.sub(e,t)),-1))}function Ke(t,e){return Object(l.tidy)(()=>{const n=l.sub(t,e),r=l.clipByValue(l.abs(t),d(),Number.MAX_VALUE),i=l.abs(l.div(n,r));return l.mul(100,l.mean(i,-1))})}function Qe(t,e){return Object(l.tidy)(()=>{const n=l.clipByValue(e,d(),Number.MAX_VALUE),r=l.log(l.add(1,n)),i=l.clipByValue(t,d(),Number.MAX_VALUE),s=l.log(l.add(1,i));return l.mean(kt(l.sub(r,s)),-1)})}function Xe(t,e,n=!1){return Object(l.tidy)(()=>{if(n)e=l.softmax(e);else{const t=l.sum(e,e.shape.length-1,!0);e=l.div(e,t)}return e=l.clipByValue(e,d(),1-d()),l.neg(l.sum(l.mul(t.toFloat(),l.log(e)),e.shape.length-1))})}function Ye(t,e,n=!1){return Object(l.tidy)(()=>{const r=l.floor(function(t){const e=[ct(t.shape)];return t.reshape(e)}(t)).toInt(),i=(e=l.clipByValue(e,d(),1-d())).shape;return Xe(l.oneHot(r,i[i.length-1]).reshape(i),e,n)})}function Je(t,e){return Object(l.tidy)(()=>{let n;return n=l.clipByValue(e,d(),1-d()),n=l.log(l.div(n,l.sub(1,n))),l.mean(function(t,e){if(!l.util.arraysEqual(t.shape,e.shape))throw new m(`logits and labels must have the same shape, but got shapes ${JSON.stringify(t.shape)} and ${JSON.stringify(e.shape)}`);return Object(l.tidy)(()=>{const n=e.relu(),r=e.abs().neg();return n.sub(e.mul(t)).add(r.exp().log1p())})}(t,n),-1)})}function Ze(t,e){return Object(l.tidy)(()=>{const n=l.clipByValue(t,d(),1),r=l.clipByValue(e,d(),1);return l.sum(l.mul(t,l.log(l.div(n,r))),-1)})}function tn(t,e){return Object(l.tidy)(()=>{const n=We(t,-1),r=We(e,-1),i=l.mul(n,r);return l.neg(l.sum(i,-1))})}qe.constructors={};const en={meanSquaredError:Ge,meanAbsoluteError:He,meanAbsolutePercentageError:Ke,meanSquaredLogarithmicError:Qe,squaredHinge:function(t,e){return Object(l.tidy)(()=>{const n=l.maximum(0,l.sub(1,l.mul(t,e)));return l.mean(kt(n),-1)})},hinge:function(t,e){return Object(l.tidy)(()=>{const n=l.maximum(0,l.sub(1,l.mul(t,e)));return l.mean(n,-1)})},categoricalHinge:function(t,e){return Object(l.tidy)(()=>{const n=l.sum(l.mul(t,e),-1),r=l.max(l.mul(l.sub(1,t),e),-1);return l.maximum(0,l.add(1,l.sub(r,n)))})},logcosh:function(t,e){return Object(l.tidy)(()=>{const n=Math.log(2),r=l.sub(e,t),i=l.sub(l.add(r,l.softplus(l.mul(-2,r))),n);return l.mean(i,-1)})},categoricalCrossentropy:Xe,sparseCategoricalCrossentropy:Ye,binaryCrossentropy:Je,kullbackLeiblerDivergence:Ze,poisson:function(t,e){return Object(l.tidy)(()=>{const n=l.log(l.add(d(),e));return l.mean(l.sub(e,l.mul(t,n)),-1)})},cosineProximity:tn};function nn(t){if("string"==typeof t){if(t in en)return en[t];let e="Unknown loss "+t;throw t.toLowerCase().includes("softmaxcrossentropy")&&(e=`Unknown loss ${t}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new m(e)}return t}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function rn(t,e){return Object(l.tidy)(()=>{const n=l.mul(.5,l.onesLike(e)),r=ft(l.greater(e,n),t.dtype);return l.mean(l.equal(t,r),-1)})}function sn(t,e){return Object(l.tidy)(()=>ft(l.equal(l.argMax(t,-1),l.argMax(e,-1)),"float32"))}function an(t,e){return Object(l.tidy)(()=>l.logicalAnd(t.equal(1),e.equal(1)).sum().cast("float32"))}function on(t,e){return Object(l.tidy)(()=>{const n=an(t,e),r=function(t,e){return Object(l.tidy)(()=>l.logicalAnd(t.equal(0),e.equal(1)).sum().cast("float32"))}(t,e),i=n.add(r);return l.where(l.greater(i,0),n.div(i),0).cast("float32")})}function un(t,e){return Object(l.tidy)(()=>{const n=an(t,e),r=function(t,e){return Object(l.tidy)(()=>l.logicalAnd(t.equal(1),e.equal(0)).sum().cast("float32"))}(t,e),i=n.add(r);return l.where(l.greater(i,0),n.div(i),0).cast("float32")})}function cn(t,e){return Je(t,e)}function ln(t,e){return t.rank===e.rank&&(t=t.squeeze([t.rank-1])),(e=e.argMax(-1)).dtype!==t.dtype&&(e=e.asType(t.dtype)),l.equal(t,e).asType("float32")}const hn=Xe,dn=Ye,pn={binaryAccuracy:rn,categoricalAccuracy:sn,precision:on,categoricalCrossentropy:hn,sparseCategoricalCrossentropy:dn,mse:Ge,MSE:Ge,mae:He,MAE:He,mape:Ke,MAPE:Ke,cosine:tn};function fn(t){if("string"==typeof t&&t in pn)return pn[t];if("string"!=typeof t&&null!=t)return t;throw new m("Unknown metric "+t)}function mn(t){if(v(null!==t,"Unknown LossOrMetricFn "+t),"string"==typeof t)return t;{let e;for(const n of Object.keys(en))if(en[n]===t){e=n;break}if(void 0!==e)return e;for(const n of Object.keys(pn))if(pn[n]===t){e=n;break}return void 0!==e?e:t.name}}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function gn(t,e,n=!1){if(null==t||"object"!=typeof t||Object.getPrototypeOf(t)!==Object.prototype||!function t(e){if(null===e)return!0;if("object"==typeof e){if(Object.getPrototypeOf(e)===Object.prototype){const n=Object.keys(e);for(const r of n){if("string"!=typeof r)return!1;if(!t(e[r]))return!1}return!0}if(Array.isArray(e)){for(const n of e)if(!t(n))return!1;return!0}return!1}{const t=typeof e;return"string"===t||"number"===t||"boolean"===t}}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */(t))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(n){const n=JSON.stringify(t);n.length>1048576&&console.warn(`User-defined metadata of model "${e}" is too large in size (length=${n.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= 1048576.`)}}function bn(t,e,n,r=console.log){const i=function(t){let e=!0;const n=[],r=[];for(const e in t.nodesByDepth)n.push(t.nodesByDepth[e]);for(const t of n){if(t.length>1||1===t.length&&t[0].inboundLayers.length>1){e=!1;break}r.push(...t)}if(e)for(const n of t.layers){let t=!1;for(const i of n.inboundNodes)if(-1!==r.indexOf(i)){if(t){e=!1;break}t=!0}if(!e)break}return e}(t),s=["Layer (type)","Output shape","Param #"];let a;if(i?(e=e||65,n=n||[.45,.85,1]):(e=e||98,n=n||[.33,.55,.67,1]),n[n.length-1]<=1&&(n=n.map(t=>Math.floor(e*t))),!i){s.push("Receives inputs"),a=[];for(const e in t.nodesByDepth)a.push(...t.nodesByDepth[e])}r("_".repeat(e)),yn(s,n,r),r("=".repeat(e));const o=t.layers;for(let t=0;t<o.length;++t)i?vn(o[t],n,r):wn(o[t],n,a,r),r((t===o.length-1?"=":"_").repeat(e));t.checkTrainableWeightsConsistency();const u=function(t){let e;e=null!=t.collectedTrainableWeights?xe(t.collectedTrainableWeights):xe(t.trainableWeights);return e}(t),c=xe(t.nonTrainableWeights);r("Total params: "+(u+c)),r("Trainable params: "+u),r("Non-trainable params: "+c),r("_".repeat(e))}function yn(t,e,n=console.log){let r="";for(let n=0;n<t.length;++n)n>0&&(r=r.slice(0,r.length-1)+" "),r+=t[n],r=r.slice(0,e[n]),r+=" ".repeat(e[n]-r.length);n(r)}function vn(t,e,n){let r;try{r=JSON.stringify(t.outputShape)}catch(t){r="multiple"}yn([`${t.name} (${t.getClassName()})`,r,t.countParams().toString()],e,n)}function wn(t,e,n,r){let i;try{i=JSON.stringify(t.outputShape)}catch(t){i="multiple"}const s=[];for(const e of t.inboundNodes)if(!(null!=n&&n.length>0&&-1===n.indexOf(e)))for(let t=0;t<e.inboundLayers.length;++t){const n=e.inboundLayers[t].name,r=e.nodeIndices[t],i=e.tensorIndices[t];s.push(`${n}[${r}][${i}]`)}const a=t.name,o=t.getClassName(),u=0===s.length?"":s[0];yn([`${a} (${o})`,i,t.countParams().toString(),u],e,r);for(let t=1;t<s.length;++t)yn(["","","",s[t]],e,r)}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function xn(t,e,n){return("inboundNodes"===t||"outputLayers"===t||"inputLayers"===t)&&0===e&&"string"==typeof n}function _n(t,e){if(null===t)return null;if("string"==typeof t)return S(t);if("number"==typeof t||"boolean"==typeof t)return t;if(t instanceof Array){const n=[],r=t.length;for(let i=0;i<r;++i){const r=t[i];xn(e,i,r)?n.push(r):n.push(_n(r,e))}return n}{const e={};for(const n of Object.keys(t)){const r=t[n];if("name"===n&&"string"==typeof r)e[n]=r;else{const t=S(n);e[t]=_n(r,t)}}return e}}
/** @license See the LICENSE file. */
const On="2.7.0";
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */class Sn{constructor(t){if(this.id2Value={},this.id2Mask={},this.name2Id={},t instanceof Sn)for(const e in t.id2Value)this.id2Value[e]=t.id2Value[e],e in t.id2Mask&&(this.id2Mask[e]=t.id2Mask[e]);else{if(null==t)return;for(const e of t)this.add(e.key,e.value)}}add(t,e,n){if(null!=this.id2Value[t.id])throw new m(`Duplicate key: name=${t.name}, id=${t.id}`);return this.id2Value[t.id]=function(t,e){if(null==t.dtype||t.dtype===e.dtype)return e;try{return Object(l.cast)(e,t.dtype)}catch(n){throw new m(`The dtype of the feed (${e.dtype}) can not be cast to the dtype of the key '${t.name}' (${t.dtype}).`)}}(t,e),this.name2Id[t.name]=t.id,null!=n&&(this.id2Mask[t.id]=n),this}addFeed(t){this.add(t.key,t.value)}hasKey(t){return null!=this.id2Value[t.id]}names(){return Object.keys(this.name2Id)}getValue(t){if(t instanceof Te){if(null==this.id2Value[t.id])throw new m("Nonexistent key: "+t.name);return this.id2Value[t.id]}{const e=this.name2Id[t];if(null==e)throw new m("Feed dict has no SymbolicTensor name: "+t);return this.id2Value[e]}}getMask(t){if(t instanceof Te){if(null==this.id2Value[t.id])throw new m("Nonexistent key: "+t.name);return this.id2Mask[t.id]}{const e=this.name2Id[t];if(null==e)throw new m("Feed dict has no SymbolicTensor name: "+t);return this.id2Mask[e]}}disposeMasks(){null!=this.id2Mask&&Object(l.dispose)(this.id2Mask)}}const kn={},Tn={};function Cn(t,e,n,r){const i=null!=n&&n.training,s=Array.isArray(t),a=s?t:[t],o=a.map(t=>t.name),u=[],c=e.names();for(const t of o)-1!==c.indexOf(t)?u.push(e.getValue(t)):u.push(null);null!=r&&(r.maxNumTensors=-1/0,r.minNumTensors=1/0);const h=o.join(",")+"|"+e.names().join(",");let d,p;if(null==kn[h]){const t=function(t,e){l.util.assert(null!=t&&t.length>0,()=>"Expected at least one fetch, got none");let n=[],r={};if(1===t.length){const i=Nn(t[0],e);n=i.sorted,r=i.recipientMap}else{const i=new Set;for(const s of t){const{sorted:t,recipientMap:a}=Nn(s,e);for(const e of t)i.has(e.name)||(n.push(e),i.add(e.name));for(const t in a)null==r[t]&&(r[t]=new Set),a[t].forEach(e=>r[t].add(e))}}return{sorted:n,recipientCounts:An(r)}}(a,e);d=t.sorted,p=t.recipientCounts,kn[h]=d,Tn[h]=p}d=kn[h],p={},i||Object.assign(p,Tn[h]);const f=new Sn(e);for(let t=0;t<d.length;++t){if(null!=r){const t=Object(l.memory)().numTensors;t>r.maxNumTensors&&(r.maxNumTensors=t),t<r.minNumTensors&&(r.minNumTensors=t)}const s=d[t],a=s.sourceLayer;if(a instanceof Ee)continue;const c=[],h=[],m=[];let g=!1;for(const t of s.inputs){const n=f.getValue(t),r=f.getMask(t);c.push(n),h.push(r),null!=r&&(g=!0),i||(p[t.name]--,0!==p[t.name]||e.hasKey(t)||-1!==o.indexOf(t.name)||n.isDisposed||!0===t.sourceLayer.stateful||m.push(n))}g&&((n=n||{}).mask=h[0]);const b=_(a.apply(c,n));let y=null;a.supportsMasking&&(y=a.computeMask(c,h));const v=In(s),w=Array.isArray(v)?v:[v];for(let t=0;t<w.length;++t){f.hasKey(w[t])||f.add(w[t],b[t],Array.isArray(y)?y[0]:y);const e=o.indexOf(w[t].name);-1!==e&&(u[e]=b[t])}i||Object(l.dispose)(m)}return f.disposeMasks(),s?u:u[0]}function An(t){const e={};for(const n in t)e[n]=t[n].size;return e}function Nn(t,e){const n=new Set,r=[],i={};for(const t of e.names())n.add(t);const s=[],a=[];for(s.push(t);s.length>0;){const t=s[s.length-1];if(n.has(t.name)){s.pop();continue}const e=a[a.length-1]===s.length-1;if(0===t.inputs.length||e)s.pop(),r.push(t),n.add(t.name),e&&a.pop();else{a.push(s.length-1);for(const e of t.inputs)null==i[e.name]&&(i[e.name]=new Set),i[e.name].add(t.name),n.has(e.name)||s.push(e)}}return{sorted:r,recipientMap:i}}function In(t){let e;if(1===t.sourceLayer.inboundNodes.length)e=t.sourceLayer.output;else{let n=null;for(let e=0;e<t.sourceLayer.inboundNodes.length;++e)for(const r of t.sourceLayer.inboundNodes[e].outputTensors)if(r.id===t.id){n=e;break}e=t.sourceLayer.getOutputAt(n)}return e}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */class En extends Ie{constructor(t){if(super({}),this.containerNodes=new Set,this.name=t.name,null==this.name){const t=this.getClassName().toLowerCase();this.name=ge(t)}if(this.supportsMasking=!1,this.trainable_=!0,Array.isArray(t.inputs)?this.inputs=t.inputs.slice():this.inputs=[t.inputs],Array.isArray(t.outputs)?this.outputs=t.outputs.slice():this.outputs=[t.outputs],N(this.inputs).length!==this.inputs.length)throw new m("The list of inputs passed to the model is redundant. All inputs should only appear once. Found: "+this.inputs.map(t=>t.name));N(this.outputs).length!==this.outputs.length&&console.warn("The list of outputs passed to the model is redundant. All outputs should only appear once. Found: "+this.outputs.map(t=>t.name)),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(const t of this.outputs){const e=t.sourceLayer,n=t.nodeIndex,r=t.tensorIndex;this.outputLayers.push(e),this.outputLayersNodeIndices.push(n),this.outputLayersTensorIndices.push(r)}for(const t of this.inputs){const e=t.sourceLayer,n=t.nodeIndex,r=t.tensorIndex;v(0===n,"input layer has >1 nodes"),v(0===r,"input layer has >1 tensors"),this.inputLayers.push(e),this.inputLayersNodeIndices.push(n),this.inputLayersTensorIndices.push(r)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let e=0;e<this.inputLayers.length;e++){const n=this.inputLayers[e];if(!(n instanceof Ee))throw new TypeError(`Input layers to a LayersModel must be InputLayer objects. Received inputs: ${t.inputs}. Input ${e} (0-based) originates from layer type ${n.getClassName()}.`);this.inputNames.push(n.name),this.feedInputShapes.push(n.batchInputShape),this.feedInputNames.push(n.name)}for(const t of this.outputLayers)this.outputNames.push(t.name);this.internalInputShapes=this.inputs.map(t=>t.shape),this.internalOutputShapes=this.outputs.map(t=>t.shape);const e={},n={},r={},i={},s={},a=[],o=(t,e,n,r,i,u)=>{null!=r&&null!=i&&null!=u||(r=t.sourceLayer,i=t.nodeIndex,u=t.tensorIndex);const c=r.inboundNodes[i];if(-1!==n.indexOf(c))throw new f(`The tensor ${t.name} at layer "${r.name}" is part of a cycle.`);if(-1!==e.indexOf(c))return;this.containerNodes.add(En.nodeKey(r,i)),r.id in s||(s[r.id]=Object.keys(s).length),-1===n.indexOf(c)&&n.push(c);const l=c.inboundLayers.length;for(let t=0;t<l;t++){const r=c.inputTensors[t],i=c.inboundLayers[t],s=c.nodeIndices[t],a=c.tensorIndices[t];o(r,e,n,i,s,a)}for(e.push(c);n.indexOf(c)>=0;)n.splice(n.indexOf(c),1);a.push(c)},u=[],c=[];for(const t of this.outputs)o(t,u,c);const l=a.slice().reverse();for(const t of l){n[t.id]=t,t.id in e||(e[t.id]=0);let s=e[t.id];const a=null==r[t.outboundLayer.id]?0:r[t.outboundLayer.id];s=Math.max(s,a),r[t.outboundLayer.id]=s,i[t.outboundLayer.id]=t.outboundLayer,e[t.id]=s;for(let r=0;r<t.inboundLayers.length;r++){const i=t.inboundLayers[r],a=t.nodeIndices[r],o=i.inboundNodes[a],u=null==e[o.id]?0:e[o.id];e[o.id]=Math.max(s+1,u),n[o.id]=o}}const h={};for(const t in e){const r=e[t];r in h||(h[r]=[]),h[r].push(n[t])}const d={};for(const t in r){const e=r[t];e in d||(d[e]=[]),d[e].push(i[t])}let p=Object.keys(d).map(t=>parseInt(t,10)).sort(A);this.layers=[];for(const t of p){const e=d[t];e.sort((t,e)=>{const n=s[t.id],r=s[e.id];return n<r?-1:n>r?1:0});for(const t of e)t instanceof En&&this.internalContainerRefs.push(t),this.layers.push(t)}this.layersByDepth=d,p=Object.keys(h).map(t=>parseInt(t,10)).sort(A);const g=this.inputs.slice(),b=[];for(const t of p)for(const e of h[t]){const t=e.outboundLayer;if(null!=t){for(const n of e.inputTensors)if(-1===g.indexOf(n))throw new f("Graph disconnected: cannot obtain value for tensor "+n+` at layer "${t.name}". The following previous layers were accessed without issue: `+b);for(const t of e.outputTensors)g.push(t);b.push(t.name)}}this.nodesByDepth=h;const y=this.layers.map(t=>t.name);for(const t of y){const e=y.filter(e=>e===t).length;if(1!==e)throw new f(`The name "${t}" is used ${e} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(y))}this.outboundNodes=[],this.inboundNodes=[],new Ae({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map(t=>null),outputMasks:this.outputs.map(t=>null),inputShapes:this.inputs.map(t=>t.shape),outputShapes:this.outputs.map(t=>t.shape)}),this.built=!0,this._refCount=1}assertNotDisposed(){if(0===this._refCount)throw new Error(`Container '${this.name}' is already disposed.`)}dispose(){this.assertNotDisposed();const t={refCountAfterDispose:null,numDisposedVariables:0};if(0==--this._refCount){for(const e of this.layers)t.numDisposedVariables+=e.dispose().numDisposedVariables;for(const e of this.internalContainerRefs)t.numDisposedVariables+=e.dispose().numDisposedVariables}return t.refCountAfterDispose=this._refCount,t}get trainable(){return this.trainable_}set trainable(t){this.layers.forEach(e=>{e._trainableWeights.forEach(e=>e.trainable=t)}),this.trainable_=t}get trainableWeights(){if(this._trainableWeights.length>0)throw new m("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");if(!this.trainable)return[];let t=[];for(const e of this.layers)t=t.concat(e.trainableWeights);return t}get nonTrainableWeights(){const t=[];for(const e of this.layers)t.push(...e.nonTrainableWeights);if(!this.trainable){const e=[];for(const t of this.layers)e.push(...t.trainableWeights);return e.concat(t)}return t}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}loadWeights(t,e=!0){const n={};let r=0;for(const t of this.layers)for(const e of t.weights){if(null!=n[e.originalName])throw new m("Duplicate weight name: "+e.originalName);n[e.originalName]=e,r++}const i=[];for(const r in t){let s=r;if(null==n[r]){const t=r.split("/");s=t.slice(0,-2).concat([t[t.length-1]]).join("/")}if(null!=n[s])i.push([n[s],t[r]]);else if(e)throw new m("Provided weight data has no target variable: "+r);delete n[s]}if(e){const t=[];for(const e in n)t.push(e);if(t.length>0)throw new m(`${t.length} of ${r} weights are not set: `+t)}Se(i)}updatedConfig(){const t=this.getConfig(),e={};return e.className=this.getClassName(),e.config=t,e.kerasVersion="tfjs-layers "+On,e.backend="TensorFlow.js",e}toJSON(t,e=!0){const n=function t(e,n){if(null==e)return null;if("string"==typeof e)return O(e);if("number"==typeof e||"boolean"==typeof e)return e;if(e instanceof Array){const r=[],i=e.length;for(let s=0;s<i;++s){const i=e[s];xn(n,s,i)?r.push(i):r.push(t(i,n))}return r}{const n={};for(const r of Object.keys(e)){const i=e[r],s=O(r);n[s]="name"!==r&&"className"!==r||"string"!=typeof i?t(i,r):i}return n}}(this.updatedConfig());return e?JSON.stringify(n):n}call(t,e){return Object(l.tidy)(()=>{t=_(t);const n=new Sn;for(let e=0;e<this.inputs.length;++e)n.add(this.inputs[e],t[e]);return Cn(this.outputs,n,e)})}computeMask(t,e){return Object(l.tidy)(()=>{let n;return t=_(t),n=null==e?y(null,t.length):_(e),this.runInternalGraph(t,n)[1]})}computeOutputShape(t){const e=ye(t);if(e.length!==this.inputLayers.length)throw new m(`Invalid inputShape argument ${t}: model has ${this.inputLayers.length} tensor inputs.`);const n={};for(let t=0;t<e.length;t++){const r=this.inputLayers[t],i=e[t];n[r.name+"_0_0"]=i}const r=Object.keys(this.nodesByDepth).map(t=>parseInt(t,10)).sort(A);if(r.length>1)for(const t of r){const e=this.nodesByDepth[t];for(const t of e){const e=t.outboundLayer;if(-1!==this.inputLayers.map(t=>t.id).indexOf(e.id))continue;const r=[];for(let e=0;e<t.inboundLayers.length;e++){const i=t.inboundLayers[e],s=t.nodeIndices[e],a=t.tensorIndices[e],o=n[`${i.name}_${s}_${a}`];r.push(o)}const i=ye(e.computeOutputShape(x(r))),s=e.inboundNodes.indexOf(t);for(let t=0;t<i.length;t++){n[`${e.name}_${s}_${t}`]=i[t]}}}const i=[],s=[];for(let t=0;t<this.outputLayers.length;t++){const e=this.outputLayers[t],n=this.outputLayersNodeIndices[t],r=this.outputLayersTensorIndices[t],i=`${e.name}_${n}_${r}`;s.push(i)}for(let t=0;t<s.length;t++){const e=s[t];v(e in n),i.push(n[e])}return x(i)}runInternalGraph(t,e){null==e&&(e=y(null,t.length));const n={};for(let r=0;r<this.inputs.length;++r){const i=this.inputs[r],s=t[r],a=e[r];n[i.id]=[s,a]}const r=Object.keys(this.nodesByDepth).map(t=>parseInt(t,10)).sort(A);for(const t of r){const e=this.nodesByDepth[t];for(const t of e){const e=t.outboundLayer,r=t.inputTensors,i=t.outputTensors,s=new Array;for(const t of r)t.id in n&&s.push(n[t.id]);if(s.length===r.length){let r,a,o,u,c={};if(null!=t.callArgs&&(c=t.callArgs),1===s.length){const[t,n]=s[0];null==c.mask&&(c.mask=n),o=_(e.call(t,c)),u=_(e.computeMask(t,n)),r=[t],a=[n]}else r=s.map(t=>t[0]),a=s.map(t=>t[1]),null==c.mask&&(c.mask=a),o=_(e.call(r,c)),u=_(e.computeMask(r,a));if(e.activityRegularizer)throw new g("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let t=0;t<i.length;++t){const e=i[t],r=o[t],s=u[t];n[e.id]=[r,s]}}}}const i=[],s=[],a=[];for(const t of this.outputs){v(t.id in n,`Could not compute output ${t.name} : ${t.id}`);const[e,r]=n[t.id];a.push(e.shape),i.push(e),s.push(r)}return[i,s,a]}buildNodeConversionMap(t){const e={};let n;for(const t of this.layers){n=t instanceof En?1:0;for(let r=0;r<t.inboundNodes.length;r++){const i=En.nodeKey(t,r);this.containerNodes.has(i)&&(e[i]=n,n+=1)}}return e}getLayer(t,e){if(null!=e){if(this.layers.length<=e)throw new m(`Was asked to retrieve layer at index ${e}, but model only has ${this.layers.length} layer(s).`);return this.layers[e]}if(null==t)throw new m("Provide either a layer name or layer index");for(const e of this.layers)if(e.name===t)return e;throw new m("No such layer: "+t)}calculateLosses(){return Object(l.tidy)(()=>{const t=[];for(const e of this.layers)for(let n=0;n<e.inboundNodes.length;++n){const r=En.nodeKey(e,n);this.containerNodes.has(r)&&t.push(...e.calculateLosses())}return t})}getConfig(){const t={name:this.name},e=this.buildNodeConversionMap(this.layers),n=[];for(const t of this.layers){const r=t.getClassName(),i=t.getConfig(),s=[];for(let n=0;n<t.inboundNodes.length;n++){const r=t.inboundNodes[n],i=En.nodeKey(t,n);let a={};if(this.containerNodes.has(i)){if(r.callArgs)try{JSON.stringify(r.callArgs),a=r.callArgs}catch(e){console.warn(`Layer ${t.name} was passed non-serializable keyword arguments: `+r.callArgs+". They will not be included in the serialized model (and thus will be missing at deserialization time)."),a={}}if(r.inboundLayers.length>0){const t=[];for(let n=0;n<r.inboundLayers.length;n++){const i=r.inboundLayers[n],s=r.nodeIndices[n],o=r.tensorIndices[n];let u=e[En.nodeKey(i,s)];null==u&&(u=0),t.push([i.name,u,o,a])}s.push(t)}}}const a={};a.name=t.name,a.className=r,a.config=i,a.inboundNodes=s,n.push(a)}t.layers=n;const r=[];for(let t=0;t<this.inputLayers.length;t++){const n=this.inputLayers[t],i=this.inputLayersNodeIndices[t],s=En.nodeKey(n,i);if(!this.containerNodes.has(s))continue;let a=e[s];null==a&&(a=0);const o=this.inputLayersTensorIndices[t];r.push([n.name,a,o])}t.inputLayers=r;const i=[];for(let t=0;t<this.outputLayers.length;t++){const n=this.outputLayers[t],r=this.outputLayersNodeIndices[t],s=En.nodeKey(n,r);if(!this.containerNodes.has(s))continue;let a=e[s];null==a&&(a=0);const o=this.outputLayersTensorIndices[t];i.push([n.name,a,o])}return t.outputLayers=i,t}static fromConfig(t,e,n={},r=!1){const i={},s={};function a(t,e){t.name in s?s[t.name].push(e):s[t.name]=[e]}function o(t,e){const n=[];let r;for(const s of e){const o=s[0],u=s[1],c=s[2];if(r=null==s[3]?{}:s[3],!(o in i))return void a(t,e);const l=i[o];if(l.inboundNodes.length<=u)return void a(t,e);const h=l.inboundNodes[u];n.push(h.outputTensors[c])}n.length>0&&t.apply(x(n),r)}function u(t){const n=t.name,s=Ue(t,null!=e.customObjects?e.customObjects:{});s.setFastWeightInitDuringBuild(r),i[n]=s;t.inboundNodes.forEach(t=>{if(!(t instanceof Array))throw new m("Corrupted configuration, expected array for nodeData: "+t);a(s,t)})}const c=e.name,l=e.layers;for(const t of l)u(t);for(;!I(s);)for(const t of l){const e=i[t.name];if(e.name in s){const t=s[e.name];delete s[e.name];for(const n of t)o(e,n)}}const h=[],d=[],p=e.inputLayers;for(const t of p){const e=t[0],n=t[1],r=t[2];v(e in i);const s=i[e].inboundNodes[n].outputTensors;h.push(s[r])}const f=e.outputLayers;for(const t of f){const e=t[0],n=t[1],r=t[2];v(e in i);const s=i[e].inboundNodes[n].outputTensors;d.push(s[r])}return new t({inputs:h,outputs:d,name:c})}get stateful(){if(this._stateful)throw new m("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false.");for(const t of this.layers)if(t.stateful)return!0;return!1}resetStates(){Object(l.tidy)(()=>{this.layers.forEach(t=>{t.stateful&&t.resetStates()})})}}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function jn(t,e,n){const r=e.length;if(null==t||Array.isArray(t)&&0===t.length)return e.map(t=>null);if(1===r)return Array.isArray(t)&&1===t.length?t:"object"==typeof t&&e[0]in t?[t[e[0]]]:[t];if(Array.isArray(t)){if(t.length!==r)throw new Error(`Provided ${n} is an array of ${t.length} element(s), but the model has ${r} outputs. Make sure a set of weights is provided for each model output.`);return t}if("object"==typeof t&&Object.keys(t).length>0&&"object"==typeof t[Object.keys(t)[0]]){const n=[];return e.forEach(e=>{e in t?n.push(t[e]):n.push(null)}),n}throw new Error(`The model has multiple (${r}) outputs, so ${n} must be either an array with ${r} elements or an object with ${e} keys. Provided ${n} not understood: ${JSON.stringify(t)}`)}function Mn(t,e){return jn(t,e,"classWeight")}async function Dn(t,e,n,r){if(null!=e||null!=r)throw new Error("Support sampleWeight is not implemented yet");if(null!=n){const e=Object(l.tidy)(()=>{if(1===t.shape.length)return t.clone();if(2===t.shape.length){if(t.shape[1]>1){const e=1;return t.argMax(e)}if(1===t.shape[1])return t.reshape([t.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${t.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}throw new Error(`Unexpected rank of target (y) tensor (${t.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)}),r=Array.from(await e.data());Object(l.dispose)(e);const i=[];return r.forEach(t=>{if(null==n[t])throw new Error(`classWeight must contain all classes in the training data. The class ${t} exists in the data but not in classWeight`);i.push(n[t])}),Object(l.tensor1d)(i,"float32")}return null}function Rn(t,e){return Object(l.mul)(t,e)}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function Pn(t,e){let n,r;const i=e;n=i.xs,r=i.ys,l.util.assert(null!=n&&null!=r,()=>"A Dataset iterator for fitDataset() is expected to generate objects of the form `{xs: xVal, ys: yVal}`, where the two values may be `tf.Tensor`, an array of Tensors, or a map of string to Tensor.  The provided Dataset instead generates "+e);const s=Fn("input",t.inputNames,n),a=Fn("output",t.outputNames,r),o=s[0].shape[0];l.util.assert(s.length===t.inputs.length,()=>`LayersModel has ${t.inputs.length} inputs, but the dataset provides ${s.length} inputs.  (Expected input keys: `+JSON.stringify(t.inputNames)+")"),l.util.assert(a.length===t.outputs.length,()=>`LayersModel has ${t.outputs.length} outputs, but the dataset provides ${a.length} outputs.  (Expected output keys: `+JSON.stringify(t.outputNames)+")");for(let e=0;e<s.length;e++)l.util.assert(s[e].shape[0]===o,()=>`Batch size mismatch: input ${t.inputNames[e]} has ${s[e].shape[0]}; expected  ${o} based on input ${t.inputNames[0]}.`);for(let e=0;e<a.length;e++)l.util.assert(a[e].shape[0]===o,()=>`Batch size mismatch: output ${t.outputNames[e]} has ${a[e].shape[0]}; expected  ${o} based on input ${t.inputNames[0]}.`);return{xs:s,ys:a}}function Fn(t,e,n){if(n instanceof l.Tensor)return[n];if(Array.isArray(n))return l.util.assert(n.length===e.length,()=>`Received an array of ${n.length} Tensors, but expected ${e.length} to match the ${t} keys ${e}.`),n;{const r=[];for(const i of e){if(null==n[i])throw new m(`The feature data generated by the dataset lacks the required ${t} key '${i}'.`);r.push(n[i])}return r}}async function zn(t,e,n){const r=null!=n.batchesPerEpoch;if(l.util.assert(null!=t.optimizer,()=>"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."),l.util.assert(null!=n,()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."),l.util.assert(null!=n.epochs&&n.epochs>0&&Number.isInteger(n.epochs),()=>"For fitDataset(), config.epochs is expected to be a positive integer, but got "+n.epochs),l.util.assert(!r||n.batchesPerEpoch>0&&Number.isInteger(n.batchesPerEpoch),()=>"For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got "+n.batchesPerEpoch),l.util.assert(null==n.validationSplit,()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."),t.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");t.isTraining=!0;try{const i=null!=n.validationData;let s,a;if(i)if(Ln(n.validationData))l.util.assert(null==n.validationBatches||n.validationBatches>0&&Number.isInteger(n.validationBatches),()=>"For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got "+n.validationBatches);else{const t=function(t){if(3===t.length)throw new g("Validation with sample weights is not implemented yet.");return{xs:t[0],ys:t[1]}}(n.validationData);s=t.xs,a=t.ys}const o=t.makeTrainFunction(),u=t.getDedupedMetricsNames();let c;c=i?u.slice().concat(u.map(t=>"val_"+t)):u.slice();const h=Be(n.callbacks,n.yieldEvery),d=null==n.verbose?1:n.verbose,{callbackList:p,history:f}=Ve(h,d,n.epochs,null,null,function(t,e){let n=null;null!=e.batchesPerEpoch?n=e.batchesPerEpoch:Number.isFinite(t.size)&&(n=t.size);return n}(e,n),null,i,c);p.setModel(t),t.history=f,await p.onTrainBegin(),t.stopTraining_=!1;let m=null==n.initialEpoch?0:n.initialEpoch,b=await e.iterator();for(;m<n.epochs;){const c={};await p.onEpochBegin(m);let h=0,d=0;for(r||(b=await e.iterator());!r||h<n.batchesPerEpoch;){const e=await b.next();if(r&&e.done){console.warn("You provided `batchesPerEpoch` as "+n.batchesPerEpoch+", but your dataset iterator ran out of data after "+h+" batches; interrupting training. Make sure that your dataset can generate at least `batchesPerEpoch * epochs` batches (in this case, "+n.batchesPerEpoch*n.epochs+" batches). You may need to use the repeat() function when building your dataset.");break}if(null!=e.value){const{xs:r,ys:i}=Pn(t,e.value),s={};s.batch=d,s.size=r[0].shape[0],await p.onBatchBegin(d,s);const a=[];if(null!=n.classWeight){const e=Mn(n.classWeight,t.outputNames);for(let t=0;t<e.length;++t)a.push(await Dn(i[t],null,e[t]))}const c=r.concat(i).concat(a),f=o(c);l.dispose(c);for(let t=0;t<u.length;++t){const e=u[t],n=f[t];s[e]=n,l.keep(n)}await p.onBatchEnd(d,s),De(s),d++,h++}if(r?h>=n.batchesPerEpoch:e.done){if(i){let e;e=Ln(n.validationData)?_(await t.evaluateDataset(n.validationData,{batches:n.validationBatches})):_(t.evaluate(s,a,{batchSize:null==n.validationBatchSize?32:n.validationBatchSize,verbose:0}));for(let n=0;n<t.metricsNames.length;++n)c["val_"+t.metricsNames[n]]=e[n]}break}if(t.stopTraining_)break}if(await p.onEpochEnd(m,c),m++,t.stopTraining_)break}return await p.onTrainEnd(),await t.history.syncData(),t.history}finally{t.isTraining=!1}}function Ln(t){return"function"==typeof t.iterator}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
function $n(t){l.util.assert(t>0&&Number.isInteger(t),()=>"batchSize is required to be a positive integer, but got "+t)}function Bn(t,e,n){return null==t?[null]:Array.isArray(t)?t.map(t=>gt(t,e,n-e)):gt(t,e,n-e)}function qn(t,e){return l.tidy(()=>null==t?null:Array.isArray(t)?t.map(t=>qn(t,e)):St(t,"int32"===e.dtype?e:e.toInt()))}function Vn(t,e){const n=[];let r=0,i=null;for(;r<t;)i=r+e,i>=t&&(i=t),n.push([r,i]),r=i;return n}async function Un(t,e,n,r={}){if(t.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");let i,s,a,o,u,c,h;t.isTraining=!0;try{const d=null==r.batchSize?32:r.batchSize;$n(d);const p=!1,f=await t.standardizeUserData(e,n,r.sampleWeight,r.classWeight,p,d);i=f[0],s=f[1],h=f[2];let b,y=!1;if(null!=r.validationData&&r.validationData.length>0){if(y=!0,2!==r.validationData.length)throw 3===r.validationData.length?new g("validationData including sample weights is not supported yet."):new m("When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; "+r.validationData+" is invalid.");a=r.validationData[0],o=r.validationData[1];const e=!0,n=await t.standardizeUserData(a,o,null,null,e,d);u=n[0],c=n[1],b=u.concat(c)}else if(null!=r.validationSplit&&r.validationSplit>0&&r.validationSplit<1){y=!0;const t=Math.floor(i[0].shape[0]*(1-r.validationSplit)),e=i[0].shape[0];u=Bn(i,t,e),i=Bn(i,0,t),c=Bn(s,t,e),s=Bn(s,0,t),b=u.concat(c)}else null!=r.validationSteps&&(y=!0);const v=i.concat(s).concat(h);t.checkTrainableWeightsConsistency();const w=t.makeTrainFunction(),x=t.getDedupedMetricsNames();let _,O;y?(t.makeTestFunction(),_=t.testFunction,O=x.slice().concat(x.map(t=>"val_"+t))):(_=null,b=[],O=x.slice());const S=Be(r.callbacks,r.yieldEvery);return await async function(t,e,n,r,i,s,a,o,u,c,h,d,p,f,b){null==i&&(i=32),null==s&&(s=1),null==h&&(h=!0),null==p&&(p=0);let y=!1;if(null!=u&&null!=c&&(y=!0),null!=b&&(y=!0,null==f))throw new m("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");const v=t.checkNumSamples(n,i,f,"steps_per_epoch");let w;null!=v&&(w=pt(0,v)),null==a&&(a=1);const{callbackList:x,history:_}=Ve(o,a,s,p,v,f,i,y,d);x.setModel(t),t.history=_,await x.onTrainBegin(),t.stopTraining_=!1;for(let a=p;a<s;++a){await x.onEpochBegin(a);const s={};if(null!=f)throw new g("stepsPerEpoch mode is not implemented yet.");{if("batch"===h)throw new g("batch shuffling is not implemneted yet");h&&l.util.shuffle(w);const a=Object(l.tensor1d)(w),o=Vn(v,i);for(let h=0;h<o.length;++h){const d={};if(await x.onBatchBegin(h,d),l.tidy(()=>{const p=o[h][0],f=o[h][1],m=gt(a,p,f-p);d.batch=h,d.size=f-p;const g=qn(n,m),b=e(g);for(let t=0;t<r.length;++t){const e=r[t],n=b[t];d[e]=n,l.keep(n)}if(h===o.length-1&&y){const e=t.testLoop(u,c,i);for(let t=0;t<r.length;++t){const n=r[t],i=e[t];l.keep(i),s["val_"+n]=i}}}),await x.onBatchEnd(h,d),De(d),t.stopTraining_)break}a.dispose()}if(await x.onEpochEnd(a,s),t.stopTraining_)break}return await x.onTrainEnd(),await t.history.syncData(),t.history}(t,w,v,x,d,r.epochs,r.verbose,S,_,b,r.shuffle,O,r.initialEpoch,null,null)}finally{t.isTraining=!1,Gn(i,e),Gn(s,n),Gn(u,a),Gn(c,o),null!=h&&l.dispose(h)}}function Wn(t){const e=[];t instanceof l.Tensor&&(t=[t]);for(let n=0;n<t.length;++n){const r=t[n];if(1===r.rank)e.push(mt(r,1));else{if(0===r.rank)throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");e.push(r)}}return e}function Gn(t,e){if(null==t)return;const n=[];if(e instanceof l.Tensor)n.push(e.id);else if(Array.isArray(e))e.forEach(t=>n.push(t.id));else if(null!=e)for(const t in e){const r=e[t];n.push(r.id)}const r=[];if(t instanceof l.Tensor)-1===n.indexOf(t.id)&&r.push(t);else if(Array.isArray(t))t.forEach(t=>{-1===n.indexOf(t.id)&&r.push(t)});else if(null!=t)for(const e in t){const i=t[e];-1===n.indexOf(i.id)&&r.push(i)}r.forEach(t=>{t.isDisposed||t.dispose()})}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function Hn(t){return Array.isArray(t)}function Kn(t){return!function(t){return t instanceof l.Tensor}(t)&&!Hn(t)}function Qn(t,e,n,r=!0,i=""){if(null==e||0===e.length){if(null!=t){let e=!1;if(Hn(t)&&t.length>0)e=!0;else if(Kn(t)){for(const n in t)if(t.hasOwnProperty(n)){e=!0;break}}else e=!0;if(e)throw new m(`Error when checking model ${i} expected no data, but got `+t)}return[]}if(null==t)return e.map(t=>null);let s;if(Kn(t)){t=t,s=[];for(const n of e){if(null==t[n])throw new m(`No data provided for "${n}". Need data for each key in: `+e);s.push(t[n])}}else if(Hn(t)){if((t=t).length!==e.length)throw new m(`Error when checking model ${i}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${e.length} Tensor(s), but instead got the following list of Tensor(s): `+t);s=t}else{if(t=t,e.length>1)throw new m(`The model ${i} expects ${e.length} Tensor(s), but only received one Tensor. Found: Tensor with shape `+t.shape);s=[t]}if(s=Wn(s),null!=n)for(let t=0;t<e.length;++t){if(null==n[t])continue;const a=s[t];if(a.shape.length!==n[t].length)throw new m(`Error when checking ${i}: expected ${e[t]} to have ${n[t].length} dimension(s). but got array with shape `+a.shape);for(let s=0;s<n[t].length;++s){if(0===s&&!r)continue;const o=a.shape[s],u=n[t][s];if(null!=u&&u>=0&&o!==u)throw new m(`Error when checking ${i}: expected ${e[t]} to have shape [${n[t]}], but got array with shape [${a.shape}].`)}}return s}function Xn(t,e,n,r=!0,i=""){let s;if(Array.isArray(t)){if(t.length!==e.length)throw new m(`Error when checking model ${i}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${e.length} Tensor(s), but instead got ${t.length} Tensors(s).`);s=t}else{if(e.length>1)throw new m(`The model expects ${e.length} ${i} Tensors, but only received one Tensor. Found: array with shape `+JSON.stringify(t.shape)+".");s=[t]}if(null!=n)for(let t=0;t<e.length;++t){if(null==n[t])continue;const a=s[t];if(a.shape.length!==n[t].length)throw new m(`Error when checking ${i}: expected ${e[t]} to have ${n[t].length} dimension(s), but got array with shape `+JSON.stringify(a.shape));for(let s=0;s<n[t].length;++s){if(0===s&&!r)continue;const o=a.shape[s],u=n[t][s];if(null!=u&&u!==o)throw new m(`Error when checking ${i}: expected ${e[t]} to have shape ${JSON.stringify(n[t])} but got array with shape ${JSON.stringify(a.shape)}.`)}}}class Yn extends En{constructor(t){super(t),this.isTraining=!1}summary(t,e,n=console.log){if(!this.built)throw new m("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data).");bn(this,t,e,n)}compile(t){if(null==t.loss&&(t.loss=[]),this.loss=t.loss,"string"==typeof t.optimizer)this.optimizer_=function(t){const e={Adagrad:()=>l.train.adagrad(.01),Adadelta:()=>l.train.adadelta(1,.95,d()),Adam:()=>l.train.adam(.001,.9,.999,d()),Adamax:()=>l.train.adamax(.002,.9,.999,d(),0),RMSProp:()=>l.train.rmsprop(.001,.9,0,d()),SGD:()=>l.train.sgd(.01)};if(e.adagrad=e.Adagrad,e.adadelta=e.Adadelta,e.adam=e.Adam,e.adamax=e.Adamax,e.rmsprop=e.RMSProp,e.sgd=e.SGD,t in e)return e[t]();throw new m("Unknown Optimizer "+t)}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */(t.optimizer),this.isOptimizerOwned=!0;else{if(!(t.optimizer instanceof l.Optimizer))throw new m("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=t.optimizer,this.isOptimizerOwned=!1}let e=[];if(Array.isArray(t.loss)||"string"==typeof t.loss||"function"==typeof t.loss)if(Array.isArray(t.loss)){if(t.loss.length!==this.outputs.length)throw new m(`When passing an Array as loss, it should have one entry per model output. The model has ${this.outputs.length} output(s), but you passed loss=${t.loss}.`);const n=t.loss;e=n.map(t=>nn(t))}else{const n=nn(t.loss);this.outputs.forEach(t=>{e.push(n)})}else{t.loss=t.loss;for(const e in t.loss)if(-1===this.outputNames.indexOf(e))throw new m(`Unknown entry in loss dictionary: "${e}". Only expected the following keys: `+this.outputNames);for(const n of this.outputNames)null==t.loss[n]&&console.warn(`Output "${n}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${n} during training`),e.push(nn(t.loss[n]))}this.lossFunctions=e,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let t=0;t<this.outputs.length;++t){const e=this.internalOutputShapes[t],n=this.outputNames[t];this.feedOutputNames.push(n),this.feedOutputShapes.push(e),this.feedLossFns.push(this.lossFunctions[t])}const n=[];this.metrics=t.metrics,this.metricsNames=["loss"],this.metricsTensors=[],it("loss",()=>{for(let t=0;t<this.outputs.length;++t){if(-1!==n.indexOf(t))continue;const e=this.lossFunctions[t];this.outputs.length>1&&(this.metricsTensors.push([e,t]),this.metricsNames.push(this.outputNames[t]+"_loss"))}});const r=function(t,e){if(null==t||Array.isArray(t)&&0===t.length)return e.map(t=>[]);let n;if("string"==typeof t||"function"==typeof t)n=[t];else{if(!Array.isArray(t)&&"object"!=typeof t)throw new TypeError("Type of metrics argument not understood. Expected an string,function, Array, or Object, found: "+t);n=t}if(Array.isArray(n))return e.map(t=>n);{const t=[];for(const r of e){let e=n.hasOwnProperty(r)?n[r]:[];Array.isArray(e)||(e=[e]),t.push(e)}return t}}(t.metrics,this.outputNames),i=(t,e,n)=>{this.outputNames.length>1&&(e=this.outputNames[t]+"_"+e),this.metricsNames.push(e),this.metricsTensors.push([n,t])};it("metric",()=>{for(let t=0;t<this.outputs.length;++t){if(-1!==n.indexOf(t))continue;(e=>{let n,r,s;for(const a of e){if("string"==typeof a&&-1!==["accuracy","acc","crossentropy","ce"].indexOf(a)){const e=this.internalOutputShapes[t];let i;1===e[e.length-1]||this.lossFunctions[t]===Je?-1!==["accuracy","acc"].indexOf(a)?r=rn:-1!==["crossentropy","ce"].indexOf(a)&&(r=cn):this.lossFunctions[t]===Ye?-1!==["accuracy","acc"].indexOf(a)?r=ln:-1!==["crossentropy","ce"].indexOf(a)&&(r=dn):-1!==["accuracy","acc"].indexOf(a)?r=sn:-1!==["crossentropy","ce"].indexOf(a)&&(r=hn),-1!==["accuracy","acc"].indexOf(a)?i="acc":-1!==["crossentropy","ce"].indexOf(a)&&(i="ce"),s=r,n=""+i}else{const t=fn(a);s=t,n=""+mn(a)}let e;it(n,()=>{e=s}),i(t,n,e)}})(r[t])}}),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){null!=this.collectedTrainableWeights&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")}evaluate(t,e,n={}){const r=null==n.batchSize?32:n.batchSize;$n(r);const i=this.standardizeUserDataXY(t,e,!0,r);try{const s=i[0].concat(i[1]);this.makeTestFunction();const a=this.testFunction;return x(this.testLoop(a,s,r,n.verbose,n.steps))}finally{Gn(i[0],t),Gn(i[1],e)}}async evaluateDataset(t,e){return this.makeTestFunction(),async function(t,e,n){const r=null!=(n=n||{}).batches,i=t.testFunction;let s=[];if(n.verbose>0)throw new g("Verbose mode is not implemented yet.");l.util.assert(!r||n.batches>0&&Number.isInteger(n.batches),()=>"Test loop expects `batches` to be a positive integer, but received "+JSON.stringify(n.batches));const a="function"==typeof e.next?e:await e.iterator();let o=0,u=0;for(;!r||u<n.batches;){const e=await a.next();if(s=l.tidy(()=>{if(e.value){const{xs:n,ys:r}=Pn(t,e.value),a=n.concat(r),c=l.tidy(()=>i(a));if(l.dispose(a),0===u)for(let t=0;t<c.length;++t)s.push(Object(l.scalar)(0));const h=a[0].shape[0];for(let t=0;t<c.length;++t){const e=c[t],n=s[t];s[t]=l.tidy(()=>l.add(s[t],l.mul(h,e))),u>0&&l.dispose(n)}l.dispose(c),o+=h,++u}return s}),e.done){r&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${n.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let t=0;t<s.length;++t){const e=s[t];s[t]=l.div(s[t],o),l.dispose(e)}return x(s)}(this,t,e)}checkNumSamples(t,e,n,r="steps"){let i;if(null!=n){if(i=null,null!=e)throw new m(`If ${r} is set, batchSize must be null or undefined.Got batchSize = `+e)}else{if(null==t)throw new m("Either the input data should have a defined shape, or "+r+" shoud be specified.");i=Array.isArray(t)?t[0].shape[0]:t.shape[0]}return i}execute(t,e){if(Array.isArray(e)&&0===e.length)throw new m("`outputs` is an empty Array, which is not allowed.");const n=Array.isArray(e),r=n?e:[e],i=this.retrieveSymbolicTensors(r),s=new Sn;if(t instanceof l.Tensor&&(t=[t]),Array.isArray(t)){if(t.length!==this.inputs.length)throw new m(`The number of inputs provided (${t.length}) does not match the number of inputs of this model (${this.inputs.length}).`);for(let e=0;e<this.inputs.length;++e)s.add(this.inputs[e],t[e])}else for(const e of this.inputs){const n=t[e.name];if(null==n)throw new m("No value is provided for the model's input "+e.name);s.add(e,n)}const a=Cn(i,s);return n?a:a[0]}retrieveSymbolicTensors(t){const e=y(null,t.length);let n=t.length;for(const r of this.layers){const i=Array.isArray(r.output)?r.output:[r.output],s=i.map(t=>t.name);for(let r=0;r<t.length;++r){const a=s.indexOf(t[r]);if(-1!==a&&(e[r]=i[a],n--),0===n)break}if(0===n)break}if(n>0){const n=[];throw e.forEach((e,r)=>{null==e&&n.push(t[r])}),new m("Cannot find SymbolicTensors for output name(s): "+JSON.stringify(n))}return e}predictLoop(t,e=32,n=!1){return l.tidy(()=>{const r=this.checkNumSamples(t);if(n)throw new g("Verbose predictLoop() is not implemented yet.");const i=Vn(r,e),s=this.outputs.map(t=>[]);for(let e=0;e<i.length;++e){l.tidy(()=>{const n=i[e][0],r=i[e][1],s=Bn(t,n,r),a=[];if(Array.isArray(s))for(let t=0;t<s.length;++t)a.push({key:this.inputs[t],value:s[t]});else a.push({key:this.inputs[0],value:s});const o=new Sn(a);return Cn(this.outputs,o)}).forEach((t,e)=>s[e].push(t))}return x(s.map(t=>l.concat(t,0)))})}predict(t,e={}){const n=Wn(t);Xn(n,this.inputNames,this.feedInputShapes,!1);try{const r=null==e.batchSize?32:e.batchSize;return $n(r),this.predictLoop(n,r)}finally{Gn(n,t)}}predictOnBatch(t){Xn(t,this.inputNames,this.feedInputShapes,!0);const e=(Array.isArray(t)?t[0]:t).shape[0];return this.predictLoop(t,e)}standardizeUserDataXY(t,e,n=!0,r){if(null==this.optimizer_)throw new f("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const i=[];for(let t=0;t<this.feedOutputShapes.length;++t){const e=this.feedOutputShapes[t];this.feedLossFns[t]===Ye?i.push(e.slice(0,e.length-1).concat([1])):i.push(e)}if(function(t,e,n){const r=N(t.map(t=>t.shape[0]));r.sort();const i=N(e.map(t=>t.shape[0]));if(i.sort(),r.length>1)throw new m("All input Tensors (x) should have the same number of samples. Got array shapes: "+JSON.stringify(t.map(t=>t.shape)));if(i.length>1)throw new m("All target Tensors (y) should have the same number of samples. Got array shapes: "+JSON.stringify(e.map(t=>t.shape)));if(r.length>0&&i.length>0&&!l.util.arraysEqual(r,i))throw new m(`Input Tensors should have the same number of samples as target Tensors. Found ${r[0]} input sample(s) and ${i[0]} target sample(s).`)}(t=Qn(t,this.feedInputNames,this.feedInputShapes,!1,"input"),e=Qn(e,this.feedOutputNames,i,!1,"target")),function(t,e,n){const r=[Ge,Je,Xe];for(let i=0;i<t.length;++i){const s=t[i],a=e[i],o=n[i];if(null!=a){if(a===Xe&&1===s.shape[s.shape.length-1])throw new m(`You are passing a target array of shape ${s.shape} while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].`);if(-1!==r.indexOf(a)){const t=s.shape.slice(1),e=o.slice(1);for(let n=0;n<t.length;++n){const r=t[n],i=e[n];if(null!=i&&r!==i)throw new m(`A target Tensor with shape ${s.shape} was passed for an output of shape ${o}, while using a loss function that expects targets to have the same shape as the output.`)}}}}}(e,this.feedLossFns,this.feedOutputShapes),this.stateful&&null!=r&&r>0&&t[0].shape[0]%r!=0)throw new m(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${r}. Found: ${t[0].shape[0]} sample(s).`);return[t,e]}async standardizeUserData(t,e,n,r,i=!0,s){const[a,o]=this.standardizeUserDataXY(t,e,i,s);if(null!=n)throw new Error("sample weight is not supported yet.");let u=null;if(null!=r){const t=Mn(r,this.outputNames);u=[];for(let e=0;e<t.length;++e)u.push(await Dn(o[e],null,t[e]))}return[a,o,u]}testLoop(t,e,n,r=0,i){return l.tidy(()=>{const s=this.checkNumSamples(e,n,i,"steps"),a=[];if(r>0)throw new g("Verbose mode is not implemented yet.");if(null!=i)throw new g("steps mode in testLoop() is not implemented yet");{const r=Vn(s,n),i=Object(l.tensor1d)(pt(0,s));for(let n=0;n<r.length;++n){const s=r[n][0],o=r[n][1],u=gt(i,s,o-s),c=qn(e,u),h=t(c);if(0===n)for(let t=0;t<h.length;++t)a.push(Object(l.scalar)(0));for(let t=0;t<h.length;++t){const e=h[t];a[t]=l.add(a[t],l.mul(o-s,e))}}for(let t=0;t<a.length;++t)a[t]=l.div(a[t],s)}return a})}getDedupedMetricsNames(){const t=this.metricsNames,e=[];for(let n=0;n<t.length;++n){const r=t[n];let i=r;if(w(t,r)>1){i+="_"+w(t.slice(0,n),r)}e.push(i)}return e}makeTrainFunction(){return t=>{const e=[],n=t.slice(0,this.inputs.length),r=t.slice(this.inputs.length,this.inputs.length+this.outputs.length),i=t.slice(this.inputs.length+this.outputs.length,this.inputs.length+2*this.outputs.length),s=[],a=this.collectedTrainableWeights.map(t=>t.read());return[this.optimizer_.minimize(()=>{const t=[];for(let e=0;e<this.inputs.length;++e)t.push({key:this.inputs[e],value:n[e]});const a=new Sn(t),o=Cn(this.outputs,a,{training:!0});let u;for(let t=0;t<this.lossFunctions.length;++t){let n=(0,this.lossFunctions[t])(r[t],o[t]);null!=i[t]&&(n=Rn(n,i[t]));const s=l.mean(n);e.push(s),u=0===t?n:l.add(u,n)}for(let t=0;t<this.metricsTensors.length;++t){let n;if(this.outputs.length>1&&t<this.outputs.length)n=e[t];else{const e=this.metricsTensors[t][0],i=this.metricsTensors[t][1];n=l.mean(e(r[i],o[i]))}l.keep(n),s.push(n)}return u=l.mean(u),this.calculateLosses().forEach(t=>{u=l.add(u,t)}),u},!0,a)].concat(s)}}makeTestFunction(){this.testFunction=t=>l.tidy(()=>{const e=[];let n;const r=t.slice(0,this.inputs.length),i=t.slice(this.inputs.length,this.inputs.length+this.outputs.length),s=[];for(let t=0;t<this.inputs.length;++t)s.push({key:this.inputs[t],value:r[t]});const a=new Sn(s),o=Cn(this.outputs,a);for(let t=0;t<this.lossFunctions.length;++t){const r=this.lossFunctions[t],s=l.mean(r(i[t],o[t]));n=0===t?s:l.add(n,s),e.push(n)}for(let t=0;t<this.metricsTensors.length;++t){const n=this.metricsTensors[t][0],r=this.metricsTensors[t][1],s=l.mean(n(i[r],o[r]));e.push(s)}return e})}async fit(t,e,n={}){return Un(this,t,e,n)}async fitDataset(t,e){return zn(this,t,e)}async trainOnBatch(t,e){const n=await this.standardizeUserData(t,e),r=n[0],i=n[1],s=this.makeTrainFunction()(r.concat(i)),a=[];for(const t of s){const e=await t.data();a.push(e[0])}return l.dispose(s),x(a)}getNamedWeights(t){const e=[],n=null!=t&&t.trainableOnly,r=n?this.trainableWeights:this.weights,i=this.getWeights(n);for(let t=0;t<r.length;++t)n&&!r[t].trainable||e.push({name:r[t].originalName,tensor:i[t]});return e}set stopTraining(t){this.stopTraining_=t}get stopTraining(){return this.stopTraining_}get optimizer(){return this.optimizer_}set optimizer(t){this.optimizer_!==t&&(this.optimizer_=t,this.isOptimizerOwned=!1)}dispose(){const t=super.dispose();if(0===t.refCountAfterDispose&&null!=this.optimizer&&this.isOptimizerOwned){const e=l.memory().numTensors;this.optimizer_.dispose(),t.numDisposedVariables+=e-l.memory().numTensors}return t}getLossIdentifiers(){let t;if("string"==typeof this.loss)t=O(this.loss);else if(Array.isArray(this.loss)){for(const t of this.loss)if("string"!=typeof t)throw new Error("Serialization of non-string loss is not supported.");t=this.loss.map(t=>O(t))}else{const e=Object.keys(this.loss);t={};const n=this.loss;for(const r of e){if("string"!=typeof n[r])throw new Error("Serialization of non-string loss is not supported.");t[r]=O(n[r])}}return t}getMetricIdentifiers(){if("string"==typeof this.metrics||"function"==typeof this.metrics)return[O(mn(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map(t=>O(mn(t)));{const t={};for(const e in this.metrics)t[e]=O(mn(this.metrics[e]));return t}}getTrainingConfig(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}}loadTrainingConfig(t){if(null!=t.weighted_metrics)throw new Error("Loading weight_metrics is not supported yet.");if(null!=t.loss_weights)throw new Error("Loading loss_weights is not supported yet.");if(null!=t.sample_weight_mode)throw new Error("Loading sample_weight_mode is not supported yet.");const e=Ue(_n(t.optimizer_config));let n,r;if("string"==typeof t.loss)n=S(t.loss);else if(Array.isArray(t.loss))n=t.loss.map(t=>S(t));else if(null!=t.loss){n={};for(const e in t.loss)n[e]=S(t.loss[e])}if(Array.isArray(t.metrics))r=t.metrics.map(t=>S(t));else if(null!=t.metrics){r={};for(const e in t.metrics)r[e]=S(t.metrics[e])}this.compile({loss:n,metrics:r,optimizer:e})}async save(t,e){if("string"==typeof t){const e=l.io.getSaveHandlers(t);if(0===e.length)throw new m(`Cannot find any save handlers for URL '${t}'`);if(e.length>1)throw new m(`Found more than one (${e.length}) save handlers for URL '${t}'`);t=e[0]}if(null==t.save)throw new m("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const n=await l.io.encodeWeights(this.getNamedWeights(e)),r={modelTopology:this.toJSON(null,!1),format:"layers-model",generatedBy:"TensorFlow.js tfjs-layers v"+On,convertedBy:null};if(null!=e&&e.includeOptimizer&&null!=this.optimizer){r.trainingConfig=this.getTrainingConfig();const t="optimizer",{data:e,specs:i}=await l.io.encodeWeights(await this.optimizer.getWeights(),t);n.specs.push(...i),n.data=l.io.concatenateArrayBuffers([n.data,e])}if(null!=this.userDefinedMetadata){const t=!0;gn(this.userDefinedMetadata,this.name,t),r.userDefinedMetadata=this.userDefinedMetadata}return r.weightData=n.data,r.weightSpecs=n.specs,t.save(r)}setUserDefinedMetadata(t){gn(t,this.name),this.userDefinedMetadata=t}getUserDefinedMetadata(){return this.userDefinedMetadata}}Yn.className="Model",l.serialization.registerClass(Yn);class Jn extends Yn{}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
async function Zn(t,e){"modelTopology"in t||(t={modelTopology:t});let n=(t=t).modelTopology;null!=n.model_config&&(n=n.model_config);const r=Ue(_n(n),e);if(null!=t.weightsManifest){const e=await l.io.loadWeights(t.weightsManifest,t.pathPrefix,r.weights.map(t=>t.originalName)),n={};for(const t of r.weights)n[t.originalName]=e[t.originalName];r.loadWeights(n),Object(l.dispose)(e)}return r}async function tr(t,e){if(null==e&&(e={}),"string"==typeof t){const n=l.io.getLoadHandlers(t,e);if(0===n.length)n.push(l.io.browserHTTPRequest(t,e));else if(n.length>1)throw new m(`Found more than one (${n.length}) load handlers for URL '${t}'`);t=n[0]}return async function(t,e,n){null==n&&(n={});if(null==t.load)throw new m("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const r=await t.load();let i=r.modelTopology;null!=i.model_config&&(i=i.model_config);const s=null==n.strict||n.strict,a=null!=r.weightData&&null!=r.weightSpecs&&s,o=Ue(_n(i),e,a),u=r.trainingConfig;null!=u&&o.loadTrainingConfig(u);null!=r.userDefinedMetadata&&o.setUserDefinedMetadata(r.userDefinedMetadata);if(null!=r.weightData){if(null==r.weightSpecs)throw new m("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");const{modelWeights:t,optimizerWeights:e}=function(t,e){const n=l.io.decodeWeights(t,e),r={},i=[];return e.forEach(t=>{"optimizer"===t.group?i.push({name:t.name,tensor:n[t.name]}):r[t.name]=n[t.name]}),{modelWeights:r,optimizerWeights:i}}(r.weightData,r.weightSpecs);o.loadWeights(t,s),null!=o.optimizer&&e.length>0&&await o.optimizer.setWeights(e),Object(l.dispose)(t),Object(l.dispose)(e.map(t=>t.tensor))}return o}(t,void 0,e)}Jn.className="Functional",l.serialization.registerClass(Jn);class er extends Yn{constructor(t){if(super({inputs:[],outputs:[]}),t=t||{},this.trainable=!0,this.built=!1,this.name=null!=t.name?t.name:ge("sequential_"),null!=t.layers)for(const e of t.layers)this.add(e)}checkShape(t){if(t.inboundNodes[0].outputTensors[0].shape.some(t=>t<0))throw new m("Negative dimension size caused by adding layer "+t.name+" with input shape ["+t.inboundNodes[0].inputTensors[0].shape+"]")}add(t){const e=t instanceof er||t instanceof Yn;let n;if(e){if(n=t,1!==n.outputs.length)throw new m("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(1!==n.inputs.length)throw new m("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(0===this.outputs.length){if(0===t.inboundNodes.length){if(null==t.batchInputShape)throw new m("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");const e=je({batchShape:t.batchInputShape,dtype:t.dtype,name:t.name+"_input"});t.apply(e)}if(e)this.outputs=n.outputs,this.inputs=n.inputs;else{if(1!==t.inboundNodes.length)throw new m(`A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer ${t.name} which has ${t.inboundNodes.length} pre-existing inbound connections.`);if(1!==t.inboundNodes[0].outputTensors.length)throw new m("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(t),this.outputs=[t.inboundNodes[0].outputTensors[0]],this.inputs=function t(e,n,r){if((null==n||null!=r&&r>0)&&(n=e.sourceLayer,r=e.nodeIndex),0===n.inboundNodes.length)return[e];{const e=n.inboundNodes[r];if(0===e.inboundLayers.length)return e.inputTensors;{const n=[];for(let r=0;r<e.inboundLayers.length;r++){const i=t(e.inputTensors[r],e.inboundLayers[r],e.nodeIndices[r]);for(const t of i)-1===n.indexOf(t)&&n.push(t)}return n}}}(this.outputs[0])}this.inboundNodes=[],new Ae({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:y(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(t=>t.shape),outputShapes:this.outputs[0].shape})}else{const e=t.apply(this.outputs[0]);if(Array.isArray(e))throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(t),this.outputs=[e],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(t),this.built=!1}pop(){if(0===this.layers.length)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),0===this.layers.length)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else{const t=this.layers.length-1;this.layers[t].outboundNodes=[],this.outputs=[this.layers[t].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}}call(t,e){return null==this.model&&this.build(),this.model.call(t,e)}build(t){if(we(t),0===this.inputs.length||0===this.outputs.length)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new Yn({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supportsMasking,this.inputLayers=this.model.inputLayers,this.inputLayersNodeIndices=this.model.inputLayersNodeIndices,this.inputLayersTensorIndices=this.model.inputLayersTensorIndices,this.outputLayers=this.model.outputLayers,this.outputLayersNodeIndices=this.model.outputLayersNodeIndices,this.outputLayersTensorIndices=this.model.outputLayersTensorIndices,this.nodesByDepth=this.model.nodesByDepth,this.containerNodes=this.model.containerNodes,this.outputNames=this.model.outputNames,this.inputNames=this.model.inputNames,this.built=!0}countParams(){return this.built||this.build(),super.countParams()}summary(t,e,n=console.log){this.built||this.build(),super.summary(t,e,n)}setWeights(t){null==this.model&&this.build(),this.model.setWeights(t)}evaluate(t,e,n={}){if(!this.built)throw new f("The model needs to be compiled before being used.");return this.model.evaluate(t,e,n)}async evaluateDataset(t,e){if(!this.built)throw new f("The model needs to be compiled before being used.");return this.model.evaluateDataset(t,e)}predict(t,e={}){return null==this.model&&this.build(),this.model.predict(t,e)}predictOnBatch(t){return null==this.model&&this.build(),this.model.predictOnBatch(t)}compile(t){this.build(),this.model.compile(t),this.optimizer_=this.model.optimizer,this.isOptimizerOwned=this.model.isOptimizerOwned,this.loss=this.model.loss,this.metrics=this.model.metrics,this.metricsTensors=this.model.metricsTensors,this.metricsNames=this.model.metricsNames}get optimizer(){return null==this.model?void 0:this.model.optimizer}set optimizer(t){this.model.optimizer=t}async fit(t,e,n={}){if(!this.built)throw new f("The model needs to be compiled before being used.");return this.model.fit(t,e,n)}async fitDataset(t,e){if(!this.built)throw new f("The model needs to be compiled before being used.");return this.model.fitDataset(t,e)}async trainOnBatch(t,e){return this.model.trainOnBatch(t,e)}static fromConfig(t,e,n={},r=!1){let i,s={};if(e instanceof Array){if(null==e[0].className||"Merge"===e[0].className)throw new m("Legacy serialization format not supported yet.");i=e}else l.util.assert(null!=e.layers,()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field."),i=e.layers,delete e.layers,s=e;const a=new t(s);if(!(a instanceof er))throw new g("Sequential.fromConfig called on non-Sequential input: "+a);for(const t of i){const e=Ue(t,void 0,r);r&&e.setFastWeightInitDuringBuild(!0),a.add(e)}return a}set stopTraining(t){if(null==this.model)throw new m("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=t}get stopTraining(){if(null==this.model)throw new m("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}getConfig(){const t=[];for(const e of this.layers){const n={};n.className=e.getClassName(),n.config=e.getConfig(),t.push(n)}return{name:this.name,layers:t}}}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
function nr(t){return new Yn(t)}function rr(t){return new er(t)}function ir(t,e){return null==e&&(e={}),tr(t,e)}function sr(t){return je(t)}function ar(t,e){qe.registerCallbackConstructor(t,e)}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */er.className="Sequential",l.serialization.registerClass(er);class or extends l.serialization.Serializable{getConfig(){return{}}}class ur extends or{apply(t,e=1){return function(t,e=1){if(1!==e)throw new g(`Support for alpha values other than 1 (${e}) is not implemented yet.`);return l.elu(t)}(t,e)}}ur.className="elu",l.serialization.registerClass(ur);class cr extends or{apply(t){return l.selu(t)}}cr.className="selu",l.serialization.registerClass(cr);class lr extends or{apply(t){return l.relu(t)}}lr.className="relu",l.serialization.registerClass(lr);class hr extends or{apply(t){return Object(l.tidy)(()=>l.minimum(6,l.relu(t)))}}hr.className="relu6",l.serialization.registerClass(hr);class dr extends or{apply(t){return t}}dr.className="linear",l.serialization.registerClass(dr);class pr extends or{apply(t){return l.sigmoid(t)}}pr.className="sigmoid",l.serialization.registerClass(pr);class fr extends or{apply(t){return function(t){return Object(l.tidy)(()=>{const e=l.add(.5,l.mul(.2,t));return l.clipByValue(e,0,1)})}(t)}}fr.className="hardSigmoid",l.serialization.registerClass(fr);class mr extends or{apply(t){return l.softplus(t)}}mr.className="softplus",l.serialization.registerClass(mr);class gr extends or{apply(t){return function(t){return Object(l.tidy)(()=>l.div(t,l.abs(t).add(1)))}(t)}}gr.className="softsign",l.serialization.registerClass(gr);class br extends or{apply(t){return l.tanh(t)}}br.className="tanh",l.serialization.registerClass(br);class yr extends or{apply(t,e=-1){return l.softmax(t,e)}}yr.className="softmax",l.serialization.registerClass(yr);class vr extends or{apply(t,e=-1){return l.logSoftmax(t,e)}}vr.className="logSoftmax",l.serialization.registerClass(vr);class wr extends or{apply(t,e=1){return Object(l.tidy)(()=>l.sigmoid(t.mul(e)).mul(t))}}function xr(t){return t.getClassName()}function _r(t,e={}){return C(t,l.serialization.SerializationMap.getMap().classNameMap,e,"activation")}function Or(t){if(null==t){const t={className:"linear",config:{}};return _r(t)}if("string"==typeof t){const e={};return e.className=t,e.config={},_r(e)}return t instanceof or?t:_r(t)}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function Sr(t){if(null!=t&&"object"!=typeof t)throw new Error("Argument to L1L2 regularizer's constructor is expected to be an object, but received: "+t)}wr.className="swish",l.serialization.registerClass(wr);class kr extends l.serialization.Serializable{}class Tr extends kr{constructor(t){super(),Sr(t),this.l1=null==t||null==t.l1?.01:t.l1,this.l2=null==t||null==t.l2?.01:t.l2,this.hasL1=0!==this.l1,this.hasL2=0!==this.l2}apply(t){return Object(l.tidy)(()=>{let e=Object(l.zeros)([1]);return this.hasL1&&(e=Object(l.add)(e,Object(l.sum)(l.mul(this.l1,Object(l.abs)(t))))),this.hasL2&&(e=Object(l.add)(e,Object(l.sum)(l.mul(this.l2,kt(t))))),e.asScalar()})}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(t,e){return new t({l1:e.l1,l2:e.l2})}}Tr.className="L1L2",l.serialization.registerClass(Tr);const Cr={l1l2:"L1L2"};function Ar(t){return T(t)}function Nr(t,e={}){return C(t,l.serialization.SerializationMap.getMap().classNameMap,e,"regularizer")}function Ir(t){if(null==t)return null;if("string"==typeof t){return Nr({className:t in Cr?Cr[t]:t,config:{}})}return t instanceof kr?t:Nr(t)}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */class Er extends Ie{constructor(t){super(null==t?{}:t),this.supportsMasking=!0,null!=t&&(this.maxValue=t.maxValue)}call(t,e){t=ve(t);let n=Object(l.relu)(t);return null!=this.maxValue&&(n=Object(l.clipByValue)(n,0,this.maxValue)),n}computeOutputShape(t){return t}getConfig(){const t={maxValue:this.maxValue},e=super.getConfig();return Object.assign(t,e),t}}Er.className="ReLU",l.serialization.registerClass(Er);class jr extends Ie{constructor(t){super(null==t?{}:t),this.DEFAULT_ALPHA=.3,null==t&&(t={}),this.alpha=null==t.alpha?this.DEFAULT_ALPHA:t.alpha}call(t,e){const n=ve(t);return Object(l.leakyRelu)(n,this.alpha)}computeOutputShape(t){return t}getConfig(){const t={alpha:this.alpha},e=super.getConfig();return Object.assign(t,e),t}}jr.className="LeakyReLU",l.serialization.registerClass(jr);class Mr extends Ie{constructor(t){if(super(null==t?{}:t),this.DEFAULT_ALPHA_INITIALIZER="zeros",null==t&&(t={}),this.supportsMasking=!0,this.alphaInitializer=Yt(t.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=Ir(t.alphaRegularizer),this.alphaConstraint=U(t.alphaConstraint),null==t.sharedAxes)this.sharedAxes=null;else if(Array.isArray(t.sharedAxes))this.sharedAxes=t.sharedAxes;else{if("number"!=typeof t.sharedAxes)throw new m("Expected sharedAxes to be a number or an array of numbers, but got "+t.sharedAxes);this.sharedAxes=[t.sharedAxes]}}build(t){const e=(t=we(t)).slice(1);if(null!=this.sharedAxes)for(const t of this.sharedAxes)e[t-1]=1;this.alpha=this.addWeight("alpha",e,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);const n={};if(null!=this.sharedAxes)for(let e=1;e<t.length;++e)n[e]=t[e];this.inputSpec=[new ke({ndim:t.length,axes:n})],this.built=!0}call(t,e){return t=ve(t),Object(l.prelu)(t,this.alpha.read())}getConfig(){const t={alphaInitializer:Xt(this.alphaInitializer),alphaRegularizer:Ar(this.alphaRegularizer),alphaConstraint:q(this.alphaConstraint),sharedAxes:this.sharedAxes},e=super.getConfig();return Object.assign(t,e),t}}Mr.className="PReLU",l.serialization.registerClass(Mr);class Dr extends Ie{constructor(t){if(super(null==t?{}:t),this.DEFAULT_ALPHA=1,null==t&&(t={}),null!=t.alpha&&t.alpha!==this.DEFAULT_ALPHA)throw new g(`Non-default alpha value (${t.alpha}) is not supported by the ELU layer yet.`);this.alpha=null==t.alpha?this.DEFAULT_ALPHA:t.alpha}call(t,e){const n=ve(t);return Object(l.elu)(n)}computeOutputShape(t){return t}getConfig(){const t={alpha:this.alpha},e=super.getConfig();return Object.assign(t,e),t}}Dr.className="ELU",l.serialization.registerClass(Dr);class Rr extends Ie{constructor(t){super(null==t?{}:t),this.DEFAULT_THETA=1,null==t&&(t={}),this.theta=null==t.theta?this.DEFAULT_THETA:t.theta}call(t,e){const n=ve(t);return n.mul(ft(n.greater(this.theta),"float32"))}computeOutputShape(t){return t}getConfig(){const t={theta:this.theta},e=super.getConfig();return Object.assign(t,e),t}}Rr.className="ThresholdedReLU",l.serialization.registerClass(Rr);class Pr extends Ie{constructor(t){super(null==t?{}:t),this.DEFAULT_AXIS=1,null==t&&(t={}),this.softmax=(new yr).apply,this.axis=null==t.axis?this.DEFAULT_AXIS:t.axis}call(t,e){const n=ve(t);return this.softmax(n,this.axis)}computeOutputShape(t){return t}getConfig(){const t={axis:this.axis},e=super.getConfig();return Object.assign(t,e),t}}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
function Fr(t,e,n){if("number"==typeof t)return y(t,e);if(t.length!==e)throw new m(`The ${n} argument must be an integer or tuple of ${e} integers. Received: ${t.length} elements.`);for(let i=0;i<e;++i){const s=t[i];if((r=s)!==parseInt(r.toString(),10))throw new m(`The ${n} argument must be an integer or tuple of ${e} integers. Received: ${JSON.stringify(t)} including a non-integer number `+s)}return t;var r}function zr(t,e,n,r,i=1){if(null==t)return t;let s;return s="same"===n?t:t-(e+(e-1)*(i-1))+1,Math.floor((s+r-1)/r)}function Lr(t,e,n,r){if(null==t)return null;if("valid"===r)t=t*e+dt([n-e,0]);else{if("same"!==r)throw new m(`Unsupport padding mode: ${r}.`);t*=e}return t}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function $r(t,e){return Object(l.tidy)(()=>(tt(e),"channelsFirst"===e?l.transpose(t,[0,2,3,1]):t))}function Br(t,e){return Object(l.tidy)(()=>(tt(e),"channelsFirst"===e?l.transpose(t,[0,2,3,4,1]):t))}function qr(t,e,n,r=1,i="valid",s,a=1){return Object(l.tidy)(()=>{if(null==s&&(s="channelsLast"),tt(s),3!==t.shape.length)throw new m("The input of a conv1dWithBias operation should be 3, but is "+t.shape.length+" instead.");if(3!==e.shape.length)throw new m("The kernel for a conv1dWithBias operation should be 3, but is "+e.shape.length+" instead");if(null!=n&&1!==n.shape.length)throw new m("The bias for a conv1dWithBias operation should be 1, but is "+e.shape.length+" instead");if("channelsFirst"===s&&(t=l.transpose(t,[0,2,1])),"causal"===i)throw new g("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let o=l.conv1d(t,e,r,"same"===i?"same":"valid","NWC",a);return null!=n&&(o=Ct(o,n)),o})}function Vr(t,e,n,r=[1,1],i="valid",s,a,o=null){return Object(l.tidy)(()=>{if(null==s&&(s="channelsLast"),tt(s),3!==t.rank&&4!==t.rank)throw new m(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${t.rank}.`);if(3!==e.rank&&4!==e.rank)throw new m(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${t.rank}.`);let u=$r(t,s);if("causal"===i)throw new g("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return u=l.fused.conv2d({x:u,filter:e,strides:r,pad:"same"===i?"same":"valid",dilations:a,dataFormat:"NHWC",bias:n,activation:o}),"channelsFirst"===s&&(u=l.transpose(u,[0,3,1,2])),u})}function Ur(t,e,n,r=[1,1,1],i="valid",s,a){return Object(l.tidy)(()=>{if(null==s&&(s="channelsLast"),tt(s),4!==t.rank&&5!==t.rank)throw new m("conv3dWithBias expects input to be of rank 4 or 5, but received "+t.rank+".");if(4!==e.rank&&5!==e.rank)throw new m("conv3dWithBias expects kernel to be of rank 4 or 5, but received "+t.rank+".");let o=Br(t,s);if("causal"===i)throw new g("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return o=l.conv3d(o,e,r,"same"===i?"same":"valid","NDHWC",a),null!=n&&(o=Ct(o,n)),"channelsFirst"===s&&(o=l.transpose(o,[0,4,1,2,3])),o})}Pr.className="Softmax",l.serialization.registerClass(Pr);class Wr extends Ie{constructor(t,e){if(super(e),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",Wr.verifyArgs(e),this.rank=t,M(this.rank,"rank"),1!==this.rank&&2!==this.rank&&3!==this.rank)throw new g(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=Fr(e.kernelSize,t,"kernelSize"),this.strides=Fr(null==e.strides?1:e.strides,t,"strides"),this.padding=null==e.padding?"valid":e.padding,et(this.padding),this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,tt(this.dataFormat),this.activation=Or(e.activation),this.useBias=null==e.useBias||e.useBias,this.biasInitializer=Yt(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=U(e.biasConstraint),this.biasRegularizer=Ir(e.biasRegularizer),this.activityRegularizer=Ir(e.activityRegularizer),this.dilationRate=Fr(null==e.dilationRate?1:e.dilationRate,t,"dilationRate"),1===this.rank&&Array.isArray(this.dilationRate)&&1!==this.dilationRate.length)throw new m("dilationRate must be a number or an array of a single number for 1D convolution, but received "+JSON.stringify(this.dilationRate));if(2===this.rank){if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate];else if(2!==this.dilationRate.length)throw new m("dilationRate must be a number or array of two numbers for 2D convolution, but received "+JSON.stringify(this.dilationRate))}else if(3===this.rank)if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(3!==this.dilationRate.length)throw new m("dilationRate must be a number or array of three numbers for 3D convolution, but received "+JSON.stringify(this.dilationRate))}static verifyArgs(t){if(v("kernelSize"in t,"required key 'kernelSize' not in config"),"number"!=typeof t.kernelSize&&!j(t.kernelSize,"number",1,3))throw new m(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(t.kernelSize)}.`)}getConfig(){const t={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:xr(this.activation),useBias:this.useBias,biasInitializer:Xt(this.biasInitializer),biasRegularizer:Ar(this.biasRegularizer),activityRegularizer:Ar(this.activityRegularizer),biasConstraint:q(this.biasConstraint)},e=super.getConfig();return Object.assign(t,e),t}}class Gr extends Wr{constructor(t,e){super(t,e),this.kernel=null,Gr.verifyArgs(e),this.filters=e.filters,M(this.filters,"filters"),this.kernelInitializer=Yt(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=U(e.kernelConstraint),this.kernelRegularizer=Ir(e.kernelRegularizer)}build(t){t=we(t);const e="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[e])throw new m("The channel dimension of the input should be defined. Found "+t[e]);const n=t[e],r=this.kernelSize.concat([n,this.filters]);this.kernel=this.addWeight("kernel",r,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:{[e]:n}}],this.built=!0}call(t,e){return Object(l.tidy)(()=>{let e;t=ve(t);const n=null==this.bias?null:this.bias.read(),r=D(this.activation.getClassName());if(null!=r&&2===this.rank)e=Vr(t,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate,r);else{if(1===this.rank)e=qr(t,this.kernel.read(),n,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(2===this.rank)e=Vr(t,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate);else{if(3!==this.rank)throw new g("convolutions greater than 3D are not implemented yet.");e=Ur(t,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate)}null!=this.activation&&(e=this.activation.apply(e))}return e})}computeOutputShape(t){t=we(t);const e=[],n="channelsLast"===this.dataFormat?t.slice(1,t.length-1):t.slice(2);for(let t=0;t<n.length;++t){const r=zr(n[t],this.kernelSize[t],this.padding,this.strides[t],"number"==typeof this.dilationRate?this.dilationRate:this.dilationRate[t]);e.push(r)}let r=[t[0]];return"channelsLast"===this.dataFormat?(r=r.concat(e),r.push(this.filters)):(r.push(this.filters),r=r.concat(e)),r}getConfig(){const t={filters:this.filters,kernelInitializer:Xt(this.kernelInitializer),kernelRegularizer:Ar(this.kernelRegularizer),kernelConstraint:q(this.kernelConstraint)},e=super.getConfig();return Object.assign(t,e),t}static verifyArgs(t){if(!("filters"in t)||"number"!=typeof t.filters||t.filters<1)throw new m("Convolution layer expected config.filters to be a 'number' > 0 but got "+JSON.stringify(t.filters))}}class Hr extends Gr{constructor(t){super(2,t),Hr.verifyArgs(t)}getConfig(){const t=super.getConfig();return delete t.rank,t}static verifyArgs(t){if("number"!=typeof t.kernelSize&&!j(t.kernelSize,"number",1,2))throw new m(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(t.kernelSize)}.`)}}Hr.className="Conv2D",l.serialization.registerClass(Hr);class Kr extends Gr{constructor(t){super(3,t),Kr.verifyArgs(t)}getConfig(){const t=super.getConfig();return delete t.rank,t}static verifyArgs(t){if("number"!=typeof t.kernelSize&&(!Array.isArray(t.kernelSize)||1!==t.kernelSize.length&&3!==t.kernelSize.length))throw new m(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(t.kernelSize)}.`)}}Kr.className="Conv3D",l.serialization.registerClass(Kr);class Qr extends Hr{constructor(t){if(super(t),this.inputSpec=[new ke({ndim:4})],"same"!==this.padding&&"valid"!==this.padding)throw new m("Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode "+this.padding)}build(t){if(4!==(t=we(t)).length)throw new m("Input should have rank 4; Received input shape: "+JSON.stringify(t));const e="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[e])throw new m("The channel dimension of the inputs should be defined. Found `None`.");const n=t[e],r=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",r,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new ke({ndim:4,axes:{[e]:n}})],this.built=!0}call(t,e){return l.tidy(()=>{let e=ve(t);if(4!==e.shape.length)throw new m("Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-"+e.shape.length);const n=e.shape,r=n[0];let i,s;"channelsFirst"===this.dataFormat?(i=2,s=3):(i=1,s=2);const a=n[i],o=n[s],u=this.kernelSize[0],c=this.kernelSize[1],h=this.strides[0],d=this.strides[1],p=[r,Lr(a,h,u,this.padding),Lr(o,d,c,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(e=l.transpose(e,[0,2,3,1]));let f=l.conv2dTranspose(e,this.kernel.read(),p,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(f=l.transpose(f,[0,3,1,2])),null!=this.bias&&(f=Ct(f,this.bias.read(),this.dataFormat)),null!=this.activation&&(f=this.activation.apply(f)),f})}computeOutputShape(t){const e=(t=we(t)).slice();let n,r,i;"channelsFirst"===this.dataFormat?(n=1,r=2,i=3):(n=3,r=1,i=2);const s=this.kernelSize[0],a=this.kernelSize[1],o=this.strides[0],u=this.strides[1];return e[n]=this.filters,e[r]=Lr(e[r],o,s,this.padding),e[i]=Lr(e[i],u,a,this.padding),e}getConfig(){const t=super.getConfig();return delete t.dilationRate,t}}Qr.className="Conv2DTranspose",l.serialization.registerClass(Qr);class Xr extends Gr{constructor(t,e){if(super(t,e),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,null==e.filters)throw new m("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(null!=e.kernelInitializer||null!=e.kernelRegularizer||null!=e.kernelConstraint)throw new m("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(null!=e.padding&&"same"!==e.padding&&"valid"!==e.padding)throw new m(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received `+JSON.stringify(e.padding));this.depthMultiplier=null==e.depthMultiplier?1:e.depthMultiplier,this.depthwiseInitializer=Yt(e.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=Ir(e.depthwiseRegularizer),this.depthwiseConstraint=U(e.depthwiseConstraint),this.pointwiseInitializer=Yt(e.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=Ir(e.pointwiseRegularizer),this.pointwiseConstraint=U(e.pointwiseConstraint)}build(t){if((t=we(t)).length<this.rank+2)throw new m(`Inputs to SeparableConv${this.rank}D should have rank `+(this.rank+2)+", but received input shape: "+JSON.stringify(t));const e="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[e]||t[e]<0)throw new m("The channel dimension of the inputs should be defined, but found "+JSON.stringify(t[e]));const n=t[e],r=this.kernelSize.concat([n,this.depthMultiplier]),i=[];for(let t=0;t<this.rank;++t)i.push(1);i.push(n*this.depthMultiplier,this.filters);this.depthwiseKernel=this.addWeight("depthwise_kernel",r,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",i,"float32",this.pointwiseInitializer,this.pointwiseRegularizer,!0,this.pointwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.inputSpec=[new ke({ndim:this.rank+2,axes:{[e]:n}})],this.built=!0}call(t,e){return Object(l.tidy)(()=>{let e;if(t=ve(t),1===this.rank)throw new g("1D separable convolution is not implemented yet.");return 2===this.rank&&("channelsFirst"===this.dataFormat&&(t=l.transpose(t,[0,2,3,1])),e=l.separableConv2d(t,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(e=Ct(e,this.bias.read(),this.dataFormat)),null!=this.activation&&(e=this.activation.apply(e)),"channelsFirst"===this.dataFormat&&(e=l.transpose(e,[0,3,1,2])),e})}getConfig(){const t=super.getConfig();return delete t.rank,delete t.kernelInitializer,delete t.kernelRegularizer,delete t.kernelConstraint,t.depthwiseInitializer=Xt(this.depthwiseInitializer),t.pointwiseInitializer=Xt(this.pointwiseInitializer),t.depthwiseRegularizer=Ar(this.depthwiseRegularizer),t.pointwiseRegularizer=Ar(this.pointwiseRegularizer),t.depthwiseConstraint=q(this.depthwiseConstraint),t.pointwiseConstraint=q(this.pointwiseConstraint),t}}Xr.className="SeparableConv";class Yr extends Xr{constructor(t){super(2,t)}}Yr.className="SeparableConv2D",l.serialization.registerClass(Yr);class Jr extends Gr{constructor(t){super(1,t),Jr.verifyArgs(t),this.inputSpec=[{ndim:3}]}getConfig(){const t=super.getConfig();return delete t.rank,delete t.dataFormat,t}static verifyArgs(t){if("number"!=typeof t.kernelSize&&!j(t.kernelSize,"number",1,1))throw new m(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(t.kernelSize)}.`)}}Jr.className="Conv1D",l.serialization.registerClass(Jr);class Zr extends Ie{constructor(t){super(t),"number"==typeof t.cropping?this.cropping=[[t.cropping,t.cropping],[t.cropping,t.cropping]]:"number"==typeof t.cropping[0]?this.cropping=[[t.cropping[0],t.cropping[0]],[t.cropping[1],t.cropping[1]]]:this.cropping=t.cropping,this.dataFormat=void 0===t.dataFormat?"channelsLast":t.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(t){return"channelsFirst"===this.dataFormat?[t[0],t[1],t[2]-this.cropping[0][0]-this.cropping[0][1],t[3]-this.cropping[1][0]-this.cropping[1][1]]:[t[0],t[1]-this.cropping[0][0]-this.cropping[0][1],t[2]-this.cropping[1][0]-this.cropping[1][1],t[3]]}call(t,e){return Object(l.tidy)(()=>{if(t=ve(t),"channelsLast"===this.dataFormat){const e=yt(t,this.cropping[0][0],t.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return yt(e,this.cropping[1][0],t.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}{const e=yt(t,this.cropping[0][0],t.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return yt(e,this.cropping[1][0],t.shape[3]-this.cropping[1][1]-this.cropping[1][0],4)}})}getConfig(){const t={cropping:this.cropping,dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}Zr.className="Cropping2D",l.serialization.registerClass(Zr);class ti extends Ie{constructor(t){super(t),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=null==t.size?this.DEFAULT_SIZE:t.size,this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat}computeOutputShape(t){if("channelsFirst"===this.dataFormat){const e=null==t[2]?null:this.size[0]*t[2],n=null==t[3]?null:this.size[1]*t[3];return[t[0],t[1],e,n]}{const e=null==t[1]?null:this.size[0]*t[1],n=null==t[2]?null:this.size[1]*t[2];return[t[0],e,n,t[3]]}}call(t,e){return l.tidy(()=>{let e=ve(t);const n=e.shape;if("channelsFirst"===this.dataFormat){e=l.transpose(e,[0,2,3,1]);const t=this.size[0]*n[2],r=this.size[1]*n[3],i=e.resizeNearestNeighbor([t,r]);return l.transpose(i,[0,3,1,2])}{const t=this.size[0]*n[1],r=this.size[1]*n[2];return e.resizeNearestNeighbor([t,r])}})}getConfig(){const t={size:this.size,dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}ti.className="UpSampling2D",l.serialization.registerClass(ti);class ei extends Wr{constructor(t){super(2,t),this.depthwiseKernel=null,this.depthMultiplier=null==t.depthMultiplier?1:t.depthMultiplier,this.depthwiseInitializer=Yt(t.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=U(t.depthwiseConstraint),this.depthwiseRegularizer=Ir(t.depthwiseRegularizer)}build(t){if((t=we(t)).length<4)throw new m(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(t)}.`);const e="channelsFirst"===this.dataFormat?1:3;if(null==t[e]||t[e]<0)throw new m(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${t[e]}).`);const n=t[e],r=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",r,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[n*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(t,e){return Object(l.tidy)(()=>{let e=
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
function(t,e,n=[1,1],r="valid",i,s){return Object(l.tidy)(()=>{null==i&&(i="channelsLast"),tt(i);let a=$r(t,i);if(4!==t.rank)throw new m("Input for depthwiseConv2d is required to be 4-D, but is instead "+t.rank+"-D");if(4!==e.rank)throw new m("depthwiseKernel is required to be 4-D, but is instead "+e.rank+"-D");return a=l.depthwiseConv2d(a,e,n,"same"===r?"same":"valid","NHWC",s),"channelsFirst"===i&&(a=l.transpose(a,[0,3,1,2])),a})}(t=ve(t),this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(e=Ct(e,this.bias.read(),this.dataFormat)),null!=this.activation&&(e=this.activation.apply(e)),e})}computeOutputShape(t){t=we(t);const e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2],r="channelsFirst"===this.dataFormat?t[1]*this.depthMultiplier:t[3]*this.depthMultiplier,i=zr(e,this.kernelSize[0],this.padding,this.strides[0]),s=zr(n,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[t[0],r,i,s]:[t[0],i,s,r]}getConfig(){const t=super.getConfig();return t.depthMultiplier=this.depthMultiplier,t.depthwiseInitializer=Xt(this.depthwiseInitializer),t.depthwiseRegularizer=Ar(this.depthwiseRegularizer),t.depthwiseConstraint=q(this.depthwiseRegularizer),t}}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
function ni(t,e,n,r){if(Array.isArray(t)){if(null!=e||null!=n)throw new m("When inputs is an array, neither initialState or constants should be provided");null!=r&&(n=t.slice(t.length-r,t.length),t=t.slice(0,t.length-r)),t.length>1&&(e=t.slice(1,t.length)),t=t[0]}function i(t){return null==t||Array.isArray(t)?t:[t]}return{inputs:t,initialState:e=i(e),constants:n=i(n)}}function ri(t,e,n,r=!1,i,s,a=!1,o=!1){return l.tidy(()=>{const u=e.shape.length;if(u<3)throw new m(`Input should be at least 3D, but is ${u}D.`);const c=[1,0].concat(pt(2,u));if(e=l.transpose(e,c),null!=s)throw new g("The rnn() functoin of the deeplearn.js backend does not support constants yet.");a&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),null!=i&&((i=i.asType("bool").asType("float32")).rank===u-1&&(i=l.expandDims(i,-1)),i=l.transpose(i,c)),r&&(e=l.reverse(e,0),null!=i&&(i=l.reverse(i,0)));const h=[];let d,p=n;const f=e.shape[0],b=l.unstack(e);let y,v;null!=i&&(y=l.unstack(i));for(let e=0;e<f;++e){const n=b[e],r=l.tidy(()=>t(n,p));if(null==i)d=r[0],p=r[1];else{const t=l.tidy(()=>{const t=y[e],n=l.onesLike(t).sub(t);return{output:r[0].mul(t).add(p[0].mul(n)),newStates:p.map((e,i)=>r[1][i].mul(t).add(e.mul(n)))}});d=t.output,p=t.newStates}o&&h.push(d)}if(o){const t=1;v=l.stack(h,t)}return[d,v,p]})}ei.className="DepthwiseConv2D",l.serialization.registerClass(ei);class ii extends Ie{constructor(t){let e;if(super(t),null==t.cell)throw new m("cell property is missing for the constructor of RNN.");if(e=Array.isArray(t.cell)?new di({cells:t.cell}):t.cell,null==e.stateSize)throw new m("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=e,this.returnSequences=null!=t.returnSequences&&t.returnSequences,this.returnState=null!=t.returnState&&t.returnState,this.goBackwards=null!=t.goBackwards&&t.goBackwards,this._stateful=null!=t.stateful&&t.stateful,this.unroll=null!=t.unroll&&t.unroll,this.supportsMasking=!0,this.inputSpec=[new ke({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){if(null==this.states_){return pt(0,Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1).map(t=>null)}return this.states_}setStates(t){this.states_=t}computeOutputShape(t){be(t)&&(t=t[0]),t=t;let e=this.cell.stateSize;Array.isArray(e)||(e=[e]);const n=e[0];let r;if(r=this.returnSequences?[t[0],t[1],n]:[t[0],n],this.returnState){const n=[];for(const r of e)n.push([t[0],r]);return[r].concat(n)}return r}computeMask(t,e){return l.tidy(()=>{Array.isArray(e)&&(e=e[0]);const t=this.returnSequences?e:null;if(this.returnState){const e=this.states.map(t=>null);return[t].concat(e)}return t})}get states(){if(null==this.states_){const t=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,e=[];for(let n=0;n<t;++n)e.push(null);return e}return this.states_}set states(t){this.states_=t}build(t){if(null!=this.numConstants)throw new g("Constants support is not implemented in RNN yet.");be(t)&&(t=t[0]),t=t;const e=this.stateful?t[0]:null,n=t.slice(2);this.inputSpec[0]=new ke({shape:[e,null,...n]});const r=[t[0]].concat(t.slice(2));let i;if(this.cell.build(r),i=Array.isArray(this.cell.stateSize)?this.cell.stateSize:[this.cell.stateSize],null!=this.stateSpec){if(!l.util.arraysEqual(this.stateSpec.map(t=>t.shape[t.shape.length-1]),i))throw new m(`An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=${this.stateSpec}; However cell.stateSize is `+this.cell.stateSize)}else this.stateSpec=i.map(t=>new ke({shape:[null,t]}));this.stateful&&this.resetStates()}resetStates(t,e=!1){Object(l.tidy)(()=>{if(!this.stateful)throw new p("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape[0];if(null==n)throw new m("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==this.states_)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(t=>l.zeros([n,t])):this.states_=[l.zeros([n,this.cell.stateSize])];else if(null==t)l.dispose(this.states_),null!=this.keptStates&&(l.dispose(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(t=>l.zeros([n,t])):this.states_[0]=l.zeros([n,this.cell.stateSize]);else{if(Array.isArray(t)||(t=[t]),t.length!==this.states_.length)throw new m(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${t.length} state value(s). Input received: `+t);!0===e?this.keptStates.push(this.states_.slice()):l.dispose(this.states_);for(let e=0;e<this.states_.length;++e){const r=t[e],i=Array.isArray(this.cell.stateSize)?this.cell.stateSize[e]:this.cell.stateSize,s=[n,i];if(!l.util.arraysEqual(r.shape,s))throw new m(`State ${e} is incompatible with layer ${this.name}: expected shape=${s}, received shape=${r.shape}`);this.states_[e]=r}}this.states_=this.states_.map(t=>l.keep(t.clone()))})}apply(t,e){let n=null==e?null:e.initialState,r=null==e?null:e.constants;null==e&&(e={});const i=ni(t,n,r,this.numConstants);t=i.inputs,n=i.initialState,r=i.constants;let s=[],a=[];if(null!=n){e.initialState=n,s=s.concat(n),this.stateSpec=[];for(const t of n)this.stateSpec.push(new ke({shape:t.shape}));a=a.concat(this.stateSpec)}null!=r&&(e.constants=r,s=s.concat(r),this.numConstants=r.length);if(s[0]instanceof Te){const n=[t].concat(s),r=this.inputSpec.concat(a),i=this.inputSpec;this.inputSpec=r;const o=super.apply(n,e);return this.inputSpec=i,o}return super.apply(t,e)}call(t,e){return Object(l.tidy)(()=>{const n=null==e?null:e.mask,r=null==e?null:e.training;let i=null==e?null:e.initialState;t=ve(t),null==i&&(i=this.stateful?this.states_:this.getInitialState(t));const s=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(i.length!==s)throw new m(`RNN Layer has ${s} state(s) but was passed `+i.length+" initial state(s).");this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const a={training:r},o=ri((t,e)=>{const n=this.cell.call([t].concat(e),a);return[n[0],n.slice(1)]},t,i,this.goBackwards,n,null,this.unroll,this.returnSequences),u=o[0],c=o[1],l=o[2];this.stateful&&this.resetStates(l,r);const h=this.returnSequences?c:u;return this.returnState?[h].concat(l):h})}getInitialState(t){return Object(l.tidy)(()=>{let e=l.zeros(t.shape);return e=l.sum(e,[1,2]),e=mt(e),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map(t=>t>1?xt(e,[1,t]):e):this.cell.stateSize>1?[xt(e,[1,this.cell.stateSize])]:[e]})}get trainableWeights(){return this.trainable?this.cell.trainableWeights:[]}get nonTrainableWeights(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}setFastWeightInitDuringBuild(t){super.setFastWeightInitDuringBuild(t),null!=this.cell&&this.cell.setFastWeightInitDuringBuild(t)}getConfig(){const t=super.getConfig(),e={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};null!=this.numConstants&&(e.numConstants=this.numConstants);const n=this.cell.getConfig();return this.getClassName()===ii.className&&(e.cell={className:this.cell.getClassName(),config:n}),Object.assign({},n,t,e)}static fromConfig(t,e,n={}){const r=Ue(e.cell,n);return new t(Object.assign(e,{cell:r}))}}ii.className="RNN",l.serialization.registerClass(ii);class si extends Ie{}class ai extends si{constructor(t){super(t),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=t.units,M(this.units,"units"),this.activation=Or(null==t.activation?this.DEFAULT_ACTIVATION:t.activation),this.useBias=null==t.useBias||t.useBias,this.kernelInitializer=Yt(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Yt(t.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Yt(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Ir(t.kernelRegularizer),this.recurrentRegularizer=Ir(t.recurrentRegularizer),this.biasRegularizer=Ir(t.biasRegularizer),this.kernelConstraint=U(t.kernelConstraint),this.recurrentConstraint=U(t.recurrentConstraint),this.biasConstraint=U(t.biasConstraint),this.dropout=ht([1,dt([0,null==t.dropout?0:t.dropout])]),this.recurrentDropout=ht([1,dt([0,null==t.recurrentDropout?0:t.recurrentDropout])]),this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(t){t=we(t),this.kernel=this.addWeight("kernel",[t[t.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(t,e){return Object(l.tidy)(()=>{if(2!==(t=t).length)throw new m(`SimpleRNNCell expects 2 input Tensors, got ${t.length}.`);let n=t[1];t=t[0];const r=null!=e.training&&e.training;let i;0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=pi({ones:()=>l.onesLike(t),rate:this.dropout,training:r})),0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=pi({ones:()=>l.onesLike(n),rate:this.recurrentDropout,training:r}));const s=this.dropoutMask,a=this.recurrentDropoutMask;i=Ot(null!=s?l.mul(t,s):t,this.kernel.read()),null!=this.bias&&(i=Ct(i,this.bias.read())),null!=a&&(n=l.mul(n,a));let o=l.add(i,Ot(n,this.recurrentKernel.read()));return null!=this.activation&&(o=this.activation.apply(o)),[o,o]})}getConfig(){const t=super.getConfig(),e={units:this.units,activation:xr(this.activation),useBias:this.useBias,kernelInitializer:Xt(this.kernelInitializer),recurrentInitializer:Xt(this.recurrentInitializer),biasInitializer:Xt(this.biasInitializer),kernelRegularizer:Ar(this.kernelRegularizer),recurrentRegularizer:Ar(this.recurrentRegularizer),biasRegularizer:Ar(this.biasRegularizer),activityRegularizer:Ar(this.activityRegularizer),kernelConstraint:q(this.kernelConstraint),recurrentConstraint:q(this.recurrentConstraint),biasConstraint:q(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign({},t,e)}}ai.className="SimpleRNNCell",l.serialization.registerClass(ai);class oi extends ii{constructor(t){t.cell=new ai(t),super(t)}call(t,e){return Object(l.tidy)(()=>{null!=this.cell.dropoutMask&&(l.dispose(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(l.dispose(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==e?null:e.mask,r=null==e?null:e.training,i=null==e?null:e.initialState;return super.call(t,{mask:n,training:r,initialState:i})})}static fromConfig(t,e){return new t(e)}}oi.className="SimpleRNN",l.serialization.registerClass(oi);class ui extends si{constructor(t){if(super(t),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",t.resetAfter)throw new m("GRUCell does not support reset_after parameter set to true.");this.units=t.units,M(this.units,"units"),this.activation=Or(void 0===t.activation?this.DEFAULT_ACTIVATION:t.activation),this.recurrentActivation=Or(void 0===t.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:t.recurrentActivation),this.useBias=null==t.useBias||t.useBias,this.kernelInitializer=Yt(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Yt(t.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Yt(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Ir(t.kernelRegularizer),this.recurrentRegularizer=Ir(t.recurrentRegularizer),this.biasRegularizer=Ir(t.biasRegularizer),this.kernelConstraint=U(t.kernelConstraint),this.recurrentConstraint=U(t.recurrentConstraint),this.biasConstraint=U(t.biasConstraint),this.dropout=ht([1,dt([0,null==t.dropout?0:t.dropout])]),this.recurrentDropout=ht([1,dt([0,null==t.recurrentDropout?0:t.recurrentDropout])]),this.implementation=t.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(t){const e=(t=we(t))[t.length-1];this.kernel=this.addWeight("kernel",[e,3*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,3*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[3*this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(t,e){return Object(l.tidy)(()=>{if(2!==(t=t).length)throw new m("GRUCell expects 2 input Tensors (inputs, h, c), got "+t.length+".");const n=null!=e.training&&e.training;let r=t[1];t=t[0],0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=pi({ones:()=>l.onesLike(t),rate:this.dropout,training:n,count:3})),0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=pi({ones:()=>l.onesLike(r),rate:this.recurrentDropout,training:n,count:3}));const i=this.dropoutMask,s=this.recurrentDropoutMask;let a,o,u;0<this.dropout&&this.dropout<1&&(t=l.mul(t,i[0]));let c=Ot(t,this.kernel.read());this.useBias&&(c=Ct(c,this.bias.read())),0<this.recurrentDropout&&this.recurrentDropout<1&&(r=l.mul(r,s[0]));const h=this.recurrentKernel.read(),[d,p]=l.split(h,[2*this.units,this.units],h.rank-1),f=Ot(r,d),[g,b,y]=l.split(c,3,c.rank-1),[v,w]=l.split(f,2,f.rank-1);a=this.recurrentActivation.apply(l.add(g,v)),o=this.recurrentActivation.apply(l.add(b,w));const x=Ot(l.mul(o,r),p);u=this.activation.apply(l.add(y,x));const _=l.add(l.mul(a,r),l.mul(l.add(1,l.neg(a)),u));return[_,_]})}getConfig(){const t=super.getConfig(),e={units:this.units,activation:xr(this.activation),recurrentActivation:xr(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Xt(this.kernelInitializer),recurrentInitializer:Xt(this.recurrentInitializer),biasInitializer:Xt(this.biasInitializer),kernelRegularizer:Ar(this.kernelRegularizer),recurrentRegularizer:Ar(this.recurrentRegularizer),biasRegularizer:Ar(this.biasRegularizer),activityRegularizer:Ar(this.activityRegularizer),kernelConstraint:q(this.kernelConstraint),recurrentConstraint:q(this.recurrentConstraint),biasConstraint:q(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation,resetAfter:!1};return Object.assign({},t,e)}}ui.className="GRUCell",l.serialization.registerClass(ui);class ci extends ii{constructor(t){0===t.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),t.cell=new ui(t),super(t)}call(t,e){return Object(l.tidy)(()=>{null!=this.cell.dropoutMask&&(l.dispose(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(l.dispose(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==e?null:e.mask,r=null==e?null:e.training,i=null==e?null:e.initialState;return super.call(t,{mask:n,training:r,initialState:i})})}static fromConfig(t,e){return 0===e.implmentation&&(e.implementation=1),new t(e)}}ci.className="GRU",l.serialization.registerClass(ci);class li extends si{constructor(t){super(t),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=t.units,M(this.units,"units"),this.activation=Or(void 0===t.activation?this.DEFAULT_ACTIVATION:t.activation),this.recurrentActivation=Or(void 0===t.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:t.recurrentActivation),this.useBias=null==t.useBias||t.useBias,this.kernelInitializer=Yt(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Yt(t.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Yt(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=t.unitForgetBias,this.kernelRegularizer=Ir(t.kernelRegularizer),this.recurrentRegularizer=Ir(t.recurrentRegularizer),this.biasRegularizer=Ir(t.biasRegularizer),this.kernelConstraint=U(t.kernelConstraint),this.recurrentConstraint=U(t.recurrentConstraint),this.biasConstraint=U(t.biasConstraint),this.dropout=ht([1,dt([0,null==t.dropout?0:t.dropout])]),this.recurrentDropout=ht([1,dt([0,null==t.recurrentDropout?0:t.recurrentDropout])]),this.implementation=t.implementation,this.stateSize=[this.units,this.units],this.dropoutMask=null,this.recurrentDropoutMask=null}build(t){var e;const n=(t=we(t))[t.length-1];let r;if(this.kernel=this.addWeight("kernel",[n,4*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,4*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){if(this.unitForgetBias){const t=this.biasInitializer,n=this.units;r=new((e=class extends jt{apply(e,r){const i=t.apply([n]),s=(new Dt).apply([n]),a=t.apply([2*n]);return wt(wt(i,s),a)}}).className="CustomInit",e)}else r=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.units],null,r,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(t,e){return Object(l.tidy)(()=>{const n=null!=e.training&&e.training;if(3!==(t=t).length)throw new m("LSTMCell expects 3 input Tensors (inputs, h, c), got "+t.length+".");let r=t[1];const i=t[2];t=t[0],0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=pi({ones:()=>l.onesLike(t),rate:this.dropout,training:n,count:4})),0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=pi({ones:()=>l.onesLike(r),rate:this.recurrentDropout,training:n,count:4}));const s=this.dropoutMask,a=this.recurrentDropoutMask;let o,u,c,h;0<this.dropout&&this.dropout<1&&(t=l.mul(t,s[0]));let d=Ot(t,this.kernel.read());0<this.recurrentDropout&&this.recurrentDropout<1&&(r=l.mul(r,a[0])),d=l.add(d,Ot(r,this.recurrentKernel.read())),this.useBias&&(d=Ct(d,this.bias.read()));const[p,f,g,b]=l.split(d,4,d.rank-1);o=this.recurrentActivation.apply(p),u=this.recurrentActivation.apply(f),c=l.add(l.mul(u,i),l.mul(o,this.activation.apply(g))),h=this.recurrentActivation.apply(b);const y=l.mul(h,this.activation.apply(c));return[y,y,c]})}getConfig(){const t=super.getConfig(),e={units:this.units,activation:xr(this.activation),recurrentActivation:xr(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Xt(this.kernelInitializer),recurrentInitializer:Xt(this.recurrentInitializer),biasInitializer:Xt(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:Ar(this.kernelRegularizer),recurrentRegularizer:Ar(this.recurrentRegularizer),biasRegularizer:Ar(this.biasRegularizer),activityRegularizer:Ar(this.activityRegularizer),kernelConstraint:q(this.kernelConstraint),recurrentConstraint:q(this.recurrentConstraint),biasConstraint:q(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation};return Object.assign({},t,e)}}li.className="LSTMCell",l.serialization.registerClass(li);class hi extends ii{constructor(t){0===t.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),t.cell=new li(t),super(t)}call(t,e){return Object(l.tidy)(()=>{null!=this.cell.dropoutMask&&(l.dispose(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(l.dispose(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==e?null:e.mask,r=null==e?null:e.training,i=null==e?null:e.initialState;return super.call(t,{mask:n,training:r,initialState:i})})}static fromConfig(t,e){return 0===e.implmentation&&(e.implementation=1),new t(e)}}hi.className="LSTM",l.serialization.registerClass(hi);class di extends si{constructor(t){super(t),this.cells=t.cells}get stateSize(){const t=[];for(const e of this.cells.slice().reverse())Array.isArray(e.stateSize)?t.push(...e.stateSize):t.push(e.stateSize);return t}call(t,e){return Object(l.tidy)(()=>{let n=(t=t).slice(1);const r=[];for(const t of this.cells.slice().reverse())Array.isArray(t.stateSize)?r.push(n.splice(0,t.stateSize.length)):r.push(n.splice(0,1));r.reverse();const i=[];let s;for(let a=0;a<this.cells.length;++a){const o=this.cells[a];n=r[a],s=0===a?[t[0]].concat(n):[s[0]].concat(n),s=o.call(s,e),i.push(s.slice(1))}n=[];for(const t of i.slice().reverse())n.push(...t);return[s[0]].concat(n)})}build(t){let e;be(t)&&(t=t[0]),t=t,this.cells.forEach((n,r)=>{it("RNNCell_"+r,()=>{n.build(t),e=Array.isArray(n.stateSize)?n.stateSize[0]:n.stateSize,t=[t[0],e]})}),this.built=!0}getConfig(){const t=super.getConfig(),e={cells:this.cells.map(t=>({className:t.getClassName(),config:t.getConfig()}))};return Object.assign({},t,e)}static fromConfig(t,e,n={}){const r=[];for(const t of e.cells)r.push(Ue(t,n));return new t({cells:r})}get trainableWeights(){if(!this.trainable)return[];const t=[];for(const e of this.cells)t.push(...e.trainableWeights);return t}get nonTrainableWeights(){const t=[];for(const e of this.cells)t.push(...e.nonTrainableWeights);if(!this.trainable){const e=[];for(const t of this.cells)e.push(...t.trainableWeights);return e.concat(t)}return t}getWeights(){const t=[];for(const e of this.cells)t.push(...e.weights);return Oe(t)}setWeights(t){const e=[];for(const n of this.cells){const r=n.weights.length,i=t.splice(r);for(let t=0;t<n.weights.length;++t)e.push([n.weights[t],i[t]])}Se(e)}}function pi(t){const{ones:e,rate:n,training:r=!1,count:i=1}=t,s=()=>At(e(),n),a=()=>Nt(s,e,r);if(!i||i<=1)return l.keep(a().clone());return Array(i).fill(void 0).map(a).map(t=>l.keep(t.clone()))}
/**
 * @license
 * Copyright 2020 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */di.className="StackedRNNCells",l.serialization.registerClass(di);var fi=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n};class mi extends ii{constructor(t){if(t.unroll)throw new g("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(t.cell))throw new g("It is not possible at the moment to stack convolutional cells.");super(t),this.inputSpec=[new ke({ndim:5})]}call(t,e){return l.tidy(()=>{if(null!=this.cell.dropoutMask&&(l.dispose(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(l.dispose(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),e&&e.constants)throw new m("ConvRNN2D cell does not support constants");const n=null==e?null:e.mask,r=null==e?null:e.training,i=null==e?null:e.initialState;return super.call(t,{mask:n,training:r,initialState:i})})}computeOutputShape(t){let e=this.computeSingleOutputShape(t);return this.returnSequences||(e=[e[0],...e.slice(2)]),this.returnState&&(e=[e,...Array(2).fill([t[0],...e.slice(-3)])]),e}getInitialState(t){return l.tidy(()=>{const{stateSize:e}=this.cell,n=t.shape,r=this.computeSingleOutputShape(n),i=[r[0],...r.slice(2)],s=l.zeros(i);return Array.isArray(e)?Array(e.length).fill(s):[s]})}resetStates(t,e=!1){l.tidy(()=>{if(!this.stateful)throw new p("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape,r=this.computeSingleOutputShape(n),i=[r[0],...r.slice(2)];if(null==n[0])throw new m("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==this.getStates())Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>l.zeros(i)):this.states_=[l.zeros(i)];else if(null==t)l.dispose(this.states_),null!=this.keptStates&&(l.dispose(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>l.zeros(i)):this.states_[0]=l.zeros(i);else{if(Array.isArray(t)||(t=[t]),t.length!==this.states_.length)throw new m(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${t.length} state value(s). Input received: `+t);e?this.keptStates.push(this.states_.slice()):l.dispose(this.states_);for(let e=0;e<this.states_.length;++e){const n=t[e],r=i;if(!l.util.arraysEqual(n.shape,r))throw new m(`State ${e} is incompatible with layer ${this.name}: expected shape=${r}, received shape=${n.shape}`);this.states_[e]=n}}this.states_=this.states_.map(t=>l.keep(t.clone()))})}computeSingleOutputShape(t){const{dataFormat:e,filters:n,kernelSize:r,padding:i,strides:s,dilationRate:a}=this.cell,o="channelsFirst"===e,u=t[o?3:2],c=t[o?4:3],l=zr(u,r[0],i,s[0],a[0]),h=zr(c,r[1],i,s[1],a[1]);return[...t.slice(0,2),...o?[n,l,h]:[l,h,n]]}}mi.className="ConvRNN2D";class gi extends li{constructor(t){const{filters:e,kernelSize:n,strides:r,padding:i,dataFormat:s,dilationRate:a}=t;super(Object.assign({},t,{units:e})),this.filters=e,M(this.filters,"filters"),this.kernelSize=Fr(n,2,"kernelSize"),this.kernelSize.forEach(t=>M(t,"kernelSize")),this.strides=Fr(r||1,2,"strides"),this.strides.forEach(t=>M(t,"strides")),this.padding=i||"valid",et(this.padding),this.dataFormat=s||"channelsLast",tt(this.dataFormat),this.dilationRate=Fr(a||1,2,"dilationRate"),this.dilationRate.forEach(t=>M(t,"dilationRate"))}build(t){var e;t=we(t);const n="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[n])throw new m("The channel dimension of the input should be defined. Found "+t[n]);const r=t[n],i=this.kernelSize.concat([r,4*this.filters]);this.kernel=this.addWeight("kernel",i,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const s=this.kernelSize.concat([this.filters,4*this.filters]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",s,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let t;if(this.unitForgetBias){const n=this.biasInitializer,r=this.filters;t=new((e=class extends jt{apply(t,e){return vt([n.apply([r]),l.ones([r]),n.apply([2*r])])}}).className="CustomInit",e)}else t=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.filters],null,t,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(t,e){return l.tidy(()=>{if(3!==t.length)throw new m("ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got "+t.length+".");const n=e.training||!1,r=t[0],i=t[1],s=t[2];0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=pi({ones:()=>l.onesLike(r),rate:this.dropout,training:n,count:4}));const a=this.dropoutMask,o=(t,e,n)=>e&&e[n]?l.mul(e[n],t):t;let u=o(r,a,0),c=o(r,a,1),h=o(r,a,2),d=o(r,a,3);0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=pi({ones:()=>l.onesLike(i),rate:this.recurrentDropout,training:n,count:4}));const p=this.recurrentDropoutMask;let f=o(i,p,0),g=o(i,p,1),b=o(i,p,2),y=o(i,p,3);const[v,w,x,_]=l.split(this.kernel.read(),4,3),[O,S,k,T]=this.useBias?l.split(this.bias.read(),4):[null,null,null,null];u=this.inputConv(u,v,O,this.padding),c=this.inputConv(c,w,S,this.padding),h=this.inputConv(h,x,k,this.padding),d=this.inputConv(d,_,T,this.padding);const[C,A,N,I]=l.split(this.recurrentKernel.read(),4,3);f=this.recurrentConv(f,C),g=this.recurrentConv(g,A),b=this.recurrentConv(b,N),y=this.recurrentConv(y,I);const E=this.recurrentActivation.apply(l.add(u,f)),j=this.recurrentActivation.apply(l.add(c,g)),M=l.add(l.mul(j,s),l.mul(E,this.activation.apply(l.add(h,b)))),D=l.mul(this.recurrentActivation.apply(l.add(d,y)),this.activation.apply(M));return[D,D,M]})}getConfig(){const t=super.getConfig(),{units:e}=t,n=fi(t,["units"]),r={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign({},n,r)}inputConv(t,e,n,r){const i=l.conv2d(t,e,this.strides,r||"valid","channelsFirst"===this.dataFormat?"NCHW":"NHWC",this.dilationRate);return n?Ct(i,n,this.dataFormat):i}recurrentConv(t,e){return l.conv2d(t,e,1,"same","channelsFirst"===this.dataFormat?"NCHW":"NHWC")}}gi.className="ConvLSTM2DCell",l.serialization.registerClass(gi);class bi extends mi{constructor(t){const e=new gi(t);super(Object.assign({},t,{cell:e}))}static fromConfig(t,e){return new t(e)}}bi.className="ConvLSTM2D",l.serialization.registerClass(bi);
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
class yi extends Ie{constructor(t){super(t),this.rate=Math.max(Math.min(t.rate,1),0),this.noiseShape=t.noiseShape,this.seed=t.seed,this.supportsMasking=!0}getNoiseShape(t){if(null==this.noiseShape)return this.noiseShape;const e=t.shape,n=[];for(let t=0;t<this.noiseShape.length;++t)n.push(null==this.noiseShape[t]?e[t]:this.noiseShape[t]);return n}call(t,e){return Object(l.tidy)(()=>{this.invokeCallHook(t,e);const n=ve(t);if(0<this.rate&&this.rate<1){const t=null!=e.training&&e.training,r=this.getNoiseShape(n);return Nt(()=>At(n,this.rate,r,this.seed),()=>n,t)}return t})}getConfig(){const t={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},e=super.getConfig();return Object.assign(t,e),t}dispose(){return super.dispose()}}yi.className="Dropout",l.serialization.registerClass(yi);class vi extends yi{constructor(t){super(t),this.inputSpec=[{ndim:3}]}getNoiseShape(t){const e=t.shape;return[e[0],1,e[2]]}}vi.className="SpatialDropout1D",l.serialization.registerClass(vi);class wi extends Ie{constructor(t){if(super(t),this.activation=null,this.useBias=!0,this.kernel=null,this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",null==t.batchInputShape&&null==t.inputShape&&null!=t.inputDim){let e=null;null!=t.batchSize&&(e=t.batchSize),this.batchInputShape=[e,t.inputDim]}this.units=t.units,M(this.units,"units"),this.activation=Or(t.activation),null!=t.useBias&&(this.useBias=t.useBias),this.kernelInitializer=Yt(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=Yt(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=U(t.kernelConstraint),this.biasConstraint=U(t.biasConstraint),this.kernelRegularizer=Ir(t.kernelRegularizer),this.biasRegularizer=Ir(t.biasRegularizer),this.activityRegularizer=Ir(t.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(t){const e=(t=we(t))[t.length-1];null==this.kernel&&(this.kernel=this.addWeight("kernel",[e,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:{[-1]:e}}],this.built=!0}computeOutputShape(t){const e=(t=we(t)).slice();return e[e.length-1]=this.units,e}call(t,e){return Object(l.tidy)(()=>{this.invokeCallHook(t,e);const n=ve(t),r=D(this.activation.getClassName());let i;return null!=r?i=Ot(n,this.kernel.read(),r,this.bias?this.bias.read():null):(i=Ot(n,this.kernel.read()),null!=this.bias&&(i=Ct(i,this.bias.read())),null!=this.activation&&(i=this.activation.apply(i))),i})}getConfig(){const t={units:this.units,activation:xr(this.activation),useBias:this.useBias,kernelInitializer:Xt(this.kernelInitializer),biasInitializer:Xt(this.biasInitializer),kernelRegularizer:Ar(this.kernelRegularizer),biasRegularizer:Ar(this.biasRegularizer),activityRegularizer:Ar(this.activityRegularizer),kernelConstraint:q(this.kernelConstraint),biasConstraint:q(this.biasConstraint)},e=super.getConfig();return Object.assign(t,e),t}}wi.className="Dense",l.serialization.registerClass(wi);class xi extends Ie{constructor(t){super(t=t||{}),this.inputSpec=[{minNDim:3}],this.dataFormat=t.dataFormat}computeOutputShape(t){t=we(t);for(const e of t.slice(1))if(null==e)throw new m(`The shape of the input to "Flatten" is not fully defined (got ${t.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`);return[t[0],ct(t,1)]}call(t,e){return Object(l.tidy)(()=>{this.invokeCallHook(t,e);let n=ve(t);if("channelsFirst"===this.dataFormat&&n.rank>1){const t=[0];for(let e=2;e<n.rank;++e)t.push(e);t.push(1),n=n.transpose(t)}return function(t){if(t.rank<=1)throw new m(`batchFlatten requires a minimum rank of 2. Got rank: ${t.rank}.`);const e=[t.shape[0],ct(t.shape,1)];return t.reshape(e)}(n)})}getConfig(){const t={};null!=this.dataFormat&&(t.dataFormat=this.dataFormat);const e=super.getConfig();return Object.assign(t,e),t}}xi.className="Flatten",l.serialization.registerClass(xi);class _i extends Ie{constructor(t){super(t),this.supportsMasking=!0,this.activation=Or(t.activation)}call(t,e){return Object(l.tidy)(()=>{this.invokeCallHook(t,e);const n=ve(t);return this.activation.apply(n)})}getConfig(){const t={activation:xr(this.activation)},e=super.getConfig();return Object.assign(t,e),t}}_i.className="Activation",l.serialization.registerClass(_i);class Oi extends Ie{constructor(t){super(t),this.n=t.n,this.inputSpec=[{ndim:2}]}computeOutputShape(t){return[t[0],this.n,t[1]]}call(t,e){return Object(l.tidy)(()=>{return t=ve(t),e=t,n=this.n,Object(l.tidy)(()=>{if(2!==e.shape.length)throw new m(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`);return xt(mt(e,1),[1,n,1])});var e,n})}getConfig(){const t={n:this.n},e=super.getConfig();return Object.assign(t,e),t}}Oi.className="RepeatVector",l.serialization.registerClass(Oi);class Si extends Ie{constructor(t){super(t),this.targetShape=t.targetShape;for(let t=0;t<this.targetShape.length;++t)this.isUnknown(this.targetShape[t])&&(this.targetShape[t]=null)}isUnknown(t){return t<0||null==t}fixUnknownDimension(t,e){const n="Total size of new array must be unchanged.",r=e.slice();let i=1,s=null;for(let t=0;t<r.length;++t){const e=r[t];if(this.isUnknown(e)){if(null!==s)throw new m("Can only specifiy one unknown dimension.");s=t}else i*=e}const a=ct(t);if(null!==s){if(0===i||a%i!=0)throw new m(n);r[s]=a/i}else if(a!==i)throw new m(n);return r}computeOutputShape(t){let e=!1;for(let n=0;n<t.length;++n)if(this.isUnknown(t[n])){e=!0;break}return e?t.slice(0,1).concat(this.targetShape):t.slice(0,1).concat(this.fixUnknownDimension(t.slice(1),this.targetShape))}call(t,e){return Object(l.tidy)(()=>{this.invokeCallHook(t,e);const n=ve(t),r=n.shape,i=r.slice(0,1).concat(this.fixUnknownDimension(r.slice(1),this.targetShape));return n.reshape(i)})}getConfig(){const t={targetShape:this.targetShape},e=super.getConfig();return Object.assign(t,e),t}}Si.className="Reshape",l.serialization.registerClass(Si);class ki extends Ie{constructor(t){if(super(t),null==t.dims)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(t.dims))throw new Error("Permute constructor requires `dims` to be an Array, but received "+t.dims+" instead.");const e=pt(1,t.dims.length+1);if(!l.util.arraysEqual(t.dims.slice().sort(),e))throw new Error("Invalid permutation `dims`: "+JSON.stringify(t.dims)+" `dims` must contain consecutive integers starting from 1.");this.dims=t.dims,this.dimsIncludingBatch=[0].concat(this.dims),this.inputSpec=[new ke({ndim:this.dims.length+1})]}computeOutputShape(t){const e=(t=we(t)).slice();return this.dims.forEach((n,r)=>{e[r+1]=t[n]}),e}call(t,e){return Object(l.transpose)(ve(t),this.dimsIncludingBatch)}getConfig(){const t={dims:this.dims},e=super.getConfig();return Object.assign(t,e),t}}ki.className="Permute",l.serialization.registerClass(ki);class Ti extends Ie{constructor(t){super(null==t?{}:t),this.supportsMasking=!0,this.maskValue=null!=t?null==t.maskValue?0:t.maskValue:0}computeOutputShape(t){return t}getConfig(){const t=super.getConfig(),e={maskValue:this.maskValue};return Object.assign(e,t),e}computeMask(t,e){const n=ve(t);return Object(l.any)(Object(l.notEqual)(n,this.maskValue),-1)}call(t,e){return Object(l.tidy)(()=>{this.invokeCallHook(t,e);const n=ve(t),r=Object(l.any)(Object(l.notEqual)(n,this.maskValue),-1,!0);return n.mul(r.asType(n.dtype))})}}Ti.className="Masking",l.serialization.registerClass(Ti);
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
class Ci extends Ie{constructor(t){if(super(t),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==t.batchInputShape&&null==t.inputShape){let e=null;null!=t.batchSize&&(e=t.batchSize),null==t.inputLength?this.batchInputShape=[e,null]:this.batchInputShape=[e].concat(_(t.inputLength))}this.inputDim=t.inputDim,M(this.inputDim,"inputDim"),this.outputDim=t.outputDim,M(this.outputDim,"outputDim"),this.embeddingsInitializer=Yt(t.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=Ir(t.embeddingsRegularizer),this.activityRegularizer=Ir(t.activityRegularizer),this.embeddingsConstraint=U(t.embeddingsConstraint),this.maskZero=t.maskZero,this.supportsMasking=t.maskZero,this.inputLength=t.inputLength}build(t){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0}warnOnIncompatibleInputShape(t){}computeMask(t,e){return Object(l.tidy)(()=>this.maskZero?(t=ve(t),Object(l.notEqual)(t,Object(l.zerosLike)(t))):null)}computeOutputShape(t){if(t=we(t),null==this.inputLength)return[...t,this.outputDim];const e=_(this.inputLength);if(e.length!==t.length-1)throw new m(`"inputLength" is ${this.inputLength}, but received input shape has shape `+t);{let n=0;for(let r=0;r<e.length;++r){const i=e[r],s=t[r+1];if(null!=i&&null!=s&&i!==s)throw new m(`"inputLength" is ${this.inputLength}, but received input shape has shape `+t);null==i&&(e[n]=s),n++}}return[t[0],...e,this.outputDim]}call(t,e){return Object(l.tidy)(()=>{this.invokeCallHook(t,e);let n=ve(t);"int32"!==n.dtype&&(n=ft(n,"int32"));return St(this.embeddings.read(),n.as1D()).reshape(we(this.computeOutputShape(n.shape)))})}getConfig(){const t={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:Xt(this.embeddingsInitializer),embeddingsRegularizer:Ar(this.embeddingsRegularizer),activityRegularizer:Ar(this.activityRegularizer),embeddingsConstraint:q(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},e=super.getConfig();return Object.assign(t,e),t}}Ci.className="Embedding",l.serialization.registerClass(Ci);
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
class Ai extends Ie{constructor(t){super(t||{}),this.supportsMasking=!0}mergeFunction(t){throw new g}computeElementwiseOpOutputShape(t,e){if(null==t||null==e)return null;if(t.length<e.length)return this.computeElementwiseOpOutputShape(e,t);if(0===e.length)return t;const n=t.slice(0,t.length-e.length);for(let r=0;r<e.length;++r){const i=t[t.length-e.length+r],s=e[r];if(null==i||null==s||i<0||s<0)n.push(null);else if(1===i)n.push(s);else if(1===s)n.push(i);else{if(i!==s)throw new m("Operands could not be broadcast together with shapes "+JSON.stringify(t)+" "+JSON.stringify(e));n.push(i)}}return n}build(t){if(Array.isArray(t)&&!Array.isArray(t[0])&&(t=[we(t)]),(t=t).length<2)throw new m(`A merge layer should be called on an Array of at least 2 inputs. Got ${t.length} input(s).`);let e=[];for(const n of t)null!=n&&null!==n[0]&&e.push(n[0]);if(e=N(e),e.length>1)throw new m(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(t)}.`);let n=null==t[0]?null:t[0].slice(1);for(let e=1;e<t.length;++e){const r=null==t[e]?null:t[e].slice(1);n=this.computeElementwiseOpOutputShape(n,r)}const r=t.map(t=>t.length);-1===t.indexOf(null)&&1===N(r).length?this.reshapeRequired=!1:this.reshapeRequired=!0}call(t,e){return Object(l.tidy)(()=>{if(t=t,this.reshapeRequired){const e=[],n=t.map(t=>t.rank);if(-1===n.indexOf(null)){const r=dt(n);for(let n of t){const t=n.rank;for(let e=0;e<r-t;++e)n=mt(n,1);e.push(n)}return this.mergeFunction(e)}{let n=!1;for(const r of t){const t=r.rank;if(null==t){const t=r.shape,i=t[0],s=t.slice(1).concat([i]);let a=r.reshape([i].concat(ct(t.slice(1))));a=l.transpose(a,[1,0]),a=a.reshape(s),e.push(a),n=!0}else if(t>1){const i=pt(1,t).concat([0]);e.push(l.transpose(r,i)),n=!0}else e.push(r)}let r=this.mergeFunction(e);const i=r.rank;if(n)if(null==i){const t=r.shape,e=t[t.length-1],n=[e].concat(t.slice(0,t.length-1));r=l.transpose(r.reshape([-1,e]),[1,0]).reshape(n)}else if(i>1){const t=[i-1].concat(pt(0,i-1));r=l.transpose(r,t)}return r}}return this.mergeFunction(t)})}computeOutputShape(t){let e;e=null==(t=t)[0]?null:t[0].slice(1);for(let n=1;n<t.length;++n){const r=null==t[n]?null:t[n].slice(1);e=this.computeElementwiseOpOutputShape(e,r)}let n=[];for(const e of t)null!=e&&null!==e[0]&&n.push(e[0]);return n=N(n),e=1===n.length?n.concat(e):[null].concat(e),e}computeMask(t,e){return l.tidy(()=>{if(null==e)return null;if(!Array.isArray(e))throw new m("`mask` should be an Array");if(!Array.isArray(t))throw new m("`inputs` should be an Array");if(e.length!==t.length)throw new m(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${t.length} vs ${e.length})`);if(e.every(t=>null==t))return null;let n=(e=e.map(t=>null==t?t:l.expandDims(t,0)))[0];for(let t=1;t<e.length-1;++t)n=l.logicalAnd(n,e[t]);return n})}}class Ni extends Ai{constructor(t){super(t)}mergeFunction(t){return Object(l.tidy)(()=>{let e=t[0].clone();for(let n=1;n<t.length;++n)e=l.add(e,t[n]);return e})}}Ni.className="Add",l.serialization.registerClass(Ni);class Ii extends Ai{constructor(t){super(t)}mergeFunction(t){return Object(l.tidy)(()=>{let e=t[0].clone();for(let n=1;n<t.length;++n)e=l.mul(e,t[n]);return e})}}Ii.className="Multiply",l.serialization.registerClass(Ii);class Ei extends Ai{constructor(t){super(t)}mergeFunction(t){return Object(l.tidy)(()=>{let e=t[0].clone();for(let n=1;n<t.length;++n)e=l.add(e,t[n]);return l.mul(1/t.length,e)})}}Ei.className="Average",l.serialization.registerClass(Ei);class ji extends Ai{constructor(t){super(t)}mergeFunction(t){return Object(l.tidy)(()=>{let e=t[0];for(let n=1;n<t.length;++n)e=l.maximum(e,t[n]);return e})}}ji.className="Maximum",l.serialization.registerClass(ji);class Mi extends Ai{constructor(t){super(t)}mergeFunction(t){return Object(l.tidy)(()=>{let e=t[0];for(let n=1;n<t.length;++n)e=l.minimum(e,t[n]);return e})}}Mi.className="Minimum",l.serialization.registerClass(Mi);class Di extends Ai{constructor(t){super(t),this.DEFAULT_AXIS=-1,null==t&&(t={}),this.axis=null==t.axis?this.DEFAULT_AXIS:t.axis,this.supportsMasking=!0,this.reshapeRequired=!1}build(t){if(!Array.isArray(t)||!Array.isArray(t[0])||1===t.length)throw new m("A `Concatenate` layer should be called on a list of at least 2 inputs");t=t;let e=!0;for(const n of t)if(null!=n){e=!1;break}if(e)return;const n=[];for(let e=0;e<t.length;++e){const r=t[e].slice();r.splice(this.axis,1);let i=!1;for(const t of n)if(l.util.arraysEqual(t,r)){i=!0;break}i||n.push(r)}if(n.length>1)throw new m("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(t))}mergeFunction(t){return Object(l.tidy)(()=>vt(t,this.axis))}computeOutputShape(t){if(!Array.isArray(t)||!Array.isArray(t[0]))throw new m("A `Concatenate` layer should be called on a list of inputs.");const e=t,n=e[0].slice(),r=this.axis<0?n.length+this.axis:this.axis;for(const t of e.slice(1)){if(null==n[r]||null==t[r]){n[r]=null;break}n[r]+=t[r]}return n}computeMask(t,e){if(null==e)return null;if(!Array.isArray(e))throw new m("`mask` should be an array for Concatenate");if(!Array.isArray(t))throw new m("`inputs` should be an array for Concatenate");if(e.length!==t.length)throw new m(`Mismatch in the length of mask (${e.length}) and the legnth of inputs (${t.length})`);return l.tidy(()=>{let n=!0;if(e.forEach(t=>{null==t||(n=!1)}),n)return null;const r=[];for(let n=0;n<t.length;++n)null==e[n]?r.push(l.onesLike(t[n]).asType("bool")):e[n].rank<t[n].rank?r.push(l.expandDims(e[n],-1)):r.push(e[n]);const i=l.concat(r,this.axis);return l.all(i,-1,!1)})}getConfig(){const t={axis:this.axis},e=super.getConfig();return Object.assign(t,e),t}}function Ri(t,e){for(;t<0;)t+=e;return t}Di.className="Concatenate",l.serialization.registerClass(Di);class Pi extends Ai{constructor(t){super(t),this.axes=t.axes,this.normalize=null!=t.normalize&&t.normalize,this.supportsMasking=!0,this.reshapeRequired=!1}build(t){l.util.assert(Array.isArray(t)&&2===t.length&&Array.isArray(t[0])&&Array.isArray(t[1]),()=>"A `Dot` layer should be called on a list of exactly 2 inputs.");const e=t[0],n=t[1];if(e.length>3||n.length>3)throw new g("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(e,n);if(e[r[0]]!==n[r[1]])throw new m(`Dimension incompatibility: ${e[r[0]]} !== ${n[r[1]]}`)}mergeFunction(t){if(2!==t.length)throw new m(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${t.length} input(s).`);let e,n=t[0],r=t[1];return e=Array.isArray(this.axes)?this.axes.map((e,n)=>Ri(e,t[n].shape.length)):[Ri(this.axes,n.shape.length),Ri(this.axes,r.shape.length)],this.normalize&&(n=We(n,e[0]),r=We(r,e[1])),function(t,e,n){if(t.shape.length>3||e.shape.length>3)throw new g("batchDot is not implemented for tensors of 4D or higher rank yet");if(l.util.assert(t.shape.length>=2,()=>"batchDot requires the rank of x to be >= 2, but got "+t.shape.length),l.util.assert(t.shape.length>=2,()=>"batchDot requires the rank of y to be >= 2, but got "+e.shape.length),"number"==typeof n&&(n=[n,n]),"complex64"===t.dtype||"complex64"===e.dtype)throw new g("batchDot is not implemented for complex64-type Tensors yet.");const r=t.shape.length,i=e.shape.length;null==n&&(n=[r-1,i-2]);const s=n;return l.tidy(()=>{let n,a;if(r>i){n=r-i;const t=[];for(let e=0;e<n;++e)t.push(1);e=e.reshape(e.shape.concat(t))}else if(i>r){n=i-r;const e=[];for(let t=0;t<n;++t)e.push(1);t=t.reshape(t.shape.concat(e))}else n=0;if(2===t.shape.length&&2===e.shape.length)a=s[0]===s[1]?t.mul(e).sum(s[0]):t.transpose([1,0]).mul(e).sum(s[1]);else{const n=s[0]!==t.shape.length-1,r=s[1]===e.shape.length-1;a=t.matMul(e,n,r)}if(n>0){let t;t=r>i?r+i-3:r-1;const e=[];for(let r=t;r<t+n;++r)e.push(r);a=a.squeeze(e)}return 1===a.shape.length&&(a=a.expandDims(1)),a})}(n,r,e)}interpretAxes(t,e){let n;return n=Array.isArray(this.axes)?this.axes:[Ri(this.axes,t.length),Ri(this.axes,e.length)],n}computeOutputShape(t){l.util.assert(Array.isArray(t)&&2===t.length&&Array.isArray(t[0])&&Array.isArray(t[1]),()=>"A `Dot` layer should be called on a list of exactly 2 inputs.");const e=t[0].slice(),n=t[1].slice();if(e.length>3||n.length>3)throw new g("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(e,n);e.splice(r[0],1),n.splice(r[1],1),n.splice(0,1);const i=e.concat(n);return 1===i.length&&i.push(1),i}computeMask(t,e){return null}getConfig(){const t={axes:this.axes,normalize:this.normalize},e=super.getConfig();return Object.assign(t,e),t}}Pi.className="Dot",l.serialization.registerClass(Pi);
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
class Fi extends Ie{constructor(t){super(t),this.supportsMasking=!0,this.stddev=t.stddev}computeOutputShape(t){return t}getConfig(){const t=super.getConfig(),e={stddev:this.stddev};return Object.assign(e,t),e}call(t,e){return Object(l.tidy)(()=>{this.invokeCallHook(t,e);const n=ve(t);return Nt(()=>_t(n.shape,0,this.stddev).add(n),()=>n,e.training||!1)})}}Fi.className="GaussianNoise",l.serialization.registerClass(Fi);class zi extends Ie{constructor(t){super(t),this.supportsMasking=!0,this.rate=t.rate}computeOutputShape(t){return t}getConfig(){const t=super.getConfig(),e={rate:this.rate};return Object.assign(e,t),e}call(t,e){return Object(l.tidy)(()=>{this.invokeCallHook(t,e);const n=ve(t);if(this.rate>0&&this.rate<1){return Nt(()=>{const t=Math.sqrt(this.rate/(1-this.rate));return n.mul(_t(n.shape,1,t))},()=>n,e.training||!1)}return n})}}zi.className="GaussianDropout",l.serialization.registerClass(zi);class Li extends Ie{constructor(t){super(t),this.supportsMasking=!0,this.rate=t.rate,this.noiseShape=t.noiseShape}_getNoiseShape(t){return this.noiseShape||ve(t).shape}computeOutputShape(t){return t}getConfig(){const t=super.getConfig(),e={rate:this.rate};return Object.assign(e,t),e}call(t,e){return Object(l.tidy)(()=>{if(this.rate<1&&this.rate>0){const n=this._getNoiseShape(t);return Nt(()=>{const e=ve(t),r=-1.7580993408473766;let i=Object(l.greaterEqual)(Object(l.randomUniform)(n),this.rate);i=ft(i,"float32");const s=((1-this.rate)*(1+this.rate*r**2))**-.5,a=-s*r*this.rate;return e.mul(i).add(i.add(-1).mul(r)).mul(s).add(a)},()=>ve(t),e.training||!1)}return t})}}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
function $i(t,e,n,r,i,s=.001){let a;if(2===t.rank)a=l.batchNorm2d(t,e,n,r,i,s);else if(3===t.rank)a=l.batchNorm3d(t,e,n,r,i,s);else{if(4!==t.rank)throw new g(`batchNormalization is not implemented for array of rank ${t.rank} yet`);a=l.batchNorm4d(t,e,n,r,i,s)}return a}function Bi(t,e,n,r,i=.001){return l.util.arraysEqual(r.slice().sort(),pt(0,t.rank-1))?function(t,e,n,r,i=.001){return Object(l.tidy)(()=>{const s=l.moments(t,r),a=s.mean,o=s.variance;return[$i(t,a,o,n,e,i),a,o]})}(t,e,n,r,i):function(t,e,n,r,i=.001){return Object(l.tidy)(()=>{const s=l.moments(t,r),a=s.mean,o=s.variance,u=[];for(const e of pt(0,t.rank))-1!==r.indexOf(e)?u.push(1):u.push(t.shape[e]);const c=a.reshape(u),h=o.reshape(u),d=null==e?null:e.reshape(u),p=null==n?null:n.reshape(u);return[$i(t,c,h,p,d,i),a,o]})}(t,e,n,r,i)}Li.className="AlphaDropout",l.serialization.registerClass(Li);class qi extends Ie{constructor(t){null==t&&(t={}),super(t),this.supportsMasking=!0,this.axis=null==t.axis?-1:t.axis,this.momentum=null==t.momentum?.99:t.momentum,this.epsilon=null==t.epsilon?.001:t.epsilon,this.center=null==t.center||t.center,this.scale=null==t.scale||t.scale,this.betaInitializer=Yt(t.betaInitializer||"zeros"),this.gammaInitializer=Yt(t.gammaInitializer||"ones"),this.movingMeanInitializer=Yt(t.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=Yt(t.movingVarianceInitializer||"ones"),this.betaConstraint=U(t.betaConstraint),this.gammaConstraint=U(t.gammaConstraint),this.betaRegularizer=Ir(t.betaRegularizer),this.gammaRegularizer=Ir(t.gammaRegularizer)}build(t){t=we(t);const e=this.axis>=0?this.axis:this.axis+t.length,n=t[e];if(null==n)throw new m(`Axis ${e} of input tensor should have a defined dimension but the layer received an input with shape `+JSON.stringify(t)+".");this.inputSpec=[new ke({ndim:t.length,axes:{[e]:n}})];const r=[n];this.scale&&(this.gamma=this.addWeight("gamma",r,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",r,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",r,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",r,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(t,e){return Object(l.tidy)(()=>{const n=null!=e.training&&e.training,r=ve(t),i=r.shape,s=i.length,a=pt(0,s),o=this.axis>=0?this.axis:this.axis+s;a.splice(o,1);const u=y(1,s);u[o]=i[o];const c=a.slice();c.sort();const h=!l.util.arraysEqual(c,pt(0,s).slice(0,s-1));if(!n)return(()=>{if(h){const t=this.movingMean.read().reshape(u),e=this.movingVariance.read().reshape(u),n=this.center?this.beta.read().reshape(u):null,i=this.scale?this.gamma.read().reshape(u):null;return $i(r,t,e,n,i,this.epsilon)}return $i(r,this.movingMean.read(),this.movingVariance.read(),null==this.beta?null:this.beta.read(),null==this.gamma?null:this.gamma.read(),this.epsilon)})();const[d,p,f]=Bi(r,this.gamma.read(),this.beta.read(),a,this.epsilon),m=(t,e,n)=>{l.tidy(()=>{const r=1-n,i=t.read(),s=i.sub(e).mul(r);t.write(i.sub(s))})};return(()=>{m(this.movingMean,p,this.momentum),m(this.movingVariance,f,this.momentum)})(),d})}getConfig(){const t={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Xt(this.betaInitializer),gammaInitializer:Xt(this.gammaInitializer),movingMeanInitializer:Xt(this.movingMeanInitializer),movingVarianceInitializer:Xt(this.movingVarianceInitializer),betaRegularizer:Ar(this.betaRegularizer),gammaRegularizer:Ar(this.gammaRegularizer),betaConstraint:q(this.betaConstraint),gammaConstraint:q(this.gammaConstraint)},e=super.getConfig();return Object.assign(t,e),t}}qi.className="BatchNormalization",l.serialization.registerClass(qi);class Vi extends Ie{constructor(t){if(null==t&&(t={}),super(t),this.axis=null==t.axis?-1:t.axis,"number"==typeof this.axis){if(!Number.isInteger(this.axis))throw new Error("Expected axis to be an integer, but received "+this.axis)}else{if(!Array.isArray(this.axis))throw new Error("Expected axis to be an integer or an array of integers, but received "+JSON.stringify(this.axis));for(const t of this.axis)if(!Number.isInteger(t))throw new Error("Expected axis to be an array of integers, but received "+JSON.stringify(this.axis))}this.epsilon=null==t.epsilon?.001:t.epsilon,this.center=null==t.center||t.center,this.scale=null==t.scale||t.scale,this.betaInitializer=Yt(t.betaInitializer||"zeros"),this.gammaInitializer=Yt(t.gammaInitializer||"ones"),this.betaRegularizer=Ir(t.betaRegularizer),this.gammaRegularizer=Ir(t.gammaRegularizer),this.supportsMasking=!0}build(t){const e=(t=we(t)).length;"number"==typeof this.axis&&(this.axis=[this.axis]);for(let t=0;t<this.axis.length;++t)this.axis[t]<0&&(this.axis[t]+=e);for(const t of this.axis)if(t<0||t>=e)throw new Error("Invalid axis: "+t);if(this.axis.length!==N(this.axis).length)throw new Error("Found duplicate axes in: "+this.axis);const n=this.axis.map(e=>t[e]);this.scale?this.gamma=this.addWeight("gamma",n,"float32",this.gammaInitializer,this.gammaRegularizer,!0):this.gamma=null,this.center?this.beta=this.addWeight("beta",n,"float32",this.betaInitializer,this.betaRegularizer,!0):this.beta=null,this.built=!0}call(t,e){const n=ve(t),r=n.shape,i=r.length;return Object(l.tidy)(()=>{let{mean:t,variance:e}=Object(l.moments)(n,this.axis,!0);const s=y(1,i);for(const t of this.axis)s[t]=r[t];const a=t=>null!=t&&t.shape.length!==i&&this.axis!==[i-1]?t.reshape(s):t;let o=a(this.gamma.read()),u=a(this.beta.read());const c=[],h=[];for(let t=0;t<i;++t)-1!==this.axis.indexOf(t)?(c.push(r[t]),h.push(1)):(c.push(1),h.push(r[t]));return t=t.tile(c),e=e.tile(c),o=o.tile(h),u=u.tile(h),$i(n,t,e,u,o,this.epsilon)})}getConfig(){const t={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Xt(this.betaInitializer),gammaInitializer:Xt(this.gammaInitializer),betaRegularizer:Ar(this.betaRegularizer),gammaRegularizer:Ar(this.gammaRegularizer)},e=super.getConfig();return Object.assign(t,e),t}}Vi.className="LayerNormalization",l.serialization.registerClass(Vi);class Ui extends Ie{constructor(t){if(null==t&&(t={}),super(t),this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,null==t.padding)this.padding=[[1,1],[1,1]];else if("number"==typeof t.padding)this.padding=[[t.padding,t.padding],[t.padding,t.padding]];else{if(t.padding=t.padding,2!==t.padding.length)throw new m(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${t.padding.length} array.`);let e,n;if("number"==typeof t.padding[0])e=[t.padding[0],t.padding[0]],n=[t.padding[1],t.padding[1]];else{if(t.padding=t.padding,2!==t.padding[0].length)throw new m(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${t.padding[0].length} array.`);if(e=t.padding[0],2!==t.padding[1].length)throw new m(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${t.padding[1].length} array.`);n=t.padding[1]}this.padding=[e,n]}this.inputSpec=[new ke({ndim:4})]}computeOutputShape(t){let e,n;return t=we(t),"channelsFirst"===this.dataFormat?(e=null!=t[2]&&t[2]>=0?t[2]+this.padding[0][0]+this.padding[0][1]:null,n=null!=t[3]&&t[3]>=0?t[3]+this.padding[1][0]+this.padding[1][1]:null,[t[0],t[1],e,n]):(e=null!=t[1]&&t[1]>=0?t[1]+this.padding[0][0]+this.padding[0][1]:null,n=null!=t[2]&&t[2]>=0?t[2]+this.padding[1][0]+this.padding[1][1]:null,[t[0],e,n,t[3]])}call(t,e){return Object(l.tidy)(()=>{return e=ve(t),n=this.padding,r=this.dataFormat,Object(l.tidy)(()=>{if(4!==e.rank)throw new m("temporalPadding expects input tensor to be 4-D, but received a "+e.rank+"-D tensor.");if(null==n&&(n=[[1,1],[1,1]]),2!==n.length||2!==n[0].length||2!==n[1].length)throw new m("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==r&&(r="channelsLast"),"channelsLast"!==r&&"channelsFirst"!==r)throw new m(`Unknown data format: ${r}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let t;return t="channelsFirst"===r?[[0,0],[0,0],n[0],n[1]]:[[0,0],n[0],n[1],[0,0]],l.pad(e,t)});var e,n,r})}getConfig(){const t={padding:this.padding,dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
function Wi(t,e,n,r,i,s){return Object(l.tidy)(()=>{let a;tt(i),nt(s),et(r),null==n&&(n=[1,1]),null==r&&(r="valid"),null==i&&(i="channelsLast"),null==s&&(s="max"),t=$r(t,i);const o="same"===r?"same":"valid";return a="max"===s?l.maxPool(t,e,n,o):l.avgPool(t,e,n,o),"channelsFirst"===i&&(a=l.transpose(a,[0,3,1,2])),a})}function Gi(t,e,n,r,i,s){return Object(l.tidy)(()=>{let a;tt(i),nt(s),et(r),null==n&&(n=[1,1,1]),null==r&&(r="valid"),null==i&&(i="channelsLast"),null==s&&(s="max"),t=Br(t,i);const o="same"===r?"same":"valid";return a="max"===s?l.maxPool3d(t,e,n,o):l.avgPool3d(t,e,n,o),"channelsFirst"===i&&(a=l.transpose(a,[0,4,1,2,3])),a})}Ui.className="ZeroPadding2D",l.serialization.registerClass(Ui);class Hi extends Ie{constructor(t){if(null==t.poolSize&&(t.poolSize=2),super(t),"number"==typeof t.poolSize)this.poolSize=[t.poolSize];else{if(!Array.isArray(t.poolSize)||1!==t.poolSize.length||"number"!=typeof t.poolSize[0])throw new m("poolSize for 1D convolutional layer must be a number or an Array of a single number, but received "+JSON.stringify(t.poolSize));this.poolSize=t.poolSize}if(M(this.poolSize,"poolSize"),null==t.strides)this.strides=this.poolSize;else if("number"==typeof t.strides)this.strides=[t.strides];else{if(!Array.isArray(t.strides)||1!==t.strides.length||"number"!=typeof t.strides[0])throw new m("strides for 1D convolutional layer must be a number or an Array of a single number, but received "+JSON.stringify(t.strides));this.strides=t.strides}M(this.strides,"strides"),this.padding=null==t.padding?"valid":t.padding,et(this.padding),this.inputSpec=[new ke({ndim:3})]}computeOutputShape(t){const e=zr((t=we(t))[1],this.poolSize[0],this.padding,this.strides[0]);return[t[0],e,t[2]]}call(t,e){return Object(l.tidy)(()=>{this.invokeCallHook(t,e),t=mt(ve(t),2);const n=this.poolingFunction(ve(t),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return l.squeeze(n,[2])})}getConfig(){const t={poolSize:this.poolSize,padding:this.padding,strides:this.strides},e=super.getConfig();return Object.assign(t,e),t}}class Ki extends Hi{constructor(t){super(t)}poolingFunction(t,e,n,r,i){return tt(i),et(r),Wi(t,e,n,r,i,"max")}}Ki.className="MaxPooling1D",l.serialization.registerClass(Ki);class Qi extends Hi{constructor(t){super(t)}poolingFunction(t,e,n,r,i){return tt(i),et(r),Wi(t,e,n,r,i,"avg")}}Qi.className="AveragePooling1D",l.serialization.registerClass(Qi);class Xi extends Ie{constructor(t){if(null==t.poolSize&&(t.poolSize=[2,2]),super(t),this.poolSize=Array.isArray(t.poolSize)?t.poolSize:[t.poolSize,t.poolSize],null==t.strides)this.strides=this.poolSize;else if(Array.isArray(t.strides)){if(2!==t.strides.length)throw new m("If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length "+t.strides.length+".");this.strides=t.strides}else this.strides=[t.strides,t.strides];M(this.poolSize,"poolSize"),M(this.strides,"strides"),this.padding=null==t.padding?"valid":t.padding,this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,tt(this.dataFormat),et(this.padding),this.inputSpec=[new ke({ndim:4})]}computeOutputShape(t){t=we(t);let e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2];return e=zr(e,this.poolSize[0],this.padding,this.strides[0]),n=zr(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[t[0],t[1],e,n]:[t[0],e,n,t[3]]}call(t,e){return Object(l.tidy)(()=>(this.invokeCallHook(t,e),this.poolingFunction(ve(t),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){const t={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}class Yi extends Xi{constructor(t){super(t)}poolingFunction(t,e,n,r,i){return tt(i),et(r),Wi(t,e,n,r,i,"max")}}Yi.className="MaxPooling2D",l.serialization.registerClass(Yi);class Ji extends Xi{constructor(t){super(t)}poolingFunction(t,e,n,r,i){return tt(i),et(r),Wi(t,e,n,r,i,"avg")}}Ji.className="AveragePooling2D",l.serialization.registerClass(Ji);class Zi extends Ie{constructor(t){if(null==t.poolSize&&(t.poolSize=[2,2,2]),super(t),this.poolSize=Array.isArray(t.poolSize)?t.poolSize:[t.poolSize,t.poolSize,t.poolSize],null==t.strides)this.strides=this.poolSize;else if(Array.isArray(t.strides)){if(3!==t.strides.length)throw new m("If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length "+t.strides.length+".");this.strides=t.strides}else this.strides=[t.strides,t.strides,t.strides];M(this.poolSize,"poolSize"),M(this.strides,"strides"),this.padding=null==t.padding?"valid":t.padding,this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,tt(this.dataFormat),et(this.padding),this.inputSpec=[new ke({ndim:5})]}computeOutputShape(t){t=we(t);let e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2],r="channelsFirst"===this.dataFormat?t[4]:t[3];return e=zr(e,this.poolSize[0],this.padding,this.strides[0]),n=zr(n,this.poolSize[1],this.padding,this.strides[1]),r=zr(r,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat?[t[0],t[1],e,n,r]:[t[0],e,n,r,t[4]]}call(t,e){return Object(l.tidy)(()=>(this.invokeCallHook(t,e),this.poolingFunction(ve(t),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){const t={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}class ts extends Zi{constructor(t){super(t)}poolingFunction(t,e,n,r,i){return tt(i),et(r),Gi(t,e,n,r,i,"max")}}ts.className="MaxPooling3D",l.serialization.registerClass(ts);class es extends Zi{constructor(t){super(t)}poolingFunction(t,e,n,r,i){return tt(i),et(r),Gi(t,e,n,r,i,"avg")}}es.className="AveragePooling3D",l.serialization.registerClass(es);class ns extends Ie{constructor(t){super(t),this.inputSpec=[new ke({ndim:3})]}computeOutputShape(t){return[t[0],t[2]]}call(t,e){throw new g}}class rs extends ns{constructor(t){super(t||{})}call(t,e){return Object(l.tidy)(()=>{const e=ve(t);return l.mean(e,1)})}}rs.className="GlobalAveragePooling1D",l.serialization.registerClass(rs);class is extends ns{constructor(t){super(t||{})}call(t,e){return Object(l.tidy)(()=>{const e=ve(t);return l.max(e,1)})}}is.className="GlobalMaxPooling1D",l.serialization.registerClass(is);class ss extends Ie{constructor(t){super(t),this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,tt(this.dataFormat),this.inputSpec=[new ke({ndim:4})]}computeOutputShape(t){return t=t,"channelsLast"===this.dataFormat?[t[0],t[3]]:[t[0],t[1]]}call(t,e){throw new g}getConfig(){const t={dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}class as extends ss{call(t,e){return Object(l.tidy)(()=>{const e=ve(t);return"channelsLast"===this.dataFormat?l.mean(e,[1,2]):l.mean(e,[2,3])})}}as.className="GlobalAveragePooling2D",l.serialization.registerClass(as);class os extends ss{call(t,e){return Object(l.tidy)(()=>{const e=ve(t);return"channelsLast"===this.dataFormat?l.max(e,[1,2]):l.max(e,[2,3])})}}os.className="GlobalMaxPooling2D",l.serialization.registerClass(os);
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
class us extends Ie{constructor(t){super(t),this.layer=t.layer}build(t){this.built=!0}get trainable(){return null!=this.layer&&this.layer.trainable}set trainable(t){null!=this.layer&&(this.layer.trainable=t)}get trainableWeights(){return this.layer.trainableWeights}get nonTrainableWeights(){return this.layer.nonTrainableWeights}get updates(){return this.layer._updates}get losses(){return this.layer.losses}getWeights(){return this.layer.getWeights()}setWeights(t){this.layer.setWeights(t)}getConfig(){const t={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},e=super.getConfig();return Object.assign(t,e),t}setFastWeightInitDuringBuild(t){super.setFastWeightInitDuringBuild(t),null!=this.layer&&this.layer.setFastWeightInitDuringBuild(t)}static fromConfig(t,e,n={}){const r=Ue(e.layer,n);delete e.layer;const i={layer:r};return Object.assign(i,e),new t(i)}}class cs extends us{constructor(t){super(t),this.supportsMasking=!0}build(t){if((t=we(t)).length<3)throw new m("TimeDistributed layer expects an input shape >= 3D, but received input shape "+JSON.stringify(t));this.inputSpec=[{shape:t}];const e=[t[0]].concat(t.slice(2));this.layer.built||(this.layer.build(e),this.layer.built=!0),super.build(t)}computeOutputShape(t){const e=[(t=we(t))[0]].concat(t.slice(2)),n=this.layer.computeOutputShape(e),r=t[1];return[n[0],r].concat(n.slice(1))}call(t,e){return Object(l.tidy)(()=>ri((t,n)=>[ve(this.layer.call(t,e)),[]],t=ve(t),[],!1,null,null,!1,!0)[1])}}cs.className="TimeDistributed",l.serialization.registerClass(cs);class ls extends us{constructor(t){super(t);const e=t.layer.getConfig(),n={};n.className=t.layer.getClassName(),n.config=e,this.forwardLayer=Ue(n),e.goBackwards=!0!==e.goBackwards;const r={};var i;if(r.className=t.layer.getClassName(),r.config=e,this.backwardLayer=Ue(r),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=void 0===t.mergeMode?"concat":t.mergeMode,i=this.mergeMode,E(J,"BidirectionalMergeMode",i),t.weights)throw new g("weights support is not implemented for Bidirectional layer yet.");this._stateful=t.layer.stateful,this.returnSequences=t.layer.returnSequences,this.returnState=t.layer.returnState,this.supportsMasking=!0,this._trainable=!0,this.inputSpec=t.layer.inputSpec,this.numConstants=null}get trainable(){return this._trainable}set trainable(t){this._trainable=t,null!=this.forwardLayer&&(this.forwardLayer.trainable=t),null!=this.backwardLayer&&(this.backwardLayer.trainable=t)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(t){const e=t.length,n=Math.floor(e/2);this.forwardLayer.setWeights(t.slice(0,n)),this.backwardLayer.setWeights(t.slice(n))}computeOutputShape(t){let e,n,r,i=this.forwardLayer.computeOutputShape(t);return Array.isArray(i)&&Array.isArray(i[0])||(i=[i]),i=i,this.returnState?(r=i.slice(1),e=i[0]):e=i[0],e=e,"concat"===this.mergeMode?(e[e.length-1]*=2,n=[e]):n=null==this.mergeMode?[e,e.slice()]:[e],this.returnState?null==this.mergeMode?n.concat(r).concat(r.slice()):[e].concat(r).concat(r.slice()):x(n)}apply(t,e){let n=null==e?null:e.initialState,r=null==e?null:e.constants;null==e&&(e={});const i=ni(t,n,r,this.numConstants);if(t=i.inputs,n=i.initialState,r=i.constants,Array.isArray(t)&&(n=t.slice(1),t=t[0]),(null==n||0===n.length)&&null==r)return super.apply(t,e);const s=[],a=[];if(null!=n){const t=n.length;if(t%2>0)throw new m("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");e.initialState=n,s.push(...n);const r=n.map(t=>new ke({shape:t.shape}));this.forwardLayer.stateSpec=r.slice(0,t/2),this.backwardLayer.stateSpec=r.slice(t/2),a.push(...r)}if(null!=r)throw new g("Support for constants in Bidirectional layers is not implemented yet.");const o=s[0]instanceof Te;for(const t of s)if(t instanceof Te!==o)throw new m("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(o){const n=[t].concat(s),r=this.inputSpec.concat(a),i=this.inputSpec;this.inputSpec=r;const o=super.apply(n,e);return this.inputSpec=i,o}return super.apply(t,e)}call(t,e){return Object(l.tidy)(()=>{const n=e.initialState;let r,i,s,a;if(null==n)r=this.forwardLayer.call(t,e),i=this.backwardLayer.call(t,e);else{const s=n.slice(0,n.length/2),a=n.slice(n.length/2);r=this.forwardLayer.call(t,Object.assign(e,{initialState:s})),i=this.backwardLayer.call(t,Object.assign(e,{initialState:a}))}return this.returnState&&(Array.isArray(r)&&(s=r.slice(1).concat(i.slice(1))),r=r[0],i=i[0]),this.returnSequences&&(i=l.reverse(i,1)),"concat"===this.mergeMode?a=vt([r,i]):"sum"===this.mergeMode?a=l.add(r,i):"ave"===this.mergeMode?a=l.mul(.5,l.add(r,i)):"mul"===this.mergeMode?a=l.mul(r,i):null==this.mergeMode&&(a=[r,i]),this.returnState?null==this.mergeMode?a.concat(s):[a].concat(s):a})}resetStates(t){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(t){it(this.forwardLayer.name,()=>{this.forwardLayer.build(t)}),it(this.backwardLayer.name,()=>{this.backwardLayer.build(t)}),this.built=!0}computeMask(t,e){let n;if(Array.isArray(e)&&(e=e[0]),n=this.returnSequences?null==this.mergeMode?[e,e]:e:null==this.mergeMode?[null,null]:null,this.returnState){const t=this.forwardLayer.states.map(t=>null);return Array.isArray(n)?n.concat(t).concat(t):[n].concat(t).concat(t)}return n}get trainableWeights(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)}get nonTrainableWeights(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)}setFastWeightInitDuringBuild(t){super.setFastWeightInitDuringBuild(t),null!=this.forwardLayer&&this.forwardLayer.setFastWeightInitDuringBuild(t),null!=this.backwardLayer&&this.backwardLayer.setFastWeightInitDuringBuild(t)}getConfig(){const t={mergeMode:this.mergeMode},e=super.getConfig();return Object.assign(t,e),t}static fromConfig(t,e){const n=Ue(e.layer);if(delete e.layer,null!=e.numConstants)throw new g("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");const r=e;return r.layer=n,new t(r)}}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
function hs(t){return new Ee(t)}function ds(t){return new Dr(t)}function ps(t){return new Er(t)}function fs(t){return new jr(t)}function ms(t){return new Mr(t)}function gs(t){return new Pr(t)}function bs(t){return new Rr(t)}function ys(t){return new Jr(t)}function vs(t){return new Hr(t)}function ws(t){return new Qr(t)}function xs(t){return new Kr(t)}function _s(t){return new Yr(t)}function Os(t){return new Zr(t)}function Ss(t){return new ti(t)}function ks(t){return new ei(t)}function Ts(t){return new _i(t)}function Cs(t){return new wi(t)}function As(t){return new yi(t)}function Ns(t){return new vi(t)}function Is(t){return new xi(t)}function Es(t){return new Oi(t)}function js(t){return new Si(t)}function Ms(t){return new ki(t)}function Ds(t){return new Ci(t)}function Rs(t){return new Ni(t)}function Ps(t){return new Ei(t)}function Fs(t){return new Di(t)}function zs(t){return new ji(t)}function Ls(t){return new Mi(t)}function $s(t){return new Ii(t)}function Bs(t){return new Pi(t)}function qs(t){return new qi(t)}function Vs(t){return new Vi(t)}function Us(t){return new Ui(t)}function Ws(t){return new Qi(t)}function Gs(t){return Ws(t)}function Hs(t){return Ws(t)}function Ks(t){return new Ji(t)}function Qs(t){return Ks(t)}function Xs(t){return Ks(t)}function Ys(t){return new es(t)}function Js(t){return Ys(t)}function Zs(t){return Ys(t)}function ta(t){return new rs(t)}function ea(t){return new as(t)}function na(t){return new is(t)}function ra(t){return new os(t)}function ia(t){return new Ki(t)}function sa(t){return new Yi(t)}function aa(t){return new ts(t)}function oa(t){return new ci(t)}function ua(t){return new ui(t)}function ca(t){return new hi(t)}function la(t){return new li(t)}function ha(t){return new oi(t)}function da(t){return new ai(t)}function pa(t){return new bi(t)}function fa(t){return new gi(t)}function ma(t){return new ii(t)}function ga(t){return new di(t)}function ba(t){return new ls(t)}function ya(t){return new cs(t)}ls.className="Bidirectional",l.serialization.registerClass(ls);const va=na,wa=ra,xa=ia,_a=sa;function Oa(t){return new Fi(t)}function Sa(t){return new zi(t)}function ka(t){return new Li(t)}function Ta(t){return new Ti(t)}function Ca(t,e){return rn(t,e)}function Aa(t,e){return cn(t,e)}function Na(t,e){return ln(t,e)}function Ia(t,e){return sn(t,e)}function Ea(t,e){return hn(t,e)}function ja(t,e){return on(t,e)}function Ma(t,e){return un(t,e)}function Da(t,e){return tn(t,e)}function Ra(t,e){return He(t,e)}function Pa(t,e){return Ke(t,e)}function Fa(t,e){return Ke(t,e)}function za(t,e){return Ke(t,e)}function La(t,e){return Ge(t,e)}function $a(t,e){return Ge(t,e)}function Ba(t,e){return Ge(t,e)}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */function qa(t){return new Tr(t)}function Va(t){return Sr(e=t),new Tr({l1:null!=e?e.l1:null,l2:0});var e}function Ua(t){return Sr(e=t),new Tr({l2:null!=e?e.l2:null,l1:0});var e}
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */class Wa extends Pe{constructor(){super(...arguments),this.model=null}setModel(t){if(!(t instanceof Yn))throw new Error("model must be a LayersModel, not some other Container");this.model=t}}function Ga(t,e){return t<e}function Ha(t,e){return t>e}class Ka extends Wa{constructor(t){if(super(),null==t&&(t={}),t.restoreBestWeights)throw new g("restoreBestWeights = True is not implemented in EarlyStopping yet.");this.monitor=t.monitor||"val_loss",this.minDelta=Math.abs(t.minDelta||0),this.patience=t.patience||0,this.verbose=t.verbose||0,this.mode=t.mode||"auto",this.baseline=t.baseline,-1===["auto","min","max"].indexOf(this.mode)&&(console.warn(`EarlyStopping mode '${this.mode}' is invalid. Falling back to mode 'auto'.`),this.mode="auto"),"min"===this.mode?this.monitorFunc=Ga:"max"===this.mode||-1!==this.monitor.indexOf("acc")?this.monitorFunc=Ha:this.monitorFunc=Ga,this.monitorFunc===Ga&&(this.minDelta*=-1)}async onTrainBegin(t){this.wait=0,this.stoppedEpoch=0,null!=this.baseline?this.best=this.baseline:this.best=this.monitorFunc===Ga?1/0:-1/0}async onEpochEnd(t,e){await Me(e);const n=this.getMonitorValue(e);null!=n&&(this.monitorFunc(n-this.minDelta,this.best)?(this.best=n,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=t,this.model.stopTraining=!0)))}async onTrainEnd(t){this.stoppedEpoch>0&&this.verbose&&console.log(`Epoch ${this.stoppedEpoch}: early stopping.`)}getMonitorValue(t){null==t&&(t={});const e=t[this.monitor];return null==e&&console.warn(`Metric for EarlyStopping ${this.monitor} is not available. Available metrics are: `+Object.keys(t)),e}}const Qa={earlyStopping:function(t){return new Ka(t)}};
/**
 * @license
 * Copyright 2018 Google LLC
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 * =============================================================================
 */var Xa=n(60),Ya=n(2);
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class Ja{constructor(t,e,n){this.node=t,this.tensorMap=e,this.context=n,this.inputs=[],this.attrs={},this.inputs=t.inputNames.map(t=>this.getInput(t)),null!=t.rawAttrs&&(this.attrs=Object.keys(t.rawAttrs).reduce((t,e)=>(t[e]=this.getAttr(e),t),{}))}getInput(t){return Object(Ya.e)(t,this.tensorMap,this.context)}getAttr(t,e){const n=this.node.rawAttrs[t];if(null!=n.tensor)return Object(Ya.e)(t,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return Object(Xa.f)(this.node.rawAttrs,t,e);if(null!=n.s)return Object(Xa.i)(this.node.rawAttrs,t,e);if(null!=n.b)return Object(Xa.c)(this.node.rawAttrs,t,e);if(null!=n.shape)return Object(Xa.k)(this.node.rawAttrs,t,e);if(null!=n.type)return Object(Xa.e)(this.node.rawAttrs,t,e);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return Object(Xa.g)(this.node.rawAttrs,t,e);if(null!=n.list.s)return Object(Xa.h)(this.node.rawAttrs,t,e);if(null!=n.list.shape)return Object(Xa.j)(this.node.rawAttrs,t,e);if(null!=n.list.b)return Object(Xa.b)(this.node.rawAttrs,t,e);if(null!=n.list.type)return Object(Xa.d)(this.node.rawAttrs,t,e)}return e}}var Za=n(112),to=n(13),eo=n(220),no=n(132),ro=n(9),io=n(16),so=n(168),ao=n(122),oo=n(14),uo=n(103),co=n(68),lo=n(44),ho=n(106);var po=n(41),fo=n(218),mo=n(219),go=n(221),bo=n(222),yo=n(223),vo=n(162),wo=n(224),xo=n(226),_o=n(51),Oo=n(125),So=n(165),ko=n(127),To=n(229),Co=n(40),Ao=n(230),No=n(128),Io=n(76),Eo=n(174),jo=n(100),Mo=n(30),Do=n(241),Ro=n(94),Po=n(84),Fo=n(242),zo=n(182),Lo=n(87),$o=n(184),Bo=n(244),qo=n(185),Vo=n(175),Uo=n(35),Wo=n(27),Go=n(149),Ho=n(247),Ko=n(227),Qo=n(181),Xo=n(179),Yo=n(172),Jo=n(133);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function Zo(t,e,n=""){l.util.assert(function(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(-1!==t[n]&&-1!==e[n]&&t[n]!==e[n])return!1;return!0}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */(t,e),()=>n+` Shapes ${t} and ${e} must match`)}class tu{constructor(t,e,n,r,i,s,a){this.name=t,this.dtype=e,this.maxSize=n,this.elementShape=r,this.identicalElementShapes=i,this.dynamicSize=s,this.clearAfterRead=a,this.tensors=[],this.closed_=!1,this.idTensor=Object(l.scalar)(0),Object(l.keep)(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(t){this.tensors.forEach(e=>{null!=t&&t.has(e.tensor.id)||e.tensor.dispose()}),this.tensors=[],this.closed_=!0,this.idTensor.dispose()}size(){return this.tensors.length}read(t){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(t<0||t>=this.size())throw new Error(`Tried to read from index ${t}, but array size is: ${this.size()}`);const e=this.tensors[t];if(e.cleared)throw new Error(`TensorArray ${this.name}: Could not read index ${t} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);return this.clearAfterRead&&(e.cleared=!0),e.read=!0,e.tensor}readMany(t){return t.map(t=>this.read(t))}write(t,e){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(t<0||!this.dynamicSize&&t>=this.maxSize)throw new Error(`Tried to write to index ${t}, but array is not resizeable and size is: ${this.maxSize}`);const n=this.tensors[t]||{};if(e.dtype!==this.dtype)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${t},\n          because the value dtype is ${e.dtype}, but TensorArray dtype is ${this.dtype}.`);if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=e.shape),Zo(this.elementShape,e.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${t}.`),n.read)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${t}, because it has already been read.`);if(n.written)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${t}, because it has already been written.`);n.tensor=e,Object(l.keep)(e),n.written=!0,this.tensors[t]=n}writeMany(t,e){if(t.length!==e.length)throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${t.length} is not the same as tensors size: ${e.length}.`);t.forEach((t,n)=>this.write(t,e[n]))}gather(t,e){if(e&&e!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${e}`);if(t)t=t.slice(0,this.size());else{t=[];for(let e=0;e<this.size();e++)t.push(e)}if(0===t.length)return Object(l.tensor)([],[0].concat(this.elementShape));const n=this.readMany(t);return Zo(this.elementShape,n[0].shape,"TensorArray shape mismatch: "),Object(l.stack)(n,0)}concat(t){if(t&&t!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but concat requested dtype ${t}`);if(0===this.size())return Object(l.tensor)([],[0].concat(this.elementShape));const e=[];for(let t=0;t<this.size();t++)e.push(t);const n=this.readMany(e);return Zo(this.elementShape,n[0].shape,`TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${n[0].shape})`),Object(l.concat)(n,0)}scatter(t,e){if(e.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${e.dtype}`);if(t.length!==e.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`);const n=Math.max(...t);if(!this.dynamicSize&&n>=this.maxSize)throw new Error(`Max index must be < array size (${n}  vs. ${this.maxSize})`);this.writeMany(t,Object(l.unstack)(e,0))}split(t,e){if(e.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${e.dtype}`);let n=0;const r=t.map(t=>(n+=t,n));if(n!==e.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: ${e.shape}`);if(!this.dynamicSize&&t.length!==this.maxSize)throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${t.length}), and the TensorArray is not marked as dynamically resizeable`);const i=0===n?0:e.size/n,s=[];Object(l.tidy)(()=>{e=Object(l.reshape)(e,[1,n,i]);for(let n=0;n<t.length;++n){const a=[0,0===n?0:r[n-1],0],o=[1,t[n],i];s[n]=Object(l.reshape)(Object(l.slice)(e,a,o),this.elementShape)}return s});const a=[];for(let e=0;e<t.length;e++)a[e]=e;this.writeMany(a,s)}}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class eu{constructor(t,e,n,r=-1){this.tensors=t,this.elementShape=e,this.elementDtype=n,null!=t&&t.forEach(t=>{if(n!==t.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${t.dtype}`);Zo(e,t.shape,"TensorList shape mismatch: "),Object(l.keep)(t)}),this.idTensor=Object(l.scalar)(0),this.maxNumElements=r,Object(l.keep)(this.idTensor)}get id(){return this.idTensor.id}copy(){return new eu([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(t){this.tensors.forEach(e=>{null!=t&&t.has(e.id)||e.dispose()}),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(t,e,n=-1){if(e!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e}, 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.`);return Zo(t,this.elementShape,"TensorList shape mismatch: "),Object(l.tidy)(()=>{const e=this.tensors.map(e=>Object(l.reshape)(e,t));return Object(l.stack)(e,0)})}popBack(t,e){if(e!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e}, but list elements ${this.elementDtype}`);if(0===this.size())throw new Error("Trying to pop from an empty list.");const n=this.tensors.pop();return Zo(n.shape,t,"TensorList shape mismatch: "),Object(l.reshape)(n,t)}pushBack(t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(Zo(t.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");Object(l.keep)(t),this.tensors.push(t)}resize(t){if(t<0)throw new Error("TensorListResize expects size to be non-negative. Got: "+t);if(-1!==this.maxNumElements&&t>this.maxNumElements)throw new Error(`TensorListResize input size ${t} is greater maxNumElement ${this.maxNumElements}.`);this.tensors.length=t}getItem(t,e,n){if(n!==this.elementDtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${this.elementDtype}`);if(t<0||t>this.tensors.length)throw new Error(`Trying to access element ${t} in a list with ${this.tensors.length} elements.`);if(null==this.tensors[t])throw new Error(`element at index ${t} is null.`);return Zo(this.tensors[t].shape,e,"TensorList shape mismatch: "),this.tensors[t]}setItem(t,e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(t<0||-1!==this.maxNumElements&&t>=this.maxNumElements)throw new Error(`Trying to set element ${t} in a list with max ${this.maxNumElements} elements.`);Zo(this.elementShape,e.shape,"TensorList shape mismatch: "),Object(l.keep)(e),this.tensors[t]=e}gather(t,e,n){if(e!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e}, but list elements ${this.elementDtype}`);return Zo(this.elementShape,n,"TensorList shape mismatch: "),0===(t=t.slice(0,this.size())).length?Object(l.tensor)([],[0].concat(this.elementShape)):Object(l.tidy)(()=>{const e=t.map(t=>Object(l.reshape)(this.tensors[t],n));return Object(l.stack)(e,0)})}concat(t,e){if(t&&t!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${t}`);return Zo(this.elementShape,e,"TensorList shape mismatch: "),0===this.size()?Object(l.tensor)([],[0].concat(this.elementShape)):Object(l.tidy)(()=>{const t=this.tensors.map(t=>Object(l.reshape)(t,e));return Object(l.concat)(t,0)})}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const nu=async(t,e,n)=>{switch(t.op){case"If":case"StatelessIf":{const r=Object(Ya.d)("thenBranch",t,e,n),i=Object(Ya.d)("elseBranch",t,e,n),s=Object(Ya.d)("cond",t,e,n),a=Object(Ya.d)("args",t,e,n);return(await s.data())[0]?n.functionMap[r].executeFunctionAsync(a,n.tensorArrayMap,n.tensorListMap):n.functionMap[i].executeFunctionAsync(a,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{const r=Object(Ya.d)("body",t,e,n),i=Object(Ya.d)("cond",t,e,n),s=Object(Ya.d)("args",t,e,n),a=await n.functionMap[i].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap),o=s.map(t=>t.id);let u=await a[0].data();a.forEach(t=>{t.kept||-1!==o.indexOf(t.id)||t.dispose()});let c=s;for(;u[0];){const t=c;c=await n.functionMap[r].executeFunctionAsync(c,n.tensorArrayMap,n.tensorListMap);const e=c.map(t=>t.id);t.forEach(t=>{t.kept||-1!==o.indexOf(t.id)||-1!==e.indexOf(t.id)||t.dispose()});const s=await n.functionMap[i].executeFunctionAsync(c,n.tensorArrayMap,n.tensorListMap);u=await s[0].data(),s.forEach(t=>{t.kept||-1!==o.indexOf(t.id)||-1!==e.indexOf(t.id)||t.dispose()})}return c}case"LoopCond":{const r=Object(Ya.d)("pred",t,e,n);return[Object(Ya.a)(r)]}case"Switch":{const r=Object(Ya.d)("pred",t,e,n);let i=Object(Ya.d)("data",t,e,n);return i.kept||(i=Object(Ya.a)(i)),(await r.data())[0]?[void 0,i]:[i,void 0]}case"Merge":{const r=t.inputNames.find(t=>void 0!==Object(Ya.e)(t,e,n));if(r){const t=Object(Ya.e)(r,e,n);return[Object(Ya.a)(t)]}return}case"Enter":{const r=Object(Ya.d)("frameName",t,e,n),i=Object(Ya.d)("tensor",t,e,n);return n.enterFrame(r),[Object(Ya.a)(i)]}case"Exit":{const r=Object(Ya.d)("tensor",t,e,n);return n.exitFrame(),[Object(Ya.a)(r)]}case"NextIteration":{const r=Object(Ya.d)("tensor",t,e,n);return n.nextIteration(),[Object(Ya.a)(r)]}case"TensorArrayV3":{const r=Object(Ya.d)("size",t,e,n),i=Object(Ya.d)("dtype",t,e,n),s=Object(Ya.d)("elementShape",t,e,n),a=Object(Ya.d)("dynamicSize",t,e,n),o=Object(Ya.d)("clearAfterRead",t,e,n),u=Object(Ya.d)("identicalElementShapes",t,e,n),c=Object(Ya.d)("name",t,e,n),h=new tu(c,i,r,s,u,a,o);return n.addTensorArray(h),[h.idTensor,Object(l.scalar)(1)]}case"TensorArrayWriteV3":{const r=Object(Ya.d)("tensorArrayId",t,e,n),i=Object(Ya.d)("index",t,e,n),s=Object(Ya.d)("tensor",t,e,n),a=n.getTensorArray(r.id);return a.write(i,s),[a.idTensor]}case"TensorArrayReadV3":{const r=Object(Ya.d)("tensorArrayId",t,e,n),i=Object(Ya.d)("index",t,e,n);return[n.getTensorArray(r.id).read(i)]}case"TensorArrayGatherV3":{const r=Object(Ya.d)("tensorArrayId",t,e,n),i=Object(Ya.d)("indices",t,e,n),s=Object(Ya.d)("dtype",t,e,n);return[n.getTensorArray(r.id).gather(i,s)]}case"TensorArrayScatterV3":{const r=Object(Ya.d)("tensorArrayId",t,e,n),i=Object(Ya.d)("indices",t,e,n),s=Object(Ya.d)("tensor",t,e,n),a=n.getTensorArray(r.id);return a.scatter(i,s),[a.idTensor]}case"TensorArrayConcatV3":{const r=Object(Ya.d)("tensorArrayId",t,e,n),i=n.getTensorArray(r.id),s=Object(Ya.d)("dtype",t,e,n);return[i.concat(s)]}case"TensorArraySplitV3":{const r=Object(Ya.d)("tensorArrayId",t,e,n),i=Object(Ya.d)("tensor",t,e,n),s=Object(Ya.d)("lengths",t,e,n),a=n.getTensorArray(r.id);return a.split(s,i),[a.idTensor]}case"TensorArraySizeV3":{const r=Object(Ya.d)("tensorArrayId",t,e,n),i=n.getTensorArray(r.id);return[Object(l.scalar)(i.size(),"int32")]}case"TensorArrayCloseV3":{const r=Object(Ya.d)("tensorArrayId",t,e,n),i=n.getTensorArray(r.id);return i.clearAndClose(),[i.idTensor]}case"TensorListSetItem":{const r=Object(Ya.d)("tensorListId",t,e,n),i=Object(Ya.d)("index",t,e,n),s=Object(Ya.d)("tensor",t,e,n),a=n.getTensorList(r.id);return a.setItem(i,s),[a.idTensor]}case"TensorListGetItem":{const r=Object(Ya.d)("tensorListId",t,e,n),i=Object(Ya.d)("index",t,e,n),s=Object(Ya.d)("elementShape",t,e,n),a=Object(Ya.d)("elementDType",t,e,n);return[n.getTensorList(r.id).getItem(i,s,a)]}case"TensorListScatterV2":case"TensorListScatter":{const r=Object(Ya.d)("indices",t,e,n),i=function(t,e,n,r){if(e.length!==t.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${t.shape[0]}`);const i=Math.max(...e);if(null!=r&&-1!==r&&i>=r)throw new Error(`Max index must be < array size (${i}  vs. ${r})`);const s=new eu([],n,t.dtype,r),a=Object(l.unstack)(t,0);return e.forEach((t,e)=>{s.setItem(t,a[e])}),s}(Object(Ya.d)("tensor",t,e,n),r,Object(Ya.d)("elementShape",t,e,n),Object(Ya.d)("numElements",t,e,n));return n.addTensorList(i),[i.idTensor]}case"TensorListReserve":{const r=function(t,e,n){return new eu([],t,e,n)}(Object(Ya.d)("elementShape",t,e,n),Object(Ya.d)("elementDType",t,e,n),Object(Ya.d)("numElements",t,e,n));return n.addTensorList(r),[r.idTensor]}case"TensorListGather":{const r=Object(Ya.d)("tensorListId",t,e,n),i=Object(Ya.d)("indices",t,e,n),s=Object(Ya.d)("elementShape",t,e,n),a=Object(Ya.d)("elementDType",t,e,n);return[n.getTensorList(r.id).gather(i,a,s)]}case"TensorListStack":{const r=Object(Ya.d)("tensorListId",t,e,n),i=Object(Ya.d)("elementShape",t,e,n),s=Object(Ya.d)("elementDType",t,e,n),a=Object(Ya.d)("numElements",t,e,n);return[n.getTensorList(r.id).stack(i,s,a)]}case"TensorListFromTensor":{const r=function(t,e,n){const r=t.dtype;if(t.shape.length<1)throw new Error("Tensor must be at least a vector, but saw shape: "+t.shape);if(t.dtype!==n)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${n}`);Zo(t.shape.slice(1),e,"TensorList shape mismatch: ");const i=Object(l.unstack)(t);return new eu(i,e,r)}(Object(Ya.d)("tensor",t,e,n),Object(Ya.d)("elementShape",t,e,n),Object(Ya.d)("elementDType",t,e,n));return n.addTensorList(r),[r.idTensor]}case"TensorListConcat":{const r=Object(Ya.d)("tensorListId",t,e,n),i=n.getTensorList(r.id),s=Object(Ya.d)("dtype",t,e,n),a=Object(Ya.d)("elementShape",t,e,n);return[i.concat(s,a)]}case"TensorListPushBack":{const r=Object(Ya.d)("tensorListId",t,e,n),i=Object(Ya.d)("tensor",t,e,n),s=n.getTensorList(r.id);return s.pushBack(i),[s.idTensor]}case"TensorListPopBack":{const r=Object(Ya.d)("tensorListId",t,e,n),i=Object(Ya.d)("elementShape",t,e,n),s=Object(Ya.d)("elementDType",t,e,n);return[n.getTensorList(r.id).popBack(i,s)]}case"TensorListSplit":{const r=Object(Ya.d)("tensor",t,e,n),i=Object(Ya.d)("elementShape",t,e,n),s=function(t,e,n){let r=0;const i=e.map(t=>(r+=t,r));if(r!==t.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: ${t.shape}`);const s=0===r?0:t.size/r,a=Object(l.tidy)(()=>{const a=[];t=Object(l.reshape)(t,[1,r,s]);for(let r=0;r<e.length;++r){const o=[0,0===r?0:i[r-1],0],u=[1,e[r],s];a[r]=Object(l.reshape)(Object(l.slice)(t,o,u),n)}return t.dispose(),a}),o=new eu([],n,t.dtype,e.length);for(let t=0;t<a.length;t++)o.setItem(t,a[t]);return o}(r,Object(Ya.d)("lengths",t,e,n),i);return n.addTensorList(s),[s.idTensor]}default:throw TypeError(`Node type ${t.op} is not implemented`)}};var ru=n(163),iu=n(69),su=n(19),au=n(164),ou=n(81),uu=n(228),cu=n(124),lu=n(131),hu=n(238),du=n(225),pu=n(237),fu=n(167);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function mu(t,e,n){const[r,i]=Object(Ya.d)("fusedOps",t,e,n),s="biasadd"===r,a="prelu"===i,o="fusedbatchnorm"===r,u=Object(Ya.d)("numArgs",t,e,n);if(s){if(a&&2!==u)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!a&&1!==u)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(o)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported.");const c=Object(Ya.d)("strides",t,e,n),l=Object(Ya.c)(t,e,n),h=Object(Ya.d)("dataFormat",t,e,n).toUpperCase(),d=Object(Ya.d)("dilations",t,e,n),[p,f]=Object(Ya.d)("args",t,e,n);return{stride:c,pad:l,dataFormat:h,dilations:d,biasArg:p,preluArg:f,activationFunc:i}}var gu=n(123),bu=n(234),yu=n(239),vu=n(115),wu=n(83),xu=n(240),_u=n(180),Ou=n(150),Su=n(248),ku=n(58),Tu=n(23);var Cu=n(12),Au=n(191),Nu=n(243);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function Iu(t,e,n){return{boxes:Object(Ya.d)("boxes",t,e,n),scores:Object(Ya.d)("scores",t,e,n),maxOutputSize:Object(Ya.d)("maxOutputSize",t,e,n),iouThreshold:Object(Ya.d)("iouThreshold",t,e,n),scoreThreshold:Object(Ya.d)("scoreThreshold",t,e,n),softNmsSigma:Object(Ya.d)("softNmsSigma",t,e,n)}}var Eu=n(189),ju=n(190);var Mu=n(77),Du=n(15);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class Ru{constructor(t,e){this.keyDType=t,this.valueDType=e,this.handle=Object(l.scalar)(0),this.tensorMap=new Map,Object(l.keep)(this.handle)}get id(){return this.handle.id}clearAndClose(){this.tensorMap.forEach(t=>t.dispose()),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}async import(t,e){this.checkKeyAndValueTensor(t,e);const n=await t.data();return this.tensorMap.forEach(t=>t.dispose()),this.tensorMap.clear(),Object(l.tidy)(()=>{const t=Object(l.unstack)(e),r=n.length,i=t.length;l.util.assert(r===i,()=>`The number of elements doesn't match, keys has ${r} elements, the values has ${i} elements.`);for(let e=0;e<r;e++){const r=n[e],i=t[e];Object(l.keep)(i),this.tensorMap.set(r,i)}return this.handle})}async find(t,e){this.checkKeyAndValueTensor(t,e);const n=await t.data();return Object(l.tidy)(()=>{const t=[];for(let r=0;r<n.length;r++){const i=n[r],s=this.findWithDefault(i,e);t.push(s)}return Object(l.stack)(t)})}findWithDefault(t,e){const n=this.tensorMap.get(t);return null!=n?n:e}checkKeyAndValueTensor(t,e){if(t.dtype!==this.keyDType)throw new Error(`Expect key dtype ${this.keyDType}, but got `+t.dtype);if(e.dtype!==this.valueDType)throw new Error(`Expect value dtype ${this.valueDType}, but got `+e.dtype)}}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var Pu=n(82),Fu=n(104),zu=n(46),Lu=n(56),$u=n(101),Bu=n(57),qu=n(62),Vu=n(102),Uu=n(130),Wu=n(37);var Gu=n(29),Hu=n(31);var Ku=n(86),Qu=n(173),Xu=n(245),Yu=n(236),Ju=n(271);var Zu=n(72),tc=n(93),ec=n(114),nc=n(21),rc=n(158),ic=n(159),sc=n(160),ac=n(161),oc=n(126);var uc=n(32),cc=n(99),lc=n(45),hc=n(28),dc=n(246),pc=n(107),fc=n(8),mc=n(63),gc=n(108),bc=n(88),yc=n(78),vc=n(251),wc=n(252);var xc=n(135),_c=n(116),Oc=n(136),Sc=n(186);var kc=n(49),Tc=n(177),Cc=n(59),Ac=n(105),Nc=n(98),Ic=n(166),Ec=n(113);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function jc(t,e,n,r){const i=((t,e,n)=>{switch(t.category){case"arithmetic":return l.tidy(()=>((t,e,n)=>{switch(t.op){case"BiasAdd":case"AddV2":case"Add":return[to.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"AddN":return[eo.a(Object(Ya.d)("tensors",t,e,n))];case"FloorMod":case"Mod":return[no.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"Mul":return[ro.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"RealDiv":case"Div":return[io.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"DivNoNan":return[so.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"FloorDiv":return[ao.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"Sub":return[oo.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"Minimum":return[uo.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"Maximum":return[co.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"Pow":return[lo.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"SquaredDifference":return[ho.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n));case"basic_math":return l.tidy(()=>((t,e,n)=>{switch(t.op){case"Abs":case"ComplexAbs":return[po.a(Object(Ya.d)("x",t,e,n))];case"Acos":return[fo.a(Object(Ya.d)("x",t,e,n))];case"Acosh":return[mo.a(Object(Ya.d)("x",t,e,n))];case"Asin":return[go.a(Object(Ya.d)("x",t,e,n))];case"Asinh":return[bo.a(Object(Ya.d)("x",t,e,n))];case"Atan":return[yo.a(Object(Ya.d)("x",t,e,n))];case"Atan2":return[vo.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("y",t,e,n))];case"Atanh":return[wo.a(Object(Ya.d)("x",t,e,n))];case"Ceil":return[xo.a(Object(Ya.d)("x",t,e,n))];case"Complex":return[_o.a(Object(Ya.d)("real",t,e,n),Object(Ya.d)("imag",t,e,n))];case"Cos":return[Oo.a(Object(Ya.d)("x",t,e,n))];case"Cosh":return[So.a(Object(Ya.d)("x",t,e,n))];case"Elu":return[ko.a(Object(Ya.d)("x",t,e,n))];case"Erf":return[To.a(Object(Ya.d)("x",t,e,n))];case"Exp":return[Co.a(Object(Ya.d)("x",t,e,n))];case"Expm1":return[Ao.a(Object(Ya.d)("x",t,e,n))];case"Floor":return[No.a(Object(Ya.d)("x",t,e,n))];case"Log":return[Io.a(Object(Ya.d)("x",t,e,n))];case"Log1p":return[Eo.a(Object(Ya.d)("x",t,e,n))];case"Imag":return[jo.a(Object(Ya.d)("x",t,e,n))];case"Neg":return[Mo.a(Object(Ya.d)("x",t,e,n))];case"Reciprocal":return[Do.a(Object(Ya.d)("x",t,e,n))];case"Real":return[Ro.a(Object(Ya.d)("x",t,e,n))];case"Relu":return[Po.a(Object(Ya.d)("x",t,e,n))];case"Round":return[Fo.a(Object(Ya.d)("x",t,e,n))];case"Selu":return[zo.a(Object(Ya.d)("x",t,e,n))];case"Sigmoid":return[Lo.a(Object(Ya.d)("x",t,e,n))];case"Sin":return[$o.a(Object(Ya.d)("x",t,e,n))];case"Sign":return[Bo.a(Object(Ya.d)("x",t,e,n))];case"Sinh":return[qo.a(Object(Ya.d)("x",t,e,n))];case"Softplus":return[Vo.a(Object(Ya.d)("x",t,e,n))];case"Sqrt":return[Uo.a(Object(Ya.d)("x",t,e,n))];case"Square":return[Wo.a(Object(Ya.d)("x",t,e,n))];case"Tanh":return[Go.a(Object(Ya.d)("x",t,e,n))];case"Tan":return[Ho.a(Object(Ya.d)("x",t,e,n))];case"Relu6":case"ClipByValue":return[Ko.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("clipValueMin",t,e,n),Object(Ya.d)("clipValueMax",t,e,n))];case"Rsqrt":return[Qo.a(Object(Ya.e)(t.inputNames[0],e,n))];case"Prod":return[Xo.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("axes",t,e,n))];case"LeakyRelu":return[Yo.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("alpha",t,e,n))];case"Prelu":return[Jo.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("alpha",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n));case"control":return nu(t,e,n);case"convolution":return l.tidy(()=>((t,e,n)=>{switch(t.op){case"Conv1D":{const r=Object(Ya.d)("stride",t,e,n),i=Object(Ya.d)("pad",t,e,n),s=Object(Ya.d)("dataFormat",t,e,n).toUpperCase(),a=Object(Ya.d)("dilation",t,e,n);return[ru.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("filter",t,e,n),r,i,s,a)]}case"Conv2D":{const r=Object(Ya.d)("strides",t,e,n),i=Object(Ya.c)(t,e,n),s=Object(Ya.d)("dataFormat",t,e,n).toUpperCase(),a=Object(Ya.d)("dilations",t,e,n);return[iu.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("filter",t,e,n),[r[1],r[2]],i,s,[a[1],a[2]])]}case"_FusedConv2D":{const{stride:r,pad:i,dataFormat:s,dilations:a,biasArg:o,preluArg:u,activationFunc:c}=mu(t,e,n);return[su.qb.conv2d({x:Object(Ya.d)("x",t,e,n),filter:Object(Ya.d)("filter",t,e,n),strides:[r[1],r[2]],pad:i,dataFormat:s,dilations:[a[1],a[2]],bias:o,activation:c,preluActivationWeights:u})]}case"FusedDepthwiseConv2dNative":{const{stride:r,pad:i,dataFormat:s,dilations:a,biasArg:o,preluArg:u,activationFunc:c}=mu(t,e,n);return[su.qb.depthwiseConv2d({x:Object(Ya.d)("x",t,e,n),filter:Object(Ya.d)("filter",t,e,n),strides:[r[1],r[2]],pad:i,dataFormat:s,dilations:[a[1],a[2]],bias:o,activation:c,preluActivationWeights:u})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const r=Object(Ya.d)("outputShape",t,e,n),i=Object(Ya.d)("strides",t,e,n),s=Object(Ya.c)(t,e,n);return[au.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("filter",t,e,n),r,[i[1],i[2]],s)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const r=Object(Ya.d)("strides",t,e,n),i=Object(Ya.c)(t,e,n),s=Object(Ya.d)("dilations",t,e,n),a=Object(Ya.d)("dataFormat",t,e,n).toUpperCase();return[ou.a(Object(Ya.d)("input",t,e,n),Object(Ya.d)("filter",t,e,n),[r[1],r[2]],i,a,[s[1],s[2]])]}case"Conv3D":{const r=Object(Ya.d)("strides",t,e,n),i=Object(Ya.d)("pad",t,e,n),s=Object(Ya.d)("dataFormat",t,e,n).toUpperCase(),a=Object(Ya.d)("dilations",t,e,n);return[uu.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("filter",t,e,n),[r[1],r[2],r[3]],i,s,[a[1],a[2],a[3]])]}case"AvgPool":{const r=Object(Ya.d)("strides",t,e,n),i=Object(Ya.d)("pad",t,e,n),s=Object(Ya.d)("kernelSize",t,e,n);return[cu.a(Object(Ya.d)("x",t,e,n),[s[1],s[2]],[r[1],r[2]],i)]}case"MaxPool":{const r=Object(Ya.d)("strides",t,e,n),i=Object(Ya.d)("pad",t,e,n),s=Object(Ya.d)("kernelSize",t,e,n);return[lu.a(Object(Ya.d)("x",t,e,n),[s[1],s[2]],[r[1],r[2]],i)]}case"MaxPoolWithArgmax":{const r=Object(Ya.d)("strides",t,e,n),i=Object(Ya.d)("pad",t,e,n),s=Object(Ya.d)("kernelSize",t,e,n),a=Object(Ya.d)("includeBatchInIndex",t,e,n),{result:o,indexes:u}=hu.a(Object(Ya.d)("x",t,e,n),[s[1],s[2]],[r[1],r[2]],i,a);return[o,u]}case"AvgPool3D":{const r=Object(Ya.d)("strides",t,e,n),i=Object(Ya.d)("pad",t,e,n),s=Object(Ya.d)("kernelSize",t,e,n);return[du.a(Object(Ya.d)("x",t,e,n),[s[1],s[2],s[3]],[r[1],r[2],r[3]],i)]}case"MaxPool3D":{const r=Object(Ya.d)("strides",t,e,n),i=Object(Ya.d)("pad",t,e,n),s=Object(Ya.d)("kernelSize",t,e,n);return[pu.a(Object(Ya.d)("x",t,e,n),[s[1],s[2],s[3]],[r[1],r[2],r[3]],i)]}case"Dilation2D":{const r=Object(Ya.d)("strides",t,e,n),i=Object(Ya.d)("pad",t,e,n),s=Object(Ya.d)("dilations",t,e,n),a=r[1],o=r[2],u=s[1],c=s[2];return[fu.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("filter",t,e,n),[a,o],i,[u,c],"NHWC")]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n));case"creation":return l.tidy(()=>((t,e,n)=>{switch(t.op){case"Fill":{const r=Object(Ya.d)("shape",t,e,n),i=Object(Ya.d)("dtype",t,e,n),s=Object(Ya.d)("value",t,e,n);return[gu.a(r,s,i)]}case"LinSpace":{const r=Object(Ya.d)("start",t,e,n),i=Object(Ya.d)("stop",t,e,n),s=Object(Ya.d)("num",t,e,n);return[bu.a(r,i,s)]}case"Multinomial":{const r=Object(Ya.d)("logits",t,e,n),i=Object(Ya.d)("numSamples",t,e,n),s=Object(Ya.d)("seed",t,e,n);return[yu.a(r,i,s)]}case"OneHot":{const r=Object(Ya.d)("indices",t,e,n),i=Object(Ya.d)("depth",t,e,n),s=Object(Ya.d)("onValue",t,e,n),a=Object(Ya.d)("offValue",t,e,n);return[vu.a(r,i,s,a)]}case"Ones":return[wu.a(Object(Ya.d)("shape",t,e,n),Object(Ya.d)("dtype",t,e,n))];case"OnesLike":return[xu.a(Object(Ya.d)("x",t,e,n))];case"RandomUniform":return[_u.a(Object(Ya.d)("shape",t,e,n),Object(Ya.d)("minval",t,e,n),Object(Ya.d)("maxval",t,e,n),Object(Ya.d)("dtype",t,e,n))];case"Range":{const r=Object(Ya.d)("start",t,e,n),i=Object(Ya.d)("stop",t,e,n),s=Object(Ya.d)("step",t,e,n);return[Ou.a(r,i,s,Object(Ya.d)("dtype",t,e,n))]}case"TruncatedNormal":{const r=Object(Ya.d)("shape",t,e,n),i=Object(Ya.d)("mean",t,e,n),s=Object(Ya.d)("stdDev",t,e,n),a=Object(Ya.d)("seed",t,e,n);return[Su.a(r,i,s,Object(Ya.d)("dtype",t,e,n),a)]}case"Zeros":return[ku.a(Object(Ya.d)("shape",t,e,n),Object(Ya.d)("dtype",t,e,n))];case"ZerosLike":return[Tu.a(Object(Ya.d)("x",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n));case"dynamic":return(async(t,e,n)=>{switch(t.op){case"NonMaxSuppressionV5":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:a,scoreThreshold:o,softNmsSigma:u}=Iu(t,e,n),c=await su.zb.nonMaxSuppressionWithScoreAsync(r,i,s,a,o,u);return[c.selectedIndices,c.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:a,scoreThreshold:o}=Iu(t,e,n),u=Object(Ya.d)("padToMaxOutputSize",t,e,n),c=await su.zb.nonMaxSuppressionPaddedAsync(r,i,s,a,o,u);return[c.selectedIndices,c.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:a,scoreThreshold:o}=Iu(t,e,n);return[await su.zb.nonMaxSuppressionAsync(r,i,s,a,o)]}case"Where":{const r=Cu.a(Object(Ya.d)("condition",t,e,n),"bool"),i=[await Au.a(r)];return r.dispose(),i}case"ListDiff":return Nu.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("y",t,e,n));default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n);case"evaluation":return l.tidy(()=>((t,e,n)=>{switch(t.op){case"TopKV2":{const r=Object(Ya.d)("x",t,e,n),i=Object(Ya.d)("k",t,e,n),s=Object(Ya.d)("sorted",t,e,n),a=Eu.a(r,i,s);return[a.values,a.indices]}case"Unique":{const r=Object(Ya.d)("x",t,e,n),i=ju.a(r);return[i.values,i.indices]}case"UniqueV2":{const r=Object(Ya.d)("x",t,e,n),i=Object(Ya.d)("axis",t,e,n),s=ju.a(r,i);return[s.values,s.indices]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n));case"image":return l.tidy(()=>((t,e,n)=>{switch(t.op){case"ResizeBilinear":{const r=Object(Ya.d)("images",t,e,n),i=Object(Ya.d)("size",t,e,n),s=Object(Ya.d)("alignCorners",t,e,n);return[su.zb.resizeBilinear(r,[i[0],i[1]],s)]}case"ResizeNearestNeighbor":{const r=Object(Ya.d)("images",t,e,n),i=Object(Ya.d)("size",t,e,n),s=Object(Ya.d)("alignCorners",t,e,n);return[su.zb.resizeNearestNeighbor(r,[i[0],i[1]],s)]}case"CropAndResize":{const r=Object(Ya.d)("image",t,e,n),i=Object(Ya.d)("boxes",t,e,n),s=Object(Ya.d)("boxInd",t,e,n),a=Object(Ya.d)("cropSize",t,e,n),o=Object(Ya.d)("method",t,e,n),u=Object(Ya.d)("extrapolationValue",t,e,n);return[su.zb.cropAndResize(r,i,s,a,o,u)]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n));case"graph":return l.tidy(()=>((t,e,n)=>{switch(t.op){case"Const":return e[t.name];case"PlaceholderWithDefault":const r=Object(Ya.d)("default",t,e,n);return[Object(Ya.e)(t.name,e,n)||r];case"Placeholder":return[Object(Ya.e)(t.name,e,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":{const r=Object(Ya.d)("x",t,e,n);return[Object(Ya.a)(r)]}case"IdentityN":return Object(Ya.d)("x",t,e,n).map(t=>Object(Ya.a)(t));case"Snapshot":const i=Object(Ya.d)("x",t,e,n);return[Object(Ya.a)(i)];case"Shape":return[Mu.a(Object(Ya.d)("x",t,e,n).shape,"int32")];case"ShapeN":return Object(Ya.d)("x",t,e,n).map(t=>Mu.a(t.shape));case"Size":return[Du.a(Object(Ya.d)("x",t,e,n).size,"int32")];case"Rank":return[Du.a(Object(Ya.d)("x",t,e,n).rank,"int32")];case"NoOp":return[Du.a(1)];case"Print":const s=Object(Ya.d)("x",t,e,n),a=Object(Ya.d)("data",t,e,n),o=Object(Ya.d)("message",t,e,n),u=Object(Ya.d)("summarize",t,e,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(o);for(let t=0;t<a.length;t++)console.log(Array.prototype.slice.call(a[t].dataSync()).slice(0,u));return[s];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n));case"logical":return l.tidy(()=>((t,e,n)=>{switch(t.op){case"Equal":return[Pu.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"NotEqual":return[Fu.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"Greater":return[zu.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"GreaterEqual":return[Lu.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"Less":return[$u.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"LessEqual":return[Bu.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"LogicalAnd":return[qu.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"LogicalNot":return[Vu.a(Object(Ya.d)("a",t,e,n))];case"LogicalOr":return[Uu.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];case"Select":case"SelectV2":return[Wu.a(Object(Ya.d)("condition",t,e,n),Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n));case"matrices":return l.tidy(()=>((t,e,n)=>{switch(t.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[Gu.a(Object(Ya.d)("a",t,e,n),Object(Ya.d)("b",t,e,n),Object(Ya.d)("transposeA",t,e,n),Object(Ya.d)("transposeB",t,e,n))];case"Transpose":return[Hu.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("perm",t,e,n))];case"_FusedMatMul":const[r,i]=Object(Ya.d)("fusedOps",t,e,n),s="biasadd"===r,a="prelu"===i,o=Object(Ya.d)("numArgs",t,e,n);if(s){if(a&&2!==o)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!a&&1!==o)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[u,c]=Object(Ya.d)("args",t,e,n);return[su.qb.matMul({a:Object(Ya.d)("a",t,e,n),b:Object(Ya.d)("b",t,e,n),transposeA:Object(Ya.d)("transposeA",t,e,n),transposeB:Object(Ya.d)("transposeB",t,e,n),bias:u,activation:i,preluActivationWeights:c})];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n));case"normalization":return l.tidy(()=>((t,e,n)=>{switch(t.op){case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[Ku.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("mean",t,e,n),Object(Ya.d)("variance",t,e,n),Object(Ya.d)("offset",t,e,n),Object(Ya.d)("scale",t,e,n),Object(Ya.d)("epsilon",t,e,n))];case"LRN":return[Qu.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("radius",t,e,n),Object(Ya.d)("bias",t,e,n),Object(Ya.d)("alpha",t,e,n),Object(Ya.d)("beta",t,e,n))];case"Softmax":return[Xu.a(Object(Ya.d)("x",t,e,n))];case"LogSoftmax":return[Yu.a(Object(Ya.d)("x",t,e,n))];case"SparseToDense":return[Ju.a(Object(Ya.d)("sparseIndices",t,e,n),Object(Ya.d)("outputShape",t,e,n),Object(Ya.d)("sparseValues",t,e,n),Object(Ya.d)("defaultValue",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n));case"reduction":return l.tidy(()=>((t,e,n)=>{switch(t.op){case"Max":{const r=Object(Ya.d)("axis",t,e,n),i=Object(Ya.d)("keepDims",t,e,n);return[Zu.a(Object(Ya.d)("x",t,e,n),r,i)]}case"Mean":{const r=Object(Ya.d)("axis",t,e,n),i=Object(Ya.d)("keepDims",t,e,n);return[tc.a(Object(Ya.d)("x",t,e,n),r,i)]}case"Min":{const r=Object(Ya.d)("axis",t,e,n),i=Object(Ya.d)("keepDims",t,e,n);return[ec.a(Object(Ya.d)("x",t,e,n),r,i)]}case"Sum":{const r=Object(Ya.d)("axis",t,e,n),i=Object(Ya.d)("keepDims",t,e,n);return[nc.a(Object(Ya.d)("x",t,e,n),r,i)]}case"All":{const r=Object(Ya.d)("axis",t,e,n),i=Object(Ya.d)("keepDims",t,e,n);return[rc.a(Object(Ya.d)("x",t,e,n),r,i)]}case"Any":{const r=Object(Ya.d)("axis",t,e,n),i=Object(Ya.d)("keepDims",t,e,n);return[ic.a(Object(Ya.d)("x",t,e,n),r,i)]}case"ArgMax":{const r=Object(Ya.d)("axis",t,e,n);return[sc.a(Object(Ya.d)("x",t,e,n),r)]}case"ArgMin":{const r=Object(Ya.d)("axis",t,e,n);return[ac.a(Object(Ya.d)("x",t,e,n),r)]}case"Prod":{const r=Object(Ya.d)("axis",t,e,n),i=Object(Ya.d)("keepDims",t,e,n);return[Xo.a(Object(Ya.d)("x",t,e,n),r,i)]}case"Cumsum":{const r=Object(Ya.d)("axis",t,e,n),i=Object(Ya.d)("exclusive",t,e,n),s=Object(Ya.d)("reverse",t,e,n);return[oc.a(Object(Ya.d)("x",t,e,n),r,i,s)]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n));case"slice_join":return l.tidy(()=>((t,e,n)=>{switch(t.op){case"ConcatV2":case"Concat":{const r=Object(Ya.d)("n",t,e,n),i=Object(Ya.d)("axis",t,e,n);let s=Object(Ya.d)("tensors",t,e,n);return s=s.slice(0,r),[uc.a(s,i)]}case"GatherV2":case"Gather":{const r=Object(Ya.d)("axis",t,e,n),i=Object(Ya.d)("x",t,e,n),s=Object(Ya.d)("indices",t,e,n);return[cc.a(i,Cu.a(s,"int32"),r)]}case"ReverseV2":case"Reverse":{const r=Object(Ya.d)("axis",t,e,n),i=Object(Ya.d)("x",t,e,n);return[lc.a(i,r)]}case"Slice":{const r=Object(Ya.d)("begin",t,e,n),i=Object(Ya.d)("size",t,e,n);return[hc.a(Object(Ya.d)("x",t,e,n),r,i)]}case"StridedSlice":{const r=Object(Ya.d)("begin",t,e,n),i=Object(Ya.d)("end",t,e,n),s=Object(Ya.d)("strides",t,e,n),a=Object(Ya.d)("beginMask",t,e,n),o=Object(Ya.d)("endMask",t,e,n),u=Object(Ya.d)("ellipsisMask",t,e,n),c=Object(Ya.d)("newAxisMask",t,e,n),l=Object(Ya.d)("shrinkAxisMask",t,e,n),h=Object(Ya.d)("x",t,e,n);return[dc.a(h,r,i,s,a,o,u,c,l)]}case"Pack":return Object(l.tidy)(()=>{const r=Object(Ya.d)("axis",t,e,n),i=Object(Ya.d)("tensors",t,e,n),s=i[0].shape,a=pc.a(i[0]).shape,o=i.map(t=>{const e=l.util.arraysEqual(t.shape,s);if(!e&&!l.util.arraysEqual(pc.a(t).shape,a))throw new Error("the input tensors shape does not match");return e?t:fc.a(t,s)});return[mc.a(o,r)]});case"Unpack":{const r=Object(Ya.d)("axis",t,e,n),i=Object(Ya.d)("tensor",t,e,n);return gc.a(i,r)}case"Tile":{const r=Object(Ya.d)("reps",t,e,n);return[bc.a(Object(Ya.d)("x",t,e,n),r)]}case"Split":case"SplitV":{const r=Object(Ya.d)("axis",t,e,n),i=Object(Ya.d)("numOrSizeSplits",t,e,n),s=Object(Ya.d)("x",t,e,n);return yc.a(s,i,r)}case"ScatterNd":{const r=Object(Ya.d)("indices",t,e,n),i=Object(Ya.d)("values",t,e,n),s=Object(Ya.d)("shape",t,e,n);return[vc.a(r,i,s)]}case"GatherNd":{const r=Object(Ya.d)("x",t,e,n),i=Object(Ya.d)("indices",t,e,n);return[wc.a(r,i)]}case"SparseToDense":{const r=Object(Ya.d)("sparseIndices",t,e,n),i=Object(Ya.d)("outputShape",t,e,n),s=Object(Ya.d)("sparseValues",t,e,n),a=Object(Ya.d)("defaultValue",t,e,n);return[Ju.a(r,s,i,s.dtype===a.dtype?a:Cu.a(a,s.dtype))]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n));case"spectral":return l.tidy(()=>((t,e,n)=>{switch(t.op){case"FFT":return[xc.a(Object(Ya.d)("x",t,e,n))];case"IFFT":return[_c.a(Object(Ya.d)("x",t,e,n))];case"RFFT":return[Oc.a(Object(Ya.d)("x",t,e,n))];case"IRFFT":return[Sc.a(Object(Ya.d)("x",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n));case"transformation":return l.tidy(()=>((t,e,n)=>{switch(t.op){case"Cast":return[Cu.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("dtype",t,e,n))];case"ExpandDims":{const r=Object(Ya.d)("axis",t,e,n);return[kc.a(Object(Ya.d)("x",t,e,n),r)]}case"Squeeze":{const r=Object(Ya.d)("axis",t,e,n);return[pc.a(Object(Ya.d)("x",t,e,n),r)]}case"Reshape":return[fc.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("shape",t,e,n))];case"MirrorPad":return[Tc.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("padding",t,e,n),Object(Ya.d)("mode",t,e,n))];case"PadV2":case"Pad":return[Cc.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("padding",t,e,n),Object(Ya.d)("constantValue",t,e,n))];case"SpaceToBatchND":{const r=Object(Ya.d)("blockShape",t,e,n),i=Object(Ya.d)("paddings",t,e,n);return[Ac.a(Object(Ya.d)("x",t,e,n),r,i)]}case"BatchToSpaceND":{const r=Object(Ya.d)("blockShape",t,e,n),i=Object(Ya.d)("crops",t,e,n);return[Nc.a(Object(Ya.d)("x",t,e,n),r,i)]}case"DepthToSpace":{const r=Object(Ya.d)("blockSize",t,e,n),i=Object(Ya.d)("dataFormat",t,e,n).toUpperCase();return[Ic.a(Object(Ya.d)("x",t,e,n),r,i)]}case"BroadcastTo":return[Ec.a(Object(Ya.d)("x",t,e,n),Object(Ya.d)("shape",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n));case"hash_table":return(async(t,e,n,r)=>{switch(t.op){case"HashTable":case"HashTableV2":{const i=Object(Ya.d)("keyDType",t,e,n),s=Object(Ya.d)("valueDType",t,e,n),a=new Ru(i,s);return r.addHashTable(t.name,a),[a.handle]}case"LookupTableImport":case"LookupTableImportV2":{const i=Object(Ya.d)("tableHandle",t,e,n,r),s=Object(Ya.d)("keys",t,e,n),a=Object(Ya.d)("values",t,e,n),o=r.getHashTableById(i.id);return[await o.import(s,a)]}case"LookupTableFind":case"LookupTableFindV2":{const i=Object(Ya.d)("tableHandle",t,e,n,r),s=Object(Ya.d)("keys",t,e,n),a=Object(Ya.d)("defaultValue",t,e,n),o=r.getHashTableById(i.id);return[await o.find(s,a)]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n,r);case"custom":const i=Object(Za.b)(t.op);if(i&&i.customExecutor)return i.customExecutor(new Ja(t,e,n));throw TypeError(`Custom op ${t.op} is not registered.`);default:throw TypeError(`Unknown op '${t.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(t,e,n);return l.util.isPromise(i)?i.then(t=>[].concat(t)):[].concat(i)}class Mc{constructor(t={},e={},n={},r={}){this.weightMap=t,this.tensorArrayMap=e,this.tensorListMap=n,this.functionMap=r,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(t,e){return{id:t,frameName:e,iterationId:0}}set currentContext(t){this.contexts!==t&&(this.contexts=t,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){const t=[];for(let e=0;e<this.contexts.length-1;e++){const n=this.contexts.slice(0,this.contexts.length-e);t.push(this.contextIdforContexts(n))}t.push(""),this._currentContextIds=t}contextIdforContexts(t){return t?t.map(t=>0===t.id&&0===t.iterationId?"":`${t.frameName}-${t.iterationId}`).join("/"):""}enterFrame(t){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,t)),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 t=Object.assign({},this.contexts[this.contexts.length-1]);t.iterationId+=1,t.id=this.lastId,this.contexts.splice(-1,1,t),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}}getWeight(t){return this.weightMap[t]}addTensorArray(t){this.tensorArrayMap[t.id]=t}getTensorArray(t){return this.tensorArrayMap[t]}addTensorList(t){this.tensorListMap[t.id]=t}getTensorList(t){return this.tensorListMap[t]}dispose(t){for(const e in this.tensorArrayMap)this.tensorArrayMap[e].clearAndClose(t);for(const e in this.tensorListMap)this.tensorListMap[e].clearAndClose(t)}}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function Dc(t,e,n,r){const i=new Set,s=[];let a=null,o=null;const u=new Set,c=Object.keys(t).map(t=>Object(Ya.g)(t)[0]);let l=[];null!=r&&(l=r.map(t=>Object(Ya.g)(t.name)[0]));const h=[...e];for(;h.length>0;){const t=h.pop();(zc(t)||Lc(t)||$c(t))&&null==a&&(a=t,o=a.children.map(t=>t.name).filter(t=>i.has(t))),i.add(t.name),null==n[t.name]&&(-1===c.indexOf(t.name)&&-1===l.indexOf(t.name)&&(0!==t.inputs.length?t.inputs.forEach(t=>{u.has(t.name)||(u.add(t.name),h.push(t))}):s.push(t.name)))}return{inputs:t,outputs:e,usedNodes:i,missingInputs:s,dynamicNode:a,syncInputs:o}}const Rc=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],Pc=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],Fc=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2"];function zc(t){return Rc.indexOf(t.op)>=0}function Lc(t){return Pc.indexOf(t.op)>=0}function $c(t){return Fc.indexOf(t.op)>=0}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Bc{constructor(t,e){this.graph=t,this.parent=e,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this._outputs=t.outputs,this._inputs=t.inputs,this._initNodes=t.initNodes,this._signature=t.signature,this._functions=t.functions,null!=t.functions&&Object.keys(t.functions).forEach(e=>{this._functionExecutorMap[e]=new Bc(t.functions[e],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(t){const e=Object.keys(t).map(e=>t[e].map(t=>t.id));this._weightIds=[].concat(...e),this._weightMap=t}set resourceManager(t){this._resourceManager=t}get inputs(){return this._inputs.map(t=>({name:t.name,shape:t.attrParams.shape?t.attrParams.shape.value:void 0,dtype:t.attrParams.dtype?t.attrParams.dtype.value:void 0}))}get outputs(){return this._outputs.map(t=>({name:t.name,shape:t.attrParams.shape?t.attrParams.shape.value:void 0,dtype:t.attrParams.dtype?t.attrParams.dtype.value:void 0}))}get inputNodes(){return this._inputs.map(t=>t.signatureKey||t.name)}get outputNodes(){return this._outputs.map(t=>{const e=t.signatureKey||t.name;return t.defaultOutput?`${e}:${t.defaultOutput}`:e})}get functions(){return Object.keys(this._functions).reduce((t,e)=>(t[e]=this._functions[e].signature,t),{})}getCompilationKey(t,e){const n=t.map(t=>t.name).sort(),r=e.map(t=>t.name).sort();return n.join(this.SEPERATOR)+"--"+r.join(this.SEPERATOR)}compile(t,e){const n=Dc(t,e,this.weightMap,this._initNodes),{missingInputs:r,dynamicNode:i,syncInputs:s}=n;if(null!=i)throw new Error(`This execution contains the node '${i.name}', which has the dynamic op '${i.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${s}]`);if(r.length>0){const n=e.map(t=>t.name),i=Object.keys(t);throw new Error(`Cannot compute the outputs [${n}] from the provided inputs [${i}]. Missing the following inputs: [${r}]`)}return function(t,e,n){const{usedNodes:r,inputs:i}=n,s=[],a=Object.keys(i).map(t=>Object(Ya.g)(t)[0]).map(e=>t.nodes[e]),o=t.initNodes;a.forEach(t=>{r.has(t.name)&&s.push(t)}),t.weights.forEach(t=>{r.has(t.name)&&s.push(t)}),null!=o&&o.forEach(t=>{r.has(t.name)&&s.push(t)});const u=new Set,c=[];for(;s.length>0;){const t=s.pop();u.add(t.name),e[t.name]||c.push(t),t.children.forEach(t=>{!u.has(t.name)&&r.has(t.name)&&t.inputs.every(t=>u.has(t.name))&&s.push(t)})}return c}(this.graph,this.weightMap,n)}execute(t,e){t=this.mapInputs(t);const n=Object.keys(t).sort();this.checkInputs(t),this.checkInputShapeAndType(t),e=this.mapOutputs(e),this.checkOutputs(e);const r=n.map(t=>this.graph.nodes[Object(Ya.g)(t)[0]]),i=e.map(t=>Object(Ya.g)(t)[0]);let s=i.map(t=>this.graph.nodes[t]);0===s.length&&(s=this._outputs);const a=this.getCompilationKey(r,s);let o=this.compiledMap.get(a);null==o&&(o=this.compile(t,s),this.compiledMap.set(a,o));const u={},c={};return Object(l.tidy)(()=>{const n=new Mc(this.weightMap,u,c,this.functionExecutorMap),r=Object.assign({},this.weightMap);Object.keys(t).forEach(e=>{const[n,i]=Object(Ya.g)(e),s=[];s[i]=t[e],r[n]=s});const s=this.getFrozenTensorIds(r),a={};for(let t=0;t<o.length;t++){const e=o[t];if(!r[e.name]){const t=jc(e,r,n,this._resourceManager);if(l.util.isPromise(t))throw new Error(`The execution of the op '${e.op}' returned a promise. Please use model.executeAsync() instead.`);r[e.name]=t,this.checkTensorForDisposal(e.name,e,r,n,s,i,a)}}return null==this.parent&&n.dispose(s),e.map(t=>Object(Ya.e)(t,r,n))})}getFrozenTensorIds(t){const e=[].concat.apply([],Object.keys(t).map(e=>t[e]).map(t=>t.map(t=>t.id)));return new Set(e)}checkTensorForDisposal(t,e,n,r,i,s,a){"control"!==e.category&&-1===s.indexOf(t)&&(n[t].forEach(t=>{null!=t&&(a[t.id]=(a[t.id]||0)+e.children.length)}),e.inputs.forEach(t=>{if("control"!==t.category){const e=Object(Ya.f)(t.name,n,r);null!=e&&e.forEach(t=>{if(t&&!i.has(t.id)){const e=a[t.id];1===e?(t.dispose(),delete a[t.id]):null!=e&&a[t.id]--}})}}))}async executeAsync(t,e){return this._executeAsync(t,e)}async _executeAsync(t,e,n=!1,r={},i={}){n||(t=this.mapInputs(t),this.checkInputs(t),this.checkInputShapeAndType(t),e=this.mapOutputs(e),this.checkOutputs(e));const s=new Mc(this.weightMap,r,i,this.functionExecutorMap),a=await this.executeWithControlFlow(t,s,e,n),o=e.map(t=>Object(Ya.e)(t,a,s)),u=o.map(t=>t.id),c=Object.keys(t).map(e=>t[e].id),l=new Set([...u,...c,...this.weightIds]);return Object.keys(a).forEach(t=>{a[t].forEach(t=>{!t||t.isDisposed||l.has(t.id)||t.dispose()})}),null==this.parent&&s.dispose(l),o}async executeFunctionAsync(t,e,n){const r=t.reduce((t,e,n)=>(t[this.inputs[n].name]=e,t),{});return this._executeAsync(r,this.outputNodes,!0,e,n)}async executeWithControlFlow(t,e,n,r){const i=Object.keys(t),s=i.map(t=>this.graph.nodes[Object(Ya.g)(t)[0]]),a=n.map(t=>Object(Ya.g)(t)[0]);let o=a.map(t=>this.graph.nodes[t]);0===o.length&&(o=this._outputs);const{usedNodes:u,missingInputs:c,dynamicNode:l,syncInputs:h}=Dc(t,o,this.weightMap,this._initNodes),d=[...s,...this.graph.weights,...this._initNodes||[]].map(t=>({node:t,contexts:e.currentContext})),p=Object.assign({},this.weightMap);Object.keys(t).forEach(e=>{const[n,r]=Object(Ya.g)(e),i=[];i[r]=t[e],p[n]=i});const f={},m=this.getFrozenTensorIds(p),g={};for(;d.length>0;){const t=this.processStack(s,d,e,p,g,m,a,f,u);await Promise.all(t)}null!=l||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 b=o.filter(t=>!zc(t)&&!Object(Ya.e)(t.name,p,e)).map(t=>t.name);if(b.length>0){let t="";throw null!=l&&(t=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${h}]`),new Error(`Cannot compute the outputs [${b}] from the provided inputs [${i}]. Consider providing the following inputs: [${c}]. ${t}`)}return p}processStack(t,e,n,r,i,s,a,o,u){const c=[];for(;e.length>0;){const t=e.pop();n.currentContext=t.contexts;let h="";if("Enter"===t.node.op&&Object(Ya.d)("isConstant",t.node,r,n)&&([h]=Object(Ya.b)(t.node.name,n)),null==r[t.node.name]){const d=jc(t.node,r,n,this._resourceManager);h||([h]=Object(Ya.b)(t.node.name,n));const p=n.currentContext;l.util.isPromise(d)?c.push(d.then(c=>(r[h]=c,n.currentContext=p,this.checkTensorForDisposal(h,t.node,r,n,s,a,o),this.processChildNodes(t.node,e,n,r,i,u),c))):(r[h]=d,this.checkTensorForDisposal(h,t.node,r,n,s,a,o),this.processChildNodes(t.node,e,n,r,i,u))}else this.processChildNodes(t.node,e,n,r,i,u)}return c}processChildNodes(t,e,n,r,i,s){t.children.forEach(t=>{const[a]=Object(Ya.b)(t.name,n);!i[a]&&s.has(t.name)&&("Merge"===t.op?t.inputNames.some(t=>!!Object(Ya.e)(t,r,n))&&(i[a]=!0,e.push({contexts:n.currentContext,node:t})):t.inputNames.every(t=>!!Object(Ya.e)(t,r,n))&&(i[a]=!0,e.push({contexts:n.currentContext,node:t})))})}dispose(){Object.keys(this.weightMap).forEach(t=>this.weightMap[t].forEach(t=>t.dispose()))}checkInputShapeAndType(t){Object.keys(t).forEach(e=>{const n=t[e],[r]=Object(Ya.g)(e),i=this.graph.nodes[r];if(i.attrParams.shape&&i.attrParams.shape.value){const t=i.attrParams.shape.value,e=t.length===n.shape.length&&n.shape.every((e,n)=>-1===t[n]||t[n]===e);l.util.assert(e,()=>`The shape of dict['${i.name}'] provided in model.execute(dict) must be [${t}], but was [${n.shape}]`)}i.attrParams.dtype&&i.attrParams.dtype.value&&l.util.assert(n.dtype===i.attrParams.dtype.value,()=>`The dtype of dict['${i.name}'] provided in model.execute(dict) must be ${i.attrParams.dtype.value}, but was ${n.dtype}`)})}mapInputs(t){const e={};for(const n in t)if(null!=this._signature&&null!=this._signature.inputs&&null!=this._signature.inputs[n]){e[this._signature.inputs[n].name]=t[n]}else e[n]=t[n];return e}checkInputs(t){const e=Object.keys(t).filter(t=>{const[e]=Object(Ya.g)(t);return null==this.graph.nodes[e]});if(e.length>0)throw new Error(`The dict provided in model.execute(dict) has keys: [${e}] that are not part of graph`)}mapOutputs(t){return t.map(t=>{if(null!=this._signature&&null!=this._signature.outputs&&null!=this._signature.outputs[t]){return this._signature.outputs[t].name}return t},{})}checkOutputs(t){t.forEach(t=>{const[e]=Object(Ya.g)(t);if(!this.graph.nodes[e])throw new Error(`The output '${t}' is not found in the graph`)})}}class qc{constructor(t={},e={}){this.hashTableNameToHandle=t,this.hashTableMap=e}addHashTable(t,e){this.hashTableNameToHandle[t]=e.handle,this.hashTableMap[e.id]=e}getHashTableHandleByName(t){return this.hashTableNameToHandle[t]}getHashTableById(t){return this.hashTableMap[t]}dispose(){for(const t in this.hashTableMap)this.hashTableMap[t].clearAndClose(),delete this.hashTableMap[t];for(const t in this.hashTableNameToHandle)this.hashTableNameToHandle[t].dispose(),delete this.hashTableNameToHandle[t]}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Vc{constructor(t,e={}){this.modelUrl=t,this.loadOptions=e,this.version="n/a",null==e&&(this.loadOptions={}),this.resourceManager=new qc}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}findIOHandler(){const t=this.modelUrl;if(null!=t.load)this.handler=t;else if(null!=this.loadOptions.requestInit)this.handler=l.io.browserHTTPRequest(t,this.loadOptions);else{const e=l.io.getLoadHandlers(t,this.loadOptions);if(0===e.length)e.push(l.io.browserHTTPRequest(t,this.loadOptions));else if(e.length>1)throw new Error(`Found more than one (${e.length}) load handlers for URL '${[t]}'`);this.handler=e[0]}}async 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 t=await this.handler.load();return this.loadSync(t)}loadSync(t){this.artifacts=t;const e=this.artifacts.modelTopology;let n={};null!=this.artifacts.userDefinedMetadata&&(n=this.artifacts.userDefinedMetadata.signature),this.version=`${e.versions.producer}.${e.versions.minConsumer}`;const r=l.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new Bc(Xa.a.Instance.transformGraph(e,n)),this.executor.weightMap=this.convertTensorMapToTensorsMap(r),this.executor.resourceManager=this.resourceManager,null!=t.modelInitializer){const e=Xa.a.Instance.transformGraph(t.modelInitializer);this.initializer=new Bc(e),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0}async save(t,e){if("string"==typeof t){const e=l.io.getSaveHandlers(t);if(0===e.length)throw new Error(`Cannot find any save handlers for URL '${t}'`);if(e.length>1)throw new Error(`Found more than one (${e.length}) save handlers for URL '${t}'`);t=e[0]}if(null==t.save)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return t.save(this.artifacts)}predict(t,e){return this.execute(t,this.outputNodes)}normalizeInputs(t){if(!(t instanceof l.Tensor||Array.isArray(t)))return t;if((t=Array.isArray(t)?t:[t]).length!==this.inputNodes.length)throw new Error(`Input tensor count mismatch,the graph model has ${this.inputNodes.length} placeholders, while there are ${t.length} input tensors.`);return this.inputNodes.reduce((e,n,r)=>(e[n]=t[r],e),{})}normalizeOutputs(t){return t=t||this.outputNodes,Array.isArray(t)?t:[t]}execute(t,e){t=this.normalizeInputs(t),e=this.normalizeOutputs(e);const n=this.executor.execute(t,e);return n.length>1?n:n[0]}async executeAsync(t,e){t=this.normalizeInputs(t),e=this.normalizeOutputs(e);const n=await this.executor.executeAsync(t,e);return n.length>1?n:n[0]}convertTensorMapToTensorsMap(t){return Object.keys(t).reduce((e,n)=>(e[n]=[t[n]],e),{})}dispose(){this.executor.dispose(),this.initializer&&this.initializer.dispose(),this.resourceManager.dispose()}}async function Uc(t,e={}){if(null==t)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");null==e&&(e={}),e.fromTFHub&&null==t.load&&(t.endsWith("/")||(t+="/"),t+="model.json?tfjs-format=file");const n=new Vc(t,e);return await n.load(),n}
/** @license See the LICENSE file. */const Wc="2.7.0";
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var Gc=n(89),Hc=n(43),Kc=n(75);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */
class Qc{constructor(){this.size=null}batch(t,e=!0){const n=this;let r;return l.util.assert(t>0,()=>"batchSize needs to be positive, but it is\n      "+t),r=this.size===1/0||null==this.size?this.size:e?Math.ceil(this.size/t):Math.floor(this.size/t),Xc(async()=>(await n.iterator()).columnMajorBatch(t,e,Zc),r)}concatenate(t){const e=this;let n;return n=this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null,Xc(async()=>(await e.iterator()).concatenate(await t.iterator()),n)}filter(t){const e=this;let n;return n=this.size===1/0?1/0:null,Xc(async()=>(await e.iterator()).filter(e=>l.tidy(()=>t(e))),n)}async forEachAsync(t){return(await this.iterator()).forEachAsync(t)}map(t){const e=this;return Xc(async()=>(await e.iterator()).map(e=>l.tidy(()=>t(e))),this.size)}mapAsync(t){const e=this;return Xc(async()=>(await e.iterator()).mapAsync(t),this.size)}prefetch(t){if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");const e=this;return Xc(async()=>(await e.iterator()).prefetch(t),this.size)}repeat(t){const e=this;let n;return n=null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null,Xc(async()=>{const n=Object(Hc.e)(async()=>({value:await e.iterator(),done:!1}));return Object(Hc.d)(n.take(t))},n)}skip(t){const e=this;let n;return n=null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null,Xc(async()=>(await e.iterator()).skip(t),n)}shuffle(t,e,n=!0){if(null==t||t<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified.  If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);const r=this,i=Gc.alea(e||l.util.now().toString());return Xc(async()=>{let e=i.int32();return n&&(e+=i.int32()),(await r.iterator()).shuffle(t,e.toString())},this.size)}take(t){const e=this;let n;return n=null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null,Xc(async()=>(await e.iterator()).take(t),n)}async toArray(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}}function Xc(t,e=null){return new class extends Qc{constructor(){super(...arguments),this.size=e}async iterator(){return t()}}}function Yc(t){return Xc(async()=>Object(Hc.f)(t),t.length)}function Jc(t){if(!Object(Kc.e)(t))throw new Error("The argument to zip() must be an object or array.");let e;if(Array.isArray(t))for(let n=0;n<t.length;n++)e=null==e?t[n].size:Math.min(e,t[n].size);else if(t instanceof Object)for(const n in t)e=null==e?t[n].size:Math.min(e,t[n].size);return Xc(async()=>{const e=await Object(Kc.c)(t,t=>{if(t instanceof Qc)return{value:t.iterator(),recurse:!1};if(Object(Kc.e)(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")});return Object(Hc.g)(e,Hc.c.SHORTEST)},e)}function Zc(t){if(null===t)return null;const e=t[0];if(Object(Kc.a)(e)){return{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof l.Tensor?l.stack(t):l.tensor(t)}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */(t),recurse:!1}}return{value:null,recurse:!0}}Qc.MAX_BUFFER_SIZE=1e4;class tl extends Qc{constructor(t){super(),this.input=t}async iterator(){return(await this.input.iterator()).decodeUTF8().split("\n").map(t=>(t.endsWith("\r")&&(t=t.slice(0,-1)),t))}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */const el=Symbol("out"),nl=Symbol("field"),rl=Symbol("quote"),il=Symbol("quoteafterquote"),sl=Symbol("quoteinquote");class al extends Qc{constructor(t,e){super(),this.input=t,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new tl(t),e||(e={}),this.hasHeader=!1!==e.hasHeader,this.fullColumnNames=e.columnNames,this.columnConfigs=e.columnConfigs,this.configuredColumnsOnly=e.configuredColumnsOnly,e.delimWhitespace?(l.util.assert(null==e.delimiter,()=>"Delimiter should not be provided when delimWhitespace is true."),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=e.delimiter?e.delimiter:","}async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){const t=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&t&&l.util.assert(t.length===this.fullColumnNames.length,()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+")."),this.fullColumnNames||(this.fullColumnNames=t);const e=this.fullColumnNames.reduce((t,e)=>(t[e]=t[e]+1||1,t),{}),n=Object.keys(e).filter(t=>e[t]>1);if(l.util.assert(0===n.length,()=>"Duplicate column names found: "+n.toString()),this.columnConfigs)for(const t of Object.keys(this.columnConfigs)){if(-1===this.fullColumnNames.indexOf(t))throw new Error('The key "'+t+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){const t=await this.base.iterator(),e=await t.next();if(e.done)throw new Error("No data was found for CSV parsing.");const n=e.value;return this.parseRow(n,!1)}return null}async iterator(){this.columnNamesValidated||await this.setColumnNames();let t=await this.base.iterator();return this.hasHeader&&(t=t.skip(1)),t.map(t=>this.makeDataElement(t))}makeDataElement(t){const e=this.parseRow(t),n={},r={};for(let i=0;i<this.fullColumnNames.length;i++){const s=this.fullColumnNames[i],a=this.columnConfigs?this.columnConfigs[s]:null;if(!this.configuredColumnsOnly||a){const o=e[i];let u=null;if(""===o)if(a&&void 0!==a.default)u=a.default;else{if(a&&(a.required||a.isLabel))throw new Error(`Required column ${s} is empty in this line: ${t}`);u=void 0}else{const t=Number(o);if(isNaN(t))u=a&&"bool"===a.dtype?this.getBoolean(o):o;else if(a&&a.dtype)switch(a.dtype){case"float32":u=t;break;case"int32":u=Math.floor(t);break;case"bool":u=this.getBoolean(o);break;default:u=t}else u=t}a&&a.isLabel?r[s]=u:n[s]=u}}return 0===Object.keys(r).length?n:{xs:n,ys:r}}getBoolean(t){return"1"===t||"true"===t.toLowerCase()?1:0}parseRow(t,e=!0){const n=[];let r=0;const i=t.length;let s=el;for(let e=0;e<i;e++)switch(s){case el:switch(t.charAt(e)){case'"':r=e+1,s=rl;break;case this.delimiter:if(r=e+1," "===this.delimiter&&this.delimWhitespace)break;n.push(""),s=el;break;default:s=nl,r=e}break;case nl:switch(t.charAt(e)){case this.delimiter:n.push(t.substring(r,e)),s=el,r=e+1}break;case rl:switch(t.charAt(e)){case'"':s=il}break;case il:switch(t.charAt(e)){case this.delimiter:n.push(t.substring(r,e-1)),s=el,r=e+1;break;case'"':s=rl;break;default:s=sl}break;case sl:switch(t.charAt(e)){case'"':s=rl}}if(s===il?n.push(t.substring(r,i-1)):n.push(t.substring(r)),e&&n.length!==this.fullColumnNames.length)throw new Error(`Invalid row in csv file. Should have ${this.fullColumnNames.length} elements in a row, but got ${n}`);return n}}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */class ol extends Hc.a{constructor(t){super(),this.microphoneConfig=t,this.isClosed=!1,this.fftSize=t.fftSize||1024;const e=Math.log2(this.fftSize);if(this.fftSize<0||e<4||e>14||!Number.isInteger(e))throw new Error("Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got "+this.fftSize);if(this.numFrames=t.numFramesPerSpectrogram||43,this.sampleRateHz=t.sampleRateHz,this.columnTruncateLength=t.columnTruncateLength||this.fftSize,this.audioTrackConstraints=t.audioTrackConstraints,this.smoothingTimeConstant=t.smoothingTimeConstant||0,this.includeSpectrogram=!1!==t.includeSpectrogram,this.includeWaveform=!0===t.includeWaveform,!this.includeSpectrogram&&!this.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.")}summary(){return"microphone"}static async create(t={}){if(Object(l.env)().get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");const e=new ol(t);return await e.start(),e}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})}catch(t){throw new Error("Error thrown while initializing video stream: "+t.message)}if(!this.stream)throw new Error("Could not obtain audio from microphone.");const t=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new t,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: `+this.audioContext.sampleRate)}else this.sampleRateHz=this.audioContext.sampleRate;const e=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,e.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize)}async next(){if(this.isClosed)return{value:null,done:!0};let t,e;const n=await this.getAudioData();if(this.includeSpectrogram){const e=this.flattenQueue(n.freqDataQueue);t=this.getTensorFromAudioDataArray(e,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){const t=this.flattenQueue(n.timeDataQueue);e=this.getTensorFromAudioDataArray(t,[this.numFrames*this.fftSize,1])}return{value:{spectrogram:t,waveform:e},done:!1}}async capture(){return(await this.next()).value}async getAudioData(){const t=[],e=[];let n=0;return new Promise(r=>{const i=setInterval(()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&r({freqDataQueue:t,timeDataQueue:e}),t.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),e.push(this.timeData.slice())),++n===this.numFrames&&(clearInterval(i),r({freqDataQueue:t,timeDataQueue:e}))},this.fftSize/this.sampleRateHz*1e3)})}stop(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())}toArray(){throw new Error("Can not convert infinite audio stream to array.")}getSampleRate(){return this.sampleRateHz}flattenQueue(t){const e=t[0].length,n=new Float32Array(t.length*e);return t.forEach((t,r)=>n.set(t,r*e)),n}getTensorFromAudioDataArray(t,e){const n=new Float32Array(l.util.sizeFromShape(e));return n.set(t,n.length-t.length),Object(l.tensor)(n,e)}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */class ul extends Hc.a{constructor(t,e){if(super(),this.webcamVideoElement=t,this.webcamConfig=e,this.isClosed=!0,this.resize=!1,this.needToResize())if(this.resize=!0,this.cropSize=[this.webcamConfig.resizeHeight,this.webcamConfig.resizeWidth],this.cropBoxInd=Object(l.tensor1d)([0],"int32"),this.webcamConfig.centerCrop){const t=1*this.webcamConfig.resizeWidth/this.webcamVideoElement.width,e=1*this.webcamConfig.resizeHeight/this.webcamVideoElement.height,n=(1-t)/2,r=(1-e)/2,i=n+t,s=e+r;this.cropBox=Object(l.tensor2d)([r,n,s,i],[1,4])}else this.cropBox=Object(l.tensor2d)([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(t,e={}){if(Object(l.env)().get("IS_NODE"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!e.resizeWidth||!e.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=e.resizeWidth,t.height=e.resizeHeight}const n=new ul(t,e);return await n.start(),n}async start(){this.webcamConfig.facingMode&&l.util.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,()=>`Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`);try{this.stream=await navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})}catch(t){throw t.message="Error thrown while initializing video stream: "+t.message,t}if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,new Promise(t=>{this.webcamVideoElement.onloadedmetadata=()=>{t()}})}async next(){if(this.isClosed)return{value:null,done:!0};let t;try{t=l.browser.fromPixels(this.webcamVideoElement)}catch(t){throw new Error("Error thrown converting video to pixels: "+JSON.stringify(t))}if(!this.resize)return{value:t,done:!1};try{return{value:this.cropAndResizeFrame(t),done:!1}}catch(t){throw new Error("Error thrown cropping the video: "+t.message)}finally{t.dispose()}}needToResize(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)}cropAndResizeFrame(t){return Object(l.tidy)(()=>{const e=t.toFloat().expandDims(0);let n;n=l.image.cropAndResize(e,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");const r=n.shape;return n.reshape(r.slice(1))})}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach(t=>t.stop());try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */class cl{}var ll=n(289);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */class hl extends ll.a{constructor(t,e={}){super(),this.file=t,this.options=e,l.util.assert(t instanceof Uint8Array||!!Object(l.env)().get("IS_BROWSER")&&(t instanceof File||t instanceof Blob),()=>"FileChunkIterator only supports File, Blob and Uint8Array right now."),this.offset=e.offset||0,this.chunkSize=e.chunkSize||1048576}summary(){return"FileChunks "+this.file}async next(){if(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))return{value:null,done:!0};const t=new Promise((t,e)=>{const n=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)t(new Uint8Array(this.file.slice(this.offset,n)));else{const r=new FileReader;r.onload=n=>{let i=r.result;if(i instanceof ArrayBuffer&&(i=new Uint8Array(i)),!(i instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(i)},r.onabort=t=>e(new Error("Aborted")),r.onerror=t=>e(new Error(t.type));const i=this.file.slice(this.offset,n);r.readAsArrayBuffer(i)}this.offset=n});return{value:await t,done:!1}}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */const dl=t=>({method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity});
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */function pl(t){return"string"==typeof t&&"file://"===t.substr(0,7)}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */class fl extends cl{constructor(t,e={}){super(),this.input=t,this.options=e}async iterator(){if(pl(this.input)&&Object(l.env)().get("IS_NODE")){const t=n(312);this.input=t.readFileSync(this.input.substr(7))}return new hl(this.input,this.options)}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */class ml extends cl{constructor(t,e={}){super(),this.url=t,this.fileOptions=e}async iterator(){return pl(this.url)?new fl(this.url,this.fileOptions).iterator():async function(t,e={}){let n,r;"string"==typeof t?n=t:(n=t.url,r=dl(t));const i=await l.util.fetch(n,r);if(i.ok){const t=new Uint8Array(await i.arrayBuffer());return new hl(t,e)}throw new Error(i.statusText)}(this.url,this.fileOptions)}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */function gl(t,e={}){return new al(new ml(t),e)}function bl(t){const e=Object(Hc.e)(t);return Xc(async()=>e)}function yl(t){return Xc(async()=>{const e=await t();return Object(Hc.e)(()=>e.next())})}async function vl(t,e){return ul.create(t,e)}async function wl(t){return ol.create(t)}
/** @license See the LICENSE file. */const xl="2.7.0";
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var _l=n(11);
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Ol=l.kernel_impls.nonMaxSuppressionV3Impl,Sl=l.kernel_impls.split,kl=l.kernel_impls.tile,Tl=l.kernel_impls.topkImpl,Cl=l.kernel_impls.whereImpl;class Al extends l.KernelBackend{constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new l.DataStorage(this,Object(l.engine)())}write(t,e,n){this.firstUse&&(this.firstUse=!1,Object(l.env)().get("IS_NODE")&&l.backend_util.warn("\n============================\nHi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.\n============================"));const r={};return this.data.set(r,{values:t,dtype:n,refCount:1}),r}makeTensorInfo(t,e,n){let r;if("string"===e&&null!=n&&n.length>0&&l.util.isString(n[0])){const i=n.map(t=>l.util.encodeString(t));r=this.write(i,t,e)}else r=this.write(n,t,e);return{dataId:r,shape:t,dtype:e}}incRef(t){this.data.get(t).refCount++}decRef(t){if(this.data.has(t)){this.data.get(t).refCount--}}move(t,e,n,r){this.data.set(t,{values:e,dtype:r,refCount:1})}numDataIds(){return this.data.numDataIds()}async read(t){return this.readSync(t)}readSync(t){const{dtype:e,complexTensorInfos:n}=this.data.get(t);if("complex64"===e){const t=this.readSync(n.real.dataId),e=this.readSync(n.imag.dataId);return l.backend_util.mergeRealAndImagArrays(t,e)}return this.data.get(t).values}bufferSync(t){const e=this.readSync(t.dataId);let n=e;if("string"===t.dtype)try{n=e.map(t=>l.util.decodeString(t))}catch(t){throw new Error("Failed to decode encoded string bytes into utf-8")}return l.buffer(t.shape,t.dtype,n)}makeOutput(t,e,n){const r=this.write(t,e,n);return Object(l.engine)().makeTensorFromDataId(r,e,n,this)}disposeData(t){if(this.data.has(t)){const{complexTensorInfos:e}=this.data.get(t);null!=e&&(this.disposeData(e.real.dataId),this.disposeData(e.imag.dataId)),this.data.delete(t)}}disposeIntermediateTensorInfo(t){const e=t.dataId;if(this.data.has(e)){const t=this.data.get(e);t.refCount--,t.refCount<1&&this.disposeData(e)}}async time(t){const e=l.util.now();t();return{kernelMs:l.util.now()-e}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}stridedSlice(t,e,n,r){Object(_l.a)(t,"stridedSlice");const i=l.slice_util.computeOutShape(e,n,r);if(i.some(t=>0===t))return l.tensor([],i);const s=l.buffer(i,t.dtype),a=this.bufferSync(t);for(let t=0;t<s.size;t++){const n=s.indexToLoc(t),i=new Array(n.length);for(let t=0;t<i.length;t++)i[t]=n[t]*r[t]+e[t];s.set(a.get(...i),...n)}return s.toTensor()}diag(t){const e=this.readSync(t.dataId),n=l.buffer([t.size,t.size],t.dtype),r=n.values;for(let n=0;n<e.length;n++)r[n*t.size+n]=e[n];return n.toTensor()}unstack(t,e){const n=t.shape[e],r=new Array(t.rank-1);let i=0;for(let n=0;n<t.rank;n++)n!==e&&(r[i++]=t.shape[n]);const s=new Array(t.rank).fill(0),a=t.shape.slice();a[e]=1;const o=new Array(n);for(let n=0;n<o.length;n++)s[e]=n,o[n]=l.slice(t,s,a).reshape(r);return o}reverse(t,e){Object(_l.a)(t,"reverse");const n=l.buffer(t.shape,t.dtype),r=this.bufferSync(t);for(let i=0;i<n.size;i++){const s=n.indexToLoc(i),a=s.slice();e.forEach(e=>a[e]=t.shape[e]-1-a[e]),n.set(r.get(...a),...s)}return n.toTensor()}neg(t){return Object(_l.a)(t,"neg"),l.mul(l.scalar(-1),t)}addN(t){Object(_l.a)(t,"addN");const e=t.map(t=>this.readSync(t.dataId)),n=l.buffer(t[0].shape,t[0].dtype),r=n.values;for(let n=0;n<t.length;n++){const t=e[n];for(let e=0;e<r.length;e++)r[e]+=t[e]}return n.toTensor()}softmax(t,e){const n=l.util.parseAxisParam([e],t.shape),r=Object(l.max)(t,n),i=l.backend_util.expandShapeToKeepDim(r.shape,n),s=l.sub(t,r.reshape(i)),a=l.exp(s),o=this.sum(a,n).reshape(i);return l.div(a,o)}pow(t,e){return Object(_l.a)([t,e],"pow"),this.broadcastedBinaryOp(t,e,t.dtype,(t,e)=>Math.pow(t,e))}floorDiv(t,e){Object(_l.a)([t,e],"floorDiv");return this.broadcastedBinaryOp(t,e,"int32",(t,e)=>Math.floor(t/e))}sum(t,e){Object(_l.a)(t,"sum"),l.backend_util.assertAxesAreInnerMostDims("sum",e,t.rank);const[n,r]=l.backend_util.computeOutAndReduceShapes(t.shape,e),i=Object(l.upcastType)(t.dtype,"int32"),s=l.zeros(n,i),a=l.util.sizeFromShape(r),o=this.readSync(s.dataId),u=this.readSync(t.dataId);for(let t=0;t<o.length;++t){const e=t*a;let n=0;for(let t=0;t<a;++t)n+=u[e+t];o[t]=n}return s}prod(t,e){Object(_l.a)(t,"sum");const[n,r]=l.backend_util.computeOutAndReduceShapes(t.shape,e),i=Object(l.upcastType)(t.dtype,"int32"),s=l.zeros(n,i),a=l.util.sizeFromShape(r),o=this.readSync(s.dataId),u=this.readSync(t.dataId);for(let t=0;t<o.length;++t){const e=t*a;let n=1;for(let t=0;t<a;++t)n*=u[e+t];o[t]=n}return s}unsortedSegmentSum(t,e,n){Object(_l.a)(t,"unsortedSegmentSum");const r=[],i=t.rank-e.rank;for(let t=0;t<i;++t)e=e.expandDims(t+1);for(let i=0;i<n;++i){const n=l.scalar(i,"int32"),s=l.equal(n,e).asType("float32").mul(t).sum(0);r.push(s)}return l.stack(r)}argMin(t,e){Object(_l.a)(t,"argMin");const n=[e];l.backend_util.assertAxesAreInnerMostDims("argMin",n,t.rank);const[r,i]=l.backend_util.computeOutAndReduceShapes(t.shape,n),s=l.zeros(r,"int32"),a=l.util.sizeFromShape(i),o=this.readSync(s.dataId),u=this.readSync(t.dataId);for(let t=0;t<o.length;++t){const e=t*a;let n=u[e],r=0;for(let t=0;t<a;++t){const i=u[e+t];i<n&&(n=i,r=t)}o[t]=r}return s}argMax(t,e){Object(_l.a)(t,"argMax");const n=[e];l.backend_util.assertAxesAreInnerMostDims("argMax",n,t.rank);const[r,i]=l.backend_util.computeOutAndReduceShapes(t.shape,n),s=l.zeros(r,"int32"),a=l.util.sizeFromShape(i),o=this.readSync(s.dataId),u=this.readSync(t.dataId);for(let t=0;t<o.length;++t){const e=t*a;let n=u[e],r=0;for(let t=0;t<a;++t){const i=u[e+t];i>n&&(n=i,r=t)}o[t]=r}return s}cumsum(t,e,n,r){if(Object(_l.a)(t,"cumsum"),e!==t.rank-1)throw new Error(`backend.cumsum in CPU expects an inner-most axis=${t.rank-1} but got axis=`+e);const i=Object(l.upcastType)(t.dtype,"int32"),s=l.zeros(t.shape,i),a=this.readSync(s.dataId),o=this.readSync(t.dataId),u=t.shape[t.rank-1],c=r?(t,e)=>t+u-e-1:(t,e)=>t+e;for(let t=0;t<o.length;t+=u)for(let e=0;e<u;e++){const r=c(t,e);if(0===e)a[r]=n?0:o[r];else{const i=c(t,e-1);a[r]=n?o[i]+a[i]:o[r]+a[i]}}return s}equal(t,e){return Object(_l.a)([t,e],"equal"),this.broadcastedBinaryOp(t,e,"bool",(t,e)=>t===e?1:0)}notEqual(t,e){return Object(_l.a)([t,e],"notEqual"),this.broadcastedBinaryOp(t,e,"bool",(t,e)=>t!==e?1:0)}less(t,e){return Object(_l.a)([t,e],"less"),this.broadcastedBinaryOp(t,e,"bool",(t,e)=>t<e?1:0)}lessEqual(t,e){return Object(_l.a)([t,e],"lessEqual"),this.broadcastedBinaryOp(t,e,"bool",(t,e)=>t<=e?1:0)}greater(t,e){return Object(_l.a)([t,e],"greater"),this.broadcastedBinaryOp(t,e,"bool",(t,e)=>t>e?1:0)}greaterEqual(t,e){return Object(_l.a)([t,e],"greaterEqual"),this.broadcastedBinaryOp(t,e,"bool",(t,e)=>t>=e?1:0)}logicalAnd(t,e){return Object(_l.a)([t,e],"logicalAnd"),this.broadcastedBinaryOp(t,e,"bool",(t,e)=>t&&e)}logicalOr(t,e){return Object(_l.a)([t,e],"logicalOr"),this.broadcastedBinaryOp(t,e,"bool",(t,e)=>t||e)}select(t,e,n){Object(_l.a)([t,e,n],"select");const r=this.readSync(t.dataId),i=this.readSync(e.dataId),s=this.readSync(n.dataId),a=l.zeros(e.shape,Object(l.upcastType)(e.dtype,n.dtype)),o=this.readSync(a.dataId);let u=0;const c=0===t.rank||t.rank>1||1===e.rank?1:l.util.sizeFromShape(e.shape.slice(1));for(let t=0;t<r.length;t++)for(let e=0;e<c;e++)1===r[t]?o[u++]=i[t]:o[u++]=s[t];return a}where(t){Object(_l.a)([t],"where");const e=this.readSync(t.dataId);return Cl(t.shape,e)}topk(t,e,n){Object(_l.a)(t,"topk");const r=this.readSync(t.dataId);return Tl(r,t.shape,t.dtype,e,n)}min(t,e){Object(_l.a)(t,"min"),l.backend_util.assertAxesAreInnerMostDims("min",e,t.rank);const[n,r]=l.backend_util.computeOutAndReduceShapes(t.shape,e),i=l.zeros(n,t.dtype),s=l.util.sizeFromShape(r),a=this.readSync(i.dataId),o=this.readSync(t.dataId);for(let t=0;t<a.length;++t){const e=t*s;let n=o[e];for(let t=0;t<s;++t){const r=o[e+t];r<n&&(n=r)}a[t]=n}return i}minimum(t,e){return Object(_l.a)([t,e],"minimum"),this.broadcastedBinaryOp(t,e,t.dtype,(t,e)=>Math.min(t,e))}mod(t,e){return Object(_l.a)([t,e],"mod"),this.broadcastedBinaryOp(t,e,t.dtype,(t,e)=>{const n=t%e;return t<0&&e<0||t>=0&&e>=0?n:(n+e)%e})}maximum(t,e){return Object(_l.a)([t,e],"maximum"),this.broadcastedBinaryOp(t,e,t.dtype,(t,e)=>Math.max(t,e))}all(t,e){Object(_l.a)(t,"all"),l.backend_util.assertAxesAreInnerMostDims("all",e,t.rank);const[n,r]=l.backend_util.computeOutAndReduceShapes(t.shape,e),i=l.zeros(n,t.dtype),s=l.util.sizeFromShape(r),a=this.readSync(i.dataId),o=this.readSync(t.dataId);for(let t=0;t<a.length;++t){const e=t*s;let n=o[e];for(let t=0;t<s;++t){const r=o[e+t];n=n&&r}a[t]=n}return i}any(t,e){Object(_l.a)(t,"any"),l.backend_util.assertAxesAreInnerMostDims("any",e,t.rank);const[n,r]=l.backend_util.computeOutAndReduceShapes(t.shape,e),i=l.zeros(n,t.dtype),s=l.util.sizeFromShape(r),a=this.readSync(i.dataId),o=this.readSync(t.dataId);for(let t=0;t<a.length;++t){const e=t*s;let n=o[e];for(let t=0;t<s;++t){const r=o[e+t];n=n||r}a[t]=n}return i}squaredDifference(t,e){return Object(_l.a)([t,e],"squaredDifference"),this.broadcastedBinaryOp(t,e,t.dtype,(t,e)=>{const n=t-e;return n*n})}eluDer(t,e){Object(_l.a)([t,e],"eluDer");const n=new Float32Array(e.size),r=this.readSync(e.dataId),i=this.readSync(t.dataId);for(let t=0;t<r.length;++t){const e=r[t];n[t]=e>=1?i[t]:i[t]*(e+1)}return this.makeOutput(n,e.shape,"float32")}atan2(t,e){return Object(_l.a)([t,e],"atan2"),this.broadcastedBinaryOp(t,e,t.dtype,(t,e)=>Math.atan2(t,e))}tile(t,e){return Object(_l.a)(t,"tile"),kl(this.bufferSync(t),e)}gather(t,e,n){Object(_l.a)([t,e],"gather");const r=t.shape.slice(),i=this.readSync(e.dataId);r[n]=i.length;const s=l.buffer(r,t.dtype),a=this.bufferSync(t);for(let t=0;t<s.size;++t){const e=s.indexToLoc(t),r=e.slice();r[n]=i[e[n]];const o=a.locToIndex(r);s.values[t]=a.values[o]}return s.toTensor()}batchToSpaceND(t,e,n){Object(_l.a)([t],"batchToSpaceND");const r=e.reduce((t,e)=>t*e),i=l.backend_util.getReshaped(t.shape,e,r),s=l.backend_util.getPermuted(i.length,e.length),a=l.backend_util.getReshapedPermuted(t.shape,e,r),o=l.backend_util.getSliceBeginCoords(n,e.length),u=l.backend_util.getSliceSize(a,n,e.length);return l.transpose(t.reshape(i),s).reshape(a).slice(o,u)}pool3d(t,e,n){Object(_l.a)(t,"pool3d");const r=e.strideDepth,i=e.strideHeight,s=e.strideWidth,a=e.dilationDepth,o=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterDepth,h=e.effectiveFilterHeight,d=e.effectiveFilterWidth,p=e.padInfo.front,f=e.padInfo.top,m=e.padInfo.left,g="max"===n?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,b=this.readSync(t.dataId),y=l.buffer(e.outShape,t.dtype),v=y.values,w=e.outShape[1]*e.outShape[2]*e.outShape[3]*e.outShape[4],x=e.outShape[2]*e.outShape[3]*e.outShape[4],_=e.outShape[3]*e.outShape[4],O=e.outShape[4];for(let l=0;l<e.batchSize;++l){const y=l*w,S=l*t.strides[0];for(let l=0;l<e.inChannels;++l)for(let w=0;w<e.outDepth;++w){const k=w*r-p;let T=k;for(;T<0;)T+=a;const C=Math.min(e.inDepth,c+k),A=y+w*x;for(let r=0;r<e.outHeight;++r){const c=r*i-f;let p=c;for(;p<0;)p+=o;const y=Math.min(e.inHeight,h+c),w=A+r*_;for(let r=0;r<e.outWidth;++r){const i=r*s-m;let c=i;for(;c<0;)c+=u;const h=Math.min(e.inWidth,d+i),f=w+r*O;let x=g,_=0,k=0;for(let e=T;e<C;e+=a){const r=S+e*t.strides[1];for(let e=p;e<y;e+=o){const i=r+e*t.strides[2];for(let e=c;e<h;e+=u){const r=b[i+e*t.strides[3]+l];if("max"===n&&r>x?x=r:"avg"===n&&(_+=r,k++),isNaN(x))break}if(isNaN(x))break}if(isNaN(x))break}v[f+l]="avg"===n?_/k:x}}}}return y.toTensor()}avgPool3d(t,e){return Object(_l.a)(t,"avgPool3d"),this.pool3d(t,e,"avg").toFloat()}avgPool3dBackprop(t,e,n){Object(_l.a)([t,e],"avgPool3dBackprop");const r=n.strideDepth,i=n.strideHeight,s=n.strideWidth,a=n.filterDepth,o=n.filterHeight,u=n.filterWidth,c=n.dilationDepth,h=n.dilationHeight,d=n.dilationWidth,p=n.effectiveFilterDepth,f=n.effectiveFilterHeight,m=n.effectiveFilterWidth,g=p-1-n.padInfo.front,b=m-1-n.padInfo.left,y=f-1-n.padInfo.top,v=l.buffer(e.shape,"float32"),w=1/(a*o*u),x=this.bufferSync(t);for(let t=0;t<n.batchSize;++t)for(let e=0;e<n.inChannels;++e)for(let a=0;a<n.inDepth;++a)for(let o=0;o<n.inHeight;++o)for(let u=0;u<n.inWidth;++u){const l=a-g,_=o-y,O=u-b;let S=0;for(let a=0;a<p;a+=c){const o=(l+a)/r;if(!(o<0||o>=n.outDepth||Math.floor(o)!==o))for(let r=0;r<f;r+=h){const a=(_+r)/i;if(!(a<0||a>=n.outHeight||Math.floor(a)!==a))for(let r=0;r<m;r+=d){const i=(O+r)/s;if(i<0||i>=n.outWidth||Math.floor(i)!==i)continue;S+=x.get(t,o,a,i,e)}}}v.set(S*w,t,a,o,u,e)}return v.toTensor()}maxPool3d(t,e){return Object(_l.a)(t,"maxPool3d"),this.pool3d(t,e,"max").toFloat()}maxPool3dPositions(t,e){const n=l.buffer(e.outShape,"int32"),r=e.strideDepth,i=e.strideHeight,s=e.strideWidth,a=e.dilationDepth,o=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterDepth,h=e.effectiveFilterHeight,d=e.effectiveFilterWidth,p=e.padInfo.front,f=e.padInfo.top,m=e.padInfo.left,g=this.bufferSync(t);for(let t=0;t<e.batchSize;++t)for(let l=0;l<e.inChannels;++l)for(let b=0;b<e.outDepth;++b){const y=b*r-p;let v=y;for(;v<0;)v+=a;const w=Math.min(e.inDepth,c+y);for(let r=0;r<e.outHeight;++r){const c=r*i-f;let p=c;for(;p<0;)p+=o;const x=Math.min(e.inHeight,h+c);for(let i=0;i<e.outWidth;++i){const f=i*s-m;let _=f;for(;_<0;)_+=u;const O=Math.min(e.inWidth,d+f);let S=Number.NEGATIVE_INFINITY,k=-1;for(let e=v;e<w;e+=a){const n=e-y;for(let r=p;r<x;r+=o){const i=r-c;for(let s=_;s<O;s+=u){const a=s-f,o=g.get(t,e,r,s,l);o>=S&&(S=o,k=n*h*d+i*h+a)}}}n.set(k,t,b,r,i,l)}}}return n.toTensor()}maxPool3dBackprop(t,e,n,r){Object(_l.a)([e,n],"maxPool3dBackprop");const i=this.maxPool3dPositions(e,r),s=r.strideDepth,a=r.strideHeight,o=r.strideWidth,u=r.dilationDepth,c=r.dilationHeight,h=r.dilationWidth,d=r.effectiveFilterDepth,p=r.effectiveFilterHeight,f=r.effectiveFilterWidth,m=d-1-r.padInfo.front,g=f-1-r.padInfo.left,b=p-1-r.padInfo.top,y=l.buffer(e.shape,"float32"),v=this.bufferSync(i),w=this.bufferSync(t);for(let t=0;t<r.batchSize;++t)for(let e=0;e<r.inChannels;++e)for(let n=0;n<r.inDepth;++n)for(let i=0;i<r.inHeight;++i)for(let l=0;l<r.inWidth;++l){const x=n-m,_=i-b,O=l-g;let S=0;for(let n=0;n<d;n+=u){const i=(x+n)/s;if(!(i<0||i>=r.outDepth||Math.floor(i)!==i))for(let s=0;s<p;s+=c){const u=(_+s)/a;if(!(u<0||u>=r.outHeight||Math.floor(u)!==u))for(let a=0;a<f;a+=h){const c=(O+a)/o;if(c<0||c>=r.outWidth||Math.floor(c)!==c)continue;const l=d*p*f-1-v.get(t,i,u,c,e)===n*p*f+s*f+a?1:0;if(0===l)continue;S+=w.get(t,i,u,c,e)*l}}}y.set(S,t,n,i,l,e)}return y.toTensor()}resizeBilinear(t,e,n,r){Object(_l.a)(t,"resizeBilinear");const[i,s,a,o]=t.shape,u=this.readSync(t.dataId),c=new Float32Array(l.util.sizeFromShape([i,e,n,o])),h=[r&&e>1?s-1:s,r&&n>1?a-1:a],d=[r&&e>1?e-1:e,r&&n>1?n-1:n];let p=0;const f=h[0]/d[0],m=h[1]/d[1];for(let r=0;r<i;r++)for(let i=0;i<e;i++){const e=f*i,l=Math.floor(e),h=e-l,d=Math.min(s-1,Math.ceil(e)),g=r*t.strides[0]+l*t.strides[1],b=r*t.strides[0]+d*t.strides[1];for(let e=0;e<n;e++){const n=m*e,r=Math.floor(n),i=n-r,s=Math.min(a-1,Math.ceil(n)),l=g+r*t.strides[2],d=b+r*t.strides[2],f=g+s*t.strides[2],y=b+s*t.strides[2];for(let t=0;t<o;t++){const e=u[l+t],n=u[d+t],r=e+(u[f+t]-e)*i,s=r+(n+(u[y+t]-n)*i-r)*h;c[p++]=s}}}return l.tensor(c,[i,e,n,o])}resizeBilinearBackprop(t,e,n){Object(_l.a)([t,e],"resizeBilinearBackprop");const[r,i,s,a]=e.shape,[,o,u]=t.shape,c=new Float32Array(r*i*s*a),h=[n&&o>1?i-1:i,n&&u>1?s-1:s],d=[n&&o>1?o-1:o,n&&u>1?u-1:u],p=h[0]/d[0],f=h[1]/d[1],m=this.readSync(t.dataId);let g=0;for(let t=0;t<r;t++){const n=t*e.strides[0];for(let t=0;t<o;t++){const r=t*p,o=Math.floor(r),l=Math.min(Math.ceil(r),i-1),h=n+o*e.strides[1],d=n+l*e.strides[1],b=r-o,y=1-b;for(let t=0;t<u;t++){const n=t*f,r=Math.floor(n),i=Math.min(Math.ceil(n),s-1),o=n-r,u=1-o,l=h+r*e.strides[2],p=h+i*e.strides[2],v=d+r*e.strides[2],w=d+i*e.strides[2],x=y*u,_=y*o,O=b*u,S=b*o;for(let t=0;t<a;t++){const e=m[g++];c[l+t]+=e*x,c[p+t]+=e*_,c[v+t]+=e*O,c[w+t]+=e*S}}}}return l.tensor4d(c,[r,s,i,a],e.dtype)}resizeNearestNeighbor(t,e,n,r){Object(_l.a)(t,"resizeNearestNeighbor");const[i,s,a,o]=t.shape,u=this.readSync(t.dataId),c=new Float32Array(i*e*n*o),h=[r&&e>1?s-1:s,r&&n>1?a-1:a],d=[r&&e>1?e-1:e,r&&n>1?n-1:n],p=h[0]/d[0],f=h[1]/d[1];let m=0;for(let l=0;l<i;l++){const i=l*t.strides[0];for(let l=0;l<e;l++){const e=p*l,h=i+Math.min(s-1,r?Math.round(e):Math.floor(e))*t.strides[1];for(let e=0;e<n;e++){const n=f*e,i=h+Math.min(a-1,r?Math.round(n):Math.floor(n))*t.strides[2];for(let t=0;t<o;t++){const e=u[i+t];c[m++]=e}}}}return l.tensor(c,[i,e,n,o],t.dtype)}resizeNearestNeighborBackprop(t,e,n){Object(_l.a)([t,e],"resizeNearestNeighborBackprop");const[r,i,s,a]=e.shape,[,o,u]=t.shape,c=new Float32Array(r*i*s*a),h=this.readSync(t.dataId),d=[n&&o>1?i-1:i,n&&u>1?s-1:s],p=[n&&o>1?o-1:o,n&&u>1?u-1:u],f=d[0]/p[0],m=d[1]/p[1],g=1/f,b=1/m,y=2*Math.ceil(g)+2,v=2*Math.ceil(b)+2;for(let l=0;l<r;l++){const r=l*e.strides[0];for(let l=0;l<i;l++){const d=r+l*e.strides[1],p=Math.floor(l*g),w=Math.floor(p-y/2);for(let p=0;p<s;p++){const g=d+p*e.strides[2],x=Math.floor(p*b),_=Math.floor(x-v/2);for(let e=0;e<a;e++){let a=0;for(let c=0;c<y;c++){const d=c+w;if(d<0||d>=o)continue;const g=r+d*t.strides[1],b=d*f;if(l===Math.min(i-1,n?Math.round(b):Math.floor(b)))for(let r=0;r<v;r++){const i=r+_;if(i<0||i>=u)continue;const o=g+i*t.strides[2],c=i*m;p===Math.min(s-1,n?Math.round(c):Math.floor(c))&&(a+=h[o+e])}}c[g+e]=a}}}}return l.tensor4d(c,e.shape,e.dtype)}localResponseNormalization4D(t,e,n,r,i){Object(_l.a)(t,"localResponseNormalization4D");const s=t.shape[3],a=s-1,o=this.readSync(t.dataId),u=t.size,c=new Float32Array(u);function h(t){const n=t%s;let r=t-n+Math.max(0,n-e);const i=t-n+Math.min(n+e,a);let u=0;for(;r<=i;r++){const t=o[r];u+=t*t}return u}for(let t=0;t<u;t++){const e=h(t),s=o[t]*Math.pow(n+r*e,-i);c[t]=s}return l.tensor4d(c,t.shape)}LRNGrad(t,e,n,r,i,s,a){Object(_l.a)(t,"LRNGrad");const o=t.shape[3],u=this.readSync(t.dataId),c=this.readSync(e.dataId),h=this.readSync(n.dataId),d=new Float32Array(t.size),p=t.size;for(let t=0;t<p;t++){const e=t%o,n=t-e+Math.max(0,e-r),l=t-e+Math.min(o,e+r+1);let p=0;for(let t=n;t<l;t++)p+=Math.pow(c[t],2);p=s*p+i;for(let e=n;e<l;e++){let n=-2*s*a*c[e]*h[t]/p;t===e&&(n+=Math.pow(p,-a)),n*=u[t],d[e]+=n}}return l.tensor4d(d,t.shape)}multinomial(t,e,n,r){Object(_l.a)(t,"multinomial");const i=e?t:l.softmax(t),s=i.shape[0],a=i.shape[1],o=l.zeros([s,n],"int32"),u=this.readSync(o.dataId),c=this.readSync(i.dataId);for(let t=0;t<s;++t){const e=t*a,i=new Float32Array(a-1);i[0]=c[e];for(let t=1;t<i.length;++t)i[t]=i[t-1]+c[e+t];const s=Gc.alea(r.toString()),o=t*n;for(let t=0;t<n;++t){const e=s();u[o+t]=i.length;for(let n=0;n<i.length;n++)if(e<i[n]){u[o+t]=n;break}}}return o}oneHot(t,e,n,r){Object(_l.a)(t,"oneHot");const i=new Float32Array(t.size*e);i.fill(r);const s=this.readSync(t.dataId);for(let r=0;r<t.size;++r)s[r]>=0&&s[r]<e&&(i[r*e+s[r]]=n);return l.tensor2d(i,[t.size,e],"int32")}nonMaxSuppression(t,e,n,r,i){Object(_l.a)(t,"nonMaxSuppression");const s=this.readSync(t.dataId),a=this.readSync(e.dataId);return Ol(s,a,n,r,i)}depthToSpace(t,e,n){l.util.assert("NHWC"===n,()=>"Only NHWC dataFormat supported on CPU for depthToSpace. Got "+n),l.util.assert(e>1,()=>"blockSize should be > 1 for depthToSpace, but was: "+e);const r=t.shape[0],i=t.shape[1],s=t.shape[2],a=t.shape[3],o=i*e,u=s*e,c=a/(e*e),h=this.readSync(t.dataId),d=new Float32Array(r*o*u*c);let p=0;for(let t=0;t<r;++t)for(let n=0;n<o;++n){const r=Math.floor(n/e),o=n%e;for(let n=0;n<u;++n){const u=Math.floor(n/e),l=(o*e+n%e)*c;for(let e=0;e<c;++e){const n=e+l+a*(u+s*(r+i*t));d[p++]=h[n]}}}return l.tensor4d(d,[r,o,u,c])}broadcastedBinaryOp(t,e,n,r){const i=l.backend_util.assertAndGetBroadcastShape(t.shape,e.shape),s=l.buffer(i,n),a=this.readSync(t.dataId),o=this.readSync(e.dataId),u=l.backend_util.getBroadcastDims(t.shape,i),c=l.backend_util.getBroadcastDims(e.shape,i),h=s.values;if(u.length+c.length===0)for(let t=0;t<h.length;++t)h[t]=r(a[t%a.length],o[t%o.length]);else{const n=this.bufferSync(t),i=this.bufferSync(e);for(let l=0;l<h.length;++l){const d=s.indexToLoc(l),p=d.slice(-t.rank);u.forEach(t=>p[t]=0);const f=n.locToIndex(p),m=d.slice(-e.rank);c.forEach(t=>m[t]=0);const g=i.locToIndex(m);h[l]=r(a[f],o[g])}}return s.toTensor()}split(t,e,n){return Sl(t,e,n)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}cropAndResize(t,e,n,r,i,s){const[a,o,u,c]=t.shape,h=e.shape[0],[d,p]=r,f=l.buffer([h,d,p,c],"float32"),m=this.readSync(e.dataId),g=this.readSync(n.dataId),b=this.readSync(t.dataId),y=t.strides,v=f.strides;for(let t=0;t<h;t++){const e=4*t,n=m[e],r=m[e+1],l=m[e+2],h=m[e+3],w=g[t];if(w>=a)continue;const x=d>1?(l-n)*(o-1)/(d-1):0,_=p>1?(h-r)*(u-1)/(p-1):0;for(let e=0;e<d;e++){const a=d>1?n*(o-1)+e*x:.5*(n+l)*(o-1);if(a<0||a>o-1)for(let n=0;n<p;n++)for(let r=0;r<c;r++){const i=r+n*v[2]+e*v[1]+t*v[0];f.values[i]=s}else if("bilinear"===i){const n=Math.floor(a),i=Math.ceil(a),o=a-n;for(let a=0;a<p;a++){const l=p>1?r*(u-1)+a*_:.5*(r+h)*(u-1);if(l<0||l>u-1){for(let n=0;n<c;n++){const r=n+a*v[2]+e*v[1]+t*v[0];f.values[r]=s}continue}const d=Math.floor(l),m=Math.ceil(l),g=l-d;for(let r=0;r<c;r++){let s=r+d*y[2]+n*y[1]+w*y[0];const u=b[s];s=r+m*y[2]+n*y[1]+w*y[0];const c=b[s];s=r+d*y[2]+i*y[1]+w*y[0];const l=b[s];s=r+m*y[2]+i*y[1]+w*y[0];const h=u+(c-u)*g,p=l+(b[s]-l)*g;s=r+a*v[2]+e*v[1]+t*v[0],f.values[s]=h+(p-h)*o}}}else for(let n=0;n<p;++n){const i=p>1?r*(u-1)+n*_:.5*(r+h)*(u-1);if(i<0||i>u-1){for(let r=0;r<c;r++){const i=r+n*v[2]+e*v[1]+t*v[0];f.values[i]=s}continue}const o=Math.round(i),l=Math.round(a);for(let r=0;r<c;r++){const i=r+o*y[2]+l*y[1]+w*y[0],s=r+n*v[2]+e*v[1]+t*v[0];f.values[s]=b[i]}}}}return f.toTensor()}sparseToDense(t,e,n,r){const{sliceRank:i,numUpdates:s,sliceSize:a,strides:o,outputSize:u}=l.backend_util.calculateShapes(e,t,n);return this.scatter(t,e,n,u,a,s,i,o,r,!1)}gatherND(t,e){const n=e.shape,r=n[n.length-1],[i,s,a,o]=l.backend_util.prepareAndValidate(t,e);if(0===s)return l.tensor([],i,t.dtype);const u=new l.TensorBuffer([s,a],t.dtype),c=this.readSync(e.dataId),h=this.readSync(t.dataId);for(let e=0;e<s;e++){const n=[];let i=0;for(let t=0;t<r;t++){const s=c[e*r+t];i+=s*o[t],n.push(s)}if(i<0||i>=t.size/a)throw new Error(`Invalid indices: ${n} does not index into ${t.shape}`);for(let t=0;t<a;t++)u.values[e*a+t]=h[i*a+t]}return u.toTensor().reshape(i)}scatterND(t,e,n){const{sliceRank:r,numUpdates:i,sliceSize:s,strides:a,outputSize:o}=l.backend_util.calculateShapes(e,t,n),u=l.scalar(0);return this.scatter(t,e,n,o,s,i,r,a,u,!0)}onesLike(t){if("string"===t.dtype)throw new Error("onesLike is not supported for string tensors");return l.fill(t.shape,1,t.dtype)}zerosLike(t){const e=l.util.getArrayFromDType(t.dtype,l.util.sizeFromShape(t.shape));return this.makeOutput(e,t.shape,t.dtype)}linspace(t,e,n){return l.backend_util.linspaceImpl(t,e,n)}scatter(t,e,n,r,i,s,a,o,u,c){const h=[r/i,i],d=this.readSync(t.dataId),p=this.readSync(e.dataId);if(0===r)return l.tensor([],n,e.dtype);const f=new l.TensorBuffer(h,e.dtype);f.values.fill(this.readSync(u.dataId)[0]);for(let t=0;t<s;t++){const s=[];let u=0;for(let e=0;e<a;e++){const n=d[t*a+e];s.push(n),u+=n*o[e]}if(u<0||u>=r/i)throw new Error(`Invalid indices: ${s} does not index into ${n}`);for(let n=0;n<i;n++)c?f.values[u*i+n]+=p[t*i+n]:f.values[u*i+n]=0===e.rank?p[0]:p[t*i+n]}return f.toTensor().reshape(n)}}
/** @license See the LICENSE file. */
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
Object(l.registerBackend)("cpu",()=>new Al,1);var Nl=n(17);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Il=Object(Nl.a)(l.Elu,t=>t>=0?t:Math.exp(t)-1),El={kernelName:l.Elu,backendName:"cpu",kernelFunc:Il};var jl=n(65),Ml=n(48);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const Dl=Object(Ml.a)((t,e)=>t<0?e*t:t);function Rl(t){const{inputs:e,backend:n}=t,{x:r,alpha:i}=e;Object(_l.a)([r,i],"prelu");const s=n.data.get(r.dataId).values,a=n.data.get(i.dataId).values,[o,u]=Dl(r.shape,i.shape,s,a,r.dtype);return n.makeTensorInfo(u,r.dtype,o)}const Pl={kernelName:l.Prelu,backendName:"cpu",kernelFunc:Rl},Fl=Object(Nl.a)(l.Relu,t=>Math.max(0,t)),zl={kernelName:l.Relu,backendName:"cpu",kernelFunc:Fl},Ll=Object(Nl.a)(l.Relu6,t=>Math.min(Math.max(0,t),6)),$l={kernelName:l.Relu6,backendName:"cpu",kernelFunc:Ll};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function Bl(t,e,n,r){if("linear"===n)return Object(jl.a)({inputs:{x:e},backend:t});if("relu"===n)return Fl({inputs:{x:e},backend:t});if("elu"===n)return Il({inputs:{x:e},backend:t});if("relu6"===n)return Ll({inputs:{x:e},backend:t});if("prelu"===n)return Rl({inputs:{x:e,alpha:r},backend:t});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}var ql=n(70);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function Vl(t){const{inputs:e,backend:n,attrs:r}=t,{x:i}=e,{shape:s}=r,a=l.util.sizeFromShape(i.shape),o=l.util.inferFromImplicitShape(s,a),u=l.util.sizeFromShape(o);l.util.assert(a===u,()=>`The new shape (${o}) has ${u} elements and the old shape (${i.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`),n.incRef(i.dataId);const c=n.data.get(i.dataId);if(null!=c.complexTensorInfos){const t=c.complexTensorInfos.real,e=c.complexTensorInfos.imag;t.shape=o,e.shape=o}return{dataId:i.dataId,shape:o,dtype:i.dtype}}const Ul={kernelName:l.Reshape,backendName:"cpu",kernelFunc:Vl};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function Wl(t){const{inputs:e,backend:n,attrs:r}=t,{a:i,b:s}=e,{transposeA:a,transposeB:o}=r;Object(_l.a)([i,s],"matMul");const u=i.shape.length,c=s.shape.length,h=a?i.shape[u-2]:i.shape[u-1],d=o?s.shape[c-1]:s.shape[c-2],p=a?i.shape[u-1]:i.shape[u-2],f=o?s.shape[c-2]:s.shape[c-1],m=i.shape.slice(0,-2),g=s.shape.slice(0,-2),b=l.util.sizeFromShape(m),y=l.util.sizeFromShape(g),v=b===y||1===b||1===y;l.util.assert(u>=2&&c>=2&&v,()=>`Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input batch dimensions of (${m}) and (${g}).`);const w=(b>y?i.shape.slice(0,-2):s.shape.slice(0,-2)).concat([p,f]);l.util.assert(h===d,()=>`Error in matMul: inner shapes (${h}) and (${d}) of Tensors with shapes ${i.shape} and ${s.shape} and transposeA=${a} and transposeB=${o} must match.`);const x=o?[y,f,d]:[y,d,f],_=Vl({inputs:{x:i},backend:n,attrs:{shape:a?[b,h,p]:[b,p,h]}}),O=Vl({inputs:{x:s},backend:n,attrs:{shape:x}}),S=a?_.shape[1]:_.shape[2],k=a?_.shape[2]:_.shape[1],T=o?O.shape[1]:O.shape[2],C=Math.max(b,y),A=n.data.get(_.dataId).values,N=n.data.get(O.dataId).values,I=l.util.computeStrides(_.shape),E=l.util.computeStrides(O.shape),[j,M,D]=a?[I[0],1,I[1]]:[I[0],I[1],1],[R,P,F]=o?[1,E[1],E[0]]:[E[1],1,E[0]],z=k*T,L=Object(l.buffer)([C,k,T],_.dtype),$=L.values,B=n.blockSize;for(let t=0;t<C;t++)for(let e=0;e<k;e+=B)for(let n=0;n<T;n+=B)for(let r=0;r<S;r+=B){const i=Math.min(e+B,k),s=Math.min(n+B,T),a=Math.min(r+B,S);for(let o=e;o<i;o++)for(let e=n;e<s;e++){let n=0;for(let i=r;i<a;i++){const r=Math.min(t,b-1)*j,s=Math.min(t,y-1)*F;n+=A[r+o*M+i*D]*N[i*R+e*P+s]}$[t*z+(o*T+e)]+=n}}return n.disposeIntermediateTensorInfo(_),n.disposeIntermediateTensorInfo(O),n.makeTensorInfo(w,L.dtype,L.values)}const Gl={kernelName:l.BatchMatMul,backendName:"cpu",kernelFunc:Wl};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Hl={kernelName:l._FusedMatMul,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{a:i,b:s,bias:a,preluActivationWeights:o}=e,{transposeA:u,transposeB:c,activation:l}=r;let h,d,p;const f=[];h=Wl({inputs:{a:i,b:s},attrs:{transposeA:u,transposeB:c},backend:n}),a&&(d=Object(ql.a)({inputs:{a:h,b:a},backend:n}),f.push(h),h=d),l&&(p=Bl(n,h,l,o),f.push(h),h=p);for(const t of f)n.disposeIntermediateTensorInfo(t);return h}};var Kl=n(193);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Ql=Object(Nl.a)(l.Acos,t=>Math.acos(t)),Xl={kernelName:l.Acos,backendName:"cpu",kernelFunc:Ql},Yl=Object(Nl.a)(l.Acosh,t=>Math.acosh(t)),Jl={kernelName:l.Acosh,backendName:"cpu",kernelFunc:Yl},Zl=Object(Nl.a)(l.Asin,t=>Math.asin(t)),th={kernelName:l.Asin,backendName:"cpu",kernelFunc:Zl},eh=Object(Nl.a)(l.Asinh,t=>Math.asinh(t)),nh={kernelName:l.Asinh,backendName:"cpu",kernelFunc:eh},rh=Object(Nl.a)(l.Atan,t=>Math.atan(t)),ih={kernelName:l.Atan,backendName:"cpu",kernelFunc:rh},sh=Object(Nl.a)(l.Atanh,t=>Math.atanh(t)),ah={kernelName:l.Atanh,backendName:"cpu",kernelFunc:sh};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function oh(t,e,n,r,i,s){const a=i.strideHeight,o=i.strideWidth,u=i.dilationHeight,c=i.dilationWidth,h=i.effectiveFilterHeight,d=i.effectiveFilterWidth,p=i.padInfo.top,f=i.padInfo.left,m="max"===s?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,g=Object(l.buffer)(i.outShape,n),b=g.values,y=i.outShape[1]*i.outShape[2]*i.outShape[3],v=i.outShape[2]*i.outShape[3],w=i.outShape[3];for(let e=0;e<i.batchSize;++e){const n=e*y,l=e*r[0];for(let e=0;e<i.inChannels;++e)for(let g=0;g<i.outHeight;++g){const y=g*a-p,x=Math.max(0,y),_=Math.min(i.inHeight,h+y),O=n+g*v;for(let n=0;n<i.outWidth;++n){const a=n*o-f,h=Math.max(0,a),p=Math.min(i.inWidth,d+a);let g=m,y=0,v=0;for(let n=x;n<_;n+=u){const i=l+n*r[1];for(let n=h;n<p;n+=c){const a=t[i+n*r[2]+e];"max"===s&&a>g?g=a:"avg"===s&&(y+=a,v++)}if(isNaN(g))break}b[O+n*w+e]="avg"===s?y/v:g}}}return g}function uh(t,e,n,r,i=!1,s=!1){const a=Object(l.buffer)(r.outShape,"int32"),o=r.strideHeight,u=r.strideWidth,c=r.dilationHeight,h=r.dilationWidth,d=r.effectiveFilterHeight,p=r.effectiveFilterWidth,f=r.padInfo.top,m=r.padInfo.left,g=Object(l.buffer)(e,n,t);for(let t=0;t<r.batchSize;++t)for(let e=0;e<r.inChannels;++e)for(let n=0;n<r.outHeight;++n){const l=n*o-f;let b=l;for(;b<0;)b+=c;const y=Math.min(r.inHeight,d+l);for(let o=0;o<r.outWidth;++o){const d=o*u-m;let f=d;for(;f<0;)f+=h;const v=Math.min(r.inWidth,p+d);let w=Number.NEGATIVE_INFINITY,x=-1;for(let n=b;n<y;n+=c){const a=n-l;for(let o=f;o<v;o+=h){const u=o-d,c=g.get(t,n,o,e);c>w&&(w=c,x=i?s?((t*r.inHeight+n)*r.inWidth+o)*r.inChannels+e:(n*r.inWidth+o)*r.inChannels+e:a*p+u)}}a.set(x,t,n,o,e)}}return a}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const ch={kernelName:l.AvgPool,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{x:i}=e;Object(_l.a)(i,"avgPool");const{filterSize:s,strides:a,pad:o,dimRoundingMode:u}=r;l.util.assert(l.backend_util.eitherStridesOrDilationsAreOne(a,1),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${a} and dilations '1'`);const c=l.backend_util.computePool2DInfo(i.shape,s,a,1,o,u);let h;if(1===c.filterWidth&&1===c.filterHeight&&l.util.arraysEqual(c.inShape,c.outShape))h=Object(jl.a)({inputs:{x:i},backend:n});else{const t=n.data.get(i.dataId).values,e=l.util.computeStrides(i.shape),r=oh(t,i.shape,i.dtype,e,c,"avg");h=n.makeTensorInfo(c.outShape,i.dtype,r.values)}return h}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const lh={kernelName:l.AvgPoolBackprop,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{dy:i,input:s}=e,a=s;Object(_l.a)([i,s],"avgPoolBackprop");const{filterSize:o,strides:u,pad:c}=r,h=l.backend_util.computePool2DInfo(a.shape,o,u,1,c),d=h.strideHeight,p=h.strideWidth,f=h.filterHeight,m=h.filterWidth,g=h.dilationHeight,b=h.dilationWidth,y=h.effectiveFilterHeight,v=h.effectiveFilterWidth,w=v-1-h.padInfo.left,x=y-1-h.padInfo.top,_=Object(l.buffer)(a.shape,"float32"),O=1/(f*m),S=n.data.get(i.dataId).values,k=Object(l.buffer)(i.shape,"float32",S);for(let t=0;t<h.batchSize;++t)for(let e=0;e<h.inChannels;++e)for(let n=0;n<h.inHeight;++n)for(let r=0;r<h.inWidth;++r){const i=n-x,s=r-w;let a=0;for(let n=0;n<y;n+=g){const r=(i+n)/d;if(!(r<0||r>=h.outHeight||Math.floor(r)!==r))for(let n=0;n<v;n+=b){const i=(s+n)/p;if(i<0||i>=h.outWidth||Math.floor(i)!==i)continue;a+=k.get(t,r,i,e)}}_.set(a*O,t,n,r,e)}return n.makeTensorInfo(_.shape,_.dtype,_.values)}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const hh={kernelName:l.FusedBatchNorm,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{x:i,scale:s,offset:a,mean:o,variance:u}=e;l.util.assert(o.shape.length===u.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),l.util.assert(null==a||o.shape.length===a.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),l.util.assert(null==s||o.shape.length===s.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks."),Object(_l.a)([i,o,u,s,a],"batchNorm");let{varianceEpsilon:c}=r;null==c&&(c=.001);const h=n.data.get(i.dataId).values,d=n.data.get(o.dataId).values,p=n.data.get(u.dataId).values,f=s?n.data.get(s.dataId).values:new Float32Array([1]),m=a?n.data.get(a.dataId).values:new Float32Array([0]),g=new Float32Array(h.length),b=m.length,y=f.length,v=p.length,w=d.length;let x=0,_=0,O=0,S=0;for(let t=0;t<h.length;++t)g[t]=m[x++]+(h[t]-d[_++])*f[O++]/Math.sqrt(p[S++]+c),x>=b&&(x=0),_>=w&&(_=0),O>=y&&(O=0),S>=v&&(S=0);return n.makeTensorInfo(i.shape,i.dtype,g)}};var dh=n(153),ph=n(194);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const fh=Object(Nl.a)(l.ClipByValue,(t,e)=>{const n=e;return t>n.clipValueMax?n.clipValueMax:t<n.clipValueMin?n.clipValueMin:t}),mh={kernelName:l.ClipByValue,backendName:"cpu",kernelFunc:fh};var gh=n(50);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function bh(t){const{inputs:e,backend:n}=t,{input:r}=e,i=n.data.get(r.dataId).complexTensorInfos.imag,s=n.data.get(i.dataId).values;return n.makeTensorInfo(i.shape,i.dtype,s)}const yh={kernelName:l.Imag,backendName:"cpu",kernelFunc:bh};var vh=n(95);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function wh(t){const{inputs:e,backend:n,attrs:r}=t,{axis:i}=r,s=l.util.parseAxisParam(i,e[0].shape)[0];let a=l.backend_util.computeOutShape(e.map(t=>t.shape),s);if(0===l.util.sizeFromShape(a))return n.makeTensorInfo(a,e[0].dtype,[]);const o=e.filter(t=>l.util.sizeFromShape(t.shape)>0);if(1===o.length)return o[0];const u=o.map(t=>t.shape);if(l.backend_util.assertParamsConsistent(u,s),"complex64"===o[0].dtype){const t=o.map(t=>Object(vh.a)({inputs:{input:t},backend:n})),e=o.map(t=>bh({inputs:{input:t},backend:n})),r=wh({inputs:t,backend:n,attrs:{axis:s}}),i=wh({inputs:e,backend:n,attrs:{axis:s}}),a=Object(gh.a)({inputs:{real:r,imag:i},backend:n});return t.forEach(t=>n.disposeIntermediateTensorInfo(t)),e.forEach(t=>n.disposeIntermediateTensorInfo(t)),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(i),a}const c=o.map(t=>{const e=l.util.sizeFromShape(t.shape.slice(s));return Vl({inputs:{x:t},backend:n,attrs:{shape:[-1,e]}})});a=l.backend_util.computeOutShape(c.map(t=>t.shape),1);const h=l.util.getTypedArrayFromDType(o[0].dtype,l.util.sizeFromShape(a));if(1===c[0].shape[0]){let t=0;c.forEach(e=>{const r=n.data.get(e.dataId).values,i=l.util.sizeFromShape(e.shape);h.set(r,t),t+=i})}else{let t=0;c.forEach(e=>{const r=n.data.get(e.dataId).values;let i=0;for(let n=0;n<e.shape[0];++n){const s=n*a[1]+t;for(let t=0;t<e.shape[1];++t)h[s+t]=r[i++]}t+=e.shape[1]})}const d=l.backend_util.computeOutShape(o.map(t=>t.shape),s),p=n.makeTensorInfo(d,e[0].dtype,h);return c.forEach(t=>n.disposeIntermediateTensorInfo(t)),p}const xh={kernelName:l.Concat,backendName:"cpu",kernelFunc:wh};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function _h(t){const{inputs:e,backend:n,attrs:r}=t,{x:i,filter:s}=e,{strides:a,pad:o,dataFormat:u,dilations:c,dimRoundingMode:h}=r;Object(_l.a)([i,s],"conv2d");const d=l.backend_util.convertConv2DDataFormat(u),p=l.backend_util.computeConv2DInfo(i.shape,s.shape,a,c,o,h,!1,d),f=p.filterHeight,m=p.filterWidth,g=p.dilationHeight,b=p.dilationWidth,y=p.padInfo.left,v=p.padInfo.top,w="channelsLast"===p.dataFormat,x=new l.TensorBuffer(p.outShape,i.dtype),_=l.util.computeStrides(i.shape),O=l.util.computeStrides(s.shape),S=_[0],k=w?_[1]:_[2],T=w?_[2]:1,C=w?1:_[1],A=x.strides[0],N=w?x.strides[1]:x.strides[2],I=w?x.strides[2]:1,E=w?1:x.strides[1],j=n.data.get(i.dataId).values,M=n.data.get(s.dataId).values,D=x.values;for(let t=0;t<p.batchSize;++t){const e=t*S,n=t*A;for(let t=0;t<p.outHeight;++t){const r=n+t*N,i=t*p.strideHeight-v;for(let t=0;t<f;++t){const n=i+t*g;if(n<0||n>=p.inHeight)continue;const s=t*O[0],a=e+n*k;for(let t=0;t<p.outWidth;++t){const e=r+t*I,n=t*p.strideWidth-y;for(let t=0;t<m;++t){const r=n+t*b;if(r<0||r>=p.inWidth)continue;const i=a+r*T;let o=s+t*O[1];for(let t=0;t<p.inChannels;++t){const n=j[i+t*C];for(let t=0;t<p.outChannels;++t)D[e+t*E]+=n*M[o+t];o+=p.outChannels}}}}}}return n.makeTensorInfo(x.shape,x.dtype,D)}const Oh={kernelName:l.Conv2D,backendName:"cpu",kernelFunc:_h};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Sh={kernelName:l.Conv2DBackpropFilter,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{x:i,dy:s}=e,{strides:a,pad:o,dataFormat:u,dimRoundingMode:c,filterShape:h}=r;Object(_l.a)([i,s],"conv2dBackpropFilter");const d=l.backend_util.convertConv2DDataFormat(u),p=l.backend_util.computeConv2DInfo(i.shape,h,a,1,o,c,!1,d),{strideHeight:f,strideWidth:m,filterHeight:g,filterWidth:b}=p,y="channelsLast"===p.dataFormat,v=new l.TensorBuffer(p.filterShape,"float32"),w=p.padInfo.left,x=p.padInfo.top,_=n.data.get(i.dataId).values,O=n.data.get(s.dataId).values,S=new l.TensorBuffer(i.shape,i.dtype,_),k=new l.TensorBuffer(s.shape,s.dtype,O);for(let t=0;t<g;++t){const e=Math.max(0,Math.ceil((x-t)/f)),n=Math.min(p.outHeight,(p.inHeight+x-t)/f);for(let r=0;r<b;++r){const i=Math.max(0,Math.ceil((w-r)/m)),s=Math.min(p.outWidth,(p.inWidth+w-r)/m);for(let a=0;a<p.inChannels;++a)for(let o=0;o<p.outChannels;++o){let u=0;for(let c=0;c<p.batchSize;++c)for(let l=e;l<n;++l){const e=t+l*f-x;for(let t=i;t<s;++t){const n=r+t*m-w;u+=y?S.get(c,e,n,a)*k.get(c,l,t,o):S.get(c,a,e,n)*k.get(c,o,l,t)}}v.set(u,t,r,a,o)}}}return n.makeTensorInfo(v.shape,v.dtype,v.values)}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const kh={kernelName:l.Conv2DBackpropInput,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{dy:i,filter:s}=e,{inputShape:a,strides:o,pad:u,dataFormat:c,dimRoundingMode:h}=r;Object(_l.a)([i,s],"conv2dBackpropInput");const d=l.util.computeStrides(s.shape),p=l.util.computeStrides(i.shape);let f=l.backend_util.convertConv2DDataFormat(c);const m=l.backend_util.computeConv2DInfo(a,s.shape,o,1,u,h,!1,f),g=new l.TensorBuffer(m.inShape,"float32"),b=g.values,y=n.data.get(i.dataId).values,v=n.data.get(s.dataId).values,[w,x,_]=d,{batchSize:O,filterHeight:S,filterWidth:k,inChannels:T,inHeight:C,inWidth:A,outChannels:N,outHeight:I,outWidth:E,strideHeight:j,strideWidth:M}=m;f=m.dataFormat;const D=S-1-m.padInfo.top,R=k-1-m.padInfo.left,P="channelsLast"===f,F=g.strides[0],z=P?g.strides[1]:g.strides[2],L=P?g.strides[2]:1,$=P?1:g.strides[1],B=p[0],q=P?p[1]:p[2],V=P?p[2]:1,U=P?1:p[1];for(let t=0;t<O;++t)for(let e=0;e<T;++e)for(let n=0;n<C;++n){const r=n-D,i=Math.max(0,Math.ceil(r/j)),s=Math.min(I,(S+r)/j);for(let a=0;a<A;++a){const o=a-R,u=Math.max(0,Math.ceil(o/M)),c=Math.min(E,(k+o)/M);let l=0;for(let n=i;n<s;++n){const i=n*j-r;for(let r=u;r<c;++r){const s=B*t+q*n+V*r,a=w*(S-1-i)+x*(k-1-(r*M-o))+_*e;for(let t=0;t<N;++t){l+=y[s+U*t]*v[a+t]}}}b[F*t+z*n+L*a+$*e]=l}}return n.makeTensorInfo(g.shape,g.dtype,g.values)}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Th={kernelName:l.Conv3D,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{x:i,filter:s}=e,{strides:a,pad:o,dilations:u}=r;Object(_l.a)([i,s],"conv3d");const c=l.backend_util.computeConv3DInfo(i.shape,s.shape,a,u,o),{filterDepth:h,filterHeight:d,filterWidth:p,dilationDepth:f,dilationHeight:m,dilationWidth:g,padInfo:b}=c,y=b.front,v=b.left,w=b.top,x=new l.TensorBuffer(c.outShape,i.dtype),_=n.data.get(i.dataId).values,O=n.data.get(s.dataId).values,S=x.values,k=l.util.computeStrides(i.shape),T=l.util.computeStrides(s.shape);for(let t=0;t<c.batchSize;++t){const e=t*k[0],n=t*x.strides[0];for(let t=0;t<c.outDepth;++t){const r=n+t*x.strides[1],i=t*c.strideDepth-y;for(let t=0;t<h;++t){const n=i+t*f;if(n<0||n>=c.inDepth)continue;const s=t*T[0],a=e+n*k[1];for(let t=0;t<c.outHeight;++t){const e=r+t*x.strides[2],n=t*c.strideHeight-w;for(let t=0;t<d;++t){const r=n+t*m;if(r<0||r>=c.inHeight)continue;const i=s+t*T[1],o=a+r*k[2];for(let t=0;t<c.outWidth;++t){const n=e+t*c.outChannels,r=t*c.strideWidth-v;for(let t=0;t<p;++t){const e=r+t*g;if(e<0||e>=c.inWidth)continue;const s=i+t*T[2],a=o+e*c.inChannels;let u=s;for(let t=0;t<c.inChannels;++t){const e=_[a+t];for(let t=0;t<c.outChannels;++t)S[n+t]+=e*O[u+t];u+=c.outChannels}}}}}}}}return n.makeTensorInfo(x.shape,x.dtype,x.values)}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Ch={kernelName:l.Conv3DBackpropFilterV2,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{x:i,dy:s}=e,{strides:a,pad:o,filterShape:u}=r;Object(_l.a)([i,s],"conv3dBackpropFilterV2");const c=l.util.computeStrides(i.shape),h=l.util.computeStrides(s.shape),d=l.backend_util.computeConv3DInfo(i.shape,u,a,1,o),p=d.strideDepth,f=d.strideHeight,m=d.strideWidth,g=d.filterDepth,b=d.filterHeight,y=d.filterWidth,v=new l.TensorBuffer(d.filterShape,"float32"),w=v.values,[x,_,O,S]=v.strides,k=n.data.get(s.dataId).values,[T,C,A,N]=h,I=n.data.get(i.dataId).values,[E,j,M,D]=c,R=d.padInfo.front,P=d.padInfo.left,F=d.padInfo.top;for(let t=0;t<g;++t){const e=Math.max(0,Math.ceil((R-t)/p)),n=Math.min(d.outDepth,(d.inDepth+R-t)/p),r=t*x;for(let i=0;i<b;++i){const s=Math.max(0,Math.ceil((F-i)/f)),a=Math.min(d.outHeight,(d.inHeight+F-i)/f),o=i*_+r;for(let r=0;r<y;++r){const u=Math.max(0,Math.ceil((P-r)/m)),c=Math.min(d.outWidth,(d.inWidth+P-r)/m),l=r*O+o;for(let o=0;o<d.inChannels;++o){const h=o*S+l;for(let l=0;l<d.outChannels;++l){let g=0;for(let h=0;h<d.batchSize;++h){const d=h*E,b=h*T;for(let h=e;h<n;++h){const e=(t+h*p-R)*j+d,n=h*C+b;for(let t=s;t<a;++t){const s=(i+t*f-F)*M+e,a=t*A+n;for(let t=u;t<c;++t){const e=t*N+a;g+=I[(r+t*m-P)*D+s+o]*k[e+l]}}}}w[h+l]=g}}}}}return n.makeTensorInfo(v.shape,v.dtype,v.values)}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Ah={kernelName:l.Conv3DBackpropInputV2,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{dy:i,filter:s}=e,{pad:a,strides:o,inputShape:u}=r;Object(_l.a)([i],"conv3dBackpropInputV2");const c=l.util.computeStrides(i.shape),h=l.util.computeStrides(s.shape),d=l.backend_util.computeConv3DInfo(u,s.shape,o,1,a),p=new l.TensorBuffer(d.inShape,"float32"),f=p.values,[m,g,b,y]=p.strides,v=n.data.get(i.dataId).values,[w,x,_,O]=c,S=n.data.get(s.dataId).values,[k,T,C,A]=h,{batchSize:N,filterDepth:I,filterHeight:E,filterWidth:j,inChannels:M,inDepth:D,inHeight:R,inWidth:P,outChannels:F,outDepth:z,outHeight:L,outWidth:$,strideDepth:B,strideHeight:q,strideWidth:V}=d,U=I-1-d.padInfo.front,W=E-1-d.padInfo.top,G=j-1-d.padInfo.left;for(let t=0;t<N;++t)for(let e=0;e<M;++e)for(let n=0;n<D;++n){const r=n-U,i=Math.max(0,Math.ceil(r/B)),s=Math.min(z,(I+r)/B);for(let a=0;a<R;++a){const o=a-W,u=Math.max(0,Math.ceil(o/q)),c=Math.min(L,(E+o)/q);for(let l=0;l<P;++l){const h=l-G,d=Math.max(0,Math.ceil(h/V)),p=Math.min($,(j+h)/V);let N=0;for(let n=i;n<s;++n){const i=n*B-r;for(let r=u;r<c;++r){const s=r*q-o;for(let a=d;a<p;++a){const o=w*t+x*n+_*r+O*a,u=k*(I-1-i)+T*(E-1-s)+C*(j-1-(a*V-h))+A*e;for(let t=0;t<F;++t){N+=v[o+t]*S[u+t]}}}}f[m*t+g*n+b*a+y*l+e]=N}}}return n.makeTensorInfo(p.shape,p.dtype,p.values)}},Nh=Object(Nl.a)(l.Cos,t=>Math.cos(t)),Ih={kernelName:l.Cos,backendName:"cpu",kernelFunc:Nh},Eh=Object(Nl.a)(l.Cosh,t=>Math.cosh(t)),jh={kernelName:l.Cosh,backendName:"cpu",kernelFunc:Eh};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function Mh(t){const{inputs:e,backend:n,attrs:r}=t,{x:i,filter:s}=e,{strides:a,pad:o,dilations:u,dimRoundingMode:c}=r;Object(_l.a)([i,s],"depthwiseConv2DNative");const h=l.util.computeStrides(i.shape),d=l.util.computeStrides(s.shape);let p=u;null==p&&(p=[1,1]),l.util.assert(l.backend_util.eitherStridesOrDilationsAreOne(a,p),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${p}'`);const f=l.backend_util.computeConv2DInfo(i.shape,s.shape,a,p,o,c,!0),{filterHeight:m,filterWidth:g,dilationHeight:b,dilationWidth:y,padInfo:v}=f,w=v.left,x=v.top,_=f.outChannels/f.inChannels,O=new l.TensorBuffer(f.outShape,i.dtype),S=n.data.get(i.dataId).values,k=n.data.get(s.dataId).values,T=O.values;for(let t=0;t<f.batchSize;++t){const e=t*h[0],n=t*O.strides[0];for(let t=0;t<f.outHeight;++t){const r=n+t*O.strides[1],i=t*f.strideHeight-w;for(let t=0;t<m;++t){const n=i+t*b;if(n<0||n>=f.inHeight)continue;const s=t*d[0],a=e+n*h[1];for(let t=0;t<f.outWidth;++t){const e=r+t*O.strides[2],n=t*f.strideWidth-x;for(let t=0;t<g;++t){const r=n+t*y;if(r<0||r>=f.inWidth)continue;const i=s+t*d[1],o=a+r*f.inChannels;let u=e,c=i;for(let t=0;t<f.inChannels;++t){const e=S[o+t];for(let t=0;t<_;++t)T[u+t]+=e*k[c+t];u+=_,c+=_}}}}}}return n.makeTensorInfo(O.shape,O.dtype,O.values)}const Dh={kernelName:l.DepthwiseConv2dNative,backendName:"cpu",kernelFunc:Mh};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Rh={kernelName:l.DepthwiseConv2dNativeBackpropFilter,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{x:i,dy:s}=e,{strides:a,dilations:o,pad:u,dimRoundingMode:c,filterShape:h}=r;Object(_l.a)([i,s],"depthwiseConv2dNativeBackpropFilter");const d=l.backend_util.computeConv2DInfo(i.shape,h,a,o,u,c,!0),{strideHeight:p,strideWidth:f,filterHeight:m,filterWidth:g}=d,b=new l.TensorBuffer(d.filterShape,"float32"),y=d.padInfo.left,v=d.padInfo.top,w=d.outChannels/d.inChannels,x=n.data.get(i.dataId).values,_=new l.TensorBuffer(i.shape,i.dtype,x),O=n.data.get(s.dataId).values,S=new l.TensorBuffer(s.shape,s.dtype,O);for(let t=0;t<m;++t){const e=Math.max(0,Math.ceil((v-t)/p)),n=Math.min(d.outHeight,(d.inHeight+v-t)/p);for(let r=0;r<g;++r){const i=Math.max(0,Math.ceil((y-r)/f)),s=Math.min(d.outWidth,(d.inWidth+y-r)/f);for(let a=0;a<d.outChannels;++a){const o=Math.trunc(a/w),u=a%w;let c=0;for(let u=0;u<d.batchSize;++u)for(let l=e;l<n;++l){const e=t+l*p-v;for(let t=i;t<s;++t){const n=r+t*f-y;c+=_.get(u,e,n,o)*S.get(u,l,t,a)}}b.set(c,t,r,o,u)}}}return n.makeTensorInfo(b.shape,b.dtype,b.values)}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Ph={kernelName:l.DepthwiseConv2dNativeBackpropInput,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{dy:i,filter:s}=e,{strides:a,dilations:o,pad:u,dimRoundingMode:c,inputShape:h}=r;Object(_l.a)([i,s],"depthwiseConv2DNativeBackpropInput");const d=l.util.computeStrides(i.shape),p=l.util.computeStrides(s.shape),f=l.backend_util.computeConv2DInfo(h,s.shape,a,o,u,c,!0),m=new l.TensorBuffer(f.inShape,"float32"),g=m.values,[b,y,v]=m.strides,w=n.data.get(i.dataId).values,[x,_,O]=d,S=n.data.get(s.dataId).values,[k,T,C]=p,{batchSize:A,filterHeight:N,filterWidth:I,inChannels:E,inHeight:j,inWidth:M,outChannels:D,outHeight:R,outWidth:P,strideHeight:F,strideWidth:z}=f,L=N-1-f.padInfo.top,$=I-1-f.padInfo.left,B=D/E;for(let t=0;t<A;++t)for(let e=0;e<E;++e)for(let n=0;n<j;++n){const r=n-L,i=Math.max(0,Math.ceil(r/F)),s=Math.min(R,(N+r)/F);for(let a=0;a<M;++a){const o=a-$,u=Math.max(0,Math.ceil(o/z)),c=Math.min(P,(I+o)/z);let l=0;for(let n=i;n<s;++n){const i=n*F-r;for(let r=u;r<c;++r){const s=x*t+_*n+O*r,a=k*(N-1-i)+T*(I-1-(r*z-o))+C*e;for(let t=0;t<B;++t){l+=w[s+(e*B+t)]*S[a+t]}}}g[b*t+y*n+v*a+e]=l}}return n.makeTensorInfo(m.shape,m.dtype,m.values)}},Fh={kernelName:l.Dilation2D,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:r,filter:i}=t,{strides:s,pad:a,dilations:o}=n,u=e,c=u.data.get(r.dataId).values,h=r.shape.length,d=u.data.get(i.dataId).values,p=i.shape.length,{batchSize:f,inHeight:m,inWidth:g,inChannels:b,outHeight:y,outWidth:v,padInfo:w,strideHeight:x,strideWidth:_,filterHeight:O,filterWidth:S,dilationHeight:k,dilationWidth:T,outShape:C}=l.backend_util.computeDilation2DInfo(r.shape,i.shape,s,a,"NHWC",o),A=l.util.sizeFromShape(C),N=C.length,I=l.util.getArrayFromDType(r.dtype,A);for(let t=0;t<f;++t)for(let e=0;e<y;++e){const n=e*x-w.top;for(let s=0;s<v;++s){const a=s*_-w.left;for(let o=0;o<b;++o){let u=Number.MIN_SAFE_INTEGER;for(let e=0;e<O;++e){const s=n+e*k;if(s>=0&&s<m)for(let n=0;n<S;++n){const f=a+n*T;if(f>=0&&f<g){const a=l.util.locToIndex([t,s,f,o],h,l.util.computeStrides(r.shape)),m=l.util.locToIndex([e,n,o],p,l.util.computeStrides(i.shape)),g=c[a]+d[m];g>u&&(u=g)}}}I[l.util.locToIndex([t,e,s,o],N,l.util.computeStrides(C))]=u}}}return{dataId:u.write(l.util.toTypedArray(I,r.dtype),C,r.dtype),shape:C,dtype:r.dtype}}},zh={kernelName:l.Dilation2DBackpropFilter,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:r,filter:i,dy:s}=t,{strides:a,pad:o,dilations:u}=n,c=e,h=l.util.toNestedArray(r.shape,c.data.get(r.dataId).values),d=l.util.toNestedArray(i.shape,c.data.get(i.dataId).values),{batchSize:p,inHeight:f,inWidth:m,inChannels:g,outHeight:b,outWidth:y,padInfo:v,strideHeight:w,strideWidth:x,filterHeight:_,filterWidth:O,dilationHeight:S,dilationWidth:k,outShape:T}=l.backend_util.computeDilation2DInfo(r.shape,i.shape,a,o,"NHWC",u);l.util.assert(s.rank===T.length,()=>`Error in ${l.Dilation2DBackpropFilter}, dy must have the same rank as output ${T.length}, but got `+s.rank);const C=l.util.toNestedArray(T,c.data.get(s.dataId).values),A=l.util.makeZerosNestedTypedArray(i.shape,i.dtype);for(let t=0;t<p;++t)for(let e=0;e<b;++e){const n=e*w-v.top;for(let r=0;r<y;++r){const i=r*x-v.left;for(let s=0;s<g;++s){let a=Number.MIN_SAFE_INTEGER,o=0,u=0;for(let e=0;e<_;++e){const r=n+e*S;if(r>=0&&r<f)for(let n=0;n<O;++n){const c=i+n*k;if(c>=0&&c<m){const i=h[t][r][c][s]+d[e][n][s];i>a&&(a=i,o=e,u=n)}}}A[o][u][s]+=C[t][e][r][s]}}}return{dataId:c.write(l.util.toTypedArray(A,r.dtype),i.shape,i.dtype),shape:i.shape,dtype:i.dtype}}},Lh={kernelName:l.Dilation2DBackpropInput,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:r,filter:i,dy:s}=t,{strides:a,pad:o,dilations:u}=n,c=e,h=l.util.toNestedArray(r.shape,c.data.get(r.dataId).values),d=l.util.toNestedArray(i.shape,c.data.get(i.dataId).values),{batchSize:p,inHeight:f,inWidth:m,inChannels:g,outHeight:b,outWidth:y,padInfo:v,strideHeight:w,strideWidth:x,filterHeight:_,filterWidth:O,dilationHeight:S,dilationWidth:k,outShape:T}=l.backend_util.computeDilation2DInfo(r.shape,i.shape,a,o,"NHWC",u);l.util.assert(s.rank===T.length,()=>`Error in ${l.Dilation2DBackpropInput}, dy must have the same rank as output ${T.length}, but got `+s.rank);const C=l.util.toNestedArray(T,c.data.get(s.dataId).values),A=l.util.makeZerosNestedTypedArray(r.shape,r.dtype);for(let t=0;t<p;++t)for(let e=0;e<b;++e){const n=e*w-v.top;for(let r=0;r<y;++r){const i=r*x-v.left;for(let s=0;s<g;++s){let a=Number.MIN_SAFE_INTEGER,o=n<0?0:n,u=i<0?0:i;for(let e=0;e<_;++e){const r=n+e*S;if(r>=0&&r<f)for(let n=0;n<O;++n){const c=i+n*k;if(c>=0&&c<m){const i=h[t][r][c][s]+d[e][n][s];i>a&&(a=i,o=r,u=c)}}}A[t][o][u][s]+=C[t][e][r][s]}}}return{dataId:c.write(l.util.toTypedArray(A,r.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var $h=n(53);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Bh=Object(Ml.a)((t,e)=>t/e),qh=Object($h.a)(l.Div,Bh),Vh={kernelName:l.Div,backendName:"cpu",kernelFunc:qh},Uh=l.backend_util.ERF_P,Wh=l.backend_util.ERF_A1,Gh=l.backend_util.ERF_A2,Hh=l.backend_util.ERF_A3,Kh=l.backend_util.ERF_A4,Qh=l.backend_util.ERF_A5,Xh=Object(Nl.a)(l.Erf,t=>{const e=Math.sign(t),n=Math.abs(t),r=1/(1+Uh*n);return e*(1-((((Qh*r+Kh)*r+Hh)*r+Gh)*r+Wh)*r*Math.exp(-n*n))}),Yh={kernelName:l.Erf,backendName:"cpu",kernelFunc:Xh};var Jh=n(195),Zh=n(196),td=n(139),ed=n(117),nd=n(140);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function rd(t,e,n){const r=t.shape,i=r[0],s=r[1],a=n.data.get(t.dataId),o=a.complexTensorInfos.real,u=a.complexTensorInfos.imag,c=[i,s],h=l.util.sizeFromShape(c),d=l.util.getTypedArrayFromDType("float32",h),p=l.util.getTypedArrayFromDType("float32",h);for(let t=0;t<i;t++){const r=Object(ed.a)({inputs:{x:o},backend:n,attrs:{begin:[t,0],size:[1,s]}}),i=Object(ed.a)({inputs:{x:u},backend:n,attrs:{begin:[t,0],size:[1,s]}}),a=Object(gh.a)({inputs:{real:r,imag:i},backend:n}),{real:c,imag:h}=id(a,e,n),f=l.backend_util.mergeRealAndImagArrays(c,h);for(let e=0;e<s;e++){const n=l.backend_util.getComplexWithIndex(f,e);d[t*s+e]=n.real,p[t*s+e]=n.imag}n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(a)}const f=n.makeTensorInfo(c,"float32",d),m=n.makeTensorInfo(c,"float32",p),g=Object(gh.a)({inputs:{real:f,imag:m},backend:n});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}function id(t,e,n){const r=l.util.sizeFromShape(t.shape),i=n.data.get(t.dataId),s=n.data.get(i.complexTensorInfos.real.dataId).values,a=n.data.get(i.complexTensorInfos.imag.dataId).values;if(0==((o=r)&o-1)){const i=function t(e,n,r,i,s){if(1===r)return{real:e,imag:n};const a=l.backend_util.mergeRealAndImagArrays(e,n),o=r/2,u=l.backend_util.complexWithEvenIndex(a),c=u.real,h=u.imag,d=[c.length],p=s.makeTensorInfo(d,"float32",c),f=s.makeTensorInfo(d,"float32",h),m=Object(gh.a)({inputs:{real:p,imag:f},backend:s}),g=l.backend_util.complexWithOddIndex(a),b=g.real,y=g.imag,v=[b.length],w=s.makeTensorInfo(v,"float32",b),x=s.makeTensorInfo(v,"float32",y),_=Object(gh.a)({inputs:{real:w,imag:x},backend:s}),O=t(c,h,o,i,s),S=O.real,k=O.imag,T=[S.length],C=s.makeTensorInfo(T,"float32",S),A=s.makeTensorInfo(T,"float32",k),N=Object(gh.a)({inputs:{real:C,imag:A},backend:s}),I=t(b,y,o,i,s),E=I.real,j=I.imag,M=[E.length],D=s.makeTensorInfo(M,"float32",E),R=s.makeTensorInfo(M,"float32",j),P=Object(gh.a)({inputs:{real:D,imag:R},backend:s}),F=l.backend_util.exponents(r,i),z=[F.real.length],L=s.makeTensorInfo(z,"float32",F.real),$=s.makeTensorInfo(z,"float32",F.imag),B=Object(gh.a)({inputs:{real:L,imag:$},backend:s}),q=Object(td.a)({inputs:{a:B,b:P},backend:s}),V=Object(ql.a)({inputs:{a:N,b:q},backend:s}),U=Object(nd.a)({inputs:{a:N,b:q},backend:s}),W=Object(vh.a)({inputs:{input:V},backend:s}),G=Object(vh.a)({inputs:{input:U},backend:s}),H=bh({inputs:{input:V},backend:s}),K=bh({inputs:{input:U},backend:s}),Q=wh({inputs:[W,G],backend:s,attrs:{axis:0}}),X=wh({inputs:[H,K],backend:s,attrs:{axis:0}}),Y=s.data.get(Q.dataId).values,J=s.data.get(X.dataId).values;return s.disposeIntermediateTensorInfo(p),s.disposeIntermediateTensorInfo(f),s.disposeIntermediateTensorInfo(m),s.disposeIntermediateTensorInfo(w),s.disposeIntermediateTensorInfo(x),s.disposeIntermediateTensorInfo(_),s.disposeIntermediateTensorInfo(C),s.disposeIntermediateTensorInfo(A),s.disposeIntermediateTensorInfo(N),s.disposeIntermediateTensorInfo(D),s.disposeIntermediateTensorInfo(R),s.disposeIntermediateTensorInfo(P),s.disposeIntermediateTensorInfo(L),s.disposeIntermediateTensorInfo($),s.disposeIntermediateTensorInfo(B),s.disposeIntermediateTensorInfo(q),s.disposeIntermediateTensorInfo(V),s.disposeIntermediateTensorInfo(U),s.disposeIntermediateTensorInfo(W),s.disposeIntermediateTensorInfo(H),s.disposeIntermediateTensorInfo(G),s.disposeIntermediateTensorInfo(K),s.disposeIntermediateTensorInfo(Q),s.disposeIntermediateTensorInfo(X),{real:Y,imag:J}}(s,a,r,e,n),o=[t.shape[0],t.shape[1]];if(e){const t=n.makeTensorInfo(o,"float32",i.real),e=n.makeTensorInfo(o,"float32",i.imag),s=n.makeTensorInfo([],"float32",l.util.createScalarValue(r,"float32")),a=Object(jl.a)({inputs:{x:s},backend:n}),u=Vh.kernelFunc({inputs:{a:t,b:s},backend:n}),c=Vh.kernelFunc({inputs:{a:e,b:a},backend:n}),h=n.data.get(u.dataId).values,d=n.data.get(c.dataId).values;return n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(c),{real:h,imag:d}}return i}{const t=function(t,e,n){const r=new Float32Array(2*e);for(let i=0;i<e;i++){let s=0,a=0;for(let r=0;r<e;r++){const o=l.backend_util.exponent(i*r,e,n),u=l.backend_util.getComplexWithIndex(t,r);s+=u.real*o.real-u.imag*o.imag,a+=u.real*o.imag+u.imag*o.real}n&&(s/=e,a/=e),l.backend_util.assignToTypedArray(r,s,a,i)}return r}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */(l.backend_util.mergeRealAndImagArrays(s,a),r,e);return l.backend_util.splitRealAndImagArrays(t)}var o}const sd={kernelName:l.FFT,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n}=t,{input:r}=e,i=l.util.sizeFromShape(r.shape),s=r.shape[r.shape.length-1],a=Vl({inputs:{x:r},backend:n,attrs:{shape:[i/s,s]}}),o=rd(a,!1,n),u=Vl({inputs:{x:o},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),u}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const ad={kernelName:l.Fill,backendName:"cpu",kernelFunc:function(t){const{backend:e,attrs:n}=t,{shape:r,value:i,dtype:s}=n,a=s||l.util.inferDtype(i),o=l.util.getArrayFromDType(a,l.util.sizeFromShape(r));return function(t,e,n){t.fill(e)}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */(o,i),e.makeTensorInfo(r,a,o)}};const od={kernelName:l.FlipLeftRight,backendName:"cpu",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{image:r}=t,i=n,s=l.util.getTypedArrayFromDType(r.dtype,l.util.sizeFromShape(r.shape)),[a,o,u,c]=r.shape,h=i.data.get(r.dataId).values;for(let t=0;t<a;t++){const e=t*u*o*c;for(let t=0;t<o;t++){const n=t*(u*c);for(let r=0;r<u;r++){const i=r*c;for(let o=0;o<c;o++){const l=[a,t,r,o][2],d=Math.round(u-l),p=e+n+i+o;let f=h[p];if(d>=0&&d<u){f=h[e+n+d*c+o]}s[p]=f}}}}return{dataId:i.write(s,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}};var ud=n(197);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const cd={kernelName:l.FusedConv2D,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{x:i,filter:s,bias:a,preluActivationWeights:o}=e,{strides:u,pad:c,dataFormat:l,dilations:h,dimRoundingMode:d,activation:p}=r;let f=_h({inputs:{x:i,filter:s},backend:n,attrs:{strides:u,pad:c,dataFormat:l,dilations:h,dimRoundingMode:d}});if(a){const t=f;f=Object(ql.a)({inputs:{a:f,b:a},backend:n}),n.disposeIntermediateTensorInfo(t)}if(p){const t=f;f=Bl(n,f,p,o),n.disposeIntermediateTensorInfo(t)}return f}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const ld={kernelName:l.FusedDepthwiseConv2D,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{x:i,filter:s,bias:a,preluActivationWeights:o}=e,{strides:u,pad:c,dataFormat:l,dilations:h,dimRoundingMode:d,activation:p}=r;let f=Mh({inputs:{x:i,filter:s},backend:n,attrs:{strides:u,pad:c,dataFormat:l,dilations:h,dimRoundingMode:d}});if(a){const t=f;f=Object(ql.a)({inputs:{a:f,b:a},backend:n}),n.disposeIntermediateTensorInfo(t)}if(p){const t=f;f=Bl(n,f,p,o),n.disposeIntermediateTensorInfo(t)}return f}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const hd={kernelName:l.IFFT,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n}=t,{input:r}=e,i=l.util.sizeFromShape(r.shape),s=r.shape[r.shape.length-1],a=Vl({inputs:{x:r},backend:n,attrs:{shape:[i/s,s]}}),o=rd(a,!0,n),u=Vl({inputs:{x:o},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),u}},dd=Object(Nl.a)(l.IsFinite,t=>Number.isFinite(t)?1:0,"bool"),pd={kernelName:l.IsFinite,backendName:"cpu",kernelFunc:dd},fd=Object(Nl.a)(l.IsInf,t=>Math.abs(t)===1/0?1:0,"bool"),md={kernelName:l.IsInf,backendName:"cpu",kernelFunc:fd},gd=Object(Nl.a)(l.IsNan,t=>Number.isNaN(t)?1:0,"bool"),bd={kernelName:l.IsNan,backendName:"cpu",kernelFunc:gd};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var yd=n(198);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const vd=Object(Nl.a)(l.Log1p,t=>Math.log1p(t)),wd={kernelName:l.Log1p,backendName:"cpu",kernelFunc:vd},xd=Object(Nl.a)(l.LogicalNot,t=>t?0:1,"bool"),_d={kernelName:l.LogicalNot,backendName:"cpu",kernelFunc:xd};var Od=n(199),Sd=n(141);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const kd={kernelName:l.Max,backendName:"cpu",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:r}=t,{reductionIndices:i,keepDims:s}=e,a=n;let o=r.shape;const u=o.length,c=l.util.parseAxisParam(i,o);let h=c;const d=l.backend_util.getAxesPermutation(h,u);let p=a.data.get(r.dataId).values;if(null!=d){const t=new Array(u);for(let e=0;e<t.length;e++)t[e]=o[d[e]];p=Object(Sd.a)(p,o,r.dtype,d,t),h=l.backend_util.getInnerMostAxes(h.length,u),o=t}Object(_l.a)(r,"max"),l.backend_util.assertAxesAreInnerMostDims("max",h,u);const[f,m]=l.backend_util.computeOutAndReduceShapes(o,h),g=l.util.sizeFromShape(m),b=Object(Od.a)(p,g,f,r.dtype),y=a.write(b,f,r.dtype);let v=f;if(s){v=l.backend_util.expandShapeToKeepDim(f,c)}return{dataId:y,shape:v,dtype:r.dtype}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Td={kernelName:l.MaxPool,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{x:i}=e;Object(_l.a)(i,"maxPool");const{filterSize:s,strides:a,pad:o,dimRoundingMode:u}=r;l.util.assert(l.backend_util.eitherStridesOrDilationsAreOne(a,1),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '1'`);const c=l.backend_util.computePool2DInfo(i.shape,s,a,1,o,u);let h;if(1===c.filterWidth&&1===c.filterHeight&&l.util.arraysEqual(c.inShape,c.outShape))h=Object(jl.a)({inputs:{x:i},backend:n});else{const t=n.data.get(i.dataId).values,e=l.util.computeStrides(i.shape),r=oh(t,i.shape,i.dtype,e,c,"max");h=n.makeTensorInfo(c.outShape,i.dtype,r.values)}return h}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Cd={kernelName:l.MaxPoolBackprop,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{dy:i,input:s,output:a}=e,o=s;Object(_l.a)([s,a],"maxPoolBackprop");const{filterSize:u,strides:c,pad:h,dimRoundingMode:d}=r,p=l.backend_util.computePool2DInfo(o.shape,u,c,1,h,d),f=n.data.get(o.dataId).values,m=Object(l.buffer)(p.outShape,o.dtype,uh(f,o.shape,o.dtype,p).values),g=p.strideHeight,b=p.strideWidth,y=p.dilationHeight,v=p.dilationWidth,w=p.effectiveFilterHeight,x=p.effectiveFilterWidth,_=x-1-p.padInfo.left,O=w-1-p.padInfo.top,S=Object(l.buffer)(o.shape,"float32"),k=n.data.get(i.dataId).values,T=Object(l.buffer)(i.shape,"float32",k);for(let t=0;t<p.batchSize;++t)for(let e=0;e<p.inChannels;++e)for(let n=0;n<p.inHeight;++n)for(let r=0;r<p.inWidth;++r){const i=n-O,s=r-_;let a=0;for(let n=0;n<w;n+=y){const r=(i+n)/g;if(!(r<0||r>=p.outHeight||Math.floor(r)!==r))for(let i=0;i<x;i+=v){const o=(s+i)/b;if(o<0||o>=p.outWidth||Math.floor(o)!==o)continue;const u=w*x-1-m.get(t,r,o,e)===n*x+i?1:0;if(0===u)continue;a+=T.get(t,r,o,e)*u}}S.set(a,t,n,r,e)}return n.makeTensorInfo(S.shape,S.dtype,S.values)}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const Ad={kernelName:l.MaxPoolWithArgmax,backendName:"cpu",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:r}=t,{filterSize:i,strides:s,pad:a,includeBatchInIndex:o}=e,u=n;Object(_l.a)(r,"MaxPoolWithArgmax");const c=u.data.get(r.dataId).values,h=l.backend_util.computePool2DInfo(r.shape,i,s,[1,1],a),[d,p]=function(t,e,n,r,i){const s=oh(t,0,n,l.util.computeStrides(e),i,"max"),a=uh(t,e,n,i,!0,r);return[s.values,a.values]}(c,r.shape,r.dtype,o,h),f=u.write(d,h.outShape,r.dtype),m=u.write(p,h.outShape,r.dtype);return[{dataId:f,shape:h.outShape,dtype:r.dtype},{dataId:m,shape:h.outShape,dtype:"int32"}]}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Nd={kernelName:l.MirrorPad,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{x:i}=e,{paddings:s,mode:a}=r;Object(_l.a)(i,"mirrorPad");const o=s.map((t,e)=>t[0]+i.shape[e]+t[1]),u=s.map(t=>t[0]),c=s.map((t,e)=>t[0]+i.shape[e]),h="reflect"===a?0:1,d=n.data.get(i.dataId).values,p=i.shape.length,f=l.util.computeStrides(i.shape),m=l.util.sizeFromShape(o),g=o.length,b=l.util.computeStrides(o),y=l.util.getTypedArrayFromDType(i.dtype,m);for(let t=0;t<m;t++){let e=l.util.indexToLoc(t,g,b);for(let t=0;t<g;t++)e[t]<u[t]?e[t]=2*u[t]-e[t]-h:e[t]>=c[t]&&(e[t]=2*(c[t]-1)-e[t]+h);e=e.map((t,e)=>t-u[e]);const n=l.util.locToIndex(e,p,f);y[t]=d[n]}return{dataId:n.write(y,o,i.dtype),shape:o,dtype:i.dtype}}},Id=l.kernel_impls.nonMaxSuppressionV4Impl,Ed={kernelName:l.NonMaxSuppressionV4,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{boxes:r,scores:i}=t,{maxOutputSize:s,iouThreshold:a,scoreThreshold:o,padToMaxOutputSize:u}=n,c=e;Object(_l.a)(r,"NonMaxSuppressionPadded");const l=c.data.get(r.dataId).values,h=c.data.get(i.dataId).values,{selectedIndices:d,validOutputs:p}=Id(l,h,s,a,o,u);return[d,p]}},jd=l.kernel_impls.nonMaxSuppressionV5Impl,Md={kernelName:l.NonMaxSuppressionV5,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{boxes:r,scores:i}=t,{maxOutputSize:s,iouThreshold:a,scoreThreshold:o,softNmsSigma:u}=n,c=e;Object(_l.a)(r,"NonMaxSuppressionWithScore");const l=c.data.get(r.dataId).values,h=c.data.get(i.dataId).values,d=s,p=a,f=o,m=u,{selectedIndices:g,selectedScores:b}=jd(l,h,d,p,f,m);return[g,b]}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var Dd=n(200);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Rd={kernelName:l.PadV2,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{x:i}=e,{paddings:s,constantValue:a}=r;Object(_l.a)(i,"pad");const o=s.map((t,e)=>t[0]+i.shape[e]+t[1]),u=s.map(t=>t[0]),c=n.data.get(i.dataId).values,h=l.util.sizeFromShape(i.shape),d=i.shape.length,p=l.util.computeStrides(i.shape),f=l.util.sizeFromShape(o),m=o.length,g=l.util.computeStrides(o),b=l.util.getTypedArrayFromDType(i.dtype,f);0!==a&&b.fill(a);for(let t=0;t<h;t++){const e=l.util.indexToLoc(t,d,p).map((t,e)=>t+u[e]);b[l.util.locToIndex(e,m,g)]=c[t]}return{dataId:n.write(b,o,i.dtype),shape:o,dtype:i.dtype}}},Pd=Object(Nl.a)(l.Reciprocal,t=>1/t),Fd={kernelName:l.Reciprocal,backendName:"cpu",kernelFunc:Pd},zd={kernelName:l.RotateWithOffset,backendName:"cpu",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{image:r}=t,{radians:i,fillValue:s,center:a}=e,o=n,u=l.util.getTypedArrayFromDType(r.dtype,l.util.sizeFromShape(r.shape)),[c,h,d,p]=r.shape,[f,m]=l.backend_util.getImageCenter(a,h,d),g=Math.sin(i),b=Math.cos(i),y=o.data.get(r.dataId).values;for(let t=0;t<c;t++){const e=t*d*h*p;for(let t=0;t<h;t++){const n=t*(d*p);for(let r=0;r<d;r++){const i=r*p;for(let a=0;a<p;a++){const o=[c,t,r,a],l=o[2],v=o[1];let w=(l-f)*b-(v-m)*g,x=(l-f)*g+(v-m)*b;w=Math.round(w+f),x=Math.round(x+m);let _=s;if("number"!=typeof s&&(_=3===a?255:s[a]),w>=0&&w<d&&x>=0&&x<h){_=y[e+x*(d*p)+w*p+a]}u[e+n+i+a]=_}}}}return{dataId:o.write(u,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},Ld=Object(Nl.a)(l.Round,t=>{const e=Math.floor(t);return t-e<.5?Math.floor(t):t-e>.5?Math.ceil(t):e%2==0?e:e+1}),$d={kernelName:l.Round,backendName:"cpu",kernelFunc:Ld};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var Bd=n(201);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const qd=l.backend_util.SELU_SCALEALPHA,Vd=l.backend_util.SELU_SCALE,Ud=Object(Nl.a)(l.Selu,t=>t>=0?Vd*t:qd*(Math.exp(t)-1)),Wd={kernelName:l.Selu,backendName:"cpu",kernelFunc:Ud},Gd=Object(Nl.a)(l.Sigmoid,t=>1/(1+Math.exp(-t))),Hd={kernelName:l.Sigmoid,backendName:"cpu",kernelFunc:Gd},Kd=Object(Nl.a)(l.Sign,t=>t<0?-1:t>0?1:0),Qd={kernelName:l.Sign,backendName:"cpu",kernelFunc:Kd},Xd=Object(Nl.a)(l.Sin,t=>Math.sin(t)),Yd={kernelName:l.Sin,backendName:"cpu",kernelFunc:Xd},Jd=Object(Nl.a)(l.Sinh,t=>Math.sinh(t)),Zd={kernelName:l.Sinh,backendName:"cpu",kernelFunc:Jd},tp=Math.log(1.1920928955078125e-7)+2,ep=Object(Nl.a)(l.Softplus,t=>{const e=t>-tp,n=t<tp,r=Math.exp(t);let i;return i=n?r:e?t:Math.log(1+r),i}),np={kernelName:l.Softplus,backendName:"cpu",kernelFunc:ep};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function rp(t){const{inputs:e,attrs:n,backend:r}=t,{x:i}=e,{perm:s}=n;Object(_l.a)(i,"transpose");const a=i.shape.length,o=new Array(a);for(let t=0;t<o.length;t++)o[t]=i.shape[s[t]];const u=r.data.get(i.dataId).values,c=Object(Sd.a)(u,i.shape,i.dtype,s,o);return{dataId:r.write(c,o,i.dtype),shape:o,dtype:i.dtype}}const ip={kernelName:l.Transpose,backendName:"cpu",kernelFunc:rp};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const sp={kernelName:l.SpaceToBatchND,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{x:i}=e,{blockShape:s,paddings:a}=r;Object(_l.a)([i],"spaceToBatchND");const o=l.util.sizeFromShape(s),u=[[0,0]];u.push(...a);for(let t=1+s.length;t<i.shape.length;++t)u.push([0,0]);const c=Rd.kernelFunc({inputs:{x:i},backend:n,attrs:{paddings:u,constantValue:0}}),h=l.backend_util.getReshaped(c.shape,s,o,!1),d=l.backend_util.getPermuted(h.length,s.length,!1),p=l.backend_util.getReshapedPermuted(c.shape,s,o,!1),f=Vl({inputs:{x:c},backend:n,attrs:{shape:h}}),m=rp({inputs:{x:f},backend:n,attrs:{perm:d}}),g=Vl({inputs:{x:m},backend:n,attrs:{shape:p}});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}},ap=Object(Nl.a)(l.Sqrt,t=>Math.sqrt(t)),op={kernelName:l.Sqrt,backendName:"cpu",kernelFunc:ap},up={kernelName:l.Square,backendName:"cpu",kernelFunc:({inputs:t,backend:e})=>{const{x:n}=t,r=e;Object(_l.a)(n,"square");const i=r.data.get(n.dataId).values,s=new Float32Array(i.length);for(let t=0;t<i.length;++t){const e=i[t];s[t]=e*e}return{dataId:r.write(s,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var cp=n(202);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const lp=Object(Nl.a)(l.Step,(t,e)=>{const n=e;return isNaN(t)?NaN:t>0?1:n.alpha}),hp={kernelName:l.Step,backendName:"cpu",kernelFunc:lp},dp=Object(Nl.a)(l.Tan,t=>Math.tan(t)),pp={kernelName:l.Tan,backendName:"cpu",kernelFunc:dp},fp=Object(Nl.a)(l.Tanh,t=>Math.tanh(t)),mp={kernelName:l.Tanh,backendName:"cpu",kernelFunc:fp};var gp=n(203);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const bp={kernelName:l.Unique,backendName:"cpu",kernelFunc:function(t){const{inputs:e,attrs:n,backend:r}=t,{axis:i}=n,{x:s}=e;Object(_l.a)(s,"unique");const a=r.data.get(s.dataId).values,{outputValues:o,outputShape:u,indices:c}=Object(gp.a)(a,i,s.shape,s.dtype);return[r.makeTensorInfo(u,s.dtype,o),r.makeTensorInfo([c.length],"int32",c)]}},yp=[Hl,Kl.a,Xl,Jl,ql.b,th,nh,ih,ah,ch,lh,Gl,hh,dh.b,ph.a,mh,gh.b,xh,Sh,kh,Oh,Ch,Ah,Th,Ih,jh,Dh,Rh,Ph,Fh,Lh,zh,Vh,El,Yh,Jh.a,Zh.a,sd,ad,od,ud.a,cd,ld,jl.b,hd,yh,pd,md,bd,yd.a,wd,_d,Td,Cd,Ad,kd,Nd,td.b,Ed,Md,Dd.a,Rd,Pl,vh.b,Fd,zl,$l,Ul,zd,$d,Bd.a,Wd,Hd,Qd,Yd,Zd,ed.b,np,sp,op,up,cp.a,hp,nd.b,pp,mp,ip,bp];
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */for(const t of yp)Object(l.registerKernel)(t);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var vp=n(205);
/** @license See the LICENSE file. */const wp={"tfjs-core":l.version_core,"tfjs-backend-cpu":"2.7.0","tfjs-backend-webgl":vp.version_webgl,"tfjs-data":xl,"tfjs-layers":On,"tfjs-converter":Wc,tfjs:"2.7.0"};
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(113),u=n(18),c=n(4);const l=Object(c.b)({where_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n){const c=Object(s.a)(e,"a","where"),l=Object(s.a)(n,"b","where"),h=Object(s.a)(t,"condition","where","bool"),d=Object(u.a)(c.shape,l.shape),p=Object(o.a)(c,d),f=Object(o.a)(l,d);1===h.rank&&Object(a.b)(h.shape[0]===c.shape[0],()=>"The first dimension of `a` must match the size of `condition`."),1!==h.rank&&Object(a.e)(h.shape,f.shape,"Error in where: ");const m={condition:h,t:p,e:f};return r.a.runKernelFunc((t,e)=>{const n=t.select(h,p,f);return e([h]),n},m,null,i.rc)}})},function(t,e,n){"use strict";(function(t){n.d(e,"f",(function(){return o})),n.d(e,"e",(function(){return u})),n.d(e,"a",(function(){return d})),n.d(e,"b",(function(){return p})),n.d(e,"d",(function(){return f})),n.d(e,"c",(function(){return m})),n.d(e,"g",(function(){return g}));var r=n(51),i=n(64),s=n(7),a=n(152);async function o(t,e){const n=[],r=[],i=Array.isArray(t)?t.map(t=>t.name):Object.keys(t);for(let s=0;s<i.length;++s){const a=i[s],o=Array.isArray(t)?t[s].tensor:t[a];if("float32"!==o.dtype&&"int32"!==o.dtype&&"bool"!==o.dtype&&"string"!==o.dtype&&"complex64"!==o.dtype)throw new Error(`Unsupported dtype in weight '${a}': ${o.dtype}`);const u={name:a,shape:o.shape,dtype:o.dtype};if("string"===o.dtype){const t=new Promise(async t=>{const e=await o.bytes(),n=e.reduce((t,e)=>t+e.length,0)+4*e.length,r=new Uint8Array(n);let i=0;for(let t=0;t<e.length;t++){const n=e[t],s=new Uint8Array(new Uint32Array([n.length]).buffer);r.set(s,i),i+=4,r.set(n,i),i+=n.length}t(r)});r.push(t)}else r.push(o.data());null!=e&&(u.group=e),n.push(u)}return{data:c(await Promise.all(r)),specs:n}}function u(t,e){const n={};let o,u=0;for(const c of e){const e=c.name,l=c.dtype,h=c.shape,d=Object(s.N)(h);let p;if("quantization"in c){const n=c.quantization;if("uint8"===n.dtype||"uint16"===n.dtype){if(!("min"in n)||!("scale"in n))throw new Error(`Weight ${c.name} with quantization ${n.dtype} doesn't have corresponding metadata min and scale.`)}else{if("float16"!==n.dtype)throw new Error(`Weight ${c.name} has unknown quantization dtype ${n.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);if("float32"!==l)throw new Error(`Weight ${c.name} is quantized with ${n.dtype} which only supports weights of type float32 not ${l}.`)}const r=a.a[n.dtype],i=t.slice(u,u+d*r),s="uint8"===n.dtype?new Uint8Array(i):new Uint16Array(i);if("float32"===l)if("uint8"===n.dtype||"uint16"===n.dtype){p=new Float32Array(s.length);for(let t=0;t<s.length;t++){const e=s[t];p[t]=e*n.scale+n.min}}else{if("float16"!==n.dtype)throw new Error(`Unsupported quantization type ${n.dtype} for weight type float32.`);void 0===o&&(o=b()),p=o(s)}else{if("int32"!==l)throw new Error(`Unsupported dtype in weight '${e}': ${l}`);if("uint8"!==n.dtype&&"uint16"!==n.dtype)throw new Error(`Unsupported quantization type ${n.dtype} for weight type int32.`);p=new Int32Array(s.length);for(let t=0;t<s.length;t++){const e=s[t];p[t]=Math.round(e*n.scale+n.min)}}u+=d*r}else if("string"===l){const e=Object(s.N)(c.shape);p=[];for(let n=0;n<e;n++){const e=new Uint32Array(t.slice(u,u+4))[0];u+=4;const n=new Uint8Array(t.slice(u,u+e));p.push(n),u+=e}}else{const s=a.a[l],o=t.slice(u,u+d*s);if("float32"===l)p=new Float32Array(o);else if("int32"===l)p=new Int32Array(o);else if("bool"===l)p=new Uint8Array(o);else{if("complex64"!==l)throw new Error(`Unsupported dtype in weight '${e}': ${l}`);{p=new Float32Array(o);const t=new Float32Array(p.length/2),s=new Float32Array(p.length/2);for(let e=0;e<t.length;e++)t[e]=p[2*e],s[e]=p[2*e+1];const a=Object(i.a)(t,h,"float32"),u=Object(i.a)(s,h,"float32");n[e]=Object(r.a)(a,u),a.dispose(),u.dispose()}}u+=d*s}"complex64"!==l&&(n[e]=Object(i.a)(p,h,l))}return n}function c(t){if(null===t)throw new Error("Invalid input value: "+JSON.stringify(t));let e=0;const n=[];t.forEach(t=>{if(e+=t.byteLength,n.push(t.byteLength===t.buffer.byteLength?t:new t.constructor(t)),!(t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array))throw new Error("Unsupported TypedArray subtype: "+t.constructor.name)});const r=new Uint8Array(e);let i=0;return n.forEach(t=>{r.set(new Uint8Array(t.buffer),i),i+=t.byteLength}),r.buffer}const l=void 0!==t&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function h(e){return l?t.byteLength(e):new Blob([e]).size}function d(e){if(l)return t.from(e).toString("base64");const n=new Uint8Array(e);let r="";for(let t=0,e=n.length;t<e;t++)r+=String.fromCharCode(n[t]);return btoa(r)}function p(e){if(l){const n=t.from(e,"base64");return n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}const n=atob(e),r=new Uint8Array(n.length);for(let t=0;t<n.length;++t)r.set([n.charCodeAt(t)],t);return r.buffer}function f(t){if(1===t.length)return t[0];let e=0;t.forEach(t=>{e+=t.byteLength});const n=new Uint8Array(e);let r=0;return t.forEach(t=>{n.set(new Uint8Array(t),r),r+=t.byteLength}),n.buffer}function m(t){for(t=t.trim();t.endsWith("/");)t=t.slice(0,t.length-1);const e=t.split("/");return e[e.length-1]}function g(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==t.modelTopology?0:h(JSON.stringify(t.modelTopology)),weightSpecsBytes:null==t.weightSpecs?0:h(JSON.stringify(t.weightSpecs)),weightDataBytes:null==t.weightData?0:t.weightData.byteLength}}function b(){const t=function(){const t=t=>{let e=t<<13,n=0;for(;0==(8388608&e);)n-=8388608,e<<=1;return e&=-8388609,n+=947912704,e|n},e=new Uint32Array(2048);e[0]=0;for(let n=1;n<1024;n++)e[n]=t(n);for(let t=1024;t<2048;t++)e[t]=939524096+(t-1024<<13);return e}(),e=function(){const t=new Uint32Array(64);t[0]=0,t[31]=1199570944,t[32]=2147483648,t[63]=3347054592;for(let e=1;e<31;e++)t[e]=e<<23;for(let e=33;e<63;e++)t[e]=2147483648+(e-32<<23);return t}(),n=function(){const t=new Uint32Array(64);for(let e=0;e<64;e++)t[e]=1024;return t[0]=t[32]=0,t}();return r=>{const i=new ArrayBuffer(4*r.length),s=new Uint32Array(i);for(let i=0;i<r.length;i++){const a=r[i],o=t[n[a>>10]+(1023&a)]+e[a>>10];s[i]=o}return new Float32Array(i)}}}).call(this,n(155).Buffer)},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));var r=n(6),i=n(7);
/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function s(t,e="float32",n){return e=e||"float32",i.c(t),new r.b(t,e,n)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({exp_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","exp"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.exp(e);return n([r]),r},n,null,i.X)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({abs_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","abs"),n={x:e};return r.a.runKernelFunc((t,n)=>(n([e]),"complex64"===e.dtype?t.complexAbs(e):t.abs(e)),n,null,i.a)}})},function(t,e,n){"use strict";n.d(e,"c",(function(){return d})),n.d(e,"b",(function(){return p})),n.d(e,"a",(function(){return f})),n.d(e,"d",(function(){return m}));var r=n(18),i=n(127),s=n(9),a=n(133),o=n(84),u=n(134),c=n(8),l=n(85),h=n(21);
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function d(t,e,n){if(null==n||"linear"===n)return t;if("relu"===n)return Object(s.a)(t,Object(l.a)(e));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function p(t,e){let n=e;const i=r.c(t.shape,e.shape);return i.length>0&&(n=Object(h.a)(n,i)),Object(c.a)(n,t.shape)}function f(t,e,n){if("linear"===e)return t;if("relu"===e)return Object(o.a)(t);if("elu"===e)return Object(i.a)(t);if("relu6"===e)return Object(u.a)(t);if("prelu"===e)return Object(a.a)(t,n);throw new Error(`Unknown fused activation ${e}.`)}const m=(t,e)=>!(t>0)||"linear"===e},function(t,e,n){"use strict";n.d(e,"f",(function(){return l})),n.d(e,"e",(function(){return h})),n.d(e,"d",(function(){return d})),n.d(e,"g",(function(){return p})),n.d(e,"a",(function(){return f})),n.d(e,"b",(function(){return k})),n.d(e,"c",(function(){return r}));var r,i=n(0),s=n(89),a=n(75);function o(t){return t instanceof i.Tensor?{value:t.clone(),recurse:!1}:Object(a.e)(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */class u{constructor(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}wrap(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity}get(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]}set(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e}length(){let t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t}isFull(){return this.length()===this.capacity}isEmpty(){return 0===this.length()}push(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)}pushAll(t){for(const e of t)this.push(e)}pop(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);const t=this.get(this.end);return this.set(this.end,void 0),t}unshift(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)}shift(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t}shuffleExcise(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const e=this.wrap(this.begin+t),n=this.get(e);return this.set(e,this.pop()),n}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */class c extends u{constructor(){super(c.INITIAL_CAPACITY)}isFull(){return!1}push(t){super.isFull()&&this.expand(),super.push(t)}unshift(t){super.isFull()&&this.expand(),super.unshift(t)}expand(){const t=2*this.capacity,e=new Array(t),n=this.length();for(let t=0;t<n;t++)e[t]=this.get(this.wrap(this.begin+t));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */
function l(t){return new m(t)}function h(t){return new g(t)}function d(t,e){return new C(t,e)}function p(t,e=r.FAIL){return new A(t,e)}c.INITIAL_CAPACITY=32;class f{async toArray(){const t=[];let e=await this.next();for(;!e.done;)t.push(e.value),e=await this.next();return t}async toArrayForTest(){const t=this.prefetch(100),e=[];let n=await t.next();for(;!n.done;)e.push(n.value),n=await t.next();return e}async resolveFully(){let t=await this.next();for(;!t.done;)t=await this.next()}async resolveWhile(t){let e=await this.next(),n=t(e.value);for(;!e.done&&n;)e=await this.next(),n=t(e.value)}handleErrors(t){return new O(this,t)}filter(t){return new x(this,t)}map(t){return new _(this,t)}mapAsync(t){return new S(this,t)}serialMapAsync(t){return new S(this,t).serial()}flatmap(t){return new T(this,t)}async forEachAsync(t){return this.map(t).resolveFully()}async serialForEach(t){return this.serialMapAsync(t).resolveWhile(t=>!0===t)}rowMajorBatch(t,e=!0){return new w(this,t,e)}columnMajorBatch(t,e=!0,n=a.f){return this.rowMajorBatch(t,e).map(t=>Object(a.d)(t,n))}concatenate(t,e){return new C(l([this,t]),e)}take(t){return t<0||null==t?this:new v(this,t)}skip(t){return t<0||null==t?this:new y(this,t)}prefetch(t){return new N(this,t)}shuffle(t,e){return new I(this,t,e)}serial(){return new b(this)}}class m extends f{constructor(t){super(),this.items=t,this.trav=0}summary(){return`Array of ${this.items.length} items`}async next(){if(this.trav>=this.items.length)return{value:null,done:!0};const t=this.items[this.trav];return this.trav++,{value:(e=t,Object(a.b)(e,o)),done:!1};
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */
var e}}class g extends f{constructor(t){super(),this.nextFn=t}summary(){return"Function call"}async next(){try{return this.nextFn()}catch(t){throw t.message="Error thrown while iterating through a dataset: "+t.message,t}}}class b extends f{constructor(t){super(),this.upstream=t,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return this.upstream.summary()+" -> Serial"}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){return this.upstream.next()}}class y extends f{constructor(t,e){super(),this.upstream=t,this.maxCount=e,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return this.upstream.summary()+" -> Skip"}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;this.count++<this.maxCount;){const t=await this.upstream.next();if(t.done)return t;i.dispose(t.value)}return this.upstream.next()}}class v extends f{constructor(t,e){super(),this.upstream=t,this.maxCount=e,this.count=0}summary(){return this.upstream.summary()+" -> Take"}async next(){return this.count++>=this.maxCount?{value:null,done:!0}:this.upstream.next()}}class w extends f{constructor(t,e,n=!0){super(),this.upstream=t,this.batchSize=e,this.enableSmallLastBatch=n,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return this.upstream.summary()+" -> RowMajorBatch"}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){const t=[];for(;t.length<this.batchSize;){const e=await this.upstream.next();if(e.done)return this.enableSmallLastBatch&&t.length>0?{value:t,done:!1}:{value:null,done:!0};t.push(e.value)}return{value:t,done:!1}}}class x extends f{constructor(t,e){super(),this.upstream=t,this.predicate=e,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return this.upstream.summary()+" -> Filter"}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;;){const t=await this.upstream.next();if(t.done||this.predicate(t.value))return t;i.dispose(t.value)}}}class _ extends f{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return this.upstream.summary()+" -> Map"}async next(){const t=await this.upstream.next();if(t.done)return{value:null,done:!0};const e=i.tensor_util.getTensorsInContainer(t.value),n=this.transform(t.value),r=i.tensor_util.getTensorsInContainer(n);for(const t of e)i.tensor_util.isTensorInList(t,r)||t.dispose();return{value:n,done:!1}}}class O extends f{constructor(t,e){super(),this.upstream=t,this.handler=e,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return this.upstream.summary()+" -> handleErrors"}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;;)try{return await this.upstream.next()}catch(t){if(!this.handler(t))return{value:null,done:!0}}}}class S extends f{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return this.upstream.summary()+" -> AsyncMap"}async next(){const t=await this.upstream.next();if(t.done)return{value:null,done:!0};const e=i.tensor_util.getTensorsInContainer(t.value),n=await this.transform(t.value),r=i.tensor_util.getTensorsInContainer(n);for(const t of e)i.tensor_util.isTensorInList(t,r)||t.dispose();return{value:n,done:!1}}}class k extends f{constructor(){super(),this.outputQueue=new c,this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;0===this.outputQueue.length();)if(!await this.pump())return{value:null,done:!0};return{value:this.outputQueue.shift(),done:!1}}}class T extends k{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return this.upstream.summary()+" -> Flatmap"}async pump(){const t=await this.upstream.next();if(t.done)return!1;const e=i.tensor_util.getTensorsInContainer(t.value),n=this.transform(t.value),r=i.tensor_util.getTensorsInContainer(n);this.outputQueue.pushAll(n);for(const t of e)i.tensor_util.isTensorInList(t,r)||t.dispose();return!0}}class C extends f{constructor(t,e){super(),this.baseErrorHandler=e,this.lastRead=null,this.iterator=null,this.moreIterators=t}summary(){return"TODO: fill in upstream of chained summaries -> Chained"}async next(){return this.lastRead=this.readFromChain(this.lastRead),this.lastRead}async readFromChain(t){if(await t,null==this.iterator){const t=await this.moreIterators.next();if(t.done)return{value:null,done:!0};this.iterator=t.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}const e=await this.iterator.next();return e.done?(this.iterator=null,this.readFromChain(t)):e}}!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(r||(r={}));class A extends f{constructor(t,e=r.FAIL){super(),this.iterators=t,this.mismatchMode=e,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(t){await t;let e=0,n=0;const i=await Object(a.c)(this.iterators,(function(t){if(t instanceof f){return{value:t.next().then(t=>(e++,t.done&&n++,t.value)),recurse:!1}}return{value:null,recurse:!0}}));if(e===n)return{value:null,done:!0};if(n>0)switch(this.mismatchMode){case r.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case r.SHORTEST:return{value:null,done:!0};case r.LONGEST:}return this.count++,{value:i,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}}class N extends f{constructor(t,e){super(),this.upstream=t,this.bufferSize=e,this.buffer=new u(e)}summary(){return this.upstream.summary()+" -> Prefetch"}refill(){for(;!this.buffer.isFull();){const t=this.upstream.next();this.buffer.push(t)}}next(){return this.refill(),this.buffer.shift()}}class I extends N{constructor(t,e,n){super(t,e),this.upstream=t,this.windowSize=e,this.upstreamExhausted=!1,this.random=s.alea(n||i.util.now().toString()),this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}randomInt(t){return Math.floor(this.random()*t)}chooseIndex(){return this.randomInt(this.buffer.length())}async serialNext(){for(this.upstreamExhausted||this.refill();!this.buffer.isEmpty();){const t=this.chooseIndex(),e=await this.buffer.shuffleExcise(t);if(!e.done)return this.refill(),e;this.upstreamExhausted=!0}return{value:null,done:!0}}}},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(4);const u=Object(o.b)({pow_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"base","pow"),o=Object(a.a)(e,"exp","pow");[n,o]=Object(s.makeTypesMatch)(n,o);const u={a:n,b:o};return r.a.runKernelFunc((t,e)=>{const r=t.pow(n,o);return e([n,o,r]),r},u,null,i.Zb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(71),u=n(4),c=n(8);const l=Object(u.b)({reverse_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){const n=Object(s.a)(t,"x","reverse"),u={x:n},l={dims:e};return r.a.runKernelFunc(t=>{const r=Object(a.I)(e,n.shape);if(0===n.rank)return Object(o.a)(n);const i=t.reverse(n,r);return Object(c.a)(i,n.shape)},u,null,i.mc,l)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(18),u=n(4);const c=Object(u.b)({greater_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","greater"),u=Object(a.a)(e,"b","greater");[n,u]=Object(s.makeTypesMatch)(n,u),Object(o.a)(n.shape,u.shape);const c={a:n,b:u};return r.a.runKernelFunc(t=>t.greater(n,u),c,null,i.kb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return a}));var r=n(5),i=n(7),s=n(10);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function a(t,e,n,a){if(null==a&&(a=Object(i.r)(t)),"complex64"===a)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!Object(i.A)(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t)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!=e){Object(i.c)(e);const t=Object(i.N)(e),r=Object(i.N)(n);Object(i.b)(t===r,()=>`Based on the provided shape, [${e}], the tensor should have ${t} values but has ${r}`);for(let t=0;t<n.length;++t){const r=n[t],s=t!==n.length-1||r!==Object(i.N)(e.slice(t));Object(i.b)(n[t]===e[t]||!s,()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${e}). `)}}return Object(i.A)(t)||Array.isArray(t)||(t=[t]),e=e||n,t="string"!==a?Object(s.toTypedArray)(t,a):Object(i.m)(t,[],!0),r.a.makeTensor(t,e,a)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(0);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function i(t){return(e,n,i,s,a)=>{const o=r.backend_util.assertAndGetBroadcastShape(e,n),u=o.length,c=r.util.computeStrides(o),l=r.util.sizeFromShape(o),h=r.util.getTypedArrayFromDType(a,l),d=e.length,p=n.length,f=r.util.computeStrides(e),m=r.util.computeStrides(n),g=r.backend_util.getBroadcastDims(e,o),b=r.backend_util.getBroadcastDims(n,o);if(g.length+b.length===0)for(let e=0;e<h.length;++e)h[e]=t(i[e%i.length],s[e%s.length]);else for(let e=0;e<h.length;++e){const n=r.util.indexToLoc(e,u,c),a=n.slice(-d);g.forEach(t=>a[t]=0);const o=r.util.locToIndex(a,d,f),l=n.slice(-p);b.forEach(t=>l[t]=0);const y=r.util.locToIndex(l,p,m);h[e]=t(i[o],s[y])}return[h,o]}}},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(1),i=n(7),s=n(4),a=n(8);const o=Object(s.b)({expandDims_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=0){const n=Object(r.a)(t,"x","expandDims",null);i.b(e<=n.rank,()=>"Axis must be <= rank of the tensor");const s=n.shape.slice();return e<0&&(i.b(-(n.rank+1)<=e,()=>`Axis must be in the interval [${-(n.rank+1)}, ${n.rank}]`),e=n.rank+e+1),s.splice(e,0,1),Object(a.a)(n,s)}})},function(t,e,n){"use strict";
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function r(t){const{inputs:e,backend:n}=t,{real:r,imag:i}=e,s=n.data.get(r.dataId).values,a=n.data.get(i.dataId).values,o=n.makeTensorInfo(r.shape,"complex64");return n.data.get(o.dataId).complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",s),imag:n.makeTensorInfo(i.shape,"float32",a)},o}n.d(e,"a",(function(){return r})),n.d(e,"b",(function(){return i}));const i={kernelName:n(0).Complex,backendName:"cpu",kernelFunc:r}},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4);const u=Object(o.b)({complex_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){const n=Object(s.a)(t,"real","complex"),o=Object(s.a)(e,"imag","complex");a.e(n.shape,o.shape,`real and imag shapes, ${n.shape} and ${o.shape}, must match in call to tf.complex().`);const u={real:n,imag:o};return r.a.runKernelFunc(t=>t.complex(n,o),u,null,i.y)}})},function(t,e,n){"use strict";n.r(e),n.d(e,"assertParamsValid",(function(){return i})),n.d(e,"maskToAxes",(function(){return s})),n.d(e,"computeOutShape",(function(){return a})),n.d(e,"stridesWithElidedDims",(function(){return o})),n.d(e,"getNormalizedAxes",(function(){return l})),n.d(e,"startIndicesWithElidedDims",(function(){return h})),n.d(e,"stopIndicesWithElidedDims",(function(){return d})),n.d(e,"stridesForAxis",(function(){return p})),n.d(e,"startForAxis",(function(){return f})),n.d(e,"stopForAxis",(function(){return m})),n.d(e,"isSliceContinous",(function(){return g})),n.d(e,"computeFlatOffset",(function(){return b})),n.d(e,"parseSliceParams",(function(){return y}));var r=n(7);
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function i(t,e,n){const i=t.shape.length;r.b(i===e.length,()=>`Error in slice${i}D: Length of begin ${e} must match the rank of the array (${i}).`),r.b(i===n.length,()=>`Error in slice${i}D: Length of size ${n} must match the rank of the array (${i}).`);for(let s=0;s<i;++s)r.b(e[s]+n[s]<=t.shape[s],()=>`Error in slice${i}D: begin[${s}] + size[${s}] (${e[s]+n[s]}) would overflow input.shape[${s}] (${t.shape[s]})`)}function s(t){const e=[];let n=0;for(;t>0;)1&t&&e.push(n),t/=2,n++;return e}function a(t,e,n){const r=[];for(let i=0;i<t.length;i++)r[i]=Math.ceil((e[i]-t[i])/n[i]);return r}function o(t,e,n,r){const i=[...t];for(let t=i.length;t<r.length;t++)i.push(1);for(let t=0;t<n;t++)0===t?i[e]=1:(i.splice(e,0,1),i.pop());return i}function u(t,e,n){return n<=t?n:n-(e-1)}function c(t,e){const n=[];for(let r=0;r<t;r++)n.push(e+r);return n}function l(t,e,n,r,i,s,a,u,c){const l=t.length;let g=new Array(l),b=new Array(l),y=new Array(l);if(e.length&&n>0){const c=e[0],l=n+1;g=h(a,c,l,r,t),b=d(u,c,l,i,t),y=o(s,c,l,t)}else for(let e=0;e<l;e++)g[e]=f(a,r,s,t,e,c),b[e]=m(u,i,s,t,e,c),y[e]=p(s,e,c);return{begin:g,end:b,strides:y}}function h(t,e,n,r,i){const s=[...i],a=c(n,e);for(let i=0;i<s.length;i++)if(a.indexOf(i)>-1)s[i]=0;else{const a=u(e,n,i);let o=r[a];t&1<<a&&(o=0),s[i]=o}return s}function d(t,e,n,i,s){const a=[...s],o=c(n,e);for(let r=0;r<a.length;r++)if(o.indexOf(r)>-1)a[r]=Number.MAX_SAFE_INTEGER;else{const s=u(e,n,r);let o=i[s];t&1<<s&&(o=Number.MAX_SAFE_INTEGER),a[r]=o}for(let t=0;t<a.length;t++){const e=s[t];a[t]<0&&(a[t]+=e),a[t]=r.i(0,a[t],s[t])}return a}function p(t,e,n){let r=t[e];return(n&1<<e||null==r)&&(r=1),r}function f(t,e,n,i,s,a){let o=e[s];const u=n[s]||1;(t&1<<s||a&1<<s||null==o)&&(o=u>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);const c=i[s];return o<0&&(o+=c),o=r.i(0,o,c-1),o}function m(t,e,n,i,s,a){let o=e[s];const u=n[s]||1;(t&1<<s||a&1<<s||null==o)&&(o=u>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);const c=i[s];return o<0&&(o+=c),o=u>0?r.i(0,o,c):r.i(-1,o,c-1),o}function g(t,e,n){let r=n.length;for(let t=0;t<n.length;t++)if(n[t]>1){r=t;break}for(let i=r+1;i<n.length;i++)if(e[i]>0||n[i]!==t[i])return!1;return!0}function b(t,e){let n=t.length>0?t[t.length-1]:1;for(let r=0;r<t.length-1;r++)n+=t[r]*e[r];return n}function y(t,e,n){let i;const s=t.shape.length;let a;return i="number"==typeof e?[e,...new Array(s-1).fill(0)]:e.length<s?e.concat(new Array(s-e.length).fill(0)):e.slice(),i.forEach(t=>{r.b(-1!==t,()=>"slice() does not support negative begin indexing.")}),a=null==n?new Array(s).fill(-1):"number"==typeof n?[n,...new Array(s-1).fill(-1)]:n.length<s?n.concat(new Array(s-n.length).fill(-1)):n,a=a.map((e,n)=>e>=0?e:(r.b(-1===e,()=>`Negative size values should be exactly -1 but got ${e} for the slice() size at index ${n}.`),t.shape[n]-i[n])),[i,a]}},function(t,e,n){"use strict";n.d(e,"a",(function(){return o})),n.d(e,"b",(function(){return u}));var r=n(0),i=n(11),s=n(153),a=n(50);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function o(t,e,n,r){return null==n?({inputs:n,backend:s})=>{const{a:a,b:o}=n,u=s;Object(i.a)([a,o],t);const c=u.data.get(a.dataId).values,l=u.data.get(o.dataId).values,h=r||a.dtype,[d,p]=e(a.shape,o.shape,c,l,h);return u.makeTensorInfo(p,h,d)}:({inputs:t,backend:i})=>{const{a:o,b:u}=t,c=i;if("complex64"===o.dtype||"complex64"===u.dtype){const t=Object(s.a)({inputs:{x:o},backend:c,attrs:{dtype:"complex64"}}),e=c.data.get(t.dataId),r=e.complexTensorInfos.real,i=e.complexTensorInfos.imag,l=c.data.get(r.dataId).values,h=c.data.get(i.dataId).values,d=Object(s.a)({inputs:{x:u},backend:c,attrs:{dtype:"complex64"}}),p=c.data.get(d.dataId),f=p.complexTensorInfos.real,m=p.complexTensorInfos.imag,g=c.data.get(f.dataId).values,b=c.data.get(m.dataId).values,[y,v,w]=n(o.shape,u.shape,l,h,g,b),x=c.makeTensorInfo(w,"float32",y),_=c.makeTensorInfo(w,"float32",v),O=Object(a.a)({inputs:{real:x,imag:_},backend:c});return c.disposeIntermediateTensorInfo(t),c.disposeIntermediateTensorInfo(d),c.disposeIntermediateTensorInfo(x),c.disposeIntermediateTensorInfo(_),O}{const t=c.data.get(o.dataId).values,n=c.data.get(u.dataId).values,i=r||o.dtype,[s,a]=e(o.shape,u.shape,t,n,i);return c.makeTensorInfo(a,i,s)}}}function u(t){return(e,n,i,s,a,o)=>{const u=r.backend_util.assertAndGetBroadcastShape(e,n),c=r.util.sizeFromShape(u),l=u.length,h=r.util.computeStrides(u),d=r.util.getTypedArrayFromDType("float32",c),p=r.util.getTypedArrayFromDType("float32",c),f=r.backend_util.getBroadcastDims(e,u),m=r.backend_util.getBroadcastDims(n,u),g=r.backend_util.mergeRealAndImagArrays(i,s),b=r.backend_util.mergeRealAndImagArrays(a,o),y=e.length,v=r.util.computeStrides(e),w=n.length,x=r.util.computeStrides(n);if(f.length+m.length===0)for(let e=0;e<d.length;e++){const n=e%g.length,r=e%b.length,i=t(g[2*n],g[2*n+1],b[2*r],b[2*r+1]);d[e]=i.real,p[e]=i.imag}else for(let e=0;e<d.length;e++){const n=r.util.indexToLoc(e,l,h),i=n.slice(-y);f.forEach(t=>i[t]=0);const s=r.util.locToIndex(i,y,v),a=n.slice(-w);m.forEach(t=>a[t]=0);const o=r.util.locToIndex(a,w,x),u=t(g[2*s],g[2*s+1],b[2*o],b[2*o+1]);d[e]=u.real,p[e]=u.imag}return[d,p,u]}}},,function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.logWithDuration=e.log=e.setVerbosity=e.verbosity=e.Level=void 0;var r=n(61);function i(t,n,r){if(void 0===n&&(n="Magenta.js"),void 0===r&&(r=10),0===r)throw Error("Logging level cannot be NONE.");e.verbosity>=r&&(5===r?console.warn:console.log)("%c "+n+" ","background:magenta; color:white",t)}!function(t){t[t.NONE=0]="NONE",t[t.WARN=5]="WARN",t[t.INFO=10]="INFO",t[t.DEBUG=20]="DEBUG"}(e.Level||(e.Level={})),e.verbosity=10,e.setVerbosity=function(t){t=t},e.log=i,e.logWithDuration=function(t,e,n,s){void 0===n&&(n="Magenta.js"),void 0===s&&(s=10),i(t+" in "+((r.performance.now()-e)/1e3).toPrecision(3)+"s",n,s)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(18),u=n(4);const c=Object(u.b)({greaterEqual_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","greaterEqual"),u=Object(a.a)(e,"b","greaterEqual");[n,u]=Object(s.makeTypesMatch)(n,u),Object(o.a)(n.shape,u.shape);const c={a:n,b:u};return r.a.runKernelFunc((t,e)=>{const r=t.greaterEqual(n,u);return e([n,u]),r},c,null,i.lb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(18),u=n(4);const c=Object(u.b)({lessEqual_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","lessEqual"),u=Object(a.a)(e,"b","lessEqual");[n,u]=Object(s.makeTypesMatch)(n,u),Object(o.a)(n.shape,u.shape);const c={a:n,b:u};return r.a.runKernelFunc((t,e)=>{const r=t.lessEqual(n,u);return e([n,u]),r},c,null,i.vb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return a}));var r=n(5),i=n(7),s=n(51);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function a(t,e="float32"){if("complex64"===e){const e=a(t,"float32"),n=a(t,"float32");return Object(s.a)(e,n)}const n=Object(i.F)(Object(i.N)(t),e);return r.a.makeTensor(n,t,e)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({pad_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n=0){const a=Object(s.a)(t,"x","pad");if(0===a.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const o={paddings:e,constantValue:n},u={x:a};return r.a.runKernelFunc((t,r)=>(r([a]),t.pad(a,e,n)),u,null,i.Xb,o)}})},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return S})),n.d(e,"i",(function(){return T})),n.d(e,"c",(function(){return C})),n.d(e,"f",(function(){return A})),n.d(e,"e",(function(){return E})),n.d(e,"d",(function(){return j})),n.d(e,"k",(function(){return D})),n.d(e,"g",(function(){return R})),n.d(e,"h",(function(){return P})),n.d(e,"j",(function(){return F})),n.d(e,"b",(function(){return z}));var r=n(0),i=n(91),s=n(112),a=n(2),o=n(272),u=n(273),c=n(274),l=n(275),h=n(276),d=n(277),p=n(278),f=n(279),m=n(280),g=n(281),b=n(282),y=n(283),v=n(284),w=n(285),x=n(286),_=n(287),O=n(288);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class S{static get Instance(){return this._instance||(this._instance=new this)}constructor(){const t=[].concat(...[o,u,c,l,h,d,p,b,g,f,y,v,w,x,_,O,m].map(t=>t.json));this.opMappers=t.reduce((t,e)=>(t[e.tfOpName]=e,t),{})}transformGraph(t,e={}){const n=t.node,r=[],i=[],s=[],o=n.reduce((t,e)=>(t[e.name]=this.mapNode(e),e.op.startsWith("Placeholder")?r.push(t[e.name]):"Const"===e.op?i.push(t[e.name]):null!=e.input&&0!==e.input.length||s.push(t[e.name]),t),{});let u=[];const c=[];let l={},h={};null!=e&&(l=this.mapSignatureEntries(e.inputs),h=this.mapSignatureEntries(e.outputs));const d=Object.keys(o);d.forEach(t=>{const e=o[t];e.inputNames.forEach(t=>{const[n]=Object(a.b)(t);e.inputs.push(o[n]),o[n].children.push(e)})}),0===Object.keys(h).length?d.forEach(t=>{const e=o[t];0===e.children.length&&c.push(e)}):Object.keys(h).forEach(t=>{const[e]=Object(a.b)(t),n=o[e];null!=n&&(n.signatureKey=h[t],c.push(n))}),Object.keys(l).length>0?Object.keys(l).forEach(t=>{const[e]=Object(a.b)(t),n=o[e];n&&(n.signatureKey=l[t],u.push(n))}):u=r;let p={};null!=t.library&&null!=t.library.function&&(p=t.library.function.reduce((t,e)=>(t[e.signature.name]=this.mapFunction(e),t),{}));const f={nodes:o,inputs:u,outputs:c,weights:i,placeholders:r,signature:e,functions:p};return s.length>0&&(f.initNodes=s),f}mapSignatureEntries(t){return Object.keys(t||{}).reduce((e,n)=>(e[t[n].name]=n,e),{})}mapNode(t){const e=Object(s.b)(t.op)||this.opMappers[t.op]||{};null==t.attr&&(t.attr={});const n={name:t.name,op:t.op,category:e.category,inputNames:(t.input||[]).map(t=>t.startsWith("^")?t.substr(1):t),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:t.attr};return null!=e.inputs&&(n.inputParams=e.inputs.reduce((t,e)=>(t[e.name]={type:e.type,inputIndexStart:e.start,inputIndexEnd:e.end},t),{})),null!=e.attrs&&(n.attrParams=e.attrs.reduce((e,n)=>{const r=n.type;let i=void 0;switch(n.type){case"string":i=T(t.attr,n.tfName,n.defaultValue),void 0===i&&n.tfDeprecatedName&&(i=T(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":i=P(t.attr,n.tfName,n.defaultValue),void 0===i&&n.tfDeprecatedName&&(i=P(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":i=A(t.attr,n.tfName,n.defaultValue||0),void 0===i&&n.tfDeprecatedName&&(i=A(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":i=R(t.attr,n.tfName,n.defaultValue),void 0===i&&n.tfDeprecatedName&&(i=R(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":i=C(t.attr,n.tfName,n.defaultValue),void 0===i&&n.tfDeprecatedName&&(i=C(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":i=z(t.attr,n.tfName,n.defaultValue),void 0===i&&n.tfDeprecatedName&&(i=z(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":i=D(t.attr,n.tfName,n.defaultValue),void 0===i&&n.tfDeprecatedName&&(i=D(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":i=F(t.attr,n.tfName,n.defaultValue),void 0===i&&n.tfDeprecatedName&&(i=F(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":i=E(t.attr,n.tfName,n.defaultValue),void 0===i&&n.tfDeprecatedName&&(i=E(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":i=j(t.attr,n.tfName,n.defaultValue),void 0===i&&n.tfDeprecatedName&&(i=j(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":i=I(t.attr,n.tfName,n.defaultValue),void 0===i&&n.tfDeprecatedName&&(i=I(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${n.type} for op: ${t.op}`)}return e[n.name]={value:i,type:r},e},{})),n}mapFunction(t){const e=t.nodeDef,n=[];let r={};null!=e&&(r=e.reduce((t,e)=>(t[e.name]=this.mapNode(e),"Const"===e.op&&n.push(t[e.name]),t),{}));const i=[],s=[];t.signature.inputArg.forEach(t=>{const[e]=Object(a.b)(t.name),n={name:e,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:N(t.type),type:"dtype"}},children:[]};n.signatureKey=t.name,i.push(n),r[e]=n});Object.keys(r).forEach(t=>{const e=r[t];e.inputNames.forEach(t=>{const[n]=Object(a.b)(t);e.inputs.push(r[n]),r[n].children.push(e)})});const o=t.ret;t.signature.outputArg.forEach(t=>{const[e,n]=Object(a.b)(o[t.name]),i=r[e];null!=i&&(i.defaultOutput=n,s.push(i))});const u=this.mapArgsToSignature(t);return{nodes:r,inputs:i,outputs:s,weights:n,placeholders:[],signature:u}}mapArgsToSignature(t){return{methodName:t.signature.name,inputs:t.signature.inputArg.reduce((t,e)=>(t[e.name]=this.mapArgToTensorInfo(e),t),{}),outputs:t.signature.outputArg.reduce((e,n)=>(e[n.name]=this.mapArgToTensorInfo(n,t.ret),e),{})}}mapArgToTensorInfo(t,e){let n=t.name;return null!=e&&(n=e[n]),{name:n,dtype:t.type}}}function k(e,n){const i=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){const n=Object(r.env)().global;if(void 0!==n.atob)return n.atob(e);if(void 0!==t)return new t(e,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(e);return n?i:i.toLowerCase()}function T(t,e,n,r=!1){const i=t[e];return null!=i?k(i.s,r):n}function C(t,e,n){const r=t[e];return r?r.b:n}function A(t,e,n){const r=t[e]||{},i=null!=r.i?r.i:null!=r.f?r.f:n;return"number"==typeof i?i:parseInt(i,10)}function N(t){switch("string"==typeof t&&(t=i.a[t]),t){case i.a.DT_FLOAT:return"float32";case i.a.DT_INT32:case i.a.DT_INT64:case i.a.DT_INT8:case i.a.DT_UINT8:return"int32";case i.a.DT_BOOL:return"bool";case i.a.DT_DOUBLE:return"float32";case i.a.DT_STRING:return"string";default:return null}}function I(t,e,n){const r=t[e];return r&&r.func?r.func.name:n}function E(t,e,n){const r=t[e];return r&&r.type?N(r.type):n}function j(t,e,n){const r=t[e];return r&&r.list&&r.list.type?r.list.type.map(t=>N(t)):n}function M(t){if(!t.unknownRank)return null!=t.dim?t.dim.map(t=>"number"==typeof t.size?t.size:parseInt(t.size,10)):[]}function D(t,e,n){const r=t[e];return r&&r.shape?M(r.shape):n}function R(t,e,n){const r=t[e];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map(t=>"number"==typeof t?t:parseInt(t,10)):n}function P(t,e,n,r=!1){const i=t[e];return i&&i.list&&i.list.s?i.list.s.map(t=>k(t,r)):n}function F(t,e,n){const r=t[e];return r&&r.list&&r.list.shape?r.list.shape.map(t=>M(t)):n}function z(t,e,n){const r=t[e];return r&&r.list&&r.list.b?r.list.b:n}}).call(this,n(155).Buffer)},function(t,e,n){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.getOfflineAudioContext=e.isSafari=e.navigator=e.performance=e.fetch=void 0;var n=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==t)return t;throw new Error("cannot find the global object")}();e.fetch=n.fetch.bind(n),e.performance=n.performance,e.navigator=n.navigator,e.isSafari=!!n.webkitOfflineAudioContext;var r=void 0!==n.WorkerGlobalScope;e.getOfflineAudioContext=function(t){if(t=e.isSafari?44100:t,r)throw new Error("Cannot use offline audio context in a web worker.");var i=n.webkitOfflineAudioContext;return e.isSafari?new i(1,t,t):new n.OfflineAudioContext(1,t,t)}}).call(this,n(96))},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(18),o=n(4);const u=Object(o.b)({logicalAnd_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){const n=Object(s.a)(t,"a","logicalAnd","bool"),o=Object(s.a)(e,"b","logicalAnd","bool");Object(a.a)(n.shape,o.shape);const u={a:n,b:o};return r.a.runKernelFunc(t=>t.logicalAnd(n,o),u,null,i.Ab)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(1),i=n(7),s=n(32),a=n(49),o=n(4);const u=Object(o.b)({stack_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=0){const n=Object(r.b)(t,"tensors","stack");if(i.b(n.length>=1,()=>"Pass at least one tensor to tf.stack"),1===n.length)return Object(a.a)(n[0],e);const o=n[0].rank,u=n[0].shape,c=n[0].dtype;i.b(e<=o,()=>"Axis must be <= rank of the tensor"),n.forEach(t=>{i.e(u,t.shape,"All tensors passed to stack must have matching shapes"),i.b(c===t.dtype,()=>"All tensors passed to stack must have matching dtypes")});const l=n.map(t=>Object(a.a)(t,e));return Object(s.a)(l,e)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));var r=n(1),i=n(47);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function s(t,e,n){const s=Object(r.c)(t,n);return Object(i.a)(t,e,s,n)}},function(t,e,n){"use strict";
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function r(t){const{inputs:e,backend:n}=t,{x:r}=e;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}n.d(e,"a",(function(){return r})),n.d(e,"b",(function(){return i}));const i={kernelName:n(0).Identity,backendName:"cpu",kernelFunc:r}},function(t,e){t.exports=function(){throw new Error("define cannot be used indirect")}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HI_CLICK_CLASS=e.LO_CLICK_CLASS=e.HI_CLICK_PITCH=e.LO_CLICK_PITCH=e.MAX_MIDI_PROGRAM=e.MIN_MIDI_PROGRAM=e.MAX_DRUM_PITCH=e.MIN_DRUM_PITCH=e.MAX_PIANO_PITCH=e.MIN_PIANO_PITCH=e.MIDI_PITCHES=e.MAX_MIDI_PITCH=e.MIN_MIDI_PITCH=e.NUM_PITCH_CLASSES=e.NO_CHORD=e.MIDI_VELOCITIES=e.MAX_MIDI_VELOCITY=e.MIN_MIDI_VELOCITY=e.DEFAULT_DRUM_PITCH_CLASSES=e.NON_DRUM_CHANNELS=e.DRUM_CHANNEL=e.DEFAULT_CHANNEL=e.DEFAULT_TICKS_PER_QUARTER=e.DEFAULT_PROGRAM=e.DEFAULT_VELOCITY=e.DEFAULT_STEPS_PER_SECOND=e.DEFAULT_STEPS_PER_QUARTER=e.DEFAULT_STEPS_PER_BAR=e.DEFAULT_QUARTERS_PER_MINUTE=void 0,e.DEFAULT_QUARTERS_PER_MINUTE=120,e.DEFAULT_STEPS_PER_BAR=16,e.DEFAULT_STEPS_PER_QUARTER=4,e.DEFAULT_STEPS_PER_SECOND=100,e.DEFAULT_VELOCITY=80,e.DEFAULT_PROGRAM=0,e.DEFAULT_TICKS_PER_QUARTER=220,e.DEFAULT_CHANNEL=0,e.DRUM_CHANNEL=9,e.NON_DRUM_CHANNELS=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15],e.DEFAULT_DRUM_PITCH_CLASSES=[[36,35],[38,27,28,31,32,33,34,37,39,40,56,65,66,75,85],[42,44,54,68,69,70,71,73,78,80],[46,67,72,74,79,81],[45,29,41,61,64,84],[48,47,60,63,77,86,87],[50,30,43,62,76,83],[49,55,57,58],[51,52,53,59,82]],e.MIN_MIDI_VELOCITY=0,e.MAX_MIDI_VELOCITY=127,e.MIDI_VELOCITIES=e.MAX_MIDI_VELOCITY-e.MIN_MIDI_VELOCITY+1,e.NO_CHORD="N.C.",e.NUM_PITCH_CLASSES=12,e.MIN_MIDI_PITCH=0,e.MAX_MIDI_PITCH=127,e.MIDI_PITCHES=e.MAX_MIDI_PITCH-e.MIN_MIDI_PITCH+1,e.MIN_PIANO_PITCH=21,e.MAX_PIANO_PITCH=108,e.MIN_DRUM_PITCH=35,e.MAX_DRUM_PITCH=81,e.MIN_MIDI_PROGRAM=0,e.MAX_MIDI_PROGRAM=127,e.LO_CLICK_PITCH=89,e.HI_CLICK_PITCH=90,e.LO_CLICK_CLASS=9,e.HI_CLICK_CLASS=10},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(18),u=n(12),c=n(4);const l=Object(c.b)({maximum_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","maximum"),c=Object(a.a)(e,"b","maximum");[n,c]=Object(s.makeTypesMatch)(n,c),"bool"===n.dtype&&(n=Object(u.a)(n,"int32"),c=Object(u.a)(c,"int32")),Object(o.a)(n.shape,c.shape);const l={a:n,b:c};return r.a.runKernelFunc((t,e)=>{const r=t.maximum(n,c);return e([n,c]),r},l,null,i.Jb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(20),u=n(4),c=n(8);const l=Object(u.b)({conv2d_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,u,l="NHWC",h=[1,1],d){const p=Object(s.a)(t,"x","conv2d"),f=Object(s.a)(e,"filter","conv2d");let m=p,g=!1;3===p.rank&&(g=!0,m=Object(c.a)(p,[1,p.shape[0],p.shape[1],p.shape[2]])),a.b(4===m.rank,()=>`Error in conv2d: input must be rank 4, but got rank ${m.rank}.`),a.b(4===f.rank,()=>"Error in conv2d: filter must be rank 4, but got rank "+f.rank+"."),null!=d&&a.b(a.v(u),()=>`Error in conv2d: pad must be an integer when using, dimRoundingMode ${d} but got pad ${u}.`);const b="NHWC"===l?m.shape[3]:m.shape[1];a.b(b===f.shape[2],()=>`Error in conv2d: depth of input (${b}) must match input depth for filter ${f.shape[2]}.`),a.b(o.h(n,h),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${h}'`);const y={x:m,filter:f},v={strides:n,pad:u,dataFormat:l,dilations:h,dimRoundingMode:d},w=r.a.runKernelFunc((t,e)=>{const r=o.g(l),i=o.a(m.shape,f.shape,n,h,u,d,!1,r),s=t.conv2d(m,f,i);return e([m,f]),s},y,null,i.A,v);return g?Object(c.a)(w,[w.shape[1],w.shape[2],w.shape[3]]):w}})},function(t,e,n){"use strict";n.d(e,"c",(function(){return a})),n.d(e,"a",(function(){return u})),n.d(e,"b",(function(){return c}));var r=n(0),i=n(48),s=n(53);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const a=Object(i.a)((t,e)=>t+e),o=Object(s.b)((t,e,n,r)=>({real:t+n,imag:e+r})),u=Object(s.a)(r.Add,a,o),c={kernelName:r.Add,backendName:"cpu",kernelFunc:u}},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({clone_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","clone",null),n={x:e};return r.a.runKernelFunc(()=>r.a.makeTensorFromDataId(e.dataId,e.shape,e.dtype),n,null,i.nb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return h}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(24),u=n(4),c=n(8),l=n(31);const h=Object(u.b)({max_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=null,n=!1){const u=Object(s.a)(t,"x","max"),h={x:u},d={reductionIndices:e,keepDims:n};return r.a.runKernelFunc((t,r)=>{let i=a.I(e,u.shape);const s=o.f(i,u.rank);let h=u;null!=s&&(h=Object(l.a)(u,s),i=o.g(i.length,h.rank));const d=t.max(h,i);null!=s&&h.dispose();let p=d;if(n){const t=o.e(p.shape,a.I(e,u.shape));p=Object(c.a)(p,t),d.dispose()}return r([u,p]),p},h,null,i.Db,d)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(0);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function i(t){return(e,n,i)=>{const s=r.util.getTypedArrayFromDType(n,e.length);for(let n=0;n<e.length;++n)s[n]=t(e[n],i);return s}}},function(t,e,n){"use strict";n.d(e,"c",(function(){return o})),n.d(e,"b",(function(){return u})),n.d(e,"d",(function(){return c})),n.d(e,"f",(function(){return l})),n.d(e,"e",(function(){return h})),n.d(e,"h",(function(){return d})),n.d(e,"g",(function(){return p})),n.d(e,"a",(function(){return f}));var r=n(26),i=n(151);
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const s=Object(i.a)("kernelRegistry",()=>new Map),a=Object(i.a)("gradRegistry",()=>new Map);function o(t,e){const n=m(t,e);return s.get(n)}function u(t){return a.get(t)}function c(t){const e=s.entries(),n=[];for(;;){const{done:r,value:i}=e.next();if(r)break;const[s,a]=i,[o]=s.split("_");o===t&&n.push(a)}return n}function l(t){const{kernelName:e,backendName:n}=t,r=m(e,n);s.has(r)&&console.warn(`The kernel '${e}' for backend '${n}' is already registered`),s.set(r,t)}function h(t){const{kernelName:e}=t;a.has(e)&&Object(r.c)().getBool("DEBUG")&&console.warn(`Overriding the gradient for '${e}'`),a.set(e,t)}function d(t,e){const n=m(t,e);if(!s.has(n))throw new Error(`The kernel '${t}' for backend '${e}' is not registered`);s.delete(n)}function p(t){if(!a.has(t))throw new Error(`The gradient '${t}' for backend is not registered`);a.delete(t)}function f(t,e){c(t).forEach(t=>{l(Object.assign({},t,{backendName:e}))})}function m(t,e){return`${e}_${t}`}},function(t,e,n){"use strict";n.d(e,"b",(function(){return i})),n.d(e,"d",(function(){return a})),n.d(e,"f",(function(){return o})),n.d(e,"c",(function(){return u})),n.d(e,"e",(function(){return c})),n.d(e,"a",(function(){return l}));var r=n(0);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */function i(t,e){return s(t,e)}function s(t,e,n=new Map,r=new Set){if(null==t)return null;if(r.has(t))throw new Error("Circular references are not supported.");if(n.has(t))return n.get(t);const i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(i.recurse){if(c(t)){const i=Array.isArray(t)?[]:{};r.add(t);for(const a in t){const o=s(t[a],e,n,r);i[a]=o}return r.delete(t),i}throw new Error("Can't recurse into non-iterable type: "+t)}return n.set(t,i.value),i.value}function a(t,e=o){return function t(e,n,r=new Set){const i=e[0];if(r.has(i))throw new Error("Circular references are not supported.");const s=n(e);if(s.recurse&&null!==s.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(s.recurse){if(c(i)){const s=Array.isArray(i)?[]:{};r.add(i);for(const a in i){const i=e.map(t=>t[a]),o=t(i,n,r);s[a]=o}return r.delete(i),s}throw new Error("Can't recurse into non-iterable type: "+i)}return s.value}(t,e)}function o(t){return null===t?null:c(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}async function u(t,e){const n=new Map;s(t,e,n);for(const t of Array.from(n.keys())){const e=n.get(t);if(r.util.isPromise(e)){const r=await e;n.set(t,r)}}return s(t,e,n)}function c(t){return null!=t&&!ArrayBuffer.isView(t)&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof r.Tensor))}function l(t){return null==t||(null===(e=t)||"object"!=typeof e&&"function"!=typeof e)||Array.isArray(t)||"object"==typeof t&&t instanceof r.Tensor||r.util.isTypedArray(t);var e}},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({log_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","log"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.log(e);return n([e]),r},n,null,i.xb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return a}));var r=n(1),i=n(7),s=n(47);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function a(t,e){Object(i.d)(t);const n=Object(r.c)(t,e);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return Object(s.a)(t,null,n,e)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4),u=n(187);const c=Object(o.b)({split_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n=0){const o=Object(s.a)(t,"x","split"),c={x:o},l={numOrSizeSplits:e,axis:n};return r.a.runKernelFunc((t,r)=>{const i=Object(a.I)(n,o.shape)[0],s=Object(u.a)(o,e,i);return t.split(o,s,i)},c,null,i.Cc,l)}})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NoteSequence=void 0;var r=n(314).tensorflow.magenta.NoteSequence;e.NoteSequence=r},function(t,e,n){"use strict";n.d(e,"a",(function(){return o})),n.d(e,"b",(function(){return u})),n.d(e,"c",(function(){return c}));var r=n(15),i=n(77);
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function s(t,e,n){const r=function(t,e,n){return function(t,e,n){let r=0,i=t.length,s=0,a=!1;for(;r<i;){s=r+(i-r>>>1);const o=n(e,t[s]);o>0?r=s+1:(i=s,a=!o)}return a?r:-r-1}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */(t,e,n||a)}(t,e,n),i=r<0?-(r+1):r;t.splice(i,0,e)}function a(t,e){return t>e?1:t<e?-1:0}function o(t,e,n,r,i){return l(t,e,n,r,i,0).selectedIndices}function u(t,e,n,r,i,s){return l(t,e,n,r,i,0,!1,s,!0)}function c(t,e,n,r,i,s){return l(t,e,n,r,i,s,!0)}function l(t,e,n,a,o,u,c=!1,l=!1,f=!1){const m=[];for(let t=0;t<e.length;t++)e[t]>o&&m.push({score:e[t],boxIndex:t,suppressBeginIndex:0});m.sort(p);const g=u>0?-.5/u:0,b=[],y=[];for(;b.length<n&&m.length>0;){const e=m.pop(),{score:n,boxIndex:r,suppressBeginIndex:i}=e;if(n<o)break;let u=!1;for(let n=b.length-1;n>=i;--n){const i=h(t,r,b[n]);if(i>=a){u=!0;break}if(e.score=e.score*d(a,g,i),e.score<=o)break}e.suppressBeginIndex=b.length,u||(e.score===n?(b.push(r),y.push(e.score)):e.score>o&&s(m,e,p))}const v=b.length,w=n-v;l&&w>0&&(b.push(...new Array(w).fill(0)),y.push(...new Array(w).fill(0)));const x={selectedIndices:Object(i.a)(b,"int32")};return c&&(x.selectedScores=Object(i.a)(y,"float32")),f&&(x.validOutputs=Object(r.a)(v,"int32")),x}function h(t,e,n){const r=t.subarray(4*e,4*e+4),i=t.subarray(4*n,4*n+4),s=Math.min(r[0],r[2]),a=Math.min(r[1],r[3]),o=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),c=Math.min(i[0],i[2]),l=Math.min(i[1],i[3]),h=Math.max(i[0],i[2]),d=Math.max(i[1],i[3]),p=(o-s)*(u-a),f=(h-c)*(d-l);if(p<=0||f<=0)return 0;const m=Math.max(s,c),g=Math.max(a,l),b=Math.min(o,h),y=Math.min(u,d),v=Math.max(b-m,0)*Math.max(y-g,0);return v/(p+f-v)}function d(t,e,n){const r=Math.exp(e*n*n);return n<=t?r:0}function p(t,e){return t.score-e.score||t.score===e.score&&e.boxIndex-t.boxIndex}},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(20),u=n(4),c=n(8);const l=Object(u.b)({depthwiseConv2d_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,u,l="NHWC",h=[1,1],d){const p=Object(s.a)(t,"x","depthwiseConv2d"),f=Object(s.a)(e,"filter","depthwiseConv2d");let m=p,g=!1;3===p.rank&&(g=!0,m=Object(c.a)(p,[1,p.shape[0],p.shape[1],p.shape[2]])),a.b(4===m.rank,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${m.rank}.`),a.b(4===f.rank,()=>"Error in depthwiseConv2d: filter must be rank 4, but got rank "+f.rank+"."),a.b(m.shape[3]===f.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${m.shape[3]}) must match the inChannels dimension in filter ${f.shape[2]}.`),null!=d&&a.b(a.v(u),()=>`Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode ${d} but got pad ${u}.`);const b={x:m,filter:f},y={strides:n,pad:u,dataFormat:l,dilations:h,dimRoundingMode:d},v=r.a.runKernelFunc((t,e)=>{null==h&&(h=[1,1]),a.b(o.h(n,h),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${h}'`);const r=o.a(m.shape,f.shape,n,h,u,d,!0),i=t.depthwiseConv2D(m,f,r);return e([m,f]),i},b,null,i.L,y);return g?Object(c.a)(v,[v.shape[1],v.shape[2],v.shape[3]]):v}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(18),u=n(4);const c=Object(u.b)({equal_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","equal"),u=Object(a.a)(e,"b","equal");[n,u]=Object(s.makeTypesMatch)(n,u),Object(o.a)(n.shape,u.shape);const c={a:n,b:u};return r.a.runKernelFunc(t=>t.equal(n,u),c,null,i.V)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(7),s=n(51),a=n(58);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function o(t,e="float32"){if("complex64"===e){const e=o(t,"float32"),n=Object(a.a)(t,"float32");return Object(s.a)(e,n)}const n=Object(i.D)(Object(i.N)(t),e);return r.a.makeTensor(n,t,e)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(4),o=n(12);const u=Object(a.b)({relu_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","relu"),n={x:e};return r.a.runKernelFunc((t,n)=>(n([e]),"bool"===e.dtype?Object(o.a)(e,"int32"):t.relu(e)),n,null,i.fc)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({step_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=0){const n=Object(s.a)(t,"x","step"),a={x:n},o={alpha:e};return r.a.runKernelFunc(t=>t.step(n,e),a,null,i.Gc,o)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(8);var u=n(4);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function c(t){return null==t?null:0===t.rank?Object(o.a)(t,[t.size]):1===t.rank?t:2===t.rank?Object(o.a)(t,[1,1,t.shape[0],t.shape[1]]):3===t.rank?Object(o.a)(t,[1,t.shape[0],t.shape[1],t.shape[2]]):t}const l=Object(u.b)({batchNorm_:function(t,e,n,u,l,h){null==h&&(h=.001);const d=Object(s.a)(t,"x","batchNorm"),p=Object(s.a)(e,"mean","batchNorm"),f=Object(s.a)(n,"variance","batchNorm");let m,g;null!=l&&(m=Object(s.a)(l,"scale","batchNorm")),null!=u&&(g=Object(s.a)(u,"offset","batchNorm")),a.b(p.rank===f.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),a.b(null==g||p.rank===g.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),a.b(null==m||p.rank===m.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");const b=function(t){let e;return e=0===t.rank||1===t.rank?Object(o.a)(t,[1,1,1,t.size]):2===t.rank?Object(o.a)(t,[1,1,t.shape[0],t.shape[1]]):3===t.rank?Object(o.a)(t,[1,t.shape[0],t.shape[1],t.shape[2]]):t,e}(d),y={x:b,scale:m,offset:g,mean:p,variance:f},v={varianceEpsilon:h},w=r.a.runKernelFunc((t,e)=>(e([b,p,f,m]),t.batchNorm(b,c(p),c(f),c(g),c(m),h)),y,null,i.fb,v);return Object(o.a)(w,d.shape)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({sigmoid_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","sigmoid"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.sigmoid(e);return n([r]),r},n,null,i.tc)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4);const u=Object(o.b)({tile_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){const n=Object(s.a)(t,"x","tile",null);a.b(n.rank===e.length,()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${e}.`);const o=[n],u={x:n},c={reps:e};return r.a.runKernelFunc((t,r)=>{const i=t.tile(n,e);return r([n]),i},u,null,i.Mc,c,o)}})},function(t,e,n){var r=n(301),i=n(302),s=n(303),a=n(304),o=n(305),u=n(306),c=n(307);c.alea=r,c.xor128=i,c.xorwow=s,c.xorshift7=a,c.xor4096=o,c.tychei=u,t.exports=c},function(t,e,n){!function(t,e,n,r){"use strict";function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var s=i(e),a=i(n),o=i(r),u=function(t,e,n){return{endTime:e,insertTime:n,type:"exponentialRampToValue",value:t}},c=function(t,e,n){return{endTime:e,insertTime:n,type:"linearRampToValue",value:t}},l=function(t,e){return{startTime:e,type:"setValue",value:t}},h=function(t,e,n){return{duration:n,startTime:e,type:"setValueCurve",values:t}},d=function(t,e,n){var r=n.startTime,i=n.target,s=n.timeConstant;return i+(e-i)*Math.exp((r-t)/s)},p=function(t){return"exponentialRampToValue"===t.type},f=function(t){return"linearRampToValue"===t.type},m=function(t){return p(t)||f(t)},g=function(t){return"setValue"===t.type},b=function(t){return"setValueCurve"===t.type},y=function t(e,n,r,i){var s=e[n];return void 0===s?i:m(s)||g(s)?s.value:b(s)?s.values[s.values.length-1]:d(r,t(e,n-1,s.startTime,i),s)},v=function(t,e,n,r,i){return void 0===n?[r.insertTime,i]:m(n)?[n.endTime,n.value]:g(n)?[n.startTime,n.value]:b(n)?[n.startTime+n.duration,n.values[n.values.length-1]]:[n.startTime,y(t,e-1,n.startTime,i)]},w=function(t){return"cancelAndHold"===t.type},x=function(t){return"cancelScheduledValues"===t.type},_=function(t){return w(t)||x(t)?t.cancelTime:p(t)||f(t)?t.endTime:t.startTime},O=function(t,e,n,r){var i=r.endTime,s=r.value;return n===s?s:0<n&&0<s||n<0&&s<0?n*Math.pow(s/n,(t-e)/(i-e)):0},S=function(t,e,n,r){return n+(t-e)/(r.endTime-e)*(r.value-n)},k=function(t,e){var n=e.duration,r=e.startTime,i=e.values;return function(t,e){var n=Math.floor(e),r=Math.ceil(e);return n===r?t[n]:(1-(e-n))*t[n]+(1-(r-e))*t[r]}(i,(t-r)/n*(i.length-1))},T=function(t){return"setTarget"===t.type},C=function(){function t(e){a.default(this,t),this._automationEvents=[],this._currenTime=0,this._defaultValue=e}return o.default(t,[{key:Symbol.iterator,value:function(){return this._automationEvents[Symbol.iterator]()}},{key:"add",value:function(t){var e=_(t);if(w(t)||x(t)){var n=this._automationEvents.findIndex((function(n){return x(t)&&b(n)?n.startTime+n.duration>=e:_(n)>=e})),r=this._automationEvents[n];if(-1!==n&&(this._automationEvents=this._automationEvents.slice(0,n)),w(t)){var i=this._automationEvents[this._automationEvents.length-1];if(void 0!==r&&m(r)){if(T(i))throw new Error("The internal list is malformed.");var s=b(i)?i.startTime+i.duration:_(i),a=b(i)?i.values[i.values.length-1]:i.value,o=p(r)?O(e,s,a,r):S(e,s,a,r),d=p(r)?u(o,e,this._currenTime):c(o,e,this._currenTime);this._automationEvents.push(d)}void 0!==i&&T(i)&&this._automationEvents.push(l(this.getValue(e),e)),void 0!==i&&b(i)&&i.startTime+i.duration>e&&(this._automationEvents[this._automationEvents.length-1]=h(new Float32Array([6,7]),i.startTime,e-i.startTime))}}else{var g=this._automationEvents.findIndex((function(t){return _(t)>e})),y=-1===g?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[g-1];if(void 0!==y&&b(y)&&_(y)+y.duration>e)return!1;var v=p(t)?u(t.value,t.endTime,this._currenTime):f(t)?c(t.value,e,this._currenTime):t;if(-1===g)this._automationEvents.push(v);else{if(b(t)&&e+t.duration>_(this._automationEvents[g]))return!1;this._automationEvents.splice(g,0,v)}}return!0}},{key:"flush",value:function(t){var e=this._automationEvents.findIndex((function(e){return _(e)>t}));if(e>1){var n=this._automationEvents.slice(e-1),r=n[0];T(r)&&n.unshift(l(y(this._automationEvents,e-2,r.startTime,this._defaultValue),r.startTime)),this._automationEvents=n}}},{key:"getValue",value:function(t){if(0===this._automationEvents.length)return this._defaultValue;var e=this._automationEvents[this._automationEvents.length-1],n=this._automationEvents.findIndex((function(e){return _(e)>t})),r=this._automationEvents[n],i=_(e)<=t?e:this._automationEvents[n-1];if(void 0!==i&&T(i)&&(void 0===r||!m(r)||r.insertTime>t))return d(t,y(this._automationEvents,n-2,i.startTime,this._defaultValue),i);if(void 0!==i&&g(i)&&(void 0===r||!m(r)))return i.value;if(void 0!==i&&b(i)&&(void 0===r||!m(r)||i.startTime+i.duration>t))return t<i.startTime+i.duration?k(t,i):i.values[i.values.length-1];if(void 0!==i&&m(i)&&(void 0===r||!m(r)))return i.value;if(void 0!==r&&p(r)){var a=v(this._automationEvents,n-1,i,r,this._defaultValue),o=s.default(a,2),u=o[0],c=o[1];return O(t,u,c,r)}if(void 0!==r&&f(r)){var l=v(this._automationEvents,n-1,i,r,this._defaultValue),h=s.default(l,2),w=h[0],x=h[1];return S(t,w,x,r)}return this._defaultValue}}]),t}();t.AutomationEventList=C,t.createCancelAndHoldAutomationEvent=function(t){return{cancelTime:t,type:"cancelAndHold"}},t.createCancelScheduledValuesAutomationEvent=function(t){return{cancelTime:t,type:"cancelScheduledValues"}},t.createExponentialRampToValueAutomationEvent=function(t,e){return{endTime:e,type:"exponentialRampToValue",value:t}},t.createLinearRampToValueAutomationEvent=function(t,e){return{endTime:e,type:"linearRampToValue",value:t}},t.createSetTargetAutomationEvent=function(t,e,n){return{startTime:e,target:t,timeConstant:n,type:"setTarget"}},t.createSetValueAutomationEvent=l,t.createSetValueCurveAutomationEvent=h,Object.defineProperty(t,"__esModule",{value:!0})}(e,n(331),n(337),n(338))},function(t,e,n){"use strict";
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */
var r,i;n.d(e,"a",(function(){return r})),function(t){t[t.DT_INVALID=0]="DT_INVALID",t[t.DT_FLOAT=1]="DT_FLOAT",t[t.DT_DOUBLE=2]="DT_DOUBLE",t[t.DT_INT32=3]="DT_INT32",t[t.DT_UINT8=4]="DT_UINT8",t[t.DT_INT16=5]="DT_INT16",t[t.DT_INT8=6]="DT_INT8",t[t.DT_STRING=7]="DT_STRING",t[t.DT_COMPLEX64=8]="DT_COMPLEX64",t[t.DT_INT64=9]="DT_INT64",t[t.DT_BOOL=10]="DT_BOOL",t[t.DT_QINT8=11]="DT_QINT8",t[t.DT_QUINT8=12]="DT_QUINT8",t[t.DT_QINT32=13]="DT_QINT32",t[t.DT_BFLOAT16=14]="DT_BFLOAT16",t[t.DT_FLOAT_REF=101]="DT_FLOAT_REF",t[t.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",t[t.DT_INT32_REF=103]="DT_INT32_REF",t[t.DT_UINT8_REF=104]="DT_UINT8_REF",t[t.DT_INT16_REF=105]="DT_INT16_REF",t[t.DT_INT8_REF=106]="DT_INT8_REF",t[t.DT_STRING_REF=107]="DT_STRING_REF",t[t.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",t[t.DT_INT64_REF=109]="DT_INT64_REF",t[t.DT_BOOL_REF=110]="DT_BOOL_REF",t[t.DT_QINT8_REF=111]="DT_QINT8_REF",t[t.DT_QUINT8_REF=112]="DT_QUINT8_REF",t[t.DT_QINT32_REF=113]="DT_QINT32_REF",t[t.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF"}(r||(r={})),function(t){let e;!function(t){t[t.LEGACY=0]="LEGACY",t[t.V1=1]="V1",t[t.V2=2]="V2"}(e=t.CheckpointFormatVersion||(t.CheckpointFormatVersion={}))}(i||(i={}))},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.split=e.trim=e.concatenate=e.applySustainControlChanges=e.mergeConsecutiveNotes=e.replaceInstruments=e.mergeInstruments=e.createQuantizedNoteSequence=e.unquantizeSequence=e.assertIsAbsoluteQuantizedSequence=e.isAbsoluteQuantizedSequence=e.assertIsRelativeQuantizedSequence=e.isRelativeQuantizedSequence=e.assertIsQuantizedSequence=e.isQuantizedSequence=e.quantizeNoteSequence=e.quantizeToStep=e.stepsPerQuarterToStepsPerSecond=e.clone=e.QuantizationStatusException=e.MultipleTempoException=e.NegativeTimeException=e.BadTimeSignatureException=e.MultipleTimeSignatureException=void 0;var s=n(79),a=n(67),o=function(t){function e(e){var n=this.constructor,r=t.call(this,e)||this;return Object.setPrototypeOf(r,n.prototype),r}return i(e,t),e}(Error);e.MultipleTimeSignatureException=o;var u=function(t){function e(e){var n=this.constructor,r=t.call(this,e)||this;return Object.setPrototypeOf(r,n.prototype),r}return i(e,t),e}(Error);e.BadTimeSignatureException=u;var c=function(t){function e(e){var n=this.constructor,r=t.call(this,e)||this;return Object.setPrototypeOf(r,n.prototype),r}return i(e,t),e}(Error);e.NegativeTimeException=c;var l=function(t){function e(e){var n=this.constructor,r=t.call(this,e)||this;return Object.setPrototypeOf(r,n.prototype),r}return i(e,t),e}(Error);e.MultipleTempoException=l;var h=function(t){function e(e){var n=this.constructor,r=t.call(this,e)||this;return Object.setPrototypeOf(r,n.prototype),r}return i(e,t),e}(Error);function d(t){return s.NoteSequence.decode(s.NoteSequence.encode(t).finish())}function p(t,e){return t*e/60}function f(t,e,n){void 0===n&&(n=.5);var r=t*e;return Math.floor(r+(1-n))}function m(t){return t.controlChanges.concat(t.textAnnotations)}function g(t){if(t.tempos&&0!==t.tempos.length){if(t.tempos.sort((function(t,e){return t.time-e.time})),0!==t.tempos[0].time&&t.tempos[0].qpm!==a.DEFAULT_QUARTERS_PER_MINUTE)throw new l("NoteSequence has an implicit tempo change from initial "+a.DEFAULT_QUARTERS_PER_MINUTE+" qpm to "+t.tempos[0].qpm+" qpm at "+t.tempos[0].time+" seconds.");for(var e=1;e<t.tempos.length;e++)if(t.tempos[e].qpm!==t.tempos[0].qpm)throw new l("NoteSequence has at least one tempo change from "+t.tempos[0].qpm+" qpm to "+t.tempos[e].qpm+"qpm at "+t.tempos[e].time+" seconds.")}}function b(t){return t.quantizationInfo&&(t.quantizationInfo.stepsPerQuarter>0||t.quantizationInfo.stepsPerSecond>0)}function y(t){if(!b(t))throw new h("NoteSequence "+t.id+" is not quantized (missing quantizationInfo)")}function v(t){return t.quantizationInfo&&t.quantizationInfo.stepsPerQuarter>0}function w(t){if(!v(t))throw new h("NoteSequence "+t.id+" is not quantized or is quantized based on absolute timing")}function x(t){return t.quantizationInfo&&t.quantizationInfo.stepsPerSecond>0}function _(t,e,n,r,i){for(var a,o=0,u=0;u<t.length;++u){var c=i?i[u]:t[u][e];if(0===c)throw Error("Sequence "+t[u].id+" has no "+e+", and no individual duration was provided.");0===u?a=d(t[0]):Array.prototype.push.apply(a.notes,t[u].notes.map((function(t){var e=s.NoteSequence.Note.create(t);return e[n]+=o,e[r]+=o,e}))),o+=c}return a[e]=o,a}function O(t,e,n,r,i,s,a){var o=d(t);o[r]=n,o.notes=o.notes.filter((function(t){return t[i]>=e&&t[i]<=n&&(a||t[s]<=n)})),o[r]-=e;for(var u=0;u<o.notes.length;u++)o.notes[u][i]-=e,o.notes[u][s]-=e,a&&(o.notes[u][s]=Math.min(o.notes[u][s],o[r]));return o}e.QuantizationStatusException=h,e.clone=d,e.stepsPerQuarterToStepsPerSecond=p,e.quantizeToStep=f,e.quantizeNoteSequence=function(t,e){var n=d(t);if(n.quantizationInfo=s.NoteSequence.QuantizationInfo.create({stepsPerQuarter:e}),n.timeSignatures.length>0){if(n.timeSignatures.sort((function(t,e){return t.time-e.time})),0!==n.timeSignatures[0].time&&(4!==n.timeSignatures[0].numerator||4!==n.timeSignatures[0].denominator))throw new o("NoteSequence has an implicit change from initial 4/4 time signature to "+n.timeSignatures[0].numerator+"/"+n.timeSignatures[0].denominator+" at "+n.timeSignatures[0].time+" seconds.");for(var r=1;r<n.timeSignatures.length;r++){if((i=n.timeSignatures[r]).numerator!==n.timeSignatures[0].numerator||i.denominator!==n.timeSignatures[0].denominator)throw new o("NoteSequence has at least one time signature change from "+n.timeSignatures[0].numerator+"/"+n.timeSignatures[0].denominator+" to "+i.numerator+"/"+i.denominator+" at "+i.time+" seconds")}n.timeSignatures[0].time=0,n.timeSignatures=[n.timeSignatures[0]]}else{var i=s.NoteSequence.TimeSignature.create({numerator:4,denominator:4,time:0});n.timeSignatures.push(i)}var l,h=n.timeSignatures[0];if(!(l=h.denominator)||0!=(l&l-1))throw new u("Denominator is not a power of 2. Time signature: "+h.numerator+"/"+h.denominator);if(0===h.numerator)throw new u("Numerator is 0. Time signature: "+h.numerator+"/"+h.denominator);if(n.tempos.length>0)g(n),n.tempos[0].time=0,n.tempos=[n.tempos[0]];else{var b=s.NoteSequence.Tempo.create({qpm:a.DEFAULT_QUARTERS_PER_MINUTE,time:0});n.tempos.push(b)}var y=p(e,n.tempos[0].qpm);return n.totalQuantizedSteps=f(t.totalTime,y),function(t,e){for(var n=0,r=t.notes;n<r.length;n++){var i=r[n];if(i.quantizedStartStep=f(i.startTime,e),i.quantizedEndStep=f(i.endTime,e),i.quantizedEndStep===i.quantizedStartStep&&(i.quantizedEndStep+=1),i.quantizedStartStep<0||i.quantizedEndStep<0)throw new c("Got negative note time: start_step = "+i.quantizedStartStep+", end_step = "+i.quantizedEndStep);i.quantizedEndStep>t.totalQuantizedSteps&&(t.totalQuantizedSteps=i.quantizedEndStep)}m(t).forEach((function(t){if(t.quantizedStep=f(t.time,e),t.quantizedStep<0)throw new c("Got negative event time: step = "+t.quantizedStep)}))}(n,y),n},e.isQuantizedSequence=b,e.assertIsQuantizedSequence=y,e.isRelativeQuantizedSequence=v,e.assertIsRelativeQuantizedSequence=w,e.isAbsoluteQuantizedSequence=x,e.assertIsAbsoluteQuantizedSequence=function(t){if(!x(t))throw new h("NoteSequence "+t.id+" is not quantized or is quantized based on relative timing")},e.unquantizeSequence=function(t,e){w(t),g(t);var n=d(t);e?n.tempos&&n.tempos.length>0?n.tempos[0].qpm=e:n.tempos.push(s.NoteSequence.Tempo.create({time:0,qpm:e})):e=t.tempos&&t.tempos.length>0?n.tempos[0].qpm:a.DEFAULT_QUARTERS_PER_MINUTE;var r=function(t){return t/n.quantizationInfo.stepsPerQuarter*(60/e)};return n.totalTime=r(n.totalQuantizedSteps),n.notes.forEach((function(t){t.startTime=r(t.quantizedStartStep),t.endTime=r(t.quantizedEndStep),n.totalTime=Math.max(n.totalTime,t.endTime),delete t.quantizedStartStep,delete t.quantizedEndStep})),m(n).forEach((function(t){t.time=r(t.time)})),delete n.totalQuantizedSteps,delete n.quantizationInfo,n},e.createQuantizedNoteSequence=function(t,e){return void 0===t&&(t=a.DEFAULT_STEPS_PER_QUARTER),void 0===e&&(e=a.DEFAULT_QUARTERS_PER_MINUTE),s.NoteSequence.create({quantizationInfo:{stepsPerQuarter:t},tempos:[{qpm:e}]})},e.mergeInstruments=function(t){var e=d(t),n=e.notes.concat(e.pitchBends).concat(e.controlChanges),r=Array.from(new Set(n.filter((function(t){return!t.isDrum})).map((function(t){return t.program}))));return n.forEach((function(t){t.isDrum?(t.program=0,t.instrument=r.length):t.instrument=r.indexOf(t.program)})),e},e.replaceInstruments=function(t,e){var n=new Set(t.notes.map((function(t){return t.instrument}))),r=new Set(e.notes.map((function(t){return t.instrument}))),i=[];t.notes.forEach((function(t){r.has(t.instrument)||i.push(s.NoteSequence.Note.create(t))})),e.notes.forEach((function(t){n.has(t.instrument)&&i.push(s.NoteSequence.Note.create(t))}));var a=d(t);return a.notes=i.sort((function(t,e){var n=t.instrument-e.instrument;return n||t.quantizedStartStep-e.quantizedStartStep})),a},e.mergeConsecutiveNotes=function(t){y(t);var e=d(t);e.notes=[];var n=t.notes.sort((function(t,e){var n=t.instrument-e.instrument;return n||t.quantizedStartStep-e.quantizedStartStep})),r=new s.NoteSequence.Note;r.pitch=n[0].pitch,r.instrument=n[0].instrument,r.quantizedStartStep=n[0].quantizedStartStep,r.quantizedEndStep=n[0].quantizedEndStep,e.notes.push(r);for(var i=0,a=1;a<n.length;a++){var o=n[a],u=e.notes[i];if(u.instrument===o.instrument&&u.pitch===o.pitch&&o.quantizedStartStep===u.quantizedEndStep&&o.quantizedStartStep%16!=0)e.notes[i].quantizedEndStep+=o.quantizedEndStep-o.quantizedStartStep;else{var c=new s.NoteSequence.Note;c.pitch=n[a].pitch,c.instrument=n[a].instrument,c.quantizedStartStep=n[a].quantizedStartStep,c.quantizedEndStep=n[a].quantizedEndStep,e.notes.push(c),i++}}return e},e.applySustainControlChanges=function(t,e){var n;if(void 0===e&&(e=64),function(t){t[t.SUSTAIN_ON=0]="SUSTAIN_ON",t[t.SUSTAIN_OFF=1]="SUSTAIN_OFF",t[t.NOTE_ON=2]="NOTE_ON",t[t.NOTE_OFF=3]="NOTE_OFF"}(n||(n={})),b(t))throw new Error("Can only apply sustain to unquantized NoteSequence.");for(var r=d(t),i=[],s=0,a=r.notes;s<a.length;s++){!1===(E=a[s]).isDrum&&(null!==E.startTime&&i.push({time:E.startTime,type:n.NOTE_ON,event:E}),null!==E.endTime&&i.push({time:E.endTime,type:n.NOTE_OFF,event:E}))}for(var o=0,u=r.controlChanges;o<u.length;o++){var c=u[o];if(c.controlNumber===e){var l=c.controlValue;l>=64?i.push({time:c.time,type:n.SUSTAIN_ON,event:c}):l<64&&i.push({time:c.time,type:n.SUSTAIN_OFF,event:c})}}i.sort((function(t,e){return t.time-e.time}));for(var h={},p={},f=0,m=0,g=i;m<g.length;m++){var y=g[m];f=y.time;var v=y.type,w=y.event;if(v===n.SUSTAIN_ON)p[w.instrument]=!0;else if(v===n.SUSTAIN_OFF){p[w.instrument]=!1;var x=[];w.instrument in h||(h[w.instrument]=[]);for(var _=0,O=h[w.instrument];_<O.length;_++){(E=O[_]).endTime<f?(E.endTime=f,f>r.totalTime&&(r.totalTime=f)):x.push(E)}h[w.instrument]=x}else if(v===n.NOTE_ON){if(!0===p[w.instrument]){x=[];w.instrument in h||(h[w.instrument]=[]);for(var S=0,k=h[w.instrument];S<k.length;S++){(E=k[S]).pitch===w.pitch?(E.endTime=f,E.startTime===E.endTime&&r.notes.push(E)):x.push(E)}h[w.instrument]=x}w.instrument in h||(h[w.instrument]=[]),h[w.instrument].push(w)}else if(v===n.NOTE_OFF)if(!0===p[w.instrument]);else{var T=h[w.instrument].indexOf(w);T>-1&&h[w.instrument].splice(T,1)}}for(var C=0,A=Object.values(h);C<A.length;C++)for(var N=0,I=A[C];N<I.length;N++){var E;(E=I[N]).endTime=f,r.totalTime=f}return r},e.concatenate=function(t,e){if(e&&e.length!==t.length)throw new Error("Number of sequences to concatenate and their individual\n durations does not match.");if(b(t[0])){for(var n=0;n<t.length;++n)if(y(t[n]),t[n].quantizationInfo.stepsPerQuarter!==t[0].quantizationInfo.stepsPerQuarter)throw new Error("Not all sequences have the same quantizationInfo");return _(t,"totalQuantizedSteps","quantizedStartStep","quantizedEndStep",e)}return _(t,"totalTime","startTime","endTime",e)},e.trim=function(t,e,n,r){return b(t)?O(t,e,n,"totalQuantizedSteps","quantizedStartStep","quantizedEndStep",r):O(t,e,n,"totalTime","startTime","endTime",r)},e.split=function(t,e){y(t);for(var n=d(t),r=n.notes.sort((function(t,e){return t.quantizedStartStep-e.quantizedStartStep})),i=[],a=0,o=[],u=0;u<r.length;u++){var c=r[u],l=c.quantizedStartStep,h=c.quantizedEndStep;if(c.quantizedStartStep-=a,c.quantizedEndStep-=a,!(c.quantizedStartStep<0))if(c.quantizedEndStep<=e)o.push(c);else{if(c.quantizedStartStep<e){var p=s.NoteSequence.Note.create(c);p.quantizedEndStep=e,p.startTime=p.endTime=void 0,o.push(p),c.quantizedStartStep=a+e,c.quantizedEndStep=h}else c.quantizedStartStep=l,c.quantizedEndStep=h;var f;if((c.quantizedEndStep>e||c.quantizedStartStep>e)&&(u-=1),0!==o.length)(f=d(n)).notes=o,f.totalQuantizedSteps=e,i.push(f);o=[],a+=e}}return 0!==o.length&&((f=d(n)).notes=o,f.totalQuantizedSteps=e,i.push(f)),i}},function(t,e,n){"use strict";n.d(e,"a",(function(){return b}));var r=n(5),i=n(33),s=n(3),a=n(1),o=n(7),u=n(24),c=n(12),l=n(16),h=n(9),d=n(83),p=n(4),f=n(8),m=n(15),g=n(21);const b=Object(p.b)({mean_:
/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=null,n=!1){const p=Object(a.a)(t,"x","mean"),b=Object(o.I)(e,p.shape),y=Object(u.d)(p.shape,b)[1],v=Object(o.N)(y),w={x:p},x={axis:e,keepDims:n},_=()=>{const t=Object(m.a)(v),r=t.dtype===p.dtype?p:Object(c.a)(p,t.dtype),i=Object(l.a)(r,t);return Object(g.a)(i,e,n)};return Object(i.a)(t=>({value:r.a.runKernelFunc(_,w,null,s.Kb,x),gradFunc:e=>{const n=t.shape.slice();b.forEach(t=>{n[t]=1});const r=Object(f.a)(e,n);return Object(l.a)(Object(h.a)(r,Object(d.a)(t.shape,"float32")),v)}}))(p)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({real_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"input","real"),n={input:e};return r.a.runKernelFunc(t=>t.real(e),n,null,i.dc)}})},function(t,e,n){"use strict";
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function r(t){const{inputs:e,backend:n}=t,{input:r}=e,i=n.data.get(r.dataId).complexTensorInfos.real,s=n.data.get(i.dataId).values;return n.makeTensorInfo(i.shape,i.dtype,s)}n.d(e,"a",(function(){return r})),n.d(e,"b",(function(){return i}));const i={kernelName:n(0).Real,backendName:"cpu",kernelFunc:r}},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
var r,i,s,a,o;n.d(e,"a",(function(){return r})),n.d(e,"c",(function(){return c})),n.d(e,"b",(function(){return l})),function(t){t.R0="R0",t.R1="R1",t.R2="R2",t.R3="R3",t.R4="R4",t.R5="R5",t.R6="R6"}(r||(r={})),function(t){t.float32="float32",t.int32="int32",t.bool="int32",t.complex64="complex64"}(i||(i={})),function(t){t.float32="float32",t.int32="int32",t.bool="bool",t.complex64="complex64"}(s||(s={})),function(t){t.float32="float32",t.int32="float32",t.bool="float32",t.complex64="complex64"}(a||(a={})),function(t){t.float32="complex64",t.int32="complex64",t.bool="complex64",t.complex64="complex64"}(o||(o={}));const u={float32:a,int32:i,bool:s,complex64:o};function c(t,e){if("string"===t||"string"===e){if("string"===t&&"string"===e)return"string";throw new Error(`Can not upcast ${t} with ${e}`)}return u[t][e]}function l(t){return c(t,"int32")}},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4);const u=Object(o.b)({batchToSpaceND_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n){const o=Object(s.a)(t,"x","batchToSpaceND"),u=e.reduce((t,e)=>t*e);a.b(o.rank>=1+e.length,()=>`input rank is ${o.rank} but should be > than blockShape.length ${e.length}`),a.b(n.length===e.length,()=>`crops.length is ${n.length} but should be equal to blockShape.length  ${e.length}`),a.b(o.shape[0]%u==0,()=>`input tensor batch is ${o.shape[0]} but is not divisible by the product of the elements of blockShape ${e.join(" * ")} === ${u}`);const c={x:o},l={blockShape:e,crops:n};return r.a.runKernelFunc(t=>t.batchToSpaceND(o,e,n),c,null,i.t,l)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4),u=n(8),c=n(170);const l=Object(o.b)({gather_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n=0){const o=Object(s.a)(t,"x","gather"),l=Object(s.a)(e,"indices","gather","int32"),h={x:o,indices:l},d={axis:n};return r.a.runKernelFunc((t,e)=>{const r=Object(a.I)(n,o.shape)[0],i=Object(c.collectGatherOpShapeInfo)(o,l,r),s=t.gather(o,Object(u.a)(l,[l.size]),r);return e([o,l]),Object(u.a)(s,i.outputShape)},h,null,i.jb,d)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({imag_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"input","imag"),n={input:e};return r.a.runKernelFunc(t=>t.imag(e),n,null,i.ob)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(18),u=n(4);const c=Object(u.b)({less_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","less"),u=Object(a.a)(e,"b","less");[n,u]=Object(s.makeTypesMatch)(n,u),Object(o.a)(n.shape,u.shape);const c={a:n,b:u};return r.a.runKernelFunc(t=>t.less(n,u),c,null,i.ub)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({logicalNot_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","logicalNot","bool"),n={x:e};return r.a.runKernelFunc(t=>t.logicalNot(e),n,null,i.Bb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(18),u=n(12),c=n(4);const l=Object(c.b)({minimum_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","minimum"),c=Object(a.a)(e,"b","minimum");[n,c]=Object(s.makeTypesMatch)(n,c),"bool"===n.dtype&&(n=Object(u.a)(n,"int32"),c=Object(u.a)(c,"int32")),Object(o.a)(n.shape,c.shape);const l={a:n,b:c};return r.a.runKernelFunc((t,e)=>{const r=t.minimum(n,c);return e([n,c]),r},l,null,i.Mb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(18),u=n(4);const c=Object(u.b)({notEqual_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","notEqual"),u=Object(a.a)(e,"b","notEqual");[n,u]=Object(s.makeTypesMatch)(n,u),Object(o.a)(n.shape,u.shape);const c={a:n,b:u};return r.a.runKernelFunc(t=>t.notEqual(n,u),c,null,i.Ub)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4);const u=Object(o.b)({spaceToBatchND_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n){const o=Object(s.a)(t,"x","spaceToBatchND");a.b(o.rank>=1+e.length,()=>`input rank ${o.rank} should be > than [blockShape] ${e.length}`),a.b(n.length===e.length,()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${e.length}`),a.b(o.shape.reduce((t,r,i)=>i>0&&i<=e.length?t&&(r+n[i-1][0]+n[i-1][1])%e[i-1]==0:t,!0),()=>`input spatial dimensions ${o.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${e.toString()}`);const u={x:o},c={blockShape:e,paddings:n};return r.a.runKernelFunc(t=>t.spaceToBatchND(o,e,n),u,null,i.Ac,c)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(18),u=n(4);const c=Object(u.b)({squaredDifference_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","squaredDifference"),u=Object(a.a)(e,"b","squaredDifference");[n,u]=Object(s.makeTypesMatch)(n,u),Object(o.a)(n.shape,u.shape);const c={a:n,b:u};return r.a.runKernelFunc((t,e)=>{const r=t.squaredDifference(n,u);return e([n,u]),r},c,null,i.Fc,{})}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(1),i=n(7),s=n(4),a=n(8);const o=Object(s.b)({squeeze_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){const n=Object(r.a)(t,"x","squeeze");return Object(a.a)(n,Object(i.P)(n.shape,e).newShape)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4);const u=Object(o.b)({unstack_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=0){const n=Object(s.a)(t,"x","unstack");a.b(e>=-n.shape.length&&e<n.shape.length,()=>`Axis = ${e} is not in [-${n.shape.length}, ${n.shape.length})`),e<0&&(e+=n.shape.length);const o={value:n},u={axis:e};return r.a.runKernelFunc(t=>t.unstack(n,e),o,null,i.Qc,u)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return i})),n.d(e,"b",(function(){return s})),n.d(e,"c",(function(){return a}));var r=n(89);n(143);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class i{constructor(t,e,n,i,s){this.mean=t,this.stdDev=e,this.dtype=n,this.nextVal=NaN,this.truncated=i,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);const a=s||Math.random();this.random=r.alea(a.toString())}nextValue(){if(!isNaN(this.nextVal)){const t=this.nextVal;return this.nextVal=NaN,t}let t,e,n=!1;for(;!n;){let r,i,s;do{r=2*this.random()-1,i=2*this.random()-1,s=r*r+i*i}while(s>=1||0===s);const a=Math.sqrt(-2*Math.log(s)/s);t=this.mean+this.stdDev*r*a,e=this.mean+this.stdDev*i*a,this.truncated&&!this.isValidTruncated(t)||(n=!0)}return this.truncated&&!this.isValidTruncated(e)||(this.nextVal=this.convertValue(e)),this.convertValue(t)}convertValue(t){return null==this.dtype||"float32"===this.dtype?t:Math.round(t)}isValidTruncated(t){return t<=this.upper&&t>=this.lower}}class s{constructor(t,e,n,s){this.alpha=t,this.beta=1/e,this.dtype=n;const a=s||Math.random();this.randu=r.alea(a.toString()),this.randn=new i(0,1,n,!1,this.randu()),this.d=t<1?t+2/3:t-1/3,this.c=1/Math.sqrt(9*this.d)}nextValue(){let t,e,n,r,i,s;for(;;){do{r=this.randn.nextValue(),s=1+this.c*r}while(s<=0);if(s*=s*s,t=r*r,e=1-.331*t*t,n=.5*t+this.d*(1-s+Math.log(s)),i=this.randu(),i<e||Math.log(i)<n)break}return s=1/this.beta*this.d*s,this.alpha<1&&(s*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(s)}convertValue(t){return"float32"===this.dtype?t:Math.round(t)}}class a{constructor(t=0,e=1,n,i){if(this.canReturnFloat=()=>null==this.dtype||"float32"===this.dtype,this.min=t,this.range=e-t,this.dtype=n,null==i&&(i=Math.random()),"number"==typeof i&&(i=i.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${t} - ${e} <= 1 and dtype is not float`);this.random=r.alea(i)}convertValue(t){return this.canReturnFloat()?t:Math.round(t)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}},function(t,e,n){"use strict";(function(t){var r=e;function i(t,e,n){for(var r=Object.keys(e),i=0;i<r.length;++i)void 0!==t[r[i]]&&n||(t[r[i]]=e[r[i]]);return t}function s(t){function e(t,n){if(!(this instanceof e))return new e(t,n);Object.defineProperty(this,"message",{get:function(){return t}}),Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),n&&i(this,n)}return(e.prototype=Object.create(Error.prototype)).constructor=e,Object.defineProperty(e.prototype,"name",{get:function(){return t}}),e.prototype.toString=function(){return this.name+": "+this.message},e}r.asPromise=n(317),r.base64=n(318),r.EventEmitter=n(319),r.float=n(320),r.inquire=n(321),r.utf8=n(322),r.pool=n(323),r.LongBits=n(324),r.isNode=Boolean(void 0!==t&&t&&t.process&&t.process.versions&&t.process.versions.node),r.global=r.isNode&&t||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||this,r.emptyArray=Object.freeze?Object.freeze([]):[],r.emptyObject=Object.freeze?Object.freeze({}):{},r.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},r.isString=function(t){return"string"==typeof t||t instanceof String},r.isObject=function(t){return t&&"object"==typeof t},r.isset=r.isSet=function(t,e){var n=t[e];return!(null==n||!t.hasOwnProperty(e))&&("object"!=typeof n||(Array.isArray(n)?n.length:Object.keys(n).length)>0)},r.Buffer=function(){try{var t=r.inquire("buffer").Buffer;return t.prototype.utf8Write?t:null}catch(t){return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(t){return"number"==typeof t?r.Buffer?r._Buffer_allocUnsafe(t):new r.Array(t):r.Buffer?r._Buffer_from(t):"undefined"==typeof Uint8Array?t:new Uint8Array(t)},r.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||r.inquire("long"),r.key2Re=/^true|false|0|1$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(t){return t?r.LongBits.from(t).toHash():r.LongBits.zeroHash},r.longFromHash=function(t,e){var n=r.LongBits.fromHash(t);return r.Long?r.Long.fromBits(n.lo,n.hi,e):n.toNumber(Boolean(e))},r.merge=i,r.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)},r.newError=s,r.ProtocolError=s("ProtocolError"),r.oneOfGetter=function(t){for(var e={},n=0;n<t.length;++n)e[t[n]]=1;return function(){for(var t=Object.keys(this),n=t.length-1;n>-1;--n)if(1===e[t[n]]&&void 0!==this[t[n]]&&null!==this[t[n]])return t[n]}},r.oneOfSetter=function(t){return function(e){for(var n=0;n<t.length;++n)t[n]!==e&&delete this[t[n]]}},r.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},r._configure=function(){var t=r.Buffer;t?(r._Buffer_from=t.from!==Uint8Array.from&&t.from||function(e,n){return new t(e,n)},r._Buffer_allocUnsafe=t.allocUnsafe||function(e){return new t(e)}):r._Buffer_from=r._Buffer_allocUnsafe=null}}).call(this,n(96))},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.hzToMidi=e.midiToHz=e.hannWindow=e.frame=e.padConstant=e.padCenterToLength=e.applyWindow=e.resampleAndMakeMono=e.powerToDb=e.melSpectrogram=e.loadAudioFromFile=e.loadAudioFromUrl=void 0;var s=n(36),a=n(264),o=n(214),u=n(376),c=n(61),l=n(55),h=c.getOfflineAudioContext(16e3);function d(t){if(1===t.numberOfChannels)return t.getChannelData(0);if(2!==t.numberOfChannels)throw Error(t.numberOfChannels+" channel audio is not supported.");for(var e=t.getChannelData(0),n=t.getChannelData(1),r=new Float32Array(t.length),i=0;i<t.length;++i)r[i]=(e[i]+n[i])/2;return r}function p(t,e){if(t.length!==e[0].length)throw new Error("Each entry in filterbank should have dimensions matching FFT. |mags| = "+t.length+", |filterbank[0]| = "+e[0].length+".");for(var n=new Float32Array(e.length),r=0;r<e.length;r++){var i=f(t,e[r]);n[r]=i.reduce((function(t,e){return t+e}))}return n}function f(t,e){if(t.length!==e.length)return console.error("Buffer length "+t.length+" != window length "+e.length+"."),null;for(var n=new Float32Array(t.length),r=0;r<t.length;r++)n[r]=e[r]*t[r];return n}function m(t,e){if(t.length>e)throw new Error("Data is longer than length.");var n=Math.floor((e-t.length)/2);return g(t,[n,e-t.length-n])}function g(t,e){var n,r;"object"==typeof e?(n=e[0],r=e[1]):n=r=e;var i=new Float32Array(t.length+n+r);return i.set(t,n),i}function b(t,e,n){for(var r=Math.floor((t.length-e)/n)+1,i=Array.from({length:r},(function(t,n){return new Float32Array(e)})),s=0;s<r;s++){var a=s*n,o=t.slice(a,a+e);i[s].set(o),o.length}return i}function y(t){var e=new a(t.length),n=e.createComplexArray(),r=e.toComplexArray(t);return e.transform(n,r),n}function v(t){for(var e=new Float32Array(t),n=0;n<t;n++)e[n]=.5*(1-Math.cos(2*Math.PI*n/(t-1)));return e}function w(t,e,n){for(var r=(e-t)/(n-1),i=new Float32Array(n),s=0;s<n;s++)i[s]=t+r*s;return i}function x(t){return 1125*Math.log(1+t/700)}e.loadAudioFromUrl=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,c.fetch(t).then((function(t){return t.arrayBuffer()})).then((function(t){return h.decodeAudioData(t)}))]}))}))},e.loadAudioFromFile=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){return e=new FileReader,[2,new Promise((function(n,r){e.onerror=function(){e.abort(),r(new DOMException("Something went wrong reading that file."))},e.onload=function(){n(e.result)},e.readAsArrayBuffer(t)})).then((function(t){return h.decodeAudioData(t)}))]}))}))},e.melSpectrogram=function(t,e){e.power||(e.power=2);var n=function(t,e){var n=t.map((function(t){return function(t,e){return t.map((function(t){return Math.pow(t,e)}))}(function(t){for(var e=new Float32Array(t.length/2),n=0;n<t.length/2;n++)e[n]=Math.sqrt(t[2*n]*t[2*n]+t[2*n+1]*t[2*n+1]);return e}(t),e)})),r=t[0].length-1;return[n,r]}(function(t,e){var n=e.nFft||2048,r=e.winLength||n,i=e.hopLength||Math.floor(r/4),s=v(r);s=m(s,n);for(var a=b(t=function(t,e){for(var n=g(t,e),r=0;r<e;r++)n[r]=n[2*e-r],n[n.length-r-1]=n[n.length-2*e+r-1];return n}(t,Math.floor(n/2)),n,i),o=[],u=a.length,c=n+2,l=0;l<u;l++){var h=new Float32Array(c);o[l]=h}for(l=0;l<u;l++){h=y(f(a[l],s));o[l].set(h.slice(0,c))}return o}(t,e),e.power),r=n[0],i=n[1];return e.nFft=i,function(t,e){for(var n=[],r=0;r<t.length;r++)n[r]=p(t[r],e);return n}(r,function(t){for(var e=t.fMin||0,n=t.fMax||t.sampleRate/2,r=t.nMels||128,i=t.nFft||2048,s=function(t,e){return w(0,t/2,Math.floor(1+e/2))}(t.sampleRate,i),a=function(t,e,n){var r=x(e),i=x(n);return w(r,i,t).map((function(t){return function(t){return 700*(Math.exp(t/1125)-1)}(t)}))}(r+2,e,n),o=function(t){for(var e=new Float32Array(t.length-1),n=0;n<t.length;n++)e[n]=t[n+1]-t[n];return e}(a),u=function(t,e){for(var n=[],r=0;r<t.length;r++)n[r]=new Float32Array(e.length);for(r=0;r<t.length;r++)for(var i=0;i<e.length;i++)n[r][i]=t[r]-e[i];return n}(a,s),c=u[0].length,l=[],h=0;h<r;h++){l[h]=new Float32Array(c);for(var d=0;d<u[h].length;d++){var p=-u[h][d]/o[h],f=u[h+2][d]/o[h+1],m=Math.max(0,Math.min(p,f));l[h][d]=m}}var g=function(t){var e=2/(a[2+t]-a[t]);l[t]=l[t].map((function(t){return t*e}))};for(h=0;h<l.length;h++)g(h);return l}(e))},e.powerToDb=function(t,e,n){void 0===e&&(e=1e-10),void 0===n&&(n=80);for(var r=t.length,i=t[0].length,s=[],a=0;a<r;a++)s[a]=new Float32Array(i);for(a=0;a<r;a++)for(var o=0;o<i;o++){var u=t[a][o];s[a][o]=10*Math.log10(Math.max(e,u))}if(n){if(n<0)throw new Error("topDb must be non-negative.");for(a=0;a<r;a++){var c=s[a].reduce((function(t,e){return Math.max(t,e)}));for(o=0;o<i;o++)s[a][o]=Math.max(s[a][o],c-n)}}return s},e.resampleAndMakeMono=function(t,e){return void 0===e&&(e=16e3),r(this,void 0,void 0,(function(){var n,r,s,a,h,p;return i(this,(function(i){return t.sampleRate===e?[2,d(t)]:(n=t.sampleRate,r=t.length*e/n,c.isSafari?(l.log("Safari does not support WebAudio resampling, so this may be slow.","O&F",5),h=d(t),p=new Float32Array(r),u(o(p,[r]),o(h,[h.length])),[2,p]):(s=new OfflineAudioContext(t.numberOfChannels,t.duration*e,e),(a=s.createBufferSource()).buffer=t,a.connect(s.destination),a.start(),[2,s.startRendering().then((function(t){return t.getChannelData(0)}))]))}))}))},e.applyWindow=f,e.padCenterToLength=m,e.padConstant=g,e.frame=b,e.hannWindow=v,e.midiToHz=function(t){var e=s.sub(t,69);return e=s.div(e,12),e=s.pow(2,e),e=s.mul(440,e)},e.hzToMidi=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e=s.sub(s.div(s.log(t),s.log(2)),s.div(s.log(440),s.log(2))),e=s.mul(12,e),[4,(e=s.add(e,69)).array()];case 1:return[2,n.sent()]}}))}))}},function(t,e,n){"use strict";n.d(e,"c",(function(){return i})),n.d(e,"b",(function(){return s})),n.d(e,"a",(function(){return a}));
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r={};function i(t,e){const n={tfOpName:t,category:"custom",inputs:[],attrs:[],customExecutor:e};r[t]=n}function s(t){return r[t]}function a(t){delete r[t]}},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(1),a=n(71),o=n(4),u=n(8);const c=Object(o.b)({broadcastTo_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(s.a)(t,"broadcastTo","x");const o=n.shape;if(e.some(t=>!(t>0)||t%1!=0))throw new Error(`broadcastTo(): Invalid broadcast shape [${e}].`);if(e.length<n.rank)throw new Error(`broadcastTo(): shape.length=${e.length} < input.rank=${n.rank}.`);if(e.length>n.rank){const t=n.shape.slice();for(;t.length<e.length;)t.unshift(1);n=Object(u.a)(n,t)}const c=n.shape,l=Array.from(e);for(let t=e.length-1;t>=0;t--)if(c[t]===e[t])l[t]=1;else if(1!==n.shape[t])throw new Error(`broadcastTo(): [${o}] cannot be broadcast to [${e}].`);if(0===l.map((t,e)=>t>1?e:-1).filter(t=>t>=0).length)return Object(a.a)(n);const h={x:n},d={shape:e,inputShape:c};return r.a.runKernelFunc(t=>t.tile(n,l),h,null,i.u,d)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return h}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(24),u=n(4),c=n(8),l=n(31);const h=Object(u.b)({min_:function(t,e=null,n=!1){const u=Object(s.a)(t,"x","min"),h={x:u},d={axis:e,keepDims:n};return r.a.runKernelFunc((t,r)=>{const i=Object(a.I)(e,u.shape);let s=i;const h=o.f(s,u.rank);let d=u;null!=h&&(d=Object(l.a)(u,h),s=o.g(s.length,u.rank));const p=t.min(d,s);null!=h&&d.dispose();let f=p;if(n){const t=o.e(f.shape,i);f=Object(c.a)(p,t),p.dispose()}return r([u,f]),f},h,null,i.Lb,d)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(4),o=n(8);const u=Object(a.b)({oneHot_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n=1,a=0){if(e<2)throw new Error("Error in oneHot: depth must be >=2, but it is "+e);const u=Object(s.a)(t,"indices","oneHot","int32"),c=[...u.shape,e],l={indices:u},h={depth:e,onValue:n,offValue:a};return r.a.runKernelFunc((t,r)=>(r([u]),Object(o.a)(t.oneHot(Object(o.a)(u,[u.size]),e,n,a),c)),l,null,i.Vb,h)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(7),a=n(4),o=n(8);const u=Object(a.b)({ifft_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){Object(s.b)("complex64"===t.dtype,()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${t.dtype}.`);const e={input:t};return r.a.runKernelFunc(e=>{const n=t.shape[t.shape.length-1],r=t.size/n,i=Object(o.a)(t,[r,n]),s=e.ifft(i);return Object(o.a)(s,t.shape)},e,null,i.mb)}})},function(t,e,n){"use strict";n.d(e,"c",(function(){return s})),n.d(e,"a",(function(){return a})),n.d(e,"b",(function(){return o}));var r=n(0),i=n(11);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function s(t,e,n,i,s){const a=r.slice_util.isSliceContinous(i,e,n),o=r.util.sizeFromShape(n),u=r.util.computeStrides(i);if(a){const n=r.slice_util.computeFlatOffset(e,u);return t.subarray(n,n+o)}const c=r.util.getTypedArrayFromDType(s,o);for(let s=0;s<o;++s){const a=n.length,o=r.util.computeStrides(n),l=r.util.indexToLoc(s,a,o).map((t,n)=>t+e[n]),h=r.util.locToIndex(l,i.length,u);c[s]=t[h]}return c}function a(t){const{inputs:e,backend:n,attrs:a}=t,{x:o}=e,{begin:u,size:c}=a;Object(i.a)(o,"slice");const[l,h]=r.slice_util.parseSliceParams(o,u,c);r.slice_util.assertParamsValid(o,l,h);const d=s(n.data.get(o.dataId).values,l,h,o.shape,o.dtype);return n.makeTensorInfo(h,o.dtype,d)}const o={kernelName:r.Slice,backendName:"cpu",kernelFunc:a}},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e){(function(e){t.exports=e}).call(this,{})},function(t,e,n){"use strict";n.r(e),n.d(e,"getContext",(function(){return Yi})),n.d(e,"setContext",(function(){return Ji})),n.d(e,"Clock",(function(){return Es})),n.d(e,"Context",(function(){return Vi})),n.d(e,"BaseContext",(function(){return qi})),n.d(e,"Delay",(function(){return js})),n.d(e,"Gain",(function(){return Os})),n.d(e,"Offline",(function(){return Ms})),n.d(e,"OfflineContext",(function(){return Ki})),n.d(e,"Param",(function(){return ys})),n.d(e,"ToneAudioBuffer",(function(){return Hi})),n.d(e,"ToneAudioBuffers",(function(){return Ds})),n.d(e,"ToneAudioNode",(function(){return vs})),n.d(e,"connectSeries",(function(){return ws})),n.d(e,"connect",(function(){return xs})),n.d(e,"disconnect",(function(){return _s})),n.d(e,"FrequencyClass",(function(){return ls})),n.d(e,"Frequency",(function(){return ps})),n.d(e,"MidiClass",(function(){return Rs})),n.d(e,"Midi",(function(){return Ps})),n.d(e,"TimeClass",(function(){return us})),n.d(e,"Time",(function(){return cs})),n.d(e,"TicksClass",(function(){return Fs})),n.d(e,"Ticks",(function(){return zs})),n.d(e,"TransportTimeClass",(function(){return fs})),n.d(e,"TransportTime",(function(){return ms})),n.d(e,"Emitter",(function(){return Bi})),n.d(e,"IntervalTimeline",(function(){return $s})),n.d(e,"StateTimeline",(function(){return bs})),n.d(e,"Timeline",(function(){return Pi})),n.d(e,"isUndef",(function(){return ai})),n.d(e,"isDefined",(function(){return oi})),n.d(e,"isFunction",(function(){return ui})),n.d(e,"isNumber",(function(){return ci})),n.d(e,"isObject",(function(){return li})),n.d(e,"isBoolean",(function(){return hi})),n.d(e,"isArray",(function(){return di})),n.d(e,"isString",(function(){return pi})),n.d(e,"isNote",(function(){return fi})),n.d(e,"dbToGain",(function(){return ts})),n.d(e,"gainToDb",(function(){return es})),n.d(e,"intervalToFrequencyRatio",(function(){return ns})),n.d(e,"ftom",(function(){return is})),n.d(e,"mtof",(function(){return as})),n.d(e,"optionsFromArguments",(function(){return Ci})),n.d(e,"defaultArg",(function(){return Ai})),n.d(e,"Unit",(function(){return i})),n.d(e,"debug",(function(){return r})),n.d(e,"Noise",(function(){return Xs})),n.d(e,"UserMedia",(function(){return Zs})),n.d(e,"Oscillator",(function(){return na})),n.d(e,"AMOscillator",(function(){return oa})),n.d(e,"FMOscillator",(function(){return ua})),n.d(e,"PulseOscillator",(function(){return ca})),n.d(e,"FatOscillator",(function(){return la})),n.d(e,"PWMOscillator",(function(){return ha})),n.d(e,"OmniOscillator",(function(){return pa})),n.d(e,"ToneOscillatorNode",(function(){return ea})),n.d(e,"LFO",(function(){return ba})),n.d(e,"ToneBufferSource",(function(){return Qs})),n.d(e,"Player",(function(){return wa})),n.d(e,"Players",(function(){return xa})),n.d(e,"GrainPlayer",(function(){return _a})),n.d(e,"Add",(function(){return fa})),n.d(e,"Abs",(function(){return Oa})),n.d(e,"AudioToGain",(function(){return sa})),n.d(e,"GainToAudio",(function(){return Sa})),n.d(e,"GreaterThan",(function(){return Aa})),n.d(e,"GreaterThanZero",(function(){return Ca})),n.d(e,"Multiply",(function(){return aa})),n.d(e,"Negate",(function(){return ka})),n.d(e,"Pow",(function(){return Na})),n.d(e,"Signal",(function(){return Ts})),n.d(e,"connectSignal",(function(){return Cs})),n.d(e,"Scale",(function(){return ma})),n.d(e,"ScaleExp",(function(){return Ia})),n.d(e,"Subtract",(function(){return Ta})),n.d(e,"SyncedSignal",(function(){return Ea})),n.d(e,"WaveShaper",(function(){return ia})),n.d(e,"Zero",(function(){return ga})),n.d(e,"AMSynth",(function(){return La})),n.d(e,"DuoSynth",(function(){return Ua})),n.d(e,"FMSynth",(function(){return Wa})),n.d(e,"MetalSynth",(function(){return Ha})),n.d(e,"MembraneSynth",(function(){return Ka})),n.d(e,"MonoSynth",(function(){return Va})),n.d(e,"NoiseSynth",(function(){return Qa})),n.d(e,"PluckSynth",(function(){return ro})),n.d(e,"PolySynth",(function(){return io})),n.d(e,"Sampler",(function(){return so})),n.d(e,"Synth",(function(){return Fa})),n.d(e,"Loop",(function(){return oo})),n.d(e,"Part",(function(){return uo})),n.d(e,"Pattern",(function(){return vo})),n.d(e,"Sequence",(function(){return wo})),n.d(e,"ToneEvent",(function(){return ao})),n.d(e,"AutoFilter",(function(){return So})),n.d(e,"AutoPanner",(function(){return To})),n.d(e,"AutoWah",(function(){return Ao})),n.d(e,"BitCrusher",(function(){return No})),n.d(e,"Chebyshev",(function(){return Eo})),n.d(e,"Chorus",(function(){return Po})),n.d(e,"Distortion",(function(){return Fo})),n.d(e,"FeedbackDelay",(function(){return Lo})),n.d(e,"FrequencyShifter",(function(){return Bo})),n.d(e,"Freeverb",(function(){return Uo})),n.d(e,"JCReverb",(function(){return Ko})),n.d(e,"PingPongDelay",(function(){return Xo})),n.d(e,"PitchShift",(function(){return Yo})),n.d(e,"Phaser",(function(){return Jo})),n.d(e,"Reverb",(function(){return Zo})),n.d(e,"StereoWidener",(function(){return ru})),n.d(e,"Tremolo",(function(){return iu})),n.d(e,"Vibrato",(function(){return su})),n.d(e,"Analyser",(function(){return au})),n.d(e,"Meter",(function(){return uu})),n.d(e,"FFT",(function(){return cu})),n.d(e,"DCMeter",(function(){return lu})),n.d(e,"Waveform",(function(){return hu})),n.d(e,"Follower",(function(){return Co})),n.d(e,"Channel",(function(){return fu})),n.d(e,"CrossFade",(function(){return xo})),n.d(e,"Merge",(function(){return Mo})),n.d(e,"MidSideMerge",(function(){return eu})),n.d(e,"MidSideSplit",(function(){return tu})),n.d(e,"MultibandSplit",(function(){return mu})),n.d(e,"Panner",(function(){return ko})),n.d(e,"Panner3D",(function(){return bu})),n.d(e,"PanVol",(function(){return pu})),n.d(e,"Recorder",(function(){return yu})),n.d(e,"Solo",(function(){return du})),n.d(e,"Split",(function(){return jo})),n.d(e,"Volume",(function(){return qs})),n.d(e,"Compressor",(function(){return vu})),n.d(e,"Gate",(function(){return wu})),n.d(e,"Limiter",(function(){return xu})),n.d(e,"MidSideCompressor",(function(){return _u})),n.d(e,"MultibandCompressor",(function(){return Ou})),n.d(e,"AmplitudeEnvelope",(function(){return Pa})),n.d(e,"Envelope",(function(){return ja})),n.d(e,"FrequencyEnvelope",(function(){return qa})),n.d(e,"EQ3",(function(){return Su})),n.d(e,"Filter",(function(){return Ba})),n.d(e,"OnePoleFilter",(function(){return eo})),n.d(e,"FeedbackCombFilter",(function(){return to})),n.d(e,"LowpassCombFilter",(function(){return no})),n.d(e,"Convolver",(function(){return ku})),n.d(e,"BiquadFilter",(function(){return $a})),n.d(e,"version",(function(){return s})),n.d(e,"start",(function(){return Zi})),n.d(e,"supported",(function(){return Jr})),n.d(e,"now",(function(){return Tu})),n.d(e,"immediate",(function(){return Cu})),n.d(e,"Transport",(function(){return Au})),n.d(e,"getTransport",(function(){return Nu})),n.d(e,"Destination",(function(){return Iu})),n.d(e,"Master",(function(){return Eu})),n.d(e,"getDestination",(function(){return ju})),n.d(e,"Listener",(function(){return Mu})),n.d(e,"getListener",(function(){return Du})),n.d(e,"Draw",(function(){return Ru})),n.d(e,"getDraw",(function(){return Pu})),n.d(e,"context",(function(){return Fu})),n.d(e,"loaded",(function(){return zu})),n.d(e,"Buffer",(function(){return Lu})),n.d(e,"Buffers",(function(){return $u})),n.d(e,"BufferSource",(function(){return Bu}));var r={};n.r(r),n.d(r,"assert",(function(){return Zr})),n.d(r,"assertRange",(function(){return ti})),n.d(r,"assertContextRunning",(function(){return ei})),n.d(r,"setLogger",(function(){return ri})),n.d(r,"log",(function(){return ii})),n.d(r,"warn",(function(){return si}));var i={};n.r(i);const s="14.7.58";var a=n(90);const o=new WeakSet,u=new WeakMap,c=new WeakMap,l=new WeakMap,h=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakMap,m=new WeakMap,g=new WeakMap,b={construct:()=>b},y=/^import(?:(?:[\s]+[\w]+|(?:[\s]+[\w]+[\s]*,)?[\s]*\{[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?(?:[\s]*,[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?)*[\s]*}|(?:[\s]+[\w]+[\s]*,)?[\s]*\*[\s]+as[\s]+[\w]+)[\s]+from)?(?:[\s]*)("([^"\\]|\\.)+"|'([^'\\]|\\.)+')(?:[\s]*);?/,v=(t,e)=>{const n=[];let r=t.replace(/^[\s]+/,""),i=r.match(y);for(;null!==i;){const t=i[1].slice(1,-1),s=i[0].replace(/([\s]+)?;?$/,"").replace(t,new URL(t,e).toString());n.push(s),r=r.slice(i[0].length).replace(/^[\s]+/,""),i=r.match(y)}return[n.join(";"),r]},w=t=>{if(void 0!==t&&!Array.isArray(t))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},x=t=>{if(!(t=>{try{new new Proxy(t,b)}catch{return!1}return!0})(t))throw new TypeError("The given value for processorCtor should be a constructor.");if(null===t.prototype||"object"!=typeof t.prototype)throw new TypeError("The given value for processorCtor should have a prototype.")},_=(t,e)=>{const n=t.get(e);if(void 0===n)throw new Error("A value with the given key could not be found.");return n},O=(t,e)=>{const n=Array.from(t).filter(e);if(n.length>1)throw Error("More than one element was found.");if(0===n.length)throw Error("No element was found.");const[r]=n;return t.delete(r),r},S=(t,e,n,r)=>{const i=_(t,e),s=O(i,t=>t[0]===n&&t[1]===r);return 0===i.size&&t.delete(e),s},k=t=>_(p,t),T=t=>{if(o.has(t))throw new Error("The AudioNode is already stored.");o.add(t),k(t).forEach(t=>t(!0))},C=t=>"port"in t,A=t=>{if(!o.has(t))throw new Error("The AudioNode is not stored.");o.delete(t),k(t).forEach(t=>t(!1))},N=(t,e)=>{!C(t)&&e.every(t=>0===t.size)&&A(t)},I={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},E=(t,e)=>t.context===e,j=t=>{try{t.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},M=()=>new DOMException("","IndexSizeError"),D=t=>{var e;t.getChannelData=(e=t.getChannelData,n=>{try{return e.call(t,n)}catch(t){if(12===t.code)throw M();throw t}})},R={numberOfChannels:1},P=-34028234663852886e22,F=-P,z=t=>o.has(t),L={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},$=t=>_(u,t),B=t=>_(l,t),q=(t,e)=>{const{activeInputs:n}=$(t);n.forEach(n=>n.forEach(([n])=>{e.includes(t)||q(n,[...e,t])}));const r=(t=>"playbackRate"in t)(t)?[t.playbackRate]:C(t)?Array.from(t.parameters.values()):(t=>"frequency"in t&&"gain"in t)(t)?[t.Q,t.detune,t.frequency,t.gain]:(t=>"offset"in t)(t)?[t.offset]:(t=>!("frequency"in t)&&"gain"in t)(t)?[t.gain]:(t=>"detune"in t&&"frequency"in t)(t)?[t.detune,t.frequency]:(t=>"pan"in t)(t)?[t.pan]:[];for(const t of r){const n=B(t);void 0!==n&&n.activeInputs.forEach(([t])=>q(t,e))}z(t)&&A(t)},V=t=>{q(t.destination,[])},U=t=>void 0===t||"number"==typeof t||"string"==typeof t&&("balanced"===t||"interactive"===t||"playback"===t),W=t=>"context"in t,G=t=>W(t[0]),H=(t,e,n,r)=>{for(const e of t)if(n(e)){if(r)return!1;throw Error("The set contains at least one similar element.")}return t.add(e),!0},K=(t,e,[n,r],i)=>{H(t,[e,n,r],t=>t[0]===e&&t[1]===n,i)},Q=(t,[e,n,r],i)=>{const s=t.get(e);void 0===s?t.set(e,new Set([[n,r]])):H(s,[n,r],t=>t[0]===n,i)},X=t=>"inputs"in t,Y=(t,e,n,r)=>{if(X(e)){const i=e.inputs[r];return t.connect(i,n,0),[i,n,0]}return t.connect(e,n,r),[e,n,r]},J=(t,e,n)=>{for(const r of t)if(r[0]===e&&r[1]===n)return t.delete(r),r;return null},Z=(t,e)=>{if(!k(t).delete(e))throw new Error("Missing the expected event listener.")},tt=(t,e,n)=>{const r=_(t,e),i=O(r,t=>t[0]===n);return 0===r.size&&t.delete(e),i},et=(t,e,n,r)=>{X(e)?t.disconnect(e.inputs[r],n,0):t.disconnect(e,n,r)},nt=t=>_(c,t),rt=t=>_(h,t),it=t=>f.has(t),st=t=>!o.has(t),at=t=>new Promise(e=>{const n=t.createScriptProcessor(256,1,1),r=t.createGain(),i=t.createBuffer(1,2,44100),s=i.getChannelData(0);s[0]=1,s[1]=1;const a=t.createBufferSource();a.buffer=i,a.loop=!0,a.connect(n).connect(t.destination),a.connect(r),a.disconnect(r),n.onaudioprocess=r=>{const i=r.inputBuffer.getChannelData(0);Array.prototype.some.call(i,t=>1===t)?e(!0):e(!1),a.stop(),n.onaudioprocess=null,a.disconnect(n),n.disconnect(t.destination)},a.start()}),ot=(t,e)=>{const n=new Map;for(const e of t)for(const t of e){const e=n.get(t);n.set(t,void 0===e?1:e+1)}n.forEach((t,n)=>e(n,t))},ut=t=>"context"in t,ct=(t,e,n,r)=>{const{activeInputs:i,passiveInputs:s}=B(e),{outputs:a}=$(t),o=k(t),u=a=>{const o=nt(t),u=rt(e);if(a){const e=tt(s,t,n);K(i,t,e,!1),r||it(t)||o.connect(u,n)}else{const e=((t,e,n)=>O(t,t=>t[0]===e&&t[1]===n))(i,t,n);Q(s,e,!1),r||it(t)||o.disconnect(u,n)}};return!!H(a,[e,n],t=>t[0]===e&&t[1]===n,!0)&&(o.add(u),z(t)?K(i,t,[n,u],!0):Q(s,[t,n,u],!0),!0)},lt=(t,e,n,r,i)=>{const[s,a]=((t,e,n,r)=>{const{activeInputs:i,passiveInputs:s}=$(e),a=J(i[r],t,n);if(null===a){return[S(s,t,n,r)[2],!1]}return[a[2],!0]})(t,n,r,i);if(null!==s&&(Z(t,s),!a||e||it(t)||et(nt(t),nt(n),r,i)),z(n)){const{activeInputs:t}=$(n);N(n,t)}},ht=(t,e,n,r)=>{const[i,s]=((t,e,n)=>{const{activeInputs:r,passiveInputs:i}=B(e),s=J(r,t,n);if(null===s){return[tt(i,t,n)[1],!1]}return[s[2],!0]})(t,n,r);null!==i&&(Z(t,i),!s||e||it(t)||nt(t).disconnect(rt(n),r))};class dt{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach((n,r)=>t.call(e,n,r,this))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}}const pt={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}};function ft(t,e,n,r,i){if("function"==typeof t.copyFromChannel)0===e[n].byteLength&&(e[n]=new Float32Array(128)),t.copyFromChannel(e[n],r,i);else{const s=t.getChannelData(r);if(0===e[n].byteLength)e[n]=s.slice(i,i+128);else{const t=new Float32Array(s.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[n].set(t)}}}const mt=(t,e,n,r,i)=>{"function"==typeof t.copyToChannel?0!==e[n].byteLength&&t.copyToChannel(e[n],r,i):0!==e[n].byteLength&&t.getChannelData(r).set(e[n],i)},gt=(t,e)=>{const n=[];for(let r=0;r<t;r+=1){const t=[],i="number"==typeof e?e:e[r];for(let e=0;e<i;e+=1)t.push(new Float32Array(128));n.push(t)}return n},bt=async(t,e,n,r,i,s,a)=>{const o=null===e?128*Math.ceil(t.context.length/128):e.length,u=r.channelCount*r.numberOfInputs,c=i.reduce((t,e)=>t+e,0),l=0===c?null:n.createBuffer(c,o,n.sampleRate);if(void 0===s)throw new Error("Missing the processor constructor.");const h=$(t),d=await((t,e)=>{const n=_(g,t),r=nt(e);return _(n,r)})(n,t),p=gt(r.numberOfInputs,r.channelCount),f=gt(r.numberOfOutputs,i),m=Array.from(t.parameters.keys()).reduce((t,e)=>({...t,[e]:new Float32Array(128)}),{});for(let c=0;c<o;c+=128){if(r.numberOfInputs>0&&null!==e)for(let t=0;t<r.numberOfInputs;t+=1)for(let n=0;n<r.channelCount;n+=1)ft(e,p[t],n,n,c);void 0!==s.parameterDescriptors&&null!==e&&s.parameterDescriptors.forEach(({name:t},n)=>{ft(e,m,t,u+n,c)});for(let t=0;t<r.numberOfInputs;t+=1)for(let e=0;e<i[t];e+=1)0===f[t][e].byteLength&&(f[t][e]=new Float32Array(128));try{const t=p.map((t,e)=>0===h.activeInputs[e].size?[]:t),e=a(c/n.sampleRate,n.sampleRate,()=>d.process(t,f,m));if(null!==l)for(let t=0,e=0;t<r.numberOfOutputs;t+=1){for(let n=0;n<i[t];n+=1)mt(l,f[t],n,e+n,c);e+=i[t]}if(!e)break}catch(e){t.dispatchEvent(new ErrorEvent("processorerror",{colno:e.colno,filename:e.filename,lineno:e.lineno,message:e.message}));break}}return l},yt={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},vt={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},wt={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},xt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},_t={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},Ot={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},St=(t,e,n)=>{const r=e[n];if(void 0===r)throw t();return r},kt={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},Tt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},Ct=()=>new DOMException("","InvalidStateError"),At=()=>new DOMException("","InvalidAccessError"),Nt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},It=(t,e,n,r,i,s,a,o,u,c,l)=>{const h=c.length;let d=o;for(let o=0;o<h;o+=1){let h=n[0]*c[o];for(let e=1;e<i;e+=1){const r=d-e&u-1;h+=n[e]*s[r],h-=t[e]*a[r]}for(let t=i;t<r;t+=1)h+=n[t]*s[d-t&u-1];for(let n=i;n<e;n+=1)h-=t[n]*a[d-n&u-1];s[d]=c[o],a[d]=h,d=d+1&u-1,l[o]=h}return d},Et={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},jt=t=>{const e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const n=t.decodeAudioData(e.buffer,()=>{});return void 0!==n&&(n.catch(()=>{}),!0)}catch{}return!1},Mt={numberOfChannels:1},Dt=(t,e,n)=>{const r=e[n];void 0!==r&&r!==t[n]&&(t[n]=r)},Rt=(t,e)=>{Dt(t,e,"channelCount"),Dt(t,e,"channelCountMode"),Dt(t,e,"channelInterpretation")},Pt=t=>"function"==typeof t.getFloatTimeDomainData,Ft=(t,e,n)=>{const r=e[n];void 0!==r&&r!==t[n].value&&(t[n].value=r)},zt=t=>{var e;t.start=(e=t.start,(n=0,r=0,i)=>{if("number"==typeof i&&i<0||r<0||n<0)throw new RangeError("The parameters can't be negative.");e.call(t,n,r,i)})},Lt=t=>{var e;t.stop=(e=t.stop,(n=0)=>{if(n<0)throw new RangeError("The parameter can't be negative.");e.call(t,n)})},$t=(t,e)=>null===t?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(t*e))))),Bt=async(t,e)=>new t(await(t=>new Promise((e,n)=>{const{port1:r,port2:i}=new MessageChannel;r.onmessage=({data:t})=>{r.close(),i.close(),e(t)},r.onmessageerror=({data:t})=>{r.close(),i.close(),n(t)},i.postMessage(t)}))(e)),qt=(t,e)=>{const n=t.createBiquadFilter();return Rt(n,e),Ft(n,e,"Q"),Ft(n,e,"detune"),Ft(n,e,"frequency"),Ft(n,e,"gain"),Dt(n,e,"type"),n},Vt=(t,e)=>{const n=t.createChannelSplitter(e.numberOfOutputs);return Rt(n,e),(t=>{const e=t.numberOfOutputs;Object.defineProperty(t,"channelCount",{get:()=>e,set:t=>{if(t!==e)throw Ct()}}),Object.defineProperty(t,"channelCountMode",{get:()=>"explicit",set:t=>{if("explicit"!==t)throw Ct()}}),Object.defineProperty(t,"channelInterpretation",{get:()=>"discrete",set:t=>{if("discrete"!==t)throw Ct()}})})(n),n},Ut=(t,e)=>(t.connect=e.connect.bind(e),t.disconnect=e.disconnect.bind(e),t),Wt=(t,e)=>{const n=t.createDelay(e.maxDelayTime);return Rt(n,e),Ft(n,e,"delayTime"),n},Gt=(t,e)=>{const n=t.createGain();return Rt(n,e),Ft(n,e,"gain"),n};function Ht(t,e){const n=e[0]*e[0]+e[1]*e[1];return[(t[0]*e[0]+t[1]*e[1])/n,(t[1]*e[0]-t[0]*e[1])/n]}function Kt(t,e){let n=[0,0];for(let s=t.length-1;s>=0;s-=1)i=e,n=[(r=n)[0]*i[0]-r[1]*i[1],r[0]*i[1]+r[1]*i[0]],n[0]+=t[s];var r,i;return n}const Qt=(t,e,n,r)=>t.createScriptProcessor(e,n,r),Xt=()=>new DOMException("","NotSupportedError"),Yt={numberOfChannels:1},Jt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},Zt={channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0,distanceModel:"inverse",maxDistance:1e4,orientationX:1,orientationY:0,orientationZ:0,panningModel:"equalpower",positionX:0,positionY:0,positionZ:0,refDistance:1,rolloffFactor:1},te={disableNormalization:!1},ee={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},ne=()=>new DOMException("","UnknownError"),re={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},ie=t=>{if(null===t)return!1;const e=t.length;return e%2!=0?0!==t[Math.floor(e/2)]:t[e/2-1]+t[e/2]!==0},se=(t,e,n,r)=>{let i=Object.getPrototypeOf(t);for(;!i.hasOwnProperty(e);)i=Object.getPrototypeOf(i);const{get:s,set:a}=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,{get:n(s),set:r(a)})},ae=t=>{const e=t.createOscillator();try{e.start(-1)}catch(t){return t instanceof RangeError}return!1},oe=t=>{const e=t.createBuffer(1,1,44100),n=t.createBufferSource();n.buffer=e,n.start(),n.stop();try{return n.stop(),!0}catch{return!1}},ue=t=>{const e=t.createOscillator();try{e.stop(-1)}catch(t){return t instanceof RangeError}return!1},ce=()=>{try{new DOMException}catch{return!1}return!0},le=()=>new Promise(t=>{const e=new ArrayBuffer(0),{port1:n,port2:r}=new MessageChannel;n.onmessage=({data:e})=>t(null!==e),r.postMessage(e,[e])}),he=(t,e)=>{const n=e.createGain();t.connect(n);const r=(i=t.disconnect,()=>{i.call(t,n),t.removeEventListener("ended",r)});var i;t.addEventListener("ended",r),Ut(t,n),t.stop=(e=>{let r=!1;return(i=0)=>{if(r)try{e.call(t,i)}catch{n.gain.setValueAtTime(0,i)}else e.call(t,i),r=!0}})(t.stop)},de=(t,e)=>n=>{const r={value:t};return Object.defineProperties(n,{currentTarget:r,target:r}),"function"==typeof e?e.call(t,n):e.handleEvent.call(t,n)},pe=(fe=H,(t,e,[n,r,i],s)=>{fe(t[r],[e,n,i],t=>t[0]===e&&t[1]===n,s)});var fe;const me=(t=>(e,n,[r,i,s],a)=>{const o=e.get(r);void 0===o?e.set(r,new Set([[i,n,s]])):t(o,[i,n,s],t=>t[0]===i&&t[1]===n,a)})(H),ge=(t=>(e,n,r,i)=>t(e[i],t=>t[0]===n&&t[1]===r))(O),be=new WeakMap,ye=(t=>e=>{var n;return null!==(n=t.get(e))&&void 0!==n?n:0})(be),ve=(we=new Map,xe=new WeakMap,(t,e)=>{const n=xe.get(t);if(void 0!==n)return n;const r=we.get(t);if(void 0!==r)return r;try{const n=e();return n instanceof Promise?(we.set(t,n),n.catch(()=>!1).then(e=>(we.delete(t),xe.set(t,e),e))):(xe.set(t,n),n)}catch{return xe.set(t,!1),!1}});var we,xe;const _e="undefined"==typeof window?null:window,Oe=(Se=ve,ke=M,(t,e)=>{const n=t.createAnalyser();if(Rt(n,e),!(e.maxDecibels>e.minDecibels))throw ke();return Dt(n,e,"fftSize"),Dt(n,e,"maxDecibels"),Dt(n,e,"minDecibels"),Dt(n,e,"smoothingTimeConstant"),Se(Pt,()=>Pt(n))||(t=>{t.getFloatTimeDomainData=e=>{const n=new Uint8Array(e.length);t.getByteTimeDomainData(n);const r=Math.max(n.length,t.fftSize);for(let t=0;t<r;t+=1)e[t]=.0078125*(n[t]-128);return e}})(n),n});var Se,ke;const Te=(Ce=$,t=>{const e=Ce(t);if(null===e.renderer)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return e.renderer});var Ce;const Ae=((t,e,n)=>async(r,i,s,a)=>{const o=t(r),u=[...a,r];await Promise.all(o.activeInputs.map((t,a)=>Array.from(t).filter(([t])=>!u.includes(t)).map(async([t,o])=>{const c=e(t),l=await c.render(t,i,u),h=r.context.destination;n(t)||r===h&&n(r)||l.connect(s,o,a)})).reduce((t,e)=>[...t,...e],[]))})($,Te,it),Ne=(Ie=Oe,Ee=nt,je=Ae,()=>{const t=new WeakMap;return{render(e,n,r){const i=t.get(n);return void 0!==i?Promise.resolve(i):(async(e,n,r)=>{let i=Ee(e);if(!E(i,n)){const t={channelCount:i.channelCount,channelCountMode:i.channelCountMode,channelInterpretation:i.channelInterpretation,fftSize:i.fftSize,maxDecibels:i.maxDecibels,minDecibels:i.minDecibels,smoothingTimeConstant:i.smoothingTimeConstant};i=Ie(n,t)}return t.set(n,i),await je(e,n,i,r),i})(e,n,r)}}});var Ie,Ee,je;const Me=(De=d,t=>{const e=De.get(t);if(void 0===e)throw Ct();return e});var De;const Re=(t=>null===t?null:t.hasOwnProperty("OfflineAudioContext")?t.OfflineAudioContext:t.hasOwnProperty("webkitOfflineAudioContext")?t.webkitOfflineAudioContext:null)(_e),Pe=(Fe=Re,t=>null!==Fe&&t instanceof Fe);var Fe;const ze=new WeakMap,Le=($e=de,class{constructor(t){this._nativeEventTarget=t,this._listeners=new WeakMap}addEventListener(t,e,n){if(null!==e){let r=this._listeners.get(e);void 0===r&&(r=$e(this,e),"function"==typeof e&&this._listeners.set(e,r)),this._nativeEventTarget.addEventListener(t,r,n)}}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,e,n){const r=null===e?void 0:this._listeners.get(e);this._nativeEventTarget.removeEventListener(t,void 0===r?null:r,n)}});var $e;const Be=(t=>null===t?null:t.hasOwnProperty("AudioContext")?t.AudioContext:t.hasOwnProperty("webkitAudioContext")?t.webkitAudioContext:null)(_e),qe=(Ve=Be,t=>null!==Ve&&t instanceof Ve);var Ve;const Ue=(t=>e=>null!==t&&"function"==typeof t.AudioNode&&e instanceof t.AudioNode)(_e),We=(t=>e=>null!==t&&"function"==typeof t.AudioParam&&e instanceof t.AudioParam)(_e),Ge=((t,e,n,r,i,s,a,o,u,l,h,d,f,m,g)=>class extends l{constructor(e,r,i,s){super(i),this._context=e,this._nativeAudioNode=i;const a=h(e);d(a)&&!0!==n(at,()=>at(a))&&(t=>{const e=new Map;var n,r;t.connect=(n=t.connect.bind(t),(t,r=0,i=0)=>{const s=ut(t)?n(t,r,i):n(t,r),a=e.get(t);return void 0===a?e.set(t,[{input:i,output:r}]):a.every(t=>t.input!==i||t.output!==r)&&a.push({input:i,output:r}),s}),t.disconnect=(r=t.disconnect,(n,i,s)=>{if(r.apply(t),void 0===n)e.clear();else if("number"==typeof n)for(const[t,r]of e){const i=r.filter(t=>t.output!==n);0===i.length?e.delete(t):e.set(t,i)}else if(e.has(n))if(void 0===i)e.delete(n);else{const t=e.get(n);if(void 0!==t){const r=t.filter(t=>t.output!==i&&(t.input!==s||void 0===s));0===r.length?e.delete(n):e.set(n,r)}}for(const[n,r]of e)r.forEach(e=>{ut(n)?t.connect(n,e.output,e.input):t.connect(n,e.output)})})})(i),c.set(this,i),p.set(this,new Set),"closed"!==e.state&&r&&T(this),t(this,s,i)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(t){this._nativeAudioNode.channelCount=t}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(t){this._nativeAudioNode.channelCountMode=t}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(t){this._nativeAudioNode.channelInterpretation=t}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(t,n=0,o=0){if(n<0||n>=this._nativeAudioNode.numberOfOutputs)throw i();const c=h(this._context),l=g(c);if(f(t)||m(t))throw s();if(W(t)){const i=nt(t);try{const e=Y(this._nativeAudioNode,i,n,o),r=st(this);(l||r)&&this._nativeAudioNode.disconnect(...e),"closed"!==this.context.state&&!r&&st(t)&&T(t)}catch(t){if(12===t.code)throw s();throw t}if(e(this,t,n,o,l)){const e=u([this],t);ot(e,r(l))}return t}const d=rt(t);if("playbackRate"===d.name)throw a();try{this._nativeAudioNode.connect(d,n),(l||st(this))&&this._nativeAudioNode.disconnect(d,n)}catch(t){if(12===t.code)throw s();throw t}if(ct(this,t,n,l)){const e=u([this],t);ot(e,r(l))}}disconnect(t,e,n){let r;const a=h(this._context),c=g(a);if(void 0===t)r=((t,e)=>{const n=$(t),r=[];for(const i of n.outputs)G(i)?lt(t,e,...i):ht(t,e,...i),r.push(i[0]);return n.outputs.clear(),r})(this,c);else if("number"==typeof t){if(t<0||t>=this.numberOfOutputs)throw i();r=((t,e,n)=>{const r=$(t),i=[];for(const s of r.outputs)s[1]===n&&(G(s)?lt(t,e,...s):ht(t,e,...s),i.push(s[0]),r.outputs.delete(s));return i})(this,c,t)}else{if(void 0!==e&&(e<0||e>=this.numberOfOutputs))throw i();if(W(t)&&void 0!==n&&(n<0||n>=t.numberOfInputs))throw i();if(r=((t,e,n,r,i)=>{const s=$(t);return Array.from(s.outputs).filter(t=>!(t[0]!==n||void 0!==r&&t[1]!==r||void 0!==i&&t[2]!==i)).map(n=>(G(n)?lt(t,e,...n):ht(t,e,...n),s.outputs.delete(n),n[0]))})(this,c,t,e,n),0===r.length)throw s()}for(const t of r){const e=u([this],t);ot(e,o)}}})((He=u,(t,e,n)=>{const r=[];for(let t=0;t<n.numberOfInputs;t+=1)r.push(new Set);He.set(t,{activeInputs:r,outputs:new Set,passiveInputs:new WeakMap,renderer:e})}),((t,e,n,r,i,s,a,o,u,c,l,h,d)=>(p,f,m,g,b)=>{const{activeInputs:y,passiveInputs:v}=s(f),{outputs:w}=s(p),x=o(p),_=s=>{const o=u(f),c=u(p);if(s){const e=S(v,p,m,g);t(y,p,e,!1),b||h(p)||n(c,o,m,g),d(f)&&T(f)}else{const t=r(y,p,m,g);e(v,g,t,!1),b||h(p)||i(c,o,m,g);const n=a(f);0===n?l(f)&&N(f,y):setTimeout(()=>{l(f)&&N(f,y)},1e3*n)}};return!!c(w,[f,m,g],t=>t[0]===f&&t[1]===m&&t[2]===g,!0)&&(x.add(_),l(p)?t(y,p,[m,g,_],!0):e(v,g,[p,m,_],!0),!0)})(pe,me,Y,ge,et,$,ye,k,nt,H,z,it,st),ve,((t,e,n,r,i,s)=>a=>(o,u)=>{const c=t.get(o);if(void 0===c){if(!a&&s(o)){const t=r(o),{outputs:s}=n(o);for(const n of s)if(G(n)){const i=r(n[0]);e(t,i,n[1],n[2])}else{const e=i(n[0]);t.disconnect(e,n[1])}}t.set(o,u)}else t.set(o,c+u)})(f,et,$,nt,rt,z),M,At,Xt,((t,e,n,r,i,s,a,o)=>(u,c)=>{const l=e.get(u);if(void 0===l)throw new Error("Missing the expected cycle count.");const h=s(u.context),d=o(h);if(l===c){if(e.delete(u),!d&&a(u)){const e=r(u),{outputs:s}=n(u);for(const n of s)if(G(n)){const i=r(n[0]);t(e,i,n[1],n[2])}else{const t=i(n[0]);e.connect(t,n[1])}}}else e.set(u,l-c)})(Y,f,$,nt,rt,Me,z,Pe),((t,e,n)=>function r(i,s){const a=W(s)?s:n(t,s);if((t=>"delayTime"in t)(a))return[];if(i[0]===a)return[i];if(i.includes(a))return[];const{outputs:o}=e(a);return Array.from(o).map(t=>r([...i,a],t[0])).reduce((t,e)=>t.concat(e),[])})(ze,$,_),Le,Me,qe,Ue,We,Pe);var He;const Ke=((t,e,n,r,i,s)=>class extends t{constructor(t,n){const a=i(t),o={...I,...n},u=r(a,o);super(t,!1,u,s(a)?e():null),this._nativeAnalyserNode=u}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(t){this._nativeAnalyserNode.fftSize=t}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(t){const e=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=t,!(t>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=e,n()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(t){const e=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=t,!(this._nativeAnalyserNode.maxDecibels>t))throw this._nativeAnalyserNode.minDecibels=e,n()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(t){this._nativeAnalyserNode.smoothingTimeConstant=t}getByteFrequencyData(t){this._nativeAnalyserNode.getByteFrequencyData(t)}getByteTimeDomainData(t){this._nativeAnalyserNode.getByteTimeDomainData(t)}getFloatFrequencyData(t){this._nativeAnalyserNode.getFloatFrequencyData(t)}getFloatTimeDomainData(t){this._nativeAnalyserNode.getFloatTimeDomainData(t)}})(Ge,Ne,M,Oe,Me,Pe),Qe=new WeakSet,Xe=(t=>null===t?null:t.hasOwnProperty("AudioBuffer")?t.AudioBuffer:null)(_e),Ye=(Je=new Uint32Array(1),t=>(Je[0]=t,Je[0]));var Je;const Ze=((t,e)=>n=>{n.copyFromChannel=(r,i,s=0)=>{const a=t(s),o=t(i);if(o>=n.numberOfChannels)throw e();const u=n.length,c=n.getChannelData(o),l=r.length;for(let t=a<0?-a:0;t+a<u&&t<l;t+=1)r[t]=c[t+a]},n.copyToChannel=(r,i,s=0)=>{const a=t(s),o=t(i);if(o>=n.numberOfChannels)throw e();const u=n.length,c=n.getChannelData(o),l=r.length;for(let t=a<0?-a:0;t+a<u&&t<l;t+=1)c[t+a]=r[t]}})(Ye,M),tn=(t=>e=>{e.copyFromChannel=(n=>(r,i,s=0)=>{const a=t(s),o=t(i);if(a<e.length)return n.call(e,r,o,a)})(e.copyFromChannel),e.copyToChannel=(n=>(r,i,s=0)=>{const a=t(s),o=t(i);if(a<e.length)return n.call(e,r,o,a)})(e.copyToChannel)})(Ye),en=((t,e,n,r,i,s,a,o)=>{let u=null;return class c{constructor(c){if(null===i)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:l,numberOfChannels:h,sampleRate:d}={...R,...c};null===u&&(u=new i(1,1,44100));const p=null!==r&&e(s,s)?new r({length:l,numberOfChannels:h,sampleRate:d}):u.createBuffer(h,l,d);if(0===p.numberOfChannels)throw n();return"function"!=typeof p.copyFromChannel?(a(p),D(p)):e(j,()=>j(p))||o(p),t.add(p),p}static[Symbol.hasInstance](e){return null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===c.prototype||t.has(e)}}})(Qe,ve,Xt,Xe,Re,(nn=Xe,()=>{if(null===nn)return!1;try{new nn({length:1,sampleRate:44100})}catch{return!1}return!0}),Ze,tn);var nn;const rn=(sn=Gt,(t,e)=>{const n=sn(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});e.connect(n).connect(t.destination);const r=()=>{e.removeEventListener("ended",r),e.disconnect(n),n.disconnect()};e.addEventListener("ended",r)});var sn;const an=((t,e,n)=>async(r,i,s,a)=>{const o=e(r);await Promise.all(Array.from(o.activeInputs).map(async([e,r])=>{const o=t(e),u=await o.render(e,i,a);n(e)||u.connect(s,r)}))})(Te,B,it),on=(t=>(e,n,r,i)=>t(n,e,r,i))(an),un=((t,e,n,r,i,s,a,o,u,c,l)=>(h,d)=>{const p=h.createBufferSource();return Rt(p,d),Ft(p,d,"playbackRate"),Dt(p,d,"buffer"),Dt(p,d,"loop"),Dt(p,d,"loopEnd"),Dt(p,d,"loopStart"),e(n,()=>n(h))||(t=>{t.start=(e=>{let n=!1;return(r=0,i=0,s)=>{if(n)throw Ct();e.call(t,r,i,s),n=!0}})(t.start)})(p),e(r,()=>r(h))||u(p),e(i,()=>i(h))||c(p,h),e(s,()=>s(h))||zt(p),e(a,()=>a(h))||l(p,h),e(o,()=>o(h))||Lt(p),t(h,p),p})(rn,ve,t=>{const e=t.createBufferSource();e.start();try{e.start()}catch{return!0}return!1},t=>{const e=t.createBufferSource(),n=t.createBuffer(1,1,44100);e.buffer=n;try{e.start(0,1)}catch{return!1}return!0},t=>{const e=t.createBufferSource();e.start();try{e.stop()}catch{return!1}return!0},ae,oe,ue,t=>{var e;t.start=(e=t.start,(n=0,r=0,i)=>{const s=t.buffer,a=null===s?r:Math.min(s.duration,r);null!==s&&a>s.duration-.5/t.context.sampleRate?e.call(t,n,0,0):e.call(t,n,a,i)})},(cn=se,(t,e)=>{const n=e.createBuffer(1,1,44100);null===t.buffer&&(t.buffer=n),cn(t,"buffer",e=>()=>{const r=e.call(t);return r===n?null:r},e=>r=>e.call(t,null===r?n:r))}),he);var cn;const ln=((t,e)=>(n,r,i,s)=>(t(r).replay(i),e(r,n,i,s)))((t=>e=>{const n=t(e);if(null===n.renderer)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return n.renderer})(B),an),hn=((t,e,n,r,i)=>()=>{const s=new WeakMap;let a=null,o=null;return{set start(t){a=t},set stop(t){o=t},render(u,c,l){const h=s.get(c);return void 0!==h?Promise.resolve(h):(async(u,c,l)=>{let h=n(u);const d=E(h,c);if(!d){const t={buffer:h.buffer,channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,loop:h.loop,loopEnd:h.loopEnd,loopStart:h.loopStart,playbackRate:h.playbackRate.value};h=e(c,t),null!==a&&h.start(...a),null!==o&&h.stop(o)}return s.set(c,h),d?await t(c,u.playbackRate,h.playbackRate,l):await r(c,u.playbackRate,h.playbackRate,l),await i(u,c,h,l),h})(u,c,l)}}})(on,un,nt,ln,Ae),dn=((t,e,n,r,i,s,o,u,c,l,h,d)=>(p,f,m,g=null,b=null)=>{const y=new a.AutomationEventList(m.defaultValue),v=f?r(y):null,w={get defaultValue(){return m.defaultValue},get maxValue(){return null===g?m.maxValue:g},get minValue(){return null===b?m.minValue:b},get value(){return m.value},set value(t){m.value=t,w.setValueAtTime(t,p.context.currentTime)},cancelAndHoldAtTime(t){if("function"==typeof m.cancelAndHoldAtTime)null===v&&y.flush(p.context.currentTime),y.add(i(t)),m.cancelAndHoldAtTime(t);else{const e=Array.from(y).pop();null===v&&y.flush(p.context.currentTime),y.add(i(t));const n=Array.from(y).pop();m.cancelScheduledValues(t),e!==n&&void 0!==n&&("exponentialRampToValue"===n.type?m.exponentialRampToValueAtTime(n.value,n.endTime):"linearRampToValue"===n.type?m.linearRampToValueAtTime(n.value,n.endTime):"setValue"===n.type?m.setValueAtTime(n.value,n.startTime):"setValueCurve"===n.type&&m.setValueCurveAtTime(n.values,n.startTime,n.duration))}return w},cancelScheduledValues:t=>(null===v&&y.flush(p.context.currentTime),y.add(s(t)),m.cancelScheduledValues(t),w),exponentialRampToValueAtTime(t,e){if(0===t)throw new RangeError;if(!Number.isFinite(e)||e<0)throw new RangeError;return null===v&&y.flush(p.context.currentTime),y.add(o(t,e)),m.exponentialRampToValueAtTime(t,e),w},linearRampToValueAtTime:(t,e)=>(null===v&&y.flush(p.context.currentTime),y.add(u(t,e)),m.linearRampToValueAtTime(t,e),w),setTargetAtTime:(t,e,n)=>(null===v&&y.flush(p.context.currentTime),y.add(c(t,e,n)),m.setTargetAtTime(t,e,n),w),setValueAtTime:(t,e)=>(null===v&&y.flush(p.context.currentTime),y.add(l(t,e)),m.setValueAtTime(t,e),w),setValueCurveAtTime(t,e,n){const r=t instanceof Float32Array?t:new Float32Array(t);if(null!==d&&"webkitAudioContext"===d.name){const t=e+n,i=p.context.sampleRate,s=Math.ceil(e*i),a=Math.floor(t*i),o=a-s,u=new Float32Array(o);for(let t=0;t<o;t+=1){const a=(r.length-1)/n*((s+t)/i-e),o=Math.floor(a),c=Math.ceil(a);u[t]=o===c?r[o]:(1-(a-o))*r[o]+(1-(c-a))*r[c]}null===v&&y.flush(p.context.currentTime),y.add(h(u,e,n)),m.setValueCurveAtTime(u,e,n);const c=a/i;c<t&&w.setValueAtTime(u[u.length-1],c),w.setValueAtTime(r[r.length-1],t)}else null===v&&y.flush(p.context.currentTime),y.add(h(r,e,n)),m.setValueCurveAtTime(r,e,n);return w}};return n.set(w,m),e.set(w,p),t(w,v),w})((pn=l,(t,e)=>{pn.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})}),ze,h,t=>({replay(e){for(const n of t)if("exponentialRampToValue"===n.type){const{endTime:t,value:r}=n;e.exponentialRampToValueAtTime(r,t)}else if("linearRampToValue"===n.type){const{endTime:t,value:r}=n;e.linearRampToValueAtTime(r,t)}else if("setTarget"===n.type){const{startTime:t,target:r,timeConstant:i}=n;e.setTargetAtTime(r,t,i)}else if("setValue"===n.type){const{startTime:t,value:r}=n;e.setValueAtTime(r,t)}else{if("setValueCurve"!==n.type)throw new Error("Can't apply an unknown automation.");{const{duration:t,startTime:r,values:i}=n;e.setValueCurveAtTime(i,r,t)}}}}),a.createCancelAndHoldAutomationEvent,a.createCancelScheduledValuesAutomationEvent,a.createExponentialRampToValueAutomationEvent,a.createLinearRampToValueAutomationEvent,a.createSetTargetAutomationEvent,a.createSetValueAutomationEvent,a.createSetValueCurveAutomationEvent,Be);var pn;const fn=((t,e,n,r,i,s,a,o)=>class extends t{constructor(t,r){const o=s(t),u={...L,...r},c=i(o,u),l=a(o),h=l?e():null;super(t,!1,c,h),this._audioBufferSourceNodeRenderer=h,this._isBufferNullified=!1,this._isBufferSet=null!==u.buffer,this._nativeAudioBufferSourceNode=c,this._onended=null,this._playbackRate=n(this,l,c.playbackRate,F,P)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(t){if(this._nativeAudioBufferSourceNode.buffer=t,null!==t){if(this._isBufferSet)throw r();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(t){this._nativeAudioBufferSourceNode.loop=t}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(t){this._nativeAudioBufferSourceNode.loopEnd=t}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(t){this._nativeAudioBufferSourceNode.loopStart=t}get onended(){return this._onended}set onended(t){const e="function"==typeof t?o(this,t):null;this._nativeAudioBufferSourceNode.onended=e;const n=this._nativeAudioBufferSourceNode.onended;this._onended=null!==n&&n===e?t:n}get playbackRate(){return this._playbackRate}start(t=0,e=0,n){if(this._nativeAudioBufferSourceNode.start(t,e,n),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.start=void 0===n?[t,e]:[t,e,n]),"closed"!==this.context.state){T(this);const t=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",t),z(this)&&A(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeAudioBufferSourceNode.stop(t),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.stop=t)}})(Ge,hn,dn,Ct,un,Me,Pe,de),mn=((t,e,n,r,i,s,a,o)=>class extends t{constructor(t,n){const r=s(t),u=a(r),c=i(r,n,u);super(t,!1,c,u?e(o):null),this._isNodeOfNativeOfflineAudioContext=u,this._nativeAudioDestinationNode=c}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(t){if(this._isNodeOfNativeOfflineAudioContext)throw r();if(t>this._nativeAudioDestinationNode.maxChannelCount)throw n();this._nativeAudioDestinationNode.channelCount=t}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(t){if(this._isNodeOfNativeOfflineAudioContext)throw r();this._nativeAudioDestinationNode.channelCountMode=t}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}})(Ge,t=>{let e=null;return{render:(n,r,i)=>(null===e&&(e=(async(e,n,r)=>{const i=n.destination;return await t(e,n,i,r),i})(n,r,i)),e)}},M,Ct,((t,e)=>(n,r,i)=>{const s=n.destination;if(s.channelCount!==r)try{s.channelCount=r}catch{}i&&"explicit"!==s.channelCountMode&&(s.channelCountMode="explicit"),0===s.maxChannelCount&&Object.defineProperty(s,"maxChannelCount",{value:r});const a=t(n,{channelCount:r,channelCountMode:s.channelCountMode,channelInterpretation:s.channelInterpretation,gain:1});return e(a,"channelCount",t=>()=>t.call(a),t=>e=>{t.call(a,e);try{s.channelCount=e}catch(t){if(e>s.maxChannelCount)throw t}}),e(a,"channelCountMode",t=>()=>t.call(a),t=>e=>{t.call(a,e),s.channelCountMode=e}),e(a,"channelInterpretation",t=>()=>t.call(a),t=>e=>{t.call(a,e),s.channelInterpretation=e}),Object.defineProperty(a,"maxChannelCount",{get:()=>s.maxChannelCount}),a.connect(s),a})(Gt,se),Me,Pe,Ae),gn=((t,e,n,r,i)=>()=>{const s=new WeakMap;return{render(a,o,u){const c=s.get(o);return void 0!==c?Promise.resolve(c):(async(a,o,u)=>{let c=n(a);const l=E(c,o);if(!l){const t={Q:c.Q.value,channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,detune:c.detune.value,frequency:c.frequency.value,gain:c.gain.value,type:c.type};c=e(o,t)}return s.set(o,c),l?(await t(o,a.Q,c.Q,u),await t(o,a.detune,c.detune,u),await t(o,a.frequency,c.frequency,u),await t(o,a.gain,c.gain,u)):(await r(o,a.Q,c.Q,u),await r(o,a.detune,c.detune,u),await r(o,a.frequency,c.frequency,u),await r(o,a.gain,c.gain,u)),await i(a,o,c,u),c})(a,o,u)}}})(on,qt,nt,ln,Ae),bn=(t=>(e,n)=>t.set(e,n))(be),yn=(vn=Ge,wn=dn,xn=gn,_n=At,On=qt,Sn=Me,kn=Pe,Tn=bn,class extends vn{constructor(t,e){const n=Sn(t),r={...yt,...e},i=On(n,r),s=kn(n);super(t,!1,i,s?xn():null),this._Q=wn(this,s,i.Q,F,P),this._detune=wn(this,s,i.detune,1200*Math.log2(F),-1200*Math.log2(F)),this._frequency=wn(this,s,i.frequency,t.sampleRate/2,0),this._gain=wn(this,s,i.gain,40*Math.log10(F),P),this._nativeBiquadFilterNode=i,Tn(this,1)}get detune(){return this._detune}get frequency(){return this._frequency}get gain(){return this._gain}get Q(){return this._Q}get type(){return this._nativeBiquadFilterNode.type}set type(t){this._nativeBiquadFilterNode.type=t}getFrequencyResponse(t,e,n){if(this._nativeBiquadFilterNode.getFrequencyResponse(t,e,n),t.length!==e.length||e.length!==n.length)throw _n()}});var vn,wn,xn,_n,On,Sn,kn,Tn;const Cn=((t,e)=>(n,r,i)=>{const s=new Set;var a,o;return n.connect=(a=n.connect,(i,o=0,u=0)=>{const c=0===s.size;if(e(i))return a.call(n,i,o,u),t(s,[i,o,u],t=>t[0]===i&&t[1]===o&&t[2]===u,!0),c&&r(),i;a.call(n,i,o),t(s,[i,o],t=>t[0]===i&&t[1]===o,!0),c&&r()}),n.disconnect=(o=n.disconnect,(t,r,a)=>{const u=s.size>0;if(void 0===t)o.apply(n),s.clear();else if("number"==typeof t){o.call(n,t);for(const e of s)e[1]===t&&s.delete(e)}else{e(t)?o.call(n,t,r,a):o.call(n,t,r);for(const e of s)e[0]!==t||void 0!==r&&e[1]!==r||void 0!==a&&e[2]!==a||s.delete(e)}const c=0===s.size;u&&c&&i()}),n})(H,Ue),An=(Nn=Ct,In=Cn,(t,e)=>{e.channelCount=1,e.channelCountMode="explicit",Object.defineProperty(e,"channelCount",{get:()=>1,set:()=>{throw Nn()}}),Object.defineProperty(e,"channelCountMode",{get:()=>"explicit",set:()=>{throw Nn()}});const n=t.createBufferSource();In(e,()=>{const t=e.numberOfInputs;for(let r=0;r<t;r+=1)n.connect(e,0,r)},()=>n.disconnect(e))});var Nn,In;const En=((t,e)=>(n,r)=>{const i=n.createChannelMerger(r.numberOfInputs);return null!==t&&"webkitAudioContext"===t.name&&e(n,i),Rt(i,r),i})(Be,An),jn=((t,e,n,r,i)=>class extends t{constructor(t,s){const a=r(t),o={...vt,...s};super(t,!1,n(a,o),i(a)?e():null)}})(Ge,((t,e,n)=>()=>{const r=new WeakMap;return{render(i,s,a){const o=r.get(s);return void 0!==o?Promise.resolve(o):(async(i,s,a)=>{let o=e(i);if(!E(o,s)){const e={channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,numberOfInputs:o.numberOfInputs};o=t(s,e)}return r.set(s,o),await n(i,s,o,a),o})(i,s,a)}}})(En,nt,Ae),En,Me,Pe),Mn=((t,e,n,r,i,s)=>class extends t{constructor(t,a){const o=r(t),u=s({...wt,...a});super(t,!1,n(o,u),i(o)?e():null)}})(Ge,((t,e,n)=>()=>{const r=new WeakMap;return{render(i,s,a){const o=r.get(s);return void 0!==o?Promise.resolve(o):(async(i,s,a)=>{let o=e(i);if(!E(o,s)){const e={channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,numberOfOutputs:o.numberOfOutputs};o=t(s,e)}return r.set(s,o),await n(i,s,o,a),o})(i,s,a)}}})(Vt,nt,Ae),Vt,Me,Pe,t=>({...t,channelCount:t.numberOfOutputs})),Dn=((t,e,n,r)=>(i,{offset:s,...a})=>{const o=i.createBuffer(1,2,44100),u=e(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),c=n(i,{...a,gain:s}),l=o.getChannelData(0);l[0]=1,l[1]=1,u.buffer=o,u.loop=!0;const h={get bufferSize(){},get channelCount(){return c.channelCount},set channelCount(t){c.channelCount=t},get channelCountMode(){return c.channelCountMode},set channelCountMode(t){c.channelCountMode=t},get channelInterpretation(){return c.channelInterpretation},set channelInterpretation(t){c.channelInterpretation=t},get context(){return c.context},get inputs(){return[]},get numberOfInputs(){return u.numberOfInputs},get numberOfOutputs(){return c.numberOfOutputs},get offset(){return c.gain},get onended(){return u.onended},set onended(t){u.onended=t},addEventListener:(...t)=>u.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>u.dispatchEvent(t[0]),removeEventListener:(...t)=>u.removeEventListener(t[0],t[1],t[2]),start(t=0){u.start.call(u,t)},stop(t=0){u.stop.call(u,t)}};return t(i,u),r(Ut(h,c),()=>u.connect(c),()=>u.disconnect(c))})(rn,un,Gt,Cn),Rn=((t,e,n,r,i)=>(s,a)=>{if(void 0===s.createConstantSource)return n(s,a);const o=s.createConstantSource();return Rt(o,a),Ft(o,a,"offset"),e(r,()=>r(s))||zt(o),e(i,()=>i(s))||Lt(o),t(s,o),o})(rn,ve,Dn,ae,ue),Pn=((t,e,n,r,i,s,a)=>class extends t{constructor(t,a){const o=i(t),u={...xt,...a},c=r(o,u),l=s(o),h=l?n():null;super(t,!1,c,h),this._constantSourceNodeRenderer=h,this._nativeConstantSourceNode=c,this._offset=e(this,l,c.offset,F,P),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(t){const e="function"==typeof t?a(this,t):null;this._nativeConstantSourceNode.onended=e;const n=this._nativeConstantSourceNode.onended;this._onended=null!==n&&n===e?t:n}start(t=0){if(this._nativeConstantSourceNode.start(t),null!==this._constantSourceNodeRenderer&&(this._constantSourceNodeRenderer.start=t),"closed"!==this.context.state){T(this);const t=()=>{this._nativeConstantSourceNode.removeEventListener("ended",t),z(this)&&A(this)};this._nativeConstantSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeConstantSourceNode.stop(t),null!==this._constantSourceNodeRenderer&&(this._constantSourceNodeRenderer.stop=t)}})(Ge,dn,((t,e,n,r,i)=>()=>{const s=new WeakMap;let a=null,o=null;return{set start(t){a=t},set stop(t){o=t},render(u,c,l){const h=s.get(c);return void 0!==h?Promise.resolve(h):(async(u,c,l)=>{let h=n(u);const d=E(h,c);if(!d){const t={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=e(c,t),null!==a&&h.start(a),null!==o&&h.stop(o)}return s.set(c,h),d?await t(c,u.offset,h.offset,l):await r(c,u.offset,h.offset,l),await i(u,c,h,l),h})(u,c,l)}}})(on,Rn,nt,ln,Ae),Rn,Me,Pe,de),Fn=((t,e)=>(n,r)=>{const i=n.createConvolver();if(Rt(i,r),r.disableNormalization===i.normalize&&(i.normalize=!r.disableNormalization),Dt(i,r,"buffer"),r.channelCount>2)throw t();if(e(i,"channelCount",t=>()=>t.call(i),e=>n=>{if(n>2)throw t();return e.call(i,n)}),"max"===r.channelCountMode)throw t();return e(i,"channelCountMode",t=>()=>t.call(i),e=>n=>{if("max"===n)throw t();return e.call(i,n)}),i})(Xt,se),zn=((t,e,n,r,i,s)=>class extends t{constructor(t,a){const o=r(t),u={..._t,...a},c=n(o,u);super(t,!1,c,i(o)?e():null),this._isBufferNullified=!1,this._nativeConvolverNode=c,null!==u.buffer&&s(this,u.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(t){if(this._nativeConvolverNode.buffer=t,null===t&&null!==this._nativeConvolverNode.buffer){const t=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=t.createBuffer(1,1,44100),this._isBufferNullified=!0,s(this,0)}else this._isBufferNullified=!1,s(this,null===this._nativeConvolverNode.buffer?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(t){this._nativeConvolverNode.normalize=t}})(Ge,((t,e,n)=>()=>{const r=new WeakMap;return{render(i,s,a){const o=r.get(s);return void 0!==o?Promise.resolve(o):(async(i,s,a)=>{let o=e(i);if(!E(o,s)){const e={buffer:o.buffer,channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,disableNormalization:!o.normalize};o=t(s,e)}return r.set(s,o),X(o)?await n(i,s,o.inputs[0],a):await n(i,s,o,a),o})(i,s,a)}}})(Fn,nt,Ae),Fn,Me,Pe,bn),Ln=((t,e,n,r,i,s,a)=>class extends t{constructor(t,o){const u=i(t),c={...Ot,...o},l=r(u,c),h=s(u);super(t,!1,l,h?n(c.maxDelayTime):null),this._delayTime=e(this,h,l.delayTime),a(this,c.maxDelayTime)}get delayTime(){return this._delayTime}})(Ge,dn,((t,e,n,r,i)=>s=>{const a=new WeakMap;return{render(o,u,c){const l=a.get(u);return void 0!==l?Promise.resolve(l):(async(o,u,c)=>{let l=n(o);const h=E(l,u);if(!h){const t={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,delayTime:l.delayTime.value,maxDelayTime:s};l=e(u,t)}return a.set(u,l),h?await t(u,o.delayTime,l.delayTime,c):await r(u,o.delayTime,l.delayTime,c),await i(o,u,l,c),l})(o,u,c)}}})(on,Wt,nt,ln,Ae),Wt,Me,Pe,bn),$n=(Bn=Xt,(t,e)=>{const n=t.createDynamicsCompressor();if(Rt(n,e),e.channelCount>2)throw Bn();if("max"===e.channelCountMode)throw Bn();return Ft(n,e,"attack"),Ft(n,e,"knee"),Ft(n,e,"ratio"),Ft(n,e,"release"),Ft(n,e,"threshold"),n});var Bn;const qn=((t,e,n,r,i,s,a,o)=>class extends t{constructor(t,i){const u=s(t),c={...kt,...i},l=r(u,c),h=a(u);super(t,!1,l,h?n():null),this._attack=e(this,h,l.attack),this._knee=e(this,h,l.knee),this._nativeDynamicsCompressorNode=l,this._ratio=e(this,h,l.ratio),this._release=e(this,h,l.release),this._threshold=e(this,h,l.threshold),o(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(t){const e=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=t,t>2)throw this._nativeDynamicsCompressorNode.channelCount=e,i()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(t){const e=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=t,"max"===t)throw this._nativeDynamicsCompressorNode.channelCountMode=e,i()}get knee(){return this._knee}get ratio(){return this._ratio}get reduction(){return"number"==typeof this._nativeDynamicsCompressorNode.reduction.value?this._nativeDynamicsCompressorNode.reduction.value:this._nativeDynamicsCompressorNode.reduction}get release(){return this._release}get threshold(){return this._threshold}})(Ge,dn,((t,e,n,r,i)=>()=>{const s=new WeakMap;return{render(a,o,u){const c=s.get(o);return void 0!==c?Promise.resolve(c):(async(a,o,u)=>{let c=n(a);const l=E(c,o);if(!l){const t={attack:c.attack.value,channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,knee:c.knee.value,ratio:c.ratio.value,release:c.release.value,threshold:c.threshold.value};c=e(o,t)}return s.set(o,c),l?(await t(o,a.attack,c.attack,u),await t(o,a.knee,c.knee,u),await t(o,a.ratio,c.ratio,u),await t(o,a.release,c.release,u),await t(o,a.threshold,c.threshold,u)):(await r(o,a.attack,c.attack,u),await r(o,a.knee,c.knee,u),await r(o,a.ratio,c.ratio,u),await r(o,a.release,c.release,u),await r(o,a.threshold,c.threshold,u)),await i(a,o,c,u),c})(a,o,u)}}})(on,$n,nt,ln,Ae),$n,Xt,Me,Pe,bn),Vn=((t,e,n,r,i,s)=>class extends t{constructor(t,a){const o=i(t),u={...Tt,...a},c=r(o,u),l=s(o);super(t,!1,c,l?n():null),this._gain=e(this,l,c.gain,F,P)}get gain(){return this._gain}})(Ge,dn,((t,e,n,r,i)=>()=>{const s=new WeakMap;return{render(a,o,u){const c=s.get(o);return void 0!==c?Promise.resolve(c):(async(a,o,u)=>{let c=n(a);const l=E(c,o);if(!l){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,gain:c.gain.value};c=e(o,t)}return s.set(o,c),l?await t(o,a.gain,c.gain,u):await r(o,a.gain,c.gain,u),await i(a,o,c,u),c})(a,o,u)}}})(on,Gt,nt,ln,Ae),Gt,Me,Pe),Un=((t,e,n,r)=>(i,s,{channelCount:a,channelCountMode:o,channelInterpretation:u,feedback:c,feedforward:l})=>{const h=$t(s,i.sampleRate),d=c instanceof Float64Array?c:new Float64Array(c),p=l instanceof Float64Array?l:new Float64Array(l),f=d.length,m=p.length,g=Math.min(f,m);if(0===f||f>20)throw r();if(0===d[0])throw e();if(0===m||m>20)throw r();if(0===p[0])throw e();if(1!==d[0]){for(let t=0;t<m;t+=1)p[t]/=d[0];for(let t=1;t<f;t+=1)d[t]/=d[0]}const b=n(i,h,a,a);b.channelCount=a,b.channelCountMode=o,b.channelInterpretation=u;const y=[],v=[],w=[];for(let t=0;t<a;t+=1){y.push(0);const t=new Float32Array(32),e=new Float32Array(32);t.fill(0),e.fill(0),v.push(t),w.push(e)}b.onaudioprocess=t=>{const e=t.inputBuffer,n=t.outputBuffer,r=e.numberOfChannels;for(let t=0;t<r;t+=1){const r=e.getChannelData(t),i=n.getChannelData(t);y[t]=It(d,f,p,m,g,v[t],w[t],y[t],32,r,i)}};const x=i.sampleRate/2;return Ut({get bufferSize(){return h},get channelCount(){return b.channelCount},set channelCount(t){b.channelCount=t},get channelCountMode(){return b.channelCountMode},set channelCountMode(t){b.channelCountMode=t},get channelInterpretation(){return b.channelInterpretation},set channelInterpretation(t){b.channelInterpretation=t},get context(){return b.context},get inputs(){return[b]},get numberOfInputs(){return b.numberOfInputs},get numberOfOutputs(){return b.numberOfOutputs},addEventListener:(...t)=>b.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>b.dispatchEvent(t[0]),getFrequencyResponse(e,n,r){if(e.length!==n.length||n.length!==r.length)throw t();const i=e.length;for(let t=0;t<i;t+=1){const i=-Math.PI*(e[t]/x),s=[Math.cos(i),Math.sin(i)],a=Ht(Kt(p,s),Kt(d,s));n[t]=Math.sqrt(a[0]*a[0]+a[1]*a[1]),r[t]=Math.atan2(a[1],a[0])}},removeEventListener:(...t)=>b.removeEventListener(t[0],t[1],t[2])},b)})(At,Ct,Qt,Xt),Wn=((t,e,n,r)=>i=>t(jt,()=>jt(i))?Promise.resolve(t(r,r)).then(t=>{if(!t){const t=n(i,512,0,1);i.oncomplete=()=>{t.onaudioprocess=null,t.disconnect()},t.onaudioprocess=()=>i.currentTime,t.connect(i.destination)}return i.startRendering()}):new Promise(t=>{const n=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=e=>{n.disconnect(),t(e.renderedBuffer)},n.connect(i.destination),i.startRendering()}))(ve,Gt,Qt,((t,e)=>()=>{if(null===e)return Promise.resolve(!1);const n=new e(1,1,44100),r=t(n,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(t=>{n.oncomplete=()=>{r.disconnect(),t(0!==n.currentTime)},n.startRendering()})})(Gt,Re)),Gn=((t,e,n,r,i)=>(s,a)=>{const o=new WeakMap;let u=null;const c=async(c,l,h)=>{let d=null,p=e(c);const f=E(p,l);if(void 0===l.createIIRFilter?d=t(l,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):f||(p=l.createIIRFilter(a,s)),o.set(l,null===d?p:d),null!==d){if(null===u){if(null===n)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new n(c.context.destination.channelCount,c.context.length,l.sampleRate);u=(async()=>{await r(c,t,t.destination,h);return((t,e,n,r)=>{const i=n instanceof Float64Array?n:new Float64Array(n),s=r instanceof Float64Array?r:new Float64Array(r),a=i.length,o=s.length,u=Math.min(a,o);if(1!==i[0]){for(let t=0;t<a;t+=1)s[t]/=i[0];for(let t=1;t<o;t+=1)i[t]/=i[0]}const c=new Float32Array(32),l=new Float32Array(32),h=e.createBuffer(t.numberOfChannels,t.length,t.sampleRate),d=t.numberOfChannels;for(let e=0;e<d;e+=1){const n=t.getChannelData(e),r=h.getChannelData(e);c.fill(0),l.fill(0),It(i,a,s,o,u,c,l,0,32,n,r)}return h})(await i(t),l,s,a)})()}const t=await u;return d.buffer=t,d.start(0),d}return await r(c,l,p,h),p};return{render(t,e,n){const r=o.get(e);return void 0!==r?Promise.resolve(r):c(t,e,n)}}})(un,nt,Re,Ae,Wn);var Hn;const Kn=((t,e,n,r,i,s)=>class extends t{constructor(t,a){const o=r(t),u=i(o),c={...Nt,...a},l=e(o,u?null:t.baseLatency,c);super(t,!1,l,u?n(c.feedback,c.feedforward):null),(t=>{var e;t.getFrequencyResponse=(e=t.getFrequencyResponse,(n,r,i)=>{if(n.length!==r.length||r.length!==i.length)throw At();return e.call(t,n,r,i)})})(l),this._nativeIIRFilterNode=l,s(this,1)}getFrequencyResponse(t,e,n){return this._nativeIIRFilterNode.getFrequencyResponse(t,e,n)}})(Ge,(Hn=Un,(t,e,n)=>{if(void 0===t.createIIRFilter)return Hn(t,e,n);const r=t.createIIRFilter(n.feedforward,n.feedback);return Rt(r,n),r}),Gn,Me,Pe,bn),Qn=((t,e,n,r,i)=>(s,a)=>{const o=a.listener,{forwardX:u,forwardY:c,forwardZ:l,positionX:h,positionY:d,positionZ:p,upX:f,upY:m,upZ:g}=void 0===o.forwardX?(()=>{const u=e(a,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),c=i(a),l=r(a,256,9,0),h=(e,r)=>{const i=n(a,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:r});return i.connect(u,0,e),i.start(),Object.defineProperty(i.offset,"defaultValue",{get:()=>r}),t({context:s},c,i.offset,F,P)};let d=[0,0,-1,0,1,0],p=[0,0,0];return l.onaudioprocess=({inputBuffer:t})=>{const e=[t.getChannelData(0)[0],t.getChannelData(1)[0],t.getChannelData(2)[0],t.getChannelData(3)[0],t.getChannelData(4)[0],t.getChannelData(5)[0]];e.some((t,e)=>t!==d[e])&&(o.setOrientation(...e),d=e);const n=[t.getChannelData(6)[0],t.getChannelData(7)[0],t.getChannelData(8)[0]];n.some((t,e)=>t!==p[e])&&(o.setPosition(...n),p=n)},u.connect(l),{forwardX:h(0,0),forwardY:h(1,0),forwardZ:h(2,-1),positionX:h(6,0),positionY:h(7,0),positionZ:h(8,0),upX:h(3,0),upY:h(4,1),upZ:h(5,0)}})():o;return{get forwardX(){return u},get forwardY(){return c},get forwardZ(){return l},get positionX(){return h},get positionY(){return d},get positionZ(){return p},get upX(){return f},get upY(){return m},get upZ(){return g}}})(dn,En,Rn,Qt,Pe),Xn=new WeakMap,Yn=((t,e,n,r,i,s)=>class extends n{constructor(n,s){super(n),this._nativeContext=n,d.set(this,n),r(n)&&i.set(n,new Set),this._destination=new t(this,s),this._listener=e(this,n),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(t){const e="function"==typeof t?s(this,t):null;this._nativeContext.onstatechange=e;const n=this._nativeContext.onstatechange;this._onstatechange=null!==n&&n===e?t:n}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}})(mn,Qn,Le,Pe,Xn,de),Jn=((t,e,n,r,i,s)=>(a,o)=>{const u=a.createOscillator();return Rt(u,o),Ft(u,o,"detune"),Ft(u,o,"frequency"),void 0!==o.periodicWave?u.setPeriodicWave(o.periodicWave):Dt(u,o,"type"),e(n,()=>n(a))||zt(u),e(r,()=>r(a))||s(u,a),e(i,()=>i(a))||Lt(u),t(a,u),u})(rn,ve,ae,oe,ue,he),Zn=((t,e,n,r,i,s,a)=>class extends t{constructor(t,a){const o=i(t),u={...Jt,...a},c=n(o,u),l=s(o),h=l?r():null,d=t.sampleRate/2;super(t,!1,c,h),this._detune=e(this,l,c.detune,153600,-153600),this._frequency=e(this,l,c.frequency,d,-d),this._nativeOscillatorNode=c,this._onended=null,this._oscillatorNodeRenderer=h,null!==this._oscillatorNodeRenderer&&void 0!==u.periodicWave&&(this._oscillatorNodeRenderer.periodicWave=u.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(t){const e="function"==typeof t?a(this,t):null;this._nativeOscillatorNode.onended=e;const n=this._nativeOscillatorNode.onended;this._onended=null!==n&&n===e?t:n}get type(){return this._nativeOscillatorNode.type}set type(t){this._nativeOscillatorNode.type=t,null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(t){this._nativeOscillatorNode.setPeriodicWave(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.periodicWave=t)}start(t=0){if(this._nativeOscillatorNode.start(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.start=t),"closed"!==this.context.state){T(this);const t=()=>{this._nativeOscillatorNode.removeEventListener("ended",t),z(this)&&A(this)};this._nativeOscillatorNode.addEventListener("ended",t)}}stop(t=0){this._nativeOscillatorNode.stop(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.stop=t)}})(Ge,dn,Jn,((t,e,n,r,i)=>()=>{const s=new WeakMap;let a=null,o=null,u=null;return{set periodicWave(t){a=t},set start(t){o=t},set stop(t){u=t},render(c,l,h){const d=s.get(l);return void 0!==d?Promise.resolve(d):(async(c,l,h)=>{let d=n(c);const p=E(d,l);if(!p){const t={channelCount:d.channelCount,channelCountMode:d.channelCountMode,channelInterpretation:d.channelInterpretation,detune:d.detune.value,frequency:d.frequency.value,periodicWave:null===a?void 0:a,type:d.type};d=e(l,t),null!==o&&d.start(o),null!==u&&d.stop(u)}return s.set(l,d),p?(await t(l,c.detune,d.detune,h),await t(l,c.frequency,d.frequency,h)):(await r(l,c.detune,d.detune,h),await r(l,c.frequency,d.frequency,h)),await i(c,l,d,h),d})(c,l,h)}}})(on,Jn,nt,ln,Ae),Me,Pe,de),tr=(er=un,(t,e)=>{const n=er(t,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),r=t.createBuffer(1,2,44100);return n.buffer=r,n.loop=!0,n.connect(e),n.start(),()=>{n.stop(),n.disconnect(e)}});var er;const nr=((t,e,n,r,i)=>(s,{curve:a,oversample:o,...u})=>{const c=s.createWaveShaper(),l=s.createWaveShaper();Rt(c,u),Rt(l,u);const h=n(s,{...u,gain:1}),d=n(s,{...u,gain:-1}),p=n(s,{...u,gain:1}),f=n(s,{...u,gain:-1});let m=null,g=!1,b=null;const y={get bufferSize(){},get channelCount(){return c.channelCount},set channelCount(t){h.channelCount=t,d.channelCount=t,c.channelCount=t,p.channelCount=t,l.channelCount=t,f.channelCount=t},get channelCountMode(){return c.channelCountMode},set channelCountMode(t){h.channelCountMode=t,d.channelCountMode=t,c.channelCountMode=t,p.channelCountMode=t,l.channelCountMode=t,f.channelCountMode=t},get channelInterpretation(){return c.channelInterpretation},set channelInterpretation(t){h.channelInterpretation=t,d.channelInterpretation=t,c.channelInterpretation=t,p.channelInterpretation=t,l.channelInterpretation=t,f.channelInterpretation=t},get context(){return c.context},get curve(){return b},set curve(n){if(null!==n&&n.length<2)throw e();if(null===n)c.curve=n,l.curve=n;else{const t=n.length,e=new Float32Array(t+2-t%2),r=new Float32Array(t+2-t%2);e[0]=n[0],r[0]=-n[t-1];const i=Math.ceil((t+1)/2),s=(t+1)/2-1;for(let a=1;a<i;a+=1){const o=a/i*s,u=Math.floor(o),c=Math.ceil(o);e[a]=u===c?n[u]:(1-(o-u))*n[u]+(1-(c-o))*n[c],r[a]=u===c?-n[t-1-u]:-(1-(o-u))*n[t-1-u]-(1-(c-o))*n[t-1-c]}e[i]=t%2==1?n[i-1]:(n[i-2]+n[i-1])/2,c.curve=e,l.curve=r}b=n,g&&(r(b)&&null===m?m=t(s,h):null!==m&&(m(),m=null))},get inputs(){return[h]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return c.numberOfOutputs},get oversample(){return c.oversample},set oversample(t){c.oversample=t,l.oversample=t},addEventListener:(...t)=>h.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>h.dispatchEvent(t[0]),removeEventListener:(...t)=>h.removeEventListener(t[0],t[1],t[2])};null!==a&&(y.curve=a instanceof Float32Array?a:new Float32Array(a)),o!==y.oversample&&(y.oversample=o);return i(Ut(y,p),()=>{h.connect(c).connect(p),h.connect(d).connect(l).connect(f).connect(p),g=!0,r(b)&&(m=t(s,h))},()=>{h.disconnect(c),c.disconnect(p),h.disconnect(d),d.disconnect(l),l.disconnect(f),f.disconnect(p),g=!1,null!==m&&(m(),m=null)})})(tr,Ct,Gt,ie,Cn),rr=((t,e,n,r,i,s,a)=>(o,u)=>{const c=o.createWaveShaper();if(null!==s&&"webkitAudioContext"===s.name)return n(o,u);Rt(c,u);const l=null===u.curve||u.curve instanceof Float32Array?u.curve:new Float32Array(u.curve);if(null!==l&&l.length<2)throw e();Dt(c,{curve:l},"curve"),Dt(c,u,"oversample");let h=null,d=!1;a(c,"curve",t=>()=>t.call(c),e=>n=>(e.call(c,n),d&&(r(n)&&null===h?h=t(o,c):r(n)||null===h||(h(),h=null)),n));return i(c,()=>{d=!0,r(c.curve)&&(h=t(o,c))},()=>{d=!1,null!==h&&(h(),h=null)})})(tr,Ct,nr,ie,Cn,Be,se),ir=((t,e,n,r,i,s,a,o,u)=>(c,{coneInnerAngle:l,coneOuterAngle:h,coneOuterGain:d,distanceModel:p,maxDistance:f,orientationX:m,orientationY:g,orientationZ:b,panningModel:y,positionX:v,positionY:w,positionZ:x,refDistance:_,rolloffFactor:O,...S})=>{const k=c.createPanner();if(S.channelCount>2)throw a();if("max"===S.channelCountMode)throw a();Rt(k,S);const T={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},C=n(c,{...T,channelInterpretation:"speakers",numberOfInputs:6}),A=r(c,{...S,gain:1}),N=r(c,{...T,gain:1}),I=r(c,{...T,gain:0}),E=r(c,{...T,gain:0}),j=r(c,{...T,gain:0}),M=r(c,{...T,gain:0}),D=r(c,{...T,gain:0}),R=i(c,256,6,1),P=s(c,{...T,curve:new Float32Array([1,1]),oversample:"none"});let F=[m,g,b],z=[v,w,x];R.onaudioprocess=({inputBuffer:t})=>{const e=[t.getChannelData(0)[0],t.getChannelData(1)[0],t.getChannelData(2)[0]];e.some((t,e)=>t!==F[e])&&(k.setOrientation(...e),F=e);const n=[t.getChannelData(3)[0],t.getChannelData(4)[0],t.getChannelData(5)[0]];n.some((t,e)=>t!==z[e])&&(k.setPosition(...n),z=n)},Object.defineProperty(I.gain,"defaultValue",{get:()=>0}),Object.defineProperty(E.gain,"defaultValue",{get:()=>0}),Object.defineProperty(j.gain,"defaultValue",{get:()=>0}),Object.defineProperty(M.gain,"defaultValue",{get:()=>0}),Object.defineProperty(D.gain,"defaultValue",{get:()=>0});const L={get bufferSize(){},get channelCount(){return k.channelCount},set channelCount(t){if(t>2)throw a();A.channelCount=t,k.channelCount=t},get channelCountMode(){return k.channelCountMode},set channelCountMode(t){if("max"===t)throw a();A.channelCountMode=t,k.channelCountMode=t},get channelInterpretation(){return k.channelInterpretation},set channelInterpretation(t){A.channelInterpretation=t,k.channelInterpretation=t},get coneInnerAngle(){return k.coneInnerAngle},set coneInnerAngle(t){k.coneInnerAngle=t},get coneOuterAngle(){return k.coneOuterAngle},set coneOuterAngle(t){k.coneOuterAngle=t},get coneOuterGain(){return k.coneOuterGain},set coneOuterGain(t){if(t<0||t>1)throw e();k.coneOuterGain=t},get context(){return k.context},get distanceModel(){return k.distanceModel},set distanceModel(t){k.distanceModel=t},get inputs(){return[A]},get maxDistance(){return k.maxDistance},set maxDistance(t){if(t<0)throw new RangeError;k.maxDistance=t},get numberOfInputs(){return k.numberOfInputs},get numberOfOutputs(){return k.numberOfOutputs},get orientationX(){return N.gain},get orientationY(){return I.gain},get orientationZ(){return E.gain},get panningModel(){return k.panningModel},set panningModel(t){k.panningModel=t},get positionX(){return j.gain},get positionY(){return M.gain},get positionZ(){return D.gain},get refDistance(){return k.refDistance},set refDistance(t){if(t<0)throw new RangeError;k.refDistance=t},get rolloffFactor(){return k.rolloffFactor},set rolloffFactor(t){if(t<0)throw new RangeError;k.rolloffFactor=t},addEventListener:(...t)=>A.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>A.dispatchEvent(t[0]),removeEventListener:(...t)=>A.removeEventListener(t[0],t[1],t[2])};l!==L.coneInnerAngle&&(L.coneInnerAngle=l),h!==L.coneOuterAngle&&(L.coneOuterAngle=h),d!==L.coneOuterGain&&(L.coneOuterGain=d),p!==L.distanceModel&&(L.distanceModel=p),f!==L.maxDistance&&(L.maxDistance=f),m!==L.orientationX.value&&(L.orientationX.value=m),g!==L.orientationY.value&&(L.orientationY.value=g),b!==L.orientationZ.value&&(L.orientationZ.value=b),y!==L.panningModel&&(L.panningModel=y),v!==L.positionX.value&&(L.positionX.value=v),w!==L.positionY.value&&(L.positionY.value=w),x!==L.positionZ.value&&(L.positionZ.value=x),_!==L.refDistance&&(L.refDistance=_),O!==L.rolloffFactor&&(L.rolloffFactor=O),1===F[0]&&0===F[1]&&0===F[2]||k.setOrientation(...F),0===z[0]&&0===z[1]&&0===z[2]||k.setPosition(...z);return u(Ut(L,k),()=>{A.connect(k),t(A,P,0,0),P.connect(N).connect(C,0,0),P.connect(I).connect(C,0,1),P.connect(E).connect(C,0,2),P.connect(j).connect(C,0,3),P.connect(M).connect(C,0,4),P.connect(D).connect(C,0,5),C.connect(R).connect(c.destination)},()=>{A.disconnect(k),o(A,P,0,0),P.disconnect(N),N.disconnect(C),P.disconnect(I),I.disconnect(C),P.disconnect(E),E.disconnect(C),P.disconnect(j),j.disconnect(C),P.disconnect(M),M.disconnect(C),P.disconnect(D),D.disconnect(C),C.disconnect(R),R.disconnect(c.destination)})})(Y,Ct,En,Gt,Qt,rr,Xt,et,Cn),sr=(ar=ir,(t,e)=>{const n=t.createPanner();return void 0===n.orientationX?ar(t,e):(Rt(n,e),Ft(n,e,"orientationX"),Ft(n,e,"orientationY"),Ft(n,e,"orientationZ"),Ft(n,e,"positionX"),Ft(n,e,"positionY"),Ft(n,e,"positionZ"),Dt(n,e,"coneInnerAngle"),Dt(n,e,"coneOuterAngle"),Dt(n,e,"coneOuterGain"),Dt(n,e,"distanceModel"),Dt(n,e,"maxDistance"),Dt(n,e,"panningModel"),Dt(n,e,"refDistance"),Dt(n,e,"rolloffFactor"),n)});var ar;const or=((t,e,n,r,i,s,a)=>class extends t{constructor(t,o){const u=i(t),c={...Zt,...o},l=n(u,c),h=s(u);super(t,!1,l,h?r():null),this._nativePannerNode=l,this._orientationX=e(this,h,l.orientationX,F,P),this._orientationY=e(this,h,l.orientationY,F,P),this._orientationZ=e(this,h,l.orientationZ,F,P),this._positionX=e(this,h,l.positionX,F,P),this._positionY=e(this,h,l.positionY,F,P),this._positionZ=e(this,h,l.positionZ,F,P),a(this,1)}get coneInnerAngle(){return this._nativePannerNode.coneInnerAngle}set coneInnerAngle(t){this._nativePannerNode.coneInnerAngle=t}get coneOuterAngle(){return this._nativePannerNode.coneOuterAngle}set coneOuterAngle(t){this._nativePannerNode.coneOuterAngle=t}get coneOuterGain(){return this._nativePannerNode.coneOuterGain}set coneOuterGain(t){this._nativePannerNode.coneOuterGain=t}get distanceModel(){return this._nativePannerNode.distanceModel}set distanceModel(t){this._nativePannerNode.distanceModel=t}get maxDistance(){return this._nativePannerNode.maxDistance}set maxDistance(t){this._nativePannerNode.maxDistance=t}get orientationX(){return this._orientationX}get orientationY(){return this._orientationY}get orientationZ(){return this._orientationZ}get panningModel(){return this._nativePannerNode.panningModel}set panningModel(t){this._nativePannerNode.panningModel=t}get positionX(){return this._positionX}get positionY(){return this._positionY}get positionZ(){return this._positionZ}get refDistance(){return this._nativePannerNode.refDistance}set refDistance(t){this._nativePannerNode.refDistance=t}get rolloffFactor(){return this._nativePannerNode.rolloffFactor}set rolloffFactor(t){this._nativePannerNode.rolloffFactor=t}})(Ge,dn,sr,((t,e,n,r,i,s,a,o,u,c)=>()=>{const l=new WeakMap;let h=null;return{render(d,p,f){const m=l.get(p);return void 0!==m?Promise.resolve(m):(async(d,p,f)=>{let m=null,g=s(d);const b={channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation},y={...b,coneInnerAngle:g.coneInnerAngle,coneOuterAngle:g.coneOuterAngle,coneOuterGain:g.coneOuterGain,distanceModel:g.distanceModel,maxDistance:g.maxDistance,panningModel:g.panningModel,refDistance:g.refDistance,rolloffFactor:g.rolloffFactor},v=E(g,p);if("bufferSize"in g)m=r(p,{...b,gain:1});else if(!v){const t={...y,orientationX:g.orientationX.value,orientationY:g.orientationY.value,orientationZ:g.orientationZ.value,positionX:g.positionX.value,positionY:g.positionY.value,positionZ:g.positionZ.value};g=i(p,t)}if(l.set(p,null===m?g:m),null!==m){if(null===h){if(null===a)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new a(6,d.context.length,p.sampleRate),r=e(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});r.connect(t.destination),h=(async()=>{const e=await Promise.all([d.orientationX,d.orientationY,d.orientationZ,d.positionX,d.positionY,d.positionZ].map(async(e,r)=>{const i=n(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:0===r?1:0});return await o(t,e,i.offset,f),i}));for(let t=0;t<6;t+=1)e[t].connect(r,0,t),e[t].start(0);return c(t)})()}const t=await h,s=r(p,{...b,gain:1});await u(d,p,s,f);const l=[];for(let e=0;e<t.numberOfChannels;e+=1)l.push(t.getChannelData(e));let g=[l[0][0],l[1][0],l[2][0]],v=[l[3][0],l[4][0],l[5][0]],w=r(p,{...b,gain:1}),x=i(p,{...y,orientationX:g[0],orientationY:g[1],orientationZ:g[2],positionX:v[0],positionY:v[1],positionZ:v[2]});s.connect(w).connect(x.inputs[0]),x.connect(m);for(let e=128;e<t.length;e+=128){const t=[l[0][e],l[1][e],l[2][e]],n=[l[3][e],l[4][e],l[5][e]];if(t.some((t,e)=>t!==g[e])||n.some((t,e)=>t!==v[e])){g=t,v=n;const a=e/p.sampleRate;w.gain.setValueAtTime(0,a),w=r(p,{...b,gain:0}),x=i(p,{...y,orientationX:g[0],orientationY:g[1],orientationZ:g[2],positionX:v[0],positionY:v[1],positionZ:v[2]}),w.gain.setValueAtTime(1,a),s.connect(w).connect(x.inputs[0]),x.connect(m)}}return m}return v?(await t(p,d.orientationX,g.orientationX,f),await t(p,d.orientationY,g.orientationY,f),await t(p,d.orientationZ,g.orientationZ,f),await t(p,d.positionX,g.positionX,f),await t(p,d.positionY,g.positionY,f),await t(p,d.positionZ,g.positionZ,f)):(await o(p,d.orientationX,g.orientationX,f),await o(p,d.orientationY,g.orientationY,f),await o(p,d.orientationZ,g.orientationZ,f),await o(p,d.positionX,g.positionX,f),await o(p,d.positionY,g.positionY,f),await o(p,d.positionZ,g.positionZ,f)),X(g)?await u(d,p,g.inputs[0],f):await u(d,p,g,f),g})(d,p,f)}}})(on,En,Rn,Gt,sr,nt,Re,ln,Ae,Wn),Me,Pe,bn),ur=((t,e,n,r)=>class i{constructor(i,s){const a=e(i),o=r({...te,...s}),u=t(a,o);return n.add(u),u}static[Symbol.hasInstance](t){return null!==t&&"object"==typeof t&&Object.getPrototypeOf(t)===i.prototype||n.has(t)}})((t=>(e,{disableNormalization:n,imag:r,real:i})=>{const s=r instanceof Float32Array?r:new Float32Array(r),a=i instanceof Float32Array?i:new Float32Array(i),o=e.createPeriodicWave(a,s,{disableNormalization:n});if(Array.from(r).length<2)throw t();return o})(M),Me,new WeakSet,t=>{const{imag:e,real:n}=t;return void 0===e?void 0===n?{...t,imag:[0,0],real:[0,0]}:{...t,imag:Array.from(n,()=>0),real:n}:void 0===n?{...t,imag:e,real:Array.from(e,()=>0)}:{...t,imag:e,real:n}}),cr=((t,e)=>(n,r)=>{const i=r.channelCountMode;if("clamped-max"===i)throw e();if(void 0===n.createStereoPanner)return t(n,r);const s=n.createStereoPanner();return Rt(s,r),Ft(s,r,"pan"),Object.defineProperty(s,"channelCountMode",{get:()=>i,set:t=>{if(t!==i)throw e()}}),s})(((t,e,n,r,i,s)=>{const a=new Float32Array([1,1]),o=Math.PI/2,u={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},c={...u,oversample:"none"},l=(t,s,l,h,d)=>{if(1===s)return((t,e,i,s)=>{const l=new Float32Array(16385),h=new Float32Array(16385);for(let t=0;t<16385;t+=1){const e=t/16384*o;l[t]=Math.cos(e),h[t]=Math.sin(e)}const d=n(t,{...u,gain:0}),p=r(t,{...c,curve:l}),f=r(t,{...c,curve:a}),m=n(t,{...u,gain:0}),g=r(t,{...c,curve:h});return{connectGraph(){e.connect(d),e.connect(f.inputs[0]),e.connect(m),f.connect(i),i.connect(p.inputs[0]),i.connect(g.inputs[0]),p.connect(d.gain),g.connect(m.gain),d.connect(s,0,0),m.connect(s,0,1)},disconnectGraph(){e.disconnect(d),e.disconnect(f.inputs[0]),e.disconnect(m),f.disconnect(i),i.disconnect(p.inputs[0]),i.disconnect(g.inputs[0]),p.disconnect(d.gain),g.disconnect(m.gain),d.disconnect(s,0,0),m.disconnect(s,0,1)}}})(t,l,h,d);if(2===s)return((t,i,s,l)=>{const h=new Float32Array(16385),d=new Float32Array(16385),p=new Float32Array(16385),f=new Float32Array(16385),m=Math.floor(8192.5);for(let t=0;t<16385;t+=1)if(t>m){const e=(t-m)/(16384-m)*o;h[t]=Math.cos(e),d[t]=Math.sin(e),p[t]=0,f[t]=1}else{const e=t/(16384-m)*o;h[t]=1,d[t]=0,p[t]=Math.cos(e),f[t]=Math.sin(e)}const g=e(t,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),b=n(t,{...u,gain:0}),y=r(t,{...c,curve:h}),v=n(t,{...u,gain:0}),w=r(t,{...c,curve:d}),x=r(t,{...c,curve:a}),_=n(t,{...u,gain:0}),O=r(t,{...c,curve:p}),S=n(t,{...u,gain:0}),k=r(t,{...c,curve:f});return{connectGraph(){i.connect(g),i.connect(x.inputs[0]),g.connect(b,0),g.connect(v,0),g.connect(_,1),g.connect(S,1),x.connect(s),s.connect(y.inputs[0]),s.connect(w.inputs[0]),s.connect(O.inputs[0]),s.connect(k.inputs[0]),y.connect(b.gain),w.connect(v.gain),O.connect(_.gain),k.connect(S.gain),b.connect(l,0,0),_.connect(l,0,0),v.connect(l,0,1),S.connect(l,0,1)},disconnectGraph(){i.disconnect(g),i.disconnect(x.inputs[0]),g.disconnect(b,0),g.disconnect(v,0),g.disconnect(_,1),g.disconnect(S,1),x.disconnect(s),s.disconnect(y.inputs[0]),s.disconnect(w.inputs[0]),s.disconnect(O.inputs[0]),s.disconnect(k.inputs[0]),y.disconnect(b.gain),w.disconnect(v.gain),O.disconnect(_.gain),k.disconnect(S.gain),b.disconnect(l,0,0),_.disconnect(l,0,0),v.disconnect(l,0,1),S.disconnect(l,0,1)}}})(t,l,h,d);throw i()};return(e,{channelCount:r,channelCountMode:a,pan:o,...u})=>{if("max"===a)throw i();const c=t(e,{...u,channelCount:1,channelCountMode:a,numberOfInputs:2}),h=n(e,{...u,channelCount:r,channelCountMode:a,gain:1}),d=n(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:o});let{connectGraph:p,disconnectGraph:f}=l(e,r,h,d,c);Object.defineProperty(d.gain,"defaultValue",{get:()=>0}),Object.defineProperty(d.gain,"minValue",{get:()=>-1});const m={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(t){h.channelCount!==t&&(g&&f(),({connectGraph:p,disconnectGraph:f}=l(e,t,h,d,c)),g&&p()),h.channelCount=t},get channelCountMode(){return h.channelCountMode},set channelCountMode(t){if("clamped-max"===t||"max"===t)throw i();h.channelCountMode=t},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(t){h.channelInterpretation=t},get context(){return h.context},get inputs(){return[h]},get numberOfInputs(){return h.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get pan(){return d.gain},addEventListener:(...t)=>h.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>h.dispatchEvent(t[0]),removeEventListener:(...t)=>h.removeEventListener(t[0],t[1],t[2])};let g=!1;return s(Ut(m,c),()=>{p(),g=!0},()=>{f(),g=!1})}})(En,Vt,Gt,rr,Xt,Cn),Xt),lr=((t,e,n,r,i,s)=>class extends t{constructor(t,a){const o=i(t),u={...ee,...a},c=n(o,u),l=s(o);super(t,!1,c,l?r():null),this._pan=e(this,l,c.pan)}get pan(){return this._pan}})(Ge,dn,cr,((t,e,n,r,i)=>()=>{const s=new WeakMap;return{render(a,o,u){const c=s.get(o);return void 0!==c?Promise.resolve(c):(async(a,o,u)=>{let c=n(a);const l=E(c,o);if(!l){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,pan:c.pan.value};c=e(o,t)}return s.set(o,c),l?await t(o,a.pan,c.pan,u):await r(o,a.pan,c.pan,u),X(c)?await i(a,o,c.inputs[0],u):await i(a,o,c,u),c})(a,o,u)}}})(on,cr,nt,ln,Ae),Me,Pe),hr=((t,e,n)=>()=>{const r=new WeakMap;return{render(i,s,a){const o=r.get(s);return void 0!==o?Promise.resolve(o):(async(i,s,a)=>{let o=e(i);if(!E(o,s)){const e={channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,curve:o.curve,oversample:o.oversample};o=t(s,e)}return r.set(s,o),X(o)?await n(i,s,o.inputs[0],a):await n(i,s,o,a),o})(i,s,a)}}})(rr,nt,Ae),dr=((t,e,n,r,i,s,a)=>class extends t{constructor(t,e){const o=i(t),u={...re,...e},c=n(o,u);super(t,!0,c,s(o)?r():null),this._isCurveNullified=!1,this._nativeWaveShaperNode=c,a(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(t){if(null===t)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(t.length<2)throw e();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=t}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(t){this._nativeWaveShaperNode.oversample=t}})(Ge,Ct,rr,hr,Me,Pe,bn),pr=(t=>null!==t&&t.isSecureContext)(_e),fr=(t=>(e,n,r)=>{Object.defineProperties(t,{currentFrame:{configurable:!0,get:()=>Math.round(e*n)},currentTime:{configurable:!0,get:()=>e}});try{return r()}finally{null!==t&&(delete t.currentFrame,delete t.currentTime)}})(_e),mr=new WeakMap,gr=((t,e)=>n=>{let r=t.get(n);if(void 0!==r)return r;if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");return r=new e(1,1,8e3),t.set(n,r),r})(mr,Re),br=(t=>null===t?null:t.hasOwnProperty("AudioWorkletNode")?t.AudioWorkletNode:null)(_e),yr=pr?((t,e,n,r,i,s,a,o,u,c,l,h)=>(d,p,f={credentials:"omit"})=>{const g=s(d),b=new URL(p,h.location.href).toString();if(void 0!==g.audioWorklet)return Promise.all([i(p),Promise.resolve(t(l,l))]).then(([t,e])=>{const[n,r]=v(t,b),i=e?r:r.replace(/\s+extends\s+AudioWorkletProcessor\s*{/," extends (class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}){"),s=new Blob([`${n};(registerProcessor=>{${i}\n})((n,p)=>registerProcessor(n,class extends p{${e?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${e?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}))`],{type:"application/javascript; charset=utf-8"}),u=URL.createObjectURL(s);return g.audioWorklet.addModule(u,f).then(()=>{if(o(g))return;return a(g).audioWorklet.addModule(u,f)}).finally(()=>URL.revokeObjectURL(u))});const y=c.get(d);if(void 0!==y&&y.has(p))return Promise.resolve();const _=u.get(d);if(void 0!==_){const t=_.get(p);if(void 0!==t)return t}const O=i(p).then(t=>{const[e,r]=v(t,b);return n(`${e};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${r}\n})})(window,'_AWGS')`)}).then(()=>{const t=h._AWGS.pop();if(void 0===t)throw new SyntaxError;r(g.currentTime,g.sampleRate,()=>t(class{},void 0,(t,n)=>{if(""===t.trim())throw e();const r=m.get(g);if(void 0!==r){if(r.has(t))throw e();x(n),w(n.parameterDescriptors),r.set(t,n)}else x(n),w(n.parameterDescriptors),m.set(g,new Map([[t,n]]))},g.sampleRate,void 0,void 0))});return void 0===_?u.set(d,new Map([[p,O]])):_.set(p,O),O.then(()=>{const t=c.get(d);void 0===t?c.set(d,new Set([p])):t.add(p)}).finally(()=>{const t=u.get(d);void 0!==t&&t.delete(p)}),O})(ve,Xt,(t=>e=>new Promise((n,r)=>{if(null===t)return void r(new SyntaxError);const i=t.document.head;if(null===i)r(new SyntaxError);else{const s=t.document.createElement("script"),a=new Blob([e],{type:"application/javascript"}),o=URL.createObjectURL(a),u=t.onerror,c=()=>{t.onerror=u,URL.revokeObjectURL(o)};t.onerror=(e,n,i,s,a)=>n===o||n===t.location.href&&1===i&&1===s?(c(),r(a),!1):null!==u?u(e,n,i,s,a):void 0,s.onerror=()=>{c(),r(new SyntaxError)},s.onload=()=>{c(),n()},s.src=o,s.type="module",i.appendChild(s)}}))(_e),fr,(t=>async e=>{try{const t=await fetch(e);if(t.ok)return t.text()}catch{}throw t()})(()=>new DOMException("","AbortError")),Me,gr,Pe,new WeakMap,new WeakMap,((t,e)=>async()=>{if(null===t)return!0;if(null===e)return!1;const n=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),r=new e(1,128,8e3),i=URL.createObjectURL(n);let s=!1,a=!1;try{await r.audioWorklet.addModule(i);const e=new t(r,"a",{numberOfOutputs:0}),n=r.createOscillator();e.port.onmessage=()=>s=!0,e.onprocessorerror=()=>a=!0,n.connect(e),await r.startRendering()}catch{}finally{URL.revokeObjectURL(i)}return s&&!a})(br,Re),_e):void 0,vr=((t,e)=>n=>t(n)||e(n))(qe,Pe),wr=((t,e,n,r,i,s,a,o,u,c,l,h,d,p,f,m,g,b,y,v)=>class extends f{constructor(e,n){super(e,n),this._nativeContext=e,this._audioWorklet=void 0===t?void 0:{addModule:(e,n)=>t(this,e,n)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new e(this)}createBiquadFilter(){return new i(this)}createBuffer(t,e,r){return new n({length:e,numberOfChannels:t,sampleRate:r})}createBufferSource(){return new r(this)}createChannelMerger(t=6){return new s(this,{numberOfInputs:t})}createChannelSplitter(t=6){return new a(this,{numberOfOutputs:t})}createConstantSource(){return new o(this)}createConvolver(){return new u(this)}createDelay(t=1){return new l(this,{maxDelayTime:t})}createDynamicsCompressor(){return new h(this)}createGain(){return new d(this)}createIIRFilter(t,e){return new p(this,{feedback:e,feedforward:t})}createOscillator(){return new m(this)}createPanner(){return new g(this)}createPeriodicWave(t,e,n={disableNormalization:!1}){return new b(this,{...n,imag:e,real:t})}createStereoPanner(){return new y(this)}createWaveShaper(){return new v(this)}decodeAudioData(t,e,n){return c(this._nativeContext,t).then(t=>("function"==typeof e&&e(t),t)).catch(t=>{throw"function"==typeof n&&n(t),t})}})(yr,Ke,en,fn,yn,jn,Mn,Pn,zn,((t,e,n,r,i,s,a,o,u,c,l)=>(h,d)=>{const p=a(h)?h:s(h);if(i.has(d)){const t=n();return Promise.reject(t)}try{i.add(d)}catch{}return e(u,()=>u(p))?p.decodeAudioData(d).then(n=>(e(o,()=>o(n))||l(n),t.add(n),n)):new Promise((e,n)=>{const i=()=>{try{(t=>{const{port1:e}=new MessageChannel;e.postMessage(t,[t])})(d)}catch{}},s=t=>{n(t),i()};try{p.decodeAudioData(d,n=>{"function"!=typeof n.copyFromChannel&&(c(n),D(n)),t.add(n),i(),e(n)},t=>{s(null===t?r():t)})}catch(t){s(t)}})})(Qe,ve,()=>new DOMException("","DataCloneError"),()=>new DOMException("","EncodingError"),new WeakSet,Me,vr,j,jt,Ze,tn),Ln,qn,Vn,Kn,Yn,Zn,or,ur,lr,dr),xr=((t,e,n,r)=>class extends t{constructor(t,i){const s=n(t),a=e(s,i);if(r(s))throw TypeError();super(t,!0,a,null),this._nativeMediaElementAudioSourceNode=a}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}})(Ge,(t,e)=>t.createMediaElementSource(e.mediaElement),Me,Pe),_r=((t,e,n,r)=>class extends t{constructor(t,i){const s=n(t);if(r(s))throw new TypeError;const a={...Et,...i},o=e(s,a);super(t,!1,o,null),this._nativeMediaStreamAudioDestinationNode=o}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}})(Ge,(t,e)=>{const n=t.createMediaStreamDestination();return Rt(n,e),1===n.numberOfOutputs&&Object.defineProperty(n,"numberOfOutputs",{get:()=>0}),n},Me,Pe),Or=((t,e,n,r)=>class extends t{constructor(t,i){const s=n(t),a=e(s,i);if(r(s))throw new TypeError;super(t,!0,a,null),this._nativeMediaStreamAudioSourceNode=a}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}})(Ge,(t,{mediaStream:e})=>{const n=e.getAudioTracks();n.sort((t,e)=>t.id<e.id?-1:t.id>e.id?1:0);const r=n.slice(0,1),i=t.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(i,"mediaStream",{value:e}),i},Me,Pe),Sr=((t,e,n)=>class extends t{constructor(t,r){const i=n(t);super(t,!0,e(i,r),null)}})(Ge,((t,e)=>(n,{mediaStreamTrack:r})=>{if("function"==typeof n.createMediaStreamTrackSource)return n.createMediaStreamTrackSource(r);const i=new MediaStream([r]),s=n.createMediaStreamSource(i);if("audio"!==r.kind)throw t();if(e(n))throw new TypeError;return s})(Ct,Pe),Me),kr=((t,e,n,r,i,s,a,o,u)=>class extends t{constructor(t={}){if(null===u)throw new Error("Missing the native AudioContext constructor.");const e=new u(t);if(null===e)throw r();if(!U(t.latencyHint))throw new TypeError(`The provided value '${t.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(void 0!==t.sampleRate&&e.sampleRate!==t.sampleRate)throw n();super(e,2);const{latencyHint:i}=t,{sampleRate:s}=e;if(this._baseLatency="number"==typeof e.baseLatency?e.baseLatency:"balanced"===i?512/s:"interactive"===i||void 0===i?256/s:"playback"===i?1024/s:128*Math.max(2,Math.min(128,Math.round(i*s/128)))/s,this._nativeAudioContext=e,"webkitAudioContext"===u.name?(this._nativeGainNode=e.createGain(),this._nativeOscillatorNode=e.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(e.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,"running"===e.state){this._state="suspended";const t=()=>{"suspended"===this._state&&(this._state=null),e.removeEventListener("statechange",t)};e.addEventListener("statechange",t)}}get baseLatency(){return this._baseLatency}get state(){return null!==this._state?this._state:this._nativeAudioContext.state}close(){return"closed"===this.state?this._nativeAudioContext.close().then(()=>{throw e()}):("suspended"===this._state&&(this._state=null),this._nativeAudioContext.close().then(()=>{null!==this._nativeGainNode&&null!==this._nativeOscillatorNode&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),V(this)}))}createMediaElementSource(t){return new i(this,{mediaElement:t})}createMediaStreamDestination(){return new s(this)}createMediaStreamSource(t){return new a(this,{mediaStream:t})}createMediaStreamTrackSource(t){return new o(this,{mediaStreamTrack:t})}resume(){return"suspended"===this._state?new Promise((t,e)=>{const n=()=>{this._nativeAudioContext.removeEventListener("statechange",n),"running"===this._nativeAudioContext.state?t():this.resume().then(t,e)};this._nativeAudioContext.addEventListener("statechange",n)}):this._nativeAudioContext.resume().catch(t=>{if(void 0===t||15===t.code)throw e();throw t})}suspend(){return this._nativeAudioContext.suspend().catch(t=>{if(void 0===t)throw e();throw t})}})(wr,Ct,Xt,ne,xr,_r,Or,Sr,Be),Tr=(Cr=Xn,t=>{const e=Cr.get(t);if(void 0===e)throw new Error("The context has no set of AudioWorkletNodes.");return e});var Cr;const Ar=(Nr=Tr,(t,e)=>{Nr(t).add(e)});var Nr;const Ir=(t=>(e,n,r=0,i=0)=>{const s=e[r];if(void 0===s)throw t();return ut(n)?s.connect(n,0,i):s.connect(n,0)})(M),Er=(t=>(e,n)=>{t(e).delete(n)})(Tr),jr=(t=>(e,n,r,i=0)=>void 0===n?e.forEach(t=>t.disconnect()):"number"==typeof n?St(t,e,n).disconnect():ut(n)?void 0===r?e.forEach(t=>t.disconnect(n)):void 0===i?St(t,e,r).disconnect(n,0):St(t,e,r).disconnect(n,0,i):void 0===r?e.forEach(t=>t.disconnect(n)):St(t,e,r).disconnect(n,0))(M),Mr=new WeakMap,Dr=((t,e)=>n=>e(t,n))(Mr,_),Rr=((t,e,n,r,i,s,a,o,u,c,l,h,d)=>(p,f,m,b)=>{if(0===b.numberOfInputs&&0===b.numberOfOutputs)throw u();const y=Array.isArray(b.outputChannelCount)?b.outputChannelCount:Array.from(b.outputChannelCount);if(y.some(t=>t<1))throw u();if(y.length!==b.numberOfOutputs)throw e();if("explicit"!==b.channelCountMode)throw u();const v=b.channelCount*b.numberOfInputs,w=y.reduce((t,e)=>t+e,0),x=void 0===m.parameterDescriptors?0:m.parameterDescriptors.length;if(v+x>6||w>6)throw u();const _=new MessageChannel,O=[],S=[];for(let t=0;t<b.numberOfInputs;t+=1)O.push(a(p,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1})),S.push(i(p,{channelCount:b.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:b.channelCount}));const k=[];if(void 0!==m.parameterDescriptors)for(const{defaultValue:t,maxValue:e,minValue:n,name:r}of m.parameterDescriptors){const i=s(p,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:void 0!==b.parameterData[r]?b.parameterData[r]:void 0===t?0:t});Object.defineProperties(i.offset,{defaultValue:{get:()=>void 0===t?0:t},maxValue:{get:()=>void 0===e?F:e},minValue:{get:()=>void 0===n?P:n}}),k.push(i)}const T=r(p,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,v+x)}),C=$t(f,p.sampleRate),A=o(p,C,v+x,Math.max(1,w)),N=i(p,{channelCount:Math.max(1,w),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,w)}),I=[];for(let t=0;t<b.numberOfOutputs;t+=1)I.push(r(p,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:y[t]}));for(let t=0;t<b.numberOfInputs;t+=1){O[t].connect(S[t]);for(let e=0;e<b.channelCount;e+=1)S[t].connect(T,e,t*b.channelCount+e)}const E=new dt(void 0===m.parameterDescriptors?[]:m.parameterDescriptors.map(({name:t},e)=>{const n=k[e];return n.connect(T,0,v+e),n.start(0),[t,n.offset]}));T.connect(A);let j=b.channelInterpretation,M=null;const D=0===b.numberOfOutputs?[A]:I,R={get bufferSize(){return C},get channelCount(){return b.channelCount},set channelCount(t){throw n()},get channelCountMode(){return b.channelCountMode},set channelCountMode(t){throw n()},get channelInterpretation(){return j},set channelInterpretation(t){for(const e of O)e.channelInterpretation=t;j=t},get context(){return A.context},get inputs(){return O},get numberOfInputs(){return b.numberOfInputs},get numberOfOutputs(){return b.numberOfOutputs},get onprocessorerror(){return M},set onprocessorerror(t){"function"==typeof M&&R.removeEventListener("processorerror",M),M="function"==typeof t?t:null,"function"==typeof M&&R.addEventListener("processorerror",M)},get parameters(){return E},get port(){return _.port2},addEventListener:(...t)=>A.addEventListener(t[0],t[1],t[2]),connect:t.bind(null,D),disconnect:c.bind(null,D),dispatchEvent:(...t)=>A.dispatchEvent(t[0]),removeEventListener:(...t)=>A.removeEventListener(t[0],t[1],t[2])},z=new Map;var L,$;_.port1.addEventListener=(L=_.port1.addEventListener,(...t)=>{if("message"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const n=z.get(t[1]);void 0!==n?t[1]=n:(t[1]=t=>{l(p.currentTime,p.sampleRate,()=>e(t))},z.set(e,t[1]))}}return L.call(_.port1,t[0],t[1],t[2])}),_.port1.removeEventListener=($=_.port1.removeEventListener,(...t)=>{if("message"===t[0]){const e=z.get(t[1]);void 0!==e&&(z.delete(t[1]),t[1]=e)}return $.call(_.port1,t[0],t[1],t[2])});let B=null;Object.defineProperty(_.port1,"onmessage",{get:()=>B,set:t=>{"function"==typeof B&&_.port1.removeEventListener("message",B),B="function"==typeof t?t:null,"function"==typeof B&&(_.port1.addEventListener("message",B),_.port1.start())}}),m.prototype.port=_.port1;let q=null;((t,e,n,r)=>{let i=g.get(t);void 0===i&&(i=new WeakMap,g.set(t,i));const s=Bt(n,r);return i.set(e,s),s})(p,R,m,b).then(t=>q=t);const V=gt(b.numberOfInputs,b.channelCount),U=gt(b.numberOfOutputs,y),W=void 0===m.parameterDescriptors?[]:m.parameterDescriptors.reduce((t,{name:e})=>({...t,[e]:new Float32Array(128)}),{});let G=!0;const H=()=>{b.numberOfOutputs>0&&A.disconnect(N);for(let t=0,e=0;t<b.numberOfOutputs;t+=1){const n=I[t];for(let r=0;r<y[t];r+=1)N.disconnect(n,e+r,r);e+=y[t]}},K=new Map;A.onaudioprocess=({inputBuffer:t,outputBuffer:e})=>{if(null!==q){const n=h(R);for(let r=0;r<C;r+=128){for(let e=0;e<b.numberOfInputs;e+=1)for(let n=0;n<b.channelCount;n+=1)ft(t,V[e],n,n,r);void 0!==m.parameterDescriptors&&m.parameterDescriptors.forEach(({name:e},n)=>{ft(t,W,e,v+n,r)});for(let t=0;t<b.numberOfInputs;t+=1)for(let e=0;e<y[t];e+=1)0===U[t][e].byteLength&&(U[t][e]=new Float32Array(128));try{const t=V.map((t,e)=>{if(n[e].size>0)return K.set(e,C/128),t;const r=K.get(e);return void 0===r?[]:(t.every(t=>t.every(t=>0===t))&&(1===r?K.delete(e):K.set(e,r-1)),t)}),i=l(p.currentTime+r/p.sampleRate,p.sampleRate,()=>q.process(t,U,W));G=i;for(let t=0,n=0;t<b.numberOfOutputs;t+=1){for(let i=0;i<y[t];i+=1)mt(e,U[t],i,n+i,r);n+=y[t]}}catch(t){G=!1,R.dispatchEvent(new ErrorEvent("processorerror",{colno:t.colno,filename:t.filename,lineno:t.lineno,message:t.message}))}if(!G){for(let t=0;t<b.numberOfInputs;t+=1){O[t].disconnect(S[t]);for(let e=0;e<b.channelCount;e+=1)S[r].disconnect(T,e,t*b.channelCount+e)}if(void 0!==m.parameterDescriptors){const t=m.parameterDescriptors.length;for(let e=0;e<t;e+=1){const t=k[e];t.disconnect(T,0,v+e),t.stop()}}T.disconnect(A),A.onaudioprocess=null,Q?H():J();break}}}};let Q=!1;const X=a(p,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),Y=()=>A.connect(X).connect(p.destination),J=()=>{A.disconnect(X),X.disconnect()};return Y(),d(R,()=>{if(G){J(),b.numberOfOutputs>0&&A.connect(N);for(let t=0,e=0;t<b.numberOfOutputs;t+=1){const n=I[t];for(let r=0;r<y[t];r+=1)N.connect(n,e+r,r);e+=y[t]}}Q=!0},()=>{G&&(Y(),H()),Q=!1})})(Ir,M,Ct,En,Vt,Rn,Gt,Qt,Xt,jr,fr,Dr,Cn),Pr=((t,e,n,r,i)=>(s,a,o,u,c,l)=>{if(null!==o)try{const e=new o(s,u,l),r=new Map;let a=null;if(Object.defineProperties(e,{channelCount:{get:()=>l.channelCount,set:()=>{throw t()}},channelCountMode:{get:()=>"explicit",set:()=>{throw t()}},onprocessorerror:{get:()=>a,set:t=>{"function"==typeof a&&e.removeEventListener("processorerror",a),a="function"==typeof t?t:null,"function"==typeof a&&e.addEventListener("processorerror",a)}}}),e.addEventListener=(d=e.addEventListener,(...t)=>{if("processorerror"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const n=r.get(t[1]);void 0!==n?t[1]=n:(t[1]=n=>{"error"===n.type?(Object.defineProperties(n,{type:{value:"processorerror"}}),e(n)):e(new ErrorEvent(t[0],{...n}))},r.set(e,t[1]))}}return d.call(e,"error",t[1],t[2]),d.call(e,...t)}),e.removeEventListener=(h=e.removeEventListener,(...t)=>{if("processorerror"===t[0]){const e=r.get(t[1]);void 0!==e&&(r.delete(t[1]),t[1]=e)}return h.call(e,"error",t[1],t[2]),h.call(e,t[0],t[1],t[2])}),0!==l.numberOfOutputs){const t=n(s,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});e.connect(t).connect(s.destination);return i(e,()=>t.disconnect(),()=>t.connect(s.destination))}return e}catch(t){if(11===t.code)throw r();throw t}var h,d;if(void 0===c)throw r();return(t=>{const{port1:e}=new MessageChannel;try{e.postMessage(t)}finally{e.close()}})(l),e(s,a,c,l)})(Ct,Rr,Gt,Xt,Cn),Fr=((t,e,n,r,i,s,a,o,u,c,l,h,d,p,f,m)=>(g,b,y)=>{const v=new WeakMap;let w=null;return{render(x,_,O){o(_,x);const S=v.get(_);return void 0!==S?Promise.resolve(S):(async(o,x,_)=>{let O=l(o),S=null;const k=E(O,x),T=Array.isArray(b.outputChannelCount)?b.outputChannelCount:Array.from(b.outputChannelCount);if(null===h){const t=T.reduce((t,e)=>t+e,0),n=i(x,{channelCount:Math.max(1,t),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,t)}),s=[];for(let t=0;t<o.numberOfOutputs;t+=1)s.push(r(x,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:T[t]}));const c=a(x,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1});c.connect=e.bind(null,s),c.disconnect=u.bind(null,s),S=[n,s,c]}else k||(O=new h(x,g));if(v.set(x,null===S?O:S[2]),null!==S){if(null===w){if(void 0===y)throw new Error("Missing the processor constructor.");if(null===d)throw new Error("Missing the native OfflineAudioContext constructor.");const t=o.channelCount*o.numberOfInputs,e=void 0===y.parameterDescriptors?0:y.parameterDescriptors.length,n=t+e,u=async()=>{const u=new d(n,128*Math.ceil(o.context.length/128),x.sampleRate),c=[],l=[];for(let t=0;t<b.numberOfInputs;t+=1)c.push(a(u,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1})),l.push(i(u,{channelCount:b.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:b.channelCount}));const h=await Promise.all(Array.from(o.parameters.values()).map(async t=>{const e=s(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:t.value});return await p(u,t,e.offset,_),e})),g=r(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,t+e)});for(let t=0;t<b.numberOfInputs;t+=1){c[t].connect(l[t]);for(let e=0;e<b.channelCount;e+=1)l[t].connect(g,e,t*b.channelCount+e)}for(const[e,n]of h.entries())n.connect(g,0,t+e),n.start(0);return g.connect(u.destination),await Promise.all(c.map(t=>f(o,u,t,_))),m(u)};w=bt(o,0===n?null:await u(),x,b,T,y,c)}const t=await w,e=n(x,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[u,l,h]=S;null!==t&&(e.buffer=t,e.start(0)),e.connect(u);for(let t=0,e=0;t<o.numberOfOutputs;t+=1){const n=l[t];for(let r=0;r<T[t];r+=1)u.connect(n,e+r,r);e+=T[t]}return h}if(k)for(const[e,n]of o.parameters.entries())await t(x,n,O.parameters.get(e),_);else for(const[t,e]of o.parameters.entries())await p(x,e,O.parameters.get(t),_);return await f(o,x,O,_),O})(x,_,O)}}})(on,Ir,un,En,Vt,Rn,Gt,Er,jr,fr,nt,br,Re,ln,Ae,Wn),zr=(t=>e=>t.get(e))(mr),Lr=(t=>(e,n)=>{t.set(e,n)})(Mr),$r=pr?((t,e,n,r,i,s,a,o,u,c,l,h,d)=>class extends e{constructor(e,d,p){var f;const g=o(e),b=u(g),y=l({...pt,...p}),v=m.get(g),w=null==v?void 0:v.get(d),x=b||"closed"!==g.state?g:null!==(f=a(g))&&void 0!==f?f:g,_=i(x,b?null:e.baseLatency,c,d,w,y);super(e,!0,_,b?r(d,y,w):null);const O=[];_.parameters.forEach((t,e)=>{const r=n(this,b,t);O.push([e,r])}),this._nativeAudioWorkletNode=_,this._onprocessorerror=null,this._parameters=new dt(O),b&&t(g,this);const{activeInputs:S}=s(this);h(_,S)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(t){const e="function"==typeof t?d(this,t):null;this._nativeAudioWorkletNode.onprocessorerror=e;const n=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=null!==n&&n===e?t:n}get parameters(){return null===this._parameters?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}})(Ar,Ge,dn,Fr,Pr,$,zr,Me,Pe,br,t=>({...t,outputChannelCount:void 0!==t.outputChannelCount?t.outputChannelCount:1===t.numberOfInputs&&1===t.numberOfOutputs?[t.channelCount]:Array.from({length:t.numberOfOutputs},()=>1)}),Lr,de):void 0,Br=(((t,e,n,r,i)=>{})(Ct,Xt,ne,Yn,Be),((t,e)=>(n,r,i)=>{if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new e(n,r,i)}catch(e){if("SyntaxError"===e.name)throw t();throw e}})(Xt,Re)),qr=((t,e,n,r,i,s,a,o)=>{const u=[];return(c,l)=>n(c).render(c,l,u).then(()=>Promise.all(Array.from(r(l)).map(t=>n(t).render(t,l,u)))).then(()=>i(l)).then(n=>("function"!=typeof n.copyFromChannel?(a(n),D(n)):e(s,()=>s(n))||o(n),t.add(n),n))})(Qe,ve,Te,Tr,Wn,j,Ze,tn),Vr=(((t,e,n,r,i)=>{})(ve,Ct,Br,Yn,qr),((t,e,n,r,i)=>class extends t{constructor(t,n,i){let s;if("number"==typeof t&&void 0!==n&&void 0!==i)s={length:n,numberOfChannels:t,sampleRate:i};else{if("object"!=typeof t)throw new Error("The given parameters are not valid.");s=t}const{length:a,numberOfChannels:o,sampleRate:u}={...Yt,...s},c=r(o,a,u);e(jt,()=>jt(c))||c.addEventListener("statechange",(()=>{let t=0;const e=n=>{"running"===this._state&&(t>0?(c.removeEventListener("statechange",e),n.stopImmediatePropagation(),this._waitForThePromiseToSettle(n)):t+=1)};return e})()),super(c,o),this._length=a,this._nativeOfflineAudioContext=c,this._state=null}get length(){return void 0===this._nativeOfflineAudioContext.length?this._length:this._nativeOfflineAudioContext.length}get state(){return null===this._state?this._nativeOfflineAudioContext.state:this._state}startRendering(){return"running"===this._state?Promise.reject(n()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,V(this)}))}_waitForThePromiseToSettle(t){null===this._state?this._nativeOfflineAudioContext.dispatchEvent(t):setTimeout(()=>this._waitForThePromiseToSettle(t))}})(wr,ve,Ct,Br,qr)),Ur=((t,e)=>n=>{const r=t.get(n);return e(r)||e(n)})(d,qe),Wr=(Gr=c,Hr=Ue,t=>Gr.has(t)||Hr(t));var Gr,Hr;const Kr=(Qr=h,Xr=We,t=>Qr.has(t)||Xr(t));var Qr,Xr;const Yr=((t,e)=>n=>{const r=t.get(n);return e(r)||e(n)})(d,Pe),Jr=()=>(async(t,e,n,r,i,s,a,o,u,c,l,h,d,p,f,m)=>{if(t(e,e)&&t(n,n)&&t(i,i)&&t(s,s)&&t(o,o)&&t(u,u)&&t(c,c)&&t(l,l)&&t(h,h)&&t(d,d)&&t(p,p)){return(await Promise.all([t(r,r),t(a,a),t(f,f),t(m,m)])).every(t=>t)}return!1})(ve,(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createBuffer(1,1,44100);if(void 0===e.copyToChannel)return!0;const n=new Float32Array(2);try{e.copyFromChannel(n,0,0)}catch{return!1}return!0})(Re),(t=>()=>{if(null===t)return!1;if(void 0!==t.prototype&&void 0!==t.prototype.close)return!0;const e=new t,n=void 0!==e.close;try{e.close()}catch{}return n})(Be),(t=>()=>{if(null===t)return Promise.resolve(!1);const e=new t(1,1,44100);return new Promise(t=>{let n=!0;const r=r=>{n&&(n=!1,e.startRendering(),t(r instanceof TypeError))};let i;try{i=e.decodeAudioData(null,()=>{},r)}catch(t){r(t)}void 0!==i&&i.catch(r)})})(Re),(t=>()=>{if(null===t)return!1;let e;try{e=new t({latencyHint:"balanced"})}catch{return!1}return e.close(),!0})(Be),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createGain(),n=e.connect(e)===e;return e.disconnect(e),n})(Re),((t,e)=>async()=>{if(null===t)return!0;if(null===e)return!1;const n=new Blob(['class A extends AudioWorkletProcessor{process(){this.port.postMessage(0)}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),r=new e(1,128,8e3),i=URL.createObjectURL(n);let s=!1;try{await r.audioWorklet.addModule(i);const e=new t(r,"a",{numberOfOutputs:0}),n=r.createOscillator();e.port.onmessage=()=>s=!0,n.connect(e),n.start(0),await r.startRendering(),s||await new Promise(t=>setTimeout(t,5))}catch{}finally{URL.revokeObjectURL(i)}return s})(br,Re),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createChannelMerger();if("max"===e.channelCountMode)return!0;try{e.channelCount=2}catch{return!0}return!1})(Re),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100);if(void 0===e.createConstantSource)return!0;return e.createConstantSource().offset.maxValue!==Number.POSITIVE_INFINITY})(Re),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100),n=e.createConvolver();n.buffer=e.createBuffer(1,1,e.sampleRate);try{n.buffer=e.createBuffer(1,1,e.sampleRate)}catch{return!1}return!0})(Re),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createConvolver();try{e.channelCount=1}catch{return!1}return!0})(Re),ce,(t=>()=>null!==t&&t.hasOwnProperty("isSecureContext"))(_e),(t=>()=>{if(null===t)return!1;const e=new t;try{return e.createMediaStreamSource(new MediaStream),!1}catch(t){return!0}})(Be),(t=>()=>{if(null===t)return Promise.resolve(!1);const e=new t(1,1,44100);if(void 0===e.createStereoPanner)return Promise.resolve(!0);if(void 0===e.createConstantSource)return Promise.resolve(!0);const n=e.createConstantSource(),r=e.createStereoPanner();return n.channelCount=1,n.offset.value=1,r.channelCount=1,n.start(),n.connect(r).connect(e.destination),e.startRendering().then(t=>1!==t.getChannelData(0)[0])})(Re),le);function Zr(t,e){if(!t)throw new Error(e)}function ti(t,e,n=1/0){if(!(e<=t&&t<=n))throw new RangeError(`Value must be within [${e}, ${n}], got: ${t}`)}function ei(t){t.isOffline||"running"===t.state||si('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}let ni=console;function ri(t){ni=t}function ii(...t){ni.log(...t)}function si(...t){ni.warn(...t)}function ai(t){return void 0===t}function oi(t){return!ai(t)}function ui(t){return"function"==typeof t}function ci(t){return"number"==typeof t}function li(t){return"[object Object]"===Object.prototype.toString.call(t)&&t.constructor===Object}function hi(t){return"boolean"==typeof t}function di(t){return Array.isArray(t)}function pi(t){return"string"==typeof t}function fi(t){return pi(t)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(t)}const mi="object"==typeof self?self:null,gi=mi&&(mi.hasOwnProperty("AudioContext")||mi.hasOwnProperty("webkitAudioContext"));function bi(t,e,n,r){var i,s=arguments.length,a=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var o=t.length-1;o>=0;o--)(i=t[o])&&(a=(s<3?i(a):s>3?i(e,n,a):i(e,n))||a);return s>3&&a&&Object.defineProperty(e,n,a),a}function yi(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))}Object.create;Object.create;class vi{constructor(t,e,n){this._callback=t,this._type=e,this._updateInterval=n,this._createClock()}_createWorker(){const t=new Blob([`\n\t\t\t// the initial timeout time\n\t\t\tlet timeoutTime =  ${(1e3*this._updateInterval).toFixed(1)};\n\t\t\t// onmessage callback\n\t\t\tself.onmessage = function(msg){\n\t\t\t\ttimeoutTime = parseInt(msg.data);\n\t\t\t};\n\t\t\t// the tick function which posts a message\n\t\t\t// and schedules a new tick\n\t\t\tfunction tick(){\n\t\t\t\tsetTimeout(tick, timeoutTime);\n\t\t\t\tself.postMessage('tick');\n\t\t\t}\n\t\t\t// call tick initially\n\t\t\ttick();\n\t\t\t`],{type:"text/javascript"}),e=URL.createObjectURL(t),n=new Worker(e);n.onmessage=this._callback.bind(this),this._worker=n}_createTimeout(){this._timeout=setTimeout(()=>{this._createTimeout(),this._callback()},1e3*this._updateInterval)}_createClock(){if("worker"===this._type)try{this._createWorker()}catch(t){this._type="timeout",this._createClock()}else"timeout"===this._type&&this._createTimeout()}_disposeClock(){this._timeout&&(clearTimeout(this._timeout),this._timeout=0),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(t){this._updateInterval=Math.max(t,128/44100),"worker"===this._type&&this._worker.postMessage(Math.max(1e3*t,1))}get type(){return this._type}set type(t){this._disposeClock(),this._type=t,this._createClock()}dispose(){this._disposeClock()}}function wi(t){return Kr(t)}function xi(t){return Wr(t)}function _i(t){return Yr(t)}function Oi(t){return Ur(t)}function Si(t){return t instanceof AudioBuffer}function ki(t,e){return"value"===t||wi(e)||xi(e)||Si(e)}function Ti(t,...e){if(!e.length)return t;const n=e.shift();if(li(t)&&li(n))for(const e in n)ki(e,n[e])?t[e]=n[e]:li(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Ti(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Ti(t,...e)}function Ci(t,e,n=[],r){const i={},s=Array.from(e);if(li(s[0])&&r&&!Reflect.has(s[0],r)){Object.keys(s[0]).some(e=>Reflect.has(t,e))||(Ti(i,{[r]:s[0]}),n.splice(n.indexOf(r),1),s.shift())}if(1===s.length&&li(s[0]))Ti(i,s[0]);else for(let t=0;t<n.length;t++)oi(s[t])&&(i[n[t]]=s[t]);return Ti(t,i)}function Ai(t,e){return ai(t)?e:t}function Ni(t,e){return e.forEach(e=>{Reflect.has(t,e)&&delete t[e]}),t}
/**
 * Tone.js
 * @author Yotam Mann
 * @license http://opensource.org/licenses/MIT MIT License
 * @copyright 2014-2019 Yotam Mann
 */class Ii{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||mi&&this.toString()===mi.TONE_DEBUG_CLASS)&&ii(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}}Ii.version=s;function Ei(t,e){return t>e+1e-6}function ji(t,e){return Ei(t,e)||Di(t,e)}function Mi(t,e){return t+1e-6<e}function Di(t,e){return Math.abs(t-e)<1e-6}function Ri(t,e,n){return Math.max(Math.min(t,n),e)}class Pi extends Ii{constructor(){super(),this.name="Timeline",this._timeline=[];const t=Ci(Pi.getDefaults(),arguments,["memory"]);this.memory=t.memory,this.increasing=t.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(t){if(Zr(Reflect.has(t,"time"),"Timeline: events must have a time attribute"),t.time=t.time.valueOf(),this.increasing&&this.length){const e=this._timeline[this.length-1];Zr(ji(t.time,e.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(t)}else{const e=this._search(t.time);this._timeline.splice(e+1,0,t)}if(this.length>this.memory){const t=this.length-this.memory;this._timeline.splice(0,t)}return this}remove(t){const e=this._timeline.indexOf(t);return-1!==e&&this._timeline.splice(e,1),this}get(t,e="time"){const n=this._search(t,e);return-1!==n?this._timeline[n]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){const n=this._search(t,e);return n+1<this._timeline.length?this._timeline[n+1]:null}getBefore(t){const e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];const n=this._search(t);return n-1>=0?this._timeline[n-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(Di(this._timeline[e].time,t)){for(let n=e;n>=0&&Di(this._timeline[n].time,t);n--)e=n;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else 1===this._timeline.length&&ji(this._timeline[0].time,t)&&(this._timeline=[]);return this}cancelBefore(t){const e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this}previousEvent(t){const e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null}_search(t,e="time"){if(0===this._timeline.length)return-1;let n=0;const r=this._timeline.length;let i=r;if(r>0&&this._timeline[r-1][e]<=t)return r-1;for(;n<i;){let r=Math.floor(n+(i-n)/2);const s=this._timeline[r],a=this._timeline[r+1];if(Di(s[e],t)){for(let n=r;n<this._timeline.length;n++){if(!Di(this._timeline[n][e],t))break;r=n}return r}if(Mi(s[e],t)&&Ei(a[e],t))return r;Ei(s[e],t)?i=r:n=r+1}return-1}_iterate(t,e=0,n=this._timeline.length-1){this._timeline.slice(e,n+1).forEach(t)}forEach(t){return this._iterate(t),this}forEachBefore(t,e){const n=this._search(t);return-1!==n&&this._iterate(e,0,n),this}forEachAfter(t,e){const n=this._search(t);return this._iterate(e,n+1),this}forEachBetween(t,e,n){let r=this._search(t),i=this._search(e);return-1!==r&&-1!==i?(this._timeline[r].time!==t&&(r+=1),this._timeline[i].time===e&&(i-=1),this._iterate(n,r,i)):-1===r&&this._iterate(n,0,i),this}forEachFrom(t,e){let n=this._search(t);for(;n>=0&&this._timeline[n].time>=t;)n--;return this._iterate(e,n+1),this}forEachAtTime(t,e){const n=this._search(t);if(-1!==n&&Di(this._timeline[n].time,t)){let r=n;for(let e=n;e>=0&&Di(this._timeline[e].time,t);e--)r=e;this._iterate(t=>{e(t)},r,n)}return this}dispose(){return super.dispose(),this._timeline=[],this}}const Fi=[];function zi(t){Fi.push(t)}const Li=[];function $i(t){Li.push(t)}class Bi extends Ii{constructor(){super(...arguments),this.name="Emitter"}on(t,e){return t.split(/\W+/).forEach(t=>{ai(this._events)&&(this._events={}),this._events.hasOwnProperty(t)||(this._events[t]=[]),this._events[t].push(e)}),this}once(t,e){const n=(...r)=>{e(...r),this.off(t,n)};return this.on(t,n),this}off(t,e){return t.split(/\W+/).forEach(n=>{if(ai(this._events)&&(this._events={}),this._events.hasOwnProperty(t))if(ai(e))this._events[t]=[];else{const n=this._events[t];for(let t=n.length-1;t>=0;t--)n[t]===e&&n.splice(t,1)}}),this}emit(t,...e){if(this._events&&this._events.hasOwnProperty(t)){const n=this._events[t].slice(0);for(let t=0,r=n.length;t<r;t++)n[t].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach(e=>{const n=Object.getOwnPropertyDescriptor(Bi.prototype,e);Object.defineProperty(t.prototype,e,n)})}dispose(){return super.dispose(),this._events=void 0,this}}class qi extends Bi{constructor(){super(...arguments),this.isOffline=!1}}class Vi extends qi{constructor(){super(),this.name="Context",this._constants=new Map,this._timeouts=new Pi,this._timeoutIds=0,this._initialized=!1,this.isOffline=!1,this._workletModules=new Map;const t=Ci(Vi.getDefaults(),arguments,["context"]);t.context?this._context=t.context:this._context=function(t){return new kr(t)}({latencyHint:t.latencyHint}),this._ticker=new vi(this.emit.bind(this,"tick"),t.clockSource,t.updateInterval),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this._setLatencyHint(t.latencyHint),this.lookAhead=t.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){var t;return this._initialized||(t=this,Fi.forEach(e=>e(t)),this._initialized=!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(t,e,n){return this._context.createBuffer(t,e,n)}createChannelMerger(t){return this._context.createChannelMerger(t)}createChannelSplitter(t){return this._context.createChannelSplitter(t)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(t){return this._context.createDelay(t)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(t,e){return this._context.createIIRFilter(t,e)}createPanner(){return this._context.createPanner()}createPeriodicWave(t,e,n){return this._context.createPeriodicWave(t,e,n)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(t){Zr(Oi(this._context),"Not available if OfflineAudioContext");return this._context.createMediaStreamSource(t)}createMediaStreamDestination(){Zr(Oi(this._context),"Not available if OfflineAudioContext");return this._context.createMediaStreamDestination()}decodeAudioData(t){return this._context.decodeAudioData(t)}get currentTime(){return this._context.currentTime}get state(){return this._context.state}get sampleRate(){return this._context.sampleRate}get listener(){return this.initialize(),this._listener}set listener(t){Zr(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){Zr(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){Zr(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){Zr(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return function(t,e,n){return Zr(oi($r),"This node only works in a secure context (https or localhost)"),new $r(t,e,n)}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */(this.rawContext,t,e)}addAudioWorkletModule(t,e){return yi(this,void 0,void 0,(function*(){Zr(oi(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletModules.has(e)||this._workletModules.set(e,this.rawContext.audioWorklet.addModule(t)),yield this._workletModules.get(e)}))}workletsAreReady(){return yi(this,void 0,void 0,(function*(){const t=[];this._workletModules.forEach(e=>t.push(e)),yield Promise.all(t)}))}get updateInterval(){return this._ticker.updateInterval}set updateInterval(t){this._ticker.updateInterval=t}get clockSource(){return this._ticker.type}set clockSource(t){this._ticker.type=t}get latencyHint(){return this._latencyHint}_setLatencyHint(t){let e=0;if(this._latencyHint=t,pi(t))switch(t){case"interactive":e=.1;break;case"playback":e=.5;break;case"balanced":e=.25}this.lookAhead=e,this.updateInterval=e/2}get rawContext(){return this._context}now(){return this._context.currentTime+this.lookAhead}immediate(){return this._context.currentTime}resume(){return"suspended"===this._context.state&&Oi(this._context)?this._context.resume():Promise.resolve()}close(){return yi(this,void 0,void 0,(function*(){var t;Oi(this._context)&&(yield this._context.close()),this._initialized&&(t=this,Li.forEach(e=>e(t)))}))}getConstant(t){if(this._constants.has(t))return this._constants.get(t);{const e=this._context.createBuffer(1,128,this._context.sampleRate),n=e.getChannelData(0);for(let e=0;e<n.length;e++)n[e]=t;const r=this._context.createBufferSource();return r.channelCount=1,r.channelCountMode="explicit",r.buffer=e,r.loop=!0,r.start(0),this._constants.set(t,r),r}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(t=>this._constants[t].disconnect()),this}_timeoutLoop(){const t=this.now();let e=this._timeouts.peek();for(;this._timeouts.length&&e&&e.time<=t;)e.callback(),this._timeouts.shift(),e=this._timeouts.peek()}setTimeout(t,e){this._timeoutIds++;const n=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:n+e}),this._timeoutIds}clearTimeout(t){return this._timeouts.forEach(e=>{e.id===t&&this._timeouts.remove(e)}),this}clearInterval(t){return this.clearTimeout(t)}setInterval(t,e){const n=++this._timeoutIds,r=()=>{const i=this.now();this._timeouts.add({callback:()=>{t(),r()},id:n,time:i+e})};return r(),n}}function Ui(t,e){di(e)?e.forEach(e=>Ui(t,e)):Object.defineProperty(t,e,{enumerable:!0,writable:!1})}function Wi(t,e){di(e)?e.forEach(e=>Wi(t,e)):Object.defineProperty(t,e,{writable:!0})}const Gi=()=>{};class Hi extends Ii{constructor(){super(),this.name="ToneAudioBuffer",this.onload=Gi;const t=Ci(Hi.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,t.url&&Si(t.url)||t.url instanceof Hi?this.set(t.url):pi(t.url)&&this.load(t.url).catch(t.onerror)}static getDefaults(){return{onerror:Gi,onload:Gi,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Yi().sampleRate}set(t){return t instanceof Hi?t.loaded?this._buffer=t.get():t.onload=()=>{this.set(t),this.onload(this)}:this._buffer=t,this._reversed&&this._reverse(),this}get(){return this._buffer}load(t){return yi(this,void 0,void 0,(function*(){const e=Hi.load(t).then(t=>{this.set(t),this.onload(this)});Hi.downloads.push(e);try{yield e}finally{const t=Hi.downloads.indexOf(e);Hi.downloads.splice(t,1)}return this}))}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){const e=di(t)&&t[0].length>0,n=e?t.length:1,r=e?t[0].length:t.length,i=Yi(),s=i.createBuffer(n,r,i.sampleRate),a=e||1!==n?t:[t];for(let t=0;t<n;t++)s.copyToChannel(a[t],t);return this._buffer=s,this}toMono(t){if(ci(t))this.fromArray(this.toArray(t));else{let t=new Float32Array(this.length);const e=this.numberOfChannels;for(let n=0;n<e;n++){const e=this.toArray(n);for(let n=0;n<e.length;n++)t[n]+=e[n]}t=t.map(t=>t/e),this.fromArray(t)}return this}toArray(t){if(ci(t))return this.getChannelData(t);if(1===this.numberOfChannels)return this.toArray(0);{const t=[];for(let e=0;e<this.numberOfChannels;e++)t[e]=this.getChannelData(e);return t}}getChannelData(t){return this._buffer?this._buffer.getChannelData(t):new Float32Array(0)}slice(t,e=this.duration){const n=Math.floor(t*this.sampleRate),r=Math.floor(e*this.sampleRate);Zr(n<r,"The start time must be less than the end time");const i=r-n,s=Yi().createBuffer(this.numberOfChannels,i,this.sampleRate);for(let t=0;t<this.numberOfChannels;t++)s.copyToChannel(this.getChannelData(t).subarray(n,r),t);return new Hi(s)}_reverse(){if(this.loaded)for(let t=0;t<this.numberOfChannels;t++)this.getChannelData(t).reverse();return this}get loaded(){return this.length>0}get duration(){return this._buffer?this._buffer.duration:0}get length(){return this._buffer?this._buffer.length:0}get numberOfChannels(){return this._buffer?this._buffer.numberOfChannels:0}get reverse(){return this._reversed}set reverse(t){this._reversed!==t&&(this._reversed=t,this._reverse())}static fromArray(t){return(new Hi).fromArray(t)}static fromUrl(t){return yi(this,void 0,void 0,(function*(){const e=new Hi;return yield e.load(t)}))}static load(t){return yi(this,void 0,void 0,(function*(){const e=t.match(/\[(.+\|?)+\]$/);if(e){const n=e[1].split("|");let r=n[0];for(const t of n)if(Hi.supportsType(t)){r=t;break}t=t.replace(e[0],r)}const n=""===Hi.baseUrl||Hi.baseUrl.endsWith("/")?Hi.baseUrl:Hi.baseUrl+"/",r=yield fetch(n+t);if(!r.ok)throw new Error("could not load url: "+t);const i=yield r.arrayBuffer();return yield Yi().decodeAudioData(i)}))}static supportsType(t){const e=t.split("."),n=e[e.length-1];return""!==document.createElement("audio").canPlayType("audio/"+n)}static loaded(){return yi(this,void 0,void 0,(function*(){for(yield Promise.resolve();Hi.downloads.length;)yield Hi.downloads[0]}))}}Hi.baseUrl="",Hi.downloads=[];class Ki extends Vi{constructor(){var t,e,n;super({clockSource:"offline",context:_i(arguments[0])?arguments[0]:(t=arguments[0],e=arguments[1]*arguments[2],n=arguments[2],new Vr(t,e,n)),lookAhead:0,updateInterval:_i(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=_i(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(t){return yi(this,void 0,void 0,(function*(){let e=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,e++;const n=Math.floor(this.sampleRate/128);t&&e%n==0&&(yield new Promise(t=>setTimeout(t,1)))}}))}render(t=!0){return yi(this,void 0,void 0,(function*(){yield this.workletsAreReady(),yield this._renderClock(t);const e=yield this._context.startRendering();return new Hi(e)}))}close(){return Promise.resolve()}}const Qi=new class extends qi{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(t,e,n){return{}}createChannelMerger(t){return{}}createChannelSplitter(t){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(t){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(t,e){return{}}createPanner(){return{}}createPeriodicWave(t,e,n){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(t){return{}}createMediaStreamDestination(){return{}}decodeAudioData(t){return Promise.resolve({})}createAudioWorkletNode(t,e){return{}}get rawContext(){return{}}addAudioWorkletModule(t,e){return yi(this,void 0,void 0,(function*(){return Promise.resolve()}))}resume(){return Promise.resolve()}setTimeout(t,e){return 0}clearTimeout(t){return this}setInterval(t,e){return 0}clearInterval(t){return this}getConstant(t){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(t){}get destination(){return{}}set destination(t){}now(){return 0}immediate(){return 0}};let Xi=Qi;function Yi(){return Xi===Qi&&gi&&Ji(new Vi),Xi}function Ji(t){Xi=Oi(t)?new Vi(t):_i(t)?new Ki(t):t}function Zi(){return Xi.resume()}if(mi&&!mi.TONE_SILENCE_LOGGING){let t="v";"dev"===s&&(t="");const e=` * Tone.js ${t}${s} * `;console.log("%c"+e,"background: #000; color: #fff")}function ts(t){return Math.pow(10,t/20)}function es(t){return Math.log(t)/Math.LN10*20}function ns(t){return Math.pow(2,t/12)}let rs=440;function is(t){return Math.round(ss(t))}function ss(t){return 69+12*Math.log2(t/rs)}function as(t){return rs*Math.pow(2,(t-69)/12)}class os extends Ii{constructor(t,e,n){super(),this.defaultUnits="s",this._val=e,this._units=n,this.context=t,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:t=>this._frequencyToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:t=>this._ticksToUnits(parseInt(t,10)),regexp:/^(\d+)i$/i},m:{method:t=>this._beatsToUnits(parseInt(t,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(t,e)=>{const n=parseInt(t,10),r="."===e?1.5:1;return 1===n?this._beatsToUnits(this._getTimeSignature())*r:this._beatsToUnits(4/n)*r},regexp:/^(\d+)n(\.?)$/i},number:{method:t=>this._expressions[this.defaultUnits].method.call(this,t),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:t=>this._secondsToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:t=>parseInt(t,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:t=>{const e=parseInt(t,10);return this._beatsToUnits(8/(3*Math.floor(e)))},regexp:/^(\d+)t$/i},tr:{method:(t,e,n)=>{let r=0;return t&&"0"!==t&&(r+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(r+=this._beatsToUnits(parseFloat(e))),n&&"0"!==n&&(r+=this._beatsToUnits(parseFloat(n)/4)),r},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof os&&this.fromType(this._val),ai(this._val))return this._noArg();if(pi(this._val)&&ai(this._units)){for(const t in this._expressions)if(this._expressions[t].regexp.test(this._val.trim())){this._units=t;break}}else if(li(this._val)){let t=0;for(const e in this._val)if(oi(this._val[e])){const n=this._val[e];t+=new this.constructor(this.context,e).valueOf()*n}return t}if(oi(this._units)){const t=this._expressions[this._units],e=this._val.toString().trim().match(t.regexp);return e?t.method.apply(this,e.slice(1)):t.method.call(this,this._val)}return pi(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(t){return 1/t}_beatsToUnits(t){return 60/this._getBpm()*t}_secondsToUnits(t){return t}_ticksToUnits(t){return t*this._beatsToUnits(1)/this._getPPQ()}_noArg(){return this._now()}_getBpm(){return this.context.transport.bpm.value}_getTimeSignature(){return this.context.transport.timeSignature}_getPPQ(){return this.context.transport.PPQ}fromType(t){switch(this._units=void 0,this.defaultUnits){case"s":this._val=t.toSeconds();break;case"i":this._val=t.toTicks();break;case"hz":this._val=t.toFrequency();break;case"midi":this._val=t.toMidi()}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return 1e3*this.toSeconds()}}class us extends os{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:t=>this._now()+new this.constructor(this.context,t).valueOf(),regexp:/^\+(.+)/},quantize:{method:t=>{const e=new us(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(e))},regexp:/^@(.+)/}})}quantize(t,e=1){const n=new this.constructor(this.context,t).valueOf(),r=this.valueOf();return r+(Math.round(r/n)*n-r)*e}toNotation(){const t=this.toSeconds(),e=["1m"];for(let t=1;t<9;t++){const n=Math.pow(2,t);e.push(n+"n."),e.push(n+"n"),e.push(n+"t")}e.push("0");let n=e[0],r=new us(this.context,e[0]).toSeconds();return e.forEach(e=>{const i=new us(this.context,e).toSeconds();Math.abs(i-t)<Math.abs(r-t)&&(n=e,r=i)}),n}toBarsBeatsSixteenths(){const t=this._beatsToUnits(1);let e=this.valueOf()/t;e=parseFloat(e.toFixed(4));const n=Math.floor(e/this._getTimeSignature());let r=e%1*4;e=Math.floor(e)%this._getTimeSignature();const i=r.toString();i.length>3&&(r=parseFloat(parseFloat(i).toFixed(3)));return[n,e,r].join(":")}toTicks(){const t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.round(e*this._getPPQ())}toSeconds(){return this.valueOf()}toMidi(){return is(this.toFrequency())}_now(){return this.context.now()}}function cs(t,e){return new us(Yi(),t,e)}class ls extends us{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return rs}static set A4(t){!function(t){rs=t}(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return"midi"===this.defaultUnits?t:ls.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,method(t,e){const n=hs[t.toLowerCase()]+12*(parseInt(e,10)+1);return"midi"===this.defaultUnits?n:ls.mtof(n)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(t,e,n){let r=1;return t&&"0"!==t&&(r*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(r*=this._beatsToUnits(parseFloat(e))),n&&"0"!==n&&(r*=this._beatsToUnits(parseFloat(n)/4)),r}}})}transpose(t){return new ls(this.context,this.valueOf()*ns(t))}harmonize(t){return t.map(t=>this.transpose(t))}toMidi(){return is(this.valueOf())}toNote(){const t=this.toFrequency(),e=Math.log2(t/ls.A4);let n=Math.round(12*e)+57;const r=Math.floor(n/12);r<0&&(n+=-12*r);return ds[n%12]+r.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){const t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(t){return t}_ticksToUnits(t){return 1/(60*t/(this._getBpm()*this._getPPQ()))}_beatsToUnits(t){return 1/super._beatsToUnits(t)}_secondsToUnits(t){return 1/t}static mtof(t){return as(t)}static ftom(t){return is(t)}}const hs={cbb:-2,cb:-1,c:0,"c#":1,cx:2,dbb:0,db:1,d:2,"d#":3,dx:4,ebb:2,eb:3,e:4,"e#":5,ex:6,fbb:3,fb:4,f:5,"f#":6,fx:7,gbb:5,gb:6,g:7,"g#":8,gx:9,abb:7,ab:8,a:9,"a#":10,ax:11,bbb:9,bb:10,b:11,"b#":12,bx:13},ds=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];function ps(t,e){return new ls(Yi(),t,e)}class fs extends us{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}}function ms(t,e){return new fs(Yi(),t,e)}class gs extends Ii{constructor(){super();const t=Ci(gs.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=t.context}static getDefaults(){return{context:Yi()}}now(){return this.context.currentTime+this.context.lookAhead}immediate(){return this.context.currentTime}get sampleTime(){return 1/this.context.sampleRate}get blockTime(){return 128/this.context.sampleRate}toSeconds(t){return new us(this.context,t).toSeconds()}toFrequency(t){return new ls(this.context,t).toFrequency()}toTicks(t){return new fs(this.context,t).toTicks()}_getPartialProperties(t){const e=this.get();return Object.keys(e).forEach(n=>{ai(t[n])&&delete e[n]}),e}get(){const t=this.constructor.getDefaults();return Object.keys(t).forEach(e=>{if(Reflect.has(this,e)){const n=this[e];oi(n)&&oi(n.value)&&oi(n.setValueAtTime)?t[e]=n.value:n instanceof gs?t[e]=n._getPartialProperties(t[e]):di(n)||ci(n)||pi(n)||hi(n)?t[e]=n:delete t[e]}}),t}set(t){return Object.keys(t).forEach(e=>{Reflect.has(this,e)&&oi(this[e])&&(this[e]&&oi(this[e].value)&&oi(this[e].setValueAtTime)?this[e].value!==t[e]&&(this[e].value=t[e]):this[e]instanceof gs?this[e].set(t[e]):this[e]=t[e])}),this}}class bs extends Pi{constructor(t="stopped"){super(),this.name="StateTimeline",this._initial=t,this.setStateAtTime(this._initial,0)}getValueAtTime(t){const e=this.get(t);return null!==e?e.state:this._initial}setStateAtTime(t,e,n){return ti(e,0),this.add(Object.assign({},n,{state:t,time:e})),this}getLastState(t,e){for(let n=this._search(e);n>=0;n--){const e=this._timeline[n];if(e.state===t)return e}}getNextState(t,e){const n=this._search(e);if(-1!==n)for(let e=n;e<this._timeline.length;e++){const n=this._timeline[e];if(n.state===t)return n}}}class ys extends gs{constructor(){super(Ci(ys.getDefaults(),arguments,["param","units","convert"])),this.name="Param",this.overridden=!1,this._minOutput=1e-7;const t=Ci(ys.getDefaults(),arguments,["param","units","convert"]);for(Zr(oi(t.param)&&(wi(t.param)||t.param instanceof ys),"param must be an AudioParam");!wi(t.param);)t.param=t.param._param;this._swappable=!!oi(t.swappable)&&t.swappable,this._swappable?(this.input=this.context.createGain(),this._param=t.param,this.input.connect(this._param)):this._param=this.input=t.param,this._events=new Pi(1e3),this._initialValue=this._param.defaultValue,this.units=t.units,this.convert=t.convert,this._minValue=t.minValue,this._maxValue=t.maxValue,oi(t.value)&&t.value!==this._toType(this._initialValue)&&this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(gs.getDefaults(),{convert:!0,units:"number"})}get value(){const t=this.now();return this.getValueAtTime(t)}set value(t){this.cancelScheduledValues(this.now()),this.setValueAtTime(t,this.now())}get minValue(){return oi(this._minValue)?this._minValue:"time"===this.units||"frequency"===this.units||"normalRange"===this.units||"positive"===this.units||"transportTime"===this.units||"ticks"===this.units||"bpm"===this.units||"hertz"===this.units||"samples"===this.units?0:"audioRange"===this.units?-1:"decibels"===this.units?-1/0:this._param.minValue}get maxValue(){return oi(this._maxValue)?this._maxValue:"normalRange"===this.units||"audioRange"===this.units?1:this._param.maxValue}_is(t,e){return this.units===e}_assertRange(t){return oi(this.maxValue)&&oi(this.minValue)&&ti(t,this._fromType(this.minValue),this._fromType(this.maxValue)),t}_fromType(t){return this.convert&&!this.overridden?this._is(t,"time")?this.toSeconds(t):this._is(t,"decibels")?ts(t):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t}_toType(t){return this.convert&&"decibels"===this.units?es(t):t}setValueAtTime(t,e){const n=this.toSeconds(e),r=this._fromType(t);return Zr(isFinite(r)&&isFinite(n),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(r),this.log(this.units,"setValueAtTime",t,n),this._events.add({time:n,type:"setValueAtTime",value:r}),this._param.setValueAtTime(r,n),this}getValueAtTime(t){const e=Math.max(this.toSeconds(t),0),n=this._events.getAfter(e),r=this._events.get(e);let i=this._initialValue;if(null===r)i=this._initialValue;else if("setTargetAtTime"!==r.type||null!==n&&"setValueAtTime"!==n.type)if(null===n)i=r.value;else if("linearRampToValueAtTime"===n.type||"exponentialRampToValueAtTime"===n.type){let t=r.value;if("setTargetAtTime"===r.type){const e=this._events.getBefore(r.time);t=null===e?this._initialValue:e.value}i="linearRampToValueAtTime"===n.type?this._linearInterpolate(r.time,t,n.time,n.value,e):this._exponentialInterpolate(r.time,t,n.time,n.value,e)}else i=r.value;else{const t=this._events.getBefore(r.time);let n;n=null===t?this._initialValue:t.value,"setTargetAtTime"===r.type&&(i=this._exponentialApproach(r.time,n,r.value,r.constant,e))}return this._toType(i)}setRampPoint(t){t=this.toSeconds(t);let e=this.getValueAtTime(t);return this.cancelAndHoldAtTime(t),0===this._fromType(e)&&(e=this._toType(this._minOutput)),this.setValueAtTime(e,t),this}linearRampToValueAtTime(t,e){const n=this._fromType(t),r=this.toSeconds(e);return Zr(isFinite(n)&&isFinite(r),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(n),this._events.add({time:r,type:"linearRampToValueAtTime",value:n}),this.log(this.units,"linearRampToValueAtTime",t,r),this._param.linearRampToValueAtTime(n,r),this}exponentialRampToValueAtTime(t,e){let n=this._fromType(t);n=Math.max(this._minOutput,n),this._assertRange(n);const r=this.toSeconds(e);return Zr(isFinite(n)&&isFinite(r),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({time:r,type:"exponentialRampToValueAtTime",value:n}),this.log(this.units,"exponentialRampToValueAtTime",t,r),this._param.exponentialRampToValueAtTime(n,r),this}exponentialRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialRampToValueAtTime(t,n+this.toSeconds(e)),this}linearRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.linearRampToValueAtTime(t,n+this.toSeconds(e)),this}targetRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialApproachValueAtTime(t,n,e),this}exponentialApproachValueAtTime(t,e,n){e=this.toSeconds(e),n=this.toSeconds(n);const r=Math.log(n+1)/Math.log(200);return this.setTargetAtTime(t,e,r),this.cancelAndHoldAtTime(e+.9*n),this.linearRampToValueAtTime(t,e+n),this}setTargetAtTime(t,e,n){const r=this._fromType(t);Zr(isFinite(n)&&n>0,"timeConstant must be a number greater than 0");const i=this.toSeconds(e);return this._assertRange(r),Zr(isFinite(r)&&isFinite(i),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:n,time:i,type:"setTargetAtTime",value:r}),this.log(this.units,"setTargetAtTime",t,i,n),this._param.setTargetAtTime(r,i,n),this}setValueCurveAtTime(t,e,n,r=1){n=this.toSeconds(n),e=this.toSeconds(e);const i=this._fromType(t[0])*r;this.setValueAtTime(this._toType(i),e);const s=n/(t.length-1);for(let n=1;n<t.length;n++){const i=this._fromType(t[n])*r;this.linearRampToValueAtTime(this._toType(i),e+n*s)}return this}cancelScheduledValues(t){const e=this.toSeconds(t);return Zr(isFinite(e),"Invalid argument to cancelScheduledValues: "+JSON.stringify(t)),this._events.cancel(e),this._param.cancelScheduledValues(e),this.log(this.units,"cancelScheduledValues",e),this}cancelAndHoldAtTime(t){const e=this.toSeconds(t),n=this._fromType(this.getValueAtTime(e));Zr(isFinite(e),"Invalid argument to cancelAndHoldAtTime: "+JSON.stringify(t)),this.log(this.units,"cancelAndHoldAtTime",e,"value="+n);const r=this._events.get(e),i=this._events.getAfter(e);return r&&Di(r.time,e)?i?(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time)):(this._param.cancelAndHoldAtTime(e),this._events.cancel(e+this.sampleTime)):i&&(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time),"linearRampToValueAtTime"===i.type?this.linearRampToValueAtTime(this._toType(n),e):"exponentialRampToValueAtTime"===i.type&&this.exponentialRampToValueAtTime(this._toType(n),e)),this._events.add({time:e,type:"setValueAtTime",value:n}),this._param.setValueAtTime(n,e),this}rampTo(t,e=.1,n){return"frequency"===this.units||"bpm"===this.units||"decibels"===this.units?this.exponentialRampTo(t,e,n):this.linearRampTo(t,e,n),this}apply(t){const e=this.context.currentTime;t.setValueAtTime(this.getValueAtTime(e),e);const n=this._events.get(e);if(n&&"setTargetAtTime"===n.type){const r=this._events.getAfter(n.time),i=r?r.time:e+2,s=(i-e)/10;for(let n=e;n<i;n+=s)t.linearRampToValueAtTime(this.getValueAtTime(n),n)}return this._events.forEachAfter(this.context.currentTime,e=>{"cancelScheduledValues"===e.type?t.cancelScheduledValues(e.time):"setTargetAtTime"===e.type?t.setTargetAtTime(e.value,e.time,e.constant):t[e.type](e.value,e.time)}),this}setParam(t){Zr(this._swappable,"The Param must be assigned as 'swappable' in the constructor");const e=this.input;return e.disconnect(this._param),this.apply(t),this._param=t,e.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(t,e,n,r,i){return n+(e-n)*Math.exp(-(i-t)/r)}_linearInterpolate(t,e,n,r,i){return e+(i-t)/(n-t)*(r-e)}_exponentialInterpolate(t,e,n,r,i){return e*Math.pow(r/e,(i-t)/(n-t))}}class vs extends gs{constructor(){super(...arguments),this.name="ToneAudioNode",this._internalChannels=[]}get numberOfInputs(){return oi(this.input)?wi(this.input)||this.input instanceof ys?1:this.input.numberOfInputs:0}get numberOfOutputs(){return oi(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return oi(t)&&(t instanceof vs||xi(t))}_getInternalNodes(){const t=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&t.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&t.push(this.output),t}_setChannelProperties(t){this._getInternalNodes().forEach(e=>{e.channelCount=t.channelCount,e.channelCountMode=t.channelCountMode,e.channelInterpretation=t.channelInterpretation})}_getChannelProperties(){const t=this._getInternalNodes();Zr(t.length>0,"ToneAudioNode does not have any internal nodes");const e=t[0];return{channelCount:e.channelCount,channelCountMode:e.channelCountMode,channelInterpretation:e.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCount:t}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCountMode:t}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelInterpretation:t}))}connect(t,e=0,n=0){return xs(this,t,e,n),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return si("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,n=0){return _s(this,t,e,n),this}chain(...t){return ws(this,...t),this}fan(...t){return t.forEach(t=>this.connect(t)),this}dispose(){return super.dispose(),oi(this.input)&&(this.input instanceof vs?this.input.dispose():xi(this.input)&&this.input.disconnect()),oi(this.output)&&(this.output instanceof vs?this.output.dispose():xi(this.output)&&this.output.disconnect()),this._internalChannels=[],this}}function ws(...t){const e=t.shift();t.reduce((t,e)=>(t instanceof vs?t.connect(e):xi(t)&&xs(t,e),e),e)}function xs(t,e,n=0,r=0){for(Zr(oi(t),"Cannot connect from undefined node"),Zr(oi(e),"Cannot connect to undefined node"),(e instanceof vs||xi(e))&&Zr(e.numberOfInputs>0,"Cannot connect to node with no inputs"),Zr(t.numberOfOutputs>0,"Cannot connect from node with no outputs");e instanceof vs||e instanceof ys;)oi(e.input)&&(e=e.input);for(;t instanceof vs;)oi(t.output)&&(t=t.output);wi(e)?t.connect(e,n):t.connect(e,n,r)}function _s(t,e,n=0,r=0){if(oi(e))for(;e instanceof vs;)e=e.input;for(;!xi(t);)oi(t.output)&&(t=t.output);wi(e)?t.disconnect(e,n):xi(e)?t.disconnect(e,n,r):t.disconnect()}class Os extends vs{constructor(){super(Ci(Os.getDefaults(),arguments,["gain","units"])),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode;const t=Ci(Os.getDefaults(),arguments,["gain","units"]);this.gain=new ys({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),Ui(this,"gain")}static getDefaults(){return Object.assign(vs.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}}class Ss extends vs{constructor(t){super(t),this.onended=Gi,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new Os({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(t){const e=this.toSeconds(t);return-1!==this._startTime&&e>=this._startTime&&(-1===this._stopTime||e<=this._stopTime)?"started":"stopped"},this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut,this._curve=t.curve,this.onended=t.onended}static getDefaults(){return Object.assign(vs.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:Gi})}_startGain(t,e=1){Zr(-1===this._startTime,"Source cannot be started more than once");const n=this.toSeconds(this._fadeIn);return this._startTime=t+n,this._startTime=Math.max(this._startTime,this.context.currentTime),n>0?(this._gainNode.gain.setValueAtTime(0,t),"linear"===this._curve?this._gainNode.gain.linearRampToValueAtTime(e,t+n):this._gainNode.gain.exponentialApproachValueAtTime(e,t,n)):this._gainNode.gain.setValueAtTime(e,t),this}stop(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this}_stopGain(t){Zr(-1!==this._startTime,"'start' must be called before 'stop'"),this.cancelStop();const e=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(t)+e,this._stopTime=Math.max(this._stopTime,this.context.currentTime),e>0?"linear"===this._curve?this._gainNode.gain.linearRampTo(0,e,t):this._gainNode.gain.targetRampTo(0,e,t):(this._gainNode.gain.cancelAndHoldAtTime(t),this._gainNode.gain.setValueAtTime(0,t)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{const t="exponential"===this._curve?2*e:0;this._stopSource(this.now()+t),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==Gi&&(this.onended(this),this.onended=Gi,!this.context.isOffline)){const t=()=>this.dispose();void 0!==window.requestIdleCallback?window.requestIdleCallback(t):setTimeout(t,1e3)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),Zr(-1!==this._startTime,"Source is not started"),this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),this.context.clearTimeout(this._timeout),this._stopTime=-1,this}dispose(){return super.dispose(),this._gainNode.disconnect(),this}}class ks extends Ss{constructor(){super(Ci(ks.getDefaults(),arguments,["offset"])),this.name="ToneConstantSource",this._source=this.context.createConstantSource();const t=Ci(ks.getDefaults(),arguments,["offset"]);xs(this._source,this._gainNode),this.offset=new ys({context:this.context,convert:t.convert,param:this._source.offset,units:t.units,value:t.offset,minValue:t.minValue,maxValue:t.maxValue})}static getDefaults(){return Object.assign(Ss.getDefaults(),{convert:!0,offset:1,units:"number"})}start(t){const e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._source.start(e),this}_stopSource(t){this._source.stop(t)}dispose(){return super.dispose(),"started"===this.state&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}}class Ts extends vs{constructor(){super(Ci(Ts.getDefaults(),arguments,["value","units"])),this.name="Signal",this.override=!0;const t=Ci(Ts.getDefaults(),arguments,["value","units"]);this.output=this._constantSource=new ks({context:this.context,convert:t.convert,offset:t.value,units:t.units,minValue:t.minValue,maxValue:t.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign(vs.getDefaults(),{convert:!0,units:"number",value:0})}connect(t,e=0,n=0){return Cs(this,t,e,n),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(t,e){return this._param.setValueAtTime(t,e),this}getValueAtTime(t){return this._param.getValueAtTime(t)}setRampPoint(t){return this._param.setRampPoint(t),this}linearRampToValueAtTime(t,e){return this._param.linearRampToValueAtTime(t,e),this}exponentialRampToValueAtTime(t,e){return this._param.exponentialRampToValueAtTime(t,e),this}exponentialRampTo(t,e,n){return this._param.exponentialRampTo(t,e,n),this}linearRampTo(t,e,n){return this._param.linearRampTo(t,e,n),this}targetRampTo(t,e,n){return this._param.targetRampTo(t,e,n),this}exponentialApproachValueAtTime(t,e,n){return this._param.exponentialApproachValueAtTime(t,e,n),this}setTargetAtTime(t,e,n){return this._param.setTargetAtTime(t,e,n),this}setValueCurveAtTime(t,e,n,r){return this._param.setValueCurveAtTime(t,e,n,r),this}cancelScheduledValues(t){return this._param.cancelScheduledValues(t),this}cancelAndHoldAtTime(t){return this._param.cancelAndHoldAtTime(t),this}rampTo(t,e,n){return this._param.rampTo(t,e,n),this}get value(){return this._param.value}set value(t){this._param.value=t}get convert(){return this._param.convert}set convert(t){this._param.convert=t}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(t){this._param.overridden=t}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(t){return this._param.apply(t),this}}function Cs(t,e,n,r){(e instanceof ys||wi(e)||e instanceof Ts&&e.override)&&(e.cancelScheduledValues(0),e.setValueAtTime(0,0),e instanceof Ts&&(e.overridden=!0)),xs(t,e,n,r)}class As extends ys{constructor(){super(Ci(As.getDefaults(),arguments,["value"])),this.name="TickParam",this._events=new Pi(1/0),this._multiplier=1;const t=Ci(As.getDefaults(),arguments,["value"]);this._multiplier=t.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:"setValueAtTime",value:this._fromType(t.value)}),this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(ys.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(t,e,n){e=this.toSeconds(e),this.setRampPoint(e);const r=this._fromType(t),i=this._events.get(e),s=Math.round(Math.max(1/n,1));for(let t=0;t<=s;t++){const s=n*t+e,a=this._exponentialApproach(i.time,i.value,r,n,s);this.linearRampToValueAtTime(this._toType(a),s)}return this}setValueAtTime(t,e){const n=this.toSeconds(e);super.setValueAtTime(t,e);const r=this._events.get(n),i=this._events.previousEvent(r),s=this._getTicksUntilEvent(i,n);return r.ticks=Math.max(s,0),this}linearRampToValueAtTime(t,e){const n=this.toSeconds(e);super.linearRampToValueAtTime(t,e);const r=this._events.get(n),i=this._events.previousEvent(r),s=this._getTicksUntilEvent(i,n);return r.ticks=Math.max(s,0),this}exponentialRampToValueAtTime(t,e){e=this.toSeconds(e);const n=this._fromType(t),r=this._events.get(e),i=Math.round(Math.max(10*(e-r.time),1)),s=(e-r.time)/i;for(let t=0;t<=i;t++){const i=s*t+r.time,a=this._exponentialInterpolate(r.time,r.value,e,n,i);this.linearRampToValueAtTime(this._toType(a),i)}return this}_getTicksUntilEvent(t,e){if(null===t)t={ticks:0,time:0,type:"setValueAtTime",value:0};else if(ai(t.ticks)){const e=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(e,t.time)}const n=this._fromType(this.getValueAtTime(t.time));let r=this._fromType(this.getValueAtTime(e));const i=this._events.get(e);return i&&i.time===e&&"setValueAtTime"===i.type&&(r=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(n+r)+t.ticks}getTicksAtTime(t){const e=this.toSeconds(t),n=this._events.get(e);return Math.max(this._getTicksUntilEvent(n,e),0)}getDurationOfTicks(t,e){const n=this.toSeconds(e),r=this.getTicksAtTime(e);return this.getTimeOfTick(r+t)-n}getTimeOfTick(t){const e=this._events.get(t,"ticks"),n=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&n&&"linearRampToValueAtTime"===n.type&&e.value!==n.value){const r=this._fromType(this.getValueAtTime(e.time)),i=(this._fromType(this.getValueAtTime(n.time))-r)/(n.time-e.time),s=Math.sqrt(Math.pow(r,2)-2*i*(e.ticks-t)),a=(-r+s)/i,o=(-r-s)/i;return(a>0?a:o)+e.time}return e?0===e.value?1/0:e.time+(t-e.ticks)/e.value:t/this._initialValue}ticksToTime(t,e){return this.getDurationOfTicks(t,e)}timeToTicks(t,e){const n=this.toSeconds(e),r=this.toSeconds(t),i=this.getTicksAtTime(n);return this.getTicksAtTime(n+r)-i}_fromType(t){return"bpm"===this.units&&this.multiplier?1/(60/t/this.multiplier):super._fromType(t)}_toType(t){return"bpm"===this.units&&this.multiplier?t/this.multiplier*60:super._toType(t)}get multiplier(){return this._multiplier}set multiplier(t){const e=this.value;this._multiplier=t,this.cancelScheduledValues(0),this.setValueAtTime(e,0)}}class Ns extends Ts{constructor(){super(Ci(Ns.getDefaults(),arguments,["value"])),this.name="TickSignal";const t=Ci(Ns.getDefaults(),arguments,["value"]);this.input=this._param=new As({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(Ts.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(t,e){return this._param.ticksToTime(t,e)}timeToTicks(t,e){return this._param.timeToTicks(t,e)}getTimeOfTick(t){return this._param.getTimeOfTick(t)}getDurationOfTicks(t,e){return this._param.getDurationOfTicks(t,e)}getTicksAtTime(t){return this._param.getTicksAtTime(t)}get multiplier(){return this._param.multiplier}set multiplier(t){this._param.multiplier=t}dispose(){return super.dispose(),this._param.dispose(),this}}class Is extends gs{constructor(){super(Ci(Is.getDefaults(),arguments,["frequency"])),this.name="TickSource",this._state=new bs,this._tickOffset=new Pi;const t=Ci(Is.getDefaults(),arguments,["frequency"]);this.frequency=new Ns({context:this.context,units:t.units,value:t.frequency}),Ui(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},gs.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(t,e){const n=this.toSeconds(t);return"started"!==this._state.getValueAtTime(n)&&(this._state.setStateAtTime("started",n),oi(e)&&this.setTicksAtTime(e,n)),this}stop(t){const e=this.toSeconds(t);if("stopped"===this._state.getValueAtTime(e)){const t=this._state.get(e);t&&t.time>0&&(this._tickOffset.cancel(t.time),this._state.cancel(t.time))}return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this.setTicksAtTime(0,e),this}pause(t){const e=this.toSeconds(t);return"started"===this._state.getValueAtTime(e)&&this._state.setStateAtTime("paused",e),this}cancel(t){return t=this.toSeconds(t),this._state.cancel(t),this._tickOffset.cancel(t),this}getTicksAtTime(t){const e=this.toSeconds(t),n=this._state.getLastState("stopped",e),r={state:"paused",time:e};this._state.add(r);let i=n,s=0;return this._state.forEachBetween(n.time,e+this.sampleTime,t=>{let e=i.time;const n=this._tickOffset.get(t.time);n&&n.time>=i.time&&(s=n.ticks,e=n.time),"started"===i.state&&"started"!==t.state&&(s+=this.frequency.getTicksAtTime(t.time)-this.frequency.getTicksAtTime(e)),i=t}),this._state.remove(r),s}get ticks(){return this.getTicksAtTime(this.now())}set ticks(t){this.setTicksAtTime(t,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(t){const e=this.now(),n=this.frequency.timeToTicks(t,e);this.setTicksAtTime(n,e)}getSecondsAtTime(t){t=this.toSeconds(t);const e=this._state.getLastState("stopped",t),n={state:"paused",time:t};this._state.add(n);let r=e,i=0;return this._state.forEachBetween(e.time,t+this.sampleTime,t=>{let e=r.time;const n=this._tickOffset.get(t.time);n&&n.time>=r.time&&(i=n.seconds,e=n.time),"started"===r.state&&"started"!==t.state&&(i+=t.time-e),r=t}),this._state.remove(n),i}setTicksAtTime(t,e){return e=this.toSeconds(e),this._tickOffset.cancel(e),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(t,e),ticks:t,time:e}),this}getStateAtTime(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)}getTimeOfTick(t,e=this.now()){const n=this._tickOffset.get(e),r=this._state.get(e),i=Math.max(n.time,r.time),s=this.frequency.getTicksAtTime(i)+t-n.ticks;return this.frequency.getTimeOfTick(s)}forEachTickBetween(t,e,n){let r=this._state.get(t);this._state.forEachBetween(t,e,e=>{r&&"started"===r.state&&"started"!==e.state&&this.forEachTickBetween(Math.max(r.time,t),e.time-this.sampleTime,n),r=e});let i=null;if(r&&"started"===r.state){const s=Math.max(r.time,t),a=this.frequency.getTicksAtTime(s),o=a-this.frequency.getTicksAtTime(r.time);let u=Math.ceil(o)-o;u=Di(u,1)?0:u;let c=this.frequency.getTimeOfTick(a+u);for(;c<e;){try{n(c,Math.round(this.getTicksAtTime(c)))}catch(t){i=t;break}c+=this.frequency.getDurationOfTicks(1,c)}}if(i)throw i;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this.frequency.dispose(),this}}class Es extends gs{constructor(){super(Ci(Es.getDefaults(),arguments,["callback","frequency"])),this.name="Clock",this.callback=Gi,this._lastUpdate=0,this._state=new bs("stopped"),this._boundLoop=this._loop.bind(this);const t=Ci(Es.getDefaults(),arguments,["callback","frequency"]);this.callback=t.callback,this._tickSource=new Is({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,Ui(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(gs.getDefaults(),{callback:Gi,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){ei(this.context);const n=this.toSeconds(t);return this.log("start",n),"started"!==this._state.getValueAtTime(n)&&(this._state.setStateAtTime("started",n),this._tickSource.start(n,e),n<this._lastUpdate&&this.emit("start",n,e)),this}stop(t){const e=this.toSeconds(t);return this.log("stop",e),this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._tickSource.stop(e),e<this._lastUpdate&&this.emit("stop",e),this}pause(t){const e=this.toSeconds(t);return"started"===this._state.getValueAtTime(e)&&(this._state.setStateAtTime("paused",e),this._tickSource.pause(e),e<this._lastUpdate&&this.emit("pause",e)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(t){this._tickSource.ticks=t}get seconds(){return this._tickSource.seconds}set seconds(t){this._tickSource.seconds=t}getSecondsAtTime(t){return this._tickSource.getSecondsAtTime(t)}setTicksAtTime(t,e){return this._tickSource.setTicksAtTime(t,e),this}getTimeOfTick(t,e=this.now()){return this._tickSource.getTimeOfTick(t,e)}getTicksAtTime(t){return this._tickSource.getTicksAtTime(t)}nextTickTime(t,e){const n=this.toSeconds(e),r=this.getTicksAtTime(n);return this._tickSource.getTimeOfTick(r+t,n)}_loop(){const t=this._lastUpdate,e=this.now();this._lastUpdate=e,this.log("loop",t,e),t!==e&&(this._state.forEachBetween(t,e,t=>{switch(t.state){case"started":const e=this._tickSource.getTicksAtTime(t.time);this.emit("start",t.time,e);break;case"stopped":0!==t.time&&this.emit("stop",t.time);break;case"paused":this.emit("pause",t.time)}}),this._tickSource.forEachTickBetween(t,e,(t,e)=>{this.callback(t,e)}))}getStateAtTime(t){const e=this.toSeconds(t);return this._state.getValueAtTime(e)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}}Bi.mixin(Es);class js extends vs{constructor(){super(Ci(js.getDefaults(),arguments,["delayTime","maxDelay"])),this.name="Delay";const t=Ci(js.getDefaults(),arguments,["delayTime","maxDelay"]),e=this.toSeconds(t.maxDelay);this._maxDelay=Math.max(e,this.toSeconds(t.delayTime)),this._delayNode=this.input=this.output=this.context.createDelay(e),this.delayTime=new ys({context:this.context,param:this._delayNode.delayTime,units:"time",value:t.delayTime,minValue:0,maxValue:this.maxDelay}),Ui(this,"delayTime")}static getDefaults(){return Object.assign(vs.getDefaults(),{delayTime:0,maxDelay:1})}get maxDelay(){return this._maxDelay}dispose(){return super.dispose(),this._delayNode.disconnect(),this.delayTime.dispose(),this}}function Ms(t,e,n=2,r=Yi().sampleRate){return yi(this,void 0,void 0,(function*(){const i=Yi(),s=new Ki(n,e,r);Ji(s),yield t(s);const a=s.render();Ji(i);const o=yield a;return new Hi(o)}))}class Ds extends Ii{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;const t=Ci(Ds.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach(e=>{this._loadingCount++;const n=t.urls[e];this.add(e,n,this._bufferLoaded.bind(this,t.onload),t.onerror)})}static getDefaults(){return{baseUrl:"",onerror:Gi,onload:Gi,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return Zr(this.has(t),"ToneAudioBuffers has no buffer named: "+t),this._buffers.get(t.toString())}_bufferLoaded(t){this._loadingCount--,0===this._loadingCount&&t&&t()}get loaded(){return Array.from(this._buffers).every(([t,e])=>e.loaded)}add(t,e,n=Gi,r=Gi){return pi(e)?this._buffers.set(t.toString(),new Hi(this.baseUrl+e,n,r)):this._buffers.set(t.toString(),new Hi(e,n,r)),this}dispose(){return super.dispose(),this._buffers.forEach(t=>t.dispose()),this._buffers.clear(),this}}class Rs extends ls{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(t){return is(super._frequencyToUnits(t))}_ticksToUnits(t){return is(super._ticksToUnits(t))}_beatsToUnits(t){return is(super._beatsToUnits(t))}_secondsToUnits(t){return is(super._secondsToUnits(t))}toMidi(){return this.valueOf()}toFrequency(){return as(this.toMidi())}transpose(t){return new Rs(this.context,this.toMidi()+t)}}function Ps(t,e){return new Rs(Yi(),t,e)}class Fs extends fs{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(t){return this._getPPQ()*t}_secondsToUnits(t){return Math.floor(t/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(t){return t}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}}function zs(t,e){return new Fs(Yi(),t,e)}class Ls extends gs{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Pi,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(t,e){return this._events.add({callback:t,time:this.toSeconds(e)}),1===this._events.length&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(t){return this._events.cancel(this.toSeconds(t)),this}_drawLoop(){const t=this.context.currentTime;for(;this._events.length&&this._events.peek().time-this.anticipation<=t;){const e=this._events.shift();e&&t-e.time<=this.expiration&&e.callback()}this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}}zi(t=>{t.draw=new Ls({context:t})}),$i(t=>{t.draw.dispose()});class $s extends Ii{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){Zr(oi(t.time),"Events must have a time property"),Zr(oi(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new Bs(t.time,t.time+t.duration,t);for(null===this._root?this._root=e:this._root.insert(e),this._length++;null!==e;)e.updateHeight(),e.updateMax(),this._rebalance(e),e=e.parent;return this}remove(t){if(null!==this._root){const e=[];this._root.search(t.time,e);for(const n of e)if(n.event===t){this._removeNode(n),this._length--;break}}return this}get length(){return this._length}cancel(t){return this.forEachFrom(t,t=>this.remove(t)),this}_setRoot(t){this._root=t,null!==this._root&&(this._root.parent=null)}_replaceNodeInParent(t,e){null!==t.parent?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)}_removeNode(t){if(null===t.left&&null===t.right)this._replaceNodeInParent(t,null);else if(null===t.right)this._replaceNodeInParent(t,t.left);else if(null===t.left)this._replaceNodeInParent(t,t.right);else{let e,n=null;if(t.getBalance()>0)if(null===t.left.right)e=t.left,e.right=t.right,n=e;else{for(e=t.left.right;null!==e.right;)e=e.right;e.parent&&(e.parent.right=e.left,n=e.parent,e.left=t.left,e.right=t.right)}else if(null===t.right.left)e=t.right,e.left=t.left,n=e;else{for(e=t.right.left;null!==e.left;)e=e.left;e.parent&&(e.parent.left=e.right,n=e.parent,e.left=t.left,e.right=t.right)}null!==t.parent?t.isLeftChild()?t.parent.left=e:t.parent.right=e:this._setRoot(e),n&&this._rebalance(n)}t.dispose()}_rotateLeft(t){const e=t.parent,n=t.isLeftChild(),r=t.right;r&&(t.right=r.left,r.left=t),null!==e?n?e.left=r:e.right=r:this._setRoot(r)}_rotateRight(t){const e=t.parent,n=t.isLeftChild(),r=t.left;r&&(t.left=r.right,r.right=t),null!==e?n?e.left=r:e.right=r:this._setRoot(r)}_rebalance(t){const e=t.getBalance();e>1&&t.left?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&t.right&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))}get(t){if(null!==this._root){const e=[];if(this._root.search(t,e),e.length>0){let t=e[0];for(let n=1;n<e.length;n++)e[n].low>t.low&&(t=e[n]);return t.event}}return null}forEach(t){if(null!==this._root){const e=[];this._root.traverse(t=>e.push(t)),e.forEach(e=>{e.event&&t(e.event)})}return this}forEachAtTime(t,e){if(null!==this._root){const n=[];this._root.search(t,n),n.forEach(t=>{t.event&&e(t.event)})}return this}forEachFrom(t,e){if(null!==this._root){const n=[];this._root.searchAfter(t,n),n.forEach(t=>{t.event&&e(t.event)})}return this}dispose(){return super.dispose(),null!==this._root&&this._root.traverse(t=>t.dispose()),this._root=null,this}}class Bs{constructor(t,e,n){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=n,this.low=t,this.high=e,this.max=this.high}insert(t){t.low<=this.low?null===this.left?this.left=t:this.left.insert(t):null===this.right?this.right=t:this.right.insert(t)}search(t,e){t>this.max||(null!==this.left&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),this.low>t||null!==this.right&&this.right.search(t,e))}searchAfter(t,e){this.low>=t&&(e.push(this),null!==this.left&&this.left.searchAfter(t,e)),null!==this.right&&this.right.searchAfter(t,e)}traverse(t){t(this),null!==this.left&&this.left.traverse(t),null!==this.right&&this.right.traverse(t)}updateHeight(){null!==this.left&&null!==this.right?this.height=Math.max(this.left.height,this.right.height)+1:null!==this.right?this.height=this.right.height+1:null!==this.left?this.height=this.left.height+1:this.height=0}updateMax(){this.max=this.high,null!==this.left&&(this.max=Math.max(this.max,this.left.max)),null!==this.right&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let t=0;return null!==this.left&&null!==this.right?t=this.left.height-this.right.height:null!==this.left?t=this.left.height+1:null!==this.right&&(t=-(this.right.height+1)),t}isLeftChild(){return null!==this.parent&&this.parent.left===this}get left(){return this._left}set left(t){this._left=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(t){this._right=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}}class qs extends vs{constructor(){super(Ci(qs.getDefaults(),arguments,["volume"])),this.name="Volume";const t=Ci(qs.getDefaults(),arguments,["volume"]);this.input=this.output=new Os({context:this.context,gain:t.volume,units:"decibels"}),this.volume=this.output.gain,Ui(this,"volume"),this._unmutedVolume=t.volume,this.mute=t.mute}static getDefaults(){return Object.assign(vs.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}}class Vs extends vs{constructor(){super(Ci(Vs.getDefaults(),arguments)),this.name="Destination",this.input=new qs({context:this.context}),this.output=new Os({context:this.context}),this.volume=this.input.volume;const t=Ci(Vs.getDefaults(),arguments);ws(this.input,this.output,this.context.rawContext.destination),this.mute=t.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign(vs.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(t){this.input.mute=t}chain(...t){return this.input.disconnect(),t.unshift(this.input),t.push(this.output),ws(...t),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}}zi(t=>{t.destination=new Vs({context:t})}),$i(t=>{t.destination.dispose()});class Us extends Ii{constructor(t){super(),this.name="TimelineValue",this._timeline=new Pi({memory:10}),this._initialValue=t}set(t,e){return this._timeline.add({value:t,time:e}),this}get(t){const e=this._timeline.get(t);return e?e.value:this._initialValue}}class Ws{constructor(t,e){this.id=Ws._eventId++;const n=Object.assign(Ws.getDefaults(),e);this.transport=t,this.callback=n.callback,this._once=n.once,this.time=n.time}static getDefaults(){return{callback:Gi,once:!1,time:0}}invoke(t){this.callback&&(this.callback(t),this._once&&this.transport.clear(this.id))}dispose(){return this.callback=void 0,this}}Ws._eventId=0;class Gs extends Ws{constructor(t,e){super(t,e),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);const n=Object.assign(Gs.getDefaults(),e);this.duration=new Fs(t.context,n.duration).valueOf(),this._interval=new Fs(t.context,n.interval).valueOf(),this._nextTick=n.time,this.transport.on("start",this._boundRestart),this.transport.on("loopStart",this._boundRestart),this.context=this.transport.context,this._restart()}static getDefaults(){return Object.assign({},Ws.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(t),super.invoke(t)}_createEvents(t){const e=this.transport.getTicksAtTime(t);e>=this.time&&e>=this._nextTick&&this._nextTick+this._interval<this.time+this.duration&&(this._nextTick+=this._interval,this._currentId=this._nextId,this._nextId=this.transport.scheduleOnce(this.invoke.bind(this),new Fs(this.context,this._nextTick).toSeconds()))}_restart(t){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.time;const e=this.transport.getTicksAtTime(t);e>this.time&&(this._nextTick=this.time+Math.ceil((e-this.time)/this._interval)*this._interval),this._currentId=this.transport.scheduleOnce(this.invoke.bind(this),new Fs(this.context,this._nextTick).toSeconds()),this._nextTick+=this._interval,this._nextId=this.transport.scheduleOnce(this.invoke.bind(this),new Fs(this.context,this._nextTick).toSeconds())}dispose(){return super.dispose(),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off("start",this._boundRestart),this.transport.off("loopStart",this._boundRestart),this}}class Hs extends gs{constructor(){super(Ci(Hs.getDefaults(),arguments)),this.name="Transport",this._loop=new Us(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Pi,this._repeatedEvents=new $s,this._syncedSignals=[],this._swingAmount=0;const t=Ci(Hs.getDefaults(),arguments);this._ppq=t.ppq,this._clock=new Es({callback:this._processTick.bind(this),context:this.context,frequency:0,units:"bpm"}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=t.ppq,this.bpm.setValueAtTime(t.bpm,0),Ui(this,"bpm"),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(gs.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(t,e){if(this._swingAmount>0&&e%this._ppq!=0&&e%(2*this._swingTicks)!=0){const n=e%(2*this._swingTicks)/(2*this._swingTicks),r=Math.sin(n*Math.PI)*this._swingAmount;t+=new Fs(this.context,2*this._swingTicks/3).toSeconds()*r}this._loop.get(t)&&e>=this._loopEnd&&(this.emit("loopEnd",t),this._clock.setTicksAtTime(this._loopStart,t),e=this._loopStart,this.emit("loopStart",t,this._clock.getSecondsAtTime(t)),this.emit("loop",t)),this._timeline.forEachAtTime(e,e=>e.invoke(t))}schedule(t,e){const n=new Ws(this,{callback:t,time:new fs(this.context,e).toTicks()});return this._addEvent(n,this._timeline)}scheduleRepeat(t,e,n,r=1/0){const i=new Gs(this,{callback:t,duration:new us(this.context,r).toTicks(),interval:new us(this.context,e).toTicks(),time:new fs(this.context,n).toTicks()});return this._addEvent(i,this._repeatedEvents)}scheduleOnce(t,e){const n=new Ws(this,{callback:t,once:!0,time:new fs(this.context,e).toTicks()});return this._addEvent(n,this._timeline)}clear(t){if(this._scheduledEvents.hasOwnProperty(t)){const e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this}_addEvent(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id}cancel(t=0){const e=this.toTicks(t);return this._timeline.forEachFrom(e,t=>this.clear(t.id)),this._repeatedEvents.forEachFrom(e,t=>this.clear(t.id)),this}_bindClockEvents(){this._clock.on("start",(t,e)=>{e=new Fs(this.context,e).toSeconds(),this.emit("start",t,e)}),this._clock.on("stop",t=>{this.emit("stop",t)}),this._clock.on("pause",t=>{this.emit("pause",t)})}get state(){return this._clock.getStateAtTime(this.now())}start(t,e){let n;return oi(e)&&(n=this.toTicks(e)),this._clock.start(t,n),this}stop(t){return this._clock.stop(t),this}pause(t){return this._clock.pause(t),this}toggle(t){return t=this.toSeconds(t),"started"!==this._clock.getStateAtTime(t)?this.start(t):this.stop(t),this}get timeSignature(){return this._timeSignature}set timeSignature(t){di(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}get loopStart(){return new us(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new us(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t)}get loop(){return this._loop.get(this.now())}set loop(t){this._loop.set(t,this.now())}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get swing(){return this._swingAmount}set swing(t){this._swingAmount=t}get swingSubdivision(){return new Fs(this.context,this._swingTicks).toNotation()}set swingSubdivision(t){this._swingTicks=this.toTicks(t)}get position(){const t=this.now(),e=this._clock.getTicksAtTime(t);return new Fs(this.context,e).toBarsBeatsSixteenths()}set position(t){const e=this.toTicks(t);this.ticks=e}get seconds(){return this._clock.seconds}set seconds(t){const e=this.now(),n=this._clock.frequency.timeToTicks(t,e);this.ticks=n}get progress(){if(this.loop){const t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}return 0}get ticks(){return this._clock.ticks}set ticks(t){if(this._clock.ticks!==t){const e=this.now();if("started"===this.state){const n=this._clock.getTicksAtTime(e),r=this._clock.getTimeOfTick(Math.ceil(n));this.emit("stop",r),this._clock.setTicksAtTime(t,r),this.emit("start",r,this._clock.getSecondsAtTime(r))}else this._clock.setTicksAtTime(t,e)}}getTicksAtTime(t){return Math.round(this._clock.getTicksAtTime(t))}getSecondsAtTime(t){return this._clock.getSecondsAtTime(t)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(t){this._clock.frequency.multiplier=t}nextSubdivision(t){if(t=this.toTicks(t),"started"!==this.state)return 0;{const e=this.now(),n=t-this.getTicksAtTime(e)%t;return this._clock.nextTickTime(n,e)}}syncSignal(t,e){if(!e){const n=this.now();if(0!==t.getValueAtTime(n)){const r=1/(60/this.bpm.getValueAtTime(n)/this.PPQ);e=t.getValueAtTime(n)/r}else e=0}const n=new Os(e);return this.bpm.connect(n),n.connect(t._param),this._syncedSignals.push({initial:t.value,ratio:n,signal:t}),t.value=0,this}unsyncSignal(t){for(let e=this._syncedSignals.length-1;e>=0;e--){const n=this._syncedSignals[e];n.signal===t&&(n.ratio.dispose(),n.signal.value=n.initial,this._syncedSignals.splice(e,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),Wi(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}}Bi.mixin(Hs),zi(t=>{t.transport=new Hs({context:t})}),$i(t=>{t.transport.dispose()});class Ks extends vs{constructor(t){super(t),this.input=void 0,this._state=new bs("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=Gi,this._syncedStop=Gi,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new qs({context:this.context,mute:t.mute,volume:t.volume}),this.volume=this._volume.volume,Ui(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(vs.getDefaults(),{mute:!1,onstop:Gi,volume:0})}get state(){return this._synced?"started"===this.context.transport.state?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}_clampToCurrentTime(t){return this._synced?t:Math.max(t,this.context.currentTime)}start(t,e,n){let r=ai(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(r=this._clampToCurrentTime(r),this._synced||"started"!==this._state.getValueAtTime(r))if(this.log("start",r),this._state.setStateAtTime("started",r),this._synced){const t=this._state.get(r);t&&(t.offset=this.toSeconds(Ai(e,0)),t.duration=n?this.toSeconds(n):void 0);const i=this.context.transport.schedule(t=>{this._start(t,e,n)},r);this._scheduled.push(i),"started"===this.context.transport.state&&this.context.transport.getSecondsAtTime(this.immediate())>r&&this._syncedStart(this.now(),this.context.transport.seconds)}else ei(this.context),this._start(r,e,n);else Zr(Ei(r,this._state.get(r).time),"Start time must be strictly greater than previous start time"),this._state.cancel(r),this._state.setStateAtTime("started",r),this.log("restart",r),this.restart(r,e,n);return this}stop(t){let e=ai(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),"started"===this._state.getValueAtTime(e)||oi(this._state.getNextState("started",e))){if(this.log("stop",e),this._synced){const t=this.context.transport.schedule(this._stop.bind(this),e);this._scheduled.push(t)}else this._stop(e);this._state.cancel(e),this._state.setStateAtTime("stopped",e)}return this}restart(t,e,n){return t=this.toSeconds(t),"started"===this._state.getValueAtTime(t)&&(this._state.cancel(t),this._restart(t,e,n)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(t,e)=>{if(e>0){const n=this._state.get(e);if(n&&"started"===n.state&&n.time!==e){const r=e-this.toSeconds(n.time);let i;n.duration&&(i=this.toSeconds(n.duration)-r),this._start(t,this.toSeconds(n.offset)+r,i)}}},this._syncedStop=t=>{const e=this.context.transport.getSecondsAtTime(Math.max(t-this.sampleTime,0));"started"===this._state.getValueAtTime(e)&&this._stop(t)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach(t=>this.context.transport.clear(t)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=Gi,this.unsync(),this._volume.dispose(),this._state.dispose(),this}}class Qs extends Ss{constructor(){super(Ci(Qs.getDefaults(),arguments,["url","onload"])),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1;const t=Ci(Qs.getDefaults(),arguments,["url","onload"]);xs(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new ys({context:this.context,param:this._source.playbackRate,units:"positive",value:t.playbackRate}),this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this._buffer=new Hi(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(Ss.getDefaults(),{url:new Hi,loop:!1,loopEnd:0,loopStart:0,onload:Gi,onerror:Gi,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t}get curve(){return this._curve}set curve(t){this._curve=t}start(t,e,n,r=1){Zr(this.buffer.loaded,"buffer is either not set or not loaded");const i=this.toSeconds(t);this._startGain(i,r),e=this.loop?Ai(e,this.loopStart):Ai(e,0);let s=Math.max(this.toSeconds(e),0);if(this.loop){const t=this.toSeconds(this.loopEnd)||this.buffer.duration,e=this.toSeconds(this.loopStart),n=t-e;ji(s,t)&&(s=(s-e)%n+e),Di(s,this.buffer.duration)&&(s=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,Mi(s,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(i,s)),oi(n)){let t=this.toSeconds(n);t=Math.max(t,0),this.stop(i+t)}return this}_stopSource(t){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(t)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(t){this._source.loopStart=this.toSeconds(t)}get loopEnd(){return this._source.loopEnd}set loopEnd(t){this._source.loopEnd=this.toSeconds(t)}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._source.loop}set loop(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}}class Xs extends Ks{constructor(){super(Ci(Xs.getDefaults(),arguments,["type"])),this.name="Noise",this._source=null;const t=Ci(Xs.getDefaults(),arguments,["type"]);this._playbackRate=t.playbackRate,this.type=t.type,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Ks.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(t){if(Zr(t in Js,"Noise: invalid type: "+t),this._type!==t&&(this._type=t,"started"===this.state)){const t=this.now();this._stop(t),this._start(t)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}_start(t){const e=Js[this._type];this._source=new Qs({url:e,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(t),Math.random()*(e.duration-.001))}_stop(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(t){this._stop(t),this._start(t)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}}const Ys={brown:null,pink:null,white:null},Js={get brown(){if(!Ys.brown){const t=[];for(let e=0;e<2;e++){const n=new Float32Array(220500);t[e]=n;let r=0;for(let t=0;t<220500;t++){const e=2*Math.random()-1;n[t]=(r+.02*e)/1.02,r=n[t],n[t]*=3.5}}Ys.brown=(new Hi).fromArray(t)}return Ys.brown},get pink(){if(!Ys.pink){const t=[];for(let e=0;e<2;e++){const n=new Float32Array(220500);let r,i,s,a,o,u,c;t[e]=n,r=i=s=a=o=u=c=0;for(let t=0;t<220500;t++){const e=2*Math.random()-1;r=.99886*r+.0555179*e,i=.99332*i+.0750759*e,s=.969*s+.153852*e,a=.8665*a+.3104856*e,o=.55*o+.5329522*e,u=-.7616*u-.016898*e,n[t]=r+i+s+a+o+u+c+.5362*e,n[t]*=.11,c=.115926*e}}Ys.pink=(new Hi).fromArray(t)}return Ys.pink},get white(){if(!Ys.white){const t=[];for(let e=0;e<2;e++){const n=new Float32Array(220500);t[e]=n;for(let t=0;t<220500;t++)n[t]=2*Math.random()-1}Ys.white=(new Hi).fromArray(t)}return Ys.white}};class Zs extends vs{constructor(){super(Ci(Zs.getDefaults(),arguments,["volume"])),this.name="UserMedia";const t=Ci(Zs.getDefaults(),arguments,["volume"]);this._volume=this.output=new qs({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Ui(this,"volume"),this.mute=t.mute}static getDefaults(){return Object.assign(vs.getDefaults(),{mute:!1,volume:0})}open(t){return yi(this,void 0,void 0,(function*(){Zr(Zs.supported,"UserMedia is not supported"),"started"===this.state&&this.close();const e=yield Zs.enumerateDevices();ci(t)?this._device=e[t]:(this._device=e.find(e=>e.label===t||e.deviceId===t),!this._device&&e.length>0&&(this._device=e[0]),Zr(oi(this._device),"No matching device "+t));const n={audio:{echoCancellation:!1,sampleRate:this.context.sampleRate,noiseSuppression:!1,mozNoiseSuppression:!1}};this._device&&(n.audio.deviceId=this._device.deviceId);const r=yield navigator.mediaDevices.getUserMedia(n);if(!this._stream){this._stream=r;const t=this.context.createMediaStreamSource(r);xs(t,this.output),this._mediaStream=t}return this}))}close(){return this._stream&&this._mediaStream&&(this._stream.getAudioTracks().forEach(t=>{t.stop()}),this._stream=void 0,this._mediaStream.disconnect(),this._mediaStream=void 0),this._device=void 0,this}static enumerateDevices(){return yi(this,void 0,void 0,(function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(t=>"audioinput"===t.kind)}))}get state(){return this._stream&&this._stream.active?"started":"stopped"}get deviceId(){return this._device?this._device.deviceId:void 0}get groupId(){return this._device?this._device.groupId:void 0}get label(){return this._device?this._device.label:void 0}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}dispose(){return super.dispose(),this.close(),this._volume.dispose(),this.volume.dispose(),this}static get supported(){return oi(navigator.mediaDevices)&&oi(navigator.mediaDevices.getUserMedia)}}function ta(t,e){return yi(this,void 0,void 0,(function*(){const n=e/t.context.sampleRate,r=new Ki(1,n,t.context.sampleRate);new t.constructor(Object.assign(t.get(),{frequency:2/n,detune:0,context:r})).toDestination().start(0);return(yield r.render()).getChannelData(0)}))}class ea extends Ss{constructor(){super(Ci(ea.getDefaults(),arguments,["frequency","type"])),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator];const t=Ci(ea.getDefaults(),arguments,["frequency","type"]);xs(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new ys({context:this.context,param:this._oscillator.frequency,units:"frequency",value:t.frequency}),this.detune=new ys({context:this.context,param:this._oscillator.detune,units:"cents",value:t.detune}),Ui(this,["frequency","detune"])}static getDefaults(){return Object.assign(Ss.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(t){const e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._oscillator.start(e),this}_stopSource(t){this._oscillator.stop(t)}setPeriodicWave(t){return this._oscillator.setPeriodicWave(t),this}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t}dispose(){return super.dispose(),"started"===this.state&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}}class na extends Ks{constructor(){super(Ci(na.getDefaults(),arguments,["frequency","type"])),this.name="Oscillator",this._oscillator=null;const t=Ci(na.getDefaults(),arguments,["frequency","type"]);this.frequency=new Ts({context:this.context,units:"frequency",value:t.frequency}),Ui(this,"frequency"),this.detune=new Ts({context:this.context,units:"cents",value:t.detune}),Ui(this,"detune"),this._partials=t.partials,this._partialCount=t.partialCount,this._type=t.type,t.partialCount&&"custom"!==t.type&&(this._type=this.baseType+t.partialCount.toString()),this.phase=t.phase}static getDefaults(){return Object.assign(Ks.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(t){const e=this.toSeconds(t),n=new ea({context:this.context,onended:()=>this.onstop(this)});this._oscillator=n,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(e)}_stop(t){const e=this.toSeconds(t);this._oscillator&&this._oscillator.stop(e)}_restart(t){const e=this.toSeconds(t);return this.log("restart",e),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(e),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if("custom"===this._type){return na._periodicWaveCache.find(t=>{return t.phase===this._phase&&(e=t.partials,n=this._partials,e.length===n.length&&e.every((t,e)=>n[e]===t));var e,n})}{const t=na._periodicWaveCache.find(t=>t.type===this._type&&t.phase===this._phase);return this._partialCount=t?t.partialCount:this._partialCount,t}}get type(){return this._type}set type(t){this._type=t;const e=-1!==["sine","square","sawtooth","triangle"].indexOf(t);if(0===this._phase&&e)this._wave=void 0,this._partialCount=0,null!==this._oscillator&&(this._oscillator.type=t);else{const e=this._getCachedPeriodicWave();if(oi(e)){const{partials:t,wave:n}=e;this._wave=n,this._partials=t,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave)}else{const[e,n]=this._getRealImaginary(t,this._phase),r=this.context.createPeriodicWave(e,n);this._wave=r,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave),na._periodicWaveCache.push({imag:n,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:e,type:this._type,wave:this._wave}),na._periodicWaveCache.length>100&&na._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(t){this.partialCount&&"custom"!==this._type&&"custom"!==t?this.type=t+this.partialCount:this.type=t}get partialCount(){return this._partialCount}set partialCount(t){ti(t,0);let e=this._type;const n=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(n&&(e=n[1]),"custom"!==this._type)this.type=0===t?e:e+t.toString();else{const e=new Float32Array(t);this._partials.forEach((t,n)=>e[n]=t),this._partials=Array.from(e),this.type=this._type}}_getRealImaginary(t,e){let n=2048;const r=new Float32Array(n),i=new Float32Array(n);let s=1;if("custom"===t){if(s=this._partials.length+1,this._partialCount=this._partials.length,n=s,0===this._partials.length)return[r,i]}else{const e=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(t);e?(s=parseInt(e[2],10)+1,this._partialCount=parseInt(e[2],10),t=e[1],s=Math.max(s,2),n=s):this._partialCount=0,this._partials=[]}for(let a=1;a<n;++a){const n=2/(a*Math.PI);let o;switch(t){case"sine":o=a<=s?1:0,this._partials[a-1]=o;break;case"square":o=1&a?2*n:0,this._partials[a-1]=o;break;case"sawtooth":o=n*(1&a?1:-1),this._partials[a-1]=o;break;case"triangle":o=1&a?n*n*2*(a-1>>1&1?-1:1):0,this._partials[a-1]=o;break;case"custom":o=this._partials[a-1];break;default:throw new TypeError("Oscillator: invalid type: "+t)}0!==o?(r[a]=-o*Math.sin(e*a),i[a]=o*Math.cos(e*a)):(r[a]=0,i[a]=0)}return[r,i]}_inverseFFT(t,e,n){let r=0;const i=t.length;for(let s=0;s<i;s++)r+=t[s]*Math.cos(s*n)+e[s]*Math.sin(s*n);return r}getInitialValue(){const[t,e]=this._getRealImaginary(this._type,0);let n=0;const r=2*Math.PI;for(let i=0;i<32;i++)n=Math.max(this._inverseFFT(t,e,i/32*r),n);return Ri(-this._inverseFFT(t,e,this._phase)/n,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this.type="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(t){this._phase=t*Math.PI/180,this.type=this._type}asArray(t=1024){return yi(this,void 0,void 0,(function*(){return ta(this,t)}))}dispose(){return super.dispose(),null!==this._oscillator&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}}na._periodicWaveCache=[];class ra extends vs{constructor(){super(Object.assign(Ci(ra.getDefaults(),arguments,["context"])))}connect(t,e=0,n=0){return Cs(this,t,e,n),this}}class ia extends ra{constructor(){super(Object.assign(Ci(ia.getDefaults(),arguments,["mapping","length"]))),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper;const t=Ci(ia.getDefaults(),arguments,["mapping","length"]);di(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):ui(t.mapping)&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign(Ts.getDefaults(),{length:1024})}setMap(t,e=1024){const n=new Float32Array(e);for(let r=0,i=e;r<i;r++){const e=r/(i-1)*2-1;n[r]=t(e,r)}return this.curve=n,this}get curve(){return this._shaper.curve}set curve(t){this._shaper.curve=t}get oversample(){return this._shaper.oversample}set oversample(t){Zr(["none","2x","4x"].some(e=>e.includes(t)),"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.disconnect(),this}}class sa extends ra{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new ia({context:this.context,mapping:t=>(t+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class aa extends Ts{constructor(){super(Object.assign(Ci(aa.getDefaults(),arguments,["value"]))),this.name="Multiply",this.override=!1;const t=Ci(aa.getDefaults(),arguments,["value"]);this._mult=this.input=this.output=new Os({context:this.context,minValue:t.minValue,maxValue:t.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(Ts.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}}class oa extends Ks{constructor(){super(Ci(oa.getDefaults(),arguments,["frequency","type","modulationType"])),this.name="AMOscillator",this._modulationScale=new sa({context:this.context}),this._modulationNode=new Os({context:this.context});const t=Ci(oa.getDefaults(),arguments,["frequency","type","modulationType"]);this._carrier=new na({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new na({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new aa({context:this.context,units:"positive",value:t.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),Ui(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(na.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){this._modulator.restart(t),this._carrier.restart(t)}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(t=1024){return yi(this,void 0,void 0,(function*(){return ta(this,t)}))}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this._modulationScale.dispose(),this}}class ua extends Ks{constructor(){super(Ci(ua.getDefaults(),arguments,["frequency","type","modulationType"])),this.name="FMOscillator",this._modulationNode=new Os({context:this.context,gain:0});const t=Ci(ua.getDefaults(),arguments,["frequency","type","modulationType"]);this._carrier=new na({context:this.context,detune:t.detune,frequency:0,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.detune=this._carrier.detune,this.frequency=new Ts({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new na({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new aa({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new aa({context:this.context,units:"positive",value:t.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this.detune.connect(this._modulator.detune),Ui(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(na.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){return this._modulator.restart(t),this._carrier.restart(t),this}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(t=1024){return yi(this,void 0,void 0,(function*(){return ta(this,t)}))}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}}class ca extends Ks{constructor(){super(Ci(ca.getDefaults(),arguments,["frequency","width"])),this.name="PulseOscillator",this._widthGate=new Os({context:this.context,gain:0}),this._thresh=new ia({context:this.context,mapping:t=>t<=0?-1:1});const t=Ci(ca.getDefaults(),arguments,["frequency","width"]);this.width=new Ts({context:this.context,units:"audioRange",value:t.width}),this._triangle=new na({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:"triangle"}),this.frequency=this._triangle.frequency,this.detune=this._triangle.detune,this._triangle.chain(this._thresh,this.output),this.width.chain(this._widthGate,this._thresh),Ui(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(Ks.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(t){t=this.toSeconds(t),this._triangle.start(t),this._widthGate.gain.setValueAtTime(1,t)}_stop(t){t=this.toSeconds(t),this._triangle.stop(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(0,t)}_restart(t){this._triangle.restart(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(1,t)}get phase(){return this._triangle.phase}set phase(t){this._triangle.phase=t}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(t){this._triangle.type=t}asArray(t=1024){return yi(this,void 0,void 0,(function*(){return ta(this,t)}))}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}}class la extends Ks{constructor(){super(Ci(la.getDefaults(),arguments,["frequency","type","spread"])),this.name="FatOscillator",this._oscillators=[];const t=Ci(la.getDefaults(),arguments,["frequency","type","spread"]);this.frequency=new Ts({context:this.context,units:"frequency",value:t.frequency}),this.detune=new Ts({context:this.context,units:"cents",value:t.detune}),this._spread=t.spread,this._type=t.type,this._phase=t.phase,this._partials=t.partials,this._partialCount=t.partialCount,this.count=t.count,Ui(this,["frequency","detune"])}static getDefaults(){return Object.assign(na.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(t){t=this.toSeconds(t),this._forEach(e=>e.start(t))}_stop(t){t=this.toSeconds(t),this._forEach(e=>e.stop(t))}_restart(t){this._forEach(e=>e.restart(t))}_forEach(t){for(let e=0;e<this._oscillators.length;e++)t(this._oscillators[e],e)}get type(){return this._type}set type(t){this._type=t,this._forEach(e=>e.type=t)}get spread(){return this._spread}set spread(t){if(this._spread=t,this._oscillators.length>1){const e=-t/2,n=t/(this._oscillators.length-1);this._forEach((t,r)=>t.detune.value=e+n*r)}}get count(){return this._oscillators.length}set count(t){if(ti(t,1),this._oscillators.length!==t){this._forEach(t=>t.dispose()),this._oscillators=[];for(let e=0;e<t;e++){const n=new na({context:this.context,volume:-6-1.1*t,type:this._type,phase:this._phase+e/t*360,partialCount:this._partialCount,onstop:0===e?()=>this.onstop(this):Gi});"custom"===this.type&&(n.partials=this._partials),this.frequency.connect(n.frequency),this.detune.connect(n.detune),n.detune.overridden=!1,n.connect(this.output),this._oscillators[e]=n}this.spread=this._spread,"started"===this.state&&this._forEach(t=>t.start())}}get phase(){return this._phase}set phase(t){this._phase=t,this._forEach((t,e)=>t.phase=this._phase+e/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(t){this._forEach(e=>e.baseType=t),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this._type="custom",this._forEach(e=>e.partials=t))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(t){this._partialCount=t,this._forEach(e=>e.partialCount=t),this._type=this._oscillators[0].type}asArray(t=1024){return yi(this,void 0,void 0,(function*(){return ta(this,t)}))}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(t=>t.dispose()),this}}class ha extends Ks{constructor(){super(Ci(ha.getDefaults(),arguments,["frequency","modulationFrequency"])),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new aa({context:this.context,value:2});const t=Ci(ha.getDefaults(),arguments,["frequency","modulationFrequency"]);this._pulse=new ca({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new na({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),Ui(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(Ks.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(t){t=this.toSeconds(t),this._modulator.start(t),this._pulse.start(t)}_stop(t){t=this.toSeconds(t),this._modulator.stop(t),this._pulse.stop(t)}_restart(t){this._modulator.restart(t),this._pulse.restart(t)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(t){this._modulator.phase=t}asArray(t=1024){return yi(this,void 0,void 0,(function*(){return ta(this,t)}))}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}}const da={am:oa,fat:la,fm:ua,oscillator:na,pulse:ca,pwm:ha};class pa extends Ks{constructor(){super(Ci(pa.getDefaults(),arguments,["frequency","type"])),this.name="OmniOscillator";const t=Ci(pa.getDefaults(),arguments,["frequency","type"]);this.frequency=new Ts({context:this.context,units:"frequency",value:t.frequency}),this.detune=new Ts({context:this.context,units:"cents",value:t.detune}),Ui(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(na.getDefaults(),ua.getDefaults(),oa.getDefaults(),la.getDefaults(),ca.getDefaults(),ha.getDefaults())}_start(t){this._oscillator.start(t)}_stop(t){this._oscillator.stop(t)}_restart(t){return this._oscillator.restart(t),this}get type(){let t="";return["am","fm","fat"].some(t=>this._sourceType===t)&&(t=this._sourceType),t+this._oscillator.type}set type(t){"fm"===t.substr(0,2)?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):"am"===t.substr(0,2)?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):"fat"===t.substr(0,3)?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(3)):"pwm"===t?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):"pulse"===t?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=t)}get partials(){return this._oscillator.partials}set partials(t){this._getOscType(this._oscillator,"pulse")||this._getOscType(this._oscillator,"pwm")||(this._oscillator.partials=t)}get partialCount(){return this._oscillator.partialCount}set partialCount(t){this._getOscType(this._oscillator,"pulse")||this._getOscType(this._oscillator,"pwm")||(this._oscillator.partialCount=t)}set(t){return Reflect.has(t,"type")&&t.type&&(this.type=t.type),super.set(t),this}_createNewOscillator(t){if(t!==this._sourceType){this._sourceType=t;const e=da[t],n=this.now();if(this._oscillator){const t=this._oscillator;t.stop(n),this.context.setTimeout(()=>t.dispose(),this.blockTime)}this._oscillator=new e({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),"started"===this.state&&this._oscillator.start(n)}}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t}get sourceType(){return this._sourceType}set sourceType(t){let e="sine";"pwm"!==this._oscillator.type&&"pulse"!==this._oscillator.type&&(e=this._oscillator.type),"fm"===t?this.type="fm"+e:"am"===t?this.type="am"+e:"fat"===t?this.type="fat"+e:"oscillator"===t?this.type=e:"pulse"===t?this.type="pulse":"pwm"===t&&(this.type="pwm")}_getOscType(t,e){return t instanceof da[e]}get baseType(){return this._oscillator.baseType}set baseType(t){this._getOscType(this._oscillator,"pulse")||this._getOscType(this._oscillator,"pwm")||"pulse"===t||"pwm"===t||(this._oscillator.baseType=t)}get width(){return this._getOscType(this._oscillator,"pulse")?this._oscillator.width:void 0}get count(){return this._getOscType(this._oscillator,"fat")?this._oscillator.count:void 0}set count(t){this._getOscType(this._oscillator,"fat")&&ci(t)&&(this._oscillator.count=t)}get spread(){return this._getOscType(this._oscillator,"fat")?this._oscillator.spread:void 0}set spread(t){this._getOscType(this._oscillator,"fat")&&ci(t)&&(this._oscillator.spread=t)}get modulationType(){return this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am")?this._oscillator.modulationType:void 0}set modulationType(t){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&pi(t)&&(this._oscillator.modulationType=t)}get modulationIndex(){return this._getOscType(this._oscillator,"fm")?this._oscillator.modulationIndex:void 0}get harmonicity(){return this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am")?this._oscillator.harmonicity:void 0}get modulationFrequency(){return this._getOscType(this._oscillator,"pwm")?this._oscillator.modulationFrequency:void 0}asArray(t=1024){return yi(this,void 0,void 0,(function*(){return ta(this,t)}))}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}}class fa extends Ts{constructor(){super(Object.assign(Ci(fa.getDefaults(),arguments,["value"]))),this.override=!1,this.name="Add",this._sum=new Os({context:this.context}),this.input=this._sum,this.output=this._sum,this.addend=this._param,ws(this._constantSource,this._sum)}static getDefaults(){return Object.assign(Ts.getDefaults(),{value:0})}dispose(){return super.dispose(),this._sum.dispose(),this}}class ma extends ra{constructor(){super(Object.assign(Ci(ma.getDefaults(),arguments,["min","max"]))),this.name="Scale";const t=Ci(ma.getDefaults(),arguments,["min","max"]);this._mult=this.input=new aa({context:this.context,value:t.max-t.min}),this._add=this.output=new fa({context:this.context,value:t.min}),this._min=t.min,this._max=t.max,this.input.connect(this.output)}static getDefaults(){return Object.assign(ra.getDefaults(),{max:1,min:0})}get min(){return this._min}set min(t){this._min=t,this._setRange()}get max(){return this._max}set max(t){this._max=t,this._setRange()}_setRange(){this._add.value=this._min,this._mult.value=this._max-this._min}dispose(){return super.dispose(),this._add.dispose(),this._mult.dispose(),this}}class ga extends ra{constructor(){super(Object.assign(Ci(ga.getDefaults(),arguments))),this.name="Zero",this._gain=new Os({context:this.context}),this.output=this._gain,this.input=void 0,xs(this.context.getConstant(0),this._gain)}dispose(){return super.dispose(),_s(this.context.getConstant(0),this._gain),this}}class ba extends vs{constructor(){super(Ci(ba.getDefaults(),arguments,["frequency","min","max"])),this.name="LFO",this._stoppedValue=0,this._units="number",this.convert=!0,this._fromType=ys.prototype._fromType,this._toType=ys.prototype._toType,this._is=ys.prototype._is,this._clampValue=ys.prototype._clampValue;const t=Ci(ba.getDefaults(),arguments,["frequency","min","max"]);this._oscillator=new na({context:this.context,frequency:t.frequency,type:t.type}),this.frequency=this._oscillator.frequency,this._amplitudeGain=new Os({context:this.context,gain:t.amplitude,units:"normalRange"}),this.amplitude=this._amplitudeGain.gain,this._stoppedSignal=new Ts({context:this.context,units:"audioRange",value:0}),this._zeros=new ga({context:this.context}),this._a2g=new sa({context:this.context}),this._scaler=this.output=new ma({context:this.context,max:t.max,min:t.min}),this.units=t.units,this.min=t.min,this.max=t.max,this._oscillator.chain(this._a2g,this._amplitudeGain,this._scaler),this._zeros.connect(this._a2g),this._stoppedSignal.connect(this._a2g),Ui(this,["amplitude","frequency"]),this.phase=t.phase}static getDefaults(){return Object.assign(vs.getDefaults(),{amplitude:1,frequency:"4n",max:1,min:0,phase:0,type:"sine",units:"number"})}start(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(0,t),this._oscillator.start(t),this}stop(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(this._stoppedValue,t),this._oscillator.stop(t),this}sync(){return this._oscillator.sync(),this._oscillator.syncFrequency(),this}unsync(){return this._oscillator.unsync(),this._oscillator.unsyncFrequency(),this}get min(){return this._toType(this._scaler.min)}set min(t){t=this._fromType(t),this._scaler.min=t}get max(){return this._toType(this._scaler.max)}set max(t){t=this._fromType(t),this._scaler.max=t}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t,this._stoppedValue=this._oscillator.getInitialValue(),this._stoppedSignal.value=this._stoppedValue}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t,this._stoppedValue=this._oscillator.getInitialValue(),this._stoppedSignal.value=this._stoppedValue}get units(){return this._units}set units(t){const e=this.min,n=this.max;this._units=t,this.min=e,this.max=n}get state(){return this._oscillator.state}connect(t,e,n){return(t instanceof ys||t instanceof Ts)&&(this.convert=t.convert,this.units=t.units),Cs(this,t,e,n),this}dispose(){return super.dispose(),this._oscillator.dispose(),this._stoppedSignal.dispose(),this._zeros.dispose(),this._scaler.dispose(),this._a2g.dispose(),this._amplitudeGain.dispose(),this.amplitude.dispose(),this}}function ya(t,e=1/0){const n=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return n.get(this)},set:function(r){ti(r,t,e),n.set(this,r)}})}}function va(t,e=1/0){const n=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return n.get(this)},set:function(r){ti(this.toSeconds(r),t,e),n.set(this,r)}})}}class wa extends Ks{constructor(){super(Ci(wa.getDefaults(),arguments,["url","onload"])),this.name="Player",this._activeSources=new Set;const t=Ci(wa.getDefaults(),arguments,["url","onload"]);this._buffer=new Hi({onload:this._onload.bind(this,t.onload),onerror:t.onerror,reverse:t.reverse,url:t.url}),this.autostart=t.autostart,this._loop=t.loop,this._loopStart=t.loopStart,this._loopEnd=t.loopEnd,this._playbackRate=t.playbackRate,this.fadeIn=t.fadeIn,this.fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Ks.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:Gi,onerror:Gi,playbackRate:1,reverse:!1})}load(t){return yi(this,void 0,void 0,(function*(){return yield this._buffer.load(t),this._onload(),this}))}_onload(t=Gi){t(),this.autostart&&this.start()}_onSourceEnd(t){this.onstop(this),this._activeSources.delete(t),0!==this._activeSources.size||this._synced||"started"!==this._state.getValueAtTime(this.now())||(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(t,e,n){return super.start(t,e,n),this}_start(t,e,n){e=this._loop?Ai(e,this._loopStart):Ai(e,0);let r=this.toSeconds(e);this._synced&&(r*=this._playbackRate);const i=n;n=Ai(n,Math.max(this._buffer.duration-r,0));let s=this.toSeconds(n);s/=this._playbackRate,t=this.toSeconds(t);const a=new Qs({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);this._loop||this._synced||(this._state.cancel(t+s),this._state.setStateAtTime("stopped",t+s,{implicitEnd:!0})),this._activeSources.add(a),this._loop&&ai(i)?a.start(t,r):a.start(t,r,s-this.toSeconds(this.fadeOut))}_stop(t){const e=this.toSeconds(t);this._activeSources.forEach(t=>t.stop(e))}restart(t,e,n){return super.restart(t,e,n),this}_restart(t,e,n){this._stop(t),this._start(t,e,n)}seek(t,e){const n=this.toSeconds(e);if("started"===this._state.getValueAtTime(n)){const e=this.toSeconds(t);this._stop(n),this._start(n,e)}return this}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this.buffer.loaded&&ti(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopStart=t})}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this.buffer.loaded&&ti(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopEnd=t})}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._loop}set loop(t){if(this._loop!==t&&(this._loop=t,this._activeSources.forEach(e=>{e.loop=t}),t)){const t=this._state.getNextState("stopped",this.now());t&&this._state.cancel(t.time)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t;const e=this.now(),n=this._state.getNextState("stopped",e);n&&n.implicitEnd&&(this._state.cancel(n.time),this._activeSources.forEach(t=>t.cancelStop())),this._activeSources.forEach(n=>{n.playbackRate.setValueAtTime(t,e)})}get reverse(){return this._buffer.reverse}set reverse(t){this._buffer.reverse=t}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(t=>t.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}}bi([va(0)],wa.prototype,"fadeIn",void 0),bi([va(0)],wa.prototype,"fadeOut",void 0);class xa extends vs{constructor(){super(Ci(xa.getDefaults(),arguments,["urls","onload"],"urls")),this.name="Players",this.input=void 0,this._players=new Map;const t=Ci(xa.getDefaults(),arguments,["urls","onload"],"urls");this._volume=this.output=new qs({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Ui(this,"volume"),this._buffers=new Ds({urls:t.urls,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.mute=t.mute,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Ks.getDefaults(),{baseUrl:"",fadeIn:0,fadeOut:0,mute:!1,onload:Gi,onerror:Gi,urls:{},volume:0})}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._players.forEach(e=>{e.fadeIn=t})}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._players.forEach(e=>{e.fadeOut=t})}get state(){return Array.from(this._players).some(([t,e])=>"started"===e.state)?"started":"stopped"}has(t){return this._buffers.has(t)}player(t){if(Zr(this.has(t),`No Player with the name ${t} exists on this object`),!this._players.has(t)){const e=new wa({context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,url:this._buffers.get(t)}).connect(this.output);this._players.set(t,e)}return this._players.get(t)}get loaded(){return this._buffers.loaded}add(t,e,n){return Zr(!this._buffers.has(t),"A buffer with that name already exists on this object"),this._buffers.add(t,e,n),this}stopAll(t){return this._players.forEach(e=>e.stop(t)),this}dispose(){return super.dispose(),this._volume.dispose(),this.volume.dispose(),this._players.forEach(t=>t.dispose()),this._buffers.dispose(),this}}class _a extends Ks{constructor(){super(Ci(_a.getDefaults(),arguments,["url","onload"])),this.name="GrainPlayer",this._loopStart=0,this._loopEnd=0,this._activeSources=[];const t=Ci(_a.getDefaults(),arguments,["url","onload"]);this.buffer=new Hi({onload:t.onload,onerror:t.onerror,reverse:t.reverse,url:t.url}),this._clock=new Es({context:this.context,callback:this._tick.bind(this),frequency:1/t.grainSize}),this._playbackRate=t.playbackRate,this._grainSize=t.grainSize,this._overlap=t.overlap,this.detune=t.detune,this.overlap=t.overlap,this.loop=t.loop,this.playbackRate=t.playbackRate,this.grainSize=t.grainSize,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.reverse=t.reverse,this._clock.on("stop",this._onstop.bind(this))}static getDefaults(){return Object.assign(Ks.getDefaults(),{onload:Gi,onerror:Gi,overlap:.1,grainSize:.2,playbackRate:1,detune:0,loop:!1,loopStart:0,loopEnd:0,reverse:!1})}_start(t,e,n){e=Ai(e,0),e=this.toSeconds(e),t=this.toSeconds(t);const r=1/this._clock.frequency.getValueAtTime(t);this._clock.start(t,e/r),n&&this.stop(t+this.toSeconds(n))}restart(t,e,n){return super.restart(t,e,n),this}_restart(t,e,n){this._stop(t),this._start(t,e,n)}_stop(t){this._clock.stop(t)}_onstop(t){this._activeSources.forEach(e=>{e.fadeOut=0,e.stop(t)}),this.onstop(this)}_tick(t){const e=this._clock.getTicksAtTime(t),n=e*this._grainSize;if(this.log("offset",n),!this.loop&&n>this.buffer.duration)return void this.stop(t);const r=n<this._overlap?0:this._overlap,i=new Qs({context:this.context,url:this.buffer,fadeIn:r,fadeOut:this._overlap,loop:this.loop,loopStart:this._loopStart,loopEnd:this._loopEnd,playbackRate:ns(this.detune/100)}).connect(this.output);i.start(t,this._grainSize*e),i.stop(t+this._grainSize/this.playbackRate),this._activeSources.push(i),i.onended=()=>{const t=this._activeSources.indexOf(i);-1!==t&&this._activeSources.splice(t,1)}}get playbackRate(){return this._playbackRate}set playbackRate(t){ti(t,.001),this._playbackRate=t,this.grainSize=this._grainSize}get loopStart(){return this._loopStart}set loopStart(t){this.buffer.loaded&&ti(this.toSeconds(t),0,this.buffer.duration),this._loopStart=this.toSeconds(t)}get loopEnd(){return this._loopEnd}set loopEnd(t){this.buffer.loaded&&ti(this.toSeconds(t),0,this.buffer.duration),this._loopEnd=this.toSeconds(t)}get reverse(){return this.buffer.reverse}set reverse(t){this.buffer.reverse=t}get grainSize(){return this._grainSize}set grainSize(t){this._grainSize=this.toSeconds(t),this._clock.frequency.setValueAtTime(this._playbackRate/this._grainSize,this.now())}get overlap(){return this._overlap}set overlap(t){const e=this.toSeconds(t);ti(e,0),this._overlap=e}get loaded(){return this.buffer.loaded}dispose(){return super.dispose(),this.buffer.dispose(),this._clock.dispose(),this._activeSources.forEach(t=>t.dispose()),this}}class Oa extends ra{constructor(){super(...arguments),this.name="Abs",this._abs=new ia({context:this.context,mapping:t=>Math.abs(t)<.001?0:Math.abs(t)}),this.input=this._abs,this.output=this._abs}dispose(){return super.dispose(),this._abs.dispose(),this}}class Sa extends ra{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new ia({context:this.context,mapping:t=>2*Math.abs(t)-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class ka extends ra{constructor(){super(...arguments),this.name="Negate",this._multiply=new aa({context:this.context,value:-1}),this.input=this._multiply,this.output=this._multiply}dispose(){return super.dispose(),this._multiply.dispose(),this}}class Ta extends Ts{constructor(){super(Object.assign(Ci(Ta.getDefaults(),arguments,["value"]))),this.override=!1,this.name="Subtract",this._sum=new Os({context:this.context}),this.input=this._sum,this.output=this._sum,this._neg=new ka({context:this.context}),this.subtrahend=this._param,ws(this._constantSource,this._neg,this._sum)}static getDefaults(){return Object.assign(Ts.getDefaults(),{value:0})}dispose(){return super.dispose(),this._neg.dispose(),this._sum.dispose(),this}}class Ca extends ra{constructor(){super(Object.assign(Ci(Ca.getDefaults(),arguments))),this.name="GreaterThanZero",this._thresh=this.output=new ia({context:this.context,length:127,mapping:t=>t<=0?0:1}),this._scale=this.input=new aa({context:this.context,value:1e4}),this._scale.connect(this._thresh)}dispose(){return super.dispose(),this._scale.dispose(),this._thresh.dispose(),this}}class Aa extends Ts{constructor(){super(Object.assign(Ci(Aa.getDefaults(),arguments,["value"]))),this.name="GreaterThan",this.override=!1;const t=Ci(Aa.getDefaults(),arguments,["value"]);this._subtract=this.input=new Ta({context:this.context,value:t.value}),this._gtz=this.output=new Ca({context:this.context}),this.comparator=this._param=this._subtract.subtrahend,Ui(this,"comparator"),this._subtract.connect(this._gtz)}static getDefaults(){return Object.assign(Ts.getDefaults(),{value:0})}dispose(){return super.dispose(),this._gtz.dispose(),this._subtract.dispose(),this.comparator.dispose(),this}}class Na extends ra{constructor(){super(Object.assign(Ci(Na.getDefaults(),arguments,["value"]))),this.name="Pow";const t=Ci(Na.getDefaults(),arguments,["value"]);this._exponentScaler=this.input=this.output=new ia({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(ra.getDefaults(),{value:1})}_expFunc(t){return e=>Math.pow(Math.abs(e),t)}get value(){return this._exponent}set value(t){this._exponent=t,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}}class Ia extends ma{constructor(){super(Object.assign(Ci(Ia.getDefaults(),arguments,["min","max","exponent"]))),this.name="ScaleExp";const t=Ci(Ia.getDefaults(),arguments,["min","max","exponent"]);this.input=this._exp=new Na({context:this.context,value:t.exponent}),this._exp.connect(this._mult)}static getDefaults(){return Object.assign(ma.getDefaults(),{exponent:1})}get exponent(){return this._exp.value}set exponent(t){this._exp.value=t}dispose(){return super.dispose(),this._exp.dispose(),this}}class Ea extends Ts{constructor(){super(Ci(Ts.getDefaults(),arguments,["value","units"])),this.name="SyncedSignal",this.override=!1;const t=Ci(Ts.getDefaults(),arguments,["value","units"]);this._lastVal=t.value,this._synced=this.context.transport.scheduleRepeat(this._onTick.bind(this),"1i"),this._syncedCallback=this._anchorValue.bind(this),this.context.transport.on("start",this._syncedCallback),this.context.transport.on("pause",this._syncedCallback),this.context.transport.on("stop",this._syncedCallback),this._constantSource.disconnect(),this._constantSource.stop(0),this._constantSource=this.output=new ks({context:this.context,offset:t.value,units:t.units}).start(0),this.setValueAtTime(t.value,0)}_onTick(t){const e=super.getValueAtTime(this.context.transport.seconds);this._lastVal!==e&&(this._lastVal=e,this._constantSource.offset.setValueAtTime(e,t))}_anchorValue(t){const e=super.getValueAtTime(this.context.transport.seconds);this._lastVal=e,this._constantSource.offset.cancelAndHoldAtTime(t),this._constantSource.offset.setValueAtTime(e,t)}getValueAtTime(t){const e=new fs(this.context,t).toSeconds();return super.getValueAtTime(e)}setValueAtTime(t,e){const n=new fs(this.context,e).toSeconds();return super.setValueAtTime(t,n),this}linearRampToValueAtTime(t,e){const n=new fs(this.context,e).toSeconds();return super.linearRampToValueAtTime(t,n),this}exponentialRampToValueAtTime(t,e){const n=new fs(this.context,e).toSeconds();return super.exponentialRampToValueAtTime(t,n),this}setTargetAtTime(t,e,n){const r=new fs(this.context,e).toSeconds();return super.setTargetAtTime(t,r,n),this}cancelScheduledValues(t){const e=new fs(this.context,t).toSeconds();return super.cancelScheduledValues(e),this}setValueCurveAtTime(t,e,n,r){const i=new fs(this.context,e).toSeconds();return n=this.toSeconds(n),super.setValueCurveAtTime(t,i,n,r),this}cancelAndHoldAtTime(t){const e=new fs(this.context,t).toSeconds();return super.cancelAndHoldAtTime(e),this}setRampPoint(t){const e=new fs(this.context,t).toSeconds();return super.setRampPoint(e),this}exponentialRampTo(t,e,n){const r=new fs(this.context,n).toSeconds();return super.exponentialRampTo(t,e,r),this}linearRampTo(t,e,n){const r=new fs(this.context,n).toSeconds();return super.linearRampTo(t,e,r),this}targetRampTo(t,e,n){const r=new fs(this.context,n).toSeconds();return super.targetRampTo(t,e,r),this}dispose(){return super.dispose(),this.context.transport.clear(this._synced),this.context.transport.off("start",this._syncedCallback),this.context.transport.off("pause",this._syncedCallback),this.context.transport.off("stop",this._syncedCallback),this._constantSource.dispose(),this}}class ja extends vs{constructor(){super(Ci(ja.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="Envelope",this._sig=new Ts({context:this.context,value:0}),this.output=this._sig,this.input=void 0;const t=Ci(ja.getDefaults(),arguments,["attack","decay","sustain","release"]);this.attack=t.attack,this.decay=t.decay,this.sustain=t.sustain,this.release=t.release,this.attackCurve=t.attackCurve,this.releaseCurve=t.releaseCurve,this.decayCurve=t.decayCurve}static getDefaults(){return Object.assign(vs.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(t,e){if(pi(t))return t;{let n;for(n in Ma)if(Ma[n][e]===t)return n;return t}}_setCurve(t,e,n){if(pi(n)&&Reflect.has(Ma,n)){const r=Ma[n];li(r)?"_decayCurve"!==t&&(this[t]=r[e]):this[t]=r}else{if(!di(n)||"_decayCurve"===t)throw new Error("Envelope: invalid curve: "+n);this[t]=n}}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(t){this._setCurve("_attackCurve","In",t)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(t){this._setCurve("_releaseCurve","Out",t)}get decayCurve(){return this._decayCurve}set decayCurve(t){Zr(["linear","exponential"].some(e=>e===t),"Invalid envelope curve: "+t),this._decayCurve=t}triggerAttack(t,e=1){this.log("triggerAttack",t,e),t=this.toSeconds(t);let n=this.toSeconds(this.attack);const r=this.toSeconds(this.decay),i=this.getValueAtTime(t);if(i>0){n=(1-i)/(1/n)}if(n<this.sampleTime)this._sig.cancelScheduledValues(t),this._sig.setValueAtTime(e,t);else if("linear"===this._attackCurve)this._sig.linearRampTo(e,n,t);else if("exponential"===this._attackCurve)this._sig.targetRampTo(e,n,t);else{this._sig.cancelAndHoldAtTime(t);let r=this._attackCurve;for(let t=1;t<r.length;t++)if(r[t-1]<=i&&i<=r[t]){r=this._attackCurve.slice(t),r[0]=i;break}this._sig.setValueCurveAtTime(r,t,n,e)}if(r&&this.sustain<1){const i=e*this.sustain,s=t+n;this.log("decay",s),"linear"===this._decayCurve?this._sig.linearRampToValueAtTime(i,r+s):this._sig.exponentialApproachValueAtTime(i,s,r)}return this}triggerRelease(t){this.log("triggerRelease",t),t=this.toSeconds(t);const e=this.getValueAtTime(t);if(e>0){const n=this.toSeconds(this.release);n<this.sampleTime?this._sig.setValueAtTime(0,t):"linear"===this._releaseCurve?this._sig.linearRampTo(0,n,t):"exponential"===this._releaseCurve?this._sig.targetRampTo(0,n,t):(Zr(di(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(t),this._sig.setValueCurveAtTime(this._releaseCurve,t,n,e))}return this}getValueAtTime(t){return this._sig.getValueAtTime(t)}triggerAttackRelease(t,e,n=1){return e=this.toSeconds(e),this.triggerAttack(e,n),this.triggerRelease(e+this.toSeconds(t)),this}cancel(t){return this._sig.cancelScheduledValues(this.toSeconds(t)),this}connect(t,e=0,n=0){return Cs(this,t,e,n),this}asArray(t=1024){return yi(this,void 0,void 0,(function*(){const e=t/this.context.sampleRate,n=new Ki(1,e,this.context.sampleRate),r=this.toSeconds(this.attack)+this.toSeconds(this.decay),i=r+this.toSeconds(this.release),s=.1*i,a=i+s,o=new this.constructor(Object.assign(this.get(),{attack:e*this.toSeconds(this.attack)/a,decay:e*this.toSeconds(this.decay)/a,release:e*this.toSeconds(this.release)/a,context:n}));o._sig.toDestination(),o.triggerAttackRelease(e*(r+s)/a,0);return(yield n.render()).getChannelData(0)}))}dispose(){return super.dispose(),this._sig.dispose(),this}}bi([va(0)],ja.prototype,"attack",void 0),bi([va(0)],ja.prototype,"decay",void 0),bi([ya(0,1)],ja.prototype,"sustain",void 0),bi([va(0)],ja.prototype,"release",void 0);const Ma=(()=>{let t,e;const n=[];for(t=0;t<128;t++)n[t]=Math.sin(t/127*(Math.PI/2));const r=[];for(t=0;t<127;t++){e=t/127;const n=Math.sin(e*(2*Math.PI)*6.4-Math.PI/2)+1;r[t]=n/10+.83*e}r[127]=1;const i=[];for(t=0;t<128;t++)i[t]=Math.ceil(t/127*5)/5;const s=[];for(t=0;t<128;t++)e=t/127,s[t]=.5*(1-Math.cos(Math.PI*e));const a=[];for(t=0;t<128;t++){e=t/127;const n=4*Math.pow(e,3)+.2,r=Math.cos(n*Math.PI*2*e);a[t]=Math.abs(r*(1-e))}function o(t){const e=new Array(t.length);for(let n=0;n<t.length;n++)e[n]=1-t[n];return e}return{bounce:{In:o(a),Out:a},cosine:{In:n,Out:(u=n,u.slice(0).reverse())},exponential:"exponential",linear:"linear",ripple:{In:r,Out:o(r)},sine:{In:s,Out:o(s)},step:{In:i,Out:o(i)}};var u})();class Da extends vs{constructor(){super(Ci(Da.getDefaults(),arguments)),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease;const t=Ci(Da.getDefaults(),arguments);this._volume=this.output=new qs({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Ui(this,"volume")}static getDefaults(){return Object.assign(vs.getDefaults(),{volume:0})}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",0)),this}_syncState(){let t=!1;return this._synced||(this._synced=!0,t=!0),t}_syncMethod(t,e){const n=this["_original_"+t]=this[t];this[t]=(...t)=>{const r=t[e],i=this.context.transport.schedule(r=>{t[e]=r,n.apply(this,t)},r);this._scheduledEvents.push(i)}}unsync(){return this._scheduledEvents.forEach(t=>this.context.transport.clear(t)),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease),this}triggerAttackRelease(t,e,n,r){const i=this.toSeconds(n),s=this.toSeconds(e);return this.triggerAttack(t,i,r),this.triggerRelease(i+s),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}}class Ra extends Da{constructor(){super(Ci(Ra.getDefaults(),arguments));const t=Ci(Ra.getDefaults(),arguments);this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(Da.getDefaults(),{detune:0,onsilence:Gi,portamento:0})}triggerAttack(t,e,n=1){this.log("triggerAttack",t,e,n);const r=this.toSeconds(e);return this._triggerEnvelopeAttack(r,n),this.setNote(t,r),this}triggerRelease(t){this.log("triggerRelease",t);const e=this.toSeconds(t);return this._triggerEnvelopeRelease(e),this}setNote(t,e){const n=this.toSeconds(e),r=t instanceof ls?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(n)>.05){const t=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(r,t,n)}else this.frequency.setValueAtTime(r,n);return this}}bi([va(0)],Ra.prototype,"portamento",void 0);class Pa extends ja{constructor(){super(Ci(Pa.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new Os({context:this.context,gain:0}),this.output=this._gainNode,this.input=this._gainNode,this._sig.connect(this._gainNode.gain),this.output=this._gainNode,this.input=this._gainNode}dispose(){return super.dispose(),this._gainNode.dispose(),this}}class Fa extends Ra{constructor(){super(Ci(Fa.getDefaults(),arguments)),this.name="Synth";const t=Ci(Fa.getDefaults(),arguments);this.oscillator=new pa(Object.assign({context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)},t.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new Pa(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),Ui(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(Ra.getDefaults(),{envelope:Object.assign(Ni(ja.getDefaults(),Object.keys(vs.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(Ni(pa.getDefaults(),[...Object.keys(Ks.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(t,e){if(this.envelope.triggerAttack(t,e),this.oscillator.start(t),0===this.envelope.sustain){const e=this.toSeconds(this.envelope.attack),n=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+e+n)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}}class za extends Ra{constructor(){super(Ci(za.getDefaults(),arguments)),this.name="ModulationSynth";const t=Ci(za.getDefaults(),arguments);this._carrier=new Fa({context:this.context,oscillator:t.oscillator,envelope:t.envelope,onsilence:()=>this.onsilence(this),volume:-10}),this._modulator=new Fa({context:this.context,oscillator:t.modulation,envelope:t.modulationEnvelope,volume:-10}),this.oscillator=this._carrier.oscillator,this.envelope=this._carrier.envelope,this.modulation=this._modulator.oscillator,this.modulationEnvelope=this._modulator.envelope,this.frequency=new Ts({context:this.context,units:"frequency"}),this.detune=new Ts({context:this.context,value:t.detune,units:"cents"}),this.harmonicity=new aa({context:this.context,value:t.harmonicity,minValue:0}),this._modulationNode=new Os({context:this.context,gain:0}),Ui(this,["frequency","harmonicity","oscillator","envelope","modulation","modulationEnvelope","detune"])}static getDefaults(){return Object.assign(Ra.getDefaults(),{harmonicity:3,oscillator:Object.assign(Ni(pa.getDefaults(),[...Object.keys(Ks.getDefaults()),"frequency","detune"]),{type:"sine"}),envelope:Object.assign(Ni(ja.getDefaults(),Object.keys(vs.getDefaults())),{attack:.01,decay:.01,sustain:1,release:.5}),modulation:Object.assign(Ni(pa.getDefaults(),[...Object.keys(Ks.getDefaults()),"frequency","detune"]),{type:"square"}),modulationEnvelope:Object.assign(Ni(ja.getDefaults(),Object.keys(vs.getDefaults())),{attack:.5,decay:0,sustain:1,release:.5})})}_triggerEnvelopeAttack(t,e){this._carrier._triggerEnvelopeAttack(t,e),this._modulator._triggerEnvelopeAttack(t,e)}_triggerEnvelopeRelease(t){return this._carrier._triggerEnvelopeRelease(t),this._modulator._triggerEnvelopeRelease(t),this}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this._carrier.dispose(),this._modulator.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._modulationNode.dispose(),this}}class La extends za{constructor(){super(Ci(La.getDefaults(),arguments)),this.name="AMSynth",this._modulationScale=new sa({context:this.context}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output)}dispose(){return super.dispose(),this._modulationScale.dispose(),this}}class $a extends vs{constructor(){super(Ci($a.getDefaults(),arguments,["frequency","type"])),this.name="BiquadFilter";const t=Ci($a.getDefaults(),arguments,["frequency","type"]);this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new ys({context:this.context,units:"number",value:t.Q,param:this._filter.Q}),this.frequency=new ys({context:this.context,units:"frequency",value:t.frequency,param:this._filter.frequency}),this.detune=new ys({context:this.context,units:"cents",value:t.detune,param:this._filter.detune}),this.gain=new ys({context:this.context,units:"gain",value:t.gain,param:this._filter.gain}),this.type=t.type}static getDefaults(){return Object.assign(vs.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(t){Zr(-1!==["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t),"Invalid filter type: "+t),this._filter.type=t}getFrequencyResponse(t=128){const e=new Float32Array(t);for(let n=0;n<t;n++){const r=19980*Math.pow(n/t,2)+20;e[n]=r}const n=new Float32Array(t),r=new Float32Array(t),i=this.context.createBiquadFilter();return i.type=this.type,i.Q.value=this.Q.value,i.frequency.value=this.frequency.value,i.gain.value=this.gain.value,i.getFrequencyResponse(e,n,r),n}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}}class Ba extends vs{constructor(){super(Ci(Ba.getDefaults(),arguments,["frequency","type","rolloff"])),this.name="Filter",this.input=new Os({context:this.context}),this.output=new Os({context:this.context}),this._filters=[];const t=Ci(Ba.getDefaults(),arguments,["frequency","type","rolloff"]);this._filters=[],this.Q=new Ts({context:this.context,units:"positive",value:t.Q}),this.frequency=new Ts({context:this.context,units:"frequency",value:t.frequency}),this.detune=new Ts({context:this.context,units:"cents",value:t.detune}),this.gain=new Ts({context:this.context,units:"decibels",value:t.gain}),this._type=t.type,this.rolloff=t.rolloff,Ui(this,["detune","frequency","gain","Q"])}static getDefaults(){return Object.assign(vs.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:"lowpass"})}get type(){return this._type}set type(t){Zr(-1!==["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t),"Invalid filter type: "+t),this._type=t,this._filters.forEach(e=>e.type=t)}get rolloff(){return this._rolloff}set rolloff(t){const e=ci(t)?t:parseInt(t,10),n=[-12,-24,-48,-96];let r=n.indexOf(e);Zr(-1!==r,"rolloff can only be "+n.join(", ")),r+=1,this._rolloff=e,this.input.disconnect(),this._filters.forEach(t=>t.disconnect()),this._filters=new Array(r);for(let t=0;t<r;t++){const e=new $a({context:this.context});e.type=this._type,this.frequency.connect(e.frequency),this.detune.connect(e.detune),this.Q.connect(e.Q),this.gain.connect(e.gain),this._filters[t]=e}this._internalChannels=this._filters,ws(this.input,...this._internalChannels,this.output)}getFrequencyResponse(t=128){const e=new $a({frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),n=new Float32Array(t).map(()=>1);return this._filters.forEach(()=>{e.getFrequencyResponse(t).forEach((t,e)=>n[e]*=t)}),e.dispose(),n}dispose(){return super.dispose(),this._filters.forEach(t=>{t.dispose()}),Wi(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}}class qa extends ja{constructor(){super(Ci(qa.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="FrequencyEnvelope";const t=Ci(qa.getDefaults(),arguments,["attack","decay","sustain","release"]);this._octaves=t.octaves,this._baseFrequency=this.toFrequency(t.baseFrequency),this._exponent=this.input=new Na({context:this.context,value:t.exponent}),this._scale=this.output=new ma({context:this.context,min:this._baseFrequency,max:this._baseFrequency*Math.pow(2,this._octaves)}),this._sig.chain(this._exponent,this._scale)}static getDefaults(){return Object.assign(ja.getDefaults(),{baseFrequency:200,exponent:1,octaves:4})}get baseFrequency(){return this._baseFrequency}set baseFrequency(t){const e=this.toFrequency(t);ti(e,0),this._baseFrequency=e,this._scale.min=this._baseFrequency,this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(t){ti(t,0),this._octaves=t,this._scale.max=this._baseFrequency*Math.pow(2,t)}get exponent(){return this._exponent.value}set exponent(t){this._exponent.value=t}dispose(){return super.dispose(),this._exponent.dispose(),this._scale.dispose(),this}}class Va extends Ra{constructor(){super(Ci(Va.getDefaults(),arguments)),this.name="MonoSynth";const t=Ci(Va.getDefaults(),arguments);this.oscillator=new pa(Object.assign(t.oscillator,{context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)})),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.filter=new Ba(Object.assign(t.filter,{context:this.context})),this.filterEnvelope=new qa(Object.assign(t.filterEnvelope,{context:this.context})),this.envelope=new Pa(Object.assign(t.envelope,{context:this.context})),this.oscillator.chain(this.filter,this.envelope,this.output),this.filterEnvelope.connect(this.filter.frequency),Ui(this,["oscillator","frequency","detune","filter","filterEnvelope","envelope"])}static getDefaults(){return Object.assign(Ra.getDefaults(),{envelope:Object.assign(Ni(ja.getDefaults(),Object.keys(vs.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.9}),filter:Object.assign(Ni(Ba.getDefaults(),Object.keys(vs.getDefaults())),{Q:1,rolloff:-12,type:"lowpass"}),filterEnvelope:Object.assign(Ni(qa.getDefaults(),Object.keys(vs.getDefaults())),{attack:.6,baseFrequency:200,decay:.2,exponent:2,octaves:3,release:2,sustain:.5}),oscillator:Object.assign(Ni(pa.getDefaults(),Object.keys(Ks.getDefaults())),{type:"sawtooth"})})}_triggerEnvelopeAttack(t,e=1){if(this.envelope.triggerAttack(t,e),this.filterEnvelope.triggerAttack(t),this.oscillator.start(t),0===this.envelope.sustain){const e=this.toSeconds(this.envelope.attack),n=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+e+n)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.filterEnvelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this.filterEnvelope.dispose(),this.filter.dispose(),this}}class Ua extends Ra{constructor(){super(Ci(Ua.getDefaults(),arguments)),this.name="DuoSynth";const t=Ci(Ua.getDefaults(),arguments);this.voice0=new Va(Object.assign(t.voice0,{context:this.context,onsilence:()=>this.onsilence(this)})),this.voice1=new Va(Object.assign(t.voice1,{context:this.context})),this.harmonicity=new aa({context:this.context,units:"positive",value:t.harmonicity}),this._vibrato=new ba({frequency:t.vibratoRate,context:this.context,min:-50,max:50}),this._vibrato.start(),this.vibratoRate=this._vibrato.frequency,this._vibratoGain=new Os({context:this.context,units:"normalRange",gain:t.vibratoAmount}),this.vibratoAmount=this._vibratoGain.gain,this.frequency=new Ts({context:this.context,units:"frequency",value:440}),this.detune=new Ts({context:this.context,units:"cents",value:t.detune}),this.frequency.connect(this.voice0.frequency),this.frequency.chain(this.harmonicity,this.voice1.frequency),this._vibrato.connect(this._vibratoGain),this._vibratoGain.fan(this.voice0.detune,this.voice1.detune),this.detune.fan(this.voice0.detune,this.voice1.detune),this.voice0.connect(this.output),this.voice1.connect(this.output),Ui(this,["voice0","voice1","frequency","vibratoAmount","vibratoRate"])}getLevelAtTime(t){return t=this.toSeconds(t),this.voice0.envelope.getValueAtTime(t)+this.voice1.envelope.getValueAtTime(t)}static getDefaults(){return Ti(Ra.getDefaults(),{vibratoAmount:.5,vibratoRate:5,harmonicity:1.5,voice0:Ti(Ni(Va.getDefaults(),Object.keys(Ra.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}}),voice1:Ti(Ni(Va.getDefaults(),Object.keys(Ra.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}})})}_triggerEnvelopeAttack(t,e){this.voice0._triggerEnvelopeAttack(t,e),this.voice1._triggerEnvelopeAttack(t,e)}_triggerEnvelopeRelease(t){return this.voice0._triggerEnvelopeRelease(t),this.voice1._triggerEnvelopeRelease(t),this}dispose(){return super.dispose(),this.voice0.dispose(),this.voice1.dispose(),this.frequency.dispose(),this.detune.dispose(),this._vibrato.dispose(),this.vibratoRate.dispose(),this._vibratoGain.dispose(),this.harmonicity.dispose(),this}}class Wa extends za{constructor(){super(Ci(Wa.getDefaults(),arguments)),this.name="FMSynth";const t=Ci(Wa.getDefaults(),arguments);this.modulationIndex=new aa({context:this.context,value:t.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output)}static getDefaults(){return Object.assign(za.getDefaults(),{modulationIndex:10})}dispose(){return super.dispose(),this.modulationIndex.dispose(),this}}const Ga=[1,1.483,1.932,2.546,2.63,3.897];class Ha extends Ra{constructor(){super(Ci(Ha.getDefaults(),arguments)),this.name="MetalSynth",this._oscillators=[],this._freqMultipliers=[];const t=Ci(Ha.getDefaults(),arguments);this.detune=new Ts({context:this.context,units:"cents",value:t.detune}),this.frequency=new Ts({context:this.context,units:"frequency"}),this._amplitude=new Os({context:this.context,gain:0}).connect(this.output),this._highpass=new Ba({Q:0,context:this.context,type:"highpass"}).connect(this._amplitude);for(let e=0;e<Ga.length;e++){const n=new ua({context:this.context,harmonicity:t.harmonicity,modulationIndex:t.modulationIndex,modulationType:"square",onstop:0===e?()=>this.onsilence(this):Gi,type:"square"});n.connect(this._highpass),this._oscillators[e]=n;const r=new aa({context:this.context,value:Ga[e]});this._freqMultipliers[e]=r,this.frequency.chain(r,n.frequency),this.detune.connect(n.detune)}this._filterFreqScaler=new ma({context:this.context,max:7e3,min:this.toFrequency(t.resonance)}),this.envelope=new ja({attack:t.envelope.attack,attackCurve:"linear",context:this.context,decay:t.envelope.decay,release:t.envelope.release,sustain:0}),this.envelope.chain(this._filterFreqScaler,this._highpass.frequency),this.envelope.connect(this._amplitude.gain),this._octaves=t.octaves,this.octaves=t.octaves}static getDefaults(){return Ti(Ra.getDefaults(),{envelope:Object.assign(Ni(ja.getDefaults(),Object.keys(vs.getDefaults())),{attack:.001,decay:1.4,release:.2}),harmonicity:5.1,modulationIndex:32,octaves:1.5,resonance:4e3})}_triggerEnvelopeAttack(t,e=1){return this.envelope.triggerAttack(t,e),this._oscillators.forEach(e=>e.start(t)),0===this.envelope.sustain&&this._oscillators.forEach(e=>{e.stop(t+this.toSeconds(this.envelope.attack)+this.toSeconds(this.envelope.decay))}),this}_triggerEnvelopeRelease(t){return this.envelope.triggerRelease(t),this._oscillators.forEach(e=>e.stop(t+this.toSeconds(this.envelope.release))),this}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}get modulationIndex(){return this._oscillators[0].modulationIndex.value}set modulationIndex(t){this._oscillators.forEach(e=>e.modulationIndex.value=t)}get harmonicity(){return this._oscillators[0].harmonicity.value}set harmonicity(t){this._oscillators.forEach(e=>e.harmonicity.value=t)}get resonance(){return this._filterFreqScaler.min}set resonance(t){this._filterFreqScaler.min=this.toFrequency(t),this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._filterFreqScaler.max=this._filterFreqScaler.min*Math.pow(2,t)}dispose(){return super.dispose(),this._oscillators.forEach(t=>t.dispose()),this._freqMultipliers.forEach(t=>t.dispose()),this.frequency.dispose(),this.detune.dispose(),this._filterFreqScaler.dispose(),this._amplitude.dispose(),this.envelope.dispose(),this._highpass.dispose(),this}}class Ka extends Fa{constructor(){super(Ci(Ka.getDefaults(),arguments)),this.name="MembraneSynth",this.portamento=0;const t=Ci(Ka.getDefaults(),arguments);this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,Ui(this,["oscillator","envelope"])}static getDefaults(){return Ti(Ra.getDefaults(),Fa.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(t,e){const n=this.toSeconds(e),r=this.toFrequency(t instanceof ls?t.toFrequency():t),i=r*this.octaves;return this.oscillator.frequency.setValueAtTime(i,n),this.oscillator.frequency.exponentialRampToValueAtTime(r,n+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}}bi([ya(0)],Ka.prototype,"octaves",void 0),bi([va(0)],Ka.prototype,"pitchDecay",void 0);class Qa extends Da{constructor(){super(Ci(Qa.getDefaults(),arguments)),this.name="NoiseSynth";const t=Ci(Qa.getDefaults(),arguments);this.noise=new Xs(Object.assign({context:this.context},t.noise)),this.envelope=new Pa(Object.assign({context:this.context},t.envelope)),this.noise.chain(this.envelope,this.output)}static getDefaults(){return Object.assign(Da.getDefaults(),{envelope:Object.assign(Ni(ja.getDefaults(),Object.keys(vs.getDefaults())),{decay:.1,sustain:0}),noise:Object.assign(Ni(Xs.getDefaults(),Object.keys(Ks.getDefaults())),{type:"white"})})}triggerAttack(t,e=1){return t=this.toSeconds(t),this.envelope.triggerAttack(t,e),this.noise.start(t),0===this.envelope.sustain&&this.noise.stop(t+this.toSeconds(this.envelope.attack)+this.toSeconds(this.envelope.decay)),this}triggerRelease(t){return t=this.toSeconds(t),this.envelope.triggerRelease(t),this.noise.stop(t+this.toSeconds(this.envelope.release)),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",0),this._syncMethod("triggerRelease",0)),this}triggerAttackRelease(t,e,n=1){return e=this.toSeconds(e),t=this.toSeconds(t),this.triggerAttack(e,n),this.triggerRelease(e+t),this}dispose(){return super.dispose(),this.noise.dispose(),this.envelope.dispose(),this}}const Xa=new Set;function Ya(t){Xa.add(t)}function Ja(t,e){const n=`registerProcessor("${t}", ${e})`;Xa.add(n)}class Za extends vs{constructor(t){super(t),this.name="ToneAudioWorklet",this.workletOptions={},this.onprocessorerror=Gi;const e=URL.createObjectURL(new Blob([Array.from(Xa).join("\n")],{type:"text/javascript"})),n=this._audioWorkletName();this._dummyGain=this.context.createGain(),this._dummyParam=this._dummyGain.gain,this.context.addAudioWorkletModule(e,n).then(()=>{this.disposed||(this._worklet=this.context.createAudioWorkletNode(n,this.workletOptions),this._worklet.onprocessorerror=this.onprocessorerror.bind(this),this.onReady(this._worklet))})}dispose(){return super.dispose(),this._dummyGain.disconnect(),this._worklet&&(this._worklet.port.postMessage("dispose"),this._worklet.disconnect()),this}}Ya('\n\t/**\n\t * The base AudioWorkletProcessor for use in Tone.js. Works with the [[ToneAudioWorklet]]. \n\t */\n\tclass ToneAudioWorkletProcessor extends AudioWorkletProcessor {\n\n\t\tconstructor(options) {\n\t\t\t\n\t\t\tsuper(options);\n\t\t\t/**\n\t\t\t * If the processor was disposed or not. Keep alive until it\'s disposed.\n\t\t\t */\n\t\t\tthis.disposed = false;\n\t\t   \t/** \n\t\t\t * The number of samples in the processing block\n\t\t\t */\n\t\t\tthis.blockSize = 128;\n\t\t\t/**\n\t\t\t * the sample rate\n\t\t\t */\n\t\t\tthis.sampleRate = sampleRate;\n\n\t\t\tthis.port.onmessage = (event) => {\n\t\t\t\t// when it receives a dispose \n\t\t\t\tif (event.data === "dispose") {\n\t\t\t\t\tthis.disposed = true;\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}\n');Ya("\n\t/**\n\t * Abstract class for a single input/output processor. \n\t * has a 'generate' function which processes one sample at a time\n\t */\n\tclass SingleIOProcessor extends ToneAudioWorkletProcessor {\n\n\t\tconstructor(options) {\n\t\t\tsuper(Object.assign(options, {\n\t\t\t\tnumberOfInputs: 1,\n\t\t\t\tnumberOfOutputs: 1\n\t\t\t}));\n\t\t\t/**\n\t\t\t * Holds the name of the parameter and a single value of that\n\t\t\t * parameter at the current sample\n\t\t\t * @type { [name: string]: number }\n\t\t\t */\n\t\t\tthis.params = {}\n\t\t}\n\n\t\t/**\n\t\t * Generate an output sample from the input sample and parameters\n\t\t * @abstract\n\t\t * @param input number\n\t\t * @param channel number\n\t\t * @param parameters { [name: string]: number }\n\t\t * @returns number\n\t\t */\n\t\tgenerate(){}\n\n\t\t/**\n\t\t * Update the private params object with the \n\t\t * values of the parameters at the given index\n\t\t * @param parameters { [name: string]: Float32Array },\n\t\t * @param index number\n\t\t */\n\t\tupdateParams(parameters, index) {\n\t\t\tfor (const paramName in parameters) {\n\t\t\t\tconst param = parameters[paramName];\n\t\t\t\tif (param.length > 1) {\n\t\t\t\t\tthis.params[paramName] = parameters[paramName][index];\n\t\t\t\t} else {\n\t\t\t\t\tthis.params[paramName] = parameters[paramName][0];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Process a single frame of the audio\n\t\t * @param inputs Float32Array[][]\n\t\t * @param outputs Float32Array[][]\n\t\t */\n\t\tprocess(inputs, outputs, parameters) {\n\t\t\tconst input = inputs[0];\n\t\t\tconst output = outputs[0];\n\t\t\t// get the parameter values\n\t\t\tconst channelCount = Math.max(input && input.length || 0, output.length);\n\t\t\tfor (let sample = 0; sample < this.blockSize; sample++) {\n\t\t\t\tthis.updateParams(parameters, sample);\n\t\t\t\tfor (let channel = 0; channel < channelCount; channel++) {\n\t\t\t\t\tconst inputSample = input && input.length ? input[channel][sample] : 0;\n\t\t\t\t\toutput[channel][sample] = this.generate(inputSample, channel, this.params);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn !this.disposed;\n\t\t}\n\t};\n");Ya("\n\t/**\n\t * A multichannel buffer for use within an AudioWorkletProcessor as a delay line\n\t */\n\tclass DelayLine {\n\t\t\n\t\tconstructor(size, channels) {\n\t\t\tthis.buffer = [];\n\t\t\tthis.writeHead = []\n\t\t\tthis.size = size;\n\n\t\t\t// create the empty channels\n\t\t\tfor (let i = 0; i < channels; i++) {\n\t\t\t\tthis.buffer[i] = new Float32Array(this.size);\n\t\t\t\tthis.writeHead[i] = 0;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Push a value onto the end\n\t\t * @param channel number\n\t\t * @param value number\n\t\t */\n\t\tpush(channel, value) {\n\t\t\tthis.writeHead[channel] += 1;\n\t\t\tif (this.writeHead[channel] > this.size) {\n\t\t\t\tthis.writeHead[channel] = 0;\n\t\t\t}\n\t\t\tthis.buffer[channel][this.writeHead[channel]] = value;\n\t\t}\n\n\t\t/**\n\t\t * Get the recorded value of the channel given the delay\n\t\t * @param channel number\n\t\t * @param delay number delay samples\n\t\t */\n\t\tget(channel, delay) {\n\t\t\tlet readHead = this.writeHead[channel] - Math.floor(delay);\n\t\t\tif (readHead < 0) {\n\t\t\t\treadHead += this.size;\n\t\t\t}\n\t\t\treturn this.buffer[channel][readHead];\n\t\t}\n\t}\n");Ja("feedback-comb-filter",'\n\tclass FeedbackCombFilterWorklet extends SingleIOProcessor {\n\n\t\tconstructor(options) {\n\t\t\tsuper(options);\n\t\t\tthis.delayLine = new DelayLine(this.sampleRate, options.channelCount || 2);\n\t\t}\n\n\t\tstatic get parameterDescriptors() {\n\t\t\treturn [{\n\t\t\t\tname: "delayTime",\n\t\t\t\tdefaultValue: 0.1,\n\t\t\t\tminValue: 0,\n\t\t\t\tmaxValue: 1,\n\t\t\t\tautomationRate: "k-rate"\n\t\t\t}, {\n\t\t\t\tname: "feedback",\n\t\t\t\tdefaultValue: 0.5,\n\t\t\t\tminValue: 0,\n\t\t\t\tmaxValue: 0.9999,\n\t\t\t\tautomationRate: "k-rate"\n\t\t\t}];\n\t\t}\n\n\t\tgenerate(input, channel, parameters) {\n\t\t\tconst delayedSample = this.delayLine.get(channel, parameters.delayTime * this.sampleRate);\n\t\t\tthis.delayLine.push(channel, input + delayedSample * parameters.feedback);\n\t\t\treturn delayedSample;\n\t\t}\n\t}\n');class to extends Za{constructor(){super(Ci(to.getDefaults(),arguments,["delayTime","resonance"])),this.name="FeedbackCombFilter";const t=Ci(to.getDefaults(),arguments,["delayTime","resonance"]);this.input=new Os({context:this.context}),this.output=new Os({context:this.context}),this.delayTime=new ys({context:this.context,value:t.delayTime,units:"time",minValue:0,maxValue:1,param:this._dummyParam,swappable:!0}),this.resonance=new ys({context:this.context,value:t.resonance,units:"normalRange",param:this._dummyParam,swappable:!0}),Ui(this,["resonance","delayTime"])}_audioWorkletName(){return"feedback-comb-filter"}static getDefaults(){return Object.assign(vs.getDefaults(),{delayTime:.1,resonance:.5})}onReady(t){ws(this.input,t,this.output);const e=t.parameters.get("delayTime");this.delayTime.setParam(e);const n=t.parameters.get("feedback");this.resonance.setParam(n)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.delayTime.dispose(),this.resonance.dispose(),this}}class eo extends vs{constructor(){super(Ci(eo.getDefaults(),arguments,["frequency","type"])),this.name="OnePoleFilter";const t=Ci(eo.getDefaults(),arguments,["frequency","type"]);this._frequency=t.frequency,this._type=t.type,this.input=new Os({context:this.context}),this.output=new Os({context:this.context}),this._createFilter()}static getDefaults(){return Object.assign(vs.getDefaults(),{frequency:880,type:"lowpass"})}_createFilter(){const t=this._filter,e=this.toFrequency(this._frequency),n=1/(2*Math.PI*e);if("lowpass"===this._type){const t=1/(n*this.context.sampleRate),e=t-1;this._filter=this.context.createIIRFilter([t,0],[1,e])}else{const t=1/(n*this.context.sampleRate)-1;this._filter=this.context.createIIRFilter([1,-1],[1,t])}this.input.chain(this._filter,this.output),t&&this.context.setTimeout(()=>{this.disposed||(this.input.disconnect(t),t.disconnect())},this.blockTime)}get frequency(){return this._frequency}set frequency(t){this._frequency=t,this._createFilter()}get type(){return this._type}set type(t){this._type=t,this._createFilter()}getFrequencyResponse(t=128){const e=new Float32Array(t);for(let n=0;n<t;n++){const r=19980*Math.pow(n/t,2)+20;e[n]=r}const n=new Float32Array(t),r=new Float32Array(t);return this._filter.getFrequencyResponse(e,n,r),n}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this._filter.disconnect(),this}}class no extends vs{constructor(){super(Ci(no.getDefaults(),arguments,["delayTime","resonance","dampening"])),this.name="LowpassCombFilter";const t=Ci(no.getDefaults(),arguments,["delayTime","resonance","dampening"]);this._combFilter=this.output=new to({context:this.context,delayTime:t.delayTime,resonance:t.resonance}),this.delayTime=this._combFilter.delayTime,this.resonance=this._combFilter.resonance,this._lowpass=this.input=new eo({context:this.context,frequency:t.dampening,type:"lowpass"}),this._lowpass.connect(this._combFilter)}static getDefaults(){return Object.assign(vs.getDefaults(),{dampening:3e3,delayTime:.1,resonance:.5})}get dampening(){return this._lowpass.frequency}set dampening(t){this._lowpass.frequency=t}dispose(){return super.dispose(),this._combFilter.dispose(),this._lowpass.dispose(),this}}class ro extends Da{constructor(){super(Ci(ro.getDefaults(),arguments)),this.name="PluckSynth";const t=Ci(ro.getDefaults(),arguments);this._noise=new Xs({context:this.context,type:"pink"}),this.attackNoise=t.attackNoise,this._lfcf=new no({context:this.context,dampening:t.dampening,resonance:t.resonance}),this.resonance=t.resonance,this.release=t.release,this._noise.connect(this._lfcf),this._lfcf.connect(this.output)}static getDefaults(){return Ti(Da.getDefaults(),{attackNoise:1,dampening:4e3,resonance:.7,release:1})}get dampening(){return this._lfcf.dampening}set dampening(t){this._lfcf.dampening=t}triggerAttack(t,e){const n=this.toFrequency(t);e=this.toSeconds(e);const r=1/n;return this._lfcf.delayTime.setValueAtTime(r,e),this._noise.start(e),this._noise.stop(e+r*this.attackNoise),this._lfcf.resonance.cancelScheduledValues(e),this._lfcf.resonance.setValueAtTime(this.resonance,e),this}triggerRelease(t){return this._lfcf.resonance.linearRampTo(0,this.release,t),this}dispose(){return super.dispose(),this._noise.dispose(),this._lfcf.dispose(),this}}class io extends Da{constructor(){super(Ci(io.getDefaults(),arguments,["voice","options"])),this.name="PolySynth",this._availableVoices=[],this._activeVoices=[],this._voices=[],this._gcTimeout=-1,this._averageActiveVoices=0;const t=Ci(io.getDefaults(),arguments,["voice","options"]);Zr(!ci(t.voice),"DEPRECATED: The polyphony count is no longer the first argument.");const e=t.voice.getDefaults();this.options=Object.assign(e,t.options),this.voice=t.voice,this.maxPolyphony=t.maxPolyphony,this._dummyVoice=this._getNextAvailableVoice();const n=this._voices.indexOf(this._dummyVoice);this._voices.splice(n,1),this._gcTimeout=this.context.setInterval(this._collectGarbage.bind(this),1)}static getDefaults(){return Object.assign(Da.getDefaults(),{maxPolyphony:32,options:{},voice:Fa})}get activeVoices(){return this._activeVoices.length}_makeVoiceAvailable(t){this._availableVoices.push(t);const e=this._activeVoices.findIndex(e=>e.voice===t);this._activeVoices.splice(e,1)}_getNextAvailableVoice(){if(this._availableVoices.length)return this._availableVoices.shift();if(this._voices.length<this.maxPolyphony){const t=new this.voice(Object.assign(this.options,{context:this.context,onsilence:this._makeVoiceAvailable.bind(this)}));return t.connect(this.output),this._voices.push(t),t}si("Max polyphony exceeded. Note dropped.")}_collectGarbage(){if(this._averageActiveVoices=Math.max(.95*this._averageActiveVoices,this.activeVoices),this._availableVoices.length&&this._voices.length>Math.ceil(this._averageActiveVoices+1)){const t=this._availableVoices.shift(),e=this._voices.indexOf(t);this._voices.splice(e,1),this.context.isOffline||t.dispose()}}_triggerAttack(t,e,n){t.forEach(t=>{const r=new Rs(this.context,t).toMidi(),i=this._getNextAvailableVoice();i&&(i.triggerAttack(t,e,n),this._activeVoices.push({midi:r,voice:i,released:!1}),this.log("triggerAttack",t,e))})}_triggerRelease(t,e){t.forEach(t=>{const n=new Rs(this.context,t).toMidi(),r=this._activeVoices.find(({midi:t,released:e})=>t===n&&!e);r&&(r.voice.triggerRelease(e),r.released=!0,this.log("triggerRelease",t,e))})}_scheduleEvent(t,e,n,r){Zr(!this.disposed,"Synth was already disposed"),n<=this.now()?"attack"===t?this._triggerAttack(e,n,r):this._triggerRelease(e,n):this.context.setTimeout(()=>{this._scheduleEvent(t,e,n,r)},n-this.now())}triggerAttack(t,e,n){Array.isArray(t)||(t=[t]);const r=this.toSeconds(e);return this._scheduleEvent("attack",t,r,n),this}triggerRelease(t,e){Array.isArray(t)||(t=[t]);const n=this.toSeconds(e);return this._scheduleEvent("release",t,n),this}triggerAttackRelease(t,e,n,r){const i=this.toSeconds(n);if(this.triggerAttack(t,i,r),di(e)){Zr(di(t),"If the duration is an array, the notes must also be an array"),t=t;for(let n=0;n<t.length;n++){const r=e[Math.min(n,e.length-1)],s=this.toSeconds(r);Zr(s>0,"The duration must be greater than 0"),this.triggerRelease(t[n],i+s)}}else{const n=this.toSeconds(e);Zr(n>0,"The duration must be greater than 0"),this.triggerRelease(t,i+n)}return this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}set(t){const e=Ni(t,["onsilence","context"]);return this.options=Ti(this.options,e),this._voices.forEach(t=>t.set(e)),this._dummyVoice.set(e),this}get(){return this._dummyVoice.get()}releaseAll(t){const e=this.toSeconds(t);return this._activeVoices.forEach(({voice:t})=>{t.triggerRelease(e)}),this}dispose(){return super.dispose(),this._dummyVoice.dispose(),this._voices.forEach(t=>t.dispose()),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this}}class so extends Da{constructor(){super(Ci(so.getDefaults(),arguments,["urls","onload","baseUrl"],"urls")),this.name="Sampler",this._activeSources=new Map;const t=Ci(so.getDefaults(),arguments,["urls","onload","baseUrl"],"urls"),e={};Object.keys(t.urls).forEach(n=>{const r=parseInt(n,10);if(Zr(fi(n)||ci(r)&&isFinite(r),"url key is neither a note or midi pitch: "+n),fi(n)){const r=new ls(this.context,n).toMidi();e[r]=t.urls[n]}else ci(r)&&isFinite(r)&&(e[r]=t.urls[r])}),this._buffers=new Ds({urls:e,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.attack=t.attack,this.release=t.release,this.curve=t.curve,this._buffers.loaded&&Promise.resolve().then(t.onload)}static getDefaults(){return Object.assign(Da.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:Gi,onerror:Gi,release:.1,urls:{}})}_findClosest(t){let e=0;for(;e<96;){if(this._buffers.has(t+e))return-e;if(this._buffers.has(t-e))return e;e++}throw new Error("No available buffers for note: "+t)}triggerAttack(t,e,n=1){return this.log("triggerAttack",t,e,n),Array.isArray(t)||(t=[t]),t.forEach(t=>{const r=ss(new ls(this.context,t).toFrequency()),i=Math.round(r),s=r-i,a=this._findClosest(i),o=i-a,u=this._buffers.get(o),c=ns(a+s),l=new Qs({url:u,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:c}).connect(this.output);l.start(e,0,u.duration/c,n),di(this._activeSources.get(i))||this._activeSources.set(i,[]),this._activeSources.get(i).push(l),l.onended=()=>{if(this._activeSources&&this._activeSources.has(i)){const t=this._activeSources.get(i),e=t.indexOf(l);-1!==e&&t.splice(e,1)}}}),this}triggerRelease(t,e){return this.log("triggerRelease",t,e),Array.isArray(t)||(t=[t]),t.forEach(t=>{const n=new ls(this.context,t).toMidi();if(this._activeSources.has(n)&&this._activeSources.get(n).length){const t=this._activeSources.get(n);e=this.toSeconds(e),t.forEach(t=>{t.stop(e)}),this._activeSources.set(n,[])}}),this}releaseAll(t){const e=this.toSeconds(t);return this._activeSources.forEach(t=>{for(;t.length;){t.shift().stop(e)}}),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(t,e,n,r=1){const i=this.toSeconds(n);return this.triggerAttack(t,i,r),di(e)?(Zr(di(t),"notes must be an array when duration is array"),t.forEach((t,n)=>{const r=e[Math.min(n,e.length-1)];this.triggerRelease(t,i+this.toSeconds(r))})):this.triggerRelease(t,i+this.toSeconds(e)),this}add(t,e,n){if(Zr(fi(t)||isFinite(t),"note must be a pitch or midi: "+t),fi(t)){const r=new ls(this.context,t).toMidi();this._buffers.add(r,e,n)}else this._buffers.add(t,e,n);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach(t=>{t.forEach(t=>t.dispose())}),this._activeSources.clear(),this}}bi([va(0)],so.prototype,"attack",void 0),bi([va(0)],so.prototype,"release",void 0);class ao extends gs{constructor(){super(Ci(ao.getDefaults(),arguments,["callback","value"])),this.name="ToneEvent",this._state=new bs("stopped"),this._startOffset=0;const t=Ci(ao.getDefaults(),arguments,["callback","value"]);this._loop=t.loop,this.callback=t.callback,this.value=t.value,this._loopStart=this.toTicks(t.loopStart),this._loopEnd=this.toTicks(t.loopEnd),this._playbackRate=t.playbackRate,this._probability=t.probability,this._humanize=t.humanize,this.mute=t.mute,this._playbackRate=t.playbackRate,this._state.increasing=!0,this._rescheduleEvents()}static getDefaults(){return Object.assign(gs.getDefaults(),{callback:Gi,humanize:!1,loop:!1,loopEnd:"1m",loopStart:0,mute:!1,playbackRate:1,probability:1,value:null})}_rescheduleEvents(t=-1){this._state.forEachFrom(t,t=>{let e;if("started"===t.state){-1!==t.id&&this.context.transport.clear(t.id);const n=t.time+Math.round(this.startOffset/this._playbackRate);if(!0===this._loop||ci(this._loop)&&this._loop>1){e=1/0,ci(this._loop)&&(e=this._loop*this._getLoopDuration());const r=this._state.getAfter(n);null!==r&&(e=Math.min(e,r.time-n)),e!==1/0&&(this._state.setStateAtTime("stopped",n+e+1,{id:-1}),e=new Fs(this.context,e));const i=new Fs(this.context,this._getLoopDuration());t.id=this.context.transport.scheduleRepeat(this._tick.bind(this),i,new Fs(this.context,n),e)}else t.id=this.context.transport.schedule(this._tick.bind(this),new Fs(this.context,n))}})}get state(){return this._state.getValueAtTime(this.context.transport.ticks)}get startOffset(){return this._startOffset}set startOffset(t){this._startOffset=t}get probability(){return this._probability}set probability(t){this._probability=t}get humanize(){return this._humanize}set humanize(t){this._humanize=t}start(t){const e=this.toTicks(t);return"stopped"===this._state.getValueAtTime(e)&&(this._state.add({id:-1,state:"started",time:e}),this._rescheduleEvents(e)),this}stop(t){this.cancel(t);const e=this.toTicks(t);if("started"===this._state.getValueAtTime(e)){this._state.setStateAtTime("stopped",e,{id:-1});const t=this._state.getBefore(e);let n=e;null!==t&&(n=t.time),this._rescheduleEvents(n)}return this}cancel(t){t=Ai(t,-1/0);const e=this.toTicks(t);return this._state.forEachFrom(e,t=>{this.context.transport.clear(t.id)}),this._state.cancel(e),this}_tick(t){const e=this.context.transport.getTicksAtTime(t);if(!this.mute&&"started"===this._state.getValueAtTime(e)){if(this.probability<1&&Math.random()>this.probability)return;if(this.humanize){let e=.02;hi(this.humanize)||(e=this.toSeconds(this.humanize)),t+=(2*Math.random()-1)*e}this.callback(t,this.value)}}_getLoopDuration(){return Math.round((this._loopEnd-this._loopStart)/this._playbackRate)}get loop(){return this._loop}set loop(t){this._loop=t,this._rescheduleEvents()}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._rescheduleEvents()}get loopEnd(){return new Fs(this.context,this._loopEnd).toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t),this._loop&&this._rescheduleEvents()}get loopStart(){return new Fs(this.context,this._loopStart).toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t),this._loop&&this._rescheduleEvents()}get progress(){if(this._loop){const t=this.context.transport.ticks,e=this._state.get(t);if(null!==e&&"started"===e.state){const n=this._getLoopDuration();return(t-e.time)%n/n}return 0}return 0}dispose(){return super.dispose(),this.cancel(),this._state.dispose(),this}}class oo extends gs{constructor(){super(Ci(oo.getDefaults(),arguments,["callback","interval"])),this.name="Loop";const t=Ci(oo.getDefaults(),arguments,["callback","interval"]);this._event=new ao({context:this.context,callback:this._tick.bind(this),loop:!0,loopEnd:t.interval,playbackRate:t.playbackRate,probability:t.probability}),this.callback=t.callback,this.iterations=t.iterations}static getDefaults(){return Object.assign(gs.getDefaults(),{interval:"4n",callback:Gi,playbackRate:1,iterations:1/0,probability:1,mute:!1,humanize:!1})}start(t){return this._event.start(t),this}stop(t){return this._event.stop(t),this}cancel(t){return this._event.cancel(t),this}_tick(t){this.callback(t)}get state(){return this._event.state}get progress(){return this._event.progress}get interval(){return this._event.loopEnd}set interval(t){this._event.loopEnd=t}get playbackRate(){return this._event.playbackRate}set playbackRate(t){this._event.playbackRate=t}get humanize(){return this._event.humanize}set humanize(t){this._event.humanize=t}get probability(){return this._event.probability}set probability(t){this._event.probability=t}get mute(){return this._event.mute}set mute(t){this._event.mute=t}get iterations(){return!0===this._event.loop?1/0:this._event.loop}set iterations(t){this._event.loop=t===1/0||t}dispose(){return super.dispose(),this._event.dispose(),this}}class uo extends ao{constructor(){super(Ci(uo.getDefaults(),arguments,["callback","events"])),this.name="Part",this._state=new bs("stopped"),this._events=new Set;const t=Ci(uo.getDefaults(),arguments,["callback","events"]);this._state.increasing=!0,t.events.forEach(t=>{di(t)?this.add(t[0],t[1]):this.add(t)})}static getDefaults(){return Object.assign(ao.getDefaults(),{events:[]})}start(t,e){const n=this.toTicks(t);if("started"!==this._state.getValueAtTime(n)){e=Ai(e,this._loop?this._loopStart:0),e=this._loop?Ai(e,this._loopStart):Ai(e,0);const t=this.toTicks(e);this._state.add({id:-1,offset:t,state:"started",time:n}),this._forEach(e=>{this._startNote(e,n,t)})}return this}_startNote(t,e,n){e-=n,this._loop?t.startOffset>=this._loopStart&&t.startOffset<this._loopEnd?(t.startOffset<n&&(e+=this._getLoopDuration()),t.start(new Fs(this.context,e))):t.startOffset<this._loopStart&&t.startOffset>=n&&(t.loop=!1,t.start(new Fs(this.context,e))):t.startOffset>=n&&t.start(new Fs(this.context,e))}get startOffset(){return this._startOffset}set startOffset(t){this._startOffset=t,this._forEach(t=>{t.startOffset+=this._startOffset})}stop(t){const e=this.toTicks(t);return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._forEach(e=>{e.stop(t)}),this}at(t,e){const n=new fs(this.context,t).toTicks(),r=new Fs(this.context,1).toSeconds(),i=this._events.values();let s=i.next();for(;!s.done;){const t=s.value;if(Math.abs(n-t.startOffset)<r)return oi(e)&&(t.value=e),t;s=i.next()}return oi(e)?(this.add(t,e),this.at(t)):null}add(t,e){t instanceof Object&&Reflect.has(t,"time")&&(t=(e=t).time);const n=this.toTicks(t);let r;return e instanceof ao?(r=e,r.callback=this._tick.bind(this)):r=new ao({callback:this._tick.bind(this),context:this.context,value:e}),r.startOffset=n,r.set({humanize:this.humanize,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,playbackRate:this.playbackRate,probability:this.probability}),this._events.add(r),this._restartEvent(r),this}_restartEvent(t){this._state.forEach(e=>{"started"===e.state?this._startNote(t,e.time,e.offset):t.stop(new Fs(this.context,e.time))})}remove(t,e){return li(t)&&t.hasOwnProperty("time")&&(t=(e=t).time),t=this.toTicks(t),this._events.forEach(n=>{n.startOffset===t&&(ai(e)||oi(e)&&n.value===e)&&(this._events.delete(n),n.dispose())}),this}clear(){return this._forEach(t=>t.dispose()),this._events.clear(),this}cancel(t){return this._forEach(e=>e.cancel(t)),this._state.cancel(this.toTicks(t)),this}_forEach(t){return this._events&&this._events.forEach(e=>{e instanceof uo?e._forEach(t):t(e)}),this}_setAll(t,e){this._forEach(n=>{n[t]=e})}_tick(t,e){this.mute||this.callback(t,e)}_testLoopBoundries(t){this._loop&&(t.startOffset<this._loopStart||t.startOffset>=this._loopEnd)?t.cancel(0):"stopped"===t.state&&this._restartEvent(t)}get probability(){return this._probability}set probability(t){this._probability=t,this._setAll("probability",t)}get humanize(){return this._humanize}set humanize(t){this._humanize=t,this._setAll("humanize",t)}get loop(){return this._loop}set loop(t){this._loop=t,this._forEach(e=>{e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.loop=t,this._testLoopBoundries(e)})}get loopEnd(){return new Fs(this.context,this._loopEnd).toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t),this._loop&&this._forEach(e=>{e.loopEnd=t,this._testLoopBoundries(e)})}get loopStart(){return new Fs(this.context,this._loopStart).toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t),this._loop&&this._forEach(t=>{t.loopStart=this.loopStart,this._testLoopBoundries(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._setAll("playbackRate",t)}get length(){return this._events.size}dispose(){return super.dispose(),this.clear(),this}}function*co(t){let e=0;for(;e<t.length;)e=po(e,t),yield t[e],e++}function*lo(t){let e=t.length-1;for(;e>=0;)e=po(e,t),yield t[e],e--}function*ho(t,e){for(;;)yield*e(t)}function po(t,e){return Ri(t,0,e.length-1)}function*fo(t,e){let n=e?0:t.length-1;for(;;)n=po(n,t),yield t[n],e?(n++,n>=t.length-1&&(e=!1)):(n--,n<=0&&(e=!0))}function*mo(t){let e=0,n=0;for(;e<t.length;)e=po(e,t),yield t[e],n++,e+=n%2?2:-1}function*go(t){let e=t.length-1,n=0;for(;e>=0;)e=po(e,t),yield t[e],n++,e+=n%2?-2:1}function*bo(t){const e=[];for(let n=0;n<t.length;n++)e.push(n);for(;e.length>0;){const n=po(e.splice(Math.floor(e.length*Math.random()),1)[0],t);yield t[n]}}function*yo(t,e="up",n=0){switch(Zr(t.length>0,"The array must have more than one value in it"),e){case"up":yield*ho(t,co);case"down":yield*ho(t,lo);case"upDown":yield*fo(t,!0);case"downUp":yield*fo(t,!1);case"alternateUp":yield*ho(t,mo);case"alternateDown":yield*ho(t,go);case"random":yield*function*(t){for(;;){const e=Math.floor(Math.random()*t.length);yield t[e]}}(t);case"randomOnce":yield*ho(t,bo);case"randomWalk":yield*function*(t){let e=Math.floor(Math.random()*t.length);for(;;)0===e?e++:e===t.length-1||Math.random()<.5?e--:e++,yield t[e]}(t)}}class vo extends oo{constructor(){super(Ci(vo.getDefaults(),arguments,["callback","values","pattern"])),this.name="Pattern";const t=Ci(vo.getDefaults(),arguments,["callback","values","pattern"]);this.callback=t.callback,this._values=t.values,this._pattern=yo(t.values,t.pattern),this._type=t.pattern}static getDefaults(){return Object.assign(oo.getDefaults(),{pattern:"up",values:[],callback:Gi})}_tick(t){const e=this._pattern.next();this._value=e.value,this.callback(t,this._value)}get values(){return this._values}set values(t){this._values=t,this.pattern=this._type}get value(){return this._value}get pattern(){return this._type}set pattern(t){this._type=t,this._pattern=yo(this._values,this._type)}}class wo extends ao{constructor(){super(Ci(wo.getDefaults(),arguments,["callback","events","subdivision"])),this.name="Sequence",this._part=new uo({callback:this._seqCallback.bind(this),context:this.context}),this._events=[],this._eventsArray=[];const t=Ci(wo.getDefaults(),arguments,["callback","events","subdivision"]);this._subdivision=this.toTicks(t.subdivision),this.events=t.events,this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.playbackRate=t.playbackRate,this.probability=t.probability,this.humanize=t.humanize,this.mute=t.mute,this.playbackRate=t.playbackRate}static getDefaults(){return Object.assign(Ni(ao.getDefaults(),["value"]),{events:[],loop:!0,loopEnd:0,loopStart:0,subdivision:"8n"})}_seqCallback(t,e){null!==e&&this.callback(t,e)}get events(){return this._events}set events(t){this.clear(),this._eventsArray=t,this._events=this._createSequence(this._eventsArray),this._eventsUpdated()}start(t,e){return this._part.start(t,e?this._indexTime(e):e),this}stop(t){return this._part.stop(t),this}get subdivision(){return new Fs(this.context,this._subdivision).toSeconds()}_createSequence(t){return new Proxy(t,{get:(t,e)=>t[e],set:(t,e,n)=>(pi(e)&&isFinite(parseInt(e,10))&&di(n)?t[e]=this._createSequence(n):t[e]=n,this._eventsUpdated(),!0)})}_eventsUpdated(){this._part.clear(),this._rescheduleSequence(this._eventsArray,this._subdivision,this.startOffset),this.loopEnd=this.loopEnd}_rescheduleSequence(t,e,n){t.forEach((t,r)=>{const i=r*e+n;if(di(t))this._rescheduleSequence(t,e/t.length,i);else{const e=new Fs(this.context,i,"i").toSeconds();this._part.add(e,t)}})}_indexTime(t){return new Fs(this.context,t*this._subdivision+this.startOffset).toSeconds()}clear(){return this._part.clear(),this}dispose(){return super.dispose(),this._part.dispose(),this}get loop(){return this._part.loop}set loop(t){this._part.loop=t}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this._part.loopStart=this._indexTime(t)}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this._part.loopEnd=0===t?this._indexTime(this._eventsArray.length):this._indexTime(t)}get startOffset(){return this._part.startOffset}set startOffset(t){this._part.startOffset=t}get playbackRate(){return this._part.playbackRate}set playbackRate(t){this._part.playbackRate=t}get probability(){return this._part.probability}set probability(t){this._part.probability=t}get progress(){return this._part.progress}get humanize(){return this._part.humanize}set humanize(t){this._part.humanize=t}get length(){return this._part.length}}class xo extends vs{constructor(){super(Object.assign(Ci(xo.getDefaults(),arguments,["fade"]))),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new Sa({context:this.context}),this.a=new Os({context:this.context,gain:0}),this.b=new Os({context:this.context,gain:0}),this.output=new Os({context:this.context}),this._internalChannels=[this.a,this.b];const t=Ci(xo.getDefaults(),arguments,["fade"]);this.fade=new Ts({context:this.context,units:"normalRange",value:t.fade}),Ui(this,"fade"),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode="explicit",xs(this._split,this.a.gain,0),xs(this._split,this.b.gain,1),this.fade.chain(this._g2a,this._panner.pan),this.a.connect(this.output),this.b.connect(this.output)}static getDefaults(){return Object.assign(vs.getDefaults(),{fade:.5})}dispose(){return super.dispose(),this.a.dispose(),this.b.dispose(),this.output.dispose(),this.fade.dispose(),this._g2a.dispose(),this._panner.disconnect(),this._split.disconnect(),this}}class _o extends vs{constructor(t){super(t),this.name="Effect",this._dryWet=new xo({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new Os({context:this.context}),this.effectReturn=new Os({context:this.context}),this.input=new Os({context:this.context}),this.output=this._dryWet,this.input.fan(this._dryWet.a,this.effectSend),this.effectReturn.connect(this._dryWet.b),this.wet.setValueAtTime(t.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],Ui(this,"wet")}static getDefaults(){return Object.assign(vs.getDefaults(),{wet:1})}connectEffect(t){return this._internalChannels.push(t),this.effectSend.chain(t,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}}class Oo extends _o{constructor(t){super(t),this.name="LFOEffect",this._lfo=new ba({context:this.context,frequency:t.frequency,amplitude:t.depth}),this.depth=this._lfo.amplitude,this.frequency=this._lfo.frequency,this.type=t.type,Ui(this,["frequency","depth"])}static getDefaults(){return Object.assign(_o.getDefaults(),{frequency:1,type:"sine",depth:1})}start(t){return this._lfo.start(t),this}stop(t){return this._lfo.stop(t),this}sync(){return this._lfo.sync(),this}unsync(){return this._lfo.unsync(),this}get type(){return this._lfo.type}set type(t){this._lfo.type=t}dispose(){return super.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class So extends Oo{constructor(){super(Ci(So.getDefaults(),arguments,["frequency","baseFrequency","octaves"])),this.name="AutoFilter";const t=Ci(So.getDefaults(),arguments,["frequency","baseFrequency","octaves"]);this.filter=new Ba(Object.assign(t.filter,{context:this.context})),this.connectEffect(this.filter),this._lfo.connect(this.filter.frequency),this.octaves=t.octaves,this.baseFrequency=t.baseFrequency}static getDefaults(){return Object.assign(Oo.getDefaults(),{baseFrequency:200,octaves:2.6,filter:{type:"lowpass",rolloff:-12,Q:1}})}get baseFrequency(){return this._lfo.min}set baseFrequency(t){this._lfo.min=this.toFrequency(t),this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._lfo.max=this._lfo.min*Math.pow(2,t)}dispose(){return super.dispose(),this.filter.dispose(),this}}class ko extends vs{constructor(){super(Object.assign(Ci(ko.getDefaults(),arguments,["pan"]))),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner;const t=Ci(ko.getDefaults(),arguments,["pan"]);this.pan=new ys({context:this.context,param:this._panner.pan,value:t.pan,minValue:-1,maxValue:1}),this._panner.channelCount=t.channelCount,this._panner.channelCountMode="explicit",Ui(this,"pan")}static getDefaults(){return Object.assign(vs.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}}class To extends Oo{constructor(){super(Ci(To.getDefaults(),arguments,["frequency"])),this.name="AutoPanner";const t=Ci(To.getDefaults(),arguments,["frequency"]);this._panner=new ko({context:this.context,channelCount:t.channelCount}),this.connectEffect(this._panner),this._lfo.connect(this._panner.pan),this._lfo.min=-1,this._lfo.max=1}static getDefaults(){return Object.assign(Oo.getDefaults(),{channelCount:1})}dispose(){return super.dispose(),this._panner.dispose(),this}}class Co extends vs{constructor(){super(Ci(Co.getDefaults(),arguments,["smoothing"])),this.name="Follower";const t=Ci(Co.getDefaults(),arguments,["smoothing"]);this._abs=this.input=new Oa({context:this.context}),this._lowpass=this.output=new eo({context:this.context,frequency:1/this.toSeconds(t.smoothing),type:"lowpass"}),this._abs.connect(this._lowpass),this._smoothing=t.smoothing}static getDefaults(){return Object.assign(vs.getDefaults(),{smoothing:.05})}get smoothing(){return this._smoothing}set smoothing(t){this._smoothing=t,this._lowpass.frequency=1/this.toSeconds(this.smoothing)}dispose(){return super.dispose(),this._abs.dispose(),this._lowpass.dispose(),this}}class Ao extends _o{constructor(){super(Ci(Ao.getDefaults(),arguments,["baseFrequency","octaves","sensitivity"])),this.name="AutoWah";const t=Ci(Ao.getDefaults(),arguments,["baseFrequency","octaves","sensitivity"]);this._follower=new Co({context:this.context,smoothing:t.follower}),this._sweepRange=new Ia({context:this.context,min:0,max:1,exponent:.5}),this._baseFrequency=this.toFrequency(t.baseFrequency),this._octaves=t.octaves,this._inputBoost=new Os({context:this.context}),this._bandpass=new Ba({context:this.context,rolloff:-48,frequency:0,Q:t.Q}),this._peaking=new Ba({context:this.context,type:"peaking"}),this._peaking.gain.value=t.gain,this.gain=this._peaking.gain,this.Q=this._bandpass.Q,this.effectSend.chain(this._inputBoost,this._follower,this._sweepRange),this._sweepRange.connect(this._bandpass.frequency),this._sweepRange.connect(this._peaking.frequency),this.effectSend.chain(this._bandpass,this._peaking,this.effectReturn),this._setSweepRange(),this.sensitivity=t.sensitivity,Ui(this,["gain","Q"])}static getDefaults(){return Object.assign(_o.getDefaults(),{baseFrequency:100,octaves:6,sensitivity:0,Q:2,gain:2,follower:.2})}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._setSweepRange()}get follower(){return this._follower.smoothing}set follower(t){this._follower.smoothing=t}get baseFrequency(){return this._baseFrequency}set baseFrequency(t){this._baseFrequency=this.toFrequency(t),this._setSweepRange()}get sensitivity(){return es(1/this._inputBoost.gain.value)}set sensitivity(t){this._inputBoost.gain.value=1/ts(t)}_setSweepRange(){this._sweepRange.min=this._baseFrequency,this._sweepRange.max=Math.min(this._baseFrequency*Math.pow(2,this._octaves),this.context.sampleRate/2)}dispose(){return super.dispose(),this._follower.dispose(),this._sweepRange.dispose(),this._bandpass.dispose(),this._peaking.dispose(),this._inputBoost.dispose(),this}}Ja("bit-crusher","\n\tclass BitCrusherWorklet extends SingleIOProcessor {\n\n\t\tstatic get parameterDescriptors() {\n\t\t\treturn [{\n\t\t\t\tname: \"bits\",\n\t\t\t\tdefaultValue: 12,\n\t\t\t\tminValue: 1,\n\t\t\t\tmaxValue: 16,\n\t\t\t\tautomationRate: 'k-rate'\n\t\t\t}];\n\t\t}\n\n\t\tgenerate(input, _channel, parameters) {\n\t\t\tconst step = Math.pow(0.5, parameters.bits - 1);\n\t\t\tconst val = step * Math.floor(input / step + 0.5);\n\t\t\treturn val;\n\t\t}\n\t}\n");class No extends _o{constructor(){super(Ci(No.getDefaults(),arguments,["bits"])),this.name="BitCrusher";const t=Ci(No.getDefaults(),arguments,["bits"]);this._bitCrusherWorklet=new Io({context:this.context,bits:t.bits}),this.connectEffect(this._bitCrusherWorklet),this.bits=this._bitCrusherWorklet.bits}static getDefaults(){return Object.assign(_o.getDefaults(),{bits:4})}dispose(){return super.dispose(),this._bitCrusherWorklet.dispose(),this}}class Io extends Za{constructor(){super(Ci(Io.getDefaults(),arguments)),this.name="BitCrusherWorklet";const t=Ci(Io.getDefaults(),arguments);this.input=new Os({context:this.context}),this.output=new Os({context:this.context}),this.bits=new ys({context:this.context,value:t.bits,units:"positive",minValue:1,maxValue:16,param:this._dummyParam,swappable:!0})}static getDefaults(){return Object.assign(Za.getDefaults(),{bits:12})}_audioWorkletName(){return"bit-crusher"}onReady(t){ws(this.input,t,this.output);const e=t.parameters.get("bits");this.bits.setParam(e)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.bits.dispose(),this}}class Eo extends _o{constructor(){super(Ci(Eo.getDefaults(),arguments,["order"])),this.name="Chebyshev";const t=Ci(Eo.getDefaults(),arguments,["order"]);this._shaper=new ia({context:this.context,length:4096}),this._order=t.order,this.connectEffect(this._shaper),this.order=t.order,this.oversample=t.oversample}static getDefaults(){return Object.assign(_o.getDefaults(),{order:1,oversample:"none"})}_getCoefficient(t,e,n){return n.has(e)||(0===e?n.set(e,0):1===e?n.set(e,t):n.set(e,2*t*this._getCoefficient(t,e-1,n)-this._getCoefficient(t,e-2,n))),n.get(e)}get order(){return this._order}set order(t){this._order=t,this._shaper.setMap(e=>this._getCoefficient(e,t,new Map))}get oversample(){return this._shaper.oversample}set oversample(t){this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.dispose(),this}}class jo extends vs{constructor(){super(Ci(jo.getDefaults(),arguments,["channels"])),this.name="Split";const t=Ci(jo.getDefaults(),arguments,["channels"]);this._splitter=this.input=this.output=this.context.createChannelSplitter(t.channels),this._internalChannels=[this._splitter]}static getDefaults(){return Object.assign(vs.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._splitter.disconnect(),this}}class Mo extends vs{constructor(){super(Ci(Mo.getDefaults(),arguments,["channels"])),this.name="Merge";const t=Ci(Mo.getDefaults(),arguments,["channels"]);this._merger=this.output=this.input=this.context.createChannelMerger(t.channels)}static getDefaults(){return Object.assign(vs.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}}class Do extends vs{constructor(t){super(t),this.name="StereoEffect",this.input=new Os({context:this.context}),this.input.channelCount=2,this.input.channelCountMode="explicit",this._dryWet=this.output=new xo({context:this.context,fade:t.wet}),this.wet=this._dryWet.fade,this._split=new jo({context:this.context,channels:2}),this._merge=new Mo({context:this.context,channels:2}),this.input.connect(this._split),this.input.connect(this._dryWet.a),this._merge.connect(this._dryWet.b),Ui(this,["wet"])}connectEffectLeft(...t){this._split.connect(t[0],0,0),ws(...t),xs(t[t.length-1],this._merge,0,0)}connectEffectRight(...t){this._split.connect(t[0],1,0),ws(...t),xs(t[t.length-1],this._merge,0,1)}static getDefaults(){return Object.assign(vs.getDefaults(),{wet:1})}dispose(){return super.dispose(),this._dryWet.dispose(),this._split.dispose(),this._merge.dispose(),this}}class Ro extends Do{constructor(t){super(t),this.feedback=new Ts({context:this.context,value:t.feedback,units:"normalRange"}),this._feedbackL=new Os({context:this.context}),this._feedbackR=new Os({context:this.context}),this._feedbackSplit=new jo({context:this.context,channels:2}),this._feedbackMerge=new Mo({context:this.context,channels:2}),this._merge.connect(this._feedbackSplit),this._feedbackMerge.connect(this._split),this._feedbackSplit.connect(this._feedbackL,0,0),this._feedbackL.connect(this._feedbackMerge,0,0),this._feedbackSplit.connect(this._feedbackR,1,0),this._feedbackR.connect(this._feedbackMerge,0,1),this.feedback.fan(this._feedbackL.gain,this._feedbackR.gain),Ui(this,["feedback"])}static getDefaults(){return Object.assign(Do.getDefaults(),{feedback:.5})}dispose(){return super.dispose(),this.feedback.dispose(),this._feedbackL.dispose(),this._feedbackR.dispose(),this._feedbackSplit.dispose(),this._feedbackMerge.dispose(),this}}class Po extends Ro{constructor(){super(Ci(Po.getDefaults(),arguments,["frequency","delayTime","depth"])),this.name="Chorus";const t=Ci(Po.getDefaults(),arguments,["frequency","delayTime","depth"]);this._depth=t.depth,this._delayTime=t.delayTime/1e3,this._lfoL=new ba({context:this.context,frequency:t.frequency,min:0,max:1}),this._lfoR=new ba({context:this.context,frequency:t.frequency,min:0,max:1,phase:180}),this._delayNodeL=new js({context:this.context}),this._delayNodeR=new js({context:this.context}),this.frequency=this._lfoL.frequency,Ui(this,["frequency"]),this._lfoL.frequency.connect(this._lfoR.frequency),this.connectEffectLeft(this._delayNodeL),this.connectEffectRight(this._delayNodeR),this._lfoL.connect(this._delayNodeL.delayTime),this._lfoR.connect(this._delayNodeR.delayTime),this.depth=this._depth,this.type=t.type,this.spread=t.spread}static getDefaults(){return Object.assign(Ro.getDefaults(),{frequency:1.5,delayTime:3.5,depth:.7,type:"sine",spread:180,feedback:0,wet:.5})}get depth(){return this._depth}set depth(t){this._depth=t;const e=this._delayTime*t;this._lfoL.min=Math.max(this._delayTime-e,0),this._lfoL.max=this._delayTime+e,this._lfoR.min=Math.max(this._delayTime-e,0),this._lfoR.max=this._delayTime+e}get delayTime(){return 1e3*this._delayTime}set delayTime(t){this._delayTime=t/1e3,this.depth=this._depth}get type(){return this._lfoL.type}set type(t){this._lfoL.type=t,this._lfoR.type=t}get spread(){return this._lfoR.phase-this._lfoL.phase}set spread(t){this._lfoL.phase=90-t/2,this._lfoR.phase=t/2+90}start(t){return this._lfoL.start(t),this._lfoR.start(t),this}stop(t){return this._lfoL.stop(t),this._lfoR.stop(t),this}sync(){return this._lfoL.sync(),this._lfoR.sync(),this}unsync(){return this._lfoL.unsync(),this._lfoR.unsync(),this}dispose(){return super.dispose(),this._lfoL.dispose(),this._lfoR.dispose(),this._delayNodeL.dispose(),this._delayNodeR.dispose(),this.frequency.dispose(),this}}class Fo extends _o{constructor(){super(Ci(Fo.getDefaults(),arguments,["distortion"])),this.name="Distortion";const t=Ci(Fo.getDefaults(),arguments,["distortion"]);this._shaper=new ia({context:this.context,length:4096}),this._distortion=t.distortion,this.connectEffect(this._shaper),this.distortion=t.distortion,this.oversample=t.oversample}static getDefaults(){return Object.assign(_o.getDefaults(),{distortion:.4,oversample:"none"})}get distortion(){return this._distortion}set distortion(t){this._distortion=t;const e=100*t,n=Math.PI/180;this._shaper.setMap(t=>Math.abs(t)<.001?0:(3+e)*t*20*n/(Math.PI+e*Math.abs(t)))}get oversample(){return this._shaper.oversample}set oversample(t){this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.dispose(),this}}class zo extends _o{constructor(t){super(t),this.name="FeedbackEffect",this._feedbackGain=new Os({context:this.context,gain:t.feedback,units:"normalRange"}),this.feedback=this._feedbackGain.gain,Ui(this,"feedback"),this.effectReturn.chain(this._feedbackGain,this.effectSend)}static getDefaults(){return Object.assign(_o.getDefaults(),{feedback:.125})}dispose(){return super.dispose(),this._feedbackGain.dispose(),this.feedback.dispose(),this}}class Lo extends zo{constructor(){super(Ci(Lo.getDefaults(),arguments,["delayTime","feedback"])),this.name="FeedbackDelay";const t=Ci(Lo.getDefaults(),arguments,["delayTime","feedback"]);this._delayNode=new js({context:this.context,delayTime:t.delayTime,maxDelay:t.maxDelay}),this.delayTime=this._delayNode.delayTime,this.connectEffect(this._delayNode),Ui(this,"delayTime")}static getDefaults(){return Object.assign(zo.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._delayNode.dispose(),this.delayTime.dispose(),this}}class $o extends vs{constructor(t){super(t),this.name="PhaseShiftAllpass",this.input=new Os({context:this.context}),this.output=new Os({context:this.context}),this.offset90=new Os({context:this.context});this._bank0=this._createAllPassFilterBank([.6923878,.9360654322959,.988229522686,.9987488452737]),this._bank1=this._createAllPassFilterBank([.4021921162426,.856171088242,.9722909545651,.9952884791278]),this._oneSampleDelay=this.context.createIIRFilter([0,1],[1,0]),ws(this.input,...this._bank0,this._oneSampleDelay,this.output),ws(this.input,...this._bank1,this.offset90)}_createAllPassFilterBank(t){return t.map(t=>{const e=[[t*t,0,-1],[1,0,-t*t]];return this.context.createIIRFilter(e[0],e[1])})}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.offset90.dispose(),this._bank0.forEach(t=>t.disconnect()),this._bank1.forEach(t=>t.disconnect()),this._oneSampleDelay.disconnect(),this}}class Bo extends _o{constructor(){super(Ci(Bo.getDefaults(),arguments,["frequency"])),this.name="FrequencyShifter";const t=Ci(Bo.getDefaults(),arguments,["frequency"]);this.frequency=new Ts({context:this.context,units:"frequency",value:t.frequency,minValue:-this.context.sampleRate/2,maxValue:this.context.sampleRate/2}),this._sine=new ea({context:this.context,type:"sine"}),this._cosine=new na({context:this.context,phase:-90,type:"sine"}),this._sineMultiply=new aa({context:this.context}),this._cosineMultiply=new aa({context:this.context}),this._negate=new ka({context:this.context}),this._add=new fa({context:this.context}),this._phaseShifter=new $o({context:this.context}),this.effectSend.connect(this._phaseShifter),this.frequency.fan(this._sine.frequency,this._cosine.frequency),this._phaseShifter.offset90.connect(this._cosineMultiply),this._cosine.connect(this._cosineMultiply.factor),this._phaseShifter.connect(this._sineMultiply),this._sine.connect(this._sineMultiply.factor),this._sineMultiply.connect(this._negate),this._cosineMultiply.connect(this._add),this._negate.connect(this._add.addend),this._add.connect(this.effectReturn);const e=this.immediate();this._sine.start(e),this._cosine.start(e)}static getDefaults(){return Object.assign(_o.getDefaults(),{frequency:0})}dispose(){return super.dispose(),this.frequency.dispose(),this._add.dispose(),this._cosine.dispose(),this._cosineMultiply.dispose(),this._negate.dispose(),this._phaseShifter.dispose(),this._sine.dispose(),this._sineMultiply.dispose(),this}}const qo=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100],Vo=[225,556,441,341];class Uo extends Do{constructor(){super(Ci(Uo.getDefaults(),arguments,["roomSize","dampening"])),this.name="Freeverb",this._combFilters=[],this._allpassFiltersL=[],this._allpassFiltersR=[];const t=Ci(Uo.getDefaults(),arguments,["roomSize","dampening"]);this.roomSize=new Ts({context:this.context,value:t.roomSize,units:"normalRange"}),this._allpassFiltersL=Vo.map(t=>{const e=this.context.createBiquadFilter();return e.type="allpass",e.frequency.value=t,e}),this._allpassFiltersR=Vo.map(t=>{const e=this.context.createBiquadFilter();return e.type="allpass",e.frequency.value=t,e}),this._combFilters=qo.map((e,n)=>{const r=new no({context:this.context,dampening:t.dampening,delayTime:e});return n<qo.length/2?this.connectEffectLeft(r,...this._allpassFiltersL):this.connectEffectRight(r,...this._allpassFiltersR),this.roomSize.connect(r.resonance),r}),Ui(this,["roomSize"])}static getDefaults(){return Object.assign(Do.getDefaults(),{roomSize:.7,dampening:3e3})}get dampening(){return this._combFilters[0].dampening}set dampening(t){this._combFilters.forEach(e=>e.dampening=t)}dispose(){return super.dispose(),this._allpassFiltersL.forEach(t=>t.disconnect()),this._allpassFiltersR.forEach(t=>t.disconnect()),this._combFilters.forEach(t=>t.dispose()),this.roomSize.dispose(),this}}const Wo=[.06748,.06404,.08212,.09004],Go=[.773,.802,.753,.733],Ho=[347,113,37];class Ko extends Do{constructor(){super(Ci(Ko.getDefaults(),arguments,["roomSize"])),this.name="JCReverb",this._allpassFilters=[],this._feedbackCombFilters=[];const t=Ci(Ko.getDefaults(),arguments,["roomSize"]);this.roomSize=new Ts({context:this.context,value:t.roomSize,units:"normalRange"}),this._scaleRoomSize=new ma({context:this.context,min:-.733,max:.197}),this._allpassFilters=Ho.map(t=>{const e=this.context.createBiquadFilter();return e.type="allpass",e.frequency.value=t,e}),this._feedbackCombFilters=Wo.map((t,e)=>{const n=new to({context:this.context,delayTime:t});return this._scaleRoomSize.connect(n.resonance),n.resonance.value=Go[e],e<Wo.length/2?this.connectEffectLeft(...this._allpassFilters,n):this.connectEffectRight(...this._allpassFilters,n),n}),this.roomSize.connect(this._scaleRoomSize),Ui(this,["roomSize"])}static getDefaults(){return Object.assign(Do.getDefaults(),{roomSize:.5})}dispose(){return super.dispose(),this._allpassFilters.forEach(t=>t.disconnect()),this._feedbackCombFilters.forEach(t=>t.dispose()),this.roomSize.dispose(),this._scaleRoomSize.dispose(),this}}class Qo extends Ro{constructor(t){super(t),this._feedbackL.disconnect(),this._feedbackL.connect(this._feedbackMerge,0,1),this._feedbackR.disconnect(),this._feedbackR.connect(this._feedbackMerge,0,0),Ui(this,["feedback"])}}class Xo extends Qo{constructor(){super(Ci(Xo.getDefaults(),arguments,["delayTime","feedback"])),this.name="PingPongDelay";const t=Ci(Xo.getDefaults(),arguments,["delayTime","feedback"]);this._leftDelay=new js({context:this.context,maxDelay:t.maxDelay}),this._rightDelay=new js({context:this.context,maxDelay:t.maxDelay}),this._rightPreDelay=new js({context:this.context,maxDelay:t.maxDelay}),this.delayTime=new Ts({context:this.context,units:"time",value:t.delayTime}),this.connectEffectLeft(this._leftDelay),this.connectEffectRight(this._rightPreDelay,this._rightDelay),this.delayTime.fan(this._leftDelay.delayTime,this._rightDelay.delayTime,this._rightPreDelay.delayTime),this._feedbackL.disconnect(),this._feedbackL.connect(this._rightDelay),Ui(this,["delayTime"])}static getDefaults(){return Object.assign(Qo.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._leftDelay.dispose(),this._rightDelay.dispose(),this._rightPreDelay.dispose(),this.delayTime.dispose(),this}}class Yo extends zo{constructor(){super(Ci(Yo.getDefaults(),arguments,["pitch"])),this.name="PitchShift";const t=Ci(Yo.getDefaults(),arguments,["pitch"]);this._frequency=new Ts({context:this.context}),this._delayA=new js({maxDelay:1,context:this.context}),this._lfoA=new ba({context:this.context,min:0,max:.1,type:"sawtooth"}).connect(this._delayA.delayTime),this._delayB=new js({maxDelay:1,context:this.context}),this._lfoB=new ba({context:this.context,min:0,max:.1,type:"sawtooth",phase:180}).connect(this._delayB.delayTime),this._crossFade=new xo({context:this.context}),this._crossFadeLFO=new ba({context:this.context,min:0,max:1,type:"triangle",phase:90}).connect(this._crossFade.fade),this._feedbackDelay=new js({delayTime:t.delayTime,context:this.context}),this.delayTime=this._feedbackDelay.delayTime,Ui(this,"delayTime"),this._pitch=t.pitch,this._windowSize=t.windowSize,this._delayA.connect(this._crossFade.a),this._delayB.connect(this._crossFade.b),this._frequency.fan(this._lfoA.frequency,this._lfoB.frequency,this._crossFadeLFO.frequency),this.effectSend.fan(this._delayA,this._delayB),this._crossFade.chain(this._feedbackDelay,this.effectReturn);const e=this.now();this._lfoA.start(e),this._lfoB.start(e),this._crossFadeLFO.start(e),this.windowSize=this._windowSize}static getDefaults(){return Object.assign(zo.getDefaults(),{pitch:0,windowSize:.1,delayTime:0,feedback:0})}get pitch(){return this._pitch}set pitch(t){this._pitch=t;let e=0;t<0?(this._lfoA.min=0,this._lfoA.max=this._windowSize,this._lfoB.min=0,this._lfoB.max=this._windowSize,e=ns(t-1)+1):(this._lfoA.min=this._windowSize,this._lfoA.max=0,this._lfoB.min=this._windowSize,this._lfoB.max=0,e=ns(t)-1),this._frequency.value=e*(1.2/this._windowSize)}get windowSize(){return this._windowSize}set windowSize(t){this._windowSize=this.toSeconds(t),this.pitch=this._pitch}dispose(){return super.dispose(),this._frequency.dispose(),this._delayA.dispose(),this._delayB.dispose(),this._lfoA.dispose(),this._lfoB.dispose(),this._crossFade.dispose(),this._crossFadeLFO.dispose(),this._feedbackDelay.dispose(),this}}class Jo extends Do{constructor(){super(Ci(Jo.getDefaults(),arguments,["frequency","octaves","baseFrequency"])),this.name="Phaser";const t=Ci(Jo.getDefaults(),arguments,["frequency","octaves","baseFrequency"]);this._lfoL=new ba({context:this.context,frequency:t.frequency,min:0,max:1}),this._lfoR=new ba({context:this.context,frequency:t.frequency,min:0,max:1,phase:180}),this._baseFrequency=this.toFrequency(t.baseFrequency),this._octaves=t.octaves,this.Q=new Ts({context:this.context,value:t.Q,units:"positive"}),this._filtersL=this._makeFilters(t.stages,this._lfoL),this._filtersR=this._makeFilters(t.stages,this._lfoR),this.frequency=this._lfoL.frequency,this.frequency.value=t.frequency,this.connectEffectLeft(...this._filtersL),this.connectEffectRight(...this._filtersR),this._lfoL.frequency.connect(this._lfoR.frequency),this.baseFrequency=t.baseFrequency,this.octaves=t.octaves,this._lfoL.start(),this._lfoR.start(),Ui(this,["frequency","Q"])}static getDefaults(){return Object.assign(Do.getDefaults(),{frequency:.5,octaves:3,stages:10,Q:10,baseFrequency:350})}_makeFilters(t,e){const n=[];for(let r=0;r<t;r++){const t=this.context.createBiquadFilter();t.type="allpass",this.Q.connect(t.Q),e.connect(t.frequency),n.push(t)}return n}get octaves(){return this._octaves}set octaves(t){this._octaves=t;const e=this._baseFrequency*Math.pow(2,t);this._lfoL.max=e,this._lfoR.max=e}get baseFrequency(){return this._baseFrequency}set baseFrequency(t){this._baseFrequency=this.toFrequency(t),this._lfoL.min=this._baseFrequency,this._lfoR.min=this._baseFrequency,this.octaves=this._octaves}dispose(){return super.dispose(),this.Q.dispose(),this._lfoL.dispose(),this._lfoR.dispose(),this._filtersL.forEach(t=>t.disconnect()),this._filtersR.forEach(t=>t.disconnect()),this.frequency.dispose(),this}}class Zo extends _o{constructor(){super(Ci(Zo.getDefaults(),arguments,["decay"])),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();const t=Ci(Zo.getDefaults(),arguments,["decay"]);this._decay=t.decay,this._preDelay=t.preDelay,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(_o.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(t){ti(t=this.toSeconds(t),.001),this._decay=t,this.generate()}get preDelay(){return this._preDelay}set preDelay(t){ti(t=this.toSeconds(t),0),this._preDelay=t,this.generate()}generate(){return yi(this,void 0,void 0,(function*(){const t=this.ready,e=new Ki(2,this._decay+this._preDelay,this.context.sampleRate),n=new Xs({context:e}),r=new Xs({context:e}),i=new Mo({context:e});n.connect(i,0,0),r.connect(i,0,1);const s=new Os({context:e}).toDestination();i.connect(s),n.start(0),r.start(0),s.gain.setValueAtTime(0,0),s.gain.setValueAtTime(1,this._preDelay),s.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);const a=e.render();return this.ready=a.then(Gi),yield t,this._convolver.buffer=(yield a).get(),this}))}dispose(){return super.dispose(),this._convolver.disconnect(),this}}class tu extends vs{constructor(){super(Ci(tu.getDefaults(),arguments)),this.name="MidSideSplit",this._split=this.input=new jo({channels:2,context:this.context}),this._midAdd=new fa({context:this.context}),this.mid=new aa({context:this.context,value:Math.SQRT1_2}),this._sideSubtract=new Ta({context:this.context}),this.side=new aa({context:this.context,value:Math.SQRT1_2}),this._split.connect(this._midAdd,0),this._split.connect(this._midAdd.addend,1),this._split.connect(this._sideSubtract,0),this._split.connect(this._sideSubtract.subtrahend,1),this._midAdd.connect(this.mid),this._sideSubtract.connect(this.side)}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._midAdd.dispose(),this._sideSubtract.dispose(),this._split.dispose(),this}}class eu extends vs{constructor(){super(Ci(eu.getDefaults(),arguments)),this.name="MidSideMerge",this.mid=new Os({context:this.context}),this.side=new Os({context:this.context}),this._left=new fa({context:this.context}),this._leftMult=new aa({context:this.context,value:Math.SQRT1_2}),this._right=new Ta({context:this.context}),this._rightMult=new aa({context:this.context,value:Math.SQRT1_2}),this._merge=this.output=new Mo({context:this.context}),this.mid.fan(this._left),this.side.connect(this._left.addend),this.mid.connect(this._right),this.side.connect(this._right.subtrahend),this._left.connect(this._leftMult),this._right.connect(this._rightMult),this._leftMult.connect(this._merge,0,0),this._rightMult.connect(this._merge,0,1)}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._leftMult.dispose(),this._rightMult.dispose(),this._left.dispose(),this._right.dispose(),this}}class nu extends _o{constructor(t){super(t),this.name="MidSideEffect",this._midSideMerge=new eu({context:this.context}),this._midSideSplit=new tu({context:this.context}),this._midSend=this._midSideSplit.mid,this._sideSend=this._midSideSplit.side,this._midReturn=this._midSideMerge.mid,this._sideReturn=this._midSideMerge.side,this.effectSend.connect(this._midSideSplit),this._midSideMerge.connect(this.effectReturn)}connectEffectMid(...t){this._midSend.chain(...t,this._midReturn)}connectEffectSide(...t){this._sideSend.chain(...t,this._sideReturn)}dispose(){return super.dispose(),this._midSideSplit.dispose(),this._midSideMerge.dispose(),this._midSend.dispose(),this._sideSend.dispose(),this._midReturn.dispose(),this._sideReturn.dispose(),this}}class ru extends nu{constructor(){super(Ci(ru.getDefaults(),arguments,["width"])),this.name="StereoWidener";const t=Ci(ru.getDefaults(),arguments,["width"]);this.width=new Ts({context:this.context,value:t.width,units:"normalRange"}),Ui(this,["width"]),this._twoTimesWidthMid=new aa({context:this.context,value:2}),this._twoTimesWidthSide=new aa({context:this.context,value:2}),this._midMult=new aa({context:this.context}),this._twoTimesWidthMid.connect(this._midMult.factor),this.connectEffectMid(this._midMult),this._oneMinusWidth=new Ta({context:this.context}),this._oneMinusWidth.connect(this._twoTimesWidthMid),xs(this.context.getConstant(1),this._oneMinusWidth),this.width.connect(this._oneMinusWidth.subtrahend),this._sideMult=new aa({context:this.context}),this.width.connect(this._twoTimesWidthSide),this._twoTimesWidthSide.connect(this._sideMult.factor),this.connectEffectSide(this._sideMult)}static getDefaults(){return Object.assign(nu.getDefaults(),{width:.5})}dispose(){return super.dispose(),this.width.dispose(),this._midMult.dispose(),this._sideMult.dispose(),this._twoTimesWidthMid.dispose(),this._twoTimesWidthSide.dispose(),this._oneMinusWidth.dispose(),this}}class iu extends Do{constructor(){super(Ci(iu.getDefaults(),arguments,["frequency","depth"])),this.name="Tremolo";const t=Ci(iu.getDefaults(),arguments,["frequency","depth"]);this._lfoL=new ba({context:this.context,type:t.type,min:1,max:0}),this._lfoR=new ba({context:this.context,type:t.type,min:1,max:0}),this._amplitudeL=new Os({context:this.context}),this._amplitudeR=new Os({context:this.context}),this.frequency=new Ts({context:this.context,value:t.frequency,units:"frequency"}),this.depth=new Ts({context:this.context,value:t.depth,units:"normalRange"}),Ui(this,["frequency","depth"]),this.connectEffectLeft(this._amplitudeL),this.connectEffectRight(this._amplitudeR),this._lfoL.connect(this._amplitudeL.gain),this._lfoR.connect(this._amplitudeR.gain),this.frequency.fan(this._lfoL.frequency,this._lfoR.frequency),this.depth.fan(this._lfoR.amplitude,this._lfoL.amplitude),this.spread=t.spread}static getDefaults(){return Object.assign(Do.getDefaults(),{frequency:10,type:"sine",depth:.5,spread:180})}start(t){return this._lfoL.start(t),this._lfoR.start(t),this}stop(t){return this._lfoL.stop(t),this._lfoR.stop(t),this}sync(){return this._lfoL.sync(),this._lfoR.sync(),this.context.transport.syncSignal(this.frequency),this}unsync(){return this._lfoL.unsync(),this._lfoR.unsync(),this.context.transport.unsyncSignal(this.frequency),this}get type(){return this._lfoL.type}set type(t){this._lfoL.type=t,this._lfoR.type=t}get spread(){return this._lfoR.phase-this._lfoL.phase}set spread(t){this._lfoL.phase=90-t/2,this._lfoR.phase=t/2+90}dispose(){return super.dispose(),this._lfoL.dispose(),this._lfoR.dispose(),this._amplitudeL.dispose(),this._amplitudeR.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class su extends _o{constructor(){super(Ci(su.getDefaults(),arguments,["frequency","depth"])),this.name="Vibrato";const t=Ci(su.getDefaults(),arguments,["frequency","depth"]);this._delayNode=new js({context:this.context,delayTime:0,maxDelay:t.maxDelay}),this._lfo=new ba({context:this.context,type:t.type,min:0,max:t.maxDelay,frequency:t.frequency,phase:-90}).start().connect(this._delayNode.delayTime),this.frequency=this._lfo.frequency,this.depth=this._lfo.amplitude,this.depth.value=t.depth,Ui(this,["frequency","depth"]),this.effectSend.chain(this._delayNode,this.effectReturn)}static getDefaults(){return Object.assign(_o.getDefaults(),{maxDelay:.005,frequency:5,depth:.1,type:"sine"})}get type(){return this._lfo.type}set type(t){this._lfo.type=t}dispose(){return super.dispose(),this._delayNode.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class au extends vs{constructor(){super(Ci(au.getDefaults(),arguments,["type","size"])),this.name="Analyser",this._analysers=[],this._buffers=[];const t=Ci(au.getDefaults(),arguments,["type","size"]);this.input=this.output=this._gain=new Os({context:this.context}),this._split=new jo({context:this.context,channels:t.channels}),this.input.connect(this._split),ti(t.channels,1);for(let e=0;e<t.channels;e++)this._analysers[e]=this.context.createAnalyser(),this._split.connect(this._analysers[e],e,0);this.size=t.size,this.type=t.type}static getDefaults(){return Object.assign(vs.getDefaults(),{size:1024,smoothing:.8,type:"fft",channels:1})}getValue(){return this._analysers.forEach((t,e)=>{const n=this._buffers[e];"fft"===this._type?t.getFloatFrequencyData(n):"waveform"===this._type&&t.getFloatTimeDomainData(n)}),1===this.channels?this._buffers[0]:this._buffers}get size(){return this._analysers[0].frequencyBinCount}set size(t){this._analysers.forEach((e,n)=>{e.fftSize=2*t,this._buffers[n]=new Float32Array(t)})}get channels(){return this._analysers.length}get type(){return this._type}set type(t){Zr("waveform"===t||"fft"===t,"Analyser: invalid type: "+t),this._type=t}get smoothing(){return this._analysers[0].smoothingTimeConstant}set smoothing(t){this._analysers.forEach(e=>e.smoothingTimeConstant=t)}dispose(){return super.dispose(),this._analysers.forEach(t=>t.disconnect()),this._split.dispose(),this._gain.dispose(),this}}class ou extends vs{constructor(){super(Ci(ou.getDefaults(),arguments)),this.name="MeterBase",this.input=this.output=this._analyser=new au({context:this.context,size:256,type:"waveform"})}dispose(){return super.dispose(),this._analyser.dispose(),this}}class uu extends ou{constructor(){super(Ci(uu.getDefaults(),arguments,["smoothing"])),this.name="Meter",this._rms=0;const t=Ci(uu.getDefaults(),arguments,["smoothing"]);this.input=this.output=this._analyser=new au({context:this.context,size:256,type:"waveform",channels:t.channels}),this.smoothing=t.smoothing,this.normalRange=t.normalRange}static getDefaults(){return Object.assign(ou.getDefaults(),{smoothing:.8,normalRange:!1,channels:1})}getLevel(){return si("'getLevel' has been changed to 'getValue'"),this.getValue()}getValue(){const t=this._analyser.getValue(),e=(1===this.channels?[t]:t).map(t=>{const e=t.reduce((t,e)=>t+e*e,0),n=Math.sqrt(e/t.length);return this._rms=Math.max(n,this._rms*this.smoothing),this.normalRange?this._rms:es(this._rms)});return 1===this.channels?e[0]:e}get channels(){return this._analyser.channels}dispose(){return super.dispose(),this._analyser.dispose(),this}}class cu extends ou{constructor(){super(Ci(cu.getDefaults(),arguments,["size"])),this.name="FFT";const t=Ci(cu.getDefaults(),arguments,["size"]);this.normalRange=t.normalRange,this._analyser.type="fft",this.size=t.size}static getDefaults(){return Object.assign(vs.getDefaults(),{normalRange:!1,size:1024,smoothing:.8})}getValue(){return this._analyser.getValue().map(t=>this.normalRange?ts(t):t)}get size(){return this._analyser.size}set size(t){this._analyser.size=t}get smoothing(){return this._analyser.smoothing}set smoothing(t){this._analyser.smoothing=t}getFrequencyOfIndex(t){return Zr(0<=t&&t<this.size,"index must be greater than or equal to 0 and less than "+this.size),t*this.context.sampleRate/(2*this.size)}}class lu extends ou{constructor(){super(Ci(lu.getDefaults(),arguments)),this.name="DCMeter",this._analyser.type="waveform",this._analyser.size=256}getValue(){return this._analyser.getValue()[0]}}class hu extends ou{constructor(){super(Ci(hu.getDefaults(),arguments,["size"])),this.name="Waveform";const t=Ci(hu.getDefaults(),arguments,["size"]);this._analyser.type="waveform",this.size=t.size}static getDefaults(){return Object.assign(ou.getDefaults(),{size:1024})}getValue(){return this._analyser.getValue()}get size(){return this._analyser.size}set size(t){this._analyser.size=t}}class du extends vs{constructor(){super(Ci(du.getDefaults(),arguments,["solo"])),this.name="Solo";const t=Ci(du.getDefaults(),arguments,["solo"]);this.input=this.output=new Os({context:this.context}),du._allSolos.has(this.context)||du._allSolos.set(this.context,new Set),du._allSolos.get(this.context).add(this),this.solo=t.solo}static getDefaults(){return Object.assign(vs.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(t){t?this._addSolo():this._removeSolo(),du._allSolos.get(this.context).forEach(t=>t._updateSolo())}get muted(){return 0===this.input.gain.value}_addSolo(){du._soloed.has(this.context)||du._soloed.set(this.context,new Set),du._soloed.get(this.context).add(this)}_removeSolo(){du._soloed.has(this.context)&&du._soloed.get(this.context).delete(this)}_isSoloed(){return du._soloed.has(this.context)&&du._soloed.get(this.context).has(this)}_noSolos(){return!du._soloed.has(this.context)||du._soloed.has(this.context)&&0===du._soloed.get(this.context).size}_updateSolo(){this._isSoloed()||this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),du._allSolos.get(this.context).delete(this),this._removeSolo(),this}}du._allSolos=new Map,du._soloed=new Map;class pu extends vs{constructor(){super(Ci(pu.getDefaults(),arguments,["pan","volume"])),this.name="PanVol";const t=Ci(pu.getDefaults(),arguments,["pan","volume"]);this._panner=this.input=new ko({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new qs({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,Ui(this,["pan","volume"])}static getDefaults(){return Object.assign(vs.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}}class fu extends vs{constructor(){super(Ci(fu.getDefaults(),arguments,["volume","pan"])),this.name="Channel";const t=Ci(fu.getDefaults(),arguments,["volume","pan"]);this._solo=this.input=new du({solo:t.solo,context:this.context}),this._panVol=this.output=new pu({context:this.context,pan:t.pan,volume:t.volume,mute:t.mute,channelCount:t.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),Ui(this,["pan","volume"])}static getDefaults(){return Object.assign(vs.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(t){this._solo.solo=t}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(t){this._panVol.mute=t}_getBus(t){return fu.buses.has(t)||fu.buses.set(t,new Os({context:this.context})),fu.buses.get(t)}send(t,e=0){const n=this._getBus(t),r=new Os({context:this.context,units:"decibels",gain:e});return this.connect(r),r.connect(n),r}receive(t){return this._getBus(t).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}}fu.buses=new Map;class mu extends vs{constructor(){super(Ci(mu.getDefaults(),arguments,["lowFrequency","highFrequency"])),this.name="MultibandSplit",this.input=new Os({context:this.context}),this.output=void 0,this.low=new Ba({context:this.context,frequency:0,type:"lowpass"}),this._lowMidFilter=new Ba({context:this.context,frequency:0,type:"highpass"}),this.mid=new Ba({context:this.context,frequency:0,type:"lowpass"}),this.high=new Ba({context:this.context,frequency:0,type:"highpass"}),this._internalChannels=[this.low,this.mid,this.high];const t=Ci(mu.getDefaults(),arguments,["lowFrequency","highFrequency"]);this.lowFrequency=new Ts({context:this.context,units:"frequency",value:t.lowFrequency}),this.highFrequency=new Ts({context:this.context,units:"frequency",value:t.highFrequency}),this.Q=new Ts({context:this.context,units:"positive",value:t.Q}),this.input.fan(this.low,this.high),this.input.chain(this._lowMidFilter,this.mid),this.lowFrequency.fan(this.low.frequency,this._lowMidFilter.frequency),this.highFrequency.fan(this.mid.frequency,this.high.frequency),this.Q.connect(this.low.Q),this.Q.connect(this._lowMidFilter.Q),this.Q.connect(this.mid.Q),this.Q.connect(this.high.Q),Ui(this,["high","mid","low","highFrequency","lowFrequency"])}static getDefaults(){return Object.assign(vs.getDefaults(),{Q:1,highFrequency:2500,lowFrequency:400})}dispose(){return super.dispose(),Wi(this,["high","mid","low","highFrequency","lowFrequency"]),this.low.dispose(),this._lowMidFilter.dispose(),this.mid.dispose(),this.high.dispose(),this.lowFrequency.dispose(),this.highFrequency.dispose(),this.Q.dispose(),this}}class gu extends vs{constructor(){super(...arguments),this.name="Listener",this.positionX=new ys({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new ys({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new ys({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new ys({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new ys({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new ys({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new ys({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new ys({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new ys({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(vs.getDefaults(),{positionX:0,positionY:0,positionZ:0,forwardX:0,forwardY:0,forwardZ:-1,upX:0,upY:1,upZ:0})}dispose(){return super.dispose(),this.positionX.dispose(),this.positionY.dispose(),this.positionZ.dispose(),this.forwardX.dispose(),this.forwardY.dispose(),this.forwardZ.dispose(),this.upX.dispose(),this.upY.dispose(),this.upZ.dispose(),this}}zi(t=>{t.listener=new gu({context:t})}),$i(t=>{t.listener.dispose()});class bu extends vs{constructor(){super(Ci(bu.getDefaults(),arguments,["positionX","positionY","positionZ"])),this.name="Panner3D";const t=Ci(bu.getDefaults(),arguments,["positionX","positionY","positionZ"]);this._panner=this.input=this.output=this.context.createPanner(),this.panningModel=t.panningModel,this.maxDistance=t.maxDistance,this.distanceModel=t.distanceModel,this.coneOuterGain=t.coneOuterGain,this.coneOuterAngle=t.coneOuterAngle,this.coneInnerAngle=t.coneInnerAngle,this.refDistance=t.refDistance,this.rolloffFactor=t.rolloffFactor,this.positionX=new ys({context:this.context,param:this._panner.positionX,value:t.positionX}),this.positionY=new ys({context:this.context,param:this._panner.positionY,value:t.positionY}),this.positionZ=new ys({context:this.context,param:this._panner.positionZ,value:t.positionZ}),this.orientationX=new ys({context:this.context,param:this._panner.orientationX,value:t.orientationX}),this.orientationY=new ys({context:this.context,param:this._panner.orientationY,value:t.orientationY}),this.orientationZ=new ys({context:this.context,param:this._panner.orientationZ,value:t.orientationZ})}static getDefaults(){return Object.assign(vs.getDefaults(),{coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0,distanceModel:"inverse",maxDistance:1e4,orientationX:0,orientationY:0,orientationZ:0,panningModel:"equalpower",positionX:0,positionY:0,positionZ:0,refDistance:1,rolloffFactor:1})}setPosition(t,e,n){return this.positionX.value=t,this.positionY.value=e,this.positionZ.value=n,this}setOrientation(t,e,n){return this.orientationX.value=t,this.orientationY.value=e,this.orientationZ.value=n,this}get panningModel(){return this._panner.panningModel}set panningModel(t){this._panner.panningModel=t}get refDistance(){return this._panner.refDistance}set refDistance(t){this._panner.refDistance=t}get rolloffFactor(){return this._panner.rolloffFactor}set rolloffFactor(t){this._panner.rolloffFactor=t}get distanceModel(){return this._panner.distanceModel}set distanceModel(t){this._panner.distanceModel=t}get coneInnerAngle(){return this._panner.coneInnerAngle}set coneInnerAngle(t){this._panner.coneInnerAngle=t}get coneOuterAngle(){return this._panner.coneOuterAngle}set coneOuterAngle(t){this._panner.coneOuterAngle=t}get coneOuterGain(){return this._panner.coneOuterGain}set coneOuterGain(t){this._panner.coneOuterGain=t}get maxDistance(){return this._panner.maxDistance}set maxDistance(t){this._panner.maxDistance=t}dispose(){return super.dispose(),this._panner.disconnect(),this.orientationX.dispose(),this.orientationY.dispose(),this.orientationZ.dispose(),this.positionX.dispose(),this.positionY.dispose(),this.positionZ.dispose(),this}}class yu extends vs{constructor(){super(Ci(yu.getDefaults(),arguments)),this.name="Recorder";const t=Ci(yu.getDefaults(),arguments);this.input=new Os({context:this.context}),Zr(yu.supported,"Media Recorder API is not available"),this._stream=this.context.createMediaStreamDestination(),this.input.connect(this._stream),this._recorder=new MediaRecorder(this._stream.stream,{mimeType:t.mimeType})}static getDefaults(){return vs.getDefaults()}get mimeType(){return this._recorder.mimeType}static get supported(){return null!==mi&&Reflect.has(mi,"MediaRecorder")}get state(){return"inactive"===this._recorder.state?"stopped":"paused"===this._recorder.state?"paused":"started"}start(){return yi(this,void 0,void 0,(function*(){Zr("started"!==this.state,"Recorder is already started");const t=new Promise(t=>{const e=()=>{this._recorder.removeEventListener("start",e,!1),t()};this._recorder.addEventListener("start",e,!1)});return this._recorder.start(),yield t}))}stop(){return yi(this,void 0,void 0,(function*(){Zr("stopped"!==this.state,"Recorder is not started");const t=new Promise(t=>{const e=n=>{this._recorder.removeEventListener("dataavailable",e,!1),t(n.data)};this._recorder.addEventListener("dataavailable",e,!1)});return this._recorder.stop(),yield t}))}pause(){return Zr("started"===this.state,"Recorder must be started"),this._recorder.pause(),this}dispose(){return super.dispose(),this.input.dispose(),this._stream.disconnect(),this}}class vu extends vs{constructor(){super(Ci(vu.getDefaults(),arguments,["threshold","ratio"])),this.name="Compressor",this._compressor=this.context.createDynamicsCompressor(),this.input=this._compressor,this.output=this._compressor;const t=Ci(vu.getDefaults(),arguments,["threshold","ratio"]);this.threshold=new ys({minValue:this._compressor.threshold.minValue,maxValue:this._compressor.threshold.maxValue,context:this.context,convert:!1,param:this._compressor.threshold,units:"decibels",value:t.threshold}),this.attack=new ys({minValue:this._compressor.attack.minValue,maxValue:this._compressor.attack.maxValue,context:this.context,param:this._compressor.attack,units:"time",value:t.attack}),this.release=new ys({minValue:this._compressor.release.minValue,maxValue:this._compressor.release.maxValue,context:this.context,param:this._compressor.release,units:"time",value:t.release}),this.knee=new ys({minValue:this._compressor.knee.minValue,maxValue:this._compressor.knee.maxValue,context:this.context,convert:!1,param:this._compressor.knee,units:"decibels",value:t.knee}),this.ratio=new ys({minValue:this._compressor.ratio.minValue,maxValue:this._compressor.ratio.maxValue,context:this.context,convert:!1,param:this._compressor.ratio,units:"positive",value:t.ratio}),Ui(this,["knee","release","attack","ratio","threshold"])}static getDefaults(){return Object.assign(vs.getDefaults(),{attack:.003,knee:30,ratio:12,release:.25,threshold:-24})}get reduction(){return this._compressor.reduction}dispose(){return super.dispose(),this._compressor.disconnect(),this.attack.dispose(),this.release.dispose(),this.threshold.dispose(),this.ratio.dispose(),this.knee.dispose(),this}}class wu extends vs{constructor(){super(Object.assign(Ci(wu.getDefaults(),arguments,["threshold","smoothing"]))),this.name="Gate";const t=Ci(wu.getDefaults(),arguments,["threshold","smoothing"]);this._follower=new Co({context:this.context,smoothing:t.smoothing}),this._gt=new Aa({context:this.context,value:ts(t.threshold)}),this.input=new Os({context:this.context}),this._gate=this.output=new Os({context:this.context}),this.input.connect(this._gate),this.input.chain(this._follower,this._gt,this._gate.gain)}static getDefaults(){return Object.assign(vs.getDefaults(),{smoothing:.1,threshold:-40})}get threshold(){return es(this._gt.value)}set threshold(t){this._gt.value=ts(t)}get smoothing(){return this._follower.smoothing}set smoothing(t){this._follower.smoothing=t}dispose(){return super.dispose(),this.input.dispose(),this._follower.dispose(),this._gt.dispose(),this._gate.dispose(),this}}class xu extends vs{constructor(){super(Object.assign(Ci(xu.getDefaults(),arguments,["threshold"]))),this.name="Limiter";const t=Ci(xu.getDefaults(),arguments,["threshold"]);this._compressor=this.input=this.output=new vu({context:this.context,ratio:20,attack:0,release:0,threshold:t.threshold}),this.threshold=this._compressor.threshold,Ui(this,"threshold")}static getDefaults(){return Object.assign(vs.getDefaults(),{threshold:-12})}get reduction(){return this._compressor.reduction}dispose(){return super.dispose(),this._compressor.dispose(),this.threshold.dispose(),this}}class _u extends vs{constructor(){super(Object.assign(Ci(_u.getDefaults(),arguments))),this.name="MidSideCompressor";const t=Ci(_u.getDefaults(),arguments);this._midSideSplit=this.input=new tu({context:this.context}),this._midSideMerge=this.output=new eu({context:this.context}),this.mid=new vu(Object.assign(t.mid,{context:this.context})),this.side=new vu(Object.assign(t.side,{context:this.context})),this._midSideSplit.mid.chain(this.mid,this._midSideMerge.mid),this._midSideSplit.side.chain(this.side,this._midSideMerge.side),Ui(this,["mid","side"])}static getDefaults(){return Object.assign(vs.getDefaults(),{mid:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16},side:{ratio:6,threshold:-30,release:.25,attack:.03,knee:10}})}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._midSideSplit.dispose(),this._midSideMerge.dispose(),this}}class Ou extends vs{constructor(){super(Object.assign(Ci(Ou.getDefaults(),arguments))),this.name="MultibandCompressor";const t=Ci(Ou.getDefaults(),arguments);this._splitter=this.input=new mu({context:this.context,lowFrequency:t.lowFrequency,highFrequency:t.highFrequency}),this.lowFrequency=this._splitter.lowFrequency,this.highFrequency=this._splitter.highFrequency,this.output=new Os({context:this.context}),this.low=new vu(Object.assign(t.low,{context:this.context})),this.mid=new vu(Object.assign(t.mid,{context:this.context})),this.high=new vu(Object.assign(t.high,{context:this.context})),this._splitter.low.chain(this.low,this.output),this._splitter.mid.chain(this.mid,this.output),this._splitter.high.chain(this.high,this.output),Ui(this,["high","mid","low","highFrequency","lowFrequency"])}static getDefaults(){return Object.assign(vs.getDefaults(),{lowFrequency:250,highFrequency:2e3,low:{ratio:6,threshold:-30,release:.25,attack:.03,knee:10},mid:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16},high:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16}})}dispose(){return super.dispose(),this._splitter.dispose(),this.low.dispose(),this.mid.dispose(),this.high.dispose(),this.output.dispose(),this}}class Su extends vs{constructor(){super(Ci(Su.getDefaults(),arguments,["low","mid","high"])),this.name="EQ3",this.output=new Os({context:this.context}),this._internalChannels=[];const t=Ci(Su.getDefaults(),arguments,["low","mid","high"]);this.input=this._multibandSplit=new mu({context:this.context,highFrequency:t.highFrequency,lowFrequency:t.lowFrequency}),this._lowGain=new Os({context:this.context,gain:t.low,units:"decibels"}),this._midGain=new Os({context:this.context,gain:t.mid,units:"decibels"}),this._highGain=new Os({context:this.context,gain:t.high,units:"decibels"}),this.low=this._lowGain.gain,this.mid=this._midGain.gain,this.high=this._highGain.gain,this.Q=this._multibandSplit.Q,this.lowFrequency=this._multibandSplit.lowFrequency,this.highFrequency=this._multibandSplit.highFrequency,this._multibandSplit.low.chain(this._lowGain,this.output),this._multibandSplit.mid.chain(this._midGain,this.output),this._multibandSplit.high.chain(this._highGain,this.output),Ui(this,["low","mid","high","lowFrequency","highFrequency"]),this._internalChannels=[this._multibandSplit]}static getDefaults(){return Object.assign(vs.getDefaults(),{high:0,highFrequency:2500,low:0,lowFrequency:400,mid:0})}dispose(){return super.dispose(),Wi(this,["low","mid","high","lowFrequency","highFrequency"]),this._multibandSplit.dispose(),this.lowFrequency.dispose(),this.highFrequency.dispose(),this._lowGain.dispose(),this._midGain.dispose(),this._highGain.dispose(),this.low.dispose(),this.mid.dispose(),this.high.dispose(),this.Q.dispose(),this}}class ku extends vs{constructor(){super(Ci(ku.getDefaults(),arguments,["url","onload"])),this.name="Convolver",this._convolver=this.context.createConvolver();const t=Ci(ku.getDefaults(),arguments,["url","onload"]);this._buffer=new Hi(t.url,e=>{this.buffer=e,t.onload()}),this.input=new Os({context:this.context}),this.output=new Os({context:this.context}),this._buffer.loaded&&(this.buffer=this._buffer),this.normalize=t.normalize,this.input.chain(this._convolver,this.output)}static getDefaults(){return Object.assign(vs.getDefaults(),{normalize:!0,onload:Gi})}load(t){return yi(this,void 0,void 0,(function*(){this.buffer=yield this._buffer.load(t)}))}get buffer(){return this._buffer.length?this._buffer:null}set buffer(t){t&&this._buffer.set(t),this._convolver.buffer&&(this.input.disconnect(),this._convolver.disconnect(),this._convolver=this.context.createConvolver(),this.input.chain(this._convolver,this.output));const e=this._buffer.get();this._convolver.buffer=e||null}get normalize(){return this._convolver.normalize}set normalize(t){this._convolver.normalize=t}dispose(){return super.dispose(),this._buffer.dispose(),this._convolver.disconnect(),this}}function Tu(){return Yi().now()}function Cu(){return Yi().immediate()}const Au=Yi().transport;function Nu(){return Yi().transport}const Iu=Yi().destination,Eu=Yi().destination;function ju(){return Yi().destination}const Mu=Yi().listener;function Du(){return Yi().listener}const Ru=Yi().draw;function Pu(){return Yi().draw}const Fu=Yi();function zu(){return Hi.loaded()}const Lu=Hi,$u=Ds,Bu=Qs},function(t,e,n){"use strict";n.r(e),n.d(e,"validateUpdateShape",(function(){return i})),n.d(e,"validateInput",(function(){return s})),n.d(e,"calculateShapes",(function(){return a}));var r=n(7);function i(t,e,n){const r=e.rank>1?e.shape[e.rank-1]:1,i=e.rank>1?e.rank-1:1,s="Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: "+n.shape+`, indices.shape: ${e.shape}, shape: ${t}`+`, sliceDim: ${r}, and batchDim: ${i}.`;if(n.rank<i)throw new Error(s+` update.rank < ${i}. `);if(t.length<r+(n.rank-i))throw new Error(s+" Output shape length < "+(r+(n.rank-i)));if(n.rank!==i+t.length-r)throw new Error(s+" update.rank != "+(i+t.length-r));for(let t=0;t<i;++t)if(n.shape[t]!==e.shape[t])throw new Error(s+` updates.shape[${t}] (${n.shape[t]}) != indices.shape[${t}] (${e.shape[t]}).`);for(let e=0;e<n.rank-i;++e)if(n.shape[e+i]!==t[e+r])throw new Error(s+` updates.shape[${e+i}] (${n.shape[e+i]}) != shape[${e+i}] (${t[e+i]})`)}function s(t,e,n){if(e.rank<1)throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${e.rank}.`);if(t.rank<1)throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${t.rank}.`);if("int32"!==e.dtype)throw new Error("The dtype of 'indices' should be int32, but got dtype: "+e.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===e.size)throw new Error("Indices specified for empty output. indices shape: "+e.shape);if(0===t.size)throw new Error("Updates specified for empty output. updates shape: "+t.shape)}i(n,e,t)}function a(t,e,n){const i=e.shape.length,s=i>1?e.shape[i-1]:1,a=n.length;let o=1;for(let t=s;t<a;++t)o*=n[t];const u=s<1?1:s;return{sliceRank:s,numUpdates:Object(r.N)(e.shape)/u,sliceSize:o,strides:[...Object(r.j)(n.slice(0,s)),1],outputSize:Object(r.N)(n)}}},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(4);const u=Object(o.b)({floorDiv_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","floorDiv"),o=Object(a.a)(e,"b","floorDiv");[n,o]=Object(s.makeTypesMatch)(n,o);const u={a:n,b:o};return r.a.runKernelFunc((t,e)=>{const r=t.floorDiv(n,o);return e([n,o]),r},u,null,i.db)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));var r=n(5),i=n(3);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function s(t,e,n){const s={shape:t,value:e,dtype:n};return r.a.runKernelFunc(r=>r.fill(t,e,n),{},null,i.ab,s)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return h}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(12),u=n(20),c=n(4),l=n(8);const h=Object(c.b)({avgPool_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,c,h){const d=Object(s.a)(t,"x","avgPool","float32");a.b(u.h(n,1),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`);let p=d,f=!1;3===d.rank&&(f=!0,p=Object(l.a)(d,[1,d.shape[0],d.shape[1],d.shape[2]])),a.b(4===p.rank,()=>`Error in avgPool: x must be rank 4 but got rank ${p.rank}.`),null!=h&&a.b(a.v(c),()=>`Error in avgPool: pad must be an integer when using, dimRoundingMode ${h} but got pad ${c}.`);const m={x:p},g={filterSize:e,strides:n,pad:c,dimRoundingMode:h};let b=r.a.runKernelFunc((t,r)=>{const i=u.e(p.shape,e,n,1,c,h);return r([p]),1===i.filterWidth&&1===i.filterHeight&&a.a(i.inShape,i.outShape)?p.clone():t.avgPool(p,i)},m,null,i.o,g);return b=Object(o.a)(b,d.dtype),f?Object(l.a)(b,[b.shape[1],b.shape[2],b.shape[3]]):b}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({cos_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","cos"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.cos(e);return n([e]),r},n,null,i.G)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(1),a=n(24),o=n(4),u=n(31);const c=Object(o.b)({cumsum_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=0,n=!1,o=!1){const c=Object(s.a)(t,"x","cumsum"),l={x:c},h={axis:e,exclusive:n,reverse:o};return r.a.runKernelFunc((t,r)=>{const i=Object(a.f)([e],c.rank);let s=c;null!=i&&(s=Object(u.a)(c,i));const l=Object(a.g)(1,c.rank)[0];let h=t.cumsum(s,l,n,o);if(r([c]),null!=i){const t=Object(a.h)(i);h=Object(u.a)(h,t)}return h},l,null,i.J,h)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({elu_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","elu"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.elu(e);return n([r]),r},n,null,i.T)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({floor_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","floor"),n={x:e};return r.a.runKernelFunc(t=>t.floor(e),n,null,i.cb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return f}));var r=n(1),i=n(7),s=n(13),a=n(24),o=n(40),u=n(76),c=n(72),l=n(4),h=n(8),d=n(14),p=n(21);const f=Object(l.b)({logSumExp_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=null,n=!1){const l=Object(r.a)(t,"x","logSumExp"),f=Object(i.I)(e,l.shape),m=Object(c.a)(l,f,!0),g=Object(d.a)(l,m),b=Object(o.a)(g),y=Object(p.a)(b,f),v=Object(u.a)(y),w=Object(s.a)(Object(h.a)(m,v.shape),v);if(n){const t=Object(a.e)(w.shape,f);return Object(h.a)(w,t)}return w}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(18),o=n(4);const u=Object(o.b)({logicalOr_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){const n=Object(s.a)(t,"a","logicalOr","bool"),o=Object(s.a)(e,"b","logicalOr","bool");Object(a.a)(n.shape,o.shape);const u={a:n,b:o};return r.a.runKernelFunc(t=>t.logicalOr(n,o),u,null,i.Cb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(20),u=n(4),c=n(8);const l=Object(u.b)({maxPool_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,u,l){const h=Object(s.a)(t,"x","maxPool");let d=h,p=!1;3===h.rank&&(p=!0,d=Object(c.a)(h,[1,h.shape[0],h.shape[1],h.shape[2]])),a.b(4===d.rank,()=>`Error in maxPool: input must be rank 4 but got rank ${d.rank}.`),a.b(o.h(n,1),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`),null!=l&&a.b(a.v(u),()=>`Error in maxPool: pad must be an integer when using, dimRoundingMode ${l} but got pad ${u}.`);const f={x:d},m={filterSize:e,strides:n,pad:u,dimRoundingMode:l},g=r.a.runKernelFunc((t,r)=>{const i=o.e(d.shape,e,n,1,u,l);let s;return s=1===i.filterWidth&&1===i.filterHeight&&a.a(i.inShape,i.outShape)?d.clone():t.maxPool(d,i),r([d,s]),s},f,null,i.Eb,m);return p?Object(c.a)(g,[g.shape[1],g.shape[2],g.shape[3]]):g}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(4);const u=Object(o.b)({mod_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","mod"),o=Object(a.a)(e,"b","mod");[n,o]=Object(s.makeTypesMatch)(n,o);const u={a:n,b:o};return r.a.runKernelFunc((t,e)=>{const r=t.mod(n,o);return e([n,o]),r},u,null,i.Ob)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({prelu_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){const n=Object(s.a)(t,"x","prelu"),a=Object(s.a)(e,"alpha","prelu"),o={x:n,alpha:a};return r.a.runKernelFunc((t,e)=>{const r=t.prelu(n,a);return e([n,a]),r},o,null,i.ac)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(12),o=n(4);const u=Object(o.b)({relu6_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","relu6"),n={x:e};return r.a.runKernelFunc((t,n)=>(n([e]),"bool"===e.dtype?Object(a.a)(e,"int32"):t.relu6(e)),n,null,i.gc)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(7),a=n(4);const o=Object(a.b)({fft_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){Object(s.b)("complex64"===t.dtype,()=>`The dtype for tf.spectral.fft() must be complex64 but got ${t.dtype}.`);const e={input:t};return r.a.runKernelFunc(e=>{const n=t.shape[t.shape.length-1],r=t.size/n,i=t.as2D(r,n);return e.fft(i).reshape(t.shape)},e,null,i.Z)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return m}));var r=n(7),i=n(51),s=n(32),a=n(100),o=n(4),u=n(94),c=n(8),l=n(28),h=n(78),d=n(58),p=n(23),f=n(135);const m=Object(o.b)({rfft_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){Object(r.b)("float32"===t.dtype,()=>"The dtype for rfft() must be real value but got "+t.dtype);let n=t.shape[t.shape.length-1];const o=t.size/n;let m;if(null!=e&&e<n){const r=t.shape.map(t=>0),i=t.shape.map(t=>t);i[t.shape.length-1]=e,m=Object(l.a)(t,r,i),n=e}else if(null!=e&&e>n){const r=t.shape.map(t=>t);r[t.shape.length-1]=e-n,m=Object(s.a)([t,Object(d.a)(r)],t.shape.length-1),n=e}else m=t;const g=Object(p.a)(m),b=Object(c.a)(Object(i.a)(m,g),[o,n]),y=Object(f.a)(b),v=Math.floor(n/2)+1,w=Object(u.a)(y),x=Object(a.a)(y),_=Object(h.a)(w,[v,n-v],w.shape.length-1),O=Object(h.a)(x,[v,n-v],x.shape.length-1),S=m.shape.slice();return S[m.shape.length-1]=v,Object(c.a)(Object(i.a)(_[0],O[0]),S)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4);const u=Object(o.b)({unsortedSegmentSum_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n){const o=Object(s.a)(t,"x","unsortedSegmentSum"),u=Object(s.a)(e,"segmentIds","unsortedSegmentSum","int32");Object(a.b)(Object(a.v)(n),()=>"numSegments must be of dtype int");const c={x:o,segmentIds:u},l={numSegments:n};return r.a.runKernelFunc((t,e)=>{const r=t.unsortedSegmentSum(o,u,n);return e([u]),r},c,null,i.Rc,l)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return g}));var r=n(1),i=n(7),s=n(41),a=n(24),o=n(72),u=n(114),c=n(4),l=n(44),h=n(8),d=n(15),p=n(35),f=n(27),m=n(21);const g=Object(c.b)({norm_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e="euclidean",n=null,c=!1){const g=function t(e,n,r=null){if(0===e.rank)return Object(s.a)(e);if(1!==e.rank&&null===r)return t(Object(h.a)(e,[-1]),n,r);if(1===e.rank||"number"==typeof r||Array.isArray(r)&&1===r.length){if(1===n)return Object(m.a)(Object(s.a)(e),r);if(n===1/0)return Object(o.a)(Object(s.a)(e),r);if(n===-1/0)return Object(u.a)(Object(s.a)(e),r);if("euclidean"===n||2===n)return Object(p.a)(Object(m.a)(Object(l.a)(Object(s.a)(e),Object(d.a)(2,"int32")),r));throw new Error("Error in norm: invalid ord value: "+n)}if(Array.isArray(r)&&2===r.length){if(1===n)return Object(o.a)(Object(m.a)(Object(s.a)(e),r[0]),r[1]-1);if(n===1/0)return Object(o.a)(Object(m.a)(Object(s.a)(e),r[1]),r[0]);if(n===-1/0)return Object(u.a)(Object(m.a)(Object(s.a)(e),r[1]),r[0]);if("fro"===n||"euclidean"===n)return Object(p.a)(Object(m.a)(Object(f.a)(e),r));throw new Error("Error in norm: invalid ord value: "+n)}throw new Error("Error in norm: invalid axis: "+r)}(t=Object(r.a)(t,"x","norm"),e,n);let b=g.shape;if(c){const e=Object(i.I)(n,t.shape);b=a.e(g.shape,e)}return Object(h.a)(g,b)}})},function(t,e,n){"use strict";n.d(e,"c",(function(){return a})),n.d(e,"a",(function(){return u})),n.d(e,"b",(function(){return c}));var r=n(0),i=n(48),s=n(53);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const a=Object(i.a)((t,e)=>t*e),o=Object(s.b)((t,e,n,r)=>({real:t*n-e*r,imag:t*r+e*n})),u=Object(s.a)(r.Multiply,a,o),c={kernelName:r.Multiply,backendName:"cpu",kernelFunc:u}},function(t,e,n){"use strict";n.d(e,"c",(function(){return a})),n.d(e,"a",(function(){return u})),n.d(e,"b",(function(){return c}));var r=n(0),i=n(48),s=n(53);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const a=Object(i.a)((t,e)=>t-e),o=Object(s.b)((t,e,n,r)=>({real:t-n,imag:e-r})),u=Object(s.a)(r.Sub,a,o),c={kernelName:r.Sub,backendName:"cpu",kernelFunc:u}},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(0);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function i(t,e,n,i,s){const a=e.length,o=r.util.sizeFromShape(e),u=r.util.computeStrides(e),c=r.util.computeStrides(s),l=r.util.getTypedArrayFromDType(n,r.util.sizeFromShape(s));for(let e=0;e<o;++e){const n=r.util.indexToLoc(e,a,u),s=new Array(n.length);for(let t=0;t<s.length;t++)s[t]=n[i[t]];l[r.util.locToIndex(s,a,c)]=t[e]}return l}},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(7),a=n(20),o=n(4),u=n(8);const c=Object(o.b)({conv2DBackpropInput_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,o,c,l="NHWC",h){s.b(t.length===e.rank,()=>`Length of inShape (${t.length}) and rank of dy (${e.rank}) must match`);let d=t,p=e,f=!1;3===e.rank&&(f=!0,p=Object(u.a)(e,[1,e.shape[0],e.shape[1],e.shape[2]]),d=[1,t[0],t[1],t[2]]),s.b(4===d.length,()=>"Error in conv2dDerInput: inShape must be length 4, but got length "+d.length+"."),s.b(4===p.rank,()=>"Error in conv2dDerInput: dy must be rank 4, but got rank "+p.rank),s.b(4===n.rank,()=>"Error in conv2dDerInput: filter must be rank 4, but got rank "+n.rank);const m="NHWC"===l?d[3]:d[1],g="NHWC"===l?p.shape[3]:p.shape[1];s.b(m===n.shape[2],()=>`Error in conv2dDerInput: depth of input (${m}) must match input depth for filter ${n.shape[2]}.`),s.b(g===n.shape[3],()=>`Error in conv2dDerInput: depth of output (${g}) must match output depth for filter ${n.shape[3]}.`),null!=h&&s.b(s.v(c),()=>`Error in conv2dDerInput: pad must be an integer when using, dimRoundingMode ${h} but got pad ${c}.`);const b={dy:p,filter:n},y={strides:o,pad:c,dataFormat:l,dimRoundingMode:h,inputShape:d},v=r.a.runKernelFunc((t,e)=>{const r=a.g(l),i=a.a(d,n.shape,o,1,c,h,!1,r),s=t.conv2dDerInput(p,n,i);return e([p,n]),s},b,null,i.C,y);return f?Object(u.a)(v,[v.shape[1],v.shape[2],v.shape[3]]):v}})},function(t,e,n){"use strict";n.r(e),n.d(e,"TEST_EPSILON_FLOAT16",(function(){return a})),n.d(e,"expectArraysClose",(function(){return o})),n.d(e,"testEpsilon",(function(){return u})),n.d(e,"expectPromiseToFail",(function(){return l})),n.d(e,"expectArraysEqual",(function(){return h})),n.d(e,"expectNumbersClose",(function(){return d})),n.d(e,"expectValuesInRange",(function(){return f})),n.d(e,"expectArrayBuffersEqual",(function(){return m}));var r=n(5),i=n(1),s=n(7);
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const a=.1;function o(t,e,n){return null==n&&(n=u()),c(t,e,(t,e)=>p(t,e,n))}function u(){return 32===r.a.backend.floatPrecision()?.001:a}function c(t,e,n){let r=!0;if((Object(s.A)(t)||Object(s.A)(e))&&(r=!1),Object(s.A)(t)&&Object(s.A)(e)&&(r=!0),r){const n=t.constructor.name,r=e.constructor.name;if(n!==r)throw new Error(`Arrays are of different type. Actual: ${n}. Expected: `+r)}if(Array.isArray(t)&&Array.isArray(e)){const n=Object(i.c)(t),r=Object(i.c)(e);if(!Object(s.a)(n,r))throw new Error(`Arrays have different shapes. Actual: [${n}]. Expected: [${r}]`)}const a=Object(s.A)(t)?t:Object(s.m)(t),o=Object(s.A)(e)?e:Object(s.m)(e);if(a.length!==o.length)throw new Error(`Arrays have different lengths actual: ${a.length} vs expected: ${o.length}.\nActual:   ${a}.\nExpected: ${o}.`);for(let t=0;t<o.length;++t){const e=a[t],r=o[t];if(!n(e,r))throw new Error(`Arrays differ: actual[${t}] = ${e}, expected[${t}] = ${r}.\nActual:   ${a}.\nExpected: ${o}.`)}}function l(t,e){t().then(()=>e.fail(),()=>e())}function h(t,e){const n="string"==typeof e||"number"==typeof e||"boolean"==typeof e?[e]:e;return Object(s.z)(t)||Object(s.z)(t[0])||Object(s.z)(e)||Object(s.z)(e[0])?c(t,n,(t,e)=>t==e):c(t,e,(t,e)=>p(t,e,0))}function d(t,e,n){if(null==n&&(n=u()),!p(t,e,n))throw new Error(`Numbers differ: actual === ${t}, expected === ${e}`)}function p(t,e,n){return!isFinite(t)&&!isFinite(e)||!(isNaN(t)||isNaN(e)||Math.abs(t-e)>n)}function f(t,e,n){for(let r=0;r<t.length;r++)if(t[r]<e||t[r]>n)throw new Error(`Value out of range:${t[r]} low: ${e}, high: ${n}`)}function m(t,e){expect(new Float32Array(t)).toEqual(new Float32Array(e))}},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(7),a=n(20),o=n(4),u=n(8);const c=Object(o.b)({conv2DBackpropFilter_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,o,c,l="NHWC",h){let d=t;3===t.rank&&(d=Object(u.a)(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let p=e;3===p.rank&&(p=Object(u.a)(e,[1,e.shape[0],e.shape[1],e.shape[2]])),s.b(4===d.rank,()=>"Error in conv2dDerFilter: input must be rank 4, but got shape "+d.shape+"."),s.b(4===p.rank,()=>"Error in conv2dDerFilter: dy must be rank 4, but got shape "+p.shape+"."),s.b(4===n.length,()=>"Error in conv2dDerFilter: filterShape must be length 4, but got "+n+".");const f="NHWC"===l?d.shape[3]:d.shape[1],m="NHWC"===l?p.shape[3]:p.shape[1];s.b(f===n[2],()=>`Error in conv2dDerFilter: depth of input ${f}) must match input depth in filter (${n[2]}.`),s.b(m===n[3],()=>`Error in conv2dDerFilter: depth of dy (${m}) must match output depth for filter (${n[3]}).`),null!=h&&s.b(s.v(c),()=>`Error in conv2dDerFilter: pad must be an integer when using, dimRoundingMode ${h} but got pad ${c}.`);const g={x:d,dy:p},b={strides:o,pad:c,dataFormat:l,dimRoundingMode:h,filterShape:n};return r.a.runKernelFunc(t=>{const e=a.g(l),r=a.a(d.shape,n,o,1,c,h,!1,e);return t.conv2dDerFilter(d,p,r)},g,null,i.B,b)}})},function(t,e,n){"use strict";(function(t){var e=n(156),r=n(26);
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const i=Object(r.c)();i.registerFlag("DEBUG",()=>!1,t=>{t&&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.")}),i.registerFlag("IS_BROWSER",()=>e.isBrowser()),i.registerFlag("IS_NODE",()=>void 0!==t&&void 0!==t.versions&&void 0!==t.versions.node),i.registerFlag("IS_CHROME",()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)),i.registerFlag("PROD",()=>!1),i.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>i.getBool("DEBUG")),i.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0),i.registerFlag("IS_TEST",()=>!1)}).call(this,n(154))},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.getAudioFeatures=e.startSpice=e.CONF_THRESHOLD=e.PITCH_CONF_JITTER=e.PT_SLOPE=e.PT_OFFSET=e.MODEL_FRAME_RATE=e.MODEL_SAMPLE_RATE=void 0;var s=n(36),a=n(111),o=n(397),u=n(217);e.MODEL_SAMPLE_RATE=16e3,e.MODEL_FRAME_RATE=250,e.PT_OFFSET=25.58,e.PT_SLOPE=63.07,e.PITCH_CONF_JITTER=.002,e.CONF_THRESHOLD=.7,e.startSpice=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,s.loadGraphModel(t,{fromTFHub:!0})];case 1:return[2,e.sent()]}}))}))},e.getAudioFeatures=function(t,n,c){return r(this,void 0,void 0,(function(){var r,l,h,d,p,f;return i(this,(function(i){switch(i.label){case 0:if("webgl"!==s.getBackend())throw new Error("Device does not support webgl.");return[4,a.resampleAndMakeMono(t,e.MODEL_SAMPLE_RATE)];case 1:return r=i.sent(),l=r.length,[4,o.computePower(r)];case 2:return h=i.sent(),[4,u.getPitches(n,r,c)];case 3:return d=i.sent(),p=d.pitches,f=d.confidences,[2,{f0_hz:p,loudness_db:h,confidences:f,originalRecordedBufferLength:l}]}}))}))}},function(t,e,n){"use strict";n.d(e,"a",(function(){return r})),n.d(e,"b",(function(){return i}));class r{constructor(t,e){this.backend=t,this.dataMover=e,this.data=new WeakMap,this.dataIdsCount=0}get(t){return this.data.has(t)||this.dataMover.moveData(this.backend,t),this.data.get(t)}set(t,e){this.dataIdsCount++,this.data.set(t,e)}has(t){return this.data.has(t)}delete(t){return this.dataIdsCount--,this.data.delete(t)}numDataIds(){return this.dataIdsCount}}class i{time(t){return s("time")}read(t){return s("read")}readSync(t){return s("readSync")}numDataIds(){return s("numDataIds")}disposeData(t){return s("disposeData")}write(t,e,n){return s("write")}move(t,e,n,r){return s("move")}memory(){return s("memory")}floatPrecision(){return s("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}batchMatMul(t,e,n,r){return s("batchMatMul")}fusedBatchMatMul({a:t,b:e,transposeA:n,transposeB:r,bias:i,activation:a,preluActivationWeights:o}){return s("fusedBatchMatMul")}slice(t,e,n){return s("slice")}stridedSlice(t,e,n,r){return s("stridedSlice")}unstack(t,e){return s("unstack")}reverse(t,e){return s("reverse")}concat(t,e){return s("concat")}neg(t){return s("neg")}add(t,e){return s("add")}addN(t){return s("addN")}subtract(t,e){return s("subtract")}multiply(t,e){return s("multiply")}realDivide(t,e){return s("realDivide")}floorDiv(t,e){return s("floorDiv")}sum(t,e){return s("sum")}prod(t,e){return s("prod")}unsortedSegmentSum(t,e,n){return s("unsortedSegmentSum")}argMin(t,e){return s("argMin")}argMax(t,e){return s("argMax")}equal(t,e){return s("equal")}notEqual(t,e){return s("notEqual")}less(t,e){return s("less")}lessEqual(t,e){return s("lessEqual")}greater(t,e){return s("greater")}greaterEqual(t,e){return s("greaterEqual")}logicalNot(t){return s("logicalNot")}logicalAnd(t,e){return s("logicalAnd")}logicalOr(t,e){return s("logicalOr")}where(t){return s("where")}select(t,e,n){return s("select")}topk(t,e,n){return s("topk")}min(t,e){return s("min")}minimum(t,e){return s("minimum")}mod(t,e){return s("mod")}max(t,e){return s("max")}maximum(t,e){return s("maximum")}all(t,e){return s("all")}any(t,e){return s("any")}squaredDifference(t,e){return s("squaredDifference")}ceil(t){return s("ceil")}floor(t){return s("floor")}round(t){return s("round")}sign(t){return s("sign")}isNaN(t){return s("isNaN")}isInf(t){return s("isInf")}isFinite(t){return s("isFinite")}pow(t,e){return s("pow")}exp(t){return s("exp")}expm1(t){return s("expm1")}softmax(t,e){return s("softmax")}log(t){return s("log")}log1p(t){return s("log1p")}sqrt(t){return s("sqrt")}rsqrt(t){return s("rsqrt")}square(t){return s("square")}reciprocal(t){return s("reciprocal")}relu(t){return s("relu")}relu6(t){return s("relu6")}prelu(t,e){return s("prelu")}elu(t){return s("elu")}eluDer(t,e){return s("eluDer")}selu(t){return s("selu")}int(t){return s("int")}clip(t,e,n){return s("clip")}abs(t){return s("abs")}complexAbs(t){return s("complexAbs")}sigmoid(t){return s("sigmoid")}softplus(t){return s("softplus")}sin(t){return s("sin")}cos(t){return s("cos")}tan(t){return s("tan")}asin(t){return s("asin")}acos(t){return s("acos")}atan(t){return s("atan")}atan2(t,e){return s("atan2")}sinh(t){return s("sinh")}cosh(t){return s("cosh")}tanh(t){return s("tanh")}asinh(t){return s("asinh")}acosh(t){return s("acosh")}atanh(t){return s("atanh")}erf(t){return s("erf")}step(t,e){return s("step")}fusedConv2d({input:t,filter:e,convInfo:n,bias:r,activation:i,preluActivationWeights:a}){return s("fusedConv2d")}conv2d(t,e,n){return s("conv2d")}conv2dDerInput(t,e,n){return s("conv2dDerInput")}conv2dDerFilter(t,e,n){return s("conv2dDerFilter")}fusedDepthwiseConv2D({input:t,filter:e,convInfo:n,bias:r,activation:i,preluActivationWeights:a}){return s("fusedDepthwiseConv2D")}depthwiseConv2D(t,e,n){return s("depthwiseConv2D")}depthwiseConv2DDerInput(t,e,n){return s("depthwiseConv2DDerInput")}depthwiseConv2DDerFilter(t,e,n){return s("depthwiseConv2DDerFilter")}conv3d(t,e,n){return s("conv3d")}conv3dDerInput(t,e,n){return s("conv3dDerInput")}conv3dDerFilter(t,e,n){return s("conv3dDerFilter")}maxPool(t,e){return s("maxPool")}maxPoolBackprop(t,e,n,r){return s("maxPoolBackprop")}avgPool(t,e){return s("avgPool")}avgPoolBackprop(t,e,n){return s("avgPoolBackprop")}avgPool3d(t,e){return s("avgPool3d")}avgPool3dBackprop(t,e,n){return s("avgPool3dBackprop")}maxPool3d(t,e){return s("maxPool3d")}maxPool3dBackprop(t,e,n,r){return s("maxPool3dBackprop")}reshape(t,e){return s("reshape")}cast(t,e){return s("cast")}tile(t,e){return s("tile")}pad(t,e,n){return s("pad")}transpose(t,e){return s("transpose")}gather(t,e,n){return s("gather")}gatherND(t,e){return s("gatherND")}scatterND(t,e,n){return s("scatterND")}batchToSpaceND(t,e,n){return s("batchToSpaceND")}spaceToBatchND(t,e,n){return s("spaceToBatchND")}resizeBilinear(t,e,n,r){return s("resizeBilinear")}resizeBilinearBackprop(t,e,n){return s("resizeBilinearBackprop")}resizeNearestNeighbor(t,e,n,r){return s("resizeNearestNeighbor")}resizeNearestNeighborBackprop(t,e,n){return s("resizeNearestNeighborBackprop")}batchNorm(t,e,n,r,i,a){return s("batchNorm")}localResponseNormalization4D(t,e,n,r,i){return s("localResponseNormalization4D")}LRNGrad(t,e,n,r,i,a,o){return s("LRNGrad")}multinomial(t,e,n,r){return s("multinomial")}oneHot(t,e,n,r){return s("oneHot")}cumsum(t,e,n,r){return s("cumsum")}nonMaxSuppression(t,e,n,r,i){return s("nonMaxSuppression")}fft(t){return s("fft")}ifft(t){return s("ifft")}complex(t,e){return s("complex")}real(t){return s("real")}imag(t){return s("imag")}cropAndResize(t,e,n,r,i,a){return s("cropAndResize")}depthToSpace(t,e,n){return s("depthToSpace")}split(t,e,n){return s("split")}sparseToDense(t,e,n,r){return s("sparseToDense")}diag(t){return s("diag")}fill(t,e,n){return s("fill")}onesLike(t){return s("onesLike")}zerosLike(t){return s("zerosLike")}linspace(t,e,n){return s("linspace")}dispose(){return s("dispose")}}function s(t){throw new Error(`'${t}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return i})),n.d(e,"b",(function(){return s}));var r=n(7);
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function i(t,e){const n=t[0].length;t.forEach((t,e)=>{r.b(t.length===n,()=>`Error in concat${n}D: rank of tensors[${e}] must be the same as the rank of the rest (${n})`)}),r.b(e>=0&&e<n,()=>`Error in concat${n}D: axis must be between 0 and ${n-1}.`);const i=t[0];t.forEach((t,s)=>{for(let a=0;a<n;a++)r.b(a===e||t[a]===i[a],()=>`Error in concat${n}D: Shape of tensors[${s}] (${t}) does not match the shape of the rest (${i}) along the non-concatenated axis ${s}.`)})}function s(t,e){const n=t[0].slice();for(let r=1;r<t.length;r++)n[e]+=t[r][e];return n}},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({tanh_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","tanh"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.tanh(e);return n([r]),r},n,null,i.Lc)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(7),a=n(77),o=n(58);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function u(t,e,n=1,u="float32"){if(0===n)throw new Error("Cannot have a step of zero");const c={start:t,stop:e,step:n,dtype:u};return r.a.runKernelFunc(()=>{if(t===e||t<e&&n<0||e<t&&n>1)return Object(o.a)([0],u);const r=Math.abs(Math.ceil((e-t)/n)),i=Object(s.F)(r,u);e<t&&1===n&&(n=-1),i[0]=t;for(let t=1;t<i.length;t++)i[t]=i[t-1]+n;return Object(a.a)(i,u)},{},null,i.cc,c)}},function(t,e,n){"use strict";(function(t,r){
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
let i;function s(){if(null==i){let e;if("undefined"!=typeof window)e=window;else if(void 0!==t)e=t;else if(void 0!==r)e=r;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}i=e}return i}function a(t,e){const n=function(){const t=s();return null==t._tfGlobals&&(t._tfGlobals=new Map),t._tfGlobals}();if(n.has(t))return n.get(t);{const r=e();return n.set(t,r),n.get(t)}}n.d(e,"b",(function(){return s})),n.d(e,"a",(function(){return a}))}).call(this,n(96),n(154))},function(t,e,n){"use strict";n.d(e,"a",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8}},function(t,e,n){"use strict";n.d(e,"a",(function(){return u})),n.d(e,"b",(function(){return c}));var r=n(0),i=n(48),s=n(50),a=n(65),o=n(95);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function u(t){const{inputs:e,backend:n,attrs:c}=t,{x:l}=e,{dtype:h}=c;if("complex64"===h){if("complex64"===l.dtype)return Object(a.a)({inputs:{x:l},backend:n});const t=r.zeros(l.shape),e=u({inputs:{x:l},backend:n,attrs:{dtype:"float32"}}),i=Object(s.a)({inputs:{real:e,imag:t},backend:n});return t.dispose(),n.disposeIntermediateTensorInfo(e),i}if("complex64"===l.dtype){const t=Object(o.a)({inputs:{input:l},backend:n}),e=u({inputs:{x:t},backend:n,attrs:{dtype:h}});return n.disposeIntermediateTensorInfo(t),e}if(!r.util.hasEncodingLoss(l.dtype,h)){const t=Object(a.a)({inputs:{x:l},backend:n});return{dataId:t.dataId,shape:t.shape,dtype:h}}if("int32"===h){const t=n.data.get(l.dataId).values,e=Int32Array.from(t);return n.makeTensorInfo(l.shape,"int32",e)}if("bool"===h){const t=n.data.get(l.dataId).values,e=r.util.toTypedArray([0],l.dtype),[s,a]=Object(i.a)((t,e)=>t!==e?1:0)(l.shape,[],t,e,"bool");return n.makeTensorInfo(a,"bool",s)}throw new Error(`Error in Cast: failed to cast ${l.dtype} to ${h}`)}const c={kernelName:r.Cast,backendName:"cpu",kernelFunc:u}},function(t,e){var n,r,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function o(t){if(n===setTimeout)return setTimeout(t,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(t){n=s}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(t){r=a}}();var u,c=[],l=!1,h=-1;function d(){l&&u&&(l=!1,u.length?c=u.concat(c):h=-1,c.length&&p())}function p(){if(!l){var t=o(d);l=!0;for(var e=c.length;e;){for(u=c,c=[];++h<e;)u&&u[h].run();h=-1,e=c.length}u=null,l=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function f(t,e){this.fun=t,this.array=e}function m(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new f(t,e)),1!==c.length||l||o(p)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,n){"use strict";(function(t){
/*!
 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <http://feross.org>
 * @license  MIT
 */
var r=n(295),i=n(296),s=n(297);function a(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(t,e){if(a()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,n){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,n);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return h(this,t)}return c(this,t,e,n)}function c(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,n,r){if(e.byteLength,n<0||e.byteLength<n)throw new RangeError("'offset' is out of bounds");if(e.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");e=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=d(t,e);return t}(t,e,n,r):"string"==typeof e?function(t,e,n){"string"==typeof n&&""!==n||(n="utf8");if(!u.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|f(e,n),i=(t=o(t,r)).write(e,n);i!==r&&(t=t.slice(0,i));return t}(t,e,n):function(t,e){if(u.isBuffer(e)){var n=0|p(e.length);return 0===(t=o(t,n)).length||e.copy(t,0,0,n),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(r=e.length)!=r?o(t,0):d(t,e);if("Buffer"===e.type&&s(e.data))return d(t,e.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function h(t,e){if(l(e),t=o(t,e<0?0:0|p(e)),!u.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n)t[n]=0;return t}function d(t,e){var n=e.length<0?0:0|p(e.length);t=o(t,n);for(var r=0;r<n;r+=1)t[r]=255&e[r];return t}function p(t){if(t>=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|t}function f(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return $(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return B(t).length;default:if(r)return $(t).length;e=(""+e).toLowerCase(),r=!0}}function m(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return N(this,e,n);case"utf8":case"utf-8":return T(this,e,n);case"ascii":return C(this,e,n);case"latin1":case"binary":return A(this,e,n);case"base64":return k(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function g(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function b(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=u.from(e,r)),u.isBuffer(e))return 0===e.length?-1:y(t,e,n,r,i);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):y(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,n,r,i){var s,a=1,o=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;a=2,o/=2,u/=2,n/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var l=-1;for(s=n;s<o;s++)if(c(t,s)===c(e,-1===l?0:s-l)){if(-1===l&&(l=s),s-l+1===u)return l*a}else-1!==l&&(s-=s-l),l=-1}else for(n+u>o&&(n=o-u),s=n;s>=0;s--){for(var h=!0,d=0;d<u;d++)if(c(t,s+d)!==c(e,d)){h=!1;break}if(h)return s}return-1}function v(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var a=0;a<r;++a){var o=parseInt(e.substr(2*a,2),16);if(isNaN(o))return a;t[n+a]=o}return a}function w(t,e,n,r){return q($(e,t.length-n),t,n,r)}function x(t,e,n,r){return q(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function _(t,e,n,r){return x(t,e,n,r)}function O(t,e,n,r){return q(B(e),t,n,r)}function S(t,e,n,r){return q(function(t,e){for(var n,r,i,s=[],a=0;a<t.length&&!((e-=2)<0);++a)n=t.charCodeAt(a),r=n>>8,i=n%256,s.push(i),s.push(r);return s}(e,t.length-n),t,n,r)}function k(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function T(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i<n;){var s,a,o,u,c=t[i],l=null,h=c>239?4:c>223?3:c>191?2:1;if(i+h<=n)switch(h){case 1:c<128&&(l=c);break;case 2:128==(192&(s=t[i+1]))&&(u=(31&c)<<6|63&s)>127&&(l=u);break;case 3:s=t[i+1],a=t[i+2],128==(192&s)&&128==(192&a)&&(u=(15&c)<<12|(63&s)<<6|63&a)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:s=t[i+1],a=t[i+2],o=t[i+3],128==(192&s)&&128==(192&a)&&128==(192&o)&&(u=(15&c)<<18|(63&s)<<12|(63&a)<<6|63&o)>65535&&u<1114112&&(l=u)}null===l?(l=65533,h=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=h}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=4096));return n}(r)}e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=a(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,n){return c(null,t,e,n)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,n){return function(t,e,n,r){return l(e),e<=0?o(t,e):void 0!==n?"string"==typeof r?o(t,e).fill(n,r):o(t,e).fill(n):o(t,e)}(null,t,e,n)},u.allocUnsafe=function(t){return h(null,t)},u.allocUnsafeSlow=function(t){return h(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,i=0,s=Math.min(n,r);i<s;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},u.isEncoding=function(t){switch(String(t).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}},u.concat=function(t,e){if(!s(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=u.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){var a=t[n];if(!u.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(r,i),i+=a.length}return r},u.byteLength=f,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)g(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?T(this,0,t):m.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,n,r,i){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;for(var s=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0),o=Math.min(s,a),c=this.slice(r,i),l=t.slice(e,n),h=0;h<o;++h)if(c[h]!==l[h]){s=c[h],a=l[h];break}return s<a?-1:a<s?1:0},u.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},u.prototype.indexOf=function(t,e,n){return b(this,t,e,n,!0)},u.prototype.lastIndexOf=function(t,e,n){return b(this,t,e,n,!1)},u.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return v(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":return x(this,t,e,n);case"latin1":case"binary":return _(this,t,e,n);case"base64":return O(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function C(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function A(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function N(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var i="",s=e;s<n;++s)i+=L(t[s]);return i}function I(t,e,n){for(var r=t.slice(e,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+256*r[s+1]);return i}function E(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function j(t,e,n,r,i,s){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function M(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-n,2);i<s;++i)t[n+i]=(e&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function D(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-n,4);i<s;++i)t[n+i]=e>>>8*(r?i:3-i)&255}function R(t,e,n,r,i,s){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function P(t,e,n,r,s){return s||R(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function F(t,e,n,r,s){return s||R(t,0,n,8),i.write(t,e,n,r,52,8),n+8}u.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=u.prototype;else{var i=e-t;n=new u(i,void 0);for(var s=0;s<i;++s)n[s]=this[s+t]}return n},u.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||E(t,e,this.length);for(var r=this[t],i=1,s=0;++s<e&&(i*=256);)r+=this[t+s]*i;return r},u.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||E(t,e,this.length);for(var r=this[t+--e],i=1;e>0&&(i*=256);)r+=this[t+--e]*i;return r},u.prototype.readUInt8=function(t,e){return e||E(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||E(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||E(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||E(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||E(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||E(t,e,this.length);for(var r=this[t],i=1,s=0;++s<e&&(i*=256);)r+=this[t+s]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*e)),r},u.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||E(t,e,this.length);for(var r=e,i=1,s=this[t+--r];r>0&&(i*=256);)s+=this[t+--r]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*e)),s},u.prototype.readInt8=function(t,e){return e||E(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||E(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(t,e){e||E(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(t,e){return e||E(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||E(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||E(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||E(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||E(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||E(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||j(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,s=0;for(this[e]=255&t;++s<n&&(i*=256);)this[e+s]=t/i&255;return e+n},u.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||j(this,t,e,n,Math.pow(2,8*n)-1,0);var i=n-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+n},u.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):D(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):D(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);j(this,t,e,n,i-1,-i)}var s=0,a=1,o=0;for(this[e]=255&t;++s<n&&(a*=256);)t<0&&0===o&&0!==this[e+s-1]&&(o=1),this[e+s]=(t/a>>0)-o&255;return e+n},u.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);j(this,t,e,n,i-1,-i)}var s=n-1,a=1,o=0;for(this[e+s]=255&t;--s>=0&&(a*=256);)t<0&&0===o&&0!==this[e+s+1]&&(o=1),this[e+s]=(t/a>>0)-o&255;return e+n},u.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):D(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):D(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,n){return P(this,t,e,!0,n)},u.prototype.writeFloatBE=function(t,e,n){return P(this,t,e,!1,n)},u.prototype.writeDoubleLE=function(t,e,n){return F(this,t,e,!0,n)},u.prototype.writeDoubleBE=function(t,e,n){return F(this,t,e,!1,n)},u.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<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),t.length-e<r-n&&(r=t.length-e+n);var i,s=r-n;if(this===t&&n<e&&e<r)for(i=s-1;i>=0;--i)t[i+e]=this[i+n];else if(s<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)t[i+e]=this[i+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+s),e);return s},u.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var s;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(s=e;s<n;++s)this[s]=t;else{var a=u.isBuffer(t)?t:$(new u(t,r).toString()),o=a.length;for(s=0;s<n-e;++s)this[s+e]=a[s%o]}return this};var z=/[^+\/0-9A-Za-z-_]/g;function L(t){return t<16?"0"+t.toString(16):t.toString(16)}function $(t,e){var n;e=e||1/0;for(var r=t.length,i=null,s=[],a=0;a<r;++a){if((n=t.charCodeAt(a))>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;s.push(n)}else if(n<2048){if((e-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function B(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function q(t,e,n,r){for(var i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}}).call(this,n(96))},function(t,e,n){"use strict";function r(){if("undefined"!=typeof navigator&&null!=navigator){const t=navigator.userAgent||navigator.vendor||window.opera;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 i(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}n.r(e),n.d(e,"isMobile",(function(){return r})),n.d(e,"isBrowser",(function(){return i}))},function(t,e,n){"use strict";
/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function r(t,e=!1){console.log(t.toString(e))}n.d(e,"a",(function(){return r}))},function(t,e,n){"use strict";n.d(e,"a",(function(){return h}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(24),u=n(4),c=n(8),l=n(31);const h=Object(u.b)({all_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=null,n=!1){let u=Object(s.a)(t,"x","all","bool");const h={x:u},d={axis:e,keepDims:n};return r.a.runKernelFunc(t=>{const r=Object(a.I)(e,u.shape);let i=r;const s=Object(o.f)(i,u.rank);null!=s&&(u=Object(l.a)(u,s),i=Object(o.g)(i.length,u.rank));const h=t.all(u,i);if(n){const t=Object(o.e)(h.shape,r);return Object(c.a)(h,t)}return h},h,null,i.f,d)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return h}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(24),u=n(4),c=n(8),l=n(31);const h=Object(u.b)({any_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=null,n=!1){let u=Object(s.a)(t,"x","any","bool");const h={x:u},d={axis:e,keepDims:n};return r.a.runKernelFunc(t=>{const r=Object(a.I)(e,u.shape);let i=r;const s=Object(o.f)(i,u.rank);null!=s&&(u=Object(l.a)(u,s),i=Object(o.g)(i.length,u.rank));const h=t.any(u,i);if(n){const t=Object(o.e)(h.shape,r);return Object(c.a)(h,t)}return h},h,null,i.g,d)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(24),u=n(4),c=n(31);const l=Object(u.b)({argMax_:
/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=0){let n=Object(s.a)(t,"x","argMax");const u={x:n},l={axis:e};return r.a.runKernelFunc((t,r)=>{r([n]);let i=a.I(e,n.shape);const s=o.f(i,n.rank);return null!=s&&(n=Object(c.a)(n,s),i=o.g(i.length,n.rank)),t.argMax(n,i[0])},u,null,i.h,l)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(24),u=n(4),c=n(31);const l=Object(u.b)({argMin_:
/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=0){let n=Object(s.a)(t,"x","argMin");const u={x:n},l={axis:e};return r.a.runKernelFunc((t,r)=>{r([n]),null==e&&(e=0);let i=a.I(e,n.shape);const s=o.f(i,n.rank);return null!=s&&(n=Object(c.a)(n,s),i=o.g(i.length,n.rank)),t.argMin(n,i[0])},u,null,i.i,l)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(25),a=n(1),o=n(4);const u=Object(o.b)({atan2_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(a.a)(t,"a","atan2"),o=Object(a.a)(e,"b","atan2");[n,o]=Object(s.makeTypesMatch)(n,o);const u={a:n,b:o};return r.a.runKernelFunc((t,e)=>{const r=t.atan2(n,o);return e([n,o]),r},u,null,i.m)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(1),i=n(7),s=n(69),a=n(20),o=n(4),u=n(8);const c=Object(o.b)({conv1d_:function(t,e,n,o,c="NWC",l=1,h){const d=Object(r.a)(t,"x","conv1d"),p=Object(r.a)(e,"filter","conv1d");let f=d,m=!1;2===d.rank&&(m=!0,f=Object(u.a)(d,[1,d.shape[0],d.shape[1]])),i.b(3===f.rank,()=>`Error in conv1d: input must be rank 3, but got rank ${f.rank}.`),i.b(3===p.rank,()=>"Error in conv1d: filter must be rank 3, but got rank "+p.rank+"."),null!=h&&i.b(i.v(o),()=>`Error in conv1d: pad must be an integer when using, dimRoundingMode ${h} but got pad ${o}.`),i.b(f.shape[2]===p.shape[1],()=>`Error in conv1d: depth of input (${f.shape[2]}) must match input depth for filter ${p.shape[1]}.`),i.b(a.h(n,l),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${l}'`),i.b("NWC"===c,()=>`Error in conv1d: got dataFormat of ${c} but only NWC is currently supported.`);const g=Object(u.a)(p,[1,p.shape[0],p.shape[1],p.shape[2]]),b=Object(u.a)(f,[f.shape[0],1,f.shape[1],f.shape[2]]),y=[1,n],v=[1,l],w=Object(s.a)(b,g,y,o,"NHWC",v,h);return m?Object(u.a)(w,[w.shape[2],w.shape[3]]):Object(u.a)(w,[w.shape[0],w.shape[2],w.shape[3]])}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return a}));var r=n(1),i=n(142),s=n(4);const a=Object(s.b)({conv2dTranspose_:function(t,e,n,s,a,o){const u=Object(r.a)(t,"x","conv2dTranspose"),c=Object(r.a)(e,"filter","conv2dTranspose");return Object(i.a)(n,u,c,s,a,"NHWC",o)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({cosh_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","cosh"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.cosh(e);return n([e]),r},n,null,i.H)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4);const u=Object(o.b)({depthToSpace_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n="NHWC"){const o=Object(s.a)(t,"x","depthToSpace"),u="NHWC"===n?o.shape[1]:o.shape[2],c="NHWC"===n?o.shape[2]:o.shape[3],l="NHWC"===n?o.shape[3]:o.shape[1];a.b(u*e>=0,()=>`Negative dimension size caused by overflow when multiplying\n    ${u} and ${e}  for depthToSpace with input shape\n    ${o.shape}`),a.b(c*e>=0,()=>`Negative dimension size caused by overflow when multiplying\n    ${c} and ${e} for depthToSpace with input shape\n        ${o.shape}`),a.b(l%(e*e)==0,()=>`Dimension size must be evenly divisible by ${e*e} but is ${l} for depthToSpace with input shape ${o.shape}`);const h={x:o},d={blockSize:e,dataFormat:n};return r.a.runKernelFunc(t=>t.depthToSpace(o,e,n),h,null,i.K,d)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4),u=n(8);const c=Object(o.b)({dilation2d_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,o,c=[1,1],l="NHWC"){const h=Object(s.a)(t,"x","dilation2d"),d=Object(s.a)(e,"filter","dilation2d");a.b(3===h.rank||4===h.rank,()=>"Error in dilation2d: input must be rank 3 or 4, but got rank "+h.rank+"."),a.b(3===d.rank,()=>"Error in dilation2d: filter must be rank 3, but got rank "+d.rank+"."),a.b("NHWC"===l,()=>"Error in dilation2d: Only NHWC is currently supported, but got dataFormat of "+l);let p=h,f=!1;3===h.rank&&(p=Object(u.a)(h,[1,h.shape[0],h.shape[1],h.shape[2]]),f=!0);const m={x:p,filter:d},g={strides:n,pad:o,dilations:c},b=r.a.runKernel(i.P,m,g);return f?Object(u.a)(b,[b.shape[1],b.shape[2],b.shape[3]]):b}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(25),i=n(1),s=n(16),a=n(82),o=n(4),u=n(37),c=n(23);const l=Object(o.b)({divNoNan_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){let n=Object(i.a)(t,"a","div"),o=Object(i.a)(e,"b","div");[n,o]=Object(r.makeTypesMatch)(n,o);const l=Object(s.a)(n,o),h=Object(c.a)(l),d=Object(a.a)(o,h);return Object(u.a)(d,h,l)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(1),i=n(7),s=n(29),a=n(4),o=n(8);const u=Object(a.b)({dot_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){const n=Object(r.a)(t,"t1","dot"),a=Object(r.a)(e,"t2","dot");i.b(!(1!==n.rank&&2!==n.rank||1!==a.rank&&2!==a.rank),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${a.rank}.`);const u=1===n.rank?n.size:n.shape[1],c=1===a.rank?a.size:a.shape[0];if(i.b(u===c,()=>`Error in dot: inner dimensions of inputs must match, but got ${u} and ${c}.`),1===n.rank&&1===a.rank){const t=Object(o.a)(n,[1,-1]),e=Object(o.a)(a,[-1,1]),r=Object(s.a)(t,e);return Object(o.a)(r,[])}if(1===n.rank&&2===a.rank){const t=Object(o.a)(n,[1,-1]),e=Object(o.a)(a,[a.shape[0],a.shape[1]]),r=Object(s.a)(t,e);return Object(o.a)(r,[r.size])}if(2===n.rank&&1===a.rank){const t=Object(o.a)(a,[-1,1]),e=Object(s.a)(n,t);return Object(o.a)(e,[e.size])}{const t=Object(o.a)(a,[a.shape[0],a.shape[1]]);return Object(s.a)(n,t)}}})},function(t,e,n){"use strict";n.r(e),n.d(e,"segOpComputeOptimalWindowSize",(function(){return s})),n.d(e,"computeOutShape",(function(){return a})),n.d(e,"collectGatherOpShapeInfo",(function(){return o}));var r=n(7),i=n(171);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function s(t,e){let n,s=!1;for(t<=i.a?(n=t,s=!0):n=Object(r.G)(t,Math.floor(Math.sqrt(t)));!s;)n>e||n===t?s=!0:n=Object(r.G)(t,n+1);return n}function a(t,e,n){const r=[],i=t.length;for(let s=0;s<i;s++)s!==e?r.push(t[s]):r.push(n);return r}function o(t,e,n){const r=t.shape[n],i=[];let s=1,a=1;for(let e=0;e<n;e++)i.push(t.shape[e]),s*=t.shape[e];for(let t=0;t<e.rank;t++)i.push(e.shape[t]);for(let e=n+1;e<t.rank;e++)i.push(t.shape[e]),a*=t.shape[e];return{batchSize:s,sliceSize:a,dimSize:r,outputShape:i}}},function(t,e,n){"use strict";n.d(e,"a",(function(){return i})),n.d(e,"b",(function(){return s}));var r=n(7);
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const i=30;function s(t){return t<=i?t:Object(r.G)(t,Math.floor(Math.sqrt(t)))}},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(1),i=n(68),s=n(9),a=n(4),o=n(15);const u=Object(a.b)({leakyRelu_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=.2){const n=Object(r.a)(t,"x","leakyRelu");return Object(i.a)(Object(s.a)(Object(o.a)(e),n),n)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4),u=n(8);const c=Object(o.b)({localResponseNormalization_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=5,n=1,o=1,c=.5){const l=Object(s.a)(t,"x","localResponseNormalization");a.b(4===l.rank||3===l.rank,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got\n               rank ${l.rank}.`),a.b(a.v(e),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${e}.`);let h=l,d=!1;3===l.rank&&(d=!0,h=Object(u.a)(l,[1,l.shape[0],l.shape[1],l.shape[2]]));const p={x:h},f={depthRadius:e,bias:n,alpha:o,beta:c},m=r.a.runKernelFunc((t,r)=>{const i=t.localResponseNormalization4D(h,e,n,o,c);return r([h,i]),i},p,null,i.sb,f);return d?Object(u.a)(m,[m.shape[1],m.shape[2],m.shape[3]]):m}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({log1p_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","log1p"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.log1p(e);return n([e]),r},n,null,i.yb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({softplus_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","softplus"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.softplus(e);return n([e]),r},n,null,i.zc)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(1),i=n(18),s=n(62),a=n(102),o=n(130),u=n(4);const c=Object(u.b)({logicalXor_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){const n=Object(r.a)(t,"a","logicalXor","bool"),u=Object(r.a)(e,"b","logicalXor","bool");return Object(i.a)(n.shape,u.shape),Object(s.a)(Object(o.a)(t,e),Object(a.a)(Object(s.a)(t,e)))}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4);const u=Object(o.b)({mirrorPad_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n){a.b("reflect"===n||"symmetric"===n,()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`);const o=Object(s.a)(t,"x","mirrorPad");if(0===o.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");a.b(e.length===o.rank,()=>`Padding doesn't match input. Must be ${o.rank}. Got ${e.length}.`);const u="reflect"===n?1:0;for(let t=0;t<o.rank;t++)a.b(2===e[t].length,()=>"Invalid number of paddings. Must be length of 2 each."),a.b(e[t][0]>=0&&e[t][0]<=o.shape[t]-u&&e[t][1]>=0&&e[t][1]<=o.shape[t]-u,()=>`Padding in dimension ${t} cannot be greater than or equal to ${o.shape[t]-u} or less than 0 for input of shape `+o.shape);const c={paddings:e,mode:n},l={x:o};return r.a.runKernel(i.Nb,l,c)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return d}));var r=n(1),i=n(7),s=n(124),a=n(98),o=n(20),u=n(131),c=n(4),l=n(8),h=n(105);const d=Object(c.b)({pool_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,c,d,p){null==d&&(d=[1,1]),null==p&&(p=1),0===c&&(c="valid");const f=Object(r.a)(t,"x","maxPool");let m=f,g=!1;3===f.rank&&(g=!0,m=Object(l.a)(f,[1,f.shape[0],f.shape[1],f.shape[2]])),i.b(o.h(p,d),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${p} and dilations '${d}'`);const b=o.e(m.shape,e,p,d,c),y=[b.dilationHeight,b.dilationWidth];let v;v="same"===c?function(t,e){const n=t.map((t,n)=>t+(t-1)*(e[n]-1)).map(t=>t-1),r=n.map(t=>Math.floor(t/2)),i=n.map((t,e)=>t-r[e]);return n.map((t,e)=>[r[e],i[e]])}([b.filterHeight,b.filterWidth],y):[[0,0],[0,0]];const w=1===y[0]&&1===y[1],[x,_]=function(t,e,n){const r=n.map(t=>t[0]),i=n.map(t=>t[1]),s=t.concat(r,i),a=e.map((t,e)=>(t-s[e]%t)%t),o=i.map((t,e)=>t+a[e]),u=e.map((t,e)=>[r[e],o[e]]),c=e.map((t,e)=>[0,a[e]]);return[u,c]}([b.inHeight,b.inWidth],y,v),O=w?c:"valid",S=w?m:Object(h.a)(m,y,x),k=("avg"===n?()=>Object(s.a)(S,e,p,O):()=>Object(u.a)(S,e,p,O))(),T=w?k:Object(a.a)(k,y,_);return g?Object(l.a)(T,[T.shape[1],T.shape[2],T.shape[3]]):T}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return d}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(24),u=n(12),c=n(4),l=n(8),h=n(31);const d=Object(c.b)({prod_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=null,n=!1){let c=Object(s.a)(t,"x","prod");"bool"===c.dtype&&(c=Object(u.a)(c,"int32"));const d={x:c},p={axis:e,keepDims:n};return r.a.runKernelFunc(t=>{const r=Object(a.I)(e,c.shape),i=Object(o.f)(r,c.rank);let s=r,u=c;null!=i&&(u=Object(h.a)(c,i),s=Object(o.g)(s.length,c.rank));let d=t.prod(u,s);if(n){const t=Object(o.e)(d.shape,r);d=Object(l.a)(d,t)}return d},d,null,i.bc,p)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return a}));var r=n(39),i=n(4),s=n(109);const a=Object(i.b)({randomUniform_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=0,n=1,i="float32",a){const o=Object(r.a)(t,i),u=new s.c(e,n,null,a);for(let t=0;t<o.values.length;t++)o.values[t]=u.nextValue();return o.toTensor()}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({rsqrt_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","rsqrt"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.rsqrt(e);return n([e]),r},n,null,i.pc)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({selu_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","selu"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.selu(e);return n([e]),r},n,null,i.sc)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(1),i=n(7),s=n(69),a=n(81),o=n(4),u=n(8);const c=Object(o.b)({separableConv2d_:function(t,e,n,o,c,l=[1,1],h="NHWC"){const d=Object(r.a)(t,"x","separableConv2d"),p=Object(r.a)(e,"depthwiseFilter","separableConv2d"),f=Object(r.a)(n,"pointwiseFilter","separableConv2d");let m=d,g=!1;if(3===d.rank&&(g=!0,m=Object(u.a)(d,[1,d.shape[0],d.shape[1],d.shape[2]])),"NCHW"===h)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");i.b(4===m.rank,()=>`Error in separableConv2d: input must be rank 4, but got rank ${m.rank}.`),i.b(4===p.rank,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${p.rank}.`),i.b(4===f.rank,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${p.rank}.`),i.b(1===f.shape[0],()=>`Error in separableConv2d: the first dimension of pointwise filter  must be 1, but got ${f.shape[0]}.`),i.b(1===f.shape[1],()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${f.shape[1]}.`);const b=p.shape[2],y=p.shape[3];i.b(f.shape[2]===b*y,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${b*y}, but got ${f.shape[2]}.`);const v=Object(a.a)(m,p,o,c,h,l),w=Object(s.a)(v,f,1,"valid",h);return g?Object(u.a)(w,[w.shape[1],w.shape[2],w.shape[3]]):w}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({sin_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","sin"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.sin(e);return n([e]),r},n,null,i.vc)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({sinh_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","sinh"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.sinh(e);return n([e]),r},n,null,i.wc)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return f}));var r=n(51),i=n(32),s=n(100),a=n(9),o=n(4),u=n(94),c=n(8),l=n(45),h=n(15),d=n(28),p=n(116);const f=Object(o.b)({irfft_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=t.shape[t.shape.length-1],n=t.size/e;let o;if(e<=2){const r=Object(c.a)(t,[n,e]);o=Object(p.a)(r)}else{const f=[n,2*(e-1)],m=Object(c.a)(Object(u.a)(t),[n,e]),g=Object(c.a)(Object(s.a)(t),[n,e]),b=Object(l.a)(Object(d.a)(m,[0,1],[n,e-2]),1),y=Object(a.a)(Object(l.a)(Object(d.a)(g,[0,1],[n,e-2]),1),Object(h.a)(-1)),v=Object(i.a)([m,b],1),w=Object(i.a)([g,y],1),x=Object(c.a)(Object(r.a)(v,w),[f[0],f[1]]);o=Object(p.a)(x)}if(o=Object(u.a)(o),3===t.rank&&0!==t.shape[0]){const e=o,n=t.shape[0];o=Object(c.a)(o,[n,o.shape[0]/n,o.shape[1]]),e.dispose()}return o}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(7);function i(t,e,n=0){let i=[];if("number"==typeof e)Object(r.b)(t.shape[n]%e==0,()=>"Number of splits must evenly divide the axis."),i=new Array(e).fill(t.shape[n]/e);else{const s=e.reduce((t,e)=>(-1===e&&(t+=1),t),0);Object(r.b)(s<=1,()=>"There should be only one negative value in split array.");const a=e.indexOf(-1);if(-1!==a){const r=e.reduce((t,e)=>e>0?t+e:t);e[a]=t.shape[n]-r}Object(r.b)(t.shape[n]===e.reduce((t,e)=>t+e),()=>"The sum of sizes must match the size of the axis dimension."),i=e}return i}},function(t,e,n){"use strict";n.d(e,"a",(function(){return a}));var r=n(1),i=n(7),s=n(47);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function a(t,e,n){if(Object(i.d)(t),null!=e&&3!==e.length)throw new Error("tensor3d() requires shape to have three numbers");const a=Object(r.c)(t,n);if(3!==a.length&&1!==a.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===a.length&&null==e)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Object(s.a)(t,e,a,n)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({topk_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=1,n=!0){const a=Object(s.a)(t,"x","topk");if(0===a.rank)throw new Error("topk() expects the input to be of rank 1 or higher");const o=a.shape[a.shape.length-1];if(e>o)throw new Error(`'k' passed to topk() must be <= the last dimension (${o}) but got `+e);const u={x:a},c={k:e,sorted:n},[l,h]=r.a.runKernelFunc(t=>t.topk(a,e,n),u,null,i.Nc,c);return{values:l,indices:h}}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4);const u=Object(o.b)({unique_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=0){const n=Object(s.a)(t,"x","unique",null);Object(a.b)(n.rank>0,()=>"The input tensor must be at least 1D");const o={x:n},u={axis:e},[c,l]=r.a.runKernel(i.Pc,o,u);return{values:c,indices:l}}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));var r=n(192),i=n(1);const s=
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
async function(t){const e=Object(i.a)(t,"condition","whereAsync","bool"),n=await e.data(),s=Object(r.a)(e.shape,n);return t!==e&&e.dispose(),s}},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(39);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function i(t,e){const n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(t);const i=Object(r.a)(t,"int32"),s=Object(r.a)([n.length,t.length],"int32");for(let e=0;e<n.length;e++){const r=i.indexToLoc(n[e]),a=e*t.length;s.values.set(r,a)}return s.toTensor()}},function(t,e,n){"use strict";n.d(e,"b",(function(){return i})),n.d(e,"a",(function(){return s}));var r=n(0);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function i(t){const e=new Float32Array(t.length);for(let n=0;n<t.length;++n)e[n]=Math.abs(t[n]);return e}const s={kernelName:r.Abs,backendName:"cpu",kernelFunc:t=>{const{x:e}=t.inputs,n=t.backend;let s=new Float32Array(r.util.sizeFromShape(e.shape));if("complex64"!==e.dtype){s=i(n.data.get(e.dataId).values)}else{const t=n.data.get(e.dataId),r=t.complexTensorInfos.real,i=t.complexTensorInfos.imag,a=n.data.get(r.dataId).values,o=n.data.get(i.dataId).values;for(let t=0;t<a.length;t++){const e=a[t],n=o[t];s[t]=Math.hypot(e,n)}}return n.makeOutput(s,e.shape,"float32")}}},function(t,e,n){"use strict";n.d(e,"b",(function(){return a})),n.d(e,"a",(function(){return u}));var r=n(0),i=n(73),s=n(17);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const a=Object(i.a)(t=>Math.ceil(t)),o=Object(s.b)(r.Ceil,a),u={kernelName:r.Ceil,backendName:"cpu",kernelFunc:o}},function(t,e,n){"use strict";n.d(e,"b",(function(){return a})),n.d(e,"a",(function(){return u}));var r=n(0),i=n(73),s=n(17);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const a=Object(i.a)(t=>Math.exp(t)),o=Object(s.b)(r.Exp,a),u={kernelName:r.Exp,backendName:"cpu",kernelFunc:o}},function(t,e,n){"use strict";n.d(e,"b",(function(){return a})),n.d(e,"a",(function(){return u}));var r=n(0),i=n(73),s=n(17);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const a=Object(i.a)(t=>Math.expm1(t)),o=Object(s.b)(r.Expm1,a),u={kernelName:r.Expm1,backendName:"cpu",kernelFunc:o}},function(t,e,n){"use strict";n.d(e,"b",(function(){return a})),n.d(e,"a",(function(){return u}));var r=n(0),i=n(73),s=n(17);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const a=Object(i.a)(t=>Math.floor(t)),o=Object(s.b)(r.Floor,a),u={kernelName:r.Floor,backendName:"cpu",kernelFunc:o}},function(t,e,n){"use strict";n.d(e,"b",(function(){return a})),n.d(e,"a",(function(){return u}));var r=n(0),i=n(73),s=n(17);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const a=Object(i.a)(t=>Math.log(t)),o=Object(s.b)(r.Log,a),u={kernelName:r.Log,backendName:"cpu",kernelFunc:o}},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(0);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function i(t,e,n,i){const s=r.util.getTypedArrayFromDType(i,r.util.sizeFromShape(n));for(let n=0;n<s.length;++n){const r=n*e;let i=t[r];for(let n=0;n<e;++n){const e=t[r+n];e>i&&(i=e)}s[n]=i}return s}},function(t,e,n){"use strict";n.d(e,"b",(function(){return a})),n.d(e,"a",(function(){return u}));var r=n(0),i=n(48),s=n(53);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const a=Object(i.a)((t,e)=>t!==e?1:0),o=Object(s.a)(r.NotEqual,a,null,"bool"),u={kernelName:r.NotEqual,backendName:"cpu",kernelFunc:o}},function(t,e,n){"use strict";n.d(e,"b",(function(){return a})),n.d(e,"a",(function(){return u}));var r=n(0),i=n(73),s=n(17);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const a=Object(i.a)(t=>1/Math.sqrt(t)),o=Object(s.b)(r.Rsqrt,a),u={kernelName:r.Rsqrt,backendName:"cpu",kernelFunc:o}},function(t,e,n){"use strict";n.d(e,"b",(function(){return a})),n.d(e,"a",(function(){return u}));var r=n(0),i=n(48),s=n(53);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const a=Object(i.a)((t,e)=>{const n=t-e;return n*n}),o=Object(s.a)(r.SquaredDifference,a),u={kernelName:r.SquaredDifference,backendName:"cpu",kernelFunc:o}},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(0);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function i(t,e,n,i){const s=r.util.parseAxisParam(e,n)[0],a=[1,n[0],1];for(let t=0;t<s;t++)a[0]*=n[t];a[1]=n[s];for(let t=s+1;t<n.length;t++)a[2]*=n[t];const o={},u=new Int32Array(n[s]),c=new r.TensorBuffer(a,i,t),l=[],h=1===a[0]&&1===a[2];for(let e=0;e<n[s];e++){let n;if(h)n=t[e].toString();else{const t=[];for(let n=0;n<a[0];n++)for(let r=0;r<a[2];r++)t.push(c.get(n,e,r));n=t.join(",")}if(void 0!==o[n])u[e]=o[n];else{const t=Object.keys(o).length;o[n]=t,u[e]=t,l.push(e)}}const d=a.slice();d[1]=Object.keys(o).length;const p=new r.TensorBuffer(d,i);l.forEach((t,e)=>{for(let n=0;n<a[0];n++)for(let r=0;r<a[2];r++)p.set(c.get(n,t,r),n,e,r)});const f=n.slice();return f[s]=d[1],{outputValues:p.values,outputShape:f,indices:u}}},function(t,e,n){"use strict";n.r(e);var r=n(193);n.d(e,"simpleAbsImpl",(function(){return r.b}));var i=n(70);n.d(e,"addImpl",(function(){return i.c}));var s=n(194);n.d(e,"ceilImpl",(function(){return s.b}));var a=n(195);n.d(e,"expImpl",(function(){return a.b}));var o=n(196);n.d(e,"expm1Impl",(function(){return o.b}));var u=n(197);n.d(e,"floorImpl",(function(){return u.b}));var c=n(198);n.d(e,"logImpl",(function(){return c.b}));var l=n(199);n.d(e,"maxImpl",(function(){return l.a}));var h=n(139);n.d(e,"multiplyImpl",(function(){return h.c}));var d=n(200);n.d(e,"notEqualImpl",(function(){return d.b}));var p=n(201);n.d(e,"rsqrtImpl",(function(){return p.b}));var f=n(117);n.d(e,"sliceImpl",(function(){return f.c}));var m=n(202);n.d(e,"squaredDifferenceImpl",(function(){return m.b}));var g=n(140);n.d(e,"subImpl",(function(){return g.c}));var b=n(141);n.d(e,"transposeImpl",(function(){return b.a}));var y=n(203);n.d(e,"uniqueImpl",(function(){return y.a}))},function(t,e,n){"use strict";n.r(e),n.d(e,"version_webgl",(function(){return lr})),n.d(e,"MathBackendWebGL",(function(){return cr})),n.d(e,"setWebGLContext",(function(){return u})),n.d(e,"GPGPUContext",(function(){return tn})),n.d(e,"gpgpu_util",(function(){return i})),n.d(e,"webgl_util",(function(){return r})),n.d(e,"forceHalfFloat",(function(){return hr})),n.d(e,"webgl",(function(){return dr}));var r={};n.r(r),n.d(r,"callAndCheck",(function(){return b})),n.d(r,"canBeRepresented",(function(){return y})),n.d(r,"getWebGLErrorMessage",(function(){return v})),n.d(r,"getExtensionOrThrow",(function(){return w})),n.d(r,"createVertexShader",(function(){return x})),n.d(r,"createFragmentShader",(function(){return _})),n.d(r,"createProgram",(function(){return S})),n.d(r,"linkProgram",(function(){return k})),n.d(r,"validateProgram",(function(){return T})),n.d(r,"createStaticVertexBuffer",(function(){return C})),n.d(r,"createStaticIndexBuffer",(function(){return A})),n.d(r,"getNumChannels",(function(){return N})),n.d(r,"createTexture",(function(){return I})),n.d(r,"validateTextureSize",(function(){return E})),n.d(r,"createFramebuffer",(function(){return j})),n.d(r,"bindVertexBufferToProgramAttribute",(function(){return M})),n.d(r,"bindTextureUnit",(function(){return D})),n.d(r,"unbindTextureUnit",(function(){return R})),n.d(r,"getProgramUniformLocationOrThrow",(function(){return P})),n.d(r,"getProgramUniformLocation",(function(){return F})),n.d(r,"bindTextureToProgramUniformSampler",(function(){return z})),n.d(r,"bindCanvasToFramebuffer",(function(){return L})),n.d(r,"bindColorTextureToFramebuffer",(function(){return $})),n.d(r,"unbindColorTextureFromFramebuffer",(function(){return B})),n.d(r,"validateFramebuffer",(function(){return q})),n.d(r,"getFramebufferErrorMessage",(function(){return V})),n.d(r,"getBatchDim",(function(){return G})),n.d(r,"getRowsCols",(function(){return H})),n.d(r,"getShapeAs3D",(function(){return K})),n.d(r,"getTextureShapeFromLogicalShape",(function(){return Q})),n.d(r,"isReshapeFree",(function(){return Y})),n.d(r,"getWebGLMaxTextureSize",(function(){return tt})),n.d(r,"resetMaxTextureSize",(function(){return et})),n.d(r,"resetMaxTexturesInShader",(function(){return nt})),n.d(r,"getMaxTexturesInShader",(function(){return rt})),n.d(r,"getWebGLDisjointQueryTimerVersion",(function(){return it})),n.d(r,"hasExtension",(function(){return st})),n.d(r,"isWebGLVersionEnabled",(function(){return at})),n.d(r,"isCapableOfRenderingToFloatTexture",(function(){return ot})),n.d(r,"isDownloadFloatTextureEnabled",(function(){return ut})),n.d(r,"isWebGLFenceEnabled",(function(){return lt})),n.d(r,"assertNotComplex",(function(){return ht}));var i={};n.r(i),n.d(i,"createVertexShader",(function(){return je})),n.d(i,"createVertexBuffer",(function(){return Me})),n.d(i,"createIndexBuffer",(function(){return De})),n.d(i,"getInternalFormatForFloat32MatrixTexture",(function(){return Pe})),n.d(i,"createFloat32MatrixTexture",(function(){return Fe})),n.d(i,"getInternalFormatForFloat16MatrixTexture",(function(){return ze})),n.d(i,"createFloat16MatrixTexture",(function(){return Le})),n.d(i,"getInternalFormatForUnsignedBytesMatrixTexture",(function(){return $e})),n.d(i,"createUnsignedBytesMatrixTexture",(function(){return Be})),n.d(i,"getInternalFormatForPackedMatrixTexture",(function(){return qe})),n.d(i,"createPackedMatrixTexture",(function(){return Ve})),n.d(i,"getInternalFormatForFloat16PackedMatrixTexture",(function(){return Ue})),n.d(i,"createFloat16PackedMatrixTexture",(function(){return We})),n.d(i,"bindVertexProgramAttributeStreams",(function(){return Ge})),n.d(i,"uploadDenseMatrixToTexture",(function(){return He})),n.d(i,"uploadPixelDataToTexture",(function(){return Ke})),n.d(i,"createBufferFromOutputTexture",(function(){return Qe})),n.d(i,"downloadFloat32MatrixFromBuffer",(function(){return Xe})),n.d(i,"downloadByteEncodedFloatMatrixFromOutputTexture",(function(){return Ye})),n.d(i,"downloadPackedMatrixFromBuffer",(function(){return Je})),n.d(i,"downloadMatrixFromPackedOutputTexture",(function(){return Ze}));var s=n(0);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const a={},o={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function u(t,e){a[t]=e}function c(t){if(!(t in a)){const e=function(t){if(1!==t&&2!==t)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const e=function(t){if("undefined"!=typeof OffscreenCanvas&&2===t)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}(t);if(e.addEventListener("webglcontextlost",e=>{e.preventDefault(),delete a[t]},!1),1===t)return e.getContext("webgl",o)||e.getContext("experimental-webgl",o);return e.getContext("webgl2",o)}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */(t);if(null===e)return console.log("Could not get context for WebGL version",t),null;a[t]=e}const e=a[t];return e.isContextLost()?(delete a[t],c(t)):(e.disable(e.DEPTH_TEST),e.disable(e.STENCIL_TEST),e.disable(e.BLEND),e.disable(e.DITHER),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SAMPLE_COVERAGE),e.enable(e.SCISSOR_TEST),e.enable(e.CULL_FACE),e.cullFace(e.BACK),a[t])}var l,h,d;function p(t,e){return[e,t]}function f(t){const e=s.util.sizeFromShape(t),n=Math.ceil(e/4);return s.util.sizeToSquarishShape(n)}function m(t,e){return[Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(t/2))]}function g(t,e){const n=t;let r,i,a,o,u,c,l,h,d,p;return 2===Object(s.env)().getNumber("WEBGL_VERSION")?(r=n.R32F,i=n.R16F,a=n.RGBA16F,o=n.RGBA32F,u=n.RED,l=4,h=1,d=n.HALF_FLOAT,p=n.FLOAT):(r=t.RGBA,i=t.RGBA,a=t.RGBA,o=n.RGBA,u=t.RGBA,l=4,h=4,d=null!=e?e.HALF_FLOAT_OES:null,p=t.FLOAT),c=t.RGBA,{internalFormatFloat:r,internalFormatHalfFloat:i,internalFormatPackedHalfFloat:a,internalFormatPackedFloat:o,textureFormatFloat:u,downloadTextureFormat:c,downloadUnpackNumChannels:l,defaultNumChannels:h,textureTypeHalfFloat:d,textureTypeFloat:p}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function b(t,e){const n=e();return Object(s.env)().getBool("DEBUG")&&function(t){const e=t.getError();if(e!==t.NO_ERROR)throw new Error("WebGL Error: "+v(t,e))}(t),n}!function(t){t[t.DENSE=0]="DENSE",t[t.SHARED_BATCH=1]="SHARED_BATCH"}(l||(l={})),function(t){t[t.RENDER=0]="RENDER",t[t.UPLOAD=1]="UPLOAD",t[t.PIXELS=2]="PIXELS",t[t.DOWNLOAD=3]="DOWNLOAD"}(h||(h={})),function(t){t[t.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",t[t.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",t[t.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",t[t.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",t[t.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"}(d||(d={}));function y(t){return!!(Object(s.env)().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===t||5.96e-8<Math.abs(t)&&Math.abs(t)<65504)}function v(t,e){switch(e){case t.NO_ERROR:return"NO_ERROR";case t.INVALID_ENUM:return"INVALID_ENUM";case t.INVALID_VALUE:return"INVALID_VALUE";case t.INVALID_OPERATION:return"INVALID_OPERATION";case t.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case t.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case t.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return"Unknown error code "+e}}function w(t,e){return U(t,()=>t.getExtension(e),'Extension "'+e+'" not supported on this browser.')}function x(t,e){const n=U(t,()=>t.createShader(t.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(b(t,()=>t.shaderSource(n,e)),b(t,()=>t.compileShader(n)),!1===t.getShaderParameter(n,t.COMPILE_STATUS))throw console.log(t.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}function _(t,e){const n=U(t,()=>t.createShader(t.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(b(t,()=>t.shaderSource(n,e)),b(t,()=>t.compileShader(n)),!1===t.getShaderParameter(n,t.COMPILE_STATUS))throw function(t,e){const n=O.exec(e);if(null==n)return console.log("Couldn't parse line number in error: "+e),void console.log(t);const r=+n[1],i=t.split("\n"),a=i.length.toString().length+2,o=i.map((t,e)=>s.util.rightPad((e+1).toString(),a)+t);let u=0;for(let t=0;t<o.length;t++)u=Math.max(o[t].length,u);const c=o.slice(0,r-1),l=o.slice(r-1,r),h=o.slice(r);console.log(c.join("\n")),console.log(e.split("\n")[0]),console.log("%c "+s.util.rightPad(l[0],u),"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(h.join("\n"))}(e,t.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}const O=/ERROR: [0-9]+:([0-9]+):/g;function S(t){return U(t,()=>t.createProgram(),"Unable to create WebGLProgram.")}function k(t,e){if(b(t,()=>t.linkProgram(e)),!1===t.getProgramParameter(e,t.LINK_STATUS))throw console.log(t.getProgramInfoLog(e)),new Error("Failed to link vertex and fragment shaders.")}function T(t,e){if(b(t,()=>t.validateProgram(e)),!1===t.getProgramParameter(e,t.VALIDATE_STATUS))throw console.log(t.getProgramInfoLog(e)),new Error("Shader program validation failed.")}function C(t,e){const n=U(t,()=>t.createBuffer(),"Unable to create WebGLBuffer");return b(t,()=>t.bindBuffer(t.ARRAY_BUFFER,n)),b(t,()=>t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW)),n}function A(t,e){const n=U(t,()=>t.createBuffer(),"Unable to create WebGLBuffer");return b(t,()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n)),b(t,()=>t.bufferData(t.ELEMENT_ARRAY_BUFFER,e,t.STATIC_DRAW)),n}function N(){return 2===Object(s.env)().getNumber("WEBGL_VERSION")?1:4}function I(t){return U(t,()=>t.createTexture(),"Unable to create WebGLTexture.")}function E(t,e){const n=Object(s.env)().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t<=0||e<=0){throw new Error("Requested texture size "+`[${t}x${e}]`+" is invalid.")}if(t>n||e>n){throw new Error("Requested texture size "+`[${t}x${e}]`+" greater than WebGL maximum on this browser / GPU "+`[${n}x${n}]`+".")}}function j(t){return U(t,()=>t.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function M(t,e,n,r,i,s,a){const o=t.getAttribLocation(e,n);return-1!==o&&(b(t,()=>t.bindBuffer(t.ARRAY_BUFFER,r)),b(t,()=>t.vertexAttribPointer(o,i,t.FLOAT,!1,s,a)),b(t,()=>t.enableVertexAttribArray(o)),!0)}function D(t,e,n){W(t,n),b(t,()=>t.activeTexture(t.TEXTURE0+n)),b(t,()=>t.bindTexture(t.TEXTURE_2D,e))}function R(t,e){W(t,e),b(t,()=>t.activeTexture(t.TEXTURE0+e)),b(t,()=>t.bindTexture(t.TEXTURE_2D,null))}function P(t,e,n){return U(t,()=>t.getUniformLocation(e,n),'uniform "'+n+'" not present in program.')}function F(t,e,n){return t.getUniformLocation(e,n)}function z(t,e,n,r){b(t,()=>D(t,e,r)),b(t,()=>t.uniform1i(n,r))}function L(t){b(t,()=>t.bindFramebuffer(t.FRAMEBUFFER,null)),b(t,()=>t.viewport(0,0,t.canvas.width,t.canvas.height)),b(t,()=>t.scissor(0,0,t.canvas.width,t.canvas.height))}function $(t,e,n){b(t,()=>t.bindFramebuffer(t.FRAMEBUFFER,n)),b(t,()=>t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0))}function B(t,e){b(t,()=>t.bindFramebuffer(t.FRAMEBUFFER,e)),b(t,()=>t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,null,0))}function q(t){const e=t.checkFramebufferStatus(t.FRAMEBUFFER);if(e!==t.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+V(t,e))}function V(t,e){switch(e){case t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case t.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return"unknown error "+e}}function U(t,e,n){const r=b(t,()=>e());if(null==r)throw new Error(n);return r}function W(t,e){const n=t.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=e+t.TEXTURE0;if(r<t.TEXTURE0||r>n){throw new Error(`textureUnit must be in ${`[gl.TEXTURE0, gl.TEXTURE${n}]`}.`)}}function G(t,e=2){return s.util.sizeFromShape(t.slice(0,t.length-e))}function H(t){if(0===t.length)throw Error("Cannot get rows and columns of an empty shape array.");return[t.length>1?t[t.length-2]:1,t[t.length-1]]}function K(t){let e=[1,1,1];return 0===t.length||1===t.length&&1===t[0]||(e=[G(t),...H(t)]),e}function Q(t,e=!1){let n=Object(s.env)().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e&&(n*=2,1===(t=t.map((e,n)=>n>=t.length-2?s.util.nearestLargerEven(t[n]):t[n])).length&&(t=[2,t[0]])),2!==t.length){const e=s.util.squeezeShape(t);t=e.newShape}let r=s.util.sizeFromShape(t);if(t.length<=1&&r<=n)return[1,r];if(2===t.length&&t[0]<=n&&t[1]<=n)return t;if(3===t.length&&t[0]*t[1]<=n&&t[2]<=n)return[t[0]*t[1],t[2]];if(3===t.length&&t[0]<=n&&t[1]*t[2]<=n)return[t[0],t[1]*t[2]];if(4===t.length&&t[0]*t[1]*t[2]<=n&&t[3]<=n)return[t[0]*t[1]*t[2],t[3]];if(4===t.length&&t[0]<=n&&t[1]*t[2]*t[3]<=n)return[t[0],t[1]*t[2]*t[3]];if(e){const e=G(t);let n=2,i=2;return t.length&&([n,i]=H(t)),r=e*(n/2)*(i/2),s.util.sizeToSquarishShape(r).map(t=>2*t)}return s.util.sizeToSquarishShape(r)}function X(t){return t%2==0}function Y(t,e){if(t=t.slice(-2),e=e.slice(-2),s.util.arraysEqual(t,e))return!0;if(!t.length||!e.length)return!0;if(0===t[0]||0===t[1]||0===e[0]||0===e[1])return!0;if(t.length!==e.length){const n=t.slice(-1)[0],r=e.slice(-1)[0];if(n===r)return!0;if(X(n)&&X(r)&&(1===t[0]||1===e[0]))return!0}return t[1]===e[1]&&X(t[0])&&X(e[0])}let J,Z;function tt(t){if(null==J){const e=c(t);J=e.getParameter(e.MAX_TEXTURE_SIZE)}return J}function et(){J=null}function nt(){Z=null}function rt(t){if(null==Z){const e=c(t);Z=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,Z)}function it(t){if(0===t)return 0;let e;const n=c(t);return e=st(n,"EXT_disjoint_timer_query_webgl2")&&2===t?2:st(n,"EXT_disjoint_timer_query")?1:0,e}function st(t,e){return null!=t.getExtension(e)}function at(t){try{if(null!=c(t))return!0}catch(t){return console.log("Error when getting WebGL context: ",t),!1}return!1}function ot(t){if(0===t)return!1;const e=c(t);if(1===t){if(!st(e,"OES_texture_float"))return!1}else if(!st(e,"EXT_color_buffer_float"))return!1;return ct(e)}function ut(t){if(0===t)return!1;const e=c(t);if(1!==t){if(st(e,"EXT_color_buffer_float"))return ct(e);const t="EXT_color_buffer_half_float";if(st(e,t)){const n=e.getExtension(t);return function(t,e){const n=g(t,e),r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r);t.texImage2D(t.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);const i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0);const s=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(r),t.deleteFramebuffer(i),s}(e,n)}return!1}if(!st(e,"OES_texture_float"))return!1;if(!st(e,"WEBGL_color_buffer_float"))return!1;return ct(e)}function ct(t){const e=g(t),n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n);t.texImage2D(t.TEXTURE_2D,0,e.internalFormatFloat,1,1,0,e.textureFormatFloat,e.textureTypeFloat,null);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0);const i=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(n),t.deleteFramebuffer(r),i}function lt(t){if(2!==t)return!1;return null!=c(t).fenceSync}function ht(t,e){Array.isArray(t)||(t=[t]),t.forEach(t=>{null!=t&&s.util.assert("complex64"!==t.dtype,()=>e+" does not support complex64 tensors in the WebGL backend.")})}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const dt=Object(s.env)();dt.registerFlag("HAS_WEBGL",()=>dt.getNumber("WEBGL_VERSION")>0),dt.registerFlag("WEBGL_VERSION",()=>at(2)?2:at(1)?1:0),dt.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",()=>!1),dt.registerFlag("WEBGL_BUFFER_SUPPORTED",()=>2===dt.get("WEBGL_VERSION")),dt.registerFlag("WEBGL_CPU_FORWARD",()=>!0),dt.registerFlag("WEBGL_FORCE_F16_TEXTURES",()=>!1),dt.registerFlag("WEBGL_PACK",()=>dt.getBool("HAS_WEBGL")),dt.registerFlag("WEBGL_PACK_NORMALIZATION",()=>dt.getBool("WEBGL_PACK")),dt.registerFlag("WEBGL_PACK_CLIP",()=>dt.getBool("WEBGL_PACK")),dt.registerFlag("WEBGL_PACK_DEPTHWISECONV",()=>!1),dt.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",()=>dt.getBool("WEBGL_PACK")),dt.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",()=>dt.getBool("WEBGL_PACK")),dt.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",()=>dt.getBool("WEBGL_PACK")),dt.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",()=>dt.getBool("WEBGL_PACK")),dt.registerFlag("WEBGL_PACK_REDUCE",()=>dt.getBool("WEBGL_PACK")),dt.registerFlag("WEBGL_LAZILY_UNPACK",()=>dt.getBool("WEBGL_PACK")),dt.registerFlag("WEBGL_CONV_IM2COL",()=>dt.getBool("WEBGL_PACK")),dt.registerFlag("WEBGL_MAX_TEXTURE_SIZE",()=>tt(dt.getNumber("WEBGL_VERSION"))),dt.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>rt(dt.getNumber("WEBGL_VERSION"))),dt.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{const t=dt.getNumber("WEBGL_VERSION");return 0===t?0:it(t)}),dt.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>dt.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!s.device_util.isMobile()),dt.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>ot(dt.getNumber("WEBGL_VERSION"))),dt.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",()=>!dt.getBool("WEBGL_FORCE_F16_TEXTURES")&&dt.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")),dt.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",()=>ut(dt.getNumber("WEBGL_VERSION"))),dt.registerFlag("WEBGL_FENCE_API_ENABLED",()=>lt(dt.getNumber("WEBGL_VERSION"))),dt.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>dt.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0),dt.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",()=>-1,t=>{if(t<0&&-1!==t)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${t}.`)});var pt=n(204);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const{simpleAbsImpl:ft,addImpl:mt,ceilImpl:gt,expImpl:bt,expm1Impl:yt,floorImpl:vt,logImpl:wt,maxImpl:xt,multiplyImpl:_t,rsqrtImpl:Ot,sliceImpl:St,subImpl:kt,transposeImpl:Tt,uniqueImpl:Ct}=pt;
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class At{constructor(t,e){this.outputShape=[],this.outputShape=t,this.variableNames=e.map((t,e)=>"T"+e);const n=[];this.variableNames.forEach(t=>{n.push(`float v${t} = get${t}AtOutCoords();`)});const r=this.variableNames.map(t=>"v"+t).join(" + ");this.userCode=`\n      void main() {\n        ${n.join("\n        ")}\n\n        float result = ${r};\n        setOutput(result);\n      }\n    `}}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Nt{constructor(t,e){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.variableNames=e.map((t,e)=>"T"+e);const n=[];this.variableNames.forEach(t=>{n.push(`vec4 v${t} = get${t}AtOutCoords();`)});const r=this.variableNames.map(t=>"v"+t).join(" + ");this.userCode=`\n      void main() {\n        ${n.join("\n        ")}\n\n        vec4 result = ${r};\n        setOutput(result);\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class It{constructor(t,e,n){this.variableNames=["A"];const{windowSize:r,batchSize:i,outSize:s}=t;n||this.variableNames.push("bestIndicesA"),this.outputShape=[i,s];const a="max"===e?">":"<",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 ${a} bestValue) {\n            bestValue = candidate;\n            bestIndex = inIdx;\n          }\n        }\n        setOutput(float(bestIndex));\n      }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function Et(t,e){return["x","y","z","w","u","v"].slice(0,e).map(e=>`${t}.${e}`)}function jt(t,e){return 1===e?[t]:Et(t,e)}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function Mt(){let t,e,n,r,i,a,o,u,c,l;return 2===Object(s.env)().getNumber("WEBGL_VERSION")?(t="#version 300 es",e="in",n="out",r="in",i="texture",a="outputColor",o="out vec4 outputColor;",u="\n      bool isnan_custom(float val) {\n        return (val > 0.0 || val < 0.0) ? false : val != 0.0;\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    ",c="",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    "):(t="",e="attribute",n="varying",r="varying",i="texture2D",a="gl_FragColor",o="",u="\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    ",c="\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:t,attribute:e,varyingVs:n,varyingFs:r,texture2D:i,output:a,defineOutput:o,defineSpecialNaN:u,defineSpecialInf:c,defineRound:l}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function Dt(t,e,n="index"){const r=s.util.computeStrides(e);return r.map((e,i)=>`${`int ${t[i]} = ${n} / ${e}`}; ${i===r.length-1?`int ${t[i+1]} = ${n} - ${t[i]} * ${e}`:`index -= ${t[i]} * ${e}`};`).join("")}function Rt(t){const e=s.util.computeStrides(t).map(t=>t.toString());return`\n  int getFlatIndex(ivec3 coords) {\n    return coords.x * ${e[0]} + coords.y * ${e[1]} + coords.z;\n  }\n`}const Pt="\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:Ft}=s.backend_util;
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function zt(t,e,n,r){const i=[];t.forEach(t=>{const e=s.util.sizeFromShape(t.shapeInfo.logicalShape);t.shapeInfo.isUniform?i.push(`uniform float ${t.name}${e>1?`[${e}]`:""};`):(i.push(`uniform sampler2D ${t.name};`),i.push(`uniform int offset${t.name};`))});const a=i.join("\n"),o=t.map(t=>function(t,e,n=!1){let r="";r+=n?$t(t):Lt(t);const i=t.shapeInfo.logicalShape,a=e.logicalShape;i.length<=a.length&&(r+=n?function(t,e){const n=t.name,r=n.charAt(0).toUpperCase()+n.slice(1),i="get"+r+"AtOutCoords",a=t.shapeInfo.logicalShape.length,o=e.logicalShape.length,u=Ft(t.shapeInfo.logicalShape,e.logicalShape),c=Kt(o),l=o-a;let h;const d=["x","y","z","w","u","v"];h=0===a?"":o<2&&u.length>=1?"coords = 0;":u.map(t=>`coords.${d[t+l]} = 0;`).join("\n");let p="";p=o<2&&a>0?"coords":t.shapeInfo.logicalShape.map((t,e)=>"coords."+d[e+l]).join(", ");let f="return outputValue;";const m=1===s.util.sizeFromShape(t.shapeInfo.logicalShape),g=1===s.util.sizeFromShape(e.logicalShape);if(1!==a||m||g){if(m&&!g)f=1===o?"\n        return vec4(outputValue.x, outputValue.x, 0., 0.);\n      ":"\n        return vec4(outputValue.x);\n      ";else if(u.length){const t=a-2,e=a-1;u.indexOf(t)>-1&&u.indexOf(e)>-1?f="return vec4(outputValue.x);":u.indexOf(t)>-1?f="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":u.indexOf(e)>-1&&(f="return vec4(outputValue.xx, outputValue.zz);")}}else f="\n      return vec4(outputValue.xy, outputValue.xy);\n    ";return`\n    vec4 ${i}() {\n      ${c} coords = getOutputCoords();\n      ${h}\n      vec4 outputValue = get${r}(${p});\n      ${f}\n    }\n  `}(t,e):function(t,e){const n=t.name,r=n.charAt(0).toUpperCase()+n.slice(1),i="get"+r+"AtOutCoords",a=e.texShape,o=t.shapeInfo.texShape,u=t.shapeInfo.logicalShape.length,c=e.logicalShape.length;if(!t.shapeInfo.isUniform&&u===c&&null==t.shapeInfo.flatOffset&&s.util.arraysEqual(o,a))return`\n      float ${i}() {\n        return sampleTexture(${n}, resultUV);\n      }\n    `;const l=Kt(c),h=Ft(t.shapeInfo.logicalShape,e.logicalShape),d=c-u;let p;const f=["x","y","z","w","u","v"];p=0===u?"":c<2&&h.length>=1?"coords = 0;":h.map(t=>`coords.${f[t+d]} = 0;`).join("\n");let m="";m=c<2&&u>0?"coords":t.shapeInfo.logicalShape.map((t,e)=>"coords."+f[e+d]).join(", ");return`\n    float ${i}() {\n      ${l} coords = getOutputCoords();\n      ${p}\n      return get${r}(${m});\n    }\n  `}(t,e));return r}(t,e,r)).join("\n"),u=e.texShape,c=Mt(),l=function(t){return`\n    float sampleTexture(sampler2D textureSampler, vec2 uv) {\n      return ${t.texture2D}(textureSampler, uv).r;\n    }\n  `}(c);let h,d,p=function(t){return`${t.version}\n    precision highp float;\n    precision highp int;\n    precision highp sampler2D;\n    ${t.varyingFs} vec2 resultUV;\n    ${t.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    ${t.defineSpecialNaN}\n    ${t.defineSpecialInf}\n    ${t.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    ${Bt}\n    ${qt}\n    ${Vt}\n  `}(c);e.isPacked?(h=function(t,e){switch(t.length){case 0:return Wt();case 1:return function(t,e){const n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(1===n[0])return`\n      int getOutputCoords() {\n        return 2 * int(resultUV.x * ${n[1]}.0);\n      }\n    `;if(1===n[1])return`\n      int getOutputCoords() {\n        return 2 * int(resultUV.y * ${n[0]}.0);\n      }\n    `;return`\n    int getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(${n[0]}, ${n[1]}));\n      return 2 * (resTexRC.x * ${n[1]} + resTexRC.y);\n    }\n  `}(0,e);case 2:return function(t,e){const n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(s.util.arraysEqual(t,e))return`\n      ivec2 getOutputCoords() {\n        return 2 * ivec2(resultUV.yx * vec2(${n[0]}, ${n[1]}));\n      }\n    `;const r=Math.ceil(t[1]/2);return`\n    ivec2 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(${n[0]}, ${n[1]}));\n\n      int index = resTexRC.x * ${n[1]} + resTexRC.y;\n      int r = 2 * (index / ${r});\n      int c = imod(index, ${r}) * 2;\n\n      return ivec2(r, c);\n    }\n  `}(t,e);case 3:return function(t,e){const n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],r=Math.ceil(t[2]/2),i=r*Math.ceil(t[1]/2);return`\n    ivec3 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(${n[0]}, ${n[1]}));\n      int index = resTexRC.x * ${n[1]} + resTexRC.y;\n\n      int b = index / ${i};\n      index -= b * ${i};\n\n      int r = 2 * (index / ${r});\n      int c = imod(index, ${r}) * 2;\n\n      return ivec3(b, r, c);\n    }\n  `}(t,e);default:return function(t,e){const n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],r=Math.ceil(t[t.length-1]/2),i=r*Math.ceil(t[t.length-2]/2);let s=i,a="",o="b, r, c";for(let e=2;e<t.length-1;e++)s*=t[t.length-e-1],a=`\n      int b${e} = index / ${s};\n      index -= b${e} * ${s};\n    `+a,o=`b${e}, `+o;return`\n    ivec${t.length} getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(${n[0]}, ${n[1]}));\n      int index = resTexRC.x * ${n[1]} + resTexRC.y;\n\n      ${a}\n\n      int b = index / ${i};\n      index -= b * ${i};\n\n      int r = 2 * (index / ${r});\n      int c = imod(index, ${r}) * 2;\n\n      return ivec${t.length}(${o});\n    }\n  `}(t,e)}}(e.logicalShape,u),d=function(t){return`\n    void setOutput(vec4 val) {\n      ${t.output} = val;\n    }\n  `}(c)):(h=function(t,e){switch(t.length){case 0:return Wt();case 1:return function(t,e){if(1===e[0])return`\n      int getOutputCoords() {\n        return int(resultUV.x * ${e[1]}.0);\n      }\n    `;if(1===e[1])return`\n      int getOutputCoords() {\n        return int(resultUV.y * ${e[0]}.0);\n      }\n    `;return`\n    int getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(${e[0]}, ${e[1]}));\n      return resTexRC.x * ${e[1]} + resTexRC.y;\n    }\n  `}(0,e);case 2:return function(t,e){if(s.util.arraysEqual(t,e))return`\n      ivec2 getOutputCoords() {\n        return ivec2(resultUV.yx * vec2(${e[0]}, ${e[1]}));\n      }\n    `;if(1===t[1])return`\n      ivec2 getOutputCoords() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n                               vec2(${e[0]}, ${e[1]}));\n        int index = resTexRC.x * ${e[1]} + resTexRC.y;\n        return ivec2(index, 0);\n      }\n    `;if(1===t[0])return`\n      ivec2 getOutputCoords() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n                               vec2(${e[0]}, ${e[1]}));\n        int index = resTexRC.x * ${e[1]} + resTexRC.y;\n        return ivec2(0, index);\n      }\n    `;return`\n    ivec2 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(${e[0]}, ${e[1]}));\n      int index = resTexRC.x * ${e[1]} + resTexRC.y;\n      int r = index / ${t[1]};\n      int c = index - r * ${t[1]};\n      return ivec2(r, c);\n    }\n  `}(t,e);case 3:return function(t,e){const n=Dt(["r","c","d"],t);return`\n    ivec3 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(${e[0]}, ${e[1]}));\n      int index = resTexRC.x * ${e[1]} + resTexRC.y;\n      ${n}\n      return ivec3(r, c, d);\n    }\n  `}(t,e);case 4:return function(t,e){const n=Dt(["r","c","d","d2"],t);return`\n    ivec4 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n        vec2(${e[0]}, ${e[1]}));\n      int index = resTexRC.x * ${e[1]} + resTexRC.y;\n      ${n}\n      return ivec4(r, c, d, d2);\n    }\n  `}(t,e);case 5:return function(t,e){const n=Dt(["r","c","d","d2","d3"],t);return`\n    ivec5 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx * vec2(${e[0]},\n                             ${e[1]}));\n\n      int index = resTexRC.x * ${e[1]} + resTexRC.y;\n\n      ${n}\n\n      ivec5 outShape = ivec5(r, c, d, d2, d3);\n      return outShape;\n    }\n  `}(t,e);case 6:return function(t,e){const n=Dt(["r","c","d","d2","d3","d4"],t);return`\n    ivec6 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n        vec2(${e[0]}, ${e[1]}));\n      int index = resTexRC.x * ${e[1]} + resTexRC.y;\n\n      ${n}\n\n      ivec6 result = ivec6(r, c, d, d2, d3, d4);\n      return result;\n    }\n  `}(t,e);default:throw new Error(t.length+"-D output sampling is not yet supported")}}(e.logicalShape,u),d=function(t){return`\n    void setOutput(float val) {\n      ${t.output} = vec4(val, 0, 0, 0);\n    }\n  `}(c)),r&&(p+=Ut);return[p,l,d,a,h,o,n].join("\n")}function Lt(t){const e=t.shapeInfo.logicalShape;switch(e.length){case 0:return function(t){const e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1);if(t.shapeInfo.isUniform)return`float ${n}() {return ${e};}`;const[r,i]=t.shapeInfo.texShape;if(1===r&&1===i)return`\n      float ${n}() {\n        return sampleTexture(${e}, halfCR);\n      }\n    `;const[s,a]=t.shapeInfo.texShape,o=Gt(e);return`\n    float ${n}() {\n      vec2 uv = uvFromFlat(${s}, ${a}, ${o});\n      return sampleTexture(${e}, uv);\n    }\n  `}(t);case 1:return function(t){const e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1);if(t.shapeInfo.isUniform)return`\n      float ${n}(int index) {\n        ${Ht(t)}\n      }\n    `;const r=t.shapeInfo.texShape,i=r[0],s=r[1];if(1===s&&1===i)return`\n      float ${n}(int index) {\n        return sampleTexture(${e}, halfCR);\n      }\n    `;const a=Gt(e);if(1===s)return`\n      float ${n}(int index) {\n        vec2 uv = vec2(0.5, (float(index + ${a}) + 0.5) / ${i}.0);\n        return sampleTexture(${e}, uv);\n      }\n    `;if(1===i)return`\n      float ${n}(int index) {\n        vec2 uv = vec2((float(index + ${a}) + 0.5) / ${s}.0, 0.5);\n        return sampleTexture(${e}, uv);\n      }\n    `;return`\n    float ${n}(int index) {\n      vec2 uv = uvFromFlat(${i}, ${s}, index + ${a});\n      return sampleTexture(${e}, uv);\n    }\n  `}(t);case 2:return function(t){const e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=t.shapeInfo.texShape;if(null!=i&&s.util.arraysEqual(e,i)){const t=i[0],e=i[1];return`\n    float ${r}(int row, int col) {\n      vec2 uv = (vec2(col, row) + halfCR) / vec2(${e}.0, ${t}.0);\n      return sampleTexture(${n}, uv);\n    }\n  `}const{newShape:a,keptDims:o}=s.util.squeezeShape(e),u=a;if(u.length<e.length){const e=Qt(t,u),n=["row","col"];return`\n      ${Lt(e)}\n      float ${r}(int row, int col) {\n        return ${r}(${Xt(n,o)});\n      }\n    `}if(t.shapeInfo.isUniform)return`\n      float ${r}(int row, int col) {\n        int index = round(dot(vec2(row, col), vec2(${e[1]}, 1)));\n        ${Ht(t)}\n      }\n    `;const c=i[0],l=i[1],h=Gt(n);if(1===l)return`\n    float ${r}(int row, int col) {\n      float index = dot(vec3(row, col, ${h}), vec3(${e[1]}, 1, 1));\n      vec2 uv = vec2(0.5, (index + 0.5) / ${c}.0);\n      return sampleTexture(${n}, uv);\n    }\n  `;if(1===c)return`\n    float ${r}(int row, int col) {\n      float index = dot(vec3(row, col, ${h}), vec3(${e[1]}, 1, 1));\n      vec2 uv = vec2((index + 0.5) / ${l}.0, 0.5);\n      return sampleTexture(${n}, uv);\n    }\n  `;return`\n  float ${r}(int row, int col) {\n    // Explicitly use integer operations as dot() only works on floats.\n    int index = row * ${e[1]} + col + ${h};\n    vec2 uv = uvFromFlat(${c}, ${l}, index);\n    return sampleTexture(${n}, uv);\n  }\n`}(t);case 3:return function(t){const e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=e[1]*e[2],a=e[2],{newShape:o,keptDims:u}=s.util.squeezeShape(e),c=o;if(c.length<e.length){const e=Qt(t,c),n=["row","col","depth"];return`\n        ${Lt(e)}\n        float ${r}(int row, int col, int depth) {\n          return ${r}(${Xt(n,u)});\n        }\n      `}if(t.shapeInfo.isUniform)return`\n      float ${r}(int row, int col, int depth) {\n        int index = round(dot(vec3(row, col, depth),\n                          vec3(${i}, ${a}, 1)));\n        ${Ht(t)}\n      }\n    `;const l=t.shapeInfo.texShape,h=l[0],d=l[1],p=t.shapeInfo.flatOffset;if(d===i&&null==p)return`\n        float ${r}(int row, int col, int depth) {\n          float texR = float(row);\n          float texC = dot(vec2(col, depth), vec2(${a}, 1));\n          vec2 uv = (vec2(texC, texR) + halfCR) /\n                     vec2(${d}.0, ${h}.0);\n          return sampleTexture(${n}, uv);\n        }\n      `;if(d===a&&null==p)return`\n    float ${r}(int row, int col, int depth) {\n      float texR = dot(vec2(row, col), vec2(${e[1]}, 1));\n      float texC = float(depth);\n      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${d}.0, ${h}.0);\n      return sampleTexture(${n}, uv);\n    }\n  `;const f=Gt(n);return`\n      float ${r}(int row, int col, int depth) {\n        // Explicitly use integer operations as dot() only works on floats.\n        int index = row * ${i} + col * ${a} + depth + ${f};\n        vec2 uv = uvFromFlat(${h}, ${d}, index);\n        return sampleTexture(${n}, uv);\n      }\n  `}(t);case 4:return function(t){const e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=e[3],a=e[2]*i,o=e[1]*a,{newShape:u,keptDims:c}=s.util.squeezeShape(e);if(u.length<e.length){const e=Qt(t,u),n=["row","col","depth","depth2"];return`\n      ${Lt(e)}\n      float ${r}(int row, int col, int depth, int depth2) {\n        return ${r}(${Xt(n,c)});\n      }\n    `}if(t.shapeInfo.isUniform)return`\n      float ${r}(int row, int col, int depth, int depth2) {\n        int index = round(dot(vec4(row, col, depth, depth2),\n                          vec4(${o}, ${a}, ${i}, 1)));\n        ${Ht(t)}\n      }\n    `;const l=t.shapeInfo.flatOffset,h=t.shapeInfo.texShape,d=h[0],p=h[1];if(p===o&&null==l)return`\n      float ${r}(int row, int col, int depth, int depth2) {\n        float texR = float(row);\n        float texC =\n            dot(vec3(col, depth, depth2),\n                vec3(${a}, ${i}, 1));\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2(${p}.0, ${d}.0);\n        return sampleTexture(${n}, uv);\n      }\n    `;if(p===i&&null==l)return`\n      float ${r}(int row, int col, int depth, int depth2) {\n        float texR = dot(vec3(row, col, depth),\n                         vec3(${e[1]*e[2]}, ${e[2]}, 1));\n        float texC = float(depth2);\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2(${p}.0, ${d}.0);\n        return sampleTexture(${n}, uv);\n      }\n    `;const f=Gt(n);return`\n    float ${r}(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 * ${a} +\n          depth * ${i} + depth2;\n      vec2 uv = uvFromFlat(${d}, ${p}, index + ${f});\n      return sampleTexture(${n}, uv);\n    }\n  `}(t);case 5:return function(t){const e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=e[4],a=e[3]*i,o=e[2]*a,u=e[1]*o,{newShape:c,keptDims:l}=s.util.squeezeShape(e);if(c.length<e.length){const e=Qt(t,c),n=["row","col","depth","depth2","depth3"];return`\n      ${Lt(e)}\n      float ${r}(int row, int col, int depth, int depth2, int depth3) {\n        return ${r}(${Xt(n,l)});\n      }\n    `}if(t.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(${u}, ${o}, ${a}, ${i})) +\n          depth3;\n        ${Ht(t)}\n      }\n    `;const h=t.shapeInfo.flatOffset,d=t.shapeInfo.texShape,p=d[0],f=d[1];if(f===u&&null==h)return`\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(${o}, ${a}, ${i}, 1));\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2(${f}.0, ${p}.0);\n        return sampleTexture(${n}, uv);\n      }\n    `;if(f===i&&null==h)return`\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(${e[1]*e[2]*e[3]},\n               ${e[2]*e[3]}, ${e[3]}, 1));\n        int texC = depth3;\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2(${f}.0, ${p}.0);\n        return sampleTexture(${n}, uv);\n      }\n    `;const m=Gt(n);return`\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 * ${u} + col * ${o} + depth * ${a} +\n          depth2 * ${i} + depth3 + ${m};\n      vec2 uv = uvFromFlat(${p}, ${f}, index);\n      return sampleTexture(${n}, uv);\n    }\n  `}(t);case 6:return function(t){const e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),{newShape:i,keptDims:a}=s.util.squeezeShape(e);if(i.length<e.length){const e=Qt(t,i),n=["row","col","depth","depth2","depth3","depth4"];return`\n      ${Lt(e)}\n      float ${r}(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        return ${r}(${Xt(n,a)});\n      }\n    `}const o=e[5],u=e[4]*o,c=e[3]*u,l=e[2]*c,h=e[1]*l;if(t.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(${h}, ${l}, ${c}, ${u})) +\n          dot(\n            vec2(depth3, depth4),\n            vec2(${o}, 1)));\n        ${Ht(t)}\n      }\n    `;const d=t.shapeInfo.flatOffset,p=t.shapeInfo.texShape,f=p[0],m=p[1];if(m===h&&null==d)return`\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}, ${c}, ${u}, ${o})) +\n               float(depth4);\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2(${m}.0, ${f}.0);\n        return sampleTexture(${n}, uv);\n      }\n    `;if(m===o&&null==d)return`\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(${e[1]*e[2]*e[3]*e[4]},\n               ${e[2]*e[3]*e[4]},\n               ${e[3]*e[4]},\n               ${e[4]})) + float(depth3);\n        int texC = depth4;\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2(${m}.0, ${f}.0);\n        return sampleTexture(${n}, uv);\n      }\n    `;const g=Gt(n);return`\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 * ${h} + col * ${l} + depth * ${c} +\n          depth2 * ${u} + depth3 * ${o} + depth4 + ${g};\n      vec2 uv = uvFromFlat(${f}, ${m}, index);\n      return sampleTexture(${n}, uv);\n    }\n  `}(t);default:throw new Error(e.length+"-D input sampling is not yet supported")}}function $t(t){switch(t.shapeInfo.logicalShape.length){case 0:return function(t){const e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1),r=Mt();return`\n    vec4 ${n}() {\n      return ${r.texture2D}(${e}, halfCR);\n    }\n  `}(t);case 1:return function(t){const e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1),r=t.shapeInfo.texShape,i=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],s=Mt();return`\n    vec4 ${n}(int index) {\n      vec2 uv = packedUVfrom1D(\n        ${i[0]}, ${i[1]}, index);\n      return ${s.texture2D}(${e}, uv);\n    }\n  `}(t);case 2:return function(t){const e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=t.shapeInfo.texShape,a=i[0],o=i[1],u=Mt();if(null!=i&&s.util.arraysEqual(e,i))return`\n      vec4 ${r}(int row, int col) {\n        vec2 uv = (vec2(col, row) + halfCR) / vec2(${o}.0, ${a}.0);\n\n        return ${u.texture2D}(${n}, uv);\n      }\n    `;const c=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)],l=Math.ceil(e[1]/2);return`\n    vec4 ${r}(int row, int col) {\n      vec2 uv = packedUVfrom2D(${l}, ${c[0]}, ${c[1]}, row, col);\n      return ${u.texture2D}(${n}, uv);\n    }\n  `}(t);case 3:return function(t){const e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=t.shapeInfo.texShape,s=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)];if(1===e[0]){const n=e.slice(1),i=[1,2],s=Qt(t,n),a=["b","row","col"];return`\n        ${$t(s)}\n        vec4 ${r}(int b, int row, int col) {\n          return ${r}(${Xt(a,i)});\n        }\n      `}const a=s[0],o=s[1],u=Math.ceil(e[2]/2),c=u*Math.ceil(e[1]/2),l=Mt();return`\n    vec4 ${r}(int b, int row, int col) {\n      vec2 uv = packedUVfrom3D(\n        ${a}, ${o}, ${c}, ${u}, b, row, col);\n      return ${l.texture2D}(${n}, uv);\n    }\n  `}(t);default:return function(t){const e=t.shapeInfo.logicalShape,n=e.length,r=t.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),s=t.shapeInfo.texShape,a=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)],o=a[0],u=a[1],c=Math.ceil(e[n-1]/2);let l=c*Math.ceil(e[n-2]/2),h="int b, int row, int col",d=`b * ${l} + (row / 2) * ${c} + (col / 2)`;for(let t=2;t<n-1;t++)h=`int b${t}, `+h,l*=e[n-t-1],d=`b${t} * ${l} + `+d;const p=Mt();return`\n    vec4 ${i}(${h}) {\n      int index = ${d};\n      int texR = index / ${u};\n      int texC = index - texR * ${u};\n      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${u}, ${o});\n      return ${p.texture2D}(${r}, uv);\n    }\n  `}(t)}}const Bt="\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",qt="\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",Vt="\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",Ut="\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 Wt(){return"\n    int getOutputCoords() {\n      return 0;\n    }\n  "}function Gt(t){return"offset"+t}function Ht(t){const e=t.name,n=s.util.sizeFromShape(t.shapeInfo.logicalShape);return n<2?`return ${e};`:`\n    for (int i = 0; i < ${n}; i++) {\n      if (i == index) {\n        return ${e}[i];\n      }\n    }\n  `}function Kt(t){if(t<=1)return"int";if(2===t)return"ivec2";if(3===t)return"ivec3";if(4===t)return"ivec4";if(5===t)return"ivec5";if(6===t)return"ivec6";throw Error(`GPU for rank ${t} is not yet supported`)}function Qt(t,e){const n=JSON.parse(JSON.stringify(t));return n.shapeInfo.logicalShape=e,n}function Xt(t,e){return e.map(e=>t[e]).join(", ")}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Yt{constructor(t,e,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,s.util.assert(t.length>2,()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`);const i=t[t.length-1],a=Math.ceil(i/e);this.outputShape=t.slice(0,-1),a>1&&this.outputShape.push(a),r||this.variableNames.push("bestIndicesA");const o=this.outputShape,u=o.length,c=Kt(u),l=jt("coords",u);let h,d;if(1===a){d=u+1;const t=Kt(d);h=`\n        ${t} sourceLocR = ${t}(${l.join()}, 0);\n        ++${l[u-1]};\n        ${t} sourceLocG = ${t}(${l.join()}, 0);\n        ++${l[u-2]};\n        ${t} sourceLocA = ${t}(${l.join()}, 0);\n        --${l[u-1]};\n        ${t} sourceLocB = ${t}(${l.join()}, 0);\n        --${l[u-2]};`}else d=u,h=`\n        ${c} sourceLocR = coords;\n        ++${l[u-1]};\n        ${c} sourceLocG = coords;\n        ++${l[u-2]};\n        ${c} sourceLocA = coords;\n        --${l[u-1]};\n        ${c} sourceLocB = coords;\n        --${l[u-2]};`;const p=["x","y","z","w","u","v"].slice(0,d),f="."+p[d-1],m=p.map(t=>"int "+t),g=jt("sourceLocR",d-1).concat("inIdx.r"),b=jt("sourceLocG",d-1).concat("inIdx.g"),y=jt("sourceLocB",d-1).concat("inIdx.b"),v=jt("sourceLocA",d-1).concat("inIdx.a"),w="max"===n?"greaterThan":"lessThan",x=r?"":`\n          inIdx = round(vec4(getBestIndicesAChannel(${g.join()}),\n                             getBestIndicesAChannel(${b.join()}),\n                             getBestIndicesAChannel(${y.join()}),\n                             getBestIndicesAChannel(${v.join()})));`,_=`vec4(\n            getAChannel(${g.join()}),\n            hasNextCol ? getAChannel(${b.join()}) : 0.,\n            hasNextRow ? getAChannel(${y.join()}) : 0.,\n            hasNextRow && hasNextCol ? getAChannel(${v.join()}) : 0.)`,O=r?"":`\n      float getBestIndicesAChannel(${m.join()}) {\n        return getChannel(getBestIndicesA(${p.join()}),\n                                          vec2(${p.slice(-2).join()}));\n      }`;this.userCode=`\n      float getAChannel(${m.join()}) {\n        return getChannel(getA(${p.join()}),\n                               vec2(${p.slice(-2).join()}));\n      }\n      ${O}\n      void main() {\n        ${c} coords = getOutputCoords();\n        bool hasNextCol = ${l[u-1]} < ${o[u-1]-1};\n        bool hasNextRow = ${l[u-2]} < ${o[u-2]-1};\n        ${h}\n        ivec4 srcIdx = ivec4(sourceLocR${f}, sourceLocG${f},\n          sourceLocB${f}, sourceLocA${f}) * ${e};\n        ivec4 inIdx = srcIdx;\n        vec4 bestIndex = vec4(inIdx);\n        vec4 bestValue = ${_};\n\n        for (int i = 0; i < ${e}; i++) {\n          inIdx = srcIdx;\n          ${x}\n          vec4 candidate = ${_};\n          bvec4 nan = isnan(candidate);\n          bvec4 replace = bvec4(\n            vec4(${w}(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    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Jt{constructor(t){this.variableNames=["dy"],this.outputShape=t.inShape;const e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,i=t.strideWidth,s=t.dilationHeight,a=t.dilationWidth,o=t.effectiveFilterHeight,u=t.effectiveFilterWidth,c=o-1-t.padInfo.top,l=u-1-t.padInfo.left,h=1/(e*n);this.userCode=`\n      const ivec2 pads = ivec2(${c}, ${l});\n      const float avgMultiplier = float(${h});\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n\n        ivec2 dyRCCorner = coords.yz - pads;\n        int dyRCorner = dyRCCorner.x;\n        int dyCCorner = dyRCCorner.y;\n\n        // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < ${o};\n            wR += ${s}) {\n          float dyR = float(dyRCorner + wR) / ${r}.0;\n\n          if (dyR < 0.0 || dyR >= ${t.outHeight}.0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          for (int wC = 0; wC < ${u};\n            wC+= ${a}) {\n            float dyC = float(dyCCorner + wC) / ${i}.0;\n\n            if (dyC < 0.0 || dyC >= ${t.outWidth}.0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            float dyValue = getDy(b, idyR, idyC, d);\n\n            dotProd += dyValue * avgMultiplier;\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}class Zt{constructor(t){this.variableNames=["dy"],this.outputShape=t.inShape;const e=t.filterDepth,n=t.filterHeight,r=t.filterWidth,i=t.strideDepth,s=t.strideHeight,a=t.strideWidth,o=t.dilationDepth,u=t.dilationHeight,c=t.dilationWidth,l=t.effectiveFilterDepth,h=t.effectiveFilterHeight,d=t.effectiveFilterWidth,p=l-1-t.padInfo.front,f=h-1-t.padInfo.top,m=d-1-t.padInfo.left,g=1/(e*n*r);this.userCode=`\n      const ivec3 pads = ivec3(${p}, ${f}, ${m});\n      const float avgMultiplier = float(${g});\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyDCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n        // dx(xD, xR, xC, ch).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int wD = 0; wD < ${l};\n            wD += ${o}) {\n          float dyD = float(dyDCorner + wD) / ${i}.0;\n\n          if (dyD < 0.0 || dyD >= ${t.outDepth}.0 || fract(dyD) > 0.0) {\n            continue;\n          }\n          int idyD = int(dyD);\n\n          for (int wR = 0; wR < ${h};\n              wR += ${u}) {\n            float dyR = float(dyRCorner + wR) / ${s}.0;\n\n            if (dyR < 0.0 || dyR >= ${t.outHeight}.0 ||\n                fract(dyR) > 0.0) {\n              continue;\n            }\n            int idyR = int(dyR);\n\n            for (int wC = 0; wC < ${d};\n                wC += ${c}) {\n              float dyC = float(dyCCorner + wC) / ${a}.0;\n\n              if (dyC < 0.0 || dyC >= ${t.outWidth}.0 ||\n                  fract(dyC) > 0.0) {\n                continue;\n              }\n              int idyC = int(dyC);\n\n              float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n              dotProd += dyValue * avgMultiplier;\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const te="return (a < 0.) ? b * a : a;";class ee{constructor(t,e,n){this.variableNames=["A","B"],this.outputShape=s.backend_util.assertAndGetBroadcastShape(e,n),this.userCode=`\n      float binaryOperation(float a, float b) {\n        ${t}\n      }\n\n      void main() {\n        float a = getAAtOutCoords();\n        float b = getBAtOutCoords();\n        setOutput(binaryOperation(a, b));\n      }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const ne="\n  vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n  return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";class re{constructor(t,e,n,r=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=s.backend_util.assertAndGetBroadcastShape(e,n);const i=this.outputShape.length;let a="";if(r)if(0===i||1===s.util.sizeFromShape(this.outputShape))a="\n          result.y = 0.;\n          result.z = 0.;\n          result.w = 0.;\n        ";else{if(a=`\n          ${Kt(i)} coords = getOutputCoords();\n        `,1===i)a+=`\n            result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;\n            result.z = 0.;\n            result.w = 0.;\n          `;else{const t=jt("coords",i);a+=`\n            bool nextRowOutOfBounds =\n              (${t[i-2]} + 1) >= ${this.outputShape[i-2]};\n            bool nextColOutOfBounds =\n              (${t[i-1]} + 1) >= ${this.outputShape[i-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        ${t}\n      }\n\n      void main() {\n        vec4 a = getAAtOutCoords();\n        vec4 b = getBAtOutCoords();\n\n        vec4 result = binaryOperation(a, b);\n        ${a}\n\n        setOutput(result);\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class ie{constructor(t){this.variableNames=["A"],this.outputShape=t,this.userCode="\n      uniform float minVal;\n      uniform float maxVal;\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    "}getCustomSetupFunc(t,e){return(n,r)=>{null==this.minLoc&&(this.minLoc=n.getUniformLocationNoThrow(r,"minVal"),this.maxLoc=n.getUniformLocationNoThrow(r,"maxVal")),n.gl.uniform1f(this.minLoc,t),n.gl.uniform1f(this.maxLoc,e)}}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class se{constructor(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.userCode="\n      uniform float minVal;\n      uniform float maxVal;\n\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    "}getCustomSetupFunc(t,e){return(n,r)=>{null==this.minLoc&&(this.minLoc=n.getUniformLocationNoThrow(r,"minVal"),this.maxLoc=n.getUniformLocationNoThrow(r,"maxVal")),n.gl.uniform1f(this.minLoc,t),n.gl.uniform1f(this.maxLoc,e)}}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class ae{constructor(t){this.variableNames=["real","imag"],this.outputShape=t,this.userCode="\n      void main() {\n        float re = abs(getRealAtOutCoords());\n        float im = abs(getImagAtOutCoords());\n        float mx = max(re, im);\n\n        // sadly the length function in glsl is not underflow-safe\n        // (at least not on Intel GPUs). So the safe solution is\n        // to ensure underflow-safety in all cases.\n        setOutput(\n          mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n        );\n      }\n    "}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class oe{constructor(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;const e=t.strideHeight,n=t.strideWidth,r=t.padInfo.top,i=t.padInfo.left,s="channelsLast"===t.dataFormat;this.userCode=`\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int wR = coords.x;\n        int wC = coords.y;\n        int d1 = coords.z;\n        int d2 = coords.w;\n\n        // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int b = 0; b < ${t.batchSize}; b++) {\n          for (int yR = 0; yR < ${t.outHeight}; yR++) {\n            int xR = wR + yR * ${e} - ${r};\n\n            if (xR < 0 || xR >= ${t.inHeight}) {\n              continue;\n            }\n\n            for (int yC = 0; yC < ${t.outWidth}; yC++) {\n              int xC = wC + yC * ${n} - ${i};\n\n              if (xC < 0 || xC >= ${t.inWidth}) {\n                continue;\n              }\n\n              if (${s}) {\n                float dyValue = getDy(b, yR, yC, d2);\n                float xValue = getX(b, xR, xC, d1);\n                dotProd += (xValue * dyValue);\n              } else {\n                float dyValue = getDy(b, d2, yR, yC);\n                float xValue = getX(b, d1, xR, xC);\n                dotProd += (xValue * dyValue);\n              }\n\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}class ue{constructor(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;const e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,i=t.strideWidth,s="channelsLast"===t.dataFormat,a=e-1-t.padInfo.top,o=n-1-t.padInfo.left,u=s?1:2,c=s?2:3,l=s?3:1;this.userCode=`\n      const ivec2 pads = ivec2(${a}, ${o});\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d1 = coords[${l}];\n\n        ivec2 dyCorner = ivec2(coords[${u}], coords[${c}]) - 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 < ${e}; wR++) {\n          float dyR = float(dyRCorner + wR) / ${r}.0;\n\n          if (dyR < 0.0 || dyR >= ${t.outHeight}.0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          int wRPerm = ${e} - 1 - wR;\n\n          for (int wC = 0; wC < ${n}; wC++) {\n            float dyC = float(dyCCorner + wC) / ${i}.0;\n\n            if (dyC < 0.0 || dyC >= ${t.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 < ${t.outChannels}; d2++) {\n\n              if (${s}) {\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    `}}class ce{constructor(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;const e=t.strideDepth,n=t.strideHeight,r=t.strideWidth,i=t.padInfo.front,s=t.padInfo.top,a=t.padInfo.left;this.userCode=`\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int wF = coords.x;\n        int wR = coords.y;\n        int wC = coords.z;\n        int d1 = coords.w;\n        int d2 = coords.u;\n\n        float dotProd = 0.0;\n\n        for (int b = 0; b < ${t.batchSize}; b++) {\n          for (int yF = 0; yF < ${t.outDepth}; yF++) {\n            int xF = wF + yF * ${e} - ${i};\n\n            if (xF < 0 || xF >= ${t.inDepth}) {\n              continue;\n            }\n\n            for (int yR = 0; yR < ${t.outHeight}; yR++) {\n              int xR = wR + yR * ${n} - ${s};\n\n              if (xR < 0 || xR >= ${t.inHeight}) {\n                continue;\n              }\n\n              for (int yC = 0; yC < ${t.outWidth}; yC++) {\n                int xC = wC + yC * ${r} - ${a};\n\n                if (xC < 0 || xC >= ${t.inWidth}) {\n                  continue;\n                }\n\n                float dyValue = getDy(b, yF, yR, yC, d2);\n                float xValue = getX(b, xF, xR, xC, d1);\n                dotProd += (xValue * dyValue);\n              }\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}class le{constructor(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;const e=t.filterDepth,n=t.filterHeight,r=t.filterWidth,i=t.strideDepth,s=t.strideHeight,a=t.strideWidth,o=e-1-t.padInfo.front,u=n-1-t.padInfo.top,c=r-1-t.padInfo.left;this.userCode=`\n      const ivec3 pads = ivec3(${o}, ${u}, ${c});\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int d1 = coords.u;\n\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyFCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        float dotProd = 0.0;\n        for (int wF = 0; wF < ${e}; wF++) {\n          float dyF = float(dyFCorner + wF) / ${i}.0;\n\n          if (dyF < 0.0 || dyF >= ${t.outDepth}.0 || fract(dyF) > 0.0) {\n            continue;\n          }\n          int idyF = int(dyF);\n\n          int wFPerm = ${e} - 1 - wF;\n\n          for (int wR = 0; wR < ${n}; wR++) {\n            float dyR = float(dyRCorner + wR) / ${s}.0;\n\n            if (dyR < 0.0 || dyR >= ${t.outHeight}.0 ||\n              fract(dyR) > 0.0) {\n              continue;\n            }\n            int idyR = int(dyR);\n\n            int wRPerm = ${n} - 1 - wR;\n\n            for (int wC = 0; wC < ${r}; wC++) {\n              float dyC = float(dyCCorner + wC) / ${a}.0;\n\n              if (dyC < 0.0 || dyC >= ${t.outWidth}.0 ||\n                  fract(dyC) > 0.0) {\n                continue;\n              }\n              int idyC = int(dyC);\n\n              int wCPerm = ${r} - 1 - wC;\n\n              for (int d2 = 0; d2 < ${t.outChannels}; d2++) {\n                float xValue = getDy(batch, idyF, idyR, idyC, d2);\n                float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n                dotProd += xValue * wValue;\n              }\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class he{constructor(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;const e=t.strideHeight,n=t.strideWidth,r=t.padInfo.top,i=t.padInfo.left,s=t.outChannels/t.inChannels;this.userCode=`\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int wR = coords.x;\n        int wC = coords.y;\n        int d1 = coords.z;\n        int dm = coords.w;\n        int d2 = d1 * ${s} + dm;\n\n        float dotProd = 0.0;\n\n        // TO DO: Vec4 over the batch size\n        for (int b = 0; b < ${t.batchSize}; b++) {\n          for (int yR = 0; yR < ${t.outHeight}; yR++) {\n            int xR = wR + yR * ${e} - ${r};\n\n            if (xR < 0 || xR >= ${t.inHeight}) {\n              continue;\n            }\n\n            for (int yC = 0; yC < ${t.outWidth}; yC++) {\n              int xC = wC + yC * ${n} - ${i};\n\n              if (xC < 0 || xC >= ${t.inWidth}) {\n                continue;\n              }\n\n              float dyValue = getDy(b, yR, yC, d2);\n              float xValue = getX(b, xR, xC, d1);\n              dotProd += (xValue * dyValue);\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}class de{constructor(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;const e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,i=t.strideWidth,s=e-1-t.padInfo.top,a=n-1-t.padInfo.left,o=t.outChannels/t.inChannels;this.userCode=`\n      const ivec2 pads = ivec2(${s}, ${a});\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d1 = coords[3];\n        ivec2 dyCorner = coords.yz - pads;\n        int dyRCorner = dyCorner.x;\n        int dyCCorner = dyCorner.y;\n\n        float dotProd = 0.0;\n\n        for (int wR = 0; wR < ${e}; wR++) {\n          float dyR = float(dyRCorner + wR) / ${r}.0;\n\n          if (dyR < 0.0 || dyR >= ${t.outHeight}.0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          int wRPerm = ${e} - 1 - wR;\n\n          for (int wC = 0; wC < ${n}; wC++) {\n            float dyC = float(dyCCorner + wC) / ${i}.0;\n\n            if (dyC < 0.0 || dyC >= ${t.outWidth}.0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            int wCPerm = ${n} - 1 - wC;\n\n            // TO DO: Vec4 over the channelMul\n            for (int dm = 0; dm < ${o}; dm++) {\n              int d2 = d1 * ${o} + dm;\n              float xValue = getDy(batch, idyR, idyC, d2);\n              float wValue = getW(wRPerm, wCPerm, d1, dm);\n              dotProd += xValue * wValue;\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class pe{constructor(t,e=!1,n=null,r=!1){this.variableNames=["x","W"],this.outputShape=t.outShape;const i=t.padInfo.top,s=t.padInfo.left,a=t.strideHeight,o=t.strideWidth,u=t.dilationHeight,c=t.dilationWidth,l=t.filterHeight,h=t.filterWidth,d=4*Math.floor(t.inChannels/4),p=t.inChannels%4,f="channelsLast"===t.dataFormat,m=f?1:2,g=f?2:3,b=f?3:1;let y="",v="";n&&(y=r?`float activation(float a) {\n          float b = getPreluActivationWeightsAtOutCoords();\n          ${n}\n        }`:`\n          float activation(float x) {\n            ${n}\n          }\n        `,v="result = activation(result);");const w=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode=`\n      ${y}\n\n      const ivec2 strides = ivec2(${a}, ${o});\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[${m}], coords[${g}]) * 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 < ${l}; wR++) {\n          int xR = xRCorner + wR * ${u};\n\n          if (xR < 0 || xR >= ${t.inHeight}) {\n            continue;\n          }\n\n          for (int wC = 0; wC < ${h}; wC++) {\n            int xC = xCCorner + wC * ${c};\n\n            if (xC < 0 || xC >= ${t.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 (${f}) {\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===p}) {\n\n              if (${f}) {\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===p}) {\n              vec2 wValues = vec2(\n                getW(wR, wC, ${d}, d2),\n                getW(wR, wC, ${d} + 1, d2)\n              );\n\n              if (${f}) {\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===p}) {\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 (${f}) {\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        ${w}\n        ${v}\n        setOutput(result);\n      }\n    `}}class fe{constructor(t){this.variableNames=["x","W"],this.outputShape=t.outShape;const e=t.padInfo.front,n=t.padInfo.top,r=t.padInfo.left,i=t.strideDepth,s=t.strideHeight,a=t.strideWidth,o=t.dilationDepth,u=t.dilationHeight,c=t.dilationWidth,l=t.filterDepth,h=t.filterHeight,d=t.filterWidth,p=4*Math.floor(t.inChannels/4),f=t.inChannels%4;this.userCode=`\n      const ivec3 strides = ivec3(${i}, ${s}, ${a});\n      const ivec3 pads = ivec3(${e}, ${n}, ${r});\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int d2 = coords.u;\n\n        ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n        int xFCorner = xFRCCorner.x;\n        int xRCorner = xFRCCorner.y;\n        int xCCorner = xFRCCorner.z;\n\n        // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n        // y(yF, yR, yC, d2). ? = to be determined. : = across all\n        // values in that axis.\n        float dotProd = 0.0;\n        for (int wF = 0; wF < ${l}; wF++) {\n          int xF = xFCorner + wF * ${o};\n\n          if (xF < 0 || xF >= ${t.inDepth}) {\n            continue;\n          }\n\n          for (int wR = 0; wR < ${h}; wR++) {\n            int xR = xRCorner + wR * ${u};\n\n            if (xR < 0 || xR >= ${t.inHeight}) {\n              continue;\n            }\n\n            for (int wC = 0; wC < ${d}; wC++) {\n              int xC = xCCorner + wC * ${c};\n\n              if (xC < 0 || xC >= ${t.inWidth}) {\n                continue;\n              }\n\n              for (int d1 = 0; d1 < ${p}; d1 += 4) {\n                vec4 xValues = vec4(\n                  getX(batch, xF, xR, xC, d1),\n                  getX(batch, xF, xR, xC, d1 + 1),\n                  getX(batch, xF, xR, xC, d1 + 2),\n                  getX(batch, xF, xR, xC, d1 + 3)\n                );\n                vec4 wValues = vec4(\n                  getW(wF, wR, wC, d1, d2),\n                  getW(wF, wR, wC, d1 + 1, d2),\n                  getW(wF, wR, wC, d1 + 2, d2),\n                  getW(wF, wR, wC, d1 + 3, d2)\n                );\n\n                dotProd += dot(xValues, wValues);\n              }\n\n              if (${1===f}) {\n                dotProd +=\n                  getX(batch, xF, xR, xC, ${p}) *\n                  getW(wF, wR, wC, ${p}, d2);\n              } else if (${2===f}) {\n                vec2 xValues = vec2(\n                  getX(batch, xF, xR, xC, ${p}),\n                  getX(batch, xF, xR, xC, ${p} + 1)\n                );\n                vec2 wValues = vec2(\n                  getW(wF, wR, wC, ${p}, d2),\n                  getW(wF, wR, wC, ${p} + 1, d2)\n                );\n                dotProd += dot(xValues, wValues);\n              } else if (${3===f}) {\n                vec3 xValues = vec3(\n                  getX(batch, xF, xR, xC, ${p}),\n                  getX(batch, xF, xR, xC, ${p} + 1),\n                  getX(batch, xF, xR, xC, ${p} + 2)\n                );\n                vec3 wValues = vec3(\n                  getW(wF, wR, wC, ${p}, d2),\n                  getW(wF, wR, wC, ${p} + 1, d2),\n                  getW(wF, wR, wC, ${p} + 2, d2)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class me{constructor(t,e=!1,n=null,r=!1){this.variableNames=["x","W"],this.outputShape=t.outShape;const i=t.inHeight,s=t.inWidth,a=t.padInfo.top,o=t.padInfo.left,u=t.strideHeight,c=t.strideWidth,l=t.dilationHeight,h=t.dilationWidth,d=t.filterHeight,p=t.filterWidth,f=t.outChannels/t.inChannels;let m="",g="";n&&(m=r?`float activation(float a) {\n          float b = getPreluActivationWeightsAtOutCoords();\n          ${n}\n        }`:`\n          float activation(float x) {\n            ${n}\n          }\n        `,g="result = activation(result);");const b=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode=`\n      ${m}\n\n      const ivec2 strides = ivec2(${u}, ${c});\n      const ivec2 pads = ivec2(${a}, ${o});\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 / ${f};\n        int q = d2 - d1 * ${f};\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 < ${d}; wR++) {\n          int xR = xRCorner + wR * ${l};\n\n          if (xR < 0 || xR >= ${i}) {\n            continue;\n          }\n\n          for (int wC = 0; wC < ${p}; wC++) {\n            int xC = xCCorner + wC * ${h};\n\n            if (xC < 0 || xC >= ${s}) {\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        ${b}\n        ${g}\n        setOutput(result);\n      }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class ge{constructor(t,e=!1,n=null,r=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.outShape;const i=t.inHeight,a=t.inWidth,o=t.padInfo.top,u=t.padInfo.left,c=t.strideHeight,l=t.strideWidth,h=t.dilationHeight,d=t.dilationWidth,p=t.filterHeight,f=t.filterWidth,m=f;let g="int xR; int xC; int xCOffset;";for(let t=0;t<p;t++)for(let e=0;e<f;e++)g+=`\n          vec4 xTexelR${t}C${2*e} = vec4(0.);\n          vec4 wR${t}C${e} = vec4(0.);\n          vec4 xR${t}C${e} = vec4(0.);`;for(let t=0;t<p;t++)for(let e=0;e<m;e++){const n=2*e;if(g+=`\n          xR = xRCorner + ${t*h};\n          xC = xCCorner + ${n*d};\n        `,1===l){if(n<f&&(g+=u%2==1?`\n                xCOffset = xC + 1;\n                if(xR >= 0 && xR < ${i} && xCOffset >= 0 && xCOffset < ${a}) {\n                  xTexelR${t}C${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 >= ${a}) {\n                    xTexelR${t}C${n}.zw = vec2(0.);\n                  }\n                } else {\n                  xTexelR${t}C${n} = vec4(0.);\n                }\n\n                xCOffset = xC + 1 - 2;\n                if(xR >= 0 && xR < ${i} && xCOffset >= 0 && xCOffset < ${a}) {\n                  vec4 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 >= ${a}) {\n                    previous.zw = vec2(0.);\n                  }\n\n                  xR${t}C${n} = vec4(previous.zw, xTexelR${t}C${n}.xy);\n                } else {\n                  xR${t}C${n} = vec4(0, 0, xTexelR${t}C${n}.xy);\n                }\n              `:`\n                if(xR >= 0 && xR < ${i} && xC >= 0 && xC < ${a}) {\n                  xTexelR${t}C${n} = getX(batch, xR, xC, d1);\n                } else {\n                  xTexelR${t}C${n} = vec4(0.);\n                }\n\n                xR${t}C${n} = xTexelR${t}C${n};\n              `,n+1<f)){const e=u%2==0?s.util.nearestLargerEven(d):d;d%2==0&&u%2==1||d%2!=0&&u%2!=1?(g+=`\n                  xCOffset = xC + ${u%2} + ${e};\n\n                  if(xR >= 0 && xR < ${i} &&\n                    xCOffset >= 0 && xCOffset < ${a}) {\n                    xTexelR${t}C${n+2} = getX(batch, xR, xCOffset, d1);\n                  }\n                `,d>1&&(g+=`\n                    xCOffset -= 2;\n                    if(xR >= 0 && xR < ${i} &&\n                      xCOffset >= 0 && xCOffset < ${a}) {\n                      xTexelR${t}C${n} = getX(batch, xR, xCOffset, d1);\n                    } else {\n                      xTexelR${t}C${n} = vec4(0.);\n                    }\n                  `),g+=`\n                  xR${t}C${n+1} = vec4(\n                    xTexelR${t}C${n}.zw, xTexelR${t}C${n+2}.xy);\n                `):g+=`\n                  xCOffset = xC + ${e};\n\n                  if(xR >= 0 && xR < ${i} &&\n                    xCOffset >= 0 && xCOffset < ${a}) {\n                    xTexelR${t}C${n+2} = getX(batch, xR, xCOffset, d1);\n                  }\n\n                  xR${t}C${n+1} = xTexelR${t}C${n+2};\n                `}}else n<f&&(g+=`\n              if(xR >= 0 && xR < ${i}) {\n            `,u%2==1?(g+=`\n                xCOffset = xC + 1 - ${l};\n                if(xCOffset >= 0 && xCOffset < ${a}) {\n                  xTexelR${t}C${n} = getX(batch, xR, xCOffset, d1);\n                } else {\n                  xTexelR${t}C${n} = vec4(0.);\n                }\n\n                if(xC + 1 >= 0 && xC + 1 < ${a}) {\n                  xTexelR${t}C${n+2} = getX(batch, xR, xC + 1, d1);\n                } else {\n                  xTexelR${t}C${n+2} = vec4(0.);\n                }\n\n                xR${t}C${n} = vec4(\n                  xTexelR${t}C${n}.zw, xTexelR${t}C${n+2}.zw);\n              `,n+1<f&&(g+=`\n                  vec4 final = vec4(0.);\n                  xCOffset = xC + 1 + ${l};\n                  if(xCOffset >= 0 && xCOffset < ${a}) {\n                    final = getX(batch, xR, xCOffset, d1);\n                  }\n                  xR${t}C${n+1} = vec4(xTexelR${t}C${n+2}.xy, final.xy);\n                `)):(g+=`\n                if(xC >= 0 && xC < ${a}) {\n                  xTexelR${t}C${n} = getX(batch, xR, xC, d1);\n                } else {\n                  xTexelR${t}C${n} = vec4(0.);\n                }\n\n                xCOffset = xC + ${l};\n                if(xCOffset >= 0 && xCOffset < ${a}) {\n                  xTexelR${t}C${n+2} = getX(batch, xR, xCOffset, d1);\n                } else {\n                  xTexelR${t}C${n+2} = vec4(0.);\n                }\n\n                xR${t}C${n} = vec4(\n                  xTexelR${t}C${n}.xy, xTexelR${t}C${n+2}.xy);\n              `,n+1<f&&(g+=`\n                  xR${t}C${n+1} = vec4(\n                    xTexelR${t}C${n}.zw, xTexelR${t}C${n+2}.zw);\n                `)),g+="}");n<f&&(g+=`\n            vec4 wTexelR${t}C${n} = getW(${t}, ${n}, d1, q);\n            wR${t}C${n} = vec4(wTexelR${t}C${n}.xz, wTexelR${t}C${n}.xz);\n          `,n+1<f&&(g+=`\n              vec4 wTexelR${t}C${n+1} = getW(${t}, ${n+1}, d1, q);\n              wR${t}C${n+1} =\n                vec4(wTexelR${t}C${n+1}.xz, wTexelR${t}C${n+1}.xz);`))}for(let t=0;t<p;t++)for(let e=0;e<f;e++)g+=`dotProd += xR${t}C${e} * wR${t}C${e};`;let b="",y="";n&&(b=r?`vec4 activation(vec4 a) {\n          vec4 b = getPreluActivationWeightsAtOutCoords();\n          ${n}\n        }`:`vec4 activation(vec4 x) {\n          ${n}\n        }`,y="result = activation(result);");const v=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode=`\n      ${b}\n\n      const ivec2 strides = ivec2(${c}, ${l});\n      const ivec2 pads = ivec2(${o}, ${u});\n\n      void main() {\n\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;\n        int q = 0;\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        vec4 dotProd = vec4(0.);\n\n        ${g}\n\n        vec4 result = dotProd;\n        ${v}\n        ${y}\n        setOutput(result);\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class be{constructor(t,e,n,r,i){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[s,a,o,u]=t,[c]=e,[l,h]=n;this.outputShape=[c,l,h,u];const d="bilinear"===r?1:0,[p,f]=[a-1+".0",o-1+".0"],[m,g,b]=l>1?[""+(a-1)/(l-1),"(y2-y1) * height_ratio",`y1*${p} + float(y)*(height_scale)`]:["0.0","0.0","0.5 * (y1+y2) * "+p],[y,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(${y});\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 >= ${s}) {\n          return;\n        }\n\n        float height_scale = ${g};\n        float width_scale = ${v};\n\n        float in_y = ${b};\n        if( in_y < 0.0 || in_y > ${p} ) {\n          setOutput(float(${i}));\n          return;\n        }\n        float in_x = ${w};\n        if( in_x < 0.0 || in_x > ${f} ) {\n          setOutput(float(${i}));\n          return;\n        }\n\n        vec2 sourceFracIndexCR = vec2(in_x,in_y);\n        if(${d} == 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    `}}class ye{constructor(t,e,n){this.variableNames=["x"],this.outputShape=t;const r=t.length,i=e?"0.0":`getX(${ve(r,"coords")})`,s=t[t.length-1];let a="",o="";e?(a=n?"end != "+(s-1):"end != 0",o=n?"end + 1":"end - 1"):(a=n?"end + pow2 < "+s:"end >= pow2",o=n?"end + pow2":"end - pow2"),this.userCode=`\n      uniform float index;\n      void main() {\n        ${Kt(r)} coords = getOutputCoords();\n        int end = ${we(r,"coords")};\n        float val = ${i};\n        int pow2 = int(pow(2.0, index));\n        if (${a}) {\n          int idx = ${o};\n          ${we(r,"coords")} = idx;\n          val += getX(${ve(r,"coords")});\n        }\n        setOutput(val);\n      }\n    `}getCustomSetupFunc(t){return(e,n)=>{null==this.index&&(this.index=e.getUniformLocation(n,"index")),e.gl.uniform1f(this.index,t)}}}function ve(t,e){if(1===t)return""+e;if(2===t)return`${e}.x, ${e}.y`;if(3===t)return`${e}.x, ${e}.y, ${e}.z`;if(4===t)return`${e}.x, ${e}.y, ${e}.z, ${e}.w`;throw Error(`Cumulative sum for rank ${t} is not yet supported`)}function we(t,e){if(1===t)return""+e;if(2===t)return e+".y";if(3===t)return e+".z";if(4===t)return e+".w";throw Error(`Cumulative sum for rank ${t} is not yet supported`)}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class xe{constructor(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=l.DENSE;const e=f(t),n=Mt();this.outputShape=t,this.userCode=`\n      ivec3 outCoordsFromFlatIndex(int index) {\n        ${Dt(["r","c","d"],t)}\n        return ivec3(r, c, d);\n      }\n\n      void main() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n          vec2(${e[0]}, ${e[1]}));\n        int index = 4 * (resTexRC.x * ${e[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        ${n.output} = result;\n      }\n    `}}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class _e{constructor(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=l.DENSE;const e=f(t),n=Mt();this.outputShape=t,this.userCode=`\n      ivec3 outCoordsFromFlatIndex(int index) {\n        ${Dt(["r","c","d"],t)}\n        return ivec3(r, c, d);\n      }\n\n      void main() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n          vec2(${e[0]}, ${e[1]}));\n        int index = 4 * (resTexRC.x * ${e[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        ${n.output} = result;\n      }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Oe{constructor(t,e,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=t,this.blockSize=e,this.dataFormat=n,this.userCode=`\n    void main() {\n      ivec4 coords = getOutputCoords();\n      int b = coords[0];\n      int h = ${this.getHeightCoordString()};\n      int w = ${this.getWidthCoordString()};\n      int d = ${this.getDepthCoordString()};\n\n      int in_h = h / ${e};\n      int offset_h = imod(h, ${e});\n      int in_w = w / ${e};\n      int offset_w = imod(w, ${e});\n      int offset_d = (offset_h * ${e} + offset_w) *\n        ${this.getOutputDepthSize()};\n      int in_d = d + offset_d;\n\n      float result = ${this.getInputSamplingString()};\n      setOutput(result);\n    }\n  `}getHeightCoordString(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"}getWidthCoordString(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"}getDepthCoordString(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"}getOutputDepthSize(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]}getInputSamplingString(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Se{constructor(t){this.variableNames=["X"],this.outputShape=[t,t],this.userCode="\n      void main() {\n          ivec2 coords = getOutputCoords();\n          float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n          setOutput(val);\n      }\n    "}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class ke{constructor(t){this.variableNames=["A"],this.outTexUsage=h.DOWNLOAD;const e=Mt();this.outputShape=t,this.userCode=`\n      ${Pt}\n\n      void main() {\n        float x = getAAtOutCoords();\n        ${e.output} = encode_float(x);\n      }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Te{constructor(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=h.DOWNLOAD;const e=Mt();this.outputShape=t,this.userCode=`\n      ${Pt}\n\n      void main() {\n        ivec3 coords = getOutputCoords();\n        float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n        ${e.output} = encode_float(x);\n      }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Ce{constructor(t,e,n=!1){this.variableNames=["A"];const r=Mt(),[i,s]=e;this.outputShape=t;let a="result";n&&(a="floor(result * 255. + 0.5)"),this.userCode=`\n      ${Rt(t)}\n\n      void main() {\n        ivec3 coords = getOutputCoords();\n\n        int flatIndex = getFlatIndex(coords);\n        int offset = imod(flatIndex, 4);\n\n        flatIndex = idiv(flatIndex, 4, 1.);\n\n        int r = flatIndex / ${s};\n        int c = imod(flatIndex, ${s});\n        vec2 uv = (vec2(c, r) + halfCR) / vec2(${s}.0, ${i}.0);\n        vec4 values = ${r.texture2D}(A, uv);\n\n        float result;\n\n        if(offset == 0) {\n          result = values[0];\n        } else if(offset == 1) {\n          result = values[1];\n        } else if(offset == 2) {\n          result = values[2];\n        } else {\n          result = values[3];\n        }\n\n        ${r.output} = vec4(${a}, 0., 0., 0.);\n      }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Ae{constructor(t,e,n=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const r=Mt(),[i,s]=e;this.outputShape=t;let a="",o="result";n&&(o="floor(result * 255. + 0.5)");for(let e=0;e<=1;e++)for(let n=0;n<=1;n++){const o=2*e+n;a+=`\n          localCoords = coords;\n          if(localCoords[2] + ${n} < ${t[2]}) {\n            localCoords[2] += ${n};\n            if(localCoords[1] + ${e} < ${t[1]}) {\n              localCoords[1] += ${e};\n\n              flatIndex = getFlatIndex(localCoords);\n              offset = imod(flatIndex, 4);\n\n              flatIndex = idiv(flatIndex, 4, 1.);\n\n              r = flatIndex / ${s};\n              c = imod(flatIndex, ${s});\n              uv = (vec2(c, r) + halfCR) / vec2(${s}.0, ${i}.0);\n              values = ${r.texture2D}(A, uv);\n\n              if(offset == 0) {\n                result[${o}] = values[0];\n              } else if(offset == 1) {\n                result[${o}] = values[1];\n              } else if(offset == 2) {\n                result[${o}] = values[2];\n              } else {\n                result[${o}] = values[3];\n              }\n            }\n          }\n        `}this.userCode=`\n      ${Rt(t)}\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        ${a}\n\n        ${r.output} = ${o};\n      }\n    `}}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Ne{constructor(t,e){this.outputShape=[],this.variableNames=["x"],this.outputShape=t,this.userCode="\n      uniform float value;\n      void main() {\n        // Input can be obtained from uniform value.\n        setOutput(value);\n      }\n    "}getCustomSetupFunc(t){return(e,n)=>{null==this.valueLoc&&(this.valueLoc=e.getUniformLocationNoThrow(n,"value")),e.gl.uniform1f(this.valueLoc,t)}}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Ie{constructor(t,e,n){this.variableNames=["A","indices"];const r=t.slice();r[n]=e,this.outputShape=r,this.rank=r.length;const i=Kt(this.rank),s=function(t,e){const n=t.length;if(n>4)throw Error(`Gather for rank ${n} is not yet supported`);if(1===n)return"int(getIndices(resRC))";const r=["resRC.x","resRC.y","resRC.z","resRC.w"],i=[];for(let n=0;n<t.length;n++)n===e?i.push(`int(getIndices(${r[n]}))`):i.push(""+r[n]);return i.join()}(t,n);this.userCode=`\n      void main() {\n        ${i} resRC = getOutputCoords();\n        setOutput(getA(${s}));\n      }\n    `}}class Ee{constructor(t,e,n){this.sliceDim=t,this.strides=e,this.variableNames=["x","indices"],this.outputShape=n;const r=Kt(e.length),i=Kt(n.length),s=this.sliceDim>1?"strides[j]":"strides";this.userCode=`\n        ${r} strides = ${r}(${this.strides});\n         void main() {\n          ${i} coords = getOutputCoords();\n          int flattenIndex = 0;\n          for (int j = 0; j < ${this.sliceDim}; j++) {\n            int index = round(getIndices(coords[0], j));\n            flattenIndex += index * ${s};\n          }\n          setOutput(getX(flattenIndex, coords[1]));\n        }\n      `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function je(t){const e=Mt();return x(t,`${e.version}\n    precision highp float;\n    ${e.attribute} vec3 clipSpacePos;\n    ${e.attribute} vec2 uv;\n    ${e.varyingVs} vec2 resultUV;\n\n    void main() {\n      gl_Position = vec4(clipSpacePos, 1);\n      resultUV = uv;\n    }`)}function Me(t){return C(t,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}function De(t){return A(t,new Uint16Array([0,1,2,2,1,3]))}function Re(t,e,n,r,i,s){E(e,n);const a=I(t),o=t.TEXTURE_2D;return b(t,()=>t.bindTexture(o,a)),b(t,()=>t.texParameteri(o,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE)),b(t,()=>t.texParameteri(o,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),b(t,()=>t.texParameteri(o,t.TEXTURE_MIN_FILTER,t.NEAREST)),b(t,()=>t.texParameteri(o,t.TEXTURE_MAG_FILTER,t.NEAREST)),b(t,()=>t.texImage2D(o,0,r,e,n,0,i,s,null)),b(t,()=>t.bindTexture(t.TEXTURE_2D,null)),a}function Pe(t){return t.internalFormatFloat}function Fe(t,e,n,r){const[i,s]=p(e,n);return Re(t,i,s,Pe(r),r.textureFormatFloat,t.FLOAT)}function ze(t){return t.internalFormatHalfFloat}function Le(t,e,n,r){const[i,s]=p(e,n);return Re(t,i,s,ze(r),r.textureFormatFloat,r.textureTypeHalfFloat)}function $e(t){return t.downloadTextureFormat}function Be(t,e,n,r){const[i,s]=p(e,n);return Re(t,i,s,$e(r),t.RGBA,t.UNSIGNED_BYTE)}function qe(t){return t.internalFormatPackedFloat}function Ve(t,e,n,r){const[i,s]=m(e,n);return Re(t,i,s,qe(r),t.RGBA,t.FLOAT)}function Ue(t){return t.internalFormatPackedHalfFloat}function We(t,e,n,r){const[i,s]=m(e,n);return Re(t,i,s,Ue(r),t.RGBA,r.textureTypeHalfFloat)}function Ge(t,e,n){b(t,()=>t.bindBuffer(t.ARRAY_BUFFER,n));return M(t,e,"clipSpacePos",n,3,20,0)&&M(t,e,"uv",n,2,20,12)}function He(t,e,n,r,i,s){let a,o,u;b(t,()=>t.bindTexture(t.TEXTURE_2D,e)),i instanceof Uint8Array?(a=new Uint8Array(n*r*4),o=t.UNSIGNED_BYTE,u=t.RGBA):(a=new Float32Array(n*r*4),o=t.FLOAT,u=s.internalFormatPackedFloat),a.set(i),b(t,()=>t.texImage2D(t.TEXTURE_2D,0,u,n,r,0,t.RGBA,o,a)),b(t,()=>t.bindTexture(t.TEXTURE_2D,null))}function Ke(t,e,n){b(t,()=>t.bindTexture(t.TEXTURE_2D,e)),n.data instanceof Uint8Array?b(t,()=>t.texImage2D(t.TEXTURE_2D,0,t.RGBA,n.width,n.height,0,t.RGBA,t.UNSIGNED_BYTE,n.data)):b(t,()=>t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n)),b(t,()=>t.bindTexture(t.TEXTURE_2D,null))}function Qe(t,e,n,r){const i=t.createBuffer();b(t,()=>t.bindBuffer(t.PIXEL_PACK_BUFFER,i));const s=16*e*n;return b(t,()=>t.bufferData(t.PIXEL_PACK_BUFFER,s,t.STREAM_READ)),b(t,()=>t.readPixels(0,0,n,e,t.RGBA,t.FLOAT,0)),b(t,()=>t.bindBuffer(t.PIXEL_PACK_BUFFER,null)),i}function Xe(t,e,n){const r=t,i=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,e),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,i),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),i}function Ye(t,e,n,r){const[i,s]=p(e,n),a=new Uint8Array(e*n*4);return b(t,()=>t.readPixels(0,0,i,s,r.downloadTextureFormat,t.UNSIGNED_BYTE,a)),new Float32Array(a.buffer)}function Je(t,e,n,r,i,s,a,o){const u=t,c=new Float32Array(function(t,e){const[n,r]=m(t,e);return n*r*4}(s,a));return u.bindBuffer(u.PIXEL_PACK_BUFFER,e),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,c),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),c}function Ze(t,e,n){const r=new Float32Array(e*n*4);return b(t,()=>t.readPixels(0,0,n,e,t.RGBA,t.FLOAT,r)),r}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class tn{constructor(t){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];const e=Object(s.env)().getNumber("WEBGL_VERSION");null!=t?(this.gl=t,u(e,t)):this.gl=c(e);let n="WEBGL_color_buffer_float";if(1===Object(s.env)().getNumber("WEBGL_VERSION")){const t="OES_texture_float",e="OES_texture_half_float";if(this.textureFloatExtension=w(this.gl,t),st(this.gl,e))this.textureHalfFloatExtension=w(this.gl,e);else if(Object(s.env)().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),st(this.gl,"EXT_color_buffer_half_float"))this.colorBufferHalfFloatExtension=w(this.gl,"EXT_color_buffer_half_float");else if(Object(s.env)().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",st(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!st(this.gl,"EXT_color_buffer_half_float"))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension("EXT_color_buffer_half_float")}this.vertexBuffer=Me(this.gl),this.indexBuffer=De(this.gl),this.framebuffer=j(this.gl),this.textureConfig=g(this.gl,this.textureHalfFloatExtension)}get debug(){return Object(s.env)().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 t=this.gl;b(t,()=>t.finish()),b(t,()=>t.bindFramebuffer(t.FRAMEBUFFER,null)),b(t,()=>t.deleteFramebuffer(this.framebuffer)),b(t,()=>t.bindBuffer(t.ARRAY_BUFFER,null)),b(t,()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)),b(t,()=>t.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(t,e){return this.throwIfDisposed(),Fe(this.gl,t,e,this.textureConfig)}createFloat16MatrixTexture(t,e){return this.throwIfDisposed(),Le(this.gl,t,e,this.textureConfig)}createUnsignedBytesMatrixTexture(t,e){return this.throwIfDisposed(),Be(this.gl,t,e,this.textureConfig)}uploadPixelDataToTexture(t,e){this.throwIfDisposed(),Ke(this.gl,t,e)}uploadDenseMatrixToTexture(t,e,n,r){this.throwIfDisposed(),He(this.gl,t,e,n,r,this.textureConfig)}createFloat16PackedMatrixTexture(t,e){return this.throwIfDisposed(),We(this.gl,t,e,this.textureConfig)}createPackedMatrixTexture(t,e){return this.throwIfDisposed(),Ve(this.gl,t,e,this.textureConfig)}deleteMatrixTexture(t){this.throwIfDisposed(),this.outputTexture===t&&(B(this.gl,this.framebuffer),this.outputTexture=null),b(this.gl,()=>this.gl.deleteTexture(t))}downloadByteEncodedFloatMatrixFromOutputTexture(t,e,n){return this.downloadMatrixDriver(t,()=>Ye(this.gl,e,n,this.textureConfig))}downloadPackedMatrixFromBuffer(t,e,n,r,i,s){return Je(this.gl,t,0,0,0,i,s,this.textureConfig)}downloadFloat32MatrixFromBuffer(t,e){return Xe(this.gl,t,e)}createBufferFromTexture(t,e,n){this.bindTextureToFrameBuffer(t);const r=Qe(this.gl,e,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r}createAndWaitForFence(){const t=this.createFence(this.gl);return this.pollFence(t)}createFence(t){let e,n;if(Object(s.env)().getBool("WEBGL_FENCE_API_ENABLED")){const r=t,i=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);t.flush(),n=()=>{const t=r.clientWaitSync(i,0,0);return t===r.ALREADY_SIGNALED||t===r.CONDITION_SATISFIED},e=i}else Object(s.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(e=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(e,Object(s.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:e,isFencePassed:n}}downloadMatrixFromPackedTexture(t,e,n){return this.downloadMatrixDriver(t,()=>Ze(this.gl,e,n))}createProgram(t){this.throwIfDisposed();const e=this.gl,n=_(e,t),r=je(e),i=S(e);return b(e,()=>e.attachShader(i,r)),b(e,()=>e.attachShader(i,n)),k(e,i),this.debug&&T(e,i),this.vertexAttrsAreBound||(this.setProgram(i),this.vertexAttrsAreBound=Ge(e,this.program,this.vertexBuffer)),i}deleteProgram(t){this.throwIfDisposed(),t===this.program&&(this.program=null),null!=t&&b(this.gl,()=>this.gl.deleteProgram(t))}setProgram(t){this.throwIfDisposed(),this.program=t,null!=this.program&&this.debug&&T(this.gl,this.program),b(this.gl,()=>this.gl.useProgram(t))}getUniformLocation(t,e,n=!0){return this.throwIfDisposed(),n?P(this.gl,t,e):F(this.gl,t,e)}getAttributeLocation(t,e){return this.throwIfDisposed(),b(this.gl,()=>this.gl.getAttribLocation(t,e))}getUniformLocationNoThrow(t,e){return this.throwIfDisposed(),this.gl.getUniformLocation(t,e)}setInputMatrixTexture(t,e,n){this.throwIfDisposed(),this.throwIfNoProgram(),z(this.gl,t,e,n)}setOutputMatrixTexture(t,e,n){this.setOutputMatrixTextureDriver(t,n,e)}setOutputPackedMatrixTexture(t,e,n){this.throwIfDisposed();const[r,i]=m(e,n);this.setOutputMatrixTextureDriver(t,r,i)}setOutputMatrixWriteRegion(t,e,n,r){this.setOutputMatrixWriteRegionDriver(n,t,r,e)}setOutputPackedMatrixWriteRegion(t,e,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){null!=this.program&&T(this.gl,this.program),q(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const t=this.gl;this.debug&&this.debugValidate(),b(t,()=>t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),b(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=w(this.gl,2===Object(s.env)().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===Object(s.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const t=this.gl,e=this.getQueryTimerExtensionWebGL2(),n=t.createQuery();return t.beginQuery(e.TIME_ELAPSED_EXT,n),n}const t=this.getQueryTimerExtensionWebGL1(),e=t.createQueryEXT();return t.beginQueryEXT(t.TIME_ELAPSED_EXT,e),e}endQuery(){if(2===Object(s.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const t=this.gl,e=this.getQueryTimerExtensionWebGL2();return void t.endQuery(e.TIME_ELAPSED_EXT)}const t=this.getQueryTimerExtensionWebGL1();t.endQueryEXT(t.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(t){return await s.util.repeatedTry(()=>this.disposed||this.isQueryAvailable(t,Object(s.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(t,Object(s.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(t,e){if(0===e)return null;if(2===e){const e=this.gl;return e.getQueryParameter(t,e.QUERY_RESULT)/1e6}{const e=this.getQueryTimerExtensionWebGL1();return e.getQueryObjectEXT(t,e.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(t,e){if(0===e)return!0;if(2===e){const e=this.gl,n=this.getQueryTimerExtensionWebGL2(),r=e.getQueryParameter(t,e.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),r&&!this.disjoint}{const e=this.getQueryTimerExtensionWebGL1(),n=e.getQueryObjectEXT(t,e.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(e.GPU_DISJOINT_EXT)),n&&!this.disjoint}}pollFence(t){return new Promise(e=>{this.addItemToPoll(()=>t.isFencePassed(),()=>e())})}pollItems(){const t=function(t){let e=0;for(;e<t.length;++e){if(!t[e]())break}return e-1}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */(this.itemsToPoll.map(t=>t.isDoneFn));for(let e=0;e<=t;++e){const{resolveFn:t}=this.itemsToPoll[e];t()}this.itemsToPoll=this.itemsToPoll.slice(t+1)}addItemToPoll(t,e){this.itemsToPoll.push({isDoneFn:t,resolveFn:e}),this.itemsToPoll.length>1||s.util.repeatedTry(()=>(this.pollItems(),0===this.itemsToPoll.length))}bindTextureToFrameBuffer(t){this.throwIfDisposed(),$(this.gl,t,this.framebuffer),this.debug&&q(this.gl)}unbindTextureToFrameBuffer(){null!=this.outputTexture?($(this.gl,this.outputTexture,this.framebuffer),this.debug&&q(this.gl)):B(this.gl,this.framebuffer)}downloadMatrixDriver(t,e){this.bindTextureToFrameBuffer(t);const n=e();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(t,e,n){this.throwIfDisposed();const r=this.gl;$(r,t,this.framebuffer),this.debug&&q(r),this.outputTexture=t,b(r,()=>r.viewport(0,0,e,n)),b(r,()=>r.scissor(0,0,e,n))}setOutputMatrixWriteRegionDriver(t,e,n,r){this.throwIfDisposed(),b(this.gl,()=>this.gl.scissor(t,e,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.")}}function en(t,e){if(t.length!==e.length)throw Error(`Binary was compiled with ${t.length} inputs, but was executed with ${e.length} inputs`);t.forEach((t,n)=>{const r=t.logicalShape,i=e[n],a=i.shape;if(!s.util.arraysEqual(r,a))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${a} must match`);if(t.isUniform&&i.isUniform)return;const o=t.texShape,u=i.isUniform?null:i.texData.texShape;if(!s.util.arraysEqual(o,u))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${o} and ${u} must match`)})}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class nn{constructor(t,e,n){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;const{filterWidth:r,inChannels:i,strideWidth:s,strideHeight:a,padInfo:o,outWidth:u,dilationWidth:c,dilationHeight:l,dataFormat:h}=n,{left:d,top:p}=o,f=i*r,m=Mt(),g="channelsLast"===h,b=g?0:1,y=g?1:2;let v="";for(let n=0;n<=1;n++)for(let r=0;r<=1;r++)v+=`\n          blockIndex = rc.y + ${r};\n          pos = rc.x + ${n};\n\n          if(blockIndex < ${t[1]} && pos < ${t[0]}) {\n            offsetY = int(blockIndex / (${u})) * ${a} - ${p};\n            d0 = offsetY + ${l} * (pos / ${f});\n\n            if(d0 < ${e[b]} && d0 >= 0) {\n\n              offsetX = int(mod(float(blockIndex), ${u}.) * ${s}. - ${d}.);\n              d1 = offsetX + ${c} * (int(mod(float(pos), ${f}.) / ${i}.));\n\n              if(d1 < ${e[y]} && d1 >= 0) {\n\n                ch = int(mod(float(pos), ${i}.));\n\n                if (${g}) {\n                  innerDims = vec2(d1, ch);\n                  result[${2*n+r}] = getChannel(\n                    getA(d0, int(innerDims.x),\n                    int(innerDims.y)), innerDims);\n                } else {\n                  innerDims = vec2(d0, d1);\n                  result[${2*n+r}] = getChannel(\n                    getA(ch, int(innerDims.x),\n                    int(innerDims.y)), innerDims);\n                }\n              }\n            }\n          }\n        `;this.userCode=`\n      void main() {\n        ivec2 rc = getOutputCoords();\n\n        vec4 result = vec4(0);\n\n        int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n        vec2 innerDims;\n\n        ${v}\n\n        ${m.output} = result;\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class rn{constructor(t,e,n,r,i){this.variableNames=["x"],this.outputShape=[];const s=e,a=t[3]-1;let o;this.outputShape=t;const u=`float(${n}) + float(${r}) * sum`;o=.5===i?`inversesqrt(${u})`:1===i?`1.0/(${u})`:`exp(log(${u}) * float(-${i}));`,this.userCode=`\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int r = coords[1];\n        int c = coords[2];\n        int d = coords[3];\n        float x = getX(b, r, c, d);\n        float sum = 0.0;\n        for (int j = -${s}; j <= ${s}; j++) {\n          int idx = d + j;\n          if (idx >= 0 && idx <=  ${a}) {\n            float z = getX(b, r, c, idx);\n            sum += z * z;\n          }\n        }\n        float val = x * ${o};\n        setOutput(val);\n      }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class sn{constructor(t,e,n,r,i){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=t,this.depth=t[3],this.depthRadius=e,this.bias=n,this.alpha=r,this.beta=i,this.userCode=`\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int r = coords[1];\n        int c = coords[2];\n\n        float result = 0.0;\n        for (int d = 0; d < ${this.depth}; ++d) {\n          int depthBegin = int(max(0.0, float(d - ${e})));\n          int depthEnd = int(min(float(${this.depth}),\n              float(d + ${e} + 1)));\n\n          const int MIN_DEPTH_BEGIN = 0;\n          const int MAX_DEPTH_END = ${this.depth};\n\n          float norm = 0.0;\n          for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {\n            if (k < depthBegin){\n              continue;\n            }\n            else if (k >= depthBegin && k < depthEnd) {\n              norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n            }\n            else {\n              break;\n            }\n          }\n\n          norm = float(${r}) * norm + float(${n});\n\n          for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){\n            if (k < depthBegin){\n              continue;\n            }\n            else if (k >= depthBegin && k < depthEnd){\n              float dyi = -2.0 * float(${r})\n                * float(${i})\n                * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n                / norm;\n              if (k == d) {\n                dyi += pow(norm, -1.0 * ${i});\n              }\n              if (k == coords[3]) {\n                dyi *= getDy(b, r, c, d);\n                result += dyi;\n              }\n            }\n            else {\n              break;\n            }\n          }\n      }\n      setOutput(result);\n      }\n    `}}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class an{constructor(t,e,n,r,i){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const s=e,a=t[3]-1;let o;this.outputShape=t;const u=`float(${n}) + float(${r}) * sum`;o=.5===i?`inversesqrt(${u})`:1===i?`1.0/(${u})`:`exp(log(${u}) * float(-${i}));`,this.userCode=`\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords.x;\n        int r = coords.y;\n        int c = coords.z;\n        int d = coords.w;\n\n        bool hasNextCol = d < ${this.outputShape[3]};\n        bool hasNextRow = c < ${this.outputShape[2]};\n\n        vec4 sum = vec4(0.);\n        vec4 xFragAtOutputCoords = getX(b, r, c, d);\n\n        vec4 xAtOutputCoords = vec4(\n          getChannel(xFragAtOutputCoords, vec2(c, d)),\n          hasNextCol ?\n            getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,\n          hasNextRow ?\n            getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0\n        );\n\n        int firstChannel = d - ${s};\n        vec2 cache = vec2(0.);\n        if(firstChannel >= 0){\n          vec4 firstChannelFrag = getX(b, r, c, firstChannel);\n          cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));\n            if(hasNextRow){\n              cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));\n            }\n        }\n\n        ivec2 depth = ivec2(d, d + 1);\n        for (int j = - ${s}; j <= ${s}; j++) {\n          ivec2 idx = depth + j;\n          bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n          bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${a}));\n\n          bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n          bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n          if(depthInRange || depthPlusOneInRange){\n            vec4 z = vec4(0.);\n            vec4 xFragAtCurrentDepth;\n            z.xz = cache.xy;\n            if(depthPlusOneInRange && hasNextCol){\n              xFragAtCurrentDepth = idx.y != d ?\n                getX(b, r, c, idx.y) : xFragAtOutputCoords;\n              z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n              if(hasNextRow){\n                z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n              }\n            }\n            cache.xy = z.yw;\n            sum += z * z;\n          }\n        }\n        vec4 result = xAtOutputCoords * ${o};\n        setOutput(result);\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class on{constructor(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;const e=t.strideHeight,n=t.strideWidth,r=t.dilationHeight,i=t.effectiveFilterHeight,s=t.effectiveFilterWidth,a=i-1-t.padInfo.top,o=s-1-t.padInfo.left,u=i*s-1;this.userCode=`\n      const ivec2 pads = ivec2(${a}, ${o});\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n\n        ivec2 dyRCCorner = coords.yz - pads;\n        int dyRCorner = dyRCCorner.x;\n        int dyCCorner = dyRCCorner.y;\n\n        // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < ${i};\n          wR += ${r}) {\n          float dyR = float(dyRCorner + wR) / ${e}.0;\n\n          if (dyR < 0.0 || dyR >= ${t.outHeight}.0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          for (int wC = 0; wC < ${s}; wC++) {\n            float dyC = float(dyCCorner + wC) / ${n}.0;\n\n            if (dyC < 0.0 || dyC >= ${t.outWidth}.0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            float dyValue = getDy(b, idyR, idyC, d);\n            int maxPosValue = ${u} - int(getMaxPos(b, idyR, idyC, d));\n\n            // Get the current value, check it against the value from the\n            // position matrix.\n            int curPosValue = wR * ${s} + wC;\n            float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n            dotProd += dyValue * mask;\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}class un{constructor(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;const e=t.strideDepth,n=t.strideHeight,r=t.strideWidth,i=t.dilationDepth,s=t.dilationHeight,a=t.dilationWidth,o=t.effectiveFilterDepth,u=t.effectiveFilterHeight,c=t.effectiveFilterWidth,l=o-1-t.padInfo.front,h=u-1-t.padInfo.top,d=c-1-t.padInfo.left,p=o*u*c-1;this.userCode=`\n      const ivec3 pads = ivec3(${l}, ${h}, ${d});\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyDCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n        // dx(xD, xR, xC, ch).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int wD = 0; wD < ${o};\n           wD += ${i}) {\n          float dyD = float(dyDCorner + wD) / ${e}.0;\n\n          if (dyD < 0.0 || dyD >= ${t.outDepth}.0 || fract(dyD) > 0.0) {\n            continue;\n          }\n          int idyD = int(dyD);\n\n          for (int wR = 0; wR < ${u};\n              wR += ${s}) {\n            float dyR = float(dyRCorner + wR) / ${n}.0;\n\n            if (dyR < 0.0 || dyR >= ${t.outHeight}.0 ||\n                fract(dyR) > 0.0) {\n              continue;\n            }\n            int idyR = int(dyR);\n\n            for (int wC = 0; wC < ${c};\n                wC += ${a}) {\n              float dyC = float(dyCCorner + wC) / ${r}.0;\n\n              if (dyC < 0.0 || dyC >= ${t.outWidth}.0 ||\n                  fract(dyC) > 0.0) {\n                continue;\n              }\n              int idyC = int(dyC);\n\n              float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n              int maxPosValue = ${p} -\n                  int(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n              // Get the current value, check it against the value from the\n              // position matrix.\n              int curPosValue =\n                  wD * ${u} * ${c} +\n                  wR * ${c} + wC;\n              float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n              dotProd += dyValue * mask;\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class cn{constructor(t,e,n,r=!1,i=!1,s=!1,a=null,o=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n;const u=r?t[1]:t[2],c=Math.ceil(u/2),l=r?"i * 2, rc.y":"rc.y, i * 2",h=i?"rc.z, i * 2":"i * 2, rc.z",d=r?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],p=i?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let f="",m="";a&&(f=o?`vec4 activation(vec4 a) {\n          vec4 b = getPreluActivationWeightsAtOutCoords();\n          ${a}\n        }`:`vec4 activation(vec4 x) {\n          ${a}\n        }`,m="result = activation(result);");const g=s?"result += getBiasAtOutCoords();":"";s&&this.variableNames.push("bias"),o&&this.variableNames.push("preluActivationWeights");let b="rc.x",y="rc.x";t[0]<e[0]?b=`int(min(float(rc.x), ${t[0]-1}.))`:e[0]<t[0]&&(y=`int(min(float(rc.x), ${e[0]-1}.))`),this.userCode=`\n      ${f}\n\n      const float sharedDimension = ${c}.0;\n\n      vec4 dot2x2ARowBCol(ivec3 rc) {\n        vec4 result = vec4(0);\n        for (int i = 0; i < ${c}; i++) {\n          int batchA = ${b};\n          int batchB = ${y};\n          vec4 a = getMatrixA(batchA, ${l});\n          vec4 b = getMatrixB(batchB, ${h});\n\n          // These swizzled products need to be separately added.\n          // See: https://github.com/tensorflow/tfjs/issues/1735\n          result += (${d[0]} * ${p[0]});\n          result += (${d[1]} * ${p[1]});\n        }\n        return result;\n      }\n\n      void main() {\n        ivec3 rc = getOutputCoords();\n        vec4 result = dot2x2ARowBCol(rc);\n\n        ${g}\n\n        ${m}\n\n        setOutput(result);\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class ln{constructor(t,e,n){this.variableNames=["probs"],this.outputShape=[t,n],this.userCode=`\n      uniform float seed;\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n\n        float r = random(seed);\n        float cdf = 0.0;\n\n        for (int i = 0; i < ${e-1}; i++) {\n          cdf += getProbs(batch, i);\n\n          if (r < cdf) {\n            setOutput(float(i));\n            return;\n          }\n        }\n\n        // If no other event happened, last event happened.\n        setOutput(float(${e-1}));\n      }\n    `}getCustomSetupFunc(t){return(e,n)=>{null==this.seedLoc&&(this.seedLoc=e.getUniformLocation(n,"seed")),e.gl.uniform1f(this.seedLoc,t)}}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class hn{constructor(t,e,n,r){this.variableNames=["indices"],this.outputShape=[t,e],this.userCode=`\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int index = round(getIndices(coords.x));\n        setOutput(mix(float(${r}), float(${n}),\n                      float(index == coords.y)));\n      }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class dn{constructor(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=t;const e=t.length;if(0===e)this.userCode="\n        void main() {\n          setOutput(vec4(getA(), 0., 0., 0.));\n        }\n      ";else{const n=jt("rc",e),r=Kt(e),i=function(t,e,n){if(1===t)return"rc > "+e[0];let r="";for(let i=t-2;i<t;i++)r+=`${n[i]} >= ${e[i]}`,i<t-1&&(r+="||");return r}(e,t,n),s=function(t,e,n,r){if(1===t)return"";const i=r.slice(-2);return`\n    int r = ${i[0]};\n    int c = ${i[1]};\n    int rp1 = r + 1;\n    int cp1 = c + 1;\n\n    bool cEdge = cp1 >= ${e};\n    bool rEdge = rp1 >= ${n};\n  `}(e,t[t.length-1],t[t.length-2],n),a=function(t,e){const n=t.length,r=function(t,e){const n=[];for(let r=0;r<=1;r++)for(let i=0;i<=1;i++){let s=`${0===r?"r":"rp1"}, ${0===i?"c":"cp1"}`;for(let n=2;n<t;n++)s=e[e.length-1-n]+","+s;n.push(s)}return n}(n,e);if(1===n)return`getA(rc),\n            rc + 1 >= ${t[0]} ? 0. : getA(rc + 1),\n            0, 0`;return`getA(${r[0]}),\n          cEdge ? 0. : getA(${r[1]}),\n          rEdge ? 0. : getA(${r[2]}),\n          rEdge || cEdge ? 0. : getA(${r[3]})`}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */(t,n);this.userCode=`\n        void main() {\n          ${r} rc = getOutputCoords();\n\n          if(${i}) {\n            setOutput(vec4(0));\n          } else {\n            ${s}\n\n            setOutput(vec4(${a}));\n          }\n        }\n      `}}}class pn{constructor(t,e,n){this.variableNames=["x"],this.outputShape=e.map((e,n)=>e[0]+t[n]+e[1]);const r=t.length,i=Kt(r),s=e.map(t=>t[0]).join(","),a=e.map((e,n)=>e[0]+t[n]).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?`\n      ${i} start = ${i}(${s});\n      ${i} end = ${i}(${a});\n\n      void main() {\n        ${i} outC = getOutputCoords();\n        if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n          setOutput(float(${n}));\n        } else {\n          ${i} coords = outC - start;\n          setOutput(getX(${o}));\n        }\n      }\n    `:`\n        int start = ${s};\n        int end = ${a};\n\n        void main() {\n          int outC = getOutputCoords();\n          if (outC < start || outC >= end) {\n            setOutput(float(${n}));\n          } else {\n            setOutput(getX(outC - start));\n          }\n        }\n      `}}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class fn{constructor(t,e,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.map((e,n)=>e[0]+t[n]+e[1]);const r=t.length,i=Kt(r),s=e.map(t=>t[0]).join(","),a=e.map((e,n)=>e[0]+t[n]).join(","),o=jt("rc",r),u=jt("source",r),c=`${o[r-1]} < ${this.outputShape[r-1]}`,l=1===r?"source":`vec2(${u.slice(-2).join()})`,h=[i+" rc = outputLoc;",`${o[r-1]} += 1;\n       if(${c}) {\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(${c}) {`],d=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let p="";for(let t=0,e=1===r?2:4;t<e;t++)p+=`\n        ${h[t]}\n        if (${d}) {\n          result[${t}] = float(${n});\n        } else {\n          ${i} source = rc - start;\n          result[${t}] = getChannel(getX(${u.join()}), ${l});\n        }\n      `;p+=1===r?"} ":"}}",this.userCode=`\n      const ${i} start = ${i}(${s});\n      const ${i} end = ${i}(${a});\n\n      void main() {\n        ${i} outputLoc = getOutputCoords();\n        vec4 result = vec4(0.);\n        ${p}\n        setOutput(result);\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class mn{constructor(t,e,n,r=!1,i=!1){if(this.variableNames=["x"],"avg"===e&&n)throw new Error("Cannot compute positions for average pool.");const s=t.filterWidth,a=t.strideHeight,o=t.strideWidth,u=t.dilationHeight,c=t.dilationWidth,l=t.effectiveFilterHeight,h=t.effectiveFilterWidth,d=t.padInfo.top,p=t.padInfo.left;this.outputShape=t.outShape;const f="avg"===e,m=`((batch  * ${t.inHeight} + xR) * ${t.inWidth} + xC) * ${t.inChannels} + d`,g=`(xR * ${t.inWidth} + xC) * ${t.inChannels} + d`;let b="0.0";if(f||(b="-1.0 / 1e-20"),n){const e=">=";return void(this.userCode=`\n        const ivec2 strides = ivec2(${a}, ${o});\n        const ivec2 pads = ivec2(${d}, ${p});\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 < ${l};\n              wR += ${u}) {\n            int xR = xRCorner + wR;\n\n            if (xR < 0 || xR >= ${t.inHeight}) {\n              continue;\n            }\n\n            for (int wC = 0; wC < ${h};\n                wC += ${c}) {\n              int xC = xCCorner + wC;\n\n              if (xC < 0 || xC >= ${t.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 ${e} currMinMaxValue) {\n                minMaxValue = value;\n                minMaxValueFound = 1.0;\n                minMaxPosition = ${r?i?m:g:`wR * ${h} + wC`};\n              }\n            }\n          }\n          setOutput(float(minMaxPosition));\n        }\n      `)}let y=`${e}(${e}(${e}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===e&&(y="avgValue / count");const v=4*Math.floor(s/4),w=s%4,x=`\n      if (${f}) {\n        avgValue += dot(values, ones);\n      } else {\n        minMaxValue = max(values, minMaxValue);\n      }\n    `;this.userCode=`\n      const ivec2 strides = ivec2(${a}, ${o});\n      const ivec2 pads = ivec2(${d}, ${p});\n      const float initializationValue = ${b};\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 >= ${t.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(${b});\n        float avgValue = 0.0;\n        count = 0.0;\n\n        for (int wR = 0; wR < ${l};\n            wR += ${u}) {\n          int xR = xRCorner + wR;\n\n          if (xR < 0 || xR >= ${t.inHeight}) {\n            continue;\n          }\n\n          for (int wC = 0; wC < ${v}; wC += 4) {\n            int xC = xCCorner + wC * ${c};\n\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + ${c}, d),\n              getValue(batch, xR, xC + 2 * ${c}, d),\n              getValue(batch, xR, xC + 3 * ${c}, d)\n            );\n\n            ${x}\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            ${x}\n          } else if (${2===w}) {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + ${c}, d),\n              initializationValue,\n              initializationValue\n            );\n\n            ${x}\n          } else if (${3===w}) {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + ${c}, d),\n              getValue(batch, xR, xC + 2 * ${c}, d),\n              initializationValue\n            );\n\n            ${x}\n          }\n        }\n        setOutput(${y});\n      }\n    `}}class gn{constructor(t,e,n,r=!1,i=!1){if(this.variableNames=["x"],"avg"===e&&n)throw new Error("Cannot compute positions for average pool.");const s=t.filterWidth,a=t.strideDepth,o=t.strideHeight,u=t.strideWidth,c=t.dilationDepth,l=t.dilationHeight,h=t.dilationWidth,d=t.effectiveFilterDepth,p=t.effectiveFilterHeight,f=t.effectiveFilterWidth,m=t.padInfo.front,g=t.padInfo.top,b=t.padInfo.left;this.outputShape=t.outShape;const y="avg"===e;let v="0.0";if(y||(v="-1.0 / 1e-20"),n){const e=">=";return void(this.userCode=`\n        const ivec3 strides =\n            ivec3(${a}, ${o}, ${u});\n        const ivec3 pads = ivec3(${m}, ${g}, ${b});\n\n        void main() {\n          ivec5 coords = getOutputCoords();\n          int batch = coords.x;\n          int ch = coords.u;\n\n          ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n          int xDCorner = xCorner.x;\n          int xRCorner = xCorner.y;\n          int xCCorner = xCorner.z;\n\n          // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n          // ? = to be determined\n          float minMaxValue = 0.0;\n          float minMaxValueFound = 0.0;\n          int minMaxPosition = 0;\n\n          for (int wD = 0; wD < ${d};\n              wD += ${c}) {\n            int xD = xDCorner + wD;\n\n            if (xD < 0 || xD >= ${t.inDepth}) {\n              continue;\n            }\n\n            for (int wR = 0; wR < ${p};\n                wR += ${l}) {\n              int xR = xRCorner + wR;\n\n              if (xR < 0 || xR >= ${t.inHeight}) {\n                continue;\n              }\n\n              for (int wC = 0; wC < ${f};\n                  wC += ${h}) {\n                int xC = xCCorner + wC;\n\n                if (xC < 0 || xC >= ${t.inWidth}) {\n                  continue;\n                }\n\n                float value = getX(batch, xD, xR, xC, ch);\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 ${e} currMinMaxValue) {\n                  minMaxValue = value;\n                  minMaxValueFound = 1.0;\n                  minMaxPosition = ${r?i?`(((batch * ${t.inDepth} + xD) * ${t.inHeight} + xR) * ${t.inWidth} + xC) * ${t.inChannels} + ch`:`((xD * ${t.inHeight} + xR) * ${t.inWidth} + xC) * ${t.inChannels} + ch`:`wD * ${p} * ${f} +\n                      wR * ${f} + wC`};\n                }\n              }\n            }\n          }\n          setOutput(float(minMaxPosition));\n        }\n      `)}let w=`${e}(${e}(${e}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===e&&(w="avgValue / count");const x=4*Math.floor(s/4),_=s%4,O=`\n      if (${y}) {\n        avgValue += dot(values, ones);\n      } else {\n        minMaxValue = max(values, minMaxValue);\n      }\n    `;this.userCode=`\n      const ivec3 strides =\n        ivec3(${a}, ${o}, ${u});\n      const ivec3 pads = ivec3(${m}, ${g}, ${b});\n      const float initializationValue = ${v};\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 xD, int xR, int xC, int ch) {\n        if (xC < 0 || xC >= ${t.inWidth}) {\n          return initializationValue;\n        }\n        count += 1.0;\n        return getX(batch, xD, xR, xC, ch);\n      }\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n        int xDCorner = xCorner.x;\n        int xRCorner = xCorner.y;\n        int xCCorner = xCorner.z;\n\n        // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n        // ? = to be determined\n        vec4 minMaxValue = vec4(${v});\n        float avgValue = 0.0;\n        count = 0.0;\n\n        for (int wD = 0; wD < ${d};\n            wD += ${c}) {\n          int xD = xDCorner + wD;\n\n          if (xD < 0 || xD >= ${t.inDepth}) {\n            continue;\n          }\n\n          for (int wR = 0; wR < ${p};\n            wR += ${l}) {\n            int xR = xRCorner + wR;\n\n            if (xR < 0 || xR >= ${t.inHeight}) {\n              continue;\n            }\n\n            for (int wC = 0; wC < ${x}; wC += 4) {\n              int xC = xCCorner + wC * ${h};\n\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + ${h}, ch),\n                getValue(batch, xD, xR, xC + 2 * ${h}, ch),\n                getValue(batch, xD, xR, xC + 3 * ${h}, ch)\n              );\n\n              ${O}\n            }\n\n            int xC = xCCorner + ${x};\n            if (${1===_}) {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                initializationValue,\n                initializationValue,\n                initializationValue\n              );\n\n              ${O}\n            } else if (${2===_}) {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + ${h}, ch),\n                initializationValue,\n                initializationValue\n              );\n\n              ${O}\n            } else if (${3===_}) {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + ${h}, ch),\n                getValue(batch, xD, xR, xC + 2 * ${h}, ch),\n                initializationValue\n              );\n\n              ${O}\n            }\n          }\n          setOutput(${w});\n        }\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class bn{constructor(t,e){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:i,outSize:s}=t;this.outputShape=[r,s];let a="0.0",o="";"prod"===e?a="1.0":"min"===e?(a="1.0 / 1e-20",o="min"):"max"===e&&(a="-1.0 / 1e-20",o="max");let u=`${e}(${e}(${e}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"sum"===e?u="sumValue":"prod"===e?u="prodValue":"all"===e?u="allValue":"any"===e&&(u="anyValue");const c=4*Math.floor(n/4),l=n%4;let h=`\n      if (${"sum"===e}) {\n        sumValue += dot(values, ones);\n      } else if (${"prod"===e}) {\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      }\n    `,d="vec4";"all"===e?(a="1.0",h="\n        bool reducedAllValue = all(values);\n        float floatedReducedAllValue = float(reducedAllValue);\n        allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n      ",d="bvec4"):"any"===e&&(a="0.0",h="\n        bool reducedAnyValue = any(values);\n        float floatedReducedAnyValue = float(reducedAnyValue);\n        anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n      ",d="bvec4");let p="";i%n>0&&(p=`\n        if (inIdx < 0 || inIdx >= ${i}) {\n          return initializationValue;\n        }\n      `),this.userCode=`\n      const float initializationValue = ${a};\n      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n      float getValue(int batch, int inIdx) {\n        ${p}\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(${a});\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 < ${c}; i += 4) {\n          int inIdx = inOffset + i;\n          ${d} values = ${d}(\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 + ${c};\n        if (${1===l}) {\n          ${d} values = ${d}(\n            getValue(batch, inIdx),\n            initializationValue,\n            initializationValue,\n            initializationValue\n          );\n\n          ${h}\n        } else if (${2===l}) {\n          ${d} values = ${d}(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            initializationValue,\n            initializationValue\n          );\n\n          ${h}\n        } else if (${3===l}) {\n          ${d} values = ${d}(\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    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class yn{constructor(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;let n="";for(let t=0;t<4;t++){let e="thisRC = rc;";t%2==1&&(e+="thisRC.z += 1;"),t>1&&(e+="thisRC.y += 1;"),n+=`\n        ${e}\n        ${t>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[${t}] =\n            getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n        ${t>0?"}":""}\n      `}var r;
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */this.userCode=`\n      ${r=e,`\n    ivec3 inputCoordsFromReshapedOutCoords(int index) {\n      ${Dt(["r","c","d"],r)}\n      return ivec3(r, c, d);\n    }\n  `}\n      ${Rt(t)}\n\n      void main() {\n        ivec3 rc = getOutputCoords();\n\n        vec4 result = vec4(0.);\n\n        ivec3 thisRC;\n        int rows = ${t[1]};\n        int cols = ${t[2]};\n\n        ${n}\n\n        setOutput(result);\n      }\n    `}}class vn{constructor(t,e,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e.shape;const[,r,i]=e.shape,[,s,a]=t.shape,o=[n&&s>1?r-1:r,n&&a>1?i-1:i],u=[n&&s>1?s-1:s,n&&a>1?a-1:a],c=o[0]/u[0],l=o[1]/u[1],h=1/c,d=1/l,p=2*Math.ceil(h)+2,f=2*Math.ceil(d)+2;this.userCode=`\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        int r = coords[1];\n        int c = coords[2];\n\n        float accumulator = 0.0;\n\n        const float heightScale = float(${c});\n        const float widthScale = float(${l});\n\n        const float invHeightScale = float(${h});\n        const float invWidthScale = float(${d});\n\n        const int winHeight = int(${p});\n        const int winWidth = int(${f});\n\n        // Compute bounds for where in dy we will look\n        float startRLerp = floor(float(r) * invHeightScale);\n        int startDyR = int(startRLerp - float(winHeight / 2));\n\n        float startCLerp = floor(float(c) * invWidthScale);\n        int startDyC = int(startCLerp - float(winWidth / 2));\n\n        // Loop over dy\n        for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n          int dyR = dyROffset + startDyR;\n\n          // Guard against the window exceeding the bounds of dy\n          if (dyR < 0 || dyR >= ${s}) {\n            continue;\n          }\n\n          for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n            int dyC = dyCOffset + startDyC;\n\n            // Guard against the window exceeding the bounds of dy\n            if (dyC < 0 || dyC >= ${a}) {\n              continue;\n            }\n\n            float dxR = float(dyR) * heightScale;\n            int topDxRIndex = int(floor(dxR));\n            int bottomDxRIndex = int(min(ceil(dxR), ${r-1}.0));\n            float dxRLerp = dxR - float(topDxRIndex);\n            float inverseDxRLerp = 1.0 - dxRLerp;\n\n            float dxC = float(dyC) * widthScale;\n            int leftDxCIndex = int(floor(dxC));\n            int rightDxCIndex = int(min(ceil(dxC), ${i-1}.0));\n            float dxCLerp = dxC - float(leftDxCIndex);\n            float inverseDxCLerp = 1.0 - dxCLerp;\n\n            if (r == topDxRIndex && c == leftDxCIndex) {\n              // topLeft\n              accumulator +=\n                getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n            }\n\n            if (r == topDxRIndex && c == rightDxCIndex) {\n              // topRight\n              accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n            }\n\n            if (r == bottomDxRIndex && c == leftDxCIndex) {\n              // bottomLeft\n              accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n            }\n\n            if (r == bottomDxRIndex && c == rightDxCIndex) {\n              // bottomRight\n              accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n            }\n          }\n        }\n        // End loop over dy\n\n        setOutput(accumulator);\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class wn{constructor(t,e,n,r){this.variableNames=["A"],this.outputShape=[];const[i,s,a,o]=t;this.outputShape=[i,e,n,o];const u=[r&&e>1?s-1:s,r&&n>1?a-1:a],c=[r&&e>1?e-1:e,r&&n>1?n-1:n];this.userCode=`\n      const vec2 effectiveInputOverOutputRatioRC = vec2(\n          ${u[0]/c[0]},\n          ${u[1]/c[1]});\n      const vec2 inputShapeRC = vec2(${s}.0, ${a}.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 = vec2(yRC) * effectiveInputOverOutputRatioRC;\n\n        // Compute the four integer indices.\n        ivec2 sourceFloorRC = ivec2(sourceFracIndexRC);\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    `}}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class xn{constructor(t,e,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,s,a,o]=t;this.outputShape=[i,e,n,o];const u=[r&&e>1?s-1:s,r&&n>1?a-1:a],c=[r&&e>1?e-1:e,r&&n>1?n-1:n];this.userCode=`\n      const vec3 effectiveInputOverOutputRatioRC = vec3(\n          ${u[0]/c[0]},\n          ${u[1]/c[1]},\n          ${u[1]/c[1]});\n      const vec3 inputShapeRC = vec3(${s}.0, ${a}.0,\n                                     ${a}.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 = vec3(yRC) * effectiveInputOverOutputRatioRC;\n\n        // Compute the four integer indices.\n        ivec3 sourceFloorRC = ivec3(sourceFracIndexRC);\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 < ${o-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    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class _n{constructor(t,e,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e.shape;const[,r,i]=e.shape,[,s,a]=t.shape,o=[n&&s>1?r-1:r,n&&a>1?i-1:i],u=[n&&s>1?s-1:s,n&&a>1?a-1:a],c=o[0]/u[0],l=o[1]/u[1],h=1/c,d=1/l,p=2*Math.ceil(h)+2,f=2*Math.ceil(d)+2;this.userCode=`\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        int r = coords[1];\n        int c = coords[2];\n\n        float accumulator = 0.0;\n\n        const float heightScale = float(${c});\n        const float widthScale = float(${l});\n\n        const float invHeightScale = float(${h});\n        const float invWidthScale = float(${d});\n\n        const int winHeight = int(${p});\n        const int winWidth = int(${f});\n\n        // Compute bounds for where in dy we will look\n        float startRLerp = floor(float(r) * invHeightScale);\n        int startDyR = int(floor(startRLerp - float(winHeight / 2)));\n\n        float startCLerp = floor(float(c) * invWidthScale);\n        int startDyC = int(floor(startCLerp - float(winWidth / 2)));\n\n        // Loop over dy\n        for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n          int dyR = dyROffset + startDyR;\n\n          // Guard against the window exceeding the bounds of dy\n          if (dyR < 0 || dyR >= ${s}) {\n            continue;\n          }\n\n          for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n            int dyC = dyCOffset + startDyC;\n\n            // Guard against the window exceeding the bounds of dy\n            if (dyC < 0 || dyC >= ${a}) {\n              continue;\n            }\n\n            float sourceFracRow =\n              float(${o[0]}) *\n                (float(dyR) / float(${u[0]}));\n\n            float sourceFracCol =\n                float(${o[1]}) *\n                  (float(dyC) / float(${u[1]}));\n\n            int sourceNearestRow = int(min(\n                float(int(${r}) - 1),\n                ${n} ? float(round(sourceFracRow)) :\n                                  float(floor(sourceFracRow))));\n\n            int sourceNearestCol = int(min(\n                float(int(${i}) - 1),\n                ${n} ? float(round(sourceFracCol)) :\n                                  float(floor(sourceFracCol))));\n\n            if (r == sourceNearestRow && c == sourceNearestCol) {\n              accumulator += getDy(b, dyR, dyC, d);\n            }\n          }\n        }\n        // End loop over dy\n\n        setOutput(accumulator);\n      }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class On{constructor(t,e,n,r){this.variableNames=["A"],this.outputShape=[];const[i,s,a,o]=t;this.outputShape=[i,e,n,o];const u=[r&&e>1?s-1:s,r&&n>1?a-1:a],c=[r&&e>1?e-1:e,r&&n>1?n-1:n],l=r?"0.5":"0.0";this.userCode=`\n      const vec2 effectiveInputOverOutputRatioRC = vec2(\n          ${u[0]/c[0]},\n          ${u[1]/c[1]});\n      const vec2 inputShapeRC = vec2(${s}.0, ${a}.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 = vec2(yRC) * effectiveInputOverOutputRatioRC;\n\n        // Compute the coordinators of nearest neighbor point.\n        ivec2 sourceNearestRC = ivec2(\n          min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${l})));\n\n        float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n        setOutput(newValue);\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Sn{constructor(t,e){this.variableNames=["x"];const n=t.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);if(this.outputShape=t,1===n)return void(this.userCode=`\n        void main() {\n          int coord = getOutputCoords();\n          setOutput(getX(${t[0]} - coord - 1));\n        }\n      `);const r=t.map((n,r)=>(n=>-1!==e.indexOf(n)&&1!==t[n]?`${t[n]} - coords[${n}] - 1`:`coords[${n}]`)(r)).join(","),i=Kt(n);this.userCode=`\n      void main() {\n        ${i} coords = getOutputCoords();\n        setOutput(getX(${r}));\n      }\n    `}}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class kn{constructor(t,e){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const n=t.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);this.outputShape=t;const r=jt("rc",n),i=`${r[n-1]} + 1 < ${this.outputShape[n-1]}`,s=`${r[n-2]} + 1 < ${this.outputShape[n-2]}`,a=Kt(n);function o(n){const r=t.map((r,i)=>function(n,r){return-1!==e.indexOf(n)&&1!==t[n]?`${t[n]} - ${r[n]} - 1`:""+r[n]}(i,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(${t[0]} - rc - 1),\n            ${t[0]} - rc - 1);\n          if(${i}){\n              result.g = getChannel(getX(${t[0]} - (rc  + 1) - 1),\n                ${t[0]} - (rc  + 1) - 1);\n          }\n          setOutput(result);\n        }\n      `:`\n        void main() {\n          ${a} rc = getOutputCoords();\n          vec4 result = vec4(0.);\n          result.r = ${function(t){return o(t)}(r.slice())};\n          if(${i}){\n            result.g = ${function(t){return t[n-1]="("+t[n-1]+" + 1)",o(t)}(r.slice())};\n          }\n          if(${s}) {\n            result.b = ${function(t){return t[n-2]="("+t[n-2]+" + 1)",o(t)}(r.slice())};\n            if(${i}) {\n              result.a = ${function(t){return t[n-1]="("+t[n-1]+" + 1)",t[n-2]="("+t[n-2]+" + 1)",o(t)}(r.slice())};\n            }\n          }\n          setOutput(result);\n        }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Tn{constructor(t,e,n,r,i,s,a=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=s;const o=Kt(i.length),u=Kt(s.length);let c="";1===n?c="i":2===n&&(c="i, j");const l=`getIndices(${c})`;let h="";1===r?h="i":2===r&&(h="i, coords[1]");const d=`getUpdates(${h})`,p=e>1?"strides[j]":"strides";this.userCode=`\n        ${o} strides = ${o}(${i});\n\n        void main() {\n          ${u} coords = getOutputCoords();\n          float sum = 0.0;\n          bool found = false;\n          for (int i = 0; i < ${t}; i++) {\n            int flattenedIndex = 0;\n            for (int j = 0; j < ${e}; j++) {\n              int index = round(${l});\n              flattenedIndex += index * ${p};\n            }\n            if (flattenedIndex == coords[0]) {\n              sum += ${d};\n              found = true;\n            }\n          }\n          setOutput(mix(getDefaultValue(), sum, float(found)));\n        }\n      `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Cn{constructor(t,e){this.variableNames=["x","segmentIds"];const n=t.windowSize,r=t.batchSize,i=t.inSize,s=t.numSegments,a=s*Math.ceil(i/n);this.outputShape=[r,a];const o=4*Math.floor(n/4),u=n%4,c="\n        sumValue += dot(values, segFilter);\n    ";let l="";i%n>0&&(l=`\n        if (inIdx < 0 || inIdx >= ${i}) {\n          return initializationValue;\n        }\n      `);let h="";i%n>0&&(h=`\n        if (inIdx < 0 || inIdx >= ${i}) {\n          return -1.0;\n        }\n      `),this.userCode=`\n      const float initializationValue = 0.0;\n\n      float getValue(int batch, int inIdx) {\n        ${l}\n        return getX(batch, inIdx);\n      }\n\n      float getSegmentIdAtIndex(int inIdx) {\n        ${h}\n        return getSegmentIds(inIdx);\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = int(floor(float(outIdx) / float(\n          ${s})) * float(${n}));\n        int currentSeg = int(mod(float(outIdx), float(${s})));\n\n        float sumValue = 0.0;\n\n        for (int i = 0; i < ${o}; 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          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0\n          );\n\n          ${c}\n        }\n\n        int inIdx = inOffset + ${o};\n        if (${1===u}) {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            initializationValue,\n            initializationValue,\n            initializationValue\n          );\n\n          int inIdxSeg = int(getSegmentIdAtIndex(inIdx));\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            0,\n            0,\n            0\n          );\n\n          ${c}\n        } else if (${2===u}) {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            initializationValue,\n            initializationValue\n          );\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n              0,\n              0\n          );\n\n          ${c}\n        } else if (${3===u}) {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            initializationValue\n          );\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n            0\n          );\n\n          ${c}\n        }\n        setOutput(sumValue);\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class An{constructor(t,e,n){let r,i;if(this.variableNames=["c","a","b"],this.outputShape=e,n>4)throw Error(`Where for rank ${n} is not yet supported`);if(1===n)i="resRC",r="resRC";else{const n=["resRC.x","resRC.y","resRC.z","resRC.w"],s=[],a=[];for(let r=0;r<e.length;r++)a.push(""+n[r]),r<t&&s.push(""+n[r]);r=s.join(),i=a.join()}const s=Kt(n);this.userCode=`\n      void main() {\n        ${s} resRC = getOutputCoords();\n        float cVal = getC(${r});\n        if (cVal >= 1.0) {\n          setOutput(getA(${i}));\n        } else {\n          setOutput(getB(${i}));\n        }\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Nn{constructor(t){this.variableNames=["source"],this.outputShape=t,this.rank=t.length;const e=Kt(this.rank),n=`uniform int start[${this.rank}];`,r=function(t){if(1===t)return"sourceLoc";if(t<=6)return In.slice(0,t).map(t=>"sourceLoc."+t).join(",");throw Error(`Slicing for rank ${t} is not yet supported`)}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */(this.rank);let i;i=`\n        ${e} sourceLoc;\n        ${e} coords = getOutputCoords();\n        ${t.map((t,e)=>`sourceLoc.${In[e]} = start[${e}] + coords.${In[e]};`).join("\n")}\n      `,this.userCode=`\n      ${n}\n      void main() {\n        ${i}\n        setOutput(getSource(${r}));\n      }\n    `}getCustomSetupFunc(t){if(t.length!==this.rank)throw Error(`The rank (${this.rank}) of the program must match the length of start (${t.length})`);return(e,n)=>{null==this.startLoc&&(this.startLoc=e.getUniformLocationNoThrow(n,"start"),null==this.startLoc)||e.gl.uniform1iv(this.startLoc,t)}}}const In=["x","y","z","w","u","v"];class En{constructor(t){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.rank=t.length;const e=Kt(this.rank),n=jt("coords",this.rank),r=jt("sourceLoc",this.rank),i=1===this.rank?"sourceLoc":`vec2(${r.slice(-2).join()})`,s=`getChannel(getSource(${r.join()}), ${i})`,a=`\n      result.x = ${s};\n      if (++${n[this.rank-1]} < ${t[this.rank-1]}) {\n        ++${r[this.rank-1]};\n        result.y = ${s};\n        --${r[this.rank-1]};\n      }\n    `,o=1===this.rank?"":`\n      --${n[this.rank-1]};\n      if (++${n[this.rank-2]} < ${t[this.rank-2]}) {\n        ++${r[this.rank-2]};\n        result.z = ${s};\n        if (++${n[this.rank-1]} < ${t[this.rank-1]}) {\n          ++${r[this.rank-1]};\n          result.w = ${s};\n        }\n      }\n    `,u=this.rank<=4?`sourceLoc = coords +\n            ${e}(${t.map((t,e)=>`start[${e}]`).join()});`:t.map((t,e)=>`${r[e]} = ${n[e]} + start[${e}];`).join("\n");this.userCode=`\n      uniform int start[${this.rank}];\n      void main() {\n        ${e} coords = getOutputCoords();\n        ${e} sourceLoc;\n        ${u}\n        vec4 result = vec4(0.);\n        ${a}\n        ${o}\n        setOutput(result);\n      }\n    `}getCustomSetupFunc(t){if(t.length!==this.rank)throw Error(`The rank (${this.rank}) of the program must match the length of start (${t.length})`);return(e,n)=>{null==this.startLoc&&(this.startLoc=e.getUniformLocationNoThrow(n,"start"),null==this.startLoc)||e.gl.uniform1iv(this.startLoc,t)}}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class jn{constructor(t,e,n){this.variableNames=["x"],this.outputShape=n;const r=n.length,i=Kt(n.length),s=Kt(n.length);let a="";if(1===r)a="coords * strides + begin";else{let t=0;a=n.map((e,r)=>(t++,1===n.length?`coords * strides[${r}] + begin[${r}]`:`coords[${t-1}] * strides[${r}] + begin[${r}]`)).join(",")}this.userCode=`\n      ${i} begin = ${i}(${t});\n      ${i} strides = ${i}(${e});\n\n      void main() {\n        ${s} coords = getOutputCoords();\n        setOutput(getX(${a}));\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Mn{constructor(t){this.gpgpu=t,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}acquireTexture(t,e,n){const r=Rn(e,n),i=Pn(t,r,n);i in this.freeTextures||(this.freeTextures[i]=[]),i in this.usedTextures||(this.usedTextures[i]=[]);const s=Dn(t,r,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[i].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=s,this.log();const t=this.freeTextures[i].shift();return this.usedTextures[i].push(t),t}let a;return r===d.PACKED_2X2_FLOAT32?a=this.gpgpu.createPackedMatrixTexture(t[0],t[1]):r===d.PACKED_2X2_FLOAT16?a=this.gpgpu.createFloat16PackedMatrixTexture(t[0],t[1]):r===d.UNPACKED_FLOAT32?a=this.gpgpu.createFloat32MatrixTexture(t[0],t[1]):r===d.UNPACKED_FLOAT16?a=this.gpgpu.createFloat16MatrixTexture(t[0],t[1]):r===d.PACKED_4X1_UNSIGNED_BYTE&&(a=this.gpgpu.createUnsignedBytesMatrixTexture(t[0],t[1])),this.usedTextures[i].push(a),this.numUsedTextures++,this._numBytesAllocated+=s,this.log(),a}releaseTexture(t,e,n,r){if(null==this.freeTextures)return;const i=Rn(n,r),a=Pn(e,i,r);a in this.freeTextures||(this.freeTextures[a]=[]);const o=Dn(e,i,this.gpgpu.gl,this.gpgpu.textureConfig,r),u=Object(s.env)().get("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==u&&this._numBytesAllocated>u?(this.gpgpu.deleteMatrixTexture(t),this._numBytesAllocated-=o):(this.freeTextures[a].push(t),this.numFreeTextures++,this._numBytesFree+=o),this.numUsedTextures--;const c=this.usedTextures[a],l=c.indexOf(t);if(l<0)throw new Error("Cannot release a texture that was never provided by this texture manager");c.splice(l,1),this.log()}log(){if(!this.logEnabled)return;const t=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${t})`);const e=this._numBytesFree/this._numBytesAllocated;console.log("Bytes allocated: "+this._numBytesAllocated),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*e)}%)`)}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 t in this.freeTextures)this.freeTextures[t].forEach(t=>{this.gpgpu.deleteMatrixTexture(t)});for(const t in this.usedTextures)this.usedTextures[t].forEach(t=>{this.gpgpu.deleteMatrixTexture(t)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function Dn(t,e,n,r,i){const s=function(t,e){switch(t){case d.PACKED_2X2_FLOAT32:return qe(e);case d.PACKED_2X2_FLOAT16:return Ue(e);case d.UNPACKED_FLOAT32:return Pe(e);case d.UNPACKED_FLOAT16:return ze(e);case d.PACKED_4X1_UNSIGNED_BYTE:return $e(e);default:throw new Error("Unknown physical texture type "+t)}}(e,r);let a;if(i){const[e,n]=m(t[0],t[1]);a=e*n}else{const[e,n]=p(t[0],t[1]);a=e*n}return a*function(t,e){const n=t;if(e===n.R32F)return 4;if(e===n.R16F)return 2;if(e===n.RGBA32F)return 16;if(e===t.RGBA)return 16;if(e===n.RGBA16F)return 8;throw new Error("Unknown internal format "+e)}(n,s)}function Rn(t,e){if(t===h.UPLOAD)return d.PACKED_2X2_FLOAT32;if(t===h.RENDER||null==t)return function(t){return Object(s.env)().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?t?d.PACKED_2X2_FLOAT32:d.UNPACKED_FLOAT32:t?d.PACKED_2X2_FLOAT16:d.UNPACKED_FLOAT16}(e);if(t===h.DOWNLOAD||t===h.PIXELS)return d.PACKED_4X1_UNSIGNED_BYTE;throw new Error("Unknown logical texture type "+t)}function Pn(t,e,n){return`${t[0]}_${t[1]}_${e}_${n}`}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Fn{constructor(t,e){this.variableNames=["A"];const n=new Array(t.length);for(let r=0;r<n.length;r++)n[r]=t[r]*e[r];this.outputShape=n,this.rank=n.length;const r=Kt(this.rank),i=function(t){const e=t.length;if(e>5)throw Error(`Tile for rank ${e} is not yet supported`);if(1===e)return`imod(resRC, ${t[0]})`;const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[];for(let e=0;e<t.length;e++)r.push(`imod(${n[e]}, ${t[e]})`);return r.join()}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */(t);this.userCode=`\n      void main() {\n        ${r} resRC = getOutputCoords();\n        setOutput(getA(${i}));\n      }\n    `}}class zn{constructor(t,e){this.variableNames=["A"],this.outputShape=t,this.userCode=`\n      float unaryOperation(float x) {\n        ${e}\n      }\n\n      void main() {\n        float x = getAAtOutCoords();\n        float y = unaryOperation(x);\n\n        setOutput(y);\n      }\n    `}}const Ln="return abs(x);",$n="if (isnan(x)) return x;\n  return (x < 0.0) ? 0.0 : x;\n",Bn="if (isnan(x)) return x;\n  return (x < 0.0) ? 0.0 : min(6.0, x);\n",qn="return (x >= 0.0) ? x : (exp(x) - 1.0);",Vn=`\n  // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n  // see: https://arxiv.org/abs/1706.02515\n  float scaleAlpha = ${s.backend_util.SELU_SCALEALPHA};\n  float scale = ${s.backend_util.SELU_SCALE};\n  return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n`;const Un="return -x;",Wn="return ceil(x);",Gn="return floor(x);",Hn="return exp(x);",Kn="return exp(x) - 1.0;",Qn=`\n  // Error function is calculated approximately with elementary function.\n  // See "Handbook of Mathematical Functions with Formulas,\n  // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n  float p = ${s.backend_util.ERF_P};\n  float a1 = ${s.backend_util.ERF_A1};\n  float a2 = ${s.backend_util.ERF_A2};\n  float a3 = ${s.backend_util.ERF_A3};\n  float a4 = ${s.backend_util.ERF_A4};\n  float a5 = ${s.backend_util.ERF_A5};\n\n  float sign = sign(x);\n  x = abs(x);\n  float t = 1.0 / (1.0 + p * x);\n  return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n`,Xn="return x;",Yn="\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",Jn="\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",Zn="\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";class tr{constructor(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.userCode=`\n      vec4 unaryOperation(vec4 x) {\n        ${e}\n      }\n\n      void main() {\n        vec4 x = getAAtOutCoords();\n        vec4 y = unaryOperation(x);\n\n        setOutput(y);\n      }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class er{constructor(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=t;const e=t.length,n=jt("rc",e),r=Kt(e),i=function(t,e){if(1===t)return"rc";let n="";for(let r=0;r<t;r++)n+=e[r],r<t-1&&(n+=",");return n}(e,n),s=n.slice(-2),a=e<=1?"rc":`vec2(${s.join(",")})`;this.userCode=`\n      void main() {\n        ${r} rc = getOutputCoords();\n        vec4 packedInput = getA(${i});\n\n        setOutput(getChannel(packedInput, ${a}));\n      }\n    `}}
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const{segment_util:nr}=s.backend_util,rr=s.kernel_impls.split,ir=s.kernel_impls.tile,sr=s.kernel_impls.topkImpl,ar=s.kernel_impls.whereImpl,or={};function ur(t,e=!1){if("linear"===t)return"return x;";if("relu"===t)return e?Yn:$n;if("elu"===t)return e?Zn:qn;if("relu6"===t)return e?Jn:Bn;if("prelu"===t)return e?ne:te;throw new Error(`Activation ${t} has not been implemented for the WebGL backend.`)}class cr extends s.KernelBackend{constructor(t){if(super(),this.pendingRead=new WeakMap,this.pendingDisposal=new WeakSet,this.dataRefCount=new WeakMap,this.numBytesInGPU=0,this.uploadWaitMs=0,this.downloadWaitMs=0,this.warnedAboutMemory=!1,this.warnedAboutCPUBackend=!1,this.pendingDeletes=0,this.disposed=!1,!Object(s.env)().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(null==t){const t=c(Object(s.env)().getNumber("WEBGL_VERSION"));this.binaryCache=((e=Object(s.env)().getNumber("WEBGL_VERSION"))in or||(or[e]={}),or[e]),this.gpgpu=new tn(t),this.canvas=t.canvas,this.gpgpuCreatedLocally=!0}else this.gpgpu=t,this.binaryCache={},this.gpgpuCreatedLocally=!1,this.canvas=t.gl.canvas;var e;this.textureManager=new Mn(this.gpgpu),this.numMBBeforeWarning=null==Object(s.env)().global.screen?1024:Object(s.env)().global.screen.height*Object(s.env)().global.screen.width*window.devicePixelRatio*600/1024/1024,this.texData=new s.DataStorage(this,Object(s.engine)())}numDataIds(){return this.texData.numDataIds()+(this.cpuBackend?this.cpuBackend.numDataIds():0)-this.pendingDeletes}write(t,e,n){if((Object(s.env)().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||Object(s.env)().getBool("DEBUG"))&&this.checkNumericalProblems(t),"complex64"===n&&null!=t)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");const r={};return this.texData.set(r,{shape:e,dtype:n,values:t,usage:h.UPLOAD,refCount:1,complexParentRefCount:0}),r}incRef(t){this.texData.get(t).refCount++}decRef(t){if(this.texData.has(t)){this.texData.get(t).refCount--}}move(t,e,n,r){if(Object(s.env)().getBool("DEBUG")&&this.checkNumericalProblems(e),"complex64"===r)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(t,{shape:n,dtype:r,values:e,usage:h.UPLOAD,refCount:1,complexParentRefCount:0})}disposeIntermediateTensorInfo(t){const e=t.dataId;if(this.texData.has(e)){const t=this.texData.get(e);t.refCount--,t.refCount<1&&this.disposeData(e)}}readSync(t){const e=this.texData.get(t),{values:n,dtype:r,complexTensorInfos:i,slice:a,shape:o,isPacked:u}=e;if(null!=a){let e;e=u?new tr(o,Xn):new zn(o,Xn);const n=this.runWebGLProgram(e,[{dataId:t,shape:o,dtype:r}],r),i=this.readSync(n.dataId);return this.disposeIntermediateTensorInfo(n),i}if(null!=n)return this.convertAndCacheOnCPU(t);if("string"===r)return n;const c=null!=this.activeTimers;let l,h;if(c&&(l=s.util.now()),"complex64"===r){const t=this.readSync(i.real.dataId),e=this.readSync(i.imag.dataId);h=s.backend_util.mergeRealAndImagArrays(t,e)}else h=this.getValuesFromTexture(t);return c&&(this.downloadWaitMs+=s.util.now()-l),this.convertAndCacheOnCPU(t,h)}async read(t){if(this.pendingRead.has(t)){const e=this.pendingRead.get(t);return new Promise(t=>e.push(t))}const e=this.texData.get(t),{values:n,shape:r,slice:i,dtype:a,complexTensorInfos:o,isPacked:u}=e;if(null!=i){let e;e=u?new tr(r,Xn):new zn(r,Xn);const n=this.runWebGLProgram(e,[{dataId:t,shape:r,dtype:a}],a),i=this.read(n.dataId);return this.disposeIntermediateTensorInfo(n),i}if(null!=n)return this.convertAndCacheOnCPU(t);if(!Object(s.env)().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===Object(s.env)().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let c,l,h=null;if("complex64"!==a&&Object(s.env)().get("WEBGL_BUFFER_SUPPORTED")){c=this.decode(t);const e=this.texData.get(c.dataId);h=this.gpgpu.createBufferFromTexture(e.texture,...f(r))}if(this.pendingRead.set(t,[]),"complex64"!==a&&await this.gpgpu.createAndWaitForFence(),"complex64"===a){const t=await Promise.all([this.read(o.real.dataId),this.read(o.imag.dataId)]),e=t[0],n=t[1];l=s.backend_util.mergeRealAndImagArrays(e,n)}else if(null==h)l=this.getValuesFromTexture(t);else{const t=s.util.sizeFromShape(r);l=this.gpgpu.downloadFloat32MatrixFromBuffer(h,t)}null!=c&&this.disposeIntermediateTensorInfo(c);const d=this.convertAndCacheOnCPU(t,l),p=this.pendingRead.get(t);return this.pendingRead.delete(t),p.forEach(t=>t(d)),this.pendingDisposal.has(t)&&(this.pendingDisposal.delete(t),this.disposeData(t),this.pendingDeletes--),d}checkNumericalProblems(t){if(null!=t)for(let e=0;e<t.length;e++){const n=t[e];if(!y(n)){if(Object(s.env)().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(t){const{shape:e,dtype:n,isPacked:r}=this.texData.get(t),i=s.util.sizeFromShape(e);if(Object(s.env)().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){const n=this.decode(t),r=this.texData.get(n.dataId),s=this.gpgpu.downloadMatrixFromPackedTexture(r.texture,...f(e)).subarray(0,i);return this.disposeIntermediateTensorInfo(n),s}const a=Object(s.env)().getBool("WEBGL_PACK")&&!0===r,o=a?K(e):e,u=a?new Te(o):new ke(o),c=this.runWebGLProgram(u,[{shape:o,dtype:n,dataId:t}],"float32"),l=this.texData.get(c.dataId),h=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(l.texture,l.texShape[0],l.texShape[1]).subarray(0,i);return this.disposeIntermediateTensorInfo(c),h}async time(t){const e=this.activeTimers,n=[];let r=!1;null==this.programTimersStack?(this.programTimersStack=n,r=!0):this.activeTimers.push(n),this.activeTimers=n,t();const i=s.util.flatten(this.activeTimers.map(t=>t.query)).filter(t=>null!=t),a=s.util.flatten(this.activeTimers.map(t=>t.name)).filter(t=>null!=t);this.activeTimers=e,r&&(this.programTimersStack=null);const o={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};if(Object(s.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const t=await Promise.all(i);o.kernelMs=s.util.sum(t),o.getExtraProfileInfo=()=>t.map((t,e)=>({name:a[e],ms:t})).map(t=>`${t.name}: ${t.ms}`).join(", ")}else o.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,o}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return Object(s.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:s.util.now(),endMs:null}}endTimer(t){return Object(s.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),t):(t.endMs=s.util.now(),t)}async getQueryTime(t){if(Object(s.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(t);const e=t;return e.endMs-e.startMs}disposeData(t){if(this.pendingDisposal.has(t))return;if(this.pendingRead.has(t))return this.pendingDisposal.add(t),void this.pendingDeletes++;if(!this.texData.has(t))return;if(this.texData.get(t).complexParentRefCount>0)return void this.texData.get(t).refCount--;this.releaseGPUData(t);const{complexTensorInfos:e}=this.texData.get(t);null!=e&&(this.texData.get(e.real.dataId).complexParentRefCount--,this.disposeIntermediateTensorInfo(e.real),this.texData.get(e.imag.dataId).complexParentRefCount--,this.disposeIntermediateTensorInfo(e.imag)),this.texData.delete(t)}releaseGPUData(t){const{texture:e,dtype:n,texShape:r,usage:i,isPacked:s,slice:a}=this.texData.get(t),o=a&&a.origDataId||t,u=this.dataRefCount.get(o);u>1?this.dataRefCount.set(o,u-1):(this.dataRefCount.delete(o),null!=e&&(this.numBytesInGPU-=this.computeBytes(r,n),this.textureManager.releaseTexture(e,r,i,s)));const c=this.texData.get(t);c.texture=null,c.texShape=null,c.isPacked=!1,c.slice=null}getTexture(t){return this.uploadToGPU(t),this.texData.get(t).texture}getDataInfo(t){return this.texData.get(t)}getCPUBackend(){return Object(s.env)().getBool("WEBGL_CPU_FORWARD")?(null==this.cpuBackend&&(this.cpuBackend=Object(s.engine)().findBackend("cpu")),this.cpuBackend):null}shouldExecuteOnCPU(t,e=128){const n=this.getCPUBackend();return this.warnedAboutCPUBackend||null!=n||(console.warn("Your application contains ops that are small enough to be executed on the CPU backend, however the CPU backend cannot be found. Consider importing the CPU backend (@tensorflow/tfjs-backend-cpu) for better performance."),this.warnedAboutCPUBackend=!0),null!=n&&t.every(t=>null==this.texData.get(t.dataId).texture&&s.util.sizeFromShape(t.shape)<e)}getGPGPUContext(){return this.gpgpu}slice(t,e,n){if(this.shouldExecuteOnCPU([t])){const r=St(this.texData.get(t.dataId).values,e,n,t.shape,t.dtype);return this.makeOutput(n,t.dtype,r)}if(0===s.util.sizeFromShape(n))return Object(s.tensor)([],n,t.dtype);const{isPacked:r}=this.texData.get(t.dataId),i=s.slice_util.isSliceContinous(t.shape,e,n);if(r||!i){const r=Object(s.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new En(n):new Nn(n),i=r.getCustomSetupFunc(e);return this.compileAndRun(r,[t],null,i)}return this.uploadToGPU(t.dataId),this.shallowSlice(t,e,n)}shallowSlice(t,e,n){const r=this.texData.get(t.dataId),i=this.makeOutput(n,t.dtype),a=this.texData.get(i.dataId);Object.assign(a,r),a.shape=n,a.dtype=t.dtype;let o=s.slice_util.computeFlatOffset(e,t.strides);r.slice&&(o+=r.slice.flatOffset),a.slice={flatOffset:o,origDataId:r.slice&&r.slice.origDataId||t.dataId};const u=this.dataRefCount.get(a.slice.origDataId)||1;return this.dataRefCount.set(a.slice.origDataId,u+1),i}stridedSlice(t,e,n,r){const i=this.tryRunOnCpuOrThrow([t],()=>this.cpuBackend.stridedSlice(t,e,n,r));if(i)return i;const a=s.slice_util.computeOutShape(e,n,r);if(a.some(t=>0===t))return Object(s.tensor)([],a);const o=new jn(e,r,a);return this.compileAndRun(o,[t])}reverse(t,e){const n=Object(s.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new kn(t.shape,e):new Sn(t.shape,e);return this.compileAndRun(n,[t])}neg(t){const e=this.tryRunOnCpuOrThrow([t],()=>this.cpuBackend.neg(t));if(e)return e;if(Object(s.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Un,t.dtype);const n=new zn(t.shape,Un);return this.compileAndRun(n,[t])}batchMatMul(t,e,n,r){const i=n?t.shape[2]:t.shape[1],a=r?e.shape[1]:e.shape[2],o=n?t.shape[1]:t.shape[2],u=Math.max(t.shape[0],e.shape[0]);if((1===i||1===a)&&o>1e3){n&&(t=Object(s.transpose)(t,[0,2,1])),r&&(e=Object(s.transpose)(e,[0,2,1]));const i=1===a?t:t.as3D(u,o,1),c=1===a?2:1,l=1===a?e.as3D(u,1,o):e;return s.mul(i,l).sum(c,!0)}const c=Object(s.upcastType)(t.dtype,e.dtype),l=new cn(t.shape,e.shape,[u,i,a],n,r);return this.compileAndRun(l,[t,e],c)}fusedBatchMatMul({a:t,b:e,transposeA:n,transposeB:r,bias:i,activation:a,preluActivationWeights:o}){const u=n?t.shape[2]:t.shape[1],c=r?e.shape[1]:e.shape[2],l=Math.max(t.shape[0],e.shape[0]),h=Object(s.upcastType)(t.dtype,e.dtype),d=null!=i,p=null!=o,f=a?ur(a,!0):null,m=new cn(t.shape,e.shape,[l,u,c],n,r,d,f,p),g=[t,e];return i&&g.push(i),o&&g.push(o),this.compileAndRun(m,g,h)}localResponseNormalization4D(t,e,n,r,i){const a=Object(s.env)().getBool("WEBGL_PACK_NORMALIZATION")?new an(t.shape,e,n,r,i):new rn(t.shape,e,n,r,i);return this.compileAndRun(a,[t])}LRNGrad(t,e,n,r,i,s,a){const o=new sn(e.shape,r,i,s,a);return this.compileAndRun(o,[e,n,t])}tile(t,e){if("string"===t.dtype){const n=this.readSync(t.dataId).map(t=>s.util.decodeString(t)),r=Object(s.buffer)(t.shape,t.dtype,n);return ir(r,e)}const n=new Fn(t.shape,e);return this.compileAndRun(n,[t])}pad(t,e,n){const r=Object(s.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new fn(t.shape,e,n):new pn(t.shape,e,n);return this.compileAndRun(r,[t])}gather(t,e,n){const r=this.tryRunOnCpuOrThrow([t,e],()=>this.cpuBackend.gather(t,e,n));if(r)return r;const i=new Ie(t.shape,e.size,n);return this.compileAndRun(i,[t,e])}batchToSpaceND(t,e,n){s.util.assert(t.rank<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");const r=e.reduce((t,e)=>t*e),i=s.backend_util.getReshaped(t.shape,e,r),a=s.backend_util.getPermuted(i.length,e.length),o=s.backend_util.getReshapedPermuted(t.shape,e,r),u=s.backend_util.getSliceBeginCoords(n,e.length),c=s.backend_util.getSliceSize(o,n,e.length);return Object(s.transpose)(t.reshape(i),a).reshape(o).slice(u,c)}spaceToBatchND(t,e,n){s.util.assert(t.rank<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");const r=e.reduce((t,e)=>t*e),i=[[0,0]];i.push(...n);for(let n=1+e.length;n<t.shape.length;++n)i.push([0,0]);const a=t.pad(i),o=s.backend_util.getReshaped(a.shape,e,r,!1),u=s.backend_util.getPermuted(o.length,e.length,!1),c=s.backend_util.getReshapedPermuted(a.shape,e,r,!1),l=Object(s.transpose)(a.reshape(o),u);return Object(s.reshape)(l,c)}reduce(t,e,n){const r=t.shape[0],i=t.shape[1],a=s.backend_util.computeOptimalWindowSize(i),o=Math.ceil(i/a),u=new bn({windowSize:a,inSize:i,batchSize:r,outSize:o},e),c=this.compileAndRun(u,[t],n);return 1===c.shape[1]?c:this.reduce(c,e,n)}argReduce(t,e,n=null){let r=t.shape[0],i=t.shape[1];null!=n&&(r=n.shape[0],i=n.shape[1]);const a=s.backend_util.computeOptimalWindowSize(i),o={windowSize:a,inSize:i,batchSize:r,outSize:Math.ceil(i/a)},u=new It(o,e,null==n),c=[t];null!=n&&c.push(n);const l=this.compileAndRun(u,c,"int32");return 1===l.shape[1]?l:this.argReduce(t,e,l)}argReducePacked(t,e,n=null){const r=null!=n?n.shape:t.shape,i=r[r.length-1],a=s.backend_util.computeOptimalWindowSize(i),o=new Yt(r,a,e,null==n),u=null==n?[t]:[t,n],c=this.compileAndRun(o,u,"int32");return c.rank===t.rank?this.argReducePacked(t,e,c):c}sum(t,e){s.backend_util.assertAxesAreInnerMostDims("sum",e,t.rank);const[n,r]=s.backend_util.computeOutAndReduceShapes(t.shape,e),i=s.util.sizeFromShape(r),a=t.as2D(-1,i),o=s.sumOutType(t.dtype);return this.reduce(a,"sum",o).reshape(n)}prod(t,e){const n=this.tryRunOnCpuOrThrow([t],()=>this.cpuBackend.prod(t,e));if(n)return n;const[r,i]=s.backend_util.computeOutAndReduceShapes(t.shape,e),a=s.util.sizeFromShape(i),o=t.as2D(-1,a),u=s.sumOutType(t.dtype);return this.reduce(o,"prod",u).reshape(r)}unsortedSegmentSum(t,e,n){let r=0;const i=s.backend_util.getAxesPermutation([r],t.rank);let a=t;null!=i&&(a=Object(s.transpose)(t,i),r=s.backend_util.getInnerMostAxes(1,t.rank)[0]);const o=nr.computeOutShape(a.shape,r,n),u=s.util.sizeFromShape([a.shape[r]]),c=a.as2D(-1,u),l=s.sumOutType(t.dtype);let h=this.segOpCompute(c,"unsortedSegmentSum",e,l,n).reshape(o);return null!=i&&(h=Object(s.transpose)(h,s.backend_util.getUndoAxesPermutation(i))),h}segOpCompute(t,e,n,r,i){const a=t.shape[0],o=t.shape[1],u=nr.segOpComputeOptimalWindowSize(o,i),c=new Cn({windowSize:u,inSize:o,batchSize:a,numSegments:i},e),l=this.compileAndRun(c,[t,n],r);return l.shape[1]===i?l:(n=Object(s.range)(0,i).tile([o/u]),this.segOpCompute(l,e,n,r,i))}argMinMaxReduce(t,e,n){const r=[e];if(s.backend_util.assertAxesAreInnerMostDims("arg"+n.charAt(0).toUpperCase()+n.slice(1),r,t.rank),!Object(s.env)().getBool("WEBGL_PACK_REDUCE")||t.rank<=2){const[e,i]=s.backend_util.computeOutAndReduceShapes(t.shape,r),a=s.util.sizeFromShape(i),o=t.as2D(-1,a);return this.argReduce(o,n).reshape(e)}return this.argReducePacked(t,n)}argMin(t,e){return this.argMinMaxReduce(t,e,"min")}argMax(t,e){return this.argMinMaxReduce(t,e,"max")}cumsum(t,e,n,r){if(e!==t.rank-1)throw new Error(`WebGL cumsum shader expects an inner-most axis=${t.rank-1} but got axis=`+e);const i=t.shape[e];let s=t;for(let e=0;e<=Math.ceil(Math.log2(i))-1;e++){const n=new ye(t.shape,!1,r),i=n.getCustomSetupFunc(e),a=s;s=this.compileAndRun(n,[s],s.dtype,i),a.dispose()}if(n){const e=new ye(t.shape,n,r),i=s;s=this.compileAndRun(e,[s]),i.dispose()}return s}equal(t,e){if(Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(equal(a, b));\n","bool");const n=new ee("return float(a == b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")}less(t,e){const n=this.tryRunOnCpuOrThrow([t,e],()=>this.cpuBackend.less(t,e));if(n)return n;if(Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(lessThan(a, b));\n","bool");const r=new ee("return float(a < b);",t.shape,e.shape);return this.compileAndRun(r,[t,e],"bool")}lessEqual(t,e){if(Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(lessThanEqual(a, b));\n","bool");const n=new ee("return float(a <= b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")}greater(t,e){const n=this.tryRunOnCpuOrThrow([t,e],()=>this.cpuBackend.greater(t,e));if(n)return n;if(Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(greaterThan(a, b));\n","bool");const r=new ee("return float(a > b);",t.shape,e.shape);return this.compileAndRun(r,[t,e],"bool")}greaterEqual(t,e){if(Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(greaterThanEqual(a, b));\n","bool");const n=new ee("return float(a >= b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")}logicalNot(t){const e=new zn(t.shape,"return float(!(x >= 1.0));");return this.compileAndRun(e,[t])}logicalAnd(t,e){if(Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(\n    vec4(greaterThanEqual(a, vec4(1.0))) *\n    vec4(greaterThanEqual(b, vec4(1.0))));\n","bool");const n=new ee("return float(a >= 1.0 && b >= 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")}logicalOr(t,e){if(Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return min(\n    vec4(greaterThanEqual(a, vec4(1.0))) +\n    vec4(greaterThanEqual(b, vec4(1.0))),\n    vec4(1.0));\n","bool");const n=new ee("return float(a >= 1.0 || b >= 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")}select(t,e,n){const r=new An(t.rank,e.shape,e.rank);return this.compileAndRun(r,[t,e,n],Object(s.upcastType)(e.dtype,n.dtype))}where(t){s.backend_util.warn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");const e=t.dataSync();return ar(t.shape,e)}topk(t,e,n){const r=t.dataSync();return sr(r,t.shape,t.dtype,e,n)}min(t,e){s.backend_util.assertAxesAreInnerMostDims("min",e,t.rank);const[n,r]=s.backend_util.computeOutAndReduceShapes(t.shape,e),i=s.util.sizeFromShape(r),a=t.as2D(-1,i);return this.reduce(a,"min",a.dtype).reshape(n)}minimum(t,e){const n=this.tryRunOnCpuOrThrow([t,e],()=>this.cpuBackend.minimum(t,e));if(n)return n;const r=Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new re("\n  vec4 result = vec4(min(a, b));\n  vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n",t.shape,e.shape):new ee("\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return min(a, b);\n",t.shape,e.shape);return this.compileAndRun(r,[t,e])}mod(t,e){const n=Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new re("\n  vec4 result = mod(a, b);\n  vec4 isNaN = vec4(equal(b, vec4(0.0)));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n",t.shape,e.shape):new ee("if (b == 0.0) return NAN;\n  return mod(a, b);",t.shape,e.shape);return this.compileAndRun(n,[t,e])}maximum(t,e){const n=this.tryRunOnCpuOrThrow([t,e],()=>this.cpuBackend.maximum(t,e));if(n)return n;const r=Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new re("\n  vec4 result = vec4(max(a, b));\n  vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n",t.shape,e.shape):new ee("\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return max(a, b);\n",t.shape,e.shape);return this.compileAndRun(r,[t,e])}all(t,e){s.backend_util.assertAxesAreInnerMostDims("all",e,t.rank);const[n,r]=s.backend_util.computeOutAndReduceShapes(t.shape,e),i=s.util.sizeFromShape(r),a=t.as2D(-1,i);return this.reduce(a,"all",a.dtype).reshape(n)}any(t,e){s.backend_util.assertAxesAreInnerMostDims("any",e,t.rank);const[n,r]=s.backend_util.computeOutAndReduceShapes(t.shape,e),i=s.util.sizeFromShape(r),a=t.as2D(-1,i);return this.reduce(a,"any",a.dtype).reshape(n)}floorDiv(t,e){if(Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  ivec4 ia = round(a);\n  ivec4 ib = round(b);\n  bvec4 cond = notEqual(ib, ivec4(0));\n  ivec4 result = ivec4(0);\n  vec4 s = sign(a) * sign(b);\n\n  // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n  if (cond[0]) {\n    result[0] = idiv(ia[0], ib[0], s[0]);\n  }\n  if (cond[1]) {\n    result[1] = idiv(ia[1], ib[1], s[1]);\n  }\n  if (cond[2]) {\n    result[2] = idiv(ia[2], ib[2], s[2]);\n  }\n  if (cond[3]) {\n    result[3] = idiv(ia[3], ib[3], s[3]);\n  }\n  return vec4(result);\n","int32");const n=new ee("\n  float s = sign(a) * sign(b);\n  int ia = round(a);\n  int ib = round(b);\n  if (ib != 0) {\n    // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n    return float(idiv(ia, ib, s));\n  } else {\n    return NAN;\n  }\n",t.shape,e.shape);return this.compileAndRun(n,[t,e],"int32")}packedUnaryOp(t,e,n){const r=new tr(t.shape,e);return this.compileAndRun(r,[t],n)}packedBinaryOp(t,e,n,r,i=!1){const s=new re(n,t.shape,e.shape,i);return this.compileAndRun(s,[t,e],r)}makeComplexComponentTensorInfo(t,e){return{dataId:e.dataId,dtype:e.dtype,shape:t.shape}}addN(t){if(1===t.length)return t[0];if(t.length>Object(s.env)().get("WEBGL_MAX_TEXTURES_IN_SHADER")){const e=Math.floor(t.length/2),n=this.addN(t.slice(0,e)),r=this.addN(t.slice(e));return this.addN([n,r])}const e=t.map(t=>t.dtype).reduce((t,e)=>Object(s.upcastType)(t,e)),n=t.map(t=>t.shape),r=Object(s.env)().getBool("WEBGL_PACK")?new Nt(t[0].shape,n):new At(t[0].shape,n);return this.compileAndRun(r,t,e)}pow(t,e){const n=Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new re("\n  // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.\n  vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));\n  vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n  vec4 result = multiplier * pow(abs(a), b);\n\n  // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n  bvec4 isExpZero = equal(b, vec4(0.0));\n  result.r = isExpZero.r ? 1.0 : result.r;\n  result.g = isExpZero.g ? 1.0 : result.g;\n  result.b = isExpZero.b ? 1.0 : result.b;\n  result.a = isExpZero.a ? 1.0 : result.a;\n\n  vec4 isNaN = vec4(lessThan(a, vec4(0.0))) * vec4(lessThan(floor(b), b));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n",t.shape,e.shape):new ee("\nif(a < 0.0 && floor(b) < b){\n  return NAN;\n}\nif (b == 0.0) {\n  return 1.0;\n}\nreturn (round(mod(b, 2.0)) != 1) ?\n    pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",t.shape,e.shape),r=Object(s.upcastType)(t.dtype,e.dtype);return this.compileAndRun(n,[t,e],r)}ceil(t){if(this.shouldExecuteOnCPU([t])){const e=gt(this.texData.get(t.dataId).values,t.dtype);return this.makeOutput(t.shape,t.dtype,e)}if(Object(s.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Wn,t.dtype);const e=new zn(t.shape,Wn);return this.compileAndRun(e,[t])}floor(t){if(this.shouldExecuteOnCPU([t])){const e=vt(this.texData.get(t.dataId).values,t.dtype);return this.makeOutput(t.shape,t.dtype,e)}if(Object(s.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Gn,t.dtype);const e=new zn(t.shape,Gn);return this.compileAndRun(e,[t])}sign(t){const e=new zn(t.shape,"\n  if (isnan(x)) { return 0.0; }\n  return sign(x);\n");return this.compileAndRun(e,[t])}isNaN(t){const e=new zn(t.shape,"return float(isnan(x));");return this.compileAndRun(e,[t],"bool")}isInf(t){const e=new zn(t.shape,"return float(isinf(x));");return this.compileAndRun(e,[t],"bool")}isFinite(t){const e=new zn(t.shape,"return float(!isnan(x) && !isinf(x));");return this.compileAndRun(e,[t],"bool")}round(t){const e=new zn(t.shape,"\n  // OpenGL ES does not support round function.\n  // The algorithm is based on banker's rounding.\n  float base = floor(x);\n  if ((x - base) < 0.5) {\n    return floor(x);\n  } else if ((x - base) > 0.5) {\n    return ceil(x);\n  } else {\n    if (mod(base, 2.0) == 0.0) {\n      return base;\n    } else {\n      return base + 1.0;\n    }\n  }\n");return this.compileAndRun(e,[t])}exp(t){if(this.shouldExecuteOnCPU([t])){const e=bt(this.texData.get(t.dataId).values,t.dtype);return this.makeOutput(t.shape,t.dtype,e)}if(Object(s.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Hn,t.dtype);const e=new zn(t.shape,Hn);return this.compileAndRun(e,[t])}expm1(t){if(this.shouldExecuteOnCPU([t])){const e=yt(this.texData.get(t.dataId).values,t.dtype);return this.makeOutput(t.shape,t.dtype,e)}if(Object(s.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Kn,t.dtype);const e=new zn(t.shape,Kn);return this.compileAndRun(e,[t])}softmax(t,e){const n=s.util.parseAxisParam([e],t.shape),r=Object(s.max)(t,n),i=s.backend_util.expandShapeToKeepDim(r.shape,n),a=s.sub(t,r.reshape(i)),o=this.exp(a),u=this.sum(o,n).reshape(i);return Object(s.div)(o,u)}log(t){if(this.shouldExecuteOnCPU([t])){const e=wt(this.texData.get(t.dataId).values,t.dtype);return this.makeOutput(t.shape,t.dtype,e)}if(Object(s.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,"\n  vec4 result = log(x);\n  vec4 isNaN = vec4(lessThan(x, vec4(0.0)));\n  result.r = isNaN.r == 1.0 ? NAN : result.r;\n  result.g = isNaN.g == 1.0 ? NAN : result.g;\n  result.b = isNaN.b == 1.0 ? NAN : result.b;\n  result.a = isNaN.a == 1.0 ? NAN : result.a;\n\n  return result;\n",t.dtype);const e=new zn(t.shape,"if (x < 0.0) return NAN;\n  return log(x);");return this.compileAndRun(e,[t])}log1p(t){const e=new zn(t.shape,"return log(1.0 + x);");return this.compileAndRun(e,[t])}sqrt(t){const e=new zn(t.shape,"return sqrt(x);");return this.compileAndRun(e,[t])}rsqrt(t){if(this.shouldExecuteOnCPU([t])){const e=Ot(this.texData.get(t.dataId).values,t.dtype);return this.makeOutput(t.shape,t.dtype,e)}const e=new zn(t.shape,"return inversesqrt(x);");return this.compileAndRun(e,[t])}reciprocal(t){const e=new zn(t.shape,"return 1.0 / x;");return this.compileAndRun(e,[t])}relu(t){let e;return e=Object(s.env)().getBool("WEBGL_PACK")?new tr(t.shape,Yn):new zn(t.shape,$n),this.compileAndRun(e,[t])}relu6(t){let e;return e=Object(s.env)().getBool("WEBGL_PACK")?new tr(t.shape,Jn):new zn(t.shape,Bn),this.compileAndRun(e,[t])}prelu(t,e){const n=Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new re(ne,t.shape,e.shape):new ee(te,t.shape,e.shape);return this.compileAndRun(n,[t,e])}elu(t){if(Object(s.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Zn,t.dtype);const e=new zn(t.shape,qn);return this.compileAndRun(e,[t])}eluDer(t,e){const n=Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new re("\n  vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n  return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",t.shape,e.shape):new ee("return (b >= 1.0) ? a : a * (b + 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e])}selu(t){const e=new zn(t.shape,Vn);return this.compileAndRun(e,[t])}clip(t,e,n){let r;r=Object(s.env)().getBool("WEBGL_PACK_CLIP")?new se(t.shape):new ie(t.shape);const i=r.getCustomSetupFunc(e,n);return this.compileAndRun(r,[t],null,i)}abs(t){if(this.shouldExecuteOnCPU([t])&&"complex64"!==t.dtype){const e=ft(this.texData.get(t.dataId).values);return this.makeOutput(t.shape,t.dtype,e)}if(Object(s.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Ln,t.dtype);const e=new zn(t.shape,Ln);return this.compileAndRun(e,[t])}complexAbs(t){const e=this.texData.get(t.dataId),n=new ae(t.shape),r=[this.makeComplexComponentTensorInfo(t,e.complexTensorInfos.real),this.makeComplexComponentTensorInfo(t,e.complexTensorInfos.imag)];return this.compileAndRun(n,r)}sigmoid(t){const e=new zn(t.shape,"return 1.0 / (1.0 + exp(-1.0 * x));");return this.compileAndRun(e,[t])}softplus(t){const e=new zn(t.shape,"\n  float epsilon = 1.1920928955078125e-7;\n  float threshold = log(epsilon) + 2.0;\n\n  bool too_large = x > -threshold;\n  bool too_small = x < threshold;\n\n  float result;\n  float exp_x = exp(x);\n\n  if (too_large){\n    result = x;\n  }\n  else if (too_small){\n    result = exp_x;\n  }\n  else{\n    result = log(exp_x + 1.0);\n  }\n  return result;\n");return this.compileAndRun(e,[t])}asin(t){const e=new zn(t.shape,"if (isnan(x)) return x;\n  if (abs(x) > 1.) {\n    return NAN;\n  }\n  return asin(x);\n");return this.compileAndRun(e,[t])}acos(t){const e=new zn(t.shape,"if (isnan(x)) return x;\n  if (abs(x) > 1.) {\n    return NAN;\n  }\n  return acos(x);\n");return this.compileAndRun(e,[t])}atan(t){const e=new zn(t.shape,"if (isnan(x)) return x;\n  return atan(x);\n");return this.compileAndRun(e,[t])}sinh(t){const e=new zn(t.shape,"\n  float e2x = exp(x);\n  return (e2x - 1.0 / e2x) / 2.0;\n");return this.compileAndRun(e,[t])}cosh(t){const e=new zn(t.shape,"\n  float e2x = exp(-x);\n  return (e2x + 1.0 / e2x) / 2.0;\n");return this.compileAndRun(e,[t])}tanh(t){const e=new zn(t.shape,"\n  float e2x = exp(-2.0 * abs(x));\n  return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n");return this.compileAndRun(e,[t])}asinh(t){const e=new zn(t.shape,"if (isnan(x)) return x;return log(x + sqrt(x * x + 1.0));");return this.compileAndRun(e,[t])}acosh(t){const e=new zn(t.shape,"if (isnan(x)) return x;\n  if (x < 1.0) return NAN;\n  return log(x + sqrt(x * x - 1.0));");return this.compileAndRun(e,[t])}atanh(t){const e=new zn(t.shape,"if (isnan(x)) return x;\n  if ((x < -1.0) || (x > 1.0)) return NAN;\n  return (log(1.0 + x) - log(1.0 - x)) / 2.0;");return this.compileAndRun(e,[t])}erf(t){const e=new zn(t.shape,Qn);return this.compileAndRun(e,[t])}step(t,e){const n=new zn(t.shape,function(t=0){return`if (isnan(x)) return x;\n    return x > 0.0 ? 1.0 : float(${t});\n  `}(e));return this.compileAndRun(n,[t])}conv2dByMatMul(t,e,n,r,i,a){const o=t.shape,u=this.texData.get(t.dataId),c=n.inChannels,l=o[0]*o[1]*o[2],h=n.outChannels,d="channelsLast"===n.dataFormat,p=(1===l||1===h)&&c>1e3,f=o[2]%2!=0&&!!u.isPacked;if(p||!Object(s.env)().getBool("WEBGL_LAZILY_UNPACK")||!Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS")||!f){const u=d?o[0]*o[1]*o[2]:o[0]*o[2]*o[3],c=Object(s.reshape)(t,[1,u,n.inChannels]),l=Object(s.reshape)(e,[1,n.inChannels,n.outChannels]),h=this.fusedBatchMatMul({a:c,b:l,transposeA:!1,transposeB:!1,bias:r,activation:i,preluActivationWeights:a});return Object(s.reshape)(h,n.outShape)}const m=d?o[0]*o[1]*(o[2]+1):o[0]*o[2]*(o[3]+1),g={dataId:t.dataId,shape:[1,m,n.inChannels],dtype:t.dtype},b=u.shape;u.shape=u.shape.slice(),u.shape[u.shape.length-2]++,s.util.assert(Y(u.shape,g.shape),()=>`packed reshape ${u.shape} to ${g.shape} isn't free`);const y=Object(s.reshape)(e,[1,n.inChannels,n.outChannels]),v=this.fusedBatchMatMul({a:g,b:y,transposeA:!1,transposeB:!1,bias:r,activation:i,preluActivationWeights:a}),w=this.texData.get(v.dataId);return s.util.assert(w.isPacked,()=>"batchMatMul result is expected to be packed"),u.shape=b,w.shape=n.outShape,Object(s.engine)().makeTensorFromDataId(v.dataId,n.outShape,v.dtype)}conv2dWithIm2Row(t,e,n,r,i,s){const{filterWidth:a,filterHeight:o,inChannels:u,outWidth:c,outHeight:l,dataFormat:h}=n,d="channelsLast"===h,p=a*o*u,f=l*c,m=[p,f],g=t.squeeze([0]),b=e.reshape([1,p,-1]),y=new nn(m,g.shape,n),v=this.compileAndRun(y,[g]).reshape([1,m[0],m[1]]),w=null!=r,x=null!=s,_=i?ur(i,!0):null,O=new cn(v.shape,b.shape,[1,f,n.outChannels],!0,!1,w,_,x),S=[v,b];r&&S.push(r),x&&S.push(s);const k=this.compileAndRun(O,S);return d?k.reshape([1,l,c,n.outChannels]):k.reshape([1,n.outChannels,l,c])}fusedConv2d({input:t,filter:e,convInfo:n,bias:r,activation:i,preluActivationWeights:a}){if(1===n.filterHeight&&1===n.filterWidth&&1===n.dilationHeight&&1===n.dilationWidth&&1===n.strideHeight&&1===n.strideWidth&&("SAME"===n.padInfo.type||"VALID"===n.padInfo.type))return this.conv2dByMatMul(t,e,n,r,i,a);if(Object(s.env)().getBool("WEBGL_CONV_IM2COL")&&1===t.shape[0])return this.conv2dWithIm2Row(t,e,n,r,i,a);const o=null!=r,u=null!=a,c=i?ur(i,!1):null,l=new pe(n,o,c,u),h=[t,e];return r&&h.push(r),a&&h.push(a),this.compileAndRun(l,h)}conv2d(t,e,n){if(1===n.filterHeight&&1===n.filterWidth&&1===n.dilationHeight&&1===n.dilationWidth&&1===n.strideHeight&&1===n.strideWidth&&("SAME"===n.padInfo.type||"VALID"===n.padInfo.type))return this.conv2dByMatMul(t,e,n);if(Object(s.env)().getBool("WEBGL_CONV_IM2COL")&&1===t.shape[0])return this.conv2dWithIm2Row(t,e,n);const r=new pe(n);return this.compileAndRun(r,[t,e])}conv2dDerInput(t,e,n){const r=new ue(n);return this.compileAndRun(r,[t,e])}conv2dDerFilter(t,e,n){const r=new oe(n);return this.compileAndRun(r,[t,e])}fusedDepthwiseConv2D({input:t,filter:e,convInfo:n,bias:r,activation:i,preluActivationWeights:a}){const o=Object(s.env)().getBool("WEBGL_PACK_DEPTHWISECONV")&&n.strideWidth<=2&&n.outChannels/n.inChannels==1,u=i?ur(i,o):null,c=[t,e],l=null!=r,h=null!=a;let d;return l&&c.push(r),h&&c.push(a),o?(d=new ge(n,l,u,h),this.compileAndRun(d,c)):(d=new me(n,l,u,h),this.compileAndRun(d,c))}depthwiseConv2D(t,e,n){let r;return Object(s.env)().getBool("WEBGL_PACK_DEPTHWISECONV")&&n.strideWidth<=2&&n.outChannels/n.inChannels==1?(r=new ge(n),this.compileAndRun(r,[t,e])):(r=new me(n),this.compileAndRun(r,[t,e]))}depthwiseConv2DDerInput(t,e,n){const r=new de(n);return this.compileAndRun(r,[t,e])}depthwiseConv2DDerFilter(t,e,n){const r=new he(n);return this.compileAndRun(r,[t,e])}conv3d(t,e,n){const r=new fe(n);return this.compileAndRun(r,[t,e])}conv3dDerInput(t,e,n){const r=new le(n);return this.compileAndRun(r,[t,e])}conv3dDerFilter(t,e,n){const r=new ce(n);return this.compileAndRun(r,[t,e])}unstack(t,e){const n=t.shape[e],r=new Array(t.rank-1);let i=0;for(let n=0;n<t.rank;n++)n!==e&&(r[i++]=t.shape[n]);const s=new Array(t.rank).fill(0),a=t.shape.slice();a[e]=1;const o=new Array(n);for(let n=0;n<o.length;n++)s[e]=n,o[n]=this.slice(t,s,a).reshape(r);return o}avgPool3d(t,e){const n=new gn(e,"avg",!1);return this.compileAndRun(n,[t],"float32")}avgPool3dBackprop(t,e,n){const r=new Zt(n);return this.compileAndRun(r,[t],e.dtype)}maxPool3d(t,e){const n=new gn(e,"max",!1);return this.compileAndRun(n,[t],"float32")}maxPool3dBackprop(t,e,n,r){const i=new gn(r,"max",!0),s=this.compileAndRun(i,[e]),a=new un(r),o=this.compileAndRun(a,[t,s],e.dtype);return s.dispose(),o}resizeBilinear(t,e,n,r){const i=Object(s.env)().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new xn(t.shape,e,n,r):new wn(t.shape,e,n,r);return this.compileAndRun(i,[t],"float32")}resizeBilinearBackprop(t,e,n){const r=new vn(t,e,n);return this.compileAndRun(r,[t])}resizeNearestNeighbor(t,e,n,r){const i=new On(t.shape,e,n,r);return this.compileAndRun(i,[t])}resizeNearestNeighborBackprop(t,e,n){const r=new _n(t,e,n);return this.compileAndRun(r,[t])}multinomial(t,e,n,r){const i=e?t:Object(s.softmax)(t),a=i.shape[0],o=i.shape[1],u=new ln(a,o,n),c=u.getCustomSetupFunc(r);return this.compileAndRun(u,[i],"int32",c)}oneHot(t,e,n,r){const i=new hn(t.size,e,n,r);return this.compileAndRun(i,[t])}diag(t){const e=new Se(t.size);return this.compileAndRun(e,[t])}cropAndResize(t,e,n,r,i,s){const a=new be(t.shape,e.shape,r,i,s);return this.compileAndRun(a,[t,e,n],"float32")}depthToSpace(t,e,n){s.util.assert(e>1,()=>"blockSize should be > 1 for depthToSpace, but was: "+e);const r=t.shape[0],i="NHWC"===n?t.shape[1]:t.shape[2],a="NHWC"===n?t.shape[2]:t.shape[3],o="NHWC"===n?t.shape[3]:t.shape[1],u=i*e,c=a*e,l=o/(e*e),h=new Oe("NHWC"===n?[r,u,c,l]:[r,l,u,c],e,n);return this.compileAndRun(h,[t])}split(t,e,n){return rr(t,e,n)}scatterND(t,e,n){const{sliceRank:r,numUpdates:i,sliceSize:a,strides:o,outputSize:u}=s.backend_util.calculateShapes(e,t,n),c=[u/a,a],l=t.reshape([i,r]),h=e.reshape([i,a]);if(0===u)return s.backend_util.reshapeTensor(Object(s.tensor)([]),n);const d=Object(s.scalar)(0),p=new Tn(i,r,l.rank,h.rank,o,c);return this.compileAndRun(p,[h,l,d]).reshape(n)}sparseToDense(t,e,n,r){const{sliceRank:i,numUpdates:a,strides:o,outputSize:u}=s.backend_util.calculateShapes(e,t,n),c=new Tn(a,i,t.rank,e.rank,o,[u,1],!1);return this.compileAndRun(c,[e,t,r]).reshape(n)}gatherND(t,e){const n=e.shape,r=n[n.length-1],[i,a,o,u]=s.backend_util.prepareAndValidate(t,e),c=e.reshape([a,r]),l=t.reshape([t.size/o,o]),h=new Ee(r,u,[a,o]);return this.compileAndRun(h,[l,c]).reshape(i)}fill(t,e,n){if("string"===(n=n||s.util.inferDtype(e))){const r=s.util.getArrayFromDType(n,s.util.sizeFromShape(t));return r.fill(e),Object(s.engine)().makeTensor(r,t,n,this)}{const r=new Ne(t,e),i=r.getCustomSetupFunc(e);return this.compileAndRun(r,[],n,i)}}onesLike(t){if("string"===t.dtype)throw new Error("onesLike is not supported under string dtype");return this.fill(t.shape,1,t.dtype)}zerosLike(t){return this.fill(t.shape,"string"===t.dtype?"":0,t.dtype)}linspace(t,e,n){return s.backend_util.linspaceImpl(t,e,n)}makeTensorInfo(t,e,n){const r=this.write(n,t,e);return this.texData.get(r).usage=null,{dataId:r,shape:t,dtype:e}}makeOutput(t,e,n){const{dataId:r}=this.makeTensorInfo(t,e,n);return Object(s.engine)().makeTensorFromDataId(r,t,e,this)}unpackTensor(t){const e=new er(t.shape);return this.runWebGLProgram(e,[t],t.dtype)}packTensor(t){const e=new dn(t.shape);return this.runWebGLProgram(e,[t],t.dtype,null,!0)}packedReshape(t,e){const n=[G(t.shape),...H(t.shape)],r={dtype:t.dtype,shape:n,dataId:t.dataId},i=[G(e),...H(e)],s=new yn(i,n),a=this.runWebGLProgram(s,[r],t.dtype,null,!0);return{dataId:a.dataId,shape:e,dtype:a.dtype}}decode(t){const e=this.texData.get(t),{isPacked:n,shape:r,dtype:i}=e,s=K(r);let a;a=n?new _e(s):new xe(s);return{dtype:i,shape:r,dataId:this.runWebGLProgram(a,[{shape:s,dtype:i,dataId:t}],i,null,!0).dataId}}runWebGLProgram(t,e,n,r,i=!1){const a=this.makeTensorInfo(t.outputShape,n),o=this.texData.get(a.dataId);if(t.packedOutput&&(o.isPacked=!0),t.outPackingScheme===l.DENSE){const e=f(t.outputShape);o.texShape=e.map(t=>2*t)}if(null!=t.outTexUsage&&(o.usage=t.outTexUsage),0===s.util.sizeFromShape(a.shape))return o.values=s.util.getTypedArrayFromDType(a.dtype,0),a;const u=[],c=e.map(e=>{if("complex64"===e.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(e.dataId);if(null==n.texture){if(!t.packedInputs&&s.util.sizeFromShape(e.shape)<=Object(s.env)().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:e.shape,texData:null,isUniform:!0,uniformValues:n.values};t.packedInputs&&(n.isPacked=!0,n.shape=e.shape)}else if(!!n.isPacked!=!!t.packedInputs)e=n.isPacked?this.unpackTensor(e):this.packTensor(e),u.push(e),n=this.texData.get(e.dataId);else if(n.isPacked&&!Y(n.shape,e.shape)){const t=e,r=e.shape;e.shape=n.shape,e=this.packedReshape(e,r),u.push(e),n=this.texData.get(e.dataId),t.shape=r}return this.uploadToGPU(e.dataId),{shape:e.shape,texData:n,isUniform:!1}});this.uploadToGPU(a.dataId);const h={shape:a.shape,texData:o,isUniform:!1},d=function(t,e,n){let r="";e.concat(n).forEach(t=>{const e=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0,n=t.isUniform?"uniform":t.texData.texShape;r+=`${t.shape}_${n}_${e}`});const i=t.userCode;let s=t.constructor.name;return s+="_"+r+"_"+i,s}(t,c,h),p=this.getAndSaveBinary(d,()=>function(t,e,n,r){const i=e.userCode,a=n.map((t,n)=>{const r={logicalShape:t.shape,texShape:t.isUniform?null:t.texData.texShape,isUniform:t.isUniform,isPacked:!t.isUniform&&t.texData.isPacked,flatOffset:null};return null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0&&(r.flatOffset=t.texData.slice.flatOffset),{name:e.variableNames[n],shapeInfo:r}}),o=a.map(t=>t.shapeInfo),u={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},c=zt(a,u,i,e.packedInputs),l=t.createProgram(c);let h=null;const d=t.getUniformLocation(l,"NAN",!1);1===Object(s.env)().getNumber("WEBGL_VERSION")&&(h=t.getUniformLocation(l,"INFINITY",!1));const p={};for(let n=0;n<e.variableNames.length;n++){const r=e.variableNames[n],i=!1;p[r]=t.getUniformLocation(l,r,i),p["offset"+r]=t.getUniformLocation(l,"offset"+r,i)}return{program:e,source:c,webGLProgram:l,uniformLocations:p,inShapeInfos:o,outShapeInfo:u,infLoc:h,nanLoc:d}}(this.gpgpu,t,c,h)),m=null!=this.activeTimers;let g;if(m&&(g=this.startTimer()),function(t,e,n,r,i){en(e.inShapeInfos,n),en([e.outShapeInfo],[r]);const a=r.texData.texture,o=r.texData.texShape;r.texData.isPacked?t.setOutputPackedMatrixTexture(a,o[0],o[1]):t.setOutputMatrixTexture(a,o[0],o[1]),t.setProgram(e.webGLProgram),1===Object(s.env)().getNumber("WEBGL_VERSION")&&null!==e.infLoc&&t.gl.uniform1f(e.infLoc,1/0),null!==e.nanLoc&&t.gl.uniform1f(e.nanLoc,NaN),n.forEach((n,r)=>{const i=e.program.variableNames[r],a=e.uniformLocations[i],o=e.uniformLocations["offset"+i];if(null!=a)if(n.isUniform)if(s.util.sizeFromShape(n.shape)<2)t.gl.uniform1f(a,n.uniformValues[0]);else{let e=n.uniformValues;e instanceof Float32Array||(e=new Float32Array(e)),t.gl.uniform1fv(a,e)}else null!=n.texData.slice&&null!=o&&t.gl.uniform1i(o,n.texData.slice.flatOffset),t.setInputMatrixTexture(n.texData.texture,a,r)}),null!=i&&i(t,e.webGLProgram),t.executeProgram()}(this.gpgpu,p,c,h,r),u.forEach(t=>this.disposeIntermediateTensorInfo(t)),m&&(g=this.endTimer(g),this.activeTimers.push({name:t.constructor.name,query:this.getQueryTime(g)})),!Object(s.env)().getBool("WEBGL_LAZILY_UNPACK")&&o.isPacked&&!1===i){const t=this.unpackTensor(a);return this.disposeIntermediateTensorInfo(a),t}return a}compileAndRun(t,e,n,r,i=!1){n=n||e[0].dtype;const a=this.runWebGLProgram(t,e,n,r,i);return Object(s.engine)().makeTensorFromDataId(a.dataId,a.shape,a.dtype)}getAndSaveBinary(t,e){return t in this.binaryCache||(this.binaryCache[t]=e()),this.binaryCache[t]}getTextureManager(){return this.textureManager}dispose(){if(!this.disposed){if(!Object(s.env)().getBool("IS_TEST")){Object.keys(this.binaryCache).forEach(t=>{this.gpgpu.deleteProgram(this.binaryCache[t].webGLProgram),delete this.binaryCache[t]})}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=Object(s.tidy)(()=>{if(!Object(s.env)().get("WEBGL_RENDER_FLOAT32_ENABLED")){const t=Object(s.env)().getBool("DEBUG");Object(s.env)().set("DEBUG",!1);const e=this.abs(Object(s.scalar)(1e-8)).dataSync()[0];if(Object(s.env)().set("DEBUG",t),e>0)return 32}return 16})),this.floatPrecisionValue}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}uploadToGPU(t){const e=this.texData.get(t),{shape:n,dtype:r,values:i,texture:a,usage:o,isPacked:u}=e;if(null!=a)return;const c=null!=this.activeTimers;let l;c&&(l=s.util.now());let d=e.texShape;if(null==d&&(d=Q(n,u),e.texShape=d),null!=i){const t=K(n);let a,o=d[1],p=d[0];const f=i instanceof Uint8Array;u?([o,p]=m(d[0],d[1]),a=new Ae(t,[p,o],f)):a=new Ce(t,[p,o],f);const g=this.makeTensorInfo([p,o],r);this.texData.get(g.dataId).usage=f?h.PIXELS:h.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(g.dataId),o,p,i);const b=!0,y=this.runWebGLProgram(a,[g],r,null,b),v=this.texData.get(y.dataId);e.texture=v.texture,e.texShape=v.texShape,e.isPacked=v.isPacked,e.usage=v.usage,this.disposeIntermediateTensorInfo(g),this.texData.delete(y.dataId),e.values=null,c&&(this.uploadWaitMs+=s.util.now()-l)}else{const t=this.acquireTexture(d,o,r,u);e.texture=t}}convertAndCacheOnCPU(t,e){const n=this.texData.get(t),{dtype:r}=n;return this.releaseGPUData(t),null!=e&&(n.values=function(t,e){if("float32"===e||"complex64"===e)return t;if("int32"===e||"bool"===e){const n="int32"===e?new Int32Array(t.length):new Uint8Array(t.length);for(let e=0;e<n.length;++e)n[e]=Math.round(t[e]);return n}throw new Error("Unknown dtype "+e)}
/** @license See the LICENSE file. */(e,r)),n.values}acquireTexture(t,e,n,r){if(this.numBytesInGPU+=this.computeBytes(t,n),!this.warnedAboutMemory&&this.numBytesInGPU>1024*this.numMBBeforeWarning*1024){const t=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${t} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(t,e,r)}computeBytes(t,e){return t[0]*t[1]*s.util.bytesPerElement(e)}tryRunOnCpuOrThrow(t,e){if(this.shouldExecuteOnCPU(t))try{return e()}catch(t){if(Object(s.env)().getBool("IS_TEST"))throw new Error("CPU forwarding failed")}return null}}const lr="2.7.0";
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function hr(){Object(s.env)().set("WEBGL_FORCE_F16_TEXTURES",!0)}
/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */s.device_util.isBrowser()&&Object(s.registerBackend)("webgl",()=>new cr,2);const dr={forceHalfFloat:hr};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function pr(t){const{inputs:e,backend:n}=t,{x:r}=e;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const fr={kernelName:s.Identity,backendName:"webgl",kernelFunc:pr};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function mr(t){const{inputs:e,backend:n}=t,{real:r,imag:i}=e,s=n.makeTensorInfo(r.shape,"complex64"),a=n.texData.get(s.dataId),o=pr({inputs:{x:r},backend:n});n.texData.get(o.dataId).complexParentRefCount++;const u=pr({inputs:{x:i},backend:n});return n.texData.get(u.dataId).complexParentRefCount++,a.complexTensorInfos={real:o,imag:u},s}const gr={kernelName:s.Complex,backendName:"webgl",kernelFunc:mr};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function br(t){return({inputs:e,backend:n})=>{const{x:r}=e,i=n,s=new zn(r.shape,t);return i.runWebGLProgram(s,[r],r.dtype)}}function yr({opSnippet:t,packedOpSnippet:e,checkOutOfBounds:n=!1,supportsComplex:r=!1,cpuKernelImpl:i,dtype:a}){return({inputs:o,backend:u})=>{const{a:c,b:l}=o,h=u;if(r&&"complex64"===c.dtype){const e=h.texData.get(c.dataId),n=h.texData.get(l.dataId),[r,i]=[[e.complexTensorInfos.real,n.complexTensorInfos.real],[e.complexTensorInfos.imag,n.complexTensorInfos.imag]].map(e=>{const[n,r]=e,i={dataId:n.dataId,dtype:n.dtype,shape:c.shape},a={dataId:r.dataId,dtype:r.dtype,shape:l.shape},o=new ee(t,c.shape,l.shape);return h.runWebGLProgram(o,[i,a],Object(s.upcastType)(n.dtype,r.dtype))}),a=mr({inputs:{real:r,imag:i},backend:h});return h.disposeIntermediateTensorInfo(r),h.disposeIntermediateTensorInfo(i),a}const d=a||Object(s.upcastType)(c.dtype,l.dtype);if(h.shouldExecuteOnCPU([c,l])&&null!=i){const t=h.texData.get(c.dataId),e=h.texData.get(l.dataId),[n,r]=i(c.shape,l.shape,t.values,e.values,d),s=h.makeTensorInfo(r,d);return h.texData.get(s.dataId).values=n,s}let p;return p=Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=e?new re(e,c.shape,l.shape,n):new ee(t,c.shape,l.shape),h.runWebGLProgram(p,[c,l],d)}}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const vr="return a + b;",wr=yr({opSnippet:vr,packedOpSnippet:vr,supportsComplex:!0,cpuKernelImpl:mt}),xr={kernelName:s.Add,backendName:"webgl",kernelFunc:wr},_r=yr({opSnippet:"\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return atan(a, b);\n",packedOpSnippet:"\n  vec4 result = atan(a, b);\n  vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n"}),Or={kernelName:s.Atan2,backendName:"webgl",kernelFunc:_r};const Sr={kernelName:s.AvgPool,backendName:"webgl",kernelFunc:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const{inputs:e,backend:n,attrs:r}=t,{x:i}=e;ht(i,"avgPool");const{filterSize:a,strides:o,pad:u,dimRoundingMode:c}=r;s.util.assert(s.backend_util.eitherStridesOrDilationsAreOne(o,1),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`);const l=s.backend_util.computePool2DInfo(i.shape,a,o,1,u,c);if(1===l.filterWidth&&1===l.filterHeight&&s.util.arraysEqual(l.inShape,l.outShape))return pr({inputs:{x:i},backend:n});const h=new mn(l,"avg",!1);return n.runWebGLProgram(h,[i],"float32")}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const kr={kernelName:s.AvgPoolBackprop,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{dy:i,input:a}=e,o=a;ht([i,a],"avgPoolBackprop");const{filterSize:u,strides:c,pad:l}=r,h=s.backend_util.computePool2DInfo(o.shape,u,c,1,l),d=new Jt(h);return n.runWebGLProgram(d,[i],o.dtype)}};
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Tr{constructor(t,e,n,r,i,a){this.outputShape=[],this.variableNames=["x","mean","variance"],s.backend_util.assertAndGetBroadcastShape(t,e),s.backend_util.assertAndGetBroadcastShape(t,n);let o="0.0";null!=r&&(s.backend_util.assertAndGetBroadcastShape(t,r),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");let u="1.0";null!=i&&(s.backend_util.assertAndGetBroadcastShape(t,i),this.variableNames.push("scale"),u="getScaleAtOutCoords()"),this.outputShape=t,this.userCode=`\n      void main() {\n        float x = getXAtOutCoords();\n        float mean = getMeanAtOutCoords();\n        float variance = getVarianceAtOutCoords();\n        float offset = ${o};\n        float scale = ${u};\n        float inv = scale * inversesqrt(variance + float(${a}));\n        setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n      }\n    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Cr{constructor(t,e,n,r,i,a){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],s.backend_util.assertAndGetBroadcastShape(t,e),s.backend_util.assertAndGetBroadcastShape(t,n);let o="vec4(0.0)";null!=r&&(s.backend_util.assertAndGetBroadcastShape(t,r),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");let u="vec4(1.0)";null!=i&&(s.backend_util.assertAndGetBroadcastShape(t,i),this.variableNames.push("scale"),u="getScaleAtOutCoords()"),this.outputShape=t,this.userCode=`\n      void main() {\n        vec4 offset = ${o};\n        vec4 scale = ${u};\n\n        vec4 x = getXAtOutCoords();\n        vec4 mean = getMeanAtOutCoords();\n        vec4 variance = getVarianceAtOutCoords();\n\n        vec4 inv = scale * inversesqrt(variance + vec4(${a}));\n\n        setOutput((x - mean) * inv + offset);\n      }\n    `}}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Ar={kernelName:s.FusedBatchNorm,backendName:"webgl",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:r,mean:i,variance:a,offset:o,scale:u}=t;s.util.assert(i.shape.length===a.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),s.util.assert(null==o||i.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),s.util.assert(null==u||i.shape.length===u.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:c}=n;null==c&&(c=.001);const l=[r,i,a];let h=null;null!=o&&(h=o.shape,l.push(o));let d=null;null!=u&&(d=u.shape,l.push(u));const p=Object(s.env)().getBool("WEBGL_PACK_NORMALIZATION")?new Cr(r.shape,i.shape,a.shape,h,d,c):new Tr(r.shape,i.shape,a.shape,h,d,c);return e.runWebGLProgram(p,l,l[0].dtype)}},Nr=yr({opSnippet:"return float(a != b);",dtype:"bool"}),Ir={kernelName:s.NotEqual,backendName:"webgl",kernelFunc:Nr};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function Er(t){const{inputs:e,backend:n}=t,{input:r}=e;return pr({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.real},backend:n})}const jr={kernelName:s.Real,backendName:"webgl",kernelFunc:Er};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Mr={kernelName:s.Cast,backendName:"webgl",kernelFunc:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function t(e){const{inputs:n,backend:r,attrs:i}=e,{x:a}=n,{dtype:o}=i;if("complex64"===o){if("complex64"===a.dtype)return pr({inputs:{x:a},backend:r});const e=s.zeros(a.shape),n=t({inputs:{x:a},backend:r,attrs:{dtype:"float32"}}),i=mr({inputs:{real:n,imag:e},backend:r});return e.dispose(),r.disposeIntermediateTensorInfo(n),i}if("complex64"===a.dtype){const e=Er({inputs:{input:a},backend:r}),n=t({inputs:{x:e},backend:r,attrs:{dtype:o}});return r.disposeIntermediateTensorInfo(e),n}if(!s.util.hasEncodingLoss(a.dtype,o)){const t=pr({inputs:{x:a},backend:r});return{dataId:t.dataId,shape:t.shape,dtype:o}}if("int32"===o)return function(t,e){const n=new zn(t.shape,"return float(int(x));"),r=e.runWebGLProgram(n,[t],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}(a,r);if("bool"===o){const t=r.makeTensorInfo([],"bool",s.util.getTypedArrayFromDType("bool",1)),e=Nr({inputs:{a:a,b:t},backend:r});return r.disposeIntermediateTensorInfo(t),e}throw new Error(`Error in Cast: failed to cast ${a.dtype} to ${o}`)}};
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Dr{constructor(t){this.outputShape=[],this.outputShape=s.backend_util.computeOutShape(t,1),this.variableNames=t.map((t,e)=>"T"+e);const e=new Array(t.length-1);e[0]=t[0][1];for(let n=1;n<e.length;n++)e[n]=e[n-1]+t[n][1];const n=[`if (yC < ${e[0]}) setOutput(getT0(yR, yC));`];for(let t=1;t<e.length;t++){const r=e[t-1];n.push(`else if (yC < ${e[t]}) setOutput(getT${t}(yR, yC-${r}));`)}const r=e.length,i=e[e.length-1];n.push(`else setOutput(getT${r}(yR, yC-${i}));`),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    `}}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Rr{constructor(t,e){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=s.backend_util.computeOutShape(t,e);const n=this.outputShape,r=n.length,i=Kt(r),a=jt("coords",r),o=["x","y","z","w","u","v"].slice(0,r);this.variableNames=t.map((t,e)=>"T"+e);const u=new Array(t.length-1);u[0]=t[0][e];for(let n=1;n<u.length;n++)u[n]=u[n-1]+t[n][e];const c=o[e],l=o.slice(-2),h=o.join();let d=`if (${c} < ${u[0]}) {\n        return getChannel(\n            getT0(${h}), vec2(${l.join()}));\n        }`;for(let t=1;t<u.length;t++){const e=u[t-1];d+=`\n        if (${c} < ${u[t]}  && ${c} >= ${u[t-1]}) {\n          return getChannel(\n            getT${t}(${Pr(o,c,e)}),\n            vec2(${Pr(l,c,e)}));\n        }`}const p=u.length,f=u[u.length-1];d+=`\n        return getChannel(\n          getT${p}(${Pr(o,c,f)}),\n          vec2(${Pr(l,c,f)}));`,this.userCode=`\n      float getValue(${o.map(t=>"int "+t)}) {\n        ${d}\n      }\n\n      void main() {\n        ${i} coords = getOutputCoords();\n        vec4 result = vec4(getValue(${a}), 0., 0., 0.);\n\n        ${a[r-1]} = ${a[r-1]} + 1;\n        if (${a[r-1]} < ${n[r-1]}) {\n          result.g = getValue(${a});\n        }\n\n        ${a[r-2]} = ${a[r-2]} + 1;\n        if (${a[r-2]} < ${n[r-2]}) {\n          result.a = getValue(${a});\n        }\n\n        ${a[r-1]} = ${a[r-1]} - 1;\n        if (${a[r-2]} < ${n[r-2]} &&\n            ${a[r-1]} < ${n[r-1]}) {\n          result.b = getValue(${a});\n        }\n        setOutput(result);\n      }\n    `}}function Pr(t,e,n){const r=t.indexOf(e);return t.map((t,e)=>e===r?`${t} - ${n}`:t).join()}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function Fr(t){const{inputs:e,backend:n}=t,{input:r}=e;return pr({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.imag},backend:n})}const zr={kernelName:s.Imag,backendName:"webgl",kernelFunc:Fr};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function Lr(t){const{inputs:e,backend:n,attrs:r}=t,{x:i}=e,{shape:a}=r,o=n,u=s.util.sizeFromShape(i.shape),c=s.util.inferFromImplicitShape(a,u),l=s.util.sizeFromShape(c);s.util.assert(u===l,()=>`The new shape (${c}) has ${l} elements and the old shape (${i.shape}) has ${u} elements. The new shape and old shape must have the same number of elements.`);const h=o.texData.get(i.dataId);return!h.isPacked||Y(i.shape,c)||null!==h.texture&&Y(h.shape,c)?(o.incRef(i.dataId),{dataId:i.dataId,shape:c,dtype:i.dtype}):function(t,e,n){const r=[G(t.shape),...H(t.shape)],i={dtype:t.dtype,shape:r,dataId:t.dataId},s=[G(e),...H(e)],a=new yn(s,r),o=n.runWebGLProgram(a,[i],t.dtype,null,!0);return{dataId:o.dataId,shape:e,dtype:o.dtype}}(i,c,o)}const $r={kernelName:s.Reshape,backendName:"webgl",kernelFunc:Lr};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Br={kernelName:s.Concat,backendName:"webgl",kernelFunc:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const{inputs:e,backend:n,attrs:r}=t,{axis:i}=r,a=s.util.parseAxisParam(i,e[0].shape)[0],o=s.backend_util.computeOutShape(e.map(t=>t.shape),a);if(0===s.util.sizeFromShape(o))return n.makeTensorInfo(o,e[0].dtype,[]);const u=e.filter(t=>s.util.sizeFromShape(t.shape)>0);if(1===u.length)return u[0];const c=u.map(t=>t.shape);return s.backend_util.assertParamsConsistent(c,a),function t(e,n,r){const i=e[0].dtype;if("complex64"===i){const i=e.map(t=>Er({inputs:{input:t},backend:r})),s=e.map(t=>Fr({inputs:{input:t},backend:r})),a=t(i,n,r),o=t(s,n,r),u=mr({inputs:{real:a,imag:o},backend:r});return i.forEach(t=>r.disposeIntermediateTensorInfo(t)),s.forEach(t=>r.disposeIntermediateTensorInfo(t)),r.disposeIntermediateTensorInfo(a),r.disposeIntermediateTensorInfo(o),u}if(e.length>Object(s.env)().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){const i=Math.floor(e.length/2),s=t(e.slice(0,i),n,r),a=t(e.slice(i),n,r),o=t([s,a],n,r);return r.disposeIntermediateTensorInfo(s),r.disposeIntermediateTensorInfo(a),o}if(Object(s.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&e[0].shape.length>1){const t=new Rr(e.map(t=>t.shape),n);return r.runWebGLProgram(t,e,i)}const a=s.backend_util.computeOutShape(e.map(t=>t.shape),n),o=e.map(t=>Lr({inputs:{x:t},attrs:{shape:[-1,s.util.sizeFromShape(t.shape.slice(n))]},backend:r})),u=new Dr(o.map(t=>t.shape)),c=r.runWebGLProgram(u,o,i);o.forEach(t=>r.disposeIntermediateTensorInfo(t));const l=Lr({inputs:{x:c},attrs:{shape:a},backend:r});return r.disposeIntermediateTensorInfo(c),l}(u,a,n)}},qr=br("if (isnan(x)) return x;\n  return cos(x);\n"),Vr={kernelName:s.Cos,backendName:"webgl",kernelFunc:qr},Ur=yr({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}),Wr={kernelName:s.Div,backendName:"webgl",kernelFunc:Ur};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class Gr{constructor(t,e,n){this.variableNames=["real","imag"];const r=e[1];this.outputShape=e;const i=n?"2.0 * "+Math.PI:"-2.0 * "+Math.PI,s=n?r+".0":"1.0";let a;if("real"===t)a="return real * expR - imag * expI;";else{if("imag"!==t)throw new Error(`FFT component must be either "real" or "imag", got ${t}.`);a="return real * expI + imag * expR;"}this.userCode=`\n      const float exponentMultiplier = ${i};\n\n      float unaryOpComplex(float real, float expR, float imag, float expI) {\n        ${a}\n      }\n\n      float mulMatDFT(int batch, int index) {\n        float indexRatio = float(index) / float(${r});\n        float exponentMultiplierTimesIndexRatio =\n            exponentMultiplier * indexRatio;\n\n        float result = 0.0;\n\n        for (int i = 0; i < ${r}; i++) {\n          // x = (-2|2 * PI / N) * index * i;\n          float x = exponentMultiplierTimesIndexRatio * float(i);\n          float expR = cos(x);\n          float expI = sin(x);\n          float real = getReal(batch, i);\n          float imag = getImag(batch, i);\n\n          result +=\n              unaryOpComplex(real, expR, imag, expI) / ${s};\n        }\n\n        return result;\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        setOutput(mulMatDFT(coords[0], coords[1]));\n      }\n    `}}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function Hr(t,e,n){const r=n.texData.get(t.dataId),i=s.util.sizeFromShape(t.shape),a=t.shape[t.shape.length-1],o=Lr({inputs:{x:t},backend:n,attrs:{shape:[i/a,a]}}).shape,u=new Gr("real",o,e),c=new Gr("imag",o,e),l=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:o},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:o}],h=n.runWebGLProgram(u,l,"float32"),d=n.runWebGLProgram(c,l,"float32"),p=mr({inputs:{real:h,imag:d},backend:n});n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d);const f=Lr({inputs:{x:p},backend:n,attrs:{shape:t.shape}});return n.disposeIntermediateTensorInfo(f),f}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Kr={kernelName:s.FFT,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n}=t,{input:r}=e;return Hr(r,!1,n)}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Qr{constructor(t){this.variableNames=["Image"],this.outputShape=[];const e=t[2];this.outputShape=t,this.userCode=`\n        void main() {\n          ivec4 coords = getOutputCoords();\n          int x = coords[2];\n\n          int coordX = ${e} - x;\n          float outputValue;\n          if(coordX >= 0 && coordX < ${e}) {\n            outputValue = getImage(coords[0], coords[1], coordX, coords[3]);\n          } else {\n            outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);\n          }\n          setOutput(outputValue);\n        }\n    `}}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Xr={kernelName:s.FlipLeftRight,backendName:"webgl",kernelFunc:({inputs:t,backend:e})=>{const{image:n}=t,r=e,i=new Qr(n.shape);return r.runWebGLProgram(i,[n],n.dtype)}};
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Yr{constructor(t){this.variableNames=["A"];const e=Mt(),[n,r]=t;this.outputShape=t,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 = ${e.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    `}}
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class Jr{constructor(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const e=Mt(),[n,r]=t;this.outputShape=t,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 = ${e.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        ${e.output} = result;\n      }\n    `}}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Zr={kernelName:s.FromPixels,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t;let{pixels:i}=e;const{numChannels:a}=r,o="undefined"!=typeof HTMLVideoElement&&i instanceof HTMLVideoElement,u="undefined"!=typeof HTMLImageElement&&i instanceof HTMLImageElement,[c,l]=o?[i.videoWidth,i.videoHeight]:[i.width,i.height],d=[l,c],p=[l,c,a];(u||o)&&(null==ti&&(ti=document.createElement("canvas").getContext("2d")),ti.canvas.width=c,ti.canvas.height=l,ti.drawImage(i,0,0,c,l),i=ti.canvas);const f=n.makeTensorInfo(d,"int32");n.texData.get(f.dataId).usage=h.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(f.dataId),i);const m=Object(s.env)().getBool("WEBGL_PACK")?new Jr(p):new Yr(p),g=n.runWebGLProgram(m,[f],"int32");return n.disposeData(f.dataId),g}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */};let ti;const ei={kernelName:s.IFFT,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n}=t,{input:r}=e;return Hr(r,!0,n)}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class ni{constructor(t,e){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:i,outSize:a}=t;this.outputShape=[r,a];const o=4*Math.floor(n/4),u=n%4;let c="sumValue += dot(values, ones);";if(null!=e){const t=1/e;c=`sumValue += dot(values * ${s.util.isInt(t)?t.toPrecision(2):t}, ones);`}let l="";i%n>0&&(l=`\n        if (inIdx < 0 || inIdx >= ${i}) {\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 < ${o}; 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          ${c}\n        }\n\n        int inIdx = inOffset + ${o};\n        if (${1===u}) {\n          vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n          ${c}\n        } else if (${2===u}) {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1), 0.0, 0.0);\n\n          ${c}\n        } else if (${3===u}) {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2), 0.0);\n\n          ${c}\n        }\n        setOutput(sumValue);\n      }\n    `}}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function ri(t,e,n,r){const i=function(t){const e=[];for(;0===e.length||1!==e[e.length-1].outSize;){const n=e.length?e[e.length-1].outSize:t[1],r=s.backend_util.computeOptimalWindowSize(n);e.push({inSize:n,windowSize:r,outSize:Math.ceil(n/r)})}return e}(t.shape);let a=t;for(let s=0;s<i.length;s++){const{inSize:o,windowSize:u,outSize:c}=i[s];let l,h;l="mean"===n?0===s?new ni({windowSize:u,inSize:o,batchSize:t.shape[0],outSize:c},o):new ni({windowSize:u,inSize:o,batchSize:t.shape[0],outSize:c}):new bn({windowSize:u,inSize:o,batchSize:t.shape[0],outSize:c},n),h=a,a=r.runWebGLProgram(l,[a],e),h.dataId!==t.dataId&&r.disposeIntermediateTensorInfo(h)}return a}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class ii{constructor(t,e){this.variableNames=["A"];const n=new Array(t.length);for(let r=0;r<n.length;r++)n[r]=t[e[r]];this.outputShape=n,this.rank=n.length;const r=Kt(this.rank),i=function(t){const e=t.length;if(e>6)throw Error(`Transpose for rank ${e} is not yet supported`);const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(e);for(let e=0;e<t.length;e++)r[t[e]]=n[e];return r.join()}
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */(e);this.userCode=`\n    void main() {\n      ${r} resRC = getOutputCoords();\n      setOutput(getA(${i}));\n    }\n    `}}class si{constructor(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;const n=new Array(t.length);for(let r=0;r<n.length;r++)n[r]=t[e[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=Kt(this.rank),i=Et("rc",this.rank),s=new Array(this.rank);for(let t=0;t<e.length;t++)s[e[t]]=i[t];const a=`vec2(${s.slice(-2).join()})`,o=`++${i[this.rank-1]} < ${n[this.rank-1]}`,u=`getChannel(getA(${s.join()}), ${a})`;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      --${i[this.rank-1]};\n      if(++${i[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    `}}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function ai(t,e,n){const r=Object(s.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new si(t.shape,e):new ii(t.shape,e);return n.runWebGLProgram(r,[t],t.dtype)}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const oi={kernelName:s.Max,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:r}=t,{reductionIndices:i,keepDims:a}=e,o=n,u=r.shape.length,c=s.util.parseAxisParam(i,r.shape);let l=c;const h=s.backend_util.getAxesPermutation(l,u),d=null!=h,p=o.shouldExecuteOnCPU([r]);let f=r;if(d){if(p){const t=o.texData.get(f.dataId).values,e=new Array(u);for(let t=0;t<e.length;t++)e[t]=r.shape[h[t]];const n=Tt(t,r.shape,r.dtype,h,e);f=o.makeTensorInfo(e,r.dtype);o.texData.get(f.dataId).values=n}else f=ai(r,h,o);l=s.backend_util.getInnerMostAxes(l.length,u)}s.backend_util.assertAxesAreInnerMostDims("max",l,u);const[m,g]=s.backend_util.computeOutAndReduceShapes(f.shape,l);let b,y=m;if(a&&(y=s.backend_util.expandShapeToKeepDim(m,c)),p){const t=o.texData.get(f.dataId).values,e=xt(t,s.util.sizeFromShape(g),y,r.dtype);b=o.makeTensorInfo(y,r.dtype);o.texData.get(b.dataId).values=e}else b=function(t,e,n,r){const i=s.util.sizeFromShape(e),a=Lr({inputs:{x:t},attrs:{shape:[s.util.sizeFromShape(t.shape)/i,i]},backend:r}),o=ri(a,t.dtype,"max",r),u=Lr({inputs:{x:o},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(a),r.disposeIntermediateTensorInfo(o),u}(f,g,y,o);return d&&o.disposeIntermediateTensorInfo(f),b}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const ui={kernelName:s.MaxPool,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{x:i}=e;ht(i,"maxPool");const{filterSize:a,strides:o,pad:u,dimRoundingMode:c}=r;s.util.assert(s.backend_util.eitherStridesOrDilationsAreOne(o,1),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`);const l=s.backend_util.computePool2DInfo(i.shape,a,o,1,u,c);if(1===l.filterWidth&&1===l.filterHeight&&s.util.arraysEqual(l.inShape,l.outShape))return pr({inputs:{x:i},backend:n});const h=new mn(l,"max",!1);return n.runWebGLProgram(h,[i],i.dtype)}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const ci={kernelName:s.MaxPoolBackprop,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n,attrs:r}=t,{dy:i,input:a,output:o}=e,u=a;ht([a,o],"maxPoolBackprop");const{filterSize:c,strides:l,pad:h,dimRoundingMode:d}=r,p=s.backend_util.computePool2DInfo(u.shape,c,l,1,h,d),f=new mn(p,"max",!0),m=n.runWebGLProgram(f,[u],u.dtype),g=new on(p),b=n.runWebGLProgram(g,[i,m],u.dtype);return n.disposeIntermediateTensorInfo(m),b}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const li={kernelName:s.MaxPoolWithArgmax,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:r}=t,{filterSize:i,strides:a,pad:o,includeBatchInIndex:u}=e,c=n;s.util.assert(4===r.shape.length,()=>`Error in maxPool: input must be rank 4 but got rank ${r.shape.length}.`);const l=[1,1];s.util.assert(s.backend_util.eitherStridesOrDilationsAreOne(a,l),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${l}'`);const h=s.backend_util.computePool2DInfo(r.shape,i,a,l,o),[d,p]=function(t,e,n,r){let i=new mn(n,"max",!1);const s=r.runWebGLProgram(i,[t],"float32");return i=new mn(n,"max",!0,!0,e),[s,r.runWebGLProgram(i,[t],"float32")]}(r,u,h,c);return[d,p]}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const hi={kernelName:s.Mean,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:r}=t,{keepDims:i,axis:a}=e,o=n,u=r.shape.length,c=s.util.parseAxisParam(a,r.shape);let l=c;const h=s.backend_util.getAxesPermutation(l,u),d=null!=h,p=o.shouldExecuteOnCPU([r]),f=[];let m=r;if(d){if(p){const t=o.texData.get(m.dataId).values,e=new Array(u);for(let t=0;t<e.length;t++)e[t]=r.shape[h[t]];const n=Tt(t,r.shape,r.dtype,h,e);m=o.makeTensorInfo(e,r.dtype);o.texData.get(m.dataId).values=n}else m=ai(r,h,o);f.push(m),l=s.backend_util.getInnerMostAxes(l.length,u)}s.backend_util.assertAxesAreInnerMostDims("sum",l,u);const[g,b]=s.backend_util.computeOutAndReduceShapes(m.shape,l);let y=g;i&&(y=s.backend_util.expandShapeToKeepDim(g,c));const v=function(t,e,n,r){const i=s.util.sizeFromShape(e),a=Lr({inputs:{x:t},attrs:{shape:[s.util.sizeFromShape(t.shape)/i,i]},backend:r}),o=ri(a,"float32","mean",r),u=Lr({inputs:{x:o},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(a),r.disposeIntermediateTensorInfo(o),u}(m,b,y,o);for(const t of f)o.disposeIntermediateTensorInfo(t);return v}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class di{constructor(t,e,n){this.variableNames=["x"],this.outputShape=e.map((e,n)=>e[0]+t[n]+e[1]);const r=t.length,i=Kt(r),s=e.map(t=>t[0]).join(","),a=e.map((e,n)=>e[0]+t[n]).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r),u="reflect"===n?0:1;this.userCode=1!==r?`\n      ${i} start = ${i}(${s});\n      ${i} end = ${i}(${a});\n\n      void main() {\n        ${i} outC = getOutputCoords();\n        for (int i = 0; i < ${r}; i++) {\n          if (outC[i] < start[i]) {\n            outC[i] = start[i] * 2 - outC[i] - ${u};\n          } else if(outC[i] >= end[i]) {\n            outC[i] = (end[i] - 1) * 2 - outC[i] + ${u};\n          }\n        }\n        ${i} coords = outC - start;\n        setOutput(getX(${o}));\n      }\n    `:`\n        int start = ${s};\n        int end = ${a};\n\n        void main() {\n          int outC = getOutputCoords();\n          if (outC < start) {\n            outC = start * 2 - outC - ${u};\n          } else if(outC >= end) {\n            outC = (end - 1) * 2 - outC + ${u};\n          }\n          setOutput(getX(outC - start));\n        }\n      `}}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */class pi{constructor(t,e,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.map((e,n)=>e[0]+t[n]+e[1]);const r=t.length,i=Kt(r),s=e.map(t=>t[0]).join(","),a=e.map((e,n)=>e[0]+t[n]).join(","),o=jt("rc",r),u=jt("source",r),c=`${o[r-1]} < ${this.outputShape[r-1]}`,l=1===r?"source":`vec2(${u.slice(-2).join()})`,h="reflect"===n?0:1;let d="";if(1===r){const t=`\n        ${i} source = rc;\n        if (source < start) {\n          source = start * 2 - source - ${h};\n        } else if (source >= end) {\n          source = (end - 1) * 2 - source + ${h};\n        }\n        source -= start;\n      `;d=`\n        ${i} rc = outputLoc;\n        ${t}\n        result[0] = getChannel(getX(${u.join()}), ${l});\n        ${o[r-1]} += 1;\n        if(${c}) {\n          ${t}\n          result[1] = getChannel(getX(${u.join()}), ${l});\n        }\n      `}else{const t=`\n        ${i} source = rc;\n        ${i} lt = ${i}(lessThan(source, start));\n        ${i} gte = ${i}(greaterThanEqual(source, end));\n        ${i} orig = 1 - (lt + gte);\n        source = orig * source +\n                lt * (start * 2 - source - ${h}) +\n                gte * ((end - 1) * 2 - source + ${h});\n        source -= start;\n      `;d=`\n        ${i} rc = outputLoc;\n        ${t}\n        result[0] = getChannel(getX(${u.join()}), ${l});\n        ${o[r-1]} += 1;\n        if(${c}) {\n          ${t}\n          result[1] = getChannel(getX(${u.join()}), ${l});\n        }\n        rc = outputLoc;\n        ${o[r-2]} += 1;\n        if(${o[r-2]} < ${this.outputShape[r-2]}) {\n          ${t}\n          result[2] = getChannel(getX(${u.join()}), ${l});\n          ${o[r-1]} += 1;\n          if(${c}) {\n            ${t}\n            result[3] = getChannel(getX(${u.join()}), ${l});\n          }\n        }\n      `}this.userCode=`\n      const ${i} start = ${i}(${s});\n      const ${i} end = ${i}(${a});\n\n      void main() {\n        ${i} outputLoc = getOutputCoords();\n        vec4 result = vec4(0.);\n        ${d}\n        setOutput(result);\n      }\n    `}}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const fi={kernelName:s.MirrorPad,backendName:"webgl",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:r}=t,{paddings:i,mode:a}=n,o=Object(s.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new pi(r.shape,i,a):new di(r.shape,i,a);return e.runWebGLProgram(o,[r],r.dtype)}},mi="return areal * breal - aimag * bimag;",gi="return areal * bimag + aimag * breal;";class bi{constructor(t,e,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=s.backend_util.assertAndGetBroadcastShape(e,n),this.userCode=`\n      float binaryOpComplex(\n          float areal, float aimag, float breal, float bimag) {\n        ${t}\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    `}}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const yi="return a * b;";const vi={kernelName:s.Multiply,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n}=t,{a:r,b:i}=e,a=s.backend_util.upcastType(r.dtype,i.dtype);if("complex64"===r.dtype){const t=n.texData.get(r.dataId),e=n.texData.get(i.dataId),s=new bi(mi,r.shape,i.shape),a=new bi(gi,r.shape,i.shape),o=[{dataId:t.complexTensorInfos.real.dataId,dtype:t.complexTensorInfos.real.dtype,shape:r.shape},{dataId:t.complexTensorInfos.imag.dataId,dtype:t.complexTensorInfos.imag.dtype,shape:r.shape},{dataId:e.complexTensorInfos.real.dataId,dtype:e.complexTensorInfos.real.dtype,shape:i.shape},{dataId:e.complexTensorInfos.imag.dataId,dtype:e.complexTensorInfos.imag.dtype,shape:i.shape}],u=n.runWebGLProgram(s,o,"float32"),c=n.runWebGLProgram(a,o,"float32"),l=mr({inputs:{real:u,imag:c},backend:n});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(c),l}if(n.shouldExecuteOnCPU([r,i])){const t=n.texData.get(r.dataId),e=n.texData.get(i.dataId),[s,o]=_t(r.shape,i.shape,t.values,e.values,a),u=n.makeTensorInfo(o,a);return n.texData.get(u.dataId).values=s,u}let o;return o=Object(s.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new re(yi,r.shape,i.shape):new ee(yi,r.shape,i.shape),n.runWebGLProgram(o,[r,i],a)}},wi={kernelName:s.NonMaxSuppressionV3,backendName:"webgl",kernelFunc:({inputs:t,backend:e,attrs:n})=>{s.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{boxes:r,scores:i}=t,{maxOutputSize:a,iouThreshold:o,scoreThreshold:u}=n,c=e,l=c.readSync(r.dataId),h=c.readSync(i.dataId),d=a,p=o,f=u;return s.kernel_impls.nonMaxSuppressionV3Impl(l,h,d,p,f)}},xi=s.kernel_impls.nonMaxSuppressionV4Impl,_i={kernelName:s.NonMaxSuppressionV4,backendName:"webgl",kernelFunc:({inputs:t,backend:e,attrs:n})=>{s.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{boxes:r,scores:i}=t,{maxOutputSize:a,iouThreshold:o,scoreThreshold:u,padToMaxOutputSize:c}=n,l=e,h=l.readSync(r.dataId),d=l.readSync(i.dataId),{selectedIndices:p,validOutputs:f}=xi(h,d,a,o,u,c);return[p,f]}},Oi=s.kernel_impls.nonMaxSuppressionV5Impl,Si={kernelName:s.NonMaxSuppressionV5,backendName:"webgl",kernelFunc:({inputs:t,backend:e,attrs:n})=>{s.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{boxes:r,scores:i}=t,{maxOutputSize:a,iouThreshold:o,scoreThreshold:u,softNmsSigma:c}=n,l=e,h=l.readSync(r.dataId),d=l.readSync(i.dataId),p=a,f=o,m=u,g=c,{selectedIndices:b,selectedScores:y}=Oi(h,d,p,f,m,g);return[b,y]}};
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
class ki{constructor(t,e,n,r){this.variableNames=["Image"],this.outputShape=[];const i=t[1],a=t[2],o=Math.sin(e).toFixed(3),u=Math.cos(e).toFixed(3);this.outputShape=t;const[c,l]=s.backend_util.getImageCenter(r,i,a),h=c.toFixed(3),d=l.toFixed(3);let p="";p="number"==typeof n?`float outputValue = ${n.toFixed(2)};`:`\n        vec3 fill = vec3(${n.join(",")});\n        float outputValue = fill[coords[3]];`,this.userCode=`\n        void main() {\n          ivec4 coords = getOutputCoords();\n          int x = coords[2];\n          int y = coords[1];\n          float coordXFloat = (float(x) - ${h}) * ${u} - (float(y) - ${d}) * ${o};\n          float coordYFloat = (float(x) - ${h}) * ${o} + (float(y) - ${d}) * ${u};\n          int coordX = int(round(coordXFloat + ${h}));\n          int coordY = int(round(coordYFloat + ${d}));\n          ${p}\n          if(coordX >= 0 && coordX < ${a} && coordY >= 0 && coordY < ${i}) {\n            outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n          }\n          setOutput(outputValue);\n        }\n    `}}
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Ti={kernelName:s.RotateWithOffset,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{image:r}=t,{radians:i,fillValue:s,center:a}=e,o=n,u=new ki(r.shape,i,s,a);return o.runWebGLProgram(u,[r],r.dtype)}},Ci=br("if (isnan(x)) return x;\n  return sin(x);\n"),Ai={kernelName:s.Sin,backendName:"webgl",kernelFunc:Ci},Ni=br("return x * x;"),Ii={kernelName:s.Square,backendName:"webgl",kernelFunc:Ni},Ei=yr({opSnippet:"return (a - b) * (a - b);",packedOpSnippet:"return (a - b) * (a - b);"}),ji={kernelName:s.SquaredDifference,backendName:"webgl",kernelFunc:Ei},Mi="return a - b;",Di=yr({opSnippet:Mi,packedOpSnippet:Mi,supportsComplex:!0,cpuKernelImpl:kt}),Ri={kernelName:s.Sub,backendName:"webgl",kernelFunc:Di},Pi=br("return tan(x);");
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const Fi=[xr,Or,Sr,kr,Ar,Mr,gr,Br,Vr,Wr,Kr,Xr,Zr,fr,ei,zr,oi,ui,ci,li,hi,fi,vi,wi,_i,Si,Ir,jr,$r,Ti,Ai,Ii,Ri,ji,{kernelName:s.Tan,backendName:"webgl",kernelFunc:Pi},{kernelName:s.Transpose,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:r}=t,{perm:i}=e,s=n,a=r.shape.length,o=new Array(a);for(let t=0;t<o.length;t++)o[t]=r.shape[i[t]];let u;if(s.shouldExecuteOnCPU([r])){const t=s.texData.get(r.dataId).values,e=Tt(t,r.shape,r.dtype,i,o);u=s.makeTensorInfo(o,r.dtype);s.texData.get(u.dataId).values=e}else u=ai(r,i,s);return u}},{kernelName:s.Unique,backendName:"webgl",kernelFunc:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const{inputs:e,attrs:n,backend:r}=t,{axis:i}=n,{x:s}=e;ht(s,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const a=r.readSync(s.dataId),{outputValues:o,outputShape:u,indices:c}=Ct(a,i,s.shape,s.dtype);return[r.makeTensorInfo(u,s.dtype,o),r.makeTensorInfo([c.length],"int32",c)]}}];
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */for(const t of Fi)Object(s.registerKernel)(t);
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(7),a=n(20),o=n(4),u=n(8);const c=Object(o.b)({conv3DBackpropInput_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,o,c){s.b(t.length===e.rank,()=>`Length of inShape (${t.length}) and rank of dy (${e.rank}) must match`);let l=t,h=e,d=!1;4===e.rank&&(d=!0,h=Object(u.a)(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]),l=[1,t[0],t[1],t[2],t[3]]);const p=l[4],f=h.shape[4];s.b(5===l.length,()=>"Error in conv3dDerInput: inShape must be length 5, but got length "+l.length+"."),s.b(5===h.rank,()=>"Error in conv3dDerInput: dy must be rank 5, but got rank "+h.rank),s.b(5===n.rank,()=>"Error in conv3dDerInput: filter must be rank 5, but got rank "+n.rank),s.b(p===n.shape[3],()=>`Error in conv3dDerInput: depth of input (${p}) must match input depth for filter ${n.shape[3]}.`),s.b(f===n.shape[4],()=>`Error in conv3dDerInput: depth of output (${f}) must match output depth for filter ${n.shape[4]}.`);const m={dy:h,filter:n},g={pad:c,strides:o,inputShape:l},b=r.a.runKernelFunc(t=>{const e=a.b(l,n.shape,o,1,c);return t.conv3dDerInput(h,n,e)},m,null,i.F,g);return d?Object(u.a)(b,[b.shape[1],b.shape[2],b.shape[3],b.shape[4]]):b}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4),u=n(8);const c=Object(o.b)({resizeNearestNeighbor_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n=!1){const o=Object(s.a)(t,"images","resizeNearestNeighbor");a.b(3===o.rank||4===o.rank,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${o.rank}.`),a.b(2===e.length,()=>"Error in resizeNearestNeighbor: new shape must 2D, but got shape "+e+"."),a.b("float32"===o.dtype||"int32"===o.dtype,()=>"`images` must have `int32` or `float32` as dtype");let c=o,l=!1;3===o.rank&&(l=!0,c=Object(u.a)(o,[1,o.shape[0],o.shape[1],o.shape[2]]));const[h,d]=e,p={images:c},f={alignCorners:n,size:e},m=r.a.runKernelFunc((t,e)=>(e([c]),t.resizeNearestNeighbor(c,h,d,n)),p,null,i.kc,f);return l?Object(u.a)(m,[m.shape[1],m.shape[2],m.shape[3]]):m}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4),u=n(8);const c=Object(o.b)({resizeBilinear_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n=!1){const o=Object(s.a)(t,"images","resizeBilinear");a.b(3===o.rank||4===o.rank,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${o.rank}.`),a.b(2===e.length,()=>"Error in resizeBilinear: new shape must 2D, but got shape "+e+".");let c=o,l=!1;3===o.rank&&(l=!0,c=Object(u.a)(o,[1,o.shape[0],o.shape[1],o.shape[2]]));const[h,d]=e,p={images:c},f={alignCorners:n,size:e},m=r.a.runKernelFunc((t,e)=>(e([c]),t.resizeBilinear(c,h,d,n)),p,null,i.ic,f);return l?Object(u.a)(m,[m.shape[1],m.shape[2],m.shape[3]]):m}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(20),a=n(4),o=n(8);const u=Object(a.b)({depthwiseConv2dNativeBackpropInput_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,a,u,c=[1,1],l){let h=e,d=!1;3===e.rank&&(d=!0,h=Object(o.a)(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const p={dy:h,filter:n},f={strides:a,pad:u,dimRoundingMode:l,dilations:c,inputShape:t},m=r.a.runKernelFunc(e=>{const r=s.a(t,n.shape,a,c,u,l,!0);return e.depthwiseConv2DDerInput(h,n,r)},p,null,i.N,f);return d?Object(o.a)(m,[m.shape[1],m.shape[2],m.shape[3]]):m}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(20),a=n(4),o=n(8);const u=Object(a.b)({depthwiseConv2dNativeBackpropFilter_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,a,u,c=[1,1],l){let h=t;3===t.rank&&(h=Object(o.a)(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let d=e;3===d.rank&&(d=Object(o.a)(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const p={x:h,dy:d},f={strides:a,pad:u,dimRoundingMode:l,dilations:c,filterShape:n};return r.a.runKernelFunc(e=>{const r=s.a(t.shape,n,a,c,u,l,!0);return e.depthwiseConv2DDerFilter(h,d,r)},p,null,i.M,f)}})},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.PitchChordEncoder=e.TriadChordEncoder=e.MajorMinorChordEncoder=e.chordEncoderFromType=e.ChordEncoder=e.ChordSymbols=e.ChordEncodingException=e.ChordSymbolException=e.ChordQuality=void 0;var s,a=n(36),o=n(404),u=n(67),c=[["1P","3M","5P"],["1P","3m","5P"],["1P","3M","5A"],["1P","3m","5d"]];!function(t){t[t.Major=0]="Major",t[t.Minor=1]="Minor",t[t.Augmented=2]="Augmented",t[t.Diminished=3]="Diminished",t[t.Other=4]="Other"}(s=e.ChordQuality||(e.ChordQuality={}));var l=function(t){function e(e){var n=this.constructor,r=t.call(this,e)||this;return Object.setPrototypeOf(r,n.prototype),r}return i(e,t),e}(Error);e.ChordSymbolException=l;var h=function(t){function e(e){var n=this.constructor,r=t.call(this,e)||this;return Object.setPrototypeOf(r,n.prototype),r}return i(e,t),e}(Error);e.ChordEncodingException=h;var d=function(){function t(){}return t.pitches=function(t){if(!o.Chord.tokenize(t)[0]||!o.Chord.exists(t))throw new l("Unrecognized chord symbol: "+t);return o.Chord.notes(t).map(o.Note.chroma)},t.root=function(t){var e=o.Chord.tokenize(t)[0];if(!e)throw new l("Chord symbol has unknown root: "+t);return o.Note.chroma(e)},t.quality=function(t){if(!o.Chord.exists(t))throw new l("Unrecognized chord symbol: "+t);var e=o.Chord.intervals(t),n=c.map((function(t){return t.every((function(t){return e.includes(t)}))})),r=n.indexOf(!0),i=n.lastIndexOf(!0);return r>=0&&r===i?r:s.Other},t}();e.ChordSymbols=d;var p=function(){function t(){}return t.prototype.encodeProgression=function(t,e){var n=this,r=t.map((function(t){return n.encode(t)})),i=Array.from(Array(e).keys()).map((function(t){return Math.floor(t*r.length/e)}));return a.stack(i.map((function(t){return r[t]})))},t}();e.ChordEncoder=p,e.chordEncoderFromType=function(t){switch(t){case"MajorMinorChordEncoder":return new f;case"TriadChordEncoder":return new m;case"PitchChordEncoder":return new g;default:throw new Error("Unknown chord encoder type: "+t)}};var f=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.depth=1+2*u.NUM_PITCH_CLASSES,e}return i(e,t),e.prototype.index=function(t){if(t===u.NO_CHORD)return 0;var e=d.root(t),n=1+d.quality(t)*u.NUM_PITCH_CLASSES+e;if(n>=this.depth)throw new h("Chord is neither major nor minor: "+t);return n},e.prototype.encode=function(t){var e=this;return a.tidy((function(){return a.oneHot(a.tensor1d([e.index(t)],"int32"),e.depth).as1D()}))},e}(p);e.MajorMinorChordEncoder=f;var m=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.depth=1+4*u.NUM_PITCH_CLASSES,e}return i(e,t),e.prototype.index=function(t){if(t===u.NO_CHORD)return 0;var e=d.root(t),n=1+d.quality(t)*u.NUM_PITCH_CLASSES+e;if(n>=this.depth)throw new h("Chord is not a standard triad: "+t);return n},e.prototype.encode=function(t){var e=this;return a.tidy((function(){return a.oneHot(a.tensor1d([e.index(t)],"int32"),e.depth).as1D()}))},e}(p);e.TriadChordEncoder=m;var g=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.depth=1+3*u.NUM_PITCH_CLASSES,e}return i(e,t),e.prototype.encode=function(t){var e=this;return a.tidy((function(){if(t===u.NO_CHORD)return a.oneHot(a.tensor1d([0],"int32"),e.depth).as1D();var n=d.root(t),r=a.oneHot(a.tensor1d([n],"int32"),u.NUM_PITCH_CLASSES).as1D(),i=a.buffer([u.NUM_PITCH_CLASSES]);d.pitches(t).forEach((function(t){return i.set(1,t)}));var s=i.toTensor().as1D(),o=r;return a.concat1d([a.tensor1d([0]),r,s,o])}))},e}(p);e.PitchChordEncoder=g},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.GrooveConverter=e.MultitrackConverter=e.TrioRhythmConverter=e.TrioConverter=e.MelodyShapeConverter=e.MelodyRhythmConverter=e.MelodyConverter=e.DrumsOneHotConverter=e.DrumRollConverter=e.DrumsConverter=e.DataConverter=e.converterFromSpec=e.DEFAULT_DRUM_PITCH_CLASSES=void 0;var o=n(36),u=n(79),c=n(67),l=n(67);Object.defineProperty(e,"DEFAULT_DRUM_PITCH_CLASSES",{enumerable:!0,get:function(){return l.DEFAULT_DRUM_PITCH_CLASSES}});var h=n(55),d=n(258),p=n(259),f=n(92);e.converterFromSpec=function(t){switch(t.type){case"MelodyConverter":return new v(t.args);case"MelodyRhythmConverter":return new x(t.args);case"MelodyShapeConverter":return new _(t.args);case"DrumsConverter":return new g(t.args);case"DrumRollConverter":return new b(t.args);case"TrioConverter":return new O(t.args);case"TrioRhythmConverter":return new S(t.args);case"DrumsOneHotConverter":return new y(t.args);case"MultitrackConverter":return new k(t.args);case"GrooveConverter":return new T(t.args);default:throw new Error("Unknown DataConverter type: "+t)}};var m=function(){function t(t){this.NUM_SPLITS=0,this.SEGMENTED_BY_TRACK=!1,this.numSteps=t.numSteps,this.numSegments=t.numSegments}return t.prototype.tensorSteps=function(t){return o.scalar(t.shape[0],"int32")},t}();e.DataConverter=m;var g=function(t){function e(e){var n=t.call(this,e)||this;n.pitchClasses=e.pitchClasses||l.DEFAULT_DRUM_PITCH_CLASSES,n.pitchToClass=new Map;for(var r=function(t){i.pitchClasses[t].forEach((function(e){n.pitchToClass.set(e,t)}))},i=this,s=0;s<n.pitchClasses.length;++s)r(s);return n.depth=n.pitchClasses.length+1,n}return i(e,t),e.prototype.toTensor=function(t){var e=this;f.assertIsQuantizedSequence(t);for(var n=this.numSteps||t.totalQuantizedSteps,r=o.buffer([n,this.pitchClasses.length+1],"int32"),i=0;i<n;++i)r.set(1,i,-1);return t.notes.forEach((function(t){r.set(1,t.quantizedStartStep,e.pitchToClass.get(t.pitch)),r.set(0,t.quantizedStartStep,-1)})),r.toTensor()},e.prototype.toNoteSequence=function(t,e,n){return s(this,void 0,void 0,(function(){var r,i,s,o,c;return a(this,(function(a){switch(a.label){case 0:return r=f.createQuantizedNoteSequence(e,n),[4,(i=t.argMax(1)).data()];case 1:for(s=a.sent(),i.dispose(),o=0;o<s.length;++o)for(c=0;c<this.pitchClasses.length;c++)s[o]>>c&1&&r.notes.push(u.NoteSequence.Note.create({pitch:this.pitchClasses[c][0],quantizedStartStep:o,quantizedEndStep:o+1,isDrum:!0}));return r.totalQuantizedSteps=s.length,[2,r]}}))}))},e}(m);e.DrumsConverter=g;var b=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.toNoteSequence=function(t,e,n){return s(this,void 0,void 0,(function(){var r,i,s,o,c;return a(this,(function(a){switch(a.label){case 0:return r=f.createQuantizedNoteSequence(e,n),[4,t.data()];case 1:for(i=a.sent(),s=0;s<t.shape[0];++s)for(o=i.slice(s*this.pitchClasses.length,(s+1)*this.pitchClasses.length),c=0;c<o.length;++c)o[c]&&r.notes.push(u.NoteSequence.Note.create({pitch:this.pitchClasses[c][0],quantizedStartStep:s,quantizedEndStep:s+1,isDrum:!0}));return r.totalQuantizedSteps=t.shape[0],[2,r]}}))}))},e}(g);e.DrumRollConverter=b;var y=function(t){function e(e){var n=t.call(this,e)||this;return n.depth=Math.pow(2,n.pitchClasses.length),n}return i(e,t),e.prototype.toTensor=function(t){var e=this;f.assertIsRelativeQuantizedSequence(t);for(var n=this.numSteps||t.totalQuantizedSteps,r=Array(n).fill(0),i=0,s=t.notes;i<s.length;i++){var a=s[i],u=a.pitch,c=a.quantizedStartStep;r[c]+=Math.pow(2,this.pitchToClass.get(u))}return o.tidy((function(){return o.oneHot(o.tensor1d(r,"int32"),e.depth)}))},e}(g);e.DrumsOneHotConverter=y;var v=function(t){function e(e){var n=t.call(this,e)||this;return n.NOTE_OFF=1,n.FIRST_PITCH=2,n.minPitch=e.minPitch,n.maxPitch=e.maxPitch,n.ignorePolyphony=e.ignorePolyphony,n.depth=e.maxPitch-e.minPitch+1+n.FIRST_PITCH,n}return i(e,t),e.prototype.toTensor=function(t){var e=this,n=d.Melody.fromNoteSequence(t,this.minPitch,this.maxPitch,this.ignorePolyphony,this.numSteps);return o.tidy((function(){return o.oneHot(o.tensor(n.events,[n.events.length],"int32"),e.depth)}))},e.prototype.toNoteSequence=function(t,e,n){return s(this,void 0,void 0,(function(){var r,i;return a(this,(function(s){switch(s.label){case 0:return[4,(r=t.argMax(1)).data()];case 1:return i=s.sent(),r.dispose(),[2,new d.Melody(i,this.minPitch,this.maxPitch).toNoteSequence(e,n)]}}))}))},e}(m);e.MelodyConverter=v;var w=function(t){function e(e,n){var r=t.call(this,e)||this;return r.minPitch=e.minPitch,r.maxPitch=e.maxPitch,r.ignorePolyphony=e.ignorePolyphony,r.melodyControl=n,r.depth=n.depth,r}return i(e,t),e.prototype.toTensor=function(t){var e=d.Melody.fromNoteSequence(t,this.minPitch,this.maxPitch,this.ignorePolyphony,this.numSteps);return this.melodyControl.extract(e)},e}(m),x=function(t){function e(e){return t.call(this,e,new d.MelodyRhythm)||this}return i(e,t),e.prototype.toNoteSequence=function(t,e,n){return s(this,void 0,void 0,(function(){var r,i,s;return a(this,(function(a){switch(a.label){case 0:return r=f.createQuantizedNoteSequence(e,n),[4,t.data()];case 1:for(i=a.sent(),s=0;s<i.length;++s)i[s]&&r.notes.push(u.NoteSequence.Note.create({pitch:l.DEFAULT_DRUM_PITCH_CLASSES[1][0],quantizedStartStep:s,quantizedEndStep:s+1,isDrum:!0}));return r.totalQuantizedSteps=i.length,[2,r]}}))}))},e}(w);e.MelodyRhythmConverter=x;var _=function(t){function e(e){return t.call(this,e,new d.MelodyShape)||this}return i(e,t),e.prototype.toNoteSequence=function(t,e,n){return s(this,void 0,void 0,(function(){var r,i,s,o,c;return a(this,(function(a){switch(a.label){case 0:return r=f.createQuantizedNoteSequence(e,n),[4,(i=t.argMax(1)).data()];case 1:for(s=a.sent(),i.dispose(),o=Math.round((this.maxPitch+this.minPitch)/2),c=0;c<s.length;++c){switch(s[c]){case 0:(o-=1)<this.minPitch&&(o=this.minPitch,h.log("Pitch range exceeded when creating NoteSequence from shape.","MelodyShapeConverter"));break;case 2:(o+=1)>this.maxPitch&&(o=this.maxPitch,h.log("Pitch range exceeded when creating NoteSequence from shape.","MelodyShapeConverter"))}r.notes.push(u.NoteSequence.Note.create({pitch:o,quantizedStartStep:c,quantizedEndStep:c+1}))}return r.totalQuantizedSteps=s.length,[2,r]}}))}))},e}(w);e.MelodyShapeConverter=_;var O=function(t){function e(e){var n=t.call(this,e)||this;return n.NUM_SPLITS=3,n.MEL_PROG_RANGE=[0,31],n.BASS_PROG_RANGE=[32,39],e.melArgs.numSteps=e.numSteps,e.bassArgs.numSteps=e.numSteps,e.drumsArgs.numSteps=e.numSteps,n.melConverter=new v(e.melArgs),n.bassConverter=new v(e.bassArgs),n.drumsConverter=new y(e.drumsArgs),n.depth=n.melConverter.depth+n.bassConverter.depth+n.drumsConverter.depth,n}return i(e,t),e.prototype.toTensor=function(t){var e=this;f.assertIsQuantizedSequence(t);var n=f.clone(t),r=f.clone(t),i=f.clone(t);return n.notes=t.notes.filter((function(t){return!t.isDrum&&t.program>=e.MEL_PROG_RANGE[0]&&t.program<=e.MEL_PROG_RANGE[1]})),r.notes=t.notes.filter((function(t){return!t.isDrum&&t.program>=e.BASS_PROG_RANGE[0]&&t.program<=e.BASS_PROG_RANGE[1]})),i.notes=t.notes.filter((function(t){return t.isDrum})),o.tidy((function(){return o.concat([e.melConverter.toTensor(n),e.bassConverter.toTensor(r),e.drumsConverter.toTensor(i)],-1)}))},e.prototype.toNoteSequence=function(t,e,n){return s(this,void 0,void 0,(function(){var r,i,s,u,c,l,h=this;return a(this,(function(a){switch(a.label){case 0:return r=o.split(t,[this.melConverter.depth,this.bassConverter.depth,this.drumsConverter.depth],-1),[4,this.melConverter.toNoteSequence(r[0],e,n)];case 1:return(i=a.sent()).notes.forEach((function(t){t.instrument=0,t.program=0})),[4,this.bassConverter.toNoteSequence(r[1],e,n)];case 2:return s=a.sent(),(c=i.notes).push.apply(c,s.notes.map((function(t){return t.instrument=1,t.program=h.BASS_PROG_RANGE[0],t}))),[4,this.drumsConverter.toNoteSequence(r[2],e,n)];case 3:return u=a.sent(),(l=i.notes).push.apply(l,u.notes.map((function(t){return t.instrument=2,t}))),r.forEach((function(t){return t.dispose()})),[2,i]}}))}))},e}(m);e.TrioConverter=O;var S=function(t){function e(e){var n=t.call(this,e)||this;return n.NUM_SPLITS=3,n.trioConverter=new O(e),n.depth=3,n}return i(e,t),e.prototype.toTensor=function(t){var e=this;return o.tidy((function(){var n=e.trioConverter.toTensor(t),r=o.split(n,[e.trioConverter.melConverter.depth,e.trioConverter.bassConverter.depth,e.trioConverter.drumsConverter.depth],1),i=o.argMax(r[0],1),s=o.argMax(r[1],1),a=o.argMax(r[2],1),u=o.greater(i,1),c=o.greater(s,1),l=o.greater(a,0);return o.stack([u,c,l],1)}))},e.prototype.toNoteSequence=function(t,e,n){return s(this,void 0,void 0,(function(){var r,i,s,c;return a(this,(function(a){switch(a.label){case 0:return r=o.split(t,3,1),[4,Promise.all(r.map((function(t){return t.data()})))];case 1:for(i=a.sent(),s=f.createQuantizedNoteSequence(e,n),c=0;c<this.numSteps;++c)i[0][c]&&s.notes.push(u.NoteSequence.Note.create({pitch:72,quantizedStartStep:c,quantizedEndStep:c+1,instrument:0,program:0})),i[1][c]&&s.notes.push(u.NoteSequence.Note.create({pitch:36,quantizedStartStep:c,quantizedEndStep:c+1,instrument:1,program:32})),i[2][c]&&s.notes.push(u.NoteSequence.Note.create({pitch:l.DEFAULT_DRUM_PITCH_CLASSES[1][0],quantizedStartStep:c,quantizedEndStep:c+1,instrument:2,isDrum:!0}));return s.totalQuantizedSteps=this.numSteps,[2,s]}}))}))},e}(m);e.TrioRhythmConverter=S;var k=function(t){function e(e){var n=t.call(this,e)||this;return n.SEGMENTED_BY_TRACK=!0,n.stepsPerQuarter=e.stepsPerQuarter,n.totalSteps=e.totalSteps,n.numVelocityBins=e.numVelocityBins,n.minPitch=e.minPitch?e.minPitch:c.MIN_MIDI_PITCH,n.maxPitch=e.maxPitch?e.maxPitch:c.MAX_MIDI_PITCH,n.numPitches=n.maxPitch-n.minPitch+1,n.performanceEventDepth=2*n.numPitches+n.totalSteps+n.numVelocityBins,n.numPrograms=c.MAX_MIDI_PROGRAM-c.MIN_MIDI_PROGRAM+2,n.endToken=n.performanceEventDepth+n.numPrograms,n.depth=n.endToken+1,n.endTensor=o.tidy((function(){return o.oneHot(o.tensor1d([n.endToken],"int32"),n.depth).as1D()})),n}return i(e,t),e.prototype.trackToTensor=function(t){var e=this,n=this.numSteps/this.numSegments,r=void 0;if(t){for(;t.events.length>n-2;)t.events.pop();(r=o.buffer([t.events.length+2],"int32")).set(this.performanceEventDepth+(t.isDrum?this.numPrograms-1:t.program),0),t.events.forEach((function(t,n){switch(t.type){case"note-on":r.set(t.pitch-e.minPitch,n+1);break;case"note-off":r.set(e.numPitches+t.pitch-e.minPitch,n+1);break;case"time-shift":r.set(2*e.numPitches+t.steps-1,n+1);break;case"velocity-change":r.set(2*e.numPitches+e.totalSteps+t.velocityBin-1,n+1);break;default:throw new Error("Unrecognized performance event: "+t)}})),r.set(this.endToken,t.events.length+1)}else r=o.buffer([1],"int32",new Int32Array([this.endToken]));return o.tidy((function(){var t=o.oneHot(r.toTensor(),e.depth);return t.pad([[0,n-t.shape[0]],[0,0]])}))},e.prototype.toTensor=function(t){var e=this;if(f.assertIsRelativeQuantizedSequence(t),t.quantizationInfo.stepsPerQuarter!==this.stepsPerQuarter)throw new Error("Steps per quarter note mismatch: "+t.quantizationInfo.stepsPerQuarter+" != "+this.stepsPerQuarter);var n=f.clone(t);n.notes=t.notes.filter((function(t){return t.pitch>=e.minPitch&&t.pitch<=e.maxPitch}));for(var r=new Set(n.notes.map((function(t){return t.instrument}))),i=Array.from(r).map((function(t){return p.Performance.fromNoteSequence(n,e.totalSteps,e.numVelocityBins,t)})).sort((function(t,e){return e.isDrum?-1:t.isDrum?1:t.program-e.program}));i.length>this.numSegments;)i.pop();for(i.forEach((function(t){return t.setNumSteps(e.totalSteps)}));i.length<this.numSegments;)i.push(void 0);return o.tidy((function(){return o.concat(i.map((function(t){return e.trackToTensor(t)})),0)}))},e.prototype.tokensToTrack=function(t){var e=this,n=t.indexOf(this.endToken),r=n>=0?n:t.length,i=t.slice(0,r),s=i.filter((function(t){return t<e.performanceEventDepth})),a=i.filter((function(t){return t>=e.performanceEventDepth})),o=a.length?a[0]-this.performanceEventDepth<this.numPrograms-1?[a[0]-this.performanceEventDepth,!1]:[0,!0]:[0,!1],u=o[0],c=o[1],l=Array.from(s).map((function(t){if(t<e.numPitches)return{type:"note-on",pitch:e.minPitch+t};if(t<2*e.numPitches)return{type:"note-off",pitch:e.minPitch+t-e.numPitches};if(t<2*e.numPitches+e.totalSteps)return{type:"time-shift",steps:t-2*e.numPitches+1};if(t<2*e.numPitches+e.totalSteps+e.numVelocityBins)return{type:"velocity-change",velocityBin:t-2*e.numPitches-e.totalSteps+1};throw new Error("Invalid performance event token: "+t)}));return new p.Performance(l,this.totalSteps,this.numVelocityBins,u,c)},e.prototype.toNoteSequence=function(t,e,n){return void 0===e&&(e=this.stepsPerQuarter),s(this,void 0,void 0,(function(){var r,i,u=this;return a(this,(function(c){switch(c.label){case 0:return(r=f.createQuantizedNoteSequence(e,n)).totalQuantizedSteps=this.totalSteps,i=o.tidy((function(){return o.split(t.argMax(1),u.numSegments)})),[4,Promise.all(i.map((function(t){return s(u,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return[4,t.data()];case 1:return e=r.sent(),n=this.tokensToTrack(e),t.dispose(),[2,n]}}))}))})))];case 1:return c.sent().forEach((function(t,e){var n;t.setNumSteps(u.totalSteps),(n=r.notes).push.apply(n,t.toNoteSequence(e).notes)})),[2,r]}}))}))},e}(m);e.MultitrackConverter=k;var T=function(t){function e(e){var n=t.call(this,e)||this;n.TAPIFY_CHANNEL=3,n.stepsPerQuarter=e.stepsPerQuarter||c.DEFAULT_STEPS_PER_QUARTER,n.pitchClasses=e.pitchClasses||l.DEFAULT_DRUM_PITCH_CLASSES,n.pitchToClass=new Map;for(var r=function(t){i.pitchClasses[t].forEach((function(e){n.pitchToClass.set(e,t)}))},i=this,s=0;s<n.pitchClasses.length;++s)r(s);return n.humanize=e.humanize||!1,n.tapify=e.tapify||!1,n.splitInstruments=e.splitInstruments||!1,n.depth=3,n}return i(e,t),e.prototype.toTensor=function(t){for(var e=this,n=f.isRelativeQuantizedSequence(t)?t:f.quantizeNoteSequence(t,this.stepsPerQuarter),r=this.numSteps,i=n.tempos&&n.tempos.length?n.tempos[0].qpm:c.DEFAULT_QUARTERS_PER_MINUTE,s=60/i/this.stepsPerQuarter,a=[],u=0;u<r;++u)a.push(new Map);n.notes.forEach((function(t){if(e.tapify||e.pitchToClass.has(t.pitch)){var n=t.quantizedStartStep;if(n>=a.length)throw Error("Model does not support sequences with more than "+r+" steps ("+r*s+" seconds at qpm "+i+").");var o=e.tapify?e.TAPIFY_CHANNEL:e.pitchToClass.get(t.pitch);(!a[n].has(o)||a[n].get(o).velocity<t.velocity)&&a[n].set(o,t)}}));var l=this.pitchClasses.length,h=o.buffer([r,l]),d=o.buffer([r,l]),p=o.buffer([r,l]);function m(t){if(void 0===t.startTime)return 0;var e=t.startTime;return 2*(t.quantizedStartStep*s-e)/s}for(var g=0;g<r;++g)for(var b=0;b<l;++b){var y=a[g].get(b);h.set(y?1:0,g,b),this.humanize||this.tapify||d.set(y?y.velocity/c.MAX_MIDI_VELOCITY:0,g,b),this.humanize||p.set(y?m(y):0,g,b)}return o.tidy((function(){var t=h.toTensor(),n=d.toTensor(),i=p.toTensor(),s=e.splitInstruments?r*l:r;return o.concat([t.as2D(s,-1),n.as2D(s,-1),i.as2D(s,-1)],1)}))},e.prototype.toNoteSequence=function(t,e,n){return void 0===n&&(n=c.DEFAULT_QUARTERS_PER_MINUTE),s(this,void 0,void 0,(function(){function r(t,e,n){return Math.min(Math.max(t,e),n)}var i,s,o,l,h,d,p,f,m,g,b,y,v,w,x;return a(this,(function(a){switch(a.label){case 0:if(e&&e!==this.stepsPerQuarter)throw Error("`stepsPerQuarter` is set by the model.");return e=this.stepsPerQuarter,i=this.splitInstruments?t.shape[0]/this.pitchClasses.length:t.shape[0],s=60/n/this.stepsPerQuarter,o=u.NoteSequence.create({totalTime:i*s,tempos:[{qpm:n}]}),[4,t.data()];case 1:for(l=a.sent(),h=this.pitchClasses.length,d=0;d<i;++d)for(p=l.slice(d*h*this.depth,(d+1)*h*this.depth),f=0;f<h;++f)m=p[this.splitInstruments?f*this.depth:f],g=this.splitInstruments?f*this.depth+1:h+f,b=p[g],y=this.splitInstruments?f*this.depth+2:2*h+f,v=p[y],m>.5&&(w=r(Math.round(b*c.MAX_MIDI_VELOCITY),c.MIN_MIDI_VELOCITY,c.MAX_MIDI_VELOCITY),x=r(v/2,-.5,.5),o.notes.push(u.NoteSequence.Note.create({pitch:this.pitchClasses[f][0],startTime:(d-x)*s,endTime:(d-x+1)*s,velocity:w,isDrum:!0})));return[2,o]}}))}))},e}(m);e.GrooveConverter=T},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(261),i=new WeakMap;e.keySignatureKeys=["Cb","Gb","Db","Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#"];var s=function(){function t(t){var n=this;this.tempos=[],this.timeSignatures=[],this.keySignatures=[],this.meta=[],this.name="",i.set(this,480),t&&(i.set(this,t.header.ticksPerBeat),t.tracks.forEach((function(t){return t.forEach((function(t){t.meta&&("timeSignature"===t.type?n.timeSignatures.push({ticks:t.absoluteTime,timeSignature:[t.numerator,t.denominator]}):"setTempo"===t.type?n.tempos.push({bpm:6e7/t.microsecondsPerBeat,ticks:t.absoluteTime}):"keySignature"===t.type&&n.keySignatures.push({key:e.keySignatureKeys[t.key+7],scale:0===t.scale?"major":"minor",ticks:t.absoluteTime}))}))})),t.tracks[0].forEach((function(t){t.meta&&("trackName"===t.type?n.name=t.text:"text"!==t.type&&"cuePoint"!==t.type&&"marker"!==t.type&&"lyrics"!==t.type||n.meta.push({text:t.text,ticks:t.absoluteTime,type:t.type}))})),this.update())}return t.prototype.update=function(){var t=this,e=0,n=0;this.tempos.sort((function(t,e){return t.ticks-e.ticks})),this.tempos.forEach((function(r,i){var s=i>0?t.tempos[i-1].bpm:t.tempos[0].bpm,a=r.ticks/t.ppq-n,o=60/s*a;r.time=o+e,e=r.time,n+=a})),this.timeSignatures.sort((function(t,e){return t.ticks-e.ticks})),this.timeSignatures.forEach((function(e,n){var r=n>0?t.timeSignatures[n-1]:t.timeSignatures[0],i=(e.ticks-r.ticks)/t.ppq/r.timeSignature[0]/(r.timeSignature[1]/4);r.measures=r.measures||0,e.measures=i+r.measures}))},t.prototype.ticksToSeconds=function(t){var e=r.search(this.tempos,t);if(-1!==e){var n=this.tempos[e],i=n.time,s=(t-n.ticks)/this.ppq;return i+60/n.bpm*s}return.5*(t/this.ppq)},t.prototype.ticksToMeasures=function(t){var e=r.search(this.timeSignatures,t);if(-1!==e){var n=this.timeSignatures[e],i=(t-n.ticks)/this.ppq;return n.measures+i/(n.timeSignature[0]/n.timeSignature[1])/4}return t/this.ppq/4},Object.defineProperty(t.prototype,"ppq",{get:function(){return i.get(this)},enumerable:!0,configurable:!0}),t.prototype.secondsToTicks=function(t){var e=r.search(this.tempos,t,"time");if(-1!==e){var n=this.tempos[e],i=(t-n.time)/(60/n.bpm);return Math.round(n.ticks+i*this.ppq)}var s=t/.5;return Math.round(s*this.ppq)},t.prototype.toJSON=function(){return{keySignatures:this.keySignatures,meta:this.meta,name:this.name,ppq:this.ppq,tempos:this.tempos.map((function(t){return{bpm:t.bpm,ticks:t.ticks}})),timeSignatures:this.timeSignatures}},t.prototype.fromJSON=function(t){this.name=t.name,this.tempos=t.tempos.map((function(t){return Object.assign({},t)})),this.timeSignatures=t.timeSignatures.map((function(t){return Object.assign({},t)})),this.keySignatures=t.keySignatures.map((function(t){return Object.assign({},t)})),this.meta=t.meta.map((function(t){return Object.assign({},t)})),i.set(this,t.ppq),this.update()},t.prototype.setTempo=function(t){this.tempos=[{bpm:t,ticks:0}],this.update()},t}();e.Header=s},function(t,e,n){var r=n(374),i=n(375),s="undefined"!=typeof Float64Array;function a(t,e){return t[0]-e[0]}function o(){var t,e=this.stride,n=new Array(e.length);for(t=0;t<n.length;++t)n[t]=[Math.abs(e[t]),t];n.sort(a);var r=new Array(n.length);for(t=0;t<r.length;++t)r[t]=n[t][1];return r}function u(t,e){var n=["View",e,"d",t].join("");e<0&&(n="View_Nil"+t);var i="generic"===t;if(-1===e){var s="function "+n+"(a){this.data=a;};var proto="+n+".prototype;proto.dtype='"+t+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+n+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+n+"(a){return new "+n+"(a);}";return new Function(s)()}if(0===e){s="function "+n+"(a,d) {this.data = a;this.offset = d};var proto="+n+".prototype;proto.dtype='"+t+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+n+"_copy() {return new "+n+"(this.data,this.offset)};proto.pick=function "+n+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+n+"_get(){return "+(i?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+n+"_set(v){return "+(i?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+n+"(a,b,c,d){return new "+n+"(a,d)}";return new Function("TrivialArray",s)(c[t][0])}s=["'use strict'"];var a=r(e),u=a.map((function(t){return"i"+t})),l="this.offset+"+a.map((function(t){return"this.stride["+t+"]*i"+t})).join("+"),h=a.map((function(t){return"b"+t})).join(","),d=a.map((function(t){return"c"+t})).join(",");s.push("function "+n+"(a,"+h+","+d+",d){this.data=a","this.shape=["+h+"]","this.stride=["+d+"]","this.offset=d|0}","var proto="+n+".prototype","proto.dtype='"+t+"'","proto.dimension="+e),s.push("Object.defineProperty(proto,'size',{get:function "+n+"_size(){return "+a.map((function(t){return"this.shape["+t+"]"})).join("*"),"}})"),1===e?s.push("proto.order=[0]"):(s.push("Object.defineProperty(proto,'order',{get:"),e<4?(s.push("function "+n+"_order(){"),2===e?s.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&s.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):s.push("ORDER})")),s.push("proto.set=function "+n+"_set("+u.join(",")+",v){"),i?s.push("return this.data.set("+l+",v)}"):s.push("return this.data["+l+"]=v}"),s.push("proto.get=function "+n+"_get("+u.join(",")+"){"),i?s.push("return this.data.get("+l+")}"):s.push("return this.data["+l+"]}"),s.push("proto.index=function "+n+"_index(",u.join(),"){return "+l+"}"),s.push("proto.hi=function "+n+"_hi("+u.join(",")+"){return new "+n+"(this.data,"+a.map((function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")})).join(",")+","+a.map((function(t){return"this.stride["+t+"]"})).join(",")+",this.offset)}");var p=a.map((function(t){return"a"+t+"=this.shape["+t+"]"})),f=a.map((function(t){return"c"+t+"=this.stride["+t+"]"}));s.push("proto.lo=function "+n+"_lo("+u.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+f.join(","));for(var m=0;m<e;++m)s.push("if(typeof i"+m+"==='number'&&i"+m+">=0){d=i"+m+"|0;b+=c"+m+"*d;a"+m+"-=d}");s.push("return new "+n+"(this.data,"+a.map((function(t){return"a"+t})).join(",")+","+a.map((function(t){return"c"+t})).join(",")+",b)}"),s.push("proto.step=function "+n+"_step("+u.join(",")+"){var "+a.map((function(t){return"a"+t+"=this.shape["+t+"]"})).join(",")+","+a.map((function(t){return"b"+t+"=this.stride["+t+"]"})).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(m=0;m<e;++m)s.push("if(typeof i"+m+"==='number'){d=i"+m+"|0;if(d<0){c+=b"+m+"*(a"+m+"-1);a"+m+"=ceil(-a"+m+"/d)}else{a"+m+"=ceil(a"+m+"/d)}b"+m+"*=d}");s.push("return new "+n+"(this.data,"+a.map((function(t){return"a"+t})).join(",")+","+a.map((function(t){return"b"+t})).join(",")+",c)}");var g=new Array(e),b=new Array(e);for(m=0;m<e;++m)g[m]="a[i"+m+"]",b[m]="b[i"+m+"]";s.push("proto.transpose=function "+n+"_transpose("+u+"){"+u.map((function(t,e){return t+"=("+t+"===undefined?"+e+":"+t+"|0)"})).join(";"),"var a=this.shape,b=this.stride;return new "+n+"(this.data,"+g.join(",")+","+b.join(",")+",this.offset)}"),s.push("proto.pick=function "+n+"_pick("+u+"){var a=[],b=[],c=this.offset");for(m=0;m<e;++m)s.push("if(typeof i"+m+"==='number'&&i"+m+">=0){c=(c+this.stride["+m+"]*i"+m+")|0}else{a.push(this.shape["+m+"]);b.push(this.stride["+m+"])}");return s.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),s.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+a.map((function(t){return"shape["+t+"]"})).join(",")+","+a.map((function(t){return"stride["+t+"]"})).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",s.join("\n"))(c[t],o)}var c={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};t.exports=function(t,e,n,r){if(void 0===t)return(0,c.array[0])([]);"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var a=e.length;if(void 0===n){n=new Array(a);for(var o=a-1,l=1;o>=0;--o)n[o]=l,l*=e[o]}if(void 0===r){r=0;for(o=0;o<a;++o)n[o]<0&&(r-=(e[o]-1)*n[o])}for(var h=function(t){if(i(t))return"buffer";if(s)switch(Object.prototype.toString.call(t)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(t)?"array":"generic"}(t),d=c[h];d.length<=a+1;)d.push(u(h,d.length-1));return(0,d[a+1])(t,e,n,r)}},function(t,e,n){"use strict";var r=n(265),i={body:"",args:[],thisVars:[],localVars:[]};function s(t){if(!t)return i;for(var e=0;e<t.args.length;++e){var n=t.args[e];t.args[e]=0===e?{name:n,lvalue:!0,rvalue:!!t.rvalue,count:t.count||1}:{name:n,lvalue:!1,rvalue:!0,count:1}}return t.thisVars||(t.thisVars=[]),t.localVars||(t.localVars=[]),t}function a(t){for(var e=[],n=0;n<t.args.length;++n)e.push("a"+n);return new Function("P",["return function ",t.funcName,"_ndarrayops(",e.join(","),") {P(",e.join(","),");return a0}"].join(""))(function(t){return r({args:t.args,pre:s(t.pre),body:s(t.body),post:s(t.proc),funcName:t.funcName})}(t))}var o={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};!function(){for(var t in o){var n=o[t];e[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+n+"c"},funcName:t}),e[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+n+"=b"},rvalue:!0,funcName:t+"eq"}),e[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+n+"s"},funcName:t+"s"}),e[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+n+"=s"},rvalue:!0,funcName:t+"seq"})}}();var u={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in u){var n=u[t];e[t]=a({args:["array","array"],body:{args:["a","b"],body:"a="+n+"b"},funcName:t}),e[t+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+n+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var c={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in c){var n=c[t];e[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+n+"c"},funcName:t}),e[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+n+"s"},funcName:t+"s"}),e[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+n+"b"},rvalue:!0,count:2,funcName:t+"eq"}),e[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+n+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var l=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;t<l.length;++t){var n=l[t];e[n]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+n,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:n}),e[n+"eq"]=a({args:["array"],pre:{args:[],body:"this_f=Math."+n,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:n+"eq"})}}();var h=["max","min","atan2","pow"];!function(){for(var t=0;t<h.length;++t){var n=h[t];e[n]=a({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+n,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:n}),e[n+"s"]=a({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+n,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:n+"s"}),e[n+"eq"]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+n,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:n+"eq"}),e[n+"seq"]=a({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+n,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:n+"seq"})}}();var d=["atan2","pow"];!function(){for(var t=0;t<d.length;++t){var n=d[t];e[n+"op"]=a({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+n,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:n+"op"}),e[n+"ops"]=a({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+n,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:n+"ops"}),e[n+"opeq"]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+n,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:n+"opeq"}),e[n+"opseq"]=a({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+n,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:n+"opseq"})}}(),e.any=r({args:["array"],pre:i,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"}),e.all=r({args:["array"],pre:i,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"}),e.sum=r({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"}),e.prod=r({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"}),e.norm2squared=r({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"}),e.norm2=r({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"}),e.norminf=r({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),e.norm1=r({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),e.sup=r({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),e.inf=r({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),e.argmin=r({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),e.argmax=r({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),e.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),e.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),e.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),e.equals=r({args:["array","array"],pre:i,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MIDI_PITCHES=e.MAX_MIDI_PITCH=e.MIN_MIDI_PITCH=e.MEL_SPEC_BINS=e.FRAME_LENGTH_SECONDS=e.SPEC_HOP_LENGTH=e.SAMPLE_RATE=void 0,e.SAMPLE_RATE=16e3,e.SPEC_HOP_LENGTH=512,e.FRAME_LENGTH_SECONDS=e.SPEC_HOP_LENGTH/e.SAMPLE_RATE,e.MEL_SPEC_BINS=229,e.MIN_MIDI_PITCH=21,e.MAX_MIDI_PITCH=108,e.MIDI_PITCHES=e.MAX_MIDI_PITCH-e.MIN_MIDI_PITCH+1},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.upsample_linear=e.upsample_f0=e.shiftF0=e.getPitches=void 0;var s=n(36),a=n(111),o=n(146);function u(t,e){for(var n=[],r=Math.floor(e/t.length),i=e%t.length,s=0;s<t.length;s++){n.push(t[s]);for(var a=1;a<r;a++)n.push(-1);s<i&&n.push(-1)}var o=-1;for(s=0;s<n.length;s++)if(-1!==n[s]){var u=n[s],c=o>=0?n[o]:0;-1!==o&&(u-=n[o]);for(a=o+1;a<s;a++)n[a]=c+u*(a-o)/(s-o);o=s}for(s=o+1;s<n.length;s++)n[s]=o>=0?n[s-1]:0;return n}function c(t){var e=t*o.PT_SLOPE+o.PT_OFFSET;return 10*Math.pow(2,1*e/12)}e.shiftF0=function(t,e){return void 0===e&&(e=0),s.tidy((function(){var n=s.mul(t,s.pow(2,e));return n=n.clipByValue(0,a.midiToHz(110).dataSync()[0])}))},e.upsample_linear=u,e.upsample_f0=function(t,e,n){return t.splice(n),u(t,e)},e.getPitches=function(t,e,n){return void 0===n&&(n=o.CONF_THRESHOLD),r(this,void 0,void 0,(function(){var r,a,u,l,h,d,p,f,m,g,b,y,v,w,x,_,O,S,k,T,C,A,N,I;return i(this,(function(i){switch(i.label){case 0:return 16e3,r=512,a=[],u=[],l=e.length,h=s.tensor(e),d=Math.ceil(l/r)*r,p=h.pad([[0,d-l]]),f=p.size/16e3,[4,t.execute({input_audio_samples:p})];case 1:return[4,(m=i.sent())[0].data()];case 2:return g=i.sent(),[4,m[1].data()];case 3:if(32*((b=i.sent()).length-1)/1e3!==f)return[3,9];k=20,T=0,i.label=4;case 4:return T<b.length?(C=1-g[T],u.push(C),C>=o.CONF_THRESHOLD?(k=c(b[T]),a.push(k),[3,7]):[3,5]):[3,8];case 5:return[4,(A=s.truncatedNormal([1],0,o.PITCH_CONF_JITTER)).array()];case 6:N=i.sent(),I=1-N,a.push(k*I),A.dispose(),i.label=7;case 7:return++T,[3,4];case 8:return[3,20];case 9:y=d/r+1,v=new Float32Array(y),g=new Float32Array(y),T=0,i.label=10;case 10:return T<d?(w=p.slice([T],[d/4]),[4,t.execute({input_audio_samples:w})]):[3,15];case 11:return[4,(x=i.sent())[0].data()];case 12:return _=i.sent(),[4,x[1].data()];case 13:O=i.sent(),S=Math.floor(T/r),g.set(_,S),v.set(O,S),w.dispose(),x[0].dispose(),x[1].dispose(),i.label=14;case 14:return T+=d/4,[3,10];case 15:k=20,T=0,i.label=16;case 16:return T<v.length?(C=1-g[T],u.push(C),C>=n?(k=c(v[T]),a.push(k),[3,19]):[3,17]):[3,20];case 17:return[4,(A=s.truncatedNormal([1],0,o.PITCH_CONF_JITTER)).array()];case 18:N=i.sent(),I=1-N,a.push(k*I),A.dispose(),i.label=19;case 19:return++T,[3,16];case 20:return m[0].dispose(),m[1].dispose(),h.dispose(),p.dispose(),[2,{pitches:a,confidences:u}]}}))}))}},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({acos_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","acos"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.acos(e);return n([e]),r},n,null,i.b)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({acosh_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","acosh"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.acosh(e);return n([e]),r},n,null,i.c)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4);const u=Object(o.b)({addN_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){a.b(Array.isArray(t),()=>"The argument passed to tf.addN() must be a list of tensors"),a.b(t.length>=1,()=>"Must pass at least one tensor to tf.addN(), but got "+t.length);const e=t.map((t,e)=>Object(s.a)(t,"tensors"+e,"addN")),n=e[0];e.forEach(t=>{if(t.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),e.forEach(t=>{if(!a.a(t.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});const o=e;return r.a.runKernelFunc((t,n)=>{const r=t.addN(e);return n(e),r},o,null,i.e)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({asin_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","asin"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.asin(e);return n([e]),r},n,null,i.j)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({asinh_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","asinh"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.asinh(e);return n([e]),r},n,null,i.k)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({atan_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","atan"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.atan(e);return n([e]),r},n,null,i.l)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({atanh_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","atanh"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.atanh(e);return n([e]),r},n,null,i.n)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return d}));var r=n(5),i=n(22),s=n(3),a=n(1),o=n(7),u=n(12),c=n(20),l=n(4),h=n(8);const d=Object(l.b)({avgPool3d_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,l,d,p="NDHWC",f){null==f?f=[1,1,1]:Object(i.b)("dilations is deprecated, this field will be gone in v3.0.0.");const m=Object(a.a)(t,"x","avgPool3d","float32");let g=m,b=!1;4===m.rank&&(b=!0,g=Object(h.a)(m,[1,m.shape[0],m.shape[1],m.shape[2],m.shape[3]])),o.b(5===g.rank,()=>`Error in avgPool3d: x must be rank 5 but got rank ${g.rank}.`),o.b("NDHWC"===p,()=>"Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of "+p),o.b(c.h(n,f),()=>`Error in avgPool3d: Either strides or dilations must be 1. Got strides ${n} and dilations '${f}'`),null!=d&&o.b(o.v(l),()=>`Error in avgPool3d: pad must be an integer when using, dimRoundingMode ${d} but got pad ${l}.`);const y={x:g},v={filterSize:e,strides:n,pad:l,dimRoundingMode:d,dataFormat:p,dilations:f};let w=r.a.runKernelFunc((t,r)=>{null==f&&(f=[1,1,1]);const i=c.f(g.shape,e,n,f,l,d,p);return r([g]),t.avgPool3d(g,i)},y,null,s.p,v);return w=Object(u.a)(w,g.dtype),b?Object(h.a)(w,[w.shape[1],w.shape[2],w.shape[3],w.shape[4]]):w}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({ceil_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","ceil"),n={x:e};return r.a.runKernelFunc(t=>t.ceil(e),n,null,i.w)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(4);const u=Object(o.b)({clipByValue_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n){const o=Object(s.a)(t,"x","clipByValue");a.b(e<=n,()=>`Error in clip: min (${e}) must be less than or equal to max (${n}).`);const u={x:o},c={clipValueMin:e,clipValueMax:n};return r.a.runKernelFunc((t,r)=>{const i=t.clip(o,e,n);return r([o]),i},u,null,i.x,c)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(20),u=n(4),c=n(8);const l=Object(u.b)({conv3d_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,u,l="NDHWC",h=[1,1,1]){const d=Object(s.a)(t,"x","conv3d"),p=Object(s.a)(e,"filter","conv3d");let f=d,m=!1;4===d.rank&&(m=!0,f=Object(c.a)(d,[1,d.shape[0],d.shape[1],d.shape[2],d.shape[3]])),a.b(5===f.rank,()=>`Error in conv3d: input must be rank 5, but got rank ${f.rank}.`),a.b(5===p.rank,()=>"Error in conv3d: filter must be rank 5, but got rank "+p.rank+"."),a.b(f.shape[4]===p.shape[3],()=>`Error in conv3d: depth of input (${f.shape[4]}) must match input depth for filter ${p.shape[3]}.`),a.b(Object(o.h)(n,h),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${h}'`),a.b("NDHWC"===l,()=>`Error in conv3d: got dataFormat of ${l} but only NDHWC is currently supported.`);const g={x:f,filter:p},b={strides:n,pad:u,dataFormat:l,dilations:h},y=r.a.runKernelFunc((t,e)=>{const r=o.b(f.shape,p.shape,n,h,u),i=t.conv3d(f,p,r);return e([f,p]),i},g,null,i.D,b);return m?Object(c.a)(y,[y.shape[1],y.shape[2],y.shape[3],y.shape[4]]):y}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(5),i=n(3),s=n(1),a=n(7),o=n(12),u=n(4);const c=Object(u.b)({erf_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){let e=Object(s.a)(t,"x","erf");a.b("int32"===e.dtype||"float32"===e.dtype,()=>"Input dtype must be `int32` or `float32`."),"int32"===e.dtype&&(e=Object(o.a)(e,"float32"));const n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.erf(e);return n([e]),r},n,null,i.W)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({expm1_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","expm1"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.expm1(e);return n([e]),r},n,null,i.Y)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({isFinite_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","isFinite"),n={x:e};return r.a.runKernelFunc(t=>t.isFinite(e),n,null,i.pb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({isInf_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","isInf"),n={x:e};return r.a.runKernelFunc(t=>t.isInf(e),n,null,i.qb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({isNaN_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","isNaN"),n={x:e};return r.a.runKernelFunc(t=>t.isNaN(e),n,null,i.rb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));var r=n(5),i=n(3);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function s(t,e,n){if(n<=0)throw new Error("The number of values should be positive.");const s={start:t,stop:e,num:n};return r.a.runKernelFunc(r=>r.linspace(t,e,n),{},null,i.wb,s)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(33),i=n(1),s=n(9),a=n(30),o=n(4),u=n(87),c=n(175);const l=Object(o.b)({logSigmoid_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(i.a)(t,"x","logSigmoid");return Object(r.a)(t=>({value:Object(a.a)(Object(c.a)(Object(a.a)(t))),gradFunc:e=>Object(s.a)(e,Object(u.a)(Object(a.a)(t)))}))(e)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return p}));var r=n(5),i=n(3),s=n(1),a=n(12),o=n(40),u=n(76),c=n(72),l=n(4),h=n(14),d=n(21);const p=Object(l.b)({logSoftmax_:
/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=-1){const n=Object(s.a)(t,"logits","logSoftmax");if(-1===e&&(e=n.rank-1),e!==n.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${e}`);const l={logits:n},p={axis:e};return r.a.runKernelFunc((n,r)=>{const i=Object(c.a)(t,e,!0),s=Object(h.a)(t,i),l=Object(h.a)(Object(a.a)(s,"float32"),Object(u.a)(Object(d.a)(Object(o.a)(s),e,!0)));return r([l]),l},l,null,i.zb,p)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return h}));var r=n(5),i=n(22),s=n(3),a=n(1),o=n(7),u=n(20),c=n(4),l=n(8);const h=Object(c.b)({maxPool3d_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=[1,1,1],n,c,h,d="NDHWC",p){null==p?p=[1,1,1]:Object(i.b)("dilations is deprecated, this field will be gone in v3.0.0.");const f=Object(a.a)(t,"x","maxPool3d");let m=f,g=!1;4===f.rank&&(g=!0,m=Object(l.a)(f,[1,f.shape[0],f.shape[1],f.shape[2],f.shape[3]])),o.b(5===m.rank,()=>`Error in maxPool3d: x must be rank 5 but got rank ${m.rank}.`),o.b("NDHWC"===d,()=>"Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of "+d),o.b(u.h(n,p),()=>`Error in maxPool3d: Either strides or dilations must be 1. Got strides ${n} and dilations '${p}'`),null!=h&&o.b(o.v(c),()=>`Error in maxPool3d: pad must be an integer when using, dimRoundingMode ${h} but got pad ${c}.`);const b={x:m},y={filterSize:e,strides:n,pad:c,dimRoundingMode:h,dataFormat:d,dilations:p},v=r.a.runKernelFunc((t,r)=>{null==p&&(p=[1,1,1]);const i=u.f(m.shape,e,n,p,c,h,d),s=t.maxPool3d(m,i);return r([m,s]),s},b,null,s.Fb,y);return g?Object(l.a)(v,[v.shape[1],v.shape[2],v.shape[3],v.shape[4]]):v}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({maxPoolWithArgmax_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,a,o=!1){const u={x:Object(s.a)(t,"x","maxPoolWithArgmax")},c={filterSize:e,strides:n,pad:a,includeBatchInIndex:o},l=r.a.runKernel(i.Ib,u,c);return{result:l[0],indexes:l[1]}}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(1),s=n(4),a=n(8);const o=Object(s.b)({multinomial_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,s=!1){const o=Object(i.a)(t,"logits","multinomial"),u=o.size,c=o.rank;if(u<2)throw new Error("Error in multinomial: you need at least 2 outcomes, but got "+u+".");if(c>2)throw new Error("Rank of probabilities must be 1 or 2, but is "+c);n=n||Math.random();const l=1===c?Object(a.a)(o,[1,-1]):o,h=r.a.runKernelFunc(t=>t.multinomial(l,s,e,n),{logits2D:l});return 1===c?Object(a.a)(h,[h.size]):h}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return h}));var r=n(5),i=n(3),s=n(1),a=n(51),o=n(100),u=n(4),c=n(94),l=n(23);const h=Object(u.b)({onesLike_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","onesLike"),n={x:e};return r.a.runKernelFunc((t,n)=>{if("complex64"===e.dtype){const t=h(Object(c.a)(e)),n=Object(l.a)(Object(o.a)(e));return Object(a.a)(t,n)}return t.onesLike(e)},n,null,i.Wb)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({reciprocal_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","reciprocal"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.reciprocal(e);return n([e]),r},n,null,i.ec)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({round_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","round"),n={x:e};return r.a.runKernelFunc(t=>t.round(e),n,null,i.oc)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return a}));var r=n(6),i=n(1),s=n(7);const a=
/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
async function(t,e){const n=Object(i.a)(t,"x","setdiff1d"),a=Object(i.a)(e,"y","setdiff1d");s.b(n.dtype===a.dtype,()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${a.dtype}).`),s.b(1===n.rank,()=>`x should be 1D tensor, but got x (${n.shape}).`),s.b(1===a.rank,()=>`y should be 1D tensor, but got y (${a.shape}).`);const o=await n.data(),u=await a.data(),c=new Set(u);let l=0;for(let t=0;t<o.length;t++)c.has(o[t])||l++;const h=new r.b([l],n.dtype),d=new r.b([l],"int32");for(let t=0,e=0;t<o.length;t++)c.has(o[t])||(h.values[e]=o[t],d.values[e]=t,e++);return[h.toTensor(),d.toTensor()]}},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({sign_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","sign"),n={x:e};return r.a.runKernelFunc(t=>t.sign(e),n,null,i.uc)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({softmax_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=-1){const n=Object(s.a)(t,"logits","softmax","float32");if(-1===e&&(e=n.rank-1),e!==n.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and dim was ${e}`);const a={logits:n},o={dim:e};return r.a.runKernelFunc((t,r)=>{const i=t.softmax(n,e);return r([i]),i},a,null,i.yc,o)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(5),i=n(3),s=n(1),a=n(4),o=n(8),u=n(28),c=n(52);const l=Object(a.b)({stridedSlice_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,a,l=0,h=0,d=0,p=0,f=0){let m=Object(s.a)(t,"x","stridedSlice");const g={x:m},b={begin:e,end:n,strides:a,beginMask:l,endMask:h,ellipsisMask:d,newAxisMask:p,shrinkAxisMask:f};return r.a.runKernelFunc(t=>{null==a&&(a=new Array(e.length));const r=Object(c.maskToAxes)(d);if(r.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(0!==d&&0!==p)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(0!==d&&0!==f)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");const i=m.rank-e.length,s=Object(c.maskToAxes)(p),g=m.shape.slice();s.forEach(t=>{e[t]=0,n[t]=1,g.splice(t,0,1)}),m=Object(o.a)(m,g);const{begin:b,end:y,strides:v}=Object(c.getNormalizedAxes)(m.shape,r,i,e,n,a,l,h,d);e=b,n=y,a=v;const w=Object(c.maskToAxes)(f);w.forEach(t=>{n[t]=e[t]+1,a[t]=1});const x=Object(c.computeOutShape)(e,n,a),_=x.filter((t,e)=>-1===w.indexOf(e));if(a.every(t=>1===t))return Object(o.a)(Object(u.a)(m,e,x),_);const O=t.stridedSlice(m,e,n,a);return Object(o.a)(O,_)},g,null,i.Hc,b)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({tan_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t){const e=Object(s.a)(t,"x","tan"),n={x:e};return r.a.runKernelFunc((t,n)=>{const r=t.tan(e);return n([e]),r},n,null,i.Kc)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return a}));var r=n(39),i=n(4),s=n(109);const a=Object(i.b)({truncatedNormal_:
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e=0,n=1,i,a){if(null!=i&&"bool"===i)throw new Error("Unsupported data type $ { dtype }");const o=new s.a(e,n,i,!0,a),u=Object(r.a)(t,i);for(let t=0;t<u.values.length;t++)u.values[t]=o.nextValue();return u.toTensor()}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return p})),n.d(e,"b",(function(){return f})),n.d(e,"c",(function(){return m})),n.d(e,"d",(function(){return g})),n.d(e,"e",(function(){return b})),n.d(e,"f",(function(){return y}));var r=n(22),i=n(1),s=n(7),a=n(82),o=n(46),u=n(56),c=n(101),l=n(57),h=n(104),d=n(4);const p=Object(d.b)({equalStrict_:function(t,e){Object(r.b)("strict variants of ops have been deprecated and will be removed in future");const n=Object(i.a)(t,"a","equalStrict"),o=Object(i.a)(e,"b","equalStrict");return Object(s.e)(n.shape,o.shape,"Error in equalStrict: "),Object(a.a)(n,o)}}),f=Object(d.b)({greaterEqualStrict_:function(t,e){Object(r.b)("strict variants of ops have been deprecated and will be removed in future");const n=Object(i.a)(t,"a","greaterEqualStrict"),a=Object(i.a)(e,"b","greaterEqualStrict");return Object(s.e)(n.shape,a.shape,"Error in greaterEqualStrict: "),Object(u.a)(n,a)}}),m=Object(d.b)({greaterStrict_:function(t,e){Object(r.b)("strict variants of ops have been deprecated and will be removed in future");const n=Object(i.a)(t,"a","greaterStrict"),a=Object(i.a)(e,"b","greaterStrict");return Object(s.e)(n.shape,a.shape,"Error in greaterStrict: "),Object(o.a)(n,a)}}),g=Object(d.b)({lessEqualStrict_:function(t,e){Object(r.b)("strict variants of ops have been deprecated and will be removed in future");const n=Object(i.a)(t,"a","lessEqualStrict"),a=Object(i.a)(e,"b","lessEqualStrict");return Object(s.e)(n.shape,a.shape,"Error in lessEqualStrict: "),Object(l.a)(n,a)}}),b=Object(d.b)({lessStrict_:function(t,e){Object(r.b)("strict variants of ops have been deprecated and will be removed in future");const n=Object(i.a)(t,"a","lessStrict"),a=Object(i.a)(e,"b","lessStrict");return Object(s.e)(n.shape,a.shape,"Error in lessStrict: "),Object(c.a)(n,a)}}),y=Object(d.b)({notEqualStrict_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){Object(r.b)("strict variants of ops have been deprecated and will be removed in future");const n=Object(i.a)(t,"a","notEqualStrict"),a=Object(i.a)(e,"b","notEqualStrict");return Object(s.e)(n.shape,a.shape,"Error in notEqualStrict: "),Object(h.a)(n,a)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return g})),n.d(e,"b",(function(){return b})),n.d(e,"c",(function(){return y})),n.d(e,"d",(function(){return v})),n.d(e,"e",(function(){return w})),n.d(e,"f",(function(){return x})),n.d(e,"g",(function(){return _})),n.d(e,"h",(function(){return O})),n.d(e,"i",(function(){return S}));var r=n(22),i=n(1),s=n(7),a=n(13),o=n(16),u=n(68),c=n(103),l=n(132),h=n(9),d=n(4),p=n(44),f=n(106),m=n(14);const g=Object(d.b)({addStrict_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){Object(r.b)("strict variants of ops have been deprecated and will be removed in future");const n=Object(i.a)(t,"a","addStrict"),o=Object(i.a)(e,"b","addStrict");return s.e(n.shape,o.shape,"Error in addStrict: "),Object(a.a)(n,o)}}),b=Object(d.b)({divStrict_:function(t,e){Object(r.b)("strict variants of ops have been deprecated and will be removed in future");const n=Object(i.a)(t,"a","div"),a=Object(i.a)(e,"b","div");return s.e(n.shape,a.shape,"Error in divideStrict: "),Object(o.a)(n,a)}}),y=Object(d.b)({maximumStrict_:function(t,e){Object(r.b)("strict variants of ops have been deprecated and will be removed in future");const n=Object(i.a)(t,"a","maximumStrict"),a=Object(i.a)(e,"b","maximumStrict");return s.e(n.shape,a.shape,"Error in maximumStrict: "),Object(u.a)(n,a)}}),v=Object(d.b)({minimumStrict_:function(t,e){Object(r.b)("strict variants of ops have been deprecated and will be removed in future");const n=Object(i.a)(t,"a","minimumStrict"),a=Object(i.a)(e,"b","minimumStrict");return s.e(n.shape,a.shape,"Error in minimumStrict: "),Object(c.a)(n,a)}}),w=Object(d.b)({modStrict_:function(t,e){Object(r.b)("strict variants of ops have been deprecated and will be removed in future");const n=Object(i.a)(t,"a","modStrict"),a=Object(i.a)(e,"b","modStrict");return s.e(n.shape,a.shape,"Error in modStrict: "),Object(l.a)(n,a)}}),x=Object(d.b)({mulStrict_:function(t,e){Object(r.b)("strict variants of ops have been deprecated and will be removed in future");const n=Object(i.a)(t,"a","mul"),a=Object(i.a)(e,"b","mul");return s.e(n.shape,a.shape,"Error in multiplyStrict: "),Object(h.a)(n,a)}}),_=Object(d.b)({powStrict_:function(t,e){return Object(r.b)("strict variants of ops have been deprecated and will be removed in future"),s.e(t.shape,e.shape,"Error in powStrict: "),Object(p.a)(t,e)}}),O=Object(d.b)({squaredDifferenceStrict_:function(t,e){Object(r.b)("strict variants of ops have been deprecated and will be removed in future");const n=Object(i.a)(t,"a","squaredDifferenceStrict"),a=Object(i.a)(e,"b","squaredDifferenceStrict");return s.e(n.shape,a.shape,"Error in squaredDifferenceStrict: "),Object(f.a)(n,a)}}),S=Object(d.b)({subStrict_:function(t,e){Object(r.b)("strict variants of ops have been deprecated and will be removed in future");const n=Object(i.a)(t,"a","subStrict"),a=Object(i.a)(e,"b","subStrict");return s.e(n.shape,a.shape,"Error in subStrict: "),Object(m.a)(n,a)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(5),i=n(3),s=n(1),a=n(4),o=n(121);const u=Object(a.b)({scatterND_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n){const a=Object(s.a)(t,"indices","scatterND","int32"),u=Object(s.a)(e,"updates","scatterND");o.validateInput(u,a,n);const c={indices:a,updates:u},l={shape:n};return r.a.runKernelFunc(t=>t.scatterND(a,u,n),c,null,i.qc,l)}})},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3),s=n(1),a=n(4);const o=Object(a.b)({gatherND_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e){const n=Object(s.a)(e,"indices","gatherND","int32"),a=Object(s.a)(t,"x","gatherND"),o={params:a,indices:n};return r.a.runKernelFunc(t=>t.gatherND(a,n),o,null,i.ib)}})},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return i}));
/**
 * @license
 * Copyright 2017 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:void 0!==t?t:t=>t();function i(){return new Promise(t=>r(()=>t()))}}).call(this,n(309).setImmediate)},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(313),e)},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.BinaryCounter=e.AuxiliaryInput=e.auxiliaryInputFromSpec=void 0;var s=n(36);e.auxiliaryInputFromSpec=function(t){switch(t.type){case"BinaryCounter":return new o(t.args);default:throw new Error("Unknown auxiliary input: "+t)}};var a=function(t){this.depth=t};e.AuxiliaryInput=a;var o=function(t){function e(e){return t.call(this,e.numBits)||this}return i(e,t),e.prototype.getTensors=function(t){for(var e=s.buffer([t,this.depth]),n=0;n<t;++n)for(var r=0;r<this.depth;++r)e.set(Math.floor((n+1)/Math.pow(2,r))%2?1:-1,n,r);return e.toTensor().as2D(t,this.depth)},e}(a);e.BinaryCounter=o},function(t,e,n){"use strict";t.exports=h;var r,i=n(110),s=i.LongBits,a=i.base64,o=i.utf8;function u(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}function c(){}function l(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function h(){this.len=0,this.head=new u(c,0,0),this.tail=this.head,this.states=null}var d=function(){return i.Buffer?function(){return(h.create=function(){return new r})()}:function(){return new h}};function p(t,e,n){e[n]=255&t}function f(t,e){this.len=t,this.next=void 0,this.val=e}function m(t,e,n){for(;t.hi;)e[n++]=127&t.lo|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[n++]=127&t.lo|128,t.lo=t.lo>>>7;e[n++]=t.lo}function g(t,e,n){e[n]=255&t,e[n+1]=t>>>8&255,e[n+2]=t>>>16&255,e[n+3]=t>>>24}h.create=d(),h.alloc=function(t){return new i.Array(t)},i.Array!==Array&&(h.alloc=i.pool(h.alloc,i.Array.prototype.subarray)),h.prototype._push=function(t,e,n){return this.tail=this.tail.next=new u(t,e,n),this.len+=e,this},f.prototype=Object.create(u.prototype),f.prototype.fn=function(t,e,n){for(;t>127;)e[n++]=127&t|128,t>>>=7;e[n]=t},h.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new f((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this},h.prototype.int32=function(t){return t<0?this._push(m,10,s.fromNumber(t)):this.uint32(t)},h.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},h.prototype.uint64=function(t){var e=s.from(t);return this._push(m,e.length(),e)},h.prototype.int64=h.prototype.uint64,h.prototype.sint64=function(t){var e=s.from(t).zzEncode();return this._push(m,e.length(),e)},h.prototype.bool=function(t){return this._push(p,1,t?1:0)},h.prototype.fixed32=function(t){return this._push(g,4,t>>>0)},h.prototype.sfixed32=h.prototype.fixed32,h.prototype.fixed64=function(t){var e=s.from(t);return this._push(g,4,e.lo)._push(g,4,e.hi)},h.prototype.sfixed64=h.prototype.fixed64,h.prototype.float=function(t){return this._push(i.float.writeFloatLE,4,t)},h.prototype.double=function(t){return this._push(i.float.writeDoubleLE,8,t)};var b=i.Array.prototype.set?function(t,e,n){e.set(t,n)}:function(t,e,n){for(var r=0;r<t.length;++r)e[n+r]=t[r]};h.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(p,1,0);if(i.isString(t)){var n=h.alloc(e=a.length(t));a.decode(t,n,0),t=n}return this.uint32(e)._push(b,e,t)},h.prototype.string=function(t){var e=o.length(t);return e?this.uint32(e)._push(o.write,e,t):this._push(p,1,0)},h.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new u(c,0,0),this.len=0,this},h.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new u(c,0,0),this.len=0),this},h.prototype.ldelim=function(){var t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=e,this.len+=n),this},h.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e},h._configure=function(t){r=t,h.create=d(),r._configure()}},function(t,e,n){"use strict";t.exports=u;var r,i=n(110),s=i.LongBits,a=i.utf8;function o(t,e){return RangeError("index out of range: "+t.pos+" + "+(e||1)+" > "+t.len)}function u(t){this.buf=t,this.pos=0,this.len=t.length}var c,l="undefined"!=typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new u(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new u(t);throw Error("illegal buffer")},h=function(){return i.Buffer?function(t){return(u.create=function(t){return i.Buffer.isBuffer(t)?new r(t):l(t)})(t)}:l};function d(){var t=new s(0,0),e=0;if(!(this.len-this.pos>4)){for(;e<3;++e){if(this.pos>=this.len)throw o(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(127&this.buf[this.pos++])<<7*e)>>>0,t}for(;e<4;++e)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t;if(e=0,this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw o(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function p(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}function f(){if(this.pos+8>this.len)throw o(this,8);return new s(p(this.buf,this.pos+=4),p(this.buf,this.pos+=4))}u.create=h(),u.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,u.prototype.uint32=(c=4294967295,function(){if(c=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return c;if((this.pos+=5)>this.len)throw this.pos=this.len,o(this,10);return c}),u.prototype.int32=function(){return 0|this.uint32()},u.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},u.prototype.bool=function(){return 0!==this.uint32()},u.prototype.fixed32=function(){if(this.pos+4>this.len)throw o(this,4);return p(this.buf,this.pos+=4)},u.prototype.sfixed32=function(){if(this.pos+4>this.len)throw o(this,4);return 0|p(this.buf,this.pos+=4)},u.prototype.float=function(){if(this.pos+4>this.len)throw o(this,4);var t=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},u.prototype.double=function(){if(this.pos+8>this.len)throw o(this,4);var t=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},u.prototype.bytes=function(){var t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw o(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(e,n):e===n?new this.buf.constructor(0):this._slice.call(this.buf,e,n)},u.prototype.string=function(){var t=this.bytes();return a.read(t,0,t.length)},u.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw o(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw o(this)}while(128&this.buf[this.pos++]);return this},u.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(t=7&this.uint32());)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},u._configure=function(t){r=t,u.create=h(),r._configure();var e=i.Long?"toLong":"toNumber";i.merge(u.prototype,{int64:function(){return d.call(this)[e](!1)},uint64:function(){return d.call(this)[e](!0)},sint64:function(){return d.call(this).zzDecode()[e](!1)},fixed64:function(){return f.call(this)[e](!0)},sfixed64:function(){return f.call(this)[e](!1)}})}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MelodyRegister=e.MelodyShape=e.MelodyRhythm=e.Melody=e.NOTE_OFF=e.NO_EVENT=void 0;var r=n(36),i=n(79),s=n(92);e.NO_EVENT=0,e.NOTE_OFF=1;var a=function(){function t(t,e,n){this.events=t,this.minPitch=e,this.maxPitch=n}return t.fromNoteSequence=function(n,r,i,a,o){void 0===a&&(a=!0),s.assertIsQuantizedSequence(n);var u=n.notes.sort((function(t,e){return t.quantizedStartStep===e.quantizedStartStep?e.pitch-t.pitch:t.quantizedStartStep-e.quantizedStartStep})),c=new Int32Array(o||n.totalQuantizedSteps),l=-1;return u.forEach((function(t){if(t.quantizedStartStep===l){if(a)return;throw new Error("`NoteSequence` is not monophonic.")}if(t.pitch<r||t.pitch>i)throw Error("`NoteSequence` has a pitch outside of the valid range: "+t.pitch);c[t.quantizedStartStep]=t.pitch-r+2,c[t.quantizedEndStep]=e.NOTE_OFF,l=t.quantizedStartStep})),new t(c,r,i)},t.prototype.toNoteSequence=function(t,n){for(var r=s.createQuantizedNoteSequence(t,n),a=null,o=0;o<this.events.length;++o){var u=this.events[o];switch(u){case e.NO_EVENT:break;case e.NOTE_OFF:a&&(a.quantizedEndStep=o,r.notes.push(a),a=null);break;default:a&&(a.quantizedEndStep=o,r.notes.push(a)),a=i.NoteSequence.Note.create({pitch:u-2+this.minPitch,quantizedStartStep:o})}}return a&&(a.quantizedEndStep=this.events.length,r.notes.push(a)),r.totalQuantizedSteps=this.events.length,r},t}();e.Melody=a;var o=function(){function t(){this.depth=1}return t.prototype.extract=function(t){for(var e=t.events.length,n=r.buffer([e,1]),i=0;i<e;++i)n.set(t.events[i]>=2?1:0,i,0);return n.toTensor().as2D(e,1)},t}();e.MelodyRhythm=o;var u=function(){function t(){this.depth=3}return t.prototype.extract=function(t){for(var e=t.events.length,n=r.buffer([e,3]),i=null,s=null,a=0;a<e;++a)if(t.events[a]>=2){if(null!==i){0===n.get(i,0)&&0===n.get(i,1)&&0===n.get(i,2)&&(i=-1);var o=void 0;o=t.events[a]<s?0:t.events[a]>s?2:1;for(var u=a;u>i;--u)n.set(1,u,o)}i=a,s=t.events[a]}if(i!==e-1)if(null===i||0===n.get(i,0)&&0===n.get(i,1)&&0===n.get(i,2))for(u=0;u<e;++u)n.set(1,u,1);else for(u=e-1;u>i;--u)for(var c=0;c<3;c++)n.set(n.get(i,c),u,c);return n.toTensor().as2D(e,3)},t}();e.MelodyShape=u;var c=function(){function t(t){this.boundaryPitches=t,this.depth=t.length+1}return t.prototype.meanMelodyPitch=function(t){for(var n=0,r=0,i=null,s=0;s<t.events.length;++s)t.events[s]===e.NOTE_OFF?i=null:t.events[s]>=2&&(i=t.minPitch+t.events[s]-2),null!==i&&(n+=i,r+=1);return r?n/r:null},t.prototype.extract=function(t){var e=t.events.length,n=this.meanMelodyPitch(t);if(null===n)return r.zeros([e,this.depth]);for(var i=0;i<this.boundaryPitches.length&&n>=this.boundaryPitches[i];)i++;for(var s=r.buffer([e,this.depth]),a=0;a<e;++a)s.set(1,a,i);return s.toTensor().as2D(e,this.depth)},t}();e.MelodyRegister=c},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Performance=void 0;var r=n(79),i=n(67),s=n(92),a=n(55),o=function(){function t(t,e,n,r,i){this.events=t,this.maxShiftSteps=e,this.numVelocityBins=n,this.program=r,this.isDrum=i}return t.fromNoteSequence=function(e,n,r,a){s.assertIsQuantizedSequence(e);for(var o=e.notes.filter((function(t,e){return void 0===a||t.instrument===a})),u=o.sort((function(t,e){return t.startTime===e.startTime?t.pitch-e.pitch:t.startTime-e.startTime})),c=u.map((function(t,e){return{step:t.quantizedStartStep,index:e,isOffset:0}})),l=u.map((function(t,e){return{step:t.quantizedEndStep,index:e,isOffset:1}})),h=c.concat(l).sort((function(t,e){return t.step===e.step?t.index===e.index?t.isOffset-e.isOffset:t.index-e.index:t.step-e.step})),d=r?Math.ceil((i.MIDI_VELOCITIES-1)/r):void 0,p=[],f=0,m=r,g=0,b=h;g<b.length;g++){var y=b[g];if(y.step>f){for(;y.step>f+n;)p.push({type:"time-shift",steps:n}),f+=n;p.push({type:"time-shift",steps:y.step-f}),f=y.step}if(y.isOffset)p.push({type:"note-off",pitch:u[y.index].pitch});else{if(d){var v=Math.floor((u[y.index].velocity-i.MIN_MIDI_VELOCITY-1)/d)+1;v!==m&&(p.push({type:"velocity-change",velocityBin:v}),m=v)}p.push({type:"note-on",pitch:u[y.index].pitch})}}var w=!!o.some((function(t){return t.isDrum}))&&(!o.some((function(t){return!t.isDrum}))||void 0),x=Array.from(new Set(o.map((function(t){return t.program})))),_=new t(p,n,r,w||1!==x.length?void 0:x[0],w);return _.setNumSteps(e.totalQuantizedSteps),_},t.prototype.getNumSteps=function(){return this.events.filter((function(t){return"time-shift"===t.type})).map((function(t){return t.steps})).reduce((function(t,e){return t+e}),0)},t.prototype.setNumSteps=function(t){var e=this.getNumSteps();if(e<t){if(this.events.length){var n=this.events[this.events.length-1];if("time-shift"===n.type){var r=Math.min(t-e,this.maxShiftSteps-n.steps);n.steps+=r,e+=r}}for(;e<t;)e+this.maxShiftSteps>t?(this.events.push({type:"time-shift",steps:t-e}),e=t):(this.events.push({type:"time-shift",steps:this.maxShiftSteps}),e+=this.maxShiftSteps)}else if(e>t)for(;this.events.length&&e>t;){var i=this.events[this.events.length-1];"time-shift"===i.type?e-i.steps<t?(i.steps-=e-t,e=t):(this.events.pop(),e-=i.steps):this.events.pop()}},t.prototype.toNoteSequence=function(t){for(var e=this,n=this.numVelocityBins?Math.ceil((i.MIDI_VELOCITIES-1)/this.numVelocityBins):void 0,s=r.NoteSequence.create(),o=0,u=void 0,c=new Map,l=i.MIN_MIDI_PITCH;l<=i.MAX_MIDI_PITCH;++l)c.set(l,[]);for(var h=0,d=this.events;h<d.length;h++){var p=d[h];switch(p.type){case"note-on":c.get(p.pitch).push([o,u]);break;case"note-off":var f=c.get(p.pitch);if(f.length){var m=f.shift(),g=m[0],b=m[1];o>g?s.notes.push(r.NoteSequence.Note.create({pitch:p.pitch,velocity:b,instrument:t,quantizedStartStep:g,quantizedEndStep:o,program:this.program,isDrum:this.isDrum})):a.log("Ignoring zero-length note: (pitch = "+p.pitch+", step = "+o+")","Performance")}else a.log("Ignoring note-off with no previous note-on:(pitch = "+p.pitch+", step = "+o+")","Performance");break;case"time-shift":o+=p.steps;break;case"velocity-change":if(!n)throw new Error("Unexpected velocity change event: "+p);u=i.MIN_MIDI_VELOCITY+(p.velocityBin-1)*n+1;break;default:throw new Error("Unrecognized performance event: "+p)}}return c.forEach((function(n,i){for(var u=0,c=n;u<c.length;u++){var l=c[u],h=l[0],d=l[1];o>h?s.notes.push(r.NoteSequence.Note.create({pitch:i,velocity:d,instrument:t,quantizedStartStep:h,quantizedEndStep:o,program:e.program,isDrum:e.isDrum})):a.log("Ignoring zero-length note: (pitch = "+i+", step = "+o+")","Performance")}})),s.totalQuantizedSteps=o,s},t}();e.Performance=o},function(t,e,n){e.parseMidi=n(341),e.writeMidi=n(342)},function(t,e,n){"use strict";function r(t,e,n){void 0===n&&(n="ticks");var r=0,i=t.length,s=i;if(i>0&&t[i-1][n]<=e)return i-1;for(;r<s;){var a=Math.floor(r+(s-r)/2),o=t[a],u=t[a+1];if(o[n]===e){for(var c=a;c<t.length;c++){t[c][n]===e&&(a=c)}return a}if(o[n]<e&&u[n]>e)return a;o[n]>e?s=a:o[n]<e&&(r=a+1)}return-1}Object.defineProperty(e,"__esModule",{value:!0}),e.search=r,e.insert=function(t,e,n){if(void 0===n&&(n="ticks"),t.length){var i=r(t,e[n],n);t.splice(i+1,0,e)}else t.push(e)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(261),i=n(263),s=n(345),a=n(346),o=n(347),u=n(349),c=new WeakMap,l=function(){function t(t,e){var n=this;if(this.name="",this.notes=[],this.controlChanges=s.createControlChanges(),this.pitchBends=[],c.set(this,e),t){var r=t.find((function(t){return"trackName"===t.type}));this.name=r?r.text:""}if(this.instrument=new o.Instrument(t,this),this.channel=0,t){for(var i=t.filter((function(t){return"noteOn"===t.type})),a=t.filter((function(t){return"noteOff"===t.type})),u=function(){var t=i.shift();l.channel=t.channel;var e=a.findIndex((function(e){return e.noteNumber===t.noteNumber&&e.absoluteTime>=t.absoluteTime}));if(-1!==e){var n=a.splice(e,1)[0];l.addNote({durationTicks:n.absoluteTime-t.absoluteTime,midi:t.noteNumber,noteOffVelocity:n.velocity/127,ticks:t.absoluteTime,velocity:t.velocity/127})}},l=this;i.length;)u();t.filter((function(t){return"controller"===t.type})).forEach((function(t){n.addCC({number:t.controllerType,ticks:t.absoluteTime,value:t.value/127})})),t.filter((function(t){return"pitchBend"===t.type})).forEach((function(t){n.addPitchBend({ticks:t.absoluteTime,value:t.value/Math.pow(2,13)})}))}}return t.prototype.addNote=function(t){var e=c.get(this),n=new u.Note({midi:0,ticks:0,velocity:1},{ticks:0,velocity:0},e);return Object.assign(n,t),r.insert(this.notes,n,"ticks"),this},t.prototype.addCC=function(t){var e=c.get(this),n=new i.ControlChange({controllerType:t.number},e);return delete t.number,Object.assign(n,t),Array.isArray(this.controlChanges[n.number])||(this.controlChanges[n.number]=[]),r.insert(this.controlChanges[n.number],n,"ticks"),this},t.prototype.addPitchBend=function(t){var e=c.get(this),n=new a.PitchBend({},e);return Object.assign(n,t),r.insert(this.pitchBends,n,"ticks"),this},Object.defineProperty(t.prototype,"duration",{get:function(){if(!this.notes.length)return 0;for(var t=this.notes[this.notes.length-1].time+this.notes[this.notes.length-1].duration,e=0;e<this.notes.length-1;e++){var n=this.notes[e].time+this.notes[e].duration;t<n&&(t=n)}return t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"durationTicks",{get:function(){if(!this.notes.length)return 0;for(var t=this.notes[this.notes.length-1].ticks+this.notes[this.notes.length-1].durationTicks,e=0;e<this.notes.length-1;e++){var n=this.notes[e].ticks+this.notes[e].durationTicks;t<n&&(t=n)}return t},enumerable:!0,configurable:!0}),t.prototype.fromJSON=function(t){var e=this;for(var n in this.name=t.name,this.channel=t.channel,this.instrument=new o.Instrument(void 0,this),this.instrument.fromJSON(t.instrument),t.controlChanges)t.controlChanges[n]&&t.controlChanges[n].forEach((function(t){e.addCC({number:t.number,ticks:t.ticks,value:t.value})}));t.notes.forEach((function(t){e.addNote({durationTicks:t.durationTicks,midi:t.midi,ticks:t.ticks,velocity:t.velocity})}))},t.prototype.toJSON=function(){for(var t={},e=0;e<127;e++)this.controlChanges.hasOwnProperty(e)&&(t[e]=this.controlChanges[e].map((function(t){return t.toJSON()})));return{channel:this.channel,controlChanges:t,pitchBends:this.pitchBends.map((function(t){return t.toJSON()})),instrument:this.instrument.toJSON(),name:this.name,notes:this.notes.map((function(t){return t.toJSON()}))}},t}();e.Track=l},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.controlChangeNames={1:"modulationWheel",2:"breath",4:"footController",5:"portamentoTime",7:"volume",8:"balance",10:"pan",64:"sustain",65:"portamentoTime",66:"sostenuto",67:"softPedal",68:"legatoFootswitch",84:"portamentoControl"},e.controlChangeIds=Object.keys(e.controlChangeNames).reduce((function(t,n){return t[e.controlChangeNames[n]]=n,t}),{});var r=new WeakMap,i=new WeakMap,s=function(){function t(t,e){r.set(this,e),i.set(this,t.controllerType),this.ticks=t.absoluteTime,this.value=t.value}return Object.defineProperty(t.prototype,"number",{get:function(){return i.get(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return e.controlChangeNames[this.number]?e.controlChangeNames[this.number]:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"time",{get:function(){return r.get(this).ticksToSeconds(this.ticks)},set:function(t){var e=r.get(this);this.ticks=e.secondsToTicks(t)},enumerable:!0,configurable:!0}),t.prototype.toJSON=function(){return{number:this.number,ticks:this.ticks,time:this.time,value:this.value}},t}();e.ControlChange=s},function(t,e,n){"use strict";function r(t){if(this.size=0|t,this.size<=1||0!=(this.size&this.size-1))throw new Error("FFT size must be a power of two and bigger than 1");this._csize=t<<1;for(var e=new Array(2*this.size),n=0;n<e.length;n+=2){const t=Math.PI*n/this.size;e[n]=Math.cos(t),e[n+1]=-Math.sin(t)}this.table=e;for(var r=0,i=1;this.size>i;i<<=1)r++;this._width=r%2==0?r-1:r,this._bitrev=new Array(1<<this._width);for(var s=0;s<this._bitrev.length;s++){this._bitrev[s]=0;for(var a=0;a<this._width;a+=2){var o=this._width-a-2;this._bitrev[s]|=(s>>>a&3)<<o}}this._out=null,this._data=null,this._inv=0}t.exports=r,r.prototype.fromComplexArray=function(t,e){for(var n=e||new Array(t.length>>>1),r=0;r<t.length;r+=2)n[r>>>1]=t[r];return n},r.prototype.createComplexArray=function(){const t=new Array(this._csize);for(var e=0;e<t.length;e++)t[e]=0;return t},r.prototype.toComplexArray=function(t,e){for(var n=e||this.createComplexArray(),r=0;r<n.length;r+=2)n[r]=t[r>>>1],n[r+1]=0;return n},r.prototype.completeSpectrum=function(t){for(var e=this._csize,n=e>>>1,r=2;r<n;r+=2)t[e-r]=t[r],t[e-r+1]=-t[r+1]},r.prototype.transform=function(t,e){if(t===e)throw new Error("Input and output buffers must be different");this._out=t,this._data=e,this._inv=0,this._transform4(),this._out=null,this._data=null},r.prototype.realTransform=function(t,e){if(t===e)throw new Error("Input and output buffers must be different");this._out=t,this._data=e,this._inv=0,this._realTransform4(),this._out=null,this._data=null},r.prototype.inverseTransform=function(t,e){if(t===e)throw new Error("Input and output buffers must be different");this._out=t,this._data=e,this._inv=1,this._transform4();for(var n=0;n<t.length;n++)t[n]/=this.size;this._out=null,this._data=null},r.prototype._transform4=function(){var t,e,n=this._out,r=this._csize,i=1<<this._width,s=r/i<<1,a=this._bitrev;if(4===s)for(t=0,e=0;t<r;t+=s,e++){const n=a[e];this._singleTransform2(t,n,i)}else for(t=0,e=0;t<r;t+=s,e++){const n=a[e];this._singleTransform4(t,n,i)}var o=this._inv?-1:1,u=this.table;for(i>>=2;i>=2;i>>=2){var c=(s=r/i<<1)>>>2;for(t=0;t<r;t+=s)for(var l=t+c,h=t,d=0;h<l;h+=2,d+=i){const t=h,e=t+c,r=e+c,i=r+c,s=n[t],a=n[t+1],l=n[e],p=n[e+1],f=n[r],m=n[r+1],g=n[i],b=n[i+1],y=s,v=a,w=u[d],x=o*u[d+1],_=l*w-p*x,O=l*x+p*w,S=u[2*d],k=o*u[2*d+1],T=f*S-m*k,C=f*k+m*S,A=u[3*d],N=o*u[3*d+1],I=g*A-b*N,E=g*N+b*A,j=y+T,M=v+C,D=y-T,R=v-C,P=_+I,F=O+E,z=o*(_-I),L=o*(O-E),$=j+P,B=M+F,q=j-P,V=M-F,U=D+L,W=R-z,G=D-L,H=R+z;n[t]=$,n[t+1]=B,n[e]=U,n[e+1]=W,n[r]=q,n[r+1]=V,n[i]=G,n[i+1]=H}}},r.prototype._singleTransform2=function(t,e,n){const r=this._out,i=this._data,s=i[e],a=i[e+1],o=i[e+n],u=i[e+n+1],c=s+o,l=a+u,h=s-o,d=a-u;r[t]=c,r[t+1]=l,r[t+2]=h,r[t+3]=d},r.prototype._singleTransform4=function(t,e,n){const r=this._out,i=this._data,s=this._inv?-1:1,a=2*n,o=3*n,u=i[e],c=i[e+1],l=i[e+n],h=i[e+n+1],d=i[e+a],p=i[e+a+1],f=i[e+o],m=i[e+o+1],g=u+d,b=c+p,y=u-d,v=c-p,w=l+f,x=h+m,_=s*(l-f),O=s*(h-m),S=g+w,k=b+x,T=y+O,C=v-_,A=g-w,N=b-x,I=y-O,E=v+_;r[t]=S,r[t+1]=k,r[t+2]=T,r[t+3]=C,r[t+4]=A,r[t+5]=N,r[t+6]=I,r[t+7]=E},r.prototype._realTransform4=function(){var t,e,n=this._out,r=this._csize,i=1<<this._width,s=r/i<<1,a=this._bitrev;if(4===s)for(t=0,e=0;t<r;t+=s,e++){const n=a[e];this._singleRealTransform2(t,n>>>1,i>>>1)}else for(t=0,e=0;t<r;t+=s,e++){const n=a[e];this._singleRealTransform4(t,n>>>1,i>>>1)}var o=this._inv?-1:1,u=this.table;for(i>>=2;i>=2;i>>=2){var c=(s=r/i<<1)>>>1,l=c>>>1,h=l>>>1;for(t=0;t<r;t+=s)for(var d=0,p=0;d<=h;d+=2,p+=i){var f=t+d,m=f+l,g=m+l,b=g+l,y=n[f],v=n[f+1],w=n[m],x=n[m+1],_=n[g],O=n[g+1],S=n[b],k=n[b+1],T=y,C=v,A=u[p],N=o*u[p+1],I=w*A-x*N,E=w*N+x*A,j=u[2*p],M=o*u[2*p+1],D=_*j-O*M,R=_*M+O*j,P=u[3*p],F=o*u[3*p+1],z=S*P-k*F,L=S*F+k*P,$=T+D,B=C+R,q=T-D,V=C-R,U=I+z,W=E+L,G=o*(I-z),H=o*(E-L),K=$+U,Q=B+W,X=q+H,Y=V-G;if(n[f]=K,n[f+1]=Q,n[m]=X,n[m+1]=Y,0!==d){if(d!==h){var J=q+-o*H,Z=-V+-o*G,tt=$+-o*U,et=-B- -o*W,nt=t+l-d,rt=t+c-d;n[nt]=J,n[nt+1]=Z,n[rt]=tt,n[rt+1]=et}}else{var it=$-U,st=B-W;n[g]=it,n[g+1]=st}}}},r.prototype._singleRealTransform2=function(t,e,n){const r=this._out,i=this._data,s=i[e],a=i[e+n],o=s+a,u=s-a;r[t]=o,r[t+1]=0,r[t+2]=u,r[t+3]=0},r.prototype._singleRealTransform4=function(t,e,n){const r=this._out,i=this._data,s=this._inv?-1:1,a=2*n,o=3*n,u=i[e],c=i[e+n],l=i[e+a],h=i[e+o],d=u+l,p=u-l,f=c+h,m=s*(c-h),g=d+f,b=p,y=-m,v=d-f,w=p,x=m;r[t]=g,r[t+1]=0,r[t+2]=b,r[t+3]=y,r[t+4]=v,r[t+5]=0,r[t+6]=w,r[t+7]=x}},function(t,e,n){"use strict";var r=n(378);function i(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}t.exports=function(t){var e=new i;e.pre=t.pre,e.body=t.body,e.post=t.post;var n=t.args.slice(0);e.argTypes=n;for(var s=0;s<n.length;++s){var a=n[s];if("array"===a||"object"==typeof a&&a.blockIndices){if(e.argTypes[s]="array",e.arrayArgs.push(s),e.arrayBlockIndices.push(a.blockIndices?a.blockIndices:0),e.shimArgs.push("array"+s),s<e.pre.args.length&&e.pre.args[s].count>0)throw new Error("cwise: pre() block may not reference array args");if(s<e.post.args.length&&e.post.args[s].count>0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===a)e.scalarArgs.push(s),e.shimArgs.push("scalar"+s);else if("index"===a){if(e.indexArgs.push(s),s<e.pre.args.length&&e.pre.args[s].count>0)throw new Error("cwise: pre() block may not reference array index");if(s<e.body.args.length&&e.body.args[s].lvalue)throw new Error("cwise: body() block may not write to array index");if(s<e.post.args.length&&e.post.args[s].count>0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===a){if(e.shapeArgs.push(s),s<e.pre.args.length&&e.pre.args[s].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(s<e.body.args.length&&e.body.args[s].lvalue)throw new Error("cwise: body() block may not write to array shape");if(s<e.post.args.length&&e.post.args[s].lvalue)throw new Error("cwise: post() block may not write to array shape")}else{if("object"!=typeof a||!a.offset)throw new Error("cwise: Unknown argument type "+n[s]);e.argTypes[s]="offset",e.offsetArgs.push({array:a.array,offset:a.offset}),e.offsetArgIndex.push(s)}}if(e.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(e.pre.args.length>n.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>n.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>n.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,r(e)}},function(t,e,n){"use strict";t.exports=function(t,e,n){return 0===t.length?t:e?(n||t.sort(e),function(t,e){for(var n=1,r=t.length,i=t[0],s=t[0],a=1;a<r;++a)if(s=i,e(i=t[a],s)){if(a===n){n++;continue}t[n++]=i}return t.length=n,t}(t,e)):(n||t.sort(),function(t){for(var e=1,n=t.length,r=t[0],i=t[0],s=1;s<n;++s,i=r)if(i=r,(r=t[s])!==i){if(s===e){e++;continue}t[e++]=r}return t.length=e,t}(t))}},function(t,e,n){"use strict";(function(t){var r=n(268),i=n(380),s=n(155).Buffer;t.__TYPEDARRAY_POOL||(t.__TYPEDARRAY_POOL={UINT8:i([32,0]),UINT16:i([32,0]),UINT32:i([32,0]),BIGUINT64:i([32,0]),INT8:i([32,0]),INT16:i([32,0]),INT32:i([32,0]),BIGINT64:i([32,0]),FLOAT:i([32,0]),DOUBLE:i([32,0]),DATA:i([32,0]),UINT8C:i([32,0]),BUFFER:i([32,0])});var a="undefined"!=typeof Uint8ClampedArray,o="undefined"!=typeof BigUint64Array,u="undefined"!=typeof BigInt64Array,c=t.__TYPEDARRAY_POOL;c.UINT8C||(c.UINT8C=i([32,0])),c.BIGUINT64||(c.BIGUINT64=i([32,0])),c.BIGINT64||(c.BIGINT64=i([32,0])),c.BUFFER||(c.BUFFER=i([32,0]));var l=c.DATA,h=c.BUFFER;function d(t){if(t){var e=t.length||t.byteLength,n=r.log2(e);l[n].push(t)}}function p(t){t=r.nextPow2(t);var e=r.log2(t),n=l[e];return n.length>0?n.pop():new ArrayBuffer(t)}function f(t){return new Uint8Array(p(t),0,t)}function m(t){return new Uint16Array(p(2*t),0,t)}function g(t){return new Uint32Array(p(4*t),0,t)}function b(t){return new Int8Array(p(t),0,t)}function y(t){return new Int16Array(p(2*t),0,t)}function v(t){return new Int32Array(p(4*t),0,t)}function w(t){return new Float32Array(p(4*t),0,t)}function x(t){return new Float64Array(p(8*t),0,t)}function _(t){return a?new Uint8ClampedArray(p(t),0,t):f(t)}function O(t){return o?new BigUint64Array(p(8*t),0,t):null}function S(t){return u?new BigInt64Array(p(8*t),0,t):null}function k(t){return new DataView(p(t),0,t)}function T(t){t=r.nextPow2(t);var e=r.log2(t),n=h[e];return n.length>0?n.pop():new s(t)}e.free=function(t){if(s.isBuffer(t))h[r.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,n=0|r.log2(e);l[n].push(t)}},e.freeUint8=e.freeUint16=e.freeUint32=e.freeBigUint64=e.freeInt8=e.freeInt16=e.freeInt32=e.freeBigInt64=e.freeFloat32=e.freeFloat=e.freeFloat64=e.freeDouble=e.freeUint8Clamped=e.freeDataView=function(t){d(t.buffer)},e.freeArrayBuffer=d,e.freeBuffer=function(t){h[r.log2(t.length)].push(t)},e.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return p(t);switch(e){case"uint8":return f(t);case"uint16":return m(t);case"uint32":return g(t);case"int8":return b(t);case"int16":return y(t);case"int32":return v(t);case"float":case"float32":return w(t);case"double":case"float64":return x(t);case"uint8_clamped":return _(t);case"bigint64":return S(t);case"biguint64":return O(t);case"buffer":return T(t);case"data":case"dataview":return k(t);default:return null}return null},e.mallocArrayBuffer=p,e.mallocUint8=f,e.mallocUint16=m,e.mallocUint32=g,e.mallocInt8=b,e.mallocInt16=y,e.mallocInt32=v,e.mallocFloat32=e.mallocFloat=w,e.mallocFloat64=e.mallocDouble=x,e.mallocUint8Clamped=_,e.mallocBigUint64=O,e.mallocBigInt64=S,e.mallocDataView=k,e.mallocBuffer=T,e.clearCache=function(){for(var t=0;t<32;++t)c.UINT8[t].length=0,c.UINT16[t].length=0,c.UINT32[t].length=0,c.INT8[t].length=0,c.INT16[t].length=0,c.INT32[t].length=0,c.FLOAT[t].length=0,c.DOUBLE[t].length=0,c.BIGUINT64[t].length=0,c.BIGINT64[t].length=0,c.UINT8C[t].length=0,l[t].length=0,h[t].length=0}}).call(this,n(96))},function(t,e,n){"use strict";function r(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}e.INT_BITS=32,e.INT_MAX=2147483647,e.INT_MIN=-1<<31,e.sign=function(t){return(t>0)-(t<0)},e.abs=function(t){var e=t>>31;return(t^e)-e},e.min=function(t,e){return e^(t^e)&-(t<e)},e.max=function(t,e){return t^(t^e)&-(t<e)},e.isPow2=function(t){return!(t&t-1||!t)},e.log2=function(t){var e,n;return e=(t>65535)<<4,e|=n=((t>>>=e)>255)<<3,e|=n=((t>>>=n)>15)<<2,(e|=n=((t>>>=n)>3)<<1)|(t>>>=n)>>1},e.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},e.popCount=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},e.countTrailingZeros=r,e.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},e.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},e.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var i=new Array(256);!function(t){for(var e=0;e<256;++e){var n=e,r=e,i=7;for(n>>>=1;n;n>>>=1)r<<=1,r|=1&n,--i;t[e]=r<<i&255}}(i),e.reverse=function(t){return i[255&t]<<24|i[t>>>8&255]<<16|i[t>>>16&255]<<8|i[t>>>24&255]},e.interleave2=function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},e.deinterleave2=function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},e.interleave3=function(t,e,n){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(n=1227133513&((n=3272356035&((n=251719695&((n=4278190335&((n&=1023)|n<<16))|n<<8))|n<<4))|n<<2))<<2},e.deinterleave3=function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},e.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>r(t)+1}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sliceAudioBuffer=e.arrayBufferToAudioBuffer=void 0,e.arrayBufferToAudioBuffer=function(t,e,n){var r=t.createBuffer(1,e.length,n);return r.copyToChannel(e,0),r},e.sliceAudioBuffer=function(t,e,n,r,i){void 0===n&&(n=0),void 0===r&&(r=e.length);for(var s=t.createBuffer(e.numberOfChannels,r-n,i),a=0;a<e.numberOfChannels;a++)s.copyToChannel(e.getChannelData(a).slice(n,r),a);return s}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONF_THRESHOLD=e.PITCHES_HOP=e.CONF_SMOOTH_SIZE=e.LD_CONF_REDUCTION=e.OUTPUT_SAMPLE_RATE=e.CROSSFADE_DURATION=e.LOWEST_LD=e.MIN_VRAM=void 0,e.MIN_VRAM=50,e.LOWEST_LD=-120,e.CROSSFADE_DURATION=1,e.OUTPUT_SAMPLE_RATE=48e3,e.LD_CONF_REDUCTION=-25,e.CONF_SMOOTH_SIZE=100,e.PITCHES_HOP=8192,e.CONF_THRESHOLD=.7},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(5),i=n(3);var s=n(1),a=n(4);const o=Object(a.b)({sparseToDense_:
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
function(t,e,n,a=0){const o=Object(s.a)(t,"sparseIndices","sparseToDense","int32"),u=Object(s.a)(e,"sparseValues","sparseToDense"),c=Object(s.a)(a,"defaultValue","sparseToDense",u.dtype);!function(t,e,n,r){if("int32"!==t.dtype)throw new Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.rank>2)throw new Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${t.shape}.`);const i=t.rank>0?t.shape[0]:1,s=t.rank>1?t.shape[1]:1;if(n.length!==s)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${s}.`);const a=e.size;if(0!==e.rank&&(1!==e.rank||a!==i))throw new Error(`sparseValues has incorrect shape ${e.shape}, should be [] or [${i}]`);if(e.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(o,u,n,c);const l={sparseIndices:o,sparseValues:u,defaultValue:c},h={outputShape:n};return r.a.runKernelFunc(t=>t.sparseToDense(o,u,n,c),l,null,i.Bc,h)}})},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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}]},{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"}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}]},{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}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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"}],attrs:[{tfName:"clip_value_min",name:"clipValueMin",type:"number"},{tfName:"clip_value_max",name:"clipValueMax",type:"number"}]},{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},{tfName:"clipValueMin",name:"clipValueMin",type:"number",defaultValue:0},{tfName:"clipValueMax",name:"clipValueMax",type:"number",defaultValue:6}]},{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}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));const r=[{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:"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"}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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:"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}]},{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:[]}]},{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:[]}]},{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"}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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",notSupported:!0}]},{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:"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"}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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:"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"}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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"}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));const r=[{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}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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:"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:"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"}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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:"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}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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:"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"}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{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",notSupported:!0}]},{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}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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}]}]},function(t,e,n){"use strict";n.r(e),n.d(e,"json",(function(){return r}));
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
const r=[{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:[]}]},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return a}));var r=n(0),i=n(43),s=n(290);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */
class a extends i.a{decodeUTF8(){return new o(this)}}class o extends s.a{constructor(t){super(),this.upstream=t,this.impl=new u(t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class u extends i.b{constructor(t){if(super(),this.upstream=t,Object(r.env)().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{const{StringDecoder:t}=n(311);this.decoder=new t("utf8")}}summary(){return this.upstream.summary()+" -> Utf8"}async pump(){const e=await this.upstream.next();let n,i;return!e.done&&(n=e.value,i=Object(r.env)().get("IS_BROWSER")?this.decoder.decode(n,{stream:!0}):this.decoder.write(t.from(n.buffer)),this.outputQueue.push(i),!0)}}}).call(this,n(155).Buffer)},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(43);
/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * =============================================================================
 */class i extends r.a{split(t){return new s(this,t)}}class s extends i{constructor(t,e){super(),this.upstream=t,this.impl=new a(t,e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class a extends r.b{constructor(t,e){super(),this.upstream=t,this.separator=e,this.carryover=""}summary(){return`${this.upstream.summary()} -> Split('${this.separator}')`}async pump(){const t=await this.upstream.next();if(t.done)return""!==this.carryover&&(this.outputQueue.push(this.carryover),this.carryover="",!0);const e=t.value.split(this.separator);e[0]=this.carryover+e[0];for(const t of e.slice(0,-1))this.outputQueue.push(t);return this.carryover=e[e.length-1],!0}}},function(t){t.exports=JSON.parse('{"chromatic":["1P 2m 2M 3m 3M 4P 4A 5P 6m 6M 7m 7M"],"lydian":["1P 2M 3M 4A 5P 6M 7M"],"major":["1P 2M 3M 4P 5P 6M 7M",["ionian"]],"mixolydian":["1P 2M 3M 4P 5P 6M 7m",["dominant"]],"dorian":["1P 2M 3m 4P 5P 6M 7m"],"aeolian":["1P 2M 3m 4P 5P 6m 7m",["minor"]],"phrygian":["1P 2m 3m 4P 5P 6m 7m"],"locrian":["1P 2m 3m 4P 5d 6m 7m"],"melodic minor":["1P 2M 3m 4P 5P 6M 7M"],"melodic minor second mode":["1P 2m 3m 4P 5P 6M 7m"],"lydian augmented":["1P 2M 3M 4A 5A 6M 7M"],"lydian dominant":["1P 2M 3M 4A 5P 6M 7m",["lydian b7"]],"melodic minor fifth mode":["1P 2M 3M 4P 5P 6m 7m",["hindu","mixolydian b6M"]],"locrian #2":["1P 2M 3m 4P 5d 6m 7m",["half-diminished"]],"altered":["1P 2m 3m 3M 5d 6m 7m",["super locrian","diminished whole tone","pomeroy"]],"harmonic minor":["1P 2M 3m 4P 5P 6m 7M"],"phrygian dominant":["1P 2m 3M 4P 5P 6m 7m",["spanish","phrygian major"]],"half-whole diminished":["1P 2m 3m 3M 4A 5P 6M 7m",["dominant diminished"]],"diminished":["1P 2M 3m 4P 5d 6m 6M 7M",["whole-half diminished"]],"major pentatonic":["1P 2M 3M 5P 6M",["pentatonic"]],"lydian pentatonic":["1P 3M 4A 5P 7M",["chinese"]],"mixolydian pentatonic":["1P 3M 4P 5P 7m",["indian"]],"locrian pentatonic":["1P 3m 4P 5d 7m",["minor seven flat five pentatonic"]],"minor pentatonic":["1P 3m 4P 5P 7m"],"minor six pentatonic":["1P 3m 4P 5P 6M"],"minor hexatonic":["1P 2M 3m 4P 5P 7M"],"flat three pentatonic":["1P 2M 3m 5P 6M",["kumoi"]],"flat six pentatonic":["1P 2M 3M 5P 6m"],"major flat two pentatonic":["1P 2m 3M 5P 6M"],"whole tone pentatonic":["1P 3M 5d 6m 7m"],"ionian pentatonic":["1P 3M 4P 5P 7M"],"lydian #5P pentatonic":["1P 3M 4A 5A 7M"],"lydian dominant pentatonic":["1P 3M 4A 5P 7m"],"minor #7M pentatonic":["1P 3m 4P 5P 7M"],"super locrian pentatonic":["1P 3m 4d 5d 7m"],"in-sen":["1P 2m 4P 5P 7m"],"iwato":["1P 2m 4P 5d 7m"],"hirajoshi":["1P 2M 3m 5P 6m"],"kumoijoshi":["1P 2m 4P 5P 6m"],"pelog":["1P 2m 3m 5P 6m"],"vietnamese 1":["1P 3m 4P 5P 6m"],"vietnamese 2":["1P 3m 4P 5P 7m"],"prometheus":["1P 2M 3M 4A 6M 7m"],"prometheus neopolitan":["1P 2m 3M 4A 6M 7m"],"ritusen":["1P 2M 4P 5P 6M"],"scriabin":["1P 2m 3M 5P 6M"],"piongio":["1P 2M 4P 5P 6M 7m"],"major blues":["1P 2M 3m 3M 5P 6M"],"minor blues":["1P 3m 4P 5d 5P 7m",["blues"]],"composite blues":["1P 2M 3m 3M 4P 5d 5P 6M 7m"],"augmented":["1P 2A 3M 5P 5A 7M"],"augmented heptatonic":["1P 2A 3M 4P 5P 5A 7M"],"dorian #4":["1P 2M 3m 4A 5P 6M 7m"],"lydian diminished":["1P 2M 3m 4A 5P 6M 7M"],"whole tone":["1P 2M 3M 4A 5A 7m"],"leading whole tone":["1P 2M 3M 4A 5A 7m 7M"],"lydian minor":["1P 2M 3M 4A 5P 6m 7m"],"locrian major":["1P 2M 3M 4P 5d 6m 7m",["arabian"]],"neopolitan":["1P 2m 3m 4P 5P 6m 7M"],"neopolitan minor":["1P 2m 3m 4P 5P 6m 7M"],"neopolitan major":["1P 2m 3m 4P 5P 6M 7M",["dorian b2"]],"neopolitan major pentatonic":["1P 3M 4P 5d 7m"],"romanian minor":["1P 2M 3m 5d 5P 6M 7m"],"double harmonic lydian":["1P 2m 3M 4A 5P 6m 7M"],"harmonic major":["1P 2M 3M 4P 5P 6m 7M"],"double harmonic major":["1P 2m 3M 4P 5P 6m 7M",["gypsy"]],"egyptian":["1P 2M 4P 5P 7m"],"hungarian minor":["1P 2M 3m 4A 5P 6m 7M"],"hungarian major":["1P 2A 3M 4A 5P 6M 7m"],"oriental":["1P 2m 3M 4P 5d 6M 7m"],"spanish heptatonic":["1P 2m 3m 3M 4P 5P 6m 7m"],"flamenco":["1P 2m 3m 3M 4A 5P 7m"],"balinese":["1P 2m 3m 4P 5P 6m 7M"],"todi raga":["1P 2m 3m 4A 5P 6m 7M"],"malkos raga":["1P 3m 4P 6m 7m"],"kafi raga":["1P 3m 3M 4P 5P 6M 7m 7M"],"purvi raga":["1P 2m 3M 4P 4A 5P 6m 7M"],"persian":["1P 2m 3M 4P 5d 6m 7M"],"bebop":["1P 2M 3M 4P 5P 6M 7m 7M"],"bebop dominant":["1P 2M 3M 4P 5P 6M 7m 7M"],"bebop minor":["1P 2M 3m 3M 4P 5P 6M 7m"],"bebop major":["1P 2M 3M 4P 5P 5A 6M 7M"],"bebop locrian":["1P 2m 3m 4P 5d 5P 6m 7m"],"minor bebop":["1P 2M 3m 4P 5P 6m 7m 7M"],"mystery #1":["1P 2m 3M 5d 6m 7m"],"enigmatic":["1P 2m 3M 5d 6m 7m 7M"],"minor six diminished":["1P 2M 3m 4P 5P 6m 6M 7M"],"ionian augmented":["1P 2M 3M 4P 5A 6M 7M"],"lydian #9":["1P 2m 3M 4A 5P 6M 7M"],"ichikosucho":["1P 2M 3M 4P 5d 5P 6M 7M"],"six tone symmetric":["1P 2m 3M 4P 5A 6M"]}')},function(t){t.exports=JSON.parse('{"4":["1P 4P 7m 10m",["quartal"]],"5":["1P 5P"],"7":["1P 3M 5P 7m",["Dominant","Dom"]],"9":["1P 3M 5P 7m 9M",["79"]],"11":["1P 5P 7m 9M 11P"],"13":["1P 3M 5P 7m 9M 13M",["13_"]],"64":["5P 8P 10M"],"M":["1P 3M 5P",["Major",""]],"M#5":["1P 3M 5A",["augmented","maj#5","Maj#5","+","aug"]],"M#5add9":["1P 3M 5A 9M",["+add9"]],"M13":["1P 3M 5P 7M 9M 13M",["maj13","Maj13"]],"M13#11":["1P 3M 5P 7M 9M 11A 13M",["maj13#11","Maj13#11","M13+4","M13#4"]],"M6":["1P 3M 5P 13M",["6"]],"M6#11":["1P 3M 5P 6M 11A",["M6b5","6#11","6b5"]],"M69":["1P 3M 5P 6M 9M",["69"]],"M69#11":["1P 3M 5P 6M 9M 11A"],"M7#11":["1P 3M 5P 7M 11A",["maj7#11","Maj7#11","M7+4","M7#4"]],"M7#5":["1P 3M 5A 7M",["maj7#5","Maj7#5","maj9#5","M7+"]],"M7#5sus4":["1P 4P 5A 7M"],"M7#9#11":["1P 3M 5P 7M 9A 11A"],"M7add13":["1P 3M 5P 6M 7M 9M"],"M7b5":["1P 3M 5d 7M"],"M7b6":["1P 3M 6m 7M"],"M7b9":["1P 3M 5P 7M 9m"],"M7sus4":["1P 4P 5P 7M"],"M9":["1P 3M 5P 7M 9M",["maj9","Maj9"]],"M9#11":["1P 3M 5P 7M 9M 11A",["maj9#11","Maj9#11","M9+4","M9#4"]],"M9#5":["1P 3M 5A 7M 9M",["Maj9#5"]],"M9#5sus4":["1P 4P 5A 7M 9M"],"M9b5":["1P 3M 5d 7M 9M"],"M9sus4":["1P 4P 5P 7M 9M"],"Madd9":["1P 3M 5P 9M",["2","add9","add2"]],"Maj7":["1P 3M 5P 7M",["maj7","M7"]],"Mb5":["1P 3M 5d"],"Mb6":["1P 3M 13m"],"Msus2":["1P 2M 5P",["add9no3","sus2"]],"Msus4":["1P 4P 5P",["sus","sus4"]],"Maddb9":["1P 3M 5P 9m"],"11b9":["1P 5P 7m 9m 11P"],"13#11":["1P 3M 5P 7m 9M 11A 13M",["13+4","13#4"]],"13#9":["1P 3M 5P 7m 9A 13M",["13#9_"]],"13#9#11":["1P 3M 5P 7m 9A 11A 13M"],"13b5":["1P 3M 5d 6M 7m 9M"],"13b9":["1P 3M 5P 7m 9m 13M"],"13b9#11":["1P 3M 5P 7m 9m 11A 13M"],"13no5":["1P 3M 7m 9M 13M"],"13sus4":["1P 4P 5P 7m 9M 13M",["13sus"]],"69#11":["1P 3M 5P 6M 9M 11A"],"7#11":["1P 3M 5P 7m 11A",["7+4","7#4","7#11_","7#4_"]],"7#11b13":["1P 3M 5P 7m 11A 13m",["7b5b13"]],"7#5":["1P 3M 5A 7m",["+7","7aug","aug7"]],"7#5#9":["1P 3M 5A 7m 9A",["7alt","7#5#9_","7#9b13_"]],"7#5b9":["1P 3M 5A 7m 9m"],"7#5b9#11":["1P 3M 5A 7m 9m 11A"],"7#5sus4":["1P 4P 5A 7m"],"7#9":["1P 3M 5P 7m 9A",["7#9_"]],"7#9#11":["1P 3M 5P 7m 9A 11A",["7b5#9"]],"7#9#11b13":["1P 3M 5P 7m 9A 11A 13m"],"7#9b13":["1P 3M 5P 7m 9A 13m"],"7add6":["1P 3M 5P 7m 13M",["67","7add13"]],"7b13":["1P 3M 7m 13m"],"7b5":["1P 3M 5d 7m"],"7b6":["1P 3M 5P 6m 7m"],"7b9":["1P 3M 5P 7m 9m"],"7b9#11":["1P 3M 5P 7m 9m 11A",["7b5b9"]],"7b9#9":["1P 3M 5P 7m 9m 9A"],"7b9b13":["1P 3M 5P 7m 9m 13m"],"7b9b13#11":["1P 3M 5P 7m 9m 11A 13m",["7b9#11b13","7b5b9b13"]],"7no5":["1P 3M 7m"],"7sus4":["1P 4P 5P 7m",["7sus"]],"7sus4b9":["1P 4P 5P 7m 9m",["susb9","7susb9","7b9sus","7b9sus4","phryg"]],"7sus4b9b13":["1P 4P 5P 7m 9m 13m",["7b9b13sus4"]],"9#11":["1P 3M 5P 7m 9M 11A",["9+4","9#4","9#11_","9#4_"]],"9#11b13":["1P 3M 5P 7m 9M 11A 13m",["9b5b13"]],"9#5":["1P 3M 5A 7m 9M",["9+"]],"9#5#11":["1P 3M 5A 7m 9M 11A"],"9b13":["1P 3M 7m 9M 13m"],"9b5":["1P 3M 5d 7m 9M"],"9no5":["1P 3M 7m 9M"],"9sus4":["1P 4P 5P 7m 9M",["9sus"]],"m":["1P 3m 5P"],"m#5":["1P 3m 5A",["m+","mb6"]],"m11":["1P 3m 5P 7m 9M 11P",["_11"]],"m11A 5":["1P 3m 6m 7m 9M 11P"],"m11b5":["1P 3m 7m 12d 2M 4P",["h11","_11b5"]],"m13":["1P 3m 5P 7m 9M 11P 13M",["_13"]],"m6":["1P 3m 4P 5P 13M",["_6"]],"m69":["1P 3m 5P 6M 9M",["_69"]],"m7":["1P 3m 5P 7m",["minor7","_","_7"]],"m7#5":["1P 3m 6m 7m"],"m7add11":["1P 3m 5P 7m 11P",["m7add4"]],"m7b5":["1P 3m 5d 7m",["half-diminished","h7","_7b5"]],"m9":["1P 3m 5P 7m 9M",["_9"]],"m9#5":["1P 3m 6m 7m 9M"],"m9b5":["1P 3m 7m 12d 2M",["h9","-9b5"]],"mMaj7":["1P 3m 5P 7M",["mM7","_M7"]],"mMaj7b6":["1P 3m 5P 6m 7M",["mM7b6"]],"mM9":["1P 3m 5P 7M 9M",["mMaj9","-M9"]],"mM9b6":["1P 3m 5P 6m 7M 9M",["mMaj9b6"]],"mb6M7":["1P 3m 6m 7M"],"mb6b9":["1P 3m 6m 9m"],"o":["1P 3m 5d",["mb5","dim"]],"o7":["1P 3m 5d 13M",["diminished","m6b5","dim7"]],"o7M7":["1P 3m 5d 6M 7M"],"oM7":["1P 3m 5d 7M"],"sus24":["1P 2M 4P 5P",["sus4add9"]],"+add#9":["1P 3M 5A 9A"],"madd4":["1P 3m 4P 5P"],"madd9":["1P 3m 5P 9M"]}')},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(294);window.mm=r},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.tf=void 0;var s=n(36);e.tf=s,i(n(254),e),i(n(355),e),i(n(359),e),i(n(363),e),i(n(367),e),i(n(370),e),i(n(371),e),i(n(388),e),i(n(395),e),i(n(398),e)},function(t,e,n){"use strict";e.byteLength=function(t){var e=c(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,r=c(t),a=r[0],o=r[1],u=new s(function(t,e,n){return 3*(e+n)/4-n}(0,a,o)),l=0,h=o>0?a-4:a;for(n=0;n<h;n+=4)e=i[t.charCodeAt(n)]<<18|i[t.charCodeAt(n+1)]<<12|i[t.charCodeAt(n+2)]<<6|i[t.charCodeAt(n+3)],u[l++]=e>>16&255,u[l++]=e>>8&255,u[l++]=255&e;2===o&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,u[l++]=255&e);1===o&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e);return u},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,s=[],a=0,o=n-i;a<o;a+=16383)s.push(l(t,a,a+16383>o?o:a+16383));1===i?(e=t[n-1],s.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],s.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return s.join("")};for(var r=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,u=a.length;o<u;++o)r[o]=a[o],i[a.charCodeAt(o)]=o;function c(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function l(t,e,n){for(var i,s,a=[],o=e;o<n;o+=3)i=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),a.push(r[(s=i)>>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
e.read=function(t,e,n,r,i){var s,a,o=8*i-r-1,u=(1<<o)-1,c=u>>1,l=-7,h=n?i-1:0,d=n?-1:1,p=t[e+h];for(h+=d,s=p&(1<<-l)-1,p>>=-l,l+=o;l>0;s=256*s+t[e+h],h+=d,l-=8);for(a=s&(1<<-l)-1,s>>=-l,l+=r;l>0;a=256*a+t[e+h],h+=d,l-=8);if(0===s)s=1-c;else{if(s===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,r),s-=c}return(p?-1:1)*a*Math.pow(2,s-r)},e.write=function(t,e,n,r,i,s){var a,o,u,c=8*s-i-1,l=(1<<c)-1,h=l>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:s-1,f=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=l):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+h>=1?d/u:d*Math.pow(2,1-h))*u>=2&&(a++,u/=2),a+h>=l?(o=0,a=l):a+h>=1?(o=(e*u-1)*Math.pow(2,i),a+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[n+p]=255&o,p+=f,o/=256,i-=8);for(a=a<<i|o,c+=i;c>0;t[n+p]=255&a,p+=f,a/=256,c-=8);t[n+p-f]|=128*m}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){"use strict";(function(t){var e=n(26);
/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */const r=()=>n(299);let i;class s{constructor(){this.util=n(300),this.textEncoder=new this.util.TextEncoder}fetch(t,n){return null!=Object(e.c)().global.fetch?Object(e.c)().global.fetch(t,n):(null==i&&(i=r()),i(t,n))}now(){const e=t.hrtime();return 1e3*e[0]+e[1]/1e6}encode(t,e){if("utf-8"!==e&&"utf8"!==e)throw new Error("Node built-in encoder only supports utf-8, but got "+e);return this.textEncoder.encode(t)}decode(t,e){return 0===t.length?"":new this.util.TextDecoder(e).decode(t)}}Object(e.c)().get("IS_NODE")&&Object(e.c)().setPlatform("node",new s)}).call(this,n(154))},function(t,e){},function(t,e){},function(t,e,n){(function(t){var r;!function(t,i,s){function a(t){var e,n=this,r=(e=4022871197,function(t){t=t.toString();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)});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(t),n.s0<0&&(n.s0+=1),n.s1-=r(t),n.s1<0&&(n.s1+=1),n.s2-=r(t),n.s2<0&&(n.s2+=1),r=null}function o(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function u(t,e){var n=new a(t),r=e&&e.state,i=n.next;return i.int32=function(){return 4294967296*n.next()|0},i.double=function(){return i()+11102230246251565e-32*(2097152*i()|0)},i.quick=i,r&&("object"==typeof r&&o(r,n),i.state=function(){return o(n,{})}),i}i&&i.exports?i.exports=u:n(66)&&n(119)?void 0===(r=function(){return u}.call(e,n,e,i))||(i.exports=r):this.alea=u}(0,t,n(66))}).call(this,n(118)(t))},function(t,e,n){(function(t){var r;!function(t,i,s){function a(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),e.next()}function o(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function u(t,e){var n=new a(t),r=e&&e.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},i.int32=n.next,i.quick=i,r&&("object"==typeof r&&o(r,n),i.state=function(){return o(n,{})}),i}i&&i.exports?i.exports=u:n(66)&&n(119)?void 0===(r=function(){return u}.call(e,n,e,i))||(i.exports=r):this.xor128=u}(0,t,n(66))}).call(this,n(118)(t))},function(t,e,n){(function(t){var r;!function(t,i,s){function a(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),r==n.length&&(e.d=e.x<<10^e.x>>>4),e.next()}function o(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function u(t,e){var n=new a(t),r=e&&e.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},i.int32=n.next,i.quick=i,r&&("object"==typeof r&&o(r,n),i.state=function(){return o(n,{})}),i}i&&i.exports?i.exports=u:n(66)&&n(119)?void 0===(r=function(){return u}.call(e,n,e,i))||(i.exports=r):this.xorwow=u}(0,t,n(66))}).call(this,n(118)(t))},function(t,e,n){(function(t){var r;!function(t,i,s){function a(t){var e=this;e.next=function(){var t,n,r=e.x,i=e.i;return t=r[i],n=(t^=t>>>7)^t<<24,n^=(t=r[i+1&7])^t>>>10,n^=(t=r[i+3&7])^t>>>3,n^=(t=r[i+4&7])^t<<7,t=r[i+7&7],n^=(t^=t<<13)^t<<9,r[i]=n,e.i=i+1&7,n},function(t,e){var n,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,n=0;n<e.length;++n)r[7&n]=r[7&n]<<15^e.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],t.x=r,t.i=0,n=256;n>0;--n)t.next()}(e,t)}function o(t,e){return e.x=t.x.slice(),e.i=t.i,e}function u(t,e){null==t&&(t=+new Date);var n=new a(t),r=e&&e.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},i.int32=n.next,i.quick=i,r&&(r.x&&o(r,n),i.state=function(){return o(n,{})}),i}i&&i.exports?i.exports=u:n(66)&&n(119)?void 0===(r=function(){return u}.call(e,n,e,i))||(i.exports=r):this.xorshift7=u}(0,t,n(66))}).call(this,n(118)(t))},function(t,e,n){(function(t){var r;!function(t,i,s){function a(t){var e=this;e.next=function(){var t,n,r=e.w,i=e.X,s=e.i;return e.w=r=r+1640531527|0,n=i[s+34&127],t=i[s=s+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=i[s]=n^t,e.i=s,n+(r^r>>>16)|0},function(t,e){var n,r,i,s,a,o=[],u=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,u=Math.max(u,e.length)),i=0,s=-32;s<u;++s)e&&(r^=e.charCodeAt((s+32)%e.length)),0===s&&(a=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,s>=0&&(a=a+1640531527|0,i=0==(n=o[127&s]^=r+a)?i+1:0);for(i>=128&&(o[127&(e&&e.length||0)]=-1),i=127,s=512;s>0;--s)r=o[i+34&127],n=o[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,o[i]=r^n;t.w=a,t.X=o,t.i=i}(e,t)}function o(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function u(t,e){null==t&&(t=+new Date);var n=new a(t),r=e&&e.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},i.int32=n.next,i.quick=i,r&&(r.X&&o(r,n),i.state=function(){return o(n,{})}),i}i&&i.exports?i.exports=u:n(66)&&n(119)?void 0===(r=function(){return u}.call(e,n,e,i))||(i.exports=r):this.xor4096=u}(0,t,n(66))}).call(this,n(118)(t))},function(t,e,n){(function(t){var r;!function(t,i,s){function a(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,r=e.d,i=e.a;return t=t<<25^t>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-r|0,e.d=r<<16^n>>>16^i,e.a=i-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var r=0;r<n.length+20;r++)e.b^=0|n.charCodeAt(r),e.next()}function o(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function u(t,e){var n=new a(t),r=e&&e.state,i=function(){return(n.next()>>>0)/4294967296};return i.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},i.int32=n.next,i.quick=i,r&&("object"==typeof r&&o(r,n),i.state=function(){return o(n,{})}),i}i&&i.exports?i.exports=u:n(66)&&n(119)?void 0===(r=function(){return u}.call(e,n,e,i))||(i.exports=r):this.tychei=u}(0,t,n(66))}).call(this,n(118)(t))},function(t,e,n){var r;!function(i,s){var a,o=this,u=s.pow(256,6),c=s.pow(2,52),l=2*c;function h(t,e,n){var r=[],h=f(function t(e,n){var r,i=[],s=typeof e;if(n&&"object"==s)for(r in e)try{i.push(t(e[r],n-1))}catch(t){}return i.length?i:"string"==s?e:e+"\0"}((e=1==e?{entropy:!0}:e||{}).entropy?[t,m(i)]:null==t?function(){try{var t;return a&&(t=a.randomBytes)?t=t(256):(t=new Uint8Array(256),(o.crypto||o.msCrypto).getRandomValues(t)),m(t)}catch(t){var e=o.navigator,n=e&&e.plugins;return[+new Date,o,n,o.screen,m(i)]}}():t,3),r),g=new d(r),b=function(){for(var t=g.g(6),e=u,n=0;t<c;)t=256*(t+n),e*=256,n=g.g(1);for(;t>=l;)t/=2,e/=2,n>>>=1;return(t+n)/e};return b.int32=function(){return 0|g.g(4)},b.quick=function(){return g.g(4)/4294967296},b.double=b,f(m(g.S),i),(e.pass||n||function(t,e,n,r){return r&&(r.S&&p(r,g),t.state=function(){return p(g,{})}),n?(s.random=t,e):t})(b,h,"global"in e?e.global:this==s,e.state)}function d(t){var e,n=t.length,r=this,i=0,s=r.i=r.j=0,a=r.S=[];for(n||(t=[n++]);i<256;)a[i]=i++;for(i=0;i<256;i++)a[i]=a[s=255&s+t[i%n]+(e=a[i])],a[s]=e;(r.g=function(t){for(var e,n=0,i=r.i,s=r.j,a=r.S;t--;)e=a[i=255&i+1],n=256*n+a[255&(a[i]=a[s=255&s+e])+(a[s]=e)];return r.i=i,r.j=s,n})(256)}function p(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function f(t,e){for(var n,r=t+"",i=0;i<r.length;)e[255&i]=255&(n^=19*e[255&i])+r.charCodeAt(i++);return m(e)}function m(t){return String.fromCharCode.apply(0,t)}if(s.seedrandom=h,f(s.random(),i),t.exports){t.exports=h;try{a=n(308)}catch(t){}}else void 0===(r=function(){return h}.call(e,n,e,t))||(t.exports=r)}([],Math)},function(t,e){},function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function s(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new s(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new s(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(310),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(96))},function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var r,i,s,a,o,u=1,c={},l=!1,h=t.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(t);d=d&&d.setTimeout?d:t,"[object process]"==={}.toString.call(t.process)?r=function(t){e.nextTick((function(){f(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?t.MessageChannel?((s=new MessageChannel).port1.onmessage=function(t){f(t.data)},r=function(t){s.port2.postMessage(t)}):h&&"onreadystatechange"in h.createElement("script")?(i=h.documentElement,r=function(t){var e=h.createElement("script");e.onreadystatechange=function(){f(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):r=function(t){setTimeout(f,0,t)}:(a="setImmediate$"+Math.random()+"$",o=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(a)&&f(+e.data.slice(a.length))},t.addEventListener?t.addEventListener("message",o,!1):t.attachEvent("onmessage",o),r=function(e){t.postMessage(a+e,"*")}),d.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n<e.length;n++)e[n]=arguments[n+1];var i={callback:t,args:e};return c[u]=i,r(u),u++},d.clearImmediate=p}function p(t){delete c[t]}function f(t){if(l)setTimeout(f,0,t);else{var e=c[t];if(e){l=!0;try{!function(t){var e=t.callback,n=t.args;switch(n.length){case 0:e();break;case 1:e(n[0]);break;case 2:e(n[0],n[1]);break;case 3:e(n[0],n[1],n[2]);break;default:e.apply(void 0,n)}}(e)}finally{p(t),l=!1}}}}}("undefined"==typeof self?void 0===t?this:t:self)}).call(this,n(96),n(154))},function(t,e){},function(t,e){},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.sequences=e.performance=e.melodies=e.logging=e.data=e.constants=e.chords=e.aux_inputs=void 0;var s=n(255);e.aux_inputs=s;var a=n(211);e.chords=a;var o=n(67);e.constants=o;var u=n(212);e.data=u;var c=n(55);e.logging=c;var l=n(258);e.melodies=l;var h=n(259);e.performance=h;var d=n(92);e.sequences=d,i(n(330),e),i(n(339),e),i(n(350),e),i(n(352),e),i(n(353),e)},function(t,e,n){"use strict";var r,i,s=n(315),a=s.Reader,o=s.Writer,u=s.util,c=s.roots.default||(s.roots.default={});c.tensorflow=((i={}).magenta=((r={}).NoteSequence=function(){function t(t){if(this.timeSignatures=[],this.keySignatures=[],this.tempos=[],this.notes=[],this.pitchBends=[],this.controlChanges=[],this.partInfos=[],this.textAnnotations=[],this.sectionAnnotations=[],this.sectionGroups=[],t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}var e,n;return t.prototype.id="",t.prototype.filename="",t.prototype.referenceNumber=u.Long?u.Long.fromBits(0,0,!1):0,t.prototype.collectionName="",t.prototype.ticksPerQuarter=0,t.prototype.timeSignatures=u.emptyArray,t.prototype.keySignatures=u.emptyArray,t.prototype.tempos=u.emptyArray,t.prototype.notes=u.emptyArray,t.prototype.totalTime=0,t.prototype.totalQuantizedSteps=u.Long?u.Long.fromBits(0,0,!1):0,t.prototype.pitchBends=u.emptyArray,t.prototype.controlChanges=u.emptyArray,t.prototype.partInfos=u.emptyArray,t.prototype.sourceInfo=null,t.prototype.textAnnotations=u.emptyArray,t.prototype.sectionAnnotations=u.emptyArray,t.prototype.sectionGroups=u.emptyArray,t.prototype.quantizationInfo=null,t.prototype.subsequenceInfo=null,t.prototype.sequenceMetadata=null,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=o.create()),null!=t.id&&t.hasOwnProperty("id")&&e.uint32(10).string(t.id),null!=t.filename&&t.hasOwnProperty("filename")&&e.uint32(18).string(t.filename),null!=t.collectionName&&t.hasOwnProperty("collectionName")&&e.uint32(26).string(t.collectionName),null!=t.ticksPerQuarter&&t.hasOwnProperty("ticksPerQuarter")&&e.uint32(32).int32(t.ticksPerQuarter),null!=t.timeSignatures&&t.timeSignatures.length)for(var n=0;n<t.timeSignatures.length;++n)c.tensorflow.magenta.NoteSequence.TimeSignature.encode(t.timeSignatures[n],e.uint32(42).fork()).ldelim();if(null!=t.keySignatures&&t.keySignatures.length)for(n=0;n<t.keySignatures.length;++n)c.tensorflow.magenta.NoteSequence.KeySignature.encode(t.keySignatures[n],e.uint32(50).fork()).ldelim();if(null!=t.tempos&&t.tempos.length)for(n=0;n<t.tempos.length;++n)c.tensorflow.magenta.NoteSequence.Tempo.encode(t.tempos[n],e.uint32(58).fork()).ldelim();if(null!=t.notes&&t.notes.length)for(n=0;n<t.notes.length;++n)c.tensorflow.magenta.NoteSequence.Note.encode(t.notes[n],e.uint32(66).fork()).ldelim();if(null!=t.totalTime&&t.hasOwnProperty("totalTime")&&e.uint32(73).double(t.totalTime),null!=t.pitchBends&&t.pitchBends.length)for(n=0;n<t.pitchBends.length;++n)c.tensorflow.magenta.NoteSequence.PitchBend.encode(t.pitchBends[n],e.uint32(82).fork()).ldelim();if(null!=t.controlChanges&&t.controlChanges.length)for(n=0;n<t.controlChanges.length;++n)c.tensorflow.magenta.NoteSequence.ControlChange.encode(t.controlChanges[n],e.uint32(90).fork()).ldelim();if(null!=t.partInfos&&t.partInfos.length)for(n=0;n<t.partInfos.length;++n)c.tensorflow.magenta.NoteSequence.PartInfo.encode(t.partInfos[n],e.uint32(98).fork()).ldelim();if(null!=t.sourceInfo&&t.hasOwnProperty("sourceInfo")&&c.tensorflow.magenta.NoteSequence.SourceInfo.encode(t.sourceInfo,e.uint32(106).fork()).ldelim(),null!=t.textAnnotations&&t.textAnnotations.length)for(n=0;n<t.textAnnotations.length;++n)c.tensorflow.magenta.NoteSequence.TextAnnotation.encode(t.textAnnotations[n],e.uint32(114).fork()).ldelim();if(null!=t.quantizationInfo&&t.hasOwnProperty("quantizationInfo")&&c.tensorflow.magenta.NoteSequence.QuantizationInfo.encode(t.quantizationInfo,e.uint32(122).fork()).ldelim(),null!=t.totalQuantizedSteps&&t.hasOwnProperty("totalQuantizedSteps")&&e.uint32(128).int64(t.totalQuantizedSteps),null!=t.subsequenceInfo&&t.hasOwnProperty("subsequenceInfo")&&c.tensorflow.magenta.NoteSequence.SubsequenceInfo.encode(t.subsequenceInfo,e.uint32(138).fork()).ldelim(),null!=t.referenceNumber&&t.hasOwnProperty("referenceNumber")&&e.uint32(144).int64(t.referenceNumber),null!=t.sequenceMetadata&&t.hasOwnProperty("sequenceMetadata")&&c.tensorflow.magenta.SequenceMetadata.encode(t.sequenceMetadata,e.uint32(154).fork()).ldelim(),null!=t.sectionAnnotations&&t.sectionAnnotations.length)for(n=0;n<t.sectionAnnotations.length;++n)c.tensorflow.magenta.NoteSequence.SectionAnnotation.encode(t.sectionAnnotations[n],e.uint32(162).fork()).ldelim();if(null!=t.sectionGroups&&t.sectionGroups.length)for(n=0;n<t.sectionGroups.length;++n)c.tensorflow.magenta.NoteSequence.SectionGroup.encode(t.sectionGroups[n],e.uint32(170).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.id=t.string();break;case 2:r.filename=t.string();break;case 18:r.referenceNumber=u.Long?t.int64().toNumber():t.int64();break;case 3:r.collectionName=t.string();break;case 4:r.ticksPerQuarter=t.int32();break;case 5:r.timeSignatures&&r.timeSignatures.length||(r.timeSignatures=[]),r.timeSignatures.push(c.tensorflow.magenta.NoteSequence.TimeSignature.decode(t,t.uint32()));break;case 6:r.keySignatures&&r.keySignatures.length||(r.keySignatures=[]),r.keySignatures.push(c.tensorflow.magenta.NoteSequence.KeySignature.decode(t,t.uint32()));break;case 7:r.tempos&&r.tempos.length||(r.tempos=[]),r.tempos.push(c.tensorflow.magenta.NoteSequence.Tempo.decode(t,t.uint32()));break;case 8:r.notes&&r.notes.length||(r.notes=[]),r.notes.push(c.tensorflow.magenta.NoteSequence.Note.decode(t,t.uint32()));break;case 9:r.totalTime=t.double();break;case 16:r.totalQuantizedSteps=u.Long?t.int64().toNumber():t.int64();break;case 10:r.pitchBends&&r.pitchBends.length||(r.pitchBends=[]),r.pitchBends.push(c.tensorflow.magenta.NoteSequence.PitchBend.decode(t,t.uint32()));break;case 11:r.controlChanges&&r.controlChanges.length||(r.controlChanges=[]),r.controlChanges.push(c.tensorflow.magenta.NoteSequence.ControlChange.decode(t,t.uint32()));break;case 12:r.partInfos&&r.partInfos.length||(r.partInfos=[]),r.partInfos.push(c.tensorflow.magenta.NoteSequence.PartInfo.decode(t,t.uint32()));break;case 13:r.sourceInfo=c.tensorflow.magenta.NoteSequence.SourceInfo.decode(t,t.uint32());break;case 14:r.textAnnotations&&r.textAnnotations.length||(r.textAnnotations=[]),r.textAnnotations.push(c.tensorflow.magenta.NoteSequence.TextAnnotation.decode(t,t.uint32()));break;case 20:r.sectionAnnotations&&r.sectionAnnotations.length||(r.sectionAnnotations=[]),r.sectionAnnotations.push(c.tensorflow.magenta.NoteSequence.SectionAnnotation.decode(t,t.uint32()));break;case 21:r.sectionGroups&&r.sectionGroups.length||(r.sectionGroups=[]),r.sectionGroups.push(c.tensorflow.magenta.NoteSequence.SectionGroup.decode(t,t.uint32()));break;case 15:r.quantizationInfo=c.tensorflow.magenta.NoteSequence.QuantizationInfo.decode(t,t.uint32());break;case 17:r.subsequenceInfo=c.tensorflow.magenta.NoteSequence.SubsequenceInfo.decode(t,t.uint32());break;case 19:r.sequenceMetadata=c.tensorflow.magenta.SequenceMetadata.decode(t,t.uint32());break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.id&&t.hasOwnProperty("id")&&!u.isString(t.id))return"id: string expected";if(null!=t.filename&&t.hasOwnProperty("filename")&&!u.isString(t.filename))return"filename: string expected";if(null!=t.referenceNumber&&t.hasOwnProperty("referenceNumber")&&!(u.isInteger(t.referenceNumber)||t.referenceNumber&&u.isInteger(t.referenceNumber.low)&&u.isInteger(t.referenceNumber.high)))return"referenceNumber: integer|Long expected";if(null!=t.collectionName&&t.hasOwnProperty("collectionName")&&!u.isString(t.collectionName))return"collectionName: string expected";if(null!=t.ticksPerQuarter&&t.hasOwnProperty("ticksPerQuarter")&&!u.isInteger(t.ticksPerQuarter))return"ticksPerQuarter: integer expected";if(null!=t.timeSignatures&&t.hasOwnProperty("timeSignatures")){if(!Array.isArray(t.timeSignatures))return"timeSignatures: array expected";for(var e=0;e<t.timeSignatures.length;++e)if(n=c.tensorflow.magenta.NoteSequence.TimeSignature.verify(t.timeSignatures[e]))return"timeSignatures."+n}if(null!=t.keySignatures&&t.hasOwnProperty("keySignatures")){if(!Array.isArray(t.keySignatures))return"keySignatures: array expected";for(e=0;e<t.keySignatures.length;++e)if(n=c.tensorflow.magenta.NoteSequence.KeySignature.verify(t.keySignatures[e]))return"keySignatures."+n}if(null!=t.tempos&&t.hasOwnProperty("tempos")){if(!Array.isArray(t.tempos))return"tempos: array expected";for(e=0;e<t.tempos.length;++e)if(n=c.tensorflow.magenta.NoteSequence.Tempo.verify(t.tempos[e]))return"tempos."+n}if(null!=t.notes&&t.hasOwnProperty("notes")){if(!Array.isArray(t.notes))return"notes: array expected";for(e=0;e<t.notes.length;++e)if(n=c.tensorflow.magenta.NoteSequence.Note.verify(t.notes[e]))return"notes."+n}if(null!=t.totalTime&&t.hasOwnProperty("totalTime")&&"number"!=typeof t.totalTime)return"totalTime: number expected";if(null!=t.totalQuantizedSteps&&t.hasOwnProperty("totalQuantizedSteps")&&!(u.isInteger(t.totalQuantizedSteps)||t.totalQuantizedSteps&&u.isInteger(t.totalQuantizedSteps.low)&&u.isInteger(t.totalQuantizedSteps.high)))return"totalQuantizedSteps: integer|Long expected";if(null!=t.pitchBends&&t.hasOwnProperty("pitchBends")){if(!Array.isArray(t.pitchBends))return"pitchBends: array expected";for(e=0;e<t.pitchBends.length;++e)if(n=c.tensorflow.magenta.NoteSequence.PitchBend.verify(t.pitchBends[e]))return"pitchBends."+n}if(null!=t.controlChanges&&t.hasOwnProperty("controlChanges")){if(!Array.isArray(t.controlChanges))return"controlChanges: array expected";for(e=0;e<t.controlChanges.length;++e)if(n=c.tensorflow.magenta.NoteSequence.ControlChange.verify(t.controlChanges[e]))return"controlChanges."+n}if(null!=t.partInfos&&t.hasOwnProperty("partInfos")){if(!Array.isArray(t.partInfos))return"partInfos: array expected";for(e=0;e<t.partInfos.length;++e)if(n=c.tensorflow.magenta.NoteSequence.PartInfo.verify(t.partInfos[e]))return"partInfos."+n}if(null!=t.sourceInfo&&t.hasOwnProperty("sourceInfo")&&(n=c.tensorflow.magenta.NoteSequence.SourceInfo.verify(t.sourceInfo)))return"sourceInfo."+n;if(null!=t.textAnnotations&&t.hasOwnProperty("textAnnotations")){if(!Array.isArray(t.textAnnotations))return"textAnnotations: array expected";for(e=0;e<t.textAnnotations.length;++e)if(n=c.tensorflow.magenta.NoteSequence.TextAnnotation.verify(t.textAnnotations[e]))return"textAnnotations."+n}if(null!=t.sectionAnnotations&&t.hasOwnProperty("sectionAnnotations")){if(!Array.isArray(t.sectionAnnotations))return"sectionAnnotations: array expected";for(e=0;e<t.sectionAnnotations.length;++e)if(n=c.tensorflow.magenta.NoteSequence.SectionAnnotation.verify(t.sectionAnnotations[e]))return"sectionAnnotations."+n}if(null!=t.sectionGroups&&t.hasOwnProperty("sectionGroups")){if(!Array.isArray(t.sectionGroups))return"sectionGroups: array expected";for(e=0;e<t.sectionGroups.length;++e){var n;if(n=c.tensorflow.magenta.NoteSequence.SectionGroup.verify(t.sectionGroups[e]))return"sectionGroups."+n}}return null!=t.quantizationInfo&&t.hasOwnProperty("quantizationInfo")&&(n=c.tensorflow.magenta.NoteSequence.QuantizationInfo.verify(t.quantizationInfo))?"quantizationInfo."+n:null!=t.subsequenceInfo&&t.hasOwnProperty("subsequenceInfo")&&(n=c.tensorflow.magenta.NoteSequence.SubsequenceInfo.verify(t.subsequenceInfo))?"subsequenceInfo."+n:null!=t.sequenceMetadata&&t.hasOwnProperty("sequenceMetadata")&&(n=c.tensorflow.magenta.SequenceMetadata.verify(t.sequenceMetadata))?"sequenceMetadata."+n:null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence)return t;var e=new c.tensorflow.magenta.NoteSequence;if(null!=t.id&&(e.id=String(t.id)),null!=t.filename&&(e.filename=String(t.filename)),null!=t.referenceNumber&&(u.Long?(e.referenceNumber=u.Long.fromValue(t.referenceNumber)).unsigned=!1:"string"==typeof t.referenceNumber?e.referenceNumber=parseInt(t.referenceNumber,10):"number"==typeof t.referenceNumber?e.referenceNumber=t.referenceNumber:"object"==typeof t.referenceNumber&&(e.referenceNumber=new u.LongBits(t.referenceNumber.low>>>0,t.referenceNumber.high>>>0).toNumber())),null!=t.collectionName&&(e.collectionName=String(t.collectionName)),null!=t.ticksPerQuarter&&(e.ticksPerQuarter=0|t.ticksPerQuarter),t.timeSignatures){if(!Array.isArray(t.timeSignatures))throw TypeError(".tensorflow.magenta.NoteSequence.timeSignatures: array expected");e.timeSignatures=[];for(var n=0;n<t.timeSignatures.length;++n){if("object"!=typeof t.timeSignatures[n])throw TypeError(".tensorflow.magenta.NoteSequence.timeSignatures: object expected");e.timeSignatures[n]=c.tensorflow.magenta.NoteSequence.TimeSignature.fromObject(t.timeSignatures[n])}}if(t.keySignatures){if(!Array.isArray(t.keySignatures))throw TypeError(".tensorflow.magenta.NoteSequence.keySignatures: array expected");for(e.keySignatures=[],n=0;n<t.keySignatures.length;++n){if("object"!=typeof t.keySignatures[n])throw TypeError(".tensorflow.magenta.NoteSequence.keySignatures: object expected");e.keySignatures[n]=c.tensorflow.magenta.NoteSequence.KeySignature.fromObject(t.keySignatures[n])}}if(t.tempos){if(!Array.isArray(t.tempos))throw TypeError(".tensorflow.magenta.NoteSequence.tempos: array expected");for(e.tempos=[],n=0;n<t.tempos.length;++n){if("object"!=typeof t.tempos[n])throw TypeError(".tensorflow.magenta.NoteSequence.tempos: object expected");e.tempos[n]=c.tensorflow.magenta.NoteSequence.Tempo.fromObject(t.tempos[n])}}if(t.notes){if(!Array.isArray(t.notes))throw TypeError(".tensorflow.magenta.NoteSequence.notes: array expected");for(e.notes=[],n=0;n<t.notes.length;++n){if("object"!=typeof t.notes[n])throw TypeError(".tensorflow.magenta.NoteSequence.notes: object expected");e.notes[n]=c.tensorflow.magenta.NoteSequence.Note.fromObject(t.notes[n])}}if(null!=t.totalTime&&(e.totalTime=Number(t.totalTime)),null!=t.totalQuantizedSteps&&(u.Long?(e.totalQuantizedSteps=u.Long.fromValue(t.totalQuantizedSteps)).unsigned=!1:"string"==typeof t.totalQuantizedSteps?e.totalQuantizedSteps=parseInt(t.totalQuantizedSteps,10):"number"==typeof t.totalQuantizedSteps?e.totalQuantizedSteps=t.totalQuantizedSteps:"object"==typeof t.totalQuantizedSteps&&(e.totalQuantizedSteps=new u.LongBits(t.totalQuantizedSteps.low>>>0,t.totalQuantizedSteps.high>>>0).toNumber())),t.pitchBends){if(!Array.isArray(t.pitchBends))throw TypeError(".tensorflow.magenta.NoteSequence.pitchBends: array expected");for(e.pitchBends=[],n=0;n<t.pitchBends.length;++n){if("object"!=typeof t.pitchBends[n])throw TypeError(".tensorflow.magenta.NoteSequence.pitchBends: object expected");e.pitchBends[n]=c.tensorflow.magenta.NoteSequence.PitchBend.fromObject(t.pitchBends[n])}}if(t.controlChanges){if(!Array.isArray(t.controlChanges))throw TypeError(".tensorflow.magenta.NoteSequence.controlChanges: array expected");for(e.controlChanges=[],n=0;n<t.controlChanges.length;++n){if("object"!=typeof t.controlChanges[n])throw TypeError(".tensorflow.magenta.NoteSequence.controlChanges: object expected");e.controlChanges[n]=c.tensorflow.magenta.NoteSequence.ControlChange.fromObject(t.controlChanges[n])}}if(t.partInfos){if(!Array.isArray(t.partInfos))throw TypeError(".tensorflow.magenta.NoteSequence.partInfos: array expected");for(e.partInfos=[],n=0;n<t.partInfos.length;++n){if("object"!=typeof t.partInfos[n])throw TypeError(".tensorflow.magenta.NoteSequence.partInfos: object expected");e.partInfos[n]=c.tensorflow.magenta.NoteSequence.PartInfo.fromObject(t.partInfos[n])}}if(null!=t.sourceInfo){if("object"!=typeof t.sourceInfo)throw TypeError(".tensorflow.magenta.NoteSequence.sourceInfo: object expected");e.sourceInfo=c.tensorflow.magenta.NoteSequence.SourceInfo.fromObject(t.sourceInfo)}if(t.textAnnotations){if(!Array.isArray(t.textAnnotations))throw TypeError(".tensorflow.magenta.NoteSequence.textAnnotations: array expected");for(e.textAnnotations=[],n=0;n<t.textAnnotations.length;++n){if("object"!=typeof t.textAnnotations[n])throw TypeError(".tensorflow.magenta.NoteSequence.textAnnotations: object expected");e.textAnnotations[n]=c.tensorflow.magenta.NoteSequence.TextAnnotation.fromObject(t.textAnnotations[n])}}if(t.sectionAnnotations){if(!Array.isArray(t.sectionAnnotations))throw TypeError(".tensorflow.magenta.NoteSequence.sectionAnnotations: array expected");for(e.sectionAnnotations=[],n=0;n<t.sectionAnnotations.length;++n){if("object"!=typeof t.sectionAnnotations[n])throw TypeError(".tensorflow.magenta.NoteSequence.sectionAnnotations: object expected");e.sectionAnnotations[n]=c.tensorflow.magenta.NoteSequence.SectionAnnotation.fromObject(t.sectionAnnotations[n])}}if(t.sectionGroups){if(!Array.isArray(t.sectionGroups))throw TypeError(".tensorflow.magenta.NoteSequence.sectionGroups: array expected");for(e.sectionGroups=[],n=0;n<t.sectionGroups.length;++n){if("object"!=typeof t.sectionGroups[n])throw TypeError(".tensorflow.magenta.NoteSequence.sectionGroups: object expected");e.sectionGroups[n]=c.tensorflow.magenta.NoteSequence.SectionGroup.fromObject(t.sectionGroups[n])}}if(null!=t.quantizationInfo){if("object"!=typeof t.quantizationInfo)throw TypeError(".tensorflow.magenta.NoteSequence.quantizationInfo: object expected");e.quantizationInfo=c.tensorflow.magenta.NoteSequence.QuantizationInfo.fromObject(t.quantizationInfo)}if(null!=t.subsequenceInfo){if("object"!=typeof t.subsequenceInfo)throw TypeError(".tensorflow.magenta.NoteSequence.subsequenceInfo: object expected");e.subsequenceInfo=c.tensorflow.magenta.NoteSequence.SubsequenceInfo.fromObject(t.subsequenceInfo)}if(null!=t.sequenceMetadata){if("object"!=typeof t.sequenceMetadata)throw TypeError(".tensorflow.magenta.NoteSequence.sequenceMetadata: object expected");e.sequenceMetadata=c.tensorflow.magenta.SequenceMetadata.fromObject(t.sequenceMetadata)}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.timeSignatures=[],n.keySignatures=[],n.tempos=[],n.notes=[],n.pitchBends=[],n.controlChanges=[],n.partInfos=[],n.textAnnotations=[],n.sectionAnnotations=[],n.sectionGroups=[]),e.defaults){if(n.id="",n.filename="",n.collectionName="",n.ticksPerQuarter=0,n.totalTime=0,n.sourceInfo=null,n.quantizationInfo=null,u.Long){var r=new u.Long(0,0,!1);n.totalQuantizedSteps=e.longs===String?r.toString():e.longs===Number?r.toNumber():r}else n.totalQuantizedSteps=e.longs===String?"0":0;n.subsequenceInfo=null,u.Long?(r=new u.Long(0,0,!1),n.referenceNumber=e.longs===String?r.toString():e.longs===Number?r.toNumber():r):n.referenceNumber=e.longs===String?"0":0,n.sequenceMetadata=null}if(null!=t.id&&t.hasOwnProperty("id")&&(n.id=t.id),null!=t.filename&&t.hasOwnProperty("filename")&&(n.filename=t.filename),null!=t.collectionName&&t.hasOwnProperty("collectionName")&&(n.collectionName=t.collectionName),null!=t.ticksPerQuarter&&t.hasOwnProperty("ticksPerQuarter")&&(n.ticksPerQuarter=t.ticksPerQuarter),t.timeSignatures&&t.timeSignatures.length){n.timeSignatures=[];for(var i=0;i<t.timeSignatures.length;++i)n.timeSignatures[i]=c.tensorflow.magenta.NoteSequence.TimeSignature.toObject(t.timeSignatures[i],e)}if(t.keySignatures&&t.keySignatures.length)for(n.keySignatures=[],i=0;i<t.keySignatures.length;++i)n.keySignatures[i]=c.tensorflow.magenta.NoteSequence.KeySignature.toObject(t.keySignatures[i],e);if(t.tempos&&t.tempos.length)for(n.tempos=[],i=0;i<t.tempos.length;++i)n.tempos[i]=c.tensorflow.magenta.NoteSequence.Tempo.toObject(t.tempos[i],e);if(t.notes&&t.notes.length)for(n.notes=[],i=0;i<t.notes.length;++i)n.notes[i]=c.tensorflow.magenta.NoteSequence.Note.toObject(t.notes[i],e);if(null!=t.totalTime&&t.hasOwnProperty("totalTime")&&(n.totalTime=e.json&&!isFinite(t.totalTime)?String(t.totalTime):t.totalTime),t.pitchBends&&t.pitchBends.length)for(n.pitchBends=[],i=0;i<t.pitchBends.length;++i)n.pitchBends[i]=c.tensorflow.magenta.NoteSequence.PitchBend.toObject(t.pitchBends[i],e);if(t.controlChanges&&t.controlChanges.length)for(n.controlChanges=[],i=0;i<t.controlChanges.length;++i)n.controlChanges[i]=c.tensorflow.magenta.NoteSequence.ControlChange.toObject(t.controlChanges[i],e);if(t.partInfos&&t.partInfos.length)for(n.partInfos=[],i=0;i<t.partInfos.length;++i)n.partInfos[i]=c.tensorflow.magenta.NoteSequence.PartInfo.toObject(t.partInfos[i],e);if(null!=t.sourceInfo&&t.hasOwnProperty("sourceInfo")&&(n.sourceInfo=c.tensorflow.magenta.NoteSequence.SourceInfo.toObject(t.sourceInfo,e)),t.textAnnotations&&t.textAnnotations.length)for(n.textAnnotations=[],i=0;i<t.textAnnotations.length;++i)n.textAnnotations[i]=c.tensorflow.magenta.NoteSequence.TextAnnotation.toObject(t.textAnnotations[i],e);if(null!=t.quantizationInfo&&t.hasOwnProperty("quantizationInfo")&&(n.quantizationInfo=c.tensorflow.magenta.NoteSequence.QuantizationInfo.toObject(t.quantizationInfo,e)),null!=t.totalQuantizedSteps&&t.hasOwnProperty("totalQuantizedSteps")&&("number"==typeof t.totalQuantizedSteps?n.totalQuantizedSteps=e.longs===String?String(t.totalQuantizedSteps):t.totalQuantizedSteps:n.totalQuantizedSteps=e.longs===String?u.Long.prototype.toString.call(t.totalQuantizedSteps):e.longs===Number?new u.LongBits(t.totalQuantizedSteps.low>>>0,t.totalQuantizedSteps.high>>>0).toNumber():t.totalQuantizedSteps),null!=t.subsequenceInfo&&t.hasOwnProperty("subsequenceInfo")&&(n.subsequenceInfo=c.tensorflow.magenta.NoteSequence.SubsequenceInfo.toObject(t.subsequenceInfo,e)),null!=t.referenceNumber&&t.hasOwnProperty("referenceNumber")&&("number"==typeof t.referenceNumber?n.referenceNumber=e.longs===String?String(t.referenceNumber):t.referenceNumber:n.referenceNumber=e.longs===String?u.Long.prototype.toString.call(t.referenceNumber):e.longs===Number?new u.LongBits(t.referenceNumber.low>>>0,t.referenceNumber.high>>>0).toNumber():t.referenceNumber),null!=t.sequenceMetadata&&t.hasOwnProperty("sequenceMetadata")&&(n.sequenceMetadata=c.tensorflow.magenta.SequenceMetadata.toObject(t.sequenceMetadata,e)),t.sectionAnnotations&&t.sectionAnnotations.length)for(n.sectionAnnotations=[],i=0;i<t.sectionAnnotations.length;++i)n.sectionAnnotations[i]=c.tensorflow.magenta.NoteSequence.SectionAnnotation.toObject(t.sectionAnnotations[i],e);if(t.sectionGroups&&t.sectionGroups.length)for(n.sectionGroups=[],i=0;i<t.sectionGroups.length;++i)n.sectionGroups[i]=c.tensorflow.magenta.NoteSequence.SectionGroup.toObject(t.sectionGroups[i],e);return n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t.Note=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.pitch=0,t.prototype.pitchName=0,t.prototype.velocity=0,t.prototype.startTime=0,t.prototype.quantizedStartStep=u.Long?u.Long.fromBits(0,0,!1):0,t.prototype.endTime=0,t.prototype.quantizedEndStep=u.Long?u.Long.fromBits(0,0,!1):0,t.prototype.numerator=0,t.prototype.denominator=0,t.prototype.instrument=0,t.prototype.program=0,t.prototype.isDrum=!1,t.prototype.part=0,t.prototype.voice=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.pitch&&t.hasOwnProperty("pitch")&&e.uint32(8).int32(t.pitch),null!=t.velocity&&t.hasOwnProperty("velocity")&&e.uint32(16).int32(t.velocity),null!=t.startTime&&t.hasOwnProperty("startTime")&&e.uint32(25).double(t.startTime),null!=t.endTime&&t.hasOwnProperty("endTime")&&e.uint32(33).double(t.endTime),null!=t.numerator&&t.hasOwnProperty("numerator")&&e.uint32(40).int32(t.numerator),null!=t.denominator&&t.hasOwnProperty("denominator")&&e.uint32(48).int32(t.denominator),null!=t.instrument&&t.hasOwnProperty("instrument")&&e.uint32(56).int32(t.instrument),null!=t.program&&t.hasOwnProperty("program")&&e.uint32(64).int32(t.program),null!=t.isDrum&&t.hasOwnProperty("isDrum")&&e.uint32(72).bool(t.isDrum),null!=t.part&&t.hasOwnProperty("part")&&e.uint32(80).int32(t.part),null!=t.pitchName&&t.hasOwnProperty("pitchName")&&e.uint32(88).int32(t.pitchName),null!=t.voice&&t.hasOwnProperty("voice")&&e.uint32(96).int32(t.voice),null!=t.quantizedStartStep&&t.hasOwnProperty("quantizedStartStep")&&e.uint32(104).int64(t.quantizedStartStep),null!=t.quantizedEndStep&&t.hasOwnProperty("quantizedEndStep")&&e.uint32(112).int64(t.quantizedEndStep),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence.Note;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.pitch=t.int32();break;case 11:r.pitchName=t.int32();break;case 2:r.velocity=t.int32();break;case 3:r.startTime=t.double();break;case 13:r.quantizedStartStep=u.Long?t.int64().toNumber():t.int64();break;case 4:r.endTime=t.double();break;case 14:r.quantizedEndStep=u.Long?t.int64().toNumber():t.int64();break;case 5:r.numerator=t.int32();break;case 6:r.denominator=t.int32();break;case 7:r.instrument=t.int32();break;case 8:r.program=t.int32();break;case 9:r.isDrum=t.bool();break;case 10:r.part=t.int32();break;case 12:r.voice=t.int32();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.pitch&&t.hasOwnProperty("pitch")&&!u.isInteger(t.pitch))return"pitch: integer expected";if(null!=t.pitchName&&t.hasOwnProperty("pitchName"))switch(t.pitchName){default:return"pitchName: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 32:case 33:case 34:case 35:}return null!=t.velocity&&t.hasOwnProperty("velocity")&&!u.isInteger(t.velocity)?"velocity: integer expected":null!=t.startTime&&t.hasOwnProperty("startTime")&&"number"!=typeof t.startTime?"startTime: number expected":null!=t.quantizedStartStep&&t.hasOwnProperty("quantizedStartStep")&&!(u.isInteger(t.quantizedStartStep)||t.quantizedStartStep&&u.isInteger(t.quantizedStartStep.low)&&u.isInteger(t.quantizedStartStep.high))?"quantizedStartStep: integer|Long expected":null!=t.endTime&&t.hasOwnProperty("endTime")&&"number"!=typeof t.endTime?"endTime: number expected":null!=t.quantizedEndStep&&t.hasOwnProperty("quantizedEndStep")&&!(u.isInteger(t.quantizedEndStep)||t.quantizedEndStep&&u.isInteger(t.quantizedEndStep.low)&&u.isInteger(t.quantizedEndStep.high))?"quantizedEndStep: integer|Long expected":null!=t.numerator&&t.hasOwnProperty("numerator")&&!u.isInteger(t.numerator)?"numerator: integer expected":null!=t.denominator&&t.hasOwnProperty("denominator")&&!u.isInteger(t.denominator)?"denominator: integer expected":null!=t.instrument&&t.hasOwnProperty("instrument")&&!u.isInteger(t.instrument)?"instrument: integer expected":null!=t.program&&t.hasOwnProperty("program")&&!u.isInteger(t.program)?"program: integer expected":null!=t.isDrum&&t.hasOwnProperty("isDrum")&&"boolean"!=typeof t.isDrum?"isDrum: boolean expected":null!=t.part&&t.hasOwnProperty("part")&&!u.isInteger(t.part)?"part: integer expected":null!=t.voice&&t.hasOwnProperty("voice")&&!u.isInteger(t.voice)?"voice: integer expected":null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence.Note)return t;var e=new c.tensorflow.magenta.NoteSequence.Note;switch(null!=t.pitch&&(e.pitch=0|t.pitch),t.pitchName){case"UNKNOWN_PITCH_NAME":case 0:e.pitchName=0;break;case"F_FLAT_FLAT":case 1:e.pitchName=1;break;case"C_FLAT_FLAT":case 2:e.pitchName=2;break;case"G_FLAT_FLAT":case 3:e.pitchName=3;break;case"D_FLAT_FLAT":case 4:e.pitchName=4;break;case"A_FLAT_FLAT":case 5:e.pitchName=5;break;case"E_FLAT_FLAT":case 6:e.pitchName=6;break;case"B_FLAT_FLAT":case 7:e.pitchName=7;break;case"F_FLAT":case 8:e.pitchName=8;break;case"C_FLAT":case 9:e.pitchName=9;break;case"G_FLAT":case 10:e.pitchName=10;break;case"D_FLAT":case 11:e.pitchName=11;break;case"A_FLAT":case 12:e.pitchName=12;break;case"E_FLAT":case 13:e.pitchName=13;break;case"B_FLAT":case 14:e.pitchName=14;break;case"F":case 15:e.pitchName=15;break;case"C":case 16:e.pitchName=16;break;case"G":case 17:e.pitchName=17;break;case"D":case 18:e.pitchName=18;break;case"A":case 19:e.pitchName=19;break;case"E":case 20:e.pitchName=20;break;case"B":case 21:e.pitchName=21;break;case"F_SHARP":case 22:e.pitchName=22;break;case"C_SHARP":case 23:e.pitchName=23;break;case"G_SHARP":case 24:e.pitchName=24;break;case"D_SHARP":case 25:e.pitchName=25;break;case"A_SHARP":case 26:e.pitchName=26;break;case"E_SHARP":case 27:e.pitchName=27;break;case"B_SHARP":case 28:e.pitchName=28;break;case"F_SHARP_SHARP":case 29:e.pitchName=29;break;case"C_SHARP_SHARP":case 30:e.pitchName=30;break;case"G_SHARP_SHARP":case 31:e.pitchName=31;break;case"D_SHARP_SHARP":case 32:e.pitchName=32;break;case"A_SHARP_SHARP":case 33:e.pitchName=33;break;case"E_SHARP_SHARP":case 34:e.pitchName=34;break;case"B_SHARP_SHARP":case 35:e.pitchName=35}return null!=t.velocity&&(e.velocity=0|t.velocity),null!=t.startTime&&(e.startTime=Number(t.startTime)),null!=t.quantizedStartStep&&(u.Long?(e.quantizedStartStep=u.Long.fromValue(t.quantizedStartStep)).unsigned=!1:"string"==typeof t.quantizedStartStep?e.quantizedStartStep=parseInt(t.quantizedStartStep,10):"number"==typeof t.quantizedStartStep?e.quantizedStartStep=t.quantizedStartStep:"object"==typeof t.quantizedStartStep&&(e.quantizedStartStep=new u.LongBits(t.quantizedStartStep.low>>>0,t.quantizedStartStep.high>>>0).toNumber())),null!=t.endTime&&(e.endTime=Number(t.endTime)),null!=t.quantizedEndStep&&(u.Long?(e.quantizedEndStep=u.Long.fromValue(t.quantizedEndStep)).unsigned=!1:"string"==typeof t.quantizedEndStep?e.quantizedEndStep=parseInt(t.quantizedEndStep,10):"number"==typeof t.quantizedEndStep?e.quantizedEndStep=t.quantizedEndStep:"object"==typeof t.quantizedEndStep&&(e.quantizedEndStep=new u.LongBits(t.quantizedEndStep.low>>>0,t.quantizedEndStep.high>>>0).toNumber())),null!=t.numerator&&(e.numerator=0|t.numerator),null!=t.denominator&&(e.denominator=0|t.denominator),null!=t.instrument&&(e.instrument=0|t.instrument),null!=t.program&&(e.program=0|t.program),null!=t.isDrum&&(e.isDrum=Boolean(t.isDrum)),null!=t.part&&(e.part=0|t.part),null!=t.voice&&(e.voice=0|t.voice),e},t.toObject=function(t,e){e||(e={});var n={};if(e.defaults){if(n.pitch=0,n.velocity=0,n.startTime=0,n.endTime=0,n.numerator=0,n.denominator=0,n.instrument=0,n.program=0,n.isDrum=!1,n.part=0,n.pitchName=e.enums===String?"UNKNOWN_PITCH_NAME":0,n.voice=0,u.Long){var r=new u.Long(0,0,!1);n.quantizedStartStep=e.longs===String?r.toString():e.longs===Number?r.toNumber():r}else n.quantizedStartStep=e.longs===String?"0":0;u.Long?(r=new u.Long(0,0,!1),n.quantizedEndStep=e.longs===String?r.toString():e.longs===Number?r.toNumber():r):n.quantizedEndStep=e.longs===String?"0":0}return null!=t.pitch&&t.hasOwnProperty("pitch")&&(n.pitch=t.pitch),null!=t.velocity&&t.hasOwnProperty("velocity")&&(n.velocity=t.velocity),null!=t.startTime&&t.hasOwnProperty("startTime")&&(n.startTime=e.json&&!isFinite(t.startTime)?String(t.startTime):t.startTime),null!=t.endTime&&t.hasOwnProperty("endTime")&&(n.endTime=e.json&&!isFinite(t.endTime)?String(t.endTime):t.endTime),null!=t.numerator&&t.hasOwnProperty("numerator")&&(n.numerator=t.numerator),null!=t.denominator&&t.hasOwnProperty("denominator")&&(n.denominator=t.denominator),null!=t.instrument&&t.hasOwnProperty("instrument")&&(n.instrument=t.instrument),null!=t.program&&t.hasOwnProperty("program")&&(n.program=t.program),null!=t.isDrum&&t.hasOwnProperty("isDrum")&&(n.isDrum=t.isDrum),null!=t.part&&t.hasOwnProperty("part")&&(n.part=t.part),null!=t.pitchName&&t.hasOwnProperty("pitchName")&&(n.pitchName=e.enums===String?c.tensorflow.magenta.NoteSequence.PitchName[t.pitchName]:t.pitchName),null!=t.voice&&t.hasOwnProperty("voice")&&(n.voice=t.voice),null!=t.quantizedStartStep&&t.hasOwnProperty("quantizedStartStep")&&("number"==typeof t.quantizedStartStep?n.quantizedStartStep=e.longs===String?String(t.quantizedStartStep):t.quantizedStartStep:n.quantizedStartStep=e.longs===String?u.Long.prototype.toString.call(t.quantizedStartStep):e.longs===Number?new u.LongBits(t.quantizedStartStep.low>>>0,t.quantizedStartStep.high>>>0).toNumber():t.quantizedStartStep),null!=t.quantizedEndStep&&t.hasOwnProperty("quantizedEndStep")&&("number"==typeof t.quantizedEndStep?n.quantizedEndStep=e.longs===String?String(t.quantizedEndStep):t.quantizedEndStep:n.quantizedEndStep=e.longs===String?u.Long.prototype.toString.call(t.quantizedEndStep):e.longs===Number?new u.LongBits(t.quantizedEndStep.low>>>0,t.quantizedEndStep.high>>>0).toNumber():t.quantizedEndStep),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),t.PitchName=(e={},(n=Object.create(e))[e[0]="UNKNOWN_PITCH_NAME"]=0,n[e[1]="F_FLAT_FLAT"]=1,n[e[2]="C_FLAT_FLAT"]=2,n[e[3]="G_FLAT_FLAT"]=3,n[e[4]="D_FLAT_FLAT"]=4,n[e[5]="A_FLAT_FLAT"]=5,n[e[6]="E_FLAT_FLAT"]=6,n[e[7]="B_FLAT_FLAT"]=7,n[e[8]="F_FLAT"]=8,n[e[9]="C_FLAT"]=9,n[e[10]="G_FLAT"]=10,n[e[11]="D_FLAT"]=11,n[e[12]="A_FLAT"]=12,n[e[13]="E_FLAT"]=13,n[e[14]="B_FLAT"]=14,n[e[15]="F"]=15,n[e[16]="C"]=16,n[e[17]="G"]=17,n[e[18]="D"]=18,n[e[19]="A"]=19,n[e[20]="E"]=20,n[e[21]="B"]=21,n[e[22]="F_SHARP"]=22,n[e[23]="C_SHARP"]=23,n[e[24]="G_SHARP"]=24,n[e[25]="D_SHARP"]=25,n[e[26]="A_SHARP"]=26,n[e[27]="E_SHARP"]=27,n[e[28]="B_SHARP"]=28,n[e[29]="F_SHARP_SHARP"]=29,n[e[30]="C_SHARP_SHARP"]=30,n[e[31]="G_SHARP_SHARP"]=31,n[e[32]="D_SHARP_SHARP"]=32,n[e[33]="A_SHARP_SHARP"]=33,n[e[34]="E_SHARP_SHARP"]=34,n[e[35]="B_SHARP_SHARP"]=35,n),t.TimeSignature=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.time=0,t.prototype.numerator=0,t.prototype.denominator=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.time&&t.hasOwnProperty("time")&&e.uint32(9).double(t.time),null!=t.numerator&&t.hasOwnProperty("numerator")&&e.uint32(16).int32(t.numerator),null!=t.denominator&&t.hasOwnProperty("denominator")&&e.uint32(24).int32(t.denominator),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence.TimeSignature;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.time=t.double();break;case 2:r.numerator=t.int32();break;case 3:r.denominator=t.int32();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.time&&t.hasOwnProperty("time")&&"number"!=typeof t.time?"time: number expected":null!=t.numerator&&t.hasOwnProperty("numerator")&&!u.isInteger(t.numerator)?"numerator: integer expected":null!=t.denominator&&t.hasOwnProperty("denominator")&&!u.isInteger(t.denominator)?"denominator: integer expected":null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence.TimeSignature)return t;var e=new c.tensorflow.magenta.NoteSequence.TimeSignature;return null!=t.time&&(e.time=Number(t.time)),null!=t.numerator&&(e.numerator=0|t.numerator),null!=t.denominator&&(e.denominator=0|t.denominator),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.time=0,n.numerator=0,n.denominator=0),null!=t.time&&t.hasOwnProperty("time")&&(n.time=e.json&&!isFinite(t.time)?String(t.time):t.time),null!=t.numerator&&t.hasOwnProperty("numerator")&&(n.numerator=t.numerator),null!=t.denominator&&t.hasOwnProperty("denominator")&&(n.denominator=t.denominator),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),t.KeySignature=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.time=0,t.prototype.key=0,t.prototype.mode=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.time&&t.hasOwnProperty("time")&&e.uint32(9).double(t.time),null!=t.key&&t.hasOwnProperty("key")&&e.uint32(16).int32(t.key),null!=t.mode&&t.hasOwnProperty("mode")&&e.uint32(24).int32(t.mode),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence.KeySignature;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.time=t.double();break;case 2:r.key=t.int32();break;case 3:r.mode=t.int32();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.time&&t.hasOwnProperty("time")&&"number"!=typeof t.time)return"time: number expected";if(null!=t.key&&t.hasOwnProperty("key"))switch(t.key){default:return"key: enum value expected";case 0:case 1:case 1:case 2:case 3:case 3:case 4:case 5:case 6:case 6:case 7:case 8:case 8:case 9:case 10:case 10:case 11:}if(null!=t.mode&&t.hasOwnProperty("mode"))switch(t.mode){default:return"mode: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:}return null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence.KeySignature)return t;var e=new c.tensorflow.magenta.NoteSequence.KeySignature;switch(null!=t.time&&(e.time=Number(t.time)),t.key){case"C":case 0:e.key=0;break;case"C_SHARP":case 1:e.key=1;break;case"D_FLAT":case 1:e.key=1;break;case"D":case 2:e.key=2;break;case"D_SHARP":case 3:e.key=3;break;case"E_FLAT":case 3:e.key=3;break;case"E":case 4:e.key=4;break;case"F":case 5:e.key=5;break;case"F_SHARP":case 6:e.key=6;break;case"G_FLAT":case 6:e.key=6;break;case"G":case 7:e.key=7;break;case"G_SHARP":case 8:e.key=8;break;case"A_FLAT":case 8:e.key=8;break;case"A":case 9:e.key=9;break;case"A_SHARP":case 10:e.key=10;break;case"B_FLAT":case 10:e.key=10;break;case"B":case 11:e.key=11}switch(t.mode){case"MAJOR":case 0:e.mode=0;break;case"MINOR":case 1:e.mode=1;break;case"NOT_SPECIFIED":case 2:e.mode=2;break;case"MIXOLYDIAN":case 3:e.mode=3;break;case"DORIAN":case 4:e.mode=4;break;case"PHRYGIAN":case 5:e.mode=5;break;case"LYDIAN":case 6:e.mode=6;break;case"LOCRIAN":case 7:e.mode=7}return e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.time=0,n.key=e.enums===String?"C":0,n.mode=e.enums===String?"MAJOR":0),null!=t.time&&t.hasOwnProperty("time")&&(n.time=e.json&&!isFinite(t.time)?String(t.time):t.time),null!=t.key&&t.hasOwnProperty("key")&&(n.key=e.enums===String?c.tensorflow.magenta.NoteSequence.KeySignature.Key[t.key]:t.key),null!=t.mode&&t.hasOwnProperty("mode")&&(n.mode=e.enums===String?c.tensorflow.magenta.NoteSequence.KeySignature.Mode[t.mode]:t.mode),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t.Key=function(){var t={},e=Object.create(t);return e[t[0]="C"]=0,e[t[1]="C_SHARP"]=1,e.D_FLAT=1,e[t[2]="D"]=2,e[t[3]="D_SHARP"]=3,e.E_FLAT=3,e[t[4]="E"]=4,e[t[5]="F"]=5,e[t[6]="F_SHARP"]=6,e.G_FLAT=6,e[t[7]="G"]=7,e[t[8]="G_SHARP"]=8,e.A_FLAT=8,e[t[9]="A"]=9,e[t[10]="A_SHARP"]=10,e.B_FLAT=10,e[t[11]="B"]=11,e}(),t.Mode=function(){var t={},e=Object.create(t);return e[t[0]="MAJOR"]=0,e[t[1]="MINOR"]=1,e[t[2]="NOT_SPECIFIED"]=2,e[t[3]="MIXOLYDIAN"]=3,e[t[4]="DORIAN"]=4,e[t[5]="PHRYGIAN"]=5,e[t[6]="LYDIAN"]=6,e[t[7]="LOCRIAN"]=7,e}(),t}(),t.Tempo=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.time=0,t.prototype.qpm=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.time&&t.hasOwnProperty("time")&&e.uint32(9).double(t.time),null!=t.qpm&&t.hasOwnProperty("qpm")&&e.uint32(17).double(t.qpm),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence.Tempo;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.time=t.double();break;case 2:r.qpm=t.double();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.time&&t.hasOwnProperty("time")&&"number"!=typeof t.time?"time: number expected":null!=t.qpm&&t.hasOwnProperty("qpm")&&"number"!=typeof t.qpm?"qpm: number expected":null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence.Tempo)return t;var e=new c.tensorflow.magenta.NoteSequence.Tempo;return null!=t.time&&(e.time=Number(t.time)),null!=t.qpm&&(e.qpm=Number(t.qpm)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.time=0,n.qpm=0),null!=t.time&&t.hasOwnProperty("time")&&(n.time=e.json&&!isFinite(t.time)?String(t.time):t.time),null!=t.qpm&&t.hasOwnProperty("qpm")&&(n.qpm=e.json&&!isFinite(t.qpm)?String(t.qpm):t.qpm),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),t.PitchBend=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.time=0,t.prototype.bend=0,t.prototype.instrument=0,t.prototype.program=0,t.prototype.isDrum=!1,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.time&&t.hasOwnProperty("time")&&e.uint32(9).double(t.time),null!=t.bend&&t.hasOwnProperty("bend")&&e.uint32(16).int32(t.bend),null!=t.instrument&&t.hasOwnProperty("instrument")&&e.uint32(24).int32(t.instrument),null!=t.program&&t.hasOwnProperty("program")&&e.uint32(32).int32(t.program),null!=t.isDrum&&t.hasOwnProperty("isDrum")&&e.uint32(40).bool(t.isDrum),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence.PitchBend;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.time=t.double();break;case 2:r.bend=t.int32();break;case 3:r.instrument=t.int32();break;case 4:r.program=t.int32();break;case 5:r.isDrum=t.bool();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.time&&t.hasOwnProperty("time")&&"number"!=typeof t.time?"time: number expected":null!=t.bend&&t.hasOwnProperty("bend")&&!u.isInteger(t.bend)?"bend: integer expected":null!=t.instrument&&t.hasOwnProperty("instrument")&&!u.isInteger(t.instrument)?"instrument: integer expected":null!=t.program&&t.hasOwnProperty("program")&&!u.isInteger(t.program)?"program: integer expected":null!=t.isDrum&&t.hasOwnProperty("isDrum")&&"boolean"!=typeof t.isDrum?"isDrum: boolean expected":null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence.PitchBend)return t;var e=new c.tensorflow.magenta.NoteSequence.PitchBend;return null!=t.time&&(e.time=Number(t.time)),null!=t.bend&&(e.bend=0|t.bend),null!=t.instrument&&(e.instrument=0|t.instrument),null!=t.program&&(e.program=0|t.program),null!=t.isDrum&&(e.isDrum=Boolean(t.isDrum)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.time=0,n.bend=0,n.instrument=0,n.program=0,n.isDrum=!1),null!=t.time&&t.hasOwnProperty("time")&&(n.time=e.json&&!isFinite(t.time)?String(t.time):t.time),null!=t.bend&&t.hasOwnProperty("bend")&&(n.bend=t.bend),null!=t.instrument&&t.hasOwnProperty("instrument")&&(n.instrument=t.instrument),null!=t.program&&t.hasOwnProperty("program")&&(n.program=t.program),null!=t.isDrum&&t.hasOwnProperty("isDrum")&&(n.isDrum=t.isDrum),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),t.ControlChange=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.time=0,t.prototype.quantizedStep=u.Long?u.Long.fromBits(0,0,!1):0,t.prototype.controlNumber=0,t.prototype.controlValue=0,t.prototype.instrument=0,t.prototype.program=0,t.prototype.isDrum=!1,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.time&&t.hasOwnProperty("time")&&e.uint32(9).double(t.time),null!=t.controlNumber&&t.hasOwnProperty("controlNumber")&&e.uint32(16).int32(t.controlNumber),null!=t.controlValue&&t.hasOwnProperty("controlValue")&&e.uint32(24).int32(t.controlValue),null!=t.instrument&&t.hasOwnProperty("instrument")&&e.uint32(32).int32(t.instrument),null!=t.program&&t.hasOwnProperty("program")&&e.uint32(40).int32(t.program),null!=t.isDrum&&t.hasOwnProperty("isDrum")&&e.uint32(48).bool(t.isDrum),null!=t.quantizedStep&&t.hasOwnProperty("quantizedStep")&&e.uint32(56).int64(t.quantizedStep),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence.ControlChange;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.time=t.double();break;case 7:r.quantizedStep=u.Long?t.int64().toNumber():t.int64();break;case 2:r.controlNumber=t.int32();break;case 3:r.controlValue=t.int32();break;case 4:r.instrument=t.int32();break;case 5:r.program=t.int32();break;case 6:r.isDrum=t.bool();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.time&&t.hasOwnProperty("time")&&"number"!=typeof t.time?"time: number expected":null!=t.quantizedStep&&t.hasOwnProperty("quantizedStep")&&!(u.isInteger(t.quantizedStep)||t.quantizedStep&&u.isInteger(t.quantizedStep.low)&&u.isInteger(t.quantizedStep.high))?"quantizedStep: integer|Long expected":null!=t.controlNumber&&t.hasOwnProperty("controlNumber")&&!u.isInteger(t.controlNumber)?"controlNumber: integer expected":null!=t.controlValue&&t.hasOwnProperty("controlValue")&&!u.isInteger(t.controlValue)?"controlValue: integer expected":null!=t.instrument&&t.hasOwnProperty("instrument")&&!u.isInteger(t.instrument)?"instrument: integer expected":null!=t.program&&t.hasOwnProperty("program")&&!u.isInteger(t.program)?"program: integer expected":null!=t.isDrum&&t.hasOwnProperty("isDrum")&&"boolean"!=typeof t.isDrum?"isDrum: boolean expected":null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence.ControlChange)return t;var e=new c.tensorflow.magenta.NoteSequence.ControlChange;return null!=t.time&&(e.time=Number(t.time)),null!=t.quantizedStep&&(u.Long?(e.quantizedStep=u.Long.fromValue(t.quantizedStep)).unsigned=!1:"string"==typeof t.quantizedStep?e.quantizedStep=parseInt(t.quantizedStep,10):"number"==typeof t.quantizedStep?e.quantizedStep=t.quantizedStep:"object"==typeof t.quantizedStep&&(e.quantizedStep=new u.LongBits(t.quantizedStep.low>>>0,t.quantizedStep.high>>>0).toNumber())),null!=t.controlNumber&&(e.controlNumber=0|t.controlNumber),null!=t.controlValue&&(e.controlValue=0|t.controlValue),null!=t.instrument&&(e.instrument=0|t.instrument),null!=t.program&&(e.program=0|t.program),null!=t.isDrum&&(e.isDrum=Boolean(t.isDrum)),e},t.toObject=function(t,e){e||(e={});var n={};if(e.defaults)if(n.time=0,n.controlNumber=0,n.controlValue=0,n.instrument=0,n.program=0,n.isDrum=!1,u.Long){var r=new u.Long(0,0,!1);n.quantizedStep=e.longs===String?r.toString():e.longs===Number?r.toNumber():r}else n.quantizedStep=e.longs===String?"0":0;return null!=t.time&&t.hasOwnProperty("time")&&(n.time=e.json&&!isFinite(t.time)?String(t.time):t.time),null!=t.controlNumber&&t.hasOwnProperty("controlNumber")&&(n.controlNumber=t.controlNumber),null!=t.controlValue&&t.hasOwnProperty("controlValue")&&(n.controlValue=t.controlValue),null!=t.instrument&&t.hasOwnProperty("instrument")&&(n.instrument=t.instrument),null!=t.program&&t.hasOwnProperty("program")&&(n.program=t.program),null!=t.isDrum&&t.hasOwnProperty("isDrum")&&(n.isDrum=t.isDrum),null!=t.quantizedStep&&t.hasOwnProperty("quantizedStep")&&("number"==typeof t.quantizedStep?n.quantizedStep=e.longs===String?String(t.quantizedStep):t.quantizedStep:n.quantizedStep=e.longs===String?u.Long.prototype.toString.call(t.quantizedStep):e.longs===Number?new u.LongBits(t.quantizedStep.low>>>0,t.quantizedStep.high>>>0).toNumber():t.quantizedStep),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),t.PartInfo=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.part=0,t.prototype.name="",t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.part&&t.hasOwnProperty("part")&&e.uint32(8).int32(t.part),null!=t.name&&t.hasOwnProperty("name")&&e.uint32(18).string(t.name),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence.PartInfo;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.part=t.int32();break;case 2:r.name=t.string();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.part&&t.hasOwnProperty("part")&&!u.isInteger(t.part)?"part: integer expected":null!=t.name&&t.hasOwnProperty("name")&&!u.isString(t.name)?"name: string expected":null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence.PartInfo)return t;var e=new c.tensorflow.magenta.NoteSequence.PartInfo;return null!=t.part&&(e.part=0|t.part),null!=t.name&&(e.name=String(t.name)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.part=0,n.name=""),null!=t.part&&t.hasOwnProperty("part")&&(n.part=t.part),null!=t.name&&t.hasOwnProperty("name")&&(n.name=t.name),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),t.SourceInfo=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.sourceType=0,t.prototype.encodingType=0,t.prototype.parser=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.sourceType&&t.hasOwnProperty("sourceType")&&e.uint32(8).int32(t.sourceType),null!=t.encodingType&&t.hasOwnProperty("encodingType")&&e.uint32(16).int32(t.encodingType),null!=t.parser&&t.hasOwnProperty("parser")&&e.uint32(24).int32(t.parser),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence.SourceInfo;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.sourceType=t.int32();break;case 2:r.encodingType=t.int32();break;case 3:r.parser=t.int32();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.sourceType&&t.hasOwnProperty("sourceType"))switch(t.sourceType){default:return"sourceType: enum value expected";case 0:case 1:case 2:}if(null!=t.encodingType&&t.hasOwnProperty("encodingType"))switch(t.encodingType){default:return"encodingType: enum value expected";case 0:case 1:case 2:case 3:case 4:}if(null!=t.parser&&t.hasOwnProperty("parser"))switch(t.parser){default:return"parser: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:}return null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence.SourceInfo)return t;var e=new c.tensorflow.magenta.NoteSequence.SourceInfo;switch(t.sourceType){case"UNKNOWN_SOURCE_TYPE":case 0:e.sourceType=0;break;case"SCORE_BASED":case 1:e.sourceType=1;break;case"PERFORMANCE_BASED":case 2:e.sourceType=2}switch(t.encodingType){case"UNKNOWN_ENCODING_TYPE":case 0:e.encodingType=0;break;case"MUSIC_XML":case 1:e.encodingType=1;break;case"ABC":case 2:e.encodingType=2;break;case"MIDI":case 3:e.encodingType=3;break;case"MUSICNET":case 4:e.encodingType=4}switch(t.parser){case"UNKNOWN_PARSER":case 0:e.parser=0;break;case"MUSIC21":case 1:e.parser=1;break;case"PRETTY_MIDI":case 2:e.parser=2;break;case"MAGENTA_MUSIC_XML":case 3:e.parser=3;break;case"MAGENTA_MUSICNET":case 4:e.parser=4;break;case"MAGENTA_ABC":case 5:e.parser=5;break;case"TONEJS_MIDI_CONVERT":case 6:e.parser=6}return e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.sourceType=e.enums===String?"UNKNOWN_SOURCE_TYPE":0,n.encodingType=e.enums===String?"UNKNOWN_ENCODING_TYPE":0,n.parser=e.enums===String?"UNKNOWN_PARSER":0),null!=t.sourceType&&t.hasOwnProperty("sourceType")&&(n.sourceType=e.enums===String?c.tensorflow.magenta.NoteSequence.SourceInfo.SourceType[t.sourceType]:t.sourceType),null!=t.encodingType&&t.hasOwnProperty("encodingType")&&(n.encodingType=e.enums===String?c.tensorflow.magenta.NoteSequence.SourceInfo.EncodingType[t.encodingType]:t.encodingType),null!=t.parser&&t.hasOwnProperty("parser")&&(n.parser=e.enums===String?c.tensorflow.magenta.NoteSequence.SourceInfo.Parser[t.parser]:t.parser),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t.SourceType=function(){var t={},e=Object.create(t);return e[t[0]="UNKNOWN_SOURCE_TYPE"]=0,e[t[1]="SCORE_BASED"]=1,e[t[2]="PERFORMANCE_BASED"]=2,e}(),t.EncodingType=function(){var t={},e=Object.create(t);return e[t[0]="UNKNOWN_ENCODING_TYPE"]=0,e[t[1]="MUSIC_XML"]=1,e[t[2]="ABC"]=2,e[t[3]="MIDI"]=3,e[t[4]="MUSICNET"]=4,e}(),t.Parser=function(){var t={},e=Object.create(t);return e[t[0]="UNKNOWN_PARSER"]=0,e[t[1]="MUSIC21"]=1,e[t[2]="PRETTY_MIDI"]=2,e[t[3]="MAGENTA_MUSIC_XML"]=3,e[t[4]="MAGENTA_MUSICNET"]=4,e[t[5]="MAGENTA_ABC"]=5,e[t[6]="TONEJS_MIDI_CONVERT"]=6,e}(),t}(),t.TextAnnotation=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.time=0,t.prototype.quantizedStep=u.Long?u.Long.fromBits(0,0,!1):0,t.prototype.text="",t.prototype.annotationType=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.time&&t.hasOwnProperty("time")&&e.uint32(9).double(t.time),null!=t.text&&t.hasOwnProperty("text")&&e.uint32(18).string(t.text),null!=t.annotationType&&t.hasOwnProperty("annotationType")&&e.uint32(24).int32(t.annotationType),null!=t.quantizedStep&&t.hasOwnProperty("quantizedStep")&&e.uint32(32).int64(t.quantizedStep),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence.TextAnnotation;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.time=t.double();break;case 4:r.quantizedStep=u.Long?t.int64().toNumber():t.int64();break;case 2:r.text=t.string();break;case 3:r.annotationType=t.int32();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.time&&t.hasOwnProperty("time")&&"number"!=typeof t.time)return"time: number expected";if(null!=t.quantizedStep&&t.hasOwnProperty("quantizedStep")&&!(u.isInteger(t.quantizedStep)||t.quantizedStep&&u.isInteger(t.quantizedStep.low)&&u.isInteger(t.quantizedStep.high)))return"quantizedStep: integer|Long expected";if(null!=t.text&&t.hasOwnProperty("text")&&!u.isString(t.text))return"text: string expected";if(null!=t.annotationType&&t.hasOwnProperty("annotationType"))switch(t.annotationType){default:return"annotationType: enum value expected";case 0:case 1:case 2:}return null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence.TextAnnotation)return t;var e=new c.tensorflow.magenta.NoteSequence.TextAnnotation;switch(null!=t.time&&(e.time=Number(t.time)),null!=t.quantizedStep&&(u.Long?(e.quantizedStep=u.Long.fromValue(t.quantizedStep)).unsigned=!1:"string"==typeof t.quantizedStep?e.quantizedStep=parseInt(t.quantizedStep,10):"number"==typeof t.quantizedStep?e.quantizedStep=t.quantizedStep:"object"==typeof t.quantizedStep&&(e.quantizedStep=new u.LongBits(t.quantizedStep.low>>>0,t.quantizedStep.high>>>0).toNumber())),null!=t.text&&(e.text=String(t.text)),t.annotationType){case"UNKNOWN":case 0:e.annotationType=0;break;case"CHORD_SYMBOL":case 1:e.annotationType=1;break;case"BEAT":case 2:e.annotationType=2}return e},t.toObject=function(t,e){e||(e={});var n={};if(e.defaults)if(n.time=0,n.text="",n.annotationType=e.enums===String?"UNKNOWN":0,u.Long){var r=new u.Long(0,0,!1);n.quantizedStep=e.longs===String?r.toString():e.longs===Number?r.toNumber():r}else n.quantizedStep=e.longs===String?"0":0;return null!=t.time&&t.hasOwnProperty("time")&&(n.time=e.json&&!isFinite(t.time)?String(t.time):t.time),null!=t.text&&t.hasOwnProperty("text")&&(n.text=t.text),null!=t.annotationType&&t.hasOwnProperty("annotationType")&&(n.annotationType=e.enums===String?c.tensorflow.magenta.NoteSequence.TextAnnotation.TextAnnotationType[t.annotationType]:t.annotationType),null!=t.quantizedStep&&t.hasOwnProperty("quantizedStep")&&("number"==typeof t.quantizedStep?n.quantizedStep=e.longs===String?String(t.quantizedStep):t.quantizedStep:n.quantizedStep=e.longs===String?u.Long.prototype.toString.call(t.quantizedStep):e.longs===Number?new u.LongBits(t.quantizedStep.low>>>0,t.quantizedStep.high>>>0).toNumber():t.quantizedStep),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t.TextAnnotationType=function(){var t={},e=Object.create(t);return e[t[0]="UNKNOWN"]=0,e[t[1]="CHORD_SYMBOL"]=1,e[t[2]="BEAT"]=2,e}(),t}(),t.QuantizationInfo=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}var e;return t.prototype.stepsPerQuarter=0,t.prototype.stepsPerSecond=0,Object.defineProperty(t.prototype,"resolution",{get:u.oneOfGetter(e=["stepsPerQuarter","stepsPerSecond"]),set:u.oneOfSetter(e)}),t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.stepsPerQuarter&&t.hasOwnProperty("stepsPerQuarter")&&e.uint32(8).int32(t.stepsPerQuarter),null!=t.stepsPerSecond&&t.hasOwnProperty("stepsPerSecond")&&e.uint32(16).int32(t.stepsPerSecond),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence.QuantizationInfo;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.stepsPerQuarter=t.int32();break;case 2:r.stepsPerSecond=t.int32();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";var e={};if(null!=t.stepsPerQuarter&&t.hasOwnProperty("stepsPerQuarter")&&(e.resolution=1,!u.isInteger(t.stepsPerQuarter)))return"stepsPerQuarter: integer expected";if(null!=t.stepsPerSecond&&t.hasOwnProperty("stepsPerSecond")){if(1===e.resolution)return"resolution: multiple values";if(e.resolution=1,!u.isInteger(t.stepsPerSecond))return"stepsPerSecond: integer expected"}return null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence.QuantizationInfo)return t;var e=new c.tensorflow.magenta.NoteSequence.QuantizationInfo;return null!=t.stepsPerQuarter&&(e.stepsPerQuarter=0|t.stepsPerQuarter),null!=t.stepsPerSecond&&(e.stepsPerSecond=0|t.stepsPerSecond),e},t.toObject=function(t,e){e||(e={});var n={};return null!=t.stepsPerQuarter&&t.hasOwnProperty("stepsPerQuarter")&&(n.stepsPerQuarter=t.stepsPerQuarter,e.oneofs&&(n.resolution="stepsPerQuarter")),null!=t.stepsPerSecond&&t.hasOwnProperty("stepsPerSecond")&&(n.stepsPerSecond=t.stepsPerSecond,e.oneofs&&(n.resolution="stepsPerSecond")),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),t.SubsequenceInfo=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.startTimeOffset=0,t.prototype.endTimeOffset=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.startTimeOffset&&t.hasOwnProperty("startTimeOffset")&&e.uint32(9).double(t.startTimeOffset),null!=t.endTimeOffset&&t.hasOwnProperty("endTimeOffset")&&e.uint32(17).double(t.endTimeOffset),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence.SubsequenceInfo;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.startTimeOffset=t.double();break;case 2:r.endTimeOffset=t.double();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.startTimeOffset&&t.hasOwnProperty("startTimeOffset")&&"number"!=typeof t.startTimeOffset?"startTimeOffset: number expected":null!=t.endTimeOffset&&t.hasOwnProperty("endTimeOffset")&&"number"!=typeof t.endTimeOffset?"endTimeOffset: number expected":null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence.SubsequenceInfo)return t;var e=new c.tensorflow.magenta.NoteSequence.SubsequenceInfo;return null!=t.startTimeOffset&&(e.startTimeOffset=Number(t.startTimeOffset)),null!=t.endTimeOffset&&(e.endTimeOffset=Number(t.endTimeOffset)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.startTimeOffset=0,n.endTimeOffset=0),null!=t.startTimeOffset&&t.hasOwnProperty("startTimeOffset")&&(n.startTimeOffset=e.json&&!isFinite(t.startTimeOffset)?String(t.startTimeOffset):t.startTimeOffset),null!=t.endTimeOffset&&t.hasOwnProperty("endTimeOffset")&&(n.endTimeOffset=e.json&&!isFinite(t.endTimeOffset)?String(t.endTimeOffset):t.endTimeOffset),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),t.SectionAnnotation=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.time=0,t.prototype.sectionId=u.Long?u.Long.fromBits(0,0,!1):0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.time&&t.hasOwnProperty("time")&&e.uint32(9).double(t.time),null!=t.sectionId&&t.hasOwnProperty("sectionId")&&e.uint32(32).int64(t.sectionId),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence.SectionAnnotation;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.time=t.double();break;case 4:r.sectionId=u.Long?t.int64().toNumber():t.int64();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.time&&t.hasOwnProperty("time")&&"number"!=typeof t.time?"time: number expected":null!=t.sectionId&&t.hasOwnProperty("sectionId")&&!(u.isInteger(t.sectionId)||t.sectionId&&u.isInteger(t.sectionId.low)&&u.isInteger(t.sectionId.high))?"sectionId: integer|Long expected":null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence.SectionAnnotation)return t;var e=new c.tensorflow.magenta.NoteSequence.SectionAnnotation;return null!=t.time&&(e.time=Number(t.time)),null!=t.sectionId&&(u.Long?(e.sectionId=u.Long.fromValue(t.sectionId)).unsigned=!1:"string"==typeof t.sectionId?e.sectionId=parseInt(t.sectionId,10):"number"==typeof t.sectionId?e.sectionId=t.sectionId:"object"==typeof t.sectionId&&(e.sectionId=new u.LongBits(t.sectionId.low>>>0,t.sectionId.high>>>0).toNumber())),e},t.toObject=function(t,e){e||(e={});var n={};if(e.defaults)if(n.time=0,u.Long){var r=new u.Long(0,0,!1);n.sectionId=e.longs===String?r.toString():e.longs===Number?r.toNumber():r}else n.sectionId=e.longs===String?"0":0;return null!=t.time&&t.hasOwnProperty("time")&&(n.time=e.json&&!isFinite(t.time)?String(t.time):t.time),null!=t.sectionId&&t.hasOwnProperty("sectionId")&&("number"==typeof t.sectionId?n.sectionId=e.longs===String?String(t.sectionId):t.sectionId:n.sectionId=e.longs===String?u.Long.prototype.toString.call(t.sectionId):e.longs===Number?new u.LongBits(t.sectionId.low>>>0,t.sectionId.high>>>0).toNumber():t.sectionId),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),t.Section=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}var e;return t.prototype.sectionId=u.Long?u.Long.fromBits(0,0,!1):0,t.prototype.sectionGroup=null,Object.defineProperty(t.prototype,"sectionType",{get:u.oneOfGetter(e=["sectionId","sectionGroup"]),set:u.oneOfSetter(e)}),t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.sectionId&&t.hasOwnProperty("sectionId")&&e.uint32(8).int64(t.sectionId),null!=t.sectionGroup&&t.hasOwnProperty("sectionGroup")&&c.tensorflow.magenta.NoteSequence.SectionGroup.encode(t.sectionGroup,e.uint32(18).fork()).ldelim(),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence.Section;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.sectionId=u.Long?t.int64().toNumber():t.int64();break;case 2:r.sectionGroup=c.tensorflow.magenta.NoteSequence.SectionGroup.decode(t,t.uint32());break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";var e={};if(null!=t.sectionId&&t.hasOwnProperty("sectionId")&&(e.sectionType=1,!(u.isInteger(t.sectionId)||t.sectionId&&u.isInteger(t.sectionId.low)&&u.isInteger(t.sectionId.high))))return"sectionId: integer|Long expected";if(null!=t.sectionGroup&&t.hasOwnProperty("sectionGroup")){if(1===e.sectionType)return"sectionType: multiple values";e.sectionType=1;var n=c.tensorflow.magenta.NoteSequence.SectionGroup.verify(t.sectionGroup);if(n)return"sectionGroup."+n}return null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence.Section)return t;var e=new c.tensorflow.magenta.NoteSequence.Section;if(null!=t.sectionId&&(u.Long?(e.sectionId=u.Long.fromValue(t.sectionId)).unsigned=!1:"string"==typeof t.sectionId?e.sectionId=parseInt(t.sectionId,10):"number"==typeof t.sectionId?e.sectionId=t.sectionId:"object"==typeof t.sectionId&&(e.sectionId=new u.LongBits(t.sectionId.low>>>0,t.sectionId.high>>>0).toNumber())),null!=t.sectionGroup){if("object"!=typeof t.sectionGroup)throw TypeError(".tensorflow.magenta.NoteSequence.Section.sectionGroup: object expected");e.sectionGroup=c.tensorflow.magenta.NoteSequence.SectionGroup.fromObject(t.sectionGroup)}return e},t.toObject=function(t,e){e||(e={});var n={};return null!=t.sectionId&&t.hasOwnProperty("sectionId")&&("number"==typeof t.sectionId?n.sectionId=e.longs===String?String(t.sectionId):t.sectionId:n.sectionId=e.longs===String?u.Long.prototype.toString.call(t.sectionId):e.longs===Number?new u.LongBits(t.sectionId.low>>>0,t.sectionId.high>>>0).toNumber():t.sectionId,e.oneofs&&(n.sectionType="sectionId")),null!=t.sectionGroup&&t.hasOwnProperty("sectionGroup")&&(n.sectionGroup=c.tensorflow.magenta.NoteSequence.SectionGroup.toObject(t.sectionGroup,e),e.oneofs&&(n.sectionType="sectionGroup")),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),t.SectionGroup=function(){function t(t){if(this.sections=[],t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.sections=u.emptyArray,t.prototype.numTimes=0,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=o.create()),null!=t.sections&&t.sections.length)for(var n=0;n<t.sections.length;++n)c.tensorflow.magenta.NoteSequence.Section.encode(t.sections[n],e.uint32(10).fork()).ldelim();return null!=t.numTimes&&t.hasOwnProperty("numTimes")&&e.uint32(16).int32(t.numTimes),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.NoteSequence.SectionGroup;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.sections&&r.sections.length||(r.sections=[]),r.sections.push(c.tensorflow.magenta.NoteSequence.Section.decode(t,t.uint32()));break;case 2:r.numTimes=t.int32();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.sections&&t.hasOwnProperty("sections")){if(!Array.isArray(t.sections))return"sections: array expected";for(var e=0;e<t.sections.length;++e){var n=c.tensorflow.magenta.NoteSequence.Section.verify(t.sections[e]);if(n)return"sections."+n}}return null!=t.numTimes&&t.hasOwnProperty("numTimes")&&!u.isInteger(t.numTimes)?"numTimes: integer expected":null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.NoteSequence.SectionGroup)return t;var e=new c.tensorflow.magenta.NoteSequence.SectionGroup;if(t.sections){if(!Array.isArray(t.sections))throw TypeError(".tensorflow.magenta.NoteSequence.SectionGroup.sections: array expected");e.sections=[];for(var n=0;n<t.sections.length;++n){if("object"!=typeof t.sections[n])throw TypeError(".tensorflow.magenta.NoteSequence.SectionGroup.sections: object expected");e.sections[n]=c.tensorflow.magenta.NoteSequence.Section.fromObject(t.sections[n])}}return null!=t.numTimes&&(e.numTimes=0|t.numTimes),e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.sections=[]),e.defaults&&(n.numTimes=0),t.sections&&t.sections.length){n.sections=[];for(var r=0;r<t.sections.length;++r)n.sections[r]=c.tensorflow.magenta.NoteSequence.Section.toObject(t.sections[r],e)}return null!=t.numTimes&&t.hasOwnProperty("numTimes")&&(n.numTimes=t.numTimes),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),t}(),r.SequenceMetadata=function(){function t(t){if(this.genre=[],this.composers=[],t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.title="",t.prototype.artist="",t.prototype.genre=u.emptyArray,t.prototype.composers=u.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=o.create()),null!=t.title&&t.hasOwnProperty("title")&&e.uint32(10).string(t.title),null!=t.artist&&t.hasOwnProperty("artist")&&e.uint32(18).string(t.artist),null!=t.genre&&t.genre.length)for(var n=0;n<t.genre.length;++n)e.uint32(26).string(t.genre[n]);if(null!=t.composers&&t.composers.length)for(n=0;n<t.composers.length;++n)e.uint32(34).string(t.composers[n]);return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.SequenceMetadata;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.title=t.string();break;case 2:r.artist=t.string();break;case 3:r.genre&&r.genre.length||(r.genre=[]),r.genre.push(t.string());break;case 4:r.composers&&r.composers.length||(r.composers=[]),r.composers.push(t.string());break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.title&&t.hasOwnProperty("title")&&!u.isString(t.title))return"title: string expected";if(null!=t.artist&&t.hasOwnProperty("artist")&&!u.isString(t.artist))return"artist: string expected";if(null!=t.genre&&t.hasOwnProperty("genre")){if(!Array.isArray(t.genre))return"genre: array expected";for(var e=0;e<t.genre.length;++e)if(!u.isString(t.genre[e]))return"genre: string[] expected"}if(null!=t.composers&&t.hasOwnProperty("composers")){if(!Array.isArray(t.composers))return"composers: array expected";for(e=0;e<t.composers.length;++e)if(!u.isString(t.composers[e]))return"composers: string[] expected"}return null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.SequenceMetadata)return t;var e=new c.tensorflow.magenta.SequenceMetadata;if(null!=t.title&&(e.title=String(t.title)),null!=t.artist&&(e.artist=String(t.artist)),t.genre){if(!Array.isArray(t.genre))throw TypeError(".tensorflow.magenta.SequenceMetadata.genre: array expected");e.genre=[];for(var n=0;n<t.genre.length;++n)e.genre[n]=String(t.genre[n])}if(t.composers){if(!Array.isArray(t.composers))throw TypeError(".tensorflow.magenta.SequenceMetadata.composers: array expected");for(e.composers=[],n=0;n<t.composers.length;++n)e.composers[n]=String(t.composers[n])}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.genre=[],n.composers=[]),e.defaults&&(n.title="",n.artist=""),null!=t.title&&t.hasOwnProperty("title")&&(n.title=t.title),null!=t.artist&&t.hasOwnProperty("artist")&&(n.artist=t.artist),t.genre&&t.genre.length){n.genre=[];for(var r=0;r<t.genre.length;++r)n.genre[r]=t.genre[r]}if(t.composers&&t.composers.length)for(n.composers=[],r=0;r<t.composers.length;++r)n.composers[r]=t.composers[r];return n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),r.VelocityRange=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.min=0,t.prototype.max=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.min&&t.hasOwnProperty("min")&&e.uint32(8).int32(t.min),null!=t.max&&t.hasOwnProperty("max")&&e.uint32(16).int32(t.max),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof a||(t=a.create(t));for(var n=void 0===e?t.len:t.pos+e,r=new c.tensorflow.magenta.VelocityRange;t.pos<n;){var i=t.uint32();switch(i>>>3){case 1:r.min=t.int32();break;case 2:r.max=t.int32();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.min&&t.hasOwnProperty("min")&&!u.isInteger(t.min)?"min: integer expected":null!=t.max&&t.hasOwnProperty("max")&&!u.isInteger(t.max)?"max: integer expected":null},t.fromObject=function(t){if(t instanceof c.tensorflow.magenta.VelocityRange)return t;var e=new c.tensorflow.magenta.VelocityRange;return null!=t.min&&(e.min=0|t.min),null!=t.max&&(e.max=0|t.max),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.min=0,n.max=0),null!=t.min&&t.hasOwnProperty("min")&&(n.min=t.min),null!=t.max&&t.hasOwnProperty("max")&&(n.max=t.max),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),r),i),t.exports=c},function(t,e,n){"use strict";t.exports=n(316)},function(t,e,n){"use strict";var r=e;function i(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}r.build="minimal",r.Writer=n(256),r.BufferWriter=n(325),r.Reader=n(257),r.BufferReader=n(326),r.util=n(110),r.rpc=n(327),r.roots=n(329),r.configure=i,i()},function(t,e,n){"use strict";t.exports=function(t,e){var n=new Array(arguments.length-1),r=0,i=2,s=!0;for(;i<arguments.length;)n[r++]=arguments[i++];return new Promise((function(i,a){n[r]=function(t){if(s)if(s=!1,t)a(t);else{for(var e=new Array(arguments.length-1),n=0;n<e.length;)e[n++]=arguments[n];i.apply(null,e)}};try{t.apply(e||null,n)}catch(t){s&&(s=!1,a(t))}}))}},function(t,e,n){"use strict";var r=e;r.length=function(t){var e=t.length;if(!e)return 0;for(var n=0;--e%4>1&&"="===t.charAt(e);)++n;return Math.ceil(3*t.length)/4-n};for(var i=new Array(64),s=new Array(123),a=0;a<64;)s[i[a]=a<26?a+65:a<52?a+71:a<62?a-4:a-59|43]=a++;r.encode=function(t,e,n){for(var r,s=null,a=[],o=0,u=0;e<n;){var c=t[e++];switch(u){case 0:a[o++]=i[c>>2],r=(3&c)<<4,u=1;break;case 1:a[o++]=i[r|c>>4],r=(15&c)<<2,u=2;break;case 2:a[o++]=i[r|c>>6],a[o++]=i[63&c],u=0}o>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,a)),o=0)}return u&&(a[o++]=i[r],a[o++]=61,1===u&&(a[o++]=61)),s?(o&&s.push(String.fromCharCode.apply(String,a.slice(0,o))),s.join("")):String.fromCharCode.apply(String,a.slice(0,o))};r.decode=function(t,e,n){for(var r,i=n,a=0,o=0;o<t.length;){var u=t.charCodeAt(o++);if(61===u&&a>1)break;if(void 0===(u=s[u]))throw Error("invalid encoding");switch(a){case 0:r=u,a=1;break;case 1:e[n++]=r<<2|(48&u)>>4,r=u,a=2;break;case 2:e[n++]=(15&r)<<4|(60&u)>>2,r=u,a=3;break;case 3:e[n++]=(3&r)<<6|u,a=0}}if(1===a)throw Error("invalid encoding");return n-i},r.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}},function(t,e,n){"use strict";function r(){this._listeners={}}t.exports=r,r.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this},r.prototype.off=function(t,e){if(void 0===t)this._listeners={};else if(void 0===e)this._listeners[t]=[];else for(var n=this._listeners[t],r=0;r<n.length;)n[r].fn===e?n.splice(r,1):++r;return this},r.prototype.emit=function(t){var e=this._listeners[t];if(e){for(var n=[],r=1;r<arguments.length;)n.push(arguments[r++]);for(r=0;r<e.length;)e[r].fn.apply(e[r++].ctx,n)}return this}},function(t,e,n){"use strict";function r(t){return"undefined"!=typeof Float32Array?function(){var e=new Float32Array([-0]),n=new Uint8Array(e.buffer),r=128===n[3];function i(t,r,i){e[0]=t,r[i]=n[0],r[i+1]=n[1],r[i+2]=n[2],r[i+3]=n[3]}function s(t,r,i){e[0]=t,r[i]=n[3],r[i+1]=n[2],r[i+2]=n[1],r[i+3]=n[0]}function a(t,r){return n[0]=t[r],n[1]=t[r+1],n[2]=t[r+2],n[3]=t[r+3],e[0]}function o(t,r){return n[3]=t[r],n[2]=t[r+1],n[1]=t[r+2],n[0]=t[r+3],e[0]}t.writeFloatLE=r?i:s,t.writeFloatBE=r?s:i,t.readFloatLE=r?a:o,t.readFloatBE=r?o:a}():function(){function e(t,e,n,r){var i=e<0?1:0;if(i&&(e=-e),0===e)t(1/e>0?0:2147483648,n,r);else if(isNaN(e))t(2143289344,n,r);else if(e>34028234663852886e22)t((i<<31|2139095040)>>>0,n,r);else if(e<11754943508222875e-54)t((i<<31|Math.round(e/1401298464324817e-60))>>>0,n,r);else{var s=Math.floor(Math.log(e)/Math.LN2);t((i<<31|s+127<<23|8388607&Math.round(e*Math.pow(2,-s)*8388608))>>>0,n,r)}}function n(t,e,n){var r=t(e,n),i=2*(r>>31)+1,s=r>>>23&255,a=8388607&r;return 255===s?a?NaN:i*(1/0):0===s?1401298464324817e-60*i*a:i*Math.pow(2,s-150)*(a+8388608)}t.writeFloatLE=e.bind(null,i),t.writeFloatBE=e.bind(null,s),t.readFloatLE=n.bind(null,a),t.readFloatBE=n.bind(null,o)}(),"undefined"!=typeof Float64Array?function(){var e=new Float64Array([-0]),n=new Uint8Array(e.buffer),r=128===n[7];function i(t,r,i){e[0]=t,r[i]=n[0],r[i+1]=n[1],r[i+2]=n[2],r[i+3]=n[3],r[i+4]=n[4],r[i+5]=n[5],r[i+6]=n[6],r[i+7]=n[7]}function s(t,r,i){e[0]=t,r[i]=n[7],r[i+1]=n[6],r[i+2]=n[5],r[i+3]=n[4],r[i+4]=n[3],r[i+5]=n[2],r[i+6]=n[1],r[i+7]=n[0]}function a(t,r){return n[0]=t[r],n[1]=t[r+1],n[2]=t[r+2],n[3]=t[r+3],n[4]=t[r+4],n[5]=t[r+5],n[6]=t[r+6],n[7]=t[r+7],e[0]}function o(t,r){return n[7]=t[r],n[6]=t[r+1],n[5]=t[r+2],n[4]=t[r+3],n[3]=t[r+4],n[2]=t[r+5],n[1]=t[r+6],n[0]=t[r+7],e[0]}t.writeDoubleLE=r?i:s,t.writeDoubleBE=r?s:i,t.readDoubleLE=r?a:o,t.readDoubleBE=r?o:a}():function(){function e(t,e,n,r,i,s){var a=r<0?1:0;if(a&&(r=-r),0===r)t(0,i,s+e),t(1/r>0?0:2147483648,i,s+n);else if(isNaN(r))t(0,i,s+e),t(2146959360,i,s+n);else if(r>17976931348623157e292)t(0,i,s+e),t((a<<31|2146435072)>>>0,i,s+n);else{var o;if(r<22250738585072014e-324)t((o=r/5e-324)>>>0,i,s+e),t((a<<31|o/4294967296)>>>0,i,s+n);else{var u=Math.floor(Math.log(r)/Math.LN2);1024===u&&(u=1023),t(4503599627370496*(o=r*Math.pow(2,-u))>>>0,i,s+e),t((a<<31|u+1023<<20|1048576*o&1048575)>>>0,i,s+n)}}}function n(t,e,n,r,i){var s=t(r,i+e),a=t(r,i+n),o=2*(a>>31)+1,u=a>>>20&2047,c=4294967296*(1048575&a)+s;return 2047===u?c?NaN:o*(1/0):0===u?5e-324*o*c:o*Math.pow(2,u-1075)*(c+4503599627370496)}t.writeDoubleLE=e.bind(null,i,0,4),t.writeDoubleBE=e.bind(null,s,4,0),t.readDoubleLE=n.bind(null,a,0,4),t.readDoubleBE=n.bind(null,o,4,0)}(),t}function i(t,e,n){e[n]=255&t,e[n+1]=t>>>8&255,e[n+2]=t>>>16&255,e[n+3]=t>>>24}function s(t,e,n){e[n]=t>>>24,e[n+1]=t>>>16&255,e[n+2]=t>>>8&255,e[n+3]=255&t}function a(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function o(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}t.exports=r(r)},function(module,exports,__webpack_require__){"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(t){}return null}module.exports=inquire},function(t,e,n){"use strict";var r=e;r.length=function(t){for(var e=0,n=0,r=0;r<t.length;++r)(n=t.charCodeAt(r))<128?e+=1:n<2048?e+=2:55296==(64512&n)&&56320==(64512&t.charCodeAt(r+1))?(++r,e+=4):e+=3;return e},r.read=function(t,e,n){if(n-e<1)return"";for(var r,i=null,s=[],a=0;e<n;)(r=t[e++])<128?s[a++]=r:r>191&&r<224?s[a++]=(31&r)<<6|63&t[e++]:r>239&&r<365?(r=((7&r)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,s[a++]=55296+(r>>10),s[a++]=56320+(1023&r)):s[a++]=(15&r)<<12|(63&t[e++])<<6|63&t[e++],a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),a=0);return i?(a&&i.push(String.fromCharCode.apply(String,s.slice(0,a))),i.join("")):String.fromCharCode.apply(String,s.slice(0,a))},r.write=function(t,e,n){for(var r,i,s=n,a=0;a<t.length;++a)(r=t.charCodeAt(a))<128?e[n++]=r:r<2048?(e[n++]=r>>6|192,e[n++]=63&r|128):55296==(64512&r)&&56320==(64512&(i=t.charCodeAt(a+1)))?(r=65536+((1023&r)<<10)+(1023&i),++a,e[n++]=r>>18|240,e[n++]=r>>12&63|128,e[n++]=r>>6&63|128,e[n++]=63&r|128):(e[n++]=r>>12|224,e[n++]=r>>6&63|128,e[n++]=63&r|128);return n-s}},function(t,e,n){"use strict";t.exports=function(t,e,n){var r=n||8192,i=r>>>1,s=null,a=r;return function(n){if(n<1||n>i)return t(n);a+n>r&&(s=t(r),a=0);var o=e.call(s,a,a+=n);return 7&a&&(a=1+(7|a)),o}}},function(t,e,n){"use strict";t.exports=i;var r=n(110);function i(t,e){this.lo=t>>>0,this.hi=e>>>0}var s=i.zero=new i(0,0);s.toNumber=function(){return 0},s.zzEncode=s.zzDecode=function(){return this},s.length=function(){return 1};var a=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(t){if(0===t)return s;var e=t<0;e&&(t=-t);var n=t>>>0,r=(t-n)/4294967296>>>0;return e&&(r=~r>>>0,n=~n>>>0,++n>4294967295&&(n=0,++r>4294967295&&(r=0))),new i(n,r)},i.from=function(t){if("number"==typeof t)return i.fromNumber(t);if(r.isString(t)){if(!r.Long)return i.fromNumber(parseInt(t,10));t=r.Long.fromString(t)}return t.low||t.high?new i(t.low>>>0,t.high>>>0):s},i.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var e=1+~this.lo>>>0,n=~this.hi>>>0;return e||(n=n+1>>>0),-(e+4294967296*n)}return this.lo+4294967296*this.hi},i.prototype.toLong=function(t){return r.Long?new r.Long(0|this.lo,0|this.hi,Boolean(t)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(t)}};var o=String.prototype.charCodeAt;i.fromHash=function(t){return t===a?s:new i((o.call(t,0)|o.call(t,1)<<8|o.call(t,2)<<16|o.call(t,3)<<24)>>>0,(o.call(t,4)|o.call(t,5)<<8|o.call(t,6)<<16|o.call(t,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this},i.prototype.zzDecode=function(){var t=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this},i.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===e?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}},function(t,e,n){"use strict";t.exports=s;var r=n(256);(s.prototype=Object.create(r.prototype)).constructor=s;var i=n(110);function s(){r.call(this)}function a(t,e,n){t.length<40?i.utf8.write(t,e,n):e.utf8Write?e.utf8Write(t,n):e.write(t,n)}s._configure=function(){s.alloc=i._Buffer_allocUnsafe,s.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&"set"===i.Buffer.prototype.set.name?function(t,e,n){e.set(t,n)}:function(t,e,n){if(t.copy)t.copy(e,n,0,t.length);else for(var r=0;r<t.length;)e[n++]=t[r++]}},s.prototype.bytes=function(t){i.isString(t)&&(t=i._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(s.writeBytesBuffer,e,t),this},s.prototype.string=function(t){var e=i.Buffer.byteLength(t);return this.uint32(e),e&&this._push(a,e,t),this},s._configure()},function(t,e,n){"use strict";t.exports=s;var r=n(257);(s.prototype=Object.create(r.prototype)).constructor=s;var i=n(110);function s(t){r.call(this,t)}s._configure=function(){i.Buffer&&(s.prototype._slice=i.Buffer.prototype.slice)},s.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))},s._configure()},function(t,e,n){"use strict";e.Service=n(328)},function(t,e,n){"use strict";t.exports=i;var r=n(110);function i(t,e,n){if("function"!=typeof t)throw TypeError("rpcImpl must be a function");r.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=Boolean(e),this.responseDelimited=Boolean(n)}(i.prototype=Object.create(r.EventEmitter.prototype)).constructor=i,i.prototype.rpcCall=function t(e,n,i,s,a){if(!s)throw TypeError("request must be specified");var o=this;if(!a)return r.asPromise(t,o,e,n,i,s);if(o.rpcImpl)try{return o.rpcImpl(e,n[o.requestDelimited?"encodeDelimited":"encode"](s).finish(),(function(t,n){if(t)return o.emit("error",t,e),a(t);if(null!==n){if(!(n instanceof i))try{n=i[o.responseDelimited?"decodeDelimited":"decode"](n)}catch(t){return o.emit("error",t,e),a(t)}return o.emit("data",n,e),a(null,n)}o.end(!0)}))}catch(t){return o.emit("error",t,e),void setTimeout((function(){a(t)}),0)}else setTimeout((function(){a(Error("already ended"))}),0)},i.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},function(t,e,n){"use strict";t.exports={}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Metronome=e.MetronomeCallbackObject=void 0;var r=n(120),i=function(){};e.MetronomeCallbackObject=i;var s=function(){function t(t,e){void 0===e&&(e=1),this.clicksPerQuarter=1,this.muted=!1,this.loClick=new r.MembraneSynth({pitchDecay:.008,envelope:{attack:.001,decay:.3,sustain:0}}).toDestination(),this.hiClick=new r.MembraneSynth({pitchDecay:.008,envelope:{attack:.001,decay:.3,sustain:0}}).toDestination(),this.loClickNote="c5",this.hiClickNote="g5",this.ticking=!1,this.startedAt=null,this.step=-1,this.reset(),this.callbackObject=t,this.clicksPerQuarter=e}return t.prototype.isTicking=function(){return this.ticking},t.prototype.getStartedAt=function(){return this.startedAt},t.prototype.getOffsetTime=function(){return r.immediate()-this.startedAt},t.prototype.start=function(t){var e=this;void 0===t&&(t=120),this.reset(),this.ticking=!0,this.callbackObject.click||(this.callbackObject.click=function(){}),this.callbackObject.quarter||(this.callbackObject.quarter=function(){}),this.callbackObject.bar||(this.callbackObject.bar=function(){});var n=0,i=4*this.clicksPerQuarter;r.Transport.scheduleRepeat((function(t){e.startedAt||(e.startedAt=t);var r=t-e.startedAt;e.step++;var s=e.step%i,a=Math.floor(s/e.clicksPerQuarter),o=s%e.clicksPerQuarter;e.callbackObject.click(r,s),0===o&&e.callbackObject.quarter(r,a),e.muted||(0===s?e.hiClick.triggerAttack(e.hiClickNote,t,.1):e.loClick.triggerAttack(e.loClickNote,t,.1)),0===s&&(e.callbackObject.bar(r,n),n++)}),i+"n"),r.Transport.bpm.value=t,r.Transport.start()},t.prototype.stop=function(){this.ticking=!1,r.Transport.cancel(),r.Transport.stop()},t.prototype.reset=function(){this.muted=!1,this.ticking=!1,this.step=-1,this.startedAt=null},t}();e.Metronome=s},function(t,e,n){var r=n(332),i=n(333),s=n(334),a=n(336);t.exports=function(t,e){return r(t)||i(t,e)||s(t,e)||a()}},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],r=!0,i=!1,s=void 0;try{for(var a,o=t[Symbol.iterator]();!(r=(a=o.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,s=t}finally{try{r||null==o.return||o.return()}finally{if(i)throw s}}return n}}},function(t,e,n){var r=n(335);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.urlToNoteSequence=e.blobToNoteSequence=e.urlToBlob=e.sequenceProtoToMidi=e.midiToSequenceProto=e.MidiConversionError=void 0;var s=n(340),a=n(61),o=n(79),u=n(67),c=n(92),l=function(t){function e(e){var n=this.constructor,r=t.call(this,e)||this;return Object.setPrototypeOf(r,n.prototype),r}return i(e,t),e}(Error);function h(t){var e=new s.Midi(t),n=o.NoteSequence.create();n.ticksPerQuarter=e.header.ppq,n.sourceInfo=o.NoteSequence.SourceInfo.create({parser:o.NoteSequence.SourceInfo.Parser.TONEJS_MIDI_CONVERT,encodingType:o.NoteSequence.SourceInfo.EncodingType.MIDI});for(var r=0,i=e.header.timeSignatures;r<i.length;r++){var a=i[r];n.timeSignatures.push(o.NoteSequence.TimeSignature.create({time:e.header.ticksToSeconds(a.ticks),numerator:a.timeSignature[0],denominator:a.timeSignature[1]}))}n.timeSignatures.length||n.timeSignatures.push(o.NoteSequence.TimeSignature.create({time:0,numerator:4,denominator:4}));for(var c=0,l=e.header.tempos;c<l.length;c++){var h=l[c];n.tempos.push(o.NoteSequence.Tempo.create({time:h.time,qpm:h.bpm}))}for(var d=-1,p=0,f=e.tracks;p<f.length;p++){var m=f[p];m.notes.length>0&&(d+=1);for(var g=0,b=m.notes;g<b.length;g++){var y=b[g],v=y.time,w=v+y.duration;n.notes.push(o.NoteSequence.Note.create({instrument:d,program:m.instrument.number,startTime:v,endTime:w,pitch:y.midi,velocity:Math.floor(y.velocity*u.MIDI_VELOCITIES),isDrum:m.instrument.percussion})),w>n.totalTime&&(n.totalTime=w)}for(var x=Object.values(m.controlChanges),_=0,O=[].concat.apply([],x);_<O.length;_++){var S=O[_];n.controlChanges.push(o.NoteSequence.ControlChange.create({time:S.time,controlNumber:S.number,controlValue:Math.floor(S.value*(u.MIDI_VELOCITIES-1)),instrument:d,program:m.instrument.number,isDrum:m.instrument.percussion}))}}return n}function d(t){return new Promise((function(e,n){a.fetch(t).then((function(t){return t.blob()})).then((function(t){e(t)})).catch((function(t){return n(t)}))}))}function p(t){return new Promise((function(e,n){var r=new FileReader;r.onload=function(t){try{var i=h(r.result);e(i)}catch(t){n(t)}},r.onerror=function(t){return n(t)},r.readAsArrayBuffer(t)}))}e.MidiConversionError=l,e.midiToSequenceProto=h,e.sequenceProtoToMidi=function(t){c.isQuantizedSequence(t)&&(t=c.unquantizeSequence(t));var e=new s.Midi;e.fromJSON({header:{name:"",ppq:t.ticksPerQuarter||u.DEFAULT_TICKS_PER_QUARTER,tempos:[],timeSignatures:[],keySignatures:[],meta:[]},tracks:[]});var n=Array.from(t.tempos||[]);0===n.length&&n.push({time:0,qpm:u.DEFAULT_QUARTERS_PER_MINUTE}),n.sort((function(t,e){return t.time-e.time}));for(var r=0,i=n;r<i.length;r++){var a=i[r];e.header.tempos.push({ticks:e.header.secondsToTicks(a.time),bpm:a.qpm}),e.header.update()}if(t.timeSignatures&&0!==t.timeSignatures.length)for(var o=0,l=t.timeSignatures;o<l.length;o++){var h=l[o];e.header.timeSignatures.push({ticks:e.header.secondsToTicks(h.time),timeSignature:[h.numerator,h.denominator]})}else e.header.timeSignatures.push({ticks:0,timeSignature:[4,4]});e.header.update();for(var d=new Map,p=0,f=t.notes;p<f.length;p++){var m=f[p],g=m.instrument?m.instrument:0,b=void 0===m.program?u.DEFAULT_PROGRAM:m.program,y=!!m.isDrum,v=JSON.stringify([g,b,y]);d.has(v)||d.set(v,{notes:[],controlChanges:[]}),d.get(v).notes.push(m)}for(var w=0,x=t.controlChanges;w<x.length;w++){var _=x[w];g=_.instrument?_.instrument:0,b=void 0===_.program?u.DEFAULT_PROGRAM:_.program,y=!!_.isDrum,v=JSON.stringify([g,b,y]);d.has(v)||d.set(v,{notes:[],controlChanges:[]}),d.get(v).controlChanges.push(_)}return d.forEach((function(t,n){var r=JSON.parse(n).slice(1),i=r[0],s=r[1],a=e.addTrack();a.channel=s?u.DRUM_CHANNEL:u.NON_DRUM_CHANNELS[(e.tracks.length-1)%u.NON_DRUM_CHANNELS.length],a.instrument.number=i;for(var o=0,c=t.notes;o<c.length;o++){var l=c[o],h=void 0===l.velocity?u.DEFAULT_VELOCITY:l.velocity;a.addNote({midi:l.pitch,time:l.startTime,duration:l.endTime-l.startTime,velocity:(h+1)/u.MIDI_VELOCITIES})}for(var d=0,p=t.controlChanges;d<p.length;d++){var f=p[d];a.addCC({number:f.controlNumber,value:f.controlValue,time:f.time})}})),e.toArray()},e.urlToBlob=d,e.blobToNoteSequence=p,e.urlToNoteSequence=function(t){return d(t).then(p)}},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0});var s=n(260),a=n(343),o=n(213),u=n(262),c=function(){function t(t){var e=this,n=null;t&&(t instanceof ArrayBuffer&&(t=new Uint8Array(t)),(n=s.parseMidi(t)).tracks.forEach((function(t){var e=0;t.forEach((function(t){e+=t.deltaTime,t.absoluteTime=e}))})),n.tracks=function(t){for(var e=[],n=0;n<t.length;n++)for(var r=e.length,i=new Map,s=Array(16).fill(0),a=0,o=t[n];a<o.length;a++){var u=o[a],c=r,l=u.channel;if(void 0!==l){"programChange"===u.type&&(s[l]=u.programNumber);var h=s[l]+" "+l;i.has(h)?c=i.get(h):(c=r+i.size,i.set(h,c))}e[c]||e.push([]),e[c].push(u)}return e}(n.tracks)),this.header=new o.Header(n),this.tracks=[],t&&(this.tracks=n.tracks.map((function(t){return new u.Track(t,e.header)})),1===n.header.format&&0===this.tracks[0].duration&&this.tracks.shift())}return t.fromUrl=function(e){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,fetch(e)];case 1:return(n=r.sent()).ok?[4,n.arrayBuffer()]:[3,3];case 2:return[2,new t(r.sent())];case 3:throw new Error("could not load "+e)}}))}))},Object.defineProperty(t.prototype,"name",{get:function(){return this.header.name},set:function(t){this.header.name=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"duration",{get:function(){var t=this.tracks.map((function(t){return t.duration}));return Math.max.apply(Math,t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"durationTicks",{get:function(){var t=this.tracks.map((function(t){return t.durationTicks}));return Math.max.apply(Math,t)},enumerable:!0,configurable:!0}),t.prototype.addTrack=function(){var t=new u.Track(void 0,this.header);return this.tracks.push(t),t},t.prototype.toArray=function(){return a.encode(this)},t.prototype.toJSON=function(){return{header:this.header.toJSON(),tracks:this.tracks.map((function(t){return t.toJSON()}))}},t.prototype.fromJSON=function(t){var e=this;this.header=new o.Header,this.header.fromJSON(t.header),this.tracks=t.tracks.map((function(t){var n=new u.Track(void 0,e.header);return n.fromJSON(t),n}))},t.prototype.clone=function(){var e=new t;return e.fromJSON(this.toJSON()),e},t}();e.Midi=c;var l=n(262);e.Track=l.Track;var h=n(213);e.Header=h.Header},function(t,e){function n(t){for(var e,n=new r(t),i=[];!n.eof();){var s=a();i.push(s)}return i;function a(){var t={};t.deltaTime=n.readVarInt();var r=n.readUInt8();if(240==(240&r)){if(255!==r){if(240==r){t.type="sysEx";s=n.readVarInt();return t.data=n.readBytes(s),t}if(247==r){t.type="endSysEx";s=n.readVarInt();return t.data=n.readBytes(s),t}throw"Unrecognised MIDI event type byte: "+r}t.meta=!0;var i=n.readUInt8(),s=n.readVarInt();switch(i){case 0:if(t.type="sequenceNumber",2!==s)throw"Expected length for sequenceNumber event is 2, got "+s;return t.number=n.readUInt16(),t;case 1:return t.type="text",t.text=n.readString(s),t;case 2:return t.type="copyrightNotice",t.text=n.readString(s),t;case 3:return t.type="trackName",t.text=n.readString(s),t;case 4:return t.type="instrumentName",t.text=n.readString(s),t;case 5:return t.type="lyrics",t.text=n.readString(s),t;case 6:return t.type="marker",t.text=n.readString(s),t;case 7:return t.type="cuePoint",t.text=n.readString(s),t;case 32:if(t.type="channelPrefix",1!=s)throw"Expected length for channelPrefix event is 1, got "+s;return t.channel=n.readUInt8(),t;case 33:if(t.type="portPrefix",1!=s)throw"Expected length for portPrefix event is 1, got "+s;return t.port=n.readUInt8(),t;case 47:if(t.type="endOfTrack",0!=s)throw"Expected length for endOfTrack event is 0, got "+s;return t;case 81:if(t.type="setTempo",3!=s)throw"Expected length for setTempo event is 3, got "+s;return t.microsecondsPerBeat=n.readUInt24(),t;case 84:if(t.type="smpteOffset",5!=s)throw"Expected length for smpteOffset event is 5, got "+s;var a=n.readUInt8();return t.frameRate={0:24,32:25,64:29,96:30}[96&a],t.hour=31&a,t.min=n.readUInt8(),t.sec=n.readUInt8(),t.frame=n.readUInt8(),t.subFrame=n.readUInt8(),t;case 88:if(t.type="timeSignature",4!=s)throw"Expected length for timeSignature event is 4, got "+s;return t.numerator=n.readUInt8(),t.denominator=1<<n.readUInt8(),t.metronome=n.readUInt8(),t.thirtyseconds=n.readUInt8(),t;case 89:if(t.type="keySignature",2!=s)throw"Expected length for keySignature event is 2, got "+s;return t.key=n.readInt8(),t.scale=n.readUInt8(),t;case 127:return t.type="sequencerSpecific",t.data=n.readBytes(s),t;default:return t.type="unknownMeta",t.data=n.readBytes(s),t.metatypeByte=i,t}}else{var o;if(0==(128&r)){if(null===e)throw"Running status byte encountered before status byte";o=r,r=e,t.running=!0}else o=n.readUInt8(),e=r;var u=r>>4;switch(t.channel=15&r,u){case 8:return t.type="noteOff",t.noteNumber=o,t.velocity=n.readUInt8(),t;case 9:var c=n.readUInt8();return t.type=0===c?"noteOff":"noteOn",t.noteNumber=o,t.velocity=c,0===c&&(t.byte9=!0),t;case 10:return t.type="noteAftertouch",t.noteNumber=o,t.amount=n.readUInt8(),t;case 11:return t.type="controller",t.controllerType=o,t.value=n.readUInt8(),t;case 12:return t.type="programChange",t.programNumber=o,t;case 13:return t.type="channelAftertouch",t.amount=o,t;case 14:return t.type="pitchBend",t.value=o+(n.readUInt8()<<7)-8192,t;default:throw"Unrecognised MIDI event type: "+u}}}}function r(t){this.buffer=t,this.bufferLen=this.buffer.length,this.pos=0}r.prototype.eof=function(){return this.pos>=this.bufferLen},r.prototype.readUInt8=function(){var t=this.buffer[this.pos];return this.pos+=1,t},r.prototype.readInt8=function(){var t=this.readUInt8();return 128&t?t-256:t},r.prototype.readUInt16=function(){return(this.readUInt8()<<8)+this.readUInt8()},r.prototype.readInt16=function(){var t=this.readUInt16();return 32768&t?t-65536:t},r.prototype.readUInt24=function(){return(this.readUInt8()<<16)+(this.readUInt8()<<8)+this.readUInt8()},r.prototype.readInt24=function(){var t=this.readUInt24();return 8388608&t?t-16777216:t},r.prototype.readUInt32=function(){return(this.readUInt8()<<24)+(this.readUInt8()<<16)+(this.readUInt8()<<8)+this.readUInt8()},r.prototype.readBytes=function(t){var e=this.buffer.slice(this.pos,this.pos+t);return this.pos+=t,e},r.prototype.readString=function(t){var e=this.readBytes(t);return String.fromCharCode.apply(null,e)},r.prototype.readVarInt=function(){for(var t=0;!this.eof();){var e=this.readUInt8();if(!(128&e))return t+e;t+=127&e,t<<=7}return t},r.prototype.readChunk=function(){var t=this.readString(4),e=this.readUInt32();return{id:t,length:e,data:this.readBytes(e)}},t.exports=function(t){var e=new r(t),i=e.readChunk();if("MThd"!=i.id)throw"Bad MIDI file.  Expected 'MHdr', got: '"+i.id+"'";for(var s=function(t){var e=new r(t),n=e.readUInt16(),i=e.readUInt16(),s={format:n,numTracks:i},a=e.readUInt16();32768&a?(s.framesPerSecond=256-(a>>8),s.ticksPerFrame=255&a):s.ticksPerBeat=a;return s}(i.data),a=[],o=0;!e.eof()&&o<s.numTracks;o++){var u=e.readChunk();if("MTrk"!=u.id)throw"Bad MIDI file.  Expected 'MTrk', got: '"+u.id+"'";var c=n(u.data);a.push(c)}return{header:s,tracks:a}}},function(t,e){function n(t,e,n){var s,a=new i,o=e.length,u=null;for(s=0;s<o;s++)!1!==n.running&&(n.running||e[s].running)||(u=null),u=r(a,e[s],u,n.useByte9ForNoteOff);t.writeChunk("MTrk",a.buffer)}function r(t,e,n,r){var i=e.type,s=e.deltaTime,a=e.text||"",o=e.data||[],u=null;switch(t.writeVarInt(s),i){case"sequenceNumber":t.writeUInt8(255),t.writeUInt8(0),t.writeVarInt(2),t.writeUInt16(e.number);break;case"text":t.writeUInt8(255),t.writeUInt8(1),t.writeVarInt(a.length),t.writeString(a);break;case"copyrightNotice":t.writeUInt8(255),t.writeUInt8(2),t.writeVarInt(a.length),t.writeString(a);break;case"trackName":t.writeUInt8(255),t.writeUInt8(3),t.writeVarInt(a.length),t.writeString(a);break;case"instrumentName":t.writeUInt8(255),t.writeUInt8(4),t.writeVarInt(a.length),t.writeString(a);break;case"lyrics":t.writeUInt8(255),t.writeUInt8(5),t.writeVarInt(a.length),t.writeString(a);break;case"marker":t.writeUInt8(255),t.writeUInt8(6),t.writeVarInt(a.length),t.writeString(a);break;case"cuePoint":t.writeUInt8(255),t.writeUInt8(7),t.writeVarInt(a.length),t.writeString(a);break;case"channelPrefix":t.writeUInt8(255),t.writeUInt8(32),t.writeVarInt(1),t.writeUInt8(e.channel);break;case"portPrefix":t.writeUInt8(255),t.writeUInt8(33),t.writeVarInt(1),t.writeUInt8(e.port);break;case"endOfTrack":t.writeUInt8(255),t.writeUInt8(47),t.writeVarInt(0);break;case"setTempo":t.writeUInt8(255),t.writeUInt8(81),t.writeVarInt(3),t.writeUInt24(e.microsecondsPerBeat);break;case"smpteOffset":t.writeUInt8(255),t.writeUInt8(84),t.writeVarInt(5);var c=31&e.hour|{24:0,25:32,29:64,30:96}[e.frameRate];t.writeUInt8(c),t.writeUInt8(e.min),t.writeUInt8(e.sec),t.writeUInt8(e.frame),t.writeUInt8(e.subFrame);break;case"timeSignature":t.writeUInt8(255),t.writeUInt8(88),t.writeVarInt(4),t.writeUInt8(e.numerator);var l=255&Math.floor(Math.log(e.denominator)/Math.LN2);t.writeUInt8(l),t.writeUInt8(e.metronome),t.writeUInt8(e.thirtyseconds||8);break;case"keySignature":t.writeUInt8(255),t.writeUInt8(89),t.writeVarInt(2),t.writeInt8(e.key),t.writeUInt8(e.scale);break;case"sequencerSpecific":t.writeUInt8(255),t.writeUInt8(127),t.writeVarInt(o.length),t.writeBytes(o);break;case"unknownMeta":null!=e.metatypeByte&&(t.writeUInt8(255),t.writeUInt8(e.metatypeByte),t.writeVarInt(o.length),t.writeBytes(o));break;case"sysEx":t.writeUInt8(240),t.writeVarInt(o.length),t.writeBytes(o);break;case"endSysEx":t.writeUInt8(247),t.writeVarInt(o.length),t.writeBytes(o);break;case"noteOff":(u=(!1!==r&&e.byte9||r&&0==e.velocity?144:128)|e.channel)!==n&&t.writeUInt8(u),t.writeUInt8(e.noteNumber),t.writeUInt8(e.velocity);break;case"noteOn":(u=144|e.channel)!==n&&t.writeUInt8(u),t.writeUInt8(e.noteNumber),t.writeUInt8(e.velocity);break;case"noteAftertouch":(u=160|e.channel)!==n&&t.writeUInt8(u),t.writeUInt8(e.noteNumber),t.writeUInt8(e.amount);break;case"controller":(u=176|e.channel)!==n&&t.writeUInt8(u),t.writeUInt8(e.controllerType),t.writeUInt8(e.value);break;case"programChange":(u=192|e.channel)!==n&&t.writeUInt8(u),t.writeUInt8(e.programNumber);break;case"channelAftertouch":(u=208|e.channel)!==n&&t.writeUInt8(u),t.writeUInt8(e.amount);break;case"pitchBend":(u=224|e.channel)!==n&&t.writeUInt8(u);var h=8192+e.value,d=127&h,p=h>>7&127;t.writeUInt8(d),t.writeUInt8(p);break;default:throw"Unrecognized event type: "+i}return u}function i(){this.buffer=[]}i.prototype.writeUInt8=function(t){this.buffer.push(255&t)},i.prototype.writeInt8=i.prototype.writeUInt8,i.prototype.writeUInt16=function(t){var e=t>>8&255,n=255&t;this.writeUInt8(e),this.writeUInt8(n)},i.prototype.writeInt16=i.prototype.writeUInt16,i.prototype.writeUInt24=function(t){var e=t>>16&255,n=t>>8&255,r=255&t;this.writeUInt8(e),this.writeUInt8(n),this.writeUInt8(r)},i.prototype.writeInt24=i.prototype.writeUInt24,i.prototype.writeUInt32=function(t){var e=t>>24&255,n=t>>16&255,r=t>>8&255,i=255&t;this.writeUInt8(e),this.writeUInt8(n),this.writeUInt8(r),this.writeUInt8(i)},i.prototype.writeInt32=i.prototype.writeUInt32,i.prototype.writeBytes=function(t){this.buffer=this.buffer.concat(Array.prototype.slice.call(t,0))},i.prototype.writeString=function(t){var e,n=t.length,r=[];for(e=0;e<n;e++)r.push(t.codePointAt(e));this.writeBytes(r)},i.prototype.writeVarInt=function(t){if(t<0)throw"Cannot write negative variable-length integer";if(t<=127)this.writeUInt8(t);else{var e=t,n=[];for(n.push(127&e),e>>=7;e;){var r=127&e|128;n.push(r),e>>=7}this.writeBytes(n.reverse())}},i.prototype.writeChunk=function(t,e){this.writeString(t),this.writeUInt32(e.length),this.writeBytes(e)},t.exports=function(t,e){if("object"!=typeof t)throw"Invalid MIDI data";e=e||{};var r,s=t.header||{},a=t.tracks||[],o=a.length,u=new i;for(function(t,e,n){var r=null==e.format?1:e.format,s=128;e.timeDivision?s=e.timeDivision:e.ticksPerFrame&&e.framesPerSecond?s=-(255&e.framesPerSecond)<<8|255&e.ticksPerFrame:e.ticksPerBeat&&(s=32767&e.ticksPerBeat);var a=new i;a.writeUInt16(r),a.writeUInt16(n),a.writeUInt16(s),t.writeChunk("MThd",a.buffer)}(u,s,o),r=0;r<o;r++)n(u,a[r],e);return u.buffer}},function(t,e,n){"use strict";var r=this&&this.__spreadArrays||function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var s=arguments[e],a=0,o=s.length;a<o;a++,i++)r[i]=s[a];return r},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var s=n(260),a=n(213),o=i(n(344));function u(t){return o.default(t.notes.map((function(e){return function(t,e){return[{absoluteTime:t.ticks,channel:e,deltaTime:0,noteNumber:t.midi,type:"noteOn",velocity:Math.floor(127*t.velocity)},{absoluteTime:t.ticks+t.durationTicks,channel:e,deltaTime:0,noteNumber:t.midi,type:"noteOff",velocity:Math.floor(127*t.noteOffVelocity)}]}(e,t.channel)})))}function c(t,e){return{absoluteTime:t.ticks,channel:e,controllerType:t.number,deltaTime:0,type:"controller",value:t.value}}function l(t){return{absoluteTime:0,channel:t.channel,deltaTime:0,programNumber:t.instrument.number,type:"programChange"}}e.encode=function(t){var e={header:{format:1,numTracks:t.tracks.length+1,ticksPerBeat:t.header.ppq},tracks:r([r([{absoluteTime:0,deltaTime:0,meta:!0,text:t.header.name,type:"trackName"}],t.header.keySignatures.map((function(t){return function(t){var e=a.keySignatureKeys.indexOf(t.key);return{absoluteTime:t.ticks,deltaTime:0,key:e+7,meta:!0,scale:"major"===t.scale?0:1,type:"keySignature"}}(t)})),t.header.meta.map((function(t){return{absoluteTime:(e=t).ticks,deltaTime:0,meta:!0,text:e.text,type:e.type};var e})),t.header.tempos.map((function(t){return function(t){return{absoluteTime:t.ticks,deltaTime:0,meta:!0,microsecondsPerBeat:Math.floor(6e7/t.bpm),type:"setTempo"}}(t)})),t.header.timeSignatures.map((function(t){return function(t){return{absoluteTime:t.ticks,deltaTime:0,denominator:t.timeSignature[1],meta:!0,metronome:24,numerator:t.timeSignature[0],thirtyseconds:8,type:"timeSignature"}}(t)})))],t.tracks.map((function(t){return r([(e=t.name,{absoluteTime:0,deltaTime:0,meta:!0,text:e,type:"trackName"}),l(t)],u(t),function(t){for(var e=[],n=0;n<127;n++)t.controlChanges.hasOwnProperty(n)&&t.controlChanges[n].forEach((function(n){e.push(c(n,t.channel))}));return e}(t),function(t){var e=[];return t.pitchBends.forEach((function(n){e.push(function(t,e){return{absoluteTime:t.ticks,channel:e,deltaTime:0,type:"pitchBend",value:t.value}}(n,t.channel))})),e}(t));var e})))};return e.tracks=e.tracks.map((function(t){t=t.sort((function(t,e){return t.absoluteTime-e.absoluteTime}));var e=0;return t.forEach((function(t){t.deltaTime=t.absoluteTime-e,e=t.absoluteTime,delete t.absoluteTime})),t.push({deltaTime:0,meta:!0,type:"endOfTrack"}),t})),new Uint8Array(s.writeMidi(e))}},function(t,e,n){"use strict";function r(t){return function t(e,n){for(var r=0;r<e.length;r++){var i=e[r];Array.isArray(i)?t(i,n):n.push(i)}return n}(t,[])}function i(t,e){if("number"!=typeof e)throw new TypeError("Expected the depth to be a number");return function t(e,n,r){r--;for(var i=0;i<e.length;i++){var s=e[i];r>-1&&Array.isArray(s)?t(s,n,r):n.push(s)}return n}(t,[],e)}t.exports=function(t){if(!Array.isArray(t))throw new TypeError("Expected value to be an array");return r(t)},t.exports.from=r,t.exports.depth=function(t,e){if(!Array.isArray(t))throw new TypeError("Expected value to be an array");return i(t,e)},t.exports.fromDepth=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(263);e.createControlChanges=function(){return new Proxy({},{get:function(t,e){return t[e]?t[e]:r.controlChangeIds.hasOwnProperty(e)?t[r.controlChangeIds[e]]:void 0},set:function(t,e,n){return r.controlChangeIds.hasOwnProperty(e)?t[r.controlChangeIds[e]]=n:t[e]=n,!0}})}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=new WeakMap,i=function(){function t(t,e){r.set(this,e),this.ticks=t.absoluteTime,this.value=t.value}return Object.defineProperty(t.prototype,"time",{get:function(){return r.get(this).ticksToSeconds(this.ticks)},set:function(t){var e=r.get(this);this.ticks=e.secondsToTicks(t)},enumerable:!0,configurable:!0}),t.prototype.toJSON=function(){return{ticks:this.ticks,time:this.time,value:this.value}},t}();e.PitchBend=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(348),i=new WeakMap,s=function(){function t(t,e){if(this.number=0,i.set(this,e),this.number=0,t){var n=t.find((function(t){return"programChange"===t.type}));n&&(this.number=n.programNumber)}}return Object.defineProperty(t.prototype,"name",{get:function(){return this.percussion?r.DrumKitByPatchID[this.number]:r.instrumentByPatchID[this.number]},set:function(t){var e=r.instrumentByPatchID.indexOf(t);-1!==e&&(this.number=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"family",{get:function(){return this.percussion?"drums":r.InstrumentFamilyByID[Math.floor(this.number/8)]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"percussion",{get:function(){return 9===i.get(this).channel},enumerable:!0,configurable:!0}),t.prototype.toJSON=function(){return{family:this.family,name:this.name,number:this.number}},t.prototype.fromJSON=function(t){this.number=t.number},t}();e.Instrument=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.instrumentByPatchID=["acoustic grand piano","bright acoustic piano","electric grand piano","honky-tonk piano","electric piano 1","electric piano 2","harpsichord","clavi","celesta","glockenspiel","music box","vibraphone","marimba","xylophone","tubular bells","dulcimer","drawbar organ","percussive organ","rock organ","church organ","reed organ","accordion","harmonica","tango accordion","acoustic guitar (nylon)","acoustic guitar (steel)","electric guitar (jazz)","electric guitar (clean)","electric guitar (muted)","overdriven guitar","distortion guitar","guitar harmonics","acoustic bass","electric bass (finger)","electric bass (pick)","fretless bass","slap bass 1","slap bass 2","synth bass 1","synth bass 2","violin","viola","cello","contrabass","tremolo strings","pizzicato strings","orchestral harp","timpani","string ensemble 1","string ensemble 2","synthstrings 1","synthstrings 2","choir aahs","voice oohs","synth voice","orchestra hit","trumpet","trombone","tuba","muted trumpet","french horn","brass section","synthbrass 1","synthbrass 2","soprano sax","alto sax","tenor sax","baritone sax","oboe","english horn","bassoon","clarinet","piccolo","flute","recorder","pan flute","blown bottle","shakuhachi","whistle","ocarina","lead 1 (square)","lead 2 (sawtooth)","lead 3 (calliope)","lead 4 (chiff)","lead 5 (charang)","lead 6 (voice)","lead 7 (fifths)","lead 8 (bass + lead)","pad 1 (new age)","pad 2 (warm)","pad 3 (polysynth)","pad 4 (choir)","pad 5 (bowed)","pad 6 (metallic)","pad 7 (halo)","pad 8 (sweep)","fx 1 (rain)","fx 2 (soundtrack)","fx 3 (crystal)","fx 4 (atmosphere)","fx 5 (brightness)","fx 6 (goblins)","fx 7 (echoes)","fx 8 (sci-fi)","sitar","banjo","shamisen","koto","kalimba","bag pipe","fiddle","shanai","tinkle bell","agogo","steel drums","woodblock","taiko drum","melodic tom","synth drum","reverse cymbal","guitar fret noise","breath noise","seashore","bird tweet","telephone ring","helicopter","applause","gunshot"],e.InstrumentFamilyByID=["piano","chromatic percussion","organ","guitar","bass","strings","ensemble","brass","reed","pipe","synth lead","synth pad","synth effects","world","percussive","sound effects"],e.DrumKitByPatchID={0:"standard kit",8:"room kit",16:"power kit",24:"electronic kit",25:"tr-808 kit",32:"jazz kit",40:"brush kit",48:"orchestra kit",56:"sound fx kit"}},function(t,e,n){"use strict";function r(t){return["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"][t%12]}Object.defineProperty(e,"__esModule",{value:!0});var i,s,a=(i=/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,s={cbb:-2,cb:-1,c:0,"c#":1,cx:2,dbb:0,db:1,d:2,"d#":3,dx:4,ebb:2,eb:3,e:4,"e#":5,ex:6,fbb:3,fb:4,f:5,"f#":6,fx:7,gbb:5,gb:6,g:7,"g#":8,gx:9,abb:7,ab:8,a:9,"a#":10,ax:11,bbb:9,bb:10,b:11,"b#":12,bx:13},function(t){var e=i.exec(t),n=e[1],r=e[2];return s[n.toLowerCase()]+12*(parseInt(r,10)+1)}),o=new WeakMap,u=function(){function t(t,e,n){o.set(this,n),this.midi=t.midi,this.velocity=t.velocity,this.noteOffVelocity=e.velocity,this.ticks=t.ticks,this.durationTicks=e.ticks-t.ticks}return Object.defineProperty(t.prototype,"name",{get:function(){return t=this.midi,e=Math.floor(t/12)-1,r(t)+e.toString();var t,e},set:function(t){this.midi=a(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"octave",{get:function(){return Math.floor(this.midi/12)-1},set:function(t){var e=t-this.octave;this.midi+=12*e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pitch",{get:function(){return r(this.midi)},set:function(t){this.midi=12*(this.octave+1)+["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"].indexOf(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"duration",{get:function(){var t=o.get(this);return t.ticksToSeconds(this.ticks+this.durationTicks)-t.ticksToSeconds(this.ticks)},set:function(t){var e=o.get(this).secondsToTicks(this.time+t);this.durationTicks=e-this.ticks},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"time",{get:function(){return o.get(this).ticksToSeconds(this.ticks)},set:function(t){var e=o.get(this);this.ticks=e.secondsToTicks(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bars",{get:function(){return o.get(this).ticksToMeasures(this.ticks)},enumerable:!0,configurable:!0}),t.prototype.toJSON=function(){return{duration:this.duration,durationTicks:this.durationTicks,midi:this.midi,name:this.name,ticks:this.ticks,time:this.time,velocity:this.velocity}},t}();e.Note=u},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.MIDIPlayer=e.PlayerWithClick=e.SoundFontPlayer=e.Player=e.BasePlayer=e.BasePlayerCallback=void 0;var o=n(120),u=n(61),c=n(79),l=n(67),h=n(351),d=n(92);function p(t,e){return t.quantizedStartStep<e.quantizedStartStep?-1:t.quantizedStartStep>e.quantizedStartStep?1:t.pitch<e.pitch?-1:1}var f=function(){};e.BasePlayerCallback=f;var m=function(){function t(t,e){void 0===t&&(t=!1),this.playClick=t,this.callbackObject=e,this.desiredQPM=void 0}return t.prototype.setTempo=function(t){this.desiredQPM=t,"started"===o.Transport.state&&(o.Transport.bpm.value=t)},t.prototype.makeClickSequence=function(t){for(var e=d.clone(t),n=e.notes.map((function(t){return t.quantizedEndStep})),r=Math.max.apply(Math,n),i=0;i<r;i+=4){var s={pitch:i%16==0?l.LO_CLICK_PITCH:l.HI_CLICK_PITCH,quantizedStartStep:i,isDrum:!0,quantizedEndStep:i+1};e.notes.push(s)}return e.notes.sort(p),e},t.prototype.resumeContext=function(){o.context.resume()},t.prototype.start=function(t,e,n){var r=this;if(void 0===n&&(n=0),"started"===this.getPlayState())throw new Error("Cannot start playback; player is already playing.");if("paused"===this.getPlayState())throw new Error("Cannot `start()` a paused player; use `resume()`.");if("stopped"!==o.Transport.state)throw new Error("Cannot start playback while `Tone.Transport` is in use.");this.resumeContext();var i=d.isQuantizedSequence(t);if(this.playClick&&i&&(t=this.makeClickSequence(t)),e?o.Transport.bpm.value=e:t.tempos&&t.tempos.length>0&&t.tempos[0].qpm>0?o.Transport.bpm.value=t.tempos[0].qpm:o.Transport.bpm.value=l.DEFAULT_QUARTERS_PER_MINUTE,i)t=d.unquantizeSequence(t,e);else if(e)throw new Error("Cannot specify a `qpm` for a non-quantized sequence.");var s=new o.Part((function(t,e){r.currentPart===s&&(r.playNote(t,e),r.callbackObject&&o.Draw.schedule((function(){r.callbackObject.run(e,t)}),t))}),t.notes.map((function(t){return[t.startTime,t]})));return this.currentPart=s,this.desiredQPM&&(o.Transport.bpm.value=this.desiredQPM),this.currentPart.start(void 0,n),"started"!==o.Transport.state&&o.Transport.start(),new Promise((function(e){r.scheduledStop=o.Transport.schedule((function(){r.stop(),e(),r.callbackObject&&r.callbackObject.stop()}),"+"+t.totalTime)}))},t.prototype.stop=function(){this.isPlaying()&&(this.currentPart.stop(),o.Transport.stop(),this.currentPart=null),o.Transport.clear(this.scheduledStop),this.scheduledStop=void 0,this.desiredQPM=void 0},t.prototype.pause=function(){if(!this.isPlaying())throw new Error("Cannot pause playback while the player is stopped.");o.Transport.pause()},t.prototype.resume=function(){if("paused"!==this.getPlayState())throw new Error('Cannot resume playback while "'+this.getPlayState()+'".');o.Transport.start()},t.prototype.seekTo=function(t){if(!this.isPlaying())throw new Error("Cannot seek while the player is stopped.");o.Transport.seconds=t},t.prototype.isPlaying=function(){return!!this.currentPart},t.prototype.getPlayState=function(){return this.isPlaying()?o.Transport.state:"stopped"},t}();e.BasePlayer=m;var g=function(){function t(){var t=this;this.DRUM_PITCH_TO_CLASS=new Map,this.kick=(new o.MembraneSynth).toDestination(),this.tomLow=new o.MembraneSynth({pitchDecay:.008,envelope:{attack:.01,decay:.5,sustain:0}}).toDestination(),this.tomMid=new o.MembraneSynth({pitchDecay:.008,envelope:{attack:.01,decay:.5,sustain:0}}).toDestination(),this.tomHigh=new o.MembraneSynth({pitchDecay:.008,envelope:{attack:.01,decay:.5,sustain:0}}).toDestination(),this.closedHihat=new o.MetalSynth({frequency:400,envelope:{attack:.001,decay:.1,release:.8},harmonicity:5.1,modulationIndex:32,resonance:4e3,octaves:1}).toDestination(),this.openHihat=new o.MetalSynth({frequency:400,envelope:{attack:.001,decay:.5,release:.8,sustain:1},harmonicity:5.1,modulationIndex:32,resonance:4e3,octaves:1}).toDestination(),this.ride=(new o.MetalSynth).toDestination(),this.crash=new o.MetalSynth({frequency:300,envelope:{attack:.001,decay:1,release:3},harmonicity:5.1,modulationIndex:64,resonance:4e3,octaves:1.5}).toDestination(),this.snare=new o.NoiseSynth({noise:{type:"white"},envelope:{attack:.005,decay:.05,sustain:.1,release:.4}}).toDestination(),this.loClick=new o.MembraneSynth({pitchDecay:.008,envelope:{attack:.001,decay:.3,sustain:0}}).toDestination(),this.hiClick=new o.MembraneSynth({pitchDecay:.008,envelope:{attack:.001,decay:.3,sustain:0}}).toDestination(),this.pitchPlayers=[function(e,n){return void 0===n&&(n=1),t.kick.triggerAttackRelease("C2","8n",e,n)},function(e,n){return void 0===n&&(n=1),t.snare.triggerAttackRelease("16n",e,n)},function(e,n){return void 0===n&&(n=1),t.closedHihat.triggerAttack(e,.3,n)},function(e,n){return void 0===n&&(n=1),t.openHihat.triggerAttack(e,.3,n)},function(e,n){return void 0===n&&(n=.5),t.tomLow.triggerAttack("G3",e,n)},function(e,n){return void 0===n&&(n=.5),t.tomMid.triggerAttack("C4",e,n)},function(e,n){return void 0===n&&(n=.5),t.tomHigh.triggerAttack("F4",e,n)},function(e,n){return void 0===n&&(n=1),t.crash.triggerAttack(e,1,n)},function(e,n){return void 0===n&&(n=1),t.ride.triggerAttack(e,.5,n)},function(e,n){return void 0===n&&(n=.5),t.loClick.triggerAttack("G5",e,n)},function(e,n){return void 0===n&&(n=.5),t.hiClick.triggerAttack("C6",e,n)}];for(var e=function(e){l.DEFAULT_DRUM_PITCH_CLASSES[e].forEach((function(n){t.DRUM_PITCH_TO_CLASS.set(n,e)}))},n=0;n<l.DEFAULT_DRUM_PITCH_CLASSES.length;++n)e(n);this.DRUM_PITCH_TO_CLASS.set(l.LO_CLICK_PITCH,l.LO_CLICK_CLASS),this.DRUM_PITCH_TO_CLASS.set(l.HI_CLICK_PITCH,l.HI_CLICK_CLASS)}return t.getInstance=function(){return t.instance||(t.instance=new t),t.instance},t.prototype.playNote=function(t,e,n){this.pitchPlayers[this.DRUM_PITCH_TO_CLASS.get(t)](e,n)},t}(),b=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.drumKit=g.getInstance(),e.bassSynth=new o.Synth({volume:5,oscillator:{type:"triangle"}}).toDestination(),e.polySynth=(new o.PolySynth).toDestination(),e}return i(e,t),e.prototype.playNote=function(t,e){var n=e.hasOwnProperty("velocity")?e.velocity/l.MAX_MIDI_VELOCITY:void 0;if(e.isDrum)this.drumKit.playNote(e.pitch,t,n);else{var r=o.Frequency(e.pitch,"midi").toFrequency(),i=e.endTime-e.startTime;this.getSynth(e.instrument,e.program).triggerAttackRelease(r,i,t,n)}},e.prototype.getSynth=function(t,e){return void 0!==e&&e>=32&&e<=39?this.bassSynth:this.polySynth},e.tone=o,e}(m);e.Player=b;var y=function(t){function e(e,n,r,i,s){void 0===n&&(n=o.Master);var a=t.call(this,!1,s)||this;return a.soundFont=new h.SoundFont(e),a.output=n,a.programOutputs=r,a.drumOutputs=i,a}return i(e,t),e.prototype.loadSamples=function(t){return s(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.soundFont.loadSamples(t.notes.map((function(t){return{pitch:t.pitch,velocity:t.velocity,program:t.program||0,isDrum:t.isDrum||!1}})))];case 1:return e.sent(),[2]}}))}))},e.prototype.loadAllSamples=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=!1),s(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){for(n=c.NoteSequence.create(),r=e?l.MIN_DRUM_PITCH:l.MIN_PIANO_PITCH,i=e?l.MAX_DRUM_PITCH:l.MAX_PIANO_PITCH,s=r;s<=i;s++)for(o=l.MIN_MIDI_VELOCITY;o<l.MAX_MIDI_VELOCITY;o++)n.notes.push({pitch:s,velocity:o,program:t,isDrum:e});return[2,this.loadSamples(n)]}))}))},e.prototype.resumeContext=function(){o.context.resume()},e.prototype.start=function(e,n,r){var i=this;return void 0===r&&(r=0),this.resumeContext(),this.loadSamples(e).then((function(){return t.prototype.start.call(i,e,n,r)}))},e.prototype.playNote=function(t,e){this.soundFont.playNote(e.pitch,e.velocity,t,e.endTime-e.startTime,e.program,e.isDrum,this.getAudioNodeOutput(e))},e.prototype.playNoteDown=function(t){this.soundFont.playNoteDown(t.pitch,t.velocity,t.program,t.isDrum,this.getAudioNodeOutput(t))},e.prototype.playNoteUp=function(t){this.soundFont.playNoteUp(t.pitch,t.velocity,t.program,t.isDrum,this.getAudioNodeOutput(t))},e.prototype.getAudioNodeOutput=function(t){var e=this.output;return this.programOutputs&&!t.isDrum?this.programOutputs.has(t.program)&&(e=this.programOutputs.get(t.program)):this.drumOutputs&&t.isDrum&&this.drumOutputs.has(t.pitch)&&(e=this.drumOutputs.get(t.pitch)),e},e}(m);e.SoundFontPlayer=y;var v=function(t){function e(e){return t.call(this,!0,e)||this}return i(e,t),e}(b);e.PlayerWithClick=v;var w=function(t){function e(e){var n=t.call(this,!1,e)||this;return n.outputs=[],n.outputChannel=0,n.availableOutputs=[],n.NOTE_ON=144,n.NOTE_OFF=128,n}return i(e,t),e.prototype.requestMIDIAccess=function(){return s(this,void 0,void 0,(function(){var t=this;return a(this,(function(e){return navigator.requestMIDIAccess?[2,new Promise((function(e,n){navigator.requestMIDIAccess().then((function(n){n.addEventListener("statechange",(function(e){return t.initOutputs(n)})),e(t.initOutputs(n))}),(function(t){return console.log("Something went wrong",n(t))}))}))]:[2,null]}))}))},e.prototype.initOutputs=function(t){for(var e=t.outputs.values(),n=e.next();n&&!n.done;n=e.next())this.availableOutputs.push(n.value);return this.availableOutputs},e.prototype.playNote=function(t,e){for(var n=e.velocity||100,r=1e3*(e.endTime-e.startTime),i=[this.NOTE_ON+this.outputChannel,e.pitch,n],s=[this.NOTE_OFF+this.outputChannel,e.pitch,n],a=this.outputs?this.outputs:this.availableOutputs,o=0;o<a.length;o++)this.sendMessageToOutput(a[o],i),this.sendMessageToOutput(a[o],s,u.performance.now()+r)},e.prototype.sendMessageToOutput=function(t,e,n){t&&t.send(e,n)},e.prototype.playNoteDown=function(t){for(var e=[this.NOTE_ON,t.pitch,t.velocity],n=this.outputs?this.outputs:this.availableOutputs,r=0;r<n.length;r++)this.sendMessageToOutput(n[r],e)},e.prototype.playNoteUp=function(t){for(var e=[this.NOTE_OFF,t.pitch,t.velocity],n=this.outputs?this.outputs:this.availableOutputs,r=0;r<n.length;r++)this.sendMessageToOutput(n[r],e,t.endTime-t.startTime)},e}(m);e.MIDIPlayer=w},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.SoundFont=e.Instrument=void 0;var s=n(120),a=n(61),o=n(67),u=n(55),c=function(){function t(t){this.FADE_SECONDS=.1,this.baseURL=t,this.buffers=new s.ToneAudioBuffers,this.sourceMap=new Map,this.initialized=!1}return t.prototype.initialize=function(){return r(this,void 0,void 0,(function(){var t=this;return i(this,(function(e){switch(e.label){case 0:return[4,a.fetch(this.baseURL+"/instrument.json").then((function(t){return t.json()})).then((function(e){t.name=e.name,t.minPitch=e.minPitch,t.maxPitch=e.maxPitch,t.durationSeconds=e.durationSeconds,t.releaseSeconds=e.releaseSeconds,t.percussive=e.percussive,t.velocities=e.velocities,t.initialized=!0}))];case 1:return e.sent(),[2]}}))}))},t.prototype.sampleInfoToName=function(t){return this.velocities?"p"+t.pitch+"_v"+t.velocity:"p"+t.pitch},t.prototype.sampleNameToURL=function(t){return this.baseURL+"/"+t+".mp3"},t.prototype.nearestVelocity=function(t){if(!this.velocities)return t;t||(t=o.DEFAULT_VELOCITY);var e=void 0,n=o.MIDI_VELOCITIES;return this.velocities.forEach((function(r){var i=Math.abs(r-t);i<n&&(e=r,n=i)})),e},t.prototype.loadSamples=function(t){return r(this,void 0,void 0,(function(){var e,n,r,a=this;return i(this,(function(i){switch(i.label){case 0:return this.initialized?[3,2]:[4,this.initialize()];case 1:i.sent(),i.label=2;case 2:return e=t.filter((function(t){return!(t.pitch<a.minPitch||t.pitch>a.maxPitch)||(u.log("Pitch "+t.pitch+" is outside the valid range for "+a.name+", ignoring.","SoundFont"),!1)})).map((function(t){return a.sampleInfoToName({pitch:t.pitch,velocity:a.nearestVelocity(t.velocity)})})),n=Array.from(new Set(e)).filter((function(t){return!a.buffers.has(t)})),(r=n.map((function(t){return{name:t,url:a.sampleNameToURL(t)}}))).length>0?(r.forEach((function(t){return a.buffers.add(t.name,t.url)})),[4,s.loaded()]):[3,4];case 3:i.sent(),u.log("Loaded samples for "+this.name+".","SoundFont"),i.label=4;case 4:return[2]}}))}))},t.prototype.playNote=function(t,e,n,r,i){var a=this.getBuffer(t,e);if(a){r>this.durationSeconds&&u.log("Requested note duration longer than sample duration: "+r+" > "+this.durationSeconds,"SoundFont");var o=new s.ToneBufferSource({url:a,fadeOut:this.FADE_SECONDS}).connect(i);if(o.start(n,0,void 0,1),!this.percussive&&r<this.durationSeconds){var c=new s.ToneBufferSource({url:a,fadeOut:this.FADE_SECONDS}).connect(i);o.stop(n+r+this.FADE_SECONDS),c.start(n+r,this.durationSeconds,void 0,1)}}},t.prototype.playNoteDown=function(t,e,n){var r=this.getBuffer(t,e);if(r){var i=new s.ToneBufferSource(r).connect(n);i.start(0,0,void 0,1),this.sourceMap.has(t)&&this.sourceMap.get(t).stop(s.now()+this.FADE_SECONDS,this.FADE_SECONDS),this.sourceMap.set(t,i)}},t.prototype.playNoteUp=function(t,e,n){if(this.sourceMap.has(t)){var r=this.getBuffer(t,e);if(r)new s.ToneBufferSource({url:r,fadeOut:this.FADE_SECONDS}).connect(n).start(0,this.durationSeconds,void 0,1),this.sourceMap.get(t).stop(s.now()+this.FADE_SECONDS,this.FADE_SECONDS),this.sourceMap.delete(t)}},t.prototype.getBuffer=function(t,e){if(!this.initialized)throw new Error("Instrument is not initialized.");if(!(t<this.minPitch||t>this.maxPitch)){var n=this.sampleInfoToName({pitch:t,velocity:this.nearestVelocity(e)});if(!this.buffers.has(n))throw new Error("Buffer not found for "+this.name+": "+n);var r=this.buffers.get(n);if(!r.loaded)throw new Error("Buffer not loaded for "+this.name+": "+n);return r}u.log("Pitch "+t+" is outside the valid range for "+this.name+" ("+this.minPitch+"-"+this.maxPitch+")","SoundFont")},t}();e.Instrument=c;var l=function(){function t(t){this.baseURL=t,this.instruments=new Map,this.initialized=!1}return t.prototype.initialize=function(){return r(this,void 0,void 0,(function(){var t=this;return i(this,(function(e){switch(e.label){case 0:return[4,a.fetch(this.baseURL+"/soundfont.json").then((function(t){return t.json()})).then((function(e){for(var n in t.name=e.name,e.instruments){var r=t.baseURL+"/"+e.instruments[n];t.instruments.set("drums"===n?"drums":+n,new c(r))}t.initialized=!0}))];case 1:return e.sent(),[2]}}))}))},t.prototype.loadSamples=function(t){return r(this,void 0,void 0,(function(){var e,n=this;return i(this,(function(r){switch(r.label){case 0:return this.initialized?[3,2]:[4,this.initialize()];case 1:r.sent(),r.label=2;case 2:return e=new Map,t.forEach((function(t){t.isDrum=t.isDrum||!1,t.program=t.program||0;var r=t.isDrum?"drums":t.program,i={pitch:t.pitch,velocity:t.velocity};e.has(r)?e.get(r).push(i):n.instruments.has(r)?e.set(r,[i]):u.log("No instrument in "+n.name+" for: program="+t.program+", isDrum="+t.isDrum,"SoundFont")})),[4,Promise.all(Array.from(e.keys()).map((function(t){return n.instruments.get(t).loadSamples(e.get(t))})))];case 3:return r.sent(),[2]}}))}))},t.prototype.playNote=function(t,e,n,r,i,s,a){void 0===i&&(i=0),void 0===s&&(s=!1);var o=s?"drums":i;if(!this.initialized)throw new Error("SoundFont is not initialized.");this.instruments.has(o)?this.instruments.get(o).playNote(t,e,n,r,a):u.log("No instrument in "+this.name+" for: program="+i+", isDrum="+s,"SoundFont")},t.prototype.playNoteDown=function(t,e,n,r,i){void 0===n&&(n=0),void 0===r&&(r=!1);var s=r?"drums":n;if(!this.initialized)throw new Error("SoundFont is not initialized.");this.instruments.has(s)?this.instruments.get(s).playNoteDown(t,e,i):u.log("No instrument in "+this.name+" for: program="+n+", isDrum="+r,"SoundFont")},t.prototype.playNoteUp=function(t,e,n,r,i){void 0===n&&(n=0),void 0===r&&(r=!1);var s=r?"drums":n;if(!this.initialized)throw new Error("SoundFont is not initialized.");this.instruments.has(s)?this.instruments.get(s).playNoteUp(t,e,i):u.log("No instrument in "+this.name+" for: program="+n+", isDrum="+r,"SoundFont")},t}();e.SoundFont=l},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.Recorder=e.BaseRecorderCallback=void 0;var s=n(120),a=n(61),o=n(79),u=n(67),c=n(55),l=function(){};e.BaseRecorderCallback=l;var h=function(){function t(t,e){void 0===t&&(t={}),this.notes=[],this.midiInputs=[],this.loClick=new s.MembraneSynth({pitchDecay:.008,envelope:{attack:.001,decay:.3,sustain:0}}).toDestination(),this.hiClick=new s.MembraneSynth({pitchDecay:.008,envelope:{attack:.001,decay:.3,sustain:0}}).toDestination(),this.config={playClick:t.playClick,qpm:t.qpm||u.DEFAULT_QUARTERS_PER_MINUTE,playCountIn:t.playCountIn,startRecordingAtFirstNote:t.startRecordingAtFirstNote||!1},this.callbackObject=e,this.recording=!1,this.onNotes=new Map}return t.prototype.initialize=function(){return r(this,void 0,void 0,(function(){var t=this;return i(this,(function(e){switch(e.label){case 0:return[4,navigator.requestMIDIAccess().then((function(e){return t.midiReady(e)}),(function(t){return console.log("Something went wrong",t)}))];case 1:return e.sent(),[2]}}))}))},t.prototype.midiReady=function(t){c.log("Initialized Recorder","Recorder");for(var e=t.inputs.values(),n=e.next();n&&!n.done;n=e.next())this.midiInputs.push(n.value)},t.prototype.isRecording=function(){return this.recording},t.prototype.setTempo=function(t){this.config.qpm=t,"started"===s.Transport.state&&(s.Transport.bpm.value=t)},t.prototype.enablePlayClick=function(t){this.config.playClick=t},t.prototype.enablePlayCountIn=function(t){this.config.playCountIn=t},t.prototype.initClickLoop=function(){var t=this,e=0;this.clickLoop=new s.Loop((function(n){e%4==0?t.loClick.triggerAttack("G5",n):t.hiClick.triggerAttack("C6",n),e++,t.config.playCountIn&&4===e&&(s.Transport.stop(),t.clickLoop.stop())}),"4n")},t.prototype.getMIDIInputs=function(){return this.midiInputs},t.prototype.start=function(t){for(var e=this,n=0,r=t||this.midiInputs;n<r.length;n++){r[n].onmidimessage=function(t){e.midiMessageReceived(t)}}if(this.config.playClick||this.config.playCountIn?(this.initClickLoop(),s.Transport.bpm.value=this.config.qpm,s.Transport.start(),this.clickLoop.start()):this.clickLoop=null,this.recording=!0,this.firstNoteTimestamp=void 0,this.notes=[],this.onNotes=new Map,!this.startRecordingAtFirstNote){var i=Date.now();this.firstNoteTimestamp=i}},t.prototype.stop=function(){var t=this;this.recording=!1;var e=Date.now();this.onNotes.forEach((function(n,r){t.noteOff(r,e)}));for(var n=0,r=this.midiInputs;n<r.length;n++){r[n].onmidimessage=null}return this.clickLoop&&(s.Transport.stop(),this.clickLoop.stop()),0===this.notes.length?null:this.getNoteSequence()},t.prototype.getNoteSequence=function(){return 0===this.notes.length?null:o.NoteSequence.create({notes:this.notes,totalTime:this.notes[this.notes.length-1].endTime})},t.prototype.reset=function(){var t=this.stop();return this.firstNoteTimestamp=void 0,this.notes=[],this.onNotes=new Map,t},t.prototype.midiMessageReceived=function(t){if(this.recording){var e=(void 0!==t.timeStamp&&0!==t.timeStamp?t.timeStamp:a.performance.now())+a.performance.timing.navigationStart;void 0===this.firstNoteTimestamp&&(this.firstNoteTimestamp=e);var n=t.data[0]>>4,r=t.data[1],i=t.data.length>2?t.data[2]:1,s=t.srcElement;8===n||9===n&&0===i?(this.callbackObject&&this.callbackObject.noteOff&&this.callbackObject.noteOff(r,i,s),this.noteOff(r,e),this.callbackObject&&this.callbackObject.run&&this.callbackObject.run(this.getNoteSequence())):9===n&&(this.callbackObject&&this.callbackObject.noteOn&&this.callbackObject.noteOn(r,i,s),this.noteOn(r,i,e))}},t.prototype.noteOn=function(t,e,n){var r=new o.NoteSequence.Note;r.pitch=t,r.startTime=(n-this.firstNoteTimestamp)/1e3,r.velocity=e,this.onNotes.set(t,r)},t.prototype.noteOff=function(t,e){var n=this.onNotes.get(t);n&&(n.endTime=(e-this.firstNoteTimestamp)/1e3,this.notes.push(n)),this.onNotes.delete(t)},t}();e.Recorder=h},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.StaffSVGVisualizer=e.ScrollType=e.WaterfallSVGVisualizer=e.PianoRollSVGVisualizer=e.BaseSVGVisualizer=e.Visualizer=e.PianoRollCanvasVisualizer=e.BaseVisualizer=void 0;var s=n(354),a=n(67),o=n(55),u=n(92),c=function(){function t(t,e){void 0===e&&(e={});var n=u.isQuantizedSequence(t),r=t.tempos&&t.tempos.length>0?t.tempos[0].qpm:void 0;this.noteSequence=n?u.unquantizeSequence(t,r):t;this.config={noteHeight:e.noteHeight||6,noteSpacing:e.noteSpacing||1,pixelsPerTimeStep:e.pixelsPerTimeStep||30,noteRGB:e.noteRGB||"8, 41, 64",activeNoteRGB:e.activeNoteRGB||"240, 84, 119",minPitch:e.minPitch,maxPitch:e.maxPitch};var i=this.getSize();this.width=i.width,this.height=i.height}return t.prototype.updateMinMaxPitches=function(t){if(void 0===t&&(t=!1),!this.config.minPitch||!this.config.maxPitch){void 0===this.config.minPitch&&(this.config.minPitch=a.MAX_MIDI_PITCH),void 0===this.config.maxPitch&&(this.config.maxPitch=a.MIN_MIDI_PITCH);for(var e=0,n=this.noteSequence.notes;e<n.length;e++){var r=n[e];this.config.minPitch=Math.min(r.pitch,this.config.minPitch),this.config.maxPitch=Math.max(r.pitch,this.config.maxPitch)}t||(this.config.minPitch-=2,this.config.maxPitch+=2)}},t.prototype.getSize=function(){this.updateMinMaxPitches();var t=(this.config.maxPitch-this.config.minPitch)*this.config.noteHeight,e=this.noteSequence.totalTime;if(!e)throw new Error("The sequence you are using with the visualizer does not have a totalQuantizedSteps or totalTime field set, so the visualizer can't be horizontally sized correctly.");return{width:e*this.config.pixelsPerTimeStep,height:t}},t.prototype.getNotePosition=function(t,e){var n=this.getNoteEndTime(t)-this.getNoteStartTime(t),r=this.getNoteStartTime(t)*this.config.pixelsPerTimeStep,i=Math.max(this.config.pixelsPerTimeStep*n-this.config.noteSpacing,1);return{x:r,y:this.height-(t.pitch-this.config.minPitch)*this.config.noteHeight,w:i,h:this.config.noteHeight}},t.prototype.scrollIntoViewIfNeeded=function(t,e){if(t&&this.parentElement){var n=this.parentElement.getBoundingClientRect().width;e>this.parentElement.scrollLeft+n&&(this.parentElement.scrollLeft=e-20)}},t.prototype.getNoteStartTime=function(t){return Math.round(1e8*t.startTime)/1e8},t.prototype.getNoteEndTime=function(t){return Math.round(1e8*t.endTime)/1e8},t.prototype.isPaintingActiveNote=function(t,e){var n=this.getNoteStartTime(t)===this.getNoteStartTime(e),r=this.getNoteStartTime(t)<=this.getNoteStartTime(e)&&this.getNoteEndTime(t)>=this.getNoteEndTime(e);return n||r},t}();e.BaseVisualizer=c;var l=function(t){function e(e,n,r){void 0===r&&(r={});var i=t.call(this,e,r)||this;i.ctx=n.getContext("2d"),i.parentElement=n.parentElement;var s=window.devicePixelRatio||1;return i.ctx&&(i.ctx.canvas.width=s*i.width,i.ctx.canvas.height=s*i.height,n.style.width=i.width+"px",n.style.height=i.height+"px",i.ctx.scale(s,s)),i.redraw(),i}return i(e,t),e.prototype.redraw=function(t,e){var n;this.clear();for(var r=0;r<this.noteSequence.notes.length;r++){var i=this.noteSequence.notes[r],s=this.getNotePosition(i,r),a=i.velocity?i.velocity/100+.2:1,o=t&&this.isPaintingActiveNote(i,t),u="rgba("+(o?this.config.activeNoteRGB:this.config.noteRGB)+",\n  "+a+")";this.redrawNote(s.x,s.y,s.w,s.h,u),o&&i===t&&(n=s.x)}return this.scrollIntoViewIfNeeded(e,n),n},e.prototype.clear=function(){this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)},e.prototype.clearActiveNotes=function(){this.redraw()},e.prototype.redrawNote=function(t,e,n,r,i){this.ctx.fillStyle=i,this.ctx.fillRect(Math.round(t),Math.round(e),Math.round(n),Math.round(r))},e}(c);e.PianoRollCanvasVisualizer=l;var h=function(t){function e(e,n,r){void 0===r&&(r={});var i=t.call(this,e,n,r)||this;return o.log("mm.Visualizer is deprecated, and will be removed in a future          version. Please use mm.PianoRollCanvasVisualizer instead","mm.Visualizer",5),i}return i(e,t),e}(l);e.Visualizer=h;var d=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,e,n)||this;return r.drawn=!1,r}return i(e,t),e.prototype.redraw=function(t,e){if(this.drawn||this.draw(),!t)return null;var n;this.unfillActiveRect(this.svg);for(var r=0;r<this.noteSequence.notes.length;r++){var i=this.noteSequence.notes[r];if(t&&this.isPaintingActiveNote(i,t)){var s=this.svg.querySelector('rect[data-index="'+r+'"]');this.fillActiveRect(s,i),i===t&&(n=parseFloat(s.getAttribute("x")))}}return this.scrollIntoViewIfNeeded(e,n),n},e.prototype.fillActiveRect=function(t,e){t.setAttribute("fill",this.getNoteFillColor(e,!0)),t.classList.add("active")},e.prototype.unfillActiveRect=function(t){for(var e=t.querySelectorAll("rect.active"),n=0;n<e.length;++n){var r=e[n],i=this.getNoteFillColor(this.noteSequence.notes[parseInt(r.getAttribute("data-index"),10)],!1);r.setAttribute("fill",i),r.classList.remove("active")}},e.prototype.draw=function(){for(var t=0;t<this.noteSequence.notes.length;t++){var e=this.noteSequence.notes[t],n=this.getNotePosition(e,t),r=this.getNoteFillColor(e,!1),i=[["index",t],["instrument",e.instrument],["program",e.program],["isDrum",!0===e.isDrum],["pitch",e.pitch]],s=[["--midi-velocity",String(void 0!==e.velocity?e.velocity:127)]];this.drawNote(n.x,n.y,n.w,n.h,r,i,s)}this.drawn=!0},e.prototype.getNoteFillColor=function(t,e){var n=t.velocity?t.velocity/100+.2:1;return"rgba("+(e?this.config.activeNoteRGB:this.config.noteRGB)+",\n  "+n+")"},e.prototype.drawNote=function(t,e,n,r,i,s,a){if(this.svg){var o=document.createElementNS("http://www.w3.org/2000/svg","rect");o.classList.add("note"),o.setAttribute("fill",i),o.setAttribute("x",""+Math.round(t)),o.setAttribute("y",""+Math.round(e)),o.setAttribute("width",""+Math.round(n)),o.setAttribute("height",""+Math.round(r)),s.forEach((function(t){var e=t[0],n=t[1];void 0!==n&&(o.dataset[e]=""+n)})),a.forEach((function(t){var e=t[0],n=t[1];o.style.setProperty(e,n)})),this.svg.appendChild(o)}},e.prototype.clear=function(){this.svg.innerHTML="",this.drawn=!1},e.prototype.clearActiveNotes=function(){this.unfillActiveRect(this.svg)},e}(c);e.BaseSVGVisualizer=d;var p=function(t){function e(e,n,r){void 0===r&&(r={});var i=t.call(this,e,r)||this;if(!(n instanceof SVGSVGElement))throw new Error("This visualizer requires an <svg> element to display the visualization");i.svg=n,i.parentElement=n.parentElement;var s=i.getSize();return i.width=s.width,i.height=s.height,i.svg.style.width=i.width+"px",i.svg.style.height=i.height+"px",i.clear(),i.draw(),i}return i(e,t),e}(d);e.PianoRollSVGVisualizer=p;var f,m=function(t){function e(e,n,r){void 0===r&&(r={});var i=t.call(this,e,r)||this;if(i.NOTES_PER_OCTAVE=12,i.WHITE_NOTES_PER_OCTAVE=7,i.LOW_C=24,i.firstDrawnOctave=0,i.lastDrawnOctave=6,!(n instanceof HTMLDivElement))throw new Error("This visualizer requires a <div> element to display the visualization");i.config.whiteNoteWidth=r.whiteNoteWidth||20,i.config.blackNoteWidth=r.blackNoteWidth||2*i.config.whiteNoteWidth/3,i.config.whiteNoteHeight=r.whiteNoteHeight||70,i.config.blackNoteHeight=r.blackNoteHeight||140/3,i.config.showOnlyOctavesUsed=r.showOnlyOctavesUsed,i.setupDOM(n);var s=i.getSize();return i.width=s.width,i.height=s.height,i.svg.style.width=i.width+"px",i.svg.style.height=i.height+"px",i.svgPiano.style.width=i.width+"px",i.svgPiano.style.height=i.config.whiteNoteHeight+"px",i.parentElement.style.width=i.width+i.config.whiteNoteWidth+"px",i.parentElement.scrollTop=i.parentElement.scrollHeight,i.clear(),i.drawPiano(),i.draw(),i}return i(e,t),e.prototype.setupDOM=function(t){this.parentElement=document.createElement("div"),this.parentElement.classList.add("waterfall-notes-container");var e=Math.max(t.getBoundingClientRect().height,200);this.parentElement.style.paddingTop=e-this.config.whiteNoteHeight+"px",this.parentElement.style.height=e-this.config.whiteNoteHeight+"px",this.parentElement.style.boxSizing="border-box",this.parentElement.style.overflowX="hidden",this.parentElement.style.overflowY="auto",this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svgPiano=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.classList.add("waterfall-notes"),this.svgPiano.classList.add("waterfall-piano"),this.parentElement.appendChild(this.svg),t.innerHTML="",t.appendChild(this.parentElement),t.appendChild(this.svgPiano)},e.prototype.redraw=function(t,e){if(this.drawn||this.draw(),!t)return null;this.clearActiveNotes(),this.parentElement.style.paddingTop=this.parentElement.style.height;for(var n=0;n<this.noteSequence.notes.length;n++){var r=this.noteSequence.notes[n];if(t&&this.isPaintingActiveNote(r,t)){var i=this.svg.querySelector('rect[data-index="'+n+'"]');this.fillActiveRect(i,r);var s=this.svgPiano.querySelector('rect[data-pitch="'+r.pitch+'"]');if(this.fillActiveRect(s,r),r===t){var a=parseFloat(i.getAttribute("y")),o=parseFloat(i.getAttribute("height"));return a<this.parentElement.scrollTop-o&&(this.parentElement.scrollTop=a+o),a}}}return null},e.prototype.getSize=function(){this.updateMinMaxPitches(!0);var t=52;if(this.config.showOnlyOctavesUsed){for(var e=!1,n=!1,r=1;r<7;r++){var i=this.LOW_C+this.NOTES_PER_OCTAVE*r;!e&&i>this.config.minPitch&&(this.firstDrawnOctave=r-1,e=!0),!n&&i>this.config.maxPitch&&(this.lastDrawnOctave=r-1,n=!0)}t=(this.lastDrawnOctave-this.firstDrawnOctave+1)*this.WHITE_NOTES_PER_OCTAVE}var s=t*this.config.whiteNoteWidth,a=this.noteSequence.totalTime;if(!a)throw new Error("The sequence you are using with the visualizer does not have a totalQuantizedSteps or totalTime field set, so the visualizer can't be horizontally sized correctly.");return{width:s,height:Math.max(a*this.config.pixelsPerTimeStep,1)}},e.prototype.getNotePosition=function(t,e){var n=this.svgPiano.querySelector('rect[data-pitch="'+t.pitch+'"]');if(!n)return null;var r=this.getNoteEndTime(t)-this.getNoteStartTime(t),i=Number(n.getAttribute("x")),s=Number(n.getAttribute("width")),a=Math.max(this.config.pixelsPerTimeStep*r-this.config.noteSpacing,1);return{x:i,y:this.height-this.getNoteStartTime(t)*this.config.pixelsPerTimeStep-a,w:s,h:a}},e.prototype.drawPiano=function(){this.svgPiano.innerHTML="";var t=this.config.whiteNoteWidth-this.config.blackNoteWidth/2,e=[1,3,6,8,10],n=0,r=0;this.config.showOnlyOctavesUsed?r=this.firstDrawnOctave*this.NOTES_PER_OCTAVE+this.LOW_C:(r=this.LOW_C-3,this.drawWhiteKey(r,n),this.drawWhiteKey(r+2,this.config.whiteNoteWidth),r+=3,n=2*this.config.whiteNoteWidth);for(var i=this.firstDrawnOctave;i<=this.lastDrawnOctave;i++)for(var s=0;s<this.NOTES_PER_OCTAVE;s++)-1===e.indexOf(s)&&(this.drawWhiteKey(r,n),n+=this.config.whiteNoteWidth),r++;this.config.showOnlyOctavesUsed?(r=this.firstDrawnOctave*this.NOTES_PER_OCTAVE+this.LOW_C,n=-this.config.whiteNoteWidth):(this.drawWhiteKey(r,n),r=this.LOW_C-3,this.drawBlackKey(r+1,t),r+=3,n=this.config.whiteNoteWidth);for(i=this.firstDrawnOctave;i<=this.lastDrawnOctave;i++)for(s=0;s<this.NOTES_PER_OCTAVE;s++)-1!==e.indexOf(s)?this.drawBlackKey(r,n+t):n+=this.config.whiteNoteWidth,r++},e.prototype.drawWhiteKey=function(t,e){var n=document.createElementNS("http://www.w3.org/2000/svg","rect");return n.dataset.pitch=String(t),n.setAttribute("x",String(e)),n.setAttribute("y","0"),n.setAttribute("width",String(this.config.whiteNoteWidth)),n.setAttribute("height",String(this.config.whiteNoteHeight)),n.setAttribute("fill","white"),n.setAttribute("original-fill","white"),n.setAttribute("stroke","black"),n.setAttribute("stroke-width","3px"),n.classList.add("white"),this.svgPiano.appendChild(n),n},e.prototype.drawBlackKey=function(t,e){var n=document.createElementNS("http://www.w3.org/2000/svg","rect");return n.dataset.pitch=String(t),n.setAttribute("x",String(e)),n.setAttribute("y","0"),n.setAttribute("width",String(this.config.blackNoteWidth)),n.setAttribute("height",String(this.config.blackNoteHeight)),n.setAttribute("fill","black"),n.setAttribute("original-fill","black"),n.setAttribute("stroke","black"),n.setAttribute("stroke-width","3px"),n.classList.add("black"),this.svgPiano.appendChild(n),n},e.prototype.clearActiveNotes=function(){t.prototype.unfillActiveRect.call(this,this.svg);for(var e=this.svgPiano.querySelectorAll("rect.active"),n=0;n<e.length;++n){var r=e[n];r.setAttribute("fill",r.getAttribute("original-fill")),r.classList.remove("active")}},e}(d);e.WaterfallSVGVisualizer=m,function(t){t[t.PAGE=0]="PAGE",t[t.NOTE=1]="NOTE",t[t.BAR=2]="BAR"}(f=e.ScrollType||(e.ScrollType={}));var g=function(t){function e(e,n,r){void 0===r&&(r={});var i=t.call(this,e,r)||this;return(void 0===r.pixelsPerTimeStep||r.pixelsPerTimeStep<=0)&&(i.config.pixelsPerTimeStep=0),i.instruments=r.instruments||[],i.render=new s.StaffSVGRender(i.getScoreInfo(e),{noteHeight:i.config.noteHeight,noteSpacing:i.config.noteSpacing,pixelsPerTimeStep:i.config.pixelsPerTimeStep,noteRGB:i.config.noteRGB,activeNoteRGB:i.config.activeNoteRGB,defaultKey:r.defaultKey||0,scrollType:r.scrollType||f.PAGE},n),i.drawnNotes=e.notes.length,i.clear(),i.redraw(),i}return i(e,t),e.prototype.clear=function(){this.render.clear()},e.prototype.redraw=function(t,e){this.drawnNotes!==this.noteSequence.notes.length&&(this.render.scoreInfo=this.getScoreInfo(this.noteSequence));var n=t?this.getNoteInfo(t):void 0;return this.render.redraw(n,e)},e.prototype.isNoteInInstruments=function(t){return void 0===t.instrument||0===this.instruments.length||this.instruments.indexOf(t.instrument)>=0},e.prototype.timeToQuarters=function(t){var e=t*this.noteSequence.tempos[0].qpm/60;return Math.round(16*e)/16},e.prototype.getNoteInfo=function(t){var e=this.timeToQuarters(t.startTime);return{start:e,length:this.timeToQuarters(t.endTime)-e,pitch:t.pitch,intensity:t.velocity}},e.prototype.getScoreInfo=function(t){var e=this,n=[];return t.notes.forEach((function(t){e.isNoteInInstruments(t)&&n.push(e.getNoteInfo(t))})),{notes:n,tempos:t.tempos?t.tempos.map((function(t){return{start:e.timeToQuarters(t.time),qpm:t.qpm}})):[],keySignatures:t.keySignatures?t.keySignatures.map((function(t){return{start:e.timeToQuarters(t.time),key:t.key}})):[],timeSignatures:t.timeSignatures?t.timeSignatures.map((function(t){return{start:e.timeToQuarters(t.time),numerator:t.numerator,denominator:t.denominator}})):[]}},e.prototype.clearActiveNotes=function(){this.redraw()},e}(c);e.StaffSVGVisualizer=g},function(t,e,n){self,t.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=4)}([function(t,e,n){"use strict";n.r(e),n.d(e,"SVGNS",(function(){return r})),n.d(e,"drawSVGPath",(function(){return i})),n.d(e,"drawSVGText",(function(){return s})),n.d(e,"createSVGGroupChild",(function(){return a})),n.d(e,"setFade",(function(){return o}));const r="http://www.w3.org/2000/svg";function i(t,e,n,i,s,a,o=1){const u=document.createElementNS(r,"path");return u.setAttributeNS(null,"d",e),u.setAttributeNS(null,"transform",`translate(${n}, ${i}) scale(${s}, ${a})`),u.setAttributeNS(null,"opacity",""+o),t.appendChild(u),u}function s(t,e,n,i,s,a=!1,o=1,u=1){const c=document.createElementNS(r,"text");c.setAttributeNS(null,"font-family","Times"),c.setAttributeNS(null,"font-size",s),a&&c.setAttributeNS(null,"font-weight","bold"),c.setAttributeNS(null,"transform",`translate(${n}, ${i}) scale(${o}, ${u})`);const l=document.createTextNode(e);return c.appendChild(l),t.appendChild(c),c}function a(t,e){const n=document.createElementNS(r,"g");return n.setAttribute("data-id",e),t.appendChild(n),n}function o(t,e=!1,n=1,i=0){let s=t.querySelector("animate");if(!s){(s=document.createElementNS(r,"animate")).setAttributeNS(null,"attributeName","opacity"),s.setAttributeNS(null,"dur","4s"),s.setAttributeNS(null,"fill","freeze"),s.setAttributeNS(null,"keyTimes","0; 0.25; 0.5; 0.75; 1");const t=(n+3*i)/4;s.setAttributeNS(null,"values",`${n}; ${t}; ${i}; ${t}; ${n}`)}return e?s.setAttributeNS(null,"repeatCount","indefinite"):s.setAttributeNS(null,"repeatCount","1"),t.appendChild(s),t}},function(t,e,n){"use strict";n.r(e),n.d(e,"PATH_SCALE",(function(){return r})),n.d(e,"staffLinePath",(function(){return s})),n.d(e,"extraLinePath",(function(){return a})),n.d(e,"barPath",(function(){return o})),n.d(e,"stemPath",(function(){return u})),n.d(e,"singleFlagPath",(function(){return c})),n.d(e,"multiFlagPath",(function(){return l})),n.d(e,"tiePath",(function(){return h})),n.d(e,"dotPath",(function(){return d})),n.d(e,"NOTE_PATHS",(function(){return p})),n.d(e,"REST_PATHS",(function(){return f})),n.d(e,"CLEF_PATHS",(function(){return m})),n.d(e,"ACCIDENTAL_PATHS",(function(){return g}));const r=100,i="M 0,10 C 0,-15 35,-50 80,-50 110,-50 125,-35 125,-10 \n125,15 90,50 45,50 15,50 0,35 0,10 Z",s="m 0,0 h 100",a="m -25,0 h 175",o="m 0,-200 v 400",u="m 0,0 v 100 h 15 v -100 z",c="M0,0 h 12 c 7,100 175,156 62,314 79,-177 -49,\n-193 -61,-200 l -13,-5 z",l="m 0,0 h 10 c 6,72 173,64 84,227 44,-120 -44,\n-123 -94,-167 z",h="M 0,25 C 10,46 30,67 50,67 69,67 90,47 100,25 94,\n65 73,89 50,89 26,89 5,63 0,25 Z",d="M 5 -20 a 20 20 0 1 0 0.00001 0 z",p={4:{path:"m 0,0 c 0,-37 49,-51 79,-51 31,0 83,13 83,51 0,39 \n-55,51 -84,51 C 49,51 0,37 0,0 Z m 111,31 c 13,-19 0,-58 -22,-68 -33,-15 \n-53,10 -39,49 9,27 48,39 61,19 z",width:150,stemVSteps:0,stemAnchor:0,flags:0},2:{path:"m 0,10 c 0,-25 35,-60 80,-60 15,0 45,4 45,40 C 125,16 \n89,50 45,50 17,50 0,36 0,10 Z m 71,7 c 17,-11 45,-34 38,-45 -7,-10 -39,1 \n-57,12 -19,11 -42,31 -36,42 6,10 37,2 55,-9 z",width:125,stemVSteps:7,stemAnchor:-10,flags:0},1:{path:i,width:125,stemVSteps:7,stemAnchor:-10,flags:0},.5:{path:i,width:125,stemVSteps:7,stemAnchor:-10,flags:1},.25:{path:i,width:125,stemVSteps:9,stemAnchor:-10,flags:2},.125:{path:i,width:125,stemVSteps:11,stemAnchor:-10,flags:3},.0625:{path:i,width:125,stemVSteps:13,stemAnchor:-10,flags:4}},f={4:"m 0,-50 h 125 v -50 H 0 Z",2:"M 0,0 H 125 V -50 H 0 Z",1:"m 0,-25 c 39,-39 37,-75 8,-120 l 6,-5 61,103 C \n40,-13 31,4 73,71 l -5,5 C 14,52 16,125 67,144 l -4,6 C -37,102 -1,22 59,60 Z",.5:"m 52,-47 c 26,-2 42,-21 48,-42 l 12,4 L 64,83 52,79 \n88,-49 c 0,0 -17,22 -57,22 -16,0 -31,-13 -31,-27 0,-18 10,-31 27,-31 17,0 \n33,15 25,38 z",.25:"m 129,-191 c -6,21 -22,40 -48,42 8,-23 -8,-38 \n-25,-38 -17,0 -27,13 -27,31 0,14 15,27 31,27 40,0 57,-22 57,-22 l -20,69 \nc -7,18 -22,33 -45,35 8,-23 -8,-38 -25,-38 -17,0 -27,13 -27,31 0,14 15,27 \n31,27 40,0 57,-22 57,-22 l -36,128 12,4 77,-270 z",.125:"m 129,-191 c -6,21 -22,40 -48,42 8,-23 -8,-38 \n-25,-38 -17,0 -27,13 -27,31 0,14 15,27 31,27 40,0 57,-22 57,-22 l -20,69 \nc -7,18 -22,33 -45,35 8,-23 -8,-38 -25,-38 -17,0 -27,13 -27,31 0,14 15,27 \n31,27 40,0 57,-22 57,-22 L 68,20 C 61,37 46,51 24,52 32,29 16,14 -1,14 c \n-17,0 -27,13 -27,31 0,14 15,27 31,27 38,0 55,-20 57,-22 l -36,128 12,4 \n105,-369 z",.0625:"m 158,-292 c -6,21 -22,40 -48,42 8,-23 -8,-38 \n-25,-38 -17,0 -27,13 -27,31 0,14 15,27 31,27 40,0 57,-22 57,-22 l -17,61 \nv 0 c -6,21 -22,40 -48,42 8,-23 -8,-38 -25,-38 -17,0 -27,13 -27,31 0,14 \n15,27 31,27 40,0 57,-22 57,-22 l -20,69 c -7,18 -22,33 -45,35 8,-23 -8,-38 \n-25,-38 -17,0 -27,13 -27,31 0,14 15,27 31,27 40,0 57,-22 57,-22 L 68,20 C \n61,37 46,51 24,52 32,29 16,14 -1,14 c -17,0 -27,13 -27,31 0,14 15,27 31,27 \n38,0 55,-20 57,-22 l -36,128 12,4 134,-469 z"},m={50:{path:"m 101,-199 c -49,0 -100,28 -100,83 0,39 58,57 82,26 15,-20 \n-4,-47 -32,-47 -23,1 -25,0 -25,-8 0,-22 40,-46 71,-41 91,16 67,208 -105,302 \n75,-27 198,-94 211,-201 6,-66 -42,-114 -102,-114 z m 143,33 c -13,0 -23,11 \n-23,24 0,14 10,24 23,24 13,0 23,-11 23,-24 0,-13 -10,-24 -23,-24 z m 2,83 c \n-13,0 -23,11 -23,24 0,14 10,24 23,24 13,0 23,-11 23,-24 0,-13 -10,-24 -23,-24 \nz",upper:-4,lower:3},71:{path:"M 139,48 C 102,57 76,120 131,151 41,128 64,24 129,2 L \n117,-57 C -32,47 26,217 166,182 Z m 12,-1 27,131 C 242,153 216,46 151,47 \nZ m -35,-177 c 34,-23 82,-117 50,-140 -23,-17 -71,33 -50,140 z m -10,10 c \n-23,-77 -20,-200 48,-213 19,-4 89,171 -26,266 l 13,66 c 120,-6 137,155 \n39,191 l 12,58 c 30,131 -137,145 -138,47 0,-29 37,-59 63,-37 21,18 25,71 \n-25,70 32,42 103,0 91,-65 L 167,193 C 56,232 -112,63 106,-120 Z",upper:-7,lower:8}},g=[null,"m -49,-121 v 52 l -29,9 v -48 h -8 v 51 l -20,6 v 29 l \n20,-6 v 70 l -20,6 v 30 l 20,-6 v 51 h 8 V 69 l 30,-8 v 50 h 8 V 58 l 20,-6 \nV 23 l -20,6 v -71 l 20,-6 v -29 l -20,6 v -50 z m 1,82 v 71 l -29,9 v -71 z","M -106,-166 V 67 c 52,-42 85,-56 85,-94 0,-47 -46,-51 \n-73,-22 v -117 z m 31,120 c 20,0 42,46 -20,91 V -7 c 0,-28 10,-39 20,-39 z","m -81,-58 v -48 H -92 V 73 l 60,-13 v 50 h 11 V -72 Z m \n50,24 v 58 l -50,11 v -58 z"]},function(t,e,n){"use strict";n.r(e),n.d(e,"MIN_RESOLUTION",(function(){return r})),n.d(e,"STEM_WIDTH",(function(){return i})),n.d(e,"LINE_STROKE",(function(){return s})),n.d(e,"COMPACT_SPACING",(function(){return a}));const r=.0625,i=15,s=1,a=150},function(t,e,n){"use strict";n.r(e),n.d(e,"MAX_QUARTER_DIVISION",(function(){return u})),n.d(e,"ScrollType",(function(){return c})),n.d(e,"StaffSVGRender",(function(){return l}));var r=n(2),i=n(0),s=n(1);const a=[{steps:[0,0,-1,-1,-2,-3,-3,-4,-4,-5,-5,-6],accidental:[0,1,0,1,0,0,1,0,1,0,1,0]},{steps:[0,-1,-1,-2,-2,-3,-4,-4,-5,-5,-6,-6],accidental:[0,0,3,0,3,0,0,3,0,3,0,3]},{steps:[0,0,-1,-1,-2,-3,-3,-4,-4,-5,-5,-6],accidental:[3,0,0,1,0,3,0,0,1,0,1,0]},{steps:[0,-1,-1,-2,-2,-3,-4,-4,-5,-5,-6,-6],accidental:[0,2,0,0,3,0,2,0,0,3,0,3]},{steps:[0,0,-1,-1,-2,-3,-3,-4,-4,-5,-5,-6],accidental:[3,0,3,0,0,3,0,3,0,0,1,0]},{steps:[0,-1,-1,-2,-2,-3,-4,-4,-5,-5,-6,-6],accidental:[0,2,0,2,0,0,2,0,2,0,0,3]},{steps:[0,-1,-1,-2,-2,-3,-4,-4,-5,-5,-6,-7],accidental:[3,0,3,0,3,0,0,3,0,3,0,0]},{steps:[0,0,-1,-1,-2,-3,-3,-4,-4,-5,-5,-6],accidental:[0,1,0,1,0,3,0,0,1,0,1,0]},{steps:[0,-1,-1,-2,-2,-3,-4,-4,-5,-5,-6,-6],accidental:[0,0,3,0,3,0,2,0,0,3,0,3]},{steps:[0,0,-1,-1,-2,-3,-3,-4,-4,-5,-5,-6],accidental:[3,0,0,1,0,3,0,3,0,0,1,0]},{steps:[0,-1,-1,-2,-2,-3,-4,-4,-5,-5,-6,-6],accidental:[0,2,0,0,3,0,2,0,2,0,0,3]},{steps:[0,0,-1,-1,-2,-3,-3,-4,-4,-5,-5,-6],accidental:[3,0,3,0,0,3,0,3,0,3,0,0]}],o=[{accidental:1,pitches:[]},{accidental:2,pitches:[70,75,68,73,66]},{accidental:1,pitches:[78,73]},{accidental:2,pitches:[70,75,68]},{accidental:1,pitches:[78,73,80,75]},{accidental:2,pitches:[70]},{accidental:2,pitches:[70,75,68,73,66,71]},{accidental:1,pitches:[78]},{accidental:2,pitches:[70,75,68,73]},{accidental:1,pitches:[78,73,80]},{accidental:2,pitches:[70,75]},{accidental:1,pitches:[78,73,80,75,70]}],u=16;var c;!function(t){t[t.PAGE=0]="PAGE",t[t.NOTE=1]="NOTE",t[t.BAR=2]="BAR"}(c||(c={}));class l{constructor(t,e,n){this.handleScrollEvent=t=>{this.lastKnownScrollLeft=this.parentElement.scrollLeft,this.ticking||window.requestAnimationFrame(()=>{this.changeAndDrawSignaturesIfNeeded(this.lastKnownScrollLeft),this.ticking=!1}),this.ticking=!0},this.scoreInfo=t,this.config={noteHeight:e.noteHeight||6,noteSpacing:e.noteSpacing||1,pixelsPerTimeStep:e.pixelsPerTimeStep||30,noteRGB:e.noteRGB||"8, 41, 64",activeNoteRGB:e.activeNoteRGB||"240, 84, 119"},this.div=n,this.timeSignatureNumerator=4,this.timeSignatureDenominator=4,this.key=e.defaultKey||0,this.scrollType=e.scrollType||c.PAGE,this.scale=this.config.noteHeight/s.PATH_SCALE,(void 0===e.pixelsPerTimeStep||e.pixelsPerTimeStep<=0)&&(this.config.pixelsPerTimeStep=0,this.config.noteSpacing=r.COMPACT_SPACING*this.scale),this.clear(),this.redraw()}clear(){for(;this.div.lastChild;)this.div.removeChild(this.div.lastChild);this.div.style.overflow="visible",this.div.style.position="relative",this.overlaySVG=document.createElementNS(i.SVGNS,"svg"),this.overlaySVG.style.position="absolute",this.div.appendChild(this.overlaySVG),this.overlayG=Object(i.createSVGGroupChild)(this.overlaySVG,"overlay"),this.signaturesBlinking=!1,this.signaturesQuarters=0,this.parentElement=document.createElement("div"),this.parentElement.style.overflow="auto",this.div.appendChild(this.parentElement),this.ticking=!1,this.lastKnownScrollLeft=0,this.parentElement.addEventListener("scroll",this.handleScrollEvent),this.staffSVG=document.createElementNS(i.SVGNS,"svg"),this.parentElement.appendChild(this.staffSVG),this.staffG=Object(i.createSVGGroupChild)(this.staffSVG,"staff"),this.linesG=Object(i.createSVGGroupChild)(this.staffSVG,"lines"),this.setStroke(this.linesG),this.staffG.appendChild(this.linesG),this.musicG=Object(i.createSVGGroupChild)(this.staffSVG,"music"),this.setFill(this.musicG),this.setStroke(this.musicG,0),this.staffG.appendChild(this.musicG),this.signaturesG=Object(i.createSVGGroupChild)(this.staffSVG,"signatures"),this.staffG.appendChild(this.signaturesG);let t=0,e=0;this.scoreInfo.notes.forEach(n=>{t+=n.pitch,++e});const n=t/e;this.clef=n<60?50:71,this.signaturesList=[{x:0,q:0}],this.signatureCurrent=0,this.signatureNext=0,this.changeKeySignatureIfNeeded(0),this.changeTimeSignatureIfNeeded(0),this.vStepSize=this.config.noteHeight/2,this.hStepSize=this.config.pixelsPerTimeStep,this.staffOffset=0,this.height=0,this.width=0,this.musicBlockMap=new Map,this.playingNotes=[],this.lastBar=0,this.barAccidentals={},this.lastQ=-1}isPaintingActiveNote(t,e){const n=t.start===e.start,r=t.start<=e.start&&t.start+t.length>=e.start+e.length;return n||r}redraw(t,e){let n=-1;const r=0===this.config.pixelsPerTimeStep;if(t){const s=[];this.playingNotes.forEach(e=>{this.isPaintingActiveNote(e,t)?s.push(e):this.highlightElement(this.getGroup(e),!1)}),this.playingNotes=s;const a=this.getGroup(t);if(a){this.playingNotes.push(t),this.highlightElement(a,!0),n=a.getBoundingClientRect().left-this.staffSVG.getBoundingClientRect().left;const s=t.start,o=a.getAttribute("data-is-bar-beginning");(this.scrollType!==c.BAR||o)&&this.scrollIntoViewIfNeeded(e,n),!r&&this.signaturesBlinking&&s>=this.signaturesQuarters&&(this.signaturesBlinking=!1,Object(i.setFade)(this.overlayG,this.signaturesBlinking))}}else{this.setDetails();const t=-1===this.lastQ;let e=0,n=0;t?(n=this.drawSignatures(this.overlayG,e,!0,!0,!0),r&&(this.width=0,n+=this.config.noteSpacing),n+=this.drawRests(this.initialRest,e+n)):e=this.width,this.musicBlockMap.forEach((t,i)=>{r||(e=this.quartersToTime(i)*this.hStepSize),i>this.lastQ?(n+=this.drawMusicBlock(t,e+n),this.lastQ=i):i===this.lastQ&&(n+=this.drawRests(t,e+n))});const i=this.staffSVG.getBoundingClientRect(),s=this.musicG.getBoundingClientRect();if(this.updateVerticalBoundaries(s.top-i.top,s.bottom-i.top),r)this.width+=n;else{const t=this.musicBlockMap.get(this.lastQ),e=this.quartersToTime(this.lastQ+t.notes[0].length);this.width=e*this.config.pixelsPerTimeStep}this.staffSVG.setAttributeNS(null,"width",""+this.width),this.redrawStaff(this.linesG,0,this.width)}return n}drawMusicBlock(t,e){const n=t.notes[0].start;let a=this.drawBarIfNeeded(n,e);a+=this.drawSignaturesIfNeeded(n,e+a);let o=0;for(let e=4;e>=r.MIN_RESOLUTION&&!o;e/=2)e<=t.notes[0].length&&(o=e);if(0===o){const e=0===t.notes[0].length?"[infinite]":""+4/t.notes[0].length;console.warn(" StaffRender ","background:orange; color:white",`StaffRender does not handle notes shorther than 1/${4/r.MIN_RESOLUTION}th, and this score tries to draw a 1/${e}th. Shortest possible note will be drawn instead.`),o=r.MIN_RESOLUTION}const u=s.NOTE_PATHS[o];let c;if(u.stemAnchor&&(c=Object(i.createSVGGroupChild)(this.musicG,"stem")),t.notes.forEach(n=>{const r=n.vSteps*this.vStepSize,c=2*(n.vSteps>0?Math.floor(n.vSteps/2):Math.ceil(n.vSteps/2)),l=n.vSteps>0?-2:2;for(let t=c;Math.abs(t)>4;t+=l)Object(i.drawSVGPath)(this.linesG,s.extraLinePath,e+a,t*this.vStepSize,this.scale,1);if(n.g=n.tiedFrom?n.tiedFrom.g:Object(i.createSVGGroupChild)(this.musicG,`${n.start}-${n.pitch}`),t.isBarBeginning&&n.g.setAttribute("data-is-bar-beginning","true"),n.tiedFrom){const t=e+a-n.tiedFrom.xHeadRight;Object(i.drawSVGPath)(n.g,s.tiePath,n.tiedFrom.xHeadRight,r,t/s.PATH_SCALE,this.scale*(n.vSteps<0?-1:1),n.opacity)}Object(i.drawSVGPath)(n.g,u.path,e+a,r,this.scale,this.scale,n.opacity),n.xHeadRight=e+a+u.width*this.scale,1.5*o<=n.length&&Object(i.drawSVGPath)(n.g,s.dotPath,e+a+u.width*this.scale+this.vStepSize/2,r-this.vStepSize/2,this.scale,this.scale,n.opacity),0!==n.accidental&&Object(i.drawSVGPath)(n.g,s.ACCIDENTAL_PATHS[n.accidental],e+a,r,this.scale,this.scale,n.opacity)}),u.stemAnchor){let n,o,l=e+a;const h=u.stemAnchor*this.scale,d=t.minVStep+t.maxVStep<0,p=u.flags>2?2*(u.flags-2):0;if(d?(n=t.maxVStep*this.vStepSize-h,o=(t.minVStep+7+p)*this.vStepSize):(l+=(u.width-r.STEM_WIDTH)*this.scale,n=t.minVStep*this.vStepSize+h,o=(t.maxVStep-7-p)*this.vStepSize),Object(i.drawSVGPath)(c,s.stemPath,l,n,this.scale,(o-n)/s.PATH_SCALE),1===u.flags)Object(i.drawSVGPath)(c,s.singleFlagPath,l,o,this.scale,this.scale*(d?-1:1),1);else if(u.flags>1)for(let t=0;t<u.flags;++t)Object(i.drawSVGPath)(c,s.multiFlagPath,l,o,this.scale,this.scale*(d?-1:1),1),o+=(d?-2:2)*this.vStepSize}return 0===this.config.pixelsPerTimeStep&&(a+=u.width*this.scale,c&&(a+=c.getBoundingClientRect().width),a+=this.config.noteSpacing),a+=this.drawRests(t,e+a)}drawBarIfNeeded(t,e){let n=0;const r=this.lastBar+this.getBarLength();return 0!==t&&t>=r&&(this.config.pixelsPerTimeStep>0?e-=this.config.noteSpacing:n=this.config.noteSpacing,Object(i.drawSVGPath)(this.linesG,s.barPath,e,0,1,this.scale),this.lastBar=r),n}drawRests(t,e){let n=0,a=t.restToNextLength;if(a){this.config.pixelsPerTimeStep>0&&(e+=this.quartersToTime(t.notes[0].length)*this.hStepSize);let o=t.notes[0].start+t.notes[0].length,u=0;const c=this.lastBar+this.getBarLength()-o;let l;for(a>c&&(u=a-c,a=c),l=4;l>this.getBarLength()&&l>=r.MIN_RESOLUTION;l/=2);let h=l;for(;(a||u)&&h>=r.MIN_RESOLUTION;){if(h<=a){n+=this.drawBarIfNeeded(o,e+n),n+=this.drawSignaturesIfNeeded(o,e+n);const t=Object(i.drawSVGPath)(this.musicG,s.REST_PATHS[h],e+n,0,this.scale,this.scale);this.config.pixelsPerTimeStep>0?e+=this.quartersToTime(h)*this.hStepSize:(n+=t.getBoundingClientRect().width,n+=this.config.noteSpacing),o+=h,a-=h}if(u&&a<=0){const t=this.getBarLength();for(u>t?(a=t,u-=t):(a=u,u=0),l=4;l>this.getBarLength()&&l>=r.MIN_RESOLUTION;l/=2);h=l}a<h&&(h/=2)}}return n}redrawStaff(t,e,n){let r=t.querySelector('g[data-id="staff-five-lines"]');if(r)r.setAttributeNS(null,"transform",`scale(${n/s.PATH_SCALE}, 1)`);else{r=Object(i.createSVGGroupChild)(t,"staff-five-lines");const a=0;for(let t=-4;t<=4;t+=2)Object(i.drawSVGPath)(r,s.staffLinePath,e,a+t*this.vStepSize,n/s.PATH_SCALE,1)}return r}clearSignatureOverlay(){for(;this.overlayG.lastChild;)this.overlayG.removeChild(this.overlayG.lastChild)}drawSignaturesIfNeeded(t,e){let n=0;const s=this.changeKeySignatureIfNeeded(t),a=this.changeTimeSignatureIfNeeded(t);if(s||a){const o=r.COMPACT_SPACING*this.scale*(this.config.pixelsPerTimeStep>0?3:2);this.signaturesList.push({x:e-o,q:t}),null===this.signatureNext&&(this.signatureNext=e);const u=t>0?Object(i.createSVGGroupChild)(this.signaturesG,"signatures"):this.overlayG;n+=this.drawSignatures(u,e+n,!1,s,a)}return 0===this.config.pixelsPerTimeStep?n:0}drawSignatures(t,e,n,a,u){const c=r.COMPACT_SPACING*this.scale;let l,h=c;const d=t===this.overlayG||this.config.pixelsPerTimeStep>0;if(d){(l=document.createElementNS(i.SVGNS,"rect")).setAttributeNS(null,"x",""+e),l.setAttributeNS(null,"y","0"),l.setAttributeNS(null,"width","1"),l.setAttributeNS(null,"height","1"),l.setAttribute("data-id","background"),t.appendChild(l);const n=document.defaultView.getComputedStyle(this.div.parentElement);l.setAttributeNS(null,"fill",n.getPropertyValue("background-color"))}if(n){const n=Object(i.drawSVGPath)(t,s.CLEF_PATHS[this.clef].path,e+h,0,this.scale,this.scale);this.setFill(n),h+=3*c}if(a){const n=o[this.key].accidental,r=71===this.clef?0:14;o[this.key].pitches.forEach(a=>{const o=this.getPitchDetails(a).vSteps,u=Object(i.drawSVGPath)(t,s.ACCIDENTAL_PATHS[n],e+h,(r+o)*this.vStepSize,this.scale,this.scale);this.setFill(u),h+=u.getBoundingClientRect().width})}if(u){const n=Object(i.createSVGGroupChild)(t,"time-key"),r=2.85*this.config.noteHeight+"px";Object(i.drawSVGText)(n,""+this.timeSignatureNumerator,e+h,-.5,r,!0),Object(i.drawSVGText)(n,""+this.timeSignatureDenominator,e+h,4*this.vStepSize-.5,r,!0),this.setFill(n),h+=n.getBoundingClientRect().width+c}const p=this.redrawStaff(t,e,h);this.setStroke(p);const f=this.div.getBoundingClientRect(),m=t.getBoundingClientRect();if(this.updateVerticalBoundaries(m.top-f.top,m.bottom-f.top),d&&(l.setAttributeNS(null,"y",""+-this.staffOffset),l.setAttributeNS(null,"height",""+this.height),l.setAttributeNS(null,"width",""+h)),t===this.overlayG){this.overlaySVG.setAttributeNS(null,"width",""+(h+5));for(let e=0;e<5;++e){const n=Object(i.drawSVGPath)(t,s.stemPath,h+e,e*e-this.staffOffset,1/r.STEM_WIDTH,(this.height-2*e*e)/s.PATH_SCALE,(e-5)*(e-5)*2/s.PATH_SCALE);this.setFill(n)}}if(this.config.pixelsPerTimeStep>0){const n=0===this.signaturesQuarters;return n&&(this.signaturesQuarters=this.timeToQuarters(h/this.hStepSize)),(n||e>0)&&(this.signaturesBlinking=!0,Object(i.setFade)(t,this.signaturesBlinking)),0}return h}changeKeySignatureIfNeeded(t){if(this.scoreInfo.keySignatures){let e=this.key;for(let n=0;n<this.scoreInfo.keySignatures.length&&this.scoreInfo.keySignatures[n].start<=t;++n)e=this.scoreInfo.keySignatures[n].key;if(e!==this.key)return this.key=e,!0}return!1}changeTimeSignatureIfNeeded(t){if(this.scoreInfo.timeSignatures){let e=this.timeSignatureNumerator,n=this.timeSignatureDenominator;for(let r=0;r<this.scoreInfo.timeSignatures.length&&this.scoreInfo.timeSignatures[r].start<=t;++r)e=this.scoreInfo.timeSignatures[r].numerator,n=this.scoreInfo.timeSignatures[r].denominator;if(e!==this.timeSignatureNumerator||n!==this.timeSignatureDenominator)return this.timeSignatureNumerator=e,this.timeSignatureDenominator=n,!0}return!1}changeAndDrawSignaturesIfNeeded(t){let e;if(t<this.signatureCurrent||null!==this.signatureNext&&this.signatureNext<=t){e=this.signaturesList[0].q,this.signatureNext=null;for(let n=0;n<this.signaturesList.length;++n){if(t<this.signaturesList[n].x){this.signatureNext=this.signaturesList[n].x;break}this.signatureCurrent=this.signaturesList[n].x,e=this.signaturesList[n].q}}if(void 0!==e){const t=this.key,n=this.timeSignatureNumerator,r=this.timeSignatureDenominator;this.changeKeySignatureIfNeeded(e),this.changeTimeSignatureIfNeeded(e),this.clearSignatureOverlay(),this.drawSignatures(this.overlayG,0,!0,!0,!0),this.key=t,this.timeSignatureNumerator=n,this.timeSignatureDenominator=r}this.config.pixelsPerTimeStep>0&&0===t&&(this.signatureNext=0,this.signaturesBlinking=!0,Object(i.setFade)(this.overlayG,this.signaturesBlinking))}getBarLength(){return 4*this.timeSignatureNumerator/this.timeSignatureDenominator}scrollIntoViewIfNeeded(t,e){if(t)if(this.scrollType===c.PAGE){const t=this.parentElement.getBoundingClientRect().width;e>this.parentElement.scrollLeft+t&&(this.parentElement.scrollLeft=e-20)}else{const t=this.parentElement.getBoundingClientRect().width;this.parentElement.scrollLeft=e-.5*t}}updateVerticalBoundaries(t,e){let n=0;if(t<0){this.staffOffset-=t;const e=`translate(0, ${this.staffOffset})`;this.overlayG.setAttributeNS(null,"transform",e),this.staffG.setAttributeNS(null,"transform",e),n=this.height-t}if((n=Math.max(n,e-t))>this.height){this.height=n,this.overlaySVG.setAttributeNS(null,"height",""+this.height),this.staffSVG.setAttributeNS(null,"height",""+this.height);const t=this.div.querySelectorAll('rect[data-id="background"]');for(let e=0;e<t.length;++e){const n=t[e];n.setAttributeNS(null,"y",""+-this.staffOffset),n.setAttributeNS(null,"height",""+this.height)}}}setFill(t,e=!1){t.setAttributeNS(null,"fill",this.getColor(e))}setStroke(t,e=r.LINE_STROKE,n=!1){t.setAttributeNS(null,"stroke",this.getColor(n)),t.setAttributeNS(null,"stroke-width",""+e)}getColor(t){return`rgb(${t?this.config.activeNoteRGB:this.config.noteRGB})`}getOpacity(t){return t?t/127*.8+.2:1}getGroup(t){const e=t.start,n=t.pitch;return this.staffSVG.querySelector(`g[data-id="${e}-${n}"]`)}highlightElement(t,e){t.setAttribute("fill",this.getColor(e)),t.setAttribute("stroke",this.getColor(e))}getBarBeginnings(){const t=new Set;let e=0;this.scoreInfo.notes.forEach(t=>{t.start+t.length>e&&(e=t.start+t.length)});const n=this.scoreInfo.timeSignatures?this.scoreInfo.timeSignatures.slice(0):[{start:0,numerator:4,denominator:4}];n.sort((t,e)=>t.start-e.start);let r=0;for(let i=0;i<n.length;++i){const s=i===n.length-1?e:n[i].start,a=4*n[i].numerator/n[i].denominator;for(;r<s;r+=a)t.add(r)}return t}quartersToTime(t){return t/this.scoreInfo.tempos[0].qpm*60}timeToQuarters(t){return t*this.scoreInfo.tempos[0].qpm/60}setDetails(){let t=new Map;const e=this.getBarBeginnings(),n=new Set(e);this.scoreInfo.notes.slice().sort((t,e)=>t.start-e.start).forEach(e=>{const r=this.getQNote(e);n.add(r.start),n.add(r.start+r.length),t.has(r.start)?t.get(r.start).push(r):t.set(r.start,[r])}),Array.from(n).sort((t,e)=>t-e).forEach(e=>{const n=[];t.forEach(t=>{t.forEach(t=>{const r=this.splitQNote(t,e);r&&n.push(r)})}),n.forEach(e=>{t.has(e.start)?t.get(e.start).push(e):t.set(e.start,[e])})}),t=new Map(Array.from(t).sort((t,e)=>t[0]-e[0]));const r=this.key;let i=null,s=0;const a=e[Symbol.iterator]();let o=a.next();t.forEach((t,e)=>{const n={maxVStep:Number.MAX_SAFE_INTEGER,minVStep:Number.MIN_SAFE_INTEGER,restToNextLength:0,isBarBeginning:!1,notes:[]};this.changeKeySignatureIfNeeded(e);const r=o.value+this.getBarLength();!o.done&&e>=r&&(o=a.next(),this.barAccidentals={},n.isBarBeginning=!0),t.forEach(t=>{this.analyzePitch(t,e),n.minVStep=Math.max(t.vSteps,n.minVStep),n.maxVStep=Math.min(t.vSteps,n.maxVStep),n.notes.push(t)}),i&&(i.restToNextLength=e-s),this.musicBlockMap.set(e,n),i=n,s=e+n.notes[0].length}),this.initialRest={maxVStep:0,minVStep:0,restToNextLength:this.musicBlockMap.values().next().value.notes[0].start,isBarBeginning:!0,notes:[{start:0,length:0,vSteps:0,accidental:0,opacity:0,pitch:0,xHeadRight:0}]},this.key=r}getQNote(t){return{start:t.start,length:t.length,vSteps:0,accidental:0,opacity:this.getOpacity(t.intensity),pitch:t.pitch,xHeadRight:0}}splitQNote(t,e){const n=t.start+t.length-e;return e>t.start&&n>0?(t.length-=n,{start:e,length:n,vSteps:t.vSteps,accidental:t.accidental,opacity:t.opacity,pitch:t.pitch,xHeadRight:0,tiedFrom:t}):null}analyzePitch(t,e){const n=this.getPitchDetails(t.pitch);n.vSteps in this.barAccidentals?n.accidental===this.barAccidentals[n.vSteps]?n.accidental=0:(3===this.barAccidentals[n.vSteps]?n.accidental=n.keyAccidental:0===n.accidental&&(n.accidental=3),this.barAccidentals[n.vSteps]=n.accidental):(t.tiedFrom&&(n.accidental=0),this.barAccidentals[n.vSteps]=n.accidental),t.vSteps=n.vSteps,t.accidental=n.accidental}getPitchDetails(t){const e=t-60,n=Math.floor(e/12),r=e-12*n,i=a[this.key].steps[r],s=71===this.clef?6:-6,u=1===o[this.key].accidental?69+(r+3)%12:64+(r+8)%12;return{vSteps:s-7*n+i,accidental:a[this.key].accidental[r],keyAccidental:o[this.key].pitches.indexOf(u)>-1?o[this.key].accidental:0}}}},function(t,e,n){"use strict";n.r(e);var r=n(3);n.d(e,"MAX_QUARTER_DIVISION",(function(){return r.MAX_QUARTER_DIVISION})),n.d(e,"ScrollType",(function(){return r.ScrollType})),n.d(e,"StaffSVGRender",(function(){return r.StaffSVGRender}))}])},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(356),e)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(357);Object.defineProperty(e,"Coconet",{enumerable:!0,get:function(){return r.Coconet}})},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.Coconet=void 0;var s=n(0),a=n(61),o=n(55),u=n(92),c=n(358),l={useSoftmaxLoss:!0,batchNormVarianceEpsilon:1e-7,numInstruments:4,numFilters:128,numLayers:33,numRegularConvLayers:0,dilation:[[1,1],[2,2],[4,4],[8,8],[16,16],[16,32],[1,1],[2,2],[4,4],[8,8],[16,16],[16,32],[1,1],[2,2],[4,4],[8,8],[16,16],[16,32],[1,1],[2,2],[4,4],[8,8],[16,16],[16,32],[1,1],[2,2],[4,4],[8,8],[16,16],[16,32]],layers:null,interleaveSplitEveryNLayers:16,numPointwiseSplits:4},h=function(){function t(t,e){this.residualPeriod=2,this.outputForResidual=null,this.residualCounter=-1,this.rawVars=null,this.spec=t,this.rawVars=e}return t.prototype.dispose=function(){null!==this.rawVars&&s.dispose(this.rawVars),this.outputForResidual&&this.outputForResidual.dispose()},t.prototype.predictFromPianoroll=function(t,e){var n=this;return s.tidy((function(){for(var r=n.getConvnetInput(t,e),i=n.spec.layers.length,s=0;s<i;s++){n.residualCounter+=1,n.residualSave(r);var a=null;n.spec.interleaveSplitEveryNLayers&&s>0&&s<i-2&&s%(n.spec.interleaveSplitEveryNLayers+1)==0&&(a=n.spec.numPointwiseSplits),r=n.applyConvolution(r,n.spec.layers[s],s,s>=n.spec.numRegularConvLayers,a),r=n.applyResidual(r,0===s,s===i-1,s),r=n.applyActivation(r,n.spec.layers[s],s),r=n.applyPooling(r,n.spec.layers[s],s)}return n.computePredictions(r)}))},t.prototype.computePredictions=function(t){return this.spec.useSoftmaxLoss?t.transpose([0,1,3,2]).softmax().transpose([0,1,3,2]):t.sigmoid()},t.prototype.residualReset=function(){this.outputForResidual=null,this.residualCounter=0},t.prototype.residualSave=function(t){this.residualCounter%this.residualPeriod==1&&(this.outputForResidual=t)},t.prototype.applyResidual=function(t,e,n,r){return null==this.outputForResidual?t:this.outputForResidual.shape[this.outputForResidual.shape.length-1]!==t.shape[t.shape.length-1]?(this.residualReset(),t):(this.residualCounter%this.residualPeriod==0&&(e||n||(t=t.add(this.outputForResidual))),t)},t.prototype.getVar=function(t,e){var n="model/conv"+e+"/"+t;return this.rawVars[n]},t.prototype.getSepConvVar=function(t,e){var n="model/conv"+e+"/SeparableConv2d/"+t;return this.rawVars[n]},t.prototype.getPointwiseSplitVar=function(t,e,n){var r="model/conv"+e+"/split_"+e+"_"+n+"/"+t;return this.rawVars[r]},t.prototype.applyConvolution=function(t,e,n,r,i){if(null==e.filters)return t;var a=e.filters,o=e.convStride||1,u=e.convPad?e.convPad.toLowerCase():"same",c=null;if(r){var l=this.getSepConvVar("depthwise_weights",n);if(i){c=s.depthwiseConv2d(t,l,[o,o],u,"NHWC",e.dilation);for(var h=s.split(c,i,c.rank-1),d=[],p=0;p<i;p++){var f=a[3]/i,m=this.getPointwiseSplitVar("kernel",n,p),g=(v=this.getPointwiseSplitVar("bias",n,p),s.matMul(h[p].reshape([-1,f]),m,!1,!1)),b=s.add(g,v);d.push(b.reshape([h[p].shape[0],h[p].shape[1],h[p].shape[2],f]))}c=s.concat(d,c.rank-1)}else{var y=this.getSepConvVar("pointwise_weights",n),v=this.getSepConvVar("biases",n);c=s.separableConv2d(t,l,y,[o,o],u,e.dilation,"NHWC").add(v)}}else{m=this.getVar("weights",n);var w=e.convStride||1,x=e.convPad?e.convPad.toLowerCase():"same";c=s.conv2d(t,m,[w,w],x,"NHWC",[1,1])}return this.applyBatchnorm(c,n)},t.prototype.applyBatchnorm=function(t,e){var n=this,r=this.getVar("gamma",e),i=this.getVar("beta",e),a=this.getVar("popmean",e),o=this.getVar("popvariance",e);if(c.IS_IOS){var u=o.arraySync()[0][0][0],l=s.tensor(u.map((function(t){return Math.sqrt(t+n.spec.batchNormVarianceEpsilon)})));return t.sub(a).mul(r.div(l)).add(i)}return s.batchNorm(t,s.squeeze(a),s.squeeze(o),s.squeeze(i),s.squeeze(r),this.spec.batchNormVarianceEpsilon)},t.prototype.applyActivation=function(t,e,n){return"identity"===e.activation?t:t.relu()},t.prototype.applyPooling=function(t,e,n){if(null==e.pooling)return t;var r=e.pooling,i=e.poolPad?e.poolPad.toLowerCase():"same";return s.maxPool(t,[r[0],r[1]],[r[0],r[1]],i)},t.prototype.getConvnetInput=function(t,e){return t=s.scalar(1,"float32").sub(e).mul(t),e=s.scalar(1,"float32").sub(e),t.concat(e,3)},t}(),d=function(){function t(t){this.spec=null,this.initialized=!1,this.checkpointURL=t,this.spec=l}return t.prototype.initialize=function(){return r(this,void 0,void 0,(function(){var t,e,n=this;return i(this,(function(r){switch(r.label){case 0:return this.dispose(),t=a.performance.now(),this.instantiateFromSpec(),[4,a.fetch(this.checkpointURL+"/weights_manifest.json").then((function(t){return t.json()})).then((function(t){return s.io.loadWeights(t,n.checkpointURL)}))];case 1:return e=r.sent(),this.convnet=new h(this.spec,e),this.initialized=!0,o.logWithDuration("Initialized model",t,"Coconet"),[2]}}))}))},t.prototype.dispose=function(){this.convnet&&this.convnet.dispose(),this.initialized=!1},t.prototype.isInitialized=function(){return this.initialized},t.prototype.instantiateFromSpec=function(){this.spec.layers=[],this.spec.layers.push({filters:[3,3,2*this.spec.numInstruments,this.spec.numFilters]});for(var t=0;t<this.spec.numLayers-3;t++)this.spec.layers.push({filters:[3,3,this.spec.numFilters,this.spec.numFilters],dilation:this.spec.dilation?this.spec.dilation[t]:null});this.spec.layers.push({filters:[2,2,this.spec.numFilters,this.spec.numFilters]}),this.spec.layers.push({filters:[2,2,this.spec.numFilters,this.spec.numInstruments],activation:"identity"})},t.prototype.infill=function(t,e){return r(this,void 0,void 0,(function(){var n,r,s,a,o,l,h;return i(this,(function(i){switch(i.label){case 0:if(u.assertIsRelativeQuantizedSequence(t),0===t.notes.length)throw new Error("NoteSequence "+t.id+" does not have any notes to infill.");return n=t.totalQuantizedSteps||t.notes[t.notes.length-1].quantizedEndStep,r=c.sequenceToPianoroll(t,n),s=.99,a=96,e?(a=e.numIterations||a,s=e.temperature||s,o=this.getCompletionMaskFromInput(e.infillMask,r)):o=this.getCompletionMask(r),[4,this.run(r,a,s,o)];case 1:return l=i.sent(),h=c.pianorollToSequence(l,n),r.dispose(),l.dispose(),o.dispose(),[2,h]}}))}))},t.prototype.run=function(t,e,n,s){return r(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.gibbs(t,e,n,s)]}))}))},t.prototype.getCompletionMaskFromInput=function(t,e){if(t){for(var n=s.buffer([e.shape[1],4]),r=0;r<t.length;r++)n.set(1,t[r].step,t[r].voice);return s.tidy((function(){return n.toTensor().expandDims(1).tile([1,c.NUM_PITCHES,1]).expandDims(0)}))}return this.getCompletionMask(e)},t.prototype.getCompletionMask=function(t){return s.tidy((function(){var e=t.sum(2,!0).equal(s.scalar(0,"float32"));return s.cast(e,"float32").add(s.zerosLike(t))}))},t.prototype.gibbs=function(t,e,n,a){return r(this,void 0,void 0,(function(){var r,o,u,c,l,h=this;return i(this,(function(d){switch(d.label){case 0:r=s.scalar(e,"float32"),o=t.clone(),u=function(t){var e,u,l;return i(this,(function(i){switch(i.label){case 0:return e=c.yaoSchedule(t,r),u=c.bernoulliMask(o.shape,e,a),[4,s.nextFrame()];case 1:return i.sent(),l=s.tidy((function(){return h.convnet.predictFromPianoroll(o,u)})),[4,s.nextFrame()];case 2:return i.sent(),o=s.tidy((function(){var t=h.samplePredictions(l,n),r=s.where(s.cast(u,"bool"),t,o);return o.dispose(),l.dispose(),u.dispose(),e.dispose(),r})),[4,s.nextFrame()];case 3:return i.sent(),[2]}}))},c=this,l=0,d.label=1;case 1:return l<e?[5,u(l)]:[3,4];case 2:d.sent(),d.label=3;case 3:return l++,[3,1];case 4:return r.dispose(),[2,o]}}))}))},t.prototype.yaoSchedule=function(t,e){return s.tidy((function(){var n=s.scalar(.1,"float32"),r=s.scalar(.9,"float32"),i=s.scalar(.7,"float32"),a=r.sub(n).mul(s.scalar(t,"float32")).div(e),o=r.sub(a).div(i);return n.reshape([1]).concat(o.reshape([1])).max()}))},t.prototype.bernoulliMask=function(t,e,n){return s.tidy((function(){var r=t[0],i=t[1],a=t[2],o=t[3],u=s.tile(s.randomUniform([r,i,1,o],0,1,"float32"),[1,1,a,1]).less(e);return s.cast(u,"float32").mul(n)}))},t.prototype.samplePredictions=function(t,e){return s.tidy((function(){t=s.pow(t,s.scalar(1/e,"float32"));var n=s.cumsum(t,2,!1,!1),r=n.slice([0,0,n.shape[2]-1,0],[n.shape[0],n.shape[1],1,n.shape[3]]),i=s.randomUniform(r.shape,0,1,"float32").mul(r).less(n).argMax(2);return s.oneHot(i.flatten(),t.shape[2],1,0).reshape([t.shape[0],t.shape[1],t.shape[3],t.shape[2]]).transpose([0,1,3,2])}))},t}();e.Coconet=d},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sequenceToPianoroll=e.pianorollToSequence=e.NUM_VOICES=e.MIN_PITCH=e.NUM_PITCHES=e.IS_IOS=void 0;var r=n(0),i=n(55),s=n(79);e.IS_IOS=/iPad|iPhone|iPod/.test(navigator.userAgent),e.NUM_PITCHES=46,e.MIN_PITCH=36,e.NUM_VOICES=4,e.pianorollToSequence=function(t,n){for(var i=r.tidy((function(){return t.reshape([n,e.NUM_PITCHES,e.NUM_VOICES]).arraySync()})),a=s.NoteSequence.create(),o=[],u=0;u<n;u++)for(var c=0;c<e.NUM_PITCHES;c++)for(var l=0;l<e.NUM_VOICES;l++){if(1===i[u][c][l]){var h=s.NoteSequence.Note.create({pitch:c+e.MIN_PITCH,instrument:l,quantizedStartStep:u,quantizedEndStep:u+1});o.push(h)}}return a.notes=o,a.totalQuantizedSteps=o[o.length-1].quantizedEndStep,a.quantizationInfo={stepsPerQuarter:4},a},e.sequenceToPianoroll=function(t,n){var s=r.tidy((function(){return r.zeros([n,e.NUM_PITCHES,e.NUM_VOICES]).arraySync()}));return t.notes.forEach((function(r){var a=r.pitch-e.MIN_PITCH,o=r.quantizedStartStep,u=r.quantizedEndStep-r.quantizedStartStep,c=r.instrument;if(c<0||c>=e.NUM_VOICES)i.log("Found invalid voice "+c+". Skipping.","Coconet",5);else{if(o+u>n)throw new Error("NoteSequence "+t.id+" has notes that are longer than the sequence's\n          totalQuantizedSteps.");for(var l=o;l<o+u;l++)s[l][a][c]=1}})),r.tensor([s])}},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(360),e)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(361);Object.defineProperty(e,"MusicRNN",{enumerable:!0,get:function(){return r.MusicRNN}})},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.MusicRNN=void 0;var s=n(36),a=n(255),o=n(211),u=n(212),c=n(61),l=n(55),h=n(92),d=n(362),p=function(){function t(t,e){this.checkpointURL=t,this.spec=e,this.initialized=!1,this.rawVars={},this.biasShapes=[],this.lstmCells=[]}return t.prototype.isInitialized=function(){return this.initialized},t.prototype.instantiateFromSpec=function(){this.dataConverter=u.converterFromSpec(this.spec.dataConverter),this.attentionLength=this.spec.attentionLength,this.chordEncoder=this.spec.chordEncoder?o.chordEncoderFromType(this.spec.chordEncoder):void 0,this.auxInputs=this.spec.auxInputs?this.spec.auxInputs.map((function(t){return a.auxiliaryInputFromSpec(t)})):void 0},t.prototype.initialize=function(){return r(this,void 0,void 0,(function(){var t,e,n,r,a,o,u,h=this;return i(this,(function(i){switch(i.label){case 0:return this.dispose(),t=c.performance.now(),this.spec?[3,2]:[4,c.fetch(this.checkpointURL+"/config.json").then((function(t){return t.json()})).then((function(t){if("MusicRNN"!==t.type)throw new Error("Attempted to instantiate MusicRNN model with incorrect type:\n                  "+t.type);h.spec=t}))];case 1:i.sent(),i.label=2;case 2:return this.instantiateFromSpec(),[4,c.fetch(this.checkpointURL+"/weights_manifest.json").then((function(t){return t.json()})).then((function(t){return s.io.loadWeights(t,h.checkpointURL)}))];case 3:for(e=i.sent(),n=d.AttentionWrapper.isWrapped(e),r=n?"rnn/"+d.ATTENTION_PREFIX:"rnn/",this.forgetBias=s.scalar(1),this.lstmCells.length=0,this.biasShapes.length=0,a=0,o=function(){var t=r+"multi_rnn_cell/cell_%d/basic_lstm_cell/".replace("%d",a.toString());if(!(t+"kernel"in e))return"break";u.lstmCells.push((function(n,r,i){return s.basicLSTMCell(h.forgetBias,e[t+"kernel"],e[t+"bias"],n,r,i)})),u.biasShapes.push(e[t+"bias"].shape[0]),++a},u=this;"break"!==o(););return this.lstmFcW=e["fully_connected/weights"],this.lstmFcB=e["fully_connected/biases"],n&&(this.attentionWrapper=new d.AttentionWrapper(this.lstmCells,this.attentionLength,this.biasShapes[0]/4),this.attentionWrapper.initialize(e)),this.rawVars=e,this.initialized=!0,l.logWithDuration("Initialized model",t,"MusicRNN"),[2]}}))}))},t.prototype.dispose=function(){var t=this;Object.keys(this.rawVars).forEach((function(e){return t.rawVars[e].dispose()})),this.rawVars={},this.forgetBias&&(this.forgetBias.dispose(),this.forgetBias=void 0),this.initialized=!1},t.prototype.continueSequence=function(t,e,n,s){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.continueSequenceImpl(t,e,n,s,!1)];case 1:return[2,r.sent().sequence]}}))}))},t.prototype.continueSequenceAndReturnProbabilities=function(t,e,n,s){return r(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.continueSequenceImpl(t,e,n,s,!0)]}))}))},t.prototype.continueSequenceImpl=function(t,e,n,a,o){return r(this,void 0,void 0,(function(){var r,u,d,p,f,m,g,b,y=this;return i(this,(function(i){switch(i.label){case 0:if(h.assertIsRelativeQuantizedSequence(t),this.chordEncoder&&!a)throw new Error("Chord progression expected but not provided.");if(!this.chordEncoder&&a)throw new Error("Unexpected chord progression provided.");return this.initialized?[3,2]:[4,this.initialize()];case 1:i.sent(),i.label=2;case 2:return r=c.performance.now(),[4,u=s.tidy((function(){var r=y.dataConverter.toTensor(t),i=r.shape[0],u=r.shape[1],c=y.chordEncoder?y.chordEncoder.encodeProgression(a,i+e):void 0,l=y.auxInputs?s.concat(y.auxInputs.map((function(t){return t.getTensors(i+e)})),1):void 0,h=y.sampleRnn(r,e,n,c,l,o),d=h.samples;return{samples:s.stack(d).as2D(d.length,u),probs:h.probs}}))];case 3:if(d=i.sent(),p=this.dataConverter.toNoteSequence(d.samples,t.quantizationInfo.stepsPerQuarter),f=[],!o)return[3,7];m=0,i.label=4;case 4:return m<d.probs.length?(b=(g=f).push,[4,d.probs[m].data()]):[3,7];case 5:b.apply(g,[i.sent()]),d.probs[m].dispose(),i.label=6;case 6:return m++,[3,4];case 7:return u.samples.dispose(),p.then((function(){return l.logWithDuration("Continuation completed",r,"MusicRNN",20)})),[2,{sequence:p,probs:f}]}}))}))},t.prototype.sampleRnn=function(t,e,n,r,i,a){for(var o,u=t.shape[0],c=t.shape[1],l=[],h=[],d=0;d<this.biasShapes.length;d++)l.push(s.zeros([1,this.biasShapes[d]/4])),h.push(s.zeros([1,this.biasShapes[d]/4]));var p,f=this.attentionWrapper?this.attentionWrapper.initState():null;t=t.toFloat();var m=[],g=[],b=s.split(t.toFloat(),u),y=r?s.split(r,r.shape[0]):void 0,v=i?s.split(i,i.shape[0]):void 0;for(d=0;d<u+e;d++){var w=void 0;if(d<u)w=b[d];else{var x=p.matMul(this.lstmFcW).add(this.lstmFcB).as1D(),_=void 0;n?(x=x.div(s.scalar(n)),_=s.multinomial(x,1).as1D()):_=x.argMax().as1D(),a&&g.push(s.softmax(x)),w=s.oneHot(_,c).toFloat(),m.push(w.as1D())}if(d===u+e-1)break;var O=[];if(y&&O.push(y[d+1]),O.push(w),v&&O.push(v[d]),w=s.concat(O,1),this.attentionWrapper){var S=this.attentionWrapper.call(w,l,h,f);l=S.c,h=S.h,f=S.attentionState,p=S.output}else l=(o=s.multiRNNCell(this.lstmCells,w,l,h))[0],p=(h=o[1])[h.length-1]}return{samples:m,probs:g}},t}();e.MusicRNN=p},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AttentionWrapper=e.ATTENTION_PREFIX=void 0;var r=n(36);e.ATTENTION_PREFIX="attention_cell_wrapper/";var i=function(){function t(t,e,n){this.cells=t,this.attnLength=e,this.attnSize=n}return t.isWrapped=function(t){return"rnn/"+e.ATTENTION_PREFIX+"kernel"in t},t.prototype.initialize=function(t){var n="rnn/"+e.ATTENTION_PREFIX;this.attnInputMatrix=t[n+"kernel"],this.attnInputBias=t[n+"bias"],this.attnW=t[n+"attention/attn_w"],this.attnV=t[n+"attention/attn_v"],this.attnMatrix=t[n+"attention/kernel"],this.attnBias=t[n+"attention/bias"],this.attnOutputMatrix=t[n+"attention_output_projection/kernel"],this.attnOutputBias=t[n+"attention_output_projection/bias"]},t.prototype.initState=function(){return{attention:r.zeros([this.attnSize]),attentionState:r.zeros([1,this.attnSize*this.attnLength])}},t.prototype.call=function(t,e,n,i){var s,a=r.concat([t,i.attention.as2D(1,-1)],1),o=r.add(r.matMul(a,this.attnInputMatrix),this.attnInputBias.as2D(1,-1));e=(s=r.multiRNNCell(this.cells,o,e,n))[0],n=s[1];for(var u=r.reshape(i.attentionState,[-1,this.attnLength,1,this.attnSize]),c=r.conv2d(u,this.attnW,[1,1],"same"),l=[],h=0;h<e.length;h++)l.push(e[h]),l.push(n[h]);var d=r.concat(l,1),p=r.matMul(d,this.attnMatrix).reshape([-1,1,1,this.attnSize]),f=r.sum(r.mul(this.attnV,r.tanh(r.add(c,p))),[2,3]),m=r.softmax(f),g=r.sum(r.mul(r.reshape(m,[-1,this.attnLength,1,1]),u),[1,2]).reshape([-1,this.attnSize]),b=i.attentionState.reshape([-1,this.attnLength,this.attnSize]),y=r.slice(b,[0,1,0],[b.shape[0],b.shape[1]-1,b.shape[2]]),v=r.add(r.matMul(r.concat([n[2],g],1),this.attnOutputMatrix),this.attnOutputBias),w=g.flatten(),x=r.concat([y,v.as3D(v.shape[0],1,v.shape[1])],1).reshape([-1,this.attnLength*this.attnSize]);return{output:v,c:e,h:n,attentionState:{attention:w,attentionState:x}}},t}();e.AttentionWrapper=i},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(364),e)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(365);Object.defineProperty(e,"MidiMe",{enumerable:!0,get:function(){return r.MidiMe}});var i=n(366);Object.defineProperty(e,"Decoder",{enumerable:!0,get:function(){return i.Decoder}}),Object.defineProperty(e,"Encoder",{enumerable:!0,get:function(){return i.Encoder}}),Object.defineProperty(e,"MusicVAE",{enumerable:!0,get:function(){return i.MusicVAE}})},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.MidiMe=void 0;var o=n(36),u=n(55),c=n(61),l=function(t){function e(){return t.call(this,{})||this}return i(e,t),e.prototype.computeOutputShape=function(t){return t[0]},e.prototype.call=function(t){return o.tidy((function(){var e=t[0],n=t[1];return o.add(o.mul(o.randomNormal(n.shape),n),e)}))},e.prototype.getClassName=function(){return"SamplingLayer"},e}(o.layers.Layer),h=function(){function t(t){void 0===t&&(t={}),this.trained=!1,this.initialized=!1,this.config={encoder_layers:t.encoder_layers||[1024,256,64],decoder_layers:t.decoder_layers||[64,256,1024],input_size:t.input_size||256,latent_size:t.latent_size||4,beta:t.beta||1,epochs:t.epochs||10}}return t.prototype.dispose=function(){this.initialized&&(this.encoder.dispose(),this.decoder.dispose(),this.vae.dispose(),this.initialized=!1)},t.prototype.initialize=function(){this.dispose();var t=c.performance.now(),e=o.input({shape:[this.config.input_size]});this.encoder=this.getEncoder(e);var n=this.encoder.apply(e)[0];this.decoder=this.getDecoder(n.shape.slice(1));var r=this.decoder.apply(n);this.vae=o.model({inputs:e,outputs:r,name:"vae"}),this.initialized=!0,u.logWithDuration("Initialized model",t,"MidiMe")},t.prototype.train=function(t,e){return s(this,void 0,void 0,(function(){var n,r,i,s,l,h=this;return a(this,(function(d){switch(d.label){case 0:n=c.performance.now(),this.trained=!1,r=.001,!1===o.ENV.get("WEBGL_RENDER_FLOAT32_ENABLED")&&!1===o.ENV.get("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&1===o.ENV.get("WEBGL_VERSION")&&(r=5e-5),i=o.train.adam(r),s=function(n){return a(this,(function(r){switch(r.label){case 0:return[4,o.nextFrame()];case 1:return r.sent(),[4,i.minimize((function(){return o.tidy((function(){var r=h.encoder.predict(t),i=r[1],s=r[2],a=h.vae.predict(t),o=h.loss(i,s,a,t);return e&&e(n,{y:a,total:o.totalLoss.arraySync(),losses:[o.reconLoss.arraySync(),o.latentLoss.arraySync()]}),o.totalLoss}))}))];case 2:return r.sent(),[4,o.nextFrame()];case 3:return r.sent(),[2]}}))},l=0,d.label=1;case 1:return l<this.config.epochs?[5,s(l)]:[3,4];case 2:d.sent(),d.label=3;case 3:return l++,[3,1];case 4:return u.logWithDuration("Training finished",n,"MidiMe"),this.trained=!0,i.dispose(),[2]}}))}))},t.prototype.sample=function(t){return void 0===t&&(t=1),s(this,void 0,void 0,(function(){var e=this;return a(this,(function(n){switch(n.label){case 0:return this.initialized?[3,2]:[4,this.initialize()];case 1:n.sent(),n.label=2;case 2:return[2,o.tidy((function(){var n=o.randomNormal([t,e.config.latent_size]);return e.decoder.predict(n)}))]}}))}))},t.prototype.decode=function(t){return s(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return this.initialized?[3,2]:[4,this.initialize()];case 1:e.sent(),e.label=2;case 2:return[2,this.decoder.predict(t)]}}))}))},t.prototype.encode=function(t){return s(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return this.initialized?[3,2]:[4,this.initialize()];case 1:n.sent(),n.label=2;case 2:return e=this.encoder.predict(t),[2,e[0]]}}))}))},t.prototype.predict=function(t){return this.vae.predict(t)},t.prototype.getEncoder=function(t){for(var e=t,n=0;n<this.config.encoder_layers.length;n++)e=o.layers.dense({units:this.config.encoder_layers[n],activation:"relu"}).apply(e);var r=this.getAffineLayers(e,this.config.latent_size,t,!1),i=this.getAffineLayers(e,this.config.latent_size,t,!0),s=(new l).apply([r,i]);return o.model({inputs:t,outputs:[s,r,i],name:"encoder"})},t.prototype.getDecoder=function(t){for(var e=o.input({shape:t}),n=e,r=0;r<this.config.decoder_layers.length;r++)n=o.layers.dense({units:this.config.decoder_layers[r],activation:"relu"}).apply(n);var i=this.getAffineLayers(n,this.config.input_size,e,!1);return o.model({inputs:e,outputs:i,name:"decoder"})},t.prototype.loss=function(t,e,n,r){var i=this;return o.tidy((function(){var s=i.klLoss(t,e),a=i.reconstructionLoss(r,n);return{latentLoss:s,reconLoss:a,totalLoss:o.add(a,o.mul(s,i.config.beta))}}))},t.prototype.reconstructionLoss=function(t,e){return o.tidy((function(){var n=o.pow(o.sub(t,e),2),r=o.div(n,o.mul(2,o.pow(o.ones([1]),2)));return o.mean(o.sum(r,-1))}))},t.prototype.klLoss=function(t,e){return o.tidy((function(){var n=o.pow(t,2),r=o.pow(e,2),i=o.add(1,o.log(r)),s=o.add(n,r),a=o.sub(i,s),u=o.div(o.mean(o.sum(a,-1)),2);return o.mul(-1,u)}))},t.prototype.getAffineLayers=function(t,e,n,r){var i=o.layers.dense({units:e}).apply(t);return r?o.layers.activation({activation:"softplus"}).apply(i):i},t}();e.MidiMe=h},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.MusicVAE=e.Nade=e.Decoder=e.Encoder=e.LayerVars=void 0;var o=n(36),u=n(211),c=n(61),l=n(67),h=n(212),d=n(55),p=function(t,e){if(void 0===t)throw Error("`kernel` is undefined.");if(void 0===e)throw Error("`bias` is undefined.");this.kernel=t,this.bias=e};function f(t,e){return e.matMul(t.kernel).add(t.bias)}e.LayerVars=p;var m=function(){};e.Encoder=m;var g=function(){function t(t,e){this.lstmFwVars=t,this.lstmBwVars=e}return t.prototype.process=function(t){var e=this;return o.tidy((function(){return[e.singleDirection(t,!0),e.singleDirection(t,!1)]}))},t.prototype.singleDirection=function(t,e){for(var n=t.shape[0],r=t.shape[1],i=e?this.lstmFwVars:this.lstmBwVars,s=[o.zeros([n,i.bias.shape[0]/4]),o.zeros([n,i.bias.shape[0]/4])],a=o.scalar(1),u=function(t,e){return o.basicLSTMCell(a,i.kernel,i.bias,t,e[0],e[1])},c=o.split(t.toFloat(),r,1),l=[],h=0,d=e?c:c.reverse();h<d.length;h++){s=u(d[h].squeeze([1]),s),l.push(s[1])}return e?l:l.reverse()},t}(),b=function(t){function e(e,n,r){var i=t.call(this)||this;return i.bidirectionalLstm=new g(e,n),i.muVars=r,i.zDims=r?i.muVars.bias.shape[0]:null,i}return i(e,t),e.prototype.encode=function(t,e){var n=this;if(e)throw new Error("Variable-length segments not supported in flat encoder");return o.tidy((function(){var e=n.bidirectionalLstm.process(t),r=e[0],i=e[1],s=o.concat([r[r.length-1],i[0]],1);return n.muVars?f(n.muVars,s):s}))},e}(m),y=function(t){function e(e,n,r){var i=t.call(this)||this;return i.baseEncoders=e,i.numSteps=n,i.muVars=r,i.zDims=i.muVars.bias.shape[0],i}return i(e,t),e.prototype.encode=function(t,e){var n=this;if(e){if(1!==t.shape[0])throw new Error("When using variable-length segments, batch size must be 1.");if(e.length!==this.numSteps[0])throw new Error("Must provide length for all variable-length segments.")}return o.tidy((function(){for(var r=t,i=0;i<n.baseEncoders.length;++i){for(var s=n.numSteps[i],a=o.split(r,s,1),u=[],c=0;c<s;++c)u.push(n.baseEncoders[i].encode(0===i&&e?o.slice3d(a[c],[0,0,0],[1,e[c],-1]):a[c]));r=o.stack(u,1)}return f(n.muVars,r.squeeze([1]))}))},e}(m);function v(t,e,n){for(var r=[],i=[],s=[],a=o.split(f(n,t).tanh(),2*e.length,1),u=function(t){var n=e[t],u=o.scalar(1);r.push((function(t,e,r){return o.basicLSTMCell(u,n.kernel,n.bias,t,e,r)})),i.push(a[2*t]),s.push(a[2*t+1])},c=0;c<e.length;++c)u(c);return{cell:r,c:i,h:s}}var w=function(){};e.Decoder=w;var x=function(t){function e(e,n,r,i,s,a){var o=t.call(this)||this;return o.lstmCellVars=e,o.zToInitStateVars=n,o.outputProjectVars=r,o.zDims=o.zToInitStateVars.kernel.shape[0],o.outputDims=i||r.bias.shape[0],s&&a&&(o.controlBidirectionalLstm=new g(s,a)),o}return i(e,t),e.prototype.decode=function(t,e,n,r,i){var s=this,a=t.shape[0];return o.tidy((function(){var u,c=v(t,s.lstmCellVars,s.zToInitStateVars),l=i?o.expandDims(i,0):void 0,h=[],d=n||o.zeros([a,s.outputDims]);if(s.controlBidirectionalLstm){var p=s.controlBidirectionalLstm.process(l),m=p[0],g=p[1];l=o.concat([o.stack(m,1),o.stack(g,1)],2)}for(var b=l?o.split(o.tile(l,[a,1,1]),i.shape[0],1):void 0,y=0;y<e;++y){var w=b?[d,t,o.squeeze(b[y],[1])]:[d,t];u=o.multiRNNCell(c.cell,o.concat(w,1),c.c,c.h),c.c=u[0],c.h=u[1];var x=f(s.outputProjectVars,c.h[c.h.length-1]);d=s.sample(x,r),h.push(d)}return o.stack(h,1)}))},e}(w),_=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.sample=function(t,e){var n=t;return(e?o.greaterEqual(o.sigmoid(n.div(o.scalar(e))),o.randomUniform(n.shape)):o.greaterEqual(n,0)).toFloat()},e}(x),O=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.sample=function(t,e){var n=t,r=e?o.multinomial(n.div(o.scalar(e)),1).as1D():n.argMax(1).as1D();return o.oneHot(r,this.outputDims).toFloat()},e}(x),S=function(t){function e(e,n,r,i,s,a){var o=t.call(this,e,n,r,i.numDims,s,a)||this;return o.nade=i,o}return i(e,t),e.prototype.sample=function(t,e){var n=o.split(t,[this.nade.numHidden,this.nade.numDims],1),r=n[0],i=n[1];return this.nade.sample(r,i)},e}(x),k=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.sample=function(t,e){var n=o.split(t,3,1),r=n[0],i=n[1],s=n[2];if(i=o.sigmoid(i),s=o.tanh(s),e){r=o.sigmoid(r.div(o.scalar(e)));var a=o.randomUniform(r.shape,0,1);r=o.greater(r,a).toFloat()}else r=o.greater(o.sigmoid(r),.5).toFloat();return o.concat([r,i,s],1)},e}(x),T=function(t){function e(e){var n=t.call(this)||this;return n.coreDecoders=e,n.numDecoders=n.coreDecoders.length,n.zDims=n.coreDecoders[0].zDims,n.outputDims=n.coreDecoders.reduce((function(t,e){return t+e.outputDims}),0),n}return i(e,t),e.prototype.decodeSeparately=function(t,e,n,r,i){for(var s=[],a=0;a<this.coreDecoders.length;++a)s.push(this.coreDecoders[a].decode(t,e,n[a],r,i));return s},e.prototype.decode=function(t,e,n,r,i){var s=this;return o.tidy((function(){var a=s.decodeSeparately(t,e,s.coreDecoders.map((function(t){return n})),r,i);return o.concat(a,-1)}))},e}(w),C=function(t){function e(e,n,r,i){var s=t.call(this)||this;return s.splitDecoder=new T(e),s.lstmCellVars=n,s.zToInitStateVars=r,s.numSteps=i,s.zDims=s.zToInitStateVars.kernel.shape[0],s.outputDims=s.splitDecoder.outputDims,s}return i(e,t),e.prototype.decode=function(t,e,n,r,i){var s=this,a=t.shape[0];return o.tidy((function(){for(var n,u=v(t,s.lstmCellVars,s.zToInitStateVars),c=[],l=new Array(s.splitDecoder.numDecoders).fill(void 0),h=o.zeros([a,1]),d=i?o.split(i,s.numSteps):void 0,p=0;p<s.numSteps;++p){n=o.multiRNNCell(u.cell,h,u.c,u.h),u.c=n[0],u.h=n[1];var f=s.splitDecoder.decodeSeparately(u.h[u.h.length-1],e/s.numSteps,l,r,d?d[p]:void 0);c.push(o.concat(f,-1)),l=f.map((function(t){return t.slice([0,t.shape[1]-1,0],[a,1,t.shape[t.rank-1]]).squeeze([1]).toFloat()}))}return o.concat(c,1)}))},e}(w),A=function(){function t(t,e){this.numDims=t.shape[0],this.numHidden=t.shape[2],this.encWeights=t.as2D(this.numDims,this.numHidden),this.decWeightsT=e.as2D(this.numDims,this.numHidden)}return t.prototype.sample=function(t,e){var n=this,r=t.shape[0];return o.tidy((function(){for(var i=[],s=t.clone(),a=0;a<n.numDims;a++){var u=o.sigmoid(s),c=n.encWeights.slice([a,0],[1,n.numHidden]).as1D(),l=n.decWeightsT.slice([a,0],[1,n.numHidden]),h=e.slice([0,a],[r,1]).add(o.matMul(u,l,!1,!0)).sigmoid().greaterEqual(o.scalar(.5)).toFloat().as1D();a<n.numDims-1&&(s=s.add(o.outerProduct(h.toFloat(),c))),i.push(h)}return o.stack(i,1)}))},t}();e.Nade=A;var N=function(){function t(t,e){this.initialized=!1,this.checkpointURL=t,this.spec=e}return t.prototype.instantiateFromSpec=function(){this.dataConverter=h.converterFromSpec(this.spec.dataConverter),this.chordEncoder=this.spec.chordEncoder?u.chordEncoderFromType(this.spec.chordEncoder):void 0},t.prototype.dispose=function(){var t=this;void 0!==this.rawVars&&Object.keys(this.rawVars).forEach((function(e){return t.rawVars[e].dispose()})),this.encoder=void 0,this.decoder=void 0,this.initialized=!1},t.prototype.getLstmLayers=function(t,e){for(var n=[],r=0;;){var i=t.replace("%d",r.toString());if(!(i+"kernel"in e))break;n.push(new p(e[i+"kernel"],e[i+"bias"])),++r}return n},t.prototype.initialize=function(){return s(this,void 0,void 0,(function(){var t,e,n,r,i,s,u,l,h,f,m,g,v,w,x,N,I,E,j,M,D,R,P,F,z=this;return a(this,(function(a){switch(a.label){case 0:return this.dispose(),t=c.performance.now(),this.spec?[3,2]:[4,c.fetch(this.checkpointURL+"/config.json").then((function(t){return t.json()})).then((function(t){if("MusicVAE"!==t.type)throw new Error("Attempted to instantiate MusicVAE model with incorrect type:\n                  "+t.type);z.spec=t}))];case 1:a.sent(),a.label=2;case 2:return this.instantiateFromSpec(),n="multi_rnn_cell/"+(e="cell_%d/lstm_cell/"),r="decoder/hierarchical_level_0/",s="encoder/"+(i="cell_%d/bidirectional_rnn/%s/multi_rnn_cell/cell_0/lstm_cell/"),u="encoder/hierarchical_level_%d/"+i.replace("%d","0"),l="control_preprocessing/"+i,[4,c.fetch(this.checkpointURL+"/weights_manifest.json").then((function(t){return t.json()})).then((function(t){return o.io.loadWeights(t,z.checkpointURL)}))];case 3:if(h=a.sent(),this.rawVars=h,f=new p(h["encoder/mu/kernel"],h["encoder/mu/bias"]),this.dataConverter.numSegments){if(m=this.getLstmLayers(u.replace("%s","fw"),h),g=this.getLstmLayers(u.replace("%s","bw"),h),m.length!==g.length||2!==m.length)throw Error("Only 2 hierarchical encoder levels are supported. Got "+m.length+" forward and "+g.length+" backward.");v=[0,1].map((function(t){return new b(m[t],g[t])})),this.encoder=new y(v,[this.dataConverter.numSegments,1],f)}else{if(w=this.getLstmLayers(s.replace("%s","fw"),h),x=this.getLstmLayers(s.replace("%s","bw"),h),w.length!==x.length||1!==w.length)throw Error("Only single-layer bidirectional encoders are supported. Got "+w.length+" forward and "+x.length+" backward.");this.encoder=new b(w[0],x[0],f)}if(N=l.replace("%s","fw").replace("%d","0")+"kernel"in h,I=this.dataConverter.numSegments?"core_decoder/":"",E=[],this.dataConverter.NUM_SPLITS)for(j=0;j<this.dataConverter.NUM_SPLITS;++j)E.push(I+"core_decoder_"+j+"/decoder/");else E.push(I+"decoder/");if(M=[null],D=[null],N&&(M=this.getLstmLayers(l.replace("%s","fw"),h),D=this.getLstmLayers(l.replace("%s","bw"),h),M.length!==D.length||1!==M.length))throw Error("Only single-layer bidirectional control preprocessing is supported. Got "+M.length+" forward and "+D.length+" backward.");return R=E.map((function(t){var e=z.getLstmLayers(t+n,h),r=new p(h[t+"z_to_initial_state/kernel"],h[t+"z_to_initial_state/bias"]),i=new p(h[t+"output_projection/kernel"],h[t+"output_projection/bias"]);return t+"nade/w_enc"in h?new S(e,r,i,new A(h[t+"nade/w_enc"],h[t+"nade/w_dec_t"]),M[0],D[0]):"GrooveConverter"===z.spec.dataConverter.type?new k(e,r,i,void 0,M[0],D[0]):z.spec.useBooleanDecoder?new _(e,r,i,void 0,M[0],D[0]):new O(e,r,i,void 0,M[0],D[0])})),this.dataConverter.numSegments?(P=this.getLstmLayers(r+e,h),F=new p(h[r+"initial_state/kernel"],h[r+"initial_state/bias"]),this.decoder=new C(R,P,F,this.dataConverter.numSegments)):1===R.length?this.decoder=R[0]:this.decoder=new T(R),this.zDims=this.decoder.zDims,this.initialized=!0,d.logWithDuration("Initialized model",t,"MusicVAE"),[2]}}))}))},t.prototype.isInitialized=function(){return this.initialized},t.prototype.checkControlArgs=function(t){var e=(t=t||{}).extraControls||{};if(this.chordEncoder&&!t.chordProgression)throw new Error("Chord progression expected but not provided.");if(!this.chordEncoder&&t.chordProgression)throw new Error("Unexpected chord progression provided.");if(this.chordEncoder&&this.dataConverter.endTensor&&t.chordProgression.length>1)throw new Error("Multiple chords not supported when using variable-length segments.");if(this.spec.conditionOnKey&&null==t.key)throw new Error("Key expected but not provided.");if(!this.spec.conditionOnKey&&null!=t.key)throw new Error("Unexpected key provided.");if(this.spec.extraControls)for(var n=0,r=this.spec.extraControls;n<r.length;n++){var i=r[n];if(!(i.name in e))throw new Error("Missing control signal: "+i.name);if(e[i.name].shape[1]!==i.depth)throw new Error("Control signal "+i.name+" has invalid depth: "+e[i.name].shape[1]+" != "+i.depth)}var s=this.spec.extraControls?new Set(this.spec.extraControls.map((function(t){return t.name}))):new Set;for(var a in e)s.has(a)||d.log("Unspecified control signal provided: "+a,"MusicVAE",5)},t.prototype.controlArgsToTensor=function(t){var e=this;return t=t||{},o.tidy((function(){var n=[];if(t.chordProgression){var r=e.encodeChordProgression(t.chordProgression);n.push(r)}if(null!=t.key){var i=o.oneHot(o.fill([e.dataConverter.numSteps],t.key,"int32"),12);n.push(i)}if(t.extraControls)for(var s=0,a=e.spec.extraControls;s<a.length;s++){var u=a[s];n.push(t.extraControls[u.name])}return n.length?o.concat2d(n,1):void 0}))},t.prototype.interpolateTensors=function(t,e,n,r){return s(this,void 0,void 0,(function(){var i,s,u,c=this;return a(this,(function(a){switch(a.label){case 0:return this.initialized?[3,2]:[4,this.initialize()];case 1:a.sent(),a.label=2;case 2:return[4,this.encodeTensors(t,r)];case 3:return i=a.sent(),s=o.tidy((function(){return c.getInterpolatedZs(i,e)})),i.dispose(),[4,this.decodeTensors(s,n,r)];case 4:return u=a.sent(),s.dispose(),[2,u]}}))}))},t.prototype.interpolate=function(t,e,n,r){return s(this,void 0,void 0,(function(){var i,s,u,c,l=this;return a(this,(function(a){switch(a.label){case 0:return this.checkControlArgs(r),this.initialized?[3,2]:[4,this.initialize()];case 1:a.sent(),a.label=2;case 2:return i=0,[4,this.encode(t,r)];case 3:return s=a.sent(),u=o.tidy((function(){return l.getInterpolatedZs(s,e)})),s.dispose(),c=this.decode(u,n,r),u.dispose(),c.then((function(){return d.logWithDuration("Interpolation completed",i,"MusicVAE",20)})),[2,c]}}))}))},t.prototype.getSegmentLengths=function(t){return s(this,void 0,void 0,(function(){var e,n,r,i,s,u,c,l,h=this;return a(this,(function(a){switch(a.label){case 0:if(t.shape[0]>1)throw new Error("Variable-length segments not supported for batch size > 1.");return e=this.dataConverter.numSteps,n=this.dataConverter.numSegments,[4,(r=o.tidy((function(){return o.min(o.equal(t.squeeze([0]),h.dataConverter.endTensor.expandDims(0)),1)}))).data()];case 1:for(i=a.sent(),r.dispose(),s=e/n,u=[],c=0,l=i.indexOf(1);-1!==l;)u.push(l-c+1),c+=s,l=i.indexOf(1,c);if(u.length!==n)throw new Error("Incorrect number of segments: "+u.length+" != "+n);return[2,u]}}))}))},t.prototype.encodeChordProgression=function(t){var e=this.dataConverter.numSteps,n=this.dataConverter.numSegments,r=this.dataConverter.SEGMENTED_BY_TRACK?e/n:e,i=this.dataConverter.SEGMENTED_BY_TRACK?o.concat2d([this.chordEncoder.encode(l.NO_CHORD).expandDims(0),this.chordEncoder.encodeProgression(t,r-1)],0):this.chordEncoder.encodeProgression(t,r);return this.dataConverter.SEGMENTED_BY_TRACK?o.tile(i,[n,1]):i},t.prototype.encodeTensors=function(t,e){return s(this,void 0,void 0,(function(){var n,r,i=this;return a(this,(function(s){switch(s.label){case 0:return this.checkControlArgs(e),this.initialized?[3,2]:[4,this.initialize()];case 1:s.sent(),s.label=2;case 2:return this.dataConverter.endTensor?[4,this.getSegmentLengths(t)]:[3,4];case 3:return r=s.sent(),[3,5];case 4:r=void 0,s.label=5;case 5:return n=r,[2,o.tidy((function(){var r=i.controlArgsToTensor(e),s=[t];if(r){var a=o.tile(o.expandDims(r,0),[t.shape[0],1,1]);s.push(a)}var u=o.concat3d(s,2);return i.encoder.encode(u,n)}))]}}))}))},t.prototype.encode=function(t,e){return s(this,void 0,void 0,(function(){var n,r,i,s=this;return a(this,(function(a){switch(a.label){case 0:return this.initialized?[3,2]:[4,this.initialize()];case 1:a.sent(),a.label=2;case 2:return n=c.performance.now(),r=o.tidy((function(){return o.stack(t.map((function(t){return s.dataConverter.toTensor(t)})))})),[4,this.encodeTensors(r,e)];case 3:return i=a.sent(),r.dispose(),d.logWithDuration("Encoding completed",n,"MusicVAE",20),[2,i]}}))}))},t.prototype.decodeTensors=function(t,e,n){return s(this,void 0,void 0,(function(){var r=this;return a(this,(function(i){switch(i.label){case 0:return this.checkControlArgs(n),this.initialized?[3,2]:[4,this.initialize()];case 1:i.sent(),i.label=2;case 2:return[2,o.tidy((function(){var i=r.controlArgsToTensor(n);return r.decoder.decode(t,r.dataConverter.numSteps,void 0,e,i)}))]}}))}))},t.prototype.decode=function(t,e,n,r,i){return void 0===r&&(r=l.DEFAULT_STEPS_PER_QUARTER),void 0===i&&(i=l.DEFAULT_QUARTERS_PER_MINUTE),s(this,void 0,void 0,(function(){var s,u,l,h,p,f,m,g,b;return a(this,(function(a){switch(a.label){case 0:return this.initialized?[3,2]:[4,this.initialize()];case 1:a.sent(),a.label=2;case 2:return s=c.performance.now(),[4,this.decodeTensors(t,e,n)];case 3:u=a.sent(),l=o.tidy((function(){return o.split(u,u.shape[0]).map((function(t){return t.squeeze([0])}))})),h=[],p=0,f=l,a.label=4;case 4:return p<f.length?(m=f[p],b=(g=h).push,[4,this.dataConverter.toNoteSequence(m,r,i)]):[3,7];case 5:b.apply(g,[a.sent()]),m.dispose(),a.label=6;case 6:return p++,[3,4];case 7:return u.dispose(),d.logWithDuration("Decoding completed",s,"MusicVAE",20),[2,h]}}))}))},t.prototype.getInterpolatedZs=function(t,e){if("number"==typeof e&&(e=[e]),2!==t.shape[0]&&4!==t.shape[0])throw new Error("Invalid number of input sequences. Requires length 2, or 4");if(1!==e.length&&2!==e.length)throw new Error("Invalid number of dimensions. Requires length 1, or 2.");var n=e[0],r=2===e.length?e[1]:n;return o.tidy((function(){var e=o.linspace(0,1,n),i=t.slice([0,0],[1,t.shape[1]]).as1D(),s=t.slice([1,0],[1,t.shape[1]]).as1D();if(2===t.shape[0]){var a=s.sub(i);return o.outerProduct(e,a).add(i)}if(4===t.shape[0]){var u=o.linspace(0,1,r),c=t.slice([2,0],[1,t.shape[1]]).as1D(),l=t.slice([3,0],[1,t.shape[1]]).as1D(),h=o.scalar(1).sub(e),d=o.scalar(1).sub(u),p=i.mul(o.outerProduct(d,h).as3D(r,n,1));return p=o.addStrict(p,s.mul(o.outerProduct(u,h).as3D(r,n,1))),p=o.addStrict(p,c.mul(o.outerProduct(d,e).as3D(r,n,1))),(p=o.addStrict(p,l.mul(o.outerProduct(u,e).as3D(r,n,1)))).as2D(n*r,t.shape[1])}throw new Error("Invalid number of note sequences. Requires length 2, or 4")}))},t.prototype.sampleTensors=function(t,e,n){return void 0===e&&(e=.5),s(this,void 0,void 0,(function(){var r,i,s=this;return a(this,(function(a){switch(a.label){case 0:return this.checkControlArgs(n),this.initialized?[3,2]:[4,this.initialize()];case 1:a.sent(),a.label=2;case 2:return r=o.tidy((function(){return o.randomNormal([t,s.decoder.zDims])})),[4,this.decodeTensors(r,e,n)];case 3:return i=a.sent(),r.dispose(),[2,i]}}))}))},t.prototype.sample=function(t,e,n,r,i){return void 0===e&&(e=.5),void 0===r&&(r=l.DEFAULT_STEPS_PER_QUARTER),void 0===i&&(i=l.DEFAULT_QUARTERS_PER_MINUTE),s(this,void 0,void 0,(function(){var s,u,l,h=this;return a(this,(function(a){switch(a.label){case 0:return this.checkControlArgs(n),this.initialized?[3,2]:[4,this.initialize()];case 1:a.sent(),a.label=2;case 2:return s=c.performance.now(),u=o.tidy((function(){return o.randomNormal([t,h.decoder.zDims])})),l=this.decode(u,e,n,r,i),u.dispose(),l.then((function(){return d.logWithDuration("Sampling completed",s,"MusicVAE",20)})),[2,l]}}))}))},t.prototype.similarTensors=function(t,e,n,r,i){return s(this,void 0,void 0,(function(){var s,u,c,l,h=this;return a(this,(function(a){switch(a.label){case 0:if(n<0||n>1)throw new Error("Similarity must be between 0 and 1.");return this.initialized?[3,2]:[4,this.initialize()];case 1:a.sent(),a.label=2;case 2:return s=o.expandDims(t,0),[4,this.encodeTensors(s,i)];case 3:return u=a.sent(),s.dispose(),c=o.tidy((function(){var t=o.randomNormal([e,h.decoder.zDims]);return o.add(u.mul(n),t.mul(1-n))})),u.dispose(),[4,this.decodeTensors(c,r,i)];case 4:return l=a.sent(),c.dispose(),[2,l]}}))}))},t.prototype.similar=function(t,e,n,r,i){return s(this,void 0,void 0,(function(){var s,u,c,l,h=this;return a(this,(function(a){switch(a.label){case 0:if(this.checkControlArgs(i),n<0||n>1)throw new Error("Similarity must be between 0 and 1.");return this.initialized?[3,2]:[4,this.initialize()];case 1:a.sent(),a.label=2;case 2:return s=0,[4,this.encode([t],i)];case 3:return u=a.sent(),c=o.tidy((function(){var t=o.randomNormal([e,h.decoder.zDims]);return o.add(u.mul(n),t.mul(1-n))})),u.dispose(),l=this.decode(c,r,i),c.dispose(),l.then((function(){return d.logWithDuration("Similar sequence generation completed",s,"MusicVAE",20)})),[2,l]}}))}))},t}();e.MusicVAE=N},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(368),e)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(369);Object.defineProperty(e,"PianoGenie",{enumerable:!0,get:function(){return r.PianoGenie}}),Object.defineProperty(e,"PianoGenieKeysig",{enumerable:!0,get:function(){return r.PianoGenieKeysig}}),Object.defineProperty(e,"PianoGenieChord",{enumerable:!0,get:function(){return r.PianoGenieChord}}),Object.defineProperty(e,"PianoGenieKeysigChordFamily",{enumerable:!0,get:function(){return r.PianoGenieKeysigChordFamily}}),Object.defineProperty(e,"PianoGenieKeysigChord",{enumerable:!0,get:function(){return r.PianoGenieKeysigChord}})},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.ChordFamily=e.PitchClass=e.PianoGenieKeysigChordFamily=e.PianoGenieKeysigChord=e.PianoGenieKeysig=e.PianoGenieChord=e.PianoGenie=void 0;var o=n(36),u=n(61),c=n(254);function l(t){for(var e=0;e<2;++e)t.c[e].dispose(),t.h[e].dispose()}function h(t,e,n){if((e=void 0!==e?e:1)<0||e>1)throw new Error("Invalid temperature specified");var r;if(0===e)r=o.argMax(t,0);else{e<1&&(t=o.div(t,o.scalar(e,"float32")));var i=o.reshape(o.softmax(t,0),[1,-1]),s=o.multinomial(i,1,n,!0);r=o.reshape(s,[])}return r}var d,p,f=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.getRnnInputFeats=function(){var e=this;return o.tidy((function(){var n,r=[t.prototype.getRnnInputFeats.call(e)],i=e.lastOutput,s=e.lastTime,a=e.time;void 0===e.deltaTimeOverride?n=(a.getTime()-s.getTime())/1e3:(n=e.deltaTimeOverride,e.deltaTimeOverride=void 0);var u=o.scalar(i,"int32"),c=o.addStrict(u,o.scalar(1,"int32")),l=o.cast(o.oneHot(c,89),"float32");r.push(l);var h=o.scalar(n,"float32"),d=o.round(o.mul(h,31.25)),p=o.minimum(d,32),f=o.cast(o.add(p,1e-4),"int32"),m=o.oneHot(f,33),g=o.cast(m,"float32");return r.push(g),e.lastTime=a,o.concat1d(r)}))},e.prototype.nextWithCustomSamplingFunction=function(e,n){this.time=new Date;var r=t.prototype.nextWithCustomSamplingFunction.call(this,e,n);return this.lastOutput=r,this.lastTime=this.time,r},e.prototype.overrideLastOutput=function(t){this.lastOutput=t},e.prototype.overrideDeltaTime=function(t){this.deltaTimeOverride=t},e.prototype.resetState=function(){t.prototype.resetState.call(this),this.lastOutput=-1,this.lastTime=new Date,this.lastTime.setSeconds(this.lastTime.getSeconds()-1e5),this.time=new Date},e}(function(){function t(t){this.checkpointURL=t,this.initialized=!1}return t.prototype.isInitialized=function(){return this.initialized},t.prototype.initialize=function(t){return s(this,void 0,void 0,(function(){var e,n,r,i,s=this;return a(this,(function(a){switch(a.label){case 0:if(this.initialized&&this.dispose(),void 0===this.checkpointURL&&void 0===t)throw new Error("Need to specify either URI or static variables");return void 0!==t?[3,2]:[4,u.fetch(this.checkpointURL+"/weights_manifest.json").then((function(t){return t.json()})).then((function(t){return o.io.loadWeights(t,s.checkpointURL)}))];case 1:return e=a.sent(),this.modelVars=e,[3,3];case 2:this.modelVars=t,a.label=3;case 3:for(this.decLSTMCells=[],this.decForgetBias=o.scalar(1,"float32"),n=function(t){var e="phero_model/decoder/rnn/rnn/multi_rnn_cell/cell_"+t+"/lstm_cell/";r.decLSTMCells.push((function(t,n,r){return o.basicLSTMCell(s.decForgetBias,s.modelVars[e+"kernel"],s.modelVars[e+"bias"],t,n,r)}))},r=this,i=0;i<2;++i)n(i);return this.resetState(),this.initialized=!0,this.next(0),this.resetState(),[2]}}))}))},t.prototype.getRnnInputFeats=function(){var t=this;return o.tidy((function(){var e=o.tensor1d([t.button],"float32");return o.sub(o.mul(2,o.div(e,7)),1).as1D()}))},t.prototype.next=function(t,e,n){return this.nextWithCustomSamplingFunction(t,(function(t){return h(t,e,n)}))},t.prototype.nextFromKeyList=function(t,e,n,r){return this.nextWithCustomSamplingFunction(t,(function(t){var i=o.tensor1d(e,"int32"),s=h(t=o.gather(t,i),n,r),a=o.gather(i,o.reshape(s,[1]));return s=o.reshape(a,[])}))},t.prototype.nextFromKeyWhitelist=function(t,e,n,r){return c.logging.log("nextFromKeyWhitelist() is deprecated, and will be removed in a future          version. Please use nextFromKeyList() instead","PianoGenie",5),this.nextFromKeyList(t,e,n,r)},t.prototype.nextWithCustomSamplingFunction=function(t,e){var n=this.lastState;this.button=t;var r=this.getRnnInputFeats(),i=this.evaluateModelAndSample(r,n,e),s=i[0],a=i[1];return r.dispose(),l(this.lastState),this.lastState=s,a},t.prototype.evaluateModelAndSample=function(t,e,n){var r=this;if(!this.initialized)throw new Error("Model is not initialized.");var i=o.tidy((function(){var i=o.matMul(o.expandDims(t,0),r.modelVars["phero_model/decoder/rnn_input/dense/kernel"]);i=o.add(i,r.modelVars["phero_model/decoder/rnn_input/dense/bias"]);var s=o.multiRNNCell(r.decLSTMCells,i,e.c,e.h),a=s[0],u=s[1],c={c:a,h:u},l=o.matMul(u[1],r.modelVars["phero_model/decoder/pitches/dense/kernel"]);l=o.add(l,r.modelVars["phero_model/decoder/pitches/dense/bias"]);var h=o.reshape(l,[88]);return[c,n(h).dataSync()[0]]}));return[i[0],i[1]]},t.prototype.resetState=function(){void 0!==this.lastState&&l(this.lastState),this.lastState=function(){for(var t={c:[],h:[]},e=0;e<2;++e)t.c.push(o.zeros([1,128],"float32")),t.h.push(o.zeros([1,128],"float32"));return t}()},t.prototype.dispose=function(){var t=this;this.initialized&&(Object.keys(this.modelVars).forEach((function(e){return t.modelVars[e].dispose()})),this.decForgetBias.dispose(),l(this.lastState),this.initialized=!1)},t}());!function(t){t[t.None=0]="None",t[t.C=1]="C",t[t.Cs=2]="Cs",t[t.D=3]="D",t[t.Eb=4]="Eb",t[t.E=5]="E",t[t.F=6]="F",t[t.Fs=7]="Fs",t[t.G=8]="G",t[t.Ab=9]="Ab",t[t.A=10]="A",t[t.Bb=11]="Bb",t[t.B=12]="B"}(d||(d={})),e.PitchClass=d,function(t){t[t.None=0]="None",t[t.Maj=1]="Maj",t[t.Min=2]="Min",t[t.Aug=3]="Aug",t[t.Dim=4]="Dim",t[t.Seven=5]="Seven",t[t.Maj7=6]="Maj7",t[t.Min7=7]="Min7",t[t.Min7b5=8]="Min7b5"}(p||(p={})),e.ChordFamily=p;var m=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.getRnnInputFeats=function(){var e=this;return o.tidy((function(){var n=[t.prototype.getRnnInputFeats.call(e)],r=o.scalar(e.chordRoot,"int32"),i=o.subStrict(r,o.scalar(1,"int32")),s=o.cast(o.oneHot(i,12),"float32");n.push(s);var a=o.scalar(e.chordFamily,"int32"),u=o.subStrict(a,o.scalar(1,"int32")),c=o.cast(o.oneHot(u,8),"float32");return n.push(c),o.concat1d(n)}))},e.prototype.setChordRoot=function(t){this.chordRoot=t},e.prototype.setChordFamily=function(t){this.chordFamily=t},e.prototype.resetState=function(){t.prototype.resetState.call(this),this.chordRoot=d.None,this.chordFamily=p.None},e}(f),g=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.getRnnInputFeats=function(){var e=this;return o.tidy((function(){var n=[t.prototype.getRnnInputFeats.call(e)],r=o.scalar(e.keySignature,"int32"),i=o.subStrict(r,o.scalar(1,"int32")),s=o.cast(o.oneHot(i,12),"float32");return n.push(s),o.concat1d(n)}))},e.prototype.setKeySignature=function(t){this.keySignature=t},e.prototype.resetState=function(){t.prototype.resetState.call(this),this.keySignature=d.None},e}(f),b=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.getRnnInputFeats=function(){var e=this;return o.tidy((function(){var n=[t.prototype.getRnnInputFeats.call(e)],r=o.scalar(e.chordRoot,"int32"),i=o.subStrict(r,o.scalar(1,"int32")),s=o.cast(o.oneHot(i,12),"float32");n.push(s);var a=o.scalar(e.chordFamily,"int32"),u=o.subStrict(a,o.scalar(1,"int32")),c=o.cast(o.oneHot(u,8),"float32");return n.push(c),o.concat1d(n)}))},e.prototype.setChordRoot=function(t){this.chordRoot=t},e.prototype.setChordFamily=function(t){this.chordFamily=t},e.prototype.resetState=function(){t.prototype.resetState.call(this),this.chordRoot=d.None,this.chordFamily=p.None},e}(g),y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.getRnnInputFeats=function(){var e=this;return o.tidy((function(){var n=[t.prototype.getRnnInputFeats.call(e)],r=o.scalar(e.chordFamily,"int32"),i=o.subStrict(r,o.scalar(1,"int32")),s=o.cast(o.oneHot(i,8),"float32");return n.push(s),o.concat1d(n)}))},e.prototype.setChordFamily=function(t){this.chordFamily=t},e.prototype.resetState=function(){t.prototype.resetState.call(this),this.chordFamily=p.None},e}(g),v=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e}(f);e.PianoGenie=v;var w=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e}(m);e.PianoGenieChord=w;var x=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e}(g);e.PianoGenieKeysig=x;var _=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e}(b);e.PianoGenieKeysigChord=_;var O=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e}(y);e.PianoGenieKeysigChordFamily=O},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(79),e)},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(372),e)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(373);Object.defineProperty(e,"OnsetsAndFrames",{enumerable:!0,get:function(){return r.OnsetsAndFrames}})},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.OnsetsAndFrames=void 0;var s=n(36),a=n(111),o=n(55),u=n(61),c=n(386),l=n(216),h=n(387),d=function(){function t(t,e){void 0===e&&(e=250),this.checkpointURL=t,this.chunkLength=e}return t.prototype.initialize=function(){return r(this,void 0,void 0,(function(){var t,e,n=this;return i(this,(function(r){switch(r.label){case 0:return this.dispose(),t=u.performance.now(),[4,u.fetch(this.checkpointURL+"/weights_manifest.json").then((function(t){return t.json()})).then((function(t){return s.io.loadWeights(t,n.checkpointURL)}))];case 1:return e=r.sent(),this.build(e),Object.keys(e).map((function(t){return e[t].dispose()})),this.initialized=!0,o.logWithDuration("Initialized model",t,"O&F"),[2]}}))}))},t.prototype.dispose=function(){this.initialized&&(this.onsetsCnn.dispose(),this.onsetsRnn.dispose(),this.activationCnn.dispose(),this.frameRnn.dispose(),this.velocityCnn.dispose(),this.initialized=!1)},t.prototype.isInitialized=function(){return this.initialized},t.prototype.transcribeFromMelSpec=function(t,e){return void 0===e&&(e=4),r(this,void 0,void 0,(function(){var n,r,a,c,l,d,p=this;return i(this,(function(i){return this.isInitialized()||this.initialize(),n=u.performance.now(),o.log("Computing onsets, frames, and velocities...","O&F",20),r=s.tidy((function(){var n=h.batchInput(t,p.chunkLength);return p.processBatches(n,p.chunkLength,t.length,e)})),a=r[0],c=r[1],l=r[2],o.log("Converting to NoteSequence...","O&F",20),(d=h.pianorollToNoteSequence(a,c,l)).then((function(){a.dispose(),c.dispose(),l.dispose(),o.logWithDuration("Transcribed from mel spec",n,"O&F")})),[2,d]}))}))},t.prototype.transcribeFromAudioBuffer=function(t,e){return void 0===e&&(e=4),r(this,void 0,void 0,(function(){var n,r,s=this;return i(this,(function(i){return n=u.performance.now(),(r=c.preprocessAudio(t)).then((function(){return o.logWithDuration("Converted audio to mel spec",n,"O&F",20)})),[2,r.then((function(t){return s.transcribeFromMelSpec(t.map((function(t){return Array.from(t)}),e))}))]}))}))},t.prototype.transcribeFromAudioFile=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,a.loadAudioFromFile(t)];case 1:return e=n.sent(),[2,this.transcribeFromAudioBuffer(e)]}}))}))},t.prototype.transcribeFromAudioURL=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,a.loadAudioFromUrl(t)];case 1:return e=n.sent(),[2,this.transcribeFromAudioBuffer(e)]}}))}))},t.prototype.processBatches=function(t,e,n,r){var i,a,o,u,c=this,l=function(t){return[c.onsetsCnn.predict(t,r),c.activationCnn.predict(t,r),c.velocityCnn.predict(t,r)]};if(1===t.shape[0])a=(i=l(t.expandDims(-1)))[0],o=i[1],u=i[2];else{for(var d=l(t.expandDims(-1)),p=[],f=0;f<3;++f)p.push(h.unbatchOutput(d[f],e,n));a=p[0],o=p[1],u=p[2]}var m=this.onsetsRnn.predict(a,this.chunkLength);a.dispose();var g=s.concat3d([m,o],-1);o.dispose();var b=this.frameRnn.predict(g,this.chunkLength),y=s.clipByValue(u,0,1).mul(s.scalar(80)).add(s.scalar(10)).toInt();return u.dispose(),[b.squeeze(),m.squeeze(),y.squeeze()]},t.prototype.build=function(t){var e=this;s.tidy((function(){e.onsetsCnn=new p,e.onsetsCnn.setWeights(t,"onsets"),e.onsetsRnn=new f([null,e.onsetsCnn.outputShape[2]]),e.onsetsRnn.setWeights(t,"onsets","onset_probs"),e.activationCnn=new p("sigmoid"),e.activationCnn.setWeights(t,"frame","activation_probs"),e.frameRnn=new f([null,2*l.MIDI_PITCHES]),e.frameRnn.setWeights(t,"frame","frame_probs"),e.velocityCnn=new p("linear"),e.velocityCnn.setWeights(t,"velocity","onset_velocities")}))},t}();e.OnsetsAndFrames=d;var p=function(){function t(t){this.nn=s.sequential();var e={filters:48,kernelSize:[3,3],activation:"linear",useBias:!1,padding:"same",dilationRate:[1,1],inputShape:[null,l.MEL_SPEC_BINS,1],trainable:!1},n={scale:!1,trainable:!1};this.nn.add(s.layers.conv2d(e)),this.nn.add(s.layers.batchNormalization(n)),this.nn.add(s.layers.activation({activation:"relu"})),e.inputShape=null,this.nn.add(s.layers.conv2d(e)),this.nn.add(s.layers.batchNormalization(n)),this.nn.add(s.layers.activation({activation:"relu"})),this.nn.add(s.layers.maxPooling2d({poolSize:[1,2],strides:[1,2]})),e.filters=96,this.nn.add(s.layers.conv2d(e)),this.nn.add(s.layers.batchNormalization(n)),this.nn.add(s.layers.activation({activation:"relu"})),this.nn.add(s.layers.maxPooling2d({poolSize:[1,2],strides:[1,2]}));var r=this.nn.outputShape;this.nn.add(s.layers.reshape({targetShape:[r[1],r[2]*r[3]]})),this.nn.add(s.layers.dense({units:768,activation:"relu",trainable:!1})),t&&this.nn.add(s.layers.dense({units:l.MIDI_PITCHES,activation:t,trainable:!1})),this.outputShape=this.nn.outputShape}return t.prototype.dispose=function(){this.nn.dispose()},t.prototype.predict=function(t,e){return this.nn.predict(t,{batchSize:e})},t.prototype.setWeights=function(t,e,n){function r(e){var n=t[e];if(void 0===n)throw Error("Variable not found: "+e);return n}var i=[r(e+"/conv0/weights"),r(e+"/conv0/BatchNorm/beta"),r(e+"/conv0/BatchNorm/moving_mean"),r(e+"/conv0/BatchNorm/moving_variance"),r(e+"/conv1/weights"),r(e+"/conv1/BatchNorm/beta"),r(e+"/conv1/BatchNorm/moving_mean"),r(e+"/conv1/BatchNorm/moving_variance"),r(e+"/conv2/weights"),r(e+"/conv2/BatchNorm/beta"),r(e+"/conv2/BatchNorm/moving_mean"),r(e+"/conv2/BatchNorm/moving_variance"),r(e+"/fc_end/weights"),r(e+"/fc_end/biases")];n&&(i=i.concat([r(e+"/"+n+"/weights"),r(e+"/"+n+"/biases")])),this.nn.setWeights(i)},t}(),f=function(){function t(t,e){var n,r,i;void 0===e&&(e=384),this.dense=s.sequential(),this.units=e,this.lstm=(n=s.layers.lstm({inputShape:t,units:e,returnSequences:!0,recurrentActivation:"sigmoid",returnState:!0,kernelInitializer:"zeros",recurrentInitializer:"zeros",biasInitializer:"zeros",trainable:!1}),r=[s.input({shape:t}),s.input({shape:[e]}),s.input({shape:[e]})],i=n.apply(r),s.model({inputs:r,outputs:i})),this.dense.add(s.layers.dense({inputShape:[null,e],units:l.MIDI_PITCHES,activation:"sigmoid",trainable:!1}))}return t.prototype.dispose=function(){this.lstm.dispose(),this.dense.dispose()},t.prototype.setWeights=function(t,e,n){var r=this;function i(e){var n=t[e];if(void 0===n)throw Error("Variable not found: "+e);return n}var a,o=function(t,e){void 0===e&&(e=0);var n=s.split(t,4,-1),r=n[0],i=n[1],a=n[2],o=n[3];return s.concat([r,a.add(s.scalar(e)),i,o],-1)},u="cudnn_lstm/rnn/multi_rnn_cell/cell_0/cudnn_compatible_lstm_cell";this.lstm.setWeights((a=i(e+"/"+u+"/kernel"),s.split(o(a),[a.shape[0]-r.units,r.units])).concat(o(i(e+"/"+u+"/bias"),1))),this.dense.setWeights([i(e+"/"+n+"/weights"),i(e+"/"+n+"/biases")])},t.prototype.predict=function(t,e){var n=this;return s.tidy((function(){return n.predictImpl(t,e)}))},t.prototype.predictImpl=function(t,e){for(var n=t.shape[1],r=Math.ceil(n/e),i=[s.zeros([1,this.units]),s.zeros([1,this.units])],a=[],o=0;o<r;++o){var u=t.slice([0,o*e],[-1,o<r-1?e:-1]),c=this.lstm.predict([u,i[0],i[1]]);a.push(this.dense.predict(c[0])),i=c.slice(1)}return 1===a.length?a[0]:s.concat3d(a,1)},t}()},function(t,e,n){"use strict";t.exports=function(t){for(var e=new Array(t),n=0;n<t;++n)e[n]=n;return e}},function(t,e){function n(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}
/*!
 * Determine if an object is a Buffer
 *
 * @author   Feross Aboukhadijeh <https://feross.org>
 * @license  MIT
 */
t.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},function(t,e,n){"use strict";var r=n(377),i=n(382),s=n(215),a=n(383)({args:["array","array","scalar","scalar","scalar"],body:function(t,e,n,r,i){var s=e*n;s<r&&(s=r),s>i&&(s=i)}});t.exports=function(t,e,n,o){void 0===n&&(n=-1/0),void 0===o&&(o=1/0);var u=e.shape,c=t.shape;if(e.shape.length!==t.shape.length)throw new Error("ndarray-resample: input and output arrays should have the same dimensions");var l,h=u.map((function(){return 0}));if(1===t.size)return(l=s.sum(e)/e.size)<n&&(l=n),l>o&&(l=o),void t.set.apply(t,h.concat(l));if(1===e.size)return(l=e.get.apply(e,h))<n&&(l=n),l>o&&(l=o),void s.assigns(t,l);for(var d=u.length,p=new Array(d),f=!1,m=0;m<d;m++)p[m]=Math.min(c[m],u[m]),c[m]>u[m]&&(f=!0);var g=i.malloc(u),b=i.malloc(u);s.assign(g,e),s.assigns(b,0),r(1,g,b);var y=g.lo,v=g.hi,w=i.malloc(c),x=i.malloc(c);f&&(s.assigns(w,0),s.assigns(x,0));var _=new Array(d),O=new Array(d),S=new Array(d),k=new Array(d);for(m=0;m<1<<d;++m){for(var T=0;T<d;++T)if(m&1<<T){if(_[T]=p[T]-(p[T]+1>>>1),0===_[T])continue;O[T]=c[T]-_[T],S[T]=u[T]-_[T],k[T]=1&p[T]?0:1}else _[T]=p[T]+1>>>1,O[T]=0,S[T]=0,k[T]=0;s.assign(v.apply(y.apply(w,O),_),v.apply(y.apply(g,S),_)),s.assign(y.apply(v.apply(y.apply(x,O),_),k),y.apply(v.apply(y.apply(b,S),_),k)),s.assigns(v.apply(v.apply(y.apply(x,O),_),k),0)}r(-1,w,x),a(t,w,t.size/e.size,n,o),i.free(g),i.free(b),i.free(w),i.free(x)}},function(t,e,n){"use strict";var r=n(215),i=n(214),s=n(267),a=n(381);t.exports=function(t,e,n){var o,u,c=e.shape,l=c.length,h=1,d=new Array(l),p=0;for(o=l-1;o>=0;--o)if(d[o]=h,h*=c[o],p=Math.max(p,a.scratchMemory(c[o])),e.shape[o]!==n.shape[o])throw new Error("Shape mismatch, real and imaginary arrays must have same size");var f,m=4*h+p;f="array"===e.dtype||"float64"===e.dtype||"custom"===e.dtype?s.mallocDouble(m):s.mallocFloat(m);var g,b,y,v,w=i(f,c.slice(0),d,0),x=i(f,c.slice(0),d.slice(0),h),_=i(f,c.slice(0),d.slice(0),2*h),O=i(f,c.slice(0),d.slice(0),3*h),S=4*h;for(r.assign(w,e),r.assign(x,n),o=l-1;o>=0&&(a(t,h/c[o],c[o],f,w.offset,x.offset,S),0!==o);--o){for(b=1,y=_.stride,v=O.stride,u=o-1;u<l;++u)v[u]=y[u]=b,b*=c[u];for(u=o-2;u>=0;--u)v[u]=y[u]=b,b*=c[u];r.assign(_,w),r.assign(O,x),g=w,w=_,_=g,g=x,x=O,O=g}r.assign(e,w),r.assign(n,x),s.free(f)}},function(t,e,n){"use strict";var r=n(379);t.exports=function(t){var e=["'use strict'","var CACHED={}"],n=[],i=t.funcName+"_cwise_thunk";e.push(["return function ",i,"(",t.shimArgs.join(","),"){"].join(""));for(var s=[],a=[],o=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],u=[],c=[],l=0;l<t.arrayArgs.length;++l){var h=t.arrayArgs[l];n.push(["t",h,"=array",h,".dtype,","r",h,"=array",h,".order"].join("")),s.push("t"+h),s.push("r"+h),a.push("t"+h),a.push("r"+h+".join()"),o.push("array"+h+".data"),o.push("array"+h+".stride"),o.push("array"+h+".offset|0"),l>0&&(u.push("array"+t.arrayArgs[0]+".shape.length===array"+h+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[l]))),c.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+h+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[l])+"]"))}for(t.arrayArgs.length>1&&(e.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex--\x3e0;) {"),e.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}")),l=0;l<t.scalarArgs.length;++l)o.push("scalar"+t.scalarArgs[l]);return n.push(["type=[",a.join(","),"].join()"].join("")),n.push("proc=CACHED[type]"),e.push("var "+n.join(",")),e.push(["if(!proc){","CACHED[type]=proc=compile([",s.join(","),"])}","return proc(",o.join(","),")}"].join("")),t.debug&&console.log("-----Generated thunk:\n"+e.join("\n")+"\n----------"),new Function("compile",e.join("\n"))(r.bind(void 0,t))}},function(t,e,n){"use strict";var r=n(266);function i(t,e,n){var r,i,s=t.length,a=e.arrayArgs.length,o=e.indexArgs.length>0,u=[],c=[],l=0,h=0;for(r=0;r<s;++r)c.push(["i",r,"=0"].join(""));for(i=0;i<a;++i)for(r=0;r<s;++r)h=l,l=t[r],0===r?c.push(["d",i,"s",r,"=t",i,"p",l].join("")):c.push(["d",i,"s",r,"=(t",i,"p",l,"-s",h,"*t",i,"p",h,")"].join(""));for(c.length>0&&u.push("var "+c.join(",")),r=s-1;r>=0;--r)l=t[r],u.push(["for(i",r,"=0;i",r,"<s",l,";++i",r,"){"].join(""));for(u.push(n),r=0;r<s;++r){for(h=l,l=t[r],i=0;i<a;++i)u.push(["p",i,"+=d",i,"s",r].join(""));o&&(r>0&&u.push(["index[",h,"]-=s",h].join("")),u.push(["++index[",l,"]"].join(""))),u.push("}")}return u.join("\n")}function s(t,e,n){for(var r=t.body,i=[],s=[],a=0;a<t.args.length;++a){var o=t.args[a];if(!(o.count<=0)){var u=new RegExp(o.name,"g"),c="",l=e.arrayArgs.indexOf(a);switch(e.argTypes[a]){case"offset":var h=e.offsetArgIndex.indexOf(a);l=e.offsetArgs[h].array,c="+q"+h;case"array":c="p"+l+c;var d="l"+a,p="a"+l;if(0===e.arrayBlockIndices[l])1===o.count?"generic"===n[l]?o.lvalue?(i.push(["var ",d,"=",p,".get(",c,")"].join("")),r=r.replace(u,d),s.push([p,".set(",c,",",d,")"].join(""))):r=r.replace(u,[p,".get(",c,")"].join("")):r=r.replace(u,[p,"[",c,"]"].join("")):"generic"===n[l]?(i.push(["var ",d,"=",p,".get(",c,")"].join("")),r=r.replace(u,d),o.lvalue&&s.push([p,".set(",c,",",d,")"].join(""))):(i.push(["var ",d,"=",p,"[",c,"]"].join("")),r=r.replace(u,d),o.lvalue&&s.push([p,"[",c,"]=",d].join("")));else{for(var f=[o.name],m=[c],g=0;g<Math.abs(e.arrayBlockIndices[l]);g++)f.push("\\s*\\[([^\\]]+)\\]"),m.push("$"+(g+1)+"*t"+l+"b"+g);if(u=new RegExp(f.join(""),"g"),c=m.join("+"),"generic"===n[l])throw new Error("cwise: Generic arrays not supported in combination with blocks!");r=r.replace(u,[p,"[",c,"]"].join(""))}break;case"scalar":r=r.replace(u,"Y"+e.scalarArgs.indexOf(a));break;case"index":r=r.replace(u,"index");break;case"shape":r=r.replace(u,"shape")}}}return[i.join("\n"),r,s.join("\n")].join("\n").trim()}function a(t){for(var e=new Array(t.length),n=!0,r=0;r<t.length;++r){var i=t[r],s=i.match(/\d+/);s=s?s[0]:"",0===i.charAt(0)?e[r]="u"+i.charAt(1)+s:e[r]=i.charAt(0)+s,r>0&&(n=n&&e[r]===e[r-1])}return n?e[0]:e.join("")}t.exports=function(t,e){for(var n=e[1].length-Math.abs(t.arrayBlockIndices[0])|0,o=new Array(t.arrayArgs.length),u=new Array(t.arrayArgs.length),c=0;c<t.arrayArgs.length;++c)u[c]=e[2*c],o[c]=e[2*c+1];var l=[],h=[],d=[],p=[],f=[];for(c=0;c<t.arrayArgs.length;++c){t.arrayBlockIndices[c]<0?(d.push(0),p.push(n),l.push(n),h.push(n+t.arrayBlockIndices[c])):(d.push(t.arrayBlockIndices[c]),p.push(t.arrayBlockIndices[c]+n),l.push(0),h.push(t.arrayBlockIndices[c]));for(var m=[],g=0;g<o[c].length;g++)d[c]<=o[c][g]&&o[c][g]<p[c]&&m.push(o[c][g]-d[c]);f.push(m)}var b=["SS"],y=["'use strict'"],v=[];for(g=0;g<n;++g)v.push(["s",g,"=SS[",g,"]"].join(""));for(c=0;c<t.arrayArgs.length;++c){b.push("a"+c),b.push("t"+c),b.push("p"+c);for(g=0;g<n;++g)v.push(["t",c,"p",g,"=t",c,"[",d[c]+g,"]"].join(""));for(g=0;g<Math.abs(t.arrayBlockIndices[c]);++g)v.push(["t",c,"b",g,"=t",c,"[",l[c]+g,"]"].join(""))}for(c=0;c<t.scalarArgs.length;++c)b.push("Y"+c);if(t.shapeArgs.length>0&&v.push("shape=SS.slice(0)"),t.indexArgs.length>0){var w=new Array(n);for(c=0;c<n;++c)w[c]="0";v.push(["index=[",w.join(","),"]"].join(""))}for(c=0;c<t.offsetArgs.length;++c){var x=t.offsetArgs[c],_=[];for(g=0;g<x.offset.length;++g)0!==x.offset[g]&&(1===x.offset[g]?_.push(["t",x.array,"p",g].join("")):_.push([x.offset[g],"*t",x.array,"p",g].join("")));0===_.length?v.push("q"+c+"=0"):v.push(["q",c,"=",_.join("+")].join(""))}var O=r([].concat(t.pre.thisVars).concat(t.body.thisVars).concat(t.post.thisVars));for((v=v.concat(O)).length>0&&y.push("var "+v.join(",")),c=0;c<t.arrayArgs.length;++c)y.push("p"+c+"|=0");t.pre.body.length>3&&y.push(s(t.pre,t,u));var S=s(t.body,t,u),k=function(t){for(var e=0,n=t[0].length;e<n;){for(var r=1;r<t.length;++r)if(t[r][e]!==t[0][e])return e;++e}return e}(f);k<n?y.push(function(t,e,n,r){for(var s=e.length,a=n.arrayArgs.length,o=n.blockSize,u=n.indexArgs.length>0,c=[],l=0;l<a;++l)c.push(["var offset",l,"=p",l].join(""));for(l=t;l<s;++l)c.push(["for(var j"+l+"=SS[",e[l],"]|0;j",l,">0;){"].join("")),c.push(["if(j",l,"<",o,"){"].join("")),c.push(["s",e[l],"=j",l].join("")),c.push(["j",l,"=0"].join("")),c.push(["}else{s",e[l],"=",o].join("")),c.push(["j",l,"-=",o,"}"].join("")),u&&c.push(["index[",e[l],"]=j",l].join(""));for(l=0;l<a;++l){for(var h=["offset"+l],d=t;d<s;++d)h.push(["j",d,"*t",l,"p",e[d]].join(""));c.push(["p",l,"=(",h.join("+"),")"].join(""))}for(c.push(i(e,n,r)),l=t;l<s;++l)c.push("}");return c.join("\n")}(k,f[0],t,S)):y.push(i(f[0],t,S)),t.post.body.length>3&&y.push(s(t.post,t,u)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+y.join("\n")+"\n----------");var T=[t.funcName||"unnamed","_cwise_loop_",o[0].join("s"),"m",k,a(u)].join("");return new Function(["function ",T,"(",b.join(","),"){",y.join("\n"),"} return ",T].join(""))()}},function(t,e,n){"use strict";t.exports=function(t,e){switch(void 0===e&&(e=0),typeof t){case"number":if(t>0)return function(t,e){var n,r;for(n=new Array(t),r=0;r<t;++r)n[r]=e;return n}(0|t,e);break;case"object":if("number"==typeof t.length)return function t(e,n,r){var i=0|e[r];if(i<=0)return[];var s,a=new Array(i);if(r===e.length-1)for(s=0;s<i;++s)a[s]=n;else for(s=0;s<i;++s)a[s]=t(e,n,r+1);return a}(t,e,0)}return[]}},function(t,e,n){var r=n(268);function i(t,e,n,i,s,a){var o,u,c,l,h,d,p,f,m,g,b,y,v,w,x,_,O,S,k,T,C,A,N,I;for(t|=0,e|=0,s|=0,a|=0,o=n|=0,u=r.log2(o),S=0;S<e;++S){for(p=o>>1,h=0,c=0;c<o-1;c++){for(c<h&&(v=i[s+c],i[s+c]=i[s+h],i[s+h]=v,v=i[a+c],i[a+c]=i[a+h],i[a+h]=v),d=p;d<=h;)h-=d,d>>=1;h+=d}for(b=-1,y=0,g=1,f=0;f<u;f++){for(m=g,g<<=1,_=1,O=0,h=0;h<m;h++){for(c=h;c<o;c+=g)k=i[s+(l=c+m)],T=i[a+l],C=i[s+c],A=i[a+c],w=(N=_*(k+T))-T*(_+O),x=N+(I=k*(O-_)),i[s+l]=C-w,i[a+l]=A-x,i[s+c]+=w,i[a+c]+=x;I=_*(y-b),_=(N=b*(_+O))-O*(b+y),O=N+I}y=Math.sqrt((1-b)/2),t<0&&(y=-y),b=Math.sqrt((1+b)/2)}if(t<0){var E=1/o;for(c=0;c<o;c++)i[s+c]*=E,i[a+c]*=E}s+=n,a+=n}}t.exports=function(t,e,n,s,a,o,u){t|=0,e|=0,n|=0,a|=0,o|=0,r.isPow2(n)?i(t,e,n,s,a,o):function(t,e,n,s,a,o,u){t|=0,e|=0,n|=0,a|=0,o|=0,u|=0;var c,l,h,d,p,f,m,g,b,y=r.nextPow2(2*n+1),v=u,w=v+n,x=w+n,_=x+y,O=_+y,S=O+y,k=-t*Math.PI/n;for(b=0;b<n;++b)l=k*(b*b%(2*n)),d=Math.cos(l),p=Math.sin(l),s[O+(y-b)]=s[O+b]=s[v+b]=d,s[S+(y-b)]=s[S+b]=s[w+b]=p;for(b=n;b<=y-n;++b)s[O+b]=0;for(b=n;b<=y-n;++b)s[S+b]=0;i(1,1,y,s,O,S),k=t<0?1/n:1;for(c=0;c<e;++c){for(b=0;b<n;++b)l=s[a+b],h=s[o+b],d=s[v+b],p=-s[w+b],f=d*(l+h),m=l*(p-d),g=h*(d+p),s[x+b]=f-g,s[_+b]=f+m;for(b=n;b<y;++b)s[x+b]=0;for(b=n;b<y;++b)s[_+b]=0;for(i(1,1,y,s,x,_),b=0;b<y;++b)l=s[x+b],h=s[_+b],d=s[O+b],p=s[S+b],f=d*(l+h),m=l*(p-d),g=h*(d+p),s[x+b]=f-g,s[_+b]=f+m;for(i(-1,1,y,s,x,_),b=0;b<n;++b)l=s[x+b],h=s[_+b],d=s[v+b],p=-s[w+b],f=d*(l+h),m=l*(p-d),g=h*(d+p),s[a+b]=k*(f-g),s[o+b]=k*(f+m);a+=n,o+=n}}(t,e,n,s,a,o,u)},t.exports.scratchMemory=function(t){return r.isPow2(t)?0:2*t+4*r.nextPow2(2*t+1)}},function(t,e,n){"use strict";var r=n(214),i=n(215),s=n(267);e.clone=function(t){var e=t.dtype;"generic"!==e&&"array"!==e||(e="double");var n=s.malloc(t.size,e),a=r(n,t.shape);return i.assign(a,t),a},e.malloc=function(t,e){e||(e="double");for(var n=1,i=new Array(t.length),a=t.length-1;a>=0;--a)i[a]=n,n*=t[a];return r(s.malloc(n,e),t,i,0)},e.free=function(t){"generic"!==t.dtype&&"array"!==t.dtype&&s.free(t.data)},e.zeros=function(t,e){e||(e="double");for(var n=1,i=new Array(t.length),a=t.length-1;a>=0;--a)i[a]=n,n*=t[a];var o=s.malloc(n,e);for(a=0;a<n;++a)o[a]=0;return r(o,t,i,0)},e.ones=function(t,e){e||(e="double");for(var n=1,i=new Array(t.length),a=t.length-1;a>=0;--a)i[a]=n,n*=t[a];var o=s.malloc(n,e);for(a=0;a<n;++a)o[a]=1;return r(o,t,i,0)},e.eye=function(t,e){var n,i;e||(e="double");var a=1,o=new Array(t.length);for(n=t.length-1;n>=0;--n)o[n]=a,a*=t[n];var u=s.malloc(a,e);for(n=0;n<a;++n)u[n]=0;var c=1/0,l=0;for(n=t.length-1;n>=0;n--)l+=o[n],c=Math.min(c,t[n]);for(n=0,i=0;n<c;n++,i+=l)u[i]=1;return r(u,t,o,0)}},function(t,e,n){"use strict";var r=n(384),i=n(265),s=["args","body"],a=["pre","post","printCode","funcName","blockSize"];t.exports=function(t){for(var e in t)s.indexOf(e)<0&&a.indexOf(e)<0&&console.warn("cwise: Unknown argument '"+e+"' passed to expression compiler");for(var n=0;n<s.length;++n)if(!t[s[n]])throw new Error("cwise: Missing argument: "+s[n]);return i({args:t.args,pre:r(t.pre||function(){}),body:r(t.body),post:r(t.post||function(){}),debug:!!t.printCode,funcName:t.funcName||t.body.name||"cwise",blockSize:t.blockSize||64})}},function(t,e,n){"use strict";(function(e){var r=n(385),i=n(266),s=0;function a(t,e,n){this.name=t,this.lvalue=e,this.rvalue=n,this.count=0}function o(t,e,n,r){this.body=t,this.args=e,this.thisVars=n,this.localVars=r}t.exports=function(t){for(var n=["(",t,")()"].join(""),u=r.parse(n,{range:!0}),c="_inline_"+s+++"_",l=function(t){for(var e=t.body[0].expression.callee.params,n=new Array(e.length),r=0;r<e.length;++r)n[r]=e[r].name;return n}(u),h=new Array(l.length),d=0;d<l.length;++d)h[d]=new a([c,"arg",d,"_"].join(""),!1,!1);for(var p=new Array(n.length),f=(d=0,n.length);d<f;++d)p[d]=n.charAt(d);var m,g=[],b=[];function y(t,e){for(var n=t.range[0],r=t.range[1],i=n+1;i<r;++i)p[i]="";p[n]=e}return function t(n,r){if(n.parent=r,"MemberExpression"===n.type)n.computed?(t(n.object,n),t(n.property,n)):"ThisExpression"===n.object.type?y(n,(v=n.property.name,w="this_"+v.replace(/\_/g,"__"),b.push(w),w)):t(n.object,n);else{if("ThisExpression"===n.type)throw new Error("cwise-parser: Computed this is not allowed");if("Identifier"===n.type){var i=n.name,s=l.indexOf(i);if(s>=0){var a=h[s],o=function(t){return"AssignmentExpression"===t.parent.type&&t.parent.left===t?"="===t.parent.operator?1:3:"UpdateExpression"===t.parent.type?3:2}(n);1&o&&(a.lvalue=!0),2&o&&(a.rvalue=!0),++a.count,y(n,a.name)}else(function(t){if("eval"===t)throw new Error("cwise-parser: eval() not allowed");return"undefined"!=typeof window?t in window:void 0!==e?t in e:"undefined"!=typeof self&&t in self})(i)||y(n,function(t){var e=c+t.replace(/\_/g,"__");return g.push(e),e}(i))}else if("Literal"===n.type)"string"==typeof n.value&&y(n,"'"+n.value.replace(/\_/g,"\\_").replace(/\'/g,"'")+"'");else{if("WithStatement"===n.type)throw new Error("cwise-parser: with() statements not allowed");for(var u=Object.keys(n),d=0,p=u.length;d<p;++d)if("parent"!==u[d]){var f=n[u[d]];if(f)if(f instanceof Array)for(var m=0;m<f.length;++m)f[m]&&"string"==typeof f[m].type&&t(f[m],n);else"string"==typeof f.type&&t(f,n)}}}var v,w}(u.body[0].expression.callee.body,void 0),i(g),i(b),new o((m=u.body[0].expression.callee.body,p.slice(m.range[0],m.range[1]).join("")),h,b,g)}}).call(this,n(96))},function(t,e,n){var r,i,s;!function(n,a){"use strict";i=[e],void 0===(s="function"==typeof(r=function(t){var e,n,r,i,s,a,o,u,c,l,h,d,p,f,m,g,b,y;function v(t,e){if(!t)throw new Error("ASSERT: "+e)}function w(t){return t>=48&&t<=57}function x(t){return"0123456789abcdefABCDEF".indexOf(t)>=0}function _(t){return"01234567".indexOf(t)>=0}function O(t){return 32===t||9===t||11===t||12===t||160===t||t>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(t)>=0}function S(t){return 10===t||13===t||8232===t||8233===t}function k(t){return 36===t||95===t||t>=65&&t<=90||t>=97&&t<=122||92===t||t>=128&&o.NonAsciiIdentifierStart.test(String.fromCharCode(t))}function T(t){return 36===t||95===t||t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||92===t||t>=128&&o.NonAsciiIdentifierPart.test(String.fromCharCode(t))}function C(t){switch(t){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return!0;default:return!1}}function A(t){return"eval"===t||"arguments"===t}function N(t,e,n,r,i){var s;v("number"==typeof n,"Comment must have valid position"),b.lastCommentStart>=n||(b.lastCommentStart=n,s={type:t,value:e},y.range&&(s.range=[n,r]),y.loc&&(s.loc=i),y.comments.push(s),y.attachComment&&(y.leadingComments.push(s),y.trailingComments.push(s)))}function I(t){var e,n,r,i;for(e=h-t,n={start:{line:d,column:h-p-t}};h<f;)if(r=c.charCodeAt(h),++h,S(r))return y.comments&&(i=c.slice(e+t,h-1),n.end={line:d,column:h-p-1},N("Line",i,e,h-1,n)),13===r&&10===c.charCodeAt(h)&&++h,++d,void(p=h);y.comments&&(i=c.slice(e+t,h),n.end={line:d,column:h-p},N("Line",i,e,h,n))}function E(){var t,e,n,r;for(y.comments&&(t=h-2,e={start:{line:d,column:h-p-2}});h<f;)if(S(n=c.charCodeAt(h)))13===n&&10===c.charCodeAt(h+1)&&++h,++d,++h,p=h,h>=f&&H({},a.UnexpectedToken,"ILLEGAL");else if(42===n){if(47===c.charCodeAt(h+1))return++h,++h,void(y.comments&&(r=c.slice(t+2,h-2),e.end={line:d,column:h-p},N("Block",r,t,h,e)));++h}else++h;H({},a.UnexpectedToken,"ILLEGAL")}function j(){var t,e;for(e=0===h;h<f;)if(O(t=c.charCodeAt(h)))++h;else if(S(t))++h,13===t&&10===c.charCodeAt(h)&&++h,++d,p=h,e=!0;else if(47===t)if(47===(t=c.charCodeAt(h+1)))++h,++h,I(2),e=!0;else{if(42!==t)break;++h,++h,E()}else if(e&&45===t){if(45!==c.charCodeAt(h+1)||62!==c.charCodeAt(h+2))break;h+=3,I(3)}else{if(60!==t)break;if("!--"!==c.slice(h+1,h+4))break;++h,++h,++h,++h,I(4)}}function M(t){var e,n,r,i=0;for(n="u"===t?4:2,e=0;e<n;++e){if(!(h<f&&x(c[h])))return"";r=c[h++],i=16*i+"0123456789abcdef".indexOf(r.toLowerCase())}return String.fromCharCode(i)}function D(){var t,e;for(t=c.charCodeAt(h++),e=String.fromCharCode(t),92===t&&(117!==c.charCodeAt(h)&&H({},a.UnexpectedToken,"ILLEGAL"),++h,(t=M("u"))&&"\\"!==t&&k(t.charCodeAt(0))||H({},a.UnexpectedToken,"ILLEGAL"),e=t);h<f&&T(t=c.charCodeAt(h));)++h,e+=String.fromCharCode(t),92===t&&(e=e.substr(0,e.length-1),117!==c.charCodeAt(h)&&H({},a.UnexpectedToken,"ILLEGAL"),++h,(t=M("u"))&&"\\"!==t&&T(t.charCodeAt(0))||H({},a.UnexpectedToken,"ILLEGAL"),e+=t);return e}function R(){var t,n;return t=h,{type:1===(n=92===c.charCodeAt(h)?D():function(){var t,e;for(t=h++;h<f;){if(92===(e=c.charCodeAt(h)))return h=t,D();if(!T(e))break;++h}return c.slice(t,h)}()).length?e.Identifier:function(t){if(l&&C(t))return!0;switch(t.length){case 2:return"if"===t||"in"===t||"do"===t;case 3:return"var"===t||"for"===t||"new"===t||"try"===t||"let"===t;case 4:return"this"===t||"else"===t||"case"===t||"void"===t||"with"===t||"enum"===t;case 5:return"while"===t||"break"===t||"catch"===t||"throw"===t||"const"===t||"yield"===t||"class"===t||"super"===t;case 6:return"return"===t||"typeof"===t||"delete"===t||"switch"===t||"export"===t||"import"===t;case 7:return"default"===t||"finally"===t||"extends"===t;case 8:return"function"===t||"continue"===t||"debugger"===t;case 10:return"instanceof"===t;default:return!1}}(n)?e.Keyword:"null"===n?e.NullLiteral:"true"===n||"false"===n?e.BooleanLiteral:e.Identifier,value:n,lineNumber:d,lineStart:p,start:t,end:h}}function P(){var t,n,r,i,s=h,o=c.charCodeAt(h),u=c[h];switch(o){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:case 126:return++h,y.tokenize&&(40===o?y.openParenToken=y.tokens.length:123===o&&(y.openCurlyToken=y.tokens.length)),{type:e.Punctuator,value:String.fromCharCode(o),lineNumber:d,lineStart:p,start:s,end:h};default:if(61===(t=c.charCodeAt(h+1)))switch(o){case 43:case 45:case 47:case 60:case 62:case 94:case 124:case 37:case 38:case 42:return h+=2,{type:e.Punctuator,value:String.fromCharCode(o)+String.fromCharCode(t),lineNumber:d,lineStart:p,start:s,end:h};case 33:case 61:return h+=2,61===c.charCodeAt(h)&&++h,{type:e.Punctuator,value:c.slice(s,h),lineNumber:d,lineStart:p,start:s,end:h}}}return">>>="===(i=c.substr(h,4))?{type:e.Punctuator,value:i,lineNumber:d,lineStart:p,start:s,end:h+=4}:">>>"===(r=i.substr(0,3))||"<<="===r||">>="===r?{type:e.Punctuator,value:r,lineNumber:d,lineStart:p,start:s,end:h+=3}:u===(n=r.substr(0,2))[1]&&"+-<>&|".indexOf(u)>=0||"=>"===n?{type:e.Punctuator,value:n,lineNumber:d,lineStart:p,start:s,end:h+=2}:"<>=!+-*%&|^/".indexOf(u)>=0?(++h,{type:e.Punctuator,value:u,lineNumber:d,lineStart:p,start:s,end:h}):void H({},a.UnexpectedToken,"ILLEGAL")}function F(){var t,n,r;if(v(w((r=c[h]).charCodeAt(0))||"."===r,"Numeric literal must start with a decimal digit or a decimal point"),n=h,t="","."!==r){if(t=c[h++],r=c[h],"0"===t){if("x"===r||"X"===r)return++h,function(t){for(var n="";h<f&&x(c[h]);)n+=c[h++];return 0===n.length&&H({},a.UnexpectedToken,"ILLEGAL"),k(c.charCodeAt(h))&&H({},a.UnexpectedToken,"ILLEGAL"),{type:e.NumericLiteral,value:parseInt("0x"+n,16),lineNumber:d,lineStart:p,start:t,end:h}}(n);if(_(r)&&function(){var t,e;for(t=h+1;t<f;++t){if("8"===(e=c[t])||"9"===e)return!1;if(!_(e))return!0}return!0}())return function(t){for(var n="0"+c[h++];h<f&&_(c[h]);)n+=c[h++];return(k(c.charCodeAt(h))||w(c.charCodeAt(h)))&&H({},a.UnexpectedToken,"ILLEGAL"),{type:e.NumericLiteral,value:parseInt(n,8),octal:!0,lineNumber:d,lineStart:p,start:t,end:h}}(n)}for(;w(c.charCodeAt(h));)t+=c[h++];r=c[h]}if("."===r){for(t+=c[h++];w(c.charCodeAt(h));)t+=c[h++];r=c[h]}if("e"===r||"E"===r)if(t+=c[h++],"+"!==(r=c[h])&&"-"!==r||(t+=c[h++]),w(c.charCodeAt(h)))for(;w(c.charCodeAt(h));)t+=c[h++];else H({},a.UnexpectedToken,"ILLEGAL");return k(c.charCodeAt(h))&&H({},a.UnexpectedToken,"ILLEGAL"),{type:e.NumericLiteral,value:parseFloat(t),lineNumber:d,lineStart:p,start:n,end:h}}function z(){var t,n,r,i;return g=null,j(),t=h,n=function(){var t,e,n,r;for(v("/"===(t=c[h]),"Regular expression literal must start with a slash"),e=c[h++],n=!1,r=!1;h<f;)if(e+=t=c[h++],"\\"===t)S((t=c[h++]).charCodeAt(0))&&H({},a.UnterminatedRegExp),e+=t;else if(S(t.charCodeAt(0)))H({},a.UnterminatedRegExp);else if(n)"]"===t&&(n=!1);else{if("/"===t){r=!0;break}"["===t&&(n=!0)}return r||H({},a.UnterminatedRegExp),{value:e.substr(1,e.length-2),literal:e}}(),r=function(){var t,e,n,r;for(e="",n="";h<f&&T((t=c[h]).charCodeAt(0));)if(++h,"\\"===t&&h<f)if("u"===(t=c[h])){if(r=++h,t=M("u"))for(n+=t,e+="\\u";r<h;++r)e+=c[r];else h=r,n+="u",e+="\\u";K({},a.UnexpectedToken,"ILLEGAL")}else e+="\\",K({},a.UnexpectedToken,"ILLEGAL");else n+=t,e+=t;return{value:n,literal:e}}(),i=function(t,e){var n;try{n=new RegExp(t,e)}catch(t){H({},a.InvalidRegExp)}return n}(n.value,r.value),y.tokenize?{type:e.RegularExpression,value:i,lineNumber:d,lineStart:p,start:t,end:h}:{literal:n.literal+r.literal,value:i,start:t,end:h}}function L(){var t,e,n,r;return j(),t=h,e={start:{line:d,column:h-p}},n=z(),e.end={line:d,column:h-p},y.tokenize||(y.tokens.length>0&&(r=y.tokens[y.tokens.length-1]).range[0]===t&&"Punctuator"===r.type&&("/"!==r.value&&"/="!==r.value||y.tokens.pop()),y.tokens.push({type:"RegularExpression",value:n.literal,range:[t,h],loc:e})),n}function $(){var t;return j(),h>=f?{type:e.EOF,lineNumber:d,lineStart:p,start:h,end:h}:k(t=c.charCodeAt(h))?R():40===t||41===t||59===t?P():39===t||34===t?function(){var t,n,r,i,s,o,u,l,m="",g=!1;for(u=d,l=p,v("'"===(t=c[h])||'"'===t,"String literal must starts with a quote"),n=h,++h;h<f;){if((r=c[h++])===t){t="";break}if("\\"===r)if((r=c[h++])&&S(r.charCodeAt(0)))++d,"\r"===r&&"\n"===c[h]&&++h,p=h;else switch(r){case"u":case"x":o=h,(s=M(r))?m+=s:(h=o,m+=r);break;case"n":m+="\n";break;case"r":m+="\r";break;case"t":m+="\t";break;case"b":m+="\b";break;case"f":m+="\f";break;case"v":m+="\v";break;default:_(r)?(0!==(i="01234567".indexOf(r))&&(g=!0),h<f&&_(c[h])&&(g=!0,i=8*i+"01234567".indexOf(c[h++]),"0123".indexOf(r)>=0&&h<f&&_(c[h])&&(i=8*i+"01234567".indexOf(c[h++]))),m+=String.fromCharCode(i)):m+=r}else{if(S(r.charCodeAt(0)))break;m+=r}}return""!==t&&H({},a.UnexpectedToken,"ILLEGAL"),{type:e.StringLiteral,value:m,octal:g,startLineNumber:u,startLineStart:l,lineNumber:d,lineStart:p,start:n,end:h}}():46===t?w(c.charCodeAt(h+1))?F():P():w(t)?F():y.tokenize&&47===t?function(){var t,e;if(!(t=y.tokens[y.tokens.length-1]))return L();if("Punctuator"===t.type){if("]"===t.value)return P();if(")"===t.value)return!(e=y.tokens[y.openParenToken-1])||"Keyword"!==e.type||"if"!==e.value&&"while"!==e.value&&"for"!==e.value&&"with"!==e.value?P():L();if("}"===t.value){if(y.tokens[y.openCurlyToken-3]&&"Keyword"===y.tokens[y.openCurlyToken-3].type){if(!(e=y.tokens[y.openCurlyToken-4]))return P()}else{if(!y.tokens[y.openCurlyToken-4]||"Keyword"!==y.tokens[y.openCurlyToken-4].type)return P();if(!(e=y.tokens[y.openCurlyToken-5]))return L()}return r.indexOf(e.value)>=0?P():L()}return L()}return"Keyword"===t.type&&"this"!==t.value?L():P()}():P()}function B(){var t,r,i;return j(),t={start:{line:d,column:h-p}},r=$(),t.end={line:d,column:h-p},r.type!==e.EOF&&(i=c.slice(r.start,r.end),y.tokens.push({type:n[r.type],value:i,range:[r.start,r.end],loc:t})),r}function q(){var t;return h=(t=g).end,d=t.lineNumber,p=t.lineStart,g=void 0!==y.tokens?B():$(),h=t.end,d=t.lineNumber,p=t.lineStart,t}function V(){var t,e,n;t=h,e=d,n=p,g=void 0!==y.tokens?B():$(),h=t,d=e,p=n}function U(t,e){this.line=t,this.column=e}function W(t,e,n,r){this.start=new U(t,e),this.end=new U(n,r)}function G(){var t,e,n,r;return t=h,e=d,n=p,j(),r=d!==e,h=t,d=e,p=n,r}function H(t,e){var n,r=Array.prototype.slice.call(arguments,2),i=e.replace(/%(\d)/g,(function(t,e){return v(e<r.length,"Message reference must be in range"),r[e]}));throw"number"==typeof t.lineNumber?((n=new Error("Line "+t.lineNumber+": "+i)).index=t.start,n.lineNumber=t.lineNumber,n.column=t.start-p+1):((n=new Error("Line "+d+": "+i)).index=h,n.lineNumber=d,n.column=h-p+1),n.description=i,n}function K(){try{H.apply(null,arguments)}catch(t){if(!y.errors)throw t;y.errors.push(t)}}function Q(t){if(t.type===e.EOF&&H(t,a.UnexpectedEOS),t.type===e.NumericLiteral&&H(t,a.UnexpectedNumber),t.type===e.StringLiteral&&H(t,a.UnexpectedString),t.type===e.Identifier&&H(t,a.UnexpectedIdentifier),t.type===e.Keyword){if(function(t){switch(t){case"class":case"enum":case"export":case"extends":case"import":case"super":return!0;default:return!1}}(t.value))H(t,a.UnexpectedReserved);else if(l&&C(t.value))return void K(t,a.StrictReservedWord);H(t,a.UnexpectedToken,t.value)}H(t,a.UnexpectedToken,t.value)}function X(t){var n=q();n.type===e.Punctuator&&n.value===t||Q(n)}function Y(t){var n=q();n.type===e.Keyword&&n.value===t||Q(n)}function J(t){return g.type===e.Punctuator&&g.value===t}function Z(t){return g.type===e.Keyword&&g.value===t}function tt(){var t,n=h,r=d,i=p,s=g;if(59===c.charCodeAt(h)||J(";"))q();else{if(t=d,j(),d!==t)return h=n,d=r,p=i,void(g=s);g.type===e.EOF||J("}")||Q(g)}}function et(t){return t.type===i.Identifier||t.type===i.MemberExpression}function nt(t,e){var n,r,i;return n=l,i=g,r=kt(),e&&l&&A(t[0].name)&&K(e,a.StrictParamName),l=n,m.markEnd(m.createFunctionExpression(null,t,[],r),i)}function rt(){var t,n;return n=g,(t=q()).type===e.StringLiteral||t.type===e.NumericLiteral?(l&&t.octal&&K(t,a.StrictOctalLiteral),m.markEnd(m.createLiteral(t),n)):m.markEnd(m.createIdentifier(t.value),n)}function it(){var t,n,r,i,s,o;return o=g,(t=g).type===e.Identifier?(r=rt(),"get"!==t.value||J(":")?"set"!==t.value||J(":")?(X(":"),i=mt(),m.markEnd(m.createProperty("init",r,i),o)):(n=rt(),X("("),(t=g).type!==e.Identifier?(X(")"),K(t,a.UnexpectedToken,t.value),i=nt([])):(s=[yt()],X(")"),i=nt(s,t)),m.markEnd(m.createProperty("set",n,i),o)):(n=rt(),X("("),X(")"),i=nt([]),m.markEnd(m.createProperty("get",n,i),o))):t.type!==e.EOF&&t.type!==e.Punctuator?(n=rt(),X(":"),i=mt(),m.markEnd(m.createProperty("init",n,i),o)):void Q(t)}function st(){var t,n,r,o;if(J("("))return function(){var t;return X("("),t=gt(),X(")"),t}();if(J("["))return function(){var t,e=[];for(t=g,X("[");!J("]");)J(",")?(q(),e.push(null)):(e.push(mt()),J("]")||X(","));return q(),m.markEnd(m.createArrayExpression(e),t)}();if(J("{"))return function(){var t,e,n,r,o,u=[],c={},h=String;for(o=g,X("{");!J("}");)e=(t=it()).key.type===i.Identifier?t.key.name:h(t.key.value),r="init"===t.kind?s.Data:"get"===t.kind?s.Get:s.Set,n="$"+e,Object.prototype.hasOwnProperty.call(c,n)?(c[n]===s.Data?l&&r===s.Data?K({},a.StrictDuplicateProperty):r!==s.Data&&K({},a.AccessorDataProperty):r===s.Data?K({},a.AccessorDataProperty):c[n]&r&&K({},a.AccessorGetSet),c[n]|=r):c[n]=r,u.push(t),J("}")||X(",");return X("}"),m.markEnd(m.createObjectExpression(u),o)}();if(t=g.type,o=g,t===e.Identifier)r=m.createIdentifier(q().value);else if(t===e.StringLiteral||t===e.NumericLiteral)l&&g.octal&&K(g,a.StrictOctalLiteral),r=m.createLiteral(q());else if(t===e.Keyword){if(Z("function"))return function(){var t,e,n,r,i,s,o,u,c,h=null;c=g,Y("function"),J("(")||(t=g,h=yt(),l?A(t.value)&&K(t,a.StrictFunctionName):A(t.value)?(n=t,r=a.StrictFunctionName):C(t.value)&&(n=t,r=a.StrictReservedWord));i=Tt(n),s=i.params,e=i.stricted,n=i.firstRestricted,i.message&&(r=i.message);u=l,o=kt(),l&&n&&H(n,r);l&&e&&K(e,r);return l=u,m.markEnd(m.createFunctionExpression(h,s,[],o),c)}();Z("this")?(q(),r=m.createThisExpression()):Q(q())}else t===e.BooleanLiteral?((n=q()).value="true"===n.value,r=m.createLiteral(n)):t===e.NullLiteral?((n=q()).value=null,r=m.createLiteral(n)):J("/")||J("/=")?(r=void 0!==y.tokens?m.createLiteral(L()):m.createLiteral(z()),V()):Q(q());return m.markEnd(r,o)}function at(){var t=[];if(X("("),!J(")"))for(;h<f&&(t.push(mt()),!J(")"));)X(",");return X(")"),t}function ot(){var t,n;return n=g,function(t){return t.type===e.Identifier||t.type===e.Keyword||t.type===e.BooleanLiteral||t.type===e.NullLiteral}(t=q())||Q(t),m.markEnd(m.createIdentifier(t.value),n)}function ut(){return X("."),ot()}function ct(){var t;return X("["),t=gt(),X("]"),t}function lt(){var t,e,n;return n=g,Y("new"),t=function(){var t,e,n;v(b.allowIn,"callee of new expression always allow in keyword."),n=g,t=Z("new")?lt():st();for(;J(".")||J("[");)J("[")?(e=ct(),t=m.createMemberExpression("[",t,e)):(e=ut(),t=m.createMemberExpression(".",t,e)),m.markEnd(t,n);return t}(),e=J("(")?at():[],m.markEnd(m.createNewExpression(t,e),n)}function ht(){var t,n,r=g;return t=function(){var t,e,n,r,i=b.allowIn;for(r=g,b.allowIn=!0,t=Z("new")?lt():st();;){if(J("."))n=ut(),t=m.createMemberExpression(".",t,n);else if(J("("))e=at(),t=m.createCallExpression(t,e);else{if(!J("["))break;n=ct(),t=m.createMemberExpression("[",t,n)}m.markEnd(t,r)}return b.allowIn=i,t}(),g.type===e.Punctuator&&(!J("++")&&!J("--")||G()||(l&&t.type===i.Identifier&&A(t.name)&&K({},a.StrictLHSPostfix),et(t)||K({},a.InvalidLHSInAssignment),n=q(),t=m.markEnd(m.createPostfixExpression(n.value,t),r))),t}function dt(){var t,n,r;return g.type!==e.Punctuator&&g.type!==e.Keyword?n=ht():J("++")||J("--")?(r=g,t=q(),n=dt(),l&&n.type===i.Identifier&&A(n.name)&&K({},a.StrictLHSPrefix),et(n)||K({},a.InvalidLHSInAssignment),n=m.createUnaryExpression(t.value,n),n=m.markEnd(n,r)):J("+")||J("-")||J("~")||J("!")?(r=g,t=q(),n=dt(),n=m.createUnaryExpression(t.value,n),n=m.markEnd(n,r)):Z("delete")||Z("void")||Z("typeof")?(r=g,t=q(),n=dt(),n=m.createUnaryExpression(t.value,n),n=m.markEnd(n,r),l&&"delete"===n.operator&&n.argument.type===i.Identifier&&K({},a.StrictDelete)):n=ht(),n}function pt(t,n){var r=0;if(t.type!==e.Punctuator&&t.type!==e.Keyword)return 0;switch(t.value){case"||":r=1;break;case"&&":r=2;break;case"|":r=3;break;case"^":r=4;break;case"&":r=5;break;case"==":case"!=":case"===":case"!==":r=6;break;case"<":case">":case"<=":case">=":case"instanceof":r=7;break;case"in":r=n?7:0;break;case"<<":case">>":case">>>":r=8;break;case"+":case"-":r=9;break;case"*":case"/":case"%":r=11}return r}function ft(){var t,e,n,r,i;return i=g,t=function(){var t,e,n,r,i,s,a,o,u,c;if(t=g,u=dt(),0===(i=pt(r=g,b.allowIn)))return u;for(r.prec=i,q(),e=[t,g],s=[u,r,a=dt()];(i=pt(g,b.allowIn))>0;){for(;s.length>2&&i<=s[s.length-2].prec;)a=s.pop(),o=s.pop().value,u=s.pop(),n=m.createBinaryExpression(o,u,a),e.pop(),t=e[e.length-1],m.markEnd(n,t),s.push(n);(r=q()).prec=i,s.push(r),e.push(g),n=dt(),s.push(n)}for(n=s[c=s.length-1],e.pop();c>1;)n=m.createBinaryExpression(s[c-1].value,s[c-2],n),c-=2,t=e.pop(),m.markEnd(n,t);return n}(),J("?")&&(q(),e=b.allowIn,b.allowIn=!0,n=mt(),b.allowIn=e,X(":"),r=mt(),t=m.createConditionalExpression(t,n,r),m.markEnd(t,i)),t}function mt(){var t,n,r,s,o,u;return t=g,o=g,s=n=ft(),g.type!==e.Punctuator||"="!==(u=g.value)&&"*="!==u&&"/="!==u&&"%="!==u&&"+="!==u&&"-="!==u&&"<<="!==u&&">>="!==u&&">>>="!==u&&"&="!==u&&"^="!==u&&"|="!==u||(et(n)||K({},a.InvalidLHSInAssignment),l&&n.type===i.Identifier&&A(n.name)&&K(t,a.StrictLHSAssignment),t=q(),r=mt(),s=m.markEnd(m.createAssignmentExpression(t.value,n,r),o)),s}function gt(){var t,e=g;if(t=mt(),J(",")){for(t=m.createSequenceExpression([t]);h<f&&J(",");)q(),t.expressions.push(mt());m.markEnd(t,e)}return t}function bt(){var t,e;return e=g,X("{"),t=function(){for(var t,e=[];h<f&&!J("}")&&void 0!==(t=At());)e.push(t);return e}(),X("}"),m.markEnd(m.createBlockStatement(t),e)}function yt(){var t,n;return n=g,(t=q()).type!==e.Identifier&&Q(t),m.markEnd(m.createIdentifier(t.value),n)}function vt(t){var e,n,r=null;return n=g,e=yt(),l&&A(e.name)&&K({},a.StrictVarName),"const"===t?(X("="),r=mt()):J("=")&&(q(),r=mt()),m.markEnd(m.createVariableDeclarator(e,r),n)}function wt(t){var e=[];do{if(e.push(vt(t)),!J(","))break;q()}while(h<f);return e}function xt(){var t,e,n,r,i,s,o,u,c,l,h=b.allowIn;return t=e=n=null,Y("for"),X("("),J(";")?q():(Z("var")||Z("let")?(b.allowIn=!1,l=g,u=q(),c=wt(),t=m.markEnd(m.createVariableDeclaration(c,u.value),l),b.allowIn=h,1===t.declarations.length&&Z("in")&&(q(),r=t,i=gt(),t=null)):(b.allowIn=!1,t=gt(),b.allowIn=h,Z("in")&&(et(t)||K({},a.InvalidLHSInForIn),q(),r=t,i=gt(),t=null)),void 0===r&&X(";")),void 0===r&&(J(";")||(e=gt()),X(";"),J(")")||(n=gt())),X(")"),o=b.inIteration,b.inIteration=!0,s=St(),b.inIteration=o,void 0===r?m.createForStatement(t,e,n,s):m.createForInStatement(r,i,s)}function _t(){var t,e,n,r=[];for(n=g,Z("default")?(q(),t=null):(Y("case"),t=gt()),X(":");h<f&&!(J("}")||Z("default")||Z("case"));)e=St(),r.push(e);return m.markEnd(m.createSwitchCase(t,r),n)}function Ot(){var t,e,n,r,i=[],s=null;return Y("try"),t=bt(),Z("catch")&&i.push((r=g,Y("catch"),X("("),J(")")&&Q(g),e=yt(),l&&A(e.name)&&K({},a.StrictCatchVariable),X(")"),n=bt(),m.markEnd(m.createCatchClause(e,n),r))),Z("finally")&&(q(),s=bt()),0!==i.length||s||H({},a.NoCatchOrFinally),m.createTryStatement(t,[],i,s)}function St(){var t,n,r,s,o,u,d,p,y,v=g.type;if(v===e.EOF&&Q(g),v===e.Punctuator&&"{"===g.value)return bt();if(s=g,v===e.Punctuator)switch(g.value){case";":return m.markEnd((X(";"),m.createEmptyStatement()),s);case"(":return m.markEnd(function(){var t=gt();return tt(),m.createExpressionStatement(t)}(),s)}if(v===e.Keyword)switch(g.value){case"break":return m.markEnd(function(){var t,n=null;return Y("break"),59===c.charCodeAt(h)?(q(),b.inIteration||b.inSwitch||H({},a.IllegalBreak),m.createBreakStatement(null)):G()?(b.inIteration||b.inSwitch||H({},a.IllegalBreak),m.createBreakStatement(null)):(g.type===e.Identifier&&(t="$"+(n=yt()).name,Object.prototype.hasOwnProperty.call(b.labelSet,t)||H({},a.UnknownLabel,n.name)),tt(),null!==n||b.inIteration||b.inSwitch||H({},a.IllegalBreak),m.createBreakStatement(n))}(),s);case"continue":return m.markEnd(function(){var t,n=null;return Y("continue"),59===c.charCodeAt(h)?(q(),b.inIteration||H({},a.IllegalContinue),m.createContinueStatement(null)):G()?(b.inIteration||H({},a.IllegalContinue),m.createContinueStatement(null)):(g.type===e.Identifier&&(t="$"+(n=yt()).name,Object.prototype.hasOwnProperty.call(b.labelSet,t)||H({},a.UnknownLabel,n.name)),tt(),null!==n||b.inIteration||H({},a.IllegalContinue),m.createContinueStatement(n))}(),s);case"debugger":return m.markEnd((Y("debugger"),tt(),m.createDebuggerStatement()),s);case"do":return m.markEnd((Y("do"),y=b.inIteration,b.inIteration=!0,d=St(),b.inIteration=y,Y("while"),X("("),p=gt(),X(")"),J(";")&&q(),m.createDoWhileStatement(d,p)),s);case"for":return m.markEnd(xt(),s);case"function":return m.markEnd(Ct(),s);case"if":return m.markEnd(function(){var t,e,n;return Y("if"),X("("),t=gt(),X(")"),e=St(),Z("else")?(q(),n=St()):n=null,m.createIfStatement(t,e,n)}(),s);case"return":return m.markEnd((u=null,Y("return"),b.inFunctionBody||K({},a.IllegalReturn),32===c.charCodeAt(h)&&k(c.charCodeAt(h+1))?(u=gt(),tt(),m.createReturnStatement(u)):G()?m.createReturnStatement(null):(J(";")||J("}")||g.type===e.EOF||(u=gt()),tt(),m.createReturnStatement(u))),s);case"switch":return m.markEnd(function(){var t,e,n,r,i;if(Y("switch"),X("("),t=gt(),X(")"),X("{"),e=[],J("}"))return q(),m.createSwitchStatement(t,e);for(r=b.inSwitch,b.inSwitch=!0,i=!1;h<f&&!J("}");)null===(n=_t()).test&&(i&&H({},a.MultipleDefaultsInSwitch),i=!0),e.push(n);return b.inSwitch=r,X("}"),m.createSwitchStatement(t,e)}(),s);case"throw":return m.markEnd(function(){var t;return Y("throw"),G()&&H({},a.NewlineAfterThrow),t=gt(),tt(),m.createThrowStatement(t)}(),s);case"try":return m.markEnd(Ot(),s);case"var":return m.markEnd((Y("var"),o=wt(),tt(),m.createVariableDeclaration(o,"var")),s);case"while":return m.markEnd(function(){var t,e,n;return Y("while"),X("("),t=gt(),X(")"),n=b.inIteration,b.inIteration=!0,e=St(),b.inIteration=n,m.createWhileStatement(t,e)}(),s);case"with":return m.markEnd(function(){var t,e;return l&&(j(),K({},a.StrictModeWith)),Y("with"),X("("),t=gt(),X(")"),e=St(),m.createWithStatement(t,e)}(),s)}return(t=gt()).type===i.Identifier&&J(":")?(q(),r="$"+t.name,Object.prototype.hasOwnProperty.call(b.labelSet,r)&&H({},a.Redeclaration,"Label",t.name),b.labelSet[r]=!0,n=St(),delete b.labelSet[r],m.markEnd(m.createLabeledStatement(t,n),s)):(tt(),m.markEnd(m.createExpressionStatement(t),s))}function kt(){var t,n,r,s,o,u,d,p,y=[];for(p=g,X("{");h<f&&g.type===e.StringLiteral&&(n=g,t=At(),y.push(t),t.expression.type===i.Literal);)"use strict"===c.slice(n.start+1,n.end-1)?(l=!0,r&&K(r,a.StrictOctalLiteral)):!r&&n.octal&&(r=n);for(s=b.labelSet,o=b.inIteration,u=b.inSwitch,d=b.inFunctionBody,b.labelSet={},b.inIteration=!1,b.inSwitch=!1,b.inFunctionBody=!0;h<f&&!J("}")&&void 0!==(t=At());)y.push(t);return X("}"),b.labelSet=s,b.inIteration=o,b.inSwitch=u,b.inFunctionBody=d,m.markEnd(m.createBlockStatement(y),p)}function Tt(t){var e,n,r,i,s,o,u=[];if(X("("),!J(")"))for(i={};h<f&&(n=g,e=yt(),s="$"+n.value,l?(A(n.value)&&(r=n,o=a.StrictParamName),Object.prototype.hasOwnProperty.call(i,s)&&(r=n,o=a.StrictParamDupe)):t||(A(n.value)?(t=n,o=a.StrictParamName):C(n.value)?(t=n,o=a.StrictReservedWord):Object.prototype.hasOwnProperty.call(i,s)&&(t=n,o=a.StrictParamDupe)),u.push(e),i[s]=!0,!J(")"));)X(",");return X(")"),{params:u,stricted:r,firstRestricted:t,message:o}}function Ct(){var t,e,n,r,i,s,o,u,c,h;return h=g,Y("function"),r=g,t=yt(),l?A(r.value)&&K(r,a.StrictFunctionName):A(r.value)?(o=r,u=a.StrictFunctionName):C(r.value)&&(o=r,u=a.StrictReservedWord),e=(s=Tt(o)).params,i=s.stricted,o=s.firstRestricted,s.message&&(u=s.message),c=l,n=kt(),l&&o&&H(o,u),l&&i&&K(i,u),l=c,m.markEnd(m.createFunctionDeclaration(t,e,[],n),h)}function At(){if(g.type===e.Keyword)switch(g.value){case"const":case"let":return t=g.value,r=g,Y(t),n=wt(t),tt(),m.markEnd(m.createVariableDeclaration(n,t),r);case"function":return Ct();default:return St()}var t,n,r;if(g.type!==e.EOF)return St()}function Nt(){var t,n;return j(),V(),n=g,l=!1,t=function(){for(var t,n,r,s=[];h<f&&(n=g).type===e.StringLiteral&&(t=At(),s.push(t),t.expression.type===i.Literal);)"use strict"===c.slice(n.start+1,n.end-1)?(l=!0,r&&K(r,a.StrictOctalLiteral)):!r&&n.octal&&(r=n);for(;h<f&&void 0!==(t=At());)s.push(t);return s}(),m.markEnd(m.createProgram(t),n)}function It(){var t,e,n,r=[];for(t=0;t<y.tokens.length;++t)n={type:(e=y.tokens[t]).type,value:e.value},y.range&&(n.range=e.range),y.loc&&(n.loc=e.loc),r.push(n);y.tokens=r}(n={})[(e={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8,RegularExpression:9}).BooleanLiteral]="Boolean",n[e.EOF]="<end>",n[e.Identifier]="Identifier",n[e.Keyword]="Keyword",n[e.NullLiteral]="Null",n[e.NumericLiteral]="Numeric",n[e.Punctuator]="Punctuator",n[e.StringLiteral]="String",n[e.RegularExpression]="RegularExpression",r=["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="],i={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement"},s={Data:1,Get:2,Set:4},a={UnexpectedToken:"Unexpected token %0",UnexpectedNumber:"Unexpected number",UnexpectedString:"Unexpected string",UnexpectedIdentifier:"Unexpected identifier",UnexpectedReserved:"Unexpected reserved word",UnexpectedEOS:"Unexpected end of input",NewlineAfterThrow:"Illegal newline after throw",InvalidRegExp:"Invalid regular expression",UnterminatedRegExp:"Invalid regular expression: missing /",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NoCatchOrFinally:"Missing catch or finally after try",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared",IllegalContinue:"Illegal continue statement",IllegalBreak:"Illegal break statement",IllegalReturn:"Illegal return statement",StrictModeWith:"Strict mode code may not include a with statement",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictDuplicateProperty:"Duplicate data property in object literal not allowed in strict mode",AccessorDataProperty:"Object literal may not have data and accessor property with the same name",AccessorGetSet:"Object literal may not have multiple get/set accessors with the same name",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictReservedWord:"Use of future reserved word in strict mode"},o={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ﬀ-ﬆﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼＡ-Ｚａ-ｚｦ-ﾾￂ-ￇￊ-ￏￒ-ￗￚ-ￜ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԧԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠࢢ-ࢬࣤ-ࣾऀ-ॣ०-९ॱ-ॷॹ-ॿঁ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಂಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲംഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤜᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶᴀ-ᷦ᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‌‍‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚗꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺꩻꪀ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ﬀ-ﬆﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︦︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ０-９Ａ-Ｚ＿ａ-ｚｦ-ﾾￂ-ￇￊ-ￏￒ-ￗￚ-ￜ]")},u={name:"SyntaxTree",processComment:function(t){var e,n;if(!(t.type===i.Program&&t.body.length>0)){for(y.trailingComments.length>0?y.trailingComments[0].range[0]>=t.range[1]?(n=y.trailingComments,y.trailingComments=[]):y.trailingComments.length=0:y.bottomRightStack.length>0&&y.bottomRightStack[y.bottomRightStack.length-1].trailingComments&&y.bottomRightStack[y.bottomRightStack.length-1].trailingComments[0].range[0]>=t.range[1]&&(n=y.bottomRightStack[y.bottomRightStack.length-1].trailingComments,delete y.bottomRightStack[y.bottomRightStack.length-1].trailingComments);y.bottomRightStack.length>0&&y.bottomRightStack[y.bottomRightStack.length-1].range[0]>=t.range[0];)e=y.bottomRightStack.pop();e?e.leadingComments&&e.leadingComments[e.leadingComments.length-1].range[1]<=t.range[0]&&(t.leadingComments=e.leadingComments,delete e.leadingComments):y.leadingComments.length>0&&y.leadingComments[y.leadingComments.length-1].range[1]<=t.range[0]&&(t.leadingComments=y.leadingComments,y.leadingComments=[]),n&&(t.trailingComments=n),y.bottomRightStack.push(t)}},markEnd:function(t,e){return y.range&&(t.range=[e.start,h]),y.loc&&(t.loc=new W(void 0===e.startLineNumber?e.lineNumber:e.startLineNumber,e.start-(void 0===e.startLineStart?e.lineStart:e.startLineStart),d,h-p),this.postProcess(t)),y.attachComment&&this.processComment(t),t},postProcess:function(t){return y.source&&(t.loc.source=y.source),t},createArrayExpression:function(t){return{type:i.ArrayExpression,elements:t}},createAssignmentExpression:function(t,e,n){return{type:i.AssignmentExpression,operator:t,left:e,right:n}},createBinaryExpression:function(t,e,n){return{type:"||"===t||"&&"===t?i.LogicalExpression:i.BinaryExpression,operator:t,left:e,right:n}},createBlockStatement:function(t){return{type:i.BlockStatement,body:t}},createBreakStatement:function(t){return{type:i.BreakStatement,label:t}},createCallExpression:function(t,e){return{type:i.CallExpression,callee:t,arguments:e}},createCatchClause:function(t,e){return{type:i.CatchClause,param:t,body:e}},createConditionalExpression:function(t,e,n){return{type:i.ConditionalExpression,test:t,consequent:e,alternate:n}},createContinueStatement:function(t){return{type:i.ContinueStatement,label:t}},createDebuggerStatement:function(){return{type:i.DebuggerStatement}},createDoWhileStatement:function(t,e){return{type:i.DoWhileStatement,body:t,test:e}},createEmptyStatement:function(){return{type:i.EmptyStatement}},createExpressionStatement:function(t){return{type:i.ExpressionStatement,expression:t}},createForStatement:function(t,e,n,r){return{type:i.ForStatement,init:t,test:e,update:n,body:r}},createForInStatement:function(t,e,n){return{type:i.ForInStatement,left:t,right:e,body:n,each:!1}},createFunctionDeclaration:function(t,e,n,r){return{type:i.FunctionDeclaration,id:t,params:e,defaults:n,body:r,rest:null,generator:!1,expression:!1}},createFunctionExpression:function(t,e,n,r){return{type:i.FunctionExpression,id:t,params:e,defaults:n,body:r,rest:null,generator:!1,expression:!1}},createIdentifier:function(t){return{type:i.Identifier,name:t}},createIfStatement:function(t,e,n){return{type:i.IfStatement,test:t,consequent:e,alternate:n}},createLabeledStatement:function(t,e){return{type:i.LabeledStatement,label:t,body:e}},createLiteral:function(t){return{type:i.Literal,value:t.value,raw:c.slice(t.start,t.end)}},createMemberExpression:function(t,e,n){return{type:i.MemberExpression,computed:"["===t,object:e,property:n}},createNewExpression:function(t,e){return{type:i.NewExpression,callee:t,arguments:e}},createObjectExpression:function(t){return{type:i.ObjectExpression,properties:t}},createPostfixExpression:function(t,e){return{type:i.UpdateExpression,operator:t,argument:e,prefix:!1}},createProgram:function(t){return{type:i.Program,body:t}},createProperty:function(t,e,n){return{type:i.Property,key:e,value:n,kind:t}},createReturnStatement:function(t){return{type:i.ReturnStatement,argument:t}},createSequenceExpression:function(t){return{type:i.SequenceExpression,expressions:t}},createSwitchCase:function(t,e){return{type:i.SwitchCase,test:t,consequent:e}},createSwitchStatement:function(t,e){return{type:i.SwitchStatement,discriminant:t,cases:e}},createThisExpression:function(){return{type:i.ThisExpression}},createThrowStatement:function(t){return{type:i.ThrowStatement,argument:t}},createTryStatement:function(t,e,n,r){return{type:i.TryStatement,block:t,guardedHandlers:e,handlers:n,finalizer:r}},createUnaryExpression:function(t,e){return"++"===t||"--"===t?{type:i.UpdateExpression,operator:t,argument:e,prefix:!0}:{type:i.UnaryExpression,operator:t,argument:e,prefix:!0}},createVariableDeclaration:function(t,e){return{type:i.VariableDeclaration,declarations:t,kind:e}},createVariableDeclarator:function(t,e){return{type:i.VariableDeclarator,id:t,init:e}},createWhileStatement:function(t,e){return{type:i.WhileStatement,test:t,body:e}},createWithStatement:function(t,e){return{type:i.WithStatement,object:t,body:e}}},t.version="1.2.5",t.tokenize=function(t,n){var r;"string"==typeof t||t instanceof String||(t=String(t)),m=u,h=0,d=(c=t).length>0?1:0,p=0,f=c.length,g=null,b={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},y={},(n=n||{}).tokens=!0,y.tokens=[],y.tokenize=!0,y.openParenToken=-1,y.openCurlyToken=-1,y.range="boolean"==typeof n.range&&n.range,y.loc="boolean"==typeof n.loc&&n.loc,"boolean"==typeof n.comment&&n.comment&&(y.comments=[]),"boolean"==typeof n.tolerant&&n.tolerant&&(y.errors=[]);try{if(V(),g.type===e.EOF)return y.tokens;for(q();g.type!==e.EOF;)try{q()}catch(t){if(g,y.errors){y.errors.push(t);break}throw t}It(),r=y.tokens,void 0!==y.comments&&(r.comments=y.comments),void 0!==y.errors&&(r.errors=y.errors)}catch(t){throw t}finally{y={}}return r},t.parse=function(t,e){var n,r;r=String,"string"==typeof t||t instanceof String||(t=r(t)),m=u,h=0,d=(c=t).length>0?1:0,p=0,f=c.length,g=null,b={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},y={},void 0!==e&&(y.range="boolean"==typeof e.range&&e.range,y.loc="boolean"==typeof e.loc&&e.loc,y.attachComment="boolean"==typeof e.attachComment&&e.attachComment,y.loc&&null!==e.source&&void 0!==e.source&&(y.source=r(e.source)),"boolean"==typeof e.tokens&&e.tokens&&(y.tokens=[]),"boolean"==typeof e.comment&&e.comment&&(y.comments=[]),"boolean"==typeof e.tolerant&&e.tolerant&&(y.errors=[]),y.attachComment&&(y.range=!0,y.comments=[],y.bottomRightStack=[],y.trailingComments=[],y.leadingComments=[]));try{n=Nt(),void 0!==y.comments&&(n.comments=y.comments),void 0!==y.tokens&&(It(),n.tokens=y.tokens),void 0!==y.errors&&(n.errors=y.errors)}catch(t){throw t}finally{y={}}return n},t.Syntax=function(){var t,e={};for(t in"function"==typeof Object.create&&(e=Object.create(null)),i)i.hasOwnProperty(t)&&(e[t]=i[t]);return"function"==typeof Object.freeze&&Object.freeze(e),e}()})?r.apply(e,i):r)||(t.exports=s)}()},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.preprocessAudio=void 0;var s=n(111),a=n(216);e.preprocessAudio=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,s.resampleAndMakeMono(t)];case 1:return e=n.sent(),[2,s.powerToDb(s.melSpectrogram(e,{sampleRate:a.SAMPLE_RATE,hopLength:a.SPEC_HOP_LENGTH,nMels:a.MEL_SPEC_BINS,nFft:2048,fMin:30}))]}}))}))}},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.pianorollToNoteSequence=e.unbatchOutput=e.batchInput=void 0;var s=n(36),a=n(79),o=n(216);e.batchInput=function(t,e){var n=Math.ceil(t.length/e),r=t.length%e,i=0;if(n>1&&r>0&&r<=3&&(n-=1,i=r,r=0),1===n)return s.tensor2d(t).expandDims(0);var a,o=e+6,u=s.tensor2d(t.slice(0,o)).expandDims(0),c=s.tensor2d(t.slice(t.length-o)).expandDims(0);if(2===n)return s.concat([u,c],0);a=r?s.tensor2d(t).pad([[0,e-r],[0,0]]).as3D(n,e,-1):s.tensor2d(t.slice(0,t.length-i)).as3D(n,e,-1);var l=s.slice(a,[0,e-3],[n-2,-1]),h=s.slice(a,[2,0],[-1,3]),d=s.concat([l,a.slice(1,n-2),h],1);return s.concat([u,d,c],0)},e.unbatchOutput=function(t,e,n){return 1===t.shape[0]?t:s.tidy((function(){var r=t.slice([0,0],[1,e]),i=n%e;i<=3&&(i+=e);var a=t.slice([t.shape[0]-1,t.shape[1]-i],[-1,-1]),o=[r,a];if(t.shape[0]>2){var u=t.shape[0]-2;o=[r,t.slice([1,3],[u,e]).as3D(1,u*e,-1),a]}return s.concat(o,1)}))},e.pianorollToNoteSequence=function(t,e,n,u,c){return void 0===u&&(u=.5),void 0===c&&(c=.5),r(this,void 0,void 0,(function(){function r(t,e){h.notes.push(a.NoteSequence.Note.create({pitch:t+o.MIN_MIDI_PITCH,startTime:(d[t]-1)*o.FRAME_LENGTH_SECONDS,endTime:e*o.FRAME_LENGTH_SECONDS,velocity:p[t]})),d[t]=0}function l(t,e,n){d[t]?f[t]||(r(t,e),d[t]=e+1,p[t]=n):(d[t]=e+1,p[t]=n)}var h,d,p,f,m,g,b,y,v,w,x,_,O;return i(this,(function(i){switch(i.label){case 0:return h=a.NoteSequence.create(),d=new Uint32Array(o.MIDI_PITCHES),p=new Uint8Array(o.MIDI_PITCHES),f=new Uint8Array(o.MIDI_PITCHES),m=s.tidy((function(){var r=s.greater(e,u),i=s.greater(t,c);return r=r.pad([[0,1],[0,0]]),i=i.pad([[0,1],[0,0]]),n=n.pad([[0,1],[0,0]]),[i=s.logicalOr(i,r),r,n]})),[4,Promise.all(m.map((function(t){return t.data()})))];case 1:for(g=i.sent(),b=g[0],y=g[1],v=g[2],m.forEach((function(t){return t.dispose()})),w=t.shape[0],x=0;x<w+1;++x){for(_=0;_<o.MIDI_PITCHES;++_)O=x*o.MIDI_PITCHES+_,y[O]?l(_,x,v[O]):!b[O]&&d[_]&&r(_,x);f=y.slice(x*o.MIDI_PITCHES,(x+1)*o.MIDI_PITCHES)}return h.totalTime=w*o.FRAME_LENGTH_SECONDS,[2,h]}}))}))}},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(389),e)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(390);Object.defineProperty(e,"GANSynth",{enumerable:!0,get:function(){return r.GANSynth}})},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.GANSynth=void 0;var s=n(36),a=n(55),o=n(61),u=n(391),c=n(394),l=function(){function t(t){this.nn=s.sequential(),this.nLatents=256,this.nPitches=61,this.minMidiPitch=24,this.maxMidiPitch=84,this.midiPitches=this.maxMidiPitch-this.minMidiPitch+1,this.checkpointURL=t}return t.prototype.initialize=function(){return r(this,void 0,void 0,(function(){var t,e,n=this;return i(this,(function(r){switch(r.label){case 0:return t=o.performance.now(),[4,o.fetch(this.checkpointURL+"/weights_manifest.json").then((function(t){return t.json()})).then((function(t){return s.io.loadWeights(t,n.checkpointURL)}))];case 1:return e=r.sent(),s.tidy((function(){for(var r in e)if(r.includes("kernel")){var i=e[r].shape[0]*e[r].shape[1]*e[r].shape[2],o=e[r];e[r]=s.mul(o,s.sqrt(2/i)),o.dispose()}n.build(e),n.initialized=!0,a.logWithDuration("Initialized model",t,"GANSynth")})),Object.keys(e).map((function(t){return e[t].dispose()})),[2]}}))}))},t.prototype.dispose=function(){this.initialized&&(this.nn.dispose(),this.initialized=!1)},t.prototype.isInitialized=function(){return this.initialized},t.prototype.build=function(t){var e=this;s.tidy((function(){var n={filters:256,kernelSize:[2,16],strides:[1,1],activation:"linear",useBias:!0,padding:"valid",dilationRate:[1,1],trainable:!1},r={inputShape:[1,1,e.nLatents+e.nPitches]};e.nn.add(c.pixelNorm(1e-8,r)),e.nn.add(c.initialPad(2,16)),e.nn.add(s.layers.conv2d(n)),e.nn.add(s.layers.leakyReLU({alpha:.2})),e.nn.add(c.pixelNorm()),n.padding="same",n.kernelSize=[3,3],e.nn.add(s.layers.conv2d(n)),e.nn.add(s.layers.leakyReLU({alpha:.2})),e.nn.add(c.pixelNorm());for(var i=[256,256,256,128,64,32],a=0;a<i.length;a++)e.nn.add(c.boxUpscale(2)),n.filters=i[a],e.nn.add(s.layers.conv2d(n)),e.nn.add(s.layers.leakyReLU({alpha:.2})),e.nn.add(c.pixelNorm()),e.nn.add(s.layers.conv2d(n)),e.nn.add(s.layers.leakyReLU({alpha:.2})),e.nn.add(c.pixelNorm());n.filters=2,n.kernelSize=[1,1],n.activation="tanh",e.nn.add(s.layers.conv2d(n)),e.setWeights(t)}))},t.prototype.setWeights=function(t){function e(e){var n=t[e];if(void 0===n)throw Error("Variable not found: "+e);return n}var n="Generator/progressive_gan_generator/progressive_gan_block_",r=[e(n+"1/conv0/conv2d/kernel/ExponentialMovingAverage"),e(n+"1/conv0/bias/ExponentialMovingAverage"),e(n+"1/conv1/conv2d/kernel/ExponentialMovingAverage"),e(n+"1/conv1/bias/ExponentialMovingAverage"),e(n+"2/conv0/conv2d/kernel/ExponentialMovingAverage"),e(n+"2/conv0/bias/ExponentialMovingAverage"),e(n+"2/conv1/conv2d/kernel/ExponentialMovingAverage"),e(n+"2/conv1/bias/ExponentialMovingAverage"),e(n+"3/conv0/conv2d/kernel/ExponentialMovingAverage"),e(n+"3/conv0/bias/ExponentialMovingAverage"),e(n+"3/conv1/conv2d/kernel/ExponentialMovingAverage"),e(n+"3/conv1/bias/ExponentialMovingAverage"),e(n+"4/conv0/conv2d/kernel/ExponentialMovingAverage"),e(n+"4/conv0/bias/ExponentialMovingAverage"),e(n+"4/conv1/conv2d/kernel/ExponentialMovingAverage"),e(n+"4/conv1/bias/ExponentialMovingAverage"),e(n+"5/conv0/conv2d/kernel/ExponentialMovingAverage"),e(n+"5/conv0/bias/ExponentialMovingAverage"),e(n+"5/conv1/conv2d/kernel/ExponentialMovingAverage"),e(n+"5/conv1/bias/ExponentialMovingAverage"),e(n+"6/conv0/conv2d/kernel/ExponentialMovingAverage"),e(n+"6/conv0/bias/ExponentialMovingAverage"),e(n+"6/conv1/conv2d/kernel/ExponentialMovingAverage"),e(n+"6/conv1/bias/ExponentialMovingAverage"),e(n+"7/conv0/conv2d/kernel/ExponentialMovingAverage"),e(n+"7/conv0/bias/ExponentialMovingAverage"),e(n+"7/conv1/conv2d/kernel/ExponentialMovingAverage"),e(n+"7/conv1/bias/ExponentialMovingAverage"),e(n+"7/to_rgb/conv2d/kernel/ExponentialMovingAverage"),e(n+"7/to_rgb/bias/ExponentialMovingAverage")];this.nn.setWeights(r)},t.prototype.predict=function(t,e){return this.nn.predict(t,{batchSize:e})},t.prototype.randomSample=function(t){var e=this;return s.tidy((function(){var n=s.randomNormal([1,e.nLatents],0,1,"float32"),r=s.tensor1d([t-e.minMidiPitch],"int32"),i=s.oneHot(r,e.midiPitches),a=s.concat([n,i],1).expandDims(1).expandDims(1);return e.predict(a,1)}))},t.prototype.specgramsToAudio=function(t){return u.specgramsToAudio(t)},t}();e.GANSynth=l},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.istft=e.ifft=e.specgramsToAudio=e.ifreqToPhase=e.melToLinear=e.melToLinearMatrix=void 0;var s=n(36),a=n(264),o=n(111),u=n(392),c=n(393);function l(){for(var t=s.buffer([1024,1024]),e=0;e<c.MEL_SPARSE_COEFFS.length;e++){var n=c.MEL_SPARSE_COEFFS[e];t.set(n[2],n[0],n[1])}return t.toTensor()}function h(t,e,n){return s.div(s.sub(t,n),e)}function d(t){return s.tidy((function(){var e=l().expandDims(0),n=h(t,u.MAG_DESCALE_A,u.MAG_DESCALE_B),r=s.exp(n),i=s.matMul(r,e);return s.sqrt(i)}))}function p(t){return s.tidy((function(){var e=l().expandDims(0),n=h(t,u.PHASE_DESCALE_A,u.PHASE_DESCALE_B),r=s.cumsum(s.mul(n,Math.PI),1);return s.matMul(r,e)}))}function f(t,e){for(var n=s.tidy((function(){var n=s.concat([t,e],0).expandDims(3);n=s.pad(n,[[0,0],[0,0],[1,0],[0,0]]);return s.batchToSpaceND(n,[1,2],[[0,0],[0,0]]).reshape([128,4096])})),r=n.dataSync(),i=[],a=0;a<128;a++)i[a]=r.slice(4096*a,4096*(a+1));return n.dispose(),i}function m(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){return e={nFFt:u.N_FFT,winLength:u.N_FFT,hopLength:u.N_HOP,sampleRate:u.SAMPLE_RATE,center:!1},[2,b(t,e)]}))}))}function g(t){var e=t.length/2,n=new a(e),r=n.createComplexArray();return n.inverseTransform(r,t),n.fromComplexArray(r)}function b(t,e){for(var n=t.length,r=t[0].length/2,i=e.winLength||r,s=e.hopLength||Math.floor(i/4),a=e.center||!1,c=o.hannWindow(i),l=0;l<c.length;l++)c[l]=c[l]/1.5;c=o.padCenterToLength(c,r);var h=r+s*(n-1),d=new Float32Array(h);for(l=0;l<n;l++){var p=l*s,f=g(t[l]);f=y(f=o.applyWindow(f,c),d.slice(p,p+r)),d.set(f,p)}var m=0,b=h;return a?(m=r/2,b=d.length-r/2):(m=h-u.SAMPLE_LENGTH,b=d.length-m),d.slice(m,b)}function y(t,e){if(t.length!==e.length)return console.error("Array lengths must be equal to add: "+t.length+", "+t.length),null;for(var n=new Float32Array(t.length),r=0;r<t.length;r++)n[r]=t[r]+e[r];return n}e.melToLinearMatrix=l,e.melToLinear=d,e.ifreqToPhase=p,e.specgramsToAudio=function(t){return r(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,f((e=s.tidy((function(){var e=d(s.slice(t,[0,0,0,0],[1,-1,-1,1]).reshape([1,128,1024])),n=p(s.slice(t,[0,0,0,1],[1,-1,-1,1]).reshape([1,128,1024])),r=e.mul(s.cos(n)),i=s.reverse(r.slice([0,0,0],[1,128,1023]),2);r=s.concat([r,i],2);var a=e.mul(s.sin(n)),o=s.reverse(a.slice([0,0,0],[1,128,1023]),2);return[r,a=s.concat([a,s.mul(o,-1)],2)]})))[0],e[1])];case 1:return[4,m(r.sent())];case 2:return n=r.sent(),e.forEach((function(t){return t.dispose()})),[2,n]}}))}))},e.ifft=g,e.istft=b},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.N_FFT=e.N_HOP=e.SAMPLE_LENGTH=e.SAMPLE_RATE=e.PHASE_DESCALE_B=e.PHASE_DESCALE_A=e.MAG_DESCALE_B=e.MAG_DESCALE_A=void 0,e.MAG_DESCALE_A=.0661371661726,e.MAG_DESCALE_B=.113718730221,e.PHASE_DESCALE_A=.8,e.PHASE_DESCALE_B=0,e.SAMPLE_RATE=16e3,e.SAMPLE_LENGTH=64e3,e.N_HOP=512,e.N_FFT=2048},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MEL_SPARSE_COEFFS=void 0,e.MEL_SPARSE_COEFFS=[[1,1,1.0087615084725814],[2,1,.029087889211125567],[2,2,.958243896036208],[3,2,.5326346877272624],[3,3,.45988057223186607],[4,3,1.0072850129664943],[5,4,1.0050894259864507],[6,4,.016233689242197466],[6,5,.9763230964529687],[7,5,.5149287456976357],[7,6,.48299891928441196],[8,6,1.0020339883784544],[9,7,1.0013940582804204],[10,7,.004285414445239434],[10,8,.9936677765505681],[11,8,.4979349533263788],[11,9,.5020647178266697],[12,9,.9896782321684733],[12,10,.006967080931645349],[13,10,1.0022486641537054],[14,11,1.0033233953996759],[15,11,.4782757843614299],[15,12,.5183887055972138],[16,12,.9736767011426267],[16,13,.01804416217807709],[17,13,1.0056329663266226],[18,14,1.00808642668908],[19,14,.4576416347984229],[19,15,.5340800956534676],[20,15,.9582897445862256],[20,16,.028988367857957848],[21,16,1.008754652772106],[22,17,1.0122552436937966],[23,17,.4380796830853842],[23,18,.5491738237632201],[24,18,.9434838949694413],[24,19,.039794474296176746],[25,19,1.0116287566447584],[26,20,1.0158945544322868],[27,20,.41952402212367873],[27,21,.5637020154076856],[28,21,.9292283399303117],[28,22,.05045785324282485],[29,22,1.0142694870195312],[30,23,1.0190617246342517],[31,23,.40191289323704393],[31,24,.5776942788784806],[32,24,.915494649120402],[32,25,.060974426459003916],[33,25,1.016690283888679],[34,26,1.0218076651124588],[35,26,.3851885348435194],[35,27,.5911779611807773],[36,27,.9022565352474414],[36,28,.07134062388959171],[37,28,1.0189038677945517],[38,29,1.0241776077147466],[39,29,.369297000124277],[39,30,.6041783722578726],[40,30,.8894896443111251],[40,31,.08155334505527755],[41,31,1.0209222848386956],[42,32,1.0262117836546005],[43,32,.35418795675261777],[43,33,.6167189821271176],[44,33,.87717137085618],[44,34,.09160992335204851],[45,34,1.0227569476841007],[46,35,1.0279460165329002],[47,35,.3398144781420294],[47,36,.628821594757742],[48,36,.8652806947525041],[48,37,.10150809298528844],[49,37,1.0244186730654867],[50,38,1.029412240942602],[51,38,.32613283297317347],[51,39,.6405065019041107],[52,39,.8537980365619783],[52,40,.11124595830527892],[53,40,1.0259177162406141],[54,41,1.030638956235277],[55,41,.3131022777355948],[55,42,.6517926196031543],[56,42,.8427051290118196],[56,43,.12082196533877268],[57,43,1.0272638027474759],[58,44,1.031651623831845],[59,44,.3006848555240512],[59,45,.6626976096262132],[60,45,.8319849024715039],[60,46,.13023487533380312],[61,46,1.0284661577762764],[62,47,1.0324730153919173],[63,47,.28884520321029805],[63,48,.6732379878311283],[64,48,.821621382643116],[64,49,.1394837401591093],[65,49,1.0295335334192939],[66,50,1.0331235182054521],[67,50,.27755036829985363],[67,51,.68342922107227],[68,51,.8115995989355603],[68,52,.148567879414825],[69,52,1.0304742340231496],[70,53,1.0336214033370148],[71,53,.2667696361817086],[71,54,.6932858140884962],[72,54,.8019055022130549],[72,55,.1574868591255191],[73,55,1.031296139836255],[74,56,1.0339830613212895],[75,56,.2564743680536822],[75,57,.7028213875855097],[76,57,.7925258907912134],[76,58,.16624047189958738],[77,58,1.032006729117501],[78,59,1.0342232095724524],[79,59,.24663784949713183],[79,60,.7120487485622758],[80,60,.7834483437084975],[80,61,.17482871845079165],[81,61,1.032613098850059],[82,62,1.0343550751159198],[83,62,.2372351494674972],[83,63,.7209799537859948],[84,63,.7746611604312031],[84,64,.18325179038711914],[85,64,1.0331219841851924],[86,65,1.0343905557724016],[87,65,.22824298931879333],[87,66,.7296263672031092],[88,66,.7661533062642226],[88,67,.19151005417692718],[89,67,1.0335397767254908],[90,68,1.0343403625078313],[91,68,.21963962139622123],[91,69,.7379987119645334],[92,69,.7579143628308538],[92,70,.19960403621540457],[93,70,1.0338725417430177],[94,71,1.0342141453043734],[95,71,.21140471667072153],[95,72,.746107117663542],[96,72,.7499344830670268],[96,73,.20753440891552338],[97,73,1.0341260344172454],[98,74,1.034020604597683],[99,74,.20351926086574523],[99,75,.7539611633021215],[100,75,.7422043502477234],[100,76,.2153019777561019],[101,76,1.0343057151671131],[102,77,1.0337675900563705],[103,77,.19596545852169872],[103,78,.7615699164421695],[104,78,.734715140616724],[104,79,.22290766922455862],[105,79,1.034416764143981],[106,80,1.03346218824938],[107,80,.1887266444456389],[107,81,.7689419689404797],[108,81,.7274584892496355],[108,82,.23035251959385997],[109,82,1.0344640949448594],[110,83,1.0331108005456808],[111,83,.18178720201436843],[111,84,.7760854696185804],[112,84,.7204264588178948],[112,85,.23763766448199494],[113,85,1.0344523675990727],[114,86,1.032719212418228],[115,86,.1751324878193402],[115,87,.7830081541774375],[116,87,.7136115109646374],[116,88,.2447643291417676],[117,88,1.0343860008764458],[118,89,1.0322926551739824],[119,89,.16874876216974247],[119,90,.789717372631832],[120,90,.7070064800338803],[120,91,.2517338194331562],[121,91,1.0342691839607763],[122,92,1.0318358610025598],[123,92,.16262312499771858],[123,93,.7962201145052664],[124,93,.7006045489251309],[124,94,.25854751343650967],[125,94,1.0341058875275075],[126,95,1.0313531121234998],[127,95,.15674345673841866],[127,96,.8025230320033012],[128,96,.6943992268713032],[128,97,.2652068536620191],[129,97,1.033899874262366],[130,98,1.030848284714744],[131,98,.1510983637896712],[131,99,.8086324613545763],[132,99,.6883843289574696],[132,100,.2717133398209474],[133,100,1.033654708853177],[134,101,1.0303248882205327],[135,101,.14567712818173575],[135,102,.8145544424922615],[136,102,.6825539572209546],[136,103,.2780685221191216],[137,103,1.033373767485838],[138,104,1.0297861005632643],[139,104,.14046966111762169],[139,105,.8202947372282664],[140,105,.6769024831869065],[140,106,.28427399504058354],[141,106,1.0330602468722847],[142,107,1.029234799720434],[143,107,.13546646006984392],[143,108,.8258588460540109],[144,108,.671424531713726],[144,109,.290331391589362],[145,109,1.0327171728357682],[146,110,1.0286735920712562],[147,110,.13065856914309196],[147,111,.8312520236957351],[148,111,.6661149660273628],[148,112,.2962423779602388],[149,112,1.03234740847843],[150,113,1.0281048378703825],[151,113,.12603754244145],[151,114,.8364792935255917],[152,114,.6609688738465388],[152,115,.30200864860954885],[153,115,1.0319536619522978],[154,116,1.0275306741623285],[155,116,.12159541018943322],[155,117,.8415454609370665],[156,117,.655981554500098],[156,118,.3076319217011811],[157,118,1.031538493855763],[158,119,1.0269530354146845],[159,119,.11732464738966399],[159,120,.846455125764718],[160,120,.6511485069565366],[160,121,.3131139349019227],[161,121,1.0311043242739946],[162,122,1.0263736721146446],[163,122,.11321814480714538],[163,123,.851212693834753],[164,123,.6464654186857061],[164,124,.3184564415055735],[165,124,1.0306534394819706],[166,125,1.0257941675461106],[167,125,.10926918209624069],[167,126,.8558223877141483],[168,126,.6419281552876014],[168,127,.32366120686047056],[169,127,1.0301879983273805],[170,128,1.0252159529388847],[171,128,.10547140289367021],[171,129,.8602882567276612],[172,129,.6375327508240597],[172,130,.32873000508360367],[173,130,1.0297100383091813],[174,131,1.0246403211604227],[175,131,.10181879172477112],[175,132,.8646141862987496],[176,132,.6332753987956673],[176,133,.33366461604209907],[177,133,1.0292214813668379],[178,134,1.0240684391009978],[179,134,.09830565257411007],[179,135,.8688039066707689],[180,135,.6291524437169539],[180,136,.3384668225808326],[181,136,1.0287241393952773],[182,137,1.0235013588866442],[183,137,.0949265889928822],[183,138,.8728610010546515],[184,138,.6251603732380943],[184,139,.3431384079843332],[185,139,1.0282197194980238],[186,140,1.0229400280388043],[187,140,.09167648561647405],[187,141,.8767889132518744],[188,141,.6212958107744541],[188,142,.3476811536535296],[189,142,1.0277098289923983],[190,143,1.0223852986877378],[191,143,.08855049098843445],[191,144,.8805909547856343],[192,144,.6175555086043407],[192,145,.35209683698566024],[193,145,1.0271959801772084],[194,146,1.021837935933431],[195,146,.08554400158179727],[195,147,.8842703115872171],[196,147,.6139363413989273],[196,148,.35638722943949186],[197,148,1.026679594876984],[198,149,1.0212986254395027],[199,149,.082652646931321],[199,150,.8878300502607867],[200,150,.6104353001536761],[200,151,.3605540947783916],[201,151,1.0261620087703698],[202,152,1.020767980334856],[203,152,.07987227578640096],[203,153,.8912731239662092],[204,153,.6070494864912312],[204,154,.364599187472458],[205,154,1.025644475516362],[206,155,1.0202465474911722],[207,155,.07719894321045902],[207,156,.8946023779404728],[208,156,.6037761073076129],[208,157,.36852425125748506],[209,157,1.0251281706842847],[210,158,1.0197348132361097],[211,158,.07462889855138014],[211,159,.8978205546916732],[212,159,.6006124697383151],[212,160,.3723310178292769],[213,160,1.0246141955013988],[214,161,1.0192332085569418],[215,161,.07215857422040488],[215,162,.9009302988805],[216,162,.5975559764226185],[216,163,.37602120567284064],[217,163,1.024103580422386],[218,164,1.018742113842709],[219,164,.06978457521665815],[219,165,.9039341619174114],[220,165,.5946041210439893],[220,166,.3795965190111676],[221,166,1.0235972885322195],[222,167,1.0182618632088625],[223,167,.0675036693443592],[223,168,.9068346062921914],[224,168,.5917544841265701],[224,169,.3830586468674795],[225,169,1.0230962187892327],[226,170,1.0177927484431766],[227,170,.06531277806896706],[227,171,.9096340096561174],[228,171,.5890047290713193],[228,172,.38640926223293437],[229,172,1.0226012091159231],[230,173,1.017335022608167],[231,173,.0632089679653424],[231,174,.9123346686734497],[232,174,.586352598418078],[232,175,.3896500213288084],[233,175,1.0221130393455482],[234,176,1.0168889033326205],[235,176,.06118944272087777],[235,177,.914938802652698],[236,177,.5837959103122896],[236,178,.39278256296329067],[237,178,1.0216324340290364],[238,179,1.0164545758191],[239,179,.05925153564332089],[239,180,.9174485569826359],[240,180,.5813325551691159],[240,181,.3958085079669357],[241,181,1.0211600651125134],[242,182,1.01603219559476],[243,182,.05739270264601734],[243,183,.919866006375456],[244,183,.578960492519135],[244,184,.39872945870775167],[245,184,1.020696554488055],[246,185,1.0156218910279706],[247,185,.055610515672866775],[247,186,.9221931579354511],[248,186,.5766777480237313],[248,187,.4015469986761612],[249,187,1.0202424764259312],[250,188,1.0152237656316911],[251,188,.05390265653168126],[251,189,.9244319540637365],[252,189,.5744824106486663],[252,190,.4042626921377848],[253,190,1.0197983598926021],[254,191,1.0148379001729047],[255,191,.052266911108559244],[255,192,.9265842752073952],[256,192,.5723726299899468],[256,193,.40687808384383367],[257,193,1.0193646907609162],[258,194,1.0144643546050645],[259,194,.05070116393653833],[259,195,.9286519424651887],[260,195,.5703466137364466],[260,196,.4093946987997115],[261,196,1.0189419139168765],[262,197,1.014103169839173],[263,197,.04920339309393266],[263,198,.9306367200572258],[264,198,.5684026252644323],[264,199,.41181404208517797],[265,199,1.0185304352678317],[266,200,1.0137543693675302],[267,200,.04777166540942449],[267,201,.9325403176671191],[268,201,.5665389813575877],[268,202,.4141375987198434],[269,202,1.0181306236573189],[270,203,1.0134179607527265],[271,203,.04640413195303674],[271,204,.934364392667829],[272,204,.5647540500383554],[272,205,.4163668335733731],[273,205,1.017742812691386],[274,206,1.0130939369942324],[275,206,.04509902379599986],[275,207,.9361105522297561],[276,207,.5630462485124229],[276,208,.4185031913161667],[277,208,1.0173673024779883],[278,209,1.0127822777820206],[279,209,.043854648017688035],[279,210,.9377803553285139],[280,210,.5614140412123577],[280,211,.42054809640522234],[281,211,1.0170043612872055],[282,212,1.0124829506474082],[283,212,.042669383945431606],[283,213,.9393753146522579],[284,213,.5598559379382144],[284,214,.42250295310432634],[285,214,1.016654227133528],[286,215,1.0121959120202477],[287,215,.04154167961383383],[287,216,.9408968984130733],[288,216,.5583704920894111],[288,217,.42436914553372207],[289,217,1.0163171092845467],[290,218,1.0119211081990869],[291,218,.04047004842376173],[291,219,.9423465320743504],[292,219,.5569562989809166],[292,220,.4261480377490578],[293,220,1.0159931896995795],[294,221,1.0116584762427925],[295,221,.03945306599345366],[295,222,.9437255999933521],[296,222,.5556119942410062],[296,223,.4278409738424421],[297,223,1.0156826244024533],[298,224,1.0114079447897668],[299,224,.038489367187566605],[299,225,.9450354469842541],[300,225,.5543362522836106],[300,226,.42944927807097044],[301,226,1.015385544788648],[302,227,1.0111694348102989],[303,227,.03757764331096192],[303,228,.9462773798108762],[304,228,.5531277848528364],[304,229,.4309742550012965],[305,229,1.0151020588742643],[306,230,1.010942860298229],[307,230,.036716639459590646],[307,231,.9474526686068676],[308,231,.5519853396352962],[308,232,.4324171896758833],[309,232,1.0148322524854105],[310,233,1.0107281289063446],[311,233,.03590515201636021],[311,234,.9485625482321702],[312,234,.5509076989367998],[312,235,.43377934779319954],[313,235,1.0145761903940136],[314,236,1.0105251425307091],[315,236,.03514202628559325],[315,237,.9496082195647421],[316,237,.5498936784177629],[316,238,.4350619759070698],[317,238,1.014333917399279],[318,239,1.0103337978471305],[319,239,.03442615425358563],[319,240,.9505908507379167],[320,240,.5489421258861396],[320,241,.43626630163460317],[321,241,1.0141054593619083],[322,242,1.01015398680447],[323,242,.03375647247069698],[323,243,.9515115783174108],[324,243,.5480519201477565],[324,244,.43739353387882146],[325,244,1.0138908241879996],[326,245,1.0099855970782285],[327,245,.033131960048180864],[327,246,.9523715084281075],[328,246,.5472219699015581],[328,247,.438444863061944],[329,247,1.013690002769195],[330,248,1.009828512486449],[331,248,.0325516367573507],[331,249,.9531717178331495],[332,249,.5464512126887197],[332,250,.43942146136466664],[333,250,1.0135029698801676],[334,251,1.0096826133725936],[335,251,.03201456123217285],[335,252,.9539132549610332],[336,252,.5457386138858732],[336,253,.4403244829779182],[337,253,1.0133296850325435],[338,254,1.009547776957031],[339,254,.03151982926510845],[339,255,.9545971408911784],[340,255,.5450831657405287],[340,256,.44115506435778573],[341,256,1.0131700932920482],[342,257,1.0094238776594737],[343,257,.031066572189892106],[343,258,.9552243702967873],[344,258,.5444838864501296],[344,259,.44191432448690826],[345,259,1.013024126057376],[346,260,1.0093107873949636],[347,260,.030653955347715485],[347,261,.9557959123477745],[348,261,.5439398192781751],[348,262,.44260336514265247],[349,262,1.01289170180302],[350,263,1.0092083758457435],[351,263,.03028117663272106],[351,264,.956312711573757],[352,264,.5434500317097861],[352,265,.44322327116676213],[353,265,1.012772726788603],[354,266,1.0091165107105933],[355,266,.029947465111254432],[355,267,.9567756886915669],[356,267,.5430136146404813],[356,268,.443775110739594],[357,268,1.0126670957357586],[358,269,1.0090350579329337],[359,269,.02965207970869547],[359,270,.9571857414000476],[360,270,.5426296815994802],[360,271,.44425993565630856],[361,271,1.012574692474406],[362,272,1.0089638819102829],[363,272,.029394307963707546],[363,273,.9575437451393404],[364,273,.5422973680058967],[364,274,.4446787816043237],[365,274,1.0124953905592755],[366,275,1.0089028456858484],[367,275,.029173464843693937],[367,276,.9578505538209541],[368,276,.5420158304528419],[368,277,.44503266844280676],[369,277,1.0124290538587923],[370,278,1.0088518111235036],[371,278,.028988891617224174],[371,279,.9581070005279474],[372,279,.5417842460227992],[372,280,.4453226004830567],[373,280,1.012375537116488],[374,281,1.0088106390682976],[375,281,.028839954783933083],[375,282,.9583138981860433],[376,282,.5416018116287169],[376,283,.4455495667668758],[377,283,1.0123346864882432],[378,284,1.008779189492711],[379,284,.02872604505481853],[379,285,.9584720402070429],[380,285,.5414677433849261],[380,286,.44571454134485444],[381,286,1.0123063400541175],[382,287,1.008757321629678],[383,287,.028646576380597488],[383,288,.9585822011116006],[384,288,.5413812759956369],[384,289,.4458184835568685],[385,289,1.0122903283078832],[386,290,1.0087448940943453],[387,290,.028600985028178233],[387,291,.9586451371206854],[388,291,.541341662177547],[388,292,.44586233830592226],[389,292,1.0122864746237836],[390,293,1.0087417649949195],[391,293,.028588728701898054],[391,294,.9586615867284015],[392,294,.5413481720936798],[392,295,.44584703633543826],[393,295,1.0122945957030358],[394,296,1.0087477920325896],[395,296,.028609285702619672],[395,297,.958632271251788],[396,297,.5414000928186515],[396,298,.44577349450072723],[397,298,1.0123145019997328],[398,299,1.0087628325926643],[399,299,.028662154128659946],[399,300,.9585578953591529],[400,300,.5414967278190544],[400,301,.4456426160405528],[401,301,1.0123459981276965],[402,302,1.0087867438270437],[403,302,.028746851113718195],[403,303,.9584391475775814],[404,303,.5416373964555454],[404,304,.4454552908447334],[405,304,1.0123888832492127],[406,305,1.0088193827286074],[407,305,.02886291209986826],[407,306,.9582767007831089],[408,306,.541821433501071],[408,307,.44521239571891796],[409,307,1.0124429514472502],[410,308,1.0088606061980132],[411,308,.029009890142771087],[411,309,.9580712126699451],[412,309,.5420481886827784],[412,310,.4449147946460895],[413,310,1.01250799207953],[414,311,1.0089102711038211],[415,311,.029187355249536997],[415,312,.9578233262044412],[416,312,.5423170262339921],[416,313,.44456333904778883],[417,313,1.0125837901172945],[418,314,1.0089682343360202],[419,314,.02939489374516595],[419,315,.9575336700623188],[420,315,.5426273244683578],[420,316,.4441588680360723],[421,316,1.0126701264704934],[422,317,1.0090343528545804],[423,317,.029632107670909735],[423,318,.9572028590461733],[424,318,.5429784753662162],[424,319,.44370220866623333],[425,319,1.0127667782967882],[426,320,1.0091084837312583],[427,320,.02989861420426184],[427,321,.9568314944924141],[428,321,.5433698841780775],[428,322,.44319417618582607],[429,322,1.0128735192969558],[430,323,1.0091904841873789],[431,323,.03019404510848359],[431,324,.9564201646615609],[432,324,.5438009690392793],[432,325,.442635574278337],[433,325,1.0129901199984148],[434,326,1.0092802116265451],[435,326,.030518046204357472],[435,327,.9559694451142186],[436,327,.5442711606026257],[436,328,.4420271953022404],[437,328,1.013116348025554],[438,329,1.0093775236632159],[439,329,.030870276865616747],[439,330,.9554798990737882],[440,330,.5447799016825403],[440,331,.4413698205263152],[441,331,1.0132519683584005],[442,332,1.009482278147551],[443,332,.03125040953717358],[443,333,.9549520777754482],[444,333,.5453266469100869],[444,334,.4406642203630321],[445,334,1.0133967435791398],[446,335,1.009594333186143],[447,335,.031658129272365214],[447,336,.9543865208053518],[448,336,.5459108623998897],[448,337,.43991115459682073],[449,337,1.0135504341086077],[450,338,1.0097135471594447],[451,338,.03209313328990995],[451,339,.9537837564264052],[452,339,.5465320254328632],[452,340,.4391113726049666],[453,340,1.013712798432744],[454,341,1.009839778736762],[455,341,.03255513055252836],[455,342,.9531443018899375],[456,342,.5471896241467579],[456,343,.43826561357805704],[457,343,1.0138835933177033],[458,344,1.0099728868869051],[459,344,.033043841357819334],[459,345,.9524686637453139],[460,345,.5478831572348231],[460,346,.437374606734874],[461,346,1.0140625740178375],[462,347,1.0101127308880269],[463,347,.03355899695286791],[463,348,.9517573381261256],[464,348,.5486121336621822],[464,349,.436439071532636],[465,349,1.0142494944714182],[466,350,1.0102591703335964],[467,350,.03410033916008615],[467,351,.9510108110386514],[468,351,.5493760723833191],[468,352,.4354597178717026],[469,352,1.0144441074918717],[470,353,1.0104120651366326],[471,353,.03466762001996195],[471,354,.9502295586328896],[472,354,.5501745020753853],[472,355,.43443724629963687],[473,355,1.0146461649465606],[474,356,1.0105712755316636],[475,356,.035260601448092795],[475,357,.9494140474694148],[476,357,.5510069608761691],[476,358,.43337234820709825],[477,358,1.0148554179311553],[478,359,1.0107366620751033],[479,359,.035879054907258415],[479,360,.9485647347731454],[480,360,.5518729961339426],[480,361,.4322657060211073],[481,361,1.0150716169344107],[482,362,1.0109080856433987],[483,362,.036522761091017805],[483,363,.9476820686815849],[484,363,.5527721641646695],[484,364,.4311179933933358],[485,364,1.0152945119966836],[486,365,1.011085407429963],[487,365,.037191509621709105],[487,366,.9467664884832998],[488,366,.5537040300164661],[488,367,.42992987538427074],[489,367,1.0155238528614574],[490,368,1.0112684889404733],[491,368,.03788509876006132],[491,369,.945818424848663],[492,369,.5546681672409077],[492,370,.42870200864543534],[493,370,1.015759389119438],[494,371,1.0114571919861517],[495,371,.038603335123549486],[495,372,.9448383000574974],[496,372,.5556641576735553],[496,373,.42743504159139284],[497,373,1.016000870349307],[498,374,1.0116513786769457],[499,374,.03934603342038135],[499,375,.9438265282100843],[500,375,.556691591222498],[500,376,.42612961457530607],[501,376,1.0162480462474877],[502,377,1.011850911412824],[503,377,.0401130161915153],[503,378,.9427835154401112],[504,378,.5577500656591832],[504,379,.42478636005357434],[505,379,1.0165006667574357],[506,380,1.012055652873517],[507,380,.04090411356002747],[507,381,.9417096601187289],[508,381,.5588391864205529],[508,382,.4234059027505881],[509,382,1.016758482190165],[510,383,1.0122654660085202],[511,383,.04171916299559172],[511,384,.940605353048487],[512,384,.5599585664146272],[512,385,.4219888598177451],[513,385,1.0170212433404524],[514,386,1.0124802140252198],[515,386,.04255800908365318],[515,387,.9394709776545362],[516,387,.5611078258344457],[516,388,.42053584098827806],[517,388,1.0172887015980372],[518,389,1.0126997603766286],[519,389,.04342050330548295],[519,390,.9383069101697904],[520,390,.5622865919744513],[520,391,.4190474487280153],[521,391,1.0175606090547666],[522,392,1.0129239687479124],[523,392,.044306503823998804],[523,393,.9371135198133816],[524,393,.5634944990567509],[524,394,.41752427838399275],[525,394,1.017836718605313],[526,395,1.0131527030429122],[527,395,.04521587528078427],[527,396,.9358911689630978],[528,396,.5647311880602439],[528,397,.4159669183258934],[529,397,1.0181167840454461],[530,398,1.013385827369556],[531,398,.04614848859869256],[531,399,.9346402133241121],[532,399,.5659963065530312],[532,400,.41437595008823225],[533,400,1.0184005601646522],[534,401,1.0136232060250132],[535,401,.04710422079259773],[535,402,.9333610020906034],[536,402,.5672895085344858],[536,403,.41275194850334485],[537,403,1.0186878028359048],[538,404,1.0138647034793364],[539,404,.048082954782625906],[539,405,.9320538781067357],[540,405,.5686104542795039],[540,406,.4110954818363832],[541,406,1.0189782691001303],[542,407,1.0141101843606544],[543,407,.04908457922335384],[543,408,.9307191780153855],[544,408,.5699588101870642],[544,409,.40940711191046436],[545,409,1.0192717172488233],[546,410,1.0143595134378742],[547,410,.05010898832967291],[547,411,.9293572324099554],[548,411,.571334248633412],[548,412,.4076873942350095],[549,412,1.0195679069010588],[550,413,1.014612555604275],[551,413,.05115608171422347],[551,414,.9279683659767549],[552,414,.5727364478324755],[552,415,.4059368781231612],[553,415,1.0198665990790994],[554,416,1.0148691758602966],[555,416,.05222576422885553],[555,417,.9265528976348417],[556,417,.5741650916958022],[556,418,.40415610681371494],[557,418,1.0201675562784311],[558,419,1.0151292392959954],[559,419,.05331794581129548],[559,420,.9251111406735011],[560,420,.575619869698764],[560,421,.40234561758289383],[561,421,1.020470542537326],[562,422,1.0153926110734461],[563,422,.05443254133751677],[563,423,.9236434028815992],[564,423,.577100476753225],[564,424,.40050594185671334],[565,424,1.0207753235006762],[566,425,1.0156591564087798],[567,425,.05556947047932675],[567,426,.9221499866777003],[568,426,.5786066130792553],[568,427,.3986376053171075],[569,427,1.021081666483685],[570,428,1.0159287405542117],[571,428,.056728657567230105],[571,429,.9206311892316345],[572,429,.5801379840824749],[572,430,.3967411280111777],[573,430,1.0213893405291132],[574,431,1.016201228779567],[575,431,.057910031456259455],[575,432,.9190873025878152],[576,432,.5816943002369833],[576,433,.39481702444623007],[577,433,1.021698116466727],[578,434,1.0164764863538518],[579,434,.05911352539724152],[579,435,.9175186137811212],[580,435,.5832752769689779],[580,436,.3928658036922941],[581,436,1.0220077669657777],[582,437,1.0167543785266802],[583,437,.06033907691219022],[583,438,.9159254049505173],[584,438,.5848806345442068],[584,439,.3908879694785636],[585,439,1.022318066586335],[586,440,1.017034770509633],[587,440,.061586627674206584],[587,441,.914307953451257],[588,441,.58651009795775],[588,442,.3888840202832941],[589,442,1.0226287918300547],[590,443,1.017317527457434],[591,443,.06285612338957339],[591,444,.9126665319603182],[592,444,.5881633968320044],[592,445,.3868544494242516],[593,445,1.0229397211858324],[594,446,1.0176025144493452],[595,446,.06414751368695158],[595,447,.9110014085827639],[596,447,.5898402653081352],[596,448,.3847997451452973],[597,448,1.0232506351759092],[598,449,1.0178895964699735],[599,449,.06546075200505637],[599,450,.9093128469516464],[600,450,.5915404419502857],[600,451,.38272039070347513],[601,451,1.0235613163962847],[602,452,1.018178638390636],[603,452,.06679579548876291],[603,453,.9076011063291527],[604,453,.5932636696450677],[604,454,.3806168644453139],[605,454,1.0238715495601471],[606,455,1.0184695049504477],[607,455,.06815260488510425],[607,456,.9058664416991429],[608,456,.5950096955107654],[608,457,.37848963988927037],[609,457,1.024181121533852],[610,458,1.0187620607370533],[611,458,.06953114444294146],[611,459,.9041091038666588],[612,459,.5967782707982764],[612,460,.3763391858013562],[613,460,1.0244898213757605],[614,461,1.0190561701684775],[615,461,.07093138181829654],[615,462,.9023293395404434],[616,462,.5985691508103589],[616,463,.37416596626748977],[617,463,1.0247974403689852],[618,464,1.0193516974735164],[619,464,.07235328797779521],[619,465,.9005273914292568],[620,465,.6003820948062436],[620,466,.37197044076689306],[621,466,1.0251037720559506],[622,467,1.0196485066733956],[623,467,.07379683710904351],[623,468,.8987034983230944],[624,468,.6022168659211814],[624,469,.3697530642404009],[625,469,1.025408612268551],[626,470,1.01994646156273],[627,470,.07526200653052777],[627,471,.8968578951803935],[628,471,.6040732310832857],[628,472,.36751428715382667],[629,472,1.0257117591594511],[630,473,1.0202454256910738],[631,473,.07674877660715493],[631,474,.8949908132065928],[632,474,.6059509609308075],[632,475,.3652545555682938],[633,475,1.0260130132278693],[634,476,1.0205452623441595],[635,476,.07825713066499564],[635,477,.8931024799348216],[636,477,.6078498297369068],[636,478,.36297431119783957],[637,478,1.026312177347325],[638,479,1.0208458345252258],[639,479,.07978705490923481],[639,480,.8911931193041005],[640,480,.6097696153313106],[640,481,.360673991471839],[641,481,1.0266090567901067],[642,482,1.021147004936792],[643,482,.08133853834681559],[643,483,.8892629517341233],[644,483,.6117100990244927],[644,484,.3583540295921792],[645,484,1.0269034592511874],[646,485,1.0214486359623245],[647,485,.08291157270803175],[647,486,.8873121941972261],[648,486,.6136710655396947],[648,487,.35601485458732646],[649,487,1.0271951948700204],[650,488,1.0217505896477503],[651,488,.08450615237016054],[651,489,.885341060291742],[652,489,.6156523029400911],[652,490,.3536568913681695],[653,490,1.0274840762511013],[654,491,1.022052727683594],[655,491,.08612227428601159],[655,492,.8833497603088218],[656,492,.6176536025590085],[656,493,.3512805607832744],[657,493,1.02776991848203],[658,494,1.0223549113867765],[659,494,.08775993791161714],[659,495,.8813385013049766],[660,495,.6196747589336273],[660,496,.34888627966024516],[661,496,1.028052539155018],[662,497,1.0226570016825074],[663,497,.08941914513388247],[663,498,.8793074871648813],[664,498,.621715569739104],[664,499,.346474460866357],[665,499,1.0283317583791294],[666,500,1.0229588590871557],[667,500,.09109990020637701],[667,501,.8772569186645972],[668,501,.6237758357289777],[668,502,.34404551334349676],[669,502,1.0286073987990987],[670,503,1.023260343690056],[671,503,.09280220968027517],[671,504,.8751869935378795],[672,504,.6258553606671395],[672,505,.3415998421603758],[673,505,1.0288792856085094],[674,506,1.0235613151361742],[675,506,.09452608233896752],[675,507,.8730979065358732],[676,507,.6279539512706841],[676,508,.33913784855416224],[677,508,1.0291472465628844],[678,509,1.0238616326091752],[679,509,.09627152913686766],[679,510,.8709898494841083],[680,510,.6300714171530707],[680,511,.3366599299694516],[681,511,1.0294111119920568],[682,512,1.0241611548135297],[683,512,.09803856313307117],[683,513,.8688630113461538],[684,513,.6322075707612916],[684,514,.3341664801038121],[685,514,1.0296707148107829],[686,515,1.0244597399582411],[687,515,.09982719943517422],[687,516,.8667175782751595],[688,516,.6343622273238361],[688,517,.33165788894132453],[689,517,1.029925890529174],[690,518,1.024757245739534],[691,518,.10163745513498708],[691,519,.864553733672022],[692,519,.6365352047963319],[692,520,.32913454279236454],[693,520,1.0301764772610114],[694,521,1.0250535293244536],[695,521,.10346934925456013],[695,522,.8623716582378126],[696,522,.6387263238040831],[696,523,.32659682433041565],[697,523,1.0304223157317631],[698,524,1.0253484473338592],[699,524,.10532290268142636],[699,525,.8601715300305955],[700,525,.6409354075949926],[700,526,.32404511262442137],[701,526,1.0306632492858765],[702,527,1.0256418558269649],[703,527,.10719813812199533],[703,528,.8579535245094766],[704,528,.6431622819855923],[704,529,.3214797831731655],[705,529,1.0308991238920382],[706,530,1.0259336102845216],[707,530,.10909508003982304],[707,531,.855717814591042],[708,531,.6454067753119441],[708,532,.3189012079363341],[709,532,1.03112978814904],[710,533,1.0262235655929648],[711,533,.11101375459950885],[711,534,.8534645706974212],[712,534,.6476687183847731],[712,535,.31630975536452444],[713,535,1.0313550932895121],[714,536,1.0265115760290215],[715,536,.11295418962138112],[715,537,.8511939607995829],[716,537,.6499479444348513],[716,538,.3137057904341974],[717,538,1.0315748931821125],[718,539,1.0267974952437684],[719,539,.11491641452111552],[719,540,.8489061504692988],[720,540,.6522442890739327],[720,541,.3110896746693046],[721,541,1.0317890443354898],[722,542,1.027081176247435],[723,542,.11690046026072583],[723,543,.8466013029223681],[724,543,.6545575902471419],[724,544,.3084617661720711],[725,544,1.0319974058989068],[726,545,1.0273624713942857],[727,545,.11890635929917114],[727,546,.8442795790631381],[728,546,.6568876881880987],[728,547,.3058224196480645],[729,547,1.0321998396634169],[730,548,1.0276412323675237],[731,548,.12093414553884717],[731,549,.8419411375296247],[732,549,.6592344253774453],[732,550,.3031719864317822],[733,550,1.0323962100616533],[734,551,1.027917310164898],[735,551,.12298385427920393],[735,552,.8395861347312832],[736,552,.661597646501151],[736,553,.30051081451364153],[737,553,1.0325863841657408],[738,554,1.028190555083932],[739,554,.12505552216817234],[739,555,.8372147248951822],[740,555,.6639771984076539],[740,556,.2978392485576317],[741,556,1.0327702316879357],[742,557,1.0284608167076257],[743,557,.12714918714905468],[743,558,.8348270601054527],[744,558,.6663729300704698],[744,559,.2951576299293991],[745,559,1.0329476249762861],[746,560,1.0287279438905246],[747,560,.12926488841857217],[747,561,.8324232903405301],[748,561,.6687846925454237],[748,562,.2924662967182933],[749,562,1.0331184390116956],[750,563,1.0289917847447467],[751,563,.13140266637549056],[751,564,.8300035635173267],[752,564,.6712123389365675],[752,565,.28976558374944045],[753,565,1.033282551406384],[754,566,1.0292521866268258],[755,566,.13356256257828694],[755,567,.8275680255195722],[756,567,.6736557243576808],[756,568,.28705582261488644],[757,568,1.0334398423957492],[758,569,1.0295089961237516],[759,569,.1357446196959754],[759,570,.8251168202441111],[760,570,.6761147058925864],[760,571,.2843373416864493],[761,571,1.0335901948361186],[762,572,1.0297620590403478],[763,572,.13794888146102224],[763,573,.822650089632257],[764,573,.6785891425651428],[764,574,.2816104661359854],[765,574,1.0337334941973482],[766,575,1.0300112203862977],[767,575,.1401753926301894],[767,576,.8201679737037143],[768,576,.6810788952992894],[768,577,.278875517953921],[769,577,1.0338696285566522],[770,578,1.0302563243634062],[771,578,.14242419893016717],[771,579,.8176706105975015],[772,579,.6835838268889712],[772,580,.2761328159639002],[773,580,1.0339984885922306],[774,581,1.0304972143534852],[775,581,.14469534702456693],[775,582,.8151581365963325],[776,582,.6861038019600981],[776,583,.2733826758448351],[777,583,1.0341199675739228],[778,584,1.0307337329063364],[779,584,.14698888445850505],[779,585,.8126306861670012],[780,585,.6886386869453004],[780,586,.2706254101402667],[781,586,1.0342339613562985],[782,587,1.0309657217274584],[783,587,.14930485962229872],[783,588,.810088391991206],[784,588,.6911883500416512],[784,589,.267861328280309],[785,589,1.0343403683692496],[786,590,1.0311930216672842],[787,590,.1516433217043255],[787,591,.80753138499415],[788,591,.6937526611907388],[788,592,.2650907365900638],[789,592,1.0344390896084676],[790,593,1.0314154727094134],[791,593,.1540043206504027],[791,594,.8049597943767033],[792,594,.6963314920402311],[792,595,.2623139383094437],[793,595,1.034530028625162],[794,596,1.0316329139598897],[795,596,.1563879071152346],[795,597,.8023737476471726],[796,597,.6989247159176777],[796,598,.25953123360660696],[797,598,1.0346130915153564],[798,599,1.0318451836365417],[799,599,.15879413242528773],[799,600,.799773370648628],[800,600,.7015322078013413],[800,601,.256742919587031],[801,601,1.0346881869094755],[802,602,1.0320521190584917],[803,602,.16122304853347555],[803,603,.7971587875884961],[804,603,.7041538442893039],[804,604,.2539492903120581],[805,604,1.0347552259598483],[806,605,1.032253556636297],[807,605,.16367470797552194],[807,606,.7945301210672343],[808,606,.7067895035746306],[808,607,.2511506368077842],[809,607,1.0348141223290412],[810,608,1.0324493318619021],[811,608,.16614916382632547],[811,609,.7918874921076472],[812,609,.709439065413448],[812,610,.24834724708249672],[813,610,1.0348647921767888],[814,611,1.032639279299876],[815,611,.1686464696616927],[815,612,.7892310201754584],[816,612,.7121024111062217],[816,613,.24553940613187852],[817,613,1.0349071541468273],[818,614,1.0328232325774014],[819,614,.17116667951302045],[819,615,.7865608232133336],[820,615,.7147794234616441],[820,616,.24272739595679857],[821,616,1.0349411293537],[822,617,1.0330010243763053],[823,617,.17370984782335191],[823,618,.7838770176637189],[824,618,.7174699867799718],[824,619,.23991149556876706],[825,619,1.0349666413686411],[826,620,1.033172486424039],[827,620,.17627602940857415],[827,621,.7811797184924586],[828,621,.720173986819918],[828,622,.23709198101021747],[829,622,1.0349836162040225],[830,623,1.0333374494861536],[831,623,.1788652794118951],[831,624,.7784690392157592],[832,624,.7228913107823544],[832,625,.234269125354749],[833,625,1.0349919822996723],[834,626,1.0334957433581187],[835,626,.18147765326305537],[835,627,.7757450919251534],[836,627,.7256218472813651],[836,628,.23144319872166874],[837,628,1.0349916705072433],[838,629,1.033647196858036],[839,629,.1841132066386375],[839,630,.773007987305413],[840,630,.7283654863202004],[840,631,.22861446829229304],[841,631,1.0349826140730403],[842,632,1.033791637819688],[843,632,.1867719954109858],[843,633,.7702578346682248],[844,633,.7311221192693971],[844,634,.2257831983137577],[845,634,1.0349647486235953],[846,635,1.0339288930859631],[847,635,.18945407561392777],[847,636,.7674947419659374],[848,636,.7338916388459672],[848,637,.22294965011006523],[849,637,1.0349380121480094],[850,638,1.0342420464149167],[851,638,.1924281237940313],[851,639,.5378425839134362],[852,639,.5202524171708031],[852,640,.4568109772775498],[852,641,.05199677850209752],[853,640,.24351254102567055],[853,641,.5225687624093359],[853,642,.2921493228893563],[854,642,.25538328243481595],[854,643,.5241438210153896],[854,644,.23257172527298814],[855,643,.011987787701546808],[855,644,.3172219958151092],[855,645,.4868674616302827],[855,646,.176468024136203],[856,645,.07357769424953754],[856,646,.38294232266815553],[856,647,.4259205416014665],[856,648,.11753224171517974],[857,647,.13246196705929972],[857,648,.4398303708699065],[857,649,.36708371923835004],[857,650,.06067586883292038],[858,649,.18926719214302565],[858,650,.4946697651421086],[858,651,.3040061179704405],[858,652,.005602736230038195],[859,651,.23906249586178907],[859,652,.5231149368578739],[859,653,.2495840468006932],[860,653,.2897970473112013],[860,654,.5026442283960142],[860,655,.20274559579570214],[861,654,.04664315619110009],[861,655,.3473240465998149],[861,656,.4526192727121032],[861,657,.1523595035438806],[862,656,.09766699822939251],[862,657,.3969699779916487],[862,658,.40188113292822186],[862,659,.1034820659161816],[863,658,.14649823031506354],[863,659,.44395391725661004],[863,660,.3530826952522148],[863,661,.056517279244449437],[864,660,.193417537810633],[864,661,.48905272813711814],[864,662,.30196784607077015],[864,663,.011088189502860925],[865,662,.235165441654809],[865,663,.5161755064939912],[865,664,.25593745749264785],[866,664,.27598857145168865],[866,665,.5055165820237347],[866,666,.21733399798014585],[867,665,.03142691535889764],[867,666,.321995701601107],[867,667,.4677769922252197],[867,668,.17692400337387545],[868,667,.07312870986769164],[868,668,.3630952451007391],[868,669,.4264378437134144],[868,670,.13731285791147696],[869,669,.11270032695167025],[869,670,.4009509624326517],[869,671,.38688927555227676],[869,672,.09946833663506985],[870,671,.15050630725355646],[870,672,.43706477714430675],[870,673,.34910378546507886],[870,674,.06336347754327785],[871,673,.1865736616624162],[871,674,.4714631653468664],[871,675,.3125696686315781],[871,676,.028869775846049314],[872,675,.22058655357283705],[872,676,.502393455771382],[872,677,.27458473006488804],[873,677,.24983886475629993],[873,678,.5137748593109537],[873,679,.24315322539257223],[874,678,.0036240101488931717],[874,679,.2812413419420975],[874,680,.49584386088869215],[874,681,.2153614227018543],[875,680,.034735500335029305],[875,681,.3144060917430617],[875,682,.46485314373790926],[875,683,.18595981453922283],[876,682,.0641063484572785],[876,683,.34219859962945964],[876,684,.43549740951782173],[876,685,.15817234633893226],[877,684,.091864261548934],[877,685,.3683988258245694],[877,686,.407752916631107],[877,687,.13197572785525458],[878,686,.11803256264694018],[878,687,.3930296465168421],[878,688,.3815964769154389],[878,689,.10734720976073055],[879,688,.1426340315995158],[879,689,.4161134070872291],[879,690,.35700543857338174],[879,691,.08426456699687354],[880,690,.16569092182506315],[880,691,.43767193845249674],[880,692,.33395766972405766],[880,693,.06270608273067858],[881,692,.1872249764612122],[881,693,.457726572814142],[881,694,.3124315425508366],[881,695,.04265053289025597],[882,694,.20725744392861123],[882,695,.47629815883858434],[882,696,.29240591801936916],[882,697,.024077171256560802],[883,696,.22580909293436022],[883,697,.49340707629100294],[883,698,.272739666255128],[883,699,.006906252371233933],[884,698,.24190643067177103],[884,699,.5047275543873398],[884,700,.2549459812508028],[885,700,.2567100539467806],[885,701,.5031577036963546],[885,702,.24065881914660317],[886,701,.008634717813202674],[886,702,.27224949572145724],[886,703,.49094674236787206],[886,704,.22719544196570912],[887,703,.02292373131969297],[887,704,.28597629401801355],[887,705,.47672398599653515],[887,706,.2143533208320832],[888,705,.035751602096786475],[888,706,.29743237559552355],[888,707,.46390276826706217],[888,708,.20289630196958544],[889,707,.04719579903029385],[889,708,.3075210742305127],[889,709,.45246460115847775],[889,710,.19280622955805915],[890,709,.057274491299496445],[890,710,.3162602301176305],[890,711,.4423913913890736],[890,712,.18406533389761395],[891,711,.0660054606502899],[891,712,.3236673045470217],[891,713,.43366542899845073],[891,714,.17665622026124392],[892,713,.07340611260620647],[892,714,.3297593908476435],[892,715,.4262693763198494],[892,716,.17056185812791913],[893,715,.07949348729590157],[893,716,.33455322495703466],[893,717,.42018625732795906],[893,718,.16576557078065143],[894,717,.0842842699121286],[894,718,.3380651956328206],[894,719,.41539944734620887],[894,720,.16225102525634236],[895,719,.0877948008176482],[895,720,.3403113543186734],[895,721,.41189266310148215],[895,722,.1600022226324315],[896,721,.09004108530992379],[896,722,.3413074246800344],[896,723,.4096499531105413],[896,724,.15900348863810745],[897,723,.0910388030604564],[897,724,.341068811820455],[897,725,.4086556883871424],[897,726,.15923946457791555],[898,725,.09080331723824445],[898,726,.33961061119156805],[898,727,.40889455345709996],[898,728,.16069509855546693],[899,727,.08934968333179105],[899,728,.33694761720865024],[899,729,.41035153766953336],[899,730,.1633556369851302],[900,729,.08669265767999552],[900,730,.33309433158306806],[900,731,.41301192679237225],[900,732,.16720661638248935],[901,731,.08284670572359325],[901,732,.32806497138102175],[901,733,.41686129488304347],[901,734,.17223385542154263],[902,733,.0778260099865808],[902,734,.3218734768206457],[902,735,.421885496422382],[902,736,.17842344724960524],[903,735,.07164447779930824],[903,736,.31453351881588426],[903,737,.42807065870301164],[903,738,.185761752049803],[904,737,.06431574877136567],[904,738,.3060585062772846],[904,739,.435403174462235],[904,740,.19423538984244326],[905,739,.05585320202451507],[905,740,.29646159317816856],[905,741,.4438696947508069],[905,742,.20383123351642937],[906,741,.04626996319383157],[906,742,.2857556853951481],[906,743,.4534571220289279],[906,744,.21453640208174513],[907,743,.03557891120608933],[907,744,.27395344733160587],[907,745,.4640838862781736],[907,746,.2259711147745072],[908,745,.02378916236694485],[908,746,.26064383557298154],[908,747,.4744097020055178],[908,748,.23741469023048611],[908,749,.0029874664482454345],[909,747,.010888485342882084],[909,748,.24524012825579347],[909,749,.47705262348683797],[909,750,.25146343127990345],[909,751,.018030374036361534],[910,750,.23051594568994063],[910,751,.4659638155007443],[910,752,.26789265476733026],[910,753,.034103962104678205],[911,752,.2157780537828917],[911,753,.4490488012027463],[911,754,.28394240197843773],[911,755,.051207169174446954],[912,754,.19869680451466967],[912,755,.4309201309554197],[912,756,.3010279740476113],[912,757,.06933596927309439],[913,756,.18059146729117878],[913,757,.4117775174928008],[913,758,.3191380672559441],[913,759,.08847923890660256],[914,758,.16147315955443303],[914,759,.3916318997027402],[914,760,.33826157637971177],[914,761,.10862604895508292],[915,760,.14135280401108383],[915,761,.37049402581791996],[915,762,.35838758963377015],[915,763,.12976565972904766],[916,762,.12024113359574008],[916,763,.34837445826725],[916,764,.3795053837685538],[916,765,.15188751617588445],[917,764,.0981486962833266],[917,765,.32528357838026745],[917,766,.40160441931520835],[917,767,.17498124323033803],[918,766,.07508585975635881],[918,767,.30123159095005636],[918,768,.42467433597326765],[918,769,.19903664130457108],[919,768,.05106281593203439],[919,769,.2762285286588279],[919,770,.4480441892579001],[919,771,.22091817857346802],[920,770,.02605116606412028],[920,771,.24679268601046497],[920,772,.4613333588465915],[920,773,.24636316696152993],[920,774,.026661594315488448],[921,772,.00017143112777602207],[921,773,.22016507993495968],[921,774,.4450006731455823],[921,775,.27654268563105877],[921,776,.05450703342817279],[922,775,.19537707282293476],[922,776,.4169980825615683],[922,777,.3043455873211709],[922,778,.08322496813649063],[923,777,.16671893224886847],[923,778,.3873911007134449],[923,779,.333032487802997],[923,780,.11284587069811512],[924,779,.1371380798307044],[924,780,.3568813039463011],[924,781,.36262258254682433],[924,782,.14336176762117853],[925,781,.10666365535341012],[925,782,.32548606626333626],[925,783,.39310680323983005],[925,784,.17476372572452537],[926,783,.07530458232966944],[926,784,.2932141772790525],[926,785,.4235343782302751],[926,786,.20429957725699868],[927,785,.04297407877416276],[927,786,.2566282342451322],[927,787,.44609730979381396],[927,788,.23600300007995265],[927,789,.023774697332874434],[928,787,.00973561058609779],[928,788,.22213324067090034],[928,789,.4366882593279592],[928,790,.27231575108916795],[928,791,.058813271383982776],[929,790,.1899112794795718],[929,791,.4051174305988943],[929,792,.3087329260703045],[929,793,.09459113946159277],[930,792,.15536737862587172],[930,793,.36909687837539557],[930,794,.3443998634306182],[930,795,.13113054742980831],[931,794,.11887833690004168],[931,795,.3317399346424034],[931,796,.3809015150071346],[931,797,.1684974582828263],[932,796,.08156315084174257],[932,797,.29356399783457987],[932,798,.4168389957384664],[932,799,.2027189344423823],[933,798,.043285265762028874],[933,799,.2496929999720567],[933,800,.44089395742648096],[933,801,.24052352812737388],[933,802,.03507425254057242],[934,800,.0043335535351657515],[934,801,.21027601904641954],[934,802,.42143856683278325],[934,803,.2844016743443022],[934,804,.07585590645285804],[935,803,.17353832434253885],[935,804,.38262846297038483],[935,805,.3257498632562316],[935,806,.11730189433403454],[936,805,.13268775789077444],[936,806,.3407519309130924],[936,807,.3670972990020704],[936,808,.15947396875496164],[937,807,.09057464650490143],[937,808,.2978183751219168],[937,809,.40749895190525254],[937,810,.19795010289674397],[938,809,.0474866463063797],[938,810,.24850494279526708],[938,811,.4346436181876547],[938,812,.2403211224239381],[938,813,.04014881320170647],[939,811,.003878639500178961],[939,812,.2047038150773143],[939,813,.41157455841171137],[939,814,.28957529821809164],[939,815,.08560320920592149],[940,814,.16385621221760913],[940,815,.36828320787286745],[940,816,.33550406688664397],[940,817,.13164677712134118],[941,816,.11836297424309958],[941,817,.32185871977911545],[941,818,.3799973298161782],[941,819,.17581896778117206],[942,818,.07143918326167292],[942,819,.2705029465809176],[942,820,.4180894904987747],[942,821,.22040151023922497],[942,822,.023261093492508676],[943,820,.023754358875460287],[943,821,.22082957274806367],[943,822,.41735892037093947],[943,823,.26975946681527463],[943,824,.07244459405934162],[944,823,.17462856886910824],[944,824,.376380003235797],[944,825,.32258384746152186],[944,826,.12234695850241085],[945,825,.12764964491952732],[945,826,.32754202842781277],[945,827,.3705351976091778],[945,828,.17002290467196218],[946,827,.07705703864783364],[946,828,.27228373423426855],[946,829,.4119493110954956],[946,830,.21796235075295245],[946,831,.024608216085607083],[947,829,.025780053026113373],[947,830,.2190518649272109],[947,831,.41169318411556594],[947,832,.27077590916361477],[947,833,.07732052594065236],[948,832,.1695115580680664],[948,833,.36773423672329814],[948,834,.3275311475162098],[948,835,.13077893984001213],[949,834,.11922966876699366],[949,835,.31565346594837984],[949,836,.37813100062036553],[949,837,.17991281790206778],[950,836,.06510103041600655],[950,837,.25463712967072577],[950,838,.4162975451493948],[950,839,.23222690463246418],[950,840,.043347365043106205],[951,838,.010682336294089382],[951,839,.20025854636251755],[951,840,.3947874901107556],[951,841,.2917173663646273],[951,842,.09950708368621437],[952,841,.14911244770443477],[952,842,.3431424199239878],[952,843,.3480530442639449],[952,844,.15411315971947762],[953,843,.0934299055238343],[953,844,.2830893937829872],[953,845,.3971235804951196],[953,846,.20716078374370134],[953,847,.020137203526012115],[954,845,.036025540013401365],[954,846,.22261124110739972],[954,847,.40630997808531094],[954,848,.2648205963423913],[954,849,.07872881878459281],[955,848,.16692727676480973],[955,849,.35954874836594064],[955,850,.328443108696204],[955,851,.13751082396144756],[956,850,.11152248261980105],[956,851,.3006327942159715],[956,852,.3829521945790107],[956,853,.1916328343080391],[956,854,.0076262937092498664],[957,852,.0514953905500914],[957,853,.2343500090068106],[957,854,.41021535649217705],[957,855,.25030428726128284],[957,856,.06835964516566889],[958,855,.17563114080501685],[958,856,.3667504924135684],[958,857,.31835263030310357],[958,858,.1299663000321827],[959,857,.11940718803292909],[959,858,.3065438045294419],[959,859,.37569491987401304],[959,860,.18605528589059708],[959,861,.004834820768368334],[960,859,.05684866493974193],[960,860,.2366688077210537],[960,861,.4085057240274029],[960,862,.24678375999468344],[960,863,.06783571840441664],[961,862,.17558642045742334],[961,863,.36451985113857055],[961,864,.3173137388508224],[961,865,.13129392160626782],[962,864,.11725721455632943],[962,865,.3008194332920608],[962,866,.37580301677160466],[962,867,.19024874552861262],[962,868,.011245575393110812],[963,866,.05231298976932004],[963,867,.23017401181136463],[963,868,.40175554736854613],[963,869,.2536595659979476],[963,870,.07679940668774121],[964,869,.16706057585212106],[964,870,.35303258747063304],[964,871,.3251768586309606],[964,872,.14116418004635392],[965,871,.10550294433561781],[965,872,.28424844668945237],[965,873,.38249269088982873],[965,874,.2036626805762719],[965,875,.02684871916582402],[966,873,.03836058116912999],[966,874,.21480488879977247],[966,875,.389260042863657],[966,876,.27095452974310497],[966,877,.09504101254228686],[967,876,.1502807743955375],[967,877,.3328577086192332],[967,878,.3421239629983485],[967,879,.15918522100542254],[968,878,.08474515454977341],[968,879,.25820758590913884],[968,880,.3938397310124852],[968,881,.22523159171338067],[968,882,.05190695217080459],[969,880,.015820211753405387],[969,881,.19007905592596833],[969,882,.36921246833932636],[969,883,.2980889913883655],[969,884,.12132017371569158],[970,883,.1247775639085626],[970,884,.3015570552958629],[970,885,.36552163552482225],[970,886,.18684713857492927],[970,887,.014284415706242481],[971,885,.055013622481818666],[971,886,.2263705108609403],[971,887,.39186593267986564],[971,888,.2561333080985603],[971,889,.08592049273991473],[972,888,.1575841200944441],[972,889,.3370827060887002],[972,890,.33284859953655166],[972,891,.15390042438231766],[973,890,.08972988049108406],[973,891,.2590326783958039],[973,892,.38812639016604245],[973,893,.22348813860080616],[973,894,.054161074977768404],[974,892,.017081968749935856],[974,893,.18740927170107446],[974,894,.3625874079443392],[974,895,.2990263270079478],[974,896,.12613079428882987],[975,895,.11819045745461297],[975,896,.28905735771716573],[975,897,.36789499357104777],[975,898,.19628130377264577],[975,899,.02735424128922767],[976,897,.04494375361325131],[976,898,.21330043570426716],[976,899,.37902147922066165],[976,900,.2697531768133337],[976,901,.10241904377888808],[977,900,.14130067843136315],[977,901,.3150246804904708],[977,902,.3480110183643501],[977,903,.1725701388645175],[977,904,.005966983373903607],[978,902,.06884101502859519],[978,903,.23351128359258333],[978,904,.3898863909020141],[978,905,.24593198700119934],[978,906,.08224765045066],[979,905,.1597942440306211],[979,906,.3346851109670727],[979,907,.3285973743088808],[979,908,.15444027476874822],[980,907,.08792661347585409],[980,908,.2508895640647832],[980,909,.38533070676895603],[980,910,.22893712756876922],[980,911,.06583953763953361],[981,909,.01060737785460527],[981,910,.17530908392596897],[981,911,.34707093920704996],[981,912,.3101853041457825],[981,913,.1404924603408273],[982,912,.1016482122325276],[982,913,.2640331008343238],[982,914,.3757885914855772],[982,915,.21658719088481612],[982,916,.05379076081392352],[983,914,.023321537452804155],[983,915,.1869789080592518],[983,916,.35433193126746176],[983,917,.2960976478285003],[983,918,.13047091456929613],[984,917,.11086010315035294],[984,918,.272590889791831],[984,919,.3683410258652817],[984,920,.20801518542415245],[984,921,.04616290894518408],[985,919,.03202626907959427],[985,920,.1942489952348069],[985,921,.35801621736570555],[985,922,.2871844809716754],[985,923,.12448425960359358],[986,922,.11614980664040801],[986,923,.2769245860037902],[986,924,.3634503371272694],[986,925,.20337777894188264],[986,926,.04278533591281287],[987,924,.036633170664026604],[987,925,.19735437260885233],[987,926,.3585975660673821],[987,927,.28298312203941667],[987,928,.12237172260813765],[988,927,.11761764880185657],[988,928,.2769347836061358],[988,929,.3613222869658947],[988,930,.20269252495682932],[988,931,.04352084243134597],[989,929,.03715658569409518],[989,930,.19646584076452728],[989,931,.3563193376763676],[989,932,.28325914825402143],[989,933,.12401877287718965],[990,932,.11535841088563661],[990,933,.2726772185957825],[990,934,.36193002492598775],[990,935,.2058724789923987],[990,936,.04828585408934835],[991,934,.03368059076582972],[991,935,.19166681871807822],[991,936,.35120102320155516],[991,937,.2879669101334489],[991,938,.12934311950798513],[992,937,.10947528483272252],[992,938,.2643619456949593],[992,939,.36503164238003943],[992,940,.21273290367631378],[992,941,.05704255868679827],[993,939,.026351338857843194],[993,940,.18296002570453515],[993,941,.3430562989307297],[993,942,.29724916938947604],[993,943,.13830626997954892],[994,942,.10006782116457263],[994,943,.2523219642979947],[994,944,.3701807952606593],[994,945,.22297333198451888],[994,946,.06976592160365215],[995,944,.015392306252147629],[995,945,.17030051412165803],[995,946,.33152253946088156],[995,947,.31147369956054877],[995,948,.1509473916728322],[996,947,.087196881644584],[996,948,.2369586950063475],[996,949,.376718339613223],[996,950,.2345765114615184],[996,951,.08521591343298078],[997,949,.0011357385555340561],[997,950,.15263475001807864],[997,951,.311827742306229],[997,952,.32860504822914505],[997,953,.16942021655341175],[997,954,.016626147439510436],[998,952,.07024774813594223],[998,953,.2212622403680772],[998,954,.36621398307130515],[998,955,.2523140266095425],[998,956,.10329850546808812],[999,955,.13345393361930616],[999,956,.2868146645965228],[999,957,.3438149621043634],[999,958,.19052159754051476],[999,959,.038598535306774456],[1e3,957,.04874340776161587],[1e3,958,.20027433884645776],[1e3,959,.35045072214288214],[1e3,960,.2752172040116266],[1e3,961,.1246081801436533],[1001,960,.11153410463061227],[1001,961,.25968030157128735],[1001,962,.3589611456155988],[1001,963,.21376355164890676],[1001,964,.06462574300561937],[1002,962,.024112239164856285],[1002,963,.1744379670887302],[1002,964,.32884307142135794],[1002,965,.3038963549633426],[1002,966,.14989396525089382],[1002,967,.002787631885767016],[1003,965,.08652179776851913],[1003,966,.23158274748299973],[1003,967,.37014802862444746],[1003,968,.23660182809114255],[1003,969,.09233857620429504],[1004,968,.14320871996140178],[1004,969,.2949268298641504],[1004,970,.33370967770704096],[1004,971,.1821563205430922],[1004,972,.03341416685633306],[1005,970,.05691996613850173],[1005,971,.2048164607341282],[1005,972,.34996958396767003],[1005,973,.26846185022737096],[1005,974,.12203613352843197],[1006,973,.11270360292617912],[1006,974,.2573174820670815],[1006,975,.35551075517876596],[1006,976,.21342439841857963],[1006,977,.06808655521031844],[1007,975,.02300584415020569],[1007,976,.1693741701851818],[1007,977,.31909197071849676],[1007,978,.3064750144925845],[1007,979,.1569666027177789],[1007,980,.01237576860780718],[1008,978,.07918600624195261],[1008,979,.22224585329482],[1008,980,.36060022658704466],[1008,981,.24542280629144228],[1008,982,.10372340547250797],[1009,981,.13025049048804305],[1009,982,.2755544084078468],[1009,983,.34173289952302016],[1009,984,.19757209548510224],[1009,985,.052414383405106256],[1010,983,.04055057399599624],[1010,984,.18602861646793578],[1010,985,.3325126760154172],[1010,986,.28836807114447566],[1010,987,.1417402962688462],[1010,988,.0007268068329768394],[1011,986,.0921230324039655],[1011,987,.23132424535108578],[1011,988,.3651955312519228],[1011,989,.23251096307120944],[1011,990,.09383068210249161],[1012,989,.1395300348660987],[1012,990,.2846106560560243],[1012,991,.33325384799782276],[1012,992,.18901293891606955],[1012,993,.045352651706964286],[1013,991,.0492531143811913],[1013,992,.19272260635298227],[1013,993,.33561458168523745],[1013,994,.27986377343343843],[1013,995,.13637852619084528],[1014,994,.09650852938196901],[1014,995,.2338020594070448],[1014,996,.36193613166585775],[1014,997,.22898317334607854],[1014,998,.09193468643195023],[1015,996,.002457496874436509],[1015,997,.14093777570167637],[1015,998,.28368384860268375],[1015,999,.33027760738271117],[1015,1e3,.1884400273628213],[1015,1001,.046968846655108074],[1016,999,.04899295849310335],[1016,1e3,.19034003312195327],[1016,1001,.3313219755276299],[1016,1002,.28105052006571385],[1016,1003,.13948843868730657],[1016,1004,.0023949943264103815],[1017,1002,.09296476581718328],[1017,1003,.22852898102309294],[1017,1004,.35981389159869226],[1017,1005,.23289594529521537],[1017,1006,.09793041579114306],[1018,1005,.13381394889325862],[1018,1006,.27358691892030107],[1018,1007,.33460745416509985],[1018,1008,.1955825556102765],[1018,1009,.05665143264068217],[1019,1007,.040361378819567154],[1019,1008,.17925977203170015],[1019,1009,.31806447498945245],[1019,1010,.2909077306146313],[1019,1011,.1516962543781077],[1019,1012,.01525050343287846],[1020,1010,.08150854362929537],[1020,1011,.21698349128246774],[1020,1012,.3497669475500838],[1020,1013,.24583808157633427],[1020,1014,.11136370502634059],[1021,1013,.1194990282921764],[1021,1014,.25479878825131264],[1021,1015,.34346022054644576],[1021,1016,.20933239464254857],[1021,1017,.07400664151417581],[1022,1015,.023670383811016393],[1022,1016,.1594303860158249],[1022,1017,.29640289279632487],[1022,1018,.3088876485347881],[1022,1019,.17249814489158258],[1022,1020,.03643709112995095],[1023,1018,.062217701784737935],[1023,1019,.19815982330648652],[1023,1020,.3337745723213922],[1023,1021,.3700921432339217],[1023,1022,.3700921432339217]]},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.boxUpscale=e.initialPad=e.pixelNorm=void 0;var s=n(36),a=function(t){function e(e,n){void 0===e&&(e=1e-8),void 0===n&&(n={});var r=t.call(this,n)||this;return r.epsilon=e,r.layerConfig=n,r.supportsMasking=!0,r}return i(e,t),e.prototype.computeOutputShape=function(t){return[t[0],t[1],t[2],t[3]]},e.prototype.call=function(t){var e=this;return s.tidy((function(){var n=t;Array.isArray(n)&&(n=n[0]);var r=s.mean(s.square(n),[3],!0);return s.mul(n,s.rsqrt(s.add(r,e.epsilon)))}))},e.prototype.getClassName=function(){return"PixelNorm"},e}(s.layers.Layer);e.pixelNorm=function(t,e){return void 0===t&&(t=1e-8),void 0===e&&(e={}),new a(t,e)};var o=function(t){function e(e,n,r){void 0===e&&(e=2),void 0===n&&(n=16),void 0===r&&(r={});var i=t.call(this,r)||this;return i.kernelH=e,i.kernelW=n,i.layerConfig=r,i.supportsMasking=!0,i}return i(e,t),e.prototype.computeOutputShape=function(t){return[t[0],2*(this.kernelH-1)+t[1],2*(this.kernelW-1)+t[2],t[3]]},e.prototype.call=function(t){var e=t;Array.isArray(e)&&(e=e[0]);var n=this.kernelH-1,r=this.kernelW-1;return s.pad(e,[[0,0],[n,n],[r,r],[0,0]])},e.prototype.getClassName=function(){return"InitialPad"},e}(s.layers.Layer);e.initialPad=function(t,e,n){return void 0===t&&(t=2),void 0===e&&(e=16),void 0===n&&(n={}),new o(t,e,n)};var u=function(t){function e(e){void 0===e&&(e=2);var n=t.call(this,{})||this;return n.scale=e,n.supportsMasking=!0,n}return i(e,t),e.prototype.computeOutputShape=function(t){return[t[0],this.scale*t[1],this.scale*t[2],t[3]]},e.prototype.call=function(t){var e=this;return s.tidy((function(){var n=t;Array.isArray(n)&&(n=n[0]);var r=s.tile(n,[Math.pow(e.scale,2),1,1,1]);return s.batchToSpaceND(r,[e.scale,e.scale],[[0,0],[0,0]])}))},e.prototype.getClassName=function(){return"BoxUpscale"},e}(s.layers.Layer);e.boxUpscale=function(t){return void 0===t&&(t=2),new u(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(396);Object.defineProperty(e,"SPICE",{enumerable:!0,get:function(){return r.SPICE}})},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.SPICE=void 0;var s=n(146),a=function(){function t(t){this.modelUrl=t||"https://tfhub.dev/google/tfjs-model/spice/2/default/1"}return t.prototype.initialize=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t=this,[4,s.startSpice(this.modelUrl)];case 1:return t.spiceModel=e.sent(),this.initialized=!0,[2]}}))}))},t.prototype.getAudioFeatures=function(t,e){return r(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,s.getAudioFeatures(t,this.spiceModel,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.dispose=function(){this.initialized&&(this.spiceModel.dispose(),this.initialized=!1)},t.prototype.isInitialized=function(){return this.initialized},t}();e.SPICE=a},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.computePower=void 0;var s=n(36),a=n(146);e.computePower=function(t){return r(this,void 0,void 0,(function(){var e,n,r,o,u,c,l,h,d;return i(this,(function(i){switch(i.label){case 0:return 1024,20.7,120,e=Math.floor(a.MODEL_SAMPLE_RATE/a.MODEL_FRAME_RATE),n=s.tensor1d(t,"float32"),r=t.length,null===n?[2,[]]:(o=n.mul(n).reshape([r,1]),u=s.conv1d(o,s.ones([1024,1,1]).div(1024),e,"same").sqrt().squeeze(),1e-20,c=s.mul(s.log(s.maximum(1e-20,u)).div(s.log(10)),20),l=c.sub(20.7),[4,(h=s.maximum(l,-120)).array()]);case 1:return d=i.sent(),n.dispose(),o.dispose(),u.dispose(),c.dispose(),l.dispose(),h.dispose(),[2,d]}}))}))}},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(399),e)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(400);Object.defineProperty(e,"DDSP",{enumerable:!0,get:function(){return r.DDSP}})},function(t,e,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.DDSP=void 0,n(205);var a=n(36),o=n(120),u=n(111),c=n(217),l=n(146),h=n(401),d=n(402),p=n(269),f=n(270),m=n(403),g=function(){function t(t,e){this.checkpointUrl=t,e&&(this.settings=e)}return t.prototype.initialize=function(){return i(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return a.registerOp("Roll",(function(t){var e=a.split(t.inputs[0],2,2),n=a.concat([e[1],e[0]],2);return e.forEach((function(t){return t.dispose()})),n})),a.env().set("WEBGL_PACK",!1),a.env().set("WEBGL_CONV_IM2COL",!1),a.env().set("WEBGL_DELETE_TEXTURE_THRESHOLD",104857600),t=this,[4,m.getModel(this.checkpointUrl+"/model.json")];case 1:t.model=n.sent(),n.label=2;case 2:return n.trys.push([2,,4,5]),[4,fetch(this.checkpointUrl+"/settings.json").then((function(t){return t.json()}))];case 3:return e=n.sent(),[3,5];case 4:if(null===this.settings)throw new Error("Passing settings is required if you do not have a settings.json file.");return[7];case 5:return this.settings=r(r({},e),this.settings),this.initialized=!0,[2]}}))}))},t.prototype.dispose=function(){this.initialized&&(this.model.dispose(),this.checkpointUrl=null,this.initialized=!1)},t.prototype.isInitialized=function(){return this.initialized},t.prototype.memCheck=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,m.memCheck()];case 1:return[2,t.sent()]}}))}))},t.prototype.synthesize=function(t,e){return i(this,void 0,void 0,(function(){var n,i,g,b,y,v,w,x,_,O,S,k,T,C,A,N,I,E,j,M,D,R,P,F,z,L,$,B,q,V,U=this;return s(this,(function(s){switch(s.label){case 0:return null!==e&&(this.settings=r(r({},this.settings),e)),n=t.f0_hz,i=t.loudness_db,g=t.confidences,b=c.upsample_f0(n,i.length,this.settings.modelMaxFrameLength),y=c.upsample_f0(g,i.length,this.settings.modelMaxFrameLength),[4,m.normalizeAudioFeatures({f0_hz:b,loudness_db:i,confidences:y},this.settings)];case 1:v=s.sent(),w=[],x=v.loudness_db.length,_=m.convertFrameToSecs(x),O=!1,S=m.convertFrameToSecs(this.settings.modelMaxFrameLength),T=f.CROSSFADE_DURATION*l.MODEL_SAMPLE_RATE,F=0,s.label=2;case 2:return F<_?(C=Math.floor(m.convertSecsToFrame(F)),(A=m.convertSecsToFrame(F+S))>x&&(O=!0),[4,m.resizeAudioFeatures(v,C,A,O,x)]):[3,7];case 3:return N=s.sent(),I=N.f0_hz,E=N.loudness_db,j=a.tensor1d(I,"float32"),M=a.tensor1d(E,"float32"),[4,this.model.predict({f0_hz:j,loudness_db:M})];case 4:return[4,(D=s.sent()).data()];case 5:R=s.sent(),w.push(R),D.dispose(),j.dispose(),M.dispose(),s.label=6;case 6:return F+=S-f.CROSSFADE_DURATION,[3,2];case 7:if(_<=S)k=w[0];else{for(P=[],F=0;F<w.length;F++)z=w[F],P.push(z);k=d.mixAndJoinAudioData(P,T)}return L=k.slice(0,t.originalRecordedBufferLength),$=L.map((function(t){return t*(U.settings.postGain||1)})),B=new o.Context,q=p.arrayBufferToAudioBuffer(B,$,l.MODEL_SAMPLE_RATE),[4,u.resampleAndMakeMono(q,f.OUTPUT_SAMPLE_RATE)];case 8:return V=s.sent(),[4,h.addReverb({audioCtx:B,arrayBuffer:V,sampleRate:f.OUTPUT_SAMPLE_RATE})];case 9:return[2,s.sent()]}}))}))},t}();e.DDSP=g},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.addReverb=void 0;var s=n(120),a=n(269);e.addReverb=function(t){var e=t.audioCtx,n=t.arrayBuffer,o=t.sampleRate;return r(this,void 0,void 0,(function(){var t,r,u;return i(this,(function(i){switch(i.label){case 0:return s.setContext(e),r=a.arrayBufferToAudioBuffer(e,n,o),[4,s.Offline((function(){var t=new s.Compressor({attack:.001,release:.001,threshold:-6}).toDestination(),e=new s.Reverb({wet:.3,decay:3}).connect(t),n=new s.Filter(8e3,"lowpass",-24).connect(e);return new s.Player({url:r}).connect(n).start(),e.ready}),n.length/o)];case 1:return t=i.sent(),u=t.getChannelData(0),r=null,t.dispose(),t=null,[2,u]}}))}))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.mixAndJoinAudioData=void 0,e.mixAndJoinAudioData=function(t,e){for(var n,r,i,s=t.reduce((function(t,e){return t+e.length}),0),a=new Float32Array(s),o=0,u=0;u<t.length;u++){var c=t[u],l=u<t.length-1;if(0===u&&(a.set(c,o),o+=c.length),l){for(var h=t[u+1],d=o-e,p=d,f=0,m=c.length-e;p<o&&f<h.length;p++,f++,m++){var g=(p-d)/(o-d);a[p]=(n=c[m],r=h[f],n*(1-(i=g))+r*i)}a.set(h.slice(e),o),o+=h.slice(e).length}}return a}},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{u(r.next(t))}catch(t){s(t)}}function o(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.resizeAudioFeatures=e.normalizeAudioFeatures=e.convertFrameToSecs=e.convertSecsToFrame=e.memCheck=e.getModel=void 0;var s=n(36),a=n(111),o=n(217),u=n(146),c=n(270);e.memCheck=function(){return r(this,void 0,void 0,(function(){var t,e,n,r;return i(this,(function(i){switch(i.label){case 0:if(1048576,600,t=window.screen.availWidth*window.screen.availHeight,e=window.devicePixelRatio,n=Math.round(t*e*600/1048576),!isNaN(n)&&n<c.MIN_VRAM)throw new Error("Insufficient memory! Your device has "+n+" and recommended memory is "+c.MIN_VRAM);i.label=1;case 1:return i.trys.push([1,3,,4]),[4,s.ready()];case 2:if(i.sent(),"webgl"!==s.getBackend())throw new Error("It looks like your browser does not support webgl.");return[3,4];case 3:throw r=i.sent(),new Error("insufficient memory - "+r);case 4:return[2,!0]}}))}))},e.getModel=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,s.loadGraphModel(t)];case 1:return[2,e.sent()]}}))}))},e.resizeAudioFeatures=function(t,e,n,r,i){return new Promise((function(s){for(var a={loudness_db:[0],f0_hz:[0]},o=0,u=e;u<n;u++)r&&u>=i?(a.loudness_db[o]=c.LOWEST_LD,a.f0_hz[o]=-1):(a.loudness_db[o]=t.loudness_db[u],a.f0_hz[o]=t.f0_hz[u]),o+=1;s(a)}))},e.normalizeAudioFeatures=function(t,e){return r(this,void 0,void 0,(function(){var n,r,u,l,h,d,p,f,m,g,b,y,v,w,x,_,O,S,k,T,C,A,N,I,E,j;return i(this,(function(i){switch(i.label){case 0:return n=e.averageMaxLoudness,r=e.meanLoudness,u=e.loudnessThreshold,l=e.meanPitch,h=[],t.loudness_db.length>0?(p=s.tidy((function(){var e=s.tensor1d(t.loudness_db,"float32"),r=e.max(),i=s.sub(n,r),a=s.add(e,i);return e.dispose(),r.dispose(),i.dispose(),a})),f=p.greater(u),[4,s.booleanMaskAsync(p,f)]):[3,4];case 1:return[4,(m=i.sent()).array()];case 2:return g=i.sent(),b=s.tidy((function(){var t=g>0?m.mean():p.mean(),e=s.sub(r,t),i=p.add(e).add(0).clipByValue(c.LOWEST_LD,n),a=i.min(),o=t.sub(a);return i.sub(a).div(o).mul(r-c.LOWEST_LD).add(c.LOWEST_LD)})),y=s.reshape(t.confidences,[-1,1,1]),v=s.pool(y,[c.CONF_SMOOTH_SIZE,1],"avg","same"),w=v.reshape([-1]),x=s.lessEqual(w,c.CONF_THRESHOLD),[4,(d=s.tidy((function(){var t=x.mul(c.LD_CONF_REDUCTION),e=b.add(t),n=s.maximum(e,c.LOWEST_LD);return t.dispose(),e.dispose(),n}))).array()];case 3:h=i.sent(),f.dispose(),p.dispose(),b.dispose(),m.dispose(),v.dispose(),w.dispose(),y.dispose(),x.dispose(),i.label=4;case 4:return _=[],t.f0_hz.length>0?[4,a.hzToMidi(t.f0_hz)]:[3,10];case 5:return O=i.sent(),S=s.tidy((function(){for(var t=0,e=O.length;t<e;++t)O[t]===-1/0&&(O[t]=0);return O})),k=s.lessEqual(t.confidences,c.CONF_THRESHOLD),T=d.greater(u),C=s.logicalOr(k,T),[4,s.booleanMaskAsync(S,C)];case 6:return A=i.sent(),N=A.mean(),[4,s.sub(l,N)];case 7:return[4,(I=i.sent()).array()];case 8:return E=i.sent(),[4,(j=s.tidy((function(){var e=E/12;return e=Math.round(e),o.shiftF0(t.f0_hz,e)}))).array()];case 9:_=i.sent(),d.dispose(),N.dispose(),A.dispose(),I.dispose(),j.dispose(),T.dispose(),C.dispose(),k.dispose(),i.label=10;case 10:return[2,{f0_hz:_,loudness_db:h}]}}))}))},e.convertSecsToFrame=function(t){return t*u.MODEL_FRAME_RATE},e.convertFrameToSecs=function(t){return t/u.MODEL_FRAME_RATE}},function(t,e,n){"use strict";n.r(e),n.d(e,"Array",(function(){return i})),n.d(e,"Note",(function(){return r})),n.d(e,"Interval",(function(){return s})),n.d(e,"Distance",(function(){return a})),n.d(e,"Scale",(function(){return c})),n.d(e,"Chord",(function(){return l})),n.d(e,"PcSet",(function(){return o})),n.d(e,"Dictionary",(function(){return u})),n.d(e,"transpose",(function(){return Oe})),n.d(e,"interval",(function(){return Se})),n.d(e,"note",(function(){return ke})),n.d(e,"midi",(function(){return Te})),n.d(e,"freq",(function(){return Ce})),n.d(e,"chord",(function(){return Ae})),n.d(e,"scale",(function(){return Ne}));var r={};n.r(r),n.d(r,"names",(function(){return d})),n.d(r,"tokenize",(function(){return g})),n.d(r,"props",(function(){return v})),n.d(r,"name",(function(){return w})),n.d(r,"pc",(function(){return x})),n.d(r,"midi",(function(){return _})),n.d(r,"midiToFreq",(function(){return O})),n.d(r,"freq",(function(){return S})),n.d(r,"freqToMidi",(function(){return C})),n.d(r,"chroma",(function(){return A})),n.d(r,"oct",(function(){return N})),n.d(r,"stepToLetter",(function(){return I})),n.d(r,"altToAcc",(function(){return j})),n.d(r,"from",(function(){return M})),n.d(r,"build",(function(){return D})),n.d(r,"fromMidi",(function(){return R})),n.d(r,"simplify",(function(){return P})),n.d(r,"enharmonic",(function(){return F}));var i={};n.r(i),n.d(i,"range",(function(){return z})),n.d(i,"rotate",(function(){return L})),n.d(i,"compact",(function(){return $})),n.d(i,"sort",(function(){return q})),n.d(i,"unique",(function(){return V})),n.d(i,"shuffle",(function(){return U})),n.d(i,"permutations",(function(){return W}));var s={};n.r(s),n.d(s,"names",(function(){return X})),n.d(s,"tokenize",(function(){return Y})),n.d(s,"qToAlt",(function(){return tt})),n.d(s,"altToQ",(function(){return et})),n.d(s,"props",(function(){return it})),n.d(s,"num",(function(){return st})),n.d(s,"name",(function(){return at})),n.d(s,"semitones",(function(){return ot})),n.d(s,"chroma",(function(){return ut})),n.d(s,"ic",(function(){return ct})),n.d(s,"build",(function(){return lt})),n.d(s,"simplify",(function(){return ht})),n.d(s,"invert",(function(){return dt})),n.d(s,"fromSemitones",(function(){return mt}));var a={};n.r(a),n.d(a,"transpose",(function(){return Ot})),n.d(a,"trFifths",(function(){return St})),n.d(a,"fifths",(function(){return kt})),n.d(a,"transposeBy",(function(){return Tt})),n.d(a,"addIntervals",(function(){return At})),n.d(a,"add",(function(){return Nt})),n.d(a,"subtract",(function(){return It})),n.d(a,"interval",(function(){return Et})),n.d(a,"semitones",(function(){return jt}));var o={};n.r(o),n.d(o,"chroma",(function(){return Ft})),n.d(o,"chromas",(function(){return Lt})),n.d(o,"modes",(function(){return $t})),n.d(o,"isChroma",(function(){return qt})),n.d(o,"intervals",(function(){return Ut})),n.d(o,"isEqual",(function(){return Wt})),n.d(o,"isSubsetOf",(function(){return Gt})),n.d(o,"isSupersetOf",(function(){return Ht})),n.d(o,"includes",(function(){return Kt})),n.d(o,"filter",(function(){return Qt}));var u={};n.r(u),n.d(u,"dictionary",(function(){return Xt})),n.d(u,"combine",(function(){return Yt})),n.d(u,"scale",(function(){return Jt})),n.d(u,"chord",(function(){return Zt})),n.d(u,"pcset",(function(){return te}));var c={};n.r(c),n.d(c,"props",(function(){return ne})),n.d(c,"names",(function(){return re})),n.d(c,"intervals",(function(){return ie})),n.d(c,"notes",(function(){return se})),n.d(c,"exists",(function(){return ae})),n.d(c,"tokenize",(function(){return oe})),n.d(c,"modeNames",(function(){return ue})),n.d(c,"chords",(function(){return ce})),n.d(c,"toScale",(function(){return le})),n.d(c,"supersets",(function(){return he})),n.d(c,"subsets",(function(){return de}));var l={};n.r(l),n.d(l,"names",(function(){return pe})),n.d(l,"props",(function(){return me})),n.d(l,"intervals",(function(){return ge})),n.d(l,"notes",(function(){return be})),n.d(l,"exists",(function(){return ye})),n.d(l,"supersets",(function(){return ve})),n.d(l,"subsets",(function(){return we})),n.d(l,"tokenize",(function(){return _e}));var h="C C# Db D D# Eb E F F# Gb G G# Ab A A# Bb B".split(" "),d=function(t){return"string"!=typeof t?h.slice():h.filter((function(e){var n=e[1]||" ";return-1!==t.indexOf(n)}))},p=d(" #"),f=d(" b"),m=/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/;function g(t){"string"!=typeof t&&(t="");var e=m.exec(t);return[e[1].toUpperCase(),e[2].replace(/x/g,"##"),e[3],e[4]]}var b=Object.freeze({pc:null,name:null,step:null,alt:null,oct:null,octStr:null,chroma:null,midi:null,freq:null}),y=[0,2,4,5,7,9,11],v=function(t,e){return void 0===e&&(e={}),function(n){return e[n]||(e[n]=t(n))}}((function(t){var e=g(t);if(""===e[0]||""!==e[3])return b;var n=e[0],r=e[1],i=e[2],s={letter:n,acc:r,octStr:i,pc:n+r,name:n+r+i,step:(n.charCodeAt(0)+3)%7,alt:"b"===r[0]?-r.length:r.length,oct:i.length?+i:null,chroma:0,midi:null,freq:null};return s.chroma=(y[s.step]+s.alt+120)%12,s.midi=null!==s.oct?y[s.step]+s.alt+12*(s.oct+1):null,s.freq=O(s.midi),Object.freeze(s)})),w=function(t){return v(t).name},x=function(t){return v(t).pc},_=function(t){if("number"!=typeof t&&"string"!=typeof t)return null;var e,n=v(t).midi,r=n||0===n?n:+t;return(e=r)>=0&&e<=127?r:null},O=function(t,e){return void 0===e&&(e=440),"number"==typeof t?Math.pow(2,(t-69)/12)*e:null},S=function(t){return v(t).freq||O(t)},k=Math.log(2),T=Math.log(440),C=function(t){var e=12*(Math.log(t)-T)/k+69;return Math.round(100*e)/100},A=function(t){return v(t).chroma},N=function(t){return v(t).oct},I=function(t){return"CDEFGAB"[t]},E=function(t,e){return Array(e+1).join(t)},j=function(t){return function(t,e){return"number"!=typeof t?"":e(t)}(t,(function(t){return t<0?E("b",-t):E("#",t)}))},M=function(t,e){void 0===t&&(t={}),void 0===e&&(e=null);var n=e?Object.assign({},v(e),t):t,r=n.step,i=n.alt,s=n.oct;if("number"!=typeof r)return null;var a=I(r);if(!a)return null;var o=a+j(i);return s||0===s?o+s:o},D=M;function R(t,e){return void 0===e&&(e=!1),t=Math.round(t),(!0===e?p:f)[t%12]+(Math.floor(t/12)-1)}var P=function(t,e){void 0===e&&(e=!0);var n=v(t),r=n.alt,i=n.chroma,s=n.midi;if(null===i)return null;var a=!1===e?r<0:r>0;return null===s?x(R(i,a)):R(s,a)},F=function(t){return P(t,!1)};function z(t,e){return null===t||null===e?[]:t<e?function(t,e){for(var n=[];e--;n[e]=e+t);return n}(t,e-t+1):function(t,e){for(var n=[];e--;n[e]=t-e);return n}(t,t-e+1)}function L(t,e){var n=e.length,r=(t%n+n)%n;return e.slice(r,n).concat(e.slice(0,r))}var $=function(t){return t.filter((function(t){return 0===t||t}))},B=function(t){var e=v(t).midi;return null!==e?e:v(t+"-100").midi};function q(t){return $(t.map(w)).sort((function(t,e){return B(t)>B(e)}))}function V(t){return q(t).filter((function(t,e,n){return 0===e||t!==n[e-1]}))}var U=function(t,e){var n,r;void 0===e&&(e=Math.random);for(var i=t.length;i;)n=e()*i--|0,r=t[i],t[i]=t[n],t[n]=r;return t},W=function(t){return 0===t.length?[[]]:W(t.slice(1)).reduce((function(e,n){return e.concat(t.map((function(e,r){var i=n.slice();return i.splice(r,0,t[0]),i})))}),[])},G=new RegExp("^([-+]?\\d+)(d{1,4}|m|M|P|A{1,4})|(AA|A|P|M|m|d|dd)([-+]?\\d+)$"),H=[0,2,4,5,7,9,11],K=[0,1,2,3,4,5,6,5,4,3,2,1],Q="1P 2m 2M 3m 3M 4P 5P 6m 6M 7m 7M 8P".split(" "),X=function(t){return"string"!=typeof t?Q.slice():Q.filter((function(e){return-1!==t.indexOf(e[1])}))},Y=function(t){var e=G.exec(""+t);return null===e?null:e[1]?[e[1],e[2]]:[e[4],e[3]]},J=Object.freeze({name:null,num:null,q:null,step:null,alt:null,dir:null,type:null,simple:null,semitones:null,chroma:null,oct:null}),Z=function(t,e){return Array(Math.abs(e)+1).join(t)},tt=function(t,e){return"M"===e&&"M"===t||"P"===e&&"P"===t?0:"m"===e&&"M"===t?-1:/^A+$/.test(e)?e.length:/^d+$/.test(e)?"P"===t?-e.length:-e.length-1:null},et=function(t,e){return 0===e?"M"===t?"M":"P":-1===e&&"M"===t?"m":e>0?Z("A",e):e<0?Z("d","P"===t?e:e+1):null},nt=function(t){return(Math.abs(t)-1)%7},rt={};function it(t){return"string"!=typeof t?J:rt[t]||(rt[t]=function(t){var e=Y(t);if(null===e)return J;var n={num:0,q:"d",name:"",type:"M",step:0,dir:-1,simple:1,alt:0,oct:0,semitones:0,chroma:0,ic:0};return n.num=+e[0],n.q=e[1],n.step=nt(n.num),n.type="PMMPPMM"[n.step],"M"===n.type&&"P"===n.q?J:(n.name=""+n.num+n.q,n.dir=n.num<0?-1:1,n.simple=8===n.num||-8===n.num?n.num:n.dir*(n.step+1),n.alt=tt(n.type,n.q),n.oct=Math.floor((Math.abs(n.num)-1)/7),n.semitones=n.dir*(H[n.step]+n.alt+12*n.oct),n.chroma=(n.dir*(H[n.step]+n.alt)%12+12)%12,Object.freeze(n))}(t))}var st=function(t){return it(t).num},at=function(t){return it(t).name},ot=function(t){return it(t).semitones},ut=function(t){return it(t).chroma},ct=function(t){return"string"==typeof t&&(t=it(t).chroma),"number"==typeof t?K[t%12]:null},lt=function(t){var e=void 0===t?{}:t,n=e.num,r=e.step,i=e.alt,s=e.oct,a=void 0===s?1:s,o=e.dir;if(void 0!==r&&(n=r+1+7*a),void 0===n)return null;if("number"!=typeof i)return null;var u="number"!=typeof o?"":o<0?"-":"",c="PMMPPMM"[nt(n)];return u+n+et(c,i)},ht=function(t){var e=it(t);if(e===J)return null;var n=e;return n.simple+n.q},dt=function(t){var e=it(t);if(e===J)return null;var n=e,r=(7-n.step)%7,i="P"===n.type?-n.alt:-(n.alt+1);return lt({step:r,alt:i,oct:n.oct,dir:n.dir})},pt=[1,2,2,3,3,4,5,5,6,6,7,7],ft="P m M m M P d P m M m M".split(" "),mt=function(t){var e=t<0?-1:1,n=Math.abs(t),r=n%12,i=Math.floor(n/12);return e*(pt[r]+7*i)+ft[r]},gt=[0,2,4,-1,1,3,5],bt=gt.map((function(t){return Math.floor(7*t/12)})),yt=[3,0,4,1,5,2,6];var vt=function(t,e,n){var r=yt[function(t){var e=(t+1)%7;return e<0?7+e:e}(t)],i=Math.floor((t+1)/7);return void 0===e?{step:r,alt:i,dir:n}:{step:r,alt:i,oct:e+4*i+bt[r],dir:n}},wt=function(t){return function(t,e){return void 0===e&&(e={}),function(n){return e[n]||(e[n]=t(n))}}((function(e){var n=t(e);return null===n.name?null:function(t){var e=t.step,n=t.alt,r=t.oct,i=t.dir;void 0===i&&(i=1);var s=gt[e]+7*n;return null===r?[i*s]:[i*s,i*(r-bt[e]-4*n)]}(n)}))},xt=wt(v),_t=wt(it);function Ot(t,e){if(1===arguments.length)return function(e){return Ot(t,e)};var n=xt(t),r=_t(e);if(null===n||null===r)return null;var i=1===n.length?[n[0]+r[0]]:[n[0]+r[0],n[1]+r[1]];return D(vt(i[0],i[1]))}function St(t,e){if(1===arguments.length)return function(e){return St(t,e)};var n=xt(t);return null===n?null:D(vt(n[0]+e))}function kt(t,e){if(1===arguments.length)return function(e){return kt(t,e)};var n=xt(t),r=xt(e);return null===r||null===n?null:r[0]-n[0]}function Tt(t,e){return 1===arguments.length?function(e){return Ot(e,t)}:Ot(e,t)}var Ct=function(t){return 7*(e=t)[0]+12*e[1]<0?vt(-t[0],-t[1],-1):vt(t[0],t[1],1);var e};function At(t,e,n){var r=_t(t),i=_t(e);if(null===r||null===i)return null;var s=[r[0]+n*i[0],r[1]+n*i[1]];return lt(Ct(s))}function Nt(t,e){return 1===arguments.length?function(e){return Nt(t,e)}:At(t,e,1)}function It(t,e){return 1===arguments.length?function(e){return Nt(t,e)}:At(t,e,-1)}function Et(t,e){if(1===arguments.length)return function(e){return Et(t,e)};var n=xt(t),r=xt(e);if(null===n||null===r||n.length!==r.length)return null;var i=1===n.length?[r[0]-n[0],-Math.floor(7*(r[0]-n[0])/12)]:[r[0]-n[0],r[1]-n[1]];return lt(Ct(i))}function jt(t,e){if(1===arguments.length)return function(e){return jt(t,e)};var n=v(t),r=v(e);return null!==n.midi&&null!==r.midi?r.midi-n.midi:null!==n.chroma&&null!==r.chroma?(r.chroma-n.chroma+12)%12:null}var Mt=n(291),Dt=n(292),Rt=function(t){return A(t)||ut(t)||0},Pt=function(t){return parseInt(Ft(t),2)};function Ft(t){if(qt(t))return t;if(!Array.isArray(t))return"";var e=[0,0,0,0,0,0,0,0,0,0,0,0];return t.map(Rt).forEach((function(t){e[t]=1})),e.join("")}var zt=null;function Lt(t){return zt=zt||z(2048,4095).map((function(t){return t.toString(2)})),"number"==typeof t?zt.filter((function(e){return function(t){return t.replace(/0/g,"").length}(e)===t})):zt.slice()}function $t(t,e){e=!1!==e;var n=Ft(t).split("");return $(n.map((function(t,r){var i=L(r,n);return e&&"0"===i[0]?null:i.join("")})))}var Bt=/^[01]{12}$/;function qt(t){return Bt.test(t)}var Vt="1P 2m 2M 3m 3M 4P 5d 5P 6m 6M 7m 7M".split(" ");function Ut(t){return qt(t)?$(t.split("").map((function(t,e){return"1"===t?Vt[e]:null}))):[]}function Wt(t,e){return 1===arguments.length?function(e){return Wt(t,e)}:Ft(t)===Ft(e)}function Gt(t,e){return arguments.length>1?Gt(t)(e):(t=Pt(t),function(e){return(e=Pt(e))!==t&&(e&t)===e})}function Ht(t,e){return arguments.length>1?Ht(t)(e):(t=Pt(t),function(e){return(e=Pt(e))!==t&&(e|t)===e})}function Kt(t,e){return arguments.length>1?Kt(t)(e):(t=Ft(t),function(e){return"1"===t[Rt(e)]})}function Qt(t,e){return 1===arguments.length?function(e){return Qt(t,e)}:e.filter(Kt(t))}var Xt=function(t){var e=Object.keys(t).sort(),n=[],r=[],i=function(t,e,i){n[t]=e,r[i]=r[i]||[],r[i].push(t)};e.forEach((function(e){var n=t[e][0].split(" "),r=t[e][1],s=Ft(n);i(e,n,s),r&&r.forEach((function(t){return i(t,n,s)}))}));var s=Object.keys(n).sort(),a=function(t){return n[t]};return a.names=function(t){return"string"==typeof t?(r[t]||[]).slice():(!0===t?s:e).slice()},a},Yt=function(t,e){var n=function(n){return t(n)||e(n)};return n.names=function(n){return t.names(n).concat(e.names(n))},n},Jt=Xt(Mt),Zt=Xt(Dt),te=Yt(Jt,Zt),ee=Object.freeze({name:null,intervals:[],names:[],chroma:null,setnum:null}),ne=function(t,e){return function(n){return e[n]||(e[n]=t(n))}}((function(t){var e=Jt(t);if(!e)return ee;var n={intervals:e,name:t};return n.chroma=Ft(e),n.setnum=parseInt(n.chroma,2),n.names=Jt.names(n.chroma),Object.freeze(n)}),{}),re=Jt.names,ie=function(t){var e=oe(t);return ne(e[1]).intervals};function se(t,e){var n=oe(t);return e=e||n[1],ie(e).map(Ot(n[0]))}function ae(t){var e=oe(t);return void 0!==Jt(e[1])}function oe(t){if("string"!=typeof t)return["",""];var e=t.indexOf(" "),n=w(t.substring(0,e))||w(t)||"",r=""!==n?t.substring(n.length+1):t;return[n,r.length?r:""]}var ue=function(t){var e=ie(t),n=se(t);return $t(e).map((function(t,r){var i=Jt.names(t)[0];if(i)return[n[r]||e[r],i]})).filter((function(t){return t}))},ce=function(t){var e=Gt(ie(t));return Zt.names().filter((function(t){return e(Zt(t))}))},le=function(t){var e=$(t.map(x));if(!e.length)return e;var n=e[0],r=V(e);return L(r.indexOf(n),r)},he=function(t){if(!ie(t).length)return[];var e=Ht(ie(t));return Jt.names().filter((function(t){return e(Jt(t))}))},de=function(t){var e=Gt(ie(t));return Jt.names().filter((function(t){return e(Jt(t))}))},pe=Zt.names,fe=Object.freeze({name:null,names:[],intervals:[],chroma:null,setnum:null}),me=function(t,e){return void 0===e&&(e={}),function(n){return e[n]||(e[n]=t(n))}}((function(t){var e=Zt(t);if(!e)return fe;var n={intervals:e,name:t};return n.chroma=Ft(e),n.setnum=parseInt(n.chroma,2),n.names=Zt.names(n.chroma),n})),ge=function(t){return me(_e(t)[1]).intervals};function be(t,e){if(e)return me(e).intervals.map(Ot(t));var n=_e(t),r=n[0],i=n[1];return me(i).intervals.map(Ot(r))}var ye=function(t){return void 0!==Zt(_e(t)[1])},ve=function(t){if(!ge(t).length)return[];var e=Ht(ge(t));return Zt.names().filter((function(t){return e(Zt(t))}))},we=function(t){var e=Gt(ge(t));return Zt.names().filter((function(t){return e(Zt(t))}))},xe=/^(6|64|7|9|11|13)$/;function _e(t){var e=g(t);return""===e[0]?["",t]:"A"===e[0]&&"ug"===e[3]?["","aug"]:xe.test(e[2])?[e[0]+e[1],e[2]+e[3]]:[e[0]+e[1]+e[2],e[3]]}const Oe=Ot,Se=Et,ke=v,Te=_,Ce=S,Ae=Zt,Ne=Jt}]);