@vouchfor/embeds 1.2.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. package/dist/es/{browser-173d6373.js → browser-4d54600e.js} +2 -2
  2. package/dist/es/{browser-173d6373.js.map → browser-4d54600e.js.map} +1 -1
  3. package/dist/es/embeds.js +1 -1
  4. package/dist/es/{index-df8e918a.js → index-14868944.js} +92 -89
  5. package/dist/es/{index-df8e918a.js.map → index-14868944.js.map} +1 -1
  6. package/dist/es/src/components/DialogEmbed/index.d.ts +1 -0
  7. package/dist/iife/dialog-embed/{browser-1ef3ad7b.js → browser-d8ab928d.js} +2 -2
  8. package/dist/iife/dialog-embed/{browser-1ef3ad7b.js.map → browser-d8ab928d.js.map} +1 -1
  9. package/dist/iife/dialog-embed/embed.iife.js +53 -51
  10. package/dist/iife/dialog-embed/embed.iife.js.map +1 -1
  11. package/dist/iife/dialog-embed/embed.js +1 -1
  12. package/dist/iife/dialog-embed/{index-c8b48d2a.js → index-568f189c.js} +249 -247
  13. package/dist/iife/dialog-embed/{index-c8b48d2a.js.map → index-568f189c.js.map} +1 -1
  14. package/dist/iife/dialog-embed/src/components/DialogEmbed/index.d.ts +1 -0
  15. package/dist/iife/embeds.iife.js +28 -26
  16. package/dist/iife/embeds.iife.js.map +1 -1
  17. package/dist/iife/player-embed/{browser-165af7be.js → browser-951710ee.js} +2 -2
  18. package/dist/iife/player-embed/{browser-165af7be.js.map → browser-951710ee.js.map} +1 -1
  19. package/dist/iife/player-embed/embed.iife.js +1 -1
  20. package/dist/iife/player-embed/embed.js +1 -1
  21. package/dist/iife/player-embed/{index-7e54dc9a.js → index-86dfade0.js} +4 -4
  22. package/dist/iife/player-embed/{index-7e54dc9a.js.map → index-86dfade0.js.map} +1 -1
  23. package/dist/iife/player-embed/src/components/DialogEmbed/index.d.ts +1 -0
  24. package/package.json +1 -1
  25. package/src/components/DialogEmbed/Dialog.stories.ts +12 -0
  26. package/src/components/DialogEmbed/DialogOverlay.ts +2 -1
  27. package/src/components/DialogEmbed/DialogPortal.ts +22 -10
  28. package/src/components/DialogEmbed/index.ts +5 -1
@@ -1,7 +1,7 @@
1
1
  var I = Object.defineProperty;
