OXYGENHUB
# 6246d1e51f4f oxygenhub / assets / backdrop / backdrop.js
26.2 KiB · JavaScript · last changed feat(web): the mark, ripples, the swarm and adrift (closes #167) 23 days ago source blame history raw
1
/**
2
 * Start a backdrop on `canvas` with the page's `data`: the scene it names
3
 * (docs/backgrounds.md §2), the dashboard's sky by default. `still`
4
 * is the viewer's choice of a still backdrop; reduced motion asks for
5
 * one too. Without WebGL2 there is no backdrop, and nothing breaks.
6
 * @param {HTMLCanvasElement} canvas
7
 * @param {any} data
8
 * @param {boolean} still
9
 */
10
export function start(canvas, data, still) {
11
    const ret = wasm.start(canvas, data, still);
12
    if (ret[1]) {
13
        throw takeFromExternrefTable0(ret[0]);
14
    }
15
}
16
function __wbg_get_imports() {
17
    const import0 = {
18
        __proto__: null,
19
        __wbg___wbindgen_boolean_get_5b446f51afd21013: function(arg0) {
20
            const v = arg0;
21
            const ret = typeof(v) === 'boolean' ? v : undefined;
22
            return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
23
        },
24
        __wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
25
            const ret = arg0 === undefined;
26
            return ret;
27
        },
28
        __wbg___wbindgen_number_get_2e0e7dee9f701a71: function(arg0, arg1) {
29
            const obj = arg1;
30
            const ret = typeof(obj) === 'number' ? obj : undefined;
31
            getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
32
            getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
33
        },
34
        __wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
35
            const obj = arg1;
36
            const ret = typeof(obj) === 'string' ? obj : undefined;
37
            var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
38
            var len1 = WASM_VECTOR_LEN;
39
            getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
40
            getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
41
        },
42
        __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
43
            throw new Error(getStringFromWasm0(arg0, arg1));
44
        },
45
        __wbg__wbg_cb_unref_dcc1a90847f04c41: function(arg0) {
46
            arg0._wbg_cb_unref();
47
        },
48
        __wbg_addEventListener_4d0db17c671ea324: function() { return handleError(function (arg0, arg1, arg2, arg3) {
49
            arg0.addEventListener(getStringFromWasm0(arg1, arg2), arg3);
50
        }, arguments); },
51
        __wbg_appendChild_fb8c52e7dd8484ea: function() { return handleError(function (arg0, arg1) {
52
            const ret = arg0.appendChild(arg1);
53
            return ret;
54
        }, arguments); },
55
        __wbg_attachShader_9567ae57af6746d5: function(arg0, arg1, arg2) {
56
            arg0.attachShader(arg1, arg2);
57
        },
58
        __wbg_bindBuffer_0324f62b876c4403: function(arg0, arg1, arg2) {
59
            arg0.bindBuffer(arg1 >>> 0, arg2);
60
        },
61
        __wbg_bindVertexArray_f58af0a346185ec5: function(arg0, arg1) {
62
            arg0.bindVertexArray(arg1);
63
        },
64
        __wbg_blendFunc_589e4252bb396484: function(arg0, arg1, arg2) {
65
            arg0.blendFunc(arg1 >>> 0, arg2 >>> 0);
66
        },
67
        __wbg_body_e549239eaff082e1: function(arg0) {
68
            const ret = arg0.body;
69
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
70
        },
71
        __wbg_bufferData_5fa44d94fe7a3878: function(arg0, arg1, arg2, arg3) {
72
            arg0.bufferData(arg1 >>> 0, arg2, arg3 >>> 0);
73
        },
74
        __wbg_clearColor_796427e8ac60fe14: function(arg0, arg1, arg2, arg3, arg4) {
75
            arg0.clearColor(arg1, arg2, arg3, arg4);
76
        },
77
        __wbg_clear_cb96796cc568b7c8: function(arg0, arg1) {
78
            arg0.clear(arg1 >>> 0);
79
        },
80
        __wbg_clientX_5075231ed45e8ef5: function(arg0) {
81
            const ret = arg0.clientX;
82
            return ret;
83
        },
84
        __wbg_clientY_846c39814ce02ab2: function(arg0) {
85
            const ret = arg0.clientY;
86
            return ret;
87
        },
