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,EAC/C,EAAE,KAAK,UAAU,OAAS,EAAE,KAAK,UAAU,QAAU,EACrD,EAAE,KAAK,UAAU,KACZ,KAAK,aAAe,EAAE,KAAK,UAAU,SAAW,EAErD,EAAE,KAAK,UAAU,IACb,EAAQ,OAAO,KAAK,UAAU,QAC9B,EAAE,KAAK,UAAU,IACjB,EAAE,KAAK,UAAU,QAcrB,IAXA,IAAI,EAAQ,KAAK,MACX,EAAQ,OAAO,KAAK,UAAU,OAAiC,EAAvB,EAAE,KAAK,UAAU,KAC3D,EAAE,KAAK,UAAU,OAAS,EAAK,KAAK,iBAEpC,GACC,EAAQ,OAAO,KAAK,UAAU,OAC3B,EAAE,KAAK,UAAU,QAChB,EAAE,KAAK,UAAU,OAAS,IAC1B,EAAQ,GAGR,EAAI,EAAG,EAAI,EAAO,IACvB,EAAE,KAAK,UAAU,IAAM,EAAE,KAAK,UAAU,KACnC,EAAE,KAAK,UAAU,OAAS,GAAO,EAEtC,EAAE,KAAK,UAAU,IAAM,EAAE,KAAK,UAAU,IACxC,EAAQ,SAAS,EAAE,GAAI,EAAE,GAAI,EAAE,MAAO,EAAE,QACxC,EAAQ,SAAS,EAAE,GAAI,EAAE,GAAI,EAAE,MAAO,EAAE,OAGhD,CAEJ,CAEJ","file":"/npm/filmstrip@0.0.1/filmstrip.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/filmstrip@0.0.1/filmstrip.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\n * Filmstrip.js: an HTML5 video preview widget that will rock your world\n *   Copyright © <2013> Instituto Nacional de Associativismo y Economia Social.\n *   Copyright © <2013> Cooperativa de Trabajo OpCode Limitada <info@opcode.coop>.\n *   Copyright © <2013> Leonardo Vidarte <leo@opcode.coop>\n *\n *  This program is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU Affero General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU Affero General Public License for more details.\n *\n *  You should have received a copy of the GNU Affero General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\n\nvar Filmstrip = function(model, args) {\n\n    this.model = null;\n    this.video = null;\n    this.canvas = null;\n    this.context = null;\n    this._frameHeight = 0;\n    this._frameWidth = 0;\n    this._framePadding = 0;\n    this._count = 0;\n    this._step = 0;\n    this._maxSteps = 0;\n    this._canvasDrawn = false;\n\n    this._createCanvas = function() {\n        return $('<canvas />')\n            .attr({ width: this.width, height: this.height })\n            .get(0);\n    };\n\n    __construct = function(self) {\n        var opts = {\n            width: 80,\n            height: 400,\n            bgColor: '#333',\n            drawBackground: true,\n            drawHoles: true,\n            holesColor: '#222',\n            holesDispersion: .8,\n            bandsPadding: 20,\n            orientation: 'vertical',\n            autoOrientation: true,\n            startAt: 5,\n            strechOnResize: true,\n            autoResize: true,\n        }\n\n        for (opt in opts) {\n            self[opt] = (args[opt] !== undefined) ? args[opt] : opts[opt];\n        }\n\n        self.model = model;\n        self.canvas = self._createCanvas();\n        self.context = self.canvas.getContext('2d');\n    }(this);\n\n    this.load = function() {\n        var self = this;\n        var video = $('<video preload=\"metadata\" />')\n            .attr('src', self.model.src)\n            .bind('loadedmetadata', function() {\n                self.video = this;\n                if (self.autoResize) {\n                    self.resize(self.width, self.height);\n                }\n                $(self).trigger('loaded');\n            })\n            .bind('seeked', function() {\n                self._drawFrame();\n                if (self._count < self._maxSteps - 1) {\n                    self._count++;\n                    self.video.currentTime += self._step;\n                } else {\n                    self.setCanvas(self._tmpCanvas);\n                    self._destroyTmpCanvas();\n                    self._canvasDrawn = true;\n                    $(self).trigger('draw:finished');\n                }\n            });\n    };\n\n    this.resize = function(width, height) {\n        if (width == 0 || height == 0) {\n            return;\n        }\n\n        if (this.autoOrientation) {\n            this.orientation = (width > height * 2) ?\n                'horizontal' :  'vertical';\n        }\n\n        switch (this.orientation) {\n\n            case 'horizontal':\n                this.width = width;\n                if (height !== undefined) {\n                    this.height = height;\n                }\n\n                this.attrTrans = {\n                    x: 'x',\n                    y: 'y',\n                    width: 'width',\n                    height: 'height',\n                    x0: 'x0',\n                    x1: 'x1',\n                    y0: 'y0',\n                    y1: 'y1',\n                    videoWidth: 'videoWidth',\n                    videoHeight: 'videoHeight',\n                    _frameWidth: '_frameWidth',\n                    _frameHeight: '_frameHeight',\n                };\n                break;\n\n            case 'vertical':\n                if (height === undefined) {\n                    this.height = width;\n                } else {\n                    this.width = width;\n                    this.height = height;\n                }\n\n                this.attrTrans = {\n                    x: 'y',\n                    y: 'x',\n                    width: 'height',\n                    height: 'width',\n                    x0: 'y0',\n                    x1: 'y1',\n                    y0: 'x0',\n                    y1: 'x1',\n                    videoWidth: 'videoHeight',\n                    videoHeight: 'videoWidth',\n                    _frameWidth: '_frameHeight',\n                    _frameHeight: '_frameWidth',\n                };\n                break;\n\n        }\n\n        this[this.attrTrans._frameHeight] = (\n            this[this.attrTrans.height] - (this.bandsPadding * 2)\n        );\n        this[this.attrTrans._frameWidth] = Math.ceil(\n            this.video[this.attrTrans.videoWidth] *\n            this[this.attrTrans._frameHeight] /\n            this.video[this.attrTrans.videoHeight]\n        );\n        this._maxSteps = Math.floor(\n            this[this.attrTrans.width] / this[this.attrTrans._frameWidth]\n        );\n        this._framePadding = (\n            (this[this.attrTrans.width] - \n                (this._maxSteps * this[this.attrTrans._frameWidth])\n            ) / (this._maxSteps - 1)\n        );\n\n        this._count = 0;\n        if (this._maxSteps == 1) {\n            this._framePadding = 0;\n            this._step = this.video.duration - (this.startAt * 2);\n        } else {\n            this._step = (\n                (this.video.duration - (this.startAt * 2)) /\n                (this._maxSteps - 1)\n            );\n        }\n\n        if (this._maxSteps) {\n            this._createTmpCanvas();\n            $(this).trigger('draw:started');\n            this.video.currentTime = this.startAt;\n        }\n    };\n\n    this._drawFrame = function() {\n        var _ = {};\n\n        _[this.attrTrans.y] = this.bandsPadding;\n        _[this.attrTrans.x] = this[this.attrTrans._frameWidth] * this._count;\n\n        if (this._maxSteps <= 5) {\n            var extraPadding = (\n                (this[this.attrTrans.width] -\n                    (this[this.attrTrans._frameWidth] * this._maxSteps)\n                ) / (this._maxSteps + 1)\n            );\n            _[this.attrTrans.x] += extraPadding * (this._count + 1);\n        } else {\n            _[this.attrTrans.x] += this._framePadding * this._count;\n        }\n\n        this._tmpContext.drawImage(\n            this.video,\n            _.x,\n            _.y,\n            this._frameWidth,\n            this._frameHeight\n        );\n\n        $(this).trigger('draw:frame', {\n            x: _.x,\n            y: _.y,\n            width: this._frameWidth,\n            height: this._frameHeight,\n            pos: this._count,\n            steps: this._maxSteps,\n        });\n    };\n\n    this.on = function(event, handler) {\n        $(this).on(event, handler);\n    };\n\n    this._createTmpCanvas = function() {\n        this._tmpCanvas = this._createCanvas();\n        this._tmpContext = this._tmpCanvas.getContext('2d');\n        this.drawBaseFilmstrip(this._tmpContext);\n    };\n\n    this._destroyTmpCanvas = function() {\n        delete this._tmpCanvas;\n        delete this._tmpContext;\n    };\n\n    this.setCanvas = function(canvas) {\n        this.width = canvas.width;\n        this.height = canvas.height;\n        this.canvas.width = canvas.width;\n        this.canvas.height = canvas.height;\n        this.context.drawImage(canvas, 0, 0);\n    };\n\n    this.clearCanvas = function() {\n        this.canvas.width = this.canvas.width;\n        this.canvas.height = this.canvas.height;\n        $(self).trigger('draw:finished');\n    },\n\n    this.drawCanvas = function(elem) {\n        elem.width(this.width);\n        elem.height(this.height);\n        elem.get(0).width = this.width;\n        elem.get(0).height = this.height;\n        var context = elem.get(0).getContext('2d');\n        context.drawImage(this.canvas, 0, 0);\n    };\n\n    this.drawFrame = function(elem, args) {\n        elem.width(this.width);\n        elem.height(this.height);\n        var canvas = elem.get(0);\n        var context = canvas.getContext('2d');\n\n        if (args.pos == 0) {\n            canvas.width = this.width;\n            canvas.height = this.height;\n            if (this.strechOnResize && this._canvasDrawn) {\n                context.drawImage(\n                    this.canvas, \n                    0,\n                    0,\n                    this._tmpCanvas.width,\n                    this._tmpCanvas.height\n                );\n            }\n        }\n\n        var _ = {};\n\n        if (args.pos) {\n            _[this.attrTrans.x] = args[this.attrTrans.x] - this._framePadding;\n            _[this.attrTrans.width] = args[this.attrTrans.width] + this._framePadding;\n        } else {\n            _[this.attrTrans.x] = args[this.attrTrans.x];\n            _[this.attrTrans.width] = args[this.attrTrans.width];\n        }\n\n        _[this.attrTrans.y] = 0;\n        _[this.attrTrans.height] = this[this.attrTrans.height];\n\n        if (args.pos == args.steps - 1) {\n            _[this.attrTrans.x] = Math.floor(_[this.attrTrans.x]);\n            _[this.attrTrans.width] = this._tmpCanvas[this.attrTrans.width] - _[this.attrTrans.x];\n        }\n\n        context.drawImage(\n            this._tmpCanvas,\n            _.x,\n            _.y,\n            _.width,\n            _.height,\n            _.x,\n            _.y,\n            _.width,\n            _.height\n        );\n    };\n\n    this.drawBaseFilmstrip = function(context) {\n        if (this.drawBackground) {\n            context.fillStyle = this.bgColor;\n            context.fillRect(0, 0, context.canvas.width, context.canvas.height);\n        }\n\n        if (this.drawHoles && this.bandsPadding) {\n            context.fillStyle = this.holesColor;\n            var _ = {};\n\n            _[this.attrTrans.height] = this.bandsPadding / 2;\n            _[this.attrTrans.width] = _[this.attrTrans.height] / 2;\n            _[this.attrTrans.y0] = (\n                (this.bandsPadding - _[this.attrTrans.height]) / 2\n            );\n            _[this.attrTrans.y1] = (\n                context.canvas[this.attrTrans.height] -\n                _[this.attrTrans.y0] -\n                _[this.attrTrans.height]\n            );\n\n            var total = Math.ceil(\n                ((context.canvas[this.attrTrans.width] - (_[this.attrTrans.y0] * 2)) /\n                _[this.attrTrans.width] / 2) * this.holesDispersion\n            );\n            var sep = (\n                (context.canvas[this.attrTrans.width] -\n                    _[this.attrTrans.height] -\n                    (_[this.attrTrans.width] * total)\n                ) / (total - 1)\n            );\n\n            for (var i = 0; i < total; i++) {\n                _[this.attrTrans.x0] = _[this.attrTrans.y0] + (\n                    (_[this.attrTrans.width] + sep) * i\n                );\n                _[this.attrTrans.x1] = _[this.attrTrans.x0];\n                context.fillRect(_.x0, _.y0, _.width, _.height);\n                context.fillRect(_.x1, _.y1, _.width, _.height);\n            }\n\n        }\n\n    };\n\n};\n"]}