@onlyworlds/sdk 4.170.0 → 4.171.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.
- package/CHANGELOG.md +14 -0
- package/dist/index.d.ts +92 -2
- package/dist/index.js +1825 -143
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -391,15 +391,15 @@ var OwApiError = class extends Error {
|
|
|
391
391
|
const nested = env?.error && typeof env.error === "object" ? env.error : void 0;
|
|
392
392
|
const list2 = nested?.refusals;
|
|
393
393
|
if (!Array.isArray(list2)) return void 0;
|
|
394
|
-
const
|
|
394
|
+
const rows2 = [];
|
|
395
395
|
for (const r of list2) {
|
|
396
396
|
if (!r || typeof r !== "object") continue;
|
|
397
397
|
const { word, stop_reason, output_tokens } = r;
|
|
398
398
|
if (typeof word === "string" && typeof stop_reason === "string" && Number.isSafeInteger(output_tokens)) {
|
|
399
|
-
|
|
399
|
+
rows2.push({ word, stop_reason, output_tokens });
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
|
-
return
|
|
402
|
+
return rows2;
|
|
403
403
|
}
|
|
404
404
|
/** ask: the model gave no answer (502 `ask_failed`). Not counted; try again in a moment. */
|
|
405
405
|
get isAskFailed() {
|
|
@@ -551,14 +551,14 @@ async function errorFromResponse(res) {
|
|
|
551
551
|
|
|
552
552
|
// src/v2/keys.ts
|
|
553
553
|
var LEGACY_RE = /^[0-9]{10}$/;
|
|
554
|
-
function isDemoKey(
|
|
555
|
-
return LEGACY_RE.test(
|
|
556
|
-
}
|
|
557
|
-
function detectKeyKind(
|
|
558
|
-
if (
|
|
559
|
-
if (
|
|
560
|
-
if (
|
|
561
|
-
if (LEGACY_RE.test(
|
|
554
|
+
function isDemoKey(key3) {
|
|
555
|
+
return LEGACY_RE.test(key3) && key3 >= "0000000000" && key3 <= "0000000009";
|
|
556
|
+
}
|
|
557
|
+
function detectKeyKind(key3) {
|
|
558
|
+
if (key3.startsWith("ow_w_")) return "write";
|
|
559
|
+
if (key3.startsWith("ow_r_")) return "read";
|
|
560
|
+
if (key3.startsWith("ow_a_")) return "account";
|
|
561
|
+
if (LEGACY_RE.test(key3)) return "legacy";
|
|
562
562
|
return "unknown";
|
|
563
563
|
}
|
|
564
564
|
function kindCanWrite(kind) {
|
|
@@ -760,8 +760,8 @@ async function completeSignIn(baseUrl, fetchImpl, opts) {
|
|
|
760
760
|
} catch {
|
|
761
761
|
}
|
|
762
762
|
}
|
|
763
|
-
const
|
|
764
|
-
const raw = storage.get(
|
|
763
|
+
const key3 = RECORD_PREFIX + clientId;
|
|
764
|
+
const raw = storage.get(key3);
|
|
765
765
|
let record = null;
|
|
766
766
|
try {
|
|
767
767
|
record = raw ? JSON.parse(raw) : null;
|
|
@@ -769,7 +769,7 @@ async function completeSignIn(baseUrl, fetchImpl, opts) {
|
|
|
769
769
|
record = null;
|
|
770
770
|
}
|
|
771
771
|
if (!record || typeof record.state !== "string" || typeof record.verifier !== "string" || typeof record.redirectUri !== "string") {
|
|
772
|
-
storage.remove(
|
|
772
|
+
storage.remove(key3);
|
|
773
773
|
throw new OwSignInError("state_mismatch", "No sign-in is pending for this tool here: start again from the sign-in button.");
|
|
774
774
|
}
|
|
775
775
|
if (state !== record.state) {
|
|
@@ -778,7 +778,7 @@ async function completeSignIn(baseUrl, fetchImpl, opts) {
|
|
|
778
778
|
if (record.scope === "world:read" && "ai_uses" in ai) {
|
|
779
779
|
throw new TypeError("completeSignIn: this sign-in asked for a read-only token (scope world:read), which gets no AI door token: leave aiUses out. Nothing was sent.");
|
|
780
780
|
}
|
|
781
|
-
storage.remove(
|
|
781
|
+
storage.remove(key3);
|
|
782
782
|
if (!code) {
|
|
783
783
|
throw new OwSignInError("state_mismatch", "This page was not reached from the sign-in that was started here: start again.");
|
|
784
784
|
}
|
|
@@ -1365,8 +1365,8 @@ var OwV2Client = class {
|
|
|
1365
1365
|
* image is already out) and 409 `upload_pending` (an upload is not yet recorded), both
|
|
1366
1366
|
* with Retry-After.
|
|
1367
1367
|
*/
|
|
1368
|
-
async createRemovalTicket(
|
|
1369
|
-
return this.request("POST", "/media/remove-ticket", { body: { key: objectKey(
|
|
1368
|
+
async createRemovalTicket(key3) {
|
|
1369
|
+
return this.request("POST", "/media/remove-ticket", { body: { key: objectKey(key3) } });
|
|
1370
1370
|
}
|
|
1371
1371
|
/**
|
|
1372
1372
|
* Remove one uploaded image: a removal ticket from the API, then the removal at the
|
|
@@ -2796,7 +2796,7 @@ function getElementLabel(elementType) {
|
|
|
2796
2796
|
var ADDRESSING_KEYS = ["keyless"];
|
|
2797
2797
|
var isBody = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2798
2798
|
var idOf = (v) => v.id;
|
|
2799
|
-
var carries = (v,
|
|
2799
|
+
var carries = (v, key3) => Object.prototype.hasOwnProperty.call(v, key3) && v[key3] !== void 0;
|
|
2800
2800
|
function matchesPair(el, pair) {
|
|
2801
2801
|
if (!isBody(el) || typeof el.type !== "string" || typeof el.supertype !== "string") return false;
|
|
2802
2802
|
return fold(el.type) === fold(pair.type) && fold(el.supertype) === fold(pair.supertype);
|
|
@@ -2848,8 +2848,8 @@ function timeKey(value) {
|
|
|
2848
2848
|
return [seconds, Number(((m[7] ?? "") + "000000").slice(0, 6))];
|
|
2849
2849
|
}
|
|
2850
2850
|
function instantOf(value) {
|
|
2851
|
-
const
|
|
2852
|
-
return
|
|
2851
|
+
const key3 = timeKey(value);
|
|
2852
|
+
return key3 === null ? null : { seconds: key3[0], microseconds: key3[1] };
|
|
2853
2853
|
}
|
|
2854
2854
|
function compareInstants(a, b) {
|
|
2855
2855
|
if (a === null || b === null) return a === null ? b === null ? 0 : 1 : -1;
|
|
@@ -2933,11 +2933,11 @@ function readMarkOf(relations, characterId, members, options) {
|
|
|
2933
2933
|
const hasAuthor = carries(rel, "created_by");
|
|
2934
2934
|
if (carries(rel, "changed_by") && (!hasAuthor || rel.changed_by !== rel.created_by)) continue;
|
|
2935
2935
|
if (hasAuthor && handOf(rel, members) !== characterId) continue;
|
|
2936
|
-
const
|
|
2937
|
-
const c =
|
|
2936
|
+
const key3 = timeKey(rel.updated_at);
|
|
2937
|
+
const c = key3 !== null && markKey !== null ? compareKeys(key3, markKey) : key3 !== null ? 1 : markKey !== null ? -1 : 0;
|
|
2938
2938
|
if (mark === null || c > 0 || c === 0 && byCodePoint(tieId(rel), tieId(mark)) > 0) {
|
|
2939
2939
|
mark = rel;
|
|
2940
|
-
markKey =
|
|
2940
|
+
markKey = key3;
|
|
2941
2941
|
}
|
|
2942
2942
|
}
|
|
2943
2943
|
return mark;
|
|
@@ -2990,10 +2990,10 @@ function noteOf(narratives, characterId, members) {
|
|
|
2990
2990
|
const id = idOf(note);
|
|
2991
2991
|
if (typeof id !== "string" || id === "" || note.narrator !== characterId) continue;
|
|
2992
2992
|
if (isHiddenMark2(note.hidden) || proposedMarkOf(note) !== null || !isOwnHand(note, characterId, members)) continue;
|
|
2993
|
-
const
|
|
2994
|
-
if (line === null || (
|
|
2993
|
+
const key3 = timeKey(note.created_at);
|
|
2994
|
+
if (line === null || (key3 !== null ? lineKey === null || compareKeys(key3, lineKey) >= 0 : lineKey === null)) {
|
|
2995
2995
|
line = id;
|
|
2996
|
-
lineKey =
|
|
2996
|
+
lineKey = key3;
|
|
2997
2997
|
}
|
|
2998
2998
|
}
|
|
2999
2999
|
return line;
|
|
@@ -3086,12 +3086,12 @@ var LINK_FIELDS = new Map(
|
|
|
3086
3086
|
var ANCHOR_TARGET = new Map((LINK_FIELDS.get("construct") ?? []).map(([f, , t]) => [f, t]));
|
|
3087
3087
|
function linkTarget(el, field, target) {
|
|
3088
3088
|
if (target !== "any") return target;
|
|
3089
|
-
const
|
|
3090
|
-
return typeof
|
|
3089
|
+
const key3 = el[`${field.slice(0, -3)}_type`];
|
|
3090
|
+
return typeof key3 === "string" && TYPE_RANK.has(key3) ? key3 : "";
|
|
3091
3091
|
}
|
|
3092
3092
|
var isBody2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
3093
|
-
var own = (v,
|
|
3094
|
-
var valueOf = (v,
|
|
3093
|
+
var own = (v, key3) => Object.prototype.hasOwnProperty.call(v, key3);
|
|
3094
|
+
var valueOf = (v, key3) => own(v, key3) && v[key3] !== void 0 ? v[key3] : null;
|
|
3095
3095
|
var whole = (v) => typeof v === "number" && Number.isInteger(v) ? v : null;
|
|
3096
3096
|
function dateOf(element) {
|
|
3097
3097
|
if (!isBody2(element)) return null;
|
|
@@ -3664,7 +3664,7 @@ function lensReading(r, lens, clockV) {
|
|
|
3664
3664
|
const { list: keep, cut: cut2, mail } = resolveOne(body, recipe, r, visited, wall);
|
|
3665
3665
|
const { anchors, unseen } = anchorsOf(body, r);
|
|
3666
3666
|
const resolved = new Set(anchors.filter((id) => r.view.has(id) && !unseen.has(id)));
|
|
3667
|
-
const
|
|
3667
|
+
const rows2 = keep.map((id) => r.row(id, recipe.show, resolved.has(id) ? recipe.notes : null));
|
|
3668
3668
|
const counts = {};
|
|
3669
3669
|
for (const why of CUT_REASONS) {
|
|
3670
3670
|
if (OWNER_ONLY.has(why) && !r.owner) continue;
|
|
@@ -3673,7 +3673,7 @@ function lensReading(r, lens, clockV) {
|
|
|
3673
3673
|
if (n > 0) counts[why] = n;
|
|
3674
3674
|
}
|
|
3675
3675
|
const notesIgnored = Object.keys(recipe.notes).filter((k) => !anchors.includes(k) && r.view.has(k)).length;
|
|
3676
|
-
return { reading: { kept: keep, rows, cut: counts, notesIgnored, mail, unreadable: null }, cutById: cut2 };
|
|
3676
|
+
return { reading: { kept: keep, rows: rows2, cut: counts, notesIgnored, mail, unreadable: null }, cutById: cut2 };
|
|
3677
3677
|
}
|
|
3678
3678
|
|
|
3679
3679
|
// src/charter.ts
|
|
@@ -3837,8 +3837,8 @@ var isString = (v) => typeof v === "string";
|
|
|
3837
3837
|
var list = (v) => Array.isArray(v) ? v : [];
|
|
3838
3838
|
var cp = byCodePoint;
|
|
3839
3839
|
function playedKey(s) {
|
|
3840
|
-
const
|
|
3841
|
-
return
|
|
3840
|
+
const key3 = timeKey(s);
|
|
3841
|
+
return key3 === null ? null : [key3[0], Math.floor(key3[1] / 1e3)];
|
|
3842
3842
|
}
|
|
3843
3843
|
var proposed = (el) => proposedMarkOf(el) !== null;
|
|
3844
3844
|
function recordMarkOf(element) {
|
|
@@ -4017,9 +4017,9 @@ var GRAPH_OPTION_KEYS = ["lens", "asOf", "clock", "rooms", "hidden", "proposed",
|
|
|
4017
4017
|
var DECLARED_LINKS = Object.freeze(["x_lens_leads_to", "x_spine_depends_on"]);
|
|
4018
4018
|
var GRAPH_REASONS = [...CUT_REASONS, "room", "hidden", "proposed", "map_space", "reading_aid", "outside_lens"];
|
|
4019
4019
|
var GRAPH_OWNER_ONLY = /* @__PURE__ */ new Set([...OWNER_ONLY, "hidden", "proposed"]);
|
|
4020
|
-
function flag(opts,
|
|
4021
|
-
const v = valueOf(opts,
|
|
4022
|
-
if (v !== null && typeof v !== "boolean") throw new TypeError(`worldGraph: ${
|
|
4020
|
+
function flag(opts, key3) {
|
|
4021
|
+
const v = valueOf(opts, key3);
|
|
4022
|
+
if (v !== null && typeof v !== "boolean") throw new TypeError(`worldGraph: ${key3} is a boolean; got ${JSON.stringify(v)}.`);
|
|
4023
4023
|
return v === true;
|
|
4024
4024
|
}
|
|
4025
4025
|
function worldGraph(world, reader, options) {
|
|
@@ -4040,12 +4040,12 @@ function worldGraph(world, reader, options) {
|
|
|
4040
4040
|
reading_aid: flag(opts, "readingAids")
|
|
4041
4041
|
};
|
|
4042
4042
|
const seenRung = reader.rung === "owner" && reader.as != null ? reader.as.rung : reader.rung;
|
|
4043
|
-
for (const [kind,
|
|
4044
|
-
if (flags[kind] && seenRung !== "owner") throw new TypeError(`worldGraph: ${
|
|
4043
|
+
for (const [kind, key3] of [["hidden", "hidden"], ["proposed", "proposed"]]) {
|
|
4044
|
+
if (flags[kind] && seenRung !== "owner") throw new TypeError(`worldGraph: ${key3} is the owner's alone; a ${seenRung} reader may not ask it.`);
|
|
4045
4045
|
}
|
|
4046
4046
|
if (seenRung === "public") {
|
|
4047
|
-
for (const [kind,
|
|
4048
|
-
if (flags[kind]) throw new TypeError(`worldGraph: a public reader takes no flag; it asked ${
|
|
4047
|
+
for (const [kind, key3] of [["room", "rooms"], ["map_space", "mapSpace"], ["reading_aid", "readingAids"]]) {
|
|
4048
|
+
if (flags[kind]) throw new TypeError(`worldGraph: a public reader takes no flag; it asked ${key3}.`);
|
|
4049
4049
|
}
|
|
4050
4050
|
}
|
|
4051
4051
|
const { asOf, clock } = readingDate("worldGraph", world, opts);
|
|
@@ -4160,16 +4160,16 @@ function degreeOf(graph) {
|
|
|
4160
4160
|
if (!isBody2(graph) || !Array.isArray(graph.nodes) || !Array.isArray(graph.edges)) {
|
|
4161
4161
|
throw new TypeError("degreeOf: graph is what worldGraph answers, an object with nodes and edges lists.");
|
|
4162
4162
|
}
|
|
4163
|
-
const
|
|
4163
|
+
const count2 = new Map(graph.nodes.map((n) => [n.id, 0]));
|
|
4164
4164
|
const add = (id) => {
|
|
4165
|
-
const n =
|
|
4166
|
-
if (n !== void 0)
|
|
4165
|
+
const n = count2.get(id);
|
|
4166
|
+
if (n !== void 0) count2.set(id, n + 1);
|
|
4167
4167
|
};
|
|
4168
4168
|
for (const e of graph.edges) {
|
|
4169
4169
|
add(e.source);
|
|
4170
4170
|
if (e.target !== e.source) add(e.target);
|
|
4171
4171
|
}
|
|
4172
|
-
return Object.fromEntries(
|
|
4172
|
+
return Object.fromEntries(count2);
|
|
4173
4173
|
}
|
|
4174
4174
|
function outDegreeOf(graph) {
|
|
4175
4175
|
if (!isBody2(graph) || !Array.isArray(graph.nodes) || !Array.isArray(graph.edges)) {
|
|
@@ -4185,11 +4185,11 @@ function outDegreeOf(graph) {
|
|
|
4185
4185
|
// src/landing.ts
|
|
4186
4186
|
var OPTION_KEYS = ["heads", "hops", "size"];
|
|
4187
4187
|
var GAP_ORDER = ["orphan", "near_orphan", "no_place", "nobody_here"];
|
|
4188
|
-
function whole2(opts,
|
|
4189
|
-
const v = valueOf(opts,
|
|
4188
|
+
function whole2(opts, key3, fallback) {
|
|
4189
|
+
const v = valueOf(opts, key3);
|
|
4190
4190
|
if (v === null) return fallback;
|
|
4191
4191
|
if (typeof v !== "number" || !Number.isInteger(v) || v < 1) {
|
|
4192
|
-
throw new RangeError(`landingOf: ${
|
|
4192
|
+
throw new RangeError(`landingOf: ${key3} is a whole number, 1 or more; got ${JSON.stringify(v) ?? typeof v}.`);
|
|
4193
4193
|
}
|
|
4194
4194
|
return v;
|
|
4195
4195
|
}
|
|
@@ -4203,7 +4203,7 @@ function landingOf(graph, options) {
|
|
|
4203
4203
|
refuseUnknownOptions("landingOf", options, OPTION_KEYS);
|
|
4204
4204
|
const opts = isBody2(options) ? options : {};
|
|
4205
4205
|
const k = whole2(opts, "heads", 5);
|
|
4206
|
-
const
|
|
4206
|
+
const reach2 = whole2(opts, "hops", 1);
|
|
4207
4207
|
const size = whole2(opts, "size", 24);
|
|
4208
4208
|
const degree = new Map(graph.nodes.map((n) => [n.id, 0]));
|
|
4209
4209
|
const near = new Map(graph.nodes.map((n) => [n.id, /* @__PURE__ */ new Set()]));
|
|
@@ -4232,7 +4232,7 @@ function landingOf(graph, options) {
|
|
|
4232
4232
|
heads.forEach((head, rank) => {
|
|
4233
4233
|
const seen = /* @__PURE__ */ new Map([[head, 0]]);
|
|
4234
4234
|
let frontier = [head];
|
|
4235
|
-
for (let step = 0; step <
|
|
4235
|
+
for (let step = 0; step < reach2 && frontier.length; step++) {
|
|
4236
4236
|
const next = [];
|
|
4237
4237
|
for (const id of frontier) {
|
|
4238
4238
|
for (const nb of near.get(id) ?? []) {
|
|
@@ -4278,9 +4278,9 @@ var byId = (a, b) => byCodePoint(a, b);
|
|
|
4278
4278
|
function point(e) {
|
|
4279
4279
|
return [e.x, e.y, whole3(e.z) ? e.z : 0];
|
|
4280
4280
|
}
|
|
4281
|
-
function largest(
|
|
4281
|
+
function largest(points2, index) {
|
|
4282
4282
|
let best = null;
|
|
4283
|
-
for (const p of
|
|
4283
|
+
for (const p of points2) if (best === null || p[index] > best) best = p[index];
|
|
4284
4284
|
return best;
|
|
4285
4285
|
}
|
|
4286
4286
|
function mapSpace(elements) {
|
|
@@ -4290,8 +4290,8 @@ function mapSpace(elements) {
|
|
|
4290
4290
|
if (!isRow(e) || typeof e.type !== "string") continue;
|
|
4291
4291
|
const id = idOf2(e.id);
|
|
4292
4292
|
if (id === null) continue;
|
|
4293
|
-
const
|
|
4294
|
-
if (
|
|
4293
|
+
const rows2 = byType.get(e.type);
|
|
4294
|
+
if (rows2) rows2.set(id, e);
|
|
4295
4295
|
else byType.set(e.type, /* @__PURE__ */ new Map([[id, e]]));
|
|
4296
4296
|
}
|
|
4297
4297
|
const indexed = (type) => byType.get(type) ?? /* @__PURE__ */ new Map();
|
|
@@ -4311,10 +4311,10 @@ function mapSpace(elements) {
|
|
|
4311
4311
|
out.no_point++;
|
|
4312
4312
|
continue;
|
|
4313
4313
|
}
|
|
4314
|
-
const
|
|
4315
|
-
const group = placed.get(
|
|
4314
|
+
const key3 = JSON.stringify([z, m]);
|
|
4315
|
+
const group = placed.get(key3);
|
|
4316
4316
|
if (group) group.markers.push(mk);
|
|
4317
|
-
else placed.set(
|
|
4317
|
+
else placed.set(key3, { zone: z, map: m, markers: [mk] });
|
|
4318
4318
|
}
|
|
4319
4319
|
const rowId = (r) => r.id;
|
|
4320
4320
|
const markerOrder = (a, b) => {
|
|
@@ -4361,8 +4361,8 @@ function mapSpace(elements) {
|
|
|
4361
4361
|
for (const o of outlines) if (o.map === mid) own4.push(...o.points);
|
|
4362
4362
|
for (const q of pins) if (q.map === mid) own4.push([q.x, q.y, q.z]);
|
|
4363
4363
|
let measured = false;
|
|
4364
|
-
const slot = (
|
|
4365
|
-
const v = mp[
|
|
4364
|
+
const slot = (key3, i) => {
|
|
4365
|
+
const v = mp[key3];
|
|
4366
4366
|
if (whole3(v)) return v;
|
|
4367
4367
|
measured = true;
|
|
4368
4368
|
return largest(own4, i);
|
|
@@ -5215,10 +5215,10 @@ function layoutByKind(graph) {
|
|
|
5215
5215
|
fy.fill(0);
|
|
5216
5216
|
const grid = /* @__PURE__ */ new Map();
|
|
5217
5217
|
for (let i = 0; i < n; i++) {
|
|
5218
|
-
const
|
|
5219
|
-
const c = grid.get(
|
|
5218
|
+
const key3 = cellKey(Math.floor(px[i] / cell), Math.floor(py[i] / cell));
|
|
5219
|
+
const c = grid.get(key3);
|
|
5220
5220
|
if (c) c.push(i);
|
|
5221
|
-
else grid.set(
|
|
5221
|
+
else grid.set(key3, [i]);
|
|
5222
5222
|
}
|
|
5223
5223
|
for (let i = 0; i < n; i++) {
|
|
5224
5224
|
const cx = Math.floor(px[i] / cell);
|
|
@@ -5345,13 +5345,13 @@ function layoutAround(graph, focus, options) {
|
|
|
5345
5345
|
});
|
|
5346
5346
|
}
|
|
5347
5347
|
}
|
|
5348
|
-
const
|
|
5348
|
+
const points2 = [];
|
|
5349
5349
|
for (const x of graph.nodes) {
|
|
5350
5350
|
const j = index.get(x.id);
|
|
5351
5351
|
const p = at.get(j);
|
|
5352
|
-
if (p)
|
|
5352
|
+
if (p) points2.push({ id: x.id, depth: depth.get(j), x: p[0], y: p[1] });
|
|
5353
5353
|
}
|
|
5354
|
-
return { method: "around", version: 1, points };
|
|
5354
|
+
return { method: "around", version: 1, points: points2 };
|
|
5355
5355
|
}
|
|
5356
5356
|
function reachAround(fn, graph, focus, options) {
|
|
5357
5357
|
if (options !== void 0 && options !== null && (typeof options !== "object" || Array.isArray(options))) {
|
|
@@ -5407,13 +5407,1693 @@ function unplacedAround(graph, focus, placed, options) {
|
|
|
5407
5407
|
return N.filter((x, j) => depth.has(j) && !ids.has(x.id)).map((x) => x.id);
|
|
5408
5408
|
}
|
|
5409
5409
|
|
|
5410
|
+
// src/layout-directions.generated.ts
|
|
5411
|
+
var LAYOUT_DIRECTIONS = {
|
|
5412
|
+
"1": [[0, 0, 1]],
|
|
5413
|
+
"2": [[1, 0, 0], [-1, 0, 0]],
|
|
5414
|
+
"3": [[0, 0, 1], [-0.7373688780783197, 0.6754902942615238, 0], [0, -0, -1]],
|
|
5415
|
+
"4": [[0, 0, 1], [-0.695198045233462, 0.6368583569306933, 0.33333333333333337], [0.08242576373001424, -0.9391990642895748, -0.33333333333333326], [0, 0, -1]],
|
|
5416
|
+
"5": [[0, 0, 1], [-0.6385801803758553, 0.5849917548403054, 0.5], [0.08742572471695988, -0.9961710408648278, 0], [0.5269235102573634, 0.6872784110810248, -0.5], [-0, -0, -1]],
|
|
5417
|
+
"6": [[0, 0, 1], [-0.5898951024626559, 0.5403922354092191, 0.6], [0.08565936637983158, -0.976044298662415, 0.19999999999999996], [0.5961458996313616, 0.7775667600616132, -0.19999999999999996], [-0.7877707882523429, -0.1393455603034493, -0.6000000000000001], [0, -0, -1]],
|
|
5418
|
+
"7": [[0, 0, 1], [-0.5496023119586257, 0.5034807387033677, 0.6666666666666667], [0.08242576373001424, -0.9391990642895748, 0.33333333333333337], [0.6084388609788626, 0.7936007512916959, 0], [-0.9283967773231725, -0.16422031769801332, -0.33333333333333326], [0.6288980651919651, -0.40005347036784733, -0.6666666666666667], [-0, 0, -1]],
|
|
5419
|
+
"8": [[0, 0, 1], [-0.516050715285824, 0.4727447277551981, 0.7142857142857143], [0.07898983319899221, -0.9000484080667219, 0.4285714285714286], [0.6021982974369867, 0.7854610412354569, 0.1428571428571429], [-0.9746135928368869, -0.17239542161051932, -0.1428571428571428], [0.7623395769811511, -0.4849380372588282, -0.4285714285714286], [-0.18168516629672943, 0.6758597626098751, -0.7142857142857142], [-0, -0, -1]],
|
|
5420
|
+
"9": [[0, 0, 1], [-0.4877236689784852, 0.44679483291345823, 0.75], [0.07571289854915235, -0.8627094279033269, 0.5], [0.5891183939391361, 0.7684006233226082, 0.25], [-0.9847134853154287, -0.17418195037931164, 0], [0.816962551270686, -0.5196847023160215, -0.25], [-0.22482392297649015, 0.8363337872270026, -0.5], [-0.30486134122856906, -0.586991961294461, -0.75], [0, 0, -1]],
|
|
5421
|
+
"10": [[0, 0, 1], [-0.4634653634889746, 0.42457223795379545, 0.7777777777777778], [0.07269269081806179, -0.8282957185649263, 0.5555555555555556], [0.5736416593807637, 0.7482139637241293, 0.33333333333333337], [-0.9786161295671286, -0.17310341400072715, 0.11111111111111116], [0.838530753589287, -0.5334046271571298, -0.11111111111111116], [-0.24475728589475018, 0.9104849037135786, -0.33333333333333326], [-0.38323470525217274, -0.7378951045925418, -0.5555555555555556], [0.5904004074166422, 0.2156132818666903, -0.7777777777777777], [-0, 0, -1]],
|
|
5422
|
+
"11": [[0, 0, 1], [-0.44242132684699176, 0.40529417655691424, 0.8], [0.0699405797735679, -0.7969368326918622, 0.6], [0.5576434272376701, 0.727347102873604, 0.4], [-0.9648182327441664, -0.17066276033283695, 0.19999999999999996], [0.8437552948123972, -0.5367280526263227, 0], [-0.25435923281542117, 0.9462036676538251, -0.19999999999999996], [-0.4224282658171793, -0.8133599204772083, -0.3999999999999999], [0.7514570370592945, 0.2744309046992816, -0.6000000000000001], [-0.5546073336826828, 0.2289338450849617, -0.8], [0, -0, -1]],
|
|
5423
|
+
"12": [[0, 0, 1], [-0.42395729644554403, 0.38837961221886946, 0.8181818181818181], [0.06743926123364803, -0.7684355980551066, 0.6363636363636364], [0.5419508178466923, 0.7068788727832848, 0.4545454545454546], [-0.947384361744101, -0.1675789540290368, 0.2727272727272727], [0.8402614690603121, -0.5345055666713762, 0.09090909090909094], [-0.25852933421817137, 0.96171623701526, -0.09090909090909083], [-0.4434346781506459, -0.8538064891555796, -0.2727272727272727], [0.8366755929177183, 0.3055525846198174, -0.4545454545454546], [-0.7130301937142096, 0.29432849873215816, -0.6363636363636365], [0.2436943129985174, -0.520760592027541, -0.8181818181818181], [0, 0, -1]],
|
|
5424
|
+
"13": [[0, 0, 1], [-0.4075959834451839, 0.3733913092653723, 0.8333333333333334], [0.06516328781643527, -0.7425020548634919, 0.6666666666666667], [0.5269235102573634, 0.6872784110810248, 0.5], [-0.9283967773231725, -0.16422031769801332, 0.33333333333333337], [0.8319539402538132, -0.5292209968608358, 0.16666666666666663], [-0.25960430490148856, 0.9657150743757783, 0], [-0.4544604551325598, -0.8750359518002268, -0.16666666666666674], [0.8856006111249631, 0.32341992280003534, -0.33333333333333326], [-0.8005067334905939, 0.33043754271604686, -0.5], [0.3159161523060558, -0.6750944676618913, -0.6666666666666667], [0.1654353806952051, 0.5274340625801373, -0.8333333333333333], [-0, -0, -1]],
|
|
5425
|
+
"14": [[0, 0, 1], [-0.39297241869283406, 0.3599949260555726, 0.8461538461538461], [0.06308661492714052, -0.7188394383926304, 0.6923076923076923], [0.5127010600321121, 0.6687277432853984, 0.5384615384615384], [-0.9089662941373189, -0.16078333881167228, 0.3846153846153846], [0.8209810829027779, -0.5222409632018149, 0.23076923076923073], [-0.2588351052703015, 0.9628536900881661, 0.07692307692307687], [-0.4595413712680014, -0.8848189466381307, -0.07692307692307687], [0.9139676157188188, 0.3337795073808984, -0.23076923076923084], [-0.8532420518195122, 0.3522059155153258, -0.3846153846153846], [0.3571538652245594, -0.7632170648988335, -0.5384615384615385], [0.21596396222355244, 0.6885271426692644, -0.6923076923076923], [-0.4611045460217621, -0.2672195095368558, -0.8461538461538463], [0, -0, -1]],
|
|
5426
|
+
"15": [[0, 0, 1], [-0.3798030426918194, 0.3479306988625974, 0.8571428571428572], [0.061185261699879714, -0.6971744990445823, 0.7142857142857143], [0.49931645049733125, 0.6512698903049704, 0.5714285714285714], [-0.8896964160798639, -0.1573747687111584, 0.4285714285714286], [0.808583226675384, -0.5143544619015181, 0.2857142857142857], [-0.25694162625884587, 0.9558100425451458, 0.1428571428571429], [-0.4609070247133692, -0.8874484292452546, 0], [0.9296869770656191, 0.33952019293303454, -0.1428571428571428], [-0.8858140706674197, 0.36565117140027187, -0.2857142857142858], [0.3829482061405273, -0.8183380731861357, -0.4285714285714286], [0.24560784405736685, 0.7830365091696518, -0.5714285714285714], [-0.6055217096090176, -0.3509122077664434, -0.7142857142857142], [0.5030649401885496, -0.11059741589237235, -0.8571428571428572], [-0, 0, -1]],
|
|
5427
|
+
"16": [[0, 0, 1], [-0.36786422792519446, 0.3369937665623645, 0.8666666666666667], [0.05943806350956925, -0.6772660768327722, 0.7333333333333334], [0.4867510887830901, 0.6348806010333568, 0.6], [-0.8709133751451783, -0.15405231324279442, 0.4666666666666667], [0.7955001208318675, -0.5060320608868306, 0.33333333333333337], [-0.25435923281542117, 0.9462036676538251, 0.19999999999999996], [-0.4598816463026073, -0.8854741255110502, 0.06666666666666665], [0.9372315911853896, 0.3422754739090409, -0.06666666666666665], [-0.905669983418706, 0.3738474035410179, -0.19999999999999996], [0.3996058363695167, -0.8539344614361853, -0.33333333333333326], [0.2646966091123282, 0.8438945001282196, -0.46666666666666656], [-0.6921689678025839, -0.4011260649859411, -0.6000000000000001], [0.6640118437577864, -0.14598114115051664, -0.7333333333333334], [-0.28692497025223807, 0.40812124464997057, -0.8666666666666667], [-0, -0, -1]],
|
|
5428
|
+
"17": [[0, 0, 1], [-0.3569771731011225, 0.32702033252495366, 0.875], [0.057826681447667144, -0.658905209353174, 0.75], [0.47496243362009977, 0.6195043879180133, 0.625], [-0.852786893732276, -0.15084599390920442, 0.5], [0.7821820926083319, -0.497560221483642, 0.375], [-0.25136078737180445, 0.9350496000597116, 0.25], [-0.4572920118428536, -0.8804879419416914, 0.125], [0.9393212963241181, 0.343038630874102, 0], [-0.917095675135622, 0.3785637629878722, -0.125], [0.4103871200443174, -0.8769734384242952, -0.25], [0.27744356783852625, 0.8845338131835487, -0.375], [-0.7492948872853635, -0.43423170299739083, -0.5], [0.7624172814240208, -0.16761530057248775, -0.625], [-0.3804123602945737, 0.5410974368217905, -0.75], [-0.06221497017514103, -0.4801086309223219, -0.875], [0, 0, -1]],
|
|
5429
|
+
"18": [[0, 0, 1], [-0.34699711909567993, 0.3178777855348348, 0.8823529411764706], [0.05633534298084221, -0.641912176723608, 0.7647058823529411], [0.4638981751574867, 0.6050730220215469, 0.6470588235294117], [-0.835396461869561, -0.14776987137716055, 0.5294117647058824], [0.7689059306077044, -0.4891150139444908, 0.4117647058823529], [-0.24812180506217843, 0.9230007473134937, 0.2941176470588235], [-0.45367351003109324, -0.8735207368940686, 0.17647058823529416], [0.9376947647205491, 0.34244462414121385, 0.05882352941176472], [-0.9227449565713303, 0.3808957042416165, -0.05882352941176472], [0.4171941193684078, -0.8915196005990602, -0.17647058823529416], [0.28604630689858945, 0.9119607009067109, -0.2941176470588236], [-0.7884584956061721, -0.4569278145353718, -0.41176470588235303], [0.8285775485458468, -0.18216044970508394, -0.5294117647058822], [-0.4385017292091751, 0.6237235865135268, -0.6470588235294117], [-0.0828096513923031, -0.639036364482566, -0.7647058823529411], [0.35983482139107914, 0.30326916841591733, -0.8823529411764706], [-0, 0, -1]],
|
|
5430
|
+
"19": [[0, 0, 1], [-0.3378055299289004, 0.30945753692442424, 0.8888888888888888], [0.054950509153342826, -0.6261327095263831, 0.7777777777777778], [0.4535035511004269, 0.591515075627712, 0.6666666666666667], [-0.8187689969303081, -0.14482870695098746, 0.5555555555555556], [0.7558414070299084, -0.4808044334461958, 0.4444444444444444], [-0.24475728589475018, 0.9104849037135786, 0.33333333333333337], [-0.4493825253065195, -0.865258706919354, 0.2222222222222222], [0.9335050094639784, 0.3409145322413112, 0.11111111111111116], [-0.9243455561378048, 0.38155640847493627, 0], [0.42122153640807447, -0.9001259568825218, -0.11111111111111116], [0.291800583580539, 0.9303062417143476, -0.22222222222222232], [-0.8157289514335003, -0.4727316011037246, -0.33333333333333326], [0.8749124248343603, -0.19234704227756905, -0.4444444444444444], [-0.47820828375373015, 0.6802020744166177, -0.5555555555555556], [-0.09578621274197921, -0.7391755928087071, -0.6666666666666667], [0.4806119910350665, 0.405060294855434, -0.7777777777777777], [-0.4577316351212349, 0.018928640181410113, -0.8888888888888888], [0, -0, -1]],
|
|
5431
|
+
"20": [[0, 0, 1], [-0.3293043372158504, 0.30166974801980206, 0.8947368421052632], [0.053660546862797975, -0.6114342545600823, 0.7894736842105263], [0.4437250612693587, 0.5787607672261262, 0.6842105263157895], [-0.8029008272447404, -0.14202185116400012, 0.5789473684210527], [0.7430908708905336, -0.47269358605465456, 0.4736842105263158], [-0.24134348850096937, 0.8977857475678827, 0.368421052631579], [-0.4446613324391361, -0.8561683373444298, 0.26315789473684215], [0.9275384024876668, 0.3387355369431874, 0.1578947368421053], [-0.9230644113001568, 0.3810275705098016, 0.052631578947368474], [0.4232585436290039, -0.9044789229952026, -0.05263157894736836], [0.2955296325164402, 0.9421950373368883, -0.1578947368421053], [-0.8347149180670507, -0.4837343568468028, -0.26315789473684204], [0.9079754606968211, -0.19961585796282524, -0.368421052631579], [-0.5065134773100863, 0.7204632995519659, -0.4736842105263157], [-0.10478310766339541, -0.8086040099744368, -0.5789473684210527], [0.5576466989837349, 0.4699852282691597, -0.6842105263157894], [-0.6132602712464177, 0.025360237574365733, -0.7894736842105263], [0.3165587908790109, -0.3150182777184845, -0.894736842105263], [-0, 0, -1]],
|
|
5432
|
+
"21": [[0, 0, 1], [-0.32141164236553593, 0.29443939300285343, 0.9], [0.052455434830175916, -0.5977026245188966, 0.8], [0.434512257882468, 0.5667442966187481, 0.7], [-0.787770788252343, -0.13934556030344933, 0.6], [0.7307135198851643, -0.4648201284981465, 0.5], [-0.23793127558949334, 0.8850924856173826, 0.4], [-0.43967727908253185, -0.846571845892941, 0.30000000000000004], [0.9203431522094901, 0.3361078430817991, 0.19999999999999996], [-0.9197122159024477, 0.3796438329800835, 0.09999999999999998], [0.4238459950479107, -0.9057342725556136, 0], [0.29778368525136917, 0.9493813126442471, -0.10000000000000009], [-0.8477303934526246, -0.4912770908730207, -0.19999999999999996], [0.9316893075381398, -0.20482928066832, -0.30000000000000004], [-0.5271148286859193, 0.7497666019365054, -0.3999999999999999], [-0.11129352202378986, -0.8588444282613353, -0.5], [0.6117191963648345, 0.5155575863070594, -0.6000000000000001], [-0.7135330034354017, 0.029506829861152873, -0.7], [0.425297648582049, -0.42322796470764995, -0.8], [-0.020134384491006584, 0.43542462787624736, -0.8999999999999999], [-0, -0, -1]],
|
|
5433
|
+
"22": [[0, 0, 1], [-0.31405846397635756, 0.28770327925906725, 0.9047619047619048], [0.051326510634756045, -0.5848391155866024, 0.8095238095238095], [0.42581849973668684, 0.555404828615438, 0.7142857142857143], [-0.7733481354144034, -0.13679439609333258, 0.6190476190476191], [0.7187406459336746, -0.4572039661346827, 0.5238095238095238], [-0.2345545411067194, 0.8725312016532483, 0.4285714285714286], [-0.434547310228452, -0.836694403030226, 0.33333333333333337], [0.9123081179980854, 0.33317346147489496, 0.23809523809523814], [-0.9148648382749645, 0.37764290596119643, 0.1428571428571429], [0.42336517130260093, -0.9047067801402696, 0.04761904761904767], [0.2989443477565133, 0.9530816876051537, -0.04761904761904767], [-0.8563370140404155, -0.49626480342558954, -0.1428571428571428], [0.9485883482254093, -0.20854448735788095, -0.23809523809523814], [-0.5422372258728768, 0.7712766557899802, -0.33333333333333326], [-0.11611042384119566, -0.8960161271359254, -0.4285714285714286], [0.6513550981968154, 0.5489627663325237, -0.5238095238095237], [-0.784682803064974, 0.0324490974538459, -0.6190476190476191], [0.4960772513483495, -0.49366312305256654, -0.7142857142857142], [-0.027118399635443817, 0.5864603944131874, -0.8095238095238095], [-0.2728893717989686, -0.32701267016856467, -0.9047619047619047], [0, 0, -1]],
|
|
5434
|
+
"23": [[0, 0, 1], [-0.307186245354415, 0.28140776406012985, 0.9090909090909091], [0.05026625749026777, -0.5727580778606413, 0.8181818181818181], [0.4176011513068299, 0.5446867527235258, 0.7272727272727273], [-0.759597363264414, -0.13436207811655637, 0.6363636363636364], [0.707185404690833, -0.44985346751496536, 0.5454545454545454], [-0.23123566619583744, 0.8601851524125683, 0.4545454545454546], [-0.4293537809020744, -0.8266945783458458, 0.36363636363636365], [0.903712927731064, 0.3300345117748937, 0.2727272727272727], [-0.9089387178823998, 0.375196689610436, 0.18181818181818177], [0.4220909316290248, -0.9019838039713488, 0.09090909090909094], [0.2992838644448729, 0.954164120307897, 0], [-0.8616285392512325, -0.4993313504456436, -0.09090909090909083], [0.9603967039963224, -0.21114052124907454, -0.18181818181818188], [-0.5533270695193799, 0.7870508171953314, -0.2727272727272727], [-0.11971297375179911, -0.9238167561572064, -0.36363636363636354], [0.6810908622541959, 0.5740240997605432, -0.4545454545454546], [-0.837424678568082, 0.03463013959140024, -0.5454545454545454], [0.5467833660637457, -0.5441224796955638, -0.6363636363636365], [-0.03170343356140929, 0.6856159803167561, -0.7272727272727273], [-0.3683818574153218, -0.44144458261930436, -0.8181818181818181], [0.41287732752774026, 0.05555206046417563, -0.9090909090909092], [-0, 0, -1]],
|
|
5435
|
+
"24": [[0, 0, 1], [-0.30074492230798877, 0.27550698450539274, 0.9130434782608696], [0.049268126283565555, -0.5613848875746095, 0.8260869565217391], [0.40982149143592084, 0.5345395640505101, 0.7391304347826086], [-0.7464811427533351, -0.132042003389954, 0.6521739130434783], [0.69604917898279, -0.4427695122797996, 0.5652173913043479], [-0.22798912690196857, 0.8481081880616413, 0.4782608695652174], [-0.4241549095354004, -0.8166844678879457, 0.3913043478260869], [0.8947608047681981, 0.32676521082684135, 0.30434782608695654], [-0.9022394029707872, 0.37243130980204714, 0.21739130434782605], [0.420225032678538, -0.8979964862938741, 0.13043478260869568], [0.29900085363505524, 0.9532618372500109, 0.04347826086956519], [-0.864393042941632, -0.5009334368415268, -0.04347826086956519], [0.9683319264178566, -0.2128850576384003, -0.13043478260869557], [-0.5613749417978571, 0.7984980873586381, -0.21739130434782616], [-0.1224142672755785, -0.944662451843793, -0.30434782608695654], [0.703676898167669, 0.5930596347396514, -0.3913043478260869], [-0.8774678701383942, 0.03628605128024159, -0.4782608695652173], [0.5847431534926765, -0.5818975382406665, -0.5652173913043479], [-0.035016320853924476, 0.7572602223934733, -0.6521739130434783], [-0.4315575388186394, -0.5171501629767417, -0.7391304347826086], [0.5585099024388678, 0.07514671744245928, -0.826086956521739], [-0.33479712002497747, 0.23294311586366684, -0.9130434782608696], [0, -0, -1]],
|
|
5436
|
+
"25": [[0, 0, 1], [-0.2946914091498117, 0.2699614705759335, 0.9166666666666666], [0.048326387651842655, -0.5506542615944049, 0.8333333333333334], [0.402444478534368, 0.5249175570479622, 0.75], [-0.7339620971753463, -0.12982756050054534, 0.6666666666666667], [0.6853257779900078, -0.4359481623365476, 0.5833333333333333], [-0.22482392297649015, 0.8363337872270026, 0.5], [-0.41899183701761944, -0.8067432859351786, 0.41666666666666663], [0.8856006111249631, 0.32341992280003534, 0.33333333333333337], [-0.8949937362656377, 0.3694404039155357, 0.25], [0.41791778707511407, -0.8930660364544505, 0.16666666666666663], [0.2982428739362337, 0.9508452785294838, 0.08333333333333337], [-0.86521120975323, -0.5014075812324265, 0], [0.9732786302096672, -0.21397257659043498, -0.08333333333333326], [-0.5670852647332059, 0.8066204341229474, -0.16666666666666674], [-0.12442994035028206, -0.9602172618446438, -0.25], [0.7209179865525995, 0.6075904422831507, -0.33333333333333326], [-0.9082830553033093, 0.037560355932476766, -0.41666666666666674], [0.6138642797364022, -0.6108769483813479, -0.5], [-0.037518210339173505, 0.8113658891740322, -0.5833333333333333], [-0.4775564006481947, -0.5722721727949878, -0.6666666666666667], [0.6555307995236941, 0.08820074192333299, -0.75], [-0.45374651829182727, 0.31570500897768483, -0.8333333333333333], [0.08771630578430308, -0.38990777361034584, -0.9166666666666667], [0, 0, -1]],
|
|
5437
|
+
"26": [[0, 0, 1], [-0.2889884005600614, 0.2647370475429109, 0.92], [0.047436009123543434, -0.5405088575022904, 0.84], [0.3954384538772192, 0.5157794385153351, 0.76], [-0.7220038534882782, -0.12771231556931806, 0.6799999999999999], [0.6750042358499178, -0.4293824421010582, 0.6], [-0.22174523823979114, 0.8248812334621138, 0.52], [-0.4138934816723466, -0.7969267129599451, 0.43999999999999995], [0.8763419668271457, 0.32003868075207725, 0.36], [-0.8873717338922925, 0.3662941521359388, 0.28], [0.41528256695583476, -0.8874347241248635, 0.19999999999999996], [0.29712120682174714, 0.9472692270187967, 0.12], [-0.8645187636961245, -0.5010062945885256, 0.040000000000000036], [0.9758941202227466, -0.21454758473278432, -0.040000000000000036], [-0.570973481586335, 0.8121510224860761, -0.1200000000000001], [-0.12591424660024989, -0.9716715507325977, -0.19999999999999996], [0.7340630356378014, 0.6186691035684713, -0.28], [-0.932155612294555, 0.038547561113035915, -0.3600000000000001], [0.6365272353578447, -0.6334296161750719, -0.43999999999999995], [-0.03945517463037865, 0.8532545277904398, -0.52], [-0.5125673159709543, -0.6142269504005273, -0.6000000000000001], [0.7266640964488232, 0.09777162641694916, -0.6799999999999999], [-0.5334947723421171, 0.37119176699333284, -0.76], [0.11908760571016992, -0.5293563470538716, -0.8400000000000001], [0.19485431256567315, 0.34004675689463526, -0.9199999999999999], [-0, -0, -1]],
|
|
5438
|
+
"27": [[0, 0, 1], [-0.2836034146455075, 0.25980395933135525, 0.9230769230769231], [0.046592552953324526, -0.5308981094789704, 0.8461538461538461], [0.38877482782567024, 0.5070879183314857, 0.7692307692307692], [-0.7105716385283298, -0.12569011771321628, 0.6923076923076923], [0.6650706895738738, -0.42306353307471545, 0.6153846153846154], [-0.21875559049229887, 0.8137598928590662, 0.5384615384615384], [-0.40887993175618537, -0.7872734276779366, 0.46153846153846156], [0.8670658119914937, 0.3166510438837865, 0.3846153846153846], [-0.8795017759676464, 0.3630455479092646, 0.3076923076923077], [0.4124057604590294, -0.8812871557389154, 0.23076923076923073], [0.29572083429508306, 0.9428046187363347, 0.15384615384615385], [-0.8626476153486857, -0.49992192587434325, 0.07692307692307687], [0.976675773628176, -0.21471942904125782, 0], [-0.5734253381966136, 0.8156385362099965, -0.07692307692307687], [-0.12698074610098126, -0.9799016537726546, -0.15384615384615374], [0.7440099803694885, 0.627052399118902, -0.23076923076923084], [-0.9506733960210262, 0.03931332960754407, -0.3076923076923077], [0.654304074741614, -0.651119945704077, -0.3846153846153846], [-0.04097736474196862, 0.886173292364148, -0.46153846153846145], [-0.5398936176868647, -0.6469729926191838, -0.5384615384615385], [0.7811876521480923, 0.10510769372067906, -0.6153846153846154], [-0.5923333661980372, 0.4121301280664876, -0.6923076923076923], [0.14024224455753304, -0.6233908376853995, -0.7692307692307692], [0.2649669341512124, 0.46240263023209566, -0.8461538461538463], [-0.36642029892180394, -0.11689806936342426, -0.9230769230769231], [0, -0, -1]],
|
|
5439
|
+
"28": [[0, 0, 1], [-0.2785080220768423, 0.2551361623468179, 0.9259259259259259], [0.04579209096111903, -0.5217772579386527, 0.8518518518518519], [0.3824277729205091, 0.4988093091494195, 0.7777777777777778], [-0.6996325887862029, -0.12375515384017699, 0.7037037037037037], [0.6555096436219682, -0.41698157826342375, 0.6296296296296297], [-0.21585563668288205, 0.8029722092349061, 0.5555555555555556], [-0.4039648490067198, -0.7778097349335349, 0.4814814814814815], [0.8578319040514615, 0.3132788355140178, 0.40740740740740744], [-0.8714813478729231, 0.35973483178374893, 0.33333333333333337], [0.40935375264471846, -0.87476519231393, 0.2592592592592593], [0.2941073434581424, 0.9376605556980218, 0.18518518518518523], [-0.8598538132902449, -0.4983028604753126, 0.11111111111111116], [0.9760056701025444, -0.21457210866093585, 0.03703703703703709], [-0.5747348291419023, 0.8175011523286958, -0.03703703703703698], [-0.12771495032263896, -0.9855674570782763, -0.11111111111111116], [0.7514233523703308, 0.6333003968895508, -0.18518518518518512], [-0.9649830160641499, 0.03990507732202582, -0.2592592592592593], [0.6682907807445782, -0.6650385862945781, -0.33333333333333326], [-0.04218417721069037, 0.9122717246427359, -0.40740740740740744], [-0.5615535436098882, -0.6729288228702761, -0.4814814814814814], [0.8240538197686103, 0.11087527594608598, -0.5555555555555556], [-0.6377211014104125, 0.4437097320415068, -0.6296296296296295], [0.15594009917209442, -0.6931693753072818, -0.7037037037037037], [0.31249774947930786, 0.5453502406393801, -0.7777777777777777], [-0.49900409121720346, -0.15919591529013416, -0.8518518518518519], [0.3428773855120988, -0.1584180488536721, -0.9259259259259258], [-0, 0, -1]],
|
|
5440
|
+
"29": [[0, 0, 1], [-0.2736772201610808, 0.2507107520744166, 0.9285714285714286], [0.045031133323085455, -0.5131065381386384, 0.8571428571428572], [0.3763739358981167, 0.4909131507721606, 0.7857142857142857], [-0.6891558805315475, -0.12190197166631211, 0.7142857142857143], [0.6463048212852868, -0.4111262237573086, 0.6428571428571428], [-0.21304474183108008, 0.7925158204939701, 0.5714285714285714], [-0.39915719218447976, -0.7685528842749874, 0.5], [0.848684214596046, 0.3099381139965485, 0.4285714285714286], [-0.8633847574533415, 0.3563926769576943, 0.3571428571428571], [0.40617791010778614, -0.8679786012795746, 0.2857142857142857], [0.29233180663739977, 0.9319998645285176, 0.2142857142857143], [-0.8563370140404155, -0.49626480342558954, 0.1428571428571429], [0.9741810677055418, -0.21417097494236687, 0.0714285714285714], [-0.5751294291397393, 0.8180624302199665, 0], [-0.12818243718167643, -0.9891750209047128, -0.0714285714285714], [0.7568062343350688, 0.6378370955081453, -0.1428571428571428], [-0.9759369139540713, 0.04035805539003135, -0.2142857142857142], [0.6792817520716277, -0.6759760707608481, -0.2857142857142858], [-0.04314510962358552, 0.9330527740205296, -0.3571428571428572], [-0.5788857759383629, -0.6936986298303354, -0.4285714285714286], [0.8582912883406427, 0.11548187891855381, -0.5], [-0.6736388772333649, 0.4687003849314331, -0.5714285714285714], [0.1681196764018798, -0.7473088172128562, -0.6428571428571428], [0.347954129581559, 0.6072263515975626, -0.7142857142857142], [-0.5893258193244872, -0.18801101005529297, -0.7857142857142858], [0.4675839256500151, -0.2160356334559198, -0.8571428571428572], [-0.14328801625781448, 0.3423793896216835, -0.9285714285714286], [-0, -0, -1]],
|
|
5441
|
+
"30": [[0, 0, 1], [-0.26908892081571595, 0.24650749402121833, 0.9310344827586207], [0.044306568817154286, -0.5048504993081459, 0.8620689655172413], [0.37059217392732463, 0.4833718661204398, 0.7931034482758621], [-0.679112748493399, -0.12012548302021492, 0.7241379310344828], [0.6374397351492023, -0.40548698161276814, 0.6551724137931034], [-0.2103213839623855, 0.7823850649669528, 0.5862068965517242], [-0.39446246605776236, -0.759513474798677, 0.5172413793103448], [0.8396548626164058, 0.30664060913543506, 0.4482758620689655], [-0.8552687578857846, 0.35304251031750383, 0.3793103448275862], [0.4029181971805925, -0.8610127840927965, 0.31034482758620685], [0.29043429402477744, 0.9259502953138384, 0.24137931034482762], [-0.8522543351759542, -0.4938988075724357, 0.1724137931034483], [0.9714357465709926, -0.21356742379216737, 0.10344827586206895], [-0.5747873955506776, 0.8175759226359202, 0.03448275862068961], [-0.1284342635717169, -0.991118347776237, -0.034482758620689724], [0.7605465271307019, 0.640989418236053, -0.10344827586206895], [-0.9841834530143472, 0.04069907567055569, -0.17241379310344818], [0.6878699288017551, -0.6845224536768124, -0.24137931034482762], [-0.04391069950148329, 0.9496093609794386, -0.31034482758620685], [-0.5928286352874143, -0.710406835193778, -0.3793103448275863], [0.8859122590409625, 0.11919824146045263, -0.4482758620689655], [-0.7025230394025818, 0.48879723264119496, -0.5172413793103448], [0.17781533072564126, -0.7904069727641114, -0.5862068965517242], [0.3756099039705486, 0.6554893654696115, -0.6551724137931034], [-0.6570295015149592, -0.20961033127234707, -0.7241379310344827], [0.5529237385096573, -0.2554647915573513, -0.7931034482758621], [-0.195652274678809, 0.46750110813242074, -0.8620689655172413], [-0.1235118016763087, -0.34339427304639153, -0.9310344827586208], [0, 0, -1]],
|
|
5442
|
+
"31": [[0, 0, 1], [-0.26472352880690797, 0.2425084373478725, 0.9333333333333333], [0.04361561449083707, -0.49697743113895576, 0.8666666666666667], [0.36506331658731744, 0.47616045077501745, 0.8], [-0.6694764369228443, -0.11842095518663467, 0.7333333333333334], [0.6288980651919651, -0.40005347036784733, 0.6666666666666667], [-0.20768344392119087, 0.7725720595006227, 0.6], [-0.3898836348008979, -0.7506972138419028, 0.5333333333333333], [0.8307670126659575, 0.30339478058843256, 0.4666666666666667], [-0.8471766958595086, 0.3497022247463771, 0.4], [0.3996058363695167, -0.8539344614361853, 0.33333333333333337], [0.28844644245463147, 0.9196127112671703, 0.2666666666666667], [-0.8477303934526246, -0.4912770908730207, 0.19999999999999996], [0.9679552796397968, -0.2128022529008211, 0.1333333333333333], [-0.5738499405044762, 0.8162424892999413, 0.06666666666666665], [-0.12851068979899324, -0.9917081236973845, 0], [0.7629478832366341, 0.6430132837043843, -0.06666666666666665], [-0.9902249284989514, 0.04094890964932928, -0.1333333333333333], [0.6945081518876892, -0.691128372273593, -0.19999999999999996], [-0.04451879916094646, 0.9627600767637574, -0.2666666666666666], [-0.6040663748960826, -0.7238734030262435, -0.33333333333333326], [0.908330120561029, 0.12221453302118644, -0.3999999999999999], [-0.7259944292669236, 0.5051280143642958, -0.46666666666666656], [0.18566042482444997, -0.8252792025790787, -0.5333333333333334], [0.39774469997223616, 0.6941175359000779, -0.6000000000000001], [-0.7100952704949538, -0.22653975893042197, -0.6666666666666667], [0.6171792939217774, -0.2851524879366096, -0.7333333333333334], [-0.23163664932267067, 0.5534839317365644, -0.8], [-0.16884966287564607, -0.46944507691067494, -0.8666666666666667], [0.3177927337300666, 0.16702295434238915, -0.9333333333333333], [-0, 0, -1]],
|
|
5443
|
+
"32": [[0, 0, 1], [-0.2605635920811433, 0.23869759454376707, 0.935483870967742], [0.04295577310065062, -0.4894588788296008, 0.8709677419354839], [0.3597699530565615, 0.4692561954023253, 0.8064516129032258], [-0.6602221112766007, -0.11678399528454535, 0.7419354838709677], [0.6206639044789506, -0.3948155713328065, 0.6774193548387097], [-0.20512841356082354, 0.7630674739143751, 0.6129032258064516], [-0.38542179525703346, -0.7421062133094, 0.5483870967741935], [0.8220370312060853, 0.3002066053609888, 0.4838709677419355], [-0.839141605941583, 0.34638545643338076, 0.4193548387096774], [0.39626529010340755, -0.8467959080993048, 0.3548387096774194], [0.28639336034944646, 0.9130671619959212, 0.29032258064516125], [-0.842864694861574, -0.48845731908314693, 0.22580645161290325], [0.9638881602935612, -0.21190810812171773, 0.16129032258064513], [-0.5724299801502497, 0.8142227418146978, 0.09677419354838712], [-0.12844380939383954, -0.991192012226729, 0.032258064516129004], [0.7642510516375448, 0.6441115954123013, -0.032258064516129004], [-0.9944564247356997, 0.041123895303692426, -0.09677419354838701], [0.6995487126467727, -0.6961444034653116, -0.16129032258064524], [-0.04499842182909705, 0.9731323591592668, -0.22580645161290325], [-0.6131130569739477, -0.7347143516602861, -0.29032258064516125], [0.9265780800994169, 0.12466977016800276, -0.35483870967741926], [-0.7451935897330145, 0.5184862901481618, -0.4193548387096775], [0.1920767834034999, -0.8538005597643092, -0.4838709677419355], [0.41575488140098305, 0.7255477039332603, -0.5483870967741935], [-0.7527778018602946, -0.24015665058962812, -0.6129032258064515], [0.6677684784747181, -0.30852597434489415, -0.6774193548387097], [-0.25884286807863266, 0.6184918006069122, -0.7419354838709677], [-0.20012686320304487, -0.5564036616255285, -0.8064516129032258], [0.43492915554646666, 0.22858657476641525, -0.8709677419354838], [-0.34169760276581906, 0.0900703914907756, -0.935483870967742], [0, -0, -1]],
|
|
5444
|
+
"33": [[0, 0, 1], [-0.2565935101015265, 0.2350606742391798, 0.9375], [0.04232479698236247, -0.4822692314054483, 0.875], [0.3546962429362163, 0.462638439007107, 0.8125], [-0.6513267486990695, -0.11521053089496282, 0.75], [0.6127219134530144, -0.3897635267370161, 0.6875], [-0.20265354556067544, 0.753861088312487, 0.625], [-0.3810766765357113, -0.7337399516180761, 0.5625], [0.8134761049324166, 0.2970801688164052, 0.5], [-0.8311885418549458, 0.34310254719114075, 0.4375], [0.3929157534044839, -0.839638142729704, 0.375], [0.28429505799735505, 0.9063774434518329, 0.3125], [-0.837737151581558, -0.4854858029438326, 0.25], [0.9593540408900971, -0.21091129469007083, 0.1875], [-0.5706185404418606, 0.8116461552326856, 0.125], [-0.12825944676337947, -0.9897692985317091, 0.0625], [0.7646489954560431, 0.6444469828838243, 0], [-0.9971926874194682, 0.04123704835628656, -0.0625], [0.7032698820804025, -0.6998474640652896, -0.125], [-0.045372222301394455, 0.9812161390047724, -0.1875], [-0.6203639620517941, -0.7434033592790662, -0.25], [0.9414344361497554, 0.12666867186242986, -0.3125], [-0.760956044590783, 0.5294533956834635, -0.375], [0.197361688014682, -0.8772924906232785, -0.4375], [0.43057126799572026, 0.7514042741271556, -0.5], [-0.7876838013468469, -0.2512926164768494, -0.5625], [0.708644226524793, -0.3274116067171075, -0.625], [-0.28035152662437224, 0.6698856406278492, -0.6875], [-0.2238651405383096, -0.622402119896585, -0.75], [0.5160310885281405, 0.27121147776682025, -0.8125], [-0.46813234080986477, 0.12339818267655571, -0.875], [0.18820356785645184, -0.29269978996593404, -0.9375], [0, 0, -1]],
|
|
5445
|
+
"34": [[0, 0, 1], [-0.25279928917580424, 0.23158485706570656, 0.9393939393939394], [0.04172065726136552, -0.4753853708867998, 0.8787878787878788], [0.34982774866395483, 0.4562883503459223, 0.8181818181818181], [-0.6427690189371401, -0.11369678899645062, 0.7575757575757576], [0.6050574110936823, -0.38488799771697146, 0.696969696969697], [-0.2002559611866138, 0.7449421939474734, 0.6363636363636364], [-0.3768470128156466, -0.7255959915060745, 0.5757575757575757], [0.8050914646590575, 0.2940181116363958, 0.5151515151515151], [-0.8233363485624601, 0.33986127594637994, 0.4545454545454546], [0.3895722894434421, -0.832493354448225, 0.3939393939393939], [0.2821675333982468, 0.899594559779481, 0.33333333333333337], [-0.8324122518372322, -0.48239991469942456, 0.2727272727272727], [0.9544499180011202, -0.20983313703007533, 0.21212121212121215], [-0.5684895225945089, 0.8086178464278462, 0.1515151515151515], [-0.12797855215174117, -0.9876016542003292, 0.09090909090909094], [0.7642978363121707, 0.6441510255856059, 0.030303030303030276], [-0.998687203900876, 0.04129885130489479, -0.030303030303030276], [0.7058942902493737, -0.7024591007193342, -0.09090909090909083], [-0.045658162702376624, 0.9873998638039119, -0.1515151515151516], [-0.6261287598047602, -0.7503115136485516, -0.21212121212121215], [0.9534993447617368, 0.1282919882521207, -0.2727272727272727], [-0.7739126619494532, 0.5384682725687746, -0.33333333333333326], [0.20173331942850917, -0.896724830555627, -0.39393939393939403], [0.4428507103765296, 0.7728335383968978, -0.4545454545454546], [-0.8165521492645147, -0.2605024068384013, -0.5151515151515151], [0.7422286027524824, -0.34292844036891584, -0.5757575757575757], [-0.29780335546798314, 0.7115858934703944, -0.6363636363636365], [-0.2427043258357353, -0.6747798542684791, -0.696969696969697], [0.5778049704183031, 0.303678098804344, -0.7575757575757576], [-0.5559686628261057, 0.14655155526996755, -0.8181818181818181], [0.2580945824480962, -0.40139637592589594, -0.8787878787878789], [0.05806886795098674, 0.33788612461127565, -0.9393939393939394], [-0, -0, -1]],
|
|
5446
|
+
"35": [[0, 0, 1], [-0.24916833610166875, 0.22825860661845473, 0.9411764705882353], [0.041141517513863475, -0.46878637217168373, 0.8823529411764706], [0.34515128733508793, 0.4501887346540438, 0.8235294117647058], [-0.6345291630432852, -0.1122392745094053, 0.7647058823529411], [0.5976564225788388, -0.3801800946347573, 0.7058823529411764], [-0.19793272755964236, 0.7362998806556565, 0.6470588235294117], [-0.3727308227798641, -0.717670518068125, 0.5882352941176471], [0.7968873171839792, 0.29102197013683273, 0.5294117647058824], [-0.8155990201215925, 0.3366674192425908, 0.47058823529411764], [0.38624670121818105, -0.8253867655758073, 0.4117647058823529], [0.2800236048738724, 0.8927593778084879, 0.3529411764705882], [-0.82694224660668, -0.47922993485974796, 0.2941176470588235], [0.9492548338380724, -0.20869101235018583, 0.23529411764705888], [-0.5661032981700964, 0.80522368773455, 0.17647058823529416], [-0.12761824365592317, -0.9848211784056791, 0.11764705882352944], [0.7633249269380465, 0.6433310565351008, 0.05882352941176472], [-0.9991460540072825, 0.04131782619737533, 0], [0.707602003141318, -0.7041585031354356, -0.05882352941176472], [-0.04587066812929727, 0.9919954895842746, -0.11764705882352944], [-0.6306538002658213, -0.7557340244412493, -0.17647058823529416], [0.963244360215052, 0.1296031662984631, -0.23529411764705888], [-0.7845511357972309, 0.5458702455784307, -0.2941176470588236], [0.2053567583171396, -0.9128313797000149, -0.3529411764705883], [0.4530760585396283, 0.7906781343680971, -0.41176470588235303], [-0.8406112739970799, -0.2681779238337381, -0.47058823529411775], [0.7701382304823782, -0.35582339628033866, -0.5294117647058822], [-0.3122036703667882, 0.745994709742523, -0.588235294117647], [-0.2580495837719078, -0.7174435805050309, -0.6470588235294117], [0.6270054312140466, 0.3295364820991994, -0.7058823529411764], [-0.6230956285729644, 0.16424600801259084, -0.7647058823529411], [0.30680295688763426, -0.47714908949245827, -0.8235294117647058], [0.07970643411946908, 0.46378892996404153, -0.8823529411764706], [-0.26716378578020294, -0.20690665233061617, -0.9411764705882353], [0, -0, -1]],
|
|
5447
|
+
"36": [[0, 0, 1], [-0.24568928324747039, 0.2250715092156481, 0.9428571428571428], [0.040585711151640766, -0.46245324534697374, 0.8857142857142857], [0.34065479978934954, 0.4443238628923505, 0.8285714285714285], [-0.6265888744157015, -0.1108347492537324, 0.7714285714285715], [0.590505697160561, -0.3756313884491907, 0.7142857142857143], [-0.19568091270390542, 0.7279232416329959, 0.6571428571428571], [-0.3687256197706954, -0.7099587433962037, 0.6], [0.7888655590367059, 0.2880924369272564, 0.5428571428571429], [-0.8079867476656185, 0.3335251838314422, 0.48571428571428577], [0.3829482061405273, -0.8183380731861357, 0.4285714285714286], [0.27787355527291546, 0.8859046808808048, 0.37142857142857144], [-0.8213696093029024, -0.4760004776358065, 0.3142857142857143], [0.943833489470002, -0.20749914499893188, 0.2571428571428571], [-0.5635094549802144, 0.8015342127120348, 0.19999999999999996], [-0.12719259659861698, -0.9815364894415262, 0.1428571428571429], [0.7618349025080648, 0.6420752623680631, 0.08571428571428574], [-0.9987381560298804, 0.04130095833539563, 0.02857142857142858], [0.7085400371065, -0.7050919722181691, -0.02857142857142847], [-0.04602145026515789, 0.9952562922885649, -0.08571428571428563], [-0.6341375954006453, -0.7599087753370015, -0.1428571428571428], [0.9710457443504109, 0.13065283149995713, -0.19999999999999996], [-0.7932556631982214, 0.5519266290226972, -0.2571428571428571], [0.20835990619976336, -0.9261806731325936, -0.3142857142857143], [0.46161331683069345, 0.805576788426216, -0.37142857142857144], [-0.8607654532379618, -0.27460765671097226, -0.4285714285714286], [0.7935162350422854, -0.3666246273470695, -0.48571428571428577], [-0.3242237694677405, 0.7747161220480112, -0.5428571428571429], [-0.2707618235798361, -0.7527868455889234, -0.6000000000000001], [0.6672257499452777, 0.35067515440373603, -0.6571428571428573], [-0.6767380312435957, 0.17838597320386232, -0.7142857142857142], [0.34414366693751197, -0.5352224730805653, -0.7714285714285714], [0.094830902221739, 0.5517938815707484, -0.8285714285714285], [-0.36703160210458036, -0.28424990261771016, -0.8857142857142857], [0.3320596072551592, -0.027510459698353154, -0.9428571428571428], [-0, 0, -1]],
|
|
5448
|
+
"37": [[0, 0, 1], [-0.2423518395714441, 0.222014137420034, 0.9444444444444444], [0.04005172193379981, -0.45636871362968584, 0.8888888888888888], [0.3363272349563497, 0.43867932089645145, 0.8333333333333334], [-0.618931184882115, -0.10948021179867554, 0.7777777777777778], [0.5835927058714294, -0.3712339092567628, 0.7222222222222222], [-0.19349762433710338, 0.7198015177335018, 0.6666666666666667], [-0.3648285701866474, -0.7024552115630645, 0.6111111111111112], [0.7810263259878246, 0.2852295615908674, 0.5555555555555556], [-0.8005067334905939, 0.33043754271604686, 0.5], [0.3796839619622585, -0.811362572979005, 0.4444444444444444], [0.2757256344920085, 0.8790567709668954, 0.38888888888888884], [-0.8157289514335003, -0.4727316011037246, 0.33333333333333337], [0.938239049389318, -0.20626922304083145, 0.2777777777777778], [-0.5607489176491526, 0.7976076324270732, 0.2222222222222222], [-0.12671324897200167, -0.9778373968902916, 0.16666666666666663], [0.7599142812296179, 0.6404565607212775, 0.11111111111111116], [-0.9976029703775479, 0.041254014844705034, 0.05555555555555558], [0.7088294143034152, -0.7053799411794167, 0], [-0.04612010775734344, 0.9973898515161284, -0.05555555555555558], [-0.6367418675309263, -0.7630295637266504, -0.11111111111111116], [0.9772076193865111, 0.13148190307099206, -0.16666666666666674], [-0.8003336304410634, 0.556851294274912, -0.22222222222222232], [0.21084375879972228, -0.937221646969405, -0.2777777777777777], [0.4687466242189617, 0.8180253609590699, -0.33333333333333326], [-0.8777012451230772, -0.2800106362411353, -0.38888888888888884], [0.813205122286388, -0.37572139264307247, -0.4444444444444444], [-0.33433870460156717, 0.798885242450595, -0.5], [-0.2814161047927435, -0.7824084615177916, -0.5555555555555556], [0.7006671182609369, 0.3682510003577145, -0.6111111111111112], [-0.7207368879545201, 0.18998393062885344, -0.6666666666666667], [0.3740764189644628, -0.5817747798788795, -0.7222222222222223], [0.10645959124347575, 0.6194578951206725, -0.7777777777777777], [-0.43703340364077253, -0.3384632323572492, -0.8333333333333333], [0.4565586667605149, -0.03782495228995922, -0.8888888888888888], [-0.22319375514832496, 0.24126590936312214, -0.9444444444444444], [0, -0, -1]]
|
|
5449
|
+
};
|
|
5450
|
+
|
|
5451
|
+
// src/layout3d/order.ts
|
|
5452
|
+
function byCodePoint2(a, b) {
|
|
5453
|
+
const n = a.length < b.length ? a.length : b.length;
|
|
5454
|
+
for (let i = 0; i < n; i++) {
|
|
5455
|
+
const x = a.charCodeAt(i), y = b.charCodeAt(i);
|
|
5456
|
+
if (x === y) continue;
|
|
5457
|
+
const xs = x >= 55296 && x <= 57343, ys = y >= 55296 && y <= 57343;
|
|
5458
|
+
if (xs !== ys) return xs ? 1 : -1;
|
|
5459
|
+
return x < y ? -1 : 1;
|
|
5460
|
+
}
|
|
5461
|
+
return a.length - b.length;
|
|
5462
|
+
}
|
|
5463
|
+
|
|
5464
|
+
// src/layout3d/structure.ts
|
|
5465
|
+
function after(a, b) {
|
|
5466
|
+
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return a[i] > b[i];
|
|
5467
|
+
return false;
|
|
5468
|
+
}
|
|
5469
|
+
function structure(ids, pairs) {
|
|
5470
|
+
const sorted = [...ids].sort(byCodePoint2);
|
|
5471
|
+
const at = new Map(sorted.map((id, i) => [id, i]));
|
|
5472
|
+
const n = sorted.length;
|
|
5473
|
+
const deg = new Int32Array(n + 1);
|
|
5474
|
+
const ea = new Int32Array(pairs.length), eb = new Int32Array(pairs.length);
|
|
5475
|
+
let m = 0;
|
|
5476
|
+
for (const [x, y] of pairs) {
|
|
5477
|
+
const a = at.get(x), b = at.get(y);
|
|
5478
|
+
if (a === void 0 || b === void 0 || a === b) continue;
|
|
5479
|
+
ea[m] = a;
|
|
5480
|
+
eb[m] = b;
|
|
5481
|
+
m++;
|
|
5482
|
+
deg[a + 1]++;
|
|
5483
|
+
deg[b + 1]++;
|
|
5484
|
+
}
|
|
5485
|
+
for (let i = 0; i < n; i++) deg[i + 1] += deg[i];
|
|
5486
|
+
const fill = deg.slice(0, n);
|
|
5487
|
+
const nb = new Int32Array(2 * m);
|
|
5488
|
+
for (let k = 0; k < m; k++) {
|
|
5489
|
+
nb[fill[ea[k]]++] = eb[k];
|
|
5490
|
+
nb[fill[eb[k]]++] = ea[k];
|
|
5491
|
+
}
|
|
5492
|
+
const piece = new Int32Array(n).fill(-1);
|
|
5493
|
+
const queue = new Int32Array(n);
|
|
5494
|
+
let main = -1, mainSize = 0, pieces = 0;
|
|
5495
|
+
for (let s = 0; s < n; s++) {
|
|
5496
|
+
if (piece[s] !== -1) continue;
|
|
5497
|
+
let head2 = 0, tail2 = 0;
|
|
5498
|
+
queue[tail2++] = s;
|
|
5499
|
+
piece[s] = pieces;
|
|
5500
|
+
while (head2 < tail2) {
|
|
5501
|
+
const v = queue[head2++];
|
|
5502
|
+
for (let k = deg[v]; k < deg[v + 1]; k++) {
|
|
5503
|
+
const w = nb[k];
|
|
5504
|
+
if (piece[w] === -1) {
|
|
5505
|
+
piece[w] = pieces;
|
|
5506
|
+
queue[tail2++] = w;
|
|
5507
|
+
}
|
|
5508
|
+
}
|
|
5509
|
+
}
|
|
5510
|
+
if (tail2 > mainSize) {
|
|
5511
|
+
mainSize = tail2;
|
|
5512
|
+
main = pieces;
|
|
5513
|
+
}
|
|
5514
|
+
pieces++;
|
|
5515
|
+
}
|
|
5516
|
+
const body = new Uint8Array(n);
|
|
5517
|
+
if (mainSize === 1) {
|
|
5518
|
+
for (let i = 0; i < n; i++) if (piece[i] === main) body[i] = 1;
|
|
5519
|
+
} else if (mainSize > 1) {
|
|
5520
|
+
const disc = new Int32Array(n).fill(-1), low = new Int32Array(n), parent = new Int32Array(n).fill(-1), next = new Int32Array(n);
|
|
5521
|
+
const stackV = new Int32Array(n);
|
|
5522
|
+
const edgeA = new Int32Array(m), edgeB = new Int32Array(m);
|
|
5523
|
+
const stamp = new Int32Array(n).fill(-1);
|
|
5524
|
+
let best = [], blocks = 0, clock = 0, top = 0, etop = 0;
|
|
5525
|
+
let root2 = 0;
|
|
5526
|
+
while (piece[root2] !== main) root2++;
|
|
5527
|
+
disc[root2] = low[root2] = clock++;
|
|
5528
|
+
next[root2] = deg[root2];
|
|
5529
|
+
stackV[top++] = root2;
|
|
5530
|
+
while (top) {
|
|
5531
|
+
const v = stackV[top - 1];
|
|
5532
|
+
if (next[v] < deg[v + 1]) {
|
|
5533
|
+
const w = nb[next[v]++];
|
|
5534
|
+
if (disc[w] === -1) {
|
|
5535
|
+
parent[w] = v;
|
|
5536
|
+
disc[w] = low[w] = clock++;
|
|
5537
|
+
next[w] = deg[w];
|
|
5538
|
+
edgeA[etop] = v;
|
|
5539
|
+
edgeB[etop] = w;
|
|
5540
|
+
etop++;
|
|
5541
|
+
stackV[top++] = w;
|
|
5542
|
+
} else if (w !== parent[v] && disc[w] < disc[v]) {
|
|
5543
|
+
edgeA[etop] = v;
|
|
5544
|
+
edgeB[etop] = w;
|
|
5545
|
+
etop++;
|
|
5546
|
+
if (disc[w] < low[v]) low[v] = disc[w];
|
|
5547
|
+
}
|
|
5548
|
+
} else {
|
|
5549
|
+
top--;
|
|
5550
|
+
const u = parent[v];
|
|
5551
|
+
if (u === -1) continue;
|
|
5552
|
+
if (low[v] < low[u]) low[u] = low[v];
|
|
5553
|
+
if (low[v] >= disc[u]) {
|
|
5554
|
+
const members = [];
|
|
5555
|
+
for (; ; ) {
|
|
5556
|
+
etop--;
|
|
5557
|
+
const a = edgeA[etop], b = edgeB[etop];
|
|
5558
|
+
if (stamp[a] !== blocks) {
|
|
5559
|
+
stamp[a] = blocks;
|
|
5560
|
+
members.push(a);
|
|
5561
|
+
}
|
|
5562
|
+
if (stamp[b] !== blocks) {
|
|
5563
|
+
stamp[b] = blocks;
|
|
5564
|
+
members.push(b);
|
|
5565
|
+
}
|
|
5566
|
+
if (a === u && b === v) break;
|
|
5567
|
+
}
|
|
5568
|
+
if (members.length >= best.length) {
|
|
5569
|
+
members.sort((x, y) => x - y);
|
|
5570
|
+
let wins = members.length > best.length;
|
|
5571
|
+
if (!wins) wins = after(members, best);
|
|
5572
|
+
if (wins) best = members;
|
|
5573
|
+
}
|
|
5574
|
+
blocks++;
|
|
5575
|
+
}
|
|
5576
|
+
}
|
|
5577
|
+
}
|
|
5578
|
+
for (const v of best) body[v] = 1;
|
|
5579
|
+
}
|
|
5580
|
+
const hangCut = new Int32Array(n).fill(-1), hangDepth = new Int32Array(n);
|
|
5581
|
+
let head = 0, tail = 0;
|
|
5582
|
+
for (let i = 0; i < n; i++) if (body[i]) queue[tail++] = i;
|
|
5583
|
+
while (head < tail) {
|
|
5584
|
+
const v = queue[head++];
|
|
5585
|
+
for (let k = deg[v]; k < deg[v + 1]; k++) {
|
|
5586
|
+
const w = nb[k];
|
|
5587
|
+
if (body[w] || hangCut[w] !== -1) continue;
|
|
5588
|
+
hangCut[w] = body[v] ? v : hangCut[v];
|
|
5589
|
+
hangDepth[w] = hangDepth[v] + 1;
|
|
5590
|
+
queue[tail++] = w;
|
|
5591
|
+
}
|
|
5592
|
+
}
|
|
5593
|
+
const off = new Uint8Array(n);
|
|
5594
|
+
for (let i = 0; i < n; i++) if (piece[i] !== main) off[i] = 1;
|
|
5595
|
+
return { ids: sorted, body, hangCut, hangDepth, off };
|
|
5596
|
+
}
|
|
5597
|
+
|
|
5598
|
+
// src/layout3d/centres.ts
|
|
5599
|
+
var MAX_CENTRES = 12;
|
|
5600
|
+
var MIN_GROUP = 3;
|
|
5601
|
+
var WAYS_CAP = 2 ** 52;
|
|
5602
|
+
function rows(sorted, pairs) {
|
|
5603
|
+
const at = new Map(sorted.map((id, i) => [id, i]));
|
|
5604
|
+
const n = sorted.length;
|
|
5605
|
+
const ea = [], eb = [];
|
|
5606
|
+
for (const [x, y] of pairs) {
|
|
5607
|
+
const a = at.get(x), b = at.get(y);
|
|
5608
|
+
if (a === void 0 || b === void 0 || a === b) continue;
|
|
5609
|
+
ea.push(a);
|
|
5610
|
+
eb.push(b);
|
|
5611
|
+
}
|
|
5612
|
+
const m = ea.length;
|
|
5613
|
+
const start = new Int32Array(n + 1);
|
|
5614
|
+
for (let k = 0; k < m; k++) {
|
|
5615
|
+
start[ea[k] + 1]++;
|
|
5616
|
+
start[eb[k] + 1]++;
|
|
5617
|
+
}
|
|
5618
|
+
for (let i = 0; i < n; i++) start[i + 1] += start[i];
|
|
5619
|
+
const fill = start.slice(0, n);
|
|
5620
|
+
const raw = new Int32Array(2 * m);
|
|
5621
|
+
for (let k = 0; k < m; k++) {
|
|
5622
|
+
raw[fill[ea[k]]++] = eb[k];
|
|
5623
|
+
raw[fill[eb[k]]++] = ea[k];
|
|
5624
|
+
}
|
|
5625
|
+
const deg = new Int32Array(n + 1);
|
|
5626
|
+
const nb = new Int32Array(2 * m);
|
|
5627
|
+
let out = 0;
|
|
5628
|
+
for (let i = 0; i < n; i++) {
|
|
5629
|
+
const row = raw.subarray(start[i], start[i + 1]).slice().sort();
|
|
5630
|
+
deg[i] = out;
|
|
5631
|
+
for (let k = 0; k < row.length; k++) if (k === 0 || row[k] !== row[k - 1]) nb[out++] = row[k];
|
|
5632
|
+
}
|
|
5633
|
+
deg[n] = out;
|
|
5634
|
+
return { deg, nb };
|
|
5635
|
+
}
|
|
5636
|
+
function pick(n, g, members, inSet) {
|
|
5637
|
+
const { deg, nb } = g;
|
|
5638
|
+
const size = members.length;
|
|
5639
|
+
const count2 = new Int32Array(n);
|
|
5640
|
+
for (const v of members) {
|
|
5641
|
+
let c = 0;
|
|
5642
|
+
for (let k = deg[v]; k < deg[v + 1]; k++) if (inSet[nb[k]]) c++;
|
|
5643
|
+
count2[v] = c;
|
|
5644
|
+
}
|
|
5645
|
+
const ranked = Int32Array.from(members);
|
|
5646
|
+
ranked.sort((a, b) => count2[b] - count2[a] || a - b);
|
|
5647
|
+
let f = 0;
|
|
5648
|
+
while (f * f < size) f++;
|
|
5649
|
+
const floor = Math.max(3, f);
|
|
5650
|
+
const mark = new Int32Array(n);
|
|
5651
|
+
const hit = new Int32Array(MAX_CENTRES);
|
|
5652
|
+
let taken = [];
|
|
5653
|
+
for (const v of ranked) {
|
|
5654
|
+
if (count2[v] < floor || taken.length === MAX_CENTRES) break;
|
|
5655
|
+
hit.fill(0);
|
|
5656
|
+
for (let k = deg[v]; k < deg[v + 1]; k++) {
|
|
5657
|
+
const w = nb[k];
|
|
5658
|
+
if (!inSet[w]) continue;
|
|
5659
|
+
for (let r2 = 0; r2 < taken.length; r2++) hit[r2] += mark[w] >> r2 & 1;
|
|
5660
|
+
}
|
|
5661
|
+
let ok = true;
|
|
5662
|
+
for (let r2 = 0; r2 < taken.length; r2++) {
|
|
5663
|
+
if (2 * hit[r2] >= count2[v]) {
|
|
5664
|
+
ok = false;
|
|
5665
|
+
break;
|
|
5666
|
+
}
|
|
5667
|
+
}
|
|
5668
|
+
if (!ok) continue;
|
|
5669
|
+
const r = taken.length;
|
|
5670
|
+
taken.push(v);
|
|
5671
|
+
mark[v] |= 1 << r;
|
|
5672
|
+
for (let k = deg[v]; k < deg[v + 1]; k++) if (inSet[nb[k]]) mark[nb[k]] |= 1 << r;
|
|
5673
|
+
}
|
|
5674
|
+
if (taken.length === 0 && ranked.length) taken = [ranked[0]];
|
|
5675
|
+
for (; ; ) {
|
|
5676
|
+
const { group, dist } = reach(n, g, members, inSet, taken);
|
|
5677
|
+
const sizes = new Int32Array(taken.length);
|
|
5678
|
+
for (const v of members) if (taken.length && group[v] !== -1) sizes[group[v]]++;
|
|
5679
|
+
let last = -1;
|
|
5680
|
+
for (let r = 0; r < taken.length; r++) if (sizes[r] < MIN_GROUP) last = r;
|
|
5681
|
+
if (last === -1 || taken.length === 1) return { taken, group, dist };
|
|
5682
|
+
taken.splice(last, 1);
|
|
5683
|
+
}
|
|
5684
|
+
}
|
|
5685
|
+
function reach(n, g, members, inSet, taken) {
|
|
5686
|
+
const { deg, nb } = g;
|
|
5687
|
+
const K = taken.length;
|
|
5688
|
+
const dist = new Int32Array(n).fill(-1);
|
|
5689
|
+
const group = new Int32Array(n).fill(-1);
|
|
5690
|
+
const ways = new Float64Array(n * K);
|
|
5691
|
+
let front = new Int32Array(n), next = new Int32Array(n);
|
|
5692
|
+
let fl = 0;
|
|
5693
|
+
for (let r = 0; r < K; r++) {
|
|
5694
|
+
const c = taken[r];
|
|
5695
|
+
dist[c] = 0;
|
|
5696
|
+
ways[c * K + r] = 1;
|
|
5697
|
+
front[fl++] = c;
|
|
5698
|
+
}
|
|
5699
|
+
let d = 0;
|
|
5700
|
+
while (fl) {
|
|
5701
|
+
d++;
|
|
5702
|
+
let nl = 0;
|
|
5703
|
+
for (let i = 0; i < fl; i++) {
|
|
5704
|
+
const v = front[i];
|
|
5705
|
+
for (let k = deg[v]; k < deg[v + 1]; k++) {
|
|
5706
|
+
const w = nb[k];
|
|
5707
|
+
if (!inSet[w]) continue;
|
|
5708
|
+
if (dist[w] === -1) {
|
|
5709
|
+
dist[w] = d;
|
|
5710
|
+
next[nl++] = w;
|
|
5711
|
+
}
|
|
5712
|
+
if (dist[w] !== d) continue;
|
|
5713
|
+
for (let r = 0; r < K; r++) ways[w * K + r] = Math.min(WAYS_CAP, ways[w * K + r] + ways[v * K + r]);
|
|
5714
|
+
}
|
|
5715
|
+
}
|
|
5716
|
+
const t = front;
|
|
5717
|
+
front = next;
|
|
5718
|
+
next = t;
|
|
5719
|
+
fl = nl;
|
|
5720
|
+
}
|
|
5721
|
+
for (let r = 0; r < K; r++) group[taken[r]] = r;
|
|
5722
|
+
for (const v of members) {
|
|
5723
|
+
if (dist[v] === 0) continue;
|
|
5724
|
+
if (dist[v] === -1) continue;
|
|
5725
|
+
let best = 0;
|
|
5726
|
+
for (let r = 1; r < K; r++) if (ways[v * K + r] > ways[v * K + best]) best = r;
|
|
5727
|
+
group[v] = best;
|
|
5728
|
+
}
|
|
5729
|
+
return { group, dist };
|
|
5730
|
+
}
|
|
5731
|
+
function centres(ids, pairs, body) {
|
|
5732
|
+
const sorted = [...ids].sort(byCodePoint2);
|
|
5733
|
+
const n = sorted.length;
|
|
5734
|
+
const g = rows(sorted, pairs);
|
|
5735
|
+
const members = [];
|
|
5736
|
+
for (let i = 0; i < n; i++) if (body[i]) members.push(i);
|
|
5737
|
+
const first = pick(n, g, members, body);
|
|
5738
|
+
let taken = first.taken;
|
|
5739
|
+
const group = first.group, dist = first.dist;
|
|
5740
|
+
for (let round = 0; round < 2; round++) {
|
|
5741
|
+
const sizes = new Int32Array(taken.length);
|
|
5742
|
+
for (const v of members) sizes[group[v]]++;
|
|
5743
|
+
let big = 0;
|
|
5744
|
+
for (let r = 1; r < taken.length; r++) if (sizes[r] > sizes[big]) big = r;
|
|
5745
|
+
if (!taken.length || 2 * sizes[big] <= members.length) break;
|
|
5746
|
+
const inside = [], inSet = new Uint8Array(n);
|
|
5747
|
+
for (const v of members) if (group[v] === big && v !== taken[big]) {
|
|
5748
|
+
inside.push(v);
|
|
5749
|
+
inSet[v] = 1;
|
|
5750
|
+
}
|
|
5751
|
+
const sub = pick(n, g, inside, inSet);
|
|
5752
|
+
if (sub.taken.length < 2) break;
|
|
5753
|
+
const base = taken.length;
|
|
5754
|
+
taken = taken.concat(sub.taken);
|
|
5755
|
+
for (const v of inside) if (sub.dist[v] !== -1) {
|
|
5756
|
+
group[v] = base + sub.group[v];
|
|
5757
|
+
dist[v] = sub.dist[v];
|
|
5758
|
+
}
|
|
5759
|
+
}
|
|
5760
|
+
return { ids: sorted, taken: Int32Array.from(taken), group, dist };
|
|
5761
|
+
}
|
|
5762
|
+
|
|
5763
|
+
// src/layout3d/plate.ts
|
|
5764
|
+
var REST = 60;
|
|
5765
|
+
var SPREAD = 2;
|
|
5766
|
+
var TILE = 0.4;
|
|
5767
|
+
function truthy(v) {
|
|
5768
|
+
if (v === void 0 || v === null || v === false || v === 0 || v === "") return false;
|
|
5769
|
+
if (Array.isArray(v)) return v.length > 0;
|
|
5770
|
+
if (typeof v === "object") return Object.keys(v).length > 0;
|
|
5771
|
+
return true;
|
|
5772
|
+
}
|
|
5773
|
+
function isLayoutMap(row) {
|
|
5774
|
+
const v = row.x_layout;
|
|
5775
|
+
return v !== null && typeof v === "object" && !Array.isArray(v) && typeof v.method === "string" && v.method.length > 0;
|
|
5776
|
+
}
|
|
5777
|
+
var numeric = (v) => typeof v === "number" || typeof v === "boolean";
|
|
5778
|
+
function key(v, what) {
|
|
5779
|
+
if (v !== null && typeof v === "object") throw new Error(`plate: ${what} is a list or an object (${JSON.stringify(v)})`);
|
|
5780
|
+
return v;
|
|
5781
|
+
}
|
|
5782
|
+
function root(w, h, count2, what) {
|
|
5783
|
+
if (!numeric(w) || !numeric(h)) throw new Error(`plate: ${what}: a width or height that is no number (${JSON.stringify([w, h])})`);
|
|
5784
|
+
const a = w * h / count2;
|
|
5785
|
+
if (a < 0) throw new Error(`plate: ${what}: the square root of a negative area (${a})`);
|
|
5786
|
+
return Math.sqrt(a);
|
|
5787
|
+
}
|
|
5788
|
+
function plate(rows2, nodes, opts = {}) {
|
|
5789
|
+
const maps = /* @__PURE__ */ new Map();
|
|
5790
|
+
for (const e of rows2) {
|
|
5791
|
+
if (e.type !== "map") continue;
|
|
5792
|
+
if (isLayoutMap(e)) continue;
|
|
5793
|
+
maps.set(key(e.id, "a map id"), e);
|
|
5794
|
+
}
|
|
5795
|
+
const pins = [];
|
|
5796
|
+
for (const e of rows2) if (e.type === "pin") {
|
|
5797
|
+
if (typeof e.id !== "string") throw new Error(`plate: a pin's id is not a string (${JSON.stringify(e.id)})`);
|
|
5798
|
+
pins.push(e);
|
|
5799
|
+
}
|
|
5800
|
+
pins.sort((a, b) => byCodePoint2(a.id, b.id));
|
|
5801
|
+
const at = /* @__PURE__ */ new Map();
|
|
5802
|
+
for (const pin of pins) {
|
|
5803
|
+
const m2 = pin.map === void 0 ? null : pin.map;
|
|
5804
|
+
const el = pin.element_id === void 0 ? null : pin.element_id;
|
|
5805
|
+
if (maps.has(key(m2, "a pin's map")) && nodes.has(key(el, "a pin's element_id")) && numeric(pin.x) && numeric(pin.y)) {
|
|
5806
|
+
if (!at.has(m2)) at.set(m2, /* @__PURE__ */ new Map());
|
|
5807
|
+
const row = at.get(m2);
|
|
5808
|
+
if (!row.has(el)) row.set(el, [Number(pin.x), Number(pin.y)]);
|
|
5809
|
+
}
|
|
5810
|
+
}
|
|
5811
|
+
if (at.size === 0) return null;
|
|
5812
|
+
let m = null, best = -1;
|
|
5813
|
+
for (const [c, row] of at) {
|
|
5814
|
+
const better = row.size > best || row.size === best && byCodePoint2(c, m) > 0;
|
|
5815
|
+
if (better) {
|
|
5816
|
+
m = c;
|
|
5817
|
+
best = row.size;
|
|
5818
|
+
}
|
|
5819
|
+
}
|
|
5820
|
+
const map = maps.get(m);
|
|
5821
|
+
const W = map.width, H = map.height;
|
|
5822
|
+
const mine0 = at.get(m);
|
|
5823
|
+
const count2 = mine0.size;
|
|
5824
|
+
if (count2 < 3 || !truthy(W) || !truthy(H)) return null;
|
|
5825
|
+
const own4 = SPREAD * REST / root(W, H, count2, "the first map");
|
|
5826
|
+
const scale = opts.scale === void 0 ? own4 : opts.scale;
|
|
5827
|
+
const out = /* @__PURE__ */ new Map(), onFirst = /* @__PURE__ */ new Map();
|
|
5828
|
+
for (const [el, [x, y]] of mine0) {
|
|
5829
|
+
const mx = x - W / 2, my = y - H / 2;
|
|
5830
|
+
onFirst.set(el, [mx, my]);
|
|
5831
|
+
out.set(el, [mx * scale, my * scale, 0]);
|
|
5832
|
+
}
|
|
5833
|
+
const first = out.size;
|
|
5834
|
+
const todo = [...at.keys()].filter((c) => c !== m).sort(byCodePoint2);
|
|
5835
|
+
let small = 0, more = 0;
|
|
5836
|
+
let moved = true;
|
|
5837
|
+
while (moved) {
|
|
5838
|
+
moved = false;
|
|
5839
|
+
for (const c of todo.slice()) {
|
|
5840
|
+
const row = maps.get(c);
|
|
5841
|
+
const loc = row.location === void 0 ? null : row.location;
|
|
5842
|
+
const cw = row.width, ch = row.height;
|
|
5843
|
+
const mine = at.get(c);
|
|
5844
|
+
const fresh = [];
|
|
5845
|
+
for (const [el, xy] of mine) if (!out.has(el)) fresh.push([el, xy]);
|
|
5846
|
+
if (out.has(key(loc, "a map's location")) && truthy(cw) && truthy(ch) && mine.size >= 3 && fresh.length) {
|
|
5847
|
+
const sc = TILE * REST / root(cw, ch, mine.size, `the map ${c}`);
|
|
5848
|
+
const [lx, ly, lz] = out.get(loc);
|
|
5849
|
+
const rise = REST * (mine.size >= 20 ? 4 : 2);
|
|
5850
|
+
for (const [el, [x, y]] of fresh) out.set(el, [lx + (x - cw / 2) * sc, ly + (y - ch / 2) * sc, lz + rise]);
|
|
5851
|
+
todo.splice(todo.indexOf(c), 1);
|
|
5852
|
+
small += 1;
|
|
5853
|
+
more += fresh.length;
|
|
5854
|
+
moved = true;
|
|
5855
|
+
}
|
|
5856
|
+
}
|
|
5857
|
+
}
|
|
5858
|
+
return {
|
|
5859
|
+
at: out,
|
|
5860
|
+
first: onFirst,
|
|
5861
|
+
facts: {
|
|
5862
|
+
map: map.name === void 0 ? null : map.name,
|
|
5863
|
+
map_id: m,
|
|
5864
|
+
map_width: W,
|
|
5865
|
+
map_height: H,
|
|
5866
|
+
pinned: out.size,
|
|
5867
|
+
on_the_first_map: first,
|
|
5868
|
+
maps_as_small_plates: small,
|
|
5869
|
+
elements_on_them: more,
|
|
5870
|
+
maps_left_out: todo.length,
|
|
5871
|
+
scale,
|
|
5872
|
+
maps_in_the_world: maps.size
|
|
5873
|
+
}
|
|
5874
|
+
};
|
|
5875
|
+
}
|
|
5876
|
+
|
|
5877
|
+
// src/layout3d/spread.ts
|
|
5878
|
+
var key2 = (p) => p.join(",");
|
|
5879
|
+
function groupsOf(feed) {
|
|
5880
|
+
const groups = /* @__PURE__ */ new Map();
|
|
5881
|
+
feed.anchor.forEach((p, i) => {
|
|
5882
|
+
if (feed.fixed && feed.fixed[i]) return;
|
|
5883
|
+
const k = key2(p);
|
|
5884
|
+
if (!groups.has(k)) groups.set(k, []);
|
|
5885
|
+
groups.get(k).push(i);
|
|
5886
|
+
});
|
|
5887
|
+
return groups;
|
|
5888
|
+
}
|
|
5889
|
+
function cubeRoot(v) {
|
|
5890
|
+
if (!(v > 0)) return 0;
|
|
5891
|
+
let x = Math.sqrt(v);
|
|
5892
|
+
if (x < 1) x = 1;
|
|
5893
|
+
for (let k = 0; k < 40; k++) x = (2 * x + v / (x * x)) / 3;
|
|
5894
|
+
return x;
|
|
5895
|
+
}
|
|
5896
|
+
function plainStart(feed, num) {
|
|
5897
|
+
if (!num) throw new Error("plainStart: needs each element's own number");
|
|
5898
|
+
const REST5 = feed.rest;
|
|
5899
|
+
const groups = groupsOf(feed);
|
|
5900
|
+
return feed.pos.map((p, i) => {
|
|
5901
|
+
if (feed.fixed && feed.fixed[i]) return p;
|
|
5902
|
+
const lobe = REST5 * 1.1 * cubeRoot(groups.get(key2(feed.anchor[i])).length);
|
|
5903
|
+
let g = num[i] >>> 0;
|
|
5904
|
+
const draw = () => (g = (g * 1664525 + 1013904223) % 4294967296) / 4294967296;
|
|
5905
|
+
draw();
|
|
5906
|
+
draw();
|
|
5907
|
+
let x = 0, y = 0, z = 0;
|
|
5908
|
+
for (let tries = 0; tries < 64; tries++) {
|
|
5909
|
+
const a = 2 * draw() - 1, b = 2 * draw() - 1, c = 2 * draw() - 1;
|
|
5910
|
+
if (a * a + b * b + c * c <= 1) {
|
|
5911
|
+
x = a;
|
|
5912
|
+
y = b;
|
|
5913
|
+
z = c;
|
|
5914
|
+
break;
|
|
5915
|
+
}
|
|
5916
|
+
}
|
|
5917
|
+
return [feed.anchor[i][0] + x * lobe, feed.anchor[i][1] + y * lobe, feed.anchor[i][2] + z * lobe];
|
|
5918
|
+
});
|
|
5919
|
+
}
|
|
5920
|
+
|
|
5921
|
+
// src/layout3d/points.ts
|
|
5922
|
+
var REST2 = 60;
|
|
5923
|
+
var LOBE = 1.1;
|
|
5924
|
+
var GAP = 1.25;
|
|
5925
|
+
var CLEAR = 1.8;
|
|
5926
|
+
var PACK_STEPS = 600;
|
|
5927
|
+
var OPPOSING = ["rivals", "adversaries", "rival", "antagonist"];
|
|
5928
|
+
function count(n, K, part, at, pairs, edges) {
|
|
5929
|
+
const size = new Int32Array(K), link = new Int32Array(K * K), opp = new Int32Array(K * K);
|
|
5930
|
+
for (let v = 0; v < n; v++) if (part[v] !== -1) size[part[v]]++;
|
|
5931
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5932
|
+
for (const [x, y] of pairs) {
|
|
5933
|
+
let a = at.get(x), b = at.get(y);
|
|
5934
|
+
if (a === void 0 || b === void 0 || a === b) continue;
|
|
5935
|
+
if (a > b) {
|
|
5936
|
+
const t = a;
|
|
5937
|
+
a = b;
|
|
5938
|
+
b = t;
|
|
5939
|
+
}
|
|
5940
|
+
const key3 = a * n + b;
|
|
5941
|
+
if (seen.has(key3)) continue;
|
|
5942
|
+
seen.add(key3);
|
|
5943
|
+
const p = part[a], q = part[b];
|
|
5944
|
+
if (p === -1 || q === -1 || p === q) continue;
|
|
5945
|
+
if (p < q) link[p * K + q]++;
|
|
5946
|
+
else link[q * K + p]++;
|
|
5947
|
+
}
|
|
5948
|
+
for (const [s, t, field] of edges) {
|
|
5949
|
+
if (!OPPOSING.includes(field)) continue;
|
|
5950
|
+
const a = at.get(s), b = at.get(t);
|
|
5951
|
+
if (a === void 0 || b === void 0) continue;
|
|
5952
|
+
const p = part[a], q = part[b];
|
|
5953
|
+
if (p === -1 || q === -1 || p === q) continue;
|
|
5954
|
+
if (p < q) opp[p * K + q]++;
|
|
5955
|
+
else opp[q * K + p]++;
|
|
5956
|
+
}
|
|
5957
|
+
return { size, link, opp };
|
|
5958
|
+
}
|
|
5959
|
+
function bySize(K, size) {
|
|
5960
|
+
const order = new Int32Array(K);
|
|
5961
|
+
for (let i = 0; i < K; i++) order[i] = i;
|
|
5962
|
+
order.sort((a, b) => size[b] - size[a] || a - b);
|
|
5963
|
+
return order;
|
|
5964
|
+
}
|
|
5965
|
+
function slots(K, size, link, opp, table) {
|
|
5966
|
+
const slot = new Int32Array(K), dirs = new Float64Array(3 * K);
|
|
5967
|
+
if (K === 1) return { slot, ends: null, dirs };
|
|
5968
|
+
const D = table[String(K)];
|
|
5969
|
+
if (!D || D.length !== K) throw new Error(`points: the table has no row of ${K} directions`);
|
|
5970
|
+
let anyOpp = false;
|
|
5971
|
+
for (let i = 0; i < K; i++) for (let j = i + 1; j < K; j++) if (opp[i * K + j] > 0) anyOpp = true;
|
|
5972
|
+
let b0 = -1, b1 = -1;
|
|
5973
|
+
if (anyOpp) {
|
|
5974
|
+
let bo = -1, bs = -1;
|
|
5975
|
+
for (let i = 0; i < K; i++) {
|
|
5976
|
+
for (let j = i + 1; j < K; j++) {
|
|
5977
|
+
const o = opp[i * K + j], s = size[i] + size[j];
|
|
5978
|
+
if (o > bo || o === bo && s > bs) {
|
|
5979
|
+
bo = o;
|
|
5980
|
+
bs = s;
|
|
5981
|
+
b0 = i;
|
|
5982
|
+
b1 = j;
|
|
5983
|
+
}
|
|
5984
|
+
}
|
|
5985
|
+
}
|
|
5986
|
+
} else {
|
|
5987
|
+
const order2 = bySize(K, size);
|
|
5988
|
+
const m = Math.min(K, 4);
|
|
5989
|
+
const big = Array.from(order2.subarray(0, m)).sort((a, b) => a - b);
|
|
5990
|
+
for (let x = 0; x < m; x++) {
|
|
5991
|
+
for (let y = x + 1; y < m; y++) {
|
|
5992
|
+
const i = big[x], j = big[y];
|
|
5993
|
+
if (b0 === -1) {
|
|
5994
|
+
b0 = i;
|
|
5995
|
+
b1 = j;
|
|
5996
|
+
continue;
|
|
5997
|
+
}
|
|
5998
|
+
const lp = link[i * K + j], lq = link[b0 * K + b1];
|
|
5999
|
+
const left = lp * size[b0] * size[b1], right = lq * size[i] * size[j];
|
|
6000
|
+
if (left < right) {
|
|
6001
|
+
b0 = i;
|
|
6002
|
+
b1 = j;
|
|
6003
|
+
}
|
|
6004
|
+
}
|
|
6005
|
+
}
|
|
6006
|
+
}
|
|
6007
|
+
const place = new Int32Array(K).fill(-1), used = new Uint8Array(K);
|
|
6008
|
+
const placed = new Int32Array(K);
|
|
6009
|
+
let np = 0;
|
|
6010
|
+
place[b0] = 0;
|
|
6011
|
+
used[0] = 1;
|
|
6012
|
+
placed[np++] = b0;
|
|
6013
|
+
place[b1] = K - 1;
|
|
6014
|
+
used[K - 1] = 1;
|
|
6015
|
+
placed[np++] = b1;
|
|
6016
|
+
const order = bySize(K, size);
|
|
6017
|
+
for (let oi = 0; oi < K; oi++) {
|
|
6018
|
+
const g = order[oi];
|
|
6019
|
+
if (place[g] !== -1) continue;
|
|
6020
|
+
let bestS = -1, bestC = 0;
|
|
6021
|
+
for (let s = 0; s < K; s++) {
|
|
6022
|
+
if (used[s]) continue;
|
|
6023
|
+
let c = 0;
|
|
6024
|
+
for (let pi = 0; pi < np; pi++) {
|
|
6025
|
+
const h = placed[pi], t = place[h];
|
|
6026
|
+
const lo = g < h ? g : h, hi = g < h ? h : g;
|
|
6027
|
+
const w = link[lo * K + hi] - 4 * opp[lo * K + hi];
|
|
6028
|
+
const dx = D[s][0] - D[t][0], dy = D[s][1] - D[t][1], dz = D[s][2] - D[t][2];
|
|
6029
|
+
c += w * Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
6030
|
+
}
|
|
6031
|
+
if (bestS === -1 || c < bestC) {
|
|
6032
|
+
bestS = s;
|
|
6033
|
+
bestC = c;
|
|
6034
|
+
}
|
|
6035
|
+
}
|
|
6036
|
+
place[g] = bestS;
|
|
6037
|
+
used[bestS] = 1;
|
|
6038
|
+
placed[np++] = g;
|
|
6039
|
+
}
|
|
6040
|
+
for (let g = 0; g < K; g++) {
|
|
6041
|
+
slot[g] = place[g];
|
|
6042
|
+
dirs[3 * g] = D[place[g]][0];
|
|
6043
|
+
dirs[3 * g + 1] = D[place[g]][1];
|
|
6044
|
+
dirs[3 * g + 2] = D[place[g]][2];
|
|
6045
|
+
}
|
|
6046
|
+
return { slot, ends: [b0, b1], dirs };
|
|
6047
|
+
}
|
|
6048
|
+
function pack(K, radius, link, opp, dirs, gap, fx = null) {
|
|
6049
|
+
let nf = 0;
|
|
6050
|
+
if (fx) {
|
|
6051
|
+
for (let i = 0; i < K; i++) if (fx.flag[i]) nf++;
|
|
6052
|
+
}
|
|
6053
|
+
if (nf > 0) return packFixed(K, radius, link, opp, dirs, gap, fx, nf);
|
|
6054
|
+
const P = new Float64Array(3 * K);
|
|
6055
|
+
if (K === 1) return P;
|
|
6056
|
+
let sum = 0;
|
|
6057
|
+
for (let i = 0; i < K; i++) sum += radius[i];
|
|
6058
|
+
for (let c = 0; c < 3 * K; c++) P[c] = dirs[c] * sum;
|
|
6059
|
+
let total = 0;
|
|
6060
|
+
for (let i = 0; i < K; i++) for (let j = i + 1; j < K; j++) total += link[i * K + j];
|
|
6061
|
+
if (total === 0) total = 1;
|
|
6062
|
+
const D = new Float64Array(3 * K);
|
|
6063
|
+
for (let step = 0; step < PACK_STEPS; step++) {
|
|
6064
|
+
D.fill(0);
|
|
6065
|
+
for (let i = 0; i < K; i++) {
|
|
6066
|
+
for (let j = i + 1; j < K; j++) {
|
|
6067
|
+
const dx = P[3 * i] - P[3 * j], dy = P[3 * i + 1] - P[3 * j + 1], dz = P[3 * i + 2] - P[3 * j + 2];
|
|
6068
|
+
const dist = Math.max(Math.sqrt(dx * dx + dy * dy + dz * dz), 1e-6);
|
|
6069
|
+
const need = gap * (radius[i] + radius[j]);
|
|
6070
|
+
let f = dist - need;
|
|
6071
|
+
if (f > 0) f *= (0.02 + 0.5 * link[i * K + j] / total) * (opp[i * K + j] ? 0.25 : 1);
|
|
6072
|
+
const ux = dx / dist * f * 0.5, uy = dy / dist * f * 0.5, uz = dz / dist * f * 0.5;
|
|
6073
|
+
D[3 * i] -= ux;
|
|
6074
|
+
D[3 * i + 1] -= uy;
|
|
6075
|
+
D[3 * i + 2] -= uz;
|
|
6076
|
+
D[3 * j] += ux;
|
|
6077
|
+
D[3 * j + 1] += uy;
|
|
6078
|
+
D[3 * j + 2] += uz;
|
|
6079
|
+
}
|
|
6080
|
+
}
|
|
6081
|
+
for (let c = 0; c < 3 * K; c++) P[c] = P[c] + D[c] * 0.5;
|
|
6082
|
+
}
|
|
6083
|
+
let mx = 0, my = 0, mz = 0;
|
|
6084
|
+
for (let i = 0; i < K; i++) {
|
|
6085
|
+
mx += P[3 * i];
|
|
6086
|
+
my += P[3 * i + 1];
|
|
6087
|
+
mz += P[3 * i + 2];
|
|
6088
|
+
}
|
|
6089
|
+
mx /= K;
|
|
6090
|
+
my /= K;
|
|
6091
|
+
mz /= K;
|
|
6092
|
+
for (let i = 0; i < K; i++) {
|
|
6093
|
+
P[3 * i] -= mx;
|
|
6094
|
+
P[3 * i + 1] -= my;
|
|
6095
|
+
P[3 * i + 2] -= mz;
|
|
6096
|
+
}
|
|
6097
|
+
return P;
|
|
6098
|
+
}
|
|
6099
|
+
function packFixed(K, radius, link, opp, dirs, gap, fx, nf) {
|
|
6100
|
+
const P = new Float64Array(3 * K);
|
|
6101
|
+
let ox = 0, oy = 0, oz = 0;
|
|
6102
|
+
for (let i = 0; i < K; i++) {
|
|
6103
|
+
if (!fx.flag[i]) continue;
|
|
6104
|
+
P[3 * i] = fx.at[3 * i];
|
|
6105
|
+
P[3 * i + 1] = fx.at[3 * i + 1];
|
|
6106
|
+
P[3 * i + 2] = fx.at[3 * i + 2];
|
|
6107
|
+
ox += fx.at[3 * i];
|
|
6108
|
+
oy += fx.at[3 * i + 1];
|
|
6109
|
+
oz += fx.at[3 * i + 2];
|
|
6110
|
+
}
|
|
6111
|
+
if (nf === K) return P;
|
|
6112
|
+
ox /= nf;
|
|
6113
|
+
oy /= nf;
|
|
6114
|
+
oz /= nf;
|
|
6115
|
+
let sum = 0;
|
|
6116
|
+
for (let i = 0; i < K; i++) sum += radius[i];
|
|
6117
|
+
for (let i = 0; i < K; i++) {
|
|
6118
|
+
if (fx.flag[i]) continue;
|
|
6119
|
+
P[3 * i] = ox + dirs[3 * i] * sum;
|
|
6120
|
+
P[3 * i + 1] = oy + dirs[3 * i + 1] * sum;
|
|
6121
|
+
P[3 * i + 2] = oz + dirs[3 * i + 2] * sum;
|
|
6122
|
+
}
|
|
6123
|
+
let total = 0;
|
|
6124
|
+
for (let i = 0; i < K; i++) for (let j = i + 1; j < K; j++) total += link[i * K + j];
|
|
6125
|
+
if (total === 0) total = 1;
|
|
6126
|
+
const D = new Float64Array(3 * K);
|
|
6127
|
+
for (let step = 0; step < PACK_STEPS; step++) {
|
|
6128
|
+
D.fill(0);
|
|
6129
|
+
for (let i = 0; i < K; i++) {
|
|
6130
|
+
for (let j = i + 1; j < K; j++) {
|
|
6131
|
+
const dx = P[3 * i] - P[3 * j], dy = P[3 * i + 1] - P[3 * j + 1], dz = P[3 * i + 2] - P[3 * j + 2];
|
|
6132
|
+
const dist = Math.max(Math.sqrt(dx * dx + dy * dy + dz * dz), 1e-6);
|
|
6133
|
+
const need = gap * (radius[i] + radius[j]);
|
|
6134
|
+
let f = dist - need;
|
|
6135
|
+
if (f > 0) f *= (0.02 + 0.5 * link[i * K + j] / total) * (opp[i * K + j] ? 0.25 : 1);
|
|
6136
|
+
const ux = dx / dist * f * 0.5, uy = dy / dist * f * 0.5, uz = dz / dist * f * 0.5;
|
|
6137
|
+
D[3 * i] -= ux;
|
|
6138
|
+
D[3 * i + 1] -= uy;
|
|
6139
|
+
D[3 * i + 2] -= uz;
|
|
6140
|
+
D[3 * j] += ux;
|
|
6141
|
+
D[3 * j + 1] += uy;
|
|
6142
|
+
D[3 * j + 2] += uz;
|
|
6143
|
+
}
|
|
6144
|
+
}
|
|
6145
|
+
for (let i = 0; i < K; i++) {
|
|
6146
|
+
if (fx.flag[i]) continue;
|
|
6147
|
+
for (let c = 3 * i; c < 3 * i + 3; c++) P[c] = P[c] + D[c] * 0.5;
|
|
6148
|
+
}
|
|
6149
|
+
}
|
|
6150
|
+
return P;
|
|
6151
|
+
}
|
|
6152
|
+
function fixedParts(K, flag2, at) {
|
|
6153
|
+
for (let i = 0; i < K; i++) if (flag2[i]) return { flag: flag2, at };
|
|
6154
|
+
return null;
|
|
6155
|
+
}
|
|
6156
|
+
function points(ids, body, taken, group, pairs, edges, plate2, table, opts = {}) {
|
|
6157
|
+
const dirTable = table;
|
|
6158
|
+
const root2 = cubeRoot;
|
|
6159
|
+
const gap = GAP;
|
|
6160
|
+
const n = ids.length, k = taken.length;
|
|
6161
|
+
const at = new Map(ids.map((id, i) => [id, i]));
|
|
6162
|
+
const part = new Int32Array(n).fill(-1);
|
|
6163
|
+
for (let v = 0; v < n; v++) if (body[v]) part[v] = group[v];
|
|
6164
|
+
const { size, link, opp } = count(n, k, part, at, pairs, edges);
|
|
6165
|
+
const g1 = slots(k, size, link, opp, dirTable);
|
|
6166
|
+
const lobe = new Float64Array(k);
|
|
6167
|
+
for (let g = 0; g < k; g++) lobe[g] = REST2 * LOBE * root2(size[g]);
|
|
6168
|
+
const out = { k, size, link, opp, slot: g1.slot, ends: g1.ends, dirs: g1.dirs, lobe, cpt: new Float64Array(0), plate: null };
|
|
6169
|
+
const fixed = opts.fixed || null;
|
|
6170
|
+
const entries = plate2 ? plate2 instanceof Map ? [...plate2.entries()] : Object.entries(plate2) : [];
|
|
6171
|
+
if (!entries.length) {
|
|
6172
|
+
let fx2 = null;
|
|
6173
|
+
if (fixed) {
|
|
6174
|
+
const flag2 = new Uint8Array(k), fat = new Float64Array(3 * k);
|
|
6175
|
+
for (let g = 0; g < k; g++) if (fixed.group[g]) {
|
|
6176
|
+
flag2[g] = 1;
|
|
6177
|
+
fat[3 * g] = fixed.at[3 * g];
|
|
6178
|
+
fat[3 * g + 1] = fixed.at[3 * g + 1];
|
|
6179
|
+
fat[3 * g + 2] = fixed.at[3 * g + 2];
|
|
6180
|
+
}
|
|
6181
|
+
fx2 = fixedParts(k, flag2, fat);
|
|
6182
|
+
}
|
|
6183
|
+
out.cpt = pack(k, lobe, link, opp, g1.dirs, gap, fx2);
|
|
6184
|
+
return out;
|
|
6185
|
+
}
|
|
6186
|
+
const pinned = new Uint8Array(n), q = new Float64Array(3 * n);
|
|
6187
|
+
let outside = 0, half = 0;
|
|
6188
|
+
for (const [id, xy] of entries) {
|
|
6189
|
+
const v = at.get(id);
|
|
6190
|
+
if (v === void 0) throw new Error(`points: the plate names ${id}, which is not among the ids`);
|
|
6191
|
+
pinned[v] = 1;
|
|
6192
|
+
q[3 * v] = xy[0];
|
|
6193
|
+
q[3 * v + 1] = xy[1];
|
|
6194
|
+
q[3 * v + 2] = xy.length > 2 ? xy[2] : 0;
|
|
6195
|
+
if (!body[v]) outside++;
|
|
6196
|
+
half = Math.max(half, Math.sqrt(xy[0] * xy[0] + xy[1] * xy[1]));
|
|
6197
|
+
}
|
|
6198
|
+
const over = new Uint8Array(k), unit = new Int32Array(k).fill(-1);
|
|
6199
|
+
let pu = 0;
|
|
6200
|
+
for (let g = 0; g < k; g++) {
|
|
6201
|
+
if (pinned[taken[g]]) over[g] = 1;
|
|
6202
|
+
else unit[g] = pu++;
|
|
6203
|
+
}
|
|
6204
|
+
const K = pu + 1;
|
|
6205
|
+
const upart = new Int32Array(n).fill(-1);
|
|
6206
|
+
for (let v = 0; v < n; v++) if (body[v]) upart[v] = pinned[v] || over[group[v]] ? pu : unit[group[v]];
|
|
6207
|
+
const u = count(n, K, upart, at, pairs, edges);
|
|
6208
|
+
u.size[pu] += outside;
|
|
6209
|
+
const g2 = slots(K, u.size, u.link, u.opp, dirTable);
|
|
6210
|
+
const radius = new Float64Array(K);
|
|
6211
|
+
for (let p = 0; p < pu; p++) radius[p] = REST2 * LOBE * root2(u.size[p]);
|
|
6212
|
+
radius[pu] = half * CLEAR;
|
|
6213
|
+
let fx = null;
|
|
6214
|
+
if (fixed) {
|
|
6215
|
+
const flag2 = new Uint8Array(K), fat = new Float64Array(3 * K);
|
|
6216
|
+
for (let g = 0; g < k; g++) if (!over[g] && fixed.group[g]) {
|
|
6217
|
+
const p = unit[g];
|
|
6218
|
+
flag2[p] = 1;
|
|
6219
|
+
fat[3 * p] = fixed.at[3 * g];
|
|
6220
|
+
fat[3 * p + 1] = fixed.at[3 * g + 1];
|
|
6221
|
+
fat[3 * p + 2] = fixed.at[3 * g + 2];
|
|
6222
|
+
}
|
|
6223
|
+
if (fixed.plate) {
|
|
6224
|
+
flag2[pu] = 1;
|
|
6225
|
+
fat[3 * pu] = fixed.plate[0];
|
|
6226
|
+
fat[3 * pu + 1] = fixed.plate[1];
|
|
6227
|
+
fat[3 * pu + 2] = fixed.plate[2];
|
|
6228
|
+
}
|
|
6229
|
+
fx = fixedParts(K, flag2, fat);
|
|
6230
|
+
}
|
|
6231
|
+
const upt = pack(K, radius, u.link, u.opp, g2.dirs, gap, fx);
|
|
6232
|
+
const point2 = Float64Array.of(upt[3 * pu], upt[3 * pu + 1], upt[3 * pu + 2]);
|
|
6233
|
+
const plateAt = new Float64Array(3 * n);
|
|
6234
|
+
for (let v = 0; v < n; v++) {
|
|
6235
|
+
if (!pinned[v]) continue;
|
|
6236
|
+
for (let c = 0; c < 3; c++) plateAt[3 * v + c] = point2[c] + q[3 * v + c];
|
|
6237
|
+
}
|
|
6238
|
+
const snap = opts.snap || null;
|
|
6239
|
+
if (snap) {
|
|
6240
|
+
for (let v = 0; v < n; v++) {
|
|
6241
|
+
if (!pinned[v] || !snap.flag[v]) continue;
|
|
6242
|
+
let close = true;
|
|
6243
|
+
for (let c = 0; c < 3; c++) {
|
|
6244
|
+
const d = plateAt[3 * v + c] - snap.at[3 * v + c];
|
|
6245
|
+
if (!(d <= snap.near && -d <= snap.near)) close = false;
|
|
6246
|
+
}
|
|
6247
|
+
if (close) for (let c = 0; c < 3; c++) plateAt[3 * v + c] = snap.at[3 * v + c];
|
|
6248
|
+
}
|
|
6249
|
+
}
|
|
6250
|
+
const cpt = new Float64Array(3 * k);
|
|
6251
|
+
for (let g = 0; g < k; g++) {
|
|
6252
|
+
if (over[g]) {
|
|
6253
|
+
const c = taken[g];
|
|
6254
|
+
cpt[3 * g] = plateAt[3 * c] + 0;
|
|
6255
|
+
cpt[3 * g + 1] = plateAt[3 * c + 1] + 0;
|
|
6256
|
+
cpt[3 * g + 2] = plateAt[3 * c + 2] + (lobe[g] + REST2 * 6);
|
|
6257
|
+
} else {
|
|
6258
|
+
const p = unit[g];
|
|
6259
|
+
cpt[3 * g] = upt[3 * p];
|
|
6260
|
+
cpt[3 * g + 1] = upt[3 * p + 1];
|
|
6261
|
+
cpt[3 * g + 2] = upt[3 * p + 2];
|
|
6262
|
+
}
|
|
6263
|
+
}
|
|
6264
|
+
out.cpt = cpt;
|
|
6265
|
+
out.plate = {
|
|
6266
|
+
parts: K,
|
|
6267
|
+
over,
|
|
6268
|
+
unit,
|
|
6269
|
+
size: u.size,
|
|
6270
|
+
link: u.link,
|
|
6271
|
+
opp: u.opp,
|
|
6272
|
+
slot: g2.slot,
|
|
6273
|
+
ends: g2.ends,
|
|
6274
|
+
dirs: g2.dirs,
|
|
6275
|
+
radius,
|
|
6276
|
+
half,
|
|
6277
|
+
point: point2,
|
|
6278
|
+
pinned,
|
|
6279
|
+
at: plateAt
|
|
6280
|
+
};
|
|
6281
|
+
return out;
|
|
6282
|
+
}
|
|
6283
|
+
|
|
6284
|
+
// src/layout3d/relax.ts
|
|
6285
|
+
function relax(feed, opts = {}) {
|
|
6286
|
+
const R = feed.rest;
|
|
6287
|
+
const STEPS3 = opts.steps ?? feed.steps;
|
|
6288
|
+
const CUT = (opts.cutoff ?? 3) * R;
|
|
6289
|
+
const CAP02 = opts.cap0 ?? 3;
|
|
6290
|
+
const n = feed.pos.length;
|
|
6291
|
+
const m = feed.pairs.length;
|
|
6292
|
+
const px = new Float64Array(n), py = new Float64Array(n), pz = new Float64Array(n);
|
|
6293
|
+
const ax = new Float64Array(n), ay = new Float64Array(n), az = new Float64Array(n);
|
|
6294
|
+
for (let i = 0; i < n; i++) {
|
|
6295
|
+
px[i] = feed.pos[i][0];
|
|
6296
|
+
py[i] = feed.pos[i][1];
|
|
6297
|
+
pz[i] = feed.pos[i][2];
|
|
6298
|
+
ax[i] = feed.anchor[i][0];
|
|
6299
|
+
ay[i] = feed.anchor[i][1];
|
|
6300
|
+
az[i] = feed.anchor[i][2];
|
|
6301
|
+
}
|
|
6302
|
+
const perAxis = Array.isArray(feed.pull[0]);
|
|
6303
|
+
const pullX = new Float64Array(n), pullY = new Float64Array(n), pullZ = new Float64Array(n);
|
|
6304
|
+
for (let i = 0; i < n; i++) {
|
|
6305
|
+
if (perAxis) {
|
|
6306
|
+
const q = feed.pull[i];
|
|
6307
|
+
pullX[i] = q[0];
|
|
6308
|
+
pullY[i] = q[1];
|
|
6309
|
+
pullZ[i] = q[2];
|
|
6310
|
+
} else pullX[i] = pullY[i] = pullZ[i] = feed.pull[i];
|
|
6311
|
+
}
|
|
6312
|
+
const fixed = new Uint8Array(n);
|
|
6313
|
+
if (feed.fixed) for (let i = 0; i < n; i++) fixed[i] = feed.fixed[i] ? 1 : 0;
|
|
6314
|
+
const ea = new Int32Array(m), eb = new Int32Array(m);
|
|
6315
|
+
const ew = new Float64Array(m);
|
|
6316
|
+
const scale = new Float64Array(n);
|
|
6317
|
+
for (let k = 0; k < m; k++) {
|
|
6318
|
+
ea[k] = feed.pairs[k][0];
|
|
6319
|
+
eb[k] = feed.pairs[k][1];
|
|
6320
|
+
ew[k] = feed.weight[k];
|
|
6321
|
+
scale[ea[k]] += ew[k];
|
|
6322
|
+
scale[eb[k]] += ew[k];
|
|
6323
|
+
}
|
|
6324
|
+
for (let i = 0; i < n; i++) scale[i] = 1 / Math.max(1, scale[i] / 4);
|
|
6325
|
+
const dx = new Float64Array(n), dy = new Float64Array(n), dz = new Float64Array(n);
|
|
6326
|
+
const lx = new Float64Array(n), ly = new Float64Array(n), lz = new Float64Array(n);
|
|
6327
|
+
const cellOf = new Int32Array(n);
|
|
6328
|
+
const order = new Int32Array(n);
|
|
6329
|
+
const cut2 = CUT * CUT;
|
|
6330
|
+
for (let step = 0; step < STEPS3; step++) {
|
|
6331
|
+
let x0 = Infinity, y0 = Infinity, z0 = Infinity, x1 = -Infinity, y1 = -Infinity, z1 = -Infinity;
|
|
6332
|
+
for (let i = 0; i < n; i++) {
|
|
6333
|
+
if (px[i] < x0) x0 = px[i];
|
|
6334
|
+
if (px[i] > x1) x1 = px[i];
|
|
6335
|
+
if (py[i] < y0) y0 = py[i];
|
|
6336
|
+
if (py[i] > y1) y1 = py[i];
|
|
6337
|
+
if (pz[i] < z0) z0 = pz[i];
|
|
6338
|
+
if (pz[i] > z1) z1 = pz[i];
|
|
6339
|
+
}
|
|
6340
|
+
const nx = Math.floor((x1 - x0) / CUT) + 1, ny = Math.floor((y1 - y0) / CUT) + 1, nz = Math.floor((z1 - z0) / CUT) + 1;
|
|
6341
|
+
const cells = nx * ny * nz;
|
|
6342
|
+
const startOf2 = new Int32Array(cells + 1);
|
|
6343
|
+
for (let i = 0; i < n; i++) {
|
|
6344
|
+
const c = (Math.floor((px[i] - x0) / CUT) * ny + Math.floor((py[i] - y0) / CUT)) * nz + Math.floor((pz[i] - z0) / CUT);
|
|
6345
|
+
cellOf[i] = c;
|
|
6346
|
+
startOf2[c + 1]++;
|
|
6347
|
+
}
|
|
6348
|
+
for (let c = 0; c < cells; c++) startOf2[c + 1] += startOf2[c];
|
|
6349
|
+
const fill = startOf2.slice(0, cells);
|
|
6350
|
+
for (let i = 0; i < n; i++) order[fill[cellOf[i]]++] = i;
|
|
6351
|
+
dx.fill(0);
|
|
6352
|
+
dy.fill(0);
|
|
6353
|
+
dz.fill(0);
|
|
6354
|
+
for (let cx = 0; cx < nx; cx++) for (let cy = 0; cy < ny; cy++) for (let cz = 0; cz < nz; cz++) {
|
|
6355
|
+
const c = (cx * ny + cy) * nz + cz;
|
|
6356
|
+
const s0 = startOf2[c], s1 = startOf2[c + 1];
|
|
6357
|
+
if (s0 === s1) continue;
|
|
6358
|
+
for (let ox = 0; ox <= 1; ox++) for (let oy = ox ? -1 : 0; oy <= 1; oy++) for (let oz = ox || oy ? -1 : 0; oz <= 1; oz++) {
|
|
6359
|
+
const qx = cx + ox, qy = cy + oy, qz = cz + oz;
|
|
6360
|
+
if (qx >= nx || qy < 0 || qy >= ny || qz < 0 || qz >= nz) continue;
|
|
6361
|
+
const q = (qx * ny + qy) * nz + qz;
|
|
6362
|
+
const same = q === c;
|
|
6363
|
+
const t0 = startOf2[q], t1 = startOf2[q + 1];
|
|
6364
|
+
if (t0 === t1) continue;
|
|
6365
|
+
for (let u = s0; u < s1; u++) {
|
|
6366
|
+
const i = order[u];
|
|
6367
|
+
const xi = px[i], yi = py[i], zi = pz[i];
|
|
6368
|
+
for (let v = same ? u + 1 : t0; v < t1; v++) {
|
|
6369
|
+
const j = order[v];
|
|
6370
|
+
const ux = xi - px[j], uy = yi - py[j], uz = zi - pz[j];
|
|
6371
|
+
const d2 = ux * ux + uy * uy + uz * uz;
|
|
6372
|
+
if (d2 > cut2) continue;
|
|
6373
|
+
const d = Math.max(Math.sqrt(d2), 1e-6);
|
|
6374
|
+
const f = (R * R / d - R / 3) / d;
|
|
6375
|
+
dx[i] += ux * f;
|
|
6376
|
+
dy[i] += uy * f;
|
|
6377
|
+
dz[i] += uz * f;
|
|
6378
|
+
dx[j] -= ux * f;
|
|
6379
|
+
dy[j] -= uy * f;
|
|
6380
|
+
dz[j] -= uz * f;
|
|
6381
|
+
}
|
|
6382
|
+
}
|
|
6383
|
+
}
|
|
6384
|
+
}
|
|
6385
|
+
lx.fill(0);
|
|
6386
|
+
ly.fill(0);
|
|
6387
|
+
lz.fill(0);
|
|
6388
|
+
for (let k = 0; k < m; k++) {
|
|
6389
|
+
const a = ea[k], b = eb[k];
|
|
6390
|
+
const ux = px[a] - px[b], uy = py[a] - py[b], uz = pz[a] - pz[b];
|
|
6391
|
+
const d = Math.max(Math.sqrt(ux * ux + uy * uy + uz * uz), 1e-6);
|
|
6392
|
+
const f = (d - R) * 0.5 * ew[k] / d;
|
|
6393
|
+
lx[b] += ux * f;
|
|
6394
|
+
ly[b] += uy * f;
|
|
6395
|
+
lz[b] += uz * f;
|
|
6396
|
+
lx[a] -= ux * f;
|
|
6397
|
+
ly[a] -= uy * f;
|
|
6398
|
+
lz[a] -= uz * f;
|
|
6399
|
+
}
|
|
6400
|
+
const cap = CAP02 * R * (1 - step / STEPS3) + R / 20;
|
|
6401
|
+
for (let i = 0; i < n; i++) {
|
|
6402
|
+
if (fixed[i]) {
|
|
6403
|
+
px[i] = ax[i];
|
|
6404
|
+
py[i] = ay[i];
|
|
6405
|
+
pz[i] = az[i];
|
|
6406
|
+
continue;
|
|
6407
|
+
}
|
|
6408
|
+
const vx = dx[i] + lx[i] * scale[i] + (ax[i] - px[i]) * pullX[i];
|
|
6409
|
+
const vy = dy[i] + ly[i] * scale[i] + (ay[i] - py[i]) * pullY[i];
|
|
6410
|
+
const vz = dz[i] + lz[i] * scale[i] + (az[i] - pz[i]) * pullZ[i];
|
|
6411
|
+
const len = Math.max(Math.sqrt(vx * vx + vy * vy + vz * vz), 1e-9);
|
|
6412
|
+
const s = Math.min(1, cap / len);
|
|
6413
|
+
px[i] += vx * s;
|
|
6414
|
+
py[i] += vy * s;
|
|
6415
|
+
pz[i] += vz * s;
|
|
6416
|
+
}
|
|
6417
|
+
}
|
|
6418
|
+
const pos = new Float64Array(n * 3);
|
|
6419
|
+
for (let i = 0; i < n; i++) {
|
|
6420
|
+
pos[3 * i] = px[i];
|
|
6421
|
+
pos[3 * i + 1] = py[i];
|
|
6422
|
+
pos[3 * i + 2] = pz[i];
|
|
6423
|
+
}
|
|
6424
|
+
return { pos };
|
|
6425
|
+
}
|
|
6426
|
+
|
|
6427
|
+
// src/layout3d/hang.ts
|
|
6428
|
+
var REST3 = 60;
|
|
6429
|
+
var GOLD = Math.PI * (3 - /* @__PURE__ */ Math.sqrt(5));
|
|
6430
|
+
var HOW = ["centre", "with", "arm", "link", "shelf", "map"];
|
|
6431
|
+
var CENTRE = 0;
|
|
6432
|
+
var WITH = 1;
|
|
6433
|
+
var ARM = 2;
|
|
6434
|
+
var LINK = 3;
|
|
6435
|
+
var SHELF = 4;
|
|
6436
|
+
var MAP = 5;
|
|
6437
|
+
var LINE = REST3 / 8;
|
|
6438
|
+
var len3 = (x, y, z) => Math.sqrt(x * x + y * y + z * z);
|
|
6439
|
+
function quantile90(a, m) {
|
|
6440
|
+
if (m === 0) return 0;
|
|
6441
|
+
const s = Float64Array.from(a.subarray(0, m)).sort();
|
|
6442
|
+
const vi = (m - 1) * 0.9;
|
|
6443
|
+
let lo, hi;
|
|
6444
|
+
if (vi >= m - 1) {
|
|
6445
|
+
lo = m - 1;
|
|
6446
|
+
hi = m - 1;
|
|
6447
|
+
} else {
|
|
6448
|
+
lo = Math.floor(vi);
|
|
6449
|
+
hi = lo + 1;
|
|
6450
|
+
}
|
|
6451
|
+
const t = vi - lo;
|
|
6452
|
+
const d = s[hi] - s[lo];
|
|
6453
|
+
return t >= 0.5 ? s[hi] - d * (1 - t) : s[lo] + d * t;
|
|
6454
|
+
}
|
|
6455
|
+
function hang(ids, body, hangCut, hangDepth, off, taken, group, cpt, plate2, kind, degree, relaxed, opts = {}) {
|
|
6456
|
+
const n = ids.length, k = taken.length;
|
|
6457
|
+
const pinned = plate2 ? plate2.pinned : new Uint8Array(n);
|
|
6458
|
+
const at = plate2 ? plate2.at : null;
|
|
6459
|
+
const pos = new Float64Array(3 * n);
|
|
6460
|
+
const how = new Uint8Array(n).fill(255);
|
|
6461
|
+
const H = opts.held || null;
|
|
6462
|
+
const hat = H ? H.at : null;
|
|
6463
|
+
const line = LINE;
|
|
6464
|
+
const inH = new Uint8Array(n);
|
|
6465
|
+
const hl = [];
|
|
6466
|
+
if (H) {
|
|
6467
|
+
for (let v = 0; v < n; v++) if (H.flag[v] === 1 && !pinned[v]) {
|
|
6468
|
+
inH[v] = 1;
|
|
6469
|
+
hl.push(v);
|
|
6470
|
+
}
|
|
6471
|
+
}
|
|
6472
|
+
function near(x, y, z) {
|
|
6473
|
+
for (let i = 0; i < hl.length; i++) {
|
|
6474
|
+
const u = hl[i];
|
|
6475
|
+
if (len3(x - hat[3 * u], y - hat[3 * u + 1], z - hat[3 * u + 2]) < line) return true;
|
|
6476
|
+
}
|
|
6477
|
+
return false;
|
|
6478
|
+
}
|
|
6479
|
+
let nb = 0;
|
|
6480
|
+
for (let v = 0; v < n; v++) {
|
|
6481
|
+
if (!body[v]) continue;
|
|
6482
|
+
pos[3 * v] = relaxed[3 * v];
|
|
6483
|
+
pos[3 * v + 1] = relaxed[3 * v + 1];
|
|
6484
|
+
pos[3 * v + 2] = relaxed[3 * v + 2];
|
|
6485
|
+
how[v] = taken[group[v]] === v ? CENTRE : WITH;
|
|
6486
|
+
nb++;
|
|
6487
|
+
}
|
|
6488
|
+
const middle = new Float64Array(3);
|
|
6489
|
+
for (let v = 0; v < n; v++) {
|
|
6490
|
+
if (!body[v]) continue;
|
|
6491
|
+
middle[0] += relaxed[3 * v];
|
|
6492
|
+
middle[1] += relaxed[3 * v + 1];
|
|
6493
|
+
middle[2] += relaxed[3 * v + 2];
|
|
6494
|
+
}
|
|
6495
|
+
middle[0] /= nb;
|
|
6496
|
+
middle[1] /= nb;
|
|
6497
|
+
middle[2] /= nb;
|
|
6498
|
+
const skin = new Float64Array(k);
|
|
6499
|
+
const vals = new Float64Array(n);
|
|
6500
|
+
for (let g = 0; g < k; g++) {
|
|
6501
|
+
let m = 0;
|
|
6502
|
+
for (let v = 0; v < n; v++) {
|
|
6503
|
+
if (!body[v] || group[v] !== g || pinned[v]) continue;
|
|
6504
|
+
vals[m++] = len3(relaxed[3 * v] - cpt[3 * g], relaxed[3 * v + 1] - cpt[3 * g + 1], relaxed[3 * v + 2] - cpt[3 * g + 2]);
|
|
6505
|
+
}
|
|
6506
|
+
skin[g] = quantile90(vals, m);
|
|
6507
|
+
}
|
|
6508
|
+
const out = new Float64Array(3);
|
|
6509
|
+
function outward(px, py, pz, g) {
|
|
6510
|
+
let ux = px - cpt[3 * g], uy = py - cpt[3 * g + 1], uz = pz - cpt[3 * g + 2];
|
|
6511
|
+
const lu = len3(ux, uy, uz);
|
|
6512
|
+
if (lu > 1e-6) {
|
|
6513
|
+
ux = ux / lu;
|
|
6514
|
+
uy = uy / lu;
|
|
6515
|
+
uz = uz / lu;
|
|
6516
|
+
} else {
|
|
6517
|
+
ux = 0;
|
|
6518
|
+
uy = 0;
|
|
6519
|
+
uz = 0;
|
|
6520
|
+
}
|
|
6521
|
+
let ox = cpt[3 * g] - middle[0], oy = cpt[3 * g + 1] - middle[1], oz = cpt[3 * g + 2] - middle[2];
|
|
6522
|
+
const lo = len3(ox, oy, oz);
|
|
6523
|
+
if (lo > 1e-6) {
|
|
6524
|
+
ox = ox / lo;
|
|
6525
|
+
oy = oy / lo;
|
|
6526
|
+
oz = oz / lo;
|
|
6527
|
+
} else {
|
|
6528
|
+
ox = 0;
|
|
6529
|
+
oy = 0;
|
|
6530
|
+
oz = 1;
|
|
6531
|
+
}
|
|
6532
|
+
ux = ux + 0.75 * ox;
|
|
6533
|
+
uy = uy + 0.75 * oy;
|
|
6534
|
+
uz = uz + 0.75 * oz;
|
|
6535
|
+
const l = len3(ux, uy, uz);
|
|
6536
|
+
out[0] = ux / l;
|
|
6537
|
+
out[1] = uy / l;
|
|
6538
|
+
out[2] = uz / l;
|
|
6539
|
+
}
|
|
6540
|
+
const fp = new Float64Array(3);
|
|
6541
|
+
const count2 = new Int32Array(n);
|
|
6542
|
+
let nh = 0;
|
|
6543
|
+
for (let v = 0; v < n; v++) if (hangCut[v] !== -1) {
|
|
6544
|
+
count2[hangCut[v]]++;
|
|
6545
|
+
nh++;
|
|
6546
|
+
}
|
|
6547
|
+
const first = new Int32Array(n + 1);
|
|
6548
|
+
for (let c = 0; c < n; c++) first[c + 1] = first[c] + count2[c];
|
|
6549
|
+
const fill = first.slice(0, n);
|
|
6550
|
+
const members = new Int32Array(nh);
|
|
6551
|
+
for (let v = 0; v < n; v++) if (hangCut[v] !== -1) members[fill[hangCut[v]]++] = v;
|
|
6552
|
+
for (let c = 0; c < n; c++) {
|
|
6553
|
+
const a = first[c], b = first[c + 1];
|
|
6554
|
+
if (a === b) continue;
|
|
6555
|
+
const row = members.subarray(a, b);
|
|
6556
|
+
row.sort((x, y) => hangDepth[x] - hangDepth[y] || x - y);
|
|
6557
|
+
const g = group[c];
|
|
6558
|
+
outward(pos[3 * c], pos[3 * c + 1], pos[3 * c + 2], g);
|
|
6559
|
+
const ux = out[0], uy = out[1], uz = out[2];
|
|
6560
|
+
let tx = uy * 1 - uz * 0, ty = uz * 0 - ux * 1, tz = ux * 0 - uy * 0;
|
|
6561
|
+
if (len3(tx, ty, tz) < 1e-3) {
|
|
6562
|
+
tx = uy * 0 - uz * 0;
|
|
6563
|
+
ty = uz * 1 - ux * 0;
|
|
6564
|
+
tz = ux * 0 - uy * 1;
|
|
6565
|
+
}
|
|
6566
|
+
const lt = len3(tx, ty, tz);
|
|
6567
|
+
tx = tx / lt;
|
|
6568
|
+
ty = ty / lt;
|
|
6569
|
+
tz = tz / lt;
|
|
6570
|
+
const wx = uy * tz - uz * ty, wy = uz * tx - ux * tz, wz = ux * ty - uy * tx;
|
|
6571
|
+
const overPlace = !!pinned[c];
|
|
6572
|
+
const fanPoint = (j, d) => {
|
|
6573
|
+
const ang = GOLD * j;
|
|
6574
|
+
const fan = REST3 * 0.5 * Math.sqrt(j);
|
|
6575
|
+
const ca = Math.cos(ang), sa = Math.sin(ang);
|
|
6576
|
+
if (overPlace) {
|
|
6577
|
+
fp[0] = at[3 * c] + ca * fan * 0.5;
|
|
6578
|
+
fp[1] = at[3 * c + 1] + sa * fan * 0.5;
|
|
6579
|
+
fp[2] = at[3 * c + 2] + REST3 * d;
|
|
6580
|
+
} else {
|
|
6581
|
+
const reach2 = skin[g] + REST3 * d;
|
|
6582
|
+
fp[0] = cpt[3 * g] + ux * reach2 + (tx * ca + wx * sa) * fan;
|
|
6583
|
+
fp[1] = cpt[3 * g + 1] + uy * reach2 + (ty * ca + wy * sa) * fan;
|
|
6584
|
+
fp[2] = cpt[3 * g + 2] + uz * reach2 + (tz * ca + wz * sa) * fan;
|
|
6585
|
+
}
|
|
6586
|
+
};
|
|
6587
|
+
const used = H ? /* @__PURE__ */ new Set() : null;
|
|
6588
|
+
if (H) {
|
|
6589
|
+
for (let r = 0; r < row.length; r++) {
|
|
6590
|
+
const v = row[r];
|
|
6591
|
+
if (!inH[v]) continue;
|
|
6592
|
+
const d = hangDepth[v];
|
|
6593
|
+
const hx = hat[3 * v], hy = hat[3 * v + 1], hz = hat[3 * v + 2];
|
|
6594
|
+
let axx, axy, axz;
|
|
6595
|
+
if (overPlace) {
|
|
6596
|
+
axx = at[3 * c];
|
|
6597
|
+
axy = at[3 * c + 1];
|
|
6598
|
+
axz = at[3 * c + 2] + REST3 * d;
|
|
6599
|
+
} else {
|
|
6600
|
+
const reach2 = skin[g] + REST3 * d;
|
|
6601
|
+
axx = cpt[3 * g] + ux * reach2;
|
|
6602
|
+
axy = cpt[3 * g + 1] + uy * reach2;
|
|
6603
|
+
axz = cpt[3 * g + 2] + uz * reach2;
|
|
6604
|
+
}
|
|
6605
|
+
const bound = len3(hx - axx, hy - axy, hz - axz) + line + REST3;
|
|
6606
|
+
for (let j = 0; ; j++) {
|
|
6607
|
+
const fan = REST3 * 0.5 * Math.sqrt(j);
|
|
6608
|
+
if (!((overPlace ? fan * 0.5 : fan) < bound)) break;
|
|
6609
|
+
fanPoint(j, d);
|
|
6610
|
+
if (len3(fp[0] - hx, fp[1] - hy, fp[2] - hz) < line) used.add(j);
|
|
6611
|
+
}
|
|
6612
|
+
}
|
|
6613
|
+
}
|
|
6614
|
+
for (let r = 0; r < row.length; r++) {
|
|
6615
|
+
const v = row[r], d = hangDepth[v];
|
|
6616
|
+
how[v] = degree[v] === 1 && d === 1 ? LINK : ARM;
|
|
6617
|
+
let j = r;
|
|
6618
|
+
if (H) {
|
|
6619
|
+
if (inH[v]) continue;
|
|
6620
|
+
for (j = 0; ; j++) {
|
|
6621
|
+
if (used.has(j)) continue;
|
|
6622
|
+
fanPoint(j, d);
|
|
6623
|
+
if (!near(fp[0], fp[1], fp[2])) break;
|
|
6624
|
+
}
|
|
6625
|
+
used.add(j);
|
|
6626
|
+
}
|
|
6627
|
+
fanPoint(j, d);
|
|
6628
|
+
pos[3 * v] = fp[0];
|
|
6629
|
+
pos[3 * v + 1] = fp[1];
|
|
6630
|
+
pos[3 * v + 2] = fp[2];
|
|
6631
|
+
}
|
|
6632
|
+
}
|
|
6633
|
+
let anyOff = 0;
|
|
6634
|
+
for (let v = 0; v < n; v++) if (off[v]) anyOff++;
|
|
6635
|
+
if (anyOff) {
|
|
6636
|
+
let zmin = Infinity, sx = 0, sy = 0, cnt = 0;
|
|
6637
|
+
for (let v = 0; v < n; v++) {
|
|
6638
|
+
if (off[v]) continue;
|
|
6639
|
+
const end = pinned[v];
|
|
6640
|
+
const src = end ? at : inH[v] ? hat : pos;
|
|
6641
|
+
const fx = src[3 * v], fy = src[3 * v + 1], fz = src[3 * v + 2];
|
|
6642
|
+
if (fz < zmin) zmin = fz;
|
|
6643
|
+
sx += fx;
|
|
6644
|
+
sy += fy;
|
|
6645
|
+
cnt++;
|
|
6646
|
+
}
|
|
6647
|
+
zmin = zmin - REST3 * 3;
|
|
6648
|
+
const cx = sx / cnt, cy = sy / cnt;
|
|
6649
|
+
const shelf = [];
|
|
6650
|
+
for (let v = 0; v < n; v++) if (off[v] && !pinned[v]) shelf.push(v);
|
|
6651
|
+
shelf.sort((x, y) => byCodePoint2(kind[x], kind[y]) || x - y);
|
|
6652
|
+
const shelfPoint = (j) => {
|
|
6653
|
+
const r = REST3 * 0.9 * Math.sqrt(j + 1);
|
|
6654
|
+
fp[0] = cx + r * Math.cos(GOLD * j);
|
|
6655
|
+
fp[1] = cy + r * Math.sin(GOLD * j);
|
|
6656
|
+
fp[2] = zmin;
|
|
6657
|
+
};
|
|
6658
|
+
const used = H ? /* @__PURE__ */ new Set() : null;
|
|
6659
|
+
for (let q = 0; q < shelf.length; q++) {
|
|
6660
|
+
const v = shelf[q];
|
|
6661
|
+
how[v] = SHELF;
|
|
6662
|
+
let j = q;
|
|
6663
|
+
if (H) {
|
|
6664
|
+
if (inH[v]) continue;
|
|
6665
|
+
for (j = 0; ; j++) {
|
|
6666
|
+
if (used.has(j)) continue;
|
|
6667
|
+
shelfPoint(j);
|
|
6668
|
+
if (!near(fp[0], fp[1], fp[2])) break;
|
|
6669
|
+
}
|
|
6670
|
+
used.add(j);
|
|
6671
|
+
}
|
|
6672
|
+
shelfPoint(j);
|
|
6673
|
+
pos[3 * v] = fp[0];
|
|
6674
|
+
pos[3 * v + 1] = fp[1];
|
|
6675
|
+
pos[3 * v + 2] = fp[2];
|
|
6676
|
+
}
|
|
6677
|
+
}
|
|
6678
|
+
if (H) {
|
|
6679
|
+
for (let i = 0; i < hl.length; i++) {
|
|
6680
|
+
const v = hl[i];
|
|
6681
|
+
pos[3 * v] = hat[3 * v];
|
|
6682
|
+
pos[3 * v + 1] = hat[3 * v + 1];
|
|
6683
|
+
pos[3 * v + 2] = hat[3 * v + 2];
|
|
6684
|
+
}
|
|
6685
|
+
}
|
|
6686
|
+
for (let v = 0; v < n; v++) {
|
|
6687
|
+
if (!pinned[v]) continue;
|
|
6688
|
+
pos[3 * v] = at[3 * v];
|
|
6689
|
+
pos[3 * v + 1] = at[3 * v + 1];
|
|
6690
|
+
pos[3 * v + 2] = at[3 * v + 2];
|
|
6691
|
+
how[v] = MAP;
|
|
6692
|
+
}
|
|
6693
|
+
for (let v = 0; v < n; v++) if (how[v] === 255) throw new Error(`hang: ${ids[v]} was placed by no rule`);
|
|
6694
|
+
return { pos, how, skin, middle };
|
|
6695
|
+
}
|
|
6696
|
+
|
|
6697
|
+
// src/layout3d/method.ts
|
|
6698
|
+
var METHOD = "by-links-3d";
|
|
6699
|
+
var REST4 = 60;
|
|
6700
|
+
var STEPS2 = 300;
|
|
6701
|
+
var CROSS = 0.25;
|
|
6702
|
+
var PLATE = 0.02;
|
|
6703
|
+
var HOLD = 0.12;
|
|
6704
|
+
var CAP0 = 0.1;
|
|
6705
|
+
var CUTOFF = 3;
|
|
6706
|
+
var SNAP = REST4 / 1e9;
|
|
6707
|
+
var HELD_BOX = 768;
|
|
6708
|
+
var FRAME_AGREE = 3;
|
|
6709
|
+
var REFUSED = { notObject: "held-not-object", notPoint: "held-not-point", box: "held-box", unit: "held-unit" };
|
|
6710
|
+
function refuse(Kind, code, message) {
|
|
6711
|
+
const err = new Kind(message);
|
|
6712
|
+
err.code = code;
|
|
6713
|
+
throw err;
|
|
6714
|
+
}
|
|
6715
|
+
function isPoint(p) {
|
|
6716
|
+
if (!(Array.isArray(p) || ArrayBuffer.isView(p) && !(p instanceof DataView))) return false;
|
|
6717
|
+
const q = p;
|
|
6718
|
+
if (q.length !== 3) return false;
|
|
6719
|
+
for (let i = 0; i < 3; i++) if (typeof q[i] !== "number" || !Number.isFinite(q[i])) return false;
|
|
6720
|
+
return true;
|
|
6721
|
+
}
|
|
6722
|
+
function readHeld(held) {
|
|
6723
|
+
if (held === void 0 || held === null) return null;
|
|
6724
|
+
let entries = [];
|
|
6725
|
+
if (held instanceof Map) entries = [...held.entries()];
|
|
6726
|
+
else if (typeof held === "object" && !Array.isArray(held) && !ArrayBuffer.isView(held)) entries = Object.entries(held);
|
|
6727
|
+
else refuse(TypeError, REFUSED.notObject, "layoutByLinks3d: held is not a Map or an object");
|
|
6728
|
+
for (const [id, p] of entries) {
|
|
6729
|
+
if (!isPoint(p)) refuse(TypeError, REFUSED.notPoint, `layoutByLinks3d: held[${id}] is not three finite numbers`);
|
|
6730
|
+
}
|
|
6731
|
+
const points2 = entries;
|
|
6732
|
+
if (points2.length) {
|
|
6733
|
+
const lo = [Infinity, Infinity, Infinity], hi = [-Infinity, -Infinity, -Infinity];
|
|
6734
|
+
for (const [, p] of points2) for (let a = 0; a < 3; a++) {
|
|
6735
|
+
if (p[a] < lo[a]) lo[a] = p[a];
|
|
6736
|
+
if (p[a] > hi[a]) hi[a] = p[a];
|
|
6737
|
+
}
|
|
6738
|
+
for (let a = 0; a < 3; a++) {
|
|
6739
|
+
if (hi[a] - lo[a] > HELD_BOX * REST4) {
|
|
6740
|
+
refuse(RangeError, REFUSED.box, `layoutByLinks3d: the held points' box is ${(hi[a] - lo[a]) / REST4} rests on ${"xyz"[a]}, wider than ${HELD_BOX}`);
|
|
6741
|
+
}
|
|
6742
|
+
}
|
|
6743
|
+
}
|
|
6744
|
+
return points2.length ? points2 : null;
|
|
6745
|
+
}
|
|
6746
|
+
function readUnit(u) {
|
|
6747
|
+
if (u === void 0 || u === null) return 0;
|
|
6748
|
+
if (typeof u !== "number" || !Number.isFinite(u) || u < 0 || u > LINE) {
|
|
6749
|
+
refuse(RangeError, REFUSED.unit, `layoutByLinks3d: heldUnit ${String(u)} is not a finite number from 0 to ${LINE}`);
|
|
6750
|
+
}
|
|
6751
|
+
return u;
|
|
6752
|
+
}
|
|
6753
|
+
function frameOf(first, at, hflag, hat, unit) {
|
|
6754
|
+
const cv = [], cx = [], cy = [];
|
|
6755
|
+
for (const [id, q] of first) {
|
|
6756
|
+
const v = at.get(id);
|
|
6757
|
+
if (hflag[v]) {
|
|
6758
|
+
cv.push(v);
|
|
6759
|
+
cx.push(q[0]);
|
|
6760
|
+
cy.push(q[1]);
|
|
6761
|
+
}
|
|
6762
|
+
}
|
|
6763
|
+
const order = cv.map((_, i) => i).sort((p, q) => cv[p] - cv[q]);
|
|
6764
|
+
const m = order.length;
|
|
6765
|
+
const tolZ = unit + SNAP, near = 3 * unit + SNAP;
|
|
6766
|
+
for (let ia = 0; ia < m; ia++) {
|
|
6767
|
+
const a = order[ia], va = cv[a];
|
|
6768
|
+
const ax = hat[3 * va], ay = hat[3 * va + 1], az = hat[3 * va + 2];
|
|
6769
|
+
const bs = [], bdist = [];
|
|
6770
|
+
for (let ib = 0; ib < m; ib++) {
|
|
6771
|
+
const c = order[ib];
|
|
6772
|
+
if (c === a) continue;
|
|
6773
|
+
const dz = hat[3 * cv[c] + 2] - az;
|
|
6774
|
+
if (!(dz <= tolZ && -dz <= tolZ)) continue;
|
|
6775
|
+
if (cx[c] === cx[a] && cy[c] === cy[a]) continue;
|
|
6776
|
+
const mx = cx[c] - cx[a], my = cy[c] - cy[a];
|
|
6777
|
+
bs.push(bs.length);
|
|
6778
|
+
bdist.push([c, Math.sqrt(mx * mx + my * my)]);
|
|
6779
|
+
}
|
|
6780
|
+
bs.sort((p, q) => bdist[q][1] - bdist[p][1] || p - q);
|
|
6781
|
+
for (const ib of bs) {
|
|
6782
|
+
const [b, bd] = bdist[ib];
|
|
6783
|
+
const vb = cv[b];
|
|
6784
|
+
const hx = hat[3 * vb] - ax, hy = hat[3 * vb + 1] - ay;
|
|
6785
|
+
if (hx === 0 && hy === 0) continue;
|
|
6786
|
+
const s = Math.sqrt(hx * hx + hy * hy) / bd;
|
|
6787
|
+
const P = Float64Array.of(ax - s * cx[a], ay - s * cy[a], az);
|
|
6788
|
+
let agree = 0;
|
|
6789
|
+
for (let ic = 0; ic < m; ic++) {
|
|
6790
|
+
const c = order[ic], vc = cv[c];
|
|
6791
|
+
const ex = hat[3 * vc] - (P[0] + s * cx[c]), ey = hat[3 * vc + 1] - (P[1] + s * cy[c]), ez = hat[3 * vc + 2] - P[2];
|
|
6792
|
+
if (ex <= near && -ex <= near && ey <= near && -ey <= near && ez <= near && -ez <= near) agree++;
|
|
6793
|
+
}
|
|
6794
|
+
if (agree >= FRAME_AGREE) return { a: va, b: vb, s, P, agree };
|
|
6795
|
+
}
|
|
6796
|
+
}
|
|
6797
|
+
return null;
|
|
6798
|
+
}
|
|
6799
|
+
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
6800
|
+
function fnv1a(id) {
|
|
6801
|
+
let h = 2166136261;
|
|
6802
|
+
for (const b of encoder.encode(id)) h = Math.imul(h ^ b, 16777619) >>> 0;
|
|
6803
|
+
return h;
|
|
6804
|
+
}
|
|
6805
|
+
function byLink(a, b) {
|
|
6806
|
+
return byCodePoint2(a.source, b.source) || byCodePoint2(a.field ?? "", b.field ?? "") || (a.index ?? 0) - (b.index ?? 0) || byCodePoint2(a.target, b.target);
|
|
6807
|
+
}
|
|
6808
|
+
function feedOf(ids, body, pairs, taken, group, cpt, plate2, opts = {}) {
|
|
6809
|
+
const held = opts.held || null;
|
|
6810
|
+
const free = opts.free || null;
|
|
6811
|
+
const extra = opts.extra || [];
|
|
6812
|
+
const n = ids.length;
|
|
6813
|
+
const at = new Map(ids.map((id, i) => [id, i]));
|
|
6814
|
+
const blist = [], bi = new Int32Array(n).fill(-1);
|
|
6815
|
+
for (let v = 0; v < n; v++) if (body[v]) {
|
|
6816
|
+
bi[v] = blist.length;
|
|
6817
|
+
blist.push(v);
|
|
6818
|
+
}
|
|
6819
|
+
const nb = blist.length;
|
|
6820
|
+
const centre = new Uint8Array(n);
|
|
6821
|
+
for (const t of taken) centre[t] = 1;
|
|
6822
|
+
const pinned = plate2 ? plate2.pinned : null;
|
|
6823
|
+
const seen = /* @__PURE__ */ new Set(), bp = [];
|
|
6824
|
+
for (const [x, y] of pairs) {
|
|
6825
|
+
const a = at.get(x), b = at.get(y);
|
|
6826
|
+
if (a === void 0 || b === void 0 || a === b) continue;
|
|
6827
|
+
let i = bi[a], j = bi[b];
|
|
6828
|
+
if (i < 0 || j < 0) continue;
|
|
6829
|
+
if (i > j) {
|
|
6830
|
+
const t = i;
|
|
6831
|
+
i = j;
|
|
6832
|
+
j = t;
|
|
6833
|
+
}
|
|
6834
|
+
const key3 = i * nb + j;
|
|
6835
|
+
if (seen.has(key3)) continue;
|
|
6836
|
+
seen.add(key3);
|
|
6837
|
+
bp.push([i, j]);
|
|
6838
|
+
}
|
|
6839
|
+
bp.sort((p, q) => p[0] - q[0] || p[1] - q[1]);
|
|
6840
|
+
const weight = bp.map(([i, j]) => {
|
|
6841
|
+
const u = blist[i], w = blist[j];
|
|
6842
|
+
let x = group[u] === group[w] ? 1 : CROSS;
|
|
6843
|
+
if (pinned && (pinned[u] || pinned[w])) x = PLATE;
|
|
6844
|
+
return x;
|
|
6845
|
+
});
|
|
6846
|
+
const anchor = blist.map((v) => pinned && pinned[v] ? [plate2.at[3 * v], plate2.at[3 * v + 1], plate2.at[3 * v + 2]] : held && held.flag[v] ? [held.at[3 * v], held.at[3 * v + 1], held.at[3 * v + 2]] : [cpt[3 * group[v]], cpt[3 * group[v] + 1], cpt[3 * group[v] + 2]]);
|
|
6847
|
+
const pull = blist.map(() => HOLD);
|
|
6848
|
+
const fixed = blist.map((v) => !!centre[v] && !(free && free[group[v]] === 1) || !!pinned && !!pinned[v] || !!held && held.flag[v] === 1);
|
|
6849
|
+
const feed = {
|
|
6850
|
+
rest: REST4,
|
|
6851
|
+
steps: STEPS2,
|
|
6852
|
+
ids: blist.map((v) => ids[v]),
|
|
6853
|
+
pairs: bp,
|
|
6854
|
+
weight,
|
|
6855
|
+
anchor,
|
|
6856
|
+
pull,
|
|
6857
|
+
fixed,
|
|
6858
|
+
group: blist.map((v) => group[v]),
|
|
6859
|
+
num: blist.map((v) => fnv1a(ids[v]))
|
|
6860
|
+
};
|
|
6861
|
+
for (const v of extra) {
|
|
6862
|
+
const h = held;
|
|
6863
|
+
feed.ids.push(ids[v]);
|
|
6864
|
+
feed.anchor.push([h.at[3 * v], h.at[3 * v + 1], h.at[3 * v + 2]]);
|
|
6865
|
+
feed.pull.push(0);
|
|
6866
|
+
feed.fixed.push(true);
|
|
6867
|
+
feed.group.push(-1);
|
|
6868
|
+
feed.num.push(fnv1a(ids[v]));
|
|
6869
|
+
}
|
|
6870
|
+
return feed;
|
|
6871
|
+
}
|
|
6872
|
+
function startOf(feed) {
|
|
6873
|
+
const nb = feed.anchor.length;
|
|
6874
|
+
const out = new Array(nb);
|
|
6875
|
+
const members = /* @__PURE__ */ new Map();
|
|
6876
|
+
for (let i = 0; i < nb; i++) {
|
|
6877
|
+
if (feed.fixed[i]) out[i] = [feed.anchor[i][0], feed.anchor[i][1], feed.anchor[i][2]];
|
|
6878
|
+
if (feed.fixed[i]) continue;
|
|
6879
|
+
const g = feed.group[i];
|
|
6880
|
+
if (!members.has(g)) members.set(g, []);
|
|
6881
|
+
members.get(g).push(i);
|
|
6882
|
+
}
|
|
6883
|
+
for (const list2 of members.values()) {
|
|
6884
|
+
const zero = list2.map(() => [0, 0, 0]);
|
|
6885
|
+
const off = plainStart({ rest: feed.rest, pos: zero, anchor: zero, fixed: null }, list2.map((i) => feed.num[i]));
|
|
6886
|
+
for (let k = 0; k < list2.length; k++) {
|
|
6887
|
+
const i = list2[k];
|
|
6888
|
+
if (feed.fixed[i]) continue;
|
|
6889
|
+
const a = feed.anchor[i];
|
|
6890
|
+
out[i] = [a[0] + off[k][0], a[1] + off[k][1], a[2] + off[k][2]];
|
|
6891
|
+
}
|
|
6892
|
+
}
|
|
6893
|
+
return out;
|
|
6894
|
+
}
|
|
6895
|
+
function layout3d(nodes, edges, rows2, table, opts = {}) {
|
|
6896
|
+
const heldIn = readHeld(opts.held);
|
|
6897
|
+
const unit = readUnit(opts.heldUnit);
|
|
6898
|
+
const steps = STEPS2;
|
|
6899
|
+
const n = nodes.length;
|
|
6900
|
+
const handed = nodes.map((x) => x.id);
|
|
6901
|
+
if (!n) return { method: METHOD, ids: [], points: new Float64Array(0), how: [], group: [], part: [], centres: [], held: [] };
|
|
6902
|
+
const sortedNodes = [...nodes].sort((a, b) => byCodePoint2(a.id, b.id));
|
|
6903
|
+
const ids = sortedNodes.map((x) => x.id);
|
|
6904
|
+
for (let i = 1; i < n; i++) if (ids[i] === ids[i - 1]) throw new Error(`layoutByLinks3d: two nodes share the id ${ids[i]}`);
|
|
6905
|
+
const at = new Map(ids.map((id, i) => [id, i]));
|
|
6906
|
+
const links = edges.filter((e) => at.has(e.source) && at.has(e.target)).sort(byLink);
|
|
6907
|
+
const seen = /* @__PURE__ */ new Set(), ip = [];
|
|
6908
|
+
for (const e of links) {
|
|
6909
|
+
const a = at.get(e.source), b = at.get(e.target);
|
|
6910
|
+
if (a === b) continue;
|
|
6911
|
+
const lo = a < b ? a : b, hi = a < b ? b : a;
|
|
6912
|
+
const key3 = lo * n + hi;
|
|
6913
|
+
if (seen.has(key3)) continue;
|
|
6914
|
+
seen.add(key3);
|
|
6915
|
+
ip.push([lo, hi]);
|
|
6916
|
+
}
|
|
6917
|
+
ip.sort((p2, q) => p2[0] - q[0] || p2[1] - q[1]);
|
|
6918
|
+
const pairs = ip.map(([a, b]) => [ids[a], ids[b]]);
|
|
6919
|
+
const edges3 = links.map((e) => [e.source, e.target, e.field]);
|
|
6920
|
+
const s = structure(ids, pairs);
|
|
6921
|
+
const c = centres(ids, pairs, s.body);
|
|
6922
|
+
const k = c.taken.length;
|
|
6923
|
+
let hflag = null, hat = null;
|
|
6924
|
+
if (heldIn) {
|
|
6925
|
+
for (const [id, q] of heldIn) {
|
|
6926
|
+
const v = at.get(id);
|
|
6927
|
+
if (v === void 0) continue;
|
|
6928
|
+
if (!hflag) {
|
|
6929
|
+
hflag = new Uint8Array(n);
|
|
6930
|
+
hat = new Float64Array(3 * n);
|
|
6931
|
+
}
|
|
6932
|
+
const h2 = hat;
|
|
6933
|
+
hflag[v] = 1;
|
|
6934
|
+
h2[3 * v] = q[0];
|
|
6935
|
+
h2[3 * v + 1] = q[1];
|
|
6936
|
+
h2[3 * v + 2] = q[2];
|
|
6937
|
+
}
|
|
6938
|
+
}
|
|
6939
|
+
let plateAt = null, plateAns = null, frame = null;
|
|
6940
|
+
if (rows2) {
|
|
6941
|
+
plateAns = plate(rows2, new Set(ids));
|
|
6942
|
+
if (plateAns && hflag) {
|
|
6943
|
+
frame = frameOf(plateAns.first, at, hflag, hat, unit);
|
|
6944
|
+
if (frame) plateAns = plate(rows2, new Set(ids), { scale: frame.s });
|
|
6945
|
+
}
|
|
6946
|
+
plateAt = plateAns ? plateAns.at : null;
|
|
6947
|
+
}
|
|
6948
|
+
let keep = null, cases = null, popts = {};
|
|
6949
|
+
const extra = [];
|
|
6950
|
+
if (hflag) {
|
|
6951
|
+
const hp = hat;
|
|
6952
|
+
const pinnedV = new Uint8Array(n);
|
|
6953
|
+
if (plateAt) for (const id of plateAt.keys()) pinnedV[at.get(id)] = 1;
|
|
6954
|
+
keep = new Uint8Array(n);
|
|
6955
|
+
for (let v = 0; v < n; v++) if (hflag[v] && !pinnedV[v]) keep[v] = 1;
|
|
6956
|
+
cases = new Uint8Array(k);
|
|
6957
|
+
const gflag = new Uint8Array(k), gat = new Float64Array(3 * k);
|
|
6958
|
+
const sx = new Float64Array(k), sy = new Float64Array(k), sz = new Float64Array(k);
|
|
6959
|
+
const cnt = new Int32Array(k);
|
|
6960
|
+
for (let i = 0; i < n; i++) {
|
|
6961
|
+
const v = i;
|
|
6962
|
+
if (!s.body[v] || !keep[v]) continue;
|
|
6963
|
+
const g = c.group[v];
|
|
6964
|
+
sx[g] += hp[3 * v];
|
|
6965
|
+
sy[g] += hp[3 * v + 1];
|
|
6966
|
+
sz[g] += hp[3 * v + 2];
|
|
6967
|
+
cnt[g]++;
|
|
6968
|
+
}
|
|
6969
|
+
for (let g = 0; g < k; g++) {
|
|
6970
|
+
const t = c.taken[g];
|
|
6971
|
+
if (pinnedV[t]) cases[g] = 1;
|
|
6972
|
+
else if (keep[t]) {
|
|
6973
|
+
cases[g] = 2;
|
|
6974
|
+
gflag[g] = 1;
|
|
6975
|
+
gat[3 * g] = hp[3 * t];
|
|
6976
|
+
gat[3 * g + 1] = hp[3 * t + 1];
|
|
6977
|
+
gat[3 * g + 2] = hp[3 * t + 2];
|
|
6978
|
+
} else if (cnt[g] > 0) {
|
|
6979
|
+
cases[g] = 3;
|
|
6980
|
+
gflag[g] = 1;
|
|
6981
|
+
gat[3 * g] = sx[g] / cnt[g];
|
|
6982
|
+
gat[3 * g + 1] = sy[g] / cnt[g];
|
|
6983
|
+
gat[3 * g + 2] = sz[g] / cnt[g];
|
|
6984
|
+
} else cases[g] = 4;
|
|
6985
|
+
}
|
|
6986
|
+
popts = {
|
|
6987
|
+
fixed: { group: gflag, at: gat, plate: frame ? frame.P : null },
|
|
6988
|
+
snap: { flag: hflag, at: hp, near: 3 * unit + SNAP }
|
|
6989
|
+
};
|
|
6990
|
+
for (let v = 0; v < n; v++) if (keep[v] && !s.body[v]) extra.push(v);
|
|
6991
|
+
}
|
|
6992
|
+
const p = hflag ? points(s.ids, s.body, c.taken, c.group, pairs, edges3, plateAt, table, popts) : points(s.ids, s.body, c.taken, c.group, pairs, edges3, plateAt, table);
|
|
6993
|
+
const heldOpt = keep ? { flag: keep, at: hat } : null;
|
|
6994
|
+
let free = null;
|
|
6995
|
+
if (cases) {
|
|
6996
|
+
free = new Uint8Array(k);
|
|
6997
|
+
for (let g = 0; g < k; g++) {
|
|
6998
|
+
if (cases[g] === 3) free[g] = 1;
|
|
6999
|
+
else if (cases[g] === 4) free[g] = 1;
|
|
7000
|
+
}
|
|
7001
|
+
}
|
|
7002
|
+
const feed = feedOf(s.ids, s.body, pairs, c.taken, c.group, p.cpt, p.plate, { held: heldOpt, free, extra });
|
|
7003
|
+
const start = startOf(feed);
|
|
7004
|
+
const r = relax({ ...feed, pos: start }, { steps, cap0: CAP0, cutoff: CUTOFF });
|
|
7005
|
+
const relaxed = new Float64Array(3 * n);
|
|
7006
|
+
let j = 0;
|
|
7007
|
+
for (let v = 0; v < n; v++) {
|
|
7008
|
+
if (!s.body[v]) continue;
|
|
7009
|
+
relaxed[3 * v] = r.pos[3 * j];
|
|
7010
|
+
relaxed[3 * v + 1] = r.pos[3 * j + 1];
|
|
7011
|
+
relaxed[3 * v + 2] = r.pos[3 * j + 2];
|
|
7012
|
+
j++;
|
|
7013
|
+
}
|
|
7014
|
+
const kind = sortedNodes.map((x) => x.type);
|
|
7015
|
+
const degree = new Int32Array(n);
|
|
7016
|
+
for (const [a, b] of ip) {
|
|
7017
|
+
degree[a]++;
|
|
7018
|
+
degree[b]++;
|
|
7019
|
+
}
|
|
7020
|
+
const hopts = {};
|
|
7021
|
+
if (heldOpt) hopts.held = { ...heldOpt };
|
|
7022
|
+
const h = hang(s.ids, s.body, s.hangCut, s.hangDepth, s.off, c.taken, c.group, p.cpt, p.plate, kind, degree, relaxed, hopts);
|
|
7023
|
+
const out = new Float64Array(3 * n), how = new Array(n), group = new Array(n), part = new Array(n);
|
|
7024
|
+
const held = new Array(n);
|
|
7025
|
+
for (let i = 0; i < n; i++) {
|
|
7026
|
+
const v = at.get(handed[i]);
|
|
7027
|
+
out[3 * i] = h.pos[3 * v];
|
|
7028
|
+
out[3 * i + 1] = h.pos[3 * v + 1];
|
|
7029
|
+
out[3 * i + 2] = h.pos[3 * v + 2];
|
|
7030
|
+
held[i] = keep !== null && keep[v] === 1;
|
|
7031
|
+
const w = h.how[v];
|
|
7032
|
+
how[i] = HOW[w];
|
|
7033
|
+
const own4 = s.body[v] && c.taken[c.group[v]] === v;
|
|
7034
|
+
if (w === CENTRE || w === WITH || w === MAP && own4) {
|
|
7035
|
+
group[i] = ids[c.taken[c.group[v]]];
|
|
7036
|
+
part[i] = null;
|
|
7037
|
+
} else if (w === MAP) {
|
|
7038
|
+
group[i] = null;
|
|
7039
|
+
part[i] = "map";
|
|
7040
|
+
} else if (w === ARM || w === LINK) {
|
|
7041
|
+
group[i] = null;
|
|
7042
|
+
part[i] = "one-link";
|
|
7043
|
+
} else {
|
|
7044
|
+
group[i] = null;
|
|
7045
|
+
part[i] = "no-link";
|
|
7046
|
+
}
|
|
7047
|
+
}
|
|
7048
|
+
return { method: METHOD, ids: handed, points: out, how, group, part, centres: Array.from(c.taken, (t) => ids[t]), held };
|
|
7049
|
+
}
|
|
7050
|
+
|
|
7051
|
+
// src/layout3d/space.ts
|
|
7052
|
+
var isRow3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
7053
|
+
var idOf4 = (v) => typeof v === "string" && v !== "" ? v : null;
|
|
7054
|
+
function spaceRows(elements) {
|
|
7055
|
+
if (elements === null || elements === void 0) return null;
|
|
7056
|
+
const space = mapSpace(elements);
|
|
7057
|
+
const rawMaps = /* @__PURE__ */ new Map(), rawPins = /* @__PURE__ */ new Map();
|
|
7058
|
+
for (const e of elements) {
|
|
7059
|
+
if (!isRow3(e) || typeof e.type !== "string") continue;
|
|
7060
|
+
const id = idOf4(e.id);
|
|
7061
|
+
if (id === null) continue;
|
|
7062
|
+
if (e.type === "map") rawMaps.set(id, e);
|
|
7063
|
+
else if (e.type === "pin") rawPins.set(id, e);
|
|
7064
|
+
}
|
|
7065
|
+
const maps = [...rawMaps.values()], pins = [...rawPins.values()];
|
|
7066
|
+
const rows2 = [];
|
|
7067
|
+
for (const m of space.maps) {
|
|
7068
|
+
const raw = rawMaps.get(m.id);
|
|
7069
|
+
if (layoutOf(raw, maps, pins).layout !== null) continue;
|
|
7070
|
+
rows2.push({ type: "map", id: m.id, width: m.width, height: m.height, location: m.location, name: raw.name });
|
|
7071
|
+
}
|
|
7072
|
+
for (const p of space.pins) {
|
|
7073
|
+
rows2.push({ type: "pin", id: p.pin, map: p.map, element_id: p.element_id, x: p.x, y: p.y });
|
|
7074
|
+
}
|
|
7075
|
+
return rows2;
|
|
7076
|
+
}
|
|
7077
|
+
|
|
7078
|
+
// src/layout-by-links-3d.ts
|
|
7079
|
+
var BY_LINKS_3D_REST = 60;
|
|
7080
|
+
var KEYS = ["held", "heldUnit"];
|
|
7081
|
+
function layoutByLinks3d(graph, elements, options) {
|
|
7082
|
+
refuseUnknownOptions("layoutByLinks3d", options, KEYS);
|
|
7083
|
+
if (!graph || typeof graph !== "object" || !Array.isArray(graph.nodes) || !Array.isArray(graph.edges)) {
|
|
7084
|
+
throw new TypeError("layoutByLinks3d: the graph is { nodes, edges }, as worldGraph answers it");
|
|
7085
|
+
}
|
|
7086
|
+
const rows2 = spaceRows(elements);
|
|
7087
|
+
return layout3d(graph.nodes, graph.edges, rows2, LAYOUT_DIRECTIONS, options ?? {});
|
|
7088
|
+
}
|
|
7089
|
+
|
|
5410
7090
|
// src/drag.ts
|
|
5411
7091
|
var TYPES = new Set(ELEMENT_TYPES);
|
|
5412
7092
|
function dragField(a, b) {
|
|
5413
7093
|
if (typeof a !== "string" || typeof b !== "string" || !TYPES.has(a) || !TYPES.has(b) || a === b) return null;
|
|
5414
|
-
const
|
|
5415
|
-
if (!Object.prototype.hasOwnProperty.call(DRAG_PAIRS,
|
|
5416
|
-
const row = DRAG_PAIRS[
|
|
7094
|
+
const key3 = a < b ? `${a}+${b}` : `${b}+${a}`;
|
|
7095
|
+
if (!Object.prototype.hasOwnProperty.call(DRAG_PAIRS, key3)) return null;
|
|
7096
|
+
const row = DRAG_PAIRS[key3];
|
|
5417
7097
|
return { on: row.on, field: row.field, holds: row.holds };
|
|
5418
7098
|
}
|
|
5419
7099
|
|
|
@@ -5426,7 +7106,7 @@ function deepFreeze(value) {
|
|
|
5426
7106
|
return value;
|
|
5427
7107
|
}
|
|
5428
7108
|
var VIEWS = /* @__PURE__ */ deepFreeze(VIEWS_TABLE);
|
|
5429
|
-
var own2 = (el,
|
|
7109
|
+
var own2 = (el, key3) => Object.prototype.hasOwnProperty.call(el, key3) ? el[key3] : void 0;
|
|
5430
7110
|
var PROFILE_READERS = {
|
|
5431
7111
|
room: (el) => isRoomElement(el),
|
|
5432
7112
|
charter: (el) => isCharterElement(el)
|
|
@@ -5539,9 +7219,9 @@ var tables = null;
|
|
|
5539
7219
|
function load() {
|
|
5540
7220
|
const ccc = /* @__PURE__ */ new Map();
|
|
5541
7221
|
for (const run of NFC_CLASS_RUNS.split(",")) {
|
|
5542
|
-
const [start,
|
|
7222
|
+
const [start, count2, cls] = run.split(".");
|
|
5543
7223
|
const s = parseInt(start, 36);
|
|
5544
|
-
const n =
|
|
7224
|
+
const n = count2 ? parseInt(count2, 36) : 1;
|
|
5545
7225
|
const c = parseInt(cls, 36);
|
|
5546
7226
|
for (let k = 0; k < n; k++) ccc.set(s + k, c);
|
|
5547
7227
|
}
|
|
@@ -5658,7 +7338,7 @@ var OwWorldFileError = class extends Error {
|
|
|
5658
7338
|
}
|
|
5659
7339
|
};
|
|
5660
7340
|
var READ_OPTION_KEYS = ["maxBytes", "maxEntries", "skip"];
|
|
5661
|
-
var
|
|
7341
|
+
var refuse2 = (reason, message) => {
|
|
5662
7342
|
throw new OwWorldFileError(reason, message);
|
|
5663
7343
|
};
|
|
5664
7344
|
function pathFault(name) {
|
|
@@ -5690,7 +7370,7 @@ function isJunk(path) {
|
|
|
5690
7370
|
function foldName(name) {
|
|
5691
7371
|
return simpleCaseFold(nfc(name));
|
|
5692
7372
|
}
|
|
5693
|
-
function
|
|
7373
|
+
function byCodePoint3(a, b) {
|
|
5694
7374
|
const n = Math.min(a.length, b.length);
|
|
5695
7375
|
for (let i = 0; i < n; i++) {
|
|
5696
7376
|
const x = a.codePointAt(i);
|
|
@@ -5724,29 +7404,29 @@ function centralDirectory(bytes) {
|
|
|
5724
7404
|
break;
|
|
5725
7405
|
}
|
|
5726
7406
|
}
|
|
5727
|
-
if (end < 0)
|
|
7407
|
+
if (end < 0) refuse2("not_openable", "The file is not a zip: it has no end of central directory.");
|
|
5728
7408
|
const thisDisk = u16(bytes, end + 4);
|
|
5729
7409
|
const cdDisk = u16(bytes, end + 6);
|
|
5730
7410
|
if (!(thisDisk === 0 && cdDisk === 0 || thisDisk === 65535 && cdDisk === 65535)) {
|
|
5731
|
-
|
|
7411
|
+
refuse2("not_openable", `The zip spans disks (its end record says disk ${thisDisk}, the directory on disk ${cdDisk}).`);
|
|
5732
7412
|
}
|
|
5733
7413
|
let cdSize = u32(bytes, end + 12);
|
|
5734
7414
|
let cdOffset = u32(bytes, end + 16);
|
|
5735
7415
|
const loc = end - 20;
|
|
5736
7416
|
if (loc >= 0 && u32(bytes, loc) === SIG_LOCATOR64) {
|
|
5737
|
-
if (u32(bytes, loc + 4) !== 0 || u32(bytes, loc + 16) > 1)
|
|
7417
|
+
if (u32(bytes, loc + 4) !== 0 || u32(bytes, loc + 16) > 1) refuse2("not_openable", "The zip spans disks (zip64).");
|
|
5738
7418
|
const rec = u64(bytes, loc + 8);
|
|
5739
|
-
if (rec + 56 > len || u32(bytes, rec) !== SIG_END64)
|
|
5740
|
-
if (u32(bytes, rec + 16) !== 0 || u32(bytes, rec + 20) !== 0)
|
|
7419
|
+
if (rec + 56 > len || u32(bytes, rec) !== SIG_END64) refuse2("not_openable", "The zip64 end record is missing.");
|
|
7420
|
+
if (u32(bytes, rec + 16) !== 0 || u32(bytes, rec + 20) !== 0) refuse2("not_openable", "The zip spans disks (zip64).");
|
|
5741
7421
|
cdSize = u64(bytes, rec + 40);
|
|
5742
7422
|
cdOffset = u64(bytes, rec + 48);
|
|
5743
7423
|
}
|
|
5744
7424
|
const cdEnd = cdOffset + cdSize;
|
|
5745
|
-
if (cdEnd > len)
|
|
7425
|
+
if (cdEnd > len) refuse2("not_openable", "The central directory lies past the end of the file.");
|
|
5746
7426
|
const out = [];
|
|
5747
7427
|
let p = cdOffset;
|
|
5748
7428
|
while (p < cdEnd) {
|
|
5749
|
-
if (p + 46 > cdEnd || u32(bytes, p) !== SIG_CENTRAL)
|
|
7429
|
+
if (p + 46 > cdEnd || u32(bytes, p) !== SIG_CENTRAL) refuse2("not_openable", "The central directory is broken.");
|
|
5750
7430
|
const flags = u16(bytes, p + 8);
|
|
5751
7431
|
const nlen = u16(bytes, p + 28);
|
|
5752
7432
|
const elen = u16(bytes, p + 30);
|
|
@@ -5762,7 +7442,7 @@ function centralDirectory(bytes) {
|
|
|
5762
7442
|
let r = q + 4;
|
|
5763
7443
|
const stop = r + u16(extra, q + 2);
|
|
5764
7444
|
const next = () => {
|
|
5765
|
-
if (r + 8 > stop)
|
|
7445
|
+
if (r + 8 > stop) refuse2("not_openable", "A zip64 extra field is short.");
|
|
5766
7446
|
const v = u64(extra, r);
|
|
5767
7447
|
r += 8;
|
|
5768
7448
|
return v;
|
|
@@ -5800,7 +7480,7 @@ function centralDirectory(bytes) {
|
|
|
5800
7480
|
});
|
|
5801
7481
|
p += 46 + nlen + elen + clen;
|
|
5802
7482
|
}
|
|
5803
|
-
if (p !== cdEnd)
|
|
7483
|
+
if (p !== cdEnd) refuse2("not_openable", "The central directory is broken.");
|
|
5804
7484
|
return out;
|
|
5805
7485
|
}
|
|
5806
7486
|
var crcTable = null;
|
|
@@ -5838,7 +7518,7 @@ function endsEarly(payload) {
|
|
|
5838
7518
|
}
|
|
5839
7519
|
function inflateEntry(bytes, e) {
|
|
5840
7520
|
const off = e.offset;
|
|
5841
|
-
if (off + 30 > bytes.length || u32(bytes, off) !== SIG_LOCAL)
|
|
7521
|
+
if (off + 30 > bytes.length || u32(bytes, off) !== SIG_LOCAL) refuse2("not_openable", `${e.name}: no local header at its offset.`);
|
|
5842
7522
|
const start = off + 30 + u16(bytes, off + 26) + u16(bytes, off + 28);
|
|
5843
7523
|
const payload = bytes.subarray(start, start + e.csize);
|
|
5844
7524
|
let data;
|
|
@@ -5848,7 +7528,7 @@ function inflateEntry(bytes, e) {
|
|
|
5848
7528
|
try {
|
|
5849
7529
|
data = inflateSync(payload);
|
|
5850
7530
|
} catch {
|
|
5851
|
-
return
|
|
7531
|
+
return refuse2("not_openable", `${e.name}: its deflate stream is broken.`);
|
|
5852
7532
|
}
|
|
5853
7533
|
} else {
|
|
5854
7534
|
const out = new Uint8Array(e.usize);
|
|
@@ -5868,16 +7548,16 @@ function inflateEntry(bytes, e) {
|
|
|
5868
7548
|
inf.push(payload.subarray(i, stop), stop === payload.length);
|
|
5869
7549
|
}
|
|
5870
7550
|
} catch {
|
|
5871
|
-
if (!over)
|
|
7551
|
+
if (!over) refuse2("not_openable", `${e.name}: its deflate stream is broken.`);
|
|
5872
7552
|
}
|
|
5873
7553
|
data = over ? new Uint8Array(e.usize + 1) : out.subarray(0, n);
|
|
5874
7554
|
}
|
|
5875
|
-
if (data.length > e.usize)
|
|
5876
|
-
if (data.length !== e.usize)
|
|
7555
|
+
if (data.length > e.usize) refuse2("too_big", `${e.name} holds more than the ${e.usize} bytes it declares.`);
|
|
7556
|
+
if (data.length !== e.usize) refuse2("not_openable", `${e.name} holds ${data.length} bytes and declares ${e.usize}.`);
|
|
5877
7557
|
if (e.method !== 0 && payload.length > 0 && endsEarly(payload)) {
|
|
5878
|
-
|
|
7558
|
+
refuse2("not_openable", `${e.name}: its deflate stream ends before its declared compressed size.`);
|
|
5879
7559
|
}
|
|
5880
|
-
if (crc32(data) !== e.crc)
|
|
7560
|
+
if (crc32(data) !== e.crc) refuse2("not_openable", `${e.name} fails its CRC.`);
|
|
5881
7561
|
return e.method === 0 ? data.slice() : data;
|
|
5882
7562
|
}
|
|
5883
7563
|
function parseWorld(data) {
|
|
@@ -5917,7 +7597,7 @@ function checkCollisions(names) {
|
|
|
5917
7597
|
done.add(prefix);
|
|
5918
7598
|
const other = byFold.get(folded);
|
|
5919
7599
|
if (other !== void 0) {
|
|
5920
|
-
|
|
7600
|
+
refuse2("collision", `The names ${JSON.stringify(other)} and ${JSON.stringify(prefix)} are one name after NFC and case folding.`);
|
|
5921
7601
|
}
|
|
5922
7602
|
byFold.set(folded, prefix);
|
|
5923
7603
|
}
|
|
@@ -5932,7 +7612,7 @@ function checkFileAndFolder(files) {
|
|
|
5932
7612
|
prefix = i ? `${prefix}/${segs[i]}` : segs[i];
|
|
5933
7613
|
if (seen.has(prefix)) continue;
|
|
5934
7614
|
seen.add(prefix);
|
|
5935
|
-
if (files.has(prefix))
|
|
7615
|
+
if (files.has(prefix)) refuse2("unsafe_path", `${JSON.stringify(prefix)} is a file and a folder.`);
|
|
5936
7616
|
}
|
|
5937
7617
|
}
|
|
5938
7618
|
}
|
|
@@ -5950,29 +7630,29 @@ function readWorldFile(bytes, opts = {}) {
|
|
|
5950
7630
|
const bare = isDir ? name2.slice(0, -1) : name2;
|
|
5951
7631
|
const quoted = JSON.stringify(name2);
|
|
5952
7632
|
const fault = pathFault(bare);
|
|
5953
|
-
if (fault)
|
|
7633
|
+
if (fault) refuse2("unsafe_path", `The entry ${quoted} ${fault}.`);
|
|
5954
7634
|
const kind = e.external >>> 16 & 61440;
|
|
5955
|
-
if (kind !== 0 && kind !== 32768 && kind !== 16384)
|
|
5956
|
-
if (e.flags & 65)
|
|
5957
|
-
if (e.method !== 0 && e.method !== 8)
|
|
5958
|
-
if (e.badUtf8)
|
|
5959
|
-
if (e.nonAscii && !(e.flags & 2048))
|
|
7635
|
+
if (kind !== 0 && kind !== 32768 && kind !== 16384) refuse2("link", `The entry ${quoted} is a link or a special file.`);
|
|
7636
|
+
if (e.flags & 65) refuse2("method", `The entry ${quoted} is encrypted.`);
|
|
7637
|
+
if (e.method !== 0 && e.method !== 8) refuse2("method", `The entry ${quoted} uses method ${e.method} (only stored and deflate).`);
|
|
7638
|
+
if (e.badUtf8) refuse2("name", `The entry ${quoted} is flagged UTF-8 and is not.`);
|
|
7639
|
+
if (e.nonAscii && !(e.flags & 2048)) refuse2("name", `The entry ${quoted} is not ASCII and lacks the UTF-8 flag.`);
|
|
5960
7640
|
const bad = nameFault(bare);
|
|
5961
|
-
if (bad)
|
|
5962
|
-
if (seen.has(name2))
|
|
7641
|
+
if (bad) refuse2("name", `The entry ${quoted}: ${bad}.`);
|
|
7642
|
+
if (seen.has(name2)) refuse2("duplicate", `The entry ${quoted} appears twice.`);
|
|
5963
7643
|
seen.add(name2);
|
|
5964
7644
|
if (isDir) continue;
|
|
5965
7645
|
files.push(e);
|
|
5966
|
-
if (files.length > maxEntries)
|
|
7646
|
+
if (files.length > maxEntries) refuse2("too_many", `The world file holds more than ${maxEntries} files.`);
|
|
5967
7647
|
declared += e.usize;
|
|
5968
|
-
if (declared > maxBytes)
|
|
7648
|
+
if (declared > maxBytes) refuse2("too_big", `The world file declares more than ${maxBytes} bytes.`);
|
|
5969
7649
|
}
|
|
5970
7650
|
checkCollisions(seen);
|
|
5971
7651
|
const names = new Set(files.map((e) => e.name));
|
|
5972
7652
|
checkFileAndFolder(names);
|
|
5973
7653
|
const marker = files.find((e) => e.name === MARKER_NAME);
|
|
5974
7654
|
if (marker && new TextDecoder("utf-8", { ignoreBOM: true }).decode(inflateEntry(bytes, marker)) !== WORLD_FILE_MEDIA_TYPE) {
|
|
5975
|
-
|
|
7655
|
+
refuse2("marker", "The mimetype entry holds other bytes than the OnlyWorlds media type.");
|
|
5976
7656
|
}
|
|
5977
7657
|
const candidates = [...names].filter((n) => n !== MARKER_NAME && !isJunk(n));
|
|
5978
7658
|
let prefix;
|
|
@@ -5980,15 +7660,15 @@ function readWorldFile(bytes, opts = {}) {
|
|
|
5980
7660
|
prefix = "";
|
|
5981
7661
|
} else {
|
|
5982
7662
|
const roots = new Set(candidates.filter((n) => n.split("/").length === 2 && n.endsWith(`/${WORLD_FILE}`) && !n.startsWith(".")).map((n) => n.slice(0, -WORLD_FILE.length)));
|
|
5983
|
-
if (roots.size === 0)
|
|
5984
|
-
if (roots.size > 1)
|
|
7663
|
+
if (roots.size === 0) refuse2("not_a_world", "There is no world.json at the root or in one top-level folder.");
|
|
7664
|
+
if (roots.size > 1) refuse2("more_than_one", `The file holds worlds in ${[...roots].join(", ")}.`);
|
|
5985
7665
|
prefix = [...roots][0];
|
|
5986
7666
|
}
|
|
5987
7667
|
const inside = new Set(candidates.filter((n) => n.startsWith(prefix)));
|
|
5988
7668
|
for (const n of inside) {
|
|
5989
7669
|
const rel = n.slice(prefix.length);
|
|
5990
7670
|
if (rel !== WORLD_FILE && rel.endsWith(`/${WORLD_FILE}`) && !rel.startsWith("records/")) {
|
|
5991
|
-
|
|
7671
|
+
refuse2("more_than_one", `A second world.json sits inside the world: ${n}.`);
|
|
5992
7672
|
}
|
|
5993
7673
|
}
|
|
5994
7674
|
const content = /* @__PURE__ */ new Map();
|
|
@@ -6004,7 +7684,7 @@ function readWorldFile(bytes, opts = {}) {
|
|
|
6004
7684
|
if (opts.skip?.(path)) continue;
|
|
6005
7685
|
out.push({ path, data: n === worldName ? parsed.data : data });
|
|
6006
7686
|
}
|
|
6007
|
-
out.sort((a, b) =>
|
|
7687
|
+
out.sort((a, b) => byCodePoint3(a.path, b.path));
|
|
6008
7688
|
const name = parsed.world.name;
|
|
6009
7689
|
return {
|
|
6010
7690
|
worldId: parsed.world.id,
|
|
@@ -6032,10 +7712,10 @@ function writeOptions(opts) {
|
|
|
6032
7712
|
if (typeof opts !== "object") throw new TypeError(`writeWorldFile: options must be an object, such as { includePrivateRecords: true }. Nothing was written.`);
|
|
6033
7713
|
refuseUnknownOptions("writeWorldFile", opts, WRITE_OPTION_KEYS, "Nothing was written.");
|
|
6034
7714
|
const o = opts;
|
|
6035
|
-
for (const
|
|
6036
|
-
const asked = o[
|
|
7715
|
+
for (const key3 of ["includePrivateRecords", "includeHidden", "includeAuthorFields"]) {
|
|
7716
|
+
const asked = o[key3];
|
|
6037
7717
|
if (asked !== void 0 && typeof asked !== "boolean") {
|
|
6038
|
-
throw new TypeError(`writeWorldFile: ${
|
|
7718
|
+
throw new TypeError(`writeWorldFile: ${key3} must be true or false; got ${JSON.stringify(asked) ?? String(asked)}. Nothing was written.`);
|
|
6039
7719
|
}
|
|
6040
7720
|
}
|
|
6041
7721
|
if (o.report !== void 0 && typeof o.report !== "function") {
|
|
@@ -6122,9 +7802,9 @@ function writeWorldFile(files, topDir, opts = {}) {
|
|
|
6122
7802
|
});
|
|
6123
7803
|
if (!kept.some((f) => f.path === WORLD_FILE)) throw new OwWorldFileError("not_a_world");
|
|
6124
7804
|
const keys = kept.map((f) => `${topDir}/${f.path}`);
|
|
6125
|
-
for (const
|
|
6126
|
-
const bad = nameFault(
|
|
6127
|
-
if (bad) throw new OwWorldFileError("name", `The path ${
|
|
7805
|
+
for (const key3 of keys) {
|
|
7806
|
+
const bad = nameFault(key3);
|
|
7807
|
+
if (bad) throw new OwWorldFileError("name", `The path ${key3}: ${bad}.`);
|
|
6128
7808
|
}
|
|
6129
7809
|
checkCollisions([MARKER_NAME, ...keys]);
|
|
6130
7810
|
checkFileAndFolder(/* @__PURE__ */ new Set([MARKER_NAME, ...keys]));
|
|
@@ -6132,7 +7812,7 @@ function writeWorldFile(files, topDir, opts = {}) {
|
|
|
6132
7812
|
[MARKER_NAME]: [new TextEncoder().encode(WORLD_FILE_MEDIA_TYPE), { level: 0, mtime: STAMP }]
|
|
6133
7813
|
};
|
|
6134
7814
|
let authorFieldsLeftOut = 0;
|
|
6135
|
-
for (const f of [...kept].sort((a, b) =>
|
|
7815
|
+
for (const f of [...kept].sort((a, b) => byCodePoint3(a.path, b.path))) {
|
|
6136
7816
|
let data = f.data;
|
|
6137
7817
|
if (f.path === WORLD_FILE) {
|
|
6138
7818
|
data = withoutLink(data, parseWorld(data)).data;
|
|
@@ -6775,9 +8455,9 @@ function descriptionLines(el) {
|
|
|
6775
8455
|
const d = text(own3(el, "description"));
|
|
6776
8456
|
return d === null ? [] : d.split("\n").map((l) => ` ${l}`);
|
|
6777
8457
|
}
|
|
6778
|
-
function rowsOf(
|
|
6779
|
-
if (
|
|
6780
|
-
if (
|
|
8458
|
+
function rowsOf(key3, v) {
|
|
8459
|
+
if (key3 === "style") return [v];
|
|
8460
|
+
if (key3 === "names") {
|
|
6781
8461
|
if (!isObj(v)) return [];
|
|
6782
8462
|
return Object.keys(v).flatMap((t) => Array.isArray(v[t]) ? v[t] : []);
|
|
6783
8463
|
}
|
|
@@ -6798,8 +8478,8 @@ function draughtText(draught) {
|
|
|
6798
8478
|
const character = own3(d, "character");
|
|
6799
8479
|
const her = isObj(character) && isObj(own3(character, "element")) ? own3(character, "element") : null;
|
|
6800
8480
|
hold(her);
|
|
6801
|
-
for (const
|
|
6802
|
-
for (const row of rowsOf(
|
|
8481
|
+
for (const key3 of ELEMENT_SECTIONS2) {
|
|
8482
|
+
for (const row of rowsOf(key3, own3(d, key3))) if (isObj(row)) hold(own3(row, "element"));
|
|
6803
8483
|
}
|
|
6804
8484
|
const calendar = own3(d, "calendar");
|
|
6805
8485
|
const unit = isObj(calendar) ? text(own3(calendar, "time_basic_unit")) : null;
|
|
@@ -6829,12 +8509,12 @@ function draughtText(draught) {
|
|
|
6829
8509
|
const kind = kindOf(her);
|
|
6830
8510
|
put(typeWordOf(type) + (kind === null ? "" : ` \xB7 ${kind}`) + marks(her));
|
|
6831
8511
|
for (const l of descriptionLines(her)) put(l);
|
|
6832
|
-
for (const
|
|
6833
|
-
if (UNPRINTED.has(
|
|
6834
|
-
const v = her[
|
|
8512
|
+
for (const key3 of Object.keys(her)) {
|
|
8513
|
+
if (UNPRINTED.has(key3) || UNPRINTED_PREFIXES.some((p) => key3.startsWith(p))) continue;
|
|
8514
|
+
const v = her[key3];
|
|
6835
8515
|
if (!isSet(v)) continue;
|
|
6836
8516
|
let value;
|
|
6837
|
-
if (isLinkField(type,
|
|
8517
|
+
if (isLinkField(type, key3)) {
|
|
6838
8518
|
const resolved = [];
|
|
6839
8519
|
let missing = 0;
|
|
6840
8520
|
for (const id of Array.isArray(v) ? v : [v]) {
|
|
@@ -6851,7 +8531,7 @@ function draughtText(draught) {
|
|
|
6851
8531
|
} else {
|
|
6852
8532
|
value = text(v);
|
|
6853
8533
|
}
|
|
6854
|
-
if (value !== null) put(` ${
|
|
8534
|
+
if (value !== null) put(` ${key3.replace(/_/g, " ")}: ${value}`, " ");
|
|
6855
8535
|
}
|
|
6856
8536
|
}
|
|
6857
8537
|
const roster = own3(d, "roster");
|
|
@@ -6899,18 +8579,18 @@ function draughtText(draught) {
|
|
|
6899
8579
|
return line;
|
|
6900
8580
|
};
|
|
6901
8581
|
const recentMore = own3(d, "recent_more") === true;
|
|
6902
|
-
const sectionSet = (
|
|
6903
|
-
for (const [
|
|
6904
|
-
const v = own3(d,
|
|
6905
|
-
if (!sectionSet(
|
|
8582
|
+
const sectionSet = (key3) => isSet(own3(d, key3)) || key3 === "recent" && recentMore;
|
|
8583
|
+
for (const [key3, heading] of SECTIONS) {
|
|
8584
|
+
const v = own3(d, key3);
|
|
8585
|
+
if (!sectionSet(key3)) continue;
|
|
6906
8586
|
out.push("", `## ${heading}`);
|
|
6907
|
-
for (const row of rowsOf(
|
|
8587
|
+
for (const row of rowsOf(key3, v)) {
|
|
6908
8588
|
if (!isObj(row)) continue;
|
|
6909
|
-
if (
|
|
6910
|
-
else if (
|
|
8589
|
+
if (key3 === "recent") put(recentRow(row));
|
|
8590
|
+
else if (key3 === "roster") put(memberRow(row));
|
|
6911
8591
|
else for (const l of elementRow(row)) put(l);
|
|
6912
8592
|
}
|
|
6913
|
-
if (
|
|
8593
|
+
if (key3 === "recent" && recentMore) out.push("More changes than these; read on from recent_cursor.");
|
|
6914
8594
|
}
|
|
6915
8595
|
const policy = own3(d, "policy");
|
|
6916
8596
|
const components = isObj(policy) ? own3(policy, "components") : void 0;
|
|
@@ -7141,13 +8821,13 @@ function multiplesIn(a, b, m, offset) {
|
|
|
7141
8821
|
}
|
|
7142
8822
|
function leapYearsBefore(y, r) {
|
|
7143
8823
|
const [a, b, sign] = y >= 0 ? [0, y, 1] : [y, 0, -1];
|
|
7144
|
-
let
|
|
8824
|
+
let count2 = multiplesIn(a, b, r.n, r.offset);
|
|
7145
8825
|
let s = -1;
|
|
7146
8826
|
for (const d of r.except) {
|
|
7147
|
-
|
|
8827
|
+
count2 += s * multiplesIn(a, b, d, r.offset);
|
|
7148
8828
|
s = -s;
|
|
7149
8829
|
}
|
|
7150
|
-
return sign *
|
|
8830
|
+
return sign * count2;
|
|
7151
8831
|
}
|
|
7152
8832
|
function isLeapYear(y, N) {
|
|
7153
8833
|
return floorMod(y, N) === 0;
|
|
@@ -7224,16 +8904,16 @@ function yearSlots(cfg, y) {
|
|
|
7224
8904
|
if (!months) return [];
|
|
7225
8905
|
const inter = cfg.intercalary ?? [];
|
|
7226
8906
|
const active = (ic) => intercalaryInYear(cfg, ic, y);
|
|
7227
|
-
const
|
|
8907
|
+
const slots2 = [];
|
|
7228
8908
|
const push = (afterMonth) => {
|
|
7229
|
-
for (const ic of inter) if (ic.after_month === afterMonth && active(ic))
|
|
8909
|
+
for (const ic of inter) if (ic.after_month === afterMonth && active(ic)) slots2.push({ kind: "intercalary", intercalary: ic });
|
|
7230
8910
|
};
|
|
7231
8911
|
push(0);
|
|
7232
8912
|
for (let m = 1; m <= months.names.length; m++) {
|
|
7233
|
-
for (let d = 1; d <= months.lengths[m - 1]; d++)
|
|
8913
|
+
for (let d = 1; d <= months.lengths[m - 1]; d++) slots2.push({ kind: "month", month: m, day: d });
|
|
7234
8914
|
push(m);
|
|
7235
8915
|
}
|
|
7236
|
-
return
|
|
8916
|
+
return slots2;
|
|
7237
8917
|
}
|
|
7238
8918
|
function skippedWeekDaysPerYear(cfg) {
|
|
7239
8919
|
const inter = (cfg.intercalary ?? []).filter((i) => i.in_week === false);
|
|
@@ -7269,8 +8949,8 @@ function positionOf(cfg, step) {
|
|
|
7269
8949
|
const y = absoluteYear(cfg, step);
|
|
7270
8950
|
const offset = step - yearStartStep(cfg, y);
|
|
7271
8951
|
if (!cfg.bundles?.months) return { absYear: y, offset, slot: null, slots: null };
|
|
7272
|
-
const
|
|
7273
|
-
return { absYear: y, offset, slot:
|
|
8952
|
+
const slots2 = yearSlots(cfg, y);
|
|
8953
|
+
return { absYear: y, offset, slot: slots2[offset] ?? null, slots: slots2 };
|
|
7274
8954
|
}
|
|
7275
8955
|
function breakdownStep(cfg, step) {
|
|
7276
8956
|
const pos = positionOf(cfg, step);
|
|
@@ -7458,13 +9138,13 @@ function parseDate(cfg, input, opts = {}) {
|
|
|
7458
9138
|
const resolveInYear = (abs) => {
|
|
7459
9139
|
const start = yearStartStep(cfg, abs);
|
|
7460
9140
|
if (monthIndex == null && intercalary == null) return { step: start };
|
|
7461
|
-
const
|
|
9141
|
+
const slots2 = yearSlots(cfg, abs);
|
|
7462
9142
|
if (intercalary != null) {
|
|
7463
|
-
const idx2 =
|
|
9143
|
+
const idx2 = slots2.findIndex((s) => s.kind === "intercalary" && s.intercalary === intercalary);
|
|
7464
9144
|
if (idx2 === -1) return { error: `${intercalary.name} does not occur in that year` };
|
|
7465
9145
|
return { step: start + idx2 };
|
|
7466
9146
|
}
|
|
7467
|
-
const idx =
|
|
9147
|
+
const idx = slots2.findIndex((s) => s.kind === "month" && s.month === monthIndex && s.day === (day ?? 1));
|
|
7468
9148
|
if (idx === -1) return { error: "that day does not exist in that month" };
|
|
7469
9149
|
return { step: start + idx };
|
|
7470
9150
|
};
|
|
@@ -7713,6 +9393,7 @@ var GameTier = /* @__PURE__ */ ((GameTier2) => {
|
|
|
7713
9393
|
export {
|
|
7714
9394
|
AGENT_DOORS,
|
|
7715
9395
|
ASK_LIMITS,
|
|
9396
|
+
BY_LINKS_3D_REST,
|
|
7716
9397
|
CALENDAR_FIELD,
|
|
7717
9398
|
CALENDAR_SUPERTYPE,
|
|
7718
9399
|
CHARTER_PAIRS,
|
|
@@ -7818,6 +9499,7 @@ export {
|
|
|
7818
9499
|
landingOf,
|
|
7819
9500
|
layoutAround,
|
|
7820
9501
|
layoutByKind,
|
|
9502
|
+
layoutByLinks3d,
|
|
7821
9503
|
layoutOf,
|
|
7822
9504
|
lensesInUse,
|
|
7823
9505
|
lookupWorld,
|