88
        __wbg_compileShader_c2b53ff3a8851f60: function(arg0, arg1) {
89
            arg0.compileShader(arg1);
90
        },
91
        __wbg_createBuffer_ffe613371d42cfd3: function(arg0) {
92
            const ret = arg0.createBuffer();
93
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
94
        },
95
        __wbg_createElement_74049073a11f9c31: function() { return handleError(function (arg0, arg1, arg2) {
96
            const ret = arg0.createElement(getStringFromWasm0(arg1, arg2));
97
            return ret;
98
        }, arguments); },
99
        __wbg_createProgram_cbf448e6f18a9402: function(arg0) {
100
            const ret = arg0.createProgram();
101
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
102
        },
103
        __wbg_createShader_6c1a2295587878a5: function(arg0, arg1) {
104
            const ret = arg0.createShader(arg1 >>> 0);
105
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
106
        },
107
        __wbg_createVertexArray_b223ea69dd08fcab: function(arg0) {
108
            const ret = arg0.createVertexArray();
109
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
110
        },
111
        __wbg_devicePixelRatio_7d39e9af5448d3d4: function(arg0) {
112
            const ret = arg0.devicePixelRatio;
113
            return ret;
114
        },
115
        __wbg_document_9854e03c05fc8834: function(arg0) {
116
            const ret = arg0.document;
117
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
118
        },
119
        __wbg_drawArraysInstanced_9b44aa78a087154d: function(arg0, arg1, arg2, arg3, arg4) {
120
            arg0.drawArraysInstanced(arg1 >>> 0, arg2, arg3, arg4);
121
        },
122
        __wbg_drawArrays_08872e02fb57b847: function(arg0, arg1, arg2, arg3) {
123
            arg0.drawArrays(arg1 >>> 0, arg2, arg3);
124
        },
125
        __wbg_enableVertexAttribArray_d52693866bc8b8dd: function(arg0, arg1) {
126
            arg0.enableVertexAttribArray(arg1 >>> 0);
127
        },
128
        __wbg_enable_cb4fc19b51148c37: function(arg0, arg1) {
129
            arg0.enable(arg1 >>> 0);
130
        },
131
        __wbg_from_296ca31f8d0f1c52: function(arg0) {
132
            const ret = Array.from(arg0);
133
            return ret;
134
        },
135
        __wbg_getBoundingClientRect_57152b1a20f3de34: function(arg0) {
136
            const ret = arg0.getBoundingClientRect();
137
            return ret;
138
        },
139
        __wbg_getComputedStyle_dd0f456804795fd6: function() { return handleError(function (arg0, arg1) {
140
            const ret = arg0.getComputedStyle(arg1);
141
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
142
        }, arguments); },
143
        __wbg_getContext_051324720aa5b7e8: function() { return handleError(function (arg0, arg1, arg2, arg3) {
144
            const ret = arg0.getContext(getStringFromWasm0(arg1, arg2), arg3);
145
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
146
        }, arguments); },
147
        __wbg_getProgramInfoLog_3276b294d6d42fe2: function(arg0, arg1, arg2) {
148
            const ret = arg1.getProgramInfoLog(arg2);
149
            var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
150
            var len1 = WASM_VECTOR_LEN;
151
            getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
152
            getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
153
        },
154
        __wbg_getProgramParameter_fc7124bb9fb7c675: function(arg0, arg1, arg2) {
155
            const ret = arg0.getProgramParameter(arg1, arg2 >>> 0);
156
            return ret;
157
        },
158
        __wbg_getPropertyValue_e90a3628c2de4fb6: function() { return handleError(function (arg0, arg1, arg2, arg3) {
159
            const ret = arg1.getPropertyValue(getStringFromWasm0(arg2, arg3));
160
            const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
161
            const len1 = WASM_VECTOR_LEN;
162
            getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
163
            getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
164
        }, arguments); },
165
        __wbg_getShaderInfoLog_7e0cbba353ca95da: function(arg0, arg1, arg2) {
166
            const ret = arg1.getShaderInfoLog(arg2);
167
            var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
168
            var len1 = WASM_VECTOR_LEN;
169
            getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
170
            getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
171
        },
172
        __wbg_getShaderParameter_745acf10b8e45e31: function(arg0, arg1, arg2) {
173
            const ret = arg0.getShaderParameter(arg1, arg2 >>> 0);
174
            return ret;
175
        },
