From 6dfa6cd43359456c482286d31f8d76fb257997f7 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Wed, 24 Jan 2024 13:32:17 +0100 Subject: [PATCH] fix define-values #290 --- README.md | 2 +- dist/lips.cjs | 34 +++++++++++++++++++--------------- dist/lips.esm.js | 34 +++++++++++++++++++--------------- dist/lips.esm.min.js | 4 ++-- dist/lips.js | 34 +++++++++++++++++++--------------- dist/lips.min.js | 8 ++++---- dist/std.min.scm | 2 +- dist/std.scm | 10 +++++----- dist/std.xcb | Bin 107191 -> 107190 bytes lib/R7RS.scm | 10 +++++----- src/lips.js | 23 +++++++++++++++-------- tests/std.scm | 6 ++++++ tests/syntax.scm | 9 +++++++++ 13 files changed, 105 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index 6a00757d3..852c1006a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.18.1-blue.svg)](https://www.npmjs.com/package/@jcubic/lips) ![1.0.0 Complete](https://img.shields.io/github/milestones/progress-percent/jcubic/lips/1?label=1.0.0%20Complete) [![Build and test](https://github.com/jcubic/lips/actions/workflows/build.yaml/badge.svg?branch=devel&event=push)](https://github.com/jcubic/lips/actions/workflows/build.yaml) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&3df4b3c6d80e6b8ee8ccabd287057791)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&6057f83183211c4b2368b942ae388f62)](https://coveralls.io/github/jcubic/lips?branch=devel) [![Join Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jcubic/lips) ![NPM Download Count](https://img.shields.io/npm/dm/@jcubic/lips) ![JSDelivr Download count](https://img.shields.io/jsdelivr/npm/hm/@jcubic/lips) diff --git a/dist/lips.cjs b/dist/lips.cjs index 9b6d253cb..4f3b4355e 100644 --- a/dist/lips.cjs +++ b/dist/lips.cjs @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Mon, 22 Jan 2024 12:07:50 +0000 + * build: Wed, 24 Jan 2024 12:31:18 +0000 */ 'use strict'; @@ -7546,7 +7546,7 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol) { // if we have (x ... a b) we need to remove two from the end var list_len = pattern.cdr.cdr.length(); if (!is_pair(code)) { - throw new Error('syntax-rules: no matching syntax'); + return false; } var code_len = code.length(); var list = code; @@ -7608,8 +7608,13 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol) { log({ IIIIII: bindings['...'].symbols[_name3].toString() }); - } else { + } else if (pattern.car instanceof LSymbol && pattern.cdr instanceof Pair && LSymbol.is(pattern.cdr.car, ellipsis_symbol)) { + // empty elipsis with rest (a b ... . d) #290 log('>> 8'); + bindings['...'].symbols[_name3] = null; + return traverse(pattern.cdr.cdr, code); + } else { + log('>> 9'); return false; //bindings['...'].symbols[name] = code; } @@ -7618,11 +7623,11 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol) { } else if (pattern.car instanceof Pair) { var names = _toConsumableArray(pattern_names); if (code === _nil) { - log('>> 9'); + log('>> 10'); bindings['...'].lists.push(_nil); return true; } - log('>> 10'); + log('>> 11'); var _node2 = code; while (_node2 instanceof Pair) { if (!traverse(pattern.car, _node2.car, names, true)) { @@ -7638,15 +7643,11 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol) { if (LSymbol.is(pattern, ellipsis_symbol)) { throw new Error('syntax: invalid usage of ellipsis'); } - log('>> 11'); + log('>> 12'); var _name4 = pattern.__name__; if (symbols.includes(_name4)) { return true; } - log({ - name: _name4, - ellipsis: ellipsis - }); if (ellipsis) { bindings['...'].symbols[_name4] = bindings['...'].symbols[_name4] || []; bindings['...'].symbols[_name4].push(code); @@ -7656,7 +7657,7 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol) { return true; } if (pattern instanceof Pair && code instanceof Pair) { - log('>> 12'); + log('>> 13'); log({ a: 12, code: code && code.toString(), @@ -7673,7 +7674,7 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol) { if (!traverse(pattern.car, code.car, pattern_names, ellipsis)) { return false; } - log('>> 12 | 1'); + log('>> 14'); var _name5 = pattern.cdr.valueOf(); if (!(_name5 in bindings.symbols)) { bindings.symbols[_name5] = _nil; @@ -12483,6 +12484,9 @@ var global_env = new Environment({ expansion: this, define: env }); + log({ + bindings: bindings + }); if (bindings) { /* c8 ignore next 5 */ if (is_debug()) { @@ -15216,10 +15220,10 @@ if (typeof window !== 'undefined') { // ------------------------------------------------------------------------- var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Mon, 22 Jan 2024 12:07:50 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Wed, 24 Jan 2024 12:31:18 +0000' == '{{' + 'DATE}}'; can be removed // but disabling Tree-shaking is adding lot of not used code so we use this // hack instead - var date = LString('Mon, 22 Jan 2024 12:07:50 +0000').valueOf(); + var date = LString('Wed, 24 Jan 2024 12:31:18 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); var _format = function _format(x) { return x.toString().padStart(2, '0'); @@ -15258,7 +15262,7 @@ read_only(QuotedPromise, '__class__', 'promise'); read_only(Parameter, '__class__', 'parameter'); // ------------------------------------------------------------------------- var version = 'DEV'; -var date = 'Mon, 22 Jan 2024 12:07:50 +0000'; +var date = 'Wed, 24 Jan 2024 12:31:18 +0000'; // unwrap async generator into Promise var parse = compose(uniterate_async, _parse); diff --git a/dist/lips.esm.js b/dist/lips.esm.js index 3f9b5a282..c6cfbeed5 100644 --- a/dist/lips.esm.js +++ b/dist/lips.esm.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Mon, 22 Jan 2024 12:07:50 +0000 + * build: Wed, 24 Jan 2024 12:31:18 +0000 */ function _classApplyDescriptorGet(receiver, descriptor) { @@ -9520,7 +9520,7 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol) { // if we have (x ... a b) we need to remove two from the end var list_len = pattern.cdr.cdr.length(); if (!is_pair(code)) { - throw new Error('syntax-rules: no matching syntax'); + return false; } var code_len = code.length(); var list = code; @@ -9582,8 +9582,13 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol) { log({ IIIIII: bindings['...'].symbols[_name3].toString() }); - } else { + } else if (pattern.car instanceof LSymbol && pattern.cdr instanceof Pair && LSymbol.is(pattern.cdr.car, ellipsis_symbol)) { + // empty elipsis with rest (a b ... . d) #290 log('>> 8'); + bindings['...'].symbols[_name3] = null; + return traverse(pattern.cdr.cdr, code); + } else { + log('>> 9'); return false; //bindings['...'].symbols[name] = code; } @@ -9592,11 +9597,11 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol) { } else if (pattern.car instanceof Pair) { var names = _toConsumableArray(pattern_names); if (code === _nil) { - log('>> 9'); + log('>> 10'); bindings['...'].lists.push(_nil); return true; } - log('>> 10'); + log('>> 11'); var _node2 = code; while (_node2 instanceof Pair) { if (!traverse(pattern.car, _node2.car, names, true)) { @@ -9612,15 +9617,11 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol) { if (LSymbol.is(pattern, ellipsis_symbol)) { throw new Error('syntax: invalid usage of ellipsis'); } - log('>> 11'); + log('>> 12'); var _name4 = pattern.__name__; if (symbols.includes(_name4)) { return true; } - log({ - name: _name4, - ellipsis: ellipsis - }); if (ellipsis) { bindings['...'].symbols[_name4] = bindings['...'].symbols[_name4] || []; bindings['...'].symbols[_name4].push(code); @@ -9630,7 +9631,7 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol) { return true; } if (pattern instanceof Pair && code instanceof Pair) { - log('>> 12'); + log('>> 13'); log({ a: 12, code: code && code.toString(), @@ -9647,7 +9648,7 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol) { if (!traverse(pattern.car, code.car, pattern_names, ellipsis)) { return false; } - log('>> 12 | 1'); + log('>> 14'); var _name5 = pattern.cdr.valueOf(); if (!(_name5 in bindings.symbols)) { bindings.symbols[_name5] = _nil; @@ -14457,6 +14458,9 @@ var global_env = new Environment({ expansion: this, define: env }); + log({ + bindings: bindings + }); if (bindings) { /* c8 ignore next 5 */ if (is_debug()) { @@ -17190,10 +17194,10 @@ if (typeof window !== 'undefined') { // ------------------------------------------------------------------------- var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Mon, 22 Jan 2024 12:07:50 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Wed, 24 Jan 2024 12:31:18 +0000' == '{{' + 'DATE}}'; can be removed // but disabling Tree-shaking is adding lot of not used code so we use this // hack instead - var date = LString('Mon, 22 Jan 2024 12:07:50 +0000').valueOf(); + var date = LString('Wed, 24 Jan 2024 12:31:18 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); var _format = function _format(x) { return x.toString().padStart(2, '0'); @@ -17232,7 +17236,7 @@ read_only(QuotedPromise, '__class__', 'promise'); read_only(Parameter, '__class__', 'parameter'); // ------------------------------------------------------------------------- var version = 'DEV'; -var date = 'Mon, 22 Jan 2024 12:07:50 +0000'; +var date = 'Wed, 24 Jan 2024 12:31:18 +0000'; // unwrap async generator into Promise var parse = compose(uniterate_async, _parse); diff --git a/dist/lips.esm.min.js b/dist/lips.esm.min.js index 5100067f4..d6d22428f 100644 --- a/dist/lips.esm.min.js +++ b/dist/lips.esm.min.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Mon, 22 Jan 2024 12:07:50 +0000 + * build: Wed, 24 Jan 2024 12:31:18 +0000 */ function _classApplyDescriptorGet(e,t){if(t.get){return t.get.call(e)}return t.value}function _classExtractFieldDescriptor(e,t,r){if(!t.has(e)){throw new TypeError("attempted to "+r+" private field on non-instance")}return t.get(e)}function _classPrivateFieldGet(e,t){var r=_classExtractFieldDescriptor(e,t,"get");return _classApplyDescriptorGet(e,r)}function _classApplyDescriptorSet(e,t,r){if(t.set){t.set.call(e,r)}else{if(!t.writable){throw new TypeError("attempted to set read only private field")}t.value=r}}function _classPrivateFieldSet(e,t,r){var n=_classExtractFieldDescriptor(e,t,"set");_classApplyDescriptorSet(e,n,r);return r}function _getPrototypeOf(e){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function e(t){return t.__proto__||Object.getPrototypeOf(t)};return _getPrototypeOf(e)}function _setPrototypeOf(e,t){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function e(t,r){t.__proto__=r;return t};return _setPrototypeOf(e,t)}function _isNativeFunction(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch(e){return typeof t==="function"}}function _isNativeReflectConstruct$1(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct$1=function e(){return!!t})()}function _construct(e,t,r){if(_isNativeReflectConstruct$1())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&_setPrototypeOf(i,r.prototype),i}function _wrapNativeSuper(e){var n=typeof Map==="function"?new Map:undefined;_wrapNativeSuper=function e(t){if(t===null||!_isNativeFunction(t))return t;if(typeof t!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof n!=="undefined"){if(n.has(t))return n.get(t);n.set(t,r)}function r(){return _construct(t,arguments,_getPrototypeOf(this).constructor)}r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}});return _setPrototypeOf(r,t)};return _wrapNativeSuper(e)}function _assertThisInitialized(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function _typeof$1(e){"@babel/helpers - typeof";return _typeof$1="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$1(e)}function _possibleConstructorReturn(e,t){if(t&&(_typeof$1(t)==="object"||typeof t==="function")){return t}else if(t!==void 0){throw new TypeError("Derived constructors may only return object or undefined")}return _assertThisInitialized(e)}function _inherits(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});Object.defineProperty(e,"prototype",{writable:false});if(t)_setPrototypeOf(e,t)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArray(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function _arrayLikeToArray$1(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r=0)continue;r[i]=e[i]}return r}function _objectWithoutProperties(e,t){if(e==null)return{};var r=_objectWithoutPropertiesLoose(e,t);var n,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;r[n]=e[n]}}return r}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,u=[],s=!0,c=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(u.push(n.value),u.length!==t);s=!0);}catch(e){c=!0,i=e}finally{try{if(!s&&null!=r["return"]&&(o=r["return"](),Object(o)!==o))return}finally{if(c)throw i}}return u}}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray$1(e,t)||_nonIterableRest()}function _OverloadYield(e,t){this.v=e,this.k=t}function _awaitAsyncGenerator(e){return new _OverloadYield(e,0)}function AsyncGenerator(o){var a,u;function s(r,e){try{var n=o[r](e),i=n.value,a=i instanceof _OverloadYield;Promise.resolve(a?i.v:i).then(function(e){if(a){var t="return"===r?"return":"next";if(!i.k||e.done)return s(t,e);e=o[t](e).value}c(n.done?"return":"normal",e)},function(e){s("throw",e)})}catch(e){c("throw",e)}}function c(e,t){switch(e){case"return":a.resolve({value:t,done:!0});break;case"throw":a.reject(t);break;default:a.resolve({value:t,done:!1})}(a=a.next)?s(a.key,a.arg):u=null}this._invoke=function(n,i){return new Promise(function(e,t){var r={key:n,arg:i,resolve:e,reject:t,next:null};u?u=u.next=r:(a=u=r,s(n,i))})},"function"!=typeof o["return"]&&(this["return"]=void 0)}AsyncGenerator.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},AsyncGenerator.prototype.next=function(e){return this._invoke("next",e)},AsyncGenerator.prototype["throw"]=function(e){return this._invoke("throw",e)},AsyncGenerator.prototype["return"]=function(e){return this._invoke("return",e)};function _wrapAsyncGenerator(e){return function(){return new AsyncGenerator(e.apply(this,arguments))}}function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}var regeneratorRuntime$1={exports:{}};var _typeof={exports:{}};(function(t){function r(e){"@babel/helpers - typeof";return t.exports=r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t.exports.__esModule=true,t.exports["default"]=t.exports,r(e)}t.exports=r,t.exports.__esModule=true,t.exports["default"]=t.exports})(_typeof);var _typeofExports=_typeof.exports;(function(B){var O=_typeofExports["default"];function I(){B.exports=I=function e(){return o},B.exports.__esModule=true,B.exports["default"]=B.exports;var c,o={},e=Object.prototype,l=e.hasOwnProperty,f=Object.defineProperty||function(e,t,r){e[t]=r.value},t="function"==typeof Symbol?Symbol:{},i=t.iterator||"@@iterator",r=t.asyncIterator||"@@asyncIterator",n=t.toStringTag||"@@toStringTag";function a(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(c){a=function e(t,r,n){return t[r]=n}}function u(e,t,r,n){var i=t&&t.prototype instanceof s?t:s,a=Object.create(i.prototype),o=new P(n||[]);return f(a,"_invoke",{value:S(e,r,o)}),a}function _(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}o.wrap=u;var p="suspendedStart",h="suspendedYield",d="executing",m="completed",y={};function s(){}function v(){}function g(){}var b={};a(b,i,function(){return this});var w=Object.getPrototypeOf,D=w&&w(w(C([])));D&&D!==e&&l.call(D,i)&&(b=D);var x=g.prototype=s.prototype=Object.create(b);function E(e){["next","throw","return"].forEach(function(t){a(e,t,function(e){return this._invoke(t,e)})})}function L(u,s){function c(e,t,r,n){var i=_(u[e],u,t);if("throw"!==i.type){var a=i.arg,o=a.value;return o&&"object"==O(o)&&l.call(o,"__await")?s.resolve(o.__await).then(function(e){c("next",e,r,n)},function(e){c("throw",e,r,n)}):s.resolve(o).then(function(e){a.value=e,r(a)},function(e){return c("throw",e,r,n)})}n(i.arg)}var i;f(this,"_invoke",{value:function e(r,n){function t(){return new s(function(e,t){c(r,n,e,t)})}return i=i?i.then(t,t):t()}})}function S(a,o,u){var s=p;return function(e,t){if(s===d)throw new Error("Generator is already running");if(s===m){if("throw"===e)throw t;return{value:c,done:!0}}for(u.method=e,u.arg=t;;){var r=u.delegate;if(r){var n=A(r,u);if(n){if(n===y)continue;return n}}if("next"===u.method)u.sent=u._sent=u.arg;else if("throw"===u.method){if(s===p)throw s=m,u.arg;u.dispatchException(u.arg)}else"return"===u.method&&u.abrupt("return",u.arg);s=d;var i=_(a,o,u);if("normal"===i.type){if(s=u.done?m:h,i.arg===y)continue;return{value:i.arg,done:u.done}}"throw"===i.type&&(s=m,u.method="throw",u.arg=i.arg)}}}function A(e,t){var r=t.method,n=e.iterator[r];if(n===c)return t.delegate=null,"throw"===r&&e.iterator["return"]&&(t.method="return",t.arg=c,A(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var i=_(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,y;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=c),t.delegate=null,y):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function F(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(F,this),this.reset(!0)}function C(t){if(t||""===t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return t("end");if(a.tryLoc<=this.prev){var u=l.call(a,"catchLoc"),s=l.call(a,"finallyLoc");if(u&&s){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&l.call(i,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),k(n),y}},catch:function e(t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var a=i.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function e(t,r,n){return this.delegate={iterator:C(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=c),y}},o}B.exports=I,B.exports.__esModule=true,B.exports["default"]=B.exports})(regeneratorRuntime$1);var regeneratorRuntimeExports=regeneratorRuntime$1.exports;var runtime=regeneratorRuntimeExports();var regenerator=runtime;try{regeneratorRuntime=runtime}catch(e){if(typeof globalThis==="object"){globalThis.regeneratorRuntime=runtime}else{Function("r","regeneratorRuntime = r")(runtime)}}var _regeneratorRuntime=getDefaultExportFromCjs(regenerator);var global$1=typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{};var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var inited=false;function init$1(){inited=true;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var t=0,r=e.length;t0){throw new Error("Invalid string. Length must be a multiple of 4")}a=e[u-2]==="="?2:e[u-1]==="="?1:0;o=new Arr(u*3/4-a);n=a>0?u-4:u;var s=0;for(t=0,r=0;t>16&255;o[s++]=i>>8&255;o[s++]=i&255}if(a===2){i=revLookup[e.charCodeAt(t)]<<2|revLookup[e.charCodeAt(t+1)]>>4;o[s++]=i&255}else if(a===1){i=revLookup[e.charCodeAt(t)]<<10|revLookup[e.charCodeAt(t+1)]<<4|revLookup[e.charCodeAt(t+2)]>>2;o[s++]=i>>8&255;o[s++]=i&255}return o}function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[e&63]}function encodeChunk(e,t,r){var n;var i=[];for(var a=t;as?s:u+o))}if(n===1){t=e[r-1];i+=lookup[t>>2];i+=lookup[t<<4&63];i+="=="}else if(n===2){t=(e[r-2]<<8)+e[r-1];i+=lookup[t>>10];i+=lookup[t>>4&63];i+=lookup[t<<2&63];i+="="}a.push(i);return a.join("")}function read$1(e,t,r,n,i){var a,o;var u=i*8-n-1;var s=(1<>1;var l=-7;var f=r?i-1:0;var _=r?-1:1;var p=e[t+f];f+=_;a=p&(1<<-l)-1;p>>=-l;l+=u;for(;l>0;a=a*256+e[t+f],f+=_,l-=8){}o=a&(1<<-l)-1;a>>=-l;l+=n;for(;l>0;o=o*256+e[t+f],f+=_,l-=8){}if(a===0){a=1-c}else if(a===s){return o?NaN:(p?-1:1)*Infinity}else{o=o+Math.pow(2,n);a=a-c}return(p?-1:1)*o*Math.pow(2,a-n)}function write(e,t,r,n,i,a){var o,u,s;var c=a*8-i-1;var l=(1<>1;var _=i===23?Math.pow(2,-24)-Math.pow(2,-77):0;var p=n?0:a-1;var h=n?1:-1;var d=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){u=isNaN(t)?1:0;o=l}else{o=Math.floor(Math.log(t)/Math.LN2);if(t*(s=Math.pow(2,-o))<1){o--;s*=2}if(o+f>=1){t+=_/s}else{t+=_*Math.pow(2,1-f)}if(t*s>=2){o++;s/=2}if(o+f>=l){u=0;o=l}else if(o+f>=1){u=(t*s-1)*Math.pow(2,i);o=o+f}else{u=t*Math.pow(2,f-1)*Math.pow(2,i);o=0}}for(;i>=8;e[r+p]=u&255,p+=h,u/=256,i-=8){}o=o<0;e[r+p]=o&255,p+=h,o/=256,c-=8){}e[r+p-h]|=d*128}var toString$1={}.toString;var isArray=Array.isArray||function(e){return toString$1.call(e)=="[object Array]"}; /*! @@ -48,4 +48,4 @@ function _classApplyDescriptorGet(e,t){if(t.get){return t.get.call(e)}return t.v * Released under BSD-3-Clause License * * build: Wed, 27 Oct 2021 10:43:10 GMT - */Object.defineProperty(lzjbPack,"__esModule",{value:true});const NBBY=8,MATCH_BITS=6,MATCH_MIN=3,MATCH_MAX=(1<r-MATCH_MAX){t[i++]=e[n++];continue}l=(e[n]+13^e[n+1]-13^e[n+2])&LEMPEL_SIZE-1;c=n-f[l]&OFFSET_MASK;f[l]=n;a=n-c;if(a>=0&&a!=n&&e[n]==e[a]&&e[n+1]==e[a+1]&&e[n+2]==e[a+2]){t[o]|=u;for(s=MATCH_MIN;s>NBBY;t[i++]=c;n+=s}else{t[i++]=e[n++]}}console.assert(e.length>=n);return i}function decompress(e,t,r){t=t|0;var n=0,i=0,a=0,o=0,u=1<<(NBBY-1|0),s=0,c=0;while(n>(NBBY-MATCH_BITS|0))+MATCH_MIN|0;c=(e[n]<4){r[i]=r[a];i=i+1|0;a=a+1|0;r[i]=r[a];i=i+1|0;a=a+1|0;r[i]=r[a];i=i+1|0;a=a+1|0;r[i]=r[a];i=i+1|0;a=a+1|0;s=s-4|0}while(s>0){r[i]=r[a];i=i+1|0;a=a+1|0;s=s-1|0}}}else{r[i]=e[n];i=i+1|0;n=n+1|0}}return i}function encode_magic$1(){const e=new TextEncoder("utf-8");return e.encode(MAGIC_STRING)}const MAGIC_STRING="@lzjb";const MAGIC=encode_magic$1();function merge_uint8_array$1(...e){if(e.length>1){const r=e.reduce((e,t)=>e+t.length,0);const n=new Uint8Array(r);let t=0;e.forEach(e=>{n.set(e,t);t+=e.length});return n}else if(e.length){return e[0]}}function number_to_bytes(t){const e=Math.ceil(Math.log2(t)/8);const r=new Uint8Array(e);for(let e=0;e=0;e--){r=r*256+t[e]}return r}function pack(e,{magic:t=true}={}){const r=new Uint8Array(Math.max(e.length*1.5|0,16*1024));const n=compress(e,r);const i=number_to_bytes(e.length);const a=[Uint8Array.of(i.length),i,r.slice(0,n)];if(t){a.unshift(MAGIC)}return merge_uint8_array$1(...a)}function unpack(t,{magic:e=true}={}){if(e){const e=new TextDecoder("utf-8");const s=e.decode(t.slice(0,MAGIC.length));if(s!==MAGIC_STRING){throw new Error("Invalid magic value")}}const r=e?MAGIC.length:0;const n=t[r];const i=r+1;const a=r+n+1;const o=bytes_to_number(t.slice(i,a));t=t.slice(a);const u=new Uint8Array(o);decompress(t,t.length,u);return u}var pack_1=lzjbPack.pack=pack;var unpack_1=lzjbPack.unpack=unpack;function unfetch(s,c){return c=c||{},new Promise(function(e,t){var r=new XMLHttpRequest,n=[],i=[],a={},o=function(){return{ok:2==(r.status/100|0),statusText:r.statusText,status:r.status,url:r.responseURL,text:function(){return Promise.resolve(r.responseText)},json:function(){return Promise.resolve(r.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([r.response]))},clone:o,headers:{keys:function(){return n},entries:function(){return i},get:function(e){return a[e.toLowerCase()]},has:function(e){return e.toLowerCase()in a}}}};for(var u in r.open(c.method||"get",s,!0),r.onload=function(){r.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,t,r){n.push(t=t.toLowerCase()),i.push([t,r]),a[t]=a[t]?a[t]+","+r:r}),e(o())},r.onerror=t,r.withCredentials="include"==c.credentials,c.headers)r.setRequestHeader(u,c.headers[u]);r.send(c.body||null)})}var _excluded=["token"],_excluded2=["env"],_excluded3=["stderr","stdin","stdout","command_line"],_excluded4=["use_dynamic"],_excluded5=["use_dynamic"],_excluded6=["env","dynamic_env","use_dynamic","error"];function _classPrivateFieldInitSpec(e,t,r){_checkPrivateRedeclaration(e,t);t.set(e,r)}function _checkPrivateRedeclaration(e,t){if(t.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function _callSuper(e,t,r){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct()?Reflect.construct(t,r||[],_getPrototypeOf(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function e(){return!!t})()}function _createForOfIteratorHelper(t,e){var r=typeof Symbol!=="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=_unsupportedIterableToArray(t))||e&&t&&typeof t.length==="number"){if(r)t=r;var n=0;var i=function e(){};return{s:i,n:function e(){if(n>=t.length)return{done:true};return{done:false,value:t[n++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a=true,o=false,u;return{s:function e(){r=r.call(t)},n:function e(){var t=r.next();a=t.done;return t},e:function e(t){o=true;u=t},f:function e(){try{if(!a&&r["return"]!=null)r["return"]()}finally{if(o)throw u}}}}function _unsupportedIterableToArray(e,t){if(!e)return;if(typeof e==="string")return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor)r=e.constructor.name;if(r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _arrayLikeToArray(e,t)}function _arrayLikeToArray(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r1&&arguments[1]!==undefined?arguments[1]:null;var n=arguments[1]===true;function t(e){if(!is_debug()){return}var t=global_env.get("repr")(e);if(r===null||r instanceof RegExp&&r.test(t)){console.log(global_env.get("type")(e)+": "+t)}if(n){console.log(e)}}if(is_promise(e)){e.then(t)}else{t(e)}return e}function is_debug(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var t=user_env&&user_env.get("DEBUG",{throwError:false});if(e===null){return t===true}return(t===null||t===void 0?void 0:t.valueOf())===e.valueOf()}function num_mnemicic_re(e){return e?"(?:#".concat(e,"(?:#[ie])?|#[ie]#").concat(e,")"):"(?:#[ie])?"}function gen_rational_re(e,t){return"".concat(num_mnemicic_re(e),"[+-]?").concat(t,"+/").concat(t,"+")}function gen_complex_re(e,t){return"".concat(num_mnemicic_re(e),"(?:[+-]?(?:").concat(t,"+/").concat(t,"+|nan.0|inf.0|").concat(t,"+))?(?:[+-]i|[+-]?(?:").concat(t,"+/").concat(t,"+|").concat(t,"+|nan.0|inf.0)i)(?=[()[\\]\\s]|$)")}function gen_integer_re(e,t){return"".concat(num_mnemicic_re(e),"[+-]?").concat(t,"+")}var re_re=/^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/;var float_stre="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)";var complex_float_stre="(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|nan.0|inf.0|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+|nan.0|inf.0))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,t){var r=e==="x"?"(?!\\+|".concat(t,")"):"(?!\\.|".concat(t,")");var n="";if(e===""){n="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(t,"+/").concat(t,"+(?!").concat(t,")|[+-]?").concat(t,"+)").concat(r,")?)(").concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(t,"+/").concat(t,"+|[+-]?").concat(t,"+|[+-])i$"),"i")}var complex_list_re=function(){var a={};[[10,"","[0-9]"],[16,"x","[0-9a-fA-F]"],[8,"o","[0-7]"],[2,"b","[01]"]].forEach(function(e){var t=_slicedToArray(e,3),r=t[0],n=t[1],i=t[2];a[r]=make_complex_match_re(n,i)});return a}();var characters={alarm:"",backspace:"\b",delete:"",escape:"",newline:"\n",null:"\0",return:"\r",space:" ",tab:"\t",dle:"",soh:"",dc1:"",stx:"",dc2:"",etx:"",dc3:"",eot:"",dc4:"",enq:"",nak:"",ack:"",syn:"",bel:"",etb:"",bs:"\b",can:"",ht:"\t",em:"",lf:"\n",sub:"",vt:"\v",esc:"",ff:"\f",fs:"",cr:"\r",gs:"",so:"",rs:"",si:"",us:"",del:""};function ucs2decode(e){var t=[];var r=0;var n=e.length;while(r=55296&&i<=56319&&r1&&arguments[1]!==undefined?arguments[1]:10;var r=num_pre_parse(e);var n=r.number.split("/");var i=LRational({num:LNumber([n[0],r.radix||t]),denom:LNumber([n[1],r.radix||t])});if(r.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;var r=num_pre_parse(e);if(r.inexact){return LFloat(parseInt(r.number,r.radix||t))}return LNumber([r.number,r.radix||t])}function parse_character(e){var t=e.match(/#\\x([0-9a-f]+)$/i);var r;if(t){var n=parseInt(t[1],16);r=String.fromCodePoint(n)}else{t=e.match(/#\\([\s\S]+)$/);if(t){r=t[1]}}if(r){return LCharacter(r)}throw new Error("Parse: invalid character")}function parse_complex(e){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;function t(e){var t;if(e==="+"){t=LNumber(1)}else if(e==="-"){t=LNumber(-1)}else if(e.match(int_bare_re)){t=LNumber([e,i])}else if(e.match(rational_bare_re)){var r=e.split("/");t=LRational({num:LNumber([r[0],i]),denom:LNumber([r[1],i])})}else if(e.match(float_re)){var n=parse_float(e);if(a.exact){return n.toRational()}return n}else if(e.match(/nan.0$/)){return LNumber(NaN)}else if(e.match(/inf.0$/)){if(e[0]==="-"){return LNumber(Number.NEGATIVE_INFINITY)}return LNumber(Number.POSITIVE_INFINITY)}else{throw new Error("Internal Parser Error")}if(a.inexact){return LFloat(t.valueOf())}return t}var a=num_pre_parse(e);i=a.radix||i;var r;var n=a.number.match(complex_bare_match_re);if(i!==10&&n){r=n}else{r=a.number.match(complex_list_re[i])}var o,u;u=t(r[2]);if(r[1]){o=t(r[1])}else{o=LNumber(0)}if(u.cmp(0)===0&&u.__type__==="bigint"){return o}return LComplex({im:u,re:o})}function is_int(e){return parseInt(e.toString(),10)===e}function parse_big_int(e){var t=e.match(/^(([-+]?[0-9]*)(?:\.([0-9]+))?)e([-+]?[0-9]+)/i);if(t){var r=parseInt(t[4],10);var n;var i=t[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=t[3]&&t[3].length;if(i0){return LNumber(a).mul(u)}}}r=LFloat(r);if(t.exact){return r.toRational()}return r}function parse_string(e){e=e.replace(/\\x([0-9a-f]+);/gi,function(e,t){return"\\u"+t.padStart(4,"0")}).replace(/\n/g,"\\n");var t=e.match(/(\\*)(\\x[0-9A-F])/i);if(t&&t[1].length%2===0){throw new Error("Invalid string literal, unclosed ".concat(t[2]))}try{return LString(JSON.parse(e))}catch(e){var r=e.message.replace(/in JSON /,"").replace(/.*Error: /,"");throw new Error("Invalid string literal: ".concat(r))}}function parse_symbol(e){if(e.match(/^\|.*\|$/)){e=e.replace(/(^\|)|(\|$)/g,"");var r={t:"\t",r:"\r",n:"\n"};e=e.replace(/\\(x[^;]+);/g,function(e,t){return String.fromCharCode(parseInt("0"+t,16))}).replace(/\\(.)/g,function(e,t){return r[t]||t})}return new LSymbol(e)}function parse_argument(e){if(constants.hasOwnProperty(e)){return constants[e]}if(e.match(/^"[\s\S]*"$/)){return parse_string(e)}else if(e[0]==="#"){var t=e.match(re_re);if(t){return new RegExp(t[1],t[2])}else if(e.match(char_re)){return parse_character(e)}var r=e.match(/#\\(.+)/);if(r&&ucs2decode(r[1]).length===1){return parse_character(e)}}if(e.match(/[0-9a-f]|[+-]i/i)){if(e.match(int_re)){return parse_integer(e)}else if(e.match(float_re)){return parse_float(e)}else if(e.match(rational_re)){return parse_rational(e)}else if(e.match(complex_re)){return parse_complex(e)}}if(e.match(/^#[iexobd]/)){throw new Error("Invalid numeric constant: "+e)}return parse_symbol(e)}function is_atom_string(e){return!(["(",")","[","]"].includes(e)||specials.names().includes(e))}function is_symbol_string(e){return is_atom_string(e)&&!(e.match(re_re)||e.match(/^"[\s\S]*"$/)||e.match(int_re)||e.match(float_re)||e.match(complex_re)||e.match(rational_re)||e.match(char_re)||["#t","#f","nil","true","false"].includes(e))}var string_re=/"(?:\\[\S\s]|[^"])*"?/g;function escape_regex(e){if(typeof e==="string"){var t=/([-\\^$[\]()+{}?*.|])/g;return e.replace(t,"\\$1")}return e}function Stack(){this.data=[]}Stack.prototype.push=function(e){this.data.push(e)};Stack.prototype.top=function(){return this.data[this.data.length-1]};Stack.prototype.pop=function(){return this.data.pop()};Stack.prototype.is_empty=function(){return!this.data.length};function tokens(e){if(e instanceof LString){e=e.valueOf()}var t=new Lexer(e,{whitespace:true});var r=[];while(true){var n=t.peek(true);if(n===eof){break}r.push(n);t.skip()}return r}function multiline_formatter(e){var t=e.token,r=_objectWithoutProperties(e,_excluded);if(t.match(/^"[\s\S]*"$/)&&t.match(/\n/)){var n=new RegExp("^ {1,"+(e.col+1)+"}","mg");t=t.replace(n,"")}return _objectSpread({token:t},r)}function Thunk(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};this.fn=e;this.cont=t}Thunk.prototype.toString=function(){return"#"};function trampoline(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(t){return tokens(e)}else{var r=tokens(e).map(function(e){if(e.token==="#\\ "||e.token=="#\\\n"){return e.token}return e.token.trim()}).filter(function(e){return e&&!e.match(/^;/)&&!e.match(/^#\|[\s\S]*\|#$/)});return strip_s_comments(r)}}function strip_s_comments(e){var t=0;var r=null;var n=[];for(var i=0;i0&&arguments[0]!==undefined?arguments[0]:null;if(e instanceof LSymbol){if(e.is_gensym()){return e}e=e.valueOf()}if(is_gensym(e)){return LSymbol(e)}if(e!==null){return r(e,Symbol("#:".concat(e)))}t++;return r(t,Symbol("#:g".concat(t)))}}();function QuotedPromise(e){var r=this;var n={pending:true,rejected:false,fulfilled:false,reason:undefined,type:undefined};e=e.then(function(e){n.type=type(e);n.fulfilled=true;n.pending=false;return e});read_only(this,"_promise",e,{hidden:true});if(is_function(e["catch"])){e=e["catch"](function(e){n.rejected=true;n.pending=false;n.reason=e})}Object.keys(n).forEach(function(t){Object.defineProperty(r,"__".concat(t,"__"),{enumerable:true,get:function e(){return n[t]}})});read_only(this,"__promise__",e);this.then=false}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.valueOf().then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.valueOf()["catch"](e))};QuotedPromise.prototype.valueOf=function(){if(!this._promise){throw new Error("QuotedPromise: invalid promise created")}return this._promise};QuotedPromise.prototype.toString=function(){if(this.__pending__){return QuotedPromise.pending_str}if(this.__rejected__){return QuotedPromise.rejected_str}return"#")};QuotedPromise.pending_str="#";QuotedPromise.rejected_str="#";function promise_all(e){if(Array.isArray(e)){return Promise.all(escape_quoted_promises(e)).then(unescape_quoted_promises)}return e}function escape_quoted_promises(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof QuotedPromise){t[r]=new Value(n)}else{t[r]=n}}return t}function unescape_quoted_promises(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof Value){t[r]=n.valueOf()}else{t[r]=n}}return t}var specials={LITERAL:Symbol["for"]("literal"),SPLICE:Symbol["for"]("splice"),SYMBOL:Symbol["for"]("symbol"),names:function e(){return Object.keys(this.__list__)},type:function e(t){try{return this.get(t).type}catch(e){console.log({name:t});console.log(e);return null}},get:function e(t){return this.__list__[t]},off:function e(t){var r=this;var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(Array.isArray(t)){t.forEach(function(e){return r.off(e,n)})}else if(n===null){delete this.__events__[t]}else{this.__events__=this.__events__.filter(function(e){return e!==n})}},on:function e(t,r){var n=this;if(Array.isArray(t)){t.forEach(function(e){return n.on(e,r)})}else if(!this.__events__[t]){this.__events__[t]=[r]}else{this.__events__[t].push(r)}},trigger:function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i",new LSymbol("quote-promise"),specials.LITERAL]];var builtins=defined_specials.map(function(e){return e[0]});Object.freeze(builtins);Object.defineProperty(specials,"__builtins__",{writable:false,value:builtins});defined_specials.forEach(function(e){var t=_slicedToArray(e,3),r=t[0],n=t[1],i=t[2];specials.append(r,n,i)});var Lexer=function(){function p(e){var t=this;var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},n=r.whitespace,i=n===void 0?false:n;_classCallCheck(this,p);read_only(this,"__input__",e.replace(/\r/g,""));var a={};["_i","_whitespace","_col","_newline","_line","_state","_next","_token","_prev_char"].forEach(function(r){Object.defineProperty(t,r,{configurable:false,enumerable:false,get:function e(){return a[r]},set:function e(t){a[r]=t}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}_createClass(p,[{key:"get",value:function e(t){return this.__internal[t]}},{key:"set",value:function e(t,r){this.__internal[t]=r}},{key:"token",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(t){var r=this._line;if(this._whitespace&&this._token==="\n"){--r}return{token:this._token,col:this._col,offset:this._i,line:r}}return this._token}},{key:"peek",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(this._i>=this.__input__.length){return eof}if(this._token){return this.token(t)}var r=this.next_token();if(r){this._token=this.__input__.substring(this._i,this._next);return this.token(t)}return eof}},{key:"skip",value:function e(){if(this._next!==null){this._token=null;this._i=this._next}}},{key:"read_line",value:function e(){var t=this.__input__.length;if(this._i>=t){return eof}for(var r=this._i;r=r){return eof}if(t+this._i>=r){return this.read_rest()}var n=this._i+t;var i=this.__input__.substring(this._i,n);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=n;return i}},{key:"peek_char",value:function e(){if(this._i>=this.__input__.length){return eof}return LCharacter(this.__input__[this._i])}},{key:"read_char",value:function e(){var t=this.peek_char();this.skip_char();return t}},{key:"skip_char",value:function e(){if(this._i1&&arguments[1]!==undefined?arguments[1]:{},n=r.prev_char,i=r["char"],a=r.next_char;var o=_slicedToArray(t,4),u=o[0],s=o[1],c=o[2],l=o[3];if(t.length!==5){throw new Error("Lexer: Invalid rule of length ".concat(t.length))}if(!i.match(u)){return false}if(!match_or_null(s,n)){return false}if(!match_or_null(c,a)){return false}if(l!==this._state){return false}return true}},{key:"next_token",value:function e(){if(this._i>=this.__input__.length){return false}var t=true;e:for(var r=this._i,n=this.__input__.length;r2&&arguments[2]!==undefined?arguments[2]:null;var i=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;if(t.length===0){throw new Error("Lexer: invalid literal rule")}if(t.length===1){return[[t,n,i,null,null]]}var a=[];for(var o=0,u=t.length;o1&&arguments[1]!==undefined?arguments[1]:{},r=t.env,n=t.meta,i=n===void 0?false:n,a=t.formatter,o=a===void 0?multiline_formatter:a;_classCallCheck(this,u);if(e instanceof LString){e=e.toString()}read_only(this,"_formatter",o,{hidden:true});read_only(this,"__lexer__",new Lexer(e));read_only(this,"__env__",r);read_only(this,"_meta",i,{hidden:true});read_only(this,"_refs",[],{hidden:true});read_only(this,"_state",{parentheses:0},{hidden:true})}_createClass(u,[{key:"resolve",value:function e(t){return this.__env__&&this.__env__.get(t,{throwError:false})}},{key:"peek",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=this.__lexer__.peek(true);if(!(r===eof)){t.next=4;break}return t.abrupt("return",eof);case 4:if(!this.is_comment(r.token)){t.next=7;break}this.skip();return t.abrupt("continue",0);case 7:if(!(r.token==="#;")){t.next=14;break}this.skip();if(!(this.__lexer__.peek()===eof)){t.next=11;break}throw new Error("Lexer: syntax error eof found after comment");case 11:t.next=13;return this._read_object();case 13:return t.abrupt("continue",0);case 14:return t.abrupt("break",17);case 17:r=this._formatter(r);if(!this._meta){t.next=20;break}return t.abrupt("return",r);case 20:return t.abrupt("return",r.token);case 21:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"reset",value:function e(){this._refs.length=0}},{key:"skip",value:function e(){this.__lexer__.skip()}},{key:"read",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return this.peek();case 2:r=t.sent;this.skip();return t.abrupt("return",r);case 5:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"match_datum_label",value:function e(t){var r=t.match(/^#([0-9]+)=$/);return r&&r[1]}},{key:"match_datum_ref",value:function e(t){var r=t.match(/^#([0-9]+)#$/);return r&&r[1]}},{key:"is_open",value:function e(t){var r=["(","["].includes(t);if(r){this._state.parentheses++}return r}},{key:"is_close",value:function e(t){var r=[")","]"].includes(t);if(r){this._state.parentheses--}return r}},{key:"read_list",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r,n,i,a,o;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=_nil,n=r;case 1:t.next=4;return this.peek();case 4:a=t.sent;if(!(a===eof)){t.next=7;break}return t.abrupt("break",32);case 7:if(!this.is_close(a)){t.next=10;break}this.skip();return t.abrupt("break",32);case 10:if(!(a==="."&&r!==_nil)){t.next=18;break}this.skip();t.next=14;return this._read_object();case 14:n.cdr=t.sent;i=true;t.next=30;break;case 18:if(!i){t.next=22;break}throw new Error("Parser: syntax error more than one element after dot");case 22:t.t0=Pair;t.next=25;return this._read_object();case 25:t.t1=t.sent;t.t2=_nil;o=new t.t0(t.t1,t.t2);if(r===_nil){r=o}else{n.cdr=o}n=o;case 30:t.next=1;break;case 32:return t.abrupt("return",r);case 33:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"read_value",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return this.read();case 2:r=t.sent;if(!(r===eof)){t.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return t.abrupt("return",parse_argument(r));case 6:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"is_comment",value:function e(t){return t.match(/^;/)||t.match(/^#\|/)&&t.match(/\|#$/)}},{key:"evaluate",value:function e(t){return _evaluate(t,{env:this.__env__,error:function e(t){throw t}})}},{key:"read_object",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:this.reset();t.next=3;return this._read_object();case 3:r=t.sent;if(r instanceof DatumReference){r=r.valueOf()}if(!this._refs.length){t.next=7;break}return t.abrupt("return",this._resolve_object(r));case 7:return t.abrupt("return",r);case 8:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"balanced",value:function e(){return this._state.parentheses===0}},{key:"ballancing_error",value:function e(t,r){var n=this._state.parentheses;var i;if(n<0){i=new Error("Parser: unexpected parenthesis");i.__code__=[r.toString()+")"]}else{i=new Error("Parser: expected parenthesis but eof found");var a=new RegExp("\\){".concat(n,"}$"));i.__code__=[t.toString().replace(a,"")]}throw i}},{key:"_resolve_object",value:function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function e(r){var n=this;var i;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!Array.isArray(r)){t.next=2;break}return t.abrupt("return",r.map(function(e){return n._resolve_object(e)}));case 2:if(!is_plain_object(r)){t.next=6;break}i={};Object.keys(r).forEach(function(e){i[e]=n._resolve_object(r[e])});return t.abrupt("return",i);case 6:if(!(r instanceof Pair)){t.next=8;break}return t.abrupt("return",this._resolve_pair(r));case 8:return t.abrupt("return",r);case 9:case"end":return t.stop()}},e,this)}));function e(e){return t.apply(this,arguments)}return e}()},{key:"_resolve_pair",value:function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function e(r){return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!(r instanceof Pair)){t.next=15;break}if(!(r.car instanceof DatumReference)){t.next=7;break}t.next=4;return r.car.valueOf();case 4:r.car=t.sent;t.next=8;break;case 7:this._resolve_pair(r.car);case 8:if(!(r.cdr instanceof DatumReference)){t.next=14;break}t.next=11;return r.cdr.valueOf();case 11:r.cdr=t.sent;t.next=15;break;case 14:this._resolve_pair(r.cdr);case 15:return t.abrupt("return",r);case 16:case"end":return t.stop()}},e,this)}));function e(e){return t.apply(this,arguments)}return e}()},{key:"_read_object",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r,n,i,a,o,u,s,c,l,f,_;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return this.peek();case 2:r=t.sent;if(!(r===eof)){t.next=5;break}return t.abrupt("return",r);case 5:if(!is_special(r)){t.next=38;break}n=specials.get(r);i=is_builtin(r);this.skip();o=is_symbol_extension(r);if(!o){t.next=14;break}t.t0=undefined;t.next=17;break;case 14:t.next=16;return this._read_object();case 16:t.t0=t.sent;case 17:u=t.t0;if(i){t.next=25;break}s=this.__env__.get(n.symbol);if(!(typeof s==="function")){t.next=25;break}if(is_literal(r)){c=[u]}else if(u===_nil){c=[]}else if(u instanceof Pair){c=u.to_array(false)}if(!(c||o)){t.next=24;break}return t.abrupt("return",call_function(s,o?[]:c,{env:this.__env__,dynamic_env:this.__env__,use_dynamic:false}));case 24:throw new Error("Parse Error: Invalid parser extension "+"invocation ".concat(n.symbol));case 25:if(is_literal(r)){a=new Pair(n.symbol,new Pair(u,_nil))}else{a=new Pair(n.symbol,u)}if(!i){t.next=28;break}return t.abrupt("return",a);case 28:if(!(s instanceof Macro)){t.next=37;break}t.next=31;return this.evaluate(a);case 31:l=t.sent;if(!(l instanceof Pair||l instanceof LSymbol)){t.next=34;break}return t.abrupt("return",Pair.fromArray([LSymbol("quote"),l]));case 34:return t.abrupt("return",l);case 37:throw new Error("Parse Error: invalid parser extension: "+n.symbol);case 38:f=this.match_datum_ref(r);if(!(f!==null)){t.next=44;break}this.skip();if(!this._refs[f]){t.next=43;break}return t.abrupt("return",new DatumReference(f,this._refs[f]));case 43:throw new Error("Parse Error: invalid datum label #".concat(f,"#"));case 44:_=this.match_datum_label(r);if(!(_!==null)){t.next=51;break}this.skip();this._refs[_]=this._read_object();return t.abrupt("return",this._refs[_]);case 51:if(!this.is_close(r)){t.next=55;break}this.skip();t.next=61;break;case 55:if(!this.is_open(r)){t.next=60;break}this.skip();return t.abrupt("return",this.read_list());case 60:return t.abrupt("return",this.read_value());case 61:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()}]);return u}();var DatumReference=function(){function r(e,t){_classCallCheck(this,r);this.name=e;this.data=t}_createClass(r,[{key:"valueOf",value:function e(){return this.data}}]);return r}();function _parse(e,t){return _parse2.apply(this,arguments)}function _parse2(){_parse2=_wrapAsyncGenerator(_regeneratorRuntime.mark(function e(r,n){var i,a,o;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!n){if(global_env){n=global_env.get("**interaction-environment**",{throwError:false})}else{n=user_env}}i=new Parser(r,{env:n});case 3:t.next=6;return _awaitAsyncGenerator(i.read_object());case 6:o=t.sent;if(!i.balanced()){i.ballancing_error(o,a)}if(!(o===eof)){t.next=10;break}return t.abrupt("break",15);case 10:a=o;t.next=13;return o;case 13:t.next=3;break;case 15:case"end":return t.stop()}},e)}));return _parse2.apply(this,arguments)}function unpromise(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(e){return e};var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;if(is_promise(e)){var n=e.then(t);if(r===null){return n}else{return n["catch"](r)}}if(e instanceof Array){return unpromise_array(e,t,r)}if(is_plain_object(e)){return unpromise_object(e,t,r)}return t(e)}function unpromise_array(t,r,e){if(t.find(is_promise)){return unpromise(promise_all(t),function(e){if(Object.isFrozen(t)){Object.freeze(e)}return r(e)},e)}return r(t)}function unpromise_object(t,e,r){var i=Object.keys(t);var n=[],a=[];var o=i.length;while(o--){var u=i[o];var s=t[u];n[o]=s;if(is_promise(s)){a.push(s)}}if(a.length){return unpromise(promise_all(n),function(e){var n={};e.forEach(function(e,t){var r=i[t];n[r]=e});if(Object.isFrozen(t)){Object.freeze(n)}return n},r)}return e(t)}function read_only(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},i=n.hidden,a=i===void 0?false:i;Object.defineProperty(e,t,{value:r,configurable:true,enumerable:!a})}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=_asyncToGenerator(_regeneratorRuntime.mark(function e(r){var n,i,a,o,u,s,c;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:n=[];i=false;a=false;t.prev=3;u=_asyncIterator(r);case 5:t.next=7;return u.next();case 7:if(!(i=!(s=t.sent).done)){t.next=13;break}c=s.value;n.push(c);case 10:i=false;t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15;t.t0=t["catch"](3);a=true;o=t.t0;case 19:t.prev=19;t.prev=20;if(!(i&&u["return"]!=null)){t.next=24;break}t.next=24;return u["return"]();case 24:t.prev=24;if(!a){t.next=27;break}throw o;case 27:return t.finish(24);case 28:return t.finish(19);case 29:return t.abrupt("return",n);case 30:case"end":return t.stop()}},e,null,[[3,15,19,29],[20,,24,28]])}));return _uniterate_async.apply(this,arguments)}function matcher(e,t){if(t instanceof RegExp){return function(e){return String(e).match(t)}}else if(is_function(t)){return t}throw new Error("Invalid matcher")}function doc(e,t,r,n){if(typeof e!=="string"){t=arguments[0];r=arguments[1];n=arguments[2];e=null}if(r){if(n){t.__doc__=r}else{t.__doc__=trim_lines(r)}}if(e){t.__name__=e}else if(t.name&&!is_lambda(t)){t.__name__=t.name}return t}function trim_lines(e){return e.split("\n").map(function(e){return e.trim()}).join("\n")}function previousSexp(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var r=e.length;if(t<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(t))}e:while(t--&&r>=0){var n=1;while(n>0){var i=e[--r];if(!i){break e}if(i==="("||i.token==="("){n--}else if(i===")"||i.token===")"){n++}}r--}return e.slice(r+1)}function lineIndent(e){if(!e||!e.length){return 0}var t=e.length;if(e[t-1].token==="\n"){return 0}while(--t){if(e[t].token==="\n"){var r=(e[t+1]||{}).token;if(r){return r.length}}}return 0}function match(e,t){return l(e,t)===t.length;function l(r,n){function e(e,t){var r=_createForOfIteratorHelper(e),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;var a=l(i,t);if(a!==-1){return a}}}catch(e){r.e(e)}finally{r.f()}return-1}function t(){return r[a]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function i(){var e=r[a+1];var t=n[u+1];if(e!==undefined&&t!==undefined){return l([e],[t])}}var a=0;var o={};for(var u=0;u0){continue}}else if(t()){return-1}}else if(r[a]instanceof Array){var c=l(r[a],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;a++;continue}else{return-1}a++}if(r.length!==a){return-1}return n.length}}function Formatter(e){this.__code__=e.replace(/\r/g,"")}Formatter.defaults={offset:0,indent:2,exceptions:{specials:[/^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|(?:call-with-(?:input-file|output-file|port))|lambda|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax|\*)?)$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(t){var r=Formatter.defaults;if(typeof t==="undefined"){return Object.assign({},r)}var n=t&&t.exceptions||{};var i=n.specials||[];var a=n.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},r),t),{},{exceptions:{specials:[].concat(_toConsumableArray(r.exceptions.specials),_toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(_toConsumableArray(r.exceptions.shift[1]),_toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(t){var r=tokenize(this.__code__,true);return this._indent(r,t)};Formatter.exception_shift=function(a,e){function t(e){if(!e.length){return false}if(e.indexOf(a)!==-1){return true}else{var t=e.filter(function(e){return e instanceof RegExp});if(!t.length){return false}var r=_createForOfIteratorHelper(t),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;if(a.match(i)){return true}}}catch(e){r.e(e)}finally{r.f()}}return false}if(t(e.exceptions.specials)){return e.indent}var r=e.exceptions.shift;for(var n=0,i=Object.entries(r);n0){n.offset=0}if(a.toString()===t.toString()&&balanced(a)){return n.offset+a[0].col}else if(a.length===1){return n.offset+a[0].col+1}else{var s=-1;if(o){var c=Formatter.exception_shift(o.token,n);if(c!==-1){s=c}}if(s===-1){s=Formatter.exception_shift(a[1].token,n)}if(s!==-1){return n.offset+a[0].col+s}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return n.offset+a[1].col}return n.offset+a[3].col}else if(a[0].line===a[1].line){return n.offset+n.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,t=new Array(e),r=0;r")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/^[[(]$/;var p_e=/^[\])]$/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var glob=Symbol["for"]("*");var sexp_or_atom=new Pattern([p_o,glob,p_e],[not_p],"+");var sexp=new Pattern([p_o,glob,p_e],"+");var symbol=new Pattern([Symbol["for"]("symbol")],"?");var symbols=new Pattern([Symbol["for"]("symbol")],"*");var identifiers=[p_o,symbols,p_e];var let_value=new Pattern([p_o,Symbol["for"]("symbol"),glob,p_e],"+");var def_lambda_re=keywords_re("define","lambda","define-macro","syntax-rules");var non_def=/^(?!.*\b(?:[()[\]]|define(?:-macro)?|let(?:\*|rec|-env|-syntax|)?|lambda|syntax-rules)\b).*$/;var let_re=/^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/;function keywords_re(){for(var e=arguments.length,t=new Array(e),r=0;r0&&!u[e]){u[e]=previousSexp(o,e)}});var s=_createForOfIteratorHelper(i),c;try{for(s.s();!(c=s.n()).done;){var l=_slicedToArray(c.value,3),f=l[0],_=l[1],p=l[2];_=_.valueOf();var h=_>0?u[_]:o;var d=h.filter(function(e){return e.trim()&&!is_special(e)});var m=r(h);var y=match(f,d);var v=n.slice(a).find(function(e){return e.trim()&&!is_special(e)});if(y&&(p instanceof Ahead&&p.match(v)||!p)){var g=a-m;if(n[g]!=="\n"){if(!n[g].trim()){n[g]="\n"}else{n.splice(g,0,"\n");a++}}a+=m;continue e}}}catch(e){s.e(e)}finally{s.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return" ".repeat(e)};Formatter.prototype.format=function e(t){var r=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var n=tokenize(r,true);var i=this._options(t);var a=0;var o=0;for(var u=0;u0){n=Math.floor(t()*r);r--;var i=[e[n],e[r]];e[r]=i[0];e[n]=i[1]}return e}function Nil(){}Nil.prototype.toString=function(){return"()"};Nil.prototype.valueOf=function(){return undefined};Nil.prototype.serialize=function(){return 0};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,_nil)};Nil.prototype.to_array=function(){return[]};var _nil=new Nil;function Pair(e,t){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,t)}this.car=e;this.cdr=t}function to_array(a,o){return function e(t){typecheck(a,t,["pair","nil"]);if(t===_nil){return[]}var r=[];var n=t;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(o&&i instanceof Pair){i=this.get(a).call(this,i)}r.push(i);n=n.cdr}else if(n===_nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return r}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var t=this;while(true){if(!t||t===_nil||!(t instanceof Pair)||t.haveCycles("cdr")){break}e++;t=t.cdr}return e};Pair.match=function(e,t){if(e instanceof LSymbol){return LSymbol.is(e,t)}else if(e instanceof Pair){return Pair.match(e.car,t)||Pair.match(e.cdr,t)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,t)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,t)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var n=new Map;function i(e){if(e instanceof Pair){if(n.has(e)){return n.get(e)}var t=new Pair;n.set(e,t);if(r){t.car=i(e.car)}else{t.car=e.car}t.cdr=i(e.cdr);t[__cycles__]=e[__cycles__];return t}return e}return i(this)};Pair.prototype.last_pair=function(){var e=this;while(true){if(e.cdr===_nil){return e}e=e.cdr}};Pair.prototype.to_array=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var t=[];if(this.car instanceof Pair){if(e){t.push(this.car.to_array())}else{t.push(this.car)}}else{t.push(this.car.valueOf())}if(this.cdr instanceof Pair){t=t.concat(this.cdr.to_array(e))}return t};Pair.fromArray=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(e instanceof Pair||r&&e instanceof Array&&e[__data__]){return e}if(t===false){var n=_nil;for(var i=e.length;i--;){n=new Pair(e[i],n)}return n}if(e.length&&!(e instanceof Array)){e=_toConsumableArray(e)}var a=_nil;var o=e.length;while(o--){var u=e[o];if(u instanceof Array){u=Pair.fromArray(u,t,r)}else if(typeof u==="string"){u=LString(u)}else if(typeof u==="number"&&!Number.isNaN(u)){u=LNumber(u)}a=new Pair(u,a)}return a};Pair.prototype.to_object=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var t=this;var r={};while(true){if(t instanceof Pair&&t.car instanceof Pair){var n=t.car;var i=n.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=n.cdr;if(a instanceof Pair){a=a.to_object(e)}if(is_native(a)){if(!e){a=a.valueOf()}}r[i]=a;t=t.cdr}else{break}}return r};Pair.fromPairs=function(e){return e.reduce(function(e,t){return new Pair(new Pair(new LSymbol(t[0]),t[1]),e)},_nil)};Pair.fromObject=function(t){var e=Object.keys(t).map(function(e){return[e,t[e]]});return Pair.fromPairs(e)};Pair.prototype.reduce=function(e){var t=this;var r=_nil;while(true){if(t!==_nil){r=e(r,t.car);t=t.cdr}else{break}}return r};Pair.prototype.reverse=function(){if(this.haveCycles()){throw new Error("You can't reverse list that have cycles")}var e=this;var t=_nil;while(e!==_nil){var r=e.cdr;e.cdr=t;t=e;e=r}return t};Pair.prototype.transform=function(n){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var t=n(e.car);if(t instanceof Pair){t=i(t)}var r=n(e.cdr);if(r instanceof Pair){r=i(r)}return new Pair(t,r)}return e}return i(this)};Pair.prototype.map=function(e){if(typeof this.car!=="undefined"){return new Pair(e(this.car),this.cdr===_nil?_nil:this.cdr.map(e))}else{return _nil}};var repr=new Map;function is_plain_object(e){return e&&_typeof$1(e)==="object"&&e.constructor===Object}var props=Object.getOwnPropertyNames(Array.prototype);var array_methods=[];props.forEach(function(e){array_methods.push(Array[e],Array.prototype[e])});function is_array_method(e){e=unbind(e);return array_methods.includes(e)}function is_lips_function(e){return is_function(e)&&(is_lambda(e)||e.__doc__)}function user_repr(r){var e=r.constructor||Object;var n=is_plain_object(r);var i=is_function(r[Symbol.asyncIterator])||is_function(r[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,t){t=unbind(t);if(r.constructor===t&&(t===Object&&n&&!i||t!==Object)){a=e}})}return a}var str_mapping=new Map;[[true,"#t"],[false,"#f"],[null,"null"],[undefined,"#"]].forEach(function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];str_mapping.set(r,n)});function symbolize(r){if(r&&_typeof$1(r)==="object"){var n={};var e=Object.getOwnPropertySymbols(r);e.forEach(function(e){var t=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");n[t]=toString(r[e])});var t=Object.getOwnPropertyNames(r);t.forEach(function(e){var t=r[e];if(t&&_typeof$1(t)==="object"&&t.constructor===Object){n[e]=symbolize(t)}else{n[e]=toString(t)}});return n}return r}function get_props(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function has_own_function(e,t){return e.hasOwnProperty(t)&&is_function(e.toString)}function function_to_string(e){if(is_native_function(e)){return"#"}var t=e.prototype&&e.prototype.constructor;if(is_function(t)&&is_lambda(t)){if(e[__class__]&&t.hasOwnProperty("__name__")){var r=t.__name__;if(LString.isString(r)){r=r.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof$1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!is_lambda(e)){return"#")}else{return"#"}}var instances=new Map;[[Error,function(e){return e.message}],[Pair,function(e,t){var r=t.quote,n=t.skip_cycles,i=t.pair_args;if(!n){e.markCycles()}return e.toString.apply(e,[r].concat(_toConsumableArray(i)))}],[LCharacter,function(e,t){var r=t.quote;if(r){return e.toString()}return e.valueOf()}],[LString,function(e,t){var r=t.quote;e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];instances.set(r,n)});var native_types=[LSymbol,LNumber,Macro,Values,InputPort,OutputPort,Environment,QuotedPromise];function toString(e,t,r){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(is_prototype(e)){return"#"}if(e){var n=e.constructor;if(instances.has(n)){for(var i=arguments.length,a=new Array(i>3?i-3:0),o=3;o"}if(e===null){return"null"}if(_typeof$1(e)==="object"){var l=e.constructor;if(!l){l=Object}var f;if(typeof l.__class__==="string"){f=l.__class__}else{var _=user_repr(e);if(_){if(is_function(_)){return _(e,t)}else{throw new Error("toString: Invalid repr value")}}f=l.name}if(is_function(e.toString)&&is_lambda(e.toString)){return e.toString().valueOf()}if(type(e)==="instance"){if(is_lambda(l)&&l.__name__){f=l.__name__.valueOf()}else if(!is_native_function(l)){f="instance"}}if(is_iterator(e,Symbol.iterator)){if(f){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(f){return"#")}return"#"}if(f!==""){return"#<"+f+">"}return"#"}if(typeof e!=="string"){return e.toString()}return e}function is_prototype(e){return e&&_typeof$1(e)==="object"&&e.hasOwnProperty&&e.hasOwnProperty("constructor")&&typeof e.constructor==="function"&&e.constructor.prototype===e}Pair.prototype.markCycles=function(){markCycles(this);return this};Pair.prototype.haveCycles=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(!e){return this.haveCycles("car")||this.haveCycles("cdr")}return!!(this[__cycles__]&&this[__cycles__][e])};function markCycles(e){var t=[];var i=[];var a=[];function o(e){if(!t.includes(e)){t.push(e)}}function u(e,t,r,n){if(r instanceof Pair){if(n.includes(r)){if(!a.includes(r)){a.push(r)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][t]=r;if(!i.includes(e)){i.push(e)}return true}}}var s=trampoline(function e(t,r){if(t instanceof Pair){delete t.ref;delete t[__cycles__];o(t);r.push(t);var n=u(t,"car",t.car,r);var i=u(t,"cdr",t.cdr,r);if(!n){s(t.car,r.slice())}if(!i){return new Thunk(function(){return e(t.cdr,r.slice())})}}});function r(e,t){if(e[__cycles__][t]instanceof Pair){var r=n.indexOf(e[__cycles__][t]);e[__cycles__][t]="#".concat(r,"#")}}s(e,[]);var n=t.filter(function(e){return a.includes(e)});n.forEach(function(e,t){e[__ref__]="#".concat(t,"=")});i.forEach(function(e){r(e,"car");r(e,"cdr")})}Pair.prototype.toString=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.nested,n=r===void 0?false:r;var i=[];if(this[__ref__]){i.push(this[__ref__]+"(")}else if(!n){i.push("(")}var a;if(this[__cycles__]&&this[__cycles__].car){a=this[__cycles__].car}else{a=toString(this.car,e,true)}if(a!==undefined){i.push(a)}if(this.cdr instanceof Pair){if(this[__cycles__]&&this[__cycles__].cdr){i.push(" . ");i.push(this[__cycles__].cdr)}else{if(this.cdr[__ref__]){i.push(" . ")}else{i.push(" ")}var o=this.cdr.toString(e,{nested:true});i.push(o)}}else if(this.cdr!==_nil){i=i.concat([" . ",toString(this.cdr,e,true)])}if(!n||this[__ref__]){i.push(")")}return i.join("")};Pair.prototype.set=function(e,t){this[e]=t;if(t instanceof Pair){this.markCycles()}};Pair.prototype.append=function(e){if(e instanceof Array){return this.append(Pair.fromArray(e))}var t=this;if(t.car===undefined){if(e instanceof Pair){this.car=e.car;this.cdr=e.cdr}else{this.car=e}}else if(e!==_nil){while(true){if(t instanceof Pair&&t.cdr!==_nil){t=t.cdr}else{break}}t.cdr=e}return this};Pair.prototype.serialize=function(){return[this.car,this.cdr]};Pair.prototype[Symbol.iterator]=function(){var r=this;return{next:function e(){var t=r;r=t.cdr;if(t===_nil){return{value:undefined,done:true}}else{return{value:t.car,done:false}}}}};function abs(e){return e<0?-e:e}function seq_compare(e,t){var r=_toArray(t),n=r[0],i=r.slice(1);while(i.length>0){var a=i,o=_slicedToArray(a,1),u=o[0];if(!e(n,u)){return false}var s=i;var c=_toArray(s);n=c[0];i=c.slice(1)}return true}function equal(e,t){if(is_function(e)){return is_function(t)&&unbind(e)===unbind(t)}else if(e instanceof LNumber){if(!(t instanceof LNumber)){return false}var r;if(e.__type__===t.__type__){if(e.__type__==="complex"){r=e.__im__.__type__===t.__im__.__type__&&e.__re__.__type__===t.__re__.__type__}else{r=true}if(r&&e.cmp(t)===0){if(e.valueOf()===0){return Object.is(e.valueOf(),t.valueOf())}return true}}return false}else if(typeof e==="number"){if(typeof t!=="number"){return false}if(Number.isNaN(e)){return Number.isNaN(t)}if(e===Number.NEGATIVE_INFINITY){return t===Number.NEGATIVE_INFINITY}if(e===Number.POSITIVE_INFINITY){return t===Number.POSITIVE_INFINITY}return equal(LNumber(e),LNumber(t))}else if(e instanceof LCharacter){if(!(t instanceof LCharacter)){return false}return e.__char__===t.__char__}else{return e===t}}function same_atom(e,t){if(type(e)!==type(t)){return false}if(!is_atom(e)){return false}if(e instanceof RegExp){return e.source===t.source}if(e instanceof LString){return e.valueOf()===t.valueOf()}return equal(e,t)}function is_atom(e){return e instanceof LSymbol||LString.isString(e)||e===_nil||e===null||e instanceof LCharacter||e instanceof LNumber||e===true||e===false}var truncate=function(){if(Math.trunc){return Math.trunc}else{return function(e){if(e===0){return 0}else if(e<0){return Math.ceil(e)}else{return Math.floor(e)}}}}();function Macro(e,t,r,n){if(typeof this!=="undefined"&&this.constructor!==Macro||typeof this==="undefined"){return new Macro(e,t)}typecheck("Macro",e,"string",1);typecheck("Macro",t,"function",2);if(r){if(n){this.__doc__=r}else{this.__doc__=trim_lines(r)}}this.__name__=e;this.__fn__=t}Macro.defmacro=function(e,t,r,n){var i=new Macro(e,t,r,n);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,t,r){var n=t.env,i=_objectWithoutProperties(t,_excluded2);var a=_objectSpread(_objectSpread({},i),{},{macro_expand:r});var o=this.__fn__.call(n,e,a,this.__name__);return o};Macro.prototype.toString=function(){return"#")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(c){return function(){var r=_asyncToGenerator(_regeneratorRuntime.mark(function e(r,v){var a,g,n,i,o,b,w,D,x,E,L,S,u,A,s;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:s=function e(){s=_asyncToGenerator(_regeneratorRuntime.mark(function e(r,n,i){var a,o,u,s,c,l,f,_,p,h,d,m,y;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!(r instanceof Pair&&r.car instanceof LSymbol)){t.next=50;break}if(!r[__data__]){t.next=3;break}return t.abrupt("return",r);case 3:a=r.car.valueOf();o=i.get(r.car,{throwError:false});u=b(r.car);s=u||w(o,r)||D(o);if(!(s&&r.cdr.car instanceof Pair)){t.next=28;break}if(!u){t.next=15;break}g=E(r.cdr.car);t.next=12;return S(r.cdr.car,n);case 12:c=t.sent;t.next=17;break;case 15:g=x(r.cdr.car);c=r.cdr.car;case 17:t.t0=Pair;t.t1=r.car;t.t2=Pair;t.t3=c;t.next=23;return A(r.cdr.cdr,n,i);case 23:t.t4=t.sent;t.t5=new t.t2(t.t3,t.t4);return t.abrupt("return",new t.t0(t.t1,t.t5));case 28:if(!L(a,o)){t.next=50;break}l=o instanceof Syntax?r:r.cdr;t.next=32;return o.invoke(l,_objectSpread(_objectSpread({},v),{},{env:i}),true);case 32:f=t.sent;if(!(o instanceof Syntax)){t.next=41;break}_=f,p=_.expr,h=_.scope;if(!(p instanceof Pair)){t.next=40;break}if(!(n!==-1&&n<=1||n")}return"#"};Syntax.className="syntax";var SyntaxParameter=function(e){_inherits(t,e);function t(){_classCallCheck(this,t);return _callSuper(this,t,arguments)}return _createClass(t)}(Syntax);Syntax.Parameter=SyntaxParameter;function extract_patterns(e,t,w,D){var r=arguments.length>4&&arguments[4]!==undefined?arguments[4]:{};var x={"...":{symbols:{},lists:[]},symbols:{}};var E=r.expansion,L=r.define;function S(e){if(is_debug()){console.log(e)}}S(w);function A(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;S({code:t&&toString(t,true),pattern:e&&toString(e,true)});if(is_atom(e)&&!(e instanceof LSymbol)){return same_atom(e,t)}if(e instanceof LSymbol&&w.includes(e.literal())){var i=E.ref(t);if(LSymbol.is(t,e)){if(typeof i==="undefined"){return true}return i===L||i===global_env}return false}if(e instanceof Pair&&e.car instanceof Pair&&e.car.cdr instanceof Pair&&LSymbol.is(e.car.cdr.car,D)){S(">> 0");if(t===_nil){S({pattern:e.toString()});if(e.car.car instanceof LSymbol){if(e.car.cdr instanceof Pair&&LSymbol.is(e.car.cdr.car,D)){var a=e.car.car.valueOf();var o=e.last_pair();if(LSymbol.is(o.car,D)){x["..."].symbols[a]=null;return true}else{return false}}var u=e.car.car.valueOf();if(x["..."].symbols[u]){throw new Error("syntax: named ellipsis can only "+"appear onces")}x["..."].symbols[u]=t}}}if(e instanceof Pair&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,D)){if(e.cdr.cdr!==_nil){if(e.cdr.cdr instanceof Pair){var s=e.cdr.cdr.length();if(!is_pair(t)){throw new Error("syntax-rules: no matching syntax")}var c=t.length();var l=t;while(c-1>s){l=l.cdr;c--}var f=l.cdr;l.cdr=_nil;if(!A(e.cdr.cdr,f,r,n)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(x["..."].symbols[_]&&!r.includes(_)&&!n){throw new Error("syntax: named ellipsis can only appear onces")}S(">> 1");if(t===_nil){S(">> 2");if(n){S("NIL");x["..."].symbols[_]=_nil}else{S("NULL");x["..."].symbols[_]=null}}else if(t instanceof Pair&&(t.car instanceof Pair||t.car===_nil)){S(">> 3 "+n);if(n){if(x["..."].symbols[_]){var p=x["..."].symbols[_];if(p===_nil){p=new Pair(_nil,new Pair(t,_nil))}else{p=p.append(new Pair(t,_nil))}x["..."].symbols[_]=p}else{x["..."].symbols[_]=new Pair(t,_nil)}}else{S(">> 4");x["..."].symbols[_]=new Pair(t,_nil)}}else{S(">> 6");if(t instanceof Pair){S(">> 7 "+n);r.push(_);if(!x["..."].symbols[_]){x["..."].symbols[_]=new Pair(t,_nil)}else{var h=x["..."].symbols[_];x["..."].symbols[_]=h.append(new Pair(t,_nil))}S({IIIIII:x["..."].symbols[_].toString()})}else{S(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=_toConsumableArray(r);if(t===_nil){S(">> 9");x["..."].lists.push(_nil);return true}S(">> 10");var m=t;while(m instanceof Pair){if(!A(e.car,m.car,d,true)){return false}m=m.cdr}return true}return false}if(e instanceof LSymbol){if(LSymbol.is(e,D)){throw new Error("syntax: invalid usage of ellipsis")}S(">> 11");var y=e.__name__;if(w.includes(y)){return true}S({name:y,ellipsis:n});if(n){x["..."].symbols[y]=x["..."].symbols[y]||[];x["..."].symbols[y].push(t)}x.symbols[y]=t;if(!x.symbols[y]);return true}if(e instanceof Pair&&t instanceof Pair){S(">> 12");S({a:12,code:t&&t.toString(),pattern:e.toString()});if(t.cdr===_nil){var v=e.car instanceof LSymbol&&e.cdr instanceof LSymbol;if(v){if(!A(e.car,t.car,r,n)){return false}S(">> 12 | 1");var g=e.cdr.valueOf();if(!(g in x.symbols)){x.symbols[g]=_nil}g=e.car.valueOf();if(!(g in x.symbols)){x.symbols[g]=t.car}return true}}S({pattern:e.toString(),code:t.toString()});if(e.cdr instanceof Pair&&e.cdr.cdr instanceof Pair&&e.cdr.car instanceof LSymbol&&LSymbol.is(e.cdr.cdr.car,D)&&e.cdr.cdr.cdr instanceof Pair&&!LSymbol.is(e.cdr.cdr.cdr.car,D)&&A(e.car,t.car,r,n)&&A(e.cdr.cdr.cdr,t.cdr,r,n)){var b=e.cdr.car.__name__;S({pattern:e.car.toString(),code:t.car.toString(),name:b});if(w.includes(b)){return true}x["..."].symbols[b]=null;return true}S("recur");if(A(e.car,t.car,r,n)&&A(e.cdr,t.cdr,r,n)){return true}}else if(e===_nil&&(t===_nil||t===undefined)){return true}else if(e.car instanceof Pair&&LSymbol.is(e.car.car,D)){throw new Error("syntax: invalid usage of ellipsis")}else{return false}}if(A(e,t)){return x}}function clear_gensyms(e,i){function a(t){if(t instanceof Pair){if(!i.length){return t}var e=a(t.car);var r=a(t.cdr);return new Pair(e,r)}else if(t instanceof LSymbol){var n=i.find(function(e){return e.gensym===t});if(n){return LSymbol(n.name)}return t}else{return t}}return a(e)}function transform_syntax(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var A=e.bindings,t=e.expr,F=e.scope,o=e.symbols,c=e.names,k=e.ellipsis;var l={};function u(e){if(e instanceof LSymbol){return true}return["string","symbol"].includes(_typeof$1(e))}function P(e){if(!u(e)){var t=type(e);throw new Error("syntax: internal error, need symbol got ".concat(t))}var r=e.valueOf();if(r===k){throw new Error("syntax: internal error, ellipis not transformed")}var n=_typeof$1(r);if(["string","symbol"].includes(n)){if(r in A.symbols){return A.symbols[r]}else if(n==="string"&&r.match(/\./)){var i=r.split(".");var a=i[0];if(a in A.symbols){return Pair.fromArray([LSymbol("."),A.symbols[a]].concat(i.slice(1).map(function(e){return LString(e)})))}}}if(o.includes(r)){return LSymbol(r)}return s(r)}function C(e){if(is_debug()){console.log(e)}}function s(e){if(!l[e]){var t=F.ref(e);var r=gensym(e);if(t){var n=F.get(e);F.set(r,n)}else{var i=F.get(e,{throwError:false});if(typeof i!=="undefined"){F.set(r,i)}}c.push({name:e,gensym:r});l[e]=r;if(typeof e==="string"&&e.match(/\./)){var a=e.split(".").filter(Boolean),o=_toArray(a),u=o[0],s=o.slice(1);if(l[u]){hidden_prop(r,"__object__",[l[u]].concat(_toConsumableArray(s)))}}}return l[e]}function B(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:function(){};var i=r.nested;C(" ==> "+e.toString(true));C(t);if(e instanceof LSymbol){var a=e.valueOf();C("[t 1");if(t[a]){if(t[a]instanceof Pair){var o=t[a],u=o.car,s=o.cdr;if(i){var c=u.car,l=u.cdr;if(l!==_nil){n(a,new Pair(l,_nil))}return c}if(s!==_nil){n(a,s)}return u}else if(t[a]instanceof Array){n(a,t[a].slice(1));return t[a][0]}}return P(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,k)){C("[t 2");var f=e.car.valueOf();var _=t[f];C({expr:e.toString(true),name:f,bindings:t,item:_});if(_===null){return}else if(_){C({b:t[f].toString()});if(_ instanceof Pair){C("[t 2 Pair "+i);C({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==_nil){C("|| next 1");n(f,h)}C({car:p.toString()});return p}else{if(p.cdr!==_nil){C("|| next 2");n(f,new Pair(p.cdr,h))}C({car:p.car.toString()});return p.car}}else if(_ instanceof Array){C("[t 2 Array "+i);if(i){n(f,_.slice(1));return Pair.fromArray(_)}else{var d=_.slice(1);if(d.length){n(f,d)}return _[0]}}else{return _}}}C("[t 3 recur "+e.toString());var m=B(e.car,t,r,n);var y=B(e.cdr,t,r,n);return new Pair(m,y)}return e}function O(t,r){var e=Object.values(t);var n=Object.getOwnPropertySymbols(t);if(n.length){e.push.apply(e,_toConsumableArray(n.map(function(e){return t[e]})))}return e.length&&e.every(function(e){if(e===null){return!r}return e instanceof Pair||e===_nil||e instanceof Array&&e.length})}function I(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function N(i){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},t=e.disabled;C("traverse>> "+toString(i));if(i instanceof Pair){if(!t&&i.car instanceof Pair&&LSymbol.is(i.car.car,k)){return N(i.car.cdr,{disabled:true})}if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,k)&&!t){C(">> 1");var r=A["..."].symbols;var n=Object.values(r);if(n.length&&n.every(function(e){return e===null})){return N(i.cdr.cdr,{disabled:t})}var a=I(r);var o=i.car instanceof LSymbol&&LSymbol.is(i.cdr.cdr.car,k);if(i.car instanceof Pair||o){if(A["..."].lists[0]===_nil){return _nil}var u=i.car;if(o){u=new Pair(i.car,new Pair(i.cdr.car,_nil))}C(">> 2");var s;if(a.length){C(">> 2 (a)");var c=_objectSpread({},r);s=_nil;var l=function e(){if(!O(c)){return 1}var n={};var t=function e(t,r){n[t]=r};var r=B(u,c,{nested:true},t);if(r!==undefined){if(o){if(s===_nil){s=r}else{s=s.append(r)}}else{s=new Pair(r,s)}}c=n};while(true){if(l())break}if(s!==_nil&&!o){s=s.reverse()}if(i.cdr.cdr!==_nil&&!LSymbol.is(i.cdr.cdr.car,k)){var f=N(i.cdr.cdr,{disabled:t});return s.append(f)}return s}else{C(">> 3");var _=B(i.car,r,{nested:true});if(_){return new Pair(_,_nil)}return _nil}}else if(i.car instanceof LSymbol){C(">> 4");if(LSymbol.is(i.cdr.cdr.car,k)){C(">> 4 (a)")}else{C(">> 4 (b)")}var p=i.car.__name__;var h=_defineProperty({},p,r[p]);var d=r[p]===null;var m=_nil;var y=function e(){if(!O(h,true)){C({bind:h});return 1}var n={};var t=function e(t,r){n[t]=r};var r=B(i,h,{nested:false},t);C({value:r.toString()});if(typeof r!=="undefined"){m=new Pair(r,m)}h=n};while(true){if(y())break}if(m!==_nil){m=m.reverse()}if(i.cdr instanceof Pair){if(i.cdr.cdr instanceof Pair||i.cdr.cdr instanceof LSymbol){var v=N(i.cdr.cdr,{disabled:t});if(d){return v}C("<<<< 1");m.append(v)}}C("<<<< 2");return m}}var g=N(i.car,{disabled:t});var b;var w;if(i.car instanceof LSymbol){var D=F.get(i.car,{throwError:false});w=D instanceof Macro&&D.__name__==="syntax-rules"}if(w){if(i.cdr.car instanceof LSymbol){b=new Pair(N(i.cdr.car,{disabled:t}),new Pair(i.cdr.cdr.car,N(i.cdr.cdr.cdr,{disabled:t})))}else{b=new Pair(i.cdr.car,N(i.cdr.cdr,{disabled:t}))}C("REST >>>> "+b.toString())}else{b=N(i.cdr,{disabled:t})}C({a:true,car:toString(i.car),cdr:toString(i.cdr),head:toString(g),rest:toString(b)});return new Pair(g,b)}if(i instanceof LSymbol){if(t&&LSymbol.is(i,k)){return i}var x=Object.keys(A["..."].symbols);var E=i.literal();if(x.includes(E)){var L="missing ellipsis symbol next to name `".concat(E,"'");throw new Error("syntax-rules: ".concat(L))}var S=P(i);if(typeof S!=="undefined"){return S}}return i}return N(t,{})}function is_null(e){return is_undef(e)||e===_nil||e===null}function is_function(e){return typeof e==="function"&&typeof e.bind==="function"}function is_continuation(e){return e instanceof Continuation}function is_context(e){return e instanceof LambdaContext}function is_parameter(e){return e instanceof Parameter}function is_pair(e){return e instanceof Pair}function is_env(e){return e instanceof Environment}function is_callable(e){return is_function(e)||is_continuation(e)||is_parameter(e)}function is_promise(e){if(e instanceof QuotedPromise){return false}if(e instanceof Promise){return true}return!!e&&is_function(e.then)}function is_undef(e){return typeof e==="undefined"}function is_iterator(e,t){if(has_own_symbol(e,t)||has_own_symbol(e.__proto__,t)){return is_function(e[t])}}function is_instance(e){if(!e){return false}if(_typeof$1(e)!=="object"){return false}if(e.__instance__){e.__instance__=false;return e.__instance__}return false}function self_evaluated(e){var t=_typeof$1(e);return["string","function"].includes(t)||_typeof$1(e)==="symbol"||e instanceof QuotedPromise||e instanceof LSymbol||e instanceof LNumber||e instanceof LString||e instanceof RegExp}function is_native(e){return e instanceof LNumber||e instanceof LString||e instanceof LCharacter}function has_own_symbol(e,t){if(e===null){return false}return _typeof$1(e)==="object"&&t in Object.getOwnPropertySymbols(e)}function box(e){switch(_typeof$1(e)){case"string":return LString(e);case"bigint":return LNumber(e);case"number":if(Number.isNaN(e)){return nan}else{return LNumber(e)}}return e}function map_object(r,n){var e=Object.getOwnPropertyNames(r);var t=Object.getOwnPropertySymbols(r);var i={};e.concat(t).forEach(function(e){var t=n(r[e]);i[e]=t});return i}function unbox(t){var e=[LString,LNumber].some(function(e){return t instanceof e});if(e){return t.valueOf()}if(t instanceof Array){return t.map(unbox)}if(t instanceof QuotedPromise){delete t.then}if(is_plain_object(t)){return map_object(t,unbox)}return t}function patch_value(e,t){if(e instanceof Pair){e.markCycles();return quote(e)}if(is_function(e)){if(t){return bind(e,t)}}return box(e)}function unbind(e){if(is_bound(e)){return e[__fn__]}return e}function bind(e,t){if(e[Symbol["for"]("__bound__")]){return e}var r=e.bind(t);var n=Object.getOwnPropertyNames(e);var i=_createForOfIteratorHelper(n),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;if(filter_fn_names(o)){try{r[o]=e[o]}catch(e){}}}}catch(e){i.e(e)}finally{i.f()}hidden_prop(r,"__fn__",e);hidden_prop(r,"__context__",t);hidden_prop(r,"__bound__",true);if(is_native_function(e)){hidden_prop(r,"__native__",true)}if(is_plain_object(t)&&is_lambda(e)){hidden_prop(r,"__method__",true)}r.valueOf=function(){return e};return r}function is_object_bound(e){return is_bound(e)&&e[Symbol["for"]("__context__")]===Object}function is_bound(e){return!!(is_function(e)&&e[__fn__])}function lips_context(e){if(is_function(e)){var t=e[__context__];if(t&&(t===lips||t.constructor&&t.constructor.__class__)){return true}}return false}function is_port(e){return e instanceof InputPort||e instanceof OutputPort}function is_port_method(e){if(is_function(e)){if(is_port(e[__context__])){return true}}return false}var __context__=Symbol["for"]("__context__");var __fn__=Symbol["for"]("__fn__");var __data__=Symbol["for"]("__data__");var __ref__=Symbol["for"]("__ref__");var __cycles__=Symbol["for"]("__cycles__");var __class__=Symbol["for"]("__class__");var __method__=Symbol["for"]("__method__");var __prototype__=Symbol["for"]("__prototype__");var __lambda__=Symbol["for"]("__lambda__");var exluded_names=["name","length","caller","callee","arguments","prototype"];function filter_fn_names(e){return!exluded_names.includes(e)}function hidden_prop(e,t,r){Object.defineProperty(e,Symbol["for"](t),{get:function e(){return r},set:function e(){},configurable:false,enumerable:false})}function set_fn_length(t,r){try{Object.defineProperty(t,"length",{get:function e(){return r}});return t}catch(e){var n=new Array(r).fill(0).map(function(e,t){return"a"+t}).join(",");var i=new Function("f","return function(".concat(n,") {\n return f.apply(this, arguments);\n };"));return i(t)}}function is_lambda(e){return e&&e[__lambda__]}function is_method(e){return e&&e[__method__]}function is_raw_lambda(e){return is_lambda(e)&&!e[__prototype__]&&!is_method(e)&&!is_port_method(e)}function is_native_function(e){var t=Symbol["for"]("__native__");return is_function(e)&&e.toString().match(/\{\s*\[native code\]\s*\}/)&&(e.name.match(/^bound /)&&e[t]===true||!e.name.match(/^bound /)&&!e[t])}function let_macro(e){var b;switch(e){case Symbol["for"]("letrec"):b="letrec";break;case Symbol["for"]("let"):b="let";break;case Symbol["for"]("let*"):b="let*";break;default:throw new Error("Invalid let_macro value")}return Macro.defmacro(b,function(t,e){var l=e.dynamic_env;var f=e.error,r=e.macro_expand,_=e.use_dynamic;var p;if(t.car instanceof LSymbol){if(!(t.cdr.car instanceof Pair||t.cdr.car===_nil)){throw new Error("let require list of pairs")}var n;if(t.cdr.car===_nil){p=_nil;n=_nil}else{n=t.cdr.car.map(function(e){return e.car});p=t.cdr.car.map(function(e){return e.cdr.car})}return Pair.fromArray([LSymbol("letrec"),[[t.car,Pair(LSymbol("lambda"),Pair(n,t.cdr.cdr))]],Pair(t.car,p)])}else if(r){return}var h=this;p=global_env.get("list->array")(t.car);var d=h.inherit(b);var m,y;if(b==="let*"){y=d}else if(b==="let"){m=[]}var v=0;function g(){var e=new Pair(new LSymbol("begin"),t.cdr);return _evaluate(e,{env:d,dynamic_env:d,use_dynamic:_,error:f})}return function t(){var r=p[v++];l=b==="let*"?d:h;if(!r){if(m&&m.length){var e=m.map(function(e){return e.value});var n=e.filter(is_promise);if(n.length){return promise_all(e).then(function(e){for(var t=0,r=e.length;t1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=this;var a=this;var o=[];var u=e;while(u instanceof Pair){o.push(_evaluate(u.car,{env:i,dynamic_env:a,use_dynamic:r,error:n}));u=u.cdr}var s=o.filter(is_promise).length;if(s){return promise_all(o).then(c.bind(this))}else{return c.call(this,o)}})}function guard_math_call(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2?n-2:0),a=2;a1&&arguments[1]!==undefined?arguments[1]:null;return function(){for(var e=arguments.length,t=new Array(e),r=0;r1?e-1:0),r=1;r=o){return a.apply(this,n)}else{return i}}return i.apply(this,arguments)}}function limit(n,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,t=new Array(e),r=0;r1){e=e.toLowerCase();if(LCharacter.__names__[e]){t=e;e=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{t=LCharacter.__rev_names__[e]}Object.defineProperty(this,"__char__",{value:e,enumerable:true});if(t){Object.defineProperty(this,"__name__",{value:t,enumerable:true})}}LCharacter.__names__=characters;LCharacter.__rev_names__={};Object.keys(LCharacter.__names__).forEach(function(e){var t=LCharacter.__names__[e];LCharacter.__rev_names__[t]=e});LCharacter.prototype.toUpperCase=function(){return LCharacter(this.__char__.toUpperCase())};LCharacter.prototype.toLowerCase=function(){return LCharacter(this.__char__.toLowerCase())};LCharacter.prototype.toString=function(){return"#\\"+(this.__name__||this.__char__)};LCharacter.prototype.valueOf=LCharacter.prototype.serialize=function(){return this.__char__};function LString(e){if(typeof this!=="undefined"&&!(this instanceof LString)||typeof this==="undefined"){return new LString(e)}if(e instanceof Array){this.__string__=e.map(function(e,t){typecheck("LString",e,"character",t+1);return e.toString()}).join("")}else{this.__string__=e.valueOf()}}{var ignore=["length","constructor"];var _keys=Object.getOwnPropertyNames(String.prototype).filter(function(e){return!ignore.includes(e)});var wrap=function e(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r0){r.push(this.__string__.substring(0,e))}r.push(t);if(e1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof LNumber){return e}if(typeof this!=="undefined"&&!(this instanceof LNumber)||typeof this==="undefined"){return new LNumber(e,t)}if(typeof e==="undefined"){throw new Error("Invalid LNumber constructor call")}var r=LNumber.getType(e);if(LNumber.types[r]){return LNumber.types[r](e,t)}var n=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!n){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(n){var a=e,o=_slicedToArray(a,2),u=o[0],s=o[1];if(u instanceof LString){u=u.valueOf()}if(s instanceof LNumber){s=s.valueOf()}var c=u.match(/^([+-])/);var l=false;if(c){u=u.replace(/^[+-]/,"");if(c[1]==="-"){l=true}}}if(Number.isNaN(e)){return LFloat(e)}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(n){var f;switch(s){case 8:f="0o";break;case 16:f="0x";break;case 2:f="0b";break;case 10:f="";break}if(typeof f==="undefined"){var _=BigInt(s);i=_toConsumableArray(u).map(function(e,t){return BigInt(parseInt(e,s))*pow(_,BigInt(t))}).reduce(function(e,t){return e+t})}else{i=BigInt(f+u)}}else{i=BigInt(e)}if(l){i*=BigInt(-1)}}else{i=e}return LBigInteger(i,true)}else if(typeof BN!=="undefined"&&!(e instanceof BN)){if(e instanceof Array){return LBigInteger(_construct(BN,_toConsumableArray(e)))}return LBigInteger(new BN(e))}else if(n){this.constant(parseInt(u,s),"integer")}else{this.constant(e,"integer")}}LNumber.prototype.constant=function(e,t){Object.defineProperty(this,"__value__",{value:e,enumerable:true});Object.defineProperty(this,"__type__",{value:t,enumerable:true})};LNumber.types={float:function e(t){return new LFloat(t)},complex:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!LNumber.isComplex(t)){t={im:0,re:t}}return new LComplex(t,r)},rational:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!LNumber.isRational(t)){t={num:t,denom:1}}return new LRational(t,r)}};LNumber.prototype.serialize=function(){return this.__value__};LNumber.prototype.isNaN=function(){return Number.isNaN(this.__value__)};LNumber.prototype.gcd=function(e){var t=this.abs();e=e.abs();if(e.cmp(t)===1){var r=t;t=e;e=r}while(true){t=t.rem(e);if(t.cmp(0)===0){return e}e=e.rem(t);if(e.cmp(0)===0){return t}}};LNumber.isFloat=function e(t){return t instanceof LFloat||Number(t)===t&&t%1!==0};LNumber.isNumber=function(e){return e instanceof LNumber||LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){if(!e){return false}var t=e instanceof LComplex||(LNumber.isNumber(e.im)||Number.isNaN(e.im))&&(LNumber.isNumber(e.re)||Number.isNaN(e.re));return t};LNumber.isRational=function(e){if(!e){return false}return e instanceof LRational||LNumber.isNumber(e.num)&&LNumber.isNumber(e.denom)};LNumber.isInteger=function(e){if(!(LNumber.isNative(e)||e instanceof LNumber)){return false}if(LNumber.isFloat(e)){return false}if(LNumber.isRational(e)){return false}if(LNumber.isComplex(e)){return false}return true};LNumber.isNative=function(e){return typeof e==="bigint"||typeof e==="number"};LNumber.isBigInteger=function(e){return e instanceof LBigInteger||typeof e==="bigint"||LNumber.isBN(e)};LNumber.isBN=function(e){return typeof BN!=="undefined"&&e instanceof BN};LNumber.getArgsType=function(e,t){if(e instanceof LFloat||t instanceof LFloat){return LFloat}if(e instanceof LBigInteger||t instanceof LBigInteger){return LBigInteger}return LNumber};LNumber.prototype.toString=function(e){if(Number.isNaN(this.__value__)){return"+nan.0"}if(e>=2&&e<36){return this.__value__.toString(e)}return this.__value__.toString()};LNumber.prototype.asType=function(e){var t=LNumber.getType(this);return LNumber.types[t]?LNumber.types[t](e):LNumber(e)};LNumber.prototype.isBigNumber=function(){return typeof this.__value__==="bigint"||typeof BN!=="undefined"&&!(this.value instanceof BN)};["floor","ceil","round"].forEach(function(e){LNumber.prototype[e]=function(){if(this["float"]||LNumber.isFloat(this.__value__)){return LNumber(Math[e](this.__value__))}else{return LNumber(Math[e](this.valueOf()))}}});LNumber.prototype.valueOf=function(){if(LNumber.isNative(this.__value__)){return Number(this.__value__)}else if(LNumber.isBN(this.__value__)){return this.__value__.toNumber()}};var matrix=function(){var e=function e(t,r){return[t,r]};return{bigint:{bigint:e,float:function e(t,r){return[LFloat(t.valueOf()),r]},rational:function e(t,r){return[{num:t,denom:1},r]},complex:function e(t,r){return[{im:0,re:t},r]}},integer:{integer:e,float:function e(t,r){return[LFloat(t.valueOf()),r]},rational:function e(t,r){return[{num:t,denom:1},r]},complex:function e(t,r){return[{im:0,re:t},r]}},float:{bigint:function e(t,r){return[t,r&&LFloat(r.valueOf())]},integer:function e(t,r){return[t,r&&LFloat(r.valueOf())]},float:e,rational:function e(t,r){return[t,r&&LFloat(r.valueOf())]},complex:function e(t,r){return[{re:t,im:LFloat(0)},r]}},complex:{bigint:t("bigint"),integer:t("integer"),float:t("float"),rational:t("rational"),complex:function e(t,r){var n=LNumber.coerce(t.__re__,r.__re__),i=_slicedToArray(n,2),a=i[0],o=i[1];var u=LNumber.coerce(t.__im__,r.__im__),s=_slicedToArray(u,2),c=s[0],l=s[1];return[{im:c,re:a},{im:l,re:o}]}},rational:{bigint:function e(t,r){return[t,r&&{num:r,denom:1}]},integer:function e(t,r){return[t,r&&{num:r,denom:1}]},float:function e(t,r){return[LFloat(t.valueOf()),r]},rational:e,complex:function e(t,r){return[{im:coerce(t.__type__,r.__im__.__type__,0)[0],re:coerce(t.__type__,r.__re__.__type__,t)[0]},{im:coerce(t.__type__,r.__im__.__type__,r.__im__)[0],re:coerce(t.__type__,r.__re__.__type__,r.__re__)[0]}]}}};function t(r){return function(e,t){return[{im:coerce(r,e.__im__.__type__,0,e.__im__)[1],re:coerce(r,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(r,e.__im__.__type__,0,0)[1],re:coerce(r,t.__type__,0,t)[1]}]}}}();function coerce(e,t,r,n){return matrix[e][t](r,n)}LNumber.coerce=function(e,t){var r=LNumber.getType(e);var n=LNumber.getType(t);if(!matrix[r]){throw new Error("LNumber::coerce unknown lhs type ".concat(r))}else if(!matrix[r][n]){throw new Error("LNumber::coerce unknown rhs type ".concat(n))}var i=matrix[r][n](e,t);return i.map(function(e){return LNumber(e,true)})};LNumber.prototype.coerce=function(e){if(!(typeof e==="number"||e instanceof LNumber)){throw new Error("LNumber: you can't coerce ".concat(type(e)))}if(typeof e==="number"){e=LNumber(e)}return LNumber.coerce(this,e)};LNumber.getType=function(e){if(e instanceof LNumber){return e.__type__}if(LNumber.isFloat(e)){return"float"}if(LNumber.isComplex(e)){return"complex"}if(LNumber.isRational(e)){return"rational"}if(typeof e==="number"){return"integer"}if(typeof BigInt!=="undefined"&&typeof e!=="bigint"||typeof BN!=="undefined"&&!(e instanceof BN)){return"bigint"}};LNumber.prototype.isFloat=function(){return!!(LNumber.isFloat(this.__value__)||this["float"])};var mapping={add:"+",sub:"-",mul:"*",div:"/",rem:"%",or:"|",and:"&",neg:"~",shl:">>",shr:"<<"};var rev_mapping={};Object.keys(mapping).forEach(function(t){rev_mapping[mapping[t]]=t;LNumber.prototype[t]=function(e){return this.op(mapping[t],e)}});LNumber._ops={"*":function e(t,r){return t*r},"+":function e(t,r){return t+r},"-":function e(t,r){if(typeof r==="undefined"){return-t}return t-r},"/":function e(t,r){return t/r},"%":function e(t,r){return t%r},"|":function e(t,r){return t|r},"&":function e(t,r){return t&r},"~":function e(t){return~t},">>":function e(t,r){return t>>r},"<<":function e(t,r){return t<1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof LComplex)||typeof this==="undefined"){return new LComplex(e,t)}if(e instanceof LComplex){return LComplex({im:e.__im__,re:e.__re__})}if(LNumber.isNumber(e)&&t){if(!t){return Number(e)}}else if(!LNumber.isComplex(e)){var r="Invalid constructor call for LComplex expect &(:im :re ) object but got ".concat(toString(e));throw new Error(r)}var n=e.im instanceof LNumber?e.im:LNumber(e.im);var i=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,i)}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.constant=function(e,t){Object.defineProperty(this,"__im__",{value:e,enumerable:true});Object.defineProperty(this,"__re__",{value:t,enumerable:true});Object.defineProperty(this,"__type__",{value:"complex",enumerable:true})};LComplex.prototype.serialize=function(){return{re:this.__re__,im:this.__im__}};LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var t=LFloat(this.__im__).toRational(e);var r=LFloat(this.__re__).toRational(e);return LComplex({im:t,re:r})}return this};LComplex.prototype.pow=function(e){throw new Error("Not yet implemented")};LComplex.prototype.add=function(e){return this.complex_op("add",e,function(e,t,r,n){return{re:e.add(t),im:r.add(n)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,t=this.__im__;var r,n;if(e instanceof LFloat){r=e.toRational().mul(e.toRational())}else{r=e.mul(e)}if(t instanceof LFloat){n=t.toRational().mul(t.toRational())}else{n=t.mul(t)}return r.add(n)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.conjugate=function(){return LComplex({re:this.__re__,im:this.__im__.sub()})};LComplex.prototype.sqrt=function(){var e=this.modulus();var t,r;if(e.cmp(0)===0){t=r=e}else if(this.__re__.cmp(0)===1){t=LFloat(.5).mul(e.add(this.__re__)).sqrt();r=this.__im__.div(t).div(2)}else{r=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){r=r.sub()}t=this.__im__.div(r).div(2)}return LComplex({im:r,re:t})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var t=this.__re__.div(e);var r=this.__im__.div(e);return LComplex({re:t,im:r})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}if(this.cmp(e)===0){var n=this.coerce(e),i=_slicedToArray(n,2),a=i[0],o=i[1];var u=a.__im__.div(o.__im__);return u.coerce(o.__re__)[0]}var s=this.coerce(e),c=_slicedToArray(s,2),l=c[0],f=c[1];var _=f.factor();var p=f.conjugate();var h=l.mul(p);if(!LNumber.isComplex(h)){return h.div(_)}var d=h.__re__.op("/",_);var m=h.__im__.op("/",_);return LComplex({re:d,im:m})};LComplex.prototype.sub=function(e){return this.complex_op("sub",e,function(e,t,r,n){return{re:e.sub(t),im:r.sub(n)}})};LComplex.prototype.mul=function(e){return this.complex_op("mul",e,function(e,t,r,n){var i={re:e.mul(t).sub(r.mul(n)),im:e.mul(n).add(t.mul(r))};return i})};LComplex.prototype.complex_op=function(e,t,i){var a=this;var r=function e(t,r){var n=i(a.__re__,t,a.__im__,r);if("im"in n&&"re"in n){if(n.im.cmp(0)===0){return n.re}return LComplex(n,true)}return n};if(typeof t==="undefined"){return r()}if(LNumber.isNumber(t)&&!LNumber.isComplex(t)){if(!(t instanceof LNumber)){t=LNumber(t)}var n=t.asType(0);t={__im__:n,__re__:t}}else if(!LNumber.isComplex(t)){throw new Error("[LComplex::".concat(e,"] Invalid value"))}var o=t.__re__ instanceof LNumber?t.__re__:this.__re__.asType(t.__re__);var u=t.__im__ instanceof LNumber?t.__im__:this.__im__.asType(t.__im__);return r(o,u)};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,t){var r=LComplex._op[e];return this[r](t)};LComplex.prototype.cmp=function(e){var t=this.coerce(e),r=_slicedToArray(t,2),n=r[0],i=r[1];var a=n.__re__.coerce(i.__re__),o=_slicedToArray(a,2),u=o[0],s=o[1];var c=u.cmp(s);if(c!==0){return c}else{var l=n.__im__.coerce(i.__im__),f=_slicedToArray(l,2),_=f[0],p=f[1];return _.cmp(p)}};LComplex.prototype.valueOf=function(){return[this.__re__,this.__im__].map(function(e){return e.valueOf()})};LComplex.prototype.toString=function(){var e;if(this.__re__.cmp(0)!==0){e=[toString(this.__re__)]}else{e=[]}var t=this.__im__.valueOf();var r=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(t);var n=toString(this.__im__);if(!r&&!Number.isNaN(t)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}n=n.replace(/^-/,"")}e.push(n);e.push("i");return e.join("")};function LFloat(e){if(typeof this!=="undefined"&&!(this instanceof LFloat)||typeof this==="undefined"){return new LFloat(e)}if(!LNumber.isNumber(e)){throw new Error("Invalid constructor call for LFloat")}if(e instanceof LNumber){return LFloat(e.valueOf())}if(typeof e==="number"){if(Object.is(e,-0)){Object.defineProperty(this,"_minus",{value:true})}this.constant(e,"float")}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){if(this.__value__===Number.NEGATIVE_INFINITY){return"-inf.0"}if(this.__value__===Number.POSITIVE_INFINITY){return"+inf.0"}if(Number.isNaN(this.__value__)){return"+nan.0"}var e=this.__value__.toString();if(!LNumber.isFloat(this.__value__)&&!e.match(/e/i)){var t=e+".0";return this._minus?"-"+t:t}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,t){if(t instanceof LNumber){t=t.__value__}var r=LNumber._ops[e];if(e==="/"&&this.__value__===0&&t===0){return NaN}return LFloat(r(this.__value__,t))};LFloat.prototype.toRational=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){return toRational(this.__value__.valueOf())}return approxRatio(e.valueOf())(this.__value__.valueOf())};LFloat.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){var t=LFloat(Math.sqrt(-e));return LComplex({re:0,im:t})}return LFloat(Math.sqrt(e))};LFloat.prototype.abs=function(){var e=this.valueOf();if(e<0){e=-e}return LFloat(e)};var toRational=approxRatio(1e-10);function approxRatio(n){return function(e){var t=function e(n,t,r){var i=function e(t,r){return r0){i=simplest_rational2(n,r)}else if(n.cmp(r)<=0){i=r}else if(r.cmp(0)>0){i=simplest_rational2(r,n)}else if(t.cmp(0)<0){i=LNumber(simplest_rational2(n.sub(),r.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(t)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,t){var r=LNumber(e).floor();var n=LNumber(t).floor();if(e.cmp(r)<1){return r}else if(r.cmp(n)===0){var i=LNumber(1).div(t.sub(n));var a=LNumber(1).div(e.sub(r));return r.add(LNumber(1).div(simplest_rational2(i,a)))}else{return r.add(LNumber(1))}}function LRational(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof LRational)||typeof this==="undefined"){return new LRational(e,t)}if(!LNumber.isRational(e)){throw new Error("Invalid constructor call for LRational")}var r,n;if(e instanceof LRational){r=LNumber(e.__num__);n=LNumber(e.__denom__)}else{r=LNumber(e.num);n=LNumber(e.denom)}if(!t&&n.cmp(0)!==0){var i=r.op("%",n).cmp(0)===0;if(i){return LNumber(r.div(n))}}this.constant(r,n)}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.constant=function(e,t){Object.defineProperty(this,"__num__",{value:e,enumerable:true});Object.defineProperty(this,"__denom__",{value:t,enumerable:true});Object.defineProperty(this,"__type__",{value:"rational",enumerable:true})};LRational.prototype.serialize=function(){return{num:this.__num__,denom:this.__denom__}};LRational.prototype.pow=function(e){var t=e.cmp(0);if(t===0){return LNumber(1)}if(t===-1){e=e.sub();var r=this.__denom__.pow(e);var n=this.__num__.pow(e);return LRational({num:r,denom:n})}var i=this;e=e.valueOf();while(e>1){i=i.mul(this);e--}return i};LRational.prototype.sqrt=function(){var e=this.__num__.sqrt();var t=this.__denom__.sqrt();if(e instanceof LFloat||t instanceof LFloat){return e.div(t)}return LRational({num:e,denom:t})};LRational.prototype.abs=function(){var e=this.__num__;var t=this.__denom__;if(e.cmp(0)===-1){e=e.sub()}if(t.cmp(0)!==1){t=t.sub()}return LRational({num:e,denom:t})};LRational.prototype.cmp=function(e){return LNumber(this.valueOf(),true).cmp(e)};LRational.prototype.toString=function(){var e=this.__num__.gcd(this.__denom__);var t,r;if(e.cmp(1)!==0){t=this.__num__.div(e);if(t instanceof LRational){t=LNumber(t.valueOf(true))}r=this.__denom__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}}else{t=this.__num__;r=this.__denom__}var n=this.cmp(0)<0;if(n){if(t.abs().cmp(r.abs())===0){return t.toString()}}else if(t.cmp(r)===0){return t.toString()}return t.toString()+"/"+r.toString()};LRational.prototype.valueOf=function(e){if(this.__denom__.cmp(0)===0){if(this.__num__.cmp(0)<0){return Number.NEGATIVE_INFINITY}return Number.POSITIVE_INFINITY}if(e){return LNumber._ops["/"](this.__num__.value,this.__denom__.value)}return LFloat(this.__num__.valueOf()).div(this.__denom__.valueOf())};LRational.prototype.mul=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=this.__num__.mul(e.__num__);var r=this.__denom__.mul(e.__denom__);return LRational({num:t,denom:r})}var n=LNumber.coerce(this,e),i=_slicedToArray(n,2),a=i[0],o=i[1];return a.mul(o)};LRational.prototype.div=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=this.__num__.mul(e.__denom__);var r=this.__denom__.mul(e.__num__);return LRational({num:t,denom:r})}var n=LNumber.coerce(this,e),i=_slicedToArray(n,2),a=i[0],o=i[1];var u=a.div(o);return u};LRational.prototype._op=function(e,t){return this[rev_mapping[e]](t)};LRational.prototype.sub=function(e){if(typeof e==="undefined"){return this.mul(-1)}if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=e.__num__.sub();var r=e.__denom__;return this.add(LRational({num:t,denom:r}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var n=LNumber.coerce(this,e),i=_slicedToArray(n,2),a=i[0],o=i[1];return a.add(o)};LRational.prototype.add=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=this.__denom__;var r=e.__denom__;var n=this.__num__;var i=e.__num__;var a,o;if(t!==r){o=r.mul(n).add(i.mul(t));a=t.mul(r)}else{o=n.add(i);a=t}return LRational({num:o,denom:a})}if(LNumber.isFloat(e)){return LFloat(this.valueOf()).add(e)}var u=LNumber.coerce(this,e),s=_slicedToArray(u,2),c=s[0],l=s[1];return c.add(l)};function LBigInteger(e,t){if(typeof this!=="undefined"&&!(this instanceof LBigInteger)||typeof this==="undefined"){return new LBigInteger(e,t)}if(e instanceof LBigInteger){return LBigInteger(e.__value__,e._native)}if(!LNumber.isBigInteger(e)){throw new Error("Invalid constructor call for LBigInteger")}this.constant(e,"bigint");Object.defineProperty(this,"_native",{value:t})}LBigInteger.prototype=Object.create(LNumber.prototype);LBigInteger.prototype.constructor=LBigInteger;LBigInteger.bn_op={"+":"iadd","-":"isub","*":"imul","/":"idiv","%":"imod","|":"ior","&":"iand","~":"inot","<<":"ishrn",">>":"ishln"};LBigInteger.prototype.serialize=function(){return this.__value__.toString()};LBigInteger.prototype._op=function(e,t){if(typeof t==="undefined"){if(LNumber.isBN(this.__value__)){e=LBigInteger.bn_op[e];return LBigInteger(this.__value__.clone()[e](),false)}return LBigInteger(LNumber._ops[e](this.__value__),true)}if(LNumber.isBN(this.__value__)&&LNumber.isBN(t.__value__)){e=LBigInteger.bn_op[e];return LBigInteger(this.__value__.clone()[e](t),false)}var r=LNumber._ops[e](this.__value__,t.__value__);if(e==="/"){var n=this.op("%",t).cmp(0)===0;if(n){return LNumber(r)}return LRational({num:this,denom:t})}return LBigInteger(r,true)};LBigInteger.prototype.sqrt=function(){var e;var t=this.cmp(0)<0;if(LNumber.isNative(this.__value__)){e=LNumber(Math.sqrt(t?-this.valueOf():this.valueOf()))}else if(LNumber.isBN(this.__value__)){e=t?this.__value__.neg().sqrt():this.__value__.sqrt()}if(t){return LComplex({re:0,im:e})}return e};LNumber.NaN=LNumber(NaN);function InputPort(e){var n=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");read_only(this,"__type__",text_port);var i;Object.defineProperty(this,"__parser__",{enumerable:true,get:function e(){return i},set:function e(t){typecheck("InputPort::__parser__",t,"parser");i=t}});this._read=e;this._with_parser=this._with_init_parser.bind(this,_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(n.char_ready()){t.next=5;break}t.next=3;return n._read();case 3:r=t.sent;i=new Parser(r,{env:n});case 5:return t.abrupt("return",n.__parser__);case 6:case"end":return t.stop()}},e)})));this.char_ready=function(){return!!this.__parser__&&this.__parser__.__lexer__.peek()!==eof};this._make_defaults()}InputPort.prototype._make_defaults=function(){this.read=this._with_parser(function(e){return e.read_object()});this.read_line=this._with_parser(function(e){return e.__lexer__.read_line()});this.read_char=this._with_parser(function(e){return e.__lexer__.read_char()});this.read_string=this._with_parser(function(e,t){if(!LNumber.isInteger(t)){var r=LNumber.getType(t);typeErrorMessage("read-string",r,"integer")}return e.__lexer__.read_string(t.valueOf())});this.peek_char=this._with_parser(function(e){return e.__lexer__.peek_char()})};InputPort.prototype._with_init_parser=function(u,s){var c=this;return _asyncToGenerator(_regeneratorRuntime.mark(function e(){var r,n,i,a,o=arguments;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return u.call(c);case 2:r=t.sent;for(n=o.length,i=new Array(n),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");read_only(this,"__type__",text_port);this.write=e}OutputPort.prototype.is_open=function(){return this._closed!==true};OutputPort.prototype.close=function(){Object.defineProperty(this,"_closed",{get:function e(){return true},set:function e(){},configurable:false,enumerable:false});this.write=function(){throw new Error("output-port: port is closed")}};OutputPort.prototype.flush=function(){};OutputPort.prototype.toString=function(){return"#"};var BufferedOutputPort=function(e){_inherits(r,e);function r(e){var t;_classCallCheck(this,r);t=_callSuper(this,r,[function(){var e;return(e=t)._write.apply(e,arguments)}]);typecheck("BufferedOutputPort",e,"function");read_only(_assertThisInitialized(t),"_fn",e,{hidden:true});read_only(_assertThisInitialized(t),"_buffer",[],{hidden:true});return t}_createClass(r,[{key:"flush",value:function e(){if(this._buffer.length){this._fn(this._buffer.join(""));this._buffer.length=0}}},{key:"_write",value:function e(){var t=this;for(var r=arguments.length,n=new Array(r),i=0;i"};OutputStringPort.prototype.valueOf=function(){return this.__buffer__.map(function(e){return e.valueOf()}).join("")};function OutputFilePort(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,t)}typecheck("OutputFilePort",e,"string");read_only(this,"__filename__",e);read_only(this,"_fd",t.valueOf(),{hidden:true});read_only(this,"__type__",text_port);this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}r.fs().write(r._fd,e,function(e){if(e){throw e}})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(){if(!this._fs){this._fs=this.internal("fs")}return this._fs};OutputFilePort.prototype.internal=function(e){return user_env.get("**internal-env**").get(e)};OutputFilePort.prototype.close=function(){var n=this;return new Promise(function(t,r){n.fs().close(n._fd,function(e){if(e){r(e)}else{read_only(n,"_fd",null,{hidden:true});OutputPort.prototype.close.call(n);t()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof InputStringPort)||typeof this==="undefined"){return new InputStringPort(e)}typecheck("InputStringPort",e,"string");t=t||global_env;e=e.valueOf();this._with_parser=this._with_init_parser.bind(this,function(){if(!r.__parser__){r.__parser__=new Parser(e,{env:t})}return r.__parser__});read_only(this,"__type__",text_port);this._make_defaults()}InputStringPort.prototype.char_ready=function(){return true};InputStringPort.prototype=Object.create(InputPort.prototype);InputStringPort.prototype.constructor=InputStringPort;InputStringPort.prototype.toString=function(){return"#"};function InputByteVectorPort(e){if(typeof this!=="undefined"&&!(this instanceof InputByteVectorPort)||typeof this==="undefined"){return new InputByteVectorPort(e)}typecheck("InputByteVectorPort",e,"uint8array");read_only(this,"__vector__",e);read_only(this,"__type__",binary_port);var r=0;Object.defineProperty(this,"__index__",{enumerable:true,get:function e(){return r},set:function e(t){typecheck("InputByteVectorPort::__index__",t,"number");if(t instanceof LNumber){t=t.valueOf()}if(typeof t==="bigint"){t=Number(t)}if(Math.floor(t)!==t){throw new Error("InputByteVectorPort::__index__ value is "+"not integer")}r=t}})}InputByteVectorPort.prototype=Object.create(InputPort.prototype);InputByteVectorPort.prototype.constructor=InputByteVectorPort;InputByteVectorPort.prototype.toString=function(){return"#"};InputByteVectorPort.prototype.close=function(){var t=this;read_only(this,"__vector__",_nil);var r=function e(){throw new Error("Input-binary-port: port is closed")};["read_u8","close","peek_u8","read_u8_vector"].forEach(function(e){t[e]=r});this.u8_ready=this.char_ready=function(){return false}};InputByteVectorPort.prototype.u8_ready=function(){return true};InputByteVectorPort.prototype.peek_u8=function(){if(this.__index__>=this.__vector__.length){return eof}return this.__vector__[this.__index__]};InputByteVectorPort.prototype.skip=function(){if(this.__index__<=this.__vector__.length){++this.__index__}};InputByteVectorPort.prototype.read_u8=function(){var e=this.peek_u8();this.skip();return e};InputByteVectorPort.prototype.read_u8_vector=function(e){if(typeof e==="undefined"){e=this.__vector__.length}else if(e>this.__index__+this.__vector__.length){e=this.__index__+this.__vector__.length}if(this.peek_u8()===eof){return eof}return this.__vector__.slice(this.__index__,e)};function OutputByteVectorPort(){if(typeof this!=="undefined"&&!(this instanceof OutputByteVectorPort)||typeof this==="undefined"){return new OutputByteVectorPort}read_only(this,"__type__",binary_port);read_only(this,"_buffer",[],{hidden:true});this.write=function(e){typecheck("write",e,["number","uint8array"]);if(LNumber.isNumber(e)){this._buffer.push(e.valueOf())}else{var t;(t=this._buffer).push.apply(t,_toConsumableArray(Array.from(e)))}};Object.defineProperty(this,"__buffer__",{enumerable:true,get:function e(){return Uint8Array.from(this._buffer)}})}OutputByteVectorPort.prototype=Object.create(OutputPort.prototype);OutputByteVectorPort.prototype.constructor=OutputByteVectorPort;OutputByteVectorPort.prototype.close=function(){OutputPort.prototype.close.call(this);read_only(this,"_buffer",null,{hidden:true})};OutputByteVectorPort.prototype._close_guard=function(){if(this._closed){throw new Error("output-port: binary port is closed")}};OutputByteVectorPort.prototype.write_u8=function(e){typecheck("OutputByteVectorPort::write_u8",e,"number");this.write(e)};OutputByteVectorPort.prototype.write_u8_vector=function(e){typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};OutputByteVectorPort.prototype.toString=function(){return"#"};OutputByteVectorPort.prototype.valueOf=function(){return this.__buffer__};function InputFilePort(e,t){if(typeof this!=="undefined"&&!(this instanceof InputFilePort)||typeof this==="undefined"){return new InputFilePort(e,t)}InputStringPort.call(this,e);typecheck("InputFilePort",t,"string");read_only(this,"__filename__",t)}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};function InputBinaryFilePort(e,t){if(typeof this!=="undefined"&&!(this instanceof InputBinaryFilePort)||typeof this==="undefined"){return new InputBinaryFilePort(e,t)}InputByteVectorPort.call(this,e);typecheck("InputBinaryFilePort",t,"string");read_only(this,"__filename__",t)}InputBinaryFilePort.prototype=Object.create(InputByteVectorPort.prototype);InputBinaryFilePort.prototype.constructor=InputBinaryFilePort;InputBinaryFilePort.prototype.toString=function(){return"#")};function OutputBinaryFilePort(e,t){var i=this;if(typeof this!=="undefined"&&!(this instanceof OutputBinaryFilePort)||typeof this==="undefined"){return new OutputBinaryFilePort(e,t)}typecheck("OutputBinaryFilePort",e,"string");read_only(this,"__filename__",e);read_only(this,"_fd",t.valueOf(),{hidden:true});read_only(this,"__type__",binary_port);var a;this.write=function(e){typecheck("write",e,["number","uint8array"]);var n;if(!a){a=i.internal("fs")}if(LNumber.isNumber(e)){n=new Uint8Array([e.valueOf()])}else{n=new Uint8Array(Array.from(e))}return new Promise(function(t,r){a.write(i._fd,n,function(e){if(e){r(e)}else{t()}})})}}OutputBinaryFilePort.prototype=Object.create(OutputFilePort.prototype);OutputBinaryFilePort.prototype.constructor=OutputBinaryFilePort;OutputBinaryFilePort.prototype.write_u8=function(e){typecheck("OutputByteVectorPort::write_u8",e,"number");this.write(e)};OutputBinaryFilePort.prototype.write_u8_vector=function(e){typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#"};function Interpreter(e){var t=this;var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},n=r.stderr,i=r.stdin,a=r.stdout,o=r.command_line,u=o===void 0?null:o,s=_objectWithoutProperties(r,_excluded3);if(typeof this!=="undefined"&&!(this instanceof Interpreter)||typeof this==="undefined"){return new Interpreter(e,_objectSpread({stdin:i,stdout:a,stderr:n,command_line:u},s))}if(typeof e==="undefined"){e="anonymous"}this.__env__=user_env.inherit(e,s);this.__env__.set("parent.frame",doc("parent.frame",function(){return t.__env__},global_env.__env__["parent.frame"].__doc__));var c="**interaction-environment-defaults**";this.set(c,get_props(s).concat(c));var l=internal_env.inherit("internal-".concat(e));if(is_port(i)){l.set("stdin",i)}if(is_port(n)){l.set("stderr",n)}if(is_port(a)){l.set("stdout",a)}l.set("command-line",u);set_interaction_env(this.__env__,l)}Interpreter.prototype.exec=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=t.use_dynamic,n=r===void 0?false:r,i=t.dynamic_env,a=t.env;typecheck("Interpreter::exec",e,["string","array"],1);typecheck("Interpreter::exec",n,"boolean",2);if(!a){a=this.__env__}if(!i){i=a}global_env.set("**interaction-environment**",this.__env__);return exec(e,{env:a,dynamic_env:i,use_dynamic:n})};Interpreter.prototype.get=function(e){var t=this.__env__.get(e);if(is_function(t)){var r=new LambdaContext({env:this.__env__});return t.bind(r)}return t};Interpreter.prototype.set=function(e,t){return this.__env__.set(e,t)};Interpreter.prototype.constant=function(e,t){return this.__env__.constant(e,t)};function LipsError(e,t){this.name="LipsError";this.message=e;this.args=t;this.stack=(new Error).stack}LipsError.prototype=new Error;LipsError.prototype.constructor=LipsError;var IgnoreException=function(e){_inherits(t,e);function t(){_classCallCheck(this,t);return _callSuper(this,t,arguments)}return _createClass(t)}(_wrapNativeSuper(Error));function Environment(e,t,r){if(arguments.length===1){if(_typeof$1(arguments[0])==="object"){e=arguments[0];t=null}else if(typeof arguments[0]==="string"){e={};t=null;r=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=t;this.__name__=r||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};Environment.prototype.fs=function(){return this.get("**fs**")};Environment.prototype.unset=function(e){if(e instanceof LSymbol){e=e.valueOf()}if(e instanceof LString){e=e.valueOf()}delete this.__env__[e]};Environment.prototype.inherit=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(_typeof$1(e)==="object"){t=e}if(!e||_typeof$1(e)==="object"){e="child of "+(this.__name__||"unknown")}return new Environment(t||{},this,e)};Environment.prototype.doc=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(t){if(!r){t=trim_lines(t)}this.__docs__.set(e,t);return this}if(this.__docs__.has(e)){return this.__docs__.get(e)}if(this.__parent__){return this.__parent__.doc(e)}};Environment.prototype.new_frame=function(e,t){var n=this.inherit("__frame__");n.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1;e=e.valueOf();var t=n.__parent__;if(!is_env(t)){return _nil}if(e<=0){return t}var r=t.get("parent.frame");return r(e-1)},global_env.__env__["parent.frame"].__doc__));t.callee=e;n.set("arguments",t);return n};Environment.prototype._lookup=function(e){if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(this.__env__.hasOwnProperty(e)){return Value(this.__env__[e])}if(this.__parent__){return this.__parent__._lookup(e)}};Environment.prototype.toString=function(){return"#"};Environment.prototype.clone=function(){var t=this;var r={};Object.keys(this.__env__).forEach(function(e){r[e]=t.__env__[e]});return new Environment(r,this.__parent__,this.__name__)};Environment.prototype.merge=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"merge";typecheck("Environment::merge",e,"environment");return this.inherit(t,e.__env__)};function Value(e){if(typeof this!=="undefined"&&!(this instanceof Value)||typeof this==="undefined"){return new Value(e)}this.value=e}Value.isUndefined=function(e){return e instanceof Value&&typeof e.value==="undefined"};Value.prototype.valueOf=function(){return this.value};function Values(e){if(e.length){if(e.length===1){return e[0]}}if(typeof this!=="undefined"&&!(this instanceof Values)||typeof this==="undefined"){return new Values(e)}this.__values__=e}Values.prototype.toString=function(){return this.__values__.map(function(e){return toString(e)}).join("\n")};Values.prototype.valueOf=function(){return this.__values__};Environment.prototype.get=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};typecheck("Environment::get",e,["symbol","string"]);var r=t.throwError,n=r===void 0?true:r;var i=e;if(i instanceof LSymbol||i instanceof LString){i=i.valueOf()}var a=this._lookup(i);if(a instanceof Value){if(Value.isUndefined(a)){return undefined}return patch_value(a.valueOf())}var o;if(e instanceof LSymbol&&e[LSymbol.object]){o=e[LSymbol.object]}else if(typeof i==="string"){o=i.split(".").filter(Boolean)}if(o&&o.length>0){var u=o,s=_toArray(u),c=s[0],l=s.slice(1);a=this._lookup(c);if(l.length){try{if(a instanceof Value){a=a.valueOf()}else{a=get(root,c);if(is_function(a)){a=unbind(a)}}if(typeof a!=="undefined"){return get.apply(void 0,[a].concat(_toConsumableArray(l)))}}catch(e){throw e}}else if(a instanceof Value){return patch_value(a.valueOf())}a=get(root,i)}if(typeof a!=="undefined"){return a}if(n){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;typecheck("Environment::set",e,["string","symbol"]);if(LNumber.isNumber(t)){t=LNumber(t)}if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}this.__env__[e]=t;if(r){this.doc(e,r,true)}return this};Environment.prototype.constant=function(t,e){var r=this;if(this.__env__.hasOwnProperty(t)){throw new Error("Environment::constant: ".concat(t," already exists"))}if(arguments.length===1&&is_plain_object(arguments[0])){var n=arguments[0];Object.keys(n).forEach(function(e){r.constant(t,n[e])})}else{Object.defineProperty(this.__env__,t,{value:e,enumerable:true})}return this};Environment.prototype.has=function(e){return this.__env__.hasOwnProperty(e)};Environment.prototype.ref=function(e){var t=this;while(true){if(!t){break}if(t.has(e)){return t}t=t.__parent__}};Environment.prototype.parents=function(){var e=this;var t=[];while(e){t.unshift(e);e=e.__parent__}return t};function quote(e){if(is_promise(e)){return e.then(quote)}if(e instanceof Pair||e instanceof LSymbol){e[__data__]=true}return e}var native_lambda=_parse(tokenize('(lambda ()\n "[native code]"\n (throw "Invalid Invocation"))'))[0];var get=doc("get",function e(t){var r;for(var n=arguments.length,i=new Array(n>1?n-1:0),a=1;a0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("peek-char",e,"input-port");return e.peek_char()},"(peek-char port)\n\n This function reads and returns a character from the string\n port, or, if there is no more data in the string port, it\n returns an EOF."),"read-line":doc("read-line",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("read-line",e,"input-port");return e.read_line()},"(read-line port)\n\n This function reads and returns the next line from the input\n port."),"read-char":doc("read-char",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("read-char",e,"input-port");return e.read_char()},"(read-char port)\n\n This function reads and returns the next character from the\n input port."),read:doc("read",function(){var e=_asyncToGenerator(function(){var l=this;var f=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;return _regeneratorRuntime.mark(function e(){var r,n,i,a,o,u,s,c;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=l.env;if(!LString.isString(f)){t.next=30;break}n=false;i=false;t.prev=4;o=_asyncIterator(_parse(f,r));case 6:t.next=8;return o.next();case 8:if(!(n=!(u=t.sent).done)){t.next=14;break}s=u.value;return t.abrupt("return",s);case 11:n=false;t.next=6;break;case 14:t.next=20;break;case 16:t.prev=16;t.t0=t["catch"](4);i=true;a=t.t0;case 20:t.prev=20;t.prev=21;if(!(n&&o["return"]!=null)){t.next=25;break}t.next=25;return o["return"]();case 25:t.prev=25;if(!i){t.next=28;break}throw a;case 28:return t.finish(25);case 29:return t.finish(20);case 30:if(f===null){c=internal(r,"stdin")}else{c=f}typecheck_text_port("read",c,"input-port");return t.abrupt("return",c.read.call(r));case 33:case"end":return t.stop()}},e,null,[[4,16,20,30],[21,,25,29]])})()});function t(){return e.apply(this,arguments)}return t}(),"(read [string])\n\n This function, if used with a string, will parse it and\n return the LIPS code, if there is any. If called with a\n port, it will parse the next item from the port. If called\n without an input, it will read a string from standard input\n (using the browser's prompt or a user defined input method)\n and calls itself with that string. This function can be used\n together with `eval` to evaluate code from a string."),pprint:doc("pprint",function e(t){if(t instanceof Pair){t=new lips.Formatter(t.toString(true))["break"]().format();global_env.get("display").call(global_env,t)}else{global_env.get("write").call(global_env,t)}global_env.get("newline").call(global_env)},"(pprint expression)\n\n This function will pretty print its input to stdout. If it is called\n with a non-list, it will just call the print function on its\n input."),print:doc("print",function e(){var t=global_env.get("display");var r=global_env.get("newline");var n=this.use_dynamic;var i=global_env;var a=global_env;for(var o=arguments.length,u=new Array(o),s=0;s1?r-1:0),i=1;in.length){throw new Error("Not enough arguments")}var u=0;var s=global_env.get("repr");t=t.replace(a,function(e){var t=e[1];if(t==="~"){return"~"}else if(t==="%"){return"\n"}else{var r=n[u++];if(t==="a"){return s(r)}else{return s(r,true)}}});o=t.match(/~([\S])/);if(o){throw new Error("format: Unrecognized escape sequence ".concat(o[1]))}return t},"(format string n1 n2 ...)\n\n This function accepts a string template and replaces any\n escape sequences in its inputs:\n\n * ~a value as if printed with `display`\n * ~s value as if printed with `write`\n * ~% newline character\n * ~~ literal tilde '~'\n\n If there are missing inputs or other escape characters it\n will error."),display:doc("display",function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(r===null){r=internal(this,"stdout")}else{typecheck("display",r,"output-port")}var n=t;if(!(r instanceof OutputBinaryFilePort)){n=global_env.get("repr")(t)}r.write.call(global_env,n)},"(display string [port])\n\n This function outputs the string to the standard output or\n the port if given. No newline."),"display-error":doc("display-error",function e(){var t=internal(this,"stderr");var r=global_env.get("repr");for(var n=arguments.length,i=new Array(n),a=0;a1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=_objectWithoutProperties(t,_excluded4);var i=this;var o=this;var u;var s=_objectSpread(_objectSpread({},n),{},{env:this,dynamic_env:i,use_dynamic:r});var c=_evaluate(e.cdr.car,s);c=resolve_promises(c);function l(t,r,n){if(is_promise(t)){return t.then(function(e){return l(t,e,n)})}if(is_promise(r)){return r.then(function(e){return l(t,e,n)})}if(is_promise(n)){return n.then(function(e){return l(t,r,e)})}o.get("set-obj!").call(o,t,r,n);return n}if(e.car instanceof Pair&&LSymbol.is(e.car.car,".")){var f=e.car.cdr.car;var _=e.car.cdr.cdr.car;var p=_evaluate(f,{env:this,dynamic_env:i,use_dynamic:r,error:error});var h=_evaluate(_,{env:this,dynamic_env:i,use_dynamic:r,error:error});return l(p,h,c)}if(!(e.car instanceof LSymbol)){throw new Error("set! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var d=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(c,function(e){if(!u){var t=d.split(".");if(t.length>1){var r=t.pop();var n=t.join(".");var i=a.get(n,{throwError:false});if(i){l(i,r,e);return}}throw new Error("Unbound variable `"+d+"'")}u.set(d,e)})}),"(set! name value)\n\n Macro that can be used to set the value of the variable or slot (mutate it).\n set! searches the scope chain until it finds first non empty slot and sets it."),"unset!":doc(new Macro("set!",function(e){if(!(e.car instanceof LSymbol)){throw new Error("unset! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var t=e.car;var r=this.ref(t);if(r){delete r.__env__[t.__name__]}}),"(unset! name)\n\n Function to delete the specified name from environment.\n Trying to access the name afterwards will error."),"set-car!":doc("set-car!",function(e,t){typecheck("set-car!",e,"pair");e.car=t},"(set-car! obj value)\n\n Function that sets the car (first item) of the list/pair to specified value.\n The old value is lost."),"set-cdr!":doc("set-cdr!",function(e,t){typecheck("set-cdr!",e,"pair");e.cdr=t},"(set-cdr! obj value)\n\n Function that sets the cdr (tail) of the list/pair to specified value.\n It will destroy the list. The old tail is lost."),"empty?":doc("empty?",function(e){return typeof e==="undefined"||e===_nil},"(empty? object)\n\n Function that returns #t if value is nil (an empty list) or undefined."),gensym:doc("gensym",gensym,"(gensym)\n\n Generates a unique symbol that is not bound anywhere,\n to use with macros as meta name."),load:doc("load",function e(u,t){typecheck("load",u,"string");var s=this;if(s.__name__==="__frame__"){s=s.__parent__}if(!(t instanceof Environment)){if(s===global_env){t=s}else{t=this.get("**interaction-environment**")}}var c="**module-path**";var l=global_env.get(c,{throwError:false});u=u.valueOf();if(!u.match(/.[^.]+$/)){u+=".scm"}var r=u.match(/\.xcb$/);function f(e){if(r){e=unserialize_bin(e)}else{if(type(e)==="buffer"){e=e.toString()}e=e.replace(/^#!.*/,"");if(e.match(/^\{/)){e=unserialize(e)}}return exec(e,{env:t})}function n(e){return root.fetch(e).then(function(e){return r?e.arrayBuffer():e.text()}).then(function(e){if(r){e=new Uint8Array(e)}return e})}if(is_node()){return new Promise(function(){var r=_asyncToGenerator(_regeneratorRuntime.mark(function e(r,n){var i,a,o;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:i=nodeRequire("path");if(!l){t.next=6;break}l=l.valueOf();u=i.join(l,u);t.next=12;break;case 6:a=s.get("command-line",{throwError:false});if(!a){t.next=11;break}t.next=10;return a();case 10:o=t.sent;case 11:if(o&&o!==_nil){process.cwd();u=i.join(i.dirname(o.car.valueOf()),u)}case 12:global_env.set(c,i.dirname(u));nodeRequire("fs").readFile(u,function(e,t){if(e){n(e);global_env.set(c,l)}else{try{f(t).then(function(){r();global_env.set(c,l)})["catch"](n)}catch(e){n(e)}}});case 14:case"end":return t.stop()}},e)}));return function(e,t){return r.apply(this,arguments)}}())}if(l){l=l.valueOf();u=l+"/"+u.replace(/^\.?\/?/,"")}return n(u).then(function(e){global_env.set(c,u.replace(/\/[^/]*$/,""));return f(e)}).then(function(){})["finally"](function(){global_env.set(c,l)})},"(load filename)\n (load filename environment)\n\n Fetches the file (from disk or network) and evaluates its content as LIPS code.\n If the second argument is provided and it's an environment the evaluation\n will happen in that environment."),do:doc(new Macro("do",function(){var r=_asyncToGenerator(function(_,e){var p=this;var h=e.use_dynamic,d=e.error;return _regeneratorRuntime.mark(function e(){var r,n,u,s,i,c,l,a,o,f;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=p;n=r;u=r.inherit("do");s=_.car;i=_.cdr.car;c=_.cdr.cdr;if(c!==_nil){c=new Pair(LSymbol("begin"),c)}l={env:r,dynamic_env:n,use_dynamic:h,error:d};a=s;case 9:if(!(a!==_nil)){t.next=20;break}o=a.car;t.t0=u;t.t1=o.car;t.next=15;return _evaluate(o.cdr.car,l);case 15:t.t2=t.sent;t.t0.set.call(t.t0,t.t1,t.t2);a=a.cdr;t.next=9;break;case 20:l={env:u,dynamic_env:n,error:d};f=_regeneratorRuntime.mark(function e(){var r,n,i,a,o;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!(c!==_nil)){t.next=3;break}t.next=3;return lips.evaluate(c,l);case 3:r=s;n={};case 5:if(!(r!==_nil)){t.next=15;break}i=r.car;if(!(i.cdr.cdr!==_nil)){t.next=12;break}t.next=10;return _evaluate(i.cdr.cdr.car,l);case 10:a=t.sent;n[i.car.valueOf()]=a;case 12:r=r.cdr;t.next=5;break;case 15:o=Object.getOwnPropertySymbols(n);Object.keys(n).concat(o).forEach(function(e){u.set(e,n[e])});case 17:case"end":return t.stop()}},e)});case 22:t.next=24;return _evaluate(i.car,l);case 24:t.t3=t.sent;if(!(t.t3===false)){t.next=29;break}return t.delegateYield(f(),"t4",27);case 27:t.next=22;break;case 29:if(!(i.cdr!==_nil)){t.next=33;break}t.next=32;return _evaluate(i.cdr.car,l);case 32:return t.abrupt("return",t.sent);case 33:case"end":return t.stop()}},e)})()});return function(e,t){return r.apply(this,arguments)}}()),"(do (( )) (test return) . body)\n\n Iteration macro that evaluates the expression body in scope of the variables.\n On each loop it changes the variables according to the expression and runs\n test to check if the loop should continue. If test is a single value, the macro\n will return undefined. If the test is a pair of expressions the macro will\n evaluate and return the second expression after the loop exits."),if:doc(new Macro("if",function(r,e){var t=e.error,n=e.use_dynamic;var i=this;var a=this;var o={env:a,dynamic_env:i,use_dynamic:n,error:t};var u=function e(t){if(t===false){return _evaluate(r.cdr.cdr.car,o)}else{return _evaluate(r.cdr.car,o)}};if(r===_nil){throw new Error("too few expressions for `if`")}var s=_evaluate(r.car,o);return unpromise(s,u)}),"(if cond true-expr false-expr)\n\n Macro that evaluates cond expression and if the value is true, it\n evaluates and returns true-expression, if not it evaluates and returns\n false-expression."),"let-env":new Macro("let-env",function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=e.dynamic_env,n=e.use_dynamic,i=e.error;typecheck("let-env",t,"pair");var a=_evaluate(t.car,{env:this,dynamic_env:r,error:i,use_dynamic:n});return unpromise(a,function(e){typecheck("let-env",e,"environment");return _evaluate(Pair(LSymbol("begin"),t.cdr),{env:e,dynamic_env:r,error:i})})},"(let-env env . body)\n\n Special macro that evaluates body in context of given environment\n object."),letrec:doc(let_macro(Symbol["for"]("letrec")),"(letrec ((a value-a) (b value-b) ...) . body)\n\n Macro that creates a new environment, then evaluates and assigns values to\n names and then evaluates the body in context of that environment.\n Values are evaluated sequentially and the next value can access the\n previous values/names."),"letrec*":doc(let_macro(Symbol["for"]("letrec")),"(letrec* ((a value-a) (b value-b) ...) . body)\n\n Same as letrec but the order of execution of the binding is guaranteed,\n so you can use recursive code as well as referencing the previous binding.\n\n In LIPS both letrec and letrec* behave the same."),"let*":doc(let_macro(Symbol["for"]("let*")),"(let* ((a value-a) (b value-b) ...) . body)\n\n Macro similar to `let`, but the subsequent bindings after the first\n are evaluated in the environment including the previous let variables,\n so you can define one variable, and use it in the next's definition."),let:doc(let_macro(Symbol["for"]("let")),"(let ((a value-a) (b value-b) ...) . body)\n\n Macro that creates a new environment, then evaluates and assigns values to names,\n and then evaluates the body in context of that environment. Values are evaluated\n sequentially but you can't access previous values/names when the next are\n evaluated. You can only get them in the body of the let expression. (If you want\n to define multiple variables and use them in each other's definitions, use\n `let*`.)"),"begin*":doc(parallel("begin*",function(e){return e.pop()}),"(begin* . body)\n\n This macro is a parallel version of begin. It evaluates each expression\n in the body and if it's a promise it will await it in parallel and return\n the value of the last expression (i.e. it uses Promise.all())."),shuffle:doc("shuffle",function(e){typecheck("shuffle",e,["pair","nil","array"]);var t=global_env.get("random");if(e===_nil){return _nil}if(Array.isArray(e)){return shuffle(e.slice(),t)}var r=global_env.get("list->array")(e);r=shuffle(r,t);return global_env.get("array->list")(r)},"(shuffle obj)\n\n Order items in vector or list in random order."),begin:doc(new Macro("begin",function(e,t){var n=_objectSpread(_objectSpread({},t),{},{env:this});var i=global_env.get("list->array")(e);var a;return function t(){if(i.length){var e=i.shift();var r=_evaluate(e,n);return unpromise(r,function(e){a=e;return t()})}else{return a}}()}),"(begin . args)\n\n Macro that runs a list of expressions in order and returns the value\n of the last one. It can be used in places where you can only have a\n single expression, like (if)."),ignore:new Macro("ignore",function(e,t){var r=_objectSpread(_objectSpread({},t),{},{env:this,dynamic_env:this});_evaluate(new Pair(new LSymbol("begin"),e),r)},"(ignore . body)\n\n Macro that will evaluate the expression and swallow any promises that may\n be created. It will discard any value that may be returned by the last body\n expression. The code should have side effects and/or when it's promise\n it should resolve to undefined."),"call/cc":doc(Macro.defmacro("call/cc",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=_objectSpread({env:this},t);return unpromise(_evaluate(e.car,r),function(e){if(is_function(e)){return e(new Continuation(null))}})}),"(call/cc proc)\n\n Call-with-current-continuation.\n\n NOT SUPPORTED BY LIPS RIGHT NOW"),parameterize:doc(new Macro("parameterize",function(t,e){var i=e.dynamic_env;var a=i.inherit("parameterize").new_frame(null,{});var o=_objectSpread(_objectSpread({},e),{},{env:this});var u=t.car;if(!is_pair(u)){var r=type(u);throw new Error("Invalid syntax for parameterize expecting pair got ".concat(r))}function s(){var e=new Pair(new LSymbol("begin"),t.cdr);return _evaluate(e,_objectSpread(_objectSpread({},o),{},{dynamic_env:a}))}return function r(){var e=u.car;var n=e.car.valueOf();return unpromise(_evaluate(e.cdr.car,o),function(e){var t=i.get(n,{throwError:false});if(!is_parameter(t)){throw new Error("Unknown parameter ".concat(n))}a.set(n,t.inherit(e));if(!is_null(u.cdr)){u=u.cdr;return r()}else{return s()}})}()}),"(parameterize ((name value) ...)\n\n Macro that change the dynamic variable created by make-parameter."),"make-parameter":doc(new Macro("make-parameter",function(e,t){t.dynamic_env;var r=_evaluate(e.car,t);var n;if(e.cdr.car instanceof Pair){n=_evaluate(e.cdr.car,t)}return new Parameter(r,n)}),"(make-parameter init converter)\n\n Function creates new dynamic variable that can be custimized with parameterize\n macro. The value should be assigned to a variable e.g.:\n\n (define radix (make-parameter 10))\n\n The result value is a procedure that return the value of dynamic variable."),define:doc(Macro.defmacro("define",function(r,e){var n=this;if(r.car instanceof Pair&&r.car.car instanceof LSymbol){var t=new Pair(new LSymbol("define"),new Pair(r.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(r.car.cdr,r.cdr)))));return t}else if(e.macro_expand){return}e.dynamic_env=this;e.env=n;var i=r.cdr.car;var a;if(i instanceof Pair){i=_evaluate(i,e);a=true}else if(i instanceof LSymbol){i=n.get(i)}typecheck("define",r.car,"symbol");return unpromise(i,function(e){if(n.__name__===Syntax.__merge_env__){n=n.__parent__}if(a&&(is_function(e)&&is_lambda(e)||e instanceof Syntax||is_parameter(e))){e.__name__=r.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var t;if(r.cdr.cdr instanceof Pair&&LString.isString(r.cdr.cdr.car)){t=r.cdr.cdr.car.valueOf()}n.set(r.car,e,t,true)})}),'(define name expression)\n (define name expression "doc string")\n (define (function-name . args) . body)\n\n Macro for defining values. It can be used to define variables,\n or functions. If the first argument is list it will create a function\n with name being first element of the list. This form expands to\n `(define function-name (lambda args body))`'),"set-obj!":doc("set-obj!",function(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var i=_typeof$1(e);if(is_null(e)||i!=="object"&&i!=="function"){var a=typeErrorMessage("set-obj!",type(e),["object","function"]);throw new Error(a)}typecheck("set-obj!",t,["string","symbol","number"]);e=unbind(e);t=t.valueOf();if(arguments.length===2){delete e[t]}else if(is_prototype(e)&&is_function(r)){e[t]=unbind(r);e[t][__prototype__]=true}else if(is_function(r)||is_native(r)||r===_nil){e[t]=r}else{e[t]=r&&!is_prototype(r)?r.valueOf():r}if(props){var o=e[t];Object.defineProperty(e,t,_objectSpread(_objectSpread({},n),{},{value:o}))}},"(set-obj! obj key value)\n (set-obj! obj key value props)\n\n Function set a property of a JavaScript object. props should be a vector of pairs,\n passed to Object.defineProperty."),"null-environment":doc("null-environment",function(){return global_env.inherit("null")},"(null-environment)\n\n Returns a clean environment with only the standard library."),values:doc("values",function e(){for(var t=arguments.length,r=new Array(t),n=0;n1&&arguments[1]!==undefined?arguments[1]:{},y=e.use_dynamic,v=e.error;var g=this;var b;if(m.cdr instanceof Pair&&LString.isString(m.cdr.car)&&m.cdr.cdr!==_nil){b=m.cdr.car.valueOf()}function w(){var e=is_context(this)?this:{dynamic_env:g},r=e.dynamic_env;var n=g.inherit("lambda");r=r.inherit("lambda");if(this&&!is_context(this)){if(this&&!this.__instance__){Object.defineProperty(this,"__instance__",{enumerable:false,get:function e(){return true},set:function e(){},configurable:false})}n.set("this",this)}for(var t=arguments.length,i=new Array(t),a=0;a>> "+d.toString());if(d){_=d}var m=a.merge(n,Syntax.__merge_env__);if(r){return{expr:_,scope:m}}var y=_evaluate(_,_objectSpread(_objectSpread({},u),{},{env:m}));return clear_gensyms(y,h)}c=c.cdr}}catch(e){e.message+=" in macro: ".concat(v.toString(true));throw e}throw new Error("Invalid Syntax ".concat(e.toString(true)))},w);r.__code__=v;return r},"(syntax-rules () (pattern expression) ...)\n\n Base of hygienic macros, it will return a new syntax expander\n that works like Lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression) or 'expression\n\n Macro that returns a single LIPS expression as data (it won't evaluate the\n argument). It will return a list if put in front of LIPS code.\n And if put in front of a symbol it will return the symbol itself, not the value\n bound to that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code) or ,@code\n\n Special form used in the quasiquote macro. It evaluates the expression inside and\n splices the list into quasiquote's result. If it is not the last element of the\n expression, the computed value must be a pair."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code) or ,code\n\n Special form used in the quasiquote macro. It evaluates the expression inside and\n substitutes the value into quasiquote's result."),quasiquote:Macro.defmacro("quasiquote",function(e,t){var u=t.use_dynamic,s=t.error;var c=this;var l=c;function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function f(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:a;if(e instanceof Pair){var n=e.car;var i=e.cdr;if(r(n)){n=t(n)}if(r(i)){i=t(i)}if(is_promise(n)||is_promise(i)){return promise_all([n,i]).then(function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];return new Pair(r,n)})}else{return new Pair(n,i)}}return e}function o(e,t){if(e instanceof Pair){if(t!==_nil){e.append(t)}}else{e=new Pair(e,t)}return e}function r(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,/^(unquote|unquote-splicing)$/)}).length}function _(e,n,i){return e.reduce(function(e,t){if(!(t instanceof Pair)){e.push(t);return e}if(LSymbol.is(t.car,"unquote-splicing")){var r;if(n+11){var t="You can't splice multiple atoms inside list";throw new Error(t)}if(!(i.cdr instanceof Pair&&r[0]===_nil)){return r[0]}}r=r.map(function(e){if(d.has(e)){return e.clone()}else{d.add(e);return e}});var n=m(i.cdr,0,1);if(n===_nil&&r[0]===_nil){return undefined}return unpromise(n,function(e){if(r[0]===_nil){return e}if(r.length===1){return o(r[0],e)}var t=r.reduce(function(e,t){return o(e,t)});return o(t,e)})})}(i.car.cdr)}var d=new Set;function m(e,t,r){if(e instanceof Pair){if(e.car instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return h(e,t+1,r)}if(LSymbol.is(e.car.car,"unquote")){if(t+2===r&&e.car.cdr instanceof Pair&&e.car.cdr.car instanceof Pair&&LSymbol.is(e.car.cdr.car.car,"unquote-splicing")){var n=e.car.cdr;return new Pair(new Pair(new LSymbol("unquote"),h(n,t+2,r)),_nil)}else if(e.car.cdr instanceof Pair&&e.car.cdr.cdr!==_nil){if(e.car.cdr.car instanceof Pair){var i=[];return function t(r){if(r===_nil){return Pair.fromArray(i)}return unpromise(_evaluate(r.car,{env:c,dynamic_env:l,use_dynamic:u,error:s}),function(e){i.push(e);return t(r.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}}if(LSymbol.is(e.car,"quasiquote")){var a=m(e.cdr,t,r+1);return new Pair(e.car,a)}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,t,r))}if(LSymbol.is(e.car,"unquote")){t++;if(tr){throw new Error("You can't call `unquote` outside "+"of quasiquote")}if(e.cdr instanceof Pair){if(e.cdr.cdr!==_nil){if(e.cdr.car instanceof Pair){var o=[];return function t(r){if(r===_nil){return Pair.fromArray(o)}return unpromise(_evaluate(r.car,{env:c,dynamic_env:l,use_dynamic:u,error:s}),function(e){o.push(e);return t(r.cdr)})}(e.cdr)}else{return e.cdr}}else{return _evaluate(e.cdr.car,{env:c,dynamic_env:l,error:s})}}else{return e.cdr}}return f(e,function(e){return m(e,t,r)})}else if(is_plain_object(e)){return p(e,t,r)}else if(e instanceof Array){return _(e,t,r)}return e}function n(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}}if(is_plain_object(e.car)&&!r(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!r(e.car)){return quote(e.car)}if(e.car instanceof Pair&&!e.car.find("unquote")&&!e.car.find("unquote-splicing")&&!e.car.find("quasiquote")){return quote(e.car)}var i=m(e.car,0,1);return unpromise(i,function(e){n(e);return quote(e)})},"(quasiquote list)\n\n Similar macro to `quote` but inside it you can use special expressions (unquote\n x) abbreviated to ,x that will evaluate x and insert its value verbatim or\n (unquote-splicing x) abbreviated to ,@x that will evaluate x and splice the value\n into the result. Best used with macros but it can be used outside."),clone:doc("clone",function e(t){typecheck("clone",t,"pair");return t.clone()},"(clone list)\n\n Function that returns a clone of the list, that does not share any pairs with the\n original, so the clone can be safely mutated without affecting the original."),append:doc("append",function e(){var t;for(var r=arguments.length,n=new Array(r),i=0;iarray")(t).reverse();return global_env.get("array->list")(r)}else if(Array.isArray(t)){return t.reverse()}else{throw new Error(typeErrorMessage("reverse",type(t),"array or pair"))}},"(reverse list)\n\n Function that reverses the list or array. If value is not a list\n or array it will error."),nth:doc("nth",function e(t,r){typecheck("nth",t,"number");typecheck("nth",r,["array","pair"]);if(r instanceof Pair){var n=r;var i=0;while(iarray")(r).join(t)},"(join separator list)\n\n Function that returns a string by joining elements of the list using separator."),split:doc("split",function e(t,r){typecheck("split",t,["regex","string"]);typecheck("split",r,"string");return global_env.get("array->list")(r.split(t))},"(split separator string)\n\n Function that creates a list by splitting string by separator which can\n be a string or regular expression."),replace:doc("replace",function e(t,r,n){typecheck("replace",t,["regex","string"]);typecheck("replace",r,["string","function"]);typecheck("replace",n,"string");return n.replace(t,r)},"(replace pattern replacement string)\n\n Function that changes pattern to replacement inside string. Pattern can be a\n string or regex and replacement can be function or string. See Javascript\n String.replace()."),match:doc("match",function e(t,r){typecheck("match",t,["regex","string"]);typecheck("match",r,"string");var n=r.match(t);return n?global_env.get("array->list")(n):false},"(match pattern string)\n\n Function that returns a match object from JavaScript as a list or #f if\n no match."),search:doc("search",function e(t,r){typecheck("search",t,["regex","string"]);typecheck("search",r,"string");return r.search(t)},"(search pattern string)\n\n Function that returns the first found index of the pattern inside a string."),repr:doc("repr",function e(t,r){return toString(t,r)},"(repr obj)\n\n Function that returns a LIPS code representation of the object as a string."),"escape-regex":doc("escape-regex",function(e){typecheck("escape-regex",e,"string");return escape_regex(e.valueOf())},"(escape-regex string)\n\n Function that returns a new string where all special operators used in regex,\n are escaped with backslashes so they can be used in the RegExp constructor\n to match a literal string."),env:doc("env",function e(e){e=e||this.env;var t=Object.keys(e.__env__).map(LSymbol);var r;if(t.length){r=Pair.fromArray(t)}else{r=_nil}if(e.__parent__ instanceof Environment){return global_env.get("env").call(this,e.__parent__).append(r)}return r},"(env)\n (env obj)\n\n Function that returns a list of names (functions, macros and variables)\n that are bound in the current environment or one of its parents."),new:doc("new",function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2&&arguments[2]!==undefined?arguments[2]:specials.LITERAL;typecheck("set-special!",e,"string",1);typecheck("set-special!",t,"symbol",2);specials.append(e.valueOf(),t,r)},'(set-special! symbol name [type])\n\n Add a special symbol to the list of transforming operators by the parser.\n e.g.: `(add-special! "#" \'x)` will allow to use `#(1 2 3)` and it will be\n transformed into (x (1 2 3)) so you can write x macro that will process\n the list. 3rd argument is optional, and it can be one of two values:\n lips.specials.LITERAL, which is the default behavior, or\n lips.specials.SPLICE which causes the value to be unpacked into the expression.\n This can be used for e.g. to make `#(1 2 3)` into (x 1 2 3) that is needed\n by # that defines vectors.'),get:get,".":get,unbind:doc(unbind,"(unbind fn)\n\n Function that removes the weak 'this' binding from a function so you\n can get properties from the actual function object."),type:doc(type,"(type object)\n\n Function that returns the type of an object as string."),debugger:doc("debugger",function(){debugger},'(debugger)\n\n Function that triggers the JavaScript debugger (e.g. the browser devtools)\n using the "debugger;" statement. If a debugger is not running this\n function does nothing.'),in:doc("in",function(e,t){if(e instanceof LSymbol||e instanceof LString||e instanceof LNumber){e=e.valueOf()}return e in unbox(t)},'(in key value)\n\n Function that uses the Javascript "in" operator to check if key is\n a valid property in the value.'),"instance?":doc("instance?",function(e){return is_instance(e)},"(instance? obj)\n\n Checks if object is an instance, created with a new operator"),instanceof:doc("instanceof",function(e,t){return t instanceof unbind(e)},"(instanceof type obj)\n\n Predicate that tests if the obj is an instance of type."),"prototype?":doc("prototype?",is_prototype,"(prototype? obj)\n\n Predicate that tests if value is a valid JavaScript prototype,\n i.e. calling (new) with it will not throw ' is not a constructor'."),"macro?":doc("macro?",function(e){return e instanceof Macro},"(macro? expression)\n\n Predicate that tests if value is a macro."),"function?":doc("function?",is_function,"(function? expression)\n\n Predicate that tests if value is a callable function."),"real?":doc("real?",function(e){if(type(e)!=="number"){return false}if(e instanceof LNumber){return e.isFloat()}return LNumber.isFloat(e)},"(real? number)\n\n Predicate that tests if value is a real number (not complex)."),"number?":doc("number?",function(e){return Number.isNaN(e)||LNumber.isNumber(e)},"(number? expression)\n\n Predicate that tests if value is a number or NaN value."),"string?":doc("string?",function(e){return LString.isString(e)},"(string? expression)\n\n Predicate that tests if value is a string."),"pair?":doc("pair?",function(e){return e instanceof Pair},"(pair? expression)\n\n Predicate that tests if value is a pair or list structure."),"regex?":doc("regex?",function(e){return e instanceof RegExp},"(regex? expression)\n\n Predicate that tests if value is a regular expression."),"null?":doc("null?",function(e){return is_null(e)},"(null? expression)\n\n Predicate that tests if value is null-ish (i.e. undefined, nil, or\n Javascript null)."),"boolean?":doc("boolean?",function(e){return typeof e==="boolean"},"(boolean? expression)\n\n Predicate that tests if value is a boolean (#t or #f)."),"symbol?":doc("symbol?",function(e){return e instanceof LSymbol},"(symbol? expression)\n\n Predicate that tests if value is a LIPS symbol."),"array?":doc("array?",function(e){return e instanceof Array},"(array? expression)\n\n Predicate that tests if value is an array."),"object?":doc("object?",function(e){return e!==_nil&&e!==null&&!(e instanceof LCharacter)&&!(e instanceof RegExp)&&!(e instanceof LString)&&!(e instanceof Pair)&&!(e instanceof LNumber)&&_typeof$1(e)==="object"&&!(e instanceof Array)},"(object? expression)\n\n Predicate that tests if value is an plain object (not another LIPS type)."),flatten:doc("flatten",function e(t){typecheck("flatten",t,"pair");return t.flatten()},"(flatten list)\n\n Returns a shallow list from tree structure (pairs)."),"array->list":doc("array->list",function(e){typecheck("array->list",e,"array");return Pair.fromArray(e)},"(array->list array)\n\n Function that converts a JavaScript array to a LIPS cons list."),"tree->array":doc("tree->array",to_array("tree->array",true),"(tree->array list)\n\n Function that converts a LIPS cons tree structure into a JavaScript array."),"list->array":doc("list->array",to_array("list->array"),"(list->array list)\n\n Function that converts a LIPS list into a JavaScript array."),apply:doc("apply",function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;iarray").call(this,a));return t.apply(this,prepare_fn_args(t,n))},"(apply fn list)\n\n Function that calls fn with the list of arguments."),length:doc("length",function e(t){if(!t||t===_nil){return 0}if(t instanceof Pair){return t.length()}if("length"in t){return t.length}},'(length expression)\n\n Function that returns the length of the object. The object can be a LIPS\n list or any object that has a "length" property. Returns undefined if the\n length could not be found.'),"string->number":doc("string->number",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;typecheck("string->number",e,"string",1);typecheck("string->number",t,"number",2);e=e.valueOf();t=t.valueOf();if(e.match(rational_bare_re)||e.match(rational_re)){return parse_rational(e,t)}else if(e.match(complex_bare_re)||e.match(complex_re)){return parse_complex(e,t)}else{var r=t===10&&!e.match(/e/i)||t===16;if(e.match(int_bare_re)&&r||e.match(int_re)){return parse_integer(e,t)}if(e.match(float_re)){return parse_float(e)}}return false},"(string->number number [radix])\n\n Function that parses a string into a number."),try:doc(new Macro("try",function(r,e){var f=this;var _=e.use_dynamic;e.error;return new Promise(function(t,u){var s,n;if(LSymbol.is(r.cdr.car.car,"catch")){s=r.cdr.car;if(r.cdr.cdr instanceof Pair&&LSymbol.is(r.cdr.cdr.car.car,"finally")){n=r.cdr.cdr.car}}else if(LSymbol.is(r.cdr.car.car,"finally")){n=r.cdr.car}if(!(n||s)){throw new Error("try: invalid syntax")}function c(e){t(e);throw new IgnoreException("[CATCH]")}var l=function e(t,r){r(t)};if(n){l=function e(t,r){l=u;i.error=function(e){throw e};unpromise(_evaluate(new Pair(new LSymbol("begin"),n.cdr),i),function(){r(t)})}}var i={env:f,use_dynamic:_,dynamic_env:f,error:function e(t){if(t instanceof IgnoreException){throw t}var r=f.inherit("try");if(s){var n=s.cdr.car.car;if(!(n instanceof LSymbol)){throw new Error("try: invalid syntax: catch require variable name")}r.set(n,t);var i;var a={env:r,use_dynamic:_,dynamic_env:f,error:function e(t){i=true;u(t);throw new IgnoreException("[CATCH]")}};var o=_evaluate(new Pair(new LSymbol("begin"),s.cdr.cdr),a);unpromise(o,function e(t){if(!i){l(t,c)}})}else{l(undefined,function(){throw t})}}};var e=_evaluate(r.car,i);unpromise(e,function(e){l(e,t)},i.error)})}),"(try expr (catch (e) code))\n (try expr (catch (e) code) (finally code))\n (try expr (finally code))\n\n Macro that executes expr and catches any exceptions thrown. If catch is provided\n it's executed when an error is thrown. If finally is provided it's always\n executed at the end."),raise:doc("raise",function(e){throw e},"(raise obj)\n\n Throws the object verbatim (no wrapping an a new Error)."),throw:doc("throw",function(e){throw new Error(e)},"(throw string)\n\n Throws a new exception."),find:doc("find",function t(r,n){typecheck("find",r,["regex","function"]);typecheck("find",n,["pair","nil"]);if(is_null(n)){return _nil}var e=matcher("find",r);return unpromise(e(n.car),function(e){if(e&&e!==_nil){return n.car}return t(r,n.cdr)})},"(find fn list)\n (find regex list)\n\n Higher-order function that finds the first value for which fn return true.\n If called with a regex it will create a matcher function."),"for-each":doc("for-each",function(e){var t;typecheck("for-each",e,"function");for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i1?t-1:0),a=1;a3?n-3:0),a=3;a3?i-3:0),o=3;oarray")(r);var a=[];var o=matcher("filter",t);return function t(r){function e(e){if(e&&e!==_nil){a.push(n)}return t(++r)}if(r===i.length){return Pair.fromArray(a)}var n=i[r];return unpromise(o(n),e)}(0)},"(filter fn list)\n (filter regex list)\n\n Higher-order function that calls `fn` for each element of the list\n and return a new list for only those elements for which fn returns\n a truthy value. If called with a regex it will create a matcher function."),compose:doc(compose,"(compose . fns)\n\n Higher-order function that creates a new function that applies all functions\n from right to left and returns the last value. Reverse of pipe.\n e.g.:\n ((compose (curry + 2) (curry * 3)) 10) --\x3e (+ 2 (* 3 10)) --\x3e 32"),pipe:doc(pipe,"(pipe . fns)\n\n Higher-order function that creates a new function that applies all functions\n from left to right and returns the last value. Reverse of compose.\n e.g.:\n ((pipe (curry + 2) (curry * 3)) 10) --\x3e (* 3 (+ 2 10)) --\x3e 36"),curry:doc(curry,"(curry fn . args)\n\n Higher-order function that creates a curried version of the function.\n The result function will have partially applied arguments and it\n will keep returning one-argument functions until all arguments are provided,\n then it calls the original function with the accumulated arguments.\n\n e.g.:\n (define (add a b c d) (+ a b c d))\n (define add1 (curry add 1))\n (define add12 (add 2))\n (display (add12 3 4))"),gcd:doc("gcd",function e(){for(var t=arguments.length,r=new Array(t),n=0;nu?a%=u:u%=a}a=abs(s*r[o])/(a+u)}return LNumber(a)},"(lcm n1 n2 ...)\n\n Function that returns the least common multiple of the arguments."),"odd?":doc("odd?",single_math_op(function(e){return LNumber(e).isOdd()}),"(odd? number)\n\n Checks if number is odd."),"even?":doc("even?",single_math_op(function(e){return LNumber(e).isEven()}),"(even? number)\n\n Checks if number is even."),"*":doc("*",reduce_math_op(function(e,t){return LNumber(e).mul(t)},LNumber(1)),"(* . numbers)\n\n Multiplies all numbers passed as arguments. If single value is passed\n it will return that value."),"+":doc("+",reduce_math_op(function(e,t){return LNumber(e).add(t)},LNumber(0)),"(+ . numbers)\n\n Sums all numbers passed as arguments. If single value is passed it will\n return that value."),"-":doc("-",function(){for(var e=arguments.length,t=new Array(e),r=0;r":doc(">",function(){for(var e=arguments.length,t=new Array(e),r=0;r",t,["bigint","float","rational"]);return seq_compare(function(e,t){return LNumber(e).cmp(t)===1},t)},"(> x1 x2 x3 ...)\n\n Function that compares its numerical arguments and checks if they are\n monotonically decreasing, i.e. x1 > x2 and x2 > x3 and so on."),"<":doc("<",function(){for(var e=arguments.length,t=new Array(e),r=0;r=":doc(">=",function(){for(var e=arguments.length,t=new Array(e),r=0;r=",t,["bigint","float","rational"]);return seq_compare(function(e,t){return[0,1].includes(LNumber(e).cmp(t))},t)},"(>= x1 x2 ...)\n\n Function that compares its numerical arguments and checks if they are\n monotonically nonincreasing, i.e. x1 >= x2 and x2 >= x3 and so on."),"eq?":doc("eq?",equal,"(eq? a b)\n\n Function that compares two values if they are identical."),or:doc(new Macro("or",function(e,t){var i=t.use_dynamic,a=t.error;var o=global_env.get("list->array")(e);var u=this;var s=u;if(!o.length){return false}var c;return function t(){function e(e){c=e;if(c!==false){return c}else{return t()}}if(!o.length){if(c!==false){return c}else{return false}}else{var r=o.shift();var n=_evaluate(r,{env:u,dynamic_env:s,use_dynamic:i,error:a});return unpromise(n,e)}}()}),"(or . expressions)\n\n Macro that executes the values one by one and returns the first that is\n a truthy value. If there are no expressions that evaluate to true it\n returns false."),and:doc(new Macro("and",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=global_env.get("list->array")(e);var a=this;var o=a;if(!i.length){return true}var u;var s={env:a,dynamic_env:o,use_dynamic:r,error:n};return function t(){function e(e){u=e;if(u===false){return false}else{return t()}}if(!i.length){if(u!==false){return u}else{return false}}else{var r=i.shift();return unpromise(_evaluate(r,s),e)}}()}),"(and . expressions)\n\n Macro that evaluates each expression in sequence and if any value returns false\n it will stop and return false. If each value returns true it will return the\n last value. If it's called without arguments it will return true."),"|":doc("|",function(e,t){return LNumber(e).or(t)},"(| a b)\n\n Function that calculates the bitwise or operation."),"&":doc("&",function(e,t){return LNumber(e).and(t)},"(& a b)\n\n Function that calculates the bitwise and operation."),"~":doc("~",function(e){return LNumber(e).neg()},"(~ number)\n\n Function that calculates the bitwise inverse (flip all the bits)."),">>":doc(">>",function(e,t){return LNumber(e).shr(t)},"(>> a b)\n\n Function that right shifts the value a by value b bits."),"<<":doc("<<",function(e,t){return LNumber(e).shl(t)},"(<< a b)\n\n Function that left shifts the value a by value b bits."),not:doc("not",function e(t){if(is_null(t)){return true}return!t},"(not object)\n\n Function that returns the Boolean negation of its argument.")},undefined,"global");var user_env=global_env.inherit("user-env");function set_interaction_env(e,t){e.constant("**internal-env**",t);e.doc("**internal-env**","**internal-env**\n\n Constant used to hide stdin, stdout and stderr so they don't interfere\n with variables with the same name. Constants are an internal type\n of variable that can't be redefined, defining a variable with the same name\n will throw an error.");global_env.set("**interaction-environment**",e)}set_interaction_env(user_env,internal_env);global_env.doc("**interaction-environment**","**interaction-environment**\n\n Internal dynamic, global variable used to find interpreter environment.\n It's used so the read and write functions can locate **internal-env**\n that contains the references to stdin, stdout and stderr.");function set_fs(e){user_env.get("**internal-env**").set("fs",e)}(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(t){var r=e[t]?e[t]:t;global_env.set(r,doc(r,function(e){typecheck(r,e,"number");if(e instanceof LNumber){return e[t]()}},"(".concat(r," number)\n\n Function that calculates the ").concat(r," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var t=[];var r=allPossibleCases(e.slice(1));for(var n=0;n3&&arguments[3]!==undefined?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(n!==null){i+=" (argument ".concat(n,")")}if(is_function(r)){return"Invalid type: got ".concat(t).concat(i)}if(r instanceof Array){if(r.length===1){var a=r[0].toLowerCase();r="a"+("aeiou".includes(a)?"n ":" ")+r[0]}else{r=new Intl.ListFormat("en",{style:"long",type:"disjunction"}).format(r)}}return"Expecting ".concat(r," got ").concat(t).concat(i)}function typecheck_number(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;typecheck(e,t,"number",n);var i=t.__type__;var a;if(r instanceof Pair){r=r.to_array()}if(r instanceof Array){r=r.map(function(e){return e.valueOf()})}if(r instanceof Array){r=r.map(function(e){return e.valueOf().toLowerCase()});if(r.includes(i)){a=true}}else{r=r.valueOf().toLowerCase()}if(!a&&i!==r){throw new Error(typeErrorMessage(e,i,r,n))}}function typecheck_numbers(r,e,n){e.forEach(function(e,t){typecheck_number(r,e,n,t+1)})}function typecheck_args(r,e,n){e.forEach(function(e,t){typecheck(r,e,n,t+1)})}function typecheck_text_port(e,t,r){typecheck(e,t,r);if(t.__type__===binary_port){throw new Error(typeErrorMessage(e,"binary-port","textual-port"))}}function typecheck(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;e=e.valueOf();var i=type(t).toLowerCase();if(is_function(r)){if(!r(t)){throw new Error(typeErrorMessage(e,i,r,n))}return}var a=false;if(r instanceof Pair){r=r.to_array()}if(r instanceof Array){r=r.map(function(e){return e.valueOf()})}if(r instanceof Array){r=r.map(function(e){return e.valueOf().toLowerCase()});if(r.includes(i)){a=true}}else{r=r.valueOf().toLowerCase()}if(!a&&i!==r){throw new Error(typeErrorMessage(e,i,r,n))}}function memoize(r){var n=new WeakMap;return function(e){var t=n.get(e);if(!t){t=r(e)}return t}}type=memoize(type);function type(e){var t=type_constants.get(e);if(t){return t}if(_typeof$1(e)==="object"){for(var r=0,n=Object.entries(type_mapping);r2&&arguments[2]!==undefined?arguments[2]:{},n=r.env,i=r.dynamic_env,a=r.use_dynamic;var o=n===null||n===void 0?void 0:n.new_frame(e,t);var u=i===null||i===void 0?void 0:i.new_frame(e,t);var s=new LambdaContext({env:o,use_dynamic:a,dynamic_env:u});return resolve_promises(e.apply(s,t))}function apply(n,e){var t=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},i=t.env,a=t.dynamic_env,o=t.use_dynamic,r=t.error,u=r===void 0?function(){}:r;e=evaluate_args(e,{env:i,dynamic_env:a,error:u,use_dynamic:o});return unpromise(e,function(e){if(is_raw_lambda(n)){n=unbind(n)}e=prepare_fn_args(n,e);var t=e.slice();var r=call_function(n,t,{env:i,dynamic_env:a,use_dynamic:o});return unpromise(r,function(e){if(e instanceof Pair){e.markCycles();return quote(e)}return box(e)},u)})}var _p_name__=new WeakMap;var Parameter=function(){function n(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;_classCallCheck(this,n);_defineProperty(this,"__value__",void 0);_defineProperty(this,"__fn__",void 0);_classPrivateFieldInitSpec(this,_p_name__,{writable:true,value:void 0});this.__value__=e;if(t){if(!is_function(t)){throw new Error("Section argument to Parameter need to be function "+"".concat(type(t)," given"))}this.__fn__=t}if(r){_classPrivateFieldSet(this,_p_name__,r)}}_createClass(n,[{key:"__name__",get:function e(){return _classPrivateFieldGet(this,_p_name__)},set:function e(t){_classPrivateFieldSet(this,_p_name__,t);if(this.__fn__){this.__fn__.__name__="fn-".concat(t)}}},{key:"invoke",value:function e(){if(is_function(this.__fn__)){return this.__fn__(this.__value__)}return this.__value__}},{key:"inherit",value:function e(t){return new n(t,this.__fn__,this.__name__)}}]);return n}();var LambdaContext=function(){function t(e){_classCallCheck(this,t);_defineProperty(this,"env",void 0);_defineProperty(this,"dynamic_env",void 0);_defineProperty(this,"use_dynamic",void 0);Object.assign(this,e)}_createClass(t,[{key:"__name__",get:function e(){return this.env.__name__}},{key:"__parent__",get:function e(){return this.env.__parent__}},{key:"get",value:function e(){var t;return(t=this.env).get.apply(t,arguments)}}]);return t}();function search_param(e,t){var r=e.get(t.__name__,{throwError:false});if(is_parameter(r)&&r!==t){return r}var n=user_env.get("**interaction-environment**");while(true){var i=e.get("parent.frame",{throwError:false});e=i(0);if(e===n){break}r=e.get(t.__name__,{throwError:false});if(is_parameter(r)&&r!==t){return r}}return t}var Continuation=function(){function t(e){_classCallCheck(this,t);_defineProperty(this,"__value__",void 0);this.__value__=e}_createClass(t,[{key:"invoke",value:function e(){if(this.__value__===null){throw new Error("Continuations are not implemented yet")}}}]);return t}();function _evaluate(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},s=e.env,c=e.dynamic_env,l=e.use_dynamic,t=e.error,f=t===void 0?noop:t,r=_objectWithoutProperties(e,_excluded6);return function(e){try{if(!is_env(c)){c=s===true?user_env:s||user_env}if(l){s=c}else if(s===true){s=user_env}else{s=s||global_env}var t={env:s,dynamic_env:c,use_dynamic:l,error:f};var r;if(is_null(u)){return u}if(u instanceof LSymbol){return s.get(u)}if(!(u instanceof Pair)){return u}var n=u.car;var e=u.cdr;if(n instanceof Pair){r=resolve_promises(_evaluate(n,t));if(is_promise(r)){return r.then(function(e){if(!is_callable(e)){throw new Error(type(e)+" "+s.get("repr")(e)+" is not callable while evaluating "+u.toString())}return _evaluate(new Pair(e,u.cdr),t)})}else if(!is_callable(r)){throw new Error(type(r)+" "+s.get("repr")(r)+" is not callable while evaluating "+u.toString())}}if(n instanceof LSymbol){r=s.get(n)}else if(is_function(n)){r=n}var i;if(r instanceof Syntax){i=evaluate_syntax(r,u,t)}else if(r instanceof Macro){i=evaluate_macro(r,e,t)}else if(is_function(r)){i=apply(r,e,t)}else if(is_parameter(r)){var a=search_param(c,r);if(is_null(u.cdr)){i=a.invoke()}else{return unpromise(_evaluate(u.cdr.car,t),function(e){a.__value__=e})}}else if(is_continuation(r)){i=r.invoke()}else if(u instanceof Pair){r=n&&n.toString();throw new Error("".concat(type(n)," ").concat(r," is not a function"))}else{return u}var o=s.get(Symbol["for"]("__promise__"),{throwError:false});if(o===true&&is_promise(i)){i=i.then(function(e){if(e instanceof Pair&&!r[__data__]){return _evaluate(e,t)}return e});return new QuotedPromise(i)}return i}catch(e){f&&f.call(s,e,u)}}(r)}var compile=exec_collect(function(e){return e});var exec=exec_collect(function(e,t){return t});function exec_collect(d){return function(){var t=_asyncToGenerator(function(f){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},_=e.env,p=e.dynamic_env,h=e.use_dynamic;return _regeneratorRuntime.mark(function e(){var r,n,i,a,o,u,s,c,l;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!is_env(p)){p=_===true?user_env:_||user_env}if(_===true){_=user_env}else{_=_||user_env}r=[];n=Array.isArray(f)?f:_parse(f);i=false;a=false;t.prev=6;u=_asyncIterator(n);case 8:t.next=10;return u.next();case 10:if(!(i=!(s=t.sent).done)){t.next=24;break}c=s.value;l=_evaluate(c,{env:_,dynamic_env:p,use_dynamic:h,error:function e(t,r){if(t&&t.message){if(t.message.match(/^Error:/)){var n=/^(Error:)\s*([^:]+:\s*)/;t.message=t.message.replace(n,"$1 $2")}if(r){if(!(t.__code__ instanceof Array)){t.__code__=[]}t.__code__.push(r.toString(true))}}if(!(t instanceof IgnoreException)){throw t}}});t.t0=r;t.t1=d;t.t2=c;t.next=18;return l;case 18:t.t3=t.sent;t.t4=(0,t.t1)(t.t2,t.t3);t.t0.push.call(t.t0,t.t4);case 21:i=false;t.next=8;break;case 24:t.next=30;break;case 26:t.prev=26;t.t5=t["catch"](6);a=true;o=t.t5;case 30:t.prev=30;t.prev=31;if(!(i&&u["return"]!=null)){t.next=35;break}t.next=35;return u["return"]();case 35:t.prev=35;if(!a){t.next=38;break}throw o;case 38:return t.finish(35);case 39:return t.finish(30);case 40:return t.abrupt("return",r);case 41:case"end":return t.stop()}},e,null,[[6,26,30,40],[31,,35,39]])})()});function e(e){return t.apply(this,arguments)}return e}()}function balanced(e){var t={"[":"]","(":")"};var r;if(typeof e==="string"){r=tokenize(e)}else{r=e.map(function(e){return e&&e.token?e.token:e})}var n=Object.keys(t);var i=Object.values(t).concat(n);r=r.filter(function(e){return i.includes(e)});var a=new Stack;var o=_createForOfIteratorHelper(r),u;try{for(o.s();!(u=o.n()).done;){var s=u.value;if(n.includes(s)){a.push(s)}else if(!a.is_empty()){var c=a.top();var l=t[c];if(s===l){a.pop()}else{throw new Error("Syntax error: missing closing ".concat(l))}}else{throw new Error("Syntax error: not matched closing ".concat(s))}}}catch(e){o.e(e)}finally{o.f()}return a.is_empty()}function fworker(e){var t="("+e.toString()+")()";var r=window.URL||window.webkitURL;var n;try{n=new Blob([t],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;n=new i;n.append(t);n=n.getBlob()}return new root.Worker(r.createObjectURL(n))}function is_dev(){return lips.version.match(/^(\{\{VER\}\}|DEV)$/)}function get_current_script(){if(is_node()){return}var e;if(document.currentScript){e=document.currentScript}else{var t=document.querySelectorAll("script");if(!t.length){return}e=t[t.length-1]}var r=e.getAttribute("src");return r}var current_script=get_current_script();function bootstrap(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var t="dist/std.xcb";if(e===""){if(current_script){e=current_script.replace(/[^/]*$/,"std.xcb")}else if(is_dev()){e="https://cdn.jsdelivr.net/gh/jcubic/lips@devel/".concat(t)}else{e="https://cdn.jsdelivr.net/npm/@jcubic/lips@".concat(lips.version,"/").concat(t)}}var r=global_env.get("load");return r.call(user_env,e,global_env)}function Worker(e){this.url=e;var o=this.worker=fworker(function(){var o;var u;self.addEventListener("message",function(e){var r=e.data;var t=r.id;if(r.type!=="RPC"||t===null){return}function n(e){self.postMessage({id:t,type:"RPC",result:e})}function i(e){self.postMessage({id:t,type:"RPC",error:e})}if(r.method==="eval"){if(!u){i("Worker RPC: LIPS not initialized, call init first");return}u.then(function(){var e=r.params[0];var t=r.params[1];o.exec(e,{use_dynamic:t}).then(function(e){e=e.map(function(e){return e&&e.valueOf()});n(e)})["catch"](function(e){i(e)})})}else if(r.method==="init"){var a=r.params[0];if(typeof a!=="string"){i("Worker RPC: url is not a string")}else{importScripts("".concat(a,"/dist/lips.min.js"));o=new lips.Interpreter("worker");u=bootstrap(a);u.then(function(){n(true)})}}})});this.rpc=function(){var n=0;return function e(t,r){var a=++n;return new Promise(function(n,i){o.addEventListener("message",function e(t){var r=t.data;if(r&&r.type==="RPC"&&r.id===a){if(r.error){i(r.error)}else{n(r.result)}o.removeEventListener("message",e)}});o.postMessage({type:"RPC",method:t,id:a,params:r})})}}();this.rpc("init",[e])["catch"](function(e){console.error(e)});this.exec=function(e,t){var r=t.use_dynamic,n=r===void 0?false:r;return this.rpc("eval",[e,n])}}var serialization_map={pair:function e(t){var r=_slicedToArray(t,2),n=r[0],i=r[1];return Pair(n,i)},number:function e(t){if(LString.isString(t)){return LNumber([t,10])}return LNumber(t)},regex:function e(t){var r=_slicedToArray(t,2),n=r[0],i=r[1];return new RegExp(n,i)},nil:function e(){return _nil},symbol:function e(t){if(LString.isString(t)){return LSymbol(t)}else if(Array.isArray(t)){return LSymbol(Symbol["for"](t[0]))}},string:LString,character:LCharacter};var available_class=Object.keys(serialization_map);var class_map={};for(var _i6=0,_Object$entries3=Object.entries(available_class);_i6<_Object$entries3.length;_i6++){var _Object$entries3$_i=_slicedToArray(_Object$entries3[_i6],2),i=_Object$entries3$_i[0],cls=_Object$entries3$_i[1];class_map[cls]=+i}function mangle_name(e){return class_map[e]}function resolve_name(e){return available_class[e]}function serialize(e){return JSON.stringify(e,function(e,t){var r=this[e];if(r){if(r instanceof RegExp){return{"@":mangle_name("regex"),"#":[r.source,r.flags]}}var n=mangle_name(r.constructor.__class__);if(!is_undef(n)){return{"@":n,"#":r.serialize()}}}return t})}function unserialize(e){return JSON.parse(e,function(e,t){if(t&&_typeof$1(t)==="object"){if(!is_undef(t["@"])){var r=resolve_name(t["@"]);if(serialization_map[r]){return serialization_map[r](t["#"])}}}return t})}var cbor=function(){var e={pair:Pair,symbol:LSymbol,number:LNumber,string:LString,character:LCharacter,nil:_nil.constructor,regex:RegExp};function t(e,t){return{deserialize:t,Class:e}}var r=new Encoder;var a={};for(var n=0,i=Object.entries(serialization_map);n1){var n=t.reduce(function(e,t){return e+t.length},0);var i=new Uint8Array(n);var a=0;t.forEach(function(e){i.set(e,a);a+=e.length});return i}else if(t.length){return t[0]}}function encode_magic(){var e=1;var t=new TextEncoder("utf-8");return t.encode("LIPS".concat(e.toString().padStart(3," ")))}var MAGIC_LENGTH=7;function decode_magic(e){var t=new TextDecoder("utf-8");var r=t.decode(e.slice(0,MAGIC_LENGTH));var n=r.substring(0,4);if(n==="LIPS"){var i=r.match(/^(....).*([0-9]+)$/);if(i){return{type:i[1],version:Number(i[2])}}}return{type:"unknown"}}function serialize_bin(e){var t=encode_magic();var r=cbor.encode(e);return merge_uint8_array(t,pack_1(r,{magic:false}))}function unserialize_bin(e){var t=decode_magic(e),r=t.type,n=t.version;if(r==="LIPS"&&n===1){var i=unpack_1(e.slice(MAGIC_LENGTH),{magic:false});return cbor.decode(i)}else{throw new Error("Invalid file format ".concat(r))}}function execError(e){console.error(e.message||e);if(Array.isArray(e.code)){console.error(e.code.map(function(e,t){return"[".concat(t+1,"]: ").concat(e)}))}}function init(){var o=["text/x-lips","text/x-scheme"];var u;function s(r){return new Promise(function(t){var e=r.getAttribute("src");if(e){return fetch(e).then(function(e){return e.text()}).then(exec).then(t)["catch"](function(e){execError(e);t()})}else{return exec(r.innerHTML).then(t)["catch"](function(e){execError(e);t()})}})}function e(){return new Promise(function(i){var a=Array.from(document.querySelectorAll("script"));return function e(){var t=a.shift();if(!t){i()}else{var r=t.getAttribute("type");if(o.includes(r)){var n=t.getAttribute("bootstrap");if(!u&&typeof n==="string"){return bootstrap(n).then(function(){return s(t)}).then(e)}else{return s(t).then(e)}}else if(r&&r.match(/lips|lisp/)){console.warn("Expecting "+o.join(" or ")+" found "+r)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var t=currentScript;var r=t.getAttribute("bootstrap");if(typeof r==="string"){return bootstrap(r).then(function(){u=true;return e()})}}return e()}var currentScript=typeof window!=="undefined"&&window.document&&document.currentScript;if(typeof window!=="undefined"){contentLoaded(window,init)}var banner=function(){var e=LString("Mon, 22 Jan 2024 12:07:50 +0000").valueOf();var t=e==="{{"+"DATE}}"?new Date:new Date(e);var r=function e(t){return t.toString().padStart(2,"0")};var n=t.getFullYear();var i=[n,r(t.getMonth()+1),r(t.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(n," Jakub T. Jankiewicz\n\nType (env) to see environment with functions macros and variables. You can also\nuse (help name) to display help for specific function or macro, (apropos name)\nto display list of matched names in environment and (dir object) to list\nproperties of an object.\n").replace(/^.*\n/,"");return a}();read_only(Ahead,"__class__","ahead");read_only(Pair,"__class__","pair");read_only(Nil,"__class__","nil");read_only(Pattern,"__class__","pattern");read_only(Formatter,"__class__","formatter");read_only(Macro,"__class__","macro");read_only(Syntax,"__class__","syntax");read_only(Environment,"__class__","environment");read_only(InputPort,"__class__","input-port");read_only(OutputPort,"__class__","output-port");read_only(BufferedOutputPort,"__class__","output-port");read_only(OutputStringPort,"__class__","output-string-port");read_only(InputStringPort,"__class__","input-string-port");read_only(InputFilePort,"__class__","input-file-port");read_only(OutputFilePort,"__class__","output-file-port");read_only(LipsError,"__class__","lips-error");[LNumber,LComplex,LRational,LFloat,LBigInteger].forEach(function(e){read_only(e,"__class__","number")});read_only(LCharacter,"__class__","character");read_only(LSymbol,"__class__","symbol");read_only(LString,"__class__","string");read_only(QuotedPromise,"__class__","promise");read_only(Parameter,"__class__","parameter");var version="DEV";var date="Mon, 22 Jan 2024 12:07:50 +0000";var parse=compose(uniterate_async,_parse);var lips={version:version,banner:banner,date:date,exec:exec,parse:parse,tokenize:tokenize,evaluate:_evaluate,compile:compile,serialize:serialize,unserialize:unserialize,serialize_bin:serialize_bin,unserialize_bin:unserialize_bin,bootstrap:bootstrap,Environment:Environment,env:user_env,Worker:Worker,Interpreter:Interpreter,balanced_parenthesis:balanced,balancedParenthesis:balanced,balanced:balanced,Macro:Macro,Syntax:Syntax,Pair:Pair,Values:Values,QuotedPromise:QuotedPromise,Error:LipsError,quote:quote,InputPort:InputPort,OutputPort:OutputPort,BufferedOutputPort:BufferedOutputPort,InputFilePort:InputFilePort,OutputFilePort:OutputFilePort,InputStringPort:InputStringPort,OutputStringPort:OutputStringPort,InputByteVectorPort:InputByteVectorPort,OutputByteVectorPort:OutputByteVectorPort,InputBinaryFilePort:InputBinaryFilePort,OutputBinaryFilePort:OutputBinaryFilePort,set_fs:set_fs,Formatter:Formatter,Parser:Parser,Lexer:Lexer,specials:specials,repr:repr,nil:_nil,eof:eof,LSymbol:LSymbol,LNumber:LNumber,LFloat:LFloat,LComplex:LComplex,LRational:LRational,LBigInteger:LBigInteger,LCharacter:LCharacter,LString:LString,Parameter:Parameter,rationalize:rationalize};global_env.set("lips",lips);var empty={};var empty$1=Object.freeze({__proto__:null,default:empty});function normalizeArray(e,t){var r=0;for(var n=e.length-1;n>=0;n--){var i=e[n];if(i==="."){e.splice(n,1)}else if(i===".."){e.splice(n,1);r++}else if(r){e.splice(n,1);r--}}if(t){for(;r--;r){e.unshift("..")}}return e}var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var splitPath=function(e){return splitPathRe.exec(e).slice(1)};function resolve(){var e="",t=false;for(var r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if(typeof n!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!n){continue}e=n+"/"+e;t=n.charAt(0)==="/"}e=normalizeArray(filter(e.split("/"),function(e){return!!e}),!t).join("/");return(t?"/":"")+e||"."}function normalize(e){var t=isAbsolute(e),r=substr(e,-1)==="/";e=normalizeArray(filter(e.split("/"),function(e){return!!e}),!t).join("/");if(!e&&!t){e="."}if(e&&r){e+="/"}return(t?"/":"")+e}function isAbsolute(e){return e.charAt(0)==="/"}function join(){var e=Array.prototype.slice.call(arguments,0);return normalize(filter(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))}function relative(e,t){e=resolve(e).substr(1);t=resolve(t).substr(1);function r(e){var t=0;for(;t=0;r--){if(e[r]!=="")break}if(t>r)return[];return e.slice(t,r-t+1)}var n=r(e.split("/"));var i=r(t.split("/"));var a=Math.min(n.length,i.length);var o=a;for(var u=0;ur-MATCH_MAX){t[i++]=e[n++];continue}l=(e[n]+13^e[n+1]-13^e[n+2])&LEMPEL_SIZE-1;c=n-f[l]&OFFSET_MASK;f[l]=n;a=n-c;if(a>=0&&a!=n&&e[n]==e[a]&&e[n+1]==e[a+1]&&e[n+2]==e[a+2]){t[o]|=u;for(s=MATCH_MIN;s>NBBY;t[i++]=c;n+=s}else{t[i++]=e[n++]}}console.assert(e.length>=n);return i}function decompress(e,t,r){t=t|0;var n=0,i=0,a=0,o=0,u=1<<(NBBY-1|0),s=0,c=0;while(n>(NBBY-MATCH_BITS|0))+MATCH_MIN|0;c=(e[n]<4){r[i]=r[a];i=i+1|0;a=a+1|0;r[i]=r[a];i=i+1|0;a=a+1|0;r[i]=r[a];i=i+1|0;a=a+1|0;r[i]=r[a];i=i+1|0;a=a+1|0;s=s-4|0}while(s>0){r[i]=r[a];i=i+1|0;a=a+1|0;s=s-1|0}}}else{r[i]=e[n];i=i+1|0;n=n+1|0}}return i}function encode_magic$1(){const e=new TextEncoder("utf-8");return e.encode(MAGIC_STRING)}const MAGIC_STRING="@lzjb";const MAGIC=encode_magic$1();function merge_uint8_array$1(...e){if(e.length>1){const r=e.reduce((e,t)=>e+t.length,0);const n=new Uint8Array(r);let t=0;e.forEach(e=>{n.set(e,t);t+=e.length});return n}else if(e.length){return e[0]}}function number_to_bytes(t){const e=Math.ceil(Math.log2(t)/8);const r=new Uint8Array(e);for(let e=0;e=0;e--){r=r*256+t[e]}return r}function pack(e,{magic:t=true}={}){const r=new Uint8Array(Math.max(e.length*1.5|0,16*1024));const n=compress(e,r);const i=number_to_bytes(e.length);const a=[Uint8Array.of(i.length),i,r.slice(0,n)];if(t){a.unshift(MAGIC)}return merge_uint8_array$1(...a)}function unpack(t,{magic:e=true}={}){if(e){const e=new TextDecoder("utf-8");const s=e.decode(t.slice(0,MAGIC.length));if(s!==MAGIC_STRING){throw new Error("Invalid magic value")}}const r=e?MAGIC.length:0;const n=t[r];const i=r+1;const a=r+n+1;const o=bytes_to_number(t.slice(i,a));t=t.slice(a);const u=new Uint8Array(o);decompress(t,t.length,u);return u}var pack_1=lzjbPack.pack=pack;var unpack_1=lzjbPack.unpack=unpack;function unfetch(s,c){return c=c||{},new Promise(function(e,t){var r=new XMLHttpRequest,n=[],i=[],a={},o=function(){return{ok:2==(r.status/100|0),statusText:r.statusText,status:r.status,url:r.responseURL,text:function(){return Promise.resolve(r.responseText)},json:function(){return Promise.resolve(r.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([r.response]))},clone:o,headers:{keys:function(){return n},entries:function(){return i},get:function(e){return a[e.toLowerCase()]},has:function(e){return e.toLowerCase()in a}}}};for(var u in r.open(c.method||"get",s,!0),r.onload=function(){r.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,t,r){n.push(t=t.toLowerCase()),i.push([t,r]),a[t]=a[t]?a[t]+","+r:r}),e(o())},r.onerror=t,r.withCredentials="include"==c.credentials,c.headers)r.setRequestHeader(u,c.headers[u]);r.send(c.body||null)})}var _excluded=["token"],_excluded2=["env"],_excluded3=["stderr","stdin","stdout","command_line"],_excluded4=["use_dynamic"],_excluded5=["use_dynamic"],_excluded6=["env","dynamic_env","use_dynamic","error"];function _classPrivateFieldInitSpec(e,t,r){_checkPrivateRedeclaration(e,t);t.set(e,r)}function _checkPrivateRedeclaration(e,t){if(t.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function _callSuper(e,t,r){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct()?Reflect.construct(t,r||[],_getPrototypeOf(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function e(){return!!t})()}function _createForOfIteratorHelper(t,e){var r=typeof Symbol!=="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=_unsupportedIterableToArray(t))||e&&t&&typeof t.length==="number"){if(r)t=r;var n=0;var i=function e(){};return{s:i,n:function e(){if(n>=t.length)return{done:true};return{done:false,value:t[n++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a=true,o=false,u;return{s:function e(){r=r.call(t)},n:function e(){var t=r.next();a=t.done;return t},e:function e(t){o=true;u=t},f:function e(){try{if(!a&&r["return"]!=null)r["return"]()}finally{if(o)throw u}}}}function _unsupportedIterableToArray(e,t){if(!e)return;if(typeof e==="string")return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor)r=e.constructor.name;if(r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _arrayLikeToArray(e,t)}function _arrayLikeToArray(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r1&&arguments[1]!==undefined?arguments[1]:null;var n=arguments[1]===true;function t(e){if(!is_debug()){return}var t=global_env.get("repr")(e);if(r===null||r instanceof RegExp&&r.test(t)){console.log(global_env.get("type")(e)+": "+t)}if(n){console.log(e)}}if(is_promise(e)){e.then(t)}else{t(e)}return e}function is_debug(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var t=user_env&&user_env.get("DEBUG",{throwError:false});if(e===null){return t===true}return(t===null||t===void 0?void 0:t.valueOf())===e.valueOf()}function num_mnemicic_re(e){return e?"(?:#".concat(e,"(?:#[ie])?|#[ie]#").concat(e,")"):"(?:#[ie])?"}function gen_rational_re(e,t){return"".concat(num_mnemicic_re(e),"[+-]?").concat(t,"+/").concat(t,"+")}function gen_complex_re(e,t){return"".concat(num_mnemicic_re(e),"(?:[+-]?(?:").concat(t,"+/").concat(t,"+|nan.0|inf.0|").concat(t,"+))?(?:[+-]i|[+-]?(?:").concat(t,"+/").concat(t,"+|").concat(t,"+|nan.0|inf.0)i)(?=[()[\\]\\s]|$)")}function gen_integer_re(e,t){return"".concat(num_mnemicic_re(e),"[+-]?").concat(t,"+")}var re_re=/^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/;var float_stre="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)";var complex_float_stre="(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|nan.0|inf.0|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+|nan.0|inf.0))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,t){var r=e==="x"?"(?!\\+|".concat(t,")"):"(?!\\.|".concat(t,")");var n="";if(e===""){n="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(t,"+/").concat(t,"+(?!").concat(t,")|[+-]?").concat(t,"+)").concat(r,")?)(").concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(t,"+/").concat(t,"+|[+-]?").concat(t,"+|[+-])i$"),"i")}var complex_list_re=function(){var a={};[[10,"","[0-9]"],[16,"x","[0-9a-fA-F]"],[8,"o","[0-7]"],[2,"b","[01]"]].forEach(function(e){var t=_slicedToArray(e,3),r=t[0],n=t[1],i=t[2];a[r]=make_complex_match_re(n,i)});return a}();var characters={alarm:"",backspace:"\b",delete:"",escape:"",newline:"\n",null:"\0",return:"\r",space:" ",tab:"\t",dle:"",soh:"",dc1:"",stx:"",dc2:"",etx:"",dc3:"",eot:"",dc4:"",enq:"",nak:"",ack:"",syn:"",bel:"",etb:"",bs:"\b",can:"",ht:"\t",em:"",lf:"\n",sub:"",vt:"\v",esc:"",ff:"\f",fs:"",cr:"\r",gs:"",so:"",rs:"",si:"",us:"",del:""};function ucs2decode(e){var t=[];var r=0;var n=e.length;while(r=55296&&i<=56319&&r1&&arguments[1]!==undefined?arguments[1]:10;var r=num_pre_parse(e);var n=r.number.split("/");var i=LRational({num:LNumber([n[0],r.radix||t]),denom:LNumber([n[1],r.radix||t])});if(r.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;var r=num_pre_parse(e);if(r.inexact){return LFloat(parseInt(r.number,r.radix||t))}return LNumber([r.number,r.radix||t])}function parse_character(e){var t=e.match(/#\\x([0-9a-f]+)$/i);var r;if(t){var n=parseInt(t[1],16);r=String.fromCodePoint(n)}else{t=e.match(/#\\([\s\S]+)$/);if(t){r=t[1]}}if(r){return LCharacter(r)}throw new Error("Parse: invalid character")}function parse_complex(e){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;function t(e){var t;if(e==="+"){t=LNumber(1)}else if(e==="-"){t=LNumber(-1)}else if(e.match(int_bare_re)){t=LNumber([e,i])}else if(e.match(rational_bare_re)){var r=e.split("/");t=LRational({num:LNumber([r[0],i]),denom:LNumber([r[1],i])})}else if(e.match(float_re)){var n=parse_float(e);if(a.exact){return n.toRational()}return n}else if(e.match(/nan.0$/)){return LNumber(NaN)}else if(e.match(/inf.0$/)){if(e[0]==="-"){return LNumber(Number.NEGATIVE_INFINITY)}return LNumber(Number.POSITIVE_INFINITY)}else{throw new Error("Internal Parser Error")}if(a.inexact){return LFloat(t.valueOf())}return t}var a=num_pre_parse(e);i=a.radix||i;var r;var n=a.number.match(complex_bare_match_re);if(i!==10&&n){r=n}else{r=a.number.match(complex_list_re[i])}var o,u;u=t(r[2]);if(r[1]){o=t(r[1])}else{o=LNumber(0)}if(u.cmp(0)===0&&u.__type__==="bigint"){return o}return LComplex({im:u,re:o})}function is_int(e){return parseInt(e.toString(),10)===e}function parse_big_int(e){var t=e.match(/^(([-+]?[0-9]*)(?:\.([0-9]+))?)e([-+]?[0-9]+)/i);if(t){var r=parseInt(t[4],10);var n;var i=t[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=t[3]&&t[3].length;if(i0){return LNumber(a).mul(u)}}}r=LFloat(r);if(t.exact){return r.toRational()}return r}function parse_string(e){e=e.replace(/\\x([0-9a-f]+);/gi,function(e,t){return"\\u"+t.padStart(4,"0")}).replace(/\n/g,"\\n");var t=e.match(/(\\*)(\\x[0-9A-F])/i);if(t&&t[1].length%2===0){throw new Error("Invalid string literal, unclosed ".concat(t[2]))}try{return LString(JSON.parse(e))}catch(e){var r=e.message.replace(/in JSON /,"").replace(/.*Error: /,"");throw new Error("Invalid string literal: ".concat(r))}}function parse_symbol(e){if(e.match(/^\|.*\|$/)){e=e.replace(/(^\|)|(\|$)/g,"");var r={t:"\t",r:"\r",n:"\n"};e=e.replace(/\\(x[^;]+);/g,function(e,t){return String.fromCharCode(parseInt("0"+t,16))}).replace(/\\(.)/g,function(e,t){return r[t]||t})}return new LSymbol(e)}function parse_argument(e){if(constants.hasOwnProperty(e)){return constants[e]}if(e.match(/^"[\s\S]*"$/)){return parse_string(e)}else if(e[0]==="#"){var t=e.match(re_re);if(t){return new RegExp(t[1],t[2])}else if(e.match(char_re)){return parse_character(e)}var r=e.match(/#\\(.+)/);if(r&&ucs2decode(r[1]).length===1){return parse_character(e)}}if(e.match(/[0-9a-f]|[+-]i/i)){if(e.match(int_re)){return parse_integer(e)}else if(e.match(float_re)){return parse_float(e)}else if(e.match(rational_re)){return parse_rational(e)}else if(e.match(complex_re)){return parse_complex(e)}}if(e.match(/^#[iexobd]/)){throw new Error("Invalid numeric constant: "+e)}return parse_symbol(e)}function is_atom_string(e){return!(["(",")","[","]"].includes(e)||specials.names().includes(e))}function is_symbol_string(e){return is_atom_string(e)&&!(e.match(re_re)||e.match(/^"[\s\S]*"$/)||e.match(int_re)||e.match(float_re)||e.match(complex_re)||e.match(rational_re)||e.match(char_re)||["#t","#f","nil","true","false"].includes(e))}var string_re=/"(?:\\[\S\s]|[^"])*"?/g;function escape_regex(e){if(typeof e==="string"){var t=/([-\\^$[\]()+{}?*.|])/g;return e.replace(t,"\\$1")}return e}function Stack(){this.data=[]}Stack.prototype.push=function(e){this.data.push(e)};Stack.prototype.top=function(){return this.data[this.data.length-1]};Stack.prototype.pop=function(){return this.data.pop()};Stack.prototype.is_empty=function(){return!this.data.length};function tokens(e){if(e instanceof LString){e=e.valueOf()}var t=new Lexer(e,{whitespace:true});var r=[];while(true){var n=t.peek(true);if(n===eof){break}r.push(n);t.skip()}return r}function multiline_formatter(e){var t=e.token,r=_objectWithoutProperties(e,_excluded);if(t.match(/^"[\s\S]*"$/)&&t.match(/\n/)){var n=new RegExp("^ {1,"+(e.col+1)+"}","mg");t=t.replace(n,"")}return _objectSpread({token:t},r)}function Thunk(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};this.fn=e;this.cont=t}Thunk.prototype.toString=function(){return"#"};function trampoline(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(t){return tokens(e)}else{var r=tokens(e).map(function(e){if(e.token==="#\\ "||e.token=="#\\\n"){return e.token}return e.token.trim()}).filter(function(e){return e&&!e.match(/^;/)&&!e.match(/^#\|[\s\S]*\|#$/)});return strip_s_comments(r)}}function strip_s_comments(e){var t=0;var r=null;var n=[];for(var i=0;i0&&arguments[0]!==undefined?arguments[0]:null;if(e instanceof LSymbol){if(e.is_gensym()){return e}e=e.valueOf()}if(is_gensym(e)){return LSymbol(e)}if(e!==null){return r(e,Symbol("#:".concat(e)))}t++;return r(t,Symbol("#:g".concat(t)))}}();function QuotedPromise(e){var r=this;var n={pending:true,rejected:false,fulfilled:false,reason:undefined,type:undefined};e=e.then(function(e){n.type=type(e);n.fulfilled=true;n.pending=false;return e});read_only(this,"_promise",e,{hidden:true});if(is_function(e["catch"])){e=e["catch"](function(e){n.rejected=true;n.pending=false;n.reason=e})}Object.keys(n).forEach(function(t){Object.defineProperty(r,"__".concat(t,"__"),{enumerable:true,get:function e(){return n[t]}})});read_only(this,"__promise__",e);this.then=false}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.valueOf().then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.valueOf()["catch"](e))};QuotedPromise.prototype.valueOf=function(){if(!this._promise){throw new Error("QuotedPromise: invalid promise created")}return this._promise};QuotedPromise.prototype.toString=function(){if(this.__pending__){return QuotedPromise.pending_str}if(this.__rejected__){return QuotedPromise.rejected_str}return"#")};QuotedPromise.pending_str="#";QuotedPromise.rejected_str="#";function promise_all(e){if(Array.isArray(e)){return Promise.all(escape_quoted_promises(e)).then(unescape_quoted_promises)}return e}function escape_quoted_promises(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof QuotedPromise){t[r]=new Value(n)}else{t[r]=n}}return t}function unescape_quoted_promises(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof Value){t[r]=n.valueOf()}else{t[r]=n}}return t}var specials={LITERAL:Symbol["for"]("literal"),SPLICE:Symbol["for"]("splice"),SYMBOL:Symbol["for"]("symbol"),names:function e(){return Object.keys(this.__list__)},type:function e(t){try{return this.get(t).type}catch(e){console.log({name:t});console.log(e);return null}},get:function e(t){return this.__list__[t]},off:function e(t){var r=this;var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(Array.isArray(t)){t.forEach(function(e){return r.off(e,n)})}else if(n===null){delete this.__events__[t]}else{this.__events__=this.__events__.filter(function(e){return e!==n})}},on:function e(t,r){var n=this;if(Array.isArray(t)){t.forEach(function(e){return n.on(e,r)})}else if(!this.__events__[t]){this.__events__[t]=[r]}else{this.__events__[t].push(r)}},trigger:function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i",new LSymbol("quote-promise"),specials.LITERAL]];var builtins=defined_specials.map(function(e){return e[0]});Object.freeze(builtins);Object.defineProperty(specials,"__builtins__",{writable:false,value:builtins});defined_specials.forEach(function(e){var t=_slicedToArray(e,3),r=t[0],n=t[1],i=t[2];specials.append(r,n,i)});var Lexer=function(){function p(e){var t=this;var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},n=r.whitespace,i=n===void 0?false:n;_classCallCheck(this,p);read_only(this,"__input__",e.replace(/\r/g,""));var a={};["_i","_whitespace","_col","_newline","_line","_state","_next","_token","_prev_char"].forEach(function(r){Object.defineProperty(t,r,{configurable:false,enumerable:false,get:function e(){return a[r]},set:function e(t){a[r]=t}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}_createClass(p,[{key:"get",value:function e(t){return this.__internal[t]}},{key:"set",value:function e(t,r){this.__internal[t]=r}},{key:"token",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(t){var r=this._line;if(this._whitespace&&this._token==="\n"){--r}return{token:this._token,col:this._col,offset:this._i,line:r}}return this._token}},{key:"peek",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(this._i>=this.__input__.length){return eof}if(this._token){return this.token(t)}var r=this.next_token();if(r){this._token=this.__input__.substring(this._i,this._next);return this.token(t)}return eof}},{key:"skip",value:function e(){if(this._next!==null){this._token=null;this._i=this._next}}},{key:"read_line",value:function e(){var t=this.__input__.length;if(this._i>=t){return eof}for(var r=this._i;r=r){return eof}if(t+this._i>=r){return this.read_rest()}var n=this._i+t;var i=this.__input__.substring(this._i,n);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=n;return i}},{key:"peek_char",value:function e(){if(this._i>=this.__input__.length){return eof}return LCharacter(this.__input__[this._i])}},{key:"read_char",value:function e(){var t=this.peek_char();this.skip_char();return t}},{key:"skip_char",value:function e(){if(this._i1&&arguments[1]!==undefined?arguments[1]:{},n=r.prev_char,i=r["char"],a=r.next_char;var o=_slicedToArray(t,4),u=o[0],s=o[1],c=o[2],l=o[3];if(t.length!==5){throw new Error("Lexer: Invalid rule of length ".concat(t.length))}if(!i.match(u)){return false}if(!match_or_null(s,n)){return false}if(!match_or_null(c,a)){return false}if(l!==this._state){return false}return true}},{key:"next_token",value:function e(){if(this._i>=this.__input__.length){return false}var t=true;e:for(var r=this._i,n=this.__input__.length;r2&&arguments[2]!==undefined?arguments[2]:null;var i=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;if(t.length===0){throw new Error("Lexer: invalid literal rule")}if(t.length===1){return[[t,n,i,null,null]]}var a=[];for(var o=0,u=t.length;o1&&arguments[1]!==undefined?arguments[1]:{},r=t.env,n=t.meta,i=n===void 0?false:n,a=t.formatter,o=a===void 0?multiline_formatter:a;_classCallCheck(this,u);if(e instanceof LString){e=e.toString()}read_only(this,"_formatter",o,{hidden:true});read_only(this,"__lexer__",new Lexer(e));read_only(this,"__env__",r);read_only(this,"_meta",i,{hidden:true});read_only(this,"_refs",[],{hidden:true});read_only(this,"_state",{parentheses:0},{hidden:true})}_createClass(u,[{key:"resolve",value:function e(t){return this.__env__&&this.__env__.get(t,{throwError:false})}},{key:"peek",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=this.__lexer__.peek(true);if(!(r===eof)){t.next=4;break}return t.abrupt("return",eof);case 4:if(!this.is_comment(r.token)){t.next=7;break}this.skip();return t.abrupt("continue",0);case 7:if(!(r.token==="#;")){t.next=14;break}this.skip();if(!(this.__lexer__.peek()===eof)){t.next=11;break}throw new Error("Lexer: syntax error eof found after comment");case 11:t.next=13;return this._read_object();case 13:return t.abrupt("continue",0);case 14:return t.abrupt("break",17);case 17:r=this._formatter(r);if(!this._meta){t.next=20;break}return t.abrupt("return",r);case 20:return t.abrupt("return",r.token);case 21:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"reset",value:function e(){this._refs.length=0}},{key:"skip",value:function e(){this.__lexer__.skip()}},{key:"read",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return this.peek();case 2:r=t.sent;this.skip();return t.abrupt("return",r);case 5:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"match_datum_label",value:function e(t){var r=t.match(/^#([0-9]+)=$/);return r&&r[1]}},{key:"match_datum_ref",value:function e(t){var r=t.match(/^#([0-9]+)#$/);return r&&r[1]}},{key:"is_open",value:function e(t){var r=["(","["].includes(t);if(r){this._state.parentheses++}return r}},{key:"is_close",value:function e(t){var r=[")","]"].includes(t);if(r){this._state.parentheses--}return r}},{key:"read_list",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r,n,i,a,o;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=_nil,n=r;case 1:t.next=4;return this.peek();case 4:a=t.sent;if(!(a===eof)){t.next=7;break}return t.abrupt("break",32);case 7:if(!this.is_close(a)){t.next=10;break}this.skip();return t.abrupt("break",32);case 10:if(!(a==="."&&r!==_nil)){t.next=18;break}this.skip();t.next=14;return this._read_object();case 14:n.cdr=t.sent;i=true;t.next=30;break;case 18:if(!i){t.next=22;break}throw new Error("Parser: syntax error more than one element after dot");case 22:t.t0=Pair;t.next=25;return this._read_object();case 25:t.t1=t.sent;t.t2=_nil;o=new t.t0(t.t1,t.t2);if(r===_nil){r=o}else{n.cdr=o}n=o;case 30:t.next=1;break;case 32:return t.abrupt("return",r);case 33:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"read_value",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return this.read();case 2:r=t.sent;if(!(r===eof)){t.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return t.abrupt("return",parse_argument(r));case 6:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"is_comment",value:function e(t){return t.match(/^;/)||t.match(/^#\|/)&&t.match(/\|#$/)}},{key:"evaluate",value:function e(t){return _evaluate(t,{env:this.__env__,error:function e(t){throw t}})}},{key:"read_object",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:this.reset();t.next=3;return this._read_object();case 3:r=t.sent;if(r instanceof DatumReference){r=r.valueOf()}if(!this._refs.length){t.next=7;break}return t.abrupt("return",this._resolve_object(r));case 7:return t.abrupt("return",r);case 8:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"balanced",value:function e(){return this._state.parentheses===0}},{key:"ballancing_error",value:function e(t,r){var n=this._state.parentheses;var i;if(n<0){i=new Error("Parser: unexpected parenthesis");i.__code__=[r.toString()+")"]}else{i=new Error("Parser: expected parenthesis but eof found");var a=new RegExp("\\){".concat(n,"}$"));i.__code__=[t.toString().replace(a,"")]}throw i}},{key:"_resolve_object",value:function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function e(r){var n=this;var i;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!Array.isArray(r)){t.next=2;break}return t.abrupt("return",r.map(function(e){return n._resolve_object(e)}));case 2:if(!is_plain_object(r)){t.next=6;break}i={};Object.keys(r).forEach(function(e){i[e]=n._resolve_object(r[e])});return t.abrupt("return",i);case 6:if(!(r instanceof Pair)){t.next=8;break}return t.abrupt("return",this._resolve_pair(r));case 8:return t.abrupt("return",r);case 9:case"end":return t.stop()}},e,this)}));function e(e){return t.apply(this,arguments)}return e}()},{key:"_resolve_pair",value:function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function e(r){return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!(r instanceof Pair)){t.next=15;break}if(!(r.car instanceof DatumReference)){t.next=7;break}t.next=4;return r.car.valueOf();case 4:r.car=t.sent;t.next=8;break;case 7:this._resolve_pair(r.car);case 8:if(!(r.cdr instanceof DatumReference)){t.next=14;break}t.next=11;return r.cdr.valueOf();case 11:r.cdr=t.sent;t.next=15;break;case 14:this._resolve_pair(r.cdr);case 15:return t.abrupt("return",r);case 16:case"end":return t.stop()}},e,this)}));function e(e){return t.apply(this,arguments)}return e}()},{key:"_read_object",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r,n,i,a,o,u,s,c,l,f,_;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return this.peek();case 2:r=t.sent;if(!(r===eof)){t.next=5;break}return t.abrupt("return",r);case 5:if(!is_special(r)){t.next=38;break}n=specials.get(r);i=is_builtin(r);this.skip();o=is_symbol_extension(r);if(!o){t.next=14;break}t.t0=undefined;t.next=17;break;case 14:t.next=16;return this._read_object();case 16:t.t0=t.sent;case 17:u=t.t0;if(i){t.next=25;break}s=this.__env__.get(n.symbol);if(!(typeof s==="function")){t.next=25;break}if(is_literal(r)){c=[u]}else if(u===_nil){c=[]}else if(u instanceof Pair){c=u.to_array(false)}if(!(c||o)){t.next=24;break}return t.abrupt("return",call_function(s,o?[]:c,{env:this.__env__,dynamic_env:this.__env__,use_dynamic:false}));case 24:throw new Error("Parse Error: Invalid parser extension "+"invocation ".concat(n.symbol));case 25:if(is_literal(r)){a=new Pair(n.symbol,new Pair(u,_nil))}else{a=new Pair(n.symbol,u)}if(!i){t.next=28;break}return t.abrupt("return",a);case 28:if(!(s instanceof Macro)){t.next=37;break}t.next=31;return this.evaluate(a);case 31:l=t.sent;if(!(l instanceof Pair||l instanceof LSymbol)){t.next=34;break}return t.abrupt("return",Pair.fromArray([LSymbol("quote"),l]));case 34:return t.abrupt("return",l);case 37:throw new Error("Parse Error: invalid parser extension: "+n.symbol);case 38:f=this.match_datum_ref(r);if(!(f!==null)){t.next=44;break}this.skip();if(!this._refs[f]){t.next=43;break}return t.abrupt("return",new DatumReference(f,this._refs[f]));case 43:throw new Error("Parse Error: invalid datum label #".concat(f,"#"));case 44:_=this.match_datum_label(r);if(!(_!==null)){t.next=51;break}this.skip();this._refs[_]=this._read_object();return t.abrupt("return",this._refs[_]);case 51:if(!this.is_close(r)){t.next=55;break}this.skip();t.next=61;break;case 55:if(!this.is_open(r)){t.next=60;break}this.skip();return t.abrupt("return",this.read_list());case 60:return t.abrupt("return",this.read_value());case 61:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()}]);return u}();var DatumReference=function(){function r(e,t){_classCallCheck(this,r);this.name=e;this.data=t}_createClass(r,[{key:"valueOf",value:function e(){return this.data}}]);return r}();function _parse(e,t){return _parse2.apply(this,arguments)}function _parse2(){_parse2=_wrapAsyncGenerator(_regeneratorRuntime.mark(function e(r,n){var i,a,o;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!n){if(global_env){n=global_env.get("**interaction-environment**",{throwError:false})}else{n=user_env}}i=new Parser(r,{env:n});case 3:t.next=6;return _awaitAsyncGenerator(i.read_object());case 6:o=t.sent;if(!i.balanced()){i.ballancing_error(o,a)}if(!(o===eof)){t.next=10;break}return t.abrupt("break",15);case 10:a=o;t.next=13;return o;case 13:t.next=3;break;case 15:case"end":return t.stop()}},e)}));return _parse2.apply(this,arguments)}function unpromise(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(e){return e};var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;if(is_promise(e)){var n=e.then(t);if(r===null){return n}else{return n["catch"](r)}}if(e instanceof Array){return unpromise_array(e,t,r)}if(is_plain_object(e)){return unpromise_object(e,t,r)}return t(e)}function unpromise_array(t,r,e){if(t.find(is_promise)){return unpromise(promise_all(t),function(e){if(Object.isFrozen(t)){Object.freeze(e)}return r(e)},e)}return r(t)}function unpromise_object(t,e,r){var i=Object.keys(t);var n=[],a=[];var o=i.length;while(o--){var u=i[o];var s=t[u];n[o]=s;if(is_promise(s)){a.push(s)}}if(a.length){return unpromise(promise_all(n),function(e){var n={};e.forEach(function(e,t){var r=i[t];n[r]=e});if(Object.isFrozen(t)){Object.freeze(n)}return n},r)}return e(t)}function read_only(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},i=n.hidden,a=i===void 0?false:i;Object.defineProperty(e,t,{value:r,configurable:true,enumerable:!a})}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=_asyncToGenerator(_regeneratorRuntime.mark(function e(r){var n,i,a,o,u,s,c;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:n=[];i=false;a=false;t.prev=3;u=_asyncIterator(r);case 5:t.next=7;return u.next();case 7:if(!(i=!(s=t.sent).done)){t.next=13;break}c=s.value;n.push(c);case 10:i=false;t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15;t.t0=t["catch"](3);a=true;o=t.t0;case 19:t.prev=19;t.prev=20;if(!(i&&u["return"]!=null)){t.next=24;break}t.next=24;return u["return"]();case 24:t.prev=24;if(!a){t.next=27;break}throw o;case 27:return t.finish(24);case 28:return t.finish(19);case 29:return t.abrupt("return",n);case 30:case"end":return t.stop()}},e,null,[[3,15,19,29],[20,,24,28]])}));return _uniterate_async.apply(this,arguments)}function matcher(e,t){if(t instanceof RegExp){return function(e){return String(e).match(t)}}else if(is_function(t)){return t}throw new Error("Invalid matcher")}function doc(e,t,r,n){if(typeof e!=="string"){t=arguments[0];r=arguments[1];n=arguments[2];e=null}if(r){if(n){t.__doc__=r}else{t.__doc__=trim_lines(r)}}if(e){t.__name__=e}else if(t.name&&!is_lambda(t)){t.__name__=t.name}return t}function trim_lines(e){return e.split("\n").map(function(e){return e.trim()}).join("\n")}function previousSexp(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var r=e.length;if(t<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(t))}e:while(t--&&r>=0){var n=1;while(n>0){var i=e[--r];if(!i){break e}if(i==="("||i.token==="("){n--}else if(i===")"||i.token===")"){n++}}r--}return e.slice(r+1)}function lineIndent(e){if(!e||!e.length){return 0}var t=e.length;if(e[t-1].token==="\n"){return 0}while(--t){if(e[t].token==="\n"){var r=(e[t+1]||{}).token;if(r){return r.length}}}return 0}function match(e,t){return l(e,t)===t.length;function l(r,n){function e(e,t){var r=_createForOfIteratorHelper(e),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;var a=l(i,t);if(a!==-1){return a}}}catch(e){r.e(e)}finally{r.f()}return-1}function t(){return r[a]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function i(){var e=r[a+1];var t=n[u+1];if(e!==undefined&&t!==undefined){return l([e],[t])}}var a=0;var o={};for(var u=0;u0){continue}}else if(t()){return-1}}else if(r[a]instanceof Array){var c=l(r[a],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;a++;continue}else{return-1}a++}if(r.length!==a){return-1}return n.length}}function Formatter(e){this.__code__=e.replace(/\r/g,"")}Formatter.defaults={offset:0,indent:2,exceptions:{specials:[/^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|(?:call-with-(?:input-file|output-file|port))|lambda|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax|\*)?)$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(t){var r=Formatter.defaults;if(typeof t==="undefined"){return Object.assign({},r)}var n=t&&t.exceptions||{};var i=n.specials||[];var a=n.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},r),t),{},{exceptions:{specials:[].concat(_toConsumableArray(r.exceptions.specials),_toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(_toConsumableArray(r.exceptions.shift[1]),_toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(t){var r=tokenize(this.__code__,true);return this._indent(r,t)};Formatter.exception_shift=function(a,e){function t(e){if(!e.length){return false}if(e.indexOf(a)!==-1){return true}else{var t=e.filter(function(e){return e instanceof RegExp});if(!t.length){return false}var r=_createForOfIteratorHelper(t),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;if(a.match(i)){return true}}}catch(e){r.e(e)}finally{r.f()}}return false}if(t(e.exceptions.specials)){return e.indent}var r=e.exceptions.shift;for(var n=0,i=Object.entries(r);n0){n.offset=0}if(a.toString()===t.toString()&&balanced(a)){return n.offset+a[0].col}else if(a.length===1){return n.offset+a[0].col+1}else{var s=-1;if(o){var c=Formatter.exception_shift(o.token,n);if(c!==-1){s=c}}if(s===-1){s=Formatter.exception_shift(a[1].token,n)}if(s!==-1){return n.offset+a[0].col+s}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return n.offset+a[1].col}return n.offset+a[3].col}else if(a[0].line===a[1].line){return n.offset+n.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,t=new Array(e),r=0;r")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/^[[(]$/;var p_e=/^[\])]$/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var glob=Symbol["for"]("*");var sexp_or_atom=new Pattern([p_o,glob,p_e],[not_p],"+");var sexp=new Pattern([p_o,glob,p_e],"+");var symbol=new Pattern([Symbol["for"]("symbol")],"?");var symbols=new Pattern([Symbol["for"]("symbol")],"*");var identifiers=[p_o,symbols,p_e];var let_value=new Pattern([p_o,Symbol["for"]("symbol"),glob,p_e],"+");var def_lambda_re=keywords_re("define","lambda","define-macro","syntax-rules");var non_def=/^(?!.*\b(?:[()[\]]|define(?:-macro)?|let(?:\*|rec|-env|-syntax|)?|lambda|syntax-rules)\b).*$/;var let_re=/^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/;function keywords_re(){for(var e=arguments.length,t=new Array(e),r=0;r0&&!u[e]){u[e]=previousSexp(o,e)}});var s=_createForOfIteratorHelper(i),c;try{for(s.s();!(c=s.n()).done;){var l=_slicedToArray(c.value,3),f=l[0],_=l[1],p=l[2];_=_.valueOf();var h=_>0?u[_]:o;var d=h.filter(function(e){return e.trim()&&!is_special(e)});var m=r(h);var y=match(f,d);var v=n.slice(a).find(function(e){return e.trim()&&!is_special(e)});if(y&&(p instanceof Ahead&&p.match(v)||!p)){var g=a-m;if(n[g]!=="\n"){if(!n[g].trim()){n[g]="\n"}else{n.splice(g,0,"\n");a++}}a+=m;continue e}}}catch(e){s.e(e)}finally{s.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return" ".repeat(e)};Formatter.prototype.format=function e(t){var r=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var n=tokenize(r,true);var i=this._options(t);var a=0;var o=0;for(var u=0;u0){n=Math.floor(t()*r);r--;var i=[e[n],e[r]];e[r]=i[0];e[n]=i[1]}return e}function Nil(){}Nil.prototype.toString=function(){return"()"};Nil.prototype.valueOf=function(){return undefined};Nil.prototype.serialize=function(){return 0};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,_nil)};Nil.prototype.to_array=function(){return[]};var _nil=new Nil;function Pair(e,t){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,t)}this.car=e;this.cdr=t}function to_array(a,o){return function e(t){typecheck(a,t,["pair","nil"]);if(t===_nil){return[]}var r=[];var n=t;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(o&&i instanceof Pair){i=this.get(a).call(this,i)}r.push(i);n=n.cdr}else if(n===_nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return r}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var t=this;while(true){if(!t||t===_nil||!(t instanceof Pair)||t.haveCycles("cdr")){break}e++;t=t.cdr}return e};Pair.match=function(e,t){if(e instanceof LSymbol){return LSymbol.is(e,t)}else if(e instanceof Pair){return Pair.match(e.car,t)||Pair.match(e.cdr,t)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,t)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,t)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var n=new Map;function i(e){if(e instanceof Pair){if(n.has(e)){return n.get(e)}var t=new Pair;n.set(e,t);if(r){t.car=i(e.car)}else{t.car=e.car}t.cdr=i(e.cdr);t[__cycles__]=e[__cycles__];return t}return e}return i(this)};Pair.prototype.last_pair=function(){var e=this;while(true){if(e.cdr===_nil){return e}e=e.cdr}};Pair.prototype.to_array=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var t=[];if(this.car instanceof Pair){if(e){t.push(this.car.to_array())}else{t.push(this.car)}}else{t.push(this.car.valueOf())}if(this.cdr instanceof Pair){t=t.concat(this.cdr.to_array(e))}return t};Pair.fromArray=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(e instanceof Pair||r&&e instanceof Array&&e[__data__]){return e}if(t===false){var n=_nil;for(var i=e.length;i--;){n=new Pair(e[i],n)}return n}if(e.length&&!(e instanceof Array)){e=_toConsumableArray(e)}var a=_nil;var o=e.length;while(o--){var u=e[o];if(u instanceof Array){u=Pair.fromArray(u,t,r)}else if(typeof u==="string"){u=LString(u)}else if(typeof u==="number"&&!Number.isNaN(u)){u=LNumber(u)}a=new Pair(u,a)}return a};Pair.prototype.to_object=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var t=this;var r={};while(true){if(t instanceof Pair&&t.car instanceof Pair){var n=t.car;var i=n.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=n.cdr;if(a instanceof Pair){a=a.to_object(e)}if(is_native(a)){if(!e){a=a.valueOf()}}r[i]=a;t=t.cdr}else{break}}return r};Pair.fromPairs=function(e){return e.reduce(function(e,t){return new Pair(new Pair(new LSymbol(t[0]),t[1]),e)},_nil)};Pair.fromObject=function(t){var e=Object.keys(t).map(function(e){return[e,t[e]]});return Pair.fromPairs(e)};Pair.prototype.reduce=function(e){var t=this;var r=_nil;while(true){if(t!==_nil){r=e(r,t.car);t=t.cdr}else{break}}return r};Pair.prototype.reverse=function(){if(this.haveCycles()){throw new Error("You can't reverse list that have cycles")}var e=this;var t=_nil;while(e!==_nil){var r=e.cdr;e.cdr=t;t=e;e=r}return t};Pair.prototype.transform=function(n){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var t=n(e.car);if(t instanceof Pair){t=i(t)}var r=n(e.cdr);if(r instanceof Pair){r=i(r)}return new Pair(t,r)}return e}return i(this)};Pair.prototype.map=function(e){if(typeof this.car!=="undefined"){return new Pair(e(this.car),this.cdr===_nil?_nil:this.cdr.map(e))}else{return _nil}};var repr=new Map;function is_plain_object(e){return e&&_typeof$1(e)==="object"&&e.constructor===Object}var props=Object.getOwnPropertyNames(Array.prototype);var array_methods=[];props.forEach(function(e){array_methods.push(Array[e],Array.prototype[e])});function is_array_method(e){e=unbind(e);return array_methods.includes(e)}function is_lips_function(e){return is_function(e)&&(is_lambda(e)||e.__doc__)}function user_repr(r){var e=r.constructor||Object;var n=is_plain_object(r);var i=is_function(r[Symbol.asyncIterator])||is_function(r[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,t){t=unbind(t);if(r.constructor===t&&(t===Object&&n&&!i||t!==Object)){a=e}})}return a}var str_mapping=new Map;[[true,"#t"],[false,"#f"],[null,"null"],[undefined,"#"]].forEach(function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];str_mapping.set(r,n)});function symbolize(r){if(r&&_typeof$1(r)==="object"){var n={};var e=Object.getOwnPropertySymbols(r);e.forEach(function(e){var t=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");n[t]=toString(r[e])});var t=Object.getOwnPropertyNames(r);t.forEach(function(e){var t=r[e];if(t&&_typeof$1(t)==="object"&&t.constructor===Object){n[e]=symbolize(t)}else{n[e]=toString(t)}});return n}return r}function get_props(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function has_own_function(e,t){return e.hasOwnProperty(t)&&is_function(e.toString)}function function_to_string(e){if(is_native_function(e)){return"#"}var t=e.prototype&&e.prototype.constructor;if(is_function(t)&&is_lambda(t)){if(e[__class__]&&t.hasOwnProperty("__name__")){var r=t.__name__;if(LString.isString(r)){r=r.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof$1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!is_lambda(e)){return"#")}else{return"#"}}var instances=new Map;[[Error,function(e){return e.message}],[Pair,function(e,t){var r=t.quote,n=t.skip_cycles,i=t.pair_args;if(!n){e.markCycles()}return e.toString.apply(e,[r].concat(_toConsumableArray(i)))}],[LCharacter,function(e,t){var r=t.quote;if(r){return e.toString()}return e.valueOf()}],[LString,function(e,t){var r=t.quote;e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];instances.set(r,n)});var native_types=[LSymbol,LNumber,Macro,Values,InputPort,OutputPort,Environment,QuotedPromise];function toString(e,t,r){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(is_prototype(e)){return"#"}if(e){var n=e.constructor;if(instances.has(n)){for(var i=arguments.length,a=new Array(i>3?i-3:0),o=3;o"}if(e===null){return"null"}if(_typeof$1(e)==="object"){var l=e.constructor;if(!l){l=Object}var f;if(typeof l.__class__==="string"){f=l.__class__}else{var _=user_repr(e);if(_){if(is_function(_)){return _(e,t)}else{throw new Error("toString: Invalid repr value")}}f=l.name}if(is_function(e.toString)&&is_lambda(e.toString)){return e.toString().valueOf()}if(type(e)==="instance"){if(is_lambda(l)&&l.__name__){f=l.__name__.valueOf()}else if(!is_native_function(l)){f="instance"}}if(is_iterator(e,Symbol.iterator)){if(f){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(f){return"#")}return"#"}if(f!==""){return"#<"+f+">"}return"#"}if(typeof e!=="string"){return e.toString()}return e}function is_prototype(e){return e&&_typeof$1(e)==="object"&&e.hasOwnProperty&&e.hasOwnProperty("constructor")&&typeof e.constructor==="function"&&e.constructor.prototype===e}Pair.prototype.markCycles=function(){markCycles(this);return this};Pair.prototype.haveCycles=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(!e){return this.haveCycles("car")||this.haveCycles("cdr")}return!!(this[__cycles__]&&this[__cycles__][e])};function markCycles(e){var t=[];var i=[];var a=[];function o(e){if(!t.includes(e)){t.push(e)}}function u(e,t,r,n){if(r instanceof Pair){if(n.includes(r)){if(!a.includes(r)){a.push(r)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][t]=r;if(!i.includes(e)){i.push(e)}return true}}}var s=trampoline(function e(t,r){if(t instanceof Pair){delete t.ref;delete t[__cycles__];o(t);r.push(t);var n=u(t,"car",t.car,r);var i=u(t,"cdr",t.cdr,r);if(!n){s(t.car,r.slice())}if(!i){return new Thunk(function(){return e(t.cdr,r.slice())})}}});function r(e,t){if(e[__cycles__][t]instanceof Pair){var r=n.indexOf(e[__cycles__][t]);e[__cycles__][t]="#".concat(r,"#")}}s(e,[]);var n=t.filter(function(e){return a.includes(e)});n.forEach(function(e,t){e[__ref__]="#".concat(t,"=")});i.forEach(function(e){r(e,"car");r(e,"cdr")})}Pair.prototype.toString=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.nested,n=r===void 0?false:r;var i=[];if(this[__ref__]){i.push(this[__ref__]+"(")}else if(!n){i.push("(")}var a;if(this[__cycles__]&&this[__cycles__].car){a=this[__cycles__].car}else{a=toString(this.car,e,true)}if(a!==undefined){i.push(a)}if(this.cdr instanceof Pair){if(this[__cycles__]&&this[__cycles__].cdr){i.push(" . ");i.push(this[__cycles__].cdr)}else{if(this.cdr[__ref__]){i.push(" . ")}else{i.push(" ")}var o=this.cdr.toString(e,{nested:true});i.push(o)}}else if(this.cdr!==_nil){i=i.concat([" . ",toString(this.cdr,e,true)])}if(!n||this[__ref__]){i.push(")")}return i.join("")};Pair.prototype.set=function(e,t){this[e]=t;if(t instanceof Pair){this.markCycles()}};Pair.prototype.append=function(e){if(e instanceof Array){return this.append(Pair.fromArray(e))}var t=this;if(t.car===undefined){if(e instanceof Pair){this.car=e.car;this.cdr=e.cdr}else{this.car=e}}else if(e!==_nil){while(true){if(t instanceof Pair&&t.cdr!==_nil){t=t.cdr}else{break}}t.cdr=e}return this};Pair.prototype.serialize=function(){return[this.car,this.cdr]};Pair.prototype[Symbol.iterator]=function(){var r=this;return{next:function e(){var t=r;r=t.cdr;if(t===_nil){return{value:undefined,done:true}}else{return{value:t.car,done:false}}}}};function abs(e){return e<0?-e:e}function seq_compare(e,t){var r=_toArray(t),n=r[0],i=r.slice(1);while(i.length>0){var a=i,o=_slicedToArray(a,1),u=o[0];if(!e(n,u)){return false}var s=i;var c=_toArray(s);n=c[0];i=c.slice(1)}return true}function equal(e,t){if(is_function(e)){return is_function(t)&&unbind(e)===unbind(t)}else if(e instanceof LNumber){if(!(t instanceof LNumber)){return false}var r;if(e.__type__===t.__type__){if(e.__type__==="complex"){r=e.__im__.__type__===t.__im__.__type__&&e.__re__.__type__===t.__re__.__type__}else{r=true}if(r&&e.cmp(t)===0){if(e.valueOf()===0){return Object.is(e.valueOf(),t.valueOf())}return true}}return false}else if(typeof e==="number"){if(typeof t!=="number"){return false}if(Number.isNaN(e)){return Number.isNaN(t)}if(e===Number.NEGATIVE_INFINITY){return t===Number.NEGATIVE_INFINITY}if(e===Number.POSITIVE_INFINITY){return t===Number.POSITIVE_INFINITY}return equal(LNumber(e),LNumber(t))}else if(e instanceof LCharacter){if(!(t instanceof LCharacter)){return false}return e.__char__===t.__char__}else{return e===t}}function same_atom(e,t){if(type(e)!==type(t)){return false}if(!is_atom(e)){return false}if(e instanceof RegExp){return e.source===t.source}if(e instanceof LString){return e.valueOf()===t.valueOf()}return equal(e,t)}function is_atom(e){return e instanceof LSymbol||LString.isString(e)||e===_nil||e===null||e instanceof LCharacter||e instanceof LNumber||e===true||e===false}var truncate=function(){if(Math.trunc){return Math.trunc}else{return function(e){if(e===0){return 0}else if(e<0){return Math.ceil(e)}else{return Math.floor(e)}}}}();function Macro(e,t,r,n){if(typeof this!=="undefined"&&this.constructor!==Macro||typeof this==="undefined"){return new Macro(e,t)}typecheck("Macro",e,"string",1);typecheck("Macro",t,"function",2);if(r){if(n){this.__doc__=r}else{this.__doc__=trim_lines(r)}}this.__name__=e;this.__fn__=t}Macro.defmacro=function(e,t,r,n){var i=new Macro(e,t,r,n);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,t,r){var n=t.env,i=_objectWithoutProperties(t,_excluded2);var a=_objectSpread(_objectSpread({},i),{},{macro_expand:r});var o=this.__fn__.call(n,e,a,this.__name__);return o};Macro.prototype.toString=function(){return"#")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(c){return function(){var r=_asyncToGenerator(_regeneratorRuntime.mark(function e(r,v){var a,g,n,i,o,b,w,D,x,E,L,S,u,A,s;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:s=function e(){s=_asyncToGenerator(_regeneratorRuntime.mark(function e(r,n,i){var a,o,u,s,c,l,f,_,p,h,d,m,y;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!(r instanceof Pair&&r.car instanceof LSymbol)){t.next=50;break}if(!r[__data__]){t.next=3;break}return t.abrupt("return",r);case 3:a=r.car.valueOf();o=i.get(r.car,{throwError:false});u=b(r.car);s=u||w(o,r)||D(o);if(!(s&&r.cdr.car instanceof Pair)){t.next=28;break}if(!u){t.next=15;break}g=E(r.cdr.car);t.next=12;return S(r.cdr.car,n);case 12:c=t.sent;t.next=17;break;case 15:g=x(r.cdr.car);c=r.cdr.car;case 17:t.t0=Pair;t.t1=r.car;t.t2=Pair;t.t3=c;t.next=23;return A(r.cdr.cdr,n,i);case 23:t.t4=t.sent;t.t5=new t.t2(t.t3,t.t4);return t.abrupt("return",new t.t0(t.t1,t.t5));case 28:if(!L(a,o)){t.next=50;break}l=o instanceof Syntax?r:r.cdr;t.next=32;return o.invoke(l,_objectSpread(_objectSpread({},v),{},{env:i}),true);case 32:f=t.sent;if(!(o instanceof Syntax)){t.next=41;break}_=f,p=_.expr,h=_.scope;if(!(p instanceof Pair)){t.next=40;break}if(!(n!==-1&&n<=1||n")}return"#"};Syntax.className="syntax";var SyntaxParameter=function(e){_inherits(t,e);function t(){_classCallCheck(this,t);return _callSuper(this,t,arguments)}return _createClass(t)}(Syntax);Syntax.Parameter=SyntaxParameter;function extract_patterns(e,t,w,D){var r=arguments.length>4&&arguments[4]!==undefined?arguments[4]:{};var x={"...":{symbols:{},lists:[]},symbols:{}};var E=r.expansion,L=r.define;function S(e){if(is_debug()){console.log(e)}}S(w);function A(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;S({code:t&&toString(t,true),pattern:e&&toString(e,true)});if(is_atom(e)&&!(e instanceof LSymbol)){return same_atom(e,t)}if(e instanceof LSymbol&&w.includes(e.literal())){var i=E.ref(t);if(LSymbol.is(t,e)){if(typeof i==="undefined"){return true}return i===L||i===global_env}return false}if(e instanceof Pair&&e.car instanceof Pair&&e.car.cdr instanceof Pair&&LSymbol.is(e.car.cdr.car,D)){S(">> 0");if(t===_nil){S({pattern:e.toString()});if(e.car.car instanceof LSymbol){if(e.car.cdr instanceof Pair&&LSymbol.is(e.car.cdr.car,D)){var a=e.car.car.valueOf();var o=e.last_pair();if(LSymbol.is(o.car,D)){x["..."].symbols[a]=null;return true}else{return false}}var u=e.car.car.valueOf();if(x["..."].symbols[u]){throw new Error("syntax: named ellipsis can only "+"appear onces")}x["..."].symbols[u]=t}}}if(e instanceof Pair&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,D)){if(e.cdr.cdr!==_nil){if(e.cdr.cdr instanceof Pair){var s=e.cdr.cdr.length();if(!is_pair(t)){return false}var c=t.length();var l=t;while(c-1>s){l=l.cdr;c--}var f=l.cdr;l.cdr=_nil;if(!A(e.cdr.cdr,f,r,n)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(x["..."].symbols[_]&&!r.includes(_)&&!n){throw new Error("syntax: named ellipsis can only appear onces")}S(">> 1");if(t===_nil){S(">> 2");if(n){S("NIL");x["..."].symbols[_]=_nil}else{S("NULL");x["..."].symbols[_]=null}}else if(t instanceof Pair&&(t.car instanceof Pair||t.car===_nil)){S(">> 3 "+n);if(n){if(x["..."].symbols[_]){var p=x["..."].symbols[_];if(p===_nil){p=new Pair(_nil,new Pair(t,_nil))}else{p=p.append(new Pair(t,_nil))}x["..."].symbols[_]=p}else{x["..."].symbols[_]=new Pair(t,_nil)}}else{S(">> 4");x["..."].symbols[_]=new Pair(t,_nil)}}else{S(">> 6");if(t instanceof Pair){S(">> 7 "+n);r.push(_);if(!x["..."].symbols[_]){x["..."].symbols[_]=new Pair(t,_nil)}else{var h=x["..."].symbols[_];x["..."].symbols[_]=h.append(new Pair(t,_nil))}S({IIIIII:x["..."].symbols[_].toString()})}else if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,D)){S(">> 8");x["..."].symbols[_]=null;return A(e.cdr.cdr,t)}else{S(">> 9");return false}}return true}else if(e.car instanceof Pair){var d=_toConsumableArray(r);if(t===_nil){S(">> 10");x["..."].lists.push(_nil);return true}S(">> 11");var m=t;while(m instanceof Pair){if(!A(e.car,m.car,d,true)){return false}m=m.cdr}return true}return false}if(e instanceof LSymbol){if(LSymbol.is(e,D)){throw new Error("syntax: invalid usage of ellipsis")}S(">> 12");var y=e.__name__;if(w.includes(y)){return true}if(n){x["..."].symbols[y]=x["..."].symbols[y]||[];x["..."].symbols[y].push(t)}x.symbols[y]=t;if(!x.symbols[y]);return true}if(e instanceof Pair&&t instanceof Pair){S(">> 13");S({a:12,code:t&&t.toString(),pattern:e.toString()});if(t.cdr===_nil){var v=e.car instanceof LSymbol&&e.cdr instanceof LSymbol;if(v){if(!A(e.car,t.car,r,n)){return false}S(">> 14");var g=e.cdr.valueOf();if(!(g in x.symbols)){x.symbols[g]=_nil}g=e.car.valueOf();if(!(g in x.symbols)){x.symbols[g]=t.car}return true}}S({pattern:e.toString(),code:t.toString()});if(e.cdr instanceof Pair&&e.cdr.cdr instanceof Pair&&e.cdr.car instanceof LSymbol&&LSymbol.is(e.cdr.cdr.car,D)&&e.cdr.cdr.cdr instanceof Pair&&!LSymbol.is(e.cdr.cdr.cdr.car,D)&&A(e.car,t.car,r,n)&&A(e.cdr.cdr.cdr,t.cdr,r,n)){var b=e.cdr.car.__name__;S({pattern:e.car.toString(),code:t.car.toString(),name:b});if(w.includes(b)){return true}x["..."].symbols[b]=null;return true}S("recur");if(A(e.car,t.car,r,n)&&A(e.cdr,t.cdr,r,n)){return true}}else if(e===_nil&&(t===_nil||t===undefined)){return true}else if(e.car instanceof Pair&&LSymbol.is(e.car.car,D)){throw new Error("syntax: invalid usage of ellipsis")}else{return false}}if(A(e,t)){return x}}function clear_gensyms(e,i){function a(t){if(t instanceof Pair){if(!i.length){return t}var e=a(t.car);var r=a(t.cdr);return new Pair(e,r)}else if(t instanceof LSymbol){var n=i.find(function(e){return e.gensym===t});if(n){return LSymbol(n.name)}return t}else{return t}}return a(e)}function transform_syntax(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var A=e.bindings,t=e.expr,F=e.scope,o=e.symbols,c=e.names,k=e.ellipsis;var l={};function u(e){if(e instanceof LSymbol){return true}return["string","symbol"].includes(_typeof$1(e))}function P(e){if(!u(e)){var t=type(e);throw new Error("syntax: internal error, need symbol got ".concat(t))}var r=e.valueOf();if(r===k){throw new Error("syntax: internal error, ellipis not transformed")}var n=_typeof$1(r);if(["string","symbol"].includes(n)){if(r in A.symbols){return A.symbols[r]}else if(n==="string"&&r.match(/\./)){var i=r.split(".");var a=i[0];if(a in A.symbols){return Pair.fromArray([LSymbol("."),A.symbols[a]].concat(i.slice(1).map(function(e){return LString(e)})))}}}if(o.includes(r)){return LSymbol(r)}return s(r)}function C(e){if(is_debug()){console.log(e)}}function s(e){if(!l[e]){var t=F.ref(e);var r=gensym(e);if(t){var n=F.get(e);F.set(r,n)}else{var i=F.get(e,{throwError:false});if(typeof i!=="undefined"){F.set(r,i)}}c.push({name:e,gensym:r});l[e]=r;if(typeof e==="string"&&e.match(/\./)){var a=e.split(".").filter(Boolean),o=_toArray(a),u=o[0],s=o.slice(1);if(l[u]){hidden_prop(r,"__object__",[l[u]].concat(_toConsumableArray(s)))}}}return l[e]}function B(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:function(){};var i=r.nested;C(" ==> "+e.toString(true));C(t);if(e instanceof LSymbol){var a=e.valueOf();C("[t 1");if(t[a]){if(t[a]instanceof Pair){var o=t[a],u=o.car,s=o.cdr;if(i){var c=u.car,l=u.cdr;if(l!==_nil){n(a,new Pair(l,_nil))}return c}if(s!==_nil){n(a,s)}return u}else if(t[a]instanceof Array){n(a,t[a].slice(1));return t[a][0]}}return P(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,k)){C("[t 2");var f=e.car.valueOf();var _=t[f];C({expr:e.toString(true),name:f,bindings:t,item:_});if(_===null){return}else if(_){C({b:t[f].toString()});if(_ instanceof Pair){C("[t 2 Pair "+i);C({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==_nil){C("|| next 1");n(f,h)}C({car:p.toString()});return p}else{if(p.cdr!==_nil){C("|| next 2");n(f,new Pair(p.cdr,h))}C({car:p.car.toString()});return p.car}}else if(_ instanceof Array){C("[t 2 Array "+i);if(i){n(f,_.slice(1));return Pair.fromArray(_)}else{var d=_.slice(1);if(d.length){n(f,d)}return _[0]}}else{return _}}}C("[t 3 recur "+e.toString());var m=B(e.car,t,r,n);var y=B(e.cdr,t,r,n);return new Pair(m,y)}return e}function O(t,r){var e=Object.values(t);var n=Object.getOwnPropertySymbols(t);if(n.length){e.push.apply(e,_toConsumableArray(n.map(function(e){return t[e]})))}return e.length&&e.every(function(e){if(e===null){return!r}return e instanceof Pair||e===_nil||e instanceof Array&&e.length})}function I(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function N(i){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},t=e.disabled;C("traverse>> "+toString(i));if(i instanceof Pair){if(!t&&i.car instanceof Pair&&LSymbol.is(i.car.car,k)){return N(i.car.cdr,{disabled:true})}if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,k)&&!t){C(">> 1");var r=A["..."].symbols;var n=Object.values(r);if(n.length&&n.every(function(e){return e===null})){return N(i.cdr.cdr,{disabled:t})}var a=I(r);var o=i.car instanceof LSymbol&&LSymbol.is(i.cdr.cdr.car,k);if(i.car instanceof Pair||o){if(A["..."].lists[0]===_nil){return _nil}var u=i.car;if(o){u=new Pair(i.car,new Pair(i.cdr.car,_nil))}C(">> 2");var s;if(a.length){C(">> 2 (a)");var c=_objectSpread({},r);s=_nil;var l=function e(){if(!O(c)){return 1}var n={};var t=function e(t,r){n[t]=r};var r=B(u,c,{nested:true},t);if(r!==undefined){if(o){if(s===_nil){s=r}else{s=s.append(r)}}else{s=new Pair(r,s)}}c=n};while(true){if(l())break}if(s!==_nil&&!o){s=s.reverse()}if(i.cdr.cdr!==_nil&&!LSymbol.is(i.cdr.cdr.car,k)){var f=N(i.cdr.cdr,{disabled:t});return s.append(f)}return s}else{C(">> 3");var _=B(i.car,r,{nested:true});if(_){return new Pair(_,_nil)}return _nil}}else if(i.car instanceof LSymbol){C(">> 4");if(LSymbol.is(i.cdr.cdr.car,k)){C(">> 4 (a)")}else{C(">> 4 (b)")}var p=i.car.__name__;var h=_defineProperty({},p,r[p]);var d=r[p]===null;var m=_nil;var y=function e(){if(!O(h,true)){C({bind:h});return 1}var n={};var t=function e(t,r){n[t]=r};var r=B(i,h,{nested:false},t);C({value:r.toString()});if(typeof r!=="undefined"){m=new Pair(r,m)}h=n};while(true){if(y())break}if(m!==_nil){m=m.reverse()}if(i.cdr instanceof Pair){if(i.cdr.cdr instanceof Pair||i.cdr.cdr instanceof LSymbol){var v=N(i.cdr.cdr,{disabled:t});if(d){return v}C("<<<< 1");m.append(v)}}C("<<<< 2");return m}}var g=N(i.car,{disabled:t});var b;var w;if(i.car instanceof LSymbol){var D=F.get(i.car,{throwError:false});w=D instanceof Macro&&D.__name__==="syntax-rules"}if(w){if(i.cdr.car instanceof LSymbol){b=new Pair(N(i.cdr.car,{disabled:t}),new Pair(i.cdr.cdr.car,N(i.cdr.cdr.cdr,{disabled:t})))}else{b=new Pair(i.cdr.car,N(i.cdr.cdr,{disabled:t}))}C("REST >>>> "+b.toString())}else{b=N(i.cdr,{disabled:t})}C({a:true,car:toString(i.car),cdr:toString(i.cdr),head:toString(g),rest:toString(b)});return new Pair(g,b)}if(i instanceof LSymbol){if(t&&LSymbol.is(i,k)){return i}var x=Object.keys(A["..."].symbols);var E=i.literal();if(x.includes(E)){var L="missing ellipsis symbol next to name `".concat(E,"'");throw new Error("syntax-rules: ".concat(L))}var S=P(i);if(typeof S!=="undefined"){return S}}return i}return N(t,{})}function is_null(e){return is_undef(e)||e===_nil||e===null}function is_function(e){return typeof e==="function"&&typeof e.bind==="function"}function is_continuation(e){return e instanceof Continuation}function is_context(e){return e instanceof LambdaContext}function is_parameter(e){return e instanceof Parameter}function is_pair(e){return e instanceof Pair}function is_env(e){return e instanceof Environment}function is_callable(e){return is_function(e)||is_continuation(e)||is_parameter(e)}function is_promise(e){if(e instanceof QuotedPromise){return false}if(e instanceof Promise){return true}return!!e&&is_function(e.then)}function is_undef(e){return typeof e==="undefined"}function is_iterator(e,t){if(has_own_symbol(e,t)||has_own_symbol(e.__proto__,t)){return is_function(e[t])}}function is_instance(e){if(!e){return false}if(_typeof$1(e)!=="object"){return false}if(e.__instance__){e.__instance__=false;return e.__instance__}return false}function self_evaluated(e){var t=_typeof$1(e);return["string","function"].includes(t)||_typeof$1(e)==="symbol"||e instanceof QuotedPromise||e instanceof LSymbol||e instanceof LNumber||e instanceof LString||e instanceof RegExp}function is_native(e){return e instanceof LNumber||e instanceof LString||e instanceof LCharacter}function has_own_symbol(e,t){if(e===null){return false}return _typeof$1(e)==="object"&&t in Object.getOwnPropertySymbols(e)}function box(e){switch(_typeof$1(e)){case"string":return LString(e);case"bigint":return LNumber(e);case"number":if(Number.isNaN(e)){return nan}else{return LNumber(e)}}return e}function map_object(r,n){var e=Object.getOwnPropertyNames(r);var t=Object.getOwnPropertySymbols(r);var i={};e.concat(t).forEach(function(e){var t=n(r[e]);i[e]=t});return i}function unbox(t){var e=[LString,LNumber].some(function(e){return t instanceof e});if(e){return t.valueOf()}if(t instanceof Array){return t.map(unbox)}if(t instanceof QuotedPromise){delete t.then}if(is_plain_object(t)){return map_object(t,unbox)}return t}function patch_value(e,t){if(e instanceof Pair){e.markCycles();return quote(e)}if(is_function(e)){if(t){return bind(e,t)}}return box(e)}function unbind(e){if(is_bound(e)){return e[__fn__]}return e}function bind(e,t){if(e[Symbol["for"]("__bound__")]){return e}var r=e.bind(t);var n=Object.getOwnPropertyNames(e);var i=_createForOfIteratorHelper(n),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;if(filter_fn_names(o)){try{r[o]=e[o]}catch(e){}}}}catch(e){i.e(e)}finally{i.f()}hidden_prop(r,"__fn__",e);hidden_prop(r,"__context__",t);hidden_prop(r,"__bound__",true);if(is_native_function(e)){hidden_prop(r,"__native__",true)}if(is_plain_object(t)&&is_lambda(e)){hidden_prop(r,"__method__",true)}r.valueOf=function(){return e};return r}function is_object_bound(e){return is_bound(e)&&e[Symbol["for"]("__context__")]===Object}function is_bound(e){return!!(is_function(e)&&e[__fn__])}function lips_context(e){if(is_function(e)){var t=e[__context__];if(t&&(t===lips||t.constructor&&t.constructor.__class__)){return true}}return false}function is_port(e){return e instanceof InputPort||e instanceof OutputPort}function is_port_method(e){if(is_function(e)){if(is_port(e[__context__])){return true}}return false}var __context__=Symbol["for"]("__context__");var __fn__=Symbol["for"]("__fn__");var __data__=Symbol["for"]("__data__");var __ref__=Symbol["for"]("__ref__");var __cycles__=Symbol["for"]("__cycles__");var __class__=Symbol["for"]("__class__");var __method__=Symbol["for"]("__method__");var __prototype__=Symbol["for"]("__prototype__");var __lambda__=Symbol["for"]("__lambda__");var exluded_names=["name","length","caller","callee","arguments","prototype"];function filter_fn_names(e){return!exluded_names.includes(e)}function hidden_prop(e,t,r){Object.defineProperty(e,Symbol["for"](t),{get:function e(){return r},set:function e(){},configurable:false,enumerable:false})}function set_fn_length(t,r){try{Object.defineProperty(t,"length",{get:function e(){return r}});return t}catch(e){var n=new Array(r).fill(0).map(function(e,t){return"a"+t}).join(",");var i=new Function("f","return function(".concat(n,") {\n return f.apply(this, arguments);\n };"));return i(t)}}function is_lambda(e){return e&&e[__lambda__]}function is_method(e){return e&&e[__method__]}function is_raw_lambda(e){return is_lambda(e)&&!e[__prototype__]&&!is_method(e)&&!is_port_method(e)}function is_native_function(e){var t=Symbol["for"]("__native__");return is_function(e)&&e.toString().match(/\{\s*\[native code\]\s*\}/)&&(e.name.match(/^bound /)&&e[t]===true||!e.name.match(/^bound /)&&!e[t])}function let_macro(e){var b;switch(e){case Symbol["for"]("letrec"):b="letrec";break;case Symbol["for"]("let"):b="let";break;case Symbol["for"]("let*"):b="let*";break;default:throw new Error("Invalid let_macro value")}return Macro.defmacro(b,function(t,e){var l=e.dynamic_env;var f=e.error,r=e.macro_expand,_=e.use_dynamic;var p;if(t.car instanceof LSymbol){if(!(t.cdr.car instanceof Pair||t.cdr.car===_nil)){throw new Error("let require list of pairs")}var n;if(t.cdr.car===_nil){p=_nil;n=_nil}else{n=t.cdr.car.map(function(e){return e.car});p=t.cdr.car.map(function(e){return e.cdr.car})}return Pair.fromArray([LSymbol("letrec"),[[t.car,Pair(LSymbol("lambda"),Pair(n,t.cdr.cdr))]],Pair(t.car,p)])}else if(r){return}var h=this;p=global_env.get("list->array")(t.car);var d=h.inherit(b);var m,y;if(b==="let*"){y=d}else if(b==="let"){m=[]}var v=0;function g(){var e=new Pair(new LSymbol("begin"),t.cdr);return _evaluate(e,{env:d,dynamic_env:d,use_dynamic:_,error:f})}return function t(){var r=p[v++];l=b==="let*"?d:h;if(!r){if(m&&m.length){var e=m.map(function(e){return e.value});var n=e.filter(is_promise);if(n.length){return promise_all(e).then(function(e){for(var t=0,r=e.length;t1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=this;var a=this;var o=[];var u=e;while(u instanceof Pair){o.push(_evaluate(u.car,{env:i,dynamic_env:a,use_dynamic:r,error:n}));u=u.cdr}var s=o.filter(is_promise).length;if(s){return promise_all(o).then(c.bind(this))}else{return c.call(this,o)}})}function guard_math_call(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2?n-2:0),a=2;a1&&arguments[1]!==undefined?arguments[1]:null;return function(){for(var e=arguments.length,t=new Array(e),r=0;r1?e-1:0),r=1;r=o){return a.apply(this,n)}else{return i}}return i.apply(this,arguments)}}function limit(n,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,t=new Array(e),r=0;r1){e=e.toLowerCase();if(LCharacter.__names__[e]){t=e;e=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{t=LCharacter.__rev_names__[e]}Object.defineProperty(this,"__char__",{value:e,enumerable:true});if(t){Object.defineProperty(this,"__name__",{value:t,enumerable:true})}}LCharacter.__names__=characters;LCharacter.__rev_names__={};Object.keys(LCharacter.__names__).forEach(function(e){var t=LCharacter.__names__[e];LCharacter.__rev_names__[t]=e});LCharacter.prototype.toUpperCase=function(){return LCharacter(this.__char__.toUpperCase())};LCharacter.prototype.toLowerCase=function(){return LCharacter(this.__char__.toLowerCase())};LCharacter.prototype.toString=function(){return"#\\"+(this.__name__||this.__char__)};LCharacter.prototype.valueOf=LCharacter.prototype.serialize=function(){return this.__char__};function LString(e){if(typeof this!=="undefined"&&!(this instanceof LString)||typeof this==="undefined"){return new LString(e)}if(e instanceof Array){this.__string__=e.map(function(e,t){typecheck("LString",e,"character",t+1);return e.toString()}).join("")}else{this.__string__=e.valueOf()}}{var ignore=["length","constructor"];var _keys=Object.getOwnPropertyNames(String.prototype).filter(function(e){return!ignore.includes(e)});var wrap=function e(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r0){r.push(this.__string__.substring(0,e))}r.push(t);if(e1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof LNumber){return e}if(typeof this!=="undefined"&&!(this instanceof LNumber)||typeof this==="undefined"){return new LNumber(e,t)}if(typeof e==="undefined"){throw new Error("Invalid LNumber constructor call")}var r=LNumber.getType(e);if(LNumber.types[r]){return LNumber.types[r](e,t)}var n=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!n){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(n){var a=e,o=_slicedToArray(a,2),u=o[0],s=o[1];if(u instanceof LString){u=u.valueOf()}if(s instanceof LNumber){s=s.valueOf()}var c=u.match(/^([+-])/);var l=false;if(c){u=u.replace(/^[+-]/,"");if(c[1]==="-"){l=true}}}if(Number.isNaN(e)){return LFloat(e)}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(n){var f;switch(s){case 8:f="0o";break;case 16:f="0x";break;case 2:f="0b";break;case 10:f="";break}if(typeof f==="undefined"){var _=BigInt(s);i=_toConsumableArray(u).map(function(e,t){return BigInt(parseInt(e,s))*pow(_,BigInt(t))}).reduce(function(e,t){return e+t})}else{i=BigInt(f+u)}}else{i=BigInt(e)}if(l){i*=BigInt(-1)}}else{i=e}return LBigInteger(i,true)}else if(typeof BN!=="undefined"&&!(e instanceof BN)){if(e instanceof Array){return LBigInteger(_construct(BN,_toConsumableArray(e)))}return LBigInteger(new BN(e))}else if(n){this.constant(parseInt(u,s),"integer")}else{this.constant(e,"integer")}}LNumber.prototype.constant=function(e,t){Object.defineProperty(this,"__value__",{value:e,enumerable:true});Object.defineProperty(this,"__type__",{value:t,enumerable:true})};LNumber.types={float:function e(t){return new LFloat(t)},complex:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!LNumber.isComplex(t)){t={im:0,re:t}}return new LComplex(t,r)},rational:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!LNumber.isRational(t)){t={num:t,denom:1}}return new LRational(t,r)}};LNumber.prototype.serialize=function(){return this.__value__};LNumber.prototype.isNaN=function(){return Number.isNaN(this.__value__)};LNumber.prototype.gcd=function(e){var t=this.abs();e=e.abs();if(e.cmp(t)===1){var r=t;t=e;e=r}while(true){t=t.rem(e);if(t.cmp(0)===0){return e}e=e.rem(t);if(e.cmp(0)===0){return t}}};LNumber.isFloat=function e(t){return t instanceof LFloat||Number(t)===t&&t%1!==0};LNumber.isNumber=function(e){return e instanceof LNumber||LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){if(!e){return false}var t=e instanceof LComplex||(LNumber.isNumber(e.im)||Number.isNaN(e.im))&&(LNumber.isNumber(e.re)||Number.isNaN(e.re));return t};LNumber.isRational=function(e){if(!e){return false}return e instanceof LRational||LNumber.isNumber(e.num)&&LNumber.isNumber(e.denom)};LNumber.isInteger=function(e){if(!(LNumber.isNative(e)||e instanceof LNumber)){return false}if(LNumber.isFloat(e)){return false}if(LNumber.isRational(e)){return false}if(LNumber.isComplex(e)){return false}return true};LNumber.isNative=function(e){return typeof e==="bigint"||typeof e==="number"};LNumber.isBigInteger=function(e){return e instanceof LBigInteger||typeof e==="bigint"||LNumber.isBN(e)};LNumber.isBN=function(e){return typeof BN!=="undefined"&&e instanceof BN};LNumber.getArgsType=function(e,t){if(e instanceof LFloat||t instanceof LFloat){return LFloat}if(e instanceof LBigInteger||t instanceof LBigInteger){return LBigInteger}return LNumber};LNumber.prototype.toString=function(e){if(Number.isNaN(this.__value__)){return"+nan.0"}if(e>=2&&e<36){return this.__value__.toString(e)}return this.__value__.toString()};LNumber.prototype.asType=function(e){var t=LNumber.getType(this);return LNumber.types[t]?LNumber.types[t](e):LNumber(e)};LNumber.prototype.isBigNumber=function(){return typeof this.__value__==="bigint"||typeof BN!=="undefined"&&!(this.value instanceof BN)};["floor","ceil","round"].forEach(function(e){LNumber.prototype[e]=function(){if(this["float"]||LNumber.isFloat(this.__value__)){return LNumber(Math[e](this.__value__))}else{return LNumber(Math[e](this.valueOf()))}}});LNumber.prototype.valueOf=function(){if(LNumber.isNative(this.__value__)){return Number(this.__value__)}else if(LNumber.isBN(this.__value__)){return this.__value__.toNumber()}};var matrix=function(){var e=function e(t,r){return[t,r]};return{bigint:{bigint:e,float:function e(t,r){return[LFloat(t.valueOf()),r]},rational:function e(t,r){return[{num:t,denom:1},r]},complex:function e(t,r){return[{im:0,re:t},r]}},integer:{integer:e,float:function e(t,r){return[LFloat(t.valueOf()),r]},rational:function e(t,r){return[{num:t,denom:1},r]},complex:function e(t,r){return[{im:0,re:t},r]}},float:{bigint:function e(t,r){return[t,r&&LFloat(r.valueOf())]},integer:function e(t,r){return[t,r&&LFloat(r.valueOf())]},float:e,rational:function e(t,r){return[t,r&&LFloat(r.valueOf())]},complex:function e(t,r){return[{re:t,im:LFloat(0)},r]}},complex:{bigint:t("bigint"),integer:t("integer"),float:t("float"),rational:t("rational"),complex:function e(t,r){var n=LNumber.coerce(t.__re__,r.__re__),i=_slicedToArray(n,2),a=i[0],o=i[1];var u=LNumber.coerce(t.__im__,r.__im__),s=_slicedToArray(u,2),c=s[0],l=s[1];return[{im:c,re:a},{im:l,re:o}]}},rational:{bigint:function e(t,r){return[t,r&&{num:r,denom:1}]},integer:function e(t,r){return[t,r&&{num:r,denom:1}]},float:function e(t,r){return[LFloat(t.valueOf()),r]},rational:e,complex:function e(t,r){return[{im:coerce(t.__type__,r.__im__.__type__,0)[0],re:coerce(t.__type__,r.__re__.__type__,t)[0]},{im:coerce(t.__type__,r.__im__.__type__,r.__im__)[0],re:coerce(t.__type__,r.__re__.__type__,r.__re__)[0]}]}}};function t(r){return function(e,t){return[{im:coerce(r,e.__im__.__type__,0,e.__im__)[1],re:coerce(r,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(r,e.__im__.__type__,0,0)[1],re:coerce(r,t.__type__,0,t)[1]}]}}}();function coerce(e,t,r,n){return matrix[e][t](r,n)}LNumber.coerce=function(e,t){var r=LNumber.getType(e);var n=LNumber.getType(t);if(!matrix[r]){throw new Error("LNumber::coerce unknown lhs type ".concat(r))}else if(!matrix[r][n]){throw new Error("LNumber::coerce unknown rhs type ".concat(n))}var i=matrix[r][n](e,t);return i.map(function(e){return LNumber(e,true)})};LNumber.prototype.coerce=function(e){if(!(typeof e==="number"||e instanceof LNumber)){throw new Error("LNumber: you can't coerce ".concat(type(e)))}if(typeof e==="number"){e=LNumber(e)}return LNumber.coerce(this,e)};LNumber.getType=function(e){if(e instanceof LNumber){return e.__type__}if(LNumber.isFloat(e)){return"float"}if(LNumber.isComplex(e)){return"complex"}if(LNumber.isRational(e)){return"rational"}if(typeof e==="number"){return"integer"}if(typeof BigInt!=="undefined"&&typeof e!=="bigint"||typeof BN!=="undefined"&&!(e instanceof BN)){return"bigint"}};LNumber.prototype.isFloat=function(){return!!(LNumber.isFloat(this.__value__)||this["float"])};var mapping={add:"+",sub:"-",mul:"*",div:"/",rem:"%",or:"|",and:"&",neg:"~",shl:">>",shr:"<<"};var rev_mapping={};Object.keys(mapping).forEach(function(t){rev_mapping[mapping[t]]=t;LNumber.prototype[t]=function(e){return this.op(mapping[t],e)}});LNumber._ops={"*":function e(t,r){return t*r},"+":function e(t,r){return t+r},"-":function e(t,r){if(typeof r==="undefined"){return-t}return t-r},"/":function e(t,r){return t/r},"%":function e(t,r){return t%r},"|":function e(t,r){return t|r},"&":function e(t,r){return t&r},"~":function e(t){return~t},">>":function e(t,r){return t>>r},"<<":function e(t,r){return t<1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof LComplex)||typeof this==="undefined"){return new LComplex(e,t)}if(e instanceof LComplex){return LComplex({im:e.__im__,re:e.__re__})}if(LNumber.isNumber(e)&&t){if(!t){return Number(e)}}else if(!LNumber.isComplex(e)){var r="Invalid constructor call for LComplex expect &(:im :re ) object but got ".concat(toString(e));throw new Error(r)}var n=e.im instanceof LNumber?e.im:LNumber(e.im);var i=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,i)}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.constant=function(e,t){Object.defineProperty(this,"__im__",{value:e,enumerable:true});Object.defineProperty(this,"__re__",{value:t,enumerable:true});Object.defineProperty(this,"__type__",{value:"complex",enumerable:true})};LComplex.prototype.serialize=function(){return{re:this.__re__,im:this.__im__}};LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var t=LFloat(this.__im__).toRational(e);var r=LFloat(this.__re__).toRational(e);return LComplex({im:t,re:r})}return this};LComplex.prototype.pow=function(e){throw new Error("Not yet implemented")};LComplex.prototype.add=function(e){return this.complex_op("add",e,function(e,t,r,n){return{re:e.add(t),im:r.add(n)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,t=this.__im__;var r,n;if(e instanceof LFloat){r=e.toRational().mul(e.toRational())}else{r=e.mul(e)}if(t instanceof LFloat){n=t.toRational().mul(t.toRational())}else{n=t.mul(t)}return r.add(n)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.conjugate=function(){return LComplex({re:this.__re__,im:this.__im__.sub()})};LComplex.prototype.sqrt=function(){var e=this.modulus();var t,r;if(e.cmp(0)===0){t=r=e}else if(this.__re__.cmp(0)===1){t=LFloat(.5).mul(e.add(this.__re__)).sqrt();r=this.__im__.div(t).div(2)}else{r=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){r=r.sub()}t=this.__im__.div(r).div(2)}return LComplex({im:r,re:t})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var t=this.__re__.div(e);var r=this.__im__.div(e);return LComplex({re:t,im:r})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}if(this.cmp(e)===0){var n=this.coerce(e),i=_slicedToArray(n,2),a=i[0],o=i[1];var u=a.__im__.div(o.__im__);return u.coerce(o.__re__)[0]}var s=this.coerce(e),c=_slicedToArray(s,2),l=c[0],f=c[1];var _=f.factor();var p=f.conjugate();var h=l.mul(p);if(!LNumber.isComplex(h)){return h.div(_)}var d=h.__re__.op("/",_);var m=h.__im__.op("/",_);return LComplex({re:d,im:m})};LComplex.prototype.sub=function(e){return this.complex_op("sub",e,function(e,t,r,n){return{re:e.sub(t),im:r.sub(n)}})};LComplex.prototype.mul=function(e){return this.complex_op("mul",e,function(e,t,r,n){var i={re:e.mul(t).sub(r.mul(n)),im:e.mul(n).add(t.mul(r))};return i})};LComplex.prototype.complex_op=function(e,t,i){var a=this;var r=function e(t,r){var n=i(a.__re__,t,a.__im__,r);if("im"in n&&"re"in n){if(n.im.cmp(0)===0){return n.re}return LComplex(n,true)}return n};if(typeof t==="undefined"){return r()}if(LNumber.isNumber(t)&&!LNumber.isComplex(t)){if(!(t instanceof LNumber)){t=LNumber(t)}var n=t.asType(0);t={__im__:n,__re__:t}}else if(!LNumber.isComplex(t)){throw new Error("[LComplex::".concat(e,"] Invalid value"))}var o=t.__re__ instanceof LNumber?t.__re__:this.__re__.asType(t.__re__);var u=t.__im__ instanceof LNumber?t.__im__:this.__im__.asType(t.__im__);return r(o,u)};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,t){var r=LComplex._op[e];return this[r](t)};LComplex.prototype.cmp=function(e){var t=this.coerce(e),r=_slicedToArray(t,2),n=r[0],i=r[1];var a=n.__re__.coerce(i.__re__),o=_slicedToArray(a,2),u=o[0],s=o[1];var c=u.cmp(s);if(c!==0){return c}else{var l=n.__im__.coerce(i.__im__),f=_slicedToArray(l,2),_=f[0],p=f[1];return _.cmp(p)}};LComplex.prototype.valueOf=function(){return[this.__re__,this.__im__].map(function(e){return e.valueOf()})};LComplex.prototype.toString=function(){var e;if(this.__re__.cmp(0)!==0){e=[toString(this.__re__)]}else{e=[]}var t=this.__im__.valueOf();var r=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(t);var n=toString(this.__im__);if(!r&&!Number.isNaN(t)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}n=n.replace(/^-/,"")}e.push(n);e.push("i");return e.join("")};function LFloat(e){if(typeof this!=="undefined"&&!(this instanceof LFloat)||typeof this==="undefined"){return new LFloat(e)}if(!LNumber.isNumber(e)){throw new Error("Invalid constructor call for LFloat")}if(e instanceof LNumber){return LFloat(e.valueOf())}if(typeof e==="number"){if(Object.is(e,-0)){Object.defineProperty(this,"_minus",{value:true})}this.constant(e,"float")}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){if(this.__value__===Number.NEGATIVE_INFINITY){return"-inf.0"}if(this.__value__===Number.POSITIVE_INFINITY){return"+inf.0"}if(Number.isNaN(this.__value__)){return"+nan.0"}var e=this.__value__.toString();if(!LNumber.isFloat(this.__value__)&&!e.match(/e/i)){var t=e+".0";return this._minus?"-"+t:t}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,t){if(t instanceof LNumber){t=t.__value__}var r=LNumber._ops[e];if(e==="/"&&this.__value__===0&&t===0){return NaN}return LFloat(r(this.__value__,t))};LFloat.prototype.toRational=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){return toRational(this.__value__.valueOf())}return approxRatio(e.valueOf())(this.__value__.valueOf())};LFloat.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){var t=LFloat(Math.sqrt(-e));return LComplex({re:0,im:t})}return LFloat(Math.sqrt(e))};LFloat.prototype.abs=function(){var e=this.valueOf();if(e<0){e=-e}return LFloat(e)};var toRational=approxRatio(1e-10);function approxRatio(n){return function(e){var t=function e(n,t,r){var i=function e(t,r){return r0){i=simplest_rational2(n,r)}else if(n.cmp(r)<=0){i=r}else if(r.cmp(0)>0){i=simplest_rational2(r,n)}else if(t.cmp(0)<0){i=LNumber(simplest_rational2(n.sub(),r.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(t)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,t){var r=LNumber(e).floor();var n=LNumber(t).floor();if(e.cmp(r)<1){return r}else if(r.cmp(n)===0){var i=LNumber(1).div(t.sub(n));var a=LNumber(1).div(e.sub(r));return r.add(LNumber(1).div(simplest_rational2(i,a)))}else{return r.add(LNumber(1))}}function LRational(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof LRational)||typeof this==="undefined"){return new LRational(e,t)}if(!LNumber.isRational(e)){throw new Error("Invalid constructor call for LRational")}var r,n;if(e instanceof LRational){r=LNumber(e.__num__);n=LNumber(e.__denom__)}else{r=LNumber(e.num);n=LNumber(e.denom)}if(!t&&n.cmp(0)!==0){var i=r.op("%",n).cmp(0)===0;if(i){return LNumber(r.div(n))}}this.constant(r,n)}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.constant=function(e,t){Object.defineProperty(this,"__num__",{value:e,enumerable:true});Object.defineProperty(this,"__denom__",{value:t,enumerable:true});Object.defineProperty(this,"__type__",{value:"rational",enumerable:true})};LRational.prototype.serialize=function(){return{num:this.__num__,denom:this.__denom__}};LRational.prototype.pow=function(e){var t=e.cmp(0);if(t===0){return LNumber(1)}if(t===-1){e=e.sub();var r=this.__denom__.pow(e);var n=this.__num__.pow(e);return LRational({num:r,denom:n})}var i=this;e=e.valueOf();while(e>1){i=i.mul(this);e--}return i};LRational.prototype.sqrt=function(){var e=this.__num__.sqrt();var t=this.__denom__.sqrt();if(e instanceof LFloat||t instanceof LFloat){return e.div(t)}return LRational({num:e,denom:t})};LRational.prototype.abs=function(){var e=this.__num__;var t=this.__denom__;if(e.cmp(0)===-1){e=e.sub()}if(t.cmp(0)!==1){t=t.sub()}return LRational({num:e,denom:t})};LRational.prototype.cmp=function(e){return LNumber(this.valueOf(),true).cmp(e)};LRational.prototype.toString=function(){var e=this.__num__.gcd(this.__denom__);var t,r;if(e.cmp(1)!==0){t=this.__num__.div(e);if(t instanceof LRational){t=LNumber(t.valueOf(true))}r=this.__denom__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}}else{t=this.__num__;r=this.__denom__}var n=this.cmp(0)<0;if(n){if(t.abs().cmp(r.abs())===0){return t.toString()}}else if(t.cmp(r)===0){return t.toString()}return t.toString()+"/"+r.toString()};LRational.prototype.valueOf=function(e){if(this.__denom__.cmp(0)===0){if(this.__num__.cmp(0)<0){return Number.NEGATIVE_INFINITY}return Number.POSITIVE_INFINITY}if(e){return LNumber._ops["/"](this.__num__.value,this.__denom__.value)}return LFloat(this.__num__.valueOf()).div(this.__denom__.valueOf())};LRational.prototype.mul=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=this.__num__.mul(e.__num__);var r=this.__denom__.mul(e.__denom__);return LRational({num:t,denom:r})}var n=LNumber.coerce(this,e),i=_slicedToArray(n,2),a=i[0],o=i[1];return a.mul(o)};LRational.prototype.div=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=this.__num__.mul(e.__denom__);var r=this.__denom__.mul(e.__num__);return LRational({num:t,denom:r})}var n=LNumber.coerce(this,e),i=_slicedToArray(n,2),a=i[0],o=i[1];var u=a.div(o);return u};LRational.prototype._op=function(e,t){return this[rev_mapping[e]](t)};LRational.prototype.sub=function(e){if(typeof e==="undefined"){return this.mul(-1)}if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=e.__num__.sub();var r=e.__denom__;return this.add(LRational({num:t,denom:r}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var n=LNumber.coerce(this,e),i=_slicedToArray(n,2),a=i[0],o=i[1];return a.add(o)};LRational.prototype.add=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=this.__denom__;var r=e.__denom__;var n=this.__num__;var i=e.__num__;var a,o;if(t!==r){o=r.mul(n).add(i.mul(t));a=t.mul(r)}else{o=n.add(i);a=t}return LRational({num:o,denom:a})}if(LNumber.isFloat(e)){return LFloat(this.valueOf()).add(e)}var u=LNumber.coerce(this,e),s=_slicedToArray(u,2),c=s[0],l=s[1];return c.add(l)};function LBigInteger(e,t){if(typeof this!=="undefined"&&!(this instanceof LBigInteger)||typeof this==="undefined"){return new LBigInteger(e,t)}if(e instanceof LBigInteger){return LBigInteger(e.__value__,e._native)}if(!LNumber.isBigInteger(e)){throw new Error("Invalid constructor call for LBigInteger")}this.constant(e,"bigint");Object.defineProperty(this,"_native",{value:t})}LBigInteger.prototype=Object.create(LNumber.prototype);LBigInteger.prototype.constructor=LBigInteger;LBigInteger.bn_op={"+":"iadd","-":"isub","*":"imul","/":"idiv","%":"imod","|":"ior","&":"iand","~":"inot","<<":"ishrn",">>":"ishln"};LBigInteger.prototype.serialize=function(){return this.__value__.toString()};LBigInteger.prototype._op=function(e,t){if(typeof t==="undefined"){if(LNumber.isBN(this.__value__)){e=LBigInteger.bn_op[e];return LBigInteger(this.__value__.clone()[e](),false)}return LBigInteger(LNumber._ops[e](this.__value__),true)}if(LNumber.isBN(this.__value__)&&LNumber.isBN(t.__value__)){e=LBigInteger.bn_op[e];return LBigInteger(this.__value__.clone()[e](t),false)}var r=LNumber._ops[e](this.__value__,t.__value__);if(e==="/"){var n=this.op("%",t).cmp(0)===0;if(n){return LNumber(r)}return LRational({num:this,denom:t})}return LBigInteger(r,true)};LBigInteger.prototype.sqrt=function(){var e;var t=this.cmp(0)<0;if(LNumber.isNative(this.__value__)){e=LNumber(Math.sqrt(t?-this.valueOf():this.valueOf()))}else if(LNumber.isBN(this.__value__)){e=t?this.__value__.neg().sqrt():this.__value__.sqrt()}if(t){return LComplex({re:0,im:e})}return e};LNumber.NaN=LNumber(NaN);function InputPort(e){var n=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");read_only(this,"__type__",text_port);var i;Object.defineProperty(this,"__parser__",{enumerable:true,get:function e(){return i},set:function e(t){typecheck("InputPort::__parser__",t,"parser");i=t}});this._read=e;this._with_parser=this._with_init_parser.bind(this,_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(n.char_ready()){t.next=5;break}t.next=3;return n._read();case 3:r=t.sent;i=new Parser(r,{env:n});case 5:return t.abrupt("return",n.__parser__);case 6:case"end":return t.stop()}},e)})));this.char_ready=function(){return!!this.__parser__&&this.__parser__.__lexer__.peek()!==eof};this._make_defaults()}InputPort.prototype._make_defaults=function(){this.read=this._with_parser(function(e){return e.read_object()});this.read_line=this._with_parser(function(e){return e.__lexer__.read_line()});this.read_char=this._with_parser(function(e){return e.__lexer__.read_char()});this.read_string=this._with_parser(function(e,t){if(!LNumber.isInteger(t)){var r=LNumber.getType(t);typeErrorMessage("read-string",r,"integer")}return e.__lexer__.read_string(t.valueOf())});this.peek_char=this._with_parser(function(e){return e.__lexer__.peek_char()})};InputPort.prototype._with_init_parser=function(u,s){var c=this;return _asyncToGenerator(_regeneratorRuntime.mark(function e(){var r,n,i,a,o=arguments;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return u.call(c);case 2:r=t.sent;for(n=o.length,i=new Array(n),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");read_only(this,"__type__",text_port);this.write=e}OutputPort.prototype.is_open=function(){return this._closed!==true};OutputPort.prototype.close=function(){Object.defineProperty(this,"_closed",{get:function e(){return true},set:function e(){},configurable:false,enumerable:false});this.write=function(){throw new Error("output-port: port is closed")}};OutputPort.prototype.flush=function(){};OutputPort.prototype.toString=function(){return"#"};var BufferedOutputPort=function(e){_inherits(r,e);function r(e){var t;_classCallCheck(this,r);t=_callSuper(this,r,[function(){var e;return(e=t)._write.apply(e,arguments)}]);typecheck("BufferedOutputPort",e,"function");read_only(_assertThisInitialized(t),"_fn",e,{hidden:true});read_only(_assertThisInitialized(t),"_buffer",[],{hidden:true});return t}_createClass(r,[{key:"flush",value:function e(){if(this._buffer.length){this._fn(this._buffer.join(""));this._buffer.length=0}}},{key:"_write",value:function e(){var t=this;for(var r=arguments.length,n=new Array(r),i=0;i"};OutputStringPort.prototype.valueOf=function(){return this.__buffer__.map(function(e){return e.valueOf()}).join("")};function OutputFilePort(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,t)}typecheck("OutputFilePort",e,"string");read_only(this,"__filename__",e);read_only(this,"_fd",t.valueOf(),{hidden:true});read_only(this,"__type__",text_port);this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}r.fs().write(r._fd,e,function(e){if(e){throw e}})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(){if(!this._fs){this._fs=this.internal("fs")}return this._fs};OutputFilePort.prototype.internal=function(e){return user_env.get("**internal-env**").get(e)};OutputFilePort.prototype.close=function(){var n=this;return new Promise(function(t,r){n.fs().close(n._fd,function(e){if(e){r(e)}else{read_only(n,"_fd",null,{hidden:true});OutputPort.prototype.close.call(n);t()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof InputStringPort)||typeof this==="undefined"){return new InputStringPort(e)}typecheck("InputStringPort",e,"string");t=t||global_env;e=e.valueOf();this._with_parser=this._with_init_parser.bind(this,function(){if(!r.__parser__){r.__parser__=new Parser(e,{env:t})}return r.__parser__});read_only(this,"__type__",text_port);this._make_defaults()}InputStringPort.prototype.char_ready=function(){return true};InputStringPort.prototype=Object.create(InputPort.prototype);InputStringPort.prototype.constructor=InputStringPort;InputStringPort.prototype.toString=function(){return"#"};function InputByteVectorPort(e){if(typeof this!=="undefined"&&!(this instanceof InputByteVectorPort)||typeof this==="undefined"){return new InputByteVectorPort(e)}typecheck("InputByteVectorPort",e,"uint8array");read_only(this,"__vector__",e);read_only(this,"__type__",binary_port);var r=0;Object.defineProperty(this,"__index__",{enumerable:true,get:function e(){return r},set:function e(t){typecheck("InputByteVectorPort::__index__",t,"number");if(t instanceof LNumber){t=t.valueOf()}if(typeof t==="bigint"){t=Number(t)}if(Math.floor(t)!==t){throw new Error("InputByteVectorPort::__index__ value is "+"not integer")}r=t}})}InputByteVectorPort.prototype=Object.create(InputPort.prototype);InputByteVectorPort.prototype.constructor=InputByteVectorPort;InputByteVectorPort.prototype.toString=function(){return"#"};InputByteVectorPort.prototype.close=function(){var t=this;read_only(this,"__vector__",_nil);var r=function e(){throw new Error("Input-binary-port: port is closed")};["read_u8","close","peek_u8","read_u8_vector"].forEach(function(e){t[e]=r});this.u8_ready=this.char_ready=function(){return false}};InputByteVectorPort.prototype.u8_ready=function(){return true};InputByteVectorPort.prototype.peek_u8=function(){if(this.__index__>=this.__vector__.length){return eof}return this.__vector__[this.__index__]};InputByteVectorPort.prototype.skip=function(){if(this.__index__<=this.__vector__.length){++this.__index__}};InputByteVectorPort.prototype.read_u8=function(){var e=this.peek_u8();this.skip();return e};InputByteVectorPort.prototype.read_u8_vector=function(e){if(typeof e==="undefined"){e=this.__vector__.length}else if(e>this.__index__+this.__vector__.length){e=this.__index__+this.__vector__.length}if(this.peek_u8()===eof){return eof}return this.__vector__.slice(this.__index__,e)};function OutputByteVectorPort(){if(typeof this!=="undefined"&&!(this instanceof OutputByteVectorPort)||typeof this==="undefined"){return new OutputByteVectorPort}read_only(this,"__type__",binary_port);read_only(this,"_buffer",[],{hidden:true});this.write=function(e){typecheck("write",e,["number","uint8array"]);if(LNumber.isNumber(e)){this._buffer.push(e.valueOf())}else{var t;(t=this._buffer).push.apply(t,_toConsumableArray(Array.from(e)))}};Object.defineProperty(this,"__buffer__",{enumerable:true,get:function e(){return Uint8Array.from(this._buffer)}})}OutputByteVectorPort.prototype=Object.create(OutputPort.prototype);OutputByteVectorPort.prototype.constructor=OutputByteVectorPort;OutputByteVectorPort.prototype.close=function(){OutputPort.prototype.close.call(this);read_only(this,"_buffer",null,{hidden:true})};OutputByteVectorPort.prototype._close_guard=function(){if(this._closed){throw new Error("output-port: binary port is closed")}};OutputByteVectorPort.prototype.write_u8=function(e){typecheck("OutputByteVectorPort::write_u8",e,"number");this.write(e)};OutputByteVectorPort.prototype.write_u8_vector=function(e){typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};OutputByteVectorPort.prototype.toString=function(){return"#"};OutputByteVectorPort.prototype.valueOf=function(){return this.__buffer__};function InputFilePort(e,t){if(typeof this!=="undefined"&&!(this instanceof InputFilePort)||typeof this==="undefined"){return new InputFilePort(e,t)}InputStringPort.call(this,e);typecheck("InputFilePort",t,"string");read_only(this,"__filename__",t)}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};function InputBinaryFilePort(e,t){if(typeof this!=="undefined"&&!(this instanceof InputBinaryFilePort)||typeof this==="undefined"){return new InputBinaryFilePort(e,t)}InputByteVectorPort.call(this,e);typecheck("InputBinaryFilePort",t,"string");read_only(this,"__filename__",t)}InputBinaryFilePort.prototype=Object.create(InputByteVectorPort.prototype);InputBinaryFilePort.prototype.constructor=InputBinaryFilePort;InputBinaryFilePort.prototype.toString=function(){return"#")};function OutputBinaryFilePort(e,t){var i=this;if(typeof this!=="undefined"&&!(this instanceof OutputBinaryFilePort)||typeof this==="undefined"){return new OutputBinaryFilePort(e,t)}typecheck("OutputBinaryFilePort",e,"string");read_only(this,"__filename__",e);read_only(this,"_fd",t.valueOf(),{hidden:true});read_only(this,"__type__",binary_port);var a;this.write=function(e){typecheck("write",e,["number","uint8array"]);var n;if(!a){a=i.internal("fs")}if(LNumber.isNumber(e)){n=new Uint8Array([e.valueOf()])}else{n=new Uint8Array(Array.from(e))}return new Promise(function(t,r){a.write(i._fd,n,function(e){if(e){r(e)}else{t()}})})}}OutputBinaryFilePort.prototype=Object.create(OutputFilePort.prototype);OutputBinaryFilePort.prototype.constructor=OutputBinaryFilePort;OutputBinaryFilePort.prototype.write_u8=function(e){typecheck("OutputByteVectorPort::write_u8",e,"number");this.write(e)};OutputBinaryFilePort.prototype.write_u8_vector=function(e){typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#"};function Interpreter(e){var t=this;var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},n=r.stderr,i=r.stdin,a=r.stdout,o=r.command_line,u=o===void 0?null:o,s=_objectWithoutProperties(r,_excluded3);if(typeof this!=="undefined"&&!(this instanceof Interpreter)||typeof this==="undefined"){return new Interpreter(e,_objectSpread({stdin:i,stdout:a,stderr:n,command_line:u},s))}if(typeof e==="undefined"){e="anonymous"}this.__env__=user_env.inherit(e,s);this.__env__.set("parent.frame",doc("parent.frame",function(){return t.__env__},global_env.__env__["parent.frame"].__doc__));var c="**interaction-environment-defaults**";this.set(c,get_props(s).concat(c));var l=internal_env.inherit("internal-".concat(e));if(is_port(i)){l.set("stdin",i)}if(is_port(n)){l.set("stderr",n)}if(is_port(a)){l.set("stdout",a)}l.set("command-line",u);set_interaction_env(this.__env__,l)}Interpreter.prototype.exec=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=t.use_dynamic,n=r===void 0?false:r,i=t.dynamic_env,a=t.env;typecheck("Interpreter::exec",e,["string","array"],1);typecheck("Interpreter::exec",n,"boolean",2);if(!a){a=this.__env__}if(!i){i=a}global_env.set("**interaction-environment**",this.__env__);return exec(e,{env:a,dynamic_env:i,use_dynamic:n})};Interpreter.prototype.get=function(e){var t=this.__env__.get(e);if(is_function(t)){var r=new LambdaContext({env:this.__env__});return t.bind(r)}return t};Interpreter.prototype.set=function(e,t){return this.__env__.set(e,t)};Interpreter.prototype.constant=function(e,t){return this.__env__.constant(e,t)};function LipsError(e,t){this.name="LipsError";this.message=e;this.args=t;this.stack=(new Error).stack}LipsError.prototype=new Error;LipsError.prototype.constructor=LipsError;var IgnoreException=function(e){_inherits(t,e);function t(){_classCallCheck(this,t);return _callSuper(this,t,arguments)}return _createClass(t)}(_wrapNativeSuper(Error));function Environment(e,t,r){if(arguments.length===1){if(_typeof$1(arguments[0])==="object"){e=arguments[0];t=null}else if(typeof arguments[0]==="string"){e={};t=null;r=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=t;this.__name__=r||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};Environment.prototype.fs=function(){return this.get("**fs**")};Environment.prototype.unset=function(e){if(e instanceof LSymbol){e=e.valueOf()}if(e instanceof LString){e=e.valueOf()}delete this.__env__[e]};Environment.prototype.inherit=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(_typeof$1(e)==="object"){t=e}if(!e||_typeof$1(e)==="object"){e="child of "+(this.__name__||"unknown")}return new Environment(t||{},this,e)};Environment.prototype.doc=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(t){if(!r){t=trim_lines(t)}this.__docs__.set(e,t);return this}if(this.__docs__.has(e)){return this.__docs__.get(e)}if(this.__parent__){return this.__parent__.doc(e)}};Environment.prototype.new_frame=function(e,t){var n=this.inherit("__frame__");n.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1;e=e.valueOf();var t=n.__parent__;if(!is_env(t)){return _nil}if(e<=0){return t}var r=t.get("parent.frame");return r(e-1)},global_env.__env__["parent.frame"].__doc__));t.callee=e;n.set("arguments",t);return n};Environment.prototype._lookup=function(e){if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(this.__env__.hasOwnProperty(e)){return Value(this.__env__[e])}if(this.__parent__){return this.__parent__._lookup(e)}};Environment.prototype.toString=function(){return"#"};Environment.prototype.clone=function(){var t=this;var r={};Object.keys(this.__env__).forEach(function(e){r[e]=t.__env__[e]});return new Environment(r,this.__parent__,this.__name__)};Environment.prototype.merge=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"merge";typecheck("Environment::merge",e,"environment");return this.inherit(t,e.__env__)};function Value(e){if(typeof this!=="undefined"&&!(this instanceof Value)||typeof this==="undefined"){return new Value(e)}this.value=e}Value.isUndefined=function(e){return e instanceof Value&&typeof e.value==="undefined"};Value.prototype.valueOf=function(){return this.value};function Values(e){if(e.length){if(e.length===1){return e[0]}}if(typeof this!=="undefined"&&!(this instanceof Values)||typeof this==="undefined"){return new Values(e)}this.__values__=e}Values.prototype.toString=function(){return this.__values__.map(function(e){return toString(e)}).join("\n")};Values.prototype.valueOf=function(){return this.__values__};Environment.prototype.get=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};typecheck("Environment::get",e,["symbol","string"]);var r=t.throwError,n=r===void 0?true:r;var i=e;if(i instanceof LSymbol||i instanceof LString){i=i.valueOf()}var a=this._lookup(i);if(a instanceof Value){if(Value.isUndefined(a)){return undefined}return patch_value(a.valueOf())}var o;if(e instanceof LSymbol&&e[LSymbol.object]){o=e[LSymbol.object]}else if(typeof i==="string"){o=i.split(".").filter(Boolean)}if(o&&o.length>0){var u=o,s=_toArray(u),c=s[0],l=s.slice(1);a=this._lookup(c);if(l.length){try{if(a instanceof Value){a=a.valueOf()}else{a=get(root,c);if(is_function(a)){a=unbind(a)}}if(typeof a!=="undefined"){return get.apply(void 0,[a].concat(_toConsumableArray(l)))}}catch(e){throw e}}else if(a instanceof Value){return patch_value(a.valueOf())}a=get(root,i)}if(typeof a!=="undefined"){return a}if(n){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;typecheck("Environment::set",e,["string","symbol"]);if(LNumber.isNumber(t)){t=LNumber(t)}if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}this.__env__[e]=t;if(r){this.doc(e,r,true)}return this};Environment.prototype.constant=function(t,e){var r=this;if(this.__env__.hasOwnProperty(t)){throw new Error("Environment::constant: ".concat(t," already exists"))}if(arguments.length===1&&is_plain_object(arguments[0])){var n=arguments[0];Object.keys(n).forEach(function(e){r.constant(t,n[e])})}else{Object.defineProperty(this.__env__,t,{value:e,enumerable:true})}return this};Environment.prototype.has=function(e){return this.__env__.hasOwnProperty(e)};Environment.prototype.ref=function(e){var t=this;while(true){if(!t){break}if(t.has(e)){return t}t=t.__parent__}};Environment.prototype.parents=function(){var e=this;var t=[];while(e){t.unshift(e);e=e.__parent__}return t};function quote(e){if(is_promise(e)){return e.then(quote)}if(e instanceof Pair||e instanceof LSymbol){e[__data__]=true}return e}var native_lambda=_parse(tokenize('(lambda ()\n "[native code]"\n (throw "Invalid Invocation"))'))[0];var get=doc("get",function e(t){var r;for(var n=arguments.length,i=new Array(n>1?n-1:0),a=1;a0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("peek-char",e,"input-port");return e.peek_char()},"(peek-char port)\n\n This function reads and returns a character from the string\n port, or, if there is no more data in the string port, it\n returns an EOF."),"read-line":doc("read-line",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("read-line",e,"input-port");return e.read_line()},"(read-line port)\n\n This function reads and returns the next line from the input\n port."),"read-char":doc("read-char",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("read-char",e,"input-port");return e.read_char()},"(read-char port)\n\n This function reads and returns the next character from the\n input port."),read:doc("read",function(){var e=_asyncToGenerator(function(){var l=this;var f=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;return _regeneratorRuntime.mark(function e(){var r,n,i,a,o,u,s,c;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=l.env;if(!LString.isString(f)){t.next=30;break}n=false;i=false;t.prev=4;o=_asyncIterator(_parse(f,r));case 6:t.next=8;return o.next();case 8:if(!(n=!(u=t.sent).done)){t.next=14;break}s=u.value;return t.abrupt("return",s);case 11:n=false;t.next=6;break;case 14:t.next=20;break;case 16:t.prev=16;t.t0=t["catch"](4);i=true;a=t.t0;case 20:t.prev=20;t.prev=21;if(!(n&&o["return"]!=null)){t.next=25;break}t.next=25;return o["return"]();case 25:t.prev=25;if(!i){t.next=28;break}throw a;case 28:return t.finish(25);case 29:return t.finish(20);case 30:if(f===null){c=internal(r,"stdin")}else{c=f}typecheck_text_port("read",c,"input-port");return t.abrupt("return",c.read.call(r));case 33:case"end":return t.stop()}},e,null,[[4,16,20,30],[21,,25,29]])})()});function t(){return e.apply(this,arguments)}return t}(),"(read [string])\n\n This function, if used with a string, will parse it and\n return the LIPS code, if there is any. If called with a\n port, it will parse the next item from the port. If called\n without an input, it will read a string from standard input\n (using the browser's prompt or a user defined input method)\n and calls itself with that string. This function can be used\n together with `eval` to evaluate code from a string."),pprint:doc("pprint",function e(t){if(t instanceof Pair){t=new lips.Formatter(t.toString(true))["break"]().format();global_env.get("display").call(global_env,t)}else{global_env.get("write").call(global_env,t)}global_env.get("newline").call(global_env)},"(pprint expression)\n\n This function will pretty print its input to stdout. If it is called\n with a non-list, it will just call the print function on its\n input."),print:doc("print",function e(){var t=global_env.get("display");var r=global_env.get("newline");var n=this.use_dynamic;var i=global_env;var a=global_env;for(var o=arguments.length,u=new Array(o),s=0;s1?r-1:0),i=1;in.length){throw new Error("Not enough arguments")}var u=0;var s=global_env.get("repr");t=t.replace(a,function(e){var t=e[1];if(t==="~"){return"~"}else if(t==="%"){return"\n"}else{var r=n[u++];if(t==="a"){return s(r)}else{return s(r,true)}}});o=t.match(/~([\S])/);if(o){throw new Error("format: Unrecognized escape sequence ".concat(o[1]))}return t},"(format string n1 n2 ...)\n\n This function accepts a string template and replaces any\n escape sequences in its inputs:\n\n * ~a value as if printed with `display`\n * ~s value as if printed with `write`\n * ~% newline character\n * ~~ literal tilde '~'\n\n If there are missing inputs or other escape characters it\n will error."),display:doc("display",function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(r===null){r=internal(this,"stdout")}else{typecheck("display",r,"output-port")}var n=t;if(!(r instanceof OutputBinaryFilePort)){n=global_env.get("repr")(t)}r.write.call(global_env,n)},"(display string [port])\n\n This function outputs the string to the standard output or\n the port if given. No newline."),"display-error":doc("display-error",function e(){var t=internal(this,"stderr");var r=global_env.get("repr");for(var n=arguments.length,i=new Array(n),a=0;a1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=_objectWithoutProperties(t,_excluded4);var i=this;var o=this;var u;var s=_objectSpread(_objectSpread({},n),{},{env:this,dynamic_env:i,use_dynamic:r});var c=_evaluate(e.cdr.car,s);c=resolve_promises(c);function l(t,r,n){if(is_promise(t)){return t.then(function(e){return l(t,e,n)})}if(is_promise(r)){return r.then(function(e){return l(t,e,n)})}if(is_promise(n)){return n.then(function(e){return l(t,r,e)})}o.get("set-obj!").call(o,t,r,n);return n}if(e.car instanceof Pair&&LSymbol.is(e.car.car,".")){var f=e.car.cdr.car;var _=e.car.cdr.cdr.car;var p=_evaluate(f,{env:this,dynamic_env:i,use_dynamic:r,error:error});var h=_evaluate(_,{env:this,dynamic_env:i,use_dynamic:r,error:error});return l(p,h,c)}if(!(e.car instanceof LSymbol)){throw new Error("set! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var d=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(c,function(e){if(!u){var t=d.split(".");if(t.length>1){var r=t.pop();var n=t.join(".");var i=a.get(n,{throwError:false});if(i){l(i,r,e);return}}throw new Error("Unbound variable `"+d+"'")}u.set(d,e)})}),"(set! name value)\n\n Macro that can be used to set the value of the variable or slot (mutate it).\n set! searches the scope chain until it finds first non empty slot and sets it."),"unset!":doc(new Macro("set!",function(e){if(!(e.car instanceof LSymbol)){throw new Error("unset! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var t=e.car;var r=this.ref(t);if(r){delete r.__env__[t.__name__]}}),"(unset! name)\n\n Function to delete the specified name from environment.\n Trying to access the name afterwards will error."),"set-car!":doc("set-car!",function(e,t){typecheck("set-car!",e,"pair");e.car=t},"(set-car! obj value)\n\n Function that sets the car (first item) of the list/pair to specified value.\n The old value is lost."),"set-cdr!":doc("set-cdr!",function(e,t){typecheck("set-cdr!",e,"pair");e.cdr=t},"(set-cdr! obj value)\n\n Function that sets the cdr (tail) of the list/pair to specified value.\n It will destroy the list. The old tail is lost."),"empty?":doc("empty?",function(e){return typeof e==="undefined"||e===_nil},"(empty? object)\n\n Function that returns #t if value is nil (an empty list) or undefined."),gensym:doc("gensym",gensym,"(gensym)\n\n Generates a unique symbol that is not bound anywhere,\n to use with macros as meta name."),load:doc("load",function e(u,t){typecheck("load",u,"string");var s=this;if(s.__name__==="__frame__"){s=s.__parent__}if(!(t instanceof Environment)){if(s===global_env){t=s}else{t=this.get("**interaction-environment**")}}var c="**module-path**";var l=global_env.get(c,{throwError:false});u=u.valueOf();if(!u.match(/.[^.]+$/)){u+=".scm"}var r=u.match(/\.xcb$/);function f(e){if(r){e=unserialize_bin(e)}else{if(type(e)==="buffer"){e=e.toString()}e=e.replace(/^#!.*/,"");if(e.match(/^\{/)){e=unserialize(e)}}return exec(e,{env:t})}function n(e){return root.fetch(e).then(function(e){return r?e.arrayBuffer():e.text()}).then(function(e){if(r){e=new Uint8Array(e)}return e})}if(is_node()){return new Promise(function(){var r=_asyncToGenerator(_regeneratorRuntime.mark(function e(r,n){var i,a,o;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:i=nodeRequire("path");if(!l){t.next=6;break}l=l.valueOf();u=i.join(l,u);t.next=12;break;case 6:a=s.get("command-line",{throwError:false});if(!a){t.next=11;break}t.next=10;return a();case 10:o=t.sent;case 11:if(o&&o!==_nil){process.cwd();u=i.join(i.dirname(o.car.valueOf()),u)}case 12:global_env.set(c,i.dirname(u));nodeRequire("fs").readFile(u,function(e,t){if(e){n(e);global_env.set(c,l)}else{try{f(t).then(function(){r();global_env.set(c,l)})["catch"](n)}catch(e){n(e)}}});case 14:case"end":return t.stop()}},e)}));return function(e,t){return r.apply(this,arguments)}}())}if(l){l=l.valueOf();u=l+"/"+u.replace(/^\.?\/?/,"")}return n(u).then(function(e){global_env.set(c,u.replace(/\/[^/]*$/,""));return f(e)}).then(function(){})["finally"](function(){global_env.set(c,l)})},"(load filename)\n (load filename environment)\n\n Fetches the file (from disk or network) and evaluates its content as LIPS code.\n If the second argument is provided and it's an environment the evaluation\n will happen in that environment."),do:doc(new Macro("do",function(){var r=_asyncToGenerator(function(_,e){var p=this;var h=e.use_dynamic,d=e.error;return _regeneratorRuntime.mark(function e(){var r,n,u,s,i,c,l,a,o,f;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=p;n=r;u=r.inherit("do");s=_.car;i=_.cdr.car;c=_.cdr.cdr;if(c!==_nil){c=new Pair(LSymbol("begin"),c)}l={env:r,dynamic_env:n,use_dynamic:h,error:d};a=s;case 9:if(!(a!==_nil)){t.next=20;break}o=a.car;t.t0=u;t.t1=o.car;t.next=15;return _evaluate(o.cdr.car,l);case 15:t.t2=t.sent;t.t0.set.call(t.t0,t.t1,t.t2);a=a.cdr;t.next=9;break;case 20:l={env:u,dynamic_env:n,error:d};f=_regeneratorRuntime.mark(function e(){var r,n,i,a,o;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!(c!==_nil)){t.next=3;break}t.next=3;return lips.evaluate(c,l);case 3:r=s;n={};case 5:if(!(r!==_nil)){t.next=15;break}i=r.car;if(!(i.cdr.cdr!==_nil)){t.next=12;break}t.next=10;return _evaluate(i.cdr.cdr.car,l);case 10:a=t.sent;n[i.car.valueOf()]=a;case 12:r=r.cdr;t.next=5;break;case 15:o=Object.getOwnPropertySymbols(n);Object.keys(n).concat(o).forEach(function(e){u.set(e,n[e])});case 17:case"end":return t.stop()}},e)});case 22:t.next=24;return _evaluate(i.car,l);case 24:t.t3=t.sent;if(!(t.t3===false)){t.next=29;break}return t.delegateYield(f(),"t4",27);case 27:t.next=22;break;case 29:if(!(i.cdr!==_nil)){t.next=33;break}t.next=32;return _evaluate(i.cdr.car,l);case 32:return t.abrupt("return",t.sent);case 33:case"end":return t.stop()}},e)})()});return function(e,t){return r.apply(this,arguments)}}()),"(do (( )) (test return) . body)\n\n Iteration macro that evaluates the expression body in scope of the variables.\n On each loop it changes the variables according to the expression and runs\n test to check if the loop should continue. If test is a single value, the macro\n will return undefined. If the test is a pair of expressions the macro will\n evaluate and return the second expression after the loop exits."),if:doc(new Macro("if",function(r,e){var t=e.error,n=e.use_dynamic;var i=this;var a=this;var o={env:a,dynamic_env:i,use_dynamic:n,error:t};var u=function e(t){if(t===false){return _evaluate(r.cdr.cdr.car,o)}else{return _evaluate(r.cdr.car,o)}};if(r===_nil){throw new Error("too few expressions for `if`")}var s=_evaluate(r.car,o);return unpromise(s,u)}),"(if cond true-expr false-expr)\n\n Macro that evaluates cond expression and if the value is true, it\n evaluates and returns true-expression, if not it evaluates and returns\n false-expression."),"let-env":new Macro("let-env",function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=e.dynamic_env,n=e.use_dynamic,i=e.error;typecheck("let-env",t,"pair");var a=_evaluate(t.car,{env:this,dynamic_env:r,error:i,use_dynamic:n});return unpromise(a,function(e){typecheck("let-env",e,"environment");return _evaluate(Pair(LSymbol("begin"),t.cdr),{env:e,dynamic_env:r,error:i})})},"(let-env env . body)\n\n Special macro that evaluates body in context of given environment\n object."),letrec:doc(let_macro(Symbol["for"]("letrec")),"(letrec ((a value-a) (b value-b) ...) . body)\n\n Macro that creates a new environment, then evaluates and assigns values to\n names and then evaluates the body in context of that environment.\n Values are evaluated sequentially and the next value can access the\n previous values/names."),"letrec*":doc(let_macro(Symbol["for"]("letrec")),"(letrec* ((a value-a) (b value-b) ...) . body)\n\n Same as letrec but the order of execution of the binding is guaranteed,\n so you can use recursive code as well as referencing the previous binding.\n\n In LIPS both letrec and letrec* behave the same."),"let*":doc(let_macro(Symbol["for"]("let*")),"(let* ((a value-a) (b value-b) ...) . body)\n\n Macro similar to `let`, but the subsequent bindings after the first\n are evaluated in the environment including the previous let variables,\n so you can define one variable, and use it in the next's definition."),let:doc(let_macro(Symbol["for"]("let")),"(let ((a value-a) (b value-b) ...) . body)\n\n Macro that creates a new environment, then evaluates and assigns values to names,\n and then evaluates the body in context of that environment. Values are evaluated\n sequentially but you can't access previous values/names when the next are\n evaluated. You can only get them in the body of the let expression. (If you want\n to define multiple variables and use them in each other's definitions, use\n `let*`.)"),"begin*":doc(parallel("begin*",function(e){return e.pop()}),"(begin* . body)\n\n This macro is a parallel version of begin. It evaluates each expression\n in the body and if it's a promise it will await it in parallel and return\n the value of the last expression (i.e. it uses Promise.all())."),shuffle:doc("shuffle",function(e){typecheck("shuffle",e,["pair","nil","array"]);var t=global_env.get("random");if(e===_nil){return _nil}if(Array.isArray(e)){return shuffle(e.slice(),t)}var r=global_env.get("list->array")(e);r=shuffle(r,t);return global_env.get("array->list")(r)},"(shuffle obj)\n\n Order items in vector or list in random order."),begin:doc(new Macro("begin",function(e,t){var n=_objectSpread(_objectSpread({},t),{},{env:this});var i=global_env.get("list->array")(e);var a;return function t(){if(i.length){var e=i.shift();var r=_evaluate(e,n);return unpromise(r,function(e){a=e;return t()})}else{return a}}()}),"(begin . args)\n\n Macro that runs a list of expressions in order and returns the value\n of the last one. It can be used in places where you can only have a\n single expression, like (if)."),ignore:new Macro("ignore",function(e,t){var r=_objectSpread(_objectSpread({},t),{},{env:this,dynamic_env:this});_evaluate(new Pair(new LSymbol("begin"),e),r)},"(ignore . body)\n\n Macro that will evaluate the expression and swallow any promises that may\n be created. It will discard any value that may be returned by the last body\n expression. The code should have side effects and/or when it's promise\n it should resolve to undefined."),"call/cc":doc(Macro.defmacro("call/cc",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=_objectSpread({env:this},t);return unpromise(_evaluate(e.car,r),function(e){if(is_function(e)){return e(new Continuation(null))}})}),"(call/cc proc)\n\n Call-with-current-continuation.\n\n NOT SUPPORTED BY LIPS RIGHT NOW"),parameterize:doc(new Macro("parameterize",function(t,e){var i=e.dynamic_env;var a=i.inherit("parameterize").new_frame(null,{});var o=_objectSpread(_objectSpread({},e),{},{env:this});var u=t.car;if(!is_pair(u)){var r=type(u);throw new Error("Invalid syntax for parameterize expecting pair got ".concat(r))}function s(){var e=new Pair(new LSymbol("begin"),t.cdr);return _evaluate(e,_objectSpread(_objectSpread({},o),{},{dynamic_env:a}))}return function r(){var e=u.car;var n=e.car.valueOf();return unpromise(_evaluate(e.cdr.car,o),function(e){var t=i.get(n,{throwError:false});if(!is_parameter(t)){throw new Error("Unknown parameter ".concat(n))}a.set(n,t.inherit(e));if(!is_null(u.cdr)){u=u.cdr;return r()}else{return s()}})}()}),"(parameterize ((name value) ...)\n\n Macro that change the dynamic variable created by make-parameter."),"make-parameter":doc(new Macro("make-parameter",function(e,t){t.dynamic_env;var r=_evaluate(e.car,t);var n;if(e.cdr.car instanceof Pair){n=_evaluate(e.cdr.car,t)}return new Parameter(r,n)}),"(make-parameter init converter)\n\n Function creates new dynamic variable that can be custimized with parameterize\n macro. The value should be assigned to a variable e.g.:\n\n (define radix (make-parameter 10))\n\n The result value is a procedure that return the value of dynamic variable."),define:doc(Macro.defmacro("define",function(r,e){var n=this;if(r.car instanceof Pair&&r.car.car instanceof LSymbol){var t=new Pair(new LSymbol("define"),new Pair(r.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(r.car.cdr,r.cdr)))));return t}else if(e.macro_expand){return}e.dynamic_env=this;e.env=n;var i=r.cdr.car;var a;if(i instanceof Pair){i=_evaluate(i,e);a=true}else if(i instanceof LSymbol){i=n.get(i)}typecheck("define",r.car,"symbol");return unpromise(i,function(e){if(n.__name__===Syntax.__merge_env__){n=n.__parent__}if(a&&(is_function(e)&&is_lambda(e)||e instanceof Syntax||is_parameter(e))){e.__name__=r.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var t;if(r.cdr.cdr instanceof Pair&&LString.isString(r.cdr.cdr.car)){t=r.cdr.cdr.car.valueOf()}n.set(r.car,e,t,true)})}),'(define name expression)\n (define name expression "doc string")\n (define (function-name . args) . body)\n\n Macro for defining values. It can be used to define variables,\n or functions. If the first argument is list it will create a function\n with name being first element of the list. This form expands to\n `(define function-name (lambda args body))`'),"set-obj!":doc("set-obj!",function(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var i=_typeof$1(e);if(is_null(e)||i!=="object"&&i!=="function"){var a=typeErrorMessage("set-obj!",type(e),["object","function"]);throw new Error(a)}typecheck("set-obj!",t,["string","symbol","number"]);e=unbind(e);t=t.valueOf();if(arguments.length===2){delete e[t]}else if(is_prototype(e)&&is_function(r)){e[t]=unbind(r);e[t][__prototype__]=true}else if(is_function(r)||is_native(r)||r===_nil){e[t]=r}else{e[t]=r&&!is_prototype(r)?r.valueOf():r}if(props){var o=e[t];Object.defineProperty(e,t,_objectSpread(_objectSpread({},n),{},{value:o}))}},"(set-obj! obj key value)\n (set-obj! obj key value props)\n\n Function set a property of a JavaScript object. props should be a vector of pairs,\n passed to Object.defineProperty."),"null-environment":doc("null-environment",function(){return global_env.inherit("null")},"(null-environment)\n\n Returns a clean environment with only the standard library."),values:doc("values",function e(){for(var t=arguments.length,r=new Array(t),n=0;n1&&arguments[1]!==undefined?arguments[1]:{},y=e.use_dynamic,v=e.error;var g=this;var b;if(m.cdr instanceof Pair&&LString.isString(m.cdr.car)&&m.cdr.cdr!==_nil){b=m.cdr.car.valueOf()}function w(){var e=is_context(this)?this:{dynamic_env:g},r=e.dynamic_env;var n=g.inherit("lambda");r=r.inherit("lambda");if(this&&!is_context(this)){if(this&&!this.__instance__){Object.defineProperty(this,"__instance__",{enumerable:false,get:function e(){return true},set:function e(){},configurable:false})}n.set("this",this)}for(var t=arguments.length,i=new Array(t),a=0;a>> "+d.toString());if(d){_=d}var m=a.merge(n,Syntax.__merge_env__);if(r){return{expr:_,scope:m}}var y=_evaluate(_,_objectSpread(_objectSpread({},u),{},{env:m}));return clear_gensyms(y,h)}c=c.cdr}}catch(e){e.message+=" in macro: ".concat(v.toString(true));throw e}throw new Error("Invalid Syntax ".concat(e.toString(true)))},w);r.__code__=v;return r},"(syntax-rules () (pattern expression) ...)\n\n Base of hygienic macros, it will return a new syntax expander\n that works like Lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression) or 'expression\n\n Macro that returns a single LIPS expression as data (it won't evaluate the\n argument). It will return a list if put in front of LIPS code.\n And if put in front of a symbol it will return the symbol itself, not the value\n bound to that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code) or ,@code\n\n Special form used in the quasiquote macro. It evaluates the expression inside and\n splices the list into quasiquote's result. If it is not the last element of the\n expression, the computed value must be a pair."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code) or ,code\n\n Special form used in the quasiquote macro. It evaluates the expression inside and\n substitutes the value into quasiquote's result."),quasiquote:Macro.defmacro("quasiquote",function(e,t){var u=t.use_dynamic,s=t.error;var c=this;var l=c;function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function f(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:a;if(e instanceof Pair){var n=e.car;var i=e.cdr;if(r(n)){n=t(n)}if(r(i)){i=t(i)}if(is_promise(n)||is_promise(i)){return promise_all([n,i]).then(function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];return new Pair(r,n)})}else{return new Pair(n,i)}}return e}function o(e,t){if(e instanceof Pair){if(t!==_nil){e.append(t)}}else{e=new Pair(e,t)}return e}function r(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,/^(unquote|unquote-splicing)$/)}).length}function _(e,n,i){return e.reduce(function(e,t){if(!(t instanceof Pair)){e.push(t);return e}if(LSymbol.is(t.car,"unquote-splicing")){var r;if(n+11){var t="You can't splice multiple atoms inside list";throw new Error(t)}if(!(i.cdr instanceof Pair&&r[0]===_nil)){return r[0]}}r=r.map(function(e){if(d.has(e)){return e.clone()}else{d.add(e);return e}});var n=m(i.cdr,0,1);if(n===_nil&&r[0]===_nil){return undefined}return unpromise(n,function(e){if(r[0]===_nil){return e}if(r.length===1){return o(r[0],e)}var t=r.reduce(function(e,t){return o(e,t)});return o(t,e)})})}(i.car.cdr)}var d=new Set;function m(e,t,r){if(e instanceof Pair){if(e.car instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return h(e,t+1,r)}if(LSymbol.is(e.car.car,"unquote")){if(t+2===r&&e.car.cdr instanceof Pair&&e.car.cdr.car instanceof Pair&&LSymbol.is(e.car.cdr.car.car,"unquote-splicing")){var n=e.car.cdr;return new Pair(new Pair(new LSymbol("unquote"),h(n,t+2,r)),_nil)}else if(e.car.cdr instanceof Pair&&e.car.cdr.cdr!==_nil){if(e.car.cdr.car instanceof Pair){var i=[];return function t(r){if(r===_nil){return Pair.fromArray(i)}return unpromise(_evaluate(r.car,{env:c,dynamic_env:l,use_dynamic:u,error:s}),function(e){i.push(e);return t(r.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}}if(LSymbol.is(e.car,"quasiquote")){var a=m(e.cdr,t,r+1);return new Pair(e.car,a)}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,t,r))}if(LSymbol.is(e.car,"unquote")){t++;if(tr){throw new Error("You can't call `unquote` outside "+"of quasiquote")}if(e.cdr instanceof Pair){if(e.cdr.cdr!==_nil){if(e.cdr.car instanceof Pair){var o=[];return function t(r){if(r===_nil){return Pair.fromArray(o)}return unpromise(_evaluate(r.car,{env:c,dynamic_env:l,use_dynamic:u,error:s}),function(e){o.push(e);return t(r.cdr)})}(e.cdr)}else{return e.cdr}}else{return _evaluate(e.cdr.car,{env:c,dynamic_env:l,error:s})}}else{return e.cdr}}return f(e,function(e){return m(e,t,r)})}else if(is_plain_object(e)){return p(e,t,r)}else if(e instanceof Array){return _(e,t,r)}return e}function n(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}}if(is_plain_object(e.car)&&!r(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!r(e.car)){return quote(e.car)}if(e.car instanceof Pair&&!e.car.find("unquote")&&!e.car.find("unquote-splicing")&&!e.car.find("quasiquote")){return quote(e.car)}var i=m(e.car,0,1);return unpromise(i,function(e){n(e);return quote(e)})},"(quasiquote list)\n\n Similar macro to `quote` but inside it you can use special expressions (unquote\n x) abbreviated to ,x that will evaluate x and insert its value verbatim or\n (unquote-splicing x) abbreviated to ,@x that will evaluate x and splice the value\n into the result. Best used with macros but it can be used outside."),clone:doc("clone",function e(t){typecheck("clone",t,"pair");return t.clone()},"(clone list)\n\n Function that returns a clone of the list, that does not share any pairs with the\n original, so the clone can be safely mutated without affecting the original."),append:doc("append",function e(){var t;for(var r=arguments.length,n=new Array(r),i=0;iarray")(t).reverse();return global_env.get("array->list")(r)}else if(Array.isArray(t)){return t.reverse()}else{throw new Error(typeErrorMessage("reverse",type(t),"array or pair"))}},"(reverse list)\n\n Function that reverses the list or array. If value is not a list\n or array it will error."),nth:doc("nth",function e(t,r){typecheck("nth",t,"number");typecheck("nth",r,["array","pair"]);if(r instanceof Pair){var n=r;var i=0;while(iarray")(r).join(t)},"(join separator list)\n\n Function that returns a string by joining elements of the list using separator."),split:doc("split",function e(t,r){typecheck("split",t,["regex","string"]);typecheck("split",r,"string");return global_env.get("array->list")(r.split(t))},"(split separator string)\n\n Function that creates a list by splitting string by separator which can\n be a string or regular expression."),replace:doc("replace",function e(t,r,n){typecheck("replace",t,["regex","string"]);typecheck("replace",r,["string","function"]);typecheck("replace",n,"string");return n.replace(t,r)},"(replace pattern replacement string)\n\n Function that changes pattern to replacement inside string. Pattern can be a\n string or regex and replacement can be function or string. See Javascript\n String.replace()."),match:doc("match",function e(t,r){typecheck("match",t,["regex","string"]);typecheck("match",r,"string");var n=r.match(t);return n?global_env.get("array->list")(n):false},"(match pattern string)\n\n Function that returns a match object from JavaScript as a list or #f if\n no match."),search:doc("search",function e(t,r){typecheck("search",t,["regex","string"]);typecheck("search",r,"string");return r.search(t)},"(search pattern string)\n\n Function that returns the first found index of the pattern inside a string."),repr:doc("repr",function e(t,r){return toString(t,r)},"(repr obj)\n\n Function that returns a LIPS code representation of the object as a string."),"escape-regex":doc("escape-regex",function(e){typecheck("escape-regex",e,"string");return escape_regex(e.valueOf())},"(escape-regex string)\n\n Function that returns a new string where all special operators used in regex,\n are escaped with backslashes so they can be used in the RegExp constructor\n to match a literal string."),env:doc("env",function e(e){e=e||this.env;var t=Object.keys(e.__env__).map(LSymbol);var r;if(t.length){r=Pair.fromArray(t)}else{r=_nil}if(e.__parent__ instanceof Environment){return global_env.get("env").call(this,e.__parent__).append(r)}return r},"(env)\n (env obj)\n\n Function that returns a list of names (functions, macros and variables)\n that are bound in the current environment or one of its parents."),new:doc("new",function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2&&arguments[2]!==undefined?arguments[2]:specials.LITERAL;typecheck("set-special!",e,"string",1);typecheck("set-special!",t,"symbol",2);specials.append(e.valueOf(),t,r)},'(set-special! symbol name [type])\n\n Add a special symbol to the list of transforming operators by the parser.\n e.g.: `(add-special! "#" \'x)` will allow to use `#(1 2 3)` and it will be\n transformed into (x (1 2 3)) so you can write x macro that will process\n the list. 3rd argument is optional, and it can be one of two values:\n lips.specials.LITERAL, which is the default behavior, or\n lips.specials.SPLICE which causes the value to be unpacked into the expression.\n This can be used for e.g. to make `#(1 2 3)` into (x 1 2 3) that is needed\n by # that defines vectors.'),get:get,".":get,unbind:doc(unbind,"(unbind fn)\n\n Function that removes the weak 'this' binding from a function so you\n can get properties from the actual function object."),type:doc(type,"(type object)\n\n Function that returns the type of an object as string."),debugger:doc("debugger",function(){debugger},'(debugger)\n\n Function that triggers the JavaScript debugger (e.g. the browser devtools)\n using the "debugger;" statement. If a debugger is not running this\n function does nothing.'),in:doc("in",function(e,t){if(e instanceof LSymbol||e instanceof LString||e instanceof LNumber){e=e.valueOf()}return e in unbox(t)},'(in key value)\n\n Function that uses the Javascript "in" operator to check if key is\n a valid property in the value.'),"instance?":doc("instance?",function(e){return is_instance(e)},"(instance? obj)\n\n Checks if object is an instance, created with a new operator"),instanceof:doc("instanceof",function(e,t){return t instanceof unbind(e)},"(instanceof type obj)\n\n Predicate that tests if the obj is an instance of type."),"prototype?":doc("prototype?",is_prototype,"(prototype? obj)\n\n Predicate that tests if value is a valid JavaScript prototype,\n i.e. calling (new) with it will not throw ' is not a constructor'."),"macro?":doc("macro?",function(e){return e instanceof Macro},"(macro? expression)\n\n Predicate that tests if value is a macro."),"function?":doc("function?",is_function,"(function? expression)\n\n Predicate that tests if value is a callable function."),"real?":doc("real?",function(e){if(type(e)!=="number"){return false}if(e instanceof LNumber){return e.isFloat()}return LNumber.isFloat(e)},"(real? number)\n\n Predicate that tests if value is a real number (not complex)."),"number?":doc("number?",function(e){return Number.isNaN(e)||LNumber.isNumber(e)},"(number? expression)\n\n Predicate that tests if value is a number or NaN value."),"string?":doc("string?",function(e){return LString.isString(e)},"(string? expression)\n\n Predicate that tests if value is a string."),"pair?":doc("pair?",function(e){return e instanceof Pair},"(pair? expression)\n\n Predicate that tests if value is a pair or list structure."),"regex?":doc("regex?",function(e){return e instanceof RegExp},"(regex? expression)\n\n Predicate that tests if value is a regular expression."),"null?":doc("null?",function(e){return is_null(e)},"(null? expression)\n\n Predicate that tests if value is null-ish (i.e. undefined, nil, or\n Javascript null)."),"boolean?":doc("boolean?",function(e){return typeof e==="boolean"},"(boolean? expression)\n\n Predicate that tests if value is a boolean (#t or #f)."),"symbol?":doc("symbol?",function(e){return e instanceof LSymbol},"(symbol? expression)\n\n Predicate that tests if value is a LIPS symbol."),"array?":doc("array?",function(e){return e instanceof Array},"(array? expression)\n\n Predicate that tests if value is an array."),"object?":doc("object?",function(e){return e!==_nil&&e!==null&&!(e instanceof LCharacter)&&!(e instanceof RegExp)&&!(e instanceof LString)&&!(e instanceof Pair)&&!(e instanceof LNumber)&&_typeof$1(e)==="object"&&!(e instanceof Array)},"(object? expression)\n\n Predicate that tests if value is an plain object (not another LIPS type)."),flatten:doc("flatten",function e(t){typecheck("flatten",t,"pair");return t.flatten()},"(flatten list)\n\n Returns a shallow list from tree structure (pairs)."),"array->list":doc("array->list",function(e){typecheck("array->list",e,"array");return Pair.fromArray(e)},"(array->list array)\n\n Function that converts a JavaScript array to a LIPS cons list."),"tree->array":doc("tree->array",to_array("tree->array",true),"(tree->array list)\n\n Function that converts a LIPS cons tree structure into a JavaScript array."),"list->array":doc("list->array",to_array("list->array"),"(list->array list)\n\n Function that converts a LIPS list into a JavaScript array."),apply:doc("apply",function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;iarray").call(this,a));return t.apply(this,prepare_fn_args(t,n))},"(apply fn list)\n\n Function that calls fn with the list of arguments."),length:doc("length",function e(t){if(!t||t===_nil){return 0}if(t instanceof Pair){return t.length()}if("length"in t){return t.length}},'(length expression)\n\n Function that returns the length of the object. The object can be a LIPS\n list or any object that has a "length" property. Returns undefined if the\n length could not be found.'),"string->number":doc("string->number",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;typecheck("string->number",e,"string",1);typecheck("string->number",t,"number",2);e=e.valueOf();t=t.valueOf();if(e.match(rational_bare_re)||e.match(rational_re)){return parse_rational(e,t)}else if(e.match(complex_bare_re)||e.match(complex_re)){return parse_complex(e,t)}else{var r=t===10&&!e.match(/e/i)||t===16;if(e.match(int_bare_re)&&r||e.match(int_re)){return parse_integer(e,t)}if(e.match(float_re)){return parse_float(e)}}return false},"(string->number number [radix])\n\n Function that parses a string into a number."),try:doc(new Macro("try",function(r,e){var f=this;var _=e.use_dynamic;e.error;return new Promise(function(t,u){var s,n;if(LSymbol.is(r.cdr.car.car,"catch")){s=r.cdr.car;if(r.cdr.cdr instanceof Pair&&LSymbol.is(r.cdr.cdr.car.car,"finally")){n=r.cdr.cdr.car}}else if(LSymbol.is(r.cdr.car.car,"finally")){n=r.cdr.car}if(!(n||s)){throw new Error("try: invalid syntax")}function c(e){t(e);throw new IgnoreException("[CATCH]")}var l=function e(t,r){r(t)};if(n){l=function e(t,r){l=u;i.error=function(e){throw e};unpromise(_evaluate(new Pair(new LSymbol("begin"),n.cdr),i),function(){r(t)})}}var i={env:f,use_dynamic:_,dynamic_env:f,error:function e(t){if(t instanceof IgnoreException){throw t}var r=f.inherit("try");if(s){var n=s.cdr.car.car;if(!(n instanceof LSymbol)){throw new Error("try: invalid syntax: catch require variable name")}r.set(n,t);var i;var a={env:r,use_dynamic:_,dynamic_env:f,error:function e(t){i=true;u(t);throw new IgnoreException("[CATCH]")}};var o=_evaluate(new Pair(new LSymbol("begin"),s.cdr.cdr),a);unpromise(o,function e(t){if(!i){l(t,c)}})}else{l(undefined,function(){throw t})}}};var e=_evaluate(r.car,i);unpromise(e,function(e){l(e,t)},i.error)})}),"(try expr (catch (e) code))\n (try expr (catch (e) code) (finally code))\n (try expr (finally code))\n\n Macro that executes expr and catches any exceptions thrown. If catch is provided\n it's executed when an error is thrown. If finally is provided it's always\n executed at the end."),raise:doc("raise",function(e){throw e},"(raise obj)\n\n Throws the object verbatim (no wrapping an a new Error)."),throw:doc("throw",function(e){throw new Error(e)},"(throw string)\n\n Throws a new exception."),find:doc("find",function t(r,n){typecheck("find",r,["regex","function"]);typecheck("find",n,["pair","nil"]);if(is_null(n)){return _nil}var e=matcher("find",r);return unpromise(e(n.car),function(e){if(e&&e!==_nil){return n.car}return t(r,n.cdr)})},"(find fn list)\n (find regex list)\n\n Higher-order function that finds the first value for which fn return true.\n If called with a regex it will create a matcher function."),"for-each":doc("for-each",function(e){var t;typecheck("for-each",e,"function");for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i1?t-1:0),a=1;a3?n-3:0),a=3;a3?i-3:0),o=3;oarray")(r);var a=[];var o=matcher("filter",t);return function t(r){function e(e){if(e&&e!==_nil){a.push(n)}return t(++r)}if(r===i.length){return Pair.fromArray(a)}var n=i[r];return unpromise(o(n),e)}(0)},"(filter fn list)\n (filter regex list)\n\n Higher-order function that calls `fn` for each element of the list\n and return a new list for only those elements for which fn returns\n a truthy value. If called with a regex it will create a matcher function."),compose:doc(compose,"(compose . fns)\n\n Higher-order function that creates a new function that applies all functions\n from right to left and returns the last value. Reverse of pipe.\n e.g.:\n ((compose (curry + 2) (curry * 3)) 10) --\x3e (+ 2 (* 3 10)) --\x3e 32"),pipe:doc(pipe,"(pipe . fns)\n\n Higher-order function that creates a new function that applies all functions\n from left to right and returns the last value. Reverse of compose.\n e.g.:\n ((pipe (curry + 2) (curry * 3)) 10) --\x3e (* 3 (+ 2 10)) --\x3e 36"),curry:doc(curry,"(curry fn . args)\n\n Higher-order function that creates a curried version of the function.\n The result function will have partially applied arguments and it\n will keep returning one-argument functions until all arguments are provided,\n then it calls the original function with the accumulated arguments.\n\n e.g.:\n (define (add a b c d) (+ a b c d))\n (define add1 (curry add 1))\n (define add12 (add 2))\n (display (add12 3 4))"),gcd:doc("gcd",function e(){for(var t=arguments.length,r=new Array(t),n=0;nu?a%=u:u%=a}a=abs(s*r[o])/(a+u)}return LNumber(a)},"(lcm n1 n2 ...)\n\n Function that returns the least common multiple of the arguments."),"odd?":doc("odd?",single_math_op(function(e){return LNumber(e).isOdd()}),"(odd? number)\n\n Checks if number is odd."),"even?":doc("even?",single_math_op(function(e){return LNumber(e).isEven()}),"(even? number)\n\n Checks if number is even."),"*":doc("*",reduce_math_op(function(e,t){return LNumber(e).mul(t)},LNumber(1)),"(* . numbers)\n\n Multiplies all numbers passed as arguments. If single value is passed\n it will return that value."),"+":doc("+",reduce_math_op(function(e,t){return LNumber(e).add(t)},LNumber(0)),"(+ . numbers)\n\n Sums all numbers passed as arguments. If single value is passed it will\n return that value."),"-":doc("-",function(){for(var e=arguments.length,t=new Array(e),r=0;r":doc(">",function(){for(var e=arguments.length,t=new Array(e),r=0;r",t,["bigint","float","rational"]);return seq_compare(function(e,t){return LNumber(e).cmp(t)===1},t)},"(> x1 x2 x3 ...)\n\n Function that compares its numerical arguments and checks if they are\n monotonically decreasing, i.e. x1 > x2 and x2 > x3 and so on."),"<":doc("<",function(){for(var e=arguments.length,t=new Array(e),r=0;r=":doc(">=",function(){for(var e=arguments.length,t=new Array(e),r=0;r=",t,["bigint","float","rational"]);return seq_compare(function(e,t){return[0,1].includes(LNumber(e).cmp(t))},t)},"(>= x1 x2 ...)\n\n Function that compares its numerical arguments and checks if they are\n monotonically nonincreasing, i.e. x1 >= x2 and x2 >= x3 and so on."),"eq?":doc("eq?",equal,"(eq? a b)\n\n Function that compares two values if they are identical."),or:doc(new Macro("or",function(e,t){var i=t.use_dynamic,a=t.error;var o=global_env.get("list->array")(e);var u=this;var s=u;if(!o.length){return false}var c;return function t(){function e(e){c=e;if(c!==false){return c}else{return t()}}if(!o.length){if(c!==false){return c}else{return false}}else{var r=o.shift();var n=_evaluate(r,{env:u,dynamic_env:s,use_dynamic:i,error:a});return unpromise(n,e)}}()}),"(or . expressions)\n\n Macro that executes the values one by one and returns the first that is\n a truthy value. If there are no expressions that evaluate to true it\n returns false."),and:doc(new Macro("and",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=global_env.get("list->array")(e);var a=this;var o=a;if(!i.length){return true}var u;var s={env:a,dynamic_env:o,use_dynamic:r,error:n};return function t(){function e(e){u=e;if(u===false){return false}else{return t()}}if(!i.length){if(u!==false){return u}else{return false}}else{var r=i.shift();return unpromise(_evaluate(r,s),e)}}()}),"(and . expressions)\n\n Macro that evaluates each expression in sequence and if any value returns false\n it will stop and return false. If each value returns true it will return the\n last value. If it's called without arguments it will return true."),"|":doc("|",function(e,t){return LNumber(e).or(t)},"(| a b)\n\n Function that calculates the bitwise or operation."),"&":doc("&",function(e,t){return LNumber(e).and(t)},"(& a b)\n\n Function that calculates the bitwise and operation."),"~":doc("~",function(e){return LNumber(e).neg()},"(~ number)\n\n Function that calculates the bitwise inverse (flip all the bits)."),">>":doc(">>",function(e,t){return LNumber(e).shr(t)},"(>> a b)\n\n Function that right shifts the value a by value b bits."),"<<":doc("<<",function(e,t){return LNumber(e).shl(t)},"(<< a b)\n\n Function that left shifts the value a by value b bits."),not:doc("not",function e(t){if(is_null(t)){return true}return!t},"(not object)\n\n Function that returns the Boolean negation of its argument.")},undefined,"global");var user_env=global_env.inherit("user-env");function set_interaction_env(e,t){e.constant("**internal-env**",t);e.doc("**internal-env**","**internal-env**\n\n Constant used to hide stdin, stdout and stderr so they don't interfere\n with variables with the same name. Constants are an internal type\n of variable that can't be redefined, defining a variable with the same name\n will throw an error.");global_env.set("**interaction-environment**",e)}set_interaction_env(user_env,internal_env);global_env.doc("**interaction-environment**","**interaction-environment**\n\n Internal dynamic, global variable used to find interpreter environment.\n It's used so the read and write functions can locate **internal-env**\n that contains the references to stdin, stdout and stderr.");function set_fs(e){user_env.get("**internal-env**").set("fs",e)}(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(t){var r=e[t]?e[t]:t;global_env.set(r,doc(r,function(e){typecheck(r,e,"number");if(e instanceof LNumber){return e[t]()}},"(".concat(r," number)\n\n Function that calculates the ").concat(r," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var t=[];var r=allPossibleCases(e.slice(1));for(var n=0;n3&&arguments[3]!==undefined?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(n!==null){i+=" (argument ".concat(n,")")}if(is_function(r)){return"Invalid type: got ".concat(t).concat(i)}if(r instanceof Array){if(r.length===1){var a=r[0].toLowerCase();r="a"+("aeiou".includes(a)?"n ":" ")+r[0]}else{r=new Intl.ListFormat("en",{style:"long",type:"disjunction"}).format(r)}}return"Expecting ".concat(r," got ").concat(t).concat(i)}function typecheck_number(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;typecheck(e,t,"number",n);var i=t.__type__;var a;if(r instanceof Pair){r=r.to_array()}if(r instanceof Array){r=r.map(function(e){return e.valueOf()})}if(r instanceof Array){r=r.map(function(e){return e.valueOf().toLowerCase()});if(r.includes(i)){a=true}}else{r=r.valueOf().toLowerCase()}if(!a&&i!==r){throw new Error(typeErrorMessage(e,i,r,n))}}function typecheck_numbers(r,e,n){e.forEach(function(e,t){typecheck_number(r,e,n,t+1)})}function typecheck_args(r,e,n){e.forEach(function(e,t){typecheck(r,e,n,t+1)})}function typecheck_text_port(e,t,r){typecheck(e,t,r);if(t.__type__===binary_port){throw new Error(typeErrorMessage(e,"binary-port","textual-port"))}}function typecheck(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;e=e.valueOf();var i=type(t).toLowerCase();if(is_function(r)){if(!r(t)){throw new Error(typeErrorMessage(e,i,r,n))}return}var a=false;if(r instanceof Pair){r=r.to_array()}if(r instanceof Array){r=r.map(function(e){return e.valueOf()})}if(r instanceof Array){r=r.map(function(e){return e.valueOf().toLowerCase()});if(r.includes(i)){a=true}}else{r=r.valueOf().toLowerCase()}if(!a&&i!==r){throw new Error(typeErrorMessage(e,i,r,n))}}function memoize(r){var n=new WeakMap;return function(e){var t=n.get(e);if(!t){t=r(e)}return t}}type=memoize(type);function type(e){var t=type_constants.get(e);if(t){return t}if(_typeof$1(e)==="object"){for(var r=0,n=Object.entries(type_mapping);r2&&arguments[2]!==undefined?arguments[2]:{},n=r.env,i=r.dynamic_env,a=r.use_dynamic;var o=n===null||n===void 0?void 0:n.new_frame(e,t);var u=i===null||i===void 0?void 0:i.new_frame(e,t);var s=new LambdaContext({env:o,use_dynamic:a,dynamic_env:u});return resolve_promises(e.apply(s,t))}function apply(n,e){var t=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},i=t.env,a=t.dynamic_env,o=t.use_dynamic,r=t.error,u=r===void 0?function(){}:r;e=evaluate_args(e,{env:i,dynamic_env:a,error:u,use_dynamic:o});return unpromise(e,function(e){if(is_raw_lambda(n)){n=unbind(n)}e=prepare_fn_args(n,e);var t=e.slice();var r=call_function(n,t,{env:i,dynamic_env:a,use_dynamic:o});return unpromise(r,function(e){if(e instanceof Pair){e.markCycles();return quote(e)}return box(e)},u)})}var _p_name__=new WeakMap;var Parameter=function(){function n(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;_classCallCheck(this,n);_defineProperty(this,"__value__",void 0);_defineProperty(this,"__fn__",void 0);_classPrivateFieldInitSpec(this,_p_name__,{writable:true,value:void 0});this.__value__=e;if(t){if(!is_function(t)){throw new Error("Section argument to Parameter need to be function "+"".concat(type(t)," given"))}this.__fn__=t}if(r){_classPrivateFieldSet(this,_p_name__,r)}}_createClass(n,[{key:"__name__",get:function e(){return _classPrivateFieldGet(this,_p_name__)},set:function e(t){_classPrivateFieldSet(this,_p_name__,t);if(this.__fn__){this.__fn__.__name__="fn-".concat(t)}}},{key:"invoke",value:function e(){if(is_function(this.__fn__)){return this.__fn__(this.__value__)}return this.__value__}},{key:"inherit",value:function e(t){return new n(t,this.__fn__,this.__name__)}}]);return n}();var LambdaContext=function(){function t(e){_classCallCheck(this,t);_defineProperty(this,"env",void 0);_defineProperty(this,"dynamic_env",void 0);_defineProperty(this,"use_dynamic",void 0);Object.assign(this,e)}_createClass(t,[{key:"__name__",get:function e(){return this.env.__name__}},{key:"__parent__",get:function e(){return this.env.__parent__}},{key:"get",value:function e(){var t;return(t=this.env).get.apply(t,arguments)}}]);return t}();function search_param(e,t){var r=e.get(t.__name__,{throwError:false});if(is_parameter(r)&&r!==t){return r}var n=user_env.get("**interaction-environment**");while(true){var i=e.get("parent.frame",{throwError:false});e=i(0);if(e===n){break}r=e.get(t.__name__,{throwError:false});if(is_parameter(r)&&r!==t){return r}}return t}var Continuation=function(){function t(e){_classCallCheck(this,t);_defineProperty(this,"__value__",void 0);this.__value__=e}_createClass(t,[{key:"invoke",value:function e(){if(this.__value__===null){throw new Error("Continuations are not implemented yet")}}}]);return t}();function _evaluate(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},s=e.env,c=e.dynamic_env,l=e.use_dynamic,t=e.error,f=t===void 0?noop:t,r=_objectWithoutProperties(e,_excluded6);return function(e){try{if(!is_env(c)){c=s===true?user_env:s||user_env}if(l){s=c}else if(s===true){s=user_env}else{s=s||global_env}var t={env:s,dynamic_env:c,use_dynamic:l,error:f};var r;if(is_null(u)){return u}if(u instanceof LSymbol){return s.get(u)}if(!(u instanceof Pair)){return u}var n=u.car;var e=u.cdr;if(n instanceof Pair){r=resolve_promises(_evaluate(n,t));if(is_promise(r)){return r.then(function(e){if(!is_callable(e)){throw new Error(type(e)+" "+s.get("repr")(e)+" is not callable while evaluating "+u.toString())}return _evaluate(new Pair(e,u.cdr),t)})}else if(!is_callable(r)){throw new Error(type(r)+" "+s.get("repr")(r)+" is not callable while evaluating "+u.toString())}}if(n instanceof LSymbol){r=s.get(n)}else if(is_function(n)){r=n}var i;if(r instanceof Syntax){i=evaluate_syntax(r,u,t)}else if(r instanceof Macro){i=evaluate_macro(r,e,t)}else if(is_function(r)){i=apply(r,e,t)}else if(is_parameter(r)){var a=search_param(c,r);if(is_null(u.cdr)){i=a.invoke()}else{return unpromise(_evaluate(u.cdr.car,t),function(e){a.__value__=e})}}else if(is_continuation(r)){i=r.invoke()}else if(u instanceof Pair){r=n&&n.toString();throw new Error("".concat(type(n)," ").concat(r," is not a function"))}else{return u}var o=s.get(Symbol["for"]("__promise__"),{throwError:false});if(o===true&&is_promise(i)){i=i.then(function(e){if(e instanceof Pair&&!r[__data__]){return _evaluate(e,t)}return e});return new QuotedPromise(i)}return i}catch(e){f&&f.call(s,e,u)}}(r)}var compile=exec_collect(function(e){return e});var exec=exec_collect(function(e,t){return t});function exec_collect(d){return function(){var t=_asyncToGenerator(function(f){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},_=e.env,p=e.dynamic_env,h=e.use_dynamic;return _regeneratorRuntime.mark(function e(){var r,n,i,a,o,u,s,c,l;return _regeneratorRuntime.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!is_env(p)){p=_===true?user_env:_||user_env}if(_===true){_=user_env}else{_=_||user_env}r=[];n=Array.isArray(f)?f:_parse(f);i=false;a=false;t.prev=6;u=_asyncIterator(n);case 8:t.next=10;return u.next();case 10:if(!(i=!(s=t.sent).done)){t.next=24;break}c=s.value;l=_evaluate(c,{env:_,dynamic_env:p,use_dynamic:h,error:function e(t,r){if(t&&t.message){if(t.message.match(/^Error:/)){var n=/^(Error:)\s*([^:]+:\s*)/;t.message=t.message.replace(n,"$1 $2")}if(r){if(!(t.__code__ instanceof Array)){t.__code__=[]}t.__code__.push(r.toString(true))}}if(!(t instanceof IgnoreException)){throw t}}});t.t0=r;t.t1=d;t.t2=c;t.next=18;return l;case 18:t.t3=t.sent;t.t4=(0,t.t1)(t.t2,t.t3);t.t0.push.call(t.t0,t.t4);case 21:i=false;t.next=8;break;case 24:t.next=30;break;case 26:t.prev=26;t.t5=t["catch"](6);a=true;o=t.t5;case 30:t.prev=30;t.prev=31;if(!(i&&u["return"]!=null)){t.next=35;break}t.next=35;return u["return"]();case 35:t.prev=35;if(!a){t.next=38;break}throw o;case 38:return t.finish(35);case 39:return t.finish(30);case 40:return t.abrupt("return",r);case 41:case"end":return t.stop()}},e,null,[[6,26,30,40],[31,,35,39]])})()});function e(e){return t.apply(this,arguments)}return e}()}function balanced(e){var t={"[":"]","(":")"};var r;if(typeof e==="string"){r=tokenize(e)}else{r=e.map(function(e){return e&&e.token?e.token:e})}var n=Object.keys(t);var i=Object.values(t).concat(n);r=r.filter(function(e){return i.includes(e)});var a=new Stack;var o=_createForOfIteratorHelper(r),u;try{for(o.s();!(u=o.n()).done;){var s=u.value;if(n.includes(s)){a.push(s)}else if(!a.is_empty()){var c=a.top();var l=t[c];if(s===l){a.pop()}else{throw new Error("Syntax error: missing closing ".concat(l))}}else{throw new Error("Syntax error: not matched closing ".concat(s))}}}catch(e){o.e(e)}finally{o.f()}return a.is_empty()}function fworker(e){var t="("+e.toString()+")()";var r=window.URL||window.webkitURL;var n;try{n=new Blob([t],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;n=new i;n.append(t);n=n.getBlob()}return new root.Worker(r.createObjectURL(n))}function is_dev(){return lips.version.match(/^(\{\{VER\}\}|DEV)$/)}function get_current_script(){if(is_node()){return}var e;if(document.currentScript){e=document.currentScript}else{var t=document.querySelectorAll("script");if(!t.length){return}e=t[t.length-1]}var r=e.getAttribute("src");return r}var current_script=get_current_script();function bootstrap(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var t="dist/std.xcb";if(e===""){if(current_script){e=current_script.replace(/[^/]*$/,"std.xcb")}else if(is_dev()){e="https://cdn.jsdelivr.net/gh/jcubic/lips@devel/".concat(t)}else{e="https://cdn.jsdelivr.net/npm/@jcubic/lips@".concat(lips.version,"/").concat(t)}}var r=global_env.get("load");return r.call(user_env,e,global_env)}function Worker(e){this.url=e;var o=this.worker=fworker(function(){var o;var u;self.addEventListener("message",function(e){var r=e.data;var t=r.id;if(r.type!=="RPC"||t===null){return}function n(e){self.postMessage({id:t,type:"RPC",result:e})}function i(e){self.postMessage({id:t,type:"RPC",error:e})}if(r.method==="eval"){if(!u){i("Worker RPC: LIPS not initialized, call init first");return}u.then(function(){var e=r.params[0];var t=r.params[1];o.exec(e,{use_dynamic:t}).then(function(e){e=e.map(function(e){return e&&e.valueOf()});n(e)})["catch"](function(e){i(e)})})}else if(r.method==="init"){var a=r.params[0];if(typeof a!=="string"){i("Worker RPC: url is not a string")}else{importScripts("".concat(a,"/dist/lips.min.js"));o=new lips.Interpreter("worker");u=bootstrap(a);u.then(function(){n(true)})}}})});this.rpc=function(){var n=0;return function e(t,r){var a=++n;return new Promise(function(n,i){o.addEventListener("message",function e(t){var r=t.data;if(r&&r.type==="RPC"&&r.id===a){if(r.error){i(r.error)}else{n(r.result)}o.removeEventListener("message",e)}});o.postMessage({type:"RPC",method:t,id:a,params:r})})}}();this.rpc("init",[e])["catch"](function(e){console.error(e)});this.exec=function(e,t){var r=t.use_dynamic,n=r===void 0?false:r;return this.rpc("eval",[e,n])}}var serialization_map={pair:function e(t){var r=_slicedToArray(t,2),n=r[0],i=r[1];return Pair(n,i)},number:function e(t){if(LString.isString(t)){return LNumber([t,10])}return LNumber(t)},regex:function e(t){var r=_slicedToArray(t,2),n=r[0],i=r[1];return new RegExp(n,i)},nil:function e(){return _nil},symbol:function e(t){if(LString.isString(t)){return LSymbol(t)}else if(Array.isArray(t)){return LSymbol(Symbol["for"](t[0]))}},string:LString,character:LCharacter};var available_class=Object.keys(serialization_map);var class_map={};for(var _i6=0,_Object$entries3=Object.entries(available_class);_i6<_Object$entries3.length;_i6++){var _Object$entries3$_i=_slicedToArray(_Object$entries3[_i6],2),i=_Object$entries3$_i[0],cls=_Object$entries3$_i[1];class_map[cls]=+i}function mangle_name(e){return class_map[e]}function resolve_name(e){return available_class[e]}function serialize(e){return JSON.stringify(e,function(e,t){var r=this[e];if(r){if(r instanceof RegExp){return{"@":mangle_name("regex"),"#":[r.source,r.flags]}}var n=mangle_name(r.constructor.__class__);if(!is_undef(n)){return{"@":n,"#":r.serialize()}}}return t})}function unserialize(e){return JSON.parse(e,function(e,t){if(t&&_typeof$1(t)==="object"){if(!is_undef(t["@"])){var r=resolve_name(t["@"]);if(serialization_map[r]){return serialization_map[r](t["#"])}}}return t})}var cbor=function(){var e={pair:Pair,symbol:LSymbol,number:LNumber,string:LString,character:LCharacter,nil:_nil.constructor,regex:RegExp};function t(e,t){return{deserialize:t,Class:e}}var r=new Encoder;var a={};for(var n=0,i=Object.entries(serialization_map);n1){var n=t.reduce(function(e,t){return e+t.length},0);var i=new Uint8Array(n);var a=0;t.forEach(function(e){i.set(e,a);a+=e.length});return i}else if(t.length){return t[0]}}function encode_magic(){var e=1;var t=new TextEncoder("utf-8");return t.encode("LIPS".concat(e.toString().padStart(3," ")))}var MAGIC_LENGTH=7;function decode_magic(e){var t=new TextDecoder("utf-8");var r=t.decode(e.slice(0,MAGIC_LENGTH));var n=r.substring(0,4);if(n==="LIPS"){var i=r.match(/^(....).*([0-9]+)$/);if(i){return{type:i[1],version:Number(i[2])}}}return{type:"unknown"}}function serialize_bin(e){var t=encode_magic();var r=cbor.encode(e);return merge_uint8_array(t,pack_1(r,{magic:false}))}function unserialize_bin(e){var t=decode_magic(e),r=t.type,n=t.version;if(r==="LIPS"&&n===1){var i=unpack_1(e.slice(MAGIC_LENGTH),{magic:false});return cbor.decode(i)}else{throw new Error("Invalid file format ".concat(r))}}function execError(e){console.error(e.message||e);if(Array.isArray(e.code)){console.error(e.code.map(function(e,t){return"[".concat(t+1,"]: ").concat(e)}))}}function init(){var o=["text/x-lips","text/x-scheme"];var u;function s(r){return new Promise(function(t){var e=r.getAttribute("src");if(e){return fetch(e).then(function(e){return e.text()}).then(exec).then(t)["catch"](function(e){execError(e);t()})}else{return exec(r.innerHTML).then(t)["catch"](function(e){execError(e);t()})}})}function e(){return new Promise(function(i){var a=Array.from(document.querySelectorAll("script"));return function e(){var t=a.shift();if(!t){i()}else{var r=t.getAttribute("type");if(o.includes(r)){var n=t.getAttribute("bootstrap");if(!u&&typeof n==="string"){return bootstrap(n).then(function(){return s(t)}).then(e)}else{return s(t).then(e)}}else if(r&&r.match(/lips|lisp/)){console.warn("Expecting "+o.join(" or ")+" found "+r)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var t=currentScript;var r=t.getAttribute("bootstrap");if(typeof r==="string"){return bootstrap(r).then(function(){u=true;return e()})}}return e()}var currentScript=typeof window!=="undefined"&&window.document&&document.currentScript;if(typeof window!=="undefined"){contentLoaded(window,init)}var banner=function(){var e=LString("Wed, 24 Jan 2024 12:31:18 +0000").valueOf();var t=e==="{{"+"DATE}}"?new Date:new Date(e);var r=function e(t){return t.toString().padStart(2,"0")};var n=t.getFullYear();var i=[n,r(t.getMonth()+1),r(t.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(n," Jakub T. Jankiewicz\n\nType (env) to see environment with functions macros and variables. You can also\nuse (help name) to display help for specific function or macro, (apropos name)\nto display list of matched names in environment and (dir object) to list\nproperties of an object.\n").replace(/^.*\n/,"");return a}();read_only(Ahead,"__class__","ahead");read_only(Pair,"__class__","pair");read_only(Nil,"__class__","nil");read_only(Pattern,"__class__","pattern");read_only(Formatter,"__class__","formatter");read_only(Macro,"__class__","macro");read_only(Syntax,"__class__","syntax");read_only(Environment,"__class__","environment");read_only(InputPort,"__class__","input-port");read_only(OutputPort,"__class__","output-port");read_only(BufferedOutputPort,"__class__","output-port");read_only(OutputStringPort,"__class__","output-string-port");read_only(InputStringPort,"__class__","input-string-port");read_only(InputFilePort,"__class__","input-file-port");read_only(OutputFilePort,"__class__","output-file-port");read_only(LipsError,"__class__","lips-error");[LNumber,LComplex,LRational,LFloat,LBigInteger].forEach(function(e){read_only(e,"__class__","number")});read_only(LCharacter,"__class__","character");read_only(LSymbol,"__class__","symbol");read_only(LString,"__class__","string");read_only(QuotedPromise,"__class__","promise");read_only(Parameter,"__class__","parameter");var version="DEV";var date="Wed, 24 Jan 2024 12:31:18 +0000";var parse=compose(uniterate_async,_parse);var lips={version:version,banner:banner,date:date,exec:exec,parse:parse,tokenize:tokenize,evaluate:_evaluate,compile:compile,serialize:serialize,unserialize:unserialize,serialize_bin:serialize_bin,unserialize_bin:unserialize_bin,bootstrap:bootstrap,Environment:Environment,env:user_env,Worker:Worker,Interpreter:Interpreter,balanced_parenthesis:balanced,balancedParenthesis:balanced,balanced:balanced,Macro:Macro,Syntax:Syntax,Pair:Pair,Values:Values,QuotedPromise:QuotedPromise,Error:LipsError,quote:quote,InputPort:InputPort,OutputPort:OutputPort,BufferedOutputPort:BufferedOutputPort,InputFilePort:InputFilePort,OutputFilePort:OutputFilePort,InputStringPort:InputStringPort,OutputStringPort:OutputStringPort,InputByteVectorPort:InputByteVectorPort,OutputByteVectorPort:OutputByteVectorPort,InputBinaryFilePort:InputBinaryFilePort,OutputBinaryFilePort:OutputBinaryFilePort,set_fs:set_fs,Formatter:Formatter,Parser:Parser,Lexer:Lexer,specials:specials,repr:repr,nil:_nil,eof:eof,LSymbol:LSymbol,LNumber:LNumber,LFloat:LFloat,LComplex:LComplex,LRational:LRational,LBigInteger:LBigInteger,LCharacter:LCharacter,LString:LString,Parameter:Parameter,rationalize:rationalize};global_env.set("lips",lips);var empty={};var empty$1=Object.freeze({__proto__:null,default:empty});function normalizeArray(e,t){var r=0;for(var n=e.length-1;n>=0;n--){var i=e[n];if(i==="."){e.splice(n,1)}else if(i===".."){e.splice(n,1);r++}else if(r){e.splice(n,1);r--}}if(t){for(;r--;r){e.unshift("..")}}return e}var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var splitPath=function(e){return splitPathRe.exec(e).slice(1)};function resolve(){var e="",t=false;for(var r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if(typeof n!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!n){continue}e=n+"/"+e;t=n.charAt(0)==="/"}e=normalizeArray(filter(e.split("/"),function(e){return!!e}),!t).join("/");return(t?"/":"")+e||"."}function normalize(e){var t=isAbsolute(e),r=substr(e,-1)==="/";e=normalizeArray(filter(e.split("/"),function(e){return!!e}),!t).join("/");if(!e&&!t){e="."}if(e&&r){e+="/"}return(t?"/":"")+e}function isAbsolute(e){return e.charAt(0)==="/"}function join(){var e=Array.prototype.slice.call(arguments,0);return normalize(filter(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))}function relative(e,t){e=resolve(e).substr(1);t=resolve(t).substr(1);function r(e){var t=0;for(;t=0;r--){if(e[r]!=="")break}if(t>r)return[];return e.slice(t,r-t+1)}var n=r(e.split("/"));var i=r(t.split("/"));var a=Math.min(n.length,i.length);var o=a;for(var u=0;u> 8'); + bindings['...'].symbols[_name3] = null; + return traverse(pattern.cdr.cdr, code); + } else { + log('>> 9'); return false; //bindings['...'].symbols[name] = code; } @@ -9599,11 +9604,11 @@ } else if (pattern.car instanceof Pair) { var names = _toConsumableArray(pattern_names); if (code === _nil) { - log('>> 9'); + log('>> 10'); bindings['...'].lists.push(_nil); return true; } - log('>> 10'); + log('>> 11'); var _node2 = code; while (_node2 instanceof Pair) { if (!traverse(pattern.car, _node2.car, names, true)) { @@ -9619,15 +9624,11 @@ if (LSymbol.is(pattern, ellipsis_symbol)) { throw new Error('syntax: invalid usage of ellipsis'); } - log('>> 11'); + log('>> 12'); var _name4 = pattern.__name__; if (symbols.includes(_name4)) { return true; } - log({ - name: _name4, - ellipsis: ellipsis - }); if (ellipsis) { bindings['...'].symbols[_name4] = bindings['...'].symbols[_name4] || []; bindings['...'].symbols[_name4].push(code); @@ -9637,7 +9638,7 @@ return true; } if (pattern instanceof Pair && code instanceof Pair) { - log('>> 12'); + log('>> 13'); log({ a: 12, code: code && code.toString(), @@ -9654,7 +9655,7 @@ if (!traverse(pattern.car, code.car, pattern_names, ellipsis)) { return false; } - log('>> 12 | 1'); + log('>> 14'); var _name5 = pattern.cdr.valueOf(); if (!(_name5 in bindings.symbols)) { bindings.symbols[_name5] = _nil; @@ -14464,6 +14465,9 @@ expansion: this, define: env }); + log({ + bindings: bindings + }); if (bindings) { /* c8 ignore next 5 */ if (is_debug()) { @@ -17197,10 +17201,10 @@ // ------------------------------------------------------------------------- var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Mon, 22 Jan 2024 12:07:50 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Wed, 24 Jan 2024 12:31:18 +0000' == '{{' + 'DATE}}'; can be removed // but disabling Tree-shaking is adding lot of not used code so we use this // hack instead - var date = LString('Mon, 22 Jan 2024 12:07:50 +0000').valueOf(); + var date = LString('Wed, 24 Jan 2024 12:31:18 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); var _format = function _format(x) { return x.toString().padStart(2, '0'); @@ -17239,7 +17243,7 @@ read_only(Parameter, '__class__', 'parameter'); // ------------------------------------------------------------------------- var version = 'DEV'; - var date = 'Mon, 22 Jan 2024 12:07:50 +0000'; + var date = 'Wed, 24 Jan 2024 12:31:18 +0000'; // unwrap async generator into Promise var parse = compose(uniterate_async, _parse); diff --git a/dist/lips.min.js b/dist/lips.min.js index 2a2668e31..862bb0558 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,15 +31,15 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Mon, 22 Jan 2024 12:07:50 +0000 + * build: Wed, 24 Jan 2024 12:31:18 +0000 */ -(function(e,t){typeof exports==="object"&&typeof module!=="undefined"?t(exports):typeof define==="function"&&define.amd?define(["exports"],t):(e=typeof globalThis!=="undefined"?globalThis:e||self,t(e.lips={}))})(this,function(e){"use strict";var o=typeof document!=="undefined"?document.currentScript:null;function n(e,t){if(t.get){return t.get.call(e)}return t.value}function i(e,t,r){if(!t.has(e)){throw new TypeError("attempted to "+r+" private field on non-instance")}return t.get(e)}function t(e,t){var r=i(e,t,"get");return n(e,r)}function a(e,t,r){if(t.set){t.set.call(e,r)}else{if(!t.writable){throw new TypeError("attempted to set read only private field")}t.value=r}}function N(e,t,r){var n=i(e,t,"set");a(e,n,r);return r}function V(e){V=Object.setPrototypeOf?Object.getPrototypeOf.bind():function e(t){return t.__proto__||Object.getPrototypeOf(t)};return V(e)}function Y(e,t){Y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function e(t,r){t.__proto__=r;return t};return Y(e,t)}function $(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch(e){return typeof t==="function"}}function J(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(J=function e(){return!!t})()}function K(e,t,r){if(J())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&Y(i,r.prototype),i}function r(e){var n=typeof Map==="function"?new Map:undefined;r=function e(t){if(t===null||!$(t))return t;if(typeof t!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof n!=="undefined"){if(n.has(t))return n.get(t);n.set(t,r)}function r(){return K(t,arguments,V(this).constructor)}r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}});return Y(r,t)};return r(e)}function H(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function p(e){"@babel/helpers - typeof";return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function G(e,t){if(t&&(p(t)==="object"||typeof t==="function")){return t}else if(t!==void 0){throw new TypeError("Derived constructors may only return object or undefined")}return H(e)}function W(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});Object.defineProperty(e,"prototype",{writable:false});if(t)Y(e,t)}function Q(e){if(Array.isArray(e))return e}function Z(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function X(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r=0)continue;r[i]=e[i]}return r}function _e(e,t){if(e==null)return{};var r=pe(e,t);var n,i;if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;r[n]=e[n]}}return r}function de(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,u,a,o=[],s=!0,c=!1;try{if(u=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=u.call(r)).done)&&(o.push(n.value),o.length!==t);s=!0);}catch(e){c=!0,i=e}finally{try{if(!s&&null!=r["return"]&&(a=r["return"](),Object(a)!==a))return}finally{if(c)throw i}}return o}}function b(e,t){return Q(e)||de(e,t)||ee(e,t)||te()}function ve(e,t){this.v=e,this.k=t}function ye(e){return new ve(e,0)}function me(a){var u,o;function s(r,e){try{var n=a[r](e),i=n.value,u=i instanceof ve;Promise.resolve(u?i.v:i).then(function(e){if(u){var t="return"===r?"return":"next";if(!i.k||e.done)return s(t,e);e=a[t](e).value}c(n.done?"return":"normal",e)},function(e){s("throw",e)})}catch(e){c("throw",e)}}function c(e,t){switch(e){case"return":u.resolve({value:t,done:!0});break;case"throw":u.reject(t);break;default:u.resolve({value:t,done:!1})}(u=u.next)?s(u.key,u.arg):o=null}this._invoke=function(n,i){return new Promise(function(e,t){var r={key:n,arg:i,resolve:e,reject:t,next:null};o?o=o.next=r:(u=o=r,s(n,i))})},"function"!=typeof a["return"]&&(this["return"]=void 0)}me.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},me.prototype.next=function(e){return this._invoke("next",e)},me.prototype["throw"]=function(e){return this._invoke("throw",e)},me.prototype["return"]=function(e){return this._invoke("return",e)};function ge(e){return function(){return new me(e.apply(this,arguments))}}function be(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}var we={exports:{}};var De={exports:{}};(function(t){function r(e){"@babel/helpers - typeof";return t.exports=r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t.exports.__esModule=true,t.exports["default"]=t.exports,r(e)}t.exports=r,t.exports.__esModule=true,t.exports["default"]=t.exports})(De);var Ee=De.exports;(function(j){var I=Ee["default"];function P(){j.exports=P=function e(){return a},j.exports.__esModule=true,j.exports["default"]=j.exports;var c,a={},e=Object.prototype,f=e.hasOwnProperty,l=Object.defineProperty||function(e,t,r){e[t]=r.value},t="function"==typeof Symbol?Symbol:{},i=t.iterator||"@@iterator",r=t.asyncIterator||"@@asyncIterator",n=t.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(c){u=function e(t,r,n){return t[r]=n}}function o(e,t,r,n){var i=t&&t.prototype instanceof s?t:s,u=Object.create(i.prototype),a=new S(n||[]);return l(u,"_invoke",{value:F(e,r,a)}),u}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}a.wrap=o;var p="suspendedStart",_="suspendedYield",d="executing",v="completed",y={};function s(){}function m(){}function g(){}var b={};u(b,i,function(){return this});var w=Object.getPrototypeOf,D=w&&w(w(B([])));D&&D!==e&&f.call(D,i)&&(b=D);var E=g.prototype=s.prototype=Object.create(b);function A(e){["next","throw","return"].forEach(function(t){u(e,t,function(e){return this._invoke(t,e)})})}function x(o,s){function c(e,t,r,n){var i=h(o[e],o,t);if("throw"!==i.type){var u=i.arg,a=u.value;return a&&"object"==I(a)&&f.call(a,"__await")?s.resolve(a.__await).then(function(e){c("next",e,r,n)},function(e){c("throw",e,r,n)}):s.resolve(a).then(function(e){u.value=e,r(u)},function(e){return c("throw",e,r,n)})}n(i.arg)}var i;l(this,"_invoke",{value:function e(r,n){function t(){return new s(function(e,t){c(r,n,e,t)})}return i=i?i.then(t,t):t()}})}function F(u,a,o){var s=p;return function(e,t){if(s===d)throw new Error("Generator is already running");if(s===v){if("throw"===e)throw t;return{value:c,done:!0}}for(o.method=e,o.arg=t;;){var r=o.delegate;if(r){var n=k(r,o);if(n){if(n===y)continue;return n}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if(s===p)throw s=v,o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);s=d;var i=h(u,a,o);if("normal"===i.type){if(s=o.done?v:_,i.arg===y)continue;return{value:i.arg,done:o.done}}"throw"===i.type&&(s=v,o.method="throw",o.arg=i.arg)}}}function k(e,t){var r=t.method,n=e.iterator[r];if(n===c)return t.delegate=null,"throw"===r&&e.iterator["return"]&&(t.method="return",t.arg=c,k(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var i=h(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,y;var u=i.arg;return u?u.done?(t[e.resultName]=u.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=c),t.delegate=null,y):u:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function B(t){if(t||""===t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r=0;--i){var u=this.tryEntries[i],a=u.completion;if("root"===u.tryLoc)return t("end");if(u.tryLoc<=this.prev){var o=f.call(u,"catchLoc"),s=f.call(u,"finallyLoc");if(o&&s){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&f.call(i,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),y}},catch:function e(t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var u=i.arg;O(n)}return u}}throw new Error("illegal catch attempt")},delegateYield:function e(t,r,n){return this.delegate={iterator:B(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=c),y}},a}j.exports=P,j.exports.__esModule=true,j.exports["default"]=j.exports})(we);var Ae=we.exports;var xe=Ae();var Fe=xe;try{regeneratorRuntime=xe}catch(e){if(typeof globalThis==="object"){globalThis.regeneratorRuntime=xe}else{Function("r","regeneratorRuntime = r")(xe)}}var C=be(Fe);var ke=typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{};var Ce=[];var Oe=[];var Se=typeof Uint8Array!=="undefined"?Uint8Array:Array;var Be=false;function je(){Be=true;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var t=0,r=e.length;t0){throw new Error("Invalid string. Length must be a multiple of 4")}u=e[o-2]==="="?2:e[o-1]==="="?1:0;a=new Se(o*3/4-u);n=u>0?o-4:o;var s=0;for(t=0,r=0;t>16&255;a[s++]=i>>8&255;a[s++]=i&255}if(u===2){i=Oe[e.charCodeAt(t)]<<2|Oe[e.charCodeAt(t+1)]>>4;a[s++]=i&255}else if(u===1){i=Oe[e.charCodeAt(t)]<<10|Oe[e.charCodeAt(t+1)]<<4|Oe[e.charCodeAt(t+2)]>>2;a[s++]=i>>8&255;a[s++]=i&255}return a}function Pe(e){return Ce[e>>18&63]+Ce[e>>12&63]+Ce[e>>6&63]+Ce[e&63]}function Ne(e,t,r){var n;var i=[];for(var u=t;us?s:o+a))}if(n===1){t=e[r-1];i+=Ce[t>>2];i+=Ce[t<<4&63];i+="=="}else if(n===2){t=(e[r-2]<<8)+e[r-1];i+=Ce[t>>10];i+=Ce[t>>4&63];i+=Ce[t<<2&63];i+="="}u.push(i);return u.join("")}function Te(e,t,r,n,i){var u,a;var o=i*8-n-1;var s=(1<>1;var f=-7;var l=r?i-1:0;var h=r?-1:1;var p=e[t+l];l+=h;u=p&(1<<-f)-1;p>>=-f;f+=o;for(;f>0;u=u*256+e[t+l],l+=h,f-=8){}a=u&(1<<-f)-1;u>>=-f;f+=n;for(;f>0;a=a*256+e[t+l],l+=h,f-=8){}if(u===0){u=1-c}else if(u===s){return a?NaN:(p?-1:1)*Infinity}else{a=a+Math.pow(2,n);u=u-c}return(p?-1:1)*a*Math.pow(2,u-n)}function Le(e,t,r,n,i,u){var a,o,s;var c=u*8-i-1;var f=(1<>1;var h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0;var p=n?0:u-1;var _=n?1:-1;var d=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){o=isNaN(t)?1:0;a=f}else{a=Math.floor(Math.log(t)/Math.LN2);if(t*(s=Math.pow(2,-a))<1){a--;s*=2}if(a+l>=1){t+=h/s}else{t+=h*Math.pow(2,1-l)}if(t*s>=2){a++;s/=2}if(a+l>=f){o=0;a=f}else if(a+l>=1){o=(t*s-1)*Math.pow(2,i);a=a+l}else{o=t*Math.pow(2,l-1)*Math.pow(2,i);a=0}}for(;i>=8;e[r+p]=o&255,p+=_,o/=256,i-=8){}a=a<0;e[r+p]=a&255,p+=_,a/=256,c-=8){}e[r+p-_]|=d*128}var Ue={}.toString;var Me=Array.isArray||function(e){return Ue.call(e)=="[object Array]"}; +(function(e,t){typeof exports==="object"&&typeof module!=="undefined"?t(exports):typeof define==="function"&&define.amd?define(["exports"],t):(e=typeof globalThis!=="undefined"?globalThis:e||self,t(e.lips={}))})(this,function(e){"use strict";var o=typeof document!=="undefined"?document.currentScript:null;function n(e,t){if(t.get){return t.get.call(e)}return t.value}function i(e,t,r){if(!t.has(e)){throw new TypeError("attempted to "+r+" private field on non-instance")}return t.get(e)}function t(e,t){var r=i(e,t,"get");return n(e,r)}function a(e,t,r){if(t.set){t.set.call(e,r)}else{if(!t.writable){throw new TypeError("attempted to set read only private field")}t.value=r}}function N(e,t,r){var n=i(e,t,"set");a(e,n,r);return r}function V(e){V=Object.setPrototypeOf?Object.getPrototypeOf.bind():function e(t){return t.__proto__||Object.getPrototypeOf(t)};return V(e)}function Y(e,t){Y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function e(t,r){t.__proto__=r;return t};return Y(e,t)}function $(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch(e){return typeof t==="function"}}function J(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(J=function e(){return!!t})()}function K(e,t,r){if(J())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&Y(i,r.prototype),i}function r(e){var n=typeof Map==="function"?new Map:undefined;r=function e(t){if(t===null||!$(t))return t;if(typeof t!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof n!=="undefined"){if(n.has(t))return n.get(t);n.set(t,r)}function r(){return K(t,arguments,V(this).constructor)}r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}});return Y(r,t)};return r(e)}function H(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function p(e){"@babel/helpers - typeof";return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function W(e,t){if(t&&(p(t)==="object"||typeof t==="function")){return t}else if(t!==void 0){throw new TypeError("Derived constructors may only return object or undefined")}return H(e)}function G(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});Object.defineProperty(e,"prototype",{writable:false});if(t)Y(e,t)}function Q(e){if(Array.isArray(e))return e}function Z(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function X(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r=0)continue;r[i]=e[i]}return r}function _e(e,t){if(e==null)return{};var r=pe(e,t);var n,i;if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;r[n]=e[n]}}return r}function de(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,u,a,o=[],s=!0,c=!1;try{if(u=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=u.call(r)).done)&&(o.push(n.value),o.length!==t);s=!0);}catch(e){c=!0,i=e}finally{try{if(!s&&null!=r["return"]&&(a=r["return"](),Object(a)!==a))return}finally{if(c)throw i}}return o}}function b(e,t){return Q(e)||de(e,t)||ee(e,t)||te()}function ve(e,t){this.v=e,this.k=t}function ye(e){return new ve(e,0)}function me(a){var u,o;function s(r,e){try{var n=a[r](e),i=n.value,u=i instanceof ve;Promise.resolve(u?i.v:i).then(function(e){if(u){var t="return"===r?"return":"next";if(!i.k||e.done)return s(t,e);e=a[t](e).value}c(n.done?"return":"normal",e)},function(e){s("throw",e)})}catch(e){c("throw",e)}}function c(e,t){switch(e){case"return":u.resolve({value:t,done:!0});break;case"throw":u.reject(t);break;default:u.resolve({value:t,done:!1})}(u=u.next)?s(u.key,u.arg):o=null}this._invoke=function(n,i){return new Promise(function(e,t){var r={key:n,arg:i,resolve:e,reject:t,next:null};o?o=o.next=r:(u=o=r,s(n,i))})},"function"!=typeof a["return"]&&(this["return"]=void 0)}me.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},me.prototype.next=function(e){return this._invoke("next",e)},me.prototype["throw"]=function(e){return this._invoke("throw",e)},me.prototype["return"]=function(e){return this._invoke("return",e)};function ge(e){return function(){return new me(e.apply(this,arguments))}}function be(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}var we={exports:{}};var De={exports:{}};(function(t){function r(e){"@babel/helpers - typeof";return t.exports=r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t.exports.__esModule=true,t.exports["default"]=t.exports,r(e)}t.exports=r,t.exports.__esModule=true,t.exports["default"]=t.exports})(De);var Ee=De.exports;(function(j){var I=Ee["default"];function P(){j.exports=P=function e(){return a},j.exports.__esModule=true,j.exports["default"]=j.exports;var c,a={},e=Object.prototype,f=e.hasOwnProperty,l=Object.defineProperty||function(e,t,r){e[t]=r.value},t="function"==typeof Symbol?Symbol:{},i=t.iterator||"@@iterator",r=t.asyncIterator||"@@asyncIterator",n=t.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(c){u=function e(t,r,n){return t[r]=n}}function o(e,t,r,n){var i=t&&t.prototype instanceof s?t:s,u=Object.create(i.prototype),a=new S(n||[]);return l(u,"_invoke",{value:F(e,r,a)}),u}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}a.wrap=o;var p="suspendedStart",_="suspendedYield",d="executing",v="completed",y={};function s(){}function m(){}function g(){}var b={};u(b,i,function(){return this});var w=Object.getPrototypeOf,D=w&&w(w(B([])));D&&D!==e&&f.call(D,i)&&(b=D);var E=g.prototype=s.prototype=Object.create(b);function A(e){["next","throw","return"].forEach(function(t){u(e,t,function(e){return this._invoke(t,e)})})}function x(o,s){function c(e,t,r,n){var i=h(o[e],o,t);if("throw"!==i.type){var u=i.arg,a=u.value;return a&&"object"==I(a)&&f.call(a,"__await")?s.resolve(a.__await).then(function(e){c("next",e,r,n)},function(e){c("throw",e,r,n)}):s.resolve(a).then(function(e){u.value=e,r(u)},function(e){return c("throw",e,r,n)})}n(i.arg)}var i;l(this,"_invoke",{value:function e(r,n){function t(){return new s(function(e,t){c(r,n,e,t)})}return i=i?i.then(t,t):t()}})}function F(u,a,o){var s=p;return function(e,t){if(s===d)throw new Error("Generator is already running");if(s===v){if("throw"===e)throw t;return{value:c,done:!0}}for(o.method=e,o.arg=t;;){var r=o.delegate;if(r){var n=k(r,o);if(n){if(n===y)continue;return n}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if(s===p)throw s=v,o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);s=d;var i=h(u,a,o);if("normal"===i.type){if(s=o.done?v:_,i.arg===y)continue;return{value:i.arg,done:o.done}}"throw"===i.type&&(s=v,o.method="throw",o.arg=i.arg)}}}function k(e,t){var r=t.method,n=e.iterator[r];if(n===c)return t.delegate=null,"throw"===r&&e.iterator["return"]&&(t.method="return",t.arg=c,k(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var i=h(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,y;var u=i.arg;return u?u.done?(t[e.resultName]=u.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=c),t.delegate=null,y):u:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function B(t){if(t||""===t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r=0;--i){var u=this.tryEntries[i],a=u.completion;if("root"===u.tryLoc)return t("end");if(u.tryLoc<=this.prev){var o=f.call(u,"catchLoc"),s=f.call(u,"finallyLoc");if(o&&s){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&f.call(i,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),y}},catch:function e(t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var u=i.arg;O(n)}return u}}throw new Error("illegal catch attempt")},delegateYield:function e(t,r,n){return this.delegate={iterator:B(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=c),y}},a}j.exports=P,j.exports.__esModule=true,j.exports["default"]=j.exports})(we);var Ae=we.exports;var xe=Ae();var Fe=xe;try{regeneratorRuntime=xe}catch(e){if(typeof globalThis==="object"){globalThis.regeneratorRuntime=xe}else{Function("r","regeneratorRuntime = r")(xe)}}var C=be(Fe);var ke=typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{};var Ce=[];var Oe=[];var Se=typeof Uint8Array!=="undefined"?Uint8Array:Array;var Be=false;function je(){Be=true;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var t=0,r=e.length;t0){throw new Error("Invalid string. Length must be a multiple of 4")}u=e[o-2]==="="?2:e[o-1]==="="?1:0;a=new Se(o*3/4-u);n=u>0?o-4:o;var s=0;for(t=0,r=0;t>16&255;a[s++]=i>>8&255;a[s++]=i&255}if(u===2){i=Oe[e.charCodeAt(t)]<<2|Oe[e.charCodeAt(t+1)]>>4;a[s++]=i&255}else if(u===1){i=Oe[e.charCodeAt(t)]<<10|Oe[e.charCodeAt(t+1)]<<4|Oe[e.charCodeAt(t+2)]>>2;a[s++]=i>>8&255;a[s++]=i&255}return a}function Pe(e){return Ce[e>>18&63]+Ce[e>>12&63]+Ce[e>>6&63]+Ce[e&63]}function Ne(e,t,r){var n;var i=[];for(var u=t;us?s:o+a))}if(n===1){t=e[r-1];i+=Ce[t>>2];i+=Ce[t<<4&63];i+="=="}else if(n===2){t=(e[r-2]<<8)+e[r-1];i+=Ce[t>>10];i+=Ce[t>>4&63];i+=Ce[t<<2&63];i+="="}u.push(i);return u.join("")}function Te(e,t,r,n,i){var u,a;var o=i*8-n-1;var s=(1<>1;var f=-7;var l=r?i-1:0;var h=r?-1:1;var p=e[t+l];l+=h;u=p&(1<<-f)-1;p>>=-f;f+=o;for(;f>0;u=u*256+e[t+l],l+=h,f-=8){}a=u&(1<<-f)-1;u>>=-f;f+=n;for(;f>0;a=a*256+e[t+l],l+=h,f-=8){}if(u===0){u=1-c}else if(u===s){return a?NaN:(p?-1:1)*Infinity}else{a=a+Math.pow(2,n);u=u-c}return(p?-1:1)*a*Math.pow(2,u-n)}function Le(e,t,r,n,i,u){var a,o,s;var c=u*8-i-1;var f=(1<>1;var h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0;var p=n?0:u-1;var _=n?1:-1;var d=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){o=isNaN(t)?1:0;a=f}else{a=Math.floor(Math.log(t)/Math.LN2);if(t*(s=Math.pow(2,-a))<1){a--;s*=2}if(a+l>=1){t+=h/s}else{t+=h*Math.pow(2,1-l)}if(t*s>=2){a++;s/=2}if(a+l>=f){o=0;a=f}else if(a+l>=1){o=(t*s-1)*Math.pow(2,i);a=a+l}else{o=t*Math.pow(2,l-1)*Math.pow(2,i);a=0}}for(;i>=8;e[r+p]=o&255,p+=_,o/=256,i-=8){}a=a<0;e[r+p]=a&255,p+=_,a/=256,c-=8){}e[r+p-_]|=d*128}var Ue={}.toString;var Me=Array.isArray||function(e){return Ue.call(e)=="[object Array]"}; /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT - */var qe=50;c.TYPED_ARRAY_SUPPORT=ke.TYPED_ARRAY_SUPPORT!==undefined?ke.TYPED_ARRAY_SUPPORT:true;ze();function ze(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ve(e,t){if(ze()=ze()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+ze().toString(16)+" bytes")}return e|0}c.isBuffer=Rt;function Xe(e){return!!(e!=null&&e._isBuffer)}c.compare=function e(t,r){if(!Xe(t)||!Xe(r)){throw new TypeError("Arguments must be Buffers")}if(t===r)return 0;var n=t.length;var i=r.length;for(var u=0,a=Math.min(n,i);u>>1;case"base64":return It(e).length;default:if(n)return St(e).length;t=(""+t).toLowerCase();n=true}}}c.byteLength=et;function tt(e,t,r){var n=false;if(t===undefined||t<0){t=0}if(t>this.length){return""}if(r===undefined||r>this.length){r=this.length}if(r<=0){return""}r>>>=0;t>>>=0;if(r<=t){return""}if(!e)e="utf8";while(true){switch(e){case"hex":return yt(this,t,r);case"utf8":case"utf-8":return ht(this,t,r);case"ascii":return dt(this,t,r);case"latin1":case"binary":return vt(this,t,r);case"base64":return lt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}}c.prototype._isBuffer=true;function rt(e,t,r){var n=e[t];e[t]=e[r];e[r]=n}c.prototype.swap16=function e(){var t=this.length;if(t%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var r=0;r0){t=this.toString("hex",0,r).match(/.{2}/g).join(" ");if(this.length>r)t+=" ... "}return""};c.prototype.compare=function e(t,r,n,i,u){if(!Xe(t)){throw new TypeError("Argument must be a Buffer")}if(r===undefined){r=0}if(n===undefined){n=t?t.length:0}if(i===undefined){i=0}if(u===undefined){u=this.length}if(r<0||n>t.length||i<0||u>this.length){throw new RangeError("out of range index")}if(i>=u&&r>=n){return 0}if(i>=u){return-1}if(r>=n){return 1}r>>>=0;n>>>=0;i>>>=0;u>>>=0;if(this===t)return 0;var a=u-i;var o=n-r;var s=Math.min(a,o);var c=this.slice(i,u);var f=t.slice(r,n);for(var l=0;l2147483647){r=2147483647}else if(r<-2147483648){r=-2147483648}r=+r;if(isNaN(r)){r=i?0:e.length-1}if(r<0)r=e.length+r;if(r>=e.length){if(i)return-1;else r=e.length-1}else if(r<0){if(i)r=0;else return-1}if(typeof t==="string"){t=c.from(t,n)}if(Xe(t)){if(t.length===0){return-1}return it(e,t,r,n,i)}else if(typeof t==="number"){t=t&255;if(c.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(i){return Uint8Array.prototype.indexOf.call(e,t,r)}else{return Uint8Array.prototype.lastIndexOf.call(e,t,r)}}return it(e,[t],r,n,i)}throw new TypeError("val must be string, number or Buffer")}function it(e,t,r,n,i){var u=1;var a=e.length;var o=t.length;if(n!==undefined){n=String(n).toLowerCase();if(n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le"){if(e.length<2||t.length<2){return-1}u=2;a/=2;o/=2;r/=2}}function s(e,t){if(u===1){return e[t]}else{return e.readUInt16BE(t*u)}}var c;if(i){var f=-1;for(c=r;ca)r=a-o;for(c=r;c>=0;c--){var l=true;for(var h=0;hi){n=i}}var u=t.length;if(u%2!==0)throw new TypeError("Invalid hex string");if(n>u/2){n=u/2}for(var a=0;au)n=u;if(t.length>0&&(n<0||r<0)||r>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!i)i="utf8";var a=false;for(;;){switch(i){case"hex":return ut(this,t,r,n);case"utf8":case"utf-8":return at(this,t,r,n);case"ascii":return ot(this,t,r,n);case"latin1":case"binary":return st(this,t,r,n);case"base64":return ct(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ft(this,t,r,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase();a=true}}};c.prototype.toJSON=function e(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function lt(e,t,r){if(t===0&&r===e.length){return Re(e)}else{return Re(e.slice(t,r))}}function ht(e,t,r){r=Math.min(e.length,r);var n=[];var i=t;while(i239?4:u>223?3:u>191?2:1;if(i+o<=r){var s,c,f,l;switch(o){case 1:if(u<128){a=u}break;case 2:s=e[i+1];if((s&192)===128){l=(u&31)<<6|s&63;if(l>127){a=l}}break;case 3:s=e[i+1];c=e[i+2];if((s&192)===128&&(c&192)===128){l=(u&15)<<12|(s&63)<<6|c&63;if(l>2047&&(l<55296||l>57343)){a=l}}break;case 4:s=e[i+1];c=e[i+2];f=e[i+3];if((s&192)===128&&(c&192)===128&&(f&192)===128){l=(u&15)<<18|(s&63)<<12|(c&63)<<6|f&63;if(l>65535&&l<1114112){a=l}}}}if(a===null){a=65533;o=1}else if(a>65535){a-=65536;n.push(a>>>10&1023|55296);a=56320|a&1023}n.push(a);i+=o}return _t(n)}var pt=4096;function _t(e){var t=e.length;if(t<=pt){return String.fromCharCode.apply(String,e)}var r="";var n=0;while(nn)r=n;var i="";for(var u=t;un){t=n}if(r<0){r+=n;if(r<0)r=0}else if(r>n){r=n}if(rr)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)gt(t,r,this.length);var i=this[t];var u=1;var a=0;while(++a0&&(u*=256)){i+=this[t+--r]*u}return i};c.prototype.readUInt8=function e(t,r){if(!r)gt(t,1,this.length);return this[t]};c.prototype.readUInt16LE=function e(t,r){if(!r)gt(t,2,this.length);return this[t]|this[t+1]<<8};c.prototype.readUInt16BE=function e(t,r){if(!r)gt(t,2,this.length);return this[t]<<8|this[t+1]};c.prototype.readUInt32LE=function e(t,r){if(!r)gt(t,4,this.length);return(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};c.prototype.readUInt32BE=function e(t,r){if(!r)gt(t,4,this.length);return this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};c.prototype.readIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)gt(t,r,this.length);var i=this[t];var u=1;var a=0;while(++a=u)i-=Math.pow(2,8*r);return i};c.prototype.readIntBE=function e(t,r,n){t=t|0;r=r|0;if(!n)gt(t,r,this.length);var i=r;var u=1;var a=this[t+--i];while(i>0&&(u*=256)){a+=this[t+--i]*u}u*=128;if(a>=u)a-=Math.pow(2,8*r);return a};c.prototype.readInt8=function e(t,r){if(!r)gt(t,1,this.length);if(!(this[t]&128))return this[t];return(255-this[t]+1)*-1};c.prototype.readInt16LE=function e(t,r){if(!r)gt(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};c.prototype.readInt16BE=function e(t,r){if(!r)gt(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};c.prototype.readInt32LE=function e(t,r){if(!r)gt(t,4,this.length);return this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};c.prototype.readInt32BE=function e(t,r){if(!r)gt(t,4,this.length);return this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};c.prototype.readFloatLE=function e(t,r){if(!r)gt(t,4,this.length);return Te(this,t,true,23,4)};c.prototype.readFloatBE=function e(t,r){if(!r)gt(t,4,this.length);return Te(this,t,false,23,4)};c.prototype.readDoubleLE=function e(t,r){if(!r)gt(t,8,this.length);return Te(this,t,true,52,8)};c.prototype.readDoubleBE=function e(t,r){if(!r)gt(t,8,this.length);return Te(this,t,false,52,8)};function bt(e,t,r,n,i,u){if(!Xe(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}c.prototype.writeUIntLE=function e(t,r,n,i){t=+t;r=r|0;n=n|0;if(!i){var u=Math.pow(2,8*n)-1;bt(this,t,r,n,u,0)}var a=1;var o=0;this[r]=t&255;while(++o=0&&(o*=256)){this[r+a]=t/o&255}return r+n};c.prototype.writeUInt8=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,1,255,0);if(!c.TYPED_ARRAY_SUPPORT)t=Math.floor(t);this[r]=t&255;return r+1};function wt(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,u=Math.min(e.length-r,2);i>>(n?i:1-i)*8}}c.prototype.writeUInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,2,65535,0);if(c.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{wt(this,t,r,true)}return r+2};c.prototype.writeUInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,2,65535,0);if(c.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{wt(this,t,r,false)}return r+2};function Dt(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,u=Math.min(e.length-r,4);i>>(n?i:3-i)*8&255}}c.prototype.writeUInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,4,4294967295,0);if(c.TYPED_ARRAY_SUPPORT){this[r+3]=t>>>24;this[r+2]=t>>>16;this[r+1]=t>>>8;this[r]=t&255}else{Dt(this,t,r,true)}return r+4};c.prototype.writeUInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,4,4294967295,0);if(c.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{Dt(this,t,r,false)}return r+4};c.prototype.writeIntLE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var u=Math.pow(2,8*n-1);bt(this,t,r,n,u-1,-u)}var a=0;var o=1;var s=0;this[r]=t&255;while(++a>0)-s&255}return r+n};c.prototype.writeIntBE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var u=Math.pow(2,8*n-1);bt(this,t,r,n,u-1,-u)}var a=n-1;var o=1;var s=0;this[r+a]=t&255;while(--a>=0&&(o*=256)){if(t<0&&s===0&&this[r+a+1]!==0){s=1}this[r+a]=(t/o>>0)-s&255}return r+n};c.prototype.writeInt8=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,1,127,-128);if(!c.TYPED_ARRAY_SUPPORT)t=Math.floor(t);if(t<0)t=255+t+1;this[r]=t&255;return r+1};c.prototype.writeInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,2,32767,-32768);if(c.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{wt(this,t,r,true)}return r+2};c.prototype.writeInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,2,32767,-32768);if(c.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{wt(this,t,r,false)}return r+2};c.prototype.writeInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,4,2147483647,-2147483648);if(c.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8;this[r+2]=t>>>16;this[r+3]=t>>>24}else{Dt(this,t,r,true)}return r+4};c.prototype.writeInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,4,2147483647,-2147483648);if(t<0)t=4294967295+t+1;if(c.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{Dt(this,t,r,false)}return r+4};function Et(e,t,r,n,i,u){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function At(e,t,r,n,i){if(!i){Et(e,t,r,4)}Le(e,t,r,n,23,4);return r+4}c.prototype.writeFloatLE=function e(t,r,n){return At(this,t,r,true,n)};c.prototype.writeFloatBE=function e(t,r,n){return At(this,t,r,false,n)};function xt(e,t,r,n,i){if(!i){Et(e,t,r,8)}Le(e,t,r,n,52,8);return r+8}c.prototype.writeDoubleLE=function e(t,r,n){return xt(this,t,r,true,n)};c.prototype.writeDoubleBE=function e(t,r,n){return xt(this,t,r,false,n)};c.prototype.copy=function e(t,r,n,i){if(!n)n=0;if(!i&&i!==0)i=this.length;if(r>=t.length)r=t.length;if(!r)r=0;if(i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");if(i>this.length)i=this.length;if(t.length-r=0;--a){t[a+r]=this[a+n]}}else if(u<1e3||!c.TYPED_ARRAY_SUPPORT){for(a=0;a>>0;n=n===undefined?this.length:n>>>0;if(!t)t=0;var a;if(typeof t==="number"){for(a=r;a55295&&r<57344){if(!i){if(r>56319){if((t-=3)>-1)u.push(239,191,189);continue}else if(a+1===n){if((t-=3)>-1)u.push(239,191,189);continue}i=r;continue}if(r<56320){if((t-=3)>-1)u.push(239,191,189);i=r;continue}r=(i-55296<<10|r-56320)+65536}else if(i){if((t-=3)>-1)u.push(239,191,189)}i=null;if(r<128){if((t-=1)<0)break;u.push(r)}else if(r<2048){if((t-=2)<0)break;u.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;u.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;u.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return u}function Bt(e){var t=[];for(var r=0;r>8;i=r%256;u.push(i);u.push(n)}return u}function It(e){return Ie(kt(e))}function Pt(e,t,r,n){for(var i=0;i=t.length||i>=e.length)break;t[i+r]=e[i]}return i}function Nt(e){return e!==e}function Rt(e){return e!=null&&(!!e._isBuffer||Tt(e)||Lt(e))}function Tt(e){return!!e.constructor&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function Lt(e){return typeof e.readFloatLE==="function"&&typeof e.slice==="function"&&Tt(e.slice(0,0))}let Ut;try{Ut=new TextDecoder}catch(e){}let v;let Mt;let y=0;const qt=105;const zt=57342;const Vt=57343;const Yt=57337;const $t=6;const Jt={};let _={};let Kt;let Ht;let Gt=0;let Wt=0;let Qt;let Zt;let Xt=[];let er=[];let tr;let rr;let nr;let ir={useRecords:false,mapsAsObjects:true};let ur=false;let ar=2;try{new Function("")}catch(e){ar=Infinity}class or{constructor(r){if(r){if((r.keyMap||r._keyMap)&&!r.useRecords){r.useRecords=false;r.mapsAsObjects=true}if(r.useRecords===false&&r.mapsAsObjects===undefined)r.mapsAsObjects=true;if(r.getStructures)r.getShared=r.getStructures;if(r.getShared&&!r.structures)(r.structures=[]).uninitialized=true;if(r.keyMap){this.mapKey=new Map;for(let[e,t]of Object.entries(r.keyMap))this.mapKey.set(t,e)}}Object.assign(this,r)}decodeKey(e){return this.keyMap?this.mapKey.get(e)||e:e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(r){if(!this._keyMap)return r;let n=new Map;for(let[e,t]of Object.entries(r))n.set(this._keyMap.hasOwnProperty(e)?this._keyMap[e]:e,t);return n}decodeKeys(e){if(!this._keyMap||e.constructor.name!="Map")return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let r={};e.forEach((e,t)=>r[lr(this._mapKey.has(t)?this._mapKey.get(t):t)]=e);return r}mapDecode(e,t){let r=this.decode(e);if(this._keyMap){switch(r.constructor.name){case"Array":return r.map(e=>this.decodeKeys(e))}}return r}decode(t,e){if(v){return Nr(()=>{Rr();return this?this.decode(t,e):or.prototype.decode.call(ir,t,e)})}Mt=e>-1?e:t.length;y=0;Wt=0;Ht=null;Qt=null;v=t;try{rr=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(e){v=null;if(t instanceof Uint8Array)throw e;throw new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof or){_=this;tr=this.sharedValues&&(this.pack?new Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues);if(this.structures){Kt=this.structures;return sr()}else if(!Kt||Kt.length>0){Kt=[]}}else{_=ir;if(!Kt||Kt.length>0)Kt=[];tr=null}return sr()}decodeMultiple(r,n){let i,u=0;try{let e=r.length;ur=true;let t=this?this.decode(r,e):Ur.decode(r,e);if(n){if(n(t)===false){return}while(y=Qt.postBundlePosition){let e=new Error("Unexpected bundle position");e.incomplete=true;throw e}y=Qt.postBundlePosition;Qt=null}if(y==Mt){Kt=null;v=null;if(Zt)Zt=null}else if(y>Mt){let e=new Error("Unexpected end of CBOR data");e.incomplete=true;throw e}else if(!ur){throw new Error("Data read, but end of buffer not reached")}return e}catch(e){Rr();if(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")){e.incomplete=true}throw e}}function u(){let n=v[y++];let i=n>>5;n=n&31;if(n>23){switch(n){case 24:n=v[y++];break;case 25:if(i==7){return br()}n=rr.getUint16(y);y+=2;break;case 26:if(i==7){let t=rr.getFloat32(y);if(_.useFloat32>2){let e=Lr[(v[y]&127)<<1|v[y+1]>>7];y+=4;return(e*t+(t>0?.5:-.5)>>0)/e}y+=4;return t}n=rr.getUint32(y);y+=4;break;case 27:if(i==7){let e=rr.getFloat64(y);y+=8;return e}if(i>1){if(rr.getUint32(y)>0)throw new Error("JavaScript does not support arrays, maps, or strings with length over 4294967295");n=rr.getUint32(y+4)}else if(_.int64AsNumber){n=rr.getUint32(y)*4294967296;n+=rr.getUint32(y+4)}else n=rr.getBigUint64(y);y+=8;break;case 31:switch(i){case 2:case 3:throw new Error("Indefinite length not supported for byte or text strings");case 4:let e=[];let t,r=0;while((t=u())!=Jt){e[r++]=t}return i==4?e:i==3?e.join(""):c.concat(e);case 5:let n;if(_.mapsAsObjects){let e={};if(_.keyMap)while((n=u())!=Jt)e[lr(_.decodeKey(n))]=u();else while((n=u())!=Jt)e[lr(n)]=u();return e}else{if(nr){_.mapsAsObjects=true;nr=false}let e=new Map;if(_.keyMap)while((n=u())!=Jt)e.set(_.decodeKey(n),u());else while((n=u())!=Jt)e.set(n,u());return e}case 7:return Jt;default:throw new Error("Invalid major type for indefinite length "+i)}default:throw new Error("Unknown token "+n)}}switch(i){case 0:return n;case 1:return~n;case 2:return yr(n);case 3:if(Wt>=y){return Ht.slice(y-Gt,(y+=n)-Gt)}if(Wt==0&&Mt<140&&n<32){let e=n<16?vr(n):dr(n);if(e!=null)return e}return hr(n);case 4:let t=new Array(n);for(let e=0;e=Yt){let e=Kt[n&8191];if(e){if(!e.read)e.read=fr(e);return e.read()}if(n<65536){if(n==Vt){let e=Ir();let t=u();let r=u();Dr(t,r);let n={};if(_.keyMap)for(let t=2;t23){switch(t){case 24:t=v[y++];break;case 25:t=rr.getUint16(y);y+=2;break;case 26:t=rr.getUint32(y);y+=4;break;default:throw new Error("Expected array header, but got "+v[y-1])}}let r=this.compiledReader;while(r){if(r.propertyCount===t)return r(u);r=r.next}if(this.slowReads++>=ar){let e=this.length==t?this:this.slice(0,t);r=_.keyMap?new Function("r","return {"+e.map(e=>_.decodeKey(e)).map(e=>cr.test(e)?lr(e)+":r()":"["+JSON.stringify(e)+"]:r()").join(",")+"}"):new Function("r","return {"+e.map(e=>cr.test(e)?lr(e)+":r()":"["+JSON.stringify(e)+"]:r()").join(",")+"}");if(this.compiledReader)r.next=this.compiledReader;r.propertyCount=t;this.compiledReader=r;return r(u)}let n={};if(_.keyMap)for(let e=0;e64&&Ut)return Ut.decode(v.subarray(y,y+=e));const r=y+e;const n=[];t="";while(y65535){e-=65536;n.push(e>>>10&1023|55296);e=56320|e&1023}n.push(e)}else{n.push(i)}if(n.length>=4096){t+=_r.apply(String,n);n.length=0}}if(n.length>0){t+=_r.apply(String,n)}return t}let _r=String.fromCharCode;function dr(t){let r=y;let n=new Array(t);for(let e=0;e0){y=r;return}n[e]=i}return _r.apply(String,n)}function vr(d){if(d<4){if(d<2){if(d===0)return"";else{let e=v[y++];if((e&128)>1){y-=1;return}return _r(e)}}else{let e=v[y++];let t=v[y++];if((e&128)>0||(t&128)>0){y-=2;return}if(d<3)return _r(e,t);let r=v[y++];if((r&128)>0){y-=3;return}return _r(e,t,r)}}else{let l=v[y++];let h=v[y++];let p=v[y++];let _=v[y++];if((l&128)>0||(h&128)>0||(p&128)>0||(_&128)>0){y-=4;return}if(d<6){if(d===4)return _r(l,h,p,_);else{let e=v[y++];if((e&128)>0){y-=5;return}return _r(l,h,p,_,e)}}else if(d<8){let e=v[y++];let t=v[y++];if((e&128)>0||(t&128)>0){y-=6;return}if(d<7)return _r(l,h,p,_,e,t);let r=v[y++];if((r&128)>0){y-=7;return}return _r(l,h,p,_,e,t,r)}else{let o=v[y++];let s=v[y++];let c=v[y++];let f=v[y++];if((o&128)>0||(s&128)>0||(c&128)>0||(f&128)>0){y-=8;return}if(d<10){if(d===8)return _r(l,h,p,_,o,s,c,f);else{let e=v[y++];if((e&128)>0){y-=9;return}return _r(l,h,p,_,o,s,c,f,e)}}else if(d<12){let e=v[y++];let t=v[y++];if((e&128)>0||(t&128)>0){y-=10;return}if(d<11)return _r(l,h,p,_,o,s,c,f,e,t);let r=v[y++];if((r&128)>0){y-=11;return}return _r(l,h,p,_,o,s,c,f,e,t,r)}else{let n=v[y++];let i=v[y++];let u=v[y++];let a=v[y++];if((n&128)>0||(i&128)>0||(u&128)>0||(a&128)>0){y-=12;return}if(d<14){if(d===12)return _r(l,h,p,_,o,s,c,f,n,i,u,a);else{let e=v[y++];if((e&128)>0){y-=13;return}return _r(l,h,p,_,o,s,c,f,n,i,u,a,e)}}else{let e=v[y++];let t=v[y++];if((e&128)>0||(t&128)>0){y-=14;return}if(d<15)return _r(l,h,p,_,o,s,c,f,n,i,u,a,e,t);let r=v[y++];if((r&128)>0){y-=15;return}return _r(l,h,p,_,o,s,c,f,n,i,u,a,e,t,r)}}}}}function yr(e){return _.copyBuffers?Uint8Array.prototype.slice.call(v,y,y+=e):v.subarray(y,y+=e)}let mr=new Float32Array(1);let gr=new Uint8Array(mr.buffer,0,4);function br(){let t=v[y++];let r=v[y++];let e=(t&127)>>2;if(e===31){if(r||t&3)return NaN;return t&128?-Infinity:Infinity}if(e===0){let e=((t&3)<<8|r)/(1<<24);return t&128?-e:e}gr[3]=t&128|(e>>1)+56;gr[2]=(t&7)<<5|r>>3;gr[1]=r<<5;gr[0]=0;return mr[0]}new Array(4096);class wr{constructor(e,t){this.value=e;this.tag=t}}Xt[0]=e=>{return new Date(e)};Xt[1]=e=>{return new Date(Math.round(e*1e3))};Xt[2]=r=>{let n=BigInt(0);for(let e=0,t=r.byteLength;e{return BigInt(-1)-Xt[2](e)};Xt[4]=e=>{return+(e[1]+"e"+e[0])};Xt[5]=e=>{return e[1]*Math.exp(e[0]*Math.log(2))};const Dr=(e,t)=>{e=e-57344;let r=Kt[e];if(r&&r.isShared){(Kt.restoreStructures||(Kt.restoreStructures=[]))[e]=r}Kt[e]=t;t.read=fr(t)};Xt[qt]=r=>{let e=r.length;let n=r[1];Dr(r[0],n);let i={};for(let t=2;t{if(Qt)return Qt[0].slice(Qt.position0,Qt.position0+=e);return new wr(e,14)};Xt[15]=e=>{if(Qt)return Qt[1].slice(Qt.position1,Qt.position1+=e);return new wr(e,15)};let Er={Error:Error,RegExp:RegExp};Xt[27]=e=>{return(Er[e[0]]||Error)(e[1],e[2])};const Ar=e=>{if(v[y++]!=132){let e=new Error("Packed values structure must be followed by a 4 element array");if(v.length{if(!tr){if(_.getShared)Pr();else return new wr(e,$t)}if(typeof e=="number")return tr[16+(e>=0?2*e:-2*e-1)];let t=new Error("No support for non-integer packed references yet");if(e===undefined)t.incomplete=true;throw t};Xt[28]=e=>{if(!Zt){Zt=new Map;Zt.id=0}let t=Zt.id++;let r=v[y];let n;if(r>>5==4)n=[];else n={};let i={target:n};Zt.set(t,i);let u=e();if(i.used)return Object.assign(n,u);i.target=u;return u};Xt[28].handlesRead=true;Xt[29]=e=>{let t=Zt.get(e);t.used=true;return t.target};Xt[258]=e=>new Set(e);(Xt[259]=e=>{if(_.mapsAsObjects){_.mapsAsObjects=false;nr=true}return e()}).handlesRead=true;function xr(e,t){if(typeof e==="string")return e+t;if(e instanceof Array)return e.concat(t);return Object.assign({},e,t)}function Fr(){if(!tr){if(_.getShared)Pr();else throw new Error("No packed values available")}return tr}const kr=1399353956;er.push((e,t)=>{if(e>=225&&e<=255)return xr(Fr().prefixes[e-224],t);if(e>=28704&&e<=32767)return xr(Fr().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return xr(Fr().prefixes[e-1879048192],t);if(e>=216&&e<=223)return xr(t,Fr().suffixes[e-216]);if(e>=27647&&e<=28671)return xr(t,Fr().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return xr(t,Fr().suffixes[e-1811939328]);if(e==kr){return{packedValues:tr,structures:Kt.slice(0),version:t}}if(e==55799)return t});const Cr=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;const Or=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array=="undefined"?{name:"BigUint64Array"}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array=="undefined"?{name:"BigInt64Array"}:BigInt64Array,Float32Array,Float64Array];const Sr=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e{if(!o)throw new Error("Could not find typed array for code "+s);if(!_.copyBuffers){if(t===1||t===2&&!(e.byteOffset&1)||t===4&&!(e.byteOffset&3)||t===8&&!(e.byteOffset&7))return new o(e.buffer,e.byteOffset,e.byteLength)}return new o(Uint8Array.prototype.slice.call(e,0).buffer)}:e=>{if(!o)throw new Error("Could not find typed array for code "+s);let t=new DataView(e.buffer,e.byteOffset,e.byteLength);let r=e.length>>u;let n=new o(r);let i=t[c];for(let e=0;e23){switch(e){case 24:e=v[y++];break;case 25:e=rr.getUint16(y);y+=2;break;case 26:e=rr.getUint32(y);y+=4;break}}return e}function Pr(){if(_.getShared){let e=Nr(()=>{v=null;return _.getShared()})||{};let t=e.structures||[];_.sharedVersion=e.version;tr=_.sharedValues=e.packedValues;if(Kt===true)_.structures=Kt=t;else Kt.splice.apply(Kt,[0,t.length].concat(t))}}function Nr(e){let t=Mt;let r=y;let n=Gt;let i=Wt;let u=Ht;let a=Zt;let o=Qt;let s=new Uint8Array(v.slice(0,Mt));let c=Kt;let f=_;let l=ur;let h=e();Mt=t;y=r;Gt=n;Wt=i;Ht=u;Zt=a;Qt=o;v=s;ur=l;Kt=c;_=f;rr=new DataView(v.buffer,v.byteOffset,v.byteLength);return h}function Rr(){v=null;Zt=null;Kt=null}function Tr(e){Xt[e.tag]=e.decode}const Lr=new Array(147);for(let e=0;e<256;e++){Lr[e]=+("1e"+Math.floor(45.15-e*.30103))}let Ur=new or({useRecords:false});Ur.decode;Ur.decodeMultiple;let Mr;try{Mr=new TextEncoder}catch(e){}let qr,zr;const Vr=typeof globalThis==="object"&&globalThis.Buffer;const Yr=typeof Vr!=="undefined";const $r=Yr?Vr.allocUnsafeSlow:Uint8Array;const Jr=Yr?Vr:Uint8Array;const Kr=256;const Hr=Yr?4294967296:2144337920;let Gr;let O;let S;let B=0;let Wr;let Qr=null;const Zr=61440;const Xr=/[\u0080-\uFFFF]/;const en=Symbol("record-id");class tn extends or{constructor(r){super(r);this.offset=0;let s;let a;let f;let l;let n;r=r||{};let c=Jr.prototype.utf8Write?function(e,t,r){return O.utf8Write(e,t,r)}:Mr&&Mr.encodeInto?function(e,t){return Mr.encodeInto(e,O.subarray(t)).written}:false;let u=this;let e=r.structures||r.saveStructures;let h=r.maxSharedStructures;if(h==null)h=e?128:0;if(h>8190)throw new Error("Maximum maxSharedStructure is 8190");let i=r.sequential;if(i){h=0}if(!this.structures)this.structures=[];if(this.saveStructures)this.saveShared=this.saveStructures;let p,_,o=r.sharedValues;let d;if(o){d=Object.create(null);for(let e=0,t=o.length;ethis.encodeKeys(e));break}}return this.encode(e,t)};this.encode=function(t,e){if(!O){O=new $r(8192);S=new DataView(O.buffer,0,8192);B=0}Wr=O.length-10;if(Wr-B<2048){O=new $r(O.length);S=new DataView(O.buffer,0,O.length);Wr=O.length-10;B=0}else if(e===vn)B=B+7&2147483640;s=B;if(u.useSelfDescribedHeader){S.setUint32(B,3654940416);B+=3}n=u.structuredClone?new Map:null;if(u.bundleStrings&&typeof t!=="string"){Qr=[];Qr.size=Infinity}else Qr=null;a=u.structures;if(a){if(a.uninitialized){let e=u.getShared()||{};u.structures=a=e.structures||[];u.sharedVersion=e.version;let r=u.sharedValues=e.packedValues;if(r){d={};for(let e=0,t=r.length;eh&&!i)e=h;if(!a.transitions){a.transitions=Object.create(null);for(let u=0;u0){O[B++]=216;O[B++]=51;un(4);let r=e.values;g(r);un(0);un(0);_=Object.create(d||null);for(let e=0,t=r.length;eWr)w(B);u.offset=B;let e=hn(O.subarray(s,B),n.idsToInsert);n=null;return e}if(e&vn){O.start=s;O.end=B;return O}return O.subarray(s,B)}finally{if(a){if(m<10)m++;if(a.length>h)a.length=h;if(y>1e4){a.transitions=null;m=0;y=0;if(v.length>0)v=[]}else if(v.length>0&&!i){for(let e=0,t=v.length;eh){u.structures=u.structures.slice(0,h)}let e=O.subarray(s,B);if(u.updateSharedData()===false)return u.encode(t);return e}if(e&yn)B=s}};this.findCommonStringsToPack=()=>{p=new Map;if(!d)d=Object.create(null);return e=>{let r=e&&e.threshold||4;let n=this.pack?e.maxPrivatePackedValues||16:0;if(!o)o=this.sharedValues=[];for(let[e,t]of p){if(t.count>r){d[e]=n++;o.push(e);f=true}}while(this.saveShared&&this.updateSharedData()===false){}p=null}};const g=a=>{if(B>Wr)O=w(B);var e=typeof a;var o;if(e==="string"){if(_){let e=_[a];if(e>=0){if(e<16)O[B++]=e+224;else{O[B++]=198;if(e&1)g(15-e>>1);else g(e-16>>1)}return}else if(p&&!r.pack){let e=p.get(a);if(e)e.count++;else p.set(a,{count:1})}}let i=a.length;if(Qr&&i>=4&&i<1024){if((Qr.size+=i)>Zr){let e;let t=(Qr[0]?Qr[0].length*3+Qr[1].length:0)+10;if(B+t>Wr)O=w(B+t);O[B++]=217;O[B++]=223;O[B++]=249;O[B++]=Qr.position?132:130;O[B++]=26;e=B-s;B+=4;if(Qr.position){pn(s,g)}Qr=["",""];Qr.size=0;Qr.position=e}let e=Xr.test(a);Qr[e?0:1]+=a;O[B++]=e?206:207;g(i);return}let u;if(i<32){u=1}else if(i<256){u=2}else if(i<65536){u=3}else{u=5}let e=i*3;if(B+e>Wr)O=w(B+e);if(i<64||!c){let e,t,r,n=B+u;for(e=0;e>6|192;O[n++]=t&63|128}else if((t&64512)===55296&&((r=a.charCodeAt(e+1))&64512)===56320){t=65536+((t&1023)<<10)+(r&1023);e++;O[n++]=t>>18|240;O[n++]=t>>12&63|128;O[n++]=t>>6&63|128;O[n++]=t&63|128}else{O[n++]=t>>12|224;O[n++]=t>>6&63|128;O[n++]=t&63|128}}o=n-B-u}else{o=c(a,B+u,e)}if(o<24){O[B++]=96|o}else if(o<256){if(u<2){O.copyWithin(B+2,B+1,B+1+o)}O[B++]=120;O[B++]=o}else if(o<65536){if(u<3){O.copyWithin(B+3,B+2,B+2+o)}O[B++]=121;O[B++]=o>>8;O[B++]=o&255}else{if(u<5){O.copyWithin(B+5,B+3,B+3+o)}O[B++]=122;S.setUint32(B,o);B+=4}B+=o}else if(e==="number"){if(!this.alwaysUseFloat&&a>>>0===a){if(a<24){O[B++]=a}else if(a<256){O[B++]=24;O[B++]=a}else if(a<65536){O[B++]=25;O[B++]=a>>8;O[B++]=a&255}else{O[B++]=26;S.setUint32(B,a);B+=4}}else if(!this.alwaysUseFloat&&a>>0===a){if(a>=-24){O[B++]=31-a}else if(a>=-256){O[B++]=56;O[B++]=~a}else if(a>=-65536){O[B++]=57;S.setUint16(B,~a);B+=2}else{O[B++]=58;S.setUint32(B,~a);B+=4}}else{let t;if((t=this.useFloat32)>0&&a<4294967296&&a>=-2147483648){O[B++]=250;S.setFloat32(B,a);let e;if(t<4||(e=a*Lr[(O[B]&127)<<1|O[B+1]>>7])>>0===e){B+=4;return}else B--}O[B++]=251;S.setFloat64(B,a);B+=8}}else if(e==="object"){if(!a)O[B++]=246;else{if(n){let t=n.get(a);if(t){O[B++]=216;O[B++]=29;O[B++]=25;if(!t.references){let e=n.idsToInsert||(n.idsToInsert=[]);t.references=[];e.push(t)}t.references.push(B-s);B+=2;return}else n.set(a,{offset:B-s})}let e=a.constructor;if(e===Object){b(a,true)}else if(e===Array){o=a.length;if(o<24){O[B++]=128|o}else{un(o)}for(let e=0;e>8;O[B++]=o&255}else{O[B++]=186;S.setUint32(B,o);B+=4}if(u.keyMap){for(let[e,t]of a){g(u.encodeKey(e));g(t)}}else{for(let[e,t]of a){g(e);g(t)}}}else{for(let r=0,e=qr.length;r>8;O[B++]=t&255}else if(t>-1){O[B++]=218;S.setUint32(B,t);B+=4}e.encode.call(this,a,g,w);return}}if(a[Symbol.iterator]){if(Gr){let e=new Error("Iterable should be serialized as iterator");e.iteratorNotHandled=true;throw e}O[B++]=159;for(let e of a){g(e)}O[B++]=255;return}if(a[Symbol.asyncIterator]||on(a)){let e=new Error("Iterable/blob should be serialized as iterator");e.iteratorNotHandled=true;throw e}if(this.useToJSON&&a.toJSON){const t=a.toJSON();if(t!==a)return g(t)}b(a,!a.hasOwnProperty)}}}else if(e==="boolean"){O[B++]=a?245:244}else if(e==="bigint"){if(a=0){O[B++]=27;S.setBigUint64(B,a)}else if(a>-(BigInt(1)<{let t=Object.keys(e);let r=Object.values(e);let n=t.length;if(n<24){O[B++]=160|n}else if(n<256){O[B++]=184;O[B++]=n}else if(n<65536){O[B++]=185;O[B++]=n>>8;O[B++]=n&255}else{O[B++]=186;S.setUint32(B,n);B+=4}if(u.keyMap){for(let e=0;e{O[B++]=185;let e=B-s;B+=2;let n=0;if(u.keyMap){for(let e in t)if(r||t.hasOwnProperty(e)){g(u.encodeKey(e));g(t[e]);n++}}else{for(let e in t)if(r||t.hasOwnProperty(e)){g(e);g(t[e]);n++}}O[e+++s]=n>>8;O[e+s]=n&255}:(t,r)=>{let n,i=l.transitions||(l.transitions=Object.create(null));let u=0;let a=0;let o;let s;if(this.keyMap){s=Object.keys(t).map(e=>this.encodeKey(e));a=s.length;for(let t=0;t>8|224;O[B++]=c&255}else{if(!s)s=i.__keys__||(i.__keys__=Object.keys(t));if(o===undefined){c=l.nextId++;if(!c){c=0;l.nextId=1}if(c>=Kr){l.nextId=(c=h)+1}}else{c=o}l[c]=s;if(c>8|224;O[B++]=c&255;i=l.transitions;for(let e=0;e=Kr-h)v.shift()[en]=undefined;v.push(i);un(a+2);g(57344+c);g(s);if(r===null)return;for(let e in t)if(r||t.hasOwnProperty(e))g(t[e]);return}}if(a<24){O[B++]=128|a}else{un(a)}if(r===null)return;for(let e in t)if(r||t.hasOwnProperty(e))g(t[e])};const w=e=>{let t;if(e>16777216){if(e-s>Hr)throw new Error("Encoded buffer would be larger than maximum buffer size");t=Math.min(Hr,Math.round(Math.max((e-s)*(e>67108864?1.25:2),4194304)/4096)*4096)}else t=(Math.max(e-s<<2,O.length-1)>>12)+1<<12;let r=new $r(t);S=new DataView(r.buffer,0,t);if(O.copy)O.copy(r,0,s,e);else r.set(O.slice(s,e));B-=s;s=0;Wr=r.length-10;return O=r};let D=100;let E=1e3;this.encodeAsIterable=function(e,t){return k(e,t,A)};this.encodeAsAsyncIterable=function(e,t){return k(e,t,C)};function*A(n,i,e){let t=n.constructor;if(t===Object){let r=u.useRecords!==false;if(r)b(n,null);else rn(Object.keys(n).length,160);for(let t in n){let e=n[t];if(!r)g(t);if(e&&typeof e==="object"){if(i[t])yield*A(e,i[t]);else yield*x(e,i,t)}else g(e)}}else if(t===Array){let e=n.length;un(e);for(let t=0;tD)){if(i.element)yield*A(e,i.element);else yield*x(e,i,"element")}else g(e)}}else if(n[Symbol.iterator]){O[B++]=159;for(let e of n){if(e&&(typeof e==="object"||B-s>D)){if(i.element)yield*A(e,i.element);else yield*x(e,i,"element")}else g(e)}O[B++]=255}else if(on(n)){rn(n.size,64);yield O.subarray(s,B);yield n;F()}else if(n[Symbol.asyncIterator]){O[B++]=159;yield O.subarray(s,B);yield n;F();O[B++]=255}else{g(n)}if(e&&B>s)yield O.subarray(s,B);else if(B-s>D){yield O.subarray(s,B);F()}}function*x(t,r,n){let i=B-s;try{g(t);if(B-s>D){yield O.subarray(s,B);F()}}catch(e){if(e.iteratorNotHandled){r[n]={};B=s+i;yield*A.call(this,t,r[n])}else throw e}}function F(){D=E;u.encode(null,mn)}function k(e,t,r){if(t&&t.chunkThreshold)D=E=t.chunkThreshold;else D=100;if(e&&typeof e==="object"){u.encode(null,mn);return r(e,u.iterateProperties||(u.iterateProperties={}),true)}return[u.encode(e)]}async function*C(e,t){for(let r of A(e,t,true)){let e=r.constructor;if(e===Jr||e===Uint8Array)yield r;else if(on(r)){let e=r.stream().getReader();let t;while(!(t=await e.read()).done){yield t.value}}else if(r[Symbol.asyncIterator]){for await(let e of r){F();if(e)yield*C(e,t.async||(t.async={}));else yield u.encode(e)}}else{yield r}}}}useBuffer(e){O=e;S=new DataView(O.buffer,O.byteOffset,O.byteLength);B=0}clearSharedData(){if(this.structures)this.structures=[];if(this.sharedValues)this.sharedValues=undefined}updateSharedData(){let t=this.sharedVersion||0;this.sharedVersion=t+1;let e=this.structures.slice(0);let r=new nn(e,this.sharedValues,this.sharedVersion);let n=this.saveShared(r,e=>(e&&e.version||0)==t);if(n===false){r=this.getShared()||{};this.structures=r.structures||[];this.sharedValues=r.packedValues;this.sharedVersion=r.version;this.structures.nextId=this.structures.length}else{e.forEach((e,t)=>this.structures[t]=e)}return n}}function rn(e,t){if(e<24)O[B++]=t|e;else if(e<256){O[B++]=t|24;O[B++]=e}else if(e<65536){O[B++]=t|25;O[B++]=e>>8;O[B++]=e&255}else{O[B++]=t|26;S.setUint32(B,e);B+=4}}class nn{constructor(e,t,r){this.structures=e;this.packedValues=t;this.version=r}}function un(e){if(e<24)O[B++]=128|e;else if(e<256){O[B++]=152;O[B++]=e}else if(e<65536){O[B++]=153;O[B++]=e>>8;O[B++]=e&255}else{O[B++]=154;S.setUint32(B,e);B+=4}}const an=typeof Blob==="undefined"?function(){}:Blob;function on(e){if(e instanceof an)return true;let t=e[Symbol.toStringTag];return t==="Blob"||t==="File"}function sn(r,n){switch(typeof r){case"string":if(r.length>3){if(n.objectMap[r]>-1||n.values.length>=n.maxValues)return;let e=n.get(r);if(e){if(++e.count==2){n.values.push(r)}}else{n.set(r,{count:1});if(n.samplingPackedValues){let e=n.samplingPackedValues.get(r);if(e)e.count++;else n.samplingPackedValues.set(r,{count:1})}}}break;case"object":if(r){if(r instanceof Array){for(let e=0,t=r.length;e=0&&r<4294967296){O[B++]=26;S.setUint32(B,r);B+=4}else{O[B++]=251;S.setFloat64(B,r);B+=8}}},{tag:258,encode(e,t){let r=Array.from(e);t(r)}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t(["RegExp",e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,r){ln(e,r)}},{getTag(e){if(e.constructor===Uint8Array){if(this.tagUint8Array||Yr&&this.tagUint8Array!==false)return 64}},encode(e,t,r){ln(e,r)}},fn(68,1),fn(69,2),fn(70,4),fn(71,8),fn(72,1),fn(77,2),fn(78,4),fn(79,8),fn(85,4),fn(86,8),{encode(t,n){let e=t.packedValues||[];let r=t.structures||[];if(e.values.length>0){O[B++]=216;O[B++]=51;un(4);let r=e.values;n(r);un(0);un(0);packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let e=0,t=r.length;e1)e-=4;return{tag:e,encode:function e(t,r){let n=t.byteLength;let i=t.byteOffset||0;let u=t.buffer||t;r(Yr?Vr.from(u,i,n):new Uint8Array(u,i,n))}}}function ln(e,t){let r=e.byteLength;if(r<24){O[B++]=64+r}else if(r<256){O[B++]=88;O[B++]=r}else if(r<65536){O[B++]=89;O[B++]=r>>8;O[B++]=r&255}else{O[B++]=90;S.setUint32(B,r);B+=4}if(B+r>=O.length){t(B+r)}O.set(e.buffer?e:new Uint8Array(e),B);B+=r}function hn(n,e){let r;let i=e.length*2;let u=n.length-i;e.sort((e,t)=>e.offset>t.offset?1:-1);for(let r=0;r>8;n[e]=r&255}}while(r=e.pop()){let e=r.offset;n.copyWithin(e+i,e,u);i-=2;let t=e+i;n[t++]=216;n[t++]=28;u=e}return n}function pn(e,t){S.setUint32(Qr.position+e,B-Qr.position-e+1);let r=Qr;Qr=null;t(r[0]);t(r[1])}function _n(e){if(e.Class){if(!e.encode)throw new Error("Extension has no encode function");zr.unshift(e.Class);qr.unshift(e)}Tr(e)}let dn=new tn({useRecords:false});dn.encode;dn.encodeAsIterable;dn.encodeAsAsyncIterable;const vn=512;const yn=1024;const mn=2048;var gn={}; + */var qe=50;c.TYPED_ARRAY_SUPPORT=ke.TYPED_ARRAY_SUPPORT!==undefined?ke.TYPED_ARRAY_SUPPORT:true;ze();function ze(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ve(e,t){if(ze()=ze()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+ze().toString(16)+" bytes")}return e|0}c.isBuffer=Rt;function Xe(e){return!!(e!=null&&e._isBuffer)}c.compare=function e(t,r){if(!Xe(t)||!Xe(r)){throw new TypeError("Arguments must be Buffers")}if(t===r)return 0;var n=t.length;var i=r.length;for(var u=0,a=Math.min(n,i);u>>1;case"base64":return It(e).length;default:if(n)return St(e).length;t=(""+t).toLowerCase();n=true}}}c.byteLength=et;function tt(e,t,r){var n=false;if(t===undefined||t<0){t=0}if(t>this.length){return""}if(r===undefined||r>this.length){r=this.length}if(r<=0){return""}r>>>=0;t>>>=0;if(r<=t){return""}if(!e)e="utf8";while(true){switch(e){case"hex":return yt(this,t,r);case"utf8":case"utf-8":return ht(this,t,r);case"ascii":return dt(this,t,r);case"latin1":case"binary":return vt(this,t,r);case"base64":return lt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}}c.prototype._isBuffer=true;function rt(e,t,r){var n=e[t];e[t]=e[r];e[r]=n}c.prototype.swap16=function e(){var t=this.length;if(t%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var r=0;r0){t=this.toString("hex",0,r).match(/.{2}/g).join(" ");if(this.length>r)t+=" ... "}return""};c.prototype.compare=function e(t,r,n,i,u){if(!Xe(t)){throw new TypeError("Argument must be a Buffer")}if(r===undefined){r=0}if(n===undefined){n=t?t.length:0}if(i===undefined){i=0}if(u===undefined){u=this.length}if(r<0||n>t.length||i<0||u>this.length){throw new RangeError("out of range index")}if(i>=u&&r>=n){return 0}if(i>=u){return-1}if(r>=n){return 1}r>>>=0;n>>>=0;i>>>=0;u>>>=0;if(this===t)return 0;var a=u-i;var o=n-r;var s=Math.min(a,o);var c=this.slice(i,u);var f=t.slice(r,n);for(var l=0;l2147483647){r=2147483647}else if(r<-2147483648){r=-2147483648}r=+r;if(isNaN(r)){r=i?0:e.length-1}if(r<0)r=e.length+r;if(r>=e.length){if(i)return-1;else r=e.length-1}else if(r<0){if(i)r=0;else return-1}if(typeof t==="string"){t=c.from(t,n)}if(Xe(t)){if(t.length===0){return-1}return it(e,t,r,n,i)}else if(typeof t==="number"){t=t&255;if(c.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(i){return Uint8Array.prototype.indexOf.call(e,t,r)}else{return Uint8Array.prototype.lastIndexOf.call(e,t,r)}}return it(e,[t],r,n,i)}throw new TypeError("val must be string, number or Buffer")}function it(e,t,r,n,i){var u=1;var a=e.length;var o=t.length;if(n!==undefined){n=String(n).toLowerCase();if(n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le"){if(e.length<2||t.length<2){return-1}u=2;a/=2;o/=2;r/=2}}function s(e,t){if(u===1){return e[t]}else{return e.readUInt16BE(t*u)}}var c;if(i){var f=-1;for(c=r;ca)r=a-o;for(c=r;c>=0;c--){var l=true;for(var h=0;hi){n=i}}var u=t.length;if(u%2!==0)throw new TypeError("Invalid hex string");if(n>u/2){n=u/2}for(var a=0;au)n=u;if(t.length>0&&(n<0||r<0)||r>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!i)i="utf8";var a=false;for(;;){switch(i){case"hex":return ut(this,t,r,n);case"utf8":case"utf-8":return at(this,t,r,n);case"ascii":return ot(this,t,r,n);case"latin1":case"binary":return st(this,t,r,n);case"base64":return ct(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ft(this,t,r,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase();a=true}}};c.prototype.toJSON=function e(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function lt(e,t,r){if(t===0&&r===e.length){return Re(e)}else{return Re(e.slice(t,r))}}function ht(e,t,r){r=Math.min(e.length,r);var n=[];var i=t;while(i239?4:u>223?3:u>191?2:1;if(i+o<=r){var s,c,f,l;switch(o){case 1:if(u<128){a=u}break;case 2:s=e[i+1];if((s&192)===128){l=(u&31)<<6|s&63;if(l>127){a=l}}break;case 3:s=e[i+1];c=e[i+2];if((s&192)===128&&(c&192)===128){l=(u&15)<<12|(s&63)<<6|c&63;if(l>2047&&(l<55296||l>57343)){a=l}}break;case 4:s=e[i+1];c=e[i+2];f=e[i+3];if((s&192)===128&&(c&192)===128&&(f&192)===128){l=(u&15)<<18|(s&63)<<12|(c&63)<<6|f&63;if(l>65535&&l<1114112){a=l}}}}if(a===null){a=65533;o=1}else if(a>65535){a-=65536;n.push(a>>>10&1023|55296);a=56320|a&1023}n.push(a);i+=o}return _t(n)}var pt=4096;function _t(e){var t=e.length;if(t<=pt){return String.fromCharCode.apply(String,e)}var r="";var n=0;while(nn)r=n;var i="";for(var u=t;un){t=n}if(r<0){r+=n;if(r<0)r=0}else if(r>n){r=n}if(rr)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)gt(t,r,this.length);var i=this[t];var u=1;var a=0;while(++a0&&(u*=256)){i+=this[t+--r]*u}return i};c.prototype.readUInt8=function e(t,r){if(!r)gt(t,1,this.length);return this[t]};c.prototype.readUInt16LE=function e(t,r){if(!r)gt(t,2,this.length);return this[t]|this[t+1]<<8};c.prototype.readUInt16BE=function e(t,r){if(!r)gt(t,2,this.length);return this[t]<<8|this[t+1]};c.prototype.readUInt32LE=function e(t,r){if(!r)gt(t,4,this.length);return(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};c.prototype.readUInt32BE=function e(t,r){if(!r)gt(t,4,this.length);return this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};c.prototype.readIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)gt(t,r,this.length);var i=this[t];var u=1;var a=0;while(++a=u)i-=Math.pow(2,8*r);return i};c.prototype.readIntBE=function e(t,r,n){t=t|0;r=r|0;if(!n)gt(t,r,this.length);var i=r;var u=1;var a=this[t+--i];while(i>0&&(u*=256)){a+=this[t+--i]*u}u*=128;if(a>=u)a-=Math.pow(2,8*r);return a};c.prototype.readInt8=function e(t,r){if(!r)gt(t,1,this.length);if(!(this[t]&128))return this[t];return(255-this[t]+1)*-1};c.prototype.readInt16LE=function e(t,r){if(!r)gt(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};c.prototype.readInt16BE=function e(t,r){if(!r)gt(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};c.prototype.readInt32LE=function e(t,r){if(!r)gt(t,4,this.length);return this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};c.prototype.readInt32BE=function e(t,r){if(!r)gt(t,4,this.length);return this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};c.prototype.readFloatLE=function e(t,r){if(!r)gt(t,4,this.length);return Te(this,t,true,23,4)};c.prototype.readFloatBE=function e(t,r){if(!r)gt(t,4,this.length);return Te(this,t,false,23,4)};c.prototype.readDoubleLE=function e(t,r){if(!r)gt(t,8,this.length);return Te(this,t,true,52,8)};c.prototype.readDoubleBE=function e(t,r){if(!r)gt(t,8,this.length);return Te(this,t,false,52,8)};function bt(e,t,r,n,i,u){if(!Xe(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}c.prototype.writeUIntLE=function e(t,r,n,i){t=+t;r=r|0;n=n|0;if(!i){var u=Math.pow(2,8*n)-1;bt(this,t,r,n,u,0)}var a=1;var o=0;this[r]=t&255;while(++o=0&&(o*=256)){this[r+a]=t/o&255}return r+n};c.prototype.writeUInt8=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,1,255,0);if(!c.TYPED_ARRAY_SUPPORT)t=Math.floor(t);this[r]=t&255;return r+1};function wt(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,u=Math.min(e.length-r,2);i>>(n?i:1-i)*8}}c.prototype.writeUInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,2,65535,0);if(c.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{wt(this,t,r,true)}return r+2};c.prototype.writeUInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,2,65535,0);if(c.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{wt(this,t,r,false)}return r+2};function Dt(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,u=Math.min(e.length-r,4);i>>(n?i:3-i)*8&255}}c.prototype.writeUInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,4,4294967295,0);if(c.TYPED_ARRAY_SUPPORT){this[r+3]=t>>>24;this[r+2]=t>>>16;this[r+1]=t>>>8;this[r]=t&255}else{Dt(this,t,r,true)}return r+4};c.prototype.writeUInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,4,4294967295,0);if(c.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{Dt(this,t,r,false)}return r+4};c.prototype.writeIntLE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var u=Math.pow(2,8*n-1);bt(this,t,r,n,u-1,-u)}var a=0;var o=1;var s=0;this[r]=t&255;while(++a>0)-s&255}return r+n};c.prototype.writeIntBE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var u=Math.pow(2,8*n-1);bt(this,t,r,n,u-1,-u)}var a=n-1;var o=1;var s=0;this[r+a]=t&255;while(--a>=0&&(o*=256)){if(t<0&&s===0&&this[r+a+1]!==0){s=1}this[r+a]=(t/o>>0)-s&255}return r+n};c.prototype.writeInt8=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,1,127,-128);if(!c.TYPED_ARRAY_SUPPORT)t=Math.floor(t);if(t<0)t=255+t+1;this[r]=t&255;return r+1};c.prototype.writeInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,2,32767,-32768);if(c.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{wt(this,t,r,true)}return r+2};c.prototype.writeInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,2,32767,-32768);if(c.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{wt(this,t,r,false)}return r+2};c.prototype.writeInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,4,2147483647,-2147483648);if(c.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8;this[r+2]=t>>>16;this[r+3]=t>>>24}else{Dt(this,t,r,true)}return r+4};c.prototype.writeInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)bt(this,t,r,4,2147483647,-2147483648);if(t<0)t=4294967295+t+1;if(c.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{Dt(this,t,r,false)}return r+4};function Et(e,t,r,n,i,u){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function At(e,t,r,n,i){if(!i){Et(e,t,r,4)}Le(e,t,r,n,23,4);return r+4}c.prototype.writeFloatLE=function e(t,r,n){return At(this,t,r,true,n)};c.prototype.writeFloatBE=function e(t,r,n){return At(this,t,r,false,n)};function xt(e,t,r,n,i){if(!i){Et(e,t,r,8)}Le(e,t,r,n,52,8);return r+8}c.prototype.writeDoubleLE=function e(t,r,n){return xt(this,t,r,true,n)};c.prototype.writeDoubleBE=function e(t,r,n){return xt(this,t,r,false,n)};c.prototype.copy=function e(t,r,n,i){if(!n)n=0;if(!i&&i!==0)i=this.length;if(r>=t.length)r=t.length;if(!r)r=0;if(i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");if(i>this.length)i=this.length;if(t.length-r=0;--a){t[a+r]=this[a+n]}}else if(u<1e3||!c.TYPED_ARRAY_SUPPORT){for(a=0;a>>0;n=n===undefined?this.length:n>>>0;if(!t)t=0;var a;if(typeof t==="number"){for(a=r;a55295&&r<57344){if(!i){if(r>56319){if((t-=3)>-1)u.push(239,191,189);continue}else if(a+1===n){if((t-=3)>-1)u.push(239,191,189);continue}i=r;continue}if(r<56320){if((t-=3)>-1)u.push(239,191,189);i=r;continue}r=(i-55296<<10|r-56320)+65536}else if(i){if((t-=3)>-1)u.push(239,191,189)}i=null;if(r<128){if((t-=1)<0)break;u.push(r)}else if(r<2048){if((t-=2)<0)break;u.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;u.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;u.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return u}function Bt(e){var t=[];for(var r=0;r>8;i=r%256;u.push(i);u.push(n)}return u}function It(e){return Ie(kt(e))}function Pt(e,t,r,n){for(var i=0;i=t.length||i>=e.length)break;t[i+r]=e[i]}return i}function Nt(e){return e!==e}function Rt(e){return e!=null&&(!!e._isBuffer||Tt(e)||Lt(e))}function Tt(e){return!!e.constructor&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function Lt(e){return typeof e.readFloatLE==="function"&&typeof e.slice==="function"&&Tt(e.slice(0,0))}let Ut;try{Ut=new TextDecoder}catch(e){}let v;let Mt;let y=0;const qt=105;const zt=57342;const Vt=57343;const Yt=57337;const $t=6;const Jt={};let _={};let Kt;let Ht;let Wt=0;let Gt=0;let Qt;let Zt;let Xt=[];let er=[];let tr;let rr;let nr;let ir={useRecords:false,mapsAsObjects:true};let ur=false;let ar=2;try{new Function("")}catch(e){ar=Infinity}class or{constructor(r){if(r){if((r.keyMap||r._keyMap)&&!r.useRecords){r.useRecords=false;r.mapsAsObjects=true}if(r.useRecords===false&&r.mapsAsObjects===undefined)r.mapsAsObjects=true;if(r.getStructures)r.getShared=r.getStructures;if(r.getShared&&!r.structures)(r.structures=[]).uninitialized=true;if(r.keyMap){this.mapKey=new Map;for(let[e,t]of Object.entries(r.keyMap))this.mapKey.set(t,e)}}Object.assign(this,r)}decodeKey(e){return this.keyMap?this.mapKey.get(e)||e:e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(r){if(!this._keyMap)return r;let n=new Map;for(let[e,t]of Object.entries(r))n.set(this._keyMap.hasOwnProperty(e)?this._keyMap[e]:e,t);return n}decodeKeys(e){if(!this._keyMap||e.constructor.name!="Map")return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let r={};e.forEach((e,t)=>r[lr(this._mapKey.has(t)?this._mapKey.get(t):t)]=e);return r}mapDecode(e,t){let r=this.decode(e);if(this._keyMap){switch(r.constructor.name){case"Array":return r.map(e=>this.decodeKeys(e))}}return r}decode(t,e){if(v){return Nr(()=>{Rr();return this?this.decode(t,e):or.prototype.decode.call(ir,t,e)})}Mt=e>-1?e:t.length;y=0;Gt=0;Ht=null;Qt=null;v=t;try{rr=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(e){v=null;if(t instanceof Uint8Array)throw e;throw new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof or){_=this;tr=this.sharedValues&&(this.pack?new Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues);if(this.structures){Kt=this.structures;return sr()}else if(!Kt||Kt.length>0){Kt=[]}}else{_=ir;if(!Kt||Kt.length>0)Kt=[];tr=null}return sr()}decodeMultiple(r,n){let i,u=0;try{let e=r.length;ur=true;let t=this?this.decode(r,e):Ur.decode(r,e);if(n){if(n(t)===false){return}while(y=Qt.postBundlePosition){let e=new Error("Unexpected bundle position");e.incomplete=true;throw e}y=Qt.postBundlePosition;Qt=null}if(y==Mt){Kt=null;v=null;if(Zt)Zt=null}else if(y>Mt){let e=new Error("Unexpected end of CBOR data");e.incomplete=true;throw e}else if(!ur){throw new Error("Data read, but end of buffer not reached")}return e}catch(e){Rr();if(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")){e.incomplete=true}throw e}}function u(){let n=v[y++];let i=n>>5;n=n&31;if(n>23){switch(n){case 24:n=v[y++];break;case 25:if(i==7){return br()}n=rr.getUint16(y);y+=2;break;case 26:if(i==7){let t=rr.getFloat32(y);if(_.useFloat32>2){let e=Lr[(v[y]&127)<<1|v[y+1]>>7];y+=4;return(e*t+(t>0?.5:-.5)>>0)/e}y+=4;return t}n=rr.getUint32(y);y+=4;break;case 27:if(i==7){let e=rr.getFloat64(y);y+=8;return e}if(i>1){if(rr.getUint32(y)>0)throw new Error("JavaScript does not support arrays, maps, or strings with length over 4294967295");n=rr.getUint32(y+4)}else if(_.int64AsNumber){n=rr.getUint32(y)*4294967296;n+=rr.getUint32(y+4)}else n=rr.getBigUint64(y);y+=8;break;case 31:switch(i){case 2:case 3:throw new Error("Indefinite length not supported for byte or text strings");case 4:let e=[];let t,r=0;while((t=u())!=Jt){e[r++]=t}return i==4?e:i==3?e.join(""):c.concat(e);case 5:let n;if(_.mapsAsObjects){let e={};if(_.keyMap)while((n=u())!=Jt)e[lr(_.decodeKey(n))]=u();else while((n=u())!=Jt)e[lr(n)]=u();return e}else{if(nr){_.mapsAsObjects=true;nr=false}let e=new Map;if(_.keyMap)while((n=u())!=Jt)e.set(_.decodeKey(n),u());else while((n=u())!=Jt)e.set(n,u());return e}case 7:return Jt;default:throw new Error("Invalid major type for indefinite length "+i)}default:throw new Error("Unknown token "+n)}}switch(i){case 0:return n;case 1:return~n;case 2:return yr(n);case 3:if(Gt>=y){return Ht.slice(y-Wt,(y+=n)-Wt)}if(Gt==0&&Mt<140&&n<32){let e=n<16?vr(n):dr(n);if(e!=null)return e}return hr(n);case 4:let t=new Array(n);for(let e=0;e=Yt){let e=Kt[n&8191];if(e){if(!e.read)e.read=fr(e);return e.read()}if(n<65536){if(n==Vt){let e=Ir();let t=u();let r=u();Dr(t,r);let n={};if(_.keyMap)for(let t=2;t23){switch(t){case 24:t=v[y++];break;case 25:t=rr.getUint16(y);y+=2;break;case 26:t=rr.getUint32(y);y+=4;break;default:throw new Error("Expected array header, but got "+v[y-1])}}let r=this.compiledReader;while(r){if(r.propertyCount===t)return r(u);r=r.next}if(this.slowReads++>=ar){let e=this.length==t?this:this.slice(0,t);r=_.keyMap?new Function("r","return {"+e.map(e=>_.decodeKey(e)).map(e=>cr.test(e)?lr(e)+":r()":"["+JSON.stringify(e)+"]:r()").join(",")+"}"):new Function("r","return {"+e.map(e=>cr.test(e)?lr(e)+":r()":"["+JSON.stringify(e)+"]:r()").join(",")+"}");if(this.compiledReader)r.next=this.compiledReader;r.propertyCount=t;this.compiledReader=r;return r(u)}let n={};if(_.keyMap)for(let e=0;e64&&Ut)return Ut.decode(v.subarray(y,y+=e));const r=y+e;const n=[];t="";while(y65535){e-=65536;n.push(e>>>10&1023|55296);e=56320|e&1023}n.push(e)}else{n.push(i)}if(n.length>=4096){t+=_r.apply(String,n);n.length=0}}if(n.length>0){t+=_r.apply(String,n)}return t}let _r=String.fromCharCode;function dr(t){let r=y;let n=new Array(t);for(let e=0;e0){y=r;return}n[e]=i}return _r.apply(String,n)}function vr(d){if(d<4){if(d<2){if(d===0)return"";else{let e=v[y++];if((e&128)>1){y-=1;return}return _r(e)}}else{let e=v[y++];let t=v[y++];if((e&128)>0||(t&128)>0){y-=2;return}if(d<3)return _r(e,t);let r=v[y++];if((r&128)>0){y-=3;return}return _r(e,t,r)}}else{let l=v[y++];let h=v[y++];let p=v[y++];let _=v[y++];if((l&128)>0||(h&128)>0||(p&128)>0||(_&128)>0){y-=4;return}if(d<6){if(d===4)return _r(l,h,p,_);else{let e=v[y++];if((e&128)>0){y-=5;return}return _r(l,h,p,_,e)}}else if(d<8){let e=v[y++];let t=v[y++];if((e&128)>0||(t&128)>0){y-=6;return}if(d<7)return _r(l,h,p,_,e,t);let r=v[y++];if((r&128)>0){y-=7;return}return _r(l,h,p,_,e,t,r)}else{let o=v[y++];let s=v[y++];let c=v[y++];let f=v[y++];if((o&128)>0||(s&128)>0||(c&128)>0||(f&128)>0){y-=8;return}if(d<10){if(d===8)return _r(l,h,p,_,o,s,c,f);else{let e=v[y++];if((e&128)>0){y-=9;return}return _r(l,h,p,_,o,s,c,f,e)}}else if(d<12){let e=v[y++];let t=v[y++];if((e&128)>0||(t&128)>0){y-=10;return}if(d<11)return _r(l,h,p,_,o,s,c,f,e,t);let r=v[y++];if((r&128)>0){y-=11;return}return _r(l,h,p,_,o,s,c,f,e,t,r)}else{let n=v[y++];let i=v[y++];let u=v[y++];let a=v[y++];if((n&128)>0||(i&128)>0||(u&128)>0||(a&128)>0){y-=12;return}if(d<14){if(d===12)return _r(l,h,p,_,o,s,c,f,n,i,u,a);else{let e=v[y++];if((e&128)>0){y-=13;return}return _r(l,h,p,_,o,s,c,f,n,i,u,a,e)}}else{let e=v[y++];let t=v[y++];if((e&128)>0||(t&128)>0){y-=14;return}if(d<15)return _r(l,h,p,_,o,s,c,f,n,i,u,a,e,t);let r=v[y++];if((r&128)>0){y-=15;return}return _r(l,h,p,_,o,s,c,f,n,i,u,a,e,t,r)}}}}}function yr(e){return _.copyBuffers?Uint8Array.prototype.slice.call(v,y,y+=e):v.subarray(y,y+=e)}let mr=new Float32Array(1);let gr=new Uint8Array(mr.buffer,0,4);function br(){let t=v[y++];let r=v[y++];let e=(t&127)>>2;if(e===31){if(r||t&3)return NaN;return t&128?-Infinity:Infinity}if(e===0){let e=((t&3)<<8|r)/(1<<24);return t&128?-e:e}gr[3]=t&128|(e>>1)+56;gr[2]=(t&7)<<5|r>>3;gr[1]=r<<5;gr[0]=0;return mr[0]}new Array(4096);class wr{constructor(e,t){this.value=e;this.tag=t}}Xt[0]=e=>{return new Date(e)};Xt[1]=e=>{return new Date(Math.round(e*1e3))};Xt[2]=r=>{let n=BigInt(0);for(let e=0,t=r.byteLength;e{return BigInt(-1)-Xt[2](e)};Xt[4]=e=>{return+(e[1]+"e"+e[0])};Xt[5]=e=>{return e[1]*Math.exp(e[0]*Math.log(2))};const Dr=(e,t)=>{e=e-57344;let r=Kt[e];if(r&&r.isShared){(Kt.restoreStructures||(Kt.restoreStructures=[]))[e]=r}Kt[e]=t;t.read=fr(t)};Xt[qt]=r=>{let e=r.length;let n=r[1];Dr(r[0],n);let i={};for(let t=2;t{if(Qt)return Qt[0].slice(Qt.position0,Qt.position0+=e);return new wr(e,14)};Xt[15]=e=>{if(Qt)return Qt[1].slice(Qt.position1,Qt.position1+=e);return new wr(e,15)};let Er={Error:Error,RegExp:RegExp};Xt[27]=e=>{return(Er[e[0]]||Error)(e[1],e[2])};const Ar=e=>{if(v[y++]!=132){let e=new Error("Packed values structure must be followed by a 4 element array");if(v.length{if(!tr){if(_.getShared)Pr();else return new wr(e,$t)}if(typeof e=="number")return tr[16+(e>=0?2*e:-2*e-1)];let t=new Error("No support for non-integer packed references yet");if(e===undefined)t.incomplete=true;throw t};Xt[28]=e=>{if(!Zt){Zt=new Map;Zt.id=0}let t=Zt.id++;let r=v[y];let n;if(r>>5==4)n=[];else n={};let i={target:n};Zt.set(t,i);let u=e();if(i.used)return Object.assign(n,u);i.target=u;return u};Xt[28].handlesRead=true;Xt[29]=e=>{let t=Zt.get(e);t.used=true;return t.target};Xt[258]=e=>new Set(e);(Xt[259]=e=>{if(_.mapsAsObjects){_.mapsAsObjects=false;nr=true}return e()}).handlesRead=true;function xr(e,t){if(typeof e==="string")return e+t;if(e instanceof Array)return e.concat(t);return Object.assign({},e,t)}function Fr(){if(!tr){if(_.getShared)Pr();else throw new Error("No packed values available")}return tr}const kr=1399353956;er.push((e,t)=>{if(e>=225&&e<=255)return xr(Fr().prefixes[e-224],t);if(e>=28704&&e<=32767)return xr(Fr().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return xr(Fr().prefixes[e-1879048192],t);if(e>=216&&e<=223)return xr(t,Fr().suffixes[e-216]);if(e>=27647&&e<=28671)return xr(t,Fr().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return xr(t,Fr().suffixes[e-1811939328]);if(e==kr){return{packedValues:tr,structures:Kt.slice(0),version:t}}if(e==55799)return t});const Cr=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;const Or=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array=="undefined"?{name:"BigUint64Array"}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array=="undefined"?{name:"BigInt64Array"}:BigInt64Array,Float32Array,Float64Array];const Sr=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e{if(!o)throw new Error("Could not find typed array for code "+s);if(!_.copyBuffers){if(t===1||t===2&&!(e.byteOffset&1)||t===4&&!(e.byteOffset&3)||t===8&&!(e.byteOffset&7))return new o(e.buffer,e.byteOffset,e.byteLength)}return new o(Uint8Array.prototype.slice.call(e,0).buffer)}:e=>{if(!o)throw new Error("Could not find typed array for code "+s);let t=new DataView(e.buffer,e.byteOffset,e.byteLength);let r=e.length>>u;let n=new o(r);let i=t[c];for(let e=0;e23){switch(e){case 24:e=v[y++];break;case 25:e=rr.getUint16(y);y+=2;break;case 26:e=rr.getUint32(y);y+=4;break}}return e}function Pr(){if(_.getShared){let e=Nr(()=>{v=null;return _.getShared()})||{};let t=e.structures||[];_.sharedVersion=e.version;tr=_.sharedValues=e.packedValues;if(Kt===true)_.structures=Kt=t;else Kt.splice.apply(Kt,[0,t.length].concat(t))}}function Nr(e){let t=Mt;let r=y;let n=Wt;let i=Gt;let u=Ht;let a=Zt;let o=Qt;let s=new Uint8Array(v.slice(0,Mt));let c=Kt;let f=_;let l=ur;let h=e();Mt=t;y=r;Wt=n;Gt=i;Ht=u;Zt=a;Qt=o;v=s;ur=l;Kt=c;_=f;rr=new DataView(v.buffer,v.byteOffset,v.byteLength);return h}function Rr(){v=null;Zt=null;Kt=null}function Tr(e){Xt[e.tag]=e.decode}const Lr=new Array(147);for(let e=0;e<256;e++){Lr[e]=+("1e"+Math.floor(45.15-e*.30103))}let Ur=new or({useRecords:false});Ur.decode;Ur.decodeMultiple;let Mr;try{Mr=new TextEncoder}catch(e){}let qr,zr;const Vr=typeof globalThis==="object"&&globalThis.Buffer;const Yr=typeof Vr!=="undefined";const $r=Yr?Vr.allocUnsafeSlow:Uint8Array;const Jr=Yr?Vr:Uint8Array;const Kr=256;const Hr=Yr?4294967296:2144337920;let Wr;let O;let S;let B=0;let Gr;let Qr=null;const Zr=61440;const Xr=/[\u0080-\uFFFF]/;const en=Symbol("record-id");class tn extends or{constructor(r){super(r);this.offset=0;let s;let a;let f;let l;let n;r=r||{};let c=Jr.prototype.utf8Write?function(e,t,r){return O.utf8Write(e,t,r)}:Mr&&Mr.encodeInto?function(e,t){return Mr.encodeInto(e,O.subarray(t)).written}:false;let u=this;let e=r.structures||r.saveStructures;let h=r.maxSharedStructures;if(h==null)h=e?128:0;if(h>8190)throw new Error("Maximum maxSharedStructure is 8190");let i=r.sequential;if(i){h=0}if(!this.structures)this.structures=[];if(this.saveStructures)this.saveShared=this.saveStructures;let p,_,o=r.sharedValues;let d;if(o){d=Object.create(null);for(let e=0,t=o.length;ethis.encodeKeys(e));break}}return this.encode(e,t)};this.encode=function(t,e){if(!O){O=new $r(8192);S=new DataView(O.buffer,0,8192);B=0}Gr=O.length-10;if(Gr-B<2048){O=new $r(O.length);S=new DataView(O.buffer,0,O.length);Gr=O.length-10;B=0}else if(e===vn)B=B+7&2147483640;s=B;if(u.useSelfDescribedHeader){S.setUint32(B,3654940416);B+=3}n=u.structuredClone?new Map:null;if(u.bundleStrings&&typeof t!=="string"){Qr=[];Qr.size=Infinity}else Qr=null;a=u.structures;if(a){if(a.uninitialized){let e=u.getShared()||{};u.structures=a=e.structures||[];u.sharedVersion=e.version;let r=u.sharedValues=e.packedValues;if(r){d={};for(let e=0,t=r.length;eh&&!i)e=h;if(!a.transitions){a.transitions=Object.create(null);for(let u=0;u0){O[B++]=216;O[B++]=51;un(4);let r=e.values;g(r);un(0);un(0);_=Object.create(d||null);for(let e=0,t=r.length;eGr)w(B);u.offset=B;let e=hn(O.subarray(s,B),n.idsToInsert);n=null;return e}if(e&vn){O.start=s;O.end=B;return O}return O.subarray(s,B)}finally{if(a){if(m<10)m++;if(a.length>h)a.length=h;if(y>1e4){a.transitions=null;m=0;y=0;if(v.length>0)v=[]}else if(v.length>0&&!i){for(let e=0,t=v.length;eh){u.structures=u.structures.slice(0,h)}let e=O.subarray(s,B);if(u.updateSharedData()===false)return u.encode(t);return e}if(e&yn)B=s}};this.findCommonStringsToPack=()=>{p=new Map;if(!d)d=Object.create(null);return e=>{let r=e&&e.threshold||4;let n=this.pack?e.maxPrivatePackedValues||16:0;if(!o)o=this.sharedValues=[];for(let[e,t]of p){if(t.count>r){d[e]=n++;o.push(e);f=true}}while(this.saveShared&&this.updateSharedData()===false){}p=null}};const g=a=>{if(B>Gr)O=w(B);var e=typeof a;var o;if(e==="string"){if(_){let e=_[a];if(e>=0){if(e<16)O[B++]=e+224;else{O[B++]=198;if(e&1)g(15-e>>1);else g(e-16>>1)}return}else if(p&&!r.pack){let e=p.get(a);if(e)e.count++;else p.set(a,{count:1})}}let i=a.length;if(Qr&&i>=4&&i<1024){if((Qr.size+=i)>Zr){let e;let t=(Qr[0]?Qr[0].length*3+Qr[1].length:0)+10;if(B+t>Gr)O=w(B+t);O[B++]=217;O[B++]=223;O[B++]=249;O[B++]=Qr.position?132:130;O[B++]=26;e=B-s;B+=4;if(Qr.position){pn(s,g)}Qr=["",""];Qr.size=0;Qr.position=e}let e=Xr.test(a);Qr[e?0:1]+=a;O[B++]=e?206:207;g(i);return}let u;if(i<32){u=1}else if(i<256){u=2}else if(i<65536){u=3}else{u=5}let e=i*3;if(B+e>Gr)O=w(B+e);if(i<64||!c){let e,t,r,n=B+u;for(e=0;e>6|192;O[n++]=t&63|128}else if((t&64512)===55296&&((r=a.charCodeAt(e+1))&64512)===56320){t=65536+((t&1023)<<10)+(r&1023);e++;O[n++]=t>>18|240;O[n++]=t>>12&63|128;O[n++]=t>>6&63|128;O[n++]=t&63|128}else{O[n++]=t>>12|224;O[n++]=t>>6&63|128;O[n++]=t&63|128}}o=n-B-u}else{o=c(a,B+u,e)}if(o<24){O[B++]=96|o}else if(o<256){if(u<2){O.copyWithin(B+2,B+1,B+1+o)}O[B++]=120;O[B++]=o}else if(o<65536){if(u<3){O.copyWithin(B+3,B+2,B+2+o)}O[B++]=121;O[B++]=o>>8;O[B++]=o&255}else{if(u<5){O.copyWithin(B+5,B+3,B+3+o)}O[B++]=122;S.setUint32(B,o);B+=4}B+=o}else if(e==="number"){if(!this.alwaysUseFloat&&a>>>0===a){if(a<24){O[B++]=a}else if(a<256){O[B++]=24;O[B++]=a}else if(a<65536){O[B++]=25;O[B++]=a>>8;O[B++]=a&255}else{O[B++]=26;S.setUint32(B,a);B+=4}}else if(!this.alwaysUseFloat&&a>>0===a){if(a>=-24){O[B++]=31-a}else if(a>=-256){O[B++]=56;O[B++]=~a}else if(a>=-65536){O[B++]=57;S.setUint16(B,~a);B+=2}else{O[B++]=58;S.setUint32(B,~a);B+=4}}else{let t;if((t=this.useFloat32)>0&&a<4294967296&&a>=-2147483648){O[B++]=250;S.setFloat32(B,a);let e;if(t<4||(e=a*Lr[(O[B]&127)<<1|O[B+1]>>7])>>0===e){B+=4;return}else B--}O[B++]=251;S.setFloat64(B,a);B+=8}}else if(e==="object"){if(!a)O[B++]=246;else{if(n){let t=n.get(a);if(t){O[B++]=216;O[B++]=29;O[B++]=25;if(!t.references){let e=n.idsToInsert||(n.idsToInsert=[]);t.references=[];e.push(t)}t.references.push(B-s);B+=2;return}else n.set(a,{offset:B-s})}let e=a.constructor;if(e===Object){b(a,true)}else if(e===Array){o=a.length;if(o<24){O[B++]=128|o}else{un(o)}for(let e=0;e>8;O[B++]=o&255}else{O[B++]=186;S.setUint32(B,o);B+=4}if(u.keyMap){for(let[e,t]of a){g(u.encodeKey(e));g(t)}}else{for(let[e,t]of a){g(e);g(t)}}}else{for(let r=0,e=qr.length;r>8;O[B++]=t&255}else if(t>-1){O[B++]=218;S.setUint32(B,t);B+=4}e.encode.call(this,a,g,w);return}}if(a[Symbol.iterator]){if(Wr){let e=new Error("Iterable should be serialized as iterator");e.iteratorNotHandled=true;throw e}O[B++]=159;for(let e of a){g(e)}O[B++]=255;return}if(a[Symbol.asyncIterator]||on(a)){let e=new Error("Iterable/blob should be serialized as iterator");e.iteratorNotHandled=true;throw e}if(this.useToJSON&&a.toJSON){const t=a.toJSON();if(t!==a)return g(t)}b(a,!a.hasOwnProperty)}}}else if(e==="boolean"){O[B++]=a?245:244}else if(e==="bigint"){if(a=0){O[B++]=27;S.setBigUint64(B,a)}else if(a>-(BigInt(1)<{let t=Object.keys(e);let r=Object.values(e);let n=t.length;if(n<24){O[B++]=160|n}else if(n<256){O[B++]=184;O[B++]=n}else if(n<65536){O[B++]=185;O[B++]=n>>8;O[B++]=n&255}else{O[B++]=186;S.setUint32(B,n);B+=4}if(u.keyMap){for(let e=0;e{O[B++]=185;let e=B-s;B+=2;let n=0;if(u.keyMap){for(let e in t)if(r||t.hasOwnProperty(e)){g(u.encodeKey(e));g(t[e]);n++}}else{for(let e in t)if(r||t.hasOwnProperty(e)){g(e);g(t[e]);n++}}O[e+++s]=n>>8;O[e+s]=n&255}:(t,r)=>{let n,i=l.transitions||(l.transitions=Object.create(null));let u=0;let a=0;let o;let s;if(this.keyMap){s=Object.keys(t).map(e=>this.encodeKey(e));a=s.length;for(let t=0;t>8|224;O[B++]=c&255}else{if(!s)s=i.__keys__||(i.__keys__=Object.keys(t));if(o===undefined){c=l.nextId++;if(!c){c=0;l.nextId=1}if(c>=Kr){l.nextId=(c=h)+1}}else{c=o}l[c]=s;if(c>8|224;O[B++]=c&255;i=l.transitions;for(let e=0;e=Kr-h)v.shift()[en]=undefined;v.push(i);un(a+2);g(57344+c);g(s);if(r===null)return;for(let e in t)if(r||t.hasOwnProperty(e))g(t[e]);return}}if(a<24){O[B++]=128|a}else{un(a)}if(r===null)return;for(let e in t)if(r||t.hasOwnProperty(e))g(t[e])};const w=e=>{let t;if(e>16777216){if(e-s>Hr)throw new Error("Encoded buffer would be larger than maximum buffer size");t=Math.min(Hr,Math.round(Math.max((e-s)*(e>67108864?1.25:2),4194304)/4096)*4096)}else t=(Math.max(e-s<<2,O.length-1)>>12)+1<<12;let r=new $r(t);S=new DataView(r.buffer,0,t);if(O.copy)O.copy(r,0,s,e);else r.set(O.slice(s,e));B-=s;s=0;Gr=r.length-10;return O=r};let D=100;let E=1e3;this.encodeAsIterable=function(e,t){return k(e,t,A)};this.encodeAsAsyncIterable=function(e,t){return k(e,t,C)};function*A(n,i,e){let t=n.constructor;if(t===Object){let r=u.useRecords!==false;if(r)b(n,null);else rn(Object.keys(n).length,160);for(let t in n){let e=n[t];if(!r)g(t);if(e&&typeof e==="object"){if(i[t])yield*A(e,i[t]);else yield*x(e,i,t)}else g(e)}}else if(t===Array){let e=n.length;un(e);for(let t=0;tD)){if(i.element)yield*A(e,i.element);else yield*x(e,i,"element")}else g(e)}}else if(n[Symbol.iterator]){O[B++]=159;for(let e of n){if(e&&(typeof e==="object"||B-s>D)){if(i.element)yield*A(e,i.element);else yield*x(e,i,"element")}else g(e)}O[B++]=255}else if(on(n)){rn(n.size,64);yield O.subarray(s,B);yield n;F()}else if(n[Symbol.asyncIterator]){O[B++]=159;yield O.subarray(s,B);yield n;F();O[B++]=255}else{g(n)}if(e&&B>s)yield O.subarray(s,B);else if(B-s>D){yield O.subarray(s,B);F()}}function*x(t,r,n){let i=B-s;try{g(t);if(B-s>D){yield O.subarray(s,B);F()}}catch(e){if(e.iteratorNotHandled){r[n]={};B=s+i;yield*A.call(this,t,r[n])}else throw e}}function F(){D=E;u.encode(null,mn)}function k(e,t,r){if(t&&t.chunkThreshold)D=E=t.chunkThreshold;else D=100;if(e&&typeof e==="object"){u.encode(null,mn);return r(e,u.iterateProperties||(u.iterateProperties={}),true)}return[u.encode(e)]}async function*C(e,t){for(let r of A(e,t,true)){let e=r.constructor;if(e===Jr||e===Uint8Array)yield r;else if(on(r)){let e=r.stream().getReader();let t;while(!(t=await e.read()).done){yield t.value}}else if(r[Symbol.asyncIterator]){for await(let e of r){F();if(e)yield*C(e,t.async||(t.async={}));else yield u.encode(e)}}else{yield r}}}}useBuffer(e){O=e;S=new DataView(O.buffer,O.byteOffset,O.byteLength);B=0}clearSharedData(){if(this.structures)this.structures=[];if(this.sharedValues)this.sharedValues=undefined}updateSharedData(){let t=this.sharedVersion||0;this.sharedVersion=t+1;let e=this.structures.slice(0);let r=new nn(e,this.sharedValues,this.sharedVersion);let n=this.saveShared(r,e=>(e&&e.version||0)==t);if(n===false){r=this.getShared()||{};this.structures=r.structures||[];this.sharedValues=r.packedValues;this.sharedVersion=r.version;this.structures.nextId=this.structures.length}else{e.forEach((e,t)=>this.structures[t]=e)}return n}}function rn(e,t){if(e<24)O[B++]=t|e;else if(e<256){O[B++]=t|24;O[B++]=e}else if(e<65536){O[B++]=t|25;O[B++]=e>>8;O[B++]=e&255}else{O[B++]=t|26;S.setUint32(B,e);B+=4}}class nn{constructor(e,t,r){this.structures=e;this.packedValues=t;this.version=r}}function un(e){if(e<24)O[B++]=128|e;else if(e<256){O[B++]=152;O[B++]=e}else if(e<65536){O[B++]=153;O[B++]=e>>8;O[B++]=e&255}else{O[B++]=154;S.setUint32(B,e);B+=4}}const an=typeof Blob==="undefined"?function(){}:Blob;function on(e){if(e instanceof an)return true;let t=e[Symbol.toStringTag];return t==="Blob"||t==="File"}function sn(r,n){switch(typeof r){case"string":if(r.length>3){if(n.objectMap[r]>-1||n.values.length>=n.maxValues)return;let e=n.get(r);if(e){if(++e.count==2){n.values.push(r)}}else{n.set(r,{count:1});if(n.samplingPackedValues){let e=n.samplingPackedValues.get(r);if(e)e.count++;else n.samplingPackedValues.set(r,{count:1})}}}break;case"object":if(r){if(r instanceof Array){for(let e=0,t=r.length;e=0&&r<4294967296){O[B++]=26;S.setUint32(B,r);B+=4}else{O[B++]=251;S.setFloat64(B,r);B+=8}}},{tag:258,encode(e,t){let r=Array.from(e);t(r)}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t(["RegExp",e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,r){ln(e,r)}},{getTag(e){if(e.constructor===Uint8Array){if(this.tagUint8Array||Yr&&this.tagUint8Array!==false)return 64}},encode(e,t,r){ln(e,r)}},fn(68,1),fn(69,2),fn(70,4),fn(71,8),fn(72,1),fn(77,2),fn(78,4),fn(79,8),fn(85,4),fn(86,8),{encode(t,n){let e=t.packedValues||[];let r=t.structures||[];if(e.values.length>0){O[B++]=216;O[B++]=51;un(4);let r=e.values;n(r);un(0);un(0);packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let e=0,t=r.length;e1)e-=4;return{tag:e,encode:function e(t,r){let n=t.byteLength;let i=t.byteOffset||0;let u=t.buffer||t;r(Yr?Vr.from(u,i,n):new Uint8Array(u,i,n))}}}function ln(e,t){let r=e.byteLength;if(r<24){O[B++]=64+r}else if(r<256){O[B++]=88;O[B++]=r}else if(r<65536){O[B++]=89;O[B++]=r>>8;O[B++]=r&255}else{O[B++]=90;S.setUint32(B,r);B+=4}if(B+r>=O.length){t(B+r)}O.set(e.buffer?e:new Uint8Array(e),B);B+=r}function hn(n,e){let r;let i=e.length*2;let u=n.length-i;e.sort((e,t)=>e.offset>t.offset?1:-1);for(let r=0;r>8;n[e]=r&255}}while(r=e.pop()){let e=r.offset;n.copyWithin(e+i,e,u);i-=2;let t=e+i;n[t++]=216;n[t++]=28;u=e}return n}function pn(e,t){S.setUint32(Qr.position+e,B-Qr.position-e+1);let r=Qr;Qr=null;t(r[0]);t(r[1])}function _n(e){if(e.Class){if(!e.encode)throw new Error("Extension has no encode function");zr.unshift(e.Class);qr.unshift(e)}Tr(e)}let dn=new tn({useRecords:false});dn.encode;dn.encodeAsIterable;dn.encodeAsAsyncIterable;const vn=512;const yn=1024;const mn=2048;var gn={}; /**@license * * No Dependency fast and small LZJB Compression for Browser and Node @@ -48,4 +48,4 @@ * Released under BSD-3-Clause License * * build: Wed, 27 Oct 2021 10:43:10 GMT - */Object.defineProperty(gn,"__esModule",{value:true});const bn=8,wn=6,Dn=3,En=(1<r-En){t[i++]=e[n++];continue}f=(e[n]+13^e[n+1]-13^e[n+2])&xn-1;c=n-l[f]&An;l[f]=n;u=n-c;if(u>=0&&u!=n&&e[n]==e[u]&&e[n+1]==e[u+1]&&e[n+2]==e[u+2]){t[a]|=o;for(s=Dn;s>bn;t[i++]=c;n+=s}else{t[i++]=e[n++]}}console.assert(e.length>=n);return i}function kn(e,t,r){t=t|0;var n=0,i=0,u=0,a=0,o=1<<(bn-1|0),s=0,c=0;while(n>(bn-wn|0))+Dn|0;c=(e[n]<4){r[i]=r[u];i=i+1|0;u=u+1|0;r[i]=r[u];i=i+1|0;u=u+1|0;r[i]=r[u];i=i+1|0;u=u+1|0;r[i]=r[u];i=i+1|0;u=u+1|0;s=s-4|0}while(s>0){r[i]=r[u];i=i+1|0;u=u+1|0;s=s-1|0}}}else{r[i]=e[n];i=i+1|0;n=n+1|0}}return i}function Cn(){const e=new TextEncoder("utf-8");return e.encode(On)}const On="@lzjb";const Sn=Cn();function Bn(...e){if(e.length>1){const r=e.reduce((e,t)=>e+t.length,0);const n=new Uint8Array(r);let t=0;e.forEach(e=>{n.set(e,t);t+=e.length});return n}else if(e.length){return e[0]}}function jn(t){const e=Math.ceil(Math.log2(t)/8);const r=new Uint8Array(e);for(let e=0;e=0;e--){r=r*256+t[e]}return r}function Pn(e,{magic:t=true}={}){const r=new Uint8Array(Math.max(e.length*1.5|0,16*1024));const n=Fn(e,r);const i=jn(e.length);const u=[Uint8Array.of(i.length),i,r.slice(0,n)];if(t){u.unshift(Sn)}return Bn(...u)}function Nn(t,{magic:e=true}={}){if(e){const e=new TextDecoder("utf-8");const s=e.decode(t.slice(0,Sn.length));if(s!==On){throw new Error("Invalid magic value")}}const r=e?Sn.length:0;const n=t[r];const i=r+1;const u=r+n+1;const a=In(t.slice(i,u));t=t.slice(u);const o=new Uint8Array(a);kn(t,t.length,o);return o}var Rn=gn.pack=Pn;var Tn=gn.unpack=Nn;function Ln(s,c){return c=c||{},new Promise(function(e,t){var r=new XMLHttpRequest,n=[],i=[],u={},a=function(){return{ok:2==(r.status/100|0),statusText:r.statusText,status:r.status,url:r.responseURL,text:function(){return Promise.resolve(r.responseText)},json:function(){return Promise.resolve(r.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([r.response]))},clone:a,headers:{keys:function(){return n},entries:function(){return i},get:function(e){return u[e.toLowerCase()]},has:function(e){return e.toLowerCase()in u}}}};for(var o in r.open(c.method||"get",s,!0),r.onload=function(){r.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,t,r){n.push(t=t.toLowerCase()),i.push([t,r]),u[t]=u[t]?u[t]+","+r:r}),e(a())},r.onerror=t,r.withCredentials="include"==c.credentials,c.headers)r.setRequestHeader(o,c.headers[o]);r.send(c.body||null)})}var Un=["token"],Mn=["env"],qn=["stderr","stdin","stdout","command_line"],zn=["use_dynamic"],Vn=["use_dynamic"],Yn=["env","dynamic_env","use_dynamic","error"];function $n(e,t,r){Jn(e,t);t.set(e,r)}function Jn(e,t){if(t.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function Kn(e,t,r){return t=V(t),G(e,Hn()?Reflect.construct(t,r||[],V(e).constructor):t.apply(e,r))}function Hn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Hn=function e(){return!!t})()}function Gn(t,e){var r=typeof Symbol!=="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Wn(t))||e&&t&&typeof t.length==="number"){if(r)t=r;var n=0;var i=function e(){};return{s:i,n:function e(){if(n>=t.length)return{done:true};return{done:false,value:t[n++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u=true,a=false,o;return{s:function e(){r=r.call(t)},n:function e(){var t=r.next();u=t.done;return t},e:function e(t){a=true;o=t},f:function e(){try{if(!u&&r["return"]!=null)r["return"]()}finally{if(a)throw o}}}}function Wn(e,t){if(!e)return;if(typeof e==="string")return Qn(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor)r=e.constructor.name;if(r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Qn(e,t)}function Qn(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r1&&arguments[1]!==undefined?arguments[1]:null;var n=arguments[1]===true;function t(e){if(!fi()){return}var t=I.get("repr")(e);if(r===null||r instanceof RegExp&&r.test(t)){console.log(I.get("type")(e)+": "+t)}if(n){console.log(e)}}if(Ua(e)){e.then(t)}else{t(e)}return e}function fi(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var t=Es&&Es.get("DEBUG",{throwError:false});if(e===null){return t===true}return(t===null||t===void 0?void 0:t.valueOf())===e.valueOf()}function li(e){return e?"(?:#".concat(e,"(?:#[ie])?|#[ie]#").concat(e,")"):"(?:#[ie])?"}function hi(e,t){return"".concat(li(e),"[+-]?").concat(t,"+/").concat(t,"+")}function pi(e,t){return"".concat(li(e),"(?:[+-]?(?:").concat(t,"+/").concat(t,"+|nan.0|inf.0|").concat(t,"+))?(?:[+-]i|[+-]?(?:").concat(t,"+/").concat(t,"+|").concat(t,"+|nan.0|inf.0)i)(?=[()[\\]\\s]|$)")}function _i(e,t){return"".concat(li(e),"[+-]?").concat(t,"+")}var di=/^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/;var vi="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)";var yi="(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|nan.0|inf.0|".concat(vi,"|[+-]?[0-9]+))?(?:").concat(vi,"|[+-](?:[0-9]+/[0-9]+|[0-9]+|nan.0|inf.0))i");var mi=new RegExp("^(#[ie])?".concat(vi,"$"),"i");function gi(e,t){var r=e==="x"?"(?!\\+|".concat(t,")"):"(?!\\.|".concat(t,")");var n="";if(e===""){n="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(t,"+/").concat(t,"+(?!").concat(t,")|[+-]?").concat(t,"+)").concat(r,")?)(").concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(t,"+/").concat(t,"+|[+-]?").concat(t,"+|[+-])i$"),"i")}var bi=function(){var u={};[[10,"","[0-9]"],[16,"x","[0-9a-fA-F]"],[8,"o","[0-7]"],[2,"b","[01]"]].forEach(function(e){var t=b(e,3),r=t[0],n=t[1],i=t[2];u[r]=gi(n,i)});return u}();var wi={alarm:"",backspace:"\b",delete:"",escape:"",newline:"\n",null:"\0",return:"\r",space:" ",tab:"\t",dle:"",soh:"",dc1:"",stx:"",dc2:"",etx:"",dc3:"",eot:"",dc4:"",enq:"",nak:"",ack:"",syn:"",bel:"",etb:"",bs:"\b",can:"",ht:"\t",em:"",lf:"\n",sub:"",vt:"\v",esc:"",ff:"\f",fs:"",cr:"\r",gs:"",so:"",rs:"",si:"",us:"",del:""};function Di(e){var t=[];var r=0;var n=e.length;while(r=55296&&i<=56319&&r1&&arguments[1]!==undefined?arguments[1]:10;var r=Ri(e);var n=r.number.split("/");var i=A({num:j([n[0],r.radix||t]),denom:j([n[1],r.radix||t])});if(r.inexact){return i.valueOf()}else{return i}}function Li(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;var r=Ri(e);if(r.inexact){return E(parseInt(r.number,r.radix||t))}return j([r.number,r.radix||t])}function Ui(e){var t=e.match(/#\\x([0-9a-f]+)$/i);var r;if(t){var n=parseInt(t[1],16);r=String.fromCodePoint(n)}else{t=e.match(/#\\([\s\S]+)$/);if(t){r=t[1]}}if(r){return h(r)}throw new Error("Parse: invalid character")}function Mi(e){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;function t(e){var t;if(e==="+"){t=j(1)}else if(e==="-"){t=j(-1)}else if(e.match(Bi)){t=j([e,i])}else if(e.match(ji)){var r=e.split("/");t=A({num:j([r[0],i]),denom:j([r[1],i])})}else if(e.match(mi)){var n=Vi(e);if(u.exact){return n.toRational()}return n}else if(e.match(/nan.0$/)){return j(NaN)}else if(e.match(/inf.0$/)){if(e[0]==="-"){return j(Number.NEGATIVE_INFINITY)}return j(Number.POSITIVE_INFINITY)}else{throw new Error("Internal Parser Error")}if(u.inexact){return E(t.valueOf())}return t}var u=Ri(e);i=u.radix||i;var r;var n=u.number.match(Pi);if(i!==10&&n){r=n}else{r=u.number.match(bi[i])}var a,o;o=t(r[2]);if(r[1]){a=t(r[1])}else{a=j(0)}if(o.cmp(0)===0&&o.__type__==="bigint"){return a}return g({im:o,re:a})}function qi(e){return parseInt(e.toString(),10)===e}function zi(e){var t=e.match(/^(([-+]?[0-9]*)(?:\.([0-9]+))?)e([-+]?[0-9]+)/i);if(t){var r=parseInt(t[4],10);var n;var i=t[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var u=t[3]&&t[3].length;if(i0){return j(u).mul(o)}}}r=E(r);if(t.exact){return r.toRational()}return r}function Yi(e){e=e.replace(/\\x([0-9a-f]+);/gi,function(e,t){return"\\u"+t.padStart(4,"0")}).replace(/\n/g,"\\n");var t=e.match(/(\\*)(\\x[0-9A-F])/i);if(t&&t[1].length%2===0){throw new Error("Invalid string literal, unclosed ".concat(t[2]))}try{return D(JSON.parse(e))}catch(e){var r=e.message.replace(/in JSON /,"").replace(/.*Error: /,"");throw new Error("Invalid string literal: ".concat(r))}}function $i(e){if(e.match(/^\|.*\|$/)){e=e.replace(/(^\|)|(\|$)/g,"");var r={t:"\t",r:"\r",n:"\n"};e=e.replace(/\\(x[^;]+);/g,function(e,t){return String.fromCharCode(parseInt("0"+t,16))}).replace(/\\(.)/g,function(e,t){return r[t]||t})}return new L(e)}function Ji(e){if(Ds.hasOwnProperty(e)){return Ds[e]}if(e.match(/^"[\s\S]*"$/)){return Yi(e)}else if(e[0]==="#"){var t=e.match(di);if(t){return new RegExp(t[1],t[2])}else if(e.match(xi)){return Ui(e)}var r=e.match(/#\\(.+)/);if(r&&Di(r[1]).length===1){return Ui(e)}}if(e.match(/[0-9a-f]|[+-]i/i)){if(e.match(Si)){return Li(e)}else if(e.match(mi)){return Vi(e)}else if(e.match(Oi)){return Ti(e)}else if(e.match(Ci)){return Mi(e)}}if(e.match(/^#[iexobd]/)){throw new Error("Invalid numeric constant: "+e)}return $i(e)}function Ki(e){return!(["(",")","[","]"].includes(e)||d.names().includes(e))}function Hi(e){return Ki(e)&&!(e.match(di)||e.match(/^"[\s\S]*"$/)||e.match(Si)||e.match(mi)||e.match(Ci)||e.match(Oi)||e.match(xi)||["#t","#f","nil","true","false"].includes(e))}var Gi=/"(?:\\[\S\s]|[^"])*"?/g;function Wi(e){if(typeof e==="string"){var t=/([-\\^$[\]()+{}?*.|])/g;return e.replace(t,"\\$1")}return e}function Qi(){this.data=[]}Qi.prototype.push=function(e){this.data.push(e)};Qi.prototype.top=function(){return this.data[this.data.length-1]};Qi.prototype.pop=function(){return this.data.pop()};Qi.prototype.is_empty=function(){return!this.data.length};function Zi(e){if(e instanceof D){e=e.valueOf()}var t=new s(e,{whitespace:true});var r=[];while(true){var n=t.peek(true);if(n===ss){break}r.push(n);t.skip()}return r}function Xi(e){var t=e.token,r=_e(e,Un);if(t.match(/^"[\s\S]*"$/)&&t.match(/\n/)){var n=new RegExp("^ {1,"+(e.col+1)+"}","mg");t=t.replace(n,"")}return T({token:t},r)}function eu(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};this.fn=e;this.cont=t}eu.prototype.toString=function(){return"#"};function tu(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof D){e=e.toString()}if(t){return Zi(e)}else{var r=Zi(e).map(function(e){if(e.token==="#\\ "||e.token=="#\\\n"){return e.token}return e.token.trim()}).filter(function(e){return e&&!e.match(/^;/)&&!e.match(/^#\|[\s\S]*\|#$/)});return iu(r)}}function iu(e){var t=0;var r=null;var n=[];for(var i=0;i0&&arguments[0]!==undefined?arguments[0]:null;if(e instanceof L){if(e.is_gensym()){return e}e=e.valueOf()}if(ou(e)){return L(e)}if(e!==null){return r(e,Symbol("#:".concat(e)))}t++;return r(t,Symbol("#:g".concat(t)))}}();function cu(e){var r=this;var n={pending:true,rejected:false,fulfilled:false,reason:undefined,type:undefined};e=e.then(function(e){n.type=z(e);n.fulfilled=true;n.pending=false;return e});f(this,"_promise",e,{hidden:true});if(m(e["catch"])){e=e["catch"](function(e){n.rejected=true;n.pending=false;n.reason=e})}Object.keys(n).forEach(function(t){Object.defineProperty(r,"__".concat(t,"__"),{enumerable:true,get:function e(){return n[t]}})});f(this,"__promise__",e);this.then=false}cu.prototype.then=function(e){return new cu(this.valueOf().then(e))};cu.prototype["catch"]=function(e){return new cu(this.valueOf()["catch"](e))};cu.prototype.valueOf=function(){if(!this._promise){throw new Error("QuotedPromise: invalid promise created")}return this._promise};cu.prototype.toString=function(){if(this.__pending__){return cu.pending_str}if(this.__rejected__){return cu.rejected_str}return"#")};cu.pending_str="#";cu.rejected_str="#";function fu(e){if(Array.isArray(e)){return Promise.all(lu(e)).then(hu)}return e}function lu(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof cu){t[r]=new ps(n)}else{t[r]=n}}return t}function hu(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof ps){t[r]=n.valueOf()}else{t[r]=n}}return t}var d={LITERAL:Symbol["for"]("literal"),SPLICE:Symbol["for"]("splice"),SYMBOL:Symbol["for"]("symbol"),names:function e(){return Object.keys(this.__list__)},type:function e(t){try{return this.get(t).type}catch(e){console.log({name:t});console.log(e);return null}},get:function e(t){return this.__list__[t]},off:function e(t){var r=this;var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(Array.isArray(t)){t.forEach(function(e){return r.off(e,n)})}else if(n===null){delete this.__events__[t]}else{this.__events__=this.__events__.filter(function(e){return e!==n})}},on:function e(t,r){var n=this;if(Array.isArray(t)){t.forEach(function(e){return n.on(e,r)})}else if(!this.__events__[t]){this.__events__[t]=[r]}else{this.__events__[t].push(r)}},trigger:function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i",new L("quote-promise"),d.LITERAL]];var mu=yu.map(function(e){return e[0]});Object.freeze(mu);Object.defineProperty(d,"__builtins__",{writable:false,value:mu});yu.forEach(function(e){var t=b(e,3),r=t[0],n=t[1],i=t[2];d.append(r,n,i)});var s=function(){function p(e){var t=this;var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},n=r.whitespace,i=n===void 0?false:n;oe(this,p);f(this,"__input__",e.replace(/\r/g,""));var u={};["_i","_whitespace","_col","_newline","_line","_state","_next","_token","_prev_char"].forEach(function(r){Object.defineProperty(t,r,{configurable:false,enumerable:false,get:function e(){return u[r]},set:function e(t){u[r]=t}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}le(p,[{key:"get",value:function e(t){return this.__internal[t]}},{key:"set",value:function e(t,r){this.__internal[t]=r}},{key:"token",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(t){var r=this._line;if(this._whitespace&&this._token==="\n"){--r}return{token:this._token,col:this._col,offset:this._i,line:r}}return this._token}},{key:"peek",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(this._i>=this.__input__.length){return ss}if(this._token){return this.token(t)}var r=this.next_token();if(r){this._token=this.__input__.substring(this._i,this._next);return this.token(t)}return ss}},{key:"skip",value:function e(){if(this._next!==null){this._token=null;this._i=this._next}}},{key:"read_line",value:function e(){var t=this.__input__.length;if(this._i>=t){return ss}for(var r=this._i;r=r){return ss}if(t+this._i>=r){return this.read_rest()}var n=this._i+t;var i=this.__input__.substring(this._i,n);var u=i.match(/\n/g);if(u){this._line+=u.length}this._i=n;return i}},{key:"peek_char",value:function e(){if(this._i>=this.__input__.length){return ss}return h(this.__input__[this._i])}},{key:"read_char",value:function e(){var t=this.peek_char();this.skip_char();return t}},{key:"skip_char",value:function e(){if(this._i1&&arguments[1]!==undefined?arguments[1]:{},n=r.prev_char,i=r["char"],u=r.next_char;var a=b(t,4),o=a[0],s=a[1],c=a[2],f=a[3];if(t.length!==5){throw new Error("Lexer: Invalid rule of length ".concat(t.length))}if(!i.match(o)){return false}if(!gu(s,n)){return false}if(!gu(c,u)){return false}if(f!==this._state){return false}return true}},{key:"next_token",value:function e(){if(this._i>=this.__input__.length){return false}var t=true;e:for(var r=this._i,n=this.__input__.length;r2&&arguments[2]!==undefined?arguments[2]:null;var i=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;if(t.length===0){throw new Error("Lexer: invalid literal rule")}if(t.length===1){return[[t,n,i,null,null]]}var u=[];for(var a=0,o=t.length;a1&&arguments[1]!==undefined?arguments[1]:{},r=t.env,n=t.meta,i=n===void 0?false:n,u=t.formatter,a=u===void 0?Xi:u;oe(this,o);if(e instanceof D){e=e.toString()}f(this,"_formatter",a,{hidden:true});f(this,"__lexer__",new s(e));f(this,"__env__",r);f(this,"_meta",i,{hidden:true});f(this,"_refs",[],{hidden:true});f(this,"_state",{parentheses:0},{hidden:true})}le(o,[{key:"resolve",value:function e(t){return this.__env__&&this.__env__.get(t,{throwError:false})}},{key:"peek",value:function(){var e=ae(C.mark(function e(){var r;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=this.__lexer__.peek(true);if(!(r===ss)){t.next=4;break}return t.abrupt("return",ss);case 4:if(!this.is_comment(r.token)){t.next=7;break}this.skip();return t.abrupt("continue",0);case 7:if(!(r.token==="#;")){t.next=14;break}this.skip();if(!(this.__lexer__.peek()===ss)){t.next=11;break}throw new Error("Lexer: syntax error eof found after comment");case 11:t.next=13;return this._read_object();case 13:return t.abrupt("continue",0);case 14:return t.abrupt("break",17);case 17:r=this._formatter(r);if(!this._meta){t.next=20;break}return t.abrupt("return",r);case 20:return t.abrupt("return",r.token);case 21:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"reset",value:function e(){this._refs.length=0}},{key:"skip",value:function e(){this.__lexer__.skip()}},{key:"read",value:function(){var e=ae(C.mark(function e(){var r;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return this.peek();case 2:r=t.sent;this.skip();return t.abrupt("return",r);case 5:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"match_datum_label",value:function e(t){var r=t.match(/^#([0-9]+)=$/);return r&&r[1]}},{key:"match_datum_ref",value:function e(t){var r=t.match(/^#([0-9]+)#$/);return r&&r[1]}},{key:"is_open",value:function e(t){var r=["(","["].includes(t);if(r){this._state.parentheses++}return r}},{key:"is_close",value:function e(t){var r=[")","]"].includes(t);if(r){this._state.parentheses--}return r}},{key:"read_list",value:function(){var e=ae(C.mark(function e(){var r,n,i,u,a;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=U,n=r;case 1:t.next=4;return this.peek();case 4:u=t.sent;if(!(u===ss)){t.next=7;break}return t.abrupt("break",32);case 7:if(!this.is_close(u)){t.next=10;break}this.skip();return t.abrupt("break",32);case 10:if(!(u==="."&&r!==U)){t.next=18;break}this.skip();t.next=14;return this._read_object();case 14:n.cdr=t.sent;i=true;t.next=30;break;case 18:if(!i){t.next=22;break}throw new Error("Parser: syntax error more than one element after dot");case 22:t.t0=M;t.next=25;return this._read_object();case 25:t.t1=t.sent;t.t2=U;a=new t.t0(t.t1,t.t2);if(r===U){r=a}else{n.cdr=a}n=a;case 30:t.next=1;break;case 32:return t.abrupt("return",r);case 33:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"read_value",value:function(){var e=ae(C.mark(function e(){var r;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return this.read();case 2:r=t.sent;if(!(r===ss)){t.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return t.abrupt("return",Ji(r));case 6:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"is_comment",value:function e(t){return t.match(/^;/)||t.match(/^#\|/)&&t.match(/\|#$/)}},{key:"evaluate",value:function e(t){return P(t,{env:this.__env__,error:function e(t){throw t}})}},{key:"read_object",value:function(){var e=ae(C.mark(function e(){var r;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:this.reset();t.next=3;return this._read_object();case 3:r=t.sent;if(r instanceof wu){r=r.valueOf()}if(!this._refs.length){t.next=7;break}return t.abrupt("return",this._resolve_object(r));case 7:return t.abrupt("return",r);case 8:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"balanced",value:function e(){return this._state.parentheses===0}},{key:"ballancing_error",value:function e(t,r){var n=this._state.parentheses;var i;if(n<0){i=new Error("Parser: unexpected parenthesis");i.__code__=[r.toString()+")"]}else{i=new Error("Parser: expected parenthesis but eof found");var u=new RegExp("\\){".concat(n,"}$"));i.__code__=[t.toString().replace(u,"")]}throw i}},{key:"_resolve_object",value:function(){var t=ae(C.mark(function e(r){var n=this;var i;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!Array.isArray(r)){t.next=2;break}return t.abrupt("return",r.map(function(e){return n._resolve_object(e)}));case 2:if(!ra(r)){t.next=6;break}i={};Object.keys(r).forEach(function(e){i[e]=n._resolve_object(r[e])});return t.abrupt("return",i);case 6:if(!(r instanceof M)){t.next=8;break}return t.abrupt("return",this._resolve_pair(r));case 8:return t.abrupt("return",r);case 9:case"end":return t.stop()}},e,this)}));function e(e){return t.apply(this,arguments)}return e}()},{key:"_resolve_pair",value:function(){var t=ae(C.mark(function e(r){return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!(r instanceof M)){t.next=15;break}if(!(r.car instanceof wu)){t.next=7;break}t.next=4;return r.car.valueOf();case 4:r.car=t.sent;t.next=8;break;case 7:this._resolve_pair(r.car);case 8:if(!(r.cdr instanceof wu)){t.next=14;break}t.next=11;return r.cdr.valueOf();case 11:r.cdr=t.sent;t.next=15;break;case 14:this._resolve_pair(r.cdr);case 15:return t.abrupt("return",r);case 16:case"end":return t.stop()}},e,this)}));function e(e){return t.apply(this,arguments)}return e}()},{key:"_read_object",value:function(){var e=ae(C.mark(function e(){var r,n,i,u,a,o,s,c,f,l,h;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return this.peek();case 2:r=t.sent;if(!(r===ss)){t.next=5;break}return t.abrupt("return",r);case 5:if(!pu(r)){t.next=38;break}n=d.get(r);i=_u(r);this.skip();a=vu(r);if(!a){t.next=14;break}t.t0=undefined;t.next=17;break;case 14:t.next=16;return this._read_object();case 16:t.t0=t.sent;case 17:o=t.t0;if(i){t.next=25;break}s=this.__env__.get(n.symbol);if(!(typeof s==="function")){t.next=25;break}if(du(r)){c=[o]}else if(o===U){c=[]}else if(o instanceof M){c=o.to_array(false)}if(!(c||a)){t.next=24;break}return t.abrupt("return",$s(s,a?[]:c,{env:this.__env__,dynamic_env:this.__env__,use_dynamic:false}));case 24:throw new Error("Parse Error: Invalid parser extension "+"invocation ".concat(n.symbol));case 25:if(du(r)){u=new M(n.symbol,new M(o,U))}else{u=new M(n.symbol,o)}if(!i){t.next=28;break}return t.abrupt("return",u);case 28:if(!(s instanceof q)){t.next=37;break}t.next=31;return this.evaluate(u);case 31:f=t.sent;if(!(f instanceof M||f instanceof L)){t.next=34;break}return t.abrupt("return",M.fromArray([L("quote"),f]));case 34:return t.abrupt("return",f);case 37:throw new Error("Parse Error: invalid parser extension: "+n.symbol);case 38:l=this.match_datum_ref(r);if(!(l!==null)){t.next=44;break}this.skip();if(!this._refs[l]){t.next=43;break}return t.abrupt("return",new wu(l,this._refs[l]));case 43:throw new Error("Parse Error: invalid datum label #".concat(l,"#"));case 44:h=this.match_datum_label(r);if(!(h!==null)){t.next=51;break}this.skip();this._refs[h]=this._read_object();return t.abrupt("return",this._refs[h]);case 51:if(!this.is_close(r)){t.next=55;break}this.skip();t.next=61;break;case 55:if(!this.is_open(r)){t.next=60;break}this.skip();return t.abrupt("return",this.read_list());case 60:return t.abrupt("return",this.read_value());case 61:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()}]);return o}();var wu=function(){function r(e,t){oe(this,r);this.name=e;this.data=t}le(r,[{key:"valueOf",value:function e(){return this.data}}]);return r}();function Du(e,t){return Eu.apply(this,arguments)}function Eu(){Eu=ge(C.mark(function e(r,n){var i,u,a;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!n){if(I){n=I.get("**interaction-environment**",{throwError:false})}else{n=Es}}i=new bu(r,{env:n});case 3:t.next=6;return ye(i.read_object());case 6:a=t.sent;if(!i.balanced()){i.ballancing_error(a,u)}if(!(a===ss)){t.next=10;break}return t.abrupt("break",15);case 10:u=a;t.next=13;return a;case 13:t.next=3;break;case 15:case"end":return t.stop()}},e)}));return Eu.apply(this,arguments)}function w(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(e){return e};var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;if(Ua(e)){var n=e.then(t);if(r===null){return n}else{return n["catch"](r)}}if(e instanceof Array){return Au(e,t,r)}if(ra(e)){return xu(e,t,r)}return t(e)}function Au(t,r,e){if(t.find(Ua)){return w(fu(t),function(e){if(Object.isFrozen(t)){Object.freeze(e)}return r(e)},e)}return r(t)}function xu(t,e,r){var i=Object.keys(t);var n=[],u=[];var a=i.length;while(a--){var o=i[a];var s=t[o];n[a]=s;if(Ua(s)){u.push(s)}}if(u.length){return w(fu(n),function(e){var n={};e.forEach(function(e,t){var r=i[t];n[r]=e});if(Object.isFrozen(t)){Object.freeze(n)}return n},r)}return e(t)}function f(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},i=n.hidden,u=i===void 0?false:i;Object.defineProperty(e,t,{value:r,configurable:true,enumerable:!u})}function Fu(e){return ku.apply(this,arguments)}function ku(){ku=ae(C.mark(function e(r){var n,i,u,a,o,s,c;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:n=[];i=false;u=false;t.prev=3;o=Xn(r);case 5:t.next=7;return o.next();case 7:if(!(i=!(s=t.sent).done)){t.next=13;break}c=s.value;n.push(c);case 10:i=false;t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15;t.t0=t["catch"](3);u=true;a=t.t0;case 19:t.prev=19;t.prev=20;if(!(i&&o["return"]!=null)){t.next=24;break}t.next=24;return o["return"]();case 24:t.prev=24;if(!u){t.next=27;break}throw a;case 27:return t.finish(24);case 28:return t.finish(19);case 29:return t.abrupt("return",n);case 30:case"end":return t.stop()}},e,null,[[3,15,19,29],[20,,24,28]])}));return ku.apply(this,arguments)}function Cu(e,t){if(t instanceof RegExp){return function(e){return String(e).match(t)}}else if(m(t)){return t}throw new Error("Invalid matcher")}function l(e,t,r,n){if(typeof e!=="string"){t=arguments[0];r=arguments[1];n=arguments[2];e=null}if(r){if(n){t.__doc__=r}else{t.__doc__=Ou(r)}}if(e){t.__name__=e}else if(t.name&&!yo(t)){t.__name__=t.name}return t}function Ou(e){return e.split("\n").map(function(e){return e.trim()}).join("\n")}function Su(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var r=e.length;if(t<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(t))}e:while(t--&&r>=0){var n=1;while(n>0){var i=e[--r];if(!i){break e}if(i==="("||i.token==="("){n--}else if(i===")"||i.token===")"){n++}}r--}return e.slice(r+1)}function Bu(e){if(!e||!e.length){return 0}var t=e.length;if(e[t-1].token==="\n"){return 0}while(--t){if(e[t].token==="\n"){var r=(e[t+1]||{}).token;if(r){return r.length}}}return 0}function ju(e,t){return f(e,t)===t.length;function f(r,n){function e(e,t){var r=Gn(e),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;var u=f(i,t);if(u!==-1){return u}}}catch(e){r.e(e)}finally{r.f()}return-1}function t(){return r[u]===Symbol["for"]("symbol")&&!Hi(n[o])}function i(){var e=r[u+1];var t=n[o+1];if(e!==undefined&&t!==undefined){return f([e],[t])}}var u=0;var a={};for(var o=0;o0){continue}}else if(t()){return-1}}else if(r[u]instanceof Array){var c=f(r[u],n.slice(o));if(c===-1||c+o>n.length){return-1}o+=c-1;u++;continue}else{return-1}u++}if(r.length!==u){return-1}return n.length}}function Iu(e){this.__code__=e.replace(/\r/g,"")}Iu.defaults={offset:0,indent:2,exceptions:{specials:[/^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|(?:call-with-(?:input-file|output-file|port))|lambda|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax|\*)?)$/],shift:{1:["&","#"]}}};Iu.match=ju;Iu.prototype._options=function e(t){var r=Iu.defaults;if(typeof t==="undefined"){return Object.assign({},r)}var n=t&&t.exceptions||{};var i=n.specials||[];var u=n.shift||{1:[]};return T(T(T({},r),t),{},{exceptions:{specials:[].concat(R(r.exceptions.specials),R(i)),shift:T(T({},u),{},{1:[].concat(R(r.exceptions.shift[1]),R(u[1]))})}})};Iu.prototype.indent=function e(t){var r=nu(this.__code__,true);return this._indent(r,t)};Iu.exception_shift=function(u,e){function t(e){if(!e.length){return false}if(e.indexOf(u)!==-1){return true}else{var t=e.filter(function(e){return e instanceof RegExp});if(!t.length){return false}var r=Gn(t),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;if(u.match(i)){return true}}}catch(e){r.e(e)}finally{r.f()}}return false}if(t(e.exceptions.specials)){return e.indent}var r=e.exceptions.shift;for(var n=0,i=Object.entries(r);n0){n.offset=0}if(u.toString()===t.toString()&&tc(u)){return n.offset+u[0].col}else if(u.length===1){return n.offset+u[0].col+1}else{var s=-1;if(a){var c=Iu.exception_shift(a.token,n);if(c!==-1){s=c}}if(s===-1){s=Iu.exception_shift(u[1].token,n)}if(s!==-1){return n.offset+u[0].col+s}else if(u[0].line3&&u[1].line===u[3].line){if(u[1].token==="("||u[1].token==="["){return n.offset+u[1].col}return n.offset+u[3].col}else if(u[0].line===u[1].line){return n.offset+n.indent+u[0].col}else{var f=u.slice(2);for(var l=0;l")};Pu.prototype.match=function(e){return e.match(this.pattern)};function Nu(){for(var e=arguments.length,t=new Array(e),r=0;r")};Iu.Pattern=Nu;Iu.Ahead=Pu;var Ru=/^[[(]$/;var Tu=/^[\])]$/;var Lu=/[^()[\]]/;var Uu=new Pu(/[^)\]]/);var Mu=Symbol["for"]("*");var qu=new Nu([Ru,Mu,Tu],[Lu],"+");var zu=new Nu([Ru,Mu,Tu],"+");var Vu=new Nu([Symbol["for"]("symbol")],"?");var Yu=new Nu([Symbol["for"]("symbol")],"*");var $u=[Ru,Yu,Tu];var Ju=new Nu([Ru,Symbol["for"]("symbol"),Mu,Tu],"+");var Ku=Wu("define","lambda","define-macro","syntax-rules");var Hu=/^(?!.*\b(?:[()[\]]|define(?:-macro)?|let(?:\*|rec|-env|-syntax|)?|lambda|syntax-rules)\b).*$/;var Gu=/^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/;function Wu(){for(var e=arguments.length,t=new Array(e),r=0;r0&&!o[e]){o[e]=Su(a,e)}});var s=Gn(i),c;try{for(s.s();!(c=s.n()).done;){var f=b(c.value,3),l=f[0],h=f[1],p=f[2];h=h.valueOf();var _=h>0?o[h]:a;var d=_.filter(function(e){return e.trim()&&!pu(e)});var v=r(_);var y=ju(l,d);var m=n.slice(u).find(function(e){return e.trim()&&!pu(e)});if(y&&(p instanceof Pu&&p.match(m)||!p)){var g=u-v;if(n[g]!=="\n"){if(!n[g].trim()){n[g]="\n"}else{n.splice(g,0,"\n");u++}}u+=v;continue e}}}catch(e){s.e(e)}finally{s.f()}}this.__code__=n.join("");return this};Iu.prototype._spaces=function(e){return" ".repeat(e)};Iu.prototype.format=function e(t){var r=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var n=nu(r,true);var i=this._options(t);var u=0;var a=0;for(var o=0;o0){n=Math.floor(t()*r);r--;var i=[e[n],e[r]];e[r]=i[0];e[n]=i[1]}return e}function Xu(){}Xu.prototype.toString=function(){return"()"};Xu.prototype.valueOf=function(){return undefined};Xu.prototype.serialize=function(){return 0};Xu.prototype.to_object=function(){return{}};Xu.prototype.append=function(e){return new M(e,U)};Xu.prototype.to_array=function(){return[]};var U=new Xu;function M(e,t){if(typeof this!=="undefined"&&this.constructor!==M||typeof this==="undefined"){return new M(e,t)}this.car=e;this.cdr=t}function ea(u,a){return function e(t){k(u,t,["pair","nil"]);if(t===U){return[]}var r=[];var n=t;while(true){if(n instanceof M){if(n.haveCycles("cdr")){break}var i=n.car;if(a&&i instanceof M){i=this.get(u).call(this,i)}r.push(i);n=n.cdr}else if(n===U){break}else{throw new Error("".concat(u,": can't convert improper list"))}}return r}}M.prototype.flatten=function(){return M.fromArray(Qu(this.to_array()))};M.prototype.length=function(){var e=0;var t=this;while(true){if(!t||t===U||!(t instanceof M)||t.haveCycles("cdr")){break}e++;t=t.cdr}return e};M.match=function(e,t){if(e instanceof L){return L.is(e,t)}else if(e instanceof M){return M.match(e.car,t)||M.match(e.cdr,t)}else if(Array.isArray(e)){return e.some(function(e){return M.match(e,t)})}else if(ra(e)){return Object.values(e).some(function(e){return M.match(e,t)})}return false};M.prototype.find=function(e){return M.match(this,e)};M.prototype.clone=function(){var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var n=new Map;function i(e){if(e instanceof M){if(n.has(e)){return n.get(e)}var t=new M;n.set(e,t);if(r){t.car=i(e.car)}else{t.car=e.car}t.cdr=i(e.cdr);t[oo]=e[oo];return t}return e}return i(this)};M.prototype.last_pair=function(){var e=this;while(true){if(e.cdr===U){return e}e=e.cdr}};M.prototype.to_array=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var t=[];if(this.car instanceof M){if(e){t.push(this.car.to_array())}else{t.push(this.car)}}else{t.push(this.car.valueOf())}if(this.cdr instanceof M){t=t.concat(this.cdr.to_array(e))}return t};M.fromArray=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(e instanceof M||r&&e instanceof Array&&e[uo]){return e}if(t===false){var n=U;for(var i=e.length;i--;){n=new M(e[i],n)}return n}if(e.length&&!(e instanceof Array)){e=R(e)}var u=U;var a=e.length;while(a--){var o=e[a];if(o instanceof Array){o=M.fromArray(o,t,r)}else if(typeof o==="string"){o=D(o)}else if(typeof o==="number"&&!Number.isNaN(o)){o=j(o)}u=new M(o,u)}return u};M.prototype.to_object=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var t=this;var r={};while(true){if(t instanceof M&&t.car instanceof M){var n=t.car;var i=n.car;if(i instanceof L){i=i.__name__}if(i instanceof D){i=i.valueOf()}var u=n.cdr;if(u instanceof M){u=u.to_object(e)}if(Ya(u)){if(!e){u=u.valueOf()}}r[i]=u;t=t.cdr}else{break}}return r};M.fromPairs=function(e){return e.reduce(function(e,t){return new M(new M(new L(t[0]),t[1]),e)},U)};M.fromObject=function(t){var e=Object.keys(t).map(function(e){return[e,t[e]]});return M.fromPairs(e)};M.prototype.reduce=function(e){var t=this;var r=U;while(true){if(t!==U){r=e(r,t.car);t=t.cdr}else{break}}return r};M.prototype.reverse=function(){if(this.haveCycles()){throw new Error("You can't reverse list that have cycles")}var e=this;var t=U;while(e!==U){var r=e.cdr;e.cdr=t;t=e;e=r}return t};M.prototype.transform=function(n){function i(e){if(e instanceof M){if(e.replace){delete e.replace;return e}var t=n(e.car);if(t instanceof M){t=i(t)}var r=n(e.cdr);if(r instanceof M){r=i(r)}return new M(t,r)}return e}return i(this)};M.prototype.map=function(e){if(typeof this.car!=="undefined"){return new M(e(this.car),this.cdr===U?U:this.cdr.map(e))}else{return U}};var ta=new Map;function ra(e){return e&&p(e)==="object"&&e.constructor===Object}var na=Object.getOwnPropertyNames(Array.prototype);var ia=[];na.forEach(function(e){ia.push(Array[e],Array.prototype[e])});function ua(e){e=Wa(e);return ia.includes(e)}function aa(e){return m(e)&&(yo(e)||e.__doc__)}function oa(r){var e=r.constructor||Object;var n=ra(r);var i=m(r[Symbol.asyncIterator])||m(r[Symbol.iterator]);var u;if(ta.has(e)){u=ta.get(e)}else{ta.forEach(function(e,t){t=Wa(t);if(r.constructor===t&&(t===Object&&n&&!i||t!==Object)){u=e}})}return u}var sa=new Map;[[true,"#t"],[false,"#f"],[null,"null"],[undefined,"#"]].forEach(function(e){var t=b(e,2),r=t[0],n=t[1];sa.set(r,n)});function ca(r){if(r&&p(r)==="object"){var n={};var e=Object.getOwnPropertySymbols(r);e.forEach(function(e){var t=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");n[t]=da(r[e])});var t=Object.getOwnPropertyNames(r);t.forEach(function(e){var t=r[e];if(t&&p(t)==="object"&&t.constructor===Object){n[e]=ca(t)}else{n[e]=da(t)}});return n}return r}function fa(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function la(e,t){return e.hasOwnProperty(t)&&m(e.toString)}function ha(e){if(bo(e)){return"#"}var t=e.prototype&&e.prototype.constructor;if(m(t)&&yo(t)){if(e[so]&&t.hasOwnProperty("__name__")){var r=t.__name__;if(D.isString(r)){r=r.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(p(n)==="symbol"){n=au(n)}if(typeof n==="string"){return"#")}}if(la(e,"toString")){return e.toString()}else if(e.name&&!yo(e)){return"#")}else{return"#"}}var pa=new Map;[[Error,function(e){return e.message}],[M,function(e,t){var r=t.quote,n=t.skip_cycles,i=t.pair_args;if(!n){e.markCycles()}return e.toString.apply(e,[r].concat(R(i)))}],[h,function(e,t){var r=t.quote;if(r){return e.toString()}return e.valueOf()}],[D,function(e,t){var r=t.quote;e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var t=b(e,2),r=t[0],n=t[1];pa.set(r,n)});var _a=[L,j,q,_s,Go,Wo,F,cu];function da(e,t,r){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(sa.has(e)){return sa.get(e)}if(va(e)){return"#"}if(e){var n=e.constructor;if(pa.has(n)){for(var i=arguments.length,u=new Array(i>3?i-3:0),a=3;a"}if(e===null){return"null"}if(p(e)==="object"){var f=e.constructor;if(!f){f=Object}var l;if(typeof f.__class__==="string"){l=f.__class__}else{var h=oa(e);if(h){if(m(h)){return h(e,t)}else{throw new Error("toString: Invalid repr value")}}l=f.name}if(m(e.toString)&&yo(e.toString)){return e.toString().valueOf()}if(z(e)==="instance"){if(yo(f)&&f.__name__){l=f.__name__.valueOf()}else if(!bo(f)){l="instance"}}if(qa(e,Symbol.iterator)){if(l){return"#")}return"#"}if(qa(e,Symbol.asyncIterator)){if(l){return"#")}return"#"}if(l!==""){return"#<"+l+">"}return"#"}if(typeof e!=="string"){return e.toString()}return e}function va(e){return e&&p(e)==="object"&&e.hasOwnProperty&&e.hasOwnProperty("constructor")&&typeof e.constructor==="function"&&e.constructor.prototype===e}M.prototype.markCycles=function(){ya(this);return this};M.prototype.haveCycles=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(!e){return this.haveCycles("car")||this.haveCycles("cdr")}return!!(this[oo]&&this[oo][e])};function ya(e){var t=[];var i=[];var u=[];function a(e){if(!t.includes(e)){t.push(e)}}function o(e,t,r,n){if(r instanceof M){if(n.includes(r)){if(!u.includes(r)){u.push(r)}if(!e[oo]){e[oo]={}}e[oo][t]=r;if(!i.includes(e)){i.push(e)}return true}}}var s=tu(function e(t,r){if(t instanceof M){delete t.ref;delete t[oo];a(t);r.push(t);var n=o(t,"car",t.car,r);var i=o(t,"cdr",t.cdr,r);if(!n){s(t.car,r.slice())}if(!i){return new eu(function(){return e(t.cdr,r.slice())})}}});function r(e,t){if(e[oo][t]instanceof M){var r=n.indexOf(e[oo][t]);e[oo][t]="#".concat(r,"#")}}s(e,[]);var n=t.filter(function(e){return u.includes(e)});n.forEach(function(e,t){e[ao]="#".concat(t,"=")});i.forEach(function(e){r(e,"car");r(e,"cdr")})}M.prototype.toString=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.nested,n=r===void 0?false:r;var i=[];if(this[ao]){i.push(this[ao]+"(")}else if(!n){i.push("(")}var u;if(this[oo]&&this[oo].car){u=this[oo].car}else{u=da(this.car,e,true)}if(u!==undefined){i.push(u)}if(this.cdr instanceof M){if(this[oo]&&this[oo].cdr){i.push(" . ");i.push(this[oo].cdr)}else{if(this.cdr[ao]){i.push(" . ")}else{i.push(" ")}var a=this.cdr.toString(e,{nested:true});i.push(a)}}else if(this.cdr!==U){i=i.concat([" . ",da(this.cdr,e,true)])}if(!n||this[ao]){i.push(")")}return i.join("")};M.prototype.set=function(e,t){this[e]=t;if(t instanceof M){this.markCycles()}};M.prototype.append=function(e){if(e instanceof Array){return this.append(M.fromArray(e))}var t=this;if(t.car===undefined){if(e instanceof M){this.car=e.car;this.cdr=e.cdr}else{this.car=e}}else if(e!==U){while(true){if(t instanceof M&&t.cdr!==U){t=t.cdr}else{break}}t.cdr=e}return this};M.prototype.serialize=function(){return[this.car,this.cdr]};M.prototype[Symbol.iterator]=function(){var r=this;return{next:function e(){var t=r;r=t.cdr;if(t===U){return{value:undefined,done:true}}else{return{value:t.car,done:false}}}}};function ma(e){return e<0?-e:e}function ga(e,t){var r=re(t),n=r[0],i=r.slice(1);while(i.length>0){var u=i,a=b(u,1),o=a[0];if(!e(n,o)){return false}var s=i;var c=re(s);n=c[0];i=c.slice(1)}return true}function ba(e,t){if(m(e)){return m(t)&&Wa(e)===Wa(t)}else if(e instanceof j){if(!(t instanceof j)){return false}var r;if(e.__type__===t.__type__){if(e.__type__==="complex"){r=e.__im__.__type__===t.__im__.__type__&&e.__re__.__type__===t.__re__.__type__}else{r=true}if(r&&e.cmp(t)===0){if(e.valueOf()===0){return Object.is(e.valueOf(),t.valueOf())}return true}}return false}else if(typeof e==="number"){if(typeof t!=="number"){return false}if(Number.isNaN(e)){return Number.isNaN(t)}if(e===Number.NEGATIVE_INFINITY){return t===Number.NEGATIVE_INFINITY}if(e===Number.POSITIVE_INFINITY){return t===Number.POSITIVE_INFINITY}return ba(j(e),j(t))}else if(e instanceof h){if(!(t instanceof h)){return false}return e.__char__===t.__char__}else{return e===t}}function wa(e,t){if(z(e)!==z(t)){return false}if(!Da(e)){return false}if(e instanceof RegExp){return e.source===t.source}if(e instanceof D){return e.valueOf()===t.valueOf()}return ba(e,t)}function Da(e){return e instanceof L||D.isString(e)||e===U||e===null||e instanceof h||e instanceof j||e===true||e===false}var Ea=function(){if(Math.trunc){return Math.trunc}else{return function(e){if(e===0){return 0}else if(e<0){return Math.ceil(e)}else{return Math.floor(e)}}}}();function q(e,t,r,n){if(typeof this!=="undefined"&&this.constructor!==q||typeof this==="undefined"){return new q(e,t)}k("Macro",e,"string",1);k("Macro",t,"function",2);if(r){if(n){this.__doc__=r}else{this.__doc__=Ou(r)}}this.__name__=e;this.__fn__=t}q.defmacro=function(e,t,r,n){var i=new q(e,t,r,n);i.__defmacro__=true;return i};q.prototype.invoke=function(e,t,r){var n=t.env,i=_e(t,Mn);var u=T(T({},i),{},{macro_expand:r});var a=this.__fn__.call(n,e,u,this.__name__);return a};q.prototype.toString=function(){return"#")};var Aa="define-macro";var xa=-1e4;function Fa(c){return function(){var r=ae(C.mark(function e(r,m){var u,g,n,i,a,b,w,D,E,A,x,F,o,k,s;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:s=function e(){s=ae(C.mark(function e(r,n,i){var u,a,o,s,c,f,l,h,p,_,d,v,y;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!(r instanceof M&&r.car instanceof L)){t.next=50;break}if(!r[uo]){t.next=3;break}return t.abrupt("return",r);case 3:u=r.car.valueOf();a=i.get(r.car,{throwError:false});o=b(r.car);s=o||w(a,r)||D(a);if(!(s&&r.cdr.car instanceof M)){t.next=28;break}if(!o){t.next=15;break}g=A(r.cdr.car);t.next=12;return F(r.cdr.car,n);case 12:c=t.sent;t.next=17;break;case 15:g=E(r.cdr.car);c=r.cdr.car;case 17:t.t0=M;t.t1=r.car;t.t2=M;t.t3=c;t.next=23;return k(r.cdr.cdr,n,i);case 23:t.t4=t.sent;t.t5=new t.t2(t.t3,t.t4);return t.abrupt("return",new t.t0(t.t1,t.t5));case 28:if(!x(u,a)){t.next=50;break}f=a instanceof ka?r:r.cdr;t.next=32;return a.invoke(f,T(T({},m),{},{env:i}),true);case 32:l=t.sent;if(!(a instanceof ka)){t.next=41;break}h=l,p=h.expr,_=h.scope;if(!(p instanceof M)){t.next=40;break}if(!(n!==-1&&n<=1||n")}return"#"};ka.className="syntax";var Ca=function(e){W(t,e);function t(){oe(this,t);return Kn(this,t,arguments)}return le(t)}(ka);ka.Parameter=Ca;function Oa(e,t,w,D){var r=arguments.length>4&&arguments[4]!==undefined?arguments[4]:{};var E={"...":{symbols:{},lists:[]},symbols:{}};var A=r.expansion,x=r.define;function F(e){if(fi()){console.log(e)}}F(w);function k(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;F({code:t&&da(t,true),pattern:e&&da(e,true)});if(Da(e)&&!(e instanceof L)){return wa(e,t)}if(e instanceof L&&w.includes(e.literal())){var i=A.ref(t);if(L.is(t,e)){if(typeof i==="undefined"){return true}return i===x||i===I}return false}if(e instanceof M&&e.car instanceof M&&e.car.cdr instanceof M&&L.is(e.car.cdr.car,D)){F(">> 0");if(t===U){F({pattern:e.toString()});if(e.car.car instanceof L){if(e.car.cdr instanceof M&&L.is(e.car.cdr.car,D)){var u=e.car.car.valueOf();var a=e.last_pair();if(L.is(a.car,D)){E["..."].symbols[u]=null;return true}else{return false}}var o=e.car.car.valueOf();if(E["..."].symbols[o]){throw new Error("syntax: named ellipsis can only "+"appear onces")}E["..."].symbols[o]=t}}}if(e instanceof M&&e.cdr instanceof M&&L.is(e.cdr.car,D)){if(e.cdr.cdr!==U){if(e.cdr.cdr instanceof M){var s=e.cdr.cdr.length();if(!Ra(t)){throw new Error("syntax-rules: no matching syntax")}var c=t.length();var f=t;while(c-1>s){f=f.cdr;c--}var l=f.cdr;f.cdr=U;if(!k(e.cdr.cdr,l,r,n)){return false}}}if(e.car instanceof L){var h=e.car.__name__;if(E["..."].symbols[h]&&!r.includes(h)&&!n){throw new Error("syntax: named ellipsis can only appear onces")}F(">> 1");if(t===U){F(">> 2");if(n){F("NIL");E["..."].symbols[h]=U}else{F("NULL");E["..."].symbols[h]=null}}else if(t instanceof M&&(t.car instanceof M||t.car===U)){F(">> 3 "+n);if(n){if(E["..."].symbols[h]){var p=E["..."].symbols[h];if(p===U){p=new M(U,new M(t,U))}else{p=p.append(new M(t,U))}E["..."].symbols[h]=p}else{E["..."].symbols[h]=new M(t,U)}}else{F(">> 4");E["..."].symbols[h]=new M(t,U)}}else{F(">> 6");if(t instanceof M){F(">> 7 "+n);r.push(h);if(!E["..."].symbols[h]){E["..."].symbols[h]=new M(t,U)}else{var _=E["..."].symbols[h];E["..."].symbols[h]=_.append(new M(t,U))}F({IIIIII:E["..."].symbols[h].toString()})}else{F(">> 8");return false}}return true}else if(e.car instanceof M){var d=R(r);if(t===U){F(">> 9");E["..."].lists.push(U);return true}F(">> 10");var v=t;while(v instanceof M){if(!k(e.car,v.car,d,true)){return false}v=v.cdr}return true}return false}if(e instanceof L){if(L.is(e,D)){throw new Error("syntax: invalid usage of ellipsis")}F(">> 11");var y=e.__name__;if(w.includes(y)){return true}F({name:y,ellipsis:n});if(n){E["..."].symbols[y]=E["..."].symbols[y]||[];E["..."].symbols[y].push(t)}E.symbols[y]=t;if(!E.symbols[y]);return true}if(e instanceof M&&t instanceof M){F(">> 12");F({a:12,code:t&&t.toString(),pattern:e.toString()});if(t.cdr===U){var m=e.car instanceof L&&e.cdr instanceof L;if(m){if(!k(e.car,t.car,r,n)){return false}F(">> 12 | 1");var g=e.cdr.valueOf();if(!(g in E.symbols)){E.symbols[g]=U}g=e.car.valueOf();if(!(g in E.symbols)){E.symbols[g]=t.car}return true}}F({pattern:e.toString(),code:t.toString()});if(e.cdr instanceof M&&e.cdr.cdr instanceof M&&e.cdr.car instanceof L&&L.is(e.cdr.cdr.car,D)&&e.cdr.cdr.cdr instanceof M&&!L.is(e.cdr.cdr.cdr.car,D)&&k(e.car,t.car,r,n)&&k(e.cdr.cdr.cdr,t.cdr,r,n)){var b=e.cdr.car.__name__;F({pattern:e.car.toString(),code:t.car.toString(),name:b});if(w.includes(b)){return true}E["..."].symbols[b]=null;return true}F("recur");if(k(e.car,t.car,r,n)&&k(e.cdr,t.cdr,r,n)){return true}}else if(e===U&&(t===U||t===undefined)){return true}else if(e.car instanceof M&&L.is(e.car.car,D)){throw new Error("syntax: invalid usage of ellipsis")}else{return false}}if(k(e,t)){return E}}function Sa(e,i){function u(t){if(t instanceof M){if(!i.length){return t}var e=u(t.car);var r=u(t.cdr);return new M(e,r)}else if(t instanceof L){var n=i.find(function(e){return e.gensym===t});if(n){return L(n.name)}return t}else{return t}}return u(e)}function Ba(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var k=e.bindings,t=e.expr,C=e.scope,a=e.symbols,c=e.names,O=e.ellipsis;var f={};function o(e){if(e instanceof L){return true}return["string","symbol"].includes(p(e))}function S(e){if(!o(e)){var t=z(e);throw new Error("syntax: internal error, need symbol got ".concat(t))}var r=e.valueOf();if(r===O){throw new Error("syntax: internal error, ellipis not transformed")}var n=p(r);if(["string","symbol"].includes(n)){if(r in k.symbols){return k.symbols[r]}else if(n==="string"&&r.match(/\./)){var i=r.split(".");var u=i[0];if(u in k.symbols){return M.fromArray([L("."),k.symbols[u]].concat(i.slice(1).map(function(e){return D(e)})))}}}if(a.includes(r)){return L(r)}return s(r)}function B(e){if(fi()){console.log(e)}}function s(e){if(!f[e]){var t=C.ref(e);var r=su(e);if(t){var n=C.get(e);C.set(r,n)}else{var i=C.get(e,{throwError:false});if(typeof i!=="undefined"){C.set(r,i)}}c.push({name:e,gensym:r});f[e]=r;if(typeof e==="string"&&e.match(/\./)){var u=e.split(".").filter(Boolean),a=re(u),o=a[0],s=a.slice(1);if(f[o]){_o(r,"__object__",[f[o]].concat(R(s)))}}}return f[e]}function j(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:function(){};var i=r.nested;B(" ==> "+e.toString(true));B(t);if(e instanceof L){var u=e.valueOf();B("[t 1");if(t[u]){if(t[u]instanceof M){var a=t[u],o=a.car,s=a.cdr;if(i){var c=o.car,f=o.cdr;if(f!==U){n(u,new M(f,U))}return c}if(s!==U){n(u,s)}return o}else if(t[u]instanceof Array){n(u,t[u].slice(1));return t[u][0]}}return S(u)}if(e instanceof M){if(e.car instanceof L&&e.cdr instanceof M&&L.is(e.cdr.car,O)){B("[t 2");var l=e.car.valueOf();var h=t[l];B({expr:e.toString(true),name:l,bindings:t,item:h});if(h===null){return}else if(h){B({b:t[l].toString()});if(h instanceof M){B("[t 2 Pair "+i);B({______:h.toString()});var p=h.car,_=h.cdr;if(i){if(_!==U){B("|| next 1");n(l,_)}B({car:p.toString()});return p}else{if(p.cdr!==U){B("|| next 2");n(l,new M(p.cdr,_))}B({car:p.car.toString()});return p.car}}else if(h instanceof Array){B("[t 2 Array "+i);if(i){n(l,h.slice(1));return M.fromArray(h)}else{var d=h.slice(1);if(d.length){n(l,d)}return h[0]}}else{return h}}}B("[t 3 recur "+e.toString());var v=j(e.car,t,r,n);var y=j(e.cdr,t,r,n);return new M(v,y)}return e}function I(t,r){var e=Object.values(t);var n=Object.getOwnPropertySymbols(t);if(n.length){e.push.apply(e,R(n.map(function(e){return t[e]})))}return e.length&&e.every(function(e){if(e===null){return!r}return e instanceof M||e===U||e instanceof Array&&e.length})}function P(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function N(i){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},t=e.disabled;B("traverse>> "+da(i));if(i instanceof M){if(!t&&i.car instanceof M&&L.is(i.car.car,O)){return N(i.car.cdr,{disabled:true})}if(i.cdr instanceof M&&L.is(i.cdr.car,O)&&!t){B(">> 1");var r=k["..."].symbols;var n=Object.values(r);if(n.length&&n.every(function(e){return e===null})){return N(i.cdr.cdr,{disabled:t})}var u=P(r);var a=i.car instanceof L&&L.is(i.cdr.cdr.car,O);if(i.car instanceof M||a){if(k["..."].lists[0]===U){return U}var o=i.car;if(a){o=new M(i.car,new M(i.cdr.car,U))}B(">> 2");var s;if(u.length){B(">> 2 (a)");var c=T({},r);s=U;var f=function e(){if(!I(c)){return 1}var n={};var t=function e(t,r){n[t]=r};var r=j(o,c,{nested:true},t);if(r!==undefined){if(a){if(s===U){s=r}else{s=s.append(r)}}else{s=new M(r,s)}}c=n};while(true){if(f())break}if(s!==U&&!a){s=s.reverse()}if(i.cdr.cdr!==U&&!L.is(i.cdr.cdr.car,O)){var l=N(i.cdr.cdr,{disabled:t});return s.append(l)}return s}else{B(">> 3");var h=j(i.car,r,{nested:true});if(h){return new M(h,U)}return U}}else if(i.car instanceof L){B(">> 4");if(L.is(i.cdr.cdr.car,O)){B(">> 4 (a)")}else{B(">> 4 (b)")}var p=i.car.__name__;var _=he({},p,r[p]);var d=r[p]===null;var v=U;var y=function e(){if(!I(_,true)){B({bind:_});return 1}var n={};var t=function e(t,r){n[t]=r};var r=j(i,_,{nested:false},t);B({value:r.toString()});if(typeof r!=="undefined"){v=new M(r,v)}_=n};while(true){if(y())break}if(v!==U){v=v.reverse()}if(i.cdr instanceof M){if(i.cdr.cdr instanceof M||i.cdr.cdr instanceof L){var m=N(i.cdr.cdr,{disabled:t});if(d){return m}B("<<<< 1");v.append(m)}}B("<<<< 2");return v}}var g=N(i.car,{disabled:t});var b;var w;if(i.car instanceof L){var D=C.get(i.car,{throwError:false});w=D instanceof q&&D.__name__==="syntax-rules"}if(w){if(i.cdr.car instanceof L){b=new M(N(i.cdr.car,{disabled:t}),new M(i.cdr.cdr.car,N(i.cdr.cdr.cdr,{disabled:t})))}else{b=new M(i.cdr.car,N(i.cdr.cdr,{disabled:t}))}B("REST >>>> "+b.toString())}else{b=N(i.cdr,{disabled:t})}B({a:true,car:da(i.car),cdr:da(i.cdr),head:da(g),rest:da(b)});return new M(g,b)}if(i instanceof L){if(t&&L.is(i,O)){return i}var E=Object.keys(k["..."].symbols);var A=i.literal();if(E.includes(A)){var x="missing ellipsis symbol next to name `".concat(A,"'");throw new Error("syntax-rules: ".concat(x))}var F=S(i);if(typeof F!=="undefined"){return F}}return i}return N(t,{})}function ja(e){return Ma(e)||e===U||e===null}function m(e){return typeof e==="function"&&typeof e.bind==="function"}function Ia(e){return e instanceof Qs}function Pa(e){return e instanceof Gs}function Na(e){return e instanceof Hs}function Ra(e){return e instanceof M}function Ta(e){return e instanceof F}function La(e){return m(e)||Ia(e)||Na(e)}function Ua(e){if(e instanceof cu){return false}if(e instanceof Promise){return true}return!!e&&m(e.then)}function Ma(e){return typeof e==="undefined"}function qa(e,t){if($a(e,t)||$a(e.__proto__,t)){return m(e[t])}}function za(e){if(!e){return false}if(p(e)!=="object"){return false}if(e.__instance__){e.__instance__=false;return e.__instance__}return false}function Va(e){var t=p(e);return["string","function"].includes(t)||p(e)==="symbol"||e instanceof cu||e instanceof L||e instanceof j||e instanceof D||e instanceof RegExp}function Ya(e){return e instanceof j||e instanceof D||e instanceof h}function $a(e,t){if(e===null){return false}return p(e)==="object"&&t in Object.getOwnPropertySymbols(e)}function Ja(e){switch(p(e)){case"string":return D(e);case"bigint":return j(e);case"number":if(Number.isNaN(e)){return ws}else{return j(e)}}return e}function Ka(r,n){var e=Object.getOwnPropertyNames(r);var t=Object.getOwnPropertySymbols(r);var i={};e.concat(t).forEach(function(e){var t=n(r[e]);i[e]=t});return i}function Ha(t){var e=[D,j].some(function(e){return t instanceof e});if(e){return t.valueOf()}if(t instanceof Array){return t.map(Ha)}if(t instanceof cu){delete t.then}if(ra(t)){return Ka(t,Ha)}return t}function Ga(e,t){if(e instanceof M){e.markCycles();return ds(e)}if(m(e)){if(t){return Qa(e,t)}}return Ja(e)}function Wa(e){if(Xa(e)){return e[io]}return e}function Qa(e,t){if(e[Symbol["for"]("__bound__")]){return e}var r=e.bind(t);var n=Object.getOwnPropertyNames(e);var i=Gn(n),u;try{for(i.s();!(u=i.n()).done;){var a=u.value;if(po(a)){try{r[a]=e[a]}catch(e){}}}}catch(e){i.e(e)}finally{i.f()}_o(r,"__fn__",e);_o(r,"__context__",t);_o(r,"__bound__",true);if(bo(e)){_o(r,"__native__",true)}if(ra(t)&&yo(e)){_o(r,"__method__",true)}r.valueOf=function(){return e};return r}function Za(e){return Xa(e)&&e[Symbol["for"]("__context__")]===Object}function Xa(e){return!!(m(e)&&e[io])}function eo(e){if(m(e)){var t=e[no];if(t&&(t===Pc||t.constructor&&t.constructor.__class__)){return true}}return false}function to(e){return e instanceof Go||e instanceof Wo}function ro(e){if(m(e)){if(to(e[no])){return true}}return false}var no=Symbol["for"]("__context__");var io=Symbol["for"]("__fn__");var uo=Symbol["for"]("__data__");var ao=Symbol["for"]("__ref__");var oo=Symbol["for"]("__cycles__");var so=Symbol["for"]("__class__");var co=Symbol["for"]("__method__");var fo=Symbol["for"]("__prototype__");var lo=Symbol["for"]("__lambda__");var ho=["name","length","caller","callee","arguments","prototype"];function po(e){return!ho.includes(e)}function _o(e,t,r){Object.defineProperty(e,Symbol["for"](t),{get:function e(){return r},set:function e(){},configurable:false,enumerable:false})}function vo(t,r){try{Object.defineProperty(t,"length",{get:function e(){return r}});return t}catch(e){var n=new Array(r).fill(0).map(function(e,t){return"a"+t}).join(",");var i=new Function("f","return function(".concat(n,") {\n return f.apply(this, arguments);\n };"));return i(t)}}function yo(e){return e&&e[lo]}function mo(e){return e&&e[co]}function go(e){return yo(e)&&!e[fo]&&!mo(e)&&!ro(e)}function bo(e){var t=Symbol["for"]("__native__");return m(e)&&e.toString().match(/\{\s*\[native code\]\s*\}/)&&(e.name.match(/^bound /)&&e[t]===true||!e.name.match(/^bound /)&&!e[t])}function wo(e){var b;switch(e){case Symbol["for"]("letrec"):b="letrec";break;case Symbol["for"]("let"):b="let";break;case Symbol["for"]("let*"):b="let*";break;default:throw new Error("Invalid let_macro value")}return q.defmacro(b,function(t,e){var f=e.dynamic_env;var l=e.error,r=e.macro_expand,h=e.use_dynamic;var p;if(t.car instanceof L){if(!(t.cdr.car instanceof M||t.cdr.car===U)){throw new Error("let require list of pairs")}var n;if(t.cdr.car===U){p=U;n=U}else{n=t.cdr.car.map(function(e){return e.car});p=t.cdr.car.map(function(e){return e.cdr.car})}return M.fromArray([L("letrec"),[[t.car,M(L("lambda"),M(n,t.cdr.cdr))]],M(t.car,p)])}else if(r){return}var _=this;p=I.get("list->array")(t.car);var d=_.inherit(b);var v,y;if(b==="let*"){y=d}else if(b==="let"){v=[]}var m=0;function g(){var e=new M(new L("begin"),t.cdr);return P(e,{env:d,dynamic_env:d,use_dynamic:h,error:l})}return function t(){var r=p[m++];f=b==="let*"?d:_;if(!r){if(v&&v.length){var e=v.map(function(e){return e.value});var n=e.filter(Ua);if(n.length){return fu(e).then(function(e){for(var t=0,r=e.length;t1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=this;var u=this;var a=[];var o=e;while(o instanceof M){a.push(P(o.car,{env:i,dynamic_env:u,use_dynamic:r,error:n}));o=o.cdr}var s=a.filter(Ua).length;if(s){return fu(a).then(c.bind(this))}else{return c.call(this,a)}})}function Eo(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2?n-2:0),u=2;u1&&arguments[1]!==undefined?arguments[1]:null;return function(){for(var e=arguments.length,t=new Array(e),r=0;r1?e-1:0),r=1;r=a){return u.apply(this,n)}else{return i}}return i.apply(this,arguments)}}function jo(n,i){k("limit",i,"function",2);return function(){for(var e=arguments.length,t=new Array(e),r=0;r1){e=e.toLowerCase();if(h.__names__[e]){t=e;e=h.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{t=h.__rev_names__[e]}Object.defineProperty(this,"__char__",{value:e,enumerable:true});if(t){Object.defineProperty(this,"__name__",{value:t,enumerable:true})}}h.__names__=wi;h.__rev_names__={};Object.keys(h.__names__).forEach(function(e){var t=h.__names__[e];h.__rev_names__[t]=e});h.prototype.toUpperCase=function(){return h(this.__char__.toUpperCase())};h.prototype.toLowerCase=function(){return h(this.__char__.toLowerCase())};h.prototype.toString=function(){return"#\\"+(this.__name__||this.__char__)};h.prototype.valueOf=h.prototype.serialize=function(){return this.__char__};function D(e){if(typeof this!=="undefined"&&!(this instanceof D)||typeof this==="undefined"){return new D(e)}if(e instanceof Array){this.__string__=e.map(function(e,t){k("LString",e,"character",t+1);return e.toString()}).join("")}else{this.__string__=e.valueOf()}}{var Io=["length","constructor"];var Po=Object.getOwnPropertyNames(String.prototype).filter(function(e){return!Io.includes(e)});var No=function e(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r0){r.push(this.__string__.substring(0,e))}r.push(t);if(e1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof j){return e}if(typeof this!=="undefined"&&!(this instanceof j)||typeof this==="undefined"){return new j(e,t)}if(typeof e==="undefined"){throw new Error("Invalid LNumber constructor call")}var r=j.getType(e);if(j.types[r]){return j.types[r](e,t)}var n=e instanceof Array&&D.isString(e[0])&&j.isNumber(e[1]);if(e instanceof j){return j(e.value)}if(!j.isNumber(e)&&!n){throw new Error("You can't create LNumber from ".concat(z(e)))}if(e===null){e=0}var i;if(n){var u=e,a=b(u,2),o=a[0],s=a[1];if(o instanceof D){o=o.valueOf()}if(s instanceof j){s=s.valueOf()}var c=o.match(/^([+-])/);var f=false;if(c){o=o.replace(/^[+-]/,"");if(c[1]==="-"){f=true}}}if(Number.isNaN(e)){return E(e)}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(n){var l;switch(s){case 8:l="0o";break;case 16:l="0x";break;case 2:l="0b";break;case 10:l="";break}if(typeof l==="undefined"){var h=BigInt(s);i=R(o).map(function(e,t){return BigInt(parseInt(e,s))*Vo(h,BigInt(t))}).reduce(function(e,t){return e+t})}else{i=BigInt(l+o)}}else{i=BigInt(e)}if(f){i*=BigInt(-1)}}else{i=e}return x(i,true)}else if(typeof oi!=="undefined"&&!(e instanceof oi)){if(e instanceof Array){return x(K(oi,R(e)))}return x(new oi(e))}else if(n){this.constant(parseInt(o,s),"integer")}else{this.constant(e,"integer")}}j.prototype.constant=function(e,t){Object.defineProperty(this,"__value__",{value:e,enumerable:true});Object.defineProperty(this,"__type__",{value:t,enumerable:true})};j.types={float:function e(t){return new E(t)},complex:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!j.isComplex(t)){t={im:0,re:t}}return new g(t,r)},rational:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!j.isRational(t)){t={num:t,denom:1}}return new A(t,r)}};j.prototype.serialize=function(){return this.__value__};j.prototype.isNaN=function(){return Number.isNaN(this.__value__)};j.prototype.gcd=function(e){var t=this.abs();e=e.abs();if(e.cmp(t)===1){var r=t;t=e;e=r}while(true){t=t.rem(e);if(t.cmp(0)===0){return e}e=e.rem(t);if(e.cmp(0)===0){return t}}};j.isFloat=function e(t){return t instanceof E||Number(t)===t&&t%1!==0};j.isNumber=function(e){return e instanceof j||j.isNative(e)||j.isBN(e)};j.isComplex=function(e){if(!e){return false}var t=e instanceof g||(j.isNumber(e.im)||Number.isNaN(e.im))&&(j.isNumber(e.re)||Number.isNaN(e.re));return t};j.isRational=function(e){if(!e){return false}return e instanceof A||j.isNumber(e.num)&&j.isNumber(e.denom)};j.isInteger=function(e){if(!(j.isNative(e)||e instanceof j)){return false}if(j.isFloat(e)){return false}if(j.isRational(e)){return false}if(j.isComplex(e)){return false}return true};j.isNative=function(e){return typeof e==="bigint"||typeof e==="number"};j.isBigInteger=function(e){return e instanceof x||typeof e==="bigint"||j.isBN(e)};j.isBN=function(e){return typeof oi!=="undefined"&&e instanceof oi};j.getArgsType=function(e,t){if(e instanceof E||t instanceof E){return E}if(e instanceof x||t instanceof x){return x}return j};j.prototype.toString=function(e){if(Number.isNaN(this.__value__)){return"+nan.0"}if(e>=2&&e<36){return this.__value__.toString(e)}return this.__value__.toString()};j.prototype.asType=function(e){var t=j.getType(this);return j.types[t]?j.types[t](e):j(e)};j.prototype.isBigNumber=function(){return typeof this.__value__==="bigint"||typeof oi!=="undefined"&&!(this.value instanceof oi)};["floor","ceil","round"].forEach(function(e){j.prototype[e]=function(){if(this["float"]||j.isFloat(this.__value__)){return j(Math[e](this.__value__))}else{return j(Math[e](this.valueOf()))}}});j.prototype.valueOf=function(){if(j.isNative(this.__value__)){return Number(this.__value__)}else if(j.isBN(this.__value__)){return this.__value__.toNumber()}};var Uo=function(){var e=function e(t,r){return[t,r]};return{bigint:{bigint:e,float:function e(t,r){return[E(t.valueOf()),r]},rational:function e(t,r){return[{num:t,denom:1},r]},complex:function e(t,r){return[{im:0,re:t},r]}},integer:{integer:e,float:function e(t,r){return[E(t.valueOf()),r]},rational:function e(t,r){return[{num:t,denom:1},r]},complex:function e(t,r){return[{im:0,re:t},r]}},float:{bigint:function e(t,r){return[t,r&&E(r.valueOf())]},integer:function e(t,r){return[t,r&&E(r.valueOf())]},float:e,rational:function e(t,r){return[t,r&&E(r.valueOf())]},complex:function e(t,r){return[{re:t,im:E(0)},r]}},complex:{bigint:t("bigint"),integer:t("integer"),float:t("float"),rational:t("rational"),complex:function e(t,r){var n=j.coerce(t.__re__,r.__re__),i=b(n,2),u=i[0],a=i[1];var o=j.coerce(t.__im__,r.__im__),s=b(o,2),c=s[0],f=s[1];return[{im:c,re:u},{im:f,re:a}]}},rational:{bigint:function e(t,r){return[t,r&&{num:r,denom:1}]},integer:function e(t,r){return[t,r&&{num:r,denom:1}]},float:function e(t,r){return[E(t.valueOf()),r]},rational:e,complex:function e(t,r){return[{im:Mo(t.__type__,r.__im__.__type__,0)[0],re:Mo(t.__type__,r.__re__.__type__,t)[0]},{im:Mo(t.__type__,r.__im__.__type__,r.__im__)[0],re:Mo(t.__type__,r.__re__.__type__,r.__re__)[0]}]}}};function t(r){return function(e,t){return[{im:Mo(r,e.__im__.__type__,0,e.__im__)[1],re:Mo(r,e.__re__.__type__,0,e.__re__)[1]},{im:Mo(r,e.__im__.__type__,0,0)[1],re:Mo(r,t.__type__,0,t)[1]}]}}}();function Mo(e,t,r,n){return Uo[e][t](r,n)}j.coerce=function(e,t){var r=j.getType(e);var n=j.getType(t);if(!Uo[r]){throw new Error("LNumber::coerce unknown lhs type ".concat(r))}else if(!Uo[r][n]){throw new Error("LNumber::coerce unknown rhs type ".concat(n))}var i=Uo[r][n](e,t);return i.map(function(e){return j(e,true)})};j.prototype.coerce=function(e){if(!(typeof e==="number"||e instanceof j)){throw new Error("LNumber: you can't coerce ".concat(z(e)))}if(typeof e==="number"){e=j(e)}return j.coerce(this,e)};j.getType=function(e){if(e instanceof j){return e.__type__}if(j.isFloat(e)){return"float"}if(j.isComplex(e)){return"complex"}if(j.isRational(e)){return"rational"}if(typeof e==="number"){return"integer"}if(typeof BigInt!=="undefined"&&typeof e!=="bigint"||typeof oi!=="undefined"&&!(e instanceof oi)){return"bigint"}};j.prototype.isFloat=function(){return!!(j.isFloat(this.__value__)||this["float"])};var qo={add:"+",sub:"-",mul:"*",div:"/",rem:"%",or:"|",and:"&",neg:"~",shl:">>",shr:"<<"};var zo={};Object.keys(qo).forEach(function(t){zo[qo[t]]=t;j.prototype[t]=function(e){return this.op(qo[t],e)}});j._ops={"*":function e(t,r){return t*r},"+":function e(t,r){return t+r},"-":function e(t,r){if(typeof r==="undefined"){return-t}return t-r},"/":function e(t,r){return t/r},"%":function e(t,r){return t%r},"|":function e(t,r){return t|r},"&":function e(t,r){return t&r},"~":function e(t){return~t},">>":function e(t,r){return t>>r},"<<":function e(t,r){return t<1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof g)||typeof this==="undefined"){return new g(e,t)}if(e instanceof g){return g({im:e.__im__,re:e.__re__})}if(j.isNumber(e)&&t){if(!t){return Number(e)}}else if(!j.isComplex(e)){var r="Invalid constructor call for LComplex expect &(:im :re ) object but got ".concat(da(e));throw new Error(r)}var n=e.im instanceof j?e.im:j(e.im);var i=e.re instanceof j?e.re:j(e.re);this.constant(n,i)}g.prototype=Object.create(j.prototype);g.prototype.constructor=g;g.prototype.constant=function(e,t){Object.defineProperty(this,"__im__",{value:e,enumerable:true});Object.defineProperty(this,"__re__",{value:t,enumerable:true});Object.defineProperty(this,"__type__",{value:"complex",enumerable:true})};g.prototype.serialize=function(){return{re:this.__re__,im:this.__im__}};g.prototype.toRational=function(e){if(j.isFloat(this.__im__)&&j.isFloat(this.__re__)){var t=E(this.__im__).toRational(e);var r=E(this.__re__).toRational(e);return g({im:t,re:r})}return this};g.prototype.pow=function(e){throw new Error("Not yet implemented")};g.prototype.add=function(e){return this.complex_op("add",e,function(e,t,r,n){return{re:e.add(t),im:r.add(n)}})};g.prototype.factor=function(){if(this.__im__ instanceof E||this.__im__ instanceof E){var e=this.__re__,t=this.__im__;var r,n;if(e instanceof E){r=e.toRational().mul(e.toRational())}else{r=e.mul(e)}if(t instanceof E){n=t.toRational().mul(t.toRational())}else{n=t.mul(t)}return r.add(n)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};g.prototype.modulus=function(){return this.factor().sqrt()};g.prototype.conjugate=function(){return g({re:this.__re__,im:this.__im__.sub()})};g.prototype.sqrt=function(){var e=this.modulus();var t,r;if(e.cmp(0)===0){t=r=e}else if(this.__re__.cmp(0)===1){t=E(.5).mul(e.add(this.__re__)).sqrt();r=this.__im__.div(t).div(2)}else{r=E(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){r=r.sub()}t=this.__im__.div(r).div(2)}return g({im:r,re:t})};g.prototype.div=function(e){if(j.isNumber(e)&&!j.isComplex(e)){if(!(e instanceof j)){e=j(e)}var t=this.__re__.div(e);var r=this.__im__.div(e);return g({re:t,im:r})}else if(!j.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}if(this.cmp(e)===0){var n=this.coerce(e),i=b(n,2),u=i[0],a=i[1];var o=u.__im__.div(a.__im__);return o.coerce(a.__re__)[0]}var s=this.coerce(e),c=b(s,2),f=c[0],l=c[1];var h=l.factor();var p=l.conjugate();var _=f.mul(p);if(!j.isComplex(_)){return _.div(h)}var d=_.__re__.op("/",h);var v=_.__im__.op("/",h);return g({re:d,im:v})};g.prototype.sub=function(e){return this.complex_op("sub",e,function(e,t,r,n){return{re:e.sub(t),im:r.sub(n)}})};g.prototype.mul=function(e){return this.complex_op("mul",e,function(e,t,r,n){var i={re:e.mul(t).sub(r.mul(n)),im:e.mul(n).add(t.mul(r))};return i})};g.prototype.complex_op=function(e,t,i){var u=this;var r=function e(t,r){var n=i(u.__re__,t,u.__im__,r);if("im"in n&&"re"in n){if(n.im.cmp(0)===0){return n.re}return g(n,true)}return n};if(typeof t==="undefined"){return r()}if(j.isNumber(t)&&!j.isComplex(t)){if(!(t instanceof j)){t=j(t)}var n=t.asType(0);t={__im__:n,__re__:t}}else if(!j.isComplex(t)){throw new Error("[LComplex::".concat(e,"] Invalid value"))}var a=t.__re__ instanceof j?t.__re__:this.__re__.asType(t.__re__);var o=t.__im__ instanceof j?t.__im__:this.__im__.asType(t.__im__);return r(a,o)};g._op={"+":"add","-":"sub","*":"mul","/":"div"};g.prototype._op=function(e,t){var r=g._op[e];return this[r](t)};g.prototype.cmp=function(e){var t=this.coerce(e),r=b(t,2),n=r[0],i=r[1];var u=n.__re__.coerce(i.__re__),a=b(u,2),o=a[0],s=a[1];var c=o.cmp(s);if(c!==0){return c}else{var f=n.__im__.coerce(i.__im__),l=b(f,2),h=l[0],p=l[1];return h.cmp(p)}};g.prototype.valueOf=function(){return[this.__re__,this.__im__].map(function(e){return e.valueOf()})};g.prototype.toString=function(){var e;if(this.__re__.cmp(0)!==0){e=[da(this.__re__)]}else{e=[]}var t=this.__im__.valueOf();var r=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(t);var n=da(this.__im__);if(!r&&!Number.isNaN(t)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}n=n.replace(/^-/,"")}e.push(n);e.push("i");return e.join("")};function E(e){if(typeof this!=="undefined"&&!(this instanceof E)||typeof this==="undefined"){return new E(e)}if(!j.isNumber(e)){throw new Error("Invalid constructor call for LFloat")}if(e instanceof j){return E(e.valueOf())}if(typeof e==="number"){if(Object.is(e,-0)){Object.defineProperty(this,"_minus",{value:true})}this.constant(e,"float")}}E.prototype=Object.create(j.prototype);E.prototype.constructor=E;E.prototype.toString=function(){if(this.__value__===Number.NEGATIVE_INFINITY){return"-inf.0"}if(this.__value__===Number.POSITIVE_INFINITY){return"+inf.0"}if(Number.isNaN(this.__value__)){return"+nan.0"}var e=this.__value__.toString();if(!j.isFloat(this.__value__)&&!e.match(/e/i)){var t=e+".0";return this._minus?"-"+t:t}return e.replace(/^([0-9]+)e/,"$1.0e")};E.prototype._op=function(e,t){if(t instanceof j){t=t.__value__}var r=j._ops[e];if(e==="/"&&this.__value__===0&&t===0){return NaN}return E(r(this.__value__,t))};E.prototype.toRational=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){return $o(this.__value__.valueOf())}return Jo(e.valueOf())(this.__value__.valueOf())};E.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){var t=E(Math.sqrt(-e));return g({re:0,im:t})}return E(Math.sqrt(e))};E.prototype.abs=function(){var e=this.valueOf();if(e<0){e=-e}return E(e)};var $o=Jo(1e-10);function Jo(n){return function(e){var t=function e(n,t,r){var i=function e(t,r){return r0){i=Ho(n,r)}else if(n.cmp(r)<=0){i=r}else if(r.cmp(0)>0){i=Ho(r,n)}else if(t.cmp(0)<0){i=j(Ho(n.sub(),r.sub())).sub()}else{i=j(0)}if(j.isFloat(t)||j.isFloat(e)){return E(i)}return i}function Ho(e,t){var r=j(e).floor();var n=j(t).floor();if(e.cmp(r)<1){return r}else if(r.cmp(n)===0){var i=j(1).div(t.sub(n));var u=j(1).div(e.sub(r));return r.add(j(1).div(Ho(i,u)))}else{return r.add(j(1))}}function A(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof A)||typeof this==="undefined"){return new A(e,t)}if(!j.isRational(e)){throw new Error("Invalid constructor call for LRational")}var r,n;if(e instanceof A){r=j(e.__num__);n=j(e.__denom__)}else{r=j(e.num);n=j(e.denom)}if(!t&&n.cmp(0)!==0){var i=r.op("%",n).cmp(0)===0;if(i){return j(r.div(n))}}this.constant(r,n)}A.prototype=Object.create(j.prototype);A.prototype.constructor=A;A.prototype.constant=function(e,t){Object.defineProperty(this,"__num__",{value:e,enumerable:true});Object.defineProperty(this,"__denom__",{value:t,enumerable:true});Object.defineProperty(this,"__type__",{value:"rational",enumerable:true})};A.prototype.serialize=function(){return{num:this.__num__,denom:this.__denom__}};A.prototype.pow=function(e){var t=e.cmp(0);if(t===0){return j(1)}if(t===-1){e=e.sub();var r=this.__denom__.pow(e);var n=this.__num__.pow(e);return A({num:r,denom:n})}var i=this;e=e.valueOf();while(e>1){i=i.mul(this);e--}return i};A.prototype.sqrt=function(){var e=this.__num__.sqrt();var t=this.__denom__.sqrt();if(e instanceof E||t instanceof E){return e.div(t)}return A({num:e,denom:t})};A.prototype.abs=function(){var e=this.__num__;var t=this.__denom__;if(e.cmp(0)===-1){e=e.sub()}if(t.cmp(0)!==1){t=t.sub()}return A({num:e,denom:t})};A.prototype.cmp=function(e){return j(this.valueOf(),true).cmp(e)};A.prototype.toString=function(){var e=this.__num__.gcd(this.__denom__);var t,r;if(e.cmp(1)!==0){t=this.__num__.div(e);if(t instanceof A){t=j(t.valueOf(true))}r=this.__denom__.div(e);if(r instanceof A){r=j(r.valueOf(true))}}else{t=this.__num__;r=this.__denom__}var n=this.cmp(0)<0;if(n){if(t.abs().cmp(r.abs())===0){return t.toString()}}else if(t.cmp(r)===0){return t.toString()}return t.toString()+"/"+r.toString()};A.prototype.valueOf=function(e){if(this.__denom__.cmp(0)===0){if(this.__num__.cmp(0)<0){return Number.NEGATIVE_INFINITY}return Number.POSITIVE_INFINITY}if(e){return j._ops["/"](this.__num__.value,this.__denom__.value)}return E(this.__num__.valueOf()).div(this.__denom__.valueOf())};A.prototype.mul=function(e){if(!(e instanceof j)){e=j(e)}if(j.isRational(e)){var t=this.__num__.mul(e.__num__);var r=this.__denom__.mul(e.__denom__);return A({num:t,denom:r})}var n=j.coerce(this,e),i=b(n,2),u=i[0],a=i[1];return u.mul(a)};A.prototype.div=function(e){if(!(e instanceof j)){e=j(e)}if(j.isRational(e)){var t=this.__num__.mul(e.__denom__);var r=this.__denom__.mul(e.__num__);return A({num:t,denom:r})}var n=j.coerce(this,e),i=b(n,2),u=i[0],a=i[1];var o=u.div(a);return o};A.prototype._op=function(e,t){return this[zo[e]](t)};A.prototype.sub=function(e){if(typeof e==="undefined"){return this.mul(-1)}if(!(e instanceof j)){e=j(e)}if(j.isRational(e)){var t=e.__num__.sub();var r=e.__denom__;return this.add(A({num:t,denom:r}))}if(!(e instanceof j)){e=j(e).sub()}else{e=e.sub()}var n=j.coerce(this,e),i=b(n,2),u=i[0],a=i[1];return u.add(a)};A.prototype.add=function(e){if(!(e instanceof j)){e=j(e)}if(j.isRational(e)){var t=this.__denom__;var r=e.__denom__;var n=this.__num__;var i=e.__num__;var u,a;if(t!==r){a=r.mul(n).add(i.mul(t));u=t.mul(r)}else{a=n.add(i);u=t}return A({num:a,denom:u})}if(j.isFloat(e)){return E(this.valueOf()).add(e)}var o=j.coerce(this,e),s=b(o,2),c=s[0],f=s[1];return c.add(f)};function x(e,t){if(typeof this!=="undefined"&&!(this instanceof x)||typeof this==="undefined"){return new x(e,t)}if(e instanceof x){return x(e.__value__,e._native)}if(!j.isBigInteger(e)){throw new Error("Invalid constructor call for LBigInteger")}this.constant(e,"bigint");Object.defineProperty(this,"_native",{value:t})}x.prototype=Object.create(j.prototype);x.prototype.constructor=x;x.bn_op={"+":"iadd","-":"isub","*":"imul","/":"idiv","%":"imod","|":"ior","&":"iand","~":"inot","<<":"ishrn",">>":"ishln"};x.prototype.serialize=function(){return this.__value__.toString()};x.prototype._op=function(e,t){if(typeof t==="undefined"){if(j.isBN(this.__value__)){e=x.bn_op[e];return x(this.__value__.clone()[e](),false)}return x(j._ops[e](this.__value__),true)}if(j.isBN(this.__value__)&&j.isBN(t.__value__)){e=x.bn_op[e];return x(this.__value__.clone()[e](t),false)}var r=j._ops[e](this.__value__,t.__value__);if(e==="/"){var n=this.op("%",t).cmp(0)===0;if(n){return j(r)}return A({num:this,denom:t})}return x(r,true)};x.prototype.sqrt=function(){var e;var t=this.cmp(0)<0;if(j.isNative(this.__value__)){e=j(Math.sqrt(t?-this.valueOf():this.valueOf()))}else if(j.isBN(this.__value__)){e=t?this.__value__.neg().sqrt():this.__value__.sqrt()}if(t){return g({re:0,im:e})}return e};j.NaN=j(NaN);function Go(e){var n=this;if(typeof this!=="undefined"&&!(this instanceof Go)||typeof this==="undefined"){return new Go(e)}k("InputPort",e,"function");f(this,"__type__",os);var i;Object.defineProperty(this,"__parser__",{enumerable:true,get:function e(){return i},set:function e(t){k("InputPort::__parser__",t,"parser");i=t}});this._read=e;this._with_parser=this._with_init_parser.bind(this,ae(C.mark(function e(){var r;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(n.char_ready()){t.next=5;break}t.next=3;return n._read();case 3:r=t.sent;i=new bu(r,{env:n});case 5:return t.abrupt("return",n.__parser__);case 6:case"end":return t.stop()}},e)})));this.char_ready=function(){return!!this.__parser__&&this.__parser__.__lexer__.peek()!==ss};this._make_defaults()}Go.prototype._make_defaults=function(){this.read=this._with_parser(function(e){return e.read_object()});this.read_line=this._with_parser(function(e){return e.__lexer__.read_line()});this.read_char=this._with_parser(function(e){return e.__lexer__.read_char()});this.read_string=this._with_parser(function(e,t){if(!j.isInteger(t)){var r=j.getType(t);Ps("read-string",r,"integer")}return e.__lexer__.read_string(t.valueOf())});this.peek_char=this._with_parser(function(e){return e.__lexer__.peek_char()})};Go.prototype._with_init_parser=function(o,s){var c=this;return ae(C.mark(function e(){var r,n,i,u,a=arguments;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return o.call(c);case 2:r=t.sent;for(n=a.length,i=new Array(n),u=0;u"};function Wo(e){if(typeof this!=="undefined"&&!(this instanceof Wo)||typeof this==="undefined"){return new Wo(e)}k("OutputPort",e,"function");f(this,"__type__",os);this.write=e}Wo.prototype.is_open=function(){return this._closed!==true};Wo.prototype.close=function(){Object.defineProperty(this,"_closed",{get:function e(){return true},set:function e(){},configurable:false,enumerable:false});this.write=function(){throw new Error("output-port: port is closed")}};Wo.prototype.flush=function(){};Wo.prototype.toString=function(){return"#"};var Qo=function(e){W(r,e);function r(e){var t;oe(this,r);t=Kn(this,r,[function(){var e;return(e=t)._write.apply(e,arguments)}]);k("BufferedOutputPort",e,"function");f(H(t),"_fn",e,{hidden:true});f(H(t),"_buffer",[],{hidden:true});return t}le(r,[{key:"flush",value:function e(){if(this._buffer.length){this._fn(this._buffer.join(""));this._buffer.length=0}}},{key:"_write",value:function e(){var t=this;for(var r=arguments.length,n=new Array(r),i=0;i"};Zo.prototype.valueOf=function(){return this.__buffer__.map(function(e){return e.valueOf()}).join("")};function Xo(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof Xo)||typeof this==="undefined"){return new Xo(e,t)}k("OutputFilePort",e,"string");f(this,"__filename__",e);f(this,"_fd",t.valueOf(),{hidden:true});f(this,"__type__",os);this.write=function(e){if(!D.isString(e)){e=da(e)}else{e=e.valueOf()}r.fs().write(r._fd,e,function(e){if(e){throw e}})}}Xo.prototype=Object.create(Wo.prototype);Xo.prototype.constructor=Xo;Xo.prototype.fs=function(){if(!this._fs){this._fs=this.internal("fs")}return this._fs};Xo.prototype.internal=function(e){return Es.get("**internal-env**").get(e)};Xo.prototype.close=function(){var n=this;return new Promise(function(t,r){n.fs().close(n._fd,function(e){if(e){r(e)}else{f(n,"_fd",null,{hidden:true});Wo.prototype.close.call(n);t()}})})};Xo.prototype.toString=function(){return"#")};function es(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof es)||typeof this==="undefined"){return new es(e)}k("InputStringPort",e,"string");t=t||I;e=e.valueOf();this._with_parser=this._with_init_parser.bind(this,function(){if(!r.__parser__){r.__parser__=new bu(e,{env:t})}return r.__parser__});f(this,"__type__",os);this._make_defaults()}es.prototype.char_ready=function(){return true};es.prototype=Object.create(Go.prototype);es.prototype.constructor=es;es.prototype.toString=function(){return"#"};function ts(e){if(typeof this!=="undefined"&&!(this instanceof ts)||typeof this==="undefined"){return new ts(e)}k("InputByteVectorPort",e,"uint8array");f(this,"__vector__",e);f(this,"__type__",as);var r=0;Object.defineProperty(this,"__index__",{enumerable:true,get:function e(){return r},set:function e(t){k("InputByteVectorPort::__index__",t,"number");if(t instanceof j){t=t.valueOf()}if(typeof t==="bigint"){t=Number(t)}if(Math.floor(t)!==t){throw new Error("InputByteVectorPort::__index__ value is "+"not integer")}r=t}})}ts.prototype=Object.create(Go.prototype);ts.prototype.constructor=ts;ts.prototype.toString=function(){return"#"};ts.prototype.close=function(){var t=this;f(this,"__vector__",U);var r=function e(){throw new Error("Input-binary-port: port is closed")};["read_u8","close","peek_u8","read_u8_vector"].forEach(function(e){t[e]=r});this.u8_ready=this.char_ready=function(){return false}};ts.prototype.u8_ready=function(){return true};ts.prototype.peek_u8=function(){if(this.__index__>=this.__vector__.length){return ss}return this.__vector__[this.__index__]};ts.prototype.skip=function(){if(this.__index__<=this.__vector__.length){++this.__index__}};ts.prototype.read_u8=function(){var e=this.peek_u8();this.skip();return e};ts.prototype.read_u8_vector=function(e){if(typeof e==="undefined"){e=this.__vector__.length}else if(e>this.__index__+this.__vector__.length){e=this.__index__+this.__vector__.length}if(this.peek_u8()===ss){return ss}return this.__vector__.slice(this.__index__,e)};function rs(){if(typeof this!=="undefined"&&!(this instanceof rs)||typeof this==="undefined"){return new rs}f(this,"__type__",as);f(this,"_buffer",[],{hidden:true});this.write=function(e){k("write",e,["number","uint8array"]);if(j.isNumber(e)){this._buffer.push(e.valueOf())}else{var t;(t=this._buffer).push.apply(t,R(Array.from(e)))}};Object.defineProperty(this,"__buffer__",{enumerable:true,get:function e(){return Uint8Array.from(this._buffer)}})}rs.prototype=Object.create(Wo.prototype);rs.prototype.constructor=rs;rs.prototype.close=function(){Wo.prototype.close.call(this);f(this,"_buffer",null,{hidden:true})};rs.prototype._close_guard=function(){if(this._closed){throw new Error("output-port: binary port is closed")}};rs.prototype.write_u8=function(e){k("OutputByteVectorPort::write_u8",e,"number");this.write(e)};rs.prototype.write_u8_vector=function(e){k("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};rs.prototype.toString=function(){return"#"};rs.prototype.valueOf=function(){return this.__buffer__};function ns(e,t){if(typeof this!=="undefined"&&!(this instanceof ns)||typeof this==="undefined"){return new ns(e,t)}es.call(this,e);k("InputFilePort",t,"string");f(this,"__filename__",t)}ns.prototype=Object.create(es.prototype);ns.prototype.constructor=ns;ns.prototype.toString=function(){return"#")};function is(e,t){if(typeof this!=="undefined"&&!(this instanceof is)||typeof this==="undefined"){return new is(e,t)}ts.call(this,e);k("InputBinaryFilePort",t,"string");f(this,"__filename__",t)}is.prototype=Object.create(ts.prototype);is.prototype.constructor=is;is.prototype.toString=function(){return"#")};function us(e,t){var i=this;if(typeof this!=="undefined"&&!(this instanceof us)||typeof this==="undefined"){return new us(e,t)}k("OutputBinaryFilePort",e,"string");f(this,"__filename__",e);f(this,"_fd",t.valueOf(),{hidden:true});f(this,"__type__",as);var u;this.write=function(e){k("write",e,["number","uint8array"]);var n;if(!u){u=i.internal("fs")}if(j.isNumber(e)){n=new Uint8Array([e.valueOf()])}else{n=new Uint8Array(Array.from(e))}return new Promise(function(t,r){u.write(i._fd,n,function(e){if(e){r(e)}else{t()}})})}}us.prototype=Object.create(Xo.prototype);us.prototype.constructor=us;us.prototype.write_u8=function(e){k("OutputByteVectorPort::write_u8",e,"number");this.write(e)};us.prototype.write_u8_vector=function(e){k("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};var as=Symbol["for"]("binary");var os=Symbol["for"]("text");var ss=new cs;function cs(){}cs.prototype.toString=function(){return"#"};function fs(e){var t=this;var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},n=r.stderr,i=r.stdin,u=r.stdout,a=r.command_line,o=a===void 0?null:a,s=_e(r,qn);if(typeof this!=="undefined"&&!(this instanceof fs)||typeof this==="undefined"){return new fs(e,T({stdin:i,stdout:u,stderr:n,command_line:o},s))}if(typeof e==="undefined"){e="anonymous"}this.__env__=Es.inherit(e,s);this.__env__.set("parent.frame",l("parent.frame",function(){return t.__env__},I.__env__["parent.frame"].__doc__));var c="**interaction-environment-defaults**";this.set(c,fa(s).concat(c));var f=bs.inherit("internal-".concat(e));if(to(i)){f.set("stdin",i)}if(to(n)){f.set("stderr",n)}if(to(u)){f.set("stdout",u)}f.set("command-line",o);As(this.__env__,f)}fs.prototype.exec=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=t.use_dynamic,n=r===void 0?false:r,i=t.dynamic_env,u=t.env;k("Interpreter::exec",e,["string","array"],1);k("Interpreter::exec",n,"boolean",2);if(!u){u=this.__env__}if(!i){i=u}I.set("**interaction-environment**",this.__env__);return Xs(e,{env:u,dynamic_env:i,use_dynamic:n})};fs.prototype.get=function(e){var t=this.__env__.get(e);if(m(t)){var r=new Gs({env:this.__env__});return t.bind(r)}return t};fs.prototype.set=function(e,t){return this.__env__.set(e,t)};fs.prototype.constant=function(e,t){return this.__env__.constant(e,t)};function ls(e,t){this.name="LipsError";this.message=e;this.args=t;this.stack=(new Error).stack}ls.prototype=new Error;ls.prototype.constructor=ls;var hs=function(e){W(t,e);function t(){oe(this,t);return Kn(this,t,arguments)}return le(t)}(r(Error));function F(e,t,r){if(arguments.length===1){if(p(arguments[0])==="object"){e=arguments[0];t=null}else if(typeof arguments[0]==="string"){e={};t=null;r=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=t;this.__name__=r||"anonymous"}F.prototype.list=function(){return fa(this.__env__)};F.prototype.fs=function(){return this.get("**fs**")};F.prototype.unset=function(e){if(e instanceof L){e=e.valueOf()}if(e instanceof D){e=e.valueOf()}delete this.__env__[e]};F.prototype.inherit=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(p(e)==="object"){t=e}if(!e||p(e)==="object"){e="child of "+(this.__name__||"unknown")}return new F(t||{},this,e)};F.prototype.doc=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(e instanceof L){e=e.__name__}if(e instanceof D){e=e.valueOf()}if(t){if(!r){t=Ou(t)}this.__docs__.set(e,t);return this}if(this.__docs__.has(e)){return this.__docs__.get(e)}if(this.__parent__){return this.__parent__.doc(e)}};F.prototype.new_frame=function(e,t){var n=this.inherit("__frame__");n.set("parent.frame",l("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1;e=e.valueOf();var t=n.__parent__;if(!Ta(t)){return U}if(e<=0){return t}var r=t.get("parent.frame");return r(e-1)},I.__env__["parent.frame"].__doc__));t.callee=e;n.set("arguments",t);return n};F.prototype._lookup=function(e){if(e instanceof L){e=e.__name__}if(e instanceof D){e=e.valueOf()}if(this.__env__.hasOwnProperty(e)){return ps(this.__env__[e])}if(this.__parent__){return this.__parent__._lookup(e)}};F.prototype.toString=function(){return"#"};F.prototype.clone=function(){var t=this;var r={};Object.keys(this.__env__).forEach(function(e){r[e]=t.__env__[e]});return new F(r,this.__parent__,this.__name__)};F.prototype.merge=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"merge";k("Environment::merge",e,"environment");return this.inherit(t,e.__env__)};function ps(e){if(typeof this!=="undefined"&&!(this instanceof ps)||typeof this==="undefined"){return new ps(e)}this.value=e}ps.isUndefined=function(e){return e instanceof ps&&typeof e.value==="undefined"};ps.prototype.valueOf=function(){return this.value};function _s(e){if(e.length){if(e.length===1){return e[0]}}if(typeof this!=="undefined"&&!(this instanceof _s)||typeof this==="undefined"){return new _s(e)}this.__values__=e}_s.prototype.toString=function(){return this.__values__.map(function(e){return da(e)}).join("\n")};_s.prototype.valueOf=function(){return this.__values__};F.prototype.get=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};k("Environment::get",e,["symbol","string"]);var r=t.throwError,n=r===void 0?true:r;var i=e;if(i instanceof L||i instanceof D){i=i.valueOf()}var u=this._lookup(i);if(u instanceof ps){if(ps.isUndefined(u)){return undefined}return Ga(u.valueOf())}var a;if(e instanceof L&&e[L.object]){a=e[L.object]}else if(typeof i==="string"){a=i.split(".").filter(Boolean)}if(a&&a.length>0){var o=a,s=re(o),c=s[0],f=s.slice(1);u=this._lookup(c);if(f.length){try{if(u instanceof ps){u=u.valueOf()}else{u=ys(ti,c);if(m(u)){u=Wa(u)}}if(typeof u!=="undefined"){return ys.apply(void 0,[u].concat(R(f)))}}catch(e){throw e}}else if(u instanceof ps){return Ga(u.valueOf())}u=ys(ti,i)}if(typeof u!=="undefined"){return u}if(n){throw new Error("Unbound variable `"+i.toString()+"'")}};F.prototype.set=function(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;k("Environment::set",e,["string","symbol"]);if(j.isNumber(t)){t=j(t)}if(e instanceof L){e=e.__name__}if(e instanceof D){e=e.valueOf()}this.__env__[e]=t;if(r){this.doc(e,r,true)}return this};F.prototype.constant=function(t,e){var r=this;if(this.__env__.hasOwnProperty(t)){throw new Error("Environment::constant: ".concat(t," already exists"))}if(arguments.length===1&&ra(arguments[0])){var n=arguments[0];Object.keys(n).forEach(function(e){r.constant(t,n[e])})}else{Object.defineProperty(this.__env__,t,{value:e,enumerable:true})}return this};F.prototype.has=function(e){return this.__env__.hasOwnProperty(e)};F.prototype.ref=function(e){var t=this;while(true){if(!t){break}if(t.has(e)){return t}t=t.__parent__}};F.prototype.parents=function(){var e=this;var t=[];while(e){t.unshift(e);e=e.__parent__}return t};function ds(e){if(Ua(e)){return e.then(ds)}if(e instanceof M||e instanceof L){e[uo]=true}return e}var vs=Du(nu('(lambda ()\n "[native code]"\n (throw "Invalid Invocation"))'))[0];var ys=l("get",function e(t){var r;for(var n=arguments.length,i=new Array(n>1?n-1:0),u=1;u0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=ms(this,"stdin")}Ls("peek-char",e,"input-port");return e.peek_char()},"(peek-char port)\n\n This function reads and returns a character from the string\n port, or, if there is no more data in the string port, it\n returns an EOF."),"read-line":l("read-line",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=ms(this,"stdin")}Ls("read-line",e,"input-port");return e.read_line()},"(read-line port)\n\n This function reads and returns the next line from the input\n port."),"read-char":l("read-char",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=ms(this,"stdin")}Ls("read-char",e,"input-port");return e.read_char()},"(read-char port)\n\n This function reads and returns the next character from the\n input port."),read:l("read",function(){var e=ae(function(){var f=this;var l=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;return C.mark(function e(){var r,n,i,u,a,o,s,c;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=f.env;if(!D.isString(l)){t.next=30;break}n=false;i=false;t.prev=4;a=Xn(Du(l,r));case 6:t.next=8;return a.next();case 8:if(!(n=!(o=t.sent).done)){t.next=14;break}s=o.value;return t.abrupt("return",s);case 11:n=false;t.next=6;break;case 14:t.next=20;break;case 16:t.prev=16;t.t0=t["catch"](4);i=true;u=t.t0;case 20:t.prev=20;t.prev=21;if(!(n&&a["return"]!=null)){t.next=25;break}t.next=25;return a["return"]();case 25:t.prev=25;if(!i){t.next=28;break}throw u;case 28:return t.finish(25);case 29:return t.finish(20);case 30:if(l===null){c=ms(r,"stdin")}else{c=l}Ls("read",c,"input-port");return t.abrupt("return",c.read.call(r));case 33:case"end":return t.stop()}},e,null,[[4,16,20,30],[21,,25,29]])})()});function t(){return e.apply(this,arguments)}return t}(),"(read [string])\n\n This function, if used with a string, will parse it and\n return the LIPS code, if there is any. If called with a\n port, it will parse the next item from the port. If called\n without an input, it will read a string from standard input\n (using the browser's prompt or a user defined input method)\n and calls itself with that string. This function can be used\n together with `eval` to evaluate code from a string."),pprint:l("pprint",function e(t){if(t instanceof M){t=new Pc.Formatter(t.toString(true))["break"]().format();I.get("display").call(I,t)}else{I.get("write").call(I,t)}I.get("newline").call(I)},"(pprint expression)\n\n This function will pretty print its input to stdout. If it is called\n with a non-list, it will just call the print function on its\n input."),print:l("print",function e(){var t=I.get("display");var r=I.get("newline");var n=this.use_dynamic;var i=I;var u=I;for(var a=arguments.length,o=new Array(a),s=0;s1?r-1:0),i=1;in.length){throw new Error("Not enough arguments")}var o=0;var s=I.get("repr");t=t.replace(u,function(e){var t=e[1];if(t==="~"){return"~"}else if(t==="%"){return"\n"}else{var r=n[o++];if(t==="a"){return s(r)}else{return s(r,true)}}});a=t.match(/~([\S])/);if(a){throw new Error("format: Unrecognized escape sequence ".concat(a[1]))}return t},"(format string n1 n2 ...)\n\n This function accepts a string template and replaces any\n escape sequences in its inputs:\n\n * ~a value as if printed with `display`\n * ~s value as if printed with `write`\n * ~% newline character\n * ~~ literal tilde '~'\n\n If there are missing inputs or other escape characters it\n will error."),display:l("display",function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(r===null){r=ms(this,"stdout")}else{k("display",r,"output-port")}var n=t;if(!(r instanceof us)){n=I.get("repr")(t)}r.write.call(I,n)},"(display string [port])\n\n This function outputs the string to the standard output or\n the port if given. No newline."),"display-error":l("display-error",function e(){var t=ms(this,"stderr");var r=I.get("repr");for(var n=arguments.length,i=new Array(n),u=0;u1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=_e(t,zn);var i=this;var a=this;var o;var s=T(T({},n),{},{env:this,dynamic_env:i,use_dynamic:r});var c=P(e.cdr.car,s);c=Ms(c);function f(t,r,n){if(Ua(t)){return t.then(function(e){return f(t,e,n)})}if(Ua(r)){return r.then(function(e){return f(t,e,n)})}if(Ua(n)){return n.then(function(e){return f(t,r,e)})}a.get("set-obj!").call(a,t,r,n);return n}if(e.car instanceof M&&L.is(e.car.car,".")){var l=e.car.cdr.car;var h=e.car.cdr.cdr.car;var p=P(l,{env:this,dynamic_env:i,use_dynamic:r,error:error});var _=P(h,{env:this,dynamic_env:i,use_dynamic:r,error:error});return f(p,_,c)}if(!(e.car instanceof L)){throw new Error("set! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var d=e.car.valueOf();o=this.ref(e.car.__name__);return w(c,function(e){if(!o){var t=d.split(".");if(t.length>1){var r=t.pop();var n=t.join(".");var i=u.get(n,{throwError:false});if(i){f(i,r,e);return}}throw new Error("Unbound variable `"+d+"'")}o.set(d,e)})}),"(set! name value)\n\n Macro that can be used to set the value of the variable or slot (mutate it).\n set! searches the scope chain until it finds first non empty slot and sets it."),"unset!":l(new q("set!",function(e){if(!(e.car instanceof L)){throw new Error("unset! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var t=e.car;var r=this.ref(t);if(r){delete r.__env__[t.__name__]}}),"(unset! name)\n\n Function to delete the specified name from environment.\n Trying to access the name afterwards will error."),"set-car!":l("set-car!",function(e,t){k("set-car!",e,"pair");e.car=t},"(set-car! obj value)\n\n Function that sets the car (first item) of the list/pair to specified value.\n The old value is lost."),"set-cdr!":l("set-cdr!",function(e,t){k("set-cdr!",e,"pair");e.cdr=t},"(set-cdr! obj value)\n\n Function that sets the cdr (tail) of the list/pair to specified value.\n It will destroy the list. The old tail is lost."),"empty?":l("empty?",function(e){return typeof e==="undefined"||e===U},"(empty? object)\n\n Function that returns #t if value is nil (an empty list) or undefined."),gensym:l("gensym",su,"(gensym)\n\n Generates a unique symbol that is not bound anywhere,\n to use with macros as meta name."),load:l("load",function e(o,t){k("load",o,"string");var s=this;if(s.__name__==="__frame__"){s=s.__parent__}if(!(t instanceof F)){if(s===I){t=s}else{t=this.get("**interaction-environment**")}}var c="**module-path**";var f=I.get(c,{throwError:false});o=o.valueOf();if(!o.match(/.[^.]+$/)){o+=".scm"}var r=o.match(/\.xcb$/);function l(e){if(r){e=Fc(e)}else{if(z(e)==="buffer"){e=e.toString()}e=e.replace(/^#!.*/,"");if(e.match(/^\{/)){e=gc(e)}}return Xs(e,{env:t})}function n(e){return ti.fetch(e).then(function(e){return r?e.arrayBuffer():e.text()}).then(function(e){if(r){e=new Uint8Array(e)}return e})}if(Ss()){return new Promise(function(){var r=ae(C.mark(function e(r,n){var i,u,a;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:i=ai("path");if(!f){t.next=6;break}f=f.valueOf();o=i.join(f,o);t.next=12;break;case 6:u=s.get("command-line",{throwError:false});if(!u){t.next=11;break}t.next=10;return u();case 10:a=t.sent;case 11:if(a&&a!==U){process.cwd();o=i.join(i.dirname(a.car.valueOf()),o)}case 12:I.set(c,i.dirname(o));ai("fs").readFile(o,function(e,t){if(e){n(e);I.set(c,f)}else{try{l(t).then(function(){r();I.set(c,f)})["catch"](n)}catch(e){n(e)}}});case 14:case"end":return t.stop()}},e)}));return function(e,t){return r.apply(this,arguments)}}())}if(f){f=f.valueOf();o=f+"/"+o.replace(/^\.?\/?/,"")}return n(o).then(function(e){I.set(c,o.replace(/\/[^/]*$/,""));return l(e)}).then(function(){})["finally"](function(){I.set(c,f)})},"(load filename)\n (load filename environment)\n\n Fetches the file (from disk or network) and evaluates its content as LIPS code.\n If the second argument is provided and it's an environment the evaluation\n will happen in that environment."),do:l(new q("do",function(){var r=ae(function(h,e){var p=this;var _=e.use_dynamic,d=e.error;return C.mark(function e(){var r,n,o,s,i,c,f,u,a,l;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=p;n=r;o=r.inherit("do");s=h.car;i=h.cdr.car;c=h.cdr.cdr;if(c!==U){c=new M(L("begin"),c)}f={env:r,dynamic_env:n,use_dynamic:_,error:d};u=s;case 9:if(!(u!==U)){t.next=20;break}a=u.car;t.t0=o;t.t1=a.car;t.next=15;return P(a.cdr.car,f);case 15:t.t2=t.sent;t.t0.set.call(t.t0,t.t1,t.t2);u=u.cdr;t.next=9;break;case 20:f={env:o,dynamic_env:n,error:d};l=C.mark(function e(){var r,n,i,u,a;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!(c!==U)){t.next=3;break}t.next=3;return Pc.evaluate(c,f);case 3:r=s;n={};case 5:if(!(r!==U)){t.next=15;break}i=r.car;if(!(i.cdr.cdr!==U)){t.next=12;break}t.next=10;return P(i.cdr.cdr.car,f);case 10:u=t.sent;n[i.car.valueOf()]=u;case 12:r=r.cdr;t.next=5;break;case 15:a=Object.getOwnPropertySymbols(n);Object.keys(n).concat(a).forEach(function(e){o.set(e,n[e])});case 17:case"end":return t.stop()}},e)});case 22:t.next=24;return P(i.car,f);case 24:t.t3=t.sent;if(!(t.t3===false)){t.next=29;break}return t.delegateYield(l(),"t4",27);case 27:t.next=22;break;case 29:if(!(i.cdr!==U)){t.next=33;break}t.next=32;return P(i.cdr.car,f);case 32:return t.abrupt("return",t.sent);case 33:case"end":return t.stop()}},e)})()});return function(e,t){return r.apply(this,arguments)}}()),"(do (( )) (test return) . body)\n\n Iteration macro that evaluates the expression body in scope of the variables.\n On each loop it changes the variables according to the expression and runs\n test to check if the loop should continue. If test is a single value, the macro\n will return undefined. If the test is a pair of expressions the macro will\n evaluate and return the second expression after the loop exits."),if:l(new q("if",function(r,e){var t=e.error,n=e.use_dynamic;var i=this;var u=this;var a={env:u,dynamic_env:i,use_dynamic:n,error:t};var o=function e(t){if(t===false){return P(r.cdr.cdr.car,a)}else{return P(r.cdr.car,a)}};if(r===U){throw new Error("too few expressions for `if`")}var s=P(r.car,a);return w(s,o)}),"(if cond true-expr false-expr)\n\n Macro that evaluates cond expression and if the value is true, it\n evaluates and returns true-expression, if not it evaluates and returns\n false-expression."),"let-env":new q("let-env",function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=e.dynamic_env,n=e.use_dynamic,i=e.error;k("let-env",t,"pair");var u=P(t.car,{env:this,dynamic_env:r,error:i,use_dynamic:n});return w(u,function(e){k("let-env",e,"environment");return P(M(L("begin"),t.cdr),{env:e,dynamic_env:r,error:i})})},"(let-env env . body)\n\n Special macro that evaluates body in context of given environment\n object."),letrec:l(wo(Symbol["for"]("letrec")),"(letrec ((a value-a) (b value-b) ...) . body)\n\n Macro that creates a new environment, then evaluates and assigns values to\n names and then evaluates the body in context of that environment.\n Values are evaluated sequentially and the next value can access the\n previous values/names."),"letrec*":l(wo(Symbol["for"]("letrec")),"(letrec* ((a value-a) (b value-b) ...) . body)\n\n Same as letrec but the order of execution of the binding is guaranteed,\n so you can use recursive code as well as referencing the previous binding.\n\n In LIPS both letrec and letrec* behave the same."),"let*":l(wo(Symbol["for"]("let*")),"(let* ((a value-a) (b value-b) ...) . body)\n\n Macro similar to `let`, but the subsequent bindings after the first\n are evaluated in the environment including the previous let variables,\n so you can define one variable, and use it in the next's definition."),let:l(wo(Symbol["for"]("let")),"(let ((a value-a) (b value-b) ...) . body)\n\n Macro that creates a new environment, then evaluates and assigns values to names,\n and then evaluates the body in context of that environment. Values are evaluated\n sequentially but you can't access previous values/names when the next are\n evaluated. You can only get them in the body of the let expression. (If you want\n to define multiple variables and use them in each other's definitions, use\n `let*`.)"),"begin*":l(Do("begin*",function(e){return e.pop()}),"(begin* . body)\n\n This macro is a parallel version of begin. It evaluates each expression\n in the body and if it's a promise it will await it in parallel and return\n the value of the last expression (i.e. it uses Promise.all())."),shuffle:l("shuffle",function(e){k("shuffle",e,["pair","nil","array"]);var t=I.get("random");if(e===U){return U}if(Array.isArray(e)){return Zu(e.slice(),t)}var r=I.get("list->array")(e);r=Zu(r,t);return I.get("array->list")(r)},"(shuffle obj)\n\n Order items in vector or list in random order."),begin:l(new q("begin",function(e,t){var n=T(T({},t),{},{env:this});var i=I.get("list->array")(e);var u;return function t(){if(i.length){var e=i.shift();var r=P(e,n);return w(r,function(e){u=e;return t()})}else{return u}}()}),"(begin . args)\n\n Macro that runs a list of expressions in order and returns the value\n of the last one. It can be used in places where you can only have a\n single expression, like (if)."),ignore:new q("ignore",function(e,t){var r=T(T({},t),{},{env:this,dynamic_env:this});P(new M(new L("begin"),e),r)},"(ignore . body)\n\n Macro that will evaluate the expression and swallow any promises that may\n be created. It will discard any value that may be returned by the last body\n expression. The code should have side effects and/or when it's promise\n it should resolve to undefined."),"call/cc":l(q.defmacro("call/cc",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=T({env:this},t);return w(P(e.car,r),function(e){if(m(e)){return e(new Qs(null))}})}),"(call/cc proc)\n\n Call-with-current-continuation.\n\n NOT SUPPORTED BY LIPS RIGHT NOW"),parameterize:l(new q("parameterize",function(t,e){var i=e.dynamic_env;var u=i.inherit("parameterize").new_frame(null,{});var a=T(T({},e),{},{env:this});var o=t.car;if(!Ra(o)){var r=z(o);throw new Error("Invalid syntax for parameterize expecting pair got ".concat(r))}function s(){var e=new M(new L("begin"),t.cdr);return P(e,T(T({},a),{},{dynamic_env:u}))}return function r(){var e=o.car;var n=e.car.valueOf();return w(P(e.cdr.car,a),function(e){var t=i.get(n,{throwError:false});if(!Na(t)){throw new Error("Unknown parameter ".concat(n))}u.set(n,t.inherit(e));if(!ja(o.cdr)){o=o.cdr;return r()}else{return s()}})}()}),"(parameterize ((name value) ...)\n\n Macro that change the dynamic variable created by make-parameter."),"make-parameter":l(new q("make-parameter",function(e,t){t.dynamic_env;var r=P(e.car,t);var n;if(e.cdr.car instanceof M){n=P(e.cdr.car,t)}return new Hs(r,n)}),"(make-parameter init converter)\n\n Function creates new dynamic variable that can be custimized with parameterize\n macro. The value should be assigned to a variable e.g.:\n\n (define radix (make-parameter 10))\n\n The result value is a procedure that return the value of dynamic variable."),define:l(q.defmacro("define",function(r,e){var n=this;if(r.car instanceof M&&r.car.car instanceof L){var t=new M(new L("define"),new M(r.car.car,new M(new M(new L("lambda"),new M(r.car.cdr,r.cdr)))));return t}else if(e.macro_expand){return}e.dynamic_env=this;e.env=n;var i=r.cdr.car;var u;if(i instanceof M){i=P(i,e);u=true}else if(i instanceof L){i=n.get(i)}k("define",r.car,"symbol");return w(i,function(e){if(n.__name__===ka.__merge_env__){n=n.__parent__}if(u&&(m(e)&&yo(e)||e instanceof ka||Na(e))){e.__name__=r.car.valueOf();if(e.__name__ instanceof D){e.__name__=e.__name__.valueOf()}}var t;if(r.cdr.cdr instanceof M&&D.isString(r.cdr.cdr.car)){t=r.cdr.cdr.car.valueOf()}n.set(r.car,e,t,true)})}),'(define name expression)\n (define name expression "doc string")\n (define (function-name . args) . body)\n\n Macro for defining values. It can be used to define variables,\n or functions. If the first argument is list it will create a function\n with name being first element of the list. This form expands to\n `(define function-name (lambda args body))`'),"set-obj!":l("set-obj!",function(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var i=p(e);if(ja(e)||i!=="object"&&i!=="function"){var u=Ps("set-obj!",z(e),["object","function"]);throw new Error(u)}k("set-obj!",t,["string","symbol","number"]);e=Wa(e);t=t.valueOf();if(arguments.length===2){delete e[t]}else if(va(e)&&m(r)){e[t]=Wa(r);e[t][fo]=true}else if(m(r)||Ya(r)||r===U){e[t]=r}else{e[t]=r&&!va(r)?r.valueOf():r}if(na){var a=e[t];Object.defineProperty(e,t,T(T({},n),{},{value:a}))}},"(set-obj! obj key value)\n (set-obj! obj key value props)\n\n Function set a property of a JavaScript object. props should be a vector of pairs,\n passed to Object.defineProperty."),"null-environment":l("null-environment",function(){return I.inherit("null")},"(null-environment)\n\n Returns a clean environment with only the standard library."),values:l("values",function e(){for(var t=arguments.length,r=new Array(t),n=0;n1&&arguments[1]!==undefined?arguments[1]:{},y=e.use_dynamic,m=e.error;var g=this;var b;if(v.cdr instanceof M&&D.isString(v.cdr.car)&&v.cdr.cdr!==U){b=v.cdr.car.valueOf()}function w(){var e=Pa(this)?this:{dynamic_env:g},r=e.dynamic_env;var n=g.inherit("lambda");r=r.inherit("lambda");if(this&&!Pa(this)){if(this&&!this.__instance__){Object.defineProperty(this,"__instance__",{enumerable:false,get:function e(){return true},set:function e(){},configurable:false})}n.set("this",this)}for(var t=arguments.length,i=new Array(t),u=0;u>> "+d.toString());if(d){h=d}var v=u.merge(n,ka.__merge_env__);if(r){return{expr:h,scope:v}}var y=P(h,T(T({},o),{},{env:v}));return Sa(y,_)}c=c.cdr}}catch(e){e.message+=" in macro: ".concat(m.toString(true));throw e}throw new Error("Invalid Syntax ".concat(e.toString(true)))},w);r.__code__=m;return r},"(syntax-rules () (pattern expression) ...)\n\n Base of hygienic macros, it will return a new syntax expander\n that works like Lisp macros."),quote:l(new q("quote",function(e){return ds(e.car)}),"(quote expression) or 'expression\n\n Macro that returns a single LIPS expression as data (it won't evaluate the\n argument). It will return a list if put in front of LIPS code.\n And if put in front of a symbol it will return the symbol itself, not the value\n bound to that name."),"unquote-splicing":l("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code) or ,@code\n\n Special form used in the quasiquote macro. It evaluates the expression inside and\n splices the list into quasiquote's result. If it is not the last element of the\n expression, the computed value must be a pair."),unquote:l("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code) or ,code\n\n Special form used in the quasiquote macro. It evaluates the expression inside and\n substitutes the value into quasiquote's result."),quasiquote:q.defmacro("quasiquote",function(e,t){var o=t.use_dynamic,s=t.error;var c=this;var f=c;function u(e){return e instanceof M||ra(e)||Array.isArray(e)}function l(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:u;if(e instanceof M){var n=e.car;var i=e.cdr;if(r(n)){n=t(n)}if(r(i)){i=t(i)}if(Ua(n)||Ua(i)){return fu([n,i]).then(function(e){var t=b(e,2),r=t[0],n=t[1];return new M(r,n)})}else{return new M(n,i)}}return e}function a(e,t){if(e instanceof M){if(t!==U){e.append(t)}}else{e=new M(e,t)}return e}function r(e){return!!e.filter(function(e){return e instanceof M&&L.is(e.car,/^(unquote|unquote-splicing)$/)}).length}function h(e,n,i){return e.reduce(function(e,t){if(!(t instanceof M)){e.push(t);return e}if(L.is(t.car,"unquote-splicing")){var r;if(n+11){var t="You can't splice multiple atoms inside list";throw new Error(t)}if(!(i.cdr instanceof M&&r[0]===U)){return r[0]}}r=r.map(function(e){if(d.has(e)){return e.clone()}else{d.add(e);return e}});var n=v(i.cdr,0,1);if(n===U&&r[0]===U){return undefined}return w(n,function(e){if(r[0]===U){return e}if(r.length===1){return a(r[0],e)}var t=r.reduce(function(e,t){return a(e,t)});return a(t,e)})})}(i.car.cdr)}var d=new Set;function v(e,t,r){if(e instanceof M){if(e.car instanceof M){if(L.is(e.car.car,"unquote-splicing")){return _(e,t+1,r)}if(L.is(e.car.car,"unquote")){if(t+2===r&&e.car.cdr instanceof M&&e.car.cdr.car instanceof M&&L.is(e.car.cdr.car.car,"unquote-splicing")){var n=e.car.cdr;return new M(new M(new L("unquote"),_(n,t+2,r)),U)}else if(e.car.cdr instanceof M&&e.car.cdr.cdr!==U){if(e.car.cdr.car instanceof M){var i=[];return function t(r){if(r===U){return M.fromArray(i)}return w(P(r.car,{env:c,dynamic_env:f,use_dynamic:o,error:s}),function(e){i.push(e);return t(r.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}}if(L.is(e.car,"quasiquote")){var u=v(e.cdr,t,r+1);return new M(e.car,u)}if(L.is(e.car,"quote")){return new M(e.car,v(e.cdr,t,r))}if(L.is(e.car,"unquote")){t++;if(tr){throw new Error("You can't call `unquote` outside "+"of quasiquote")}if(e.cdr instanceof M){if(e.cdr.cdr!==U){if(e.cdr.car instanceof M){var a=[];return function t(r){if(r===U){return M.fromArray(a)}return w(P(r.car,{env:c,dynamic_env:f,use_dynamic:o,error:s}),function(e){a.push(e);return t(r.cdr)})}(e.cdr)}else{return e.cdr}}else{return P(e.cdr.car,{env:c,dynamic_env:f,error:s})}}else{return e.cdr}}return l(e,function(e){return v(e,t,r)})}else if(ra(e)){return p(e,t,r)}else if(e instanceof Array){return h(e,t,r)}return e}function n(e){if(e instanceof M){delete e[uo];if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}}if(ra(e.car)&&!r(Object.values(e.car))){return ds(e.car)}if(Array.isArray(e.car)&&!r(e.car)){return ds(e.car)}if(e.car instanceof M&&!e.car.find("unquote")&&!e.car.find("unquote-splicing")&&!e.car.find("quasiquote")){return ds(e.car)}var i=v(e.car,0,1);return w(i,function(e){n(e);return ds(e)})},"(quasiquote list)\n\n Similar macro to `quote` but inside it you can use special expressions (unquote\n x) abbreviated to ,x that will evaluate x and insert its value verbatim or\n (unquote-splicing x) abbreviated to ,@x that will evaluate x and splice the value\n into the result. Best used with macros but it can be used outside."),clone:l("clone",function e(t){k("clone",t,"pair");return t.clone()},"(clone list)\n\n Function that returns a clone of the list, that does not share any pairs with the\n original, so the clone can be safely mutated without affecting the original."),append:l("append",function e(){var t;for(var r=arguments.length,n=new Array(r),i=0;iarray")(t).reverse();return I.get("array->list")(r)}else if(Array.isArray(t)){return t.reverse()}else{throw new Error(Ps("reverse",z(t),"array or pair"))}},"(reverse list)\n\n Function that reverses the list or array. If value is not a list\n or array it will error."),nth:l("nth",function e(t,r){k("nth",t,"number");k("nth",r,["array","pair"]);if(r instanceof M){var n=r;var i=0;while(iarray")(r).join(t)},"(join separator list)\n\n Function that returns a string by joining elements of the list using separator."),split:l("split",function e(t,r){k("split",t,["regex","string"]);k("split",r,"string");return I.get("array->list")(r.split(t))},"(split separator string)\n\n Function that creates a list by splitting string by separator which can\n be a string or regular expression."),replace:l("replace",function e(t,r,n){k("replace",t,["regex","string"]);k("replace",r,["string","function"]);k("replace",n,"string");return n.replace(t,r)},"(replace pattern replacement string)\n\n Function that changes pattern to replacement inside string. Pattern can be a\n string or regex and replacement can be function or string. See Javascript\n String.replace()."),match:l("match",function e(t,r){k("match",t,["regex","string"]);k("match",r,"string");var n=r.match(t);return n?I.get("array->list")(n):false},"(match pattern string)\n\n Function that returns a match object from JavaScript as a list or #f if\n no match."),search:l("search",function e(t,r){k("search",t,["regex","string"]);k("search",r,"string");return r.search(t)},"(search pattern string)\n\n Function that returns the first found index of the pattern inside a string."),repr:l("repr",function e(t,r){return da(t,r)},"(repr obj)\n\n Function that returns a LIPS code representation of the object as a string."),"escape-regex":l("escape-regex",function(e){k("escape-regex",e,"string");return Wi(e.valueOf())},"(escape-regex string)\n\n Function that returns a new string where all special operators used in regex,\n are escaped with backslashes so they can be used in the RegExp constructor\n to match a literal string."),env:l("env",function e(e){e=e||this.env;var t=Object.keys(e.__env__).map(L);var r;if(t.length){r=M.fromArray(t)}else{r=U}if(e.__parent__ instanceof F){return I.get("env").call(this,e.__parent__).append(r)}return r},"(env)\n (env obj)\n\n Function that returns a list of names (functions, macros and variables)\n that are bound in the current environment or one of its parents."),new:l("new",function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2&&arguments[2]!==undefined?arguments[2]:d.LITERAL;k("set-special!",e,"string",1);k("set-special!",t,"symbol",2);d.append(e.valueOf(),t,r)},'(set-special! symbol name [type])\n\n Add a special symbol to the list of transforming operators by the parser.\n e.g.: `(add-special! "#" \'x)` will allow to use `#(1 2 3)` and it will be\n transformed into (x (1 2 3)) so you can write x macro that will process\n the list. 3rd argument is optional, and it can be one of two values:\n lips.specials.LITERAL, which is the default behavior, or\n lips.specials.SPLICE which causes the value to be unpacked into the expression.\n This can be used for e.g. to make `#(1 2 3)` into (x 1 2 3) that is needed\n by # that defines vectors.'),get:ys,".":ys,unbind:l(Wa,"(unbind fn)\n\n Function that removes the weak 'this' binding from a function so you\n can get properties from the actual function object."),type:l(z,"(type object)\n\n Function that returns the type of an object as string."),debugger:l("debugger",function(){debugger},'(debugger)\n\n Function that triggers the JavaScript debugger (e.g. the browser devtools)\n using the "debugger;" statement. If a debugger is not running this\n function does nothing.'),in:l("in",function(e,t){if(e instanceof L||e instanceof D||e instanceof j){e=e.valueOf()}return e in Ha(t)},'(in key value)\n\n Function that uses the Javascript "in" operator to check if key is\n a valid property in the value.'),"instance?":l("instance?",function(e){return za(e)},"(instance? obj)\n\n Checks if object is an instance, created with a new operator"),instanceof:l("instanceof",function(e,t){return t instanceof Wa(e)},"(instanceof type obj)\n\n Predicate that tests if the obj is an instance of type."),"prototype?":l("prototype?",va,"(prototype? obj)\n\n Predicate that tests if value is a valid JavaScript prototype,\n i.e. calling (new) with it will not throw ' is not a constructor'."),"macro?":l("macro?",function(e){return e instanceof q},"(macro? expression)\n\n Predicate that tests if value is a macro."),"function?":l("function?",m,"(function? expression)\n\n Predicate that tests if value is a callable function."),"real?":l("real?",function(e){if(z(e)!=="number"){return false}if(e instanceof j){return e.isFloat()}return j.isFloat(e)},"(real? number)\n\n Predicate that tests if value is a real number (not complex)."),"number?":l("number?",function(e){return Number.isNaN(e)||j.isNumber(e)},"(number? expression)\n\n Predicate that tests if value is a number or NaN value."),"string?":l("string?",function(e){return D.isString(e)},"(string? expression)\n\n Predicate that tests if value is a string."),"pair?":l("pair?",function(e){return e instanceof M},"(pair? expression)\n\n Predicate that tests if value is a pair or list structure."),"regex?":l("regex?",function(e){return e instanceof RegExp},"(regex? expression)\n\n Predicate that tests if value is a regular expression."),"null?":l("null?",function(e){return ja(e)},"(null? expression)\n\n Predicate that tests if value is null-ish (i.e. undefined, nil, or\n Javascript null)."),"boolean?":l("boolean?",function(e){return typeof e==="boolean"},"(boolean? expression)\n\n Predicate that tests if value is a boolean (#t or #f)."),"symbol?":l("symbol?",function(e){return e instanceof L},"(symbol? expression)\n\n Predicate that tests if value is a LIPS symbol."),"array?":l("array?",function(e){return e instanceof Array},"(array? expression)\n\n Predicate that tests if value is an array."),"object?":l("object?",function(e){return e!==U&&e!==null&&!(e instanceof h)&&!(e instanceof RegExp)&&!(e instanceof D)&&!(e instanceof M)&&!(e instanceof j)&&p(e)==="object"&&!(e instanceof Array)},"(object? expression)\n\n Predicate that tests if value is an plain object (not another LIPS type)."),flatten:l("flatten",function e(t){k("flatten",t,"pair");return t.flatten()},"(flatten list)\n\n Returns a shallow list from tree structure (pairs)."),"array->list":l("array->list",function(e){k("array->list",e,"array");return M.fromArray(e)},"(array->list array)\n\n Function that converts a JavaScript array to a LIPS cons list."),"tree->array":l("tree->array",ea("tree->array",true),"(tree->array list)\n\n Function that converts a LIPS cons tree structure into a JavaScript array."),"list->array":l("list->array",ea("list->array"),"(list->array list)\n\n Function that converts a LIPS list into a JavaScript array."),apply:l("apply",function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;iarray").call(this,u));return t.apply(this,Ys(t,n))},"(apply fn list)\n\n Function that calls fn with the list of arguments."),length:l("length",function e(t){if(!t||t===U){return 0}if(t instanceof M){return t.length()}if("length"in t){return t.length}},'(length expression)\n\n Function that returns the length of the object. The object can be a LIPS\n list or any object that has a "length" property. Returns undefined if the\n length could not be found.'),"string->number":l("string->number",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;k("string->number",e,"string",1);k("string->number",t,"number",2);e=e.valueOf();t=t.valueOf();if(e.match(ji)||e.match(Oi)){return Ti(e,t)}else if(e.match(Ii)||e.match(Ci)){return Mi(e,t)}else{var r=t===10&&!e.match(/e/i)||t===16;if(e.match(Bi)&&r||e.match(Si)){return Li(e,t)}if(e.match(mi)){return Vi(e)}}return false},"(string->number number [radix])\n\n Function that parses a string into a number."),try:l(new q("try",function(r,e){var l=this;var h=e.use_dynamic;e.error;return new Promise(function(t,o){var s,n;if(L.is(r.cdr.car.car,"catch")){s=r.cdr.car;if(r.cdr.cdr instanceof M&&L.is(r.cdr.cdr.car.car,"finally")){n=r.cdr.cdr.car}}else if(L.is(r.cdr.car.car,"finally")){n=r.cdr.car}if(!(n||s)){throw new Error("try: invalid syntax")}function c(e){t(e);throw new hs("[CATCH]")}var f=function e(t,r){r(t)};if(n){f=function e(t,r){f=o;i.error=function(e){throw e};w(P(new M(new L("begin"),n.cdr),i),function(){r(t)})}}var i={env:l,use_dynamic:h,dynamic_env:l,error:function e(t){if(t instanceof hs){throw t}var r=l.inherit("try");if(s){var n=s.cdr.car.car;if(!(n instanceof L)){throw new Error("try: invalid syntax: catch require variable name")}r.set(n,t);var i;var u={env:r,use_dynamic:h,dynamic_env:l,error:function e(t){i=true;o(t);throw new hs("[CATCH]")}};var a=P(new M(new L("begin"),s.cdr.cdr),u);w(a,function e(t){if(!i){f(t,c)}})}else{f(undefined,function(){throw t})}}};var e=P(r.car,i);w(e,function(e){f(e,t)},i.error)})}),"(try expr (catch (e) code))\n (try expr (catch (e) code) (finally code))\n (try expr (finally code))\n\n Macro that executes expr and catches any exceptions thrown. If catch is provided\n it's executed when an error is thrown. If finally is provided it's always\n executed at the end."),raise:l("raise",function(e){throw e},"(raise obj)\n\n Throws the object verbatim (no wrapping an a new Error)."),throw:l("throw",function(e){throw new Error(e)},"(throw string)\n\n Throws a new exception."),find:l("find",function t(r,n){k("find",r,["regex","function"]);k("find",n,["pair","nil"]);if(ja(n)){return U}var e=Cu("find",r);return w(e(n.car),function(e){if(e&&e!==U){return n.car}return t(r,n.cdr)})},"(find fn list)\n (find regex list)\n\n Higher-order function that finds the first value for which fn return true.\n If called with a regex it will create a matcher function."),"for-each":l("for-each",function(e){var t;k("for-each",e,"function");for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i1?t-1:0),u=1;u3?n-3:0),u=3;u3?i-3:0),a=3;aarray")(r);var u=[];var a=Cu("filter",t);return function t(r){function e(e){if(e&&e!==U){u.push(n)}return t(++r)}if(r===i.length){return M.fromArray(u)}var n=i[r];return w(a(n),e)}(0)},"(filter fn list)\n (filter regex list)\n\n Higher-order function that calls `fn` for each element of the list\n and return a new list for only those elements for which fn returns\n a truthy value. If called with a regex it will create a matcher function."),compose:l(xo,"(compose . fns)\n\n Higher-order function that creates a new function that applies all functions\n from right to left and returns the last value. Reverse of pipe.\n e.g.:\n ((compose (curry + 2) (curry * 3)) 10) --\x3e (+ 2 (* 3 10)) --\x3e 32"),pipe:l(Ao,"(pipe . fns)\n\n Higher-order function that creates a new function that applies all functions\n from left to right and returns the last value. Reverse of compose.\n e.g.:\n ((pipe (curry + 2) (curry * 3)) 10) --\x3e (* 3 (+ 2 10)) --\x3e 36"),curry:l(Bo,"(curry fn . args)\n\n Higher-order function that creates a curried version of the function.\n The result function will have partially applied arguments and it\n will keep returning one-argument functions until all arguments are provided,\n then it calls the original function with the accumulated arguments.\n\n e.g.:\n (define (add a b c d) (+ a b c d))\n (define add1 (curry add 1))\n (define add12 (add 2))\n (display (add12 3 4))"),gcd:l("gcd",function e(){for(var t=arguments.length,r=new Array(t),n=0;no?u%=o:o%=u}u=ma(s*r[a])/(u+o)}return j(u)},"(lcm n1 n2 ...)\n\n Function that returns the least common multiple of the arguments."),"odd?":l("odd?",Co(function(e){return j(e).isOdd()}),"(odd? number)\n\n Checks if number is odd."),"even?":l("even?",Co(function(e){return j(e).isEven()}),"(even? number)\n\n Checks if number is even."),"*":l("*",So(function(e,t){return j(e).mul(t)},j(1)),"(* . numbers)\n\n Multiplies all numbers passed as arguments. If single value is passed\n it will return that value."),"+":l("+",So(function(e,t){return j(e).add(t)},j(0)),"(+ . numbers)\n\n Sums all numbers passed as arguments. If single value is passed it will\n return that value."),"-":l("-",function(){for(var e=arguments.length,t=new Array(e),r=0;r":l(">",function(){for(var e=arguments.length,t=new Array(e),r=0;r",t,["bigint","float","rational"]);return ga(function(e,t){return j(e).cmp(t)===1},t)},"(> x1 x2 x3 ...)\n\n Function that compares its numerical arguments and checks if they are\n monotonically decreasing, i.e. x1 > x2 and x2 > x3 and so on."),"<":l("<",function(){for(var e=arguments.length,t=new Array(e),r=0;r=":l(">=",function(){for(var e=arguments.length,t=new Array(e),r=0;r=",t,["bigint","float","rational"]);return ga(function(e,t){return[0,1].includes(j(e).cmp(t))},t)},"(>= x1 x2 ...)\n\n Function that compares its numerical arguments and checks if they are\n monotonically nonincreasing, i.e. x1 >= x2 and x2 >= x3 and so on."),"eq?":l("eq?",ba,"(eq? a b)\n\n Function that compares two values if they are identical."),or:l(new q("or",function(e,t){var i=t.use_dynamic,u=t.error;var a=I.get("list->array")(e);var o=this;var s=o;if(!a.length){return false}var c;return function t(){function e(e){c=e;if(c!==false){return c}else{return t()}}if(!a.length){if(c!==false){return c}else{return false}}else{var r=a.shift();var n=P(r,{env:o,dynamic_env:s,use_dynamic:i,error:u});return w(n,e)}}()}),"(or . expressions)\n\n Macro that executes the values one by one and returns the first that is\n a truthy value. If there are no expressions that evaluate to true it\n returns false."),and:l(new q("and",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=I.get("list->array")(e);var u=this;var a=u;if(!i.length){return true}var o;var s={env:u,dynamic_env:a,use_dynamic:r,error:n};return function t(){function e(e){o=e;if(o===false){return false}else{return t()}}if(!i.length){if(o!==false){return o}else{return false}}else{var r=i.shift();return w(P(r,s),e)}}()}),"(and . expressions)\n\n Macro that evaluates each expression in sequence and if any value returns false\n it will stop and return false. If each value returns true it will return the\n last value. If it's called without arguments it will return true."),"|":l("|",function(e,t){return j(e).or(t)},"(| a b)\n\n Function that calculates the bitwise or operation."),"&":l("&",function(e,t){return j(e).and(t)},"(& a b)\n\n Function that calculates the bitwise and operation."),"~":l("~",function(e){return j(e).neg()},"(~ number)\n\n Function that calculates the bitwise inverse (flip all the bits)."),">>":l(">>",function(e,t){return j(e).shr(t)},"(>> a b)\n\n Function that right shifts the value a by value b bits."),"<<":l("<<",function(e,t){return j(e).shl(t)},"(<< a b)\n\n Function that left shifts the value a by value b bits."),not:l("not",function e(t){if(ja(t)){return true}return!t},"(not object)\n\n Function that returns the Boolean negation of its argument.")},undefined,"global");var Es=I.inherit("user-env");function As(e,t){e.constant("**internal-env**",t);e.doc("**internal-env**","**internal-env**\n\n Constant used to hide stdin, stdout and stderr so they don't interfere\n with variables with the same name. Constants are an internal type\n of variable that can't be redefined, defining a variable with the same name\n will throw an error.");I.set("**interaction-environment**",e)}As(Es,bs);I.doc("**interaction-environment**","**interaction-environment**\n\n Internal dynamic, global variable used to find interpreter environment.\n It's used so the read and write functions can locate **internal-env**\n that contains the references to stdin, stdout and stderr.");function xs(e){Es.get("**internal-env**").set("fs",e)}(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(t){var r=e[t]?e[t]:t;I.set(r,l(r,function(e){k(r,e,"number");if(e instanceof j){return e[t]()}},"(".concat(r," number)\n\n Function that calculates the ").concat(r," of a number.")))})})();function Fs(e){if(e.length===1){return e[0]}else{var t=[];var r=Fs(e.slice(1));for(var n=0;n3&&arguments[3]!==undefined?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(n!==null){i+=" (argument ".concat(n,")")}if(m(r)){return"Invalid type: got ".concat(t).concat(i)}if(r instanceof Array){if(r.length===1){var u=r[0].toLowerCase();r="a"+("aeiou".includes(u)?"n ":" ")+r[0]}else{r=new Intl.ListFormat("en",{style:"long",type:"disjunction"}).format(r)}}return"Expecting ".concat(r," got ").concat(t).concat(i)}function Ns(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;k(e,t,"number",n);var i=t.__type__;var u;if(r instanceof M){r=r.to_array()}if(r instanceof Array){r=r.map(function(e){return e.valueOf()})}if(r instanceof Array){r=r.map(function(e){return e.valueOf().toLowerCase()});if(r.includes(i)){u=true}}else{r=r.valueOf().toLowerCase()}if(!u&&i!==r){throw new Error(Ps(e,i,r,n))}}function Rs(r,e,n){e.forEach(function(e,t){Ns(r,e,n,t+1)})}function Ts(r,e,n){e.forEach(function(e,t){k(r,e,n,t+1)})}function Ls(e,t,r){k(e,t,r);if(t.__type__===as){throw new Error(Ps(e,"binary-port","textual-port"))}}function k(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;e=e.valueOf();var i=z(t).toLowerCase();if(m(r)){if(!r(t)){throw new Error(Ps(e,i,r,n))}return}var u=false;if(r instanceof M){r=r.to_array()}if(r instanceof Array){r=r.map(function(e){return e.valueOf()})}if(r instanceof Array){r=r.map(function(e){return e.valueOf().toLowerCase()});if(r.includes(i)){u=true}}else{r=r.valueOf().toLowerCase()}if(!u&&i!==r){throw new Error(Ps(e,i,r,n))}}function Us(r){var n=new WeakMap;return function(e){var t=n.get(e);if(!t){t=r(e)}return t}}z=Us(z);function z(e){var t=ni.get(e);if(t){return t}if(p(e)==="object"){for(var r=0,n=Object.entries(ri);r2&&arguments[2]!==undefined?arguments[2]:{},n=r.env,i=r.dynamic_env,u=r.use_dynamic;var a=n===null||n===void 0?void 0:n.new_frame(e,t);var o=i===null||i===void 0?void 0:i.new_frame(e,t);var s=new Gs({env:a,use_dynamic:u,dynamic_env:o});return Ms(e.apply(s,t))}function Js(n,e){var t=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},i=t.env,u=t.dynamic_env,a=t.use_dynamic,r=t.error,o=r===void 0?function(){}:r;e=qs(e,{env:i,dynamic_env:u,error:o,use_dynamic:a});return w(e,function(e){if(go(n)){n=Wa(n)}e=Ys(n,e);var t=e.slice();var r=$s(n,t,{env:i,dynamic_env:u,use_dynamic:a});return w(r,function(e){if(e instanceof M){e.markCycles();return ds(e)}return Ja(e)},o)})}var Ks=new WeakMap;var Hs=function(){function n(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;oe(this,n);he(this,"__value__",void 0);he(this,"__fn__",void 0);$n(this,Ks,{writable:true,value:void 0});this.__value__=e;if(t){if(!m(t)){throw new Error("Section argument to Parameter need to be function "+"".concat(z(t)," given"))}this.__fn__=t}if(r){N(this,Ks,r)}}le(n,[{key:"__name__",get:function e(){return t(this,Ks)},set:function e(t){N(this,Ks,t);if(this.__fn__){this.__fn__.__name__="fn-".concat(t)}}},{key:"invoke",value:function e(){if(m(this.__fn__)){return this.__fn__(this.__value__)}return this.__value__}},{key:"inherit",value:function e(t){return new n(t,this.__fn__,this.__name__)}}]);return n}();var Gs=function(){function t(e){oe(this,t);he(this,"env",void 0);he(this,"dynamic_env",void 0);he(this,"use_dynamic",void 0);Object.assign(this,e)}le(t,[{key:"__name__",get:function e(){return this.env.__name__}},{key:"__parent__",get:function e(){return this.env.__parent__}},{key:"get",value:function e(){var t;return(t=this.env).get.apply(t,arguments)}}]);return t}();function Ws(e,t){var r=e.get(t.__name__,{throwError:false});if(Na(r)&&r!==t){return r}var n=Es.get("**interaction-environment**");while(true){var i=e.get("parent.frame",{throwError:false});e=i(0);if(e===n){break}r=e.get(t.__name__,{throwError:false});if(Na(r)&&r!==t){return r}}return t}var Qs=function(){function t(e){oe(this,t);he(this,"__value__",void 0);this.__value__=e}le(t,[{key:"invoke",value:function e(){if(this.__value__===null){throw new Error("Continuations are not implemented yet")}}}]);return t}();function P(o){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},s=e.env,c=e.dynamic_env,f=e.use_dynamic,t=e.error,l=t===void 0?Bs:t,r=_e(e,Yn);return function(e){try{if(!Ta(c)){c=s===true?Es:s||Es}if(f){s=c}else if(s===true){s=Es}else{s=s||I}var t={env:s,dynamic_env:c,use_dynamic:f,error:l};var r;if(ja(o)){return o}if(o instanceof L){return s.get(o)}if(!(o instanceof M)){return o}var n=o.car;var e=o.cdr;if(n instanceof M){r=Ms(P(n,t));if(Ua(r)){return r.then(function(e){if(!La(e)){throw new Error(z(e)+" "+s.get("repr")(e)+" is not callable while evaluating "+o.toString())}return P(new M(e,o.cdr),t)})}else if(!La(r)){throw new Error(z(r)+" "+s.get("repr")(r)+" is not callable while evaluating "+o.toString())}}if(n instanceof L){r=s.get(n)}else if(m(n)){r=n}var i;if(r instanceof ka){i=zs(r,o,t)}else if(r instanceof q){i=Vs(r,e,t)}else if(m(r)){i=Js(r,e,t)}else if(Na(r)){var u=Ws(c,r);if(ja(o.cdr)){i=u.invoke()}else{return w(P(o.cdr.car,t),function(e){u.__value__=e})}}else if(Ia(r)){i=r.invoke()}else if(o instanceof M){r=n&&n.toString();throw new Error("".concat(z(n)," ").concat(r," is not a function"))}else{return o}var a=s.get(Symbol["for"]("__promise__"),{throwError:false});if(a===true&&Ua(i)){i=i.then(function(e){if(e instanceof M&&!r[uo]){return P(e,t)}return e});return new cu(i)}return i}catch(e){l&&l.call(s,e,o)}}(r)}var Zs=ec(function(e){return e});var Xs=ec(function(e,t){return t});function ec(d){return function(){var t=ae(function(l){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},h=e.env,p=e.dynamic_env,_=e.use_dynamic;return C.mark(function e(){var r,n,i,u,a,o,s,c,f;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!Ta(p)){p=h===true?Es:h||Es}if(h===true){h=Es}else{h=h||Es}r=[];n=Array.isArray(l)?l:Du(l);i=false;u=false;t.prev=6;o=Xn(n);case 8:t.next=10;return o.next();case 10:if(!(i=!(s=t.sent).done)){t.next=24;break}c=s.value;f=P(c,{env:h,dynamic_env:p,use_dynamic:_,error:function e(t,r){if(t&&t.message){if(t.message.match(/^Error:/)){var n=/^(Error:)\s*([^:]+:\s*)/;t.message=t.message.replace(n,"$1 $2")}if(r){if(!(t.__code__ instanceof Array)){t.__code__=[]}t.__code__.push(r.toString(true))}}if(!(t instanceof hs)){throw t}}});t.t0=r;t.t1=d;t.t2=c;t.next=18;return f;case 18:t.t3=t.sent;t.t4=(0,t.t1)(t.t2,t.t3);t.t0.push.call(t.t0,t.t4);case 21:i=false;t.next=8;break;case 24:t.next=30;break;case 26:t.prev=26;t.t5=t["catch"](6);u=true;a=t.t5;case 30:t.prev=30;t.prev=31;if(!(i&&o["return"]!=null)){t.next=35;break}t.next=35;return o["return"]();case 35:t.prev=35;if(!u){t.next=38;break}throw a;case 38:return t.finish(35);case 39:return t.finish(30);case 40:return t.abrupt("return",r);case 41:case"end":return t.stop()}},e,null,[[6,26,30,40],[31,,35,39]])})()});function e(e){return t.apply(this,arguments)}return e}()}function tc(e){var t={"[":"]","(":")"};var r;if(typeof e==="string"){r=nu(e)}else{r=e.map(function(e){return e&&e.token?e.token:e})}var n=Object.keys(t);var i=Object.values(t).concat(n);r=r.filter(function(e){return i.includes(e)});var u=new Qi;var a=Gn(r),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;if(n.includes(s)){u.push(s)}else if(!u.is_empty()){var c=u.top();var f=t[c];if(s===f){u.pop()}else{throw new Error("Syntax error: missing closing ".concat(f))}}else{throw new Error("Syntax error: not matched closing ".concat(s))}}}catch(e){a.e(e)}finally{a.f()}return u.is_empty()}function rc(e){var t="("+e.toString()+")()";var r=window.URL||window.webkitURL;var n;try{n=new Blob([t],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;n=new i;n.append(t);n=n.getBlob()}return new ti.Worker(r.createObjectURL(n))}function nc(){return Pc.version.match(/^(\{\{VER\}\}|DEV)$/)}function ic(){if(Ss()){return}var e;if(document.currentScript){e=document.currentScript}else{var t=document.querySelectorAll("script");if(!t.length){return}e=t[t.length-1]}var r=e.getAttribute("src");return r}var uc=ic();function ac(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var t="dist/std.xcb";if(e===""){if(uc){e=uc.replace(/[^/]*$/,"std.xcb")}else if(nc()){e="https://cdn.jsdelivr.net/gh/jcubic/lips@devel/".concat(t)}else{e="https://cdn.jsdelivr.net/npm/@jcubic/lips@".concat(Pc.version,"/").concat(t)}}var r=I.get("load");return r.call(Es,e,I)}function oc(e){this.url=e;var a=this.worker=rc(function(){var a;var o;self.addEventListener("message",function(e){var r=e.data;var t=r.id;if(r.type!=="RPC"||t===null){return}function n(e){self.postMessage({id:t,type:"RPC",result:e})}function i(e){self.postMessage({id:t,type:"RPC",error:e})}if(r.method==="eval"){if(!o){i("Worker RPC: LIPS not initialized, call init first");return}o.then(function(){var e=r.params[0];var t=r.params[1];a.exec(e,{use_dynamic:t}).then(function(e){e=e.map(function(e){return e&&e.valueOf()});n(e)})["catch"](function(e){i(e)})})}else if(r.method==="init"){var u=r.params[0];if(typeof u!=="string"){i("Worker RPC: url is not a string")}else{importScripts("".concat(u,"/dist/lips.min.js"));a=new Pc.Interpreter("worker");o=ac(u);o.then(function(){n(true)})}}})});this.rpc=function(){var n=0;return function e(t,r){var u=++n;return new Promise(function(n,i){a.addEventListener("message",function e(t){var r=t.data;if(r&&r.type==="RPC"&&r.id===u){if(r.error){i(r.error)}else{n(r.result)}a.removeEventListener("message",e)}});a.postMessage({type:"RPC",method:t,id:u,params:r})})}}();this.rpc("init",[e])["catch"](function(e){console.error(e)});this.exec=function(e,t){var r=t.use_dynamic,n=r===void 0?false:r;return this.rpc("eval",[e,n])}}var sc={pair:function e(t){var r=b(t,2),n=r[0],i=r[1];return M(n,i)},number:function e(t){if(D.isString(t)){return j([t,10])}return j(t)},regex:function e(t){var r=b(t,2),n=r[0],i=r[1];return new RegExp(n,i)},nil:function e(){return U},symbol:function e(t){if(D.isString(t)){return L(t)}else if(Array.isArray(t)){return L(Symbol["for"](t[0]))}},string:D,character:h};var cc=Object.keys(sc);var fc={};for(var lc=0,hc=Object.entries(cc);lc1){var n=t.reduce(function(e,t){return e+t.length},0);var i=new Uint8Array(n);var u=0;t.forEach(function(e){i.set(e,u);u+=e.length});return i}else if(t.length){return t[0]}}function Dc(){var e=1;var t=new TextEncoder("utf-8");return t.encode("LIPS".concat(e.toString().padStart(3," ")))}var Ec=7;function Ac(e){var t=new TextDecoder("utf-8");var r=t.decode(e.slice(0,Ec));var n=r.substring(0,4);if(n==="LIPS"){var i=r.match(/^(....).*([0-9]+)$/);if(i){return{type:i[1],version:Number(i[2])}}}return{type:"unknown"}}function xc(e){var t=Dc();var r=bc.encode(e);return wc(t,Rn(r,{magic:false}))}function Fc(e){var t=Ac(e),r=t.type,n=t.version;if(r==="LIPS"&&n===1){var i=Tn(e.slice(Ec),{magic:false});return bc.decode(i)}else{throw new Error("Invalid file format ".concat(r))}}function kc(e){console.error(e.message||e);if(Array.isArray(e.code)){console.error(e.code.map(function(e,t){return"[".concat(t+1,"]: ").concat(e)}))}}function Cc(){var a=["text/x-lips","text/x-scheme"];var o;function s(r){return new Promise(function(t){var e=r.getAttribute("src");if(e){return fetch(e).then(function(e){return e.text()}).then(Xs).then(t)["catch"](function(e){kc(e);t()})}else{return Xs(r.innerHTML).then(t)["catch"](function(e){kc(e);t()})}})}function e(){return new Promise(function(i){var u=Array.from(document.querySelectorAll("script"));return function e(){var t=u.shift();if(!t){i()}else{var r=t.getAttribute("type");if(a.includes(r)){var n=t.getAttribute("bootstrap");if(!o&&typeof n==="string"){return ac(n).then(function(){return s(t)}).then(e)}else{return s(t).then(e)}}else if(r&&r.match(/lips|lisp/)){console.warn("Expecting "+a.join(" or ")+" found "+r)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(Oc){var t=Oc;var r=t.getAttribute("bootstrap");if(typeof r==="string"){return ac(r).then(function(){o=true;return e()})}}return e()}var Oc=typeof window!=="undefined"&&window.document&&document.currentScript;if(typeof window!=="undefined"){si(window,Cc)}var Sc=function(){var e=D("Mon, 22 Jan 2024 12:07:50 +0000").valueOf();var t=e==="{{"+"DATE}}"?new Date:new Date(e);var r=function e(t){return t.toString().padStart(2,"0")};var n=t.getFullYear();var i=[n,r(t.getMonth()+1),r(t.getDate())].join("-");var u="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(n," Jakub T. Jankiewicz\n\nType (env) to see environment with functions macros and variables. You can also\nuse (help name) to display help for specific function or macro, (apropos name)\nto display list of matched names in environment and (dir object) to list\nproperties of an object.\n").replace(/^.*\n/,"");return u}();f(Pu,"__class__","ahead");f(M,"__class__","pair");f(Xu,"__class__","nil");f(Nu,"__class__","pattern");f(Iu,"__class__","formatter");f(q,"__class__","macro");f(ka,"__class__","syntax");f(F,"__class__","environment");f(Go,"__class__","input-port");f(Wo,"__class__","output-port");f(Qo,"__class__","output-port");f(Zo,"__class__","output-string-port");f(es,"__class__","input-string-port");f(ns,"__class__","input-file-port");f(Xo,"__class__","output-file-port");f(ls,"__class__","lips-error");[j,g,A,E,x].forEach(function(e){f(e,"__class__","number")});f(h,"__class__","character");f(L,"__class__","symbol");f(D,"__class__","string");f(cu,"__class__","promise");f(Hs,"__class__","parameter");var Bc="DEV";var jc="Mon, 22 Jan 2024 12:07:50 +0000";var Ic=xo(Fu,Du);var Pc={version:Bc,banner:Sc,date:jc,exec:Xs,parse:Ic,tokenize:nu,evaluate:P,compile:Zs,serialize:mc,unserialize:gc,serialize_bin:xc,unserialize_bin:Fc,bootstrap:ac,Environment:F,env:Es,Worker:oc,Interpreter:fs,balanced_parenthesis:tc,balancedParenthesis:tc,balanced:tc,Macro:q,Syntax:ka,Pair:M,Values:_s,QuotedPromise:cu,Error:ls,quote:ds,InputPort:Go,OutputPort:Wo,BufferedOutputPort:Qo,InputFilePort:ns,OutputFilePort:Xo,InputStringPort:es,OutputStringPort:Zo,InputByteVectorPort:ts,OutputByteVectorPort:rs,InputBinaryFilePort:is,OutputBinaryFilePort:us,set_fs:xs,Formatter:Iu,Parser:bu,Lexer:s,specials:d,repr:ta,nil:U,eof:ss,LSymbol:L,LNumber:j,LFloat:E,LComplex:g,LRational:A,LBigInteger:x,LCharacter:h,LString:D,Parameter:Hs,rationalize:Ko};I.set("lips",Pc);var Nc={};var Rc=Object.freeze({__proto__:null,default:Nc});function Tc(e,t){var r=0;for(var n=e.length-1;n>=0;n--){var i=e[n];if(i==="."){e.splice(n,1)}else if(i===".."){e.splice(n,1);r++}else if(r){e.splice(n,1);r--}}if(t){for(;r--;r){e.unshift("..")}}return e}var Lc=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var Uc=function(e){return Lc.exec(e).slice(1)};function Mc(){var e="",t=false;for(var r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if(typeof n!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!n){continue}e=n+"/"+e;t=n.charAt(0)==="/"}e=Tc(Qc(e.split("/"),function(e){return!!e}),!t).join("/");return(t?"/":"")+e||"."}function qc(e){var t=zc(e),r=Zc(e,-1)==="/";e=Tc(Qc(e.split("/"),function(e){return!!e}),!t).join("/");if(!e&&!t){e="."}if(e&&r){e+="/"}return(t?"/":"")+e}function zc(e){return e.charAt(0)==="/"}function Vc(){var e=Array.prototype.slice.call(arguments,0);return qc(Qc(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))}function Yc(e,t){e=Mc(e).substr(1);t=Mc(t).substr(1);function r(e){var t=0;for(;t=0;r--){if(e[r]!=="")break}if(t>r)return[];return e.slice(t,r-t+1)}var n=r(e.split("/"));var i=r(t.split("/"));var u=Math.min(n.length,i.length);var a=u;for(var o=0;or-En){t[i++]=e[n++];continue}f=(e[n]+13^e[n+1]-13^e[n+2])&xn-1;c=n-l[f]&An;l[f]=n;u=n-c;if(u>=0&&u!=n&&e[n]==e[u]&&e[n+1]==e[u+1]&&e[n+2]==e[u+2]){t[a]|=o;for(s=Dn;s>bn;t[i++]=c;n+=s}else{t[i++]=e[n++]}}console.assert(e.length>=n);return i}function kn(e,t,r){t=t|0;var n=0,i=0,u=0,a=0,o=1<<(bn-1|0),s=0,c=0;while(n>(bn-wn|0))+Dn|0;c=(e[n]<4){r[i]=r[u];i=i+1|0;u=u+1|0;r[i]=r[u];i=i+1|0;u=u+1|0;r[i]=r[u];i=i+1|0;u=u+1|0;r[i]=r[u];i=i+1|0;u=u+1|0;s=s-4|0}while(s>0){r[i]=r[u];i=i+1|0;u=u+1|0;s=s-1|0}}}else{r[i]=e[n];i=i+1|0;n=n+1|0}}return i}function Cn(){const e=new TextEncoder("utf-8");return e.encode(On)}const On="@lzjb";const Sn=Cn();function Bn(...e){if(e.length>1){const r=e.reduce((e,t)=>e+t.length,0);const n=new Uint8Array(r);let t=0;e.forEach(e=>{n.set(e,t);t+=e.length});return n}else if(e.length){return e[0]}}function jn(t){const e=Math.ceil(Math.log2(t)/8);const r=new Uint8Array(e);for(let e=0;e=0;e--){r=r*256+t[e]}return r}function Pn(e,{magic:t=true}={}){const r=new Uint8Array(Math.max(e.length*1.5|0,16*1024));const n=Fn(e,r);const i=jn(e.length);const u=[Uint8Array.of(i.length),i,r.slice(0,n)];if(t){u.unshift(Sn)}return Bn(...u)}function Nn(t,{magic:e=true}={}){if(e){const e=new TextDecoder("utf-8");const s=e.decode(t.slice(0,Sn.length));if(s!==On){throw new Error("Invalid magic value")}}const r=e?Sn.length:0;const n=t[r];const i=r+1;const u=r+n+1;const a=In(t.slice(i,u));t=t.slice(u);const o=new Uint8Array(a);kn(t,t.length,o);return o}var Rn=gn.pack=Pn;var Tn=gn.unpack=Nn;function Ln(s,c){return c=c||{},new Promise(function(e,t){var r=new XMLHttpRequest,n=[],i=[],u={},a=function(){return{ok:2==(r.status/100|0),statusText:r.statusText,status:r.status,url:r.responseURL,text:function(){return Promise.resolve(r.responseText)},json:function(){return Promise.resolve(r.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([r.response]))},clone:a,headers:{keys:function(){return n},entries:function(){return i},get:function(e){return u[e.toLowerCase()]},has:function(e){return e.toLowerCase()in u}}}};for(var o in r.open(c.method||"get",s,!0),r.onload=function(){r.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,t,r){n.push(t=t.toLowerCase()),i.push([t,r]),u[t]=u[t]?u[t]+","+r:r}),e(a())},r.onerror=t,r.withCredentials="include"==c.credentials,c.headers)r.setRequestHeader(o,c.headers[o]);r.send(c.body||null)})}var Un=["token"],Mn=["env"],qn=["stderr","stdin","stdout","command_line"],zn=["use_dynamic"],Vn=["use_dynamic"],Yn=["env","dynamic_env","use_dynamic","error"];function $n(e,t,r){Jn(e,t);t.set(e,r)}function Jn(e,t){if(t.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function Kn(e,t,r){return t=V(t),W(e,Hn()?Reflect.construct(t,r||[],V(e).constructor):t.apply(e,r))}function Hn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Hn=function e(){return!!t})()}function Wn(t,e){var r=typeof Symbol!=="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Gn(t))||e&&t&&typeof t.length==="number"){if(r)t=r;var n=0;var i=function e(){};return{s:i,n:function e(){if(n>=t.length)return{done:true};return{done:false,value:t[n++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u=true,a=false,o;return{s:function e(){r=r.call(t)},n:function e(){var t=r.next();u=t.done;return t},e:function e(t){a=true;o=t},f:function e(){try{if(!u&&r["return"]!=null)r["return"]()}finally{if(a)throw o}}}}function Gn(e,t){if(!e)return;if(typeof e==="string")return Qn(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor)r=e.constructor.name;if(r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Qn(e,t)}function Qn(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r1&&arguments[1]!==undefined?arguments[1]:null;var n=arguments[1]===true;function t(e){if(!fi()){return}var t=I.get("repr")(e);if(r===null||r instanceof RegExp&&r.test(t)){console.log(I.get("type")(e)+": "+t)}if(n){console.log(e)}}if(Ua(e)){e.then(t)}else{t(e)}return e}function fi(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var t=Es&&Es.get("DEBUG",{throwError:false});if(e===null){return t===true}return(t===null||t===void 0?void 0:t.valueOf())===e.valueOf()}function li(e){return e?"(?:#".concat(e,"(?:#[ie])?|#[ie]#").concat(e,")"):"(?:#[ie])?"}function hi(e,t){return"".concat(li(e),"[+-]?").concat(t,"+/").concat(t,"+")}function pi(e,t){return"".concat(li(e),"(?:[+-]?(?:").concat(t,"+/").concat(t,"+|nan.0|inf.0|").concat(t,"+))?(?:[+-]i|[+-]?(?:").concat(t,"+/").concat(t,"+|").concat(t,"+|nan.0|inf.0)i)(?=[()[\\]\\s]|$)")}function _i(e,t){return"".concat(li(e),"[+-]?").concat(t,"+")}var di=/^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/;var vi="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)";var yi="(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|nan.0|inf.0|".concat(vi,"|[+-]?[0-9]+))?(?:").concat(vi,"|[+-](?:[0-9]+/[0-9]+|[0-9]+|nan.0|inf.0))i");var mi=new RegExp("^(#[ie])?".concat(vi,"$"),"i");function gi(e,t){var r=e==="x"?"(?!\\+|".concat(t,")"):"(?!\\.|".concat(t,")");var n="";if(e===""){n="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(t,"+/").concat(t,"+(?!").concat(t,")|[+-]?").concat(t,"+)").concat(r,")?)(").concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(t,"+/").concat(t,"+|[+-]?").concat(t,"+|[+-])i$"),"i")}var bi=function(){var u={};[[10,"","[0-9]"],[16,"x","[0-9a-fA-F]"],[8,"o","[0-7]"],[2,"b","[01]"]].forEach(function(e){var t=b(e,3),r=t[0],n=t[1],i=t[2];u[r]=gi(n,i)});return u}();var wi={alarm:"",backspace:"\b",delete:"",escape:"",newline:"\n",null:"\0",return:"\r",space:" ",tab:"\t",dle:"",soh:"",dc1:"",stx:"",dc2:"",etx:"",dc3:"",eot:"",dc4:"",enq:"",nak:"",ack:"",syn:"",bel:"",etb:"",bs:"\b",can:"",ht:"\t",em:"",lf:"\n",sub:"",vt:"\v",esc:"",ff:"\f",fs:"",cr:"\r",gs:"",so:"",rs:"",si:"",us:"",del:""};function Di(e){var t=[];var r=0;var n=e.length;while(r=55296&&i<=56319&&r1&&arguments[1]!==undefined?arguments[1]:10;var r=Ri(e);var n=r.number.split("/");var i=A({num:j([n[0],r.radix||t]),denom:j([n[1],r.radix||t])});if(r.inexact){return i.valueOf()}else{return i}}function Li(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;var r=Ri(e);if(r.inexact){return E(parseInt(r.number,r.radix||t))}return j([r.number,r.radix||t])}function Ui(e){var t=e.match(/#\\x([0-9a-f]+)$/i);var r;if(t){var n=parseInt(t[1],16);r=String.fromCodePoint(n)}else{t=e.match(/#\\([\s\S]+)$/);if(t){r=t[1]}}if(r){return h(r)}throw new Error("Parse: invalid character")}function Mi(e){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;function t(e){var t;if(e==="+"){t=j(1)}else if(e==="-"){t=j(-1)}else if(e.match(Bi)){t=j([e,i])}else if(e.match(ji)){var r=e.split("/");t=A({num:j([r[0],i]),denom:j([r[1],i])})}else if(e.match(mi)){var n=Vi(e);if(u.exact){return n.toRational()}return n}else if(e.match(/nan.0$/)){return j(NaN)}else if(e.match(/inf.0$/)){if(e[0]==="-"){return j(Number.NEGATIVE_INFINITY)}return j(Number.POSITIVE_INFINITY)}else{throw new Error("Internal Parser Error")}if(u.inexact){return E(t.valueOf())}return t}var u=Ri(e);i=u.radix||i;var r;var n=u.number.match(Pi);if(i!==10&&n){r=n}else{r=u.number.match(bi[i])}var a,o;o=t(r[2]);if(r[1]){a=t(r[1])}else{a=j(0)}if(o.cmp(0)===0&&o.__type__==="bigint"){return a}return g({im:o,re:a})}function qi(e){return parseInt(e.toString(),10)===e}function zi(e){var t=e.match(/^(([-+]?[0-9]*)(?:\.([0-9]+))?)e([-+]?[0-9]+)/i);if(t){var r=parseInt(t[4],10);var n;var i=t[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var u=t[3]&&t[3].length;if(i0){return j(u).mul(o)}}}r=E(r);if(t.exact){return r.toRational()}return r}function Yi(e){e=e.replace(/\\x([0-9a-f]+);/gi,function(e,t){return"\\u"+t.padStart(4,"0")}).replace(/\n/g,"\\n");var t=e.match(/(\\*)(\\x[0-9A-F])/i);if(t&&t[1].length%2===0){throw new Error("Invalid string literal, unclosed ".concat(t[2]))}try{return D(JSON.parse(e))}catch(e){var r=e.message.replace(/in JSON /,"").replace(/.*Error: /,"");throw new Error("Invalid string literal: ".concat(r))}}function $i(e){if(e.match(/^\|.*\|$/)){e=e.replace(/(^\|)|(\|$)/g,"");var r={t:"\t",r:"\r",n:"\n"};e=e.replace(/\\(x[^;]+);/g,function(e,t){return String.fromCharCode(parseInt("0"+t,16))}).replace(/\\(.)/g,function(e,t){return r[t]||t})}return new L(e)}function Ji(e){if(Ds.hasOwnProperty(e)){return Ds[e]}if(e.match(/^"[\s\S]*"$/)){return Yi(e)}else if(e[0]==="#"){var t=e.match(di);if(t){return new RegExp(t[1],t[2])}else if(e.match(xi)){return Ui(e)}var r=e.match(/#\\(.+)/);if(r&&Di(r[1]).length===1){return Ui(e)}}if(e.match(/[0-9a-f]|[+-]i/i)){if(e.match(Si)){return Li(e)}else if(e.match(mi)){return Vi(e)}else if(e.match(Oi)){return Ti(e)}else if(e.match(Ci)){return Mi(e)}}if(e.match(/^#[iexobd]/)){throw new Error("Invalid numeric constant: "+e)}return $i(e)}function Ki(e){return!(["(",")","[","]"].includes(e)||d.names().includes(e))}function Hi(e){return Ki(e)&&!(e.match(di)||e.match(/^"[\s\S]*"$/)||e.match(Si)||e.match(mi)||e.match(Ci)||e.match(Oi)||e.match(xi)||["#t","#f","nil","true","false"].includes(e))}var Wi=/"(?:\\[\S\s]|[^"])*"?/g;function Gi(e){if(typeof e==="string"){var t=/([-\\^$[\]()+{}?*.|])/g;return e.replace(t,"\\$1")}return e}function Qi(){this.data=[]}Qi.prototype.push=function(e){this.data.push(e)};Qi.prototype.top=function(){return this.data[this.data.length-1]};Qi.prototype.pop=function(){return this.data.pop()};Qi.prototype.is_empty=function(){return!this.data.length};function Zi(e){if(e instanceof D){e=e.valueOf()}var t=new s(e,{whitespace:true});var r=[];while(true){var n=t.peek(true);if(n===ss){break}r.push(n);t.skip()}return r}function Xi(e){var t=e.token,r=_e(e,Un);if(t.match(/^"[\s\S]*"$/)&&t.match(/\n/)){var n=new RegExp("^ {1,"+(e.col+1)+"}","mg");t=t.replace(n,"")}return T({token:t},r)}function eu(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};this.fn=e;this.cont=t}eu.prototype.toString=function(){return"#"};function tu(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof D){e=e.toString()}if(t){return Zi(e)}else{var r=Zi(e).map(function(e){if(e.token==="#\\ "||e.token=="#\\\n"){return e.token}return e.token.trim()}).filter(function(e){return e&&!e.match(/^;/)&&!e.match(/^#\|[\s\S]*\|#$/)});return iu(r)}}function iu(e){var t=0;var r=null;var n=[];for(var i=0;i0&&arguments[0]!==undefined?arguments[0]:null;if(e instanceof L){if(e.is_gensym()){return e}e=e.valueOf()}if(ou(e)){return L(e)}if(e!==null){return r(e,Symbol("#:".concat(e)))}t++;return r(t,Symbol("#:g".concat(t)))}}();function cu(e){var r=this;var n={pending:true,rejected:false,fulfilled:false,reason:undefined,type:undefined};e=e.then(function(e){n.type=z(e);n.fulfilled=true;n.pending=false;return e});f(this,"_promise",e,{hidden:true});if(m(e["catch"])){e=e["catch"](function(e){n.rejected=true;n.pending=false;n.reason=e})}Object.keys(n).forEach(function(t){Object.defineProperty(r,"__".concat(t,"__"),{enumerable:true,get:function e(){return n[t]}})});f(this,"__promise__",e);this.then=false}cu.prototype.then=function(e){return new cu(this.valueOf().then(e))};cu.prototype["catch"]=function(e){return new cu(this.valueOf()["catch"](e))};cu.prototype.valueOf=function(){if(!this._promise){throw new Error("QuotedPromise: invalid promise created")}return this._promise};cu.prototype.toString=function(){if(this.__pending__){return cu.pending_str}if(this.__rejected__){return cu.rejected_str}return"#")};cu.pending_str="#";cu.rejected_str="#";function fu(e){if(Array.isArray(e)){return Promise.all(lu(e)).then(hu)}return e}function lu(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof cu){t[r]=new ps(n)}else{t[r]=n}}return t}function hu(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof ps){t[r]=n.valueOf()}else{t[r]=n}}return t}var d={LITERAL:Symbol["for"]("literal"),SPLICE:Symbol["for"]("splice"),SYMBOL:Symbol["for"]("symbol"),names:function e(){return Object.keys(this.__list__)},type:function e(t){try{return this.get(t).type}catch(e){console.log({name:t});console.log(e);return null}},get:function e(t){return this.__list__[t]},off:function e(t){var r=this;var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(Array.isArray(t)){t.forEach(function(e){return r.off(e,n)})}else if(n===null){delete this.__events__[t]}else{this.__events__=this.__events__.filter(function(e){return e!==n})}},on:function e(t,r){var n=this;if(Array.isArray(t)){t.forEach(function(e){return n.on(e,r)})}else if(!this.__events__[t]){this.__events__[t]=[r]}else{this.__events__[t].push(r)}},trigger:function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i",new L("quote-promise"),d.LITERAL]];var mu=yu.map(function(e){return e[0]});Object.freeze(mu);Object.defineProperty(d,"__builtins__",{writable:false,value:mu});yu.forEach(function(e){var t=b(e,3),r=t[0],n=t[1],i=t[2];d.append(r,n,i)});var s=function(){function p(e){var t=this;var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},n=r.whitespace,i=n===void 0?false:n;oe(this,p);f(this,"__input__",e.replace(/\r/g,""));var u={};["_i","_whitespace","_col","_newline","_line","_state","_next","_token","_prev_char"].forEach(function(r){Object.defineProperty(t,r,{configurable:false,enumerable:false,get:function e(){return u[r]},set:function e(t){u[r]=t}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}le(p,[{key:"get",value:function e(t){return this.__internal[t]}},{key:"set",value:function e(t,r){this.__internal[t]=r}},{key:"token",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(t){var r=this._line;if(this._whitespace&&this._token==="\n"){--r}return{token:this._token,col:this._col,offset:this._i,line:r}}return this._token}},{key:"peek",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(this._i>=this.__input__.length){return ss}if(this._token){return this.token(t)}var r=this.next_token();if(r){this._token=this.__input__.substring(this._i,this._next);return this.token(t)}return ss}},{key:"skip",value:function e(){if(this._next!==null){this._token=null;this._i=this._next}}},{key:"read_line",value:function e(){var t=this.__input__.length;if(this._i>=t){return ss}for(var r=this._i;r=r){return ss}if(t+this._i>=r){return this.read_rest()}var n=this._i+t;var i=this.__input__.substring(this._i,n);var u=i.match(/\n/g);if(u){this._line+=u.length}this._i=n;return i}},{key:"peek_char",value:function e(){if(this._i>=this.__input__.length){return ss}return h(this.__input__[this._i])}},{key:"read_char",value:function e(){var t=this.peek_char();this.skip_char();return t}},{key:"skip_char",value:function e(){if(this._i1&&arguments[1]!==undefined?arguments[1]:{},n=r.prev_char,i=r["char"],u=r.next_char;var a=b(t,4),o=a[0],s=a[1],c=a[2],f=a[3];if(t.length!==5){throw new Error("Lexer: Invalid rule of length ".concat(t.length))}if(!i.match(o)){return false}if(!gu(s,n)){return false}if(!gu(c,u)){return false}if(f!==this._state){return false}return true}},{key:"next_token",value:function e(){if(this._i>=this.__input__.length){return false}var t=true;e:for(var r=this._i,n=this.__input__.length;r2&&arguments[2]!==undefined?arguments[2]:null;var i=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;if(t.length===0){throw new Error("Lexer: invalid literal rule")}if(t.length===1){return[[t,n,i,null,null]]}var u=[];for(var a=0,o=t.length;a1&&arguments[1]!==undefined?arguments[1]:{},r=t.env,n=t.meta,i=n===void 0?false:n,u=t.formatter,a=u===void 0?Xi:u;oe(this,o);if(e instanceof D){e=e.toString()}f(this,"_formatter",a,{hidden:true});f(this,"__lexer__",new s(e));f(this,"__env__",r);f(this,"_meta",i,{hidden:true});f(this,"_refs",[],{hidden:true});f(this,"_state",{parentheses:0},{hidden:true})}le(o,[{key:"resolve",value:function e(t){return this.__env__&&this.__env__.get(t,{throwError:false})}},{key:"peek",value:function(){var e=ae(C.mark(function e(){var r;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=this.__lexer__.peek(true);if(!(r===ss)){t.next=4;break}return t.abrupt("return",ss);case 4:if(!this.is_comment(r.token)){t.next=7;break}this.skip();return t.abrupt("continue",0);case 7:if(!(r.token==="#;")){t.next=14;break}this.skip();if(!(this.__lexer__.peek()===ss)){t.next=11;break}throw new Error("Lexer: syntax error eof found after comment");case 11:t.next=13;return this._read_object();case 13:return t.abrupt("continue",0);case 14:return t.abrupt("break",17);case 17:r=this._formatter(r);if(!this._meta){t.next=20;break}return t.abrupt("return",r);case 20:return t.abrupt("return",r.token);case 21:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"reset",value:function e(){this._refs.length=0}},{key:"skip",value:function e(){this.__lexer__.skip()}},{key:"read",value:function(){var e=ae(C.mark(function e(){var r;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return this.peek();case 2:r=t.sent;this.skip();return t.abrupt("return",r);case 5:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"match_datum_label",value:function e(t){var r=t.match(/^#([0-9]+)=$/);return r&&r[1]}},{key:"match_datum_ref",value:function e(t){var r=t.match(/^#([0-9]+)#$/);return r&&r[1]}},{key:"is_open",value:function e(t){var r=["(","["].includes(t);if(r){this._state.parentheses++}return r}},{key:"is_close",value:function e(t){var r=[")","]"].includes(t);if(r){this._state.parentheses--}return r}},{key:"read_list",value:function(){var e=ae(C.mark(function e(){var r,n,i,u,a;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=U,n=r;case 1:t.next=4;return this.peek();case 4:u=t.sent;if(!(u===ss)){t.next=7;break}return t.abrupt("break",32);case 7:if(!this.is_close(u)){t.next=10;break}this.skip();return t.abrupt("break",32);case 10:if(!(u==="."&&r!==U)){t.next=18;break}this.skip();t.next=14;return this._read_object();case 14:n.cdr=t.sent;i=true;t.next=30;break;case 18:if(!i){t.next=22;break}throw new Error("Parser: syntax error more than one element after dot");case 22:t.t0=M;t.next=25;return this._read_object();case 25:t.t1=t.sent;t.t2=U;a=new t.t0(t.t1,t.t2);if(r===U){r=a}else{n.cdr=a}n=a;case 30:t.next=1;break;case 32:return t.abrupt("return",r);case 33:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"read_value",value:function(){var e=ae(C.mark(function e(){var r;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return this.read();case 2:r=t.sent;if(!(r===ss)){t.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return t.abrupt("return",Ji(r));case 6:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"is_comment",value:function e(t){return t.match(/^;/)||t.match(/^#\|/)&&t.match(/\|#$/)}},{key:"evaluate",value:function e(t){return P(t,{env:this.__env__,error:function e(t){throw t}})}},{key:"read_object",value:function(){var e=ae(C.mark(function e(){var r;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:this.reset();t.next=3;return this._read_object();case 3:r=t.sent;if(r instanceof wu){r=r.valueOf()}if(!this._refs.length){t.next=7;break}return t.abrupt("return",this._resolve_object(r));case 7:return t.abrupt("return",r);case 8:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"balanced",value:function e(){return this._state.parentheses===0}},{key:"ballancing_error",value:function e(t,r){var n=this._state.parentheses;var i;if(n<0){i=new Error("Parser: unexpected parenthesis");i.__code__=[r.toString()+")"]}else{i=new Error("Parser: expected parenthesis but eof found");var u=new RegExp("\\){".concat(n,"}$"));i.__code__=[t.toString().replace(u,"")]}throw i}},{key:"_resolve_object",value:function(){var t=ae(C.mark(function e(r){var n=this;var i;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!Array.isArray(r)){t.next=2;break}return t.abrupt("return",r.map(function(e){return n._resolve_object(e)}));case 2:if(!ra(r)){t.next=6;break}i={};Object.keys(r).forEach(function(e){i[e]=n._resolve_object(r[e])});return t.abrupt("return",i);case 6:if(!(r instanceof M)){t.next=8;break}return t.abrupt("return",this._resolve_pair(r));case 8:return t.abrupt("return",r);case 9:case"end":return t.stop()}},e,this)}));function e(e){return t.apply(this,arguments)}return e}()},{key:"_resolve_pair",value:function(){var t=ae(C.mark(function e(r){return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!(r instanceof M)){t.next=15;break}if(!(r.car instanceof wu)){t.next=7;break}t.next=4;return r.car.valueOf();case 4:r.car=t.sent;t.next=8;break;case 7:this._resolve_pair(r.car);case 8:if(!(r.cdr instanceof wu)){t.next=14;break}t.next=11;return r.cdr.valueOf();case 11:r.cdr=t.sent;t.next=15;break;case 14:this._resolve_pair(r.cdr);case 15:return t.abrupt("return",r);case 16:case"end":return t.stop()}},e,this)}));function e(e){return t.apply(this,arguments)}return e}()},{key:"_read_object",value:function(){var e=ae(C.mark(function e(){var r,n,i,u,a,o,s,c,f,l,h;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return this.peek();case 2:r=t.sent;if(!(r===ss)){t.next=5;break}return t.abrupt("return",r);case 5:if(!pu(r)){t.next=38;break}n=d.get(r);i=_u(r);this.skip();a=vu(r);if(!a){t.next=14;break}t.t0=undefined;t.next=17;break;case 14:t.next=16;return this._read_object();case 16:t.t0=t.sent;case 17:o=t.t0;if(i){t.next=25;break}s=this.__env__.get(n.symbol);if(!(typeof s==="function")){t.next=25;break}if(du(r)){c=[o]}else if(o===U){c=[]}else if(o instanceof M){c=o.to_array(false)}if(!(c||a)){t.next=24;break}return t.abrupt("return",$s(s,a?[]:c,{env:this.__env__,dynamic_env:this.__env__,use_dynamic:false}));case 24:throw new Error("Parse Error: Invalid parser extension "+"invocation ".concat(n.symbol));case 25:if(du(r)){u=new M(n.symbol,new M(o,U))}else{u=new M(n.symbol,o)}if(!i){t.next=28;break}return t.abrupt("return",u);case 28:if(!(s instanceof q)){t.next=37;break}t.next=31;return this.evaluate(u);case 31:f=t.sent;if(!(f instanceof M||f instanceof L)){t.next=34;break}return t.abrupt("return",M.fromArray([L("quote"),f]));case 34:return t.abrupt("return",f);case 37:throw new Error("Parse Error: invalid parser extension: "+n.symbol);case 38:l=this.match_datum_ref(r);if(!(l!==null)){t.next=44;break}this.skip();if(!this._refs[l]){t.next=43;break}return t.abrupt("return",new wu(l,this._refs[l]));case 43:throw new Error("Parse Error: invalid datum label #".concat(l,"#"));case 44:h=this.match_datum_label(r);if(!(h!==null)){t.next=51;break}this.skip();this._refs[h]=this._read_object();return t.abrupt("return",this._refs[h]);case 51:if(!this.is_close(r)){t.next=55;break}this.skip();t.next=61;break;case 55:if(!this.is_open(r)){t.next=60;break}this.skip();return t.abrupt("return",this.read_list());case 60:return t.abrupt("return",this.read_value());case 61:case"end":return t.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()}]);return o}();var wu=function(){function r(e,t){oe(this,r);this.name=e;this.data=t}le(r,[{key:"valueOf",value:function e(){return this.data}}]);return r}();function Du(e,t){return Eu.apply(this,arguments)}function Eu(){Eu=ge(C.mark(function e(r,n){var i,u,a;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!n){if(I){n=I.get("**interaction-environment**",{throwError:false})}else{n=Es}}i=new bu(r,{env:n});case 3:t.next=6;return ye(i.read_object());case 6:a=t.sent;if(!i.balanced()){i.ballancing_error(a,u)}if(!(a===ss)){t.next=10;break}return t.abrupt("break",15);case 10:u=a;t.next=13;return a;case 13:t.next=3;break;case 15:case"end":return t.stop()}},e)}));return Eu.apply(this,arguments)}function w(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(e){return e};var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;if(Ua(e)){var n=e.then(t);if(r===null){return n}else{return n["catch"](r)}}if(e instanceof Array){return Au(e,t,r)}if(ra(e)){return xu(e,t,r)}return t(e)}function Au(t,r,e){if(t.find(Ua)){return w(fu(t),function(e){if(Object.isFrozen(t)){Object.freeze(e)}return r(e)},e)}return r(t)}function xu(t,e,r){var i=Object.keys(t);var n=[],u=[];var a=i.length;while(a--){var o=i[a];var s=t[o];n[a]=s;if(Ua(s)){u.push(s)}}if(u.length){return w(fu(n),function(e){var n={};e.forEach(function(e,t){var r=i[t];n[r]=e});if(Object.isFrozen(t)){Object.freeze(n)}return n},r)}return e(t)}function f(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},i=n.hidden,u=i===void 0?false:i;Object.defineProperty(e,t,{value:r,configurable:true,enumerable:!u})}function Fu(e){return ku.apply(this,arguments)}function ku(){ku=ae(C.mark(function e(r){var n,i,u,a,o,s,c;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:n=[];i=false;u=false;t.prev=3;o=Xn(r);case 5:t.next=7;return o.next();case 7:if(!(i=!(s=t.sent).done)){t.next=13;break}c=s.value;n.push(c);case 10:i=false;t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15;t.t0=t["catch"](3);u=true;a=t.t0;case 19:t.prev=19;t.prev=20;if(!(i&&o["return"]!=null)){t.next=24;break}t.next=24;return o["return"]();case 24:t.prev=24;if(!u){t.next=27;break}throw a;case 27:return t.finish(24);case 28:return t.finish(19);case 29:return t.abrupt("return",n);case 30:case"end":return t.stop()}},e,null,[[3,15,19,29],[20,,24,28]])}));return ku.apply(this,arguments)}function Cu(e,t){if(t instanceof RegExp){return function(e){return String(e).match(t)}}else if(m(t)){return t}throw new Error("Invalid matcher")}function l(e,t,r,n){if(typeof e!=="string"){t=arguments[0];r=arguments[1];n=arguments[2];e=null}if(r){if(n){t.__doc__=r}else{t.__doc__=Ou(r)}}if(e){t.__name__=e}else if(t.name&&!yo(t)){t.__name__=t.name}return t}function Ou(e){return e.split("\n").map(function(e){return e.trim()}).join("\n")}function Su(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var r=e.length;if(t<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(t))}e:while(t--&&r>=0){var n=1;while(n>0){var i=e[--r];if(!i){break e}if(i==="("||i.token==="("){n--}else if(i===")"||i.token===")"){n++}}r--}return e.slice(r+1)}function Bu(e){if(!e||!e.length){return 0}var t=e.length;if(e[t-1].token==="\n"){return 0}while(--t){if(e[t].token==="\n"){var r=(e[t+1]||{}).token;if(r){return r.length}}}return 0}function ju(e,t){return f(e,t)===t.length;function f(r,n){function e(e,t){var r=Wn(e),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;var u=f(i,t);if(u!==-1){return u}}}catch(e){r.e(e)}finally{r.f()}return-1}function t(){return r[u]===Symbol["for"]("symbol")&&!Hi(n[o])}function i(){var e=r[u+1];var t=n[o+1];if(e!==undefined&&t!==undefined){return f([e],[t])}}var u=0;var a={};for(var o=0;o0){continue}}else if(t()){return-1}}else if(r[u]instanceof Array){var c=f(r[u],n.slice(o));if(c===-1||c+o>n.length){return-1}o+=c-1;u++;continue}else{return-1}u++}if(r.length!==u){return-1}return n.length}}function Iu(e){this.__code__=e.replace(/\r/g,"")}Iu.defaults={offset:0,indent:2,exceptions:{specials:[/^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|(?:call-with-(?:input-file|output-file|port))|lambda|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax|\*)?)$/],shift:{1:["&","#"]}}};Iu.match=ju;Iu.prototype._options=function e(t){var r=Iu.defaults;if(typeof t==="undefined"){return Object.assign({},r)}var n=t&&t.exceptions||{};var i=n.specials||[];var u=n.shift||{1:[]};return T(T(T({},r),t),{},{exceptions:{specials:[].concat(R(r.exceptions.specials),R(i)),shift:T(T({},u),{},{1:[].concat(R(r.exceptions.shift[1]),R(u[1]))})}})};Iu.prototype.indent=function e(t){var r=nu(this.__code__,true);return this._indent(r,t)};Iu.exception_shift=function(u,e){function t(e){if(!e.length){return false}if(e.indexOf(u)!==-1){return true}else{var t=e.filter(function(e){return e instanceof RegExp});if(!t.length){return false}var r=Wn(t),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;if(u.match(i)){return true}}}catch(e){r.e(e)}finally{r.f()}}return false}if(t(e.exceptions.specials)){return e.indent}var r=e.exceptions.shift;for(var n=0,i=Object.entries(r);n0){n.offset=0}if(u.toString()===t.toString()&&tc(u)){return n.offset+u[0].col}else if(u.length===1){return n.offset+u[0].col+1}else{var s=-1;if(a){var c=Iu.exception_shift(a.token,n);if(c!==-1){s=c}}if(s===-1){s=Iu.exception_shift(u[1].token,n)}if(s!==-1){return n.offset+u[0].col+s}else if(u[0].line3&&u[1].line===u[3].line){if(u[1].token==="("||u[1].token==="["){return n.offset+u[1].col}return n.offset+u[3].col}else if(u[0].line===u[1].line){return n.offset+n.indent+u[0].col}else{var f=u.slice(2);for(var l=0;l")};Pu.prototype.match=function(e){return e.match(this.pattern)};function Nu(){for(var e=arguments.length,t=new Array(e),r=0;r")};Iu.Pattern=Nu;Iu.Ahead=Pu;var Ru=/^[[(]$/;var Tu=/^[\])]$/;var Lu=/[^()[\]]/;var Uu=new Pu(/[^)\]]/);var Mu=Symbol["for"]("*");var qu=new Nu([Ru,Mu,Tu],[Lu],"+");var zu=new Nu([Ru,Mu,Tu],"+");var Vu=new Nu([Symbol["for"]("symbol")],"?");var Yu=new Nu([Symbol["for"]("symbol")],"*");var $u=[Ru,Yu,Tu];var Ju=new Nu([Ru,Symbol["for"]("symbol"),Mu,Tu],"+");var Ku=Gu("define","lambda","define-macro","syntax-rules");var Hu=/^(?!.*\b(?:[()[\]]|define(?:-macro)?|let(?:\*|rec|-env|-syntax|)?|lambda|syntax-rules)\b).*$/;var Wu=/^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/;function Gu(){for(var e=arguments.length,t=new Array(e),r=0;r0&&!o[e]){o[e]=Su(a,e)}});var s=Wn(i),c;try{for(s.s();!(c=s.n()).done;){var f=b(c.value,3),l=f[0],h=f[1],p=f[2];h=h.valueOf();var _=h>0?o[h]:a;var d=_.filter(function(e){return e.trim()&&!pu(e)});var v=r(_);var y=ju(l,d);var m=n.slice(u).find(function(e){return e.trim()&&!pu(e)});if(y&&(p instanceof Pu&&p.match(m)||!p)){var g=u-v;if(n[g]!=="\n"){if(!n[g].trim()){n[g]="\n"}else{n.splice(g,0,"\n");u++}}u+=v;continue e}}}catch(e){s.e(e)}finally{s.f()}}this.__code__=n.join("");return this};Iu.prototype._spaces=function(e){return" ".repeat(e)};Iu.prototype.format=function e(t){var r=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var n=nu(r,true);var i=this._options(t);var u=0;var a=0;for(var o=0;o0){n=Math.floor(t()*r);r--;var i=[e[n],e[r]];e[r]=i[0];e[n]=i[1]}return e}function Xu(){}Xu.prototype.toString=function(){return"()"};Xu.prototype.valueOf=function(){return undefined};Xu.prototype.serialize=function(){return 0};Xu.prototype.to_object=function(){return{}};Xu.prototype.append=function(e){return new M(e,U)};Xu.prototype.to_array=function(){return[]};var U=new Xu;function M(e,t){if(typeof this!=="undefined"&&this.constructor!==M||typeof this==="undefined"){return new M(e,t)}this.car=e;this.cdr=t}function ea(u,a){return function e(t){k(u,t,["pair","nil"]);if(t===U){return[]}var r=[];var n=t;while(true){if(n instanceof M){if(n.haveCycles("cdr")){break}var i=n.car;if(a&&i instanceof M){i=this.get(u).call(this,i)}r.push(i);n=n.cdr}else if(n===U){break}else{throw new Error("".concat(u,": can't convert improper list"))}}return r}}M.prototype.flatten=function(){return M.fromArray(Qu(this.to_array()))};M.prototype.length=function(){var e=0;var t=this;while(true){if(!t||t===U||!(t instanceof M)||t.haveCycles("cdr")){break}e++;t=t.cdr}return e};M.match=function(e,t){if(e instanceof L){return L.is(e,t)}else if(e instanceof M){return M.match(e.car,t)||M.match(e.cdr,t)}else if(Array.isArray(e)){return e.some(function(e){return M.match(e,t)})}else if(ra(e)){return Object.values(e).some(function(e){return M.match(e,t)})}return false};M.prototype.find=function(e){return M.match(this,e)};M.prototype.clone=function(){var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var n=new Map;function i(e){if(e instanceof M){if(n.has(e)){return n.get(e)}var t=new M;n.set(e,t);if(r){t.car=i(e.car)}else{t.car=e.car}t.cdr=i(e.cdr);t[oo]=e[oo];return t}return e}return i(this)};M.prototype.last_pair=function(){var e=this;while(true){if(e.cdr===U){return e}e=e.cdr}};M.prototype.to_array=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var t=[];if(this.car instanceof M){if(e){t.push(this.car.to_array())}else{t.push(this.car)}}else{t.push(this.car.valueOf())}if(this.cdr instanceof M){t=t.concat(this.cdr.to_array(e))}return t};M.fromArray=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(e instanceof M||r&&e instanceof Array&&e[uo]){return e}if(t===false){var n=U;for(var i=e.length;i--;){n=new M(e[i],n)}return n}if(e.length&&!(e instanceof Array)){e=R(e)}var u=U;var a=e.length;while(a--){var o=e[a];if(o instanceof Array){o=M.fromArray(o,t,r)}else if(typeof o==="string"){o=D(o)}else if(typeof o==="number"&&!Number.isNaN(o)){o=j(o)}u=new M(o,u)}return u};M.prototype.to_object=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var t=this;var r={};while(true){if(t instanceof M&&t.car instanceof M){var n=t.car;var i=n.car;if(i instanceof L){i=i.__name__}if(i instanceof D){i=i.valueOf()}var u=n.cdr;if(u instanceof M){u=u.to_object(e)}if(Ya(u)){if(!e){u=u.valueOf()}}r[i]=u;t=t.cdr}else{break}}return r};M.fromPairs=function(e){return e.reduce(function(e,t){return new M(new M(new L(t[0]),t[1]),e)},U)};M.fromObject=function(t){var e=Object.keys(t).map(function(e){return[e,t[e]]});return M.fromPairs(e)};M.prototype.reduce=function(e){var t=this;var r=U;while(true){if(t!==U){r=e(r,t.car);t=t.cdr}else{break}}return r};M.prototype.reverse=function(){if(this.haveCycles()){throw new Error("You can't reverse list that have cycles")}var e=this;var t=U;while(e!==U){var r=e.cdr;e.cdr=t;t=e;e=r}return t};M.prototype.transform=function(n){function i(e){if(e instanceof M){if(e.replace){delete e.replace;return e}var t=n(e.car);if(t instanceof M){t=i(t)}var r=n(e.cdr);if(r instanceof M){r=i(r)}return new M(t,r)}return e}return i(this)};M.prototype.map=function(e){if(typeof this.car!=="undefined"){return new M(e(this.car),this.cdr===U?U:this.cdr.map(e))}else{return U}};var ta=new Map;function ra(e){return e&&p(e)==="object"&&e.constructor===Object}var na=Object.getOwnPropertyNames(Array.prototype);var ia=[];na.forEach(function(e){ia.push(Array[e],Array.prototype[e])});function ua(e){e=Ga(e);return ia.includes(e)}function aa(e){return m(e)&&(yo(e)||e.__doc__)}function oa(r){var e=r.constructor||Object;var n=ra(r);var i=m(r[Symbol.asyncIterator])||m(r[Symbol.iterator]);var u;if(ta.has(e)){u=ta.get(e)}else{ta.forEach(function(e,t){t=Ga(t);if(r.constructor===t&&(t===Object&&n&&!i||t!==Object)){u=e}})}return u}var sa=new Map;[[true,"#t"],[false,"#f"],[null,"null"],[undefined,"#"]].forEach(function(e){var t=b(e,2),r=t[0],n=t[1];sa.set(r,n)});function ca(r){if(r&&p(r)==="object"){var n={};var e=Object.getOwnPropertySymbols(r);e.forEach(function(e){var t=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");n[t]=da(r[e])});var t=Object.getOwnPropertyNames(r);t.forEach(function(e){var t=r[e];if(t&&p(t)==="object"&&t.constructor===Object){n[e]=ca(t)}else{n[e]=da(t)}});return n}return r}function fa(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function la(e,t){return e.hasOwnProperty(t)&&m(e.toString)}function ha(e){if(bo(e)){return"#"}var t=e.prototype&&e.prototype.constructor;if(m(t)&&yo(t)){if(e[so]&&t.hasOwnProperty("__name__")){var r=t.__name__;if(D.isString(r)){r=r.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(p(n)==="symbol"){n=au(n)}if(typeof n==="string"){return"#")}}if(la(e,"toString")){return e.toString()}else if(e.name&&!yo(e)){return"#")}else{return"#"}}var pa=new Map;[[Error,function(e){return e.message}],[M,function(e,t){var r=t.quote,n=t.skip_cycles,i=t.pair_args;if(!n){e.markCycles()}return e.toString.apply(e,[r].concat(R(i)))}],[h,function(e,t){var r=t.quote;if(r){return e.toString()}return e.valueOf()}],[D,function(e,t){var r=t.quote;e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var t=b(e,2),r=t[0],n=t[1];pa.set(r,n)});var _a=[L,j,q,_s,Wo,Go,F,cu];function da(e,t,r){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(sa.has(e)){return sa.get(e)}if(va(e)){return"#"}if(e){var n=e.constructor;if(pa.has(n)){for(var i=arguments.length,u=new Array(i>3?i-3:0),a=3;a"}if(e===null){return"null"}if(p(e)==="object"){var f=e.constructor;if(!f){f=Object}var l;if(typeof f.__class__==="string"){l=f.__class__}else{var h=oa(e);if(h){if(m(h)){return h(e,t)}else{throw new Error("toString: Invalid repr value")}}l=f.name}if(m(e.toString)&&yo(e.toString)){return e.toString().valueOf()}if(z(e)==="instance"){if(yo(f)&&f.__name__){l=f.__name__.valueOf()}else if(!bo(f)){l="instance"}}if(qa(e,Symbol.iterator)){if(l){return"#")}return"#"}if(qa(e,Symbol.asyncIterator)){if(l){return"#")}return"#"}if(l!==""){return"#<"+l+">"}return"#"}if(typeof e!=="string"){return e.toString()}return e}function va(e){return e&&p(e)==="object"&&e.hasOwnProperty&&e.hasOwnProperty("constructor")&&typeof e.constructor==="function"&&e.constructor.prototype===e}M.prototype.markCycles=function(){ya(this);return this};M.prototype.haveCycles=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(!e){return this.haveCycles("car")||this.haveCycles("cdr")}return!!(this[oo]&&this[oo][e])};function ya(e){var t=[];var i=[];var u=[];function a(e){if(!t.includes(e)){t.push(e)}}function o(e,t,r,n){if(r instanceof M){if(n.includes(r)){if(!u.includes(r)){u.push(r)}if(!e[oo]){e[oo]={}}e[oo][t]=r;if(!i.includes(e)){i.push(e)}return true}}}var s=tu(function e(t,r){if(t instanceof M){delete t.ref;delete t[oo];a(t);r.push(t);var n=o(t,"car",t.car,r);var i=o(t,"cdr",t.cdr,r);if(!n){s(t.car,r.slice())}if(!i){return new eu(function(){return e(t.cdr,r.slice())})}}});function r(e,t){if(e[oo][t]instanceof M){var r=n.indexOf(e[oo][t]);e[oo][t]="#".concat(r,"#")}}s(e,[]);var n=t.filter(function(e){return u.includes(e)});n.forEach(function(e,t){e[ao]="#".concat(t,"=")});i.forEach(function(e){r(e,"car");r(e,"cdr")})}M.prototype.toString=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.nested,n=r===void 0?false:r;var i=[];if(this[ao]){i.push(this[ao]+"(")}else if(!n){i.push("(")}var u;if(this[oo]&&this[oo].car){u=this[oo].car}else{u=da(this.car,e,true)}if(u!==undefined){i.push(u)}if(this.cdr instanceof M){if(this[oo]&&this[oo].cdr){i.push(" . ");i.push(this[oo].cdr)}else{if(this.cdr[ao]){i.push(" . ")}else{i.push(" ")}var a=this.cdr.toString(e,{nested:true});i.push(a)}}else if(this.cdr!==U){i=i.concat([" . ",da(this.cdr,e,true)])}if(!n||this[ao]){i.push(")")}return i.join("")};M.prototype.set=function(e,t){this[e]=t;if(t instanceof M){this.markCycles()}};M.prototype.append=function(e){if(e instanceof Array){return this.append(M.fromArray(e))}var t=this;if(t.car===undefined){if(e instanceof M){this.car=e.car;this.cdr=e.cdr}else{this.car=e}}else if(e!==U){while(true){if(t instanceof M&&t.cdr!==U){t=t.cdr}else{break}}t.cdr=e}return this};M.prototype.serialize=function(){return[this.car,this.cdr]};M.prototype[Symbol.iterator]=function(){var r=this;return{next:function e(){var t=r;r=t.cdr;if(t===U){return{value:undefined,done:true}}else{return{value:t.car,done:false}}}}};function ma(e){return e<0?-e:e}function ga(e,t){var r=re(t),n=r[0],i=r.slice(1);while(i.length>0){var u=i,a=b(u,1),o=a[0];if(!e(n,o)){return false}var s=i;var c=re(s);n=c[0];i=c.slice(1)}return true}function ba(e,t){if(m(e)){return m(t)&&Ga(e)===Ga(t)}else if(e instanceof j){if(!(t instanceof j)){return false}var r;if(e.__type__===t.__type__){if(e.__type__==="complex"){r=e.__im__.__type__===t.__im__.__type__&&e.__re__.__type__===t.__re__.__type__}else{r=true}if(r&&e.cmp(t)===0){if(e.valueOf()===0){return Object.is(e.valueOf(),t.valueOf())}return true}}return false}else if(typeof e==="number"){if(typeof t!=="number"){return false}if(Number.isNaN(e)){return Number.isNaN(t)}if(e===Number.NEGATIVE_INFINITY){return t===Number.NEGATIVE_INFINITY}if(e===Number.POSITIVE_INFINITY){return t===Number.POSITIVE_INFINITY}return ba(j(e),j(t))}else if(e instanceof h){if(!(t instanceof h)){return false}return e.__char__===t.__char__}else{return e===t}}function wa(e,t){if(z(e)!==z(t)){return false}if(!Da(e)){return false}if(e instanceof RegExp){return e.source===t.source}if(e instanceof D){return e.valueOf()===t.valueOf()}return ba(e,t)}function Da(e){return e instanceof L||D.isString(e)||e===U||e===null||e instanceof h||e instanceof j||e===true||e===false}var Ea=function(){if(Math.trunc){return Math.trunc}else{return function(e){if(e===0){return 0}else if(e<0){return Math.ceil(e)}else{return Math.floor(e)}}}}();function q(e,t,r,n){if(typeof this!=="undefined"&&this.constructor!==q||typeof this==="undefined"){return new q(e,t)}k("Macro",e,"string",1);k("Macro",t,"function",2);if(r){if(n){this.__doc__=r}else{this.__doc__=Ou(r)}}this.__name__=e;this.__fn__=t}q.defmacro=function(e,t,r,n){var i=new q(e,t,r,n);i.__defmacro__=true;return i};q.prototype.invoke=function(e,t,r){var n=t.env,i=_e(t,Mn);var u=T(T({},i),{},{macro_expand:r});var a=this.__fn__.call(n,e,u,this.__name__);return a};q.prototype.toString=function(){return"#")};var Aa="define-macro";var xa=-1e4;function Fa(c){return function(){var r=ae(C.mark(function e(r,m){var u,g,n,i,a,b,w,D,E,A,x,F,o,k,s;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:s=function e(){s=ae(C.mark(function e(r,n,i){var u,a,o,s,c,f,l,h,p,_,d,v,y;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!(r instanceof M&&r.car instanceof L)){t.next=50;break}if(!r[uo]){t.next=3;break}return t.abrupt("return",r);case 3:u=r.car.valueOf();a=i.get(r.car,{throwError:false});o=b(r.car);s=o||w(a,r)||D(a);if(!(s&&r.cdr.car instanceof M)){t.next=28;break}if(!o){t.next=15;break}g=A(r.cdr.car);t.next=12;return F(r.cdr.car,n);case 12:c=t.sent;t.next=17;break;case 15:g=E(r.cdr.car);c=r.cdr.car;case 17:t.t0=M;t.t1=r.car;t.t2=M;t.t3=c;t.next=23;return k(r.cdr.cdr,n,i);case 23:t.t4=t.sent;t.t5=new t.t2(t.t3,t.t4);return t.abrupt("return",new t.t0(t.t1,t.t5));case 28:if(!x(u,a)){t.next=50;break}f=a instanceof ka?r:r.cdr;t.next=32;return a.invoke(f,T(T({},m),{},{env:i}),true);case 32:l=t.sent;if(!(a instanceof ka)){t.next=41;break}h=l,p=h.expr,_=h.scope;if(!(p instanceof M)){t.next=40;break}if(!(n!==-1&&n<=1||n")}return"#"};ka.className="syntax";var Ca=function(e){G(t,e);function t(){oe(this,t);return Kn(this,t,arguments)}return le(t)}(ka);ka.Parameter=Ca;function Oa(e,t,w,D){var r=arguments.length>4&&arguments[4]!==undefined?arguments[4]:{};var E={"...":{symbols:{},lists:[]},symbols:{}};var A=r.expansion,x=r.define;function F(e){if(fi()){console.log(e)}}F(w);function k(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;F({code:t&&da(t,true),pattern:e&&da(e,true)});if(Da(e)&&!(e instanceof L)){return wa(e,t)}if(e instanceof L&&w.includes(e.literal())){var i=A.ref(t);if(L.is(t,e)){if(typeof i==="undefined"){return true}return i===x||i===I}return false}if(e instanceof M&&e.car instanceof M&&e.car.cdr instanceof M&&L.is(e.car.cdr.car,D)){F(">> 0");if(t===U){F({pattern:e.toString()});if(e.car.car instanceof L){if(e.car.cdr instanceof M&&L.is(e.car.cdr.car,D)){var u=e.car.car.valueOf();var a=e.last_pair();if(L.is(a.car,D)){E["..."].symbols[u]=null;return true}else{return false}}var o=e.car.car.valueOf();if(E["..."].symbols[o]){throw new Error("syntax: named ellipsis can only "+"appear onces")}E["..."].symbols[o]=t}}}if(e instanceof M&&e.cdr instanceof M&&L.is(e.cdr.car,D)){if(e.cdr.cdr!==U){if(e.cdr.cdr instanceof M){var s=e.cdr.cdr.length();if(!Ra(t)){return false}var c=t.length();var f=t;while(c-1>s){f=f.cdr;c--}var l=f.cdr;f.cdr=U;if(!k(e.cdr.cdr,l,r,n)){return false}}}if(e.car instanceof L){var h=e.car.__name__;if(E["..."].symbols[h]&&!r.includes(h)&&!n){throw new Error("syntax: named ellipsis can only appear onces")}F(">> 1");if(t===U){F(">> 2");if(n){F("NIL");E["..."].symbols[h]=U}else{F("NULL");E["..."].symbols[h]=null}}else if(t instanceof M&&(t.car instanceof M||t.car===U)){F(">> 3 "+n);if(n){if(E["..."].symbols[h]){var p=E["..."].symbols[h];if(p===U){p=new M(U,new M(t,U))}else{p=p.append(new M(t,U))}E["..."].symbols[h]=p}else{E["..."].symbols[h]=new M(t,U)}}else{F(">> 4");E["..."].symbols[h]=new M(t,U)}}else{F(">> 6");if(t instanceof M){F(">> 7 "+n);r.push(h);if(!E["..."].symbols[h]){E["..."].symbols[h]=new M(t,U)}else{var _=E["..."].symbols[h];E["..."].symbols[h]=_.append(new M(t,U))}F({IIIIII:E["..."].symbols[h].toString()})}else if(e.car instanceof L&&e.cdr instanceof M&&L.is(e.cdr.car,D)){F(">> 8");E["..."].symbols[h]=null;return k(e.cdr.cdr,t)}else{F(">> 9");return false}}return true}else if(e.car instanceof M){var d=R(r);if(t===U){F(">> 10");E["..."].lists.push(U);return true}F(">> 11");var v=t;while(v instanceof M){if(!k(e.car,v.car,d,true)){return false}v=v.cdr}return true}return false}if(e instanceof L){if(L.is(e,D)){throw new Error("syntax: invalid usage of ellipsis")}F(">> 12");var y=e.__name__;if(w.includes(y)){return true}if(n){E["..."].symbols[y]=E["..."].symbols[y]||[];E["..."].symbols[y].push(t)}E.symbols[y]=t;if(!E.symbols[y]);return true}if(e instanceof M&&t instanceof M){F(">> 13");F({a:12,code:t&&t.toString(),pattern:e.toString()});if(t.cdr===U){var m=e.car instanceof L&&e.cdr instanceof L;if(m){if(!k(e.car,t.car,r,n)){return false}F(">> 14");var g=e.cdr.valueOf();if(!(g in E.symbols)){E.symbols[g]=U}g=e.car.valueOf();if(!(g in E.symbols)){E.symbols[g]=t.car}return true}}F({pattern:e.toString(),code:t.toString()});if(e.cdr instanceof M&&e.cdr.cdr instanceof M&&e.cdr.car instanceof L&&L.is(e.cdr.cdr.car,D)&&e.cdr.cdr.cdr instanceof M&&!L.is(e.cdr.cdr.cdr.car,D)&&k(e.car,t.car,r,n)&&k(e.cdr.cdr.cdr,t.cdr,r,n)){var b=e.cdr.car.__name__;F({pattern:e.car.toString(),code:t.car.toString(),name:b});if(w.includes(b)){return true}E["..."].symbols[b]=null;return true}F("recur");if(k(e.car,t.car,r,n)&&k(e.cdr,t.cdr,r,n)){return true}}else if(e===U&&(t===U||t===undefined)){return true}else if(e.car instanceof M&&L.is(e.car.car,D)){throw new Error("syntax: invalid usage of ellipsis")}else{return false}}if(k(e,t)){return E}}function Sa(e,i){function u(t){if(t instanceof M){if(!i.length){return t}var e=u(t.car);var r=u(t.cdr);return new M(e,r)}else if(t instanceof L){var n=i.find(function(e){return e.gensym===t});if(n){return L(n.name)}return t}else{return t}}return u(e)}function Ba(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var k=e.bindings,t=e.expr,C=e.scope,a=e.symbols,c=e.names,O=e.ellipsis;var f={};function o(e){if(e instanceof L){return true}return["string","symbol"].includes(p(e))}function S(e){if(!o(e)){var t=z(e);throw new Error("syntax: internal error, need symbol got ".concat(t))}var r=e.valueOf();if(r===O){throw new Error("syntax: internal error, ellipis not transformed")}var n=p(r);if(["string","symbol"].includes(n)){if(r in k.symbols){return k.symbols[r]}else if(n==="string"&&r.match(/\./)){var i=r.split(".");var u=i[0];if(u in k.symbols){return M.fromArray([L("."),k.symbols[u]].concat(i.slice(1).map(function(e){return D(e)})))}}}if(a.includes(r)){return L(r)}return s(r)}function B(e){if(fi()){console.log(e)}}function s(e){if(!f[e]){var t=C.ref(e);var r=su(e);if(t){var n=C.get(e);C.set(r,n)}else{var i=C.get(e,{throwError:false});if(typeof i!=="undefined"){C.set(r,i)}}c.push({name:e,gensym:r});f[e]=r;if(typeof e==="string"&&e.match(/\./)){var u=e.split(".").filter(Boolean),a=re(u),o=a[0],s=a.slice(1);if(f[o]){_o(r,"__object__",[f[o]].concat(R(s)))}}}return f[e]}function j(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:function(){};var i=r.nested;B(" ==> "+e.toString(true));B(t);if(e instanceof L){var u=e.valueOf();B("[t 1");if(t[u]){if(t[u]instanceof M){var a=t[u],o=a.car,s=a.cdr;if(i){var c=o.car,f=o.cdr;if(f!==U){n(u,new M(f,U))}return c}if(s!==U){n(u,s)}return o}else if(t[u]instanceof Array){n(u,t[u].slice(1));return t[u][0]}}return S(u)}if(e instanceof M){if(e.car instanceof L&&e.cdr instanceof M&&L.is(e.cdr.car,O)){B("[t 2");var l=e.car.valueOf();var h=t[l];B({expr:e.toString(true),name:l,bindings:t,item:h});if(h===null){return}else if(h){B({b:t[l].toString()});if(h instanceof M){B("[t 2 Pair "+i);B({______:h.toString()});var p=h.car,_=h.cdr;if(i){if(_!==U){B("|| next 1");n(l,_)}B({car:p.toString()});return p}else{if(p.cdr!==U){B("|| next 2");n(l,new M(p.cdr,_))}B({car:p.car.toString()});return p.car}}else if(h instanceof Array){B("[t 2 Array "+i);if(i){n(l,h.slice(1));return M.fromArray(h)}else{var d=h.slice(1);if(d.length){n(l,d)}return h[0]}}else{return h}}}B("[t 3 recur "+e.toString());var v=j(e.car,t,r,n);var y=j(e.cdr,t,r,n);return new M(v,y)}return e}function I(t,r){var e=Object.values(t);var n=Object.getOwnPropertySymbols(t);if(n.length){e.push.apply(e,R(n.map(function(e){return t[e]})))}return e.length&&e.every(function(e){if(e===null){return!r}return e instanceof M||e===U||e instanceof Array&&e.length})}function P(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function N(i){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},t=e.disabled;B("traverse>> "+da(i));if(i instanceof M){if(!t&&i.car instanceof M&&L.is(i.car.car,O)){return N(i.car.cdr,{disabled:true})}if(i.cdr instanceof M&&L.is(i.cdr.car,O)&&!t){B(">> 1");var r=k["..."].symbols;var n=Object.values(r);if(n.length&&n.every(function(e){return e===null})){return N(i.cdr.cdr,{disabled:t})}var u=P(r);var a=i.car instanceof L&&L.is(i.cdr.cdr.car,O);if(i.car instanceof M||a){if(k["..."].lists[0]===U){return U}var o=i.car;if(a){o=new M(i.car,new M(i.cdr.car,U))}B(">> 2");var s;if(u.length){B(">> 2 (a)");var c=T({},r);s=U;var f=function e(){if(!I(c)){return 1}var n={};var t=function e(t,r){n[t]=r};var r=j(o,c,{nested:true},t);if(r!==undefined){if(a){if(s===U){s=r}else{s=s.append(r)}}else{s=new M(r,s)}}c=n};while(true){if(f())break}if(s!==U&&!a){s=s.reverse()}if(i.cdr.cdr!==U&&!L.is(i.cdr.cdr.car,O)){var l=N(i.cdr.cdr,{disabled:t});return s.append(l)}return s}else{B(">> 3");var h=j(i.car,r,{nested:true});if(h){return new M(h,U)}return U}}else if(i.car instanceof L){B(">> 4");if(L.is(i.cdr.cdr.car,O)){B(">> 4 (a)")}else{B(">> 4 (b)")}var p=i.car.__name__;var _=he({},p,r[p]);var d=r[p]===null;var v=U;var y=function e(){if(!I(_,true)){B({bind:_});return 1}var n={};var t=function e(t,r){n[t]=r};var r=j(i,_,{nested:false},t);B({value:r.toString()});if(typeof r!=="undefined"){v=new M(r,v)}_=n};while(true){if(y())break}if(v!==U){v=v.reverse()}if(i.cdr instanceof M){if(i.cdr.cdr instanceof M||i.cdr.cdr instanceof L){var m=N(i.cdr.cdr,{disabled:t});if(d){return m}B("<<<< 1");v.append(m)}}B("<<<< 2");return v}}var g=N(i.car,{disabled:t});var b;var w;if(i.car instanceof L){var D=C.get(i.car,{throwError:false});w=D instanceof q&&D.__name__==="syntax-rules"}if(w){if(i.cdr.car instanceof L){b=new M(N(i.cdr.car,{disabled:t}),new M(i.cdr.cdr.car,N(i.cdr.cdr.cdr,{disabled:t})))}else{b=new M(i.cdr.car,N(i.cdr.cdr,{disabled:t}))}B("REST >>>> "+b.toString())}else{b=N(i.cdr,{disabled:t})}B({a:true,car:da(i.car),cdr:da(i.cdr),head:da(g),rest:da(b)});return new M(g,b)}if(i instanceof L){if(t&&L.is(i,O)){return i}var E=Object.keys(k["..."].symbols);var A=i.literal();if(E.includes(A)){var x="missing ellipsis symbol next to name `".concat(A,"'");throw new Error("syntax-rules: ".concat(x))}var F=S(i);if(typeof F!=="undefined"){return F}}return i}return N(t,{})}function ja(e){return Ma(e)||e===U||e===null}function m(e){return typeof e==="function"&&typeof e.bind==="function"}function Ia(e){return e instanceof Qs}function Pa(e){return e instanceof Ws}function Na(e){return e instanceof Hs}function Ra(e){return e instanceof M}function Ta(e){return e instanceof F}function La(e){return m(e)||Ia(e)||Na(e)}function Ua(e){if(e instanceof cu){return false}if(e instanceof Promise){return true}return!!e&&m(e.then)}function Ma(e){return typeof e==="undefined"}function qa(e,t){if($a(e,t)||$a(e.__proto__,t)){return m(e[t])}}function za(e){if(!e){return false}if(p(e)!=="object"){return false}if(e.__instance__){e.__instance__=false;return e.__instance__}return false}function Va(e){var t=p(e);return["string","function"].includes(t)||p(e)==="symbol"||e instanceof cu||e instanceof L||e instanceof j||e instanceof D||e instanceof RegExp}function Ya(e){return e instanceof j||e instanceof D||e instanceof h}function $a(e,t){if(e===null){return false}return p(e)==="object"&&t in Object.getOwnPropertySymbols(e)}function Ja(e){switch(p(e)){case"string":return D(e);case"bigint":return j(e);case"number":if(Number.isNaN(e)){return ws}else{return j(e)}}return e}function Ka(r,n){var e=Object.getOwnPropertyNames(r);var t=Object.getOwnPropertySymbols(r);var i={};e.concat(t).forEach(function(e){var t=n(r[e]);i[e]=t});return i}function Ha(t){var e=[D,j].some(function(e){return t instanceof e});if(e){return t.valueOf()}if(t instanceof Array){return t.map(Ha)}if(t instanceof cu){delete t.then}if(ra(t)){return Ka(t,Ha)}return t}function Wa(e,t){if(e instanceof M){e.markCycles();return ds(e)}if(m(e)){if(t){return Qa(e,t)}}return Ja(e)}function Ga(e){if(Xa(e)){return e[io]}return e}function Qa(e,t){if(e[Symbol["for"]("__bound__")]){return e}var r=e.bind(t);var n=Object.getOwnPropertyNames(e);var i=Wn(n),u;try{for(i.s();!(u=i.n()).done;){var a=u.value;if(po(a)){try{r[a]=e[a]}catch(e){}}}}catch(e){i.e(e)}finally{i.f()}_o(r,"__fn__",e);_o(r,"__context__",t);_o(r,"__bound__",true);if(bo(e)){_o(r,"__native__",true)}if(ra(t)&&yo(e)){_o(r,"__method__",true)}r.valueOf=function(){return e};return r}function Za(e){return Xa(e)&&e[Symbol["for"]("__context__")]===Object}function Xa(e){return!!(m(e)&&e[io])}function eo(e){if(m(e)){var t=e[no];if(t&&(t===Pc||t.constructor&&t.constructor.__class__)){return true}}return false}function to(e){return e instanceof Wo||e instanceof Go}function ro(e){if(m(e)){if(to(e[no])){return true}}return false}var no=Symbol["for"]("__context__");var io=Symbol["for"]("__fn__");var uo=Symbol["for"]("__data__");var ao=Symbol["for"]("__ref__");var oo=Symbol["for"]("__cycles__");var so=Symbol["for"]("__class__");var co=Symbol["for"]("__method__");var fo=Symbol["for"]("__prototype__");var lo=Symbol["for"]("__lambda__");var ho=["name","length","caller","callee","arguments","prototype"];function po(e){return!ho.includes(e)}function _o(e,t,r){Object.defineProperty(e,Symbol["for"](t),{get:function e(){return r},set:function e(){},configurable:false,enumerable:false})}function vo(t,r){try{Object.defineProperty(t,"length",{get:function e(){return r}});return t}catch(e){var n=new Array(r).fill(0).map(function(e,t){return"a"+t}).join(",");var i=new Function("f","return function(".concat(n,") {\n return f.apply(this, arguments);\n };"));return i(t)}}function yo(e){return e&&e[lo]}function mo(e){return e&&e[co]}function go(e){return yo(e)&&!e[fo]&&!mo(e)&&!ro(e)}function bo(e){var t=Symbol["for"]("__native__");return m(e)&&e.toString().match(/\{\s*\[native code\]\s*\}/)&&(e.name.match(/^bound /)&&e[t]===true||!e.name.match(/^bound /)&&!e[t])}function wo(e){var b;switch(e){case Symbol["for"]("letrec"):b="letrec";break;case Symbol["for"]("let"):b="let";break;case Symbol["for"]("let*"):b="let*";break;default:throw new Error("Invalid let_macro value")}return q.defmacro(b,function(t,e){var f=e.dynamic_env;var l=e.error,r=e.macro_expand,h=e.use_dynamic;var p;if(t.car instanceof L){if(!(t.cdr.car instanceof M||t.cdr.car===U)){throw new Error("let require list of pairs")}var n;if(t.cdr.car===U){p=U;n=U}else{n=t.cdr.car.map(function(e){return e.car});p=t.cdr.car.map(function(e){return e.cdr.car})}return M.fromArray([L("letrec"),[[t.car,M(L("lambda"),M(n,t.cdr.cdr))]],M(t.car,p)])}else if(r){return}var _=this;p=I.get("list->array")(t.car);var d=_.inherit(b);var v,y;if(b==="let*"){y=d}else if(b==="let"){v=[]}var m=0;function g(){var e=new M(new L("begin"),t.cdr);return P(e,{env:d,dynamic_env:d,use_dynamic:h,error:l})}return function t(){var r=p[m++];f=b==="let*"?d:_;if(!r){if(v&&v.length){var e=v.map(function(e){return e.value});var n=e.filter(Ua);if(n.length){return fu(e).then(function(e){for(var t=0,r=e.length;t1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=this;var u=this;var a=[];var o=e;while(o instanceof M){a.push(P(o.car,{env:i,dynamic_env:u,use_dynamic:r,error:n}));o=o.cdr}var s=a.filter(Ua).length;if(s){return fu(a).then(c.bind(this))}else{return c.call(this,a)}})}function Eo(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2?n-2:0),u=2;u1&&arguments[1]!==undefined?arguments[1]:null;return function(){for(var e=arguments.length,t=new Array(e),r=0;r1?e-1:0),r=1;r=a){return u.apply(this,n)}else{return i}}return i.apply(this,arguments)}}function jo(n,i){k("limit",i,"function",2);return function(){for(var e=arguments.length,t=new Array(e),r=0;r1){e=e.toLowerCase();if(h.__names__[e]){t=e;e=h.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{t=h.__rev_names__[e]}Object.defineProperty(this,"__char__",{value:e,enumerable:true});if(t){Object.defineProperty(this,"__name__",{value:t,enumerable:true})}}h.__names__=wi;h.__rev_names__={};Object.keys(h.__names__).forEach(function(e){var t=h.__names__[e];h.__rev_names__[t]=e});h.prototype.toUpperCase=function(){return h(this.__char__.toUpperCase())};h.prototype.toLowerCase=function(){return h(this.__char__.toLowerCase())};h.prototype.toString=function(){return"#\\"+(this.__name__||this.__char__)};h.prototype.valueOf=h.prototype.serialize=function(){return this.__char__};function D(e){if(typeof this!=="undefined"&&!(this instanceof D)||typeof this==="undefined"){return new D(e)}if(e instanceof Array){this.__string__=e.map(function(e,t){k("LString",e,"character",t+1);return e.toString()}).join("")}else{this.__string__=e.valueOf()}}{var Io=["length","constructor"];var Po=Object.getOwnPropertyNames(String.prototype).filter(function(e){return!Io.includes(e)});var No=function e(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r0){r.push(this.__string__.substring(0,e))}r.push(t);if(e1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof j){return e}if(typeof this!=="undefined"&&!(this instanceof j)||typeof this==="undefined"){return new j(e,t)}if(typeof e==="undefined"){throw new Error("Invalid LNumber constructor call")}var r=j.getType(e);if(j.types[r]){return j.types[r](e,t)}var n=e instanceof Array&&D.isString(e[0])&&j.isNumber(e[1]);if(e instanceof j){return j(e.value)}if(!j.isNumber(e)&&!n){throw new Error("You can't create LNumber from ".concat(z(e)))}if(e===null){e=0}var i;if(n){var u=e,a=b(u,2),o=a[0],s=a[1];if(o instanceof D){o=o.valueOf()}if(s instanceof j){s=s.valueOf()}var c=o.match(/^([+-])/);var f=false;if(c){o=o.replace(/^[+-]/,"");if(c[1]==="-"){f=true}}}if(Number.isNaN(e)){return E(e)}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(n){var l;switch(s){case 8:l="0o";break;case 16:l="0x";break;case 2:l="0b";break;case 10:l="";break}if(typeof l==="undefined"){var h=BigInt(s);i=R(o).map(function(e,t){return BigInt(parseInt(e,s))*Vo(h,BigInt(t))}).reduce(function(e,t){return e+t})}else{i=BigInt(l+o)}}else{i=BigInt(e)}if(f){i*=BigInt(-1)}}else{i=e}return x(i,true)}else if(typeof oi!=="undefined"&&!(e instanceof oi)){if(e instanceof Array){return x(K(oi,R(e)))}return x(new oi(e))}else if(n){this.constant(parseInt(o,s),"integer")}else{this.constant(e,"integer")}}j.prototype.constant=function(e,t){Object.defineProperty(this,"__value__",{value:e,enumerable:true});Object.defineProperty(this,"__type__",{value:t,enumerable:true})};j.types={float:function e(t){return new E(t)},complex:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!j.isComplex(t)){t={im:0,re:t}}return new g(t,r)},rational:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!j.isRational(t)){t={num:t,denom:1}}return new A(t,r)}};j.prototype.serialize=function(){return this.__value__};j.prototype.isNaN=function(){return Number.isNaN(this.__value__)};j.prototype.gcd=function(e){var t=this.abs();e=e.abs();if(e.cmp(t)===1){var r=t;t=e;e=r}while(true){t=t.rem(e);if(t.cmp(0)===0){return e}e=e.rem(t);if(e.cmp(0)===0){return t}}};j.isFloat=function e(t){return t instanceof E||Number(t)===t&&t%1!==0};j.isNumber=function(e){return e instanceof j||j.isNative(e)||j.isBN(e)};j.isComplex=function(e){if(!e){return false}var t=e instanceof g||(j.isNumber(e.im)||Number.isNaN(e.im))&&(j.isNumber(e.re)||Number.isNaN(e.re));return t};j.isRational=function(e){if(!e){return false}return e instanceof A||j.isNumber(e.num)&&j.isNumber(e.denom)};j.isInteger=function(e){if(!(j.isNative(e)||e instanceof j)){return false}if(j.isFloat(e)){return false}if(j.isRational(e)){return false}if(j.isComplex(e)){return false}return true};j.isNative=function(e){return typeof e==="bigint"||typeof e==="number"};j.isBigInteger=function(e){return e instanceof x||typeof e==="bigint"||j.isBN(e)};j.isBN=function(e){return typeof oi!=="undefined"&&e instanceof oi};j.getArgsType=function(e,t){if(e instanceof E||t instanceof E){return E}if(e instanceof x||t instanceof x){return x}return j};j.prototype.toString=function(e){if(Number.isNaN(this.__value__)){return"+nan.0"}if(e>=2&&e<36){return this.__value__.toString(e)}return this.__value__.toString()};j.prototype.asType=function(e){var t=j.getType(this);return j.types[t]?j.types[t](e):j(e)};j.prototype.isBigNumber=function(){return typeof this.__value__==="bigint"||typeof oi!=="undefined"&&!(this.value instanceof oi)};["floor","ceil","round"].forEach(function(e){j.prototype[e]=function(){if(this["float"]||j.isFloat(this.__value__)){return j(Math[e](this.__value__))}else{return j(Math[e](this.valueOf()))}}});j.prototype.valueOf=function(){if(j.isNative(this.__value__)){return Number(this.__value__)}else if(j.isBN(this.__value__)){return this.__value__.toNumber()}};var Uo=function(){var e=function e(t,r){return[t,r]};return{bigint:{bigint:e,float:function e(t,r){return[E(t.valueOf()),r]},rational:function e(t,r){return[{num:t,denom:1},r]},complex:function e(t,r){return[{im:0,re:t},r]}},integer:{integer:e,float:function e(t,r){return[E(t.valueOf()),r]},rational:function e(t,r){return[{num:t,denom:1},r]},complex:function e(t,r){return[{im:0,re:t},r]}},float:{bigint:function e(t,r){return[t,r&&E(r.valueOf())]},integer:function e(t,r){return[t,r&&E(r.valueOf())]},float:e,rational:function e(t,r){return[t,r&&E(r.valueOf())]},complex:function e(t,r){return[{re:t,im:E(0)},r]}},complex:{bigint:t("bigint"),integer:t("integer"),float:t("float"),rational:t("rational"),complex:function e(t,r){var n=j.coerce(t.__re__,r.__re__),i=b(n,2),u=i[0],a=i[1];var o=j.coerce(t.__im__,r.__im__),s=b(o,2),c=s[0],f=s[1];return[{im:c,re:u},{im:f,re:a}]}},rational:{bigint:function e(t,r){return[t,r&&{num:r,denom:1}]},integer:function e(t,r){return[t,r&&{num:r,denom:1}]},float:function e(t,r){return[E(t.valueOf()),r]},rational:e,complex:function e(t,r){return[{im:Mo(t.__type__,r.__im__.__type__,0)[0],re:Mo(t.__type__,r.__re__.__type__,t)[0]},{im:Mo(t.__type__,r.__im__.__type__,r.__im__)[0],re:Mo(t.__type__,r.__re__.__type__,r.__re__)[0]}]}}};function t(r){return function(e,t){return[{im:Mo(r,e.__im__.__type__,0,e.__im__)[1],re:Mo(r,e.__re__.__type__,0,e.__re__)[1]},{im:Mo(r,e.__im__.__type__,0,0)[1],re:Mo(r,t.__type__,0,t)[1]}]}}}();function Mo(e,t,r,n){return Uo[e][t](r,n)}j.coerce=function(e,t){var r=j.getType(e);var n=j.getType(t);if(!Uo[r]){throw new Error("LNumber::coerce unknown lhs type ".concat(r))}else if(!Uo[r][n]){throw new Error("LNumber::coerce unknown rhs type ".concat(n))}var i=Uo[r][n](e,t);return i.map(function(e){return j(e,true)})};j.prototype.coerce=function(e){if(!(typeof e==="number"||e instanceof j)){throw new Error("LNumber: you can't coerce ".concat(z(e)))}if(typeof e==="number"){e=j(e)}return j.coerce(this,e)};j.getType=function(e){if(e instanceof j){return e.__type__}if(j.isFloat(e)){return"float"}if(j.isComplex(e)){return"complex"}if(j.isRational(e)){return"rational"}if(typeof e==="number"){return"integer"}if(typeof BigInt!=="undefined"&&typeof e!=="bigint"||typeof oi!=="undefined"&&!(e instanceof oi)){return"bigint"}};j.prototype.isFloat=function(){return!!(j.isFloat(this.__value__)||this["float"])};var qo={add:"+",sub:"-",mul:"*",div:"/",rem:"%",or:"|",and:"&",neg:"~",shl:">>",shr:"<<"};var zo={};Object.keys(qo).forEach(function(t){zo[qo[t]]=t;j.prototype[t]=function(e){return this.op(qo[t],e)}});j._ops={"*":function e(t,r){return t*r},"+":function e(t,r){return t+r},"-":function e(t,r){if(typeof r==="undefined"){return-t}return t-r},"/":function e(t,r){return t/r},"%":function e(t,r){return t%r},"|":function e(t,r){return t|r},"&":function e(t,r){return t&r},"~":function e(t){return~t},">>":function e(t,r){return t>>r},"<<":function e(t,r){return t<1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof g)||typeof this==="undefined"){return new g(e,t)}if(e instanceof g){return g({im:e.__im__,re:e.__re__})}if(j.isNumber(e)&&t){if(!t){return Number(e)}}else if(!j.isComplex(e)){var r="Invalid constructor call for LComplex expect &(:im :re ) object but got ".concat(da(e));throw new Error(r)}var n=e.im instanceof j?e.im:j(e.im);var i=e.re instanceof j?e.re:j(e.re);this.constant(n,i)}g.prototype=Object.create(j.prototype);g.prototype.constructor=g;g.prototype.constant=function(e,t){Object.defineProperty(this,"__im__",{value:e,enumerable:true});Object.defineProperty(this,"__re__",{value:t,enumerable:true});Object.defineProperty(this,"__type__",{value:"complex",enumerable:true})};g.prototype.serialize=function(){return{re:this.__re__,im:this.__im__}};g.prototype.toRational=function(e){if(j.isFloat(this.__im__)&&j.isFloat(this.__re__)){var t=E(this.__im__).toRational(e);var r=E(this.__re__).toRational(e);return g({im:t,re:r})}return this};g.prototype.pow=function(e){throw new Error("Not yet implemented")};g.prototype.add=function(e){return this.complex_op("add",e,function(e,t,r,n){return{re:e.add(t),im:r.add(n)}})};g.prototype.factor=function(){if(this.__im__ instanceof E||this.__im__ instanceof E){var e=this.__re__,t=this.__im__;var r,n;if(e instanceof E){r=e.toRational().mul(e.toRational())}else{r=e.mul(e)}if(t instanceof E){n=t.toRational().mul(t.toRational())}else{n=t.mul(t)}return r.add(n)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};g.prototype.modulus=function(){return this.factor().sqrt()};g.prototype.conjugate=function(){return g({re:this.__re__,im:this.__im__.sub()})};g.prototype.sqrt=function(){var e=this.modulus();var t,r;if(e.cmp(0)===0){t=r=e}else if(this.__re__.cmp(0)===1){t=E(.5).mul(e.add(this.__re__)).sqrt();r=this.__im__.div(t).div(2)}else{r=E(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){r=r.sub()}t=this.__im__.div(r).div(2)}return g({im:r,re:t})};g.prototype.div=function(e){if(j.isNumber(e)&&!j.isComplex(e)){if(!(e instanceof j)){e=j(e)}var t=this.__re__.div(e);var r=this.__im__.div(e);return g({re:t,im:r})}else if(!j.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}if(this.cmp(e)===0){var n=this.coerce(e),i=b(n,2),u=i[0],a=i[1];var o=u.__im__.div(a.__im__);return o.coerce(a.__re__)[0]}var s=this.coerce(e),c=b(s,2),f=c[0],l=c[1];var h=l.factor();var p=l.conjugate();var _=f.mul(p);if(!j.isComplex(_)){return _.div(h)}var d=_.__re__.op("/",h);var v=_.__im__.op("/",h);return g({re:d,im:v})};g.prototype.sub=function(e){return this.complex_op("sub",e,function(e,t,r,n){return{re:e.sub(t),im:r.sub(n)}})};g.prototype.mul=function(e){return this.complex_op("mul",e,function(e,t,r,n){var i={re:e.mul(t).sub(r.mul(n)),im:e.mul(n).add(t.mul(r))};return i})};g.prototype.complex_op=function(e,t,i){var u=this;var r=function e(t,r){var n=i(u.__re__,t,u.__im__,r);if("im"in n&&"re"in n){if(n.im.cmp(0)===0){return n.re}return g(n,true)}return n};if(typeof t==="undefined"){return r()}if(j.isNumber(t)&&!j.isComplex(t)){if(!(t instanceof j)){t=j(t)}var n=t.asType(0);t={__im__:n,__re__:t}}else if(!j.isComplex(t)){throw new Error("[LComplex::".concat(e,"] Invalid value"))}var a=t.__re__ instanceof j?t.__re__:this.__re__.asType(t.__re__);var o=t.__im__ instanceof j?t.__im__:this.__im__.asType(t.__im__);return r(a,o)};g._op={"+":"add","-":"sub","*":"mul","/":"div"};g.prototype._op=function(e,t){var r=g._op[e];return this[r](t)};g.prototype.cmp=function(e){var t=this.coerce(e),r=b(t,2),n=r[0],i=r[1];var u=n.__re__.coerce(i.__re__),a=b(u,2),o=a[0],s=a[1];var c=o.cmp(s);if(c!==0){return c}else{var f=n.__im__.coerce(i.__im__),l=b(f,2),h=l[0],p=l[1];return h.cmp(p)}};g.prototype.valueOf=function(){return[this.__re__,this.__im__].map(function(e){return e.valueOf()})};g.prototype.toString=function(){var e;if(this.__re__.cmp(0)!==0){e=[da(this.__re__)]}else{e=[]}var t=this.__im__.valueOf();var r=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(t);var n=da(this.__im__);if(!r&&!Number.isNaN(t)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}n=n.replace(/^-/,"")}e.push(n);e.push("i");return e.join("")};function E(e){if(typeof this!=="undefined"&&!(this instanceof E)||typeof this==="undefined"){return new E(e)}if(!j.isNumber(e)){throw new Error("Invalid constructor call for LFloat")}if(e instanceof j){return E(e.valueOf())}if(typeof e==="number"){if(Object.is(e,-0)){Object.defineProperty(this,"_minus",{value:true})}this.constant(e,"float")}}E.prototype=Object.create(j.prototype);E.prototype.constructor=E;E.prototype.toString=function(){if(this.__value__===Number.NEGATIVE_INFINITY){return"-inf.0"}if(this.__value__===Number.POSITIVE_INFINITY){return"+inf.0"}if(Number.isNaN(this.__value__)){return"+nan.0"}var e=this.__value__.toString();if(!j.isFloat(this.__value__)&&!e.match(/e/i)){var t=e+".0";return this._minus?"-"+t:t}return e.replace(/^([0-9]+)e/,"$1.0e")};E.prototype._op=function(e,t){if(t instanceof j){t=t.__value__}var r=j._ops[e];if(e==="/"&&this.__value__===0&&t===0){return NaN}return E(r(this.__value__,t))};E.prototype.toRational=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){return $o(this.__value__.valueOf())}return Jo(e.valueOf())(this.__value__.valueOf())};E.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){var t=E(Math.sqrt(-e));return g({re:0,im:t})}return E(Math.sqrt(e))};E.prototype.abs=function(){var e=this.valueOf();if(e<0){e=-e}return E(e)};var $o=Jo(1e-10);function Jo(n){return function(e){var t=function e(n,t,r){var i=function e(t,r){return r0){i=Ho(n,r)}else if(n.cmp(r)<=0){i=r}else if(r.cmp(0)>0){i=Ho(r,n)}else if(t.cmp(0)<0){i=j(Ho(n.sub(),r.sub())).sub()}else{i=j(0)}if(j.isFloat(t)||j.isFloat(e)){return E(i)}return i}function Ho(e,t){var r=j(e).floor();var n=j(t).floor();if(e.cmp(r)<1){return r}else if(r.cmp(n)===0){var i=j(1).div(t.sub(n));var u=j(1).div(e.sub(r));return r.add(j(1).div(Ho(i,u)))}else{return r.add(j(1))}}function A(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof A)||typeof this==="undefined"){return new A(e,t)}if(!j.isRational(e)){throw new Error("Invalid constructor call for LRational")}var r,n;if(e instanceof A){r=j(e.__num__);n=j(e.__denom__)}else{r=j(e.num);n=j(e.denom)}if(!t&&n.cmp(0)!==0){var i=r.op("%",n).cmp(0)===0;if(i){return j(r.div(n))}}this.constant(r,n)}A.prototype=Object.create(j.prototype);A.prototype.constructor=A;A.prototype.constant=function(e,t){Object.defineProperty(this,"__num__",{value:e,enumerable:true});Object.defineProperty(this,"__denom__",{value:t,enumerable:true});Object.defineProperty(this,"__type__",{value:"rational",enumerable:true})};A.prototype.serialize=function(){return{num:this.__num__,denom:this.__denom__}};A.prototype.pow=function(e){var t=e.cmp(0);if(t===0){return j(1)}if(t===-1){e=e.sub();var r=this.__denom__.pow(e);var n=this.__num__.pow(e);return A({num:r,denom:n})}var i=this;e=e.valueOf();while(e>1){i=i.mul(this);e--}return i};A.prototype.sqrt=function(){var e=this.__num__.sqrt();var t=this.__denom__.sqrt();if(e instanceof E||t instanceof E){return e.div(t)}return A({num:e,denom:t})};A.prototype.abs=function(){var e=this.__num__;var t=this.__denom__;if(e.cmp(0)===-1){e=e.sub()}if(t.cmp(0)!==1){t=t.sub()}return A({num:e,denom:t})};A.prototype.cmp=function(e){return j(this.valueOf(),true).cmp(e)};A.prototype.toString=function(){var e=this.__num__.gcd(this.__denom__);var t,r;if(e.cmp(1)!==0){t=this.__num__.div(e);if(t instanceof A){t=j(t.valueOf(true))}r=this.__denom__.div(e);if(r instanceof A){r=j(r.valueOf(true))}}else{t=this.__num__;r=this.__denom__}var n=this.cmp(0)<0;if(n){if(t.abs().cmp(r.abs())===0){return t.toString()}}else if(t.cmp(r)===0){return t.toString()}return t.toString()+"/"+r.toString()};A.prototype.valueOf=function(e){if(this.__denom__.cmp(0)===0){if(this.__num__.cmp(0)<0){return Number.NEGATIVE_INFINITY}return Number.POSITIVE_INFINITY}if(e){return j._ops["/"](this.__num__.value,this.__denom__.value)}return E(this.__num__.valueOf()).div(this.__denom__.valueOf())};A.prototype.mul=function(e){if(!(e instanceof j)){e=j(e)}if(j.isRational(e)){var t=this.__num__.mul(e.__num__);var r=this.__denom__.mul(e.__denom__);return A({num:t,denom:r})}var n=j.coerce(this,e),i=b(n,2),u=i[0],a=i[1];return u.mul(a)};A.prototype.div=function(e){if(!(e instanceof j)){e=j(e)}if(j.isRational(e)){var t=this.__num__.mul(e.__denom__);var r=this.__denom__.mul(e.__num__);return A({num:t,denom:r})}var n=j.coerce(this,e),i=b(n,2),u=i[0],a=i[1];var o=u.div(a);return o};A.prototype._op=function(e,t){return this[zo[e]](t)};A.prototype.sub=function(e){if(typeof e==="undefined"){return this.mul(-1)}if(!(e instanceof j)){e=j(e)}if(j.isRational(e)){var t=e.__num__.sub();var r=e.__denom__;return this.add(A({num:t,denom:r}))}if(!(e instanceof j)){e=j(e).sub()}else{e=e.sub()}var n=j.coerce(this,e),i=b(n,2),u=i[0],a=i[1];return u.add(a)};A.prototype.add=function(e){if(!(e instanceof j)){e=j(e)}if(j.isRational(e)){var t=this.__denom__;var r=e.__denom__;var n=this.__num__;var i=e.__num__;var u,a;if(t!==r){a=r.mul(n).add(i.mul(t));u=t.mul(r)}else{a=n.add(i);u=t}return A({num:a,denom:u})}if(j.isFloat(e)){return E(this.valueOf()).add(e)}var o=j.coerce(this,e),s=b(o,2),c=s[0],f=s[1];return c.add(f)};function x(e,t){if(typeof this!=="undefined"&&!(this instanceof x)||typeof this==="undefined"){return new x(e,t)}if(e instanceof x){return x(e.__value__,e._native)}if(!j.isBigInteger(e)){throw new Error("Invalid constructor call for LBigInteger")}this.constant(e,"bigint");Object.defineProperty(this,"_native",{value:t})}x.prototype=Object.create(j.prototype);x.prototype.constructor=x;x.bn_op={"+":"iadd","-":"isub","*":"imul","/":"idiv","%":"imod","|":"ior","&":"iand","~":"inot","<<":"ishrn",">>":"ishln"};x.prototype.serialize=function(){return this.__value__.toString()};x.prototype._op=function(e,t){if(typeof t==="undefined"){if(j.isBN(this.__value__)){e=x.bn_op[e];return x(this.__value__.clone()[e](),false)}return x(j._ops[e](this.__value__),true)}if(j.isBN(this.__value__)&&j.isBN(t.__value__)){e=x.bn_op[e];return x(this.__value__.clone()[e](t),false)}var r=j._ops[e](this.__value__,t.__value__);if(e==="/"){var n=this.op("%",t).cmp(0)===0;if(n){return j(r)}return A({num:this,denom:t})}return x(r,true)};x.prototype.sqrt=function(){var e;var t=this.cmp(0)<0;if(j.isNative(this.__value__)){e=j(Math.sqrt(t?-this.valueOf():this.valueOf()))}else if(j.isBN(this.__value__)){e=t?this.__value__.neg().sqrt():this.__value__.sqrt()}if(t){return g({re:0,im:e})}return e};j.NaN=j(NaN);function Wo(e){var n=this;if(typeof this!=="undefined"&&!(this instanceof Wo)||typeof this==="undefined"){return new Wo(e)}k("InputPort",e,"function");f(this,"__type__",os);var i;Object.defineProperty(this,"__parser__",{enumerable:true,get:function e(){return i},set:function e(t){k("InputPort::__parser__",t,"parser");i=t}});this._read=e;this._with_parser=this._with_init_parser.bind(this,ae(C.mark(function e(){var r;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(n.char_ready()){t.next=5;break}t.next=3;return n._read();case 3:r=t.sent;i=new bu(r,{env:n});case 5:return t.abrupt("return",n.__parser__);case 6:case"end":return t.stop()}},e)})));this.char_ready=function(){return!!this.__parser__&&this.__parser__.__lexer__.peek()!==ss};this._make_defaults()}Wo.prototype._make_defaults=function(){this.read=this._with_parser(function(e){return e.read_object()});this.read_line=this._with_parser(function(e){return e.__lexer__.read_line()});this.read_char=this._with_parser(function(e){return e.__lexer__.read_char()});this.read_string=this._with_parser(function(e,t){if(!j.isInteger(t)){var r=j.getType(t);Ps("read-string",r,"integer")}return e.__lexer__.read_string(t.valueOf())});this.peek_char=this._with_parser(function(e){return e.__lexer__.peek_char()})};Wo.prototype._with_init_parser=function(o,s){var c=this;return ae(C.mark(function e(){var r,n,i,u,a=arguments;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:t.next=2;return o.call(c);case 2:r=t.sent;for(n=a.length,i=new Array(n),u=0;u"};function Go(e){if(typeof this!=="undefined"&&!(this instanceof Go)||typeof this==="undefined"){return new Go(e)}k("OutputPort",e,"function");f(this,"__type__",os);this.write=e}Go.prototype.is_open=function(){return this._closed!==true};Go.prototype.close=function(){Object.defineProperty(this,"_closed",{get:function e(){return true},set:function e(){},configurable:false,enumerable:false});this.write=function(){throw new Error("output-port: port is closed")}};Go.prototype.flush=function(){};Go.prototype.toString=function(){return"#"};var Qo=function(e){G(r,e);function r(e){var t;oe(this,r);t=Kn(this,r,[function(){var e;return(e=t)._write.apply(e,arguments)}]);k("BufferedOutputPort",e,"function");f(H(t),"_fn",e,{hidden:true});f(H(t),"_buffer",[],{hidden:true});return t}le(r,[{key:"flush",value:function e(){if(this._buffer.length){this._fn(this._buffer.join(""));this._buffer.length=0}}},{key:"_write",value:function e(){var t=this;for(var r=arguments.length,n=new Array(r),i=0;i"};Zo.prototype.valueOf=function(){return this.__buffer__.map(function(e){return e.valueOf()}).join("")};function Xo(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof Xo)||typeof this==="undefined"){return new Xo(e,t)}k("OutputFilePort",e,"string");f(this,"__filename__",e);f(this,"_fd",t.valueOf(),{hidden:true});f(this,"__type__",os);this.write=function(e){if(!D.isString(e)){e=da(e)}else{e=e.valueOf()}r.fs().write(r._fd,e,function(e){if(e){throw e}})}}Xo.prototype=Object.create(Go.prototype);Xo.prototype.constructor=Xo;Xo.prototype.fs=function(){if(!this._fs){this._fs=this.internal("fs")}return this._fs};Xo.prototype.internal=function(e){return Es.get("**internal-env**").get(e)};Xo.prototype.close=function(){var n=this;return new Promise(function(t,r){n.fs().close(n._fd,function(e){if(e){r(e)}else{f(n,"_fd",null,{hidden:true});Go.prototype.close.call(n);t()}})})};Xo.prototype.toString=function(){return"#")};function es(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof es)||typeof this==="undefined"){return new es(e)}k("InputStringPort",e,"string");t=t||I;e=e.valueOf();this._with_parser=this._with_init_parser.bind(this,function(){if(!r.__parser__){r.__parser__=new bu(e,{env:t})}return r.__parser__});f(this,"__type__",os);this._make_defaults()}es.prototype.char_ready=function(){return true};es.prototype=Object.create(Wo.prototype);es.prototype.constructor=es;es.prototype.toString=function(){return"#"};function ts(e){if(typeof this!=="undefined"&&!(this instanceof ts)||typeof this==="undefined"){return new ts(e)}k("InputByteVectorPort",e,"uint8array");f(this,"__vector__",e);f(this,"__type__",as);var r=0;Object.defineProperty(this,"__index__",{enumerable:true,get:function e(){return r},set:function e(t){k("InputByteVectorPort::__index__",t,"number");if(t instanceof j){t=t.valueOf()}if(typeof t==="bigint"){t=Number(t)}if(Math.floor(t)!==t){throw new Error("InputByteVectorPort::__index__ value is "+"not integer")}r=t}})}ts.prototype=Object.create(Wo.prototype);ts.prototype.constructor=ts;ts.prototype.toString=function(){return"#"};ts.prototype.close=function(){var t=this;f(this,"__vector__",U);var r=function e(){throw new Error("Input-binary-port: port is closed")};["read_u8","close","peek_u8","read_u8_vector"].forEach(function(e){t[e]=r});this.u8_ready=this.char_ready=function(){return false}};ts.prototype.u8_ready=function(){return true};ts.prototype.peek_u8=function(){if(this.__index__>=this.__vector__.length){return ss}return this.__vector__[this.__index__]};ts.prototype.skip=function(){if(this.__index__<=this.__vector__.length){++this.__index__}};ts.prototype.read_u8=function(){var e=this.peek_u8();this.skip();return e};ts.prototype.read_u8_vector=function(e){if(typeof e==="undefined"){e=this.__vector__.length}else if(e>this.__index__+this.__vector__.length){e=this.__index__+this.__vector__.length}if(this.peek_u8()===ss){return ss}return this.__vector__.slice(this.__index__,e)};function rs(){if(typeof this!=="undefined"&&!(this instanceof rs)||typeof this==="undefined"){return new rs}f(this,"__type__",as);f(this,"_buffer",[],{hidden:true});this.write=function(e){k("write",e,["number","uint8array"]);if(j.isNumber(e)){this._buffer.push(e.valueOf())}else{var t;(t=this._buffer).push.apply(t,R(Array.from(e)))}};Object.defineProperty(this,"__buffer__",{enumerable:true,get:function e(){return Uint8Array.from(this._buffer)}})}rs.prototype=Object.create(Go.prototype);rs.prototype.constructor=rs;rs.prototype.close=function(){Go.prototype.close.call(this);f(this,"_buffer",null,{hidden:true})};rs.prototype._close_guard=function(){if(this._closed){throw new Error("output-port: binary port is closed")}};rs.prototype.write_u8=function(e){k("OutputByteVectorPort::write_u8",e,"number");this.write(e)};rs.prototype.write_u8_vector=function(e){k("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};rs.prototype.toString=function(){return"#"};rs.prototype.valueOf=function(){return this.__buffer__};function ns(e,t){if(typeof this!=="undefined"&&!(this instanceof ns)||typeof this==="undefined"){return new ns(e,t)}es.call(this,e);k("InputFilePort",t,"string");f(this,"__filename__",t)}ns.prototype=Object.create(es.prototype);ns.prototype.constructor=ns;ns.prototype.toString=function(){return"#")};function is(e,t){if(typeof this!=="undefined"&&!(this instanceof is)||typeof this==="undefined"){return new is(e,t)}ts.call(this,e);k("InputBinaryFilePort",t,"string");f(this,"__filename__",t)}is.prototype=Object.create(ts.prototype);is.prototype.constructor=is;is.prototype.toString=function(){return"#")};function us(e,t){var i=this;if(typeof this!=="undefined"&&!(this instanceof us)||typeof this==="undefined"){return new us(e,t)}k("OutputBinaryFilePort",e,"string");f(this,"__filename__",e);f(this,"_fd",t.valueOf(),{hidden:true});f(this,"__type__",as);var u;this.write=function(e){k("write",e,["number","uint8array"]);var n;if(!u){u=i.internal("fs")}if(j.isNumber(e)){n=new Uint8Array([e.valueOf()])}else{n=new Uint8Array(Array.from(e))}return new Promise(function(t,r){u.write(i._fd,n,function(e){if(e){r(e)}else{t()}})})}}us.prototype=Object.create(Xo.prototype);us.prototype.constructor=us;us.prototype.write_u8=function(e){k("OutputByteVectorPort::write_u8",e,"number");this.write(e)};us.prototype.write_u8_vector=function(e){k("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};var as=Symbol["for"]("binary");var os=Symbol["for"]("text");var ss=new cs;function cs(){}cs.prototype.toString=function(){return"#"};function fs(e){var t=this;var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},n=r.stderr,i=r.stdin,u=r.stdout,a=r.command_line,o=a===void 0?null:a,s=_e(r,qn);if(typeof this!=="undefined"&&!(this instanceof fs)||typeof this==="undefined"){return new fs(e,T({stdin:i,stdout:u,stderr:n,command_line:o},s))}if(typeof e==="undefined"){e="anonymous"}this.__env__=Es.inherit(e,s);this.__env__.set("parent.frame",l("parent.frame",function(){return t.__env__},I.__env__["parent.frame"].__doc__));var c="**interaction-environment-defaults**";this.set(c,fa(s).concat(c));var f=bs.inherit("internal-".concat(e));if(to(i)){f.set("stdin",i)}if(to(n)){f.set("stderr",n)}if(to(u)){f.set("stdout",u)}f.set("command-line",o);As(this.__env__,f)}fs.prototype.exec=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=t.use_dynamic,n=r===void 0?false:r,i=t.dynamic_env,u=t.env;k("Interpreter::exec",e,["string","array"],1);k("Interpreter::exec",n,"boolean",2);if(!u){u=this.__env__}if(!i){i=u}I.set("**interaction-environment**",this.__env__);return Xs(e,{env:u,dynamic_env:i,use_dynamic:n})};fs.prototype.get=function(e){var t=this.__env__.get(e);if(m(t)){var r=new Ws({env:this.__env__});return t.bind(r)}return t};fs.prototype.set=function(e,t){return this.__env__.set(e,t)};fs.prototype.constant=function(e,t){return this.__env__.constant(e,t)};function ls(e,t){this.name="LipsError";this.message=e;this.args=t;this.stack=(new Error).stack}ls.prototype=new Error;ls.prototype.constructor=ls;var hs=function(e){G(t,e);function t(){oe(this,t);return Kn(this,t,arguments)}return le(t)}(r(Error));function F(e,t,r){if(arguments.length===1){if(p(arguments[0])==="object"){e=arguments[0];t=null}else if(typeof arguments[0]==="string"){e={};t=null;r=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=t;this.__name__=r||"anonymous"}F.prototype.list=function(){return fa(this.__env__)};F.prototype.fs=function(){return this.get("**fs**")};F.prototype.unset=function(e){if(e instanceof L){e=e.valueOf()}if(e instanceof D){e=e.valueOf()}delete this.__env__[e]};F.prototype.inherit=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(p(e)==="object"){t=e}if(!e||p(e)==="object"){e="child of "+(this.__name__||"unknown")}return new F(t||{},this,e)};F.prototype.doc=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(e instanceof L){e=e.__name__}if(e instanceof D){e=e.valueOf()}if(t){if(!r){t=Ou(t)}this.__docs__.set(e,t);return this}if(this.__docs__.has(e)){return this.__docs__.get(e)}if(this.__parent__){return this.__parent__.doc(e)}};F.prototype.new_frame=function(e,t){var n=this.inherit("__frame__");n.set("parent.frame",l("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1;e=e.valueOf();var t=n.__parent__;if(!Ta(t)){return U}if(e<=0){return t}var r=t.get("parent.frame");return r(e-1)},I.__env__["parent.frame"].__doc__));t.callee=e;n.set("arguments",t);return n};F.prototype._lookup=function(e){if(e instanceof L){e=e.__name__}if(e instanceof D){e=e.valueOf()}if(this.__env__.hasOwnProperty(e)){return ps(this.__env__[e])}if(this.__parent__){return this.__parent__._lookup(e)}};F.prototype.toString=function(){return"#"};F.prototype.clone=function(){var t=this;var r={};Object.keys(this.__env__).forEach(function(e){r[e]=t.__env__[e]});return new F(r,this.__parent__,this.__name__)};F.prototype.merge=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"merge";k("Environment::merge",e,"environment");return this.inherit(t,e.__env__)};function ps(e){if(typeof this!=="undefined"&&!(this instanceof ps)||typeof this==="undefined"){return new ps(e)}this.value=e}ps.isUndefined=function(e){return e instanceof ps&&typeof e.value==="undefined"};ps.prototype.valueOf=function(){return this.value};function _s(e){if(e.length){if(e.length===1){return e[0]}}if(typeof this!=="undefined"&&!(this instanceof _s)||typeof this==="undefined"){return new _s(e)}this.__values__=e}_s.prototype.toString=function(){return this.__values__.map(function(e){return da(e)}).join("\n")};_s.prototype.valueOf=function(){return this.__values__};F.prototype.get=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};k("Environment::get",e,["symbol","string"]);var r=t.throwError,n=r===void 0?true:r;var i=e;if(i instanceof L||i instanceof D){i=i.valueOf()}var u=this._lookup(i);if(u instanceof ps){if(ps.isUndefined(u)){return undefined}return Wa(u.valueOf())}var a;if(e instanceof L&&e[L.object]){a=e[L.object]}else if(typeof i==="string"){a=i.split(".").filter(Boolean)}if(a&&a.length>0){var o=a,s=re(o),c=s[0],f=s.slice(1);u=this._lookup(c);if(f.length){try{if(u instanceof ps){u=u.valueOf()}else{u=ys(ti,c);if(m(u)){u=Ga(u)}}if(typeof u!=="undefined"){return ys.apply(void 0,[u].concat(R(f)))}}catch(e){throw e}}else if(u instanceof ps){return Wa(u.valueOf())}u=ys(ti,i)}if(typeof u!=="undefined"){return u}if(n){throw new Error("Unbound variable `"+i.toString()+"'")}};F.prototype.set=function(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;k("Environment::set",e,["string","symbol"]);if(j.isNumber(t)){t=j(t)}if(e instanceof L){e=e.__name__}if(e instanceof D){e=e.valueOf()}this.__env__[e]=t;if(r){this.doc(e,r,true)}return this};F.prototype.constant=function(t,e){var r=this;if(this.__env__.hasOwnProperty(t)){throw new Error("Environment::constant: ".concat(t," already exists"))}if(arguments.length===1&&ra(arguments[0])){var n=arguments[0];Object.keys(n).forEach(function(e){r.constant(t,n[e])})}else{Object.defineProperty(this.__env__,t,{value:e,enumerable:true})}return this};F.prototype.has=function(e){return this.__env__.hasOwnProperty(e)};F.prototype.ref=function(e){var t=this;while(true){if(!t){break}if(t.has(e)){return t}t=t.__parent__}};F.prototype.parents=function(){var e=this;var t=[];while(e){t.unshift(e);e=e.__parent__}return t};function ds(e){if(Ua(e)){return e.then(ds)}if(e instanceof M||e instanceof L){e[uo]=true}return e}var vs=Du(nu('(lambda ()\n "[native code]"\n (throw "Invalid Invocation"))'))[0];var ys=l("get",function e(t){var r;for(var n=arguments.length,i=new Array(n>1?n-1:0),u=1;u0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=ms(this,"stdin")}Ls("peek-char",e,"input-port");return e.peek_char()},"(peek-char port)\n\n This function reads and returns a character from the string\n port, or, if there is no more data in the string port, it\n returns an EOF."),"read-line":l("read-line",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=ms(this,"stdin")}Ls("read-line",e,"input-port");return e.read_line()},"(read-line port)\n\n This function reads and returns the next line from the input\n port."),"read-char":l("read-char",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=ms(this,"stdin")}Ls("read-char",e,"input-port");return e.read_char()},"(read-char port)\n\n This function reads and returns the next character from the\n input port."),read:l("read",function(){var e=ae(function(){var f=this;var l=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;return C.mark(function e(){var r,n,i,u,a,o,s,c;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=f.env;if(!D.isString(l)){t.next=30;break}n=false;i=false;t.prev=4;a=Xn(Du(l,r));case 6:t.next=8;return a.next();case 8:if(!(n=!(o=t.sent).done)){t.next=14;break}s=o.value;return t.abrupt("return",s);case 11:n=false;t.next=6;break;case 14:t.next=20;break;case 16:t.prev=16;t.t0=t["catch"](4);i=true;u=t.t0;case 20:t.prev=20;t.prev=21;if(!(n&&a["return"]!=null)){t.next=25;break}t.next=25;return a["return"]();case 25:t.prev=25;if(!i){t.next=28;break}throw u;case 28:return t.finish(25);case 29:return t.finish(20);case 30:if(l===null){c=ms(r,"stdin")}else{c=l}Ls("read",c,"input-port");return t.abrupt("return",c.read.call(r));case 33:case"end":return t.stop()}},e,null,[[4,16,20,30],[21,,25,29]])})()});function t(){return e.apply(this,arguments)}return t}(),"(read [string])\n\n This function, if used with a string, will parse it and\n return the LIPS code, if there is any. If called with a\n port, it will parse the next item from the port. If called\n without an input, it will read a string from standard input\n (using the browser's prompt or a user defined input method)\n and calls itself with that string. This function can be used\n together with `eval` to evaluate code from a string."),pprint:l("pprint",function e(t){if(t instanceof M){t=new Pc.Formatter(t.toString(true))["break"]().format();I.get("display").call(I,t)}else{I.get("write").call(I,t)}I.get("newline").call(I)},"(pprint expression)\n\n This function will pretty print its input to stdout. If it is called\n with a non-list, it will just call the print function on its\n input."),print:l("print",function e(){var t=I.get("display");var r=I.get("newline");var n=this.use_dynamic;var i=I;var u=I;for(var a=arguments.length,o=new Array(a),s=0;s1?r-1:0),i=1;in.length){throw new Error("Not enough arguments")}var o=0;var s=I.get("repr");t=t.replace(u,function(e){var t=e[1];if(t==="~"){return"~"}else if(t==="%"){return"\n"}else{var r=n[o++];if(t==="a"){return s(r)}else{return s(r,true)}}});a=t.match(/~([\S])/);if(a){throw new Error("format: Unrecognized escape sequence ".concat(a[1]))}return t},"(format string n1 n2 ...)\n\n This function accepts a string template and replaces any\n escape sequences in its inputs:\n\n * ~a value as if printed with `display`\n * ~s value as if printed with `write`\n * ~% newline character\n * ~~ literal tilde '~'\n\n If there are missing inputs or other escape characters it\n will error."),display:l("display",function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(r===null){r=ms(this,"stdout")}else{k("display",r,"output-port")}var n=t;if(!(r instanceof us)){n=I.get("repr")(t)}r.write.call(I,n)},"(display string [port])\n\n This function outputs the string to the standard output or\n the port if given. No newline."),"display-error":l("display-error",function e(){var t=ms(this,"stderr");var r=I.get("repr");for(var n=arguments.length,i=new Array(n),u=0;u1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=_e(t,zn);var i=this;var a=this;var o;var s=T(T({},n),{},{env:this,dynamic_env:i,use_dynamic:r});var c=P(e.cdr.car,s);c=Ms(c);function f(t,r,n){if(Ua(t)){return t.then(function(e){return f(t,e,n)})}if(Ua(r)){return r.then(function(e){return f(t,e,n)})}if(Ua(n)){return n.then(function(e){return f(t,r,e)})}a.get("set-obj!").call(a,t,r,n);return n}if(e.car instanceof M&&L.is(e.car.car,".")){var l=e.car.cdr.car;var h=e.car.cdr.cdr.car;var p=P(l,{env:this,dynamic_env:i,use_dynamic:r,error:error});var _=P(h,{env:this,dynamic_env:i,use_dynamic:r,error:error});return f(p,_,c)}if(!(e.car instanceof L)){throw new Error("set! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var d=e.car.valueOf();o=this.ref(e.car.__name__);return w(c,function(e){if(!o){var t=d.split(".");if(t.length>1){var r=t.pop();var n=t.join(".");var i=u.get(n,{throwError:false});if(i){f(i,r,e);return}}throw new Error("Unbound variable `"+d+"'")}o.set(d,e)})}),"(set! name value)\n\n Macro that can be used to set the value of the variable or slot (mutate it).\n set! searches the scope chain until it finds first non empty slot and sets it."),"unset!":l(new q("set!",function(e){if(!(e.car instanceof L)){throw new Error("unset! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var t=e.car;var r=this.ref(t);if(r){delete r.__env__[t.__name__]}}),"(unset! name)\n\n Function to delete the specified name from environment.\n Trying to access the name afterwards will error."),"set-car!":l("set-car!",function(e,t){k("set-car!",e,"pair");e.car=t},"(set-car! obj value)\n\n Function that sets the car (first item) of the list/pair to specified value.\n The old value is lost."),"set-cdr!":l("set-cdr!",function(e,t){k("set-cdr!",e,"pair");e.cdr=t},"(set-cdr! obj value)\n\n Function that sets the cdr (tail) of the list/pair to specified value.\n It will destroy the list. The old tail is lost."),"empty?":l("empty?",function(e){return typeof e==="undefined"||e===U},"(empty? object)\n\n Function that returns #t if value is nil (an empty list) or undefined."),gensym:l("gensym",su,"(gensym)\n\n Generates a unique symbol that is not bound anywhere,\n to use with macros as meta name."),load:l("load",function e(o,t){k("load",o,"string");var s=this;if(s.__name__==="__frame__"){s=s.__parent__}if(!(t instanceof F)){if(s===I){t=s}else{t=this.get("**interaction-environment**")}}var c="**module-path**";var f=I.get(c,{throwError:false});o=o.valueOf();if(!o.match(/.[^.]+$/)){o+=".scm"}var r=o.match(/\.xcb$/);function l(e){if(r){e=Fc(e)}else{if(z(e)==="buffer"){e=e.toString()}e=e.replace(/^#!.*/,"");if(e.match(/^\{/)){e=gc(e)}}return Xs(e,{env:t})}function n(e){return ti.fetch(e).then(function(e){return r?e.arrayBuffer():e.text()}).then(function(e){if(r){e=new Uint8Array(e)}return e})}if(Ss()){return new Promise(function(){var r=ae(C.mark(function e(r,n){var i,u,a;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:i=ai("path");if(!f){t.next=6;break}f=f.valueOf();o=i.join(f,o);t.next=12;break;case 6:u=s.get("command-line",{throwError:false});if(!u){t.next=11;break}t.next=10;return u();case 10:a=t.sent;case 11:if(a&&a!==U){process.cwd();o=i.join(i.dirname(a.car.valueOf()),o)}case 12:I.set(c,i.dirname(o));ai("fs").readFile(o,function(e,t){if(e){n(e);I.set(c,f)}else{try{l(t).then(function(){r();I.set(c,f)})["catch"](n)}catch(e){n(e)}}});case 14:case"end":return t.stop()}},e)}));return function(e,t){return r.apply(this,arguments)}}())}if(f){f=f.valueOf();o=f+"/"+o.replace(/^\.?\/?/,"")}return n(o).then(function(e){I.set(c,o.replace(/\/[^/]*$/,""));return l(e)}).then(function(){})["finally"](function(){I.set(c,f)})},"(load filename)\n (load filename environment)\n\n Fetches the file (from disk or network) and evaluates its content as LIPS code.\n If the second argument is provided and it's an environment the evaluation\n will happen in that environment."),do:l(new q("do",function(){var r=ae(function(h,e){var p=this;var _=e.use_dynamic,d=e.error;return C.mark(function e(){var r,n,o,s,i,c,f,u,a,l;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:r=p;n=r;o=r.inherit("do");s=h.car;i=h.cdr.car;c=h.cdr.cdr;if(c!==U){c=new M(L("begin"),c)}f={env:r,dynamic_env:n,use_dynamic:_,error:d};u=s;case 9:if(!(u!==U)){t.next=20;break}a=u.car;t.t0=o;t.t1=a.car;t.next=15;return P(a.cdr.car,f);case 15:t.t2=t.sent;t.t0.set.call(t.t0,t.t1,t.t2);u=u.cdr;t.next=9;break;case 20:f={env:o,dynamic_env:n,error:d};l=C.mark(function e(){var r,n,i,u,a;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!(c!==U)){t.next=3;break}t.next=3;return Pc.evaluate(c,f);case 3:r=s;n={};case 5:if(!(r!==U)){t.next=15;break}i=r.car;if(!(i.cdr.cdr!==U)){t.next=12;break}t.next=10;return P(i.cdr.cdr.car,f);case 10:u=t.sent;n[i.car.valueOf()]=u;case 12:r=r.cdr;t.next=5;break;case 15:a=Object.getOwnPropertySymbols(n);Object.keys(n).concat(a).forEach(function(e){o.set(e,n[e])});case 17:case"end":return t.stop()}},e)});case 22:t.next=24;return P(i.car,f);case 24:t.t3=t.sent;if(!(t.t3===false)){t.next=29;break}return t.delegateYield(l(),"t4",27);case 27:t.next=22;break;case 29:if(!(i.cdr!==U)){t.next=33;break}t.next=32;return P(i.cdr.car,f);case 32:return t.abrupt("return",t.sent);case 33:case"end":return t.stop()}},e)})()});return function(e,t){return r.apply(this,arguments)}}()),"(do (( )) (test return) . body)\n\n Iteration macro that evaluates the expression body in scope of the variables.\n On each loop it changes the variables according to the expression and runs\n test to check if the loop should continue. If test is a single value, the macro\n will return undefined. If the test is a pair of expressions the macro will\n evaluate and return the second expression after the loop exits."),if:l(new q("if",function(r,e){var t=e.error,n=e.use_dynamic;var i=this;var u=this;var a={env:u,dynamic_env:i,use_dynamic:n,error:t};var o=function e(t){if(t===false){return P(r.cdr.cdr.car,a)}else{return P(r.cdr.car,a)}};if(r===U){throw new Error("too few expressions for `if`")}var s=P(r.car,a);return w(s,o)}),"(if cond true-expr false-expr)\n\n Macro that evaluates cond expression and if the value is true, it\n evaluates and returns true-expression, if not it evaluates and returns\n false-expression."),"let-env":new q("let-env",function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=e.dynamic_env,n=e.use_dynamic,i=e.error;k("let-env",t,"pair");var u=P(t.car,{env:this,dynamic_env:r,error:i,use_dynamic:n});return w(u,function(e){k("let-env",e,"environment");return P(M(L("begin"),t.cdr),{env:e,dynamic_env:r,error:i})})},"(let-env env . body)\n\n Special macro that evaluates body in context of given environment\n object."),letrec:l(wo(Symbol["for"]("letrec")),"(letrec ((a value-a) (b value-b) ...) . body)\n\n Macro that creates a new environment, then evaluates and assigns values to\n names and then evaluates the body in context of that environment.\n Values are evaluated sequentially and the next value can access the\n previous values/names."),"letrec*":l(wo(Symbol["for"]("letrec")),"(letrec* ((a value-a) (b value-b) ...) . body)\n\n Same as letrec but the order of execution of the binding is guaranteed,\n so you can use recursive code as well as referencing the previous binding.\n\n In LIPS both letrec and letrec* behave the same."),"let*":l(wo(Symbol["for"]("let*")),"(let* ((a value-a) (b value-b) ...) . body)\n\n Macro similar to `let`, but the subsequent bindings after the first\n are evaluated in the environment including the previous let variables,\n so you can define one variable, and use it in the next's definition."),let:l(wo(Symbol["for"]("let")),"(let ((a value-a) (b value-b) ...) . body)\n\n Macro that creates a new environment, then evaluates and assigns values to names,\n and then evaluates the body in context of that environment. Values are evaluated\n sequentially but you can't access previous values/names when the next are\n evaluated. You can only get them in the body of the let expression. (If you want\n to define multiple variables and use them in each other's definitions, use\n `let*`.)"),"begin*":l(Do("begin*",function(e){return e.pop()}),"(begin* . body)\n\n This macro is a parallel version of begin. It evaluates each expression\n in the body and if it's a promise it will await it in parallel and return\n the value of the last expression (i.e. it uses Promise.all())."),shuffle:l("shuffle",function(e){k("shuffle",e,["pair","nil","array"]);var t=I.get("random");if(e===U){return U}if(Array.isArray(e)){return Zu(e.slice(),t)}var r=I.get("list->array")(e);r=Zu(r,t);return I.get("array->list")(r)},"(shuffle obj)\n\n Order items in vector or list in random order."),begin:l(new q("begin",function(e,t){var n=T(T({},t),{},{env:this});var i=I.get("list->array")(e);var u;return function t(){if(i.length){var e=i.shift();var r=P(e,n);return w(r,function(e){u=e;return t()})}else{return u}}()}),"(begin . args)\n\n Macro that runs a list of expressions in order and returns the value\n of the last one. It can be used in places where you can only have a\n single expression, like (if)."),ignore:new q("ignore",function(e,t){var r=T(T({},t),{},{env:this,dynamic_env:this});P(new M(new L("begin"),e),r)},"(ignore . body)\n\n Macro that will evaluate the expression and swallow any promises that may\n be created. It will discard any value that may be returned by the last body\n expression. The code should have side effects and/or when it's promise\n it should resolve to undefined."),"call/cc":l(q.defmacro("call/cc",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=T({env:this},t);return w(P(e.car,r),function(e){if(m(e)){return e(new Qs(null))}})}),"(call/cc proc)\n\n Call-with-current-continuation.\n\n NOT SUPPORTED BY LIPS RIGHT NOW"),parameterize:l(new q("parameterize",function(t,e){var i=e.dynamic_env;var u=i.inherit("parameterize").new_frame(null,{});var a=T(T({},e),{},{env:this});var o=t.car;if(!Ra(o)){var r=z(o);throw new Error("Invalid syntax for parameterize expecting pair got ".concat(r))}function s(){var e=new M(new L("begin"),t.cdr);return P(e,T(T({},a),{},{dynamic_env:u}))}return function r(){var e=o.car;var n=e.car.valueOf();return w(P(e.cdr.car,a),function(e){var t=i.get(n,{throwError:false});if(!Na(t)){throw new Error("Unknown parameter ".concat(n))}u.set(n,t.inherit(e));if(!ja(o.cdr)){o=o.cdr;return r()}else{return s()}})}()}),"(parameterize ((name value) ...)\n\n Macro that change the dynamic variable created by make-parameter."),"make-parameter":l(new q("make-parameter",function(e,t){t.dynamic_env;var r=P(e.car,t);var n;if(e.cdr.car instanceof M){n=P(e.cdr.car,t)}return new Hs(r,n)}),"(make-parameter init converter)\n\n Function creates new dynamic variable that can be custimized with parameterize\n macro. The value should be assigned to a variable e.g.:\n\n (define radix (make-parameter 10))\n\n The result value is a procedure that return the value of dynamic variable."),define:l(q.defmacro("define",function(r,e){var n=this;if(r.car instanceof M&&r.car.car instanceof L){var t=new M(new L("define"),new M(r.car.car,new M(new M(new L("lambda"),new M(r.car.cdr,r.cdr)))));return t}else if(e.macro_expand){return}e.dynamic_env=this;e.env=n;var i=r.cdr.car;var u;if(i instanceof M){i=P(i,e);u=true}else if(i instanceof L){i=n.get(i)}k("define",r.car,"symbol");return w(i,function(e){if(n.__name__===ka.__merge_env__){n=n.__parent__}if(u&&(m(e)&&yo(e)||e instanceof ka||Na(e))){e.__name__=r.car.valueOf();if(e.__name__ instanceof D){e.__name__=e.__name__.valueOf()}}var t;if(r.cdr.cdr instanceof M&&D.isString(r.cdr.cdr.car)){t=r.cdr.cdr.car.valueOf()}n.set(r.car,e,t,true)})}),'(define name expression)\n (define name expression "doc string")\n (define (function-name . args) . body)\n\n Macro for defining values. It can be used to define variables,\n or functions. If the first argument is list it will create a function\n with name being first element of the list. This form expands to\n `(define function-name (lambda args body))`'),"set-obj!":l("set-obj!",function(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var i=p(e);if(ja(e)||i!=="object"&&i!=="function"){var u=Ps("set-obj!",z(e),["object","function"]);throw new Error(u)}k("set-obj!",t,["string","symbol","number"]);e=Ga(e);t=t.valueOf();if(arguments.length===2){delete e[t]}else if(va(e)&&m(r)){e[t]=Ga(r);e[t][fo]=true}else if(m(r)||Ya(r)||r===U){e[t]=r}else{e[t]=r&&!va(r)?r.valueOf():r}if(na){var a=e[t];Object.defineProperty(e,t,T(T({},n),{},{value:a}))}},"(set-obj! obj key value)\n (set-obj! obj key value props)\n\n Function set a property of a JavaScript object. props should be a vector of pairs,\n passed to Object.defineProperty."),"null-environment":l("null-environment",function(){return I.inherit("null")},"(null-environment)\n\n Returns a clean environment with only the standard library."),values:l("values",function e(){for(var t=arguments.length,r=new Array(t),n=0;n1&&arguments[1]!==undefined?arguments[1]:{},y=e.use_dynamic,m=e.error;var g=this;var b;if(v.cdr instanceof M&&D.isString(v.cdr.car)&&v.cdr.cdr!==U){b=v.cdr.car.valueOf()}function w(){var e=Pa(this)?this:{dynamic_env:g},r=e.dynamic_env;var n=g.inherit("lambda");r=r.inherit("lambda");if(this&&!Pa(this)){if(this&&!this.__instance__){Object.defineProperty(this,"__instance__",{enumerable:false,get:function e(){return true},set:function e(){},configurable:false})}n.set("this",this)}for(var t=arguments.length,i=new Array(t),u=0;u>> "+d.toString());if(d){h=d}var v=u.merge(n,ka.__merge_env__);if(r){return{expr:h,scope:v}}var y=P(h,T(T({},o),{},{env:v}));return Sa(y,_)}c=c.cdr}}catch(e){e.message+=" in macro: ".concat(m.toString(true));throw e}throw new Error("Invalid Syntax ".concat(e.toString(true)))},w);r.__code__=m;return r},"(syntax-rules () (pattern expression) ...)\n\n Base of hygienic macros, it will return a new syntax expander\n that works like Lisp macros."),quote:l(new q("quote",function(e){return ds(e.car)}),"(quote expression) or 'expression\n\n Macro that returns a single LIPS expression as data (it won't evaluate the\n argument). It will return a list if put in front of LIPS code.\n And if put in front of a symbol it will return the symbol itself, not the value\n bound to that name."),"unquote-splicing":l("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code) or ,@code\n\n Special form used in the quasiquote macro. It evaluates the expression inside and\n splices the list into quasiquote's result. If it is not the last element of the\n expression, the computed value must be a pair."),unquote:l("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code) or ,code\n\n Special form used in the quasiquote macro. It evaluates the expression inside and\n substitutes the value into quasiquote's result."),quasiquote:q.defmacro("quasiquote",function(e,t){var o=t.use_dynamic,s=t.error;var c=this;var f=c;function u(e){return e instanceof M||ra(e)||Array.isArray(e)}function l(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:u;if(e instanceof M){var n=e.car;var i=e.cdr;if(r(n)){n=t(n)}if(r(i)){i=t(i)}if(Ua(n)||Ua(i)){return fu([n,i]).then(function(e){var t=b(e,2),r=t[0],n=t[1];return new M(r,n)})}else{return new M(n,i)}}return e}function a(e,t){if(e instanceof M){if(t!==U){e.append(t)}}else{e=new M(e,t)}return e}function r(e){return!!e.filter(function(e){return e instanceof M&&L.is(e.car,/^(unquote|unquote-splicing)$/)}).length}function h(e,n,i){return e.reduce(function(e,t){if(!(t instanceof M)){e.push(t);return e}if(L.is(t.car,"unquote-splicing")){var r;if(n+11){var t="You can't splice multiple atoms inside list";throw new Error(t)}if(!(i.cdr instanceof M&&r[0]===U)){return r[0]}}r=r.map(function(e){if(d.has(e)){return e.clone()}else{d.add(e);return e}});var n=v(i.cdr,0,1);if(n===U&&r[0]===U){return undefined}return w(n,function(e){if(r[0]===U){return e}if(r.length===1){return a(r[0],e)}var t=r.reduce(function(e,t){return a(e,t)});return a(t,e)})})}(i.car.cdr)}var d=new Set;function v(e,t,r){if(e instanceof M){if(e.car instanceof M){if(L.is(e.car.car,"unquote-splicing")){return _(e,t+1,r)}if(L.is(e.car.car,"unquote")){if(t+2===r&&e.car.cdr instanceof M&&e.car.cdr.car instanceof M&&L.is(e.car.cdr.car.car,"unquote-splicing")){var n=e.car.cdr;return new M(new M(new L("unquote"),_(n,t+2,r)),U)}else if(e.car.cdr instanceof M&&e.car.cdr.cdr!==U){if(e.car.cdr.car instanceof M){var i=[];return function t(r){if(r===U){return M.fromArray(i)}return w(P(r.car,{env:c,dynamic_env:f,use_dynamic:o,error:s}),function(e){i.push(e);return t(r.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}}if(L.is(e.car,"quasiquote")){var u=v(e.cdr,t,r+1);return new M(e.car,u)}if(L.is(e.car,"quote")){return new M(e.car,v(e.cdr,t,r))}if(L.is(e.car,"unquote")){t++;if(tr){throw new Error("You can't call `unquote` outside "+"of quasiquote")}if(e.cdr instanceof M){if(e.cdr.cdr!==U){if(e.cdr.car instanceof M){var a=[];return function t(r){if(r===U){return M.fromArray(a)}return w(P(r.car,{env:c,dynamic_env:f,use_dynamic:o,error:s}),function(e){a.push(e);return t(r.cdr)})}(e.cdr)}else{return e.cdr}}else{return P(e.cdr.car,{env:c,dynamic_env:f,error:s})}}else{return e.cdr}}return l(e,function(e){return v(e,t,r)})}else if(ra(e)){return p(e,t,r)}else if(e instanceof Array){return h(e,t,r)}return e}function n(e){if(e instanceof M){delete e[uo];if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}}if(ra(e.car)&&!r(Object.values(e.car))){return ds(e.car)}if(Array.isArray(e.car)&&!r(e.car)){return ds(e.car)}if(e.car instanceof M&&!e.car.find("unquote")&&!e.car.find("unquote-splicing")&&!e.car.find("quasiquote")){return ds(e.car)}var i=v(e.car,0,1);return w(i,function(e){n(e);return ds(e)})},"(quasiquote list)\n\n Similar macro to `quote` but inside it you can use special expressions (unquote\n x) abbreviated to ,x that will evaluate x and insert its value verbatim or\n (unquote-splicing x) abbreviated to ,@x that will evaluate x and splice the value\n into the result. Best used with macros but it can be used outside."),clone:l("clone",function e(t){k("clone",t,"pair");return t.clone()},"(clone list)\n\n Function that returns a clone of the list, that does not share any pairs with the\n original, so the clone can be safely mutated without affecting the original."),append:l("append",function e(){var t;for(var r=arguments.length,n=new Array(r),i=0;iarray")(t).reverse();return I.get("array->list")(r)}else if(Array.isArray(t)){return t.reverse()}else{throw new Error(Ps("reverse",z(t),"array or pair"))}},"(reverse list)\n\n Function that reverses the list or array. If value is not a list\n or array it will error."),nth:l("nth",function e(t,r){k("nth",t,"number");k("nth",r,["array","pair"]);if(r instanceof M){var n=r;var i=0;while(iarray")(r).join(t)},"(join separator list)\n\n Function that returns a string by joining elements of the list using separator."),split:l("split",function e(t,r){k("split",t,["regex","string"]);k("split",r,"string");return I.get("array->list")(r.split(t))},"(split separator string)\n\n Function that creates a list by splitting string by separator which can\n be a string or regular expression."),replace:l("replace",function e(t,r,n){k("replace",t,["regex","string"]);k("replace",r,["string","function"]);k("replace",n,"string");return n.replace(t,r)},"(replace pattern replacement string)\n\n Function that changes pattern to replacement inside string. Pattern can be a\n string or regex and replacement can be function or string. See Javascript\n String.replace()."),match:l("match",function e(t,r){k("match",t,["regex","string"]);k("match",r,"string");var n=r.match(t);return n?I.get("array->list")(n):false},"(match pattern string)\n\n Function that returns a match object from JavaScript as a list or #f if\n no match."),search:l("search",function e(t,r){k("search",t,["regex","string"]);k("search",r,"string");return r.search(t)},"(search pattern string)\n\n Function that returns the first found index of the pattern inside a string."),repr:l("repr",function e(t,r){return da(t,r)},"(repr obj)\n\n Function that returns a LIPS code representation of the object as a string."),"escape-regex":l("escape-regex",function(e){k("escape-regex",e,"string");return Gi(e.valueOf())},"(escape-regex string)\n\n Function that returns a new string where all special operators used in regex,\n are escaped with backslashes so they can be used in the RegExp constructor\n to match a literal string."),env:l("env",function e(e){e=e||this.env;var t=Object.keys(e.__env__).map(L);var r;if(t.length){r=M.fromArray(t)}else{r=U}if(e.__parent__ instanceof F){return I.get("env").call(this,e.__parent__).append(r)}return r},"(env)\n (env obj)\n\n Function that returns a list of names (functions, macros and variables)\n that are bound in the current environment or one of its parents."),new:l("new",function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2&&arguments[2]!==undefined?arguments[2]:d.LITERAL;k("set-special!",e,"string",1);k("set-special!",t,"symbol",2);d.append(e.valueOf(),t,r)},'(set-special! symbol name [type])\n\n Add a special symbol to the list of transforming operators by the parser.\n e.g.: `(add-special! "#" \'x)` will allow to use `#(1 2 3)` and it will be\n transformed into (x (1 2 3)) so you can write x macro that will process\n the list. 3rd argument is optional, and it can be one of two values:\n lips.specials.LITERAL, which is the default behavior, or\n lips.specials.SPLICE which causes the value to be unpacked into the expression.\n This can be used for e.g. to make `#(1 2 3)` into (x 1 2 3) that is needed\n by # that defines vectors.'),get:ys,".":ys,unbind:l(Ga,"(unbind fn)\n\n Function that removes the weak 'this' binding from a function so you\n can get properties from the actual function object."),type:l(z,"(type object)\n\n Function that returns the type of an object as string."),debugger:l("debugger",function(){debugger},'(debugger)\n\n Function that triggers the JavaScript debugger (e.g. the browser devtools)\n using the "debugger;" statement. If a debugger is not running this\n function does nothing.'),in:l("in",function(e,t){if(e instanceof L||e instanceof D||e instanceof j){e=e.valueOf()}return e in Ha(t)},'(in key value)\n\n Function that uses the Javascript "in" operator to check if key is\n a valid property in the value.'),"instance?":l("instance?",function(e){return za(e)},"(instance? obj)\n\n Checks if object is an instance, created with a new operator"),instanceof:l("instanceof",function(e,t){return t instanceof Ga(e)},"(instanceof type obj)\n\n Predicate that tests if the obj is an instance of type."),"prototype?":l("prototype?",va,"(prototype? obj)\n\n Predicate that tests if value is a valid JavaScript prototype,\n i.e. calling (new) with it will not throw ' is not a constructor'."),"macro?":l("macro?",function(e){return e instanceof q},"(macro? expression)\n\n Predicate that tests if value is a macro."),"function?":l("function?",m,"(function? expression)\n\n Predicate that tests if value is a callable function."),"real?":l("real?",function(e){if(z(e)!=="number"){return false}if(e instanceof j){return e.isFloat()}return j.isFloat(e)},"(real? number)\n\n Predicate that tests if value is a real number (not complex)."),"number?":l("number?",function(e){return Number.isNaN(e)||j.isNumber(e)},"(number? expression)\n\n Predicate that tests if value is a number or NaN value."),"string?":l("string?",function(e){return D.isString(e)},"(string? expression)\n\n Predicate that tests if value is a string."),"pair?":l("pair?",function(e){return e instanceof M},"(pair? expression)\n\n Predicate that tests if value is a pair or list structure."),"regex?":l("regex?",function(e){return e instanceof RegExp},"(regex? expression)\n\n Predicate that tests if value is a regular expression."),"null?":l("null?",function(e){return ja(e)},"(null? expression)\n\n Predicate that tests if value is null-ish (i.e. undefined, nil, or\n Javascript null)."),"boolean?":l("boolean?",function(e){return typeof e==="boolean"},"(boolean? expression)\n\n Predicate that tests if value is a boolean (#t or #f)."),"symbol?":l("symbol?",function(e){return e instanceof L},"(symbol? expression)\n\n Predicate that tests if value is a LIPS symbol."),"array?":l("array?",function(e){return e instanceof Array},"(array? expression)\n\n Predicate that tests if value is an array."),"object?":l("object?",function(e){return e!==U&&e!==null&&!(e instanceof h)&&!(e instanceof RegExp)&&!(e instanceof D)&&!(e instanceof M)&&!(e instanceof j)&&p(e)==="object"&&!(e instanceof Array)},"(object? expression)\n\n Predicate that tests if value is an plain object (not another LIPS type)."),flatten:l("flatten",function e(t){k("flatten",t,"pair");return t.flatten()},"(flatten list)\n\n Returns a shallow list from tree structure (pairs)."),"array->list":l("array->list",function(e){k("array->list",e,"array");return M.fromArray(e)},"(array->list array)\n\n Function that converts a JavaScript array to a LIPS cons list."),"tree->array":l("tree->array",ea("tree->array",true),"(tree->array list)\n\n Function that converts a LIPS cons tree structure into a JavaScript array."),"list->array":l("list->array",ea("list->array"),"(list->array list)\n\n Function that converts a LIPS list into a JavaScript array."),apply:l("apply",function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;iarray").call(this,u));return t.apply(this,Ys(t,n))},"(apply fn list)\n\n Function that calls fn with the list of arguments."),length:l("length",function e(t){if(!t||t===U){return 0}if(t instanceof M){return t.length()}if("length"in t){return t.length}},'(length expression)\n\n Function that returns the length of the object. The object can be a LIPS\n list or any object that has a "length" property. Returns undefined if the\n length could not be found.'),"string->number":l("string->number",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;k("string->number",e,"string",1);k("string->number",t,"number",2);e=e.valueOf();t=t.valueOf();if(e.match(ji)||e.match(Oi)){return Ti(e,t)}else if(e.match(Ii)||e.match(Ci)){return Mi(e,t)}else{var r=t===10&&!e.match(/e/i)||t===16;if(e.match(Bi)&&r||e.match(Si)){return Li(e,t)}if(e.match(mi)){return Vi(e)}}return false},"(string->number number [radix])\n\n Function that parses a string into a number."),try:l(new q("try",function(r,e){var l=this;var h=e.use_dynamic;e.error;return new Promise(function(t,o){var s,n;if(L.is(r.cdr.car.car,"catch")){s=r.cdr.car;if(r.cdr.cdr instanceof M&&L.is(r.cdr.cdr.car.car,"finally")){n=r.cdr.cdr.car}}else if(L.is(r.cdr.car.car,"finally")){n=r.cdr.car}if(!(n||s)){throw new Error("try: invalid syntax")}function c(e){t(e);throw new hs("[CATCH]")}var f=function e(t,r){r(t)};if(n){f=function e(t,r){f=o;i.error=function(e){throw e};w(P(new M(new L("begin"),n.cdr),i),function(){r(t)})}}var i={env:l,use_dynamic:h,dynamic_env:l,error:function e(t){if(t instanceof hs){throw t}var r=l.inherit("try");if(s){var n=s.cdr.car.car;if(!(n instanceof L)){throw new Error("try: invalid syntax: catch require variable name")}r.set(n,t);var i;var u={env:r,use_dynamic:h,dynamic_env:l,error:function e(t){i=true;o(t);throw new hs("[CATCH]")}};var a=P(new M(new L("begin"),s.cdr.cdr),u);w(a,function e(t){if(!i){f(t,c)}})}else{f(undefined,function(){throw t})}}};var e=P(r.car,i);w(e,function(e){f(e,t)},i.error)})}),"(try expr (catch (e) code))\n (try expr (catch (e) code) (finally code))\n (try expr (finally code))\n\n Macro that executes expr and catches any exceptions thrown. If catch is provided\n it's executed when an error is thrown. If finally is provided it's always\n executed at the end."),raise:l("raise",function(e){throw e},"(raise obj)\n\n Throws the object verbatim (no wrapping an a new Error)."),throw:l("throw",function(e){throw new Error(e)},"(throw string)\n\n Throws a new exception."),find:l("find",function t(r,n){k("find",r,["regex","function"]);k("find",n,["pair","nil"]);if(ja(n)){return U}var e=Cu("find",r);return w(e(n.car),function(e){if(e&&e!==U){return n.car}return t(r,n.cdr)})},"(find fn list)\n (find regex list)\n\n Higher-order function that finds the first value for which fn return true.\n If called with a regex it will create a matcher function."),"for-each":l("for-each",function(e){var t;k("for-each",e,"function");for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i1?t-1:0),u=1;u3?n-3:0),u=3;u3?i-3:0),a=3;aarray")(r);var u=[];var a=Cu("filter",t);return function t(r){function e(e){if(e&&e!==U){u.push(n)}return t(++r)}if(r===i.length){return M.fromArray(u)}var n=i[r];return w(a(n),e)}(0)},"(filter fn list)\n (filter regex list)\n\n Higher-order function that calls `fn` for each element of the list\n and return a new list for only those elements for which fn returns\n a truthy value. If called with a regex it will create a matcher function."),compose:l(xo,"(compose . fns)\n\n Higher-order function that creates a new function that applies all functions\n from right to left and returns the last value. Reverse of pipe.\n e.g.:\n ((compose (curry + 2) (curry * 3)) 10) --\x3e (+ 2 (* 3 10)) --\x3e 32"),pipe:l(Ao,"(pipe . fns)\n\n Higher-order function that creates a new function that applies all functions\n from left to right and returns the last value. Reverse of compose.\n e.g.:\n ((pipe (curry + 2) (curry * 3)) 10) --\x3e (* 3 (+ 2 10)) --\x3e 36"),curry:l(Bo,"(curry fn . args)\n\n Higher-order function that creates a curried version of the function.\n The result function will have partially applied arguments and it\n will keep returning one-argument functions until all arguments are provided,\n then it calls the original function with the accumulated arguments.\n\n e.g.:\n (define (add a b c d) (+ a b c d))\n (define add1 (curry add 1))\n (define add12 (add 2))\n (display (add12 3 4))"),gcd:l("gcd",function e(){for(var t=arguments.length,r=new Array(t),n=0;no?u%=o:o%=u}u=ma(s*r[a])/(u+o)}return j(u)},"(lcm n1 n2 ...)\n\n Function that returns the least common multiple of the arguments."),"odd?":l("odd?",Co(function(e){return j(e).isOdd()}),"(odd? number)\n\n Checks if number is odd."),"even?":l("even?",Co(function(e){return j(e).isEven()}),"(even? number)\n\n Checks if number is even."),"*":l("*",So(function(e,t){return j(e).mul(t)},j(1)),"(* . numbers)\n\n Multiplies all numbers passed as arguments. If single value is passed\n it will return that value."),"+":l("+",So(function(e,t){return j(e).add(t)},j(0)),"(+ . numbers)\n\n Sums all numbers passed as arguments. If single value is passed it will\n return that value."),"-":l("-",function(){for(var e=arguments.length,t=new Array(e),r=0;r":l(">",function(){for(var e=arguments.length,t=new Array(e),r=0;r",t,["bigint","float","rational"]);return ga(function(e,t){return j(e).cmp(t)===1},t)},"(> x1 x2 x3 ...)\n\n Function that compares its numerical arguments and checks if they are\n monotonically decreasing, i.e. x1 > x2 and x2 > x3 and so on."),"<":l("<",function(){for(var e=arguments.length,t=new Array(e),r=0;r=":l(">=",function(){for(var e=arguments.length,t=new Array(e),r=0;r=",t,["bigint","float","rational"]);return ga(function(e,t){return[0,1].includes(j(e).cmp(t))},t)},"(>= x1 x2 ...)\n\n Function that compares its numerical arguments and checks if they are\n monotonically nonincreasing, i.e. x1 >= x2 and x2 >= x3 and so on."),"eq?":l("eq?",ba,"(eq? a b)\n\n Function that compares two values if they are identical."),or:l(new q("or",function(e,t){var i=t.use_dynamic,u=t.error;var a=I.get("list->array")(e);var o=this;var s=o;if(!a.length){return false}var c;return function t(){function e(e){c=e;if(c!==false){return c}else{return t()}}if(!a.length){if(c!==false){return c}else{return false}}else{var r=a.shift();var n=P(r,{env:o,dynamic_env:s,use_dynamic:i,error:u});return w(n,e)}}()}),"(or . expressions)\n\n Macro that executes the values one by one and returns the first that is\n a truthy value. If there are no expressions that evaluate to true it\n returns false."),and:l(new q("and",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=I.get("list->array")(e);var u=this;var a=u;if(!i.length){return true}var o;var s={env:u,dynamic_env:a,use_dynamic:r,error:n};return function t(){function e(e){o=e;if(o===false){return false}else{return t()}}if(!i.length){if(o!==false){return o}else{return false}}else{var r=i.shift();return w(P(r,s),e)}}()}),"(and . expressions)\n\n Macro that evaluates each expression in sequence and if any value returns false\n it will stop and return false. If each value returns true it will return the\n last value. If it's called without arguments it will return true."),"|":l("|",function(e,t){return j(e).or(t)},"(| a b)\n\n Function that calculates the bitwise or operation."),"&":l("&",function(e,t){return j(e).and(t)},"(& a b)\n\n Function that calculates the bitwise and operation."),"~":l("~",function(e){return j(e).neg()},"(~ number)\n\n Function that calculates the bitwise inverse (flip all the bits)."),">>":l(">>",function(e,t){return j(e).shr(t)},"(>> a b)\n\n Function that right shifts the value a by value b bits."),"<<":l("<<",function(e,t){return j(e).shl(t)},"(<< a b)\n\n Function that left shifts the value a by value b bits."),not:l("not",function e(t){if(ja(t)){return true}return!t},"(not object)\n\n Function that returns the Boolean negation of its argument.")},undefined,"global");var Es=I.inherit("user-env");function As(e,t){e.constant("**internal-env**",t);e.doc("**internal-env**","**internal-env**\n\n Constant used to hide stdin, stdout and stderr so they don't interfere\n with variables with the same name. Constants are an internal type\n of variable that can't be redefined, defining a variable with the same name\n will throw an error.");I.set("**interaction-environment**",e)}As(Es,bs);I.doc("**interaction-environment**","**interaction-environment**\n\n Internal dynamic, global variable used to find interpreter environment.\n It's used so the read and write functions can locate **internal-env**\n that contains the references to stdin, stdout and stderr.");function xs(e){Es.get("**internal-env**").set("fs",e)}(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(t){var r=e[t]?e[t]:t;I.set(r,l(r,function(e){k(r,e,"number");if(e instanceof j){return e[t]()}},"(".concat(r," number)\n\n Function that calculates the ").concat(r," of a number.")))})})();function Fs(e){if(e.length===1){return e[0]}else{var t=[];var r=Fs(e.slice(1));for(var n=0;n3&&arguments[3]!==undefined?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(n!==null){i+=" (argument ".concat(n,")")}if(m(r)){return"Invalid type: got ".concat(t).concat(i)}if(r instanceof Array){if(r.length===1){var u=r[0].toLowerCase();r="a"+("aeiou".includes(u)?"n ":" ")+r[0]}else{r=new Intl.ListFormat("en",{style:"long",type:"disjunction"}).format(r)}}return"Expecting ".concat(r," got ").concat(t).concat(i)}function Ns(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;k(e,t,"number",n);var i=t.__type__;var u;if(r instanceof M){r=r.to_array()}if(r instanceof Array){r=r.map(function(e){return e.valueOf()})}if(r instanceof Array){r=r.map(function(e){return e.valueOf().toLowerCase()});if(r.includes(i)){u=true}}else{r=r.valueOf().toLowerCase()}if(!u&&i!==r){throw new Error(Ps(e,i,r,n))}}function Rs(r,e,n){e.forEach(function(e,t){Ns(r,e,n,t+1)})}function Ts(r,e,n){e.forEach(function(e,t){k(r,e,n,t+1)})}function Ls(e,t,r){k(e,t,r);if(t.__type__===as){throw new Error(Ps(e,"binary-port","textual-port"))}}function k(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;e=e.valueOf();var i=z(t).toLowerCase();if(m(r)){if(!r(t)){throw new Error(Ps(e,i,r,n))}return}var u=false;if(r instanceof M){r=r.to_array()}if(r instanceof Array){r=r.map(function(e){return e.valueOf()})}if(r instanceof Array){r=r.map(function(e){return e.valueOf().toLowerCase()});if(r.includes(i)){u=true}}else{r=r.valueOf().toLowerCase()}if(!u&&i!==r){throw new Error(Ps(e,i,r,n))}}function Us(r){var n=new WeakMap;return function(e){var t=n.get(e);if(!t){t=r(e)}return t}}z=Us(z);function z(e){var t=ni.get(e);if(t){return t}if(p(e)==="object"){for(var r=0,n=Object.entries(ri);r2&&arguments[2]!==undefined?arguments[2]:{},n=r.env,i=r.dynamic_env,u=r.use_dynamic;var a=n===null||n===void 0?void 0:n.new_frame(e,t);var o=i===null||i===void 0?void 0:i.new_frame(e,t);var s=new Ws({env:a,use_dynamic:u,dynamic_env:o});return Ms(e.apply(s,t))}function Js(n,e){var t=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},i=t.env,u=t.dynamic_env,a=t.use_dynamic,r=t.error,o=r===void 0?function(){}:r;e=qs(e,{env:i,dynamic_env:u,error:o,use_dynamic:a});return w(e,function(e){if(go(n)){n=Ga(n)}e=Ys(n,e);var t=e.slice();var r=$s(n,t,{env:i,dynamic_env:u,use_dynamic:a});return w(r,function(e){if(e instanceof M){e.markCycles();return ds(e)}return Ja(e)},o)})}var Ks=new WeakMap;var Hs=function(){function n(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;oe(this,n);he(this,"__value__",void 0);he(this,"__fn__",void 0);$n(this,Ks,{writable:true,value:void 0});this.__value__=e;if(t){if(!m(t)){throw new Error("Section argument to Parameter need to be function "+"".concat(z(t)," given"))}this.__fn__=t}if(r){N(this,Ks,r)}}le(n,[{key:"__name__",get:function e(){return t(this,Ks)},set:function e(t){N(this,Ks,t);if(this.__fn__){this.__fn__.__name__="fn-".concat(t)}}},{key:"invoke",value:function e(){if(m(this.__fn__)){return this.__fn__(this.__value__)}return this.__value__}},{key:"inherit",value:function e(t){return new n(t,this.__fn__,this.__name__)}}]);return n}();var Ws=function(){function t(e){oe(this,t);he(this,"env",void 0);he(this,"dynamic_env",void 0);he(this,"use_dynamic",void 0);Object.assign(this,e)}le(t,[{key:"__name__",get:function e(){return this.env.__name__}},{key:"__parent__",get:function e(){return this.env.__parent__}},{key:"get",value:function e(){var t;return(t=this.env).get.apply(t,arguments)}}]);return t}();function Gs(e,t){var r=e.get(t.__name__,{throwError:false});if(Na(r)&&r!==t){return r}var n=Es.get("**interaction-environment**");while(true){var i=e.get("parent.frame",{throwError:false});e=i(0);if(e===n){break}r=e.get(t.__name__,{throwError:false});if(Na(r)&&r!==t){return r}}return t}var Qs=function(){function t(e){oe(this,t);he(this,"__value__",void 0);this.__value__=e}le(t,[{key:"invoke",value:function e(){if(this.__value__===null){throw new Error("Continuations are not implemented yet")}}}]);return t}();function P(o){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},s=e.env,c=e.dynamic_env,f=e.use_dynamic,t=e.error,l=t===void 0?Bs:t,r=_e(e,Yn);return function(e){try{if(!Ta(c)){c=s===true?Es:s||Es}if(f){s=c}else if(s===true){s=Es}else{s=s||I}var t={env:s,dynamic_env:c,use_dynamic:f,error:l};var r;if(ja(o)){return o}if(o instanceof L){return s.get(o)}if(!(o instanceof M)){return o}var n=o.car;var e=o.cdr;if(n instanceof M){r=Ms(P(n,t));if(Ua(r)){return r.then(function(e){if(!La(e)){throw new Error(z(e)+" "+s.get("repr")(e)+" is not callable while evaluating "+o.toString())}return P(new M(e,o.cdr),t)})}else if(!La(r)){throw new Error(z(r)+" "+s.get("repr")(r)+" is not callable while evaluating "+o.toString())}}if(n instanceof L){r=s.get(n)}else if(m(n)){r=n}var i;if(r instanceof ka){i=zs(r,o,t)}else if(r instanceof q){i=Vs(r,e,t)}else if(m(r)){i=Js(r,e,t)}else if(Na(r)){var u=Gs(c,r);if(ja(o.cdr)){i=u.invoke()}else{return w(P(o.cdr.car,t),function(e){u.__value__=e})}}else if(Ia(r)){i=r.invoke()}else if(o instanceof M){r=n&&n.toString();throw new Error("".concat(z(n)," ").concat(r," is not a function"))}else{return o}var a=s.get(Symbol["for"]("__promise__"),{throwError:false});if(a===true&&Ua(i)){i=i.then(function(e){if(e instanceof M&&!r[uo]){return P(e,t)}return e});return new cu(i)}return i}catch(e){l&&l.call(s,e,o)}}(r)}var Zs=ec(function(e){return e});var Xs=ec(function(e,t){return t});function ec(d){return function(){var t=ae(function(l){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},h=e.env,p=e.dynamic_env,_=e.use_dynamic;return C.mark(function e(){var r,n,i,u,a,o,s,c,f;return C.wrap(function e(t){while(1)switch(t.prev=t.next){case 0:if(!Ta(p)){p=h===true?Es:h||Es}if(h===true){h=Es}else{h=h||Es}r=[];n=Array.isArray(l)?l:Du(l);i=false;u=false;t.prev=6;o=Xn(n);case 8:t.next=10;return o.next();case 10:if(!(i=!(s=t.sent).done)){t.next=24;break}c=s.value;f=P(c,{env:h,dynamic_env:p,use_dynamic:_,error:function e(t,r){if(t&&t.message){if(t.message.match(/^Error:/)){var n=/^(Error:)\s*([^:]+:\s*)/;t.message=t.message.replace(n,"$1 $2")}if(r){if(!(t.__code__ instanceof Array)){t.__code__=[]}t.__code__.push(r.toString(true))}}if(!(t instanceof hs)){throw t}}});t.t0=r;t.t1=d;t.t2=c;t.next=18;return f;case 18:t.t3=t.sent;t.t4=(0,t.t1)(t.t2,t.t3);t.t0.push.call(t.t0,t.t4);case 21:i=false;t.next=8;break;case 24:t.next=30;break;case 26:t.prev=26;t.t5=t["catch"](6);u=true;a=t.t5;case 30:t.prev=30;t.prev=31;if(!(i&&o["return"]!=null)){t.next=35;break}t.next=35;return o["return"]();case 35:t.prev=35;if(!u){t.next=38;break}throw a;case 38:return t.finish(35);case 39:return t.finish(30);case 40:return t.abrupt("return",r);case 41:case"end":return t.stop()}},e,null,[[6,26,30,40],[31,,35,39]])})()});function e(e){return t.apply(this,arguments)}return e}()}function tc(e){var t={"[":"]","(":")"};var r;if(typeof e==="string"){r=nu(e)}else{r=e.map(function(e){return e&&e.token?e.token:e})}var n=Object.keys(t);var i=Object.values(t).concat(n);r=r.filter(function(e){return i.includes(e)});var u=new Qi;var a=Wn(r),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;if(n.includes(s)){u.push(s)}else if(!u.is_empty()){var c=u.top();var f=t[c];if(s===f){u.pop()}else{throw new Error("Syntax error: missing closing ".concat(f))}}else{throw new Error("Syntax error: not matched closing ".concat(s))}}}catch(e){a.e(e)}finally{a.f()}return u.is_empty()}function rc(e){var t="("+e.toString()+")()";var r=window.URL||window.webkitURL;var n;try{n=new Blob([t],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;n=new i;n.append(t);n=n.getBlob()}return new ti.Worker(r.createObjectURL(n))}function nc(){return Pc.version.match(/^(\{\{VER\}\}|DEV)$/)}function ic(){if(Ss()){return}var e;if(document.currentScript){e=document.currentScript}else{var t=document.querySelectorAll("script");if(!t.length){return}e=t[t.length-1]}var r=e.getAttribute("src");return r}var uc=ic();function ac(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var t="dist/std.xcb";if(e===""){if(uc){e=uc.replace(/[^/]*$/,"std.xcb")}else if(nc()){e="https://cdn.jsdelivr.net/gh/jcubic/lips@devel/".concat(t)}else{e="https://cdn.jsdelivr.net/npm/@jcubic/lips@".concat(Pc.version,"/").concat(t)}}var r=I.get("load");return r.call(Es,e,I)}function oc(e){this.url=e;var a=this.worker=rc(function(){var a;var o;self.addEventListener("message",function(e){var r=e.data;var t=r.id;if(r.type!=="RPC"||t===null){return}function n(e){self.postMessage({id:t,type:"RPC",result:e})}function i(e){self.postMessage({id:t,type:"RPC",error:e})}if(r.method==="eval"){if(!o){i("Worker RPC: LIPS not initialized, call init first");return}o.then(function(){var e=r.params[0];var t=r.params[1];a.exec(e,{use_dynamic:t}).then(function(e){e=e.map(function(e){return e&&e.valueOf()});n(e)})["catch"](function(e){i(e)})})}else if(r.method==="init"){var u=r.params[0];if(typeof u!=="string"){i("Worker RPC: url is not a string")}else{importScripts("".concat(u,"/dist/lips.min.js"));a=new Pc.Interpreter("worker");o=ac(u);o.then(function(){n(true)})}}})});this.rpc=function(){var n=0;return function e(t,r){var u=++n;return new Promise(function(n,i){a.addEventListener("message",function e(t){var r=t.data;if(r&&r.type==="RPC"&&r.id===u){if(r.error){i(r.error)}else{n(r.result)}a.removeEventListener("message",e)}});a.postMessage({type:"RPC",method:t,id:u,params:r})})}}();this.rpc("init",[e])["catch"](function(e){console.error(e)});this.exec=function(e,t){var r=t.use_dynamic,n=r===void 0?false:r;return this.rpc("eval",[e,n])}}var sc={pair:function e(t){var r=b(t,2),n=r[0],i=r[1];return M(n,i)},number:function e(t){if(D.isString(t)){return j([t,10])}return j(t)},regex:function e(t){var r=b(t,2),n=r[0],i=r[1];return new RegExp(n,i)},nil:function e(){return U},symbol:function e(t){if(D.isString(t)){return L(t)}else if(Array.isArray(t)){return L(Symbol["for"](t[0]))}},string:D,character:h};var cc=Object.keys(sc);var fc={};for(var lc=0,hc=Object.entries(cc);lc1){var n=t.reduce(function(e,t){return e+t.length},0);var i=new Uint8Array(n);var u=0;t.forEach(function(e){i.set(e,u);u+=e.length});return i}else if(t.length){return t[0]}}function Dc(){var e=1;var t=new TextEncoder("utf-8");return t.encode("LIPS".concat(e.toString().padStart(3," ")))}var Ec=7;function Ac(e){var t=new TextDecoder("utf-8");var r=t.decode(e.slice(0,Ec));var n=r.substring(0,4);if(n==="LIPS"){var i=r.match(/^(....).*([0-9]+)$/);if(i){return{type:i[1],version:Number(i[2])}}}return{type:"unknown"}}function xc(e){var t=Dc();var r=bc.encode(e);return wc(t,Rn(r,{magic:false}))}function Fc(e){var t=Ac(e),r=t.type,n=t.version;if(r==="LIPS"&&n===1){var i=Tn(e.slice(Ec),{magic:false});return bc.decode(i)}else{throw new Error("Invalid file format ".concat(r))}}function kc(e){console.error(e.message||e);if(Array.isArray(e.code)){console.error(e.code.map(function(e,t){return"[".concat(t+1,"]: ").concat(e)}))}}function Cc(){var a=["text/x-lips","text/x-scheme"];var o;function s(r){return new Promise(function(t){var e=r.getAttribute("src");if(e){return fetch(e).then(function(e){return e.text()}).then(Xs).then(t)["catch"](function(e){kc(e);t()})}else{return Xs(r.innerHTML).then(t)["catch"](function(e){kc(e);t()})}})}function e(){return new Promise(function(i){var u=Array.from(document.querySelectorAll("script"));return function e(){var t=u.shift();if(!t){i()}else{var r=t.getAttribute("type");if(a.includes(r)){var n=t.getAttribute("bootstrap");if(!o&&typeof n==="string"){return ac(n).then(function(){return s(t)}).then(e)}else{return s(t).then(e)}}else if(r&&r.match(/lips|lisp/)){console.warn("Expecting "+a.join(" or ")+" found "+r)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(Oc){var t=Oc;var r=t.getAttribute("bootstrap");if(typeof r==="string"){return ac(r).then(function(){o=true;return e()})}}return e()}var Oc=typeof window!=="undefined"&&window.document&&document.currentScript;if(typeof window!=="undefined"){si(window,Cc)}var Sc=function(){var e=D("Wed, 24 Jan 2024 12:31:18 +0000").valueOf();var t=e==="{{"+"DATE}}"?new Date:new Date(e);var r=function e(t){return t.toString().padStart(2,"0")};var n=t.getFullYear();var i=[n,r(t.getMonth()+1),r(t.getDate())].join("-");var u="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(n," Jakub T. Jankiewicz\n\nType (env) to see environment with functions macros and variables. You can also\nuse (help name) to display help for specific function or macro, (apropos name)\nto display list of matched names in environment and (dir object) to list\nproperties of an object.\n").replace(/^.*\n/,"");return u}();f(Pu,"__class__","ahead");f(M,"__class__","pair");f(Xu,"__class__","nil");f(Nu,"__class__","pattern");f(Iu,"__class__","formatter");f(q,"__class__","macro");f(ka,"__class__","syntax");f(F,"__class__","environment");f(Wo,"__class__","input-port");f(Go,"__class__","output-port");f(Qo,"__class__","output-port");f(Zo,"__class__","output-string-port");f(es,"__class__","input-string-port");f(ns,"__class__","input-file-port");f(Xo,"__class__","output-file-port");f(ls,"__class__","lips-error");[j,g,A,E,x].forEach(function(e){f(e,"__class__","number")});f(h,"__class__","character");f(L,"__class__","symbol");f(D,"__class__","string");f(cu,"__class__","promise");f(Hs,"__class__","parameter");var Bc="DEV";var jc="Wed, 24 Jan 2024 12:31:18 +0000";var Ic=xo(Fu,Du);var Pc={version:Bc,banner:Sc,date:jc,exec:Xs,parse:Ic,tokenize:nu,evaluate:P,compile:Zs,serialize:mc,unserialize:gc,serialize_bin:xc,unserialize_bin:Fc,bootstrap:ac,Environment:F,env:Es,Worker:oc,Interpreter:fs,balanced_parenthesis:tc,balancedParenthesis:tc,balanced:tc,Macro:q,Syntax:ka,Pair:M,Values:_s,QuotedPromise:cu,Error:ls,quote:ds,InputPort:Wo,OutputPort:Go,BufferedOutputPort:Qo,InputFilePort:ns,OutputFilePort:Xo,InputStringPort:es,OutputStringPort:Zo,InputByteVectorPort:ts,OutputByteVectorPort:rs,InputBinaryFilePort:is,OutputBinaryFilePort:us,set_fs:xs,Formatter:Iu,Parser:bu,Lexer:s,specials:d,repr:ta,nil:U,eof:ss,LSymbol:L,LNumber:j,LFloat:E,LComplex:g,LRational:A,LBigInteger:x,LCharacter:h,LString:D,Parameter:Hs,rationalize:Ko};I.set("lips",Pc);var Nc={};var Rc=Object.freeze({__proto__:null,default:Nc});function Tc(e,t){var r=0;for(var n=e.length-1;n>=0;n--){var i=e[n];if(i==="."){e.splice(n,1)}else if(i===".."){e.splice(n,1);r++}else if(r){e.splice(n,1);r--}}if(t){for(;r--;r){e.unshift("..")}}return e}var Lc=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var Uc=function(e){return Lc.exec(e).slice(1)};function Mc(){var e="",t=false;for(var r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if(typeof n!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!n){continue}e=n+"/"+e;t=n.charAt(0)==="/"}e=Tc(Qc(e.split("/"),function(e){return!!e}),!t).join("/");return(t?"/":"")+e||"."}function qc(e){var t=zc(e),r=Zc(e,-1)==="/";e=Tc(Qc(e.split("/"),function(e){return!!e}),!t).join("/");if(!e&&!t){e="."}if(e&&r){e+="/"}return(t?"/":"")+e}function zc(e){return e.charAt(0)==="/"}function Vc(){var e=Array.prototype.slice.call(arguments,0);return qc(Qc(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))}function Yc(e,t){e=Mc(e).substr(1);t=Mc(t).substr(1);function r(e){var t=0;for(;t=0;r--){if(e[r]!=="")break}if(t>r)return[];return e.slice(t,r-t+1)}var n=r(e.split("/"));var i=r(t.split("/"));var u=Math.min(n.length,i.length);var a=u;for(var o=0;o data (toString))) (reject err))))))))) (for-each (lambda (file) (let* ((expr (lips.parse (readFile file) env))) (set! result (--> result (concat expr))))) files)) (for-each (lambda (file) (let* ((text (--> (fetch file) (text))) (expr (lips.parse text env))) (set! result (--> result (concat expr))))) files)) (if (> result.length 0) (quasiquote (begin (unquote-splicing (vector->list result)))))))) (define-syntax syntax-error (syntax-rules () ((_ "step" arg ...) (join " " (vector->list (vector (repr arg) ...)))) ((_ message arg ...) (error (format "~a ~a" message (_ "step" arg ...)))))) (define-syntax cond-expand (syntax-rules (and or not else r7rs srfi-0 srfi-2 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower) ((cond-expand) (syntax-error "Unfulfilled cond-expand")) ((cond-expand (else body ...)) (begin body ...)) ((cond-expand ((and) body ...) more-clauses ...) (begin body ...)) ((cond-expand ((and req1 req2 ...) body ...) more-clauses ...) (cond-expand (req1 (cond-expand ((and req2 ...) body ...) more-clauses ...)) more-clauses ...)) ((cond-expand ((or) body ...) more-clauses ...) (cond-expand more-clauses ...)) ((cond-expand ((or req1 req2 ...) body ...) more-clauses ...) (cond-expand (req1 (begin body ...)) (else (cond-expand ((or req2 ...) body ...) more-clauses ...)))) ((cond-expand ((not req) body ...) more-clauses ...) (cond-expand (req (cond-expand more-clauses ...)) (else body ...))) ((cond-expand (r7rs body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-0 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-2 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-4 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-6 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-10 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-22 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-23 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-46 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-176 body ...) more-clauses ...) (begin body ...)) ((cond-expand (lips body ...) more-clauses ...) (begin body ...)) ((cond-expand (complex body ...) more-clauses ...) (begin body ...)) ((cond-expand (full-unicode body ...) more-clauses ...) (begin body ...)) ((cond-expand (ieee-float body ...) more-clauses ...) (begin body ...)) ((cond-expand (ratios body ...) more-clauses ...) (begin body ...)) ((cond-expand (exact-complex body ...) more-clauses ...) (begin body ...)) ((cond-expand (full-numeric-tower body ...) more-clauses ...) (begin body ...)))) diff --git a/dist/std.scm b/dist/std.scm index f1a658a94..7a66932e5 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -3742,10 +3742,10 @@ (let ((v (cadr var0))) (set-cdr! var0 (cddr var0)) v)) ... - (define warn - (let ((v (cdr var0))) - (set! var0 (car var0)) - v)))) + (define warn + (let ((v (cdr var0))) + (set! var0 (car var0)) + v)))) ((define-values var expr) (define var (call-with-values (lambda () expr) @@ -3753,7 +3753,7 @@ "(define-values (a b ...) expr) Evaluates expression expr and if it evaluates to result of values - then it will defined each value as variable like with define.") + then it will define each value as a variable like with define.") ;; ----------------------------------------------------------------------------- (define-macro (include . files) diff --git a/dist/std.xcb b/dist/std.xcb index 09a59264d7961c00ccf362fb29f716d7c389c467..3a80b682ec0e8f191074b7084e3c5ef7234c0ee0 100644 GIT binary patch delta 30981 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 delta 30968 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 diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 6e194e309..51e6e943f 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -474,10 +474,10 @@ (let ((v (cadr var0))) (set-cdr! var0 (cddr var0)) v)) ... - (define warn - (let ((v (cdr var0))) - (set! var0 (car var0)) - v)))) + (define warn + (let ((v (cdr var0))) + (set! var0 (car var0)) + v)))) ((define-values var expr) (define var (call-with-values (lambda () expr) @@ -485,7 +485,7 @@ "(define-values (a b ...) expr) Evaluates expression expr and if it evaluates to result of values - then it will defined each value as variable like with define.") + then it will define each value as a variable like with define.") ;; ----------------------------------------------------------------------------- (define-macro (include . files) diff --git a/src/lips.js b/src/lips.js index f3b4c63b5..b1d0fcdeb 100644 --- a/src/lips.js +++ b/src/lips.js @@ -3621,7 +3621,7 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol, scope = {}) { // if we have (x ... a b) we need to remove two from the end const list_len = pattern.cdr.cdr.length(); if (!is_pair(code)) { - throw new Error('syntax-rules: no matching syntax'); + return false; } let code_len = code.length(); let list = code; @@ -3691,8 +3691,15 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol, scope = {}) { ); } log({ IIIIII: bindings['...'].symbols[name].toString() }); - } else { + } else if (pattern.car instanceof LSymbol && + pattern.cdr instanceof Pair && + LSymbol.is(pattern.cdr.car, ellipsis_symbol)) { + // empty elipsis with rest (a b ... . d) #290 log('>> 8'); + bindings['...'].symbols[name] = null; + return traverse(pattern.cdr.cdr, code); + } else { + log('>> 9'); return false; //bindings['...'].symbols[name] = code; } @@ -3701,11 +3708,11 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol, scope = {}) { } else if (pattern.car instanceof Pair) { var names = [...pattern_names]; if (code === nil) { - log('>> 9'); + log('>> 10'); bindings['...'].lists.push(nil); return true; } - log('>> 10'); + log('>> 11'); let node = code; while (node instanceof Pair) { if (!traverse(pattern.car, node.car, names, true)) { @@ -3721,12 +3728,11 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol, scope = {}) { if (LSymbol.is(pattern, ellipsis_symbol)) { throw new Error('syntax: invalid usage of ellipsis'); } - log('>> 11'); + log('>> 12'); const name = pattern.__name__; if (symbols.includes(name)) { return true; } - log({ name, ellipsis }); if (ellipsis) { bindings['...'].symbols[name] = bindings['...'].symbols[name] || []; bindings['...'].symbols[name].push(code); @@ -3737,7 +3743,7 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol, scope = {}) { return true; } if (pattern instanceof Pair && code instanceof Pair) { - log('>> 12'); + log('>> 13'); log({ a: 12, code: code && code.toString(), @@ -3755,7 +3761,7 @@ function extract_patterns(pattern, code, symbols, ellipsis_symbol, scope = {}) { if (!traverse(pattern.car, code.car, pattern_names, ellipsis)) { return false; } - log('>> 12 | 1'); + log('>> 14'); let name = pattern.cdr.valueOf(); if (!(name in bindings.symbols)) { bindings.symbols[name] = nil; @@ -8161,6 +8167,7 @@ var global_env = new Environment({ var bindings = extract_patterns(rule, code, symbols, ellipsis, { expansion: this, define: env }); + log({bindings}); if (bindings) { /* c8 ignore next 5 */ if (is_debug()) { diff --git a/tests/std.scm b/tests/std.scm index 88b8e5087..ad2956a3a 100644 --- a/tests/std.scm +++ b/tests/std.scm @@ -296,3 +296,9 @@ (y kdr set-kdr!)) (t.is (kons 1 2) (kons 1 2)))) + +(test "std: define-values with dot" + (lambda (t) + (define-values (a . b) + (values 1 2)) + (t.is (cons a b) '(1 2)))) diff --git a/tests/syntax.scm b/tests/syntax.scm index 03c2764ff..521549d69 100644 --- a/tests/syntax.scm +++ b/tests/syntax.scm @@ -1187,3 +1187,12 @@ (define b 2))))) (foo x y) (t.is (list x y) '(1 2))))) + +(test "syntax: elipsis + improper list" + (lambda (t) + (define-syntax foo + (syntax-rules () + ((_ (foo bar ... . baz)) + '(foo baz)))) + + (t.is (foo (a . b)) '(a b))))