siam-ui-utils 3.0.32 → 3.1.1

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.
Files changed (57) hide show
  1. package/dist/CustomBootstrap.js +1 -1
  2. package/dist/CustomBootstrap.js.map +1 -1
  3. package/dist/copy-link/index.js +1 -1
  4. package/dist/copy-link/index.js.map +1 -1
  5. package/dist/custom-input/CustomInputCheckbox.js +3 -1
  6. package/dist/custom-input/CustomInputCheckbox.js.map +1 -1
  7. package/dist/custom-input/CustomInputCurrency.js +1 -1
  8. package/dist/custom-input/CustomInputCurrency.js.map +1 -1
  9. package/dist/custom-input/CustomInputFile.js +3 -1
  10. package/dist/custom-input/CustomInputFile.js.map +1 -1
  11. package/dist/custom-input/CustomInputRadio.js +3 -1
  12. package/dist/custom-input/CustomInputRadio.js.map +1 -1
  13. package/dist/drag-and-dropzone/DropzoneComponent.js +83 -0
  14. package/dist/drag-and-dropzone/DropzoneComponent.js.map +1 -0
  15. package/dist/drag-and-dropzone/index.js +1 -1
  16. package/dist/drag-and-dropzone/index.js.map +1 -1
  17. package/dist/dropzone-uploader/styled/index.js +1 -1
  18. package/dist/dropzone-uploader/styled/index.js.map +1 -1
  19. package/dist/node_modules/@neolution-ch/reactstrap/esm/Button.js +111 -0
  20. package/dist/node_modules/@neolution-ch/reactstrap/esm/Button.js.map +1 -0
  21. package/dist/node_modules/@neolution-ch/reactstrap/esm/CloseButton.js +106 -0
  22. package/dist/node_modules/@neolution-ch/reactstrap/esm/CloseButton.js.map +1 -0
  23. package/dist/node_modules/@neolution-ch/reactstrap/esm/Col.js +125 -0
  24. package/dist/node_modules/@neolution-ch/reactstrap/esm/Col.js.map +1 -0
  25. package/dist/node_modules/@neolution-ch/reactstrap/esm/FormGroup.js +75 -0
  26. package/dist/node_modules/@neolution-ch/reactstrap/esm/FormGroup.js.map +1 -0
  27. package/dist/node_modules/@neolution-ch/reactstrap/esm/Input.js +225 -0
  28. package/dist/node_modules/@neolution-ch/reactstrap/esm/Input.js.map +1 -0
  29. package/dist/node_modules/@neolution-ch/reactstrap/esm/Label.js +122 -0
  30. package/dist/node_modules/@neolution-ch/reactstrap/esm/Label.js.map +1 -0
  31. package/dist/node_modules/@neolution-ch/reactstrap/esm/Row.js +83 -0
  32. package/dist/node_modules/@neolution-ch/reactstrap/esm/Row.js.map +1 -0
  33. package/dist/node_modules/@neolution-ch/reactstrap/esm/utils.js +68 -0
  34. package/dist/node_modules/@neolution-ch/reactstrap/esm/utils.js.map +1 -0
  35. package/dist/node_modules/dropzone/dist/dropzone.js +1968 -0
  36. package/dist/node_modules/dropzone/dist/dropzone.js.map +1 -0
  37. package/dist/node_modules/just-extend/index.esm.js +43 -0
  38. package/dist/node_modules/just-extend/index.esm.js.map +1 -0
  39. package/dist/select/custom-select/index.js +1 -2
  40. package/dist/select/custom-select/index.js.map +1 -1
  41. package/dist/select/multi-select/index.css +23 -10
  42. package/dist/select/multi-select/index.js +138 -30
  43. package/dist/select/multi-select/index.js.map +1 -1
  44. package/dist/select/multi-select/styled-component.js +2 -3
  45. package/dist/select/multi-select/styled-component.js.map +1 -1
  46. package/dist/tomar-foto/index.js +1 -1
  47. package/dist/tomar-foto/index.js.map +1 -1
  48. package/index.d.ts +1 -1
  49. package/package.json +9 -10
  50. package/dist/_virtual/react-dropzone.js +0 -8
  51. package/dist/_virtual/react-dropzone.js.map +0 -1
  52. package/dist/_virtual/react-dropzone2.js +0 -5
  53. package/dist/_virtual/react-dropzone2.js.map +0 -1
  54. package/dist/node_modules/react-dropzone-component/dist/react-dropzone.js +0 -1023
  55. package/dist/node_modules/react-dropzone-component/dist/react-dropzone.js.map +0 -1
  56. package/dist/node_modules/react-multi-select-component/dist/esm/index.js +0 -178
  57. package/dist/node_modules/react-multi-select-component/dist/esm/index.js.map +0 -1