176
        __wbg_getUniformLocation_50ba45dade572703: function(arg0, arg1, arg2, arg3) {
177
            const ret = arg0.getUniformLocation(arg1, getStringFromWasm0(arg2, arg3));
178
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
179
        },
180
        __wbg_get_31af05bd4842a84f: function() { return handleError(function (arg0, arg1) {
181
            const ret = Reflect.get(arg0, arg1);
182
            return ret;
183
        }, arguments); },
184
        __wbg_get_6c896e0571ddae51: function(arg0, arg1) {
185
            const ret = arg0[arg1 >>> 0];
186
            return ret;
187
        },
188
        __wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
189
            const ret = arg0[arg1 >>> 0];
190
            return ret;
191
        },
192
        __wbg_hidden_2ba371ecafe013fa: function(arg0) {
193
            const ret = arg0.hidden;
194
            return ret;
195
        },
196
        __wbg_innerHeight_7f20e0f1a7c5a573: function() { return handleError(function (arg0) {
197
            const ret = arg0.innerHeight;
198
            return ret;
199
        }, arguments); },
200
        __wbg_innerWidth_1bc526614080537c: function() { return handleError(function (arg0) {
201
            const ret = arg0.innerWidth;
202
            return ret;
203
        }, arguments); },
204
        __wbg_instanceof_HtmlElement_32fb153a5a0e2349: function(arg0) {
205
            let result;
206
            try {
207
                result = arg0 instanceof HTMLElement;
208
            } catch (_) {
209
                result = false;
210
            }
211
            const ret = result;
212
            return ret;
213
        },
214
        __wbg_instanceof_WebGl2RenderingContext_64c994c14c0790fb: function(arg0) {
215
            let result;
216
            try {
217
                result = arg0 instanceof WebGL2RenderingContext;
218
            } catch (_) {
219
                result = false;
220
            }
221
            const ret = result;
222
            return ret;
223
        },
224
        __wbg_instanceof_Window_82d71df4eddf88bc: function(arg0) {
225
            let result;
226
            try {
227
                result = arg0 instanceof Window;
228
            } catch (_) {
229
                result = false;
230
            }
231
            const ret = result;
232
            return ret;
233
        },
234
        __wbg_left_e0a244490fe2f293: function(arg0) {
235
            const ret = arg0.left;
236
            return ret;
237
        },
238
        __wbg_length_d4bdea10311bd9cf: function(arg0) {
239
            const ret = arg0.length;
240
            return ret;
241
        },
242
        __wbg_linkProgram_acdc299c43d734a0: function(arg0, arg1) {
243
            arg0.linkProgram(arg1);
244
        },
245
        __wbg_matchMedia_8a4857f947f11f82: function() { return handleError(function (arg0, arg1, arg2) {
246
            const ret = arg0.matchMedia(getStringFromWasm0(arg1, arg2));
247
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
248
        }, arguments); },
249
        __wbg_matches_778d0873b064b1bf: function(arg0) {
250
            const ret = arg0.matches;
251
            return ret;
252
        },
253
        __wbg_new_617a8cdb8bb1130e: function() {
254
            const ret = new Object();
255
            return ret;
256
        },
257
        __wbg_now_d0b7f4bea9f38490: function(arg0) {
258
            const ret = arg0.now();
259
            return ret;
260
        },
261
        __wbg_performance_d0d7b03fc649b694: function(arg0) {
262
            const ret = arg0.performance;
263
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
264
        },
265
        __wbg_querySelector_ecbc2550705b235f: function() { return handleError(function (arg0, arg1, arg2) {
266
            const ret = arg0.querySelector(getStringFromWasm0(arg1, arg2));
267
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
268
        }, arguments); },
269
        __wbg_relatedTarget_520fe88b1de28b43: function(arg0) {
270
            const ret = arg0.relatedTarget;
271
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
272
        },
273
        __wbg_requestAnimationFrame_7b526ab7aa550c74: function() { return handleError(function (arg0, arg1) {
274
            const ret = arg0.requestAnimationFrame(arg1);
275
            return ret;
276
        }, arguments); },
277
        __wbg_right_1dca6be6342de981: function(arg0) {
278
            const ret = arg0.right;
279
            return ret;
280
        },
