@hpcc-js/observablehq-compiler 3.4.0 → 3.5.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.
- package/dist/dot-DK4iDc2-.js +40 -0
- package/dist/dot-DK4iDc2-.js.map +1 -0
- package/dist/duckdb-DkM9_nXT.js +298 -0
- package/dist/duckdb-DkM9_nXT.js.map +1 -0
- package/dist/highlight-Bv8PkwN-.js +2402 -0
- package/dist/highlight-Bv8PkwN-.js.map +1 -0
- package/dist/index-B7vRtYlU.js +1807 -0
- package/dist/index-B7vRtYlU.js.map +1 -0
- package/dist/index-COHaJzee.js +260 -0
- package/dist/index-COHaJzee.js.map +1 -0
- package/dist/index-CP3HrqN0.js +1815 -0
- package/dist/index-CP3HrqN0.js.map +1 -0
- package/dist/index-D3TL70UM.js +163 -0
- package/dist/index-D3TL70UM.js.map +1 -0
- package/dist/index-DNwLE6Kk.js +198 -0
- package/dist/index-DNwLE6Kk.js.map +1 -0
- package/dist/index.js +4381 -4944
- package/dist/index.js.map +1 -1
- package/dist/inputs-CsCXZHQ8.js +3 -0
- package/dist/inputs-CsCXZHQ8.js.map +1 -0
- package/dist/leaflet-CkvVhxBL.js +9 -0
- package/dist/leaflet-CkvVhxBL.js.map +1 -0
- package/dist/mapboxgl-C0i2HzjJ.js +9 -0
- package/dist/mapboxgl-C0i2HzjJ.js.map +1 -0
- package/dist/md-Bxvu6Hld.js +7603 -0
- package/dist/md-Bxvu6Hld.js.map +1 -0
- package/dist/mermaid-CFg6sgdO.js +17 -0
- package/dist/mermaid-CFg6sgdO.js.map +1 -0
- package/dist/node/index.cjs +10 -6
- package/dist/node/index.cjs.map +4 -4
- package/dist/node/index.js +8 -4
- package/dist/node/index.js.map +4 -4
- package/dist/runtime.js +2501 -0
- package/dist/runtime.js.map +1 -0
- package/dist/tex-ayRXOMLZ.js +24 -0
- package/dist/tex-ayRXOMLZ.js.map +1 -0
- package/dist/vega-lite-CESXoehe.js +8 -0
- package/dist/vega-lite-CESXoehe.js.map +1 -0
- package/package.json +12 -10
- package/src/__package__.ts +2 -2
- package/src/compiler.ts +2 -16
- package/src/cst.ts +1 -2
- package/src/index.ts +2 -3
- package/src/kit/compiler.ts +41 -0
- package/src/kit/index.ts +3 -0
- package/src/kit/runtime.ts +57 -0
- package/src/kit/util.ts +157 -0
- package/src/util.ts +1 -134
- package/types/compiler.d.ts +1 -3
- package/types/index.d.ts +2 -2
- package/types/kit/compiler.d.ts +6 -0
- package/types/kit/index.d.ts +3 -0
- package/types/kit/runtime.d.ts +13 -0
- package/types/kit/util.d.ts +52 -0
- package/types/util.d.ts +1 -49
- package/dist/index.umd.cjs +0 -5
- package/dist/index.umd.cjs.map +0 -1
- package/dist/node/index.css +0 -2
- package/dist/node/index.css.map +0 -7
- package/src/index.css +0 -460
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,2501 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
var _a;
|
|
4
|
+
const _RuntimeError = class _RuntimeError extends Error {
|
|
5
|
+
constructor(message, input2) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.input = input2;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
__name(_RuntimeError, "RuntimeError");
|
|
11
|
+
let RuntimeError = _RuntimeError;
|
|
12
|
+
RuntimeError.prototype.name = "RuntimeError";
|
|
13
|
+
function generatorish(value) {
|
|
14
|
+
return value && typeof value.next === "function" && typeof value.return === "function";
|
|
15
|
+
}
|
|
16
|
+
__name(generatorish, "generatorish");
|
|
17
|
+
function constant(x) {
|
|
18
|
+
return () => x;
|
|
19
|
+
}
|
|
20
|
+
__name(constant, "constant");
|
|
21
|
+
function identity(x) {
|
|
22
|
+
return x;
|
|
23
|
+
}
|
|
24
|
+
__name(identity, "identity");
|
|
25
|
+
function rethrow(error) {
|
|
26
|
+
return () => {
|
|
27
|
+
throw error;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
__name(rethrow, "rethrow");
|
|
31
|
+
const prototype = Array.prototype;
|
|
32
|
+
const map = prototype.map;
|
|
33
|
+
function noop() {
|
|
34
|
+
}
|
|
35
|
+
__name(noop, "noop");
|
|
36
|
+
const TYPE_NORMAL = 1;
|
|
37
|
+
const TYPE_IMPLICIT = 2;
|
|
38
|
+
const TYPE_DUPLICATE = 3;
|
|
39
|
+
const no_observer = Symbol("no-observer");
|
|
40
|
+
const no_value = Promise.resolve();
|
|
41
|
+
function Variable(type, module, observer, options) {
|
|
42
|
+
if (!observer) observer = no_observer;
|
|
43
|
+
Object.defineProperties(this, {
|
|
44
|
+
_observer: { value: observer, writable: true },
|
|
45
|
+
_definition: { value: variable_undefined, writable: true },
|
|
46
|
+
_duplicate: { value: void 0, writable: true },
|
|
47
|
+
_duplicates: { value: void 0, writable: true },
|
|
48
|
+
_indegree: { value: NaN, writable: true },
|
|
49
|
+
// The number of computing inputs.
|
|
50
|
+
_inputs: { value: [], writable: true },
|
|
51
|
+
_invalidate: { value: noop, writable: true },
|
|
52
|
+
_module: { value: module },
|
|
53
|
+
_name: { value: null, writable: true },
|
|
54
|
+
_outputs: { value: /* @__PURE__ */ new Set(), writable: true },
|
|
55
|
+
_promise: { value: no_value, writable: true },
|
|
56
|
+
_reachable: { value: observer !== no_observer, writable: true },
|
|
57
|
+
// Is this variable transitively visible?
|
|
58
|
+
_rejector: { value: variable_rejector(this) },
|
|
59
|
+
_shadow: { value: initShadow(module, options) },
|
|
60
|
+
_type: { value: type },
|
|
61
|
+
_value: { value: void 0, writable: true },
|
|
62
|
+
_version: { value: 0, writable: true }
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
__name(Variable, "Variable");
|
|
66
|
+
Object.defineProperties(Variable.prototype, {
|
|
67
|
+
_pending: { value: variable_pending, writable: true, configurable: true },
|
|
68
|
+
_fulfilled: { value: variable_fulfilled, writable: true, configurable: true },
|
|
69
|
+
_rejected: { value: variable_rejected, writable: true, configurable: true },
|
|
70
|
+
_resolve: { value: variable_resolve, writable: true, configurable: true },
|
|
71
|
+
define: { value: variable_define, writable: true, configurable: true },
|
|
72
|
+
delete: { value: variable_delete, writable: true, configurable: true },
|
|
73
|
+
import: { value: variable_import, writable: true, configurable: true }
|
|
74
|
+
});
|
|
75
|
+
function initShadow(module, options) {
|
|
76
|
+
if (!options?.shadow) return null;
|
|
77
|
+
return new Map(
|
|
78
|
+
Object.entries(options.shadow).map(([name, definition]) => [name, new Variable(TYPE_IMPLICIT, module).define([], definition)])
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
__name(initShadow, "initShadow");
|
|
82
|
+
function variable_attach(variable) {
|
|
83
|
+
variable._module._runtime._dirty.add(variable);
|
|
84
|
+
variable._outputs.add(this);
|
|
85
|
+
}
|
|
86
|
+
__name(variable_attach, "variable_attach");
|
|
87
|
+
function variable_detach(variable) {
|
|
88
|
+
variable._module._runtime._dirty.add(variable);
|
|
89
|
+
variable._outputs.delete(this);
|
|
90
|
+
}
|
|
91
|
+
__name(variable_detach, "variable_detach");
|
|
92
|
+
function variable_undefined() {
|
|
93
|
+
throw variable_undefined;
|
|
94
|
+
}
|
|
95
|
+
__name(variable_undefined, "variable_undefined");
|
|
96
|
+
function variable_stale() {
|
|
97
|
+
throw variable_stale;
|
|
98
|
+
}
|
|
99
|
+
__name(variable_stale, "variable_stale");
|
|
100
|
+
function variable_rejector(variable) {
|
|
101
|
+
return (error) => {
|
|
102
|
+
if (error === variable_stale) throw error;
|
|
103
|
+
if (error === variable_undefined) throw new RuntimeError(`${variable._name} is not defined`, variable._name);
|
|
104
|
+
if (error instanceof Error && error.message) throw new RuntimeError(error.message, variable._name);
|
|
105
|
+
throw new RuntimeError(`${variable._name} could not be resolved`, variable._name);
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
__name(variable_rejector, "variable_rejector");
|
|
109
|
+
function variable_duplicate(name) {
|
|
110
|
+
return () => {
|
|
111
|
+
throw new RuntimeError(`${name} is defined more than once`);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
__name(variable_duplicate, "variable_duplicate");
|
|
115
|
+
function variable_define(name, inputs, definition) {
|
|
116
|
+
switch (arguments.length) {
|
|
117
|
+
case 1: {
|
|
118
|
+
definition = name, name = inputs = null;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case 2: {
|
|
122
|
+
definition = inputs;
|
|
123
|
+
if (typeof name === "string") inputs = null;
|
|
124
|
+
else inputs = name, name = null;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return variable_defineImpl.call(
|
|
129
|
+
this,
|
|
130
|
+
name == null ? null : String(name),
|
|
131
|
+
inputs == null ? [] : map.call(inputs, this._resolve, this),
|
|
132
|
+
typeof definition === "function" ? definition : constant(definition)
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
__name(variable_define, "variable_define");
|
|
136
|
+
function variable_resolve(name) {
|
|
137
|
+
return this._shadow?.get(name) ?? this._module._resolve(name);
|
|
138
|
+
}
|
|
139
|
+
__name(variable_resolve, "variable_resolve");
|
|
140
|
+
function variable_defineImpl(name, inputs, definition) {
|
|
141
|
+
const scope = this._module._scope, runtime = this._module._runtime;
|
|
142
|
+
this._inputs.forEach(variable_detach, this);
|
|
143
|
+
inputs.forEach(variable_attach, this);
|
|
144
|
+
this._inputs = inputs;
|
|
145
|
+
this._definition = definition;
|
|
146
|
+
this._value = void 0;
|
|
147
|
+
if (definition === noop) runtime._variables.delete(this);
|
|
148
|
+
else runtime._variables.add(this);
|
|
149
|
+
if (name !== this._name || scope.get(name) !== this) {
|
|
150
|
+
let error, found;
|
|
151
|
+
if (this._name) {
|
|
152
|
+
if (this._outputs.size) {
|
|
153
|
+
scope.delete(this._name);
|
|
154
|
+
found = this._module._resolve(this._name);
|
|
155
|
+
found._outputs = this._outputs, this._outputs = /* @__PURE__ */ new Set();
|
|
156
|
+
found._outputs.forEach(function(output) {
|
|
157
|
+
output._inputs[output._inputs.indexOf(this)] = found;
|
|
158
|
+
}, this);
|
|
159
|
+
found._outputs.forEach(runtime._updates.add, runtime._updates);
|
|
160
|
+
runtime._dirty.add(found).add(this);
|
|
161
|
+
scope.set(this._name, found);
|
|
162
|
+
} else if ((found = scope.get(this._name)) === this) {
|
|
163
|
+
scope.delete(this._name);
|
|
164
|
+
} else if (found._type === TYPE_DUPLICATE) {
|
|
165
|
+
found._duplicates.delete(this);
|
|
166
|
+
this._duplicate = void 0;
|
|
167
|
+
if (found._duplicates.size === 1) {
|
|
168
|
+
found = found._duplicates.keys().next().value;
|
|
169
|
+
error = scope.get(this._name);
|
|
170
|
+
found._outputs = error._outputs, error._outputs = /* @__PURE__ */ new Set();
|
|
171
|
+
found._outputs.forEach(function(output) {
|
|
172
|
+
output._inputs[output._inputs.indexOf(error)] = found;
|
|
173
|
+
});
|
|
174
|
+
found._definition = found._duplicate, found._duplicate = void 0;
|
|
175
|
+
runtime._dirty.add(error).add(found);
|
|
176
|
+
runtime._updates.add(found);
|
|
177
|
+
scope.set(this._name, found);
|
|
178
|
+
}
|
|
179
|
+
} else {
|
|
180
|
+
throw new Error();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (this._outputs.size) throw new Error();
|
|
184
|
+
if (name) {
|
|
185
|
+
if (found = scope.get(name)) {
|
|
186
|
+
if (found._type === TYPE_DUPLICATE) {
|
|
187
|
+
this._definition = variable_duplicate(name), this._duplicate = definition;
|
|
188
|
+
found._duplicates.add(this);
|
|
189
|
+
} else if (found._type === TYPE_IMPLICIT) {
|
|
190
|
+
this._outputs = found._outputs, found._outputs = /* @__PURE__ */ new Set();
|
|
191
|
+
this._outputs.forEach(function(output) {
|
|
192
|
+
output._inputs[output._inputs.indexOf(found)] = this;
|
|
193
|
+
}, this);
|
|
194
|
+
runtime._dirty.add(found).add(this);
|
|
195
|
+
scope.set(name, this);
|
|
196
|
+
} else {
|
|
197
|
+
found._duplicate = found._definition, this._duplicate = definition;
|
|
198
|
+
error = new Variable(TYPE_DUPLICATE, this._module);
|
|
199
|
+
error._name = name;
|
|
200
|
+
error._definition = this._definition = found._definition = variable_duplicate(name);
|
|
201
|
+
error._outputs = found._outputs, found._outputs = /* @__PURE__ */ new Set();
|
|
202
|
+
error._outputs.forEach(function(output) {
|
|
203
|
+
output._inputs[output._inputs.indexOf(found)] = error;
|
|
204
|
+
});
|
|
205
|
+
error._duplicates = /* @__PURE__ */ new Set([this, found]);
|
|
206
|
+
runtime._dirty.add(found).add(error);
|
|
207
|
+
runtime._updates.add(found).add(error);
|
|
208
|
+
scope.set(name, error);
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
scope.set(name, this);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
this._name = name;
|
|
215
|
+
}
|
|
216
|
+
if (this._version > 0) ++this._version;
|
|
217
|
+
runtime._updates.add(this);
|
|
218
|
+
runtime._compute();
|
|
219
|
+
return this;
|
|
220
|
+
}
|
|
221
|
+
__name(variable_defineImpl, "variable_defineImpl");
|
|
222
|
+
function variable_import(remote, name, module) {
|
|
223
|
+
if (arguments.length < 3) module = name, name = remote;
|
|
224
|
+
return variable_defineImpl.call(this, String(name), [module._resolve(String(remote))], identity);
|
|
225
|
+
}
|
|
226
|
+
__name(variable_import, "variable_import");
|
|
227
|
+
function variable_delete() {
|
|
228
|
+
return variable_defineImpl.call(this, null, [], noop);
|
|
229
|
+
}
|
|
230
|
+
__name(variable_delete, "variable_delete");
|
|
231
|
+
function variable_pending() {
|
|
232
|
+
if (this._observer.pending) this._observer.pending();
|
|
233
|
+
}
|
|
234
|
+
__name(variable_pending, "variable_pending");
|
|
235
|
+
function variable_fulfilled(value) {
|
|
236
|
+
if (this._observer.fulfilled) this._observer.fulfilled(value, this._name);
|
|
237
|
+
}
|
|
238
|
+
__name(variable_fulfilled, "variable_fulfilled");
|
|
239
|
+
function variable_rejected(error) {
|
|
240
|
+
if (this._observer.rejected) this._observer.rejected(error, this._name);
|
|
241
|
+
}
|
|
242
|
+
__name(variable_rejected, "variable_rejected");
|
|
243
|
+
const variable_variable = Symbol("variable");
|
|
244
|
+
const variable_invalidation = Symbol("invalidation");
|
|
245
|
+
const variable_visibility = Symbol("visibility");
|
|
246
|
+
function Module(runtime, builtins = []) {
|
|
247
|
+
Object.defineProperties(this, {
|
|
248
|
+
_runtime: { value: runtime },
|
|
249
|
+
_scope: { value: /* @__PURE__ */ new Map() },
|
|
250
|
+
_builtins: { value: new Map([
|
|
251
|
+
["@variable", variable_variable],
|
|
252
|
+
["invalidation", variable_invalidation],
|
|
253
|
+
["visibility", variable_visibility],
|
|
254
|
+
...builtins
|
|
255
|
+
]) },
|
|
256
|
+
_source: { value: null, writable: true }
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
__name(Module, "Module");
|
|
260
|
+
Object.defineProperties(Module.prototype, {
|
|
261
|
+
_resolve: { value: module_resolve, writable: true, configurable: true },
|
|
262
|
+
redefine: { value: module_redefine, writable: true, configurable: true },
|
|
263
|
+
define: { value: module_define, writable: true, configurable: true },
|
|
264
|
+
derive: { value: module_derive, writable: true, configurable: true },
|
|
265
|
+
import: { value: module_import, writable: true, configurable: true },
|
|
266
|
+
value: { value: module_value, writable: true, configurable: true },
|
|
267
|
+
variable: { value: module_variable, writable: true, configurable: true },
|
|
268
|
+
builtin: { value: module_builtin, writable: true, configurable: true }
|
|
269
|
+
});
|
|
270
|
+
function module_redefine(name) {
|
|
271
|
+
const v = this._scope.get(name);
|
|
272
|
+
if (!v) throw new RuntimeError(`${name} is not defined`);
|
|
273
|
+
if (v._type === TYPE_DUPLICATE) throw new RuntimeError(`${name} is defined more than once`);
|
|
274
|
+
return v.define.apply(v, arguments);
|
|
275
|
+
}
|
|
276
|
+
__name(module_redefine, "module_redefine");
|
|
277
|
+
function module_define() {
|
|
278
|
+
const v = new Variable(TYPE_NORMAL, this);
|
|
279
|
+
return v.define.apply(v, arguments);
|
|
280
|
+
}
|
|
281
|
+
__name(module_define, "module_define");
|
|
282
|
+
function module_import() {
|
|
283
|
+
const v = new Variable(TYPE_NORMAL, this);
|
|
284
|
+
return v.import.apply(v, arguments);
|
|
285
|
+
}
|
|
286
|
+
__name(module_import, "module_import");
|
|
287
|
+
function module_variable(observer, options) {
|
|
288
|
+
return new Variable(TYPE_NORMAL, this, observer, options);
|
|
289
|
+
}
|
|
290
|
+
__name(module_variable, "module_variable");
|
|
291
|
+
async function module_value(name) {
|
|
292
|
+
let v = this._scope.get(name);
|
|
293
|
+
if (!v) throw new RuntimeError(`${name} is not defined`);
|
|
294
|
+
if (v._observer === no_observer) {
|
|
295
|
+
v = this.variable(true).define([name], identity);
|
|
296
|
+
try {
|
|
297
|
+
return await module_revalue(this._runtime, v);
|
|
298
|
+
} finally {
|
|
299
|
+
v.delete();
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
return module_revalue(this._runtime, v);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
__name(module_value, "module_value");
|
|
306
|
+
async function module_revalue(runtime, variable) {
|
|
307
|
+
await runtime._compute();
|
|
308
|
+
try {
|
|
309
|
+
return await variable._promise;
|
|
310
|
+
} catch (error) {
|
|
311
|
+
if (error === variable_stale) return module_revalue(runtime, variable);
|
|
312
|
+
throw error;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
__name(module_revalue, "module_revalue");
|
|
316
|
+
function module_derive(injects, injectModule) {
|
|
317
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
318
|
+
const modules = /* @__PURE__ */ new Set();
|
|
319
|
+
const copies = [];
|
|
320
|
+
function alias(source) {
|
|
321
|
+
let target = map2.get(source);
|
|
322
|
+
if (target) return target;
|
|
323
|
+
target = new Module(source._runtime, source._builtins);
|
|
324
|
+
target._source = source;
|
|
325
|
+
map2.set(source, target);
|
|
326
|
+
copies.push([target, source]);
|
|
327
|
+
modules.add(source);
|
|
328
|
+
return target;
|
|
329
|
+
}
|
|
330
|
+
__name(alias, "alias");
|
|
331
|
+
const derive = alias(this);
|
|
332
|
+
for (const inject of injects) {
|
|
333
|
+
const { alias: alias2, name } = typeof inject === "object" ? inject : { name: inject };
|
|
334
|
+
derive.import(name, alias2 == null ? name : alias2, injectModule);
|
|
335
|
+
}
|
|
336
|
+
for (const module of modules) {
|
|
337
|
+
for (const [name, variable] of module._scope) {
|
|
338
|
+
if (variable._definition === identity) {
|
|
339
|
+
if (module === this && derive._scope.has(name)) continue;
|
|
340
|
+
const importedModule = variable._inputs[0]._module;
|
|
341
|
+
if (importedModule._source) alias(importedModule);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
for (const [target, source] of copies) {
|
|
346
|
+
for (const [name, sourceVariable] of source._scope) {
|
|
347
|
+
const targetVariable = target._scope.get(name);
|
|
348
|
+
if (targetVariable && targetVariable._type !== TYPE_IMPLICIT) continue;
|
|
349
|
+
if (sourceVariable._definition === identity) {
|
|
350
|
+
const sourceInput = sourceVariable._inputs[0];
|
|
351
|
+
const sourceModule = sourceInput._module;
|
|
352
|
+
target.import(sourceInput._name, name, map2.get(sourceModule) || sourceModule);
|
|
353
|
+
} else {
|
|
354
|
+
target.define(name, sourceVariable._inputs.map(variable_name), sourceVariable._definition);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return derive;
|
|
359
|
+
}
|
|
360
|
+
__name(module_derive, "module_derive");
|
|
361
|
+
function module_resolve(name) {
|
|
362
|
+
let variable = this._scope.get(name), value;
|
|
363
|
+
if (!variable) {
|
|
364
|
+
variable = new Variable(TYPE_IMPLICIT, this);
|
|
365
|
+
if (this._builtins.has(name)) {
|
|
366
|
+
variable.define(name, constant(this._builtins.get(name)));
|
|
367
|
+
} else if (this._runtime._builtin._scope.has(name)) {
|
|
368
|
+
variable.import(name, this._runtime._builtin);
|
|
369
|
+
} else {
|
|
370
|
+
try {
|
|
371
|
+
value = this._runtime._global(name);
|
|
372
|
+
} catch (error) {
|
|
373
|
+
return variable.define(name, rethrow(error));
|
|
374
|
+
}
|
|
375
|
+
if (value === void 0) {
|
|
376
|
+
this._scope.set(variable._name = name, variable);
|
|
377
|
+
} else {
|
|
378
|
+
variable.define(name, constant(value));
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return variable;
|
|
383
|
+
}
|
|
384
|
+
__name(module_resolve, "module_resolve");
|
|
385
|
+
function module_builtin(name, value) {
|
|
386
|
+
this._builtins.set(name, value);
|
|
387
|
+
}
|
|
388
|
+
__name(module_builtin, "module_builtin");
|
|
389
|
+
function variable_name(variable) {
|
|
390
|
+
return variable._name;
|
|
391
|
+
}
|
|
392
|
+
__name(variable_name, "variable_name");
|
|
393
|
+
const frame = typeof requestAnimationFrame === "function" ? requestAnimationFrame : typeof setImmediate === "function" ? setImmediate : (f) => setTimeout(f, 0);
|
|
394
|
+
function Runtime(builtins, global = window_global) {
|
|
395
|
+
const builtin = this.module();
|
|
396
|
+
Object.defineProperties(this, {
|
|
397
|
+
_dirty: { value: /* @__PURE__ */ new Set() },
|
|
398
|
+
_updates: { value: /* @__PURE__ */ new Set() },
|
|
399
|
+
_precomputes: { value: [], writable: true },
|
|
400
|
+
_computing: { value: null, writable: true },
|
|
401
|
+
_init: { value: null, writable: true },
|
|
402
|
+
_modules: { value: /* @__PURE__ */ new Map() },
|
|
403
|
+
_variables: { value: /* @__PURE__ */ new Set() },
|
|
404
|
+
_disposed: { value: false, writable: true },
|
|
405
|
+
_builtin: { value: builtin },
|
|
406
|
+
_global: { value: global }
|
|
407
|
+
});
|
|
408
|
+
if (builtins) for (const name in builtins) {
|
|
409
|
+
new Variable(TYPE_IMPLICIT, builtin).define(name, [], builtins[name]);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
__name(Runtime, "Runtime");
|
|
413
|
+
Object.defineProperties(Runtime.prototype, {
|
|
414
|
+
_precompute: { value: runtime_precompute, writable: true, configurable: true },
|
|
415
|
+
_compute: { value: runtime_compute, writable: true, configurable: true },
|
|
416
|
+
_computeSoon: { value: runtime_computeSoon, writable: true, configurable: true },
|
|
417
|
+
_computeNow: { value: runtime_computeNow, writable: true, configurable: true },
|
|
418
|
+
dispose: { value: runtime_dispose, writable: true, configurable: true },
|
|
419
|
+
module: { value: runtime_module, writable: true, configurable: true }
|
|
420
|
+
});
|
|
421
|
+
function runtime_dispose() {
|
|
422
|
+
this._computing = Promise.resolve();
|
|
423
|
+
this._disposed = true;
|
|
424
|
+
this._variables.forEach((v) => {
|
|
425
|
+
v._invalidate();
|
|
426
|
+
v._version = NaN;
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
__name(runtime_dispose, "runtime_dispose");
|
|
430
|
+
function runtime_module(define2, observer = noop) {
|
|
431
|
+
let module;
|
|
432
|
+
if (define2 === void 0) {
|
|
433
|
+
if (module = this._init) {
|
|
434
|
+
this._init = null;
|
|
435
|
+
return module;
|
|
436
|
+
}
|
|
437
|
+
return new Module(this);
|
|
438
|
+
}
|
|
439
|
+
module = this._modules.get(define2);
|
|
440
|
+
if (module) return module;
|
|
441
|
+
this._init = module = new Module(this);
|
|
442
|
+
this._modules.set(define2, module);
|
|
443
|
+
try {
|
|
444
|
+
define2(this, observer);
|
|
445
|
+
} finally {
|
|
446
|
+
this._init = null;
|
|
447
|
+
}
|
|
448
|
+
return module;
|
|
449
|
+
}
|
|
450
|
+
__name(runtime_module, "runtime_module");
|
|
451
|
+
function runtime_precompute(callback) {
|
|
452
|
+
this._precomputes.push(callback);
|
|
453
|
+
this._compute();
|
|
454
|
+
}
|
|
455
|
+
__name(runtime_precompute, "runtime_precompute");
|
|
456
|
+
function runtime_compute() {
|
|
457
|
+
return this._computing || (this._computing = this._computeSoon());
|
|
458
|
+
}
|
|
459
|
+
__name(runtime_compute, "runtime_compute");
|
|
460
|
+
function runtime_computeSoon() {
|
|
461
|
+
return new Promise(frame).then(() => this._disposed ? void 0 : this._computeNow());
|
|
462
|
+
}
|
|
463
|
+
__name(runtime_computeSoon, "runtime_computeSoon");
|
|
464
|
+
async function runtime_computeNow() {
|
|
465
|
+
let queue2 = [], variables, variable, precomputes = this._precomputes;
|
|
466
|
+
if (precomputes.length) {
|
|
467
|
+
this._precomputes = [];
|
|
468
|
+
for (const callback of precomputes) callback();
|
|
469
|
+
await runtime_defer(3);
|
|
470
|
+
}
|
|
471
|
+
variables = new Set(this._dirty);
|
|
472
|
+
variables.forEach(function(variable2) {
|
|
473
|
+
variable2._inputs.forEach(variables.add, variables);
|
|
474
|
+
const reachable = variable_reachable(variable2);
|
|
475
|
+
if (reachable > variable2._reachable) {
|
|
476
|
+
this._updates.add(variable2);
|
|
477
|
+
} else if (reachable < variable2._reachable) {
|
|
478
|
+
variable2._invalidate();
|
|
479
|
+
}
|
|
480
|
+
variable2._reachable = reachable;
|
|
481
|
+
}, this);
|
|
482
|
+
variables = new Set(this._updates);
|
|
483
|
+
variables.forEach(function(variable2) {
|
|
484
|
+
if (variable2._reachable) {
|
|
485
|
+
variable2._indegree = 0;
|
|
486
|
+
variable2._outputs.forEach(variables.add, variables);
|
|
487
|
+
} else {
|
|
488
|
+
variable2._indegree = NaN;
|
|
489
|
+
variables.delete(variable2);
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
this._computing = null;
|
|
493
|
+
this._updates.clear();
|
|
494
|
+
this._dirty.clear();
|
|
495
|
+
variables.forEach(function(variable2) {
|
|
496
|
+
variable2._outputs.forEach(variable_increment);
|
|
497
|
+
});
|
|
498
|
+
do {
|
|
499
|
+
variables.forEach(function(variable2) {
|
|
500
|
+
if (variable2._indegree === 0) {
|
|
501
|
+
queue2.push(variable2);
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
while (variable = queue2.pop()) {
|
|
505
|
+
variable_compute(variable);
|
|
506
|
+
variable._outputs.forEach(postqueue);
|
|
507
|
+
variables.delete(variable);
|
|
508
|
+
}
|
|
509
|
+
variables.forEach(function(variable2) {
|
|
510
|
+
if (variable_circular(variable2)) {
|
|
511
|
+
variable_error(variable2, new RuntimeError("circular definition"));
|
|
512
|
+
variable2._outputs.forEach(variable_decrement);
|
|
513
|
+
variables.delete(variable2);
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
} while (variables.size);
|
|
517
|
+
function postqueue(variable2) {
|
|
518
|
+
if (--variable2._indegree === 0) {
|
|
519
|
+
queue2.push(variable2);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
__name(postqueue, "postqueue");
|
|
523
|
+
}
|
|
524
|
+
__name(runtime_computeNow, "runtime_computeNow");
|
|
525
|
+
function runtime_defer(depth = 0) {
|
|
526
|
+
let p = Promise.resolve();
|
|
527
|
+
for (let i = 0; i < depth; ++i) p = p.then(() => {
|
|
528
|
+
});
|
|
529
|
+
return p;
|
|
530
|
+
}
|
|
531
|
+
__name(runtime_defer, "runtime_defer");
|
|
532
|
+
function variable_circular(variable) {
|
|
533
|
+
const inputs = new Set(variable._inputs);
|
|
534
|
+
for (const i of inputs) {
|
|
535
|
+
if (i === variable) return true;
|
|
536
|
+
i._inputs.forEach(inputs.add, inputs);
|
|
537
|
+
}
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
__name(variable_circular, "variable_circular");
|
|
541
|
+
function variable_increment(variable) {
|
|
542
|
+
++variable._indegree;
|
|
543
|
+
}
|
|
544
|
+
__name(variable_increment, "variable_increment");
|
|
545
|
+
function variable_decrement(variable) {
|
|
546
|
+
--variable._indegree;
|
|
547
|
+
}
|
|
548
|
+
__name(variable_decrement, "variable_decrement");
|
|
549
|
+
function variable_value(variable) {
|
|
550
|
+
return variable._promise.catch(variable._rejector);
|
|
551
|
+
}
|
|
552
|
+
__name(variable_value, "variable_value");
|
|
553
|
+
function variable_invalidator(variable) {
|
|
554
|
+
return new Promise(function(resolve2) {
|
|
555
|
+
variable._invalidate = resolve2;
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
__name(variable_invalidator, "variable_invalidator");
|
|
559
|
+
function variable_intersector(invalidation, variable) {
|
|
560
|
+
let node = typeof IntersectionObserver === "function" && variable._observer && variable._observer._node;
|
|
561
|
+
let visible = !node, resolve2 = noop, reject = noop, promise, observer;
|
|
562
|
+
if (node) {
|
|
563
|
+
observer = new IntersectionObserver(([entry]) => (visible = entry.isIntersecting) && (promise = null, resolve2()));
|
|
564
|
+
observer.observe(node);
|
|
565
|
+
invalidation.then(() => (observer.disconnect(), observer = null, reject()));
|
|
566
|
+
}
|
|
567
|
+
return function(value) {
|
|
568
|
+
if (visible) return Promise.resolve(value);
|
|
569
|
+
if (!observer) return Promise.reject();
|
|
570
|
+
if (!promise) promise = new Promise((y, n) => (resolve2 = y, reject = n));
|
|
571
|
+
return promise.then(() => value);
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
__name(variable_intersector, "variable_intersector");
|
|
575
|
+
function variable_compute(variable) {
|
|
576
|
+
variable._invalidate();
|
|
577
|
+
variable._invalidate = noop;
|
|
578
|
+
variable._pending();
|
|
579
|
+
const value0 = variable._value;
|
|
580
|
+
const version = ++variable._version;
|
|
581
|
+
const inputs = variable._inputs;
|
|
582
|
+
const definition = variable._definition;
|
|
583
|
+
let invalidation = null;
|
|
584
|
+
const promise = variable._promise = variable._promise.then(init, init).then(define2).then(generate);
|
|
585
|
+
function init() {
|
|
586
|
+
return Promise.all(inputs.map(variable_value));
|
|
587
|
+
}
|
|
588
|
+
__name(init, "init");
|
|
589
|
+
function define2(inputs2) {
|
|
590
|
+
if (variable._version !== version) throw variable_stale;
|
|
591
|
+
for (let i = 0, n = inputs2.length; i < n; ++i) {
|
|
592
|
+
switch (inputs2[i]) {
|
|
593
|
+
case variable_invalidation: {
|
|
594
|
+
inputs2[i] = invalidation = variable_invalidator(variable);
|
|
595
|
+
break;
|
|
596
|
+
}
|
|
597
|
+
case variable_visibility: {
|
|
598
|
+
if (!invalidation) invalidation = variable_invalidator(variable);
|
|
599
|
+
inputs2[i] = variable_intersector(invalidation, variable);
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
602
|
+
case variable_variable: {
|
|
603
|
+
inputs2[i] = variable;
|
|
604
|
+
break;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return definition.apply(value0, inputs2);
|
|
609
|
+
}
|
|
610
|
+
__name(define2, "define");
|
|
611
|
+
function generate(value) {
|
|
612
|
+
if (variable._version !== version) throw variable_stale;
|
|
613
|
+
if (generatorish(value)) {
|
|
614
|
+
(invalidation || variable_invalidator(variable)).then(variable_return(value));
|
|
615
|
+
return variable_generate(variable, version, value);
|
|
616
|
+
}
|
|
617
|
+
return value;
|
|
618
|
+
}
|
|
619
|
+
__name(generate, "generate");
|
|
620
|
+
promise.then((value) => {
|
|
621
|
+
variable._value = value;
|
|
622
|
+
variable._fulfilled(value);
|
|
623
|
+
}, (error) => {
|
|
624
|
+
if (error === variable_stale || variable._version !== version) return;
|
|
625
|
+
variable._value = void 0;
|
|
626
|
+
variable._rejected(error);
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
__name(variable_compute, "variable_compute");
|
|
630
|
+
function variable_generate(variable, version, generator) {
|
|
631
|
+
const runtime = variable._module._runtime;
|
|
632
|
+
let currentValue;
|
|
633
|
+
function compute(onfulfilled) {
|
|
634
|
+
return new Promise((resolve2) => resolve2(generator.next(currentValue))).then(({ done, value }) => {
|
|
635
|
+
return done ? void 0 : Promise.resolve(value).then(onfulfilled);
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
__name(compute, "compute");
|
|
639
|
+
function recompute() {
|
|
640
|
+
const promise = compute((value) => {
|
|
641
|
+
if (variable._version !== version) throw variable_stale;
|
|
642
|
+
currentValue = value;
|
|
643
|
+
postcompute(value, promise).then(() => runtime._precompute(recompute));
|
|
644
|
+
variable._fulfilled(value);
|
|
645
|
+
return value;
|
|
646
|
+
});
|
|
647
|
+
promise.catch((error) => {
|
|
648
|
+
if (error === variable_stale || variable._version !== version) return;
|
|
649
|
+
postcompute(void 0, promise);
|
|
650
|
+
variable._rejected(error);
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
__name(recompute, "recompute");
|
|
654
|
+
function postcompute(value, promise) {
|
|
655
|
+
variable._value = value;
|
|
656
|
+
variable._promise = promise;
|
|
657
|
+
variable._outputs.forEach(runtime._updates.add, runtime._updates);
|
|
658
|
+
return runtime._compute();
|
|
659
|
+
}
|
|
660
|
+
__name(postcompute, "postcompute");
|
|
661
|
+
return compute((value) => {
|
|
662
|
+
if (variable._version !== version) throw variable_stale;
|
|
663
|
+
currentValue = value;
|
|
664
|
+
runtime._precompute(recompute);
|
|
665
|
+
return value;
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
__name(variable_generate, "variable_generate");
|
|
669
|
+
function variable_error(variable, error) {
|
|
670
|
+
variable._invalidate();
|
|
671
|
+
variable._invalidate = noop;
|
|
672
|
+
variable._pending();
|
|
673
|
+
++variable._version;
|
|
674
|
+
variable._indegree = NaN;
|
|
675
|
+
(variable._promise = Promise.reject(error)).catch(noop);
|
|
676
|
+
variable._value = void 0;
|
|
677
|
+
variable._rejected(error);
|
|
678
|
+
}
|
|
679
|
+
__name(variable_error, "variable_error");
|
|
680
|
+
function variable_return(generator) {
|
|
681
|
+
return function() {
|
|
682
|
+
generator.return();
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
__name(variable_return, "variable_return");
|
|
686
|
+
function variable_reachable(variable) {
|
|
687
|
+
if (variable._observer !== no_observer) return true;
|
|
688
|
+
const outputs = new Set(variable._outputs);
|
|
689
|
+
for (const output of outputs) {
|
|
690
|
+
if (output._observer !== no_observer) return true;
|
|
691
|
+
output._outputs.forEach(outputs.add, outputs);
|
|
692
|
+
}
|
|
693
|
+
return false;
|
|
694
|
+
}
|
|
695
|
+
__name(variable_reachable, "variable_reachable");
|
|
696
|
+
function window_global(name) {
|
|
697
|
+
return globalThis[name];
|
|
698
|
+
}
|
|
699
|
+
__name(window_global, "window_global");
|
|
700
|
+
function dispatch(node, type, detail) {
|
|
701
|
+
detail = detail || {};
|
|
702
|
+
var document2 = node.ownerDocument, event = document2.defaultView.CustomEvent;
|
|
703
|
+
if (typeof event === "function") {
|
|
704
|
+
event = new event(type, { detail });
|
|
705
|
+
} else {
|
|
706
|
+
event = document2.createEvent("Event");
|
|
707
|
+
event.initEvent(type, false, false);
|
|
708
|
+
event.detail = detail;
|
|
709
|
+
}
|
|
710
|
+
node.dispatchEvent(event);
|
|
711
|
+
}
|
|
712
|
+
__name(dispatch, "dispatch");
|
|
713
|
+
function isarray(value) {
|
|
714
|
+
return Array.isArray(value) || value instanceof Int8Array || value instanceof Int16Array || value instanceof Int32Array || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Uint16Array || value instanceof Uint32Array || value instanceof Float32Array || value instanceof Float64Array;
|
|
715
|
+
}
|
|
716
|
+
__name(isarray, "isarray");
|
|
717
|
+
function isindex(key) {
|
|
718
|
+
return key === (key | 0) + "";
|
|
719
|
+
}
|
|
720
|
+
__name(isindex, "isindex");
|
|
721
|
+
function inspectName(name) {
|
|
722
|
+
const n = document.createElement("span");
|
|
723
|
+
n.className = "observablehq--cellname";
|
|
724
|
+
n.textContent = `${name} = `;
|
|
725
|
+
return n;
|
|
726
|
+
}
|
|
727
|
+
__name(inspectName, "inspectName");
|
|
728
|
+
const symbolToString = Symbol.prototype.toString;
|
|
729
|
+
function formatSymbol(symbol) {
|
|
730
|
+
return symbolToString.call(symbol);
|
|
731
|
+
}
|
|
732
|
+
__name(formatSymbol, "formatSymbol");
|
|
733
|
+
const { getOwnPropertySymbols, prototype: { hasOwnProperty } } = Object;
|
|
734
|
+
const { toStringTag } = Symbol;
|
|
735
|
+
const FORBIDDEN = {};
|
|
736
|
+
const symbolsof = getOwnPropertySymbols;
|
|
737
|
+
function isown(object, key) {
|
|
738
|
+
return hasOwnProperty.call(object, key);
|
|
739
|
+
}
|
|
740
|
+
__name(isown, "isown");
|
|
741
|
+
function tagof(object) {
|
|
742
|
+
return object[toStringTag] || object.constructor && object.constructor.name || "Object";
|
|
743
|
+
}
|
|
744
|
+
__name(tagof, "tagof");
|
|
745
|
+
function valueof$1(object, key) {
|
|
746
|
+
try {
|
|
747
|
+
const value = object[key];
|
|
748
|
+
if (value) value.constructor;
|
|
749
|
+
return value;
|
|
750
|
+
} catch (ignore) {
|
|
751
|
+
return FORBIDDEN;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
__name(valueof$1, "valueof$1");
|
|
755
|
+
const SYMBOLS = [
|
|
756
|
+
{ symbol: "@@__IMMUTABLE_INDEXED__@@", name: "Indexed", modifier: true },
|
|
757
|
+
{ symbol: "@@__IMMUTABLE_KEYED__@@", name: "Keyed", modifier: true },
|
|
758
|
+
{ symbol: "@@__IMMUTABLE_LIST__@@", name: "List", arrayish: true },
|
|
759
|
+
{ symbol: "@@__IMMUTABLE_MAP__@@", name: "Map" },
|
|
760
|
+
{
|
|
761
|
+
symbol: "@@__IMMUTABLE_ORDERED__@@",
|
|
762
|
+
name: "Ordered",
|
|
763
|
+
modifier: true,
|
|
764
|
+
prefix: true
|
|
765
|
+
},
|
|
766
|
+
{ symbol: "@@__IMMUTABLE_RECORD__@@", name: "Record" },
|
|
767
|
+
{
|
|
768
|
+
symbol: "@@__IMMUTABLE_SET__@@",
|
|
769
|
+
name: "Set",
|
|
770
|
+
arrayish: true,
|
|
771
|
+
setish: true
|
|
772
|
+
},
|
|
773
|
+
{ symbol: "@@__IMMUTABLE_STACK__@@", name: "Stack", arrayish: true }
|
|
774
|
+
];
|
|
775
|
+
function immutableName(obj) {
|
|
776
|
+
try {
|
|
777
|
+
let symbols = SYMBOLS.filter(({ symbol }) => obj[symbol] === true);
|
|
778
|
+
if (!symbols.length) return;
|
|
779
|
+
const name = symbols.find((s) => !s.modifier);
|
|
780
|
+
const prefix = name.name === "Map" && symbols.find((s) => s.modifier && s.prefix);
|
|
781
|
+
const arrayish = symbols.some((s) => s.arrayish);
|
|
782
|
+
const setish = symbols.some((s) => s.setish);
|
|
783
|
+
return {
|
|
784
|
+
name: `${prefix ? prefix.name : ""}${name.name}`,
|
|
785
|
+
symbols,
|
|
786
|
+
arrayish: arrayish && !setish,
|
|
787
|
+
setish
|
|
788
|
+
};
|
|
789
|
+
} catch (e) {
|
|
790
|
+
return null;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
__name(immutableName, "immutableName");
|
|
794
|
+
const { getPrototypeOf, getOwnPropertyDescriptors } = Object;
|
|
795
|
+
const objectPrototype = getPrototypeOf({});
|
|
796
|
+
function inspectExpanded(object, _2, name, proto) {
|
|
797
|
+
let arrayish = isarray(object);
|
|
798
|
+
let tag, fields, next, n;
|
|
799
|
+
if (object instanceof Map) {
|
|
800
|
+
if (object instanceof object.constructor) {
|
|
801
|
+
tag = `Map(${object.size})`;
|
|
802
|
+
fields = iterateMap$1;
|
|
803
|
+
} else {
|
|
804
|
+
tag = "Map()";
|
|
805
|
+
fields = iterateObject$1;
|
|
806
|
+
}
|
|
807
|
+
} else if (object instanceof Set) {
|
|
808
|
+
if (object instanceof object.constructor) {
|
|
809
|
+
tag = `Set(${object.size})`;
|
|
810
|
+
fields = iterateSet$1;
|
|
811
|
+
} else {
|
|
812
|
+
tag = "Set()";
|
|
813
|
+
fields = iterateObject$1;
|
|
814
|
+
}
|
|
815
|
+
} else if (arrayish) {
|
|
816
|
+
tag = `${object.constructor.name}(${object.length})`;
|
|
817
|
+
fields = iterateArray$1;
|
|
818
|
+
} else if (n = immutableName(object)) {
|
|
819
|
+
tag = `Immutable.${n.name}${n.name === "Record" ? "" : `(${object.size})`}`;
|
|
820
|
+
arrayish = n.arrayish;
|
|
821
|
+
fields = n.arrayish ? iterateImArray$1 : n.setish ? iterateImSet$1 : iterateImObject$1;
|
|
822
|
+
} else if (proto) {
|
|
823
|
+
tag = tagof(object);
|
|
824
|
+
fields = iterateProto;
|
|
825
|
+
} else {
|
|
826
|
+
tag = tagof(object);
|
|
827
|
+
fields = iterateObject$1;
|
|
828
|
+
}
|
|
829
|
+
const span = document.createElement("span");
|
|
830
|
+
span.className = "observablehq--expanded";
|
|
831
|
+
if (name) {
|
|
832
|
+
span.appendChild(inspectName(name));
|
|
833
|
+
}
|
|
834
|
+
const a = span.appendChild(document.createElement("a"));
|
|
835
|
+
a.innerHTML = `<svg width=8 height=8 class='observablehq--caret'>
|
|
836
|
+
<path d='M4 7L0 1h8z' fill='currentColor' />
|
|
837
|
+
</svg>`;
|
|
838
|
+
a.appendChild(document.createTextNode(`${tag}${arrayish ? " [" : " {"}`));
|
|
839
|
+
a.addEventListener("mouseup", function(event) {
|
|
840
|
+
event.stopPropagation();
|
|
841
|
+
replace(span, inspectCollapsed(object, null, name, proto));
|
|
842
|
+
});
|
|
843
|
+
fields = fields(object);
|
|
844
|
+
for (let i = 0; !(next = fields.next()).done && i < 20; ++i) {
|
|
845
|
+
span.appendChild(next.value);
|
|
846
|
+
}
|
|
847
|
+
if (!next.done) {
|
|
848
|
+
const a2 = span.appendChild(document.createElement("a"));
|
|
849
|
+
a2.className = "observablehq--field";
|
|
850
|
+
a2.style.display = "block";
|
|
851
|
+
a2.appendChild(document.createTextNode(` … more`));
|
|
852
|
+
a2.addEventListener("mouseup", function(event) {
|
|
853
|
+
event.stopPropagation();
|
|
854
|
+
span.insertBefore(next.value, span.lastChild.previousSibling);
|
|
855
|
+
for (let i = 0; !(next = fields.next()).done && i < 19; ++i) {
|
|
856
|
+
span.insertBefore(next.value, span.lastChild.previousSibling);
|
|
857
|
+
}
|
|
858
|
+
if (next.done) span.removeChild(span.lastChild.previousSibling);
|
|
859
|
+
dispatch(span, "load");
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
span.appendChild(document.createTextNode(arrayish ? "]" : "}"));
|
|
863
|
+
return span;
|
|
864
|
+
}
|
|
865
|
+
__name(inspectExpanded, "inspectExpanded");
|
|
866
|
+
function* iterateMap$1(map2) {
|
|
867
|
+
for (const [key, value] of map2) {
|
|
868
|
+
yield formatMapField$1(key, value);
|
|
869
|
+
}
|
|
870
|
+
yield* iterateObject$1(map2);
|
|
871
|
+
}
|
|
872
|
+
__name(iterateMap$1, "iterateMap$1");
|
|
873
|
+
function* iterateSet$1(set) {
|
|
874
|
+
for (const value of set) {
|
|
875
|
+
yield formatSetField(value);
|
|
876
|
+
}
|
|
877
|
+
yield* iterateObject$1(set);
|
|
878
|
+
}
|
|
879
|
+
__name(iterateSet$1, "iterateSet$1");
|
|
880
|
+
function* iterateImSet$1(set) {
|
|
881
|
+
for (const value of set) {
|
|
882
|
+
yield formatSetField(value);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
__name(iterateImSet$1, "iterateImSet$1");
|
|
886
|
+
function* iterateArray$1(array) {
|
|
887
|
+
for (let i = 0, n = array.length; i < n; ++i) {
|
|
888
|
+
if (i in array) {
|
|
889
|
+
yield formatField$1(i, valueof$1(array, i), "observablehq--index");
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
for (const key in array) {
|
|
893
|
+
if (!isindex(key) && isown(array, key)) {
|
|
894
|
+
yield formatField$1(key, valueof$1(array, key), "observablehq--key");
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
for (const symbol of symbolsof(array)) {
|
|
898
|
+
yield formatField$1(
|
|
899
|
+
formatSymbol(symbol),
|
|
900
|
+
valueof$1(array, symbol),
|
|
901
|
+
"observablehq--symbol"
|
|
902
|
+
);
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
__name(iterateArray$1, "iterateArray$1");
|
|
906
|
+
function* iterateImArray$1(array) {
|
|
907
|
+
let i1 = 0;
|
|
908
|
+
for (const n = array.size; i1 < n; ++i1) {
|
|
909
|
+
yield formatField$1(i1, array.get(i1), true);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
__name(iterateImArray$1, "iterateImArray$1");
|
|
913
|
+
function* iterateProto(object) {
|
|
914
|
+
for (const key in getOwnPropertyDescriptors(object)) {
|
|
915
|
+
yield formatField$1(key, valueof$1(object, key), "observablehq--key");
|
|
916
|
+
}
|
|
917
|
+
for (const symbol of symbolsof(object)) {
|
|
918
|
+
yield formatField$1(
|
|
919
|
+
formatSymbol(symbol),
|
|
920
|
+
valueof$1(object, symbol),
|
|
921
|
+
"observablehq--symbol"
|
|
922
|
+
);
|
|
923
|
+
}
|
|
924
|
+
const proto = getPrototypeOf(object);
|
|
925
|
+
if (proto && proto !== objectPrototype) {
|
|
926
|
+
yield formatPrototype(proto);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
__name(iterateProto, "iterateProto");
|
|
930
|
+
function* iterateObject$1(object) {
|
|
931
|
+
for (const key in object) {
|
|
932
|
+
if (isown(object, key)) {
|
|
933
|
+
yield formatField$1(key, valueof$1(object, key), "observablehq--key");
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
for (const symbol of symbolsof(object)) {
|
|
937
|
+
yield formatField$1(
|
|
938
|
+
formatSymbol(symbol),
|
|
939
|
+
valueof$1(object, symbol),
|
|
940
|
+
"observablehq--symbol"
|
|
941
|
+
);
|
|
942
|
+
}
|
|
943
|
+
const proto = getPrototypeOf(object);
|
|
944
|
+
if (proto && proto !== objectPrototype) {
|
|
945
|
+
yield formatPrototype(proto);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
__name(iterateObject$1, "iterateObject$1");
|
|
949
|
+
function* iterateImObject$1(object) {
|
|
950
|
+
for (const [key, value] of object) {
|
|
951
|
+
yield formatField$1(key, value, "observablehq--key");
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
__name(iterateImObject$1, "iterateImObject$1");
|
|
955
|
+
function formatPrototype(value) {
|
|
956
|
+
const item = document.createElement("div");
|
|
957
|
+
const span = item.appendChild(document.createElement("span"));
|
|
958
|
+
item.className = "observablehq--field";
|
|
959
|
+
span.className = "observablehq--prototype-key";
|
|
960
|
+
span.textContent = ` <prototype>`;
|
|
961
|
+
item.appendChild(document.createTextNode(": "));
|
|
962
|
+
item.appendChild(inspect$1(value, void 0, void 0, void 0, true));
|
|
963
|
+
return item;
|
|
964
|
+
}
|
|
965
|
+
__name(formatPrototype, "formatPrototype");
|
|
966
|
+
function formatField$1(key, value, className) {
|
|
967
|
+
const item = document.createElement("div");
|
|
968
|
+
const span = item.appendChild(document.createElement("span"));
|
|
969
|
+
item.className = "observablehq--field";
|
|
970
|
+
span.className = className;
|
|
971
|
+
span.textContent = ` ${key}`;
|
|
972
|
+
item.appendChild(document.createTextNode(": "));
|
|
973
|
+
item.appendChild(inspect$1(value));
|
|
974
|
+
return item;
|
|
975
|
+
}
|
|
976
|
+
__name(formatField$1, "formatField$1");
|
|
977
|
+
function formatMapField$1(key, value) {
|
|
978
|
+
const item = document.createElement("div");
|
|
979
|
+
item.className = "observablehq--field";
|
|
980
|
+
item.appendChild(document.createTextNode(" "));
|
|
981
|
+
item.appendChild(inspect$1(key));
|
|
982
|
+
item.appendChild(document.createTextNode(" => "));
|
|
983
|
+
item.appendChild(inspect$1(value));
|
|
984
|
+
return item;
|
|
985
|
+
}
|
|
986
|
+
__name(formatMapField$1, "formatMapField$1");
|
|
987
|
+
function formatSetField(value) {
|
|
988
|
+
const item = document.createElement("div");
|
|
989
|
+
item.className = "observablehq--field";
|
|
990
|
+
item.appendChild(document.createTextNode(" "));
|
|
991
|
+
item.appendChild(inspect$1(value));
|
|
992
|
+
return item;
|
|
993
|
+
}
|
|
994
|
+
__name(formatSetField, "formatSetField");
|
|
995
|
+
function hasSelection(elem) {
|
|
996
|
+
const sel = window.getSelection();
|
|
997
|
+
return sel.type === "Range" && (sel.containsNode(elem, true) || elem.contains(sel.anchorNode) || elem.contains(sel.focusNode));
|
|
998
|
+
}
|
|
999
|
+
__name(hasSelection, "hasSelection");
|
|
1000
|
+
function inspectCollapsed(object, shallow, name, proto) {
|
|
1001
|
+
let arrayish = isarray(object);
|
|
1002
|
+
let tag, fields, next, n;
|
|
1003
|
+
if (object instanceof Map) {
|
|
1004
|
+
if (object instanceof object.constructor) {
|
|
1005
|
+
tag = `Map(${object.size})`;
|
|
1006
|
+
fields = iterateMap;
|
|
1007
|
+
} else {
|
|
1008
|
+
tag = "Map()";
|
|
1009
|
+
fields = iterateObject;
|
|
1010
|
+
}
|
|
1011
|
+
} else if (object instanceof Set) {
|
|
1012
|
+
if (object instanceof object.constructor) {
|
|
1013
|
+
tag = `Set(${object.size})`;
|
|
1014
|
+
fields = iterateSet;
|
|
1015
|
+
} else {
|
|
1016
|
+
tag = "Set()";
|
|
1017
|
+
fields = iterateObject;
|
|
1018
|
+
}
|
|
1019
|
+
} else if (arrayish) {
|
|
1020
|
+
tag = `${object.constructor.name}(${object.length})`;
|
|
1021
|
+
fields = iterateArray;
|
|
1022
|
+
} else if (n = immutableName(object)) {
|
|
1023
|
+
tag = `Immutable.${n.name}${n.name === "Record" ? "" : `(${object.size})`}`;
|
|
1024
|
+
arrayish = n.arrayish;
|
|
1025
|
+
fields = n.arrayish ? iterateImArray : n.setish ? iterateImSet : iterateImObject;
|
|
1026
|
+
} else {
|
|
1027
|
+
tag = tagof(object);
|
|
1028
|
+
fields = iterateObject;
|
|
1029
|
+
}
|
|
1030
|
+
if (shallow) {
|
|
1031
|
+
const span2 = document.createElement("span");
|
|
1032
|
+
span2.className = "observablehq--shallow";
|
|
1033
|
+
if (name) {
|
|
1034
|
+
span2.appendChild(inspectName(name));
|
|
1035
|
+
}
|
|
1036
|
+
span2.appendChild(document.createTextNode(tag));
|
|
1037
|
+
span2.addEventListener("mouseup", function(event) {
|
|
1038
|
+
if (hasSelection(span2)) return;
|
|
1039
|
+
event.stopPropagation();
|
|
1040
|
+
replace(span2, inspectCollapsed(object));
|
|
1041
|
+
});
|
|
1042
|
+
return span2;
|
|
1043
|
+
}
|
|
1044
|
+
const span = document.createElement("span");
|
|
1045
|
+
span.className = "observablehq--collapsed";
|
|
1046
|
+
if (name) {
|
|
1047
|
+
span.appendChild(inspectName(name));
|
|
1048
|
+
}
|
|
1049
|
+
const a = span.appendChild(document.createElement("a"));
|
|
1050
|
+
a.innerHTML = `<svg width=8 height=8 class='observablehq--caret'>
|
|
1051
|
+
<path d='M7 4L1 8V0z' fill='currentColor' />
|
|
1052
|
+
</svg>`;
|
|
1053
|
+
a.appendChild(document.createTextNode(`${tag}${arrayish ? " [" : " {"}`));
|
|
1054
|
+
span.addEventListener("mouseup", function(event) {
|
|
1055
|
+
if (hasSelection(span)) return;
|
|
1056
|
+
event.stopPropagation();
|
|
1057
|
+
replace(span, inspectExpanded(object, null, name, proto));
|
|
1058
|
+
}, true);
|
|
1059
|
+
fields = fields(object);
|
|
1060
|
+
for (let i = 0; !(next = fields.next()).done && i < 20; ++i) {
|
|
1061
|
+
if (i > 0) span.appendChild(document.createTextNode(", "));
|
|
1062
|
+
span.appendChild(next.value);
|
|
1063
|
+
}
|
|
1064
|
+
if (!next.done) span.appendChild(document.createTextNode(", …"));
|
|
1065
|
+
span.appendChild(document.createTextNode(arrayish ? "]" : "}"));
|
|
1066
|
+
return span;
|
|
1067
|
+
}
|
|
1068
|
+
__name(inspectCollapsed, "inspectCollapsed");
|
|
1069
|
+
function* iterateMap(map2) {
|
|
1070
|
+
for (const [key, value] of map2) {
|
|
1071
|
+
yield formatMapField(key, value);
|
|
1072
|
+
}
|
|
1073
|
+
yield* iterateObject(map2);
|
|
1074
|
+
}
|
|
1075
|
+
__name(iterateMap, "iterateMap");
|
|
1076
|
+
function* iterateSet(set) {
|
|
1077
|
+
for (const value of set) {
|
|
1078
|
+
yield inspect$1(value, true);
|
|
1079
|
+
}
|
|
1080
|
+
yield* iterateObject(set);
|
|
1081
|
+
}
|
|
1082
|
+
__name(iterateSet, "iterateSet");
|
|
1083
|
+
function* iterateImSet(set) {
|
|
1084
|
+
for (const value of set) {
|
|
1085
|
+
yield inspect$1(value, true);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
__name(iterateImSet, "iterateImSet");
|
|
1089
|
+
function* iterateImArray(array) {
|
|
1090
|
+
let i0 = -1, i1 = 0;
|
|
1091
|
+
for (const n = array.size; i1 < n; ++i1) {
|
|
1092
|
+
if (i1 > i0 + 1) yield formatEmpty(i1 - i0 - 1);
|
|
1093
|
+
yield inspect$1(array.get(i1), true);
|
|
1094
|
+
i0 = i1;
|
|
1095
|
+
}
|
|
1096
|
+
if (i1 > i0 + 1) yield formatEmpty(i1 - i0 - 1);
|
|
1097
|
+
}
|
|
1098
|
+
__name(iterateImArray, "iterateImArray");
|
|
1099
|
+
function* iterateArray(array) {
|
|
1100
|
+
let i0 = -1, i1 = 0;
|
|
1101
|
+
for (const n = array.length; i1 < n; ++i1) {
|
|
1102
|
+
if (i1 in array) {
|
|
1103
|
+
if (i1 > i0 + 1) yield formatEmpty(i1 - i0 - 1);
|
|
1104
|
+
yield inspect$1(valueof$1(array, i1), true);
|
|
1105
|
+
i0 = i1;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
if (i1 > i0 + 1) yield formatEmpty(i1 - i0 - 1);
|
|
1109
|
+
for (const key in array) {
|
|
1110
|
+
if (!isindex(key) && isown(array, key)) {
|
|
1111
|
+
yield formatField(key, valueof$1(array, key), "observablehq--key");
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
for (const symbol of symbolsof(array)) {
|
|
1115
|
+
yield formatField(formatSymbol(symbol), valueof$1(array, symbol), "observablehq--symbol");
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
__name(iterateArray, "iterateArray");
|
|
1119
|
+
function* iterateObject(object) {
|
|
1120
|
+
for (const key in object) {
|
|
1121
|
+
if (isown(object, key)) {
|
|
1122
|
+
yield formatField(key, valueof$1(object, key), "observablehq--key");
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
for (const symbol of symbolsof(object)) {
|
|
1126
|
+
yield formatField(formatSymbol(symbol), valueof$1(object, symbol), "observablehq--symbol");
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
__name(iterateObject, "iterateObject");
|
|
1130
|
+
function* iterateImObject(object) {
|
|
1131
|
+
for (const [key, value] of object) {
|
|
1132
|
+
yield formatField(key, value, "observablehq--key");
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
__name(iterateImObject, "iterateImObject");
|
|
1136
|
+
function formatEmpty(e) {
|
|
1137
|
+
const span = document.createElement("span");
|
|
1138
|
+
span.className = "observablehq--empty";
|
|
1139
|
+
span.textContent = e === 1 ? "empty" : `empty × ${e}`;
|
|
1140
|
+
return span;
|
|
1141
|
+
}
|
|
1142
|
+
__name(formatEmpty, "formatEmpty");
|
|
1143
|
+
function formatField(key, value, className) {
|
|
1144
|
+
const fragment = document.createDocumentFragment();
|
|
1145
|
+
const span = fragment.appendChild(document.createElement("span"));
|
|
1146
|
+
span.className = className;
|
|
1147
|
+
span.textContent = key;
|
|
1148
|
+
fragment.appendChild(document.createTextNode(": "));
|
|
1149
|
+
fragment.appendChild(inspect$1(value, true));
|
|
1150
|
+
return fragment;
|
|
1151
|
+
}
|
|
1152
|
+
__name(formatField, "formatField");
|
|
1153
|
+
function formatMapField(key, value) {
|
|
1154
|
+
const fragment = document.createDocumentFragment();
|
|
1155
|
+
fragment.appendChild(inspect$1(key, true));
|
|
1156
|
+
fragment.appendChild(document.createTextNode(" => "));
|
|
1157
|
+
fragment.appendChild(inspect$1(value, true));
|
|
1158
|
+
return fragment;
|
|
1159
|
+
}
|
|
1160
|
+
__name(formatMapField, "formatMapField");
|
|
1161
|
+
function format(date, fallback) {
|
|
1162
|
+
if (!(date instanceof Date)) date = /* @__PURE__ */ new Date(+date);
|
|
1163
|
+
if (isNaN(date)) return typeof fallback === "function" ? fallback(date) : fallback;
|
|
1164
|
+
const hours = date.getUTCHours();
|
|
1165
|
+
const minutes = date.getUTCMinutes();
|
|
1166
|
+
const seconds = date.getUTCSeconds();
|
|
1167
|
+
const milliseconds = date.getUTCMilliseconds();
|
|
1168
|
+
return `${formatYear(date.getUTCFullYear())}-${pad(date.getUTCMonth() + 1, 2)}-${pad(date.getUTCDate(), 2)}${hours || minutes || seconds || milliseconds ? `T${pad(hours, 2)}:${pad(minutes, 2)}${seconds || milliseconds ? `:${pad(seconds, 2)}${milliseconds ? `.${pad(milliseconds, 3)}` : ``}` : ``}Z` : ``}`;
|
|
1169
|
+
}
|
|
1170
|
+
__name(format, "format");
|
|
1171
|
+
function formatYear(year) {
|
|
1172
|
+
return year < 0 ? `-${pad(-year, 6)}` : year > 9999 ? `+${pad(year, 6)}` : pad(year, 4);
|
|
1173
|
+
}
|
|
1174
|
+
__name(formatYear, "formatYear");
|
|
1175
|
+
function pad(value, width2) {
|
|
1176
|
+
return `${value}`.padStart(width2, "0");
|
|
1177
|
+
}
|
|
1178
|
+
__name(pad, "pad");
|
|
1179
|
+
function formatDate(date) {
|
|
1180
|
+
return format(date, "Invalid Date");
|
|
1181
|
+
}
|
|
1182
|
+
__name(formatDate, "formatDate");
|
|
1183
|
+
var errorToString = Error.prototype.toString;
|
|
1184
|
+
function formatError(value) {
|
|
1185
|
+
return value.stack || errorToString.call(value);
|
|
1186
|
+
}
|
|
1187
|
+
__name(formatError, "formatError");
|
|
1188
|
+
var regExpToString = RegExp.prototype.toString;
|
|
1189
|
+
function formatRegExp(value) {
|
|
1190
|
+
return regExpToString.call(value);
|
|
1191
|
+
}
|
|
1192
|
+
__name(formatRegExp, "formatRegExp");
|
|
1193
|
+
const NEWLINE_LIMIT = 20;
|
|
1194
|
+
function formatString(string, shallow, expanded, name) {
|
|
1195
|
+
if (shallow === false) {
|
|
1196
|
+
if (count$1(string, /["\n]/g) <= count$1(string, /`|\${/g)) {
|
|
1197
|
+
const span3 = document.createElement("span");
|
|
1198
|
+
if (name) span3.appendChild(inspectName(name));
|
|
1199
|
+
const textValue3 = span3.appendChild(document.createElement("span"));
|
|
1200
|
+
textValue3.className = "observablehq--string";
|
|
1201
|
+
textValue3.textContent = JSON.stringify(string);
|
|
1202
|
+
return span3;
|
|
1203
|
+
}
|
|
1204
|
+
const lines = string.split("\n");
|
|
1205
|
+
if (lines.length > NEWLINE_LIMIT && !expanded) {
|
|
1206
|
+
const div = document.createElement("div");
|
|
1207
|
+
if (name) div.appendChild(inspectName(name));
|
|
1208
|
+
const textValue3 = div.appendChild(document.createElement("span"));
|
|
1209
|
+
textValue3.className = "observablehq--string";
|
|
1210
|
+
textValue3.textContent = "`" + templatify(lines.slice(0, NEWLINE_LIMIT).join("\n"));
|
|
1211
|
+
const splitter = div.appendChild(document.createElement("span"));
|
|
1212
|
+
const truncatedCount = lines.length - NEWLINE_LIMIT;
|
|
1213
|
+
splitter.textContent = `Show ${truncatedCount} truncated line${truncatedCount > 1 ? "s" : ""}`;
|
|
1214
|
+
splitter.className = "observablehq--string-expand";
|
|
1215
|
+
splitter.addEventListener("mouseup", function(event) {
|
|
1216
|
+
event.stopPropagation();
|
|
1217
|
+
replace(div, inspect$1(string, shallow, true, name));
|
|
1218
|
+
});
|
|
1219
|
+
return div;
|
|
1220
|
+
}
|
|
1221
|
+
const span2 = document.createElement("span");
|
|
1222
|
+
if (name) span2.appendChild(inspectName(name));
|
|
1223
|
+
const textValue2 = span2.appendChild(document.createElement("span"));
|
|
1224
|
+
textValue2.className = `observablehq--string${expanded ? " observablehq--expanded" : ""}`;
|
|
1225
|
+
textValue2.textContent = "`" + templatify(string) + "`";
|
|
1226
|
+
return span2;
|
|
1227
|
+
}
|
|
1228
|
+
const span = document.createElement("span");
|
|
1229
|
+
if (name) span.appendChild(inspectName(name));
|
|
1230
|
+
const textValue = span.appendChild(document.createElement("span"));
|
|
1231
|
+
textValue.className = "observablehq--string";
|
|
1232
|
+
textValue.textContent = JSON.stringify(string.length > 100 ? `${string.slice(0, 50)}…${string.slice(-49)}` : string);
|
|
1233
|
+
return span;
|
|
1234
|
+
}
|
|
1235
|
+
__name(formatString, "formatString");
|
|
1236
|
+
function templatify(string) {
|
|
1237
|
+
return string.replace(/[\\`\x00-\x09\x0b-\x19]|\${/g, templatifyChar);
|
|
1238
|
+
}
|
|
1239
|
+
__name(templatify, "templatify");
|
|
1240
|
+
function templatifyChar(char) {
|
|
1241
|
+
var code = char.charCodeAt(0);
|
|
1242
|
+
switch (code) {
|
|
1243
|
+
case 8:
|
|
1244
|
+
return "\\b";
|
|
1245
|
+
case 9:
|
|
1246
|
+
return "\\t";
|
|
1247
|
+
case 11:
|
|
1248
|
+
return "\\v";
|
|
1249
|
+
case 12:
|
|
1250
|
+
return "\\f";
|
|
1251
|
+
case 13:
|
|
1252
|
+
return "\\r";
|
|
1253
|
+
}
|
|
1254
|
+
return code < 16 ? "\\x0" + code.toString(16) : code < 32 ? "\\x" + code.toString(16) : "\\" + char;
|
|
1255
|
+
}
|
|
1256
|
+
__name(templatifyChar, "templatifyChar");
|
|
1257
|
+
function count$1(string, re) {
|
|
1258
|
+
var n = 0;
|
|
1259
|
+
while (re.exec(string)) ++n;
|
|
1260
|
+
return n;
|
|
1261
|
+
}
|
|
1262
|
+
__name(count$1, "count$1");
|
|
1263
|
+
var toString$1 = Function.prototype.toString, TYPE_ASYNC = { prefix: "async ƒ" }, TYPE_ASYNC_GENERATOR = { prefix: "async ƒ*" }, TYPE_CLASS = { prefix: "class" }, TYPE_FUNCTION = { prefix: "ƒ" }, TYPE_GENERATOR = { prefix: "ƒ*" };
|
|
1264
|
+
function inspectFunction(f, name) {
|
|
1265
|
+
var type, m, t = toString$1.call(f);
|
|
1266
|
+
switch (f.constructor && f.constructor.name) {
|
|
1267
|
+
case "AsyncFunction":
|
|
1268
|
+
type = TYPE_ASYNC;
|
|
1269
|
+
break;
|
|
1270
|
+
case "AsyncGeneratorFunction":
|
|
1271
|
+
type = TYPE_ASYNC_GENERATOR;
|
|
1272
|
+
break;
|
|
1273
|
+
case "GeneratorFunction":
|
|
1274
|
+
type = TYPE_GENERATOR;
|
|
1275
|
+
break;
|
|
1276
|
+
default:
|
|
1277
|
+
type = /^class\b/.test(t) ? TYPE_CLASS : TYPE_FUNCTION;
|
|
1278
|
+
break;
|
|
1279
|
+
}
|
|
1280
|
+
if (type === TYPE_CLASS) {
|
|
1281
|
+
return formatFunction(type, "", name);
|
|
1282
|
+
}
|
|
1283
|
+
if (m = /^(?:async\s*)?(\w+)\s*=>/.exec(t)) {
|
|
1284
|
+
return formatFunction(type, "(" + m[1] + ")", name);
|
|
1285
|
+
}
|
|
1286
|
+
if (m = /^(?:async\s*)?\(\s*(\w+(?:\s*,\s*\w+)*)?\s*\)/.exec(t)) {
|
|
1287
|
+
return formatFunction(type, m[1] ? "(" + m[1].replace(/\s*,\s*/g, ", ") + ")" : "()", name);
|
|
1288
|
+
}
|
|
1289
|
+
if (m = /^(?:async\s*)?function(?:\s*\*)?(?:\s*\w+)?\s*\(\s*(\w+(?:\s*,\s*\w+)*)?\s*\)/.exec(t)) {
|
|
1290
|
+
return formatFunction(type, m[1] ? "(" + m[1].replace(/\s*,\s*/g, ", ") + ")" : "()", name);
|
|
1291
|
+
}
|
|
1292
|
+
return formatFunction(type, "(…)", name);
|
|
1293
|
+
}
|
|
1294
|
+
__name(inspectFunction, "inspectFunction");
|
|
1295
|
+
function formatFunction(type, args, cellname) {
|
|
1296
|
+
var span = document.createElement("span");
|
|
1297
|
+
span.className = "observablehq--function";
|
|
1298
|
+
if (cellname) {
|
|
1299
|
+
span.appendChild(inspectName(cellname));
|
|
1300
|
+
}
|
|
1301
|
+
var spanType = span.appendChild(document.createElement("span"));
|
|
1302
|
+
spanType.className = "observablehq--keyword";
|
|
1303
|
+
spanType.textContent = type.prefix;
|
|
1304
|
+
span.appendChild(document.createTextNode(args));
|
|
1305
|
+
return span;
|
|
1306
|
+
}
|
|
1307
|
+
__name(formatFunction, "formatFunction");
|
|
1308
|
+
const { prototype: { toString } } = Object;
|
|
1309
|
+
function inspect$1(value, shallow, expand, name, proto) {
|
|
1310
|
+
let type = typeof value;
|
|
1311
|
+
switch (type) {
|
|
1312
|
+
case "boolean":
|
|
1313
|
+
case "undefined": {
|
|
1314
|
+
value += "";
|
|
1315
|
+
break;
|
|
1316
|
+
}
|
|
1317
|
+
case "number": {
|
|
1318
|
+
value = value === 0 && 1 / value < 0 ? "-0" : value + "";
|
|
1319
|
+
break;
|
|
1320
|
+
}
|
|
1321
|
+
case "bigint": {
|
|
1322
|
+
value = value + "n";
|
|
1323
|
+
break;
|
|
1324
|
+
}
|
|
1325
|
+
case "symbol": {
|
|
1326
|
+
value = formatSymbol(value);
|
|
1327
|
+
break;
|
|
1328
|
+
}
|
|
1329
|
+
case "function": {
|
|
1330
|
+
return inspectFunction(value, name);
|
|
1331
|
+
}
|
|
1332
|
+
case "string": {
|
|
1333
|
+
return formatString(value, shallow, expand, name);
|
|
1334
|
+
}
|
|
1335
|
+
default: {
|
|
1336
|
+
if (value === null) {
|
|
1337
|
+
type = null, value = "null";
|
|
1338
|
+
break;
|
|
1339
|
+
}
|
|
1340
|
+
if (value instanceof Date) {
|
|
1341
|
+
type = "date", value = formatDate(value);
|
|
1342
|
+
break;
|
|
1343
|
+
}
|
|
1344
|
+
if (value === FORBIDDEN) {
|
|
1345
|
+
type = "forbidden", value = "[forbidden]";
|
|
1346
|
+
break;
|
|
1347
|
+
}
|
|
1348
|
+
switch (toString.call(value)) {
|
|
1349
|
+
case "[object RegExp]": {
|
|
1350
|
+
type = "regexp", value = formatRegExp(value);
|
|
1351
|
+
break;
|
|
1352
|
+
}
|
|
1353
|
+
case "[object Error]":
|
|
1354
|
+
// https://github.com/lodash/lodash/blob/master/isError.js#L26
|
|
1355
|
+
case "[object DOMException]": {
|
|
1356
|
+
type = "error", value = formatError(value);
|
|
1357
|
+
break;
|
|
1358
|
+
}
|
|
1359
|
+
default:
|
|
1360
|
+
return (expand ? inspectExpanded : inspectCollapsed)(value, shallow, name, proto);
|
|
1361
|
+
}
|
|
1362
|
+
break;
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
const span = document.createElement("span");
|
|
1366
|
+
if (name) span.appendChild(inspectName(name));
|
|
1367
|
+
const n = span.appendChild(document.createElement("span"));
|
|
1368
|
+
n.className = `observablehq--${type}`;
|
|
1369
|
+
n.textContent = value;
|
|
1370
|
+
return span;
|
|
1371
|
+
}
|
|
1372
|
+
__name(inspect$1, "inspect$1");
|
|
1373
|
+
function replace(spanOld, spanNew) {
|
|
1374
|
+
if (spanOld.classList.contains("observablehq--inspect")) spanNew.classList.add("observablehq--inspect");
|
|
1375
|
+
spanOld.parentNode.replaceChild(spanNew, spanOld);
|
|
1376
|
+
dispatch(spanNew, "load");
|
|
1377
|
+
}
|
|
1378
|
+
__name(replace, "replace");
|
|
1379
|
+
const LOCATION_MATCH = /\s+\(\d+:\d+\)$/m;
|
|
1380
|
+
const _Inspector = class _Inspector {
|
|
1381
|
+
constructor(node) {
|
|
1382
|
+
if (!node) throw new Error("invalid node");
|
|
1383
|
+
this._node = node;
|
|
1384
|
+
node.classList.add("observablehq");
|
|
1385
|
+
}
|
|
1386
|
+
pending() {
|
|
1387
|
+
const { _node } = this;
|
|
1388
|
+
_node.classList.remove("observablehq--error");
|
|
1389
|
+
_node.classList.add("observablehq--running");
|
|
1390
|
+
}
|
|
1391
|
+
fulfilled(value, name) {
|
|
1392
|
+
const { _node } = this;
|
|
1393
|
+
if (!isnode(value) || value.parentNode && value.parentNode !== _node) {
|
|
1394
|
+
value = inspect$1(value, false, _node.firstChild && _node.firstChild.classList && _node.firstChild.classList.contains("observablehq--expanded"), name);
|
|
1395
|
+
value.classList.add("observablehq--inspect");
|
|
1396
|
+
}
|
|
1397
|
+
_node.classList.remove("observablehq--running", "observablehq--error");
|
|
1398
|
+
if (_node.firstChild !== value) {
|
|
1399
|
+
if (_node.firstChild) {
|
|
1400
|
+
while (_node.lastChild !== _node.firstChild) _node.removeChild(_node.lastChild);
|
|
1401
|
+
_node.replaceChild(value, _node.firstChild);
|
|
1402
|
+
} else {
|
|
1403
|
+
_node.appendChild(value);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
dispatch(_node, "update");
|
|
1407
|
+
}
|
|
1408
|
+
rejected(error, name) {
|
|
1409
|
+
const { _node } = this;
|
|
1410
|
+
_node.classList.remove("observablehq--running");
|
|
1411
|
+
_node.classList.add("observablehq--error");
|
|
1412
|
+
while (_node.lastChild) _node.removeChild(_node.lastChild);
|
|
1413
|
+
var div = document.createElement("div");
|
|
1414
|
+
div.className = "observablehq--inspect";
|
|
1415
|
+
if (name) div.appendChild(inspectName(name));
|
|
1416
|
+
div.appendChild(document.createTextNode((error + "").replace(LOCATION_MATCH, "")));
|
|
1417
|
+
_node.appendChild(div);
|
|
1418
|
+
dispatch(_node, "error", { error });
|
|
1419
|
+
}
|
|
1420
|
+
};
|
|
1421
|
+
__name(_Inspector, "Inspector");
|
|
1422
|
+
let Inspector = _Inspector;
|
|
1423
|
+
Inspector.into = function(container) {
|
|
1424
|
+
if (typeof container === "string") {
|
|
1425
|
+
container = document.querySelector(container);
|
|
1426
|
+
if (container == null) throw new Error("container not found");
|
|
1427
|
+
}
|
|
1428
|
+
return function() {
|
|
1429
|
+
return new Inspector(container.appendChild(document.createElement("div")));
|
|
1430
|
+
};
|
|
1431
|
+
};
|
|
1432
|
+
function isnode(value) {
|
|
1433
|
+
return (value instanceof Element || value instanceof Text) && value instanceof value.constructor;
|
|
1434
|
+
}
|
|
1435
|
+
__name(isnode, "isnode");
|
|
1436
|
+
function inspect(value, expanded) {
|
|
1437
|
+
const node = document.createElement("div");
|
|
1438
|
+
new Inspector(node).fulfilled(value);
|
|
1439
|
+
if (expanded) {
|
|
1440
|
+
for (const path of expanded) {
|
|
1441
|
+
let child = node;
|
|
1442
|
+
for (const i of path)
|
|
1443
|
+
child = child?.childNodes[i];
|
|
1444
|
+
child?.dispatchEvent(new Event("mouseup"));
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
return node;
|
|
1448
|
+
}
|
|
1449
|
+
__name(inspect, "inspect");
|
|
1450
|
+
function inspectError(value) {
|
|
1451
|
+
const node = document.createElement("div");
|
|
1452
|
+
new Inspector(node).rejected(value);
|
|
1453
|
+
return node;
|
|
1454
|
+
}
|
|
1455
|
+
__name(inspectError, "inspectError");
|
|
1456
|
+
function getExpanded(node) {
|
|
1457
|
+
if (!isInspector(node))
|
|
1458
|
+
return;
|
|
1459
|
+
const expanded = node.querySelectorAll(".observablehq--expanded");
|
|
1460
|
+
if (expanded.length)
|
|
1461
|
+
return Array.from(expanded, (e) => getNodePath(node, e));
|
|
1462
|
+
}
|
|
1463
|
+
__name(getExpanded, "getExpanded");
|
|
1464
|
+
function isElement(node) {
|
|
1465
|
+
return node.nodeType === 1;
|
|
1466
|
+
}
|
|
1467
|
+
__name(isElement, "isElement");
|
|
1468
|
+
function isInspector(node) {
|
|
1469
|
+
return isElement(node) && node.classList.contains("observablehq");
|
|
1470
|
+
}
|
|
1471
|
+
__name(isInspector, "isInspector");
|
|
1472
|
+
function getNodePath(node, descendant) {
|
|
1473
|
+
const path = [];
|
|
1474
|
+
while (descendant !== node) {
|
|
1475
|
+
path.push(getChildIndex(descendant));
|
|
1476
|
+
descendant = descendant.parentNode;
|
|
1477
|
+
}
|
|
1478
|
+
return path.reverse();
|
|
1479
|
+
}
|
|
1480
|
+
__name(getNodePath, "getNodePath");
|
|
1481
|
+
function getChildIndex(node) {
|
|
1482
|
+
return Array.prototype.indexOf.call(node.parentNode.childNodes, node);
|
|
1483
|
+
}
|
|
1484
|
+
__name(getChildIndex, "getChildIndex");
|
|
1485
|
+
const SRC_SELECTOR = [
|
|
1486
|
+
"audio source[src]",
|
|
1487
|
+
// audio
|
|
1488
|
+
"audio[src]",
|
|
1489
|
+
// audio
|
|
1490
|
+
"img[src]",
|
|
1491
|
+
// images
|
|
1492
|
+
"picture source[src]",
|
|
1493
|
+
// images
|
|
1494
|
+
"video source[src]",
|
|
1495
|
+
// videos
|
|
1496
|
+
"video[src]"
|
|
1497
|
+
// videos
|
|
1498
|
+
].join();
|
|
1499
|
+
const SRCSET_SELECTOR = [
|
|
1500
|
+
"img[srcset]",
|
|
1501
|
+
// images
|
|
1502
|
+
"picture source[srcset]"
|
|
1503
|
+
// images
|
|
1504
|
+
].join();
|
|
1505
|
+
const HREF_SELECTOR = [
|
|
1506
|
+
"a[href][download]",
|
|
1507
|
+
// download links
|
|
1508
|
+
"link[href]"
|
|
1509
|
+
// stylesheets
|
|
1510
|
+
].join();
|
|
1511
|
+
const ASSET_ATTRIBUTES = [
|
|
1512
|
+
[SRC_SELECTOR, "src"],
|
|
1513
|
+
[SRCSET_SELECTOR, "srcset"],
|
|
1514
|
+
[HREF_SELECTOR, "href"]
|
|
1515
|
+
];
|
|
1516
|
+
function mapAssets(root2, assets) {
|
|
1517
|
+
const resolve2 = /* @__PURE__ */ __name((s) => assets.get(asImportPath(s)) ?? s, "resolve");
|
|
1518
|
+
for (const [selector, src] of ASSET_ATTRIBUTES) {
|
|
1519
|
+
for (const element of root2.querySelectorAll(selector)) {
|
|
1520
|
+
if (isRelExternal(element))
|
|
1521
|
+
continue;
|
|
1522
|
+
const source = decodeURI(element.getAttribute(src));
|
|
1523
|
+
if (src === "srcset")
|
|
1524
|
+
element.setAttribute(src, resolveSrcset(source, resolve2));
|
|
1525
|
+
else
|
|
1526
|
+
element.setAttribute(src, resolve2(source));
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
__name(mapAssets, "mapAssets");
|
|
1531
|
+
function isRelExternal(a) {
|
|
1532
|
+
return /(?:^|\s)external(?:\s|$)/i.test(a.getAttribute("rel") ?? "");
|
|
1533
|
+
}
|
|
1534
|
+
__name(isRelExternal, "isRelExternal");
|
|
1535
|
+
function asPath(source) {
|
|
1536
|
+
const i = source.indexOf("?");
|
|
1537
|
+
const j = source.indexOf("#");
|
|
1538
|
+
const k = i >= 0 && j >= 0 ? Math.min(i, j) : i >= 0 ? i : j;
|
|
1539
|
+
return k >= 0 ? source.slice(0, k) : source;
|
|
1540
|
+
}
|
|
1541
|
+
__name(asPath, "asPath");
|
|
1542
|
+
function asImportPath(source) {
|
|
1543
|
+
const path = asPath(source);
|
|
1544
|
+
return isImportPath(path) ? path : `./${path}`;
|
|
1545
|
+
}
|
|
1546
|
+
__name(asImportPath, "asImportPath");
|
|
1547
|
+
function isImportPath(specifier) {
|
|
1548
|
+
return ["./", "../", "/"].some((prefix) => specifier.startsWith(prefix));
|
|
1549
|
+
}
|
|
1550
|
+
__name(isImportPath, "isImportPath");
|
|
1551
|
+
function resolveSrcset(srcset, resolve2) {
|
|
1552
|
+
return srcset.trim().split(/\s*,\s*/).filter((src) => src).map((src) => {
|
|
1553
|
+
const parts = src.split(/\s+/);
|
|
1554
|
+
const path = resolve2(parts[0]);
|
|
1555
|
+
if (path)
|
|
1556
|
+
parts[0] = encodeURI(path);
|
|
1557
|
+
return parts.join(" ");
|
|
1558
|
+
}).join(", ");
|
|
1559
|
+
}
|
|
1560
|
+
__name(resolveSrcset, "resolveSrcset");
|
|
1561
|
+
function display(state, value) {
|
|
1562
|
+
const { root: root2, expanded } = state;
|
|
1563
|
+
const node = isDisplayable(value, root2) ? value : inspect(value, expanded[root2.childNodes.length]);
|
|
1564
|
+
displayNode(state, node);
|
|
1565
|
+
}
|
|
1566
|
+
__name(display, "display");
|
|
1567
|
+
function displayNode(state, node) {
|
|
1568
|
+
if (node.nodeType === 11) {
|
|
1569
|
+
let child;
|
|
1570
|
+
while (child = node.firstChild) {
|
|
1571
|
+
state.root.appendChild(child);
|
|
1572
|
+
}
|
|
1573
|
+
} else {
|
|
1574
|
+
state.root.appendChild(node);
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
__name(displayNode, "displayNode");
|
|
1578
|
+
function displayError(state, value) {
|
|
1579
|
+
displayNode(state, inspectError(value));
|
|
1580
|
+
}
|
|
1581
|
+
__name(displayError, "displayError");
|
|
1582
|
+
function isDisplayable(value, root2) {
|
|
1583
|
+
return (value instanceof Element || value instanceof Text) && value instanceof value.constructor && (!value.parentNode || root2.contains(value));
|
|
1584
|
+
}
|
|
1585
|
+
__name(isDisplayable, "isDisplayable");
|
|
1586
|
+
function clear(state) {
|
|
1587
|
+
state.autoclear = false;
|
|
1588
|
+
state.expanded = Array.from(state.root.childNodes, getExpanded);
|
|
1589
|
+
while (state.root.lastChild)
|
|
1590
|
+
state.root.lastChild.remove();
|
|
1591
|
+
}
|
|
1592
|
+
__name(clear, "clear");
|
|
1593
|
+
function observe$1(state, { autodisplay, assets }) {
|
|
1594
|
+
return {
|
|
1595
|
+
_error: false,
|
|
1596
|
+
_node: state.root,
|
|
1597
|
+
// _node for visibility promise
|
|
1598
|
+
pending() {
|
|
1599
|
+
if (this._error) {
|
|
1600
|
+
this._error = false;
|
|
1601
|
+
clear(state);
|
|
1602
|
+
}
|
|
1603
|
+
},
|
|
1604
|
+
fulfilled(value) {
|
|
1605
|
+
if (autodisplay) {
|
|
1606
|
+
if (assets && value instanceof Element)
|
|
1607
|
+
mapAssets(value, assets);
|
|
1608
|
+
clear(state);
|
|
1609
|
+
display(state, value);
|
|
1610
|
+
} else if (state.autoclear) {
|
|
1611
|
+
clear(state);
|
|
1612
|
+
}
|
|
1613
|
+
},
|
|
1614
|
+
rejected(error) {
|
|
1615
|
+
console.error(error);
|
|
1616
|
+
this._error = true;
|
|
1617
|
+
clear(state);
|
|
1618
|
+
displayError(state, error);
|
|
1619
|
+
}
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
__name(observe$1, "observe$1");
|
|
1623
|
+
async function* observe(initialize) {
|
|
1624
|
+
let resolve2;
|
|
1625
|
+
let value;
|
|
1626
|
+
let stale = false;
|
|
1627
|
+
const dispose = initialize((x) => {
|
|
1628
|
+
value = x;
|
|
1629
|
+
if (resolve2) {
|
|
1630
|
+
resolve2(x);
|
|
1631
|
+
resolve2 = void 0;
|
|
1632
|
+
} else {
|
|
1633
|
+
stale = true;
|
|
1634
|
+
}
|
|
1635
|
+
return x;
|
|
1636
|
+
});
|
|
1637
|
+
if (dispose != null && typeof dispose !== "function") {
|
|
1638
|
+
throw new Error(typeof dispose === "object" && "then" in dispose && typeof dispose.then === "function" ? "async initializers are not supported" : "initializer returned something, but not a dispose function");
|
|
1639
|
+
}
|
|
1640
|
+
try {
|
|
1641
|
+
while (true) {
|
|
1642
|
+
yield stale ? (stale = false, value) : new Promise((_2) => resolve2 = _2);
|
|
1643
|
+
}
|
|
1644
|
+
} finally {
|
|
1645
|
+
if (dispose != null) {
|
|
1646
|
+
dispose();
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
__name(observe, "observe");
|
|
1651
|
+
function input(element) {
|
|
1652
|
+
return observe((change) => {
|
|
1653
|
+
const event = eventof(element);
|
|
1654
|
+
const value = valueof(element);
|
|
1655
|
+
const inputted = /* @__PURE__ */ __name(() => change(valueof(element)), "inputted");
|
|
1656
|
+
element.addEventListener(event, inputted);
|
|
1657
|
+
if (value !== void 0)
|
|
1658
|
+
change(value);
|
|
1659
|
+
return () => element.removeEventListener(event, inputted);
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
__name(input, "input");
|
|
1663
|
+
function valueof(element) {
|
|
1664
|
+
const input2 = element;
|
|
1665
|
+
const select = element;
|
|
1666
|
+
if ("type" in element) {
|
|
1667
|
+
switch (element.type) {
|
|
1668
|
+
case "range":
|
|
1669
|
+
case "number":
|
|
1670
|
+
return input2.valueAsNumber;
|
|
1671
|
+
case "date":
|
|
1672
|
+
return input2.valueAsDate;
|
|
1673
|
+
case "checkbox":
|
|
1674
|
+
return input2.checked;
|
|
1675
|
+
case "file":
|
|
1676
|
+
return input2.multiple ? input2.files : input2.files[0];
|
|
1677
|
+
case "select-multiple":
|
|
1678
|
+
return Array.from(select.selectedOptions, (o) => o.value);
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
return input2.value;
|
|
1682
|
+
}
|
|
1683
|
+
__name(valueof, "valueof");
|
|
1684
|
+
function eventof(element) {
|
|
1685
|
+
if ("type" in element) {
|
|
1686
|
+
switch (element.type) {
|
|
1687
|
+
case "button":
|
|
1688
|
+
case "submit":
|
|
1689
|
+
case "checkbox":
|
|
1690
|
+
return "click";
|
|
1691
|
+
case "file":
|
|
1692
|
+
return "change";
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
return "input";
|
|
1696
|
+
}
|
|
1697
|
+
__name(eventof, "eventof");
|
|
1698
|
+
async function* now() {
|
|
1699
|
+
while (true) {
|
|
1700
|
+
yield Date.now();
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
__name(now, "now");
|
|
1704
|
+
async function* queue(initialize) {
|
|
1705
|
+
let resolve2;
|
|
1706
|
+
const values = [];
|
|
1707
|
+
const dispose = initialize((x) => {
|
|
1708
|
+
values.push(x);
|
|
1709
|
+
if (resolve2) {
|
|
1710
|
+
resolve2(values.shift());
|
|
1711
|
+
resolve2 = void 0;
|
|
1712
|
+
}
|
|
1713
|
+
return x;
|
|
1714
|
+
});
|
|
1715
|
+
if (dispose != null && typeof dispose !== "function") {
|
|
1716
|
+
throw new Error(typeof dispose === "object" && "then" in dispose && typeof dispose.then === "function" ? "async initializers are not supported" : "initializer returned something, but not a dispose function");
|
|
1717
|
+
}
|
|
1718
|
+
try {
|
|
1719
|
+
while (true) {
|
|
1720
|
+
yield values.length ? values.shift() : new Promise((_2) => resolve2 = _2);
|
|
1721
|
+
}
|
|
1722
|
+
} finally {
|
|
1723
|
+
if (dispose != null) {
|
|
1724
|
+
dispose();
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
__name(queue, "queue");
|
|
1729
|
+
function width(target, options) {
|
|
1730
|
+
return observe((notify) => {
|
|
1731
|
+
let width2;
|
|
1732
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
1733
|
+
const w = entry.contentRect.width;
|
|
1734
|
+
if (w !== width2)
|
|
1735
|
+
notify(width2 = w);
|
|
1736
|
+
});
|
|
1737
|
+
observer.observe(target, options);
|
|
1738
|
+
return () => observer.disconnect();
|
|
1739
|
+
});
|
|
1740
|
+
}
|
|
1741
|
+
__name(width, "width");
|
|
1742
|
+
const Generators = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1743
|
+
__proto__: null,
|
|
1744
|
+
input,
|
|
1745
|
+
now,
|
|
1746
|
+
observe,
|
|
1747
|
+
queue,
|
|
1748
|
+
width
|
|
1749
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1750
|
+
function Mutable(value) {
|
|
1751
|
+
let change;
|
|
1752
|
+
return Object.defineProperty(observe((_2) => {
|
|
1753
|
+
change = _2;
|
|
1754
|
+
if (value !== void 0)
|
|
1755
|
+
change(value);
|
|
1756
|
+
}), "value", {
|
|
1757
|
+
get: /* @__PURE__ */ __name(() => value, "get"),
|
|
1758
|
+
set: /* @__PURE__ */ __name((x) => (value = x, void change?.(value)), "set")
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
__name(Mutable, "Mutable");
|
|
1762
|
+
function Mutator(value) {
|
|
1763
|
+
const mutable = Mutable(value);
|
|
1764
|
+
return [
|
|
1765
|
+
mutable,
|
|
1766
|
+
{
|
|
1767
|
+
get value() {
|
|
1768
|
+
return mutable.value;
|
|
1769
|
+
},
|
|
1770
|
+
set value(v) {
|
|
1771
|
+
mutable.value = v;
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
];
|
|
1775
|
+
}
|
|
1776
|
+
__name(Mutator, "Mutator");
|
|
1777
|
+
function define(main2, state, definition, observer = observe$1) {
|
|
1778
|
+
const { id, body, inputs = [], outputs = [], output, autodisplay, autoview, automutable } = definition;
|
|
1779
|
+
const variables = state.variables;
|
|
1780
|
+
const v = main2.variable(observer(state, definition), { shadow: {} });
|
|
1781
|
+
const vid = output ?? (outputs.length ? `cell ${id}` : null);
|
|
1782
|
+
state.autoclear = true;
|
|
1783
|
+
if (inputs.includes("display") || inputs.includes("view")) {
|
|
1784
|
+
let displayVersion = -1;
|
|
1785
|
+
const vd = new v.constructor(2, v._module);
|
|
1786
|
+
vd.define(inputs.filter((i) => i !== "display" && i !== "view"), () => {
|
|
1787
|
+
const version = v._version;
|
|
1788
|
+
return (value) => {
|
|
1789
|
+
if (version < displayVersion)
|
|
1790
|
+
throw new Error("stale display");
|
|
1791
|
+
else if (state.variables[0] !== v)
|
|
1792
|
+
throw new Error("stale display");
|
|
1793
|
+
else if (version > displayVersion)
|
|
1794
|
+
clear(state);
|
|
1795
|
+
displayVersion = version;
|
|
1796
|
+
display(state, value);
|
|
1797
|
+
return value;
|
|
1798
|
+
};
|
|
1799
|
+
});
|
|
1800
|
+
v._shadow.set("display", vd);
|
|
1801
|
+
if (inputs.includes("view")) {
|
|
1802
|
+
const vv = new v.constructor(2, v._module, null, { shadow: {} });
|
|
1803
|
+
vv._shadow.set("display", vd);
|
|
1804
|
+
vv.define(["display"], (display2) => (value) => input(display2(value)));
|
|
1805
|
+
v._shadow.set("view", vv);
|
|
1806
|
+
}
|
|
1807
|
+
} else if (!autodisplay) {
|
|
1808
|
+
clear(state);
|
|
1809
|
+
}
|
|
1810
|
+
variables.push(v.define(vid, inputs, body));
|
|
1811
|
+
if (output != null) {
|
|
1812
|
+
if (autoview) {
|
|
1813
|
+
const o = unprefix(output, "viewof$");
|
|
1814
|
+
variables.push(main2.define(o, [output], input));
|
|
1815
|
+
} else if (automutable) {
|
|
1816
|
+
const o = unprefix(output, "mutable ");
|
|
1817
|
+
const x = `cell ${id}`;
|
|
1818
|
+
v.define(o, [x], ([mutable]) => mutable);
|
|
1819
|
+
variables.push(
|
|
1820
|
+
main2.define(output, inputs, body),
|
|
1821
|
+
// initial value
|
|
1822
|
+
main2.define(x, [output], Mutator),
|
|
1823
|
+
main2.define(`mutable$${o}`, [x], ([, mutator]) => mutator)
|
|
1824
|
+
);
|
|
1825
|
+
}
|
|
1826
|
+
} else {
|
|
1827
|
+
for (const o of outputs) {
|
|
1828
|
+
variables.push(main2.variable(true).define(o, [vid], (exports) => exports[o]));
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
__name(define, "define");
|
|
1833
|
+
function unprefix(name, prefix) {
|
|
1834
|
+
if (!name.startsWith(prefix))
|
|
1835
|
+
throw new Error(`expected ${prefix}: ${name}`);
|
|
1836
|
+
return name.slice(prefix.length);
|
|
1837
|
+
}
|
|
1838
|
+
__name(unprefix, "unprefix");
|
|
1839
|
+
const files = /* @__PURE__ */ new Map();
|
|
1840
|
+
const FileAttachment = /* @__PURE__ */ __name((name, base = document.baseURI) => {
|
|
1841
|
+
const href = new URL(name, base).href;
|
|
1842
|
+
let file = files.get(href);
|
|
1843
|
+
if (!file) {
|
|
1844
|
+
file = new FileAttachmentImpl(href, name.split("/").pop());
|
|
1845
|
+
files.set(href, file);
|
|
1846
|
+
}
|
|
1847
|
+
return file;
|
|
1848
|
+
}, "FileAttachment");
|
|
1849
|
+
async function fetchFile(file) {
|
|
1850
|
+
const response = await fetch(file.href);
|
|
1851
|
+
if (!response.ok)
|
|
1852
|
+
throw new Error(`Unable to load file: ${file.name}`);
|
|
1853
|
+
return response;
|
|
1854
|
+
}
|
|
1855
|
+
__name(fetchFile, "fetchFile");
|
|
1856
|
+
const _AbstractFile = class _AbstractFile {
|
|
1857
|
+
constructor(name, mimeType = guessMimeType(name), lastModified, size) {
|
|
1858
|
+
Object.defineProperty(this, "name", {
|
|
1859
|
+
enumerable: true,
|
|
1860
|
+
configurable: true,
|
|
1861
|
+
writable: true,
|
|
1862
|
+
value: void 0
|
|
1863
|
+
});
|
|
1864
|
+
Object.defineProperty(this, "mimeType", {
|
|
1865
|
+
enumerable: true,
|
|
1866
|
+
configurable: true,
|
|
1867
|
+
writable: true,
|
|
1868
|
+
value: void 0
|
|
1869
|
+
});
|
|
1870
|
+
Object.defineProperty(this, "lastModified", {
|
|
1871
|
+
enumerable: true,
|
|
1872
|
+
configurable: true,
|
|
1873
|
+
writable: true,
|
|
1874
|
+
value: void 0
|
|
1875
|
+
});
|
|
1876
|
+
Object.defineProperty(this, "size", {
|
|
1877
|
+
enumerable: true,
|
|
1878
|
+
configurable: true,
|
|
1879
|
+
writable: true,
|
|
1880
|
+
value: void 0
|
|
1881
|
+
});
|
|
1882
|
+
Object.defineProperties(this, {
|
|
1883
|
+
name: { value: `${name}`, enumerable: true },
|
|
1884
|
+
mimeType: { value: `${mimeType}`, enumerable: true },
|
|
1885
|
+
lastModified: { value: lastModified === void 0 ? void 0 : +lastModified, enumerable: true },
|
|
1886
|
+
// prettier-ignore
|
|
1887
|
+
size: { value: size === void 0 ? void 0 : +size, enumerable: true }
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
async url() {
|
|
1891
|
+
return this.href;
|
|
1892
|
+
}
|
|
1893
|
+
async blob() {
|
|
1894
|
+
return (await fetchFile(this)).blob();
|
|
1895
|
+
}
|
|
1896
|
+
async arrayBuffer() {
|
|
1897
|
+
return (await fetchFile(this)).arrayBuffer();
|
|
1898
|
+
}
|
|
1899
|
+
async text(encoding) {
|
|
1900
|
+
return encoding === void 0 ? (await fetchFile(this)).text() : new TextDecoder(encoding).decode(await this.arrayBuffer());
|
|
1901
|
+
}
|
|
1902
|
+
async json() {
|
|
1903
|
+
return (await fetchFile(this)).json();
|
|
1904
|
+
}
|
|
1905
|
+
async stream() {
|
|
1906
|
+
return (await fetchFile(this)).body;
|
|
1907
|
+
}
|
|
1908
|
+
async dsv({ delimiter = ",", array = false, typed = false } = {}) {
|
|
1909
|
+
const [text2, d32] = await Promise.all([this.text(), import("https://cdn.jsdelivr.net/npm/d3-dsv/+esm")]);
|
|
1910
|
+
const format2 = d32.dsvFormat(delimiter);
|
|
1911
|
+
const parse = array ? format2.parseRows : format2.parse;
|
|
1912
|
+
return parse(text2, typed && d32.autoType);
|
|
1913
|
+
}
|
|
1914
|
+
async csv(options) {
|
|
1915
|
+
return this.dsv({ ...options, delimiter: "," });
|
|
1916
|
+
}
|
|
1917
|
+
async tsv(options) {
|
|
1918
|
+
return this.dsv({ ...options, delimiter: " " });
|
|
1919
|
+
}
|
|
1920
|
+
async image(props) {
|
|
1921
|
+
const url = await this.url();
|
|
1922
|
+
return new Promise((resolve2, reject) => {
|
|
1923
|
+
const i = new Image();
|
|
1924
|
+
if (new URL(url, document.baseURI).origin !== location.origin)
|
|
1925
|
+
i.crossOrigin = "anonymous";
|
|
1926
|
+
Object.assign(i, props);
|
|
1927
|
+
i.onload = () => resolve2(i);
|
|
1928
|
+
i.onerror = () => reject(new Error(`Unable to load file: ${this.name}`));
|
|
1929
|
+
i.src = url;
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
async arrow() {
|
|
1933
|
+
const [Arrow2, response] = await Promise.all([import("https://cdn.jsdelivr.net/npm/apache-arrow@17.0.0/+esm"), fetchFile(this)]);
|
|
1934
|
+
return Arrow2.tableFromIPC(response);
|
|
1935
|
+
}
|
|
1936
|
+
async arquero(options) {
|
|
1937
|
+
let request;
|
|
1938
|
+
let from;
|
|
1939
|
+
switch (this.mimeType) {
|
|
1940
|
+
case "application/json":
|
|
1941
|
+
request = this.text();
|
|
1942
|
+
from = "fromJSON";
|
|
1943
|
+
break;
|
|
1944
|
+
// @ts-expect-error fall through
|
|
1945
|
+
case "text/tab-separated-values":
|
|
1946
|
+
if (options?.delimiter === void 0)
|
|
1947
|
+
options = { ...options, delimiter: " " };
|
|
1948
|
+
// fall through
|
|
1949
|
+
case "text/csv":
|
|
1950
|
+
request = this.text();
|
|
1951
|
+
from = "fromCSV";
|
|
1952
|
+
break;
|
|
1953
|
+
default:
|
|
1954
|
+
if (/\.arrow$/i.test(this.name)) {
|
|
1955
|
+
request = this.arrow();
|
|
1956
|
+
from = "fromArrow";
|
|
1957
|
+
} else if (/\.parquet$/i.test(this.name)) {
|
|
1958
|
+
request = this.parquet();
|
|
1959
|
+
from = "fromArrow";
|
|
1960
|
+
} else {
|
|
1961
|
+
throw new Error(`unable to determine Arquero loader: ${this.name}`);
|
|
1962
|
+
}
|
|
1963
|
+
break;
|
|
1964
|
+
}
|
|
1965
|
+
const [aq2, body] = await Promise.all([import("https://cdn.jsdelivr.net/npm/arquero/+esm"), request]);
|
|
1966
|
+
return aq2[from](body, options);
|
|
1967
|
+
}
|
|
1968
|
+
async parquet() {
|
|
1969
|
+
const [Arrow2, Parquet, buffer] = await Promise.all([import("https://cdn.jsdelivr.net/npm/apache-arrow@17.0.0/+esm"), import("https://cdn.jsdelivr.net/npm/parquet-wasm/+esm").then(async (Parquet2) => (await Parquet2.default("https://cdn.jsdelivr.net/npm/parquet-wasm/esm/parquet_wasm_bg.wasm"), Parquet2)), this.arrayBuffer()]);
|
|
1970
|
+
return Arrow2.tableFromIPC(Parquet.readParquet(new Uint8Array(buffer)).intoIPCStream());
|
|
1971
|
+
}
|
|
1972
|
+
async xml(mimeType = "application/xml") {
|
|
1973
|
+
return new DOMParser().parseFromString(await this.text(), mimeType);
|
|
1974
|
+
}
|
|
1975
|
+
async html() {
|
|
1976
|
+
return this.xml("text/html");
|
|
1977
|
+
}
|
|
1978
|
+
};
|
|
1979
|
+
__name(_AbstractFile, "AbstractFile");
|
|
1980
|
+
let AbstractFile = _AbstractFile;
|
|
1981
|
+
function guessMimeType(name) {
|
|
1982
|
+
const i = name.lastIndexOf(".");
|
|
1983
|
+
const j = name.lastIndexOf("/");
|
|
1984
|
+
const extension = i > 0 && (j < 0 || i > j) ? name.slice(i).toLowerCase() : "";
|
|
1985
|
+
switch (extension) {
|
|
1986
|
+
case ".csv":
|
|
1987
|
+
return "text/csv";
|
|
1988
|
+
case ".tsv":
|
|
1989
|
+
return "text/tab-separated-values";
|
|
1990
|
+
case ".json":
|
|
1991
|
+
return "application/json";
|
|
1992
|
+
case ".html":
|
|
1993
|
+
return "text/html";
|
|
1994
|
+
case ".xml":
|
|
1995
|
+
return "application/xml";
|
|
1996
|
+
case ".png":
|
|
1997
|
+
return "image/png";
|
|
1998
|
+
case ".jpg":
|
|
1999
|
+
return "image/jpg";
|
|
2000
|
+
case ".js":
|
|
2001
|
+
return "text/javascript";
|
|
2002
|
+
default:
|
|
2003
|
+
return "application/octet-stream";
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
__name(guessMimeType, "guessMimeType");
|
|
2007
|
+
const _FileAttachmentImpl = class _FileAttachmentImpl extends AbstractFile {
|
|
2008
|
+
constructor(href, name, mimeType, lastModified, size) {
|
|
2009
|
+
super(name, mimeType, lastModified, size);
|
|
2010
|
+
Object.defineProperty(this, "href", {
|
|
2011
|
+
enumerable: true,
|
|
2012
|
+
configurable: true,
|
|
2013
|
+
writable: true,
|
|
2014
|
+
value: void 0
|
|
2015
|
+
});
|
|
2016
|
+
Object.defineProperty(this, "href", { value: href });
|
|
2017
|
+
}
|
|
2018
|
+
};
|
|
2019
|
+
__name(_FileAttachmentImpl, "FileAttachmentImpl");
|
|
2020
|
+
let FileAttachmentImpl = _FileAttachmentImpl;
|
|
2021
|
+
Object.defineProperty(FileAttachmentImpl, "name", { value: "FileAttachment" });
|
|
2022
|
+
FileAttachment.prototype = FileAttachmentImpl.prototype;
|
|
2023
|
+
function fileAttachments(resolve2) {
|
|
2024
|
+
function FileAttachment2(name) {
|
|
2025
|
+
const result = resolve2(name += "");
|
|
2026
|
+
if (result == null)
|
|
2027
|
+
throw new Error(`File not found: ${name}`);
|
|
2028
|
+
if (typeof result === "object" && "url" in result) {
|
|
2029
|
+
const { url, mimeType } = result;
|
|
2030
|
+
return new FileAttachmentImpl(url, name, mimeType);
|
|
2031
|
+
}
|
|
2032
|
+
return new FileAttachmentImpl(result, name);
|
|
2033
|
+
}
|
|
2034
|
+
__name(FileAttachment2, "FileAttachment");
|
|
2035
|
+
FileAttachment2.prototype = FileAttachmentImpl.prototype;
|
|
2036
|
+
return FileAttachment2;
|
|
2037
|
+
}
|
|
2038
|
+
__name(fileAttachments, "fileAttachments");
|
|
2039
|
+
function sluggify(string, { length = 50, fallback = "untitled", separator = "-" } = {}) {
|
|
2040
|
+
const parts = string.normalize("NFD").replace(/[\u0300-\u036f'‘’]/g, "").toLowerCase().split(/\W+/g).filter(nonempty);
|
|
2041
|
+
let i = -1;
|
|
2042
|
+
for (let l = 0, n = parts.length; ++i < n; ) {
|
|
2043
|
+
if ((l += parts[i].length) + i > length) {
|
|
2044
|
+
parts[i] = parts[i].substring(0, length - l + parts[i].length - i);
|
|
2045
|
+
break;
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
return parts.slice(0, i + 1).filter(Boolean).join(separator) || fallback.slice(0, length);
|
|
2049
|
+
}
|
|
2050
|
+
__name(sluggify, "sluggify");
|
|
2051
|
+
function nonempty(string) {
|
|
2052
|
+
return string.length > 0;
|
|
2053
|
+
}
|
|
2054
|
+
__name(nonempty, "nonempty");
|
|
2055
|
+
async function sha256(input2) {
|
|
2056
|
+
const encoded = new TextEncoder().encode(input2);
|
|
2057
|
+
const buffer = await crypto.subtle.digest("SHA-256", encoded);
|
|
2058
|
+
return new Uint8Array(buffer).reduce((i, byte) => i << 8n | BigInt(byte), 0n);
|
|
2059
|
+
}
|
|
2060
|
+
__name(sha256, "sha256");
|
|
2061
|
+
function base36(int, length) {
|
|
2062
|
+
return int.toString(36).padStart(length, "0").slice(0, length);
|
|
2063
|
+
}
|
|
2064
|
+
__name(base36, "base36");
|
|
2065
|
+
async function hash(strings, ...params) {
|
|
2066
|
+
return base36(await sha256(JSON.stringify([strings, ...params])), 16);
|
|
2067
|
+
}
|
|
2068
|
+
__name(hash, "hash");
|
|
2069
|
+
async function nameHash(name) {
|
|
2070
|
+
return /^[\w-]+$/.test(name) ? name : `${sluggify(basename(name))}.${base36(await sha256(name), 8)}`;
|
|
2071
|
+
}
|
|
2072
|
+
__name(nameHash, "nameHash");
|
|
2073
|
+
function basename(name) {
|
|
2074
|
+
return name.replace(/^.*\//, "");
|
|
2075
|
+
}
|
|
2076
|
+
__name(basename, "basename");
|
|
2077
|
+
const DatabaseClient = /* @__PURE__ */ __name((name, options) => {
|
|
2078
|
+
return new DatabaseClientImpl(name, normalizeOptions(options));
|
|
2079
|
+
}, "DatabaseClient");
|
|
2080
|
+
function normalizeOptions({ id, since } = {}) {
|
|
2081
|
+
const options = {};
|
|
2082
|
+
if (id !== void 0)
|
|
2083
|
+
options.id = id;
|
|
2084
|
+
if (since !== void 0)
|
|
2085
|
+
options.since = new Date(since);
|
|
2086
|
+
return options;
|
|
2087
|
+
}
|
|
2088
|
+
__name(normalizeOptions, "normalizeOptions");
|
|
2089
|
+
const _DatabaseClientImpl = class _DatabaseClientImpl {
|
|
2090
|
+
constructor(name, options) {
|
|
2091
|
+
Object.defineProperty(this, "name", {
|
|
2092
|
+
enumerable: true,
|
|
2093
|
+
configurable: true,
|
|
2094
|
+
writable: true,
|
|
2095
|
+
value: void 0
|
|
2096
|
+
});
|
|
2097
|
+
Object.defineProperty(this, "options", {
|
|
2098
|
+
enumerable: true,
|
|
2099
|
+
configurable: true,
|
|
2100
|
+
writable: true,
|
|
2101
|
+
value: void 0
|
|
2102
|
+
});
|
|
2103
|
+
Object.defineProperties(this, {
|
|
2104
|
+
name: { value: name, enumerable: true },
|
|
2105
|
+
options: { value: options, enumerable: true }
|
|
2106
|
+
});
|
|
2107
|
+
}
|
|
2108
|
+
async sql(strings, ...params) {
|
|
2109
|
+
const path = await this.cachePath(strings, ...params);
|
|
2110
|
+
const response = await fetch(path);
|
|
2111
|
+
if (!response.ok)
|
|
2112
|
+
throw new Error(`failed to fetch: ${path}`);
|
|
2113
|
+
return await response.json().then(revive);
|
|
2114
|
+
}
|
|
2115
|
+
async cachePath(strings, ...params) {
|
|
2116
|
+
return `.observable/cache/${await nameHash(this.name)}-${await hash(strings, ...params)}.json`;
|
|
2117
|
+
}
|
|
2118
|
+
};
|
|
2119
|
+
__name(_DatabaseClientImpl, "DatabaseClientImpl");
|
|
2120
|
+
let DatabaseClientImpl = _DatabaseClientImpl;
|
|
2121
|
+
function revive({ rows, schema, date, ...meta }) {
|
|
2122
|
+
for (const column of schema) {
|
|
2123
|
+
switch (column.type) {
|
|
2124
|
+
case "bigint": {
|
|
2125
|
+
const { name } = column;
|
|
2126
|
+
for (const row of rows) {
|
|
2127
|
+
const value = row[name];
|
|
2128
|
+
if (value == null)
|
|
2129
|
+
continue;
|
|
2130
|
+
row[name] = Number(value);
|
|
2131
|
+
}
|
|
2132
|
+
break;
|
|
2133
|
+
}
|
|
2134
|
+
case "date": {
|
|
2135
|
+
const { name } = column;
|
|
2136
|
+
for (const row of rows) {
|
|
2137
|
+
const value = row[name];
|
|
2138
|
+
if (value == null)
|
|
2139
|
+
continue;
|
|
2140
|
+
row[name] = asDate(value);
|
|
2141
|
+
}
|
|
2142
|
+
break;
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
if (date != null)
|
|
2147
|
+
date = new Date(date);
|
|
2148
|
+
return Object.assign(rows, { schema, date }, meta);
|
|
2149
|
+
}
|
|
2150
|
+
__name(revive, "revive");
|
|
2151
|
+
function asDate(value) {
|
|
2152
|
+
return new Date(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?$/.test(value) ? value + "Z" : value);
|
|
2153
|
+
}
|
|
2154
|
+
__name(asDate, "asDate");
|
|
2155
|
+
DatabaseClient.revive = revive;
|
|
2156
|
+
DatabaseClient.prototype = DatabaseClientImpl.prototype;
|
|
2157
|
+
Object.defineProperty(DatabaseClientImpl, "name", { value: "DatabaseClient" });
|
|
2158
|
+
function canvas(width2, height) {
|
|
2159
|
+
const canvas2 = document.createElement("canvas");
|
|
2160
|
+
canvas2.width = width2;
|
|
2161
|
+
canvas2.height = height;
|
|
2162
|
+
return canvas2;
|
|
2163
|
+
}
|
|
2164
|
+
__name(canvas, "canvas");
|
|
2165
|
+
function context2d(width2, height, dpi = devicePixelRatio) {
|
|
2166
|
+
const canvas2 = document.createElement("canvas");
|
|
2167
|
+
canvas2.width = width2 * dpi;
|
|
2168
|
+
canvas2.height = height * dpi;
|
|
2169
|
+
canvas2.style.width = `${width2}px`;
|
|
2170
|
+
const context = canvas2.getContext("2d");
|
|
2171
|
+
context.scale(dpi, dpi);
|
|
2172
|
+
return context;
|
|
2173
|
+
}
|
|
2174
|
+
__name(context2d, "context2d");
|
|
2175
|
+
function svg$1(width2, height) {
|
|
2176
|
+
const svg2 = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
2177
|
+
svg2.setAttribute("viewBox", `0 0 ${width2} ${height}`);
|
|
2178
|
+
svg2.setAttribute("width", `${width2}`);
|
|
2179
|
+
svg2.setAttribute("height", `${height}`);
|
|
2180
|
+
return svg2;
|
|
2181
|
+
}
|
|
2182
|
+
__name(svg$1, "svg$1");
|
|
2183
|
+
function text$1(value) {
|
|
2184
|
+
return document.createTextNode(value);
|
|
2185
|
+
}
|
|
2186
|
+
__name(text$1, "text$1");
|
|
2187
|
+
let count = 0;
|
|
2188
|
+
function uid(name) {
|
|
2189
|
+
return new Id(`O-${name == null ? "" : `${name}-`}${++count}`);
|
|
2190
|
+
}
|
|
2191
|
+
__name(uid, "uid");
|
|
2192
|
+
const _Id = class _Id {
|
|
2193
|
+
constructor(id) {
|
|
2194
|
+
Object.defineProperty(this, "id", {
|
|
2195
|
+
enumerable: true,
|
|
2196
|
+
configurable: true,
|
|
2197
|
+
writable: true,
|
|
2198
|
+
value: void 0
|
|
2199
|
+
});
|
|
2200
|
+
Object.defineProperty(this, "href", {
|
|
2201
|
+
enumerable: true,
|
|
2202
|
+
configurable: true,
|
|
2203
|
+
writable: true,
|
|
2204
|
+
value: void 0
|
|
2205
|
+
});
|
|
2206
|
+
this.id = id;
|
|
2207
|
+
this.href = new URL(`#${id}`, location.href).href;
|
|
2208
|
+
}
|
|
2209
|
+
toString() {
|
|
2210
|
+
return `url(${this.href})`;
|
|
2211
|
+
}
|
|
2212
|
+
};
|
|
2213
|
+
__name(_Id, "Id");
|
|
2214
|
+
let Id = _Id;
|
|
2215
|
+
const DOM = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2216
|
+
__proto__: null,
|
|
2217
|
+
canvas,
|
|
2218
|
+
context2d,
|
|
2219
|
+
svg: svg$1,
|
|
2220
|
+
text: text$1,
|
|
2221
|
+
uid
|
|
2222
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
2223
|
+
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
2224
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
2225
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
2226
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
2227
|
+
};
|
|
2228
|
+
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
2229
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
2230
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
2231
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
2232
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
2233
|
+
};
|
|
2234
|
+
var _Observer_promise;
|
|
2235
|
+
const _Observer = class _Observer {
|
|
2236
|
+
constructor() {
|
|
2237
|
+
_Observer_promise.set(this, void 0);
|
|
2238
|
+
Object.defineProperty(this, "fulfilled", {
|
|
2239
|
+
enumerable: true,
|
|
2240
|
+
configurable: true,
|
|
2241
|
+
writable: true,
|
|
2242
|
+
value: void 0
|
|
2243
|
+
});
|
|
2244
|
+
Object.defineProperty(this, "rejected", {
|
|
2245
|
+
enumerable: true,
|
|
2246
|
+
configurable: true,
|
|
2247
|
+
writable: true,
|
|
2248
|
+
value: void 0
|
|
2249
|
+
});
|
|
2250
|
+
this.next();
|
|
2251
|
+
}
|
|
2252
|
+
async next() {
|
|
2253
|
+
const value = await __classPrivateFieldGet(this, _Observer_promise, "f");
|
|
2254
|
+
__classPrivateFieldSet(this, _Observer_promise, new Promise((res, rej) => (this.fulfilled = res, this.rejected = rej)), "f");
|
|
2255
|
+
return { done: false, value };
|
|
2256
|
+
}
|
|
2257
|
+
throw() {
|
|
2258
|
+
return { done: true };
|
|
2259
|
+
}
|
|
2260
|
+
return() {
|
|
2261
|
+
return { done: true };
|
|
2262
|
+
}
|
|
2263
|
+
};
|
|
2264
|
+
__name(_Observer, "Observer");
|
|
2265
|
+
let Observer = _Observer;
|
|
2266
|
+
_Observer_promise = /* @__PURE__ */ new WeakMap();
|
|
2267
|
+
const _ = /* @__PURE__ */ __name(() => import("https://cdn.jsdelivr.net/npm/lodash/+esm").then((_2) => _2.default), "_");
|
|
2268
|
+
const aq = /* @__PURE__ */ __name(() => import("https://cdn.jsdelivr.net/npm/arquero/+esm"), "aq");
|
|
2269
|
+
const Arrow = /* @__PURE__ */ __name(() => import("https://cdn.jsdelivr.net/npm/apache-arrow@17.0.0/+esm"), "Arrow");
|
|
2270
|
+
const d3 = /* @__PURE__ */ __name(() => import("https://cdn.jsdelivr.net/npm/d3/+esm"), "d3");
|
|
2271
|
+
const dot = /* @__PURE__ */ __name(() => import("./dot-DK4iDc2-.js").then((_2) => _2.dot), "dot");
|
|
2272
|
+
const duckdb = /* @__PURE__ */ __name(() => import("https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@1.29.0/+esm"), "duckdb");
|
|
2273
|
+
const DuckDBClient = /* @__PURE__ */ __name(() => import("./duckdb-DkM9_nXT.js").then((_2) => _2.DuckDBClient), "DuckDBClient");
|
|
2274
|
+
const echarts = /* @__PURE__ */ __name(() => import("https://cdn.jsdelivr.net/npm/echarts/dist/echarts.esm.min.js/+esm"), "echarts");
|
|
2275
|
+
const htl = /* @__PURE__ */ __name(() => import("https://cdn.jsdelivr.net/npm/htl/+esm"), "htl");
|
|
2276
|
+
const html = /* @__PURE__ */ __name(() => import("https://cdn.jsdelivr.net/npm/htl/+esm").then((_2) => _2.html), "html");
|
|
2277
|
+
const svg = /* @__PURE__ */ __name(() => import("https://cdn.jsdelivr.net/npm/htl/+esm").then((_2) => _2.svg), "svg");
|
|
2278
|
+
const Inputs = /* @__PURE__ */ __name(() => import("./inputs-CsCXZHQ8.js"), "Inputs");
|
|
2279
|
+
const L = /* @__PURE__ */ __name(() => import("./leaflet-CkvVhxBL.js"), "L");
|
|
2280
|
+
const mapboxgl = /* @__PURE__ */ __name(() => import("./mapboxgl-C0i2HzjJ.js").then((_2) => _2.default), "mapboxgl");
|
|
2281
|
+
const md = /* @__PURE__ */ __name(() => import("./md-Bxvu6Hld.js").then((_2) => _2.md), "md");
|
|
2282
|
+
const mermaid = /* @__PURE__ */ __name(() => import("./mermaid-CFg6sgdO.js").then((_2) => _2.mermaid), "mermaid");
|
|
2283
|
+
const Plot = /* @__PURE__ */ __name(() => import("https://cdn.jsdelivr.net/npm/@observablehq/plot/+esm"), "Plot");
|
|
2284
|
+
const React = /* @__PURE__ */ __name(() => import("https://cdn.jsdelivr.net/npm/react/+esm"), "React");
|
|
2285
|
+
const ReactDOM = /* @__PURE__ */ __name(() => import("https://cdn.jsdelivr.net/npm/react-dom/client/+esm"), "ReactDOM");
|
|
2286
|
+
const tex = /* @__PURE__ */ __name(() => import("./tex-ayRXOMLZ.js").then((_2) => _2.tex), "tex");
|
|
2287
|
+
const topojson = /* @__PURE__ */ __name(() => import("https://cdn.jsdelivr.net/npm/topojson-client/+esm"), "topojson");
|
|
2288
|
+
const vl = /* @__PURE__ */ __name(() => import("./vega-lite-CESXoehe.js").then((_2) => _2.vl), "vl");
|
|
2289
|
+
const recommendedLibraries = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2290
|
+
__proto__: null,
|
|
2291
|
+
Arrow,
|
|
2292
|
+
DuckDBClient,
|
|
2293
|
+
Inputs,
|
|
2294
|
+
L,
|
|
2295
|
+
Plot,
|
|
2296
|
+
React,
|
|
2297
|
+
ReactDOM,
|
|
2298
|
+
_,
|
|
2299
|
+
aq,
|
|
2300
|
+
d3,
|
|
2301
|
+
dot,
|
|
2302
|
+
duckdb,
|
|
2303
|
+
echarts,
|
|
2304
|
+
htl,
|
|
2305
|
+
html,
|
|
2306
|
+
mapboxgl,
|
|
2307
|
+
md,
|
|
2308
|
+
mermaid,
|
|
2309
|
+
svg,
|
|
2310
|
+
tex,
|
|
2311
|
+
topojson,
|
|
2312
|
+
vl
|
|
2313
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
2314
|
+
require2.resolve = resolve;
|
|
2315
|
+
function require2(...specifiers) {
|
|
2316
|
+
return specifiers.length === 1 ? import(
|
|
2317
|
+
/* @vite-ignore */
|
|
2318
|
+
resolve(specifiers[0])
|
|
2319
|
+
) : Promise.all(specifiers.map((s) => require2(s))).then((modules) => Object.assign({}, ...modules));
|
|
2320
|
+
}
|
|
2321
|
+
__name(require2, "require");
|
|
2322
|
+
function parseNpmSpecifier(specifier) {
|
|
2323
|
+
const parts = specifier.split("/");
|
|
2324
|
+
const namerange = specifier.startsWith("@") ? [parts.shift(), parts.shift()].join("/") : parts.shift();
|
|
2325
|
+
const ranged = namerange.indexOf("@", 1);
|
|
2326
|
+
const name = ranged > 0 ? namerange.slice(0, ranged) : namerange;
|
|
2327
|
+
const range = ranged > 0 ? namerange.slice(ranged) : "";
|
|
2328
|
+
const path = parts.length > 0 ? `/${parts.join("/")}` : "";
|
|
2329
|
+
return { name, range, path };
|
|
2330
|
+
}
|
|
2331
|
+
__name(parseNpmSpecifier, "parseNpmSpecifier");
|
|
2332
|
+
function resolve(_specifier) {
|
|
2333
|
+
const specifier = String(_specifier);
|
|
2334
|
+
if (isProtocol(specifier) || isLocal(specifier))
|
|
2335
|
+
return specifier;
|
|
2336
|
+
const { name, range, path } = parseNpmSpecifier(specifier);
|
|
2337
|
+
return `https://cdn.jsdelivr.net/npm/${name}${range}${path + (isFile(path) || isDirectory(path) ? "" : "/+esm")}`;
|
|
2338
|
+
}
|
|
2339
|
+
__name(resolve, "resolve");
|
|
2340
|
+
function isProtocol(specifier) {
|
|
2341
|
+
return /^\w+:/.test(specifier);
|
|
2342
|
+
}
|
|
2343
|
+
__name(isProtocol, "isProtocol");
|
|
2344
|
+
function isLocal(specifier) {
|
|
2345
|
+
return /^(\.\/|\.\.\/|\/)/.test(specifier);
|
|
2346
|
+
}
|
|
2347
|
+
__name(isLocal, "isLocal");
|
|
2348
|
+
function isFile(specifier) {
|
|
2349
|
+
return /(\.\w*)$/.test(specifier);
|
|
2350
|
+
}
|
|
2351
|
+
__name(isFile, "isFile");
|
|
2352
|
+
function isDirectory(specifier) {
|
|
2353
|
+
return /(\/)$/.test(specifier);
|
|
2354
|
+
}
|
|
2355
|
+
__name(isDirectory, "isDirectory");
|
|
2356
|
+
const aapl = /* @__PURE__ */ __name(() => csv(dataset("aapl.csv")), "aapl");
|
|
2357
|
+
const alphabet = /* @__PURE__ */ __name(() => csv(dataset("alphabet.csv")), "alphabet");
|
|
2358
|
+
const cars = /* @__PURE__ */ __name(() => csv(dataset("cars.csv")), "cars");
|
|
2359
|
+
const citywages = /* @__PURE__ */ __name(() => csv(dataset("citywages.csv")), "citywages");
|
|
2360
|
+
const diamonds = /* @__PURE__ */ __name(() => csv(dataset("diamonds.csv")), "diamonds");
|
|
2361
|
+
const flare = /* @__PURE__ */ __name(() => csv(dataset("flare.csv")), "flare");
|
|
2362
|
+
const industries = /* @__PURE__ */ __name(() => csv(dataset("industries.csv")), "industries");
|
|
2363
|
+
const miserables = /* @__PURE__ */ __name(() => json(dataset("miserables.json")), "miserables");
|
|
2364
|
+
const olympians = /* @__PURE__ */ __name(() => csv(dataset("olympians.csv")), "olympians");
|
|
2365
|
+
const penguins = /* @__PURE__ */ __name(() => csv(dataset("penguins.csv")), "penguins");
|
|
2366
|
+
const pizza = /* @__PURE__ */ __name(() => csv(dataset("pizza.csv")), "pizza");
|
|
2367
|
+
const weather = /* @__PURE__ */ __name(() => csv(dataset("weather.csv")), "weather");
|
|
2368
|
+
function dataset(name) {
|
|
2369
|
+
return `https://cdn.jsdelivr.net/npm/@observablehq/sample-datasets/${name}`;
|
|
2370
|
+
}
|
|
2371
|
+
__name(dataset, "dataset");
|
|
2372
|
+
async function json(url) {
|
|
2373
|
+
const response = await fetch(url);
|
|
2374
|
+
if (!response.ok)
|
|
2375
|
+
throw new Error(`unable to fetch ${url}: status ${response.status}`);
|
|
2376
|
+
return response.json();
|
|
2377
|
+
}
|
|
2378
|
+
__name(json, "json");
|
|
2379
|
+
async function text(url) {
|
|
2380
|
+
const response = await fetch(url);
|
|
2381
|
+
if (!response.ok)
|
|
2382
|
+
throw new Error(`unable to fetch ${url}: status ${response.status}`);
|
|
2383
|
+
return response.text();
|
|
2384
|
+
}
|
|
2385
|
+
__name(text, "text");
|
|
2386
|
+
async function csv(url, typed) {
|
|
2387
|
+
const [contents, d32] = await Promise.all([text(url), import("https://cdn.jsdelivr.net/npm/d3-dsv/+esm")]);
|
|
2388
|
+
return d32.csvParse(contents, d32.autoType);
|
|
2389
|
+
}
|
|
2390
|
+
__name(csv, "csv");
|
|
2391
|
+
const sampleDatasets = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2392
|
+
__proto__: null,
|
|
2393
|
+
aapl,
|
|
2394
|
+
alphabet,
|
|
2395
|
+
cars,
|
|
2396
|
+
citywages,
|
|
2397
|
+
diamonds,
|
|
2398
|
+
flare,
|
|
2399
|
+
industries,
|
|
2400
|
+
miserables,
|
|
2401
|
+
olympians,
|
|
2402
|
+
penguins,
|
|
2403
|
+
pizza,
|
|
2404
|
+
weather
|
|
2405
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
2406
|
+
const root = document.querySelector("main") ?? document.body;
|
|
2407
|
+
const library = {
|
|
2408
|
+
now: /* @__PURE__ */ __name(() => now(), "now"),
|
|
2409
|
+
width: /* @__PURE__ */ __name(() => width(root), "width"),
|
|
2410
|
+
DatabaseClient: /* @__PURE__ */ __name(() => DatabaseClient, "DatabaseClient"),
|
|
2411
|
+
FileAttachment: /* @__PURE__ */ __name(() => FileAttachment, "FileAttachment"),
|
|
2412
|
+
Generators: /* @__PURE__ */ __name(() => Generators, "Generators"),
|
|
2413
|
+
Mutable: /* @__PURE__ */ __name(() => Mutable, "Mutable"),
|
|
2414
|
+
DOM: /* @__PURE__ */ __name(() => DOM, "DOM"),
|
|
2415
|
+
// deprecated!
|
|
2416
|
+
require: /* @__PURE__ */ __name(() => require2, "require"),
|
|
2417
|
+
// deprecated!
|
|
2418
|
+
__ojs_observer: /* @__PURE__ */ __name(() => () => new Observer(), "__ojs_observer"),
|
|
2419
|
+
...recommendedLibraries,
|
|
2420
|
+
...sampleDatasets
|
|
2421
|
+
};
|
|
2422
|
+
let NotebookRuntime$1 = (_a = class {
|
|
2423
|
+
constructor(builtins = library) {
|
|
2424
|
+
Object.defineProperty(this, "runtime", {
|
|
2425
|
+
enumerable: true,
|
|
2426
|
+
configurable: true,
|
|
2427
|
+
writable: true,
|
|
2428
|
+
value: void 0
|
|
2429
|
+
});
|
|
2430
|
+
Object.defineProperty(this, "main", {
|
|
2431
|
+
enumerable: true,
|
|
2432
|
+
configurable: true,
|
|
2433
|
+
writable: true,
|
|
2434
|
+
value: void 0
|
|
2435
|
+
});
|
|
2436
|
+
const runtime = new Runtime({ ...builtins, __ojs_runtime: /* @__PURE__ */ __name(() => runtime, "__ojs_runtime") });
|
|
2437
|
+
this.runtime = Object.assign(runtime, { fileAttachments });
|
|
2438
|
+
this.main = runtime.module();
|
|
2439
|
+
}
|
|
2440
|
+
define(state, definition, observer) {
|
|
2441
|
+
define(this.main, state, definition, observer);
|
|
2442
|
+
}
|
|
2443
|
+
}, __name(_a, "NotebookRuntime"), _a);
|
|
2444
|
+
const defaultNotebook = new NotebookRuntime$1();
|
|
2445
|
+
defaultNotebook.runtime;
|
|
2446
|
+
const main = defaultNotebook.main;
|
|
2447
|
+
defaultNotebook.define.bind(defaultNotebook);
|
|
2448
|
+
main.constructor.prototype.defines = function(name) {
|
|
2449
|
+
return this._scope.has(name) || this._builtins.has(name) || this._runtime._builtin._scope.has(name);
|
|
2450
|
+
};
|
|
2451
|
+
const _NotebookRuntime = class _NotebookRuntime extends NotebookRuntime$1 {
|
|
2452
|
+
stateById = /* @__PURE__ */ new Map();
|
|
2453
|
+
constructor() {
|
|
2454
|
+
super();
|
|
2455
|
+
}
|
|
2456
|
+
has(cellId) {
|
|
2457
|
+
return this.stateById.has(cellId);
|
|
2458
|
+
}
|
|
2459
|
+
async add(cellId, definition, placeholderDiv) {
|
|
2460
|
+
let state = this.stateById.get(cellId);
|
|
2461
|
+
if (state) {
|
|
2462
|
+
this.remove(cellId);
|
|
2463
|
+
}
|
|
2464
|
+
state = { root: placeholderDiv, expanded: [], variables: [] };
|
|
2465
|
+
this.stateById.set(cellId, state);
|
|
2466
|
+
this.define(state, definition);
|
|
2467
|
+
await this.runtime._computeNow();
|
|
2468
|
+
}
|
|
2469
|
+
async remove(cellId) {
|
|
2470
|
+
const state = this.stateById.get(cellId);
|
|
2471
|
+
if (!state) return;
|
|
2472
|
+
[...state.variables].forEach((v) => v.delete());
|
|
2473
|
+
this.stateById.delete(cellId);
|
|
2474
|
+
state.root?.remove();
|
|
2475
|
+
await this.runtime._computeNow();
|
|
2476
|
+
}
|
|
2477
|
+
async removeAll() {
|
|
2478
|
+
const keys = [...this.stateById.keys()];
|
|
2479
|
+
for (const key of keys) {
|
|
2480
|
+
this.remove(key);
|
|
2481
|
+
}
|
|
2482
|
+
await this.runtime._computeNow();
|
|
2483
|
+
}
|
|
2484
|
+
render(definitions, target) {
|
|
2485
|
+
definitions.forEach((definition) => {
|
|
2486
|
+
const placeholderDiv = document.createElement("div");
|
|
2487
|
+
placeholderDiv.id = `cell-${definition.id}`;
|
|
2488
|
+
placeholderDiv.className = "observablehq observablehq--cell";
|
|
2489
|
+
this.stateById.set(definition.id, { root: placeholderDiv, expanded: [], variables: [] });
|
|
2490
|
+
this.define(this.stateById.get(definition.id), definition);
|
|
2491
|
+
target.appendChild(placeholderDiv);
|
|
2492
|
+
});
|
|
2493
|
+
}
|
|
2494
|
+
};
|
|
2495
|
+
__name(_NotebookRuntime, "NotebookRuntime");
|
|
2496
|
+
let NotebookRuntime = _NotebookRuntime;
|
|
2497
|
+
export {
|
|
2498
|
+
NotebookRuntime
|
|
2499
|
+
};
|
|
2500
|
+
//# sourceMappingURL=runtime.js.map
|
|
2501
|
+
!function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('@import"https://cdn.jsdelivr.net/npm/@observablehq/inputs/dist/index.css";:root{--serif: "Source Serif 4", "Iowan Old Style", "Apple Garamond", "Palatino Linotype", "Times New Roman", "Droid Serif", Times, serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";--sans-serif: "Inter", -apple-system, BlinkMacSystemFont, "avenir next", avenir, helvetica, "helvetica neue", ubuntu, roboto, noto, "segoe ui", arial, sans-serif;--monospace: "Spline Sans Mono", Menlo, Consolas, monospace;--monospace-font: 14px/1.5 var(--monospace);--max-width: 960px }html{font:17px/1.5 var(--serif);-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background:var(--theme-background);color:var(--theme-foreground);margin:16px 0;padding:16px 24px}body{margin:auto;max-width:var(--max-width)}h1,h2,h3,h4,h5,h6{color:var(--theme-foreground-alt);font-weight:700;line-height:1.15;margin-top:0;margin-bottom:.25rem;text-wrap:balance}h2+p,h3+p,h4+p,h2+table,h3+table,h4+table{margin-top:0}.observablehq:first-of-type h1+h2{color:var(--theme-foreground);font-size:20px;font-style:italic;font-weight:400;margin-bottom:1rem}a[href]{color:var(--theme-foreground-focus);text-decoration:none}a[href]:hover,a[href]:focus{text-decoration:underline}pre,code,tt{font-family:var(--monospace);font-size:82.35294117%}pre code,figcaption code{font-size:inherit}pre[data-language]{position:relative}pre[data-language]:before{content:attr(data-language);float:right;margin:-4px -8px -4px -4px;padding:4px;font-size:12px;line-height:21px;color:var(--theme-foreground-muted)}h1 code,h2 code,h3 code,h4 code,h5 code,h6 code{font-size:88.235294117%}h2[id] a[href],h3[id] a[href]{color:inherit}pre{line-height:1.5}img{max-width:100%}p,table,figure,figcaption,h1,h2,h3,h4,h5,h6,.katex-display{max-width:640px}blockquote,ol,ul{max-width:600px}blockquote{margin:1rem 1.5rem}ul,ol{padding-left:28px}hr{height:1px;margin:1rem 0;padding:1rem 0;border:none;background:no-repeat center/100% 1px linear-gradient(to right,var(--theme-foreground-faintest),var(--theme-foreground-faintest))}pre{background-color:var(--theme-background-alt);border-radius:4px;margin:1rem -1rem;min-height:1.5em;padding:4px 1rem;overflow-x:auto;box-sizing:border-box;white-space:pre-wrap}input:not([type]),input[type=email],input[type=number],input[type=password],input[type=range],input[type=search],input[type=tel],input[type=text],input[type=url]{width:240px}input,canvas,button{vertical-align:middle}button,input,textarea{accent-color:var(--theme-foreground-focus)}table{width:100%;border-collapse:collapse;font:13px/1.2 var(--sans-serif)}table pre,table code,table tt{font-size:inherit;line-height:inherit}th>pre:only-child,td>pre:only-child{margin:0;padding:0}th{color:var(--theme-foreground);text-align:left;vertical-align:bottom}td{color:var(--theme-foreground-alt);vertical-align:top}th,td{padding:3px 6.5px 3px 0}th:last-child,td:last-child{padding-right:0}tr:not(:last-child){border-bottom:solid 1px var(--theme-foreground-faintest)}thead tr{border-bottom:solid 1px var(--theme-foreground-fainter)}figure,table{margin:1rem 0}figure img{max-width:100%}figure>h2,figure>h3{font-family:var(--sans-serif)}figure>h2{font-size:20px}figure>h3{font-size:16px;font-weight:400}figcaption{font:small var(--sans-serif);color:var(--theme-foreground-muted)}.observablehq--collapsed,.observablehq--expanded.observablehq--inspect a{cursor:pointer}.observablehq--caret{margin-right:4px;vertical-align:baseline}.observablehq--field{text-indent:-1rem;margin-left:1rem}.observablehq--inspect{font:var(--monospace-font);overflow-x:auto;white-space:pre;display:block;padding:2px 0}.observablehq--inspect.observablehq--import{white-space:normal}.observablehq--inspect::-webkit-scrollbar{display:none}.observablehq--error .observablehq--inspect{word-break:break-all;white-space:pre-wrap}.observablehq--string-expand{margin-left:6px;padding:2px 6px;border-radius:2px;font-size:80%;background:var(--theme-background-alt);cursor:pointer;vertical-align:middle}.observablehq--keyword{color:var(--syntax-keyword)}.observablehq--index,.observablehq--key{color:var(--syntax-definition)}.observablehq--symbol,.observablehq--regexp,.observablehq--string{color:var(--syntax-string)}.observablehq--null{color:var(--syntax-keyword)}.observablehq--undefined{color:var(--syntax-variable)}.observablehq--prototype-key{color:var(--syntax-comment)}.observablehq--bigint,.observablehq--boolean,.observablehq--date,.observablehq--forbidden,.observablehq--number{color:var(--syntax-literal)}.observablehq--error{color:var(--theme-error)}.observablehq--cell{margin:17px 0;min-height:1px}.tok-link{color:var(--syntax-link)}.tok-strong{font-weight:600}.tok-emphasis{font-style:italic}.tok-keyword{color:var(--syntax-keyword)}.tok-atom{color:var(--syntax-atom)}.tok-literal{color:var(--syntax-literal)}.tok-string{color:var(--syntax-string)}.tok-comment{color:var(--syntax-comment)}.tok-invalid{color:var(--syntax-invalid)}.tok-variable{color:var(--syntax-variable)}.tok-definition{color:var(--syntax-definition)}.tok-meta{color:var(--syntax-meta)}.plot-d6a7b5{--plot-background: var(--theme-background)}p .plot-d6a7b5{display:inline-block}.observablehq--cell:empty{min-height:0}.observablehq--cell:not(:empty)+pre{margin-top:-11px}:root{--syntax-link: var(--theme-foreground-focus);--syntax-keyword: #e36209;--syntax-atom: #032f62;--syntax-literal: #6f42c1;--syntax-string: #22863a;--syntax-comment: var(--theme-foreground-muted);--syntax-invalid: var(--theme-error);--syntax-definition: #005cc5;--syntax-variable: var(--theme-foreground-alt);--syntax-meta: #d73a49}:root{--theme-background-b: color-mix(in srgb, var(--theme-foreground) 4%, var(--theme-background-a));--theme-background: var(--theme-background-a);--theme-background-alt: var(--theme-background-b);--theme-foreground-alt: color-mix(in srgb, var(--theme-foreground) 90%, var(--theme-background-a));--theme-foreground-muted: color-mix(in srgb, var(--theme-foreground) 60%, var(--theme-background-a));--theme-foreground-faint: color-mix(in srgb, var(--theme-foreground) 50%, var(--theme-background-a));--theme-foreground-fainter: color-mix(in srgb, var(--theme-foreground) 30%, var(--theme-background-a));--theme-foreground-faintest: color-mix(in srgb, var(--theme-foreground) 14%, var(--theme-background-a));--theme-error: #e7040f;color-scheme:light}:root{--theme-foreground: #1b1e23;--theme-foreground-focus: #3b5fc0;--theme-background-a: #ffffff}.inputs-3a86ea-table tr:not(:last-child) td,.inputs-3a86ea-table tr:not(:last-child) th{border-bottom-color:var(--theme-foreground-faintest)}.inputs-3a86ea-table thead tr td,.inputs-3a86ea-table thead tr th{border-bottom-color:var(--theme-foreground-fainter)}.inputs-3a86ea-table thead th{background:var(--theme-background)}')),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}}();
|