@loaders.gl/video 4.2.0-alpha.4 → 4.2.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.dev.js CHANGED
@@ -2,14 +2,19 @@
2
2
  if (typeof exports === 'object' && typeof module === 'object')
3
3
  module.exports = factory();
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
- else if (typeof exports === 'object') exports['loader'] = factory();
6
- else root['loader'] = factory();})(globalThis, function () {
5
+ else if (typeof exports === 'object') exports['loaders'] = factory();
6
+ else root['loaders'] = factory();})(globalThis, function () {
7
7
  "use strict";
8
8
  var __exports__ = (() => {
9
+ var __create = Object.create;
9
10
  var __defProp = Object.defineProperty;
10
11
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __getProtoOf = Object.getPrototypeOf;
12
14
  var __hasOwnProp = Object.prototype.hasOwnProperty;
15
+ var __commonJS = (cb, mod) => function __require() {
16
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
+ };
13
18
  var __export = (target, all) => {
14
19
  for (var name in all)
15
20
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -22,14 +27,31 @@ var __exports__ = (() => {
22
27
  }
23
28
  return to;
24
29
  };
30
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
31
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
32
+ // If the importer is in node compatibility mode or this is not an ESM
33
+ // file that has been converted to a CommonJS file using a Babel-
34
+ // compatible transform (i.e. "__esModule" has not been set), then set
35
+ // "default" to the CommonJS "module.exports" for node compatibility.
36
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
37
+ mod
38
+ ));
25
39
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
40
 
27
- // src/index.ts
28
- var src_exports = {};
29
- __export(src_exports, {
41
+ // external-global-plugin:@loaders.gl/core
42
+ var require_core = __commonJS({
43
+ "external-global-plugin:@loaders.gl/core"(exports, module) {
44
+ module.exports = globalThis.loaders;
45
+ }
46
+ });
47
+
48
+ // bundle.ts
49
+ var bundle_exports = {};
50
+ __export(bundle_exports, {
30
51
  GIFBuilder: () => GIFBuilder,
31
52
  VideoLoader: () => VideoLoader
32
53
  });
54
+ __reExport(bundle_exports, __toESM(require_core(), 1));
33
55
 
34
56
  // src/lib/parsers/parse-video.ts
35
57
  async function parseVideo(arrayBuffer) {
@@ -40,7 +62,7 @@ var __exports__ = (() => {
40
62
  }
41
63
 
42
64
  // src/video-loader.ts
43
- var VERSION = true ? "4.2.0-alpha.4" : "latest";
65
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
44
66
  var EXTENSIONS = ["mp4"];
45
67
  var MIME_TYPES = ["video/mp4"];
46
68
  var DEFAULT_LOADER_OPTIONS = {
@@ -54,6 +76,7 @@ var __exports__ = (() => {
54
76
  extensions: EXTENSIONS,
55
77
  mimeTypes: MIME_TYPES,
56
78
  parse: parseVideo,
79
+ // tests: arrayBuffer => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer))),
57
80
  options: DEFAULT_LOADER_OPTIONS
58
81
  };
59
82
 
@@ -315,35 +338,43 @@ var __exports__ = (() => {
315
338
  const isValid2 = errorObj.error !== true;
316
339
  return isValid2;
317
340
  },
318
- validators: [{
319
- condition: utils.isFunction(utils.getUserMedia),
320
- errorCode: "getUserMedia",
321
- errorMsg: "The getUserMedia API is not supported in your browser"
322
- }, {
323
- condition: utils.isSupported.canvas(),
324
- errorCode: "canvas",
325
- errorMsg: "Canvas elements are not supported in your browser"
326
- }, {
327
- condition: utils.isSupported.webworkers(),
328
- errorCode: "webworkers",
329
- errorMsg: "The Web Workers API is not supported in your browser"
330
- }, {
331
- condition: utils.isFunction(utils.URL),
332
- errorCode: "globalThis.URL",
333
- errorMsg: "The globalThis.URL API is not supported in your browser"
334
- }, {
335
- condition: utils.isSupported.blob(),
336
- errorCode: "globalThis.Blob",
337
- errorMsg: "The globalThis.Blob File API is not supported in your browser"
338
- }, {
339
- condition: utils.isSupported.Uint8Array(),
340
- errorCode: "globalThis.Uint8Array",
341
- errorMsg: "The globalThis.Uint8Array function constructor is not supported in your browser"
342
- }, {
343
- condition: utils.isSupported.Uint32Array(),
344
- errorCode: "globalThis.Uint32Array",
345
- errorMsg: "The globalThis.Uint32Array function constructor is not supported in your browser"
346
- }],
341
+ validators: [
342
+ {
343
+ condition: utils.isFunction(utils.getUserMedia),
344
+ errorCode: "getUserMedia",
345
+ errorMsg: "The getUserMedia API is not supported in your browser"
346
+ },
347
+ {
348
+ condition: utils.isSupported.canvas(),
349
+ errorCode: "canvas",
350
+ errorMsg: "Canvas elements are not supported in your browser"
351
+ },
352
+ {
353
+ condition: utils.isSupported.webworkers(),
354
+ errorCode: "webworkers",
355
+ errorMsg: "The Web Workers API is not supported in your browser"
356
+ },
357
+ {
358
+ condition: utils.isFunction(utils.URL),
359
+ errorCode: "globalThis.URL",
360
+ errorMsg: "The globalThis.URL API is not supported in your browser"
361
+ },
362
+ {
363
+ condition: utils.isSupported.blob(),
364
+ errorCode: "globalThis.Blob",
365
+ errorMsg: "The globalThis.Blob File API is not supported in your browser"
366
+ },
367
+ {
368
+ condition: utils.isSupported.Uint8Array(),
369
+ errorCode: "globalThis.Uint8Array",
370
+ errorMsg: "The globalThis.Uint8Array function constructor is not supported in your browser"
371
+ },
372
+ {
373
+ condition: utils.isSupported.Uint32Array(),
374
+ errorCode: "globalThis.Uint32Array",
375
+ errorMsg: "The globalThis.Uint32Array function constructor is not supported in your browser"
376
+ }
377
+ ],
347
378
  messages: {
348
379
  videoCodecs: {
349
380
  errorCode: "videocodec",
@@ -842,6 +873,7 @@ var __exports__ = (() => {
842
873
  }
843
874
  return paletteArray;
844
875
  },
876
+ // This is the "traditional" Animated_GIF style of going from RGBA to indexed color frames
845
877
  processFrameWithQuantizer: function processFrameWithQuantizer(imageData, width, height, sampleInterval) {
846
878
  const rgbComponents = this.dataToRGB(imageData, width, height);
847
879
  const nq = new NeuQuant(rgbComponents, rgbComponents.length, sampleInterval);
@@ -899,7 +931,8 @@ var __exports__ = (() => {
899
931
  buf[p++] = width >> 8 & 255;
900
932
  buf[p++] = height & 255;
901
933
  buf[p++] = height >> 8 & 255;
902
- buf[p++] = (global_palette !== null ? 128 : 0) | gp_num_colors_pow2;
934
+ buf[p++] = (global_palette !== null ? 128 : 0) | // Global Color Table Flag.
935
+ gp_num_colors_pow2;
903
936
  buf[p++] = background;
904
937
  buf[p++] = 0;
905
938
  if (loop_count !== null) {
@@ -1123,9 +1156,11 @@ var __exports__ = (() => {
1123
1156
  this.ctx = this.canvas.getContext("2d");
1124
1157
  this.frames = [];
1125
1158
  },
1159
+ // Return a worker for processing a frame
1126
1160
  getWorker: function getWorker() {
1127
1161
  return this.availableWorkers.pop();
1128
1162
  },
1163
+ // Restores a worker to the pool
1129
1164
  freeWorker: function freeWorker(worker) {
1130
1165
  this.availableWorkers.push(worker);
1131
1166
  },
@@ -1225,6 +1260,8 @@ var __exports__ = (() => {
1225
1260
  this.processFrame(position);
1226
1261
  }
1227
1262
  },
1263
+ // Takes the already processed data in frames and feeds it to a new
1264
+ // GifWriter instance in order to get the binary GIF file
1228
1265
  generateGIF: function generateGIF(frames, callback) {
1229
1266
  const buffer = [];
1230
1267
  const gifOptions = {
@@ -1263,6 +1300,7 @@ var __exports__ = (() => {
1263
1300
  callback(gif);
1264
1301
  }
1265
1302
  },
1303
+ // From GIF: 0 = loop forever, null = not looping, n > 0 = loop n times and stop
1266
1304
  setRepeat: function setRepeat(r) {
1267
1305
  this.repeat = r;
1268
1306
  },
@@ -1513,7 +1551,17 @@ var __exports__ = (() => {
1513
1551
  sourceY = 0;
1514
1552
  }
1515
1553
  context.filter = filter;
1516
- context.drawImage(videoElement, sourceX, sourceY, sourceWidth, sourceHeight, 0, 0, gifWidth, gifHeight);
1554
+ context.drawImage(
1555
+ videoElement,
1556
+ sourceX,
1557
+ sourceY,
1558
+ sourceWidth,
1559
+ sourceHeight,
1560
+ 0,
1561
+ 0,
1562
+ gifWidth,
1563
+ gifHeight
1564
+ );
1517
1565
  finishCapture();
1518
1566
  } catch (e) {
1519
1567
  if (e.name === "NS_ERROR_NOT_AVAILABLE") {
@@ -1653,7 +1701,9 @@ var __exports__ = (() => {
1653
1701
  if (existingVideo2) {
1654
1702
  if (utils.isString(existingVideo2)) {
1655
1703
  videoElement.src = existingVideo2;
1656
- videoElement.innerHTML = `<source src="${existingVideo2}" type="video/${utils.getExtension(existingVideo2)}" />`;
1704
+ videoElement.innerHTML = `<source src="${existingVideo2}" type="video/${utils.getExtension(
1705
+ existingVideo2
1706
+ )}" />`;
1657
1707
  } else if (existingVideo2 instanceof Blob) {
1658
1708
  try {
1659
1709
  videoElement.src = utils.URL.createObjectURL(existingVideo2);
@@ -1732,16 +1782,20 @@ var __exports__ = (() => {
1732
1782
  completedCallback
1733
1783
  });
1734
1784
  } else {
1735
- utils.getUserMedia({
1736
- video: true
1737
- }, function(stream2) {
1738
- videoStream.stream({
1739
- videoElement,
1740
- cameraStream: stream2,
1741
- streamedCallback,
1742
- completedCallback
1743
- });
1744
- }, errorCallback);
1785
+ utils.getUserMedia(
1786
+ {
1787
+ video: true
1788
+ },
1789
+ function(stream2) {
1790
+ videoStream.stream({
1791
+ videoElement,
1792
+ cameraStream: stream2,
1793
+ streamedCallback,
1794
+ completedCallback
1795
+ });
1796
+ },
1797
+ errorCallback
1798
+ );
1745
1799
  }
1746
1800
  },
1747
1801
  startVideoStreaming: function startVideoStreaming(callback) {
@@ -1922,16 +1976,19 @@ var __exports__ = (() => {
1922
1976
  });
1923
1977
  return;
1924
1978
  }
1925
- videoStream.startVideoStreaming(function() {
1926
- const obj2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1927
- obj2.options = options || {};
1928
- createAndGetGIF(obj2, callback);
1929
- }, {
1930
- lastCameraStream,
1931
- callback,
1932
- webcamVideoElement,
1933
- crossOrigin: options.crossOrigin
1934
- });
1979
+ videoStream.startVideoStreaming(
1980
+ function() {
1981
+ const obj2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1982
+ obj2.options = options || {};
1983
+ createAndGetGIF(obj2, callback);
1984
+ },
1985
+ {
1986
+ lastCameraStream,
1987
+ callback,
1988
+ webcamVideoElement,
1989
+ crossOrigin: options.crossOrigin
1990
+ }
1991
+ );
1935
1992
  }
1936
1993
  function createGIF(userOptions, callback) {
1937
1994
  callback = utils.isFunction(userOptions) ? userOptions : callback;
@@ -2005,41 +2062,83 @@ var __exports__ = (() => {
2005
2062
  var GIF_BUILDER_OPTIONS = {
2006
2063
  source: "images",
2007
2064
  width: 200,
2065
+ // Desired width of the image
2008
2066
  height: 200,
2067
+ // Desired height of the image
2009
2068
  crossOrigin: "Anonymous",
2069
+ // Options are 'Anonymous', 'use-credentials', or a falsy value to not set a CORS attribute.
2070
+ // CALLBACKS
2010
2071
  progressCallback: (captureProgress) => {
2011
2072
  },
2073
+ // Callback that provides the current progress of the current image
2012
2074
  completeCallback: () => {
2013
2075
  },
2076
+ // Callback function that is called when the current image is completed
2077
+ // QUALITY SETTINGS
2014
2078
  numWorkers: 2,
2079
+ // how many web workers to use to process the animated GIF frames. Default is 2.
2015
2080
  sampleInterval: 10,
2081
+ // pixels to skip when creating the palette. Default is 10. Less is better, but slower.
2016
2082
  interval: 0.1,
2083
+ // The amount of time (in seconds) to wait between each frame capture
2017
2084
  offset: null,
2085
+ // The amount of time (in seconds) to start capturing the GIF (only for HTML5 videos)
2018
2086
  numFrames: 10,
2087
+ // The number of frames to use to create the animated GIF. Note: Each frame is captured every 100 milliseconds of a video and every ms for existing images
2019
2088
  frameDuration: 1,
2089
+ // The amount of time (10 = 1s) to stay on each frame
2090
+ // CSS FILTER OPTIONS
2020
2091
  filter: "",
2092
+ // CSS filter that will be applied to the image (eg. blur(5px))
2093
+ // WATERMARK OPTIONS
2021
2094
  waterMark: null,
2095
+ // If an image is given here, it will be stamped on top of the GIF frames
2022
2096
  waterMarkHeight: null,
2097
+ // Height of the waterMark
2023
2098
  waterMarkWidth: null,
2099
+ // Height of the waterMark
2024
2100
  waterMarkXCoordinate: 1,
2101
+ // The X (horizontal) Coordinate of the watermark image
2025
2102
  waterMarkYCoordinate: 1,
2103
+ // The Y (vertical) Coordinate of the watermark image
2104
+ // TEXT OPTIONS
2026
2105
  text: "",
2106
+ // The text that covers the animated GIF
2027
2107
  showFrameText: true,
2108
+ // If frame-specific text is supplied with the image array, you can force to not be displayed
2028
2109
  fontWeight: "normal",
2110
+ // The font weight of the text that covers the animated GIF
2029
2111
  fontSize: "16px",
2112
+ // The font size of the text that covers the animated GIF
2030
2113
  minFontSize: "10px",
2114
+ // The minimum font size of the text that covers the animated GIF
2031
2115
  resizeFont: false,
2116
+ // Whether or not the animated GIF text will be resized to fit within the GIF container
2032
2117
  fontFamily: "sans-serif",
2118
+ // The font family of the text that covers the animated GIF
2033
2119
  fontColor: "#ffffff",
2120
+ // The font color of the text that covers the animated GIF
2034
2121
  textAlign: "center",
2122
+ // The horizontal text alignment of the text that covers the animated GIF
2035
2123
  textBaseline: "bottom",
2124
+ // The vertical text alignment of the text that covers the animated GIF
2036
2125
  textXCoordinate: null,
2126
+ // The X (horizontal) Coordinate of the text that covers the animated GIF
2037
2127
  textYCoordinate: null,
2128
+ // The Y (vertical) Coordinate of the text that covers the animated GIF
2129
+ // ADVANCED OPTIONS
2130
+ // WEBCAM CAPTURE OPTIONS
2038
2131
  webcamVideoElement: null,
2132
+ // You can pass an existing video element to use for the webcam GIF creation process,
2039
2133
  keepCameraOn: false,
2134
+ // Whether or not you would like the user's camera to stay on after the GIF is created
2040
2135
  cameraStream: null,
2136
+ // Expects a cameraStream Media object
2137
+ // CANVAS OPTIMIZATION OPTIONS
2041
2138
  saveRenderingContexts: false,
2139
+ // Whether or not you would like to save all of the canvas image binary data
2042
2140
  savedRenderingContexts: []
2141
+ // Array of canvas image data
2043
2142
  };
2044
2143
  var GIFBuilder = class {
2045
2144
  static get properties() {
@@ -2053,9 +2152,7 @@ var __exports__ = (() => {
2053
2152
  };
2054
2153
  }
2055
2154
  constructor(options) {
2056
- this.options = {
2057
- ...options
2058
- };
2155
+ this.options = { ...options };
2059
2156
  this.source = options.source;
2060
2157
  delete options.source;
2061
2158
  this.files = [];
@@ -2085,6 +2182,7 @@ var __exports__ = (() => {
2085
2182
  }
2086
2183
  return await this._createGIF();
2087
2184
  }
2185
+ // PRIVATE
2088
2186
  async _createGIF() {
2089
2187
  return new Promise((resolve, reject) => {
2090
2188
  this.gifshot.createGIF(this.options, (result) => {
@@ -2096,6 +2194,7 @@ var __exports__ = (() => {
2096
2194
  });
2097
2195
  });
2098
2196
  }
2197
+ // Remove some gifshot options
2099
2198
  _cleanOptions(options) {
2100
2199
  if (options.video || options.images || options.gifWidth || options.gifHeight) {
2101
2200
  console.warn("GIFBuilder: ignoring options");
@@ -2108,7 +2207,7 @@ var __exports__ = (() => {
2108
2207
  delete options.height;
2109
2208
  }
2110
2209
  };
2111
- return __toCommonJS(src_exports);
2210
+ return __toCommonJS(bundle_exports);
2112
2211
  })();
2113
2212
  return __exports__;
2114
2213
  });
@@ -0,0 +1,9 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if (typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if (typeof define === 'function' && define.amd) define([], factory);
5
+ else if (typeof exports === 'object') exports['loaders'] = factory();
6
+ else root['loaders'] = factory();})(globalThis, function () {
7
+ "use strict";var __exports__=(()=>{var Re=Object.create;var de=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty;var He=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Pe=(t,e)=>{for(var n in e)de(t,n,{get:e[n],enumerable:!0})},ce=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ue(e))!Le.call(t,i)&&i!==n&&de(t,i,{get:()=>e[i],enumerable:!(o=Me(e,i))||o.enumerable});return t},fe=(t,e,n)=>(ce(t,e,"default"),n&&ce(n,e,"default")),Be=(t,e,n)=>(n=t!=null?Re(Ve(t)):{},ce(e||!t||!t.__esModule?de(n,"default",{value:t,enumerable:!0}):n,t)),_e=t=>ce(de({},"__esModule",{value:!0}),t);var Ce=He((lt,we)=>{we.exports=globalThis.loaders});var se={};Pe(se,{GIFBuilder:()=>K,VideoLoader:()=>ye});fe(se,Be(Ce(),1));async function he(t){let e=new Blob([t]),n=document.createElement("video");return n.src=URL.createObjectURL(e),n}var Ge="4.2.0-alpha.5",De=["mp4"],je=["video/mp4"],Ne={video:{}},ye={name:"Video",id:"video",module:"video",version:Ge,extensions:De,mimeTypes:je,parse:he,options:Ne};function Se(t,e){if(!t)throw new Error(e)}var j=globalThis.document||{},r={URL:globalThis.URL||globalThis.webkitURL||globalThis.mozURL||globalThis.msURL,getUserMedia:function(){if(!globalThis.navigator)return globalThis.navigator;let t=globalThis.navigator.getUserMedia||globalThis.navigator.webkitGetUserMedia||globalThis.navigator.mozGetUserMedia||globalThis.navigator.msGetUserMedia;return t&&t.bind(globalThis.navigator)}(),requestAnimFrame:globalThis.requestAnimationFrame||globalThis.webkitRequestAnimationFrame||globalThis.mozRequestAnimationFrame||globalThis.oRequestAnimationFrame||globalThis.msRequestAnimationFrame,requestTimeout:function(e,n){if(e=e||r.noop,n=n||0,!r.requestAnimFrame)return setTimeout(e,n);let o=new Date().getTime(),i=new Object,s=r.requestAnimFrame,a=function l(){new Date().getTime()-o>=n?e.call():i.value=s(l)};return i.value=s(a),i},Blob:globalThis.Blob||globalThis.BlobBuilder||globalThis.WebKitBlobBuilder||globalThis.MozBlobBuilder||globalThis.MSBlobBuilder,btoa:function(){let t=globalThis.btoa||function(e){let n="",o=0,i=e.length,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a,l,c,g,x,k,m;for(;o<i;)a=e.charCodeAt(o++),l=e.charCodeAt(o++),c=e.charCodeAt(o++),g=a>>2,x=(a&3)<<4|l>>4,k=(l&15)<<2|c>>6,m=c&63,isNaN(l)?k=m=64:isNaN(c)&&(m=64),n=n+s.charAt(g)+s.charAt(x)+s.charAt(k)+s.charAt(m);return n};return t?t.bind(globalThis):r.noop}(),isObject:function(e){return e&&Object.prototype.toString.call(e)==="[object Object]"},isEmptyObject:function(e){return r.isObject(e)&&!Object.keys(e).length},isArray:function(e){return e&&Array.isArray(e)},isFunction:function(e){return e&&typeof e=="function"},isElement:function(e){return e&&e.nodeType===1},isString:function(e){return typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"},isSupported:{canvas:function(){let e=j.createElement("canvas");return e&&e.getContext&&e.getContext("2d")},webworkers:function(){return globalThis.Worker},blob:function(){return r.Blob},Uint8Array:function(){return globalThis.Uint8Array},Uint32Array:function(){return globalThis.Uint32Array},videoCodecs:function(){let t=j.createElement("video"),e={mp4:!1,h264:!1,ogv:!1,ogg:!1,webm:!1};try{t&&t.canPlayType&&(e.mp4=t.canPlayType('video/mp4; codecs="mp4v.20.8"')!=="",e.h264=(t.canPlayType('video/mp4; codecs="avc1.42E01E"')||t.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"'))!=="",e.ogv=t.canPlayType('video/ogg; codecs="theora"')!=="",e.ogg=t.canPlayType('video/ogg; codecs="theora"')!=="",e.webm=t.canPlayType('video/webm; codecs="vp8, vorbis"')!==-1)}catch{}return e}()},noop:function(){},each:function(e,n){let o,i;if(r.isArray(e))for(o=-1,i=e.length;++o<i&&n(o,e[o])!==!1;);else if(r.isObject(e)){for(o in e)if(e.hasOwnProperty(o)&&n(o,e[o])===!1)break}},normalizeOptions:function(e,n){if(!r.isObject(e)||!r.isObject(n)||!Object.keys)return;let o={};return r.each(e,function(i,s){o[i]=e[i]}),r.each(n,function(i,s){let a=n[i];r.isObject(a)&&e[i]?o[i]=r.normalizeOptions(e[i],a):o[i]=a}),o},setCSSAttr:function(e,n,o){r.isElement(e)&&(r.isString(n)&&r.isString(o)?e.style[n]=o:r.isObject(n)&&r.each(n,function(i,s){e.style[i]=s}))},removeElement:function(e){r.isElement(e)&&e.parentNode&&e.parentNode.removeChild(e)},createWebWorker:function(e){if(!r.isString(e))return{};try{let n=new r.Blob([e],{type:"text/javascript"}),o=r.URL.createObjectURL(n),i=new Worker(o);return{objectUrl:o,worker:i}}catch(n){return`${n}`}},getExtension:function(e){return e.substr(e.lastIndexOf(".")+1,e.length)},getFontSize:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!j.body||e.resizeFont===!1)return e.fontSize;let n=e.text,o=e.gifWidth,i=parseInt(e.fontSize,10),s=parseInt(e.minFontSize,10),a=j.createElement("div"),l=j.createElement("span");for(a.setAttribute("width",o),a.appendChild(l),l.innerHTML=n,l.style.fontSize=`${i}px`,l.style.textIndent="-9999px",l.style.visibility="hidden",j.body.appendChild(l);l.offsetWidth>o&&i>=s;)l.style.fontSize=`${--i}px`;return j.body.removeChild(l),`${i}px`},webWorkerError:!1},$e=Object.freeze({default:r}),q={validate:function(e){e=r.isObject(e)?e:{};let n={};return r.each(q.validators,function(o,i){let s=i.errorCode;if(!e[s]&&!i.condition)return n=i,n.error=!0,!1}),delete n.condition,n},isValid:function(e){return q.validate(e).error!==!0},validators:[{condition:r.isFunction(r.getUserMedia),errorCode:"getUserMedia",errorMsg:"The getUserMedia API is not supported in your browser"},{condition:r.isSupported.canvas(),errorCode:"canvas",errorMsg:"Canvas elements are not supported in your browser"},{condition:r.isSupported.webworkers(),errorCode:"webworkers",errorMsg:"The Web Workers API is not supported in your browser"},{condition:r.isFunction(r.URL),errorCode:"globalThis.URL",errorMsg:"The globalThis.URL API is not supported in your browser"},{condition:r.isSupported.blob(),errorCode:"globalThis.Blob",errorMsg:"The globalThis.Blob File API is not supported in your browser"},{condition:r.isSupported.Uint8Array(),errorCode:"globalThis.Uint8Array",errorMsg:"The globalThis.Uint8Array function constructor is not supported in your browser"},{condition:r.isSupported.Uint32Array(),errorCode:"globalThis.Uint32Array",errorMsg:"The globalThis.Uint32Array function constructor is not supported in your browser"}],messages:{videoCodecs:{errorCode:"videocodec",errorMsg:"The video codec you are trying to use is not supported in your browser"}}},qe=Object.freeze({default:q}),Fe=function(){},be={sampleInterval:10,numWorkers:2,filter:"",gifWidth:200,gifHeight:200,interval:.1,numFrames:10,frameDuration:1,keepCameraOn:!1,images:[],video:null,webcamVideoElement:null,cameraStream:null,text:"",fontWeight:"normal",fontSize:"16px",minFontSize:"10px",resizeFont:!1,fontFamily:"sans-serif",fontColor:"#ffffff",textAlign:"center",textBaseline:"bottom",textXCoordinate:null,textYCoordinate:null,progressCallback:Fe,completeCallback:Fe,saveRenderingContexts:!1,savedRenderingContexts:[],crossOrigin:"Anonymous"},Xe=Object.freeze({default:be});function Ye(){return q.isValid()}function We(){return q.isValid()}function Qe(){let t={getUserMedia:!0};return q.isValid(t)}function Ke(t){let e=!1;if(r.isArray(t)&&t.length){if(r.each(t,function(n,o){r.isSupported.videoCodecs[o]&&(e=!0)}),!e)return!1}else if(r.isString(t)&&t.length&&!r.isSupported.videoCodecs[t])return!1;return q.isValid({getUserMedia:!0})}function Ee(){let M,B,D,X,S,_=[],Q=[],Z=[],ee=[];function me(u,p,W){let h,b;for(B=u,D=p,X=W,S=new Array(256),h=0;h<256;h++)S[h]=new Array(4),b=S[h],b[0]=b[1]=b[2]=(h<<4+8)/256|0,Z[h]=65536/256|0,Q[h]=0}function ge(){let u=[],p=new Array(256);for(let h=0;h<256;h++)p[S[h][3]]=h;let W=0;for(let h=0;h<256;h++){let b=p[h];u[W++]=S[b][0],u[W++]=S[b][1],u[W++]=S[b][2]}return u}function te(){let u,p,W,h,b,d,f,F;for(f=0,F=0,u=0;u<256;u++){for(b=S[u],W=u,h=b[1],p=u+1;p<256;p++)d=S[p],d[1]<h&&(W=p,h=d[1]);if(d=S[W],u!=W&&(p=d[0],d[0]=b[0],b[0]=p,p=d[1],d[1]=b[1],b[1]=p,p=d[2],d[2]=b[2],b[2]=p,p=d[3],d[3]=b[3],b[3]=p),h!=f){for(_[f]=F+u>>1,p=f+1;p<h;p++)_[p]=u;f=h,F=u}}for(_[f]=F+255>>1,p=f+1;p<256;p++)_[p]=255}function ie(){let u,p,W,h,b,d,f,F,T,O,$,A,G,xe;for(D<1509&&(X=1),M=30+(X-1)/3,A=B,G=0,xe=D,$=D/(3*X),O=$/100|0,F=1024,d=2048,f=d>>6,f<=1&&(f=0),u=0;u<f;u++)ee[u]=F*((f*f-u*u)*256/(f*f));for(D<1509?T=3:D%499!==0?T=3*499:D%491!==0?T=3*491:D%487!==0?T=3*487:T=3*503,u=0;u<$;)if(W=(A[G+0]&255)<<4,h=(A[G+1]&255)<<4,b=(A[G+2]&255)<<4,p=le(W,h,b),ae(F,p,W,h,b),f!==0&&re(f,p,W,h,b),G+=T,G>=xe&&(G-=D),u++,O===0&&(O=1),u%O===0)for(F-=F/M,d-=d/30,f=d>>6,f<=1&&(f=0),p=0;p<f;p++)ee[p]=F*((f*f-p*p)*256/(f*f))}function ne(u,p,W){let h,b,d,f,F,T,O;for(F=1e3,O=-1,h=_[p],b=h-1;h<256||b>=0;)h<256&&(T=S[h],d=T[1]-p,d>=F?h=256:(h++,d<0&&(d=-d),f=T[0]-u,f<0&&(f=-f),d+=f,d<F&&(f=T[2]-W,f<0&&(f=-f),d+=f,d<F&&(F=d,O=T[3])))),b>=0&&(T=S[b],d=p-T[1],d>=F?b=-1:(b--,d<0&&(d=-d),f=T[0]-u,f<0&&(f=-f),d+=f,d<F&&(f=T[2]-W,f<0&&(f=-f),d+=f,d<F&&(F=d,O=T[3]))));return O}function oe(){return ie(),ue(),te(),ge()}function ue(){let u,p;for(u=0;u<256;u++)S[u][0]>>=4,S[u][1]>>=4,S[u][2]>>=4,S[u][3]=u}function re(u,p,W,h,b){let d,f,F,T,O,$,A;for(F=p-u,F<-1&&(F=-1),T=p+u,T>256&&(T=256),d=p+1,f=p-1,$=1;d<T||f>F;){if(O=ee[$++],d<T){A=S[d++];try{A[0]-=O*(A[0]-W)/262144|0,A[1]-=O*(A[1]-h)/262144|0,A[2]-=O*(A[2]-b)/262144|0}catch{}}if(f>F){A=S[f--];try{A[0]-=O*(A[0]-W)/262144|0,A[1]-=O*(A[1]-h)/262144|0,A[2]-=O*(A[2]-b)/262144|0}catch{}}}}function ae(u,p,W,h,b){let d=S[p],f=u/1024;d[0]-=f*(d[0]-W)|0,d[1]-=f*(d[1]-h)|0,d[2]-=f*(d[2]-b)|0}function le(u,p,W){let h,b,d,f,F,T,O,$,A,G;for($=~(1<<31),A=$,T=-1,O=T,h=0;h<256;h++)G=S[h],b=G[0]-u,b<0&&(b=-b),d=G[1]-p,d<0&&(d=-d),b+=d,d=G[2]-W,d<0&&(d=-d),b+=d,b<$&&($=b,T=h),f=b-(Q[h]>>16-4),f<A&&(A=f,O=h),F=Z[h]>>10,Z[h]-=F,Q[h]+=F<<10;return Z[T]+=64,Q[T]-=65536,O}me.apply(this,arguments);let J={};return J.map=ne,J.process=oe,J}function ke(){let t=this;try{globalThis.onmessage=function(n){let o=n.data||{},i;o.gifshot&&(i=e.run(o),postMessage(i))}}catch{}var e={dataToRGB:function(o,i,s){let a=i*s*4,l=0,c=[];for(;l<a;)c.push(o[l++]),c.push(o[l++]),c.push(o[l++]),l++;return c},componentizedPaletteToArray:function(o){o=o||[];let i=[];for(let s=0;s<o.length;s+=3){let a=o[s],l=o[s+1],c=o[s+2];i.push(a<<16|l<<8|c)}return i},processFrameWithQuantizer:function(o,i,s,a){let l=this.dataToRGB(o,i,s),c=new Ee(l,l.length,a),g=c.process(),x=new Uint32Array(this.componentizedPaletteToArray(g)),k=i*s,m=new Uint8Array(k),v=0;for(let w=0;w<k;w++){let E=l[v++],C=l[v++],y=l[v++];m[w]=c.map(E,C,y)}return{pixels:m,palette:x}},run:function(o){o=o||{};let i=o,s=i.height,a=i.palette,l=i.sampleInterval,c=i.width,g=o.data;return this.processFrameWithQuantizer(g,c,s,l)}};return e}function Ze(t,e,n,o){let i=0;o=o===void 0?{}:o;let s=o.loop===void 0?null:o.loop,a=o.palette===void 0?null:o.palette;if(e<=0||n<=0||e>65535||n>65535)throw"Width/Height invalid.";function l(m){let v=m.length;if(v<2||v>256||v&v-1)throw"Invalid code/color length, must be power of 2 and 2 .. 256.";return v}t[i++]=71,t[i++]=73,t[i++]=70,t[i++]=56,t[i++]=57,t[i++]=97;let c=0,g=0;if(t[i++]=e&255,t[i++]=e>>8&255,t[i++]=n&255,t[i++]=n>>8&255,t[i++]=(a!==null?128:0)|c,t[i++]=g,t[i++]=0,s!==null){if(s<0||s>65535)throw"Loop count invalid.";t[i++]=33,t[i++]=255,t[i++]=11,t[i++]=78,t[i++]=69,t[i++]=84,t[i++]=83,t[i++]=67,t[i++]=65,t[i++]=80,t[i++]=69,t[i++]=50,t[i++]=46,t[i++]=48,t[i++]=3,t[i++]=1,t[i++]=s&255,t[i++]=s>>8&255,t[i++]=0}let x=!1;this.addFrame=function(m,v,w,E,C,y){if(x===!0&&(--i,x=!1),y=y===void 0?{}:y,m<0||v<0||m>65535||v>65535)throw"x/y invalid.";if(w<=0||E<=0||w>65535||E>65535)throw"Width/Height invalid.";if(C.length<w*E)throw"Not enough pixels for the frame size.";let I=!0,z=y.palette;if(z==null&&(I=!1,z=a),z==null)throw"Must supply either a local or global palette.";let U=l(z),V=0;for(;U>>=1;)++V;U=1<<V;let R=y.delay===void 0?0:y.delay,M=y.disposal===void 0?0:y.disposal;if(M<0||M>3)throw"Disposal out of range.";let Y=!1,L=0;if(y.transparent!==void 0&&y.transparent!==null&&(Y=!0,L=y.transparent,L<0||L>=U))throw"Transparent color index.";if((M!==0||Y||R!==0)&&(t[i++]=33,t[i++]=249,t[i++]=4,t[i++]=M<<2|(Y===!0?1:0),t[i++]=R&255,t[i++]=R>>8&255,t[i++]=L,t[i++]=0),t[i++]=44,t[i++]=m&255,t[i++]=m>>8&255,t[i++]=v&255,t[i++]=v>>8&255,t[i++]=w&255,t[i++]=w>>8&255,t[i++]=E&255,t[i++]=E>>8&255,t[i++]=I===!0?128|V-1:0,I===!0)for(let H=0,N=z.length;H<N;++H){let B=z[H];t[i++]=B>>16&255,t[i++]=B>>8&255,t[i++]=B&255}i=k(t,i,V<2?2:V,C)},this.end=function(){return x===!1&&(t[i++]=59,x=!0),i};function k(m,v,w,E){m[v++]=w;let C=v++,y=1<<w,I=y-1,z=y+1,U=z+1,V=w+1,R=0,M=0;function Y(B){for(;R>=B;)m[v++]=M&255,M>>=8,R-=8,v===C+256&&(m[C]=255,C=v++)}function L(B){M|=B<<R,R+=V,Y(8)}let H=E[0]&I,N={};L(y);for(let B=1,D=E.length;B<D;++B){let X=E[B]&I,S=H<<8|X,_=N[S];if(_===void 0){for(M|=H<<R,R+=V;R>=8;)m[v++]=M&255,M>>=8,R-=8,v===C+256&&(m[C]=255,C=v++);U===4096?(L(y),U=z+1,V=w+1,N={}):(U>=1<<V&&++V,N[S]=U++),H=X}else H=_}return L(H),L(z),Y(1),C+1===v?m[C]=0:(m[C]=v-C-1,m[v++]=0),v}}var Te=function(){},ve=function(e){this.canvas=null,this.ctx=null,this.repeat=0,this.frames=[],this.numRenderedFrames=0,this.onRenderCompleteCallback=Te,this.onRenderProgressCallback=Te,this.workers=[],this.availableWorkers=[],this.generatingGIF=!1,this.options=e,this.initializeWebWorkers(e)};ve.prototype={workerMethods:ke(),initializeWebWorkers:function(e){let n=this,o=`${Ee.toString()}(${ke.toString()}());`,i,s,a,l,c=-1,g="";for(l=e.numWorkers;++c<l;)i=r.createWebWorker(o),r.isObject(i)?(s=i.objectUrl,a=i.worker,n.workers.push({worker:a,objectUrl:s}),n.availableWorkers.push(a)):(g=i,r.webWorkerError=Boolean(i));this.workerError=g,this.canvas=j.createElement("canvas"),this.canvas.width=e.gifWidth,this.canvas.height=e.gifHeight,this.ctx=this.canvas.getContext("2d"),this.frames=[]},getWorker:function(){return this.availableWorkers.pop()},freeWorker:function(e){this.availableWorkers.push(e)},byteMap:function(){let t=[];for(let e=0;e<256;e++)t[e]=String.fromCharCode(e);return t}(),bufferToString:function(e){let n=e.length,o="",i=-1;for(;++i<n;)o+=this.byteMap[e[i]];return o},onFrameFinished:function(e){let n=this,o=n.frames,i=n.options,s=Boolean((i.images||[]).length),a=o.every(function(l){return!l.beingProcessed&&l.done});n.numRenderedFrames++,s&&e(n.numRenderedFrames/o.length),n.onRenderProgressCallback(n.numRenderedFrames*.75/o.length),a?n.generatingGIF||n.generateGIF(o,n.onRenderCompleteCallback):r.requestTimeout(function(){n.processNextFrame()},1)},processFrame:function(e){let n=this,o=this.options,i=this.options,s=i.progressCallback,a=i.sampleInterval,l=this.frames,c,g,x=function(){let v=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).data;delete c.data,c.pixels=Array.prototype.slice.call(v.pixels),c.palette=Array.prototype.slice.call(v.palette),c.done=!0,c.beingProcessed=!1,n.freeWorker(g),n.onFrameFinished(s)};if(c=l[e],c.beingProcessed||c.done){this.onFrameFinished();return}c.sampleInterval=a,c.beingProcessed=!0,c.gifshot=!0,g=this.getWorker(),g?(g.onmessage=x,g.postMessage(c)):x({data:n.workerMethods.run(c)})},startRendering:function(e){this.onRenderCompleteCallback=e;for(let n=0;n<this.options.numWorkers&&n<this.frames.length;n++)this.processFrame(n)},processNextFrame:function(){let e=-1;for(let n=0;n<this.frames.length;n++){let o=this.frames[n];if(!o.done&&!o.beingProcessed){e=n;break}}e>=0&&this.processFrame(e)},generateGIF:function(e,n){let o=[],i={loop:this.repeat},s=this.options,a=s.interval,l=s.frameDuration,c=s.images,g=Boolean(c.length),x=s.gifHeight,k=s.gifWidth,m=new Ze(o,k,x,i),v=this.onRenderProgressCallback,w=g?a*100:0,E,C;this.generatingGIF=!0,r.each(e,function(y,I){let z=I.palette;v(.75+.25*I.position*1/e.length);for(let U=0;U<l;U++)m.addFrame(0,0,k,x,I.pixels,{palette:z,delay:w})}),m.end(),v(1),this.frames=[],this.generatingGIF=!1,r.isFunction(n)&&(E=this.bufferToString(o),C=`data:image/gif;base64,${r.btoa(E)}`,n(C))},setRepeat:function(e){this.repeat=e},addFrame:function(e,n){n=r.isObject(n)?n:{};let o=this,i=o.ctx,s=o.options,a=s.gifWidth,l=s.gifHeight,c=r.getFontSize(n),g=n,x=g.filter,k=g.fontColor,m=g.fontFamily,v=g.fontWeight,w=g.gifHeight,E=g.gifWidth,C=g.text,y=g.textAlign,I=g.textBaseline,z=n.textXCoordinate?n.textXCoordinate:y==="left"?1:y==="right"?a:a/2,U=n.textYCoordinate?n.textYCoordinate:I==="top"?1:I==="center"?l/2:l,V=`${v} ${c} ${m}`,R;try{i.filter=x,i.drawImage(e,0,0,a,l),C&&(i.font=V,i.fillStyle=k,i.textAlign=y,i.textBaseline=I,i.fillText(C,z,U)),R=i.getImageData(0,0,a,l),o.addFrameImageData(R)}catch(M){return`${M}`}},addFrameImageData:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=this.frames,o=e.data;this.frames.push({data:o,width:e.width,height:e.height,palette:null,dithering:null,done:!1,beingProcessed:!1,position:n.length})},onRenderProgress:function(e){this.onRenderProgressCallback=e},isRendering:function(){return this.generatingGIF},getBase64GIF:function(e){let n=this,o=function(s){n.destroyWorkers(),r.requestTimeout(function(){e(s)},0)};n.startRendering(o)},destroyWorkers:function(){if(this.workerError)return;let e=this.workers;r.each(e,function(n,o){let i=o.worker,s=o.objectUrl;i.terminate(),r.URL.revokeObjectURL(s)})}};function Je(t,e){t.getBase64GIF(function(n){e({error:!1,errorCode:"",errorMsg:"",image:n})})}function et(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=this,n=t.callback,o=t.images,i=t.options,s=t.imagesLength,a={getUserMedia:!0,"globalThis.URL":!0},l=q.validate(a),c=[],g=0,x,k;if(l.error)return n(l);k=new ve(i),r.each(o,function(v,w){let E=w;r.isElement(E)?(i.crossOrigin&&(E.crossOrigin=i.crossOrigin),c[v]=E,g+=1,g===s&&m()):r.isString(E)&&(x=new Image,i.crossOrigin&&(x.crossOrigin=i.crossOrigin),function(C){w.text&&(C.text=w.text),C.onerror=function(y){let I;if(--s,s===0)return I={},I.error="None of the requested images was capable of being retrieved",n(I)},C.onload=function(y){w.text?c[v]={img:C,text:C.text}:c[v]=C,g+=1,g===s&&m(),r.removeElement(C)},C.src=E}(x),r.setCSSAttr(x,{position:"fixed",opacity:"0"}),j.body.appendChild(x))});function m(){r.each(c,function(v,w){w&&(w.text?k.addFrame(w.img,i,w.text):k.addFrame(w,i))}),Je(k,n)}}var tt=function(){},pe={getGIF:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments[1];n=r.isFunction(n)?n:tt;let o=j.createElement("canvas"),i,s=e.images,a=Boolean(s.length),l=e.cameraStream,c=e.crop,g=e.filter,x=e.fontColor,k=e.fontFamily,m=e.fontWeight,v=e.keepCameraOn,w=e.numWorkers,E=e.progressCallback,C=e.saveRenderingContexts,y=e.savedRenderingContexts,I=e.text,z=e.textAlign,U=e.textBaseline,V=e.videoElement,R=e.videoHeight,M=e.videoWidth,Y=e.webcamVideoElement,L=Number(e.gifWidth),H=Number(e.gifHeight),N=Number(e.interval),B=Number(e.sampleInterval),D=a?0:N*1e3,X=[],S=y.length?y.length:e.numFrames,_=S,Q=new ve(e),Z=r.getFontSize(e),ee=e.textXCoordinate?e.textXCoordinate:z==="left"?1:z==="right"?L:L/2,me=e.textYCoordinate?e.textYCoordinate:U==="top"?1:U==="center"?H/2:H,ge=`${m} ${Z} ${k}`,te=c?Math.floor(c.scaledWidth/2):0,ie=c?M-c.scaledWidth:0,ne=c?Math.floor(c.scaledHeight/2):0,oe=c?R-c.scaledHeight:0,ue=function re(){let ae=_-1;y.length?(i.putImageData(y[S-_],0,0),J()):le();function le(){try{ie>M&&(ie=M),oe>R&&(oe=R),te<0&&(te=0),ne<0&&(ne=0),i.filter=g,i.drawImage(V,te,ne,ie,oe,0,0,L,H),J()}catch(u){if(u.name==="NS_ERROR_NOT_AVAILABLE")r.requestTimeout(le,100);else throw u}}function J(){let u;C&&X.push(i.getImageData(0,0,L,H)),I&&(i.font=ge,i.fillStyle=x,i.textAlign=z,i.textBaseline=U,i.fillText(I,ee,me)),u=i.getImageData(0,0,L,H),Q.addFrameImageData(u),_=ae,E((S-_)/S),ae>0&&r.requestTimeout(re,D),_||Q.getBase64GIF(function(p){n({error:!1,errorCode:"",errorMsg:"",image:p,cameraStream:l,videoElement:V,webcamVideoElement:Y,savedRenderingContexts:X,keepCameraOn:v})})}};S=S!==void 0?S:10,N=N!==void 0?N:.1,o.width=L,o.height=H,i=o.getContext("2d"),function re(){if(!y.length&&V.currentTime===0){r.requestTimeout(re,100);return}ue()}()},getCropDimensions:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e.videoWidth,o=e.videoHeight,i=e.gifWidth,s=e.gifHeight,a={width:0,height:0,scaledWidth:0,scaledHeight:0};return n>o?(a.width=Math.round(n*(s/o))-i,a.scaledWidth=Math.round(a.width*(o/s))):(a.height=Math.round(o*(i/n))-s,a.scaledHeight=Math.round(a.height*(n/i))),a}},P={loadedData:!1,defaultVideoDimensions:{width:640,height:480},findVideoSize:function t(e){t.attempts=t.attempts||0;let n=e.cameraStream,o=e.completedCallback,i=e.videoElement;i&&(i.videoWidth>0&&i.videoHeight>0?(i.removeEventListener("loadeddata",P.findVideoSize),o({videoElement:i,cameraStream:n,videoWidth:i.videoWidth,videoHeight:i.videoHeight})):t.attempts<10?(t.attempts+=1,r.requestTimeout(function(){P.findVideoSize(e)},400)):o({videoElement:i,cameraStream:n,videoWidth:P.defaultVideoDimensions.width,videoHeight:P.defaultVideoDimensions.height}))},onStreamingTimeout:function(e){r.isFunction(e)&&e({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - Timed out while trying to start streaming",image:null,cameraStream:{}})},stream:function(e){let n=r.isArray(e.existingVideo)?e.existingVideo[0]:e.existingVideo,o=e.cameraStream,i=e.completedCallback,s=e.streamedCallback,a=e.videoElement;if(r.isFunction(s)&&s(),n){if(r.isString(n))a.src=n,a.innerHTML=`<source src="${n}" type="video/${r.getExtension(n)}" />`;else if(n instanceof Blob){try{a.src=r.URL.createObjectURL(n)}catch{}a.innerHTML=`<source src="${n}" type="${n.type}" />`}}else if(a.mozSrcObject)a.mozSrcObject=o;else if(r.URL)try{a.srcObject=o,a.src=r.URL.createObjectURL(o)}catch{a.srcObject=o}a.play(),r.requestTimeout(function l(){l.count=l.count||0,P.loadedData===!0?(P.findVideoSize({videoElement:a,cameraStream:o,completedCallback:i}),P.loadedData=!1):(l.count+=1,l.count>10?P.findVideoSize({videoElement:a,cameraStream:o,completedCallback:i}):l())},0)},startStreaming:function(e){let n=r.isFunction(e.error)?e.error:r.noop,o=r.isFunction(e.streamed)?e.streamed:r.noop,i=r.isFunction(e.completed)?e.completed:r.noop,s=e.crossOrigin,a=e.existingVideo,l=e.lastCameraStream,c=e.options,g=e.webcamVideoElement,x=r.isElement(a)?a:g||j.createElement("video"),k=void 0;s&&(x.crossOrigin=c.crossOrigin),x.autoplay=!0,x.loop=!0,x.muted=!0,x.addEventListener("loadeddata",function(m){P.loadedData=!0,c.offset&&(x.currentTime=c.offset)}),a?P.stream({videoElement:x,existingVideo:a,completedCallback:i}):l?P.stream({videoElement:x,cameraStream:l,streamedCallback:o,completedCallback:i}):r.getUserMedia({video:!0},function(m){P.stream({videoElement:x,cameraStream:m,streamedCallback:o,completedCallback:i})},n)},startVideoStreaming:function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=n.timeout!==void 0?n.timeout:0,i=n.callback,s=n.webcamVideoElement,a;o>0&&(a=r.requestTimeout(function(){P.onStreamingTimeout(i)},1e4)),P.startStreaming({error:function(){i({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - the user probably denied permission",image:null,cameraStream:{}})},streamed:function(){clearTimeout(a)},completed:function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},g=c.cameraStream,x=c.videoElement,k=c.videoHeight,m=c.videoWidth;e({cameraStream:g,videoElement:x,videoHeight:k,videoWidth:m})},lastCameraStream:n.lastCameraStream,webcamVideoElement:s,crossOrigin:n.crossOrigin,options:n})},stopVideoStreaming:function(e){e=r.isObject(e)?e:{};let n=e,o=n.keepCameraOn,i=n.videoElement,s=n.webcamVideoElement,a=e.cameraStream||{},l=a.getTracks?a.getTracks()||[]:[],c=Boolean(l.length),g=l[0];!o&&c&&r.isFunction(g.stop)&&g.stop(),r.isElement(i)&&!s&&(i.pause(),r.isFunction(r.URL.revokeObjectURL)&&!r.webWorkerError&&i.src&&r.URL.revokeObjectURL(i.src),r.removeElement(i))}};function Ae(t){t=r.isObject(t)?t:{},P.stopVideoStreaming(t)}function Ie(t,e){let n=t.options||{},o=n.images,i=n.video,s=Number(n.gifWidth),a=Number(n.gifHeight),l=Number(n.numFrames),c=t.cameraStream,g=t.videoElement,x=t.videoWidth,k=t.videoHeight,m=pe.getCropDimensions({videoWidth:x,videoHeight:k,gifHeight:a,gifWidth:s}),v=e;n.crop=m,n.videoElement=g,n.videoWidth=x,n.videoHeight=k,n.cameraStream=c,r.isElement(g)&&(g.width=s+m.width,g.height=a+m.height,n.webcamVideoElement||(r.setCSSAttr(g,{position:"fixed",opacity:"0"}),j.body.appendChild(g)),g.play(),pe.getGIF(n,function(w){(!o||!o.length)&&(!i||!i.length)&&Ae(w),v(w)}))}function it(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=t.callback,n=t.existingVideo,o=t.options,i={getUserMedia:!0,"globalThis.URL":!0},s=q.validate(i),a=0,l,c,g=void 0,x=void 0;if(s.error)return e(s);if(r.isElement(n)&&n.src){if(c=n.src,l=r.getExtension(c),!r.isSupported.videoCodecs[l])return e(q.messages.videoCodecs)}else r.isArray(n)&&r.each(n,function(k,m){if(m instanceof Blob?l=m.type.substr(m.type.lastIndexOf("/")+1,m.length):l=m.substr(m.lastIndexOf(".")+1,m.length),r.isSupported.videoCodecs[l])return n=m,!1});P.startStreaming({completed:function(m){m.options=o||{},Ie(m,e)},existingVideo:n,crossOrigin:o.crossOrigin,options:o})}function nt(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=t.callback,n=t.lastCameraStream,o=t.options,i=t.webcamVideoElement;if(!We())return e(q.validate());if(o.savedRenderingContexts.length){pe.getGIF(o,function(s){e(s)});return}P.startVideoStreaming(function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};s.options=o||{},Ie(s,e)},{lastCameraStream:n,callback:e,webcamVideoElement:i,crossOrigin:o.crossOrigin})}function ze(t,e){if(e=r.isFunction(t)?t:e,t=r.isObject(t)?t:{},!r.isFunction(e))return;let n=r.normalizeOptions(be,t)||{},o=t.cameraStream,i=n.images,s=i?i.length:0,a=n.video,l=n.webcamVideoElement;n=r.normalizeOptions(n,{gifWidth:Math.floor(n.gifWidth),gifHeight:Math.floor(n.gifHeight)}),s?et({images:i,imagesLength:s,callback:e,options:n}):a?it({existingVideo:a,callback:e,options:n}):nt({lastCameraStream:o,callback:e,webcamVideoElement:l,options:n})}function ot(t,e){if(e=r.isFunction(t)?t:e,t=r.isObject(t)?t:{},!r.isFunction(e))return;let n=r.normalizeOptions(be,t),o=r.normalizeOptions(n,{interval:.1,numFrames:1,gifWidth:Math.floor(n.gifWidth),gifHeight:Math.floor(n.gifHeight)});ze(o,e)}var rt={utils:$e,error:qe,defaultOptions:Xe,createGIF:ze,takeSnapShot:ot,stopVideoStreaming:Ae,isSupported:Ye,isWebCamGIFSupported:We,isExistingVideoGIFSupported:Ke,isExistingImagesGIFSupported:Qe,VERSION:"0.4.5"},Oe=rt;var st={source:"images",width:200,height:200,crossOrigin:"Anonymous",progressCallback:t=>{},completeCallback:()=>{},numWorkers:2,sampleInterval:10,interval:.1,offset:null,numFrames:10,frameDuration:1,filter:"",waterMark:null,waterMarkHeight:null,waterMarkWidth:null,waterMarkXCoordinate:1,waterMarkYCoordinate:1,text:"",showFrameText:!0,fontWeight:"normal",fontSize:"16px",minFontSize:"10px",resizeFont:!1,fontFamily:"sans-serif",fontColor:"#ffffff",textAlign:"center",textBaseline:"bottom",textXCoordinate:null,textYCoordinate:null,webcamVideoElement:null,keepCameraOn:!1,cameraStream:null,saveRenderingContexts:!1,savedRenderingContexts:[]},K=class{static get properties(){return{id:"gif",name:"GIF",extensions:["gif"],mimeTypes:["image/gif"],builder:K,options:st}}constructor(e){this.options={...e},this.source=e.source,delete e.source,this.files=[],this.gifshot=Oe}async initialize(e){}async add(e){await this.initialize(),this.files.push(e)}async build(){switch(await this.initialize(),this._cleanOptions(this.options),this.source){case"images":this.options.images=this.files;break;case"video":this.options.video=this.files;break;case"webcam":Se(this.files.length===0);break;default:throw new Error("GIFBuilder: invalid source")}return await this._createGIF()}async _createGIF(){return new Promise((e,n)=>{this.gifshot.createGIF(this.options,o=>{if(o.error){n(o.errorMsg);return}e(o.image)})})}_cleanOptions(e){(e.video||e.images||e.gifWidth||e.gifHeight)&&console.warn("GIFBuilder: ignoring options"),delete e.video,delete e.images,e.gifWidth=e.width,e.gifHeight=e.height,delete e.width,delete e.height}};return _e(se);})();
8
+ return __exports__;
9
+ });