281
        __wbg_setAttribute_9e7d603908f63705: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
282
            arg0.setAttribute(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
283
        }, arguments); },
284
        __wbg_setProperty_097bc3d55ce44513: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
285
            arg0.setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
286
        }, arguments); },
287
        __wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
288
            const ret = Reflect.set(arg0, arg1, arg2);
289
            return ret;
290
        }, arguments); },
291
        __wbg_set_className_541fce5cd31918aa: function(arg0, arg1, arg2) {
292
            arg0.className = getStringFromWasm0(arg1, arg2);
293
        },
294
        __wbg_set_height_c9789c1c77eaedff: function(arg0, arg1) {
295
            arg0.height = arg1 >>> 0;
296
        },
297
        __wbg_set_textContent_6d6fc559f198055f: function(arg0, arg1, arg2) {
298
            arg0.textContent = arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2);
299
        },
300
        __wbg_set_width_b0e1267db4b196b5: function(arg0, arg1) {
301
            arg0.width = arg1 >>> 0;
302
        },
303
        __wbg_shaderSource_c8812639b47d87b9: function(arg0, arg1, arg2, arg3) {
304
            arg0.shaderSource(arg1, getStringFromWasm0(arg2, arg3));
305
        },
306
        __wbg_static_accessor_GLOBAL_266715b9d96ba635: function() {
307
            const ret = typeof global === 'undefined' ? null : global;
308
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
309
        },
310
        __wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179: function() {
311
            const ret = typeof globalThis === 'undefined' ? null : globalThis;
312
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
313
        },
314
        __wbg_static_accessor_SELF_0b583911f537483a: function() {
315
            const ret = typeof self === 'undefined' ? null : self;
316
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
317
        },
318
        __wbg_static_accessor_WINDOW_d7f903d1508cbdc4: function() {
319
            const ret = typeof window === 'undefined' ? null : window;
320
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
321
        },
322
        __wbg_style_4bce24230e493a7c: function(arg0) {
323
            const ret = arg0.style;
324
            return ret;
325
        },
326
        __wbg_uniform2f_a92b5bb95dc5b4d9: function(arg0, arg1, arg2, arg3) {
327
            arg0.uniform2f(arg1, arg2, arg3);
328
        },
329
        __wbg_useProgram_e075c2902e420761: function(arg0, arg1) {
330
            arg0.useProgram(arg1);
331
        },
332
        __wbg_vertexAttribDivisor_7575d382215322f7: function(arg0, arg1, arg2) {
333
            arg0.vertexAttribDivisor(arg1 >>> 0, arg2 >>> 0);
334
        },
335
        __wbg_vertexAttribPointer_24b495e18df325dc: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
336
            arg0.vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6);
337
        },
338
        __wbg_viewport_16936692526e2ce6: function(arg0, arg1, arg2, arg3, arg4) {
339
            arg0.viewport(arg1, arg2, arg3, arg4);
340
        },
341
        __wbindgen_generic_0000000000000001: function(arg0, arg1) {
342
            // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [F64], shim_idx: 6, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
343
            const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke___f64______true_);
344
            return ret;
345
        },
346
        __wbindgen_generic_0000000000000002: function(arg0, arg1) {
347
            // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MouseEvent")], shim_idx: 5, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
348
            const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke___web_sys_793942649ef82f98___features__gen_MouseEvent__MouseEvent______true_);
349
            return ret;
350
        },
351
        __wbindgen_generic_0000000000000003: function(arg0, arg1) {
352
            // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 4, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
353
            const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke_______true_);
354
            return ret;
355
        },
356
        __wbindgen_generic_0000000000000004: function(arg0, arg1) {
357
            // Cast intrinsic for `Ref(Slice(F32)) -> NamedExternref("Float32Array")`.
358
            const ret = getArrayF32FromWasm0(arg0, arg1);
359
            return ret;
360
        },
361
        __wbindgen_generic_0000000000000005: function(arg0, arg1) {
362
            // Cast intrinsic for `Ref(String) -> Externref`.
363
            const ret = getStringFromWasm0(arg0, arg1);
364
            return ret;
365
        },
