nazuchem 0.0.0-stage → 0.2.0

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.
@@ -0,0 +1,926 @@
1
+ // SPDX-License-Identifier: MIT OR Apache-2.0
2
+ // Origin: original
3
+ // Source: Nazuchem | bindings/wasm/scripts/build.ts | Phase B step 9
4
+ const __nazuchem_web_url = require("node:url").pathToFileURL(__filename).href;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ function __accessProp(key) {
10
+ return this[key];
11
+ }
12
+ var __toCommonJS = (from) => {
13
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
14
+ if (entry)
15
+ return entry;
16
+ entry = __defProp({}, "__esModule", { value: true });
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (var key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(entry, key))
20
+ __defProp(entry, key, {
21
+ get: __accessProp.bind(from, key),
22
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
+ });
24
+ }
25
+ __moduleCache.set(from, entry);
26
+ return entry;
27
+ };
28
+ var __moduleCache;
29
+ var __returnValue = (v) => v;
30
+ function __exportSetter(name, newValue) {
31
+ this[name] = __returnValue.bind(null, newValue);
32
+ }
33
+ var __export = (target, all) => {
34
+ for (var name in all)
35
+ __defProp(target, name, {
36
+ get: all[name],
37
+ enumerable: true,
38
+ configurable: true,
39
+ set: __exportSetter.bind(all, name)
40
+ });
41
+ };
42
+
43
+ // dist/web/index.js
44
+ var exports_web = {};
45
+ __export(exports_web, {
46
+ IR_VERSION: () => IR_VERSION,
47
+ JSON_SCHEMA: () => JSON_SCHEMA,
48
+ NazuchemError: () => NazuchemError,
49
+ default: () => __wbg_init,
50
+ initSync: () => initSync,
51
+ moleculeToName: () => moleculeToName2,
52
+ nameToMolecule: () => nameToMolecule2,
53
+ nameToSmiles: () => nameToSmiles2,
54
+ smilesToName: () => smilesToName2
55
+ });
56
+ module.exports = __toCommonJS(exports_web);
57
+
58
+ // dist/web/nazuchem.js
59
+ function moleculeToName(input) {
60
+ const ret = wasm.moleculeToName(input);
61
+ if (ret[2]) {
62
+ throw takeFromExternrefTable0(ret[1]);
63
+ }
64
+ return takeFromExternrefTable0(ret[0]);
65
+ }
66
+ function nameToMolecule(name) {
67
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
68
+ const len0 = WASM_VECTOR_LEN;
69
+ const ret = wasm.nameToMolecule(ptr0, len0);
70
+ if (ret[2]) {
71
+ throw takeFromExternrefTable0(ret[1]);
72
+ }
73
+ return takeFromExternrefTable0(ret[0]);
74
+ }
75
+ function nameToSmiles(name) {
76
+ let deferred3_0;
77
+ let deferred3_1;
78
+ try {
79
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
80
+ const len0 = WASM_VECTOR_LEN;
81
+ const ret = wasm.nameToSmiles(ptr0, len0);
82
+ var ptr2 = ret[0];
83
+ var len2 = ret[1];
84
+ if (ret[3]) {
85
+ ptr2 = 0;
86
+ len2 = 0;
87
+ throw takeFromExternrefTable0(ret[2]);
88
+ }
89
+ deferred3_0 = ptr2;
90
+ deferred3_1 = len2;
91
+ return getStringFromWasm0(ptr2, len2);
92
+ } finally {
93
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
94
+ }
95
+ }
96
+ function smilesToName(smiles) {
97
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
98
+ const len0 = WASM_VECTOR_LEN;
99
+ const ret = wasm.smilesToName(ptr0, len0);
100
+ if (ret[2]) {
101
+ throw takeFromExternrefTable0(ret[1]);
102
+ }
103
+ return takeFromExternrefTable0(ret[0]);
104
+ }
105
+ function __wbg_get_imports() {
106
+ const import0 = {
107
+ __proto__: null,
108
+ __wbg___wbindgen_is_undefined_8c687d0b90d5b524: function(arg0) {
109
+ const ret = arg0 === undefined;
110
+ return ret;
111
+ },
112
+ __wbg___wbindgen_string_get_92ab86bb19cbc12f: function(arg0, arg1) {
113
+ const obj = arg1;
114
+ const ret = typeof obj === "string" ? obj : undefined;
115
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
116
+ var len1 = WASM_VECTOR_LEN;
117
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
118
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
119
+ },
120
+ __wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
121
+ throw new Error(getStringFromWasm0(arg0, arg1));
122
+ },
123
+ __wbg_new_a32a1ab6c6655abe: function(arg0, arg1) {
124
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
125
+ return ret;
126
+ },
127
+ __wbg_now_e7c6795a7f81e10f: function(arg0) {
128
+ const ret = arg0.now();
129
+ return ret;
130
+ },
131
+ __wbg_parse_6937a9050adfb0e1: function() {
132
+ return handleError(function(arg0, arg1) {
133
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
134
+ return ret;
135
+ }, arguments);
136
+ },
137
+ __wbg_performance_3fcf6e32a7e1ed0a: function(arg0) {
138
+ const ret = arg0.performance;
139
+ return ret;
140
+ },
141
+ __wbg_set_a377297433dfea63: function() {
142
+ return handleError(function(arg0, arg1, arg2) {
143
+ const ret = Reflect.set(arg0, arg1, arg2);
144
+ return ret;
145
+ }, arguments);
146
+ },
147
+ __wbg_set_name_6e2a5da46a9ae1e7: function(arg0, arg1, arg2) {
148
+ arg0.name = getStringFromWasm0(arg1, arg2);
149
+ },
150
+ __wbg_static_accessor_GLOBAL_8eb4cd83130a11a0: function() {
151
+ const ret = typeof global === "undefined" ? null : global;
152
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
153
+ },
154
+ __wbg_static_accessor_GLOBAL_THIS_1e7044f654e934db: function() {
155
+ const ret = typeof globalThis === "undefined" ? null : globalThis;
156
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
157
+ },
158
+ __wbg_static_accessor_SELF_d8b50611246a6d92: function() {
159
+ const ret = typeof self === "undefined" ? null : self;
160
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
161
+ },
162
+ __wbg_static_accessor_WINDOW_fd0bc376bf0f8b42: function() {
163
+ const ret = typeof window === "undefined" ? null : window;
164
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
165
+ },
166
+ __wbg_stringify_54b3d9b61602aee6: function() {
167
+ return handleError(function(arg0) {
168
+ const ret = JSON.stringify(arg0);
169
+ return ret;
170
+ }, arguments);
171
+ },
172
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
173
+ const ret = getStringFromWasm0(arg0, arg1);
174
+ return ret;
175
+ },
176
+ __wbindgen_init_externref_table: function() {
177
+ const table = wasm.__wbindgen_externrefs;
178
+ const offset = table.grow(4);
179
+ table.set(0, undefined);
180
+ table.set(offset + 0, undefined);
181
+ table.set(offset + 1, null);
182
+ table.set(offset + 2, true);
183
+ table.set(offset + 3, false);
184
+ }
185
+ };
186
+ return {
187
+ __proto__: null,
188
+ "./nazuchem_bg.js": import0
189
+ };
190
+ }
191
+ function addToExternrefTable0(obj) {
192
+ const idx = wasm.__externref_table_alloc();
193
+ wasm.__wbindgen_externrefs.set(idx, obj);
194
+ return idx;
195
+ }
196
+ var cachedDataViewMemory0 = null;
197
+ function getDataViewMemory0() {
198
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
199
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
200
+ }
201
+ return cachedDataViewMemory0;
202
+ }
203
+ function getStringFromWasm0(ptr, len) {
204
+ return decodeText(ptr >>> 0, len);
205
+ }
206
+ var cachedUint8ArrayMemory0 = null;
207
+ function getUint8ArrayMemory0() {
208
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
209
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
210
+ }
211
+ return cachedUint8ArrayMemory0;
212
+ }
213
+ function handleError(f, args) {
214
+ try {
215
+ return f.apply(this, args);
216
+ } catch (e) {
217
+ const idx = addToExternrefTable0(e);
218
+ wasm.__wbindgen_exn_store(idx);
219
+ }
220
+ }
221
+ function isLikeNone(x) {
222
+ return x === undefined || x === null;
223
+ }
224
+ function passStringToWasm0(arg, malloc, realloc) {
225
+ if (realloc === undefined) {
226
+ const buf = cachedTextEncoder.encode(arg);
227
+ const ptr = malloc(buf.length, 1) >>> 0;
228
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
229
+ WASM_VECTOR_LEN = buf.length;
230
+ return ptr;
231
+ }
232
+ let len = arg.length;
233
+ let ptr = malloc(len, 1) >>> 0;
234
+ const mem = getUint8ArrayMemory0();
235
+ let offset = 0;
236
+ for (;offset < len; offset++) {
237
+ const code = arg.charCodeAt(offset);
238
+ if (code > 127)
239
+ break;
240
+ mem[ptr + offset] = code;
241
+ }
242
+ if (offset !== len) {
243
+ if (offset !== 0) {
244
+ arg = arg.slice(offset);
245
+ }
246
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
247
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
248
+ const ret = cachedTextEncoder.encodeInto(arg, view);
249
+ offset += ret.written;
250
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
251
+ }
252
+ WASM_VECTOR_LEN = offset;
253
+ return ptr;
254
+ }
255
+ function takeFromExternrefTable0(idx) {
256
+ const value = wasm.__wbindgen_externrefs.get(idx);
257
+ wasm.__externref_table_dealloc(idx);
258
+ return value;
259
+ }
260
+ var cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
261
+ cachedTextDecoder.decode();
262
+ var MAX_SAFARI_DECODE_BYTES = 2146435072;
263
+ var numBytesDecoded = 0;
264
+ function decodeText(ptr, len) {
265
+ numBytesDecoded += len;
266
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
267
+ cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
268
+ cachedTextDecoder.decode();
269
+ numBytesDecoded = len;
270
+ }
271
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
272
+ }
273
+ var cachedTextEncoder = new TextEncoder;
274
+ if (!("encodeInto" in cachedTextEncoder)) {
275
+ cachedTextEncoder.encodeInto = function(arg, view) {
276
+ const buf = cachedTextEncoder.encode(arg);
277
+ view.set(buf);
278
+ return {
279
+ read: arg.length,
280
+ written: buf.length
281
+ };
282
+ };
283
+ }
284
+ var WASM_VECTOR_LEN = 0;
285
+ var wasmModule;
286
+ var wasmInstance;
287
+ var wasm;
288
+ function __wbg_finalize_init(instance, module2) {
289
+ wasmInstance = instance;
290
+ wasm = instance.exports;
291
+ wasmModule = module2;
292
+ cachedDataViewMemory0 = null;
293
+ cachedUint8ArrayMemory0 = null;
294
+ wasm.__wbindgen_start();
295
+ return wasm;
296
+ }
297
+ async function __wbg_load(module2, imports) {
298
+ if (typeof Response === "function" && module2 instanceof Response) {
299
+ if (!module2.ok) {
300
+ throw new Error(`failed to fetch Wasm: ${module2.status} ${module2.statusText} fetching '${module2.url}'`);
301
+ }
302
+ if (typeof WebAssembly.instantiateStreaming === "function") {
303
+ try {
304
+ return await WebAssembly.instantiateStreaming(module2, imports);
305
+ } catch (e) {
306
+ const validResponse = expectedResponseType(module2.type);
307
+ if (validResponse && module2.headers.get("Content-Type") !== "application/wasm") {
308
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
309
+ } else {
310
+ throw e;
311
+ }
312
+ }
313
+ }
314
+ const bytes = await module2.arrayBuffer();
315
+ return await WebAssembly.instantiate(bytes, imports);
316
+ } else {
317
+ const instance = await WebAssembly.instantiate(module2, imports);
318
+ if (instance instanceof WebAssembly.Instance) {
319
+ return { instance, module: module2 };
320
+ } else {
321
+ return instance;
322
+ }
323
+ }
324
+ function expectedResponseType(type) {
325
+ switch (type) {
326
+ case "basic":
327
+ case "cors":
328
+ case "default":
329
+ return true;
330
+ }
331
+ return false;
332
+ }
333
+ }
334
+ function initSync(module2) {
335
+ if (wasm !== undefined)
336
+ return wasm;
337
+ if (module2 !== undefined) {
338
+ if (Object.getPrototypeOf(module2) === Object.prototype) {
339
+ ({ module: module2 } = module2);
340
+ } else {
341
+ console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
342
+ }
343
+ }
344
+ const imports = __wbg_get_imports();
345
+ if (!(module2 instanceof WebAssembly.Module)) {
346
+ module2 = new WebAssembly.Module(module2);
347
+ }
348
+ const instance = new WebAssembly.Instance(module2, imports);
349
+ return __wbg_finalize_init(instance, module2);
350
+ }
351
+ async function __wbg_init(module_or_path) {
352
+ if (wasm !== undefined)
353
+ return wasm;
354
+ if (module_or_path !== undefined) {
355
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
356
+ ({ module_or_path } = module_or_path);
357
+ } else {
358
+ console.warn("using deprecated parameters for the initialization function; pass a single object instead");
359
+ }
360
+ }
361
+ if (module_or_path === undefined) {
362
+ module_or_path = new URL("../nazuchem_bg.wasm", __nazuchem_web_url);
363
+ }
364
+ const imports = __wbg_get_imports();
365
+ if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
366
+ module_or_path = fetch(module_or_path);
367
+ }
368
+ const { instance, module: module2 } = await __wbg_load(await module_or_path, imports);
369
+ return __wbg_finalize_init(instance, module2);
370
+ }
371
+
372
+ // dist/web/index.js
373
+ class NazuchemError extends Error {
374
+ constructor(message, kind) {
375
+ super(message);
376
+ this.name = "NazuchemError";
377
+ this.kind = kind;
378
+ }
379
+ }
380
+ var IR_VERSION = 1;
381
+ var JSON_SCHEMA = `{
382
+ "$defs": {
383
+ "Atom": {
384
+ "additionalProperties": false,
385
+ "description": "An atom with its stated hydrogen origin, locants, and attachment label.\\n\\nJSON omits zero charge, zero radical electrons, and false\\n\`hydrogens_stated\`, restoring those defaults when the fields are absent.",
386
+ "properties": {
387
+ "atom_map": {
388
+ "description": "An explicit SMILES atom-map number, independent of text labels.",
389
+ "format": "uint32",
390
+ "maximum": 4294967295,
391
+ "minimum": 0,
392
+ "type": [
393
+ "integer",
394
+ "null"
395
+ ]
396
+ },
397
+ "attachment_point": {
398
+ "description": "A numbered wildcard attachment, corresponding to OPSIN \`_AP{n}\`.",
399
+ "format": "uint32",
400
+ "maximum": 4294967295,
401
+ "minimum": 0,
402
+ "type": [
403
+ "integer",
404
+ "null"
405
+ ]
406
+ },
407
+ "charge": {
408
+ "description": "Formal charge; defaults to zero when omitted from JSON.",
409
+ "format": "int8",
410
+ "maximum": 127,
411
+ "minimum": -128,
412
+ "type": "integer"
413
+ },
414
+ "element": {
415
+ "description": "Atomic number; zero denotes a wildcard or attachment point.",
416
+ "format": "uint8",
417
+ "maximum": 118,
418
+ "minimum": 0,
419
+ "type": "integer"
420
+ },
421
+ "hydrogens": {
422
+ "description": "Hydrogen atoms not represented as graph vertices.",
423
+ "format": "uint8",
424
+ "maximum": 255,
425
+ "minimum": 0,
426
+ "type": "integer"
427
+ },
428
+ "hydrogens_stated": {
429
+ "description": "Distinguishes explicitly stated counts such as \`[CH4]\` from inferred \`C\`.\\nDefaults to false when omitted from JSON.",
430
+ "type": "boolean"
431
+ },
432
+ "isotope": {
433
+ "description": "Isotope mass number. Isotopic hydrogen is an atom, never a count.",
434
+ "format": "uint16",
435
+ "maximum": 65535,
436
+ "minimum": 1,
437
+ "type": [
438
+ "integer",
439
+ "null"
440
+ ]
441
+ },
442
+ "label": {
443
+ "type": [
444
+ "string",
445
+ "null"
446
+ ]
447
+ },
448
+ "locants": {
449
+ "description": "All name locants, in name order. Parent membership controls display.",
450
+ "items": {
451
+ "type": "string"
452
+ },
453
+ "type": "array"
454
+ },
455
+ "radical_electrons": {
456
+ "description": "Stated unpaired electron count; defaults to zero when omitted from JSON.",
457
+ "format": "uint8",
458
+ "maximum": 255,
459
+ "minimum": 0,
460
+ "type": "integer"
461
+ }
462
+ },
463
+ "required": [
464
+ "element",
465
+ "hydrogens"
466
+ ],
467
+ "type": "object"
468
+ },
469
+ "AxialWinding": {
470
+ "description": "Axis winding relative to its ordered references, independent of CIP ranking.\\n\\nLook along \`bond.atoms[0]\` toward \`bond.atoms[1]\`. The first reference pair is\\nattached to the near end, the second to the far end. \`Clockwise\` means the\\nshortest turn from the projection of \`refs[0]\` to \`refs[2]\` is clockwise;\\n\`Anticlockwise\` means anticlockwise. Swapping either pair reverses winding.\\nReversing the bond and exchanging the two pairs preserves winding. These\\nvalues describe the stored reference order, not CIP M/P descriptors; no\\nligand priorities are inferred. \`Unknown\` records stated unknown winding.",
471
+ "enum": [
472
+ "clockwise",
473
+ "anticlockwise",
474
+ "unknown"
475
+ ],
476
+ "type": "string"
477
+ },
478
+ "Bond": {
479
+ "additionalProperties": false,
480
+ "description": "A localized bond; endpoint order defines double-bond references and the position-variation attachment end.",
481
+ "properties": {
482
+ "atoms": {
483
+ "items": {
484
+ "format": "uint32",
485
+ "maximum": 4294967295,
486
+ "minimum": 0,
487
+ "type": "integer"
488
+ },
489
+ "maxItems": 2,
490
+ "minItems": 2,
491
+ "type": "array",
492
+ "uniqueItems": true
493
+ },
494
+ "order": {
495
+ "$ref": "#/$defs/BondOrder"
496
+ }
497
+ },
498
+ "required": [
499
+ "atoms",
500
+ "order"
501
+ ],
502
+ "type": "object"
503
+ },
504
+ "BondOrder": {
505
+ "enum": [
506
+ "single",
507
+ "double",
508
+ "triple",
509
+ "quadruple"
510
+ ],
511
+ "type": "string"
512
+ },
513
+ "Connectivity": {
514
+ "enum": [
515
+ "head_to_tail",
516
+ "head_to_head",
517
+ "unknown"
518
+ ],
519
+ "type": "string"
520
+ },
521
+ "PositionVariation": {
522
+ "additionalProperties": false,
523
+ "description": "Possible attachment endpoints for a position-variation bond.",
524
+ "properties": {
525
+ "bond": {
526
+ "format": "uint32",
527
+ "maximum": 4294967295,
528
+ "minimum": 0,
529
+ "type": "integer"
530
+ },
531
+ "endpoints": {
532
+ "items": {
533
+ "format": "uint32",
534
+ "maximum": 4294967295,
535
+ "minimum": 0,
536
+ "type": "integer"
537
+ },
538
+ "minItems": 1,
539
+ "type": "array",
540
+ "uniqueItems": true
541
+ }
542
+ },
543
+ "required": [
544
+ "bond",
545
+ "endpoints"
546
+ ],
547
+ "type": "object"
548
+ },
549
+ "Ref": {
550
+ "anyOf": [
551
+ {
552
+ "format": "uint32",
553
+ "maximum": 4294967295,
554
+ "minimum": 0,
555
+ "type": "integer"
556
+ },
557
+ {
558
+ "enum": [
559
+ "implicit_hydrogen",
560
+ "lone_pair"
561
+ ],
562
+ "type": "string"
563
+ }
564
+ ]
565
+ },
566
+ "Relation": {
567
+ "enum": [
568
+ "cis",
569
+ "trans",
570
+ "unknown"
571
+ ],
572
+ "type": "string"
573
+ },
574
+ "RepeatUnit": {
575
+ "additionalProperties": false,
576
+ "description": "A repeating unit, including its bonds to atoms outside the unit.",
577
+ "properties": {
578
+ "atoms": {
579
+ "items": {
580
+ "format": "uint32",
581
+ "maximum": 4294967295,
582
+ "minimum": 0,
583
+ "type": "integer"
584
+ },
585
+ "minItems": 1,
586
+ "type": "array",
587
+ "uniqueItems": true
588
+ },
589
+ "attachment_points": {
590
+ "description": "External wildcard atom identities that represent polymer end roles.",
591
+ "items": {
592
+ "format": "uint32",
593
+ "maximum": 4294967295,
594
+ "minimum": 0,
595
+ "type": "integer"
596
+ },
597
+ "type": "array",
598
+ "uniqueItems": true
599
+ },
600
+ "connectivity": {
601
+ "$ref": "#/$defs/Connectivity"
602
+ },
603
+ "crossing_bonds": {
604
+ "items": {
605
+ "format": "uint32",
606
+ "maximum": 4294967295,
607
+ "minimum": 0,
608
+ "type": "integer"
609
+ },
610
+ "type": "array",
611
+ "uniqueItems": true
612
+ },
613
+ "label": {
614
+ "type": [
615
+ "string",
616
+ "null"
617
+ ]
618
+ }
619
+ },
620
+ "required": [
621
+ "atoms",
622
+ "connectivity"
623
+ ],
624
+ "type": "object"
625
+ },
626
+ "Stereo": {
627
+ "description": "Ordered structural stereochemistry, independent of CIP assignment.\\n\\nUnknown winding/relation records stated unknown (wavy/ξ) stereochemistry;\\nan absent entry means unspecified stereochemistry. For a double bond,\\n\`refs[i]\` is attached to \`bonds[bond].atoms[i]\`. For an atropisomer,\\n\`refs[0..2]\` are attached to the first bond end and \`refs[2..4]\` to the second.\\nAxial chirality of allenes and other cumulenes is not representable in v1.\\nEquality is structural: equivalent configurations with permuted references\\nand adjusted winding can compare unequal.",
628
+ "oneOf": [
629
+ {
630
+ "additionalProperties": false,
631
+ "properties": {
632
+ "center": {
633
+ "format": "uint32",
634
+ "maximum": 4294967295,
635
+ "minimum": 0,
636
+ "type": "integer"
637
+ },
638
+ "kind": {
639
+ "const": "tetrahedral",
640
+ "type": "string"
641
+ },
642
+ "neighbors": {
643
+ "items": {
644
+ "$ref": "#/$defs/Ref"
645
+ },
646
+ "maxItems": 4,
647
+ "minItems": 4,
648
+ "type": "array",
649
+ "uniqueItems": true
650
+ },
651
+ "winding": {
652
+ "$ref": "#/$defs/Winding"
653
+ }
654
+ },
655
+ "required": [
656
+ "kind",
657
+ "center",
658
+ "neighbors",
659
+ "winding"
660
+ ],
661
+ "type": "object"
662
+ },
663
+ {
664
+ "additionalProperties": false,
665
+ "properties": {
666
+ "bond": {
667
+ "format": "uint32",
668
+ "maximum": 4294967295,
669
+ "minimum": 0,
670
+ "type": "integer"
671
+ },
672
+ "kind": {
673
+ "const": "double_bond",
674
+ "type": "string"
675
+ },
676
+ "refs": {
677
+ "items": {
678
+ "format": "uint32",
679
+ "maximum": 4294967295,
680
+ "minimum": 0,
681
+ "type": "integer"
682
+ },
683
+ "maxItems": 2,
684
+ "minItems": 2,
685
+ "type": "array",
686
+ "uniqueItems": true
687
+ },
688
+ "relation": {
689
+ "$ref": "#/$defs/Relation"
690
+ }
691
+ },
692
+ "required": [
693
+ "kind",
694
+ "bond",
695
+ "refs",
696
+ "relation"
697
+ ],
698
+ "type": "object"
699
+ },
700
+ {
701
+ "additionalProperties": false,
702
+ "properties": {
703
+ "bond": {
704
+ "format": "uint32",
705
+ "maximum": 4294967295,
706
+ "minimum": 0,
707
+ "type": "integer"
708
+ },
709
+ "kind": {
710
+ "const": "atropisomer",
711
+ "type": "string"
712
+ },
713
+ "refs": {
714
+ "items": {
715
+ "$ref": "#/$defs/Ref"
716
+ },
717
+ "maxItems": 4,
718
+ "minItems": 4,
719
+ "type": "array"
720
+ },
721
+ "winding": {
722
+ "$ref": "#/$defs/AxialWinding"
723
+ }
724
+ },
725
+ "required": [
726
+ "kind",
727
+ "bond",
728
+ "refs",
729
+ "winding"
730
+ ],
731
+ "type": "object"
732
+ }
733
+ ]
734
+ },
735
+ "StereoGroup": {
736
+ "oneOf": [
737
+ {
738
+ "additionalProperties": false,
739
+ "properties": {
740
+ "id": {
741
+ "format": "uint32",
742
+ "maximum": 4294967295,
743
+ "minimum": 0,
744
+ "type": "integer"
745
+ },
746
+ "kind": {
747
+ "const": "and",
748
+ "type": "string"
749
+ },
750
+ "stereo": {
751
+ "items": {
752
+ "format": "uint32",
753
+ "maximum": 4294967295,
754
+ "minimum": 0,
755
+ "type": "integer"
756
+ },
757
+ "minItems": 1,
758
+ "type": "array",
759
+ "uniqueItems": true
760
+ }
761
+ },
762
+ "required": [
763
+ "kind",
764
+ "id",
765
+ "stereo"
766
+ ],
767
+ "type": "object"
768
+ },
769
+ {
770
+ "additionalProperties": false,
771
+ "properties": {
772
+ "id": {
773
+ "format": "uint32",
774
+ "maximum": 4294967295,
775
+ "minimum": 0,
776
+ "type": "integer"
777
+ },
778
+ "kind": {
779
+ "const": "or",
780
+ "type": "string"
781
+ },
782
+ "stereo": {
783
+ "items": {
784
+ "format": "uint32",
785
+ "maximum": 4294967295,
786
+ "minimum": 0,
787
+ "type": "integer"
788
+ },
789
+ "minItems": 1,
790
+ "type": "array",
791
+ "uniqueItems": true
792
+ }
793
+ },
794
+ "required": [
795
+ "kind",
796
+ "id",
797
+ "stereo"
798
+ ],
799
+ "type": "object"
800
+ }
801
+ ]
802
+ },
803
+ "Winding": {
804
+ "description": "Tetrahedral winding, viewed from \`neighbors[0]\` toward the center.\\n\\n\`Clockwise\` means \`neighbors[1]\`, \`neighbors[2]\`, \`neighbors[3]\` occur in\\nclockwise order in that view; \`Anticlockwise\` means the reverse order.\\n\`Unknown\` records explicitly unknown configuration. No stereo entry means\\nunspecified configuration.",
805
+ "enum": [
806
+ "clockwise",
807
+ "anticlockwise",
808
+ "unknown"
809
+ ],
810
+ "type": "string"
811
+ }
812
+ },
813
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
814
+ "additionalProperties": false,
815
+ "properties": {
816
+ "atoms": {
817
+ "items": {
818
+ "$ref": "#/$defs/Atom"
819
+ },
820
+ "type": "array"
821
+ },
822
+ "bonds": {
823
+ "items": {
824
+ "$ref": "#/$defs/Bond"
825
+ },
826
+ "type": "array"
827
+ },
828
+ "nazuchem_ir": {
829
+ "const": 1,
830
+ "type": "integer"
831
+ },
832
+ "parent": {
833
+ "items": {
834
+ "format": "uint32",
835
+ "maximum": 4294967295,
836
+ "minimum": 0,
837
+ "type": "integer"
838
+ },
839
+ "type": "array",
840
+ "uniqueItems": true
841
+ },
842
+ "polymers": {
843
+ "items": {
844
+ "$ref": "#/$defs/RepeatUnit"
845
+ },
846
+ "type": "array"
847
+ },
848
+ "position_variation": {
849
+ "items": {
850
+ "$ref": "#/$defs/PositionVariation"
851
+ },
852
+ "type": "array"
853
+ },
854
+ "stereo": {
855
+ "items": {
856
+ "$ref": "#/$defs/Stereo"
857
+ },
858
+ "type": "array"
859
+ },
860
+ "stereo_groups": {
861
+ "items": {
862
+ "$ref": "#/$defs/StereoGroup"
863
+ },
864
+ "type": "array"
865
+ }
866
+ },
867
+ "required": [
868
+ "nazuchem_ir",
869
+ "atoms",
870
+ "bonds"
871
+ ],
872
+ "title": "Molecule",
873
+ "type": "object"
874
+ }
875
+ `;
876
+ function call(operation, value) {
877
+ try {
878
+ return operation(value);
879
+ } catch (source) {
880
+ if (source instanceof Error && source.name === "NazuchemError") {
881
+ throw new NazuchemError(source.message, source.kind);
882
+ }
883
+ if (source instanceof WebAssembly.RuntimeError) {
884
+ throw new NazuchemError(source.message, "internal");
885
+ }
886
+ throw source;
887
+ }
888
+ }
889
+ function nameToSmiles2(name) {
890
+ return call(nameToSmiles, name);
891
+ }
892
+ function flattenName(result) {
893
+ return {
894
+ text: result.text,
895
+ omittedStereo: result.omitted_stereo,
896
+ omittedUnits: result.omitted_units,
897
+ verification: result.verification,
898
+ status: result.status.status,
899
+ reason: result.status.reason ?? null,
900
+ alternatives: result.alternatives.map((alternative) => ({
901
+ name: alternative.name,
902
+ status: alternative.status.status,
903
+ reason: alternative.status.reason ?? null
904
+ }))
905
+ };
906
+ }
907
+ function smilesToName2(smiles) {
908
+ return flattenName(call(smilesToName, smiles));
909
+ }
910
+ function nameToMolecule2(name) {
911
+ return call(nameToMolecule, name);
912
+ }
913
+ function assertFiniteNumbers(value, seen = new WeakSet) {
914
+ if (typeof value === "number" && !Number.isFinite(value)) {
915
+ throw new NazuchemError("molecule numbers must be finite", "serialize");
916
+ }
917
+ if (value === null || typeof value !== "object" || seen.has(value))
918
+ return;
919
+ seen.add(value);
920
+ for (const child of Object.values(value))
921
+ assertFiniteNumbers(child, seen);
922
+ }
923
+ function moleculeToName2(molecule) {
924
+ assertFiniteNumbers(molecule);
925
+ return flattenName(call(moleculeToName, molecule));
926
+ }