diff --git a/applications/emocam/index.html b/applications/emocam/index.html
index 583adc8..ff2b646 100644
--- a/applications/emocam/index.html
+++ b/applications/emocam/index.html
@@ -722,8 +722,6 @@
$("#videoSource").val(idValue).prop('selected', true);
$("#videoSource").val(idValue).change();
$("#videoDropdown").val(hrefValue);
- MyAvatar.removeAnimationStateHandler(handlerId);
- MyAvatar.restoreAnimation();
});
// Enable the live webcam view and start detection.
function enableCam(event) {
@@ -782,13 +780,13 @@
}
function getStream() {
- if (window.stream) {
- window.stream.getTracks().forEach(track => {
- track.stop();
- });
+ if (window.stream) {
+ window.stream.getTracks().forEach(track => {
+ track.stop();
+ });
}
- const videoSource = videoSelect.value;
+ const videoSource = videoSelect.value;
const constraints = {
video: {deviceId: videoSource ? {exact: videoSource} : undefined}
};
diff --git a/applications/emocam/js/tasks-vision.ts b/applications/emocam/js/tasks-vision.ts
new file mode 100644
index 0000000..3692d58
--- /dev/null
+++ b/applications/emocam/js/tasks-vision.ts
@@ -0,0 +1,33078 @@
+/**
+ * Skipped minification because the original files appears to be already minified.
+ * Original file: /npm/@mediapipe/tasks-vision@0.10.0/vision_bundle.js
+ *
+ * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
+ */
+var commonjsGlobal = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {}
+ , vision = {}
+ , fileset_resolver = {};
+let supportsSimd;
+Object.defineProperty(fileset_resolver, "__esModule", {
+ value: !0
+}),
+fileset_resolver.FilesetResolver = void 0;
+const WASM_SIMD_CHECK = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 123, 3, 2, 1, 0, 10, 10, 1, 8, 0, 65, 0, 253, 15, 253, 98, 11]);
+async function isSimdSupported() {
+ if (void 0 === supportsSimd)
+ try {
+ await WebAssembly.instantiate(WASM_SIMD_CHECK),
+ supportsSimd = !0
+ } catch (e) {
+ supportsSimd = !1
+ }
+ return supportsSimd
+}
+async function createFileset(e, t="") {
+ const r = await isSimdSupported() ? "wasm_internal" : "wasm_nosimd_internal";
+ return {
+ wasmLoaderPath: `./js/wasm/vision_wasm_internal.js`,
+ wasmBinaryPath: `./js/wasm/vision_wasm_internal.wasm`
+ }
+}
+class FilesetResolver$1 {
+ static isSimdSupported() {
+ return isSimdSupported()
+ }
+ static forAudioTasks(e) {
+ return createFileset("audio", e)
+ }
+ static forTextTasks(e) {
+ return createFileset("text", e)
+ }
+ static forVisionTasks(e) {
+ return createFileset("vision", e)
+ }
+}
+fileset_resolver.FilesetResolver = FilesetResolver$1;
+var drawing_utils = {};
+Object.defineProperty(drawing_utils, "__esModule", {
+ value: !0
+}),
+drawing_utils.DrawingUtils = void 0;
+const DEFAULT_OPTIONS = {
+ color: "white",
+ lineWidth: 4,
+ radius: 6
+};
+function addDefaultOptions(e) {
+ return e = e || {},
+ Object.assign(Object.assign(Object.assign({}, DEFAULT_OPTIONS), {
+ fillColor: e.color
+ }), e)
+}
+function resolve(e, t) {
+ return e instanceof Function ? e(t) : e
+}
+class DrawingUtils$1 {
+ constructor(e) {
+ this.ctx = e
+ }
+ static clamp(e, t, r) {
+ const o = Math.min(t, r)
+ , i = Math.max(t, r);
+ return Math.max(o, Math.min(i, e))
+ }
+ static lerp(e, t, r, o, i) {
+ const a = o * (1 - (e - t) / (r - t)) + i * (1 - (r - e) / (r - t));
+ return DrawingUtils$1.clamp(a, o, i)
+ }
+ drawLandmarks(e, t) {
+ if (!e)
+ return;
+ const r = this.ctx
+ , o = addDefaultOptions(t);
+ r.save();
+ const i = r.canvas;
+ let a = 0;
+ for (const t of e) {
+ r.fillStyle = resolve(o.fillColor, {
+ index: a,
+ from: t
+ }),
+ r.strokeStyle = resolve(o.color, {
+ index: a,
+ from: t
+ }),
+ r.lineWidth = resolve(o.lineWidth, {
+ index: a,
+ from: t
+ });
+ const e = new Path2D;
+ e.arc(t.x * i.width, t.y * i.height, resolve(o.radius, {
+ index: a,
+ from: t
+ }), 0, 2 * Math.PI),
+ r.fill(e),
+ r.stroke(e),
+ ++a
+ }
+ r.restore()
+ }
+ drawConnectors(e, t, r) {
+ if (!e || !t)
+ return;
+ const o = this.ctx
+ , i = addDefaultOptions(r);
+ o.save();
+ const a = o.canvas;
+ let n = 0;
+ for (const r of t) {
+ o.beginPath();
+ const t = e[r.start]
+ , s = e[r.end];
+ t && s && (o.strokeStyle = resolve(i.color, {
+ index: n,
+ from: t,
+ to: s
+ }),
+ o.lineWidth = resolve(i.lineWidth, {
+ index: n,
+ from: t,
+ to: s
+ }),
+ o.moveTo(t.x * a.width, t.y * a.height),
+ o.lineTo(s.x * a.width, s.y * a.height)),
+ ++n,
+ o.stroke()
+ }
+ o.restore()
+ }
+ drawBoundingBox(e, t) {
+ const r = this.ctx
+ , o = addDefaultOptions(t);
+ r.save(),
+ r.beginPath(),
+ r.lineWidth = resolve(o.lineWidth, {}),
+ r.strokeStyle = resolve(o.color, {}),
+ r.fillStyle = resolve(o.fillColor, {}),
+ r.moveTo(e.originX, e.originY),
+ r.lineTo(e.originX + e.width, e.originY),
+ r.lineTo(e.originX + e.width, e.originY + e.height),
+ r.lineTo(e.originX, e.originY + e.height),
+ r.lineTo(e.originX, e.originY),
+ r.stroke(),
+ r.fill(),
+ r.restore()
+ }
+}
+drawing_utils.DrawingUtils = DrawingUtils$1;
+var image = {}
+ , image_shader_context = {};
+Object.defineProperty(image_shader_context, "__esModule", {
+ value: !0
+}),
+image_shader_context.MPImageShaderContext = image_shader_context.assertNotNull = void 0;
+const VERTEX_SHADER = "\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }"
+ , FRAGMENT_SHADER = "\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D inputTexture;\n void main() {\n gl_FragColor = texture2D(inputTexture, vTex);\n }\n ";
+function assertNotNull(e, t) {
+ if (null === e)
+ throw new Error(`Unable to obtain required WebGL resource: ${t}`);
+ return e
+}
+image_shader_context.assertNotNull = assertNotNull;
+class MPImageShaderBuffers {
+ constructor(e, t, r, o) {
+ this.gl = e,
+ this.vertexArrayObject = t,
+ this.vertexBuffer = r,
+ this.textureBuffer = o
+ }
+ bind() {
+ this.gl.bindVertexArray(this.vertexArrayObject)
+ }
+ unbind() {
+ this.gl.bindVertexArray(null)
+ }
+ close() {
+ this.gl.deleteVertexArray(this.vertexArrayObject),
+ this.gl.deleteBuffer(this.vertexBuffer),
+ this.gl.deleteBuffer(this.textureBuffer)
+ }
+}
+class MPImageShaderContext {
+ compileShader(e, t) {
+ const r = this.gl
+ , o = assertNotNull(r.createShader(t), "Failed to create WebGL shader");
+ if (r.shaderSource(o, e),
+ r.compileShader(o),
+ !r.getShaderParameter(o, r.COMPILE_STATUS)) {
+ const e = r.getShaderInfoLog(o);
+ throw new Error(`Could not compile WebGL shader: ${e}`)
+ }
+ return r.attachShader(this.program, o),
+ o
+ }
+ setupShaders() {
+ const e = this.gl;
+ this.program = assertNotNull(e.createProgram(), "Failed to create WebGL program"),
+ this.vertexShader = this.compileShader(VERTEX_SHADER, e.VERTEX_SHADER),
+ this.fragmentShader = this.compileShader(FRAGMENT_SHADER, e.FRAGMENT_SHADER),
+ e.linkProgram(this.program);
+ if (!e.getProgramParameter(this.program, e.LINK_STATUS)) {
+ const t = e.getProgramInfoLog(this.program);
+ throw new Error(`Error during program linking: ${t}`)
+ }
+ this.aVertex = e.getAttribLocation(this.program, "aVertex"),
+ this.aTex = e.getAttribLocation(this.program, "aTex")
+ }
+ createBuffers(e) {
+ const t = this.gl
+ , r = assertNotNull(t.createVertexArray(), "Failed to create vertex array");
+ t.bindVertexArray(r);
+ const o = assertNotNull(t.createBuffer(), "Failed to create buffer");
+ t.bindBuffer(t.ARRAY_BUFFER, o),
+ t.enableVertexAttribArray(this.aVertex),
+ t.vertexAttribPointer(this.aVertex, 2, t.FLOAT, !1, 0, 0),
+ t.bufferData(t.ARRAY_BUFFER, new Float32Array([-1, -1, -1, 1, 1, 1, 1, -1]), t.STATIC_DRAW);
+ const i = assertNotNull(t.createBuffer(), "Failed to create buffer");
+ t.bindBuffer(t.ARRAY_BUFFER, i),
+ t.enableVertexAttribArray(this.aTex),
+ t.vertexAttribPointer(this.aTex, 2, t.FLOAT, !1, 0, 0);
+ const a = e ? [0, 1, 0, 0, 1, 0, 1, 1] : [0, 0, 0, 1, 1, 1, 1, 0];
+ return t.bufferData(t.ARRAY_BUFFER, new Float32Array(a), t.STATIC_DRAW),
+ t.bindBuffer(t.ARRAY_BUFFER, null),
+ t.bindVertexArray(null),
+ new MPImageShaderBuffers(t,r,o,i)
+ }
+ getShaderBuffers(e) {
+ return e ? (this.shaderBuffersFlipVertically || (this.shaderBuffersFlipVertically = this.createBuffers(!0)),
+ this.shaderBuffersFlipVertically) : (this.shaderBuffersPassthrough || (this.shaderBuffersPassthrough = this.createBuffers(!1)),
+ this.shaderBuffersPassthrough)
+ }
+ maybeInitGL(e) {
+ if (this.gl) {
+ if (e !== this.gl)
+ throw new Error("Cannot change GL context once initialized")
+ } else
+ this.gl = e
+ }
+ run(e, t, r) {
+ this.maybeInitGL(e),
+ this.program || this.setupShaders();
+ const o = this.getShaderBuffers(t);
+ e.useProgram(this.program),
+ o.bind();
+ const i = r();
+ return o.unbind(),
+ i
+ }
+ bindFramebuffer(e, t) {
+ this.maybeInitGL(e),
+ this.framebuffer || (this.framebuffer = assertNotNull(e.createFramebuffer(), "Failed to create framebuffe.")),
+ e.bindFramebuffer(e.FRAMEBUFFER, this.framebuffer),
+ e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, t, 0)
+ }
+ unbindFramebuffer() {
+ var e;
+ null === (e = this.gl) || void 0 === e || e.bindFramebuffer(this.gl.FRAMEBUFFER, null)
+ }
+ close() {
+ if (this.program) {
+ const e = this.gl;
+ e.deleteProgram(this.program),
+ e.deleteShader(this.vertexShader),
+ e.deleteShader(this.fragmentShader)
+ }
+ this.framebuffer && this.gl.deleteFramebuffer(this.framebuffer),
+ this.shaderBuffersPassthrough && this.shaderBuffersPassthrough.close(),
+ this.shaderBuffersFlipVertically && this.shaderBuffersFlipVertically.close()
+ }
+}
+image_shader_context.MPImageShaderContext = MPImageShaderContext,
+Object.defineProperty(image, "__esModule", {
+ value: !0
+}),
+image.MPImage = void 0;
+const image_shader_context_1$2 = image_shader_context;
+var MPImageType;
+!function(e) {
+ e[e.IMAGE_DATA = 0] = "IMAGE_DATA",
+ e[e.IMAGE_BITMAP = 1] = "IMAGE_BITMAP",
+ e[e.WEBGL_TEXTURE = 2] = "WEBGL_TEXTURE"
+}(MPImageType || (MPImageType = {}));
+class MPImage$1 {
+ constructor(e, t, r, o, i, a, n) {
+ this.containers = e,
+ this.ownsImageBitmap = t,
+ this.ownsWebGLTexture = r,
+ this.canvas = o,
+ this.shaderContext = i,
+ this.width = a,
+ this.height = n
+ }
+ hasImageData() {
+ return !!this.getContainer(MPImageType.IMAGE_DATA)
+ }
+ hasImageBitmap() {
+ return !!this.getContainer(MPImageType.IMAGE_BITMAP)
+ }
+ hasWebGLTexture() {
+ return !!this.getContainer(MPImageType.WEBGL_TEXTURE)
+ }
+ getAsImageData() {
+ return this.convertToImageData()
+ }
+ getAsImageBitmap() {
+ return this.convertToImageBitmap()
+ }
+ getAsWebGLTexture() {
+ return this.convertToWebGLTexture()
+ }
+ getContainer(e) {
+ switch (e) {
+ case MPImageType.IMAGE_DATA:
+ return this.containers.find((e=>e instanceof ImageData));
+ case MPImageType.IMAGE_BITMAP:
+ return this.containers.find((e=>"undefined" != typeof ImageBitmap && e instanceof ImageBitmap));
+ case MPImageType.WEBGL_TEXTURE:
+ return this.containers.find((e=>"undefined" != typeof WebGLTexture && e instanceof WebGLTexture));
+ default:
+ throw new Error(`Type is not supported: ${e}`)
+ }
+ }
+ clone() {
+ const e = [];
+ for (const t of this.containers) {
+ let r;
+ if (t instanceof ImageData)
+ r = new ImageData(t.data,this.width,this.height);
+ else if (t instanceof WebGLTexture) {
+ const e = this.getGL()
+ , t = this.getShaderContext();
+ e.activeTexture(e.TEXTURE1),
+ r = (0,
+ image_shader_context_1$2.assertNotNull)(e.createTexture(), "Failed to create texture"),
+ e.bindTexture(e.TEXTURE_2D, r),
+ e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, this.width, this.height, 0, e.RGBA, e.UNSIGNED_BYTE, null),
+ t.bindFramebuffer(e, r),
+ t.run(e, !1, (()=>{
+ this.bindTexture(),
+ e.clearColor(0, 0, 0, 0),
+ e.clear(e.COLOR_BUFFER_BIT),
+ e.drawArrays(e.TRIANGLE_FAN, 0, 4),
+ this.unbindTexture()
+ }
+ )),
+ t.unbindFramebuffer(),
+ this.unbindTexture()
+ } else {
+ if (!(t instanceof ImageBitmap))
+ throw new Error(`Type is not supported: ${t}`);
+ this.convertToWebGLTexture(),
+ this.bindTexture(),
+ r = this.copyTextureToBitmap(),
+ this.unbindTexture()
+ }
+ e.push(r)
+ }
+ return new MPImage$1(e,this.hasImageBitmap(),this.hasWebGLTexture(),this.canvas,this.shaderContext,this.width,this.height)
+ }
+ getOffscreenCanvas() {
+ if (!(this.canvas instanceof OffscreenCanvas))
+ throw new Error("Conversion to ImageBitmap requires that the MediaPipe Tasks is initialized with an OffscreenCanvas");
+ return this.canvas
+ }
+ getGL() {
+ if (!this.canvas)
+ throw new Error("Conversion to different image formats require that a canvas is passed when iniitializing the image.");
+ return this.gl || (this.gl = (0,
+ image_shader_context_1$2.assertNotNull)(this.canvas.getContext("webgl2"), "You cannot use a canvas that is already bound to a different type of rendering context.")),
+ this.gl
+ }
+ getShaderContext() {
+ return this.shaderContext || (this.shaderContext = new image_shader_context_1$2.MPImageShaderContext),
+ this.shaderContext
+ }
+ convertToImageBitmap() {
+ let e = this.getContainer(MPImageType.IMAGE_BITMAP);
+ return e || (this.convertToWebGLTexture(),
+ e = this.convertWebGLTextureToImageBitmap(),
+ this.containers.push(e),
+ this.ownsImageBitmap = !0),
+ e
+ }
+ convertToImageData() {
+ let e = this.getContainer(MPImageType.IMAGE_DATA);
+ if (!e) {
+ const t = this.getGL()
+ , r = this.getShaderContext()
+ , o = new Uint8Array(this.width * this.height * 4)
+ , i = this.convertToWebGLTexture();
+ r.bindFramebuffer(t, i),
+ t.readPixels(0, 0, this.width, this.height, t.RGBA, t.UNSIGNED_BYTE, o),
+ r.unbindFramebuffer(),
+ e = new ImageData(new Uint8ClampedArray(o.buffer),this.width,this.height),
+ this.containers.push(e)
+ }
+ return e
+ }
+ convertToWebGLTexture() {
+ let e = this.getContainer(MPImageType.WEBGL_TEXTURE);
+ if (!e) {
+ const t = this.getGL();
+ e = this.bindTexture();
+ const r = this.getContainer(MPImageType.IMAGE_BITMAP) || this.convertToImageData();
+ t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, r),
+ this.unbindTexture()
+ }
+ return e
+ }
+ bindTexture() {
+ const e = this.getGL();
+ e.viewport(0, 0, this.width, this.height),
+ e.activeTexture(e.TEXTURE0);
+ let t = this.getContainer(MPImageType.WEBGL_TEXTURE);
+ return t || (t = (0,
+ image_shader_context_1$2.assertNotNull)(e.createTexture(), "Failed to create texture"),
+ this.containers.push(t),
+ this.ownsWebGLTexture = !0),
+ e.bindTexture(e.TEXTURE_2D, t),
+ e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE),
+ e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE),
+ e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR),
+ e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.LINEAR),
+ t
+ }
+ unbindTexture() {
+ this.gl.bindTexture(this.gl.TEXTURE_2D, null)
+ }
+ copyTextureToBitmap() {
+ const e = this.getGL();
+ return this.getShaderContext().run(e, !0, (()=>this.runWithResizedCanvas((()=>(e.bindFramebuffer(e.FRAMEBUFFER, null),
+ e.clearColor(0, 0, 0, 0),
+ e.clear(e.COLOR_BUFFER_BIT),
+ e.drawArrays(e.TRIANGLE_FAN, 0, 4),
+ this.getOffscreenCanvas().transferToImageBitmap())))))
+ }
+ convertWebGLTextureToImageBitmap() {
+ this.bindTexture();
+ const e = this.copyTextureToBitmap();
+ return this.unbindTexture(),
+ e
+ }
+ runWithResizedCanvas(e) {
+ const t = this.canvas;
+ if (t.width === this.width && t.height === this.height)
+ return e();
+ const r = t.width
+ , o = t.height;
+ t.width = this.width,
+ t.height = this.height;
+ const i = e();
+ return t.width = r,
+ t.height = o,
+ i
+ }
+ close() {
+ if (this.ownsImageBitmap && this.getContainer(MPImageType.IMAGE_BITMAP).close(),
+ this.ownsWebGLTexture) {
+ this.getGL().deleteTexture(this.getContainer(MPImageType.WEBGL_TEXTURE))
+ }
+ }
+}
+image.MPImage = MPImage$1;
+var mask = {};
+Object.defineProperty(mask, "__esModule", {
+ value: !0
+}),
+mask.MPMask = void 0;
+const image_shader_context_1$1 = image_shader_context;
+var MPMaskType;
+!function(e) {
+ e[e.UINT8_ARRAY = 0] = "UINT8_ARRAY",
+ e[e.FLOAT32_ARRAY = 1] = "FLOAT32_ARRAY",
+ e[e.WEBGL_TEXTURE = 2] = "WEBGL_TEXTURE"
+}(MPMaskType || (MPMaskType = {}));
+class MPMask$1 {
+ constructor(e, t, r, o, i, a) {
+ this.containers = e,
+ this.ownsWebGLTexture = t,
+ this.canvas = r,
+ this.shaderContext = o,
+ this.width = i,
+ this.height = a
+ }
+ hasUint8Array() {
+ return !!this.getContainer(MPMaskType.UINT8_ARRAY)
+ }
+ hasFloat32Array() {
+ return !!this.getContainer(MPMaskType.FLOAT32_ARRAY)
+ }
+ hasWebGLTexture() {
+ return !!this.getContainer(MPMaskType.WEBGL_TEXTURE)
+ }
+ getAsUint8Array() {
+ return this.convertToUint8Array()
+ }
+ getAsFloat32Array() {
+ return this.convertToFloat32Array()
+ }
+ getAsWebGLTexture() {
+ return this.convertToWebGLTexture()
+ }
+ getContainer(e) {
+ switch (e) {
+ case MPMaskType.UINT8_ARRAY:
+ return this.containers.find((e=>e instanceof Uint8Array));
+ case MPMaskType.FLOAT32_ARRAY:
+ return this.containers.find((e=>e instanceof Float32Array));
+ case MPMaskType.WEBGL_TEXTURE:
+ return this.containers.find((e=>"undefined" != typeof WebGLTexture && e instanceof WebGLTexture));
+ default:
+ throw new Error(`Type is not supported: ${e}`)
+ }
+ }
+ clone() {
+ const e = [];
+ for (const t of this.containers) {
+ let r;
+ if (t instanceof Uint8Array)
+ r = new Uint8Array(t);
+ else if (t instanceof Float32Array)
+ r = new Float32Array(t);
+ else {
+ if (!(t instanceof WebGLTexture))
+ throw new Error(`Type is not supported: ${t}`);
+ {
+ const e = this.getGL()
+ , t = this.getShaderContext();
+ e.activeTexture(e.TEXTURE1),
+ r = (0,
+ image_shader_context_1$1.assertNotNull)(e.createTexture(), "Failed to create texture"),
+ e.bindTexture(e.TEXTURE_2D, r),
+ e.texImage2D(e.TEXTURE_2D, 0, e.R32F, this.width, this.height, 0, e.RED, e.FLOAT, null),
+ e.bindTexture(e.TEXTURE_2D, null),
+ t.bindFramebuffer(e, r),
+ t.run(e, !1, (()=>{
+ this.bindTexture(),
+ e.clearColor(0, 0, 0, 0),
+ e.clear(e.COLOR_BUFFER_BIT),
+ e.drawArrays(e.TRIANGLE_FAN, 0, 4),
+ this.unbindTexture()
+ }
+ )),
+ t.unbindFramebuffer(),
+ this.unbindTexture()
+ }
+ }
+ e.push(r)
+ }
+ return new MPMask$1(e,this.hasWebGLTexture(),this.canvas,this.shaderContext,this.width,this.height)
+ }
+ getGL() {
+ if (!this.canvas)
+ throw new Error("Conversion to different image formats require that a canvas is passed when iniitializing the image.");
+ this.gl || (this.gl = (0,
+ image_shader_context_1$1.assertNotNull)(this.canvas.getContext("webgl2"), "You cannot use a canvas that is already bound to a different type of rendering context."));
+ if (!this.gl.getExtension("EXT_color_buffer_float"))
+ throw new Error("Missing required EXT_color_buffer_float extension");
+ return this.gl
+ }
+ getShaderContext() {
+ return this.shaderContext || (this.shaderContext = new image_shader_context_1$1.MPImageShaderContext),
+ this.shaderContext
+ }
+ convertToFloat32Array() {
+ let e = this.getContainer(MPMaskType.FLOAT32_ARRAY);
+ if (!e) {
+ const t = this.getContainer(MPMaskType.UINT8_ARRAY);
+ if (t)
+ e = new Float32Array(t).map((e=>e / 255));
+ else {
+ const t = this.getGL()
+ , r = this.getShaderContext();
+ e = new Float32Array(this.width * this.height);
+ const o = this.convertToWebGLTexture();
+ r.bindFramebuffer(t, o),
+ t.readPixels(0, 0, this.width, this.height, t.RED, t.FLOAT, e),
+ r.unbindFramebuffer()
+ }
+ this.containers.push(e)
+ }
+ return e
+ }
+ convertToUint8Array() {
+ let e = this.getContainer(MPMaskType.UINT8_ARRAY);
+ if (!e) {
+ const t = this.convertToFloat32Array();
+ e = new Uint8Array(t.map((e=>255 * e))),
+ this.containers.push(e)
+ }
+ return e
+ }
+ convertToWebGLTexture() {
+ let e = this.getContainer(MPMaskType.WEBGL_TEXTURE);
+ if (!e) {
+ const t = this.getGL();
+ e = this.bindTexture();
+ const r = this.convertToFloat32Array();
+ t.texImage2D(t.TEXTURE_2D, 0, t.R32F, this.width, this.height, 0, t.RED, t.FLOAT, r),
+ this.unbindTexture()
+ }
+ return e
+ }
+ bindTexture() {
+ const e = this.getGL();
+ e.viewport(0, 0, this.width, this.height),
+ e.activeTexture(e.TEXTURE0);
+ let t = this.getContainer(MPMaskType.WEBGL_TEXTURE);
+ return t || (t = (0,
+ image_shader_context_1$1.assertNotNull)(e.createTexture(), "Failed to create texture"),
+ this.containers.push(t),
+ this.ownsWebGLTexture = !0),
+ e.bindTexture(e.TEXTURE_2D, t),
+ e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE),
+ e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE),
+ e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST),
+ e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST),
+ t
+ }
+ unbindTexture() {
+ this.gl.bindTexture(this.gl.TEXTURE_2D, null)
+ }
+ close() {
+ if (this.ownsWebGLTexture) {
+ this.getGL().deleteTexture(this.getContainer(MPMaskType.WEBGL_TEXTURE))
+ }
+ }
+}
+mask.MPMask = MPMask$1;
+var face_detector = {}
+ , calculator_pb = {}
+ , googleProtobuf = {};
+(function(exports) {
+ var $jscomp = $jscomp || {};
+ $jscomp.scope = {},
+ $jscomp.findInternal = function(e, t, r) {
+ e instanceof String && (e = String(e));
+ for (var o = e.length, i = 0; i < o; i++) {
+ var a = e[i];
+ if (t.call(r, a, i, e))
+ return {
+ i: i,
+ v: a
+ }
+ }
+ return {
+ i: -1,
+ v: void 0
+ }
+ }
+ ,
+ $jscomp.ASSUME_ES5 = !1,
+ $jscomp.ASSUME_NO_NATIVE_MAP = !1,
+ $jscomp.ASSUME_NO_NATIVE_SET = !1,
+ $jscomp.SIMPLE_FROUND_POLYFILL = !1,
+ $jscomp.defineProperty = $jscomp.ASSUME_ES5 || "function" == typeof Object.defineProperties ? Object.defineProperty : function(e, t, r) {
+ e != Array.prototype && e != Object.prototype && (e[t] = r.value)
+ }
+ ,
+ $jscomp.getGlobal = function(e) {
+ return "undefined" != typeof window && window === e ? e : void 0 !== commonjsGlobal && null != commonjsGlobal ? commonjsGlobal : e
+ }
+ ,
+ $jscomp.global = $jscomp.getGlobal(commonjsGlobal),
+ $jscomp.polyfill = function(e, t, r, o) {
+ if (t) {
+ for (r = $jscomp.global,
+ e = e.split("."),
+ o = 0; o < e.length - 1; o++) {
+ var i = e[o];
+ i in r || (r[i] = {}),
+ r = r[i]
+ }
+ (t = t(o = r[e = e[e.length - 1]])) != o && null != t && $jscomp.defineProperty(r, e, {
+ configurable: !0,
+ writable: !0,
+ value: t
+ })
+ }
+ }
+ ,
+ $jscomp.polyfill("Array.prototype.findIndex", (function(e) {
+ return e || function(e, t) {
+ return $jscomp.findInternal(this, e, t).i
+ }
+ }
+ ), "es6", "es3"),
+ $jscomp.checkStringArgs = function(e, t, r) {
+ if (null == e)
+ throw new TypeError("The 'this' value for String.prototype." + r + " must not be null or undefined");
+ if (t instanceof RegExp)
+ throw new TypeError("First argument to String.prototype." + r + " must not be a regular expression");
+ return e + ""
+ }
+ ,
+ $jscomp.polyfill("String.prototype.endsWith", (function(e) {
+ return e || function(e, t) {
+ var r = $jscomp.checkStringArgs(this, e, "endsWith");
+ e += "",
+ void 0 === t && (t = r.length),
+ t = Math.max(0, Math.min(0 | t, r.length));
+ for (var o = e.length; 0 < o && 0 < t; )
+ if (r[--t] != e[--o])
+ return !1;
+ return 0 >= o
+ }
+ }
+ ), "es6", "es3"),
+ $jscomp.polyfill("Array.prototype.find", (function(e) {
+ return e || function(e, t) {
+ return $jscomp.findInternal(this, e, t).v
+ }
+ }
+ ), "es6", "es3"),
+ $jscomp.polyfill("String.prototype.startsWith", (function(e) {
+ return e || function(e, t) {
+ var r = $jscomp.checkStringArgs(this, e, "startsWith");
+ e += "";
+ var o = r.length
+ , i = e.length;
+ t = Math.max(0, Math.min(0 | t, r.length));
+ for (var a = 0; a < i && t < o; )
+ if (r[t++] != e[a++])
+ return !1;
+ return a >= i
+ }
+ }
+ ), "es6", "es3"),
+ $jscomp.polyfill("String.prototype.repeat", (function(e) {
+ return e || function(e) {
+ var t = $jscomp.checkStringArgs(this, null, "repeat");
+ if (0 > e || 1342177279 < e)
+ throw new RangeError("Invalid count value");
+ e |= 0;
+ for (var r = ""; e; )
+ 1 & e && (r += t),
+ (e >>>= 1) && (t += t);
+ return r
+ }
+ }
+ ), "es6", "es3");
+ var COMPILED = !0
+ , goog = goog || {};
+ goog.global = commonjsGlobal || self,
+ goog.exportPath_ = function(e, t, r) {
+ e = e.split("."),
+ r = r || goog.global,
+ e[0]in r || void 0 === r.execScript || r.execScript("var " + e[0]);
+ for (var o; e.length && (o = e.shift()); )
+ e.length || void 0 === t ? r = r[o] && r[o] !== Object.prototype[o] ? r[o] : r[o] = {} : r[o] = t
+ }
+ ,
+ goog.define = function(e, t) {
+ return t
+ }
+ ,
+ goog.FEATURESET_YEAR = 2012,
+ goog.DEBUG = !0,
+ goog.LOCALE = "en",
+ goog.TRUSTED_SITE = !0,
+ goog.STRICT_MODE_COMPATIBLE = !1,
+ goog.DISALLOW_TEST_ONLY_CODE = !goog.DEBUG,
+ goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING = !1,
+ goog.provide = function(e) {
+ if (goog.isInModuleLoader_())
+ throw Error("goog.provide cannot be used within a module.");
+ goog.constructNamespace_(e)
+ }
+ ,
+ goog.constructNamespace_ = function(e, t) {
+ goog.exportPath_(e, t)
+ }
+ ,
+ goog.getScriptNonce = function(e) {
+ return e && e != goog.global ? goog.getScriptNonce_(e.document) : (null === goog.cspNonce_ && (goog.cspNonce_ = goog.getScriptNonce_(goog.global.document)),
+ goog.cspNonce_)
+ }
+ ,
+ goog.NONCE_PATTERN_ = /^[\w+/_-]+[=]{0,2}$/,
+ goog.cspNonce_ = null,
+ goog.getScriptNonce_ = function(e) {
+ return (e = e.querySelector && e.querySelector("script[nonce]")) && (e = e.nonce || e.getAttribute("nonce")) && goog.NONCE_PATTERN_.test(e) ? e : ""
+ }
+ ,
+ goog.VALID_MODULE_RE_ = /^[a-zA-Z_$][a-zA-Z0-9._$]*$/,
+ goog.module = function(e) {
+ if ("string" != typeof e || !e || -1 == e.search(goog.VALID_MODULE_RE_))
+ throw Error("Invalid module identifier");
+ if (!goog.isInGoogModuleLoader_())
+ throw Error("Module " + e + " has been loaded incorrectly. Note, modules cannot be loaded as normal scripts. They require some kind of pre-processing step. You're likely trying to load a module via a script tag or as a part of a concatenated bundle without rewriting the module. For more info see: https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide.");
+ if (goog.moduleLoaderState_.moduleName)
+ throw Error("goog.module may only be called once per module.");
+ goog.moduleLoaderState_.moduleName = e
+ }
+ ,
+ goog.module.get = function(e) {
+ return goog.module.getInternal_(e)
+ }
+ ,
+ goog.module.getInternal_ = function(e) {
+ return null
+ }
+ ,
+ goog.ModuleType = {
+ ES6: "es6",
+ GOOG: "goog"
+ },
+ goog.moduleLoaderState_ = null,
+ goog.isInModuleLoader_ = function() {
+ return goog.isInGoogModuleLoader_() || goog.isInEs6ModuleLoader_()
+ }
+ ,
+ goog.isInGoogModuleLoader_ = function() {
+ return !!goog.moduleLoaderState_ && goog.moduleLoaderState_.type == goog.ModuleType.GOOG
+ }
+ ,
+ goog.isInEs6ModuleLoader_ = function() {
+ if (goog.moduleLoaderState_ && goog.moduleLoaderState_.type == goog.ModuleType.ES6)
+ return !0;
+ var e = goog.global.$jscomp;
+ return !!e && ("function" == typeof e.getCurrentModulePath && !!e.getCurrentModulePath())
+ }
+ ,
+ goog.module.declareLegacyNamespace = function() {
+ goog.moduleLoaderState_.declareLegacyNamespace = !0
+ }
+ ,
+ goog.declareModuleId = function(e) {
+ if (goog.moduleLoaderState_)
+ goog.moduleLoaderState_.moduleName = e;
+ else {
+ var t = goog.global.$jscomp;
+ if (!t || "function" != typeof t.getCurrentModulePath)
+ throw Error('Module with namespace "' + e + '" has been loaded incorrectly.');
+ t = t.require(t.getCurrentModulePath()),
+ goog.loadedModules_[e] = {
+ exports: t,
+ type: goog.ModuleType.ES6,
+ moduleId: e
+ }
+ }
+ }
+ ,
+ goog.setTestOnly = function(e) {
+ if (goog.DISALLOW_TEST_ONLY_CODE)
+ throw e = e || "",
+ Error("Importing test-only code into non-debug environment" + (e ? ": " + e : "."))
+ }
+ ,
+ goog.forwardDeclare = function(e) {}
+ ,
+ goog.getObjectByName = function(e, t) {
+ e = e.split("."),
+ t = t || goog.global;
+ for (var r = 0; r < e.length; r++)
+ if (null == (t = t[e[r]]))
+ return null;
+ return t
+ }
+ ,
+ goog.globalize = function(e, t) {
+ for (var r in t = t || goog.global,
+ e)
+ t[r] = e[r]
+ }
+ ,
+ goog.addDependency = function(e, t, r, o) {}
+ ,
+ goog.ENABLE_DEBUG_LOADER = !0,
+ goog.logToConsole_ = function(e) {
+ goog.global.console && goog.global.console.error(e)
+ }
+ ,
+ goog.require = function(e) {}
+ ,
+ goog.requireType = function(e) {
+ return {}
+ }
+ ,
+ goog.basePath = "",
+ goog.nullFunction = function() {}
+ ,
+ goog.abstractMethod = function() {
+ throw Error("unimplemented abstract method")
+ }
+ ,
+ goog.addSingletonGetter = function(e) {
+ e.instance_ = void 0,
+ e.getInstance = function() {
+ return e.instance_ ? e.instance_ : (goog.DEBUG && (goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = e),
+ e.instance_ = new e)
+ }
+ }
+ ,
+ goog.instantiatedSingletons_ = [],
+ goog.LOAD_MODULE_USING_EVAL = !0,
+ goog.SEAL_MODULE_EXPORTS = goog.DEBUG,
+ goog.loadedModules_ = {},
+ goog.DEPENDENCIES_ENABLED = !COMPILED,
+ goog.TRANSPILE = "detect",
+ goog.ASSUME_ES_MODULES_TRANSPILED = !1,
+ goog.TRANSPILE_TO_LANGUAGE = "",
+ goog.TRANSPILER = "transpile.js",
+ goog.hasBadLetScoping = null,
+ goog.useSafari10Workaround = function() {
+ if (null == goog.hasBadLetScoping) {
+ try {
+ var a = !eval('"use strict";let x = 1; function f() { return typeof x; };f() == "number";')
+ } catch (e) {
+ a = !1
+ }
+ goog.hasBadLetScoping = a
+ }
+ return goog.hasBadLetScoping
+ }
+ ,
+ goog.workaroundSafari10EvalBug = function(e) {
+ return "(function(){" + e + "\n;})();\n"
+ }
+ ,
+ goog.loadModule = function(e) {
+ var t = goog.moduleLoaderState_;
+ try {
+ if (goog.moduleLoaderState_ = {
+ moduleName: "",
+ declareLegacyNamespace: !1,
+ type: goog.ModuleType.GOOG
+ },
+ goog.isFunction(e))
+ var r = e.call(void 0, {});
+ else {
+ if ("string" != typeof e)
+ throw Error("Invalid module definition");
+ goog.useSafari10Workaround() && (e = goog.workaroundSafari10EvalBug(e)),
+ r = goog.loadModuleFromSource_.call(void 0, e)
+ }
+ var o = goog.moduleLoaderState_.moduleName;
+ if ("string" != typeof o || !o)
+ throw Error('Invalid module name "' + o + '"');
+ goog.moduleLoaderState_.declareLegacyNamespace ? goog.constructNamespace_(o, r) : goog.SEAL_MODULE_EXPORTS && Object.seal && "object" == typeof r && null != r && Object.seal(r),
+ goog.loadedModules_[o] = {
+ exports: r,
+ type: goog.ModuleType.GOOG,
+ moduleId: goog.moduleLoaderState_.moduleName
+ }
+ } finally {
+ goog.moduleLoaderState_ = t
+ }
+ }
+ ,
+ goog.loadModuleFromSource_ = function(a) {
+ return eval(a),
+ {}
+ }
+ ,
+ goog.normalizePath_ = function(e) {
+ e = e.split("/");
+ for (var t = 0; t < e.length; )
+ "." == e[t] ? e.splice(t, 1) : t && ".." == e[t] && e[t - 1] && ".." != e[t - 1] ? e.splice(--t, 2) : t++;
+ return e.join("/")
+ }
+ ,
+ goog.loadFileSync_ = function(e) {
+ if (goog.global.CLOSURE_LOAD_FILE_SYNC)
+ return goog.global.CLOSURE_LOAD_FILE_SYNC(e);
+ try {
+ var t = new goog.global.XMLHttpRequest;
+ return t.open("get", e, !1),
+ t.send(),
+ 0 == t.status || 200 == t.status ? t.responseText : null
+ } catch (e) {
+ return null
+ }
+ }
+ ,
+ goog.transpile_ = function(e, t, r) {
+ var o = goog.global.$jscomp;
+ o || (goog.global.$jscomp = o = {});
+ var i = o.transpile;
+ if (!i) {
+ var a = goog.basePath + goog.TRANSPILER
+ , n = goog.loadFileSync_(a);
+ if (n) {
+ if (function() {
+ (0,
+ eval)(n + "\n//# sourceURL=" + a)
+ }
+ .call(goog.global),
+ goog.global.$gwtExport && goog.global.$gwtExport.$jscomp && !goog.global.$gwtExport.$jscomp.transpile)
+ throw Error('The transpiler did not properly export the "transpile" method. $gwtExport: ' + JSON.stringify(goog.global.$gwtExport));
+ goog.global.$jscomp.transpile = goog.global.$gwtExport.$jscomp.transpile,
+ i = (o = goog.global.$jscomp).transpile
+ }
+ }
+ return i || (i = o.transpile = function(e, t) {
+ return goog.logToConsole_(t + " requires transpilation but no transpiler was found."),
+ e
+ }
+ ),
+ i(e, t, r)
+ }
+ ,
+ goog.typeOf = function(e) {
+ var t = typeof e;
+ if ("object" == t) {
+ if (!e)
+ return "null";
+ if (e instanceof Array)
+ return "array";
+ if (e instanceof Object)
+ return t;
+ var r = Object.prototype.toString.call(e);
+ if ("[object Window]" == r)
+ return "object";
+ if ("[object Array]" == r || "number" == typeof e.length && void 0 !== e.splice && void 0 !== e.propertyIsEnumerable && !e.propertyIsEnumerable("splice"))
+ return "array";
+ if ("[object Function]" == r || void 0 !== e.call && void 0 !== e.propertyIsEnumerable && !e.propertyIsEnumerable("call"))
+ return "function"
+ } else if ("function" == t && void 0 === e.call)
+ return "object";
+ return t
+ }
+ ,
+ goog.isArray = function(e) {
+ return "array" == goog.typeOf(e)
+ }
+ ,
+ goog.isArrayLike = function(e) {
+ var t = goog.typeOf(e);
+ return "array" == t || "object" == t && "number" == typeof e.length
+ }
+ ,
+ goog.isDateLike = function(e) {
+ return goog.isObject(e) && "function" == typeof e.getFullYear
+ }
+ ,
+ goog.isFunction = function(e) {
+ return "function" == goog.typeOf(e)
+ }
+ ,
+ goog.isObject = function(e) {
+ var t = typeof e;
+ return "object" == t && null != e || "function" == t
+ }
+ ,
+ goog.getUid = function(e) {
+ return Object.prototype.hasOwnProperty.call(e, goog.UID_PROPERTY_) && e[goog.UID_PROPERTY_] || (e[goog.UID_PROPERTY_] = ++goog.uidCounter_)
+ }
+ ,
+ goog.hasUid = function(e) {
+ return !!e[goog.UID_PROPERTY_]
+ }
+ ,
+ goog.removeUid = function(e) {
+ null !== e && "removeAttribute"in e && e.removeAttribute(goog.UID_PROPERTY_);
+ try {
+ delete e[goog.UID_PROPERTY_]
+ } catch (e) {}
+ }
+ ,
+ goog.UID_PROPERTY_ = "closure_uid_" + (1e9 * Math.random() >>> 0),
+ goog.uidCounter_ = 0,
+ goog.getHashCode = goog.getUid,
+ goog.removeHashCode = goog.removeUid,
+ goog.cloneObject = function(e) {
+ var t = goog.typeOf(e);
+ if ("object" == t || "array" == t) {
+ if ("function" == typeof e.clone)
+ return e.clone();
+ for (var r in t = "array" == t ? [] : {},
+ e)
+ t[r] = goog.cloneObject(e[r]);
+ return t
+ }
+ return e
+ }
+ ,
+ goog.bindNative_ = function(e, t, r) {
+ return e.call.apply(e.bind, arguments)
+ }
+ ,
+ goog.bindJs_ = function(e, t, r) {
+ if (!e)
+ throw Error();
+ if (2 < arguments.length) {
+ var o = Array.prototype.slice.call(arguments, 2);
+ return function() {
+ var r = Array.prototype.slice.call(arguments);
+ return Array.prototype.unshift.apply(r, o),
+ e.apply(t, r)
+ }
+ }
+ return function() {
+ return e.apply(t, arguments)
+ }
+ }
+ ,
+ goog.bind = function(e, t, r) {
+ return Function.prototype.bind && -1 != Function.prototype.bind.toString().indexOf("native code") ? goog.bind = goog.bindNative_ : goog.bind = goog.bindJs_,
+ goog.bind.apply(null, arguments)
+ }
+ ,
+ goog.partial = function(e, t) {
+ var r = Array.prototype.slice.call(arguments, 1);
+ return function() {
+ var t = r.slice();
+ return t.push.apply(t, arguments),
+ e.apply(this, t)
+ }
+ }
+ ,
+ goog.mixin = function(e, t) {
+ for (var r in t)
+ e[r] = t[r]
+ }
+ ,
+ goog.now = goog.TRUSTED_SITE && Date.now || function() {
+ return +new Date
+ }
+ ,
+ goog.globalEval = function(e) {
+ if (goog.global.execScript)
+ goog.global.execScript(e, "JavaScript");
+ else {
+ if (!goog.global.eval)
+ throw Error("goog.globalEval not available");
+ if (null == goog.evalWorksForGlobals_) {
+ try {
+ goog.global.eval("var _evalTest_ = 1;")
+ } catch (e) {}
+ if (void 0 !== goog.global._evalTest_) {
+ try {
+ delete goog.global._evalTest_
+ } catch (e) {}
+ goog.evalWorksForGlobals_ = !0
+ } else
+ goog.evalWorksForGlobals_ = !1
+ }
+ if (goog.evalWorksForGlobals_)
+ goog.global.eval(e);
+ else {
+ var t = goog.global.document
+ , r = t.createElement("script");
+ r.type = "text/javascript",
+ r.defer = !1,
+ r.appendChild(t.createTextNode(e)),
+ t.head.appendChild(r),
+ t.head.removeChild(r)
+ }
+ }
+ }
+ ,
+ goog.evalWorksForGlobals_ = null,
+ goog.getCssName = function(e, t) {
+ if ("." == String(e).charAt(0))
+ throw Error('className passed in goog.getCssName must not start with ".". You passed: ' + e);
+ var r = function(e) {
+ return goog.cssNameMapping_[e] || e
+ }
+ , o = function(e) {
+ e = e.split("-");
+ for (var t = [], o = 0; o < e.length; o++)
+ t.push(r(e[o]));
+ return t.join("-")
+ };
+ return o = goog.cssNameMapping_ ? "BY_WHOLE" == goog.cssNameMappingStyle_ ? r : o : function(e) {
+ return e
+ }
+ ,
+ e = t ? e + "-" + o(t) : o(e),
+ goog.global.CLOSURE_CSS_NAME_MAP_FN ? goog.global.CLOSURE_CSS_NAME_MAP_FN(e) : e
+ }
+ ,
+ goog.setCssNameMapping = function(e, t) {
+ goog.cssNameMapping_ = e,
+ goog.cssNameMappingStyle_ = t
+ }
+ ,
+ goog.getMsg = function(e, t, r) {
+ return r && r.html && (e = e.replace(/ r ? Math.max(0, e.length + r) : r,
+ "string" == typeof e)
+ return "string" != typeof t || 1 != t.length ? -1 : e.indexOf(t, r);
+ for (; r < e.length; r++)
+ if (r in e && e[r] === t)
+ return r;
+ return -1
+ }
+ ,
+ goog.array.lastIndexOf = goog.NATIVE_ARRAY_PROTOTYPES && (goog.array.ASSUME_NATIVE_FUNCTIONS || Array.prototype.lastIndexOf) ? function(e, t, r) {
+ return goog.asserts.assert(null != e.length),
+ Array.prototype.lastIndexOf.call(e, t, null == r ? e.length - 1 : r)
+ }
+ : function(e, t, r) {
+ if (0 > (r = null == r ? e.length - 1 : r) && (r = Math.max(0, e.length + r)),
+ "string" == typeof e)
+ return "string" != typeof t || 1 != t.length ? -1 : e.lastIndexOf(t, r);
+ for (; 0 <= r; r--)
+ if (r in e && e[r] === t)
+ return r;
+ return -1
+ }
+ ,
+ goog.array.forEach = goog.NATIVE_ARRAY_PROTOTYPES && (goog.array.ASSUME_NATIVE_FUNCTIONS || Array.prototype.forEach) ? function(e, t, r) {
+ goog.asserts.assert(null != e.length),
+ Array.prototype.forEach.call(e, t, r)
+ }
+ : function(e, t, r) {
+ for (var o = e.length, i = "string" == typeof e ? e.split("") : e, a = 0; a < o; a++)
+ a in i && t.call(r, i[a], a, e)
+ }
+ ,
+ goog.array.forEachRight = function(e, t, r) {
+ var o = e.length
+ , i = "string" == typeof e ? e.split("") : e;
+ for (--o; 0 <= o; --o)
+ o in i && t.call(r, i[o], o, e)
+ }
+ ,
+ goog.array.filter = goog.NATIVE_ARRAY_PROTOTYPES && (goog.array.ASSUME_NATIVE_FUNCTIONS || Array.prototype.filter) ? function(e, t, r) {
+ return goog.asserts.assert(null != e.length),
+ Array.prototype.filter.call(e, t, r)
+ }
+ : function(e, t, r) {
+ for (var o = e.length, i = [], a = 0, n = "string" == typeof e ? e.split("") : e, s = 0; s < o; s++)
+ if (s in n) {
+ var p = n[s];
+ t.call(r, p, s, e) && (i[a++] = p)
+ }
+ return i
+ }
+ ,
+ goog.array.map = goog.NATIVE_ARRAY_PROTOTYPES && (goog.array.ASSUME_NATIVE_FUNCTIONS || Array.prototype.map) ? function(e, t, r) {
+ return goog.asserts.assert(null != e.length),
+ Array.prototype.map.call(e, t, r)
+ }
+ : function(e, t, r) {
+ for (var o = e.length, i = Array(o), a = "string" == typeof e ? e.split("") : e, n = 0; n < o; n++)
+ n in a && (i[n] = t.call(r, a[n], n, e));
+ return i
+ }
+ ,
+ goog.array.reduce = goog.NATIVE_ARRAY_PROTOTYPES && (goog.array.ASSUME_NATIVE_FUNCTIONS || Array.prototype.reduce) ? function(e, t, r, o) {
+ return goog.asserts.assert(null != e.length),
+ o && (t = goog.bind(t, o)),
+ Array.prototype.reduce.call(e, t, r)
+ }
+ : function(e, t, r, o) {
+ var i = r;
+ return goog.array.forEach(e, (function(r, a) {
+ i = t.call(o, i, r, a, e)
+ }
+ )),
+ i
+ }
+ ,
+ goog.array.reduceRight = goog.NATIVE_ARRAY_PROTOTYPES && (goog.array.ASSUME_NATIVE_FUNCTIONS || Array.prototype.reduceRight) ? function(e, t, r, o) {
+ return goog.asserts.assert(null != e.length),
+ goog.asserts.assert(null != t),
+ o && (t = goog.bind(t, o)),
+ Array.prototype.reduceRight.call(e, t, r)
+ }
+ : function(e, t, r, o) {
+ var i = r;
+ return goog.array.forEachRight(e, (function(r, a) {
+ i = t.call(o, i, r, a, e)
+ }
+ )),
+ i
+ }
+ ,
+ goog.array.some = goog.NATIVE_ARRAY_PROTOTYPES && (goog.array.ASSUME_NATIVE_FUNCTIONS || Array.prototype.some) ? function(e, t, r) {
+ return goog.asserts.assert(null != e.length),
+ Array.prototype.some.call(e, t, r)
+ }
+ : function(e, t, r) {
+ for (var o = e.length, i = "string" == typeof e ? e.split("") : e, a = 0; a < o; a++)
+ if (a in i && t.call(r, i[a], a, e))
+ return !0;
+ return !1
+ }
+ ,
+ goog.array.every = goog.NATIVE_ARRAY_PROTOTYPES && (goog.array.ASSUME_NATIVE_FUNCTIONS || Array.prototype.every) ? function(e, t, r) {
+ return goog.asserts.assert(null != e.length),
+ Array.prototype.every.call(e, t, r)
+ }
+ : function(e, t, r) {
+ for (var o = e.length, i = "string" == typeof e ? e.split("") : e, a = 0; a < o; a++)
+ if (a in i && !t.call(r, i[a], a, e))
+ return !1;
+ return !0
+ }
+ ,
+ goog.array.count = function(e, t, r) {
+ var o = 0;
+ return goog.array.forEach(e, (function(e, i, a) {
+ t.call(r, e, i, a) && ++o
+ }
+ ), r),
+ o
+ }
+ ,
+ goog.array.find = function(e, t, r) {
+ return 0 > (t = goog.array.findIndex(e, t, r)) ? null : "string" == typeof e ? e.charAt(t) : e[t]
+ }
+ ,
+ goog.array.findIndex = function(e, t, r) {
+ for (var o = e.length, i = "string" == typeof e ? e.split("") : e, a = 0; a < o; a++)
+ if (a in i && t.call(r, i[a], a, e))
+ return a;
+ return -1
+ }
+ ,
+ goog.array.findRight = function(e, t, r) {
+ return 0 > (t = goog.array.findIndexRight(e, t, r)) ? null : "string" == typeof e ? e.charAt(t) : e[t]
+ }
+ ,
+ goog.array.findIndexRight = function(e, t, r) {
+ var o = e.length
+ , i = "string" == typeof e ? e.split("") : e;
+ for (--o; 0 <= o; o--)
+ if (o in i && t.call(r, i[o], o, e))
+ return o;
+ return -1
+ }
+ ,
+ goog.array.contains = function(e, t) {
+ return 0 <= goog.array.indexOf(e, t)
+ }
+ ,
+ goog.array.isEmpty = function(e) {
+ return 0 == e.length
+ }
+ ,
+ goog.array.clear = function(e) {
+ if (!Array.isArray(e))
+ for (var t = e.length - 1; 0 <= t; t--)
+ delete e[t];
+ e.length = 0
+ }
+ ,
+ goog.array.insert = function(e, t) {
+ goog.array.contains(e, t) || e.push(t)
+ }
+ ,
+ goog.array.insertAt = function(e, t, r) {
+ goog.array.splice(e, r, 0, t)
+ }
+ ,
+ goog.array.insertArrayAt = function(e, t, r) {
+ goog.partial(goog.array.splice, e, r, 0).apply(null, t)
+ }
+ ,
+ goog.array.insertBefore = function(e, t, r) {
+ var o;
+ 2 == arguments.length || 0 > (o = goog.array.indexOf(e, r)) ? e.push(t) : goog.array.insertAt(e, t, o)
+ }
+ ,
+ goog.array.remove = function(e, t) {
+ var r;
+ return (r = 0 <= (t = goog.array.indexOf(e, t))) && goog.array.removeAt(e, t),
+ r
+ }
+ ,
+ goog.array.removeLast = function(e, t) {
+ return 0 <= (t = goog.array.lastIndexOf(e, t)) && (goog.array.removeAt(e, t),
+ !0)
+ }
+ ,
+ goog.array.removeAt = function(e, t) {
+ return goog.asserts.assert(null != e.length),
+ 1 == Array.prototype.splice.call(e, t, 1).length
+ }
+ ,
+ goog.array.removeIf = function(e, t, r) {
+ return 0 <= (t = goog.array.findIndex(e, t, r)) && (goog.array.removeAt(e, t),
+ !0)
+ }
+ ,
+ goog.array.removeAllIf = function(e, t, r) {
+ var o = 0;
+ return goog.array.forEachRight(e, (function(i, a) {
+ t.call(r, i, a, e) && goog.array.removeAt(e, a) && o++
+ }
+ )),
+ o
+ }
+ ,
+ goog.array.concat = function(e) {
+ return Array.prototype.concat.apply([], arguments)
+ }
+ ,
+ goog.array.join = function(e) {
+ return Array.prototype.concat.apply([], arguments)
+ }
+ ,
+ goog.array.toArray = function(e) {
+ var t = e.length;
+ if (0 < t) {
+ for (var r = Array(t), o = 0; o < t; o++)
+ r[o] = e[o];
+ return r
+ }
+ return []
+ }
+ ,
+ goog.array.clone = goog.array.toArray,
+ goog.array.extend = function(e, t) {
+ for (var r = 1; r < arguments.length; r++) {
+ var o = arguments[r];
+ if (goog.isArrayLike(o)) {
+ var i = e.length || 0
+ , a = o.length || 0;
+ e.length = i + a;
+ for (var n = 0; n < a; n++)
+ e[i + n] = o[n]
+ } else
+ e.push(o)
+ }
+ }
+ ,
+ goog.array.splice = function(e, t, r, o) {
+ return goog.asserts.assert(null != e.length),
+ Array.prototype.splice.apply(e, goog.array.slice(arguments, 1))
+ }
+ ,
+ goog.array.slice = function(e, t, r) {
+ return goog.asserts.assert(null != e.length),
+ 2 >= arguments.length ? Array.prototype.slice.call(e, t) : Array.prototype.slice.call(e, t, r)
+ }
+ ,
+ goog.array.removeDuplicates = function(e, t, r) {
+ t = t || e;
+ var o = function(e) {
+ return goog.isObject(e) ? "o" + goog.getUid(e) : (typeof e).charAt(0) + e
+ };
+ r = r || o,
+ o = {};
+ for (var i = 0, a = 0; a < e.length; ) {
+ var n = e[a++]
+ , s = r(n);
+ Object.prototype.hasOwnProperty.call(o, s) || (o[s] = !0,
+ t[i++] = n)
+ }
+ t.length = i
+ }
+ ,
+ goog.array.binarySearch = function(e, t, r) {
+ return goog.array.binarySearch_(e, r || goog.array.defaultCompare, !1, t)
+ }
+ ,
+ goog.array.binarySelect = function(e, t, r) {
+ return goog.array.binarySearch_(e, t, !0, void 0, r)
+ }
+ ,
+ goog.array.binarySearch_ = function(e, t, r, o, i) {
+ for (var a, n = 0, s = e.length; n < s; ) {
+ var p = n + (s - n >>> 1)
+ , d = r ? t.call(i, e[p], p, e) : t(o, e[p]);
+ 0 < d ? n = p + 1 : (s = p,
+ a = !d)
+ }
+ return a ? n : -n - 1
+ }
+ ,
+ goog.array.sort = function(e, t) {
+ e.sort(t || goog.array.defaultCompare)
+ }
+ ,
+ goog.array.stableSort = function(e, t) {
+ for (var r = Array(e.length), o = 0; o < e.length; o++)
+ r[o] = {
+ index: o,
+ value: e[o]
+ };
+ var i = t || goog.array.defaultCompare;
+ for (goog.array.sort(r, (function(e, t) {
+ return i(e.value, t.value) || e.index - t.index
+ }
+ )),
+ o = 0; o < e.length; o++)
+ e[o] = r[o].value
+ }
+ ,
+ goog.array.sortByKey = function(e, t, r) {
+ var o = r || goog.array.defaultCompare;
+ goog.array.sort(e, (function(e, r) {
+ return o(t(e), t(r))
+ }
+ ))
+ }
+ ,
+ goog.array.sortObjectsByKey = function(e, t, r) {
+ goog.array.sortByKey(e, (function(e) {
+ return e[t]
+ }
+ ), r)
+ }
+ ,
+ goog.array.isSorted = function(e, t, r) {
+ t = t || goog.array.defaultCompare;
+ for (var o = 1; o < e.length; o++) {
+ var i = t(e[o - 1], e[o]);
+ if (0 < i || 0 == i && r)
+ return !1
+ }
+ return !0
+ }
+ ,
+ goog.array.equals = function(e, t, r) {
+ if (!goog.isArrayLike(e) || !goog.isArrayLike(t) || e.length != t.length)
+ return !1;
+ var o = e.length;
+ r = r || goog.array.defaultCompareEquality;
+ for (var i = 0; i < o; i++)
+ if (!r(e[i], t[i]))
+ return !1;
+ return !0
+ }
+ ,
+ goog.array.compare3 = function(e, t, r) {
+ r = r || goog.array.defaultCompare;
+ for (var o = Math.min(e.length, t.length), i = 0; i < o; i++) {
+ var a = r(e[i], t[i]);
+ if (0 != a)
+ return a
+ }
+ return goog.array.defaultCompare(e.length, t.length)
+ }
+ ,
+ goog.array.defaultCompare = function(e, t) {
+ return e > t ? 1 : e < t ? -1 : 0
+ }
+ ,
+ goog.array.inverseDefaultCompare = function(e, t) {
+ return -goog.array.defaultCompare(e, t)
+ }
+ ,
+ goog.array.defaultCompareEquality = function(e, t) {
+ return e === t
+ }
+ ,
+ goog.array.binaryInsert = function(e, t, r) {
+ return 0 > (r = goog.array.binarySearch(e, t, r)) && (goog.array.insertAt(e, t, -(r + 1)),
+ !0)
+ }
+ ,
+ goog.array.binaryRemove = function(e, t, r) {
+ return 0 <= (t = goog.array.binarySearch(e, t, r)) && goog.array.removeAt(e, t)
+ }
+ ,
+ goog.array.bucket = function(e, t, r) {
+ for (var o = {}, i = 0; i < e.length; i++) {
+ var a = e[i]
+ , n = t.call(r, a, i, e);
+ void 0 !== n && (o[n] || (o[n] = [])).push(a)
+ }
+ return o
+ }
+ ,
+ goog.array.toObject = function(e, t, r) {
+ var o = {};
+ return goog.array.forEach(e, (function(i, a) {
+ o[t.call(r, i, a, e)] = i
+ }
+ )),
+ o
+ }
+ ,
+ goog.array.range = function(e, t, r) {
+ var o = []
+ , i = 0
+ , a = e;
+ if (void 0 !== t && (i = e,
+ a = t),
+ 0 > (r = r || 1) * (a - i))
+ return [];
+ if (0 < r)
+ for (e = i; e < a; e += r)
+ o.push(e);
+ else
+ for (e = i; e > a; e += r)
+ o.push(e);
+ return o
+ }
+ ,
+ goog.array.repeat = function(e, t) {
+ for (var r = [], o = 0; o < t; o++)
+ r[o] = e;
+ return r
+ }
+ ,
+ goog.array.flatten = function(e) {
+ for (var t = [], r = 0; r < arguments.length; r++) {
+ var o = arguments[r];
+ if (Array.isArray(o))
+ for (var i = 0; i < o.length; i += 8192) {
+ var a = goog.array.slice(o, i, i + 8192);
+ a = goog.array.flatten.apply(null, a);
+ for (var n = 0; n < a.length; n++)
+ t.push(a[n])
+ }
+ else
+ t.push(o)
+ }
+ return t
+ }
+ ,
+ goog.array.rotate = function(e, t) {
+ return goog.asserts.assert(null != e.length),
+ e.length && (0 < (t %= e.length) ? Array.prototype.unshift.apply(e, e.splice(-t, t)) : 0 > t && Array.prototype.push.apply(e, e.splice(0, -t))),
+ e
+ }
+ ,
+ goog.array.moveItem = function(e, t, r) {
+ goog.asserts.assert(0 <= t && t < e.length),
+ goog.asserts.assert(0 <= r && r < e.length),
+ t = Array.prototype.splice.call(e, t, 1),
+ Array.prototype.splice.call(e, r, 0, t[0])
+ }
+ ,
+ goog.array.zip = function(e) {
+ if (!arguments.length)
+ return [];
+ for (var t = [], r = arguments[0].length, o = 1; o < arguments.length; o++)
+ arguments[o].length < r && (r = arguments[o].length);
+ for (o = 0; o < r; o++) {
+ for (var i = [], a = 0; a < arguments.length; a++)
+ i.push(arguments[a][o]);
+ t.push(i)
+ }
+ return t
+ }
+ ,
+ goog.array.shuffle = function(e, t) {
+ t = t || Math.random;
+ for (var r = e.length - 1; 0 < r; r--) {
+ var o = Math.floor(t() * (r + 1))
+ , i = e[r];
+ e[r] = e[o],
+ e[o] = i
+ }
+ }
+ ,
+ goog.array.copyByIndex = function(e, t) {
+ var r = [];
+ return goog.array.forEach(t, (function(t) {
+ r.push(e[t])
+ }
+ )),
+ r
+ }
+ ,
+ goog.array.concatMap = function(e, t, r) {
+ return goog.array.concat.apply([], goog.array.map(e, t, r))
+ }
+ ,
+ goog.crypt = {},
+ goog.crypt.stringToByteArray = function(e) {
+ for (var t = [], r = 0, o = 0; o < e.length; o++) {
+ var i = e.charCodeAt(o);
+ 255 < i && (t[r++] = 255 & i,
+ i >>= 8),
+ t[r++] = i
+ }
+ return t
+ }
+ ,
+ goog.crypt.byteArrayToString = function(e) {
+ if (8192 >= e.length)
+ return String.fromCharCode.apply(null, e);
+ for (var t = "", r = 0; r < e.length; r += 8192) {
+ var o = goog.array.slice(e, r, r + 8192);
+ t += String.fromCharCode.apply(null, o)
+ }
+ return t
+ }
+ ,
+ goog.crypt.byteArrayToHex = function(e, t) {
+ return goog.array.map(e, (function(e) {
+ return 1 < (e = e.toString(16)).length ? e : "0" + e
+ }
+ )).join(t || "")
+ }
+ ,
+ goog.crypt.hexToByteArray = function(e) {
+ goog.asserts.assert(0 == e.length % 2, "Key string length must be multiple of 2");
+ for (var t = [], r = 0; r < e.length; r += 2)
+ t.push(parseInt(e.substring(r, r + 2), 16));
+ return t
+ }
+ ,
+ goog.crypt.stringToUtf8ByteArray = function(e) {
+ for (var t = [], r = 0, o = 0; o < e.length; o++) {
+ var i = e.charCodeAt(o);
+ 128 > i ? t[r++] = i : (2048 > i ? t[r++] = i >> 6 | 192 : (55296 == (64512 & i) && o + 1 < e.length && 56320 == (64512 & e.charCodeAt(o + 1)) ? (i = 65536 + ((1023 & i) << 10) + (1023 & e.charCodeAt(++o)),
+ t[r++] = i >> 18 | 240,
+ t[r++] = i >> 12 & 63 | 128) : t[r++] = i >> 12 | 224,
+ t[r++] = i >> 6 & 63 | 128),
+ t[r++] = 63 & i | 128)
+ }
+ return t
+ }
+ ,
+ goog.crypt.utf8ByteArrayToString = function(e) {
+ for (var t = [], r = 0, o = 0; r < e.length; ) {
+ var i = e[r++];
+ if (128 > i)
+ t[o++] = String.fromCharCode(i);
+ else if (191 < i && 224 > i) {
+ var a = e[r++];
+ t[o++] = String.fromCharCode((31 & i) << 6 | 63 & a)
+ } else if (239 < i && 365 > i) {
+ a = e[r++];
+ var n = e[r++];
+ i = ((7 & i) << 18 | (63 & a) << 12 | (63 & n) << 6 | 63 & e[r++]) - 65536,
+ t[o++] = String.fromCharCode(55296 + (i >> 10)),
+ t[o++] = String.fromCharCode(56320 + (1023 & i))
+ } else
+ a = e[r++],
+ n = e[r++],
+ t[o++] = String.fromCharCode((15 & i) << 12 | (63 & a) << 6 | 63 & n)
+ }
+ return t.join("")
+ }
+ ,
+ goog.crypt.xorByteArray = function(e, t) {
+ goog.asserts.assert(e.length == t.length, "XOR array lengths must match");
+ for (var r = [], o = 0; o < e.length; o++)
+ r.push(e[o] ^ t[o]);
+ return r
+ }
+ ,
+ goog.dom.asserts = {},
+ goog.dom.asserts.assertIsLocation = function(e) {
+ if (goog.asserts.ENABLE_ASSERTS) {
+ var t = goog.dom.asserts.getWindow_(e);
+ t && (!e || !(e instanceof t.Location) && e instanceof t.Element) && goog.asserts.fail("Argument is not a Location (or a non-Element mock); got: %s", goog.dom.asserts.debugStringForType_(e))
+ }
+ return e
+ }
+ ,
+ goog.dom.asserts.assertIsElementType_ = function(e, t) {
+ if (goog.asserts.ENABLE_ASSERTS) {
+ var r = goog.dom.asserts.getWindow_(e);
+ r && void 0 !== r[t] && (e && (e instanceof r[t] || !(e instanceof r.Location || e instanceof r.Element)) || goog.asserts.fail("Argument is not a %s (or a non-Element, non-Location mock); got: %s", t, goog.dom.asserts.debugStringForType_(e)))
+ }
+ return e
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLAnchorElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLAnchorElement")
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLButtonElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLButtonElement")
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLLinkElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLLinkElement")
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLImageElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLImageElement")
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLAudioElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLAudioElement")
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLVideoElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLVideoElement")
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLInputElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLInputElement")
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLTextAreaElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLTextAreaElement")
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLCanvasElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLCanvasElement")
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLEmbedElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLEmbedElement")
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLFormElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLFormElement")
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLFrameElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLFrameElement")
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLIFrameElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLIFrameElement")
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLObjectElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLObjectElement")
+ }
+ ,
+ goog.dom.asserts.assertIsHTMLScriptElement = function(e) {
+ return goog.dom.asserts.assertIsElementType_(e, "HTMLScriptElement")
+ }
+ ,
+ goog.dom.asserts.debugStringForType_ = function(e) {
+ if (!goog.isObject(e))
+ return void 0 === e ? "undefined" : null === e ? "null" : typeof e;
+ try {
+ return e.constructor.displayName || e.constructor.name || Object.prototype.toString.call(e)
+ } catch (e) {
+ return "