366
        __wbindgen_init_externref_table: function() {
367
            const table = wasm.__wbindgen_externrefs;
368
            const offset = table.grow(4);
369
            table.set(0, undefined);
370
            table.set(offset + 0, undefined);
371
            table.set(offset + 1, null);
372
            table.set(offset + 2, true);
373
            table.set(offset + 3, false);
374
        },
375
    };
376
    return {
377
        __proto__: null,
378
        "./backdrop_bg.js": import0,
379
    };
380
}
381
382
function wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke_______true_(arg0, arg1) {
383
    wasm.wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke_______true_(arg0, arg1);
384
}
385
386
function wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke___web_sys_793942649ef82f98___features__gen_MouseEvent__MouseEvent______true_(arg0, arg1, arg2) {
387
    wasm.wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke___web_sys_793942649ef82f98___features__gen_MouseEvent__MouseEvent______true_(arg0, arg1, arg2);
388
}
389
390
function wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke___f64______true_(arg0, arg1, arg2) {
391
    wasm.wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke___f64______true_(arg0, arg1, arg2);
392
}
393
394
function addToExternrefTable0(obj) {
395
    const idx = wasm.__externref_table_alloc();
396
    wasm.__wbindgen_externrefs.set(idx, obj);
397
    return idx;
398
}
399
400
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
401
    ? { register: () => {}, unregister: () => {} }
402
    : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
403
404
function getArrayF32FromWasm0(ptr, len) {
405
    ptr = ptr >>> 0;
406
    return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
407
}
408
409
let cachedDataViewMemory0 = null;
410
function getDataViewMemory0() {
411
    if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
412
        cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
413
    }
414
    return cachedDataViewMemory0;
415
}
416
417
let cachedFloat32ArrayMemory0 = null;
418
function getFloat32ArrayMemory0() {
419
    if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
420
        cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
421
    }
422
    return cachedFloat32ArrayMemory0;
423
}
424
425
function getStringFromWasm0(ptr, len) {
426
    return decodeText(ptr >>> 0, len);
427
}
428
429
let cachedUint8ArrayMemory0 = null;
430
function getUint8ArrayMemory0() {
431
    if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
432
        cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
433
    }
434
    return cachedUint8ArrayMemory0;
435
}
436
437
function handleError(f, args) {
438
    try {
439
        return f.apply(this, args);
440
    } catch (e) {
441
        const idx = addToExternrefTable0(e);
442
        wasm.__wbindgen_exn_store(idx);
443
    }
444
}
445
446
function isLikeNone(x) {
447
    return x === undefined || x === null;
448
}
449
450
function makeMutClosure(arg0, arg1, f) {
451
    const state = { a: arg0, b: arg1, cnt: 1 };
452
    const real = (...args) => {
453
454
        // First up with a closure we increment the internal reference
455
        // count. This ensures that the Rust closure environment won't
456
        // be deallocated while we're invoking it.
457
        state.cnt++;
458
        const a = state.a;
459
        state.a = 0;
460
        try {
461
            return f(a, state.b, ...args);
462
        } finally {
463
            state.a = a;
464
            real._wbg_cb_unref();
465
        }
466
    };
467
    real._wbg_cb_unref = () => {
468
        if (--state.cnt === 0) {
469
            wasm.__wbindgen_destroy_closure(state.a, state.b);
470
            state.a = 0;
471
            CLOSURE_DTORS.unregister(state);
472
        }
473
    };
474
    CLOSURE_DTORS.register(real, state, state);
475
    return real;
476
}
477
478
function passStringToWasm0(arg, malloc, realloc) {
479
    if (realloc === undefined) {
480
        const buf = cachedTextEncoder.encode(arg);
481
        const ptr = malloc(buf.length, 1) >>> 0;
482
        getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
483
        WASM_VECTOR_LEN = buf.length;
484
        return ptr;
485
    }
486
487
    let len = arg.length;
488
    let ptr = malloc(len, 1) >>> 0;
489
490
    const mem = getUint8ArrayMemory0();
491
492
    let offset = 0;
493
494
    for (; offset < len; offset++) {
495
        const code = arg.charCodeAt(offset);
496
        if (code > 0x7F) break;
497
        mem[ptr + offset] = code;
498
    }
499
    if (offset !== len) {
500
        if (offset !== 0) {
501
            arg = arg.slice(offset);
502
        }
503
        ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
504
        const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
505
        const ret = cachedTextEncoder.encodeInto(arg, view);
506
507
        offset += ret.written;
508
        ptr = realloc(ptr, len, offset, 1) >>> 0;
509
    }
510
511
    WASM_VECTOR_LEN = offset;
512
    return ptr;
513
}
514
515
function takeFromExternrefTable0(idx) {
516
    const value = wasm.__wbindgen_externrefs.get(idx);
517
    wasm.__externref_table_dealloc(idx);
518
    return value;
519
}
520
521
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
522
cachedTextDecoder.decode();
523
const MAX_SAFARI_DECODE_BYTES = 2146435072;
524
let numBytesDecoded = 0;
525
function decodeText(ptr, len) {
526
    numBytesDecoded += len;
527
    if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
528
        cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
529
        cachedTextDecoder.decode();
530
        numBytesDecoded = len;
531
    }
