UNPKG

o1js

Version:

TypeScript framework for zk-SNARKs and zkApps

1,432 lines 22.5 MB
// Generated by js_of_ocaml 4.0.0 (function(Object) {typeof globalThis !== "object" && (this ?get() :(Object.defineProperty (Object.prototype,"_T_",{configurable:true,get:get}), _T_)); function get() {var global=this || self; global.globalThis = global; delete Object.prototype._T_}} (Object)); (function(globalThis) {var joo_global_object=globalThis; (function() {var DefaultLocale= {days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"], months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], AM:"AM", PM:"PM", am:"am", pm:"pm", formats: {D:"%m/%d/%y", F:"%Y-%m-%d", R:"%H:%M", T:"%H:%M:%S", X:"%T", c:"%a %b %d %X %Y", r:"%I:%M:%S %p", v:"%e-%b-%Y", x:"%D"}}, defaultStrftime=new Strftime(DefaultLocale,0,false), isCommonJS=typeof module !== "undefined", namespace; if(isCommonJS) {namespace = module.exports = adaptedStrftime; namespace.strftime = deprecatedStrftime; if(joo_global_object)joo_global_object.strftime = adaptedStrftime} else {namespace = joo_global_object || function(){return this || (1,eval)("this")}(); namespace.strftime = adaptedStrftime} var _require=isCommonJS?"require('strftime')":"strftime", _deprecationWarnings={}; function deprecationWarning(name,instead) {if(! _deprecationWarnings[name]) {if (typeof console !== "undefined" && typeof console.warn == "function") console.warn ("[WARNING] " + name + " is deprecated and will be removed in version 1.0. Instead, use `" + instead + "`."); _deprecationWarnings[name] = true}} namespace.strftimeTZ = deprecatedStrftimeTZ; namespace.strftimeUTC = deprecatedStrftimeUTC; namespace.localizedStrftime = deprecatedStrftimeLocalized; function adaptForwards(fn) {fn.localize = defaultStrftime.localize.bind(defaultStrftime); fn.timezone = defaultStrftime.timezone.bind(defaultStrftime); fn.utc = defaultStrftime.utc.bind(defaultStrftime)} adaptForwards(adaptedStrftime); function adaptedStrftime(fmt,d,locale) {if(d && d.days){locale = d;d = undefined} if(locale) deprecationWarning ("`" + _require + "(format, [date], [locale])`", "var s = " + _require + ".localize(locale); s(format, [date])"); var strftime= locale?defaultStrftime.localize(locale):defaultStrftime; return strftime(fmt,d)} adaptForwards(deprecatedStrftime); function deprecatedStrftime(fmt,d,locale) {if(locale) deprecationWarning ("`" + _require + ".strftime(format, [date], [locale])`", "var s = " + _require + ".localize(locale); s(format, [date])"); else deprecationWarning ("`" + _require + ".strftime(format, [date])`", _require + "(format, [date])"); var strftime= locale?defaultStrftime.localize(locale):defaultStrftime; return strftime(fmt,d)} function deprecatedStrftimeTZ(fmt,d,locale,timezone) {if ((typeof locale == "number" || typeof locale == "string") && timezone == null) {timezone = locale;locale = undefined} if(locale) deprecationWarning ("`" + _require + ".strftimeTZ(format, date, locale, tz)`", "var s = " + _require + ".localize(locale).timezone(tz); s(format, [date])` or `var s = " + _require + ".localize(locale); s.timezone(tz)(format, [date])"); else deprecationWarning ("`" + _require + ".strftimeTZ(format, date, tz)`", "var s = " + _require + ".timezone(tz); s(format, [date])` or `" + _require + ".timezone(tz)(format, [date])"); var strftime= (locale?defaultStrftime.localize(locale):defaultStrftime).timezone (timezone); return strftime(fmt,d)} var utcStrftime=defaultStrftime.utc(); function deprecatedStrftimeUTC(fmt,d,locale) {if(locale) deprecationWarning ("`" + _require + ".strftimeUTC(format, date, locale)`", "var s = " + _require + ".localize(locale).utc(); s(format, [date])"); else deprecationWarning ("`" + _require + ".strftimeUTC(format, [date])`", "var s = " + _require + ".utc(); s(format, [date])"); var strftime=locale?utcStrftime.localize(locale):utcStrftime; return strftime(fmt,d)} function deprecatedStrftimeLocalized(locale) {deprecationWarning ("`" + _require + ".localizedStrftime(locale)`", _require + ".localize(locale)"); return defaultStrftime.localize(locale)} if(typeof Date.now !== "function") Date.now = function(){return + new Date()}; function Strftime(locale,customTimezoneOffset,useUtcTimezone) {var _locale=locale || DefaultLocale, _customTimezoneOffset=customTimezoneOffset || 0, _useUtcBasedDate=useUtcTimezone || false, _cachedDateTimestamp=0, _cachedDate; function _strftime(format,date) {var timestamp; if(! date) {var currentTimestamp=Date.now(); if(currentTimestamp > _cachedDateTimestamp) {_cachedDateTimestamp = currentTimestamp; _cachedDate = new Date(_cachedDateTimestamp); timestamp = _cachedDateTimestamp; if(_useUtcBasedDate) _cachedDate = new Date (_cachedDateTimestamp + getTimestampToUtcOffsetFor(_cachedDate) + _customTimezoneOffset)} date = _cachedDate} else {timestamp = date.getTime(); if(_useUtcBasedDate) date = new Date (date.getTime() + getTimestampToUtcOffsetFor(date) + _customTimezoneOffset)} return _processFormat(format,date,_locale,timestamp)} function _processFormat(format,date,locale,timestamp) {var resultString="", padding=null, isInScope=false, length=format.length, extendedTZ=false; for(var i=0;i < length;i++) {var currentCharCode=format.charCodeAt(i); if(isInScope === true) {if(currentCharCode === 45) {padding = "";continue} else if(currentCharCode === 95) {padding = " ";continue} else if(currentCharCode === 48) {padding = "0";continue} else if(currentCharCode === 58) {if(extendedTZ) if (typeof console !== "undefined" && typeof console.warn == "function") console.warn ("[WARNING] detected use of unsupported %:: or %::: modifiers to strftime"); extendedTZ = true; continue} switch(currentCharCode) {case 65:resultString += locale.days[date.getDay()];break; case 66: resultString += locale.months[date.getMonth()];break; case 67: resultString += padTill2(Math.floor(date.getFullYear() / 100),padding); break; case 68: resultString += _processFormat(locale.formats.D,date,locale,timestamp); break; case 70: resultString += _processFormat(locale.formats.F,date,locale,timestamp); break; case 72: resultString += padTill2(date.getHours(),padding);break; case 73: resultString += padTill2(hours12(date.getHours()),padding); break; case 76: resultString += padTill3(Math.floor(timestamp % 1000)); break; case 77: resultString += padTill2(date.getMinutes(),padding);break; case 80: resultString += date.getHours() < 12?locale.am:locale.pm; break; case 82: resultString += _processFormat(locale.formats.R,date,locale,timestamp); break; case 83: resultString += padTill2(date.getSeconds(),padding);break; case 84: resultString += _processFormat(locale.formats.T,date,locale,timestamp); break; case 85: resultString += padTill2(weekNumber(date,"sunday"),padding); break; case 87: resultString += padTill2(weekNumber(date,"monday"),padding); break; case 88: resultString += _processFormat(locale.formats.X,date,locale,timestamp); break; case 89:resultString += date.getFullYear();break; case 90: if(_useUtcBasedDate && _customTimezoneOffset === 0) resultString += "GMT"; else {var tzString=date.toString().match(/\(([\w\s]+)\)/); resultString += tzString && tzString[1] || ""} break; case 97: resultString += locale.shortDays[date.getDay()];break; case 98: resultString += locale.shortMonths[date.getMonth()];break; case 99: resultString += _processFormat(locale.formats.c,date,locale,timestamp); break; case 100: resultString += padTill2(date.getDate(),padding);break; case 101: resultString += padTill2(date.getDate(),padding == null?" ":padding); break; case 104: resultString += locale.shortMonths[date.getMonth()];break; case 106: var y=new Date(date.getFullYear(),0,1), day= Math.ceil ((date.getTime() - y.getTime()) / (1000 * 60 * 60 * 24)); resultString += padTill3(day); break; case 107: resultString += padTill2(date.getHours(),padding == null?" ":padding); break; case 108: resultString += padTill2 (hours12(date.getHours()),padding == null?" ":padding); break; case 109: resultString += padTill2(date.getMonth() + 1,padding);break; case 110:resultString += "\n";break; case 111: resultString += String(date.getDate()) + ordinal(date.getDate()); break; case 112: resultString += date.getHours() < 12?locale.AM:locale.PM; break; case 114: resultString += _processFormat(locale.formats.r,date,locale,timestamp); break; case 115:resultString += Math.floor(timestamp / 1000);break; case 116:resultString += "\t";break; case 117: var day=date.getDay();resultString += day === 0?7:day;break; case 118: resultString += _processFormat(locale.formats.v,date,locale,timestamp); break; case 119:resultString += date.getDay();break; case 120: resultString += _processFormat(locale.formats.x,date,locale,timestamp); break; case 121: resultString += ("" + date.getFullYear()).slice(2);break; case 122: if(_useUtcBasedDate && _customTimezoneOffset === 0) resultString += extendedTZ?"+00:00":"+0000"; else {var off; if(_customTimezoneOffset !== 0) off = _customTimezoneOffset / (60 * 1000); else off = - date.getTimezoneOffset(); var sign=off < 0?"-":"+", sep=extendedTZ?":":"", hours=Math.floor(Math.abs(off / 60)), mins=Math.abs(off % 60); resultString += sign + padTill2(hours) + sep + padTill2(mins)} break; default:resultString += format[i];break} padding = null; isInScope = false; continue} if(currentCharCode === 37){isInScope = true;continue} resultString += format[i]} return resultString} var strftime=_strftime; strftime.localize = function(locale) {return new Strftime (locale || _locale,_customTimezoneOffset,_useUtcBasedDate)}; strftime.timezone = function(timezone) {var customTimezoneOffset=_customTimezoneOffset, useUtcBasedDate=_useUtcBasedDate, timezoneType=typeof timezone; if(timezoneType === "number" || timezoneType === "string") {useUtcBasedDate = true; if(timezoneType === "string") {var sign=timezone[0] === "-"?- 1:1, hours=parseInt(timezone.slice(1,3),10), minutes=parseInt(timezone.slice(3,5),10); customTimezoneOffset = sign * (60 * hours + minutes) * 60 * 1000} else if(timezoneType === "number") customTimezoneOffset = timezone * 60 * 1000} return new Strftime(_locale,customTimezoneOffset,useUtcBasedDate)}; strftime.utc = function(){return new Strftime(_locale,_customTimezoneOffset,true)}; return strftime} function padTill2(numberToPad,paddingChar) {if(paddingChar === "" || numberToPad > 9)return numberToPad; if(paddingChar == null)paddingChar = "0"; return paddingChar + numberToPad} function padTill3(numberToPad) {if(numberToPad > 99)return numberToPad; if(numberToPad > 9)return "0" + numberToPad; return "00" + numberToPad} function hours12(hour) {if(hour === 0)return 12;else if(hour > 12)return hour - 12; return hour} function weekNumber(date,firstWeekday) {firstWeekday = firstWeekday || "sunday"; var weekday=date.getDay(); if(firstWeekday === "monday") if(weekday === 0)weekday = 6;else weekday--; var firstDayOfYearUtc=Date.UTC(date.getFullYear(),0,1), dateUtc=Date.UTC(date.getFullYear(),date.getMonth(),date.getDate()), yday=Math.floor((dateUtc - firstDayOfYearUtc) / 86400000), weekNum=(yday + 7 - weekday) / 7; return Math.floor(weekNum)} function ordinal(number) {var i=number % 10,ii=number % 100; if(ii >= 11 && ii <= 13 || i === 0 || i >= 4)return "th"; switch(i){case 1:return "st";case 2:return "nd";case 3:return "rd"}} function getTimestampToUtcOffsetFor(date) {return (date.getTimezoneOffset() || 0) * 60000}} ())} (globalThis)); (function(globalThis) {"use strict"; var joo_global_object=globalThis, jsoo_exports=typeof module === "object" && module.exports || globalThis; function Base_am_testing(x){return 0} function caml_mul(a,b){return Math.imul(a,b)} function caml_hash_mix_int(h,d) {d = caml_mul(d,0xcc9e2d51 | 0); d = d << 15 | d >>> 32 - 15; d = caml_mul(d,0x1b873593); h ^= d; h = h << 13 | h >>> 32 - 13; return (h + (h << 2) | 0) + (0xe6546b64 | 0) | 0} function caml_hash_mix_jsbytes(h,s) {var len=s.length,i,w; for(i = 0;i + 4 <= len;i += 4) {w = s.charCodeAt(i) | s.charCodeAt(i + 1) << 8 | s.charCodeAt(i + 2) << 16 | s.charCodeAt(i + 3) << 24; h = caml_hash_mix_int(h,w)} w = 0; switch(len & 3) {case 3:w = s.charCodeAt(i + 2) << 16; case 2:w |= s.charCodeAt(i + 1) << 8; case 1:w |= s.charCodeAt(i);h = caml_hash_mix_int(h,w) } h ^= len; return h} var log2_ok=Math.log2 && Math.log2(1.1235582092889474E+307) == 1020; function jsoo_floor_log2(x) {if(log2_ok)return Math.floor(Math.log2(x)); var i=0; if(x == 0)return - Infinity; if(x >= 1)while(x >= 2){x /= 2;i++}else while(x < 1){x *= 2;i--} return i} var caml_int64_offset=Math.pow(2,- 24); function caml_raise_constant(tag){throw tag} var caml_global_data=[0]; function caml_raise_zero_divide() {caml_raise_constant(caml_global_data.Division_by_zero)} function MlInt64(lo,mi,hi) {this.lo = lo & 0xffffff;this.mi = mi & 0xffffff;this.hi = hi & 0xffff} MlInt64.prototype.caml_custom = "_j"; MlInt64.prototype.copy = function(){return new MlInt64(this.lo,this.mi,this.hi)}; MlInt64.prototype.ucompare = function(x) {if(this.hi > x.hi)return 1; if(this.hi < x.hi)return - 1; if(this.mi > x.mi)return 1; if(this.mi < x.mi)return - 1; if(this.lo > x.lo)return 1; if(this.lo < x.lo)return - 1; return 0}; MlInt64.prototype.compare = function(x) {var hi=this.hi << 16,xhi=x.hi << 16; if(hi > xhi)return 1; if(hi < xhi)return - 1; if(this.mi > x.mi)return 1; if(this.mi < x.mi)return - 1; if(this.lo > x.lo)return 1; if(this.lo < x.lo)return - 1; return 0}; MlInt64.prototype.neg = function() {var lo=- this.lo,mi=- this.mi + (lo >> 24),hi=- this.hi + (mi >> 24); return new MlInt64(lo,mi,hi)}; MlInt64.prototype.add = function(x) {var lo=this.lo + x.lo, mi=this.mi + x.mi + (lo >> 24), hi=this.hi + x.hi + (mi >> 24); return new MlInt64(lo,mi,hi)}; MlInt64.prototype.sub = function(x) {var lo=this.lo - x.lo, mi=this.mi - x.mi + (lo >> 24), hi=this.hi - x.hi + (mi >> 24); return new MlInt64(lo,mi,hi)}; MlInt64.prototype.mul = function(x) {var lo=this.lo * x.lo, mi=(lo * caml_int64_offset | 0) + this.mi * x.lo + this.lo * x.mi, hi= (mi * caml_int64_offset | 0) + this.hi * x.lo + this.mi * x.mi + this.lo * x.hi; return new MlInt64(lo,mi,hi)}; MlInt64.prototype.isZero = function(){return (this.lo | this.mi | this.hi) == 0}; MlInt64.prototype.isNeg = function(){return this.hi << 16 < 0}; MlInt64.prototype.and = function(x) {return new MlInt64(this.lo & x.lo,this.mi & x.mi,this.hi & x.hi)}; MlInt64.prototype.or = function(x) {return new MlInt64(this.lo | x.lo,this.mi | x.mi,this.hi | x.hi)}; MlInt64.prototype.xor = function(x) {return new MlInt64(this.lo ^ x.lo,this.mi ^ x.mi,this.hi ^ x.hi)}; MlInt64.prototype.shift_left = function(s) {s = s & 63; if(s == 0)return this; if(s < 24) return new MlInt64 (this.lo << s, this.mi << s | this.lo >> 24 - s, this.hi << s | this.mi >> 24 - s); if(s < 48) return new MlInt64 (0,this.lo << s - 24,this.mi << s - 24 | this.lo >> 48 - s); return new MlInt64(0,0,this.lo << s - 48)}; MlInt64.prototype.shift_right_unsigned = function(s) {s = s & 63; if(s == 0)return this; if(s < 24) return new MlInt64 (this.lo >> s | this.mi << 24 - s, this.mi >> s | this.hi << 24 - s, this.hi >> s); if(s < 48) return new MlInt64 (this.mi >> s - 24 | this.hi << 48 - s,this.hi >> s - 24,0); return new MlInt64(this.hi >> s - 48,0,0)}; MlInt64.prototype.shift_right = function(s) {s = s & 63; if(s == 0)return this; var h=this.hi << 16 >> 16; if(s < 24) return new MlInt64 (this.lo >> s | this.mi << 24 - s, this.mi >> s | h << 24 - s, this.hi << 16 >> s >>> 16); var sign=this.hi << 16 >> 31; if(s < 48) return new MlInt64 (this.mi >> s - 24 | this.hi << 48 - s, this.hi << 16 >> s - 24 >> 16, sign & 0xffff); return new MlInt64(this.hi << 16 >> s - 32,sign,sign)}; MlInt64.prototype.lsl1 = function() {this.hi = this.hi << 1 | this.mi >> 23; this.mi = (this.mi << 1 | this.lo >> 23) & 0xffffff; this.lo = this.lo << 1 & 0xffffff}; MlInt64.prototype.lsr1 = function() {this.lo = (this.lo >>> 1 | this.mi << 23) & 0xffffff; this.mi = (this.mi >>> 1 | this.hi << 23) & 0xffffff; this.hi = this.hi >>> 1}; MlInt64.prototype.udivmod = function(x) {var offset=0, modulus=this.copy(), divisor=x.copy(), quotient=new MlInt64(0,0,0); while(modulus.ucompare(divisor) > 0){offset++;divisor.lsl1()} while(offset >= 0) {offset--; quotient.lsl1(); if(modulus.ucompare(divisor) >= 0) {quotient.lo++;modulus = modulus.sub(divisor)} divisor.lsr1()} return {quotient:quotient,modulus:modulus}}; MlInt64.prototype.div = function(y) {var x=this; if(y.isZero())caml_raise_zero_divide(); var sign=x.hi ^ y.hi; if(x.hi & 0x8000)x = x.neg(); if(y.hi & 0x8000)y = y.neg(); var q=x.udivmod(y).quotient; if(sign & 0x8000)q = q.neg(); return q}; MlInt64.prototype.mod = function(y) {var x=this; if(y.isZero())caml_raise_zero_divide(); var sign=x.hi; if(x.hi & 0x8000)x = x.neg(); if(y.hi & 0x8000)y = y.neg(); var r=x.udivmod(y).modulus; if(sign & 0x8000)r = r.neg(); return r}; MlInt64.prototype.toInt = function(){return this.lo | this.mi << 24}; MlInt64.prototype.toFloat = function() {return (this.hi << 16) * Math.pow(2,32) + this.mi * Math.pow(2,24) + this.lo}; MlInt64.prototype.toArray = function() {return [this.hi >> 8, this.hi & 0xff, this.mi >> 16, this.mi >> 8 & 0xff, this.mi & 0xff, this.lo >> 16, this.lo >> 8 & 0xff, this.lo & 0xff]}; MlInt64.prototype.lo32 = function(){return this.lo | (this.mi & 0xff) << 24}; MlInt64.prototype.hi32 = function(){return this.mi >>> 8 & 0xffff | this.hi << 16}; function caml_int64_create_lo_mi_hi(lo,mi,hi) {return new MlInt64(lo,mi,hi)} function caml_int64_bits_of_float(x) {if(! isFinite(x)) {if(isNaN(x))return caml_int64_create_lo_mi_hi(1,0,0x7ff0); return x > 0 ?caml_int64_create_lo_mi_hi(0,0,0x7ff0) :caml_int64_create_lo_mi_hi(0,0,0xfff0)} var sign=x == 0 && 1 / x == - Infinity?0x8000:x >= 0?0:0x8000; if(sign)x = - x; var exp=jsoo_floor_log2(x) + 1023; if(exp <= 0) {exp = 0;x /= Math.pow(2,- 1026)} else {x /= Math.pow(2,exp - 1027); if(x < 16){x *= 2;exp -= 1} if(exp == 0)x /= 2} var k=Math.pow(2,24),r3=x | 0; x = (x - r3) * k; var r2=x | 0; x = (x - r2) * k; var r1=x | 0; r3 = r3 & 0xf | sign | exp << 4; return caml_int64_create_lo_mi_hi(r1,r2,r3)} function caml_int64_lo32(v){return v.lo32()} function caml_int64_hi32(v){return v.hi32()} function caml_hash_mix_int64(h,v) {h = caml_hash_mix_int(h,caml_int64_lo32(v)); h = caml_hash_mix_int(h,caml_int64_hi32(v)); return h} function caml_hash_mix_float(h,v0) {return caml_hash_mix_int64(h,caml_int64_bits_of_float(v0))} function caml_str_repeat(n,s) {if(n == 0)return ""; if(s.repeat)return s.repeat(n); var r="",l=0; for(;;) {if(n & 1)r += s; n >>= 1; if(n == 0)return r; s += s; l++; if(l == 9)s.slice(0,1)}} function caml_subarray_to_jsbytes(a,i,len) {var f=String.fromCharCode; if(i == 0 && len <= 4096 && len == a.length)return f.apply(null,a); var s=""; for(;0 < len;i += 1024,len -= 1024) s += f.apply(null,a.slice(i,i + Math.min(len,1024))); return s} function caml_convert_string_to_bytes(s) {if(s.t == 2) s.c += caml_str_repeat(s.l - s.c.length,"\0"); else s.c = caml_subarray_to_jsbytes(s.c,0,s.c.length); s.t = 0} function caml_jsbytes_of_string(s) {s.t & 6 && caml_convert_string_to_bytes(s);return s.c} function caml_hash_mix_string(h,v) {return caml_hash_mix_jsbytes(h,caml_jsbytes_of_string(v))} function caml_hash_mix_bytes_arr(h,s) {var len=s.length,i,w; for(i = 0;i + 4 <= len;i += 4) {w = s[i] | s[i + 1] << 8 | s[i + 2] << 16 | s[i + 3] << 24; h = caml_hash_mix_int(h,w)} w = 0; switch(len & 3) {case 3:w = s[i + 2] << 16; case 2:w |= s[i + 1] << 8; case 1:w |= s[i];h = caml_hash_mix_int(h,w) } h ^= len; return h} function jsoo_is_ascii(s) {if(s.length < 24) {for(var i=0;i < s.length;i++)if(s.charCodeAt(i) > 127)return false; return true} else return ! /[^\x00-\x7f]/.test(s)} function caml_utf16_of_utf8(s) {for(var b="",t="",c,c1,c2,v,i=0,l=s.length;i < l;i++) {c1 = s.charCodeAt(i); if(c1 < 0x80) {for(var j=i + 1;j < l && (c1 = s.charCodeAt(j)) < 0x80;j++); if(j - i > 512) {t.substr(0,1);b += t;t = "";b += s.slice(i,j)} else t += s.slice(i,j); if(j == l)break; i = j} v = 1; if(++i < l && ((c2 = s.charCodeAt(i)) & - 64) == 128) {c = c2 + (c1 << 6); if(c1 < 0xe0) {v = c - 0x3080;if(v < 0x80)v = 1} else {v = 2; if(++i < l && ((c2 = s.charCodeAt(i)) & - 64) == 128) {c = c2 + (c << 6); if(c1 < 0xf0) {v = c - 0xe2080; if(v < 0x800 || v >= 0xd7ff && v < 0xe000)v = 2} else {v = 3; if (++i < l && ((c2 = s.charCodeAt(i)) & - 64) == 128 && c1 < 0xf5) {v = c2 - 0x3c82080 + (c << 6); if(v < 0x10000 || v > 0x10ffff)v = 3}}}}} if(v < 4) {i -= v;t += "\ufffd"} else if(v > 0xffff) t += String.fromCharCode(0xd7c0 + (v >> 10),0xdc00 + (v & 0x3FF)); else t += String.fromCharCode(v); if(t.length > 1024){t.substr(0,1);b += t;t = ""}} return b + t} function MlBytes(tag,contents,length) {this.t = tag;this.c = contents;this.l = length} MlBytes.prototype.toString = function() {switch(this.t) {case 9:return this.c; default:caml_convert_string_to_bytes(this);case 0: if(jsoo_is_ascii(this.c)){this.t = 9;return this.c}this.t = 8; case 8:return this.c }}; MlBytes.prototype.toUtf16 = function() {var r=this.toString(); if(this.t == 9)return r; return caml_utf16_of_utf8(r)}; MlBytes.prototype.slice = function() {var content=this.t == 4?this.c.slice():this.c; return new MlBytes(this.t,content,this.l)}; function caml_ml_bytes_content(s) {switch(s.t & 6) {default:caml_convert_string_to_bytes(s);case 0:return s.c; case 4:return s.c }} function caml_hash_mix_bytes(h,v) {var content=caml_ml_bytes_content(v); return typeof content === "string" ?caml_hash_mix_jsbytes(h,content) :caml_hash_mix_bytes_arr(h,content)} function caml_int32_bits_of_float(x) {var float32a=new (globalThis.Float32Array)(1); float32a[0] = x; var int32a=new (globalThis.Int32Array)(float32a.buffer); return int32a[0] | 0} function caml_int64_to_bytes(x){return x.toArray()} function caml_ba_serialize(writer,ba,sz) {writer.write(32,ba.dims.length); writer.write(32,ba.kind | ba.layout << 8); if(ba.caml_custom == "_bigarr02") for(var i=0;i < ba.dims.length;i++) if(ba.dims[i] < 0xffff) writer.write(16,ba.dims[i]); else {writer.write(16,0xffff); writer.write(32,0); writer.write(32,ba.dims[i])} else for(var i=0;i < ba.dims.length;i++)writer.write(32,ba.dims[i]); switch(ba.kind) {case 2: case 3: case 12: for(var i=0;i < ba.data.length;i++)writer.write(8,ba.data[i]);break; case 4: case 5: for(var i=0;i < ba.data.length;i++)writer.write(16,ba.data[i]);break; case 6: for(var i=0;i < ba.data.length;i++)writer.write(32,ba.data[i]);break; case 8: case 9: writer.write(8,0); for(var i=0;i < ba.data.length;i++)writer.write(32,ba.data[i]); break; case 7: for(var i=0;i < ba.data.length / 2;i++) {var b=caml_int64_to_bytes(ba.get(i)); for(var j=0;j < 8;j++)writer.write(8,b[j])} break; case 1: for(var i=0;i < ba.data.length;i++) {var b=caml_int64_to_bytes(caml_int64_bits_of_float(ba.get(i))); for(var j=0;j < 8;j++)writer.write(8,b[j])} break; case 0: for(var i=0;i < ba.data.length;i++) {var b=caml_int32_bits_of_float(ba.get(i));writer.write(32,b)} break; case 10: for(var i=0;i < ba.data.length / 2;i++) {var j=ba.get(i); writer.write(32,caml_int32_bits_of_float(j[1])); writer.write(32,caml_int32_bits_of_float(j[2]))} break; case 11: for(var i=0;i < ba.data.length / 2;i++) {var complex=ba.get(i), b=caml_int64_to_bytes(caml_int64_bits_of_float(complex[1])); for(var j=0;j < 8;j++)writer.write(8,b[j]); var b=caml_int64_to_bytes(caml_int64_bits_of_float(complex[2])); for(var j=0;j < 8;j++)writer.write(8,b[j])} break } sz[0] = (4 + ba.dims.length) * 4; sz[1] = (4 + ba.dims.length) * 8} function caml_raise_with_string(tag,msg){throw globalThis.Error(msg.c)} function caml_invalid_argument(msg) {caml_raise_with_string(caml_global_data.Invalid_argument,msg)} function caml_ba_get_size_per_element(kind) {switch(kind){case 7:case 10:case 11:return 2;default:return 1}} function caml_ba_create_buffer(kind,size) {var g=globalThis,view; switch(kind) {case 0:view = g.Float32Array;break; case 1:view = g.Float64Array;break; case 2:view = g.Int8Array;break; case 3:view = g.Uint8Array;break; case 4:view = g.Int16Array;break; case 5:view = g.Uint16Array;break; case 6:view = g.Int32Array;break; case 7:view = g.Int32Array;break; case 8:view = g.Int32Array;break; case 9:view = g.Int32Array;break; case 10:view = g.Float32Array;break; case 11:view = g.Float64Array;break; case 12:view = g.Uint8Array;break } if(! view)caml_invalid_argument("Bigarray.create: unsupported kind"); var data=new view(size * caml_ba_get_size_per_element(kind)); return data} function caml_int32_float_of_bits(x) {var int32a=new (globalThis.Int32Array)(1); int32a[0] = x; var float32a=new (globalThis.Float32Array)(int32a.buffer); return float32a[0]} function caml_int64_of_bytes(a) {return new MlInt64 (a[7] << 0 | a[6] << 8 | a[5] << 16, a[4] << 0 | a[3] << 8 | a[2] << 16, a[1] << 0 | a[0] << 8)} function caml_int64_float_of_bits(x) {var lo=x.lo,mi=x.mi,hi=x.hi,exp=(hi & 0x7fff) >> 4; if(exp == 2047) return (lo | mi | hi & 0xf) == 0?hi & 0x8000?- Infinity:Infinity:NaN; var k=Math.pow(2,- 24),res=(lo * k + mi) * k + (hi & 0xf); if(exp > 0) {res += 16;res *= Math.pow(2,exp - 1027)} else res *= Math.pow(2,- 1026); if(hi & 0x8000)res = - res; return res} function caml_ba_get_size(dims) {var n_dims=dims.length,size=1; for(var i=0;i < n_dims;i++) {if(dims[i] < 0) caml_invalid_argument("Bigarray.create: negative dimension"); size = size * dims[i]} return size} function caml_int64_create_lo_hi(lo,hi) {return new MlInt64 (lo & 0xffffff, lo >>> 24 & 0xff | (hi & 0xffff) << 8, hi >>> 16 & 0xffff)} function caml_array_bound_error() {caml_invalid_argument("index out of bounds")} var caml_ba_custom_name="_bigarr02"; function Ml_Bigarray(kind,layout,dims,buffer) {this.kind = kind; this.layout = layout; this.dims = dims; this.data = buffer} Ml_Bigarray.prototype.caml_custom = caml_ba_custom_name; Ml_Bigarray.prototype.offset = function(arg) {var ofs=0; if(typeof arg === "number")arg = [arg]; if(! (arg instanceof Array)) caml_invalid_argument("bigarray.js: invalid offset"); if(this.dims.length != arg.length) caml_invalid_argument("Bigarray.get/set: bad number of dimensions"); if(this.layout == 0) for(var i=0;i < this.dims.length;i++) {if(arg[i] < 0 || arg[i] >= this.dims[i])caml_array_bound_error(); ofs = ofs * this.dims[i] + arg[i]} else for(var i=this.dims.length - 1;i >= 0;i--) {if(arg[i] < 1 || arg[i] > this.dims[i])caml_array_bound_error(); ofs = ofs * this.dims[i] + (arg[i] - 1)} return ofs}; Ml_Bigarray.prototype.get = function(ofs) {switch(this.kind) {case 7: var l=this.data[ofs * 2 + 0],h=this.data[ofs * 2 + 1]; return caml_int64_create_lo_hi(l,h); case 10: case 11: var r=this.data[ofs * 2 + 0],i=this.data[ofs * 2 + 1]; return [254,r,i]; default:return this.data[ofs]}}; Ml_Bigarray.prototype.set = function(ofs,v) {switch(this.kind) {case 7: this.data[ofs * 2 + 0] = caml_int64_lo32(v); this.data[ofs * 2 + 1] = caml_int64_hi32(v); break; case 10: case 11: this.data[ofs * 2 + 0] = v[1];this.data[ofs * 2 + 1] = v[2];break; default:this.data[ofs] = v;break} return 0}; Ml_Bigarray.prototype.fill = function(v) {switch(this.kind) {case 7: var a=caml_int64_lo32(v),b=caml_int64_hi32(v); if(a == b) this.data.fill(a); else for(var i=0;i < this.data.length;i++)this.data[i] = i % 2 == 0?a:b; break; case 10: case 11: var im=v[1],re=v[2]; if(im == re) this.data.fill(im); else for(var i=0;i < this.data.length;i++) this.data[i] = i % 2 == 0?im:re; break; default:this.data.fill(v);break}}; Ml_Bigarray.prototype.compare = function(b,total) {if(this.layout != b.layout || this.kind != b.kind) {var k1=this.kind | this.layout << 8,k2=b.kind | b.layout << 8; return k2 - k1} if(this.dims.length != b.dims.length) return b.dims.length - this.dims.length; for(var i=0;i < this.dims.length;i++) if(this.dims[i] != b.dims[i])return this.dims[i] < b.dims[i]?- 1:1; switch(this.kind) {case 0: case 1: case 10: case 11: var x,y; for(var i=0;i < this.data.length;i++) {x = this.data[i]; y = b.data[i]; if(x < y)return - 1; if(x > y)return 1; if(x != y) {if(! total)return NaN;if(x == x)return 1;if(y == y)return - 1}} break; case 7: for(var i=0;i < this.data.length;i += 2) {if(this.data[i + 1] < b.data[i + 1])return - 1; if(this.data[i + 1] > b.data[i + 1])return 1; if(this.data[i] >>> 0 < b.data[i] >>> 0)return - 1; if(this.data[i] >>> 0 > b.data[i] >>> 0)return 1} break; case 2: case 3: case 4: case 5: case 6: case 8: case 9: case 12: for(var i=0;i < this.data.length;i++) {if(this.data[i] < b.data[i])return - 1; if(this.data[i] > b.data[i])return 1} break } return 0}; function Ml_Bigarray_c_1_1(kind,layout,dims,buffer) {this.kind = kind; this.layout = layout; this.dims = dims; this.data = buffer} Ml_Bigarray_c_1_1.prototype = new Ml_Bigarray(); Ml_Bigarray_c_1_1.prototype.offset = function(arg) {if(typeof arg !== "number") if(arg instanceof Array && arg.length == 1) arg = arg[0]; else caml_invalid_argument("Ml_Bigarray_c_1_1.offset"); if(arg < 0 || arg >= this.dims[0])caml_array_bound_error(); return arg}; Ml_Bigarray_c_1_1.prototype.get = function(ofs){return this.data[ofs]}; Ml_Bigarray_c_1_1.prototype.set = function(ofs,v){this.data[ofs] = v;return 0}; Ml_Bigarray_c_1_1.prototype.fill = function(v){this.data.fill(v);return 0}; function caml_ba_create_unsafe(kind,layout,dims,data) {var size_per_element=caml_ba_get_size_per_element(kind); if(caml_ba_get_size(dims) * size_per_element != data.length) caml_invalid_argument("length doesn't match dims"); if(layout == 0 && dims.length == 1 && size_per_element == 1) return new Ml_Bigarray_c_1_1(kind,layout,dims,data); return new Ml_Bigarray(kind,layout,dims,data)} function caml_bytes_of_jsbytes(s){return new MlBytes(0,s,s.length)} function caml_string_of_jsbytes(s){return caml_bytes_of_jsbytes(s)} function caml_failwith(msg) {if(! caml_global_data.Failure) caml_global_data.Failure = [248,caml_string_of_jsbytes("Failure"),- 3]; caml_raise_with_string(caml_global_data.Failure,msg)} function caml_ba_deserialize(reader,sz,name) {var num_dims=reader.read32s(); if(num_dims < 0 || num_dims > 16) caml_failwith("input_value: wrong number of bigarray dimensions"); var tag=reader.read32s(),kind=tag & 0xff,layout=tag >> 8 & 1,dims=[]; if(name == "_bigarr02") for(var i=0;i < num_dims;i++) {var size_dim=reader.read16u(); if(size_dim == 0xffff) {var size_dim_hi=reader.read32u(),size_dim_lo=reader.read32u(); if(size_dim_hi != 0) caml_failwith("input_value: bigarray dimension overflow in 32bit"); size_dim = size_dim_lo} dims.push(size_dim)} else for(var i=0;i < num_dims;i++)dims.push(reader.read32u()); var size=caml_ba_get_size(dims), data=caml_ba_create_buffer(kind,size), ba=caml_ba_create_unsafe(kind,layout,dims,data); switch(kind) {case 2:for(var i=0;i < size;i++)data[i] = reader.read8s();break; case 3: case 12:for(var i=0;i < size;i++)data[i] = reader.read8u();break; case 4:for(var i=0;i < size;i++)data[i] = reader.read16s();break; case 5:for(var i=0;i < size;i++)data[i] = reader.read16u();break; case 6:for(var i=0;i < size;i++)data[i] = reader.read32s();break; case 8: case 9: var sixty=reader.read8u(); if(sixty) caml_failwith ("input_value: cannot read bigarray with 64-bit OCaml ints"); for(var i=0;i < size;i++)data[i] = reader.read32s(); break; case 7: var t=new Array(8); for(var i=0;i < size;i++) {for(var j=0;j < 8;j++)t[j] = reader.read8u(); var int64=caml_int64_of_bytes(t); ba.set(i,int64)} break; case 1: var t=new Array(8); for(var i=0;i < size;i++) {for(var j=0;j < 8;j++)t[j] = reader.read8u(); var f=caml_int64_float_of_bits(caml_int64_of_bytes(t)); ba.set(i,f)} break; case 0: for(var i=0;i < size;i++) {var f=caml_int32_float_of_bits(reader.read32s());ba.set(i,f)} break; case 10: for(var i=0;i < size;i++) {var re=caml_int32_float_of_bits(reader.read32s()), im=caml_int32_float_of_bits(reader.read32s()); ba.set(i,[254,re,im])} break; case 11: var t=new Array(8); for(var i=0;i < size;i++) {for(var j=0;j < 8;j++)t[j] = reader.read8u(); var re=caml_int64_float_of_bits(caml_int64_of_bytes(t)); for(var j=0;j < 8;j++)t[j] = reader.read8u(); var im=caml_int64_float_of_bits(caml_int64_of_bytes(t)); ba.set(i,[254,re,im])} break } sz[0] = (4 + num_dims) * 4; return caml_ba_create_unsafe(kind,layout,dims,data)} function caml_ba_compare(a,b,total){return a.compare(b,total)} function caml_ba_hash(ba) {var num_elts=caml_ba_get_size(ba.dims),h=0; switch(ba.kind) {case 2: case 3: case 12: if(num_elts > 256)num_elts = 256; var w=0,i=0; for(i = 0;i + 4 <= ba.data.length;i += 4) {w = ba.data[i + 0] | ba.data[i + 1] << 8 | ba.data[i + 2] << 16 | ba.data[i + 3] << 24; h = caml_hash_mix_int(h,w)} w = 0; switch(num_elts & 3) {case 3:w = ba.data[i + 2] << 16; case 2:w |= ba.data[i + 1] << 8; case 1:w |= ba.data[i + 0];h = caml_hash_mix_int(h,w) } break; case 4: case 5: if(num_elts > 128)num_elts = 128; var w=0,i=0; for(i = 0;i + 2 <= ba.data.length;i += 2) {w = ba.data[i + 0] | ba.data[i + 1] << 16; h = caml_hash_mix_int(h,w)} if((num_elts & 1) != 0)h = caml_hash_mix_int(h,ba.data[i]); break; case 6: if(num_elts > 64)num_elts = 64; for(var i=0;i < num_elts;i++)h = caml_hash_mix_int(h,ba.data[i]); break; case 8: case 9: if(num_elts > 64)num_elts = 64; for(var i=0;i < num_elts;i++)h = caml_hash_mix_int(h,ba.data[i]); break; case 7: if(num_elts > 32)num_elts = 32; num_elts *= 2; for(var i=0;i < num_elts;i++)h = caml_hash_mix_int(h,ba.data[i]); break; case 10:num_elts *= 2; case 0: if(num_elts > 64)num_elts = 64; for(var i=0;i < num_elts;i++)h = caml_hash_mix_float(h,ba.data[i]); break; case 11:num_elts *= 2; case 1: if(num_elts > 32)num_elts = 32; for(var i=0;i < num_elts;i++)h = caml_hash_mix_float(h,ba.data[i]); break } return h} function caml_int32_unmarshal(reader,size) {size[0] = 4;return reader.read32s()} function caml_nativeint_unmarshal(reader,size) {switch(reader.read8u()) {case 1:size[0] = 4;return reader.read32s(); case 2:caml_failwith("input_value: native integer value too large"); default:caml_failwith("input_value: ill-formed native integer")}} function caml_int64_unmarshal(reader,size) {var t=new Array(8); for(var j=0;j < 8;j++)t[j] = reader.read8u(); size[0] = 8; return caml_int64_of_bytes(t)} function caml_int64_marshal(writer,v,sizes) {var b=caml_int64_to_bytes(v); for(var i=0;i < 8;i++)writer.write(8,b[i]); sizes[0] = 8; sizes[1] = 8} function caml_int64_compare(x,y,total){return x.compare(y)} function caml_int64_hash(v){return v.lo32() ^ v.hi32()} var caml_custom_ops= {"_j": {deserialize:caml_int64_unmarshal, serialize:caml_int64_marshal, fixed_length:8, compare:caml_int64_compare, hash:caml_int64_hash}, "_i":{deserialize:caml_int32_unmarshal,fixed_length:4}, "_n":{deserialize:caml_nativeint_unmarshal,fixed_length:4}, "_bigarray": {deserialize: function(reader,sz){return caml_ba_deserialize(reader,sz,"_bigarray")}, serialize:caml_ba_serialize, compare:caml_ba_compare, hash:caml_ba_hash}, "_bigarr02": {deserialize: function(reader,sz){return caml_ba_deserialize(reader,sz,"_bigarr02")}, serialize:caml_ba_serialize, compare:caml_ba_compare, hash:caml_ba_hash}}; function caml_hash_mix_final(h) {h ^= h >>> 16; h = caml_mul(h,0x85ebca6b | 0); h ^= h >>> 13; h = caml_mul(h,0xc2b2ae35 | 0); h ^= h >>> 16; return h} function caml_is_ml_bytes(s){return s instanceof MlBytes} function caml_is_ml_string(s){return caml_is_ml_bytes(s)} function caml_hash(count,limit,seed,obj) {var queue,rd,wr,sz,num,h,v,i,len; sz = limit; if(sz < 0 || sz > 256)sz = 256; num = count; h = seed; queue = [obj]; rd = 0; wr = 1; while(rd < wr && num > 0) {v = queue[rd++]; if(v && v.caml_custom) {if (caml_custom_ops[v.caml_custom] && caml_custom_ops[v.caml_custom].hash) {var hh=caml_custom_ops[v.caml_custom].hash(v); h = caml_hash_mix_int(h,hh); num--}} else if(v instanceof Array && v[0] === (v[0] | 0)) switch(v[0]) {case 248:h = caml_hash_mix_int(h,v[2]);num--;break; case 250:queue[--rd] = v[1];break; default: var tag=v.length - 1 << 10 | v[0]; h = caml