Files
externals/npm/web/api/node_modules/ts2fable/dist/ts2fable.js
T

11034 lines
343 KiB
JavaScript
Executable File

#!/usr/bin/env node
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('path'), require('fs'), require('typescript')) :
typeof define === 'function' && define.amd ? define(['exports', 'path', 'fs', 'typescript'], factory) :
(global = global || self, factory(global.ts2fable = {}, global.path$$1, global.fs, global.typescript));
}(this, (function (exports, path$$1, fs, typescript) { 'use strict';
// tslint:disable:ban-types
function isDisposable(x) {
return x != null && typeof x.Dispose === "function";
}
function tryGetValue(map, key, defaultValue) {
return map.has(key) ? [true, map.get(key)] : [false, defaultValue];
}
function addToSet(v, set) {
if (set.has(v)) {
return false;
}
set.add(v);
return true;
}
class Lazy {
constructor(factory) {
this.factory = factory;
this.isValueCreated = false;
}
get Value() {
if (!this.isValueCreated) {
this.createdValue = this.factory();
this.isValueCreated = true;
}
return this.createdValue;
}
get IsValueCreated() {
return this.isValueCreated;
}
}
function dateOffset(date) {
const date1 = date;
return typeof date1.offset === "number" ? date1.offset : date.kind === 1
/* UTC */
? 0 : date.getTimezoneOffset() * -60000;
}
function int32ToString(i, radix) {
i = i < 0 && radix != null && radix !== 10 ? 0xFFFFFFFF + i + 1 : i;
return i.toString(radix);
}
class ObjectRef {
static id(o) {
if (!ObjectRef.idMap.has(o)) {
ObjectRef.idMap.set(o, ++ObjectRef.count);
}
return ObjectRef.idMap.get(o);
}
}
ObjectRef.idMap = new WeakMap();
ObjectRef.count = 0;
function stringHash(s) {
let i = 0;
let h = 5381;
const len = s.length;
while (i < len) {
h = h * 33 ^ s.charCodeAt(i++);
}
return h;
}
function numberHash(x) {
return x * 2654435761 | 0;
} // From https://stackoverflow.com/a/37449594
function combineHashCodes(hashes) {
if (hashes.length === 0) {
return 0;
}
return hashes.reduce((h1, h2) => {
return (h1 << 5) + h1 ^ h2;
});
}
function identityHash(x) {
if (x == null) {
return 0;
}
switch (typeof x) {
case "boolean":
return x ? 1 : 0;
case "number":
return numberHash(x);
case "string":
return stringHash(x);
default:
return numberHash(ObjectRef.id(x));
}
}
function structuralHash(x) {
if (x == null) {
return 0;
}
switch (typeof x) {
case "boolean":
return x ? 1 : 0;
case "number":
return numberHash(x);
case "string":
return stringHash(x);
default:
{
if (typeof x.GetHashCode === "function") {
return x.GetHashCode();
} else if (isArray(x)) {
const ar = x;
const len = ar.length;
const hashes = new Array(len);
for (let i = 0; i < len; i++) {
hashes[i] = structuralHash(ar[i]);
}
return combineHashCodes(hashes);
} else {
return stringHash(String(x));
}
}
}
}
function isArray(x) {
return Array.isArray(x) || ArrayBuffer.isView(x);
}
function equalArraysWith(x, y, eq) {
if (x == null) {
return y == null;
}
if (y == null) {
return false;
}
if (x.length !== y.length) {
return false;
}
for (let i = 0; i < x.length; i++) {
if (!eq(x[i], y[i])) {
return false;
}
}
return true;
}
function equalArrays(x, y) {
return equalArraysWith(x, y, equals);
} // export function equalObjects(x: { [k: string]: any }, y: { [k: string]: any }): boolean {
// if (x == null) { return y == null; }
// if (y == null) { return false; }
// const xKeys = Object.keys(x);
// const yKeys = Object.keys(y);
// if (xKeys.length !== yKeys.length) {
// return false;
// }
// xKeys.sort();
// yKeys.sort();
// for (let i = 0; i < xKeys.length; i++) {
// if (xKeys[i] !== yKeys[i] || !equals(x[xKeys[i]], y[yKeys[i]])) {
// return false;
// }
// }
// return true;
// }
function equals(x, y) {
if (x === y) {
return true;
} else if (x == null) {
return y == null;
} else if (y == null) {
return false;
} else if (typeof x !== "object") {
return false;
} else if (typeof x.Equals === "function") {
return x.Equals(y);
} else if (isArray(x)) {
return isArray(y) && equalArrays(x, y);
} else if (x instanceof Date) {
return y instanceof Date && compareDates(x, y) === 0;
} else {
return false;
}
}
function compareDates(x, y) {
let xtime;
let ytime; // DateTimeOffset and DateTime deals with equality differently.
if ("offset" in x && "offset" in y) {
xtime = x.getTime();
ytime = y.getTime();
} else {
xtime = x.getTime() + dateOffset(x);
ytime = y.getTime() + dateOffset(y);
}
return xtime === ytime ? 0 : xtime < ytime ? -1 : 1;
}
function comparePrimitives(x, y) {
return x === y ? 0 : x < y ? -1 : 1;
}
function compareArraysWith(x, y, comp) {
if (x == null) {
return y == null ? 0 : 1;
}
if (y == null) {
return -1;
}
if (x.length !== y.length) {
return x.length < y.length ? -1 : 1;
}
for (let i = 0, j = 0; i < x.length; i++) {
j = comp(x[i], y[i]);
if (j !== 0) {
return j;
}
}
return 0;
}
function compareArrays(x, y) {
return compareArraysWith(x, y, compare);
}
function compare(x, y) {
if (x === y) {
return 0;
} else if (x == null) {
return y == null ? 0 : -1;
} else if (y == null) {
return 1;
} else if (typeof x !== "object") {
return x < y ? -1 : 1;
} else if (typeof x.CompareTo === "function") {
return x.CompareTo(y);
} else if (isArray(x)) {
return isArray(y) && compareArrays(x, y);
} else if (x instanceof Date) {
return y instanceof Date && compareDates(x, y);
} else {
return 1;
}
}
// or Dictionaries so we need a runtime check (see #1120)
function count(col) {
if (isArray(col)) {
return col.length;
} else {
let count = 0;
for (const _ of col) {
count++;
}
return count;
}
}
const CURRIED_KEY = "__CURRIED__";
function partialApply(arity, f, args) {
if (f == null) {
return null;
} else if (CURRIED_KEY in f) {
f = f[CURRIED_KEY];
for (let i = 0; i < args.length; i++) {
f = f(args[i]);
}
return f;
} else {
switch (arity) {
case 1:
// Wrap arguments to make sure .concat doesn't destruct arrays. Example
// [1,2].concat([3,4],5) --> [1,2,3,4,5] // fails
// [1,2].concat([[3,4],5]) --> [1,2,[3,4],5] // ok
return a1 => f.apply(null, args.concat([a1]));
case 2:
return a1 => a2 => f.apply(null, args.concat([a1, a2]));
case 3:
return a1 => a2 => a3 => f.apply(null, args.concat([a1, a2, a3]));
case 4:
return a1 => a2 => a3 => a4 => f.apply(null, args.concat([a1, a2, a3, a4]));
case 5:
return a1 => a2 => a3 => a4 => a5 => f.apply(null, args.concat([a1, a2, a3, a4, a5]));
case 6:
return a1 => a2 => a3 => a4 => a5 => a6 => f.apply(null, args.concat([a1, a2, a3, a4, a5, a6]));
case 7:
return a1 => a2 => a3 => a4 => a5 => a6 => a7 => f.apply(null, args.concat([a1, a2, a3, a4, a5, a6, a7]));
case 8:
return a1 => a2 => a3 => a4 => a5 => a6 => a7 => a8 => f.apply(null, args.concat([a1, a2, a3, a4, a5, a6, a7, a8]));
default:
throw new Error("Partially applying to more than 8-arity is not supported: " + arity);
}
}
}
function addToDict(dict, k, v) {
if (dict.has(k)) {
throw new Error("An item with the same key has already been added. Key: " + k);
}
dict.set(k, v);
}
function getItemFromDict(map, key) {
if (map.has(key)) {
return map.get(key);
} else {
throw new Error(`The given key '${key}' was not present in the dictionary.`);
}
}
// https://github.com/MikeMcl/big.js/blob/01b3ce3a6b0ba7b42442ea48ec4ffc88d1669ec4/big.mjs
var P = {
GetHashCode() {
return combineHashCodes([this.s, this.e].concat(this.c));
},
Equals(x) {
return !this.cmp(x);
},
CompareTo(x) {
return this.cmp(x);
}
};
/*
* big.js v5.2.2
* A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
* Copyright (c) 2018 Michael Mclaughlin <M8ch88l@gmail.com>
* https://github.com/MikeMcl/big.js/LICENCE
*/
/************************************** EDITABLE DEFAULTS *****************************************/
// The default values below must be integers within the stated ranges.
/*
* The maximum number of decimal places (DP) of the results of operations involving division:
* div and sqrt, and pow with negative exponents.
*/
var DP = 28,
// 0 to MAX_DP
/*
* The rounding mode (RM) used when rounding to the above decimal places.
*
* 0 Towards zero (i.e. truncate, no rounding). (ROUND_DOWN)
* 1 To nearest neighbour. If equidistant, round up. (ROUND_HALF_UP)
* 2 To nearest neighbour. If equidistant, to even. (ROUND_HALF_EVEN)
* 3 Away from zero. (ROUND_UP)
*/
RM = 1,
// 0, 1, 2 or 3
// The maximum value of DP and Big.DP.
MAX_DP = 1E6,
// 0 to 1000000
// The maximum magnitude of the exponent argument to the pow method.
MAX_POWER = 1E6,
// 1 to 1000000
/*
* The negative exponent (NE) at and beneath which toString returns exponential notation.
* (JavaScript numbers: -7)
* -1000000 is the minimum recommended exponent value of a Big.
*/
NE = -29,
// 0 to -1000000
/*
* The positive exponent (PE) at and above which toString returns exponential notation.
* (JavaScript numbers: 21)
* 1000000 is the maximum recommended exponent value of a Big.
* (This limit is not enforced or checked.)
*/
PE = 29,
// 0 to 1000000
/**************************************************************************************************/
// Error messages.
NAME = "[big.js] ",
INVALID = NAME + "Invalid ",
INVALID_DP = INVALID + "decimal places",
INVALID_RM = INVALID + "rounding mode",
DIV_BY_ZERO = NAME + "Division by zero",
UNDEFINED = void 0,
NUMERIC = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
/*
* Create and return a Big constructor.
*
*/
function _Big_() {
/*
* The Big constructor and exported function.
* Create and return a new instance of a Big number object.
*
* n {number|string|Big} A numeric value.
*/
function Big(n) {
var x = this; // Enable constructor usage without new.
if (!(x instanceof Big)) return n === UNDEFINED ? _Big_() : new Big(n); // Duplicate.
if (n instanceof Big) {
x.s = n.s;
x.e = n.e;
x.c = n.c.slice();
normalize(x);
} else {
parse(x, n);
}
/*
* Retain a reference to this Big constructor, and shadow Big.prototype.constructor which
* points to Object.
*/
x.constructor = Big;
}
Big.prototype = P;
Big.DP = DP;
Big.RM = RM;
Big.NE = NE;
Big.PE = PE;
Big.version = "5.2.2";
return Big;
}
function normalize(x) {
x = round(x, DP, 0);
if (x.c.length > 1 && !x.c[0]) {
let i = x.c.findIndex(x => x);
x.c = x.c.slice(i);
x.e = x.e - i;
}
}
/*
* Parse the number or string value passed to a Big constructor.
*
* x {Big} A Big number instance.
* n {number|string} A numeric value.
*/
function parse(x, n) {
var e, i, nl; // Minus zero?
if (n === 0 && 1 / n < 0) n = "-0";else if (!NUMERIC.test(n += "")) throw Error(INVALID + "number"); // Determine sign.
x.s = n.charAt(0) == "-" ? (n = n.slice(1), -1) : 1; // Decimal point?
if ((e = n.indexOf(".")) > -1) n = n.replace(".", ""); // Exponential form?
if ((i = n.search(/e/i)) > 0) {
// Determine exponent.
if (e < 0) e = i;
e += +n.slice(i + 1);
n = n.substring(0, i);
} else if (e < 0) {
// Integer.
e = n.length;
}
nl = n.length; // Determine leading zeros before decimal point.
for (i = 0; i < e && i < nl && n.charAt(i) == "0";) ++i; // older version (ignores decimal point).
// // Determine leading zeros.
// for (i = 0; i < nl && n.charAt(i) == '0';) ++i;
if (i == nl) {
// Zero.
x.c = [x.e = 0];
} else {
x.e = e - i - 1;
x.c = []; // Convert string to array of digits without leading zeros
for (e = 0; i < nl;) x.c[e++] = +n.charAt(i++); // older version (doesn't keep trailing zeroes).
// // Determine trailing zeros.
// for (; nl > 0 && n.charAt(--nl) == '0';);
// // Convert string to array of digits without leading/trailing zeros.
// for (e = 0; i <= nl;) x.c[e++] = +n.charAt(i++);
}
x = round(x, Big.DP, Big.RM);
return x;
}
/*
* Round Big x to a maximum of dp decimal places using rounding mode rm.
* Called by stringify, P.div, P.round and P.sqrt.
*
* x {Big} The Big to round.
* dp {number} Integer, 0 to MAX_DP inclusive.
* rm {number} 0, 1, 2 or 3 (DOWN, HALF_UP, HALF_EVEN, UP)
* [more] {boolean} Whether the result of division was truncated.
*/
function round(x, dp, rm, more) {
var xc = x.c,
i = x.e + dp + 1;
if (i < xc.length) {
if (rm === 1) {
// xc[i] is the digit after the digit that may be rounded up.
more = xc[i] >= 5;
} else if (rm === 2) {
more = xc[i] > 5 || xc[i] == 5 && (more || i < 0 || xc[i + 1] !== UNDEFINED || xc[i - 1] & 1);
} else if (rm === 3) {
more = more || !!xc[0];
} else {
more = false;
if (rm !== 0) throw Error(INVALID_RM);
}
if (i < 1) {
xc.length = 1;
if (more) {
// 1, 0.1, 0.01, 0.001, 0.0001 etc.
x.e = -dp;
xc[0] = 1;
} else {
// Zero.
xc[0] = x.e = 0;
}
} else {
// Remove any digits after the required decimal places.
xc.length = i--; // Round up?
if (more) {
// Rounding up may mean the previous digit has to be rounded up.
for (; ++xc[i] > 9;) {
xc[i] = 0;
if (!i--) {
++x.e;
xc.unshift(1);
}
}
} // Remove trailing zeros.
for (i = xc.length; !xc[--i];) xc.pop();
}
} else if (rm < 0 || rm > 3 || rm !== ~~rm) {
throw Error(INVALID_RM);
}
return x;
}
/*
* Return a string representing the value of Big x in normal or exponential notation.
* Handles P.toExponential, P.toFixed, P.toJSON, P.toPrecision, P.toString and P.valueOf.
*
* x {Big}
* id? {number} Caller id.
* 1 toExponential
* 2 toFixed
* 3 toPrecision
* 4 valueOf
* n? {number|undefined} Caller's argument.
* k? {number|undefined}
*/
function stringify(x, id, n, k) {
var e,
s,
Big = x.constructor,
z = !x.c[0];
if (n !== UNDEFINED) {
if (n !== ~~n || n < (id == 3) || n > MAX_DP) {
throw Error(id == 3 ? INVALID + "precision" : INVALID_DP);
}
x = new Big(x); // The index of the digit that may be rounded up.
n = k - x.e; // Round?
if (x.c.length > ++k) round(x, n, Big.RM); // toFixed: recalculate k as x.e may have changed if value rounded up.
if (id == 2) k = x.e + n + 1; // Append zeros?
for (; x.c.length < k;) x.c.push(0);
}
e = x.e;
s = x.c.join("");
n = s.length; // Exponential notation?
if (id != 2 && (id == 1 || id == 3 && k <= e || e <= Big.NE || e >= Big.PE)) {
s = s.charAt(0) + (n > 1 ? "." + s.slice(1) : "") + (e < 0 ? "e" : "e+") + e; // Normal notation.
} else if (e < 0) {
for (; ++e;) s = "0" + s;
s = "0." + s;
} else if (e > 0) {
if (++e > n) for (e -= n; e--;) s += "0";else if (e < n) s = s.slice(0, e) + "." + s.slice(e);
} else if (n > 1) {
s = s.charAt(0) + "." + s.slice(1);
}
return x.s < 0 && (!z || id == 4) ? "-" + s : s;
} // Prototype/instance methods
/*
* Return a new Big whose value is the absolute value of this Big.
*/
P.abs = function () {
var x = new this.constructor(this);
x.s = 1;
return x;
};
/*
* Return 1 if the value of this Big is greater than the value of Big y,
* -1 if the value of this Big is less than the value of Big y, or
* 0 if they have the same value.
*/
P.cmp = function (y) {
var isneg,
Big = this.constructor,
x = new Big(this),
y = new Big(y),
xc = x.c,
yc = y.c,
i = x.s,
j = y.s,
k = x.e,
l = y.e; // Either zero?
if (!xc[0] || !yc[0]) return !xc[0] ? !yc[0] ? 0 : -j : i; // Signs differ?
if (i != j) return i;
isneg = i < 0; // Compare exponents.
if (k != l) return k > l ^ isneg ? 1 : -1; // Compare digit by digit.
j = Math.max(xc.length, yc.length);
for (i = 0; i < j; i++) {
k = i < xc.length ? xc[i] : 0;
l = i < yc.length ? yc[i] : 0;
if (k != l) return k > l ^ isneg ? 1 : -1;
}
return 0; // old version (doesn't compare well trailing zeroes, e.g. 1.0 with 1.00)
// j = (k = xc.length) < (l = yc.length) ? k : l;
// // Compare digit by digit.
// for (i = -1; ++i < j;) {
// if (xc[i] != yc[i]) return xc[i] > yc[i] ^ isneg ? 1 : -1;
// }
// // Compare lengths.
// return k == l ? 0 : k > l ^ isneg ? 1 : -1;
};
/*
* Return a new Big whose value is the value of this Big divided by the value of Big y, rounded,
* if necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM.
*/
P.div = function (y) {
var Big = this.constructor,
x = new Big(this),
y = new Big(y),
a = x.c,
// dividend
b = y.c,
// divisor
k = x.s == y.s ? 1 : -1,
dp = Big.DP;
if (dp !== ~~dp || dp < 0 || dp > MAX_DP) throw Error(INVALID_DP); // Divisor is zero?
if (!b[0]) throw Error(DIV_BY_ZERO); // Dividend is 0? Return +-0.
if (!a[0]) return new Big(k * 0);
var bl,
bt,
n,
cmp,
ri,
bz = b.slice(),
ai = bl = b.length,
al = a.length,
r = a.slice(0, bl),
// remainder
rl = r.length,
q = y,
// quotient
qc = q.c = [],
qi = 0,
d = dp + (q.e = x.e - y.e) + 1; // number of digits of the result
q.s = k;
k = d < 0 ? 0 : d; // Create version of divisor with leading zero.
bz.unshift(0); // Add zeros to make remainder as long as divisor.
for (; rl++ < bl;) r.push(0);
do {
// n is how many times the divisor goes into current remainder.
for (n = 0; n < 10; n++) {
// Compare divisor and remainder.
if (bl != (rl = r.length)) {
cmp = bl > rl ? 1 : -1;
} else {
for (ri = -1, cmp = 0; ++ri < bl;) {
if (b[ri] != r[ri]) {
cmp = b[ri] > r[ri] ? 1 : -1;
break;
}
}
} // If divisor < remainder, subtract divisor from remainder.
if (cmp < 0) {
// Remainder can't be more than 1 digit longer than divisor.
// Equalise lengths using divisor with extra leading zero?
for (bt = rl == bl ? b : bz; rl;) {
if (r[--rl] < bt[rl]) {
ri = rl;
for (; ri && !r[--ri];) r[ri] = 9;
--r[ri];
r[rl] += 10;
}
r[rl] -= bt[rl];
}
for (; !r[0];) r.shift();
} else {
break;
}
} // Add the digit n to the result array.
qc[qi++] = cmp ? n : ++n; // Update the remainder.
if (r[0] && cmp) r[rl] = a[ai] || 0;else r = [a[ai]];
} while ((ai++ < al || r[0] !== UNDEFINED) && k--); // Leading zero? Do not remove if result is simply zero (qi == 1).
if (!qc[0] && qi != 1) {
// There can't be more than one zero.
qc.shift();
q.e--;
} // Round?
if (qi > d) round(q, dp, Big.RM, r[0] !== UNDEFINED);
return q;
};
/*
* Return true if the value of this Big is equal to the value of Big y, otherwise return false.
*/
P.eq = function (y) {
return !this.cmp(y);
};
/*
* Return true if the value of this Big is greater than the value of Big y, otherwise return
* false.
*/
P.gt = function (y) {
return this.cmp(y) > 0;
};
/*
* Return true if the value of this Big is greater than or equal to the value of Big y, otherwise
* return false.
*/
P.gte = function (y) {
return this.cmp(y) > -1;
};
/*
* Return true if the value of this Big is less than the value of Big y, otherwise return false.
*/
P.lt = function (y) {
return this.cmp(y) < 0;
};
/*
* Return true if the value of this Big is less than or equal to the value of Big y, otherwise
* return false.
*/
P.lte = function (y) {
return this.cmp(y) < 1;
};
/*
* Return a new Big whose value is the value of this Big minus the value of Big y.
*/
P.minus = P.sub = function (y) {
var i,
j,
t,
xlty,
Big = this.constructor,
x = new Big(this),
y = new Big(y),
a = x.s,
b = y.s; // Signs differ?
if (a != b) {
y.s = -b;
return x.plus(y);
}
var xc = x.c.slice(),
xe = x.e,
yc = y.c,
ye = y.e; // Either zero?
if (!xc[0] || !yc[0]) {
// y is non-zero? x is non-zero? Or both are zero.
return yc[0] ? (y.s = -b, y) : new Big(xc[0] ? x : 0);
} // Determine which is the bigger number. Prepend zeros to equalise exponents.
if (a = xe - ye) {
if (xlty = a < 0) {
a = -a;
t = xc;
} else {
ye = xe;
t = yc;
}
t.reverse();
for (b = a; b--;) t.push(0);
t.reverse();
} else {
// Exponents equal. Check digit by digit.
j = ((xlty = xc.length < yc.length) ? xc : yc).length;
for (a = b = 0; b < j; b++) {
if (xc[b] != yc[b]) {
xlty = xc[b] < yc[b];
break;
}
}
} // x < y? Point xc to the array of the bigger number.
if (xlty) {
t = xc;
xc = yc;
yc = t;
y.s = -y.s;
}
/*
* Append zeros to xc if shorter. No need to add zeros to yc if shorter as subtraction only
* needs to start at yc.length.
*/
if ((b = (j = yc.length) - (i = xc.length)) > 0) for (; b--;) xc[i++] = 0; // Subtract yc from xc.
for (b = i; j > a;) {
if (xc[--j] < yc[j]) {
for (i = j; i && !xc[--i];) xc[i] = 9;
--xc[i];
xc[j] += 10;
}
xc[j] -= yc[j];
} // Remove trailing zeros.
for (; xc[--b] === 0;) xc.pop(); // Remove leading zeros and adjust exponent accordingly.
for (; xc[0] === 0;) {
xc.shift();
--ye;
}
if (!xc[0]) {
// n - n = +0
y.s = 1; // Result must be zero.
xc = [ye = 0];
}
y.c = xc;
y.e = ye;
return y;
};
/*
* Return a new Big whose value is the value of this Big modulo the value of Big y.
*/
P.mod = function (y) {
var ygtx,
Big = this.constructor,
x = new Big(this),
y = new Big(y),
a = x.s,
b = y.s;
if (!y.c[0]) throw Error(DIV_BY_ZERO);
x.s = y.s = 1;
ygtx = y.cmp(x) == 1;
x.s = a;
y.s = b;
if (ygtx) return new Big(x);
a = Big.DP;
b = Big.RM;
Big.DP = Big.RM = 0;
x = x.div(y);
Big.DP = a;
Big.RM = b;
return this.minus(x.times(y));
};
/*
* Return a new Big whose value is the value of this Big plus the value of Big y.
*/
P.plus = P.add = function (y) {
var t,
Big = this.constructor,
x = new Big(this),
y = new Big(y),
a = x.s,
b = y.s; // Signs differ?
if (a != b) {
y.s = -b;
return x.minus(y);
}
var xe = x.e,
xc = x.c,
ye = y.e,
yc = y.c; // Either zero? y is non-zero? x is non-zero? Or both are zero.
if (!xc[0] || !yc[0]) return yc[0] ? y : new Big(xc[0] ? x : a * 0);
xc = xc.slice(); // Prepend zeros to equalise exponents.
// Note: reverse faster than unshifts.
if (a = xe - ye) {
if (a > 0) {
ye = xe;
t = yc;
} else {
a = -a;
t = xc;
}
t.reverse();
for (; a--;) t.push(0);
t.reverse();
} // Point xc to the longer array.
if (xc.length - yc.length < 0) {
t = yc;
yc = xc;
xc = t;
}
a = yc.length; // Only start adding at yc.length - 1 as the further digits of xc can be left as they are.
for (b = 0; a; xc[a] %= 10) b = (xc[--a] = xc[a] + yc[a] + b) / 10 | 0; // No need to check for zero, as +x + +y != 0 && -x + -y != 0
if (b) {
xc.unshift(b);
++ye;
} // Remove trailing zeros.
for (a = xc.length; xc[--a] === 0;) xc.pop();
y.c = xc;
y.e = ye;
return y;
};
/*
* Return a Big whose value is the value of this Big raised to the power n.
* If n is negative, round to a maximum of Big.DP decimal places using rounding
* mode Big.RM.
*
* n {number} Integer, -MAX_POWER to MAX_POWER inclusive.
*/
P.pow = function (n) {
var Big = this.constructor,
x = new Big(this),
y = new Big(1),
one = new Big(1),
isneg = n < 0;
if (n !== ~~n || n < -MAX_POWER || n > MAX_POWER) throw Error(INVALID + "exponent");
if (isneg) n = -n;
for (;;) {
if (n & 1) y = y.times(x);
n >>= 1;
if (!n) break;
x = x.times(x);
}
return isneg ? one.div(y) : y;
};
/*
* Return a new Big whose value is the value of this Big rounded using rounding mode rm
* to a maximum of dp decimal places, or, if dp is negative, to an integer which is a
* multiple of 10**-dp.
* If dp is not specified, round to 0 decimal places.
* If rm is not specified, use Big.RM.
*
* dp? {number} Integer, -MAX_DP to MAX_DP inclusive.
* rm? 0, 1, 2 or 3 (ROUND_DOWN, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_UP)
*/
P.round = function (dp, rm) {
var Big = this.constructor;
if (dp === UNDEFINED) dp = 0;else if (dp !== ~~dp || dp < -MAX_DP || dp > MAX_DP) throw Error(INVALID_DP);
return round(new Big(this), dp, rm === UNDEFINED ? Big.RM : rm);
};
/*
* Return a new Big whose value is the square root of the value of this Big, rounded, if
* necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM.
*/
P.sqrt = function () {
var r,
c,
t,
Big = this.constructor,
x = new Big(this),
s = x.s,
e = x.e,
half = new Big(0.5); // Zero?
if (!x.c[0]) return new Big(x); // Negative?
if (s < 0) throw Error(NAME + "No square root"); // Estimate.
s = Math.sqrt(x + ""); // Math.sqrt underflow/overflow?
// Re-estimate: pass x coefficient to Math.sqrt as integer, then adjust the result exponent.
if (s === 0 || s === 1 / 0) {
c = x.c.join("");
if (!(c.length + e & 1)) c += "0";
s = Math.sqrt(c);
e = ((e + 1) / 2 | 0) - (e < 0 || e & 1);
r = new Big((s == 1 / 0 ? "1e" : (s = s.toExponential()).slice(0, s.indexOf("e") + 1)) + e);
} else {
r = new Big(s);
}
e = r.e + (Big.DP += 4); // Newton-Raphson iteration.
do {
t = r;
r = half.times(t.plus(x.div(t)));
} while (t.c.slice(0, e).join("") !== r.c.slice(0, e).join(""));
return round(r, Big.DP -= 4, Big.RM);
};
/*
* Return a new Big whose value is the value of this Big times the value of Big y.
*/
P.times = P.mul = function (y) {
var c,
Big = this.constructor,
x = new Big(this),
y = new Big(y),
xc = x.c,
yc = y.c,
a = xc.length,
b = yc.length,
i = x.e,
j = y.e; // Determine sign of result.
y.s = x.s == y.s ? 1 : -1; // Return signed 0 if either 0.
if (!xc[0] || !yc[0]) return new Big(y.s * 0); // Initialise exponent of result as x.e + y.e.
y.e = i + j; // If array xc has fewer digits than yc, swap xc and yc, and lengths.
if (a < b) {
c = xc;
xc = yc;
yc = c;
j = a;
a = b;
b = j;
} // Initialise coefficient array of result with zeros.
for (c = new Array(j = a + b); j--;) c[j] = 0; // Multiply.
// i is initially xc.length.
for (i = b; i--;) {
b = 0; // a is yc.length.
for (j = a + i; j > i;) {
// Current sum of products at this digit position, plus carry.
b = c[j] + yc[i] * xc[j - i - 1] + b;
c[j--] = b % 10; // carry
b = b / 10 | 0;
}
c[j] = (c[j] + b) % 10;
} // Increment result exponent if there is a final carry, otherwise remove leading zero.
if (b) ++y.e;else c.shift(); // Remove trailing zeros.
for (i = c.length; !c[--i];) c.pop();
y.c = c;
return y;
};
/*
* Return a string representing the value of this Big in exponential notation to dp fixed decimal
* places and rounded using Big.RM.
*
* dp? {number} Integer, 0 to MAX_DP inclusive.
*/
P.toExponential = function (dp) {
return stringify(this, 1, dp, dp);
};
/*
* Return a string representing the value of this Big in normal notation to dp fixed decimal
* places and rounded using Big.RM.
*
* dp? {number} Integer, 0 to MAX_DP inclusive.
*
* (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'.
* (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.
*/
P.toFixed = function (dp) {
return stringify(this, 2, dp, this.e + dp);
};
/*
* Return a string representing the value of this Big rounded to sd significant digits using
* Big.RM. Use exponential notation if sd is less than the number of digits necessary to represent
* the integer part of the value in normal notation.
*
* sd {number} Integer, 1 to MAX_DP inclusive.
*/
P.toPrecision = function (sd) {
return stringify(this, 3, sd, sd - 1);
};
/*
* Return a string representing the value of this Big.
* Return exponential notation if this Big has a positive exponent equal to or greater than
* Big.PE, or a negative exponent equal to or less than Big.NE.
* Omit the sign for negative zero.
*/
P.toString = function () {
return stringify(this);
};
/*
* Return a string representing the value of this Big.
* Return exponential notation if this Big has a positive exponent equal to or greater than
* Big.PE, or a negative exponent equal to or less than Big.NE.
* Include the sign for negative zero.
*/
P.valueOf = P.toJSON = function () {
return stringify(this, 4);
}; // Export
var Big = _Big_();
const get_Zero = new Big(0);
const get_One = new Big(1);
const get_MinusOne = new Big(-1);
const get_MaxValue = new Big("79228162514264337593543950335");
const get_MinValue = new Big("-79228162514264337593543950335");
var NumberStyles;
(function (NumberStyles) {
// None = 0x00000000,
// AllowLeadingWhite = 0x00000001,
// AllowTrailingWhite = 0x00000002,
// AllowLeadingSign = 0x00000004,
// AllowTrailingSign = 0x00000008,
// AllowParentheses = 0x00000010,
// AllowDecimalPoint = 0x00000020,
// AllowThousands = 0x00000040,
// AllowExponent = 0x00000080,
// AllowCurrencySymbol = 0x00000100,
NumberStyles[NumberStyles["AllowHexSpecifier"] = 512] = "AllowHexSpecifier"; // Integer = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign,
// HexNumber = AllowLeadingWhite | AllowTrailingWhite | AllowHexSpecifier,
// Number = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign |
// AllowTrailingSign | AllowDecimalPoint | AllowThousands,
// Float = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign |
// AllowDecimalPoint | AllowExponent,
// Currency = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | AllowTrailingSign |
// AllowParentheses | AllowDecimalPoint | AllowThousands | AllowCurrencySymbol,
// Any = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | AllowTrailingSign |
// AllowParentheses | AllowDecimalPoint | AllowThousands | AllowCurrencySymbol | AllowExponent,
})(NumberStyles || (NumberStyles = {}));
function validResponse(regexMatch, radix) {
const [_all, sign, prefix, digits] = regexMatch;
return {
sign: sign || "",
prefix: prefix || "",
digits,
radix
};
}
function getRange(unsigned, bitsize) {
switch (bitsize) {
case 8:
return unsigned ? [0, 255] : [-128, 127];
case 16:
return unsigned ? [0, 65535] : [-32768, 32767];
case 32:
return unsigned ? [0, 4294967295] : [-2147483648, 2147483647];
default:
throw new Error("Invalid bit size.");
}
}
function getInvalidDigits(radix) {
switch (radix) {
case 2:
return /[^0-1]/;
case 8:
return /[^0-7]/;
case 10:
return /[^0-9]/;
case 16:
return /[^0-9a-fA-F]/;
default:
throw new Error("Invalid Base.");
}
}
function getRadix(prefix, style) {
if (style & NumberStyles.AllowHexSpecifier) {
return 16;
} else {
switch (prefix) {
case "0b":
case "0B":
return 2;
case "0o":
case "0O":
return 8;
case "0x":
case "0X":
return 16;
default:
return 10;
}
}
}
function isValid(str, style, radix) {
const integerRegex = /^\s*([\+\-])?(0[xXoObB])?([0-9a-fA-F]+)\s*$/;
const res = integerRegex.exec(str.replace(/_/g, ""));
if (res != null) {
const [_all, sign, prefix, digits] = res;
radix = radix || getRadix(prefix, style);
const invalidDigits = getInvalidDigits(radix);
if (!invalidDigits.test(digits)) {
return validResponse(res, radix);
}
}
return null;
}
function parse$1(str, style, unsigned, bitsize, radix) {
const res = isValid(str, style, radix);
if (res != null) {
let v = Number.parseInt(res.sign + res.digits, res.radix);
if (!Number.isNaN(v)) {
const [umin, umax] = getRange(true, bitsize);
if (!unsigned && res.radix !== 10 && v >= umin && v <= umax) {
v = v << 32 - bitsize >> 32 - bitsize;
}
const [min, max] = getRange(unsigned, bitsize);
if (v >= min && v <= max) {
return v;
}
}
}
throw new Error("Input string was not in a correct format.");
}
function tryParse(str, style, unsigned, bitsize) {
try {
const v = parse$1(str, style, unsigned, bitsize);
return [true, v];
} catch (_a) {// supress error
}
return [false, 0];
}
// Adapted from: https://github.com/dcodeIO/long.js/blob/master/src/long.js
/**
* wasm optimizations, to do native i64 multiplication and divide
*/
var wasm = null;
try {
wasm = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports;
} catch (e) {} // no wasm support :(
/**
* Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
* See the from* functions below for more convenient ways of constructing Longs.
* @exports Long
* @class A Long class for representing a 64 bit two's-complement integer value.
* @param {number} low The low (signed) 32 bits of the long
* @param {number} high The high (signed) 32 bits of the long
* @param {boolean=} unsigned Whether unsigned or not, defaults to signed
* @constructor
*/
function Long(low, high, unsigned) {
/**
* The low 32 bits as a signed value.
* @type {number}
*/
this.low = low | 0;
/**
* The high 32 bits as a signed value.
* @type {number}
*/
this.high = high | 0;
/**
* Whether unsigned or not.
* @type {boolean}
*/
this.unsigned = !!unsigned;
}
Long.prototype.GetHashCode = function () {
let h1 = this.unsigned ? 1 : 0;
h1 = (h1 << 5) + h1 ^ this.high;
h1 = (h1 << 5) + h1 ^ this.low;
return h1;
};
Long.prototype.Equals = function (x) {
return equals$1(this, x);
};
Long.prototype.CompareTo = function (x) {
return compare$1(this, x);
};
Long.prototype.toString = function (radix) {
return toString(this, radix);
};
Long.prototype.toJSON = function () {
return toString(this);
}; // The internal representation of a long is the two given signed, 32-bit values.
Object.defineProperty(Long.prototype, "__isLong__", {
value: true
});
/**
* @function
* @param {*} obj Object
* @returns {boolean}
* @inner
*/
function isLong(obj) {
return (obj && obj["__isLong__"]) === true;
}
/**
* Tests if the specified object is a Long.
* @function
* @param {*} obj Object
* @returns {boolean}
*/
// Long.isLong = isLong;
/**
* A cache of the Long representations of small integer values.
* @type {!Object}
* @inner
*/
var INT_CACHE = {};
/**
* A cache of the Long representations of small unsigned integer values.
* @type {!Object}
* @inner
*/
var UINT_CACHE = {};
/**
* @param {number} value
* @param {boolean=} unsigned
* @returns {!Long}
* @inner
*/
function fromInt(value, unsigned) {
var obj, cachedObj, cache;
if (unsigned) {
value >>>= 0;
if (cache = 0 <= value && value < 256) {
cachedObj = UINT_CACHE[value];
if (cachedObj) return cachedObj;
}
obj = fromBits(value, (value | 0) < 0 ? -1 : 0, true);
if (cache) UINT_CACHE[value] = obj;
return obj;
} else {
value |= 0;
if (cache = -128 <= value && value < 128) {
cachedObj = INT_CACHE[value];
if (cachedObj) return cachedObj;
}
obj = fromBits(value, value < 0 ? -1 : 0, false);
if (cache) INT_CACHE[value] = obj;
return obj;
}
}
/**
* Returns a Long representing the given 32 bit integer value.
* @function
* @param {number} value The 32 bit integer in question
* @param {boolean=} unsigned Whether unsigned or not, defaults to signed
* @returns {!Long} The corresponding Long value
*/
// Long.fromInt = fromInt;
/**
* @param {number} value
* @param {boolean=} unsigned
* @returns {!Long}
* @inner
*/
function fromNumber(value, unsigned) {
if (isNaN(value)) return unsigned ? UZERO : ZERO;
if (unsigned) {
if (value < 0) return UZERO;
if (value >= TWO_PWR_64_DBL) return MAX_UNSIGNED_VALUE;
} else {
if (value <= -TWO_PWR_63_DBL) return MIN_VALUE;
if (value + 1 >= TWO_PWR_63_DBL) return MAX_VALUE;
}
if (value < 0) return negate(fromNumber(-value, unsigned));
return fromBits(value % TWO_PWR_32_DBL | 0, value / TWO_PWR_32_DBL | 0, unsigned);
}
/**
* Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
* @function
* @param {number} value The number in question
* @param {boolean=} unsigned Whether unsigned or not, defaults to signed
* @returns {!Long} The corresponding Long value
*/
// Long.fromNumber = fromNumber;
/**
* @param {number} lowBits
* @param {number} highBits
* @param {boolean=} unsigned
* @returns {!Long}
* @inner
*/
function fromBits(lowBits, highBits, unsigned) {
return new Long(lowBits, highBits, unsigned);
}
/**
* Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is
* assumed to use 32 bits.
* @function
* @param {number} lowBits The low 32 bits
* @param {number} highBits The high 32 bits
* @param {boolean=} unsigned Whether unsigned or not, defaults to signed
* @returns {!Long} The corresponding Long value
*/
// Long.fromBits = fromBits;
/**
* @function
* @param {number} base
* @param {number} exponent
* @returns {number}
* @inner
*/
var pow_dbl = Math.pow; // Used 4 times (4*8 to 15+4)
/**
* @param {string} str
* @param {(boolean|number)=} unsigned
* @param {number=} radix
* @returns {!Long}
* @inner
*/
function fromString(str, unsigned, radix) {
if (str.length === 0) throw Error("empty string");
if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity") return ZERO;
if (typeof unsigned === "number") {
// For goog.math.long compatibility
radix = unsigned, unsigned = false;
} else {
unsigned = !!unsigned;
}
radix = radix || 10;
if (radix < 2 || 36 < radix) throw RangeError("radix");
var p = str.indexOf("-");
if (p > 0) throw Error("interior hyphen");else if (p === 0) {
return negate(fromString(str.substring(1), unsigned, radix));
} // Do several (8) digits each time through the loop, so as to
// minimize the calls to the very expensive emulated div.
var radixToPower = fromNumber(pow_dbl(radix, 8));
var result = ZERO;
for (var i = 0; i < str.length; i += 8) {
var size = Math.min(8, str.length - i),
value = parseInt(str.substring(i, i + size), radix);
if (size < 8) {
var power = fromNumber(pow_dbl(radix, size));
result = add(multiply(result, power), fromNumber(value));
} else {
result = multiply(result, radixToPower);
result = add(result, fromNumber(value));
}
}
result.unsigned = unsigned;
return result;
}
/**
* Returns a Long representation of the given string, written using the specified radix.
* @function
* @param {string} str The textual representation of the Long
* @param {(boolean|number)=} unsigned Whether unsigned or not, defaults to signed
* @param {number=} radix The radix in which the text is written (2-36), defaults to 10
* @returns {!Long} The corresponding Long value
*/
// Long.fromString = fromString;
/**
* @function
* @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val
* @param {boolean=} unsigned
* @returns {!Long}
* @inner
*/
function fromValue(val, unsigned) {
if (typeof val === "number") return fromNumber(val, unsigned);
if (typeof val === "string") return fromString(val, unsigned); // Throws for non-objects, converts non-instanceof Long:
return fromBits(val.low, val.high, typeof unsigned === "boolean" ? unsigned : val.unsigned);
}
/**
* Converts the specified value to a Long using the appropriate from* function for its type.
* @function
* @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val Value
* @param {boolean=} unsigned Whether unsigned or not, defaults to signed
* @returns {!Long}
*/
// Long.fromValue = fromValue;
// NOTE: the compiler should inline these constant values below and then remove these variables, so there should be
// no runtime penalty for these.
/**
* @type {number}
* @const
* @inner
*/
var TWO_PWR_16_DBL = 1 << 16;
/**
* @type {number}
* @const
* @inner
*/
var TWO_PWR_24_DBL = 1 << 24;
/**
* @type {number}
* @const
* @inner
*/
var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
/**
* @type {number}
* @const
* @inner
*/
var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
/**
* @type {number}
* @const
* @inner
*/
var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;
/**
* @type {!Long}
* @const
* @inner
*/
var TWO_PWR_24 = fromInt(TWO_PWR_24_DBL);
/**
* @type {!Long}
* @inner
*/
var ZERO = fromInt(0);
/**
* Signed zero.
* @type {!Long}
*/
// Long.ZERO = ZERO;
/**
* @type {!Long}
* @inner
*/
var UZERO = fromInt(0, true);
/**
* Unsigned zero.
* @type {!Long}
*/
// Long.UZERO = UZERO;
/**
* @type {!Long}
* @inner
*/
var ONE = fromInt(1);
/**
* Signed one.
* @type {!Long}
*/
// Long.ONE = ONE;
/**
* @type {!Long}
* @inner
*/
var UONE = fromInt(1, true);
/**
* Unsigned one.
* @type {!Long}
*/
// Long.UONE = UONE;
/**
* @type {!Long}
* @inner
*/
var NEG_ONE = fromInt(-1);
/**
* Signed negative one.
* @type {!Long}
*/
// Long.NEG_ONE = NEG_ONE;
/**
* @type {!Long}
* @inner
*/
var MAX_VALUE = fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0, false);
/**
* Maximum signed value.
* @type {!Long}
*/
// Long.MAX_VALUE = MAX_VALUE;
/**
* @type {!Long}
* @inner
*/
var MAX_UNSIGNED_VALUE = fromBits(0xFFFFFFFF | 0, 0xFFFFFFFF | 0, true);
/**
* Maximum unsigned value.
* @type {!Long}
*/
// Long.MAX_UNSIGNED_VALUE = MAX_UNSIGNED_VALUE;
/**
* @type {!Long}
* @inner
*/
var MIN_VALUE = fromBits(0, 0x80000000 | 0, false);
/**
* Minimum signed value.
* @type {!Long}
*/
// Long.MIN_VALUE = MIN_VALUE;
/**
* @alias Long.prototype
* @inner
*/
// var LongPrototype = Long.prototype;
/**
* Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
* @this {!Long}
* @returns {number}
*/
function toInt($this) {
return $this.unsigned ? $this.low >>> 0 : $this.low;
}
/**
* Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
* @this {!Long}
* @returns {number}
*/
function toNumber($this) {
if ($this.unsigned) return ($this.high >>> 0) * TWO_PWR_32_DBL + ($this.low >>> 0);
return $this.high * TWO_PWR_32_DBL + ($this.low >>> 0);
}
/**
* Converts the Long to a string written in the specified radix.
* @this {!Long}
* @param {number=} radix Radix (2-36), defaults to 10
* @returns {string}
* @override
* @throws {RangeError} If `radix` is out of range
*/
function toString($this, radix) {
radix = radix || 10;
if (radix < 2 || 36 < radix) throw RangeError("radix");
if (isZero($this)) return "0";
if (isNegative($this)) {
// Unsigned Longs are never negative
if (equals$1($this, MIN_VALUE)) {
// We need to change the Long value before it can be negated, so we remove
// the bottom-most digit in this base and then recurse to do the rest.
var radixLong = fromNumber(radix),
div = divide($this, radixLong),
rem1 = subtract(multiply(div, radixLong), $this);
return toString(div, radix) + toInt(rem1).toString(radix);
} else return "-" + toString(negate($this), radix);
} // Do several (6) digits each time through the loop, so as to
// minimize the calls to the very expensive emulated div.
var radixToPower = fromNumber(pow_dbl(radix, 6), $this.unsigned),
rem = $this;
var result = "";
while (true) {
var remDiv = divide(rem, radixToPower),
intval = toInt(subtract(rem, multiply(remDiv, radixToPower))) >>> 0,
digits = intval.toString(radix);
rem = remDiv;
if (isZero(rem)) return digits + result;else {
while (digits.length < 6) digits = "0" + digits;
result = "" + digits + result;
}
}
}
/**
* Tests if this Long's value equals zero.
* @this {!Long}
* @returns {boolean}
*/
function isZero($this) {
return $this.high === 0 && $this.low === 0;
}
/**
* Tests if this Long's value equals zero. This is an alias of {@link Long#isZero}.
* @returns {boolean}
*/
// LongPrototype.eqz = LongPrototype.isZero;
/**
* Tests if this Long's value is negative.
* @this {!Long}
* @returns {boolean}
*/
function isNegative($this) {
return !$this.unsigned && $this.high < 0;
}
/**
* Tests if this Long's value is odd.
* @this {!Long}
* @returns {boolean}
*/
function isOdd($this) {
return ($this.low & 1) === 1;
}
/**
* Tests if this Long's value equals the specified's.
* @this {!Long}
* @param {!Long|number|string} other Other value
* @returns {boolean}
*/
function equals$1($this, other) {
if (!isLong(other)) other = fromValue(other);
if ($this.unsigned !== other.unsigned && $this.high >>> 31 === 1 && other.high >>> 31 === 1) return false;
return $this.high === other.high && $this.low === other.low;
}
/**
* Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.
* @function
* @param {!Long|number|string} other Other value
* @returns {boolean}
*/
// LongPrototype.neq = LongPrototype.notEquals;
/**
* Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.
* @function
* @param {!Long|number|string} other Other value
* @returns {boolean}
*/
// LongPrototype.ne = LongPrototype.notEquals;
/**
* Tests if this Long's value is less than the specified's.
* @this {!Long}
* @param {!Long|number|string} other Other value
* @returns {boolean}
*/
function lessThan($this, other) {
return compare$1($this,
/* validates */
other) < 0;
}
/**
* Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.
* @function
* @param {!Long|number|string} other Other value
* @returns {boolean}
*/
// LongPrototype.lte = LongPrototype.lessThanOrEqual;
/**
* Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.
* @function
* @param {!Long|number|string} other Other value
* @returns {boolean}
*/
// LongPrototype.le = LongPrototype.lessThanOrEqual;
/**
* Tests if this Long's value is greater than the specified's.
* @this {!Long}
* @param {!Long|number|string} other Other value
* @returns {boolean}
*/
function greaterThan($this, other) {
return compare$1($this,
/* validates */
other) > 0;
}
/**
* Tests if this Long's value is greater than the specified's. This is an alias of {@link Long#greaterThan}.
* @function
* @param {!Long|number|string} other Other value
* @returns {boolean}
*/
// LongPrototype.gt = LongPrototype.greaterThan;
/**
* Tests if this Long's value is greater than or equal the specified's.
* @this {!Long}
* @param {!Long|number|string} other Other value
* @returns {boolean}
*/
function greaterThanOrEqual($this, other) {
return compare$1($this,
/* validates */
other) >= 0;
}
/**
* Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.
* @function
* @param {!Long|number|string} other Other value
* @returns {boolean}
*/
// LongPrototype.gte = LongPrototype.greaterThanOrEqual;
/**
* Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.
* @function
* @param {!Long|number|string} other Other value
* @returns {boolean}
*/
// LongPrototype.ge = LongPrototype.greaterThanOrEqual;
/**
* Compares this Long's value with the specified's.
* @this {!Long}
* @param {!Long|number|string} other Other value
* @returns {number} 0 if they are the same, 1 if the this is greater and -1
* if the given one is greater
*/
function compare$1($this, other) {
if (!isLong(other)) other = fromValue(other);
if (equals$1($this, other)) return 0;
var thisNeg = isNegative($this),
otherNeg = isNegative(other);
if (thisNeg && !otherNeg) return -1;
if (!thisNeg && otherNeg) return 1; // At this point the sign bits are the same
if (!$this.unsigned) return isNegative(subtract($this, other)) ? -1 : 1; // Both are positive if at least one is unsigned
return other.high >>> 0 > $this.high >>> 0 || other.high === $this.high && other.low >>> 0 > $this.low >>> 0 ? -1 : 1;
}
/**
* Compares this Long's value with the specified's. This is an alias of {@link Long#compare}.
* @function
* @param {!Long|number|string} other Other value
* @returns {number} 0 if they are the same, 1 if the this is greater and -1
* if the given one is greater
*/
// LongPrototype.comp = LongPrototype.compare;
/**
* Negates this Long's value.
* @this {!Long}
* @returns {!Long} Negated Long
*/
function negate($this) {
if (!$this.unsigned && equals$1($this, MIN_VALUE)) return MIN_VALUE;
return add(not($this), ONE);
}
/**
* Negates this Long's value. This is an alias of {@link Long#negate}.
* @function
* @returns {!Long} Negated Long
*/
// LongPrototype.neg = LongPrototype.negate;
/**
* Returns the sum of this and the specified Long.
* @this {!Long}
* @param {!Long|number|string} addend Addend
* @returns {!Long} Sum
*/
function add($this, addend) {
if (!isLong(addend)) addend = fromValue(addend); // Divide each number into 4 chunks of 16 bits, and then sum the chunks.
var a48 = $this.high >>> 16;
var a32 = $this.high & 0xFFFF;
var a16 = $this.low >>> 16;
var a00 = $this.low & 0xFFFF;
var b48 = addend.high >>> 16;
var b32 = addend.high & 0xFFFF;
var b16 = addend.low >>> 16;
var b00 = addend.low & 0xFFFF;
var c48 = 0,
c32 = 0,
c16 = 0,
c00 = 0;
c00 += a00 + b00;
c16 += c00 >>> 16;
c00 &= 0xFFFF;
c16 += a16 + b16;
c32 += c16 >>> 16;
c16 &= 0xFFFF;
c32 += a32 + b32;
c48 += c32 >>> 16;
c32 &= 0xFFFF;
c48 += a48 + b48;
c48 &= 0xFFFF;
return fromBits(c16 << 16 | c00, c48 << 16 | c32, $this.unsigned);
}
/**
* Returns the difference of this and the specified Long.
* @this {!Long}
* @param {!Long|number|string} subtrahend Subtrahend
* @returns {!Long} Difference
*/
function subtract($this, subtrahend) {
if (!isLong(subtrahend)) subtrahend = fromValue(subtrahend);
return add($this, negate(subtrahend));
}
/**
* Returns the difference of this and the specified Long. This is an alias of {@link Long#subtract}.
* @function
* @param {!Long|number|string} subtrahend Subtrahend
* @returns {!Long} Difference
*/
// LongPrototype.sub = LongPrototype.subtract;
/**
* Returns the product of this and the specified Long.
* @this {!Long}
* @param {!Long|number|string} multiplier Multiplier
* @returns {!Long} Product
*/
function multiply($this, multiplier) {
if (isZero($this)) return $this.unsigned ? UZERO : ZERO;
if (!isLong(multiplier)) multiplier = fromValue(multiplier); // use wasm support if present
if (wasm) {
var low = wasm.mul($this.low, $this.high, multiplier.low, multiplier.high);
return fromBits(low, wasm.get_high(), $this.unsigned);
}
if (isZero(multiplier)) return $this.unsigned ? UZERO : ZERO;
if (equals$1($this, MIN_VALUE)) return isOdd(multiplier) ? MIN_VALUE : ZERO;
if (equals$1(multiplier, MIN_VALUE)) return isOdd($this) ? MIN_VALUE : ZERO;
if (isNegative($this)) {
if (isNegative(multiplier)) return multiply(negate($this), negate(multiplier));else return negate(multiply(negate($this), multiplier));
} else if (isNegative(multiplier)) return negate(multiply($this, negate(multiplier))); // If both longs are small, use float multiplication
if (lessThan($this, TWO_PWR_24) && lessThan(multiplier, TWO_PWR_24)) return fromNumber(toNumber($this) * toNumber(multiplier), $this.unsigned); // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products.
// We can skip products that would overflow.
var a48 = $this.high >>> 16;
var a32 = $this.high & 0xFFFF;
var a16 = $this.low >>> 16;
var a00 = $this.low & 0xFFFF;
var b48 = multiplier.high >>> 16;
var b32 = multiplier.high & 0xFFFF;
var b16 = multiplier.low >>> 16;
var b00 = multiplier.low & 0xFFFF;
var c48 = 0,
c32 = 0,
c16 = 0,
c00 = 0;
c00 += a00 * b00;
c16 += c00 >>> 16;
c00 &= 0xFFFF;
c16 += a16 * b00;
c32 += c16 >>> 16;
c16 &= 0xFFFF;
c16 += a00 * b16;
c32 += c16 >>> 16;
c16 &= 0xFFFF;
c32 += a32 * b00;
c48 += c32 >>> 16;
c32 &= 0xFFFF;
c32 += a16 * b16;
c48 += c32 >>> 16;
c32 &= 0xFFFF;
c32 += a00 * b32;
c48 += c32 >>> 16;
c32 &= 0xFFFF;
c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
c48 &= 0xFFFF;
return fromBits(c16 << 16 | c00, c48 << 16 | c32, $this.unsigned);
}
/**
* Returns the product of this and the specified Long. This is an alias of {@link Long#multiply}.
* @function
* @param {!Long|number|string} multiplier Multiplier
* @returns {!Long} Product
*/
// LongPrototype.mul = LongPrototype.multiply;
/**
* Returns this Long divided by the specified. The result is signed if this Long is signed or
* unsigned if this Long is unsigned.
* @this {!Long}
* @param {!Long|number|string} divisor Divisor
* @returns {!Long} Quotient
*/
function divide($this, divisor) {
if (!isLong(divisor)) divisor = fromValue(divisor);
if (isZero(divisor)) throw Error("division by zero"); // use wasm support if present
if (wasm) {
// guard against signed division overflow: the largest
// negative number / -1 would be 1 larger than the largest
// positive number, due to two's complement.
if (!$this.unsigned && $this.high === -0x80000000 && divisor.low === -1 && divisor.high === -1) {
// be consistent with non-wasm code path
return $this;
}
var low = ($this.unsigned ? wasm.div_u : wasm.div_s)($this.low, $this.high, divisor.low, divisor.high);
return fromBits(low, wasm.get_high(), $this.unsigned);
}
if (isZero($this)) return $this.unsigned ? UZERO : ZERO;
var approx, rem, res;
if (!$this.unsigned) {
// This section is only relevant for signed longs and is derived from the
// closure library as a whole.
if (equals$1($this, MIN_VALUE)) {
if (equals$1(divisor, ONE) || equals$1(divisor, NEG_ONE)) return MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
else if (equals$1(divisor, MIN_VALUE)) return ONE;else {
// At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
var halfThis = shiftRight($this, 1);
approx = shiftLeft(divide(halfThis, divisor), 1);
if (equals$1(approx, ZERO)) {
return isNegative(divisor) ? ONE : NEG_ONE;
} else {
rem = subtract($this, multiply(divisor, approx));
res = add(approx, divide(rem, divisor));
return res;
}
}
} else if (equals$1(divisor, MIN_VALUE)) return $this.unsigned ? UZERO : ZERO;
if (isNegative($this)) {
if (isNegative(divisor)) return divide(negate($this), negate(divisor));
return negate(divide(negate($this), divisor));
} else if (isNegative(divisor)) return negate(divide($this, negate(divisor)));
res = ZERO;
} else {
// The algorithm below has not been made for unsigned longs. It's therefore
// required to take special care of the MSB prior to running it.
if (!divisor.unsigned) divisor = toUnsigned(divisor);
if (greaterThan(divisor, $this)) return UZERO;
if (greaterThan(divisor, shiftRightUnsigned($this, 1))) // 15 >>> 1 = 7 ; with divisor = 8 ; true
return UONE;
res = UZERO;
} // Repeat the following until the remainder is less than other: find a
// floating-point that approximates remainder / other *from below*, add this
// into the result, and subtract it from the remainder. It is critical that
// the approximate value is less than or equal to the real value so that the
// remainder never becomes negative.
rem = $this;
while (greaterThanOrEqual(rem, divisor)) {
// Approximate the result of division. This may be a little greater or
// smaller than the actual value.
approx = Math.max(1, Math.floor(toNumber(rem) / toNumber(divisor))); // We will tweak the approximate result by changing it in the 48-th digit or
// the smallest non-fractional digit, whichever is larger.
var log2 = Math.ceil(Math.log(approx) / Math.LN2),
delta = log2 <= 48 ? 1 : pow_dbl(2, log2 - 48),
// Decrease the approximation until it is smaller than the remainder. Note
// that if it is too large, the product overflows and is negative.
approxRes = fromNumber(approx),
approxRem = multiply(approxRes, divisor);
while (isNegative(approxRem) || greaterThan(approxRem, rem)) {
approx -= delta;
approxRes = fromNumber(approx, $this.unsigned);
approxRem = multiply(approxRes, divisor);
} // We know the answer can't be zero... and actually, zero would cause
// infinite recursion since we would make no progress.
if (isZero(approxRes)) approxRes = ONE;
res = add(res, approxRes);
rem = subtract(rem, approxRem);
}
return res;
}
/**
* Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.
* @function
* @param {!Long|number|string} divisor Divisor
* @returns {!Long} Remainder
*/
// LongPrototype.mod = LongPrototype.modulo;
/**
* Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.
* @function
* @param {!Long|number|string} divisor Divisor
* @returns {!Long} Remainder
*/
// LongPrototype.rem = LongPrototype.modulo;
/**
* Returns the bitwise NOT of this Long.
* @this {!Long}
* @returns {!Long}
*/
function not($this) {
return fromBits(~$this.low, ~$this.high, $this.unsigned);
}
/**
* Returns this Long with bits shifted to the left by the given amount.
* @this {!Long}
* @param {number|!Long} numBits Number of bits
* @returns {!Long} Shifted Long
*/
function shiftLeft($this, numBits) {
if (isLong(numBits)) numBits = toInt(numBits);
if ((numBits &= 63) === 0) return $this;else if (numBits < 32) return fromBits($this.low << numBits, $this.high << numBits | $this.low >>> 32 - numBits, $this.unsigned);else return fromBits(0, $this.low << numBits - 32, $this.unsigned);
}
/**
* Returns this Long with bits shifted to the left by the given amount. This is an alias of {@link Long#shiftLeft}.
* @function
* @param {number|!Long} numBits Number of bits
* @returns {!Long} Shifted Long
*/
// LongPrototype.shl = LongPrototype.shiftLeft;
/**
* Returns this Long with bits arithmetically shifted to the right by the given amount.
* @this {!Long}
* @param {number|!Long} numBits Number of bits
* @returns {!Long} Shifted Long
*/
function shiftRight($this, numBits) {
if (isLong(numBits)) numBits = toInt(numBits);
if ((numBits &= 63) === 0) return $this;else if (numBits < 32) return fromBits($this.low >>> numBits | $this.high << 32 - numBits, $this.high >> numBits, $this.unsigned);else return fromBits($this.high >> numBits - 32, $this.high >= 0 ? 0 : -1, $this.unsigned);
}
/**
* Returns this Long with bits arithmetically shifted to the right by the given amount. This is an alias of {@link Long#shiftRight}.
* @function
* @param {number|!Long} numBits Number of bits
* @returns {!Long} Shifted Long
*/
// LongPrototype.shr = LongPrototype.shiftRight;
/**
* Returns this Long with bits logically shifted to the right by the given amount.
* @this {!Long}
* @param {number|!Long} numBits Number of bits
* @returns {!Long} Shifted Long
*/
function shiftRightUnsigned($this, numBits) {
if (isLong(numBits)) numBits = toInt(numBits);
numBits &= 63;
if (numBits === 0) return $this;else {
var high = $this.high;
if (numBits < 32) {
var low = $this.low;
return fromBits(low >>> numBits | high << 32 - numBits, high >>> numBits, $this.unsigned);
} else if (numBits === 32) return fromBits(high, 0, $this.unsigned);else return fromBits(high >>> numBits - 32, 0, $this.unsigned);
}
}
/**
* Converts this Long to unsigned.
* @this {!Long}
* @returns {!Long} Unsigned long
*/
function toUnsigned($this) {
if ($this.unsigned) return $this;
return fromBits($this.low, $this.high, true);
}
/**
* Converts this Long to its byte representation.
* @param {boolean=} le Whether little or big endian, defaults to big endian
* @this {!Long}
* @returns {!Array.<number>} Byte representation
*/
function toBytes($this, le) {
return le ? toBytesLE($this) : toBytesBE($this);
}
/**
* Converts this Long to its little endian byte representation.
* @this {!Long}
* @returns {!Array.<number>} Little endian byte representation
*/
function toBytesLE($this) {
var hi = $this.high,
lo = $this.low;
return [lo & 0xff, lo >>> 8 & 0xff, lo >>> 16 & 0xff, lo >>> 24, hi & 0xff, hi >>> 8 & 0xff, hi >>> 16 & 0xff, hi >>> 24];
}
/**
* Converts this Long to its big endian byte representation.
* @this {!Long}
* @returns {!Array.<number>} Big endian byte representation
*/
function toBytesBE($this) {
var hi = $this.high,
lo = $this.low;
return [hi >>> 24, hi >>> 16 & 0xff, hi >>> 8 & 0xff, hi & 0xff, lo >>> 24, lo >>> 16 & 0xff, lo >>> 8 & 0xff, lo & 0xff];
}
/**
* Creates a Long from its byte representation.
* @param {!Array.<number>} bytes Byte representation
* @param {boolean=} unsigned Whether unsigned or not, defaults to signed
* @param {boolean=} le Whether little or big endian, defaults to big endian
* @returns {Long} The corresponding Long value
*/
function fromBytes(bytes, unsigned, le) {
return le ? fromBytesLE(bytes, unsigned) : fromBytesBE(bytes, unsigned);
}
/**
* Creates a Long from its little endian byte representation.
* @param {!Array.<number>} bytes Little endian byte representation
* @param {boolean=} unsigned Whether unsigned or not, defaults to signed
* @returns {Long} The corresponding Long value
*/
function fromBytesLE(bytes, unsigned) {
return new Long(bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24, bytes[4] | bytes[5] << 8 | bytes[6] << 16 | bytes[7] << 24, unsigned);
}
/**
* Creates a Long from its big endian byte representation.
* @param {!Array.<number>} bytes Big endian byte representation
* @param {boolean=} unsigned Whether unsigned or not, defaults to signed
* @returns {Long} The corresponding Long value
*/
function fromBytesBE(bytes, unsigned) {
return new Long(bytes[4] << 24 | bytes[5] << 16 | bytes[6] << 8 | bytes[7], bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], unsigned);
}
var Long$1 = Long;
const op_Multiply = multiply;
const compare$2 = compare$1;
const fromBytes$1 = fromBytes;
const toBytes$1 = toBytes;
const toString$1 = toString;
function sameType(x, y) {
return y != null && Object.getPrototypeOf(x).constructor === Object.getPrototypeOf(y).constructor;
} // Taken from Babel helpers
function inherits(subClass, superClass) {
// if (typeof superClass !== "function" && superClass !== null) {
// throw new TypeError(
// "Super expression must either be null or a function, not " +
// typeof superClass
// );
// }
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
}); // if (superClass)
// Object.setPrototypeOf
// ? Object.setPrototypeOf(subClass, superClass)
// : (subClass.__proto__ = superClass);
}
function declare(cons, superClass) {
inherits(cons, superClass || SystemObject);
return cons;
}
function SystemObject() {
return;
}
SystemObject.prototype.toString = function () {
return "{" + Object.keys(this).map(k => k + " = " + String(this[k])).join(";\n ") + "}";
};
SystemObject.prototype.GetHashCode = function () {
return identityHash(this);
};
SystemObject.prototype.Equals = function (other) {
return this === other;
};
function compareList(self, other) {
if (self === other) {
return 0;
} else {
if (other == null) {
return -1;
}
while (self.tail != null) {
if (other.tail == null) {
return 1;
}
const res = compare(self.head, other.head);
if (res !== 0) {
return res;
}
self = self.tail;
other = other.tail;
}
return other.tail == null ? 0 : -1;
}
}
function List(head, tail) {
this.head = head;
this.tail = tail;
}
List.prototype.toString = function () {
return "[" + Array.from(this).map(x => String(x)).join("; ") + "]";
};
List.prototype.toJSON = function () {
return Array.from(this);
};
List.prototype[Symbol.iterator] = function () {
let cur = this;
return {
next: () => {
const tmp = cur;
cur = cur.tail;
return {
done: tmp.tail == null,
value: tmp.head
};
}
};
};
List.prototype.GetHashCode = function () {
const hashes = Array.from(this).map(structuralHash);
return combineHashCodes(hashes);
};
List.prototype.Equals = function (other) {
return compareList(this, other) === 0;
};
List.prototype.CompareTo = function (other) {
return compareList(this, other);
};
function Union(tag, name, ...fields) {
this.tag = tag | 0;
this.name = name;
this.fields = fields;
}
Union.prototype.toString = function () {
const len = this.fields.length;
if (len === 0) {
return this.name;
} else if (len === 1) {
return this.name + " " + String(this.fields[0]);
} else {
return this.name + " (" + this.fields.map(x => String(x)).join(",") + ")";
}
};
Union.prototype.toJSON = function () {
return this.fields.length === 0 ? this.name : [this.name].concat(this.fields);
};
Union.prototype.GetHashCode = function () {
const hashes = this.fields.map(x => structuralHash(x));
hashes.splice(0, 0, numberHash(this.tag));
return combineHashCodes(hashes);
};
Union.prototype.Equals = function (other) {
return this === other || sameType(this, other) && this.tag === other.tag && equalArrays(this.fields, other.fields);
};
Union.prototype.CompareTo = function (other) {
if (this === other) {
return 0;
} else if (!sameType(this, other)) {
return -1;
} else if (this.tag === other.tag) {
return compareArrays(this.fields, other.fields);
} else {
return this.tag < other.tag ? -1 : 1;
}
};
function recordToJson(record, getFieldNames) {
const o = {};
const keys = getFieldNames == null ? Object.keys(record) : getFieldNames(record);
for (let i = 0; i < keys.length; i++) {
o[keys[i]] = record[keys[i]];
}
return o;
}
function recordEquals(self, other, getFieldNames) {
if (self === other) {
return true;
} else if (!sameType(self, other)) {
return false;
} else {
const thisNames = getFieldNames == null ? Object.keys(self) : getFieldNames(self);
for (let i = 0; i < thisNames.length; i++) {
if (!equals(self[thisNames[i]], other[thisNames[i]])) {
return false;
}
}
return true;
}
}
function recordCompare(self, other, getFieldNames) {
if (self === other) {
return 0;
} else if (!sameType(self, other)) {
return -1;
} else {
const thisNames = getFieldNames == null ? Object.keys(self) : getFieldNames(self);
for (let i = 0; i < thisNames.length; i++) {
const result = compare(self[thisNames[i]], other[thisNames[i]]);
if (result !== 0) {
return result;
}
}
return 0;
}
}
function Record() {
return;
}
Record.prototype.toString = function () {
return "{" + Object.keys(this).map(k => k + " = " + String(this[k])).join(";\n ") + "}";
};
Record.prototype.toJSON = function () {
return recordToJson(this);
};
Record.prototype.GetHashCode = function () {
const hashes = Object.keys(this).map(k => structuralHash(this[k]));
return combineHashCodes(hashes);
};
Record.prototype.Equals = function (other) {
return recordEquals(this, other);
};
Record.prototype.CompareTo = function (other) {
return recordCompare(this, other);
};
const FSharpRef = declare(function FSharpRef(contents) {
this.contents = contents;
}, Record); // EXCEPTIONS
const Exception = declare(function Exception(msg) {
this.stack = Error().stack;
this.message = msg;
});
function getFSharpExceptionFieldNames(self) {
return Object.keys(self).filter(k => k !== "message" && k !== "stack");
}
const FSharpException = declare(function FSharpException() {
Exception.call(this);
}, Exception);
FSharpException.prototype.toString = function () {
const fieldNames = getFSharpExceptionFieldNames(this);
const len = fieldNames.length;
if (len === 0) {
return this.message;
} else if (len === 1) {
return this.message + " " + String(this[fieldNames[0]]);
} else {
return this.message + " (" + fieldNames.map(k => String(this[k])).join(",") + ")";
}
};
FSharpException.prototype.toJSON = function () {
return recordToJson(this, getFSharpExceptionFieldNames);
};
FSharpException.prototype.GetHashCode = function () {
const hashes = getFSharpExceptionFieldNames(this).map(k => structuralHash(this[k]));
return combineHashCodes(hashes);
};
FSharpException.prototype.Equals = function (other) {
return recordEquals(this, other, getFSharpExceptionFieldNames);
};
FSharpException.prototype.CompareTo = function (other) {
return recordCompare(this, other, getFSharpExceptionFieldNames);
};
const MatchFailureException = declare(function MatchFailureException(arg1, arg2, arg3) {
this.arg1 = arg1;
this.arg2 = arg2 | 0;
this.arg3 = arg3 | 0;
this.message = "The match cases were incomplete";
}, FSharpException);
const Attribute = declare(function Attribute() {
return;
});
class Some {
constructor(value) {
this.value = value;
} // Don't add "Some" for consistency with erased options
toString() {
return String(this.value);
}
toJSON() {
return this.value;
}
GetHashCode() {
return structuralHash(this.value);
}
Equals(other) {
if (other == null) {
return false;
} else {
return equals(this.value, other instanceof Some ? other.value : other);
}
}
CompareTo(other) {
if (other == null) {
return 1;
} else {
return compare(this.value, other instanceof Some ? other.value : other);
}
}
}
function some(x) {
x = x === undefined ? null : x;
return x == null || x instanceof Some ? new Some(x) : x;
}
function value(x, acceptNull) {
if (x == null) {
if (!acceptNull) {
throw new Error("Option has no value");
}
return null;
} else {
return x instanceof Some ? x.value : x;
}
}
function defaultArg(arg, defaultValue, f) {
return arg == null ? defaultValue : f != null ? f(value(arg)) : value(arg);
}
function map(f, arg) {
return arg == null ? arg : some(f(value(arg)));
}
const Choice = declare(function Choice(tag, name, field) {
Union.call(this, tag, name, field);
}, Union);
const Result = declare(function Result(tag, name, field) {
Union.call(this, tag, name, field);
}, Union);
class Enumerator {
constructor(iter) {
this.iter = iter;
}
MoveNext() {
const cur = this.iter.next();
this.current = cur.value;
return !cur.done;
}
get Current() {
return this.current;
}
Reset() {
throw new Error("JS iterators cannot be reset");
}
Dispose() {
return;
}
}
function getEnumerator(o) {
return new Enumerator(o[Symbol.iterator]());
}
function toIterator(en) {
return {
next() {
return en.MoveNext() ? {
done: false,
value: en.Current
} : {
done: true,
value: null
};
}
};
} // export function toIterable<T>(en: IEnumerable<T>): Iterable<T> {
function append(xs, ys) {
return delay(() => {
let firstDone = false;
const i = xs[Symbol.iterator]();
let iters = [i, null];
return unfold(() => {
let cur;
if (!firstDone) {
cur = iters[0].next();
if (!cur.done) {
return [cur.value, iters];
} else {
firstDone = true;
iters = [null, ys[Symbol.iterator]()];
}
}
cur = iters[1].next();
return !cur.done ? [cur.value, iters] : null;
}, iters);
});
}
function concat(xs) {
return delay(() => {
const iter = xs[Symbol.iterator]();
let output = {
value: null
};
return unfold(innerIter => {
let hasFinished = false;
while (!hasFinished) {
if (innerIter == null) {
const cur = iter.next();
if (!cur.done) {
innerIter = cur.value[Symbol.iterator]();
} else {
hasFinished = true;
}
} else {
const cur = innerIter.next();
if (!cur.done) {
output = {
value: cur.value
};
hasFinished = true;
} else {
innerIter = null;
}
}
}
return innerIter != null && output != null ? [output.value, innerIter] : null;
}, null);
});
}
function collect(f, xs) {
return concat(map$1(f, xs));
}
function delay(f) {
return {
[Symbol.iterator]: () => f()[Symbol.iterator]()
};
}
function empty() {
return unfold(() => void 0);
}
function exists(f, xs) {
let cur;
for (const iter = xs[Symbol.iterator]();;) {
cur = iter.next();
if (cur.done) {
break;
}
if (f(cur.value)) {
return true;
}
}
return false;
}
function forAll(f, xs) {
return !exists(x => !f(x), xs);
}
function filter(f, xs) {
return delay(() => unfold(iter => {
let cur = iter.next();
while (!cur.done) {
if (f(cur.value)) {
return [cur.value, iter];
}
cur = iter.next();
}
return null;
}, xs[Symbol.iterator]()));
}
function fold(f, acc, xs) {
if (Array.isArray(xs) || ArrayBuffer.isView(xs)) {
return xs.reduce(f, acc);
} else {
let cur;
for (let i = 0, iter = xs[Symbol.iterator]();; i++) {
cur = iter.next();
if (cur.done) {
break;
}
acc = f(acc, cur.value, i);
}
return acc;
}
}
function iterate(f, xs) {
fold((_, x) => f(x), null, xs);
}
function iterateIndexed(f, xs) {
fold((_, x, i) => f(i, x), null, xs);
}
function isEmpty(xs) {
const i = xs[Symbol.iterator]();
return i.next().done;
}
function map$1(f, xs) {
return delay(() => unfold(iter => {
const cur = iter.next();
return !cur.done ? [f(cur.value), iter] : null;
}, xs[Symbol.iterator]()));
}
function skipWhile(f, xs) {
return delay(() => {
let hasPassed = false;
return filter(x => hasPassed || (hasPassed = !f(x)), xs);
});
}
function sumBy(f, xs, adder) {
return fold((acc, x) => adder.Add(acc, f(x)), adder.GetZero(), xs);
}
function takeWhile(f, xs) {
return delay(() => {
const iter = xs[Symbol.iterator]();
return unfold(i => {
const cur = iter.next();
if (!cur.done && f(cur.value)) {
return [cur.value, null];
}
return void 0;
}, 0);
});
}
function tryFind(f, xs, defaultValue) {
for (let i = 0, iter = xs[Symbol.iterator]();; i++) {
const cur = iter.next();
if (cur.done) {
break;
}
if (f(cur.value, i)) {
return some(cur.value);
}
}
return defaultValue === void 0 ? null : some(defaultValue);
}
function unfold(f, fst) {
return {
[Symbol.iterator]: () => {
// Capture a copy of the first value in the closure
// so the sequence is restarted every time, see #1230
let acc = fst;
return {
next: () => {
const res = f(acc);
if (res != null) {
acc = res[1];
return {
done: false,
value: res[0]
};
}
return {
done: true
};
}
};
}
};
}
class CaseInfo {
constructor(declaringType, tag, name, fields) {
this.declaringType = declaringType;
this.tag = tag;
this.name = name;
this.fields = fields;
}
}
class TypeInfo {
constructor(fullname, generics, constructor, fields, cases, enumCases) {
this.fullname = fullname;
this.generics = generics;
this.constructor = constructor;
this.fields = fields;
this.cases = cases;
this.enumCases = enumCases;
}
toString() {
return fullName(this);
}
Equals(other) {
return equals$2(this, other);
}
CompareTo(other) {
return compare$3(this, other);
}
}
function getGenerics(t) {
return t.generics != null ? t.generics : [];
}
function equals$2(t1, t2) {
if (t1.fullname === "") {
// Anonymous records
return t2.fullname === "" && equalArraysWith(getRecordElements(t1), getRecordElements(t2), ([k1, v1], [k2, v2]) => k1 === k2 && equals$2(v1, v2));
} else {
return t1.fullname === t2.fullname && equalArraysWith(getGenerics(t1), getGenerics(t2), equals$2);
}
} // System.Type is not comparable in .NET, but let's implement this
// in case users want to create a dictionary with types as keys
function compare$3(t1, t2) {
if (t1.fullname !== t2.fullname) {
return t1.fullname < t2.fullname ? -1 : 1;
} else {
return compareArraysWith(getGenerics(t1), getGenerics(t2), compare$3);
}
}
function record(fullname, generics, constructor, fields) {
return new TypeInfo(fullname, generics, constructor, fields);
}
function union(fullname, generics, constructor, cases) {
const t = new TypeInfo(fullname, generics, constructor, null, () => cases().map((x, i) => typeof x === "string" ? new CaseInfo(t, i, x) : new CaseInfo(t, i, x[0], x[1])));
return t;
}
function option(generic) {
return new TypeInfo("Microsoft.FSharp.Core.FSharpOption`1", [generic]);
}
function list(generic) {
return new TypeInfo("Microsoft.FSharp.Collections.FSharpList`1", [generic]);
}
const string = new TypeInfo("System.String");
const bool = new TypeInfo("System.Boolean");
function fullName(t) {
const gen = t.generics != null && !isArray$1(t) ? t.generics : [];
if (gen.length > 0) {
return t.fullname + "[" + gen.map(x => fullName(x)).join(",") + "]";
} else {
return t.fullname;
}
}
function isArray$1(t) {
return t.fullname.endsWith("[]");
}
function getRecordElements(t) {
if (t.fields != null) {
return t.fields();
} else {
throw new Error(`${t.fullname} is not an F# record type`);
}
}
function escape(str) {
return str.replace(/[\-\[\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}
const fsFormatRegExp = /(^|[^%])%([0+\- ]*)(\d+)?(?:\.(\d+))?(\w)/;
function isNumeric(x) {
return typeof x === "number" || x instanceof Long$1 || x instanceof Big;
}
function isLessThan(x, y) {
if (x instanceof Long$1) {
return compare$2(x, y) < 0;
} else if (x instanceof Big) {
return x.cmp(y) < 0;
} else {
return x < y;
}
}
function multiply$1(x, y) {
if (x instanceof Long$1) {
return op_Multiply(x, y);
} else if (x instanceof Big) {
return x.mul(y);
} else {
return x * y;
}
}
function toFixed(x, dp) {
if (x instanceof Long$1) {
return String(x) + 0 .toFixed(dp).substr(1);
} else {
return x.toFixed(dp);
}
}
function toPrecision(x, sd) {
if (x instanceof Long$1) {
return String(x) + 0 .toPrecision(sd).substr(1);
} else {
return x.toPrecision(sd);
}
}
function toExponential(x, dp) {
if (x instanceof Long$1) {
return String(x) + 0 .toExponential(dp).substr(1);
} else {
return x.toExponential(dp);
}
}
function cmp(x, y, ic) {
function isIgnoreCase(i) {
return i === true || i === 1
/* CurrentCultureIgnoreCase */
|| i === 3
/* InvariantCultureIgnoreCase */
|| i === 5
/* OrdinalIgnoreCase */
;
}
function isOrdinal(i) {
return i === 4
/* Ordinal */
|| i === 5
/* OrdinalIgnoreCase */
;
}
if (x == null) {
return y == null ? 0 : -1;
}
if (y == null) {
return 1;
} // everything is bigger than null
if (isOrdinal(ic)) {
if (isIgnoreCase(ic)) {
x = x.toLowerCase();
y = y.toLowerCase();
}
return x === y ? 0 : x < y ? -1 : 1;
} else {
if (isIgnoreCase(ic)) {
x = x.toLocaleLowerCase();
y = y.toLocaleLowerCase();
}
return x.localeCompare(y);
}
}
function compare$4(...args) {
switch (args.length) {
case 2:
return cmp(args[0], args[1], false);
case 3:
return cmp(args[0], args[1], args[2]);
case 4:
return cmp(args[0], args[1], args[2] === true);
case 5:
return cmp(args[0].substr(args[1], args[4]), args[2].substr(args[3], args[4]), false);
case 6:
return cmp(args[0].substr(args[1], args[4]), args[2].substr(args[3], args[4]), args[5]);
case 7:
return cmp(args[0].substr(args[1], args[4]), args[2].substr(args[3], args[4]), args[5] === true);
default:
throw new Error("String.compare: Unsupported number of parameters");
}
}
function indexOfAny(str, anyOf, ...args) {
if (str == null || str === "") {
return -1;
}
const startIndex = args.length > 0 ? args[0] : 0;
if (startIndex < 0) {
throw new Error("Start index cannot be negative");
}
const length = args.length > 1 ? args[1] : str.length - startIndex;
if (length < 0) {
throw new Error("Length cannot be negative");
}
if (length > str.length - startIndex) {
throw new Error("Invalid startIndex and length");
}
str = str.substr(startIndex, length);
for (const c of anyOf) {
const index = str.indexOf(c);
if (index > -1) {
return index + startIndex;
}
}
return -1;
}
function toHex(x) {
if (x instanceof Long$1) {
return toString$1(x.unsigned ? x : fromBytes$1(toBytes$1(x), true), 16);
} else {
return (Number(x) >>> 0).toString(16);
}
}
function printf(input) {
return {
input,
cont: fsFormat(input)
};
}
function toConsole(arg) {
// Don't remove the lambda here, see #1357
return arg.cont(x => {
console.log(x);
});
}
function toText(arg) {
return arg.cont(x => x);
}
function toFail(arg) {
return arg.cont(x => {
throw new Error(x);
});
}
function formatOnce(str2, rep) {
return str2.replace(fsFormatRegExp, (_, prefix, flags, padLength, precision, format) => {
let sign = "";
if (isNumeric(rep)) {
if (format.toLowerCase() !== "x") {
if (isLessThan(rep, 0)) {
rep = multiply$1(rep, -1);
sign = "-";
} else {
if (flags.indexOf(" ") >= 0) {
sign = " ";
} else if (flags.indexOf("+") >= 0) {
sign = "+";
}
}
}
precision = precision == null ? null : parseInt(precision, 10);
switch (format) {
case "f":
case "F":
precision = precision != null ? precision : 6;
rep = toFixed(rep, precision);
break;
case "g":
case "G":
rep = precision != null ? toPrecision(rep, precision) : toPrecision(rep);
break;
case "e":
case "E":
rep = precision != null ? toExponential(rep, precision) : toExponential(rep);
break;
case "x":
rep = toHex(rep);
break;
case "X":
rep = toHex(rep).toUpperCase();
break;
default:
// AOid
rep = String(rep);
break;
}
}
padLength = parseInt(padLength, 10);
if (!isNaN(padLength)) {
const zeroFlag = flags.indexOf("0") >= 0; // Use '0' for left padding
const minusFlag = flags.indexOf("-") >= 0; // Right padding
const ch = minusFlag || !zeroFlag ? " " : "0";
if (ch === "0") {
rep = padLeft(rep, padLength - sign.length, ch, minusFlag);
rep = sign + rep;
} else {
rep = padLeft(sign + rep, padLength, ch, minusFlag);
}
} else {
rep = sign + rep;
}
const once = prefix + rep;
return once.replace(/%/g, "%%");
});
}
function createPrinter(str, cont) {
return (...args) => {
// Make a copy as the function may be used several times
let strCopy = str;
for (const arg of args) {
strCopy = formatOnce(strCopy, arg);
}
return fsFormatRegExp.test(strCopy) ? createPrinter(strCopy, cont) : cont(strCopy.replace(/%%/g, "%"));
};
}
function fsFormat(str) {
return cont => {
return fsFormatRegExp.test(str) ? createPrinter(str, cont) : cont(str);
};
}
function endsWith(str, search) {
const idx = str.lastIndexOf(search);
return idx >= 0 && idx === str.length - search.length;
}
function isNullOrEmpty(str) {
return typeof str !== "string" || str.length === 0;
}
function isNullOrWhiteSpace(str) {
return typeof str !== "string" || /^\s*$/.test(str);
}
function join(delimiter, xs) {
if (Array.isArray(xs)) {
return xs.join(delimiter);
} else {
return Array.from(xs).join(delimiter);
}
}
function padLeft(str, len, ch, isRight) {
ch = ch || " ";
len = len - str.length;
for (let i = 0; i < len; i++) {
str = isRight ? str + ch : ch + str;
}
return str;
}
function replace(str, search, replace) {
return str.replace(new RegExp(escape(search), "g"), replace);
}
function trim(str, ...chars) {
if (chars.length === 0) {
return str.trim();
}
const pattern = "[" + escape(chars.join("")) + "]+";
return str.replace(new RegExp("^" + pattern), "").replace(new RegExp(pattern + "$"), "");
}
function substring(str, startIndex, length) {
if (startIndex + (length || 0) > str.length) {
throw new Error("Invalid startIndex and/or length");
}
return length != null ? str.substr(startIndex, length) : str.substr(startIndex);
}
const MutableMap$00602 = declare(function Fable_Collections_MutableMap(pairs, comparer) {
const $this$$1 = this;
const this$ = new FSharpRef(null);
$this$$1.comparer = comparer;
this$.contents = $this$$1;
$this$$1["entries@23"] = new Map([]);
$this$$1["init@20-1"] = 1;
iterate(function (pair) {
MutableMap$00602$$Add$$5BDDA1(this$.contents, pair[0], pair[1]);
}, pairs);
});
function MutableMap$00602$$$$002Ector$$6623D9B3(pairs, comparer) {
return this instanceof MutableMap$00602 ? MutableMap$00602.call(this, pairs, comparer) : new MutableMap$00602(pairs, comparer);
}
function MutableMap$00602$$TryFindIndex$$2B595(this$$$1, k) {
const h = this$$$1.comparer.GetHashCode(k) | 0;
const matchValue = tryGetValue(this$$$1["entries@23"], h, null);
if (matchValue[0]) {
return [true, h, matchValue[1].findIndex(function (pair$$1) {
return this$$$1.comparer.Equals(k, pair$$1[0]);
})];
} else {
return [false, h, -1];
}
}
function MutableMap$00602$$TryFind$$2B595(this$$$2, k$$1) {
const matchValue$$1 = MutableMap$00602$$TryFindIndex$$2B595(this$$$2, k$$1);
var $target$$10;
if (matchValue$$1[0]) {
if (matchValue$$1[2] > -1) {
$target$$10 = 0;
} else {
$target$$10 = 1;
}
} else {
$target$$10 = 1;
}
switch ($target$$10) {
case 0:
{
return getItemFromDict(this$$$2["entries@23"], matchValue$$1[1])[matchValue$$1[2]];
}
case 1:
{
return null;
}
}
}
function MutableMap$00602$$Clear(this$$$4) {
this$$$4["entries@23"].clear();
}
function MutableMap$00602$$get_Count(this$$$5) {
const source = this$$$5["entries@23"].values();
return sumBy(function projection(pairs$$2) {
return pairs$$2.length;
}, source, {
GetZero() {
return 0;
},
Add($x$$2, $y$$3) {
return $x$$2 + $y$$3;
}
}) | 0;
}
function MutableMap$00602$$get_Item$$2B595(this$$$6, k$$2) {
const matchValue$$2 = MutableMap$00602$$TryFind$$2B595(this$$$6, k$$2);
if (matchValue$$2 != null) {
const pair$$2 = matchValue$$2;
return pair$$2[1];
} else {
throw new Error("The item was not found in collection");
}
}
function MutableMap$00602$$set_Item$$5BDDA1(this$$$7, k$$3, v) {
const matchValue$$3 = MutableMap$00602$$TryFindIndex$$2B595(this$$$7, k$$3);
var $target$$20;
if (matchValue$$3[0]) {
if (matchValue$$3[2] > -1) {
$target$$20 = 0;
} else {
$target$$20 = 1;
}
} else {
$target$$20 = 1;
}
switch ($target$$20) {
case 0:
{
getItemFromDict(this$$$7["entries@23"], matchValue$$3[1])[matchValue$$3[2]] = [k$$3, v];
break;
}
case 1:
{
if (matchValue$$3[0]) {
const value = getItemFromDict(this$$$7["entries@23"], matchValue$$3[1]).push([k$$3, v]);
} else {
this$$$7["entries@23"].set(matchValue$$3[1], [[k$$3, v]]);
}
break;
}
}
}
function MutableMap$00602$$Add$$5BDDA1(this$$$8, k$$4, v$$1) {
const matchValue$$4 = MutableMap$00602$$TryFindIndex$$2B595(this$$$8, k$$4);
var $target$$24;
if (matchValue$$4[0]) {
if (matchValue$$4[2] > -1) {
$target$$24 = 0;
} else {
$target$$24 = 1;
}
} else {
$target$$24 = 1;
}
switch ($target$$24) {
case 0:
{
let msg;
const clo1 = toText(printf("An item with the same key has already been added. Key: %A"));
msg = clo1(k$$4);
throw new Error(msg);
}
case 1:
{
if (matchValue$$4[0]) {
const value$$1 = getItemFromDict(this$$$8["entries@23"], matchValue$$4[1]).push([k$$4, v$$1]);
} else {
this$$$8["entries@23"].set(matchValue$$4[1], [[k$$4, v$$1]]);
}
break;
}
}
}
function MutableMap$00602$$ContainsKey$$2B595(this$$$9, k$$5) {
const matchValue$$5 = MutableMap$00602$$TryFindIndex$$2B595(this$$$9, k$$5);
var $target$$27;
if (matchValue$$5[0]) {
if (matchValue$$5[2] > -1) {
$target$$27 = 0;
} else {
$target$$27 = 1;
}
} else {
$target$$27 = 1;
}
switch ($target$$27) {
case 0:
{
return true;
}
case 1:
{
return false;
}
}
}
function MutableMap$00602$$Remove$$2B595(this$$$10, k$$6) {
const matchValue$$6 = MutableMap$00602$$TryFindIndex$$2B595(this$$$10, k$$6);
var $target$$30;
if (matchValue$$6[0]) {
if (matchValue$$6[2] > -1) {
$target$$30 = 0;
} else {
$target$$30 = 1;
}
} else {
$target$$30 = 1;
}
switch ($target$$30) {
case 0:
{
getItemFromDict(this$$$10["entries@23"], matchValue$$6[1]).splice(matchValue$$6[2], 1);
return true;
}
case 1:
{
return false;
}
}
}
MutableMap$00602.prototype[Symbol.iterator] = function () {
var elems;
const this$$$11 = this;
return toIterator((elems = delay(function () {
return collect(function (pairs$$3) {
return map$1(function (pair$$3) {
return pair$$3;
}, pairs$$3);
}, this$$$11["entries@23"].values());
}), getEnumerator(elems)));
};
MutableMap$00602.prototype.Add = function (item) {
const this$$$12 = this;
MutableMap$00602$$Add$$5BDDA1(this$$$12, item[0], item[1]);
};
MutableMap$00602.prototype.Clear = function () {
const this$$$13 = this;
MutableMap$00602$$Clear(this$$$13);
};
MutableMap$00602.prototype.Contains = function (item$$1) {
var p;
const this$$$14 = this;
const matchValue$$7 = MutableMap$00602$$TryFind$$2B595(this$$$14, item$$1[0]);
var $target$$31;
if (matchValue$$7 != null) {
if (p = matchValue$$7, equals(p[1], item$$1[1])) {
$target$$31 = 0;
} else {
$target$$31 = 1;
}
} else {
$target$$31 = 1;
}
switch ($target$$31) {
case 0:
{
return true;
}
case 1:
{
return false;
}
}
};
MutableMap$00602.prototype.CopyTo = function (array, arrayIndex) {
const this$$$15 = this;
iterateIndexed(function action(i$$10, e) {
array[arrayIndex + i$$10] = e;
}, this$$$15);
};
Object.defineProperty(MutableMap$00602.prototype, "Count", {
"get": function () {
const this$$$16 = this;
return MutableMap$00602$$get_Count(this$$$16) | 0;
}
});
Object.defineProperty(MutableMap$00602.prototype, "IsReadOnly", {
"get": function () {
return false;
}
});
MutableMap$00602.prototype.Remove = function (item$$2) {
const this$$$18 = this;
const matchValue$$8 = MutableMap$00602$$TryFind$$2B595(this$$$18, item$$2[0]);
if (matchValue$$8 != null) {
const pair$$4 = matchValue$$8;
if (equals(pair$$4[1], item$$2[1])) {
const value$$2 = MutableMap$00602$$Remove$$2B595(this$$$18, item$$2[0]);
}
return true;
} else {
return false;
}
};
Object.defineProperty(MutableMap$00602.prototype, "size", {
"get": function () {
const this$$$19 = this;
return MutableMap$00602$$get_Count(this$$$19) | 0;
}
});
MutableMap$00602.prototype.clear = function () {
const this$$$20 = this;
MutableMap$00602$$Clear(this$$$20);
};
MutableMap$00602.prototype.delete = function (k$$7) {
const this$$$21 = this;
return MutableMap$00602$$Remove$$2B595(this$$$21, k$$7);
};
MutableMap$00602.prototype.entries = function () {
const this$$$22 = this;
return map$1(function mapping(x) {
return x;
}, this$$$22);
};
MutableMap$00602.prototype.get = function (k$$8) {
const this$$$23 = this;
return MutableMap$00602$$get_Item$$2B595(this$$$23, k$$8);
};
MutableMap$00602.prototype.has = function (k$$9) {
const this$$$24 = this;
return MutableMap$00602$$ContainsKey$$2B595(this$$$24, k$$9);
};
MutableMap$00602.prototype.keys = function () {
const this$$$25 = this;
return map$1(function mapping$$1(pair$$5) {
return pair$$5[0];
}, this$$$25);
};
MutableMap$00602.prototype.set = function (k$$10, v$$2) {
const this$$$26 = this;
MutableMap$00602$$set_Item$$5BDDA1(this$$$26, k$$10, v$$2);
return this$$$26;
};
MutableMap$00602.prototype.values = function () {
const this$$$27 = this;
return map$1(function mapping$$2(pair$$6) {
return pair$$6[1];
}, this$$$27);
};
const MapTree$00602 = declare(function Map_MapTree(tag, name, ...fields) {
Union.call(this, tag, name, ...fields);
}, Union);
function MapTreeModule$$$sizeAux($acc$$5, $m$$6) {
MapTreeModule$$$sizeAux: while (true) {
const acc = $acc$$5,
m = $m$$6;
switch (m.tag) {
case 1:
{
return acc + 1 | 0;
}
case 2:
{
$acc$$5 = MapTreeModule$$$sizeAux(acc + 1, m.fields[2]);
$m$$6 = m.fields[3];
continue MapTreeModule$$$sizeAux;
}
default:
{
return acc | 0;
}
}
}
}
function MapTreeModule$$$size(x) {
return MapTreeModule$$$sizeAux(0, x);
}
function MapTreeModule$$$empty() {
return new MapTree$00602(0, "MapEmpty");
}
function MapTreeModule$$$height(_arg1) {
switch (_arg1.tag) {
case 1:
{
return 1;
}
case 2:
{
return _arg1.fields[4] | 0;
}
default:
{
return 0;
}
}
}
function MapTreeModule$$$mk(l$$1, k, v, r$$1) {
var $target$$14;
if (l$$1.tag === 0) {
if (r$$1.tag === 0) {
$target$$14 = 0;
} else {
$target$$14 = 1;
}
} else {
$target$$14 = 1;
}
switch ($target$$14) {
case 0:
{
return new MapTree$00602(1, "MapOne", k, v);
}
case 1:
{
const hl = MapTreeModule$$$height(l$$1) | 0;
const hr = MapTreeModule$$$height(r$$1) | 0;
const m$$2 = (hl < hr ? hr : hl) | 0;
return new MapTree$00602(2, "MapNode", k, v, l$$1, r$$1, m$$2 + 1);
}
}
}
function MapTreeModule$$$rebalance(t1, k$$1, v$$1, t2) {
const t1h = MapTreeModule$$$height(t1) | 0;
const t2h = MapTreeModule$$$height(t2) | 0;
if (t2h > t1h + 2) {
if (t2.tag === 2) {
if (MapTreeModule$$$height(t2.fields[2]) > t1h + 1) {
if (t2.fields[2].tag === 2) {
return MapTreeModule$$$mk(MapTreeModule$$$mk(t1, k$$1, v$$1, t2.fields[2].fields[2]), t2.fields[2].fields[0], t2.fields[2].fields[1], MapTreeModule$$$mk(t2.fields[2].fields[3], t2.fields[0], t2.fields[1], t2.fields[3]));
} else {
throw new Error("rebalance");
}
} else {
return MapTreeModule$$$mk(MapTreeModule$$$mk(t1, k$$1, v$$1, t2.fields[2]), t2.fields[0], t2.fields[1], t2.fields[3]);
}
} else {
throw new Error("rebalance");
}
} else if (t1h > t2h + 2) {
if (t1.tag === 2) {
if (MapTreeModule$$$height(t1.fields[3]) > t2h + 1) {
if (t1.fields[3].tag === 2) {
return MapTreeModule$$$mk(MapTreeModule$$$mk(t1.fields[2], t1.fields[0], t1.fields[1], t1.fields[3].fields[2]), t1.fields[3].fields[0], t1.fields[3].fields[1], MapTreeModule$$$mk(t1.fields[3].fields[3], k$$1, v$$1, t2));
} else {
throw new Error("re balance");
}
} else {
return MapTreeModule$$$mk(t1.fields[2], t1.fields[0], t1.fields[1], MapTreeModule$$$mk(t1.fields[3], k$$1, v$$1, t2));
}
} else {
throw new Error("rebalance");
}
} else {
return MapTreeModule$$$mk(t1, k$$1, v$$1, t2);
}
}
function MapTreeModule$$$add(comparer, k$$2, v$$2, m$$3) {
switch (m$$3.tag) {
case 1:
{
const c = comparer.Compare(k$$2, m$$3.fields[0]) | 0;
if (c < 0) {
return new MapTree$00602(2, "MapNode", k$$2, v$$2, new MapTree$00602(0, "MapEmpty"), m$$3, 2);
} else if (c === 0) {
return new MapTree$00602(1, "MapOne", k$$2, v$$2);
} else {
return new MapTree$00602(2, "MapNode", k$$2, v$$2, m$$3, new MapTree$00602(0, "MapEmpty"), 2);
}
}
case 2:
{
const c$$1 = comparer.Compare(k$$2, m$$3.fields[0]) | 0;
if (c$$1 < 0) {
return MapTreeModule$$$rebalance(MapTreeModule$$$add(comparer, k$$2, v$$2, m$$3.fields[2]), m$$3.fields[0], m$$3.fields[1], m$$3.fields[3]);
} else if (c$$1 === 0) {
return new MapTree$00602(2, "MapNode", k$$2, v$$2, m$$3.fields[2], m$$3.fields[3], m$$3.fields[4]);
} else {
return MapTreeModule$$$rebalance(m$$3.fields[2], m$$3.fields[0], m$$3.fields[1], MapTreeModule$$$add(comparer, k$$2, v$$2, m$$3.fields[3]));
}
}
default:
{
return new MapTree$00602(1, "MapOne", k$$2, v$$2);
}
}
}
function MapTreeModule$$$find($comparer$$1$$23, $k$$3$$24, $m$$4$$25) {
MapTreeModule$$$find: while (true) {
const comparer$$1 = $comparer$$1$$23,
k$$3 = $k$$3$$24,
m$$4 = $m$$4$$25;
switch (m$$4.tag) {
case 1:
{
const c$$2 = comparer$$1.Compare(k$$3, m$$4.fields[0]) | 0;
if (c$$2 === 0) {
return m$$4.fields[1];
} else {
throw new Error("key not found");
}
}
case 2:
{
const c$$3 = comparer$$1.Compare(k$$3, m$$4.fields[0]) | 0;
if (c$$3 < 0) {
$comparer$$1$$23 = comparer$$1;
$k$$3$$24 = k$$3;
$m$$4$$25 = m$$4.fields[2];
continue MapTreeModule$$$find;
} else if (c$$3 === 0) {
return m$$4.fields[1];
} else {
$comparer$$1$$23 = comparer$$1;
$k$$3$$24 = k$$3;
$m$$4$$25 = m$$4.fields[3];
continue MapTreeModule$$$find;
}
}
default:
{
throw new Error("key not found");
}
}
}
}
function MapTreeModule$$$mem($comparer$$10$$59, $k$$12$$60, $m$$8$$61) {
MapTreeModule$$$mem: while (true) {
const comparer$$10 = $comparer$$10$$59,
k$$12 = $k$$12$$60,
m$$8 = $m$$8$$61;
switch (m$$8.tag) {
case 1:
{
return comparer$$10.Compare(k$$12, m$$8.fields[0]) === 0;
}
case 2:
{
const c$$8 = comparer$$10.Compare(k$$12, m$$8.fields[0]) | 0;
if (c$$8 < 0) {
$comparer$$10$$59 = comparer$$10;
$k$$12$$60 = k$$12;
$m$$8$$61 = m$$8.fields[2];
continue MapTreeModule$$$mem;
} else if (c$$8 === 0) {
return true;
} else {
$comparer$$10$$59 = comparer$$10;
$k$$12$$60 = k$$12;
$m$$8$$61 = m$$8.fields[3];
continue MapTreeModule$$$mem;
}
}
default:
{
return false;
}
}
}
}
function MapTreeModule$$$ofList(comparer$$13, l$$20) {
return fold(function (acc$$9, tupledArg) {
return MapTreeModule$$$add(comparer$$13, tupledArg[0], tupledArg[1], acc$$9);
}, MapTreeModule$$$empty(), l$$20);
}
const MapTreeModule$002EMapIterator$00602 = declare(function Map_MapTreeModule_MapIterator(arg1, arg2) {
this.stack = arg1;
this.started = arg2;
}, Record);
function MapTreeModule$$$collapseLHS($stack$$111) {
MapTreeModule$$$collapseLHS: while (true) {
const stack = $stack$$111;
if (stack.tail != null) {
if (stack.head.tag === 1) {
return stack;
} else if (stack.head.tag === 2) {
$stack$$111 = new List(stack.head.fields[2], new List(new MapTree$00602(1, "MapOne", stack.head.fields[0], stack.head.fields[1]), new List(stack.head.fields[3], stack.tail)));
continue MapTreeModule$$$collapseLHS;
} else {
$stack$$111 = stack.tail;
continue MapTreeModule$$$collapseLHS;
}
} else {
return new List();
}
}
}
function MapTreeModule$$$mkIterator(s$$5) {
return new MapTreeModule$002EMapIterator$00602(MapTreeModule$$$collapseLHS(new List(s$$5, new List())), false);
}
function MapTreeModule$$$notStarted() {
throw new Error("enumeration not started");
}
function MapTreeModule$$$alreadyFinished() {
throw new Error("enumeration already finished");
}
function MapTreeModule$$$current(i$$2) {
if (i$$2.started) {
const matchValue$$4 = i$$2.stack;
if (matchValue$$4.tail == null) {
return MapTreeModule$$$alreadyFinished();
} else if (matchValue$$4.head.tag === 1) {
return [matchValue$$4.head.fields[0], matchValue$$4.head.fields[1]];
} else {
throw new Error("Please report error: Map iterator, unexpected stack for current");
}
} else {
return MapTreeModule$$$notStarted();
}
}
function MapTreeModule$$$moveNext(i$$3) {
if (i$$3.started) {
const matchValue$$5 = i$$3.stack;
if (matchValue$$5.tail == null) {
return false;
} else if (matchValue$$5.head.tag === 1) {
i$$3.stack = MapTreeModule$$$collapseLHS(matchValue$$5.tail);
return !(i$$3.stack.tail == null);
} else {
throw new Error("Please report error: Map iterator, unexpected stack for moveNext");
}
} else {
i$$3.started = true;
return !(i$$3.stack.tail == null);
}
}
const MapTreeModule$002EmkIEnumerator$0027$00602 = declare(function Map_MapTreeModule_mkIEnumerator_(s$$6) {
const $this$$1 = this;
$this$$1.s = s$$6;
$this$$1.i = MapTreeModule$$$mkIterator($this$$1.s);
});
function MapTreeModule$002EmkIEnumerator$0027$00602$$$$002Ector$$Z26BC498C(s$$6) {
return this instanceof MapTreeModule$002EmkIEnumerator$0027$00602 ? MapTreeModule$002EmkIEnumerator$0027$00602.call(this, s$$6) : new MapTreeModule$002EmkIEnumerator$0027$00602(s$$6);
}
Object.defineProperty(MapTreeModule$002EmkIEnumerator$0027$00602.prototype, "Current", {
"get": function () {
const __ = this;
return MapTreeModule$$$current(__.i);
}
});
MapTreeModule$002EmkIEnumerator$0027$00602.prototype.MoveNext = function () {
const __$$1 = this;
return MapTreeModule$$$moveNext(__$$1.i);
};
MapTreeModule$002EmkIEnumerator$0027$00602.prototype.Reset = function () {
const __$$2 = this;
__$$2.i = MapTreeModule$$$mkIterator(__$$2.s);
};
MapTreeModule$002EmkIEnumerator$0027$00602.prototype.Dispose = function () {};
function MapTreeModule$$$mkIEnumerator(s$$7) {
return MapTreeModule$002EmkIEnumerator$0027$00602$$$$002Ector$$Z26BC498C(s$$7);
}
function MapTreeModule$$$toSeq(s$$8) {
const en = MapTreeModule$$$mkIEnumerator(s$$8);
return unfold(function generator(en$$1) {
if (en$$1.MoveNext()) {
return [en$$1.Current, en$$1];
} else {
return null;
}
}, en);
}
const FSharpMap = declare(function Map_Map(comparer$$17, tree) {
const $this$$2 = this;
$this$$2.comparer = comparer$$17;
$this$$2.tree = tree;
});
function FSharpMap$$$$002Ector$$58ADD115(comparer$$17, tree) {
return this instanceof FSharpMap ? FSharpMap.call(this, comparer$$17, tree) : new FSharpMap(comparer$$17, tree);
}
function FSharpMap$$get_Tree(__$$5) {
return __$$5.tree;
}
function FSharpMap$$get_Item$$2B595(__$$8, k$$29) {
return MapTreeModule$$$find(__$$8.comparer, k$$29, __$$8.tree);
}
function FSharpMap$$get_Count(__$$20) {
return MapTreeModule$$$size(__$$20.tree);
}
function FSharpMap$$ContainsKey$$2B595(__$$21, k$$31) {
return MapTreeModule$$$mem(__$$21.comparer, k$$31, __$$21.tree);
}
FSharpMap.prototype.toString = function () {
var strings;
const this$ = this;
return "map [" + (strings = map$1(function mapping(kv) {
const clo1 = toText(printf("(%A, %A)"));
const clo2 = clo1(kv[0]);
return clo2(kv[1]);
}, this$), join("; ", strings)) + "]";
};
FSharpMap.prototype.GetHashCode = function () {
const this$$$1 = this;
const combineHash = function combineHash(x$$16, y$$3) {
return (x$$16 << 1) + y$$3 + 631;
};
let res$$3 = 0;
const e$$1 = MapTreeModule$$$mkIEnumerator(FSharpMap$$get_Tree(this$$$1));
while (e$$1.MoveNext()) {
const patternInput$$5 = e$$1.Current;
const activePatternResult3706 = patternInput$$5;
res$$3 = combineHash(res$$3, structuralHash(activePatternResult3706[0]));
res$$3 = combineHash(res$$3, structuralHash(activePatternResult3706[1]));
}
return Math.abs(res$$3) | 0;
};
FSharpMap.prototype.Equals = function (that) {
const this$$$2 = this;
return this$$$2.CompareTo(that) === 0;
};
FSharpMap.prototype[Symbol.iterator] = function () {
const __$$25 = this;
return toIterator(MapTreeModule$$$mkIEnumerator(__$$25.tree));
};
FSharpMap.prototype.CompareTo = function (obj) {
const m$$22 = this;
let res$$4 = 0;
let finished = false;
const e1 = MapTreeModule$$$mkIEnumerator(FSharpMap$$get_Tree(m$$22));
try {
const e2 = MapTreeModule$$$mkIEnumerator(FSharpMap$$get_Tree(obj));
try {
while (!finished ? res$$4 === 0 : false) {
const matchValue$$7 = [e1.MoveNext(), e2.MoveNext()];
if (matchValue$$7[0]) {
if (matchValue$$7[1]) {
const kvp1 = e1.Current;
const kvp2 = e2.Current;
const c$$10 = m$$22.comparer.Compare(kvp1[0], kvp2[0]) | 0;
res$$4 = c$$10 !== 0 ? c$$10 : compare(kvp1[1], kvp2[1]);
} else {
res$$4 = 1;
}
} else if (matchValue$$7[1]) {
res$$4 = -1;
} else {
finished = true;
}
}
return res$$4 | 0;
} finally {
if (isDisposable(e2)) {
e2.Dispose();
}
}
} finally {
if (isDisposable(e1)) {
e1.Dispose();
}
}
};
Object.defineProperty(FSharpMap.prototype, "size", {
"get": function () {
const this$$$3 = this;
return FSharpMap$$get_Count(this$$$3) | 0;
}
});
FSharpMap.prototype.clear = function () {
throw new Error("Map cannot be mutated");
};
FSharpMap.prototype.delete = function (_arg1$$1) {
throw new Error("Map cannot be mutated");
};
FSharpMap.prototype.entries = function () {
const this$$$4 = this;
return MapTreeModule$$$toSeq(FSharpMap$$get_Tree(this$$$4));
};
FSharpMap.prototype.get = function (k$$34) {
const this$$$5 = this;
return FSharpMap$$get_Item$$2B595(this$$$5, k$$34);
};
FSharpMap.prototype.has = function (k$$35) {
const this$$$6 = this;
return FSharpMap$$ContainsKey$$2B595(this$$$6, k$$35);
};
FSharpMap.prototype.keys = function () {
const this$$$7 = this;
const source$$1 = MapTreeModule$$$toSeq(FSharpMap$$get_Tree(this$$$7));
return map$1(function mapping$$1(kv$$1) {
return kv$$1[0];
}, source$$1);
};
FSharpMap.prototype.set = function (k$$36, v$$26) {
throw new Error("Map cannot be mutated");
};
FSharpMap.prototype.values = function () {
const this$$$8 = this;
const source$$2 = MapTreeModule$$$toSeq(FSharpMap$$get_Tree(this$$$8));
return map$1(function mapping$$2(kv$$2) {
return kv$$2[1];
}, source$$2);
};
function find(k$$38, m$$25) {
return FSharpMap$$get_Item$$2B595(m$$25, k$$38);
}
function containsKey(k$$41, m$$28) {
return FSharpMap$$ContainsKey$$2B595(m$$28, k$$41);
}
function ofList(l$$22, comparer$$18) {
return FSharpMap$$$$002Ector$$58ADD115(comparer$$18, MapTreeModule$$$ofList(comparer$$18, l$$22));
}
function createMutable(source$$5, comparer$$23) {
const map$$1 = MutableMap$00602$$$$002Ector$$6623D9B3(source$$5, comparer$$23);
return map$$1;
}
const MutableSet$00601 = declare(function Fable_Collections_MutableSet(items, comparer) {
const $this$$1 = this;
const this$ = new FSharpRef(null);
$this$$1.comparer = comparer;
this$.contents = $this$$1;
$this$$1["entries@24"] = new Map([]);
$this$$1["init@21-2"] = 1;
iterate(function (item) {
const value = MutableSet$00601$$Add$$2B595(this$.contents, item);
}, items);
});
function MutableSet$00601$$$$002Ector$$Z6150332D(items, comparer) {
return this instanceof MutableSet$00601 ? MutableSet$00601.call(this, items, comparer) : new MutableSet$00601(items, comparer);
}
function MutableSet$00601$$TryFindIndex$$2B595(this$$$1, k) {
const h = this$$$1.comparer.GetHashCode(k) | 0;
const matchValue = tryGetValue(this$$$1["entries@24"], h, null);
if (matchValue[0]) {
return [true, h, matchValue[1].findIndex(function (v) {
return this$$$1.comparer.Equals(k, v);
})];
} else {
return [false, h, -1];
}
}
function MutableSet$00601$$Clear(this$$$4) {
this$$$4["entries@24"].clear();
}
function MutableSet$00601$$get_Count(this$$$5) {
const source = this$$$5["entries@24"].values();
return sumBy(function projection(pairs) {
return pairs.length;
}, source, {
GetZero() {
return 0;
},
Add($x$$2, $y$$3) {
return $x$$2 + $y$$3;
}
}) | 0;
}
function MutableSet$00601$$Add$$2B595(this$$$6, k$$2) {
const matchValue$$2 = MutableSet$00601$$TryFindIndex$$2B595(this$$$6, k$$2);
var $target$$16;
if (matchValue$$2[0]) {
if (matchValue$$2[2] > -1) {
$target$$16 = 0;
} else {
$target$$16 = 1;
}
} else {
$target$$16 = 1;
}
switch ($target$$16) {
case 0:
{
return false;
}
case 1:
{
if (matchValue$$2[0]) {
const value$$1 = getItemFromDict(this$$$6["entries@24"], matchValue$$2[1]).push(k$$2);
return true;
} else {
this$$$6["entries@24"].set(matchValue$$2[1], [k$$2]);
return true;
}
}
}
}
function MutableSet$00601$$Contains$$2B595(this$$$7, k$$3) {
const matchValue$$3 = MutableSet$00601$$TryFindIndex$$2B595(this$$$7, k$$3);
var $target$$19;
if (matchValue$$3[0]) {
if (matchValue$$3[2] > -1) {
$target$$19 = 0;
} else {
$target$$19 = 1;
}
} else {
$target$$19 = 1;
}
switch ($target$$19) {
case 0:
{
return true;
}
case 1:
{
return false;
}
}
}
function MutableSet$00601$$Remove$$2B595(this$$$8, k$$4) {
const matchValue$$4 = MutableSet$00601$$TryFindIndex$$2B595(this$$$8, k$$4);
var $target$$22;
if (matchValue$$4[0]) {
if (matchValue$$4[2] > -1) {
$target$$22 = 0;
} else {
$target$$22 = 1;
}
} else {
$target$$22 = 1;
}
switch ($target$$22) {
case 0:
{
getItemFromDict(this$$$8["entries@24"], matchValue$$4[1]).splice(matchValue$$4[2], 1);
return true;
}
case 1:
{
return false;
}
}
}
MutableSet$00601.prototype[Symbol.iterator] = function () {
var elems;
const this$$$9 = this;
return toIterator((elems = delay(function () {
return collect(function (values$$1) {
return map$1(function (value$$2) {
return value$$2;
}, values$$1);
}, this$$$9["entries@24"].values());
}), getEnumerator(elems)));
};
MutableSet$00601.prototype.Add = function (item$$1) {
const this$$$10 = this;
const value$$3 = MutableSet$00601$$Add$$2B595(this$$$10, item$$1);
};
MutableSet$00601.prototype.Clear = function () {
const this$$$11 = this;
MutableSet$00601$$Clear(this$$$11);
};
MutableSet$00601.prototype.Contains = function (item$$2) {
const this$$$12 = this;
return MutableSet$00601$$Contains$$2B595(this$$$12, item$$2);
};
MutableSet$00601.prototype.CopyTo = function (array, arrayIndex) {
const this$$$13 = this;
iterateIndexed(function action(i$$8, e) {
array[arrayIndex + i$$8] = e;
}, this$$$13);
};
Object.defineProperty(MutableSet$00601.prototype, "Count", {
"get": function () {
const this$$$14 = this;
return MutableSet$00601$$get_Count(this$$$14) | 0;
}
});
Object.defineProperty(MutableSet$00601.prototype, "IsReadOnly", {
"get": function () {
return false;
}
});
MutableSet$00601.prototype.Remove = function (item$$3) {
const this$$$16 = this;
return MutableSet$00601$$Remove$$2B595(this$$$16, item$$3);
};
Object.defineProperty(MutableSet$00601.prototype, "size", {
"get": function () {
const this$$$17 = this;
return MutableSet$00601$$get_Count(this$$$17) | 0;
}
});
MutableSet$00601.prototype.add = function (k$$5) {
const this$$$18 = this;
const value$$4 = MutableSet$00601$$Add$$2B595(this$$$18, k$$5);
return this$$$18;
};
MutableSet$00601.prototype.add_ = function (k$$6) {
const this$$$19 = this;
return MutableSet$00601$$Add$$2B595(this$$$19, k$$6);
};
MutableSet$00601.prototype.clear = function () {
const this$$$20 = this;
MutableSet$00601$$Clear(this$$$20);
};
MutableSet$00601.prototype.delete = function (k$$7) {
const this$$$21 = this;
return MutableSet$00601$$Remove$$2B595(this$$$21, k$$7);
};
MutableSet$00601.prototype.has = function (k$$8) {
const this$$$22 = this;
return MutableSet$00601$$Contains$$2B595(this$$$22, k$$8);
};
MutableSet$00601.prototype.keys = function () {
const this$$$23 = this;
return map$1(function mapping(x) {
return x;
}, this$$$23);
};
MutableSet$00601.prototype.values = function () {
const this$$$24 = this;
return map$1(function mapping$$1(x$$1) {
return x$$1;
}, this$$$24);
};
MutableSet$00601.prototype.entries = function () {
const this$$$25 = this;
return map$1(function mapping$$2(v$$1) {
return [v$$1, v$$1];
}, this$$$25);
};
const SetTree$00601 = declare(function Set_SetTree(tag, name, ...fields) {
Union.call(this, tag, name, ...fields);
}, Union);
function SetTreeModule$$$SetOne(n) {
return new SetTree$00601(2, "SetOne", n);
}
function SetTreeModule$$$SetNode(x, l$$1, r$$1, h) {
return new SetTree$00601(1, "SetNode", x, l$$1, r$$1, h);
}
function SetTreeModule$$$height(t) {
switch (t.tag) {
case 2:
{
return 1;
}
case 1:
{
return t.fields[3] | 0;
}
default:
{
return 0;
}
}
}
const SetTreeModule$$$tolerance = 2;
function SetTreeModule$$$mk(l$$2, k, r$$2) {
var $target$$16;
if (l$$2.tag === 0) {
if (r$$2.tag === 0) {
$target$$16 = 0;
} else {
$target$$16 = 1;
}
} else {
$target$$16 = 1;
}
switch ($target$$16) {
case 0:
{
return SetTreeModule$$$SetOne(k);
}
case 1:
{
const hl = SetTreeModule$$$height(l$$2) | 0;
const hr = SetTreeModule$$$height(r$$2) | 0;
const m = (hl < hr ? hr : hl) | 0;
return SetTreeModule$$$SetNode(k, l$$2, r$$2, m + 1);
}
}
}
function SetTreeModule$$$rebalance(t1, k$$1, t2) {
const t1h = SetTreeModule$$$height(t1) | 0;
const t2h = SetTreeModule$$$height(t2) | 0;
if (t2h > t1h + SetTreeModule$$$tolerance) {
if (t2.tag === 1) {
if (SetTreeModule$$$height(t2.fields[1]) > t1h + 1) {
if (t2.fields[1].tag === 1) {
return SetTreeModule$$$mk(SetTreeModule$$$mk(t1, k$$1, t2.fields[1].fields[1]), t2.fields[1].fields[0], SetTreeModule$$$mk(t2.fields[1].fields[2], t2.fields[0], t2.fields[2]));
} else {
throw new Error("rebalance");
}
} else {
return SetTreeModule$$$mk(SetTreeModule$$$mk(t1, k$$1, t2.fields[1]), t2.fields[0], t2.fields[2]);
}
} else {
throw new Error("rebalance");
}
} else if (t1h > t2h + SetTreeModule$$$tolerance) {
if (t1.tag === 1) {
if (SetTreeModule$$$height(t1.fields[2]) > t2h + 1) {
if (t1.fields[2].tag === 1) {
return SetTreeModule$$$mk(SetTreeModule$$$mk(t1.fields[1], t1.fields[0], t1.fields[2].fields[1]), t1.fields[2].fields[0], SetTreeModule$$$mk(t1.fields[2].fields[2], k$$1, t2));
} else {
throw new Error("rebalance");
}
} else {
return SetTreeModule$$$mk(t1.fields[1], t1.fields[0], SetTreeModule$$$mk(t1.fields[2], k$$1, t2));
}
} else {
throw new Error("rebalance");
}
} else {
return SetTreeModule$$$mk(t1, k$$1, t2);
}
}
function SetTreeModule$$$add(comparer, k$$2, t$$1) {
switch (t$$1.tag) {
case 2:
{
const c$$1 = comparer.Compare(k$$2, t$$1.fields[0]) | 0;
if (c$$1 < 0) {
return SetTreeModule$$$SetNode(k$$2, new SetTree$00601(0, "SetEmpty"), t$$1, 2);
} else if (c$$1 === 0) {
return t$$1;
} else {
return SetTreeModule$$$SetNode(k$$2, t$$1, new SetTree$00601(0, "SetEmpty"), 2);
}
}
case 0:
{
return SetTreeModule$$$SetOne(k$$2);
}
default:
{
const c = comparer.Compare(k$$2, t$$1.fields[0]) | 0;
if (c < 0) {
return SetTreeModule$$$rebalance(SetTreeModule$$$add(comparer, k$$2, t$$1.fields[1]), t$$1.fields[0], t$$1.fields[2]);
} else if (c === 0) {
return t$$1;
} else {
return SetTreeModule$$$rebalance(t$$1.fields[1], t$$1.fields[0], SetTreeModule$$$add(comparer, k$$2, t$$1.fields[2]));
}
}
}
}
function SetTreeModule$$$mem($comparer$$4$$35, $k$$5$$36, $t$$5$$37) {
SetTreeModule$$$mem: while (true) {
const comparer$$4 = $comparer$$4$$35,
k$$5 = $k$$5$$36,
t$$5 = $t$$5$$37;
switch (t$$5.tag) {
case 2:
{
return comparer$$4.Compare(k$$5, t$$5.fields[0]) === 0;
}
case 0:
{
return false;
}
default:
{
const c$$6 = comparer$$4.Compare(k$$5, t$$5.fields[0]) | 0;
if (c$$6 < 0) {
$comparer$$4$$35 = comparer$$4;
$k$$5$$36 = k$$5;
$t$$5$$37 = t$$5.fields[1];
continue SetTreeModule$$$mem;
} else if (c$$6 === 0) {
return true;
} else {
$comparer$$4$$35 = comparer$$4;
$k$$5$$36 = k$$5;
$t$$5$$37 = t$$5.fields[2];
continue SetTreeModule$$$mem;
}
}
}
}
}
const SetTreeModule$002ESetIterator$00601 = declare(function Set_SetTreeModule_SetIterator(arg1, arg2) {
this.stack = arg1;
this.started = arg2;
}, Record);
function SetTreeModule$$$collapseLHS($stack$$104) {
SetTreeModule$$$collapseLHS: while (true) {
const stack = $stack$$104;
if (stack.tail != null) {
if (stack.head.tag === 2) {
return stack;
} else if (stack.head.tag === 1) {
$stack$$104 = new List(stack.head.fields[1], new List(SetTreeModule$$$SetOne(stack.head.fields[0]), new List(stack.head.fields[2], stack.tail)));
continue SetTreeModule$$$collapseLHS;
} else {
$stack$$104 = stack.tail;
continue SetTreeModule$$$collapseLHS;
}
} else {
return new List();
}
}
}
function SetTreeModule$$$mkIterator(s$$13) {
return new SetTreeModule$002ESetIterator$00601(SetTreeModule$$$collapseLHS(new List(s$$13, new List())), false);
}
function SetTreeModule$$$notStarted() {
throw new Error("Enumeration not started");
}
function SetTreeModule$$$alreadyFinished() {
throw new Error("Enumeration already started");
}
function SetTreeModule$$$current(i) {
if (i.started) {
const matchValue$$6 = i.stack;
if (matchValue$$6.tail == null) {
return SetTreeModule$$$alreadyFinished();
} else if (matchValue$$6.head.tag === 2) {
return matchValue$$6.head.fields[0];
} else {
throw new Error("Please report error: Set iterator, unexpected stack for current");
}
} else {
return SetTreeModule$$$notStarted();
}
}
function SetTreeModule$$$moveNext(i$$1) {
if (i$$1.started) {
const matchValue$$7 = i$$1.stack;
if (matchValue$$7.tail == null) {
return false;
} else if (matchValue$$7.head.tag === 2) {
i$$1.stack = SetTreeModule$$$collapseLHS(matchValue$$7.tail);
return !(i$$1.stack.tail == null);
} else {
throw new Error("Please report error: Set iterator, unexpected stack for moveNext");
}
} else {
i$$1.started = true;
return !(i$$1.stack.tail == null);
}
}
const SetTreeModule$002EmkIEnumerator$00601 = declare(function Set_SetTreeModule_mkIEnumerator(s$$14) {
const $this$$1 = this;
$this$$1.s = s$$14;
$this$$1.i = SetTreeModule$$$mkIterator($this$$1.s);
});
function SetTreeModule$002EmkIEnumerator$00601$$$$002Ector$$Z5B395D56(s$$14) {
return this instanceof SetTreeModule$002EmkIEnumerator$00601 ? SetTreeModule$002EmkIEnumerator$00601.call(this, s$$14) : new SetTreeModule$002EmkIEnumerator$00601(s$$14);
}
Object.defineProperty(SetTreeModule$002EmkIEnumerator$00601.prototype, "Current", {
"get": function () {
const __ = this;
return SetTreeModule$$$current(__.i);
}
});
SetTreeModule$002EmkIEnumerator$00601.prototype.MoveNext = function () {
const __$$1 = this;
return SetTreeModule$$$moveNext(__$$1.i);
};
SetTreeModule$002EmkIEnumerator$00601.prototype.Reset = function () {
const __$$2 = this;
__$$2.i = SetTreeModule$$$mkIterator(__$$2.s);
};
SetTreeModule$002EmkIEnumerator$00601.prototype.Dispose = function () {};
function SetTreeModule$$$mkIEnumerator(s$$15) {
return SetTreeModule$002EmkIEnumerator$00601$$$$002Ector$$Z5B395D56(s$$15);
}
function SetTreeModule$$$compareStacks($comparer$$17$$112, $l1$$113, $l2$$114) {
SetTreeModule$$$compareStacks: while (true) {
const comparer$$17 = $comparer$$17$$112,
l1 = $l1$$113,
l2 = $l2$$114;
var $target$$115, t1$$6, t2$$6, n1k, n2k, t1$$7, t2$$7, n1k$$1, n2k$$1, n2r, t1$$8, t2$$8, emp, n1k$$2, n1r, n2k$$2, t1$$9, t2$$9, n1k$$3, n1r$$1, n2k$$3, n2r$$1, t1$$10, t2$$10, n1k$$4, t1$$11, n1k$$5, n1l, n1r$$2, t1$$12, n2k$$4, t2$$11, n2k$$5, n2l, n2r$$2, t2$$12;
if (l1.tail != null) {
if (l2.tail != null) {
if (l2.head.tag === 2) {
if (l1.head.tag === 2) {
$target$$115 = 4;
n1k = l1.head.fields[0];
n2k = l2.head.fields[0];
t1$$7 = l1.tail;
t2$$7 = l2.tail;
} else if (l1.head.tag === 1) {
if (l1.head.fields[1].tag === 0) {
$target$$115 = 6;
emp = l1.head.fields[1];
n1k$$2 = l1.head.fields[0];
n1r = l1.head.fields[2];
n2k$$2 = l2.head.fields[0];
t1$$9 = l1.tail;
t2$$9 = l2.tail;
} else {
$target$$115 = 9;
n1k$$5 = l1.head.fields[0];
n1l = l1.head.fields[1];
n1r$$2 = l1.head.fields[2];
t1$$12 = l1.tail;
}
} else {
$target$$115 = 10;
n2k$$4 = l2.head.fields[0];
t2$$11 = l2.tail;
}
} else if (l2.head.tag === 1) {
if (l2.head.fields[1].tag === 0) {
if (l1.head.tag === 2) {
$target$$115 = 5;
n1k$$1 = l1.head.fields[0];
n2k$$1 = l2.head.fields[0];
n2r = l2.head.fields[2];
t1$$8 = l1.tail;
t2$$8 = l2.tail;
} else if (l1.head.tag === 1) {
if (l1.head.fields[1].tag === 0) {
$target$$115 = 7;
n1k$$3 = l1.head.fields[0];
n1r$$1 = l1.head.fields[2];
n2k$$3 = l2.head.fields[0];
n2r$$1 = l2.head.fields[2];
t1$$10 = l1.tail;
t2$$10 = l2.tail;
} else {
$target$$115 = 9;
n1k$$5 = l1.head.fields[0];
n1l = l1.head.fields[1];
n1r$$2 = l1.head.fields[2];
t1$$12 = l1.tail;
}
} else {
$target$$115 = 11;
n2k$$5 = l2.head.fields[0];
n2l = l2.head.fields[1];
n2r$$2 = l2.head.fields[2];
t2$$12 = l2.tail;
}
} else if (l1.head.tag === 2) {
$target$$115 = 8;
n1k$$4 = l1.head.fields[0];
t1$$11 = l1.tail;
} else if (l1.head.tag === 1) {
$target$$115 = 9;
n1k$$5 = l1.head.fields[0];
n1l = l1.head.fields[1];
n1r$$2 = l1.head.fields[2];
t1$$12 = l1.tail;
} else {
$target$$115 = 11;
n2k$$5 = l2.head.fields[0];
n2l = l2.head.fields[1];
n2r$$2 = l2.head.fields[2];
t2$$12 = l2.tail;
}
} else if (l1.head.tag === 2) {
$target$$115 = 8;
n1k$$4 = l1.head.fields[0];
t1$$11 = l1.tail;
} else if (l1.head.tag === 1) {
$target$$115 = 9;
n1k$$5 = l1.head.fields[0];
n1l = l1.head.fields[1];
n1r$$2 = l1.head.fields[2];
t1$$12 = l1.tail;
} else {
$target$$115 = 3;
t1$$6 = l1.tail;
t2$$6 = l2.tail;
}
} else {
$target$$115 = 2;
}
} else if (l2.tail != null) {
$target$$115 = 1;
} else {
$target$$115 = 0;
}
switch ($target$$115) {
case 0:
{
return 0;
}
case 1:
{
return -1 | 0;
}
case 2:
{
return 1;
}
case 3:
{
$comparer$$17$$112 = comparer$$17;
$l1$$113 = t1$$6;
$l2$$114 = t2$$6;
continue SetTreeModule$$$compareStacks;
}
case 4:
{
const c$$7 = comparer$$17.Compare(n1k, n2k) | 0;
if (c$$7 !== 0) {
return c$$7 | 0;
} else {
$comparer$$17$$112 = comparer$$17;
$l1$$113 = t1$$7;
$l2$$114 = t2$$7;
continue SetTreeModule$$$compareStacks;
}
}
case 5:
{
const c$$8 = comparer$$17.Compare(n1k$$1, n2k$$1) | 0;
if (c$$8 !== 0) {
return c$$8 | 0;
} else {
$comparer$$17$$112 = comparer$$17;
$l1$$113 = new List(new SetTree$00601(0, "SetEmpty"), t1$$8);
$l2$$114 = new List(n2r, t2$$8);
continue SetTreeModule$$$compareStacks;
}
}
case 6:
{
const c$$9 = comparer$$17.Compare(n1k$$2, n2k$$2) | 0;
if (c$$9 !== 0) {
return c$$9 | 0;
} else {
$comparer$$17$$112 = comparer$$17;
$l1$$113 = new List(n1r, t1$$9);
$l2$$114 = new List(emp, t2$$9);
continue SetTreeModule$$$compareStacks;
}
}
case 7:
{
const c$$10 = comparer$$17.Compare(n1k$$3, n2k$$3) | 0;
if (c$$10 !== 0) {
return c$$10 | 0;
} else {
$comparer$$17$$112 = comparer$$17;
$l1$$113 = new List(n1r$$1, t1$$10);
$l2$$114 = new List(n2r$$1, t2$$10);
continue SetTreeModule$$$compareStacks;
}
}
case 8:
{
$comparer$$17$$112 = comparer$$17;
$l1$$113 = new List(new SetTree$00601(0, "SetEmpty"), new List(SetTreeModule$$$SetOne(n1k$$4), t1$$11));
$l2$$114 = l2;
continue SetTreeModule$$$compareStacks;
}
case 9:
{
$comparer$$17$$112 = comparer$$17;
$l1$$113 = new List(n1l, new List(SetTreeModule$$$SetNode(n1k$$5, new SetTree$00601(0, "SetEmpty"), n1r$$2, 0), t1$$12));
$l2$$114 = l2;
continue SetTreeModule$$$compareStacks;
}
case 10:
{
$comparer$$17$$112 = comparer$$17;
$l1$$113 = l1;
$l2$$114 = new List(new SetTree$00601(0, "SetEmpty"), new List(SetTreeModule$$$SetOne(n2k$$4), t2$$11));
continue SetTreeModule$$$compareStacks;
}
case 11:
{
$comparer$$17$$112 = comparer$$17;
$l1$$113 = l1;
$l2$$114 = new List(n2l, new List(SetTreeModule$$$SetNode(n2k$$5, new SetTree$00601(0, "SetEmpty"), n2r$$2, 0), t2$$12));
continue SetTreeModule$$$compareStacks;
}
}
break;
}
}
function SetTreeModule$$$compare(comparer$$18, s1, s2) {
if (s1.tag === 0) {
if (s2.tag === 0) {
return 0;
} else {
return -1 | 0;
}
} else if (s2.tag === 0) {
return 1;
} else {
return SetTreeModule$$$compareStacks(comparer$$18, new List(s1, new List()), new List(s2, new List())) | 0;
}
}
function SetTreeModule$$$mkFromEnumerator($comparer$$19$$126, $acc$$11$$127, $e$$128) {
SetTreeModule$$$mkFromEnumerator: while (true) {
const comparer$$19 = $comparer$$19$$126,
acc$$11 = $acc$$11$$127,
e = $e$$128;
if (e.MoveNext()) {
$comparer$$19$$126 = comparer$$19;
$acc$$11$$127 = SetTreeModule$$$add(comparer$$19, e.Current, acc$$11);
$e$$128 = e;
continue SetTreeModule$$$mkFromEnumerator;
} else {
return acc$$11;
}
}
}
function SetTreeModule$$$ofSeq(comparer$$20, c$$11) {
const ie = getEnumerator(c$$11);
try {
return SetTreeModule$$$mkFromEnumerator(comparer$$20, new SetTree$00601(0, "SetEmpty"), ie);
} finally {
if (isDisposable(ie)) {
ie.Dispose();
}
}
}
const FSharpSet = declare(function Set_Set(comparer$$22, tree) {
const $this$$2 = this;
$this$$2.comparer = comparer$$22;
$this$$2.tree = tree;
});
function FSharpSet$$$$002Ector$$2528C5CB(comparer$$22, tree) {
return this instanceof FSharpSet ? FSharpSet.call(this, comparer$$22, tree) : new FSharpSet(comparer$$22, tree);
}
function FSharpSet$$get_Comparer(__$$4) {
return __$$4.comparer;
}
function FSharpSet$$get_Tree(__$$5) {
return __$$5.tree;
}
function FSharpSet$$Contains$$2B595(s$$23, x$$11) {
return SetTreeModule$$$mem(FSharpSet$$get_Comparer(s$$23), x$$11, FSharpSet$$get_Tree(s$$23));
}
FSharpSet.prototype.toString = function () {
var strings;
const this$ = this;
return "set [" + (strings = map$1(function (x$$21) {
let copyOfStruct = x$$21;
return String(copyOfStruct);
}, this$), join("; ", strings)) + "]";
};
FSharpSet.prototype.GetHashCode = function () {
const this$$$1 = this;
let res = 0;
const e$$1 = SetTreeModule$$$mkIEnumerator(FSharpSet$$get_Tree(this$$$1));
while (e$$1.MoveNext()) {
const x$$22 = res | 0;
const y$$4 = structuralHash(e$$1.Current) | 0;
res = (x$$22 << 1) + y$$4 + 631;
}
return Math.abs(res) | 0;
};
FSharpSet.prototype.Equals = function (that) {
const this$$$2 = this;
return SetTreeModule$$$compare(FSharpSet$$get_Comparer(this$$$2), FSharpSet$$get_Tree(this$$$2), FSharpSet$$get_Tree(that)) === 0;
};
FSharpSet.prototype.CompareTo = function (that$$1) {
const this$$$3 = this;
return SetTreeModule$$$compare(FSharpSet$$get_Comparer(this$$$3), FSharpSet$$get_Tree(this$$$3), FSharpSet$$get_Tree(that$$1)) | 0;
};
FSharpSet.prototype[Symbol.iterator] = function () {
const s$$32 = this;
return toIterator(SetTreeModule$$$mkIEnumerator(FSharpSet$$get_Tree(s$$32)));
};
function contains(x$$23, s$$34) {
return FSharpSet$$Contains$$2B595(s$$34, x$$23);
}
function ofList$1(li, comparer$$28) {
return FSharpSet$$$$002Ector$$2528C5CB(comparer$$28, SetTreeModule$$$ofSeq(comparer$$28, li));
}
function ofSeq(elements, comparer$$30) {
return FSharpSet$$$$002Ector$$2528C5CB(comparer$$30, SetTreeModule$$$ofSeq(comparer$$30, elements));
}
function createMutable$1(source$$1, comparer$$32) {
const set = MutableSet$00601$$$$002Ector$$Z6150332D(source$$1, comparer$$32);
return set;
}
function contains$1(value$$4, array$$22, eq$$3) {
const loop = function loop($i$$12$$79) {
loop: while (true) {
const i$$12 = $i$$12$$79;
if (i$$12 >= array$$22.length) {
return false;
} else if (eq$$3.Equals(value$$4, array$$22[i$$12])) {
return true;
} else {
$i$$12$$79 = i$$12 + 1;
continue loop;
}
}
};
return loop(0);
}
function addRangeInPlace(range, array$$47) {
iterate(function (x$$3) {
const value$$7 = array$$47.push(x$$3);
}, range);
}
function ofList$2(source$$8, cons$$32) {
return cons$$32.from(source$$8);
}
function toList(source$$9) {
const len$$18 = source$$9.length | 0;
let target$$7 = new List();
for (let i$$49 = len$$18 - 1; i$$49 >= 0; i$$49--) {
target$$7 = new List(source$$9[i$$49], target$$7);
}
return target$$7;
}
function head(_arg1) {
if (_arg1.tail != null) {
return _arg1.head;
} else {
throw new Error("List was empty");
}
}
function tail(_arg1$$2) {
if (_arg1$$2.tail != null) {
return _arg1$$2.tail;
} else {
throw new Error("List was empty");
}
}
function foldIndexedAux($f$$12, $i$$13, $acc$$14, $_arg1$$5$$15) {
foldIndexedAux: while (true) {
const f = $f$$12,
i = $i$$13,
acc = $acc$$14,
_arg1$$5 = $_arg1$$5$$15;
if (_arg1$$5.tail != null) {
$f$$12 = f;
$i$$13 = i + 1;
$acc$$14 = f(i, acc, _arg1$$5.head);
$_arg1$$5$$15 = _arg1$$5.tail;
continue foldIndexedAux;
} else {
return acc;
}
}
}
function foldIndexed(f$$1, state, xs$$7) {
return foldIndexedAux(f$$1, 0, state, xs$$7);
}
function fold$1($f$$2$$19, $state$$1$$20, $xs$$8$$21) {
fold: while (true) {
const f$$2 = $f$$2$$19,
state$$1 = $state$$1$$20,
xs$$8 = $xs$$8$$21;
if (xs$$8.tail != null) {
$f$$2$$19 = f$$2;
$state$$1$$20 = f$$2(state$$1, xs$$8.head);
$xs$$8$$21 = xs$$8.tail;
continue fold;
} else {
return state$$1;
}
}
}
function reverse(xs$$9) {
return fold$1(function (acc$$1, x$$6) {
return new List(x$$6, acc$$1);
}, new List(), xs$$9);
}
function ofSeq$1(xs$$12) {
const xs$$13 = fold(function (acc$$3, x$$9) {
return new List(x$$9, acc$$3);
}, new List(), xs$$12);
return reverse(xs$$13);
}
function concat$1(lists) {
const xs$$15 = fold(function (state$$3, xs$$14) {
return fold$1(function f$$4(acc$$4, x$$10) {
return new List(x$$10, acc$$4);
}, state$$3, xs$$14);
}, new List(), lists);
return reverse(xs$$15);
}
function length(xs$$27) {
return fold$1(function (acc$$9, _arg1$$7) {
return acc$$9 + 1;
}, 0, xs$$27);
}
function append$1(xs$$28, ys$$10) {
return fold$1(function (acc$$10, x$$15) {
return new List(x$$15, acc$$10);
}, ys$$10, reverse(xs$$28));
}
function collect$1(f$$15, xs$$29) {
const xs$$30 = collect(f$$15, xs$$29);
return ofSeq$1(xs$$30);
}
function map$2(f$$16, xs$$31) {
const xs$$32 = fold$1(function (acc$$11, x$$16) {
return new List(f$$16(x$$16), acc$$11);
}, new List(), xs$$31);
return reverse(xs$$32);
}
function mapIndexed(f$$17, xs$$33) {
const xs$$34 = foldIndexed(function (i$$3, acc$$12, x$$17) {
return new List(f$$17(i$$3, x$$17), acc$$12);
}, new List(), xs$$33);
return reverse(xs$$34);
}
function iterate$1(f$$24, xs$$46) {
fold$1(function (unitVar0, x$$24) {
f$$24(x$$24);
}, null, xs$$46);
}
function iterateIndexed$1(f$$26, xs$$48) {
foldIndexed(function (i$$7, unitVar1, x$$26) {
f$$26(i$$7, x$$26);
}, null, xs$$48);
}
function ofArray(xs$$50) {
let res$$1 = new List();
for (let i$$9 = count(xs$$50) - 1; i$$9 >= 0; i$$9--) {
res$$1 = new List(xs$$50[i$$9], res$$1);
}
return res$$1;
}
function isEmpty$1(_arg1$$8) {
if (_arg1$$8.tail == null) {
return true;
} else {
return false;
}
}
function tryPickIndexedAux($f$$28$$120, $i$$10$$121, $_arg1$$9$$122) {
tryPickIndexedAux: while (true) {
const f$$28 = $f$$28$$120,
i$$10 = $i$$10$$121,
_arg1$$9 = $_arg1$$9$$122;
if (_arg1$$9.tail != null) {
const result = f$$28(i$$10, _arg1$$9.head);
if (result == null) {
$f$$28$$120 = f$$28;
$i$$10$$121 = i$$10 + 1;
$_arg1$$9$$122 = _arg1$$9.tail;
continue tryPickIndexedAux;
} else {
return result;
}
} else {
return null;
}
}
}
function tryPickIndexed(f$$29, xs$$52) {
return tryPickIndexedAux(f$$29, 0, xs$$52);
}
function tryPick(f$$30, xs$$53) {
return tryPickIndexed(function (_arg1$$10, x$$29) {
return f$$30(x$$29);
}, xs$$53);
}
function tryFindIndexed(f$$32, xs$$55) {
return tryPickIndexed(function (i$$11, x$$31) {
return f$$32(i$$11, x$$31) ? some(x$$31) : null;
}, xs$$55);
}
function tryFind$1(f$$33, xs$$56) {
return tryPickIndexed(function (_arg1$$11, x$$32) {
return f$$33(x$$32) ? some(x$$32) : null;
}, xs$$56);
}
function findIndexed(f$$34, xs$$57) {
const matchValue$$6 = tryFindIndexed(f$$34, xs$$57);
if (matchValue$$6 != null) {
const x$$33 = value(matchValue$$6);
return x$$33;
} else {
throw new Error("List did not contain any matching elements");
}
}
function item(n, xs$$69) {
return findIndexed(function (i$$13, _arg1$$13) {
return n === i$$13;
}, xs$$69);
}
function filter$1(f$$42, xs$$71) {
const xs$$72 = fold$1(function (acc$$17, x$$37) {
return f$$42(x$$37) ? new List(x$$37, acc$$17) : acc$$17;
}, new List(), xs$$71);
return reverse(xs$$72);
}
function partition(f$$43, xs$$73) {
return fold$1(function (tupledArg$$1, x$$38) {
return f$$43(x$$38) ? [new List(x$$38, tupledArg$$1[0]), tupledArg$$1[1]] : [tupledArg$$1[0], new List(x$$38, tupledArg$$1[1])];
}, [new List(), new List()], reverse(xs$$73));
}
function choose(f$$44, xs$$74) {
const xs$$75 = fold$1(function (acc$$18, x$$39) {
const matchValue$$8 = f$$44(x$$39);
if (matchValue$$8 == null) {
return acc$$18;
} else {
const y$$10 = value(matchValue$$8);
return new List(y$$10, acc$$18);
}
}, new List(), xs$$74);
return reverse(xs$$75);
}
function contains$2(value, list, eq) {
const loop$$1 = function loop$$1($xs$$76$$162) {
loop$$1: while (true) {
const xs$$76 = $xs$$76$$162;
if (xs$$76.tail != null) {
if (eq.Equals(value, xs$$76.head)) {
return true;
} else {
$xs$$76$$162 = xs$$76.tail;
continue loop$$1;
}
} else {
return false;
}
}
};
return loop$$1(list);
}
function except(itemsToExclude, array$$2, eq$$1) {
if (isEmpty$1(array$$2)) {
return array$$2;
} else {
const cached = createMutable$1(itemsToExclude, eq$$1);
return filter$1(function f$$45(arg00) {
return addToSet(arg00, cached);
}, array$$2);
}
}
function exists$1($f$$51$$180, $_arg1$$18$$181) {
exists: while (true) {
const f$$51 = $f$$51$$180,
_arg1$$18 = $_arg1$$18$$181;
if (_arg1$$18.tail != null) {
if (f$$51(_arg1$$18.head)) {
return true;
} else {
$f$$51$$180 = f$$51;
$_arg1$$18$$181 = _arg1$$18.tail;
continue exists;
}
} else {
return false;
}
}
}
function sort(xs$$87, comparer$$1) {
let xs$$89;
const xs$$88 = ofList$2(xs$$87, Array);
xs$$88.sort(function comparer$$2(x$$49, y$$17) {
return comparer$$1.Compare(x$$49, y$$17);
});
xs$$89 = xs$$88;
return ofArray(xs$$89);
}
function outOfRange() {
throw new Error("Index out of range");
}
function slice(lower, upper, xs$$132) {
const lower$$1 = defaultArg(lower, 0) | 0;
const hasUpper = upper != null;
if (lower$$1 < 0) {
return outOfRange();
} else if (hasUpper ? upper < lower$$1 : false) {
return new List();
} else {
let lastIndex = -1 | 0;
let res$$2;
const state$$13 = new List();
res$$2 = foldIndexed(function f$$57(i$$34, acc$$26, x$$67) {
lastIndex = i$$34;
if (lower$$1 <= i$$34 ? !hasUpper ? true : i$$34 <= upper : false) {
return new List(x$$67, acc$$26);
} else {
return acc$$26;
}
}, state$$13, xs$$132);
if (lower$$1 > lastIndex + 1 ? true : hasUpper ? upper > lastIndex : false) {
outOfRange();
}
return reverse(res$$2);
}
}
function distinctBy(projection$$4, xs$$134, eq$$2) {
const hashSet = createMutable$1([], eq$$2);
return filter$1(function f$$58($arg$$1) {
const arg00$$1 = projection$$4($arg$$1);
return addToSet(arg00$$1, hashSet);
}, xs$$134);
}
function distinct(xs$$136, eq$$3) {
return distinctBy(function (x$$68) {
return x$$68;
}, xs$$136, eq$$3);
}
const version = (() => {
const packageJsonPath = path$$1.join(__dirname, "../package.json");
return fs.existsSync((packageJsonPath)) ? require(packageJsonPath).version : "0.0.0";
})();
function readText(path) {
return fs.readFileSync(path, "utf-8");
}
function enumerateFileSystemEntries(dir) {
const source$$2 = fs.readdirSync((dir));
return map$1(function mapping(str) {
return path$$1.join(dir, str);
}, source$$2);
}
function isFile(path$$2) {
let stats;
let arg00;
arg00 = path$$2;
stats = fs.lstatSync(arg00);
return stats.isFile();
}
function isDirectory(path$$3) {
let stats$$1;
let arg00$$1;
arg00$$1 = path$$3;
stats$$1 = fs.lstatSync(arg00$$1);
return stats$$1.isDirectory();
}
function enumerateFiles(dirs) {
if (isEmpty(dirs)) {
return empty();
} else {
return delay(function () {
return append((collect(function mapping$$1($arg$$2) {
let source$$3;
source$$3 = enumerateFileSystemEntries($arg$$2);
return filter(isFile, source$$3);
}, dirs)), delay(function () {
let dirs$$1;
dirs$$1 = collect(function mapping$$2($arg$$3) {
let source$$5;
source$$5 = enumerateFileSystemEntries($arg$$3);
return filter(isDirectory, source$$5);
}, dirs);
return enumerateFiles(dirs$$1);
}));
});
}
}
const FsAccessibility = declare(function ts2fable_Syntax_FsAccessibility(tag, name, ...fields) {
Union.call(this, tag, name, ...fields);
}, Union);
function FsAccessibility$reflection() {
return union("ts2fable.Syntax.FsAccessibility", [], FsAccessibility, () => ["Public", "Protected", "Private"]);
}
const FsInterface = declare(function ts2fable_Syntax_FsInterface(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
this.Comments = arg1;
this.IsStatic = arg2;
this.IsClass = arg3;
this.Name = arg4;
this.FullName = arg5;
this.TypeParameters = arg6;
this.Inherits = arg7;
this.Members = arg8;
this.Accessibility = arg9;
}, Record);
function FsInterface$reflection() {
return record("ts2fable.Syntax.FsInterface", [], FsInterface, () => [["Comments", list(FsComment$reflection())], ["IsStatic", bool], ["IsClass", bool], ["Name", string], ["FullName", string], ["TypeParameters", list(FsType$reflection())], ["Inherits", list(FsType$reflection())], ["Members", list(FsType$reflection())], ["Accessibility", option(FsAccessibility$reflection())]]);
}
const FsTypeLiteral = declare(function ts2fable_Syntax_FsTypeLiteral(arg1) {
this.Members = arg1;
}, Record);
function FsTypeLiteral$reflection() {
return record("ts2fable.Syntax.FsTypeLiteral", [], FsTypeLiteral, () => [["Members", list(FsType$reflection())]]);
}
const FsGenericParameterDefaults = declare(function ts2fable_Syntax_FsGenericParameterDefaults(arg1, arg2, arg3) {
this.Default = arg1;
this.Name = arg2;
this.FullName = arg3;
}, Record);
function FsGenericParameterDefaults$reflection() {
return record("ts2fable.Syntax.FsGenericParameterDefaults", [], FsGenericParameterDefaults, () => [["Default", FsType$reflection()], ["Name", string], ["FullName", string]]);
}
const FsEnumCaseType = declare(function ts2fable_Syntax_FsEnumCaseType(tag, name, ...fields) {
Union.call(this, tag, name, ...fields);
}, Union);
function FsEnumCaseType$reflection() {
return union("ts2fable.Syntax.FsEnumCaseType", [], FsEnumCaseType, () => ["Numeric", "String", "Unknown"]);
}
const FsEnumCase = declare(function ts2fable_Syntax_FsEnumCase(arg1, arg2, arg3) {
this.Name = arg1;
this.Type = arg2;
this.Value = arg3;
}, Record);
function FsEnumCase$reflection() {
return record("ts2fable.Syntax.FsEnumCase", [], FsEnumCase, () => [["Name", string], ["Type", FsEnumCaseType$reflection()], ["Value", option(string)]]);
}
const FsEnum = declare(function ts2fable_Syntax_FsEnum(arg1, arg2) {
this.Name = arg1;
this.Cases = arg2;
}, Record);
function FsEnum$reflection() {
return record("ts2fable.Syntax.FsEnum", [], FsEnum, () => [["Name", string], ["Cases", list(FsEnumCase$reflection())]]);
}
const FsParamComment = declare(function ts2fable_Syntax_FsParamComment(arg1, arg2) {
this.Name = arg1;
this.Description = arg2;
}, Record);
function FsParamComment$reflection() {
return record("ts2fable.Syntax.FsParamComment", [], FsParamComment, () => [["Name", string], ["Description", list(string)]]);
}
const FsComment = declare(function ts2fable_Syntax_FsComment(tag, name, ...fields) {
Union.call(this, tag, name, ...fields);
}, Union);
function FsComment$reflection() {
return union("ts2fable.Syntax.FsComment", [], FsComment, () => [["SummaryLine", [string]], ["Param", [FsParamComment$reflection()]], ["Unknown", [option(string)]]]);
}
const FsParam = declare(function ts2fable_Syntax_FsParam(arg1, arg2, arg3, arg4, arg5) {
this.Comment = arg1;
this.Name = arg2;
this.Optional = arg3;
this.ParamArray = arg4;
this.Type = arg5;
}, Record);
function FsParam$reflection() {
return record("ts2fable.Syntax.FsParam", [], FsParam, () => [["Comment", option(FsComment$reflection())], ["Name", string], ["Optional", bool], ["ParamArray", bool], ["Type", FsType$reflection()]]);
}
const FsFunctionKind = declare(function ts2fable_Syntax_FsFunctionKind(tag, name, ...fields) {
Union.call(this, tag, name, ...fields);
}, Union);
function FsFunctionKind$reflection() {
return union("ts2fable.Syntax.FsFunctionKind", [], FsFunctionKind, () => ["Regular", "Constructor", "Call", ["StringParam", [string]]]);
}
const FsFunction = declare(function ts2fable_Syntax_FsFunction(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
this.Comments = arg1;
this.Kind = arg2;
this.IsStatic = arg3;
this.Name = arg4;
this.TypeParameters = arg5;
this.Params = arg6;
this.ReturnType = arg7;
this.Accessibility = arg8;
}, Record);
function FsFunction$reflection() {
return record("ts2fable.Syntax.FsFunction", [], FsFunction, () => [["Comments", list(FsComment$reflection())], ["Kind", FsFunctionKind$reflection()], ["IsStatic", bool], ["Name", option(string)], ["TypeParameters", list(FsType$reflection())], ["Params", list(FsParam$reflection())], ["ReturnType", FsType$reflection()], ["Accessibility", option(FsAccessibility$reflection())]]);
}
const FsPropertyKind = declare(function ts2fable_Syntax_FsPropertyKind(tag, name, ...fields) {
Union.call(this, tag, name, ...fields);
}, Union);
function FsPropertyKind$reflection() {
return union("ts2fable.Syntax.FsPropertyKind", [], FsPropertyKind, () => ["Regular", "Index"]);
}
const FsProperty = declare(function ts2fable_Syntax_FsProperty(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
this.Comments = arg1;
this.Kind = arg2;
this.Index = arg3;
this.Name = arg4;
this.Option = arg5;
this.Type = arg6;
this.IsReadonly = arg7;
this.IsStatic = arg8;
this.Accessibility = arg9;
}, Record);
function FsProperty$reflection() {
return record("ts2fable.Syntax.FsProperty", [], FsProperty, () => [["Comments", list(FsComment$reflection())], ["Kind", FsPropertyKind$reflection()], ["Index", option(FsParam$reflection())], ["Name", string], ["Option", bool], ["Type", FsType$reflection()], ["IsReadonly", bool], ["IsStatic", bool], ["Accessibility", option(FsAccessibility$reflection())]]);
}
const FsGenericType = declare(function ts2fable_Syntax_FsGenericType(arg1, arg2) {
this.Type = arg1;
this.TypeParameters = arg2;
}, Record);
function FsGenericType$reflection() {
return record("ts2fable.Syntax.FsGenericType", [], FsGenericType, () => [["Type", FsType$reflection()], ["TypeParameters", list(FsType$reflection())]]);
}
const FsUnion = declare(function ts2fable_Syntax_FsUnion(arg1, arg2) {
this.Option = arg1;
this.Types = arg2;
}, Record);
function FsUnion$reflection() {
return record("ts2fable.Syntax.FsUnion", [], FsUnion, () => [["Option", bool], ["Types", list(FsType$reflection())]]);
}
const FsAlias = declare(function ts2fable_Syntax_FsAlias(arg1, arg2, arg3) {
this.Name = arg1;
this.Type = arg2;
this.TypeParameters = arg3;
}, Record);
function FsAlias$reflection() {
return record("ts2fable.Syntax.FsAlias", [], FsAlias, () => [["Name", string], ["Type", FsType$reflection()], ["TypeParameters", list(FsType$reflection())]]);
}
const FsTupleKind = declare(function ts2fable_Syntax_FsTupleKind(tag, name, ...fields) {
Union.call(this, tag, name, ...fields);
}, Union);
function FsTupleKind$reflection() {
return union("ts2fable.Syntax.FsTupleKind", [], FsTupleKind, () => ["Intersection", "Tuple", "Mapped"]);
}
const FsTuple = declare(function ts2fable_Syntax_FsTuple(arg1, arg2) {
this.Types = arg1;
this.Kind = arg2;
}, Record);
function FsTuple$reflection() {
return record("ts2fable.Syntax.FsTuple", [], FsTuple, () => [["Types", list(FsType$reflection())], ["Kind", FsTupleKind$reflection()]]);
}
const FsImportSpecifier = declare(function ts2fable_Syntax_FsImportSpecifier(arg1, arg2) {
this.PropertyName = arg1;
this.Name = arg2;
}, Record);
function FsImportSpecifier$reflection() {
return record("ts2fable.Syntax.FsImportSpecifier", [], FsImportSpecifier, () => [["PropertyName", option(string)], ["Name", string]]);
}
const FsTypeImport = declare(function ts2fable_Syntax_FsTypeImport(arg1, arg2, arg3) {
this.ImportSpecifier = arg1;
this.SpecifiedModule = arg2;
this.ResolvedModule = arg3;
}, Record);
function FsTypeImport$reflection() {
return record("ts2fable.Syntax.FsTypeImport", [], FsTypeImport, () => [["ImportSpecifier", FsImportSpecifier$reflection()], ["SpecifiedModule", string], ["ResolvedModule", option(string)]]);
}
const ModuleImport = declare(function ts2fable_Syntax_ModuleImport(arg1, arg2, arg3) {
this.Module = arg1;
this.SpecifiedModule = arg2;
this.ResolvedModule = arg3;
}, Record);
function ModuleImport$reflection() {
return record("ts2fable.Syntax.ModuleImport", [], ModuleImport, () => [["Module", string], ["SpecifiedModule", string], ["ResolvedModule", option(string)]]);
}
const FsImport = declare(function ts2fable_Syntax_FsImport(tag, name, ...fields) {
Union.call(this, tag, name, ...fields);
}, Union);
function FsImport$reflection() {
return union("ts2fable.Syntax.FsImport", [], FsImport, () => [["Type", [FsTypeImport$reflection()]], ["Module", [ModuleImport$reflection()]]]);
}
const FsExport = declare(function ts2fable_Syntax_FsExport(arg1, arg2, arg3) {
this.IsGlobal = arg1;
this.Selector = arg2;
this.Path = arg3;
}, Record);
function FsExport$reflection() {
return record("ts2fable.Syntax.FsExport", [], FsExport, () => [["IsGlobal", bool], ["Selector", string], ["Path", string]]);
}
const FsVariable = declare(function ts2fable_Syntax_FsVariable(arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
this.Export = arg1;
this.HasDeclare = arg2;
this.Name = arg3;
this.Type = arg4;
this.IsConst = arg5;
this.IsStatic = arg6;
this.Accessibility = arg7;
}, Record);
function FsVariable$reflection() {
return record("ts2fable.Syntax.FsVariable", [], FsVariable, () => [["Export", option(FsExport$reflection())], ["HasDeclare", bool], ["Name", string], ["Type", FsType$reflection()], ["IsConst", bool], ["IsStatic", bool], ["Accessibility", option(FsAccessibility$reflection())]]);
}
const FsMapped = declare(function ts2fable_Syntax_FsMapped(arg1, arg2) {
this.Name = arg1;
this.FullName = arg2;
}, Record);
function FsMapped$reflection() {
return record("ts2fable.Syntax.FsMapped", [], FsMapped, () => [["Name", string], ["FullName", string]]);
}
const FsType = declare(function ts2fable_Syntax_FsType(tag, name, ...fields) {
Union.call(this, tag, name, ...fields);
}, Union);
function FsType$reflection() {
return union("ts2fable.Syntax.FsType", [], FsType, () => [["Interface", [FsInterface$reflection()]], ["Enum", [FsEnum$reflection()]], ["Property", [FsProperty$reflection()]], ["Param", [FsParam$reflection()]], ["Array", [FsType$reflection()]], "TODO", "None", ["Mapped", [FsMapped$reflection()]], ["Function", [FsFunction$reflection()]], ["Union", [FsUnion$reflection()]], ["Alias", [FsAlias$reflection()]], ["Generic", [FsGenericType$reflection()]], ["Tuple", [FsTuple$reflection()]], ["Module", [FsModule$reflection()]], ["File", [FsFile$reflection()]], ["FileOut", [FsFileOut$reflection()]], ["Variable", [FsVariable$reflection()]], ["StringLiteral", [string]], ["ExportAssignment", [string]], "This", ["Import", [FsImport$reflection()]], ["TypeLiteral", [FsTypeLiteral$reflection()]], ["GenericParameterDefaults", [FsGenericParameterDefaults$reflection()]]]);
}
const FsModule = declare(function ts2fable_Syntax_FsModule(arg1, arg2, arg3, arg4, arg5, arg6) {
this.HasDeclare = arg1;
this.IsNamespace = arg2;
this.Name = arg3;
this.Types = arg4;
this.HelperLines = arg5;
this.Attributes = arg6;
}, Record);
function FsModule$reflection() {
return record("ts2fable.Syntax.FsModule", [], FsModule, () => [["HasDeclare", bool], ["IsNamespace", bool], ["Name", string], ["Types", list(FsType$reflection())], ["HelperLines", list(string)], ["Attributes", list(string)]]);
}
const FsFileKind = declare(function ts2fable_Syntax_FsFileKind(tag, name, ...fields) {
Union.call(this, tag, name, ...fields);
}, Union);
function FsFileKind$reflection() {
return union("ts2fable.Syntax.FsFileKind", [], FsFileKind, () => ["Index", ["Extra", [string]]]);
}
const FsFile = declare(function ts2fable_Syntax_FsFile(arg1, arg2, arg3, arg4) {
this.Kind = arg1;
this.FileName = arg2;
this.ModuleName = arg3;
this.Modules = arg4;
}, Record);
function FsFile$reflection() {
return record("ts2fable.Syntax.FsFile", [], FsFile, () => [["Kind", FsFileKind$reflection()], ["FileName", string], ["ModuleName", string], ["Modules", list(FsModule$reflection())]]);
}
const FsFileOut = declare(function ts2fable_Syntax_FsFileOut(arg1, arg2, arg3, arg4) {
this.Namespace = arg1;
this.Opens = arg2;
this.Files = arg3;
this.AbbrevTypes = arg4;
}, Record);
function FsFileOut$reflection() {
return record("ts2fable.Syntax.FsFileOut", [], FsFileOut, () => [["Namespace", string], ["Opens", list(string)], ["Files", list(FsFile$reflection())], ["AbbrevTypes", list(string)]]);
}
function FsInterface$$get_HasStaticMembers(x) {
return exists$1(isStatic, x.Members);
}
function FsInterface$$get_StaticMembers(x$$1) {
return filter$1(isStatic, x$$1.Members);
}
function FsInterface$$get_NonStaticMembers(x$$2) {
return filter$1(function predicate$$2($arg$$1) {
let value;
value = isStatic($arg$$1);
return !value;
}, x$$2.Members);
}
function FsInterface$$get_HasConstructor(x$$3) {
return exists$1(isConstructor, x$$3.Members);
}
function FsInterface$$get_Constructors(x$$4) {
return filter$1(isConstructor, x$$4.Members);
}
function FsEnum$$get_Type(x$$5) {
if (exists$1(function predicate$$5(c) {
return equals(c.Type, new FsEnumCaseType(2, "Unknown"));
}, x$$5.Cases)) {
return new FsEnumCaseType(2, "Unknown");
} else if (exists$1(function predicate$$6(c$$1) {
return equals(c$$1.Type, new FsEnumCaseType(1, "String"));
}, x$$5.Cases)) {
return new FsEnumCaseType(1, "String");
} else {
return new FsEnumCaseType(0, "Numeric");
}
}
function FsCommentModule$$$asSummaryLine(v$$1) {
if (v$$1.tag === 0) {
return v$$1.fields[0];
} else {
return null;
}
}
function FsCommentModule$$$isParam(v$$2) {
if (v$$2.tag === 1) {
return true;
} else {
return false;
}
}
function FsCommentModule$$$asParam(v$$3) {
if (v$$3.tag === 1) {
return v$$3.fields[0];
} else {
return null;
}
}
function FsParamModule$$$isStringLiteral(p) {
return FsTypeModule$$$isStringLiteral(p.Type);
}
function FsParamModule$$$getComment(p$$2) {
return p$$2.Comment;
}
function FsFunction$$get_HasStringLiteralParams(x$$6) {
return exists$1(FsParamModule$$$isStringLiteral, x$$6.Params);
}
function FsFunction$$get_ParamComments(x$$13) {
let list$$13;
list$$13 = map$2(FsParamModule$$$getComment, x$$13.Params);
return choose(function chooser$$1(x$$14) {
return x$$14;
}, list$$13);
}
function FsFunction$$get_AllComments(x$$15) {
return append$1(x$$15.Comments, FsFunction$$get_ParamComments(x$$15));
}
function FsVariable$$get_IsGlobal(x$$16) {
if (x$$16.Export != null) {
return x$$16.Export.IsGlobal;
} else {
return false;
}
}
FsVariable.prototype.Equals = function (y) {
const x$$17 = this;
return y instanceof FsVariable ? x$$17.Name === y.Name : false;
};
FsVariable.prototype.GetHashCode = function () {
const x$$18 = this;
return structuralHash(x$$18.Name) | 0;
};
FsVariable.prototype.CompareTo = function (y$$1) {
const x$$19 = this;
if (y$$1 instanceof FsVariable) {
return comparePrimitives(x$$19.Name, y$$1.Name) | 0;
} else {
throw new Error("cannot compare values of different types\\nParameter name: y");
}
};
function simpleType(name) {
const arg0 = new FsMapped(name, name);
return new FsType(7, "Mapped", arg0);
}
function FsTypeModule$$$isStringLiteral(tp$$8) {
if (tp$$8.tag === 17) {
return true;
} else {
return false;
}
}
function FsTypeModule$$$asMapped(tp$$14) {
if (tp$$14.tag === 7) {
return tp$$14.fields[0];
} else {
return null;
}
}
function FsTypeModule$$$asStringLiteral(tp$$18) {
if (tp$$18.tag === 17) {
return tp$$18.fields[0];
} else {
return null;
}
}
function FsTypeModule$$$asModule(tp$$19) {
if (tp$$19.tag === 13) {
return tp$$19.fields[0];
} else {
return null;
}
}
function FsTypeModule$$$asGenericParameterDefaults(tp$$22) {
if (tp$$22.tag === 22) {
return tp$$22.fields[0];
} else {
return null;
}
}
function FsModule$$get_HasAttributes(x$$21) {
return length(x$$21.Attributes) > 0;
}
function isStatic(tp$$23) {
switch (tp$$23.tag) {
case 8:
{
return tp$$23.fields[0].IsStatic;
}
case 0:
{
return tp$$23.fields[0].IsStatic;
}
case 2:
{
return tp$$23.fields[0].IsStatic;
}
case 16:
{
return tp$$23.fields[0].IsStatic;
}
default:
{
return false;
}
}
}
function isConstructor(tp$$24) {
if (tp$$24.tag === 8) {
return equals(tp$$24.fields[0].Kind, new FsFunctionKind(1, "Constructor"));
} else {
return false;
}
}
function getName($tp$$25$$54) {
getName: while (true) {
const tp$$25 = $tp$$25$$54;
switch (tp$$25.tag) {
case 0:
{
return tp$$25.fields[0].Name;
}
case 1:
{
return tp$$25.fields[0].Name;
}
case 3:
{
return tp$$25.fields[0].Name;
}
case 8:
{
return defaultArg(tp$$25.fields[0].Name, "");
}
case 2:
{
return tp$$25.fields[0].Name;
}
case 10:
{
return tp$$25.fields[0].Name;
}
case 16:
{
return tp$$25.fields[0].Name;
}
case 13:
{
return tp$$25.fields[0].Name;
}
case 14:
{
return tp$$25.fields[0].ModuleName;
}
case 11:
{
$tp$$25$$54 = tp$$25.fields[0].Type;
continue getName;
}
case 7:
{
return tp$$25.fields[0].Name;
}
case 20:
{
if (tp$$25.fields[0].tag === 0) {
return tp$$25.fields[0].fields[0].ImportSpecifier.Name;
} else {
return "";
}
}
case 4:
{
const name$$1 = getName(tp$$25.fields[0]);
if (name$$1 === "") {
return "";
} else {
const clo1 = toText(printf("%sArray"));
return clo1(name$$1);
}
}
default:
{
return "";
}
}
}
}
function getFullName($tp$$26$$55) {
getFullName: while (true) {
const tp$$26 = $tp$$26$$55;
switch (tp$$26.tag) {
case 0:
{
return tp$$26.fields[0].FullName;
}
case 7:
{
return tp$$26.fields[0].FullName;
}
case 11:
{
$tp$$26$$55 = tp$$26.fields[0].Type;
continue getFullName;
}
case 14:
{
return tp$$26.fields[0].FileName;
}
default:
{
return getName(tp$$26);
}
}
}
}
function getTypeName(tp$$27) {
switch (tp$$27.tag) {
case 8:
{
return String(FsFunction$reflection());
}
case 2:
{
return String(FsProperty$reflection());
}
case 16:
{
return String(FsVariable$reflection());
}
case 13:
{
return String(FsModule$reflection());
}
case 1:
{
return String(FsEnum$reflection());
}
case 3:
{
return String(FsParam$reflection());
}
case 10:
{
return String(FsAlias$reflection());
}
case 14:
{
return String(FsFile$reflection());
}
case 11:
{
return String(FsGenericType$reflection());
}
case 7:
{
return String(FsMapped$reflection());
}
case 20:
{
return String(FsImport$reflection());
}
case 4:
{
return String(FsType$reflection());
}
case 18:
{
return String(string);
}
case 22:
{
return String(FsGenericParameterDefaults$reflection());
}
case 6:
{
return String(FsType$reflection()) + ".None";
}
case 5:
{
return String(FsType$reflection()) + ".TODO";
}
case 17:
{
return String(string);
}
case 19:
{
return String(FsType$reflection()) + ".This";
}
case 12:
{
return String(FsTuple$reflection());
}
case 21:
{
return String(FsTypeLiteral$reflection());
}
case 9:
{
return String(FsUnion$reflection());
}
case 15:
{
return String(FsFileOut$reflection());
}
default:
{
return String(FsInterface$reflection());
}
}
}
function getAccessibility(tp$$28) {
switch (tp$$28.tag) {
case 8:
{
return tp$$28.fields[0].Accessibility;
}
case 2:
{
return tp$$28.fields[0].Accessibility;
}
case 16:
{
return tp$$28.fields[0].Accessibility;
}
case 13:
case 1:
case 3:
case 10:
case 14:
case 11:
case 7:
case 20:
case 4:
case 18:
case 22:
case 6:
case 5:
case 17:
case 19:
case 12:
case 21:
case 9:
case 15:
{
return null;
}
default:
{
return tp$$28.fields[0].Accessibility;
}
}
}
// Polyfills
function utf8_encode(str) {
let pos = 0;
let buf = new Uint8Array(str.length * 3);
for (let i = 0; i < str.length; i++) {
let code = str.charCodeAt(i);
if (code >= 0xD800 && code <= 0xDBFF) {
const nextCode = i < str.length ? str.charCodeAt(i + 1) : 0;
if (nextCode >= 0xDC00 && nextCode <= 0xDFFF) {
i += 1;
code = (code - 0xD800) * 0x400 + nextCode - 0xDC00 + 0x10000;
if (code > 0xFFFF) {
buf[pos++] = 0x1E << 3 | code >>> 18;
buf[pos++] = 0x2 << 6 | code >>> 12 & 0x3F;
buf[pos++] = 0x2 << 6 | code >>> 6 & 0x3F;
buf[pos++] = 0x2 << 6 | code & 0x3F;
}
} else {
buf[pos++] = 0xEF;
buf[pos++] = 0xBF;
buf[pos++] = 0xBD;
}
} else if (code <= 0x007F) {
buf[pos++] = 0x0 << 7 | code;
} else if (code <= 0x07FF) {
buf[pos++] = 0x6 << 5 | code >>> 6;
buf[pos++] = 0x2 << 6 | code & 0x3F;
} else {
buf[pos++] = 0xE << 4 | code >>> 12;
buf[pos++] = 0x2 << 6 | code >>> 6 & 0x3F;
buf[pos++] = 0x2 << 6 | code & 0x3F;
}
}
buf = new Uint8Array(buf.buffer.slice(0, pos));
return buf;
}
function utf8_decode(bytes) {
let pos = 0;
const decodeUtf8 = () => {
const i1 = bytes[pos++];
if ((i1 & 0x80) === 0) {
return i1;
} else if ((i1 & 0xE0) === 0xC0) {
const i2 = bytes[pos++];
return (i1 & 0x1F) << 6 | i2 & 0x3F;
} else if ((i1 & 0xF0) === 0xE0) {
const i2 = bytes[pos++];
const i3 = bytes[pos++];
return (i1 & 0x0F) << 12 | (i2 & 0x3F) << 6 | i3 & 0x3F;
} else if ((i1 & 0xF8) === 0xF0) {
const i2 = bytes[pos++];
const i3 = bytes[pos++];
const i4 = bytes[pos++];
return (i1 & 0x07) << 18 | (i2 & 0x3F) << 12 | (i3 & 0x3F) << 6 | i4 & 0x3F;
} else {
throw RangeError("Invalid UTF8 byte: " + i1);
}
};
const chars = new Array();
while (pos < bytes.length) {
const code = decodeUtf8();
chars.push(String.fromCodePoint(code));
}
return chars.join("");
}
class UTF8 {
getBytes(str, index, count) {
if (index != null) {
str = str.substring(index, index + count);
}
if (typeof TextEncoder !== "undefined") {
return new TextEncoder().encode(str);
} else if (typeof Buffer !== "undefined") {
return Buffer.from(str, "utf8");
} else {
return utf8_encode(str); // polyfill
}
}
getString(bytes, index, count) {
if (index != null) {
bytes = bytes.subarray(index, index + count);
}
if (typeof TextDecoder !== "undefined") {
return new TextDecoder().decode(bytes);
} else if (typeof Buffer !== "undefined") {
return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("utf8");
} else {
return utf8_decode(bytes); // polyfill
}
}
}
const _UTF8 = new UTF8();
function get_UTF8() {
return _UTF8;
}
// Unicode 9.0.0 ranges and categories (delta encoded, vbyte encoded, utf8 encoded)
// tslint:disable:max-line-length
var packedUnicode = "~~^a}i{g}i{h}l}i}e}i}m}i|qti|e{i|udh}i}l}f}n}f}ydh}e}l}e}~]a}i}gzd}i}f}d}w}j}e}}}d}f}d}e}o|f}y}i|f}o}w}k}o{i}uge}uwyfe}yvu}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y|u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y|u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u|y}u}y}u}y{u|y}u}y}u|y}u{y|uzy}u|y}u{y{u|y}u|y}u}y}u}y}u|y}u}y|u}y}u|y}u{y}u}y}u|y|w}u}y{wzu}v}y}u}v}y}u}v}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y|u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y|u}v}y}u}y}u{y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}ywu|y}u|y|u}y}uzy}u}y}u}y}u}y}u}y9w}ycxlfzxrfpxyfwx}f}x}fmr\u000eu}y}u}y}x}f}u}y}||x}y{i}u}|zf|u}i}u{|}u}|}u|y}um|}uuy[u}y|u{y{u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}yyu}y}e}u}y}u|y|uKyNu}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}d}rys|u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u|y}u}y}u}y}u}y}u}y}u}y}u}y|u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}|}uX||x}ix|}yW|}i}m}||d|g}|}rQm}r}i}r|i}r|i}r}|vwc|yw{i||s}xe{i|g}i|d|rsi}}}|}i|w^x}wtriqtizw|r}w\u001bi}w}rw}}d}rxx|r|d}rzw|qtw{d|w}ip|}}}w}r}w`rc||w%rsw}|pqtw]rux|d}i{x}|ywhrzx}rux}r{x}ry||io|}wer{||i}|=wi|}wv|hrp}}r^t}wHr}t}r}w}t{rvtzr}t|w}rwwtr|i|qti}x}wor}t||}wv||w|||wh|}ww|}w}|{wz||r}w}t{rz||t|||t|r}w}|vt}|zw||}w{r|||qtw|g|oxd}g}|yr|t}|}wx|zw|||wh|}ww|}w||}w||}w|||r}|}t{r||zr|||r{|{r}|wwz|}w}|wqtr|w{r}|sr|t}|}wu|}w{|}wh|}ww|}w||}wy||r}w}t{ry|}r|t}|}t|r}||w}|ow|r|||qti}g}|ww}|wr}t||}wv||w|||wh|}ww|}w||}wy||r}w}t}r}t}rz||t|||t|r}|vr}t}|zw||}w{r|||qtd}w}ox|tr}w}|}wx|{w{|}wz|{w||}w}|}w||{w||{w{|{wr|zt|r}t||{t{|}t{r}||w}|xt}|pqto{dxg}d}|yr}t{|}wv|}w{|}wg|}wn|{w}r{tz|}r{|}rz|wr||}w{|yw|r|||qt|vowd}w}r}t||}wv|}w{|}wg|}wt|}wy||r}w}t}r}ty|}r}t||}t|r||wt||ww}|}w|r|||qt|}w||pr}t||}wv|}w{|}wU||w}t{rz|}t{|}t{r}w}d}|zw{t}oww{r|||qtoud}wx||t||}wl|{wf|}wu|}w}||ww|{r}|zt{r{|}r}|}tv|xqt||t|i}|rwNr}w|rw|zg}wxx}rvi}qti||Yw||}w}||w||}w}||w}|xwz|}ww|}w{|}w}|}w}||w||}wzr}w|rx|}r|w}||wy|}x}|}rx||qt||wz|^w}d{iod}i}d{r|dxqtotd}r}d}r}d}r}h}l}h}l}t|wv|}wZ|zrpt}ryi}r|wyrs|}rZ|}dvr}dx|}d|iydzi||YwSt|rzt}rxt}r|t|r|w}qtixwxt|r|wzr{w}t{w|tww{rzwqr}t|r|txr}w}t}qtt{r}d|uX|}u}|yu}||wSi}x}w�}|}wz||ww|}w}|}wz||wU|}wz||w]|}wz||ww|}w}|}wz||wo|}wE|}wz||w;||r{iuoj|{wndt|xu(||yx||m}w�{i|wma}wdh}l}|{w3i{p{wv|wwq|}wzr{|swlr{i||uwlr||rwq|}w{|}r||rwJr|t}rwtvr}t|rsi{x}i{g}w}r}||qt|xot|xixm}izr{}}|}qt|xw[x}wJ|vwyr|w\\r}w}|yw8|tw_|}r{tzr|t{|zt|r}txr{|zd}|{i|qtw`||wy|swR|zwd|xqto}|{d\\wgr|t|r}||i|wIt}r}t}rw|}r}t}r}t|rvtxrt||r}qt|xqt|xiwx}ix||rps}|=rzt}wOr}t}ryt}r}tyr}t|ww|zqtiwdtrudu|{r|t}w`t}rzt|r|t}r{w|qtwRr}t}r|t{r}t}r{t||vizwZtvrvt|r||{iyqt|{w{qtw`xxi|yu|Giv|vr{i}rqt}rwwzr}wzt|r}w||}r||xyRx?yqx}y\\xYrH|yryu}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}yuu}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}yuuvyx||ux||yvuvyvuvyx||ux||yv|}u}|}u}|}u}|}u}yvuvyp||yvvvyvvvyvvvyy|}y|uzv}f}y}f{y{|}y|uzv}f{yz||y|uz|}f{yvuyf{||y{|}y|uzv}f||}as}ymxi|j}k}h}j|k}h}j}ivc}b}}ya}iuj}k}izn|i{e}h}l}ise}i}n}ita}}y|}}to}x}||oxe{h}l}x}ote{h}l}|}xq|{g_|mrqszr}s{rr|od|u}dzu}d|y}u{y|u{y}d}u}d|e}uydxu}d}u}d}u}d}uzd}y}uzy}wzy}d|y|u|eyu}yzd}e}d|y}d}onp[u}y}pzo}d||zeydye|dze}d|e}d|e}dwe}d_e|d|e}d}e}d_e�}dvh}l}h}l}dje|dwh}l}d-e}d`eedVexda|}dW|eds|ioBd0ohd�~e}due}dHevd\u000fe}d�~h}l}h}l}h}l}h}l}h}l}h}l}h}l}o`dReyh}l}e_h}l}h}l}h}l}h}l}h}l}end�}e�~h}l}h}l}h}l}h}l}h}l}h}l}h}l}h}l}h}l}h}l}h}l}e?h}l}h}l}e^h}l}e�}dNeid|exdW||d^||d\\|{dr|}dv|ddz|nuO|}yO|}u}y}u{y|u}y}u}y}u}y}uzy}u}y|u}yxx|u{y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y|dxu}y}u}y}r{u}y}|yizo}i|yX|}y}|yy}||wF|wx}i}|pr}wg|uww|}ww|}ww|}ww|}ww|}ww|}ww|}ww|}r^i|j}k}j}k}i{j}k}i}j}k}ium}i|m}i}j}k}i|j}k}h}l}h}l}h}l}h}l}iyx}itm|izm}i}h}i||Cdd|}d%|rd�~|ddr|za}i{d}x}w}p}h}l}h}l}h}l}h}l}h}l}d|h}l}h}l}h}l}h}l}m}h}l|d}purzt|m}xyd|p{x}w}i}d||}w(||r|f|x|w}m}w$i}x{w}|ywU|{w |}d|ozdtwc|ydZ|rwnd_|}otd`ovd}ood^otdWood?|}d�}w�L|td>w��~|Twix}w�w|{dG|uwVxxi|w�}x}i{wnqtw||ju}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}w}r}s{i}rti}x}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}x|r|w8ptr|ix|vfgxuf|u}y}u}y}u}y}u}y}u}y}u}y}u}y{u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}x}yvu}y}u}y}u|y}u}y}u}y}u}y}u}y}x}f|u}y}u}y}w}u}y}u}y{u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}u}y}uy|}uyy}u}y}|?w}x|y}wwr}w{r}wzr}wgt|r|t}dz|zoxd|g}d}|xwJiz|vt|wLtnr||vi|qt|xrlwxi{w}i}w}||qtwbrvi|wgrst||si}wa|{r{t}wOr}t|rzt|r}tziq|}x}qt|zi|wyr}x}wuqtwy|}wUrxt|r|t|r||uw{r}wvr}t}||qt||izwnx}wxd{w}t}r}t}wLr}w}r{w|r|wyr|w}r}w}|fw|x}i|wst}r|t|i|w}x|t}r}|twx||wx||wx|uww|}ww|}ySf}xzyx|ty.w[t|r}t|r}t|i}t}r}||qt|xw�(|rwg|zwM|zz�o{�Mw�}||w\u0014|Xyw|ryy|yw}r}wte}wq|}wy|}w}|}w||}w||}w\u0012fn|mw�}l}h}|nw>||wH|Vwrg}d}||rniwh}l}i}|xrni}m|n|h}l}h}l}h}l}h}l}h}l}h}l}h}l}h}l}i|h}l}izn{i{|}izm}h}l}h}l}h}l}i{e}m}e{|}i}g}i||zwy|}w�~||}}|}i{g}i{h}l}i}e}i}m}i|qti|e{i|udh}i}l}f}n}f}ydh}e}l}e}h}l}i}h}l}i|wtx}wQx|w_|{wx||wx||wx||w{|{g|e}f}d}g||}d}ezd||t}{d|||wr|}wd|}wk|}w||}wo||wp|\\w\u0003|yi{|zoQ|{dupIozdmo|d{|}dr|zd}|OdQr}|�~wa|{wM|or}oc|zw^oz|rwmp}wvp}|ywXry|yw`|}i}wZ|zwvi}py|TuVyVw0||qt|xuZ|zyZ|zwV|vwJ|si}|�~w�}|uwh|twv|�~wx||w}|}wR|}w||{w}||wg|}i}ovwgd|oww_|vou|Nwk|}w||yoywhox|{i}wd|yi}|>wF|zo|w|on||oPw}r{|}r||yrzwz|}w{|}wc|zr{|zr}ov|viu|wwao|i}wao{|^wvd}wbr||zoyiw|uwH|{iwwh||ovwk|yovwl|wiz|row|.w5|GuK|qyK|wox|�}o_|�|t}r}t}wIroiw|zojqt|or{t}wQt{rzt|r|i|}}iz|pwe|wqt|xr{wZryt}rv|}qtiz|rw[r}i|w}|ur|t}wNt{rut|wziyr{i}||qtw}i}w}i{|}oj|swl|}wet{r{t|r}t}r|ixr}|=ww|}w}|}wz|}wo|}wti}|xwOr}t{rv|yqt|xr|t||}wv||w|||wh|}ww|}w||}wy||r}w}t|r}tz||t|||t{||w}|xt}|ywyt|||rw|{ry|�~wIt{rvt|r{t}r}wziyqt|}i}|}i}|\\wNt{rxt}r}tzr|t}r|w|i}w}|vqt|�~wOt{rz||tzr|t}r|igwzr||\\wNt{rvt|r}t}r|i{w}|sqt|xiq|kwSr}t}r}t|rxt}r}|vqt|Hwd|{r{t|rzt}ry|zqto|i{d}|�}u^y^qtou|rw}|�|wE|�}wu|}wYt}rw|}rxt}r}w}iy|tqtok|{i|w`||rh|}t}rwt}r|t}r||�yw�x|\u0018p\u000f|}iy|sw�~|�jw�w|�`w�{|�<w�{|ww_|}qt|zi||\u001ew`||ryi}|twNrwiydzxzi}d}|tqt|}ow|}wi|ywk|�yw9|sw}tP|nrzxq|>x}|_w�P|kw�z|�5w||�hw\u0013|ywq|{wu|wwt||d}r|i}}z|�Yd�~|tdW||dBt|r{d{tx}vrvd|rwd`rzdC|gd<r{d}|�~d'|uol|�~udydudyw|}yludydu}|}u|||u}||u|||uz|}uvyz|}y}|}yw|}ysudydu||}uz||uv|}uw|}ydu||}uz|}uy|}u}|{uw|}ydudydudydudydudydudydudyb||uee}yee}yxuee}yee}yxuee}yee}yxuee}yee}yxuee}yee}yxu}y}||qLd�{rGdzrLdvr}dpr}d|iy|ory|}ro|�urw|}rm||rw|}r||}ry|�pw�~||ourw|Uu\\y\\rw|yqt|zi||�vwz|}wc|}w||}w}||w}|}wt|}wz|}w}|}w}|xw}|zw}|}w}|}w}|}w{|}w||}w}||w}|}w}|}w}|}w}|}w}|}w||}w}||wz|}ww|}wz|}wz|}w}|}wt|}wm|yw{|}wy|}wm|Je||�}dR|zd\u001a|rdo||do|}do|}dY|toq|{d_|}dB|zdA|Eda|qdR|zdu|wd||�~d�~fyd�z|qdq|{dw|ud\n|rd)|Sdr|zdF|vdt|xdV|vd`|\u001cdo|}dv|vd}||dr|}dr|zdo|]dl|Pd}|�sw��}|Uw�_|sw�~||w�R|�-w�{|��S}}|`}\u001e|�~r�~|�|{��|||{��||";
// Adapted from: https://github.com/hakatashi/general-category
function decodeVByteToIntegerArray(buffer) {
const ret = [];
let carried = 0;
let register = 0;
for (let i = 0; i < buffer.length; ++i) {
const byte = buffer[i] ^ 0xFF;
register += (byte & 127) << carried * 7;
carried++;
if ((byte & 128) !== 0) {
ret.push(register - 1);
carried = register = 0;
}
}
return ret;
}
function getCategoryFunc() {
// unpack Unicode ranges and categories (delta encoded, vbyte encoded, utf8 encoded)
const unicodeBuffer = get_UTF8().getBytes(packedUnicode);
const unicodeDeltas = decodeVByteToIntegerArray(unicodeBuffer);
const codepoints = new Uint32Array(unicodeDeltas.length / 2);
const categories = new Uint8Array(unicodeDeltas.length / 2);
const categoryEnum = new Uint8Array([14, 15, 29, 17, 16, 1, 3, 4, 2, 0, 6, 7, 5, 8, 9, 10, 18, 19, 21, 23, 22, 24, 20, 26, 27, 25, 28, 12, 13, 11]);
let currentCodepoint = 0;
for (let i = 0; i < unicodeDeltas.length; i += 2) {
codepoints[i / 2] = currentCodepoint += unicodeDeltas[i];
categories[i / 2] = unicodeDeltas[i + 1];
} // binary search in unicode ranges
return cp => {
let hi = codepoints.length;
let lo = 0;
while (hi - lo > 1) {
const mid = Math.floor((hi + lo) / 2);
const test = codepoints[mid];
if (cp < test) {
hi = mid;
} else if (cp === test) {
hi = lo = mid;
break;
} else if (test < cp) {
lo = mid;
}
}
return categoryEnum[categories[lo]];
};
}
const isDigitMask = 1 << 8
/* DecimalDigitNumber */
;
const isLetterMask = 0 | 1 << 0
/* UppercaseLetter */
| 1 << 1
/* LowercaseLetter */
| 1 << 2
/* TitlecaseLetter */
| 1 << 3
/* ModifierLetter */
| 1 << 4
/* OtherLetter */
;
const isLetterOrDigitMask = isLetterMask | isDigitMask;
const isUpperMask = 1 << 0
/* UppercaseLetter */
;
const unicodeCategoryFunc = getCategoryFunc();
function getUnicodeCategory(s, index) {
const cp = s.charCodeAt(index || 0);
return unicodeCategoryFunc(cp);
}
function isDigit(s, index) {
const test = 1 << getUnicodeCategory(s, index);
return (test & isDigitMask) !== 0;
}
function isLetterOrDigit(s, index) {
const test = 1 << getUnicodeCategory(s, index);
return (test & isLetterOrDigitMask) !== 0;
}
function isUpper(s, index) {
const test = 1 << getUnicodeCategory(s, index);
return (test & isUpperMask) !== 0;
}
const reserved = (() => {
const elements = ofArray(["atomic", "break", "checked", "component", "const", "constraint", "constructor", "continue", "eager", "event", "external", "fixed", "functor", "include", "measure", "method", "mixin", "object", "parallel", "params", "process", "protected", "pure", "sealed", "tailcall", "trait", "virtual", "volatile", "asr", "land", "lor", "lsl", "lsr", "lxor", "mod", "sig"]);
return ofList$1(elements, {
Compare: comparePrimitives
});
})();
const keywords = (() => {
const elements$$1 = ofArray(["abstract", "and", "as", "assert", "base", "begin", "class", "default", "delegate", "do", "done", "downcast", "downto", "elif", "else", "end", "exception", "extern", "false", "finally", "for", "fun", "function", "global", "if", "in", "inherit", "inline", "interface", "internal", "lazy", "let", "match", "member", "module", "mutable", "namespace", "new", "null", "of", "open", "or", "override", "private", "public", "rec", "return", "sig", "static", "struct", "then", "to", "true", "try", "type", "upcast", "use", "val", "void", "when", "while", "with", "yield"]);
return ofList$1(elements$$1, {
Compare: comparePrimitives
});
})();
const esKeywords = (() => {
const elements$$2 = ofArray(["Readonly", "Partial", "Pick", "HTMLDialogElement", "HTMLWebViewElement"]);
return ofList$1(elements$$2, {
Compare: comparePrimitives
});
})();
function stringContainsAny(a, b) {
return exists$1(function predicate(arg00) {
return a.indexOf(arg00) >= 0;
}, b);
}
function ModuleName$$$forwordSlash(s) {
return replace(s, "\\", "/");
}
function ModuleName$$$$007CNormal$007CParts$007C(moduleName) {
const moduleName2 = ModuleName$$$forwordSlash(moduleName);
if (moduleName2.indexOf("/") >= 0) {
let parts;
const source = moduleName2.split("/");
parts = ofSeq$1(source);
return new Choice(1, "Choice2Of2", parts);
} else {
return new Choice(0, "Choice1Of2", null);
}
}
function ModuleName$$$normalize(moduleName$$1) {
const moduleName2$$1 = ModuleName$$$forwordSlash(moduleName$$1);
const activePatternResult324 = ModuleName$$$$007CNormal$007CParts$007C(moduleName2$$1);
if (activePatternResult324.tag === 1) {
const clo1 = toText(printf("./%s"));
return clo1(moduleName2$$1);
} else {
return moduleName2$$1;
}
}
function $007CCapital$007C_$007C(letter) {
if (isNullOrWhiteSpace(letter)) {
return null;
} else if (isUpper(letter, 0)) {
return letter;
} else {
return null;
}
}
function $007CDigit$007C_$007C(digit) {
if (isNullOrWhiteSpace(digit)) {
return null;
} else if (isDigit(digit, 0)) {
return digit;
} else {
return null;
}
}
function createEnumNameParts(name) {
const tokens = map$1(function (value) {
return value;
}, name.split(""));
const splitParts = function splitParts($part$$15, $parts$$2$$16, $_arg1$$17) {
splitParts: while (true) {
const part = $part$$15,
parts$$2 = $parts$$2$$16,
_arg1 = $_arg1$$17;
var $target$$18, n$$1, rest$$1;
if (_arg1.tail != null) {
const activePatternResult330 = $007CDigit$007C_$007C(_arg1.head);
if (activePatternResult330 != null) {
if (parts$$2.tail == null ? part === "" : false) {
$target$$18 = 1;
n$$1 = activePatternResult330;
rest$$1 = _arg1.tail;
} else {
$target$$18 = 2;
}
} else {
$target$$18 = 2;
}
} else {
$target$$18 = 0;
}
switch ($target$$18) {
case 0:
{
return new List(part, parts$$2);
}
case 1:
{
$part$$15 = "N" + n$$1;
$parts$$2$$16 = parts$$2;
$_arg1$$17 = rest$$1;
continue splitParts;
}
case 2:
{
var $target$$19, letter$$2, rest$$3;
if (_arg1.tail != null) {
const activePatternResult329 = $007CCapital$007C_$007C(_arg1.head);
if (activePatternResult329 != null) {
if (part === "") {
$target$$19 = 0;
letter$$2 = activePatternResult329;
rest$$3 = _arg1.tail;
} else {
$target$$19 = 1;
}
} else {
$target$$19 = 1;
}
} else {
$target$$19 = 1;
}
switch ($target$$19) {
case 0:
{
$part$$15 = letter$$2;
$parts$$2$$16 = parts$$2;
$_arg1$$17 = rest$$3;
continue splitParts;
}
case 1:
{
var $target$$20, letter$$3, rest$$4;
if (_arg1.tail != null) {
const activePatternResult328 = $007CCapital$007C_$007C(_arg1.head);
if (activePatternResult328 != null) {
$target$$20 = 0;
letter$$3 = activePatternResult328;
rest$$4 = _arg1.tail;
} else {
$target$$20 = 1;
}
} else {
$target$$20 = 1;
}
switch ($target$$20) {
case 0:
{
$part$$15 = letter$$3;
$parts$$2$$16 = new List(part, parts$$2);
$_arg1$$17 = rest$$4;
continue splitParts;
}
case 1:
{
if (_arg1.tail != null) {
if (_arg1.head === "-") {
$part$$15 = "";
$parts$$2$$16 = new List(part, parts$$2);
$_arg1$$17 = _arg1.tail;
continue splitParts;
} else if (_arg1.head === ".") {
$part$$15 = "_";
$parts$$2$$16 = new List(part, parts$$2);
$_arg1$$17 = _arg1.tail;
continue splitParts;
} else {
$part$$15 = part + _arg1.head;
$parts$$2$$16 = parts$$2;
$_arg1$$17 = _arg1.tail;
continue splitParts;
}
} else {
throw new Error("The match cases were incomplete against type of 'List' at C:/projects/ts2fable/src/naming.fs");
}
}
}
}
}
}
}
break;
}
};
const list$$1 = splitParts("", new List(), (ofSeq$1(tokens)));
return reverse(list$$1);
}
function capitalize(input) {
if (isNullOrWhiteSpace(input)) {
return "";
} else {
const arg10$$1 = input[0].toLocaleUpperCase();
const arg20 = substring(input, 1);
const clo1$$1 = toText(printf("%c%s"));
const clo2 = clo1$$1(arg10$$1);
return clo2(arg20);
}
}
function lowerFirst(input$$1) {
if (isNullOrWhiteSpace(input$$1)) {
return "";
} else {
const arg10$$2 = input$$1[0].toLocaleLowerCase();
const arg20$$1 = substring(input$$1, 1);
const clo1$$2 = toText(printf("%c%s"));
const clo2$$1 = clo1$$2(arg10$$2);
return clo2$$1(arg20$$1);
}
}
function isIdentifier(input$$2) {
if (isNullOrWhiteSpace(input$$2)) {
return false;
} else if (forAll(function isLetterOrDigitOrUnderscore(c) {
if (isLetterOrDigit(c)) {
return true;
} else {
return c === "_";
}
}, input$$2.split("")) ? !(input$$2 === "_") : false) {
return !isDigit(input$$2, 0);
} else {
return false;
}
}
function asIdentifier(input$$3) {
return Array.from(map$1(function mapping(c$$1) {
if (isLetterOrDigit(c$$1)) {
return c$$1;
} else {
return "_";
}
}, input$$3.split(""))).join("");
}
function createEnumName(s$$1) {
if (isNullOrWhiteSpace(s$$1)) {
return "Empty";
} else {
let nm;
let strings;
let list$$2;
list$$2 = createEnumNameParts(s$$1);
strings = map$2(capitalize, list$$2);
nm = join("", strings);
if (isIdentifier(nm)) {
return nm;
} else {
return "``" + replace(nm, "`", "'") + "``";
}
}
}
function nameEqualsDefaultFableValue(name$$2, value$$1) {
let defaultFableValue;
const arg10$$3 = substring(name$$2, 0, 1).toLocaleLowerCase();
const arg20$$2 = substring(name$$2, 1);
const clo1$$3 = toText(printf("%s%s"));
const clo2$$2 = clo1$$3(arg10$$3);
defaultFableValue = clo2$$2(arg20$$2);
return defaultFableValue === value$$1;
}
function createModuleNameParts(name$$3) {
const tokens$$1 = map$1(function (value$$2) {
return value$$2;
}, name$$3.split(""));
const splitParts$$1 = function splitParts$$1($part$$1$$31, $parts$$3$$32, $_arg1$$1$$33) {
splitParts$$1: while (true) {
const part$$1 = $part$$1$$31,
parts$$3 = $parts$$3$$32,
_arg1$$1 = $_arg1$$1$$33;
if (_arg1$$1.tail != null) {
if (_arg1$$1.head === "-") {
$part$$1$$31 = "";
$parts$$3$$32 = new List(part$$1, parts$$3);
$_arg1$$1$$33 = _arg1$$1.tail;
continue splitParts$$1;
} else if (_arg1$$1.head === "/") {
$part$$1$$31 = "";
$parts$$3$$32 = new List(part$$1, parts$$3);
$_arg1$$1$$33 = _arg1$$1.tail;
continue splitParts$$1;
} else if (_arg1$$1.head === ".") {
$part$$1$$31 = "";
$parts$$3$$32 = new List(part$$1, parts$$3);
$_arg1$$1$$33 = _arg1$$1.tail;
continue splitParts$$1;
} else {
$part$$1$$31 = part$$1 + _arg1$$1.head;
$parts$$3$$32 = parts$$3;
$_arg1$$1$$33 = _arg1$$1.tail;
continue splitParts$$1;
}
} else {
return new List(part$$1, parts$$3);
}
}
};
const list$$3 = splitParts$$1("", new List(), (ofSeq$1(tokens$$1)));
return reverse(list$$3);
}
function escapeWord(s$$2) {
if (isNullOrEmpty(s$$2)) {
return "";
} else {
const s$$3 = replace(s$$2, "'", "");
if (((((FSharpSet$$Contains$$2B595(reserved, s$$3) ? true : FSharpSet$$Contains$$2B595(keywords, s$$3)) ? true : indexOfAny(s$$3, ["-", "/", "$"]) !== -1) ? true : s$$3.length > 0 ? isDigit(s$$3, 0) : false) ? true : indexOfAny(substring(s$$3, 0, 1), [".", "["]) !== -1) ? true : s$$3 === "_") {
const clo1$$4 = toText(printf("``%s``"));
return clo1$$4(s$$3);
} else {
return s$$3;
}
}
}
function escapeProperty(s$$4) {
if (isNullOrEmpty(s$$4)) {
return "";
} else if ((FSharpSet$$Contains$$2B595(reserved, s$$4) ? true : FSharpSet$$Contains$$2B595(keywords, s$$4)) ? true : !isIdentifier(s$$4)) {
const clo1$$5 = toText(printf("``%s``"));
return clo1$$5(s$$4);
} else {
return s$$4;
}
}
function fixModuleName(s$$5) {
const s$$6 = replace(s$$5, "'", "");
const s$$7 = capitalize(s$$6);
let s$$8;
let parts$$4;
parts$$4 = createModuleNameParts(s$$7);
s$$8 = join("_", parts$$4);
let s$$9;
if (FSharpSet$$Contains$$2B595(reserved, s$$8) ? true : FSharpSet$$Contains$$2B595(keywords, s$$8)) {
const clo1$$6 = toText(printf("%s_"));
s$$9 = clo1$$6(s$$8);
} else {
s$$9 = s$$8;
}
return s$$9;
}
function removeQuotes(s$$10) {
if (isNullOrEmpty(s$$10)) {
return "";
} else {
const c$$2 = s$$10[0];
if (c$$2 === "\"" ? true : c$$2 === "'") {
return trim(s$$10, c$$2);
} else {
return s$$10;
}
}
}
function makePartName(s$$11) {
let parts$$5;
const name$$5 = trim(s$$11, "`");
parts$$5 = createModuleNameParts(name$$5);
let name$$6;
let strings$$2;
strings$$2 = map$2(capitalize, parts$$5);
name$$6 = join("", strings$$2);
return asIdentifier(name$$6);
}
function getJsModuleName(path) {
let parts$$6;
let x$$2;
let x$$1;
const inm = path.lastIndexOf("node_modules") | 0;
x$$1 = inm === -1 ? path : substring(path, inm + 13);
const is = x$$1.lastIndexOf("@") | 0;
x$$2 = is === -1 ? x$$1 : substring(x$$1, is);
let list$$5;
const array = x$$2.split("/");
list$$5 = ofArray(array);
parts$$6 = filter$1(function predicate$$1(s$$12) {
if (s$$12 !== "index.d.ts") {
return s$$12 !== "types";
} else {
return false;
}
}, list$$5);
let out;
var $target$$41, x$$5, xs$$2, x$$6, xs$$3;
if (parts$$6.tail != null) {
if (parts$$6.head === "@types") {
if (parts$$6.tail.tail != null) {
$target$$41 = 0;
x$$5 = parts$$6.tail.head;
xs$$2 = parts$$6.tail.tail;
} else if (parts$$6.head.indexOf("@") === 0) {
$target$$41 = 1;
x$$6 = parts$$6.head;
xs$$3 = parts$$6.tail;
} else {
$target$$41 = 2;
}
} else if (parts$$6.head.indexOf("@") === 0) {
$target$$41 = 1;
x$$6 = parts$$6.head;
xs$$3 = parts$$6.tail;
} else {
$target$$41 = 2;
}
} else {
$target$$41 = 2;
}
switch ($target$$41) {
case 0:
{
const xs$0027 = new List(replace(x$$5, "__", "/"), xs$$2);
out = join("/", xs$0027);
break;
}
case 1:
{
out = join("/", new List(x$$6, xs$$3));
break;
}
case 2:
{
out = head(parts$$6);
break;
}
}
return replace(replace(out, ".ts", ""), ".d", "");
}
const primatives = (() => {
const elements = ofArray(["string", "obj", "unit", "float", "bool"]);
return ofList$1(elements, {
Compare: comparePrimitives
});
})();
function fixNamespaceString(name$$7) {
if (FSharpSet$$Contains$$2B595(primatives, name$$7)) {
return name$$7;
} else {
const parts$$7 = name$$7.split(".");
if (parts$$7.length === 1) {
return name$$7;
} else {
let parts$$8;
let list$$6;
list$$6 = ofArray(parts$$7);
parts$$8 = reverse(list$$6);
let parts$$9;
const list$$7 = append$1(new List(head(parts$$8), new List()), tail(parts$$8));
parts$$9 = map$2(fixModuleName, list$$7);
let strings$$3;
strings$$3 = reverse(parts$$9);
return join(".", strings$$3);
}
}
}
function printType($tp$$1) {
printType: while (true) {
const tp = $tp$$1;
switch (tp.tag) {
case 7:
{
return tp.fields[0].Name;
}
case 4:
{
const arg10 = printType(tp.fields[0]);
const clo1 = toText(printf("ResizeArray<%s>"));
return clo1(arg10);
}
case 9:
{
if (length(tp.fields[0].Types) === 1) {
const arg10$$1 = printType(item(0, tp.fields[0].Types));
const arg20 = tp.fields[0].Option ? " option" : "";
const clo1$$1 = toText(printf("%s%s"));
const clo2 = clo1$$1(arg10$$1);
return clo2(arg20);
} else {
const line = [];
let arg00;
const arg10$$2 = length(tp.fields[0].Types) | 0;
const clo1$$2 = toText(printf("U%d<"));
arg00 = clo1$$2(arg10$$2);
line.push(arg00);
let arg00$$1;
let strings;
strings = map$2(printType, tp.fields[0].Types);
arg00$$1 = join(", ", strings);
line.push(arg00$$1);
let arg00$$2;
const arg10$$3 = tp.fields[0].Option ? " option" : "";
const clo1$$3 = toText(printf(">%s"));
arg00$$2 = clo1$$3(arg10$$3);
line.push(arg00$$2);
return join("", line);
}
}
case 11:
{
const line$$1 = [];
let arg00$$3;
const arg10$$4 = printType(tp.fields[0].Type);
const clo1$$4 = toText(printf("%s"));
arg00$$3 = clo1$$4(arg10$$4);
line$$1.push(arg00$$3);
if (length(tp.fields[0].TypeParameters) > 0) {
line$$1.push("<");
let arg00$$5;
let strings$$2;
strings$$2 = map$2(printType, tp.fields[0].TypeParameters);
arg00$$5 = join(", ", strings$$2);
line$$1.push(arg00$$5);
line$$1.push(">");
}
return join("", line$$1);
}
case 8:
{
const line$$2 = [];
const typs = length(tp.fields[0].Params) === 0 ? ofArray([simpleType("unit"), tp.fields[0].ReturnType]) : append$1((map$2(function mapping$$2(p) {
return p.Type;
}, tp.fields[0].Params)), new List(tp.fields[0].ReturnType, new List()));
line$$2.push("(");
let arg00$$8;
let strings$$4;
strings$$4 = map$2(printType, typs);
arg00$$8 = join(" -> ", strings$$4);
line$$2.push(arg00$$8);
line$$2.push(")");
return join("", line$$2);
}
case 12:
{
const line$$3 = [];
let arg00$$10;
let strings$$6;
strings$$6 = map$2(printType, tp.fields[0].Types);
arg00$$10 = join(" * ", strings$$6);
line$$3.push(arg00$$10);
return join("", line$$3);
}
case 16:
{
let vtp;
vtp = printType(tp.fields[0].Type);
const arg30 = tp.fields[0].IsConst ? "" : " with get, set";
const clo1$$5 = toText(printf("abstract %s: %s%s"));
const clo2$$1 = clo1$$5(tp.fields[0].Name);
const clo3 = clo2$$1(vtp);
return clo3(arg30);
}
case 17:
{
return "string";
}
case 2:
{
$tp$$1 = tp.fields[0].Type;
continue printType;
}
case 1:
{
const arg10$$6 = getTypeName(tp);
const arg20$$2 = getName(tp);
const clo1$$6 = toConsole(printf("unextracted printType %s: %s"));
const clo2$$2 = clo1$$6(arg10$$6);
clo2$$2(arg20$$2);
return printEnumType(tp.fields[0]);
}
default:
{
const arg10$$7 = getTypeName(tp);
const arg20$$3 = getName(tp);
const clo1$$7 = toConsole(printf("unsupported printType %s: %s"));
const clo2$$3 = clo1$$7(arg10$$7);
clo2$$3(arg20$$3);
return "obj";
}
}
}
}
function printEnumType(en$$1) {
const matchValue = FsEnum$$get_Type(en$$1);
switch (matchValue.tag) {
case 1:
{
return "string";
}
case 2:
{
return "obj";
}
default:
{
return "float";
}
}
}
function printFunction(fn) {
const line$$4 = [];
if (fn.Kind.tag === 1) {
line$$4.push("[<Emit \"new $0($1...)\">] ");
} else if (fn.Kind.tag === 2) {
line$$4.push("[<Emit \"$0($1...)\">] ");
} else if (fn.Kind.tag === 3) {
let arg00$$13;
const clo1$$8 = toText(printf("[<Emit \"%s\">] "));
arg00$$13 = clo1$$8(fn.Kind.fields[0]);
line$$4.push(arg00$$13);
}
let arg00$$14;
const arg10$$9 = fn.Name;
const clo1$$9 = toText(printf("abstract %s"));
arg00$$14 = clo1$$9(arg10$$9);
line$$4.push(arg00$$14);
let prms;
prms = map$2(function mapping$$5(p$$2) {
if (p$$2.ParamArray) {
const arg10$$10 = p$$2.Optional ? "?" : "";
let arg30$$1;
if (p$$2.Type.tag === 4) {
arg30$$1 = printType(p$$2.Type);
} else {
const arg10$$11 = getName(new FsType(8, "Function", fn));
const clo1$$11 = toConsole(printf("ParamArray function is not an array type: %s"));
clo1$$11(arg10$$11);
arg30$$1 = printType(p$$2.Type);
}
const clo1$$10 = toText(printf("[<ParamArray>] %s%s: %s"));
const clo2$$4 = clo1$$10(arg10$$10);
const clo3$$1 = clo2$$4(p$$2.Name);
return clo3$$1(arg30$$1);
} else {
const arg10$$12 = p$$2.Optional ? "?" : "";
const arg30$$2 = printType(p$$2.Type);
const clo1$$12 = toText(printf("%s%s: %s"));
const clo2$$5 = clo1$$12(arg10$$12);
const clo3$$2 = clo2$$5(p$$2.Name);
return clo3$$2(arg30$$2);
}
}, fn.Params);
if (length(prms) === 0) {
const arg00$$15 = toText(printf(": unit"));
line$$4.push(arg00$$15);
} else {
let arg00$$16;
let arg10$$13;
arg10$$13 = join(" * ", prms);
const clo1$$13 = toText(printf(": %s"));
arg00$$16 = clo1$$13(arg10$$13);
line$$4.push(arg00$$16);
}
let arg00$$17;
const arg10$$14 = printType(fn.ReturnType);
const clo1$$14 = toText(printf(" -> %s"));
arg00$$17 = clo1$$14(arg10$$14);
line$$4.push(arg00$$17);
return join("", line$$4);
}
function printProperty(pr) {
const arg10$$15 = pr.Kind.tag === 1 ? "[<Emit \"$0[$1]{{=$2}}\">] " : "";
let arg30$$3;
if (pr.Index != null) {
const idx = pr.Index;
const arg20$$7 = printType(idx.Type);
const clo1$$16 = toText(printf("%s: %s -> "));
const clo2$$7 = clo1$$16(idx.Name);
arg30$$3 = clo2$$7(arg20$$7);
} else {
arg30$$3 = "";
}
const arg40 = printType(pr.Type);
const arg50 = pr.Option ? " option" : "";
const arg60 = pr.IsReadonly ? "" : " with get, set";
const clo1$$15 = toText(printf("%sabstract %s: %s%s%s%s"));
const clo2$$6 = clo1$$15(arg10$$15);
const clo3$$3 = clo2$$6(pr.Name);
const clo4 = clo3$$3(arg30$$3);
const clo5 = clo4(arg40);
const clo6 = clo5(arg50);
return clo6(arg60);
}
function printTypeParameters(tps) {
if (length(tps) === 0) {
return "";
} else {
const line$$5 = [];
line$$5.push("<");
let arg00$$18;
let strings$$10;
strings$$10 = map$2(printType, tps);
arg00$$18 = join(", ", strings$$10);
line$$5.push(arg00$$18);
line$$5.push(">");
return join("", line$$5);
}
}
function printComments(lines, indent, comments) {
if (exists$1(FsCommentModule$$$isParam, comments)) {
let summaryLines;
summaryLines = choose(FsCommentModule$$$asSummaryLine, comments);
iterateIndexed$1(function action(i, desc) {
let arg00$$19;
const arg20$$8 = i === 0 ? "<summary>" : "";
const arg40$$1 = i === length(summaryLines) - 1 ? "</summary>" : "";
const clo1$$17 = toText(printf("%s/// %s%s%s"));
const clo2$$8 = clo1$$17(indent);
const clo3$$4 = clo2$$8(arg20$$8);
const clo4$$1 = clo3$$4(desc);
arg00$$19 = clo4$$1(arg40$$1);
lines.push(arg00$$19);
}, summaryLines);
let list$$12;
list$$12 = choose(FsCommentModule$$$asParam, comments);
iterate$1(function action$$2(comment) {
iterateIndexed$1(function action$$1(i$$1, desc$$1) {
let arg00$$20;
let arg20$$9;
if (i$$1 === 0) {
const clo1$$19 = toText(printf("<param name=\"%s\">"));
arg20$$9 = clo1$$19(comment.Name);
} else {
arg20$$9 = "";
}
const arg40$$2 = i$$1 === length(comment.Description) - 1 ? "</param>" : "";
const clo1$$18 = toText(printf("%s/// %s%s%s"));
const clo2$$9 = clo1$$18(indent);
const clo3$$5 = clo2$$9(arg20$$9);
const clo4$$2 = clo3$$5(desc$$1);
arg00$$20 = clo4$$2(arg40$$2);
lines.push(arg00$$20);
}, comment.Description);
}, list$$12);
} else {
let list$$14;
list$$14 = choose(FsCommentModule$$$asSummaryLine, comments);
iterate$1(function action$$3(comment$$1) {
let arg00$$21;
const clo1$$20 = toText(printf("%s/// %s"));
const clo2$$10 = clo1$$20(indent);
arg00$$21 = clo2$$10(comment$$1);
lines.push(arg00$$21);
}, list$$14);
}
}
function printEnum(lines$$1, indent$$1, en$$2) {
const arg00$$22 = toText(printf(""));
lines$$1.push(arg00$$22);
const matchValue$$5 = FsEnum$$get_Type(en$$2);
switch (matchValue$$5.tag) {
case 1:
{
let arg00$$27;
const clo1$$25 = toText(printf("%stype [<StringEnum>] [<RequireQualifiedAccess>] %s ="));
const clo2$$13 = clo1$$25(indent$$1);
arg00$$27 = clo2$$13(en$$2.Name);
lines$$1.push(arg00$$27);
iterate(function (cs$$1) {
const v$$4 = replace((defaultArg(cs$$1.Value, cs$$1.Name)), "\"", "\\\"");
const unm$$1 = createEnumName(cs$$1.Name);
const line$$7 = [];
if (nameEqualsDefaultFableValue(unm$$1, v$$4)) {
let arg00$$28;
const clo1$$26 = toText(printf(" | %s"));
arg00$$28 = clo1$$26(unm$$1);
line$$7.push(arg00$$28);
} else {
let arg00$$29;
const clo1$$27 = toText(printf(" | [<CompiledName \"%s\">] %s"));
const clo2$$14 = clo1$$27(v$$4);
arg00$$29 = clo2$$14(unm$$1);
line$$7.push(arg00$$29);
}
let arg00$$30;
let arg20$$15;
arg20$$15 = join("", line$$7);
const clo1$$28 = toText(printf("%s%s"));
const clo2$$15 = clo1$$28(indent$$1);
arg00$$30 = clo2$$15(arg20$$15);
lines$$1.push(arg00$$30);
}, en$$2.Cases);
break;
}
case 2:
{
let arg00$$31;
const clo1$$29 = toText(printf("%stype %s ="));
const clo2$$16 = clo1$$29(indent$$1);
arg00$$31 = clo2$$16(en$$2.Name);
lines$$1.push(arg00$$31);
let arg00$$32;
const clo1$$30 = toText(printf("%s obj"));
arg00$$32 = clo1$$30(indent$$1);
lines$$1.push(arg00$$32);
break;
}
default:
{
let arg00$$23;
const clo1$$21 = toText(printf("%stype [<RequireQualifiedAccess>] %s ="));
const clo2$$11 = clo1$$21(indent$$1);
arg00$$23 = clo2$$11(en$$2.Name);
lines$$1.push(arg00$$23);
iterate(function (cs) {
const unm = createEnumName(cs.Name);
const line$$6 = [];
let arg00$$24;
const clo1$$22 = toText(printf(" | %s"));
arg00$$24 = clo1$$22(unm);
line$$6.push(arg00$$24);
if (cs.Value != null) {
let arg00$$25;
const arg10$$23 = cs.Value;
const clo1$$23 = toText(printf(" = %s"));
arg00$$25 = clo1$$23(arg10$$23);
line$$6.push(arg00$$25);
}
let arg00$$26;
let arg20$$12;
arg20$$12 = join("", line$$6);
const clo1$$24 = toText(printf("%s%s"));
const clo2$$12 = clo1$$24(indent$$1);
arg00$$26 = clo2$$12(arg20$$12);
lines$$1.push(arg00$$26);
}, en$$2.Cases);
}
}
}
function printModule(lines$$2, indent$$2, md) {
const lineCountStart = lines$$2.length | 0;
let indent$$3;
if (md.Name !== "") {
lines$$2.push("");
if (FsModule$$get_HasAttributes(md)) {
let arg00$$34;
let arg20$$17;
arg20$$17 = join("; ", md.Attributes);
const clo1$$31 = toText(printf("%s[<%s)>]"));
const clo2$$17 = clo1$$31(indent$$2);
arg00$$34 = clo2$$17(arg20$$17);
lines$$2.push(arg00$$34);
}
let arg00$$35;
const clo1$$32 = toText(printf("%smodule %s ="));
const clo2$$18 = clo1$$32(indent$$2);
arg00$$35 = clo2$$18(md.Name);
lines$$2.push(arg00$$35);
const clo1$$33 = toText(printf("%s "));
indent$$3 = clo1$$33(indent$$2);
} else {
indent$$3 = indent$$2;
}
iterate(function (line$$8) {
let arg00$$36;
const clo1$$34 = toText(printf("%s%s"));
const clo2$$19 = clo1$$34(indent$$3);
arg00$$36 = clo2$$19(line$$8);
lines$$2.push(arg00$$36);
}, md.HelperLines);
iterate(function (tp$$8) {
if (tp$$8.tag === 20) {
if (tp$$8.fields[0].tag === 1) {
if (tp$$8.fields[0].fields[0].Module !== tp$$8.fields[0].fields[0].SpecifiedModule) {
let arg00$$37;
const clo1$$35 = toText(printf("%smodule %s = %s"));
const clo2$$20 = clo1$$35(indent$$3);
const clo3$$6 = clo2$$20(tp$$8.fields[0].fields[0].Module);
arg00$$37 = clo3$$6(tp$$8.fields[0].fields[0].SpecifiedModule);
lines$$2.push(arg00$$37);
}
}
}
}, md.Types);
iterate(function (tp$$9) {
if (tp$$9.tag === 20) {
if (tp$$9.fields[0].tag === 0) {
if (tp$$9.fields[0].fields[0].ImportSpecifier.PropertyName == null) {
let arg00$$39;
const clo1$$37 = toText(printf("%stype %s = %s.%s"));
const clo2$$22 = clo1$$37(indent$$3);
const clo3$$8 = clo2$$22(tp$$9.fields[0].fields[0].ImportSpecifier.Name);
const clo4$$4 = clo3$$8(tp$$9.fields[0].fields[0].SpecifiedModule);
arg00$$39 = clo4$$4(tp$$9.fields[0].fields[0].ImportSpecifier.Name);
lines$$2.push(arg00$$39);
} else {
const pn = tp$$9.fields[0].fields[0].ImportSpecifier.PropertyName;
let arg00$$38;
const clo1$$36 = toText(printf("%stype %s = %s.%s"));
const clo2$$21 = clo1$$36(indent$$3);
const clo3$$7 = clo2$$21(tp$$9.fields[0].fields[0].ImportSpecifier.Name);
const clo4$$3 = clo3$$7(tp$$9.fields[0].fields[0].SpecifiedModule);
arg00$$38 = clo4$$3(pn);
lines$$2.push(arg00$$38);
}
}
}
}, md.Types);
iterate(function (tp$$10) {
switch (tp$$10.tag) {
case 0:
{
var $target$$23, en$$3;
if (tp$$10.fields[0].Members.tail != null) {
if (tp$$10.fields[0].Members.head.tag === 1) {
if (tp$$10.fields[0].Members.tail.tail == null) {
$target$$23 = 0;
en$$3 = tp$$10.fields[0].Members.head.fields[0];
} else {
$target$$23 = 1;
}
} else {
$target$$23 = 1;
}
} else {
$target$$23 = 1;
}
switch ($target$$23) {
case 0:
{
const en$$4 = new FsEnum(tp$$10.fields[0].Name, en$$3.Cases);
printEnum(lines$$2, indent$$3, en$$4);
break;
}
case 1:
{
const arg00$$40 = toText(printf(""));
lines$$2.push(arg00$$40);
printComments(lines$$2, indent$$3, tp$$10.fields[0].Comments);
let arg00$$41;
const arg30$$9 = printTypeParameters(tp$$10.fields[0].TypeParameters);
const clo1$$38 = toText(printf("%stype [<AllowNullLiteral>] %s%s ="));
const clo2$$23 = clo1$$38(indent$$3);
const clo3$$9 = clo2$$23(tp$$10.fields[0].Name);
arg00$$41 = clo3$$9(arg30$$9);
lines$$2.push(arg00$$41);
const nLines = new FSharpRef(0);
iterate(function (ih) {
let arg00$$42;
const arg20$$24 = printType(ih);
const clo1$$39 = toText(printf("%s inherit %s"));
const clo2$$24 = clo1$$39(indent$$3);
arg00$$42 = clo2$$24(arg20$$24);
lines$$2.push(arg00$$42);
void nLines.contents++;
}, tp$$10.fields[0].Inherits);
iterate(function (mbr) {
switch (mbr.tag) {
case 8:
{
let indent$$4;
const clo1$$40 = toText(printf("%s "));
indent$$4 = clo1$$40(indent$$3);
printComments(lines$$2, indent$$4, FsFunction$$get_AllComments(mbr.fields[0]));
let arg00$$43;
const arg20$$25 = printFunction(mbr.fields[0]);
const clo1$$41 = toText(printf("%s%s"));
const clo2$$25 = clo1$$41(indent$$4);
arg00$$43 = clo2$$25(arg20$$25);
lines$$2.push(arg00$$43);
void nLines.contents++;
break;
}
case 2:
{
let indent$$5;
const clo1$$42 = toText(printf("%s "));
indent$$5 = clo1$$42(indent$$3);
printComments(lines$$2, indent$$5, mbr.fields[0].Comments);
let arg00$$44;
const arg20$$26 = printProperty(mbr.fields[0]);
const clo1$$43 = toText(printf("%s%s"));
const clo2$$26 = clo1$$43(indent$$5);
arg00$$44 = clo2$$26(arg20$$26);
lines$$2.push(arg00$$44);
void nLines.contents++;
break;
}
default:
{
let arg00$$45;
const arg20$$27 = printType(mbr);
const clo1$$44 = toText(printf("%s %s"));
const clo2$$27 = clo1$$44(indent$$3);
arg00$$45 = clo2$$27(arg20$$27);
lines$$2.push(arg00$$45);
void nLines.contents++;
}
}
}, tp$$10.fields[0].Members);
if (nLines.contents === 0) {
let arg00$$46;
const clo1$$45 = toText(printf("%s interface end"));
arg00$$46 = clo1$$45(indent$$3);
lines$$2.push(arg00$$46);
}
break;
}
}
break;
}
case 1:
{
printEnum(lines$$2, indent$$3, tp$$10.fields[0]);
break;
}
case 10:
{
const arg00$$47 = toText(printf(""));
lines$$2.push(arg00$$47);
let arg00$$48;
const arg30$$10 = printTypeParameters(tp$$10.fields[0].TypeParameters);
const clo1$$46 = toText(printf("%stype %s%s ="));
const clo2$$28 = clo1$$46(indent$$3);
const clo3$$10 = clo2$$28(tp$$10.fields[0].Name);
arg00$$48 = clo3$$10(arg30$$10);
lines$$2.push(arg00$$48);
let arg00$$49;
const arg20$$29 = printType(tp$$10.fields[0].Type);
const clo1$$47 = toText(printf("%s %s"));
const clo2$$29 = clo1$$47(indent$$3);
arg00$$49 = clo2$$29(arg20$$29);
lines$$2.push(arg00$$49);
break;
}
case 13:
{
printModule(lines$$2, indent$$3, tp$$10.fields[0]);
break;
}
case 16:
{
if (tp$$10.fields[0].HasDeclare) {
let arg00$$50;
let arg20$$30;
if (tp$$10.fields[0].Export != null) {
const ep = tp$$10.fields[0].Export;
if (ep.IsGlobal) {
arg20$$30 = "[<Global>] ";
} else {
const clo1$$49 = toText(printf("[<Import(\"%s\",\"%s\")>] "));
const clo2$$31 = clo1$$49(ep.Selector);
arg20$$30 = clo2$$31(ep.Path);
}
} else {
arg20$$30 = "";
}
const arg40$$5 = printType(tp$$10.fields[0].Type);
const clo1$$48 = toText(printf("%slet %s%s: %s = jsNative"));
const clo2$$30 = clo1$$48(indent$$3);
const clo3$$11 = clo2$$30(arg20$$30);
const clo4$$5 = clo3$$11(tp$$10.fields[0].Name);
arg00$$50 = clo4$$5(arg40$$5);
lines$$2.push(arg00$$50);
}
break;
}
}
}, md.Types);
const addedLines = lines$$2.length - lineCountStart | 0;
if (addedLines === 2) {
for (let forLoopVar = 0; forLoopVar <= 1; forLoopVar++) {
lines$$2.splice(lines$$2.length - 1, 1);
}
}
}
function printFsFile(version, file) {
const lines$$3 = [];
let arg00$$51;
const clo1$$50 = toText(printf("// ts2fable %s"));
arg00$$51 = clo1$$50(version);
lines$$3.push(arg00$$51);
let arg00$$52;
const clo1$$51 = toText(printf("module rec %s"));
arg00$$52 = clo1$$51(file.Namespace);
lines$$3.push(arg00$$52);
iterate(function (opn) {
let arg00$$53;
const clo1$$52 = toText(printf("open %s"));
arg00$$53 = clo1$$52(opn);
lines$$3.push(arg00$$53);
}, file.Opens);
if (!(file.AbbrevTypes.tail == null)) {
lines$$3.push("");
iterate$1(function action$$4(arg00$$54) {
lines$$3.push(arg00$$54);
}, file.AbbrevTypes);
}
lines$$3.push("");
iterate(function (f$$1) {
let list$$17;
list$$17 = filter$1(function predicate(md$$1) {
return length(md$$1.Types) > 0;
}, f$$1.Modules);
iterate$1(function action$$5(md$$2) {
printModule(lines$$3, "", md$$2);
}, list$$17);
}, file.Files);
return lines$$3;
}
function getAllTypesFromFile(fsFile) {
const tps = [];
let value;
value = fixFile(function fix(ns, tp) {
tps.push(tp);
return tp;
}, fsFile);
return ofSeq$1(tps);
}
function getAllTypes(fsFiles) {
return collect$1(getAllTypesFromFile, fsFiles);
}
function fixTypeEx(ns$$1, doFix, fix$$1, tp$$1) {
var s;
const ns$$2 = tp$$1.tag === 13 ? ns$$1 : ns$$1 + (s = getName(tp$$1), (makePartName(s)));
const fixType$$1 = function fixType$$1(tp$$2) {
return fixTypeEx(ns$$2, doFix, fix$$1, tp$$2);
};
const fixModule = function fixModule(a) {
let Types;
Types = map$2(fixType$$1, a.Types);
return new FsModule(a.HasDeclare, a.IsNamespace, a.Name, Types, a.HelperLines, a.Attributes);
};
const fixFile$$1 = function fixFile$$1(f$$1) {
let Modules;
Modules = map$2(fixModule, f$$1.Modules);
return new FsFile(f$$1.Kind, f$$1.FileName, f$$1.ModuleName, Modules);
};
const fixParam = function fixParam(a$$1) {
let b;
let arg0;
const Type = fixType$$1(a$$1.Type);
arg0 = new FsParam(a$$1.Comment, a$$1.Name, a$$1.Optional, a$$1.ParamArray, Type);
b = new FsType(3, "Param", arg0);
const matchValue = fix$$1(ns$$2, b);
if (matchValue.tag === 3) {
return matchValue.fields[0];
} else {
return toFail(printf("param must be mapped to param"));
}
};
let t;
if (!doFix(tp$$1)) {
t = tp$$1;
} else {
switch (tp$$1.tag) {
case 21:
{
const arg0$$2 = new FsTypeLiteral((map$2(fixType$$1, tp$$1.fields[0].Members)));
t = new FsType(21, "TypeLiteral", arg0$$2);
break;
}
case 2:
{
let arg0$$3;
const Index = map(fixParam, tp$$1.fields[0].Index);
const Type$$1 = fixType$$1(tp$$1.fields[0].Type);
arg0$$3 = new FsProperty(tp$$1.fields[0].Comments, tp$$1.fields[0].Kind, Index, tp$$1.fields[0].Name, tp$$1.fields[0].Option, Type$$1, tp$$1.fields[0].IsReadonly, tp$$1.fields[0].IsStatic, tp$$1.fields[0].Accessibility);
t = new FsType(2, "Property", arg0$$3);
break;
}
case 3:
{
let arg0$$4;
const Type$$2 = fixType$$1(tp$$1.fields[0].Type);
arg0$$4 = new FsParam(tp$$1.fields[0].Comment, tp$$1.fields[0].Name, tp$$1.fields[0].Optional, tp$$1.fields[0].ParamArray, Type$$2);
t = new FsType(3, "Param", arg0$$4);
break;
}
case 4:
{
const arg0$$5 = fixType$$1(tp$$1.fields[0]);
t = new FsType(4, "Array", arg0$$5);
break;
}
case 8:
{
let arg0$$6;
let TypeParameters$$1;
TypeParameters$$1 = map$2(fixType$$1, tp$$1.fields[0].TypeParameters);
let Params;
Params = map$2(fixParam, tp$$1.fields[0].Params);
const ReturnType = fixType$$1(tp$$1.fields[0].ReturnType);
arg0$$6 = new FsFunction(tp$$1.fields[0].Comments, tp$$1.fields[0].Kind, tp$$1.fields[0].IsStatic, tp$$1.fields[0].Name, TypeParameters$$1, Params, ReturnType, tp$$1.fields[0].Accessibility);
t = new FsType(8, "Function", arg0$$6);
break;
}
case 9:
{
let arg0$$7;
let Types$$1;
Types$$1 = map$2(fixType$$1, tp$$1.fields[0].Types);
arg0$$7 = new FsUnion(tp$$1.fields[0].Option, Types$$1);
t = new FsType(9, "Union", arg0$$7);
break;
}
case 10:
{
let arg0$$8;
const Type$$3 = fixType$$1(tp$$1.fields[0].Type);
let TypeParameters$$2;
TypeParameters$$2 = map$2(fixType$$1, tp$$1.fields[0].TypeParameters);
arg0$$8 = new FsAlias(tp$$1.fields[0].Name, Type$$3, TypeParameters$$2);
t = new FsType(10, "Alias", arg0$$8);
break;
}
case 11:
{
const arg0$$9 = new FsGenericType(fixType$$1(tp$$1.fields[0].Type), (map$2(fixType$$1, tp$$1.fields[0].TypeParameters)));
t = new FsType(11, "Generic", arg0$$9);
break;
}
case 12:
{
const arg0$$10 = new FsTuple((map$2(fixType$$1, tp$$1.fields[0].Types)), tp$$1.fields[0].Kind);
t = new FsType(12, "Tuple", arg0$$10);
break;
}
case 13:
{
const arg0$$11 = fixModule(tp$$1.fields[0]);
t = new FsType(13, "Module", arg0$$11);
break;
}
case 14:
{
const arg0$$12 = fixFile$$1(tp$$1.fields[0]);
t = new FsType(14, "File", arg0$$12);
break;
}
case 15:
{
let arg0$$13;
let Files;
Files = map$2(fixFile$$1, tp$$1.fields[0].Files);
arg0$$13 = new FsFileOut(tp$$1.fields[0].Namespace, tp$$1.fields[0].Opens, Files, tp$$1.fields[0].AbbrevTypes);
t = new FsType(15, "FileOut", arg0$$13);
break;
}
case 16:
{
let arg0$$14;
const Type$$4 = fixType$$1(tp$$1.fields[0].Type);
arg0$$14 = new FsVariable(tp$$1.fields[0].Export, tp$$1.fields[0].HasDeclare, tp$$1.fields[0].Name, Type$$4, tp$$1.fields[0].IsConst, tp$$1.fields[0].IsStatic, tp$$1.fields[0].Accessibility);
t = new FsType(16, "Variable", arg0$$14);
break;
}
case 18:
{
t = tp$$1;
break;
}
case 1:
{
t = tp$$1;
break;
}
case 7:
{
t = tp$$1;
break;
}
case 6:
{
t = tp$$1;
break;
}
case 5:
{
t = tp$$1;
break;
}
case 17:
{
t = tp$$1;
break;
}
case 19:
{
t = tp$$1;
break;
}
case 20:
{
t = tp$$1;
break;
}
case 22:
{
const arg0$$15 = new FsGenericParameterDefaults(fixType$$1(tp$$1.fields[0].Default), tp$$1.fields[0].Name, tp$$1.fields[0].FullName);
t = new FsType(22, "GenericParameterDefaults", arg0$$15);
break;
}
default:
{
let arg0$$1;
let TypeParameters;
TypeParameters = map$2(fixType$$1, tp$$1.fields[0].TypeParameters);
let Inherits;
Inherits = map$2(fixType$$1, tp$$1.fields[0].Inherits);
let Members;
Members = map$2(fixType$$1, tp$$1.fields[0].Members);
arg0$$1 = new FsInterface(tp$$1.fields[0].Comments, tp$$1.fields[0].IsStatic, tp$$1.fields[0].IsClass, tp$$1.fields[0].Name, tp$$1.fields[0].FullName, TypeParameters, Inherits, Members, tp$$1.fields[0].Accessibility);
t = new FsType(0, "Interface", arg0$$1);
}
}
}
if (doFix(t)) {
return fix$$1(ns$$2, t);
} else {
return t;
}
}
function fixType(ns$$3, fix$$2, tp$$6) {
return fixTypeEx(ns$$3, function (_arg1) {
return true;
}, fix$$2, tp$$6);
}
function fixFileEx(doFix$$1, fix$$3, f$$3) {
let Modules$$1;
let list$$16;
let list$$15;
list$$15 = map$2(function mapping$$1(arg0$$16) {
return new FsType(13, "Module", arg0$$16);
}, f$$3.Modules);
list$$16 = map$2(function mapping$$2(tp$$7) {
return fixTypeEx("", doFix$$1, fix$$3, tp$$7);
}, list$$15);
Modules$$1 = choose(FsTypeModule$$$asModule, list$$16);
return new FsFile(f$$3.Kind, f$$3.FileName, f$$3.ModuleName, Modules$$1);
}
function fixFile(fix$$4, f$$4) {
return fixFileEx(function (_arg1$$1) {
return true;
}, fix$$4, f$$4);
}
function mergeTypes(tps$$1) {
const index = new Map([]);
const list$$17 = [];
iterate(function (b$$1) {
if (b$$1.tag === 0) {
if (index.has(b$$1.fields[0].Name)) {
const i = getItemFromDict(index, b$$1.fields[0].Name) | 0;
const a$$2 = list$$17[i];
if (a$$2.tag === 0) {
let arg0$$17;
let Inherits$$1;
const list$$18 = append$1(a$$2.fields[0].Inherits, b$$1.fields[0].Inherits);
Inherits$$1 = distinct(list$$18, {
Equals: equals,
GetHashCode: structuralHash
});
const Members$$1 = append$1(a$$2.fields[0].Members, b$$1.fields[0].Members);
arg0$$17 = new FsInterface(a$$2.fields[0].Comments, a$$2.fields[0].IsStatic, a$$2.fields[0].IsClass, a$$2.fields[0].Name, a$$2.fields[0].FullName, a$$2.fields[0].TypeParameters, Inherits$$1, Members$$1, a$$2.fields[0].Accessibility);
list$$17[i] = new FsType(0, "Interface", arg0$$17);
}
} else {
list$$17.push(b$$1);
addToDict(index, b$$1.fields[0].Name, list$$17.length - 1);
}
} else {
list$$17.push(b$$1);
}
}, tps$$1);
return ofSeq$1(list$$17);
}
function mergeModules(tps$$2) {
const index$$1 = new Map([]);
const list$$19 = [];
iterate(function (tp$$9) {
var tp$$10;
if (tp$$9.tag === 13) {
let md2;
let Types$$2;
let tps$$4;
tps$$4 = mergeTypes(tp$$9.fields[0].Types);
Types$$2 = mergeModules(tps$$4);
md2 = new FsModule(tp$$9.fields[0].HasDeclare, tp$$9.fields[0].IsNamespace, tp$$9.fields[0].Name, Types$$2, tp$$9.fields[0].HelperLines, tp$$9.fields[0].Attributes);
if (index$$1.has(tp$$9.fields[0].Name)) {
const i$$1 = getItemFromDict(index$$1, tp$$9.fields[0].Name) | 0;
const a$$3 = (tp$$10 = list$$19[i$$1], (FsTypeModule$$$asModule(tp$$10)));
let arg0$$18;
let Types$$3;
let tps$$6;
const tps$$5 = append$1(a$$3.Types, md2.Types);
tps$$6 = mergeTypes(tps$$5);
Types$$3 = mergeModules(tps$$6);
arg0$$18 = new FsModule(a$$3.HasDeclare, a$$3.IsNamespace, a$$3.Name, Types$$3, a$$3.HelperLines, a$$3.Attributes);
list$$19[i$$1] = new FsType(13, "Module", arg0$$18);
} else {
let value$$1;
let arg00$$1;
arg00$$1 = new FsType(13, "Module", md2);
value$$1 = list$$19.push(arg00$$1);
addToDict(index$$1, md2.Name, list$$19.length - 1);
}
} else {
const value$$2 = list$$19.push(tp$$9);
}
}, tps$$2);
return ofSeq$1(list$$19);
}
function mergeModulesInFile(f$$5) {
let Modules$$2;
let list$$21;
let tps$$7;
let list$$20;
list$$20 = ofSeq$1(f$$5.Modules);
tps$$7 = map$2(function mapping$$3(arg0$$20) {
return new FsType(13, "Module", arg0$$20);
}, list$$20);
list$$21 = mergeModules(tps$$7);
Modules$$2 = choose(FsTypeModule$$$asModule, list$$21);
return new FsFile(f$$5.Kind, f$$5.FileName, f$$5.ModuleName, Modules$$2);
}
const engines = (() => {
const elements = ofArray(["node", "vscode"]);
return ofList$1(elements, {
Compare: comparePrimitives
});
})();
function createIExportsModule(ns$$5, md$$2) {
var arg0$$26, name$$3, arg10$$1, clo1$$1, arg0$$27, name$$4, arg10$$2, clo1$$2, arg0$$28, Comments, Inherits$$2, list$$26;
const clo1 = toConsole(printf("createIExportsModule %A, %s"));
const clo2 = clo1(ns$$5);
clo2(md$$2.Name);
const typesInIExports = [];
const typesGlobal = [];
const typesChild = [];
const typesChildExport = [];
const typesOther = [];
const variablesForParent = [];
const variables = createMutable$1([], {
Equals: equals,
GetHashCode: structuralHash
});
const exportAssignments = new Set([]);
iterate$1(function action(tp$$12) {
if (tp$$12.tag === 18) {
const value$$3 = addToSet(tp$$12.fields[0], exportAssignments);
}
}, md$$2.Types);
iterate$1(function action$$1(tp$$13) {
var arg0$$23;
switch (tp$$13.tag) {
case 13:
{
let ns$$6;
if (md$$2.Name === "") {
ns$$6 = ns$$5;
} else {
let parts$$1;
const name = replace(md$$2.Name, "'", "");
const activePatternResult1451 = ModuleName$$$$007CNormal$007CParts$007C(name);
if (activePatternResult1451.tag === 1) {
parts$$1 = filter$1(function predicate(y) {
return "." !== y;
}, activePatternResult1451.fields[0]);
} else {
parts$$1 = new List(name, new List());
}
ns$$6 = append$1(ns$$5, parts$$1);
}
const patternInput = createIExportsModule(ns$$6, tp$$13.fields[0]);
iterate(function (v) {
if (v.Export != null) {
let value$$4;
value$$4 = addToSet(v, variables);
} else {
let arg00$$3;
arg00$$3 = new FsType(16, "Variable", v);
typesChild.push(arg00$$3);
}
}, patternInput[1]);
let arg00$$4;
arg00$$4 = new FsType(13, "Module", patternInput[0]);
typesOther.push(arg00$$4);
break;
}
case 16:
{
if (tp$$13.fields[0].HasDeclare) {
if (md$$2.Name === "") {
let arg00$$5;
const arg0$$24 = new FsVariable((arg0$$23 = new FsExport(FSharpSet$$Contains$$2B595(engines, item(0, ns$$5)), compare$4(tp$$13.fields[0].Name, item(0, ns$$5), true) === 0 ? "*" : tp$$13.fields[0].Name, item(0, ns$$5)), (arg0$$23)), tp$$13.fields[0].HasDeclare, tp$$13.fields[0].Name, tp$$13.fields[0].Type, tp$$13.fields[0].IsConst, tp$$13.fields[0].IsStatic, tp$$13.fields[0].Accessibility);
arg00$$5 = new FsType(16, "Variable", arg0$$24);
typesGlobal.push(arg00$$5);
} else if (FsVariable$$get_IsGlobal(tp$$13.fields[0])) {
typesGlobal.push(tp$$13);
} else {
typesInIExports.push(tp$$13);
}
} else {
typesInIExports.push(tp$$13);
}
break;
}
case 8:
{
typesInIExports.push(tp$$13);
break;
}
case 0:
{
if (tp$$13.fields[0].IsStatic) {
let arg00$$6;
const arg0$$25 = new FsProperty(new List(), new FsPropertyKind(0, "Regular"), null, replace(tp$$13.fields[0].Name, "Static", ""), false, (simpleType(tp$$13.fields[0].Name)), true, false, null);
arg00$$6 = new FsType(2, "Property", arg0$$25);
typesInIExports.push(arg00$$6);
}
typesOther.push(tp$$13);
break;
}
default:
{
typesOther.push(tp$$13);
}
}
}, md$$2.Types);
const ns$$7 = FSharpSet$$Contains$$2B595(engines, item(0, ns$$5)) ? slice(1, null, ns$$5) : ns$$5;
const selector = length(ns$$7) === 0 ? "*" : replace(md$$2.Name, "'", "");
let path;
if (length(ns$$7) === 0) {
path = replace(md$$2.Name, "'", "");
} else {
path = join("/", ns$$7);
}
if (typesInIExports.length > 0) {
let name$$2;
if (forAll(isUpper, md$$2.Name.split(""))) {
name$$2 = md$$2.Name.toLocaleLowerCase();
} else {
name$$2 = lowerFirst(md$$2.Name);
}
if (md$$2.HasDeclare) {
if (!md$$2.IsNamespace) {
const arg00$$8 = new FsVariable((arg0$$26 = new FsExport(false, "*", path), (arg0$$26)), true, name$$2, (name$$3 = (arg10$$1 = fixModuleName(md$$2.Name), (clo1$$1 = toText(printf("%s.IExports")), clo1$$1(arg10$$1))), (simpleType(name$$3))), true, false, null);
variablesForParent.push(arg00$$8);
}
} else {
const arg00$$9 = new FsVariable((arg0$$27 = new FsExport(false, selector, path), (arg0$$27)), true, name$$2, (name$$4 = (arg10$$2 = fixModuleName(md$$2.Name), (clo1$$2 = toText(printf("%s.IExports")), clo1$$2(arg10$$2))), (simpleType(name$$4))), true, false, null);
variablesForParent.push(arg00$$9);
}
}
const iexports = typesInIExports.length === 0 ? new List() : new List((arg0$$28 = (Comments = new List(), (Inherits$$2 = new List(), new FsInterface(Comments, false, false, "IExports", "IExports", new List(), Inherits$$2, (ofSeq$1(typesInIExports)), null))), (new FsType(0, "Interface", arg0$$28))), new List());
let globalNames;
let elements$$1;
elements$$1 = map$1(getName, typesGlobal);
globalNames = ofSeq(elements$$1, {
Compare: comparePrimitives
});
iterate$1(function action$$2(tp$$15) {
var value$$6, arg0$$29, name$$5, arg10$$3, clo1$$3;
if (tp$$15.tag === 13) {
if ((value$$6 = FSharpSet$$Contains$$2B595(globalNames, tp$$15.fields[0].Name), (!value$$6)) ? exportAssignments.has(tp$$15.fields[0].Name) : false) {
let value$$7;
const arg00$$10 = new FsVariable((arg0$$29 = new FsExport(false, "*", path), (arg0$$29)), true, (lowerFirst(tp$$15.fields[0].Name)), (name$$5 = (arg10$$3 = fixModuleName(tp$$15.fields[0].Name), (clo1$$3 = toText(printf("%s.IExports")), clo1$$3(arg10$$3))), (simpleType(name$$5))), true, false, null);
value$$7 = addToSet(arg00$$10, variables);
}
}
}, md$$2.Types);
let newMd;
const Types$$4 = append$1((list$$26 = (ofSeq$1(variables)), (map$2(function mapping$$4(arg0$$30) {
return new FsType(16, "Variable", arg0$$30);
}, list$$26))), append$1((ofSeq$1(typesGlobal)), append$1((ofSeq$1(typesChildExport)), append$1((ofSeq$1(typesChild)), append$1(iexports, (ofSeq$1(typesOther)))))));
newMd = new FsModule(md$$2.HasDeclare, md$$2.IsNamespace, md$$2.Name, Types$$4, md$$2.HelperLines, md$$2.Attributes);
return [newMd, (ofSeq$1(variablesForParent))];
}
function createIExports(f$$6) {
let Modules$$3;
let list$$27;
list$$27 = ofSeq$1(f$$6.Modules);
Modules$$3 = map$2(function mapping$$5(md$$3) {
const patternInput$$1 = createIExportsModule(new List(f$$6.ModuleName, new List()), md$$3);
return patternInput$$1[0];
}, list$$27);
return new FsFile(f$$6.Kind, f$$6.FileName, f$$6.ModuleName, Modules$$3);
}
function fixTic(ns$$8, typeParameters, tp$$16) {
if (length(typeParameters) === 0) {
return tp$$16;
} else {
let set;
set = ofList$1(typeParameters, {
Compare($x$$9, $y$$10) {
return $x$$9.CompareTo($y$$10);
}
});
return fixType(ns$$8, function fix$$5(ns$$9, t$$1) {
var clo1$$4;
if (t$$1.tag === 7) {
if (FSharpSet$$Contains$$2B595(set, t$$1)) {
const arg0$$31 = new FsMapped((clo1$$4 = toText(printf("'%s")), clo1$$4(t$$1.fields[0].Name)), t$$1.fields[0].FullName);
return new FsType(7, "Mapped", arg0$$31);
} else {
return t$$1;
}
} else {
return t$$1;
}
}, tp$$16);
}
}
function addTicForGenericFunctions(f$$7) {
return fixFile(function fix$$6(ns$$10, tp$$17) {
if (tp$$17.tag === 8) {
return fixTic(ns$$10, tp$$17.fields[0].TypeParameters, tp$$17);
} else {
return tp$$17;
}
}, f$$7);
}
function fixOverloadingOnStringParameters(f$$9) {
return fixFile(function fix$$7(ns$$11, tp$$18) {
if (tp$$18.tag === 8) {
if (FsFunction$$get_HasStringLiteralParams(tp$$18.fields[0])) {
const kind = [];
const name$$6 = [];
const prms = [];
let arg00$$11;
const arg10$$5 = tp$$18.fields[0].Name;
const clo1$$5 = toText(printf("$0.%s("));
arg00$$11 = clo1$$5(arg10$$5);
kind.push(arg00$$11);
let arg00$$12;
const arg10$$6 = tp$$18.fields[0].Name;
const clo1$$6 = toText(printf("%s"));
arg00$$12 = clo1$$6(arg10$$6);
name$$6.push(arg00$$12);
const slCount = new FSharpRef(0);
iterateIndexed$1(function action$$3(i$$2, prm) {
const matchValue$$1 = FsTypeModule$$$asStringLiteral(prm.Type);
if (matchValue$$1 != null) {
const sl = matchValue$$1;
void slCount.contents++;
let arg00$$14;
const clo1$$8 = toText(printf("'%s'"));
arg00$$14 = clo1$$8(sl);
kind.push(arg00$$14);
let arg00$$15;
const clo1$$9 = toText(printf("_%s"));
arg00$$15 = clo1$$9(sl);
name$$6.push(arg00$$15);
} else {
let arg00$$13;
const arg10$$7 = i$$2 + 1 - slCount.contents | 0;
const clo1$$7 = toText(printf("$%d"));
arg00$$13 = clo1$$7(arg10$$7);
kind.push(arg00$$13);
prms.push(prm);
}
if (i$$2 < length(tp$$18.fields[0].Params) - 1) {
kind.push(",");
}
}, tp$$18.fields[0].Params);
kind.push(")");
let arg0$$34;
let Kind;
const arg0$$32 = join("", kind);
Kind = new FsFunctionKind(3, "StringParam", arg0$$32);
let Name$$1;
const arg0$$33 = join("", name$$6);
Name$$1 = arg0$$33;
const Params$$1 = ofSeq$1(prms);
arg0$$34 = new FsFunction(tp$$18.fields[0].Comments, Kind, tp$$18.fields[0].IsStatic, Name$$1, tp$$18.fields[0].TypeParameters, Params$$1, tp$$18.fields[0].ReturnType, tp$$18.fields[0].Accessibility);
return new FsType(8, "Function", arg0$$34);
} else {
return tp$$18;
}
} else {
return tp$$18;
}
}, f$$9);
}
function fixNodeArray(f$$11) {
return fixFile(function fix$$8(ns$$12, tp$$19) {
if (tp$$19.tag === 11) {
if (tp$$19.fields[0].Type.tag === 7) {
if (tp$$19.fields[0].Type.fields[0].Name === "NodeArray" ? length(tp$$19.fields[0].TypeParameters) === 1 : false) {
const arg0$$35 = item(0, tp$$19.fields[0].TypeParameters);
return new FsType(4, "Array", arg0$$35);
} else {
return tp$$19;
}
} else {
return tp$$19;
}
} else {
return tp$$19;
}
}, f$$11);
}
function fixReadonlyArray(f$$13) {
return fixFile(function fix$$10(ns$$14, tp$$21) {
if (tp$$21.tag === 8) {
return fixType(ns$$14, function fix$$9(ns$$13, tp$$20) {
if (tp$$20.tag === 11) {
if (tp$$20.fields[0].Type.tag === 7) {
if (tp$$20.fields[0].Type.fields[0].Name === "ReadonlyArray" ? length(tp$$20.fields[0].TypeParameters) === 1 : false) {
const arg0$$36 = item(0, tp$$20.fields[0].TypeParameters);
return new FsType(4, "Array", arg0$$36);
} else {
return tp$$20;
}
} else {
return tp$$20;
}
} else {
return tp$$20;
}
}, tp$$21);
} else {
return tp$$21;
}
}, f$$13);
}
function fixEscapeWords(f$$15) {
return fixFile(function fix$$11(ns$$15, tp$$22) {
switch (tp$$22.tag) {
case 7:
{
const arg0$$37 = new FsMapped(escapeWord(tp$$22.fields[0].Name), tp$$22.fields[0].FullName);
return new FsType(7, "Mapped", arg0$$37);
}
case 3:
{
let arg0$$38;
const Name$$2 = escapeWord(tp$$22.fields[0].Name);
arg0$$38 = new FsParam(tp$$22.fields[0].Comment, Name$$2, tp$$22.fields[0].Optional, tp$$22.fields[0].ParamArray, tp$$22.fields[0].Type);
return new FsType(3, "Param", arg0$$38);
}
case 8:
{
let arg0$$39;
let Name$$3;
Name$$3 = map(escapeWord, tp$$22.fields[0].Name);
arg0$$39 = new FsFunction(tp$$22.fields[0].Comments, tp$$22.fields[0].Kind, tp$$22.fields[0].IsStatic, Name$$3, tp$$22.fields[0].TypeParameters, tp$$22.fields[0].Params, tp$$22.fields[0].ReturnType, tp$$22.fields[0].Accessibility);
return new FsType(8, "Function", arg0$$39);
}
case 2:
{
let arg0$$40;
const Name$$4 = escapeProperty(tp$$22.fields[0].Name);
arg0$$40 = new FsProperty(tp$$22.fields[0].Comments, tp$$22.fields[0].Kind, tp$$22.fields[0].Index, Name$$4, tp$$22.fields[0].Option, tp$$22.fields[0].Type, tp$$22.fields[0].IsReadonly, tp$$22.fields[0].IsStatic, tp$$22.fields[0].Accessibility);
return new FsType(2, "Property", arg0$$40);
}
case 0:
{
let arg0$$41;
const Name$$5 = escapeWord(tp$$22.fields[0].Name);
arg0$$41 = new FsInterface(tp$$22.fields[0].Comments, tp$$22.fields[0].IsStatic, tp$$22.fields[0].IsClass, Name$$5, tp$$22.fields[0].FullName, tp$$22.fields[0].TypeParameters, tp$$22.fields[0].Inherits, tp$$22.fields[0].Members, tp$$22.fields[0].Accessibility);
return new FsType(0, "Interface", arg0$$41);
}
case 13:
{
let arg0$$42;
const Name$$6 = fixModuleName(tp$$22.fields[0].Name);
arg0$$42 = new FsModule(tp$$22.fields[0].HasDeclare, tp$$22.fields[0].IsNamespace, Name$$6, tp$$22.fields[0].Types, tp$$22.fields[0].HelperLines, tp$$22.fields[0].Attributes);
return new FsType(13, "Module", arg0$$42);
}
case 16:
{
let arg0$$43;
const Name$$7 = escapeWord(tp$$22.fields[0].Name);
arg0$$43 = new FsVariable(tp$$22.fields[0].Export, tp$$22.fields[0].HasDeclare, Name$$7, tp$$22.fields[0].Type, tp$$22.fields[0].IsConst, tp$$22.fields[0].IsStatic, tp$$22.fields[0].Accessibility);
return new FsType(16, "Variable", arg0$$43);
}
case 10:
{
const arg0$$44 = new FsAlias(escapeWord(tp$$22.fields[0].Name), tp$$22.fields[0].Type, tp$$22.fields[0].TypeParameters);
return new FsType(10, "Alias", arg0$$44);
}
default:
{
return tp$$22;
}
}
}, f$$15);
}
function fixDateTime(f$$17) {
return fixFile(function fix$$12(ns$$16, tp$$23) {
if (tp$$23.tag === 7) {
const arg0$$45 = new FsMapped(("Date" === tp$$23.fields[0].Name ? "DateTime" : tp$$23.fields[0].Name), tp$$23.fields[0].FullName);
return new FsType(7, "Mapped", arg0$$45);
} else {
return tp$$23;
}
}, f$$17);
}
function fixEnumReferences(f$$19) {
const list$$29 = [];
let value$$9;
value$$9 = fixFile(function fix$$13(ns$$17, tp$$24) {
if (tp$$24.tag === 1) {
const value$$8 = list$$29.push(tp$$24.fields[0].Name);
return tp$$24;
} else {
return tp$$24;
}
}, f$$19);
const set$$1 = ofSeq(list$$29, {
Compare: comparePrimitives
});
return fixFile(function fix$$14(ns$$18, tp$$25) {
if (tp$$25.tag === 7) {
if (tp$$25.fields[0].Name.indexOf(".") >= 0) {
const nm = substring(tp$$25.fields[0].Name, 0, tp$$25.fields[0].Name.indexOf("."));
if (FSharpSet$$Contains$$2B595(set$$1, nm)) {
return simpleType(nm);
} else {
return tp$$25;
}
} else {
return tp$$25;
}
} else {
return tp$$25;
}
}, f$$19);
}
function fixDuplicatesInUnion(f$$22) {
return fixFile(function fix$$15(ns$$19, tp$$26) {
if (tp$$26.tag === 9) {
const set$$2 = createMutable$1([], {
Equals: equals,
GetHashCode: structuralHash
});
let tps$$8;
tps$$8 = choose(function chooser(tp$$27) {
if (set$$2.has(tp$$27)) {
return null;
} else {
const value$$10 = addToSet(tp$$27, set$$2);
return tp$$27;
}
}, tp$$26.fields[0].Types);
if (length(tps$$8) > 8) {
return simpleType("obj");
} else {
const arg0$$46 = new FsUnion(tp$$26.fields[0].Option, tps$$8);
return new FsType(9, "Union", arg0$$46);
}
} else {
return tp$$26;
}
}, f$$22);
}
function addTicForGenericTypes(f$$24) {
return fixFile(function fix$$16(ns$$20, tp$$28) {
switch (tp$$28.tag) {
case 0:
{
return fixTic(ns$$20, tp$$28.fields[0].TypeParameters, tp$$28);
}
case 10:
{
return fixTic(ns$$20, tp$$28.fields[0].TypeParameters, tp$$28);
}
default:
{
return tp$$28;
}
}
}, f$$24);
}
function fixThis(f$$26) {
return fixFile(function fix$$18(ns$$21, tp$$29) {
if (tp$$29.tag === 0) {
let arg0$$48;
let Members$$2;
Members$$2 = map$2(function mapping$$6(tp$$31) {
return fixType(ns$$21, function replaceThis(ns$$22, tp$$30) {
if (tp$$30.tag === 19) {
const arg0$$47 = new FsGenericType(simpleType(tp$$29.fields[0].Name), tp$$29.fields[0].TypeParameters);
return new FsType(11, "Generic", arg0$$47);
} else {
return tp$$30;
}
}, tp$$31);
}, tp$$29.fields[0].Members);
arg0$$48 = new FsInterface(tp$$29.fields[0].Comments, tp$$29.fields[0].IsStatic, tp$$29.fields[0].IsClass, tp$$29.fields[0].Name, tp$$29.fields[0].FullName, tp$$29.fields[0].TypeParameters, tp$$29.fields[0].Inherits, Members$$2, tp$$29.fields[0].Accessibility);
return new FsType(0, "Interface", arg0$$48);
} else {
return tp$$29;
}
}, f$$26);
}
function fixStatic(f$$28) {
return fixFile(function fix$$19(ns$$23, tp$$32) {
if (tp$$32.tag === 13) {
let arg0$$51;
let Types$$5;
Types$$5 = collect$1(function mapping$$7(tp2) {
var arg0$$49, Members$$3, arg0$$50, Name$$8, clo1$$10, Inherits$$3, Members$$4;
if (tp2.tag === 0) {
if (FsInterface$$get_HasStaticMembers(tp2.fields[0])) {
return ofArray([(arg0$$49 = (Members$$3 = FsInterface$$get_NonStaticMembers(tp2.fields[0]), new FsInterface(tp2.fields[0].Comments, tp2.fields[0].IsStatic, tp2.fields[0].IsClass, tp2.fields[0].Name, tp2.fields[0].FullName, tp2.fields[0].TypeParameters, tp2.fields[0].Inherits, Members$$3, tp2.fields[0].Accessibility)), (new FsType(0, "Interface", arg0$$49))), (arg0$$50 = (Name$$8 = (clo1$$10 = toText(printf("%sStatic")), clo1$$10(tp2.fields[0].Name)), (Inherits$$3 = new List(), (Members$$4 = FsInterface$$get_StaticMembers(tp2.fields[0]), new FsInterface(tp2.fields[0].Comments, true, tp2.fields[0].IsClass, Name$$8, tp2.fields[0].FullName, tp2.fields[0].TypeParameters, Inherits$$3, Members$$4, tp2.fields[0].Accessibility)))), (new FsType(0, "Interface", arg0$$50)))]);
} else {
return new List(tp2, new List());
}
} else {
return new List(tp2, new List());
}
}, tp$$32.fields[0].Types);
arg0$$51 = new FsModule(tp$$32.fields[0].HasDeclare, tp$$32.fields[0].IsNamespace, tp$$32.fields[0].Name, Types$$5, tp$$32.fields[0].HelperLines, tp$$32.fields[0].Attributes);
return new FsType(13, "Module", arg0$$51);
} else {
return tp$$32;
}
}, f$$28);
}
function removeTypeParamsFromStatic(f$$32) {
return fixFile(function fix$$22(ns$$27, tp$$36) {
if (tp$$36.tag === 0) {
let arg0$$53;
const TypeParameters$$3 = tp$$36.fields[0].IsStatic ? new List() : tp$$36.fields[0].TypeParameters;
arg0$$53 = new FsInterface(tp$$36.fields[0].Comments, tp$$36.fields[0].IsStatic, tp$$36.fields[0].IsClass, tp$$36.fields[0].Name, tp$$36.fields[0].FullName, TypeParameters$$3, tp$$36.fields[0].Inherits, tp$$36.fields[0].Members, tp$$36.fields[0].Accessibility);
return new FsType(0, "Interface", arg0$$53);
} else {
return tp$$36;
}
}, f$$32);
}
function addConstructors(f$$34) {
const list$$34 = [];
let value$$13;
value$$13 = fixFile(function fix$$23(ns$$28, tp$$37) {
if (tp$$37.tag === 0) {
if (tp$$37.fields[0].IsClass ? FsInterface$$get_HasConstructor(tp$$37.fields[0]) : false) {
const value$$12 = list$$34.push(tp$$37.fields[0]);
return tp$$37;
} else {
return tp$$37;
}
} else {
return tp$$37;
}
}, f$$34);
let map;
let keyValuePairs;
keyValuePairs = map$1(function mapping$$8(it$$9) {
return [it$$9.FullName, it$$9];
}, list$$34);
map = new Map(keyValuePairs);
return fixFile(function fix$$24(ns$$29, tp$$38) {
if (tp$$38.tag === 0) {
if (tp$$38.fields[0].IsClass) {
if (FsInterface$$get_HasConstructor(tp$$38.fields[0])) {
return tp$$38;
} else {
let parent;
parent = tryPick(function chooser$$1(inh) {
const fn$$4 = getFullName(inh);
if (map.has(fn$$4)) {
return getItemFromDict(map, fn$$4);
} else {
return null;
}
}, tp$$38.fields[0].Inherits);
if (parent == null) {
let defaultCtr;
const arg0$$55 = new FsFunction(new List(), new FsFunctionKind(1, "Constructor"), true, "Create", tp$$38.fields[0].TypeParameters, new List(), new FsType(19, "This"), null);
defaultCtr = new FsType(8, "Function", arg0$$55);
let arg0$$56;
const Members$$7 = append$1(new List(defaultCtr, new List()), tp$$38.fields[0].Members);
arg0$$56 = new FsInterface(tp$$38.fields[0].Comments, tp$$38.fields[0].IsStatic, tp$$38.fields[0].IsClass, tp$$38.fields[0].Name, tp$$38.fields[0].FullName, tp$$38.fields[0].TypeParameters, tp$$38.fields[0].Inherits, Members$$7, tp$$38.fields[0].Accessibility);
return new FsType(0, "Interface", arg0$$56);
} else {
const pt = parent;
let arg0$$54;
const Members$$6 = append$1(FsInterface$$get_Constructors(pt), tp$$38.fields[0].Members);
arg0$$54 = new FsInterface(tp$$38.fields[0].Comments, tp$$38.fields[0].IsStatic, tp$$38.fields[0].IsClass, tp$$38.fields[0].Name, tp$$38.fields[0].FullName, tp$$38.fields[0].TypeParameters, tp$$38.fields[0].Inherits, Members$$6, tp$$38.fields[0].Accessibility);
return new FsType(0, "Interface", arg0$$54);
}
}
} else {
return tp$$38;
}
} else {
return tp$$38;
}
}, f$$34);
}
function removeInternalModules(f$$37) {
return fixFile(function fix$$25(ns$$30, tp$$39) {
if (tp$$39.tag === 13) {
let arg0$$57;
let Types$$6;
Types$$6 = collect$1(function mapping$$9(tp$$40) {
var $target$$137, smd$$4;
if (tp$$40.tag === 13) {
if (tp$$40.fields[0].Name === "internal") {
$target$$137 = 0;
smd$$4 = tp$$40.fields[0];
} else {
$target$$137 = 1;
}
} else {
$target$$137 = 1;
}
switch ($target$$137) {
case 0:
{
return smd$$4.Types;
}
case 1:
{
return new List(tp$$40, new List());
}
}
}, tp$$39.fields[0].Types);
arg0$$57 = new FsModule(tp$$39.fields[0].HasDeclare, tp$$39.fields[0].IsNamespace, tp$$39.fields[0].Name, Types$$6, tp$$39.fields[0].HelperLines, tp$$39.fields[0].Attributes);
return new FsType(13, "Module", arg0$$57);
} else {
return tp$$39;
}
}, f$$37);
}
function removePrivatesFromClasses(f$$39) {
return fixFile(function fix$$26(ns$$31, tp$$41) {
var $target$$141, c$$2;
if (tp$$41.tag === 0) {
if (tp$$41.fields[0].IsClass) {
$target$$141 = 0;
c$$2 = tp$$41.fields[0];
} else {
$target$$141 = 1;
}
} else {
$target$$141 = 1;
}
switch ($target$$141) {
case 0:
{
let arg0$$58;
let Members$$8;
Members$$8 = filter$1(function predicate$$3(m) {
return !equals(getAccessibility(m), new FsAccessibility(2, "Private"));
}, c$$2.Members);
arg0$$58 = new FsInterface(c$$2.Comments, c$$2.IsStatic, c$$2.IsClass, c$$2.Name, c$$2.FullName, c$$2.TypeParameters, c$$2.Inherits, Members$$8, c$$2.Accessibility);
return new FsType(0, "Interface", arg0$$58);
}
case 1:
{
return tp$$41;
}
}
}, f$$39);
}
function removeDuplicateFunctions(f$$41) {
return fixFile(function fix$$27(ns$$32, tp$$42) {
if (tp$$42.tag === 0) {
const set$$3 = createMutable$1([], {
Equals: equals,
GetHashCode: structuralHash
});
let arg0$$59;
let Members$$9;
Members$$9 = collect$1(function mapping$$10(mb$$1) {
if (mb$$1.tag === 8) {
let fn2;
const Comments$$1 = new List();
const ReturnType$$1 = new FsType(6, "None");
fn2 = new FsFunction(Comments$$1, mb$$1.fields[0].Kind, mb$$1.fields[0].IsStatic, mb$$1.fields[0].Name, mb$$1.fields[0].TypeParameters, mb$$1.fields[0].Params, ReturnType$$1, mb$$1.fields[0].Accessibility);
if (addToSet(fn2, set$$3)) {
return new List(mb$$1, new List());
} else {
return new List();
}
} else {
return new List(mb$$1, new List());
}
}, tp$$42.fields[0].Members);
arg0$$59 = new FsInterface(tp$$42.fields[0].Comments, tp$$42.fields[0].IsStatic, tp$$42.fields[0].IsClass, tp$$42.fields[0].Name, tp$$42.fields[0].FullName, tp$$42.fields[0].TypeParameters, tp$$42.fields[0].Inherits, Members$$9, tp$$42.fields[0].Accessibility);
return new FsType(0, "Interface", arg0$$59);
} else {
return tp$$42;
}
}, f$$41);
}
function removeDuplicateOptions(f$$43) {
return fixFile(function fix$$28(ns$$33, tp$$43) {
var $target$$150, pr$$4;
if (tp$$43.tag === 2) {
if (tp$$43.fields[0].Option) {
$target$$150 = 0;
pr$$4 = tp$$43.fields[0];
} else {
$target$$150 = 1;
}
} else {
$target$$150 = 1;
}
switch ($target$$150) {
case 0:
{
var $target$$151, un$$3;
if (pr$$4.Type.tag === 9) {
if (pr$$4.Type.fields[0].Option) {
$target$$151 = 0;
un$$3 = pr$$4.Type.fields[0];
} else {
$target$$151 = 1;
}
} else {
$target$$151 = 1;
}
switch ($target$$151) {
case 0:
{
let arg0$$61;
let Type$$5;
const arg0$$60 = new FsUnion(false, un$$3.Types);
Type$$5 = new FsType(9, "Union", arg0$$60);
arg0$$61 = new FsProperty(pr$$4.Comments, pr$$4.Kind, pr$$4.Index, pr$$4.Name, pr$$4.Option, Type$$5, pr$$4.IsReadonly, pr$$4.IsStatic, pr$$4.Accessibility);
return new FsType(2, "Property", arg0$$61);
}
case 1:
{
return tp$$43;
}
}
}
case 1:
{
return tp$$43;
}
}
}, f$$43);
}
function removeDuplicateOptionsFromParameters(f$$45) {
const allTypes = new Lazy(function () {
const list$$39 = getAllTypesFromFile(f$$45);
return ofList$2(list$$39, Array);
});
return fixFile(function fix$$29(ns$$34, tp$$44) {
var typFromName, source$$15, t2, t$$4, t$$5, t2$$1;
var $target$$155, pr$$6;
if (tp$$44.tag === 3) {
if (tp$$44.fields[0].Optional) {
$target$$155 = 0;
pr$$6 = tp$$44.fields[0];
} else {
$target$$155 = 1;
}
} else {
$target$$155 = 1;
}
switch ($target$$155) {
case 0:
{
var $target$$156, t$$6, un$$7;
if (pr$$6.Type.tag === 9) {
if (pr$$6.Type.fields[0].Option) {
if (pr$$6.Type.fields[0].Types.tail != null) {
if (pr$$6.Type.fields[0].Types.tail.tail == null) {
$target$$156 = 0;
t$$6 = pr$$6.Type.fields[0].Types.head;
} else if (pr$$6.Type.fields[0].Option) {
$target$$156 = 1;
un$$7 = pr$$6.Type.fields[0];
} else {
$target$$156 = 2;
}
} else if (pr$$6.Type.fields[0].Option) {
$target$$156 = 1;
un$$7 = pr$$6.Type.fields[0];
} else {
$target$$156 = 2;
}
} else if (pr$$6.Type.fields[0].Option) {
$target$$156 = 1;
un$$7 = pr$$6.Type.fields[0];
} else {
$target$$156 = 2;
}
} else {
$target$$156 = 2;
}
switch ($target$$156) {
case 0:
{
const arg0$$62 = new FsParam(pr$$6.Comment, pr$$6.Name, pr$$6.Optional, pr$$6.ParamArray, t$$6);
return new FsType(3, "Param", arg0$$62);
}
case 1:
{
let arg0$$64;
let Type$$6;
const arg0$$63 = new FsUnion(false, un$$7.Types);
Type$$6 = new FsType(9, "Union", arg0$$63);
arg0$$64 = new FsParam(pr$$6.Comment, pr$$6.Name, pr$$6.Optional, pr$$6.ParamArray, Type$$6);
return new FsType(3, "Param", arg0$$64);
}
case 2:
{
var $target$$157, name$$10, t$$8;
if (pr$$6.Type.tag === 11) {
if (pr$$6.Type.fields[0].Type.tag === 7) {
if (pr$$6.Type.fields[0].Type.fields[0].FullName === "") {
if (pr$$6.Type.fields[0].TypeParameters.tail != null) {
if (pr$$6.Type.fields[0].TypeParameters.tail.tail == null) {
if (typFromName = (source$$15 = allTypes.Value, (tryFind(function predicate$$4(t$$3) {
var $target$$159;
if (t$$3.tag === 10) {
if (t$$3.fields[0].Name === pr$$6.Type.fields[0].Type.fields[0].Name) {
$target$$159 = 0;
} else {
$target$$159 = 1;
}
} else {
$target$$159 = 1;
}
switch ($target$$159) {
case 0:
{
return true;
}
case 1:
{
return false;
}
}
}, source$$15))), typFromName != null ? typFromName.tag === 10 ? typFromName.fields[0].Type.tag === 9 ? typFromName.fields[0].Type.fields[0].Option ? typFromName.fields[0].Type.fields[0].Types.tail != null ? typFromName.fields[0].Type.fields[0].Types.tail.tail == null ? typFromName.fields[0].TypeParameters.tail != null ? typFromName.fields[0].TypeParameters.tail.tail == null ? (t2 = typFromName.fields[0].TypeParameters.head, (t$$4 = typFromName.fields[0].Type.fields[0].Types.head, equals(t$$4, t2))) ? (t$$5 = typFromName.fields[0].Type.fields[0].Types.head, t2$$1 = typFromName.fields[0].TypeParameters.head, true) : false : false : false : false : false : false : false : false : false) {
$target$$157 = 0;
name$$10 = pr$$6.Type.fields[0].Type.fields[0].Name;
t$$8 = pr$$6.Type.fields[0].TypeParameters.head;
} else {
$target$$157 = 1;
}
} else {
$target$$157 = 1;
}
} else {
$target$$157 = 1;
}
} else {
$target$$157 = 1;
}
} else {
$target$$157 = 1;
}
} else {
$target$$157 = 1;
}
switch ($target$$157) {
case 0:
{
const arg0$$65 = new FsParam(pr$$6.Comment, pr$$6.Name, pr$$6.Optional, pr$$6.ParamArray, t$$8);
return new FsType(3, "Param", arg0$$65);
}
case 1:
{
return tp$$44;
}
}
}
}
}
case 1:
{
return tp$$44;
}
}
}, f$$45);
}
function extractTypeLiterals(f$$47) {
let f$$50;
f$$50 = fixFile(function fix$$30(ns$$35, tp$$45) {
if (tp$$45.tag === 13) {
let typeNames;
let arg00$$18;
arg00$$18 = map$2(getName, tp$$45.fields[0].Types);
typeNames = new Set(arg00$$18);
const newTypeName = function newTypeName($name$$11$$163) {
newTypeName: while (true) {
const name$$11 = $name$$11$$163;
const name$$12 = capitalize(name$$11);
if (typeNames.has(name$$12)) {
let name$$13;
const clo1$$12 = toText(printf("%s_"));
name$$13 = clo1$$12(name$$12);
if (typeNames.has(name$$13)) {
$name$$11$$163 = name$$13;
continue newTypeName;
} else {
const value$$14 = addToSet(name$$13, typeNames);
return name$$13;
}
} else {
const value$$15 = addToSet(name$$12, typeNames);
return name$$12;
}
}
};
let arg0$$71;
let Types$$8;
Types$$8 = collect$1(function mapping$$12(tp$$47) {
switch (tp$$47.tag) {
case 0:
{
const newTypes = [];
const materializeInterfaceType = function materializeInterfaceType(name$$14, members) {
let materialized;
const Comments$$2 = new List();
const Inherits$$4 = new List();
materialized = new FsInterface(Comments$$2, false, false, name$$14, name$$14, new List(), Inherits$$4, members, null);
newTypes.push(new FsType(0, "Interface", materialized));
};
let it2;
let arg0$$67;
let Members$$10;
Members$$10 = map$2(function mapping$$11(mb$$2) {
var arg20$$5, clo1$$16, clo2$$5;
if (mb$$2.tag === 8) {
let arg0$$66;
let Params$$2;
Params$$2 = map$2(function mapParam(prm$$1) {
var arg20$$2, clo1$$13, clo2$$2, arg20$$3, clo1$$14, clo2$$3, arg20$$4, arg30, clo1$$15, clo2$$4, clo3;
if (prm$$1.Type.tag === 21) {
let name$$15;
const itName = tp$$47.fields[0].Name === "IExports" ? "" : replace(tp$$47.fields[0].Name, "`", "");
const fnName = replace(mb$$2.fields[0].Name, "`", "");
const pmName = replace(prm$$1.Name, "`", "");
name$$15 = fnName === "Create" ? newTypeName((arg20$$2 = capitalize(pmName), (clo1$$13 = toText(printf("%s%s")), clo2$$2 = clo1$$13(itName), clo2$$2(arg20$$2)))) : fnName === pmName ? newTypeName((arg20$$3 = capitalize(pmName), (clo1$$14 = toText(printf("%s%s")), clo2$$3 = clo1$$14(itName), clo2$$3(arg20$$3)))) : newTypeName((arg20$$4 = capitalize(fnName), arg30 = capitalize(pmName), (clo1$$15 = toText(printf("%s%s%s")), clo2$$4 = clo1$$15(itName), clo3 = clo2$$4(arg20$$4), clo3(arg30))));
materializeInterfaceType(name$$15, prm$$1.Type.fields[0].Members);
const Type$$7 = simpleType(name$$15);
return new FsParam(prm$$1.Comment, prm$$1.Name, prm$$1.Optional, prm$$1.ParamArray, Type$$7);
} else {
return prm$$1;
}
}, mb$$2.fields[0].Params);
let ReturnType$$2;
if (mb$$2.fields[0].ReturnType.tag === 21) {
let name$$16;
const itName$$1 = tp$$47.fields[0].Name === "IExports" ? "" : replace(tp$$47.fields[0].Name, "`", "");
const fnName$$1 = replace(mb$$2.fields[0].Name, "`", "");
name$$16 = newTypeName((arg20$$5 = capitalize(fnName$$1), (clo1$$16 = toText(printf("%s%sReturn")), clo2$$5 = clo1$$16(itName$$1), clo2$$5(arg20$$5))));
materializeInterfaceType(name$$16, mb$$2.fields[0].ReturnType.fields[0].Members);
ReturnType$$2 = simpleType(name$$16);
} else {
ReturnType$$2 = mb$$2.fields[0].ReturnType;
}
arg0$$66 = new FsFunction(mb$$2.fields[0].Comments, mb$$2.fields[0].Kind, mb$$2.fields[0].IsStatic, mb$$2.fields[0].Name, mb$$2.fields[0].TypeParameters, Params$$2, ReturnType$$2, mb$$2.fields[0].Accessibility);
return new FsType(8, "Function", arg0$$66);
} else {
return mb$$2;
}
}, tp$$47.fields[0].Members);
arg0$$67 = new FsInterface(tp$$47.fields[0].Comments, tp$$47.fields[0].IsStatic, tp$$47.fields[0].IsClass, tp$$47.fields[0].Name, tp$$47.fields[0].FullName, tp$$47.fields[0].TypeParameters, tp$$47.fields[0].Inherits, Members$$10, tp$$47.fields[0].Accessibility);
it2 = new FsType(0, "Interface", arg0$$67);
return append$1(new List(it2, new List()), ofSeq$1(newTypes));
}
case 10:
{
if (tp$$47.fields[0].Type.tag === 9) {
let un2;
let Types$$7;
const tps$$9 = [];
iterate$1(function action$$4(tp$$49) {
if (tp$$49.tag === 21) {
addRangeInPlace(tp$$49.fields[0].Members, tps$$9);
} else {
tps$$9.push(tp$$49);
}
}, tp$$47.fields[0].Type.fields[0].Types);
Types$$7 = ofSeq$1(tps$$9);
un2 = new FsUnion(tp$$47.fields[0].Type.fields[0].Option, Types$$7);
let value$$16;
let arg0$$69;
let Type$$8;
Type$$8 = new FsType(9, "Union", un2);
arg0$$69 = new FsAlias(tp$$47.fields[0].Name, Type$$8, tp$$47.fields[0].TypeParameters);
value$$16 = new FsType(10, "Alias", arg0$$69);
return new List(value$$16, new List());
} else if (tp$$47.fields[0].Type.tag === 21) {
let value$$17;
let arg0$$70;
const Comments$$3 = new List();
const Inherits$$5 = new List();
arg0$$70 = new FsInterface(Comments$$3, false, false, tp$$47.fields[0].Name, tp$$47.fields[0].Name, tp$$47.fields[0].TypeParameters, Inherits$$5, tp$$47.fields[0].Type.fields[0].Members, null);
value$$17 = new FsType(0, "Interface", arg0$$70);
return new List(value$$17, new List());
} else {
return new List(tp$$47, new List());
}
}
default:
{
return new List(tp$$47, new List());
}
}
}, tp$$45.fields[0].Types);
arg0$$71 = new FsModule(tp$$45.fields[0].HasDeclare, tp$$45.fields[0].IsNamespace, tp$$45.fields[0].Name, Types$$8, tp$$45.fields[0].HelperLines, tp$$45.fields[0].Attributes);
return new FsType(13, "Module", arg0$$71);
} else {
return tp$$45;
}
}, f$$47);
return fixFile(function fix$$34(ns$$39, t$$10) {
var replacedTypeLiterals, uniqueNames, m$$4, generatedTypes, Types$$9, matchValue$$8, clo1$$17, source$$19;
if (t$$10.tag === 13) {
return new FsType(13, "Module", (replacedTypeLiterals = createMutable([], {
Equals: equals,
GetHashCode: structuralHash
}), uniqueNames = new Map([]), m$$4 = (matchValue$$8 = fixTypeEx("", function (_arg1$$2) {
return _arg1$$2.tag === 13 ? !equals(_arg1$$2.fields[0], t$$10.fields[0]) ? false : true : true;
}, function (ns$$38, tp$$51) {
if (tp$$51.tag === 21) {
let extractedInterface$$1;
const matchValue$$9 = tryGetValue(replacedTypeLiterals, tp$$51.fields[0], null);
if (matchValue$$9[0]) {
extractedInterface$$1 = matchValue$$9[1];
} else {
let i$$4;
let name$$17;
if (uniqueNames.has(ns$$38)) {
uniqueNames.set(ns$$38, getItemFromDict(uniqueNames, ns$$38) + 1);
const arg20$$6 = getItemFromDict(uniqueNames, ns$$38) | 0;
const clo1$$18 = toText(printf("%s%i"));
const clo2$$6 = clo1$$18(ns$$38);
name$$17 = clo2$$6(arg20$$6);
} else {
uniqueNames.set(ns$$38, 1);
name$$17 = ns$$38;
}
const generics = createMutable$1([], {
Equals: equals,
GetHashCode: structuralHash
});
let value$$19;
const tp$$50 = new FsType(21, "TypeLiteral", tp$$51.fields[0]);
value$$19 = fixType(ns$$38, function fix$$33(ns$$37, t$$9) {
var $target$$174;
if (t$$9.tag === 7) {
if (t$$9.fields[0].Name.indexOf("'") === 0) {
$target$$174 = 0;
} else {
$target$$174 = 1;
}
} else {
$target$$174 = 1;
}
switch ($target$$174) {
case 0:
{
const value$$18 = addToSet(t$$9, generics);
return t$$9;
}
case 1:
{
return t$$9;
}
}
}, tp$$50);
let extractedInterface;
const Comments$$4 = new List();
const Inherits$$6 = new List();
extractedInterface = new FsInterface(Comments$$4, false, false, name$$17, name$$17, (ofSeq$1(generics)), Inherits$$6, tp$$51.fields[0].Members, null);
i$$4 = extractedInterface;
replacedTypeLiterals.set(tp$$51.fields[0], i$$4);
extractedInterface$$1 = i$$4;
}
return extractedInterface$$1.TypeParameters.tail == null ? simpleType(extractedInterface$$1.Name) : new FsType(11, "Generic", new FsGenericType(simpleType(extractedInterface$$1.Name), extractedInterface$$1.TypeParameters));
} else {
return tp$$51;
}
}, new FsType(13, "Module", t$$10.fields[0])), matchValue$$8.tag === 13 ? matchValue$$8.fields[0] : (clo1$$17 = toFail(printf("Impossible: %A")), clo1$$17(matchValue$$8))), generatedTypes = (source$$19 = (map$1(function mapping$$13(kv) {
return new FsType(0, "Interface", kv[1]);
}, replacedTypeLiterals)), (ofSeq$1(source$$19))), Types$$9 = append$1(m$$4.Types, generatedTypes), new FsModule(m$$4.HasDeclare, m$$4.IsNamespace, m$$4.Name, Types$$9, m$$4.HelperLines, m$$4.Attributes)));
} else {
return t$$10;
}
}, f$$50);
}
function fixNamespace(f$$54) {
return fixFile(function fix$$36(ns$$41, tp$$54) {
switch (tp$$54.tag) {
case 7:
{
const arg0$$74 = new FsMapped(fixNamespaceString(tp$$54.fields[0].Name), tp$$54.fields[0].FullName);
return new FsType(7, "Mapped", arg0$$74);
}
case 20:
{
let arg0$$77;
if (tp$$54.fields[0].tag === 0) {
let arg0$$76;
const SpecifiedModule = f$$54.Kind.tag === 1 ? tp$$54.fields[0].fields[0].SpecifiedModule : fixModuleName(tp$$54.fields[0].fields[0].SpecifiedModule);
arg0$$76 = new FsTypeImport(tp$$54.fields[0].fields[0].ImportSpecifier, SpecifiedModule, tp$$54.fields[0].fields[0].ResolvedModule);
arg0$$77 = new FsImport(0, "Type", arg0$$76);
} else {
const arg0$$75 = new ModuleImport(fixModuleName(tp$$54.fields[0].fields[0].Module), fixModuleName(tp$$54.fields[0].fields[0].SpecifiedModule), tp$$54.fields[0].fields[0].ResolvedModule);
arg0$$77 = new FsImport(1, "Module", arg0$$75);
}
return new FsType(20, "Import", arg0$$77);
}
default:
{
return tp$$54;
}
}
}, f$$54);
}
function aliasToInterfacePartly(f$$56) {
let f$$64;
let f$$62;
let f$$60;
f$$60 = fixFile(function fix$$37(ns$$42, tp$$55) {
if (tp$$55.tag === 10) {
if (tp$$55.fields[0].Type.tag === 8) {
let arg0$$79;
const Inherits$$7 = new List();
let Members$$13;
let value$$20;
let arg0$$78;
const Name$$11 = "Invoke";
const Kind$$1 = new FsFunctionKind(2, "Call");
arg0$$78 = new FsFunction(tp$$55.fields[0].Type.fields[0].Comments, Kind$$1, tp$$55.fields[0].Type.fields[0].IsStatic, Name$$11, tp$$55.fields[0].Type.fields[0].TypeParameters, tp$$55.fields[0].Type.fields[0].Params, tp$$55.fields[0].Type.fields[0].ReturnType, tp$$55.fields[0].Type.fields[0].Accessibility);
value$$20 = new FsType(8, "Function", arg0$$78);
Members$$13 = new List(value$$20, new List());
arg0$$79 = new FsInterface(tp$$55.fields[0].Type.fields[0].Comments, false, false, tp$$55.fields[0].Name, tp$$55.fields[0].Name, tp$$55.fields[0].TypeParameters, Inherits$$7, Members$$13, null);
return new FsType(0, "Interface", arg0$$79);
} else {
return tp$$55;
}
} else {
return tp$$55;
}
}, f$$56);
f$$62 = fixFile(function fix$$38(ns$$43, tp$$56) {
if (tp$$56.tag === 10) {
if (tp$$56.fields[0].Type.tag === 12) {
if (tp$$56.fields[0].Type.fields[0].Kind.tag === 0) {
let arg0$$80;
const Comments$$6 = new List();
const Inherits$$8 = new List();
const Members$$14 = new List();
arg0$$80 = new FsInterface(Comments$$6, false, false, tp$$56.fields[0].Name, tp$$56.fields[0].Name, tp$$56.fields[0].TypeParameters, Inherits$$8, Members$$14, null);
return new FsType(0, "Interface", arg0$$80);
} else {
return tp$$56;
}
} else {
return tp$$56;
}
} else {
return tp$$56;
}
}, f$$60);
f$$64 = fixFile(function fix$$39(ns$$44, tp$$57) {
if (tp$$57.tag === 10) {
var $target$$191;
if (tp$$57.fields[0].Type.tag === 12) {
if (equals(tp$$57.fields[0].Type.fields[0].Kind, new FsTupleKind(2, "Mapped"))) {
$target$$191 = 0;
} else {
$target$$191 = 1;
}
} else {
$target$$191 = 1;
}
switch ($target$$191) {
case 0:
{
let arg0$$81;
const Comments$$7 = new List();
const Inherits$$9 = new List();
const Members$$15 = new List();
arg0$$81 = new FsInterface(Comments$$7, false, false, tp$$57.fields[0].Name, tp$$57.fields[0].Name, tp$$57.fields[0].TypeParameters, Inherits$$9, Members$$15, null);
return new FsType(0, "Interface", arg0$$81);
}
case 1:
{
return tp$$57;
}
}
} else {
return tp$$57;
}
}, f$$62);
return fixFile(function fix$$40(ns$$45, tp$$58) {
if (tp$$58.tag === 12) {
var $target$$194;
if (tp$$58.fields[0].Kind.tag === 0) {
$target$$194 = 0;
} else if (tp$$58.fields[0].Kind.tag === 2) {
$target$$194 = 0;
} else {
$target$$194 = 1;
}
switch ($target$$194) {
case 0:
{
return simpleType("obj");
}
case 1:
{
return tp$$58;
}
}
} else {
return tp$$58;
}
}, f$$64);
}
function fixFloatAlias(f$$66) {
return fixFile(function fix$$41(ns$$46, tp$$59) {
var Types$$11, itemsToExclude;
if (tp$$59.tag === 13) {
let floatNumberAlias;
floatNumberAlias = tryFind$1(function predicate$$5(_arg2) {
var $target$$199;
if (_arg2.tag === 10) {
if (_arg2.fields[0].Name === "float") {
if (_arg2.fields[0].Type.tag === 7) {
if (_arg2.fields[0].Type.fields[0].Name === "float") {
if (_arg2.fields[0].Type.fields[0].FullName === "float") {
$target$$199 = 0;
} else {
$target$$199 = 1;
}
} else {
$target$$199 = 1;
}
} else {
$target$$199 = 1;
}
} else {
$target$$199 = 1;
}
} else {
$target$$199 = 1;
}
switch ($target$$199) {
case 0:
{
return true;
}
case 1:
{
return false;
}
}
}, tp$$59.fields[0].Types);
if (floatNumberAlias == null) {
return tp$$59;
} else {
const a$$4 = floatNumberAlias;
return new FsType(13, "Module", (Types$$11 = (itemsToExclude = new List(a$$4, new List()), except(itemsToExclude, tp$$59.fields[0].Types, {
Equals: equals,
GetHashCode: structuralHash
})), new FsModule(tp$$59.fields[0].HasDeclare, tp$$59.fields[0].IsNamespace, tp$$59.fields[0].Name, Types$$11, tp$$59.fields[0].HelperLines, tp$$59.fields[0].Attributes)));
}
} else {
return tp$$59;
}
}, f$$66);
}
const abbrevTypes = (() => {
const elements$$3 = ofArray([["Array", "type Array<'T> = System.Collections.Generic.IList<'T>"], ["ReadonlyArray", "type ReadonlyArray<'T> = System.Collections.Generic.IReadOnlyList<'T>"], ["ReadonlySet", "type ReadonlySet<'T> = Set<'T>"], ["ReadonlyMap", "type ReadonlyMap<'K, 'V> = Map<'K, 'V>"], ["RegExp", "type RegExp = System.Text.RegularExpressions.Regex"], ["Error", "type Error = System.Exception"], ["Function", "type Function = System.Action"], ["Symbol", "type Symbol = obj"], ["TemplateStringsArray", "type TemplateStringsArray = System.Collections.Generic.IReadOnlyList<string>"]]);
return ofList(elements$$3, {
Compare: comparePrimitives
});
})();
function fixFsFileOut(fo$$1) {
let mappedTypes;
let list$$50;
let list$$49;
list$$49 = getAllTypes(fo$$1.Files);
list$$50 = choose(FsTypeModule$$$asMapped, list$$49);
mappedTypes = distinct(list$$50, {
Equals: equals,
GetHashCode: structuralHash
});
let isBrowser;
isBrowser = exists$1(function predicate$$6(mp$$7) {
return mp$$7.Name.indexOf("HTML") === 0;
}, mappedTypes);
let abbrevTypes$$1;
let list$$55;
let list$$54;
let list$$53;
list$$53 = filter$1(function predicate$$7(mp$$8) {
return containsKey(mp$$8.Name, abbrevTypes);
}, mappedTypes);
list$$54 = map$2(function mapping$$16(mp$$9) {
return find(mp$$9.Name, abbrevTypes);
}, list$$53);
list$$55 = distinct(list$$54, {
Equals($x$$27, $y$$28) {
return $x$$27 === $y$$28;
},
GetHashCode: structuralHash
});
abbrevTypes$$1 = sort(list$$55, {
Compare: comparePrimitives
});
const fo$$2 = new FsFileOut(fo$$1.Namespace, fo$$1.Opens, fo$$1.Files, abbrevTypes$$1);
if (isBrowser) {
const Opens = append$1(fo$$2.Opens, new List("Browser.Types", new List()));
let Files$$1;
Files$$1 = map$2(function fixHelperLines(f$$68) {
return fixFile(function fix$$42(ns$$47, tp$$61) {
if (tp$$61.tag === 13) {
let arg0$$82;
let HelperLines;
HelperLines = map$2(function mapping$$17(l) {
return replace(l, "Option.map", "Microsoft.FSharp.Core.Option.map");
}, tp$$61.fields[0].HelperLines);
arg0$$82 = new FsModule(tp$$61.fields[0].HasDeclare, tp$$61.fields[0].IsNamespace, tp$$61.fields[0].Name, tp$$61.fields[0].Types, HelperLines, tp$$61.fields[0].Attributes);
return new FsType(13, "Module", arg0$$82);
} else {
return tp$$61;
}
}, f$$68);
}, fo$$2.Files);
return new FsFileOut(fo$$2.Namespace, Opens, Files$$1, fo$$2.AbbrevTypes);
} else {
return fo$$2;
}
}
function extractGenericParameterDefaults(f$$70) {
let f$$73;
const extractAliasesFromGenericParameterDefaults = function extractAliasesFromGenericParameterDefaults(name$$24, tps$$10) {
const aliases = [];
let list$$60;
list$$60 = choose(FsTypeModule$$$asGenericParameterDefaults, tps$$10);
iterateIndexed$1(function action$$5(i$$6, _arg2$$1) {
var arg0$$83, list$$59;
const arg00$$21 = new FsAlias(name$$24, (arg0$$83 = new FsGenericType(simpleType(name$$24), append$1((list$$59 = slice(0, i$$6, tps$$10), (map$2(function mapping$$18(_arg1$$3) {
return simpleType("obj");
}, list$$59))), slice(i$$6 + 1, null, tps$$10))), (new FsType(11, "Generic", arg0$$83))), slice(i$$6 + 1, null, tps$$10));
aliases.push(arg00$$21);
}, list$$60);
let list$$61;
list$$61 = ofSeq$1(aliases);
return map$2(function mapping$$19(arg0$$84) {
return new FsType(10, "Alias", arg0$$84);
}, list$$61);
};
f$$73 = fixFile(function fix$$43(ns$$48, tp$$63) {
if (tp$$63.tag === 13) {
let arg0$$85;
let Types$$12;
const tps$$11 = [];
iterate$1(function action$$6(tp$$64) {
switch (tp$$64.tag) {
case 0:
{
const arg00$$22 = extractAliasesFromGenericParameterDefaults(tp$$64.fields[0].Name, tp$$64.fields[0].TypeParameters);
addRangeInPlace(arg00$$22, tps$$11);
tps$$11.push(tp$$64);
break;
}
case 10:
{
const arg00$$24 = extractAliasesFromGenericParameterDefaults(tp$$64.fields[0].Name, tp$$64.fields[0].TypeParameters);
addRangeInPlace(arg00$$24, tps$$11);
tps$$11.push(tp$$64);
break;
}
default:
{
tps$$11.push(tp$$64);
}
}
}, tp$$63.fields[0].Types);
Types$$12 = ofSeq$1(tps$$11);
arg0$$85 = new FsModule(tp$$63.fields[0].HasDeclare, tp$$63.fields[0].IsNamespace, tp$$63.fields[0].Name, Types$$12, tp$$63.fields[0].HelperLines, tp$$63.fields[0].Attributes);
return new FsType(13, "Module", arg0$$85);
} else {
return tp$$63;
}
}, f$$70);
return fixFile(function fix$$45(ns$$49, tp$$65) {
if (tp$$65.tag === 22) {
const arg0$$86 = new FsMapped(tp$$65.fields[0].Name, tp$$65.fields[0].FullName);
return new FsType(7, "Mapped", arg0$$86);
} else {
return tp$$65;
}
}, f$$73);
}
function fixTypesHasESKeywords(f$$75) {
return fixFile(function fix$$46(ns$$50, tp$$66) {
if (tp$$66.tag === 11) {
let _arg3;
const element = getName(tp$$66);
_arg3 = contains(element, esKeywords);
if (_arg3) {
const arg0$$87 = new FsGenericType(simpleType("obj"), new List());
return new FsType(11, "Generic", arg0$$87);
} else {
let arg0$$88;
let TypeParameters$$4;
TypeParameters$$4 = map$2(function mapping$$20(tp2$$2) {
if (tp2$$2.tag === 7) {
if (FSharpSet$$Contains$$2B595(esKeywords, tp2$$2.fields[0].Name)) {
return simpleType("obj");
} else {
return tp2$$2;
}
} else {
return tp2$$2;
}
}, tp$$66.fields[0].TypeParameters);
arg0$$88 = new FsGenericType(tp$$66.fields[0].Type, TypeParameters$$4);
return new FsType(11, "Generic", arg0$$88);
}
} else {
return tp$$66;
}
}, f$$75);
}
function extractTypesInGlobalModules(f$$77) {
let Modules$$4;
Modules$$4 = map$2(function mapping$$21(md$$12) {
const tps$$12 = [];
iterate$1(function action$$7(tp$$67) {
if (tp$$67.tag === 13) {
if (tp$$67.fields[0].Name === "global") {
addRangeInPlace(tp$$67.fields[0].Types, tps$$12);
} else {
tps$$12.push(tp$$67);
}
} else {
tps$$12.push(tp$$67);
}
}, md$$12.Types);
let Types$$13;
Types$$13 = ofSeq$1(tps$$12);
return new FsModule(md$$12.HasDeclare, md$$12.IsNamespace, md$$12.Name, Types$$13, md$$12.HelperLines, md$$12.Attributes);
}, f$$77.Modules);
return new FsFile(f$$77.Kind, f$$77.FileName, f$$77.ModuleName, Modules$$4);
}
function TypeScript$002ETs$002ENode$$Node$002EForEachChild$$FA7AF7F(x, cbNode) {
const value = x.forEachChild(function (nd) {
cbNode(nd);
return null;
});
}
function getAccessibility$1(modifiersOpt) {
if (modifiersOpt == null) {
return null;
} else {
const modifiers = modifiersOpt;
if (exists(function predicate(m) {
return m.kind === 118;
}, modifiers)) {
return new FsAccessibility(0, "Public");
} else if (exists(function predicate$$1(m$$1) {
return m$$1.kind === 117;
}, modifiers)) {
return new FsAccessibility(1, "Protected");
} else if (exists(function predicate$$2(m$$2) {
return m$$2.kind === 116;
}, modifiers)) {
return new FsAccessibility(2, "Private");
} else {
return null;
}
}
}
function getPropertyName(pn) {
const s = pn.getText();
return removeQuotes(s);
}
function getBindingName(bn) {
const matchValue = bn.kind | 0;
switch (matchValue) {
case 75:
{
return bn.getText();
}
case 188:
case 189:
{
return null;
}
default:
{
const arg10 = bn.kind | 0;
const clo1 = toFail(printf("unknown Binding Name kind %A"));
return clo1(arg10);
}
}
}
function readEnumCase(em) {
let name;
const pn$$1 = em.name;
name = getPropertyName(pn$$1);
let patternInput$$1;
const matchValue$$1 = em.initializer;
if (matchValue$$1 != null) {
const ep = matchValue$$1;
const matchValue$$2 = ep.kind | 0;
switch (matchValue$$2) {
case 8:
{
patternInput$$1 = [new FsEnumCaseType(0, "Numeric"), ep.text];
break;
}
case 10:
{
patternInput$$1 = [new FsEnumCaseType(1, "String"), ep.text];
break;
}
case 206:
{
const txt = ep.getText();
const patternInput = tryParse(txt, 511, false, 32);
patternInput$$1 = patternInput[0] ? [new FsEnumCaseType(0, "Numeric"), txt] : [new FsEnumCaseType(2, "Unknown"), null];
break;
}
default:
{
const arg10$$1 = ep.kind | 0;
const clo1$$1 = toFail(printf("EnumCase type not supported %A %A"));
const clo2 = clo1$$1(arg10$$1);
patternInput$$1 = clo2(name);
}
}
} else {
patternInput$$1 = [new FsEnumCaseType(2, "Unknown"), null];
}
return new FsEnumCase(name, patternInput$$1[0], patternInput$$1[1]);
}
function readTypeParameters(checker, tps) {
if (tps != null) {
const tps$$1 = tps;
let list;
list = ofSeq$1(tps$$1);
return map$2(function mapping(tp$$1) {
const matchValue$$3 = tp$$1.default;
if (matchValue$$3 == null) {
const arg0$$1 = new FsMapped(tp$$1.name.getText(), getFullNodeName(checker, tp$$1));
return new FsType(7, "Mapped", arg0$$1);
} else {
const df = matchValue$$3;
const arg0 = new FsGenericParameterDefaults(readTypeNode(checker, df), tp$$1.name.getText(), getFullNodeName(checker, tp$$1));
return new FsType(22, "GenericParameterDefaults", arg0);
}
}, list);
} else {
return new List();
}
}
function readInherits(checker$$1, hcs) {
if (hcs != null) {
const hcs$$1 = hcs;
let list$$3;
list$$3 = ofSeq$1(hcs$$1);
return collect$1(function mapping$$3(hc) {
let list$$2;
const source$$5 = hc.types;
list$$2 = ofSeq$1(source$$5);
return map$2(function mapping$$2(eta) {
const tp$$2 = readTypeNode(checker$$1, eta);
let prms;
const matchValue$$4 = eta.typeArguments;
if (matchValue$$4 != null) {
const tps$$2 = matchValue$$4;
let list$$1;
list$$1 = ofSeq$1(tps$$2);
prms = map$2(function mapping$$1(t) {
return readTypeNode(checker$$1, t);
}, list$$1);
} else {
prms = new List();
}
if (length(prms) === 0) {
return tp$$2;
} else {
const arg0$$2 = new FsGenericType(tp$$2, prms);
return new FsType(11, "Generic", arg0$$2);
}
}, list$$2);
}, list$$3);
} else {
return new List();
}
}
function readCommentLines(text) {
const array = replace(replace(text, "\r\n", "\n"), "\r", "\n").split("\n");
return ofArray(array);
}
function readComments(comments) {
if (comments.length === 0) {
return new List();
} else {
let list$$5;
list$$5 = ofSeq$1(comments);
return collect$1(function mapping$$5(dp) {
const matchValue$$5 = dp.kind;
if (matchValue$$5 === "text") {
let list$$4;
const text$$1 = dp.text;
list$$4 = readCommentLines(text$$1);
return map$2(function mapping$$4(arg0$$3) {
return new FsComment(0, "SummaryLine", arg0$$3);
}, list$$4);
} else {
return new List();
}
}, list$$5);
}
}
function readCommentTags(nd$$1) {
const tags = typescript.getJSDocTags(nd$$1);
let list$$6;
list$$6 = ofSeq$1(tags);
return collect$1(function mapping$$6(tag) {
var arg0$$4, arg0$$5;
const matchValue$$6 = tag.kind | 0;
if (matchValue$$6 === 310) {
const matchValue$$7 = tag.comment;
if (matchValue$$7 != null) {
const comment = matchValue$$7;
return new List((arg0$$4 = new FsParamComment("", readCommentLines(comment)), (new FsComment(1, "Param", arg0$$4))), new List());
} else {
return new List();
}
} else {
return new List((arg0$$5 = tag.comment, (new FsComment(2, "Unknown", arg0$$5))), new List());
}
}, list$$6);
}
function readCommentsForSignatureDeclaration(checker$$2, declaration) {
try {
const matchValue$$8 = checker$$2.getSignatureFromDeclaration(declaration);
if (matchValue$$8 != null) {
const signature = matchValue$$8;
let comments$$1;
const arg00 = checker$$2;
comments$$1 = signature.getDocumentationComment(arg00);
return readComments(comments$$1);
} else {
return new List();
}
} catch (matchValue$$9) {
return new List();
}
}
function readCommentsAtLocation(checker$$3, nd$$2) {
const matchValue$$10 = checker$$3.getSymbolAtLocation(nd$$2);
if (matchValue$$10 != null) {
const symbol = matchValue$$10;
let comments$$2;
const arg00$$1 = checker$$3;
comments$$2 = symbol.getDocumentationComment(arg00$$1);
return readComments(comments$$2);
} else {
return new List();
}
}
function readInterface(checker$$4, id$$1) {
const Comments = readCommentsAtLocation(checker$$4, id$$1.name);
const Name = id$$1.name.getText();
const FullName = getFullNodeName(checker$$4, id$$1);
const Inherits = readInherits(checker$$4, id$$1.heritageClauses);
let Members;
let list$$7;
const source$$9 = id$$1.members;
list$$7 = ofSeq$1(source$$9);
Members = map$2(function mapping$$7(te) {
return readNamedDeclaration(checker$$4, te);
}, list$$7);
return new FsInterface(Comments, false, false, Name, FullName, readTypeParameters(checker$$4, id$$1.typeParameters), Inherits, Members, getAccessibility$1(id$$1.modifiers));
}
function readTypeLiteral(checker$$5, tl) {
var list$$8, source$$10;
return new FsTypeLiteral((list$$8 = (source$$10 = tl.members, (ofSeq$1(source$$10))), (map$2(function mapping$$8(te$$1) {
return readNamedDeclaration(checker$$5, te$$1);
}, list$$8))));
}
function getFullTypeName(checker$$6, nd$$3) {
const tp$$3 = checker$$6.getTypeFromTypeNode(nd$$3);
if (!(tp$$3.symbol == null)) {
return checker$$6.getFullyQualifiedName(tp$$3.symbol);
} else {
return "error";
}
}
function getFullNodeName(checker$$7, nd$$4) {
const matchValue$$11 = checker$$7.getSymbolAtLocation(nd$$4);
if (matchValue$$11 != null) {
const smb = matchValue$$11;
return checker$$7.getFullyQualifiedName(smb);
} else {
return "";
}
}
function readClass(checker$$8, cd) {
const fullName = getFullNodeName(checker$$8, cd);
let Comments$$1;
let option$$1;
const option = cd.name;
option$$1 = map(function mapping$$9(nd$$5) {
return readCommentsAtLocation(checker$$8, nd$$5);
}, option);
const value$$2 = new List();
Comments$$1 = defaultArg(option$$1, value$$2);
let Name$$1;
const matchValue$$12 = cd.name;
if (matchValue$$12 != null) {
const id$$2 = matchValue$$12;
Name$$1 = id$$2.getText();
} else {
Name$$1 = fullName;
}
const Inherits$$1 = readInherits(checker$$8, cd.heritageClauses);
let Members$$1;
let list$$9;
const source$$11 = cd.members;
list$$9 = ofSeq$1(source$$11);
Members$$1 = map$2(function mapping$$10(te$$2) {
return readNamedDeclaration(checker$$8, te$$2);
}, list$$9);
return new FsInterface(Comments$$1, false, true, Name$$1, fullName, readTypeParameters(checker$$8, cd.typeParameters), Inherits$$1, Members$$1, getAccessibility$1(cd.modifiers));
}
function hasModifier(kind, modifiers$$1) {
if (modifiers$$1 != null) {
const mds = modifiers$$1;
return exists(function predicate$$3(md) {
return md.kind === kind;
}, mds);
} else {
return false;
}
}
function isConst(nd$$6) {
return (nd$$6.flags | 2) !== 0;
}
function isNamespace(nd$$7) {
const source$$13 = nd$$7.getChildren();
return exists(function predicate$$4(nd$$8) {
return nd$$8.kind === 135;
}, source$$13);
}
function readVariable(checker$$9, vb) {
let list$$10;
const source$$14 = vb.declarationList.declarations;
list$$10 = ofSeq$1(source$$14);
return map$2(function mapping$$12(vd) {
var option$$2, bn$$1, option$$4, option$$3, value$$4;
const arg0$$6 = new FsVariable(null, hasModifier(129, vb.modifiers) ? true : hasModifier(88, vb.modifiers), (option$$2 = (bn$$1 = vd.name, (getBindingName(bn$$1))), (defaultArg(option$$2, "unsupported_pattern"))), (option$$4 = (option$$3 = vd.type, (map(function mapping$$11(t$$1) {
return readTypeNode(checker$$9, t$$1);
}, option$$3))), (value$$4 = simpleType("obj"), defaultArg(option$$4, value$$4))), isConst(vd), hasModifier(119, vd.modifiers), getAccessibility$1(vb.modifiers));
return new FsType(16, "Variable", arg0$$6);
}, list$$10);
}
function readEnum(ed) {
var list$$11, source$$15;
return new FsEnum(ed.name.getText(), (list$$11 = (source$$15 = ed.members, (ofSeq$1(source$$15))), (map$2(readEnumCase, list$$11))));
}
function readTypeReference(checker$$10, tr) {
var typeName, arg10$$2, clo1$$2, arg0$$8, list$$12;
const matchValue$$13 = tr.typeArguments;
if (matchValue$$13 != null) {
const tas = matchValue$$13;
const arg0$$9 = new FsGenericType((typeName = tr.typeName.getText(), (typeName == null ? (arg10$$2 = tr.getText(), (clo1$$2 = toFail(printf("readTypeReference type name is null: %s")), clo1$$2(arg10$$2))) : null, (arg0$$8 = new FsMapped(typeName, getFullNodeName(checker$$10, tr)), (new FsType(7, "Mapped", arg0$$8))))), (list$$12 = (ofSeq$1(tas)), (map$2(function mapping$$14(t$$2) {
return readTypeNode(checker$$10, t$$2);
}, list$$12))));
return new FsType(11, "Generic", arg0$$9);
} else {
const arg0$$7 = new FsMapped(tr.getText(), getFullNodeName(checker$$10, tr));
return new FsType(7, "Mapped", arg0$$7);
}
}
function readFunctionType(checker$$11, ft) {
var option$$5, list$$13, source$$17;
return new FsFunction(new List(), new FsFunctionKind(0, "Regular"), hasModifier(119, ft.modifiers), (option$$5 = ft.name, (map(getPropertyName, option$$5))), readTypeParameters(checker$$11, ft.typeParameters), (list$$13 = (source$$17 = ft.parameters, (ofSeq$1(source$$17))), (mapIndexed(function mapping$$16(iParam, pd) {
return readParameterDeclaration(checker$$11, iParam, pd);
}, list$$13))), readTypeNode(checker$$11, ft.type), getAccessibility$1(ft.modifiers));
}
function readTypeNode($checker$$12$$61, $t$$3$$62) {
var list$$14, source$$18, list$$15, source$$19;
readTypeNode: while (true) {
const checker$$12 = $checker$$12$$61,
t$$3 = $t$$3$$62;
const matchValue$$14 = t$$3.kind | 0;
switch (matchValue$$14) {
case 99:
{
return new FsType(5, "TODO");
}
case 109:
{
return simpleType("unit");
}
case 124:
{
const arg0$$11 = new FsUnion(true, new List(simpleType("obj"), new List()));
return new FsType(9, "Union", arg0$$11);
}
case 127:
{
return simpleType("bool");
}
case 136:
{
return new FsType(5, "TODO");
}
case 139:
{
return simpleType("float");
}
case 140:
{
return simpleType("obj");
}
case 142:
{
return simpleType("string");
}
case 143:
{
return simpleType("Symbol");
}
case 145:
{
return simpleType("obj");
}
case 167:
{
return simpleType("bool");
}
case 168:
{
return readTypeReference(checker$$12, t$$3);
}
case 169:
{
const arg0$$10 = readFunctionType(checker$$12, t$$3);
return new FsType(8, "Function", arg0$$10);
}
case 171:
{
return simpleType("obj");
}
case 172:
{
const arg0$$13 = readTypeLiteral(checker$$12, t$$3);
return new FsType(21, "TypeLiteral", arg0$$13);
}
case 173:
{
return new FsType(4, "Array", readTypeNode(checker$$12, t$$3.elementType));
}
case 174:
{
const arg0$$12 = new FsTuple((list$$14 = (source$$18 = t$$3.elementTypes, (ofSeq$1(source$$18))), (map$2(function mapping$$17(t$$4) {
return readTypeNode(checker$$12, t$$4);
}, list$$14))), new FsTupleKind(1, "Tuple"));
return new FsType(12, "Tuple", arg0$$12);
}
case 177:
{
return readUnionType(checker$$12, t$$3);
}
case 178:
{
const arg0$$14 = new FsTuple((list$$15 = (source$$19 = t$$3.types, (ofSeq$1(source$$19))), (map$2(function mapping$$18(t$$5) {
return readTypeNode(checker$$12, t$$5);
}, list$$15))), new FsTupleKind(0, "Intersection"));
return new FsType(12, "Tuple", arg0$$14);
}
case 181:
{
$checker$$12$$61 = checker$$12;
$t$$3$$62 = t$$3.type;
continue readTypeNode;
}
case 182:
{
return new FsType(19, "This");
}
case 183:
{
$checker$$12$$61 = checker$$12;
$t$$3$$62 = t$$3.type;
continue readTypeNode;
}
case 184:
{
$checker$$12$$61 = checker$$12;
$t$$3$$62 = t$$3.objectType;
continue readTypeNode;
}
case 185:
{
const arg0$$16 = new FsTuple(new List(simpleType("obj"), new List()), new FsTupleKind(2, "Mapped"));
return new FsType(12, "Tuple", arg0$$16);
}
case 186:
{
const kind$$1 = t$$3.literal.kind;
const text$$2 = t$$3.literal.getText();
if (kind$$1 === 10) {
return new FsType(17, "StringLiteral", (removeQuotes(text$$2)));
} else {
return simpleType("obj");
}
}
case 215:
{
const arg0$$15 = new FsMapped(readExpressionText(t$$3.expression), getFullTypeName(checker$$12, t$$3));
return new FsType(7, "Mapped", arg0$$15);
}
default:
{
const arg10$$3 = t$$3.kind | 0;
const clo1$$3 = toConsole(printf("unsupported TypeNode kind: %A"));
clo1$$3(arg10$$3);
return new FsType(5, "TODO");
}
}
}
}
function readUnionType(checker$$13, un) {
let unTypes;
const source$$20 = un.types;
unTypes = ofSeq$1(source$$20);
const isOptionType = function isOptionType(t$$6) {
if (t$$6.kind === 145) {
return true;
} else {
return t$$6.kind === 99;
}
};
const isLiteralType = function isLiteralType(t$$7) {
return t$$7.kind === 186;
};
let isOptional;
isOptional = exists$1(isOptionType, unTypes);
const makeEnum = function makeEnum(name$$2, cases) {
const arg0$$17 = new FsEnum(name$$2, cases);
return new FsType(1, "Enum", arg0$$17);
};
const isKindOf = function isKindOf(kind$$2, t$$10) {
var name$$1, s$$2, matchValue$$15;
if (isLiteralType(t$$10)) {
if (equals(t$$10.literal.kind, kind$$2)) {
return name$$1 = (s$$2 = t$$10.literal.getText(), (removeQuotes(s$$2))), new FsEnumCase(name$$1, (matchValue$$15 = t$$10.literal.kind, matchValue$$15 === 8 ? new FsEnumCaseType(0, "Numeric") : matchValue$$15 === 10 ? new FsEnumCaseType(1, "String") : new FsEnumCaseType(2, "Unknown")), name$$1);
} else {
return null;
}
} else {
return null;
}
};
let nonOptionalTypes;
nonOptionalTypes = filter$1(function predicate$$6($arg$$1) {
const value$$5 = isOptionType($arg$$1);
return !value$$5;
}, unTypes);
let patternInput$$2;
patternInput$$2 = partition(isLiteralType, nonOptionalTypes);
let stringCases;
const chooser = partialApply(1, isKindOf, [10]);
stringCases = choose(chooser, patternInput$$2[0]);
let numericCases;
const chooser$$1 = partialApply(1, isKindOf, [8]);
numericCases = choose(chooser$$1, patternInput$$2[0]);
let restTypes;
restTypes = map$2(function mapping$$19(t$$11) {
return readTypeNode(checker$$13, t$$11);
}, patternInput$$2[1]);
const stringTypes = stringCases.tail == null ? new List() : new List(makeEnum("StringEnum", stringCases), new List());
const numericTypes = numericCases.tail == null ? new List() : new List(makeEnum("NumericEnum", numericCases), new List());
const unionTypes = concat$1([restTypes, stringTypes, numericTypes]);
var $target$$75;
if (unionTypes.tail != null) {
if (unionTypes.head.tag === 1) {
if (unionTypes.tail.tail == null) {
$target$$75 = 1;
} else {
$target$$75 = 2;
}
} else {
$target$$75 = 2;
}
} else {
$target$$75 = 0;
}
switch ($target$$75) {
case 0:
{
return simpleType("obj");
}
case 1:
{
return new FsType(21, "TypeLiteral", new FsTypeLiteral(unionTypes));
}
case 2:
{
return new FsType(9, "Union", new FsUnion(isOptional, unionTypes));
}
}
}
function readParameterDeclaration(checker$$14, iParam$$1, pd$$1) {
var s$$3, option$$7, list$$24;
let stringLiteral;
let list$$23;
const source$$21 = pd$$1.getChildren();
list$$23 = ofSeq$1(source$$21);
stringLiteral = tryPick(function chooser$$2(ch) {
let list$$22;
const source$$22 = ch.getChildren();
list$$22 = ofSeq$1(source$$22);
return tryFind$1(function predicate$$8(gch) {
return gch.kind === 10;
}, list$$22);
}, list$$23);
let tp$$5;
if (stringLiteral == null) {
const matchValue$$16 = pd$$1.type;
if (matchValue$$16 == null) {
tp$$5 = simpleType("obj");
} else {
const t$$12 = matchValue$$16;
tp$$5 = readTypeNode(checker$$14, t$$12);
}
} else {
const sl$$1 = stringLiteral;
tp$$5 = new FsType(17, "StringLiteral", (s$$3 = sl$$1.getText(), (removeQuotes(s$$3))));
}
let name$$3;
let option$$6;
const bn$$2 = pd$$1.name;
option$$6 = getBindingName(bn$$2);
const value$$6 = "p" + int32ToString(iParam$$1);
name$$3 = defaultArg(option$$6, value$$6);
return new FsParam((option$$7 = (list$$24 = readCommentTags(pd$$1), (tryFind$1(FsCommentModule$$$isParam, list$$24))), (map(function mapping$$20(comment$$1) {
if (comment$$1.tag === 1) {
const arg0$$18 = new FsParamComment(name$$3, comment$$1.fields[0].Description);
return new FsComment(1, "Param", arg0$$18);
} else {
return comment$$1;
}
}, option$$7))), name$$3, pd$$1.questionToken != null, pd$$1.dotDotDotToken != null, tp$$5);
}
function readMethodSignature(checker$$15, ms) {
var arg0$$19, pn$$3, list$$25, source$$23, matchValue$$17, t$$13;
return new FsFunction(readCommentsForSignatureDeclaration(checker$$15, ms), new FsFunctionKind(0, "Regular"), hasModifier(119, ms.modifiers), (arg0$$19 = (pn$$3 = ms.name, (getPropertyName(pn$$3))), (arg0$$19)), readTypeParameters(checker$$15, ms.typeParameters), (list$$25 = (source$$23 = ms.parameters, (ofSeq$1(source$$23))), (mapIndexed(function mapping$$21(iParam$$2, pd$$2) {
return readParameterDeclaration(checker$$15, iParam$$2, pd$$2);
}, list$$25))), (matchValue$$17 = ms.type, matchValue$$17 == null ? simpleType("unit") : (t$$13 = matchValue$$17, readTypeNode(checker$$15, t$$13))), getAccessibility$1(ms.modifiers));
}
function readMethodDeclaration(checker$$16, md$$1) {
var arg0$$20, pn$$4, list$$26, source$$24, matchValue$$18, t$$14;
return new FsFunction(readCommentsForSignatureDeclaration(checker$$16, md$$1), new FsFunctionKind(0, "Regular"), hasModifier(119, md$$1.modifiers), (arg0$$20 = (pn$$4 = md$$1.name, (getPropertyName(pn$$4))), (arg0$$20)), readTypeParameters(checker$$16, md$$1.typeParameters), (list$$26 = (source$$24 = md$$1.parameters, (ofSeq$1(source$$24))), (mapIndexed(function mapping$$22(iParam$$3, pd$$3) {
return readParameterDeclaration(checker$$16, iParam$$3, pd$$3);
}, list$$26))), (matchValue$$18 = md$$1.type, matchValue$$18 == null ? simpleType("unit") : (t$$14 = matchValue$$18, readTypeNode(checker$$16, t$$14))), getAccessibility$1(md$$1.modifiers));
}
function isReadOnly(modifiers$$2) {
return hasModifier(137, modifiers$$2);
}
function readPropertySignature(checker$$17, ps) {
var pn$$5, matchValue$$19, tp$$6;
return new FsProperty(readPropertyNameComments(checker$$17, ps.name), new FsPropertyKind(0, "Regular"), null, (pn$$5 = ps.name, (getPropertyName(pn$$5))), ps.questionToken != null, (matchValue$$19 = ps.type, matchValue$$19 != null ? (tp$$6 = matchValue$$19, readTypeNode(checker$$17, tp$$6)) : new FsType(6, "None")), isReadOnly(ps.modifiers), hasModifier(119, ps.modifiers), getAccessibility$1(ps.modifiers));
}
function readPropertyNameComments(checker$$18, pn$$6) {
return readCommentsAtLocation(checker$$18, pn$$6);
}
function readPropertyDeclaration(checker$$19, pd$$4) {
var pn$$7, matchValue$$20, tp$$7;
return new FsProperty(readPropertyNameComments(checker$$19, pd$$4.name), new FsPropertyKind(0, "Regular"), null, (pn$$7 = pd$$4.name, (getPropertyName(pn$$7))), pd$$4.questionToken != null, (matchValue$$20 = pd$$4.type, matchValue$$20 != null ? (tp$$7 = matchValue$$20, readTypeNode(checker$$19, tp$$7)) : new FsType(6, "None")), isReadOnly(pd$$4.modifiers), hasModifier(119, pd$$4.modifiers), getAccessibility$1(pd$$4.modifiers));
}
function readFunctionDeclaration(checker$$20, fd) {
var option$$8, list$$27, source$$25, matchValue$$21, t$$15;
return new FsFunction(readCommentsForSignatureDeclaration(checker$$20, fd), new FsFunctionKind(0, "Regular"), hasModifier(119, fd.modifiers), (option$$8 = fd.name, (map(function mapping$$23(id$$3) {
return id$$3.getText();
}, option$$8))), readTypeParameters(checker$$20, fd.typeParameters), (list$$27 = (source$$25 = fd.parameters, (ofSeq$1(source$$25))), (mapIndexed(function mapping$$24(iParam$$4, pd$$5) {
return readParameterDeclaration(checker$$20, iParam$$4, pd$$5);
}, list$$27))), (matchValue$$21 = fd.type, matchValue$$21 == null ? simpleType("unit") : (t$$15 = matchValue$$21, readTypeNode(checker$$20, t$$15))), getAccessibility$1(fd.modifiers));
}
function readIndexSignature(checker$$21, ps$$1) {
var matchValue$$22, tp$$8;
const pm = readParameterDeclaration(checker$$21, 0, ps$$1.parameters[0]);
return new FsProperty(readCommentsForSignatureDeclaration(checker$$21, ps$$1), new FsPropertyKind(1, "Index"), pm, "Item", ps$$1.questionToken != null, (matchValue$$22 = ps$$1.type, matchValue$$22 != null ? (tp$$8 = matchValue$$22, readTypeNode(checker$$21, tp$$8)) : new FsType(6, "None")), isReadOnly(ps$$1.modifiers), hasModifier(119, ps$$1.modifiers), getAccessibility$1(ps$$1.modifiers));
}
function readCallSignature(checker$$22, cs) {
var list$$28, source$$26, matchValue$$23, t$$16;
return new FsFunction(readCommentsForSignatureDeclaration(checker$$22, cs), new FsFunctionKind(2, "Call"), false, "Invoke", new List(), (list$$28 = (source$$26 = cs.parameters, (ofSeq$1(source$$26))), (mapIndexed(function mapping$$25(iParam$$5, pd$$6) {
return readParameterDeclaration(checker$$22, iParam$$5, pd$$6);
}, list$$28))), (matchValue$$23 = cs.type, matchValue$$23 == null ? simpleType("unit") : (t$$16 = matchValue$$23, readTypeNode(checker$$22, t$$16))), getAccessibility$1(cs.modifiers));
}
function readConstructSignatureDeclaration(checker$$23, cs$$1) {
var tps$$3, list$$29, source$$27;
return new FsFunction(readCommentsForSignatureDeclaration(checker$$23, cs$$1), new FsFunctionKind(1, "Constructor"), true, "Create", (tps$$3 = cs$$1.typeParameters, (readTypeParameters(checker$$23, tps$$3))), (list$$29 = (source$$27 = cs$$1.parameters, (ofSeq$1(source$$27))), (mapIndexed(function mapping$$26(iParam$$6, pd$$7) {
return readParameterDeclaration(checker$$23, iParam$$6, pd$$7);
}, list$$29))), new FsType(19, "This"), getAccessibility$1(cs$$1.modifiers));
}
function readConstructorDeclaration(checker$$24, cs$$2) {
var tps$$4, list$$30, source$$28;
return new FsFunction(readCommentsForSignatureDeclaration(checker$$24, cs$$2), new FsFunctionKind(1, "Constructor"), true, "Create", (tps$$4 = cs$$2.typeParameters, (readTypeParameters(checker$$24, tps$$4))), (list$$30 = (source$$28 = cs$$2.parameters, (ofSeq$1(source$$28))), (mapIndexed(function mapping$$27(iParam$$7, pd$$8) {
return readParameterDeclaration(checker$$24, iParam$$7, pd$$8);
}, list$$30))), new FsType(19, "This"), getAccessibility$1(cs$$2.modifiers));
}
function readNamedDeclaration(checker$$25, te$$3) {
const matchValue$$24 = te$$3.kind | 0;
switch (matchValue$$24) {
case 157:
{
const arg0$$23 = readPropertySignature(checker$$25, te$$3);
return new FsType(2, "Property", arg0$$23);
}
case 158:
{
const arg0$$27 = readPropertyDeclaration(checker$$25, te$$3);
return new FsType(2, "Property", arg0$$27);
}
case 159:
{
const arg0$$22 = readMethodSignature(checker$$25, te$$3);
return new FsType(8, "Function", arg0$$22);
}
case 160:
{
const arg0$$28 = readMethodDeclaration(checker$$25, te$$3);
return new FsType(8, "Function", arg0$$28);
}
case 161:
{
const arg0$$26 = readConstructorDeclaration(checker$$25, te$$3);
return new FsType(8, "Function", arg0$$26);
}
case 164:
{
const arg0$$24 = readCallSignature(checker$$25, te$$3);
return new FsType(8, "Function", arg0$$24);
}
case 165:
{
const arg0$$25 = readConstructSignatureDeclaration(checker$$25, te$$3);
return new FsType(8, "Function", arg0$$25);
}
case 166:
{
const arg0$$21 = readIndexSignature(checker$$25, te$$3);
return new FsType(2, "Property", arg0$$21);
}
default:
{
const arg10$$4 = te$$3.kind | 0;
const clo1$$4 = toConsole(printf("unsupported NamedDeclaration kind: %A"));
clo1$$4(arg10$$4);
return new FsType(5, "TODO");
}
}
}
function readAliasDeclaration(checker$$26, d) {
let tp$$9;
const t$$17 = d.type;
tp$$9 = readTypeNode(checker$$26, t$$17);
const name$$4 = d.name.getText();
const asAlias = function asAlias() {
const arg0$$29 = new FsAlias(name$$4, tp$$9, readTypeParameters(checker$$26, d.typeParameters));
return new FsType(10, "Alias", arg0$$29);
};
if (tp$$9.tag === 9) {
let sls;
sls = choose(FsTypeModule$$$asStringLiteral, tp$$9.fields[0].Types);
if (length(tp$$9.fields[0].Types) === length(sls)) {
const arg0$$30 = new FsEnum(name$$4, (map$2(function mapping$$28(sl$$2) {
return new FsEnumCase(sl$$2, new FsEnumCaseType(1, "String"), null);
}, sls)));
return new FsType(1, "Enum", arg0$$30);
} else {
return asAlias();
}
} else {
return asAlias();
}
}
function readExpressionText(ep$$1) {
const matchValue$$25 = ep$$1.kind | 0;
switch (matchValue$$25) {
case 75:
{
return ep$$1.getText();
}
case 193:
{
return ep$$1.getText();
}
default:
{
const arg10$$5 = ep$$1.kind | 0;
const clo1$$5 = toConsole(printf("readExpressionText kind not yet supported: %A"));
clo1$$5(arg10$$5);
return ep$$1.getText();
}
}
}
function readExportAssignment(ea) {
const matchValue$$26 = ea.expression.kind | 0;
if (matchValue$$26 === 75) {
const path = readExpressionText(ea.expression);
return new FsType(18, "ExportAssignment", path);
} else {
return new FsType(6, "None");
}
}
function readImportDeclaration(im) {
var arg0$$32, arg0$$31;
let moduleSpecifier;
const s$$4 = im.moduleSpecifier.getText();
moduleSpecifier = removeQuotes(s$$4);
const matchValue$$27 = im.importClause;
if (matchValue$$27 != null) {
const cl = matchValue$$27;
const matchValue$$28 = cl.namedBindings;
if (matchValue$$28 != null) {
const namedBindings = matchValue$$28;
if (!(namedBindings.name == null)) {
return new List((arg0$$32 = (arg0$$31 = new ModuleImport(namedBindings.name.getText(), moduleSpecifier, null), (new FsImport(1, "Module", arg0$$31))), (new FsType(20, "Import", arg0$$32))), new List());
} else {
const children = namedBindings.getChildren();
let list$$34;
list$$34 = ofSeq$1(children);
return collect$1(function mapping$$30(ch$$1) {
const matchValue$$29 = ch$$1.kind | 0;
if (matchValue$$29 === 317) {
let list$$33;
const source$$30 = ch$$1.getChildren();
list$$33 = ofSeq$1(source$$30);
return choose(function chooser$$3(slch) {
var Name$$2, option$$9;
const matchValue$$30 = slch.kind | 0;
if (matchValue$$30 === 257) {
let arg0$$35;
let arg0$$34;
const arg0$$33 = new FsTypeImport((Name$$2 = slch.name.text, new FsImportSpecifier((option$$9 = slch.propertyName, (map(function mapping$$29(id$$5) {
return id$$5.text;
}, option$$9))), Name$$2)), moduleSpecifier, null);
arg0$$34 = new FsImport(0, "Type", arg0$$33);
arg0$$35 = new FsType(20, "Import", arg0$$34);
return arg0$$35;
} else {
return null;
}
}, list$$33);
} else {
return new List();
}
}, list$$34);
}
} else {
return new List();
}
} else {
return new List();
}
}
function readStatement(checker$$27, sd) {
var arg0$$39, arg0$$38, arg0$$36, arg0$$37, arg0$$40;
const matchValue$$31 = sd.kind | 0;
switch (matchValue$$31) {
case 224:
{
return readVariable(checker$$27, sd);
}
case 243:
{
return new List((arg0$$39 = readFunctionDeclaration(checker$$27, sd), (new FsType(8, "Function", arg0$$39))), new List());
}
case 244:
{
return new List((arg0$$38 = readClass(checker$$27, sd), (new FsType(0, "Interface", arg0$$38))), new List());
}
case 245:
{
return new List((arg0$$36 = readInterface(checker$$27, sd), (new FsType(0, "Interface", arg0$$36))), new List());
}
case 246:
{
return new List(readAliasDeclaration(checker$$27, sd), new List());
}
case 247:
{
return new List((arg0$$37 = readEnum(sd), (new FsType(1, "Enum", arg0$$37))), new List());
}
case 248:
{
return new List((arg0$$40 = readModuleDeclaration(checker$$27, sd), (new FsType(13, "Module", arg0$$40))), new List());
}
case 251:
{
return new List();
}
case 252:
{
return new List();
}
case 253:
{
return readImportDeclaration(sd);
}
case 258:
{
return new List(readExportAssignment(sd), new List());
}
case 259:
{
return new List();
}
default:
{
const arg10$$6 = sd.kind | 0;
const clo1$$6 = toConsole(printf("unsupported Statement kind: %A"));
clo1$$6(arg10$$6);
return new List();
}
}
}
function readModuleName(mn) {
const s$$5 = mn.getText();
return removeQuotes(s$$5);
}
function readModuleDeclaration(checker$$28, md$$2) {
const types = [];
TypeScript$002ETs$002ENode$$Node$002EForEachChild$$FA7AF7F(md$$2, function (nd$$9) {
const matchValue$$32 = nd$$9.kind | 0;
switch (matchValue$$32) {
case 10:
{
break;
}
case 75:
{
break;
}
case 88:
{
break;
}
case 129:
{
break;
}
case 248:
{
let arg00$$3;
const arg0$$41 = readModuleDeclaration(checker$$28, nd$$9);
arg00$$3 = new FsType(13, "Module", arg0$$41);
types.push(arg00$$3);
break;
}
case 249:
{
let list$$36;
let list$$35;
const source$$31 = nd$$9.statements;
list$$35 = ofSeq$1(source$$31);
list$$36 = collect$1(function mapping$$31(sd$$1) {
return readStatement(checker$$28, sd$$1);
}, list$$35);
iterate$1(function action(arg00$$2) {
types.push(arg00$$2);
}, list$$36);
break;
}
default:
{
const arg10$$7 = nd$$9.kind | 0;
const clo1$$7 = toConsole(printf("unknown kind in ModuleDeclaration: %A"));
clo1$$7(arg10$$7);
}
}
});
return new FsModule(hasModifier(129, md$$2.modifiers), isNamespace(md$$2), readModuleName(md$$2.name), (ofSeq$1(types)), new List(), new List());
}
function readSourceFile(checker$$29, sf, file) {
let md$$3;
let tps$$5;
let list$$37;
const source$$33 = sf.statements;
list$$37 = ofSeq$1(source$$33);
tps$$5 = collect$1(function mapping$$32(sd$$2) {
return readStatement(checker$$29, sd$$2);
}, list$$37);
md$$3 = file.Kind.tag === 1 ? new FsModule(true, false, (ModuleName$$$normalize(file.Kind.fields[0])), tps$$5, new List(), new List()) : new FsModule(false, false, "", tps$$5, new List(), new List());
const Modules = new List(md$$3, new List());
return new FsFile(file.Kind, file.FileName, file.ModuleName, Modules);
}
const scriptTarget = 2;
const NodeBridge = declare(function ts2fable_Bridges_NodeBridge(arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
this.TsPaths = arg1;
this.Exports = arg2;
this.ReadText = arg3;
this.NameSpace = arg4;
this.EnumerateFilesInSameDir = arg5;
this.GetFsFileKind = arg6;
this.FixNamespace = arg7;
}, Record);
function NodeBridgeModule$$$useExport(nb, f) {
var $target$$5, tsPath;
if (nb.TsPaths.tail != null) {
if (nb.TsPaths.tail.tail == null) {
$target$$5 = 0;
tsPath = nb.TsPaths.head;
} else {
$target$$5 = 1;
}
} else {
$target$$5 = 1;
}
switch ($target$$5) {
case 0:
{
return f(tsPath);
}
case 1:
{
throw new Error("tspaths 's length must be 1 when with --exports option");
}
}
}
const WebBridge = declare(function ts2fable_Bridges_WebBridge(arg1, arg2) {
this.FileName = arg1;
this.SourceFile = arg2;
}, Record);
const Bridge = declare(function ts2fable_Bridges_Bridge(tag, name, ...fields) {
Union.call(this, tag, name, ...fields);
}, Union);
function BridgeModule$$$fsFileKind(tsPath$$1, _arg1) {
if (_arg1.tag === 1) {
return new FsFileKind(0, "Index");
} else {
return _arg1.fields[0].GetFsFileKind([_arg1.fields[0], tsPath$$1]);
}
}
function BridgeModule$$$getExportFiles(_arg1$$2) {
if (_arg1$$2.tag === 1) {
return new List(_arg1$$2.fields[0].FileName, new List());
} else {
if (length(_arg1$$2.fields[0].Exports) === 0) {
return _arg1$$2.fields[0].TsPaths;
} else {
return NodeBridgeModule$$$useExport(_arg1$$2.fields[0], function (index) {
let list;
const source = _arg1$$2.fields[0].EnumerateFilesInSameDir(index);
list = ofSeq$1(source);
return filter$1(function predicate(f$$1) {
if (endsWith(f$$1, ".d.ts")) {
return stringContainsAny(f$$1, _arg1$$2.fields[0].Exports);
} else {
return false;
}
}, list);
});
}
}
}
function BridgeModule$$$getNamespace(_arg1$$3) {
if (_arg1$$3.tag === 1) {
return "moduleName";
} else {
return _arg1$$3.fields[0].NameSpace;
}
}
function BridgeModule$$$createProgram(bridge) {
const createDummy = function createDummy(tsPaths, sourceFiles) {
const options = {
target: scriptTarget,
module: 1
};
const host = {
getSourceFile: function (fileName) {
return tryFind$1(function predicate$$1(sf) {
return sf.fileName === fileName;
}, sourceFiles);
},
writeFile: function (tupledArg) {},
getDefaultLibFileName: function (_arg3) {
return "lib.d.ts";
},
useCaseSensitiveFileNames: function () {
return false;
},
getCanonicalFileName: function (x) {
return x;
},
getCurrentDirectory: function () {
return "";
},
getNewLine: function () {
return "\r\n";
},
fileExists: function (fileName$$1) {
return contains$2(fileName$$1, tsPaths, {
Equals($x$$1, $y$$2) {
return $x$$1 === $y$$2;
},
GetHashCode: structuralHash
});
},
readFile: function (_arg7) {
return "";
},
directoryExists: function (_arg8) {
return true;
},
getDirectories: function (_arg9) {
return [];
}
};
return typescript.createProgram(Array.from(tsPaths), options, host);
};
if (bridge.tag === 1) {
return createDummy(new List(bridge.fields[0].FileName, new List()), new List(bridge.fields[0].SourceFile, new List()));
} else {
const patternInput = [BridgeModule$$$getExportFiles(bridge), bridge.fields[0].ReadText];
let sourceFiles$$1;
sourceFiles$$1 = map$2(function mapping(tsPath$$2) {
const text = patternInput[1](tsPath$$2);
return typescript.createSourceFile(tsPath$$2, text, scriptTarget, true);
}, patternInput[0]);
return createDummy(patternInput[0], sourceFiles$$1);
}
}
function BridgeModule$$$fixNameSpaceWithBridge(bridge$$1, file) {
if (bridge$$1.tag === 1) {
return fixNamespace(file);
} else {
return bridge$$1.fields[0].FixNamespace(file);
}
}
function BridgeModule$$$transform(bridge$$2, file$$1) {
let f$$27;
let f$$26;
let f$$25;
let f$$24;
let f$$23;
let f$$22;
let f$$21;
let f$$20;
let file$$2;
let f$$19;
let f$$18;
let f$$17;
let f$$16;
let f$$15;
let f$$14;
let f$$13;
let f$$12;
let f$$11;
let f$$10;
let f$$9;
let f$$8;
let f$$7;
let f$$6;
let f$$5;
let f$$4;
let f$$3;
f$$3 = removeInternalModules(file$$1);
f$$4 = mergeModulesInFile(f$$3);
f$$5 = aliasToInterfacePartly(f$$4);
f$$6 = extractGenericParameterDefaults(f$$5);
f$$7 = fixTypesHasESKeywords(f$$6);
f$$8 = extractTypesInGlobalModules(f$$7);
f$$9 = addConstructors(f$$8);
f$$10 = removePrivatesFromClasses(f$$9);
f$$11 = fixThis(f$$10);
f$$12 = fixNodeArray(f$$11);
f$$13 = fixReadonlyArray(f$$12);
f$$14 = fixDateTime(f$$13);
f$$15 = fixStatic(f$$14);
f$$16 = createIExports(f$$15);
f$$17 = fixOverloadingOnStringParameters(f$$16);
f$$18 = fixEnumReferences(f$$17);
f$$19 = fixDuplicatesInUnion(f$$18);
file$$2 = fixEscapeWords(f$$19);
f$$20 = BridgeModule$$$fixNameSpaceWithBridge(bridge$$2, file$$2);
f$$21 = addTicForGenericFunctions(f$$20);
f$$22 = addTicForGenericTypes(f$$21);
f$$23 = removeTypeParamsFromStatic(f$$22);
f$$24 = removeDuplicateFunctions(f$$23);
f$$25 = removeDuplicateOptions(f$$24);
f$$26 = extractTypeLiterals(f$$25);
f$$27 = removeDuplicateOptionsFromParameters(f$$26);
return fixFloatAlias(f$$27);
}
function BridgeModule$$$getFsFileOut(bridge$$3) {
const program = BridgeModule$$$createProgram(bridge$$3);
const nameSpace = BridgeModule$$$getNamespace(bridge$$3);
const exportFiles = BridgeModule$$$getExportFiles(bridge$$3);
iterate(function (export$) {
const clo1 = toConsole(printf("export %s"));
clo1(export$);
}, exportFiles);
let tsFiles;
let list$$4;
list$$4 = map$2(function mapping$$1(arg00) {
return program.getSourceFile(arg00);
}, exportFiles);
tsFiles = choose(function chooser(x$$1) {
return x$$1;
}, list$$4);
const checker = program.getTypeChecker();
let moduleNameMap;
let keyValuePairs;
const source$$1 = program.getSourceFiles();
keyValuePairs = map$1(function mapping$$2(sf$$1) {
return [sf$$1.fileName, getJsModuleName(sf$$1.fileName)];
}, source$$1);
moduleNameMap = new Map(keyValuePairs);
let fsFiles;
fsFiles = map$2(function mapping$$3(tsFile) {
let file$$4;
const file$$3 = new FsFile(BridgeModule$$$fsFileKind(tsFile.fileName, bridge$$3), tsFile.fileName, getItemFromDict(moduleNameMap, tsFile.fileName), new List());
file$$4 = readSourceFile(checker, tsFile, file$$3);
return BridgeModule$$$transform(bridge$$3, file$$4);
}, tsFiles);
const fo = new FsFileOut(nameSpace, ofArray(["System", "Fable.Core", "Fable.Core.JsInterop"]), fsFiles, new List());
return fixFsFileOut(fo);
}
function fixNamespace$1(f) {
const f$$1 = fixNamespace(f);
if (f$$1.Kind.tag === 1) {
return fixFile(function fix(ns, tp) {
if (tp.tag === 20) {
if (tp.fields[0].tag === 0) {
let arg0$$1;
let arg0;
let SpecifiedModule;
let s;
const activePatternResult1816 = ModuleName$$$$007CNormal$007CParts$007C(tp.fields[0].fields[0].SpecifiedModule);
if (activePatternResult1816.tag === 1) {
const dir = path$$1.dirname(f$$1.Kind.fields[0]);
const joinedPath = path$$1.join(dir, tp.fields[0].fields[0].SpecifiedModule);
s = ModuleName$$$normalize(joinedPath);
} else {
s = tp.fields[0].fields[0].SpecifiedModule;
}
SpecifiedModule = fixModuleName(s);
arg0 = new FsTypeImport(tp.fields[0].fields[0].ImportSpecifier, SpecifiedModule, tp.fields[0].fields[0].ResolvedModule);
arg0$$1 = new FsImport(0, "Type", arg0);
return new FsType(20, "Import", arg0$$1);
} else {
return tp;
}
} else {
return tp;
}
}, f$$1);
} else {
return f$$1;
}
}
function getFsFileOut(fsPath, tsPaths, exports) {
let bridge;
let arg0;
const NameSpace = path$$1.basename(fsPath, path$$1.extname(fsPath));
arg0 = new NodeBridge(tsPaths, exports, readText, NameSpace, function EnumerateFilesInSameDir(indexFile) {
const dir$$1 = path$$1.dirname(indexFile);
return enumerateFiles([dir$$1]);
}, function GetFsFileKind(tupledArg) {
if (length(tupledArg[0].Exports) === 0) {
return new FsFileKind(0, "Index");
} else {
return NodeBridgeModule$$$useExport(tupledArg[0], function (index) {
if (contains$2(tupledArg[1], tupledArg[0].TsPaths, {
Equals($x$$1, $y$$2) {
return $x$$1 === $y$$2;
},
GetHashCode: structuralHash
})) {
return new FsFileKind(0, "Index");
} else {
const dir = path$$1.dirname(index);
const relativePath = path$$1.relative(dir, tupledArg[1]);
const relativePathWithOutExtension = substring(relativePath, 0, relativePath.lastIndexOf(".d.ts"));
return new FsFileKind(1, "Extra", relativePathWithOutExtension);
}
});
}
}, fixNamespace$1);
bridge = new Bridge(0, "Node", arg0);
return BridgeModule$$$getFsFileOut(bridge);
}
function emitFsFileOutAsLines(fsPath$$1, fsFileOut) {
const file = fs.createWriteStream(fsPath$$1);
const lines = [];
const inputSequence = printFsFile(version, fsFileOut);
iterate(function (line) {
var arg20, clo1, clo2;
lines.push(line);
const value = file.write((arg20 = "\n", (clo1 = toText(printf("%s%c")), clo2 = clo1(line), clo2(arg20))));
}, inputSequence);
file.end();
return ofSeq$1(lines);
}
function emitFsFileOut(fsPath$$2, fsFileOut$$1) {
const value$$1 = emitFsFileOutAsLines(fsPath$$2, fsFileOut$$1);
}
function writeFile(tsPaths$$1, fsPath$$3, exports$$1) {
const fsFileOut$$2 = getFsFileOut(fsPath$$3, tsPaths$$1, exports$$1);
emitFsFileOut(fsPath$$3, fsFileOut$$2);
}
function getArgs(pred, args) {
let source$$3;
let source$$2;
let source$$1;
source$$1 = skipWhile(function predicate($arg$$1) {
const value = pred($arg$$1);
return !value;
}, args);
source$$2 = skipWhile(pred, source$$1);
source$$3 = takeWhile(function predicate$$1(s) {
return !(s.indexOf("-") === 0);
}, source$$2);
return ofSeq$1(source$$3);
}
function parseArgs(args$$1) {
let exports;
exports = getArgs(function pred$$1(s$$1) {
if (s$$1 === "-e") {
return true;
} else {
return s$$1 === "--exports";
}
}, args$$1);
let fsPaths;
let array$$1;
array$$1 = args$$1.filter(function predicate$$2(s$$2) {
return endsWith(s$$2, ".fs");
});
fsPaths = toList(array$$1);
let tsPaths;
let array$$3;
array$$3 = args$$1.filter(function predicate$$3(s$$3) {
return endsWith(s$$3, ".ts");
});
tsPaths = toList(array$$3);
if (fsPaths.tail == null) {
toFail(printf("Please provide the path to the F# file to be written."));
}
if (tsPaths.tail == null) {
toFail(printf("Please provide the path to a TypeScript file."));
}
const clo1 = toConsole(printf("ts2fable %s"));
clo1(version);
iterate(function (tsPath) {
var value$$1;
if (value$$1 = fs.existsSync((tsPath)), (!value$$1)) {
const clo1$$1 = toFail(printf("TypeScript file not found: %s"));
clo1$$1(tsPath);
}
}, tsPaths);
writeFile(tsPaths, head(fsPaths), exports);
}
(function (argv) {
try {
if (contains$1("-v", argv, {
Equals($x$$2, $y$$3) {
return $x$$2 === $y$$3;
},
GetHashCode: structuralHash
}) ? true : contains$1("--version", argv, {
Equals($x$$4, $y$$5) {
return $x$$4 === $y$$5;
},
GetHashCode: structuralHash
})) {
const clo1$$2 = toConsole(printf("%s"));
clo1$$2(version);
}
if ((argv.length < 2 ? true : contains$1("-h", argv, {
Equals($x$$6, $y$$7) {
return $x$$6 === $y$$7;
},
GetHashCode: structuralHash
})) ? true : contains$1("--help", argv, {
Equals($x$$8, $y$$9) {
return $x$$8 === $y$$9;
},
GetHashCode: structuralHash
})) {
toConsole(printf("Usage: ts2fable some.d.ts src/Some.fs"));
} else {
parseArgs(argv);
}
} catch (ex) {
const arg10$$3 = ex.message;
const clo1$$3 = toConsole(printf("Error: %A"));
clo1$$3(arg10$$3);
}
return 0;
})(process.argv.slice(2));
exports.getArgs = getArgs;
exports.parseArgs = parseArgs;
Object.defineProperty(exports, '__esModule', { value: true });
})));