532
    return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
533
}
534
535
const cachedTextEncoder = new TextEncoder();
536
537
if (!('encodeInto' in cachedTextEncoder)) {
538
    cachedTextEncoder.encodeInto = function (arg, view) {
539
        const buf = cachedTextEncoder.encode(arg);
540
        view.set(buf);
541
        return {
542
            read: arg.length,
543
            written: buf.length
544
        };
545
    };
546
}
547
548
let WASM_VECTOR_LEN = 0;
549
550
let wasmModule, wasmInstance, wasm;
551
function __wbg_finalize_init(instance, module) {
552
    wasmInstance = instance;
553
    wasm = instance.exports;
554
    wasmModule = module;
555
    cachedDataViewMemory0 = null;
556
    cachedFloat32ArrayMemory0 = null;
557
    cachedUint8ArrayMemory0 = null;
558
    wasm.__wbindgen_start();
559
    return wasm;
560
}
561
562
async function __wbg_load(module, imports) {
563
    if (typeof Response === 'function' && module instanceof Response) {
564
        if (!module.ok) {
565
            throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
566
        }
567
568
        if (typeof WebAssembly.instantiateStreaming === 'function') {
569
            try {
570
                return await WebAssembly.instantiateStreaming(module, imports);
571
            } catch (e) {
572
                const validResponse = expectedResponseType(module.type);
573
574
                if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
575
                    console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
576
577
                } else { throw e; }
578
            }
579
        }
580
581
        const bytes = await module.arrayBuffer();
582
        return await WebAssembly.instantiate(bytes, imports);
583
    } else {
584
        const instance = await WebAssembly.instantiate(module, imports);
585
586
        if (instance instanceof WebAssembly.Instance) {
587
            return { instance, module };
588
        } else {
589
            return instance;
590
        }
591
    }
592
593
    function expectedResponseType(type) {
594
        switch (type) {
595
            case 'basic': case 'cors': case 'default': return true;
596
        }
597
        return false;
598
    }
599
}
600
601
function initSync(module) {
602
    if (wasm !== undefined) return wasm;
603
604
605
    if (module !== undefined) {
606
        if (Object.getPrototypeOf(module) === Object.prototype) {
607
            ({module} = module)
608
        } else {
609
            console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
610
        }
611
    }
612
613
    const imports = __wbg_get_imports();
614
    if (!(module instanceof WebAssembly.Module)) {
615
        module = new WebAssembly.Module(module);
616
    }
617
    const instance = new WebAssembly.Instance(module, imports);
618
    return __wbg_finalize_init(instance, module);
619
}
620
621
async function __wbg_init(module_or_path) {
622
    if (wasm !== undefined) return wasm;
623
624
625
    if (module_or_path !== undefined) {
626
        if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
627
            ({module_or_path} = module_or_path)
628
        } else {
629
            console.warn('using deprecated parameters for the initialization function; pass a single object instead')
630
        }
631
    }
632
633
    if (module_or_path === undefined) {
634
        module_or_path = new URL('backdrop_bg.wasm', import.meta.url);
635
    }
636
    const imports = __wbg_get_imports();
637
638
    if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
639
        module_or_path = fetch(module_or_path);
640
    }
641
642
    const { instance, module } = await __wbg_load(await module_or_path, imports);
643
644
    return __wbg_finalize_init(instance, module);
645
}
646
647
export { initSync, __wbg_init as default };