2
2
  var q = (o, e, t) => e in o ? I(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
3
  var U = (o, e, t) => (q(o, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { c as G, g as H } from "./index-7e54dc9a.js";
4
+ import { c as G, g as H } from "./index-86dfade0.js";
5
5
  function J(o, e) {
6
6
  for (var t = 0; t < e.length; t++) {
7
7
  const r = e[t];
@@ -430,4 +430,4 @@ const me = /* @__PURE__ */ H(_), be = /* @__PURE__ */ J({
430
430
  export {
431
431
  be as b
432
432
  };
433
- //# sourceMappingURL=browser-165af7be.js.map
433
+ //# sourceMappingURL=browser-951710ee.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser-165af7be.js","sources":["../../../../../node_modules/path-browserify/index.js","../../../../../node_modules/skia-canvas/lib/io.js","../../../../../node_modules/skia-canvas/lib/browser.js"],"sourcesContent":["// 'path' module extracted from Node.js v8.11.1 (only the posix part)\n// transplited with Babel\n\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nfunction assertPath(path) {\n if (typeof path !== 'string') {\n throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));\n }\n}\n\n// Resolves . and .. elements in a path with directory names\nfunction normalizeStringPosix(path, allowAboveRoot) {\n var res = '';\n var lastSegmentLength = 0;\n var lastSlash = -1;\n var dots = 0;\n var code;\n for (var i = 0; i <= path.length; ++i) {\n if (i < path.length)\n code = path.charCodeAt(i);\n else if (code === 47 /*/*/)\n break;\n else\n code = 47 /*/*/;\n if (code === 47 /*/*/) {\n if (lastSlash === i - 1 || dots === 1) {\n // NOOP\n } else if (lastSlash !== i - 1 && dots === 2) {\n if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {\n if (res.length > 2) {\n var lastSlashIndex = res.lastIndexOf('/');\n if (lastSlashIndex !== res.length - 1) {\n if (lastSlashIndex === -1) {\n res = '';\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf('/');\n }\n lastSlash = i;\n dots = 0;\n continue;\n }\n } else if (res.length === 2 || res.length === 1) {\n res = '';\n lastSegmentLength = 0;\n lastSlash = i;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n if (res.length > 0)\n res += '/..';\n else\n res = '..';\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0)\n res += '/' + path.slice(lastSlash + 1, i);\n else\n res = path.slice(lastSlash + 1, i);\n lastSegmentLength = i - lastSlash - 1;\n }\n lastSlash = i;\n dots = 0;\n } else if (code === 46 /*.*/ && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\n\nfunction _format(sep, pathObject) {\n var dir = pathObject.dir || pathObject.root;\n var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');\n if (!dir) {\n return base;\n }\n if (dir === pathObject.root) {\n return dir + base;\n }\n return dir + sep + base;\n}\n\nvar posix = {\n // path.resolve([from ...], to)\n resolve: function resolve() {\n var resolvedPath = '';\n var resolvedAbsolute = false;\n var cwd;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path;\n if (i >= 0)\n path = arguments[i];\n else {\n if (cwd === undefined)\n cwd = process.cwd();\n path = cwd;\n }\n\n assertPath(path);\n\n // Skip empty entries\n if (path.length === 0) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);\n\n if (resolvedAbsolute) {\n if (resolvedPath.length > 0)\n return '/' + resolvedPath;\n else\n return '/';\n } else if (resolvedPath.length > 0) {\n return resolvedPath;\n } else {\n return '.';\n }\n },\n\n normalize: function normalize(path) {\n assertPath(path);\n\n if (path.length === 0) return '.';\n\n var isAbsolute = path.charCodeAt(0) === 47 /*/*/;\n var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;\n\n // Normalize the path\n path = normalizeStringPosix(path, !isAbsolute);\n\n if (path.length === 0 && !isAbsolute) path = '.';\n if (path.length > 0 && trailingSeparator) path += '/';\n\n if (isAbsolute) return '/' + path;\n return path;\n },\n\n isAbsolute: function isAbsolute(path) {\n assertPath(path);\n return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;\n },\n\n join: function join() {\n if (arguments.length === 0)\n return '.';\n var joined;\n for (var i = 0; i < arguments.length; ++i) {\n var arg = arguments[i];\n assertPath(arg);\n if (arg.length > 0) {\n if (joined === undefined)\n joined = arg;\n else\n joined += '/' + arg;\n }\n }\n if (joined === undefined)\n return '.';\n return posix.normalize(joined);\n },\n\n relative: function relative(from, to) {\n assertPath(from);\n assertPath(to);\n\n if (from === to) return '';\n\n from = posix.resolve(from);\n to = posix.resolve(to);\n\n if (from === to) return '';\n\n // Trim any leading backslashes\n var fromStart = 1;\n for (; fromStart < from.length; ++fromStart) {\n if (from.charCodeAt(fromStart) !== 47 /*/*/)\n break;\n }\n var fromEnd = from.length;\n var fromLen = fromEnd - fromStart;\n\n // Trim any leading backslashes\n var toStart = 1;\n for (; toStart < to.length; ++toStart) {\n if (to.charCodeAt(toStart) !== 47 /*/*/)\n break;\n }\n var toEnd = to.length;\n var toLen = toEnd - toStart;\n\n // Compare paths to find the longest common path from root\n var length = fromLen < toLen ? fromLen : toLen;\n var lastCommonSep = -1;\n var i = 0;\n for (; i <= length; ++i) {\n if (i === length) {\n if (toLen > length) {\n if (to.charCodeAt(toStart + i) === 47 /*/*/) {\n // We get here if `from` is the exact base path for `to`.\n // For example: from='/foo/bar'; to='/foo/bar/baz'\n return to.slice(toStart + i + 1);\n } else if (i === 0) {\n // We get here if `from` is the root\n // For example: from='/'; to='/foo'\n return to.slice(toStart + i);\n }\n } else if (fromLen > length) {\n if (from.charCodeAt(fromStart + i) === 47 /*/*/) {\n // We get here if `to` is the exact base path for `from`.\n // For example: from='/foo/bar/baz'; to='/foo/bar'\n lastCommonSep = i;\n } else if (i === 0) {\n // We get here if `to` is the root.\n // For example: from='/foo'; to='/'\n lastCommonSep = 0;\n }\n }\n break;\n }\n var fromCode = from.charCodeAt(fromStart + i);\n var toCode = to.charCodeAt(toStart + i);\n if (fromCode !== toCode)\n break;\n else if (fromCode === 47 /*/*/)\n lastCommonSep = i;\n }\n\n var out = '';\n // Generate the relative path based on the path difference between `to`\n // and `from`\n for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {\n if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {\n if (out.length === 0)\n out += '..';\n else\n out += '/..';\n }\n }\n\n // Lastly, append the rest of the destination (`to`) path that comes after\n // the common path parts\n if (out.length > 0)\n return out + to.slice(toStart + lastCommonSep);\n else {\n toStart += lastCommonSep;\n if (to.charCodeAt(toStart) === 47 /*/*/)\n ++toStart;\n return to.slice(toStart);\n }\n },\n\n _makeLong: function _makeLong(path) {\n return path;\n },\n\n dirname: function dirname(path) {\n assertPath(path);\n if (path.length === 0) return '.';\n var code = path.charCodeAt(0);\n var hasRoot = code === 47 /*/*/;\n var end = -1;\n var matchedSlash = true;\n for (var i = path.length - 1; i >= 1; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n if (!matchedSlash) {\n end = i;\n break;\n }\n } else {\n // We saw the first non-path separator\n matchedSlash = false;\n }\n }\n\n if (end === -1) return hasRoot ? '/' : '.';\n if (hasRoot && end === 1) return '//';\n return path.slice(0, end);\n },\n\n basename: function basename(path, ext) {\n if (ext !== undefined && typeof ext !== 'string') throw new TypeError('\"ext\" argument must be a string');\n assertPath(path);\n\n var start = 0;\n var end = -1;\n var matchedSlash = true;\n var i;\n\n if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {\n if (ext.length === path.length && ext === path) return '';\n var extIdx = ext.length - 1;\n var firstNonSlashEnd = -1;\n for (i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else {\n if (firstNonSlashEnd === -1) {\n // We saw the first non-path separator, remember this index in case\n // we need it if the extension ends up not matching\n matchedSlash = false;\n firstNonSlashEnd = i + 1;\n }\n if (extIdx >= 0) {\n // Try to match the explicit extension\n if (code === ext.charCodeAt(extIdx)) {\n if (--extIdx === -1) {\n // We matched the extension, so mark this as the end of our path\n // component\n end = i;\n }\n } else {\n // Extension does not match, so our result is the entire path\n // component\n extIdx = -1;\n end = firstNonSlashEnd;\n }\n }\n }\n }\n\n if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;\n return path.slice(start, end);\n } else {\n for (i = path.length - 1; i >= 0; --i) {\n if (path.charCodeAt(i) === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // path component\n matchedSlash = false;\n end = i + 1;\n }\n }\n\n if (end === -1) return '';\n return path.slice(start, end);\n }\n },\n\n extname: function extname(path) {\n assertPath(path);\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n for (var i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n startDot = i;\n else if (preDotState !== 1)\n preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n return '';\n }\n return path.slice(startDot, end);\n },\n\n format: function format(pathObject) {\n if (pathObject === null || typeof pathObject !== 'object') {\n throw new TypeError('The \"pathObject\" argument must be of type Object. Received type ' + typeof pathObject);\n }\n return _format('/', pathObject);\n },\n\n parse: function parse(path) {\n assertPath(path);\n\n var ret = { root: '', dir: '', base: '', ext: '', name: '' };\n if (path.length === 0) return ret;\n var code = path.charCodeAt(0);\n var isAbsolute = code === 47 /*/*/;\n var start;\n if (isAbsolute) {\n ret.root = '/';\n start = 1;\n } else {\n start = 0;\n }\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n var i = path.length - 1;\n\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n\n // Get non-dir info\n for (; i >= start; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n if (end !== -1) {\n if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);\n }\n } else {\n if (startPart === 0 && isAbsolute) {\n ret.name = path.slice(1, startDot);\n ret.base = path.slice(1, end);\n } else {\n ret.name = path.slice(startPart, startDot);\n ret.base = path.slice(startPart, end);\n }\n ret.ext = path.slice(startDot, end);\n }\n\n if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';\n\n return ret;\n },\n\n sep: '/',\n delimiter: ':',\n win32: null,\n posix: null\n};\n\nposix.posix = posix;\n\nmodule.exports = posix;\n","\"use strict\"\n\nconst {basename, extname} = require('path')\n\n//\n// Mime type <-> File extension mappings\n//\n\nclass Format{\n constructor(){\n let isWeb = (() => typeof global=='undefined')(),\n png = \"image/png\",\n jpg = \"image/jpeg\",\n jpeg = \"image/jpeg\",\n webp = \"image/webp\",\n pdf = \"application/pdf\",\n svg = \"image/svg+xml\"\n\n Object.assign(this, {\n toMime: this.toMime.bind(this),\n fromMime: this.fromMime.bind(this),\n expected: isWeb ? `\"png\", \"jpg\", or \"webp\"`\n : `\"png\", \"jpg\", \"pdf\", or \"svg\"`,\n formats: isWeb ? {png, jpg, jpeg, webp}\n : {png, jpg, jpeg, pdf, svg},\n mimes: isWeb ? {[png]: \"png\", [jpg]: \"jpg\", [webp]: \"webp\"}\n : {[png]: \"png\", [jpg]: \"jpg\", [pdf]: \"pdf\", [svg]: \"svg\"},\n })\n }\n\n toMime(ext){\n return this.formats[(ext||'').replace(/^\\./, '').toLowerCase()]\n }\n\n fromMime(mime){\n return this.mimes[mime]\n }\n}\n\n//\n// Validation of the options dict shared by the Canvas saveAs, toBuffer, and toDataURL methods\n//\n\nfunction options(pages, {filename='', extension='', format, page, quality, matte, density, outline, archive}={}){\n var {fromMime, toMime, expected} = new Format(),\n archive = archive || 'canvas',\n ext = format || extension.replace(/@\\d+x$/i,'') || extname(filename),\n format = fromMime(toMime(ext) || ext),\n mime = toMime(format),\n pp = pages.length\n\n if(!ext) throw new Error(`Cannot determine image format (use a filename extension or 'format' argument)`)\n if (!format) throw new Error(`Unsupported file format \"${ext}\" (expected ${expected})`)\n if (!pp) throw new RangeError(`Canvas has no associated contexts (try calling getContext or newPage first)`)\n\n let padding, isSequence, pattern = filename.replace(/{(\\d*)}/g, (_, width) => {\n isSequence = true\n width = parseInt(width, 10)\n padding = isFinite(width) ? width : isFinite(padding) ? padding : -1\n return \"{}\"\n })\n\n // allow negative indexing if a specific page is specified\n let idx = page > 0 ? page - 1\n : page < 0 ? pp + page\n : undefined;\n\n if (isFinite(idx) && idx < 0 || idx >= pp) throw new RangeError(\n pp == 1 ? `Canvas only has a ‘page 1’ (${idx} is out of bounds)`\n : `Canvas has pages 1–${pp} (${idx} is out of bounds)`\n )\n\n pages = isFinite(idx) ? [pages[idx]]\n : isSequence || format=='pdf' ? pages\n : pages.slice(-1) // default to the 'current' context\n\n if (quality===undefined){\n quality = 0.92\n }else{\n if (typeof quality!='number' || !isFinite(quality) || quality<0 || quality>1){\n throw new TypeError(\"The quality option must be an number in the 0.0–1.0 range\")\n }\n }\n\n if (density===undefined){\n let m = (extension || basename(filename, ext)).match(/@(\\d+)x$/i)\n density = m ? parseInt(m[1], 10) : 1\n }else if (typeof density!='number' || !Number.isInteger(density) || density<1){\n throw new TypeError(\"The density option must be a non-negative integer\")\n }\n\n if (outline===undefined){\n outline = true\n }else if (format == 'svg'){\n outline = !!outline\n }\n\n return {filename, pattern, format, mime, pages, padding, quality, matte, density, outline, archive}\n}\n\n//\n// Zip (pace Phil Katz & q.v. https://github.com/jimmywarting/StreamSaver.js)\n//\n\nclass Crc32 {\n static for(data){\n return new Crc32().append(data).get()\n }\n\n constructor(){ this.crc = -1 }\n\n get(){ return ~this.crc }\n\n append(data){\n var crc = this.crc | 0,\n table = this.table\n for (var offset = 0, len = data.length | 0; offset < len; offset++) {\n crc = (crc >>> 8) ^ table[(crc ^ data[offset]) & 0xFF]\n }\n this.crc = crc\n return this\n }\n\n}\n\nCrc32.prototype.table = (() => {\n var i, j, t, table = []\n for (i = 0; i < 256; i++) {\n t = i\n for (j = 0; j < 8; j++) {\n t = (t & 1)\n ? (t >>> 1) ^ 0xEDB88320\n : t >>> 1\n }\n table[i] = t\n }\n return table\n})()\n\nfunction calloc(size){\n let array = new Uint8Array(size),\n view = new DataView(array.buffer),\n buf = {\n array, view, size,\n set8(at, to){ view.setUint8(at, to); return buf },\n set16(at, to){ view.setUint16(at, to, true); return buf },\n set32(at, to){ view.setUint32(at, to, true); return buf },\n bytes(at, to){ array.set(to, at); return buf },\n }\n return buf\n}\n\nclass Zip{\n static encoder = new TextEncoder()\n\n constructor(directory){\n let now = new Date()\n Object.assign(this, {\n directory,\n offset: 0,\n files: [],\n time: (((now.getHours() << 6) | now.getMinutes()) << 5) | now.getSeconds() / 2,\n date: ((((now.getFullYear() - 1980) << 4) | (now.getMonth() + 1)) << 5) | now.getDate(),\n })\n this.add(directory)\n }\n\n async add(filename, blob){\n let folder = !blob,\n name = Zip.encoder.encode(`${this.directory}/${folder ? '' : filename}`),\n data = new Uint8Array(folder ? 0 : await blob.arrayBuffer()),\n preamble = 30 + name.length,\n descriptor = preamble + data.length,\n postamble = 16,\n {offset} = this\n\n let header = calloc(26)\n .set32(0, 0x08080014) // zip version\n .set16(6, this.time) // time\n .set16(8, this.date) // date\n .set32(10, Crc32.for(data)) // checksum\n .set32(14, data.length) // compressed size (w/ zero compression)\n .set32(18, data.length) // un-compressed size\n .set16(22, name.length) // filename length (utf8 bytes)\n offset += preamble\n\n let payload = calloc(preamble + data.length + postamble)\n .set32(0, 0x04034b50) // local header signature\n .bytes(4, header.array) // ...header fields...\n .bytes(30, name) // filename\n .bytes(preamble, data) // blob bytes\n offset += data.length\n\n payload\n .set32(descriptor, 0x08074b50) // signature\n .bytes(descriptor + 4, header.array.slice(10,22)) // length & filemame\n offset += postamble\n\n this.files.push({offset, folder, name, header, payload})\n this.offset = offset\n }\n\n toBuffer(){\n // central directory record\n let length = this.files.reduce((len, {name}) => 46 + name.length + len, 0),\n cdr = calloc(length + 22),\n index = 0\n\n for (var {offset, name, header, folder} of this.files){\n cdr.set32(index, 0x02014b50) // archive file signature\n .set16(index + 4, 0x0014) // version\n .bytes(index + 6, header.array) // ...header fields...\n .set8(index + 38, folder ? 0x10 : 0) // is_dir flag\n .set32(index + 42, offset) // file offset\n .bytes(index + 46, name) // filename\n index += 46 + name.length\n }\n cdr.set32(index, 0x06054b50) // signature\n .set16(index + 8, this.files.length) // № files per-segment\n .set16(index + 10, this.files.length) // № files this segment\n .set32(index + 12, length) // central directory length\n .set32(index + 16, this.offset) // file-offset of directory\n\n // concatenated zipfile data\n let output = new Uint8Array(this.offset + cdr.size),\n cursor = 0;\n\n for (var {payload} of this.files){\n output.set(payload.array, cursor)\n cursor += payload.size\n }\n output.set(cdr.array, cursor)\n\n return output\n }\n\n get blob(){\n return new Blob([this.toBuffer()], {type:\"application/zip\"})\n }\n}\n\n\n//\n// Browser helpers for converting canvas elements to blobs/buffers/files/zips\n//\n\nconst asBlob = (canvas, mime, quality, matte) => {\n if (matte){\n let {width, height} = canvas,\n comp = Object.assign(document.createElement('canvas'), {width, height}),\n ctx = comp.getContext(\"2d\")\n ctx.fillStyle = matte\n ctx.fillRect(0, 0, width, height)\n ctx.drawImage(canvas, 0, 0)\n canvas = comp\n }\n\n return new Promise((res, rej) => canvas.toBlob(res, mime, quality))\n}\n\nconst asBuffer = (...args) => asBlob(...args).then(b => b.arrayBuffer())\n\nconst asDownload = async (canvas, mime, quality, matte, filename) => {\n _download(filename, await asBlob(canvas, mime, quality, matte))\n}\n\nconst asZipDownload = async (pages, mime, quality, matte, archive, pattern, padding) => {\n let filenames = i => pattern.replace('{}', String(i+1).padStart(padding, '0')),\n folder = basename(archive, '.zip') || 'archive',\n zip = new Zip(folder)\n\n await Promise.all(pages.map(async (page, i) => {\n let filename = filenames(i) // serialize filename(s) before awaiting\n await zip.add(filename, await asBlob(page, mime, quality, matte))\n }))\n\n _download(`${folder}.zip`, zip.blob)\n}\n\nconst _download = (filename, blob) => {\n const href = window.URL.createObjectURL(blob),\n link = document.createElement('a')\n link.style.display = 'none'\n link.href = href\n link.setAttribute('download', filename)\n if (typeof link.download === 'undefined') {\n link.setAttribute('target', '_blank')\n }\n document.body.appendChild(link)\n link.click()\n document.body.removeChild(link)\n setTimeout(() => window.URL.revokeObjectURL(href), 100)\n}\n\nconst atScale = (pages, density, matte) => pages.map(page => {\n if (density == 1 && !matte) return page.canvas\n\n let scaled = document.createElement('canvas'),\n ctx = scaled.getContext(\"2d\"),\n src = page.canvas ? page.canvas : page\n scaled.width = src.width * density\n scaled.height = src.height * density\n if (matte){\n ctx.fillStyle = matte\n ctx.fillRect(0, 0, scaled.width, scaled.height)\n }\n ctx.scale(density, density)\n ctx.drawImage(src, 0, 0)\n return scaled\n})\n\nmodule.exports = {asBuffer, asDownload, asZipDownload, atScale, options}\n","\"use strict\"\n\nconst {asBuffer, asDownload, asZipDownload, atScale, options} = require('./io')\n\n//\n// Browser equivalents of the skia-canvas convenience initializers and polyfills for\n// the Canvas object’s newPage & export methods\n//\n\nconst _toURL_ = Symbol.for(\"toDataURL\")\n\nconst loadImage = src => {\n let img = Object.assign(new Image(), {crossOrigin:'Anonymous', src})\n return img.decode().then(() => img)\n}\n\nclass Canvas{\n constructor(width, height){\n let elt = document.createElement('canvas'),\n pages = []\n\n Object.defineProperty(elt, \"async\", {value:true, writable:false, enumerable:true})\n\n for (var [prop, get] of Object.entries({\n png: () => asBuffer(elt, 'image/png'),\n jpg: () => asBuffer(elt, 'image/jpeg'),\n pages: () => pages.concat(elt).map(c => c.getContext(\"2d\")),\n })) Object.defineProperty(elt, prop, {get})\n\n return Object.assign(elt, {\n width, height,\n\n newPage(...size){\n var {width, height} = elt,\n page = Object.assign(document.createElement('canvas'), {width, height})\n page.getContext(\"2d\").drawImage(elt, 0, 0)\n pages.push(page)\n\n var [width, height] = size.length ? size : [width, height]\n return Object.assign(elt, {width, height}).getContext(\"2d\")\n },\n\n saveAs(filename, args){\n args = typeof args=='number' ? {quality:args} : args\n let opts = options(this.pages, {filename, ...args}),\n {pattern, padding, mime, quality, matte, density, archive} = opts,\n pages = atScale(opts.pages, density);\n return padding==undefined ? asDownload(pages[0], mime, quality, matte, filename)\n : asZipDownload(pages, mime, quality, matte, archive, pattern, padding)\n },\n\n toBuffer(extension=\"png\", args={}){\n args = typeof args=='number' ? {quality:args} : args\n let opts = options(this.pages, {extension, ...args}),\n {mime, quality, matte, pages, density} = opts,\n canvas = atScale(pages, density, matte)[0]\n return asBuffer(canvas, mime, quality, matte)\n },\n\n [_toURL_]: elt.toDataURL.bind(elt),\n toDataURL(extension=\"png\", args={}){\n args = typeof args=='number' ? {quality:args} : args\n let opts = options(this.pages, {extension, ...args}),\n {mime, quality, matte, pages, density} = opts,\n canvas = atScale(pages, density, matte)[0],\n url = canvas[canvas===elt ? _toURL_ : 'toDataURL'](mime, quality);\n return Promise.resolve(url)\n }\n })\n }\n}\n\nconst {CanvasRenderingContext2D, CanvasGradient, CanvasPattern,\n Image, ImageData, Path2D, DOMMatrix, DOMRect, DOMPoint} = window;\n\nmodule.exports = {\n Canvas, loadImage,\n CanvasRenderingContext2D, CanvasGradient, CanvasPattern,\n Image, ImageData, Path2D, DOMMatrix, DOMRect, DOMPoint\n}"],"names":["assertPath","path","normalizeStringPosix","allowAboveRoot","res","lastSegmentLength","lastSlash","dots","code","i","lastSlashIndex","_format","sep","pathObject","dir","base","posix","resolvedPath","resolvedAbsolute","cwd","isAbsolute","trailingSeparator","joined","arg","from","to","fromStart","fromEnd","fromLen","toStart","toEnd","toLen","length","lastCommonSep","fromCode","toCode","out","hasRoot","end","matchedSlash","ext","start","extIdx","firstNonSlashEnd","startDot","startPart","preDotState","ret","pathBrowserify","basename","extname","require$$0","Format","isWeb","global","png","jpg","jpeg","webp","pdf","svg","mime","options","pages","filename","extension","format","page","quality","matte","density","outline","archive","fromMime","toMime","expected","pp","padding","isSequence","pattern","_","width","idx","m","Crc32","data","crc","table","offset","len","j","calloc","size","array","view","buf","at","_Zip","directory","now","blob","folder","name","preamble","descriptor","postamble","header","payload","cdr","index","output","cursor","__publicField","Zip","asBlob","canvas","height","comp","ctx","rej","asBuffer","args","b","asDownload","_download","asZipDownload","filenames","zip","href","link","atScale","scaled","src","io","_toURL_","loadImage","img","Image","Canvas","elt","prop","get","c","opts","url","CanvasRenderingContext2D","CanvasGradient","CanvasPattern","ImageData","Path2D","DOMMatrix","DOMRect","DOMPoint","browser"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BA,SAASA,EAAWC,GAAM;AACxB,MAAI,OAAOA,KAAS;AAClB,UAAM,IAAI,UAAU,qCAAqC,KAAK,UAAUA,CAAI,CAAC;AAEjF;AAGA,SAASC,EAAqBD,GAAME,GAAgB;AAMlD,WALIC,IAAM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D,IAAK,CAAA,GAAG;AACjC,QAAAA,IAAO,OAAOA,KAAM,WAAW,EAAC,SAAQA,EAAI,IAAIA;AAChD,YAAIsB,IAAOjF,EAAQ,KAAK,OAAO,EAAC,WAAAG,GAAW,GAAGwD,EAAI,CAAC,GAC/C,EAAC,MAAA5D,GAAM,SAAAO,GAAS,OAAAC,GAAO,OAAAN,GAAO,SAAAO,EAAO,IAAIyE,GACzC5B,IAASe,EAAQnE,GAAOO,GAASD,CAAK,EAAE,CAAC,GACzC2E,IAAM7B,EAAOA,MAASwB,IAAML,IAAU,WAAW,EAAEzE,GAAMO,CAAO;AACpE,eAAO,QAAQ,QAAQ4E,CAAG;AAAA,MAC3B;AAAA,IACP,CAAK;AAAA,EACF;AACH;AAEA,MAAM;AAAA,EAAC,0BAAAC;AAAA,EAA0B,gBAAAC;AAAA,EAAgB,eAAAC;AAAA,EAC1C,OAAAV;AAAA,EAAO,WAAAW;AAAA,EAAW,QAAAC;AAAA,EAAQ,WAAAC;AAAA,EAAW,SAAAC;AAAA,EAAS,UAAAC;AAAQ,IAAI;AAEjE,IAAAC,IAAiB;AAAA,EACf,QAAAf;AAAA,EAAQ,WAAAH;AAAA,EACR,0BAAAU;AAAA,EAA0B,gBAAAC;AAAA,EAAgB,eAAAC;AAAA,EAC1C,OAAAV;AAAA,EAAO,WAAAW;AAAA,EAAW,QAAAC;AAAA,EAAQ,WAAAC;AAAA,EAAW,SAAAC;AAAA,EAAS,UAAAC;AAChD;;;;;","x_google_ignoreList":[0,1,2]}
1
+ {"version":3,"file":"browser-951710ee.js","sources":["../../../../../node_modules/path-browserify/index.js","../../../../../node_modules/skia-canvas/lib/io.js","../../../../../node_modules/skia-canvas/lib/browser.js"],"sourcesContent":["// 'path' module extracted from Node.js v8.11.1 (only the posix part)\n// transplited with Babel\n\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nfunction assertPath(path) {\n if (typeof path !== 'string') {\n throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));\n }\n}\n\n// Resolves . and .. elements in a path with directory names\nfunction normalizeStringPosix(path, allowAboveRoot) {\n var res = '';\n var lastSegmentLength = 0;\n var lastSlash = -1;\n var dots = 0;\n var code;\n for (var i = 0; i <= path.length; ++i) {\n if (i < path.length)\n code = path.charCodeAt(i);\n else if (code === 47 /*/*/)\n break;\n else\n code = 47 /*/*/;\n if (code === 47 /*/*/) {\n if (lastSlash === i - 1 || dots === 1) {\n // NOOP\n } else if (lastSlash !== i - 1 && dots === 2) {\n if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {\n if (res.length > 2) {\n var lastSlashIndex = res.lastIndexOf('/');\n if (lastSlashIndex !== res.length - 1) {\n if (lastSlashIndex === -1) {\n res = '';\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf('/');\n }\n lastSlash = i;\n dots = 0;\n continue;\n }\n } else if (res.length === 2 || res.length === 1) {\n res = '';\n lastSegmentLength = 0;\n lastSlash = i;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n if (res.length > 0)\n res += '/..';\n else\n res = '..';\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0)\n res += '/' + path.slice(lastSlash + 1, i);\n else\n res = path.slice(lastSlash + 1, i);\n lastSegmentLength = i - lastSlash - 1;\n }\n lastSlash = i;\n dots = 0;\n } else if (code === 46 /*.*/ && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\n\nfunction _format(sep, pathObject) {\n var dir = pathObject.dir || pathObject.root;\n var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');\n if (!dir) {\n return base;\n }\n if (dir === pathObject.root) {\n return dir + base;\n }\n return dir + sep + base;\n}\n\nvar posix = {\n // path.resolve([from ...], to)\n resolve: function resolve() {\n var resolvedPath = '';\n var resolvedAbsolute = false;\n var cwd;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path;\n if (i >= 0)\n path = arguments[i];\n else {\n if (cwd === undefined)\n cwd = process.cwd();\n path = cwd;\n }\n\n assertPath(path);\n\n // Skip empty entries\n if (path.length === 0) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);\n\n if (resolvedAbsolute) {\n if (resolvedPath.length > 0)\n return '/' + resolvedPath;\n else\n return '/';\n } else if (resolvedPath.length > 0) {\n return resolvedPath;\n } else {\n return '.';\n }\n },\n\n normalize: function normalize(path) {\n assertPath(path);\n\n if (path.length === 0) return '.';\n\n var isAbsolute = path.charCodeAt(0) === 47 /*/*/;\n var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;\n\n // Normalize the path\n path = normalizeStringPosix(path, !isAbsolute);\n\n if (path.length === 0 && !isAbsolute) path = '.';\n if (path.length > 0 && trailingSeparator) path += '/';\n\n if (isAbsolute) return '/' + path;\n return path;\n },\n\n isAbsolute: function isAbsolute(path) {\n assertPath(path);\n return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;\n },\n\n join: function join() {\n if (arguments.length === 0)\n return '.';\n var joined;\n for (var i = 0; i < arguments.length; ++i) {\n var arg = arguments[i];\n assertPath(arg);\n if (arg.length > 0) {\n if (joined === undefined)\n joined = arg;\n else\n joined += '/' + arg;\n }\n }\n if (joined === undefined)\n return '.';\n return posix.normalize(joined);\n },\n\n relative: function relative(from, to) {\n assertPath(from);\n assertPath(to);\n\n if (from === to) return '';\n\n from = posix.resolve(from);\n to = posix.resolve(to);\n\n if (from === to) return '';\n\n // Trim any leading backslashes\n var fromStart = 1;\n for (; fromStart < from.length; ++fromStart) {\n if (from.charCodeAt(fromStart) !== 47 /*/*/)\n break;\n }\n var fromEnd = from.length;\n var fromLen = fromEnd - fromStart;\n\n // Trim any leading backslashes\n var toStart = 1;\n for (; toStart < to.length; ++toStart) {\n if (to.charCodeAt(toStart) !== 47 /*/*/)\n break;\n }\n var toEnd = to.length;\n var toLen = toEnd - toStart;\n\n // Compare paths to find the longest common path from root\n var length = fromLen < toLen ? fromLen : toLen;\n var lastCommonSep = -1;\n var i = 0;\n for (; i <= length; ++i) {\n if (i === length) {\n if (toLen > length) {\n if (to.charCodeAt(toStart + i) === 47 /*/*/) {\n // We get here if `from` is the exact base path for `to`.\n // For example: from='/foo/bar'; to='/foo/bar/baz'\n return to.slice(toStart + i + 1);\n } else if (i === 0) {\n // We get here if `from` is the root\n // For example: from='/'; to='/foo'\n return to.slice(toStart + i);\n }\n } else if (fromLen > length) {\n if (from.charCodeAt(fromStart + i) === 47 /*/*/) {\n // We get here if `to` is the exact base path for `from`.\n // For example: from='/foo/bar/baz'; to='/foo/bar'\n lastCommonSep = i;\n } else if (i === 0) {\n // We get here if `to` is the root.\n // For example: from='/foo'; to='/'\n lastCommonSep = 0;\n }\n }\n break;\n }\n var fromCode = from.charCodeAt(fromStart + i);\n var toCode = to.charCodeAt(toStart + i);\n if (fromCode !== toCode)\n break;\n else if (fromCode === 47 /*/*/)\n lastCommonSep = i;\n }\n\n var out = '';\n // Generate the relative path based on the path difference between `to`\n // and `from`\n for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {\n if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {\n if (out.length === 0)\n out += '..';\n else\n out += '/..';\n }\n }\n\n // Lastly, append the rest of the destination (`to`) path that comes after\n // the common path parts\n if (out.length > 0)\n return out + to.slice(toStart + lastCommonSep);\n else {\n toStart += lastCommonSep;\n if (to.charCodeAt(toStart) === 47 /*/*/)\n ++toStart;\n return to.slice(toStart);\n }\n },\n\n _makeLong: function _makeLong(path) {\n return path;\n },\n\n dirname: function dirname(path) {\n assertPath(path);\n if (path.length === 0) return '.';\n var code = path.charCodeAt(0);\n var hasRoot = code === 47 /*/*/;\n var end = -1;\n var matchedSlash = true;\n for (var i = path.length - 1; i >= 1; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n if (!matchedSlash) {\n end = i;\n break;\n }\n } else {\n // We saw the first non-path separator\n matchedSlash = false;\n }\n }\n\n if (end === -1) return hasRoot ? '/' : '.';\n if (hasRoot && end === 1) return '//';\n return path.slice(0, end);\n },\n\n basename: function basename(path, ext) {\n if (ext !== undefined && typeof ext !== 'string') throw new TypeError('\"ext\" argument must be a string');\n assertPath(path);\n\n var start = 0;\n var end = -1;\n var matchedSlash = true;\n var i;\n\n if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {\n if (ext.length === path.length && ext === path) return '';\n var extIdx = ext.length - 1;\n var firstNonSlashEnd = -1;\n for (i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else {\n if (firstNonSlashEnd === -1) {\n // We saw the first non-path separator, remember this index in case\n // we need it if the extension ends up not matching\n matchedSlash = false;\n firstNonSlashEnd = i + 1;\n }\n if (extIdx >= 0) {\n // Try to match the explicit extension\n if (code === ext.charCodeAt(extIdx)) {\n if (--extIdx === -1) {\n // We matched the extension, so mark this as the end of our path\n // component\n end = i;\n }\n } else {\n // Extension does not match, so our result is the entire path\n // component\n extIdx = -1;\n end = firstNonSlashEnd;\n }\n }\n }\n }\n\n if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;\n return path.slice(start, end);\n } else {\n for (i = path.length - 1; i >= 0; --i) {\n if (path.charCodeAt(i) === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // path component\n matchedSlash = false;\n end = i + 1;\n }\n }\n\n if (end === -1) return '';\n return path.slice(start, end);\n }\n },\n\n extname: function extname(path) {\n assertPath(path);\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n for (var i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n startDot = i;\n else if (preDotState !== 1)\n preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n return '';\n }\n return path.slice(startDot, end);\n },\n\n format: function format(pathObject) {\n if (pathObject === null || typeof pathObject !== 'object') {\n throw new TypeError('The \"pathObject\" argument must be of type Object. Received type ' + typeof pathObject);\n }\n return _format('/', pathObject);\n },\n\n parse: function parse(path) {\n assertPath(path);\n\n var ret = { root: '', dir: '', base: '', ext: '', name: '' };\n if (path.length === 0) return ret;\n var code = path.charCodeAt(0);\n var isAbsolute = code === 47 /*/*/;\n var start;\n if (isAbsolute) {\n ret.root = '/';\n start = 1;\n } else {\n start = 0;\n }\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n var i = path.length - 1;\n\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n\n // Get non-dir info\n for (; i >= start; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n if (end !== -1) {\n if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);\n }\n } else {\n if (startPart === 0 && isAbsolute) {\n ret.name = path.slice(1, startDot);\n ret.base = path.slice(1, end);\n } else {\n ret.name = path.slice(startPart, startDot);\n ret.base = path.slice(startPart, end);\n }\n ret.ext = path.slice(startDot, end);\n }\n\n if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';\n\n return ret;\n },\n\n sep: '/',\n delimiter: ':',\n win32: null,\n posix: null\n};\n\nposix.posix = posix;\n\nmodule.exports = posix;\n","\"use strict\"\n\nconst {basename, extname} = require('path')\n\n//\n// Mime type <-> File extension mappings\n//\n\nclass Format{\n constructor(){\n let isWeb = (() => typeof global=='undefined')(),\n png = \"image/png\",\n jpg = \"image/jpeg\",\n jpeg = \"image/jpeg\",\n webp = \"image/webp\",\n pdf = \"application/pdf\",\n svg = \"image/svg+xml\"\n\n Object.assign(this, {\n toMime: this.toMime.bind(this),\n fromMime: this.fromMime.bind(this),\n expected: isWeb ? `\"png\", \"jpg\", or \"webp\"`\n : `\"png\", \"jpg\", \"pdf\", or \"svg\"`,\n formats: isWeb ? {png, jpg, jpeg, webp}\n : {png, jpg, jpeg, pdf, svg},\n mimes: isWeb ? {[png]: \"png\", [jpg]: \"jpg\", [webp]: \"webp\"}\n : {[png]: \"png\", [jpg]: \"jpg\", [pdf]: \"pdf\", [svg]: \"svg\"},\n })\n }\n\n toMime(ext){\n return this.formats[(ext||'').replace(/^\\./, '').toLowerCase()]\n }\n\n fromMime(mime){\n return this.mimes[mime]\n }\n}\n\n//\n// Validation of the options dict shared by the Canvas saveAs, toBuffer, and toDataURL methods\n//\n\nfunction options(pages, {filename='', extension='', format, page, quality, matte, density, outline, archive}={}){\n var {fromMime, toMime, expected} = new Format(),\n archive = archive || 'canvas',\n ext = format || extension.replace(/@\\d+x$/i,'') || extname(filename),\n format = fromMime(toMime(ext) || ext),\n mime = toMime(format),\n pp = pages.length\n\n if(!ext) throw new Error(`Cannot determine image format (use a filename extension or 'format' argument)`)\n if (!format) throw new Error(`Unsupported file format \"${ext}\" (expected ${expected})`)\n if (!pp) throw new RangeError(`Canvas has no associated contexts (try calling getContext or newPage first)`)\n\n let padding, isSequence, pattern = filename.replace(/{(\\d*)}/g, (_, width) => {\n isSequence = true\n width = parseInt(width, 10)\n padding = isFinite(width) ? width : isFinite(padding) ? padding : -1\n return \"{}\"\n })\n\n // allow negative indexing if a specific page is specified\n let idx = page > 0 ? page - 1\n : page < 0 ? pp + page\n : undefined;\n\n if (isFinite(idx) && idx < 0 || idx >= pp) throw new RangeError(\n pp == 1 ? `Canvas only has a ‘page 1’ (${idx} is out of bounds)`\n : `Canvas has pages 1–${pp} (${idx} is out of bounds)`\n )\n\n pages = isFinite(idx) ? [pages[idx]]\n : isSequence || format=='pdf' ? pages\n : pages.slice(-1) // default to the 'current' context\n\n if (quality===undefined){\n quality = 0.92\n }else{\n if (typeof quality!='number' || !isFinite(quality) || quality<0 || quality>1){\n throw new TypeError(\"The quality option must be an number in the 0.0–1.0 range\")\n }\n }\n\n if (density===undefined){\n let m = (extension || basename(filename, ext)).match(/@(\\d+)x$/i)\n density = m ? parseInt(m[1], 10) : 1\n }else if (typeof density!='number' || !Number.isInteger(density) || density<1){\n throw new TypeError(\"The density option must be a non-negative integer\")\n }\n\n if (outline===undefined){\n outline = true\n }else if (format == 'svg'){\n outline = !!outline\n }\n\n return {filename, pattern, format, mime, pages, padding, quality, matte, density, outline, archive}\n}\n\n//\n// Zip (pace Phil Katz & q.v. https://github.com/jimmywarting/StreamSaver.js)\n//\n\nclass Crc32 {\n static for(data){\n return new Crc32().append(data).get()\n }\n\n constructor(){ this.crc = -1 }\n\n get(){ return ~this.crc }\n\n append(data){\n var crc = this.crc | 0,\n table = this.table\n for (var offset = 0, len = data.length | 0; offset < len; offset++) {\n crc = (crc >>> 8) ^ table[(crc ^ data[offset]) & 0xFF]\n }\n this.crc = crc\n return this\n }\n\n}\n\nCrc32.prototype.table = (() => {\n var i, j, t, table = []\n for (i = 0; i < 256; i++) {\n t = i\n for (j = 0; j < 8; j++) {\n t = (t & 1)\n ? (t >>> 1) ^ 0xEDB88320\n : t >>> 1\n }\n table[i] = t\n }\n return table\n})()\n\nfunction calloc(size){\n let array = new Uint8Array(size),\n view = new DataView(array.buffer),\n buf = {\n array, view, size,\n set8(at, to){ view.setUint8(at, to); return buf },\n set16(at, to){ view.setUint16(at, to, true); return buf },\n set32(at, to){ view.setUint32(at, to, true); return buf },\n bytes(at, to){ array.set(to, at); return buf },\n }\n return buf\n}\n\nclass Zip{\n static encoder = new TextEncoder()\n\n constructor(directory){\n let now = new Date()\n Object.assign(this, {\n directory,\n offset: 0,\n files: [],\n time: (((now.getHours() << 6) | now.getMinutes()) << 5) | now.getSeconds() / 2,\n date: ((((now.getFullYear() - 1980) << 4) | (now.getMonth() + 1)) << 5) | now.getDate(),\n })\n this.add(directory)\n }\n\n async add(filename, blob){\n let folder = !blob,\n name = Zip.encoder.encode(`${this.directory}/${folder ? '' : filename}`),\n data = new Uint8Array(folder ? 0 : await blob.arrayBuffer()),\n preamble = 30 + name.length,\n descriptor = preamble + data.length,\n postamble = 16,\n {offset} = this\n\n let header = calloc(26)\n .set32(0, 0x08080014) // zip version\n .set16(6, this.time) // time\n .set16(8, this.date) // date\n .set32(10, Crc32.for(data)) // checksum\n .set32(14, data.length) // compressed size (w/ zero compression)\n .set32(18, data.length) // un-compressed size\n .set16(22, name.length) // filename length (utf8 bytes)\n offset += preamble\n\n let payload = calloc(preamble + data.length + postamble)\n .set32(0, 0x04034b50) // local header signature\n .bytes(4, header.array) // ...header fields...\n .bytes(30, name) // filename\n .bytes(preamble, data) // blob bytes\n offset += data.length\n\n payload\n .set32(descriptor, 0x08074b50) // signature\n .bytes(descriptor + 4, header.array.slice(10,22)) // length & filemame\n offset += postamble\n\n this.files.push({offset, folder, name, header, payload})\n this.offset = offset\n }\n\n toBuffer(){\n // central directory record\n let length = this.files.reduce((len, {name}) => 46 + name.length + len, 0),\n cdr = calloc(length + 22),\n index = 0\n\n for (var {offset, name, header, folder} of this.files){\n cdr.set32(index, 0x02014b50) // archive file signature\n .set16(index + 4, 0x0014) // version\n .bytes(index + 6, header.array) // ...header fields...\n .set8(index + 38, folder ? 0x10 : 0) // is_dir flag\n .set32(index + 42, offset) // file offset\n .bytes(index + 46, name) // filename\n index += 46 + name.length\n }\n cdr.set32(index, 0x06054b50) // signature\n .set16(index + 8, this.files.length) // № files per-segment\n .set16(index + 10, this.files.length) // № files this segment\n .set32(index + 12, length) // central directory length\n .set32(index + 16, this.offset) // file-offset of directory\n\n // concatenated zipfile data\n let output = new Uint8Array(this.offset + cdr.size),\n cursor = 0;\n\n for (var {payload} of this.files){\n output.set(payload.array, cursor)\n cursor += payload.size\n }\n output.set(cdr.array, cursor)\n\n return output\n }\n\n get blob(){\n return new Blob([this.toBuffer()], {type:\"application/zip\"})\n }\n}\n\n\n//\n// Browser helpers for converting canvas elements to blobs/buffers/files/zips\n//\n\nconst asBlob = (canvas, mime, quality, matte) => {\n if (matte){\n let {width, height} = canvas,\n comp = Object.assign(document.createElement('canvas'), {width, height}),\n ctx = comp.getContext(\"2d\")\n ctx.fillStyle = matte\n ctx.fillRect(0, 0, width, height)\n ctx.drawImage(canvas, 0, 0)\n canvas = comp\n }\n\n return new Promise((res, rej) => canvas.toBlob(res, mime, quality))\n}\n\nconst asBuffer = (...args) => asBlob(...args).then(b => b.arrayBuffer())\n\nconst asDownload = async (canvas, mime, quality, matte, filename) => {\n _download(filename, await asBlob(canvas, mime, quality, matte))\n}\n\nconst asZipDownload = async (pages, mime, quality, matte, archive, pattern, padding) => {\n let filenames = i => pattern.replace('{}', String(i+1).padStart(padding, '0')),\n folder = basename(archive, '.zip') || 'archive',\n zip = new Zip(folder)\n\n await Promise.all(pages.map(async (page, i) => {\n let filename = filenames(i) // serialize filename(s) before awaiting\n await zip.add(filename, await asBlob(page, mime, quality, matte))\n }))\n\n _download(`${folder}.zip`, zip.blob)\n}\n\nconst _download = (filename, blob) => {\n const href = window.URL.createObjectURL(blob),\n link = document.createElement('a')\n link.style.display = 'none'\n link.href = href\n link.setAttribute('download', filename)\n if (typeof link.download === 'undefined') {\n link.setAttribute('target', '_blank')\n }\n document.body.appendChild(link)\n link.click()\n document.body.removeChild(link)\n setTimeout(() => window.URL.revokeObjectURL(href), 100)\n}\n\nconst atScale = (pages, density, matte) => pages.map(page => {\n if (density == 1 && !matte) return page.canvas\n\n let scaled = document.createElement('canvas'),\n ctx = scaled.getContext(\"2d\"),\n src = page.canvas ? page.canvas : page\n scaled.width = src.width * density\n scaled.height = src.height * density\n if (matte){\n ctx.fillStyle = matte\n ctx.fillRect(0, 0, scaled.width, scaled.height)\n }\n ctx.scale(density, density)\n ctx.drawImage(src, 0, 0)\n return scaled\n})\n\nmodule.exports = {asBuffer, asDownload, asZipDownload, atScale, options}\n","\"use strict\"\n\nconst {asBuffer, asDownload, asZipDownload, atScale, options} = require('./io')\n\n//\n// Browser equivalents of the skia-canvas convenience initializers and polyfills for\n// the Canvas object’s newPage & export methods\n//\n\nconst _toURL_ = Symbol.for(\"toDataURL\")\n\nconst loadImage = src => {\n let img = Object.assign(new Image(), {crossOrigin:'Anonymous', src})\n return img.decode().then(() => img)\n}\n\nclass Canvas{\n constructor(width, height){\n let elt = document.createElement('canvas'),\n pages = []\n\n Object.defineProperty(elt, \"async\", {value:true, writable:false, enumerable:true})\n\n for (var [prop, get] of Object.entries({\n png: () => asBuffer(elt, 'image/png'),\n jpg: () => asBuffer(elt, 'image/jpeg'),\n pages: () => pages.concat(elt).map(c => c.getContext(\"2d\")),\n })) Object.defineProperty(elt, prop, {get})\n\n return Object.assign(elt, {\n width, height,\n\n newPage(...size){\n var {width, height} = elt,\n page = Object.assign(document.createElement('canvas'), {width, height})\n page.getContext(\"2d\").drawImage(elt, 0, 0)\n pages.push(page)\n\n var [width, height] = size.length ? size : [width, height]\n return Object.assign(elt, {width, height}).getContext(\"2d\")\n },\n\n saveAs(filename, args){\n args = typeof args=='number' ? {quality:args} : args\n let opts = options(this.pages, {filename, ...args}),\n {pattern, padding, mime, quality, matte, density, archive} = opts,\n pages = atScale(opts.pages, density);\n return padding==undefined ? asDownload(pages[0], mime, quality, matte, filename)\n : asZipDownload(pages, mime, quality, matte, archive, pattern, padding)\n },\n\n toBuffer(extension=\"png\", args={}){\n args = typeof args=='number' ? {quality:args} : args\n let opts = options(this.pages, {extension, ...args}),\n {mime, quality, matte, pages, density} = opts,\n canvas = atScale(pages, density, matte)[0]\n return asBuffer(canvas, mime, quality, matte)\n },\n\n [_toURL_]: elt.toDataURL.bind(elt),\n toDataURL(extension=\"png\", args={}){\n args = typeof args=='number' ? {quality:args} : args\n let opts = options(this.pages, {extension, ...args}),\n {mime, quality, matte, pages, density} = opts,\n canvas = atScale(pages, density, matte)[0],\n url = canvas[canvas===elt ? _toURL_ : 'toDataURL'](mime, quality);\n return Promise.resolve(url)\n }\n })\n }\n}\n\nconst {CanvasRenderingContext2D, CanvasGradient, CanvasPattern,\n Image, ImageData, Path2D, DOMMatrix, DOMRect, DOMPoint} = window;\n\nmodule.exports = {\n Canvas, loadImage,\n CanvasRenderingContext2D, CanvasGradient, CanvasPattern,\n Image, ImageData, Path2D, DOMMatrix, DOMRect, DOMPoint\n}"],"names":["assertPath","path","normalizeStringPosix","allowAboveRoot","res","lastSegmentLength","lastSlash","dots","code","i","lastSlashIndex","_format","sep","pathObject","dir","base","posix","resolvedPath","resolvedAbsolute","cwd","isAbsolute","trailingSeparator","joined","arg","from","to","fromStart","fromEnd","fromLen","toStart","toEnd","toLen","length","lastCommonSep","fromCode","toCode","out","hasRoot","end","matchedSlash","ext","start","extIdx","firstNonSlashEnd","startDot","startPart","preDotState","ret","pathBrowserify","basename","extname","require$$0","Format","isWeb","global","png","jpg","jpeg","webp","pdf","svg","mime","options","pages","filename","extension","format","page","quality","matte","density","outline","archive","fromMime","toMime","expected","pp","padding","isSequence","pattern","_","width","idx","m","Crc32","data","crc","table","offset","len","j","calloc","size","array","view","buf","at","_Zip","directory","now","blob","folder","name","preamble","descriptor","postamble","header","payload","cdr","index","output","cursor","__publicField","Zip","asBlob","canvas","height","comp","ctx","rej","asBuffer","args","b","asDownload","_download","asZipDownload","filenames","zip","href","link","atScale","scaled","src","io","_toURL_","loadImage","img","Image","Canvas","elt","prop","get","c","opts","url","CanvasRenderingContext2D","CanvasGradient","CanvasPattern","ImageData","Path2D","DOMMatrix","DOMRect","DOMPoint","browser"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BA,SAASA,EAAWC,GAAM;AACxB,MAAI,OAAOA,KAAS;AAClB,UAAM,IAAI,UAAU,qCAAqC,KAAK,UAAUA,CAAI,CAAC;AAEjF;AAGA,SAASC,EAAqBD,GAAME,GAAgB;AAMlD,WALIC,IAAM,IACNC,IAAoB,GACpBC,IAAY,IACZC,IAAO,GACPC,GACKC,IAAI,GAAGA,KAAKR,EAAK,QAAQ,EAAEQ,GAAG;AACrC,QAAIA,IAAIR,EAAK;AACX,MAAAO,IAAOP,EAAK,WAAWQ,CAAC;AAAA,SACrB;AAAA,UAAID,MAAS;AAChB;AAEA,MAAAA,IAAO;AAAA;AACT,QAAIA,MAAS,IAAU;AACrB,UAAI,EAAAF,MAAcG,IAAI,KAAKF,MAAS;AAE7B,YAAID,MAAcG,IAAI,KAAKF,MAAS,GAAG;AAC5C,cAAIH,EAAI,SAAS,KAAKC,MAAsB,KAAKD,EAAI,WAAWA,EAAI,SAAS,CAAC,MAAM,MAAYA,EAAI,WAAWA,EAAI,SAAS,CAAC,MAAM;AACjI,gBAAIA,EAAI,SAAS,GAAG;AAClB,kBAAIM,IAAiBN,EAAI,YAAY,GAAG;AACxC,kBAAIM,MAAmBN,EAAI,SAAS,GAAG;AACrC,gBAAIM,MAAmB,MACrBN,IAAM,IACNC,IAAoB,MAEpBD,IAAMA,EAAI,MAAM,GAAGM,CAAc,GACjCL,IAAoBD,EAAI,SAAS,IAAIA,EAAI,YAAY,GAAG,IAE1DE,IAAYG,GACZF,IAAO;AACP;AAAA,cACD;AAAA,YACb,WAAqBH,EAAI,WAAW,KAAKA,EAAI,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AAO,WAAAW;AAAA,EAAW,QAAAC;AAAA,EAAQ,WAAAC;AAAA,EAAW,SAAAC;AAAA,EAAS,UAAAC;AAChD;;;;;","x_google_ignoreList":[0,1,2]}
@@ -168,7 +168,7 @@ ${t}`,jm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Km=Objec
168
168
  "width": {{ it.root?.answer?.settings?.crop?.width }},
169
169
  "height": {{ it.root?.answer?.settings?.crop?.height }}
170
170
  }
171
- }`}],root:"{{ it.outro?.questions?.items }}"}],system:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},j1={id:"073977ec-6384-4329-b7c5-8275fb513e74",name:"None",entityId:"none",templateId:"a95e537e-fb4d-4d2f-9c72-86c0925c7176",templates:[W1],meta:{frameRate:30,resolution:720,transitionDuration:1/3},system:!0,default:0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};async function K1(){if(typeof window>"u"){const i=await Promise.resolve().then(()=>jp);return new i.Image}return new Image}const zu=ys(async function(i){return i?new Promise((t,e)=>{K1().then(r=>{r.onload=()=>{t(r)},r.onerror=n=>{e(n)},r.src=i})}):null});async function hc({element:i,meta:t},e,r){var n,o,l;let d={...i};const{node:f}=i;if((f==null?void 0:f.type)==="video"&&((n=f==null?void 0:f.value)!=null&&n.src||(o=f==null?void 0:f.value)!=null&&o.playlist)){const p=await e(f.value,t);let g;try{g=await zu(f.value.poster)}catch{g=null}d={...d,node:{...f,video:p,poster:g,meta:await r(f.value,p.node,t)}}}if((f==null?void 0:f.type)==="image"&&f.value){let p;try{p=await zu(f.value)}catch{p=null}d={...d,node:{...f,image:p}}}return d.node&&(l=i.node)!=null&&l.elements&&(d.node.elements=await Promise.all(i.node.elements.map(p=>hc({element:p,meta:t},e,r)))),i.elements&&(d.elements=await Promise.all(i.elements.map(p=>hc({element:p,meta:t},e,r)))),d}async function _o(){if(typeof window>"u"){const i=await Promise.resolve().then(()=>jp),t=new i.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function z1(i){var t;try{if((t=await Nm(i,{method:"HEAD"}))!=null&&t.ok)return i}catch{return}}async function Y1({sources:i}){let t=null;if(i){const e=i.filter(Boolean).map(r=>z1(r));t=(await Promise.all(e)).find(Boolean)}return t}function ya(i=[]){var t;for(const e of i){if(((t=e==null?void 0:e.node)==null?void 0:t.type)==="video")return e.node;const r=ya(e==null?void 0:e.elements);if(r)return r}}function X1(i,t){return i.reduce((e,r,n)=>[...e,r.map(({duration:o},l)=>n===i.length-1&&l===r.length-1?o:o-t)],[])}function Z1(i){if(i===null||typeof i!="object")return!1;if(Object.getPrototypeOf(i)===null)return!0;let t=i;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(i)===t}function q1(i){return i.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\f/g,"\\f").replace(/"/g,'\\"')}function Lo(i){return i.flatMap(t=>t).reduce((t,e)=>t+e,0)}oo.filters.define("parse",i=>typeof i>"u"?null:typeof i=="string"?`"${q1(i)}"`:Z1(i)||Array.isArray(i)?JSON.stringify(i):i),oo.helpers.define("resolve-source",ys(async i=>{const{sources:t}=i.params[0]??{},e=t==null?void 0:t.filter(Boolean),r=e==null?void 0:e.find(l=>l.includes("blob:")),n=e==null?void 0:e.find(l=>!l.includes("http")),o=r??n??await Y1({sources:t});return o?`"${o}"`:"null"},{cacheKey:([i])=>JSON.stringify(i.params[0]??{})}));const ba=(i,t,e)=>oo.render(i,t,oo.getConfig({autoEscape:!1,defaultFilter:"parse",async:!0,asyncHelpers:["resolve-source"],...e}));async function Tn({data:i,template:t,burnCaptions:e=!1,debug:r=!1},n,o){var l,d,f,p;const g=t??j1;if(!((l=g.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${g.id}`);let v=g.templates.find(({version:U})=>U===dc);if(!v){const U=g.templates.map(({version:x})=>`"${x}"`).join(", ");console.warn(`Template renderer expects template version "${dc}" but got ${U}`),v=g.templates[g.templates.length-1]}const A=await Promise.all(v.content.map(async({scenes:U,root:x})=>{const O={...g.options,...i,intro:g.intro,outro:g.outro};async function K(B,at){return Promise.all(U.map(async({layout:st,duration:J,data:Tt,options:ft})=>{var kt,Pt,F;const j={...O,index:at,root:B},bt=Tt?JSON.parse(await ba(Tt,j)):{},N=ft?JSON.parse(await ba(ft,j)):{},G=J?parseFloat(await ba(J,j)):NaN,Z=(kt=v.layouts.find(Bt=>Bt.name===st))==null?void 0:kt.tree;if(!Z)throw new Error(`Layout tree "${st}" not found in template "${v.id}" layouts.`);const gt=JSON.parse(await ba(Z,{...bt,...N})),vt=await Promise.all(gt.flatMap(Bt=>hc({element:Bt,meta:g.meta},n,o))),Ct=ya(vt);return{duration:(isNaN(G)?null:G)??((Pt=Ct==null?void 0:Ct.meta)==null?void 0:Pt.duration)??0,captions:(F=Ct==null?void 0:Ct.meta)==null?void 0:F.captions,elements:vt}}))}if(x){const B=JSON.parse(await ba(x,O));return Array.isArray(B)?(await Promise.all(B.map(async(at,st)=>K(at,st)))).flatMap(at=>at):K(B,null)}return K(i,null)}));if(A.every(U=>U.every(x=>{const O=ya(x.elements);return!(O!=null&&O.value.src)&&!(O!=null&&O.value.playlist)}))){const U=A.flatMap(x=>x.map(O=>{const K=ya(O.elements);return!(K!=null&&K.value.src)&&!(K!=null&&K.value.playlist)&&(K==null?void 0:K.value.id)}).filter(Boolean)).join(", ");throw new Error(`Video(s) with ID ${U} failed to load, video can not be processed`)}if(A.every(U=>U.every(x=>x.duration<=0)))throw new Error("No scenes have any duration, video can not be processed");const E=A.reduce((U,x)=>{const O=x.filter(K=>K.duration>0);return O.length>0&&(U=[...U,O]),U},[]),T=((d=g.meta)==null?void 0:d.frameRate)??30,w=((f=g.meta)==null?void 0:f.resolution)??720,C=((p=g.meta)==null?void 0:p.transitionDuration)??1/3,D=X1(E,C),M=Lo(D);return{scenes:(await Promise.all(E.map((U,x)=>{const O=Lo(D[x]),K=Lo(D.slice(0,x));return Promise.all(U.map(async({duration:B,captions:at,elements:st},J)=>{var Tt,ft;const kt=await _o(),Pt=await _o(),F=await _o(),j=await _o(),bt=ya(st),N=Lo([...D.slice(0,x),...D[x].slice(0,J)]);return{draw:({canvas:G,currentTime:Z})=>{const gt=Math.max(0,Z-K),vt=Math.max(0,Z-N);cc({debug:r,canvas:G,cropCanvas:kt,posterCanvas:j,letterboxCanvas:Pt,elements:st,currentTime:Z,contentTime:gt,sceneTime:vt,totalDuration:M,contentDuration:O,sceneDuration:B}),at&&e&&V1({canvas:G,dx:0,dy:0,dw:G.width,dh:G.height,vttCaptions:at,sceneTime:vt+((bt==null?void 0:bt.meta.start)??0)})},duration:B,transitionCanvas:F,start:N,video:bt==null?void 0:bt.video,videoMeta:bt==null?void 0:bt.meta,audio:{duration:B,src:(Tt=bt==null?void 0:bt.value)==null?void 0:Tt.src,start:(ft=bt==null?void 0:bt.meta)==null?void 0:ft.start}}}))}))).flatMap(U=>U),frameRate:T,resolution:w,transitionDuration:C,fonts:v.fonts??[],duration:M}}const dc="2",Q1={name:"@vouchfor/embeds",version:"1.2.0",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"latest",access:"public"},scripts:{build:"rm -rf dist && tsc && yarn build:self","build:deps":"yarn --cwd ../media-player build","build:self":"vite build --mode iife && vite build --mode es && node scripts/build.cjs","build:package":"yarn build","build:storybook":"yarn prebuild && storybook build","generate:manifest":"wca src --outFile custom-elements.json",lint:"eslint . --quiet","lint:fix":"eslint . --fix","lint:staged":"lint-staged",prepublishOnly:"yarn build",size:"size-limit",storybook:"yarn prebuild && storybook dev -p 6007",prebuild:"yarn build:deps && yarn generate:manifest",test:"rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner","test:ci":"yarn test --config web-test-runner.ci.config.js"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@a11y/focus-trap":"^1.0.5","@lit/task":"^1.0.0","@vouchfor/media-player":"^2.1.0",uuid:"^9.0.1"},peerDependencies:{lit:"^3.1.0"},devDependencies:{"@esm-bundle/chai":"^4.3.4-fix.0","@open-wc/testing":"^3.2.0","@storybook/addon-essentials":"^7.4.5","@storybook/addon-links":"^7.4.5","@storybook/blocks":"^7.4.5","@storybook/web-components":"^7.4.5","@storybook/web-components-vite":"^7.4.5","@types/mocha":"^10.0.1","@vouchfor/eslint-config":"^1.0.0","@vouchfor/prettier-config":"^1.0.0","@web/dev-server-esbuild":"^0.4.1","@web/test-runner":"^0.17.1","@web/test-runner-browserstack":"^0.6.1","@web/test-runner-mocha":"^0.8.1","@web/test-runner-playwright":"^0.10.1",dotenv:"^16.3.1",eslint:"^8.50.0","eslint-plugin-import":"^2.28.1",glob:"^10.3.10","lint-staged":"^14.0.1",lit:"^3.1.0",lodash:"^4.17.21",prettier:"^3.0.3",react:"^18.2.0","react-dom":"^18.2.0","rollup-plugin-internal":"^1.0.4",sinon:"^17.0.1",storybook:"^7.4.5",typescript:"^5.1.3",vite:"^4.4.9","vite-plugin-commonjs":"^0.10.0","vite-plugin-dts":"^3.6.0","web-component-analyzer":"^1.1.7"}};function J1(i){const{publicApiUrl:t}=no(i),e=Qs();return navigator.sendBeacon(`${t}/api/visitor`,JSON.stringify({visitorId:e})),e}function tv(i){var o,l,d,f,p,g,v,A,E,T,w,C;if(typeof window>"u")return{client:null,tab:null,request:Qs()};let t=(l=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:l.call(o,"vouch-uid-visitor"),e=(f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"),r=(g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab");const n=Qs();return t||(t=J1(i),(A=(v=window.localStorage)==null?void 0:v.setItem)==null||A.call(v,"vouch-uid-visitor",t)),e||(e=Qs(),(T=(E=window.localStorage)==null?void 0:E.setItem)==null||T.call(E,"vouch-uid-client",e)),r||(r=Qs(),(C=(w=window.sessionStorage)==null?void 0:w.setItem)==null||C.call(w,"vouch-uid-tab",r)),{client:e,tab:r,request:n,visitor:t}}function ev(i,t){return i&&"vouchId"in i?i.vouchId:(t==null?void 0:t.id)??null}function rv(i="embedded_player"){var n,o;const[t,e]=((o=(n=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:n.split)==null?void 0:o.call(n,"/"))??[],r={};return[...new URLSearchParams(location.search).entries()].forEach(([l,d])=>{if(/utm/.test(l)){const f=l.toLowerCase().replace(/[-_][a-z0-9]/g,p=>p.slice(-1).toUpperCase());r[f]=d}}),{source:i,time:new Date,region:e,country:t,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:Q1.version,templateVersion:dc,...r}}const Yu=1;class iv{constructor(t){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(e,r)=>{const n=ev(r,this.host.vouch);!n||this.host.disableTracking||this._batchedEvents.push({event:e,payload:{...r,vouchId:n,time:new Date().toISOString()}})},this._sendTrackingEvent=()=>{if(this._batchedEvents.length<=0)return;const{publicApiUrl:e}=no(this.host.env),{client:r,tab:n,request:o,visitor:l}=tv(this.host.env);navigator.sendBeacon(`${e}/api/batchevents`,JSON.stringify({payload:{events:this._batchedEvents},context:{"x-uid-client":r,"x-uid-tab":n,"x-uid-request":o,"x-uid-visitor":l,"x-reporting-metadata":rv(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:e,key:r}=this._currentlyPlayingVideo;this._streamLatestTime[r]>this._streamStartTime[r]+Yu&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[r],streamEnd:this._streamLatestTime[r]}),delete this._streamStartTime[r],delete this._streamLatestTime[r]}},this._handleVouchLoaded=({detail:e})=>{e&&(this._hasLoaded[e]||(this._createTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._createTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:e,key:r}})=>{this._answersViewed[r]||(this._createTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:e}),this._answersViewed[r]=!0)},this._handleVideoTimeUpdate=({detail:{id:e,key:r,node:n}})=>{var o,l;!this.host.paused&&e===((l=(o=this.host.scene)==null?void 0:o.video)==null?void 0:l.id)&&(this._currentlyPlayingVideo={id:e,key:r,node:n},this._streamLatestTime[r]=n.currentTime,this._streamStartTime[r]||(this._streamStartTime[r]=n.currentTime,this._streamLatestTime[r]=n.currentTime))},this._handleVideoPause=({detail:{id:e,key:r}})=>{this._streamLatestTime[r]>this._streamStartTime[r]+Yu&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[r],streamEnd:this._streamLatestTime[r]}),delete this._streamStartTime[r],delete this._streamLatestTime[r]},this._pageUnloading=()=>{this._streamEnded(),this._sendTrackingEvent()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=t,t.addController(this)}hostConnected(){requestAnimationFrame(()=>{var t,e,r,n;"onvisibilitychange"in document?document.addEventListener("visibilitychange",this._handleVisibilityChange):window.addEventListener("pagehide",this._handlePageHide),this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.addEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.addEventListener("video:play",this._handleVideoPlay),(r=this.host.mediaPlayer)==null||r.addEventListener("video:pause",this._handleVideoPause),(n=this.host.mediaPlayer)==null||n.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,r,n;this._pageUnloading(),"onvisibilitychange"in document?document.removeEventListener("visibilitychange",this._handleVisibilityChange):window.removeEventListener("pagehide",this._handlePageHide),this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.removeEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.removeEventListener("video:play",this._handleVideoPlay),(r=this.host.mediaPlayer)==null||r.removeEventListener("video:pause",this._handleVideoPause),(n=this.host.mediaPlayer)==null||n.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}const sv=i=>{class t extends i{constructor(){super(...arguments),this._mediaPlayerRef=_r()}get waiting(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.waiting}get initialised(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.initialised}get seeking(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.seeking}get paused(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.paused}get captions(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.captions}get fullscreen(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.fullscreen}get duration(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.duration}set currentTime(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.currentTime=r)}get currentTime(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.currentTime)??0}set playbackRate(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.playbackRate=r)}get playbackRate(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.playbackRate)??1}set volume(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.volume=r)}get volume(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.volume)??1}set muted(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.muted=r)}get muted(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.muted)??!1}get scene(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.scene)??null}get scenes(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.scenes)??[]}get sceneConfig(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.sceneConfig)??null}get videoState(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.videoState}get mediaPlayer(){return this._mediaPlayerRef.value}play(){var r;(r=this._mediaPlayerRef.value)==null||r.play()}pause(){var r;(r=this._mediaPlayerRef.value)==null||r.pause()}reset(r=0,n=!1){var o;(o=this._mediaPlayerRef.value)==null||o.reset(r,n)}setScene(r){var n;(n=this._mediaPlayerRef.value)==null||n.setScene(r)}}return t};/**
171
+ }`}],root:"{{ it.outro?.questions?.items }}"}],system:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},j1={id:"073977ec-6384-4329-b7c5-8275fb513e74",name:"None",entityId:"none",templateId:"a95e537e-fb4d-4d2f-9c72-86c0925c7176",templates:[W1],meta:{frameRate:30,resolution:720,transitionDuration:1/3},system:!0,default:0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};async function K1(){if(typeof window>"u"){const i=await Promise.resolve().then(()=>jp);return new i.Image}return new Image}const zu=ys(async function(i){return i?new Promise((t,e)=>{K1().then(r=>{r.onload=()=>{t(r)},r.onerror=n=>{e(n)},r.src=i})}):null});async function hc({element:i,meta:t},e,r){var n,o,l;let d={...i};const{node:f}=i;if((f==null?void 0:f.type)==="video"&&((n=f==null?void 0:f.value)!=null&&n.src||(o=f==null?void 0:f.value)!=null&&o.playlist)){const p=await e(f.value,t);let g;try{g=await zu(f.value.poster)}catch{g=null}d={...d,node:{...f,video:p,poster:g,meta:await r(f.value,p.node,t)}}}if((f==null?void 0:f.type)==="image"&&f.value){let p;try{p=await zu(f.value)}catch{p=null}d={...d,node:{...f,image:p}}}return d.node&&(l=i.node)!=null&&l.elements&&(d.node.elements=await Promise.all(i.node.elements.map(p=>hc({element:p,meta:t},e,r)))),i.elements&&(d.elements=await Promise.all(i.elements.map(p=>hc({element:p,meta:t},e,r)))),d}async function _o(){if(typeof window>"u"){const i=await Promise.resolve().then(()=>jp),t=new i.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function z1(i){var t;try{if((t=await Nm(i,{method:"HEAD"}))!=null&&t.ok)return i}catch{return}}async function Y1({sources:i}){let t=null;if(i){const e=i.filter(Boolean).map(r=>z1(r));t=(await Promise.all(e)).find(Boolean)}return t}function ya(i=[]){var t;for(const e of i){if(((t=e==null?void 0:e.node)==null?void 0:t.type)==="video")return e.node;const r=ya(e==null?void 0:e.elements);if(r)return r}}function X1(i,t){return i.reduce((e,r,n)=>[...e,r.map(({duration:o},l)=>n===i.length-1&&l===r.length-1?o:o-t)],[])}function Z1(i){if(i===null||typeof i!="object")return!1;if(Object.getPrototypeOf(i)===null)return!0;let t=i;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(i)===t}function q1(i){return i.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\f/g,"\\f").replace(/"/g,'\\"')}function Lo(i){return i.flatMap(t=>t).reduce((t,e)=>t+e,0)}oo.filters.define("parse",i=>typeof i>"u"?null:typeof i=="string"?`"${q1(i)}"`:Z1(i)||Array.isArray(i)?JSON.stringify(i):i),oo.helpers.define("resolve-source",ys(async i=>{const{sources:t}=i.params[0]??{},e=t==null?void 0:t.filter(Boolean),r=e==null?void 0:e.find(l=>l.includes("blob:")),n=e==null?void 0:e.find(l=>!l.includes("http")),o=r??n??await Y1({sources:t});return o?`"${o}"`:"null"},{cacheKey:([i])=>JSON.stringify(i.params[0]??{})}));const ba=(i,t,e)=>oo.render(i,t,oo.getConfig({autoEscape:!1,defaultFilter:"parse",async:!0,asyncHelpers:["resolve-source"],...e}));async function Tn({data:i,template:t,burnCaptions:e=!1,debug:r=!1},n,o){var l,d,f,p;const g=t??j1;if(!((l=g.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${g.id}`);let v=g.templates.find(({version:U})=>U===dc);if(!v){const U=g.templates.map(({version:x})=>`"${x}"`).join(", ");console.warn(`Template renderer expects template version "${dc}" but got ${U}`),v=g.templates[g.templates.length-1]}const A=await Promise.all(v.content.map(async({scenes:U,root:x})=>{const O={...g.options,...i,intro:g.intro,outro:g.outro};async function K(B,at){return Promise.all(U.map(async({layout:st,duration:J,data:Tt,options:ft})=>{var kt,Pt,F;const j={...O,index:at,root:B},bt=Tt?JSON.parse(await ba(Tt,j)):{},N=ft?JSON.parse(await ba(ft,j)):{},G=J?parseFloat(await ba(J,j)):NaN,Z=(kt=v.layouts.find(Bt=>Bt.name===st))==null?void 0:kt.tree;if(!Z)throw new Error(`Layout tree "${st}" not found in template "${v.id}" layouts.`);const gt=JSON.parse(await ba(Z,{...bt,...N})),vt=await Promise.all(gt.flatMap(Bt=>hc({element:Bt,meta:g.meta},n,o))),Ct=ya(vt);return{duration:(isNaN(G)?null:G)??((Pt=Ct==null?void 0:Ct.meta)==null?void 0:Pt.duration)??0,captions:(F=Ct==null?void 0:Ct.meta)==null?void 0:F.captions,elements:vt}}))}if(x){const B=JSON.parse(await ba(x,O));return Array.isArray(B)?(await Promise.all(B.map(async(at,st)=>K(at,st)))).flatMap(at=>at):K(B,null)}return K(i,null)}));if(A.every(U=>U.every(x=>{const O=ya(x.elements);return!(O!=null&&O.value.src)&&!(O!=null&&O.value.playlist)}))){const U=A.flatMap(x=>x.map(O=>{const K=ya(O.elements);return!(K!=null&&K.value.src)&&!(K!=null&&K.value.playlist)&&(K==null?void 0:K.value.id)}).filter(Boolean)).join(", ");throw new Error(`Video(s) with ID ${U} failed to load, video can not be processed`)}if(A.every(U=>U.every(x=>x.duration<=0)))throw new Error("No scenes have any duration, video can not be processed");const E=A.reduce((U,x)=>{const O=x.filter(K=>K.duration>0);return O.length>0&&(U=[...U,O]),U},[]),T=((d=g.meta)==null?void 0:d.frameRate)??30,w=((f=g.meta)==null?void 0:f.resolution)??720,C=((p=g.meta)==null?void 0:p.transitionDuration)??1/3,D=X1(E,C),M=Lo(D);return{scenes:(await Promise.all(E.map((U,x)=>{const O=Lo(D[x]),K=Lo(D.slice(0,x));return Promise.all(U.map(async({duration:B,captions:at,elements:st},J)=>{var Tt,ft;const kt=await _o(),Pt=await _o(),F=await _o(),j=await _o(),bt=ya(st),N=Lo([...D.slice(0,x),...D[x].slice(0,J)]);return{draw:({canvas:G,currentTime:Z})=>{const gt=Math.max(0,Z-K),vt=Math.max(0,Z-N);cc({debug:r,canvas:G,cropCanvas:kt,posterCanvas:j,letterboxCanvas:Pt,elements:st,currentTime:Z,contentTime:gt,sceneTime:vt,totalDuration:M,contentDuration:O,sceneDuration:B}),at&&e&&V1({canvas:G,dx:0,dy:0,dw:G.width,dh:G.height,vttCaptions:at,sceneTime:vt+((bt==null?void 0:bt.meta.start)??0)})},duration:B,transitionCanvas:F,start:N,video:bt==null?void 0:bt.video,videoMeta:bt==null?void 0:bt.meta,audio:{duration:B,src:(Tt=bt==null?void 0:bt.value)==null?void 0:Tt.src,start:(ft=bt==null?void 0:bt.meta)==null?void 0:ft.start}}}))}))).flatMap(U=>U),frameRate:T,resolution:w,transitionDuration:C,fonts:v.fonts??[],duration:M}}const dc="2",Q1={name:"@vouchfor/embeds",version:"1.2.2",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"latest",access:"public"},scripts:{build:"rm -rf dist && tsc && yarn build:self","build:deps":"yarn --cwd ../media-player build","build:self":"vite build --mode iife && vite build --mode es && node scripts/build.cjs","build:package":"yarn build","build:storybook":"yarn prebuild && storybook build","generate:manifest":"wca src --outFile custom-elements.json",lint:"eslint . --quiet","lint:fix":"eslint . --fix","lint:staged":"lint-staged",prepublishOnly:"yarn build",size:"size-limit",storybook:"yarn prebuild && storybook dev -p 6007",prebuild:"yarn build:deps && yarn generate:manifest",test:"rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner","test:ci":"yarn test --config web-test-runner.ci.config.js"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@a11y/focus-trap":"^1.0.5","@lit/task":"^1.0.0","@vouchfor/media-player":"^2.1.0",uuid:"^9.0.1"},peerDependencies:{lit:"^3.1.0"},devDependencies:{"@esm-bundle/chai":"^4.3.4-fix.0","@open-wc/testing":"^3.2.0","@storybook/addon-essentials":"^7.4.5","@storybook/addon-links":"^7.4.5","@storybook/blocks":"^7.4.5","@storybook/web-components":"^7.4.5","@storybook/web-components-vite":"^7.4.5","@types/mocha":"^10.0.1","@vouchfor/eslint-config":"^1.0.0","@vouchfor/prettier-config":"^1.0.0","@web/dev-server-esbuild":"^0.4.1","@web/test-runner":"^0.17.1","@web/test-runner-browserstack":"^0.6.1","@web/test-runner-mocha":"^0.8.1","@web/test-runner-playwright":"^0.10.1",dotenv:"^16.3.1",eslint:"^8.50.0","eslint-plugin-import":"^2.28.1",glob:"^10.3.10","lint-staged":"^14.0.1",lit:"^3.1.0",lodash:"^4.17.21",prettier:"^3.0.3",react:"^18.2.0","react-dom":"^18.2.0","rollup-plugin-internal":"^1.0.4",sinon:"^17.0.1",storybook:"^7.4.5",typescript:"^5.1.3",vite:"^4.4.9","vite-plugin-commonjs":"^0.10.0","vite-plugin-dts":"^3.6.0","web-component-analyzer":"^1.1.7"}};function J1(i){const{publicApiUrl:t}=no(i),e=Qs();return navigator.sendBeacon(`${t}/api/visitor`,JSON.stringify({visitorId:e})),e}function tv(i){var o,l,d,f,p,g,v,A,E,T,w,C;if(typeof window>"u")return{client:null,tab:null,request:Qs()};let t=(l=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:l.call(o,"vouch-uid-visitor"),e=(f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"),r=(g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab");const n=Qs();return t||(t=J1(i),(A=(v=window.localStorage)==null?void 0:v.setItem)==null||A.call(v,"vouch-uid-visitor",t)),e||(e=Qs(),(T=(E=window.localStorage)==null?void 0:E.setItem)==null||T.call(E,"vouch-uid-client",e)),r||(r=Qs(),(C=(w=window.sessionStorage)==null?void 0:w.setItem)==null||C.call(w,"vouch-uid-tab",r)),{client:e,tab:r,request:n,visitor:t}}function ev(i,t){return i&&"vouchId"in i?i.vouchId:(t==null?void 0:t.id)??null}function rv(i="embedded_player"){var n,o;const[t,e]=((o=(n=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:n.split)==null?void 0:o.call(n,"/"))??[],r={};return[...new URLSearchParams(location.search).entries()].forEach(([l,d])=>{if(/utm/.test(l)){const f=l.toLowerCase().replace(/[-_][a-z0-9]/g,p=>p.slice(-1).toUpperCase());r[f]=d}}),{source:i,time:new Date,region:e,country:t,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:Q1.version,templateVersion:dc,...r}}const Yu=1;class iv{constructor(t){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(e,r)=>{const n=ev(r,this.host.vouch);!n||this.host.disableTracking||this._batchedEvents.push({event:e,payload:{...r,vouchId:n,time:new Date().toISOString()}})},this._sendTrackingEvent=()=>{if(this._batchedEvents.length<=0)return;const{publicApiUrl:e}=no(this.host.env),{client:r,tab:n,request:o,visitor:l}=tv(this.host.env);navigator.sendBeacon(`${e}/api/batchevents`,JSON.stringify({payload:{events:this._batchedEvents},context:{"x-uid-client":r,"x-uid-tab":n,"x-uid-request":o,"x-uid-visitor":l,"x-reporting-metadata":rv(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:e,key:r}=this._currentlyPlayingVideo;this._streamLatestTime[r]>this._streamStartTime[r]+Yu&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[r],streamEnd:this._streamLatestTime[r]}),delete this._streamStartTime[r],delete this._streamLatestTime[r]}},this._handleVouchLoaded=({detail:e})=>{e&&(this._hasLoaded[e]||(this._createTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._createTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:e,key:r}})=>{this._answersViewed[r]||(this._createTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:e}),this._answersViewed[r]=!0)},this._handleVideoTimeUpdate=({detail:{id:e,key:r,node:n}})=>{var o,l;!this.host.paused&&e===((l=(o=this.host.scene)==null?void 0:o.video)==null?void 0:l.id)&&(this._currentlyPlayingVideo={id:e,key:r,node:n},this._streamLatestTime[r]=n.currentTime,this._streamStartTime[r]||(this._streamStartTime[r]=n.currentTime,this._streamLatestTime[r]=n.currentTime))},this._handleVideoPause=({detail:{id:e,key:r}})=>{this._streamLatestTime[r]>this._streamStartTime[r]+Yu&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[r],streamEnd:this._streamLatestTime[r]}),delete this._streamStartTime[r],delete this._streamLatestTime[r]},this._pageUnloading=()=>{this._streamEnded(),this._sendTrackingEvent()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=t,t.addController(this)}hostConnected(){requestAnimationFrame(()=>{var t,e,r,n;"onvisibilitychange"in document?document.addEventListener("visibilitychange",this._handleVisibilityChange):window.addEventListener("pagehide",this._handlePageHide),this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.addEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.addEventListener("video:play",this._handleVideoPlay),(r=this.host.mediaPlayer)==null||r.addEventListener("video:pause",this._handleVideoPause),(n=this.host.mediaPlayer)==null||n.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,r,n;this._pageUnloading(),"onvisibilitychange"in document?document.removeEventListener("visibilitychange",this._handleVisibilityChange):window.removeEventListener("pagehide",this._handlePageHide),this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.removeEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.removeEventListener("video:play",this._handleVideoPlay),(r=this.host.mediaPlayer)==null||r.removeEventListener("video:pause",this._handleVideoPause),(n=this.host.mediaPlayer)==null||n.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}const sv=i=>{class t extends i{constructor(){super(...arguments),this._mediaPlayerRef=_r()}get waiting(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.waiting}get initialised(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.initialised}get seeking(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.seeking}get paused(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.paused}get captions(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.captions}get fullscreen(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.fullscreen}get duration(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.duration}set currentTime(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.currentTime=r)}get currentTime(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.currentTime)??0}set playbackRate(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.playbackRate=r)}get playbackRate(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.playbackRate)??1}set volume(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.volume=r)}get volume(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.volume)??1}set muted(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.muted=r)}get muted(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.muted)??!1}get scene(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.scene)??null}get scenes(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.scenes)??[]}get sceneConfig(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.sceneConfig)??null}get videoState(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.videoState}get mediaPlayer(){return this._mediaPlayerRef.value}play(){var r;(r=this._mediaPlayerRef.value)==null||r.play()}pause(){var r;(r=this._mediaPlayerRef.value)==null||r.pause()}reset(r=0,n=!1){var o;(o=this._mediaPlayerRef.value)==null||o.reset(r,n)}setScene(r){var n;(n=this._mediaPlayerRef.value)==null||n.setScene(r)}}return t};/**
172
172
  * @license
173
173
  * Copyright 2018 Google LLC
174
174
  * SPDX-License-Identifier: BSD-3-Clause
@@ -1,4 +1,4 @@
1
- import { P as a } from "./index-7e54dc9a.js";
1
+ import { P as a } from "./index-86dfade0.js";
2
2
  export {
3
3
  a as PlayerEmbed
4
4
  };
@@ -11276,7 +11276,7 @@ const t4 = {
11276
11276
  };
11277
11277
  async function r4() {
11278
11278
  if (typeof window > "u") {
11279
- const s = await import("./browser-165af7be.js").then((t) => t.b);
11279
+ const s = await import("./browser-951710ee.js").then((t) => t.b);
11280
11280
  return new s.Image();
11281
11281
  }
11282
11282
  return new Image();
@@ -11337,7 +11337,7 @@ async function Bc({ element: s, meta: t }, e, r) {
11337
11337
  }
11338
11338
  async function oo() {
11339
11339
  if (typeof window > "u") {
11340
- const s = await import("./browser-165af7be.js").then((e) => e.b), t = new s.Canvas();
11340
+ const s = await import("./browser-951710ee.js").then((e) => e.b), t = new s.Canvas();
11341
11341
  return t.gpu = !1, t;
11342
11342
  }
11343
11343
  return document.createElement("canvas");
@@ -11539,7 +11539,7 @@ async function Cn({ data: s, template: t, burnCaptions: e = !1, debug: r = !1 },
11539
11539
  duration: M
11540
11540
  };
11541
11541
  }
11542
- const Gc = "2", l4 = "@vouchfor/embeds", c4 = "1.2.0", h4 = "MIT", d4 = "Aaron Williams", u4 = "dist/es/embeds.js", f4 = "dist/es/embeds.js", p4 = "module", g4 = "dist/es/src/index.d.ts", m4 = {
11542
+ const Gc = "2", l4 = "@vouchfor/embeds", c4 = "1.2.2", h4 = "MIT", d4 = "Aaron Williams", u4 = "dist/es/embeds.js", f4 = "dist/es/embeds.js", p4 = "module", g4 = "dist/es/src/index.d.ts", m4 = {
11543
11543
  ".": "./dist/es/embeds.js"
11544
11544
  }, v4 = [
11545
11545
  "dist",
@@ -32816,4 +32816,4 @@ export {
32816
32816
  xc as c,
32817
32817
  jf as g
32818
32818
  };
32819
- //# sourceMappingURL=index-7e54dc9a.js.map
32819
+ //# sourceMappingURL=index-86dfade0.js.map