retirement-simulator
Version:
Retirement Simulator
1 lines • 95.4 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3")):"function"==typeof define&&define.amd?define(["exports","d3"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["retirement-simulator"]={},e.d3)}(this,(function(e,t){const r=Symbol.for("compare"),n=(e,t)=>{const s=typeof e,i=typeof t;if(s<i)return-1;if(i<s)return 1;switch(s){case"number":case"string":case"boolean":if(e<t)return-1;if(e>t)return 1;break;case"symbol":return n(e.description,t.description);case"object":if(!e&&t)return-1;if(!t&&e)return 1;if(t===e)return 0;if(e instanceof Date&&t instanceof Date)return n(e.getTime(),t.getTime());const s=e.constructor,i=t.constructor;if(s===i){return(s[r]??a)(e,t)}return n(s.name,i.name)}return 0},a=(e,t)=>0,s=(e,...t)=>{if(0===t.length)return e;const r=s(t[0],...t.slice(1));return(t,n)=>{const a=e(t,n);return 0===a?r(t,n):a}},i=e=>(t,r)=>n(t[e],r[e]),o=i("value"),l=i("rate"),c=i("name"),u=i("type"),h=i("start"),p=e=>(t,r)=>e(r,t),f={byValue:s(p(o),u,c),byRate:s(p(l),u,c),byName:s(c,u),byType:s(u,c),byStart:s(h,u,c),null:a,natural:n},m=(e=n)=>t=>[...t].sort(e),y=m(),d=e=>"function"==typeof e,g=e=>e&&(E(e)||N(e)),b=e=>e&&(O(e)||k(e)||N(e)),_=e=>e&&d(e.next)&&d(e.return)&&d(e.throw)&&d(e[Symbol.iterator]),v=e=>e&&d(e.next)&&d(e.return)&&d(e.throw)&&d(e[Symbol.asyncIterator]);function w(e){if(_(e))return e;if(E(e)){const t=e;return function*(){for(;;){const e=t.next();if(e.done)return e.value;yield e.value}}()}if(N(e))return w(e[Symbol.iterator]());throw new Error(`Not iterable: ${e}`)}function x(e){if(v(e))return e;if(O(e)){const t=e;return async function*(){for(;;){const e=await t.next();if(e.done)return e.value;yield e.value}}()}if(k(e))return x(e[Symbol.asyncIterator]());if(N(e))return x(e[Symbol.iterator]());throw new Error(`Not iterable: ${e}`)}function S(e){if(_(e))return e;if(E(e))return e;if(N(e))return e[Symbol.iterator]();throw new Error(`Not iterable: ${e}`)}function T(e){if(v(e))return e;if(k(e))return e[Symbol.asyncIterator]();if(N(e))return A(S(e));throw new Error(`Not iterable: ${e}`)}const A=e=>{const t=e;let r;return r=async function*(){let n,a=!1;try{for(;;){const e=await Promise.resolve(t.next());if(e.done)return a=!0,e.value;try{n=yield e.value}catch(e){throw await(t.throw?.(e)),e}}}finally{a||await(e.return?.(r.returning))}}()};function I(e){return N(e)?e:{[Symbol.iterator]:()=>e}}function M(e){return k(e)?e:N(e)?C(e):{[Symbol.asyncIterator]:()=>e}}async function*C(e){const t=e[Symbol.iterator]();let r;for(;;){const e=await t.next(r);if(e.done)return e.value;r=yield e.value}}const E=e=>e&&"function"==typeof e.next,O=e=>e&&"function"==typeof e.next,N=e=>e&&"function"==typeof e[Symbol.iterator],k=e=>e&&"function"==typeof e[Symbol.asyncIterator],U=(e,t)=>(...r)=>{try{return e(...r)}catch(e){return t?.(e)}};class ${returning;[Symbol.toStringTag];asArray(){return this._impl.asArray(this)}limit(e){return this._impl.limit(e,this)}forEach(e,t){this._impl.forEach(e,t,this)}map(e,t){return this._impl.map(e,t,this)}filter(e,t){return this._impl.filter(e,t,this)}flat(e=1){return this._impl.flat(e,this)}flatMap(e,t=1){return this._impl.flatMap(e,t,this)}slice(e=0,t=Number.POSITIVE_INFINITY){return this._impl.slice(e,t,this)}concat(...e){return this._impl.concat(this,...e)}reduce(e,t){return this._impl.reduce(e,t,this)}some(e,t){return this._impl.some(e,t,this)}every(e,t){return this._impl.every(e,t,this)}repeatLast(e=Number.POSITIVE_INFINITY){return this._impl.repeatLast(this,e)}repeat(e,t=Number.POSITIVE_INFINITY){const r=this._impl.repeat(e,t);return this._impl.concat(this,r)}zip(...e){return this._impl.zip(this,...e)}join(e){return this._impl.join(this,e)}sort(e){return this._impl.sort(e)(this)}}class F extends ${[Symbol.toStringTag]}const j=new class{of(...e){return this.enhance(e)}asArray(e){return[...I(e)]}limit(e,t){let r;function*n(t){let n,a=!1;try{for(let r=0;r<e;r++){const e=t.next(n);if(e.done)return e.value;try{n=yield e.value}catch(e){t.throw?.(e)}}a=!0;const s=new RangeError(`Generator produced excessive values > ${e}.`);throw t.throw?.(s),s}finally{a||t.return?.(r?.returning)}}return t?r=this.enhance(n(S(t))):e=>this.enhance(n(S(e)))}forEach(e,t,r){const n=(e,t,r)=>{const n=S(r);let a=0;for(;;){const r=n.next();if(r.done)return;e.call(t,r.value,a++)}};return r?n(e,t,r):g(t)?n(e,void 0,t):(r,a)=>n(e,a??t,r)}map(e,t,r){const n=(t,r)=>{const n=w(r);let a;return a=this.enhance(function*(){let r,s=0;for(;;)for(;;)try{for(;;){const a=n.next(r);if(a.done)return a.value;const i=e.call(t,a.value,s++);try{r=yield i}catch(e){n.throw(e)}}}finally{if(!n.return(a?.returning).done)break}}())};return r?n(t,r):g(t)?n(void 0,t):(e,r)=>n(r??t,e)}filter(e,t,r){const n=(t,r)=>{const n=w(r);let a;return a=this.enhance(function*(e){let r,s=0;for(;;)for(;;)try{for(;;){const a=n.next(r);if(a.done)return a.value;if(e.call(t,a.value,s++))try{r=yield a.value}catch(e){n.throw(e)}}}finally{const e=n.return?.(a?.returning);if(!e?.done)break}}(e))};return r?n(t,r):g(t)?n(void 0,t):(e,r)=>n(r??t,e)}flat(e,t){const r=(e,t)=>{let r;const n=new Set;return _(t)&&n.add(t),r=this.enhance(function*e(t,a){let s;for(;;)for(;;)try{for(;;){const r=t.next(s);if(r.done)return r.value;const i=r.value;_(i)&&n.add(i);try{a>0&&E(i)?yield*e(i,a-1):a>0&&N(i)?yield*e(S(i),a-1):s=yield r.value}catch(e){t.throw?.(e)}}}finally{const e=t.return?.(r?.returning);if(_(t)&&n.delete(t),e&&!e.done)break;for(const e of n)e.return(r?.returning)}}(S(t),e))};if("number"==typeof e){if(t){if(g(t))return r(e,t);throw new TypeError(`Invalid Genable: ${t}`)}return t=>r(e,t)}if(g(e))return r(t??1,e);throw new TypeError("Illegal arguments to flat()")}flatMap(e,t,r){const n=(t,r)=>{let n,a=0;return n=this.enhance(function*t(r,s){let i;for(;;)for(;;)try{for(;;){const n=r.next(i);if(n.done)return n.value;const o=e(n.value,a++);try{E(o)?s>1?yield*t(o,s-1):1===s?yield*w(o):yield o:N(o)?s>1?yield*t(S(o),s-1):1===s?yield*w(o):yield o:i=yield o}catch(e){r.throw?.(e)}}}finally{const e=r.return?.(n?.returning);if(e&&!e.done)break}}(S(r),t))};return g(r)?n(t??1,r):g(t)?n(1,t):(e,r)=>n(t??r??1,e)}slice(e,t,r){const n=r=>{const n=S(r);return this.enhance(function*(e,t){for(let t=0;t<e;t++){const e=n.next();if(e.done)return e.value}if(t===Number.POSITIVE_INFINITY)yield*I(n);else{let r;for(;;)try{for(let a=e;a<t;a++){const t=n.next(r);if(t.done)return t.value;try{r=yield t.value}catch(e){const t=n.throw?.(e);if(t){if(t.done)return t.value;r=yield t.value}}}}finally{const e=n.return?.();if(e&&!e.done)break}}}(e,t))};return r?n(r):n}concat(...e){let t;return t=this.enhance(function*(){let r=0;try{for(;r<e.length;r++)yield*I(e[r])}finally{for(;r<e.length;r++){const n=e[r];_(n)&&n.return(t?.returning)}}}())}reduce(e,t,r){const n=(t,r)=>{let n=t;if(void 0===n){const e=r.next();if(e.done)throw new TypeError("No initial value in reduce");n=e.value}for(;;){const t=r.next();if(t.done)return n;n=e(n,t.value)}};return g(r)?n(t,S(r)):g(t)?n(void 0,S(t)):(e,r)=>n(r??t,S(e))}some(e,t,r){const n=(t,r)=>{let n=0;for(;;){const a=r.next();if(a.done)return!1;if(e.call(t,a.value,n++))return!0}};return g(r)?n(t,S(r)):g(t)?n(void 0,S(t)):(e,r)=>n(r??t,S(e))}every(e,t,r){const n=(t,r)=>{let n=0;for(;;){const a=r.next();if(a.done)return!0;if(!e.call(t,a.value,n++))return!1}};if(g(r))return n(t,S(r));if(g(r))return(e,r)=>n(r??t,S(e));throw new Error(`Invalid argument to every: ${r??t}`)}repeatLast(e,t=Number.POSITIVE_INFINITY){const r=S(e);let n,a;return a=this.enhance(function*(){try{let e;for(;;){const t=r.next(n);if(t.done)break;try{n=yield e=t.value}catch(t){const n=r.throw?.(t);if(n){if(n.done)break;yield e=n.value}}}for(let r=0;r<t;r++)yield e}finally{r.return?.(a?.returning)}}())}repeat(e,t=Number.POSITIVE_INFINITY){return this.enhance(function*(){for(let r=0;r<t;r++)yield e}())}zip(...e){if(0===e.length)return this.enhance([]);const t=e.map(S);let r,n=!1;return r=this.enhance(function*(){try{for(;;){let r=[];for(const e of t){const t=e.next();if(t.done)return n=!0,t.value;r.push(t.value)}try{yield r}catch(t){for(const r of e)try{r.throw?.(t)}catch{}throw t}}}finally{if(!n)for(const t of e)try{t.return?.(r?.returning)}catch{}}}())}join(e,t){return"string"==typeof e?(t=e,e=>this.join(e,t)):[...I(e)].join(t)}merge(...e){let t,r=e.map(S);return t=this.enhance(function*(e){let r,n=!1,a=!0;try{for(;a;){a=!1;for(let t=0;t<e.length;t++){const n=e[t];if(n){const s=n.next(r);if(s.done)e[t]=null;else{a=!0;try{r=yield s.value}catch(t){e.forEach(U((e=>e?.throw?.(t))))}}}}}n=!0}finally{n||e.forEach(U((e=>e?.return?.(t?.returning))))}return t?.returning}(r))}sort(e){return(...t)=>this.merge(...t).asArray().sort(e)}enhance(e){const t=w(e),r=Object.getPrototypeOf(t),n=Object.create(F.prototype);return n.return=e=>(t.returning=e,r.return.call(t,e)),n[Symbol.iterator]=()=>t,Object.setPrototypeOf(t,n),t}};var P,R;(P||(P={})).Mixin=function(e){class t extends e{#e=void 0;constructor(...e){super(...e)}#t(){return j.enhance(this[Symbol.iterator]())}asArray(){return this.#t().asArray()}limit(e){return this.#t().limit(e)}forEach(e,t){return this.#t().forEach(e,t)}map(e,t){return this.#t().map(e,t)}filter(e,t){return this.#t().filter(e,t)}flat(e=1){return this.#t().flat(e)}flatMap(e,t=1){return this.#t().flatMap(e,t)}slice(e=0,t=Number.MAX_SAFE_INTEGER){return this.#t().slice(e,t)}concat(...e){return this.#t().concat(...e)}reduce(e,t){return this.#t().reduce(e,t)}some(e,t){return this.#t().some(e,t)}every(e,t){return this.#t().every(e,t)}repeatLast(e=Number.MAX_SAFE_INTEGER){return this.#t().repeatLast(e)}repeat(e,t=Number.MAX_SAFE_INTEGER){return this.#t().repeat(e,t)}join(e=""){return this.#t().join(e)}sort(e){return this.#t().sort(e)}get[Symbol.toStringTag](){try{return this.#e??(this.#e=`Sync.Mixin(${e.name})`)}catch{return`Sync.Mixin(${e.name}).prototype`}}}return t};class D{#r;constructor(e,t){this.#r=e.bind(this,...t)}[Symbol.iterator](){return j.enhance(w(this.#r()))}}class Y extends(P.Mixin(D)){constructor(e,t){super(e,t)}}(R||(R={})).wrap=(e,...t)=>new Y(e,t);const q=Object.getPrototypeOf(function*(){}());var L;Object.setPrototypeOf(F.prototype,(e=>{const t=Object.create(e);return(e=>{for(const r of Reflect.ownKeys(e))"constructor"!==r&&(t[r]=e[r])})($.prototype),t})(q)),Object.defineProperty(F.prototype,"_impl",{value:j,writable:!1,enumerable:!1,configurable:!1}),function(e){e.asArray=j.asArray.bind(j),e.concat=j.concat.bind(j),e.every=j.every.bind(j),e.filter=j.filter.bind(j),e.flat=j.flat.bind(j),e.flatMap=j.flatMap.bind(j),e.forEach=j.forEach.bind(j),e.join=j.join.bind(j),e.limit=j.limit.bind(j),e.map=j.map.bind(j),e.merge=j.merge.bind(j),e.of=j.of.bind(j),e.reduce=j.reduce.bind(j),e.repeat=j.repeat.bind(j),e.repeatLast=j.repeatLast.bind(j),e.slice=j.slice.bind(j),e.some=j.some.bind(j),e.sort=j.sort.bind(j),e.zip=j.zip.bind(j),e.enhance=j.enhance.bind(j),e.Mixin=P.Mixin,e.wrap=R.wrap}(L||(L={}));const z=(e=0,t=Number.MAX_SAFE_INTEGER,r=1)=>L.enhance(function*(e=0,t=Number.MAX_SAFE_INTEGER,r=1){let n=e;if(r>0)for(;n<t;)yield n,n+=r;else{if(!(r<0))throw new Error("Step must not be zero.");for(;n>t;)yield n,n+=r}}(e,t,r));function G(e,t){t=t||{},this._head=0,this._tail=0,this._capacity=t.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(e)&&this._fromArray(e)}G.prototype.peekAt=function(e){var t=e;if(t===(0|t)){var r=this.size();if(!(t>=r||t<-r))return t<0&&(t+=r),t=this._head+t&this._capacityMask,this._list[t]}},G.prototype.get=function(e){return this.peekAt(e)},G.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},G.prototype.peekFront=function(){return this.peek()},G.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(G.prototype,"length",{get:function(){return this.size()}}),G.prototype.size=function(){return this._head===this._tail?0:this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},G.prototype.unshift=function(e){if(0===arguments.length)return this.size();var t=this._list.length;return this._head=this._head-1+t&this._capacityMask,this._list[this._head]=e,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.pop(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},G.prototype.shift=function(){var e=this._head;if(e!==this._tail){var t=this._list[e];return this._list[e]=void 0,this._head=e+1&this._capacityMask,e<2&&this._tail>1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),t}},G.prototype.push=function(e){if(0===arguments.length)return this.size();var t=this._tail;return this._list[t]=e,this._tail=t+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},G.prototype.pop=function(){var e=this._tail;if(e!==this._head){var t=this._list.length;this._tail=e-1+t&this._capacityMask;var r=this._list[this._tail];return this._list[this._tail]=void 0,this._head<2&&e>1e4&&e<=t>>>2&&this._shrinkArray(),r}},G.prototype.removeOne=function(e){var t=e;if(t===(0|t)&&this._head!==this._tail){var r=this.size(),n=this._list.length;if(!(t>=r||t<-r)){t<0&&(t+=r),t=this._head+t&this._capacityMask;var a,s=this._list[t];if(e<r/2){for(a=e;a>0;a--)this._list[t]=this._list[t=t-1+n&this._capacityMask];this._list[t]=void 0,this._head=this._head+1+n&this._capacityMask}else{for(a=r-1-e;a>0;a--)this._list[t]=this._list[t=t+1+n&this._capacityMask];this._list[t]=void 0,this._tail=this._tail-1+n&this._capacityMask}return s}}},G.prototype.remove=function(e,t){var r,n=e,a=t;if(n===(0|n)&&this._head!==this._tail){var s=this.size(),i=this._list.length;if(!(n>=s||n<-s||t<1)){if(n<0&&(n+=s),1===t||!t)return(r=new Array(1))[0]=this.removeOne(n),r;if(0===n&&n+t>=s)return r=this.toArray(),this.clear(),r;var o;for(n+t>s&&(t=s-n),r=new Array(t),o=0;o<t;o++)r[o]=this._list[this._head+n+o&this._capacityMask];if(n=this._head+n&this._capacityMask,e+t===s){for(this._tail=this._tail-t+i&this._capacityMask,o=t;o>0;o--)this._list[n=n+1+i&this._capacityMask]=void 0;return r}if(0===e){for(this._head=this._head+t+i&this._capacityMask,o=t-1;o>0;o--)this._list[n=n+1+i&this._capacityMask]=void 0;return r}if(n<s/2){for(this._head=this._head+e+t+i&this._capacityMask,o=e;o>0;o--)this.unshift(this._list[n=n-1+i&this._capacityMask]);for(n=this._head-1+i&this._capacityMask;a>0;)this._list[n=n-1+i&this._capacityMask]=void 0,a--;e<0&&(this._tail=n)}else{for(this._tail=n,n=n+t+i&this._capacityMask,o=s-(t+e);o>0;o--)this.push(this._list[n++]);for(n=this._tail;a>0;)this._list[n=n+1+i&this._capacityMask]=void 0,a--}return this._head<2&&this._tail>1e4&&this._tail<=i>>>2&&this._shrinkArray(),r}}},G.prototype.splice=function(e,t){var r=e;if(r===(0|r)){var n=this.size();if(r<0&&(r+=n),!(r>n)){if(arguments.length>2){var a,s,i,o=arguments.length,l=this._list.length,c=2;if(!n||r<n/2){for(s=new Array(r),a=0;a<r;a++)s[a]=this._list[this._head+a&this._capacityMask];for(0===t?(i=[],r>0&&(this._head=this._head+r+l&this._capacityMask)):(i=this.remove(r,t),this._head=this._head+r+l&this._capacityMask);o>c;)this.unshift(arguments[--o]);for(a=r;a>0;a--)this.unshift(s[a-1])}else{var u=(s=new Array(n-(r+t))).length;for(a=0;a<u;a++)s[a]=this._list[this._head+r+t+a&this._capacityMask];for(0===t?(i=[],r!=n&&(this._tail=this._head+r+l&this._capacityMask)):(i=this.remove(r,t),this._tail=this._tail-u+l&this._capacityMask);c<o;)this.push(arguments[c++]);for(a=0;a<u;a++)this.push(s[a])}return i}return this.remove(r,t)}}},G.prototype.clear=function(){this._head=0,this._tail=0},G.prototype.isEmpty=function(){return this._head===this._tail},G.prototype.toArray=function(){return this._copyArray(!1)},G.prototype._fromArray=function(e){for(var t=0;t<e.length;t++)this.push(e[t])},G.prototype._copyArray=function(e){var t,r=[],n=this._list,a=n.length;if(e||this._head>this._tail){for(t=this._head;t<a;t++)r.push(n[t]);for(t=0;t<this._tail;t++)r.push(n[t])}else for(t=this._head;t<this._tail;t++)r.push(n[t]);return r},G.prototype._growArray=function(){this._head&&(this._list=this._copyArray(!0),this._head=0),this._tail=this._list.length,this._list.length<<=1,this._capacityMask=this._capacityMask<<1|1},G.prototype._shrinkArray=function(){this._list.length>>>=1,this._capacityMask>>>=1};var V=G;const B=Symbol.for("endTag"),H=e=>e instanceof Object&&"throw"===e[B];class K extends Promise{#r;#n;#a;#s;#i;#o;static[Symbol.toStringTag]="Future";static[Symbol.species]=Promise;constructor(e,t){let r,n;super(((e,t)=>{r=e,n=t})),this.#a=r,this.#s=n,this.#r=e,this.#n=!!t}eval(e,t){if(!this.#r){if(this.#o)throw this.#o;return this.#i}try{return this.#i=this.#r(),this.#a?.(this.#i),this.#i}catch(e){throw this.#o=e,this.#s?.(e),e}finally{this.#r=void 0,this.#a=void 0,this.#s=void 0,(e||t)&&super.then(e,t)}}then(e,t){if(this.#r&&!this.#n&&(e||t))try{this.eval()}catch(e){}return e||t?super.then(e,t):this}}class W extends ${}const X=new class{of(...e){return this.enhance(e)}async asArray(e){const t=T(e),r=[];for(;;){const e=await t.next();if(e.done)return r;r.push(e.value)}}limit(e,t){let r;async function*n(t){let n,a=!1;try{for(let r=0;r<e;r++){const e=await t.next(n);if(e.done)return e.value;try{n=yield e.value}catch(e){await(t.throw?.(e))}}a=!0;const s=new RangeError(`Generator produced excessive values > ${e}.`);throw await(t.throw?.(s)),s}finally{a||await(t.return?.(r?.returning))}}return t?r=this.enhance(n(T(t))):e=>this.enhance(n(T(e)))}forEach(e,t,r){const n=async(e,t,r)=>{const n=T(r);let a=0;for(;;){const r=await n.next();if(r.done)return;await e.call(t,r.value,a++)}};return r?n(e,t,r):b(t)?n(e,void 0,t):(r,a)=>n(e,a??t,r)}map(e,t,r){const n=(t,r)=>{const n=x(r);let a;return a=this.enhance(async function*(){let r,s=0;for(;;)for(;;)try{for(;;){const a=await n.next(r);if(a.done)return a.value;const i=await e.call(t,await a.value,s++);try{r=yield i}catch(e){await n.throw(e)}}}finally{if(!(await n.return(a?.returning)).done)break}}())};return r?n(t,r):b(t)?n(void 0,t):(e,r)=>n(r??t,e)}filter(e,t,r){const n=(t,r)=>{const n=x(r);let a;return a=this.enhance(async function*(e){let r,s=0;for(;;)for(;;)try{for(;;){const a=await n.next(r);if(a.done)return a.value;if(await e.call(t,a.value,s++))try{r=yield a.value}catch(e){await n.throw(e)}}}finally{if(!(await(n.return?.(a?.returning)))?.done)break}}(e))};return r?n(t,r):b(t)?n(void 0,t):(e,r)=>n(r??t,e)}flat(e,t){const r=(e,t)=>{let r;const n=new Set;return v(t)&&n.add(t),r=this.enhance(async function*e(t,a){let s;for(;;)for(;;)try{for(;;){const r=await t.next(s);if(r.done)return r.value;const i=r.value;v(i)&&n.add(i);try{a>0&&O(i)?yield*e(i,a-1):a>0&&(k(i)||N(i))?yield*e(T(i),a-1):s=yield r.value}catch(e){await(t.throw?.(e))}}}finally{const e=await(t.return?.(r?.returning));if(v(t)&&n.delete(t),e&&!e.done)break;for(const e of n)await e.return(r?.returning)}}(T(t),e))};if("number"==typeof e){if(t){if(b(t))return r(e,t);throw new TypeError(`Invalid Genable: ${t}`)}return t=>r(e,t)}if(b(e))return r(t??1,e);throw new TypeError("Illegal arguments to flat()")}flatMap(e,t,r){const n=(t,r)=>{let n,a=0;return n=this.enhance(async function*t(r,s){let i;for(;;)for(;;)try{for(;;){const n=await r.next(i);if(n.done)return n.value;const o=await e(n.value,a++);try{if(O(o))if(s>1)yield*t(o,s-1);else if(1===s){const e=T(o);yield*x(e)}else yield o;else k(o)||N(o)?s>1?yield*t(T(o),s-1):1===s?yield*x(o):yield o:i=yield o}catch(e){await(r.throw?.(e))}}}finally{const e=await(r.return?.(n?.returning));if(e&&!e.done)break}}(T(r),t))};return b(r)?n(t??1,r):b(t)?n(1,t):(e,r)=>n(t??r??1,e)}slice(e,t,r){const n=r=>{const n=T(r);return this.enhance(async function*(e,t){for(let t=0;t<e;t++){const e=await n.next();if(e.done)return e.value}if(t===Number.POSITIVE_INFINITY)yield*M(n);else{let r;for(;;)try{for(let a=e;a<t;a++){const t=await n.next(r);if(t.done)return t.value;try{r=yield t.value}catch(e){const t=await(n.throw?.(e));if(t){if(t.done)return t.value;r=yield t.value}}}}finally{const e=await(n.return?.());if(e&&!e.done)break}}}(e,t))};return r?n(r):n}concat(...e){let t;return t=this.enhance(async function*(){let r=0;try{for(;r<e.length;r++){const t=M(e[r]);yield*t}}finally{for(;r<e.length;r++){const n=e[r];v(n)&&await n.return(t?.returning)}}}())}reduce(e,t,r){const n=async(t,r)=>{let n=await t;if(void 0===n){const e=await r.next();if(e.done)throw new TypeError("No initial value in reduce");n=e.value}for(;;){const t=await r.next();if(t.done)return n;n=await e(n,t.value)}};return b(r)?n(t,T(r)):b(t)?n(void 0,T(t)):(e,r)=>n(r??t,T(e))}some(e,t,r){const n=async(t,r)=>{let n=0;for(;;){const a=await r.next();if(a.done)return!1;if(e.call(t,a.value,n++))return!0}};if(b(r))return n(t,T(r));if(b(r))return(e,r)=>n(r??t,T(e));throw new Error(`Invalid argument to some: ${r??t}`)}every(e,t,r){const n=async(t,r)=>{let n=0;for(;;){const a=await r.next();if(a.done)return!0;if(!e.call(t,a.value,n++))return!1}};if(b(r))return n(t,T(r));if(g(r))return(e,r)=>n(r??t,T(e));throw new Error(`Invalid argument to every: ${r??t}`)}repeatLast(e,t=Number.POSITIVE_INFINITY){const r=T(e);let n,a;return a=this.enhance(async function*(){try{let e;for(;;){const t=await r.next(n);if(t.done)break;try{n=yield e=t.value}catch(t){const n=await(r.throw?.(t));if(n){if(n.done)break;yield e=n.value}}}for(let r=0;r<t;r++)yield await e}finally{await(r.return?.(a?.returning))}}())}repeat(e,t=Number.POSITIVE_INFINITY){return this.enhance(async function*(){for(let r=0;r<t;r++)yield await e}())}zip(...e){if(0===e.length)return this.enhance([]);const t=e.map(T);let r,n=!1;return r=this.enhance(async function*(){try{for(;;){let r=[];for(const e of t){const t=await e.next();if(t.done)return n=!0,t.value;r.push(t.value)}try{yield r}catch(t){for(const r of e)try{await(r.throw?.(t))}catch{}throw t}}}finally{if(!n)for(const t of e)try{await(t.return?.(r?.returning))}catch{}}}())}join(e,t){return"string"==typeof e?(t=e,e=>this.join(e,t)):Promise.resolve(this.enhance(e).asArray()).then((e=>e.join(t)))}merge(...e){let t,r;const n=new Promise((e=>r=e));let a,s=e.length;const i=new Promise((()=>null));let o=[];return a=[...e.map((async(e,t)=>{const n=T(e);o[t]=n;const l=async e=>()=>{if(e.done)return a[t]=i,--s>0?null:(r(e),e);{const r=n.next().then(l);return a[t]=r,e}};return await n.next().then(l)})),n],t=this.enhance(async function*(){try{let r;for(;s;){const e=[];a.forEach((t=>e.push(t)));const t=await await Promise.race(e);if("function"==typeof t){let e=t();if(e){if(e.done)return e.value;r=yield e.value}}else if(t&&t.done)return t.value}}finally{if(s)for(let r=0;r<e.length;r++)(null===a[r]?null:o[r])?.return?.(t?.returning)}}())}sort(e){return async(...t)=>(await this.merge(...t).asArray()).sort(e)}enhance(e){const t=x(e),r=Object.getPrototypeOf(t),n=Object.assign(Object.create(W.prototype),r);return n.return=e=>(t.returning=e,r.return.call(t,e)),n[Symbol.asyncIterator]=()=>t,Object.setPrototypeOf(t,n),t}};var J,Z;(J||(J={})).Mixin=function(e){class t extends e{#e=void 0;constructor(...e){super(...e)}#t(){return X.enhance(this[Symbol.asyncIterator]())}asArray(){return this.#t().asArray()}limit(e){return this.#t().limit(e)}forEach(e,t){return this.#t().forEach(e,t)}map(e,t){return this.#t().map(e,t)}filter(e,t){return this.#t().filter(e,t)}flat(e=1){return this.#t().flat(e)}flatMap(e,t=1){return this.#t().flatMap(e,t)}slice(e=0,t=Number.MAX_SAFE_INTEGER){return this.#t().slice(e,t)}concat(...e){return this.#t().concat(...e)}reduce(e,t){return this.#t().reduce(e,t)}some(e,t){return this.#t().some(e,t)}every(e,t){return this.#t().every(e,t)}repeatLast(e=Number.MAX_SAFE_INTEGER){return this.#t().repeatLast(e)}repeat(e,t=Number.MAX_SAFE_INTEGER){return this.#t().repeat(e,t)}join(e=""){return this.#t().join(e)}sort(e){return this.#t().sort(e)}get[Symbol.toStringTag](){try{return this.#e??(this.#e=`Async.Mixin(${e.name})`)}catch{return`Async.Mixin(${e.name}).prototype`}}}return t};class Q{#r;constructor(e,t){this.#r=e.bind(this,...t)}[Symbol.asyncIterator](){return X.enhance(x(this.#r()))}}class ee extends(J.Mixin(Q)){constructor(e,t){super(e,t)}}(Z||(Z={})).wrap=(e,...t)=>new ee(e,t);const te=Object.getPrototypeOf(async function*(){}());var re;Object.setPrototypeOf(W.prototype,(e=>{const t=Object.create(e);return(e=>{for(const r of Reflect.ownKeys(e))"constructor"!==r&&(t[r]=e[r])})($.prototype),t})(te)),Object.defineProperty(W.prototype,"_impl",{value:X,writable:!1,enumerable:!1,configurable:!1}),function(e){e.asArray=X.asArray.bind(X),e.concat=X.concat.bind(X),e.every=X.every.bind(X),e.filter=X.filter.bind(X),e.flat=X.flat.bind(X),e.flatMap=X.flatMap.bind(X),e.forEach=X.forEach.bind(X),e.join=X.join.bind(X),e.limit=X.limit.bind(X),e.map=X.map.bind(X),e.merge=X.merge.bind(X),e.of=X.of.bind(X),e.reduce=X.reduce.bind(X),e.repeat=X.repeat.bind(X),e.repeatLast=X.repeatLast.bind(X),e.slice=X.slice.bind(X),e.some=X.some.bind(X),e.sort=X.sort.bind(X),e.zip=X.zip.bind(X),e.enhance=X.enhance.bind(X),e.Mixin=J.Mixin,e.wrap=Z.wrap}(re||(re={}));var ne=Object.freeze({__proto__:null,get Async(){return re},EnhancedAsyncGenerator:W,EnhancedGenerator:F,Future:K,get Sync(){return L},delay:(e,t)=>new Promise((r=>setTimeout((()=>r(t)),e))),doCatch:U,eventToGenerator:(e=(()=>new V))=>{let t=()=>{},r=null;const n=e(),a=e=>(n.push(e),t());return[async function*(){for(;;){for(;!n.length;)r=new Promise((e=>t=e)),await r,r=null,t=()=>{};const a=n.shift();if((e=a)instanceof Object&&"return"===e[B])return a.value;if(H(a))throw a.value;yield a}var e}(),new class{send(e){return a(e)}end(e){return a({[B]:"return",value:e})}throw(e){return a({[B]:"throw",value:e})}clear(){return n.clear()}}]},isAsyncGenable:b,isAsyncGenerator:v,isAsyncIterable:k,isAsyncIterableIterator:e=>O(e)&&k(e),isAsyncIterator:O,isGenable:g,isGenerator:_,isIterable:N,isIterableIterator:e=>E(e)&&N(e),isIterator:E,queue1:()=>{let e,t=!0;return new class{get length(){return t?0:1}push(r){return t=!1,e=r,1}shift(){t=!0;const r=e;return e=void 0,r}clear(){t=!0,e=void 0}}},queueNewest:(e=1)=>()=>{const t=new V;return new class{get length(){return t.length}push(r){for(;t.length>=e;)t.shift();return t.push(r)}shift(){return t.shift()}clear(){return t.clear()}}},queueOldest:(e=1)=>()=>{const t=new V;return new class{get length(){return t.length}push(r){return t.length<e?t.push(r):t.length}shift(){return t.shift()}clear(){return t.clear()}}},queueSticky:()=>{let e,t=!0;return new class{get length(){return t?0:1}push(r){return t=!1,e=r,1}shift(){return e}clear(){t=!0,e=void 0}}},queueUnique:e=>{const t=(e,t)=>()=>{const r=new Map;let n=null;return new class{get length(){return r.size}push(n){const a=t(n);return e?(r.delete(a),r.set(a,n)):r.has(a)||r.set(a,n),r.size}shift(){n||(n=r.values());const e=n.next();if(!e.done)return e.value;n=null}clear(){return r.clear()}}};return void 0===e?t(!1,(e=>e)):t(!!e.newest,e.keyFn||(e=>e))},queueUpdateShallow:(e={})=>()=>{const t={...e};let r={},n=!1;return new class{get length(){return n?1:0}push(e){const a=a=>Object.keys(a).forEach((a=>{t[a]!==e[a]&&(r[a]=e[a],n=!0)}));return a(t),a(e),1}shift(){try{return r}finally{Object.assign(t,r),this.clear()}}clear(){r={},n=!1}}},range:z,toAsyncGenerator:x,toAsyncIterable:M,toAsyncIterableIterator:function(e){if(k(e)&&O(e))return e;if(k(e)){let t;const r=()=>t??(t=e[Symbol.asyncIterator]()),n={[Symbol.asyncIterator]:()=>n,next:()=>r().next(),return:r().return&&(e=>r().return(e)),throw:r().throw&&(e=>r().throw(e))};return n}if(N(e))return C(e);if(O(e)){const t={[Symbol.asyncIterator]:()=>t,next:t=>e.next(t),return:e.return&&(t=>e.return(t)),throw:e.throw&&(t=>e.throw(t))};return t}throw new Error(`Not iterator nor iterable: ${e}`)},toAsyncIterator:T,toGenerator:w,toIterable:I,toIterableIterator:function(e){if(N(e)&&E(e))return e;if(N(e)){let t;const r=()=>t??(t=e[Symbol.iterator]()),n={[Symbol.iterator]:()=>n,next:e=>r().next(e),return:r().return&&(e=>r().return(e)),throw:r().throw&&(e=>r().throw(e))};return n}if(E(e)){const t={[Symbol.iterator]:()=>t,next:t=>e.next(t),return:e.return&&(t=>e.return(t)),throw:e.throw&&(t=>e.throw(t))};return t}throw new Error(`Not iterator nor iterable: ${e}`)},toIterator:S});const ae=Symbol("MARK"),se=e=>e,ie=e=>"string"==typeof e?t=>t[e]:e;class oe{key;constructor(e){this.key=e}}class le extends oe{constructor(e){super(e)}add(e){}value(){return[this.key]}}class ce extends oe{list=[];add(e){this.list.push(e)}value(){return[this.list]}}var ue="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},he={exports:{}};!function(e,t){(function(){var t,r,n,a,s,i,o,l,c,u,h,p,f,m,y;n=Math.floor,u=Math.min,r=function(e,t){return e<t?-1:e>t?1:0},c=function(e,t,a,s,i){var o;if(null==a&&(a=0),null==i&&(i=r),a<0)throw new Error("lo must be non-negative");for(null==s&&(s=e.length);a<s;)i(t,e[o=n((a+s)/2)])<0?s=o:a=o+1;return[].splice.apply(e,[a,a-a].concat(t)),t},i=function(e,t,n){return null==n&&(n=r),e.push(t),m(e,0,e.length-1,n)},s=function(e,t){var n,a;return null==t&&(t=r),n=e.pop(),e.length?(a=e[0],e[0]=n,y(e,0,t)):a=n,a},l=function(e,t,n){var a;return null==n&&(n=r),a=e[0],e[0]=t,y(e,0,n),a},o=function(e,t,n){var a;return null==n&&(n=r),e.length&&n(e[0],t)<0&&(t=(a=[e[0],t])[0],e[0]=a[1],y(e,0,n)),t},a=function(e,t){var a,s,i,o,l,c;for(null==t&&(t=r),l=[],s=0,i=(o=function(){c=[];for(var t=0,r=n(e.length/2);0<=r?t<r:t>r;0<=r?t++:t--)c.push(t);return c}.apply(this).reverse()).length;s<i;s++)a=o[s],l.push(y(e,a,t));return l},f=function(e,t,n){var a;if(null==n&&(n=r),-1!==(a=e.indexOf(t)))return m(e,0,a,n),y(e,a,n)},h=function(e,t,n){var s,i,l,c,u;if(null==n&&(n=r),!(i=e.slice(0,t)).length)return i;for(a(i,n),l=0,c=(u=e.slice(t)).length;l<c;l++)s=u[l],o(i,s,n);return i.sort(n).reverse()},p=function(e,t,n){var i,o,l,h,p,f,m,y,d;if(null==n&&(n=r),10*t<=e.length){if(!(l=e.slice(0,t).sort(n)).length)return l;for(o=l[l.length-1],h=0,f=(m=e.slice(t)).length;h<f;h++)n(i=m[h],o)<0&&(c(l,i,0,null,n),l.pop(),o=l[l.length-1]);return l}for(a(e,n),d=[],p=0,y=u(t,e.length);0<=y?p<y:p>y;0<=y?++p:--p)d.push(s(e,n));return d},m=function(e,t,n,a){var s,i,o;for(null==a&&(a=r),s=e[n];n>t&&a(s,i=e[o=n-1>>1])<0;)e[n]=i,n=o;return e[n]=s},y=function(e,t,n){var a,s,i,o,l;for(null==n&&(n=r),s=e.length,l=t,i=e[t],a=2*t+1;a<s;)(o=a+1)<s&&!(n(e[a],e[o])<0)&&(a=o),e[t]=e[a],a=2*(t=a)+1;return e[t]=i,m(e,l,t,n)},t=function(){function e(e){this.cmp=null!=e?e:r,this.nodes=[]}return e.push=i,e.pop=s,e.replace=l,e.pushpop=o,e.heapify=a,e.updateItem=f,e.nlargest=h,e.nsmallest=p,e.prototype.push=function(e){return i(this.nodes,e,this.cmp)},e.prototype.pop=function(){return s(this.nodes,this.cmp)},e.prototype.peek=function(){return this.nodes[0]},e.prototype.contains=function(e){return-1!==this.nodes.indexOf(e)},e.prototype.replace=function(e){return l(this.nodes,e,this.cmp)},e.prototype.pushpop=function(e){return o(this.nodes,e,this.cmp)},e.prototype.heapify=function(){return a(this.nodes,this.cmp)},e.prototype.updateItem=function(e){return f(this.nodes,e,this.cmp)},e.prototype.clear=function(){return this.nodes=[]},e.prototype.empty=function(){return 0===this.nodes.length},e.prototype.size=function(){return this.nodes.length},e.prototype.clone=function(){var t;return(t=new e).nodes=this.nodes.slice(0),t},e.prototype.toArray=function(){return this.nodes.slice(0)},e.prototype.insert=e.prototype.push,e.prototype.top=e.prototype.peek,e.prototype.front=e.prototype.peek,e.prototype.has=e.prototype.contains,e.prototype.copy=e.prototype.clone,e}(),e.exports=t}).call(ue)}(he);var pe=he.exports;const fe=pe,me=e=>{if(e instanceof Error)throw e;throw new Error(e)},ye=e=>e.reduce(((e,t)=>(e[t.name]=t,e)),{}),de=(e,t=2)=>e.toLocaleString("en",{minimumFractionDigits:t,maximumFractionDigits:t,currency:"USD",style:"currency"}),ge=(e,t=3)=>`${(100*e).toLocaleString("en",{minimumFractionDigits:t,maximumFractionDigits:t})}%`,be=(e,t)=>e.type===t,_e=(e,t)=>be(e,t)?e:me(`Row not of type ${t}.`),ve=e=>{if(e instanceof Object)for(const t of Object.values(e)){try{Object.freeze(e)}catch{}ve(t)}return e},we=e=>[...e.reduce(((e,t)=>(e.add(t),e)),new Set).keys()],xe=(e,t)=>t?r=>t(r.reduce(((t,r)=>t+e(r)),0)):t=>t.reduce(((t,r)=>t+e(r)),0),Se=e=>e.value,Te=xe(Se),Ae=(e,t)=>{const r=t=>t instanceof e?t:me(`${t} is not an instance of ${t.name}`),n=t?n=>n instanceof e?n:r(t(n)):r;return[t=>t instanceof e,n,r]},Ie=(e,t,r)=>{const n=r=>e(r)?r:me(`${r} is not ${t}`),a=r?t=>e(t)?t:n(r(t)):n;return[a,n]},Me=e=>"function"==typeof e,Ce=e=>e,Ee=e=>"number"==typeof e.value,[Oe,Ne]=Ie(Ee,"a monetary item"),ke=e=>"object"==typeof e,[Ue,$e]=Ie(ke,"an object"),Fe=e=>!0===e||!1===e,[je,Pe]=Ie(Fe,"true or false",(e=>!/^\s*(?:false|f)\s*$/i.test(e)&&(!!/^\s*(?:true|t)\s*$/i.test(e)||void 0)));function Re(e,t){return t?`${e}/${t}`:t=>`${e}/${t}`}const De=e=>Object.entries(e),Ye=e=>Object.keys(e);var qe;e.UnequalAction=void 0,(qe=e.UnequalAction||(e.UnequalAction={}))[qe.END_ON_FIRST=0]="END_ON_FIRST",qe[qe.END_ON_LAST=1]="END_ON_LAST",qe[qe.ERROR=2]="ERROR";class Le extends oe{#l;#c;#u;#h;#p;constructor(e,t,r,n,a,s){super(e),this.#c=t;const i={};for(const n of t)i[n]=r[n](e);this.#l=i,this.#u=n,this.#p=a,this.#h=s}add(e){for(const t of this.#c){const r=this.#l[t],n=(0,this.#u[t])(e);r.add(n)}}value(){const t={};for(const e of this.#c){const r=this.#l[e];t[e]=r.value()[Symbol.iterator]()}const r=this.#c,n=this.#h,a=this.#p;return function*(){let s=!0,i=!1;for(;s;){s=!1;let o=a?[]:{};for(const a of r){const r=t[a]?.next();if(r)if(r.done){if(delete t[a],n===e.UnequalAction.END_ON_FIRST)return;i=!0}else s=!0,o[a]=r.value}if(s){if(i&&n===e.UnequalAction.ERROR)throw new Error("Unmatched result lengths in object aggregation merge");yield o}}}()}}class ze extends oe{#f=0;constructor(e){super(e),this.#f}add(e){null!=e&&(this.#f+=e)}value(){return[this.#f]}}class Ge extends oe{#m;#y;#d;constructor(e,t,r,n){super(e),this.#m=t,this.#y=r,this.#d=n??ie(r)}add(e){this.#m(e),this.#d(e)}value(){return[]}}var Ve;e.CalendarUnit=void 0,(Ve=e.CalendarUnit||(e.CalendarUnit={})).year="year",Ve.semiannually="semiannually",Ve.quarter="quarter",Ve.month="month",Ve.semimonthly="semimonthly",Ve.biweekly="biweekly",Ve.week="week",Ve.day="day";const Be=e=>"number"==typeof e&&!isNaN(e)&&isFinite(e),He=(e,t)=>{const r=(({min:e,max:t,mod:r,minEx:n,maxEx:a})=>{const s=0|(void 0!==e?1:0)|(void 0!==t?2:0)|(n?4:0)|(a?8:0)|(void 0!==r?16:0);switch(s){case 0:case 4:case 8:case 12:return Be;case 1:case 9:return t=>Be(t)&&t>=e;case 2:case 6:return e=>Be(e)&&e<=t;case 3:return r=>Be(r)&&r>=e&&r<=t;case 5:case 13:return t=>Be(t)&&t>e;case 10:case 14:return e=>Be(e)&&e<t;case 7:return r=>Be(r)&&r>e&&r<=t;case 11:return r=>Be(r)&&r>=e&&r<t;case 15:return r=>Be(r)&&r>e&&r<t;case 16:case 20:case 24:case 28:return e=>Be(e)&&e/r%1==0;case 17:case 25:return t=>Be(t)&&t>=e&&t/r%1==0;case 18:case 22:return e=>Be(e)&&e<=t&&e/r%1==0;case 19:return n=>Be(n)&&n>=e&&n<=t&&n/r%1==0;case 21:case 29:return t=>Be(t)&&t>e&&t/r%1==0;case 26:case 30:return e=>Be(e)&&e<t&&e/r%1==0;case 23:return n=>Be(n)&&n>e&&n<=t&&n/r%1==0;case 27:return n=>Be(n)&&n>=e&&n<t&&n/r%1==0;case 31:return n=>Be(n)&&n>e&&n<t&&n/r%1==0;default:throw new Error(`Impossible ${s}`)}})(t),n=t=>r(t)?t:me(`${t} is not a valid ${e}.`);return{is:r,as:n,to:e=>Be(e)?n(e):n(Number(e))}},{is:Ke,as:We,to:Xe}=He("Integer",{mod:1}),Je=Math.floor,Ze=Math.ceil,Qe=Math.round,et=Math.max,tt=Math.min,rt=e=>t=>Qe(t/e)*e,nt=Math.trunc,at=(()=>{let e;return(...t)=>(e||(e=xe(We,We)),e(t))})(),st=e=>"string"==typeof e,{is:it,as:ot,to:lt}=He("Degrees",{min:0,max:360,maxEx:!0}),{is:ct,as:ut,to:ht}=He("Unit",{min:0,max:1}),{is:pt,as:ft,to:mt}=He("Probability",{min:0,max:1}),{is:yt,as:dt,to:gt}=He("Integer",{mod:1}),{is:bt,as:_t,to:vt}=He("Byte",{min:0,max:255,mod:1}),{is:wt,as:xt,to:St}=He("Money",{}),Tt=rt(.01),At=e=>xt(Tt(xt(e))),It=(...e)=>At(et(...e)),Mt=(...e)=>At(tt(...e)),Ct=At(0),{is:Et,as:Ot,to:Nt}=He("Rate",{min:-2,max:2,minEx:!0}),{is:kt,as:Ut,to:$t}=He("TaxRate",{min:0,max:1}),{is:Ft,as:jt,to:Pt}=He("Year",{min:1900,max:2300,mod:1}),{is:Rt,as:Dt,to:Yt}=He("Age",{min:0,max:130}),{is:qt,as:Lt,to:zt}=He("IAge",{min:0,max:130,mod:1}),Gt=e=>e,Vt={year:1,semiannually:2,quarter:4,month:12,semimonthly:24,biweekly:365.25/14,week:365.25/7,day:365.25};function Bt(e,t=0,r=1){return st(e)?wr(e):new Date(Date.UTC(gt(e),gt(t),gt(r),0,0,0,0))}const Ht=[[0,31,59,90,120,151,181,212,243,273,304,334,365],[0,31,60,91,121,152,182,213,244,274,305,335,366]],Kt=[[31,28,31,30,31,30,31,31,30,31,30,31],[31,29,31,30,31,30,31,31,30,31,30,31]],Wt=t=>t in e.CalendarUnit,[Xt,Jt]=Ie(Wt,"a calendar unit"),Zt=e=>{if(e instanceof Object){const t=Object.keys(e);switch(t.length){case 0:default:return!1;case 1:return Wt(t[0])&&yt(e[t[0]]);case 2:return Wt(t[0])&&yt(e[t[0]])&&"totalDays"===t[1]&&yt(e.totalDays)||Wt(t[1])&&yt(e[t[1]])&&"totalDays"===t[0]&&yt(e.totalDays)}}return!1},[Qt,er]=Ie(Zt,"a CalendarInterval"),tr=t=>t.year?[e.CalendarUnit.year,t.year]:t.semiannually?[e.CalendarUnit.semiannually,t.semiannually]:t.quarter?[e.CalendarUnit.quarter,t.quarter]:t.month?[e.CalendarUnit.month,t.month]:t.semimonthly?[e.CalendarUnit.semimonthly,t.semimonthly]:t.biweekly?[e.CalendarUnit.biweekly,t.biweekly]:t.week?[e.CalendarUnit.week,t.week]:t.day?[e.CalendarUnit.day,t.day]:me(`${JSON.stringify(t)} is not a CalendarInterval`),rr=t=>{if("object"==typeof t&&dr(t.date)&&yt(t.totalDays))for(const r in e.CalendarUnit)if(yt(t[r]))return!0;return!1},[nr,ar]=Ie(rr,"a valid CalendarLength");function sr(t,r,n=1){if(Zt(r)){const[e,n]=tr(r);return sr(t,e,n)}const a=r,s=br(t),i=s.getUTCFullYear(),o=s.getUTCMonth(),l=s.getUTCDate(),c=dt(n),[u,h,p]=(()=>{const t=e=>{const t=o+e;return[Je(t/12),t%12-o,0]};switch(a){case e.CalendarUnit.year:return[c,0,0];case e.CalendarUnit.semiannually:return t(6*c);case e.CalendarUnit.quarter:return t(3*c);case e.CalendarUnit.month:return t(c);case e.CalendarUnit.semimonthly:return(e=>{const t=o+Je(e/2);return[Je(t/12),(l>=15&&1&e?t%12+1:t%12)-o,l>=15?1&e?1-l:0:1&e?14:0]})(c);case e.CalendarUnit.biweekly:return[0,0,14*c];case e.CalendarUnit.week:return[0,0,7*c];case e.CalendarUnit.day:return[0,0,c]}throw new Error(`Unknown TimeInterval: ${a}`)})(),f=Bt(i+u,o+h,l);return p?new Date(f.getTime()+24*p*60*60*1e3):f}const ir=e=>String(e).padStart(2,"0"),or=e=>dr(e)?e.getUTCFullYear()-2e3+"}":cr(br(e)),lr=e=>dr(e)?`'${e.getUTCFullYear()-2e3}}`:cr(br(e)),cr=e=>dr(e)?`${e.getUTCFullYear()}}`:cr(br(e)),ur=e=>dr(e)?`${e.getUTCFullYear()}-${ir(e.getUTCMonth()+1)}`:ur(br(e)),hr=e=>dr(e)?`${e.getUTCFullYear()}-${ir(e.getUTCMonth()+1)}-${ir(e.getUTCDate())}`:hr(br(e)),pr=e=>dr(e)?`${ir(e.getUTCHours())}:${ir(e.getUTCMinutes()+1)}:${ir(e.getUTCSeconds())}`:pr(br(e)),fr=e=>dr(e)?`${hr(e)} ${pr(e)}`:fr(br(e));function mr(e){if(e instanceof Date)return mr(e.getUTCFullYear());const t=jt(e);return t%4==0&&(t%100!=0||t%400==0)}const yr=t=>{switch(t){case e.CalendarUnit.year:return e=>Bt(e.getUTCFullYear());case e.CalendarUnit.quarter:return e=>Bt(e.getUTCFullYear(),3*Je(e.getUTCMonth()/3));case e.CalendarUnit.month:return e=>Bt(e.getUTCFullYear(),e.getUTCMonth());case e.CalendarUnit.week:throw new Error("'week' is not a meaningful unit to truncate a date to.");case e.CalendarUnit.day:return e=>Bt(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}throw new Error(`Unknown TimeInterval: ${t}`)},dr=e=>e instanceof Date&&!isNaN(e.valueOf())&&0===e.getUTCHours()&&0===e.getUTCMinutes()&&0===e.getUTCSeconds()&&0===e.getUTCMilliseconds(),gr=yr(e.CalendarUnit.day),[br,_r]=Ie(dr,"is not a UTC Date",(e=>e instanceof Date?gr(e):Bt(e))),vr=yr(e.CalendarUnit.day),wr=e=>{const t=/^\s*(\d{4})(?:-(\d{1,2})(?:-(\d{1,2}))?)?\s*$/.exec(e);if(!t)throw new Error(`${e} is not a valid date. Must be in the form YYYY-01-23. Month and day are optional, default to 01.`);return Bt(Number(t[1]),Number(t[2]??1)-1,Number(t[3]??1))};class xr{start;end;constructor(e,t,r){if(this.start=br(e),Wt(t))this.end=sr(this.start,t,r??1);else if(Zt(t)){const[e,r]=tr(t);this.end=sr(this.start,e,r)}else this.end=br(t)}get length(){const e=this.end.getUTCFullYear()-this.start.getUTCFullYear(),t=this.end.getUTCMonth()-this.start.getUTCMonth(),r=this.end.getUTCDate()-this.start.getUTCDate(),n=mr(this.end),[a,s]=r<0?[t-1,r+Kt[n?1:0][this.end.getUTCMonth()]]:[t,r],[i,o]=a<0?[e-1,a+12]:[e,a],l=Je(r/7),c=s-7*l;return{...i&&{year:i},...o&&{month:o},...l&&{week:l},...c&&{day:c},totalDays:Je((this.end.getTime()-this.start.getTime())/864e5)}}range(e,t=1){return xr.calendarRange(this.start,this.end,e,void 0===t?void 0:dt(t))}toString(){return`${hr(this.start)} to ${hr(this.end)}`}static calendarRange}const[Sr,Tr,Ar]=Ae(xr,(e=>"object"==typeof e&&e.start&&e.end?new xr(e.start,e.end):void 0));class Ir extends xr{step;constructor(e,t,r=0){super(e,t),this.step=r}}const[Mr,Cr,Er]=Ae(Ir);class Or extends xr{interval;unit;n;constructor(e,t,r,n){super(e,t),this.interval={[r]:n??1},this.unit=r,this.n=n??1}[Symbol.iterator](){const e=this;return L.enhance(function*(){let t=e.start,r=0;for(;t<e.end;){const n=sr(t,e.unit,e.n);yield new Ir(t,n,r),t=n,r++}}())}}class Nr extends(L.Mixin(Or)){constructor(e,t,r,n){super(br(e),br(t),Nr.#g(r),Nr.#b(r,n))}static#g(e){if(Wt(e))return e;const[t,r]=tr(er(e));return t}static#b(e,t){if(Wt(e))return dt(t??1);{const[t,r]=tr(er(e));return r}}}function kr(e,t,r,n){return new Nr(e,t,r,void 0===n?void 0:dt(n))}const Ur=e=>(e.valueOf()-$r(e).valueOf())/864e5,$r=e=>Lr[e.getUTCFullYear()]??Bt(e.getUTCFullYear()),Fr=e=>mr(e)?366:365,jr=(e,t)=>{const r=Ur(e),n=Ur(t);mr(e.getUTCFullYear()),mr(t.getUTCFullYear());const a=t.getUTCFullYear(),s=a-e.getUTCFullYear(),i=Fr(r<60?a-1:a);return Dt(s+(n-r)/i)},Pr=vr(new Date),Rr=jt(Pr.getUTCFullYear());let Dr=jt(Rr+50);const Yr=Bt(Rr+100),qr=jt(Yr.getUTCFullYear()+1),Lr=z(Rr,qr).map((e=>Bt(e))).asArray(),zr=$r(Pr),Gr=new Date;let Vr=1===Gr.getUTCDate()?Bt(Gr.getUTCFullYear(),Gr.getUTCMonth()):Gr.getUTCMonth()<=11?Bt(Gr.getUTCFullYear(),Gr.getUTCMonth()+1):Bt(Gr.getUTCFullYear()+1,0),Br=Bt(Vr.getUTCFullYear()+50,Vr.getUTCMonth());class Hr{id;prettyName;start;end;scenario;categories;scenarios;name;type;notes;#e;sort;#_=void 0;constructor(e,t){this.type=e.type,this.name=e.name,this.id=`${this.type}/${this.name}`,this.prettyName=e.prettyName??e.name,this.scenario=t??this,this.start=e.start??t?.start??Vr,this.end=e.end,this.categories=e.categories??[],this.scenarios=e.scenarios?.length?e.scenarios:["Default"],this.notes=e.notes,this.sort=Number(e.sort||0)}set temporal(e){if(this.#_)throw new Error("Cannot reset .temporal");this.#_=e}get temporal(){return this.#_??me(".temporal has not been set.")}get[Symbol.toStringTag](){try{return this.#e??(this.#e=`${this.type}[${this.name}]`)}catch{return`${this.constructor.name}.prototype`}}hasCategory(e){return!!this.categories.find((t=>t===e))}inScenario(e){return!!this.scenarios.find((t=>t===e))}static inScenario(e,t){return Array.isArray(t)?!!t.find((t=>t===e)):this.inScenario(e,t.scenarios)}}class Kr extends Hr{value;constructor(e,t){super(e,t),this.value=e.value}}function Wr(e){class t extends e{state;scenario;item;#e=void 0;constructor(e,t,r){super(e,t,r),this.item=e,this.scenario=t,this.state=r}get[Symbol.toStringTag](){try{return this.#e??(this.#e=`${this.type}State[${this.name} #${this.state?.step?.step??"??"}]`)}catch{return`${this.type}State.prototype`}}}return t}const Xr=(e,t,r)=>Wt(t)?Xr(e,Vt[t],r):Wt(r)?Xr(e,t,Vt[r]):r*Jr(e,t,r),Jr=(e,t,r)=>Wt(t)?Jr(e,Vt[t],r):Wt(r)?Jr(e,t,Vt[r]):Math.pow(1+e/t,t/r)-1,Zr=(e,t,r)=>Wt(t)?Zr(e,Vt[t],r):Wt(r)?Zr(e,t,Vt[r]):At(e*t/r);class Qr extends Kr{rate;rateType;paymentPeriod;constructor(t,r){super(t,r),this.rate=t.rate??0,this.rateType=t.rateType||e.CalendarUnit.year,this.paymentPeriod=t.paymentPeriod||e.CalendarUnit.year}*stepper(t,r){let n=this.value,a=t.start,s=Jr(this.rate,Jt(this.rateType),e.CalendarUnit.month),i=Ct;for(;;){this.start,r.addTimeLine("interest",a,this,{amount:i,balance:n});const e=yield{value:n,interest:i,rate:s};s=e.rate,i=At(s*n),n=At(e.value+i),a=e.date}}}class en extends(Wr(Qr)){constructor(e,t,r){super(e,t,r)}}const[tn,rn,nn]=Ae(Qr);class an extends Kr{paymentPeriod;constructor(t,r){super(t,r);const n=this.end||"incomeStream"===this.type||"incomeTax"===this.type;this.paymentPeriod=t.paymentPeriod??(n?e.CalendarUnit.month:me(`Missing payment period in ${this.id}`))}}class sn extends an{fromStream;constructor(e,t){super(e,t),this.fromStream=e.fromStream??me(`fromStream must be specified for ${this.name}.`)}*stepper(t,r){let n=Zr(this.value,this.paymentPeriod,e.CalendarUnit.month),a=t.start,s=Ct;for(;;){s=At(s+(a>=this.start?n:Ct));const e=s;r.addTimeLine("pay",a,this,{amount:e,balance:s});const t=yield{value:s,payment:e};s=t.value,a=t.date}}}class on extends(Wr(sn)){constructor(e,t,r){super(e,t,r)}}const[ln,cn,un]=Ae(sn);class hn extends an{constructor(e,t){super(e,t)}*stepper(e,t){let r=this.value,n=e.start;for(;;){const e=n>=this.start?r:Ct,a=e;t.addTimeLine("receive",n,this,{amount:a,balance:r});const s=yield{value:e,payment:a};r=At(this.value+s.value),n=s.date}}}class pn extends(Wr(hn)){constructor(e,t,r){super(e,t,r)}}const[fn,mn,yn]=Ae(hn),dn=(e,t)=>{for(const[r,n]of De(t))e[r]=At((e[r]??Ct)+(n??Ct))};class gn extends an{#v;#w;constructor(e,t){super(e,t),this.#v=gn.parse(e.spec)}static parse(e,t){if("string"==typeof e){const r=e.replace(/[“”]/g,'"');if(/^["\[{]/.test(r))try{return JSON.parse(r)}catch(e){throw new Error(`Error parsing incomeStream ${t??"unknown"}: ${e.message}`)}}return e}get spec(){return this.#w??(this.#w=this.bind(this.#v))}bind(e){const t=e=>e.startsWith("@")?this.scenario.incomeStreams[e.substring(1)].id??me(`There is no IncomeStream named ${e.substring(1)}`):(this.scenario.incomes[e]??this.scenario.assets[e]??this.scenario.liabilities[e])?.id??me(`There is no income, asset, or liability named "${e}"`);if(st(e)){if(e.startsWith("@")){const t=e.substring(1);return this.scenario.incomeStreams[t].id}return t(e)}if(Array.isArray(e))return e.map((e=>this.bind(e)));if("object"==typeof e){const r={};let n=0;for(const t in e)n+=e[t];for(const a in e){r[t(a)]={weight:e[a]/n}}return r}throw new Error(`Unknown income stream spec: ${e}`)}withdraw(e,t,r){const n={},a=(e,s)=>{if(st(s)){const a=r[s]?.current;if(a){if(vn(a.item)){const{amount:s,sources:i}=a.item.withdraw(e,t,r);return dn(n,i),s}if(bn(a)){const t=a.item,r=Mt(e,a.value);return a.used=At((a.used??Ct)+r),"liability"===t.type?a.value=At(a.value+r):a.value=At(a.value-r),((e,t)=>{n[e]=At((n[e]??Ct)+t)})(t.id,r),r}throw new Error(`${s} is not a valid source of income.`)}return console.log(`The income source ${s} is not available at ${r.date}.`),Ct}if(Array.isArray(s)){let t=0;for(const r of s)if(t+=a(It(e-t,Ct),r),t>=e)break;return At(t)}if("object"==typeof s){const t=s;let r=0;for(const n in s)r+=a(At(e*t[n].weight),n);return At(r)}throw new Error(`Unknown spec: ${s}`)};return{id:t,amount:a(e,this.spec),sources:n}}*stepper(e,t){for(;;)yield{}}}const bn=e=>e.item&&("asset"===e.item.type||"liability"===e.item.type||"income"===e.item.type);class _n extends(Wr(gn)){constructor(e,t,r){super(e,t,r)}parse(e){return e}}const[vn,wn,xn]=Ae(gn);class Sn extends an{state;constructor(e,t){super(e,t),this.state=e.state}*stepper(e,t){for(;;)yield{}}}class Tn extends(Wr(Sn)){constructor(e,t,r){super(e,t,r)}}const[An,In,Mn]=Ae(Sn);class Cn extends Kr{rate;rateType;payment;paymentPeriod;expense;constructor(t,r){super(t,r),this.rate=t.rate??0,this.rateType=t.rateType||e.CalendarUnit.year,this.payment=t.payment??Ct,this.paymentPeriod=t.paymentPeriod??e.CalendarUnit.month}*stepper(t,r){let n=this.value,a=t.start,s=Jr(this.rate,Jt(this.rateType),e.CalendarUnit.month);for(;;){if(n<=0)return;const e=Mt(n,this.payment??Ct);r.addTimeLine("pay",a,this,{amount:e,balance:n});const t=At(s*n),i=At(e-t),o=a>=this.start?n:Ct;r.addTimeLine("interest",a,this,{amount:t,balance:o});const l=yield{value:o,interest:t,principal:i,payment:e,rate:s};n=At(l.value-i),a=l.date}}}class En extends(Wr(Cn)){constructor(e,t,r){super(e,t,r)}}const[On,Nn,kn]=Ae(Cn);class Un extends Hr{text;constructor(e,t){super(e,t),this.text=e.text}*stepper(e,t){let r=e.start;for(;;){let e=r>=this.start?this.text:"";r=(yield{text:e}).date}}}class $n extends(Wr(Un)){constructor(e,t,r){super(e,t,r)}}const[Fn,jn,Pn]=Ae(Un);const Rn=[{age:0,male:{p:.006304,n:1e5,years:75.97},female:{p:.005229,n:1e5,years:80.96}},{age:1,male:{p:426e-6,n:99370,years:75.45},female:{p:342e-6,n:99477,years:80.39}},{age:2,male:{p:29e-5,n:99327,years:74.48},female:{p:209e-6,n:99443,years:79.42}},{age:3,male:{p:229e-6,n:99298,years:73.5},female:{p:162e-6,n:99422,years:78.43}},{age:4,male:{p:162e-6,n:99276,years:72.52},female:{p:143e-6,n:99406,years:77.45}},{age:5,male:{p:146e-6,n:99260,years:71.53},female:{p:125e-6,n:99392,years:76.46}},{age:6,male:{p:136e-6,n:99245,years:70.54},female:{p:113e-6,n:99379,years:75.47}},{age:7,male:{p:127e-6,n:99232,years:69.55},female:{p:104e-6,n:99368,years:74.47}},{age:8,male:{p:115e-6,n:99219,years:68.56},female:{p:97e-6,n:99358,years:73.48}},{age:9,male:{p:103e-6,n:99208,years:67.57},female:{p:93e-6,n:99348,years:72.49}},{age:10,male:{p:97e-6,n:99197,years:66.57},female:{p:92e-6,n:99339,years:71.5}},{age:11,male:{p:109e-6,n:99188,years:65.58},female:{p:98e-6,n:99330,years:70.5}},{age:12,male:{p:151e-6,n:99177,years:64.59},female:{p:113e-6,n:99320,years:69.51}},{age:13,male:{p:232e-6,n:99162,years:63.6},female:{p:138e-6,n:99309,years:68.52}},{age:14,male:{p:343e-6,n:99139,years:62.61},female:{p:172e-6,n:99295,years:67.53}},{age:15,male:{p:465e-6,n:99105,years:61.63},female:{p:211e-6,n:99278,years:66.54}},{age:16,male:{p:588e-6,n:99059,years:60.66},female:{p:251e-6,n:99257,years:65.55}},{age:17,male:{p:72e-5,n:99001,years:59.7},female:{p:293e-6,n:99232,years:64.57}},{age:18,male:{p:858e-6,n:98929,years:58.74},female:{p:336e-6,n:99203,years:63.59}},{age:19,male:{p:999e-6,n:98845,years:57.79},female:{p:379e-6,n:99170,years:62.61}},{age:20,male:{p:.001146,n:98746,years:56.85},female:{p:425e-6,n:99132,years:61.63}},{age:21,male:{p:.001288,n:98633,years:55.91},female:{p:472e-6,n:99090,years:60.66}},{age:22