@@ -0,0 +1,1968 @@
1
+ import objectExtend from "../../just-extend/index.esm.js";
2
+ function $parcel$interopDefault(a) {
3
+ return a && a.__esModule ? a.default : a;
4
+ }
5
+ class $4040acfd8584338d$export$2e2bcd8739ae039 {
6
+ // Add an event listener for given event
7
+ on(event, fn) {
8
+ this._callbacks = this._callbacks || {};
9
+ if (!this._callbacks[event]) this._callbacks[event] = [];
10
+ this._callbacks[event].push(fn);
11
+ return this;
12
+ }
13
+ emit(event, ...args) {
14
+ this._callbacks = this._callbacks || {};
15
+ let callbacks = this._callbacks[event];
16
+ if (callbacks) for (let callback of callbacks) callback.apply(this, args);
17
+ if (this.element) this.element.dispatchEvent(this.makeEvent("dropzone:" + event, {
18
+ args
19
+ }));
20
+ return this;
21
+ }
22
+ makeEvent(eventName, detail) {
23
+ let params = {
24
+ bubbles: true,
25
+ cancelable: true,
26
+ detail
27
+ };
28
+ if (typeof window.CustomEvent === "function") return new CustomEvent(eventName, params);
29
+ else {
30
+ var evt = document.createEvent("CustomEvent");
31
+ evt.initCustomEvent(eventName, params.bubbles, params.cancelable, params.detail);
32
+ return evt;
33
+ }
34
+ }
35
+ // Remove event listener for given event. If fn is not provided, all event
36
+ // listeners for that event will be removed. If neither is provided, all
37
+ // event listeners will be removed.
38
+ off(event, fn) {
39
+ if (!this._callbacks || arguments.length === 0) {
40
+ this._callbacks = {};
41
+ return this;
42
+ }
43
+ let callbacks = this._callbacks[event];
44
+ if (!callbacks) return this;
45
+ if (arguments.length === 1) {
46
+ delete this._callbacks[event];
47
+ return this;
48
+ }
49
+ for (let i = 0; i < callbacks.length; i++) {
50
+ let callback = callbacks[i];
51
+ if (callback === fn) {
52
+ callbacks.splice(i, 1);
53
+ break;
54
+ }
55
+ }
56
+ return this;
57
+ }
58
+ }
59
+ var $fd6031f88dce2e32$exports = {};
60
+ $fd6031f88dce2e32$exports = '<div class="dz-preview dz-file-preview">\n <div class="dz-image"><img data-dz-thumbnail=""></div>\n <div class="dz-details">\n <div class="dz-size"><span data-dz-size=""></span></div>\n <div class="dz-filename"><span data-dz-name=""></span></div>\n </div>\n <div class="dz-progress">\n <span class="dz-upload" data-dz-uploadprogress=""></span>\n </div>\n <div class="dz-error-message"><span data-dz-errormessage=""></span></div>\n <div class="dz-success-mark">\n <svg width="54" height="54" viewBox="0 0 54 54" fill="white" xmlns="http://www.w3.org/2000/svg">\n <path d="M10.2071 29.7929L14.2929 25.7071C14.6834 25.3166 15.3166 25.3166 15.7071 25.7071L21.2929 31.2929C21.6834 31.6834 22.3166 31.6834 22.7071 31.2929L38.2929 15.7071C38.6834 15.3166 39.3166 15.3166 39.7071 15.7071L43.7929 19.7929C44.1834 20.1834 44.1834 20.8166 43.7929 21.2071L22.7071 42.2929C22.3166 42.6834 21.6834 42.6834 21.2929 42.2929L10.2071 31.2071C9.81658 30.8166 9.81658 30.1834 10.2071 29.7929Z"></path>\n </svg>\n </div>\n <div class="dz-error-mark">\n <svg width="54" height="54" viewBox="0 0 54 54" fill="white" xmlns="http://www.w3.org/2000/svg">\n <path d="M26.2929 20.2929L19.2071 13.2071C18.8166 12.8166 18.1834 12.8166 17.7929 13.2071L13.2071 17.7929C12.8166 18.1834 12.8166 18.8166 13.2071 19.2071L20.2929 26.2929C20.6834 26.6834 20.6834 27.3166 20.2929 27.7071L13.2071 34.7929C12.8166 35.1834 12.8166 35.8166 13.2071 36.2071L17.7929 40.7929C18.1834 41.1834 18.8166 41.1834 19.2071 40.7929L26.2929 33.7071C26.6834 33.3166 27.3166 33.3166 27.7071 33.7071L34.7929 40.7929C35.1834 41.1834 35.8166 41.1834 36.2071 40.7929L40.7929 36.2071C41.1834 35.8166 41.1834 35.1834 40.7929 34.7929L33.7071 27.7071C33.3166 27.3166 33.3166 26.6834 33.7071 26.2929L40.7929 19.2071C41.1834 18.8166 41.1834 18.1834 40.7929 17.7929L36.2071 13.2071C35.8166 12.8166 35.1834 12.8166 34.7929 13.2071L27.7071 20.2929C27.3166 20.6834 26.6834 20.6834 26.2929 20.2929Z"></path>\n </svg>\n </div>\n</div>\n';
61
+ let $4ca367182776f80b$var$defaultOptions = {
62
+ /**
63
+ * Has to be specified on elements other than form (or when the form doesn't
64
+ * have an `action` attribute).
65
+ *
66
+ * You can also provide a function that will be called with `files` and
67
+ * `dataBlocks` and must return the url as string.
68
+ */
69
+ url: null,
70
+ /**
71
+ * Can be changed to `"put"` if necessary. You can also provide a function
72
+ * that will be called with `files` and must return the method (since `v3.12.0`).
73
+ */
74
+ method: "post",
75
+ /**
76
+ * Will be set on the XHRequest.
77
+ */
78
+ withCredentials: false,
79
+ /**
80
+ * The timeout for the XHR requests in milliseconds (since `v4.4.0`).
81
+ * If set to null or 0, no timeout is going to be set.
82
+ */
83
+ timeout: null,
84
+ /**
85
+ * How many file uploads to process in parallel (See the
86
+ * Enqueuing file uploads documentation section for more info)
87
+ */
88
+ parallelUploads: 2,
89
+ /**
90
+ * Whether to send multiple files in one request. If
91
+ * this it set to true, then the fallback file input element will
92
+ * have the `multiple` attribute as well. This option will
93
+ * also trigger additional events (like `processingmultiple`). See the events
94
+ * documentation section for more information.
95
+ */
96
+ uploadMultiple: false,
97
+ /**
98
+ * Whether you want files to be uploaded in chunks to your server. This can't be
99
+ * used in combination with `uploadMultiple`.
100
+ *
101
+ * See [chunksUploaded](#config-chunksUploaded) for the callback to finalise an upload.
102
+ */
103
+ chunking: false,
104
+ /**
105
+ * If `chunking` is enabled, this defines whether **every** file should be chunked,
106
+ * even if the file size is below chunkSize. This means, that the additional chunk
107
+ * form data will be submitted and the `chunksUploaded` callback will be invoked.
108
+ */
109
+ forceChunking: false,
110
+ /**
111
+ * If `chunking` is `true`, then this defines the chunk size in bytes.
112
+ */
113
+ chunkSize: 2097152,
114
+ /**
115
+ * If `true`, the individual chunks of a file are being uploaded simultaneously.
116
+ */
117
+ parallelChunkUploads: false,
118
+ /**
119
+ * Whether a chunk should be retried if it fails.
120
+ */
121
+ retryChunks: false,
122
+ /**
123
+ * If `retryChunks` is true, how many times should it be retried.
124
+ */
125
+ retryChunksLimit: 3,
126
+ /**
127
+ * The maximum filesize (in MiB) that is allowed to be uploaded.
128
+ */
129
+ maxFilesize: 256,
130
+ /**
131
+ * The name of the file param that gets transferred.
132
+ * **NOTE**: If you have the option `uploadMultiple` set to `true`, then
133
+ * Dropzone will append `[]` to the name.
134
+ */
135
+ paramName: "file",
136
+ /**
137
+ * Whether thumbnails for images should be generated
138
+ */
139
+ createImageThumbnails: true,
140
+ /**
141
+ * In MB. When the filename exceeds this limit, the thumbnail will not be generated.
142
+ */
143
+ maxThumbnailFilesize: 10,
144
+ /**
145
+ * If `null`, the ratio of the image will be used to calculate it.
146
+ */
147
+ thumbnailWidth: 120,
148
+ /**
149
+ * The same as `thumbnailWidth`. If both are null, images will not be resized.
150
+ */
151
+ thumbnailHeight: 120,
152
+ /**
153
+ * How the images should be scaled down in case both, `thumbnailWidth` and `thumbnailHeight` are provided.
154
+ * Can be either `contain` or `crop`.
155
+ */
156
+ thumbnailMethod: "crop",
157
+ /**
158
+ * If set, images will be resized to these dimensions before being **uploaded**.
159
+ * If only one, `resizeWidth` **or** `resizeHeight` is provided, the original aspect
160
+ * ratio of the file will be preserved.
161
+ *
162
+ * The `options.transformFile` function uses these options, so if the `transformFile` function
163
+ * is overridden, these options don't do anything.
164
+ */
165
+ resizeWidth: null,
166
+ /**
167
+ * See `resizeWidth`.
168
+ */
169
+ resizeHeight: null,
170
+ /**
171
+ * The mime type of the resized image (before it gets uploaded to the server).
172
+ * If `null` the original mime type will be used. To force jpeg, for example, use `image/jpeg`.
173
+ * See `resizeWidth` for more information.
174
+ */
175
+ resizeMimeType: null,
176
+ /**
177
+ * The quality of the resized images. See `resizeWidth`.
178
+ */
179
+ resizeQuality: 0.8,
180
+ /**
181
+ * How the images should be scaled down in case both, `resizeWidth` and `resizeHeight` are provided.
182
+ * Can be either `contain` or `crop`.
183
+ */
184
+ resizeMethod: "contain",
185
+ /**
186
+ * The base that is used to calculate the **displayed** filesize. You can
187
+ * change this to 1024 if you would rather display kibibytes, mebibytes,
188
+ * etc... 1024 is technically incorrect, because `1024 bytes` are `1 kibibyte`
189
+ * not `1 kilobyte`. You can change this to `1024` if you don't care about
190
+ * validity.
191
+ */
192
+ filesizeBase: 1e3,
193
+ /**
194
+ * If not `null` defines how many files this Dropzone handles. If it exceeds,
195
+ * the event `maxfilesexceeded` will be called. The dropzone element gets the
196
+ * class `dz-max-files-reached` accordingly so you can provide visual
197
+ * feedback.
198
+ */
199
+ maxFiles: null,
200
+ /**
201
+ * An optional object to send additional headers to the server. Eg:
202
+ * `{ "My-Awesome-Header": "header value" }`
203
+ */
204
+ headers: null,
205
+ /**
206
+ * Should the default headers be set or not?
207
+ * Accept: application/json <- for requesting json response
208
+ * Cache-Control: no-cache <- Request shouldnt be cached
209
+ * X-Requested-With: XMLHttpRequest <- We sent the request via XMLHttpRequest
210
+ */
211
+ defaultHeaders: true,
212
+ /**
213
+ * If `true`, the dropzone element itself will be clickable, if `false`
214
+ * nothing will be clickable.
215
+ *
216
+ * You can also pass an HTML element, a CSS selector (for multiple elements)
217
+ * or an array of those. In that case, all of those elements will trigger an
218
+ * upload when clicked.
219
+ */
220
+ clickable: true,
221
+ /**
222
+ * Whether hidden files in directories should be ignored.
223
+ */
224
+ ignoreHiddenFiles: true,
225
+ /**
226
+ * The default implementation of `accept` checks the file's mime type or
227
+ * extension against this list. This is a comma separated list of mime
228
+ * types or file extensions.
229
+ *
230
+ * Eg.: `image/*,application/pdf,.psd`
231
+ *
232
+ * If the Dropzone is `clickable` this option will also be used as
233
+ * [`accept`](https://developer.mozilla.org/en-US/docs/HTML/Element/input#attr-accept)
234
+ * parameter on the hidden file input as well.
235
+ */
236
+ acceptedFiles: null,
237
+ /**
238
+ * **Deprecated!**
239
+ * Use acceptedFiles instead.
240
+ */
241
+ acceptedMimeTypes: null,
242
+ /**
243
+ * If false, files will be added to the queue but the queue will not be
244
+ * processed automatically.
245
+ * This can be useful if you need some additional user input before sending
246
+ * files (or if you want want all files sent at once).
247
+ * If you're ready to send the file simply call `myDropzone.processQueue()`.
248
+ *
249
+ * See the [enqueuing file uploads](#enqueuing-file-uploads) documentation
250
+ * section for more information.
251
+ */
252
+ autoProcessQueue: true,
253
+ /**
254
+ * If false, files added to the dropzone will not be queued by default.
255
+ * You'll have to call `enqueueFile(file)` manually.
256
+ */
257
+ autoQueue: true,
258
+ /**
259
+ * If `true`, this will add a link to every file preview to remove or cancel (if
260
+ * already uploading) the file. The `dictCancelUpload`, `dictCancelUploadConfirmation`
261
+ * and `dictRemoveFile` options are used for the wording.
262
+ */
263
+ addRemoveLinks: false,
264
+ /**
265
+ * Defines where to display the file previews – if `null` the
266
+ * Dropzone element itself is used. Can be a plain `HTMLElement` or a CSS
267
+ * selector. The element should have the `dropzone-previews` class so
268
+ * the previews are displayed properly.
269
+ */
270
+ previewsContainer: null,
271
+ /**
272
+ * Set this to `true` if you don't want previews to be shown.
273
+ */
274
+ disablePreviews: false,
275
+ /**
276
+ * This is the element the hidden input field (which is used when clicking on the
277
+ * dropzone to trigger file selection) will be appended to. This might
278
+ * be important in case you use frameworks to switch the content of your page.
279
+ *
280
+ * Can be a selector string, or an element directly.
281
+ */
282
+ hiddenInputContainer: "body",
283
+ /**
284
+ * If null, no capture type will be specified
285
+ * If camera, mobile devices will skip the file selection and choose camera
286
+ * If microphone, mobile devices will skip the file selection and choose the microphone
287
+ * If camcorder, mobile devices will skip the file selection and choose the camera in video mode
288
+ * On apple devices multiple must be set to false. AcceptedFiles may need to
289
+ * be set to an appropriate mime type (e.g. "image/*", "audio/*", or "video/*").
290
+ */
291
+ capture: null,
292
+ /**
293
+ * **Deprecated**. Use `renameFile` instead.
294
+ */
295
+ renameFilename: null,
296
+ /**
297
+ * A function that is invoked before the file is uploaded to the server and renames the file.
298
+ * This function gets the `File` as argument and can use the `file.name`. The actual name of the
299
+ * file that gets used during the upload can be accessed through `file.upload.filename`.
300
+ */
301
+ renameFile: null,
302
+ /**
303
+ * If `true` the fallback will be forced. This is very useful to test your server
304
+ * implementations first and make sure that everything works as
305
+ * expected without dropzone if you experience problems, and to test
306
+ * how your fallbacks will look.
307
+ */
308
+ forceFallback: false,
309
+ /**
310
+ * The text used before any files are dropped.
311
+ */
312
+ dictDefaultMessage: "Drop files here to upload",
313
+ /**
314
+ * The text that replaces the default message text it the browser is not supported.
315
+ */
316
+ dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
317
+ /**
318
+ * The text that will be added before the fallback form.
319
+ * If you provide a fallback element yourself, or if this option is `null` this will
320
+ * be ignored.
321
+ */
322
+ dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
323
+ /**
324
+ * If the filesize is too big.
325
+ * `{{filesize}}` and `{{maxFilesize}}` will be replaced with the respective configuration values.
326
+ */
327
+ dictFileTooBig: "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",
328
+ /**
329
+ * If the file doesn't match the file type.
330
+ */
331
+ dictInvalidFileType: "You can't upload files of this type.",
332
+ /**
333
+ * If the server response was invalid.
334
+ * `{{statusCode}}` will be replaced with the servers status code.
335
+ */
336
+ dictResponseError: "Server responded with {{statusCode}} code.",
337
+ /**
338
+ * If `addRemoveLinks` is true, the text to be used for the cancel upload link.
339
+ */
340
+ dictCancelUpload: "Cancel upload",
341
+ /**
342
+ * The text that is displayed if an upload was manually canceled
343
+ */
344
+ dictUploadCanceled: "Upload canceled.",
345
+ /**
346
+ * If `addRemoveLinks` is true, the text to be used for confirmation when cancelling upload.
347
+ */
348
+ dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?",
349
+ /**
350
+ * If `addRemoveLinks` is true, the text to be used to remove a file.
351
+ */
352
+ dictRemoveFile: "Remove file",
353
+ /**
354
+ * If this is not null, then the user will be prompted before removing a file.
355
+ */
356
+ dictRemoveFileConfirmation: null,
357
+ /**
358
+ * Displayed if `maxFiles` is st and exceeded.
359
+ * The string `{{maxFiles}}` will be replaced by the configuration value.
360
+ */
361
+ dictMaxFilesExceeded: "You can not upload any more files.",
362
+ /**
363
+ * Allows you to translate the different units. Starting with `tb` for terabytes and going down to
364
+ * `b` for bytes.
365
+ */
366
+ dictFileSizeUnits: {
367
+ tb: "TB",
368
+ gb: "GB",
369
+ mb: "MB",
370
+ kb: "KB",
371
+ b: "b"
372
+ },
373
+ /**
374
+ * Called when dropzone initialized
375
+ * You can add event listeners here
376
+ */
377
+ init() {
378
+ },
379
+ /**
380
+ * Can be an **object** of additional parameters to transfer to the server, **or** a `Function`
381
+ * that gets invoked with the `files`, `xhr` and, if it's a chunked upload, `chunk` arguments. In case
382
+ * of a function, this needs to return a map.
383
+ *
384
+ * The default implementation does nothing for normal uploads, but adds relevant information for
385
+ * chunked uploads.
386
+ *
387
+ * This is the same as adding hidden input fields in the form element.
388
+ */
389
+ params(files, xhr, chunk) {
390
+ if (chunk) return {
391
+ dzuuid: chunk.file.upload.uuid,
392
+ dzchunkindex: chunk.index,
393
+ dztotalfilesize: chunk.file.size,
394
+ dzchunksize: this.options.chunkSize,
395
+ dztotalchunkcount: chunk.file.upload.totalChunkCount,
396
+ dzchunkbyteoffset: chunk.index * this.options.chunkSize
397
+ };
398
+ },
399
+ /**
400
+ * A function that gets a [file](https://developer.mozilla.org/en-US/docs/DOM/File)
401
+ * and a `done` function as parameters.
402
+ *
403
+ * If the done function is invoked without arguments, the file is "accepted" and will
404
+ * be processed. If you pass an error message, the file is rejected, and the error
405
+ * message will be displayed.
406
+ * This function will not be called if the file is too big or doesn't match the mime types.
407
+ */
408
+ accept(file, done) {
409
+ return done();
410
+ },
411
+ /**
412
+ * The callback that will be invoked when all chunks have been uploaded for a file.
413
+ * It gets the file for which the chunks have been uploaded as the first parameter,
414
+ * and the `done` function as second. `done()` needs to be invoked when everything
415
+ * needed to finish the upload process is done.
416
+ */
417
+ chunksUploaded: function(file, done) {
418
+ done();
419
+ },
420
+ /**
421
+ * Sends the file as binary blob in body instead of form data.
422
+ * If this is set, the `params` option will be ignored.
423
+ * It's an error to set this to `true` along with `uploadMultiple` since
424
+ * multiple files cannot be in a single binary body.
425
+ */
426
+ binaryBody: false,
427
+ /**
428
+ * Gets called when the browser is not supported.
429
+ * The default implementation shows the fallback input field and adds
430
+ * a text.
431
+ */
432
+ fallback() {
433
+ let messageElement;
434
+ this.element.className = `${this.element.className} dz-browser-not-supported`;
435
+ for (let child of this.element.getElementsByTagName("div")) if (/(^| )dz-message($| )/.test(child.className)) {
436
+ messageElement = child;
437
+ child.className = "dz-message";
438
+ break;
439
+ }
440
+ if (!messageElement) {
441
+ messageElement = $3ed269f2f0fb224b$export$2e2bcd8739ae039.createElement('<div class="dz-message"><span></span></div>');
442
+ this.element.appendChild(messageElement);
443
+ }
444
+ let span = messageElement.getElementsByTagName("span")[0];
445
+ if (span) {
446
+ if (span.textContent != null) span.textContent = this.options.dictFallbackMessage;
447
+ else if (span.innerText != null) span.innerText = this.options.dictFallbackMessage;
448
+ }
449
+ return this.element.appendChild(this.getFallbackForm());
450
+ },
451
+ /**
452
+ * Gets called to calculate the thumbnail dimensions.
453
+ *
454
+ * It gets `file`, `width` and `height` (both may be `null`) as parameters and must return an object containing:
455
+ *
456
+ * - `srcWidth` & `srcHeight` (required)
457
+ * - `trgWidth` & `trgHeight` (required)
458
+ * - `srcX` & `srcY` (optional, default `0`)
459
+ * - `trgX` & `trgY` (optional, default `0`)
460
+ *
461
+ * Those values are going to be used by `ctx.drawImage()`.
462
+ */
463
+ resize(file, width, height, resizeMethod) {
464
+ let info = {
465
+ srcX: 0,
466
+ srcY: 0,
467
+ srcWidth: file.width,
468
+ srcHeight: file.height
469
+ };
470
+ let srcRatio = file.width / file.height;
471
+ if (width == null && height == null) {
472
+ width = info.srcWidth;
473
+ height = info.srcHeight;
474
+ } else if (width == null) width = height * srcRatio;
475
+ else if (height == null) height = width / srcRatio;
476
+ width = Math.min(width, info.srcWidth);
477
+ height = Math.min(height, info.srcHeight);
478
+ let trgRatio = width / height;
479
+ if (info.srcWidth > width || info.srcHeight > height) {
480
+ if (resizeMethod === "crop") {
481
+ if (srcRatio > trgRatio) {
482
+ info.srcHeight = file.height;
483
+ info.srcWidth = info.srcHeight * trgRatio;
484
+ } else {
485
+ info.srcWidth = file.width;
486
+ info.srcHeight = info.srcWidth / trgRatio;
487
+ }
488
+ } else if (resizeMethod === "contain") {
489
+ if (srcRatio > trgRatio) height = width / srcRatio;
490
+ else width = height * srcRatio;
491
+ } else throw new Error(`Unknown resizeMethod '${resizeMethod}'`);
492
+ }
493
+ info.srcX = (file.width - info.srcWidth) / 2;
494
+ info.srcY = (file.height - info.srcHeight) / 2;
495
+ info.trgWidth = width;
496
+ info.trgHeight = height;
497
+ return info;
498
+ },
499
+ /**
500
+ * Can be used to transform the file (for example, resize an image if necessary).
501
+ *
502
+ * The default implementation uses `resizeWidth` and `resizeHeight` (if provided) and resizes
503
+ * images according to those dimensions.
504
+ *
505
+ * Gets the `file` as the first parameter, and a `done()` function as the second, that needs
506
+ * to be invoked with the file when the transformation is done.
507
+ */
508
+ transformFile(file, done) {
509
+ if ((this.options.resizeWidth || this.options.resizeHeight) && file.type.match(/image.*/)) return this.resizeImage(file, this.options.resizeWidth, this.options.resizeHeight, this.options.resizeMethod, done);
510
+ else return done(file);
511
+ },
512
+ /**
513
+ * A string that contains the template used for each dropped
514
+ * file. Change it to fulfill your needs but make sure to properly
515
+ * provide all elements.
516
+ *
517
+ * If you want to use an actual HTML element instead of providing a String
518
+ * as a config option, you could create a div with the id `tpl`,
519
+ * put the template inside it and provide the element like this:
520
+ *
521
+ * document
522
+ * .querySelector('#tpl')
523
+ * .innerHTML
524
+ *
525
+ */
526
+ previewTemplate: /* @__PURE__ */ $parcel$interopDefault($fd6031f88dce2e32$exports),
527
+ /*
528
+ Those functions register themselves to the events on init and handle all
529
+ the user interface specific stuff. Overwriting them won't break the upload
530
+ but can break the way it's displayed.
531
+ You can overwrite them if you don't like the default behavior. If you just
532
+ want to add an additional event handler, register it on the dropzone object
533
+ and don't overwrite those options.
534
+ */
535
+ // Those are self explanatory and simply concern the DragnDrop.
536
+ drop(e) {
537
+ return this.element.classList.remove("dz-drag-hover");
538
+ },
539
+ dragstart(e) {
540
+ },
541
+ dragend(e) {
542
+ return this.element.classList.remove("dz-drag-hover");
543
+ },
544
+ dragenter(e) {
545
+ return this.element.classList.add("dz-drag-hover");
546
+ },
547
+ dragover(e) {
548
+ return this.element.classList.add("dz-drag-hover");
549
+ },
550
+ dragleave(e) {
551
+ return this.element.classList.remove("dz-drag-hover");
552
+ },
553
+ paste(e) {
554
+ },
555
+ // Called whenever there are no files left in the dropzone anymore, and the
556
+ // dropzone should be displayed as if in the initial state.
557
+ reset() {
558
+ return this.element.classList.remove("dz-started");
559
+ },
560
+ // Called when a file is added to the queue
561
+ // Receives `file`
562
+ addedfile(file) {
563
+ if (this.element === this.previewsContainer) this.element.classList.add("dz-started");
564
+ if (this.previewsContainer && !this.options.disablePreviews) {
565
+ file.previewElement = $3ed269f2f0fb224b$export$2e2bcd8739ae039.createElement(this.options.previewTemplate.trim());
566
+ file.previewTemplate = file.previewElement;
567
+ this.previewsContainer.appendChild(file.previewElement);
568
+ for (var node of file.previewElement.querySelectorAll("[data-dz-name]")) node.textContent = file.name;
569
+ for (node of file.previewElement.querySelectorAll("[data-dz-size]")) node.innerHTML = this.filesize(file.size);
570
+ if (this.options.addRemoveLinks) {
571
+ file._removeLink = $3ed269f2f0fb224b$export$2e2bcd8739ae039.createElement(`<a class="dz-remove" href="javascript:undefined;" data-dz-remove>${this.options.dictRemoveFile}</a>`);
572
+ file.previewElement.appendChild(file._removeLink);
573
+ }
574
+ let removeFileEvent = (e) => {
575
+ e.preventDefault();
576
+ e.stopPropagation();
577
+ if (file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING) return $3ed269f2f0fb224b$export$2e2bcd8739ae039.confirm(
578
+ this.options.dictCancelUploadConfirmation,
579
+ () => this.removeFile(file)
580
+ );
581
+ else {
582
+ if (this.options.dictRemoveFileConfirmation) return $3ed269f2f0fb224b$export$2e2bcd8739ae039.confirm(
583
+ this.options.dictRemoveFileConfirmation,
584
+ () => this.removeFile(file)
585
+ );
586
+ else return this.removeFile(file);
587
+ }
588
+ };
589
+ for (let removeLink of file.previewElement.querySelectorAll("[data-dz-remove]")) removeLink.addEventListener("click", removeFileEvent);
590
+ }
591
+ },
592
+ // Called whenever a file is removed.
593
+ removedfile(file) {
594
+ if (file.previewElement != null && file.previewElement.parentNode != null) file.previewElement.parentNode.removeChild(file.previewElement);
595
+ return this._updateMaxFilesReachedClass();
596
+ },
597
+ // Called when a thumbnail has been generated
598
+ // Receives `file` and `dataUrl`
599
+ thumbnail(file, dataUrl) {
600
+ if (file.previewElement) {
601
+ file.previewElement.classList.remove("dz-file-preview");
602
+ for (let thumbnailElement of file.previewElement.querySelectorAll("[data-dz-thumbnail]")) {
603
+ thumbnailElement.alt = file.name;
604
+ thumbnailElement.src = dataUrl;
605
+ }
606
+ return setTimeout(
607
+ () => file.previewElement.classList.add("dz-image-preview"),
608
+ 1
609
+ );
610
+ }
611
+ },
612
+ // Called whenever an error occurs
613
+ // Receives `file` and `message`
614
+ error(file, message) {
615
+ if (file.previewElement) {
616
+ file.previewElement.classList.add("dz-error");
617
+ if (typeof message !== "string" && message.error) message = message.error;
618
+ for (let node of file.previewElement.querySelectorAll("[data-dz-errormessage]")) node.textContent = message;
619
+ }
620
+ },
621
+ errormultiple() {
622
+ },
623
+ // Called when a file gets processed. Since there is a cue, not all added
624
+ // files are processed immediately.
625
+ // Receives `file`
626
+ processing(file) {
627
+ if (file.previewElement) {
628
+ file.previewElement.classList.add("dz-processing");
629
+ if (file._removeLink) return file._removeLink.innerHTML = this.options.dictCancelUpload;
630
+ }
631
+ },
632
+ processingmultiple() {
633
+ },
634
+ // Called whenever the upload progress gets updated.
635
+ // Receives `file`, `progress` (percentage 0-100) and `bytesSent`.
636
+ // To get the total number of bytes of the file, use `file.size`
637
+ uploadprogress(file, progress, bytesSent) {
638
+ if (file.previewElement) for (let node of file.previewElement.querySelectorAll("[data-dz-uploadprogress]")) node.nodeName === "PROGRESS" ? node.value = progress : node.style.width = `${progress}%`;
639
+ },
640
+ // Called whenever the total upload progress gets updated.
641
+ // Called with totalUploadProgress (0-100), totalBytes and totalBytesSent
642
+ totaluploadprogress() {
643
+ },
644
+ // Called just before the file is sent. Gets the `xhr` object as second
645
+ // parameter, so you can modify it (for example to add a CSRF token) and a
646
+ // `formData` object to add additional information.
647
+ sending() {
648
+ },
649
+ sendingmultiple() {
650
+ },
651
+ // When the complete upload is finished and successful
652
+ // Receives `file`
653
+ success(file) {
654
+ if (file.previewElement) return file.previewElement.classList.add("dz-success");
655
+ },
656
+ successmultiple() {
657
+ },
658
+ // When the upload is canceled.
659
+ canceled(file) {
660
+ return this.emit("error", file, this.options.dictUploadCanceled);
661
+ },
662
+ canceledmultiple() {
663
+ },
664
+ // When the upload is finished, either with success or an error.
665
+ // Receives `file`
666
+ complete(file) {
667
+ if (file._removeLink) file._removeLink.innerHTML = this.options.dictRemoveFile;
668
+ if (file.previewElement) return file.previewElement.classList.add("dz-complete");
669
+ },
670
+ completemultiple() {
671
+ },
672
+ maxfilesexceeded() {
673
+ },
674
+ maxfilesreached() {
675
+ },
676
+ queuecomplete() {
677
+ },
678
+ addedfiles() {
679
+ }
680
+ };
681
+ var $4ca367182776f80b$export$2e2bcd8739ae039 = $4ca367182776f80b$var$defaultOptions;
682
+ class $3ed269f2f0fb224b$export$2e2bcd8739ae039 extends $4040acfd8584338d$export$2e2bcd8739ae039 {
683
+ static initClass() {
684
+ this.prototype.Emitter = $4040acfd8584338d$export$2e2bcd8739ae039;
685
+ this.prototype.events = [
686
+ "drop",
687
+ "dragstart",
688
+ "dragend",
689
+ "dragenter",
690
+ "dragover",
691
+ "dragleave",
692
+ "addedfile",
693
+ "addedfiles",
694
+ "removedfile",
695
+ "thumbnail",
696
+ "error",
697
+ "errormultiple",
698
+ "processing",
699
+ "processingmultiple",
700
+ "uploadprogress",
701
+ "totaluploadprogress",
702
+ "sending",
703
+ "sendingmultiple",
704
+ "success",
705
+ "successmultiple",
706
+ "canceled",
707
+ "canceledmultiple",
708
+ "complete",
709
+ "completemultiple",
710
+ "reset",
711
+ "maxfilesexceeded",
712
+ "maxfilesreached",
713
+ "queuecomplete"
714
+ ];
715
+ this.prototype._thumbnailQueue = [];
716
+ this.prototype._processingThumbnail = false;
717
+ }
718
+ // Returns all files that have been accepted
719
+ getAcceptedFiles() {
720
+ return this.files.filter(
721
+ (file) => file.accepted
722
+ ).map(
723
+ (file) => file
724
+ );
725
+ }
726
+ // Returns all files that have been rejected
727
+ // Not sure when that's going to be useful, but added for completeness.
728
+ getRejectedFiles() {
729
+ return this.files.filter(
730
+ (file) => !file.accepted
731
+ ).map(
732
+ (file) => file
733
+ );
734
+ }
735
+ getFilesWithStatus(status) {
736
+ return this.files.filter(
737
+ (file) => file.status === status
738
+ ).map(
739
+ (file) => file
740
+ );
741
+ }
742
+ // Returns all files that are in the queue
743
+ getQueuedFiles() {
744
+ return this.getFilesWithStatus($3ed269f2f0fb224b$export$2e2bcd8739ae039.QUEUED);
745
+ }
746
+ getUploadingFiles() {
747
+ return this.getFilesWithStatus($3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING);
748
+ }
749
+ getAddedFiles() {
750
+ return this.getFilesWithStatus($3ed269f2f0fb224b$export$2e2bcd8739ae039.ADDED);
751
+ }
752
+ // Files that are either queued or uploading
753
+ getActiveFiles() {
754
+ return this.files.filter(
755
+ (file) => file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING || file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.QUEUED
756
+ ).map(
757
+ (file) => file
758
+ );
759
+ }
760
+ // The function that gets called when Dropzone is initialized. You
761
+ // can (and should) setup event listeners inside this function.
762
+ init() {
763
+ if (this.element.tagName === "form") this.element.setAttribute("enctype", "multipart/form-data");
764
+ if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) this.element.appendChild($3ed269f2f0fb224b$export$2e2bcd8739ae039.createElement(`<div class="dz-default dz-message"><button class="dz-button" type="button">${this.options.dictDefaultMessage}</button></div>`));
765
+ if (this.clickableElements.length) {
766
+ let setupHiddenFileInput = () => {
767
+ if (this.hiddenFileInput) this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);
768
+ this.hiddenFileInput = document.createElement("input");
769
+ this.hiddenFileInput.setAttribute("type", "file");
770
+ if (this.options.maxFiles === null || this.options.maxFiles > 1) this.hiddenFileInput.setAttribute("multiple", "multiple");
771
+ this.hiddenFileInput.className = "dz-hidden-input";
772
+ if (this.options.acceptedFiles !== null) this.hiddenFileInput.setAttribute("accept", this.options.acceptedFiles);
773
+ if (this.options.capture !== null) this.hiddenFileInput.setAttribute("capture", this.options.capture);
774
+ this.hiddenFileInput.setAttribute("tabindex", "-1");
775
+ this.hiddenFileInput.style.visibility = "hidden";
776
+ this.hiddenFileInput.style.position = "absolute";
777
+ this.hiddenFileInput.style.top = "0";
778
+ this.hiddenFileInput.style.left = "0";
779
+ this.hiddenFileInput.style.height = "0";
780
+ this.hiddenFileInput.style.width = "0";
781
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.getElement(this.options.hiddenInputContainer, "hiddenInputContainer").appendChild(this.hiddenFileInput);
782
+ this.hiddenFileInput.addEventListener("change", () => {
783
+ let { files } = this.hiddenFileInput;
784
+ if (files.length) for (let file of files) this.addFile(file);
785
+ this.emit("addedfiles", files);
786
+ setupHiddenFileInput();
787
+ });
788
+ };
789
+ setupHiddenFileInput();
790
+ }
791
+ this.URL = window.URL !== null ? window.URL : window.webkitURL;
792
+ for (let eventName of this.events) this.on(eventName, this.options[eventName]);
793
+ this.on(
794
+ "uploadprogress",
795
+ () => this.updateTotalUploadProgress()
796
+ );
797
+ this.on(
798
+ "removedfile",
799
+ () => this.updateTotalUploadProgress()
800
+ );
801
+ this.on(
802
+ "canceled",
803
+ (file) => this.emit("complete", file)
804
+ );
805
+ this.on("complete", (file) => {
806
+ if (this.getAddedFiles().length === 0 && this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0)
807
+ return setTimeout(
808
+ () => this.emit("queuecomplete"),
809
+ 0
810
+ );
811
+ });
812
+ const containsFiles = function(e) {
813
+ if (e.dataTransfer.types)
814
+ for (var i = 0; i < e.dataTransfer.types.length; i++) {
815
+ if (e.dataTransfer.types[i] === "Files") return true;
816
+ }
817
+ return false;
818
+ };
819
+ let noPropagation = function(e) {
820
+ if (!containsFiles(e)) return;
821
+ e.stopPropagation();
822
+ if (e.preventDefault) return e.preventDefault();
823
+ else return e.returnValue = false;
824
+ };
825
+ this.listeners = [
826
+ {
827
+ element: this.element,
828
+ events: {
829
+ dragstart: (e) => {
830
+ return this.emit("dragstart", e);
831
+ },
832
+ dragenter: (e) => {
833
+ noPropagation(e);
834
+ return this.emit("dragenter", e);
835
+ },
836
+ dragover: (e) => {
837
+ let efct;
838
+ try {
839
+ efct = e.dataTransfer.effectAllowed;
840
+ } catch (error) {
841
+ }
842
+ e.dataTransfer.dropEffect = "move" === efct || "linkMove" === efct ? "move" : "copy";
843
+ noPropagation(e);
844
+ return this.emit("dragover", e);
845
+ },
846
+ dragleave: (e) => {
847
+ return this.emit("dragleave", e);
848
+ },
849
+ drop: (e) => {
850
+ noPropagation(e);
851
+ return this.drop(e);
852
+ },
853
+ dragend: (e) => {
854
+ return this.emit("dragend", e);
855
+ }
856
+ }
857
+ }
858
+ ];
859
+ this.clickableElements.forEach((clickableElement) => {
860
+ return this.listeners.push({
861
+ element: clickableElement,
862
+ events: {
863
+ click: (evt) => {
864
+ if (clickableElement !== this.element || evt.target === this.element || $3ed269f2f0fb224b$export$2e2bcd8739ae039.elementInside(evt.target, this.element.querySelector(".dz-message"))) this.hiddenFileInput.click();
865
+ return true;
866
+ }
867
+ }
868
+ });
869
+ });
870
+ this.enable();
871
+ return this.options.init.call(this);
872
+ }
873
+ // Not fully tested yet
874
+ destroy() {
875
+ this.disable();
876
+ this.removeAllFiles(true);
877
+ if (this.hiddenFileInput != null ? this.hiddenFileInput.parentNode : void 0) {
878
+ this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);
879
+ this.hiddenFileInput = null;
880
+ }
881
+ delete this.element.dropzone;
882
+ return $3ed269f2f0fb224b$export$2e2bcd8739ae039.instances.splice($3ed269f2f0fb224b$export$2e2bcd8739ae039.instances.indexOf(this), 1);
883
+ }
884
+ updateTotalUploadProgress() {
885
+ let totalUploadProgress;
886
+ let totalBytesSent = 0;
887
+ let totalBytes = 0;
888
+ let activeFiles = this.getActiveFiles();
889
+ if (activeFiles.length) {
890
+ for (let file of this.getActiveFiles()) {
891
+ totalBytesSent += file.upload.bytesSent;
892
+ totalBytes += file.upload.total;
893
+ }
894
+ totalUploadProgress = 100 * totalBytesSent / totalBytes;
895
+ } else totalUploadProgress = 100;
896
+ return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent);
897
+ }
898
+ // @options.paramName can be a function taking one parameter rather than a string.
899
+ // A parameter name for a file is obtained simply by calling this with an index number.
900
+ _getParamName(n) {
901
+ if (typeof this.options.paramName === "function") return this.options.paramName(n);
902
+ else return `${this.options.paramName}${this.options.uploadMultiple ? `[${n}]` : ""}`;
903
+ }
904
+ // If @options.renameFile is a function,
905
+ // the function will be used to rename the file.name before appending it to the formData
906
+ _renameFile(file) {
907
+ if (typeof this.options.renameFile !== "function") return file.name;
908
+ return this.options.renameFile(file);
909
+ }
910
+ // Returns a form that can be used as fallback if the browser does not support DragnDrop
911
+ //
912
+ // If the dropzone is already a form, only the input field and button are returned. Otherwise a complete form element is provided.
913
+ // This code has to pass in IE7 :(
914
+ getFallbackForm() {
915
+ let existingFallback, form;
916
+ if (existingFallback = this.getExistingFallback()) return existingFallback;
917
+ let fieldsString = '<div class="dz-fallback">';
918
+ if (this.options.dictFallbackText) fieldsString += `<p>${this.options.dictFallbackText}</p>`;
919
+ fieldsString += `<input type="file" name="${this._getParamName(0)}" ${this.options.uploadMultiple ? 'multiple="multiple"' : void 0} /><input type="submit" value="Upload!"></div>`;
920
+ let fields = $3ed269f2f0fb224b$export$2e2bcd8739ae039.createElement(fieldsString);
921
+ if (this.element.tagName !== "FORM") {
922
+ form = $3ed269f2f0fb224b$export$2e2bcd8739ae039.createElement(`<form action="${this.options.url}" enctype="multipart/form-data" method="${this.options.method}"></form>`);
923
+ form.appendChild(fields);
924
+ } else {
925
+ this.element.setAttribute("enctype", "multipart/form-data");
926
+ this.element.setAttribute("method", this.options.method);
927
+ }
928
+ return form != null ? form : fields;
929
+ }
930
+ // Returns the fallback elements if they exist already
931
+ //
932
+ // This code has to pass in IE7 :(
933
+ getExistingFallback() {
934
+ let getFallback = function(elements) {
935
+ for (let el of elements) {
936
+ if (/(^| )fallback($| )/.test(el.className)) return el;
937
+ }
938
+ };
939
+ for (let tagName of [
940
+ "div",
941
+ "form"
942
+ ]) {
943
+ var fallback;
944
+ if (fallback = getFallback(this.element.getElementsByTagName(tagName))) return fallback;
945
+ }
946
+ }
947
+ // Activates all listeners stored in @listeners
948
+ setupEventListeners() {
949
+ return this.listeners.map(
950
+ (elementListeners) => (() => {
951
+ let result = [];
952
+ for (let event in elementListeners.events) {
953
+ let listener = elementListeners.events[event];
954
+ result.push(elementListeners.element.addEventListener(event, listener, false));
955
+ }
956
+ return result;
957
+ })()
958
+ );
959
+ }
960
+ // Deactivates all listeners stored in @listeners
961
+ removeEventListeners() {
962
+ return this.listeners.map(
963
+ (elementListeners) => (() => {
964
+ let result = [];
965
+ for (let event in elementListeners.events) {
966
+ let listener = elementListeners.events[event];
967
+ result.push(elementListeners.element.removeEventListener(event, listener, false));
968
+ }
969
+ return result;
970
+ })()
971
+ );
972
+ }
973
+ // Removes all event listeners and cancels all files in the queue or being processed.
974
+ disable() {
975
+ this.clickableElements.forEach(
976
+ (element) => element.classList.remove("dz-clickable")
977
+ );
978
+ this.removeEventListeners();
979
+ this.disabled = true;
980
+ return this.files.map(
981
+ (file) => this.cancelUpload(file)
982
+ );
983
+ }
984
+ enable() {
985
+ delete this.disabled;
986
+ this.clickableElements.forEach(
987
+ (element) => element.classList.add("dz-clickable")
988
+ );
989
+ return this.setupEventListeners();
990
+ }
991
+ // Returns a nicely formatted filesize
992
+ filesize(size) {
993
+ let selectedSize = 0;
994
+ let selectedUnit = "b";
995
+ if (size > 0) {
996
+ let units = [
997
+ "tb",
998
+ "gb",
999
+ "mb",
1000
+ "kb",
1001
+ "b"
1002
+ ];
1003
+ for (let i = 0; i < units.length; i++) {
1004
+ let unit = units[i];
1005
+ let cutoff = Math.pow(this.options.filesizeBase, 4 - i) / 10;
1006
+ if (size >= cutoff) {
1007
+ selectedSize = size / Math.pow(this.options.filesizeBase, 4 - i);
1008
+ selectedUnit = unit;
1009
+ break;
1010
+ }
1011
+ }
1012
+ selectedSize = Math.round(10 * selectedSize) / 10;
1013
+ }
1014
+ return `<strong>${selectedSize}</strong> ${this.options.dictFileSizeUnits[selectedUnit]}`;
1015
+ }
1016
+ // Adds or removes the `dz-max-files-reached` class from the form.
1017
+ _updateMaxFilesReachedClass() {
1018
+ if (this.options.maxFiles != null && this.getAcceptedFiles().length >= this.options.maxFiles) {
1019
+ if (this.getAcceptedFiles().length === this.options.maxFiles) this.emit("maxfilesreached", this.files);
1020
+ return this.element.classList.add("dz-max-files-reached");
1021
+ } else return this.element.classList.remove("dz-max-files-reached");
1022
+ }
1023
+ drop(e) {
1024
+ if (!e.dataTransfer) return;
1025
+ this.emit("drop", e);
1026
+ let files = [];
1027
+ for (let i = 0; i < e.dataTransfer.files.length; i++) files[i] = e.dataTransfer.files[i];
1028
+ if (files.length) {
1029
+ let { items } = e.dataTransfer;
1030
+ if (items && items.length && items[0].webkitGetAsEntry != null)
1031
+ this._addFilesFromItems(items);
1032
+ else this.handleFiles(files);
1033
+ }
1034
+ this.emit("addedfiles", files);
1035
+ }
1036
+ paste(e) {
1037
+ if ($3ed269f2f0fb224b$var$__guard__(
1038
+ e != null ? e.clipboardData : void 0,
1039
+ (x) => x.items
1040
+ ) == null) return;
1041
+ this.emit("paste", e);
1042
+ let { items } = e.clipboardData;
1043
+ if (items.length) return this._addFilesFromItems(items);
1044
+ }
1045
+ handleFiles(files) {
1046
+ for (let file of files) this.addFile(file);
1047
+ }
1048
+ // When a folder is dropped (or files are pasted), items must be handled
1049
+ // instead of files.
1050
+ _addFilesFromItems(items) {
1051
+ return (() => {
1052
+ let result = [];
1053
+ for (let item of items) {
1054
+ var entry;
1055
+ if (item.webkitGetAsEntry != null && (entry = item.webkitGetAsEntry())) {
1056
+ if (entry.isFile) result.push(this.addFile(item.getAsFile()));
1057
+ else if (entry.isDirectory)
1058
+ result.push(this._addFilesFromDirectory(entry, entry.name));
1059
+ else result.push(void 0);
1060
+ } else if (item.getAsFile != null) {
1061
+ if (item.kind == null || item.kind === "file") result.push(this.addFile(item.getAsFile()));
1062
+ else result.push(void 0);
1063
+ } else result.push(void 0);
1064
+ }
1065
+ return result;
1066
+ })();
1067
+ }
1068
+ // Goes through the directory, and adds each file it finds recursively
1069
+ _addFilesFromDirectory(directory, path) {
1070
+ let dirReader = directory.createReader();
1071
+ let errorHandler = (error) => $3ed269f2f0fb224b$var$__guardMethod__(
1072
+ console,
1073
+ "log",
1074
+ (o) => o.log(error)
1075
+ );
1076
+ var readEntries = () => {
1077
+ return dirReader.readEntries((entries) => {
1078
+ if (entries.length > 0) {
1079
+ for (let entry of entries) {
1080
+ if (entry.isFile) entry.file((file) => {
1081
+ if (this.options.ignoreHiddenFiles && file.name.substring(0, 1) === ".") return;
1082
+ file.fullPath = `${path}/${file.name}`;
1083
+ return this.addFile(file);
1084
+ });
1085
+ else if (entry.isDirectory) this._addFilesFromDirectory(entry, `${path}/${entry.name}`);
1086
+ }
1087
+ readEntries();
1088
+ }
1089
+ return null;
1090
+ }, errorHandler);
1091
+ };
1092
+ return readEntries();
1093
+ }
1094
+ // If `done()` is called without argument the file is accepted
1095
+ // If you call it with an error message, the file is rejected
1096
+ // (This allows for asynchronous validation)
1097
+ //
1098
+ // This function checks the filesize, and if the file.type passes the
1099
+ // `acceptedFiles` check.
1100
+ accept(file, done) {
1101
+ if (this.options.maxFilesize && file.size > this.options.maxFilesize * 1048576) done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize));
1102
+ else if (!$3ed269f2f0fb224b$export$2e2bcd8739ae039.isValidFile(file, this.options.acceptedFiles)) done(this.options.dictInvalidFileType);
1103
+ else if (this.options.maxFiles != null && this.getAcceptedFiles().length >= this.options.maxFiles) {
1104
+ done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles));
1105
+ this.emit("maxfilesexceeded", file);
1106
+ } else this.options.accept.call(this, file, done);
1107
+ }
1108
+ addFile(file) {
1109
+ file.upload = {
1110
+ uuid: $3ed269f2f0fb224b$export$2e2bcd8739ae039.uuidv4(),
1111
+ progress: 0,
1112
+ // Setting the total upload size to file.size for the beginning
1113
+ // It's actual different than the size to be transmitted.
1114
+ total: file.size,
1115
+ bytesSent: 0,
1116
+ filename: this._renameFile(file)
1117
+ };
1118
+ this.files.push(file);
1119
+ file.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.ADDED;
1120
+ this.emit("addedfile", file);
1121
+ this._enqueueThumbnail(file);
1122
+ this.accept(file, (error) => {
1123
+ if (error) {
1124
+ file.accepted = false;
1125
+ this._errorProcessing([
1126
+ file
1127
+ ], error);
1128
+ } else {
1129
+ file.accepted = true;
1130
+ if (this.options.autoQueue) this.enqueueFile(file);
1131
+ }
1132
+ this._updateMaxFilesReachedClass();
1133
+ });
1134
+ }
1135
+ // Wrapper for enqueueFile
1136
+ enqueueFiles(files) {
1137
+ for (let file of files) this.enqueueFile(file);
1138
+ return null;
1139
+ }
1140
+ enqueueFile(file) {
1141
+ if (file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.ADDED && file.accepted === true) {
1142
+ file.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.QUEUED;
1143
+ if (this.options.autoProcessQueue) return setTimeout(
1144
+ () => this.processQueue(),
1145
+ 0
1146
+ );
1147
+ } else throw new Error("This file can't be queued because it has already been processed or was rejected.");
1148
+ }
1149
+ _enqueueThumbnail(file) {
1150
+ if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1048576) {
1151
+ this._thumbnailQueue.push(file);
1152
+ return setTimeout(
1153
+ () => this._processThumbnailQueue(),
1154
+ 0
1155
+ );
1156
+ }
1157
+ }
1158
+ _processThumbnailQueue() {
1159
+ if (this._processingThumbnail || this._thumbnailQueue.length === 0) return;
1160
+ this._processingThumbnail = true;
1161
+ let file = this._thumbnailQueue.shift();
1162
+ return this.createThumbnail(file, this.options.thumbnailWidth, this.options.thumbnailHeight, this.options.thumbnailMethod, true, (dataUrl) => {
1163
+ this.emit("thumbnail", file, dataUrl);
1164
+ this._processingThumbnail = false;
1165
+ return this._processThumbnailQueue();
1166
+ });
1167
+ }
1168
+ // Can be called by the user to remove a file
1169
+ removeFile(file) {
1170
+ if (file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING) this.cancelUpload(file);
1171
+ this.files = $3ed269f2f0fb224b$var$without(this.files, file);
1172
+ this.emit("removedfile", file);
1173
+ if (this.files.length === 0) return this.emit("reset");
1174
+ }
1175
+ // Removes all files that aren't currently processed from the list
1176
+ removeAllFiles(cancelIfNecessary) {
1177
+ if (cancelIfNecessary == null) cancelIfNecessary = false;
1178
+ for (let file of this.files.slice()) if (file.status !== $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING || cancelIfNecessary) this.removeFile(file);
1179
+ return null;
1180
+ }
1181
+ // Resizes an image before it gets sent to the server. This function is the default behavior of
1182
+ // `options.transformFile` if `resizeWidth` or `resizeHeight` are set. The callback is invoked with
1183
+ // the resized blob.
1184
+ resizeImage(file, width, height, resizeMethod, callback) {
1185
+ return this.createThumbnail(file, width, height, resizeMethod, true, (dataUrl, canvas) => {
1186
+ if (canvas == null)
1187
+ return callback(file);
1188
+ else {
1189
+ let { resizeMimeType } = this.options;
1190
+ if (resizeMimeType == null) resizeMimeType = file.type;
1191
+ let resizedDataURL = canvas.toDataURL(resizeMimeType, this.options.resizeQuality);
1192
+ if (resizeMimeType === "image/jpeg" || resizeMimeType === "image/jpg")
1193
+ resizedDataURL = $3ed269f2f0fb224b$var$ExifRestore.restore(file.dataURL, resizedDataURL);
1194
+ return callback($3ed269f2f0fb224b$export$2e2bcd8739ae039.dataURItoBlob(resizedDataURL));
1195
+ }
1196
+ });
1197
+ }
1198
+ createThumbnail(file, width, height, resizeMethod, fixOrientation, callback) {
1199
+ let fileReader = new FileReader();
1200
+ fileReader.onload = () => {
1201
+ file.dataURL = fileReader.result;
1202
+ if (file.type === "image/svg+xml") {
1203
+ if (callback != null) callback(fileReader.result);
1204
+ return;
1205
+ }
1206
+ this.createThumbnailFromUrl(file, width, height, resizeMethod, fixOrientation, callback);
1207
+ };
1208
+ fileReader.readAsDataURL(file);
1209
+ }
1210
+ // `mockFile` needs to have these attributes:
1211
+ //
1212
+ // { name: 'name', size: 12345, imageUrl: '' }
1213
+ //
1214
+ // `callback` will be invoked when the image has been downloaded and displayed.
1215
+ // `crossOrigin` will be added to the `img` tag when accessing the file.
1216
+ displayExistingFile(mockFile, imageUrl, callback, crossOrigin, resizeThumbnail = true) {
1217
+ this.emit("addedfile", mockFile);
1218
+ this.emit("complete", mockFile);
1219
+ if (!resizeThumbnail) {
1220
+ this.emit("thumbnail", mockFile, imageUrl);
1221
+ if (callback) callback();
1222
+ } else {
1223
+ let onDone = (thumbnail) => {
1224
+ this.emit("thumbnail", mockFile, thumbnail);
1225
+ if (callback) callback();
1226
+ };
1227
+ mockFile.dataURL = imageUrl;
1228
+ this.createThumbnailFromUrl(mockFile, this.options.thumbnailWidth, this.options.thumbnailHeight, this.options.thumbnailMethod, this.options.fixOrientation, onDone, crossOrigin);
1229
+ }
1230
+ }
1231
+ createThumbnailFromUrl(file, width, height, resizeMethod, fixOrientation, callback, crossOrigin) {
1232
+ let img = document.createElement("img");
1233
+ if (crossOrigin) img.crossOrigin = crossOrigin;
1234
+ fixOrientation = getComputedStyle(document.body)["imageOrientation"] == "from-image" ? false : fixOrientation;
1235
+ img.onload = () => {
1236
+ let loadExif = (callback2) => callback2(1);
1237
+ if (typeof EXIF !== "undefined" && EXIF !== null && fixOrientation) loadExif = (callback2) => EXIF.getData(img, function() {
1238
+ return callback2(EXIF.getTag(this, "Orientation"));
1239
+ });
1240
+ return loadExif((orientation) => {
1241
+ file.width = img.width;
1242
+ file.height = img.height;
1243
+ let resizeInfo = this.options.resize.call(this, file, width, height, resizeMethod);
1244
+ let canvas = document.createElement("canvas");
1245
+ let ctx = canvas.getContext("2d");
1246
+ canvas.width = resizeInfo.trgWidth;
1247
+ canvas.height = resizeInfo.trgHeight;
1248
+ if (orientation > 4) {
1249
+ canvas.width = resizeInfo.trgHeight;
1250
+ canvas.height = resizeInfo.trgWidth;
1251
+ }
1252
+ switch (orientation) {
1253
+ case 2:
1254
+ ctx.translate(canvas.width, 0);
1255
+ ctx.scale(-1, 1);
1256
+ break;
1257
+ case 3:
1258
+ ctx.translate(canvas.width, canvas.height);
1259
+ ctx.rotate(Math.PI);
1260
+ break;
1261
+ case 4:
1262
+ ctx.translate(0, canvas.height);
1263
+ ctx.scale(1, -1);
1264
+ break;
1265
+ case 5:
1266
+ ctx.rotate(0.5 * Math.PI);
1267
+ ctx.scale(1, -1);
1268
+ break;
1269
+ case 6:
1270
+ ctx.rotate(0.5 * Math.PI);
1271
+ ctx.translate(0, -canvas.width);
1272
+ break;
1273
+ case 7:
1274
+ ctx.rotate(0.5 * Math.PI);
1275
+ ctx.translate(canvas.height, -canvas.width);
1276
+ ctx.scale(-1, 1);
1277
+ break;
1278
+ case 8:
1279
+ ctx.rotate(-0.5 * Math.PI);
1280
+ ctx.translate(-canvas.height, 0);
1281
+ break;
1282
+ }
1283
+ $3ed269f2f0fb224b$var$drawImageIOSFix(ctx, img, resizeInfo.srcX != null ? resizeInfo.srcX : 0, resizeInfo.srcY != null ? resizeInfo.srcY : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, resizeInfo.trgX != null ? resizeInfo.trgX : 0, resizeInfo.trgY != null ? resizeInfo.trgY : 0, resizeInfo.trgWidth, resizeInfo.trgHeight);
1284
+ let thumbnail = canvas.toDataURL("image/png");
1285
+ if (callback != null) return callback(thumbnail, canvas);
1286
+ });
1287
+ };
1288
+ if (callback != null) img.onerror = callback;
1289
+ return img.src = file.dataURL;
1290
+ }
1291
+ // Goes through the queue and processes files if there aren't too many already.
1292
+ processQueue() {
1293
+ let { parallelUploads } = this.options;
1294
+ let processingLength = this.getUploadingFiles().length;
1295
+ let i = processingLength;
1296
+ if (processingLength >= parallelUploads) return;
1297
+ let queuedFiles = this.getQueuedFiles();
1298
+ if (!(queuedFiles.length > 0)) return;
1299
+ if (this.options.uploadMultiple)
1300
+ return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength));
1301
+ else while (i < parallelUploads) {
1302
+ if (!queuedFiles.length) return;
1303
+ this.processFile(queuedFiles.shift());
1304
+ i++;
1305
+ }
1306
+ }
1307
+ // Wrapper for `processFiles`
1308
+ processFile(file) {
1309
+ return this.processFiles([
1310
+ file
1311
+ ]);
1312
+ }
1313
+ // Loads the file, then calls finishedLoading()
1314
+ processFiles(files) {
1315
+ for (let file of files) {
1316
+ file.processing = true;
1317
+ file.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING;
1318
+ this.emit("processing", file);
1319
+ }
1320
+ if (this.options.uploadMultiple) this.emit("processingmultiple", files);
1321
+ return this.uploadFiles(files);
1322
+ }
1323
+ _getFilesWithXhr(xhr) {
1324
+ return this.files.filter(
1325
+ (file) => file.xhr === xhr
1326
+ ).map(
1327
+ (file) => file
1328
+ );
1329
+ }
1330
+ // Cancels the file upload and sets the status to CANCELED
1331
+ // **if** the file is actually being uploaded.
1332
+ // If it's still in the queue, the file is being removed from it and the status
1333
+ // set to CANCELED.
1334
+ cancelUpload(file) {
1335
+ if (file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING) {
1336
+ let groupedFiles = this._getFilesWithXhr(file.xhr);
1337
+ for (let groupedFile of groupedFiles) groupedFile.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.CANCELED;
1338
+ if (typeof file.xhr !== "undefined") file.xhr.abort();
1339
+ for (let groupedFile1 of groupedFiles) this.emit("canceled", groupedFile1);
1340
+ if (this.options.uploadMultiple) this.emit("canceledmultiple", groupedFiles);
1341
+ } else if (file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.ADDED || file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.QUEUED) {
1342
+ file.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.CANCELED;
1343
+ this.emit("canceled", file);
1344
+ if (this.options.uploadMultiple) this.emit("canceledmultiple", [
1345
+ file
1346
+ ]);
1347
+ }
1348
+ if (this.options.autoProcessQueue) return this.processQueue();
1349
+ }
1350
+ resolveOption(option, ...args) {
1351
+ if (typeof option === "function") return option.apply(this, args);
1352
+ return option;
1353
+ }
1354
+ uploadFile(file) {
1355
+ return this.uploadFiles([
1356
+ file
1357
+ ]);
1358
+ }
1359
+ uploadFiles(files) {
1360
+ this._transformFiles(files, (transformedFiles) => {
1361
+ if (this.options.chunking) {
1362
+ let transformedFile = transformedFiles[0];
1363
+ files[0].upload.chunked = this.options.chunking && (this.options.forceChunking || transformedFile.size > this.options.chunkSize);
1364
+ files[0].upload.totalChunkCount = Math.ceil(transformedFile.size / this.options.chunkSize);
1365
+ }
1366
+ if (files[0].upload.chunked) {
1367
+ let file = files[0];
1368
+ let transformedFile = transformedFiles[0];
1369
+ file.upload.chunks = [];
1370
+ let handleNextChunk = () => {
1371
+ let chunkIndex = 0;
1372
+ while (file.upload.chunks[chunkIndex] !== void 0) chunkIndex++;
1373
+ if (chunkIndex >= file.upload.totalChunkCount) return;
1374
+ let start = chunkIndex * this.options.chunkSize;
1375
+ let end = Math.min(start + this.options.chunkSize, transformedFile.size);
1376
+ let dataBlock = {
1377
+ name: this._getParamName(0),
1378
+ data: transformedFile.webkitSlice ? transformedFile.webkitSlice(start, end) : transformedFile.slice(start, end),
1379
+ filename: file.upload.filename,
1380
+ chunkIndex
1381
+ };
1382
+ file.upload.chunks[chunkIndex] = {
1383
+ file,
1384
+ index: chunkIndex,
1385
+ dataBlock,
1386
+ status: $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING,
1387
+ progress: 0,
1388
+ retries: 0
1389
+ };
1390
+ this._uploadData(files, [
1391
+ dataBlock
1392
+ ]);
1393
+ };
1394
+ file.upload.finishedChunkUpload = (chunk, response) => {
1395
+ let allFinished = true;
1396
+ chunk.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.SUCCESS;
1397
+ chunk.dataBlock = null;
1398
+ chunk.response = chunk.xhr.responseText;
1399
+ chunk.responseHeaders = chunk.xhr.getAllResponseHeaders();
1400
+ chunk.xhr = null;
1401
+ for (let i = 0; i < file.upload.totalChunkCount; i++) {
1402
+ if (file.upload.chunks[i] === void 0) return handleNextChunk();
1403
+ if (file.upload.chunks[i].status !== $3ed269f2f0fb224b$export$2e2bcd8739ae039.SUCCESS) allFinished = false;
1404
+ }
1405
+ if (allFinished) this.options.chunksUploaded(file, () => {
1406
+ this._finished(files, response, null);
1407
+ });
1408
+ };
1409
+ if (this.options.parallelChunkUploads) for (let i = 0; i < file.upload.totalChunkCount; i++) handleNextChunk();
1410
+ else handleNextChunk();
1411
+ } else {
1412
+ let dataBlocks = [];
1413
+ for (let i = 0; i < files.length; i++) dataBlocks[i] = {
1414
+ name: this._getParamName(i),
1415
+ data: transformedFiles[i],
1416
+ filename: files[i].upload.filename
1417
+ };
1418
+ this._uploadData(files, dataBlocks);
1419
+ }
1420
+ });
1421
+ }
1422
+ /// Returns the right chunk for given file and xhr
1423
+ _getChunk(file, xhr) {
1424
+ for (let i = 0; i < file.upload.totalChunkCount; i++) {
1425
+ if (file.upload.chunks[i] !== void 0 && file.upload.chunks[i].xhr === xhr) return file.upload.chunks[i];
1426
+ }
1427
+ }
1428
+ // This function actually uploads the file(s) to the server.
1429
+ //
1430
+ // If dataBlocks contains the actual data to upload (meaning, that this could
1431
+ // either be transformed files, or individual chunks for chunked upload) then
1432
+ // they will be used for the actual data to upload.
1433
+ _uploadData(files, dataBlocks) {
1434
+ let xhr = new XMLHttpRequest();
1435
+ for (let file of files) file.xhr = xhr;
1436
+ if (files[0].upload.chunked)
1437
+ files[0].upload.chunks[dataBlocks[0].chunkIndex].xhr = xhr;
1438
+ let method = this.resolveOption(this.options.method, files, dataBlocks);
1439
+ let url = this.resolveOption(this.options.url, files, dataBlocks);
1440
+ xhr.open(method, url, true);
1441
+ let timeout = this.resolveOption(this.options.timeout, files);
1442
+ if (timeout) xhr.timeout = this.resolveOption(this.options.timeout, files);
1443
+ xhr.withCredentials = !!this.options.withCredentials;
1444
+ xhr.onload = (e) => {
1445
+ this._finishedUploading(files, xhr, e);
1446
+ };
1447
+ xhr.ontimeout = () => {
1448
+ this._handleUploadError(files, xhr, `Request timedout after ${this.options.timeout / 1e3} seconds`);
1449
+ };
1450
+ xhr.onerror = () => {
1451
+ this._handleUploadError(files, xhr);
1452
+ };
1453
+ let progressObj = xhr.upload != null ? xhr.upload : xhr;
1454
+ progressObj.onprogress = (e) => this._updateFilesUploadProgress(files, xhr, e);
1455
+ let headers = this.options.defaultHeaders ? {
1456
+ Accept: "application/json",
1457
+ "Cache-Control": "no-cache",
1458
+ "X-Requested-With": "XMLHttpRequest"
1459
+ } : {};
1460
+ if (this.options.binaryBody) headers["Content-Type"] = files[0].type;
1461
+ if (this.options.headers) objectExtend(headers, this.options.headers);
1462
+ for (let headerName in headers) {
1463
+ let headerValue = headers[headerName];
1464
+ if (headerValue) xhr.setRequestHeader(headerName, headerValue);
1465
+ }
1466
+ if (this.options.binaryBody) {
1467
+ for (let file of files) this.emit("sending", file, xhr);
1468
+ if (this.options.uploadMultiple) this.emit("sendingmultiple", files, xhr);
1469
+ this.submitRequest(xhr, null, files);
1470
+ } else {
1471
+ let formData = new FormData();
1472
+ if (this.options.params) {
1473
+ let additionalParams = this.options.params;
1474
+ if (typeof additionalParams === "function") additionalParams = additionalParams.call(this, files, xhr, files[0].upload.chunked ? this._getChunk(files[0], xhr) : null);
1475
+ for (let key in additionalParams) {
1476
+ let value = additionalParams[key];
1477
+ if (Array.isArray(value))
1478
+ for (let i = 0; i < value.length; i++) formData.append(key, value[i]);
1479
+ else formData.append(key, value);
1480
+ }
1481
+ }
1482
+ for (let file of files) this.emit("sending", file, xhr, formData);
1483
+ if (this.options.uploadMultiple) this.emit("sendingmultiple", files, xhr, formData);
1484
+ this._addFormElementData(formData);
1485
+ for (let i = 0; i < dataBlocks.length; i++) {
1486
+ let dataBlock = dataBlocks[i];
1487
+ formData.append(dataBlock.name, dataBlock.data, dataBlock.filename);
1488
+ }
1489
+ this.submitRequest(xhr, formData, files);
1490
+ }
1491
+ }
1492
+ // Transforms all files with this.options.transformFile and invokes done with the transformed files when done.
1493
+ _transformFiles(files, done) {
1494
+ let transformedFiles = [];
1495
+ let doneCounter = 0;
1496
+ for (let i = 0; i < files.length; i++) this.options.transformFile.call(this, files[i], (transformedFile) => {
1497
+ transformedFiles[i] = transformedFile;
1498
+ if (++doneCounter === files.length) done(transformedFiles);
1499
+ });
1500
+ }
1501
+ // Takes care of adding other input elements of the form to the AJAX request
1502
+ _addFormElementData(formData) {
1503
+ if (this.element.tagName === "FORM") for (let input of this.element.querySelectorAll("input, textarea, select, button")) {
1504
+ let inputName = input.getAttribute("name");
1505
+ let inputType = input.getAttribute("type");
1506
+ if (inputType) inputType = inputType.toLowerCase();
1507
+ if (typeof inputName === "undefined" || inputName === null) continue;
1508
+ if (input.tagName === "SELECT" && input.hasAttribute("multiple")) {
1509
+ for (let option of input.options) if (option.selected) formData.append(inputName, option.value);
1510
+ } else if (!inputType || inputType !== "checkbox" && inputType !== "radio" || input.checked) formData.append(inputName, input.value);
1511
+ }
1512
+ }
1513
+ // Invoked when there is new progress information about given files.
1514
+ // If e is not provided, it is assumed that the upload is finished.
1515
+ _updateFilesUploadProgress(files, xhr, e) {
1516
+ if (!files[0].upload.chunked)
1517
+ for (let file of files) {
1518
+ if (file.upload.total && file.upload.bytesSent && file.upload.bytesSent == file.upload.total) continue;
1519
+ if (e) {
1520
+ file.upload.progress = 100 * e.loaded / e.total;
1521
+ file.upload.total = e.total;
1522
+ file.upload.bytesSent = e.loaded;
1523
+ } else {
1524
+ file.upload.progress = 100;
1525
+ file.upload.bytesSent = file.upload.total;
1526
+ }
1527
+ this.emit("uploadprogress", file, file.upload.progress, file.upload.bytesSent);
1528
+ }
1529
+ else {
1530
+ let file = files[0];
1531
+ let chunk = this._getChunk(file, xhr);
1532
+ if (e) {
1533
+ chunk.progress = 100 * e.loaded / e.total;
1534
+ chunk.total = e.total;
1535
+ chunk.bytesSent = e.loaded;
1536
+ } else {
1537
+ chunk.progress = 100;
1538
+ chunk.bytesSent = chunk.total;
1539
+ }
1540
+ file.upload.progress = 0;
1541
+ file.upload.total = 0;
1542
+ file.upload.bytesSent = 0;
1543
+ for (let i = 0; i < file.upload.totalChunkCount; i++) if (file.upload.chunks[i] && typeof file.upload.chunks[i].progress !== "undefined") {
1544
+ file.upload.progress += file.upload.chunks[i].progress;
1545
+ file.upload.total += file.upload.chunks[i].total;
1546
+ file.upload.bytesSent += file.upload.chunks[i].bytesSent;
1547
+ }
1548
+ file.upload.progress = file.upload.progress / file.upload.totalChunkCount;
1549
+ this.emit("uploadprogress", file, file.upload.progress, file.upload.bytesSent);
1550
+ }
1551
+ }
1552
+ _finishedUploading(files, xhr, e) {
1553
+ let response;
1554
+ if (files[0].status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.CANCELED) return;
1555
+ if (xhr.readyState !== 4) return;
1556
+ if (xhr.responseType !== "arraybuffer" && xhr.responseType !== "blob") {
1557
+ response = xhr.responseText;
1558
+ if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) try {
1559
+ response = JSON.parse(response);
1560
+ } catch (error) {
1561
+ e = error;
1562
+ response = "Invalid JSON response from server.";
1563
+ }
1564
+ }
1565
+ this._updateFilesUploadProgress(files, xhr);
1566
+ if (!(200 <= xhr.status && xhr.status < 300)) this._handleUploadError(files, xhr, response);
1567
+ else if (files[0].upload.chunked) files[0].upload.finishedChunkUpload(this._getChunk(files[0], xhr), response);
1568
+ else this._finished(files, response, e);
1569
+ }
1570
+ _handleUploadError(files, xhr, response) {
1571
+ if (files[0].status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.CANCELED) return;
1572
+ if (files[0].upload.chunked && this.options.retryChunks) {
1573
+ let chunk = this._getChunk(files[0], xhr);
1574
+ if (chunk.retries++ < this.options.retryChunksLimit) {
1575
+ this._uploadData(files, [
1576
+ chunk.dataBlock
1577
+ ]);
1578
+ return;
1579
+ } else console.warn("Retried this chunk too often. Giving up.");
1580
+ }
1581
+ this._errorProcessing(files, response || this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr);
1582
+ }
1583
+ submitRequest(xhr, formData, files) {
1584
+ if (xhr.readyState != 1) {
1585
+ console.warn("Cannot send this request because the XMLHttpRequest.readyState is not OPENED.");
1586
+ return;
1587
+ }
1588
+ if (this.options.binaryBody) {
1589
+ if (files[0].upload.chunked) {
1590
+ const chunk = this._getChunk(files[0], xhr);
1591
+ xhr.send(chunk.dataBlock.data);
1592
+ } else xhr.send(files[0]);
1593
+ } else xhr.send(formData);
1594
+ }
1595
+ // Called internally when processing is finished.
1596
+ // Individual callbacks have to be called in the appropriate sections.
1597
+ _finished(files, responseText, e) {
1598
+ for (let file of files) {
1599
+ file.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.SUCCESS;
1600
+ this.emit("success", file, responseText, e);
1601
+ this.emit("complete", file);
1602
+ }
1603
+ if (this.options.uploadMultiple) {
1604
+ this.emit("successmultiple", files, responseText, e);
1605
+ this.emit("completemultiple", files);
1606
+ }
1607
+ if (this.options.autoProcessQueue) return this.processQueue();
1608
+ }
1609
+ // Called internally when processing is finished.
1610
+ // Individual callbacks have to be called in the appropriate sections.
1611
+ _errorProcessing(files, message, xhr) {
1612
+ for (let file of files) {
1613
+ file.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.ERROR;
1614
+ this.emit("error", file, message, xhr);
1615
+ this.emit("complete", file);
1616
+ }
1617
+ if (this.options.uploadMultiple) {
1618
+ this.emit("errormultiple", files, message, xhr);
1619
+ this.emit("completemultiple", files);
1620
+ }
1621
+ if (this.options.autoProcessQueue) return this.processQueue();
1622
+ }
1623
+ static uuidv4() {
1624
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1625
+ let r = Math.random() * 16 | 0, v = c === "x" ? r : r & 3 | 8;
1626
+ return v.toString(16);
1627
+ });
1628
+ }
1629
+ constructor(el, options) {
1630
+ super();
1631
+ let fallback, left;
1632
+ this.element = el;
1633
+ this.clickableElements = [];
1634
+ this.listeners = [];
1635
+ this.files = [];
1636
+ if (typeof this.element === "string") this.element = document.querySelector(this.element);
1637
+ if (!this.element || this.element.nodeType == null) throw new Error("Invalid dropzone element.");
1638
+ if (this.element.dropzone) throw new Error("Dropzone already attached.");
1639
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.instances.push(this);
1640
+ this.element.dropzone = this;
1641
+ let elementOptions = (left = $3ed269f2f0fb224b$export$2e2bcd8739ae039.optionsForElement(this.element)) != null ? left : {};
1642
+ this.options = objectExtend(true, {}, $4ca367182776f80b$export$2e2bcd8739ae039, elementOptions, options != null ? options : {});
1643
+ this.options.previewTemplate = this.options.previewTemplate.replace(/\n*/g, "");
1644
+ if (this.options.forceFallback || !$3ed269f2f0fb224b$export$2e2bcd8739ae039.isBrowserSupported()) return this.options.fallback.call(this);
1645
+ if (this.options.url == null) this.options.url = this.element.getAttribute("action");
1646
+ if (!this.options.url) throw new Error("No URL provided.");
1647
+ if (this.options.acceptedFiles && this.options.acceptedMimeTypes) throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");
1648
+ if (this.options.uploadMultiple && this.options.chunking) throw new Error("You cannot set both: uploadMultiple and chunking.");
1649
+ if (this.options.binaryBody && this.options.uploadMultiple) throw new Error("You cannot set both: binaryBody and uploadMultiple.");
1650
+ if (this.options.acceptedMimeTypes) {
1651
+ this.options.acceptedFiles = this.options.acceptedMimeTypes;
1652
+ delete this.options.acceptedMimeTypes;
1653
+ }
1654
+ if (this.options.renameFilename != null) this.options.renameFile = (file) => this.options.renameFilename.call(this, file.name, file);
1655
+ if (typeof this.options.method === "string") this.options.method = this.options.method.toUpperCase();
1656
+ if ((fallback = this.getExistingFallback()) && fallback.parentNode)
1657
+ fallback.parentNode.removeChild(fallback);
1658
+ if (this.options.previewsContainer !== false) {
1659
+ if (this.options.previewsContainer) this.previewsContainer = $3ed269f2f0fb224b$export$2e2bcd8739ae039.getElement(this.options.previewsContainer, "previewsContainer");
1660
+ else this.previewsContainer = this.element;
1661
+ }
1662
+ if (this.options.clickable) {
1663
+ if (this.options.clickable === true) this.clickableElements = [
1664
+ this.element
1665
+ ];
1666
+ else this.clickableElements = $3ed269f2f0fb224b$export$2e2bcd8739ae039.getElements(this.options.clickable, "clickable");
1667
+ }
1668
+ this.init();
1669
+ }
1670
+ }
1671
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.initClass();
1672
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.options = {};
1673
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.optionsForElement = function(element) {
1674
+ if (element.getAttribute("id")) return $3ed269f2f0fb224b$export$2e2bcd8739ae039.options[$3ed269f2f0fb224b$var$camelize(element.getAttribute("id"))];
1675
+ else return void 0;
1676
+ };
1677
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.instances = [];
1678
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.forElement = function(element) {
1679
+ if (typeof element === "string") element = document.querySelector(element);
1680
+ if ((element != null ? element.dropzone : void 0) == null) throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");
1681
+ return element.dropzone;
1682
+ };
1683
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.discover = function() {
1684
+ let dropzones;
1685
+ if (document.querySelectorAll) dropzones = document.querySelectorAll(".dropzone");
1686
+ else {
1687
+ dropzones = [];
1688
+ let checkElements = (elements) => (() => {
1689
+ let result = [];
1690
+ for (let el of elements) if (/(^| )dropzone($| )/.test(el.className)) result.push(dropzones.push(el));
1691
+ else result.push(void 0);
1692
+ return result;
1693
+ })();
1694
+ checkElements(document.getElementsByTagName("div"));
1695
+ checkElements(document.getElementsByTagName("form"));
1696
+ }
1697
+ return (() => {
1698
+ let result = [];
1699
+ for (let dropzone of dropzones)
1700
+ if ($3ed269f2f0fb224b$export$2e2bcd8739ae039.optionsForElement(dropzone) !== false) result.push(new $3ed269f2f0fb224b$export$2e2bcd8739ae039(dropzone));
1701
+ else result.push(void 0);
1702
+ return result;
1703
+ })();
1704
+ };
1705
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.blockedBrowsers = [
1706
+ // The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API.
1707
+ /opera.*(Macintosh|Windows Phone).*version\/12/i
1708
+ ];
1709
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.isBrowserSupported = function() {
1710
+ let capableBrowser = true;
1711
+ if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
1712
+ if (!("classList" in document.createElement("a"))) capableBrowser = false;
1713
+ else {
1714
+ if ($3ed269f2f0fb224b$export$2e2bcd8739ae039.blacklistedBrowsers !== void 0)
1715
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.blockedBrowsers = $3ed269f2f0fb224b$export$2e2bcd8739ae039.blacklistedBrowsers;
1716
+ for (let regex of $3ed269f2f0fb224b$export$2e2bcd8739ae039.blockedBrowsers) if (regex.test(navigator.userAgent)) {
1717
+ capableBrowser = false;
1718
+ continue;
1719
+ }
1720
+ }
1721
+ } else capableBrowser = false;
1722
+ return capableBrowser;
1723
+ };
1724
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.dataURItoBlob = function(dataURI) {
1725
+ let byteString = atob(dataURI.split(",")[1]);
1726
+ let mimeString = dataURI.split(",")[0].split(":")[1].split(";")[0];
1727
+ let ab = new ArrayBuffer(byteString.length);
1728
+ let ia = new Uint8Array(ab);
1729
+ for (let i = 0, end = byteString.length, asc = 0 <= end; asc ? i <= end : i >= end; asc ? i++ : i--) ia[i] = byteString.charCodeAt(i);
1730
+ return new Blob([
1731
+ ab
1732
+ ], {
1733
+ type: mimeString
1734
+ });
1735
+ };
1736
+ const $3ed269f2f0fb224b$var$without = (list, rejectedItem) => list.filter(
1737
+ (item) => item !== rejectedItem
1738
+ ).map(
1739
+ (item) => item
1740
+ );
1741
+ const $3ed269f2f0fb224b$var$camelize = (str) => str.replace(
1742
+ /[\-_](\w)/g,
1743
+ (match) => match.charAt(1).toUpperCase()
1744
+ );
1745
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.createElement = function(string) {
1746
+ let div = document.createElement("div");
1747
+ div.innerHTML = string;
1748
+ return div.childNodes[0];
1749
+ };
1750
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.elementInside = function(element, container) {
1751
+ if (element === container) return true;
1752
+ while (element = element.parentNode) {
1753
+ if (element === container) return true;
1754
+ }
1755
+ return false;
1756
+ };
1757
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.getElement = function(el, name) {
1758
+ let element;
1759
+ if (typeof el === "string") element = document.querySelector(el);
1760
+ else if (el.nodeType != null) element = el;
1761
+ if (element == null) throw new Error(`Invalid \`${name}\` option provided. Please provide a CSS selector or a plain HTML element.`);
1762
+ return element;
1763
+ };
1764
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.getElements = function(els, name) {
1765
+ let el, elements;
1766
+ if (els instanceof Array) {
1767
+ elements = [];
1768
+ try {
1769
+ for (el of els) elements.push(this.getElement(el, name));
1770
+ } catch (e) {
1771
+ elements = null;
1772
+ }
1773
+ } else if (typeof els === "string") {
1774
+ elements = [];
1775
+ for (el of document.querySelectorAll(els)) elements.push(el);
1776
+ } else if (els.nodeType != null) elements = [
1777
+ els
1778
+ ];
1779
+ if (elements == null || !elements.length) throw new Error(`Invalid \`${name}\` option provided. Please provide a CSS selector, a plain HTML element or a list of those.`);
1780
+ return elements;
1781
+ };
1782
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.confirm = function(question, accepted, rejected) {
1783
+ if (window.confirm(question)) return accepted();
1784
+ else if (rejected != null) return rejected();
1785
+ };
1786
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.isValidFile = function(file, acceptedFiles) {
1787
+ if (!acceptedFiles) return true;
1788
+ acceptedFiles = acceptedFiles.split(",");
1789
+ let mimeType = file.type;
1790
+ let baseMimeType = mimeType.replace(/\/.*$/, "");
1791
+ for (let validType of acceptedFiles) {
1792
+ validType = validType.trim();
1793
+ if (validType.charAt(0) === ".") {
1794
+ if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) return true;
1795
+ } else if (/\/\*$/.test(validType)) {
1796
+ if (baseMimeType === validType.replace(/\/.*$/, "")) return true;
1797
+ } else {
1798
+ if (mimeType === validType) return true;
1799
+ }
1800
+ }
1801
+ return false;
1802
+ };
1803
+ if (typeof jQuery !== "undefined" && jQuery !== null) jQuery.fn.dropzone = function(options) {
1804
+ return this.each(function() {
1805
+ return new $3ed269f2f0fb224b$export$2e2bcd8739ae039(this, options);
1806
+ });
1807
+ };
1808
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.ADDED = "added";
1809
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.QUEUED = "queued";
1810
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.ACCEPTED = $3ed269f2f0fb224b$export$2e2bcd8739ae039.QUEUED;
1811
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING = "uploading";
1812
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.PROCESSING = $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING;
1813
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.CANCELED = "canceled";
1814
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.ERROR = "error";
1815
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039.SUCCESS = "success";
1816
+ let $3ed269f2f0fb224b$var$detectVerticalSquash = function(img) {
1817
+ img.naturalWidth;
1818
+ let ih = img.naturalHeight;
1819
+ let canvas = document.createElement("canvas");
1820
+ canvas.width = 1;
1821
+ canvas.height = ih;
1822
+ let ctx = canvas.getContext("2d");
1823
+ ctx.drawImage(img, 0, 0);
1824
+ let { data } = ctx.getImageData(1, 0, 1, ih);
1825
+ let sy = 0;
1826
+ let ey = ih;
1827
+ let py = ih;
1828
+ while (py > sy) {
1829
+ let alpha = data[(py - 1) * 4 + 3];
1830
+ if (alpha === 0) ey = py;
1831
+ else sy = py;
1832
+ py = ey + sy >> 1;
1833
+ }
1834
+ let ratio = py / ih;
1835
+ if (ratio === 0) return 1;
1836
+ else return ratio;
1837
+ };
1838
+ var $3ed269f2f0fb224b$var$drawImageIOSFix = function(ctx, img, sx, sy, sw, sh, dx, dy, dw, dh) {
1839
+ let vertSquashRatio = $3ed269f2f0fb224b$var$detectVerticalSquash(img);
1840
+ return ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio);
1841
+ };
1842
+ class $3ed269f2f0fb224b$var$ExifRestore {
1843
+ static initClass() {
1844
+ this.KEY_STR = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
1845
+ }
1846
+ static encode64(input) {
1847
+ let output = "";
1848
+ let chr1 = void 0;
1849
+ let chr2 = void 0;
1850
+ let chr3 = "";
1851
+ let enc1 = void 0;
1852
+ let enc2 = void 0;
1853
+ let enc3 = void 0;
1854
+ let enc4 = "";
1855
+ let i = 0;
1856
+ while (true) {
1857
+ chr1 = input[i++];
1858
+ chr2 = input[i++];
1859
+ chr3 = input[i++];
1860
+ enc1 = chr1 >> 2;
1861
+ enc2 = (chr1 & 3) << 4 | chr2 >> 4;
1862
+ enc3 = (chr2 & 15) << 2 | chr3 >> 6;
1863
+ enc4 = chr3 & 63;
1864
+ if (isNaN(chr2)) enc3 = enc4 = 64;
1865
+ else if (isNaN(chr3)) enc4 = 64;
1866
+ output = output + this.KEY_STR.charAt(enc1) + this.KEY_STR.charAt(enc2) + this.KEY_STR.charAt(enc3) + this.KEY_STR.charAt(enc4);
1867
+ chr1 = chr2 = chr3 = "";
1868
+ enc1 = enc2 = enc3 = enc4 = "";
1869
+ if (!(i < input.length)) break;
1870
+ }
1871
+ return output;
1872
+ }
1873
+ static restore(origFileBase64, resizedFileBase64) {
1874
+ if (!origFileBase64.match("data:image/jpeg;base64,")) return resizedFileBase64;
1875
+ let rawImage = this.decode64(origFileBase64.replace("data:image/jpeg;base64,", ""));
1876
+ let segments = this.slice2Segments(rawImage);
1877
+ let image = this.exifManipulation(resizedFileBase64, segments);
1878
+ return `data:image/jpeg;base64,${this.encode64(image)}`;
1879
+ }
1880
+ static exifManipulation(resizedFileBase64, segments) {
1881
+ let exifArray = this.getExifArray(segments);
1882
+ let newImageArray = this.insertExif(resizedFileBase64, exifArray);
1883
+ let aBuffer = new Uint8Array(newImageArray);
1884
+ return aBuffer;
1885
+ }
1886
+ static getExifArray(segments) {
1887
+ let seg = void 0;
1888
+ let x = 0;
1889
+ while (x < segments.length) {
1890
+ seg = segments[x];
1891
+ if (seg[0] === 255 & seg[1] === 225) return seg;
1892
+ x++;
1893
+ }
1894
+ return [];
1895
+ }
1896
+ static insertExif(resizedFileBase64, exifArray) {
1897
+ let imageData = resizedFileBase64.replace("data:image/jpeg;base64,", "");
1898
+ let buf = this.decode64(imageData);
1899
+ let separatePoint = buf.indexOf(255, 3);
1900
+ let mae = buf.slice(0, separatePoint);
1901
+ let ato = buf.slice(separatePoint);
1902
+ let array = mae;
1903
+ array = array.concat(exifArray);
1904
+ array = array.concat(ato);
1905
+ return array;
1906
+ }
1907
+ static slice2Segments(rawImageArray) {
1908
+ let head = 0;
1909
+ let segments = [];
1910
+ while (true) {
1911
+ var length;
1912
+ if (rawImageArray[head] === 255 & rawImageArray[head + 1] === 218) break;
1913
+ if (rawImageArray[head] === 255 & rawImageArray[head + 1] === 216) head += 2;
1914
+ else {
1915
+ length = rawImageArray[head + 2] * 256 + rawImageArray[head + 3];
1916
+ let endPoint = head + length + 2;
1917
+ let seg = rawImageArray.slice(head, endPoint);
1918
+ segments.push(seg);
1919
+ head = endPoint;
1920
+ }
1921
+ if (head > rawImageArray.length) break;
1922
+ }
1923
+ return segments;
1924
+ }
1925
+ static decode64(input) {
1926
+ let chr1 = void 0;
1927
+ let chr2 = void 0;
1928
+ let chr3 = "";
1929
+ let enc1 = void 0;
1930
+ let enc2 = void 0;
1931
+ let enc3 = void 0;
1932
+ let enc4 = "";
1933
+ let i = 0;
1934
+ let buf = [];
1935
+ let base64test = /[^A-Za-z0-9\+\/\=]/g;
1936
+ if (base64test.exec(input)) console.warn("There were invalid base64 characters in the input text.\nValid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\nExpect errors in decoding.");
1937
+ input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
1938
+ while (true) {
1939
+ enc1 = this.KEY_STR.indexOf(input.charAt(i++));
1940
+ enc2 = this.KEY_STR.indexOf(input.charAt(i++));
1941
+ enc3 = this.KEY_STR.indexOf(input.charAt(i++));
1942
+ enc4 = this.KEY_STR.indexOf(input.charAt(i++));
1943
+ chr1 = enc1 << 2 | enc2 >> 4;
1944
+ chr2 = (enc2 & 15) << 4 | enc3 >> 2;
1945
+ chr3 = (enc3 & 3) << 6 | enc4;
1946
+ buf.push(chr1);
1947
+ if (enc3 !== 64) buf.push(chr2);
1948
+ if (enc4 !== 64) buf.push(chr3);
1949
+ chr1 = chr2 = chr3 = "";
1950
+ enc1 = enc2 = enc3 = enc4 = "";
1951
+ if (!(i < input.length)) break;
1952
+ }
1953
+ return buf;
1954
+ }
1955
+ }
1956
+ $3ed269f2f0fb224b$var$ExifRestore.initClass();
1957
+ function $3ed269f2f0fb224b$var$__guard__(value, transform) {
1958
+ return typeof value !== "undefined" && value !== null ? transform(value) : void 0;
1959
+ }
1960
+ function $3ed269f2f0fb224b$var$__guardMethod__(obj, methodName, transform) {
1961
+ if (typeof obj !== "undefined" && obj !== null && typeof obj[methodName] === "function") return transform(obj, methodName);
1962
+ else return void 0;
1963
+ }
1964
+ export {
1965
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039 as Dropzone,
1966
+ $3ed269f2f0fb224b$export$2e2bcd8739ae039 as default
1967
+ };
1968
+ //# sourceMappingURL=dropzone.js.map