/* ------------------------------------------- Meta Bind - Release Build ------------------------------------------- By: Moritz Jung (https://www.moritzjung.dev/) Version: 1.5.1 ------------------------------------------- THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin ------------------------------------------- Copyright (C) 2026 Moritz Jung ------------------------------------------- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let u=require("@codemirror/language"),d=require("@codemirror/view"),f=require("obsidian");var p=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],m=[{index:0,name:`Sunday`,shortName:`Su`},{index:1,name:`Monday`,shortName:`Mo`},{index:2,name:`Tuesday`,shortName:`Tu`},{index:3,name:`Wednesday`,shortName:`We`},{index:4,name:`Thursday`,shortName:`Th`},{index:5,name:`Friday`,shortName:`Fr`},{index:6,name:`Saturday`,shortName:`Sa`}];function h(e){return m.find(t=>t.name===e)??m[1]}function g(e){if(typeof e==`string`)return h(e).name;if(typeof e==`number`)return(m.find(t=>t.index===e)??m[1]).name;if(typeof e==`object`&&e&&`name`in e){let t=e.name;if(typeof t==`string`)return h(t).name}return m[1].name}var _={devMode:!1,ignoreCodeBlockRestrictions:!1,preferredDateFormat:`YYYY-MM-DD`,firstWeekday:m[1].name,syncInterval:200,enableJs:!1,viewFieldDisplayNullAsEmpty:!1,enableSyntaxHighlighting:!0,enableEditorRightClickMenu:!0,inputFieldTemplates:[],buttonTemplates:[],excludedFolders:[`templates`]},v=1e3;function y(e,t,n){return Math.min(Math.max(e,t),n)}function b(e,t,n){return e===void 0?void 0:Math.min(Math.max(e,t),n)}function x(e,t,n,r,i){return(e-t)/(n-t)*(i-r)+r}function S(e,t){return(e%t+t)%t}function C(e,t){if(e===t||typeof e==`number`&&typeof t==`number`&&Number.isNaN(e)&&Number.isNaN(t))return!0;if(e===null||t===null||e===void 0||t===void 0)return e===t;if(typeof e!=typeof t)return!1;if(typeof e!=`object`)return e===t;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=Array.isArray(e),r=Array.isArray(t);if(n||r){if(!n||!r)return!1;let i=e,a=t;if(i.length!==a.length)return!1;for(let e=0;e=this.input.length}advanceTo(e){this.position=e}sliceTo(e){return this.input.slice(this.position,e)}succeedOffset(e,t){return this.succeedAt(this.position+e,t)}failOffset(e,t){return this.failAt(this.position+e,t)}succeed(e){return this.succeedAt(this.position,e)}fail(e){return this.failAt(this.position,e)}succeedAt(e,t){return this.advanceTo(e),{success:!0,value:t}}failAt(e,t){return this.advanceTo(e),this.addError(Array.isArray(t)?t:[t]),{success:!1,value:void 0}}addError(e){this.latestError===void 0||this.latestError.positiont[a](n,i)),Object.defineProperty(r,a,{get:()=>{if(n[a]!==void 0)return n[a];throw Error(`Can not access rule '${a}' in language. Rule is not yet defined. Try to access it via 'ref'.`)}});for(let e in t)n[e]=t[e](r,i);return n}static or(...e){if(e.length===0)throw Error(`or must have at least one alternative`);return new se(function(t){let n=t.position;for(let r of e){let e=r;t.position=n;let i=e.p(t);if(i.success)return i}return{success:!1,value:void 0}})}static separateBy(t,n){return this.separateByNotEmpty(t,n).or(e.succeed([]))}static separateByNotEmpty(e,t){return this.sequenceMap(function(e,t){return t.unshift(e),t},e,t.then(e).many())}static string(e){let t=`'`+e+`'`;return new se(function(n){for(let r=0;r=0&&e<=a.length){let t=a[0],n=a[e];return r.succeedOffset(t.length,n)}let i=`expected valid match group (0 to `+a.length+`) in `+n;return r.fail(i)}else return r.fail(n)})}static succeed(e){return new se(function(t){return t.succeed(e)})}static fail(e){return new se(function(t){return t.fail(e)})}static oneOf(e){return de.test(function(t){return e.includes(t)},`one character of '${e}'`)}static noneOf(e){return de.test(function(t){return!e.includes(t)},`no character of '${e}'`)}static oneStringOf(e){return this.or(...e.map(e=>this.string(e))).describe(e.map(e=>`'${e}'`).join(` or `))}static manyOf(e){return new se(function(t){let n=t.position;for(;ne.succeed(e.position))}static any(){return new se(e=>e.atEOF()?e.fail(`any character`):e.succeedOffset(1,e.input[e.position]))}static remaining(){return new se(e=>e.succeedAt(e.input.length,e.input.slice(e.position)))}static eof(){return new se(e=>e.atEOF()?e.succeed(void 0):e.fail(`eof`))}static digit(){return de.testCharCode(e=>e>=F&&e<=ie,`a digit`)}static digits(){return de.testCharCodes(e=>e>=F&&e<=ie,`multiple digits`)}static letter(){return de.testCharCode(e=>e>=I&&e<=ae||e>=oe&&e<=L,`a letter`)}static letters(){return de.testCharCodes(e=>e>=I&&e<=ae||e>=oe&&e<=L,`multiple letters`)}static unicodeLetter(){return P.regexp(/^\p{L}/iu).describe(`a unicode letter`)}static unicodeLetters(){return P.regexp(/^\p{L}+/iu).describe(`multiple unicode letters`)}static unicodeAlphanumeric(){return P.regexp(/^[\p{L}\p{N}]/iu).describe(`a unicode alphanumeric character`)}static unicodeAlphanumerics(){return P.regexp(/^[\p{L}\p{N}]+/iu).describe(`multiple unicode alphanumeric characters`)}static optionalWhitespace(){return new se(function(e){let t=e.position;for(;t=e.input.length)return e.fail(`\\r\\n`);let t=e.input[e.position],n=e.input[e.position+1];return t===`\r`&&n===` `?e.succeedOffset(2,void 0):e.fail(`\\r\\n`)})}static newline(){let e=`newline`;return new se(function(t){if(t.position>=t.input.length)return t.fail(e);let n=t.input[t.position];return n===` `?t.succeedOffset(1,void 0):n===`\r`?t.position+1e.reduce((e,t)=>n(t,e),t),e.many(),t)}static postfix(e,t,n){return P.sequenceMap((e,t)=>t.reduce((e,t)=>n(t,e),e),t,e.many())}static binaryRight(e,t,n){return P.sequenceMap((e,t)=>e.reverse().reduce((e,t)=>{let[r,i]=t;return n(r,i,e)},t),P.sequence(t,e.trim(this.optionalWhitespace())).many(),t)}static binaryLeft(e,t,n){return P.sequenceMap((e,t)=>t.reduce((e,t)=>{let[r,i]=t;return n(e,r,i)},e),t,P.sequence(e.trim(this.optionalWhitespace()),t).many())}static binaryRightRange(t,n,r){return P.sequenceMap((e,t,n)=>e.reverse().reduce((e,t)=>{let[i,a,o]=t;return r({from:i,to:n},a,o,e)},t),P.sequence(e.position(),n,t.trim(this.optionalWhitespace())).many(),n,e.position())}static binaryLeftRange(t,n,r){return P.sequenceMap((e,t,n)=>n.reduce((t,n)=>{let[i,a,o]=n;return r({from:e,to:o},t,i,a)},t),e.position(),n,P.sequence(t.trim(this.optionalWhitespace()),n,e.position()).many())}static func(e,t,n){let r=typeof e==`string`?P.string(e):e;return P.sequenceMap((e,t,r,i,a,o)=>n(e,i),r,P.string(`(`),this.optionalWhitespace(),t,this.optionalWhitespace(),P.string(`)`))}},se=class e{p;constructor(e){this.p=e}tryParse(e){let t=new ee(e,0),n=this.p(t);return n.success?n:{success:!1,value:void 0,furthest:t.latestError.position,expected:t.latestError.expected}}parse(e){let t=this.tryParse(e);if(t.success)return t.value;throw new ne(e,t)}or(e){let t=this;return P.or(t,e)}trim(e){return this.wrap(e,e)}trimString(e){return this.trim(P.string(e))}wrap(t,n){let r=this;return new e(function(e){let i=t.p(e);if(!i.success)return i;let a=r.p(e);if(!a.success)return a;let o=n.p(e);return o.success?a:o})}wrapString(e,t){return this.wrap(P.string(e),P.string(t))}then(t){let n=this;return new e(function(e){let r=n.p(e);if(!r.success)return r;let i=t.p(e);return i.success,i})}skip(t){let n=this;return new e(function(e){let r=n.p(e);if(!r.success)return r;let i=t.p(e);return i.success?r:i})}and(e){let t=this;return P.sequence(t,e)}many(){let t=this;return new e(function(e){let n=[];for(;;){let r=e.position,i=t.p(e);if(i.success){if(e.position===r)throw Error(`infinite loop in many() parser detected`);n.push(i.value)}else return e.position=r,{success:!0,value:n}}})}repeat(t,n){le(t,n);let r=this;return new e(function(e){let i=[],a=0;for(;a=t?{success:!0,value:i}:{success:!1,value:void 0}}return{success:!0,value:i}})}atMost(e){return this.repeat(0,e)}atLeast(e){return P.sequenceMap((e,t)=>e.concat(t),this.repeat(e,e),this.many())}separateBy(e){return P.separateBy(this,e)}separateByNotEmpty(e){return P.separateByNotEmpty(this,e)}result(e){return this.map(()=>e)}map(t){let n=this;return new e(function(e){let r=n.p(e);return r.success?{success:!0,value:t(r.value)}:r})}marker(){let e=this;return P.sequenceMap(function(e,t,n){return{value:t,range:{from:e,to:n}}},R.position(),e,R.position())}namedMarker(e){let t=this;return P.sequenceMap(function(t,n,r){return{value:n,name:e,range:{from:t,to:r}}},R.position(),t,R.position())}node(e){let t=this;return P.sequenceMap(function(t,n,r){return e(n,{from:t,to:r})},R.position(),t,R.position())}followedBy(e){return this.skip(de.followedBy(e))}notFollowedBy(e){return this.skip(de.notFollowedBy(e))}describe(t){typeof t==`string`&&(t=[t]);let n=this;return new e(function(e){let r=e.getAndClearLatestError(),i=n.p(e);return e.latestError!==void 0&&(e.latestError.expected=t),e.mergeLatestError(r),i})}box(t){let n=this;return new e(function(e){let r=e.getAndClearLatestError(),i=n.p(e);return e.latestError!==void 0&&(e.latestError.expected=[`(${e.latestError.expected.join(` or `)} as part of ${t})`]),e.mergeLatestError(r),i})}optional(e){return this.or(P.succeed(e))}chain(t){let n=this;return new e(function(e){let r=n.p(e);return r.success?t(r.value).p(e):r})}thenEof(){let t=this;return new e(function(e){let n=t.p(e);return n.success?e.atEOF()?n:e.fail(`eof`):n})}};function ce(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n=[...e];for(let e of t)n.includes(e)||n.push(e);return n}function le(e,t){if(tn.position){let e=n.input.slice(n.position,r);return n.succeedAt(r,e)}else return n.fail(t)})}},fe=function(e){return e.INLINE=`inline`,e.BLOCK=`block`,e}({}),pe=function(e){return e.INPUT=`INPUT`,e.VIEW=`VIEW`,e.JS_VIEW=`JS_VIEW`,e.TABLE=`TABLE`,e.BUTTON_GROUP=`BUTTON_GROUP`,e.BUTTON=`BUTTON`,e.EMBED=`EMBED`,e.EXCLUDED=`EXCLUDED`,e}({}),me=class{linePosition;constructor(e){this.linePosition=e}getPosition(){return this.linePosition}};function he(e){return e===`INPUT`||e===`VIEW`||e===`BUTTON_GROUP`}var z=function(e){return e.CRITICAL=`CRITICAL`,e.ERROR=`ERROR`,e.WARNING=`WARNING`,e}({}),ge=function(e){return e.INTERNAL=`MB_INTERNAL`,e.PARSING=`MB_PARSING`,e.BIND_TARGET=`MB_BIND_TARGET`,e.VALUE=`MB_VALUE`,e.ARGUMENT=`MB_ARGUMENT`,e.JS=`MB_JS`,e.EXPRESSION=`MB_EXPRESSION`,e.PUBLISH=`MB_PUBLISH`,e.VALIDATION=`MB_VALIDATION`,e.PARSINOM=`MB_PARSINOM`,e.EXAMPLE=`MB_EXAMPLE`,e.EMBED=`MB_EMBED`,e.BUTTON=`MB_BUTTON`,e.DEPENDENCY=`MB_DEPENDENCY`,e.OTHER=`OTHER`,e}({}),_e=class extends Error{errorLevel;effect;cause;tip;docs;context;positionContext;constructor(e){super(``),this.errorLevel=e.errorLevel,this.effect=e.effect,this.cause=e.cause,this.tip=e.tip,this.docs=e.docs,this.context=e.context,this.positionContext=e.positionContext,this.updateMessage()}updateMessage(){this.cause instanceof Error?this.message=`[${this.getErrorType()}] "${this.effect}" caused by error "${this.cause.message}"`:this.message=`[${this.getErrorType()}] "${this.effect}" caused by "${this.cause}"`}log(){console.log(this.message,this.stack,this.context)}},ve=class extends _e{getErrorType(){return`MB_INTERNAL`}},ye=class extends _e{getErrorType(){return`MB_PARSING`}},be=class extends _e{getErrorType(){return`MB_VALIDATION`}},xe=class extends _e{getErrorType(){return`MB_BIND_TARGET`}},Se=class extends _e{getErrorType(){return`MB_ARGUMENT`}},Ce=class extends _e{getErrorType(){return`MB_JS`}},we=class extends _e{getErrorType(){return`MB_EXPRESSION`}},Te=class extends _e{getErrorType(){return`MB_EXAMPLE`}},Ee=class extends _e{getErrorType(){return`MB_BUTTON`}},De=class extends _e{getErrorType(){return`MB_DEPENDENCY`}};function Oe(e,t){let n=e.thenEof().tryParse(t);if(n.success)return n.value;throw new ke(z.ERROR,`parsiNOM parser`,t,n)}var ke=class extends _e{str;parseFailure;source;constructor(e,t,n,r){super({errorLevel:e,effect:`Failed to parse. Check that your syntax is correct.`,cause:`expected ${r.expected.sort().join(` or `)}`}),this.str=n,this.parseFailure=r,this.source=t,this.updateMessage2()}getErrorType(){return ge.PARSINOM}updateMessage2(){this.cause instanceof Error?this.message=`[${this.getErrorType()}] "${this.effect}" caused by error "${this.cause.message}"\n`:this.message=`[${this.getErrorType()}] "${this.effect}" caused by "${this.cause}"\n`;let e=re(this.str,this.parseFailure.furthest),t=this.str.split(` `)[e.line-1]??``,n=`${e.line} | `;this.positionContext=`${n}${t}`,this.positionContext+=`\n${this.getUnderline(n.length,e.column)}\n`,this.message+=` `+this.positionContext}getUnderline(e,t){return` `.repeat(t+e-1)+`^ (${this.cause})`}},Ae=class extends _e{str;position;source;constructor(e,t,n,r,i,a){super({errorLevel:e,effect:`Failed to validate the result of the parser.`,cause:n,docs:a}),this.str=r,this.position=i,this.source=t,this.updateMessage2()}getErrorType(){return ge.VALIDATION}updateMessage2(){if(this.cause instanceof Error?this.message=`[${this.getErrorType()}] "${this.effect}" caused by error "${this.cause.message}"\n`:this.message=`[${this.getErrorType()}] "${this.effect}" caused by "${this.cause}"\n`,this.str&&this.position){let e=re(this.str,this.position.from),t=re(this.str,this.position.to),n=this.str.split(` `)[e.line-1]??``,r=`${e.line} | `;this.positionContext=`${r}${n}`,this.positionContext+=`\n${this.getUnderline(r.length,n.length,e,t)}\n`,this.message+=` `+this.positionContext}}getUnderline(e,t,n,r){if(this.position===void 0)return``;let i=` `.repeat(n.column+e-1),a=r.line===n.line?r.column:t+1;return i+`^`.repeat(Math.max(1,a-n.column))}},je=P.sequence(P.or(R.unicodeLetter(),P.oneOf(`_$`)),P.or(R.unicodeAlphanumeric(),P.oneOf(`-_$`)).many()).map(e=>e[0]+e[1].join(``)).describe(`identifier`),Me=P.sequenceMap((e,t)=>e+t.map(e=>e[0]+e[1]).join(``),je,P.sequence(R.optionalWhitespace(),je).many()).describe(`identifier with spaces`),Ne=P.string(`\\`).then(R.any()).map(e=>e===`'`?`'`:e===`\\`?`\\`:`\\`+e);function Pe(e){return P.or(Ne,P.noneOf(e+`\\`)).many().map(e=>e.join(``)).trim(P.string(e))}var Fe=Pe(`'`),Ie=Pe(`"`),Le=P.manyNotOf(`{}[]#^|:?`).box(`file path`);function Re(e,t){return{value:e,position:t}}function ze(e){if(e!==void 0)return typeof e==`string`?{value:e}:e}var Be=function(e){return e.OBJECT=`object`,e.ARRAY=`array`,e}({}),Ve=class{parent;access;child;constructor(e,t,n){this.parent=e,this.access=t,this.child=n}};function He(e,t){return e[t]}function Ue(e,t,n){e[t]=n}var We=class{type;prop;index;constructor(e,t){if(this.type=e,this.prop=e===`object`?t:``,this.index=e===`array`?Number(t):0,Number.isNaN(this.index))throw Error(`can not access array with non number index`)}get(e){if(this.type===`object`){if(typeof e!=`object`||!e)throw Error(`can not access property of non-object`);return new Ve(e,this,He(e,this.prop))}else{if(typeof e!=`object`||!e||!Array.isArray(e))throw Error(`can not access property of non-array`);return new Ve(e,this,e[this.index])}}set(e,t){if(this.type===`object`){if(typeof e!=`object`||!e)throw Error(`can not access property of non-object`);Ue(e,this.prop,t)}else{if(typeof e!=`object`||!e||!Array.isArray(e))throw Error(`can not access property of non-array`);e[this.index]=t}}create(e){if(this.type===`object`){if(typeof e!=`object`||!e)throw Error(`can not access property of non-object`);Ue(e,this.prop,void 0)}else{if(typeof e!=`object`||!e||!Array.isArray(e))throw Error(`can not access property of non-array`);e[this.index]=void 0}}toUnvalidatedPropAccess(){return this.type===`object`?{type:this.type,prop:{value:this.prop}}:{type:this.type,prop:{value:this.index.toString()}}}},Ge=je.node((e,t)=>({type:Be.OBJECT,prop:Re(e,t)})),Ke=P.or(R.digits().wrap(P.string(`[`),P.string(`]`)).node((e,t)=>({type:Be.ARRAY,prop:Re(e,t)})),Ie.wrap(P.string(`[`),P.string(`]`)).node((e,t)=>({type:Be.OBJECT,prop:Re(e,t)}))),qe=P.or(P.sequenceMap(e=>({storagePath:void 0,listenToChildren:!0,storageProp:e}),Ke.atLeast(1)),P.sequenceMap((e,t)=>({storagePath:void 0,listenToChildren:!0,storageProp:[e,...t]}),Ge,Ke.many())),Je=P.sequenceMap((e,t)=>[e,...t],Ge,Ke.many()),Ye=P.sequenceMap((e,t)=>(e.storageProp=e.storageProp.concat(t.flat()),e),qe,P.string(`.`).then(Je).many()),Xe=P.sequenceMap((e,t,n)=>(n.storageType=e,n.storagePath=t,n),je.describe(`storage type`).node(Re).skip(P.string(`^`).describe(`storage type separator "^"`)).optional(),Le.describe(`storage path`).node(Re).skip(P.string(`#`).describe(`storage/file path separator "#"`)).optional(),Ye.describe(`property path`)).box(`bind target`),Ze=P.regexp(/^[^()',]+/).describe(`any character except parentheses, single quotation marks and commas`),Qe=P.or(Fe,Ze).node(Re),$e=P.separateBy(Qe,P.string(`,`).describe(`argument value separator ","`).trim(R.optionalWhitespace())),et=P.sequenceMap((e,t)=>({name:e,value:t}),je.node(Re),$e.trim(R.optionalWhitespace()).wrap(P.string(`(`).describe(`argument value paren "("`),P.string(`)`).describe(`argument value paren ")"`)).optional([])),tt=P.separateBy(et,P.string(`,`).describe(`argument separator ","`).trim(R.optionalWhitespace())),nt=P.string(`\\`).then(R.any()).map(e=>e===`[`?`[`:e===`]`?`]`:e===`{`?`{`:e===`}`?`}`:e===`\\`?`\\`:`\\`+e),rt=P.sequenceMap((e,t)=>e+t.flat().join(``),P.manyNotOf(`{}[]\\`),P.sequence(nt,P.manyNotOf(`{}[]\\`)).many()).box(`View Field Content`),it=P.sequenceMap((e,t)=>[e,...t.flat()],rt,P.sequence(Xe.wrapString(`{`,`}`),rt).many()),at=P.sequenceMap((e,t,n)=>({viewFieldType:e,writeToBindTarget:n===void 0?void 0:n[1],arguments:t,templateDeclaration:void 0}),je.node(Re).trim(R.optionalWhitespace()).optional().describe(`input field type`),tt.trim(R.optionalWhitespace()).wrapString(`(`,`)`).trim(R.optionalWhitespace()).optional([]),P.sequence(P.string(`:`).trim(R.optionalWhitespace()),Xe).trim(R.optionalWhitespace()).optional()),ot=P.sequenceMap((e,t,n,r)=>r===void 0?{viewFieldType:void 0,writeToBindTarget:void 0,arguments:[],templateDeclaration:t}:(r.templateDeclaration=t,r),P.string(`VIEW`),it.wrapString(`[`,`]`),R.optionalWhitespace(),at.wrapString(`[`,`]`).optional(),R.eof()),st=P.sequenceMap((e,t,n,r)=>(t!==void 0&&(e.listenToChildren=!0),{bindTarget:e,name:r}),Xe.wrapString(`{`,`}`),P.string(` and children`).optional(),P.string(` as `),je),ct=P.sequenceMap((e,t,n,r)=>({bindTargetMappings:e,writeToBindTarget:t,hidden:n!==void 0,code:r}),st.separateBy(R.whitespace()).skip(R.whitespace()),P.string(`save to `).then(Xe.wrapString(`{`,`}`)).skip(R.whitespace()).optional(),P.string(`hidden`).skip(R.whitespace()).optional(),P.string(`---`).then(R.remaining())),lt=class{range;tokenClass;constructor(e,t){this.range=e,this.tokenClass=t}},ut=function(e){return e.IDENT=`ident`,e.CONTROL=`control`,e.STRING=`string`,e.KEYWORD=`keyword`,e.ERROR=`error`,e}({}),dt=class e{static sequence(...e){return P.sequenceMap((...e)=>e.flat(2).filter(e=>e!==void 0),...e)}static separateBy(t,n){return e.sequence(t,e.sequence(n,t).many()).optional([])}static highlight(e,t){return e.node((e,n)=>[new lt(n,t)])}static highlightStr(t,n){return e.highlight(P.string(t),n)}},ft=dt.highlight(je,ut.IDENT),pt=dt.highlight(je,ut.KEYWORD),mt=dt.highlightStr(`,`,ut.CONTROL),ht=dt.highlightStr(`(`,ut.CONTROL),gt=dt.highlightStr(`)`,ut.CONTROL),_t=dt.highlightStr(`[`,ut.CONTROL),vt=dt.highlightStr(`]`,ut.CONTROL),yt=dt.highlight(Fe,ut.STRING),bt=dt.highlight(Ze,ut.IDENT),xt=P.or(bt,yt),St=dt.separateBy(xt,mt.trim(R.optionalWhitespace())),Ct=dt.sequence(pt,dt.sequence(ht,St.trim(R.optionalWhitespace()),gt).optional()),wt=dt.separateBy(Ct,mt.trim(R.optionalWhitespace())),Tt=dt.sequence(dt.sequence(ft,dt.highlightStr(`^`,ut.CONTROL)).optional(),dt.sequence(dt.highlight(Le,ut.IDENT),dt.highlightStr(`#`,ut.CONTROL)).optional(),dt.highlight(Ye,ut.IDENT)),Et=dt.sequence(pt.trim(R.optionalWhitespace()),dt.sequence(ht,wt.trim(R.optionalWhitespace()),gt).trim(R.optionalWhitespace()).optional(),dt.sequence(dt.highlightStr(`:`,ut.CONTROL).trim(R.optionalWhitespace()),Tt).trim(R.optionalWhitespace()).optional()),Dt=dt.sequence(pt.trim(R.optionalWhitespace()).optional(),dt.sequence(ht,wt.trim(R.optionalWhitespace()),gt).trim(R.optionalWhitespace()).optional(),dt.sequence(dt.highlightStr(`:`,ut.CONTROL).trim(R.optionalWhitespace()),Tt).trim(R.optionalWhitespace()).optional()),Ot=P.or(dt.sequence(dt.highlightStr(`INPUT`,ut.CONTROL),_t,ft.trim(R.optionalWhitespace()),vt.skip(R.optionalWhitespace()),_t,Dt,vt),dt.sequence(dt.highlightStr(`INPUT`,ut.CONTROL),_t,Et,vt)),kt=dt.highlight(rt,ut.IDENT),At=dt.sequence(dt.highlightStr(`{`,ut.STRING),Tt,dt.highlightStr(`}`,ut.STRING)),jt=dt.sequence(kt,dt.sequence(At,kt).many()),Mt=dt.sequence(pt.trim(R.optionalWhitespace()).optional(),dt.sequence(ht,wt.trim(R.optionalWhitespace()).optional(),gt).trim(R.optionalWhitespace()).optional(),dt.sequence(dt.highlightStr(`:`,ut.CONTROL).trim(R.optionalWhitespace()),Tt).trim(R.optionalWhitespace()).optional()),Nt=dt.sequence(dt.highlightStr(`VIEW`,ut.CONTROL),_t,jt,vt,dt.sequence(_t.skip(R.optionalWhitespace()),Mt,vt).optional()),Pt=dt.sequence(dt.highlightStr(`BUTTON`,ut.CONTROL),_t,dt.separateBy(ft,mt.trim(R.optionalWhitespace())),vt),Ft=class{str;highlights;parsingError;constructor(e,t,n){this.str=e,this.highlights=t.filter(e=>e.range.from!==e.range.to),this.parsingError=n}getHighlights(){if(this.parsingError===void 0)return this.highlights;let e=this.parsingError.parseFailure.furthest;return[new lt({from:e,to:e+1},ut.ERROR)]}},It=class{mb;constructor(e){this.mb=e}highlightInputFieldDeclaration(e,t){return this.highlightWithParser(e,t,Ot)}highlightViewFieldDeclaration(e,t){return this.highlightWithParser(e,t,Nt)}highlightInlineButtonDeclaration(e,t){return this.highlightWithParser(e,t,Pt)}highlight(e,t,n){if(t===pe.INPUT)return this.highlightInputFieldDeclaration(e,n);if(t===pe.VIEW)return this.highlightViewFieldDeclaration(e,n);if(t===pe.BUTTON_GROUP)return this.highlightInlineButtonDeclaration(e,n);throw Error(`Unknown MDRCType ${t}`)}highlightBindTarget(e,t){return this.highlightWithParser(e,t,Tt)}highlightWithParser(e,t,n){try{return t?new Ft(e,Oe(n.trim(R.optionalWhitespace()).thenEof(),e)):new Ft(e,Oe(n.thenEof(),e))}catch(t){return t instanceof ke?new Ft(e,[],t):(console.error(t),new Ft(e,[]))}}},Lt=function(e){return e.DEFAULT=`default`,e.PRIMARY=`primary`,e.DESTRUCTIVE=`destructive`,e.PLAIN=`plain`,e}({}),B=function(e){return e.COMMAND=`command`,e.JS=`js`,e.OPEN=`open`,e.INPUT=`input`,e.SLEEP=`sleep`,e.TEMPLATER_CREATE_NOTE=`templaterCreateNote`,e.RUN_TEMPLATER_FILE=`runTemplaterFile`,e.UPDATE_METADATA=`updateMetadata`,e.CREATE_NOTE=`createNote`,e.REPLACE_IN_NOTE=`replaceInNote`,e.REGEXP_REPLACE_IN_NOTE=`regexpReplaceInNote`,e.REPLACE_SELF=`replaceSelf`,e.INSERT_INTO_NOTE=`insertIntoNote`,e.INLINE_JS=`inlineJS`,e}({}),Rt=class e{type;shiftKey;ctrlKey;altKey;constructor(e,t,n,r){this.type=e,this.shiftKey=t,this.ctrlKey=n,this.altKey=r}static fromMouseEvent(t,n){return new e(n,t.shiftKey,t.ctrlKey,t.altKey)}openInNewTab(){return this.type===`middle`||this.ctrlKey}},zt=function(e){return e.LEFT=`left`,e.MIDDLE=`middle`,e}({}),Bt=class{actionType;mb;constructor(e,t){this.actionType=e,this.mb=t}},Vt=class extends Bt{constructor(e){super(B.COMMAND,e)}async run(e,t,n,r,i){this.mb.internal.executeCommandById(t.command)}create(){return{type:B.COMMAND,command:``}}getActionLabel(){return`Run a command`}},Ht=class extends Bt{constructor(e){super(B.CREATE_NOTE,e)}async run(e,t,n,r,i){if(t.openIfAlreadyExists){let e=M(A(t.folderPath??``,t.fileName),`md`);if(await this.mb.file.exists(e)){await this.mb.file.open(e,``,!1);return}}await this.mb.file.create(t.folderPath??``,t.fileName,`md`,t.openNote??!1,i.openInNewTab())}create(){return{type:B.CREATE_NOTE,folderPath:`/`,fileName:`Untitled`,openNote:!0,openIfAlreadyExists:!1}}getActionLabel(){return`Create a new note`}},Ut=class extends Bt{constructor(e){super(B.INLINE_JS,e)}async run(e,t,n,r,i){if(!this.mb.getSettings().enableJs)throw new Ce({errorLevel:z.CRITICAL,effect:`Can't run button action that requires JS evaluation.`,cause:`JS evaluation is disabled in the plugin settings.`});let a={buttonConfig:structuredClone(e),args:structuredClone(t.args),buttonContext:structuredClone(r),click:structuredClone(i)};(await this.mb.internal.jsEngineRunCode(t.code,n,a))()}create(){return{type:B.INLINE_JS,code:`console.log("Hello world")`,args:{}}}getActionLabel(){return`Run JavaScript code`}},Wt=class extends Bt{constructor(e){super(B.INPUT,e)}async run(e,t,n,r,i){let a=this.mb.domHelpers.activeDocument,o=a.defaultView,s=a.activeElement;!o||!(s instanceof o.HTMLInputElement)||(s.setRangeText(t.str,s.selectionStart,s.selectionEnd,`end`),s.dispatchEvent(new o.Event(`input`,{bubbles:!0})))}create(){return{type:B.INPUT,str:``}}getActionLabel(){return`Insert text at cursor`}};function Gt(e){if(e===`+`)return`+`;if(e===`-`)return`-`;throw Error(`Invalid LineNumberOp: ${e}`)}function Kt(e){if(e===void 0||e===`+`)return 1;if(e===`-`)return-1;throw Error(`Invalid LineNumberOp: ${e}`)}var qt=class{literal;op;number;constructor(e,t,n){this.literal=e,this.op=t,this.number=n}evaluate(e){let t=this.resolveLiteral(e),n=Kt(this.op);return t!==void 0&&this.number!==void 0?t+this.number*n:this.number===void 0?t===void 0?0:t:this.number*n}resolveLiteral(e){if(this.literal!==void 0){if(this.literal in e)return e[this.literal];throw Error(`Error while evaluating line number expression: Literal "${this.literal}" not available.`)}}},Jt=P.sequenceMap((e,t)=>e===void 0?t:-t,P.string(`-`).optional(),P.or(P.sequenceMap((e,t,n)=>Number(e+t+n),R.digits(),P.string(`.`),R.digits()),R.digits().map(e=>Number(e)))).thenEof(),Yt=P.sequenceMap((e,t)=>e===void 0?t:-t,P.string(`-`).optional(),R.digits().map(e=>Number(e))).thenEof(),Xt=P.or(P.sequenceMap((e,t,n)=>new qt(e,Gt(t),n),je,P.or(P.string(`+`),P.string(`-`)).trim(R.optionalWhitespace()),Yt),je.map(e=>new qt(e,void 0,void 0)),Yt.map(e=>new qt(void 0,void 0,e))),Zt=class extends Bt{constructor(e){super(B.INSERT_INTO_NOTE,e)}async run(e,t,n,r,i){let a=t.templater?await this.mb.internal.evaluateTemplaterTemplate(this.mb.file.resolveFilePathLike(t.value),n):t.value,o=Oe(Xt,t.line.toString());await this.mb.file.atomicModify(n,e=>{let t=e.split(` `),n=this.mb.file.createLineNumberContext(e,r.position),i=o.evaluate(n);if(i<1||i>t.length)throw Error(`Line number out of bounds`);return t=[...t.slice(0,i-1),a,...t.slice(i-1)],t.join(` `)})}create(){return{type:B.INSERT_INTO_NOTE,line:0,value:`Some text`,templater:!1}}getActionLabel(){return`Insert text into the note`}},Qt=class extends Bt{constructor(e){super(B.JS,e)}async run(e,t,n,r,i){if(!this.mb.getSettings().enableJs)throw new Ce({errorLevel:z.CRITICAL,effect:`Can't run button action that requires JS evaluation.`,cause:`JS evaluation is disabled in the plugin settings.`});let a={buttonConfig:structuredClone(e),args:structuredClone(t.args),buttonContext:structuredClone(r),click:structuredClone(i)};(await this.mb.internal.jsEngineRunFile(t.file,n,a))()}create(){return{type:B.JS,file:``,args:{}}}getActionLabel(){return`Run a JavaScript file`}},$t=P.sequence(Le,P.or(P.string(`#`).then(P.manyNotOf(`[]#|:`)),P.string(`#`).result(void 0),P.succeed(void 0)),P.string(`|`).then(P.manyNotOf(`[]`)).optional()),en=P.or(P.sequenceMap((e,t)=>new nn(e!==void 0,t[0],t[1],t[2],!0),P.string(`!`).optional(),$t.wrapString(`[[`,`]]`)),P.sequenceMap((e,t,n)=>{let r=!D(n);return new nn(e!==void 0,n,void 0,t,r)},P.string(`!`).optional(),P.manyNotOf(`[]`).wrapString(`[`,`]`),P.manyNotOf(`()`).wrapString(`(`,`)`))),tn=P.separateBy(en,P.string(`,`).trim(R.optionalWhitespace())),nn=class e{isEmbed;target;block;alias;internal;constructor(e,t,n,r,i){this.isEmbed=e,this.target=t,this.block=n,this.alias=r,this.internal=i??!0}static fromUrl(t){return new e(!1,t.href,void 0,t.hostname,!1)}fullTarget(){return this.block?`${this.target}#${this.block}`:this.target}open(e,t,n){this.internal?e.file.open(this.fullTarget(),t,n):O(this.target)}toString(){let e=this.isEmbed?`!`:``;if(this.internal){let t=this.alias?`|${this.alias}`:``;return`${e}[[${this.fullTarget()}${t}]]`}else return`${e}[${this.alias??this.fullTarget()}](${this.fullTarget()})`}},rn=class e{static parseLink(e){return Oe(en.thenEof(),e)}static parseLinkList(e){return Oe(tn.thenEof(),e)}static isLink(e){return en.thenEof().tryParse(e).success}static urlToLink(e){return nn.fromUrl(e)}static parseLinkOrUrl(t){return D(t)?e.urlToLink(new URL(t)):e.parseLink(t)}static interpretAsLink(e){let t=en.thenEof().tryParse(e);if(t.success)return t.value;let n=$t.thenEof().tryParse(e);if(n.success)return new nn(!1,n.value[0],n.value[1],n.value[2],!0);if(D(e)){let t=new URL(e);return nn.fromUrl(t)}}},an=class extends Bt{constructor(e){super(B.OPEN,e)}async run(e,t,n,r,i){let a=i.openInNewTab()||(t.newTab??!1),o=rn.interpretAsLink(t.link);if(!o)throw Error(`Invalid link`);o.open(this.mb,n,a)}create(){return{type:B.OPEN,link:``,newTab:!0}}getActionLabel(){return`Open a link`}},on=class extends Bt{constructor(e){super(B.REGEXP_REPLACE_IN_NOTE,e)}async run(e,t,n,r,i){if(t.regexp===``)throw Error(`Regexp cannot be empty`);await this.mb.file.atomicModify(n,e=>e.replace(new RegExp(t.regexp,t.regexpFlags??`g`),t.replacement))}create(){return{type:B.REGEXP_REPLACE_IN_NOTE,regexp:`([A-Z])\\w+`,replacement:`Replacement text`,regexpFlags:`g`}}getActionLabel(){return`Replace text in note using regexp`}},sn=class extends Bt{constructor(e){super(B.REPLACE_IN_NOTE,e)}async run(e,t,n,r,i){let a=t.templater?await this.mb.internal.evaluateTemplaterTemplate(this.mb.file.resolveFilePathLike(t.replacement),n):t.replacement,o=Oe(Xt,t.fromLine.toString()),s=Oe(Xt,t.toLine.toString());await this.mb.file.atomicModify(n,e=>{let t=e.split(` `),n=this.mb.file.createLineNumberContext(e,r.position),i=o.evaluate(n),c=s.evaluate(n);if(i>c)throw Error(`From line (${i}) can't be greater than to line (${c})`);if(i<1)throw Error(`From line (${i}) can't smaller than 1.`);if(c>t.length)throw Error(`To line (${c}) can't greater than the file length ${t.length}.`);return t=[...t.slice(0,i-1),a,...t.slice(c)],t.join(` `)})}create(){return{type:B.REPLACE_IN_NOTE,fromLine:0,toLine:0,replacement:`Replacement text`,templater:!1}}getActionLabel(){return`Replace text in note`}},cn=class extends Bt{constructor(e){super(B.REPLACE_SELF,e)}async run(e,t,n,r,i){if(r.isInline)throw Error(`Replace self action not supported for inline buttons`);if(r.position===void 0)throw Error(`Position of the button in the note is unknown`);if(r.position.lineStart>r.position.lineEnd)throw Error(`Position of the button in the note is invalid`);let a=r.position,o=t.templater?await this.mb.internal.evaluateTemplaterTemplate(this.mb.file.resolveFilePathLike(t.replacement),n):t.replacement;await this.mb.file.atomicModify(n,e=>{let t=e.split(` `);if(a.lineStart<0||a.lineEnd>t.length)throw Error(`Position of the button in the note is out of bounds`);return t=[...t.slice(0,a.lineStart),o,...t.slice(a.lineEnd+1)],t.join(` `)})}create(){return{type:B.REPLACE_SELF,replacement:`Replacement text`,templater:!1}}getActionLabel(){return`Replace button with text`}},ln=class extends Bt{constructor(e){super(B.RUN_TEMPLATER_FILE,e)}async run(e,t,n,r,i){let a=this.mb.file.resolveFilePathLike(t.templateFile);await this.mb.internal.evaluateTemplaterTemplate(a,n)}create(){return{type:B.RUN_TEMPLATER_FILE,templateFile:``}}getActionLabel(){return`Run a templater file`}},un=class extends Bt{constructor(e){super(B.SLEEP,e)}async run(e,t,n,r,i){await new Promise(e=>window.setTimeout(e,t.ms))}create(){return{type:B.SLEEP,ms:0}}getActionLabel(){return`Sleep for some time`}},dn=class extends Bt{constructor(e){super(B.TEMPLATER_CREATE_NOTE,e)}async run(e,t,n,r,i){if(t.openIfAlreadyExists&&t.fileName){let e=M(A(t.folderPath??``,t.fileName),`md`);if(await this.mb.file.exists(e)){await this.mb.file.open(e,``,!1);return}}await this.mb.internal.createNoteWithTemplater(t.templateFile,t.folderPath,t.fileName,t.openNote,i.openInNewTab())}create(){return{type:B.TEMPLATER_CREATE_NOTE,templateFile:``,folderPath:`/`,fileName:``,openNote:!0,openIfAlreadyExists:!1}}getActionLabel(){return`Create a new note using Templater`}};function fn(e){if(e.toLowerCase()===`null`)return null;if(e===`true`)return!0;if(e===`false`)return!1;{let t=Jt.tryParse(e);return t.success?t.value:e}}function pn(e){return e==null?``:typeof e==`string`?e:typeof e==`boolean`?e?`true`:`false`:e.toString()}function mn(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`}function hn(e){if(e!=null){if(mn(e))return[e];if(typeof e==`object`&&Array.isArray(e))return e.filter(e=>mn(e))}}function gn(e){if(typeof e==`number`)return e;if(typeof e==`string`){let t=Jt.tryParse(e);if(t.success)return t.value}}function _n(e){return mn(e)?pn(e):void 0}function vn(e){return mn(e)?e:void 0}function yn(e,t){return Array.isArray(e)?e.map(e=>bn(e,t)).filter(e=>e!==``).join(`, `):bn(e,t)}function bn(e,t){return e==null?t?``:`null`:typeof e==`function`?``:typeof e==`object`||Array.isArray(e)?JSON.stringify(e):e.toString()}function xn(e,t){return Array.isArray(e)?e.map(e=>Sn(e,t)).filter(e=>e!==``):Sn(e,t)}function Sn(e,t){return typeof e==`string`?rn.isLink(e)?rn.parseLink(e):D(e)?rn.urlToLink(new URL(e)):e:bn(e,t)}var Cn=class extends Bt{constructor(e){super(B.UPDATE_METADATA,e)}async run(e,t,n,r,i){let a=this.mb.bindTargetParser.fromStringAndValidate(t.bindTarget,n);if(t.evaluate){if(!this.mb.getSettings().enableJs)throw new Ce({errorLevel:z.CRITICAL,effect:`Can't run button action that requires JS evaluation.`,cause:`JS evaluation is disabled in the plugin settings.`});let e=this.mb.api.getMetadata(a),r=await this.mb.internal.jsEngineExecuteCustom(t.value,{x:e,getMetadata:e=>this.mb.api.getMetadata(this.mb.api.parseBindTarget(e,n))},!0);this.mb.api.setMetadata(a,r)}else this.mb.api.setMetadata(a,fn(t.value))}create(){return{type:B.UPDATE_METADATA,bindTarget:``,evaluate:!1,value:``}}getActionLabel(){return`Update metadata`}},wn=class{mb;actionContexts;constructor(e){this.mb=e,this.actionContexts={[B.COMMAND]:new Vt(e),[B.OPEN]:new an(e),[B.JS]:new Qt(e),[B.INPUT]:new Wt(e),[B.SLEEP]:new un(e),[B.TEMPLATER_CREATE_NOTE]:new dn(e),[B.UPDATE_METADATA]:new Cn(e),[B.CREATE_NOTE]:new Ht(e),[B.REPLACE_IN_NOTE]:new sn(e),[B.REPLACE_SELF]:new cn(e),[B.REGEXP_REPLACE_IN_NOTE]:new on(e),[B.INSERT_INTO_NOTE]:new Zt(e),[B.INLINE_JS]:new Ut(e),[B.RUN_TEMPLATER_FILE]:new ln(e)}}createDefaultButtonConfig(){return{label:`This is a button`,icon:``,style:Lt.DEFAULT,class:``,cssStyle:``,backgroundImage:``,tooltip:``,id:``,hidden:!1,actions:[]}}async runButtonActions(e,t,n,r){try{if(e.action)await this.runAction(e,e.action,t,n,r);else if(e.actions)for(let i of e.actions)await this.runAction(e,i,t,n,r);else console.warn(`meta-bind | ButtonMDRC >> no action defined`)}catch(e){console.warn(`meta-bind | ButtonMDRC >> error while running action`,e),this.mb.internal.showNotice(`meta-bind | Error while running button action. Check the console for details.`)}}createDefaultAction(e){return this.actionContexts[e].create()}async runAction(e,t,n,r,i){let a=t.type;await this.actionContexts[a].run(e,t,n,r,i)}getActionLabel(e){return this.actionContexts[e].getActionLabel()}},Tn=class{errors;otherError;subject;constructor(e){this.subject=e,this.errors=[]}add(e){e instanceof Error?(e instanceof _e?this.errors.push(e):this.otherError=e,console.warn(e)):(console.trace(``),console.warn(`[MB_ERROR_CONTAINER] received invalid error type`,e))}merge(e){return this.errors=this.errors.concat(e.errors),e.otherError&&(this.otherError=e.otherError),this}hasErrors(){if(this.otherError)return!0;for(let e of this.errors)if(e.errorLevel===z.ERROR||e.errorLevel===z.CRITICAL)return!0;return!1}hasCriticalErrors(){if(this.otherError)return!0;for(let e of this.errors)if(e.errorLevel===z.CRITICAL)return!0;return!1}hasWarnings(){for(let e of this.errors)if(e.errorLevel===z.WARNING)return!0;return!1}isEmpty(){return this.errors.length===0&&!this.otherError}getErrors(){let e=this.errors.filter(e=>e.errorLevel===z.ERROR||e.errorLevel===z.CRITICAL);return this.otherError?e.concat([this.otherError]):e}getWarnings(){return this.errors.filter(e=>e.errorLevel===z.WARNING)}},En=class{value;count;constructor(e){this.value=e,this.count=1}getValue(){return this.value}increment(){return this.count+=1,this.count}decrement(){return--this.count,this.count}getCount(){return this.count}isEmpty(){return this.count===0}},Dn=class{mb;buttons;buttonLoadListeners;buttonTemplates;constructor(e){this.mb=e,this.buttons=new Map,this.buttonLoadListeners=new Map,this.buttonTemplates=new Map}setButtonTemplates(e){let t=new Set,n=new Tn(`ButtonManager`);this.buttonTemplates.clear();for(let r of e){let e;try{e=this.mb.buttonParser.validateConfig(r),Object.assign(r,e)}catch(e){n.add(e);continue}e.id===void 0||e.id===``?n.add(new Ee({errorLevel:z.ERROR,cause:`Button with label "${e.label}" has no id, but button templates must have an id.`,effect:`Button templates could not be saved.`})):t.has(e.id)?n.add(new Ee({errorLevel:z.ERROR,cause:`Button id "${e.id}" is not unique. The same id is used by multiple buttons.`,effect:`Button templates could not be saved.`})):(t.add(e.id),this.buttonTemplates.set(e.id,e))}return n.hasErrors()&&this.buttonTemplates.clear(),n}registerButtonLoadListener(e,t,n){let r=this.getButton(e,t);r&&n(r),this.buttonLoadListeners.has(e)||this.buttonLoadListeners.set(e,new Map);let i=this.buttonLoadListeners.get(e);i.has(t)||i.set(t,new Map);let a=i.get(t),o=E();return a.set(o,n),()=>this.removeButtonLoadListener(e,t,o)}notifyButtonLoadListeners(e,t){let n=this.getButton(e,t);if(!n)throw Error(`ButtonManager | button with id ${t} does not exist`);let r=this.buttonLoadListeners.get(e);if(!r)return;let i=r.get(t);if(i)for(let[e,t]of i)t(n)}removeButtonLoadListener(e,t,n){let r=this.buttonLoadListeners.get(e);if(!r)return;let i=r.get(t);i&&(i.delete(n),i.size===0&&r.delete(t),r.size===0&&this.buttonLoadListeners.delete(e))}addButton(e,t){if(t.id===void 0||t.id===``)throw Error(`ButtonManager | button id is undefined`);if(this.buttonTemplates.has(t.id))throw Error(`ButtonManager | button with id "${t.id}" already exists in the button templates`);this.buttons.has(e)||this.buttons.set(e,new Map),this.buttons.get(e).set(t.id,new En(t)),this.notifyButtonLoadListeners(e,t.id)}getButton(e,t){if(this.buttonTemplates.has(t))return this.buttonTemplates.get(t);let n=this.buttons.get(e);if(n)return n.get(t)?.getValue()}removeButton(e,t){let n=this.buttons.get(e);n&&(n.get(t)?.decrement(),n.get(t)?.isEmpty()&&n.delete(t),n.size===0&&this.buttons.delete(e))}},On=function(e){return e.TOGGLE=`toggle`,e.SLIDER=`slider`,e.TEXT=`text`,e.TEXT_AREA=`textArea`,e.SELECT=`select`,e.MULTI_SELECT=`multiSelect`,e.DATE=`date`,e.TIME=`time`,e.DATE_PICKER=`datePicker`,e.NUMBER=`number`,e.SUGGESTER=`suggester`,e.EDITOR=`editor`,e.IMAGE_SUGGESTER=`imageSuggester`,e.PROGRESS_BAR=`progressBar`,e.INLINE_SELECT=`inlineSelect`,e.LIST=`list`,e.LIST_SUGGESTER=`listSuggester`,e.INLINE_LIST_SUGGESTER=`inlineListSuggester`,e.INLINE_LIST=`inlineList`,e.IMAGE_LIST_SUGGESTER=`imageListSuggester`,e.DATE_TIME=`dateTime`,e.INVALID=`invalid`,e}({}),kn=function(e){return e.CLASS=`class`,e.ADD_LABELS=`addLabels`,e.MIN_VALUE=`minValue`,e.MAX_VALUE=`maxValue`,e.STEP_SIZE=`stepSize`,e.OPTION=`option`,e.TITLE=`title`,e.OPTION_QUERY=`optionQuery`,e.SHOWCASE=`showcase`,e.ON_VALUE=`onValue`,e.OFF_VALUE=`offValue`,e.DEFAULT_VALUE=`defaultValue`,e.PLACEHOLDER=`placeholder`,e.USE_LINKS=`useLinks`,e.LIMIT=`limit`,e.MULTI_LINE=`multiLine`,e.ALLOW_OTHER=`allowOther`,e.INVALID=`invalid`,e}({}),An={toggle:{type:`toggle`,allowInBlock:!0,allowInline:!0},slider:{type:`slider`,allowInBlock:!0,allowInline:!0},text:{type:`text`,allowInBlock:!0,allowInline:!0},textArea:{type:`textArea`,allowInBlock:!0,allowInline:!0},select:{type:`select`,allowInBlock:!0,allowInline:!1},multiSelect:{type:`multiSelect`,allowInBlock:!0,allowInline:!1},date:{type:`date`,allowInBlock:!0,allowInline:!0},time:{type:`time`,allowInBlock:!0,allowInline:!0},datePicker:{type:`datePicker`,allowInBlock:!0,allowInline:!0},number:{type:`number`,allowInBlock:!0,allowInline:!0},suggester:{type:`suggester`,allowInBlock:!0,allowInline:!0},editor:{type:`editor`,allowInBlock:!0,allowInline:!1},imageSuggester:{type:`imageSuggester`,allowInBlock:!0,allowInline:!0},progressBar:{type:`progressBar`,allowInBlock:!0,allowInline:!1},inlineSelect:{type:`inlineSelect`,allowInBlock:!0,allowInline:!0},list:{type:`list`,allowInBlock:!0,allowInline:!1},listSuggester:{type:`listSuggester`,allowInBlock:!0,allowInline:!1},inlineListSuggester:{type:`inlineListSuggester`,allowInBlock:!0,allowInline:!0},inlineList:{type:`inlineList`,allowInBlock:!0,allowInline:!0},imageListSuggester:{type:`imageListSuggester`,allowInBlock:!0,allowInline:!1},dateTime:{type:`dateTime`,allowInBlock:!0,allowInline:!0},invalid:{type:`invalid`,allowInBlock:!1,allowInline:!1}},jn=function(e){return e.TRUE=`true`,e.PARTIAL=`partial`,e.FALSE=`false`,e}({}),Mn={addLabels:{type:`addLabels`,allowedFieldTypes:[`slider`,`progressBar`],values:[[],[{name:`value`,allowed:[`true`,`false`],description:``}]],allowMultiple:!1},class:{type:`class`,allowedFieldTypes:[],values:[[{name:`className`,allowed:[],description:`the name of the css class to add`}]],allowMultiple:!0},defaultValue:{type:`defaultValue`,allowedFieldTypes:[],values:[[{name:`value`,allowed:[],description:``}]],allowMultiple:!1},maxValue:{type:`maxValue`,allowedFieldTypes:[`slider`,`progressBar`],values:[[{name:`value`,allowed:[`number`],description:`the maximally allowed value`}]],allowMultiple:!1},minValue:{type:`minValue`,allowedFieldTypes:[`slider`,`progressBar`],values:[[{name:`value`,allowed:[`number`],description:`the minimally allowed value`}]],allowMultiple:!1},stepSize:{type:`stepSize`,allowedFieldTypes:[`slider`,`progressBar`],values:[[{name:`value`,allowed:[`number`],description:`the step size for sliders`}]],allowMultiple:!1},offValue:{type:`offValue`,allowedFieldTypes:[`toggle`],values:[[{name:`value`,allowed:[],description:`the value for the off state`}]],allowMultiple:!1},onValue:{type:`onValue`,allowedFieldTypes:[`toggle`],values:[[{name:`value`,allowed:[],description:`the value for the off state`}]],allowMultiple:!1},option:{type:`option`,allowedFieldTypes:[`select`,`multiSelect`,`suggester`,`imageSuggester`,`inlineSelect`,`listSuggester`,`inlineListSuggester`,`imageListSuggester`],values:[[{name:`value`,allowed:[],description:`the value and display name of the option`}],[{name:`value`,allowed:[],description:`the value of the option`},{name:`name`,allowed:[],description:`the display name of the option`}]],allowMultiple:!0},optionQuery:{type:`optionQuery`,allowedFieldTypes:[`suggester`,`imageSuggester`,`listSuggester`,`inlineListSuggester`,`imageListSuggester`],values:[[{name:`value`,allowed:[],description:`the query for options`}]],allowMultiple:!0},placeholder:{type:`placeholder`,allowedFieldTypes:[`text`,`textArea`,`number`,`list`,`inlineList`],values:[[{name:`value`,allowed:[],description:``}]],allowMultiple:!1},showcase:{type:`showcase`,allowedFieldTypes:[],values:[[],[{name:`value`,allowed:[`true`,`false`],description:``}]],allowMultiple:!1},title:{type:`title`,allowedFieldTypes:[],values:[[{name:`value`,allowed:[],description:``}]],allowMultiple:!1},useLinks:{type:`useLinks`,allowedFieldTypes:[`suggester`,`listSuggester`,`inlineListSuggester`],values:[[],[{name:`value`,allowed:[`true`,`partial`,`false`],description:``}]],allowMultiple:!1},limit:{type:`limit`,allowedFieldTypes:[`text`,`textArea`,`list`,`inlineList`],values:[[{name:`value`,allowed:[`number`],description:`a character limit for text fields`}]],allowMultiple:!1},multiLine:{type:`multiLine`,allowedFieldTypes:[`list`],values:[[],[{name:`value`,allowed:[`true`,`false`],description:``}]],allowMultiple:!1},allowOther:{type:`allowOther`,allowedFieldTypes:[`suggester`,`listSuggester`,`inlineListSuggester`],values:[[],[{name:`value`,allowed:[`true`,`false`],description:``}]],allowMultiple:!1},invalid:{type:`invalid`,allowedFieldTypes:[],values:[[]],allowMultiple:!0}},Nn=function(e){return e.MATH=`math`,e.TEXT=`text`,e.LINK=`link`,e.IMAGE=`image`,e.INVALID=`invalid`,e}({}),Pn=function(e){return e.RENDER_MARKDOWN=`renderMarkdown`,e.HIDDEN=`hidden`,e.CLASS=`class`,e.INVALID=`invalid`,e}({}),Fn={renderMarkdown:{type:`renderMarkdown`,allowedFieldTypes:[`text`],values:[[],[{name:`value`,allowed:[`true`,`false`],description:``}]],allowMultiple:!1},hidden:{type:`hidden`,allowedFieldTypes:[],values:[[],[{name:`value`,allowed:[`true`,`false`],description:``}]],allowMultiple:!1},class:{type:`class`,allowedFieldTypes:[],values:[[{name:`className`,allowed:[],description:`the name of the css class to add`}]],allowMultiple:!0},invalid:{type:`invalid`,allowedFieldTypes:[],values:[[]],allowMultiple:!0}},In=Array.isArray,Ln=Array.prototype.indexOf,Rn=Array.prototype.includes,zn=Array.from,Bn=Object.defineProperty,Vn=Object.getOwnPropertyDescriptor,Hn=Object.getOwnPropertyDescriptors,Un=Object.prototype,Wn=Array.prototype,Gn=Object.getPrototypeOf,Kn=Object.isExtensible,qn=()=>{};function Jn(e){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}var Xn=1024,Zn=2048,Qn=4096,$n=8192,er=16384,tr=32768,nr=1<<25,rr=65536,ir=1<<19,ar=1<<20,or=1<<25,sr=65536,cr=1<<21,lr=1<<22,ur=1<<23,dr=Symbol(`$state`),fr=Symbol(`legacy props`),pr=Symbol(``),mr=Symbol(`attributes`),hr=Symbol(`class`),gr=Symbol(`style`),_r=Symbol(`text`),vr=Symbol(`form reset`),yr=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},br=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function xr(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function Sr(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Cr(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function wr(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Tr(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Er(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Dr(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Or(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function kr(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ar(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function jr(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Mr(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Nr={},Pr=Symbol(`uninitialized`),Fr=`http://www.w3.org/1999/xhtml`;function Ir(){console.warn(`https://svelte.dev/e/derived_inert`)}function Lr(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Rr(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function zr(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var Br=!1;function Vr(e){Br=e}var Hr;function Ur(e){if(e===null)throw Lr(),Nr;return Hr=e}function Wr(){return Ur(Oa(Hr))}function V(e){if(Br){if(Oa(Hr)!==null)throw Lr(),Nr;Hr=e}}function Gr(e=1){if(Br){for(var t=e,n=Hr;t--;)n=Oa(n);Hr=n}}function Kr(e=!0){for(var t=0,n=Hr;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else (r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=Oa(n);e&&n.remove(),n=i}}function qr(e){if(!e||e.nodeType!==8)throw Lr(),Nr;return e.data}function Jr(e){return e===this.v}function Yr(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Xr(e){return!Yr(e,this.v)}var Zr=!1,Qr=!1,$r=[];function ei(e,t=!1,n=!1){return ti(e,new Map,``,$r,null,n)}function ti(e,t,n,r,i=null,a=!1){if(typeof e==`object`&&e){var o=t.get(e);if(o!==void 0)return o;if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);if(In(e)){var s=Array(e.length);t.set(e,s),i!==null&&t.set(i,s);for(var c=0;c{t===si&&ci()})}si.push(e)}function ui(){for(;si.length>0;)ci()}function di(e){var t=vo;if(t===null)return ho.f|=ur,e;if(!(t.f&32768)&&!(t.f&4))throw e;fi(e,t)}function fi(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}var pi=~(Zn|Qn|Xn);function mi(e,t){e.f=e.f&pi|t}function hi(e){e.f&512||e.deps===null?mi(e,Xn):mi(e,Qn)}function gi(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=sr,gi(t.deps))}function _i(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),gi(e.deps),mi(e,Xn)}var vi=!1,yi=!1;function bi(e){var t=yi;try{return yi=!1,[e(),yi]}finally{yi=t}}function xi(e){let t=0,n=ua(0),r;return()=>{Ha()&&(W(n),Ya(()=>(t===0&&(r=Bo(()=>e(()=>ga(n)))),t+=1,()=>{li(()=>{--t,t===0&&(r?.(),r=void 0,ga(n))})})))}}var Si=rr|ir;function Ci(e,t,n,r){new wi(e,t,n,r)}var wi=class{parent;is_pending=!1;transform_error;#e;#t=Br?Hr:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=xi(()=>(this.#m=ua(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=vo;t.b=this,t.f|=128,n(e)},this.parent=vo.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Za(()=>{if(Br){let e=this.#t;Wr();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},Si),Br&&(this.#e=Hr)}#g(){try{this.#a=Qa(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=Qa(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=Qa(()=>e(this.#e)),li(()=>{var e=this.#c=document.createDocumentFragment(),t=Ea();e.append(t),this.#a=this.#x(()=>Qa(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,ao(this.#o,()=>{this.#o=null}),this.#b(Vi))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=Qa(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();lo(this.#a,e);let t=this.#n.pending;this.#o=Qa(()=>t(this.#e))}else this.#b(Vi)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){_i(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=vo,n=ho,r=ni;yo(this.#i),_o(this.#i),ri(this.#i.ctx);try{return Zi.ensure(),e()}catch(e){return di(e),null}finally{yo(t),_o(n),ri(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&ao(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,li(()=>{this.#d=!1,this.#m&&ma(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),W(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;Vi?.is_fork?(this.#a&&Vi.skip_effect(this.#a),this.#o&&Vi.skip_effect(this.#o),this.#s&&Vi.skip_effect(this.#s),Vi.oncommit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(no(this.#a),null),this.#o&&=(no(this.#o),null),this.#s&&=(no(this.#s),null),Br&&(Ur(this.#t),Gr(),Ur(Kr()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){zr();return}r=!0,i&&Mr(),this.#s!==null&&ao(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){fi(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return Qa(()=>{var t=vo;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return fi(e,this.#i.parent),null}}))};li(()=>{var t;try{t=this.transform_error(e)}catch(e){fi(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>fi(e,this.#i&&this.#i.parent)):o(t)})}};function Ti(e,t,n,r){let i=oi()?ki:Ni;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=vo,c=Ei(),l=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function u(e){if(!(s.f&16384)){c();try{r([...o,...e])}catch(e){fi(e,s)}Di()}}var d=Oi();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>ji(e))).then(u).catch(e=>fi(e,s)).finally(d)}l?l.then(()=>{c(),f(),Di()}):f()}function Ei(){var e=vo,t=ho,n=ni,r=Vi;return function(i=!0){yo(e),_o(t),ri(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Di(e=!0){yo(null),_o(null),ri(null),e&&Vi?.deactivate()}function Oi(){var e=vo,t=e.b,n=Vi,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function ki(e){var t=2|Zn;return vo!==null&&(vo.f|=ir),{ctx:ni,deps:null,effects:null,equals:Jr,f:t,fn:e,reactions:null,rv:0,v:Pr,wv:0,parent:vo,ac:null}}var Ai=Symbol(`obsolete`);function ji(e,t,n){let r=vo;r===null&&Sr();var i=void 0,a=ua(Pr),o=!ho,s=new Set;return Ja(()=>{var t=vo,n=Yn();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==yr&&n.reject(e)}).finally(Di)}catch(e){n.reject(e),Di()}var c=Vi;if(o){if(t.f&32768)var l=Oi();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(Ai);else for(let e of s.values())e.reject(Ai);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Ai&&(c.activate(),t?(a.f|=ur,ma(a,t)):(a.f&8388608&&(a.f^=ur),ma(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),Ua(()=>{for(let e of s)e.reject(Ai)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function Mi(e){let t=ki(e);return Zr||xo(t),t}function Ni(e){let t=ki(e);return t.equals=Xr,t}function Pi(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;nthis.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)mi(r,Zn),t(r);for(r of n.m)mi(r,Qn),t(r)}this.#p.add(e)}#g(){this.#e=!0,Yi++>1e3&&(this.#S(),$i());for(let e of this.#u)this.#d.delete(e),mi(e,Zn),this.schedule(e);for(let e of this.#d)mi(e,Qn),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=qi=[],r=[],i=Ji=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw oa(e),this.#h()||this.discard(),t}if(Vi=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(qi=null,Ji=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)aa(e,t);i.length>0&&Vi.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),Hi=this,ta(r),ta(n),Hi=null,this.#s?.resolve();var s=Vi;if(this.#a===0&&(this.#c.length===0||s!==null)&&(this.#S(),Zr&&(this.#x(),Vi=s)),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=Xn;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=Xn:i&4?t.push(r):Zr&&i&16777224?n.push(r):jo(r)&&(i&16&&this.#d.add(r),Io(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#v(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#y(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null)for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),mi(i,Zn),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),Vi=this,this.#g()}#b(e){for(var t=0;t!u.current.get(e)[1]);if(!(!u.#e||r.length===0)){var i=r.filter(e=>!this.current.has(e));if(i.length===0)e&&u.discard();else if(t.length>0){if(e)for(let e of this.#p)u.unskip_effect(e,e=>{e.f&4194320?u.schedule(e):u.#b([e])});u.activate();var a=new Set,o=new Map;for(var s of t)na(s,i,a,o);o=new Map;var c=[...u.current].filter(([e,t])=>{let n=this.current.get(e);return n?n[0]!==t[0]||n[1]!==t[1]:!0}).map(([e])=>e);if(c.length>0)for(let e of this.#l)!(e.f&155648)&&ra(e,c,o)&&(e.f&4194320?(mi(e,Zn),u.schedule(e)):u.#u.add(e));if(u.#c.length>0&&!u.#m){u.apply();for(var l of u.#c)u.#_(l,[],[]);u.#c=[]}u.deactivate()}}}}increment(e,t){if(this.#a+=1,e){let e=this.#o.get(t)??0;this.#o.set(t,e+1)}}decrement(e,t){if(--this.#a,e){let e=this.#o.get(t)??0;e===1?this.#o.delete(t):this.#o.set(t,e-1)}this.#m||(this.#m=!0,li(()=>{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=Yn()).promise}static ensure(){if(Vi===null){let t=Vi=new e;!Ki&&!Gi&&li(()=>{t.#e||t.flush()})}return Vi}apply(){if(!Zr||!this.is_fork&&this.#t===null&&this.#n===null){Ui=null;return}Ui=new Map;for(let[e,[t]]of this.current)Ui.set(e,t);for(let t=zi;t!==null;t=t.#n)if(!(t===this||t.is_fork)){var e=!1;if(t.id0)){ca.clear();for(let e of ea){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)ea.has(n)&&(ea.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Io(n)}}ea.clear()}}ea=null}}function na(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?na(i,t,n,r):e&4194320&&!(e&2048)&&ra(i,t,r)&&(mi(i,Zn),ia(i))}}function ra(e,t,n){let r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(let r of e.deps){if(Rn.call(t,r))return!0;if(r.f&2&&ra(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function ia(e){Vi.schedule(e)}function aa(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),mi(e,Xn);for(var n=e.first;n!==null;)aa(n,t),n=n.next}}function oa(e){mi(e,Xn);for(var t=e.first;t!==null;)oa(t),t=t.next}var sa=new Set,ca=new Map,la=!1;function ua(e,t){return{f:0,v:e,reactions:null,equals:Jr,rv:0,wv:0}}function da(e,t){let n=ua(e,t);return xo(n),n}function fa(e,t=!1,n=!0){let r=ua(e);return t||(r.equals=Xr),Qr&&n&&ni!==null&&ni.l!==null&&(ni.l.s??=[]).push(r),r}function pa(e,t,n=!1){return ho!==null&&(!go||ho.f&131072)&&oi()&&ho.f&4325394&&(bo===null||!bo.has(e))&&jr(),ma(e,n?va(t):t,Ji)}function ma(e,t,n=null){if(!e.equals(t)){ca.set(e,po?t:e.v);var r=Zi.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&Fi(t),Ui===null&&hi(t)}e.wv=Ao(),_a(e,Zn,n),oi()&&vo!==null&&vo.f&1024&&!(vo.f&96)&&(wo===null?To([e]):wo.push(e)),!r.is_fork&&sa.size>0&&!la&&ha()}return t}function ha(){la=!1;for(let e of sa){e.f&1024&&mi(e,Qn);let t;try{t=jo(e)}catch{t=!0}t&&Io(e)}sa.clear()}function ga(e){pa(e,e.v+1)}function _a(e,t,n){var r=e.reactions;if(r!==null)for(var i=oi(),a=r.length,o=0;o{if(Oo===o)return e();var t=ho,n=Oo;_o(null),ko(o);var r=e();return _o(t),ko(n),r};return r&&n.set(`length`,da(e.length,a)),new Proxy(e,{defineProperty(e,t,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&kr();var i=n.get(t);return i===void 0?s(()=>{var e=da(r.value,a);return n.set(t,e),e}):pa(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=s(()=>da(Pr,a));n.set(t,e),ga(i)}}else pa(r,Pr),ga(i);return!0},get(t,r,i){if(r===dr)return e;var o=n.get(r),c=r in t;if(o===void 0&&(!c||Vn(t,r)?.writable)&&(o=s(()=>da(va(c?t[r]:Pr),a)),n.set(r,o)),o!==void 0){var l=W(o);return l===Pr?void 0:l}return Reflect.get(t,r,i)},getOwnPropertyDescriptor(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r&&`value`in r){var i=n.get(t);i&&(r.value=W(i))}else if(r===void 0){var a=n.get(t),o=a?.v;if(a!==void 0&&o!==Pr)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return r},has(e,t){if(t===dr)return!0;var r=n.get(t),i=r!==void 0&&r.v!==Pr||Reflect.has(e,t);return(r!==void 0||vo!==null&&(!i||Vn(e,t)?.writable))&&(r===void 0&&(r=s(()=>da(i?va(e[t]):Pr,a)),n.set(t,r)),W(r)===Pr)?!1:i},set(e,t,o,c){var l=n.get(t),u=t in e;if(r&&t===`length`)for(var d=o;dda(Pr,a)),n.set(d+``,f)):pa(f,Pr)}if(l===void 0)(!u||Vn(e,t)?.writable)&&(l=s(()=>da(void 0,a)),pa(l,va(o)),n.set(t,l));else{u=l.v!==Pr;var p=s(()=>va(o));pa(l,p)}var m=Reflect.getOwnPropertyDescriptor(e,t);if(m?.set&&m.set.call(c,o),!u){if(r&&typeof t==`string`){var h=n.get(`length`),g=Number(t);Number.isInteger(g)&&g>=h.v&&pa(h,g+1)}ga(i)}return!0},ownKeys(e){W(i);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return t===void 0||t.v!==Pr});for(var[r,a]of n)a.v!==Pr&&!(r in e)&&t.push(r);return t},setPrototypeOf(){Ar()}})}function ya(e){try{if(typeof e==`object`&&e&&dr in e)return e[dr]}catch{}return e}function ba(e,t){return Object.is(ya(e),ya(t))}new Set([`copyWithin`,`fill`,`pop`,`push`,`reverse`,`shift`,`sort`,`splice`,`unshift`]);var xa,Sa,Ca,wa;function Ta(){if(xa===void 0){xa=window,Sa=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;Ca=Vn(t,`firstChild`).get,wa=Vn(t,`nextSibling`).get,Kn(e)&&(e[hr]=void 0,e[mr]=null,e[gr]=void 0,e.__e=void 0),Kn(n)&&(n[_r]=void 0)}}function Ea(e=``){return document.createTextNode(e)}function Da(e){return Ca.call(e)}function Oa(e){return wa.call(e)}function H(e,t){if(!Br)return Da(e);var n=Da(Hr);if(n===null)n=Hr.appendChild(Ea());else if(t&&n.nodeType!==3){var r=Ea();return n?.before(r),Ur(r),r}return t&&Na(n),Ur(n),n}function ka(e,t=!1){if(!Br){var n=Da(e);return n instanceof Comment&&n.data===``?Oa(n):n}if(t){if(Hr?.nodeType!==3){var r=Ea();return Hr?.before(r),Ur(r),r}Na(Hr)}return Hr}function U(e,t=1,n=!1){let r=Br?Hr:e;for(var i;t--;)i=r,r=Oa(r);if(!Br)return r;if(n){if(r?.nodeType!==3){var a=Ea();return r===null?i?.after(a):r.before(a),Ur(a),a}Na(r)}return Ur(r),r}function Aa(e){e.textContent=``}function ja(){return!Zr||ea!==null?!1:(vo.f&tr)!==0}function Ma(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function Na(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function Pa(e){Br&&Da(e)!==null&&Aa(e)}var Fa=!1;function Ia(){Fa||(Fa=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[vr]?.()})},{capture:!0}))}function La(e){var t=ho,n=vo;_o(null),yo(null);try{return e()}finally{_o(t),yo(n)}}function Ra(e,t,n,r=n){e.addEventListener(t,()=>La(n));let i=e[vr];i?e[vr]=()=>{i(),r(!0)}:e[vr]=()=>r(!0),Ia()}function za(e){vo===null&&(ho===null&&Er(e),Tr()),po&&wr(e)}function Ba(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Va(e,t){var n=vo;n!==null&&n.f&8192&&(e|=$n);var r={ctx:ni,deps:null,nodes:null,f:e|Zn|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};Vi?.register_created_effect(r);var i=r;if(e&4)qi===null?Zi.ensure().schedule(r):qi.push(r);else if(t!==null){try{Io(r)}catch(e){throw no(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=rr))}if(i!==null&&(i.parent=n,n!==null&&Ba(i,n),ho!==null&&ho.f&2&&!(e&64))){var a=ho;(a.effects??=[]).push(i)}return r}function Ha(){return ho!==null&&!go}function Ua(e){let t=Va(8,null);return mi(t,Xn),t.teardown=e,t}function Wa(e){za(`$effect`);var t=vo.f;if(!ho&&t&32&&ni!==null&&!ni.i){var n=ni;(n.e??=[]).push(e)}else return Ga(e)}function Ga(e){return Va(4|ar,e)}function Ka(e){Zi.ensure();let t=Va(64|ir,e);return(e={})=>new Promise(n=>{e.outro?ao(t,()=>{no(t),n(void 0)}):(no(t),n(void 0))})}function qa(e){return Va(4,e)}function Ja(e){return Va(lr|ir,e)}function Ya(e,t=0){return Va(8|t,e)}function Xa(e,t=[],n=[],r=[]){Ti(r,t,n,t=>{Va(8,()=>{e(...t.map(W))})})}function Za(e,t=0){return Va(16|t,e)}function Qa(e){return Va(32|ir,e)}function $a(e){var t=e.teardown;if(t!==null){let e=po,n=ho;mo(!0),_o(null);try{t.call(null)}finally{mo(e),_o(n)}}}function eo(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&La(()=>{e.abort(yr)});var r=n.next;n.f&64?n.parent=null:no(n,t),n=r}}function to(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||no(t),t=n}}function no(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(ro(e.nodes.start,e.nodes.end),n=!0),e.f|=nr,eo(e,t&&!n),Fo(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();$a(e),e.f^=nr,e.f|=er;var i=e.parent;i!==null&&i.first!==null&&io(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function ro(e,t){for(;e!==null;){var n=e===t?null:Oa(e);e.remove(),e=n}}function io(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function ao(e,t,n=!0){var r=[];oo(e,r,!0);var i=()=>{n&&no(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function oo(e,t,n){if(!(e.f&8192)){e.f^=$n;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=(i.f&65536)!=0||(i.f&32)!=0&&(e.f&16)!=0;oo(i,t,o?n:!1)}i=a}}}function so(e){co(e,!0)}function co(e,t){if(e.f&8192){e.f^=$n,e.f&1024||(mi(e,Zn),Zi.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;co(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function lo(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:Oa(n);t.append(n),n=i}}var uo=null,fo=!1,po=!1;function mo(e){po=e}var ho=null,go=!1;function _o(e){ho=e}var vo=null;function yo(e){vo=e}var bo=null;function xo(e){ho!==null&&(!Zr||ho.f&2)&&(bo??=new Set).add(e)}var So=null,Co=0,wo=null;function To(e){wo=e}var Eo=1,Do=0,Oo=Do;function ko(e){Oo=e}function Ao(){return++Eo}function jo(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~sr),t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&Ui===null&&mi(e,Xn)}return!1}function Mo(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!Zr&&bo!==null&&bo.has(e)))for(var i=0;i{e.ac.abort(yr)}),e.ac=null);try{e.f|=cr;var u=e.fn,d=u();e.f|=tr;var f=e.deps,p=Vi?.is_fork;if(So!==null){var m;if(p||Fo(e,Co),f!==null&&Co>0)for(f.length=Co+So.length,m=0;m{requestAnimationFrame(()=>e()),setTimeout(()=>e())});await Promise.resolve(),Qi()}function W(e){var t=(e.f&2)!=0;if(uo?.add(e),ho!==null&&!go&&!(vo!==null&&vo.f&16384)&&(bo===null||!bo.has(e))){var n=ho.deps;if(ho.f&2097152)e.rvn?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?li(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function qo(e,t,n,r,i){var a={capture:r,passive:i},o=Ko(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Ua(()=>{t.removeEventListener(e,o,a)})}function Jo(e,t,n){(t[Uo]??={})[e]=n}function Yo(e){for(var t=0;t{throw e});throw f}}finally{e[Uo]=t,delete e.currentTarget,_o(u),yo(d)}}}var Qo=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function $o(e){return Qo?.createHTML(e)??e}function es(e){var t=Ma(`template`);return t.innerHTML=$o(e.replaceAll(``,``)),t.content}function ts(e,t){var n=vo;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function G(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(``);return()=>{if(Br)return ts(Hr,null),Hr;i===void 0&&(i=es(a?e:``+e),n||(i=Da(i)));var t=r||Sa?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=Da(t),s=t.lastChild;ts(o,s)}else ts(t,t);return t}}function ns(e,t,n=`svg`){var r=!e.startsWith(``),i=(t&1)!=0,a=`<${n}>${r?e:``+e}`,o;return()=>{if(Br)return ts(Hr,null),Hr;if(!o){var e=Da(es(a));if(i)for(o=document.createDocumentFragment();Da(e);)o.appendChild(Da(e));else o=Da(e)}var t=o.cloneNode(!0);if(i){var n=Da(t),r=t.lastChild;ts(n,r)}else ts(t,t);return t}}function rs(e,t){return ns(e,t,`svg`)}function is(e=``){if(!Br){var t=Ea(e+``);return ts(t,t),t}var n=Hr;return n.nodeType===3?Na(n):(n.before(n=Ea()),Ur(n)),ts(n,n),n}function as(){if(Br)return ts(Hr,null),Hr;var e=document.createDocumentFragment(),t=document.createComment(``),n=Ea();return e.append(t,n),ts(t,n),e}function K(e,t){if(Br){var n=vo;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=Hr),Wr();return}e!==null&&e.before(t)}function os(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[_r]??=e.nodeValue)&&(e[_r]=n,e.nodeValue=`${n}`)}function ss(e,t){return ls(e,t)}var cs=new Map;function ls(e,{target:t,anchor:n,props:r={},events:i,context:a,intro:o=!0,transformError:s}){Ta();var c=void 0,l=Ka(()=>{var o=n??t.appendChild(Ea());Ci(o,{pending:()=>{}},t=>{ii({});var n=ni;if(a&&(n.c=a),i&&(r.$$events=i),Br&&ts(t,null),c=e(t,r)||{},Br&&(vo.nodes.end=Hr,Hr===null||Hr.nodeType!==8||Hr.data!==`]`))throw Lr(),Nr;ai()},s);var l=new Set,u=e=>{for(var n=0;n{for(var e of l)for(let n of[t,document]){var r=cs.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Zo),r.delete(e),r.size===0&&cs.delete(n)):r.set(e,i)}Go.delete(u),o!==n&&o.parentNode?.removeChild(o)}});return us.set(c,l),c}var us=new WeakMap;function ds(e,t){let n=us.get(e);return n?(us.delete(e),n(t)):Promise.resolve()}var fs=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)so(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(so(r.effect),this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(no(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();lo(r,t),t.append(Ea()),this.#n.set(e,{effect:r,fragment:t})}else no(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),ao(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(no(n.effect),this.#n.delete(e))};ensure(e,t){var n=Vi,r=ja();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=Ea();i.append(a),this.#n.set(e,{effect:Qa(()=>t(a)),fragment:i})}else this.#t.set(e,Qa(()=>t(this.anchor)));if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else Br&&(this.anchor=Hr),this.#a(n)}};function ps(e,t,n=!1){var r;Br&&(r=Hr,Wr());var i=new fs(e),a=n?rr:0;function o(e,t){if(Br){var n=qr(r);if(e!==parseInt(n.substring(1))){var a=Kr();Ur(a),i.anchor=a,Vr(!1),i.ensure(e,t),Vr(!0);return}}i.ensure(e,t)}Za(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function ms(e,t){return t}function hs(e,t,n){for(var r=[],i=t.length,a,o=t.length,s=0;s{if(a){if(a.pending.delete(n),a.done.add(n),a.pending.size===0){var t=e.outrogroups;gs(e,zn(a.done)),t.delete(a),t.size===0&&(e.outrogroups=null)}}else --o},!1)}if(o===0){var c=r.length===0&&n!==null;if(c){var l=n,u=l.parentNode;Aa(u),u.append(l),e.items.clear()}gs(e,t,!c)}else a={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(a)}function gs(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i{var e=n();return In(e)?e:e==null?[]:zn(e)}),d,f=new Map,p=!0;function m(e){g.effect.f&16384||(g.pending.delete(e),g.fallback=l,bs(g,d,o,t,r),l!==null&&(d.length===0?l.f&33554432?(l.f^=or,Ss(l,null,o)):so(l):ao(l,()=>{l=null})))}function h(e){g.pending.delete(e)}var g={effect:Za(()=>{d=W(u);var e=d.length;let c=!1;Br&&qr(o)===`[!`!=(e===0)&&(o=Kr(),Ur(o),Vr(!1),c=!0);for(var g=new Set,_=Vi,v=ja(),y=0;ya(o)):(l=Qa(()=>a(_s??=Ea())),l.f|=or)),e>g.size&&Cr(``,``,``),Br&&e>0&&Ur(Kr()),!p)if(f.set(_,g),v){for(let[e,t]of s)g.has(e)||_.skip_effect(t.e);_.oncommit(m),_.ondiscard(h)}else m(_);c&&Vr(!0),W(u)}),flags:t,items:s,pending:f,outrogroups:null,fallback:l};p=!1,Br&&(o=Hr)}function ys(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function bs(e,t,n,r,i){var a=(r&8)!=0,o=t.length,s=e.items,c=ys(e.effect.first),l,u=null,d,f=[],p=[],m,h,g,_;if(a)for(_=0;_0){var T=r&4&&o===0?n:null;if(a){for(_=0;_{if(d!==void 0)for(g of d)g.nodes?.a?.apply()})}function xs(e,t,n,r,i,a,o,s){var c=o&1?o&16?ua(n):fa(n,!1,!1):null,l=o&2?ua(i):null;return{v:c,i:l,e:Qa(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function Ss(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=Oa(r);if(a.before(r),r===i)return;r=o}}function Cs(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function ws(e,t,...n){var r=new fs(e);Za(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},rr)}function Ts(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t=0;){var s=o+a;(o===0||Os.includes(r[o-1]))&&(s===r.length||Os.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function As(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function js(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function Ms(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(js)),i&&c.push(...Object.keys(i).map(js));var l=0,u=-1;let t=e.length;for(var d=0;d{Is(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),Ua(()=>{t.disconnect()})}function Rs(e,t,n=t){var r=new WeakSet,i=!0;Ra(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),zs);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&zs(o)}n(a),e.__value=a,Vi!==null&&r.add(Vi)}),qa(()=>{var a=t();if(e===document.activeElement){var o=Zr?Hi:Vi;if(r.has(o))return}if(Is(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=zs(s),n(a))}e.__value=a,i=!1}),Ls(e)}function zs(e){return`__value`in e?e.__value:e.value}var Bs=Symbol(`is custom element`),Vs=Symbol(`is html`),Hs=br?`link`:`LINK`,Us=br?`progress`:`PROGRESS`;function Ws(e){if(Br){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;qs(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;qs(e,`checked`,null),e.checked=r}}};e[vr]=n,li(n),Ia()}}function Gs(e,t){var n=Js(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==Us)||(e.value=t??``)}function Ks(e,t){var n=Js(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function qs(e,t,n,r){var i=Js(e);Br&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Hs)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[pr]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&Xs(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function Js(e){return e[mr]??={[Bs]:e.nodeName.includes(`-`),[Vs]:e.namespaceURI===Fr}}var Ys=new Map;function Xs(e){var t=e.getAttribute(`is`)||e.nodeName,n=Ys.get(t);if(n)return n;Ys.set(t,n=[]);for(var r,i=e,a=Element.prototype;a!==i;){for(var o in r=Hn(i),r)r[o].set&&o!==`innerHTML`&&o!==`textContent`&&o!==`innerText`&&n.push(o);i=Gn(i)}return n}function Zs(e,t,n=t){var r=new WeakSet;Ra(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=Qs(e)?$s(a):a,n(a),Vi!==null&&r.add(Vi),await Lo(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(Br&&e.defaultValue!==e.value||Bo(t)==null&&e.value)&&(n(Qs(e)?$s(e.value):e.value),Vi!==null&&r.add(Vi)),Ya(()=>{var n=t();if(e===document.activeElement){var i=Zr?Hi:Vi;if(r.has(i))return}Qs(e)&&n===$s(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function Qs(e){var t=e.type;return t===`number`||t===`range`}function $s(e){return e===``?null:+e}function ec(e,t){return e===t||e?.[dr]===t}function tc(e={},t,n,r){var i=ni.r,a=vo;return qa(()=>{var o,s;return Ya(()=>{o=s,s=r?.()||[],Bo(()=>{ec(n(...s),e)||(t(e,...s),o&&ec(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&ec(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function nc(e,t,n,r){var i=!Qr||(n&2)!=0,a=(n&8)!=0,o=(n&16)!=0,s=r,c=!0,l=void 0,u=()=>o&&i?(l??=ki(r),W(l)):(c&&(c=!1,s=o?Bo(r):r),s);let d;if(a){var f=dr in e||fr in e;d=Vn(e,t)?.set??(f&&t in e?n=>e[t]=n:void 0)}var p,m=!1;a?[p,m]=bi(()=>e[t]):p=e[t],p===void 0&&r!==void 0&&(p=u(),d&&(i&&Or(t),d(p)));var h=i?()=>{var n=e[t];return n===void 0?u():(c=!0,n)}:()=>{var n=e[t];return n!==void 0&&(s=void 0),n===void 0?s:n};if(i&&!(n&4))return h;if(d){var g=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||g||m)&&d(t?h():e),e):h()})}var _=!1,v=(n&1?ki:Ni)(()=>(_=!1,h()));a&&W(v);var y=vo;return(function(e,t){if(arguments.length>0){let n=t?W(v):i&&a?va(e):e;return pa(v,n),_=!0,s!==void 0&&(s=n),e}return po&&_||y.f&16384?v.v:W(v)})}function rc(e){ni===null&&xr(`onMount`),Qr&&ni.l!==null?ac(ni).m.push(e):Wa(()=>{let t=Bo(e);if(typeof t==`function`)return t})}function ic(e){ni===null&&xr(`onDestroy`),rc(()=>()=>Bo(e))}function ac(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}var oc=class{mb;svelteComponent;svelteComponentInstance;mounted;onValueChange;constructor(e,t,n){this.mb=e,this.mounted=!1,this.svelteComponent=t,this.onValueChange=n}setValue(e){this.svelteComponentInstance?.setValue(e)}getInstance(){return this.svelteComponentInstance}mount(e,t,n={}){let r=Object.assign({mb:this.mb,value:t,onValueChange:this.onValueChange},n);this.svelteComponentInstance=ss(this.svelteComponent,{target:e,props:r}),this.mounted=!0}unmount(){this.svelteComponentInstance&&ds(this.svelteComponentInstance),this.mounted=!1}isMounted(){return this.mounted}},sc=class{mounted;targetEl;onUnmountCbs;constructor(){this.mounted=!1,this.targetEl=void 0,this.onUnmountCbs=[]}isMounted(){return this.mounted}getTargetEl(){return this.targetEl}mount(e){if(this.mounted||this.targetEl){console.warn(`Mountable is already mounted`,this);return}if(e===void 0){console.error(`Mountable target element is undefined`,this);return}this.mounted=!0,this.targetEl=e,this.onMount(e)}unmount(){if(!this.mounted||!this.targetEl){console.warn(`Mountable is not mounted`,this);return}this.mounted=!1,this.onUnmount(this.targetEl);for(let e of this.onUnmountCbs)e();this.targetEl=void 0}registerUnmountCb(e){this.onUnmountCbs.push(e)}},cc=class{listeners;constructor(){this.listeners=[]}registerListener(e){let t=e;return t.uuid=E(),this.listeners.push(t),t}unregisterListener(e){this.unregisterListenerById(e.uuid)}unregisterListenerById(e){this.listeners=this.listeners.filter(t=>t.uuid!==e)}unregisterAllListeners(){this.listeners=[]}notifyListeners(e){for(let t of this.listeners)try{t.callback(e)}catch(e){let t=e instanceof Error?e:String(e);console.error(new ve({errorLevel:z.ERROR,effect:`error while calling listener callback`,cause:t}))}}},lc=class extends cc{value;constructor(e){super(),this.value=e}get(){return this.value}set(e){this.value=e,this.notifyListeners(e)}},uc=class extends cc{value;mapFn;constructor(e,t){super(),this.value=t(e),this.mapFn=t}get(){return this.value}set(e){this.value=this.mapFn(e),this.notifyListeners(this.value)}setDirect(e){this.value=e,this.notifyListeners(e)}},dc=class extends sc{mb;mountable;svelteWrapper;inputSignal;metadataSubscription;mountTarget;constructor(e){super(),this.mountable=e,this.mb=e.mb}reverseMapValue(e){let t=this.rawReverseMapValue(e);if(t!==void 0)return t;let n=this.rawReverseMapValue(this.getDefaultValue());return n===void 0?this.getFallbackDefaultValue():n}mapValue(e){return this.rawMapValue(e)}getValue(){return this.inputSignal?this.inputSignal.get():this.getDefaultValue()}getInternalValue(){return this.reverseMapValue(this.getValue())}setValue(e){this.inputSignal?.setDirect(e),this.notifySubscription(e)}setInternalValue(e){this.setValue(this.mapValue(e))}notifySubscription(e){this.metadataSubscription?.write(e)}getDefaultValue(){let e=this.mountable.getArgument(kn.DEFAULT_VALUE);if(e===void 0)return this.mapValue(this.getFallbackDefaultValue());let t=this.filterValue(e.value);return t===void 0?this.mapValue(this.getFallbackDefaultValue()):t}updateDataAttributes(e){this.mountTarget&&(this.mountTarget.dataset.internalValue=JSON.stringify(e))}getMountArgs(){return{}}onMount(e){this.mountTarget=e,this.svelteWrapper=new oc(this.mb,this.getSvelteComponent(),e=>{this.updateDataAttributes(e),this.notifySubscription(this.mapValue(e))}),this.inputSignal=new uc(void 0,e=>{let t=this.filterValue(e);return t===void 0?this.getDefaultValue():t}),this.inputSignal.registerListener({callback:e=>this.svelteWrapper?.setValue(this.reverseMapValue(e))}),this.inputSignal.registerListener({callback:e=>{this.updateDataAttributes(this.reverseMapValue(e))}}),this.updateDataAttributes(this.getInternalValue());let t=this.mountable.getBindTarget();t&&(this.metadataSubscription=this.mountable.mb.metadataManager.subscribe(this.mountable.getUuid(),this.inputSignal,t,()=>this.mountable.unmount())),this.svelteWrapper.mount(e,this.reverseMapValue(this.getValue()),this.getMountArgs())}onUnmount(){this.mountTarget=void 0,this.inputSignal?.unregisterAllListeners(),this.metadataSubscription?.unsubscribe(),this.svelteWrapper?.unmount()}};typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`),new Set([`$$slots`,`$$events`,`$$legacy`]);var fc=G(``);function pc(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}var i={setValue:r},a=fc();return Ws(a),Jo(`input`,a,()=>t.onValueChange(ei(W(n)))),Zs(a,()=>W(n),e=>pa(n,e)),K(e,a),ai(i)}Yo([`input`]);var mc=class extends dc{filterValue(e){return _n(e)}getFallbackDefaultValue(){return this.mountable.mb.dateParser.stringify(this.mountable.mb.dateParser.getDefaultDate())}getSvelteComponent(){return pc}rawMapValue(e){return e}rawReverseMapValue(e){return e}},hc=G(`
`);function gc(e,t){ii(t,!0);let n=nc(t,`iconName`,3,``),r=da(void 0);Wa(()=>W(r)?t.mb.internal.setIcon(W(r),n()):void 0);var i=as(),a=ka(i),o=e=>{var t=hc();tc(t,e=>pa(r,e),()=>W(r)),K(e,t)};ps(a,e=>{n().length>0&&e(o)}),K(e,i),ai()}new Set([`$$slots`,`$$events`,`$$legacy`]);var _c=G(`
`);function vc(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(){t.showDatePicker()}function a(e){e.key===` `&&t.showDatePicker()}var o={setValue:r},s=_c(),c=H(s),l=H(c,!0);return V(c),gc(U(c,2),{get mb(){return t.mb},iconName:`calendar`}),V(s),Xa(e=>os(l,e),[()=>W(n)?W(n).format(t.dateFormat):`none`]),Jo(`click`,s,i),Jo(`keydown`,s,a),K(e,s),ai(o)}Yo([`click`,`keydown`]);var yc=class extends dc{options;constructor(e){super(e),this.options=this.mountable.getArguments(kn.OPTION)}filterValue(e){if(e===null)return null;if(e===void 0||typeof e!=`string`)return;let t=this.mountable.mb.dateParser.parse(e);if(t.isValid())return this.mountable.mb.dateParser.stringify(t)}getFallbackDefaultValue(){return this.mountable.mb.dateParser.getDefaultDate()}getSvelteComponent(){return vc}rawMapValue(e){return e===null?null:this.mountable.mb.dateParser.stringify(e)}rawReverseMapValue(e){if(e===null)return null;let t=this.mountable.mb.dateParser.parse(e);if(t.isValid())return t}getMountArgs(){return{dateFormat:this.mountable.mb.getSettings().preferredDateFormat,showDatePicker:()=>{this.mountable.mb.internal.openDatePickerModal(this.getInternalValue(),e=>this.setInternalValue(e))}}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var bc=G(``);function xc(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}var i={setValue:r},a=bc();return Ws(a),Jo(`input`,a,()=>t.onValueChange(ei(W(n)))),Zs(a,()=>W(n),e=>pa(n,e)),K(e,a),ai(i)}Yo([`input`]);var Sc=class extends dc{filterValue(e){return _n(e)}getFallbackDefaultValue(){return this.mountable.mb.dateParser.stringify(this.mountable.mb.dateParser.getDefaultDate())}getSvelteComponent(){return xc}rawMapValue(e){return e}rawReverseMapValue(e){return e}},Cc=G(`
`);function wc(e,t){ii(t,!0);let n,r;ic(()=>{r?.()});async function i(e){r?.(),t.mb.domHelpers.empty(n),r=await t.mb.internal.renderMarkdown(e,n,t.filePath)}Wa(()=>void i(t.value));var a=Cc();tc(a,e=>n=e,()=>n),K(e,a),ai()}new Set([`$$slots`,`$$events`,`$$legacy`]);var Tc=G(``),Ec=G(`
`);function Dc(e,t){ii(t,!0);let n=da(va(t.value)),r=da(!1);function i(e){pa(n,e,!0)}function a(){pa(r,!1)}function o(){pa(r,!0)}function s(e){e.key===` `&&o()}var c={setValue:i},l=Ec(),u=H(l),d=e=>{var r=Tc();Pa(r),Jo(`focusout`,r,()=>a()),Jo(`input`,r,()=>t.onValueChange(ei(W(n)))),Zs(r,()=>W(n),e=>pa(n,e)),K(e,r)},f=e=>{wc(e,{get value(){return W(n)},get mb(){return t.mb},get filePath(){return t.filePath}})};return ps(u,e=>{W(r)?e(d):e(f,-1)}),V(l),Jo(`click`,l,()=>o()),qo(`keypress`,l,e=>s(e)),K(e,l),ai(c)}Yo([`click`,`focusout`,`input`]);var Oc=class extends dc{mdUnloadCallback;filterValue(e){return mn(e)?e?.toString():void 0}getFallbackDefaultValue(){return``}getSvelteComponent(){return Dc}rawReverseMapValue(e){return e}rawMapValue(e){return e}getMountArgs(){return{render:(e,t)=>void this.renderInElement(e,t),filePath:this.mountable.getFilePath()}}async renderInElement(e,t){this.mdUnloadCallback?.(),e.innerHTML=``,this.mdUnloadCallback=await this.mountable.mb.internal.renderMarkdown(t,e,this.mountable.getFilePath())}onUnmount(){super.onUnmount(),this.mdUnloadCallback?.()}},kc=G(``);function Ac(e,t){ii(t,!0);let n=nc(t,`variant`,19,()=>Lt.DEFAULT),r=nc(t,`disabled`,3,!1),i=nc(t,`tooltip`,3,``),a=nc(t,`classes`,3,``),o=nc(t,`onclick`,3,()=>{});var s=kc();let c;ws(H(s),()=>t.children),V(s),Xa(()=>{c=Ns(s,1,`mb-button-inner ${a()??``}`,null,c,{"mod-cta":n()===Lt.PRIMARY,"mod-warning":n()===Lt.DESTRUCTIVE,"mod-plain":n()===Lt.PLAIN,disabled:r()}),qs(s,`aria-label`,i()),s.disabled=r()}),Jo(`click`,s,function(...e){o()?.apply(this,e)}),K(e,s),ai()}Yo([`click`]),new Set([`$$slots`,`$$events`,`$$legacy`]);var jc=G(`
`),Mc=G(`
`,1);function Nc(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e){W(n).push(e),t.onValueChange(ei(W(n)))}function a(e){W(n).splice(e,1),t.onValueChange(ei(W(n)))}function o(e,r){let i=[];r>0&&i.push({name:`Move left`,icon:`arrow-left`,onclick:()=>{let e=W(n)[r-1];W(n)[r-1]=W(n)[r],W(n)[r]=e,t.onValueChange(ei(W(n)))}}),r{let e=W(n)[r+1];W(n)[r+1]=W(n)[r],W(n)[r]=e,t.onValueChange(ei(W(n)))}}),i.push({name:`Copy image path`,icon:`copy`,onclick:()=>{let e=W(n)[r];navigator.clipboard.writeText(e).then(()=>{t.mb.internal.showNotice(`Image path copied to clipboard`)}).catch(()=>{t.mb.internal.showNotice(`Failed to copy image path to clipboard`)})}}),i.push({name:`Remove`,icon:`x`,warning:!0,onclick:()=>a(r)}),t.mb.internal.createContextMenu(i).showWithEvent(e)}var s={setValue:r,pushValue:i},c=Mc(),l=ka(c);vs(l,21,()=>W(n),ms,(e,n,r)=>{var i=jc(),a=H(i);V(i),Xa((e,t)=>{qs(i,`data-value`,e),qs(a,`src`,t),qs(a,`alt`,W(n)),qs(a,`aria-label`,W(n))},[()=>pn(W(n)),()=>t.mb.internal.imagePathToUri(W(n))]),Jo(`contextmenu`,i,e=>o(e,r)),K(e,i)}),V(l);var u=U(l,2);return Ac(H(u),{get variant(){return Lt.DEFAULT},onclick:()=>t.showSuggester(),children:(e,t)=>{Gr(),K(e,is(`Add new image`))},$$slots:{default:!0}}),V(u),K(e,c),ai(s)}Yo([`contextmenu`]);var Pc=class extends dc{filterValue(e){return hn(e)}getFallbackDefaultValue(){return[]}getSvelteComponent(){return Nc}rawMapValue(e){return e}rawReverseMapValue(e){return e.map(e=>pn(e)).filter(e=>e!==void 0)}getMountArgs(){return{showSuggester:()=>this.openModal()}}openModal(){this.mountable.mb.internal.openImageSuggesterModal(this,!1,e=>{e!==void 0&&this.svelteWrapper?.getInstance()?.pushValue(e)})}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Fc=G(`
`),Ic=G(`
`);function Lc(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e){let n=[];n.push({name:`Edit`,icon:`pencil`,onclick:()=>{t.showSuggester()}}),n.push({name:`Remove`,icon:`x`,warning:!0,onclick:()=>t.clear()}),t.mb.internal.createContextMenu(n).showWithEvent(e)}var a={setValue:r},o=as(),s=ka(o),c=e=>{var r=Fc(),a=H(r);Ac(U(a,2),{get variant(){return Lt.PLAIN},onclick:e=>i(e),classes:`mb-image-card-button`,children:(e,n)=>{gc(e,{iconName:`ellipsis-vertical`,get mb(){return t.mb}})},$$slots:{default:!0}}),V(r),Xa(e=>{qs(a,`src`,e),qs(a,`alt`,W(n)),qs(a,`aria-label`,W(n))},[()=>t.mb.internal.imagePathToUri(W(n))]),Jo(`contextmenu`,r,e=>i(e)),K(e,r)},l=e=>{var n=Ic();Ac(H(n),{get variant(){return Lt.PLAIN},onclick:()=>t.showSuggester(),tooltip:`Select image`,children:(e,t)=>{Gr(),K(e,is(`No image selected. Click to select.`))},$$slots:{default:!0}}),V(n),K(e,n)};return ps(s,e=>{W(n)?e(c):e(l,-1)}),K(e,o),ai(a)}Yo([`contextmenu`]);var Rc=class extends dc{filterValue(e){return mn(e)?e:void 0}getFallbackDefaultValue(){}getSvelteComponent(){return Lc}rawMapValue(e){return e}rawReverseMapValue(e){return pn(e)}getMountArgs(){return{showSuggester:()=>this.openModal(),clear:()=>this.setInternalValue(void 0)}}openModal(){this.mountable.mb.internal.openImageSuggesterModal(this,!0,e=>this.setInternalValue(e))}},zc=G(` `);function Bc(e,t){ii(t,!0);let n=Mi(()=>t.mdLink.block?`${t.mdLink.target}#${t.mdLink.block}`:t.mdLink.target),r=Mi(()=>t.mdLink.internal?`internal-link`:`external-link`),i=Mi(()=>t.mdLink.alias?W(n):void 0),a=Mi(()=>t.mdLink.alias?t.mdLink.alias:t.mdLink.block?`${t.mdLink.target} > ${t.mdLink.block}`:t.mdLink.target);var o=zc(),s=H(o,!0);V(o),Xa(()=>{qs(o,`data-href`,W(n)),qs(o,`href`,W(n)),Ns(o,1,Ds(W(r))),qs(o,`aria-label`,W(i)),os(s,W(a))}),K(e,o),ai()}var Vc=G(`, `,1),Hc=G(` `,1);function Uc(e,t){ii(t,!0);let n=nc(t,`elements`,19,()=>[]);var r=Hc(),i=ka(r);vs(i,17,()=>n().slice(0,n().length-1),ms,(e,n)=>{var r=Vc();ws(ka(r),()=>t.children,()=>W(n)),Gr(3),K(e,r)}),ws(U(i,2),()=>t.children,()=>n()[n().length-1]),K(e,r),ai()}var Wc=G(` `),Gc=G(` `),Kc=G(``);function qc(e,t){ii(t,!0);let n=nc(t,`value`,3,void 0),r=Mi(()=>xn(n(),!1));var i=as(),a=ka(i),o=e=>{var t=Wc(),n=H(t,!0);V(t),Xa(()=>os(n,W(r))),K(e,t)},s=e=>{var t=Kc();Uc(H(t),{get elements(){return W(r)},children:(e,t=qn)=>{var n=as(),r=ka(n),i=e=>{var n=Gc(),r=H(n,!0);V(n),Xa(()=>os(r,t())),K(e,n)},a=e=>{Bc(e,{get mdLink(){return t()}})};ps(r,e=>{typeof t()==`string`?e(i):e(a,-1)}),K(e,n)},$$slots:{default:!0}}),V(t),K(e,t)},c=Mi(()=>Array.isArray(W(r))),l=e=>{var t=Kc();Bc(H(t),{get mdLink(){return W(r)}}),V(t),K(e,t)};ps(a,e=>{typeof W(r)==`string`?e(o):W(c)?e(s,1):e(l,-1)}),K(e,i),ai()}new Set([`$$slots`,`$$events`,`$$legacy`]);var Jc=G(`
`),Yc=G(`
`);function Xc(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e){W(n).push(e),t.onValueChange(ei(W(n)))}function a(e){W(n).splice(e,1),t.onValueChange(ei(W(n)))}function o(e){e.key===` `&&t.showInput()}function s(e,r){let i=[];r>0&&i.push({name:`Move left`,icon:`arrow-left`,onclick:()=>{let e=W(n)[r-1];W(n)[r-1]=W(n)[r],W(n)[r]=e,t.onValueChange(ei(W(n)))}}),r{let e=W(n)[r+1];W(n)[r+1]=W(n)[r],W(n)[r]=e,t.onValueChange(ei(W(n)))}}),i.push({name:`Edit`,icon:`pencil`,onclick:()=>{t.mb.internal.openTextPromptModal({title:`Meta Bind List`,subTitle:`Edit the value of a list item.`,value:pn(W(n)[r]),multiline:!1,onSubmit:e=>{W(n)[r]=e,t.onValueChange(ei(W(n)))},onCancel:()=>{}})}}),i.push({name:`Remove`,icon:`x`,warning:!0,onclick:()=>a(r)}),t.mb.internal.createContextMenu(i).showWithEvent(e)}var c={setValue:r,pushValue:i},l=Yc(),u=H(l);vs(u,17,()=>W(n),ms,(e,t,n)=>{var r=Jc();qc(H(r),{get value(){return W(t)}}),V(r),Xa(e=>qs(r,`data-value`,e),[()=>pn(W(t))]),Jo(`contextmenu`,r,e=>s(e,n)),K(e,r)});var d=U(u,2);return gc(U(H(d),2),{get mb(){return t.mb},iconName:`plus`}),V(d),V(l),Jo(`click`,d,()=>t.showInput()),Jo(`keydown`,d,o),K(e,l),ai(c)}Yo([`contextmenu`,`click`,`keydown`]);var Zc=class extends dc{filterValue(e){return hn(e)}getFallbackDefaultValue(){return[]}getSvelteComponent(){return Xc}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{showInput:()=>this.openModal()}}openModal(){this.mountable.mb.internal.openTextPromptModal({title:`Meta Bind List`,subTitle:`Create a new List Element.`,value:``,multiline:!1,onSubmit:e=>{this.svelteWrapper?.getInstance()?.pushValue(e)},onCancel:()=>{}})}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Qc=G(`
`),$c=G(`
`);function el(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e){W(n).push(e),t.onValueChange(ei(W(n)))}function a(e){W(n).splice(e,1),t.onValueChange(ei(W(n)))}function o(e){if(!t.allowOther){t.showSuggester();return}t.mb.internal.createContextMenu([{name:`From Options`,onclick:()=>t.showSuggester()},{name:`From Text`,onclick:()=>t.showTextPrompt()}]).showWithEvent(e)}function s(e){e.key===` `&&t.showSuggester()}function c(e,r){let i=[];r>0&&i.push({name:`Move left`,icon:`arrow-left`,onclick:()=>{let e=W(n)[r-1];W(n)[r-1]=W(n)[r],W(n)[r]=e,t.onValueChange(ei(W(n)))}}),r{let e=W(n)[r+1];W(n)[r+1]=W(n)[r],W(n)[r]=e,t.onValueChange(ei(W(n)))}}),i.push({name:`Remove`,icon:`x`,warning:!0,onclick:()=>a(r)}),t.mb.internal.createContextMenu(i).showWithEvent(e)}var l={setValue:r,pushValue:i},u=$c(),d=H(u);vs(d,17,()=>W(n),ms,(e,t,n)=>{var r=Qc();qc(H(r),{get value(){return W(t)}}),V(r),Xa(e=>qs(r,`data-value`,e),[()=>pn(W(t))]),Jo(`contextmenu`,r,e=>c(e,n)),K(e,r)});var f=U(d,2);return gc(U(H(f),2),{get mb(){return t.mb},iconName:`plus`}),V(f),V(u),Jo(`click`,f,o),Jo(`keydown`,f,s),K(e,u),ai(l)}Yo([`contextmenu`,`click`,`keydown`]);var tl=class extends dc{filterValue(e){return hn(e)}getFallbackDefaultValue(){return[]}getSvelteComponent(){return el}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{showSuggester:()=>this.openModal(),showTextPrompt:()=>this.openTextModal(),allowOther:this.mountable.getArgument(kn.ALLOW_OTHER)?.value===!0}}openModal(){this.mountable.mb.internal.openSuggesterModal(this,e=>{this.svelteWrapper?.getInstance()?.pushValue(e.value)})}openTextModal(){this.mountable.mb.internal.openTextPromptModal({title:`Meta Bind List Suggester`,subTitle:`Create a new List Element.`,value:``,multiline:!1,onSubmit:e=>{this.svelteWrapper?.getInstance()?.pushValue(e)},onCancel:()=>{}})}};new Set([`$$slots`,`$$events`,`$$legacy`]);var nl=G(``),rl=G(``);function il(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(){t.onValueChange(ei(W(n)))}var a={setValue:r},o=rl();return vs(o,21,()=>t.options,ms,(e,t)=>{var n=nl(),r=H(n,!0);V(n);var i={};Xa(()=>{os(r,W(t).name),i!==(i=W(t).value)&&(n.value=(n.__value=W(t).value)??``)}),K(e,n)}),V(o),Jo(`change`,o,()=>i()),Rs(o,()=>W(n),e=>pa(n,e)),K(e,o),ai(a)}Yo([`change`]);var al=class extends dc{options;constructor(e){super(e),this.options=this.mountable.getArguments(kn.OPTION)}filterValue(e){return vn(e)}getFallbackDefaultValue(){return null}getSvelteComponent(){return il}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{options:this.options}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var ol=G(`
`),sl=G(`Empty`),cl=G(``),ll=G(``),ul=G(` `),dl=G(`
`,1);function fl(e,t){ii(t,!0);let n=da(va(t.value)),r=da(``);function i(e){pa(n,e,!0)}function a(){W(n).push(W(r)),t.onValueChange(ei(W(n))),pa(r,``)}function o(e){W(n).splice(e,1),t.onValueChange(ei(W(n)))}function s(e,t){let n=t.toString();return`${e.toString().padStart(n.length,`0`)}/${n}`}function c(e,r){let i=[];r>0&&i.push({name:`Move up`,icon:`arrow-up`,onclick:()=>{let e=W(n)[r-1];W(n)[r-1]=W(n)[r],W(n)[r]=e,t.onValueChange(ei(W(n)))}}),r{let e=W(n)[r+1];W(n)[r+1]=W(n)[r],W(n)[r]=e,t.onValueChange(ei(W(n)))}}),i.push({name:`Edit`,icon:`pencil`,onclick:()=>{t.mb.internal.openTextPromptModal({title:`Meta Bind List`,subTitle:`Edit the value of a list item.`,value:pn(W(n)[r]),multiline:t.multiLine,onSubmit:e=>{W(n)[r]=e,t.onValueChange(ei(W(n)))},onCancel:()=>{}})}}),i.push({name:`Remove`,icon:`x`,warning:!0,onclick:()=>o(r)}),t.mb.internal.createContextMenu(i).showWithEvent(e)}var l={setValue:i},u=dl(),d=ka(u);vs(d,21,()=>W(n),ms,(e,t,n)=>{var r=ol();qc(H(r),{get value(){return W(t)}}),V(r),Xa(e=>qs(r,`data-value`,e),[()=>pn(W(t))]),Jo(`contextmenu`,r,e=>c(e,n)),K(e,r)},e=>{K(e,sl())}),V(d);var f=U(d,2),p=H(f),m=e=>{var n=cl();Pa(n),Xa(()=>{qs(n,`placeholder`,t.placeholder),qs(n,`maxlength`,t.limit)}),Zs(n,()=>W(r),e=>pa(r,e)),K(e,n)},h=e=>{var n=ll();Ws(n),Xa(()=>{qs(n,`placeholder`,t.placeholder),qs(n,`maxlength`,t.limit)}),Jo(`keyup`,n,e=>{e.key===`Enter`&&W(r).length>0&&a()}),Zs(n,()=>W(r),e=>pa(r,e)),K(e,n)};ps(p,e=>{t.multiLine?e(m):e(h,-1)});var g=U(p,2),_=e=>{var r=ul(),i=H(r,!0);V(r),Xa(e=>{Ns(r,1,`mb-content-limit-indicator ${W(n).length>t.limit?`mb-content-limit-indicator-overflow`:``}`),os(i,e)},[()=>s(W(n).length,t.limit)]),K(e,r)};ps(g,e=>{t.limit!==void 0&&e(_)});var v=U(g,2);{let e=Mi(()=>!W(r));Ac(v,{onclick:()=>a(),get disabled(){return W(e)},children:(e,n)=>{gc(e,{get mb(){return t.mb},iconName:`plus`})},$$slots:{default:!0}})}return V(f),K(e,u),ai(l)}Yo([`contextmenu`,`keyup`]);var pl=class extends dc{filterValue(e){return hn(e)}getFallbackDefaultValue(){return[]}getSvelteComponent(){return fl}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{placeholder:this.mountable.getArgument(kn.PLACEHOLDER)?.value??`New Entry...`,limit:this.mountable.getArgument(kn.LIMIT)?.value,multiLine:this.mountable.getArgument(kn.MULTI_LINE)?.value===!0}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var ml=G(`
`),hl=G(`Empty`),gl=G(`
`,1);function _l(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e){W(n).push(e),t.onValueChange(ei(W(n)))}function a(e){W(n).splice(e,1),t.onValueChange(ei(W(n)))}function o(e,r){let i=[];r>0&&i.push({name:`Move up`,icon:`arrow-up`,onclick:()=>{let e=W(n)[r-1];W(n)[r-1]=W(n)[r],W(n)[r]=e,t.onValueChange(ei(W(n)))}}),r{let e=W(n)[r+1];W(n)[r+1]=W(n)[r],W(n)[r]=e,t.onValueChange(ei(W(n)))}}),i.push({name:`Remove`,icon:`x`,warning:!0,onclick:()=>a(r)}),t.mb.internal.createContextMenu(i).showWithEvent(e)}var s={setValue:r,pushValue:i},c=gl(),l=ka(c);vs(l,21,()=>W(n),ms,(e,t,n)=>{var r=ml();qc(H(r),{get value(){return W(t)}}),V(r),Xa(e=>qs(r,`data-value`,e),[()=>pn(W(t))]),Jo(`contextmenu`,r,e=>o(e,n)),K(e,r)},e=>{K(e,hl())}),V(l);var u=U(l,2),d=H(u);Ac(d,{get variant(){return Lt.DEFAULT},onclick:()=>t.showSuggester(),children:(e,t)=>{Gr(),K(e,is(`Add new item`))},$$slots:{default:!0}});var f=U(d,2),p=e=>{Ac(e,{get variant(){return Lt.DEFAULT},onclick:()=>t.showTextPrompt(),children:(e,t)=>{Gr(),K(e,is(`Add other item`))},$$slots:{default:!0}})};return ps(f,e=>{t.allowOther&&e(p)}),V(u),K(e,c),ai(s)}Yo([`contextmenu`]);var vl=class extends dc{filterValue(e){return hn(e)}getFallbackDefaultValue(){return[]}getSvelteComponent(){return _l}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{showSuggester:()=>this.openModal(),showTextPrompt:()=>this.openTextModal(),allowOther:this.mountable.getArgument(kn.ALLOW_OTHER)?.value===!0}}openModal(){this.mountable.mb.internal.openSuggesterModal(this,e=>{this.svelteWrapper?.getInstance()?.pushValue(e.value)})}openTextModal(){this.mountable.mb.internal.openTextPromptModal({title:`Meta Bind List Suggester`,subTitle:`Create a new List Element.`,value:``,multiline:!1,onSubmit:e=>{this.svelteWrapper?.getInstance()?.pushValue(e)},onCancel:()=>{}})}};new Set([`$$slots`,`$$events`,`$$legacy`]);var yl=G(`
`);function bl(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e){W(n).includes(e)?pa(n,W(n).filter(t=>t!==e),!0):W(n).push(e),t.onValueChange(ei(W(n)))}function a(e,t){e.key===` `&&i(t)}var o={setValue:r},s=as();return vs(ka(s),17,()=>t.options,ms,(e,t)=>{var r=yl();let o;var s=H(r);Ws(s),qc(U(s,2),{get value(){return W(t).name}}),V(r),Xa((e,t,n)=>{o=Ns(r,1,`mb-select-input-element mb-mod-multi`,null,o,e),qs(r,`data-value`,t),Ks(s,n)},[()=>({"is-selected":W(n).includes(W(t).value)}),()=>pn(W(t).value),()=>W(n).includes(W(t).value)]),Jo(`click`,r,e=>{e.target instanceof HTMLInputElement||i(W(t).value)}),qo(`keypress`,r,e=>a(e,W(t).value)),Jo(`input`,s,()=>i(W(t).value)),K(e,r)}),K(e,s),ai(o)}Yo([`click`,`input`]);var xl=class extends dc{options;constructor(e){super(e),this.options=this.mountable.getArguments(kn.OPTION)}filterValue(e){return hn(e)}getFallbackDefaultValue(){return[]}getSvelteComponent(){return bl}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{options:this.options}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Sl=G(``);function Cl(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}var i={setValue:r},a=Sl();return Ws(a),Xa(()=>qs(a,`placeholder`,t.placeholder)),Jo(`input`,a,()=>t.onValueChange(ei(W(n)))),Zs(a,()=>W(n),e=>pa(n,e)),K(e,a),ai(i)}Yo([`input`]);var wl=class extends dc{filterValue(e){return gn(e)}getFallbackDefaultValue(){return null}getSvelteComponent(){return Cl}rawReverseMapValue(e){return e}rawMapValue(e){return e}getMountArgs(){return{placeholder:this.mountable.getArgument(kn.PLACEHOLDER)?.value??`Number`}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Tl=G(` `,1),El=G(`
`);function Dl(e,t){ii(t,!0);let n=da(va(t.value)),r=!1,i,a=0,o;function s(e){pa(n,e,!0)}function c(e){pa(n,e,!0),t.onValueChange(e)}function l(e){return e=y(e,t.minValue,t.maxValue),x(e,t.minValue,t.maxValue,0,100)}function u(){r=!0}function d(){r=!1}function f(e){u(),p(e)}function p(e){r&&(e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),m(e instanceof TouchEvent?e.touches[0].clientX:e.clientX))}function m(e){let n=i.getBoundingClientRect();e=y(e,n.left,n.right);let r=x(e,n.left,n.right,t.minValue,t.maxValue);r=h(r,t.stepSize),c(r)}function h(e,t){return Number.parseFloat((Math.round(e/t)*t).toFixed(10))}function g(e){a<50&&(a+=1);let r=Math.ceil(a/5);(e.key===`ArrowUp`||e.key===`ArrowRight`)&&c(y(W(n)+r,t.minValue,t.maxValue)),(e.key===`ArrowDown`||e.key===`ArrowLeft`)&&c(y(W(n)-r,t.minValue,t.maxValue)),window.clearTimeout(o),o=window.setTimeout(()=>a=1,100)}var _={setValue:s},v=El();qo(`touchmove`,xa,p,void 0,!1),qo(`touchcancel`,xa,d),qo(`touchend`,xa,d),qo(`mousemove`,xa,p),qo(`mouseup`,xa,d);var b=H(v),S=U(b,2),C=e=>{var r=Tl(),i=ka(r),a=H(i,!0);V(i);var o=U(i,2),s=H(o,!0);V(o);var c=U(o,2),l=H(c,!0);V(c),Xa(()=>{os(a,W(n)),os(s,t.minValue),os(l,t.maxValue)}),K(e,r)};return ps(S,e=>{t.addLabels&&e(C)}),V(v),tc(v,e=>i=e,()=>i),Xa((e,r)=>{qs(v,`aria-label`,e),Fs(b,r),qs(b,`aria-valuemin`,t.minValue),qs(b,`aria-valuemax`,t.maxValue),qs(b,`aria-valuenow`,W(n))},[()=>W(n).toString(),()=>`width: ${l(W(n))}%`]),Jo(`keydown`,v,g),Jo(`mousedown`,v,f),Jo(`touchstart`,v,f,void 0,!0),qo(`dragstart`,b,()=>r=!0),K(e,v),ai(_)}Yo([`keydown`,`mousedown`,`touchstart`]);var Ol=class extends dc{minValue;maxValue;stepSize;constructor(e){if(super(e),this.minValue=this.mountable.getArgument(kn.MIN_VALUE)?.value??0,this.maxValue=this.mountable.getArgument(kn.MAX_VALUE)?.value??100,this.stepSize=this.mountable.getArgument(kn.STEP_SIZE)?.value??1,this.minValue>=this.maxValue)throw new Se({errorLevel:z.ERROR,effect:`can not create progress bar input field`,cause:`minValue (${this.maxValue}) must be less than maxValue (${this.maxValue})`})}filterValue(e){return b(gn(e),this.minValue,this.maxValue)}getFallbackDefaultValue(){return this.minValue}getSvelteComponent(){return Dl}rawReverseMapValue(e){return e}rawMapValue(e){return e}getMountArgs(){return{minValue:this.minValue,maxValue:this.maxValue,stepSize:this.stepSize,addLabels:(this.mountable.getArgument(kn.ADD_LABELS)?.value??!0)===!0}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var kl=G(`
`);function Al(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e){W(n)===e?pa(n,null):pa(n,e,!0),t.onValueChange(ei(W(n)))}function a(e,t){e.key===` `&&i(t)}var o={setValue:r},s=as();return vs(ka(s),17,()=>t.options,ms,(e,t)=>{var r=kl();let o;var s=H(r);Ws(s),qc(U(s,2),{get value(){return W(t).name}}),V(r),Xa(e=>{o=Ns(r,1,`mb-select-input-element`,null,o,{"is-selected":W(t).value===W(n)}),qs(r,`data-value`,e),Ks(s,W(t).value===W(n))},[()=>pn(W(t).value)]),Jo(`click`,r,e=>{e.target instanceof HTMLInputElement||i(W(t).value)}),qo(`keypress`,r,e=>a(e,W(t).value)),Jo(`input`,s,()=>i(W(t).value)),K(e,r)}),K(e,s),ai(o)}Yo([`click`,`input`]);var jl=class extends dc{options;constructor(e){super(e),this.options=this.mountable.getArguments(kn.OPTION)}filterValue(e){return vn(e)}getFallbackDefaultValue(){return null}getSvelteComponent(){return Al}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{options:this.options}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Ml=G(` `),Nl=G(` `,1);function Pl(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}var i={setValue:r},a=Nl(),o=ka(a),s=e=>{var n=Ml(),r=H(n,!0);V(n),Xa(()=>os(r,t.minValue)),K(e,n)};ps(o,e=>{t.addLabels&&e(s)});var c=U(o,2);Ws(c);var l=U(c,2),u=e=>{var n=Ml(),r=H(n,!0);V(n),Xa(()=>os(r,t.maxValue)),K(e,n)};return ps(l,e=>{t.addLabels&&e(u)}),Xa(e=>{qs(c,`aria-label`,e),qs(c,`min`,t.minValue),qs(c,`max`,t.maxValue),qs(c,`step`,t.stepSize)},[()=>W(n).toString()]),Jo(`input`,c,()=>t.onValueChange(ei(W(n)))),Zs(c,()=>W(n),e=>pa(n,e)),K(e,a),ai(i)}Yo([`input`]);var Fl=class extends dc{minValue;maxValue;stepSize;constructor(e){if(super(e),this.minValue=this.mountable.getArgument(kn.MIN_VALUE)?.value??0,this.maxValue=this.mountable.getArgument(kn.MAX_VALUE)?.value??100,this.stepSize=this.mountable.getArgument(kn.STEP_SIZE)?.value??1,this.minValue>=this.maxValue)throw new Se({errorLevel:z.ERROR,effect:`can not create slider input field`,cause:`minValue (${this.maxValue}) must be less than maxValue (${this.maxValue})`})}filterValue(e){return b(gn(e),this.minValue,this.maxValue)}getFallbackDefaultValue(){return this.minValue}getSvelteComponent(){return Pl}rawReverseMapValue(e){return e}rawMapValue(e){return e}getMountArgs(){return{minValue:this.minValue,maxValue:this.maxValue,stepSize:this.stepSize,addLabels:this.mountable.getArgument(kn.ADD_LABELS)?.value===!0}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Il=G(` `),Ll=G(`
`);function Rl(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}let i=Mi(()=>W(n)?.toString()??`null`),a=Mi(()=>{if(rn.isLink(W(i)))try{return rn.parseLink(W(i))}catch(e){console.warn(e)}});var o={setValue:r},s=Ll(),c=H(s),l=H(c),u=e=>{Bc(e,{get mdLink(){return W(a)}})},d=e=>{var t=Il(),n=H(t,!0);V(t),Xa(()=>os(n,W(i))),K(e,t)};ps(l,e=>{W(a)===void 0?e(d,-1):e(u)}),V(c);var f=U(c,2);Ac(f,{get variant(){return Lt.PLAIN},get onclick(){return t.showSuggester},children:(e,n)=>{gc(e,{get mb(){return t.mb},iconName:`list`})},$$slots:{default:!0}});var p=U(f,2),m=e=>{Ac(e,{get variant(){return Lt.PLAIN},get onclick(){return t.showTextPrompt},children:(e,n)=>{gc(e,{get mb(){return t.mb},iconName:`pencil`})},$$slots:{default:!0}})};return ps(p,e=>{t.allowOther&&e(m)}),V(s),K(e,s),ai(o)}var zl=class extends dc{filterValue(e){return vn(e)}getFallbackDefaultValue(){return null}getSvelteComponent(){return Rl}rawMapValue(e){return e}rawReverseMapValue(e){return e}getMountArgs(){return{showSuggester:()=>this.openModal(),showTextPrompt:()=>this.openTextModal(),allowOther:this.mountable.getArgument(kn.ALLOW_OTHER)?.value===!0}}openModal(){this.mountable.mb.internal.openSuggesterModal(this,e=>this.setInternalValue(e.value))}openTextModal(){this.mountable.mb.internal.openTextPromptModal({title:`Meta Bind Suggester`,subTitle:`Set the suggester value.`,value:``,multiline:!1,onSubmit:e=>{this.setInternalValue(e)},onCancel:()=>{}})}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Bl=G(` `),Vl=G(` `,1);function Hl(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(e,t){let n=t.toString();return`${e.toString().padStart(n.length,`0`)}/${n}`}var a={setValue:r},o=Vl(),s=ka(o);Ws(s);var c=U(s,2),l=e=>{var r=Bl(),a=H(r,!0);V(r),Xa(e=>{Ns(r,1,`mb-content-limit-indicator ${W(n).length>t.limit?`mb-content-limit-indicator-overflow`:``}`),os(a,e)},[()=>i(W(n).length,t.limit)]),K(e,r)};return ps(c,e=>{t.limit!==void 0&&e(l)}),Xa(()=>{qs(s,`placeholder`,t.placeholder),qs(s,`maxlength`,t.limit)}),Jo(`input`,s,()=>t.onValueChange(ei(W(n)))),Zs(s,()=>W(n),e=>pa(n,e)),K(e,o),ai(a)}Yo([`input`]);var Ul=class extends dc{filterValue(e){return _n(e)}getFallbackDefaultValue(){return``}getSvelteComponent(){return Hl}rawReverseMapValue(e){return e}rawMapValue(e){return e}getMountArgs(){return{placeholder:this.mountable.getArgument(kn.PLACEHOLDER)?.value??`Text`,limit:this.mountable.getArgument(kn.LIMIT)?.value}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Wl=G(``);function Gl(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}var i={setValue:r},a=Wl();return Pa(a),Xa(()=>{qs(a,`placeholder`,t.placeholder),qs(a,`maxlength`,t.limit)}),Jo(`input`,a,()=>t.onValueChange(ei(W(n)))),Zs(a,()=>W(n),e=>pa(n,e)),K(e,a),ai(i)}Yo([`input`]);var Kl=class extends dc{filterValue(e){return _n(e)}getFallbackDefaultValue(){return``}getSvelteComponent(){return Gl}rawReverseMapValue(e){return e}rawMapValue(e){return e}getMountArgs(){return{placeholder:this.mountable.getArgument(kn.PLACEHOLDER)?.value??`Text`,limit:this.mountable.getArgument(kn.LIMIT)?.value}}};new Set([`$$slots`,`$$events`,`$$legacy`]);var ql=G(``);function Jl(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}var i={setValue:r},a=ql();return Ws(a),Jo(`input`,a,()=>t.onValueChange(ei(W(n)))),Zs(a,()=>W(n),e=>pa(n,e)),K(e,a),ai(i)}Yo([`input`]);var Yl=class extends dc{filterValue(e){return _n(e)}getFallbackDefaultValue(){return`00:00`}getSvelteComponent(){return Jl}rawMapValue(e){return e}rawReverseMapValue(e){return e}};new Set([`$$slots`,`$$events`,`$$legacy`]);var Xl=G(`
`);function Zl(e,t){ii(t,!0);let n=da(va(t.value));function r(e){pa(n,e,!0)}function i(){pa(n,!W(n)),t.onValueChange(ei(W(n)))}function a(e){e.key===` `&&i()}var o={setValue:r},s=Xl();let c;var l=H(s);return Ws(l),V(s),Xa(()=>{c=Ns(s,1,`checkbox-container`,null,c,{"is-enabled":W(n)}),qs(s,`aria-checked`,W(n)),Ks(l,W(n))}),Jo(`click`,s,()=>i()),Jo(`keydown`,s,e=>a(e)),K(e,s),ai(o)}Yo([`click`,`keydown`]);var Ql=class extends dc{onValue;offValue;constructor(e){super(e),this.onValue=this.mountable.getArgument(kn.ON_VALUE)?.value??!0,this.offValue=this.mountable.getArgument(kn.OFF_VALUE)?.value??!1}filterValue(e){return e===this.onValue||e===this.offValue?vn(e):void 0}getFallbackDefaultValue(){return!1}getSvelteComponent(){return Zl}rawReverseMapValue(e){return e===this.onValue?!0:(this.offValue,!1)}rawMapValue(e){return e?this.onValue:this.offValue}},$l=class{static linkToInputField(e){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/reference/inputfields/${e.toLowerCase()}/`}static linkToInputFieldArgument(e){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/reference/inputfieldarguments/${e.toLowerCase()}/`}static linkToViewField(e){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/reference/viewfields/${e.toLowerCase()}/`}static linkToViewFieldArgument(e){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/reference/viewfieldarguments/${e.toLowerCase()}/`}static linkToInputFields(){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/guides/inputfields/`}static linkToViewFields(){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/guides/viewfields/`}static linkToButtons(){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/guides/buttons/#button-configuration`}static linkToButtonConfig(){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/guides/buttons/#button-configuration`}static linkToSearch(e){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/?s=${encodeURIComponent(e)}`}static linkToHome(){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/`}static linkToGithub(){return`https://github.com/mProjectsCode/obsidian-meta-bind-plugin`}static linkToIssues(){return`https://github.com/mProjectsCode/obsidian-meta-bind-plugin/issues`}static linkToCanaryBuilds(){return`https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/guides/installation/#canary-builds`}static open(e){O(e)}},eu=class{mb;constructor(e){this.mb=e}createInputField(e){let t=e.declaration.inputFieldType,n=e.renderChildType;if(t!==On.INVALID&&this.checkRenderChildTypeAllowed(t,n),t===On.TOGGLE)return new Ql(e);if(t===On.SLIDER)return new Fl(e);if(t===On.TEXT)return new Ul(e);if(t===On.TEXT_AREA)return new Kl(e);if(t===On.SELECT)return new jl(e);if(t===On.MULTI_SELECT)return new xl(e);if(t===On.DATE_PICKER)return new yc(e);if(t===On.NUMBER)return new wl(e);if(t===On.SUGGESTER)return new zl(e);if(t===On.EDITOR)return new Oc(e);if(t===On.PROGRESS_BAR)return new Ol(e);if(t===On.INLINE_SELECT)return new al(e);if(t===On.IMAGE_SUGGESTER)return new Rc(e);if(t===On.LIST)return new pl(e);if(t===On.LIST_SUGGESTER)return new vl(e);if(t===On.DATE)return new mc(e);if(t===On.TIME)return new Yl(e);if(t===On.INLINE_LIST_SUGGESTER)return new tl(e);if(t===On.INLINE_LIST)return new Zc(e);if(t===On.IMAGE_LIST_SUGGESTER)return new Pc(e);if(t===On.DATE_TIME)return new Sc(e)}checkRenderChildTypeAllowed(e,t){if(this.mb.getSettings().ignoreCodeBlockRestrictions)return;let n=An[e];if(t===fe.BLOCK&&!n.allowInBlock)throw new ye({errorLevel:z.ERROR,effect:`can not create input field`,cause:`input fields of type '${e}' are not allowed inside of code blocks`,docs:[$l.linkToInputField(e)]});if(t===fe.INLINE&&!n.allowInline)throw new ye({errorLevel:z.ERROR,effect:`can not create input field`,cause:`input fields of type '${e}' are not allowed inside of inline code blocks`,docs:[$l.linkToInputField(e)]})}},tu=class extends sc{mb;mountable;metadataSubscription;variables;hidden;constructor(e){super(),this.mountable=e,this.mb=e.mb,this.variables=[],this.hidden=!1}async initialRender(e){this.mb.domHelpers.addClass(e,`mb-view-text`),this.hidden=this.mountable.getArgument(Pn.HIDDEN)?.value??!1,this.hidden&&this.mb.domHelpers.addClass(e,`mb-view-hidden`),await this.onInitialRender(e)}async rerender(e,t){this.hidden||await this.onRerender(e,t)}onMount(e){this.buildVariables(),this.initialRender(e),this.metadataSubscription=this.mountable.mb.metadataManager.subscribeDerived(this.mountable.getUuid(),this.mountable.getDeclaration().writeToBindTarget,this.variables.map(e=>e.bindTargetDeclaration),this.variables.map(e=>e.metadataSignal),async()=>{let t=await this.computeValue();return this.rerender(e,t),this.mapValue(t)},()=>this.mountable.unmount())}onUnmount(){this.metadataSubscription?.unsubscribe()}},nu=G(`
`);function ru(e,t){ii(t,!0);let n=nc(t,`internal`,3,!0),r=Mi(()=>n()?t.mb.internal.imagePathToUri(t.image):t.image);var i=nu(),a=H(i);V(i),Xa(()=>{qs(a,`src`,W(r)),qs(a,`alt`,t.image)}),K(e,i),ai()}var iu=G(`No images`),au=G(`
`);function ou(e,t){ii(t,!0);let n=nc(t,`images`,23,()=>[]);function r(e){n(e)}var i={updateImages:r},a=au();return vs(a,21,n,ms,(e,n)=>{ru(e,{get mb(){return t.mb},get image(){return W(n).link},get internal(){return W(n).internal}})},e=>{K(e,iu())}),V(a),K(e,a),ai(i)}var su=class extends tu{component;linkVariable;constructor(e){super(e)}buildVariables(){let e=this.mountable.getDeclaration().templateDeclaration.filter(e=>typeof e==`string`?e:!0);if(e.length!==1)throw new be({errorLevel:z.ERROR,effect:`can not create view field`,cause:`image view filed only supports exactly a single bind target and not text content`});let t=e[0];if(typeof t==`string`)throw new be({errorLevel:z.ERROR,effect:`can not create view field`,cause:`image view filed only supports exactly a single bind target and not text content`});t.listenToChildren=!0,this.linkVariable={bindTargetDeclaration:t,metadataSignal:new lc(void 0),uuid:E(),contextName:`MB_VAR_0`},this.variables.push(this.linkVariable)}computeValue(){let e=this.linkVariable.metadataSignal.get();if(typeof e==`string`){let t=rn.interpretAsLink(e);return t===void 0?void 0:[t]}else if(Array.isArray(e))return e.filter(e=>typeof e==`string`).map(e=>rn.interpretAsLink(e)).filter(e=>e!==void 0);else return}mapValue(e){return e===void 0?``:Array.isArray(e)?e.map(e=>e.toString()):e.toString()}onInitialRender(e){this.component=ss(ou,{target:e,props:{images:[],mb:this.mountable.mb}})}async onRerender(e,t){this.component?.updateImages(N(t).map(e=>({link:e.target,internal:e.internal})))}onUnmount(){super.onUnmount(),this.component&&ds(this.component)}},cu=G(``);function lu(e,t){ii(t,!0);let n=nc(t,`mdLinkList`,7);function r(e){n(e)}var i={updateList:r},a=as(),o=ka(a),s=e=>{K(e,cu())},c=e=>{Bc(e,{get mdLink(){return n()[0]}})},l=e=>{Uc(e,{get elements(){return n()},children:(e,t=qn)=>{Bc(e,{get mdLink(){return t()}})},$$slots:{default:!0}})};return ps(o,e=>{n().length===0?e(s):n().length===1?e(c,1):e(l,-1)}),K(e,a),ai(i)}var uu=class extends tu{component;linkVariable;aliasVariable;constructor(e){super(e)}buildVariables(){let e=this.mountable.getDeclaration().templateDeclaration.filter(e=>typeof e==`string`?e:!0);if(e.length!==1&&e.length!==2&&e.length!==3)throw new be({errorLevel:z.ERROR,effect:`can not create view field`,cause:`link view field must be of form "{bindTarget}" or "{bindTarget}|{bindTarget}"`});let t=e[0],n=e[1],r=e[2];if(this.variables=[],e.length===1){if(typeof t==`string`)throw new be({errorLevel:z.ERROR,effect:`can not create view field`,cause:`link view field must be of form "{bindTarget}" or "{bindTarget}|{bindTarget}"`});t.listenToChildren=!0,this.linkVariable={bindTargetDeclaration:t,metadataSignal:new lc(void 0),uuid:E(),contextName:`MB_VAR_0`},this.variables.push(this.linkVariable)}else if(e.length===2||e.length===3){if(typeof t==`string`||typeof n!=`string`)throw new be({errorLevel:z.ERROR,effect:`can not create view field`,cause:`link view field must be of form "{bindTarget}", "{bindTarget}|alias", or "{bindTarget}|{bindTarget}"`});t.listenToChildren=!0,this.linkVariable={bindTargetDeclaration:t,metadataSignal:new lc(void 0),uuid:E(),contextName:`MB_VAR_0`},this.variables.push(this.linkVariable),e.length===2?this.aliasVariable=n.slice(1):typeof r==`string`?this.aliasVariable=r:(r.listenToChildren=!0,this.aliasVariable={bindTargetDeclaration:r,metadataSignal:new lc(void 0),uuid:E(),contextName:`MB_VAR_1`},this.variables.push(this.aliasVariable))}else throw Error(`unreachable`)}getAlias(){if(this.aliasVariable)return typeof this.aliasVariable==`string`?this.aliasVariable:yn(this.aliasVariable.metadataSignal.get(),this.mountable.mb.getSettings().viewFieldDisplayNullAsEmpty)}computeValue(){let e=this.linkVariable.metadataSignal.get(),t=this.getAlias();if(typeof e==`string`){let n=rn.interpretAsLink(e);return n===void 0?void 0:(t&&(n.alias=t),[n])}else if(Array.isArray(e))return e.filter(e=>typeof e==`string`).map(e=>rn.interpretAsLink(e)).filter(e=>e!==void 0);else return}mapValue(e){return e===void 0?``:Array.isArray(e)?e.map(e=>e.toString()):e.toString()}onInitialRender(e){this.component=ss(lu,{target:e,props:{mdLinkList:[]}})}async onRerender(e,t){this.component?.updateList(N(t))}onUnmount(){super.onUnmount(),this.component&&ds(this.component)}},du=class extends tu{container;expression;expressionStr;hidden;constructor(e){super(e),this.hidden=!1}buildVariables(){let e=0;this.expressionStr=``,this.variables=[];for(let t of this.mountable.getDeclaration().templateDeclaration??[])if(typeof t!=`string`){let n={bindTargetDeclaration:t,metadataSignal:new lc(void 0),uuid:E(),contextName:`MB_VAR_${e}`};this.variables.push(n),this.expressionStr+=n.contextName,e+=1}else this.expressionStr+=t;this.expression=this.mb.math.compile(this.expressionStr)}buildMathJSContext(){let e={};for(let t of this.variables??[])!t.contextName||!t.metadataSignal||(e[t.contextName]=t.metadataSignal.get()??``);return e}computeValue(){if(!this.expression)return this.handleComputeError(new we({errorLevel:z.ERROR,effect:`failed to evaluate expression`,cause:`expression is undefined`}));let e=this.buildMathJSContext();try{return{value:fn(`${this.expression.evaluate(e)}`),error:!1}}catch(t){return t instanceof Error?this.handleComputeError(new we({errorLevel:z.ERROR,effect:`failed to evaluate expression`,cause:t,context:{expression:this.expressionStr,context:e}})):this.handleComputeError(Error(`failed to evaluate js expression because of unexpected thrown value`))}}mapValue(e){return e.value}onInitialRender(e){}onRerender(e,t){let n=yn(t?.value,this.mountable.mb.getSettings().viewFieldDisplayNullAsEmpty)??``;t?.error?this.mb.domHelpers.addClass(e,`mb-error`):this.mb.domHelpers.removeClass(e,`mb-error`),e.innerText=n}handleComputeError(e){return console.warn(e),{error:!0,value:e.message}}},fu=class extends tu{textParts;renderMarkdown;markdownUnloadCallback;constructor(e){super(e),this.renderMarkdown=!1}buildVariables(){this.textParts=[];let e=0;this.variables=[];for(let t of this.mountable.getDeclaration().templateDeclaration??[])if(typeof t!=`string`){let n={bindTargetDeclaration:t,metadataSignal:new lc(void 0),uuid:E(),contextName:`MB_VAR_${e}`};this.variables.push(n),this.textParts.push(n),e+=1}else this.textParts.push(t)}computeValue(){if(!this.textParts)throw new we({errorLevel:z.CRITICAL,effect:`failed to evaluate text view field`,cause:`content parts is undefined`});return this.textParts.map(e=>typeof e==`string`?e:yn(e.metadataSignal.get(),this.mountable.mb.getSettings().viewFieldDisplayNullAsEmpty)).join(``)}mapValue(e){return e}onInitialRender(e){this.renderMarkdown=this.mountable.getArgument(Pn.RENDER_MARKDOWN)?.value??!1,this.renderMarkdown&&this.mb.domHelpers.addClass(e,`mb-view-markdown`)}async onRerender(e,t){let n=yn(t,this.mountable.mb.getSettings().viewFieldDisplayNullAsEmpty)??``;this.renderMarkdown?(this.markdownUnloadCallback?.(),this.mb.domHelpers.empty(e),this.markdownUnloadCallback=await this.mountable.mb.internal.renderMarkdown(n,e,this.mountable.getFilePath())):e.innerText=n}onUnmount(){super.onUnmount(),this.markdownUnloadCallback?.()}},pu=class{mb;constructor(e){this.mb=e}createViewField(e){let t=e.declaration.viewFieldType;if(t===Nn.MATH)return new du(e);if(t===Nn.TEXT)return new fu(e);if(t===Nn.LINK)return new uu(e);if(t===Nn.IMAGE)return new su(e)}},mu=class extends Error{},hu=class extends Error{},gu=function(e){return this instanceof gu?(this.v=e,this):new gu(e)},_u;(function(e){e[e.SHORTEST=0]=`SHORTEST`,e[e.LONGEST=1]=`LONGEST`,e[e.STRICT_EQUAL=2]=`STRICT_EQUAL`})(_u||={});function*vu(e,t,...n){if(n.length===0)return;let r=[];for(let e of n)r.push(Eu(e));iterate:for(;;){let n=bu(r,e=>e.next()),i=[],a=!0,o=!1;for(let e of n){let n;e.done?(a=!1,n=t):(o=!0,n=e.value),i.push(n)}if(!a&&o)switch(e){case _u.SHORTEST:break iterate;case _u.STRICT_EQUAL:throw new hu(`Iterators must have equal lengths`)}if(!o)break;yield i}}var yu=function(e){return this instanceof yu?(this.v=e,this):new yu(e)};function*bu(e,t){for(let n of Tu(e))yield t(n)}function xu(e,t){for(let n of Tu(e))if(t(n))return!0;return!1}function Su(e){return e==null?!1:typeof e[Symbol.iterator]==`function`}function Cu(e){return e==null?!1:e.next!==void 0&&typeof e.next==`function`}var wu=function(e){return this instanceof wu?(this.v=e,this):new wu(e)};function Tu(e){if(Su(e))return e;if(Cu(e))return{[Symbol.iterator](){return e}};if(typeof e==`object`&&e)return(function*(){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(yield[t,e[t]])})();throw new mu(`Given collection is not iterable or iterator.`)}function Eu(e){if(Cu(e))return e;if(Su(e))return(function*(){for(let t of e)yield t})();throw new mu(`Given collection is not iterable or iterator.`)}var Du=function(e){return this instanceof Du?(this.v=e,this):new Du(e)};function*Ou(...e){for(let t of vu(_u.SHORTEST,void 0,...e))yield t}var ku=class{uuid;metadataManager;bindTarget;dependencies;dependencySignals;dependencySubscriptions;computeFunction;deleted;onDelete;constructor(e,t,n,r,i,a,o){this.uuid=e,this.metadataManager=t,this.bindTarget=n,this.dependencies=r,this.dependencySignals=i,this.dependencySubscriptions=[],this.computeFunction=a,this.onDelete=o,this.deleted=!1}init(){for(let[e,t]of Ou(this.dependencies,this.dependencySignals)){let n=this.uuid+`/`+E();this.dependencySubscriptions.push(this.metadataManager.subscribe(n,t,e,()=>this.delete())),t.registerListener({callback:()=>void this.computeValue()})}this.computeValue()}async computeValue(){try{let e=await this.computeFunction();this.bindTarget&&(C(this.metadataManager.readShortLived(this.bindTarget),e)||this.metadataManager.write(e,this.bindTarget,this.uuid))}catch(e){let t=e instanceof Error?e:String(e);console.warn(new ve({errorLevel:z.ERROR,effect:`Failed to run derived metadata computation`,cause:t}))}}unsubscribe(){for(let e of this.dependencySubscriptions)e.unsubscribe();this.metadataManager.unsubscribe(this)}onUpdate(e){return!1}updatable(){return!1}getDependencies(){return this.dependencies}delete(){this.deleted=!0;for(let e of this.dependencySubscriptions)e.deleted||e.delete();this.onDelete(),this.unsubscribe()}},Au=class{uuid;metadataManager;bindTarget;dependencies;dependencySignals;dependencySubscriptions;effectFunction;deleted;onDelete;constructor(e,t,n,r,i,a){this.uuid=e,this.metadataManager=t,this.bindTarget=void 0,this.dependencies=n,this.dependencySignals=r,this.dependencySubscriptions=[],this.effectFunction=i,this.deleted=!1,this.onDelete=a}init(){for(let[e,t]of Ou(this.dependencies,this.dependencySignals)){let n=this.uuid+`/`+E();this.dependencySubscriptions.push(this.metadataManager.subscribe(n,t,e,()=>this.delete())),t.registerListener({callback:()=>void this.runEffect()})}this.runEffect()}async runEffect(){try{await this.effectFunction()}catch(e){let t=e instanceof Error?e:String(e);console.warn(new ve({errorLevel:z.ERROR,effect:`Failed to run metadata effect`,cause:t}))}}unsubscribe(){for(let e of this.dependencySubscriptions)e.unsubscribe();this.metadataManager.unsubscribe(this)}onUpdate(e){return!1}updatable(){return!1}getDependencies(){return this.dependencies}delete(){this.deleted=!0;for(let e of this.dependencySubscriptions)e.deleted||e.delete();this.onDelete(),this.unsubscribe()}},ju=class{uuid;callbackSignal;value;metadataManager;bindTarget;deleted;onDelete;constructor(e,t,n,r,i){this.uuid=e,this.callbackSignal=t,this.metadataManager=n,this.bindTarget=r,this.onDelete=i,this.deleted=!1,this.value=void 0}unsubscribe(){this.metadataManager.unsubscribe(this)}write(e){C(this.metadataManager.readShortLived(this.bindTarget),e)||(this.value=e,this.metadataManager.write(e,this.bindTarget,this.uuid))}read(){return this.metadataManager.read(this.bindTarget)}onUpdate(e){try{if(!C(this.value,e)){let t=structuredClone(e);return this.value=t,this.callbackSignal.set(t),!0}}catch(e){let t=e instanceof Error?e:String(e);console.warn(new ve({errorLevel:z.ERROR,effect:`Failed to notify subscription of updated value in the cache`,cause:t}))}return!1}updatable(){return!0}getDependencies(){return[]}delete(){this.deleted=!0,this.onDelete()}},Mu=class{static get(e,t){return t.get(e).child}static tryGet(e,t){return t.tryGet(e)?.child}static fullGet(e,t){return t.get(e)}static set(e,t,n){t.set(e,n)}static setAndCreate(e,t,n){t.setAndCreate(e,n)}};function Nu(e,t){return e===void 0||t===void 0||e.storageType!==t.storageType||e.storagePath!==t.storagePath?!1:Pu(e.storageProp,t.storageProp,t.listenToChildren)}function Pu(e,t,n){let r=e.path,i=t.path;for(let e=0;ei.length?n:!0}function Fu(e){return e===void 0?`undefined`:`${e.storagePath}#${e.storageProp.toString()}`}var Iu=class{sources;defaultSource;constructor(){this.sources=new Map,this.defaultSource=`CHANGE_THE_DEFAULT_SOURCE`}registerSource(e){this.sources.set(e.id,e)}setDefaultSource(e){if(this.sources.has(e))this.defaultSource=e;else throw new ve({errorLevel:z.CRITICAL,effect:`can not set default source`,cause:`Source "${e}" does not exist`})}unregisterSource(e){this.sources.delete(e.id)}getSource(e){return this.sources.get(e)}iterateSources(){return this.sources.keys()}subscribe(e,t,n,r){let i=new ju(e,t,this,n,r);return this.subscribeSubscription(i),i}subscribeDerived(e,t,n,r,i,a){let o=new ku(e,this,t,n,r,i,a);return this.checkForLoops(o),o.init(),this.subscribeSubscription(o),o}subscribeEffect(e,t,n,r,i){let a=new Au(e,this,t,n,r,i);return a.init(),this.subscribeSubscription(a),a}unsubscribe(e){if(e.bindTarget===void 0)return;let t=this.getSource(e.bindTarget.storageType);if(t===void 0)throw new ve({errorLevel:z.ERROR,effect:`can not unsubscribe subscription`,cause:`Source "${e.bindTarget.storageType}" does not exist`});let n=t.unsubscribe(e);n.subscriptions.length===0&&(n.cyclesWithoutListeners=0)}subscribeSubscription(e){if(e.bindTarget===void 0)return;let t=this.getSource(e.bindTarget.storageType);if(t===void 0)throw new ve({errorLevel:z.ERROR,effect:`can not subscribe subscription`,cause:`Source "${e.bindTarget.storageType}" does not exist`});let n=t.subscribe(e);n.cyclesWithoutListeners=0;let r=t.readCacheItem(n,e.bindTarget.storageProp);e.onUpdate(r)}checkForLoops(e){for(let t of this.getAllSubscriptionsToDependencies(e))this.recCheckForLoops([e,t])}recCheckForLoops(e){let t=e.at(0),n=e.at(-1);if(!(n===void 0||t===void 0)){if(Nu(t.bindTarget,n.bindTarget))throw new xe({errorLevel:z.ERROR,effect:`bind target dependency loop detected`,cause:`the loop is as follows: ${e.map(e=>`"${Fu(e.bindTarget)}"`).join(` -> `)}`,docs:[`https://moritzjung.dev/obsidian-meta-bind-plugin-docs/guides/viewfields/#circular-dependencies`]});for(let t of this.getAllSubscriptionsToDependencies(n))this.recCheckForLoops([...e,t])}}getAllSubscriptionsToDependencies(e){return e.getDependencies().map(e=>this.getAllSubscriptionsToBindTarget(e)).flat()}getAllSubscriptionsToBindTarget(e){if(e===void 0)return[];let t=this.getCacheItemForBindTarget(e);return t?t.subscriptions.filter(t=>Nu(t.bindTarget,e)):[]}getCacheItemForBindTarget(e){return this.getSource(e.storageType)?.getCacheItemForStoragePath(e.storagePath)}async cycle(){let e=[];for(let t of this.sources.values())e.push(this.cycleSource(t));for(let t of await Promise.allSettled(e))t.status===`rejected`&&console.warn(`meta-bind | MetadataManager >> failed to cycle source`,t.reason)}async cycleSource(e){let t=[],n=await Promise.allSettled(e.getCacheItems().map(async n=>{if(e.onCycle(n),n.dirty)try{await e.syncExternal(n),n.dirty=!1}catch(t){console.warn(`failed to sync changes to external source for ${e.id}`,t)}n.externalWriteLock>0&&--n.externalWriteLock,n.subscriptions.length===0&&(n.cyclesWithoutListeners+=1),n.cyclesWithoutListeners>300&&e.shouldDelete(n)&&t.push(n)}));for(let t of n)t.status===`rejected`&&console.warn(`meta-bind | MetadataManager >> failed to cycle cache item in source ${e.id}`,t.reason);for(let n of t)n.subscriptions.length===0&&n.cyclesWithoutListeners>300&&e.shouldDelete(n)&&e.deleteCache(n)}write(e,t,n){let r=this.getSource(t.storageType);if(r===void 0)throw new ve({errorLevel:z.ERROR,effect:`can not write to cache`,cause:`Source "${t.storageType}" does not exist`});let i=r.writeCache(structuredClone(e),t);i.dirty=!0,i.externalWriteLock=5,this.notifyListeners(t,n)}read(e){let t=this.getSource(e.storageType);if(t===void 0)throw new ve({errorLevel:z.ERROR,effect:`can not read metadata`,cause:`Source "${e.storageType}" does not exist`});return structuredClone(t.readCache(e))}readShortLived(e){let t=this.getSource(e.storageType);if(t===void 0)throw new ve({errorLevel:z.ERROR,effect:`can not read metadata`,cause:`Source "${e.storageType}" does not exist`});return t.readCache(e)}isCacheExternalWriteLocked(e){return e.externalWriteLock>0}notifyListeners(e,t){let n=this.getSource(e.storageType);if(n===void 0)throw new ve({errorLevel:z.ERROR,effect:`can notify listeners metadata`,cause:`Source "${e.storageType}" does not exist`});let r=n.getCacheItemForStoragePath(e.storagePath);if(r!==void 0){for(let i of r.subscriptions)if(!(t!==void 0&&t===i.uuid||i.bindTarget===void 0||!i.updatable())&&Pu(e.storageProp,i.bindTarget.storageProp,i.bindTarget.listenToChildren)){let e=n.readCache(i.bindTarget);i.onUpdate(e)}}}notifyAllListeners(e,t){for(let n of t.subscriptions){if(n.bindTarget===void 0)continue;let t=e.readCache(n.bindTarget);n.onUpdate(t)}}deleteCachesForStoragePath(e){for(let t of this.sources.values()){if(!t.usesStoragePath())continue;let n=t.getCacheItemForStoragePath(e);if(n!==void 0){for(let e of[...n.subscriptions])e.delete();t.deleteCache(n)}}}constructDefaultCacheItem(){return{subscriptions:[],externalWriteLock:0,dirty:!1,cyclesWithoutListeners:0}}onExternalUpdate(e,t,n){let r=e.getCacheItemForStoragePath(t);if(r===void 0||this.isCacheExternalWriteLocked(r))return;e.writeEntireCache(n,r);let i=0;for(let e of r.subscriptions){if(e.bindTarget===void 0||!e.updatable())continue;let t=Mu.tryGet(n,e.bindTarget.storageProp);e.onUpdate(t)&&(i+=1)}}onStoragePathDeleted(e){this.deleteCachesForStoragePath(e)}onStoragePathRenamed(e,t){this.deleteCachesForStoragePath(e)}},Lu=class{activeMountables;constructor(){this.activeMountables=new Map}unloadFile(e){for(let t of this.activeMountables.values())t.getFilePath()===e&&t.unmount()}unload(){for(let e of this.activeMountables.values())e.unmount()}registerMountable(e){this.activeMountables.set(e.getUuid(),e)}unregisterMountable(e){this.activeMountables.delete(e.getUuid())}},Ru=function(e){return e.FRONTMATTER=`frontmatter`,e.MEMORY=`memory`,e.GLOBAL_MEMORY=`globalMemory`,e.SCOPE=`scope`,e}({}),zu=class e{path;constructor(e){this.path=e}get(e){if(this.path.length===0)throw Error(`can not use empty path to access object`);let t=this.path[0].get(e);for(let e of this.path.slice(1))t=e.get(t.child);return t}tryGet(e){try{return this.get(e)}catch{return}}set(e,t){if(this.path.length===0)throw Error(`can not use empty path to access object`);let n=this.path[0].get(e);for(let e of this.path.slice(1))n=e.get(n.child);n.access.set(n.parent,t)}setAndCreate(e,t){if(this.path.length===0)throw Error(`can not use empty path to access object`);let n=this.path[0].get(e);n.child===void 0&&(n.access.set(n.parent,this.getNextPathElementValue(0,t)),n=n.access.get(n.parent));for(let e=1;ee.prop)}toString(){return this.toStringArray().join(`.`)}concat(t){return new e(this.path.concat(t.path))}compareDiffArray(e){let t=Math.min(this.path.length,e.length);for(let n=0;ne.toUnvalidatedPropAccess()),listenToChildren:e.listenToChildren}}validate(e,t,n,r){let i=new zu(t.storageProp.map(e=>new We(e.type,e.prop.value))),a;a=t.storageType===void 0?this.mb.metadataManager.defaultSource:this.validateStorageType(t.storageType,e);let o=t.storagePath!==void 0,s=t.storagePath??{value:n},c=this.mb.metadataManager.getSource(a);if(c===void 0)throw new ve({errorLevel:z.CRITICAL,effect:`can not validate bind target`,cause:`Source '${a}' not found. But validation was successful. This should not happen.`,context:{fullDeclaration:e,sources:[...this.mb.metadataManager.sources.keys()]}});let l=c.validateStoragePath(s,o,e,this),u={storageType:a,storagePath:l,storageProp:i,listenToChildren:t.listenToChildren};return c.id===Ru.SCOPE?this.resolveScope(u,r):u}resolveScope(e,t){if(t===void 0)throw new Ae(z.ERROR,`Bind Target Scope Validator`,`Failed to resolve bind target scope, no scope provided`);return e.storageType=t.scope.storageType,e.storagePath=t.scope.storagePath,e.storageProp=t.scope.storageProp.concat(e.storageProp),e}validateStorageType(e,t){for(let t of this.mb.metadataManager.iterateSources())if(t===e.value)return t;throw new Ae(z.ERROR,`Bind Target Validator`,`Encountered invalid identifier. Expected token to be a storage type but received '${e?.value}'.`,t,e?.position)}validateStoragePathAsFilePath(e,t){let n=e?.value;if(n===void 0)throw new Ae(z.ERROR,`Bind Target Validator`,`Failed to parse bind target. Bind target storage path is undefined.`,t,e?.position);let r=this.mb.file.getPathByName(n);if(r===void 0)throw new Ae(z.ERROR,`Bind Target Validator`,`Failed to parse bind target. Bind target file path '${n}' not found.`,t,e?.position);return r}},Vu;function q(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;en?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Hu=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Uu=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Vu=globalThis).__zod_globalConfig??(Vu.__zod_globalConfig={});var Wu=globalThis.__zod_globalConfig;function Gu(e){return e&&Object.assign(Wu,e),Wu}function Ku(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function qu(e,t){return typeof t==`bigint`?t.toString():t}function Ju(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function Yu(e){return e==null}function Xu(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Zu(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r){};function ad(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var od=Ju(()=>{if(Wu.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function sd(e){if(ad(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(ad(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function cd(e){return sd(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var ld=new Set([`string`,`number`,`symbol`]);function ud(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function dd(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function fd(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function pd(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var md={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function hd(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return dd(e,td(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return ed(this,`shape`,e),e},checks:[]}))}function gd(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return dd(e,td(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return ed(this,`shape`,r),r},checks:[]}))}function _d(e,t){if(!sd(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return dd(e,td(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return ed(this,`shape`,n),n}}))}function vd(e,t){if(!sd(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return dd(e,td(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return ed(this,`shape`,n),n}}))}function yd(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return dd(e,td(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return ed(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function bd(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return dd(t,td(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return ed(this,`shape`,i),i},checks:[]}))}function xd(e,t,n){return dd(t,td(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return ed(this,`shape`,i),i}}))}function Sd(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Td(e){return typeof e==`string`?e:e?.message}function Ed(e,t,n){let r=e.message?e.message:Td(e.inst?._zod.def?.error?.(e))??Td(t?.error?.(e))??Td(n.customError?.(e))??Td(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Dd(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Od(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var kd=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,qu,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ad=q(`$ZodError`,kd),jd=q(`$ZodError`,kd,{Parent:Error});function Md(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Nd(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Hu;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Ed(e,a,Gu())));throw id(t,i?.callee),t}return o.value},Fd=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Ed(e,a,Gu())));throw id(t,i?.callee),t}return o.value},Id=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Hu;return a.issues.length?{success:!1,error:new(e??Ad)(a.issues.map(e=>Ed(e,i,Gu())))}:{success:!0,data:a.value}},Ld=Id(jd),Rd=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Ed(e,i,Gu())))}:{success:!0,data:a.value}},zd=Rd(jd),Bd=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Pd(e)(t,n,i)},Vd=e=>(t,n,r)=>Pd(e)(t,n,r),Hd=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Fd(e)(t,n,i)},Ud=e=>async(t,n,r)=>Fd(e)(t,n,r),Wd=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Id(e)(t,n,i)},Gd=e=>(t,n,r)=>Id(e)(t,n,r),Kd=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Rd(e)(t,n,i)},qd=e=>async(t,n,r)=>Rd(e)(t,n,r),Jd=/^[cC][0-9a-z]{6,}$/,Yd=/^[0-9a-z]+$/,Xd=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Zd=/^[0-9a-vA-V]{20}$/,Qd=/^[A-Za-z0-9]{27}$/,$d=/^[a-zA-Z0-9_-]{21}$/,ef=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,tf=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,nf=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,rf=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,af=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function of(){return new RegExp(af,`u`)}var sf=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,cf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,lf=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,uf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,df=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ff=/^[A-Za-z0-9_-]*$/,pf=/^https?$/,mf=/^\+[1-9]\d{6,14}$/,hf=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,gf=RegExp(`^${hf}$`);function _f(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function vf(e){return RegExp(`^${_f(e)}$`)}function yf(e){let t=_f({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${hf}T(?:${r})$`)}var bf=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},xf=/^-?\d+$/,Sf=/^-?\d+(?:\.\d+)?$/,Cf=/^(?:true|false)$/i,wf=/^[^A-Z]*$/,Tf=/^[^a-z]*$/,Ef=q(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Df={number:`number`,bigint:`bigint`,object:`date`},Of=q(`$ZodCheckLessThan`,(e,t)=>{Ef.init(e,t);let n=Df[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value{(t.inclusive?r.value<=t.value:r.value{Ef.init(e,t);let n=Df[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Af=q(`$ZodCheckMultipleOf`,(e,t)=>{Ef.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Zu(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),jf=q(`$ZodCheckNumberFormat`,(e,t)=>{Ef.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=md[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=xf)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}sa&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Mf=q(`$ZodCheckMaxLength`,(e,t)=>{var n;Ef.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Yu(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum{let r=n.value;if(r.length<=t.maximum)return;let i=Dd(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Nf=q(`$ZodCheckMinLength`,(e,t)=>{var n;Ef.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Yu(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Dd(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Pf=q(`$ZodCheckLengthEquals`,(e,t)=>{var n;Ef.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Yu(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Dd(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ff=q(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Ef.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),If=q(`$ZodCheckRegex`,(e,t)=>{Ff.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Lf=q(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=wf,Ff.init(e,t)}),Rf=q(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Tf,Ff.init(e,t)}),zf=q(`$ZodCheckIncludes`,(e,t)=>{Ef.init(e,t);let n=ud(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Bf=q(`$ZodCheckStartsWith`,(e,t)=>{Ef.init(e,t);let n=RegExp(`^${ud(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Vf=q(`$ZodCheckEndsWith`,(e,t)=>{Ef.init(e,t);let n=RegExp(`.*${ud(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Hf=q(`$ZodCheckOverwrite`,(e,t)=>{Ef.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Uf=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(` `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(` `))}},Wf={major:4,minor:4,patch:3},Gf=q(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Wf;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Sd(e),i;for(let a of t){if(a._zod.def.when){if(Cd(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Hu;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Sd(e,t))});else{if(e.issues.length===t)continue;r||=Sd(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Sd(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Hu;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Hu;return o.then(e=>t(e,r,a))}return t(o,r,a)}}$u(e,`~standard`,()=>({validate:t=>{try{let n=Ld(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return zd(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Kf=q(`$ZodString`,(e,t)=>{Gf.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??bf(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),qf=q(`$ZodStringFormat`,(e,t)=>{Ff.init(e,t),Kf.init(e,t)}),Jf=q(`$ZodGUID`,(e,t)=>{t.pattern??=tf,qf.init(e,t)}),Yf=q(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=nf(e)}else t.pattern??=nf();qf.init(e,t)}),Xf=q(`$ZodEmail`,(e,t)=>{t.pattern??=rf,qf.init(e,t)}),Zf=q(`$ZodURL`,(e,t)=>{qf.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===pf.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Qf=q(`$ZodEmoji`,(e,t)=>{t.pattern??=of(),qf.init(e,t)}),$f=q(`$ZodNanoID`,(e,t)=>{t.pattern??=$d,qf.init(e,t)}),ep=q(`$ZodCUID`,(e,t)=>{t.pattern??=Jd,qf.init(e,t)}),tp=q(`$ZodCUID2`,(e,t)=>{t.pattern??=Yd,qf.init(e,t)}),np=q(`$ZodULID`,(e,t)=>{t.pattern??=Xd,qf.init(e,t)}),rp=q(`$ZodXID`,(e,t)=>{t.pattern??=Zd,qf.init(e,t)}),ip=q(`$ZodKSUID`,(e,t)=>{t.pattern??=Qd,qf.init(e,t)}),ap=q(`$ZodISODateTime`,(e,t)=>{t.pattern??=yf(t),qf.init(e,t)}),op=q(`$ZodISODate`,(e,t)=>{t.pattern??=gf,qf.init(e,t)}),sp=q(`$ZodISOTime`,(e,t)=>{t.pattern??=vf(t),qf.init(e,t)}),cp=q(`$ZodISODuration`,(e,t)=>{t.pattern??=ef,qf.init(e,t)}),lp=q(`$ZodIPv4`,(e,t)=>{t.pattern??=sf,qf.init(e,t),e._zod.bag.format=`ipv4`}),up=q(`$ZodIPv6`,(e,t)=>{t.pattern??=cf,qf.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),dp=q(`$ZodCIDRv4`,(e,t)=>{t.pattern??=lf,qf.init(e,t)}),fp=q(`$ZodCIDRv6`,(e,t)=>{t.pattern??=uf,qf.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function pp(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var mp=q(`$ZodBase64`,(e,t)=>{t.pattern??=df,qf.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{pp(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function hp(e){if(!ff.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return pp(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var gp=q(`$ZodBase64URL`,(e,t)=>{t.pattern??=ff,qf.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{hp(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),_p=q(`$ZodE164`,(e,t)=>{t.pattern??=mf,qf.init(e,t)});function vp(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var yp=q(`$ZodJWT`,(e,t)=>{qf.init(e,t),e._zod.check=n=>{vp(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),bp=q(`$ZodNumber`,(e,t)=>{Gf.init(e,t),e._zod.pattern=e._zod.bag.pattern??Sf,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),xp=q(`$ZodNumberFormat`,(e,t)=>{jf.init(e,t),bp.init(e,t)}),Sp=q(`$ZodBoolean`,(e,t)=>{Gf.init(e,t),e._zod.pattern=Cf,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Cp=q(`$ZodAny`,(e,t)=>{Gf.init(e,t),e._zod.parse=e=>e}),wp=q(`$ZodUnknown`,(e,t)=>{Gf.init(e,t),e._zod.parse=e=>e}),Tp=q(`$ZodNever`,(e,t)=>{Gf.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Ep(e,t,n){e.issues.length&&t.issues.push(...wd(n,e.issues)),t.value[n]=e.value}var Dp=q(`$ZodArray`,(e,t)=>{Gf.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;eEp(t,n,e))):Ep(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Op(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...wd(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function kp(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=pd(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ap(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Op(e,n,i,t,u,d))):Op(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var jp=q(`$ZodObject`,(e,t)=>{if(Gf.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Ju(()=>kp(t));$u(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=ad,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>Op(n,t,e,s,r,i))):Op(a,t,e,s,r,i)}return i?Ap(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Mp=q(`$ZodObjectJIT`,(e,t)=>{jp.init(e,t);let n=e._zod.parse,r=Ju(()=>kp(t)),i=e=>{let t=new Uf([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=nd(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=nd(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(` if (${n}.issues.length) { if (${o} in input) { payload.issues = payload.issues.concat(${n}.issues.map(iss => ({ ...iss, path: iss.path ? [${o}, ...iss.path] : [${o}] }))); } } if (${n}.value === undefined) { if (${o} in input) { newResult[${o}] = undefined; } } else { newResult[${o}] = ${n}.value; } `):c?t.write(` if (${n}.issues.length) { payload.issues = payload.issues.concat(${n}.issues.map(iss => ({ ...iss, path: iss.path ? [${o}, ...iss.path] : [${o}] }))); } if (${n}.value === undefined) { if (${o} in input) { newResult[${o}] = undefined; } } else { newResult[${o}] = ${n}.value; } `):t.write(` const ${n}_present = ${o} in input; if (${n}.issues.length) { payload.issues = payload.issues.concat(${n}.issues.map(iss => ({ ...iss, path: iss.path ? [${o}, ...iss.path] : [${o}] }))); } if (!${n}_present && !${n}.issues.length) { payload.issues.push({ code: "invalid_type", expected: "nonoptional", input: undefined, path: [${o}] }); } if (${n}_present) { if (${n}.value === undefined) { newResult[${o}] = undefined; } else { newResult[${o}] = ${n}.value; } } `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=ad,s=!Wu.jitless,c=s&&od.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Ap([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Np(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Sd(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Ed(e,r,Gu())))}),t)}var Pp=q(`$ZodUnion`,(e,t)=>{Gf.init(e,t),$u(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),$u(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),$u(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),$u(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Xu(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Np(t,r,e,i)):Np(o,r,e,i)}}),Fp=q(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Pp.init(e,t);let n=e._zod.parse;$u(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=Ju(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!ad(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),Ip=q(`$ZodIntersection`,(e,t)=>{Gf.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Rp(e,t,n)):Rp(e,i,a)}});function Lp(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(sd(e)&&sd(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Lp(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;re.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Sd(e))return e;let o=Lp(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var zp=q(`$ZodRecord`,(e,t)=>{Gf.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!sd(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>Ed(e,r,Gu())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...wd(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...wd(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Sf.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Ed(e,r,Gu())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...wd(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...wd(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Bp=q(`$ZodEnum`,(e,t)=>{Gf.init(e,t);let n=Ku(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ld.has(typeof e)).map(e=>typeof e==`string`?ud(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Vp=q(`$ZodLiteral`,(e,t)=>{if(Gf.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?ud(e):e?ud(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Hp=q(`$ZodTransform`,(e,t)=>{Gf.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Uu(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Hu;return n.value=i,n.fallback=!0,n}});function Up(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Wp=q(`$ZodOptional`,(e,t)=>{Gf.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,$u(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),$u(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Xu(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Up(e,r)):Up(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Gp=q(`$ZodExactOptional`,(e,t)=>{Wp.init(e,t),$u(e._zod,`values`,()=>t.innerType._zod.values),$u(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Kp=q(`$ZodNullable`,(e,t)=>{Gf.init(e,t),$u(e._zod,`optin`,()=>t.innerType._zod.optin),$u(e._zod,`optout`,()=>t.innerType._zod.optout),$u(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Xu(e.source)}|null)$`):void 0}),$u(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),qp=q(`$ZodDefault`,(e,t)=>{Gf.init(e,t),e._zod.optin=`optional`,$u(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Jp(e,t)):Jp(r,t)}});function Jp(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Yp=q(`$ZodPrefault`,(e,t)=>{Gf.init(e,t),e._zod.optin=`optional`,$u(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Xp=q(`$ZodNonOptional`,(e,t)=>{Gf.init(e,t),$u(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Zp(t,e)):Zp(i,e)}});function Zp(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Qp=q(`$ZodCatch`,(e,t)=>{Gf.init(e,t),e._zod.optin=`optional`,$u(e._zod,`optout`,()=>t.innerType._zod.optout),$u(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Ed(e,n,Gu()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Ed(e,n,Gu()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),$p=q(`$ZodPipe`,(e,t)=>{Gf.init(e,t),$u(e._zod,`values`,()=>t.in._zod.values),$u(e._zod,`optin`,()=>t.in._zod.optin),$u(e._zod,`optout`,()=>t.out._zod.optout),$u(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>em(e,t.in,n)):em(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>em(e,t.out,n)):em(r,t.out,n)}});function em(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var tm=q(`$ZodReadonly`,(e,t)=>{Gf.init(e,t),$u(e._zod,`propValues`,()=>t.innerType._zod.propValues),$u(e._zod,`values`,()=>t.innerType._zod.values),$u(e._zod,`optin`,()=>t.innerType?._zod?.optin),$u(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(nm):nm(r)}});function nm(e){return e.value=Object.freeze(e.value),e}var rm=q(`$ZodCustom`,(e,t)=>{Ef.init(e,t),Gf.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>im(t,n,r,e));im(i,n,r,e)}});function im(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Od(e))}}var am,om=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function sm(){return new om}(am=globalThis).__zod_globalRegistry??(am.__zod_globalRegistry=sm());var cm=globalThis.__zod_globalRegistry;function lm(e,t){return new e({type:`string`,...fd(t)})}function um(e,t){return new e({type:`string`,coerce:!0,...fd(t)})}function dm(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...fd(t)})}function fm(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...fd(t)})}function pm(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...fd(t)})}function mm(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...fd(t)})}function hm(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...fd(t)})}function gm(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...fd(t)})}function _m(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...fd(t)})}function vm(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...fd(t)})}function ym(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...fd(t)})}function bm(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...fd(t)})}function xm(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...fd(t)})}function Sm(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...fd(t)})}function Cm(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...fd(t)})}function wm(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...fd(t)})}function Tm(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...fd(t)})}function Em(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...fd(t)})}function Dm(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...fd(t)})}function Om(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...fd(t)})}function km(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...fd(t)})}function Am(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...fd(t)})}function jm(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...fd(t)})}function Mm(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...fd(t)})}function Nm(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...fd(t)})}function Pm(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...fd(t)})}function Fm(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...fd(t)})}function Im(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...fd(t)})}function Lm(e,t){return new e({type:`number`,checks:[],...fd(t)})}function Rm(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...fd(t)})}function zm(e,t){return new e({type:`boolean`,...fd(t)})}function Bm(e){return new e({type:`any`})}function Vm(e){return new e({type:`unknown`})}function Hm(e,t){return new e({type:`never`,...fd(t)})}function Um(e,t){return new Of({check:`less_than`,...fd(t),value:e,inclusive:!1})}function Wm(e,t){return new Of({check:`less_than`,...fd(t),value:e,inclusive:!0})}function Gm(e,t){return new kf({check:`greater_than`,...fd(t),value:e,inclusive:!1})}function Km(e,t){return new kf({check:`greater_than`,...fd(t),value:e,inclusive:!0})}function qm(e,t){return new Af({check:`multiple_of`,...fd(t),value:e})}function Jm(e,t){return new Mf({check:`max_length`,...fd(t),maximum:e})}function Ym(e,t){return new Nf({check:`min_length`,...fd(t),minimum:e})}function Xm(e,t){return new Pf({check:`length_equals`,...fd(t),length:e})}function Zm(e,t){return new If({check:`string_format`,format:`regex`,...fd(t),pattern:e})}function Qm(e){return new Lf({check:`string_format`,format:`lowercase`,...fd(e)})}function $m(e){return new Rf({check:`string_format`,format:`uppercase`,...fd(e)})}function eh(e,t){return new zf({check:`string_format`,format:`includes`,...fd(t),includes:e})}function th(e,t){return new Bf({check:`string_format`,format:`starts_with`,...fd(t),prefix:e})}function nh(e,t){return new Vf({check:`string_format`,format:`ends_with`,...fd(t),suffix:e})}function rh(e){return new Hf({check:`overwrite`,tx:e})}function ih(e){return rh(t=>t.normalize(e))}function ah(){return rh(e=>e.trim())}function oh(){return rh(e=>e.toLowerCase())}function sh(){return rh(e=>e.toUpperCase())}function ch(){return rh(e=>rd(e))}function lh(e,t,n){return new e({type:`array`,element:t,...fd(n)})}function uh(e,t,n){let r=fd(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function dh(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...fd(n)})}function fh(e,t){let n=ph(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Od(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Od(r))}},e(t.value,t)),t);return n}function ph(e,t){let n=new Ef({check:`custom`,...fd(t)});return n._zod.check=e,n}function mh(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??cm,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function hh(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,hh(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&vh(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function gh(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function _h(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:bh(t,`input`,e.processors),output:bh(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function vh(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return vh(r.element,n);if(r.type===`set`)return vh(r.valueType,n);if(r.type===`lazy`)return vh(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return vh(r.innerType,n);if(r.type===`intersection`)return vh(r.left,n)||vh(r.right,n);if(r.type===`record`||r.type===`map`)return vh(r.keyType,n)||vh(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:vh(r.in,n)||vh(r.out,n);if(r.type===`object`){for(let e in r.shape)if(vh(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(vh(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(vh(e,n))return!0;return!!(r.rest&&vh(r.rest,n))}return!1}var yh=(e,t={})=>n=>{let r=mh({...n,processors:t});return hh(e,r),gh(r,e),_h(r,e)},bh=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=mh({...i??{},target:a,io:t,processors:n});return hh(e,o),gh(o,e),_h(o,e)},xh={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Sh=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=xh[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Ch=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},wh=(e,t,n,r)=>{n.type=`boolean`},Th=(e,t,n,r)=>{n.not={}},Eh=(e,t,n,r)=>{let i=e._zod.def,a=Ku(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Dh=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Oh=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},kh=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Ah=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=hh(a.element,t,{...r,path:[...r.path,`items`]})},jh=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=hh(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=hh(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Mh=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>hh(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Nh=(e,t,n,r)=>{let i=e._zod.def,a=hh(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=hh(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Ph=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=hh(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=hh(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=hh(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Fh=(e,t,n,r)=>{let i=e._zod.def,a=hh(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ih=(e,t,n,r)=>{let i=e._zod.def;hh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Lh=(e,t,n,r)=>{let i=e._zod.def;hh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Rh=(e,t,n,r)=>{let i=e._zod.def;hh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},zh=(e,t,n,r)=>{let i=e._zod.def;hh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Bh=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;hh(o,t,r);let s=t.seen.get(e);s.ref=o},Vh=(e,t,n,r)=>{let i=e._zod.def;hh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Hh=(e,t,n,r)=>{let i=e._zod.def;hh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Uh=q(`ZodISODateTime`,(e,t)=>{ap.init(e,t),gg.init(e,t)});function Wh(e){return Nm(Uh,e)}var Gh=q(`ZodISODate`,(e,t)=>{op.init(e,t),gg.init(e,t)});function Kh(e){return Pm(Gh,e)}var qh=q(`ZodISOTime`,(e,t)=>{sp.init(e,t),gg.init(e,t)});function Jh(e){return Fm(qh,e)}var Yh=q(`ZodISODuration`,(e,t)=>{cp.init(e,t),gg.init(e,t)});function Xh(e){return Im(Yh,e)}var Zh=q(`ZodError`,(e,t)=>{Ad.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Nd(e,t)},flatten:{value:t=>Md(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,qu,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,qu,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Qh=Pd(Zh),$h=Fd(Zh),eg=Id(Zh),tg=Rd(Zh),ng=Bd(Zh),rg=Vd(Zh),ig=Hd(Zh),ag=Ud(Zh),og=Wd(Zh),sg=Gd(Zh),cg=Kd(Zh),lg=qd(Zh),ug=new WeakMap;function dg(e,t,n){let r=Object.getPrototypeOf(e),i=ug.get(r);if(i||(i=new Set,ug.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var fg=q(`ZodType`,(e,t)=>(Gf.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:bh(e,`input`),output:bh(e,`output`)}}),e.toJSONSchema=yh(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Qh(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>eg(e,t,n),e.parseAsync=async(t,n)=>$h(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>tg(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ng(e,t,n),e.decode=(t,n)=>rg(e,t,n),e.encodeAsync=async(t,n)=>ig(e,t,n),e.decodeAsync=async(t,n)=>ag(e,t,n),e.safeEncode=(t,n)=>og(e,t,n),e.safeDecode=(t,n)=>sg(e,t,n),e.safeEncodeAsync=async(t,n)=>cg(e,t,n),e.safeDecodeAsync=async(t,n)=>lg(e,t,n),dg(e,`ZodType`,{check(...e){let t=this.def;return this.clone(td(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return dd(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(M_(e,t))},superRefine(e,t){return this.check(N_(e,t))},overwrite(e){return this.check(rh(e))},optional(){return p_(this)},exactOptional(){return h_(this)},nullable(){return __(this)},nullish(){return p_(__(this))},nonoptional(e){return C_(this,e)},array(){return Yg(this)},or(e){return $g([this,e])},and(e){return r_(this,e)},transform(e){return D_(this,d_(e))},default(e){return y_(this,e)},prefault(e){return x_(this,e)},catch(e){return T_(this,e)},pipe(e){return D_(this,e)},readonly(){return k_(this)},describe(e){let t=this.clone();return cm.add(t,{description:e}),t},meta(...e){if(e.length===0)return cm.get(this);let t=this.clone();return cm.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return cm.get(e)?.description},configurable:!0}),e)),pg=q(`_ZodString`,(e,t)=>{Kf.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sh(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,dg(e,`_ZodString`,{regex(...e){return this.check(Zm(...e))},includes(...e){return this.check(eh(...e))},startsWith(...e){return this.check(th(...e))},endsWith(...e){return this.check(nh(...e))},min(...e){return this.check(Ym(...e))},max(...e){return this.check(Jm(...e))},length(...e){return this.check(Xm(...e))},nonempty(...e){return this.check(Ym(1,...e))},lowercase(e){return this.check(Qm(e))},uppercase(e){return this.check($m(e))},trim(){return this.check(ah())},normalize(...e){return this.check(ih(...e))},toLowerCase(){return this.check(oh())},toUpperCase(){return this.check(sh())},slugify(){return this.check(ch())}})}),mg=q(`ZodString`,(e,t)=>{Kf.init(e,t),pg.init(e,t),e.email=t=>e.check(dm(_g,t)),e.url=t=>e.check(_m(bg,t)),e.jwt=t=>e.check(Mm(Fg,t)),e.emoji=t=>e.check(vm(xg,t)),e.guid=t=>e.check(fm(vg,t)),e.uuid=t=>e.check(pm(yg,t)),e.uuidv4=t=>e.check(mm(yg,t)),e.uuidv6=t=>e.check(hm(yg,t)),e.uuidv7=t=>e.check(gm(yg,t)),e.nanoid=t=>e.check(ym(Sg,t)),e.guid=t=>e.check(fm(vg,t)),e.cuid=t=>e.check(bm(Cg,t)),e.cuid2=t=>e.check(xm(wg,t)),e.ulid=t=>e.check(Sm(Tg,t)),e.base64=t=>e.check(km(Mg,t)),e.base64url=t=>e.check(Am(Ng,t)),e.xid=t=>e.check(Cm(Eg,t)),e.ksuid=t=>e.check(wm(Dg,t)),e.ipv4=t=>e.check(Tm(Og,t)),e.ipv6=t=>e.check(Em(kg,t)),e.cidrv4=t=>e.check(Dm(Ag,t)),e.cidrv6=t=>e.check(Om(jg,t)),e.e164=t=>e.check(jm(Pg,t)),e.datetime=t=>e.check(Wh(t)),e.date=t=>e.check(Kh(t)),e.time=t=>e.check(Jh(t)),e.duration=t=>e.check(Xh(t))});function hg(e){return lm(mg,e)}var gg=q(`ZodStringFormat`,(e,t)=>{qf.init(e,t),pg.init(e,t)}),_g=q(`ZodEmail`,(e,t)=>{Xf.init(e,t),gg.init(e,t)}),vg=q(`ZodGUID`,(e,t)=>{Jf.init(e,t),gg.init(e,t)}),yg=q(`ZodUUID`,(e,t)=>{Yf.init(e,t),gg.init(e,t)}),bg=q(`ZodURL`,(e,t)=>{Zf.init(e,t),gg.init(e,t)}),xg=q(`ZodEmoji`,(e,t)=>{Qf.init(e,t),gg.init(e,t)}),Sg=q(`ZodNanoID`,(e,t)=>{$f.init(e,t),gg.init(e,t)}),Cg=q(`ZodCUID`,(e,t)=>{ep.init(e,t),gg.init(e,t)}),wg=q(`ZodCUID2`,(e,t)=>{tp.init(e,t),gg.init(e,t)}),Tg=q(`ZodULID`,(e,t)=>{np.init(e,t),gg.init(e,t)}),Eg=q(`ZodXID`,(e,t)=>{rp.init(e,t),gg.init(e,t)}),Dg=q(`ZodKSUID`,(e,t)=>{ip.init(e,t),gg.init(e,t)}),Og=q(`ZodIPv4`,(e,t)=>{lp.init(e,t),gg.init(e,t)}),kg=q(`ZodIPv6`,(e,t)=>{up.init(e,t),gg.init(e,t)}),Ag=q(`ZodCIDRv4`,(e,t)=>{dp.init(e,t),gg.init(e,t)}),jg=q(`ZodCIDRv6`,(e,t)=>{fp.init(e,t),gg.init(e,t)}),Mg=q(`ZodBase64`,(e,t)=>{mp.init(e,t),gg.init(e,t)}),Ng=q(`ZodBase64URL`,(e,t)=>{gp.init(e,t),gg.init(e,t)}),Pg=q(`ZodE164`,(e,t)=>{_p.init(e,t),gg.init(e,t)}),Fg=q(`ZodJWT`,(e,t)=>{yp.init(e,t),gg.init(e,t)}),Ig=q(`ZodNumber`,(e,t)=>{bp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ch(e,t,n,r),dg(e,`ZodNumber`,{gt(e,t){return this.check(Gm(e,t))},gte(e,t){return this.check(Km(e,t))},min(e,t){return this.check(Km(e,t))},lt(e,t){return this.check(Um(e,t))},lte(e,t){return this.check(Wm(e,t))},max(e,t){return this.check(Wm(e,t))},int(e){return this.check(zg(e))},safe(e){return this.check(zg(e))},positive(e){return this.check(Gm(0,e))},nonnegative(e){return this.check(Km(0,e))},negative(e){return this.check(Um(0,e))},nonpositive(e){return this.check(Wm(0,e))},multipleOf(e,t){return this.check(qm(e,t))},step(e,t){return this.check(qm(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Lg(e){return Lm(Ig,e)}var Rg=q(`ZodNumberFormat`,(e,t)=>{xp.init(e,t),Ig.init(e,t)});function zg(e){return Rm(Rg,e)}var Bg=q(`ZodBoolean`,(e,t)=>{Sp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wh(e,t,n,r)});function Vg(e){return zm(Bg,e)}var Hg=q(`ZodAny`,(e,t)=>{Cp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ug(){return Bm(Hg)}var Wg=q(`ZodUnknown`,(e,t)=>{wp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Gg(){return Vm(Wg)}var Kg=q(`ZodNever`,(e,t)=>{Tp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Th(e,t,n,r)});function qg(e){return Hm(Kg,e)}var Jg=q(`ZodArray`,(e,t)=>{Dp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ah(e,t,n,r),e.element=t.element,dg(e,`ZodArray`,{min(e,t){return this.check(Ym(e,t))},nonempty(e){return this.check(Ym(1,e))},max(e,t){return this.check(Jm(e,t))},length(e,t){return this.check(Xm(e,t))},unwrap(){return this.element}})});function Yg(e,t){return lh(Jg,e,t)}var Xg=q(`ZodObject`,(e,t)=>{Mp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jh(e,t,n,r),$u(e,`shape`,()=>t.shape),dg(e,`ZodObject`,{keyof(){return s_(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Gg()})},loose(){return this.clone({...this._zod.def,catchall:Gg()})},strict(){return this.clone({...this._zod.def,catchall:qg()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return _d(this,e)},safeExtend(e){return vd(this,e)},merge(e){return yd(this,e)},pick(e){return hd(this,e)},omit(e){return gd(this,e)},partial(...e){return bd(f_,this,e[0])},required(...e){return xd(S_,this,e[0])}})});function Zg(e,t){return new Xg({type:`object`,shape:e??{},...fd(t)})}var Qg=q(`ZodUnion`,(e,t)=>{Pp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mh(e,t,n,r),e.options=t.options});function $g(e,t){return new Qg({type:`union`,options:e,...fd(t)})}var e_=q(`ZodDiscriminatedUnion`,(e,t)=>{Qg.init(e,t),Fp.init(e,t)});function t_(e,t,n){return new e_({type:`union`,options:t,discriminator:e,...fd(n)})}var n_=q(`ZodIntersection`,(e,t)=>{Ip.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nh(e,t,n,r)});function r_(e,t){return new n_({type:`intersection`,left:e,right:t})}var i_=q(`ZodRecord`,(e,t)=>{zp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ph(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function a_(e,t,n){return!t||!t._zod?new i_({type:`record`,keyType:hg(),valueType:e,...fd(t)}):new i_({type:`record`,keyType:e,valueType:t,...fd(n)})}var o_=q(`ZodEnum`,(e,t)=>{Bp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eh(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new o_({...t,checks:[],...fd(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new o_({...t,checks:[],...fd(r),entries:i})}});function s_(e,t){return new o_({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...fd(t)})}var c_=q(`ZodLiteral`,(e,t)=>{Vp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dh(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function l_(e,t){return new c_({type:`literal`,values:Array.isArray(e)?e:[e],...fd(t)})}var u_=q(`ZodTransform`,(e,t)=>{Hp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kh(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Uu(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Od(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Od(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function d_(e){return new u_({type:`transform`,transform:e})}var f_=q(`ZodOptional`,(e,t)=>{Wp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hh(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function p_(e){return new f_({type:`optional`,innerType:e})}var m_=q(`ZodExactOptional`,(e,t)=>{Gp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hh(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function h_(e){return new m_({type:`optional`,innerType:e})}var g_=q(`ZodNullable`,(e,t)=>{Kp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fh(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function __(e){return new g_({type:`nullable`,innerType:e})}var v_=q(`ZodDefault`,(e,t)=>{qp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lh(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function y_(e,t){return new v_({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():cd(t)}})}var b_=q(`ZodPrefault`,(e,t)=>{Yp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rh(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function x_(e,t){return new b_({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():cd(t)}})}var S_=q(`ZodNonOptional`,(e,t)=>{Xp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ih(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function C_(e,t){return new S_({type:`nonoptional`,innerType:e,...fd(t)})}var w_=q(`ZodCatch`,(e,t)=>{Qp.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zh(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function T_(e,t){return new w_({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var E_=q(`ZodPipe`,(e,t)=>{$p.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bh(e,t,n,r),e.in=t.in,e.out=t.out});function D_(e,t){return new E_({type:`pipe`,in:e,out:t})}var O_=q(`ZodReadonly`,(e,t)=>{tm.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vh(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function k_(e){return new O_({type:`readonly`,innerType:e})}var A_=q(`ZodCustom`,(e,t)=>{rm.init(e,t),fg.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oh(e,t,n,r)});function j_(e,t){return uh(A_,e??(()=>!0),t)}function M_(e,t={}){return dh(A_,e,t)}function N_(e,t){return fh(e,t)}function P_(e,t={}){let n=new A_({type:`custom`,check:`custom`,fn:t=>t instanceof e,abort:!0,...fd(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:`invalid_type`,expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}function F_(e){return um(mg,e)}function I_(){return j_(e=>typeof e==`function`)}function L_(e,t){return function(n){return n.refine(n=>{let r=n;return r[e]===void 0!=(r[t]===void 0)},{message:`Either ${e} or ${t} must be used, but not both.`,path:[t]})}}function R_(){return function(e){return e}}function z_(e,t){let n=e.safeParse(t);if(!n.success)throw new ve({errorLevel:z.CRITICAL,effect:`Failed to run function due to invalid arguments. Check that the arguments that you are passing to the function match the type definition of the function.`,cause:n.error})}function B_(e,t){return e.safeParse(t)}var V_=[`zeroth`,`first`,`second`,`third`,`fourth`,`fifth`,`sixth`,`seventh`,`eighth`,`ninth`,`tenth`,`eleventh`,`twelfth`,`thirteenth`,`fourteenth`,`fifteenth`,`sixteenth`,`seventeenth`,`eighteenth`,`nineteenth`],H_=[`twent`,`thirt`,`fort`,`fift`,`sixt`,`sevent`,`eight`,`ninet`];function U_(e){return e<20?V_[e]:e%10==0?H_[Math.floor(e/10)-2]+`ieth`:H_[Math.floor(e/10)-2]+`y-`+V_[e%10]}function W_(e){let t=``;for(let n of e.issues){let e=G_(n.path);t+=`✖ ${n.message??n.code} \n → at '${e}'\n`}return t.trim()}function G_(e){return!e||e.length===0?`unknown location`:e.map(e=>typeof e==`string`?e:typeof e==`symbol`?e.toString():U_(e+1)+` element`).join(` > `)}function K_(e,t,n){return Lg({error:r=>r.input===void 0?`The ${e} action requires a specified ${n} with the '${t}' field.`:`The ${e} action requires the value of the '${t}' field to be a number, but got ${typeof r.input}.`})}function q_(e,t,n){return hg({error:r=>r.input===void 0?`The ${e} action requires a specified ${n} with the '${t}' field.`:`The ${e} action requires the value of the '${t}' field to be a string, but got ${typeof r.input}.`})}function J_(e,t,n){return F_({error:r=>r.input===void 0?`The ${e} action requires a specified ${n} with the '${t}' field.`:`The ${e} action requires the value of the '${t}' field to be a string, but got ${typeof r.input}.`})}function Y_(e,t,n){return Vg({error:r=>r.input===void 0?`The ${e} action requires a specified ${n} with the '${t}' field.`:`The ${e} action requires the value of the '${t}' field to be a boolean, but got ${typeof r.input}.`})}var X_=R_()(Zg({type:l_(B.COMMAND),command:q_(`command`,`command`,`command to run`)})),Z_=R_()(Zg({type:l_(B.JS),file:q_(`js`,`file`,`file path to the file to run`),args:a_(hg(),Gg()).optional()})),Q_=R_()(Zg({type:l_(B.OPEN),link:q_(`open`,`link`,`link to open`),newTab:Y_(`open`,`newTab`,`flag for whether to open in a new tab`).optional()})),$_=R_()(Zg({type:l_(B.INPUT),str:q_(`input`,`str`,`value to input`)})),ev=R_()(Zg({type:l_(B.SLEEP),ms:K_(`sleep`,`ms`,`duration`)})),tv=R_()(Zg({type:l_(B.TEMPLATER_CREATE_NOTE),templateFile:q_(`templaterCreateNote`,`templateFile`,`template file path`),folderPath:q_(`templaterCreateNote`,`folderPath`,`folder path`).optional(),fileName:q_(`templaterCreateNote`,`fileName`,`file name`).optional(),openNote:Y_(`templaterCreateNote`,`openNote`,`value for whether to open the note`).optional(),openIfAlreadyExists:Y_(`templaterCreateNote`,`openIfAlreadyExists`,`value for whether to open the note if it already exists`).optional()})),nv=R_()(Zg({type:l_(B.RUN_TEMPLATER_FILE),templateFile:q_(`runTemplaterFile`,`templateFile`,`template file path`)})),rv=R_()(Zg({type:l_(B.UPDATE_METADATA),bindTarget:q_(`updateMetadata`,`bindTarget`,`bind target to the metadata to update`),evaluate:Y_(`updateMetadata`,`evaluate`,`value for whether to evaluate the value as a JavaScript expression`),value:J_(`updateMetadata`,`value`,`value for the update`)})),iv=R_()(Zg({type:l_(B.CREATE_NOTE),folderPath:q_(`createNote`,`folderPath`,`folder path`).optional(),fileName:q_(`createNote`,`fileName`,`file name`),openNote:Y_(`createNote`,`openNote`,`value for whether to open the note`).optional(),openIfAlreadyExists:Y_(`createNote`,`openIfAlreadyExists`,`value for whether to open the note if it already exists`).optional()})),av=R_()(Zg({type:l_(B.REPLACE_IN_NOTE),fromLine:J_(`replaceInNote`,`fromLine`,`line to replace from`),toLine:J_(`replaceInNote`,`toLine`,`line to replace to`),replacement:q_(`replaceInNote`,`replacement`,`replacement string`),templater:Y_(`replaceInNote`,`templater`,`value for whether to use Templater`).optional()})),ov=R_()(Zg({type:l_(B.REPLACE_SELF),replacement:q_(`replaceSelf`,`replacement`,`replacement string`),templater:Y_(`replaceSelf`,`templater`,`value for whether to use Templater`).optional()})),sv=R_()(Zg({type:l_(B.REGEXP_REPLACE_IN_NOTE),regexp:q_(`regexpReplaceInNote`,`regexp`,`search regular expression`),regexpFlags:q_(`regexpReplaceInNote`,`regexpFlags`,`regular expression flags string`).optional(),replacement:q_(`regexpReplaceInNote`,`replacement`,`replacement string`)})),cv=R_()(Zg({type:l_(B.INSERT_INTO_NOTE),line:J_(`insertIntoNote`,`line`,`line to insert at`),value:q_(`insertIntoNote`,`value`,`string to insert`),templater:Y_(`insertIntoNote`,`templater`,`value for whether to use Templater`).optional()})),lv=R_()(Zg({type:l_(B.INLINE_JS),code:q_(`inlineJS`,`code`,`code string to run`),args:a_(hg(),Gg()).optional()})),uv=R_()(t_(`type`,[X_,Z_,Q_,$_,ev,tv,rv,iv,av,ov,sv,cv,lv,nv])),dv=s_(Lt),fv=R_()(L_(`action`,`actions`)(Zg({label:hg(),icon:hg().optional(),style:dv,class:hg().optional(),cssStyle:hg().optional(),backgroundImage:hg().optional(),tooltip:hg().optional(),id:hg().optional(),hidden:Vg().optional(),action:uv.optional(),actions:uv.array().optional()}))),pv=P.sequenceMap((e,t)=>t,P.string(`BUTTON`),P.manyNotOf(`[],^`).separateBy(P.string(`,`).trim(R.optionalWhitespace())).wrapString(`[`,`]`)),mv=class{mb;constructor(e){this.mb=e}fromGroupString(e){let t=new Tn(`ButtonGroup`),n=[];try{n=Oe(pv,e)}catch(e){t.add(e)}return{declarationString:e,referencedButtonIds:n,errorCollection:t}}validateGroup(e){return{declarationString:void 0,referencedButtonIds:e.referencedButtonIds,errorCollection:new Tn(`ButtonGroup`)}}fromString(e){let t=new Tn(`Button`),n;try{let t=this.mb.internal.parseYaml(this.prepareConfigYaml(e));n=this.validateConfig(t)}catch(e){t.add(e)}return{declarationString:e,config:n,errorCollection:t}}parseConfig(e){return this.validateConfig(this.mb.internal.parseYaml(this.prepareConfigYaml(e)))}prepareConfigYaml(e){let t=e.trim();return/^```[^\r\n]*\r?\n([\s\S]*?)\r?\n```$/.exec(t)?.[1].trim()??t}validateConfig(e){let t=B_(fv,e);if(!t.success){let e=W_(t.error);throw new Ee({errorLevel:z.ERROR,effect:`The validation for the button config failed.`,cause:`Your button syntax seems to be invalid. Check that your button config follows what is described in the docs.`,positionContext:e,docs:[$l.linkToButtonConfig()]})}return t.data}validate(e){let t=new Tn(`Button`),n;try{n=this.validateConfig(e)}catch(e){t.add(e)}return{declarationString:void 0,config:n,errorCollection:t}}},hv=class{mb;constructor(e){this.mb=e}stringify(e){return e.format(this.mb.getSettings().preferredDateFormat)}parse(e){return this.mb.internal.createDate(e,this.mb.getSettings().preferredDateFormat)}getDefaultDate(){return this.mb.internal.createDate()}fromDate(e){return this.mb.internal.createDate(e)}getDefaultDay(){return new Date().getDate()}getDefaultMonth(){return 1}getDefaultYear(){return new Date().getFullYear()}},gv=class{arguments=[];add(e){this.arguments.push(e)}validate(){let e={};for(let t of Object.values(kn))e[t]=0;for(let t of this.arguments){let n=t.getConfig();if(e[n.type]+=1,e[n.type]>1&&!n.allowMultiple)throw new Se({errorLevel:z.ERROR,effect:`failed to validate argument container`,cause:`argument '${n.type}' does not allow duplicates`,docs:[$l.linkToSearch(n.type)]})}}mergeByOverride(e){for(let t of e.arguments){let e=t.getConfig();e.allowMultiple||(this.arguments=this.arguments.filter(t=>t.getConfig().type!==e.type)),this.arguments.push(t)}return this.validate(),this}mergeByThrow(e){for(let t of e.arguments){let e=t.getConfig();if(!e.allowMultiple&&this.arguments.filter(t=>t.getConfig().type===e.type).length>0)throw new Se({errorLevel:z.ERROR,effect:`failed to merge argument container`,cause:`can not merge FieldArgumentContainers, since arguments overlap`});this.arguments.push(t)}return this.validate(),this}getAll(e){return this.arguments.filter(t=>t.getConfig().type===e)}get(e){return this.getAll(e).at(0)}},_v=class extends gv{getAll(e){return super.getAll(e)}get(e){return this.getAll(e).at(0)}},vv=class{value;parseValue(e){this.validateValues(e,this.getConfig().values),this._parseValue(e)}validateValues(e,t){if(t.find(t=>t.length===e.length)===void 0)throw new Se({errorLevel:z.WARNING,effect:`Failed to parse argument value for argument '${this.getConfig().type}'.`,cause:`Expected argument values to follow the form ${t.map(e=>e.length===0?`none`:e.map(e=>`'${e.name}'`).join(`, `)).join(` or `)}. Received arguments of length ${e.length}.`,docs:[$l.linkToSearch(this.getConfig().type)]})}isAllowed(e){return this.getConfig().allowedFieldTypes.length===0?!0:this.getConfig().allowedFieldTypes.includes(e)}getAllowedFieldsAsString(){return this.getConfig().allowedFieldTypes.length===0?`all`:this.getConfig().allowedFieldTypes.join(`, `)}},yv=class extends vv{},bv=class extends yv{value=!0;_parseValue(e){this.value=e[0]===void 0||e[0]?.value.toLowerCase()===`true`}getConfig(){return Mn.addLabels}},xv=class extends yv{value=!0;_parseValue(e){this.value=e[0]===void 0||e[0]?.value.toLowerCase()===`true`}getConfig(){return Mn.allowOther}},Sv=class extends yv{value=[];_parseValue(e){this.value=e[0].value.split(` `)}getConfig(){return Mn.class}},Cv=class extends yv{value=``;_parseValue(e){this.value=fn(e[0].value)}getConfig(){return Mn.defaultValue}},wv=class extends yv{value=void 0;_parseValue(e){if(this.value=Number.parseInt(e[0].value),Number.isNaN(this.value))throw new Se({errorLevel:z.WARNING,effect:`failed to set value for input field argument`,cause:`value of argument 'limit' must be of type number`,docs:[$l.linkToInputFieldArgument(this.getConfig().type)]});if(this.value<=0)throw new Se({errorLevel:z.WARNING,effect:`failed to set value for input field argument`,cause:`value of argument 'limit' must be a positive number`,docs:[$l.linkToInputFieldArgument(this.getConfig().type)]})}getConfig(){return Mn.limit}},Tv=class extends yv{value=100;_parseValue(e){if(this.value=Number.parseFloat(e[0].value),Number.isNaN(this.value))throw new Se({errorLevel:z.WARNING,effect:`failed to set value for input field argument`,cause:`value of argument 'maxValue' must be of type number`,docs:[$l.linkToInputFieldArgument(this.getConfig().type)]})}getConfig(){return Mn.maxValue}},Ev=class extends yv{value=0;_parseValue(e){if(this.value=Number.parseFloat(e[0].value),Number.isNaN(this.value))throw new Se({errorLevel:z.WARNING,effect:`failed to set value for input field argument`,cause:`value of argument 'minValue' must be of type number`,docs:[$l.linkToInputFieldArgument(this.getConfig().type)]})}getConfig(){return Mn.minValue}},Dv=class extends yv{value=!0;_parseValue(e){this.value=e[0]===void 0||e[0]?.value.toLowerCase()===`true`}getConfig(){return Mn.multiLine}},Ov=class extends yv{value=!1;_parseValue(e){this.value=fn(e[0].value)}getConfig(){return Mn.offValue}},kv=class extends yv{value=!0;_parseValue(e){this.value=fn(e[0].value)}getConfig(){return Mn.onValue}},Av=class extends yv{value=``;name=``;_parseValue(e){e.length===1?(this.value=fn(e[0].value),this.name=e[0].value):e.length===2&&(this.value=fn(e[0].value),this.name=e[1].value)}getConfig(){return Mn.option}},jv=class extends yv{value=``;_parseValue(e){this.value=e[0].value}getConfig(){return Mn.optionQuery}},Mv=class extends yv{value=``;_parseValue(e){this.value=e[0].value}getConfig(){return Mn.placeholder}},Nv=class extends yv{value=!0;_parseValue(e){this.value=e[0]===void 0||e[0]?.value.toLowerCase()===`true`}getConfig(){return Mn.showcase}},Pv=class extends yv{value=0;_parseValue(e){if(this.value=Number.parseFloat(e[0].value),Number.isNaN(this.value))throw new Se({errorLevel:z.WARNING,effect:`failed to set value for input field argument`,cause:`value of argument 'stepSize' must be of type number`,docs:[$l.linkToInputFieldArgument(this.getConfig().type)]});if(this.value<=0)throw new Se({errorLevel:z.WARNING,effect:`failed to set value for input field argument`,cause:`value of argument 'stepSize' must be a positive number`,docs:[$l.linkToInputFieldArgument(this.getConfig().type)]})}getConfig(){return Mn.stepSize}},Fv=class extends yv{value=``;_parseValue(e){this.value=e[0].value}getConfig(){return Mn.title}};function Iv(e,t,n){return n===jn.TRUE?`[[${e}|${t}]]`:n===jn.PARTIAL?`[[${t}]]`:`${t}`}var Lv=class extends yv{value=jn.TRUE;_parseValue(e){let t=e[0]?.value.toLowerCase();if(t===void 0){this.value=jn.TRUE;return}if(t===jn.TRUE||t===jn.PARTIAL||t===jn.FALSE){this.value=t;return}throw new Se({errorLevel:z.WARNING,effect:`failed to set value for input field argument`,cause:`value of argument 'useLinks' must be one of ${k([jn.TRUE,jn.PARTIAL,jn.FALSE],e=>`'${e}'`,`, `,`or`)}`,docs:[$l.linkToInputFieldArgument(this.getConfig().type)]})}getConfig(){return Mn.useLinks}},Rv={[kn.CLASS]:Sv,[kn.ADD_LABELS]:bv,[kn.MIN_VALUE]:Ev,[kn.MAX_VALUE]:Tv,[kn.STEP_SIZE]:Pv,[kn.OPTION]:Av,[kn.TITLE]:Fv,[kn.OPTION_QUERY]:jv,[kn.SHOWCASE]:Nv,[kn.OFF_VALUE]:Ov,[kn.ON_VALUE]:kv,[kn.DEFAULT_VALUE]:Cv,[kn.PLACEHOLDER]:Mv,[kn.USE_LINKS]:Lv,[kn.LIMIT]:wv,[kn.ALLOW_OTHER]:xv,[kn.MULTI_LINE]:Dv},zv=class{static createInputFieldArgument(e){if(e in Rv){let t=Rv[e];if(t)return new t}throw new ye({errorLevel:z.WARNING,effect:`can not crate input field argument`,cause:`unknown argument '${e}'`})}},Bv=class{unvalidatedDeclaration;errorCollection;filePath;mb;constructor(e,t,n){this.mb=e,this.unvalidatedDeclaration=t,this.filePath=n,this.errorCollection=new Tn(`input field declaration`)}validate(e){let t=this.validateInputFieldType(),n=this.validateBindTarget(e),r=this.validateArguments(t),i={declarationString:this.unvalidatedDeclaration.declarationString,inputFieldType:t,bindTarget:n,argumentContainer:r,errorCollection:this.errorCollection.merge(this.unvalidatedDeclaration.errorCollection)};return this.checkForDeprecation(i),i}validateInputFieldType(){let e=this.unvalidatedDeclaration.inputFieldType;for(let t of Object.entries(On))if(t[1]===e?.value)return t[1];return this.errorCollection.add(new Ae(z.ERROR,`Declaration Validator`,`Encountered invalid identifier. Expected an input field type but received '${e?.value}'.`,this.unvalidatedDeclaration.declarationString,e?.position)),On.INVALID}checkForDeprecation(e){}validateBindTarget(e){if(this.unvalidatedDeclaration.bindTarget!==void 0)try{return this.mb.bindTargetParser.validate(this.unvalidatedDeclaration.declarationString,this.unvalidatedDeclaration.bindTarget,this.filePath,e)}catch(e){this.errorCollection.add(e)}}validateArguments(e){let t=new _v;for(let n of this.unvalidatedDeclaration.arguments){let r=this.validateArgumentType(n.name);if(r===kn.INVALID)continue;let i=zv.createInputFieldArgument(r);if(!i.isAllowed(e)){this.errorCollection.add(new Ae(z.WARNING,`Declaration Validator`,`Failed to parse input field arguments. Argument "${n.name.value}" is only applicable to "${i.getAllowedFieldsAsString()}" input fields.`,this.unvalidatedDeclaration.declarationString,n.name.position));continue}try{i.parseValue(n.value)}catch(e){this.errorCollection.add(e);continue}t.add(i)}try{t.validate()}catch(e){this.errorCollection.add(e)}return t}validateArgumentType(e){for(let t of Object.entries(kn))if(t[1]===e.value)return t[1];return this.errorCollection.add(new Ae(z.WARNING,`Declaration Validator`,`Encountered invalid identifier. Expected an input field argument type but received '${e.value}'.`,this.unvalidatedDeclaration.declarationString,e.position)),kn.INVALID}},Vv=P.sequenceMap((e,t,n)=>({inputFieldType:e,arguments:t,bindTarget:n===void 0?void 0:n[1]}),je.node(Re).trim(R.optionalWhitespace()).describe(`input field type`),tt.trim(R.optionalWhitespace()).wrap(P.string(`(`).describe(`arguments paren "("`),P.string(`)`).describe(`arguments paren ")"`)).trim(R.optionalWhitespace()).optional([]),P.sequence(P.string(`:`).trim(R.optionalWhitespace()).describe(`bind target separator ":"`),Xe).trim(R.optionalWhitespace()).optional()),Hv=P.sequenceMap((e,t,n)=>({inputFieldType:e,arguments:t,bindTarget:n===void 0?void 0:n[1]}),je.node(Re).trim(R.optionalWhitespace()).optional().describe(`input field type`),tt.trim(R.optionalWhitespace()).wrap(P.string(`(`).describe(`arguments paren "("`),P.string(`)`).describe(`arguments paren ")"`)).trim(R.optionalWhitespace()).optional([]),P.sequence(P.string(`:`).trim(R.optionalWhitespace()).describe(`bind target separator ":"`),Xe).trim(R.optionalWhitespace()).optional()),Uv=P.or(P.sequenceMap((e,t,n)=>(n.templateName=t,n),P.string(`INPUT`),P.sequenceMap((e,t,n)=>t,P.string(`[`),Me.node(Re).trim(R.optionalWhitespace()).describe(`template name`),P.string(`]`).skip(R.optionalWhitespace())),Hv.wrap(P.string(`[`),P.string(`]`)),R.eof()),P.sequenceMap((e,t)=>t,P.string(`INPUT`),Vv.wrap(P.string(`[`),P.string(`]`)),R.eof())),Wv=P.sequenceMap((e,t)=>t,P.string(`INPUT`),Hv.wrap(P.string(`[`),P.string(`]`)),R.eof()),Gv=class{mb;templates;constructor(e){this.mb=e,this.templates=[]}fromString(e){let t=new Tn(`InputField`);try{let n=Oe(Uv,e),r=this.partialToFullDeclaration(n,e,t);return r=this.applyTemplate(r),r}catch(e){t.add(e)}return{declarationString:e,inputFieldType:{value:On.INVALID},bindTarget:void 0,arguments:[],errorCollection:t}}fromStringAndValidate(e,t,n){return this.validate(this.fromString(e),t,n)}fromSimpleDeclaration(e){return{declarationString:void 0,inputFieldType:ze(e.inputFieldType),bindTarget:this.mb.bindTargetParser.fromExistingDeclaration(e.bindTarget),arguments:(e.arguments??[]).map(e=>({name:ze(e.name),value:e.value.map(e=>ze(e))})),errorCollection:new Tn(`InputField`)}}fromSimpleDeclarationAndValidate(e,t,n){return this.validate(this.fromSimpleDeclaration(e),t,n)}partialToFullDeclaration(e,t,n){return{...structuredClone(e),declarationString:t,errorCollection:n}}validate(e,t,n){return new Bv(this.mb,e,t).validate(n)}merge(e,t){let n;return e.bindTarget===void 0?n=t.bindTarget:(n=e.bindTarget,t.bindTarget?.storagePath!==void 0&&(n.storagePath=t.bindTarget.storagePath),t.bindTarget?.storageProp!==void 0&&(n.storageProp=t.bindTarget.storageProp)),{declarationString:t.declarationString,inputFieldType:t.inputFieldType??e.inputFieldType,bindTarget:n,arguments:t.arguments.concat(e.arguments).reduce((e,t)=>(e.find(e=>e.name===t.name)===void 0&&e.push(t),e),[]),errorCollection:new Tn(`input field declaration`).merge(e.errorCollection).merge(t.errorCollection)}}parseTemplateString(e){let t=new Tn(`InputFieldParser`);try{let n=Oe(Wv,e);return this.partialToFullDeclaration(n,e,t)}catch(e){t.add(e)}return{declarationString:e,inputFieldType:{value:On.INVALID},bindTarget:void 0,arguments:[],errorCollection:t}}validateTemplate(e){return this.parseTemplateString(e.declaration).errorCollection}parseTemplates(e){this.templates=[];let t=new Tn(`input field template parser`);for(let n of e){let e=this.parseTemplateString(n.declaration);t.merge(e.errorCollection);let r={name:n.name,template:e};this.templates.push(T(r))}return t}getTemplate(e){return this.templates.find(t=>t.name===e)?.template}applyTemplate(e){if(e.templateName===void 0)return e;let t=this.getTemplate(e.templateName.value);return t===void 0?(e.errorCollection.add(new Ae(z.WARNING,`Input Field Parser`,`Invalid template name. Could not find a template with the name '${e.templateName.value}'.`,e.declarationString,e.templateName.position,[`https://moritzjung.dev/obsidian-meta-bind-plugin-docs/guides/templates/`])),e):this.merge(t,e)}},Kv=class{mb;constructor(e){this.mb=e}fromString(e){let t=new Tn(`JsViewFieldDeclaration`);try{let n=Oe(ct,e);return this.partialToFullDeclaration(n,e,t)}catch(e){t.add(e)}return{declarationString:e,errorCollection:t,bindTargetMappings:[],writeToBindTarget:void 0,hidden:!1,code:``}}fromStringAndValidate(e,t){return this.validate(this.fromString(e),t)}fromSimpleDeclaration(e){let t=new Tn(`JsViewFieldDeclaration`);return{declarationString:void 0,code:e.code,bindTargetMappings:e.bindTargetMappings.map(e=>({bindTarget:this.mb.bindTargetParser.fromExistingDeclaration(e.bindTarget),name:e.name})),writeToBindTarget:this.mb.bindTargetParser.fromExistingDeclaration(e.writeToBindTarget),hidden:e.hidden??!1,errorCollection:t}}fromSimpleDeclarationAndValidate(e,t){return this.validate(this.fromSimpleDeclaration(e),t)}partialToFullDeclaration(e,t,n){let r=e;return r.declarationString=t,r.errorCollection=n,r.bindTargetMappings=[...r.bindTargetMappings],r}validate(e,t){let n={};n.declarationString=e.declarationString,n.errorCollection=e.errorCollection;try{return n.bindTargetMappings=e.bindTargetMappings.map(n=>({bindTarget:this.mb.bindTargetParser.validate(e.declarationString,n.bindTarget,t),name:n.name})),e.writeToBindTarget!==void 0&&(n.writeToBindTarget=this.mb.bindTargetParser.validate(e.declarationString,e.writeToBindTarget,t)),n.code=e.code,n.hidden=e.hidden,n}catch(e){n.errorCollection.add(e)}return{declarationString:e.declarationString,errorCollection:n.errorCollection,bindTargetMappings:[],writeToBindTarget:void 0,hidden:!1,code:``}}},qv=class extends gv{getAll(e){return super.getAll(e)}get(e){return this.getAll(e).at(0)}},Jv=class extends vv{},Yv=class extends Jv{value=[];_parseValue(e){this.value=e[0].value.split(` `)}getConfig(){return Fn.class}},Xv=class extends Jv{value=!0;_parseValue(e){this.value=e[0]===void 0||e[0]?.value.toLowerCase()===`true`}getConfig(){return Fn.hidden}},Zv=class extends Jv{value=!0;_parseValue(e){this.value=e[0]===void 0||e[0]?.value.toLowerCase()===`true`}getConfig(){return Fn.renderMarkdown}},Qv={[Pn.RENDER_MARKDOWN]:Zv,[Pn.HIDDEN]:Xv,[Pn.CLASS]:Yv},$v=class{static createViewFieldArgument(e){if(e in Qv){let t=Qv[e];if(t)return new t}throw new ye({errorLevel:z.WARNING,effect:`can not crate view field argument`,cause:`unknown argument '${e}'`})}},ey=class{unvalidatedDeclaration;errorCollection;filePath;mb;constructor(e,t,n){this.unvalidatedDeclaration=e,this.mb=n,this.filePath=t,this.errorCollection=new Tn(`view field declaration`)}validate(e){let t=this.validateInputFieldType(),n=this.validateBindTarget(e),r=this.validateArguments(t),i=this.validateTemplateDeclaration(e),a={declarationString:this.unvalidatedDeclaration.declarationString,viewFieldType:t,writeToBindTarget:n,argumentContainer:r,templateDeclaration:i,errorCollection:this.errorCollection.merge(this.unvalidatedDeclaration.errorCollection)};return this.checkForDeprecation(a),a}validateInputFieldType(){let e=this.unvalidatedDeclaration.viewFieldType;if(e===void 0)return Nn.MATH;for(let t of Object.entries(Nn))if(t[1]===e?.value)return t[1];return this.errorCollection.add(new Ae(z.ERROR,`Declaration Validator`,`Encountered invalid identifier. Expected a view field type but received '${e.value}'.`,this.unvalidatedDeclaration.declarationString,e.position)),Nn.INVALID}checkForDeprecation(e){}validateBindTarget(e){if(this.unvalidatedDeclaration.writeToBindTarget!==void 0)return this.mb.bindTargetParser.validate(this.unvalidatedDeclaration.declarationString,this.unvalidatedDeclaration.writeToBindTarget,this.filePath,e)}validateArguments(e){let t=new qv;for(let n of this.unvalidatedDeclaration.arguments){let r=this.validateArgumentType(n.name);if(r===Pn.INVALID)continue;let i=$v.createViewFieldArgument(r);if(!i.isAllowed(e)){this.errorCollection.add(new Ae(z.WARNING,`Declaration Validator`,`Failed to parse view field arguments. Argument "${n.name.value}" is only applicable to "${i.getAllowedFieldsAsString()}" view fields.`,this.unvalidatedDeclaration.declarationString,n.name.position));continue}try{i.parseValue(n.value)}catch(e){this.errorCollection.add(e);continue}t.add(i)}try{t.validate()}catch(e){this.errorCollection.add(e)}return t}validateArgumentType(e){for(let t of Object.entries(Pn))if(t[1]===e.value)return t[1];return this.errorCollection.add(new Ae(z.WARNING,`Declaration Validator`,`Encountered invalid identifier. Expected a view field argument type but received '${e.value}'.`,this.unvalidatedDeclaration.declarationString,e.position)),Pn.INVALID}validateTemplateDeclaration(e){try{return this.unvalidatedDeclaration.templateDeclaration?.map(t=>typeof t==`string`?t:this.mb.bindTargetParser.validate(this.unvalidatedDeclaration.declarationString,t,this.filePath,e))??[]}catch(e){return this.errorCollection.add(e),[]}}},ty=class{mb;constructor(e){this.mb=e}fromString(e){let t=new Tn(`ViewFieldDeclaration`);try{let n=Oe(ot,e);return this.partialToFullDeclaration(n,e,t)}catch(e){t.add(e)}return{declarationString:e,errorCollection:t,viewFieldType:{value:Nn.INVALID},writeToBindTarget:void 0,arguments:[],templateDeclaration:[]}}fromStringAndValidate(e,t,n){return this.validate(this.fromString(e),t,n)}fromSimpleDeclaration(e){let t=new Tn(`ViewFieldDeclaration`);return{declarationString:void 0,templateDeclaration:(e.templateDeclaration??[]).map(e=>typeof e==`string`?e:this.mb.bindTargetParser.fromExistingDeclaration(e)),viewFieldType:ze(e.viewFieldType),arguments:(e.arguments??[]).map(e=>({name:ze(e.name),value:e.value.map(e=>ze(e))})),writeToBindTarget:this.mb.bindTargetParser.fromExistingDeclaration(e.writeToBindTarget),errorCollection:t}}fromSimpleDeclarationAndValidate(e,t,n){return this.validate(this.fromSimpleDeclaration(e),t,n)}partialToFullDeclaration(e,t,n){return{...structuredClone(e),declarationString:t,errorCollection:n}}validate(e,t,n){return new ey(e,t,this.mb).validate(n)}},ny=m[1];function ry(e){ny=h(e)}function iy(e){return p[e]}function ay(e,t){let n=new Date(t,e+1,0).getDate(),r=Array(42).fill(0),i=oy(new Date(t,e,1));for(let e=0;e({index:S(e.index-ny.index,7),name:e.name,shortName:e.shortName})).sort((e,t)=>e.index-t.index).map(e=>e.shortName)}function cy(){return cy=Object.assign?Object.assign.bind():function(e){for(var t=1;tthis.has(e)).values()}get(e){return uy(this.wrappedObject,e)}set(e,t){return dy(this.wrappedObject,e,t),this}has(e){return fy(this.wrappedObject,e)&&e in this.wrappedObject}entries(){return xy(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){fy(this.wrappedObject,e)&&delete this.wrappedObject[e]}clear(){for(var e of this.keys())this.delete(e)}get size(){return Object.keys(this.wrappedObject).length}},by=class{constructor(e,t,n){this.a=e,this.b=t,this.bKeys=n,this[Symbol.iterator]=this.entries}get(e){return this.bKeys.has(e)?this.b.get(e):this.a.get(e)}set(e,t){return this.bKeys.has(e)?this.b.set(e,t):this.a.set(e,t),this}has(e){return this.b.has(e)||this.a.has(e)}keys(){return new Set([...this.a.keys(),...this.b.keys()])[Symbol.iterator]()}entries(){return xy(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){return this.bKeys.has(e)?this.b.delete(e):this.a.delete(e)}clear(){this.a.clear(),this.b.clear()}get size(){return[...this.keys()].length}};function xy(e,t){return{next:()=>{var n=e.next();return n.done?n:{value:t(n.value),done:!1}}}}function Sy(){return new Map}function Cy(e){if(!e)return Sy();if(Ky(e))return e;if(Gy(e))return new yy(e);throw Error(`createMap can create maps from objects or Maps`)}function wy(e){if(e instanceof yy)return e.wrappedObject;var t={};for(var n of e.keys())dy(t,n,e.get(n));return t}function Ty(e){return typeof e==`number`}function Ey(e){return!e||typeof e!=`object`||typeof e.constructor!=`function`?!1:e.isBigNumber===!0&&typeof e.constructor.prototype==`object`&&e.constructor.prototype.isBigNumber===!0||typeof e.constructor.isDecimal==`function`&&e.constructor.isDecimal(e)===!0}function Dy(e){return typeof e==`bigint`}function Oy(e){return e&&typeof e==`object`&&Object.getPrototypeOf(e).isComplex===!0||!1}function ky(e){return e&&typeof e==`object`&&Object.getPrototypeOf(e).isFraction===!0||!1}function Ay(e){return e&&e.constructor.prototype.isUnit===!0||!1}function jy(e){return typeof e==`string`}var My=Array.isArray;function Ny(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function Py(e){return Array.isArray(e)||Ny(e)}function Fy(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function Iy(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function Ly(e){return e&&e.constructor.prototype.isRange===!0||!1}function Ry(e){return e&&e.constructor.prototype.isIndex===!0||!1}function zy(e){return typeof e==`boolean`}function By(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function Vy(e){return e&&e.constructor.prototype.isHelp===!0||!1}function Hy(e){return typeof e==`function`}function Uy(e){return e instanceof Date}function Wy(e){return e instanceof RegExp}function Gy(e){return!!(e&&typeof e==`object`&&e.constructor===Object&&!Oy(e)&&!ky(e))}function Ky(e){return e?e instanceof Map||e instanceof yy||typeof e.set==`function`&&typeof e.get==`function`&&typeof e.keys==`function`&&typeof e.has==`function`:!1}function qy(e){return Ky(e)&&Ky(e.a)&&Ky(e.b)}function Jy(e){return Ky(e)&&Gy(e.wrappedObject)}function Yy(e){return e===null}function Xy(e){return e===void 0}function Zy(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function Qy(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function $y(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function eb(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function tb(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function nb(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function rb(e){return nb(e)||lb(e)&&e.args.length===1&&nb(e.args[0])&&`-+~`.includes(e.op)}function ib(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function ab(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function ob(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function sb(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function cb(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function lb(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function ub(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function db(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function fb(e){return e&&e.isRelationalNode===!0&&e.constructor.prototype.isNode===!0||!1}function pb(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function mb(e){return e&&e.constructor.prototype.isChain===!0||!1}function hb(e){var t=typeof e;return t===`object`?e===null?`null`:Ey(e)?`BigNumber`:e.constructor&&e.constructor.name?e.constructor.name:`Object`:t}function gb(e){var t=typeof e;if(t===`number`||t===`bigint`||t===`string`||t===`boolean`||e==null)return e;if(typeof e.clone==`function`)return e.clone();if(Array.isArray(e))return e.map(function(e){return gb(e)});if(e instanceof Date)return new Date(e.valueOf());if(Ey(e))return e;if(Gy(e))return _b(e,gb);if(t===`function`)return e;throw TypeError(`Cannot clone: unknown type of value (value: ${e})`)}function _b(e,t){var n={};for(var r in e)J(e,r)&&(n[r]=t(e[r]));return n}function vb(e,t){for(var n in t)J(t,n)&&(e[n]=t[n]);return e}function yb(e,t){if(Array.isArray(t))throw TypeError(`Arrays are not supported by deepExtend`);for(var n in t)if(J(t,n)&&!(n in Object.prototype)&&!(n in Function.prototype))if(t[n]&&t[n].constructor===Object)e[n]===void 0&&(e[n]={}),e[n]&&e[n].constructor===Object?yb(e[n],t[n]):e[n]=t[n];else if(Array.isArray(t[n]))throw TypeError(`Arrays are not supported by deepExtend`);else e[n]=t[n];return e}function bb(e,t){var n,r,i;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(r=0,i=e.length;r{Object.defineProperty(n,t,{get:()=>e[t],enumerable:!0,configurable:!0})}),n}function kb(e,t,n){e[t]!==void 0&&!n.includes(e[t])&&console.warn(`Warning: Unknown value "`+e[t]+`" for configuration option "`+t+`". Available options: `+n.map(e=>JSON.stringify(e)).join(`, `)+`.`)}var Ab=o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.typed=r())})(e,(function(){"use strict";function e(){return!0}function t(){return!1}function n(){}let r=`Argument is not a typed-function.`;function i(){function a(e){return typeof e==`object`&&!!e&&e.constructor===Object}let o=[{name:`number`,test:function(e){return typeof e==`number`}},{name:`string`,test:function(e){return typeof e==`string`}},{name:`boolean`,test:function(e){return typeof e==`boolean`}},{name:`Function`,test:function(e){return typeof e==`function`}},{name:`Array`,test:Array.isArray},{name:`Date`,test:function(e){return e instanceof Date}},{name:`RegExp`,test:function(e){return e instanceof RegExp}},{name:`Object`,test:a},{name:`null`,test:function(e){return e===null}},{name:`undefined`,test:function(e){return e===void 0}}],s={name:`any`,test:e,isAny:!0},c,l,u=0,d={createCount:0};function f(e){let t=c.get(e);if(t)return t;let n=`Unknown type "`+e+`"`,r=e.toLowerCase(),i;for(i of l)if(i.toLowerCase()===r){n+=`. Did you mean "`+i+`" ?`;break}throw TypeError(n)}function p(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`any`,n=t?f(t).index:l.length,r=[];for(let t=0;t{let n=c.get(t);return!n.isAny&&n.test(e)});return t.length?t:[`any`]}function _(e){return e&&typeof e==`function`&&`_typedFunctionData`in e}function v(e,t,n){if(!_(e))throw TypeError(r);let i=n&&n.exact,a=T(Array.isArray(t)?t.join(`,`):t),o=x(a);if(!i||o in e.signatures){let t=e._typedFunctionData.signatureMap.get(o);if(t)return t}let s=a.length,c;if(i){c=[];let t;for(t in e.signatures)c.push(e._typedFunctionData.signatureMap.get(t))}else c=e._typedFunctionData.signatures;for(let e=0;e!e.has(t.name)))continue}n.push(r)}}if(c=n,c.length===0)break}let l;for(l of c)if(l.params.length<=s)return l;throw TypeError(`Signature not found (signature: `+(e.name||`unnamed`)+`(`+x(a,`, `)+`))`)}function y(e,t,n){return v(e,t,n).implementation}function b(e,t){let n=f(t);if(n.test(e))return e;let r=n.conversionsTo;if(r.length===0)throw Error(`There are no conversions to `+t+` defined.`);for(let t=0;t1&&arguments[1]!==void 0?arguments[1]:`,`;return e.map(e=>e.name).join(t)}function S(e){let t=e.indexOf(`...`)===0,n=(t?e.length>3?e.slice(3):`any`:e).split(`|`).map(e=>f(e.trim())),r=!1,i=t?`...`:``;return{types:n.map(function(e){return r=e.isAny||r,i+=e.name+`|`,{name:e.name,typeIndex:e.index,test:e.test,isAny:e.isAny,conversion:null,conversionIndex:-1}}),name:i.slice(0,-1),hasAny:r,hasConversion:!1,restParam:t}}function C(e){let t=P(e.types.map(e=>e.name)),n=e.hasAny,r=e.name,i=t.map(function(e){let t=f(e.from);return n=t.isAny||n,r+=`|`+e.from,{name:e.from,typeIndex:t.index,test:t.test,isAny:t.isAny,conversion:e,conversionIndex:e.index}});return{types:e.types.concat(i),name:r,hasAny:n,hasConversion:i.length>0,restParam:e.restParam}}function w(e){return e.typeSet||(e.typeSet=new Set,e.types.forEach(t=>e.typeSet.add(t.name))),e.typeSet}function T(e){let t=[];if(typeof e!=`string`)throw TypeError(`Signatures must be strings`);let n=e.trim();if(n===``)return t;let r=n.split(`,`);for(let e=0;e=n+1}}else if(e.length===0)return function(e){return e.length===0};else if(e.length===1)return n=D(e[0]),function(e){return n(e[0])&&e.length===1};else if(e.length===2)return n=D(e[0]),r=D(e[1]),function(e){return n(e[0])&&r(e[1])&&e.length===2};else return t=e.map(D),function(e){for(let n=0;n{let r=A(e.params,t),i;for(i of r)n.add(i)}),n.has(`any`)?[`any`]:Array.from(n)}function N(e,t,n){let r,i,a=e||`unnamed`,o=n,s;for(s=0;s{let r=D(k(n.params,s));(s0){let e=g(t[s]);return r=TypeError(`Unexpected type of argument in function `+a+` (expected: `+i.join(` or `)+`, actual: `+e.join(` | `)+`, index: `+s+`)`),r.data={category:`wrongType`,fn:a,index:s,actual:e,expected:i},r}}else o=e}let c=o.map(function(e){return E(e.params)?1/0:e.params.length});if(t.lengthl)return r=TypeError(`Too many arguments in function `+a+` (expected: `+l+`, actual: `+t.length+`)`),r.data={category:`tooManyArgs`,fn:a,index:t.length,expectedLength:l},r;let u=[];for(let e=0;e0)return .001;let r=te(e),i=te(t);if(e.hasConversion){if(!t.hasConversion)return(1+r)*1e-6}else if(t.hasConversion)return-(1+i)*1e-6;let a=r-i;return a<0?-1e-7:a>0?1e-7:0}function re(e,t){let n=e.params,r=t.params,i=de(n),a=de(r),o=E(n),s=E(r);if(o&&i.hasAny){if(!s||!a.hasAny)return 1e7}else if(s&&a.hasAny)return-1e7;let c=0,l=0,u;for(u of n)u.hasAny&&++c,u.hasConversion&&++l;let d=0,f=0;for(u of r)u.hasAny&&++d,u.hasConversion&&++f;if(c!==d)return(c-d)*1e6;if(o&&i.hasConversion){if(!s||!a.hasConversion)return 1e5}else if(s&&a.hasConversion)return-1e5;if(l!==f)return(l-f)*1e4;if(o){if(!s)return 1e3}else if(s)return-1e3;let p=(n.length-r.length)*(o?-100:100);if(p!==0)return p;let m=[],h=0;for(let e=0;ee.hasConversion)){let i=E(e),a=e.map(ie);r=a.map(e=>e.name).join(`;`),n=function(){let e=[],n=i?arguments.length-1:arguments.length;for(let t=0;t`+e.conversion.to+`,`,a.push(f(e.conversion.from).test),o.push(e.conversion.convert))}),s=s?s.slice(0,-1):`pass`;let c=e=>e;switch(o.length){case 0:break;case 1:t=a[0],r=o[0],c=function(e){return t(e)?r(e):e};break;case 2:t=a[0],n=a[1],r=o[0],i=o[1],c=function(e){return t(e)?r(e):n(e)?i(e):e};break;default:c=function(e){for(let t=0;te.name).join(`|`),hasAny:e.some(e=>e.isAny),hasConversion:!1,restParam:!0}),a.push(i)}else a=i.types.map(function(e){return{types:[e],name:e.name,hasAny:e.isAny,hasConversion:e.conversion,restParam:!1}});return me(a,function(i){return t(e,n+1,r.concat([i]))})}else return[r]}return t(e,0,[])}function ae(e,t){let n=Math.max(e.length,t.length);for(let r=0;r=r:o?r>=i:r===i}function oe(e){return e.map(e=>ve(e)?ge(e.referToSelf.callback):_e(e)?z(e.referTo.references,e.referTo.callback):e)}function L(e,t,n){let r=[],i;for(i of e){let e=n[i];if(typeof e!=`number`)throw TypeError(`No definition for referenced signature "`+i+`"`);if(e=t[e],typeof e!=`function`)return!1;r.push(e)}return r}function R(e,t,n){let r=oe(e),i=Array(r.length).fill(!1),a=!0;for(;a;){a=!1;let e=!0;for(let o=0;o{let r=e[n];if(t.test(r.toString()))throw SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function ce(e,r){if(d.createCount++,Object.keys(r).length===0)throw SyntaxError(`No signatures provided`);d.warnAgainstDeprecatedThis&&se(r);let i=[],a=[],o={},s=[],c;for(c in r){if(!Object.prototype.hasOwnProperty.call(r,c))continue;let e=T(c);if(!e)continue;i.forEach(function(t){if(ae(t,e))throw TypeError(`Conflicting signatures "`+x(t)+`" and "`+x(e)+`".`)}),i.push(e);let t=a.length;a.push(r[c]);let n=e.map(C),l;for(l of I(n)){let e=x(l);s.push({params:l,name:e,fn:t}),l.every(e=>!e.hasConversion)&&(o[e]=t)}}s.sort(re);let l=R(a,o,Se),u;for(u in o)Object.prototype.hasOwnProperty.call(o,u)&&(o[u]=l[o[u]]);let f=[],p=new Map;for(u of s)p.has(u.name)||(u.fn=l[u.fn],f.push(u),p.set(u.name,u));let m=f[0]&&f[0].params.length<=2&&!E(f[0].params),h=f[1]&&f[1].params.length<=2&&!E(f[1].params),g=f[2]&&f[2].params.length<=2&&!E(f[2].params),_=f[3]&&f[3].params.length<=2&&!E(f[3].params),v=f[4]&&f[4].params.length<=2&&!E(f[4].params),y=f[5]&&f[5].params.length<=2&&!E(f[5].params),b=m&&h&&g&&_&&v&&y;for(let e=0;ee.test),be=f.map(e=>e.implementation),xe=function(){for(let e=_e;ex(T(e))),t=de(arguments);if(typeof t!=`function`)throw TypeError(`Callback function expected as last argument`);return z(e,t)}function z(e,t){return{referTo:{references:e,callback:t}}}function ge(e){if(typeof e!=`function`)throw TypeError(`Callback function expected as first argument`);return{referToSelf:{callback:e}}}function _e(e){return e&&typeof e.referTo==`object`&&Array.isArray(e.referTo.references)&&typeof e.referTo.callback==`function`}function ve(e){return e&&typeof e.referToSelf==`object`&&typeof e.referToSelf.callback==`function`}function ye(e,t){if(!e)return t;if(t&&t!==e){let n=Error(`Function names do not match (expected: `+e+`, actual: `+t+`)`);throw n.data={actual:t,expected:e},n}return e}function be(e){let t;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(_(e[n])||typeof e[n].signature==`string`)&&(t=ye(t,e[n].name));return t}function xe(e,t){let n;for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(n in e&&t[n]!==e[n]){let r=Error(`Signature "`+n+`" is defined twice`);throw r.data={signature:n,sourceFunction:t[n],destFunction:e[n]},r}e[n]=t[n]}}let Se=d;d=function(e){let t=typeof e==`string`,n=+!!t,r=t?e:``,i={};for(let e=n;e1&&arguments[1]!==void 0?arguments[1]:{override:!1};Ce(e);let n=f(e.to),r=n.conversionsTo.find(t=>t.from===e.from);if(r)if(t&&t.override)d.removeConversion({from:r.from,to:e.to,convert:r.convert});else throw Error(`There is already a conversion from "`+e.from+`" to "`+n.name+`"`);n.conversionsTo.push({from:e.from,to:n.name,convert:e.convert,index:u++})},d.addConversions=function(e,t){e.forEach(e=>d.addConversion(e,t))},d.removeConversion=function(e){Ce(e);let t=f(e.to),n=pe(t.conversionsTo,t=>t.from===e.from);if(!n)throw Error(`Attempt to remove nonexistent conversion from `+e.from+` to `+e.to);if(n.convert!==e.convert)throw Error(`Conversion to remove does not match existing conversion`);let r=t.conversionsTo.indexOf(n);t.conversionsTo.splice(r,1)},d.resolve=function(e,t){if(!_(e))throw TypeError(r);let n=e._typedFunctionData.signatures;for(let e=0;e!Nb(e)).every(e=>n[e]!==void 0)){var r=t.filter(e=>n[e]===void 0);throw Error(`Cannot create function "${e}", some dependencies are missing: ${r.map(e=>`"${e}"`).join(`, `)}.`)}}function Nb(e){return e&&e[0]===`?`}function Pb(e){return e&&e[0]===`?`?e.slice(1):e}function X(e){return typeof e==`boolean`?!0:Number.isFinite(e)?e===Math.round(e):!1}function Fb(e,t){if(t.number===`bigint`)try{BigInt(e)}catch{return t.numberFallback}return t.number}var Ib=Math.sign||function(e){return e>0?1:e<0?-1:0},Lb=Math.log2||function(e){return Math.log(e)/Math.LN2},Rb=Math.log10||function(e){return Math.log(e)/Math.LN10},zb=Math.log1p||function(e){return Math.log(e+1)},Bb=Math.cbrt||function(e){if(e===0)return e;var t=e<0,n;return t&&(e=-e),Number.isFinite(e)?(n=Math.exp(Math.log(e)/3),n=(e/(n*n)+2*n)/3):n=e,t?-n:n},Vb=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function Hb(e,t,n){var r={2:`0b`,8:`0o`,16:`0x`}[t],i=``;if(n){if(n<1)throw Error(`size must be in greater than 0`);if(!X(n))throw Error(`size must be an integer`);if(e>2**(n-1)-1||e<-(2**(n-1)))throw Error(`Value must be in range [-2^${n-1}, 2^${n-1}-1]`);if(!X(e))throw Error(`Value must be an integer`);e<0&&(e+=2**n),i=`i${n}`}var a=``;return e<0&&(e=-e,a=`-`),`${a}${r}${e.toString(t)}${i}`}function Ub(e,t){if(typeof t==`function`)return t(e);if(e===1/0)return`Infinity`;if(e===-1/0)return`-Infinity`;if(isNaN(e))return`NaN`;var{notation:n,precision:r,wordSize:i}=Wb(t);switch(n){case`fixed`:return qb(e,r);case`exponential`:return Jb(e,r);case`engineering`:return Kb(e,r);case`bin`:return Hb(e,2,i);case`oct`:return Hb(e,8,i);case`hex`:return Hb(e,16,i);case`auto`:return Yb(e,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return e===`.`?t:e+t});default:throw Error(`Unknown notation "`+n+`". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.`)}}function Wb(e){var t=`auto`,n,r;if(e!==void 0)if(Ty(e))n=e;else if(Ey(e))n=e.toNumber();else if(Gy(e))e.precision!==void 0&&(n=sx(e.precision,()=>{throw Error(`Option "precision" must be a number or BigNumber`)})),e.wordSize!==void 0&&(r=sx(e.wordSize,()=>{throw Error(`Option "wordSize" must be a number or BigNumber`)})),e.notation&&(t=e.notation);else throw Error(`Unsupported type of options, number, BigNumber, or object expected`);return{notation:t,precision:n,wordSize:r}}function Gb(e){var t=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw SyntaxError(`Invalid number `+e);var n=t[1],r=t[2],i=parseFloat(t[4]||`0`),a=r.indexOf(`.`);i+=a===-1?r.length-1:a-1;var o=r.replace(`.`,``).replace(/^0*/,function(e){return i-=e.length,``}).replace(/0*$/,``).split(``).map(function(e){return parseInt(e)});return o.length===0&&(o.push(0),i++),{sign:n,coefficients:o,exponent:i}}function Kb(e,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=Xb(Gb(e),t),r=n.exponent,i=n.coefficients,a=r%3==0?r:r<0?r-3-r%3:r-r%3;if(Ty(t))for(;t>i.length||r-a+1>i.length;)i.push(0);else for(var o=Math.abs(r-a)-(i.length-1),s=0;s0;)l++,c--;var u=i.slice(l).join(``),d=Ty(t)&&u.length||u.match(/[1-9]/)?`.`+u:``,f=i.slice(0,l).join(``)+d+`e`+(r>=0?`+`:``)+a.toString();return n.sign+f}function qb(e,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=Gb(e),r=typeof t==`number`?Xb(n,n.exponent+1+t):n,i=r.coefficients,a=r.exponent+1,o=a+(t||0);return i.length0?`.`+i.join(``):``)+`e`+(a>=0?`+`:``)+a}function Yb(e,t,n){if(isNaN(e)||!Number.isFinite(e))return String(e);var r=cx(n?.lowerExp,-3),i=cx(n?.upperExp,5),a=Gb(e),o=t?Xb(a,t):a;if(o.exponent=i)return Jb(e,t);var s=o.coefficients,c=o.exponent;s.length0?c:0;return lt&&r.splice(t,r.length-t)[0]>=5){var i=t-1;for(r[i]++;r[i]===10;)r.pop(),i===0&&(r.unshift(0),n.exponent++,i++),i--,r[i]++}return n}function Zb(e){for(var t=[],n=0;n2&&arguments[2]!==void 0?arguments[2]:1e-8,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(n<=0)throw Error(`Relative tolerance must be greater than 0`);if(r<0)throw Error(`Absolute tolerance must be at least 0`);return isNaN(e)||isNaN(t)?!1:!Number.isFinite(e)||!Number.isFinite(t)?e===t:e===t?!0:Math.abs(e-t)<=Math.max(n*Math.max(Math.abs(e),Math.abs(t)),r)}var ex=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},tx=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},nx=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},rx=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},ix=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},ax=Math.tanh||function(e){var t=Math.exp(2*e);return(t-1)/(t+1)};function ox(e,t){return(e>0?!0:e<0?!1:1/e==1/0)^(t>0?!0:t<0?!1:1/t==1/0)?-e:e}function sx(e,t){if(Ty(e))return e;if(Ey(e))return e.toNumber();t()}function cx(e,t){return Ty(e)?e:Ey(e)?e.toNumber():t}var lx=l(Ab(),1),ux=function(){return ux=lx.default.create,lx.default},dx=Y(`typed`,[`?BigNumber`,`?Complex`,`?DenseMatrix`,`?Fraction`],function(e){var{BigNumber:t,Complex:n,DenseMatrix:r,Fraction:i}=e,a=ux();return a.clear(),a.addTypes([{name:`number`,test:Ty},{name:`Complex`,test:Oy},{name:`BigNumber`,test:Ey},{name:`bigint`,test:Dy},{name:`Fraction`,test:ky},{name:`Unit`,test:Ay},{name:`identifier`,test:e=>jy&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC7\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC7\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])*$/.test(e)},{name:`string`,test:jy},{name:`Chain`,test:mb},{name:`Array`,test:My},{name:`Matrix`,test:Ny},{name:`DenseMatrix`,test:Fy},{name:`SparseMatrix`,test:Iy},{name:`Range`,test:Ly},{name:`Index`,test:Ry},{name:`boolean`,test:zy},{name:`ResultSet`,test:By},{name:`Help`,test:Vy},{name:`function`,test:Hy},{name:`Date`,test:Uy},{name:`RegExp`,test:Wy},{name:`null`,test:Yy},{name:`undefined`,test:Xy},{name:`AccessorNode`,test:Zy},{name:`ArrayNode`,test:Qy},{name:`AssignmentNode`,test:$y},{name:`BlockNode`,test:eb},{name:`ConditionalNode`,test:tb},{name:`ConstantNode`,test:nb},{name:`FunctionNode`,test:ab},{name:`FunctionAssignmentNode`,test:ib},{name:`IndexNode`,test:ob},{name:`Node`,test:sb},{name:`ObjectNode`,test:cb},{name:`OperatorNode`,test:lb},{name:`ParenthesisNode`,test:ub},{name:`RangeNode`,test:db},{name:`RelationalNode`,test:fb},{name:`SymbolNode`,test:pb},{name:`Map`,test:Ky},{name:`Object`,test:Gy}]),a.addConversions([{from:`number`,to:`BigNumber`,convert:function(e){if(t||fx(e),Qb(e)>15)throw TypeError(`Cannot implicitly convert a number with >15 significant digits to BigNumber (value: `+e+`). Use function bignumber(x) to convert to BigNumber.`);return new t(e)}},{from:`number`,to:`Complex`,convert:function(e){return n||px(e),new n(e,0)}},{from:`BigNumber`,to:`Complex`,convert:function(e){return n||px(e),new n(e.toNumber(),0)}},{from:`bigint`,to:`number`,convert:function(e){if(e>2**53-1)throw TypeError(`Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: `+e+`)`);return Number(e)}},{from:`bigint`,to:`BigNumber`,convert:function(e){return t||fx(e),new t(e.toString())}},{from:`bigint`,to:`Fraction`,convert:function(e){return i||hx(e),new i(e)}},{from:`Fraction`,to:`BigNumber`,convert:function(e){throw TypeError(`Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.`)}},{from:`Fraction`,to:`Complex`,convert:function(e){return n||px(e),new n(e.valueOf(),0)}},{from:`number`,to:`Fraction`,convert:function(e){i||hx(e);var t=new i(e);if(t.valueOf()!==e)throw TypeError(`Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: `+e+`). Use function fraction(x) to convert to Fraction.`);return t}},{from:`string`,to:`number`,convert:function(e){var t=Number(e);if(isNaN(t))throw Error(`Cannot convert "`+e+`" to a number`);return t}},{from:`string`,to:`BigNumber`,convert:function(e){t||fx(e);try{return new t(e)}catch{throw Error(`Cannot convert "`+e+`" to BigNumber`)}}},{from:`string`,to:`bigint`,convert:function(e){try{return BigInt(e)}catch{throw Error(`Cannot convert "`+e+`" to BigInt`)}}},{from:`string`,to:`Fraction`,convert:function(e){i||hx(e);try{return new i(e)}catch{throw Error(`Cannot convert "`+e+`" to Fraction`)}}},{from:`string`,to:`Complex`,convert:function(e){n||px(e);try{return new n(e)}catch{throw Error(`Cannot convert "`+e+`" to Complex`)}}},{from:`boolean`,to:`number`,convert:function(e){return+e}},{from:`boolean`,to:`BigNumber`,convert:function(e){return t||fx(e),new t(+e)}},{from:`boolean`,to:`bigint`,convert:function(e){return BigInt(+e)}},{from:`boolean`,to:`Fraction`,convert:function(e){return i||hx(e),new i(+e)}},{from:`boolean`,to:`string`,convert:function(e){return String(e)}},{from:`Array`,to:`Matrix`,convert:function(e){return r||mx(),new r(e)}},{from:`Matrix`,to:`Array`,convert:function(e){return e.valueOf()}}]),a.onMismatch=(e,t,n)=>{var r=a.createError(e,t,n);if([`wrongType`,`mismatch`].includes(r.data.category)&&t.length===1&&Py(t[0])&&n.some(e=>!e.params.includes(`,`))){var i=TypeError(`Function '${e}' doesn't apply to matrices. To call it elementwise on a matrix 'M', try 'map(M, ${e})'.`);throw i.data=r.data,i}throw r},a.onMismatch=(e,t,n)=>{var r=a.createError(e,t,n);if([`wrongType`,`mismatch`].includes(r.data.category)&&t.length===1&&Py(t[0])&&n.some(e=>!e.params.includes(`,`))){var i=TypeError(`Function '${e}' doesn't apply to matrices. To call it elementwise on a matrix 'M', try 'map(M, ${e})'.`);throw i.data=r.data,i}throw r},a});function fx(e){throw Error(`Cannot convert value ${e} into a BigNumber: no class 'BigNumber' provided`)}function px(e){throw Error(`Cannot convert value ${e} into a Complex number: no class 'Complex' provided`)}function mx(){throw Error(`Cannot convert array into a Matrix: no class 'DenseMatrix' provided`)}function hx(e){throw Error(`Cannot convert value ${e} into a Fraction, no class 'Fraction' provided.`)}var gx=Y(`ResultSet`,[],()=>{function e(t){if(!(this instanceof e))throw SyntaxError(`Constructor must be called with the new operator`);this.entries=t||[]}return e.prototype.type=`ResultSet`,e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return`[`+this.entries.map(String).join(`, `)+`]`},e.prototype.toJSON=function(){return{mathjs:`ResultSet`,entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e},{isClass:!0}),_x=9e15,vx=1e9,yx=`0123456789abcdef`,bx=`2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058`,xx=`3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789`,Sx={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-_x,maxE:_x,crypto:!1},Cx,wx,Tx=!0,Ex=`[DecimalError] `,Dx=Ex+`Invalid argument: `,Ox=Ex+`Precision limit exceeded`,kx=Ex+`crypto unavailable`,Ax=`[object Decimal]`,jx=Math.floor,Mx=Math.pow,Nx=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Px=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Fx=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ix=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Lx=1e7,Rx=7,zx=9007199254740991,Bx=bx.length-1,Vx=xx.length-1,Z={toStringTag:Ax};Z.absoluteValue=Z.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),Jx(e)},Z.ceil=function(){return Jx(new this.constructor(this),this.e+1,2)},Z.clampedTo=Z.clamp=function(e,t){var n,r=this,i=r.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(Dx+t);return n=r.cmp(e),n<0?e:r.cmp(t)>0?t:new i(r)},Z.comparedTo=Z.cmp=function(e){var t,n,r,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,c=a.s,l=e.s;if(!o||!s)return!c||!l?NaN:c===l?o===s?0:!o^c<0?1:-1:c;if(!o[0]||!s[0])return o[0]?c:s[0]?-l:0;if(c!==l)return c;if(a.e!==e.e)return a.e>e.e^c<0?1:-1;for(r=o.length,i=s.length,t=0,n=rs[t]^c<0?1:-1;return r===i?0:r>i^c<0?1:-1},Z.cosine=Z.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+Rx,r.rounding=1,n=Kx(r,fS(r,n)),r.precision=e,r.rounding=t,Jx(wx==2||wx==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)},Z.cubeRoot=Z.cbrt=function(){var e,t,n,r,i,a,o,s,c,l,u=this,d=u.constructor;if(!u.isFinite()||u.isZero())return new d(u);for(Tx=!1,a=u.s*Mx(u.s*u,1/3),!a||Math.abs(a)==1/0?(n=Hx(u.d),e=u.e,(a=(e-n.length+1)%3)&&(n+=a==1||a==-2?`0`:`00`),a=Mx(n,1/3),e=jx((e+1)/3)-(e%3==(e<0?-1:2)),a==1/0?n=`5e`+e:(n=a.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+e),r=new d(n),r.s=u.s):r=new d(a.toString()),o=(e=d.precision)+3;;)if(s=r,c=s.times(s).times(s),l=c.plus(u),r=qx(l.plus(u).times(s),l.plus(c),o+2,1),Hx(s.d).slice(0,o)===(n=Hx(r.d)).slice(0,o))if(n=n.slice(o-3,o+1),n==`9999`||!i&&n==`4999`){if(!i&&(Jx(s,e+1,0),s.times(s).times(s).eq(u))){r=s;break}o+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(Jx(r,e+1,1),t=!r.times(r).times(r).eq(u));break}return Tx=!0,Jx(r,e,d.rounding,t)},Z.decimalPlaces=Z.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-jx(this.e/Rx))*Rx,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},Z.dividedBy=Z.div=function(e){return qx(this,new this.constructor(e))},Z.dividedToIntegerBy=Z.divToInt=function(e){var t=this,n=t.constructor;return Jx(qx(t,new n(e),0,1,1),n.precision,n.rounding)},Z.equals=Z.eq=function(e){return this.cmp(e)===0},Z.floor=function(){return Jx(new this.constructor(this),this.e+1,3)},Z.greaterThan=Z.gt=function(e){return this.cmp(e)>0},Z.greaterThanOrEqualTo=Z.gte=function(e){var t=this.cmp(e);return t==1||t===0},Z.hyperbolicCosine=Z.cosh=function(){var e,t,n,r,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;n=o.precision,r=o.rounding,o.precision=n+Math.max(a.e,a.sd())+4,o.rounding=1,i=a.d.length,i<32?(e=Math.ceil(i/3),t=(1/dS(4,e)).toString()):(e=16,t=`2.3283064365386962890625e-10`),a=uS(o,1,a.times(t),new o(1),!0);for(var c,l=e,u=new o(8);l--;)c=a.times(a),a=s.minus(c.times(u.minus(c.times(u))));return Jx(a,o.precision=n,o.rounding=r,!0)},Z.hyperbolicSine=Z.sinh=function(){var e,t,n,r,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,n=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,r=i.d.length,r<3)i=uS(a,2,i,i,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,i=i.times(1/dS(5,e)),i=uS(a,2,i,i,!0);for(var o,s=new a(5),c=new a(16),l=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(c.times(o).plus(l))))}return a.precision=t,a.rounding=n,Jx(i,t,n,!0)},Z.hyperbolicTangent=Z.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,qx(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},Z.inverseCosine=Z.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,i=t.rounding;return n===-1?e.isZero()?Qx(t,r+4,i).times(.5):(t.precision=r+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=r,t.rounding=i,e.times(2)):n===0?e.isNeg()?Qx(t,r,i):new t(0):new t(NaN)},Z.inverseHyperbolicCosine=Z.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,Tx=!1,n=n.times(n).minus(1).sqrt().plus(n),Tx=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},Z.inverseHyperbolicSine=Z.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,Tx=!1,n=n.times(n).plus(1).sqrt().plus(n),Tx=!0,r.precision=e,r.rounding=t,n.ln())},Z.inverseHyperbolicTangent=Z.atanh=function(){var e,t,n,r,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,r=i.sd(),Math.max(r,e)<2*-i.e-1?Jx(new a(i),e,t,!0):(a.precision=n=r-i.e,i=qx(i.plus(1),new a(1).minus(i),n+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},Z.inverseSine=Z.asin=function(){var e,t,n,r,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),n=a.precision,r=a.rounding,t===-1?(a.precision=n+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=n,a.rounding=r,i.times(2)):t===0?(e=Qx(a,n+4,r).times(.5),e.s=i.s,e):new a(NaN))},Z.inverseTangent=Z.atan=function(){var e,t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding;if(!l.isFinite()){if(!l.s)return new u(NaN);if(d+4<=Vx)return o=Qx(u,d+4,f).times(.5),o.s=l.s,o}else if(l.isZero())return new u(l);else if(l.abs().eq(1)&&d+4<=Vx)return o=Qx(u,d+4,f).times(.25),o.s=l.s,o;for(u.precision=s=d+10,u.rounding=1,n=Math.min(28,s/Rx+2|0),e=n;e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(Tx=!1,t=Math.ceil(s/Rx),r=1,c=l.times(l),o=new u(l),i=l;e!==-1;)if(i=i.times(c),a=o.minus(i.div(r+=2)),i=i.times(c),o=a.plus(i.div(r+=2)),o.d[t]!==void 0)for(e=t;o.d[e]===a.d[e]&&e--;);return n&&(o=o.times(2<this.d.length-2},Z.isNaN=function(){return!this.s},Z.isNegative=Z.isNeg=function(){return this.s<0},Z.isPositive=Z.isPos=function(){return this.s>0},Z.isZero=function(){return!!this.d&&this.d[0]===0},Z.lessThan=Z.lt=function(e){return this.cmp(e)<0},Z.lessThanOrEqualTo=Z.lte=function(e){return this.cmp(e)<1},Z.logarithm=Z.log=function(e){var t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding,p=5;if(e==null)e=new u(10),t=!0;else{if(e=new u(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new u(NaN);t=e.eq(10)}if(n=l.d,l.s<0||!n||!n[0]||l.eq(1))return new u(n&&!n[0]?-1/0:l.s==1?n?0:1/0:NaN);if(t)if(n.length>1)a=!0;else{for(i=n[0];i%10==0;)i/=10;a=i!==1}if(Tx=!1,s=d+p,o=aS(l,s),r=t?Zx(u,s+10):aS(e,s),c=qx(o,r,s,1),Wx(c.d,i=d,f))do if(s+=10,o=aS(l,s),r=t?Zx(u,s+10):aS(e,s),c=qx(o,r,s,1),!a){+Hx(c.d).slice(i+1,i+15)+1==0x5af3107a4000&&(c=Jx(c,d+1,0));break}while(Wx(c.d,i+=10,f));return Tx=!0,Jx(c,d,f)},Z.minus=Z.sub=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.constructor;if(e=new m(e),!p.d||!e.d)return!p.s||!e.s?e=new m(NaN):p.d?e.s=-e.s:e=new m(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(l=p.d,f=e.d,s=m.precision,c=m.rounding,!l[0]||!f[0]){if(f[0])e.s=-e.s;else if(l[0])e=new m(p);else return new m(c===3?-0:0);return Tx?Jx(e,s,c):e}if(n=jx(e.e/Rx),u=jx(p.e/Rx),l=l.slice(),a=u-n,a){for(d=a<0,d?(t=l,a=-a,o=f.length):(t=f,n=u,o=l.length),r=Math.max(Math.ceil(s/Rx),o)+2,a>r&&(a=r,t.length=1),t.reverse(),r=a;r--;)t.push(0);t.reverse()}else{for(r=l.length,o=f.length,d=r0;--r)l[o++]=0;for(r=f.length;r>a;){if(l[--r]o?a+1:o+1,i>o&&(i=o,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(o=l.length,i=u.length,o-i<0&&(i=o,n=u,u=l,l=n),t=0;i;)t=(l[--i]=l[i]+u[i]+t)/Lx|0,l[i]%=Lx;for(t&&(l.unshift(t),++r),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=Xx(l,r),Tx?Jx(e,s,c):e},Z.precision=Z.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Dx+e);return n.d?(t=$x(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},Z.round=function(){var e=this,t=e.constructor;return Jx(new t(e),e.e+1,t.rounding)},Z.sine=Z.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+Rx,r.rounding=1,n=lS(r,fS(r,n)),r.precision=e,r.rounding=t,Jx(wx>2?n.neg():n,e,t,!0)):new r(NaN)},Z.squareRoot=Z.sqrt=function(){var e,t,n,r,i,a,o=this,s=o.d,c=o.e,l=o.s,u=o.constructor;if(l!==1||!s||!s[0])return new u(!l||l<0&&(!s||s[0])?NaN:s?o:1/0);for(Tx=!1,l=Math.sqrt(+o),l==0||l==1/0?(t=Hx(s),(t.length+c)%2==0&&(t+=`0`),l=Math.sqrt(t),c=jx((c+1)/2)-(c<0||c%2),l==1/0?t=`5e`+c:(t=l.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+c),r=new u(t)):r=new u(l.toString()),n=(c=u.precision)+3;;)if(a=r,r=a.plus(qx(o,a,n+2,1)).times(.5),Hx(a.d).slice(0,n)===(t=Hx(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t==`9999`||!i&&t==`4999`){if(!i&&(Jx(a,c+1,0),a.times(a).eq(o))){r=a;break}n+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)==`5`)&&(Jx(r,c+1,1),e=!r.times(r).eq(o));break}return Tx=!0,Jx(r,c,u.rounding,e)},Z.tangent=Z.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=qx(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,Jx(wx==2||wx==4?n.neg():n,e,t,!0)):new r(NaN)},Z.times=Z.mul=function(e){var t,n,r,i,a,o,s,c,l,u=this,d=u.constructor,f=u.d,p=(e=new d(e)).d;if(e.s*=u.s,!f||!f[0]||!p||!p[0])return new d(!e.s||f&&!f[0]&&!p||p&&!p[0]&&!f?NaN:!f||!p?e.s/0:e.s*0);for(n=jx(u.e/Rx)+jx(e.e/Rx),c=f.length,l=p.length,c=0;){for(t=0,i=c+r;i>r;)s=a[i]+p[r]*f[i-r-1]+t,a[i--]=s%Lx|0,t=s/Lx|0;a[i]=(a[i]+t)%Lx|0}for(;!a[--o];)a.pop();return t?++n:a.shift(),e.d=a,e.e=Xx(a,n),Tx?Jx(e,d.precision,d.rounding):e},Z.toBinary=function(e,t){return pS(this,2,e,t)},Z.toDecimalPlaces=Z.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(Ux(e,0,vx),t===void 0?t=r.rounding:Ux(t,0,8),Jx(n,e+n.e+1,t))},Z.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=Yx(r,!0):(Ux(e,0,vx),t===void 0?t=i.rounding:Ux(t,0,8),r=Jx(new i(r),e+1,t),n=Yx(r,!0,e+1)),r.isNeg()&&!r.isZero()?`-`+n:n},Z.toFixed=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?n=Yx(i):(Ux(e,0,vx),t===void 0?t=a.rounding:Ux(t,0,8),r=Jx(new a(i),e+i.e+1,t),n=Yx(r,!1,e+r.e+1)),i.isNeg()&&!i.isZero()?`-`+n:n},Z.toFraction=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.d,h=p.constructor;if(!m)return new h(p);if(l=n=new h(1),r=c=new h(0),t=new h(r),a=t.e=$x(m)-p.e-1,o=a%Rx,t.d[0]=Mx(10,o<0?Rx+o:o),e==null)e=a>0?t:l;else{if(s=new h(e),!s.isInt()||s.lt(l))throw Error(Dx+s);e=s.gt(t)?a>0?t:l:s}for(Tx=!1,s=new h(Hx(m)),u=h.precision,h.precision=a=m.length*Rx*2;d=qx(s,t,0,1,1),i=n.plus(d.times(r)),i.cmp(e)!=1;)n=r,r=i,i=l,l=c.plus(d.times(i)),c=i,i=t,t=s.minus(d.times(i)),s=i;return i=qx(e.minus(n),r,0,1,1),c=c.plus(i.times(l)),n=n.plus(i.times(r)),c.s=l.s=p.s,f=qx(l,r,a,1).minus(p).abs().cmp(qx(c,n,a,1).minus(p).abs())<1?[l,r]:[c,n],h.precision=u,Tx=!0,f},Z.toHexadecimal=Z.toHex=function(e,t){return pS(this,16,e,t)},Z.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),t===void 0?t=r.rounding:Ux(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&=n.s,e}return e.d[0]?(Tx=!1,n=qx(n,e,0,t,1).times(e),Tx=!0,Jx(n)):(e.s=n.s,n=e),n},Z.toNumber=function(){return+this},Z.toOctal=function(e,t){return pS(this,8,e,t)},Z.toPower=Z.pow=function(e){var t,n,r,i,a,o,s=this,c=s.constructor,l=+(e=new c(e));if(!s.d||!e.d||!s.d[0]||!e.d[0])return new c(Mx(+s,l));if(s=new c(s),s.eq(1))return s;if(r=c.precision,a=c.rounding,e.eq(1))return Jx(s,r,a);if(t=jx(e.e/Rx),t>=e.d.length-1&&(n=l<0?-l:l)<=zx)return i=tS(c,s,n,r),e.s<0?new c(1).div(i):Jx(i,r,a);if(o=s.s,o<0){if(tc.maxE+1||t0?o/0:0):(Tx=!1,c.rounding=s.s=1,n=Math.min(12,(t+``).length),i=iS(e.times(aS(s,r+n)),r),i.d&&(i=Jx(i,r+5,1),Wx(i.d,r,a)&&(t=r+10,i=Jx(iS(e.times(aS(s,t+n)),t),t+5,1),+Hx(i.d).slice(r+1,r+15)+1==0x5af3107a4000&&(i=Jx(i,r+1,0)))),i.s=o,Tx=!0,c.rounding=a,Jx(i,r,a))},Z.toPrecision=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=Yx(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(Ux(e,1,vx),t===void 0?t=i.rounding:Ux(t,0,8),r=Jx(new i(r),e,t),n=Yx(r,e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?`-`+n:n},Z.toSignificantDigits=Z.toSD=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(Ux(e,1,vx),t===void 0?t=r.rounding:Ux(t,0,8)),Jx(new r(n),e,t)},Z.toString=function(){var e=this,t=e.constructor,n=Yx(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?`-`+n:n},Z.truncated=Z.trunc=function(){return Jx(new this.constructor(this),this.e+1,1)},Z.valueOf=Z.toJSON=function(){var e=this,t=e.constructor,n=Yx(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?`-`+n:n};function Hx(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;tn)throw Error(Dx+e)}function Wx(e,t,n,r){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=Rx,i=0):(i=Math.ceil((t+1)/Rx),t%=Rx),a=Mx(10,Rx-t),s=e[i]%a|0,r==null?t<3?(t==0?s=s/100|0:t==1&&(s=s/10|0),o=n<4&&s==99999||n>3&&s==49999||s==5e4||s==0):o=(n<4&&s+1==a||n>3&&s+1==a/2)&&(e[i+1]/a/100|0)==Mx(10,t-2)-1||(s==a/2||s==0)&&(e[i+1]/a/100|0)==0:t<4?(t==0?s=s/1e3|0:t==1?s=s/100|0:t==2&&(s=s/10|0),o=(r||n<4)&&s==9999||!r&&n>3&&s==4999):o=((r||n<4)&&s+1==a||!r&&n>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==Mx(10,t-3)-1,o}function Gx(e,t,n){for(var r,i=[0],a,o=0,s=e.length;on-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function Kx(e,t){var n,r,i;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),i=(1/dS(4,n)).toString()):(n=16,i=`2.3283064365386962890625e-10`),e.precision+=n,t=uS(e,1,t.times(i),new e(1));for(var a=n;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=n,t}var qx=(function(){function e(e,t,n){var r,i=0,a=e.length;for(e=e.slice();a--;)r=e[a]*t+i,e[a]=r%n|0,i=r/n|0;return i&&e.unshift(i),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;it[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=+(e[n]1;)e.shift()}return function(r,i,a,o,s,c){var l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k=r.constructor,A=r.s==i.s?1:-1,j=r.d,M=i.d;if(!j||!j[0]||!M||!M[0])return new k(!r.s||!i.s||(j?M&&j[0]==M[0]:!M)?NaN:j&&j[0]==0||!M?A*0:A/0);for(c?(p=1,u=r.e-i.e):(c=Lx,p=Rx,u=jx(r.e/p)-jx(i.e/p)),D=M.length,T=j.length,_=new k(A),v=_.d=[],d=0;M[d]==(j[d]||0);d++);if(M[d]>(j[d]||0)&&u--,a==null?(S=a=k.precision,o=k.rounding):S=s?a+(r.e-i.e)+1:a,S<0)v.push(1),m=!0;else{if(S=S/p+2|0,d=0,D==1){for(f=0,M=M[0],S++;(d1&&(M=e(M,f,c),j=e(j,f,c),D=M.length,T=j.length),w=D,y=j.slice(0,D),b=y.length;b=c/2&&++E;do f=0,l=t(M,y,D,b),l<0?(x=y[0],D!=b&&(x=x*c+(y[1]||0)),f=x/E|0,f>1?(f>=c&&(f=c-1),h=e(M,f,c),g=h.length,b=y.length,l=t(h,y,g,b),l==1&&(f--,n(h,D=10;f/=10)d++;_.e=d+u*p-1,Jx(_,s?a+_.e+1:a,o,m)}return _}})();function Jx(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor;out:if(t!=null){if(d=e.d,!d)return e;for(i=1,s=d[0];s>=10;s/=10)i++;if(a=t-i,a<0)a+=Rx,o=t,u=d[f=0],c=u/Mx(10,i-o-1)%10|0;else if(f=Math.ceil((a+1)/Rx),s=d.length,f>=s)if(r){for(;s++<=f;)d.push(0);u=c=0,i=1,a%=Rx,o=a-Rx+1}else break out;else{for(u=s=d[f],i=1;s>=10;s/=10)i++;a%=Rx,o=a-Rx+i,c=o<0?0:u/Mx(10,i-o-1)%10|0}if(r=r||t<0||d[f+1]!==void 0||(o<0?u:u%Mx(10,i-o-1)),l=n<4?(c||r)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(a>0?o>0?u/Mx(10,i-o):0:d[f-1])%10&1||n==(e.s<0?8:7)),t<1||!d[0])return d.length=0,l?(t-=e.e+1,d[0]=Mx(10,(Rx-t%Rx)%Rx),e.e=-t||0):d[0]=e.e=0,e;if(a==0?(d.length=f,s=1,f--):(d.length=f+1,s=Mx(10,Rx-a),d[f]=o>0?(u/Mx(10,i-o)%Mx(10,o)|0)*s:0),l)for(;;)if(f==0){for(a=1,o=d[0];o>=10;o/=10)a++;for(o=d[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,d[0]==Lx&&(d[0]=1));break}else{if(d[f]+=s,d[f]!=Lx)break;d[f--]=0,s=1}for(a=d.length;d[--a]===0;)d.pop()}return Tx&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e0?a=a.charAt(0)+`.`+a.slice(1)+eS(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(e.e<0?`e`:`e+`)+e.e):i<0?(a=`0.`+eS(-i-1)+a,n&&(r=n-o)>0&&(a+=eS(r))):i>=o?(a+=eS(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+eS(r))):((r=i+1)0&&(i+1===o&&(a+=`.`),a+=eS(r))),a}function Xx(e,t){var n=e[0];for(t*=Rx;n>=10;n/=10)t++;return t}function Zx(e,t,n){if(t>Bx)throw Tx=!0,n&&(e.precision=n),Error(Ox);return Jx(new e(bx),t,1,!0)}function Qx(e,t,n){if(t>Vx)throw Error(Ox);return Jx(new e(xx),t,n,!0)}function $x(e){var t=e.length-1,n=t*Rx+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function eS(e){for(var t=``;e--;)t+=`0`;return t}function tS(e,t,n,r){var i,a=new e(1),o=Math.ceil(r/Rx+4);for(Tx=!1;;){if(n%2&&(a=a.times(t),mS(a.d,o)&&(i=!0)),n=jx(n/2),n===0){n=a.d.length-1,i&&a.d[n]===0&&++a.d[n];break}t=t.times(t),mS(t.d,o)}return Tx=!0,a}function nS(e){return e.d[e.d.length-1]&1}function rS(e,t,n){for(var r,i,a=new e(t[0]),o=0;++o17)return new f(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(t==null?(Tx=!1,c=m):c=t,s=new f(.03125);e.e>-2;)e=e.times(s),d+=5;for(r=Math.log(Mx(2,d))/Math.LN10*2+5|0,c+=r,n=a=o=new f(1),f.precision=c;;){if(a=Jx(a.times(e),c,1),n=n.times(++u),s=o.plus(qx(a,n,c,1)),Hx(s.d).slice(0,c)===Hx(o.d).slice(0,c)){for(i=d;i--;)o=Jx(o.times(o),c,1);if(t==null)if(l<3&&Wx(o.d,c-r,p,l))f.precision=c+=10,n=a=s=new f(1),u=0,l++;else return Jx(o,f.precision=m,p,Tx=!0);else return f.precision=m,o}o=s}}function aS(e,t){var n,r,i,a,o,s,c,l,u,d,f,p=1,m=10,h=e,g=h.d,_=h.constructor,v=_.rounding,y=_.precision;if(h.s<0||!g||!g[0]||!h.e&&g[0]==1&&g.length==1)return new _(g&&!g[0]?-1/0:h.s==1?g?0:h:NaN);if(t==null?(Tx=!1,u=y):u=t,_.precision=u+=m,n=Hx(g),r=n.charAt(0),Math.abs(a=h.e)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)h=h.times(e),n=Hx(h.d),r=n.charAt(0),p++;a=h.e,r>1?(h=new _(`0.`+n),a++):h=new _(r+`.`+n.slice(1))}else return l=Zx(_,u+2,y).times(a+``),h=aS(new _(r+`.`+n.slice(1)),u-m).plus(l),_.precision=y,t==null?Jx(h,y,v,Tx=!0):h;for(d=h,c=o=h=qx(h.minus(1),h.plus(1),u,1),f=Jx(h.times(h),u,1),i=3;;){if(o=Jx(o.times(f),u,1),l=c.plus(qx(o,new _(i),u,1)),Hx(l.d).slice(0,u)===Hx(c.d).slice(0,u))if(c=c.times(2),a!==0&&(c=c.plus(Zx(_,u+2,y).times(a+``))),c=qx(c,new _(p),u,1),t==null)if(Wx(c.d,u-m,v,s))_.precision=u+=m,l=o=h=qx(d.minus(1),d.plus(1),u,1),f=Jx(h.times(h),u,1),i=s=1;else return Jx(c,_.precision=y,v,Tx=!0);else return _.precision=y,c;c=l,i+=2}}function oS(e){return String(e.s*e.s/0)}function sS(e,t){var n,r,i;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;r++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(r,i),t){if(i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%Rx,n<0&&(r+=Rx),re.constructor.maxE?(e.d=null,e.e=NaN):e.e-1){if(t=t.replace(/(\d)_(?=\d)/g,`$1`),Ix.test(t))return sS(e,t)}else if(t===`Infinity`||t===`NaN`)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(Px.test(t))n=16,t=t.toLowerCase();else if(Nx.test(t))n=2;else if(Fx.test(t))n=8;else throw Error(Dx+t);for(a=t.search(/p/i),a>0?(c=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),a=t.indexOf(`.`),o=a>=0,r=e.constructor,o&&(t=t.replace(`.`,``),s=t.length,a=s-a,i=tS(r,new r(n),a,a*2)),l=Gx(t,n,Lx),u=l.length-1,a=u;l[a]===0;--a)l.pop();return a<0?new r(e.s*0):(e.e=Xx(l,u),e.d=l,Tx=!1,o&&(e=qx(e,i,s*4)),c&&(e=e.times(Math.abs(c)<54?Mx(2,c):nC.pow(2,c))),Tx=!0,e)}function lS(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:uS(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/dS(5,n)),t=uS(e,2,t,t);for(var i,a=new e(5),o=new e(16),s=new e(20);n--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}function uS(e,t,n,r,i){var a,o,s,c,l=1,u=e.precision,d=Math.ceil(u/Rx);for(Tx=!1,c=n.times(n),s=new e(r);;){if(o=qx(s.times(c),new e(t++*t++),u,1),s=i?r.plus(o):r.minus(o),r=qx(o.times(c),new e(t++*t++),u,1),o=s.plus(r),o.d[d]!==void 0){for(a=d;o.d[a]===s.d[a]&&a--;);if(a==-1)break}a=s,s=r,r=o,o=a,l++}return Tx=!0,o.d.length=d+1,o}function dS(e,t){for(var n=e;--t;)n*=e;return n}function fS(e,t){var n,r=t.s<0,i=Qx(e,e.precision,1),a=i.times(.5);if(t=t.abs(),t.lte(a))return wx=r?4:1,t;if(n=t.divToInt(i),n.isZero())wx=r?3:2;else{if(t=t.minus(n.times(i)),t.lte(a))return wx=nS(n)?r?2:3:r?4:1,t;wx=nS(n)?r?1:4:r?3:2}return t.minus(i).abs()}function pS(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor,m=n!==void 0;if(m?(Ux(n,1,vx),r===void 0?r=p.rounding:Ux(r,0,8)):(n=p.precision,r=p.rounding),!e.isFinite())u=oS(e);else{for(u=Yx(e),o=u.indexOf(`.`),m?(i=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):i=t,o>=0&&(u=u.replace(`.`,``),f=new p(1),f.e=u.length-o,f.d=Gx(Yx(f),10,i),f.e=f.d.length),d=Gx(u,10,i),a=c=d.length;d[--c]==0;)d.pop();if(!d[0])u=m?`0p+0`:`0`;else{if(o<0?a--:(e=new p(e),e.d=d,e.e=a,e=qx(e,f,n,r,0,i),d=e.d,a=e.e,l=Cx),o=d[n],s=i/2,l||=d[n+1]!==void 0,l=r<4?(o!==void 0||l)&&(r===0||r===(e.s<0?3:2)):o>s||o===s&&(r===4||l||r===6&&d[n-1]&1||r===(e.s<0?8:7)),d.length=n,l)for(;++d[--n]>i-1;)d[n]=0,n||(++a,d.unshift(1));for(c=d.length;!d[c-1];--c);for(o=0,u=``;o1)if(t==16||t==8){for(o=t==16?4:3,--c;c%o;c++)u+=`0`;for(d=Gx(u,i,t),c=d.length;!d[c-1];--c);for(o=1,u=`1.`;oc)for(a-=c;a--;)u+=`0`;else at)return e.length=t,!0}function hS(e){return new this(e).abs()}function gS(e){return new this(e).acos()}function _S(e){return new this(e).acosh()}function vS(e,t){return new this(e).plus(t)}function yS(e){return new this(e).asin()}function bS(e){return new this(e).asinh()}function xS(e){return new this(e).atan()}function SS(e){return new this(e).atanh()}function CS(e,t){e=new this(e),t=new this(t);var n,r=this.precision,i=this.rounding,a=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=Qx(this,a,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?Qx(this,r,i):new this(0),n.s=e.s):!e.d||t.isZero()?(n=Qx(this,a,1).times(.5),n.s=e.s):t.s<0?(this.precision=a,this.rounding=1,n=this.atan(qx(e,t,a,1)),t=Qx(this,a,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(qx(e,t,a,1)),n}function wS(e){return new this(e).cbrt()}function TS(e){return Jx(e=new this(e),e.e+1,2)}function ES(e,t,n){return new this(e).clamp(t,n)}function DS(e){if(!e||typeof e!=`object`)throw Error(Ex+`Object expected`);var t,n,r,i=e.defaults===!0,a=[`precision`,1,vx,`rounding`,0,8,`toExpNeg`,-_x,0,`toExpPos`,0,_x,`maxE`,0,_x,`minE`,-_x,0,`modulo`,0,9];for(t=0;t=a[t+1]&&r<=a[t+2])this[n]=r;else throw Error(Dx+n+`: `+r);if(n=`crypto`,i&&(this[n]=Sx[n]),(r=e[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(kx);else this[n]=!1;else throw Error(Dx+n+`: `+r);return this}function OS(e){return new this(e).cos()}function kS(e){return new this(e).cosh()}function AS(e){var t,n,r;function i(e){var t,n,r,a=this;if(!(a instanceof i))return new i(e);if(a.constructor=i,FS(e)){a.s=e.s,Tx?!e.d||e.e>i.maxE?(a.e=NaN,a.d=null):e.e=10;n/=10)t++;Tx?t>i.maxE?(a.e=NaN,a.d=null):t=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);a=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=r/4}else throw Error(kx);for(r=s[--a],e%=Rx,r&&e&&(i=Mx(10,Rx-e),s[a]=(r/i|0)*i);s[a]===0;a--)s.pop();if(a<0)n=0,s=[0];else{for(n=-1;s[0]===0;n-=Rx)s.shift();for(r=1,i=s[0];i>=10;i/=10)r++;r{var{on:t,config:n}=e,r=nC.clone({precision:n.precision,modulo:nC.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type=`BigNumber`,r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:`BigNumber`,value:this.toString()}},r.fromJSON=function(e){return new r(e.value)},t&&t(`config`,function(e,t){e.precision!==t.precision&&r.config({precision:e.precision})}),r},{isClass:!0}),iC=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:(Math.exp(e)+Math.exp(-e))*.5},aC=Math.sinh||function(e){return Math.abs(e)<1e-9?e:(Math.exp(e)-Math.exp(-e))*.5},oC=e=>{let t=Math.sin(.5*e);return-2*t*t},sC=function(e,t){return e=Math.abs(e),t=Math.abs(t),e0&&cC();break;case`number`:n.im=0,n.re=e;break;default:cC()}return isNaN(n.re)||isNaN(n.im),n};function Q(e,t){if(!(this instanceof Q))return new Q(e,t);let n=dC(e,t);this.re=n.re,this.im=n.im}Q.prototype={re:0,im:0,sign:function(){let e=sC(this.re,this.im);return new Q(this.re/e,this.im/e)},add:function(e,t){let n=dC(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im));return r||i?r&&i?Q.NAN:Q.INFINITY:new Q(this.re+n.re,this.im+n.im)},sub:function(e,t){let n=dC(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im));return r||i?r&&i?Q.NAN:Q.INFINITY:new Q(this.re-n.re,this.im-n.im)},mul:function(e,t){let n=dC(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im)),a=this.re===0&&this.im===0,o=n.re===0&&n.im===0;return r&&o||i&&a?Q.NAN:r||i?Q.INFINITY:n.im===0&&this.im===0?new Q(this.re*n.re,0):new Q(this.re*n.re-this.im*n.im,this.re*n.im+this.im*n.re)},div:function(e,t){let n=dC(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im)),a=this.re===0&&this.im===0,o=n.re===0&&n.im===0;if(a&&o||r&&i)return Q.NAN;if(o||r)return Q.INFINITY;if(a||i)return Q.ZERO;if(n.im===0)return new Q(this.re/n.re,this.im/n.re);if(Math.abs(n.re)0)return new Q(this.re**+n.re,0);if(this.re===0)switch((n.re%4+4)%4){case 0:return new Q(this.im**+n.re,0);case 1:return new Q(0,this.im**+n.re);case 2:return new Q(-(this.im**+n.re),0);case 3:return new Q(0,-(this.im**+n.re))}}if(r&&n.re>0)return Q.ZERO;let i=Math.atan2(this.im,this.re),a=lC(this.re,this.im),o=Math.exp(n.re*a-n.im*i),s=n.im*a+n.re*i;return new Q(o*Math.cos(s),o*Math.sin(s))},sqrt:function(){let e=this.re,t=this.im;if(t===0)return e>=0?new Q(Math.sqrt(e),0):new Q(0,Math.sqrt(-e));let n=sC(e,t),r=Math.sqrt(.5*(n+Math.abs(e))),i=Math.abs(t)/(2*r);return e>=0?new Q(r,t<0?-i:i):new Q(i,t<0?-r:r)},exp:function(){let e=Math.exp(this.re);return this.im===0?new Q(e,0):new Q(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){let e=this.re,t=this.im;return new Q(Math.expm1(e)*Math.cos(t)+oC(t),Math.exp(e)*Math.sin(t))},log:function(){let e=this.re,t=this.im;return t===0&&e>0?new Q(Math.log(e),0):new Q(lC(e,t),Math.atan2(t,e))},abs:function(){return sC(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){let e=this.re,t=this.im;return new Q(Math.sin(e)*iC(t),Math.cos(e)*aC(t))},cos:function(){let e=this.re,t=this.im;return new Q(Math.cos(e)*iC(t),-Math.sin(e)*aC(t))},tan:function(){let e=2*this.re,t=2*this.im,n=Math.cos(e)+iC(t);return new Q(Math.sin(e)/n,aC(t)/n)},cot:function(){let e=2*this.re,t=2*this.im,n=Math.cos(e)-iC(t);return new Q(-Math.sin(e)/n,aC(t)/n)},sec:function(){let e=this.re,t=this.im,n=.5*iC(2*t)+.5*Math.cos(2*e);return new Q(Math.cos(e)*iC(t)/n,Math.sin(e)*aC(t)/n)},csc:function(){let e=this.re,t=this.im,n=.5*iC(2*t)-.5*Math.cos(2*e);return new Q(Math.sin(e)*iC(t)/n,-Math.cos(e)*aC(t)/n)},asin:function(){let e=this.re,t=this.im,n=new Q(t*t-e*e+1,-2*e*t).sqrt(),r=new Q(n.re-t,n.im+e).log();return new Q(r.im,-r.re)},acos:function(){let e=this.re,t=this.im,n=new Q(t*t-e*e+1,-2*e*t).sqrt(),r=new Q(n.re-t,n.im+e).log();return new Q(Math.PI/2-r.im,r.re)},atan:function(){let e=this.re,t=this.im;if(e===0){if(t===1)return new Q(0,1/0);if(t===-1)return new Q(0,-1/0)}let n=e*e+(1-t)*(1-t),r=new Q((1-t*t-e*e)/n,-2*e/n).log();return new Q(-.5*r.im,.5*r.re)},acot:function(){let e=this.re,t=this.im;if(t===0)return new Q(Math.atan2(1,e),0);let n=e*e+t*t;return n===0?new Q(e===0?0:e/0,t===0?0:-t/0).atan():new Q(e/n,-t/n).atan()},asec:function(){let e=this.re,t=this.im;if(e===0&&t===0)return new Q(0,1/0);let n=e*e+t*t;return n===0?new Q(e===0?0:e/0,t===0?0:-t/0).acos():new Q(e/n,-t/n).acos()},acsc:function(){let e=this.re,t=this.im;if(e===0&&t===0)return new Q(Math.PI/2,1/0);let n=e*e+t*t;return n===0?new Q(e===0?0:e/0,t===0?0:-t/0).asin():new Q(e/n,-t/n).asin()},sinh:function(){let e=this.re,t=this.im;return new Q(aC(e)*Math.cos(t),iC(e)*Math.sin(t))},cosh:function(){let e=this.re,t=this.im;return new Q(iC(e)*Math.cos(t),aC(e)*Math.sin(t))},tanh:function(){let e=2*this.re,t=2*this.im,n=iC(e)+Math.cos(t);return new Q(aC(e)/n,Math.sin(t)/n)},coth:function(){let e=2*this.re,t=2*this.im,n=iC(e)-Math.cos(t);return new Q(aC(e)/n,-Math.sin(t)/n)},csch:function(){let e=this.re,t=this.im,n=Math.cos(2*t)-iC(2*e);return new Q(-2*aC(e)*Math.cos(t)/n,2*iC(e)*Math.sin(t)/n)},sech:function(){let e=this.re,t=this.im,n=Math.cos(2*t)+iC(2*e);return new Q(2*iC(e)*Math.cos(t)/n,-2*aC(e)*Math.sin(t)/n)},asinh:function(){let e=this.re,t=this.im;if(t===0){if(e===0)return new Q(0,0);let t=Math.abs(e),n=Math.log(t+Math.sqrt(t*t+1));return new Q(e<0?-n:n,0)}let n=new Q(e*e-t*t+1,2*e*t).sqrt();return new Q(e+n.re,t+n.im).log()},acosh:function(){let e=this.re,t=this.im;if(t===0){if(e>1)return new Q(Math.log(e+Math.sqrt(e-1)*Math.sqrt(e+1)),0);if(e<-1){let t=Math.sqrt(e*e-1);return new Q(Math.log(-e+t),Math.PI)}return new Q(0,Math.acos(e))}let n=new Q(e-1,t).sqrt(),r=new Q(e+1,t).sqrt();return new Q(e+n.re*r.re-n.im*r.im,t+n.re*r.im+n.im*r.re).log()},atanh:function(){let e=this.re,t=this.im;if(t===0){if(e===0)return new Q(0,0);if(e===1)return new Q(1/0,0);if(e===-1)return new Q(-1/0,0);if(-11){let t=(e+1)/(e-1);return new Q(.5*Math.log(t),-Math.PI/2)}let t=(1+e)/(1-e);return new Q(.5*Math.log(-t),Math.PI/2)}let n=1-e,r=1+e,i=n*n+t*t;if(i===0)return new Q(e===-1?0:e/0,t===0?0:t/0);let a=(r*n-t*t)/i,o=(t*n+r*t)/i;return new Q(lC(a,o)/2,Math.atan2(o,a)/2)},acoth:function(){let e=this.re,t=this.im;if(e===0&&t===0)return new Q(0,Math.PI/2);let n=e*e+t*t;return n===0?new Q(e===0?0:e/0,t===0?0:-t/0).atanh():new Q(e/n,-t/n).atanh()},acsch:function(){let e=this.re,t=this.im;if(t===0){if(e===0)return new Q(1/0,0);let t=1/e;return new Q(Math.log(t+Math.sqrt(t*t+1)),0)}let n=e*e+t*t;return n===0?new Q(e===0?0:e/0,t===0?0:-t/0).asinh():new Q(e/n,-t/n).asinh()},asech:function(){let e=this.re,t=this.im;if(this.isZero())return Q.INFINITY;let n=e*e+t*t;return n===0?new Q(e===0?0:e/0,t===0?0:-t/0).acosh():new Q(e/n,-t/n).acosh()},inverse:function(){if(this.isZero())return Q.INFINITY;if(this.isInfinite())return Q.ZERO;let e=this.re,t=this.im,n=e*e+t*t;return new Q(e/n,-t/n)},conjugate:function(){return new Q(this.re,-this.im)},neg:function(){return new Q(-this.re,-this.im)},ceil:function(e){return e=10**(e||0),new Q(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=10**(e||0),new Q(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=10**(e||0),new Q(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){let n=dC(e,t);return Math.abs(n.re-this.re)<=Q.EPSILON&&Math.abs(n.im-this.im)<=Q.EPSILON},clone:function(){return new Q(this.re,this.im)},toString:function(){let e=this.re,t=this.im,n=``;return this.isNaN()?`NaN`:this.isInfinite()?`Infinity`:(Math.abs(e)(Object.defineProperty(Q,"name",{value:`Complex`}),Q.prototype.constructor=Q,Q.prototype.type=`Complex`,Q.prototype.isComplex=!0,Q.prototype.toJSON=function(){return{mathjs:`Complex`,re:this.re,im:this.im}},Q.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Q.prototype.format=function(e){var t=``,n=this.im,r=this.re,i=Ub(this.re,e),a=Ub(this.im,e),o=Ty(e)?e:e?e.precision:null;if(o!==null){var s=10**-o;Math.abs(r/n)t.re?1:e.ret.im?1:e.im`u`&&(BigInt=function(e){if(isNaN(e))throw Error(``);return e});var pC=BigInt(0),mC=BigInt(1),hC=BigInt(2),gC=BigInt(3),_C=BigInt(5),vC=BigInt(10);BigInt(2**53-1);var yC=2e3,$={s:mC,n:pC,d:mC};function bC(e,t){try{e=BigInt(e)}catch{throw MC()}return e*t}function xC(e){return typeof e==`bigint`?e:Math.floor(e)}function SC(e,t){if(t===pC)throw jC();let n=Object.create(AC.prototype);n.s=e{t[e]=(t[e]||pC)+mC};for(;e%hC===pC;)n(hC),e/=hC;for(;e%gC===pC;)n(gC),e/=gC;for(;e%_C===pC;)n(_C),e/=_C;for(let t=0,r=hC+_C;r*r<=e;){for(;e%r===pC;)n(r),e/=r;r+=CC[t],t=t+1&7}return e>mC&&n(e),t}var TC=function(e,t){let n=pC,r=mC,i=mC;if(e!=null)if(t!==void 0){if(typeof e==`bigint`)n=e;else if(isNaN(e))throw MC();else if(e%1!=0)throw NC();else n=BigInt(e);if(typeof t==`bigint`)r=t;else if(isNaN(t))throw MC();else if(t%1!=0)throw NC();else r=BigInt(t);i=n*r}else if(typeof e==`object`){if(`d`in e&&`n`in e)n=BigInt(e.n),r=BigInt(e.d),`s`in e&&(n*=BigInt(e.s));else if(0 in e)n=BigInt(e[0]),1 in e&&(r=BigInt(e[1]));else if(typeof e==`bigint`)n=e;else throw MC();i=n*r}else if(typeof e==`number`){if(isNaN(e))throw MC();if(e<0&&(i=-mC,e=-e),e%1==0)n=BigInt(e);else{let t=1,i=0,a=1,o=1,s=1,c=1e7;for(e>=1&&(t=10**Math.floor(1+Math.log10(e)),e/=t);a<=c&&s<=c;){let t=(i+o)/(a+s);if(e===t){a+s<=c?(n=i+o,r=a+s):s>a?(n=o,r=s):(n=i,r=a);break}else e>t?(i+=o,a+=s):(o+=i,s+=a),a>c?(n=o,r=s):(n=i,r=a)}n=BigInt(n)*BigInt(t),r=BigInt(r)}}else if(typeof e==`string`){let t=0,a=pC,o=pC,s=pC,c=mC,l=mC,u=e.replace(/_/g,``).match(/\d+|./g);if(u===null)throw MC();if(u[t]===`-`?(i=-mC,t++):u[t]===`+`&&t++,u.length===t+1?o=bC(u[t++],i):u[t+1]===`.`||u[t]===`.`?(u[t]!==`.`&&(a=bC(u[t++],i)),t++,(t+1===u.length||u[t+1]===`(`&&u[t+3]===`)`||u[t+1]===`'`&&u[t+3]===`'`)&&(o=bC(u[t],i),c=vC**BigInt(u[t].length),t++),(u[t]===`(`&&u[t+2]===`)`||u[t]===`'`&&u[t+2]===`'`)&&(s=bC(u[t+1],i),l=vC**BigInt(u[t+1].length)-mC,t+=3)):u[t+1]===`/`||u[t+1]===`:`?(o=bC(u[t],i),c=bC(u[t+2],mC),t+=3):u[t+3]===`/`&&u[t+1]===` `&&(a=bC(u[t],i),o=bC(u[t+2],i),c=bC(u[t+4],mC),t+=5),u.length<=t)r=c*l,i=n=s+r*a+l*o;else throw MC()}else if(typeof e==`bigint`)n=e,i=e,r=mC;else throw MC();if(r===pC)throw jC();$.s=ipC;e=e*e%n,t>>=mC)t&mC&&(r=r*e%n);return r}function DC(e,t){for(;t%hC===pC;t/=hC);for(;t%_C===pC;t/=_C);if(t===mC)return pC;let n=vC%t,r=1;for(;n!==mC;r++)if(n=n*vC%t,r>yC)return pC;return BigInt(r)}function OC(e,t,n){let r=mC,i=EC(vC,n,t);for(let e=0;e<300;e++){if(r===i)return BigInt(e);r=r*vC%t,i=i*vC%t}return 0}function kC(e,t){if(!e)return t;if(!t)return e;for(;;){if(e%=t,!e)return t;if(t%=e,!t)return e}}function AC(e,t){if(TC(e,t),this instanceof AC)e=kC($.d,$.n),this.s=$.s,this.n=$.n/e,this.d=$.d/e;else return SC($.s*$.n,$.d)}var jC=function(){return Error(`Division by Zero`)},MC=function(){return Error(`Invalid argument`)},NC=function(){return Error(`Parameters must be integer`)};AC.prototype={s:mC,n:pC,d:mC,abs:function(){return SC(this.n,this.d)},neg:function(){return SC(-this.s*this.n,this.d)},add:function(e,t){return TC(e,t),SC(this.s*this.n*$.d+$.s*this.d*$.n,this.d*$.d)},sub:function(e,t){return TC(e,t),SC(this.s*this.n*$.d-$.s*this.d*$.n,this.d*$.d)},mul:function(e,t){return TC(e,t),SC(this.s*$.s*this.n*$.n,this.d*$.d)},div:function(e,t){return TC(e,t),SC(this.s*$.s*this.n*$.d,this.d*$.n)},clone:function(){return SC(this.s*this.n,this.d)},mod:function(e,t){if(e===void 0)return SC(this.s*this.n%this.d,mC);if(TC(e,t),pC===$.n*this.d)throw jC();return SC(this.s*($.d*this.n)%($.n*this.d),$.d*this.d)},gcd:function(e,t){return TC(e,t),SC(kC($.n,this.n)*kC($.d,this.d),$.d*this.d)},lcm:function(e,t){return TC(e,t),$.n===pC&&this.n===pC?SC(pC,mC):SC($.n*this.n,kC($.n,this.n)*kC($.d,this.d))},inverse:function(){return SC(this.s*this.d,this.n)},pow:function(e,t){if(TC(e,t),$.d===mC)return $.s$.s*$.n*this.d},gte:function(e,t){return TC(e,t),this.s*this.n*$.d>=$.s*$.n*this.d},compare:function(e,t){TC(e,t);let n=this.s*this.n*$.d-$.s*$.n*this.d;return(pCpC&&this.s>=pC?mC:pC),e)},floor:function(e){return e=vC**BigInt(e||0),SC(xC(this.s*e*this.n/this.d)-(e*this.n%this.d>pC&&this.s=pC?mC:pC)+hC*(e*this.n%this.d)>this.d?mC:pC),e)},roundTo:function(e,t){TC(e,t);let n=this.n*$.d,r=this.d*$.n,i=n%r,a=xC(n/r);return i+i>=r&&a++,SC(this.s*a*$.n,$.d)},divisible:function(e,t){return TC(e,t),$.n===pC?!1:this.n*$.d%($.n*this.d)===pC},valueOf:function(){return Number(this.s*this.n)/Number(this.d)},toString:function(e=15){let t=this.n,n=this.d,r=DC(t,n),i=OC(t,n,r),a=this.spC&&(r+=i,r+=` `,t%=n),r+=t,r+=`/`,r+=n}return r},toLatex:function(e=!1){let t=this.n,n=this.d,r=this.spC&&(r+=i,t%=n),r+=`\\frac{`,r+=t,r+=`}{`,r+=n,r+=`}`}return r},toContinued:function(){let e=this.n,t=this.d,n=[];for(;t;){n.push(xC(e/t));let r=e%t;e=t,t=r}return n},simplify:function(e=.001){let t=BigInt(Math.ceil(1/e)),n=this.abs(),r=n.toContinued();for(let e=1;e=0;t--)i=i.inverse().add(r[t]);let a=i.sub(n);if(a.n*t(Object.defineProperty(AC,"name",{value:`Fraction`}),AC.prototype.constructor=AC,AC.prototype.type=`Fraction`,AC.prototype.isFraction=!0,AC.prototype.toJSON=function(){return{mathjs:`Fraction`,n:String(this.s*this.n),d:String(this.d)}},AC.fromJSON=function(e){return new AC(e)},AC),{isClass:!0}),FC=Y(`Range`,[],()=>{function e(t,n,r){if(!(this instanceof e))throw SyntaxError(`Constructor must be called with the new operator`);var i=t!=null,a=n!=null,o=r!=null;if(i){if(Ey(t))t=t.toNumber();else if(typeof t!=`number`&&!Dy(t))throw TypeError(`Parameter start must be a number or bigint`)}if(a){if(Ey(n))n=n.toNumber();else if(typeof n!=`number`&&!Dy(n))throw TypeError(`Parameter end must be a number or bigint`)}if(o){if(Ey(r))r=r.toNumber();else if(typeof r!=`number`&&!Dy(r))throw TypeError(`Parameter step must be a number or bigint`)}if(this.start=i?parseFloat(t):0,this.end=a?parseFloat(n):0,this.step=o?parseFloat(r):1,o&&$b(this.step,0))throw Error(`Step must not be zero`)}return e.prototype.type=`Range`,e.prototype.isRange=!0,e.parse=function(t){if(typeof t!=`string`)return null;var n=t.split(`:`).map(function(e){return parseFloat(e)});if(n.some(function(e){return isNaN(e)}))return null;switch(n.length){case 2:return new e(n[0],n[1]);case 3:return new e(n[0],n[2],n[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,n=this.step,r=this.end-t;return Ib(n)===Ib(r)?e=Math.ceil(r/n):r===0&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start:this.start+(e-1)*this.step},e.prototype.max=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start+(e-1)*this.step:this.start},e.prototype.forEach=function(e){var t=this.start,n=this.step,r=this.end,i=0;if(n>0)for(;tr;)e(t,[i],this),t+=n,i++},e.prototype.map=function(e){var t=[];return this.forEach(function(n,r,i){t[r[0]]=e(n,r,i)}),t},e.prototype.toArray=function(){var e=[];return this.forEach(function(t,n){e[n[0]]=t}),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=Ub(this.start,e);return this.step!==1&&(t+=`:`+Ub(this.step,e)),t+=`:`+Ub(this.end,e),t},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:`Range`,start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e},{isClass:!0}),IC=Y(`Matrix`,[],()=>{function e(){if(!(this instanceof e))throw SyntaxError(`Constructor must be called with the new operator`)}return e.prototype.type=`Matrix`,e.prototype.isMatrix=!0,e.prototype.storage=function(){throw Error(`Cannot invoke storage on a Matrix interface`)},e.prototype.datatype=function(){throw Error(`Cannot invoke datatype on a Matrix interface`)},e.prototype.create=function(e,t){throw Error(`Cannot invoke create on a Matrix interface`)},e.prototype.subset=function(e,t,n){throw Error(`Cannot invoke subset on a Matrix interface`)},e.prototype.get=function(e){throw Error(`Cannot invoke get on a Matrix interface`)},e.prototype.set=function(e,t,n){throw Error(`Cannot invoke set on a Matrix interface`)},e.prototype.resize=function(e,t){throw Error(`Cannot invoke resize on a Matrix interface`)},e.prototype.reshape=function(e,t){throw Error(`Cannot invoke reshape on a Matrix interface`)},e.prototype.clone=function(){throw Error(`Cannot invoke clone on a Matrix interface`)},e.prototype.size=function(){throw Error(`Cannot invoke size on a Matrix interface`)},e.prototype.map=function(e,t){throw Error(`Cannot invoke map on a Matrix interface`)},e.prototype.forEach=function(e){throw Error(`Cannot invoke forEach on a Matrix interface`)},e.prototype[Symbol.iterator]=function(){throw Error(`Cannot iterate a Matrix interface`)},e.prototype.toArray=function(){throw Error(`Cannot invoke toArray on a Matrix interface`)},e.prototype.valueOf=function(){throw Error(`Cannot invoke valueOf on a Matrix interface`)},e.prototype.format=function(e){throw Error(`Cannot invoke format on a Matrix interface`)},e.prototype.toString=function(){throw Error(`Cannot invoke toString on a Matrix interface`)},e},{isClass:!0});function LC(e,t,n){var r=e.constructor,i=new r(2),a=``;if(n){if(n<1)throw Error(`size must be in greater than 0`);if(!X(n))throw Error(`size must be an integer`);if(e.greaterThan(i.pow(n-1).sub(1))||e.lessThan(i.pow(n-1).mul(-1)))throw Error(`Value must be in range [-2^${n-1}, 2^${n-1}-1]`);if(!e.isInteger())throw Error(`Value must be an integer`);e.lessThan(0)&&(e=e.add(i.pow(n))),a=`i${n}`}switch(t){case 2:return`${e.toBinary()}${a}`;case 8:return`${e.toOctal()}${a}`;case 16:return`${e.toHexadecimal()}${a}`;default:throw Error(`Base ${t} not supported `)}}function RC(e,t){if(typeof t==`function`)return t(e);if(!e.isFinite())return e.isNaN()?`NaN`:e.gt(0)?`Infinity`:`-Infinity`;var{notation:n,precision:r,wordSize:i}=Wb(t);switch(n){case`fixed`:return VC(e,r);case`exponential`:return BC(e,r);case`engineering`:return zC(e,r);case`bin`:return LC(e,2,i);case`oct`:return LC(e,8,i);case`hex`:return LC(e,16,i);case`auto`:var a=HC(t?.lowerExp,-3),o=HC(t?.upperExp,5);if(e.isZero())return`0`;var s,c=e.toSignificantDigits(r),l=c.e;return s=l>=a&&l=0?`+`:``)+r.toString()}function BC(e,t){return t===void 0?e.toExponential():e.toExponential(t-1)}function VC(e,t){return e.toFixed(t)}function HC(e,t){return Ty(e)?e:Ey(e)?e.toNumber():t}function UC(e,t){var n=e.length-t.length,r=e.length;return e.substring(n,r)===t}function WC(e,t){var n=GC(e,t);return t&&typeof t==`object`&&`truncate`in t&&n.length>t.truncate?n.substring(0,t.truncate-3)+`...`:n}function GC(e,t){return typeof e==`number`?Ub(e,t):Ey(e)?RC(e,t):XC(e)?!t||t.fraction!==`decimal`?`${e.s*e.n}/${e.d}`:e.toString():Array.isArray(e)?YC(e,t):jy(e)?KC(e):typeof e==`function`?e.syntax?String(e.syntax):`function`:e&&typeof e==`object`?typeof e.format==`function`?e.format(t):e&&e.toString(t)!=={}.toString()?e.toString(t):`{`+Object.keys(e).map(n=>KC(n)+`: `+WC(e[n],t)).join(`, `)+`}`:String(e)}function KC(e){for(var t=String(e),n=``,r=0;r/g,`>`),t}function YC(e,t){if(Array.isArray(e)){for(var n=`[`,r=e.length,i=0;it?1:-1}function QC(e,t,n){if(!(this instanceof QC))throw SyntaxError(`Constructor must be called with the new operator`);this.actual=e,this.expected=t,this.relation=n,this.message=`Dimension mismatch (`+(Array.isArray(e)?`[`+e.join(`, `)+`]`:e)+` `+(this.relation||`!=`)+` `+(Array.isArray(t)?`[`+t.join(`, `)+`]`:t)+`)`,this.stack=Error().stack}QC.prototype=RangeError(),QC.prototype.constructor=RangeError,QC.prototype.name=`DimensionError`,QC.prototype.isDimensionError=!0;function $C(e,t,n){if(!(this instanceof $C))throw SyntaxError(`Constructor must be called with the new operator`);this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=n),this.min!==void 0&&this.index=this.max?this.message=`Index out of range (`+this.index+` > `+(this.max-1)+`)`:this.message=`Index out of range (`+this.index+`)`,this.stack=Error().stack}$C.prototype=RangeError(),$C.prototype.constructor=RangeError,$C.prototype.name=`IndexError`,$C.prototype.isIndexError=!0;function ew(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function tw(e,t,n){var r,i=e.length;if(i!==t[n])throw new QC(i,t[n]);if(n`)}function nw(e,t){if(t.length===0){if(Array.isArray(e))throw new QC(e.length,0)}else tw(e,t,0)}function rw(e,t){var n=e.isMatrix?e._size:ew(e);t._sourceSize.forEach((e,t)=>{if(e!==null&&e!==n[t])throw new QC(e,n[t])})}function iw(e,t){if(e!==void 0){if(!Ty(e)||!X(e))throw TypeError(`Index must be an integer (value: `+e+`)`);if(e<0||typeof t==`number`&&e>=t)throw new $C(e,t)}}function aw(e){for(var t=0;t=0)throw Error(`More than one wildcard in sizes`);var o=a>=0,s=t%n===0;if(o)if(s)r[a]=-t/n;else throw Error(`Could not replace wildcard, since `+t+` is no multiple of `+-n);return r}function uw(e){return e.reduce((e,t)=>e*t,1)}function dw(e,t){for(var n=e,r,i=t.length-1;i>0;i--){var a=t[i];r=[];for(var o=n.length/a,s=0;s1&&arguments[1]!==void 0?arguments[1]:!1;if(!Array.isArray(e))return e;if(typeof t!=`boolean`)throw TypeError(`Boolean expected for second argument of flatten`);var n=[];return t?i(e):r(e),n;function r(e){for(var t=0;tt.test(e))}function xw(e,t){return Array.prototype.join.call(e,t)}function Sw(e){if(!Array.isArray(e))throw TypeError(`Array input expected`);if(e.length===0)return e;var t=[],n=0;t[0]={value:e[0],identifier:0};for(var r=1;r1)return e.slice(1).reduce(function(e,n){return Tw(e,n,t,0)},e[0]);throw Error(`Wrong number of arguments in function concat`)}function Dw(){for(var e=arguments.length,t=Array(e),n=0;ne.length),i=Math.max(...r),a=Array(i).fill(null),o=0;oa[u]&&(a[u]=s[l])}for(var d=0;d1||e[i]>t[a])throw Error(`shape mismatch: mismatch is found in arg with shape (${e}) not possible to broadcast dimension ${r} with size ${e[i]} to size ${t[a]}`)}}function kw(e,t){var n=ew(e);if(bb(n,t))return e;Ow(n,t);var r=Dw(n,t),i=r.length,a=[...Array(i-n.length).fill(1),...n],o=Pw(e);n.lengthe[t],e)}function Mw(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e.length===0)return[];if(n)return a(e);var r=[];return i(e,0);function i(n,a){if(Array.isArray(n)){for(var o=n.length,s=Array(o),c=0;c2&&arguments[2]!==void 0?arguments[2]:!1;if(e.length===0)return;if(n){a(e);return}var r=[];i(e,0);function i(n,a){if(Array.isArray(n))for(var o=n.length,s=0;s0);i=Rw(e,t.isMatrix?t.get(o):jw(t,o),o,t)}var s;if(t.isMatrix&&t.dataType!==`mixed`&&t.dataType!==void 0){var c=Iw(e,i);s=c===void 0?e:c}else s=e;return i>=1&&i<=3?{isUnary:i===1,fn:function(){for(var t=arguments.length,r=Array(t),a=0;a{var[r,i]=e;r.split(`,`).length===t&&n.push(i)}),n.length===1)return n[0]}function Lw(e){if(e.length!==1)return!1;var t=e.toString();if(/arguments/.test(t))return!1;var n=t.match(/\(.*?\)/);return!/\.\.\./.test(n)}function Rw(e,t,n,r){for(var i=[t,n,r],a=3;a>0;a--){var o=i.slice(0,a);if(lx.default.resolve(e,o)!==null)return a}}function zw(e,t,n,r){try{return e(...t)}catch(e){Bw(e,t,n,r)}}function Bw(e,t,n,r){if(e instanceof TypeError&&e.data?.category===`wrongType`){var i=[];throw i.push(`value: ${hb(t[0])}`),t.length>=2&&i.push(`index: ${hb(t[1])}`),t.length>=3&&i.push(`array: ${hb(t[2])}`),TypeError(`Function ${n} cannot apply callback arguments ${r}(${i.join(`, `)}) at index ${JSON.stringify(t[1])}`)}else throw TypeError(`Function ${n} cannot apply callback arguments to function ${r}: ${e.message}`)}var Vw=Y(`DenseMatrix`,[`Matrix`,`config`],e=>{var{Matrix:t,config:n}=e;function r(e,t){if(!(this instanceof r))throw SyntaxError(`Constructor must be called with the new operator`);if(t&&!jy(t))throw Error(`Invalid datatype: `+t);if(Ny(e))e.type===`DenseMatrix`?(this._data=gb(e._data),this._size=gb(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&My(e.data)&&My(e.size))this._data=e.data,this._size=e.size,nw(this._data,this._size),this._datatype=t||e.datatype;else if(My(e))this._data=u(e),this._size=ew(this._data),nw(this._data,this._size),this._datatype=t;else if(e)throw TypeError(`Unsupported type of data (`+hb(e)+`)`);else this._data=[],this._size=[0],this._datatype=t}r.prototype=new t,r.prototype.createDenseMatrix=function(e,t){return new r(e,t)},Object.defineProperty(r,"name",{value:`DenseMatrix`}),r.prototype.constructor=r,r.prototype.type=`DenseMatrix`,r.prototype.isDenseMatrix=!0,r.prototype.getDataType=function(){return ww(this._data,hb)},r.prototype.storage=function(){return`dense`},r.prototype.datatype=function(){return this._datatype},r.prototype.create=function(e,t){return new r(e,t)},r.prototype.subset=function(e,t,n){switch(arguments.length){case 1:return i(this,e);case 2:case 3:return o(this,e,t,n);default:throw SyntaxError(`Wrong number of arguments`)}},r.prototype.get=function(e){return jw(this._data,e)},r.prototype.set=function(e,t,n){if(!My(e))throw TypeError(`Array expected`);if(e.lengthe===1):t.isScalar())return e.get(t.min());var i=t.size();if(i.length!==e._size.length)throw new QC(i.length,e._size.length);for(var o=t.min(),s=t.max(),c=0,l=e._size.length;ce!==null)};function i(e){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=t.dimension(a);function s(e,t){return Ty(e)?t(e):e.map(t).valueOf()}return Ty(o)?r[a]=null:r[a]=o.size()[0],a(iw(t,e.length),i(e[t],a+1))):s(o,t=>(iw(t,e.length),e[t]))}}function o(e,t,n,r){if(!t||t.isIndex!==!0)throw TypeError(`Invalid index`);var i=t.size(),a=t.isScalar(),o;if(Ny(n)?(o=n.size(),n=n.valueOf()):o=ew(n),a){if(o.length!==0)throw TypeError(`Scalar expected`);e.set(t.min(),n,r)}else{if(!bb(o,i)){if(o.length===0)n=kw([n],i);else try{n=kw(n,i)}catch{}o=ew(n)}if(i.length`);l(e,t.max().map(function(e){return e+1}),r),s(e._data,t,n)}return e}function s(e,t,n){var r=t.size().length-1;i(e,n);function i(e,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,o=t.dimension(a),s=(t,r)=>{iw(t,e.length),i(e[t],n[r[0]],a+1)},c=(t,r)=>{iw(t,e.length),e[t]=n[r[0]]};aArray.isArray(e)&&e.length===1?e[0]:e);return c(n?this.clone():this,r,t)};function c(e,t,n){if(t.length===0){for(var r=e._data;My(r);)r=r[0];return r}return e._size=t.slice(0),e._data=ow(e._data,e._size,n),e}r.prototype.reshape=function(e,t){var n=t?this.clone():this;return n._data=cw(n._data,e),n._size=lw(e,n._size.reduce((e,t)=>e*t)),n};function l(e,t,n){for(var r=e._size.slice(0),i=!1;r.lengthr[a]&&(r[a]=t[a],i=!0);i&&c(e,r,n)}r.prototype.clone=function(){return new r({data:gb(this._data),size:gb(this._size),datatype:this._datatype})},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(e){arguments.length>1&&arguments[1]!==void 0&&arguments[1];var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=this,r=n._size.length-1;if(r<0)return n.clone();var i=Fw(e,n,`map`,t),a=i.fn,o=n.create(void 0,n._datatype);if(o._size=n._size,t||i.isUnary)return o._data=f(n._data),o;if(r===0){for(var s=n.valueOf(),c=Array(s.length),l=0;l1&&arguments[1]!==void 0?arguments[1]:0,i=Array(e.length);if(t1&&arguments[1]!==void 0?arguments[1]:0,n=Array(e.length);if(t1&&arguments[1]!==void 0&&arguments[1];var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=this,r=n._size.length-1;if(r<0)return;var i=Fw(e,n,`map`,t),a=i.fn;if(t||i.isUnary){l(n._data);return}if(r===0){for(var o=0;o1&&arguments[1]!==void 0?arguments[1]:0;if(t1&&arguments[1]!==void 0?arguments[1]:0;if(te*t,1),i=0;i=0&&(n[s]++,!(n[s][e[n]]);t.push(new r(a,e._datatype))},o=0;o0?e:0,n=e<0?-e:0,i=this._size[0],a=this._size[1],o=Math.min(i-n,a-t),s=[],c=0;c0?n:0,o=n<0?-n:0,s=e[0],c=e[1],l=Math.min(s-o,c-a),u;if(My(t)){if(t.length!==l)throw Error(`Invalid value array length`);u=function(e){return t[e]}}else if(Ny(t)){var d=t.size();if(d.length!==1||d[0]!==l)throw Error(`Invalid matrix length`);u=function(e){return t.get([e])}}else u=function(){return t};i||=Ey(u(0))?u(0).mul(0):0;var f=[];if(e.length>0){f=ow(f,e,i);for(var p=0;p{var{typed:t}=e;return t(Hw,{any:gb})});function Ww(e){var t=e.length,n=e[0].length,r,i,a=[];for(i=0;it(e),!1,!0):Nw(e,t,!0)}function qw(e,t,n){if(!n)return Ny(e)?e.map(e=>t(e),!1,!0):Mw(e,t,!0);var r=e=>e===0?e:t(e);return Ny(e)?e.map(e=>r(e),!1,!0):Mw(e,r,!0)}function Jw(e,t,n){var r=Array.isArray(e)?ew(e):e.size();if(t<0||t>=r.length)throw new $C(t,r.length);return Ny(e)?e.create(Yw(e.valueOf(),t,n),e.datatype()):Yw(e,t,n)}function Yw(e,t,n){var r,i,a,o;if(t<=0)if(Array.isArray(e[0])){for(o=Ww(e),i=[],r=0;r{var{typed:t,equal:n}=e;return t(Zw,{number:e=>Number.isFinite(e)?n(e,Math.round(e)):!1,BigNumber:e=>e.isFinite()?n(e.round(),e):!1,bigint:e=>!0,Fraction:e=>e.d===1n,"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),$w=`number`,eT=`number, number`;function tT(e){return Math.abs(e)}tT.signature=$w;function nT(e,t){return e+t}nT.signature=eT;function rT(e,t){return e-t}rT.signature=eT;function iT(e,t){return e*t}iT.signature=eT;function aT(e,t){return e/t}aT.signature=eT;function oT(e){return-e}oT.signature=$w;function sT(e){return e}sT.signature=$w;function cT(e){return Bb(e)}cT.signature=$w;function lT(e){return e*e*e}lT.signature=$w;function uT(e){return Math.exp(e)}uT.signature=$w;function dT(e){return Vb(e)}dT.signature=$w;function fT(e,t){if(!X(e)||!X(t))throw Error(`Parameters in function gcd must be integer numbers`);for(var n;t!==0;)n=e%t,e=t,t=n;return e<0?-e:e}fT.signature=eT;function pT(e,t){if(!X(e)||!X(t))throw Error(`Parameters in function lcm must be integer numbers`);if(e===0||t===0)return 0;for(var n,r=e*t;t!==0;)n=t,t=e%n,e=n;return Math.abs(r/e)}pT.signature=eT;function mT(e,t){return t?Math.log(e)/Math.log(t):Math.log(e)}function hT(e){return Rb(e)}hT.signature=$w;function gT(e){return Lb(e)}gT.signature=$w;function _T(e){return zb(e)}_T.signature=$w;function vT(e,t){return t===0?e:e-t*Math.floor(e/t)}vT.signature=eT;function yT(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,n=t<0;if(n&&(t=-t),t===0)throw Error(`Root must be non-zero`);if(e<0&&Math.abs(t)%2!=1)throw Error(`Root must be odd when a is negative.`);if(e===0)return n?1/0:0;if(!isFinite(e))return n?0:e;var r=Math.abs(e)**(1/t);return r=e<0?-r:r,n?1/r:r}function bT(e){return Ib(e)}bT.signature=$w;function xT(e){return Math.sqrt(e)}xT.signature=$w;function ST(e){return e*e}ST.signature=$w;function CT(e,t){var n,r,i,a=0,o=1,s=1,c=0;if(!X(e)||!X(t))throw Error(`Parameters in function xgcd must be integer numbers`);for(;t;)r=Math.floor(e/t),i=e-r*t,n=a,a=o-r*a,o=n,n=s,s=c-r*s,c=n,e=t,t=i;return e<0?[-e,-o,-c]:[e,e?o:0,c]}CT.signature=eT;function wT(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:e**+t}wT.signature=eT;function TT(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!X(t)||t<0||t>15)throw Error(`Number of decimals in function round must be an integer from 0 to 15 inclusive`);return parseFloat(qb(e,t))}function ET(e){return Math.abs(e)}ET.signature=$w;var DT=`number`,OT=`number, number`;function kT(e,t){if(!X(e)||!X(t))throw Error(`Integers expected in function bitAnd`);return e&t}kT.signature=OT;function AT(e){if(!X(e))throw Error(`Integer expected in function bitNot`);return~e}AT.signature=DT;function jT(e,t){if(!X(e)||!X(t))throw Error(`Integers expected in function bitOr`);return e|t}jT.signature=OT;function MT(e,t){if(!X(e)||!X(t))throw Error(`Integers expected in function bitXor`);return e^t}MT.signature=OT;function NT(e,t){if(!X(e)||!X(t))throw Error(`Integers expected in function leftShift`);return e<>t}PT.signature=OT;function FT(e,t){if(!X(e)||!X(t))throw Error(`Integers expected in function rightLogShift`);return e>>>t}FT.signature=OT;function IT(e,t){if(t>1;return IT(e,n)*IT(n+1,t)}function LT(e,t){if(!X(e)||e<0||!X(t)||t<0)throw TypeError(`Positive integer value expected in function combinations`);if(t>e)throw TypeError(`k must be less than or equal to n`);for(var n=e-t,r=1,i=t171?1/0:IT(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*JT(1-e));if(e>=171.35)return 1/0;if(e>85){var n=e*e,r=n*e,i=r*e,a=i*e;return Math.sqrt(2*Math.PI/e)*(e/Math.E)**+e*(1+1/(12*e)+1/(288*n)-139/(51840*r)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,t=XT[0];for(var o=1;o=1;r--)n+=QT[r]/(e+r);return ZT+(e+.5)*Math.log(t)-t+Math.log(n)}$T.signature=`number`;var eE=`number`,tE=`number, number`;function nE(e){return Math.acos(e)}nE.signature=eE;function rE(e){return ex(e)}rE.signature=eE;function iE(e){return Math.atan(1/e)}iE.signature=eE;function aE(e){return Number.isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}aE.signature=eE;function oE(e){return Math.asin(1/e)}oE.signature=eE;function sE(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}sE.signature=eE;function cE(e){return Math.acos(1/e)}cE.signature=eE;function lE(e){var t=1/e,n=Math.sqrt(t*t-1);return Math.log(n+t)}lE.signature=eE;function uE(e){return Math.asin(e)}uE.signature=eE;function dE(e){return tx(e)}dE.signature=eE;function fE(e){return Math.atan(e)}fE.signature=eE;function pE(e,t){return Math.atan2(e,t)}pE.signature=tE;function mE(e){return nx(e)}mE.signature=eE;function hE(e){return Math.cos(e)}hE.signature=eE;function gE(e){return rx(e)}gE.signature=eE;function _E(e){return 1/Math.tan(e)}_E.signature=eE;function vE(e){var t=Math.exp(2*e);return(t+1)/(t-1)}vE.signature=eE;function yE(e){return 1/Math.sin(e)}yE.signature=eE;function bE(e){return e===0?1/0:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*Ib(e)}bE.signature=eE;function xE(e){return 1/Math.cos(e)}xE.signature=eE;function SE(e){return 2/(Math.exp(e)+Math.exp(-e))}SE.signature=eE;function CE(e){return Math.sin(e)}CE.signature=eE;function wE(e){return ix(e)}wE.signature=eE;function TE(e){return Math.tan(e)}TE.signature=eE;function EE(e){return ax(e)}EE.signature=eE;var DE=`number`;function OE(e){return X(e)}OE.signature=DE;function kE(e){return e<0}kE.signature=DE;function AE(e){return e>0}AE.signature=DE;function jE(e){return e===0}jE.signature=DE;function ME(e){return Number.isNaN(e)}ME.signature=DE;function NE(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-9,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(n<=0)throw Error(`Relative tolerance must be greater than 0`);if(r<0)throw Error(`Absolute tolerance must be at least 0`);return e.isNaN()||t.isNaN()?!1:!e.isFinite()||!t.isFinite()?e.eq(t):e.eq(t)?!0:e.minus(t).abs().lte(e.constructor.max(e.constructor.max(e.abs(),t.abs()).mul(n),r))}var PE=`isNegative`,FE=Y(PE,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(PE,{number:e=>$b(e,0,n.relTol,n.absTol)?!1:kE(e),BigNumber:e=>NE(e,new e.constructor(0),n.relTol,n.absTol)?!1:e.isNeg()&&!e.isZero()&&!e.isNaN(),bigint:e=>e<0n,Fraction:e=>e.s<0n,Unit:t.referToSelf(e=>n=>t.find(e,n.valueType())(n.value)),"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),IE=`isNumeric`,LE=Y(IE,[`typed`],e=>{var{typed:t}=e;return t(IE,{"number | BigNumber | bigint | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),RE=`hasNumericValue`,zE=Y(RE,[`typed`,`isNumeric`],e=>{var{typed:t,isNumeric:n}=e;return t(RE,{boolean:()=>!0,string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return n(e)}})}),BE=`isPositive`,VE=Y(BE,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(BE,{number:e=>$b(e,0,n.relTol,n.absTol)?!1:AE(e),BigNumber:e=>NE(e,new e.constructor(0),n.relTol,n.absTol)?!1:!e.isNeg()&&!e.isZero()&&!e.isNaN(),bigint:e=>e>0n,Fraction:e=>e.s>0n&&e.n>0n,Unit:t.referToSelf(e=>n=>t.find(e,n.valueType())(n.value)),"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),HE=`isZero`,UE=Y(HE,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return t(HE,{"number | BigNumber | Complex | Fraction":e=>n(e,0),bigint:e=>e===0n,Unit:t.referToSelf(e=>n=>t.find(e,n.valueType())(n.value)),"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),WE=`isNaN`,GE=Y(WE,[`typed`],e=>{var{typed:t}=e;return t(WE,{number:ME,BigNumber:function(e){return e.isNaN()},bigint:function(e){return!1},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),KE=`isBounded`,qE=Y(KE,[`typed`],e=>{var{typed:t}=e;return t(KE,{number:e=>Number.isFinite(e),"BigNumber | Complex":e=>e.isFinite(),"bigint | Fraction":()=>!0,"null | undefined":()=>!1,Unit:t.referToSelf(e=>t=>e(t.value)),"Array | Matrix":t.referToSelf(e=>t=>(Array.isArray(t)||(t=t.valueOf()),t.every(t=>e(t))))})}),JE=`isFinite`,YE=Y(JE,[`typed`,`isBounded`,`map`],e=>{var{typed:t,isBounded:n,map:r}=e;return t(JE,{"Array | Matrix":e=>r(e,n),any:e=>n(e)})}),XE=`typeOf`,ZE=Y(XE,[`typed`],e=>{var{typed:t}=e;return t(XE,{any:hb})});function QE(e,t,n,r){return $b(e.re,t.re,n,r)&&$b(e.im,t.im,n,r)}var $E=Y(`compareUnits`,[`typed`],e=>{var{typed:t}=e;return{"Unit, Unit":t.referToSelf(e=>(n,r)=>{if(!n.equalBase(r))throw Error(`Cannot compare units with different base`);return t.find(e,[n.valueType(),r.valueType()])(n.value,r.value)})}}),eD=`equalScalar`,tD=Y(eD,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(eD,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return $b(e,t,n.relTol,n.absTol)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||NE(e,t,n.relTol,n.absTol)},"bigint, bigint":function(e,t){return e===t},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return QE(e,t,n.relTol,n.absTol)}},$E({typed:t}))});Y(eD,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(eD,{"number, number":function(e,t){return $b(e,t,n.relTol,n.absTol)}})});var nD=Y(`SparseMatrix`,[`typed`,`equalScalar`,`Matrix`],e=>{var{typed:t,equalScalar:n,Matrix:r}=e;function i(e,t){if(!(this instanceof i))throw SyntaxError(`Constructor must be called with the new operator`);if(t&&!jy(t))throw Error(`Invalid datatype: `+t);if(Ny(e))a(this,e,t);else if(e&&My(e.index)&&My(e.ptr)&&My(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(My(e))o(this,e,t);else if(e)throw TypeError(`Unsupported type of data (`+hb(e)+`)`);else this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}function a(e,t,n){t.type===`SparseMatrix`?(e._values=t._values?gb(t._values):void 0,e._index=gb(t._index),e._ptr=gb(t._ptr),e._size=gb(t._size),e._datatype=n||t._datatype):o(e,t.valueOf(),n||t._datatype)}function o(e,r,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var a=r.length,o=0,s=n,c=0;if(jy(i)&&(s=t.find(n,[i,i])||n,c=t.convert(0,i)),a>0){var l=0;do{e._ptr.push(e._index.length);for(var u=0;u`);if(i.length===1)d(t.dimension(0),(t,i)=>{iw(t),e.set([t,0],n[i[0]],r)});else{var l=t.dimension(0),u=t.dimension(1);d(l,(t,i)=>{iw(t),d(u,(a,o)=>{iw(a),e.set([t,a],n[i[0]][o[0]],r)})})}}return e;function d(e,t){Ty(e)?t(e,[0]):e.forEach(t)}}i.prototype.get=function(e){if(!My(e))throw TypeError(`Array expected`);if(e.length!==this._size.length)throw new QC(e.length,this._size.length);if(!this._values)throw Error(`Cannot invoke get on a Pattern only matrix`);var t=e[0],n=e[1];iw(t,this._size[0]),iw(n,this._size[1]);var r=l(t,this._ptr[n],this._ptr[n+1],this._index);return rs-1||o>c-1)&&(f(this,Math.max(a+1,s),Math.max(o+1,c),i),s=this._size[0],c=this._size[1]),iw(a,s),iw(o,c);var h=l(a,this._ptr[o],this._ptr[o+1],this._index);return hArray.isArray(e)&&e.length===1?e[0]:e);if(r.length!==2)throw Error(`Only two dimensions matrix are supported`);return r.forEach(function(e){if(!Ty(e)||!X(e)||e<0)throw TypeError(`Invalid size, must contain positive integers (size: `+WC(r)+`)`)}),f(n?this.clone():this,r[0],r[1],t)};function f(e,r,i,a){var o=a||0,s=n,c=0;jy(e._datatype)&&(s=t.find(n,[e._datatype,e._datatype])||n,c=t.convert(0,e._datatype),o=t.convert(o,e._datatype));var l=!s(o,c),u=e._size[0],d=e._size[1],f,p,m;if(i>d){for(p=d;pu){if(l){var h=0;for(p=0;pr-1&&(e._values.splice(m,1),e._index.splice(m,1),_++)}e._ptr[p]=e._values.length}return e._size[0]=r,e._size[1]=i,e}i.prototype.reshape=function(e,t){if(!My(e))throw TypeError(`Array expected`);if(e.length!==2)throw Error(`Sparse matrices can only be reshaped in two dimensions`);e.forEach(function(t){if(!Ty(t)||!X(t)||t<=-2||t===0)throw TypeError(`Invalid size, must contain positive integers or -1 (size: `+WC(e)+`)`)});var n=this._size[0]*this._size[1];if(e=lw(e,n),n!==e[0]*e[1])throw Error(`Reshaping sparse matrix will result in the wrong number of elements`);var r=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return r;for(var i=[],a=0;a=r&&b<=a&&h(e._values[y],b-r,g-o)}else{for(var x={},S=_;S `+(this._values?WC(this._values[c],e):`X`)}return i},i.prototype.toString=function(){return WC(this.toArray())},i.prototype.toJSON=function(){return{mathjs:`SparseMatrix`,values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},i.prototype.diagonal=function(e){if(e){if(Ey(e)&&(e=e.toNumber()),!Ty(e)||!X(e))throw TypeError(`The parameter k must be an integer number`)}else e=0;var t=e>0?e:0,n=e<0?-e:0,r=this._size[0],a=this._size[1],o=Math.min(r-n,a-t),s=[],c=[],l=[];l[0]=0;for(var u=t;u0?a:0,d=a<0?-a:0,f=e[0],p=e[1],m=Math.min(f-d,p-u),h;if(My(r)){if(r.length!==m)throw Error(`Invalid value array length`);h=function(e){return r[e]}}else if(Ny(r)){var g=r.size();if(g.length!==1||g[0]!==m)throw Error(`Invalid matrix length`);h=function(e){return r.get([e])}}else h=function(){return r};for(var _=[],v=[],y=[],b=0;b=0&&x=c||i[d]!==t)){var p=r?r[u]:void 0;i.splice(d,0,t),r&&r.splice(d,0,p),i.splice(d<=u?u+1:u,1),r&&r.splice(d<=u?u+1:u,1);continue}if(d=c||i[u]!==e)){var m=r?r[d]:void 0;i.splice(u,0,e),r&&r.splice(u,0,m),i.splice(u<=d?d+1:d,1),r&&r.splice(u<=d?d+1:d,1)}}},i},{isClass:!0}),rD=`number`,iD=[`typed`];function aD(e){var t=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);return t?{input:e,radix:{"0b":2,"0o":8,"0x":16}[t[1]],integerPart:t[2],fractionalPart:t[3]}:null}function oD(e){for(var t=parseInt(e.integerPart,e.radix),n=0,r=0;r{var{typed:t}=e,n=t(`number`,{"":function(){return 0},number:function(e){return e},string:function(e){if(e===`NaN`)return NaN;var t=aD(e);if(t)return oD(t);var n=0,r=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);r&&(n=Number(r[2]),e=r[1]);var i=Number(e);if(isNaN(i))throw SyntaxError(`String "`+e+`" is not a valid number`);if(r){if(i>2**n-1)throw SyntaxError(`String "${e}" is out of range`);i>=2**(n-1)&&(i-=2**n)}return i},BigNumber:function(e){return e.toNumber()},bigint:function(e){return Number(e)},Fraction:function(e){return e.valueOf()},Unit:t.referToSelf(e=>t=>{var n=t.clone();return n.value=e(t.value),n}),null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))});return n.fromJSON=function(e){return parseFloat(e.value)},n}),cD=Y(`bigint`,[`typed`],e=>{var{typed:t}=e,n=t(`bigint`,{"":function(){return 0n},bigint:function(e){return e},number:function(e){return BigInt(e.toFixed())},BigNumber:function(e){return BigInt(e.round().toString())},Fraction:function(e){return BigInt(e.valueOf().toFixed())},"string | boolean":function(e){return BigInt(e)},null:function(e){return 0n},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))});return n.fromJSON=function(e){return BigInt(e.value)},n}),lD=`string`,uD=Y(lD,[`typed`],e=>{var{typed:t}=e;return t(lD,{"":function(){return``},number:Ub,null:function(e){return`null`},boolean:function(e){return e+``},string:function(e){return e},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e)),any:function(e){return String(e)}})}),dD=`boolean`,fD=Y(dD,[`typed`],e=>{var{typed:t}=e;return t(dD,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1;var n=Number(e);if(e!==``&&!isNaN(n))return!!n;throw Error(`Cannot convert "`+e+`" to a boolean`)},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),pD=Y(`bignumber`,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(`bignumber`,{"":function(){return new n(0)},number:function(e){return new n(e+``)},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var r=t[2],i=n(t[1]),a=new n(2).pow(Number(r));if(i.gt(a.sub(1)))throw SyntaxError(`String "${e}" is out of range`);var o=new n(2).pow(Number(r)-1);return i.gte(o)?i.sub(a):i}return new n(e)},BigNumber:function(e){return e},bigint:function(e){return new n(e.toString())},Unit:t.referToSelf(e=>t=>{var n=t.clone();return n.value=e(t.value),n}),Fraction:function(e){return new n(String(e.n)).div(String(e.d)).times(String(e.s))},null:function(e){return new n(0)},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),mD=Y(`complex`,[`typed`,`Complex`],e=>{var{typed:t,Complex:n}=e;return t(`complex`,{"":function(){return n.ZERO},number:function(e){return new n(e,0)},"number, number":function(e,t){return new n(e,t)},"BigNumber, BigNumber":function(e,t){return new n(e.toNumber(),t.toNumber())},Fraction:function(e){return new n(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return n(e)},null:function(e){return n(0)},Object:function(e){if(`re`in e&&`im`in e)return new n(e.re,e.im);if(`r`in e&&`phi`in e||`abs`in e&&`arg`in e)return new n(e);throw Error(`Expected object with properties (re and im) or (r and phi) or (abs and arg)`)},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),hD=Y(`fraction`,[`typed`,`Fraction`],e=>{var{typed:t,Fraction:n}=e;return t(`fraction`,{number:function(e){if(!Number.isFinite(e)||isNaN(e))throw Error(e+` cannot be represented as a fraction`);return new n(e)},string:function(e){return new n(e)},"number, number":function(e,t){return new n(e,t)},"bigint, bigint":function(e,t){return new n(e,t)},null:function(e){return new n(0)},BigNumber:function(e){return new n(e.toString())},bigint:function(e){return new n(e.toString())},Fraction:function(e){return e},Unit:t.referToSelf(e=>t=>{var n=t.clone();return n.value=e(t.value),n}),Object:function(e){return new n(e)},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),gD=`matrix`,_D=Y(gD,[`typed`,`Matrix`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,Matrix:n,DenseMatrix:r,SparseMatrix:i}=e;return t(gD,{"":function(){return a([])},string:function(e){return a([],e)},"string, string":function(e,t){return a([],e,t)},Array:function(e){return a(e)},Matrix:function(e){return a(e,e.storage())},"Array | Matrix, string":a,"Array | Matrix, string, string":a});function a(e,t,n){if(t===`dense`||t==="default"||t===void 0)return new r(e,n);if(t===`sparse`)return new i(e,n);throw TypeError(`Unknown matrix type `+JSON.stringify(t)+`.`)}}),vD=`matrixFromFunction`,yD=Y(vD,[`typed`,`matrix`,`isZero`],e=>{var{typed:t,matrix:n,isZero:r}=e;return t(vD,{"Array | Matrix, function, string, string":function(e,t,n,r){return i(e,t,n,r)},"Array | Matrix, function, string":function(e,t,n){return i(e,t,n)},"Matrix, function":function(e,t){return i(e,t,`dense`)},"Array, function":function(e,t){return i(e,t,`dense`).toArray()},"Array | Matrix, string, function":function(e,t,n){return i(e,n,t)},"Array | Matrix, string, string, function":function(e,t,n,r){return i(e,r,t,n)}});function i(e,t,i,a){var o=a===void 0?n(i):n(i,a);return o.resize(e),o.forEach(function(e,n){var i=t(n);r(i)||o.set(n,i)}),o}}),bD=`matrixFromRows`,xD=Y(bD,[`typed`,`matrix`,`flatten`,`size`],e=>{var{typed:t,matrix:n,flatten:r,size:i}=e;return t(bD,{"...Array":function(e){return a(e)},"...Matrix":function(e){return n(a(e.map(e=>e.toArray())))}});function a(e){if(e.length===0)throw TypeError(`At least one row is needed to construct a matrix.`);var t=o(e[0]),n=[];for(var i of e){var a=o(i);if(a!==t)throw TypeError(`The vectors had different length: `+(t|0)+` ≠ `+(a|0));n.push(r(i))}return n}function o(e){var t=i(e);if(t.length===1)return t[0];if(t.length===2){if(t[0]===1)return t[1];if(t[1]===1)return t[0];throw TypeError(`At least one of the arguments is not a vector.`)}else throw TypeError(`Only one- or two-dimensional vectors are supported.`)}}),SD=`matrixFromColumns`,CD=Y(SD,[`typed`,`matrix`,`flatten`,`size`],e=>{var{typed:t,matrix:n,flatten:r,size:i}=e;return t(SD,{"...Array":function(e){return a(e)},"...Matrix":function(e){return n(a(e.map(e=>e.toArray())))}});function a(e){if(e.length===0)throw TypeError(`At least one column is needed to construct a matrix.`);for(var t=o(e[0]),n=[],i=0;i{var{typed:t}=e;return t(wD,{"Unit, Array":function(e,t){return e.splitUnit(t)}})}),ED=`unaryMinus`,DD=Y(ED,[`typed`],e=>{var{typed:t}=e;return t(ED,{number:oT,"Complex | BigNumber | Fraction":e=>e.neg(),bigint:e=>-e,Unit:t.referToSelf(e=>n=>{var r=n.clone();return r.value=t.find(e,r.valueType())(n.value),r}),"Array | Matrix":t.referToSelf(e=>t=>qw(t,e,!0))})}),OD=`unaryPlus`,kD=Y(OD,[`typed`,`config`,`numeric`],e=>{var{typed:t,config:n,numeric:r}=e;return t(OD,{number:sT,Complex:function(e){return e},BigNumber:function(e){return e},bigint:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e,!0)),boolean:function(e){return r(+!!e,n.number)},string:function(e){return r(e,Fb(e,n))}})}),AD=`abs`,jD=Y(AD,[`typed`],e=>{var{typed:t}=e;return t(AD,{number:tT,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),bigint:e=>e<0n?-e:e,"Array | Matrix":t.referToSelf(e=>t=>qw(t,e,!0))})}),MD=`mapSlices`,ND=Y(MD,[`typed`,`isInteger`],e=>{var{typed:t,isInteger:n}=e;return t(MD,{"Array | Matrix, number | BigNumber, function":function(e,t,r){if(!n(t))throw TypeError(`Integer number expected for dimension`);var i=Array.isArray(e)?ew(e):e.size();if(t<0||t>=i.length)throw new $C(t,i.length);return Ny(e)?e.create(PD(e.valueOf(),t,r),e.datatype()):PD(e,t,r)}})},{formerly:`apply`});function PD(e,t,n){var r,i,a;if(t<=0)if(Array.isArray(e[0])){for(a=FD(e),i=[],r=0;r{var{typed:t}=e;return t(ID,{"number, number":nT,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"bigint, bigint":function(e,t){return e+t},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":t.referToSelf(e=>(n,r)=>{if(n.value===null||n.value===void 0)throw Error(`Parameter x contains a unit with undefined value`);if(r.value===null||r.value===void 0)throw Error(`Parameter y contains a unit with undefined value`);if(!n.equalBase(r))throw Error(`Units do not match`);var i=n.clone();return i.value=t.find(e,[i.valueType(),r.valueType()])(i.value,r.value),i.fixPrefix=!1,i})})}),RD=`subtractScalar`,zD=Y(RD,[`typed`],e=>{var{typed:t}=e;return t(RD,{"number, number":rT,"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"bigint, bigint":function(e,t){return e-t},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":t.referToSelf(e=>(n,r)=>{if(n.value===null||n.value===void 0)throw Error(`Parameter x contains a unit with undefined value`);if(r.value===null||r.value===void 0)throw Error(`Parameter y contains a unit with undefined value`);if(!n.equalBase(r))throw Error(`Units do not match`);var i=n.clone();return i.value=t.find(e,[i.valueType(),r.valueType()])(i.value,r.value),i.fixPrefix=!1,i})})}),BD=`cbrt`,VD=Y(BD,[`config`,`typed`,`isNegative`,`unaryMinus`,`matrix`,`Complex`,`BigNumber`,`Fraction`],e=>{var{config:t,typed:n,isNegative:r,unaryMinus:i,matrix:a,Complex:o,BigNumber:s,Fraction:c}=e;return n(BD,{number:cT,Complex:l,"Complex, boolean":l,BigNumber:function(e){return e.cbrt()},Unit:u});function l(e,n){var r=e.arg()/3,i=e.abs(),s=new o(cT(i),0).mul(new o(0,r).exp());if(n){var c=[s,new o(cT(i),0).mul(new o(0,r+Math.PI*2/3).exp()),new o(cT(i),0).mul(new o(0,r-Math.PI*2/3).exp())];return t.matrix===`Array`?c:a(c)}else return s}function u(e){if(e.value&&Oy(e.value)){var t=e.clone();return t.value=1,t=t.pow(1/3),t.value=l(e.value),t}else{var n=r(e.value);n&&(e.value=i(e.value));var a=Ey(e.value)?new s(1).div(3):ky(e.value)?new c(1,3):1/3,o=e.pow(a);return n&&(o.value=i(o.value)),o}}}),HD=Y(`matAlgo11xS0s`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i,a){var o=e._values,s=e._index,c=e._ptr,l=e._size,u=e._datatype;if(!o)throw Error(`Cannot perform operation on Pattern Sparse Matrix and Scalar value`);var d=l[0],f=l[1],p,m=n,h=0,g=i;typeof u==`string`&&(p=u,m=t.find(n,[p,p]),h=t.convert(0,p),r=t.convert(r,p),g=t.find(i,[p,p]));for(var _=[],v=[],y=[],b=0;b{var{typed:t,DenseMatrix:n}=e;return function(e,r,i,a){var o=e._values,s=e._index,c=e._ptr,l=e._size,u=e._datatype;if(!o)throw Error(`Cannot perform operation on Pattern Sparse Matrix and Scalar value`);var d=l[0],f=l[1],p,m=i;typeof u==`string`&&(p=u,r=t.convert(r,p),m=t.find(i,[p,p]));for(var h=[],g=[],_=[],v=0;v{var{typed:t}=e;return function(e,r,i,a){var o=e._data,s=e._size,c=e._datatype,l,u=i;typeof c==`string`&&(l=c,r=t.convert(r,l),u=t.find(i,[l,l]));var d=s.length>0?n(u,0,s,s[0],o,r,a):[];return e.createDenseMatrix({data:d,size:gb(s),datatype:l})};function n(e,t,r,i,a,o,s){var c=[];if(t===r.length-1)for(var l=0;l{var{typed:t,config:n,round:r}=e;function i(e){var t=Math.ceil(e),i=r(e);return t===i?t:$b(e,i,n.relTol,n.absTol)&&!$b(e,t,n.relTol,n.absTol)?i:t}return t(GD,{number:i,"number, number":function(e,t){if(!X(t))throw RangeError(`number of decimals in function ceil must be an integer`);if(t<0||t>15)throw RangeError(`number of decimals in ceil number must be in range 0-15`);var n=10**t;return i(e*n)/n}})}),YD=Y(GD,KD,e=>{var{typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}=e,c=HD({typed:t,equalScalar:a}),l=UD({typed:t,DenseMatrix:s}),u=WD({typed:t}),d=JD({typed:t,config:n,round:r});function f(e){var t=(e,t)=>NE(e,t,n.relTol,n.absTol),i=e.ceil(),a=r(e);return i.eq(a)?i:t(e,a)&&!t(e,i)?a:i}return t(`ceil`,{number:d.signatures.number,"number,number":d.signatures[`number,number`],Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},"Complex, BigNumber":function(e,t){return e.ceil(t.toNumber())},BigNumber:f,"BigNumber, BigNumber":function(e,t){var n=qD.pow(t);return f(e.mul(n)).div(n)},bigint:e=>e,"bigint, number":(e,t)=>e,"bigint, BigNumber":(e,t)=>e,Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Fraction, BigNumber":function(e,t){return e.ceil(t.toNumber())},"Unit, number, Unit":t.referToSelf(e=>function(t,n,r){var i=t.toNumeric(r);return r.multiply(e(i,n))}),"Unit, BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>e(t,n.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>qw(t,t=>e(t,n,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(e=>(t,n)=>e(t,0,n)),"Array | Matrix":t.referToSelf(e=>t=>qw(t,e,!0)),"Array, number | BigNumber":t.referToSelf(e=>(t,n)=>qw(t,t=>e(t,n),!0)),"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>c(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>u(t,n,e,!1)),"number | Complex | Fraction | BigNumber, Array":t.referToSelf(e=>(t,n)=>u(i(n),t,e,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf(e=>(t,n)=>a(t,0)?o(n.size(),n.storage()):n.storage()===`dense`?u(n,t,e,!0):l(n,t,e,!0))})}),XD=`cube`,ZD=Y(XD,[`typed`],e=>{var{typed:t}=e;return t(XD,{number:lT,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},bigint:function(e){return e*e*e},Fraction:function(e){return e.pow(3)},Unit:function(e){return e.pow(3)}})}),QD=`exp`,$D=Y(QD,[`typed`],e=>{var{typed:t}=e;return t(QD,{number:uT,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()}})}),eO=`expm1`,tO=Y(eO,[`typed`,`Complex`],e=>{var{typed:t,Complex:n}=e;return t(eO,{number:dT,Complex:function(e){var t=Math.exp(e.re);return new n(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)}})}),nO=`fix`,rO=[`typed`,`Complex`,`matrix`,`ceil`,`floor`,`equalScalar`,`zeros`,`DenseMatrix`],iO=Y(nO,[`typed`,`ceil`,`floor`],e=>{var{typed:t,ceil:n,floor:r}=e;return t(nO,{number:function(e){return e>0?r(e):n(e)},"number, number":function(e,t){return e>0?r(e,t):n(e,t)}})}),aO=Y(nO,rO,e=>{var{typed:t,Complex:n,matrix:r,ceil:i,floor:a,equalScalar:o,zeros:s,DenseMatrix:c}=e,l=UD({typed:t,DenseMatrix:c}),u=WD({typed:t}),d=iO({typed:t,ceil:i,floor:a});return t(`fix`,{number:d.signatures.number,"number, number | BigNumber":d.signatures[`number,number`],Complex:function(e){return new n(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number":function(e,t){return new n(e.re>0?a(e.re,t):i(e.re,t),e.im>0?a(e.im,t):i(e.im,t))},"Complex, BigNumber":function(e,t){var r=t.toNumber();return new n(e.re>0?a(e.re,r):i(e.re,r),e.im>0?a(e.im,r):i(e.im,r))},BigNumber:function(e){return e.isNegative()?i(e):a(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?i(e,t):a(e,t)},bigint:e=>e,"bigint, number":(e,t)=>e,"bigint, BigNumber":(e,t)=>e,Fraction:function(e){return e.s<0n?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0n?i(e,t):a(e,t)},"Unit, number, Unit":t.referToSelf(e=>function(t,n,r){var i=t.toNumeric(r);return r.multiply(e(i,n))}),"Unit, BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>e(t,n.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>qw(t,t=>e(t,n,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(e=>(t,n)=>e(t,0,n)),"Array | Matrix":t.referToSelf(e=>t=>qw(t,e,!0)),"Array | Matrix, number | BigNumber":t.referToSelf(e=>(t,n)=>qw(t,t=>e(t,n),!0)),"number | Complex | Fraction | BigNumber, Array":t.referToSelf(e=>(t,n)=>u(r(n),t,e,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf(e=>(t,n)=>o(t,0)?s(n.size(),n.storage()):n.storage()===`dense`?u(n,t,e,!0):l(n,t,e,!0))})}),oO=`floor`,sO=[`typed`,`config`,`round`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`],cO=new nC(10),lO=Y(oO,[`typed`,`config`,`round`],e=>{var{typed:t,config:n,round:r}=e;function i(e){var t=Math.floor(e),i=r(e);return t===i?t:$b(e,i,n.relTol,n.absTol)&&!$b(e,t,n.relTol,n.absTol)?i:t}return t(oO,{number:i,"number, number":function(e,t){if(!X(t))throw RangeError(`number of decimals in function floor must be an integer`);if(t<0||t>15)throw RangeError(`number of decimals in floor number must be in range 0 - 15`);var n=10**t;return i(e*n)/n}})}),uO=Y(oO,sO,e=>{var{typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}=e,c=HD({typed:t,equalScalar:a}),l=UD({typed:t,DenseMatrix:s}),u=WD({typed:t}),d=lO({typed:t,config:n,round:r});function f(e){var t=(e,t)=>NE(e,t,n.relTol,n.absTol),i=e.floor(),a=r(e);return i.eq(a)?i:t(e,a)&&!t(e,i)?a:i}return t(`floor`,{number:d.signatures.number,"number,number":d.signatures[`number,number`],Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},"Complex, BigNumber":function(e,t){return e.floor(t.toNumber())},BigNumber:f,"BigNumber, BigNumber":function(e,t){var n=cO.pow(t);return f(e.mul(n)).div(n)},bigint:e=>e,"bigint, number":(e,t)=>e,"bigint, BigNumber":(e,t)=>e,Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Fraction, BigNumber":function(e,t){return e.floor(t.toNumber())},"Unit, number, Unit":t.referToSelf(e=>function(t,n,r){var i=t.toNumeric(r);return r.multiply(e(i,n))}),"Unit, BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>e(t,n.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>qw(t,t=>e(t,n,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(e=>(t,n)=>e(t,0,n)),"Array | Matrix":t.referToSelf(e=>t=>qw(t,e,!0)),"Array, number | BigNumber":t.referToSelf(e=>(t,n)=>qw(t,t=>e(t,n),!0)),"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>c(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>u(t,n,e,!1)),"number | Complex | Fraction | BigNumber, Array":t.referToSelf(e=>(t,n)=>u(i(n),t,e,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf(e=>(t,n)=>a(t,0)?o(n.size(),n.storage()):n.storage()===`dense`?u(n,t,e,!0):l(n,t,e,!0))})}),dO=Y(`matAlgo02xDS0`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i,a){var o=e._data,s=e._size,c=e._datatype||e.getDataType(),l=r._values,u=r._index,d=r._ptr,f=r._size,p=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(s.length!==f.length)throw new QC(s.length,f.length);if(s[0]!==f[0]||s[1]!==f[1])throw RangeError(`Dimension mismatch. Matrix A (`+s+`) must match Matrix B (`+f+`)`);if(!l)throw Error(`Cannot perform operation on Dense Matrix and Pattern Sparse Matrix`);var m=s[0],h=s[1],g,_=n,v=0,y=i;typeof c==`string`&&c===p&&c!==`mixed`&&(g=c,_=t.find(n,[g,g]),v=t.convert(0,g),y=t.find(i,[g,g]));for(var b=[],x=[],S=[],C=0;C{var{typed:t}=e;return function(e,n,r,i){var a=e._data,o=e._size,s=e._datatype||e.getDataType(),c=n._values,l=n._index,u=n._ptr,d=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(o.length!==d.length)throw new QC(o.length,d.length);if(o[0]!==d[0]||o[1]!==d[1])throw RangeError(`Dimension mismatch. Matrix A (`+o+`) must match Matrix B (`+d+`)`);if(!c)throw Error(`Cannot perform operation on Dense Matrix and Pattern Sparse Matrix`);var p=o[0],m=o[1],h,g=0,_=r;typeof s==`string`&&s===f&&s!==`mixed`&&(h=s,g=t.convert(0,h),_=t.find(r,[h,h]));for(var v=[],y=0;y{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._index,s=e._ptr,c=e._size,l=e._datatype||e._data===void 0?e._datatype:e.getDataType(),u=r._values,d=r._index,f=r._ptr,p=r._size,m=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(c.length!==p.length)throw new QC(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw RangeError(`Dimension mismatch. Matrix A (`+c+`) must match Matrix B (`+p+`)`);var h=c[0],g=c[1],_,v=n,y=0,b=i;typeof l==`string`&&l===m&&l!==`mixed`&&(_=l,v=t.find(n,[_,_]),y=t.convert(0,_),b=t.find(i,[_,_]));var x=a&&u?[]:void 0,S=[],C=[],w=x?[]:void 0,T=x?[]:void 0,E=[],D=[],O,k,A,j;for(k=0;k{var{typed:t}=e;return function(e,r,i){var a=e._data,o=e._size,s=e._datatype,c=r._data,l=r._size,u=r._datatype,d=[];if(o.length!==l.length)throw new QC(o.length,l.length);for(var f=0;f0?n(m,0,d,d[0],a,c):[];return e.createDenseMatrix({data:h,size:d,datatype:p})};function n(e,t,r,i,a,o){var s=[];if(t===r.length-1)for(var c=0;cgO(e,n))}function gO(e,t){return bb(e.size(),t)?e:e.create(kw(e.valueOf(),t),e.datatype())}var _O=Y(`matrixAlgorithmSuite`,[`typed`,`matrix`],e=>{var{typed:t,matrix:n}=e,r=mO({typed:t}),i=WD({typed:t});return function(e){var a=e.elop,o=e.SD||e.DS,s;a?(s={"DenseMatrix, DenseMatrix":(e,t)=>r(...hO(e,t),a),"Array, Array":(e,t)=>r(...hO(n(e),n(t)),a).valueOf(),"Array, DenseMatrix":(e,t)=>r(...hO(n(e),t),a),"DenseMatrix, Array":(e,t)=>r(...hO(e,n(t)),a)},e.SS&&(s[`SparseMatrix, SparseMatrix`]=(t,n)=>e.SS(...hO(t,n),a,!1)),e.DS&&(s[`DenseMatrix, SparseMatrix`]=(t,n)=>e.DS(...hO(t,n),a,!1),s[`Array, SparseMatrix`]=(t,r)=>e.DS(...hO(n(t),r),a,!1)),o&&(s[`SparseMatrix, DenseMatrix`]=(e,t)=>o(...hO(t,e),a,!0),s[`SparseMatrix, Array`]=(e,t)=>o(...hO(n(t),e),a,!0))):(s={"DenseMatrix, DenseMatrix":t.referToSelf(e=>(t,n)=>r(...hO(t,n),e)),"Array, Array":t.referToSelf(e=>(t,i)=>r(...hO(n(t),n(i)),e).valueOf()),"Array, DenseMatrix":t.referToSelf(e=>(t,i)=>r(...hO(n(t),i),e)),"DenseMatrix, Array":t.referToSelf(e=>(t,i)=>r(...hO(t,n(i)),e))},e.SS&&(s[`SparseMatrix, SparseMatrix`]=t.referToSelf(t=>(n,r)=>e.SS(...hO(n,r),t,!1))),e.DS&&(s[`DenseMatrix, SparseMatrix`]=t.referToSelf(t=>(n,r)=>e.DS(...hO(n,r),t,!1)),s[`Array, SparseMatrix`]=t.referToSelf(t=>(r,i)=>e.DS(...hO(n(r),i),t,!1))),o&&(s[`SparseMatrix, DenseMatrix`]=t.referToSelf(e=>(t,n)=>o(...hO(n,t),e,!0)),s[`SparseMatrix, Array`]=t.referToSelf(e=>(t,r)=>o(...hO(n(r),t),e,!0))));var c=e.scalar||`any`;(e.Ds||e.Ss)&&(a?(s[`DenseMatrix,`+c]=(e,t)=>i(e,t,a,!1),s[c+`, DenseMatrix`]=(e,t)=>i(t,e,a,!0),s[`Array,`+c]=(e,t)=>i(n(e),t,a,!1).valueOf(),s[c+`, Array`]=(e,t)=>i(n(t),e,a,!0).valueOf()):(s[`DenseMatrix,`+c]=t.referToSelf(e=>(t,n)=>i(t,n,e,!1)),s[c+`, DenseMatrix`]=t.referToSelf(e=>(t,n)=>i(n,t,e,!0)),s[`Array,`+c]=t.referToSelf(e=>(t,r)=>i(n(t),r,e,!1).valueOf()),s[c+`, Array`]=t.referToSelf(e=>(t,r)=>i(n(r),t,e,!0).valueOf())));var l=e.sS===void 0?e.Ss:e.sS;return a?(e.Ss&&(s[`SparseMatrix,`+c]=(t,n)=>e.Ss(t,n,a,!1)),l&&(s[c+`, SparseMatrix`]=(e,t)=>l(t,e,a,!0))):(e.Ss&&(s[`SparseMatrix,`+c]=t.referToSelf(t=>(n,r)=>e.Ss(n,r,t,!1))),l&&(s[c+`, SparseMatrix`]=t.referToSelf(e=>(t,n)=>l(n,t,e,!0)))),a&&a.signatures&&vb(s,a.signatures),s}}),vO=`mod`,yO=Y(vO,[`typed`,`config`,`round`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`,`concat`],e=>{var{typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s,concat:c}=e,l=uO({typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}),u=dO({typed:t,equalScalar:a}),d=fO({typed:t}),f=pO({typed:t,equalScalar:a}),p=HD({typed:t,equalScalar:a}),m=UD({typed:t,DenseMatrix:s}),h=_O({typed:t,matrix:i,concat:c});return t(vO,{"number, number":g,"BigNumber, BigNumber":function(e,t){return t.isZero()?e:e.sub(t.mul(l(e.div(t))))},"bigint, bigint":function(e,t){if(t===0n)return e;if(e<0){var n=e%t;return n===0n?n:n+t}return e%t},"Fraction, Fraction":function(e,t){return t.equals(0)?e:e.sub(t.mul(l(e.div(t))))}},h({SS:f,DS:d,SD:u,Ss:p,sS:m}));function g(e,t){return t===0?e:e-t*l(e/t)}}),bO=Y(`matAlgo01xDSid`,[`typed`],e=>{var{typed:t}=e;return function(e,n,r,i){var a=e._data,o=e._size,s=e._datatype||e.getDataType(),c=n._values,l=n._index,u=n._ptr,d=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(o.length!==d.length)throw new QC(o.length,d.length);if(o[0]!==d[0]||o[1]!==d[1])throw RangeError(`Dimension mismatch. Matrix A (`+o+`) must match Matrix B (`+d+`)`);if(!c)throw Error(`Cannot perform operation on Dense Matrix and Pattern Sparse Matrix`);var p=o[0],m=o[1],h=typeof s==`string`&&s!==`mixed`&&s===f?s:void 0,g=h?t.find(r,[h,h]):r,_,v,y=[];for(_=0;_{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._index,s=e._ptr,c=e._size,l=e._datatype||e._data===void 0?e._datatype:e.getDataType(),u=r._values,d=r._index,f=r._ptr,p=r._size,m=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(c.length!==p.length)throw new QC(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw RangeError(`Dimension mismatch. Matrix A (`+c+`) must match Matrix B (`+p+`)`);var h=c[0],g=c[1],_,v=n,y=0,b=i;typeof l==`string`&&l===m&&l!==`mixed`&&(_=l,v=t.find(n,[_,_]),y=t.convert(0,_),b=t.find(i,[_,_]));var x=a&&u?[]:void 0,S=[],C=[],w=a&&u?[]:void 0,T=a&&u?[]:void 0,E=[],D=[],O,k,A,j,M;for(k=0;k{var{typed:t,DenseMatrix:n}=e;return function(e,r,i,a){var o=e._values,s=e._index,c=e._ptr,l=e._size,u=e._datatype;if(!o)throw Error(`Cannot perform operation on Pattern Sparse Matrix and Scalar value`);var d=l[0],f=l[1],p,m=i;typeof u==`string`&&(p=u,r=t.convert(r,p),m=t.find(i,[p,p]));for(var h=[],g=[],_=[],v=0;vArray.isArray(e))}var kO=Y(wO,TO,e=>{var{typed:t,matrix:n,config:r,round:i,equalScalar:a,zeros:o,BigNumber:s,DenseMatrix:c,concat:l}=e,u=yO({typed:t,config:r,round:i,matrix:n,equalScalar:a,zeros:o,DenseMatrix:c,concat:l}),d=bO({typed:t}),f=xO({typed:t,equalScalar:a}),p=SO({typed:t,DenseMatrix:c}),m=_O({typed:t,matrix:n,concat:l});return t(wO,{"number, number":h,"BigNumber, BigNumber":g,"Fraction, Fraction":(e,t)=>e.gcd(t)},m({SS:f,DS:d,Ss:p}),{[DO]:t.referToSelf(e=>(t,n,r)=>{for(var i=e(t,n),a=0;at=>{if(t.length===1&&Array.isArray(t[0])&&OO(t[0]))return e(...t[0]);if(OO(t))return e(...t);throw new CO(`gcd() supports only 1d matrices!`)}),Matrix:t.referToSelf(e=>t=>e(t.toArray()))});function h(e,t){if(!X(e)||!X(t))throw Error(`Parameters in function gcd must be integer numbers`);for(var n;t!==0;)n=u(e,t),e=t,t=n;return e<0?-e:e}function g(e,t){if(!e.isInt()||!t.isInt())throw Error(`Parameters in function gcd must be integer numbers`);for(var n=new s(0);!t.isZero();){var r=u(e,t);e=t,t=r}return e.lt(n)?e.neg():e}}),AO=Y(`matAlgo06xS0S0`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._size,s=e._datatype||e._data===void 0?e._datatype:e.getDataType(),c=r._values,l=r._size,u=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(o.length!==l.length)throw new QC(o.length,l.length);if(o[0]!==l[0]||o[1]!==l[1])throw RangeError(`Dimension mismatch. Matrix A (`+o+`) must match Matrix B (`+l+`)`);var d=o[0],f=o[1],p,m=n,h=0,g=i;typeof s==`string`&&s===u&&s!==`mixed`&&(p=s,m=t.find(n,[p,p]),h=t.convert(0,p),g=t.find(i,[p,p]));for(var _=a&&c?[]:void 0,v=[],y=[],b=_?[]:void 0,x=[],S=[],C=0;C{var{typed:t,matrix:n,equalScalar:r,concat:i}=e,a=dO({typed:t,equalScalar:r}),o=AO({typed:t,equalScalar:r}),s=HD({typed:t,equalScalar:r}),c=_O({typed:t,matrix:n,concat:i}),l=`number | BigNumber | Fraction | Matrix | Array`,u={};return u[`${l}, ${l}, ...${l}`]=t.referToSelf(e=>(t,n,r)=>{for(var i=e(t,n),a=0;ae.lcm(t)},c({SS:o,DS:a,Ss:s}),u);function d(e,t){if(!e.isInt()||!t.isInt())throw Error(`Parameters in function lcm must be integer numbers`);if(e.isZero())return e;if(t.isZero())return t;for(var n=e.times(t);!t.isZero();){var r=t;t=e.mod(r),e=r}return n.div(e).abs()}});function NO(e,t,n,r){return function(i){if(i>0||n.predictable){if(i<=0)return NaN;var a=i.toString(16),o=a.substring(0,15);return e*(a.length-o.length)+t(Number(`0x`+o))}return r(i.toNumber())}}var PO=`log10`,FO=[`typed`,`config`,`Complex`],IO=hT(16),LO=Y(PO,FO,e=>{var{typed:t,config:n,Complex:r}=e;function i(e){return e.log().div(Math.LN10)}function a(e){return i(new r(e,0))}return t(PO,{number:function(e){return e>=0||n.predictable?hT(e):a(e)},bigint:NO(IO,hT,n,a),Complex:i,BigNumber:function(e){return!e.isNegative()||n.predictable?e.log():a(e.toNumber())},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),RO=`log2`,zO=Y(RO,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;function i(e){return a(new r(e,0))}return t(RO,{number:function(e){return e>=0||n.predictable?gT(e):i(e)},bigint:NO(4,gT,n,i),Complex:a,BigNumber:function(e){return!e.isNegative()||n.predictable?e.log(2):i(e.toNumber())},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))});function a(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new r(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}}),BO=Y(`multiplyScalar`,[`typed`],e=>{var{typed:t}=e;return t(`multiplyScalar`,{"number, number":iT,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"bigint, bigint":function(e,t){return e*t},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":(e,t)=>t.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,t)=>e.multiply(t)})}),VO=`multiply`,HO=Y(VO,[`typed`,`matrix`,`addScalar`,`multiplyScalar`,`equalScalar`,`dot`],e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:i,equalScalar:a,dot:o}=e,s=HD({typed:t,equalScalar:a}),c=WD({typed:t});function l(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw RangeError(`Dimension mismatch in multiplication. Vectors must have the same length`);break;case 2:if(e[0]!==t[0])throw RangeError(`Dimension mismatch in multiplication. Vector length (`+e[0]+`) must match Matrix rows (`+t[0]+`)`);break;default:throw Error(`Can only multiply a 1 or 2 dimensional matrix (Matrix B has `+t.length+` dimensions)`)}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw RangeError(`Dimension mismatch in multiplication. Matrix columns (`+e[1]+`) must match Vector length (`+t[0]+`)`);break;case 2:if(e[1]!==t[0])throw RangeError(`Dimension mismatch in multiplication. Matrix A columns (`+e[1]+`) must match Matrix B rows (`+t[0]+`)`);break;default:throw Error(`Can only multiply a 1 or 2 dimensional matrix (Matrix B has `+t.length+` dimensions)`)}break;default:throw Error(`Can only multiply a 1 or 2 dimensional matrix (Matrix A has `+e.length+` dimensions)`)}}function u(e,t,n){if(n===0)throw Error(`Cannot multiply two empty vectors`);return o(e,t)}function d(e,t){if(t.storage()!==`dense`)throw Error(`Support for SparseMatrix not implemented`);return f(e,t)}function f(e,n){var a=e._data,o=e._size,s=e._datatype||e.getDataType(),c=n._data,l=n._size,u=n._datatype||n.getDataType(),d=o[0],f=l[1],p,m=r,h=i;s&&u&&s===u&&typeof s==`string`&&s!==`mixed`&&(p=s,m=t.find(r,[p,p]),h=t.find(i,[p,p]));for(var g=[],_=0;_E)for(var O=0,k=0;k(t,r)=>{l(ew(t),ew(r));var i=e(n(t),n(r));return Ny(i)?i.valueOf():i}),"Matrix, Matrix":function(e,t){var n=e.size(),r=t.size();return l(n,r),n.length===1?r.length===1?u(e,t,n[0]):d(e,t):r.length===1?p(e,t):m(e,t)},"Matrix, Array":t.referTo(`Matrix,Matrix`,e=>(t,r)=>e(t,n(r))),"Array, Matrix":t.referToSelf(e=>(t,r)=>e(n(t,r.storage()),r)),"SparseMatrix, any":function(e,t){return s(e,t,i,!1)},"DenseMatrix, any":function(e,t){return c(e,t,i,!1)},"any, SparseMatrix":function(e,t){return s(t,e,i,!0)},"any, DenseMatrix":function(e,t){return c(t,e,i,!0)},"Array, any":function(e,t){return c(n(e),t,i,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,i,!0).valueOf()},"any, any":i,"any, any, ...any":t.referToSelf(e=>(t,n,r)=>{for(var i=e(t,n),a=0;a{var{typed:t,matrix:n,equalScalar:r,BigNumber:i,concat:a}=e,o=bO({typed:t}),s=dO({typed:t,equalScalar:r}),c=AO({typed:t,equalScalar:r}),l=HD({typed:t,equalScalar:r}),u=_O({typed:t,matrix:n,concat:a});function d(){throw Error(`Complex number not supported in function nthRoot. Use nthRoots instead.`)}return t(UO,{number:yT,"number, number":yT,BigNumber:e=>f(e,new i(2)),"BigNumber, BigNumber":f,Complex:d,"Complex, number":d,Array:t.referTo(`DenseMatrix,number`,e=>t=>e(n(t),2).valueOf()),DenseMatrix:t.referTo(`DenseMatrix,number`,e=>t=>e(t,2)),SparseMatrix:t.referTo(`SparseMatrix,number`,e=>t=>e(t,2)),"SparseMatrix, SparseMatrix":t.referToSelf(e=>(t,n)=>{if(n.density()===1)return c(t,n,e);throw Error(`Root must be non-zero`)}),"DenseMatrix, SparseMatrix":t.referToSelf(e=>(t,n)=>{if(n.density()===1)return o(t,n,e,!1);throw Error(`Root must be non-zero`)}),"Array, SparseMatrix":t.referTo(`DenseMatrix,SparseMatrix`,e=>(t,r)=>e(n(t),r)),"number | BigNumber, SparseMatrix":t.referToSelf(e=>(t,n)=>{if(n.density()===1)return l(n,t,e,!0);throw Error(`Root must be non-zero`)})},u({scalar:`number | BigNumber`,SD:s,Ss:l,sS:!1}));function f(e,t){var n=i.precision,r=i.clone({precision:n+2}),a=new i(0),o=new r(1),s=t.isNegative();if(s&&(t=t.neg()),t.isZero())throw Error(`Root must be non-zero`);if(e.isNegative()&&!t.abs().mod(2).equals(1))throw Error(`Root must be odd when a is negative.`);if(e.isZero())return s?new r(1/0):0;if(!e.isFinite())return s?a:e;var c=e.abs().pow(o.div(t));return c=e.isNeg()?c.neg():c,new i((s?o.div(c):c).toPrecision(n))}}),GO=`sign`,KO=Y(GO,[`typed`,`BigNumber`,`Fraction`,`complex`],e=>{var{typed:t,BigNumber:n,complex:r,Fraction:i}=e;return t(GO,{number:bT,Complex:function(e){return e.im===0?r(bT(e.re)):e.sign()},BigNumber:function(e){return new n(e.cmp(0))},bigint:function(e){return e>0n?1n:e<0n?-1n:0n},Fraction:function(e){return e.n===0n?new i(0):new i(e.s)},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e,!0)),Unit:t.referToSelf(e=>n=>{if(!n._isDerived()&&n.units[0].unit.offset!==0)throw TypeError(`sign is ambiguous for units with offset`);return t.find(e,n.valueType())(n.value)})})}),qO=Y(`sqrt`,[`config`,`typed`,`Complex`],e=>{var{config:t,typed:n,Complex:r}=e;return n(`sqrt`,{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():i(e.toNumber())},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new r(e,0).sqrt()}}),JO=`square`,YO=Y(JO,[`typed`],e=>{var{typed:t}=e;return t(JO,{number:ST,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},bigint:function(e){return e*e},Fraction:function(e){return e.mul(e)},Unit:function(e){return e.pow(2)}})}),XO=`subtract`,ZO=Y(XO,[`typed`,`matrix`,`equalScalar`,`subtractScalar`,`unaryMinus`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,subtractScalar:i,unaryMinus:a,DenseMatrix:o,concat:s}=e,c=bO({typed:t}),l=fO({typed:t}),u=pO({typed:t,equalScalar:r}),d=SO({typed:t,DenseMatrix:o}),f=UD({typed:t,DenseMatrix:o}),p=_O({typed:t,matrix:n,concat:s});return t(XO,{"any, any":i},p({elop:i,SS:u,DS:c,SD:l,Ss:f,sS:d}))}),QO=`xgcd`,$O=Y(QO,[`typed`,`config`,`matrix`,`BigNumber`],e=>{var{typed:t,config:n,matrix:r,BigNumber:i}=e;return t(QO,{"number, number":function(e,t){var i=CT(e,t);return n.matrix===`Array`?i:r(i)},"BigNumber, BigNumber":a});function a(e,t){var a,o,s,c=new i(0),l=new i(1),u=c,d=l,f=l,p=c;if(!e.isInt()||!t.isInt())throw Error(`Parameters in function xgcd must be integer numbers`);for(;!t.isZero();)o=e.div(t).floor(),s=e.mod(t),a=u,u=d.minus(o.times(u)),d=a,a=f,f=p.minus(o.times(f)),p=a,e=t,t=s;var m=e.lt(c)?[e.neg(),d.neg(),p.neg()]:[e,e.isZero()?0:d,p];return n.matrix===`Array`?m:r(m)}}),ek=`invmod`,tk=Y(ek,[`typed`,`config`,`BigNumber`,`xgcd`,`equal`,`smaller`,`mod`,`add`,`isInteger`],e=>{var{typed:t,config:n,BigNumber:r,xgcd:i,equal:a,smaller:o,mod:s,add:c,isInteger:l}=e;return t(ek,{"number, number":u,"BigNumber, BigNumber":u});function u(e,t){if(!l(e)||!l(t))throw Error(`Parameters in function invmod must be integer numbers`);if(e=s(e,t),a(t,0))throw Error(`Divisor must be non zero`);var n=i(e,t);n=n.valueOf();var[u,d]=n;return a(u,r(1))?(d=s(d,t),o(d,r(0))&&(d=c(d,t)),d):NaN}}),nk=Y(`matAlgo09xS0Sf`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._index,s=e._ptr,c=e._size,l=e._datatype||e._data===void 0?e._datatype:e.getDataType(),u=r._values,d=r._index,f=r._ptr,p=r._size,m=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(c.length!==p.length)throw new QC(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw RangeError(`Dimension mismatch. Matrix A (`+c+`) must match Matrix B (`+p+`)`);var h=c[0],g=c[1],_,v=n,y=0,b=i;typeof l==`string`&&l===m&&l!==`mixed`&&(_=l,v=t.find(n,[_,_]),y=t.convert(0,_),b=t.find(i,[_,_]));var x=a&&u?[]:void 0,S=[],C=[],w=x?[]:void 0,T=[],E,D,O,k,A;for(D=0;D{var{typed:t,matrix:n,equalScalar:r,multiplyScalar:i,concat:a}=e,o=dO({typed:t,equalScalar:r}),s=nk({typed:t,equalScalar:r}),c=HD({typed:t,equalScalar:r});return t(rk,_O({typed:t,matrix:n,concat:a})({elop:i,SS:s,DS:o,Ss:c}))});function ak(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function bitAnd`);var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new n(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new n(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new n(0):e}return ck(e,t,function(e,t){return e&t})}function ok(e){if(e.isFinite()&&!e.isInteger())throw Error(`Integer expected in function bitNot`);var t=e.constructor,n=t.precision;t.config({precision:1e9});var r=e.plus(new t(1));return r.s=-r.s||null,t.config({precision:n}),r}function sk(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function bitOr`);var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);var r=new n(-1);return e.isZero()||t.eq(r)||e.eq(t)?t:t.isZero()||e.eq(r)?e:!e.isFinite()||!t.isFinite()?!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?r:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e:ck(e,t,function(e,t){return e|t})}function ck(e,t,n){var r=e.constructor,i,a,o=+(e.s<0),s=+(t.s<0);if(o){i=lk(ok(e));for(var c=0;c0;)n(u[--p],d[--m])===h&&(g=g.plus(_)),_=_.times(v);for(;m>0;)n(f,d[--m])===h&&(g=g.plus(_)),_=_.times(v);return r.config({precision:y}),h===0&&(g.s=-g.s),g}function lk(e){for(var t=e.d,n=t[0]+``,r=1;r0)if(++s>l)for(s-=l;s--;)c+=`0`;else s1&&((u[p+1]===null||u[p+1]===void 0)&&(u[p+1]=0),u[p+1]+=u[p]>>1,u[p]&=1)}return u.reverse()}function uk(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function bitXor`);var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new n(0);var r=new n(-1);return e.eq(r)?ok(t):t.eq(r)?ok(e):!e.isFinite()||!t.isFinite()?!e.isFinite()&&!t.isFinite()?r:new n(e.isNegative()===t.isNegative()?1/0:-1/0):ck(e,t,function(e,t){return e^t})}function dk(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function leftShift`);var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:!e.isFinite()&&!t.isFinite()?new n(NaN):t.lt(55)?e.times(2**t.toNumber()+``):e.times(new n(2).pow(t))}function fk(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function rightArithShift`);var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(2**t.toNumber()+``).floor():e.div(new n(2).pow(t)).floor():e.isNegative()?new n(-1):e.isFinite()?new n(0):new n(NaN)}var pk=`bitAnd`,mk=Y(pk,[`typed`,`matrix`,`equalScalar`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,concat:i}=e,a=dO({typed:t,equalScalar:r}),o=AO({typed:t,equalScalar:r}),s=HD({typed:t,equalScalar:r}),c=_O({typed:t,matrix:n,concat:i});return t(pk,{"number, number":kT,"BigNumber, BigNumber":ak,"bigint, bigint":(e,t)=>e&t},c({SS:o,DS:a,Ss:s}))}),hk=`bitNot`,gk=Y(hk,[`typed`],e=>{var{typed:t}=e;return t(hk,{number:AT,BigNumber:ok,bigint:e=>~e,"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),_k=`bitOr`,vk=Y(_k,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a}=e,o=bO({typed:t}),s=xO({typed:t,equalScalar:r}),c=SO({typed:t,DenseMatrix:i}),l=_O({typed:t,matrix:n,concat:a});return t(_k,{"number, number":jT,"BigNumber, BigNumber":sk,"bigint, bigint":(e,t)=>e|t},l({SS:s,DS:o,Ss:c}))}),yk=Y(`matAlgo07xSSf`,[`typed`,`SparseMatrix`],e=>{var{typed:t,SparseMatrix:n}=e;return function(e,i,a){var o=e._size,s=e._datatype||e._data===void 0?e._datatype:e.getDataType(),c=i._size,l=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(o.length!==c.length)throw new QC(o.length,c.length);if(o[0]!==c[0]||o[1]!==c[1])throw RangeError(`Dimension mismatch. Matrix A (`+o+`) must match Matrix B (`+c+`)`);var u=o[0],d=o[1],f,p=0,m=a;typeof s==`string`&&s===l&&s!==`mixed`&&(f=s,p=t.convert(0,f),m=t.find(a,[f,f]));for(var h=[],g=[],_=Array(d+1).fill(0),v=[],y=[],b=[],x=[],S=0;S{var{typed:t,matrix:n,DenseMatrix:r,concat:i,SparseMatrix:a}=e,o=fO({typed:t}),s=yk({typed:t,SparseMatrix:a}),c=UD({typed:t,DenseMatrix:r}),l=_O({typed:t,matrix:n,concat:i});return t(bk,{"number, number":MT,"BigNumber, BigNumber":uk,"bigint, bigint":(e,t)=>e^t},l({SS:s,DS:o,Ss:c}))}),Sk=`arg`,Ck=Y(Sk,[`typed`],e=>{var{typed:t}=e;return t(Sk,{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),wk=`conj`,Tk=Y(wk,[`typed`],e=>{var{typed:t}=e;return t(wk,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),Unit:t.referToSelf(e=>t=>new t.constructor(e(t.toNumeric()),t.formatUnits())),"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),Ek=`im`,Dk=Y(Ek,[`typed`],e=>{var{typed:t}=e;return t(Ek,{number:()=>0,"BigNumber | Fraction":e=>e.mul(0),Complex:e=>e.im,"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),Ok=`re`,kk=Y(Ok,[`typed`],e=>{var{typed:t}=e;return t(Ok,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.re,"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),Ak=`not`,jk=Y(Ak,[`typed`],e=>{var{typed:t}=e;return t(Ak,{"null | undefined":()=>!0,number:WT,Complex:function(e){return e.re===0&&e.im===0},BigNumber:function(e){return e.isZero()||e.isNaN()},bigint:e=>!e,Unit:t.referToSelf(e=>n=>t.find(e,n.valueType())(n.value)),"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),Mk=`nullish`,Nk=Y(Mk,[`typed`,`matrix`,`size`,`flatten`,`deepEqual`],e=>{var{typed:t,matrix:n,size:r,flatten:i,deepEqual:a}=e,o=fO({typed:t}),s=WD({typed:t}),c=mO({typed:t});return t(Mk,{"number|bigint|Complex|BigNumber|Fraction|Unit|string|boolean|SparseMatrix, any":(e,t)=>e,"null, any":(e,t)=>t,"undefined, any":(e,t)=>t,"SparseMatrix, Array | Matrix":(e,t)=>{var n=r(e),i=r(t);if(a(n,i))return e;throw new QC(n,i)},"DenseMatrix, DenseMatrix":t.referToSelf(e=>(t,n)=>c(t,n,e)),"DenseMatrix, SparseMatrix":t.referToSelf(e=>(t,n)=>o(t,n,e,!1)),"DenseMatrix, Array":t.referToSelf(e=>(t,r)=>c(t,n(r),e)),"DenseMatrix, any":t.referToSelf(e=>(t,n)=>s(t,n,e,!1)),"Array, Array":t.referToSelf(e=>(t,r)=>c(n(t),n(r),e).valueOf()),"Array, DenseMatrix":t.referToSelf(e=>(t,r)=>c(n(t),r,e)),"Array, SparseMatrix":t.referToSelf(e=>(t,r)=>o(n(t),r,e,!1)),"Array, any":t.referToSelf(e=>(t,r)=>s(n(t),r,e,!1).valueOf())})}),Pk=`or`,Fk=Y(Pk,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a}=e,o=fO({typed:t}),s=pO({typed:t,equalScalar:r}),c=UD({typed:t,DenseMatrix:i}),l=_O({typed:t,matrix:n,concat:a});return t(Pk,{"number, number":GT,"Complex, Complex":function(e,t){return e.re!==0||e.im!==0||t.re!==0||t.im!==0},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"bigint, bigint":GT,"Unit, Unit":t.referToSelf(e=>(t,n)=>e(t.value||0,n.value||0))},l({SS:s,DS:o,Ss:c}))}),Ik=`xor`,Lk=Y(Ik,[`typed`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,matrix:n,DenseMatrix:r,concat:i,SparseMatrix:a}=e,o=fO({typed:t}),s=yk({typed:t,SparseMatrix:a}),c=UD({typed:t,DenseMatrix:r}),l=_O({typed:t,matrix:n,concat:i});return t(Ik,{"number, number":KT,"Complex, Complex":function(e,t){return(e.re!==0||e.im!==0)!=(t.re!==0||t.im!==0)},"bigint, bigint":KT,"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":t.referToSelf(e=>(t,n)=>e(t.value||0,n.value||0))},l({SS:s,DS:o,Ss:c}))}),Rk=`concat`,zk=Y(Rk,[`typed`,`matrix`,`isInteger`],e=>{var{typed:t,matrix:n,isInteger:r}=e;return t(Rk,{"...Array | Matrix | number | BigNumber":function(e){var t,i=e.length,a=-1,o,s=!1,c=[];for(t=0;t0&&a>o)throw new $C(a,o+1)}else{var u=gb(l).valueOf(),d=ew(u);if(c[t]=u,o=a,a=d.length-1,t>0&&a!==o)throw new QC(o+1,a+1)}}if(c.length===0)throw SyntaxError(`At least one matrix expected`);for(var f=c.shift();c.length;)f=Ew(f,c.shift(),a);return s?n(f):f},"...string":function(e){return e.join(``)}})}),Bk=`column`,Vk=Y(Bk,[`typed`,`Index`,`matrix`,`range`],e=>{var{typed:t,Index:n,matrix:r,range:i}=e;return t(Bk,{"Matrix, number":a,"Array, number":function(e,t){return a(r(gb(e)),t).valueOf()}});function a(e,t){if(e.size().length!==2)throw Error(`Only two dimensional matrix is supported`);iw(t,e.size()[1]);var a=new n(i(0,e.size()[0]),[t]),o=e.subset(a);return Ny(o)?o:r([[o]])}}),Hk=`count`,Uk=Y(Hk,[`typed`,`size`,`prod`],e=>{var{typed:t,size:n,prod:r}=e;return t(Hk,{string:function(e){return e.length},"Matrix | Array":function(e){return r(n(e))}})}),Wk=`cross`,Gk=Y(Wk,[`typed`,`matrix`,`subtract`,`multiply`],e=>{var{typed:t,matrix:n,subtract:r,multiply:i}=e;return t(Wk,{"Matrix, Matrix":function(e,t){return n(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(a(e.toArray(),t))},"Array, Matrix":function(e,t){return n(a(e,t.toArray()))},"Array, Array":a});function a(e,t){var n=Math.max(ew(e).length,ew(t).length);e=fw(e),t=fw(t);var a=ew(e),o=ew(t);if(a.length!==1||o.length!==1||a[0]!==3||o[0]!==3)throw RangeError(`Vectors with length 3 expected (Size A = [`+a.join(`, `)+`], B = [`+o.join(`, `)+`])`);var s=[r(i(e[1],t[2]),i(e[2],t[1])),r(i(e[2],t[0]),i(e[0],t[2])),r(i(e[0],t[1]),i(e[1],t[0]))];return n>1?[s]:s}}),Kk=`diag`,qk=Y(Kk,[`typed`,`matrix`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,matrix:n,DenseMatrix:r,SparseMatrix:i}=e;return t(Kk,{Array:function(e){return a(e,0,ew(e),null)},"Array, number":function(e,t){return a(e,t,ew(e),null)},"Array, BigNumber":function(e,t){return a(e,t.toNumber(),ew(e),null)},"Array, string":function(e,t){return a(e,0,ew(e),t)},"Array, number, string":function(e,t,n){return a(e,t,ew(e),n)},"Array, BigNumber, string":function(e,t,n){return a(e,t.toNumber(),ew(e),n)},Matrix:function(e){return a(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return a(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return a(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return a(e,0,e.size(),t)},"Matrix, number, string":function(e,t,n){return a(e,t,e.size(),n)},"Matrix, BigNumber, string":function(e,t,n){return a(e,t.toNumber(),e.size(),n)}});function a(e,t,n,r){if(!X(t))throw TypeError(`Second parameter in function diag must be an integer`);var i=t>0?t:0,a=t<0?-t:0;switch(n.length){case 1:return o(e,t,r,n[0],a,i);case 2:return s(e,t,r,n,a,i)}throw RangeError(`Matrix for function diag must be 2 dimensional`)}function o(e,t,n,a,o,s){var c=[a+o,a+s];if(n&&n!==`sparse`&&n!==`dense`)throw TypeError(`Unknown matrix type ${n}"`);var l=n===`sparse`?i.diagonal(c,e,t):r.diagonal(c,e,t);return n===null?l.valueOf():l}function s(e,t,r,i,a,o){if(Ny(e)){var s=e.diagonal(t);return r===null?s.valueOf():r===s.storage()?s:n(s,r)}for(var c=Math.min(i[0]-a,i[1]-o),l=[],u=0;u{var{typed:t}=e;return t(`filter`,{"Array, function":Yk,"Matrix, function":function(e,t){return e.create(Yk(e.valueOf(),t),e.datatype())},"Array, RegExp":bw,"Matrix, RegExp":function(e,t){return e.create(bw(e.valueOf(),t),e.datatype())}})});function Yk(e,t){var n=Fw(t,e,`filter`);return n.isUnary?yw(e,n.fn):yw(e,function(e,t,r){return n.fn(e,[t],r)})}var Xk=`flatten`,Zk=Y(Xk,[`typed`],e=>{var{typed:t}=e;return t(Xk,{Array:function(e){return gw(e)},DenseMatrix:function(e){return e.create(gw(e.valueOf(),!0),e.datatype())},SparseMatrix:function(e){throw TypeError(`SparseMatrix is not supported by function flatten because it does not support 1D vectors. Convert to a DenseMatrix or Array first. Example: flatten(x.toArray())`)}})}),Qk=`forEach`,$k=Y(Qk,[`typed`],e=>{var{typed:t}=e;return t(Qk,{"Array, function":eA,"Matrix, function":function(e,t){e.forEach(t)}})});function eA(e,t){var n=Fw(t,e,Qk);Nw(e,n.fn,n.isUnary)}var tA=`getMatrixDataType`,nA=Y(tA,[`typed`],e=>{var{typed:t}=e;return t(tA,{Array:function(e){return ww(e,hb)},Matrix:function(e){return e.getDataType()}})}),rA=`identity`,iA=Y(rA,[`typed`,`config`,`matrix`,`BigNumber`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,config:n,matrix:r,BigNumber:i,DenseMatrix:a,SparseMatrix:o}=e;return t(rA,{"":function(){return n.matrix===`Matrix`?r([]):[]},string:function(e){return r(e)},"number | BigNumber":function(e){return c(e,e,n.matrix===`Matrix`?`dense`:void 0)},"number | BigNumber, string":function(e,t){return c(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return c(e,t,n.matrix===`Matrix`?`dense`:void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,n){return c(e,t,n)},Array:function(e){return s(e)},"Array, string":function(e,t){return s(e,t)},Matrix:function(e){return s(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return s(e.valueOf(),t)}});function s(e,t){switch(e.length){case 0:return t?r(t):[];case 1:return c(e[0],e[0],t);case 2:return c(e[0],e[1],t);default:throw Error(`Vector containing two values expected`)}}function c(e,t,n){var r=Ey(e)||Ey(t)?i:null;if(Ey(e)&&(e=e.toNumber()),Ey(t)&&(t=t.toNumber()),!X(e)||e<1||!X(t)||t<1)throw Error(`Parameters in function identity must be positive integers`);var s=r?new i(1):1,c=r?new r(0):0,l=[e,t];if(n){if(n===`sparse`)return o.diagonal(l,s,0,c);if(n===`dense`)return a.diagonal(l,s,0,c);throw TypeError(`Unknown matrix type "${n}"`)}for(var u=ow([],l,c),d=e{var{typed:t,matrix:n,multiplyScalar:r}=e;return t(aA,{"Matrix, Matrix":function(e,t){return n(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(a(e.toArray(),t))},"Array, Matrix":function(e,t){return n(a(e,t.toArray()))},"Array, Array":a});function i(e,t){return e.flatMap(e=>t.map(t=>r(e,t)))}function a(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:-1;if(n<0){var r=ew(e).length,o=ew(t).length;for(n=Math.max(r,o);r++t.map(t=>a(e,t,n-1)))}}),sA=`map`,cA=Y(sA,[`typed`],e=>{var{typed:t}=e;return t(sA,{"Array, function":s,"Matrix, function":function(e,t){return e.map(t)},"Array|Matrix, Array|Matrix, ...Array|Matrix|function":(e,t,r)=>n([e,t,...r.slice(0,r.length-1)],r[r.length-1])});function n(e,n){if(typeof n!=`function`)throw Error(`Last argument must be a callback function`);var c=e[0].isMatrix,l=e.map(e=>e.isMatrix?e.size():ew(e)),u=Dw(...l),d=e.length,f=c?(e,t)=>e.get(t):jw,p=e.map((e,t)=>{var n=l[t].map(()=>0);return e.isMatrix?e.get(n):jw(e,n)}),m=t.isTypedFunction(n)?o(n,p,u.map(()=>0),e):a(n,d);if(m<2)return r(e,i(m,n,null));var h=c?e.map(t=>t.isMatrix?t.create(kw(t.toArray(),u),t.datatype()):e[0].create(kw(t.valueOf(),u))):e.map(e=>e.isMatrix?kw(e.toArray(),u):kw(e,u)),g=i(m,n,h),_=(e,t)=>g([e,...h.slice(1).map(e=>f(e,t))],t);return c?h[0].map(_):s(h[0],_)}function r(e,t){var n=e[0],r=e.map(e=>e.isMatrix?e.valueOf():e),i=e.map(e=>e.isMatrix?e.size():ew(e)),a=Dw(...i),o=i.map(e=>a.length-e.length),s=a.length-1,c=t.length>1?[]:null,l=d(r,0);if(n.isMatrix){var u=n.create();return u._data=l,u._size=a,u}else return l;function d(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=a[n],i=Array(r);if(no[r]>n?e:e.length===1?e[0]:e[t]),n+1)},u=0;ue.length===1?e[0]:e[r]),c?c.slice():void 0)},p=0;pt(...e);case 1:return(e,n)=>t(...e,n);case 2:return(e,r)=>t(...e,r,...n)}}function a(e,t){var n=e.toString();if(/arguments/.test(n))return 2;var r=n.match(/\(.*?\)/);return/\.\.\./.test(r)||e.length>t+1?2:+(e.length===t+1)}function o(e,n,r,i){return t.resolve(e,[...n,r,...i])===null?t.resolve(e,[...n,r])===null?(t.resolve(e,n),0):1:2}function s(e,t){var n=Fw(t,e,sA);return Mw(e,n.fn,n.isUnary)}}),lA=`diff`,uA=Y(lA,[`typed`,`matrix`,`subtract`,`number`],e=>{var{typed:t,matrix:n,subtract:r,number:i}=e;return t(lA,{"Array | Matrix":function(e){return Ny(e)?n(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,t){if(!X(t))throw RangeError(`Dimension must be a whole number`);return Ny(e)?n(a(e.toArray(),t)):a(e,t)},"Array, BigNumber":t.referTo(`Array,number`,e=>(t,n)=>e(t,i(n))),"Matrix, BigNumber":t.referTo(`Matrix,number`,e=>(t,n)=>e(t,i(n)))});function a(e,t){if(Ny(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError(`Array/Matrix does not have that many dimensions`);if(t>0){var n=[];return e.forEach(e=>{n.push(a(e,t-1))}),n}else if(t===0)return o(e);else throw RangeError(`Cannot have negative dimension`)}function o(e){for(var t=[],n=e.length,r=1;r{var{typed:t,config:n,matrix:r,BigNumber:i}=e;return t(`ones`,{"":function(){return n.matrix===`Array`?a([]):a([],`default`)},"...number | BigNumber | string":function(e){return typeof e[e.length-1]==`string`?a(e,e.pop()):n.matrix===`Array`?a(e):a(e,`default`)},Array:a,Matrix:function(e){var t=e.storage();return a(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return a(e.valueOf(),t)}});function a(e,t){var n=o(e)?new i(1):1;if(s(e),t){var a=r(t);return e.length>0?a.resize(e,n):a}else{var c=[];return e.length>0?ow(c,e,n):c}}function o(e){var t=!1;return e.forEach(function(e,n,r){Ey(e)&&(t=!0,r[n]=e.toNumber())}),t}function s(e){e.forEach(function(e){if(typeof e!=`number`||!X(e)||e<0)throw Error(`Parameters in function ones must be positive integers`)})}});function fA(){throw Error(`No "bignumber" implementation available`)}function pA(){throw Error(`No "fraction" implementation available`)}function mA(){throw Error(`No "matrix" implementation available`)}var hA=`range`,gA=Y(hA,[`typed`,`config`,`?matrix`,`?bignumber`,`equal`,`smaller`,`smallerEq`,`larger`,`largerEq`,`add`,`isZero`,`isPositive`],e=>{var{typed:t,config:n,matrix:r,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:c,add:l,isZero:u,isPositive:d}=e;return t(hA,{string:p,"string, boolean":p,number:function(e){throw TypeError(`Too few arguments to function range(): ${e}`)},boolean:function(e){throw TypeError(`Unexpected type of argument 1 to function range(): ${e}, number|bigint|BigNumber|Fraction`)},"number, number":function(e,t){return f(m(e,t,1,!1))},"number, number, number":function(e,t,n){return f(m(e,t,n,!1))},"number, number, boolean":function(e,t,n){return f(m(e,t,1,n))},"number, number, number, boolean":function(e,t,n,r){return f(m(e,t,n,r))},"bigint, bigint|number":function(e,t){return f(m(e,t,1n,!1))},"number, bigint":function(e,t){return f(m(BigInt(e),t,1n,!1))},"bigint, bigint|number, bigint|number":function(e,t,n){return f(m(e,t,BigInt(n),!1))},"number, bigint, bigint|number":function(e,t,n){return f(m(BigInt(e),t,BigInt(n),!1))},"bigint, bigint|number, boolean":function(e,t,n){return f(m(e,t,1n,n))},"number, bigint, boolean":function(e,t,n){return f(m(BigInt(e),t,1n,n))},"bigint, bigint|number, bigint|number, boolean":function(e,t,n,r){return f(m(e,t,BigInt(n),r))},"number, bigint, bigint|number, boolean":function(e,t,n,r){return f(m(BigInt(e),t,BigInt(n),r))},"BigNumber, BigNumber":function(e,t){var n=e.constructor;return f(m(e,t,new n(1),!1))},"BigNumber, BigNumber, BigNumber":function(e,t,n){return f(m(e,t,n,!1))},"BigNumber, BigNumber, boolean":function(e,t,n){var r=e.constructor;return f(m(e,t,new r(1),n))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,n,r){return f(m(e,t,n,r))},"Fraction, Fraction":function(e,t){return f(m(e,t,1,!1))},"Fraction, Fraction, Fraction":function(e,t,n){return f(m(e,t,n,!1))},"Fraction, Fraction, boolean":function(e,t,n){return f(m(e,t,1,n))},"Fraction, Fraction, Fraction, boolean":function(e,t,n,r){return f(m(e,t,n,r))},"Unit, Unit, Unit":function(e,t,n){return f(m(e,t,n,!1))},"Unit, Unit, Unit, boolean":function(e,t,n,r){return f(m(e,t,n,r))}});function f(e){return n.matrix===`Matrix`?r?r(e):mA():e}function p(e,t){var r=h(e);if(!r)throw SyntaxError(`String "`+e+`" is no valid range`);return n.number===`BigNumber`?(i===void 0&&fA(),f(m(i(r.start),i(r.end),i(r.step)),t)):f(m(r.start,r.end,r.step,t))}function m(e,t,n,r){var i=[];if(u(n))throw Error(`Step must be non-zero`);for(var f=d(n)?r?o:a:r?c:s,p=e;f(p,t);)i.push(p),p=l(p,n);return i}function h(e){var t=e.split(`:`).map(function(e){return Number(e)});if(t.some(function(e){return isNaN(e)}))return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}}),_A=`reshape`,vA=Y(_A,[`typed`,`isInteger`,`matrix`],e=>{var{typed:t,isInteger:n}=e;return t(_A,{"Matrix, Array":function(e,t){return e.reshape(t,!0)},"Array, Array":function(e,t){return t.forEach(function(e){if(!n(e))throw TypeError(`Invalid size for dimension: `+e)}),cw(e,t)}})}),yA=Y(`resize`,[`config`,`matrix`],e=>{var{config:t,matrix:n}=e;return function(e,i,a){if(arguments.length!==2&&arguments.length!==3)throw new CO(`resize`,arguments.length,2,3);if(Ny(i)&&(i=i.valueOf()),Ey(i[0])&&(i=i.map(function(e){return Ey(e)?e.toNumber():e})),Ny(e))return e.resize(i,a,!0);if(typeof e==`string`)return r(e,i,a);var o=Array.isArray(e)?!1:t.matrix!==`Array`;if(i.length===0){for(;Array.isArray(e);)e=e[0];return gb(e)}else{Array.isArray(e)||(e=[e]),e=gb(e);var s=ow(e,i,a);return o?n(s):s}};function r(e,t,n){if(n!==void 0){if(typeof n!=`string`||n.length!==1)throw TypeError(`Single character expected as defaultValue`)}else n=` `;if(t.length!==1)throw new QC(t.length,1);var r=t[0];if(typeof r!=`number`||!X(r))throw TypeError(`Invalid size, must contain positive integers (size: `+WC(t)+`)`);if(e.length>r)return e.substring(0,r);if(e.length{var{typed:t,multiply:n,rotationMatrix:r}=e;return t(bA,{"Array , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),n(r(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),n(r(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),n(r(t,a),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),n(r(t,a),e)}});function i(e,t){var n=Array.isArray(e)?ew(e):e.size();if(n.length>2||n.length===2&&n[1]!==1||n[0]!==t)throw RangeError(`Vector must be of dimensions 1x${t}`)}}),SA=`rotationMatrix`,CA=Y(SA,[`typed`,`config`,`multiplyScalar`,`addScalar`,`unaryMinus`,`norm`,`matrix`,`BigNumber`,`DenseMatrix`,`SparseMatrix`,`cos`,`sin`],e=>{var{typed:t,config:n,multiplyScalar:r,addScalar:i,unaryMinus:a,norm:o,BigNumber:s,matrix:c,DenseMatrix:l,SparseMatrix:u,cos:d,sin:f}=e;return t(SA,{"":function(){return n.matrix===`Matrix`?c([]):[]},string:function(e){return c(e)},"number | BigNumber | Complex | Unit":function(e){return p(e,n.matrix===`Matrix`?`dense`:void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return p(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var n=c(t);return m(n),_(e,n,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){return m(t),_(e,t,t.storage()||(n.matrix===`Matrix`?`dense`:void 0))},"number | BigNumber | Complex | Unit, Array, string":function(e,t,n){var r=c(t);return m(r),_(e,r,n)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,n){return m(t),_(e,t,n)}});function p(e,t){var n=Ey(e)?new s(-1):-1,i=d(e),a=f(e);return g([[i,r(n,a)],[a,i]],t)}function m(e){var t=e.size();if(t.length<1||t[0]!==3)throw RangeError(`Vector must be of dimensions 1x3`)}function h(e){return e.reduce((e,t)=>r(e,t))}function g(e,t){if(t){if(t===`sparse`)return new u(e);if(t===`dense`)return new l(e);throw TypeError(`Unknown matrix type "${t}"`)}return e}function _(e,t,n){var r=o(t);if(r===0)throw RangeError(`Rotation around zero vector`);var c=Ey(e)?s:null,l=c?new c(1):1,u=c?new c(-1):-1,p=c?new c(t.get([0])/r):t.get([0])/r,m=c?new c(t.get([1])/r):t.get([1])/r,_=c?new c(t.get([2])/r):t.get([2])/r,v=d(e),y=i(l,a(v)),b=f(e),x=i(v,h([p,p,y])),S=i(h([p,m,y]),h([u,_,b])),C=i(h([p,_,y]),h([m,b])),w=i(h([p,m,y]),h([_,b])),T=i(v,h([m,m,y])),E=i(h([m,_,y]),h([u,p,b])),D=i(h([p,_,y]),h([u,m,b])),O=i(h([m,_,y]),h([p,b])),k=i(v,h([_,_,y]));return g([[x,S,C],[w,T,E],[D,O,k]],n)}}),wA=`row`,TA=Y(wA,[`typed`,`Index`,`matrix`,`range`],e=>{var{typed:t,Index:n,matrix:r,range:i}=e;return t(wA,{"Matrix, number":a,"Array, number":function(e,t){return a(r(gb(e)),t).valueOf()}});function a(e,t){if(e.size().length!==2)throw Error(`Only two dimensional matrix is supported`);iw(t,e.size()[0]);var a=i(0,e.size()[1]),o=new n([t],a),s=e.subset(o);return Ny(s)?s:r([[s]])}}),EA=`size`,DA=Y(EA,[`typed`],e=>{var{typed:t}=e;return t(EA,{Matrix:e=>e.size(),Array:ew,string:e=>[e.length],"number | Complex | BigNumber | Unit | boolean | null":e=>[]})}),OA=`squeeze`,kA=Y(OA,[`typed`],e=>{var{typed:t}=e;return t(OA,{Array:function(e){return fw(gb(e))},Matrix:function(e){var t=fw(e.toArray());return Array.isArray(t)?e.create(t,e.datatype()):t},any:function(e){return gb(e)}})}),AA=`subset`,jA=Y(AA,[`typed`,`matrix`,`zeros`,`add`],e=>{var{typed:t,matrix:n,zeros:r,add:i}=e;return t(AA,{"Matrix, Index":function(e,t){return aw(t)?n():(rw(e,t),e.subset(t))},"Array, Index":t.referTo(`Matrix, Index`,function(e){return function(t,r){var i=e(n(t),r);return r.isScalar()?i:i.valueOf()}}),"Object, Index":PA,"string, Index":MA,"Matrix, Index, any, any":function(e,t,n,r){return aw(t)?e:(rw(e,t),e.clone().subset(t,a(n,t),r))},"Array, Index, any, any":t.referTo(`Matrix, Index, any, any`,function(e){return function(t,r,i,a){var o=e(n(t),r,i,a);return o.isMatrix?o.valueOf():o}}),"Array, Index, any":t.referTo(`Matrix, Index, any, any`,function(e){return function(t,r,i){return e(n(t),r,i,void 0).valueOf()}}),"Matrix, Index, any":t.referTo(`Matrix, Index, any, any`,function(e){return function(t,n,r){return e(t,n,r,void 0)}}),"string, Index, string":NA,"string, Index, string, string":NA,"Object, Index, any":FA});function a(e,t){if(typeof e==`string`)throw Error(`can't boradcast a string`);if(t.isScalar())return e;var n=t.size();if(n.every(e=>e>0))try{return i(e,r(n))}catch{return e}else return e}});function MA(e,t){if(!Ry(t))throw TypeError(`Index expected`);if(aw(t))return``;if(rw(Array.from(e),t),t.size().length!==1)throw new QC(t.size().length,1);var n=e.length;iw(t.min()[0],n),iw(t.max()[0],n);var r=t.dimension(0),i=``;function a(t){i+=e.charAt(t)}return Number.isInteger(r)?a(r):r.forEach(a),i}function NA(e,t,n,r){if(!t||t.isIndex!==!0)throw TypeError(`Index expected`);if(aw(t))return e;if(rw(Array.from(e),t),t.size().length!==1)throw new QC(t.size().length,1);if(r!==void 0){if(typeof r!=`string`||r.length!==1)throw TypeError(`Single character expected as defaultValue`)}else r=` `;var i=t.dimension(0);if((Number.isInteger(i)?1:i.size()[0])!==n.length)throw new QC(i.size()[0],n.length);var a=e.length;iw(t.min()[0]),iw(t.max()[0]);for(var o=[],s=0;sa)for(var l=a-1,u=o.length;l{var{typed:t,matrix:n}=e;return t(IA,{Array:e=>r(n(e)).valueOf(),Matrix:r,any:gb});function r(e){var t=e.size(),n;switch(t.length){case 1:n=e.clone();break;case 2:var r=t[0],o=t[1];if(o===0)throw RangeError(`Cannot transpose a 2D matrix with no columns (size: `+WC(t)+`)`);switch(e.storage()){case`dense`:n=i(e,r,o);break;case`sparse`:n=a(e,r,o);break}break;default:throw RangeError(`Matrix must be a vector or two dimensional (size: `+WC(t)+`)`)}return n}function i(e,t,n){for(var r=e._data,i=[],a,o=0;o{var{typed:t,transpose:n,conj:r}=e;return t(RA,{any:function(e){return r(n(e))}})}),BA=`zeros`,VA=Y(BA,[`typed`,`config`,`matrix`,`BigNumber`],e=>{var{typed:t,config:n,matrix:r,BigNumber:i}=e;return t(BA,{"":function(){return n.matrix===`Array`?a([]):a([],`default`)},"...number | BigNumber | string":function(e){return typeof e[e.length-1]==`string`?a(e,e.pop()):n.matrix===`Array`?a(e):a(e,`default`)},Array:a,Matrix:function(e){var t=e.storage();return a(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return a(e.valueOf(),t)}});function a(e,t){var n=o(e)?new i(0):0;if(s(e),t){var a=r(t);return e.length>0?a.resize(e,n):a}else{var c=[];return e.length>0?ow(c,e,n):c}}function o(e){var t=!1;return e.forEach(function(e,n,r){Ey(e)&&(t=!0,r[n]=e.toNumber())}),t}function s(e){e.forEach(function(e){if(typeof e!=`number`||!X(e)||e<0)throw Error(`Parameters in function zeros must be positive integers`)})}}),HA=`fft`,UA=Y(HA,[`typed`,`matrix`,`addScalar`,`multiplyScalar`,`divideScalar`,`exp`,`tau`,`i`,`dotDivide`,`conj`,`pow`,`ceil`,`log2`],e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:i,divideScalar:a,exp:o,tau:s,i:c,dotDivide:l,conj:u,pow:d,ceil:f,log2:p}=e;return t(HA,{Array:m,Matrix:function(e){return e.create(m(e.valueOf()),e.datatype())}});function m(e){var t=ew(e);return t.length===1?_(e,t[0]):h(e.map(e=>m(e,t.slice(1))),0)}function h(e,t){var n=ew(e);if(t!==0)return Array(n[0]).fill(0).map((n,r)=>h(e[r],t-1));if(n.length===1)return _(e);function r(e){var t=ew(e);return Array(t[1]).fill(0).map((n,r)=>Array(t[0]).fill(0).map((t,n)=>e[n][r]))}return r(h(r(e),1))}function g(e){for(var t=e.length,n=o(a(i(-1,i(c,s)),t)),r=[],h=1-t;hi(e[a],r[t-1+a])),...Array(g-t).fill(0)],y=[...Array(t+t-1).fill(0).map((e,t)=>a(1,r[t])),...Array(g-(t+t-1)).fill(0)],b=_(v),x=_(y),S=l(u(m(u(Array(g).fill(0).map((e,t)=>i(b[t],x[t]))))),g),C=[],w=t-1;wt%2==0),t/2),..._(e.filter((e,t)=>t%2==1),t/2)],l=0;l{var{typed:t,fft:n,dotDivide:r,conj:i}=e;return t(WA,{"Array | Matrix":function(e){var t=Ny(e)?e.size():ew(e);return r(i(n(i(e))),t.reduce((e,t)=>e*t,1))}})});function KA(e){"@babel/helpers - typeof";return KA=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},KA(e)}function qA(e,t){if(KA(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(KA(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function JA(e){var t=qA(e,`string`);return KA(t)==`symbol`?t:t+``}function YA(e,t,n){return(t=JA(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function XA(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ZA(e){for(var t=1;t{var{typed:t,add:n,subtract:r,multiply:i,divide:a,max:o,map:s,abs:c,isPositive:l,isNegative:u,larger:d,smaller:f,matrix:p,bignumber:m,unaryMinus:h}=e;function g(e){return function(t,p,g,_){if(!(p.length===2&&(p.every(S)||p.every(Ay))))throw Error(`"tspan" must be an Array of two numeric values or two units [tStart, tEnd]`);var v=p[0],y=p[1],C=d(y,v),w=_.firstStep;if(w!==void 0&&!l(w))throw Error(`"firstStep" must be positive`);var T=_.maxStep;if(T!==void 0&&!l(T))throw Error(`"maxStep" must be positive`);var E=_.minStep;if(E&&u(E))throw Error(`"minStep" must be positive or zero`);var D=[v,y,w,E,T].filter(e=>e!==void 0);if(!(D.every(S)||D.every(Ay)))throw Error(`Inconsistent type of "t" dependant variables`);for(var O=1,k=_.tol?_.tol:1e-4,A=_.minDelta?_.minDelta:.2,j=_.maxDelta?_.maxDelta:5,M=_.maxIter?_.maxIter:1e4,N=[v,y,...g,T,E].some(Ey),[ee,te,ne,re]=N?[m(e.a),m(e.c),m(e.b),m(e.bp)]:[e.a,e.c,e.b,e.bp],P=w?C?w:h(w):a(r(y,v),O),F=[v],ie=[g],I=r(ne,re),ae=0,oe=0,L=b(C),R=x(C);L(F[ae],y);){var se=[];P=R(F[ae],y,P),se.push(t(F[ae],ie[ae]));for(var ce=1;ceAy(e)?e.value:e)));le1/4&&(F.push(n(F[ae],P)),ie.push(n(ie[ae],i(P,ne,se))),ae++);var ue=.84*(k/le)**(1/5);if(f(ue,A)?ue=A:d(ue,j)&&(ue=j),ue=N?m(ue):ue,P=i(P,ue),T&&d(c(P),T)?P=C?T:h(T):E&&f(c(P),E)&&(P=C?E:h(E)),oe++,oe>M)throw Error(`Maximum number of iterations reached, try changing options`)}return{t:F,y:ie}}}function _(e,t,n,r){return g({a:[[],[1/2],[0,3/4],[2/9,1/3,4/9]],c:[null,1/2,3/4,1],b:[2/9,1/3,4/9,0],bp:[7/24,1/4,1/3,1/8]})(e,t,n,r)}function v(e,t,n,r){return g({a:[[],[1/5],[3/40,9/40],[44/45,-56/15,32/9],[19372/6561,-25360/2187,64448/6561,-212/729],[9017/3168,-355/33,46732/5247,49/176,-5103/18656],[35/384,0,500/1113,125/192,-2187/6784,11/84]],c:[null,1/5,3/10,4/5,8/9,1,1],b:[35/384,0,500/1113,125/192,-2187/6784,11/84,0],bp:[5179/57600,0,7571/16695,393/640,-92097/339200,187/2100,1/40]})(e,t,n,r)}function y(e,t,n,r){var i=r.method?r.method:`RK45`,a={RK23:_,RK45:v};if(i.toUpperCase()in a){var o=ZA({},r);return delete o.method,a[i.toUpperCase()](e,t,n,o)}else{var s=Object.keys(a).map(e=>`"${e}"`),c=`${s.slice(0,-1).join(`, `)} and ${s.slice(-1)}`;throw Error(`Unavailable method "${i}". Available methods are ${c}`)}}function b(e){return e?f:d}function x(e){var t=e?d:f;return function(e,i,a){return t(n(e,a),i)?r(i,e):a}}function S(e){return Ey(e)||Ty(e)}function C(e,t,n,r){var i=y(e,t.toArray(),n.toArray(),r);return{t:p(i.t),y:p(i.y)}}return t(`solveODE`,{"function, Array, Array, Object":y,"function, Matrix, Matrix, Object":C,"function, Array, Array":(e,t,n)=>y(e,t,n,{}),"function, Matrix, Matrix":(e,t,n)=>C(e,t,n,{}),"function, Array, number | BigNumber | Unit":(e,t,n)=>{var r=y(e,t,[n],{});return{t:r.t,y:r.y.map(e=>e[0])}},"function, Matrix, number | BigNumber | Unit":(e,t,n)=>{var r=y(e,t.toArray(),[n],{});return{t:p(r.t),y:p(r.y.map(e=>e[0]))}},"function, Array, number | BigNumber | Unit, Object":(e,t,n,r)=>{var i=y(e,t,[n],r);return{t:i.t,y:i.y.map(e=>e[0])}},"function, Matrix, number | BigNumber | Unit, Object":(e,t,n,r)=>{var i=y(e,t.toArray(),[n],r);return{t:p(i.t),y:p(i.y.map(e=>e[0]))}}})}),$A=Y(`erf`,[`typed`],e=>{var{typed:t}=e;return t(`name`,{number:function(e){var t=Math.abs(e);return t>=ij?Ib(e):t<=ej?Ib(e)*n(t):t<=4?Ib(e)*(1-r(t)):Ib(e)*(1-i(t))},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))});function n(e){var t=e*e,n=nj[0][4]*t,r=t,i;for(i=0;i<3;i+=1)n=(n+nj[0][i])*t,r=(r+rj[0][i])*t;return e*(n+nj[0][3])/(r+rj[0][3])}function r(e){var t=nj[1][8]*e,n=e,r;for(r=0;r<7;r+=1)t=(t+nj[1][r])*e,n=(n+rj[1][r])*e;var i=(t+nj[1][7])/(n+rj[1][7]),a=parseInt(e*16)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}function i(e){var t=1/(e*e),n=nj[2][5]*t,r=t,i;for(i=0;i<4;i+=1)n=(n+nj[2][i])*t,r=(r+rj[2][i])*t;var a=t*(n+nj[2][4])/(r+rj[2][4]);a=(tj-a)/e,t=parseInt(e*16)/16;var o=(e-t)*(e+t);return Math.exp(-t*t)*Math.exp(-o)*a}}),ej=.46875,tj=.5641895835477563,nj=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],rj=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],ij=2**53,aj=`zeta`,oj=Y(aj,[`typed`,`config`,`multiply`,`pow`,`divide`,`factorial`,`equal`,`smallerEq`,`isBounded`,`isNegative`,`gamma`,`sin`,`subtract`,`add`,`?Complex`,`?BigNumber`,`pi`],e=>{var{typed:t,config:n,multiply:r,pow:i,divide:a,factorial:o,equal:s,smallerEq:c,isBounded:l,isNegative:u,gamma:d,sin:f,subtract:p,add:m,Complex:h,BigNumber:g,pi:_}=e;return t(aj,{number:e=>v(e,e=>e,()=>20),BigNumber:e=>v(e,e=>new g(e),()=>Math.abs(Math.log10(n.relTol))),Complex:y});function v(e,t,n){return s(e,0)?t(-.5):s(e,1)?t(NaN):l(e)?b(e,t,n,e=>e):u(e)?t(NaN):t(1)}function y(e){return e.re===0&&e.im===0?new h(-.5):e.re===1?new h(NaN,NaN):e.re===1/0&&e.im===0?new h(1):e.im===1/0||e.re===-1/0?new h(NaN,NaN):b(e,e=>e,e=>Math.round(1.3*15+.9*Math.abs(e.im)),e=>e.re)}function b(e,t,n,o){var s=n(e);if(o(e)>-(s-1)/2)return S(e,t(s),t);var c=r(i(2,e),i(t(_),p(e,1)));return c=r(c,f(r(a(t(_),2),e))),c=r(c,d(p(1,e))),r(c,b(p(1,e),t,n,o))}function x(e,t){for(var n=e,s=e;c(s,t);s=m(s,1)){var l=a(r(o(m(t,p(s,1))),i(4,s)),r(o(p(t,s)),o(r(2,s))));n=m(n,l)}return r(t,n)}function S(e,t,n){for(var o=a(1,r(x(n(0),t),p(1,i(2,p(1,e))))),s=n(0),l=n(1);c(l,t);l=m(l,1))s=m(s,a(r((-1)**(l-1),x(l,t)),i(l,e)));return r(o,s)}}),sj=`mode`,cj=Y(sj,[`typed`,`isNaN`,`isNumeric`],e=>{var{typed:t,isNaN:n,isNumeric:r}=e;return t(sj,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(e=gw(e.valueOf()),e.length===0)throw Error(`Cannot calculate mode of an empty array`);for(var t={},i=[],a=0,o=0;oa&&(a=t[s],i=[s])}return i}});function lj(e,t,n){var r;return String(e).includes(`Unexpected type`)?(r=arguments.length>2?` (type: `+hb(n)+`, value: `+JSON.stringify(n)+`)`:` (type: `+e.data.actual+`)`,TypeError(`Cannot calculate `+t+`, unexpected type of argument`+r)):String(e).includes(`complex numbers`)?(r=arguments.length>2?` (type: `+hb(n)+`, value: `+JSON.stringify(n)+`)`:``,TypeError(`Cannot calculate `+t+`, no ordering relation is defined for complex numbers`+r)):e}var uj=`prod`,dj=Y(uj,[`typed`,`config`,`multiplyScalar`,`numeric`],e=>{var{typed:t,config:n,multiplyScalar:r,numeric:i}=e;return t(uj,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){throw Error(`prod(A, dim) is not yet supported`)},"...":function(e){return a(e)}});function a(e){var t;if(Kw(e,function(e){try{t=t===void 0?e:r(t,e)}catch(t){throw lj(t,`prod`,e)}}),typeof t==`string`&&(t=i(t,Fb(t,n))),t===void 0)throw Error(`Cannot calculate prod of an empty array`);return t}}),fj=`format`,pj=Y(fj,[`typed`],e=>{var{typed:t}=e;return t(fj,{any:WC,"any, Object | function | number | BigNumber":WC})}),mj=`bin`,hj=Y(mj,[`typed`,`format`],e=>{var{typed:t,format:n}=e;return t(mj,{"number | BigNumber":function(e){return n(e,{notation:`bin`})},"number | BigNumber, number | BigNumber":function(e,t){return n(e,{notation:`bin`,wordSize:t})}})}),gj=`oct`,_j=Y(gj,[`typed`,`format`],e=>{var{typed:t,format:n}=e;return t(gj,{"number | BigNumber":function(e){return n(e,{notation:`oct`})},"number | BigNumber, number | BigNumber":function(e,t){return n(e,{notation:`oct`,wordSize:t})}})}),vj=`hex`,yj=Y(vj,[`typed`,`format`],e=>{var{typed:t,format:n}=e;return t(vj,{"number | BigNumber":function(e){return n(e,{notation:`hex`})},"number | BigNumber, number | BigNumber":function(e,t){return n(e,{notation:`hex`,wordSize:t})}})}),bj=/\$([\w.]+)/g,xj=`print`,Sj=Y(xj,[`typed`],e=>{var{typed:t}=e;return t(xj,{"string, Object | Array":Cj,"string, Object | Array, number | Object":Cj})});function Cj(e,t,n){return e.replace(bj,function(e,r){var i=r.split(`.`),a=t[i.shift()];for(a!==void 0&&a.isMatrix&&(a=a.toArray());i.length&&a!==void 0;){var o=i.shift();a=o?a[o]:a+`.`}return a===void 0?e:jy(a)?a:WC(a,n)})}var wj=`to`,Tj=Y(wj,[`typed`,`matrix`,`concat`],e=>{var{typed:t,matrix:n,concat:r}=e;return t(wj,{"Unit, Unit | string":(e,t)=>e.to(t)},_O({typed:t,matrix:n,concat:r})({Ds:!0}))}),Ej=`toBest`,Dj=Y(Ej,[`typed`],e=>{var{typed:t}=e;return t(Ej,{Unit:e=>e.toBest(),"Unit, string":(e,t)=>e.toBest(t.split(`,`)),"Unit, string, Object":(e,t,n)=>e.toBest(t.split(`,`),n),"Unit, Array":(e,t)=>e.toBest(t),"Unit, Array, Object":(e,t,n)=>e.toBest(t,n)})}),Oj=`isPrime`,kj=Y(Oj,[`typed`],e=>{var{typed:t}=e;return t(Oj,{number:function(e){if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t===0||e%(t+2)===0)return!1;return!0},bigint:function(e){if(e<=3n)return e>1n;if(e%2n==0n||e%3n==0n)return!1;for(var t=5n;t*t<=e;t+=6n)if(e%t===0n||e%(t+2n)===0n)return!1;return!0},BigNumber:function(e){if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(2**32)){for(var t=e.toNumber(),n=5;n*n<=t;n+=6)if(t%n===0||t%(n+2)===0)return!1;return!0}function r(e,t,n){for(var r=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(n)):(t=t.sub(1),r=e.mul(r).mod(n));return r}e=new(e.constructor.clone({precision:e.toFixed(0).length*2}))(e);for(var i=0,a=e.sub(1);a.mod(2).eq(0);)a=a.div(2),i+=1;var o=null;if(e.lt(`3317044064679887385961981`))o=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(t=>tt=>qw(t,e))})}),Aj=Y(`numeric`,[`number`,`?bignumber`,`?fraction`],e=>{var{number:t,bignumber:n,fraction:r}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:n?e=>n(e):fA,bigint:e=>BigInt(e),Fraction:r?e=>r(e):pA};return function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`number`;if((arguments.length>2?arguments[2]:void 0)!==void 0)throw SyntaxError(`numeric() takes one or two arguments`);var n=hb(e);if(!(n in i))throw TypeError(`Cannot convert `+e+` of type "`+n+`"; valid input types are `+Object.keys(i).join(`, `));if(!(t in a))throw TypeError(`Cannot convert `+e+` to type "`+t+`"; valid output types are `+Object.keys(a).join(`, `));return t===n?e:a[t](e)}}),jj=`divideScalar`,Mj=Y(jj,[`typed`,`numeric`],e=>{var{typed:t,numeric:n}=e;return t(jj,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"bigint, bigint":function(e,t){return e/t},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Complex | Fraction | BigNumber | Unit":(e,t)=>e.divide(t),"number | Fraction | Complex | BigNumber, Unit":(e,t)=>t.divideInto(e)})}),Nj=`pow`,Pj=Y(Nj,[`typed`,`config`,`identity`,`multiply`,`matrix`,`inv`,`fraction`,`number`,`Complex`],e=>{var{typed:t,config:n,identity:r,multiply:i,matrix:a,inv:o,number:s,fraction:c,Complex:l}=e;return t(Nj,{"number, number":u,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||n.predictable?e.pow(t):new l(e.toNumber(),0).pow(t.toNumber(),0)},"bigint, bigint":(e,t)=>e**t,"Fraction, Fraction":function(e,t){var r=e.pow(t);if(r!=null)return r;if(n.predictable)throw Error(`Result of pow is non-rational and cannot be expressed as a fraction`);return u(e.valueOf(),t.valueOf())},"Array, number":d,"Array, BigNumber":function(e,t){return d(e,t.toNumber())},"Matrix, number":f,"Matrix, BigNumber":function(e,t){return f(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function u(e,t){if(n.predictable&&!X(t)&&e<0)try{var r=c(t),i=s(r);if((t===i||Math.abs((t-i)/t)<1e-14)&&r.d%2n==1n)return(r.n%2n==0n?1:-1)*(-e)**+t}catch{}return n.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:X(t)||e>=0||n.predictable?wT(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new l(e,0).pow(t,0)}function d(e,t){if(!X(t))throw TypeError(`For A^b, b must be an integer (value is `+t+`)`);var n=ew(e);if(n.length!==2)throw Error(`For A^b, A must be 2 dimensional (A has `+n.length+` dimensions)`);if(n[0]!==n[1])throw Error(`For A^b, A must be square (size is `+n[0]+`x`+n[1]+`)`);if(t<0)try{return d(o(e),-t)}catch(e){throw e.message===`Cannot calculate inverse, determinant is zero`?TypeError(`For A^b, when A is not invertible, b must be a positive integer (value is `+t+`)`):e}for(var a=r(n[0]).valueOf(),s=e;t>=1;)(t&1)==1&&(a=i(s,a)),t>>=1,s=i(s,s);return a}function f(e,t){return a(d(e.valueOf(),t))}}),Fj=`Number of decimals in function round must be an integer`,Ij=`round`,Lj=Y(Ij,[`typed`,`config`,`matrix`,`equalScalar`,`zeros`,`BigNumber`,`DenseMatrix`],e=>{var{typed:t,config:n,matrix:r,equalScalar:i,zeros:a,BigNumber:o,DenseMatrix:s}=e,c=HD({typed:t,equalScalar:i}),l=UD({typed:t,DenseMatrix:s}),u=WD({typed:t});function d(e){return Math.abs(Gb(e).exponent)}return t(Ij,{number:function(e){var t=TT(e,d(n.relTol));return TT($b(e,t,n.relTol,n.absTol)?t:e)},"number, number":function(e,t){var r=d(n.relTol);if(t>=r)return TT(e,t);var i=TT(e,r);return TT($b(e,i,n.relTol,n.absTol)?i:e,t)},"number, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(Fj);return new o(e).toDecimalPlaces(t.toNumber())},Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw TypeError(Fj);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(Fj);var n=t.toNumber();return e.round(n)},BigNumber:function(e){var t=new o(e).toDecimalPlaces(d(n.relTol));return(NE(e,t,n.relTol,n.absTol)?t:e).toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(Fj);var r=d(n.relTol);if(t>=r)return e.toDecimalPlaces(t.toNumber());var i=e.toDecimalPlaces(r);return(NE(e,i,n.relTol,n.absTol)?i:e).toDecimalPlaces(t.toNumber())},bigint:e=>e,"bigint, number":(e,t)=>e,"bigint, BigNumber":(e,t)=>e,Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw TypeError(Fj);return e.round(t)},"Fraction, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(Fj);return e.round(t.toNumber())},"Unit, number, Unit":t.referToSelf(e=>function(t,n,r){var i=t.toNumeric(r);return r.multiply(e(i,n))}),"Unit, BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>e(t,n.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>qw(t,t=>e(t,n,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(e=>(t,n)=>e(t,0,n)),"Array | Matrix":t.referToSelf(e=>t=>qw(t,e,!0)),"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>c(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>u(t,n,e,!1)),"Array, number | BigNumber":t.referToSelf(e=>(t,n)=>u(r(t),n,e,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":t.referToSelf(e=>(t,n)=>i(t,0)?a(n.size(),n.storage()):l(n,t,e,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":t.referToSelf(e=>(t,n)=>i(t,0)?a(n.size(),n.storage()):u(n,t,e,!0)),"number | Complex | BigNumber | Fraction, Array":t.referToSelf(e=>(t,n)=>u(r(n),t,e,!0).valueOf())})}),Rj=`log`,zj=[`config`,`typed`,`typeOf`,`divideScalar`,`Complex`],Bj=Math.log(16),Vj=Y(Rj,zj,e=>{var{typed:t,typeOf:n,config:r,divideScalar:i,Complex:a}=e;function o(e){return e.log()}function s(e){return o(new a(e,0))}return t(Rj,{number:function(e){return e>=0||r.predictable?mT(e):s(e)},bigint:NO(Bj,mT,r,s),Complex:o,BigNumber:function(e){return!e.isNegative()||r.predictable?e.ln():s(e.toNumber())},"any, any":t.referToSelf(e=>(t,r)=>{if(n(t)===`Fraction`&&n(r)===`Fraction`){var a=t.log(r);if(a!==null)return a}return i(e(t),e(r))})})}),Hj=`log1p`,Uj=Y(Hj,[`typed`,`config`,`divideScalar`,`log`,`Complex`],e=>{var{typed:t,config:n,divideScalar:r,log:i,Complex:a}=e;return t(Hj,{number:function(e){return e>=-1||n.predictable?zb(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||n.predictable?t.ln():o(new a(e.toNumber(),0))},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e)),"any, any":t.referToSelf(e=>(t,n)=>r(e(t),i(n)))});function o(e){var t=e.re+1;return new a(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}}),Wj=`nthRoots`,Gj=Y(Wj,[`config`,`typed`,`divideScalar`,`Complex`],e=>{var{typed:t,config:n,divideScalar:r,Complex:i}=e,a=[function(e){return new i(e,0)},function(e){return new i(0,e)},function(e){return new i(-e,0)},function(e){return new i(0,-e)}];function o(e,t){if(t<0)throw Error(`Root must be greater than zero`);if(t===0)throw Error(`Root must be non-zero`);if(t%1!=0)throw Error(`Root must be an integer`);if(e===0||e.abs()===0)return[new i(0,0)];var n=typeof e==`number`,r;(n||e.re===0||e.im===0)&&(r=n?2*(e<0):e.im===0?2*(e.re<0):2*(e.im<0)+1);for(var o=e.arg(),s=e.abs(),c=[],l=s**(1/t),u=0;u{var{typed:t,equalScalar:n,matrix:r,pow:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=fO({typed:t}),l=yk({typed:t,SparseMatrix:s}),u=HD({typed:t,equalScalar:n}),d=UD({typed:t,DenseMatrix:a}),f=_O({typed:t,matrix:r,concat:o}),p={};for(var m in i.signatures)Object.prototype.hasOwnProperty.call(i.signatures,m)&&!m.includes(`Matrix`)&&!m.includes(`Array`)&&(p[m]=i.signatures[m]);return t(Kj,f({elop:t(p),SS:l,DS:c,Ss:u,sS:d}))}),Jj=`dotDivide`,Yj=Y(Jj,[`typed`,`matrix`,`equalScalar`,`divideScalar`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,matrix:n,equalScalar:r,divideScalar:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=dO({typed:t,equalScalar:r}),l=fO({typed:t}),u=yk({typed:t,SparseMatrix:s}),d=HD({typed:t,equalScalar:r}),f=UD({typed:t,DenseMatrix:a});return t(Jj,_O({typed:t,matrix:n,concat:o})({elop:i,SS:u,DS:l,SD:c,Ss:d,sS:f}))});function Xj(e){var{DenseMatrix:t}=e;return function(e,n,r){var i=e.size();if(i.length!==2)throw RangeError(`Matrix must be two dimensional (size: `+WC(i)+`)`);var a=i[0];if(a!==i[1])throw RangeError(`Matrix must be square (size: `+WC(i)+`)`);var o=[];if(Ny(n)){var s=n.size(),c=n._data;if(s.length===1){if(s[0]!==a)throw RangeError(`Dimension mismatch. Matrix columns must match vector length.`);for(var l=0;l{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,c=Xj({DenseMatrix:s});return t(Zj,{"SparseMatrix, Array | Matrix":function(e,t){return u(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).valueOf()}});function l(e,t){t=c(e,t,!0);for(var n=t._data,l=e._size[0],u=e._size[1],d=[],f=e._data,p=0;ph&&(v.push(d[S]),y.push(C))}if(o(_,0))throw Error(`Linear system cannot be solved since matrix is singular`);for(var w=r(g,_),T=0,E=y.length;T{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,c=Xj({DenseMatrix:s});return t($j,{"SparseMatrix, Array | Matrix":function(e,t){return u(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).valueOf()}});function l(e,t){t=c(e,t,!0);for(var n=t._data,l=e._size[0],u=e._size[1],d=[],f=e._data,p=u-1;p>=0;p--){var m=n[p][0]||0,h=void 0;if(o(m,0))h=0;else{var g=f[p][p];if(o(g,0))throw Error(`Linear system cannot be solved since matrix is singular`);h=r(m,g);for(var _=p-1;_>=0;_--)n[_]=[a(n[_][0]||0,i(h,f[_][p]))]}d[p]=[h]}return new s({data:d,size:[l,1]})}function u(e,t){t=c(e,t,!0);for(var n=t._data,l=e._size[0],u=e._size[1],d=e._values,f=e._index,p=e._ptr,m=[],h=u-1;h>=0;h--){var g=n[h][0]||0;if(o(g,0))m[h]=[0];else{for(var _=0,v=[],y=[],b=p[h],x=p[h+1]-1;x>=b;x--){var S=f[x];S===h?_=d[x]:S{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,c=Xj({DenseMatrix:s});return t(tM,{"SparseMatrix, Array | Matrix":function(e,t){return u(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).map(e=>e.valueOf())}});function l(e,t){for(var n=[c(e,t,!0)._data.map(e=>e[0])],l=e._data,u=e._size[0],d=e._size[1],f=0;fnew s({data:e.map(e=>[e]),size:[u,1]}))}function u(e,t){for(var n=[c(e,t,!0)._data.map(e=>e[0])],l=e._size[0],u=e._size[1],d=e._values,f=e._index,p=e._ptr,m=0;mm&&(v.push(d[C]),y.push(w))}if(!o(S,0)){_[m]=r(_[m],S);for(var T=0,E=y.length;Tnew s({data:e.map(e=>[e]),size:[l,1]}))}}),rM=`usolveAll`,iM=Y(rM,[`typed`,`matrix`,`divideScalar`,`multiplyScalar`,`subtractScalar`,`equalScalar`,`DenseMatrix`],e=>{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,c=Xj({DenseMatrix:s});return t(rM,{"SparseMatrix, Array | Matrix":function(e,t){return u(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).map(e=>e.valueOf())}});function l(e,t){for(var n=[c(e,t,!0)._data.map(e=>e[0])],l=e._data,u=e._size[0],d=e._size[1]-1;d>=0;d--)for(var f=n.length,p=0;p=0;h--)m[h]=a(m[h],i(m[d],l[h][d]))}else if(!o(m[d],0)){if(p===0)return[];n.splice(p,1),--p,--f}else if(p===0){var g=[...m];g[d]=1;for(var _=d-1;_>=0;_--)g[_]=a(g[_],l[_][d]);n.push(g)}}return n.map(e=>new s({data:e.map(e=>[e]),size:[u,1]}))}function u(e,t){for(var n=[c(e,t,!0)._data.map(e=>e[0])],l=e._size[0],u=e._size[1],d=e._values,f=e._index,p=e._ptr,m=u-1;m>=0;m--)for(var h=n.length,g=0;g=b;C--){var w=f[C];w===m?S=d[C]:wnew s({data:e.map(e=>[e]),size:[l,1]}))}}),aM=Y(`matAlgo08xS0Sid`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._index,s=e._ptr,c=e._size,l=e._datatype||e._data===void 0?e._datatype:e.getDataType(),u=r._values,d=r._index,f=r._ptr,p=r._size,m=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(c.length!==p.length)throw new QC(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw RangeError(`Dimension mismatch. Matrix A (`+c+`) must match Matrix B (`+p+`)`);if(!a||!u)throw Error(`Cannot perform operation on Pattern Sparse Matrices`);var h=c[0],g=c[1],_,v=n,y=0,b=i;typeof l==`string`&&l===m&&l!==`mixed`&&(_=l,v=t.find(n,[_,_]),y=t.convert(0,_),b=t.find(i,[_,_]));for(var x=[],S=[],C=[],w=[],T=[],E,D,O,k,A=0;A{var{typed:t,matrix:n}=e;return{"Array, number":t.referTo(`DenseMatrix, number`,e=>(t,r)=>e(n(t),r).valueOf()),"Array, BigNumber":t.referTo(`DenseMatrix, BigNumber`,e=>(t,r)=>e(n(t),r).valueOf()),"number, Array":t.referTo(`number, DenseMatrix`,e=>(t,r)=>e(t,n(r)).valueOf()),"BigNumber, Array":t.referTo(`BigNumber, DenseMatrix`,e=>(t,r)=>e(t,n(r)).valueOf())}}),sM=`leftShift`,cM=Y(sM,[`typed`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,DenseMatrix:a,concat:o}=e,s=bO({typed:t}),c=dO({typed:t,equalScalar:r}),l=aM({typed:t,equalScalar:r}),u=SO({typed:t,DenseMatrix:a}),d=HD({typed:t,equalScalar:r}),f=WD({typed:t}),p=_O({typed:t,matrix:n,concat:o}),m=oM({typed:t,matrix:n});return t(sM,{"number, number":NT,"BigNumber, BigNumber":dk,"bigint, bigint":(e,t)=>e<(t,n)=>r(n,0)?t.clone():d(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():f(t,n,e,!1)),"number | BigNumber, SparseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):u(n,t,e,!0)),"number | BigNumber, DenseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):f(n,t,e,!0))},m,p({SS:l,DS:s,SD:c}))}),lM=`rightArithShift`,uM=Y(lM,[`typed`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,DenseMatrix:a,concat:o}=e,s=bO({typed:t}),c=dO({typed:t,equalScalar:r}),l=aM({typed:t,equalScalar:r}),u=SO({typed:t,DenseMatrix:a}),d=HD({typed:t,equalScalar:r}),f=WD({typed:t}),p=_O({typed:t,matrix:n,concat:o}),m=oM({typed:t,matrix:n});return t(lM,{"number, number":PT,"BigNumber, BigNumber":fk,"bigint, bigint":(e,t)=>e>>t,"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():d(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():f(t,n,e,!1)),"number | BigNumber, SparseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):u(n,t,e,!0)),"number | BigNumber, DenseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):f(n,t,e,!0))},m,p({SS:l,DS:s,SD:c}))}),dM=`rightLogShift`,fM=Y(dM,[`typed`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,DenseMatrix:a,concat:o}=e,s=bO({typed:t}),c=dO({typed:t,equalScalar:r}),l=aM({typed:t,equalScalar:r}),u=SO({typed:t,DenseMatrix:a}),d=HD({typed:t,equalScalar:r}),f=WD({typed:t}),p=_O({typed:t,matrix:n,concat:o}),m=oM({typed:t,matrix:n});return t(dM,{"number, number":FT,"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():d(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():f(t,n,e,!1)),"number | BigNumber, SparseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):u(n,t,e,!0)),"number | BigNumber, DenseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):f(n,t,e,!0))},m,p({SS:l,DS:s,SD:c}))}),pM=`and`,mM=Y(pM,[`typed`,`matrix`,`equalScalar`,`zeros`,`not`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o}=e,s=dO({typed:t,equalScalar:r}),c=AO({typed:t,equalScalar:r}),l=HD({typed:t,equalScalar:r}),u=WD({typed:t}),d=_O({typed:t,matrix:n,concat:o});return t(pM,{"number, number":qT,"Complex, Complex":function(e,t){return(e.re!==0||e.im!==0)&&(t.re!==0||t.im!==0)},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!t.isZero()&&!e.isNaN()&&!t.isNaN()},"bigint, bigint":qT,"Unit, Unit":t.referToSelf(e=>(t,n)=>e(t.value||0,n.value||0)),"SparseMatrix, any":t.referToSelf(e=>(t,n)=>a(n)?i(t.size(),t.storage()):l(t,n,e,!1)),"DenseMatrix, any":t.referToSelf(e=>(t,n)=>a(n)?i(t.size(),t.storage()):u(t,n,e,!1)),"any, SparseMatrix":t.referToSelf(e=>(t,n)=>a(t)?i(t.size(),t.storage()):l(n,t,e,!0)),"any, DenseMatrix":t.referToSelf(e=>(t,n)=>a(t)?i(t.size(),t.storage()):u(n,t,e,!0)),"Array, any":t.referToSelf(e=>(t,r)=>e(n(t),r).valueOf()),"any, Array":t.referToSelf(e=>(t,r)=>e(t,n(r)).valueOf())},d({SS:c,DS:s}))}),hM=`compare`,gM=Y(hM,[`typed`,`config`,`matrix`,`equalScalar`,`BigNumber`,`Fraction`,`DenseMatrix`,`concat`],e=>{var{typed:t,config:n,equalScalar:r,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:s,concat:c}=e,l=fO({typed:t}),u=pO({typed:t,equalScalar:r}),d=UD({typed:t,DenseMatrix:s}),f=_O({typed:t,matrix:i,concat:c}),p=$E({typed:t});return t(hM,_M({typed:t,config:n}),{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return NE(e,t,n.relTol,n.absTol)?new a(0):new a(e.cmp(t))},"bigint, bigint":function(e,t){return e===t?0n:e>t?1n:-1n},"Fraction, Fraction":function(e,t){return new o(e.compare(t))},"Complex, Complex":function(){throw TypeError(`No ordering relation is defined for complex numbers`)}},p,f({SS:u,DS:l,Ss:d}))}),_M=Y(hM,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(hM,{"number, number":function(e,t){return $b(e,t,n.relTol,n.absTol)?0:e>t?1:-1}})}),vM=l(o(((e,t)=>{t.exports=function e(t,n){"use strict";var r=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,i=/(^[ ]*|[ ]*$)/g,a=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,o=/^0x[0-9a-f]+$/i,s=/^0/,c=function(t){return e.insensitive&&(``+t).toLowerCase()||``+t},l=c(t).replace(i,``)||``,u=c(n).replace(i,``)||``,d=l.replace(r,`\0$1\0`).replace(/\0$/,``).replace(/^\0/,``).split(`\0`),f=u.replace(r,`\0$1\0`).replace(/\0$/,``).replace(/^\0/,``).split(`\0`),p=parseInt(l.match(o),16)||d.length!==1&&l.match(a)&&Date.parse(l),m=parseInt(u.match(o),16)||p&&u.match(a)&&Date.parse(u)||null,h,g;if(m){if(pm)return 1}for(var _=0,v=Math.max(d.length,f.length);_g)return 1}return 0}}))(),1),yM=`compareNatural`,bM=Y(yM,[`typed`,`compare`],e=>{var{typed:t,compare:n}=e,r=n.signatures[`boolean,boolean`];return t(yM,{"any, any":i});function i(e,t){var c=hb(e),l=hb(t),u;if((c===`number`||c===`BigNumber`||c===`Fraction`||c===`bigint`)&&(l===`number`||l===`BigNumber`||l===`Fraction`||l===`bigint`))return u=n(e,t),u.toString()===`0`?(0,vM.default)(c,l):u>0?1:-1;var d=[`Array`,`DenseMatrix`,`SparseMatrix`];if(d.includes(c)||d.includes(l))return u=a(i,e,t),u===0?(0,vM.default)(c,l):u;if(c!==l)return(0,vM.default)(c,l);if(c===`Complex`)return xM(e,t);if(c===`Unit`)return e.equalBase(t)?i(e.value,t.value):o(i,e.formatUnits(),t.formatUnits());if(c===`boolean`)return r(e,t);if(c===`string`)return(0,vM.default)(e,t);if(c===`Object`)return s(i,e,t);if(c===`null`||c===`undefined`)return 0;throw TypeError(`Unsupported type of value "`+c+`"`)}function a(e,t,n){return Iy(t)&&Iy(n)?o(e,t.toJSON().values,n.toJSON().values):Iy(t)?a(e,t.toArray(),n):Iy(n)?a(e,t,n.toArray()):Fy(t)?a(e,t.toJSON().data,n):Fy(n)?a(e,t,n.toJSON().data):Array.isArray(t)?Array.isArray(n)?o(e,t,n):a(e,t,[n]):a(e,[t],n)}function o(e,t,n){for(var r=0,i=Math.min(t.length,n.length);rn.length?1:t.lengtht.re?1:e.ret.im?1:e.im{var{typed:t,matrix:n,concat:r}=e;return t(SM,ZC,_O({typed:t,matrix:n,concat:r})({elop:ZC,Ds:!0}))}),TM=`equal`,EM=Y(TM,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a,SparseMatrix:o}=e,s=fO({typed:t}),c=yk({typed:t,SparseMatrix:o}),l=UD({typed:t,DenseMatrix:i}),u=_O({typed:t,matrix:n});return t(TM,DM({typed:t,equalScalar:r}),u({elop:r,SS:c,DS:s,Ss:l}))}),DM=Y(TM,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return t(TM,{"any, any":function(e,t){return e===null?t===null:t===null?e===null:e===void 0?t===void 0:t===void 0?e===void 0:n(e,t)}})}),OM=`equalText`,kM=Y(OM,[`typed`,`compareText`,`isZero`],e=>{var{typed:t,compareText:n,isZero:r}=e;return t(OM,{"any, any":function(e,t){return r(n(e,t))}})}),AM=`smaller`,jM=Y(AM,[`typed`,`config`,`bignumber`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,config:n,bignumber:r,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=fO({typed:t}),l=yk({typed:t,SparseMatrix:s}),u=UD({typed:t,DenseMatrix:a}),d=_O({typed:t,matrix:i,concat:o}),f=$E({typed:t});function p(e,t){return e.lt(t)&&!NE(e,t,n.relTol,n.absTol)}return t(AM,MM({typed:t,config:n}),{"boolean, boolean":(e,t)=>eee.compare(t)===-1,"Fraction, BigNumber":function(e,t){return p(r(e),t)},"BigNumber, Fraction":function(e,t){return p(e,r(t))},"Complex, Complex":function(e,t){throw TypeError(`No ordering relation is defined for complex numbers`)}},f,d({SS:l,DS:c,Ss:u}))}),MM=Y(AM,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(AM,{"number, number":function(e,t){return e{var{typed:t,config:n,matrix:r,DenseMatrix:i,concat:a,SparseMatrix:o}=e,s=fO({typed:t}),c=yk({typed:t,SparseMatrix:o}),l=UD({typed:t,DenseMatrix:i}),u=_O({typed:t,matrix:r,concat:a}),d=$E({typed:t});return t(NM,FM({typed:t,config:n}),{"boolean, boolean":(e,t)=>e<=t,"BigNumber, BigNumber":function(e,t){return e.lte(t)||NE(e,t,n.relTol,n.absTol)},"bigint, bigint":(e,t)=>e<=t,"Fraction, Fraction":(e,t)=>e.compare(t)!==1,"Complex, Complex":function(){throw TypeError(`No ordering relation is defined for complex numbers`)}},d,u({SS:c,DS:s,Ss:l}))}),FM=Y(NM,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(NM,{"number, number":function(e,t){return e<=t||$b(e,t,n.relTol,n.absTol)}})}),IM=`larger`,LM=Y(IM,[`typed`,`config`,`bignumber`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,config:n,bignumber:r,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=fO({typed:t}),l=yk({typed:t,SparseMatrix:s}),u=UD({typed:t,DenseMatrix:a}),d=_O({typed:t,matrix:i,concat:o}),f=$E({typed:t});function p(e,t){return e.gt(t)&&!NE(e,t,n.relTol,n.absTol)}return t(IM,RM({typed:t,config:n}),{"boolean, boolean":(e,t)=>e>t,"BigNumber, BigNumber":p,"bigint, bigint":(e,t)=>e>t,"Fraction, Fraction":(e,t)=>e.compare(t)===1,"Fraction, BigNumber":function(e,t){return p(r(e),t)},"BigNumber, Fraction":function(e,t){return p(e,r(t))},"Complex, Complex":function(){throw TypeError(`No ordering relation is defined for complex numbers`)}},f,d({SS:l,DS:c,Ss:u}))}),RM=Y(IM,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(IM,{"number, number":function(e,t){return e>t&&!$b(e,t,n.relTol,n.absTol)}})}),zM=`largerEq`,BM=Y(zM,[`typed`,`config`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,config:n,matrix:r,DenseMatrix:i,concat:a,SparseMatrix:o}=e,s=fO({typed:t}),c=yk({typed:t,SparseMatrix:o}),l=UD({typed:t,DenseMatrix:i}),u=_O({typed:t,matrix:r,concat:a}),d=$E({typed:t});return t(zM,VM({typed:t,config:n}),{"boolean, boolean":(e,t)=>e>=t,"BigNumber, BigNumber":function(e,t){return e.gte(t)||NE(e,t,n.relTol,n.absTol)},"bigint, bigint":function(e,t){return e>=t},"Fraction, Fraction":(e,t)=>e.compare(t)!==-1,"Complex, Complex":function(){throw TypeError(`No ordering relation is defined for complex numbers`)}},d,u({SS:c,DS:s,Ss:l}))}),VM=Y(zM,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(zM,{"number, number":function(e,t){return e>=t||$b(e,t,n.relTol,n.absTol)}})}),HM=`deepEqual`,UM=Y(HM,[`typed`,`equal`],e=>{var{typed:t,equal:n}=e;return t(HM,{"any, any":function(e,t){return r(e.valueOf(),t.valueOf())}});function r(e,t){if(Array.isArray(e))if(Array.isArray(t)){var i=e.length;if(i!==t.length)return!1;for(var a=0;a{var{typed:t,config:n,equalScalar:r,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=fO({typed:t}),l=yk({typed:t,SparseMatrix:s}),u=UD({typed:t,DenseMatrix:a}),d=_O({typed:t,matrix:i,concat:o});return t(WM,KM({typed:t,equalScalar:r}),d({elop:f,SS:l,DS:c,Ss:u}));function f(e,t){return!r(e,t)}}),KM=Y(WM,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return t(WM,{"any, any":function(e,t){return e===null?t!==null:t===null?e!==null:e===void 0?t!==void 0:t===void 0?e!==void 0:!n(e,t)}})}),qM=`partitionSelect`,JM=Y(qM,[`typed`,`isNumeric`,`isNaN`,`compare`],e=>{var{typed:t,isNumeric:n,isNaN:r,compare:i}=e,a=i,o=(e,t)=>-i(e,t);return t(qM,{"Array | Matrix, number":function(e,t){return s(e,t,a)},"Array | Matrix, number, string":function(e,t,n){if(n===`asc`)return s(e,t,a);if(n===`desc`)return s(e,t,o);throw Error(`Compare string must be "asc" or "desc"`)},"Array | Matrix, number, function":s});function s(e,t,n){if(!X(t)||t<0)throw Error(`k must be a non-negative integer`);if(Ny(e)){if(e.size().length>1)throw Error(`Only one dimensional matrices supported`);return c(e.valueOf(),t,n)}if(Array.isArray(e))return c(e,t,n)}function c(e,t,i){if(t>=e.length)throw Error(`k out of bounds`);for(var a=0;a=0){var d=e[l];e[l]=e[c],e[c]=d,--l}else ++c;i(e[c],u)>0&&--c,t<=c?s=c:o=c+1}return e[t]}}),YM=`sort`,XM=Y(YM,[`typed`,`matrix`,`compare`,`compareNatural`],e=>{var{typed:t,matrix:n,compare:r,compareNatural:i}=e,a=r,o=(e,t)=>-r(e,t);return t(YM,{Array:function(e){return c(e),e.sort(a)},Matrix:function(e){return l(e),n(e.toArray().sort(a),e.storage())},"Array, function":function(e,t){return c(e),e.sort(t)},"Matrix, function":function(e,t){return l(e),n(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return c(e),e.sort(s(t))},"Matrix, string":function(e,t){return l(e),n(e.toArray().sort(s(t)),e.storage())}});function s(e){if(e===`asc`)return a;if(e===`desc`)return o;if(e===`natural`)return i;throw Error(`String "asc", "desc", or "natural" expected`)}function c(e){if(ew(e).length!==1)throw Error(`One dimensional array expected`)}function l(e){if(e.size().length!==1)throw Error(`One dimensional matrix expected`)}}),ZM=`max`,QM=Y(ZM,[`typed`,`config`,`numeric`,`larger`,`isNaN`],e=>{var{typed:t,config:n,numeric:r,larger:i,isNaN:a}=e;return t(ZM,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return Jw(e,t.valueOf(),o)},"...":function(e){if(Gw(e))throw TypeError(`Scalar values expected in function max`);return s(e)}});function o(e,t){try{return i(e,t)?e:t}catch(e){throw lj(e,`max`,t)}}function s(e){var t;if(Kw(e,function(e){try{(a(e)||t===void 0||i(e,t))&&(t=e)}catch(t){throw lj(t,`max`,e)}}),t===void 0)throw Error(`Cannot calculate max of an empty array`);return typeof t==`string`&&(t=r(t,Fb(t,n))),t}}),$M=`min`,eN=Y($M,[`typed`,`config`,`numeric`,`smaller`,`isNaN`],e=>{var{typed:t,config:n,numeric:r,smaller:i,isNaN:a}=e;return t($M,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return Jw(e,t.valueOf(),o)},"...":function(e){if(Gw(e))throw TypeError(`Scalar values expected in function min`);return s(e)}});function o(e,t){try{return i(e,t)?e:t}catch(e){throw lj(e,`min`,t)}}function s(e){var t;if(Kw(e,function(e){try{(a(e)||t===void 0||i(e,t))&&(t=e)}catch(t){throw lj(t,`min`,e)}}),t===void 0)throw Error(`Cannot calculate min of an empty array`);return typeof t==`string`&&(t=r(t,Fb(t,n))),t}}),tN=Y(`ImmutableDenseMatrix`,[`smaller`,`DenseMatrix`],e=>{var{smaller:t,DenseMatrix:n}=e;function r(e,t){if(!(this instanceof r))throw SyntaxError(`Constructor must be called with the new operator`);if(t&&!jy(t))throw Error(`Invalid datatype: `+t);if(Ny(e)||My(e)){var i=new n(e,t);this._data=i._data,this._size=i._size,this._datatype=i._datatype,this._min=null,this._max=null}else if(e&&My(e.data)&&My(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=e.min===void 0?null:e.min,this._max=e.max===void 0?null:e.max;else if(e)throw TypeError(`Unsupported type of data (`+hb(e)+`)`);else this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}return r.prototype=new n,r.prototype.type=`ImmutableDenseMatrix`,r.prototype.isImmutableDenseMatrix=!0,r.prototype.subset=function(e){switch(arguments.length){case 1:var t=n.prototype.subset.call(this,e);return Ny(t)?new r({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw Error(`Cannot invoke set subset on an Immutable Matrix instance`);default:throw SyntaxError(`Wrong number of arguments`)}},r.prototype.set=function(){throw Error(`Cannot invoke set on an Immutable Matrix instance`)},r.prototype.resize=function(){throw Error(`Cannot invoke resize on an Immutable Matrix instance`)},r.prototype.reshape=function(){throw Error(`Cannot invoke reshape on an Immutable Matrix instance`)},r.prototype.clone=function(){return new r({data:gb(this._data),size:gb(this._size),datatype:this._datatype})},r.prototype.toJSON=function(){return{mathjs:`ImmutableDenseMatrix`,data:this._data,size:this._size,datatype:this._datatype}},r.fromJSON=function(e){return new r(e)},r.prototype.swapRows=function(){throw Error(`Cannot invoke swapRows on an Immutable Matrix instance`)},r.prototype.min=function(){if(this._min===null){var e=null;this.forEach(function(n){(e===null||t(n,e))&&(e=n)}),this._min=e===null?void 0:e}return this._min},r.prototype.max=function(){if(this._max===null){var e=null;this.forEach(function(n){(e===null||t(e,n))&&(e=n)}),this._max=e===null?void 0:e}return this._max},r},{isClass:!0}),nN=Y(`Index`,[`ImmutableDenseMatrix`,`getMatrixDataType`],e=>{var{ImmutableDenseMatrix:t,getMatrixDataType:n}=e;function r(){if(!(this instanceof r))throw SyntaxError(`Constructor must be called with the new operator`);this._dimensions=[],this._sourceSize=[],this._isScalar=!0;for(var e=0,t=arguments.length;e{e&&t.push(n)}),t}var iN=Y(`FibonacciHeap`,[`smaller`,`larger`],e=>{var{smaller:t,larger:n}=e,r=1/Math.log((1+Math.sqrt(5))/2);function i(){if(!(this instanceof i))throw SyntaxError(`Constructor must be called with the new operator`);this._minimum=null,this._size=0}i.prototype.type=`FibonacciHeap`,i.prototype.isFibonacciHeap=!0,i.prototype.insert=function(e,n){var r={key:e,value:n,degree:0};if(this._minimum){var i=this._minimum;r.left=i,r.right=i.right,i.right=r,r.right.left=r,t(e,i.key)&&(this._minimum=r)}else r.left=r,r.right=r,this._minimum=r;return this._size++,r},i.prototype.size=function(){return this._size},i.prototype.clear=function(){this._minimum=null,this._size=0},i.prototype.isEmpty=function(){return this._size===0},i.prototype.extractMinimum=function(){var e=this._minimum;if(e===null)return e;for(var t=this._minimum,n=e.degree,r=e.child;n>0;){var i=r.right;r.left.right=r.right,r.right.left=r.left,r.left=t,r.right=t.right,t.right=r,r.right.left=r,r.parent=null,r=i,n--}return e.left.right=e.right,e.right.left=e.left,e===e.right?t=null:(t=e.right,t=l(t,this._size)),this._size--,this._minimum=t,e},i.prototype.remove=function(e){this._minimum=a(this._minimum,e,-1),this.extractMinimum()};function a(e,n,r){n.key=r;var i=n.parent;return i&&t(n.key,i.key)&&(o(e,n,i),s(e,i)),t(n.key,e.key)&&(e=n),e}function o(e,t,n){t.left.right=t.right,t.right.left=t.left,n.degree--,n.child===t&&(n.child=t.right),n.degree===0&&(n.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function s(e,t){var n=t.parent;n&&(t.mark?(o(e,t,n),s(n)):t.mark=!0)}var c=function(e,t){e.left.right=e.right,e.right.left=e.left,e.parent=t,t.child?(e.left=t.child,e.right=t.child.right,t.child.right=e,e.right.left=e):(t.child=e,e.right=e,e.left=e),t.degree++,e.mark=!1};function l(e,i){var a=Math.floor(Math.log(i)*r)+1,o=Array(a),s=0,l=e;if(l)for(s++,l=l.right;l!==e;)s++,l=l.right;for(var u;s>0;){for(var d=l.degree,f=l.right;u=o[d],u;){if(n(l.key,u.key)){var p=u;u=l,l=p}c(u,l),o[d]=null,d++}o[d]=l,l=f,s--}e=null;for(var m=0;m{var{addScalar:t,equalScalar:n,FibonacciHeap:r}=e;function i(){if(!(this instanceof i))throw SyntaxError(`Constructor must be called with the new operator`);this._values=[],this._heap=new r}return i.prototype.type=`Spa`,i.prototype.isSpa=!0,i.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var n=this._heap.insert(e,t);this._values[e]=n}},i.prototype.get=function(e){var t=this._values[e];return t?t.value:0},i.prototype.accumulate=function(e,n){var r=this._values[e];r?r.value=t(r.value,n):(r=this._heap.insert(e,n),this._values[e]=r)},i.prototype.forEach=function(e,t,r){var i=this._heap,a=this._values,o=[],s=i.extractMinimum();for(s&&o.push(s);s&&s.key<=t;)s.key>=e&&(n(s.value,0)||r(s.key,s.value,this)),s=i.extractMinimum(),s&&o.push(s);for(var c=0;c1&&arguments[1]!==void 0?arguments[1]:{};return n??=1/0,t??=JSON.stringify,function r(){typeof r.cache!=`object`&&(r.cache={values:new Map,lru:oN(n||1/0)});for(var i=[],a=0;a{var{on:t,config:n,addScalar:r,subtractScalar:i,multiplyScalar:a,divideScalar:o,pow:s,abs:c,fix:l,round:u,equal:d,isNumeric:f,format:p,number:m,Complex:h,BigNumber:g,Fraction:_}=e,v=m,y=!1,b=!0;function x(e,t){if(!(this instanceof x))throw Error(`Constructor must be called with the new operator`);if(!(e==null||f(e)||Oy(e)))throw TypeError(`First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined`);if(this.fixPrefix=y,this.skipAutomaticSimplification=b,t===void 0)this.units=[],this.dimensions=ie.map(e=>0);else if(typeof t==`string`){var n=x.parse(t);this.units=n.units,this.dimensions=n.dimensions}else if(Ay(t)&&t.value===null)this.fixPrefix=t.fixPrefix,this.skipAutomaticSimplification=t.skipAutomaticSimplification,this.dimensions=t.dimensions.slice(0),this.units=t.units.map(e=>cy({},e));else throw TypeError(`Second parameter in Unit constructor must be a string or valueless Unit`);this.value=this._normalize(e)}Object.defineProperty(x,"name",{value:`Unit`}),x.prototype.constructor=x,x.prototype.type=`Unit`,x.prototype.isUnit=!0;var S,C,w;function T(){for(;w===` `||w===` `;)O()}function E(e){return e>=`0`&&e<=`9`||e===`.`}function D(e){return e>=`0`&&e<=`9`}function O(){C++,w=S.charAt(C)}function k(e){C=e,w=S.charAt(C)}function A(){var e=``,t=C;if(w===`+`?O():w===`-`&&(e+=w,O()),!E(w))return k(t),null;if(w===`.`){if(e+=w,O(),!D(w))return k(t),null}else{for(;D(w);)e+=w,O();w===`.`&&(e+=w,O())}for(;D(w);)e+=w,O();if(w===`E`||w===`e`){var n=``,r=C;if(n+=w,O(),(w===`+`||w===`-`)&&(n+=w,O()),!D(w))return k(r),e;for(e+=n;D(w);)e+=w,O()}return e}function j(){for(var e=``;D(w)||x.isValidAlpha(w);)e+=w,O();var t=e.charAt(0);return x.isValidAlpha(t)?e:null}function M(e){return w===e?(O(),e):null}x.parse=function(e,t){if(t||={},S=e,C=-1,w=``,typeof S!=`string`)throw TypeError(`Invalid argument in Unit.parse, string expected`);var r=new x;r.units=[];var i=1,a=!1;O(),T();var o=A(),s=null;if(o){if(n.number===`BigNumber`)s=new g(o);else if(n.number===`Fraction`)try{s=new _(o)}catch{s=parseFloat(o)}else s=parseFloat(o);T(),M(`*`)?(i=1,a=!0):M(`/`)&&(i=-1,a=!0)}for(var c=[],l=1;;){for(T();w===`(`;)c.push(i),l*=i,i=1,O(),T();var u=void 0;if(w){var d=w;if(u=j(),u===null)throw SyntaxError(`Unexpected "`+d+`" in "`+S+`" at index `+C.toString())}else break;var f=N(u);if(f===null)throw SyntaxError(`Unit "`+u+`" not found.`);var p=i*l;if(T(),M(`^`)){T();var m=A();if(m===null)throw SyntaxError(`In "`+e+`", "^" must be followed by a floating-point number`);p*=m}r.units.push({unit:f.unit,prefix:f.prefix,power:p});for(var h=0;h1||Math.abs(this.units[0].power-1)>1e-15},x.prototype._normalize=function(e){if(e==null||this.units.length===0)return e;for(var t=e,n=x._getNumberConverter(hb(e)),r=0;r{if(J(L,e)){var t=L[e];return{unit:t,prefix:t.prefixes[``]}}for(var n in L)if(J(L,n)&&UC(e,n)){var r=L[n],i=e.length-n.length,a=e.substring(0,i),o=J(r.prefixes,a)?r.prefixes[a]:void 0;if(o!==void 0)return{unit:r,prefix:o}}return null},{hasher:e=>e[0],limit:100});x.isValuelessUnit=function(e){return N(e)!==null},x.prototype.hasBase=function(e){if(typeof e==`string`&&(e=I[e]),!e)return!1;for(var t=0;t1e-12)return!1;return!0},x.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},x.prototype.equals=function(e){return this.equalBase(e)&&d(this.value,e.value)},x.prototype.multiply=function(e){for(var t=this.clone(),n=Ay(e)?e:new x(e),r=0;r0?this.formatUnits():null,fixPrefix:this.fixPrefix,skipSimp:this.skipAutomaticSimplification}},x.fromJSON=function(e){var t=new x(e.value,e.unit??void 0);return t.fixPrefix=e.fixPrefix??y,t.skipAutomaticSimplification=e.skipSimp??b,t},x.prototype.valueOf=x.prototype.toString,x.prototype.simplify=function(){var e=this.clone(),t=[],n;for(var r in le)if(J(le,r)&&e.hasBase(I[r])){n=r;break}if(n===`NONE`)e.units=[];else{var i;if(n&&J(le,n)&&(i=le[n]),i)e.units=[{unit:i.unit,prefix:i.prefix,power:1}];else{for(var a=!1,o=0;o1e-12&&(J(le,s)?t.push({unit:le[s].unit,prefix:le[s].prefix,power:e.dimensions[o]||0}):a=!0)}t.length1e-12)if(J(ce.si,r))t.push({unit:ce.si[r].unit,prefix:ce.si[r].prefix,power:e.dimensions[n]||0});else throw Error(`Cannot express custom unit `+r+` in SI units`)}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,this.value===null?e:(e.value=null,this.to(e))},x.prototype.formatUnits=function(){for(var e=``,t=``,n=0,r=0,i=0;i0?(n++,e+=` `+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+=`^`+this.units[i].power)):this.units[i].power<0&&r++;if(r>0)for(var a=0;a0?(t+=` `+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power+1)>1e-15&&(t+=`^`+-this.units[a].power)):(t+=` `+this.units[a].prefix.name+this.units[a].unit.name,t+=`^`+this.units[a].power));e=e.substr(1),t=t.substr(1),n>1&&r>0&&(e=`(`+e+`)`),r>1&&n>0&&(t=`(`+t+`)`);var o=e;return n>0&&r>0&&(o+=` / `),o+=t,o},x.prototype.toBest=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e&&!Array.isArray(e))throw Error(`Invalid unit type. Expected string or Unit.`);var n=this.units[0].unit.prefixes;if(e&&e.length>0){var r=e.map(e=>{var t=null;if(typeof e==`string`){if(t=x.parse(e),!t)throw Error(`Invalid unit type. Expected compatible string or Unit.`)}else if(!Ay(e))throw Error(`Invalid unit type. Expected compatible string or Unit.`);t===null&&(t=e.clone());try{return this.to(t.formatUnits()),t}catch{throw Error(`Invalid unit type. Expected compatible string or Unit.`)}}).map(e=>e.units[0].prefix);this.units[0].unit.prefixes=r.reduce((e,t)=>(e[t.name]=t,e),{}),this.units[0].prefix=r[0]}var i=ne(this,t).simp;return this.units[0].unit.prefixes=n,i.fixPrefix=!0,i},x.prototype.format=function(e){var{simp:t,valueStr:n,unitStr:r}=ne(this,e),i=n;return t.value&&Oy(t.value)&&(i=`(`+i+`)`),r.length>0&&i.length>0&&(i+=` `),i+=r,i};function ne(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=e.skipAutomaticSimplification||e.value===null?e.clone():e.simplify();re(n),P(n,t.offset);var r=n._denormalize(n.value);return{simp:n,valueStr:n.value===null?``:p(r,t||{}),unitStr:n.formatUnits()}}function re(e){var t=!1;for(var n in e.value!==void 0&&e.value!==null&&Oy(e.value)&&(t=Math.abs(e.value.re)<1e-14),e.units)J(e.units,n)&&e.units[n].unit&&(e.units[n].unit.name===`VA`&&t?e.units[n].unit=L.VAR:e.units[n].unit.name===`VAR`&&!t&&(e.units[n].unit=L.VA))}function P(e,t){e.units.length===1&&!e.fixPrefix&&Math.abs(e.units[0].power-Math.round(e.units[0].power))<1e-14&&(e.units[0].prefix=e._bestPrefix(t))}x.prototype._bestPrefix=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1.2;if(this.units.length!==1||Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw Error(`Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!`);var t=this.value===null?0:c(this.value),n=c(this.units[0].unit.value),r=this.units[0].prefix;if(t===0)return r;var i=this.units[0].power,a=Math.log(t/(r.value*n)**+i)/Math.LN10-e;if(a>-2.200001&&a<1.800001)return r;a=Math.abs(a);var o=this.units[0].unit.prefixes;for(var s in o)if(J(o,s)){var l=o[s];if(l.scientific){var u=Math.abs(Math.log(t/(l.value*n)**+i)/Math.LN10-e);(u0)},L={meter:{name:`meter`,base:I.LENGTH,prefixes:F.LONG,value:1,offset:0},inch:{name:`inch`,base:I.LENGTH,prefixes:F.NONE,value:.0254,offset:0},foot:{name:`foot`,base:I.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yard:{name:`yard`,base:I.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mile:{name:`mile`,base:I.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},link:{name:`link`,base:I.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rod:{name:`rod`,base:I.LENGTH,prefixes:F.NONE,value:5.0292,offset:0},chain:{name:`chain`,base:I.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},angstrom:{name:`angstrom`,base:I.LENGTH,prefixes:F.NONE,value:1e-10,offset:0},m:{name:`m`,base:I.LENGTH,prefixes:F.SHORT,value:1,offset:0},in:{name:`in`,base:I.LENGTH,prefixes:F.NONE,value:.0254,offset:0},ft:{name:`ft`,base:I.LENGTH,prefixes:F.NONE,value:.3048,offset:0},yd:{name:`yd`,base:I.LENGTH,prefixes:F.NONE,value:.9144,offset:0},mi:{name:`mi`,base:I.LENGTH,prefixes:F.NONE,value:1609.344,offset:0},li:{name:`li`,base:I.LENGTH,prefixes:F.NONE,value:.201168,offset:0},rd:{name:`rd`,base:I.LENGTH,prefixes:F.NONE,value:5.02921,offset:0},ch:{name:`ch`,base:I.LENGTH,prefixes:F.NONE,value:20.1168,offset:0},mil:{name:`mil`,base:I.LENGTH,prefixes:F.NONE,value:254e-7,offset:0},m2:{name:`m2`,base:I.SURFACE,prefixes:F.SQUARED,value:1,offset:0},sqin:{name:`sqin`,base:I.SURFACE,prefixes:F.NONE,value:64516e-8,offset:0},sqft:{name:`sqft`,base:I.SURFACE,prefixes:F.NONE,value:.09290304,offset:0},sqyd:{name:`sqyd`,base:I.SURFACE,prefixes:F.NONE,value:.83612736,offset:0},sqmi:{name:`sqmi`,base:I.SURFACE,prefixes:F.NONE,value:2589988.110336,offset:0},sqrd:{name:`sqrd`,base:I.SURFACE,prefixes:F.NONE,value:25.29295,offset:0},sqch:{name:`sqch`,base:I.SURFACE,prefixes:F.NONE,value:404.6873,offset:0},sqmil:{name:`sqmil`,base:I.SURFACE,prefixes:F.NONE,value:64516e-14,offset:0},acre:{name:`acre`,base:I.SURFACE,prefixes:F.NONE,value:4046.86,offset:0},hectare:{name:`hectare`,base:I.SURFACE,prefixes:F.NONE,value:1e4,offset:0},m3:{name:`m3`,base:I.VOLUME,prefixes:F.CUBIC,value:1,offset:0},L:{name:`L`,base:I.VOLUME,prefixes:F.SHORT,value:.001,offset:0},l:{name:`l`,base:I.VOLUME,prefixes:F.SHORT,value:.001,offset:0},litre:{name:`litre`,base:I.VOLUME,prefixes:F.LONG,value:.001,offset:0},cuin:{name:`cuin`,base:I.VOLUME,prefixes:F.NONE,value:16387064e-12,offset:0},cuft:{name:`cuft`,base:I.VOLUME,prefixes:F.NONE,value:.028316846592,offset:0},cuyd:{name:`cuyd`,base:I.VOLUME,prefixes:F.NONE,value:.764554857984,offset:0},teaspoon:{name:`teaspoon`,base:I.VOLUME,prefixes:F.NONE,value:5e-6,offset:0},tablespoon:{name:`tablespoon`,base:I.VOLUME,prefixes:F.NONE,value:15e-6,offset:0},drop:{name:`drop`,base:I.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},gtt:{name:`gtt`,base:I.VOLUME,prefixes:F.NONE,value:5e-8,offset:0},minim:{name:`minim`,base:I.VOLUME,prefixes:F.NONE,value:6.1611519921875e-8,offset:0},fluiddram:{name:`fluiddram`,base:I.VOLUME,prefixes:F.NONE,value:36966911953125e-19,offset:0},fluidounce:{name:`fluidounce`,base:I.VOLUME,prefixes:F.NONE,value:295735295625e-16,offset:0},gill:{name:`gill`,base:I.VOLUME,prefixes:F.NONE,value:.00011829411825,offset:0},cc:{name:`cc`,base:I.VOLUME,prefixes:F.NONE,value:1e-6,offset:0},cup:{name:`cup`,base:I.VOLUME,prefixes:F.NONE,value:.0002365882365,offset:0},pint:{name:`pint`,base:I.VOLUME,prefixes:F.NONE,value:.000473176473,offset:0},quart:{name:`quart`,base:I.VOLUME,prefixes:F.NONE,value:.000946352946,offset:0},gallon:{name:`gallon`,base:I.VOLUME,prefixes:F.NONE,value:.003785411784,offset:0},beerbarrel:{name:`beerbarrel`,base:I.VOLUME,prefixes:F.NONE,value:.117347765304,offset:0},oilbarrel:{name:`oilbarrel`,base:I.VOLUME,prefixes:F.NONE,value:.158987294928,offset:0},hogshead:{name:`hogshead`,base:I.VOLUME,prefixes:F.NONE,value:.238480942392,offset:0},g:{name:`g`,base:I.MASS,prefixes:F.SHORT,value:.001,offset:0},gram:{name:`gram`,base:I.MASS,prefixes:F.LONG,value:.001,offset:0},ton:{name:`ton`,base:I.MASS,prefixes:F.SHORT,value:907.18474,offset:0},t:{name:`t`,base:I.MASS,prefixes:F.SHORT,value:1e3,offset:0},tonne:{name:`tonne`,base:I.MASS,prefixes:F.LONG,value:1e3,offset:0},grain:{name:`grain`,base:I.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dram:{name:`dram`,base:I.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},ounce:{name:`ounce`,base:I.MASS,prefixes:F.NONE,value:.028349523125,offset:0},poundmass:{name:`poundmass`,base:I.MASS,prefixes:F.NONE,value:.45359237,offset:0},hundredweight:{name:`hundredweight`,base:I.MASS,prefixes:F.NONE,value:45.359237,offset:0},stick:{name:`stick`,base:I.MASS,prefixes:F.NONE,value:.115,offset:0},stone:{name:`stone`,base:I.MASS,prefixes:F.NONE,value:6.35029318,offset:0},gr:{name:`gr`,base:I.MASS,prefixes:F.NONE,value:6479891e-11,offset:0},dr:{name:`dr`,base:I.MASS,prefixes:F.NONE,value:.0017718451953125,offset:0},oz:{name:`oz`,base:I.MASS,prefixes:F.NONE,value:.028349523125,offset:0},lbm:{name:`lbm`,base:I.MASS,prefixes:F.NONE,value:.45359237,offset:0},cwt:{name:`cwt`,base:I.MASS,prefixes:F.NONE,value:45.359237,offset:0},s:{name:`s`,base:I.TIME,prefixes:F.SHORT,value:1,offset:0},min:{name:`min`,base:I.TIME,prefixes:F.NONE,value:60,offset:0},h:{name:`h`,base:I.TIME,prefixes:F.NONE,value:3600,offset:0},second:{name:`second`,base:I.TIME,prefixes:F.LONG,value:1,offset:0},sec:{name:`sec`,base:I.TIME,prefixes:F.LONG,value:1,offset:0},minute:{name:`minute`,base:I.TIME,prefixes:F.NONE,value:60,offset:0},hour:{name:`hour`,base:I.TIME,prefixes:F.NONE,value:3600,offset:0},day:{name:`day`,base:I.TIME,prefixes:F.NONE,value:86400,offset:0},week:{name:`week`,base:I.TIME,prefixes:F.NONE,value:7*86400,offset:0},month:{name:`month`,base:I.TIME,prefixes:F.NONE,value:2629800,offset:0},year:{name:`year`,base:I.TIME,prefixes:F.NONE,value:31557600,offset:0},decade:{name:`decade`,base:I.TIME,prefixes:F.NONE,value:315576e3,offset:0},century:{name:`century`,base:I.TIME,prefixes:F.NONE,value:315576e4,offset:0},millennium:{name:`millennium`,base:I.TIME,prefixes:F.NONE,value:315576e5,offset:0},hertz:{name:`Hertz`,base:I.FREQUENCY,prefixes:F.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:`Hz`,base:I.FREQUENCY,prefixes:F.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:`rad`,base:I.ANGLE,prefixes:F.SHORT,value:1,offset:0},radian:{name:`radian`,base:I.ANGLE,prefixes:F.LONG,value:1,offset:0},deg:{name:`deg`,base:I.ANGLE,prefixes:F.SHORT,value:null,offset:0},degree:{name:`degree`,base:I.ANGLE,prefixes:F.LONG,value:null,offset:0},grad:{name:`grad`,base:I.ANGLE,prefixes:F.SHORT,value:null,offset:0},gradian:{name:`gradian`,base:I.ANGLE,prefixes:F.LONG,value:null,offset:0},cycle:{name:`cycle`,base:I.ANGLE,prefixes:F.NONE,value:null,offset:0},arcsec:{name:`arcsec`,base:I.ANGLE,prefixes:F.NONE,value:null,offset:0},arcmin:{name:`arcmin`,base:I.ANGLE,prefixes:F.NONE,value:null,offset:0},A:{name:`A`,base:I.CURRENT,prefixes:F.SHORT,value:1,offset:0},ampere:{name:`ampere`,base:I.CURRENT,prefixes:F.LONG,value:1,offset:0},K:{name:`K`,base:I.TEMPERATURE,prefixes:F.SHORT,value:1,offset:0},degC:{name:`degC`,base:I.TEMPERATURE,prefixes:F.SHORT,value:1,offset:273.15},degF:{name:`degF`,base:I.TEMPERATURE,prefixes:F.SHORT,value:new _(5,9),offset:459.67},degR:{name:`degR`,base:I.TEMPERATURE,prefixes:F.SHORT,value:new _(5,9),offset:0},kelvin:{name:`kelvin`,base:I.TEMPERATURE,prefixes:F.LONG,value:1,offset:0},celsius:{name:`celsius`,base:I.TEMPERATURE,prefixes:F.LONG,value:1,offset:273.15},fahrenheit:{name:`fahrenheit`,base:I.TEMPERATURE,prefixes:F.LONG,value:new _(5,9),offset:459.67},rankine:{name:`rankine`,base:I.TEMPERATURE,prefixes:F.LONG,value:new _(5,9),offset:0},mol:{name:`mol`,base:I.AMOUNT_OF_SUBSTANCE,prefixes:F.SHORT,value:1,offset:0},mole:{name:`mole`,base:I.AMOUNT_OF_SUBSTANCE,prefixes:F.LONG,value:1,offset:0},cd:{name:`cd`,base:I.LUMINOUS_INTENSITY,prefixes:F.SHORT,value:1,offset:0},candela:{name:`candela`,base:I.LUMINOUS_INTENSITY,prefixes:F.LONG,value:1,offset:0},N:{name:`N`,base:I.FORCE,prefixes:F.SHORT,value:1,offset:0},newton:{name:`newton`,base:I.FORCE,prefixes:F.LONG,value:1,offset:0},dyn:{name:`dyn`,base:I.FORCE,prefixes:F.SHORT,value:1e-5,offset:0},dyne:{name:`dyne`,base:I.FORCE,prefixes:F.LONG,value:1e-5,offset:0},lbf:{name:`lbf`,base:I.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},poundforce:{name:`poundforce`,base:I.FORCE,prefixes:F.NONE,value:4.4482216152605,offset:0},kip:{name:`kip`,base:I.FORCE,prefixes:F.LONG,value:4448.2216,offset:0},kilogramforce:{name:`kilogramforce`,base:I.FORCE,prefixes:F.NONE,value:9.80665,offset:0},J:{name:`J`,base:I.ENERGY,prefixes:F.SHORT,value:1,offset:0},joule:{name:`joule`,base:I.ENERGY,prefixes:F.LONG,value:1,offset:0},erg:{name:`erg`,base:I.ENERGY,prefixes:F.SHORTLONG,value:1e-7,offset:0},Wh:{name:`Wh`,base:I.ENERGY,prefixes:F.SHORT,value:3600,offset:0},BTU:{name:`BTU`,base:I.ENERGY,prefixes:F.BTU,value:1055.05585262,offset:0},eV:{name:`eV`,base:I.ENERGY,prefixes:F.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:`electronvolt`,base:I.ENERGY,prefixes:F.LONG,value:1602176565e-28,offset:0},W:{name:`W`,base:I.POWER,prefixes:F.SHORT,value:1,offset:0},watt:{name:`watt`,base:I.POWER,prefixes:F.LONG,value:1,offset:0},hp:{name:`hp`,base:I.POWER,prefixes:F.NONE,value:745.6998715386,offset:0},VAR:{name:`VAR`,base:I.POWER,prefixes:F.SHORT,value:h.I,offset:0},VA:{name:`VA`,base:I.POWER,prefixes:F.SHORT,value:1,offset:0},Pa:{name:`Pa`,base:I.PRESSURE,prefixes:F.SHORT,value:1,offset:0},psi:{name:`psi`,base:I.PRESSURE,prefixes:F.NONE,value:6894.75729276459,offset:0},atm:{name:`atm`,base:I.PRESSURE,prefixes:F.NONE,value:101325,offset:0},bar:{name:`bar`,base:I.PRESSURE,prefixes:F.SHORTLONG,value:1e5,offset:0},torr:{name:`torr`,base:I.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmHg:{name:`mmHg`,base:I.PRESSURE,prefixes:F.NONE,value:133.322,offset:0},mmH2O:{name:`mmH2O`,base:I.PRESSURE,prefixes:F.NONE,value:9.80665,offset:0},cmH2O:{name:`cmH2O`,base:I.PRESSURE,prefixes:F.NONE,value:98.0665,offset:0},coulomb:{name:`coulomb`,base:I.ELECTRIC_CHARGE,prefixes:F.LONG,value:1,offset:0},C:{name:`C`,base:I.ELECTRIC_CHARGE,prefixes:F.SHORT,value:1,offset:0},Ah:{name:`Ah`,base:I.ELECTRIC_CHARGE,prefixes:F.SHORT,value:3600,offset:0},farad:{name:`farad`,base:I.ELECTRIC_CAPACITANCE,prefixes:F.LONG,value:1,offset:0},F:{name:`F`,base:I.ELECTRIC_CAPACITANCE,prefixes:F.SHORT,value:1,offset:0},volt:{name:`volt`,base:I.ELECTRIC_POTENTIAL,prefixes:F.LONG,value:1,offset:0},V:{name:`V`,base:I.ELECTRIC_POTENTIAL,prefixes:F.SHORT,value:1,offset:0},ohm:{name:`ohm`,base:I.ELECTRIC_RESISTANCE,prefixes:F.SHORTLONG,value:1,offset:0},henry:{name:`henry`,base:I.ELECTRIC_INDUCTANCE,prefixes:F.LONG,value:1,offset:0},H:{name:`H`,base:I.ELECTRIC_INDUCTANCE,prefixes:F.SHORT,value:1,offset:0},siemens:{name:`siemens`,base:I.ELECTRIC_CONDUCTANCE,prefixes:F.LONG,value:1,offset:0},S:{name:`S`,base:I.ELECTRIC_CONDUCTANCE,prefixes:F.SHORT,value:1,offset:0},weber:{name:`weber`,base:I.MAGNETIC_FLUX,prefixes:F.LONG,value:1,offset:0},Wb:{name:`Wb`,base:I.MAGNETIC_FLUX,prefixes:F.SHORT,value:1,offset:0},tesla:{name:`tesla`,base:I.MAGNETIC_FLUX_DENSITY,prefixes:F.LONG,value:1,offset:0},T:{name:`T`,base:I.MAGNETIC_FLUX_DENSITY,prefixes:F.SHORT,value:1,offset:0},b:{name:`b`,base:I.BIT,prefixes:F.BINARY_SHORT,value:1,offset:0},bits:{name:`bits`,base:I.BIT,prefixes:F.BINARY_LONG,value:1,offset:0},B:{name:`B`,base:I.BIT,prefixes:F.BINARY_SHORT,value:8,offset:0},bytes:{name:`bytes`,base:I.BIT,prefixes:F.BINARY_LONG,value:8,offset:0}},R={meters:`meter`,inches:`inch`,feet:`foot`,yards:`yard`,miles:`mile`,links:`link`,rods:`rod`,chains:`chain`,angstroms:`angstrom`,lt:`l`,litres:`litre`,liter:`litre`,liters:`litre`,teaspoons:`teaspoon`,tablespoons:`tablespoon`,minims:`minim`,fldr:`fluiddram`,fluiddrams:`fluiddram`,floz:`fluidounce`,fluidounces:`fluidounce`,gi:`gill`,gills:`gill`,cp:`cup`,cups:`cup`,pt:`pint`,pints:`pint`,qt:`quart`,quarts:`quart`,gal:`gallon`,gallons:`gallon`,bbl:`beerbarrel`,beerbarrels:`beerbarrel`,obl:`oilbarrel`,oilbarrels:`oilbarrel`,hogsheads:`hogshead`,gtts:`gtt`,grams:`gram`,tons:`ton`,tonnes:`tonne`,grains:`grain`,drams:`dram`,ounces:`ounce`,poundmasses:`poundmass`,hundredweights:`hundredweight`,sticks:`stick`,lb:`lbm`,lbs:`lbm`,kips:`kip`,kgf:`kilogramforce`,acres:`acre`,hectares:`hectare`,sqfeet:`sqft`,sqyard:`sqyd`,sqmile:`sqmi`,sqmiles:`sqmi`,mmhg:`mmHg`,mmh2o:`mmH2O`,cmh2o:`cmH2O`,seconds:`second`,secs:`second`,minutes:`minute`,mins:`minute`,hours:`hour`,hr:`hour`,hrs:`hour`,days:`day`,weeks:`week`,months:`month`,years:`year`,decades:`decade`,centuries:`century`,millennia:`millennium`,hertz:`hertz`,radians:`radian`,degrees:`degree`,gradians:`gradian`,cycles:`cycle`,arcsecond:`arcsec`,arcseconds:`arcsec`,arcminute:`arcmin`,arcminutes:`arcmin`,BTUs:`BTU`,watts:`watt`,joules:`joule`,amperes:`ampere`,amps:`ampere`,amp:`ampere`,coulombs:`coulomb`,volts:`volt`,ohms:`ohm`,farads:`farad`,webers:`weber`,teslas:`tesla`,electronvolts:`electronvolt`,moles:`mole`,bit:`bits`,byte:`bytes`};function se(e){if(e.number===`BigNumber`){var t=uN(g);L.rad.value=new g(1),L.deg.value=t.div(180),L.grad.value=t.div(200),L.cycle.value=t.times(2),L.arcsec.value=t.div(648e3),L.arcmin.value=t.div(10800)}else L.rad.value=1,L.deg.value=Math.PI/180,L.grad.value=Math.PI/200,L.cycle.value=Math.PI*2,L.arcsec.value=Math.PI/648e3,L.arcmin.value=Math.PI/10800;L.radian.value=L.rad.value,L.degree.value=L.deg.value,L.gradian.value=L.grad.value}se(n),t&&t(`config`,function(e,t){e.number!==t.number&&se(e)});var ce={si:{NONE:{unit:oe,prefix:F.NONE[``]},LENGTH:{unit:L.m,prefix:F.SHORT[``]},MASS:{unit:L.g,prefix:F.SHORT.k},TIME:{unit:L.s,prefix:F.SHORT[``]},CURRENT:{unit:L.A,prefix:F.SHORT[``]},TEMPERATURE:{unit:L.K,prefix:F.SHORT[``]},LUMINOUS_INTENSITY:{unit:L.cd,prefix:F.SHORT[``]},AMOUNT_OF_SUBSTANCE:{unit:L.mol,prefix:F.SHORT[``]},ANGLE:{unit:L.rad,prefix:F.SHORT[``]},BIT:{unit:L.bits,prefix:F.SHORT[``]},FORCE:{unit:L.N,prefix:F.SHORT[``]},ENERGY:{unit:L.J,prefix:F.SHORT[``]},POWER:{unit:L.W,prefix:F.SHORT[``]},PRESSURE:{unit:L.Pa,prefix:F.SHORT[``]},ELECTRIC_CHARGE:{unit:L.C,prefix:F.SHORT[``]},ELECTRIC_CAPACITANCE:{unit:L.F,prefix:F.SHORT[``]},ELECTRIC_POTENTIAL:{unit:L.V,prefix:F.SHORT[``]},ELECTRIC_RESISTANCE:{unit:L.ohm,prefix:F.SHORT[``]},ELECTRIC_INDUCTANCE:{unit:L.H,prefix:F.SHORT[``]},ELECTRIC_CONDUCTANCE:{unit:L.S,prefix:F.SHORT[``]},MAGNETIC_FLUX:{unit:L.Wb,prefix:F.SHORT[``]},MAGNETIC_FLUX_DENSITY:{unit:L.T,prefix:F.SHORT[``]},FREQUENCY:{unit:L.Hz,prefix:F.SHORT[``]}}};ce.cgs=JSON.parse(JSON.stringify(ce.si)),ce.cgs.LENGTH={unit:L.m,prefix:F.SHORT.c},ce.cgs.MASS={unit:L.g,prefix:F.SHORT[``]},ce.cgs.FORCE={unit:L.dyn,prefix:F.SHORT[``]},ce.cgs.ENERGY={unit:L.erg,prefix:F.NONE[``]},ce.us=JSON.parse(JSON.stringify(ce.si)),ce.us.LENGTH={unit:L.ft,prefix:F.NONE[``]},ce.us.MASS={unit:L.lbm,prefix:F.NONE[``]},ce.us.TEMPERATURE={unit:L.degF,prefix:F.NONE[``]},ce.us.FORCE={unit:L.lbf,prefix:F.NONE[``]},ce.us.ENERGY={unit:L.BTU,prefix:F.BTU[``]},ce.us.POWER={unit:L.hp,prefix:F.NONE[``]},ce.us.PRESSURE={unit:L.psi,prefix:F.NONE[``]},ce.auto=JSON.parse(JSON.stringify(ce.si));var le=ce.auto;for(var ue in x.setUnitSystem=function(e){if(J(ce,e))le=ce[e];else throw Error(`Unit system `+e+` does not exist. Choices are: `+Object.keys(ce).join(`, `))},x.getUnitSystem=function(){for(var e in ce)if(J(ce,e)&&ce[e]===le)return e},x.typeConverters={BigNumber:function(e){return e!=null&&e.isFraction?new g(String(e.n)).div(String(e.d)).times(String(e.s)):new g(e+``)},Fraction:function(e){return new _(e)},Complex:function(e){return e},number:function(e){return e!=null&&e.isFraction?m(e):e}},x.prototype._numberConverter=function(){var e=x.typeConverters[this.valueType()];if(e)return e;throw TypeError(`Unsupported Unit value type "`+this.valueType()+`"`)},x._getNumberConverter=function(e){if(!x.typeConverters[e])throw TypeError(`Unsupported type "`+e+`"`);return x.typeConverters[e]},L)if(J(L,ue)){var de=L[ue];de.dimensions=de.base.dimensions}for(var fe in R)if(J(R,fe)){var pe=L[R[fe]],me={};for(var he in pe)J(pe,he)&&(me[he]=pe[he]);me.name=fe,L[fe]=me}x.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)};function z(e){for(var t=0;t0&&!(x.isValidAlpha(w)||D(w)))throw Error(`Invalid unit name (only alphanumeric characters are allowed): "`+e+`"`)}}return x.createUnit=function(e,t){if(typeof e!=`object`)throw TypeError(`createUnit expects first parameter to be of type 'Object'`);if(t&&t.override){for(var n in e)if(J(e,n)&&x.deleteUnit(n),e[n].aliases)for(var r=0;r1e-12){f=!1;break}if(f){u=!0,l.base=I[d];break}}if(!u){s||=e+`_STUFF`;var m={dimensions:n.dimensions.slice(0)};m.key=s,I[s]=m,le[s]={unit:l,prefix:F.NONE[``]},l.base=I[s]}}else{if(s||=e+`_STUFF`,ie.indexOf(s)>=0)throw Error(`Cannot create new base unit "`+e+`": a base unit with that name already exists (and cannot be overridden)`);for(var h in ie.push(s),I)J(I,h)&&(I[h].dimensions[ie.length-1]=0);for(var g={dimensions:[]},_=0;_{var{typed:t,Unit:n}=e;return t(gN,{Unit:function(e){return e.clone()},string:function(e){return n.isValuelessUnit(e)?new n(null,e):n.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string | Unit":function(e,t){return new n(e,t)},"number | BigNumber | Fraction":function(e){return new n(e)},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),vN=`sparse`,yN=Y(vN,[`typed`,`SparseMatrix`],e=>{var{typed:t,SparseMatrix:n}=e;return t(vN,{"":function(){return new n([])},string:function(e){return new n([],e)},"Array | Matrix":function(e){return new n(e)},"Array | Matrix, string":function(e,t){return new n(e,t)}})}),bN=`createUnit`,xN=Y(bN,[`typed`,`Unit`],e=>{var{typed:t,Unit:n}=e;return t(bN,{"Object, Object":function(e,t){return n.createUnit(e,t)},Object:function(e){return n.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,r){var i={};return i[e]=t,n.createUnit(i,r)},"string, Unit | string | Object":function(e,t){var r={};return r[e]=t,n.createUnit(r,{})},string:function(e){var t={};return t[e]={},n.createUnit(t,{})}})}),SN=`acos`,CN=Y(SN,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t(SN,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.acos(e):new r(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()}})}),wN=`acosh`,TN=Y(wN,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t(wN,{number:function(e){return e>=1||n.predictable?rE(e):e<=-1?new r(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new r(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()}})}),EN=`acot`,DN=Y(EN,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(EN,{number:iE,Complex:function(e){return e.acot()},BigNumber:function(e){return new n(1).div(e).atan()}})}),ON=`acoth`,kN=Y(ON,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(ON,{number:function(e){return e>=1||e<=-1||n.predictable?aE(e):new r(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()}})}),AN=`acsc`,jN=Y(AN,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(AN,{number:function(e){return e<=-1||e>=1||n.predictable?oE(e):new r(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()}})}),MN=`acsch`,NN=Y(MN,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(MN,{number:sE,Complex:function(e){return e.acsch()},BigNumber:function(e){return new n(1).div(e).asinh()}})}),PN=`asec`,FN=Y(PN,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(PN,{number:function(e){return e<=-1||e>=1||n.predictable?cE(e):new r(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()}})}),IN=`asech`,LN=Y(IN,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(IN,{number:function(e){if(e<=1&&e>=-1||n.predictable){var t=1/e;if(t>0||n.predictable)return lE(e);var i=Math.sqrt(t*t-1);return new r(Math.log(i-t),Math.PI)}return new r(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()}})}),RN=`asin`,zN=Y(RN,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t(RN,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.asin(e):new r(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()}})}),BN=Y(`asinh`,[`typed`],e=>{var{typed:t}=e;return t(`asinh`,{number:dE,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()}})}),VN=Y(`atan`,[`typed`],e=>{var{typed:t}=e;return t(`atan`,{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()}})}),HN=`atan2`,UN=Y(HN,[`typed`,`matrix`,`equalScalar`,`BigNumber`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,BigNumber:i,DenseMatrix:a,concat:o}=e,s=dO({typed:t,equalScalar:r}),c=fO({typed:t}),l=nk({typed:t,equalScalar:r}),u=HD({typed:t,equalScalar:r}),d=UD({typed:t,DenseMatrix:a}),f=_O({typed:t,matrix:n,concat:o});return t(HN,{"number, number":Math.atan2,"BigNumber, BigNumber":(e,t)=>i.atan2(e,t)},f({scalar:`number | BigNumber`,SS:l,DS:c,SD:s,Ss:u,sS:d}))}),WN=`atanh`,GN=Y(WN,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t(WN,{number:function(e){return e<=1&&e>=-1||n.predictable?mE(e):new r(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()}})}),KN=Y(`trigUnit`,[`typed`],e=>{var{typed:t}=e;return{Unit:t.referToSelf(e=>n=>{if(!n.hasBase(n.constructor.BASE_UNITS.ANGLE))throw TypeError(`Unit in function cot is no angle`);return t.find(e,n.valueType())(n.value)})}}),qN=`cos`,JN=Y(qN,[`typed`],e=>{var{typed:t}=e,n=KN({typed:t});return t(qN,{number:Math.cos,"Complex | BigNumber":e=>e.cos()},n)}),YN=`cosh`,XN=Y(YN,[`typed`],e=>{var{typed:t}=e;return t(YN,{number:rx,"Complex | BigNumber":e=>e.cosh()})}),ZN=`cot`,QN=Y(ZN,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e,r=KN({typed:t});return t(ZN,{number:_E,Complex:e=>e.cot(),BigNumber:e=>new n(1).div(e.tan())},r)}),$N=`coth`,eP=Y($N,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t($N,{number:vE,Complex:e=>e.coth(),BigNumber:e=>new n(1).div(e.tanh())})}),tP=`csc`,nP=Y(tP,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e,r=KN({typed:t});return t(tP,{number:yE,Complex:e=>e.csc(),BigNumber:e=>new n(1).div(e.sin())},r)}),rP=`csch`,iP=Y(rP,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(rP,{number:bE,Complex:e=>e.csch(),BigNumber:e=>new n(1).div(e.sinh())})}),aP=`sec`,oP=Y(aP,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e,r=KN({typed:t});return t(aP,{number:xE,Complex:e=>e.sec(),BigNumber:e=>new n(1).div(e.cos())},r)}),sP=`sech`,cP=Y(sP,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(sP,{number:SE,Complex:e=>e.sech(),BigNumber:e=>new n(1).div(e.cosh())})}),lP=`sin`,uP=Y(lP,[`typed`],e=>{var{typed:t}=e,n=KN({typed:t});return t(lP,{number:Math.sin,"Complex | BigNumber":e=>e.sin()},n)}),dP=`sinh`,fP=Y(dP,[`typed`],e=>{var{typed:t}=e;return t(dP,{number:wE,"Complex | BigNumber":e=>e.sinh()})}),pP=`tan`,mP=Y(pP,[`typed`],e=>{var{typed:t}=e,n=KN({typed:t});return t(pP,{number:Math.tan,"Complex | BigNumber":e=>e.tan()},n)}),hP=Y(`tanh`,[`typed`],e=>{var{typed:t}=e;return t(`tanh`,{number:ax,"Complex | BigNumber":e=>e.tanh()})}),gP=`setCartesian`,_P=Y(gP,[`typed`,`size`,`subset`,`compareNatural`,`Index`,`DenseMatrix`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(gP,{"Array | Matrix, Array | Matrix":function(e,t){var s=[];if(r(n(e),new a(0))!==0&&r(n(t),new a(0))!==0){var c=gw(Array.isArray(e)?e:e.toArray()).sort(i),l=gw(Array.isArray(t)?t:t.toArray()).sort(i);s=[];for(var u=0;u{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(vP,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(r(n(e),new a(0))===0)s=[];else if(r(n(t),new a(0))===0)return gw(e.toArray());else{var c=Sw(gw(Array.isArray(e)?e:e.toArray()).sort(i)),l=Sw(gw(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var u,d=0;d{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(bP,{"Array | Matrix":function(e){var t;if(r(n(e),new a(0))===0)t=[];else{var s=gw(Array.isArray(e)?e:e.toArray()).sort(i);t=[],t.push(s[0]);for(var c=1;c{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(SP,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(r(n(e),new a(0))===0||r(n(t),new a(0))===0)s=[];else{var c=Sw(gw(Array.isArray(e)?e:e.toArray()).sort(i)),l=Sw(gw(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var u=0;u{var{typed:t,size:n,subset:r,compareNatural:i,Index:a}=e;return t(wP,{"Array | Matrix, Array | Matrix":function(e,t){if(r(n(e),new a(0))===0)return!0;if(r(n(t),new a(0))===0)return!1;for(var o=Sw(gw(Array.isArray(e)?e:e.toArray()).sort(i)),s=Sw(gw(Array.isArray(t)?t:t.toArray()).sort(i)),c,l=0;l{var{typed:t,size:n,subset:r,compareNatural:i,Index:a}=e;return t(EP,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(r(n(t),new a(0))===0)return 0;for(var o=gw(Array.isArray(t)?t:t.toArray()),s=0,c=0;c{var{typed:t,size:n,subset:r,compareNatural:i,Index:a}=e;return t(OP,{"Array | Matrix":function(e){if(r(n(e),new a(0))===0)return[];for(var t=gw(Array.isArray(e)?e:e.toArray()).sort(i),c=[],l=0;l.toString(2).length<=t.length;)c.push(o(t,l.toString(2).split(``).reverse())),l++;return s(c)}});function o(e,t){for(var n=[],r=0;r0;n--)for(var r=0;re[r+1].length&&(t=e[r],e[r]=e[r+1],e[r+1]=t);return e}}),AP=`setSize`,jP=Y(AP,[`typed`,`compareNatural`],e=>{var{typed:t,compareNatural:n}=e;return t(AP,{"Array | Matrix":function(e){return Array.isArray(e)?gw(e).length:gw(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(t===!1||e.length===0)return Array.isArray(e)?gw(e).length:gw(e.toArray()).length;for(var r=gw(Array.isArray(e)?e:e.toArray()).sort(n),i=1,a=1;a{var{typed:t,size:n,concat:r,subset:i,setDifference:a,Index:o}=e;return t(MP,{"Array | Matrix, Array | Matrix":function(e,t){if(i(n(e),new o(0))===0)return gw(t);if(i(n(t),new o(0))===0)return gw(e);var s=gw(e),c=gw(t);return r(a(s,c),a(c,s))}})}),PP=`setUnion`,FP=Y(PP,[`typed`,`size`,`concat`,`subset`,`setIntersect`,`setSymDifference`,`Index`],e=>{var{typed:t,size:n,concat:r,subset:i,setIntersect:a,setSymDifference:o,Index:s}=e;return t(PP,{"Array | Matrix, Array | Matrix":function(e,t){if(i(n(e),new s(0))===0)return gw(t);if(i(n(t),new s(0))===0)return gw(e);var c=gw(e),l=gw(t);return r(o(c,l),a(c,l))}})}),IP=`add`,LP=Y(IP,[`typed`,`matrix`,`addScalar`,`equalScalar`,`DenseMatrix`,`SparseMatrix`,`concat`],e=>{var{typed:t,matrix:n,addScalar:r,equalScalar:i,DenseMatrix:a,SparseMatrix:o,concat:s}=e,c=bO({typed:t}),l=xO({typed:t,equalScalar:i}),u=SO({typed:t,DenseMatrix:a}),d=_O({typed:t,matrix:n,concat:s});return t(IP,{"any, any":r,"any, any, ...any":t.referToSelf(e=>(t,n,r)=>{for(var i=e(t,n),a=0;a{var{typed:t,abs:n,addScalar:r,divideScalar:i,multiplyScalar:a,sqrt:o,smaller:s,isPositive:c}=e;return t(RP,{"... number | BigNumber":l,Array:l,Matrix:e=>l(gw(e.toArray(),!0))});function l(e){for(var t=0,l=0,u=0;u{var{typed:t,abs:n,add:r,pow:i,conj:a,sqrt:o,multiply:s,equalScalar:c,larger:l,smaller:u,matrix:d,ctranspose:f,eigs:p}=e;return t(BP,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return S(d(e),2)},Matrix:function(e){return S(e,2)},"Array, number | BigNumber | string":function(e,t){return S(d(e),t)},"Matrix, number | BigNumber | string":function(e,t){return S(e,t)}});function m(e){var t=0;return e.forEach(function(e){var r=n(e);l(r,t)&&(t=r)},!0),t}function h(e){var t;return e.forEach(function(e){var r=n(e);(!t||u(r,t))&&(t=r)},!0),t||0}function g(e,t){if(t===1/0||t===`inf`)return m(e);if(t===-1/0||t===`-inf`)return h(e);if(t===`fro`)return S(e,2);if(typeof t==`number`&&!isNaN(t)){if(!c(t,0)){var a=0;return e.forEach(function(e){a=r(i(n(e),t),a)},!0),i(a,1/t)}return 1/0}throw Error(`Unsupported parameter value`)}function _(e){var t=0;return e.forEach(function(e,n){t=r(t,s(e,a(e)))}),n(o(t))}function v(e){var t=[],i=0;return e.forEach(function(e,a){var o=a[1],s=r(t[o]||0,n(e));l(s,i)&&(i=s),t[o]=s},!0),i}function y(e){var t=e.size();if(t[0]!==t[1])throw RangeError(`Invalid matrix dimensions`);var r=p(s(f(e),e)).values.toArray(),i=r[r.length-1];return n(o(i))}function b(e){var t=[],i=0;return e.forEach(function(e,a){var o=a[0],s=r(t[o]||0,n(e));l(s,i)&&(i=s),t[o]=s},!0),i}function x(e,t){if(t===1)return v(e);if(t===1/0||t===`inf`)return b(e);if(t===`fro`)return _(e);if(t===2)return y(e);throw Error(`Unsupported parameter value `+t)}function S(e,t){var n=e.size();if(n.length===1)return g(e,t);if(n.length===2){if(n[0]&&n[1])return x(e,t);throw RangeError(`Invalid matrix dimensions`)}}}),HP=`dot`,UP=Y(HP,[`typed`,`addScalar`,`multiplyScalar`,`conj`,`size`],e=>{var{typed:t,addScalar:n,multiplyScalar:r,conj:i,size:a}=e;return t(HP,{"Array | DenseMatrix, Array | DenseMatrix":s,"SparseMatrix, SparseMatrix":c});function o(e,t){var n=a(e),r=a(t),i,o;if(n.length===1)i=n[0];else if(n.length===2&&n[1]===1)i=n[0];else throw RangeError(`Expected a column vector, instead got a matrix of size (`+n.join(`, `)+`)`);if(r.length===1)o=r[0];else if(r.length===2&&r[1]===1)o=r[0];else throw RangeError(`Expected a column vector, instead got a matrix of size (`+r.join(`, `)+`)`);if(i!==o)throw RangeError(`Vectors must have equal length (`+i+` != `+o+`)`);if(i===0)throw RangeError(`Cannot calculate the dot product of empty vectors`);return i}function s(e,s){var c=o(e,s),l=Ny(e)?e._data:e,u=Ny(e)?e._datatype||e.getDataType():void 0,d=Ny(s)?s._data:s,f=Ny(s)?s._datatype||s.getDataType():void 0,p=a(e).length===2,m=a(s).length===2,h=n,g=r;if(u&&f&&u===f&&typeof u==`string`&&u!==`mixed`){var _=u;h=t.find(n,[_,_]),g=t.find(r,[_,_])}if(!p&&!m){for(var v=g(i(l[0]),d[0]),y=1;yh){p++;continue}m===h&&(l=u(l,d(a[f],c[p])),f++,p++)}return l}}),WP=Y(`trace`,[`typed`,`matrix`,`add`],e=>{var{typed:t,matrix:n,add:r}=e;return t(`trace`,{Array:function(e){return i(n(e))},SparseMatrix:a,DenseMatrix:i,any:gb});function i(e){var t=e._size,n=e._data;switch(t.length){case 1:if(t[0]===1)return gb(n[0]);throw RangeError(`Matrix must be square (size: `+WC(t)+`)`);case 2:var i=t[0];if(i===t[1]){for(var a=0,o=0;o0)for(var l=0;ll)break}return c}throw RangeError(`Matrix must be square (size: `+WC(a)+`)`)}}),GP=`index`,KP=Y(GP,[`typed`,`Index`],e=>{var{typed:t,Index:n}=e;return t(GP,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map(function(e){return Ey(e)?e.toNumber():My(e)||Ny(e)?e.map(function(e){return Ey(e)?e.toNumber():e}):e}),r=new n;return n.apply(r,t),r}})}),qP=new Set([`end`]),JP=Y(`Node`,[`mathWithTransform`],e=>{var{mathWithTransform:t}=e;function n(e){for(var t of[...qP])if(e.has(t))throw Error(`Scope contains an illegal symbol, "`+t+`" is a reserved keyword`)}class r{get type(){return`Node`}get isNode(){return!0}evaluate(e){return this.compile().evaluate(e)}compile(){var e=this._compile(t,{}),r={},i=null;function a(t){var a=Cy(t);return n(a),e(a,r,i)}return{evaluate:a}}_compile(e,t){throw Error(`Method _compile must be implemented by type `+this.type)}forEach(e){throw Error(`Cannot run forEach on a Node interface`)}map(e){throw Error(`Cannot run map on a Node interface`)}_ifNode(e){if(!sb(e))throw TypeError(`Callback function must return a Node`);return e}traverse(e){e(this,null,null);function t(e,n){e.forEach(function(e,r,i){n(e,r,i),t(e,n)})}t(this,e)}transform(e){function t(n,r,i){var a=e(n,r,i);return a===n?n.map(t):a}return t(this,null,null)}filter(e){var t=[];return this.traverse(function(n,r,i){e(n,r,i)&&t.push(n)}),t}clone(){throw Error(`Cannot clone a Node interface`)}cloneDeep(){return this.map(function(e){return e.cloneDeep()})}equals(e){return e?this.type===e.type&&bb(this,e):!1}toString(e){var t=this._getCustomString(e);return t===void 0?this._toString(e):t}_toString(){throw Error(`_toString not implemented for `+this.type)}toJSON(){throw Error(`Cannot serialize object: toJSON not implemented by `+this.type)}toHTML(e){var t=this._getCustomString(e);return t===void 0?this._toHTML(e):t}_toHTML(){throw Error(`_toHTML not implemented for `+this.type)}toTex(e){var t=this._getCustomString(e);return t===void 0?this._toTex(e):t}_toTex(e){throw Error(`_toTex not implemented for `+this.type)}_getCustomString(e){if(e&&typeof e==`object`)switch(typeof e.handler){case`object`:case`undefined`:return;case`function`:return e.handler(this,e);default:throw TypeError(`Object or function expected as callback`)}}getIdentifier(){return this.type}getContent(){return this}}return r},{isClass:!0,isNode:!0});function YP(e){return e&&e.isIndexError?new $C(e.index+1,e.min+1,e.max===void 0?void 0:e.max+1):e}function XP(e){var{subset:t}=e;return function(e,n){try{if(Array.isArray(e))return t(e,n);if(e&&typeof e.subset==`function`)return e.subset(n);if(typeof e==`string`)return t(e,n);if(typeof e==`object`){if(!n.isObjectProperty())throw TypeError(`Cannot apply a numeric index as object property`);return uy(e,n.getObjectProperty())}else throw TypeError(`Cannot apply index: unsupported type of object`)}catch(e){throw YP(e)}}}var ZP=`AccessorNode`,QP=Y(ZP,[`subset`,`Node`],e=>{var{subset:t,Node:n}=e,r=XP({subset:t});function i(e){return!(Zy(e)||Qy(e)||nb(e)||ab(e)||cb(e)||ub(e)||pb(e))}class a extends n{constructor(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(super(),!sb(e))throw TypeError(`Node expected for parameter "object"`);if(!ob(t))throw TypeError(`IndexNode expected for parameter "index"`);this.object=e,this.index=t,this.optionalChaining=n}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():``:this.object.name||``}get type(){return ZP}get isAccessorNode(){return!0}_compile(e,t){var n=this.object._compile(e,t),i=this.index._compile(e,t),a=this.optionalChaining,o=Zy(this.object)&&this.object.optionalChaining;if(this.index.isObjectProperty()){var s=this.index.getObjectProperty();return function(e,t,r){var i=r||{},c=n(e,t,i);if(a&&c==null){i.optionalShortCircuit=!0;return}if(!(o&&i!=null&&i.optionalShortCircuit))return uy(c,s)}}else return function(e,t,s){var c=s||{},l=n(e,t,c);if(a&&l==null){c.optionalShortCircuit=!0;return}if(!(o&&c!=null&&c.optionalShortCircuit))return r(l,i(e,t,l))}}forEach(e){e(this.object,`object`,this),e(this.index,`index`,this)}map(e){return new a(this._ifNode(e(this.object,`object`,this)),this._ifNode(e(this.index,`index`,this)),this.optionalChaining)}clone(){return new a(this.object,this.index,this.optionalChaining)}_toString(e){var t=this.object.toString(e);i(this.object)&&(t=`(`+t+`)`);var n=this.optionalChaining?this.index.dotNotation?`?`:`?.`:``;return t+n+this.index.toString(e)}_toHTML(e){var t=this.object.toHTML(e);return i(this.object)&&(t=`(`+t+`)`),t+this.index.toHTML(e)}_toTex(e){var t=this.object.toTex(e);return i(this.object)&&(t=`\\left(' + object + '\\right)`),t+this.index.toTex(e)}toJSON(){return{mathjs:ZP,object:this.object,index:this.index,optionalChaining:this.optionalChaining}}static fromJSON(e){return new a(e.object,e.index,e.optionalChaining)}}return YA(a,`name`,ZP),a},{isClass:!0,isNode:!0}),$P=`ArrayNode`,eF=Y($P,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),this.items=e||[],!Array.isArray(this.items)||!this.items.every(sb))throw TypeError(`Array containing Nodes expected`)}get type(){return $P}get isArrayNode(){return!0}_compile(e,t){var n=_w(this.items,function(n){return n._compile(e,t)});if(e.config.matrix!==`Array`){var r=e.matrix;return function(e,t,i){return r(_w(n,function(n){return n(e,t,i)}))}}else return function(e,t,r){return _w(n,function(n){return n(e,t,r)})}}forEach(e){for(var t=0;t[`+this.items.map(function(t){return t.toHTML(e)}).join(`,`)+`]`}_toTex(e){function t(n,r){var i=n.some(Qy)&&!n.every(Qy),a=r||i,o=a?`&`:`\\\\`,s=n.map(function(n){return n.items?t(n.items,!r):n.toTex(e)}).join(o);return i||!a||a&&!r?`\\begin{bmatrix}`+s+`\\end{bmatrix}`:s}return t(this.items,!1)}}return YA(n,`name`,$P),n},{isClass:!0,isNode:!0});function tF(e){var{subset:t,matrix:n}=e;return function(e,r,i){try{if(Array.isArray(e))return n(e).subset(r,i).valueOf().forEach((t,n)=>{e[n]=t}),e;if(e&&typeof e.subset==`function`)return e.subset(r,i);if(typeof e==`string`)return t(e,r,i);if(typeof e==`object`){if(!r.isObjectProperty())throw TypeError(`Cannot apply a numeric index as object property`);return dy(e,r.getObjectProperty(),i),e}else throw TypeError(`Cannot apply index: unsupported type of object`)}catch(e){throw YP(e)}}}var nF=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{op:`or`,associativity:`left`,associativeWith:[]}},{"OperatorNode:xor":{op:`xor`,associativity:`left`,associativeWith:[]}},{"OperatorNode:and":{op:`and`,associativity:`left`,associativeWith:[]}},{"OperatorNode:bitOr":{op:`|`,associativity:`left`,associativeWith:[]}},{"OperatorNode:bitXor":{op:`^|`,associativity:`left`,associativeWith:[]}},{"OperatorNode:bitAnd":{op:`&`,associativity:`left`,associativeWith:[]}},{"OperatorNode:equal":{op:`==`,associativity:`left`,associativeWith:[]},"OperatorNode:unequal":{op:`!=`,associativity:`left`,associativeWith:[]},"OperatorNode:smaller":{op:`<`,associativity:`left`,associativeWith:[]},"OperatorNode:larger":{op:`>`,associativity:`left`,associativeWith:[]},"OperatorNode:smallerEq":{op:`<=`,associativity:`left`,associativeWith:[]},"OperatorNode:largerEq":{op:`>=`,associativity:`left`,associativeWith:[]},RelationalNode:{associativity:`left`,associativeWith:[]}},{"OperatorNode:leftShift":{op:`<<`,associativity:`left`,associativeWith:[]},"OperatorNode:rightArithShift":{op:`>>`,associativity:`left`,associativeWith:[]},"OperatorNode:rightLogShift":{op:`>>>`,associativity:`left`,associativeWith:[]}},{"OperatorNode:to":{op:`to`,associativity:`left`,associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{op:`+`,associativity:`left`,associativeWith:[`OperatorNode:add`,`OperatorNode:subtract`]},"OperatorNode:subtract":{op:`-`,associativity:`left`,associativeWith:[]}},{"OperatorNode:multiply":{op:`*`,associativity:`left`,associativeWith:[`OperatorNode:multiply`,`OperatorNode:divide`,`Operator:dotMultiply`,`Operator:dotDivide`]},"OperatorNode:divide":{op:`/`,associativity:`left`,associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{op:`.*`,associativity:`left`,associativeWith:[`OperatorNode:multiply`,`OperatorNode:divide`,`OperatorNode:dotMultiply`,`OperatorNode:doDivide`]},"OperatorNode:dotDivide":{op:`./`,associativity:`left`,associativeWith:[]},"OperatorNode:mod":{op:`mod`,associativity:`left`,associativeWith:[]}},{"OperatorNode:multiply":{associativity:`left`,associativeWith:[`OperatorNode:multiply`,`OperatorNode:divide`,`Operator:dotMultiply`,`Operator:dotDivide`]}},{"OperatorNode:unaryPlus":{op:`+`,associativity:`right`},"OperatorNode:unaryMinus":{op:`-`,associativity:`right`},"OperatorNode:bitNot":{op:`~`,associativity:`right`},"OperatorNode:not":{op:`not`,associativity:`right`}},{"OperatorNode:pow":{op:`^`,associativity:`right`,associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{op:`.^`,associativity:`right`,associativeWith:[]}},{"OperatorNode:nullish":{op:`??`,associativity:`left`,associativeWith:[]}},{"OperatorNode:factorial":{op:`!`,associativity:`left`}},{"OperatorNode:ctranspose":{op:`'`,associativity:`left`}}];function rF(e,t){if(!t||t!==`auto`)return e;for(var n=e;ub(n);)n=n.content;return n}function iF(e,t,n,r){var i=e;t!==`keep`&&(i=e.getContent());for(var a=i.getIdentifier(),o=null,s=0;s{var{subset:t,matrix:n,Node:r}=e,i=XP({subset:t}),a=tF({subset:t,matrix:n});function o(e,t,n){t||=`keep`;var r=iF(e,t,n),i=iF(e.value,t,n);return t===`all`||i!==null&&i<=r}class s extends r{constructor(e,t,n){if(super(),this.object=e,this.index=n?t:null,this.value=n||t,!pb(e)&&!Zy(e))throw TypeError(`SymbolNode or AccessorNode expected as "object"`);if(pb(e)&&e.name===`end`)throw Error(`Cannot assign to symbol "end"`);if(this.index&&!ob(this.index))throw TypeError(`IndexNode expected as "index"`);if(!sb(this.value))throw TypeError(`Node expected as "value"`)}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():``:this.object.name||``}get type(){return cF}get isAssignmentNode(){return!0}_compile(e,t){var n=this.object._compile(e,t),r=this.index?this.index._compile(e,t):null,o=this.value._compile(e,t),s=this.object.name;if(!this.index){if(!pb(this.object))throw TypeError(`SymbolNode expected as object`);return function(e,t,n){var r=o(e,t,n);return e.set(s,r),r}}else if(this.index.isObjectProperty()){var c=this.index.getObjectProperty();return function(e,t,r){var i=n(e,t,r),a=o(e,t,r);return dy(i,c,a),a}}else if(pb(this.object))return function(e,t,i){var c=n(e,t,i),l=o(e,t,i),u=r(e,t,c);return e.set(s,a(c,u,l)),l};else{var l=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var u=this.object.index.getObjectProperty();return function(e,t,n){var i=l(e,t,n),s=uy(i,u),c=r(e,t,s),d=o(e,t,n);return dy(i,u,a(s,c,d)),d}}else{var d=this.object.index._compile(e,t);return function(e,t,n){var s=l(e,t,n),c=d(e,t,s),u=i(s,c),f=r(e,t,u),p=o(e,t,n);return a(s,c,a(u,f,p)),p}}}}forEach(e){e(this.object,`object`,this),this.index&&e(this.index,`index`,this),e(this.value,`value`,this)}map(e){return new s(this._ifNode(e(this.object,`object`,this)),this.index?this._ifNode(e(this.index,`index`,this)):null,this._ifNode(e(this.value,`value`,this)))}clone(){return new s(this.object,this.index,this.value)}_toString(e){var t=this.object.toString(e),n=this.index?this.index.toString(e):``,r=this.value.toString(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`(`+r+`)`),t+n+` = `+r}toJSON(){return{mathjs:cF,object:this.object,index:this.index,value:this.value}}static fromJSON(e){return new s(e.object,e.index,e.value)}_toHTML(e){var t=this.object.toHTML(e),n=this.index?this.index.toHTML(e):``,r=this.value.toHTML(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`(`+r+`)`),t+n+`=`+r}_toTex(e){var t=this.object.toTex(e),n=this.index?this.index.toTex(e):``,r=this.value.toTex(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`\\left(${r}\\right)`),t+n+`=`+r}}return YA(s,`name`,cF),s},{isClass:!0,isNode:!0}),uF=`BlockNode`,dF=Y(uF,[`ResultSet`,`Node`],e=>{var{ResultSet:t,Node:n}=e;class r extends n{constructor(e){if(super(),!Array.isArray(e))throw Error(`Array expected`);this.blocks=e.map(function(e){var t=e&&e.node,n=e&&e.visible!==void 0?e.visible:!0;if(!sb(t))throw TypeError(`Property "node" must be a Node`);if(typeof n!=`boolean`)throw TypeError(`Property "visible" must be a boolean`);return{node:t,visible:n}})}get type(){return uF}get isBlockNode(){return!0}_compile(e,n){var r=_w(this.blocks,function(t){return{evaluate:t.node._compile(e,n),visible:t.visible}});return function(e,n,i){var a=[];return vw(r,function(t){var r=t.evaluate(e,n,i);t.visible&&a.push(r)}),new t(a)}}forEach(e){for(var t=0;t;`)}).join(`
`)}_toTex(e){return this.blocks.map(function(t){return t.node.toTex(e)+(t.visible?``:`;`)}).join(`\\;\\; `)}}return YA(r,`name`,uF),r},{isClass:!0,isNode:!0}),fF=`ConditionalNode`,pF=Y(fF,[`Node`],e=>{var{Node:t}=e;function n(e){if(typeof e==`number`||typeof e==`boolean`||typeof e==`string`)return!!e;if(e){if(Ey(e))return!e.isZero();if(Oy(e))return!!(e.re||e.im);if(Ay(e))return!!e.value}if(e==null)return!1;throw TypeError(`Unsupported type of condition "`+hb(e)+`"`)}class r extends t{constructor(e,t,n){if(super(),!sb(e))throw TypeError(`Parameter condition must be a Node`);if(!sb(t))throw TypeError(`Parameter trueExpr must be a Node`);if(!sb(n))throw TypeError(`Parameter falseExpr must be a Node`);this.condition=e,this.trueExpr=t,this.falseExpr=n}get type(){return fF}get isConditionalNode(){return!0}_compile(e,t){var r=this.condition._compile(e,t),i=this.trueExpr._compile(e,t),a=this.falseExpr._compile(e,t);return function(e,t,o){return n(r(e,t,o))?i(e,t,o):a(e,t,o)}}forEach(e){e(this.condition,`condition`,this),e(this.trueExpr,`trueExpr`,this),e(this.falseExpr,`falseExpr`,this)}map(e){return new r(this._ifNode(e(this.condition,`condition`,this)),this._ifNode(e(this.trueExpr,`trueExpr`,this)),this._ifNode(e(this.falseExpr,`falseExpr`,this)))}clone(){return new r(this.condition,this.trueExpr,this.falseExpr)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=iF(this,t,e&&e.implicit),r=this.condition.toString(e),i=iF(this.condition,t,e&&e.implicit);(t===`all`||this.condition.type===`OperatorNode`||i!==null&&i<=n)&&(r=`(`+r+`)`);var a=this.trueExpr.toString(e),o=iF(this.trueExpr,t,e&&e.implicit);(t===`all`||this.trueExpr.type===`OperatorNode`||o!==null&&o<=n)&&(a=`(`+a+`)`);var s=this.falseExpr.toString(e),c=iF(this.falseExpr,t,e&&e.implicit);return(t===`all`||this.falseExpr.type===`OperatorNode`||c!==null&&c<=n)&&(s=`(`+s+`)`),r+` ? `+a+` : `+s}toJSON(){return{mathjs:fF,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(e){return new r(e.condition,e.trueExpr,e.falseExpr)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=iF(this,t,e&&e.implicit),r=this.condition.toHTML(e),i=iF(this.condition,t,e&&e.implicit);(t===`all`||this.condition.type===`OperatorNode`||i!==null&&i<=n)&&(r=`(`+r+`)`);var a=this.trueExpr.toHTML(e),o=iF(this.trueExpr,t,e&&e.implicit);(t===`all`||this.trueExpr.type===`OperatorNode`||o!==null&&o<=n)&&(a=`(`+a+`)`);var s=this.falseExpr.toHTML(e),c=iF(this.falseExpr,t,e&&e.implicit);return(t===`all`||this.falseExpr.type===`OperatorNode`||c!==null&&c<=n)&&(s=`(`+s+`)`),r+`?`+a+`:`+s}_toTex(e){return`\\begin{cases} {`+this.trueExpr.toTex(e)+`}, &\\quad{\\text{if }\\;`+this.condition.toTex(e)+`}\\\\{`+this.falseExpr.toTex(e)+`}, &\\quad{\\text{otherwise}}\\end{cases}`}}return YA(r,`name`,fF),r},{isClass:!0,isNode:!0}),mF=l(o(((e,t)=>{var n=Object.assign||function(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:{},o=t.preserveFormatting,s=o===void 0?!1:o,c=t.escapeMapFn,l=c===void 0?a:c,u=String(e),d=``,f=l(n({},r),s?n({},i):{}),p=Object.keys(f),m=function(){var e=!1;p.forEach(function(t,n){e||u.length>=t.length&&u.slice(0,t.length)===t&&(d+=f[p[n]],u=u.slice(t.length,u.length),e=!0)}),e||(d+=u.slice(0,1),u=u.slice(1,u.length))};u;)m();return d}}))(),1),hF={Alpha:`A`,alpha:`\\alpha`,Beta:`B`,beta:`\\beta`,Gamma:`\\Gamma`,gamma:`\\gamma`,Delta:`\\Delta`,delta:`\\delta`,Epsilon:`E`,epsilon:`\\epsilon`,varepsilon:`\\varepsilon`,Zeta:`Z`,zeta:`\\zeta`,Eta:`H`,eta:`\\eta`,Theta:`\\Theta`,theta:`\\theta`,vartheta:`\\vartheta`,Iota:`I`,iota:`\\iota`,Kappa:`K`,kappa:`\\kappa`,varkappa:`\\varkappa`,Lambda:`\\Lambda`,lambda:`\\lambda`,Mu:`M`,mu:`\\mu`,Nu:`N`,nu:`\\nu`,Xi:`\\Xi`,xi:`\\xi`,Omicron:`O`,omicron:`o`,Pi:`\\Pi`,pi:`\\pi`,varpi:`\\varpi`,Rho:`P`,rho:`\\rho`,varrho:`\\varrho`,Sigma:`\\Sigma`,sigma:`\\sigma`,varsigma:`\\varsigma`,Tau:`T`,tau:`\\tau`,Upsilon:`\\Upsilon`,upsilon:`\\upsilon`,Phi:`\\Phi`,phi:`\\phi`,varphi:`\\varphi`,Chi:`X`,chi:`\\chi`,Psi:`\\Psi`,psi:`\\psi`,Omega:`\\Omega`,omega:`\\omega`,true:`\\mathrm{True}`,false:`\\mathrm{False}`,i:`i`,inf:`\\infty`,Inf:`\\infty`,infinity:`\\infty`,Infinity:`\\infty`,oo:`\\infty`,lim:`\\lim`,undefined:`\\mathbf{?}`},gF={transpose:`^\\top`,ctranspose:`^H`,factorial:`!`,pow:`^`,dotPow:`.^\\wedge`,unaryPlus:`+`,unaryMinus:`-`,bitNot:`\\~`,not:`\\neg`,multiply:`\\cdot`,divide:`\\frac`,dotMultiply:`.\\cdot`,dotDivide:`.:`,mod:`\\mod`,add:`+`,subtract:`-`,to:`\\rightarrow`,leftShift:`<<`,rightArithShift:`>>`,rightLogShift:`>>>`,equal:`=`,unequal:`\\neq`,smaller:`<`,larger:`>`,smallerEq:`\\leq`,largerEq:`\\geq`,bitAnd:`\\&`,bitXor:`\\underline{|}`,bitOr:`|`,and:`\\wedge`,xor:`\\veebar`,or:`\\vee`},_F={abs:{1:"\\left|${args[0]}\\right|"},add:{2:`\\left(\${args[0]}${gF.add}\${args[1]}\\right)`},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:`\\left(\${args[0]}${gF.dotDivide}\${args[1]}\\right)`},dotMultiply:{2:`\\left(\${args[0]}${gF.dotMultiply}\${args[1]}\\right)`},dotPow:{2:`\\left(\${args[0]}${gF.dotPow}\${args[1]}\\right)`},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:`\\left(e${gF.pow}{\${args[0]}}-1\\right)`,fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},fraction:{2:"\\frac{${args[0]}}{${args[1]}}"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:`\\left(\${args[0]}${gF.mod}\${args[1]}\\right)`},multiply:{2:`\\left(\${args[0]}${gF.multiply}\${args[1]}\\right)`},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : y^${args[1]} = {${args[0]}}\\}"},pow:{2:`\\left(\${args[0]}\\right)${gF.pow}{\${args[1]}}`},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:`\\left(\${args[0]}${gF.subtract}\${args[1]}\\right)`},unaryMinus:{1:`${gF.unaryMinus}\\left(\${args[0]}\\right)`},unaryPlus:{1:`${gF.unaryPlus}\\left(\${args[0]}\\right)`},bitAnd:{2:`\\left(\${args[0]}${gF.bitAnd}\${args[1]}\\right)`},bitNot:{1:gF.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:`\\left(\${args[0]}${gF.bitOr}\${args[1]}\\right)`},bitXor:{2:`\\left(\${args[0]}${gF.bitXor}\${args[1]}\\right)`},leftShift:{2:`\\left(\${args[0]}${gF.leftShift}\${args[1]}\\right)`},rightArithShift:{2:`\\left(\${args[0]}${gF.rightArithShift}\${args[1]}\\right)`},rightLogShift:{2:`\\left(\${args[0]}${gF.rightLogShift}\${args[1]}\\right)`},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:`\\left(\${args[0]}${gF.and}\${args[1]}\\right)`},not:{1:gF.not+"\\left(${args[0]}\\right)"},or:{2:`\\left(\${args[0]}${gF.or}\${args[1]}\\right)`},xor:{2:`\\left(\${args[0]}${gF.xor}\${args[1]}\\right)`},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:`\\left(\${args[0]}\\right)${gF.ctranspose}`},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:`{\${args[0]}}${gF.pow}{\\frac{1}{2}}`},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:`\\left(\${args[0]}\\right)${gF.transpose}`},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:`\\left(\${args[0]}\\right)${gF.factorial}`},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:`\\left(\${args[0]}${gF.equal}\${args[1]}\\right)`},larger:{2:`\\left(\${args[0]}${gF.larger}\${args[1]}\\right)`},largerEq:{2:`\\left(\${args[0]}${gF.largerEq}\${args[1]}\\right)`},smaller:{2:`\\left(\${args[0]}${gF.smaller}\${args[1]}\\right)`},smallerEq:{2:`\\left(\${args[0]}${gF.smallerEq}\${args[1]}\\right)`},unequal:{2:`\\left(\${args[0]}${gF.unequal}\${args[1]}\\right)`},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:`\\left(\${args[0]}${gF.to}\${args[1]}\\right)`},numeric:function(e,t){return e.args[0].toTex()},number:{0:`0`,1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:`\\mathtt{""}`,1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:`0`,1:"\\left(${args[0]}\\right)"},bigint:{0:`0`,1:"\\left(${args[0]}\\right)"},complex:{0:`0`,1:"\\left(${args[0]}\\right)",2:`\\left(\\left(\${args[0]}\\right)+${hF.i}\\cdot\\left(\${args[1]}\\right)\\right)`},matrix:{0:`\\begin{bmatrix}\\end{bmatrix}`,1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:`\\begin{bsparse}\\end{bsparse}`,1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},vF="\\mathrm{${name}}\\left(${args}\\right)",yF={deg:`^\\circ`};function bF(e){return(0,mF.default)(e,{preserveFormatting:!0})}function xF(e,t){return t=t===void 0?!1:t,t?J(yF,e)?yF[e]:`\\mathrm{`+bF(e)+`}`:J(hF,e)?hF[e]:bF(e)}var SF=`ConstantNode`,CF=Y(SF,[`Node`,`isBounded`],e=>{var{Node:t,isBounded:n}=e;class r extends t{constructor(e){super(),this.value=e}get type(){return SF}get isConstantNode(){return!0}_compile(e,t){var n=this.value;return function(){return n}}forEach(e){}map(e){return this.clone()}clone(){return new r(this.value)}_toString(e){return WC(this.value,e)}_toHTML(e){var t=this._toString(e);switch(hb(this.value)){case`number`:case`bigint`:case`BigNumber`:case`Fraction`:return``+t+``;case`string`:return``+t+``;case`boolean`:return``+t+``;case`null`:return``+t+``;case`undefined`:return``+t+``;default:return``+t+``}}toJSON(){return{mathjs:SF,value:this.value}}static fromJSON(e){return new r(e.value)}_toTex(e){var t=this._toString(e);switch(hb(this.value)){case`string`:return`\\mathtt{`+bF(t)+`}`;case`number`:case`BigNumber`:if(!n(this.value))return this.value.valueOf()<0?`-\\infty`:`\\infty`;var r=t.toLowerCase().indexOf(`e`);return r===-1?t:t.substring(0,r)+`\\cdot10^{`+t.substring(r+1)+`}`;case`bigint`:return t.toString();case`Fraction`:return this.value.toLatex();default:return t}}}return YA(r,`name`,SF),r},{isClass:!0,isNode:!0}),wF=`FunctionAssignmentNode`,TF=Y(wF,[`typed`,`Node`],e=>{var{typed:t,Node:n}=e;function r(e,t,n){var r=iF(e,t,n),i=iF(e.expr,t,n);return t===`all`||i!==null&&i<=r}class i extends n{constructor(e,t,n){if(super(),typeof e!=`string`)throw TypeError(`String expected for parameter "name"`);if(!Array.isArray(t))throw TypeError(`Array containing strings or objects expected for parameter "params"`);if(!sb(n))throw TypeError(`Node expected for parameter "expr"`);if(qP.has(e))throw Error(`Illegal function name, "`+e+`" is a reserved keyword`);var r=new Set;for(var i of t){var a=typeof i==`string`?i:i.name;if(r.has(a))throw Error(`Duplicate parameter name "${a}"`);r.add(a)}this.name=e,this.params=t.map(function(e){return e&&e.name||e}),this.types=t.map(function(e){return e&&e.type||`any`}),this.expr=n}get type(){return wF}get isFunctionAssignmentNode(){return!0}_compile(e,n){var r=Object.create(n);vw(this.params,function(e){r[e]=!0});var i=this.expr,a=i._compile(e,r),o=this.name,s=this.params,c=xw(this.types,`,`),l=o+`(`+xw(this.params,`, `)+`)`;return function(e,n,r){var u={};u[c]=function(){for(var t=Object.create(n),i=0;i`+JC(this.params[i])+``);var a=this.expr.toHTML(e);return r(this,t,e&&e.implicit)&&(a=`(`+a+`)`),``+JC(this.name)+`(`+n.join(`,`)+`)=`+a}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=this.expr.toTex(e);return r(this,t,e&&e.implicit)&&(n=`\\left(${n}\\right)`),`\\mathrm{`+this.name+`}\\left(`+this.params.map(xF).join(`,`)+`\\right)=`+n}}return YA(i,`name`,wF),i},{isClass:!0,isNode:!0}),EF=`IndexNode`,DF=Y(EF,[`Node`,`size`],e=>{var{Node:t,size:n}=e;class r extends t{constructor(e,t){if(super(),this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(sb))throw TypeError(`Array containing Nodes expected for parameter "dimensions"`);if(this.dotNotation&&!this.isObjectProperty())throw Error(`dotNotation only applicable for object properties`)}get type(){return EF}get isIndexNode(){return!0}_compile(e,t){var r=_w(this.dimensions,function(r,i){if(r.filter(e=>e.isSymbolNode&&e.name===`end`).length>0){var a=Object.create(t);a.end=!0;var o=r._compile(e,a);return function(e,t,r){if(!Ny(r)&&!My(r)&&!jy(r))throw TypeError(`Cannot resolve "end": context must be a Matrix, Array, or string but is `+hb(r));var a=n(r),s=Object.create(t);return s.end=a[i],o(e,s,r)}}else return r._compile(e,t)}),i=uy(e,`index`);return function(e,t,n){return i(..._w(r,function(r){return r(e,t,n)}))}}forEach(e){for(var t=0;t.`+JC(this.getObjectProperty())+``:`[`+t.join(`,`)+`]`}_toTex(e){var t=this.dimensions.map(function(t){return t.toTex(e)});return this.dotNotation?`.`+this.getObjectProperty():`_{`+t.join(`,`)+`}`}}return YA(r,`name`,EF),r},{isClass:!0,isNode:!0}),OF=`ObjectNode`,kF=Y(OF,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),this.properties=e||{},e&&(typeof e!=`object`||!Object.keys(e).every(function(t){return sb(e[t])})))throw TypeError(`Object containing Nodes expected`)}get type(){return OF}get isObjectNode(){return!0}_compile(e,t){var n={};for(var r in this.properties)if(J(this.properties,r)){var i=KC(r),a=JSON.parse(i);n[a]=uy(this.properties,r)._compile(e,t)}return function(e,t,r){var i={};for(var a in n)J(n,a)&&(i[a]=n[a](e,t,r));return i}}forEach(e){for(var t in this.properties)J(this.properties,t)&&e(this.properties[t],`properties[`+KC(t)+`]`,this)}map(e){var t={};for(var r in this.properties)J(this.properties,r)&&(t[r]=this._ifNode(e(this.properties[r],`properties[`+KC(r)+`]`,this)));return new n(t)}clone(){var e={};for(var t in this.properties)J(this.properties,t)&&(e[t]=this.properties[t]);return new n(e)}_toString(e){var t=[];for(var n in this.properties)J(this.properties,n)&&t.push(KC(n)+`: `+this.properties[n].toString(e));return`{`+t.join(`, `)+`}`}toJSON(){return{mathjs:OF,properties:this.properties}}static fromJSON(e){return new n(e.properties)}_toHTML(e){var t=[];for(var n in this.properties)J(this.properties,n)&&t.push(``+JC(n)+`:`+this.properties[n].toHTML(e));return`{`+t.join(`,`)+`}`}_toTex(e){var t=[];for(var n in this.properties)J(this.properties,n)&&t.push(`\\mathbf{`+n+`:} & `+this.properties[n].toTex(e)+`\\\\`);return`\\left\\{\\begin{array}{ll}`+t.join(` `)+`\\end{array}\\right\\}`}}return YA(n,`name`,OF),n},{isClass:!0,isNode:!0});function AF(e,t){return new by(e,new yy(t),new Set(Object.keys(t)))}var jF=`OperatorNode`,MF=Y(jF,[`Node`],e=>{var{Node:t}=e;function n(e,t){var r=e;if(t===`auto`)for(;ub(r);)r=r.content;return nb(r)?!0:lb(r)?n(r.args[0],t):!1}function r(e,t,r,i,a){var o=iF(e,t,r),s=aF(e,t);if(t===`all`||i.length>2&&e.getIdentifier()!==`OperatorNode:add`&&e.getIdentifier()!==`OperatorNode:multiply`)return i.map(function(e){switch(e.getContent().type){case`ArrayNode`:case`ConstantNode`:case`SymbolNode`:case`ParenthesisNode`:return!1;default:return!0}});var c;switch(i.length){case 0:c=[];break;case 1:var l=iF(i[0],t,r,e);if(a&&l!==null){var u,d;if(t===`keep`?(u=i[0].getIdentifier(),d=e.getIdentifier()):(u=i[0].getContent().getIdentifier(),d=e.getContent().getIdentifier()),nF[o][d].latexLeftParens===!1){c=[!1];break}if(nF[l][u].latexParens===!1){c=[!1];break}}if(l===null){c=[!1];break}if(l<=o){c=[!0];break}c=[!1];break;case 2:var f,p=iF(i[0],t,r,e),m=oF(e,i[0],t);f=p===null?!1:p===o&&s===`right`&&!m?!0:p=2&&e.getIdentifier()===`OperatorNode:multiply`&&e.implicit&&t!==`all`&&r===`hide`)for(var x=1;x2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)){var d=i.map(function(t,n){return t=t.toString(e),a[n]&&(t=`(`+t+`)`),t});return this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?d.join(` `):d.join(` `+this.op+` `)}else return this.fn+`(`+this.args.join(`, `)+`)`}toJSON(){return{mathjs:jF,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(e){return new i(e.op,e.fn,e.args,e.implicit,e.isPercentage)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=e&&e.implicit?e.implicit:`hide`,i=this.args,a=r(this,t,n,i,!1);if(i.length===1){var o=aF(this,t),s=i[0].toHTML(e);return a[0]&&(s=`(`+s+`)`),o===`right`?``+JC(this.op)+``+s:s+``+JC(this.op)+``}else if(i.length===2){var c=i[0].toHTML(e),l=i[1].toHTML(e);return a[0]&&(c=`(`+c+`)`),a[1]&&(l=`(`+l+`)`),this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?c+``+l:c+``+JC(this.op)+``+l}else{var u=i.map(function(t,n){return t=t.toHTML(e),a[n]&&(t=`(`+t+`)`),t});return i.length>2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)?this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?u.join(``):u.join(``+JC(this.op)+``):``+JC(this.fn)+`(`+u.join(`,`)+`)`}}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=e&&e.implicit?e.implicit:`hide`,i=this.args,a=r(this,t,n,i,!0),o=gF[this.fn];if(o=o===void 0?this.op:o,i.length===1){var s=aF(this,t),c=i[0].toTex(e);return a[0]&&(c=`\\left(${c}\\right)`),s===`right`?o+c:c+o}else if(i.length===2){var l=i[0],u=l.toTex(e);a[0]&&(u=`\\left(${u}\\right)`);var d=i[1].toTex(e);a[1]&&(d=`\\left(${d}\\right)`);var f=t===`keep`?l.getIdentifier():l.getContent().getIdentifier();switch(this.getIdentifier()){case`OperatorNode:divide`:return o+`{`+u+`}{`+d+`}`;case`OperatorNode:pow`:switch(u=`{`+u+`}`,d=`{`+d+`}`,f){case`ConditionalNode`:case`OperatorNode:divide`:u=`\\left(${u}\\right)`}break;case`OperatorNode:multiply`:if(this.implicit&&n===`hide`)return u+`~`+d}return u+o+d}else if(i.length>2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)){var p=i.map(function(t,n){return t=t.toTex(e),a[n]&&(t=`\\left(${t}\\right)`),t});return this.getIdentifier()===`OperatorNode:multiply`&&this.implicit&&n===`hide`?p.join(`~`):p.join(o)}else return`\\mathrm{`+this.fn+`}\\left(`+i.map(function(t){return t.toTex(e)}).join(`,`)+`\\right)`}getIdentifier(){return this.type+`:`+this.fn}}return YA(i,`name`,jF),i},{isClass:!0,isNode:!0}),NF=`ParenthesisNode`,PF=Y(NF,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),!sb(e))throw TypeError(`Node expected for parameter "content"`);this.content=e}get type(){return NF}get isParenthesisNode(){return!0}_compile(e,t){return this.content._compile(e,t)}getContent(){return this.content.getContent()}forEach(e){e(this.content,`content`,this)}map(e){return new n(e(this.content,`content`,this))}clone(){return new n(this.content)}_toString(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`(`+this.content.toString(e)+`)`:this.content.toString(e)}toJSON(){return{mathjs:NF,content:this.content}}static fromJSON(e){return new n(e.content)}_toHTML(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`(`+this.content.toHTML(e)+`)`:this.content.toHTML(e)}_toTex(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`\\left(${this.content.toTex(e)}\\right)`:this.content.toTex(e)}}return YA(n,`name`,NF),n},{isClass:!0,isNode:!0}),FF=`RangeNode`,IF=Y(FF,[`Node`],e=>{var{Node:t}=e;function n(e,t,n){var r=iF(e,t,n),i={},a=iF(e.start,t,n);if(i.start=a!==null&&a<=r||t===`all`,e.step){var o=iF(e.step,t,n);i.step=o!==null&&o<=r||t===`all`}var s=iF(e.end,t,n);return i.end=s!==null&&s<=r||t===`all`,i}class r extends t{constructor(e,t,n){if(super(),!sb(e)||!sb(t)||n&&!sb(n))throw TypeError(`Node expected`);if(arguments.length>3)throw Error(`Too many arguments`);this.start=e,this.end=t,this.step=n||null}get type(){return FF}get isRangeNode(){return!0}needsEnd(){return this.filter(function(e){return pb(e)&&e.name===`end`}).length>0}_compile(e,t){var n=e.range,r=this.start._compile(e,t),i=this.end._compile(e,t);if(this.step){var a=this.step._compile(e,t);return function(e,t,o){return n(r(e,t,o),i(e,t,o),a(e,t,o))}}else return function(e,t,a){return n(r(e,t,a),i(e,t,a))}}forEach(e){e(this.start,`start`,this),e(this.end,`end`,this),this.step&&e(this.step,`step`,this)}map(e){return new r(this._ifNode(e(this.start,`start`,this)),this._ifNode(e(this.end,`end`,this)),this.step&&this._ifNode(e(this.step,`step`,this)))}clone(){return new r(this.start,this.end,this.step&&this.step)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i,a=this.start.toString(e);if(r.start&&(a=`(`+a+`)`),i=a,this.step){var o=this.step.toString(e);r.step&&(o=`(`+o+`)`),i+=`:`+o}var s=this.end.toString(e);return r.end&&(s=`(`+s+`)`),i+=`:`+s,i}toJSON(){return{mathjs:FF,start:this.start,end:this.end,step:this.step}}static fromJSON(e){return new r(e.start,e.end,e.step)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i,a=this.start.toHTML(e);if(r.start&&(a=`(`+a+`)`),i=a,this.step){var o=this.step.toHTML(e);r.step&&(o=`(`+o+`)`),i+=`:`+o}var s=this.end.toHTML(e);return r.end&&(s=`(`+s+`)`),i+=`:`+s,i}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i=this.start.toTex(e);if(r.start&&(i=`\\left(${i}\\right)`),this.step){var a=this.step.toTex(e);r.step&&(a=`\\left(${a}\\right)`),i+=`:`+a}var o=this.end.toTex(e);return r.end&&(o=`\\left(${o}\\right)`),i+=`:`+o,i}}return YA(r,`name`,FF),r},{isClass:!0,isNode:!0}),LF=`RelationalNode`,RF=Y(LF,[`Node`],e=>{var{Node:t}=e,n={equal:`==`,unequal:`!=`,smaller:`<`,larger:`>`,smallerEq:`<=`,largerEq:`>=`};class r extends t{constructor(e,t){if(super(),!Array.isArray(e))throw TypeError(`Parameter conditionals must be an array`);if(!Array.isArray(t))throw TypeError(`Parameter params must be an array`);if(e.length!==t.length-1)throw TypeError(`Parameter params must contain exactly one more element than parameter conditionals`);this.conditionals=e,this.params=t}get type(){return LF}get isRelationalNode(){return!0}_compile(e,t){var n=this,r=this.params.map(n=>n._compile(e,t));return function(t,i,a){for(var o,s=r[0](t,i,a),c=0;ce(t,`params[`+n+`]`,this),this)}map(e){return new r(this.conditionals.slice(),this.params.map((t,n)=>this._ifNode(e(t,`params[`+n+`]`,this)),this))}clone(){return new r(this.conditionals,this.params)}_toString(e){for(var t=e&&e.parenthesis?e.parenthesis:`keep`,r=iF(this,t,e&&e.implicit),i=this.params.map(function(n,i){var a=iF(n,t,e&&e.implicit);return t===`all`||a!==null&&a<=r?`(`+n.toString(e)+`)`:n.toString(e)}),a=i[0],o=0;o(`+n.toHTML(e)+`)`:n.toHTML(e)}),a=i[0],o=0;o`+JC(n[this.conditionals[o]])+``+i[o+1];return a}_toTex(e){for(var t=e&&e.parenthesis?e.parenthesis:`keep`,n=iF(this,t,e&&e.implicit),r=this.params.map(function(r,i){var a=iF(r,t,e&&e.implicit);return t===`all`||a!==null&&a<=n?`\\left(`+r.toTex(e)+`\right)`:r.toTex(e)}),i=r[0],a=0;a{var{math:t,Unit:n,Node:r}=e;function i(e){return n?n.isValuelessUnit(e):!1}class a extends r{constructor(e){if(super(),typeof e!=`string`)throw TypeError(`String expected for parameter "name"`);this.name=e}get type(){return`SymbolNode`}get isSymbolNode(){return!0}_compile(e,t){var r=this.name;if(t[r]===!0)return function(e,t,n){return uy(t,r)};if(r in e)return function(t,n,i){return t.has(r)?t.get(r):uy(e,r)};var o=i(r);return function(e,t,i){return e.has(r)?e.get(r):o?new n(null,r):a.onUndefinedSymbol(r)}}forEach(e){}map(e){return this.clone()}static onUndefinedSymbol(e){throw Error(`Undefined symbol `+e)}clone(){return new a(this.name)}_toString(e){return this.name}_toHTML(e){var t=JC(this.name);return t===`true`||t===`false`?``+t+``:t===`i`?``+t+``:t===`Infinity`?``+t+``:t===`NaN`?``+t+``:t===`null`?``+t+``:t===`undefined`?``+t+``:``+t+``}toJSON(){return{mathjs:`SymbolNode`,name:this.name}}static fromJSON(e){return new a(e.name)}_toTex(e){var n=!1;t[this.name]===void 0&&i(this.name)&&(n=!0);var r=xF(this.name,n);return r[0]===`\\`?r:` `+r}}return a},{isClass:!0,isNode:!0}),BF=`FunctionNode`,VF=Y(BF,[`math`,`Node`,`SymbolNode`],e=>{var t,{math:n,Node:r,SymbolNode:i}=e,a=e=>WC(e,{truncate:78});function o(e,t,n){for(var r=``,i=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,a=0,o;(o=i.exec(e))!==null;)if(r+=e.substring(a,o.index),a=o.index,o[0]===`$$`)r+=`$`,a++;else{a+=o[0].length;var s=t[o[1]];if(!s)throw ReferenceError(`Template: Property `+o[1]+` does not exist.`);if(o[2]===void 0)switch(typeof s){case`string`:r+=s;break;case`object`:if(sb(s))r+=s.toTex(n);else if(Array.isArray(s))r+=s.map(function(e,t){if(sb(e))return e.toTex(n);throw TypeError(`Template: `+o[1]+`[`+t+`] is not a Node.`)}).join(`,`);else throw TypeError(`Template: `+o[1]+` has to be a Node, String or array of Nodes`);break;default:throw TypeError(`Template: `+o[1]+` has to be a Node, String or array of Nodes`)}else if(sb(s[o[2]]&&s[o[2]]))r+=s[o[2]].toTex(n);else throw TypeError(`Template: `+o[1]+`[`+o[2]+`] is not a Node.`)}return r+=e.slice(a),r}class s extends r{constructor(e,t,n){if(super(),typeof e==`string`&&(e=new i(e)),!sb(e))throw TypeError(`Node expected as parameter "fn"`);if(!Array.isArray(t)||!t.every(sb))throw TypeError(`Array containing Nodes expected for parameter "args"`);var r=typeof n;if(!(r===`undefined`||r===`boolean`))throw TypeError(`optional flag, if specified, must be boolean`);this.fn=e,this.args=t||[],this.optional=!!n}get name(){return this.fn.name||``}get type(){return BF}get isFunctionNode(){return!0}_compile(e,t){var n=this.args.map(n=>n._compile(e,t)),r=this.optional||Zy(this.fn)&&this.fn.optionalChaining;if(pb(this.fn)){var i=this.fn.name;if(t[i]){var o=this.args;return function(t,s,c){var l=uy(s,i);if(!(r&&l===void 0)){if(typeof l!=`function`)throw TypeError(`Argument '${i}' was not a function; received: ${a(l)}`);if(l.rawArgs)return l(o,e,AF(t,s));var u=n.map(e=>e(t,s,c));return l.apply(l,u)}}}else{var c=i in e?uy(e,i):void 0,l=typeof c==`function`&&c.rawArgs===!0,u=t=>{var n;if(t.has(i))n=t.get(i);else if(i in e)n=uy(e,i);else if(r)n=void 0;else return s.onUndefinedFunction(i);if(typeof n==`function`||r&&n===void 0)return n;throw TypeError(`'${i}' is not a function; its value is: ${a(n)}`)};if(l){var d=this.args;return function(t,r,i){var a=u(t);return a.rawArgs===!0?a(d,e,AF(t,r)):a(...n.map(e=>e(t,r,i)))}}else switch(n.length){case 0:return function(e,t,n){var i=u(e);if(!(r&&i===void 0))return i()};case 1:return function(e,t,i){var a=u(e);if(!(r&&a===void 0)){var o=n[0];return a(o(e,t,i))}};case 2:return function(e,t,i){var a=u(e);if(!(r&&a===void 0)){var o=n[0],s=n[1];return a(o(e,t,i),s(e,t,i))}};default:return function(e,t,i){var a=u(e);if(!(r&&a===void 0))return a(...n.map(n=>n(e,t,i)))}}}}else if(Zy(this.fn)&&ob(this.fn.index)&&this.fn.index.isObjectProperty()){var f=this.fn.object._compile(e,t),p=this.fn.index.getObjectProperty(),m=this.args;return function(t,i,a){var o=f(t,i,a);if(!(r&&(o==null||o[p]===void 0))){var s=hy(o,p);if(s!=null&&s.rawArgs)return s(m,e,AF(t,i));var c=n.map(e=>e(t,i,a));return s.apply(o,c)}}}else{var h=this.fn.toString(),g=this.fn._compile(e,t),_=this.args;return function(t,i,o){var s=g(t,i,o);if(!(r&&s===void 0)){if(typeof s!=`function`)throw TypeError(`Expression '${h}' did not evaluate to a function; value is: ${a(s)}`);if(s.rawArgs)return s(_,e,AF(t,i));var c=n.map(e=>e(t,i,o));return s.apply(s,c)}}}}forEach(e){e(this.fn,`fn`,this);for(var t=0;t`+JC(this.fn)+`(`+t.join(`,`)+`)`}toTex(e){var t;return e&&typeof e.handler==`object`&&J(e.handler,this.name)&&(t=e.handler[this.name](this,e)),t===void 0?super.toTex(e):t}_toTex(e){var t=this.args.map(function(t){return t.toTex(e)}),r;_F[this.name]&&(r=_F[this.name]),n[this.name]&&(typeof n[this.name].toTex==`function`||typeof n[this.name].toTex==`object`||typeof n[this.name].toTex==`string`)&&(r=n[this.name].toTex);var i;switch(typeof r){case`function`:i=r(this,e);break;case`string`:i=o(r,this,e);break;case`object`:switch(typeof r[t.length]){case`function`:i=r[t.length](this,e);break;case`string`:i=o(r[t.length],this,e);break}}return i===void 0?o(vF,this,e):i}getIdentifier(){return this.type+`:`+this.name}}return t=s,YA(s,`name`,BF),YA(s,`onUndefinedFunction`,function(e){throw Error(`Undefined function `+e)}),YA(s,`fromJSON`,function(e){return new t(e.fn,e.args)}),s},{isClass:!0,isNode:!0}),HF=`parse`,UF=Y(HF,[`typed`,`numeric`,`config`,`AccessorNode`,`ArrayNode`,`AssignmentNode`,`BlockNode`,`ConditionalNode`,`ConstantNode`,`FunctionAssignmentNode`,`FunctionNode`,`IndexNode`,`ObjectNode`,`OperatorNode`,`ParenthesisNode`,`RangeNode`,`RelationalNode`,`SymbolNode`],e=>{var{typed:t,numeric:n,config:r,AccessorNode:i,ArrayNode:a,AssignmentNode:o,BlockNode:s,ConditionalNode:c,ConstantNode:l,FunctionAssignmentNode:u,FunctionNode:d,IndexNode:f,ObjectNode:p,OperatorNode:m,ParenthesisNode:h,RangeNode:g,RelationalNode:_,SymbolNode:v}=e,y=t(HF,{string:function(e){return re(e,{})},"Array | Matrix":function(e){return b(e,{})},"string, Object":function(e,t){return re(e,t.nodes===void 0?{}:t.nodes)},"Array | Matrix, Object":b});function b(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.nodes===void 0?{}:t.nodes;return qw(e,function(e){if(typeof e!=`string`)throw TypeError(`String expected`);return re(e,n)})}var x={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},S={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"?.":!0,"??":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},C={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},w={true:!0,false:!1,null:null,undefined:void 0},T=[`NaN`,`Infinity`],E={'"':`"`,"'":`'`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:` `,r:`\r`,t:` `};function D(){return{extraNodes:{},expression:``,comment:``,index:0,token:``,tokenType:x.NULL,nestingLevel:0,conditionalLevel:null}}function O(e,t){return e.expression.substr(e.index,t)}function k(e){return O(e,1)}function A(e){e.index++}function j(e){return e.expression.charAt(e.index-1)}function M(e){return e.expression.charAt(e.index+1)}function N(e){for(e.tokenType=x.NULL,e.token=``,e.comment=``;;){if(k(e)===`#`)for(;k(e)!==` `&&k(e)!==``;)e.comment+=k(e),A(e);if(y.isWhitespace(k(e),e.nestingLevel))A(e);else break}if(k(e)===``){e.tokenType=x.DELIMITER;return}if(k(e)===` `&&!e.nestingLevel){e.tokenType=x.DELIMITER,e.token=k(e),A(e);return}var t=k(e),n=O(e,2),r=O(e,3);if(r.length===3&&S[r]){e.tokenType=x.DELIMITER,e.token=r,A(e),A(e),A(e);return}if(n.length===2&&S[n]&&(n!==`?.`||!y.isDigit(e.expression.charAt(e.index+2)))){e.tokenType=x.DELIMITER,e.token=n,A(e),A(e);return}if(S[t]){e.tokenType=x.DELIMITER,e.token=t,A(e);return}if(y.isDigitDot(t)){e.tokenType=x.NUMBER;var i=O(e,2);if(i===`0b`||i===`0o`||i===`0x`){for(e.token+=k(e),A(e),e.token+=k(e),A(e);y.isAlpha(k(e),j(e),M(e))||y.isDigit(k(e));)e.token+=k(e),A(e);if(k(e)===`.`)for(e.token+=`.`,A(e);y.isAlpha(k(e),j(e),M(e))||y.isDigit(k(e));)e.token+=k(e),A(e);else if(k(e)===`i`)for(e.token+=`i`,A(e);y.isDigit(k(e));)e.token+=k(e),A(e);return}if(k(e)===`.`){if(e.token+=k(e),A(e),!y.isDigit(k(e))){e.tokenType=x.DELIMITER;return}}else{for(;y.isDigit(k(e));)e.token+=k(e),A(e);y.isDecimalMark(k(e),M(e))&&(e.token+=k(e),A(e))}for(;y.isDigit(k(e));)e.token+=k(e),A(e);if(k(e)===`E`||k(e)===`e`){if(y.isDigit(M(e))||M(e)===`-`||M(e)===`+`){if(e.token+=k(e),A(e),(k(e)===`+`||k(e)===`-`)&&(e.token+=k(e),A(e)),!y.isDigit(k(e)))throw Me(e,`Digit expected, got "`+k(e)+`"`);for(;y.isDigit(k(e));)e.token+=k(e),A(e);if(y.isDecimalMark(k(e),M(e)))throw Me(e,`Digit expected, got "`+k(e)+`"`)}else if(y.isDecimalMark(M(e),e.expression.charAt(e.index+2)))throw A(e),Me(e,`Digit expected, got "`+k(e)+`"`)}return}if(y.isAlpha(k(e),j(e),M(e))){for(;y.isAlpha(k(e),j(e),M(e))||y.isDigit(k(e));)e.token+=k(e),A(e);J(C,e.token)?e.tokenType=x.DELIMITER:e.tokenType=x.SYMBOL;return}for(e.tokenType=x.UNKNOWN;k(e)!==``;)e.token+=k(e),A(e);throw Me(e,`Syntax error in part "`+e.token+`"`)}function ee(e){do N(e);while(e.token===` `)}function te(e){e.nestingLevel++}function ne(e){e.nestingLevel--}y.isAlpha=function(e,t,n){return y.isValidLatinOrGreek(e)||y.isValidMathSymbol(e,n)||y.isValidMathSymbol(t,e)},y.isValidLatinOrGreek=function(e){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(e)},y.isValidMathSymbol=function(e,t){return/^[\uD835]$/.test(e)&&/^[\uDC00-\uDFFF]$/.test(t)&&/^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(t)},y.isWhitespace=function(e,t){return e===` `||e===` `||e===`\xA0`||e===` `&&t>0},y.isDecimalMark=function(e,t){return e===`.`&&t!==`/`&&t!==`*`&&t!==`^`},y.isDigitDot=function(e){return e>=`0`&&e<=`9`||e===`.`},y.isDigit=function(e){return e>=`0`&&e<=`9`};function re(e,t){var n=D();cy(n,{expression:e,extraNodes:t}),N(n);var r=P(n);if(n.token!==``)throw n.tokenType===x.DELIMITER?Ne(n,`Unexpected operator `+n.token):Me(n,`Unexpected part "`+n.token+`"`);return r}function P(e){var t,n=[],r;for(e.token!==``&&e.token!==` `&&e.token!==`;`&&(t=F(e),e.comment&&(t.comment=e.comment));e.token===` `||e.token===`;`;)n.length===0&&t&&(r=e.token!==`;`,n.push({node:t,visible:r})),N(e),e.token!==` `&&e.token!==`;`&&e.token!==``&&(t=F(e),e.comment&&(t.comment=e.comment),r=e.token!==`;`,n.push({node:t,visible:r}));return n.length>0?new s(n):(t||(t=new l(void 0),e.comment&&(t.comment=e.comment)),t)}function F(e){var t,n,r,i,a=ie(e);if(e.token===`=`){if(pb(a))return t=a.name,ee(e),r=F(e),new o(new v(t),r);if(Zy(a)){if(a.optionalChaining)throw Me(e,`Cannot assign to optional chain`);return ee(e),r=F(e),new o(a.object,a.index,r)}else if(ab(a)&&pb(a.fn)&&(i=!0,n=[],t=a.name,a.args.forEach(function(e,t){pb(e)?n[t]=e.name:i=!1}),i))return ee(e),r=F(e),new u(t,n,r);throw Me(e,`Invalid left hand side of assignment operator =`)}return a}function ie(e){for(var t=I(e);e.token===`?`;){var n=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,ee(e);var r=t,i=F(e);if(e.token!==`:`)throw Me(e,`False part of conditional expression expected`);e.conditionalLevel=null,ee(e),t=new c(r,i,F(e)),e.conditionalLevel=n}return t}function I(e){for(var t=ae(e);e.token===`or`;)ee(e),t=new m(`or`,`or`,[t,ae(e)]);return t}function ae(e){for(var t=oe(e);e.token===`xor`;)ee(e),t=new m(`xor`,`xor`,[t,oe(e)]);return t}function oe(e){for(var t=L(e);e.token===`and`;)ee(e),t=new m(`and`,`and`,[t,L(e)]);return t}function L(e){for(var t=R(e);e.token===`|`;)ee(e),t=new m(`|`,`bitOr`,[t,R(e)]);return t}function R(e){for(var t=se(e);e.token===`^|`;)ee(e),t=new m(`^|`,`bitXor`,[t,se(e)]);return t}function se(e){for(var t=ce(e);e.token===`&`;)ee(e),t=new m(`&`,`bitAnd`,[t,ce(e)]);return t}function ce(e){for(var t=[le(e)],n=[],r={"==":`equal`,"!=":`unequal`,"<":`smaller`,">":`larger`,"<=":`smallerEq`,">=":`largerEq`};J(r,e.token);){var i={name:e.token,fn:r[e.token]};n.push(i),ee(e),t.push(le(e))}return t.length===1?t[0]:t.length===2?new m(n[0].name,n[0].fn,t):new _(n.map(e=>e.fn),t)}function le(e){for(var t=ue(e),n,r,i,a={"<<":`leftShift`,">>":`rightArithShift`,">>>":`rightLogShift`};J(a,e.token);)n=e.token,r=a[n],ee(e),i=[t,ue(e)],t=new m(n,r,i);return t}function ue(e){for(var t=de(e),n,r,i,a={to:`to`,in:`to`};J(a,e.token);)n=e.token,r=a[n],ee(e),n===`in`&&`])},;`.includes(e.token)?t=new m(`*`,`multiply`,[t,new v(`in`)],!0):(i=[t,de(e)],t=new m(n,r,i));return t}function de(e){var t,n=[];if(e.token===`:`){if(e.conditionalLevel===e.nestingLevel)throw Me(e,`The true-expression of a conditional operator may not be empty`);t=new l(1)}else t=fe(e);if(e.token===`:`&&e.conditionalLevel!==e.nestingLevel){for(n.push(t);e.token===`:`&&n.length<3;)ee(e),e.token===`)`||e.token===`]`||e.token===`,`||e.token===``?n.push(new v(`end`)):n.push(fe(e));t=n.length===3?new g(n[0],n[2],n[1]):new g(n[0],n[1])}return t}function fe(e){for(var t=pe(e),n,r,i,a={"+":`add`,"-":`subtract`};J(a,e.token);){n=e.token,r=a[n],ee(e);var o=pe(e);i=o.isPercentage?[t,new m(`*`,`multiply`,[t,o])]:[t,o],t=new m(n,r,i)}return t}function pe(e){for(var t=me(e),n=t,r,i,a={"*":`multiply`,".*":`dotMultiply`,"/":`divide`,"./":`dotDivide`,"%":`mod`,mod:`mod`};J(a,e.token);)r=e.token,i=a[r],ee(e),n=me(e),t=new m(r,i,[t,n]);return t}function me(e){for(var t=he(e),n=t;e.tokenType===x.SYMBOL||e.token===`in`&&nb(t)||e.token===`in`&&lb(t)&&t.fn===`unaryMinus`&&nb(t.args[0])||e.tokenType===x.NUMBER&&!nb(n)&&(!lb(n)||n.op===`!`)||e.token===`(`;)n=he(e),t=new m(`*`,`multiply`,[t,n],!0);return t}function he(e){for(var t=z(e),n=t,r=[];e.token===`/`&&rb(n);)if(r.push(cy({},e)),ee(e),e.tokenType===x.NUMBER)if(r.push(cy({},e)),ee(e),e.tokenType===x.SYMBOL||e.token===`(`||e.token===`in`)cy(e,r.pop()),r.pop(),n=z(e),t=new m(`/`,`divide`,[t,n]);else{r.pop(),cy(e,r.pop());break}else{cy(e,r.pop());break}return t}function z(e){var t=ge(e);if(e.token===`%`){var n=cy({},e);ee(e);try{ge(e),cy(e,n)}catch{t=new m(`/`,`divide`,[t,new l(100)],!1,!0)}}return t}function ge(e){var t,n,r,i={"-":`unaryMinus`,"+":`unaryPlus`,"~":`bitNot`,not:`not`};return J(i,e.token)?(r=i[e.token],t=e.token,ee(e),n=[ge(e)],new m(t,r,n)):_e(e)}function _e(e){var t=ve(e),n,r,i;return(e.token===`^`||e.token===`.^`)&&(n=e.token,r=n===`^`?`pow`:`dotPow`,ee(e),i=[t,ge(e)],t=new m(n,r,i)),t}function ve(e){for(var t=ye(e);e.token===`??`;)ee(e),t=new m(`??`,`nullish`,[t,ye(e)]);return t}function ye(e){for(var t=be(e),n,r,i,a={"!":`factorial`,"'":`ctranspose`};J(a,e.token);)n=e.token,r=a[n],N(e),i=[t],t=new m(n,r,i),t=Se(e,t);return t}function be(e){var t=[];if(e.tokenType===x.SYMBOL&&J(e.extraNodes,e.token)){var n=e.extraNodes[e.token];if(N(e),e.token===`(`){if(t=[],te(e),N(e),e.token!==`)`)for(t.push(F(e));e.token===`,`;)N(e),t.push(F(e));if(e.token!==`)`)throw Me(e,`Parenthesis ) expected`);ne(e),N(e)}return new n(t)}return xe(e)}function xe(e){var t,r;return e.tokenType===x.SYMBOL||e.tokenType===x.DELIMITER&&e.token in C?(r=e.token,N(e),t=J(w,r)?new l(w[r]):T.includes(r)?new l(n(r,`number`)):new v(r),t=Se(e,t),t):Ce(e)}function Se(e,t,n){for(var r;;){var a=!1;e.token===`?.`&&(a=!0,N(e));var o=(e.token===`(`||e.token===`[`||e.token===`.`)&&(!n||n.includes(e.token));if(!(a||o))break;if(r=[],e.token===`(`)if(a||pb(t)||Zy(t)){if(te(e),N(e),e.token!==`)`)for(r.push(F(e));e.token===`,`;)N(e),r.push(F(e));if(e.token!==`)`)throw Me(e,`Parenthesis ) expected`);ne(e),N(e),t=new d(t,r,a)}else return t;else if(e.token===`[`){if(te(e),N(e),e.token!==`]`)for(r.push(F(e));e.token===`,`;)N(e),r.push(F(e));if(e.token!==`]`)throw Me(e,`Parenthesis ] expected`);ne(e),N(e),t=new i(t,new f(r),a)}else{if(a||N(e),!(e.tokenType===x.SYMBOL||e.tokenType===x.DELIMITER&&e.token in C)){var s=`Property name expected after `;throw s+=a?`optional chain`:`dot`,Me(e,s)}r.push(new l(e.token)),N(e),t=new i(t,new f(r,!0),a)}}return t}function Ce(e){var t,n;return e.token===`"`||e.token===`'`?(n=we(e,e.token),t=new l(n),t=Se(e,t),t):Te(e)}function we(e,t){for(var n=``;k(e)!==``&&k(e)!==t;)if(k(e)===`\\`){A(e);var r=k(e),i=E[r];if(i!==void 0)n+=i,e.index+=1;else if(r===`u`){var a=e.expression.slice(e.index+1,e.index+5);if(/^[0-9A-Fa-f]{4}$/.test(a))n+=String.fromCharCode(parseInt(a,16)),e.index+=5;else throw Me(e,`Invalid unicode character \\u${a}`)}else throw Me(e,`Bad escape character \\${r}`)}else n+=k(e),A(e);if(N(e),e.token!==t)throw Me(e,`End of string ${t} expected`);return N(e),n}function Te(e){var t,n,r,i;if(e.token===`[`){if(te(e),N(e),e.token!==`]`){var o=Ee(e);if(e.token===`;`){for(r=1,n=[o];e.token===`;`;)N(e),e.token!==`]`&&(n[r]=Ee(e),r++);if(e.token!==`]`)throw Me(e,`End of matrix ] expected`);ne(e),N(e),i=n[0].items.length;for(var s=1;s{var{typed:t,parse:n}=e;return t(WF,{string:function(e){return n(e).compile()},"Array | Matrix":function(e){return qw(e,function(e){return n(e).compile()})}})}),KF=`evaluate`,qF=Y(KF,[`typed`,`parse`],e=>{var{typed:t,parse:n}=e;return t(KF,{string:function(e){var t=Sy();return n(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return n(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=Sy();return qw(e,function(e){return n(e).compile().evaluate(t)})},"Array | Matrix, Map | Object":function(e,t){return qw(e,function(e){return n(e).compile().evaluate(t)})}})}),JF=Y(`Parser`,[`evaluate`,`parse`],e=>{var{evaluate:t,parse:n}=e;function r(){if(!(this instanceof r))throw SyntaxError(`Constructor must be called with the new operator`);Object.defineProperty(this,"scope",{value:Sy(),writable:!1})}r.prototype.type=`Parser`,r.prototype.isParser=!0,r.prototype.evaluate=function(e){return t(e,this.scope)},r.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},r.prototype.getAll=function(){return wy(this.scope)},r.prototype.getAllAsMap=function(){return this.scope};function i(e){if(e.length===0)return!1;for(var t=0;t0&&n.isDigit(i)))return!1}return!0}return r.prototype.set=function(e,t){if(!i(e))throw Error(`Invalid variable name: '${e}'. Variable names must follow the specified rules.`);return this.scope.set(e,t),t},r.prototype.remove=function(e){this.scope.delete(e)},r.prototype.clear=function(){this.scope.clear()},r.prototype.toJSON=function(){var e={mathjs:`Parser`,variables:{},functions:{}};for(var[t,n]of this.scope)if(Hy(n)){if(!YF(n))throw Error(`Cannot serialize external function ${t}`);e.functions[t]=`${n.syntax} = ${n.expr}`}else e.variables[t]=n;return e},r.fromJSON=function(e){var t=new r;return Object.entries(e.variables).forEach(e=>{var[n,r]=e;return t.set(n,r)}),Object.entries(e.functions).forEach(e=>{var[n,r]=e;return t.evaluate(r)}),t},r},{isClass:!0});function YF(e){return typeof e==`function`&&typeof e.syntax==`string`&&typeof e.expr==`string`}var XF=`parser`,ZF=Y(XF,[`typed`,`Parser`],e=>{var{typed:t,Parser:n}=e;return t(XF,{"":function(){return new n}})}),QF=`lup`,$F=Y(QF,[`typed`,`matrix`,`abs`,`addScalar`,`divideScalar`,`multiplyScalar`,`subtractScalar`,`larger`,`equalScalar`,`unaryMinus`,`DenseMatrix`,`SparseMatrix`,`Spa`],e=>{var{typed:t,matrix:n,abs:r,addScalar:i,divideScalar:a,multiplyScalar:o,subtractScalar:s,larger:c,equalScalar:l,unaryMinus:u,DenseMatrix:d,SparseMatrix:f,Spa:p}=e;return t(QF,{DenseMatrix:function(e){return m(e)},SparseMatrix:function(e){return h(e)},Array:function(e){var t=m(n(e));return{L:t.L.valueOf(),U:t.U.valueOf(),p:t.p}}});function m(e){var t=e._size[0],n=e._size[1],u=Math.min(t,n),f=gb(e._data),p=[],m=[t,u],h=[],g=[u,n],_,v,y,b=[];for(_=0;_0)for(_=0;_0&&e.forEach(0,w-1,function(t,n){f._forEachRow(t,h,g,_,function(r,i){r>t&&e.accumulate(r,u(o(i,n)))})});var D=w,k=e.get(w),A=r(k);e.forEach(w+1,t-1,function(e,t){var n=r(t);c(n,A)&&(D=e,A=n,k=t)}),w!==D&&(f._swapRows(w,D,v[1],h,g,_),f._swapRows(w,D,S[1],y,b,x),e.swap(w,D),O(w,D)),e.forEach(0,t-1,function(e,t){e<=w?(y.push(t),b.push(e)):(t=a(t,k),l(t,0)||(h.push(t),g.push(e)))})};for(w=0;w{var{typed:t,matrix:n,zeros:r,identity:i,isZero:a,equal:o,sign:s,sqrt:c,conj:l,unaryMinus:u,addScalar:d,divideScalar:f,multiplyScalar:p,subtractScalar:m,complex:h}=e;return cy(t(eI,{DenseMatrix:function(e){return _(e)},SparseMatrix:function(e){return v(e)},Array:function(e){var t=_(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t=e._size[0],n=e._size[1],h=i([t],`dense`),g=h._data,_=e.clone(),v=_._data,y,b,x,S=r([t],``);for(x=0;x0)for(var r=n[0][0].type===`Complex`?h(0):0,i=0;i=0;){var c=n[o+s],l=n[r+c];l===-1?(s--,a[t++]=c):(n[r+c]=n[i+l],++s,n[o+s]=l)}return t}function iI(e,t){if(!e)return null;var n=0,r,i=[],a=[],o=0,s=t,c=2*t;for(r=0;r=0;r--)e[r]!==-1&&(a[s+r]=a[o+e[r]],a[o+e[r]]=r);for(r=0;r{var{add:t,multiply:n,transpose:r}=e;return function(e,t){if(!t||e<=0||e>3)return null;var n=t._size,r=n[0],l=n[1],u=0,d=Math.max(16,10*Math.sqrt(l));d=Math.min(l-2,d);var f=i(e,t,r,l,d);oI(f,c,null);for(var p=f._index,m=f._ptr,h=m[l],g=[],_=[],v=0,y=l+1,b=2*(l+1),x=3*(l+1),S=4*(l+1),C=5*(l+1),w=6*(l+1),T=7*(l+1),E=g,D=a(l,m,_,v,x,E,b,T,y,w,S,C),O=o(l,m,_,C,S,w,d,y,x,E,b),k=0,A,j,M,N,ee,te,ne,re,P,F,ie,I,ae,oe,L,R;Ose?(te=M,ne=ue,re=_[v+M]-se):(te=p[ue++],ne=m[te],re=_[v+te]),ee=1;ee<=re;ee++)A=p[ne++],!((P=_[y+A])<=0)&&(le+=P,_[y+A]=-P,p[fe++]=A,_[b+A]!==-1&&(E[_[b+A]]=E[A]),E[A]===-1?_[x+_[C+A]]=_[b+A]:_[b+E[A]]=_[b+A]);te!==M&&(m[te]=sI(M),_[w+te]=0)}for(se!==0&&(h=fe),_[C+M]=le,m[M]=de,_[v+M]=fe-de,_[S+M]=-2,D=s(D,u,_,w,l),F=de;F=D?_[w+te]-=P:_[w+te]!==0&&(_[w+te]=_[C+te]+pe)}for(F=de;F0?(R+=me,p[oe++]=te,L+=te):(m[te]=sI(M),_[w+te]=0)}_[S+A]=oe-I+1;var he=oe,z=I+_[v+A];for(ue=ae+1;ue=0))for(L=E[A],A=_[T+L],_[T+L]=-1;A!==-1&&_[b+A]!==-1;A=_[b+A],D++){for(re=_[v+A],ie=_[S+A],ue=m[A]+1;ue<=m[A]+re-1;ue++)_[w+p[ue]]=D;var _e=A;for(j=_[b+A];j!==-1;){var ve=_[v+j]===re&&_[S+j]===ie;for(ue=m[j]+1;ve&&ue<=m[j]+re-1;ue++)_[w+p[ue]]!==D&&(ve=0);ve?(m[j]=sI(A),_[y+A]+=_[y+j],_[y+j]=0,_[S+j]=-1,j=_[b+j],_[b+_e]=j):(_e=j,j=_[b+j])}}for(ue=de,F=de;F=0;j--)_[y+j]>0||(_[b+j]=_[x+m[j]],_[x+m[j]]=j);for(te=l;te>=0;te--)_[y+te]<=0||m[te]!==-1&&(_[b+te]=_[x+m[te]],_[x+m[te]]=te);for(M=0,A=0;A<=l;A++)m[A]===-1&&(M=rI(A,M,_,x,b,g,w));return g.splice(g.length-1,1),g};function i(e,i,a,o,s){var c=r(i);if(e===1&&o===a)return t(i,c);if(e===2){for(var l=c._index,u=c._ptr,d=0,f=0;fs))for(var m=u[f+1];po)n[s+f]=0,n[i+f]=-1,d++,t[f]=sI(e),n[s+e]++;else{var m=n[c+p];m!==-1&&(l[m]=f),n[u+f]=n[c+p],n[c+p]=f}}return d}function s(e,t,n,r,i){if(e<2||e+t<0){for(var a=0;a{var{transpose:t}=e;return function(e,n,r,i){if(!e||!n||!r)return null;var a=e._size,o=a[0],s=a[1],c,l,u,d,f,p,m,h=4*s+(i?s+o+1:0),g=[],_=0,v=s,y=2*s,b=3*s,x=4*s,S=5*s+1;for(u=0;u=1&&C[l]++,D.jleaf===2&&C[D.q]--}n[l]!==-1&&(g[_+l]=n[l])}for(l=0;l{var{add:t,multiply:n,transpose:r}=e,i=cI({add:t,multiply:n,transpose:r}),a=uI({transpose:r});return function(e,t,n){var r=t._ptr,s=t._size[1],c,l={};if(l.q=i(e,t),e&&!l.q)return null;if(n){var u=e?nI(t,null,l.q,0):t;l.parent=aI(u,1);var d=iI(l.parent,s);if(l.cp=a(u,l.parent,d,1),u&&l.parent&&l.cp&&o(u,l))for(l.unz=0,c=0;c=0;g--)for(v=n[g],y=n[g+1],_=v;_=0;h--)c[h]=-1,g=l[h],g!==-1&&(u[m+g]++===0&&(u[p+g]=h),u[d+h]=u[f+g],u[f+g]=h);for(t.lnz=0,t.m2=a,g=0;g=0;){e=r[d];var f=i?i[e]:e;fI(o,e)||(pI(o,e),r[s+d]=f<0?0:mI(o[f]));var p=1;for(l=r[s+d],u=f<0?0:mI(o[f+1]);l{var{divideScalar:t,multiply:n,subtract:r}=e;return function(e,i,a,o,s,c,l){var u=e._values,d=e._index,f=e._ptr,p=e._size[1],m=i._values,h=i._index,g=i._ptr,_,v,y,b,x=gI(e,i,a,o,c);for(_=x;_{var{abs:t,divideScalar:n,multiply:r,subtract:i,larger:a,largerEq:o,SparseMatrix:s}=e,c=_I({divideScalar:n,multiply:r,subtract:i});return function(e,i,l){if(!e)return null;var u=e._size[1],d,f=100,p=100;i&&(d=i.q,f=i.lnz||f,p=i.unz||p);var m=[],h=[],g=[],_=new s({values:m,index:h,ptr:g,size:[u,u]}),v=[],y=[],b=[],x=new s({values:v,index:y,ptr:b,size:[u,u]}),S=[],C,w,T=[],E=[];for(C=0;C{var{typed:t,abs:n,add:r,multiply:i,transpose:a,divideScalar:o,subtract:s,larger:c,largerEq:l,SparseMatrix:u}=e,d=dI({add:r,multiply:i,transpose:a}),f=vI({abs:n,divideScalar:o,multiply:i,subtract:s,larger:c,largerEq:l,SparseMatrix:u});return t(yI,{"SparseMatrix, number, number":function(e,t,n){if(!X(t)||t<0||t>3)throw Error(`Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]`);if(n<0||n>1)throw Error(`Partial pivoting threshold must be a number from 0 to 1`);var r=d(t,e,!1),i=f(e,r,n);return{L:i.L,U:i.U,p:i.pinv,q:r.q,toString:function(){return`L: `+this.L.toString()+` U: `+this.U.toString()+` p: `+this.p.toString()+(this.q?` q: `+this.q.toString():``)+` `}}}})});function xI(e,t){var n,r=t.length,i=[];if(e)for(n=0;n{var{typed:t,matrix:n,lup:r,slu:i,usolve:a,lsolve:o,DenseMatrix:s}=e,c=Xj({DenseMatrix:s});return t(SI,{"Array, Array | Matrix":function(e,t){e=n(e);var i=r(e);return u(i.L,i.U,i.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var n=r(e);return u(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var n=r(e);return u(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,n,r){var a=i(e,n,r);return u(a.L,a.U,a.p,a.q,t)},"Object, Array | Matrix":function(e,t){return u(e.L,e.U,e.p,e.q,t)}});function l(e){if(Ny(e))return e;if(My(e))return n(e);throw TypeError(`Invalid Matrix LU decomposition`)}function u(e,t,n,r,i){e=l(e),t=l(t),n&&(i=c(e,i,!0),i._data=xI(n,i._data));var s=o(e,i),u=a(t,s);return r&&(u._data=xI(r,u._data)),u}}),wI=`polynomialRoot`,TI=Y(wI,[`typed`,`isZero`,`equalScalar`,`add`,`subtract`,`multiply`,`divide`,`sqrt`,`unaryMinus`,`cbrt`,`typeOf`,`im`,`re`],e=>{var{typed:t,isZero:n,equalScalar:r,add:i,subtract:a,multiply:o,divide:s,sqrt:c,unaryMinus:l,cbrt:u,typeOf:d,im:f,re:p}=e;return t(wI,{"number|Complex, ...number|Complex":(e,t)=>{for(var m=[e,...t];m.length>0&&n(m[m.length-1]);)m.pop();if(m.length<2)throw RangeError(`Polynomial [${e}, ${t}] must have a non-zero non-constant coefficient`);switch(m.length){case 2:return[l(s(m[0],m[1]))];case 3:var[h,g,_]=m,v=o(2,_),y=o(g,g),b=o(4,_,h);if(r(y,b))return[s(l(g),v)];var x=c(a(y,b));return[s(a(x,g),v),s(a(l(x),g),v)];case 4:var[S,C,w,T]=m,E=l(o(3,T)),D=o(w,w),O=o(3,T,C),k=i(o(2,w,w,w),o(27,T,T,S)),A=o(9,T,w,C);if(r(D,O)&&r(k,A))return[s(w,E)];var j=a(D,O),M=a(k,A);return r(i(o(18,T,w,C,S),o(w,w,C,C)),i(o(4,w,w,w,S),o(4,T,C,C,C),o(27,T,T,S,S)))?[s(a(o(4,T,w,C),i(o(9,T,T,S),o(w,w,w))),o(T,j)),s(a(o(9,T,S),o(w,C)),o(2,j))]:u(r(D,O)?M:s(i(M,c(a(o(M,M),o(4,j,j,j)))),2),!0).toArray().map(e=>s(i(w,e,s(j,e)),E)).map(e=>d(e)===`Complex`&&r(p(e),p(e)+f(e))?p(e):e);default:throw RangeError(`only implemented for cubic or lower-order polynomials, not ${m}`)}}})}),EI=Y(`Help`,[`evaluate`],e=>{var{evaluate:t}=e;function n(e){if(!(this instanceof n))throw SyntaxError(`Constructor must be called with the new operator`);if(!e)throw Error(`Argument "doc" missing`);this.doc=e}return n.prototype.type=`Help`,n.prototype.isHelp=!0,n.prototype.toString=function(){var e=this.doc||{},n=` `;if(e.name&&(n+=`Name: `+e.name+` `),e.category&&(n+=`Category: `+e.category+` `),e.description&&(n+=`Description: `+e.description+` `),e.syntax&&(n+=`Syntax: `+e.syntax.join(` `)+` `),e.examples){n+=`Examples: `;for(var r=!1,i=t(`config()`),a={config:e=>(r=!0,t(`config(newConfig)`,{newConfig:e}))},o=0;oe!==`mathjs`).forEach(n=>{t[n]=e[n]}),new n(t)},n.prototype.valueOf=n.prototype.toString,n},{isClass:!0}),DI=Y(`Chain`,[`?on`,`math`,`typed`],e=>{var{on:t,math:n,typed:r}=e;function i(e){if(!(this instanceof i))throw SyntaxError(`Constructor must be called with the new operator`);mb(e)?this.value=e.value:this.value=e}i.prototype.type=`Chain`,i.prototype.isChain=!0,i.prototype.done=function(){return this.value},i.prototype.valueOf=function(){return this.value},i.prototype.toString=function(){return WC(this.value)},i.prototype.toJSON=function(){return{mathjs:`Chain`,value:this.value}},i.fromJSON=function(e){return new i(e.value)};function a(e,t){typeof t==`function`&&(i.prototype[e]=s(t))}function o(e,t){Cb(i.prototype,e,function(){var e=t();if(typeof e==`function`)return s(e)})}function s(e){return function(){if(arguments.length===0)return new i(e(this.value));for(var t=[this.value],n=0;ne[t])};for(var r in e)n(r)}};var c={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return i.createProxy(n),t&&t(`import`,function(e,t,n){n||o(e,t)}),i},{isClass:!0}),OI={name:`e`,category:`Constants`,syntax:[`e`],description:`Euler's number, the base of the natural logarithm. Approximately equal to 2.71828`,examples:[`e`,`e ^ 2`,`exp(2)`,`log(e)`],seealso:[`exp`]},kI={name:`false`,category:`Constants`,syntax:[`false`],description:`Boolean value false`,examples:[`false`],seealso:[`true`]},AI={name:`i`,category:`Constants`,syntax:[`i`],description:`Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.`,examples:[`i`,`i * i`,`sqrt(-1)`],seealso:[]},jI={name:`Infinity`,category:`Constants`,syntax:[`Infinity`],description:`Infinity, a number which is larger than the maximum number that can be handled by a floating point number.`,examples:[`Infinity`,`1 / 0`],seealso:[]},MI={name:`LN10`,category:`Constants`,syntax:[`LN10`],description:`Returns the natural logarithm of 10, approximately equal to 2.302`,examples:[`LN10`,`log(10)`],seealso:[]},NI={name:`LN2`,category:`Constants`,syntax:[`LN2`],description:`Returns the natural logarithm of 2, approximately equal to 0.693`,examples:[`LN2`,`log(2)`],seealso:[]},PI={name:`LOG10E`,category:`Constants`,syntax:[`LOG10E`],description:`Returns the base-10 logarithm of E, approximately equal to 0.434`,examples:[`LOG10E`,`log(e, 10)`],seealso:[]},FI={name:`LOG2E`,category:`Constants`,syntax:[`LOG2E`],description:`Returns the base-2 logarithm of E, approximately equal to 1.442`,examples:[`LOG2E`,`log(e, 2)`],seealso:[]},II={name:`NaN`,category:`Constants`,syntax:[`NaN`],description:`Not a number`,examples:[`NaN`,`0 / 0`],seealso:[]},LI={name:`null`,category:`Constants`,syntax:[`null`],description:`Value null`,examples:[`null`],seealso:[`true`,`false`]},RI={name:`phi`,category:`Constants`,syntax:[`phi`],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:[`phi`],seealso:[]},zI={name:`pi`,category:`Constants`,syntax:[`pi`],description:`The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159`,examples:[`pi`,`sin(pi/2)`],seealso:[`tau`]},BI={bignumber:{name:`bignumber`,category:`Construction`,syntax:[`bignumber(x)`],description:`Create a big number from a number or string.`,examples:[`0.1 + 0.2`,`bignumber(0.1) + bignumber(0.2)`,`bignumber("7.2")`,`bignumber("7.2e500")`,`bignumber([0.1, 0.2, 0.3])`],seealso:[`boolean`,`bigint`,`complex`,`fraction`,`index`,`matrix`,`string`,`unit`]},bigint:{name:`bigint`,category:`Construction`,syntax:[`bigint(x)`],description:`Create a bigint, an integer with an arbitrary number of digits, from a number or string.`,examples:[`123123123123123123 # a large number will lose digits`,`bigint("123123123123123123")`,`bignumber(["1", "3", "5"])`],seealso:[`boolean`,`bignumber`,`number`,`complex`,`fraction`,`index`,`matrix`,`string`,`unit`]},boolean:{name:`boolean`,category:`Construction`,syntax:[`x`,`boolean(x)`],description:`Convert a string or number into a boolean.`,examples:[`boolean(0)`,`boolean(1)`,`boolean(3)`,`boolean("true")`,`boolean("false")`,`boolean([1, 0, 1, 1])`],seealso:[`bignumber`,`complex`,`index`,`matrix`,`number`,`string`,`unit`]},complex:{name:`complex`,category:`Construction`,syntax:[`complex()`,`complex(re, im)`,`complex(string)`],description:`Create a complex number.`,examples:[`complex()`,`complex(2, 3)`,`complex("7 - 2i")`],seealso:[`bignumber`,`boolean`,`index`,`matrix`,`number`,`string`,`unit`]},createUnit:{name:`createUnit`,category:`Construction`,syntax:[`createUnit(definitions)`,`createUnit(name, definition)`],description:`Create a user-defined unit and register it with the Unit type.`,examples:[`createUnit("foo")`,`createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})`,`createUnit("mph", "1 mile/hour")`],seealso:[`unit`,`splitUnit`]},fraction:{name:`fraction`,category:`Construction`,syntax:[`fraction(num)`,`fraction(matrix)`,`fraction(num,den)`,`fraction({n: num, d: den})`],description:`Create a fraction from a number or from integer numerator and denominator.`,examples:[`fraction(0.125)`,`fraction(1, 3) + fraction(2, 5)`,`fraction({n: 333, d: 53})`,`fraction([sqrt(9), sqrt(10), sqrt(11)])`],seealso:[`bignumber`,`boolean`,`complex`,`index`,`matrix`,`string`,`unit`]},index:{name:`index`,category:`Construction`,syntax:[`[start]`,`[start:end]`,`[start:step:end]`,`[start1, start 2, ...]`,`[start1:end1, start2:end2, ...]`,`[start1:step1:end1, start2:step2:end2, ...]`],description:`Create an index to get or replace a subset of a matrix`,examples:[`A = [1, 2, 3; 4, 5, 6]`,`A[1, :]`,`A[1, 2] = 50`,`A[1:2, 1:2] = 1`,`B = [1, 2, 3]`,`B[B>1 and B<3]`],seealso:[`bignumber`,`boolean`,`complex`,`matrix`,`number`,`range`,`string`,`unit`]},matrix:{name:`matrix`,category:`Construction`,syntax:[`[]`,`[a1, b1, ...; a2, b2, ...]`,`matrix()`,`matrix("dense")`,`matrix([...])`],description:`Create a matrix.`,examples:[`[]`,`[1, 2, 3]`,`[1, 2, 3; 4, 5, 6]`,`matrix()`,`matrix([3, 4])`,`matrix([3, 4; 5, 6], "sparse")`,`matrix([3, 4; 5, 6], "sparse", "number")`],seealso:[`bignumber`,`boolean`,`complex`,`index`,`number`,`string`,`unit`,`sparse`]},number:{name:`number`,category:`Construction`,syntax:[`x`,`number(x)`,`number(unit, valuelessUnit)`],description:`Create a number or convert a string or boolean into a number.`,examples:[`2`,`2e3`,`4.05`,`number(2)`,`number("7.2")`,`number(true)`,`number([true, false, true, true])`,`number(unit("52cm"), "m")`],seealso:[`bignumber`,`bigint`,`boolean`,`complex`,`fraction`,`index`,`matrix`,`string`,`unit`]},sparse:{name:`sparse`,category:`Construction`,syntax:[`sparse()`,`sparse([a1, b1, ...; a1, b2, ...])`,`sparse([a1, b1, ...; a1, b2, ...], "number")`],description:`Create a sparse matrix.`,examples:[`sparse()`,`sparse([3, 4; 5, 6])`,`sparse([3, 0; 5, 0], "number")`],seealso:[`bignumber`,`boolean`,`complex`,`index`,`number`,`string`,`unit`,`matrix`]},splitUnit:{name:`splitUnit`,category:`Construction`,syntax:[`splitUnit(unit: Unit, parts: Unit[])`],description:`Split a unit in an array of units whose sum is equal to the original unit.`,examples:[`splitUnit(1 m, ["feet", "inch"])`],seealso:[`unit`,`createUnit`]},string:{name:`string`,category:`Construction`,syntax:[`"text"`,`string(x)`],description:`Create a string or convert a value to a string`,examples:[`"Hello World!"`,`string(4.2)`,`string(3 + 2i)`],seealso:[`bignumber`,`boolean`,`complex`,`index`,`matrix`,`number`,`unit`]},unit:{name:`unit`,category:`Construction`,syntax:[`value unit`,`unit(value, unit)`,`unit(string)`],description:`Create a unit.`,examples:[`5.5 mm`,`3 inch`,`unit(7.1, "kilogram")`,`unit("23 deg")`],seealso:[`bignumber`,`boolean`,`complex`,`index`,`matrix`,`number`,`string`]},e:OI,E:OI,false:kI,i:AI,Infinity:jI,LN2:NI,LN10:MI,LOG2E:FI,LOG10E:PI,NaN:II,null:LI,pi:zI,PI:zI,phi:RI,SQRT1_2:{name:`SQRT1_2`,category:`Constants`,syntax:[`SQRT1_2`],description:`Returns the square root of 1/2, approximately equal to 0.707`,examples:[`SQRT1_2`,`sqrt(1/2)`],seealso:[]},SQRT2:{name:`SQRT2`,category:`Constants`,syntax:[`SQRT2`],description:`Returns the square root of 2, approximately equal to 1.414`,examples:[`SQRT2`,`sqrt(2)`],seealso:[]},tau:{name:`tau`,category:`Constants`,syntax:[`tau`],description:`Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.`,examples:[`tau`,`2 * pi`],seealso:[`pi`]},true:{name:`true`,category:`Constants`,syntax:[`true`],description:`Boolean value true`,examples:[`true`],seealso:[`false`]},version:{name:`version`,category:`Constants`,syntax:[`version`],description:`A string with the version number of math.js`,examples:[`version`],seealso:[]},speedOfLight:{description:`Speed of light in vacuum`,examples:[`speedOfLight`]},gravitationConstant:{description:`Newtonian constant of gravitation`,examples:[`gravitationConstant`]},planckConstant:{description:`Planck constant`,examples:[`planckConstant`]},reducedPlanckConstant:{description:`Reduced Planck constant`,examples:[`reducedPlanckConstant`]},magneticConstant:{description:`Magnetic constant (vacuum permeability)`,examples:[`magneticConstant`]},electricConstant:{description:`Electric constant (vacuum permeability)`,examples:[`electricConstant`]},vacuumImpedance:{description:`Characteristic impedance of vacuum`,examples:[`vacuumImpedance`]},coulomb:{description:`Coulomb's constant. Deprecated in favor of coulombConstant`,examples:[`coulombConstant`]},coulombConstant:{description:`Coulomb's constant`,examples:[`coulombConstant`]},elementaryCharge:{description:`Elementary charge`,examples:[`elementaryCharge`]},bohrMagneton:{description:`Bohr magneton`,examples:[`bohrMagneton`]},conductanceQuantum:{description:`Conductance quantum`,examples:[`conductanceQuantum`]},inverseConductanceQuantum:{description:`Inverse conductance quantum`,examples:[`inverseConductanceQuantum`]},magneticFluxQuantum:{description:`Magnetic flux quantum`,examples:[`magneticFluxQuantum`]},nuclearMagneton:{description:`Nuclear magneton`,examples:[`nuclearMagneton`]},klitzing:{description:`Von Klitzing constant`,examples:[`klitzing`]},bohrRadius:{description:`Bohr radius`,examples:[`bohrRadius`]},classicalElectronRadius:{description:`Classical electron radius`,examples:[`classicalElectronRadius`]},electronMass:{description:`Electron mass`,examples:[`electronMass`]},fermiCoupling:{description:`Fermi coupling constant`,examples:[`fermiCoupling`]},fineStructure:{description:`Fine-structure constant`,examples:[`fineStructure`]},hartreeEnergy:{description:`Hartree energy`,examples:[`hartreeEnergy`]},protonMass:{description:`Proton mass`,examples:[`protonMass`]},deuteronMass:{description:`Deuteron Mass`,examples:[`deuteronMass`]},neutronMass:{description:`Neutron mass`,examples:[`neutronMass`]},quantumOfCirculation:{description:`Quantum of circulation`,examples:[`quantumOfCirculation`]},rydberg:{description:`Rydberg constant`,examples:[`rydberg`]},thomsonCrossSection:{description:`Thomson cross section`,examples:[`thomsonCrossSection`]},weakMixingAngle:{description:`Weak mixing angle`,examples:[`weakMixingAngle`]},efimovFactor:{description:`Efimov factor`,examples:[`efimovFactor`]},atomicMass:{description:`Atomic mass constant`,examples:[`atomicMass`]},avogadro:{description:`Avogadro's number`,examples:[`avogadro`]},boltzmann:{description:`Boltzmann constant`,examples:[`boltzmann`]},faraday:{description:`Faraday constant`,examples:[`faraday`]},firstRadiation:{description:`First radiation constant`,examples:[`firstRadiation`]},loschmidt:{description:`Loschmidt constant at T=273.15 K and p=101.325 kPa`,examples:[`loschmidt`]},gasConstant:{description:`Gas constant`,examples:[`gasConstant`]},molarPlanckConstant:{description:`Molar Planck constant`,examples:[`molarPlanckConstant`]},molarVolume:{description:`Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa`,examples:[`molarVolume`]},sackurTetrode:{description:`Sackur-Tetrode constant at T=1 K and p=101.325 kPa`,examples:[`sackurTetrode`]},secondRadiation:{description:`Second radiation constant`,examples:[`secondRadiation`]},stefanBoltzmann:{description:`Stefan-Boltzmann constant`,examples:[`stefanBoltzmann`]},wienDisplacement:{description:`Wien displacement law constant`,examples:[`wienDisplacement`]},molarMass:{description:`Molar mass constant`,examples:[`molarMass`]},molarMassC12:{description:`Molar mass constant of carbon-12`,examples:[`molarMassC12`]},gravity:{description:`Standard acceleration of gravity (standard acceleration of free-fall on Earth)`,examples:[`gravity`]},planckLength:{description:`Planck length`,examples:[`planckLength`]},planckMass:{description:`Planck mass`,examples:[`planckMass`]},planckTime:{description:`Planck time`,examples:[`planckTime`]},planckCharge:{description:`Planck charge`,examples:[`planckCharge`]},planckTemperature:{description:`Planck temperature`,examples:[`planckTemperature`]},derivative:{name:`derivative`,category:`Algebra`,syntax:[`derivative(expr, variable)`,`derivative(expr, variable, {simplify: boolean})`],description:`Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.`,examples:[`derivative("2x^3", "x")`,`derivative("2x^3", "x", {simplify: false})`,`derivative("2x^2 + 3x + 4", "x")`,`derivative("sin(2x)", "x")`,`f = parse("x^2 + x")`,`x = parse("x")`,`df = derivative(f, x)`,`df.evaluate({x: 3})`],seealso:[`simplify`,`parse`,`evaluate`]},lsolve:{name:`lsolve`,category:`Algebra`,syntax:[`x=lsolve(L, b)`],description:`Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.`,examples:[`a = [-2, 3; 2, 1]`,`b = [11, 9]`,`x = lsolve(a, b)`],seealso:[`lsolveAll`,`lup`,`lusolve`,`usolve`,`matrix`,`sparse`]},lsolveAll:{name:`lsolveAll`,category:`Algebra`,syntax:[`x=lsolveAll(L, b)`],description:`Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.`,examples:[`a = [-2, 3; 2, 1]`,`b = [11, 9]`,`x = lsolve(a, b)`],seealso:[`lsolve`,`lup`,`lusolve`,`usolve`,`matrix`,`sparse`]},lup:{name:`lup`,category:`Algebra`,syntax:[`lup(m)`],description:`Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U`,examples:[`lup([[2, 1], [1, 4]])`,`lup(matrix([[2, 1], [1, 4]]))`,`lup(sparse([[2, 1], [1, 4]]))`],seealso:[`lusolve`,`lsolve`,`usolve`,`matrix`,`sparse`,`slu`,`qr`]},lusolve:{name:`lusolve`,category:`Algebra`,syntax:[`x=lusolve(A, b)`,`x=lusolve(lu, b)`],description:`Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.`,examples:[`a = [-2, 3; 2, 1]`,`b = [11, 9]`,`x = lusolve(a, b)`],seealso:[`lup`,`slu`,`lsolve`,`usolve`,`matrix`,`sparse`]},leafCount:{name:`leafCount`,category:`Algebra`,syntax:[`leafCount(expr)`],description:`Computes the number of leaves in the parse tree of the given expression`,examples:[`leafCount("e^(i*pi)-1")`,`leafCount(parse("{a: 22/7, b: 10^(1/2)}"))`],seealso:[`simplify`]},polynomialRoot:{name:`polynomialRoot`,category:`Algebra`,syntax:[`x=polynomialRoot(-6, 3)`,`x=polynomialRoot(4, -4, 1)`,`x=polynomialRoot(-8, 12, -6, 1)`],description:`Finds the roots of a univariate polynomial given by its coefficients starting from constant, linear, and so on, increasing in degree.`,examples:[`a = polynomialRoot(-6, 11, -6, 1)`],seealso:[`cbrt`,`sqrt`]},resolve:{name:`resolve`,category:`Algebra`,syntax:[`resolve(node, scope)`],description:`Recursively substitute variables in an expression tree.`,examples:[`resolve(parse("1 + x"), { x: 7 })`,`resolve(parse("size(text)"), { text: "Hello World" })`,`resolve(parse("x + y"), { x: parse("3z") })`,`resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })`],seealso:[`simplify`,`evaluate`],mayThrow:[`ReferenceError`]},simplify:{name:`simplify`,category:`Algebra`,syntax:[`simplify(expr)`,`simplify(expr, rules)`],description:`Simplify an expression tree.`,examples:[`simplify("3 + 2 / 4")`,`simplify("2x + x")`,`f = parse("x * (x + 2 + x)")`,`simplified = simplify(f)`,`simplified.evaluate({x: 2})`],seealso:[`simplifyCore`,`derivative`,`evaluate`,`parse`,`rationalize`,`resolve`]},simplifyConstant:{name:`simplifyConstant`,category:`Algebra`,syntax:[`simplifyConstant(expr)`,`simplifyConstant(expr, options)`],description:`Replace constant subexpressions of node with their values.`,examples:[`simplifyConstant("(3-3)*x")`,`simplifyConstant(parse("z-cos(tau/8)"))`],seealso:[`simplify`,`simplifyCore`,`evaluate`]},simplifyCore:{name:`simplifyCore`,category:`Algebra`,syntax:[`simplifyCore(node)`],description:`Perform simple one-pass simplifications on an expression tree.`,examples:[`simplifyCore(parse("0*x"))`,`simplifyCore(parse("(x+0)*2"))`],seealso:[`simplify`,`simplifyConstant`,`evaluate`]},symbolicEqual:{name:`symbolicEqual`,category:`Algebra`,syntax:[`symbolicEqual(expr1, expr2)`,`symbolicEqual(expr1, expr2, options)`],description:`Returns true if the difference of the expressions simplifies to 0`,examples:[`symbolicEqual("x*y","y*x")`,`symbolicEqual("abs(x^2)", "x^2")`,`symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})`],seealso:[`simplify`,`evaluate`]},rationalize:{name:`rationalize`,category:`Algebra`,syntax:[`rationalize(expr)`,`rationalize(expr, scope)`,`rationalize(expr, scope, detailed)`],description:`Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.`,examples:[`rationalize("2x/y - y/(x+1)")`,`rationalize("2x/y - y/(x+1)", true)`],seealso:[`simplify`]},slu:{name:`slu`,category:`Algebra`,syntax:[`slu(A, order, threshold)`],description:`Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U`,examples:[`slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)`],seealso:[`lusolve`,`lsolve`,`usolve`,`matrix`,`sparse`,`lup`,`qr`]},usolve:{name:`usolve`,category:`Algebra`,syntax:[`x=usolve(U, b)`],description:`Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.`,examples:[`x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])`],seealso:[`usolveAll`,`lup`,`lusolve`,`lsolve`,`matrix`,`sparse`]},usolveAll:{name:`usolveAll`,category:`Algebra`,syntax:[`x=usolve(U, b)`],description:`Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.`,examples:[`x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])`],seealso:[`usolve`,`lup`,`lusolve`,`lsolve`,`matrix`,`sparse`]},qr:{name:`qr`,category:`Algebra`,syntax:[`qr(A)`],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:[`qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])`],seealso:[`lup`,`slu`,`matrix`]},abs:{name:`abs`,category:`Arithmetic`,syntax:[`abs(x)`],description:`Compute the absolute value.`,examples:[`abs(3.5)`,`abs(-4.2)`],seealso:[`sign`]},add:{name:`add`,category:`Operators`,syntax:[`x + y`,`add(x, y)`],description:`Add two values.`,examples:[`a = 2.1 + 3.6`,`a - 3.6`,`3 + 2i`,`3 cm + 2 inch`,`"2.3" + "4"`],seealso:[`subtract`]},cbrt:{name:`cbrt`,category:`Arithmetic`,syntax:[`cbrt(x)`,`cbrt(x, allRoots)`],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:[`cbrt(64)`,`cube(4)`,`cbrt(-8)`,`cbrt(2 + 3i)`,`cbrt(8i)`,`cbrt(8i, true)`,`cbrt(27 m^3)`],seealso:[`square`,`sqrt`,`cube`,`multiply`]},ceil:{name:`ceil`,category:`Arithmetic`,syntax:[`ceil(x)`,`ceil(x, n)`,`ceil(unit, valuelessUnit)`,`ceil(unit, n, valuelessUnit)`],description:`Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.`,examples:[`ceil(3.2)`,`ceil(3.8)`,`ceil(-4.2)`,`ceil(3.241cm, cm)`,`ceil(3.241cm, 2, cm)`],seealso:[`floor`,`fix`,`round`]},cube:{name:`cube`,category:`Arithmetic`,syntax:[`cube(x)`],description:`Compute the cube of a value. The cube of x is x * x * x.`,examples:[`cube(2)`,`2^3`,`2 * 2 * 2`],seealso:[`multiply`,`square`,`pow`]},divide:{name:`divide`,category:`Operators`,syntax:[`x / y`,`divide(x, y)`],description:`Divide two values.`,examples:[`a = 2 / 3`,`a * 3`,`4.5 / 2`,`3 + 4 / 2`,`(3 + 4) / 2`,`18 km / 4.5`],seealso:[`multiply`]},dotDivide:{name:`dotDivide`,category:`Operators`,syntax:[`x ./ y`,`dotDivide(x, y)`],description:`Divide two values element wise.`,examples:[`a = [1, 2, 3; 4, 5, 6]`,`b = [2, 1, 1; 3, 2, 5]`,`a ./ b`],seealso:[`multiply`,`dotMultiply`,`divide`]},dotMultiply:{name:`dotMultiply`,category:`Operators`,syntax:[`x .* y`,`dotMultiply(x, y)`],description:`Multiply two values element wise.`,examples:[`a = [1, 2, 3; 4, 5, 6]`,`b = [2, 1, 1; 3, 2, 5]`,`a .* b`],seealso:[`multiply`,`divide`,`dotDivide`]},dotPow:{name:`dotPow`,category:`Operators`,syntax:[`x .^ y`,`dotPow(x, y)`],description:`Calculates the power of x to y element wise.`,examples:[`a = [1, 2, 3; 4, 5, 6]`,`a .^ 2`],seealso:[`pow`]},exp:{name:`exp`,category:`Arithmetic`,syntax:[`exp(x)`],description:`Calculate the exponent of a value.`,examples:[`exp(1.3)`,`e ^ 1.3`,`log(exp(1.3))`,`x = 2.4`,`(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula`],seealso:[`expm`,`expm1`,`pow`,`log`]},expm:{name:`expm`,category:`Arithmetic`,syntax:[`exp(x)`],description:`Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.`,examples:[`expm([[0,2],[0,0]])`],seealso:[`exp`]},expm1:{name:`expm1`,category:`Arithmetic`,syntax:[`expm1(x)`],description:`Calculate the value of subtracting 1 from the exponential value.`,examples:[`expm1(2)`,`pow(e, 2) - 1`,`log(expm1(2) + 1)`],seealso:[`exp`,`pow`,`log`]},fix:{name:`fix`,category:`Arithmetic`,syntax:[`fix(x)`,`fix(x, n)`,`fix(unit, valuelessUnit)`,`fix(unit, n, valuelessUnit)`],description:`Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.`,examples:[`fix(3.2)`,`fix(3.8)`,`fix(-4.2)`,`fix(-4.8)`,`fix(3.241cm, cm)`,`fix(3.241cm, 2, cm)`],seealso:[`ceil`,`floor`,`round`]},floor:{name:`floor`,category:`Arithmetic`,syntax:[`floor(x)`,`floor(x, n)`,`floor(unit, valuelessUnit)`,`floor(unit, n, valuelessUnit)`],description:`Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.`,examples:[`floor(3.2)`,`floor(3.8)`,`floor(-4.2)`,`floor(3.241cm, cm)`,`floor(3.241cm, 2, cm)`],seealso:[`ceil`,`fix`,`round`]},gcd:{name:`gcd`,category:`Arithmetic`,syntax:[`gcd(a, b)`,`gcd(a, b, c, ...)`],description:`Compute the greatest common divisor.`,examples:[`gcd(8, 12)`,`gcd(-4, 6)`,`gcd(25, 15, -10)`],seealso:[`lcm`,`xgcd`]},hypot:{name:`hypot`,category:`Arithmetic`,syntax:[`hypot(a, b, c, ...)`,`hypot([a, b, c, ...])`],description:`Calculate the hypotenuse of a list with values.`,examples:[`hypot(3, 4)`,`sqrt(3^2 + 4^2)`,`hypot(-2)`,`hypot([3, 4, 5])`],seealso:[`abs`,`norm`]},lcm:{name:`lcm`,category:`Arithmetic`,syntax:[`lcm(x, y)`],description:`Compute the least common multiple.`,examples:[`lcm(4, 6)`,`lcm(6, 21)`,`lcm(6, 21, 5)`],seealso:[`gcd`]},log:{name:`log`,category:`Arithmetic`,syntax:[`log(x)`,`log(x, base)`],description:`Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).`,examples:[`log(3.5)`,`a = log(2.4)`,`exp(a)`,`10 ^ 4`,`log(10000, 10)`,`log(10000) / log(10)`,`b = log(1024, 2)`,`2 ^ b`],seealso:[`exp`,`log1p`,`log2`,`log10`]},log2:{name:`log2`,category:`Arithmetic`,syntax:[`log2(x)`],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:[`log2(0.03125)`,`log2(16)`,`log2(16) / log2(2)`,`pow(2, 4)`],seealso:[`exp`,`log1p`,`log`,`log10`]},log1p:{name:`log1p`,category:`Arithmetic`,syntax:[`log1p(x)`,`log1p(x, base)`],description:"Calculate the logarithm of a `value+1`",examples:[`log1p(2.5)`,`exp(log1p(1.4))`,`pow(10, 4)`,`log1p(9999, 10)`,`log1p(9999) / log(10)`],seealso:[`exp`,`log`,`log2`,`log10`]},log10:{name:`log10`,category:`Arithmetic`,syntax:[`log10(x)`],description:`Compute the 10-base logarithm of a value.`,examples:[`log10(0.00001)`,`log10(10000)`,`10 ^ 4`,`log(10000) / log(10)`,`log(10000, 10)`],seealso:[`exp`,`log`]},mod:{name:`mod`,category:`Operators`,syntax:[`x % y`,`x mod y`,`mod(x, y)`],description:`Calculates the modulus, the remainder of an integer division.`,examples:[`7 % 3`,`11 % 2`,`10 mod 4`,`isOdd(x) = x % 2`,`isOdd(2)`,`isOdd(3)`],seealso:[`divide`]},multiply:{name:`multiply`,category:`Operators`,syntax:[`x * y`,`multiply(x, y)`],description:`multiply two values.`,examples:[`a = 2.1 * 3.4`,`a / 3.4`,`2 * 3 + 4`,`2 * (3 + 4)`,`3 * 2.1 km`],seealso:[`divide`]},norm:{name:`norm`,category:`Arithmetic`,syntax:[`norm(x)`,`norm(x, p)`],description:`Calculate the norm of a number, vector or matrix.`,examples:[`abs(-3.5)`,`norm(-3.5)`,`norm(3 - 4i)`,`norm([1, 2, -3], Infinity)`,`norm([1, 2, -3], -Infinity)`,`norm([3, 4], 2)`,`norm([[1, 2], [3, 4]], 1)`,`norm([[1, 2], [3, 4]], "inf")`,`norm([[1, 2], [3, 4]], "fro")`]},nthRoot:{name:`nthRoot`,category:`Arithmetic`,syntax:[`nthRoot(a)`,`nthRoot(a, root)`],description:`Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".`,examples:[`4 ^ 3`,`nthRoot(64, 3)`,`nthRoot(9, 2)`,`sqrt(9)`],seealso:[`nthRoots`,`pow`,`sqrt`]},nthRoots:{name:`nthRoots`,category:`Arithmetic`,syntax:[`nthRoots(A)`,`nthRoots(A, root)`],description:`Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.`,examples:[`nthRoots(1)`,`nthRoots(1, 3)`],seealso:[`sqrt`,`pow`,`nthRoot`]},pow:{name:`pow`,category:`Operators`,syntax:[`x ^ y`,`pow(x, y)`],description:`Calculates the power of x to y, x^y.`,examples:[`2^3`,`2*2*2`,`1 + e ^ (pi * i)`,`pow([[1, 2], [4, 3]], 2)`,`pow([[1, 2], [4, 3]], -1)`],seealso:[`multiply`,`nthRoot`,`nthRoots`,`sqrt`]},round:{name:`round`,category:`Arithmetic`,syntax:[`round(x)`,`round(x, n)`,`round(unit, valuelessUnit)`,`round(unit, n, valuelessUnit)`],description:`round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.`,examples:[`round(3.2)`,`round(3.8)`,`round(-4.2)`,`round(-4.8)`,`round(pi, 3)`,`round(123.45678, 2)`,`round(3.241cm, 2, cm)`,`round([3.2, 3.8, -4.7])`],seealso:[`ceil`,`floor`,`fix`]},sign:{name:`sign`,category:`Arithmetic`,syntax:[`sign(x)`],description:`Compute the sign of a value. The sign of a value x is 1 when x>0, -1 when x<0, and 0 when x=0.`,examples:[`sign(3.5)`,`sign(-4.2)`,`sign(0)`],seealso:[`abs`]},sqrt:{name:`sqrt`,category:`Arithmetic`,syntax:[`sqrt(x)`],description:`Compute the square root value. If x = y * y, then y is the square root of x.`,examples:[`sqrt(25)`,`5 * 5`,`sqrt(-1)`],seealso:[`square`,`sqrtm`,`multiply`,`nthRoot`,`nthRoots`,`pow`]},sqrtm:{name:`sqrtm`,category:`Arithmetic`,syntax:[`sqrtm(x)`],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:[`sqrtm([[33, 24], [48, 57]])`],seealso:[`sqrt`,`abs`,`square`,`multiply`]},square:{name:`square`,category:`Arithmetic`,syntax:[`square(x)`],description:`Compute the square of a value. The square of x is x * x.`,examples:[`square(3)`,`sqrt(9)`,`3^2`,`3 * 3`],seealso:[`multiply`,`pow`,`sqrt`,`cube`]},subtract:{name:`subtract`,category:`Operators`,syntax:[`x - y`,`subtract(x, y)`],description:`subtract two values.`,examples:[`a = 5.3 - 2`,`a + 2`,`2/3 - 1/6`,`2 * 3 - 3`,`2.1 km - 500m`],seealso:[`add`]},unaryMinus:{name:`unaryMinus`,category:`Operators`,syntax:[`-x`,`unaryMinus(x)`],description:`Inverse the sign of a value. Converts booleans and strings to numbers.`,examples:[`-4.5`,`-(-5.6)`,`-"22"`],seealso:[`add`,`subtract`,`unaryPlus`]},unaryPlus:{name:`unaryPlus`,category:`Operators`,syntax:[`+x`,`unaryPlus(x)`],description:`Converts booleans and strings to numbers.`,examples:[`+true`,`+"2"`],seealso:[`add`,`subtract`,`unaryMinus`]},xgcd:{name:`xgcd`,category:`Arithmetic`,syntax:[`xgcd(a, b)`],description:`Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.`,examples:[`xgcd(8, 12)`,`gcd(8, 12)`,`xgcd(36163, 21199)`],seealso:[`gcd`,`lcm`]},invmod:{name:`invmod`,category:`Arithmetic`,syntax:[`invmod(a, b)`],description:`Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)`,examples:[`invmod(8, 12)`,`invmod(7, 13)`,`invmod(15151, 15122)`],seealso:[`gcd`,`xgcd`]},num:{name:`num`,category:`Fraction`,syntax:[`num(x)`],description:`Get the numerator of a fraction.`,examples:[`num(fraction(2, 3))`,`num(fraction(5, 8))`],seealso:[`den`,`fraction`]},den:{name:`den`,category:`Fraction`,syntax:[`den(x)`],description:`Get the denominator of a fraction.`,examples:[`den(fraction(2, 3))`,`den(fraction(5, 8))`],seealso:[`num`,`fraction`]},bitAnd:{name:`bitAnd`,category:`Bitwise`,syntax:[`x & y`,`bitAnd(x, y)`],description:`Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0`,examples:[`5 & 3`,`bitAnd(53, 131)`,`[1, 12, 31] & 42`],seealso:[`bitNot`,`bitOr`,`bitXor`,`leftShift`,`rightArithShift`,`rightLogShift`]},bitNot:{name:`bitNot`,category:`Bitwise`,syntax:[`~x`,`bitNot(x)`],description:`Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.`,examples:[`~1`,`~2`,`bitNot([2, -3, 4])`],seealso:[`bitAnd`,`bitOr`,`bitXor`,`leftShift`,`rightArithShift`,`rightLogShift`]},bitOr:{name:`bitOr`,category:`Bitwise`,syntax:[`x | y`,`bitOr(x, y)`],description:`Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.`,examples:[`5 | 3`,`bitOr([1, 2, 3], 4)`],seealso:[`bitAnd`,`bitNot`,`bitXor`,`leftShift`,`rightArithShift`,`rightLogShift`]},bitXor:{name:`bitXor`,category:`Bitwise`,syntax:[`bitXor(x, y)`],description:`Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.`,examples:[`bitOr(1, 2)`,`bitXor([2, 3, 4], 4)`],seealso:[`bitAnd`,`bitNot`,`bitOr`,`leftShift`,`rightArithShift`,`rightLogShift`]},leftShift:{name:`leftShift`,category:`Bitwise`,syntax:[`x << y`,`leftShift(x, y)`],description:`Bitwise left logical shift of a value x by y number of bits.`,examples:[`4 << 1`,`8 >> 1`],seealso:[`bitAnd`,`bitNot`,`bitOr`,`bitXor`,`rightArithShift`,`rightLogShift`]},rightArithShift:{name:`rightArithShift`,category:`Bitwise`,syntax:[`x >> y`,`rightArithShift(x, y)`],description:`Bitwise right arithmetic shift of a value x by y number of bits.`,examples:[`8 >> 1`,`4 << 1`,`-12 >> 2`],seealso:[`bitAnd`,`bitNot`,`bitOr`,`bitXor`,`leftShift`,`rightLogShift`]},rightLogShift:{name:`rightLogShift`,category:`Bitwise`,syntax:[`x >>> y`,`rightLogShift(x, y)`],description:`Bitwise right logical shift of a value x by y number of bits.`,examples:[`8 >>> 1`,`4 << 1`,`-12 >>> 2`],seealso:[`bitAnd`,`bitNot`,`bitOr`,`bitXor`,`leftShift`,`rightArithShift`]},bellNumbers:{name:`bellNumbers`,category:`Combinatorics`,syntax:[`bellNumbers(n)`],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:[`bellNumbers(3)`,`bellNumbers(8)`],seealso:[`stirlingS2`]},catalan:{name:`catalan`,category:`Combinatorics`,syntax:[`catalan(n)`],description:`The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.`,examples:[`catalan(3)`,`catalan(8)`],seealso:[`bellNumbers`]},composition:{name:`composition`,category:`Combinatorics`,syntax:[`composition(n, k)`],description:`The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.`,examples:[`composition(5, 3)`],seealso:[`combinations`]},stirlingS2:{name:`stirlingS2`,category:`Combinatorics`,syntax:[`stirlingS2(n, k)`],description:"The Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:[`stirlingS2(5, 3)`],seealso:[`bellNumbers`,`bernoulli`]},config:{name:`config`,category:`Core`,syntax:[`config()`,`config(options)`],description:`Get configuration or change configuration.`,examples:[`config()`,`1/3 + 1/4`,`config({number: "Fraction"})`,`1/3 + 1/4`],seealso:[]},import:{name:`import`,category:`Core`,syntax:[`import(functions)`,`import(functions, options)`],description:`Import functions or constants from an object.`,examples:[`import({myFn: f(x)=x^2, myConstant: 32 })`,`myFn(2)`,`myConstant`],seealso:[]},typed:{name:`typed`,category:`Core`,syntax:[`typed(signatures)`,`typed(name, signatures)`],description:`Create a typed function.`,examples:[`double = typed({ "number": f(x)=x+x, "string": f(x)=concat(x,x) })`,`double(2)`,`double("hello")`],seealso:[]},arg:{name:`arg`,category:`Complex`,syntax:[`arg(x)`],description:`Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).`,examples:[`arg(2 + 2i)`,`atan2(3, 2)`,`arg(2 + 3i)`],seealso:[`re`,`im`,`conj`,`abs`]},conj:{name:`conj`,category:`Complex`,syntax:[`conj(x)`],description:`Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.`,examples:[`conj(2 + 3i)`,`conj(2 - 3i)`,`conj(-5.2i)`],seealso:[`re`,`im`,`abs`,`arg`]},re:{name:`re`,category:`Complex`,syntax:[`re(x)`],description:`Get the real part of a complex number.`,examples:[`re(2 + 3i)`,`im(2 + 3i)`,`re(-5.2i)`,`re(2.4)`],seealso:[`im`,`conj`,`abs`,`arg`]},im:{name:`im`,category:`Complex`,syntax:[`im(x)`],description:`Get the imaginary part of a complex number.`,examples:[`im(2 + 3i)`,`re(2 + 3i)`,`im(-5.2i)`,`im(2.4)`],seealso:[`re`,`conj`,`abs`,`arg`]},evaluate:{name:`evaluate`,category:`Expression`,syntax:[`evaluate(expression)`,`evaluate(expression, scope)`,`evaluate([expr1, expr2, expr3, ...])`,`evaluate([expr1, expr2, expr3, ...], scope)`],description:`Evaluate an expression or an array with expressions.`,examples:[`evaluate("2 + 3")`,`evaluate("sqrt(16)")`,`evaluate("2 inch to cm")`,`evaluate("sin(x * pi)", { "x": 1/2 })`,`evaluate(["width=2", "height=4","width*height"])`],seealso:[`parser`,`parse`,`compile`]},help:{name:`help`,category:`Expression`,syntax:[`help(object)`,`help(string)`],description:`Display documentation on a function or data type.`,examples:[`help(sqrt)`,`help("complex")`],seealso:[]},parse:{name:`parse`,category:`Expression`,syntax:[`parse(expr)`,`parse(expr, options)`,`parse([expr1, expr2, expr3, ...])`,`parse([expr1, expr2, expr3, ...], options)`],description:`Parse an expression. Returns a node tree, which can be evaluated by invoking node.evaluate() or transformed into a functional object via node.compile().`,examples:[`node1 = parse("sqrt(3^2 + 4^2)")`,`node1.evaluate()`,`code1 = node1.compile()`,`code1.evaluate()`,`scope = {a: 3, b: 4}`,`node2 = parse("a * b")`,`node2.evaluate(scope)`,`code2 = node2.compile()`,`code2.evaluate(scope)`],seealso:[`parser`,`evaluate`,`compile`]},parser:{name:`parser`,category:`Expression`,syntax:[`parser()`],description:`Create a parser object that keeps a context of variables and their values, allowing the evaluation of expressions in that context.`,examples:[`myParser = parser()`,`myParser.evaluate("sqrt(3^2 + 4^2)")`,`myParser.set("x", 3)`,`myParser.evaluate("y = x + 3")`,`myParser.evaluate(["y = x + 3", "y = y + 1"])`,`myParser.get("y")`],seealso:[`evaluate`,`parse`,`compile`]},compile:{name:`compile`,category:`Expression`,syntax:[`compile(expr) `,`compile([expr1, expr2, expr3, ...])`],description:`Parse and compile an expression. Returns a an object with a function evaluate([scope]) to evaluate the compiled expression.`,examples:[`code1 = compile("sqrt(3^2 + 4^2)")`,`code1.evaluate() `,`code2 = compile("a * b")`,`code2.evaluate({a: 3, b: 4})`],seealso:[`parser`,`parse`,`evaluate`]},distance:{name:`distance`,category:`Geometry`,syntax:[`distance([x1, y1], [x2, y2])`,`distance([[x1, y1], [x2, y2]])`],description:`Calculates the Euclidean distance between two points.`,examples:[`distance([0,0], [4,4])`,`distance([[0,0], [4,4]])`],seealso:[]},intersect:{name:`intersect`,category:`Geometry`,syntax:[`intersect(expr1, expr2, expr3, expr4)`,`intersect(expr1, expr2, expr3)`],description:`Computes the intersection point of lines and/or planes.`,examples:[`intersect([0, 0], [10, 10], [10, 0], [0, 10])`,`intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])`],seealso:[]},and:{name:`and`,category:`Logical`,syntax:[`x and y`,`and(x, y)`],description:`Logical and. Test whether two values are both defined with a nonzero/nonempty value.`,examples:[`true and false`,`true and true`,`2 and 4`],seealso:[`not`,`or`,`xor`]},not:{name:`not`,category:`Logical`,syntax:[`not x`,`not(x)`],description:`Logical not. Flips the boolean value of given argument.`,examples:[`not true`,`not false`,`not 2`,`not 0`],seealso:[`and`,`or`,`xor`]},nullish:{name:`nullish`,category:`Logical`,syntax:[`x ?? y`,`nullish(x, y)`],description:`Nullish coalescing operator. Returns the right-hand operand when the left-hand operand is null or undefined, and otherwise returns the left-hand operand.`,examples:[`null ?? 42`,`undefined ?? 42`,`0 ?? 42`,`false ?? 42`,`null ?? undefined ?? 42`],seealso:[`and`,`or`,`not`]},or:{name:`or`,category:`Logical`,syntax:[`x or y`,`or(x, y)`],description:`Logical or. Test if at least one value is defined with a nonzero/nonempty value.`,examples:[`true or false`,`false or false`,`0 or 4`],seealso:[`not`,`and`,`xor`]},xor:{name:`xor`,category:`Logical`,syntax:[`x xor y`,`xor(x, y)`],description:`Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.`,examples:[`true xor false`,`false xor false`,`true xor true`,`0 xor 4`],seealso:[`not`,`and`,`or`]},mapSlices:{name:`mapSlices`,category:`Matrix`,syntax:[`mapSlices(A, dim, callback)`],description:`Generate a matrix one dimension less than A by applying callback to each slice of A along dimension dim.`,examples:[`A = [[1, 2], [3, 4]]`,`mapSlices(A, 1, sum)`,`mapSlices(A, 2, prod)`],seealso:[`map`,`forEach`]},concat:{name:`concat`,category:`Matrix`,syntax:[`concat(A, B, C, ...)`,`concat(A, B, C, ..., dim)`],description:`Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.`,examples:[`A = [1, 2; 5, 6]`,`B = [3, 4; 7, 8]`,`concat(A, B)`,`concat(A, B, 1)`,`concat(A, B, 2)`],seealso:[`det`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},count:{name:`count`,category:`Matrix`,syntax:[`count(x)`],description:`Count the number of elements of a matrix, array or string.`,examples:[`a = [1, 2; 3, 4; 5, 6]`,`count(a)`,`size(a)`,`count("hello world")`],seealso:[`size`]},cross:{name:`cross`,category:`Matrix`,syntax:[`cross(A, B)`],description:`Calculate the cross product for two vectors in three dimensional space.`,examples:[`cross([1, 1, 0], [0, 1, 1])`,`cross([3, -3, 1], [4, 9, 2])`,`cross([2, 3, 4], [5, 6, 7])`],seealso:[`multiply`,`dot`]},column:{name:`column`,category:`Matrix`,syntax:[`column(x, index)`],description:`Return a column from a matrix or array.`,examples:[`A = [[1, 2], [3, 4]]`,`column(A, 1)`,`column(A, 2)`],seealso:[`row`,`matrixFromColumns`]},ctranspose:{name:`ctranspose`,category:`Matrix`,syntax:[`x'`,`ctranspose(x)`],description:`Complex Conjugate and Transpose a matrix`,examples:[`a = [1, 2, 3; 4, 5, 6]`,`a'`,`ctranspose(a)`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`zeros`]},det:{name:`det`,category:`Matrix`,syntax:[`det(x)`],description:`Calculate the determinant of a matrix`,examples:[`det([1, 2; 3, 4])`,`det([-2, 2, 3; -1, 1, 3; 2, 0, -1])`],seealso:[`concat`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},diag:{name:`diag`,category:`Matrix`,syntax:[`diag(x)`,`diag(x, k)`],description:`Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.`,examples:[`diag(1:3)`,`diag(1:3, 1)`,`a = [1, 2, 3; 4, 5, 6; 7, 8, 9]`,`diag(a)`],seealso:[`concat`,`det`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},diff:{name:`diff`,category:`Matrix`,syntax:[`diff(arr)`,`diff(arr, dim)`],description:[`Create a new matrix or array with the difference of the passed matrix or array.`,`Dim parameter is optional and used to indicate the dimension of the array/matrix to apply the difference`,`If no dimension parameter is passed it is assumed as dimension 0`,`Dimension is zero-based in javascript and one-based in the parser`,`Arrays must be 'rectangular' meaning arrays like [1, 2]`,`If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays`],examples:[`A = [1, 2, 4, 7, 0]`,`diff(A)`,`diff(A, 1)`,`B = [[1, 2], [3, 4]]`,`diff(B)`,`diff(B, 1)`,`diff(B, 2)`,`diff(B, bignumber(2))`,`diff([[1, 2], matrix([3, 4])], 2)`],seealso:[`subtract`,`partitionSelect`]},dot:{name:`dot`,category:`Matrix`,syntax:[`dot(A, B)`,`A * B`],description:`Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn`,examples:[`dot([2, 4, 1], [2, 2, 3])`,`[2, 4, 1] * [2, 2, 3]`],seealso:[`multiply`,`cross`]},getMatrixDataType:{name:`getMatrixDataType`,category:`Matrix`,syntax:[`getMatrixDataType(x)`],description:`Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".`,examples:[`getMatrixDataType([1, 2, 3])`,`getMatrixDataType([[5 cm], [2 inch]])`,`getMatrixDataType([1, "text"])`,`getMatrixDataType([1, bignumber(4)])`],seealso:[`matrix`,`sparse`,`typeOf`]},identity:{name:`identity`,category:`Matrix`,syntax:[`identity(n)`,`identity(m, n)`,`identity([m, n])`],description:`Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.`,examples:[`identity(3)`,`identity(3, 5)`,`a = [1, 2, 3; 4, 5, 6]`,`identity(size(a))`],seealso:[`concat`,`det`,`diag`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},filter:{name:`filter`,category:`Matrix`,syntax:[`filter(x, test)`],description:`Filter items in a matrix.`,examples:[`isPositive(x) = x > 0`,`filter([6, -2, -1, 4, 3], isPositive)`,`filter([6, -2, 0, 1, 0], x != 0)`],seealso:[`sort`,`map`,`forEach`]},flatten:{name:`flatten`,category:`Matrix`,syntax:[`flatten(x)`],description:`Flatten a multi dimensional matrix into a single dimensional matrix.`,examples:[`a = [1, 2, 3; 4, 5, 6]`,`size(a)`,`b = flatten(a)`,`size(b)`],seealso:[`concat`,`resize`,`size`,`squeeze`]},forEach:{name:`forEach`,category:`Matrix`,syntax:[`forEach(x, callback)`],description:`Iterates over all elements of a matrix/array, and executes the given callback function.`,examples:[`numberOfPets = {}`,`addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;`,`forEach(["Dog","Cat","Cat"], addPet)`,`numberOfPets`],seealso:[`map`,`sort`,`filter`]},inv:{name:`inv`,category:`Matrix`,syntax:[`inv(x)`],description:`Calculate the inverse of a matrix`,examples:[`inv([1, 2; 3, 4])`,`inv(4)`,`1 / 4`],seealso:[`concat`,`det`,`diag`,`identity`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},pinv:{name:`pinv`,category:`Matrix`,syntax:[`pinv(x)`],description:`Calculate the Moore–Penrose inverse of a matrix`,examples:[`pinv([1, 2; 3, 4])`,`pinv([[1, 0], [0, 1], [0, 1]])`,`pinv(4)`],seealso:[`inv`]},eigs:{name:`eigs`,category:`Matrix`,syntax:[`eigs(x)`],description:`Calculate the eigenvalues and optionally eigenvectors of a square matrix`,examples:[`eigs([[5, 2.3], [2.3, 1]])`,`eigs([[1, 2, 3], [4, 5, 6], [7, 8, 9]], { precision: 1e-6, eigenvectors: false })`],seealso:[`inv`]},kron:{name:`kron`,category:`Matrix`,syntax:[`kron(x, y)`],description:`Calculates the Kronecker product of 2 matrices or vectors.`,examples:[`kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])`,`kron([1,1], [2,3,4])`],seealso:[`multiply`,`dot`,`cross`]},matrixFromFunction:{name:`matrixFromFunction`,category:`Matrix`,syntax:[`matrixFromFunction(size, fn)`,`matrixFromFunction(size, fn, format)`,`matrixFromFunction(size, fn, format, datatype)`,`matrixFromFunction(size, format, fn)`,`matrixFromFunction(size, format, datatype, fn)`],description:`Create a matrix by evaluating a generating function at each index.`,examples:[`f(I) = I[1] - I[2]`,`matrixFromFunction([3,3], f)`,`g(I) = I[1] - I[2] == 1 ? 4 : 0`,`matrixFromFunction([100, 100], "sparse", g)`,`matrixFromFunction([5], random)`],seealso:[`matrix`,`matrixFromRows`,`matrixFromColumns`,`zeros`]},matrixFromRows:{name:`matrixFromRows`,category:`Matrix`,syntax:[`matrixFromRows(...arr)`,`matrixFromRows(row1, row2)`,`matrixFromRows(row1, row2, row3)`],description:`Create a dense matrix from vectors as individual rows.`,examples:[`matrixFromRows([1, 2, 3], [[4],[5],[6]])`],seealso:[`matrix`,`matrixFromColumns`,`matrixFromFunction`,`zeros`]},matrixFromColumns:{name:`matrixFromColumns`,category:`Matrix`,syntax:[`matrixFromColumns(...arr)`,`matrixFromColumns(row1, row2)`,`matrixFromColumns(row1, row2, row3)`],description:`Create a dense matrix from vectors as individual columns.`,examples:[`matrixFromColumns([1, 2, 3], [[4],[5],[6]])`],seealso:[`matrix`,`matrixFromRows`,`matrixFromFunction`,`zeros`]},map:{name:`map`,category:`Matrix`,syntax:[`map(x, callback)`,`map(x, y, ..., callback)`],description:`Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array or the matrices/arrays.`,examples:[`map([1, 2, 3], square)`,`map([1, 2], [3, 4], f(a,b) = a + b)`],seealso:[`filter`,`forEach`]},ones:{name:`ones`,category:`Matrix`,syntax:[`ones(m)`,`ones(m, n)`,`ones(m, n, p, ...)`,`ones([m])`,`ones([m, n])`,`ones([m, n, p, ...])`],description:`Create a matrix containing ones.`,examples:[`ones(3)`,`ones(3, 5)`,`ones([2,3]) * 4.5`,`a = [1, 2, 3; 4, 5, 6]`,`ones(size(a))`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`range`,`size`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},partitionSelect:{name:`partitionSelect`,category:`Matrix`,syntax:[`partitionSelect(x, k)`,`partitionSelect(x, k, compare)`],description:`Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.`,examples:[`partitionSelect([5, 10, 1], 2)`,`partitionSelect(["C", "B", "A", "D"], 1, compareText)`,`arr = [5, 2, 1]`,`partitionSelect(arr, 0) # returns 1, arr is now: [1, 2, 5]`,`arr`,`partitionSelect(arr, 1, 'desc') # returns 2, arr is now: [5, 2, 1]`,`arr`],seealso:[`sort`]},range:{name:`range`,category:`Type`,syntax:[`start:end`,`start:step:end`,`range(start, end)`,`range(start, end, step)`,`range(string)`],description:`Create a range. Lower bound of the range is included, upper bound is excluded.`,examples:[`1:5`,`3:-1:-3`,`range(3, 7)`,`range(0, 12, 2)`,`range("4:10")`,`range(1m, 1m, 3m)`,`a = [1, 2, 3, 4; 5, 6, 7, 8]`,`a[1:2, 1:2]`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`ones`,`size`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},resize:{name:`resize`,category:`Matrix`,syntax:[`resize(x, size)`,`resize(x, size, defaultValue)`],description:`Resize a matrix.`,examples:[`resize([1,2,3,4,5], [3])`,`resize([1,2,3], [5])`,`resize([1,2,3], [5], -1)`,`resize(2, [2, 3])`,`resize("hello", [8], "!")`],seealso:[`size`,`subset`,`squeeze`,`reshape`]},reshape:{name:`reshape`,category:`Matrix`,syntax:[`reshape(x, sizes)`],description:`Reshape a multi dimensional array to fit the specified dimensions.`,examples:[`reshape([1, 2, 3, 4, 5, 6], [2, 3])`,`reshape([[1, 2], [3, 4]], [1, 4])`,`reshape([[1, 2], [3, 4]], [4])`,`reshape([1, 2, 3, 4], [-1, 2])`],seealso:[`size`,`squeeze`,`resize`]},rotate:{name:`rotate`,category:`Matrix`,syntax:[`rotate(w, theta)`,`rotate(w, theta, v)`],description:`Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.`,examples:[`rotate([1, 0], pi / 2)`,`rotate(matrix([1, 0]), unit("35deg"))`,`rotate([1, 0, 0], unit("90deg"), [0, 0, 1])`,`rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))`],seealso:[`matrix`,`rotationMatrix`]},rotationMatrix:{name:`rotationMatrix`,category:`Matrix`,syntax:[`rotationMatrix(theta)`,`rotationMatrix(theta, v)`,`rotationMatrix(theta, v, format)`],description:`Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.`,examples:[`rotationMatrix(pi / 2)`,`rotationMatrix(unit("45deg"), [0, 0, 1])`,`rotationMatrix(1, matrix([0, 0, 1]), "sparse")`],seealso:[`cos`,`sin`]},row:{name:`row`,category:`Matrix`,syntax:[`row(x, index)`],description:`Return a row from a matrix or array.`,examples:[`A = [[1, 2], [3, 4]]`,`row(A, 1)`,`row(A, 2)`],seealso:[`column`,`matrixFromRows`]},size:{name:`size`,category:`Matrix`,syntax:[`size(x)`],description:`Calculate the size of a matrix.`,examples:[`size(2.3)`,`size("hello world")`,`a = [1, 2; 3, 4; 5, 6]`,`size(a)`,`size(1:6)`],seealso:[`concat`,`count`,`det`,`diag`,`identity`,`inv`,`ones`,`range`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},sort:{name:`sort`,category:`Matrix`,syntax:[`sort(x)`,`sort(x, compare)`],description:`Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.`,examples:[`sort([5, 10, 1])`,`sort(["C", "B", "A", "D"], "natural")`,`sortByLength(a, b) = size(a)[1] - size(b)[1]`,`sort(["Langdon", "Tom", "Sara"], sortByLength)`,`sort(["10", "1", "2"], "natural")`],seealso:[`map`,`filter`,`forEach`]},squeeze:{name:`squeeze`,category:`Matrix`,syntax:[`squeeze(x)`],description:`Remove inner and outer singleton dimensions from a matrix.`,examples:[`a = zeros(3,2,1)`,`size(squeeze(a))`,`b = zeros(1,1,3)`,`size(squeeze(b))`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`subset`,`trace`,`transpose`,`zeros`]},subset:{name:`subset`,category:`Matrix`,syntax:[`value(index)`,`value(index) = replacement`,`subset(value, [index])`,`subset(value, [index], replacement)`],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:[`d = [1, 2; 3, 4]`,`e = []`,`e[1, 1:2] = [5, 6]`,`e[2, :] = [7, 8]`,`f = d * e`,`f[2, 1]`,`f[:, 1]`,`f[[1,2], [1,3]] = [9, 10; 11, 12]`,`f`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`trace`,`transpose`,`zeros`]},trace:{name:`trace`,category:`Matrix`,syntax:[`trace(A)`],description:`Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.`,examples:[`A = [1, 2, 3; -1, 2, 3; 2, 0, 3]`,`trace(A)`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`transpose`,`zeros`]},transpose:{name:`transpose`,category:`Matrix`,syntax:[`x'`,`transpose(x)`],description:`Transpose a matrix`,examples:[`a = [1, 2, 3; 4, 5, 6]`,`a'`,`transpose(a)`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`zeros`]},zeros:{name:`zeros`,category:`Matrix`,syntax:[`zeros(m)`,`zeros(m, n)`,`zeros(m, n, p, ...)`,`zeros([m])`,`zeros([m, n])`,`zeros([m, n, p, ...])`],description:`Create a matrix containing zeros.`,examples:[`zeros(3)`,`zeros(3, 5)`,`a = [1, 2, 3; 4, 5, 6]`,`zeros(size(a))`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`transpose`]},fft:{name:`fft`,category:`Matrix`,syntax:[`fft(x)`],description:`Calculate N-dimensional Fourier transform`,examples:[`fft([[1, 0], [1, 0]])`],seealso:[`ifft`]},ifft:{name:`ifft`,category:`Matrix`,syntax:[`ifft(x)`],description:`Calculate N-dimensional inverse Fourier transform`,examples:[`ifft([[2, 2], [0, 0]])`],seealso:[`fft`]},sylvester:{name:`sylvester`,category:`Algebra`,syntax:[`sylvester(A,B,C)`],description:`Solves the real-valued Sylvester equation AX+XB=C for X`,examples:[`sylvester([[-1, -2], [1, 1]], [[-2, 1], [-1, 2]], [[-3, 2], [3, 0]])`,`A = [[-1, -2], [1, 1]]; B = [[2, -1], [1, -2]]; C = [[-3, 2], [3, 0]]`,`sylvester(A, B, C)`],seealso:[`schur`,`lyap`]},schur:{name:`schur`,category:`Algebra`,syntax:[`schur(A)`],description:`Performs a real Schur decomposition of the real matrix A = UTU'`,examples:[`schur([[1, 0], [-4, 3]])`,`A = [[1, 0], [-4, 3]]`,`schur(A)`],seealso:[`lyap`,`sylvester`]},lyap:{name:`lyap`,category:`Algebra`,syntax:[`lyap(A,Q)`],description:`Solves the Continuous-time Lyapunov equation AP+PA'+Q=0 for P`,examples:[`lyap([[-2, 0], [1, -4]], [[3, 1], [1, 3]])`,`A = [[-2, 0], [1, -4]]`,`Q = [[3, 1], [1, 3]]`,`lyap(A,Q)`],seealso:[`schur`,`sylvester`]},solveODE:{name:`solveODE`,category:`Numeric`,syntax:[`solveODE(func, tspan, y0)`,`solveODE(func, tspan, y0, options)`],description:`Numerical Integration of Ordinary Differential Equations.`,examples:[`f(t,y) = y`,`tspan = [0, 4]`,`solveODE(f, tspan, 1)`,`solveODE(f, tspan, [1, 2])`,`solveODE(f, tspan, 1, { method:"RK23", maxStep:0.1 })`],seealso:[`derivative`,`simplifyCore`]},bernoulli:{name:`bernoulli`,category:`Probability`,syntax:[`bernoulli(n)`],description:`The nth Bernoulli number`,examples:[`bernoulli(4)`,`bernoulli(fraction(12))`],seealso:[`combinations`,`gamma`,`stirlingS2`]},combinations:{name:`combinations`,category:`Probability`,syntax:[`combinations(n, k)`],description:`Compute the number of combinations of n items taken k at a time`,examples:[`combinations(7, 5)`],seealso:[`combinationsWithRep`,`permutations`,`factorial`]},combinationsWithRep:{name:`combinationsWithRep`,category:`Probability`,syntax:[`combinationsWithRep(n, k)`],description:`Compute the number of combinations of n items taken k at a time with replacements.`,examples:[`combinationsWithRep(7, 5)`],seealso:[`combinations`,`permutations`,`factorial`]},factorial:{name:`factorial`,category:`Probability`,syntax:[`n!`,`factorial(n)`],description:`Compute the factorial of a value`,examples:[`5!`,`5 * 4 * 3 * 2 * 1`,`3!`],seealso:[`combinations`,`combinationsWithRep`,`permutations`,`gamma`]},gamma:{name:`gamma`,category:`Probability`,syntax:[`gamma(n)`],description:`Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.`,examples:[`gamma(4)`,`3!`,`gamma(1/2)`,`sqrt(pi)`],seealso:[`factorial`]},kldivergence:{name:`kldivergence`,category:`Probability`,syntax:[`kldivergence(x, y)`],description:`Calculate the Kullback-Leibler (KL) divergence between two distributions.`,examples:[`kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])`],seealso:[]},lgamma:{name:`lgamma`,category:`Probability`,syntax:[`lgamma(n)`],description:`Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.`,examples:[`lgamma(4)`,`lgamma(1/2)`,`lgamma(i)`,`lgamma(complex(1.1, 2))`],seealso:[`gamma`]},multinomial:{name:`multinomial`,category:`Probability`,syntax:[`multinomial(A)`],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:[`multinomial([1, 2, 1])`],seealso:[`combinations`,`factorial`]},permutations:{name:`permutations`,category:`Probability`,syntax:[`permutations(n)`,`permutations(n, k)`],description:`Compute the number of permutations of n items taken k at a time`,examples:[`permutations(5)`,`permutations(5, 3)`],seealso:[`combinations`,`combinationsWithRep`,`factorial`]},pickRandom:{name:`pickRandom`,category:`Probability`,syntax:[`pickRandom(array)`,`pickRandom(array, number)`,`pickRandom(array, weights)`,`pickRandom(array, number, weights)`,`pickRandom(array, weights, number)`],description:`Pick a random entry from a given array.`,examples:[`pickRandom(0:10)`,`pickRandom([1, 3, 1, 6])`,`pickRandom([1, 3, 1, 6], 2)`,`pickRandom([1, 3, 1, 6], [2, 3, 2, 1])`,`pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])`,`pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)`],seealso:[`random`,`randomInt`]},random:{name:`random`,category:`Probability`,syntax:[`random()`,`random(max)`,`random(min, max)`,`random(size)`,`random(size, max)`,`random(size, min, max)`],description:`Return a random number.`,examples:[`random()`,`random(10, 20)`,`random([2, 3])`],seealso:[`pickRandom`,`randomInt`]},randomInt:{name:`randomInt`,category:`Probability`,syntax:[`randomInt(max)`,`randomInt(min, max)`,`randomInt(size)`,`randomInt(size, max)`,`randomInt(size, min, max)`],description:`Return a random integer number`,examples:[`randomInt(10, 20)`,`randomInt([2, 3], 10)`],seealso:[`pickRandom`,`random`]},compare:{name:`compare`,category:`Relational`,syntax:[`compare(x, y)`],description:`Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.`,examples:[`compare(2, 3)`,`compare(3, 2)`,`compare(2, 2)`,`compare(5cm, 40mm)`,`compare(2, [1, 2, 3])`],seealso:[`equal`,`unequal`,`smaller`,`smallerEq`,`largerEq`,`compareNatural`,`compareText`]},compareNatural:{name:`compareNatural`,category:`Relational`,syntax:[`compareNatural(x, y)`],description:`Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.`,examples:[`compareNatural(2, 3)`,`compareNatural(3, 2)`,`compareNatural(2, 2)`,`compareNatural(5cm, 40mm)`,`compareNatural("2", "10")`,`compareNatural(2 + 3i, 2 + 4i)`,`compareNatural([1, 2, 4], [1, 2, 3])`,`compareNatural([1, 5], [1, 2, 3])`,`compareNatural([1, 2], [1, 2])`,`compareNatural({a: 2}, {a: 4})`],seealso:[`equal`,`unequal`,`smaller`,`smallerEq`,`largerEq`,`compare`,`compareText`]},compareText:{name:`compareText`,category:`Relational`,syntax:[`compareText(x, y)`],description:`Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.`,examples:[`compareText("B", "A")`,`compareText("A", "B")`,`compareText("A", "A")`,`compareText("2", "10")`,`compare("2", "10")`,`compare(2, 10)`,`compareNatural("2", "10")`,`compareText("B", ["A", "B", "C"])`],seealso:[`compare`,`compareNatural`]},deepEqual:{name:`deepEqual`,category:`Relational`,syntax:[`deepEqual(x, y)`],description:`Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.`,examples:[`deepEqual([1,3,4], [1,3,4])`,`deepEqual([1,3,4], [1,3])`],seealso:[`equal`,`unequal`,`smaller`,`larger`,`smallerEq`,`largerEq`,`compare`]},equal:{name:`equal`,category:`Relational`,syntax:[`x == y`,`equal(x, y)`],description:`Check equality of two values. Returns true if the values are equal, and false if not.`,examples:[`2+2 == 3`,`2+2 == 4`,`a = 3.2`,`b = 6-2.8`,`a == b`,`50cm == 0.5m`],seealso:[`unequal`,`smaller`,`larger`,`smallerEq`,`largerEq`,`compare`,`deepEqual`,`equalText`]},equalText:{name:`equalText`,category:`Relational`,syntax:[`equalText(x, y)`],description:`Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.`,examples:[`equalText("Hello", "Hello")`,`equalText("a", "A")`,`equal("2e3", "2000")`,`equalText("2e3", "2000")`,`equalText("B", ["A", "B", "C"])`],seealso:[`compare`,`compareNatural`,`compareText`,`equal`]},larger:{name:`larger`,category:`Relational`,syntax:[`x > y`,`larger(x, y)`],description:`Check if value x is larger than y. Returns true if x is larger than y, and false if not. Comparing a value with NaN returns false.`,examples:[`2 > 3`,`5 > 2*2`,`a = 3.3`,`b = 6-2.8`,`(a > b)`,`(b < a)`,`5 cm > 2 inch`],seealso:[`equal`,`unequal`,`smaller`,`smallerEq`,`largerEq`,`compare`]},largerEq:{name:`largerEq`,category:`Relational`,syntax:[`x >= y`,`largerEq(x, y)`],description:`Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.`,examples:[`2 >= 1+1`,`2 > 1+1`,`a = 3.2`,`b = 6-2.8`,`(a >= b)`],seealso:[`equal`,`unequal`,`smallerEq`,`smaller`,`compare`]},smaller:{name:`smaller`,category:`Relational`,syntax:[`x < y`,`smaller(x, y)`],description:`Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not. Comparing a value with NaN returns false.`,examples:[`2 < 3`,`5 < 2*2`,`a = 3.3`,`b = 6-2.8`,`(a < b)`,`5 cm < 2 inch`],seealso:[`equal`,`unequal`,`larger`,`smallerEq`,`largerEq`,`compare`]},smallerEq:{name:`smallerEq`,category:`Relational`,syntax:[`x <= y`,`smallerEq(x, y)`],description:`Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.`,examples:[`2 <= 1+1`,`2 < 1+1`,`a = 3.2`,`b = 6-2.8`,`(a <= b)`],seealso:[`equal`,`unequal`,`larger`,`smaller`,`largerEq`,`compare`]},unequal:{name:`unequal`,category:`Relational`,syntax:[`x != y`,`unequal(x, y)`],description:`Check unequality of two values. Returns true if the values are unequal, and false if they are equal.`,examples:[`2+2 != 3`,`2+2 != 4`,`a = 3.2`,`b = 6-2.8`,`a != b`,`50cm != 0.5m`,`5 cm != 2 inch`],seealso:[`equal`,`smaller`,`larger`,`smallerEq`,`largerEq`,`compare`,`deepEqual`]},setCartesian:{name:`setCartesian`,category:`Set`,syntax:[`setCartesian(set1, set2)`],description:`Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.`,examples:[`setCartesian([1, 2], [3, 4])`],seealso:[`setUnion`,`setIntersect`,`setDifference`,`setPowerset`]},setDifference:{name:`setDifference`,category:`Set`,syntax:[`setDifference(set1, set2)`],description:`Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.`,examples:[`setDifference([1, 2, 3, 4], [3, 4, 5, 6])`,`setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])`],seealso:[`setUnion`,`setIntersect`,`setSymDifference`]},setDistinct:{name:`setDistinct`,category:`Set`,syntax:[`setDistinct(set)`],description:`Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.`,examples:[`setDistinct([1, 1, 1, 2, 2, 3])`],seealso:[`setMultiplicity`]},setIntersect:{name:`setIntersect`,category:`Set`,syntax:[`setIntersect(set1, set2)`],description:`Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.`,examples:[`setIntersect([1, 2, 3, 4], [3, 4, 5, 6])`,`setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])`],seealso:[`setUnion`,`setDifference`]},setIsSubset:{name:`setIsSubset`,category:`Set`,syntax:[`setIsSubset(set1, set2)`],description:`Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.`,examples:[`setIsSubset([1, 2], [3, 4, 5, 6])`,`setIsSubset([3, 4], [3, 4, 5, 6])`],seealso:[`setUnion`,`setIntersect`,`setDifference`]},setMultiplicity:{name:`setMultiplicity`,category:`Set`,syntax:[`setMultiplicity(element, set)`],description:`Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.`,examples:[`setMultiplicity(1, [1, 2, 2, 4])`,`setMultiplicity(2, [1, 2, 2, 4])`],seealso:[`setDistinct`,`setSize`]},setPowerset:{name:`setPowerset`,category:`Set`,syntax:[`setPowerset(set)`],description:`Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.`,examples:[`setPowerset([1, 2, 3])`],seealso:[`setCartesian`]},setSize:{name:`setSize`,category:`Set`,syntax:[`setSize(set)`,`setSize(set, unique)`],description:`Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.`,examples:[`setSize([1, 2, 2, 4])`,`setSize([1, 2, 2, 4], true)`],seealso:[`setUnion`,`setIntersect`,`setDifference`]},setSymDifference:{name:`setSymDifference`,category:`Set`,syntax:[`setSymDifference(set1, set2)`],description:`Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.`,examples:[`setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])`,`setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])`],seealso:[`setUnion`,`setIntersect`,`setDifference`]},setUnion:{name:`setUnion`,category:`Set`,syntax:[`setUnion(set1, set2)`],description:`Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.`,examples:[`setUnion([1, 2, 3, 4], [3, 4, 5, 6])`,`setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])`],seealso:[`setIntersect`,`setDifference`]},zpk2tf:{name:`zpk2tf`,category:`Signal`,syntax:[`zpk2tf(z, p, k)`],description:`Compute the transfer function of a zero-pole-gain model.`,examples:[`zpk2tf([1, 2], [-1, -2], 1)`,`zpk2tf([1, 2], [-1, -2])`,`zpk2tf([1 - 3i, 2 + 2i], [-1, -2])`],seealso:[]},freqz:{name:`freqz`,category:`Signal`,syntax:[`freqz(b, a)`,`freqz(b, a, w)`],description:`Calculates the frequency response of a filter given its numerator and denominator coefficients.`,examples:[`freqz([1, 2], [1, 2, 3])`,`freqz([1, 2], [1, 2, 3], [0, 1])`,`freqz([1, 2], [1, 2, 3], 512)`],seealso:[]},erf:{name:`erf`,category:`Special`,syntax:[`erf(x)`],description:`Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x`,examples:[`erf(0.2)`,`erf(-0.5)`,`erf(4)`],seealso:[]},zeta:{name:`zeta`,category:`Special`,syntax:[`zeta(s)`],description:`Compute the Riemann Zeta Function using an infinite series and Riemann's Functional Equation for the entire complex plane`,examples:[`zeta(0.2)`,`zeta(-0.5)`,`zeta(4)`],seealso:[]},cumsum:{name:`cumsum`,category:`Statistics`,syntax:[`cumsum(a, b, c, ...)`,`cumsum(A)`],description:`Compute the cumulative sum of all values.`,examples:[`cumsum(2, 3, 4, 1)`,`cumsum([2, 3, 4, 1])`,`cumsum([1, 2; 3, 4])`,`cumsum([1, 2; 3, 4], 1)`,`cumsum([1, 2; 3, 4], 2)`],seealso:[`max`,`mean`,`median`,`min`,`prod`,`std`,`sum`,`variance`]},mad:{name:`mad`,category:`Statistics`,syntax:[`mad(a, b, c, ...)`,`mad(A)`],description:`Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.`,examples:[`mad(10, 20, 30)`,`mad([1, 2, 3])`],seealso:[`mean`,`median`,`std`,`abs`]},max:{name:`max`,category:`Statistics`,syntax:[`max(a, b, c, ...)`,`max(A)`,`max(A, dimension)`],description:`Compute the maximum value of a list of values. If any NaN values are found, the function yields the last NaN in the input.`,examples:[`max(2, 3, 4, 1)`,`max([2, 3, 4, 1])`,`max([2, 5; 4, 3])`,`max([2, 5; 4, 3], 1)`,`max([2, 5; 4, 3], 2)`,`max(2.7, 7.1, -4.5, 2.0, 4.1)`,`min(2.7, 7.1, -4.5, 2.0, 4.1)`],seealso:[`mean`,`median`,`min`,`prod`,`std`,`sum`,`variance`]},mean:{name:`mean`,category:`Statistics`,syntax:[`mean(a, b, c, ...)`,`mean(A)`,`mean(A, dimension)`],description:`Compute the arithmetic mean of a list of values.`,examples:[`mean(2, 3, 4, 1)`,`mean([2, 3, 4, 1])`,`mean([2, 5; 4, 3])`,`mean([2, 5; 4, 3], 1)`,`mean([2, 5; 4, 3], 2)`,`mean([1.0, 2.7, 3.2, 4.0])`],seealso:[`max`,`median`,`min`,`prod`,`std`,`sum`,`variance`]},median:{name:`median`,category:`Statistics`,syntax:[`median(a, b, c, ...)`,`median(A)`],description:`Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.`,examples:[`median(5, 2, 7)`,`median([3, -1, 5, 7])`],seealso:[`max`,`mean`,`min`,`prod`,`std`,`sum`,`variance`,`quantileSeq`]},min:{name:`min`,category:`Statistics`,syntax:[`min(a, b, c, ...)`,`min(A)`,`min(A, dimension)`],description:`Compute the minimum value of a list of values. If any NaN values are found, the function yields the last NaN in the input.`,examples:[`min(2, 3, 4, 1)`,`min([2, 3, 4, 1])`,`min([2, 5; 4, 3])`,`min([2, 5; 4, 3], 1)`,`min([2, 5; 4, 3], 2)`,`min(2.7, 7.1, -4.5, 2.0, 4.1)`,`max(2.7, 7.1, -4.5, 2.0, 4.1)`],seealso:[`max`,`mean`,`median`,`prod`,`std`,`sum`,`variance`]},mode:{name:`mode`,category:`Statistics`,syntax:[`mode(a, b, c, ...)`,`mode(A)`,`mode(A, a, b, B, c, ...)`],description:`Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.`,examples:[`mode(2, 1, 4, 3, 1)`,`mode([1, 2.7, 3.2, 4, 2.7])`,`mode(1, 4, 6, 1, 6)`],seealso:[`max`,`mean`,`min`,`median`,`prod`,`std`,`sum`,`variance`]},prod:{name:`prod`,category:`Statistics`,syntax:[`prod(a, b, c, ...)`,`prod(A)`],description:`Compute the product of all values.`,examples:[`prod(2, 3, 4)`,`prod([2, 3, 4])`,`prod([2, 5; 4, 3])`],seealso:[`max`,`mean`,`min`,`median`,`min`,`std`,`sum`,`variance`]},quantileSeq:{name:`quantileSeq`,category:`Statistics`,syntax:[`quantileSeq(A, prob[, sorted])`,`quantileSeq(A, [prob1, prob2, ...][, sorted])`,`quantileSeq(A, N[, sorted])`],description:`Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probability are: Number, BigNumber. In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.`,examples:[`quantileSeq([3, -1, 5, 7], 0.5)`,`quantileSeq([3, -1, 5, 7], [1/3, 2/3])`,`quantileSeq([3, -1, 5, 7], 2)`,`quantileSeq([-1, 3, 5, 7], 0.5, true)`],seealso:[`mean`,`median`,`min`,`max`,`prod`,`std`,`sum`,`variance`]},std:{name:`std`,category:`Statistics`,syntax:[`std(a, b, c, ...)`,`std(A)`,`std(A, dimension)`,`std(A, normalization)`,`std(A, dimension, normalization)`],description:`Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".`,examples:[`std(2, 4, 6)`,`std([2, 4, 6, 8])`,`std([2, 4, 6, 8], "uncorrected")`,`std([2, 4, 6, 8], "biased")`,`std([1, 2, 3; 4, 5, 6])`],seealso:[`max`,`mean`,`min`,`median`,`prod`,`sum`,`variance`]},sum:{name:`sum`,category:`Statistics`,syntax:[`sum(a, b, c, ...)`,`sum(A)`,`sum(A, dimension)`],description:`Compute the sum of all values.`,examples:[`sum(2, 3, 4, 1)`,`sum([2, 3, 4, 1])`,`sum([2, 5; 4, 3])`],seealso:[`max`,`mean`,`median`,`min`,`prod`,`std`,`variance`]},variance:{name:`variance`,category:`Statistics`,syntax:[`variance(a, b, c, ...)`,`variance(A)`,`variance(A, dimension)`,`variance(A, normalization)`,`variance(A, dimension, normalization)`],description:`Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".`,examples:[`variance(2, 4, 6)`,`variance([2, 4, 6, 8])`,`variance([2, 4, 6, 8], "uncorrected")`,`variance([2, 4, 6, 8], "biased")`,`variance([1, 2, 3; 4, 5, 6])`],seealso:[`max`,`mean`,`min`,`median`,`min`,`prod`,`std`,`sum`]},corr:{name:`corr`,category:`Statistics`,syntax:[`corr(A,B)`],description:`Compute the correlation coefficient of a two list with values, For matrices, the matrix correlation coefficient is calculated.`,examples:[`corr([2, 4, 6, 8],[1, 2, 3, 6])`,`corr(matrix([[1, 2.2, 3, 4.8, 5], [1, 2, 3, 4, 5]]), matrix([[4, 5.3, 6.6, 7, 8], [1, 2, 3, 4, 5]]))`],seealso:[`max`,`mean`,`min`,`median`,`min`,`prod`,`std`,`sum`]},acos:{name:`acos`,category:`Trigonometry`,syntax:[`acos(x)`],description:`Compute the inverse cosine of a value in radians.`,examples:[`acos(0.5)`,`acos(cos(2.3))`],seealso:[`cos`,`atan`,`asin`]},acosh:{name:`acosh`,category:`Trigonometry`,syntax:[`acosh(x)`],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:[`acosh(1.5)`],seealso:[`cosh`,`asinh`,`atanh`]},acot:{name:`acot`,category:`Trigonometry`,syntax:[`acot(x)`],description:`Calculate the inverse cotangent of a value.`,examples:[`acot(0.5)`,`acot(cot(0.5))`,`acot(2)`],seealso:[`cot`,`atan`]},acoth:{name:`acoth`,category:`Trigonometry`,syntax:[`acoth(x)`],description:"Calculate the inverse hyperbolic tangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:[`acoth(2)`,`acoth(0.5)`],seealso:[`acsch`,`asech`]},acsc:{name:`acsc`,category:`Trigonometry`,syntax:[`acsc(x)`],description:`Calculate the inverse cotangent of a value.`,examples:[`acsc(2)`,`acsc(csc(0.5))`,`acsc(0.5)`],seealso:[`csc`,`asin`,`asec`]},acsch:{name:`acsch`,category:`Trigonometry`,syntax:[`acsch(x)`],description:"Calculate the inverse hyperbolic cosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:[`acsch(0.5)`],seealso:[`asech`,`acoth`]},asec:{name:`asec`,category:`Trigonometry`,syntax:[`asec(x)`],description:`Calculate the inverse secant of a value.`,examples:[`asec(0.5)`,`asec(sec(0.5))`,`asec(2)`],seealso:[`acos`,`acot`,`acsc`]},asech:{name:`asech`,category:`Trigonometry`,syntax:[`asech(x)`],description:`Calculate the inverse secant of a value.`,examples:[`asech(0.5)`],seealso:[`acsch`,`acoth`]},asin:{name:`asin`,category:`Trigonometry`,syntax:[`asin(x)`],description:`Compute the inverse sine of a value in radians.`,examples:[`asin(0.5)`,`asin(sin(0.5))`],seealso:[`sin`,`acos`,`atan`]},asinh:{name:`asinh`,category:`Trigonometry`,syntax:[`asinh(x)`],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:[`asinh(0.5)`],seealso:[`acosh`,`atanh`]},atan:{name:`atan`,category:`Trigonometry`,syntax:[`atan(x)`],description:`Compute the inverse tangent of a value in radians.`,examples:[`atan(0.5)`,`atan(tan(0.5))`],seealso:[`tan`,`acos`,`asin`]},atanh:{name:`atanh`,category:`Trigonometry`,syntax:[`atanh(x)`],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:[`atanh(0.5)`],seealso:[`acosh`,`asinh`]},atan2:{name:`atan2`,category:`Trigonometry`,syntax:[`atan2(y, x)`],description:`Computes the principal value of the arc tangent of y/x in radians.`,examples:[`atan2(2, 2) / pi`,`angle = 60 deg in rad`,`x = cos(angle)`,`y = sin(angle)`,`atan2(y, x)`],seealso:[`sin`,`cos`,`tan`]},cos:{name:`cos`,category:`Trigonometry`,syntax:[`cos(x)`],description:`Compute the cosine of x in radians.`,examples:[`cos(2)`,`cos(pi / 4) ^ 2`,`cos(180 deg)`,`cos(60 deg)`,`sin(0.2)^2 + cos(0.2)^2`],seealso:[`acos`,`sin`,`tan`]},cosh:{name:`cosh`,category:`Trigonometry`,syntax:[`cosh(x)`],description:`Compute the hyperbolic cosine of x in radians.`,examples:[`cosh(0.5)`],seealso:[`sinh`,`tanh`,`coth`]},cot:{name:`cot`,category:`Trigonometry`,syntax:[`cot(x)`],description:`Compute the cotangent of x in radians. Defined as 1/tan(x)`,examples:[`cot(2)`,`1 / tan(2)`],seealso:[`sec`,`csc`,`tan`]},coth:{name:`coth`,category:`Trigonometry`,syntax:[`coth(x)`],description:`Compute the hyperbolic cotangent of x in radians.`,examples:[`coth(2)`,`1 / tanh(2)`],seealso:[`sech`,`csch`,`tanh`]},csc:{name:`csc`,category:`Trigonometry`,syntax:[`csc(x)`],description:`Compute the cosecant of x in radians. Defined as 1/sin(x)`,examples:[`csc(2)`,`1 / sin(2)`],seealso:[`sec`,`cot`,`sin`]},csch:{name:`csch`,category:`Trigonometry`,syntax:[`csch(x)`],description:`Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)`,examples:[`csch(2)`,`1 / sinh(2)`],seealso:[`sech`,`coth`,`sinh`]},sec:{name:`sec`,category:`Trigonometry`,syntax:[`sec(x)`],description:`Compute the secant of x in radians. Defined as 1/cos(x)`,examples:[`sec(2)`,`1 / cos(2)`],seealso:[`cot`,`csc`,`cos`]},sech:{name:`sech`,category:`Trigonometry`,syntax:[`sech(x)`],description:`Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)`,examples:[`sech(2)`,`1 / cosh(2)`],seealso:[`coth`,`csch`,`cosh`]},sin:{name:`sin`,category:`Trigonometry`,syntax:[`sin(x)`],description:`Compute the sine of x in radians.`,examples:[`sin(2)`,`sin(pi / 4) ^ 2`,`sin(90 deg)`,`sin(30 deg)`,`sin(0.2)^2 + cos(0.2)^2`],seealso:[`asin`,`cos`,`tan`]},sinh:{name:`sinh`,category:`Trigonometry`,syntax:[`sinh(x)`],description:`Compute the hyperbolic sine of x in radians.`,examples:[`sinh(0.5)`],seealso:[`cosh`,`tanh`]},tan:{name:`tan`,category:`Trigonometry`,syntax:[`tan(x)`],description:`Compute the tangent of x in radians.`,examples:[`tan(0.5)`,`sin(0.5) / cos(0.5)`,`tan(pi / 4)`,`tan(45 deg)`],seealso:[`atan`,`sin`,`cos`]},tanh:{name:`tanh`,category:`Trigonometry`,syntax:[`tanh(x)`],description:`Compute the hyperbolic tangent of x in radians.`,examples:[`tanh(0.5)`,`sinh(0.5) / cosh(0.5)`],seealso:[`sinh`,`cosh`]},to:{name:`to`,category:`Units`,syntax:[`x to unit`,`to(x, unit)`],description:`Change the unit of a value.`,examples:[`5 inch to cm`,`3.2kg to g`,`16 bytes in bits`],seealso:[]},toBest:{name:`toBest`,category:`Units`,syntax:[`toBest(x)`,`toBest(x, unitList)`,`toBest(x, unitList, options)`],description:`Converts to the most appropriate display unit.`,examples:[`toBest(unit(5000, "m"))`,`toBest(unit(3500000, "W"))`,`toBest(unit(0.000000123, "A"))`,`toBest(unit(10, "m"), "cm")`,`toBest(unit(10, "m"), "mm,km", {offset: 1.5})`],seealso:[]},clone:{name:`clone`,category:`Utils`,syntax:[`clone(x)`],description:`Clone a variable. Creates a copy of primitive variables, and a deep copy of matrices`,examples:[`clone(3.5)`,`clone(2 - 4i)`,`clone(45 deg)`,`clone([1, 2; 3, 4])`,`clone("hello world")`],seealso:[]},format:{name:`format`,category:`Utils`,syntax:[`format(value)`,`format(value, precision)`],description:`Format a value of any type as string.`,examples:[`format(2.3)`,`format(3 - 4i)`,`format([])`,`format(pi, 3)`],seealso:[`print`]},bin:{name:`bin`,category:`Utils`,syntax:[`bin(value)`],description:`Format a number as binary`,examples:[`bin(2)`],seealso:[`oct`,`hex`]},oct:{name:`oct`,category:`Utils`,syntax:[`oct(value)`],description:`Format a number as octal`,examples:[`oct(56)`],seealso:[`bin`,`hex`]},hex:{name:`hex`,category:`Utils`,syntax:[`hex(value)`],description:`Format a number as hexadecimal`,examples:[`hex(240)`],seealso:[`bin`,`oct`]},isNaN:{name:`isNaN`,category:`Utils`,syntax:[`isNaN(x)`],description:`Test whether a value is NaN (not a number)`,examples:[`isNaN(2)`,`isNaN(0 / 0)`,`isNaN(NaN)`,`isNaN(Infinity)`],seealso:[`isNegative`,`isNumeric`,`isPositive`,`isZero`,`isFinite`,`isBounded`]},isBounded:{name:`isBounded`,category:`Utils`,syntax:[`isBounded(x)`],description:`Test whether a value or its entries are bounded.`,examples:[`isBounded(Infinity)`,`isBounded(bigint(3))`,`isBounded([3, -Infinity, -3])`],seealso:[`isFinite`,`isNumeric`,`isNaN`,`isNegative`,`isPositive`]},isFinite:{name:`isFinite`,category:`Utils`,syntax:[`isFinite(x)`],description:`Test whether a value is finite, elementwise on collections.`,examples:[`isFinite(Infinity)`,`isFinite(bigint(3))`,`isFinite([3, -Infinity, -3])`],seealso:[`isBounded`,`isNumeric`,`isNaN`,`isNegative`,`isPositive`]},isInteger:{name:`isInteger`,category:`Utils`,syntax:[`isInteger(x)`],description:`Test whether a value is an integer number.`,examples:[`isInteger(2)`,`isInteger(3.5)`,`isInteger([3, 0.5, -2])`],seealso:[`isNegative`,`isNumeric`,`isPositive`,`isZero`]},isNegative:{name:`isNegative`,category:`Utils`,syntax:[`isNegative(x)`],description:`Test whether a value is negative: smaller than zero.`,examples:[`isNegative(2)`,`isNegative(0)`,`isNegative(-4)`,`isNegative([3, 0.5, -2])`],seealso:[`isInteger`,`isNumeric`,`isPositive`,`isZero`]},isNumeric:{name:`isNumeric`,category:`Utils`,syntax:[`isNumeric(x)`],description:`Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.`,examples:[`isNumeric(2)`,`isNumeric("2")`,`hasNumericValue("2")`,`isNumeric(0)`,`isNumeric(bignumber(500))`,`isNumeric(fraction(0.125))`,`isNumeric(2 + 3i)`,`isNumeric([2.3, "foo", false])`],seealso:[`isInteger`,`isZero`,`isNegative`,`isPositive`,`isNaN`,`hasNumericValue`,`isFinite`,`isBounded`]},hasNumericValue:{name:`hasNumericValue`,category:`Utils`,syntax:[`hasNumericValue(x)`],description:`Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.`,examples:[`hasNumericValue(2)`,`hasNumericValue("2")`,`isNumeric("2")`,`hasNumericValue(0)`,`hasNumericValue(bignumber(500))`,`hasNumericValue(fraction(0.125))`,`hasNumericValue(2 + 3i)`,`hasNumericValue([2.3, "foo", false])`],seealso:[`isInteger`,`isZero`,`isNegative`,`isPositive`,`isNaN`,`isNumeric`]},isPositive:{name:`isPositive`,category:`Utils`,syntax:[`isPositive(x)`],description:`Test whether a value is positive: larger than zero.`,examples:[`isPositive(2)`,`isPositive(0)`,`isPositive(-4)`,`isPositive([3, 0.5, -2])`],seealso:[`isInteger`,`isNumeric`,`isNegative`,`isZero`]},isPrime:{name:`isPrime`,category:`Utils`,syntax:[`isPrime(x)`],description:`Test whether a value is prime: has no divisors other than itself and one.`,examples:[`isPrime(3)`,`isPrime(-2)`,`isPrime([2, 17, 100])`],seealso:[`isInteger`,`isNumeric`,`isNegative`,`isZero`]},isZero:{name:`isZero`,category:`Utils`,syntax:[`isZero(x)`],description:`Test whether a value is zero.`,examples:[`isZero(2)`,`isZero(0)`,`isZero(-4)`,`isZero([3, 0, -2, 0])`],seealso:[`isInteger`,`isNumeric`,`isNegative`,`isPositive`]},print:{name:`print`,category:`Utils`,syntax:[`print(template, values)`,`print(template, values, precision)`],description:`Interpolate values into a string template.`,examples:[`print("Lucy is $age years old", {age: 5})`,`print("The value of pi is $pi", {pi: pi}, 3)`,`print("Hello, $user.name!", {user: {name: "John"}})`,`print("Values: $1, $2, $3", [6, 9, 4])`],seealso:[`format`]},typeOf:{name:`typeOf`,category:`Utils`,syntax:[`typeOf(x)`],description:`Get the type of a variable.`,examples:[`typeOf(3.5)`,`typeOf(2 - 4i)`,`typeOf(45 deg)`,`typeOf("hello world")`],seealso:[`getMatrixDataType`]},numeric:{name:`numeric`,category:`Utils`,syntax:[`numeric(x)`],description:`Convert a numeric input to a specific numeric type: number, BigNumber, bigint, or Fraction.`,examples:[`numeric("4")`,`numeric("4", "number")`,`numeric("4", "bigint")`,`numeric("4", "BigNumber")`,`numeric("4", "Fraction")`,`numeric(4, "Fraction")`,`numeric(fraction(2, 5), "number")`],seealso:[`number`,`bigint`,`fraction`,`bignumber`,`string`,`format`]}},VI=`help`,HI=Y(VI,[`typed`,`mathWithTransform`,`Help`],e=>{var{typed:t,mathWithTransform:n,Help:r}=e;return t(VI,{any:function(e){var t,i=e;if(typeof e!=`string`){for(t in n)if(J(n,t)&&e===n[t]){i=t;break}}var a=uy(BI,i);if(!a){var o=typeof i==`function`?i.name:i;throw Error(`No documentation found on "`+o+`"`)}return new r(a)}})}),UI=`chain`,WI=Y(UI,[`typed`,`Chain`],e=>{var{typed:t,Chain:n}=e;return t(UI,{"":function(){return new n},any:function(e){return new n(e)}})}),GI=`det`,KI=Y(GI,[`typed`,`matrix`,`subtractScalar`,`multiply`,`divideScalar`,`isZero`,`unaryMinus`],e=>{var{typed:t,matrix:n,subtractScalar:r,multiply:i,divideScalar:a,isZero:o,unaryMinus:s}=e;return t(GI,{any:function(e){return gb(e)},"Array | Matrix":function(e){var t;switch(Ny(e)?t=e.size():Array.isArray(e)?(e=n(e),t=e.size()):t=[],t.length){case 0:return gb(e);case 1:if(t[0]===1)return gb(e.valueOf()[0]);if(t[0]===0)return 1;throw RangeError(`Matrix must be square (size: `+WC(t)+`)`);case 2:var r=t[0],i=t[1];if(r===i)return c(e.clone().valueOf(),r,i);if(i===0)return 1;throw RangeError(`Matrix must be square (size: `+WC(t)+`)`);default:throw RangeError(`Matrix must be two dimensional (size: `+WC(t)+`)`)}}});function c(e,t,n){if(t===1)return gb(e[0][0]);if(t===2)return r(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var c=!1,l=Array(t).fill(0).map((e,t)=>t),u=0;u{var{typed:t,matrix:n,divideScalar:r,addScalar:i,multiply:a,unaryMinus:o,det:s,identity:c,abs:l}=e;return t(qI,{"Array | Matrix":function(e){var t=Ny(e)?e.size():ew(e);switch(t.length){case 1:if(t[0]===1)return Ny(e)?n([r(1,e.valueOf()[0])]):[r(1,e[0])];throw RangeError(`Matrix must be square (size: `+WC(t)+`)`);case 2:var i=t[0],a=t[1];if(i===a)return Ny(e)?n(u(e.valueOf(),i,a),e.storage()):u(e,i,a);throw RangeError(`Matrix must be square (size: `+WC(t)+`)`);default:throw RangeError(`Matrix must be two dimensional (size: `+WC(t)+`)`)}},any:function(e){return r(1,e)}});function u(e,t,n){var u,d,f,p,m;if(t===1){if(p=e[0][0],p===0)throw Error(`Cannot calculate inverse, determinant is zero`);return[[r(1,p)]]}else if(t===2){var h=s(e);if(h===0)throw Error(`Cannot calculate inverse, determinant is zero`);return[[r(e[1][1],h),r(o(e[0][1]),h)],[r(o(e[1][0]),h),r(e[0][0],h)]]}else{var g=e.concat();for(u=0;uy&&(y=l(g[u][v]),b=u),u++;if(y===0)throw Error(`Cannot calculate inverse, determinant is zero`);u=b,u!==v&&(m=g[v],g[v]=g[u],g[u]=m,m=_[v],_[v]=_[u],_[u]=m);var x=g[v],S=_[v];for(u=0;u{var{typed:t,matrix:n,inv:r,deepEqual:i,equal:a,dotDivide:o,dot:s,ctranspose:c,divideScalar:l,multiply:u,add:d,Complex:f}=e;return t(YI,{"Array | Matrix":function(e){var t=Ny(e)?e.size():ew(e);switch(t.length){case 1:return _(e)?c(e):t[0]===1?r(e):o(c(e),s(e,e));case 2:if(_(e))return c(e);var i=t[0],a=t[1];if(i===a)try{return r(e)}catch(e){if(!(e instanceof Error&&e.message.match(/Cannot calculate inverse, determinant is zero/)))throw e}return Ny(e)?n(p(e.valueOf(),i,a),e.storage()):p(e,i,a);default:throw RangeError(`Matrix must be two dimensional (size: `+WC(t)+`)`)}},any:function(e){return a(e,0)?gb(e):l(1,e)}});function p(e,t,n){var{C:i,F:a}=h(e,t,n),o=u(r(u(c(i),i)),c(i));return u(u(c(a),r(u(a,c(a)))),o)}function m(e,t,n){for(var r=gb(e),i=0,a=0;ae.filter((e,n)=>n!g(s(r[t],r[t])))}}function g(e){return a(d(e,f(1,1)),d(0,f(1,1)))}function _(e){return i(d(e,f(1,1)),d(u(e,0),f(1,1)))}});function ZI(e){var{addScalar:t,subtract:n,flatten:r,multiply:i,multiplyScalar:a,divideScalar:o,sqrt:s,abs:c,bignumber:l,diag:u,size:d,reshape:f,inv:p,qr:m,usolve:h,usolveAll:g,equal:_,complex:v,larger:y,smaller:b,matrixFromColumns:x,dot:S}=e;function C(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=w(e,t,n,r,i);T(e,t,n,r,i,a);var{values:o,C:s}=E(e,t,n,r,i);return i?{values:o,eigenvectors:D(e,t,s,a,o,n,r)}:{values:o}}function w(e,n,r,i,s){var d=i===`BigNumber`,f=i===`Complex`,p=d?l(0):0,m=d?l(1):f?v(1):1,h=d?l(1):1,g=d?l(10):2,x=a(g,g),S;s&&(S=Array(n).fill(m));for(var C=!1;!C;){C=!0;for(var w=0;w1&&(x=u(Array(g-1).fill(f)))),--g,p.pop();for(var M=0;M2&&(x=u(Array(g-2).fill(f)))),g-=2,p.pop(),p.pop();for(var ee=0;ee+n(c(e),c(t))),S>100){var te=Error(`The eigenvalues failed to converge. Only found these eigenvalues: `+h.join(`, `));throw te.values=h,te.vectors=[],te}return{values:h,C:s?i(y,j(_,r)):void 0}}function D(e,t,a,o,s,c,d){var f=i(p(a),e,a),m=d===`BigNumber`,h=d===`Complex`,y=m?l(0):h?v(0):0,b=m?l(1):h?v(1):1,x=[],S=[];for(var C of s){var w=M(x,C,_);w===-1?(x.push(C),S.push(1)):S[w]+=1}for(var T=[],E=x.length,D=Array(t).fill(y),O=u(Array(t).fill(b)),k=function(){var e=x[A],s=n(f,i(e,O)),l=g(s,D);for(l.shift();l.lengthi(m,e)),T.push(...l.map(t=>({value:e,vector:r(t)})))},A=0;A=5)return null;for(s=0;;){var c=h(e,o);if(b(ne(te(o,[c])),r))break;if(++s>=10)return null;o=re(c)}return o}function ee(e,t,n){var r=n===`BigNumber`,i=n===`Complex`,a=Array(e).fill(0).map(e=>2*Math.random()-1);return r&&(a=a.map(e=>l(e))),i&&(a=a.map(e=>v(e))),a=te(a,t),re(a,n)}function te(e,t){var r=d(e);for(var a of t)a=f(a,r),e=n(e,i(o(S(a,e),S(a,a)),a));return e}function ne(e){return c(s(S(e,e)))}function re(e,t){return i(o(t===`BigNumber`?l(1):t===`Complex`?v(1):1,ne(e)),e)}return C}function QI(e){var{config:t,addScalar:n,subtract:r,abs:i,atan:a,cos:o,sin:s,multiplyScalar:c,inv:l,bignumber:u,multiply:d,add:f}=e;function p(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t.relTol,i=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;if(i===`number`)return m(e,r,a);if(i===`BigNumber`)return h(e,r,a);throw TypeError(`Unsupported data type: `+i)}function m(e,t,n){var r=e.length,i=Math.abs(t/r),a,o;if(n){o=Array(r);for(var s=0;s=Math.abs(i);){var l=c[0][0],u=c[0][1];a=g(e[l][l],e[u][u],e[l][u]),e=x(e,a,l,u),n&&(o=v(o,a,l,u)),c=S(e)}for(var d=Array(r).fill(0),f=0;f=i(a);){var u=l[0][0],d=l[0][1];o=_(e[u][u],e[d][d],e[u][d]),e=b(e,o,u,d),n&&(s=y(s,o,u,d)),l=C(e)}for(var f=Array(r).fill(0),p=0;p({value:a[t],vector:e}))}:{values:a}}return p}var $I=Y(`eigs`,`config.typed.matrix.addScalar.equal.subtract.abs.atan.cos.sin.multiplyScalar.divideScalar.inv.bignumber.multiply.add.larger.column.flatten.number.complex.sqrt.diag.size.reshape.qr.usolve.usolveAll.im.re.smaller.matrixFromColumns.dot`.split(`.`),e=>{var{config:t,typed:n,matrix:r,addScalar:i,subtract:a,equal:o,abs:s,atan:c,cos:l,sin:u,multiplyScalar:d,divideScalar:f,inv:p,bignumber:m,multiply:h,add:g,larger:_,column:v,flatten:y,number:b,complex:x,sqrt:S,diag:C,size:w,reshape:T,qr:E,usolve:D,usolveAll:O,im:k,re:A,smaller:j,matrixFromColumns:M,dot:N}=e,ee=QI({config:t,addScalar:i,subtract:a,column:v,flatten:y,equal:o,abs:s,atan:c,cos:l,sin:u,multiplyScalar:d,inv:p,bignumber:m,complex:x,multiply:h,add:g}),te=ZI({config:t,addScalar:i,subtract:a,multiply:h,multiplyScalar:d,flatten:y,divideScalar:f,sqrt:S,abs:s,bignumber:m,diag:C,size:w,reshape:T,qr:E,inv:p,usolve:D,usolveAll:O,equal:o,complex:x,larger:_,smaller:j,matrixFromColumns:M,dot:N});return n(`eigs`,{Array:function(e){return ne(r(e))},"Array, number|BigNumber":function(e,t){return ne(r(e),{precision:t})},"Array, Object"(e,t){return ne(r(e),t)},Matrix:function(e){return ne(e,{matricize:!0})},"Matrix, number|BigNumber":function(e,t){return ne(e,{precision:t,matricize:!0})},"Matrix, Object":function(e,t){var n={matricize:!0};return cy(n,t),ne(e,n)}});function ne(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=`eigenvectors`in n?n.eigenvectors:!0,a=re(e,n.precision??t.relTol,i);return n.matricize&&(a.values=r(a.values),i&&(a.eigenvectors=a.eigenvectors.map(e=>{var{value:t,vector:n}=e;return{value:t,vector:r(n)}}))),i&&Object.defineProperty(a,"vectors",{enumerable:!1,get:()=>{throw Error(`eigs(M).vectors replaced with eigs(M).eigenvectors`)}}),a}function re(e,t,n){var r=e.toArray(),i=e.size();if(i.length!==2||i[0]!==i[1])throw RangeError(`Matrix must be square (size: ${WC(i)})`);var a=i[0];return F(r,a,t)&&(ie(r,a),P(r,a,t))?ee(r,a,t,I(e,r,a),n):te(r,a,t,I(e,r,a),n)}function P(e,t,n){for(var r=0;r{var{typed:t,abs:n,add:r,identity:i,inv:a,multiply:o}=e;return t(eL,{Matrix:function(e){var t=e.size();if(t.length!==2||t[0]!==t[1])throw RangeError(`Matrix must be square (size: `+WC(t)+`)`);for(var n=t[0],l=c(s(e),1e-15),u=l.q,d=l.j,f=o(e,2**-d),p=i(n),m=i(n),h=1,g=f,_=-1,v=1;v<=u;v++)v>1&&(g=o(g,f),_=-_),h=h*(u-v+1)/((2*u-v+1)*v),p=r(p,o(h,g)),m=r(m,o(h*_,g));for(var y=o(a(m),p),b=0;b{var{typed:t,abs:n,add:r,multiply:i,map:a,sqrt:o,subtract:s,inv:c,size:l,max:u,identity:d}=e,f=1e3,p=1e-6;function m(e){var t,a=0,o=e,m=d(l(e));do{var h=o;if(o=i(.5,r(h,c(m))),m=i(.5,r(m,c(h))),t=u(n(s(o,h))),t>p&&++a>f)throw Error(`computing square root of matrix: iterative method could not converge`)}while(t>p);return o}return t(nL,{"Array | Matrix":function(e){var t=Ny(e)?e.size():ew(e);switch(t.length){case 1:if(t[0]===1)return a(e,o);throw RangeError(`Matrix must be square (size: `+WC(t)+`)`);case 2:if(t[0]===t[1])return m(e);throw RangeError(`Matrix must be square (size: `+WC(t)+`)`);default:throw RangeError(`Matrix must be at most two dimensional (size: `+WC(t)+`)`)}}})}),iL=`sylvester`,aL=Y(iL,[`typed`,`schur`,`matrixFromColumns`,`matrix`,`multiply`,`range`,`concat`,`transpose`,`index`,`subset`,`add`,`subtract`,`identity`,`lusolve`,`abs`],e=>{var{typed:t,schur:n,matrixFromColumns:r,matrix:i,multiply:a,range:o,concat:s,transpose:c,index:l,subset:u,add:d,subtract:f,identity:p,lusolve:m,abs:h,config:g}=e;return t(iL,{"Matrix, Matrix, Matrix":_,"Array, Matrix, Matrix":function(e,t,n){return _(i(e),t,n)},"Array, Array, Matrix":function(e,t,n){return _(i(e),i(t),n)},"Array, Matrix, Array":function(e,t,n){return _(i(e),t,i(n))},"Matrix, Array, Matrix":function(e,t,n){return _(e,i(t),n)},"Matrix, Array, Array":function(e,t,n){return _(e,i(t),i(n))},"Matrix, Matrix, Array":function(e,t,n){return _(e,t,i(n))},"Array, Array, Array":function(e,t,n){return _(i(e),i(t),i(n)).toArray()}});function _(e,t,g){for(var _=t.size()[0],v=e.size()[0],y=n(e),b=y.T,x=y.U,S=n(a(-1,t)),C=S.T,w=S.U,T=a(a(c(x),g),w),E=o(0,v),D=[],O=(e,t)=>s(e,t,1),k=(e,t)=>s(e,t,0),A=0;A<_;A++)if(A<_-1&&h(u(C,l(A+1,A)))>1e-5){for(var j=k(u(T,l(E,[A])),u(T,l(E,[A+1]))),M=0;M{var{typed:t,matrix:n,identity:r,multiply:i,qr:a,norm:o,subtract:s}=e;return t(oL,{Array:function(e){var t=c(n(e));return{U:t.U.valueOf(),T:t.T.valueOf()}},Matrix:function(e){return c(e)}});function c(e){var t=e.size()[0],n=e,c=r(t),l=0,u;do{u=n;var d=a(n),f=d.Q,p=d.R;if(n=i(p,f),c=i(c,f),l++>100)break}while(o(s(n,u))>1e-4);return{U:c,T:n}}}),cL=`lyap`,lL=Y(cL,[`typed`,`matrix`,`sylvester`,`multiply`,`transpose`],e=>{var{typed:t,matrix:n,sylvester:r,multiply:i,transpose:a}=e;return t(cL,{"Matrix, Matrix":function(e,t){return r(e,a(e),i(-1,t))},"Array, Matrix":function(e,t){return r(n(e),a(n(e)),i(-1,t))},"Matrix, Array":function(e,t){return r(e,a(n(e)),n(i(-1,t)))},"Array, Array":function(e,t){return r(n(e),a(n(e)),n(i(-1,t))).toArray()}})}),uL=Y(`divide`,[`typed`,`matrix`,`multiply`,`equalScalar`,`divideScalar`,`inv`],e=>{var{typed:t,matrix:n,multiply:r,equalScalar:i,divideScalar:a,inv:o}=e,s=HD({typed:t,equalScalar:i}),c=WD({typed:t});return t(`divide`,vb({"Array | Matrix, Array | Matrix":function(e,t){return r(e,o(t))},"DenseMatrix, any":function(e,t){return c(e,t,a,!1)},"SparseMatrix, any":function(e,t){return s(e,t,a,!1)},"Array, any":function(e,t){return c(n(e),t,a,!1).valueOf()},"any, Array | Matrix":function(e,t){return r(e,o(t))}},a.signatures))}),dL=`distance`,fL=Y(dL,[`typed`,`addScalar`,`subtractScalar`,`divideScalar`,`multiplyScalar`,`deepEqual`,`sqrt`,`abs`],e=>{var{typed:t,addScalar:n,subtractScalar:r,multiplyScalar:i,divideScalar:a,deepEqual:o,sqrt:s,abs:c}=e;return t(dL,{"Array, Array, Array":function(e,t,n){if(e.length===2&&t.length===2&&n.length===2){if(!u(e))throw TypeError(`Array with 2 numbers or BigNumbers expected for first argument`);if(!u(t))throw TypeError(`Array with 2 numbers or BigNumbers expected for second argument`);if(!u(n))throw TypeError(`Array with 2 numbers or BigNumbers expected for third argument`);if(o(t,n))throw TypeError(`LinePoint1 should not be same with LinePoint2`);var a=r(n[1],t[1]),s=r(t[0],n[0]),c=r(i(n[0],t[1]),i(t[0],n[1]));return g(e[0],e[1],a,s,c)}else throw TypeError(`Invalid Arguments: Try again`)},"Object, Object, Object":function(e,t,n){if(Object.keys(e).length===2&&Object.keys(t).length===2&&Object.keys(n).length===2){if(!u(e))throw TypeError(`Values of pointX and pointY should be numbers or BigNumbers`);if(!u(t))throw TypeError(`Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers`);if(!u(n))throw TypeError(`Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers`);if(o(m(t),m(n)))throw TypeError(`LinePoint1 should not be same with LinePoint2`);if(`pointX`in e&&`pointY`in e&&`lineOnePtX`in t&&`lineOnePtY`in t&&`lineTwoPtX`in n&&`lineTwoPtY`in n){var a=r(n.lineTwoPtY,t.lineOnePtY),s=r(t.lineOnePtX,n.lineTwoPtX),c=r(i(n.lineTwoPtX,t.lineOnePtY),i(t.lineOnePtX,n.lineTwoPtY));return g(e.pointX,e.pointY,a,s,c)}else throw TypeError(`Key names do not match`)}else throw TypeError(`Invalid Arguments: Try again`)},"Array, Array":function(e,t){if(e.length===2&&t.length===3){if(!u(e))throw TypeError(`Array with 2 numbers or BigNumbers expected for first argument`);if(!d(t))throw TypeError(`Array with 3 numbers or BigNumbers expected for second argument`);return g(e[0],e[1],t[0],t[1],t[2])}else if(e.length===3&&t.length===6){if(!d(e))throw TypeError(`Array with 3 numbers or BigNumbers expected for first argument`);if(!p(t))throw TypeError(`Array with 6 numbers or BigNumbers expected for second argument`);return _(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}else if(e.length===t.length&&e.length>0){if(!f(e)||!f(t))throw TypeError(`All values of an array should be numbers or BigNumbers`);return v(e,t)}else throw TypeError(`Invalid Arguments: Try again`)},"Object, Object":function(e,t){if(Object.keys(e).length===2&&Object.keys(t).length===3){if(!u(e))throw TypeError(`Values of pointX and pointY should be numbers or BigNumbers`);if(!d(t))throw TypeError(`Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers`);if(`pointX`in e&&`pointY`in e&&`xCoeffLine`in t&&`yCoeffLine`in t&&`constant`in t)return g(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw TypeError(`Key names do not match`)}else if(Object.keys(e).length===3&&Object.keys(t).length===6){if(!d(e))throw TypeError(`Values of pointX, pointY and pointZ should be numbers or BigNumbers`);if(!p(t))throw TypeError(`Values of x0, y0, z0, a, b and c should be numbers or BigNumbers`);if(`pointX`in e&&`pointY`in e&&`x0`in t&&`y0`in t&&`z0`in t&&`a`in t&&`b`in t&&`c`in t)return _(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw TypeError(`Key names do not match`)}else if(Object.keys(e).length===2&&Object.keys(t).length===2){if(!u(e))throw TypeError(`Values of pointOneX and pointOneY should be numbers or BigNumbers`);if(!u(t))throw TypeError(`Values of pointTwoX and pointTwoY should be numbers or BigNumbers`);if(`pointOneX`in e&&`pointOneY`in e&&`pointTwoX`in t&&`pointTwoY`in t)return v([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw TypeError(`Key names do not match`)}else if(Object.keys(e).length===3&&Object.keys(t).length===3){if(!d(e))throw TypeError(`Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers`);if(!d(t))throw TypeError(`Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers`);if(`pointOneX`in e&&`pointOneY`in e&&`pointOneZ`in e&&`pointTwoX`in t&&`pointTwoY`in t&&`pointTwoZ`in t)return v([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw TypeError(`Key names do not match`)}else throw TypeError(`Invalid Arguments: Try again`)},Array:function(e){if(!h(e))throw TypeError(`Incorrect array format entered for pairwise distance calculation`);return y(e)}});function l(e){return typeof e==`number`||Ey(e)}function u(e){return e.constructor!==Array&&(e=m(e)),l(e[0])&&l(e[1])}function d(e){return e.constructor!==Array&&(e=m(e)),l(e[0])&&l(e[1])&&l(e[2])}function f(e){return Array.isArray(e)||(e=m(e)),e.every(l)}function p(e){return e.constructor!==Array&&(e=m(e)),l(e[0])&&l(e[1])&&l(e[2])&&l(e[3])&&l(e[4])&&l(e[5])}function m(e){for(var t=Object.keys(e),n=[],r=0;re.length!==2||!l(e[0])||!l(e[1])))return!1}else if(e[0].length===3&&l(e[0][0])&&l(e[0][1])&&l(e[0][2])){if(e.some(e=>e.length!==3||!l(e[0])||!l(e[1])||!l(e[2])))return!1}else return!1;return!0}function g(e,t,r,o,l){return a(c(n(n(i(r,e),i(o,t)),l)),s(n(i(r,r),i(o,o))))}function _(e,t,o,c,l,u,d,f,p){var m=[r(i(r(l,t),p),i(r(u,o),f)),r(i(r(u,o),d),i(r(c,e),p)),r(i(r(c,e),f),i(r(l,t),d))];m=s(n(n(i(m[0],m[0]),i(m[1],m[1])),i(m[2],m[2])));var h=s(n(n(i(d,d),i(f,f)),i(p,p)));return a(m,h)}function v(e,t){for(var a=e.length,o=0,c=0,l=0;l{var{typed:t,config:n,abs:r,add:i,addScalar:a,matrix:o,multiply:s,multiplyScalar:c,divideScalar:l,subtract:u,smaller:d,equalScalar:f,flatten:p,isZero:m,isNumeric:h}=e;return t(`intersect`,{"Array, Array, Array":g,"Array, Array, Array, Array":_,"Matrix, Matrix, Matrix":function(e,t,n){var r=g(e.valueOf(),t.valueOf(),n.valueOf());return r===null?null:o(r)},"Matrix, Matrix, Matrix, Matrix":function(e,t,n,r){var i=_(e.valueOf(),t.valueOf(),n.valueOf(),r.valueOf());return i===null?null:o(i)}});function g(e,t,n){if(e=v(e),t=v(t),n=v(n),!b(e))throw TypeError(`Array with 3 numbers or BigNumbers expected for first argument`);if(!b(t))throw TypeError(`Array with 3 numbers or BigNumbers expected for second argument`);if(!x(n))throw TypeError(`Array with 4 numbers expected as third argument`);return T(e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],n[3])}function _(e,t,n,r){if(e=v(e),t=v(t),n=v(n),r=v(r),e.length===2){if(!y(e))throw TypeError(`Array with 2 numbers or BigNumbers expected for first argument`);if(!y(t))throw TypeError(`Array with 2 numbers or BigNumbers expected for second argument`);if(!y(n))throw TypeError(`Array with 2 numbers or BigNumbers expected for third argument`);if(!y(r))throw TypeError(`Array with 2 numbers or BigNumbers expected for fourth argument`);return S(e,t,n,r)}else if(e.length===3){if(!b(e))throw TypeError(`Array with 3 numbers or BigNumbers expected for first argument`);if(!b(t))throw TypeError(`Array with 3 numbers or BigNumbers expected for second argument`);if(!b(n))throw TypeError(`Array with 3 numbers or BigNumbers expected for third argument`);if(!b(r))throw TypeError(`Array with 3 numbers or BigNumbers expected for fourth argument`);return w(e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],r[0],r[1],r[2])}else throw TypeError(`Arrays with two or thee dimensional points expected`)}function v(e){return e.length===1?e[0]:e.length>1&&Array.isArray(e[0])&&e.every(e=>Array.isArray(e)&&e.length===1)?p(e):e}function y(e){return e.length===2&&h(e[0])&&h(e[1])}function b(e){return e.length===3&&h(e[0])&&h(e[1])&&h(e[2])}function x(e){return e.length===4&&h(e[0])&&h(e[1])&&h(e[2])&&h(e[3])}function S(e,t,o,f){var p=e,h=o,g=u(p,t),_=u(h,f),v=u(c(g[0],_[1]),c(_[0],g[1]));if(m(v)||d(r(v),n.relTol))return null;var y=c(_[0],p[1]),b=c(_[1],p[0]),x=c(_[0],h[1]),S=c(_[1],h[0]);return i(s(g,l(a(u(u(y,b),x),S),v)),p)}function C(e,t,n,r,i,o,s,l,d,f,p,m){var h=c(u(e,t),u(n,r)),g=c(u(i,o),u(s,l)),_=c(u(d,f),u(p,m));return a(a(h,g),_)}function w(e,t,n,r,i,o,s,d,p,h,g,_){var v=C(e,s,h,s,t,d,g,d,n,p,_,p),y=C(h,s,r,e,g,d,i,t,_,p,o,n),b=C(e,s,r,e,t,d,i,t,n,p,o,n),x=C(h,s,h,s,g,d,g,d,_,p,_,p),S=C(r,e,r,e,i,t,i,t,o,n,o,n),w=u(c(v,y),c(b,x)),T=u(c(S,x),c(y,y));if(m(T))return null;var E=l(w,T),D=l(a(v,c(E,y)),x),O=a(e,c(E,u(r,e))),k=a(t,c(E,u(i,t))),A=a(n,c(E,u(o,n))),j=a(s,c(D,u(h,s))),M=a(d,c(D,u(g,d))),N=a(p,c(D,u(_,p)));return f(O,j)&&f(k,M)&&f(A,N)?[O,k,A]:null}function T(e,t,n,r,i,o,s,d,f,p){var m=c(e,s),h=c(r,s),g=c(t,d),_=c(i,d),v=c(n,f),y=c(o,f),b=l(u(u(u(p,m),g),v),u(u(u(a(a(h,_),y),m),g),v));return[a(e,c(b,u(r,e))),a(t,c(b,u(i,t))),a(n,c(b,u(o,n)))]}}),mL=`sum`,hL=Y(mL,[`typed`,`config`,`add`,`numeric`],e=>{var{typed:t,config:n,add:r,numeric:i}=e;return t(mL,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":o,"...":function(e){if(Gw(e))throw TypeError(`Scalar values expected in function sum`);return a(e)}});function a(e){var t;return Kw(e,function(e){try{t=t===void 0?e:r(t,e)}catch(t){throw lj(t,`sum`,e)}}),t===void 0&&(t=i(0,n.number)),typeof t==`string`&&(t=i(t,Fb(t,n))),t}function o(e,t){try{return Jw(e,t,r)}catch(e){throw lj(e,`sum`)}}}),gL=`cumsum`,_L=Y(gL,[`typed`,`add`,`unaryPlus`],e=>{var{typed:t,add:n,unaryPlus:r}=e;return t(gL,{Array:i,Matrix:function(e){return e.create(i(e.valueOf(),e.datatype()))},"Array, number | BigNumber":o,"Matrix, number | BigNumber":function(e,t){return e.create(o(e.valueOf(),t),e.datatype())},"...":function(e){if(Gw(e))throw TypeError(`All values expected to be scalar in function cumsum`);return i(e)}});function i(e){try{return a(e)}catch(e){throw lj(e,gL)}}function a(e){if(e.length===0)return[];for(var t=[r(e[0])],i=1;i=n.length)throw new $C(t,n.length);try{return s(e,t)}catch(e){throw lj(e,gL)}}function s(e,t){var n,r,i;if(t<=0){var o=e[0][0];if(Array.isArray(o)){for(i=Ww(e),r=[],n=0;n{var{typed:t,add:n,divide:r}=e;return t(vL,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":i,"...":function(e){if(Gw(e))throw TypeError(`Scalar values expected in function mean`);return a(e)}});function i(e,t){try{return r(Jw(e,t,n),(Array.isArray(e)?ew(e):e.size())[t])}catch(e){throw lj(e,`mean`)}}function a(e){var t,i=0;if(Kw(e,function(e){try{t=t===void 0?e:n(t,e),i++}catch(t){throw lj(t,`mean`,e)}}),i===0)throw Error(`Cannot calculate the mean of an empty array`);return r(t,i)}}),bL=`median`,xL=Y(bL,[`typed`,`add`,`divide`,`compare`,`partitionSelect`],e=>{var{typed:t,add:n,divide:r,compare:i,partitionSelect:a}=e;function o(e){try{e=gw(e.valueOf());var t=e.length;if(t===0)throw Error(`Cannot calculate median of an empty array`);if(t%2==0){for(var n=t/2-1,r=a(e,n+1),o=e[n],l=0;l0&&(o=e[l]);return c(o,r)}else return s(a(e,(t-1)/2))}catch(e){throw lj(e,`median`)}}var s=t({"number | BigNumber | Complex | Unit":function(e){return e}}),c=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return r(n(e,t),2)}});return t(bL,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw Error(`median(A, dim) is not yet supported`)},"...":function(e){if(Gw(e))throw TypeError(`Scalar values expected in function median`);return o(e)}})}),SL=`mad`,CL=Y(SL,[`typed`,`abs`,`map`,`median`,`subtract`],e=>{var{typed:t,abs:n,map:r,median:i,subtract:a}=e;return t(SL,{"Array | Matrix":o,"...":function(e){return o(e)}});function o(e){if(e=gw(e.valueOf()),e.length===0)throw Error(`Cannot calculate median absolute deviation (mad) of an empty array`);try{var t=i(e);return i(r(e,function(e){return n(a(e,t))}))}catch(e){throw e instanceof TypeError&&e.message.includes(`median`)?TypeError(e.message.replace(`median`,`mad`)):lj(e,`mad`)}}}),wL=`unbiased`,TL=`variance`,EL=Y(TL,[`typed`,`add`,`subtract`,`multiply`,`divide`,`mapSlices`,`isNaN`],e=>{var{typed:t,add:n,subtract:r,multiply:i,divide:a,mapSlices:o,isNaN:s}=e;return t(TL,{"Array | Matrix":function(e){return c(e,wL)},"Array | Matrix, string":c,"Array | Matrix, number | BigNumber":function(e,t){return l(e,t,wL)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return c(e,wL)}});function c(e,t){var o,c=0;if(e.length===0)throw SyntaxError(`Function variance requires one or more parameters (0 provided)`);if(Kw(e,function(e){try{o=o===void 0?e:n(o,e),c++}catch(t){throw lj(t,`variance`,e)}}),c===0)throw Error(`Cannot calculate variance of an empty array`);var l=a(o,c);if(o=void 0,Kw(e,function(e){var t=r(e,l);o=o===void 0?i(t,t):n(o,i(t,t))}),s(o))return o;switch(t){case`uncorrected`:return a(o,c);case`biased`:return a(o,c+1);case`unbiased`:var u=Ey(o)?o.mul(0):0;return c===1?u:a(o,c-1);default:throw Error(`Unknown normalization "`+t+`". Choose "unbiased" (default), "uncorrected", or "biased".`)}}function l(e,t,n){try{if(e.length===0)throw SyntaxError(`Function variance requires one or more parameters (0 provided)`);return o(e,t,e=>c(e,n))}catch(e){throw lj(e,`variance`)}}}),DL=`quantileSeq`,OL=Y(DL,[`typed`,`?bignumber`,`add`,`subtract`,`divide`,`multiply`,`partitionSelect`,`compare`,`isInteger`,`smaller`,`smallerEq`,`larger`,`mapSlices`],e=>{var{typed:t,bignumber:n,add:r,subtract:i,divide:a,multiply:o,partitionSelect:s,compare:c,isInteger:l,smaller:u,smallerEq:d,larger:f,mapSlices:p}=e;return t(DL,{"Array | Matrix, number | BigNumber":(e,t)=>h(e,t,!1),"Array | Matrix, number | BigNumber, number":(e,t,n)=>m(e,t,!1,n,h),"Array | Matrix, number | BigNumber, boolean":h,"Array | Matrix, number | BigNumber, boolean, number":(e,t,n,r)=>m(e,t,n,r,h),"Array | Matrix, Array | Matrix":(e,t)=>g(e,t,!1),"Array | Matrix, Array | Matrix, number":(e,t,n)=>m(e,t,!1,n,g),"Array | Matrix, Array | Matrix, boolean":g,"Array | Matrix, Array | Matrix, boolean, number":(e,t,n,r)=>m(e,t,n,r,g)});function m(e,t,n,r,i){return p(e,r,e=>i(e,t,n))}function h(e,t,i){var o,s=e.valueOf();if(u(t,0))throw Error(`N/prob must be non-negative`);if(d(t,1))return Ty(t)?_(s,t,i):n(_(s,t,i));if(f(t,1)){if(!l(t))throw Error(`N must be a positive integer`);if(f(t,4294967295))throw Error(`N must be less than or equal to 2^32-1, as that is the maximum length of an Array`);var c=r(t,1);o=[];for(var p=0;u(p,t);p++){var m=a(p+1,c);o.push(_(s,m,i))}return Ty(t)?o:n(o)}}function g(e,t,n){for(var r=e.valueOf(),i=t.valueOf(),a=[],o=0;o0&&(m=a[g])}return r(o(m,i(1,p)),o(h,p))}}),kL=`std`,AL=Y(kL,[`typed`,`map`,`sqrt`,`variance`],e=>{var{typed:t,map:n,sqrt:r,variance:i}=e;return t(kL,{"Array | Matrix":a,"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":a,"Array | Matrix, number | BigNumber, string":a,"...":function(e){return a(e)}});function a(e,t){if(e.length===0)throw SyntaxError(`Function std requires one or more parameters (0 provided)`);try{var a=i.apply(null,arguments);return Py(a)?n(a,r):r(a)}catch(e){throw e instanceof TypeError&&e.message.includes(` variance`)?TypeError(e.message.replace(` variance`,` std`)):e}}}),jL=`corr`,ML=Y(jL,[`typed`,`matrix`,`mean`,`sqrt`,`sum`,`add`,`subtract`,`multiply`,`pow`,`divide`],e=>{var{typed:t,matrix:n,sqrt:r,sum:i,add:a,subtract:o,multiply:s,pow:c,divide:l}=e;return t(jL,{"Array, Array":function(e,t){return u(e,t)},"Matrix, Matrix":function(e,t){var r=u(e.toArray(),t.toArray());return Array.isArray(r)?n(r):r}});function u(e,t){var n=[];if(Array.isArray(e[0])&&Array.isArray(t[0])){if(e.length!==t.length)throw SyntaxError(`Dimension mismatch. Array A and B must have the same length.`);for(var r=0;ra(e,s(n,t[r])),0),p=i(e.map(e=>c(e,2))),m=i(t.map(e=>c(e,2)));return l(o(s(n,f),s(u,d)),r(s(o(s(n,p),c(u,2)),o(s(n,m),c(d,2)))))}}),NL=`bernoulli`,PL=Y(NL,[`typed`,`config`,`isInteger`,`number`,`?BigNumber`,`?Fraction`],e=>{var{typed:t,config:n,number:r,BigNumber:i,Fraction:a}=e,o=[void 0],s=[void 0],c=[void 0],l=50;return t(NL,{number:e=>FL(e,e=>e,o,(e,t)=>e+t,(e,t)=>e*t,(e,t)=>e/t),"bigint | Fraction":e=>FL(r(e),e=>new a(e),s,(e,t)=>e.add(t),(e,t)=>e.mul(t),(e,t)=>e.div(t)),BigNumber:e=>(n.precision!==l&&(c=[void 0],l=n.precision),FL(r(e),e=>new i(e),c,(e,t)=>e.add(t),(e,t)=>e.mul(t),(e,t)=>e.div(t)))})});function FL(e,t,n,r,i,a){if(e<0||!X(e))throw RangeError(`Bernoulli index must be nonnegative integer`);if(e===0)return t(1);if(e===1)return a(t(-1),t(2));if(e%2==1)return t(0);var o=t(1);n.length===1&&n.push([a(o,t(-3)),a(o,t(-2)),a(o,t(6))]);for(var s=e/2,c=t(0),l=t(2);n.length<=s;){for(var u=n.length,d=Math.floor((u+1)/2),f=c,p=1;p{var{typed:t}=e;return t(IL,{"number, number":LT,"BigNumber, BigNumber":function(e,t){var n=e.constructor,r,i,a=e.minus(t),o=new n(1);if(!RL(e)||!RL(t))throw TypeError(`Positive integer value expected in function combinations`);if(t.gt(e))throw TypeError(`k must be less than n in function combinations`);if(r=o,t.lt(a))for(i=o;i.lte(a);i=i.plus(o))r=r.times(t.plus(i)).dividedBy(i);else for(i=o;i.lte(t);i=i.plus(o))r=r.times(a.plus(i)).dividedBy(i);return r}})});function RL(e){return e.isInteger()&&e.gte(0)}var zL=`combinationsWithRep`,BL=Y(zL,[`typed`],e=>{var{typed:t}=e;return t(zL,{"number, number":function(e,t){if(!X(e)||e<0||!X(t)||t<0)throw TypeError(`Positive integer value expected in function combinationsWithRep`);if(e<1)throw TypeError(`k must be less than or equal to n + k - 1`);return t{var{typed:t,config:n,multiplyScalar:r,pow:i,BigNumber:a,Complex:o}=e;function s(e){if(e.im===0)return JT(e.re);if(e.re<.5){var t=new o(1-e.re,-e.im),n=new o(Math.PI*e.re,Math.PI*e.im);return new o(Math.PI).div(n.sin()).div(s(t))}e=new o(e.re-1,e.im);for(var r=new o(XT[0],0),i=1;i2;)i-=2,s+=i,o=o.times(s);return new a(o.toPrecision(a.precision))}}),WL=`lgamma`,GL=Y(WL,[`Complex`,`typed`],e=>{var{Complex:t,typed:n}=e,r=7,i=7,a=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return n(WL,{number:$T,Complex:o,BigNumber:function(){throw Error(`mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber`)}});function o(e){var n=6.283185307179586,a=1.1447298858494002,l=.1;if(e.isNaN())return new t(NaN,NaN);if(e.im===0)return new t($T(e.re),0);if(e.re>=r||Math.abs(e.im)>=i)return s(e);if(e.re<=l){var u=ox(n,e.im)*Math.floor(.5*e.re+.25),d=e.mul(Math.PI).sin().log(),f=o(new t(1-e.re,-e.im));return new t(a,u).sub(d).sub(f)}else if(e.im>=0)return c(e);else return c(e.conjugate()).conjugate()}function s(e){for(var n=e.sub(.5).mul(e.log()).sub(e).add(ZT),r=new t(1,0).div(e),i=r.div(e),o=a[0],s=a[1],c=2*i.re,l=i.re*i.re+i.im*i.im,u=2;u<8;u++){var d=s;s=-l*o+a[u],o=c*o+d}var f=r.mul(i.mul(o).add(s));return n.add(f)}function c(e){var n=0,i=0,a=e;for(e=e.add(1);e.re<=r;){a=a.mul(e);var o=+(a.im<0);o!==0&&i===0&&n++,i=o,e=e.add(1)}return s(e).sub(a.log()).sub(new t(0,n*2*Math.PI*1))}}),KL=`factorial`,qL=Y(KL,[`typed`,`gamma`],e=>{var{typed:t,gamma:n}=e;return t(KL,{number:function(e){if(e<0)throw Error(`Value must be non-negative`);return n(e+1)},BigNumber:function(e){if(e.isNegative())throw Error(`Value must be non-negative`);return n(e.plus(1))},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),JL=`kldivergence`,YL=Y(JL,[`typed`,`matrix`,`divide`,`sum`,`multiply`,`map`,`dotDivide`,`log`,`isNumeric`],e=>{var{typed:t,matrix:n,divide:r,sum:i,multiply:a,map:o,dotDivide:s,log:c,isNumeric:l}=e;return t(JL,{"Array, Array":function(e,t){return u(n(e),n(t))},"Matrix, Array":function(e,t){return u(e,n(t))},"Array, Matrix":function(e,t){return u(n(e),t)},"Matrix, Matrix":function(e,t){return u(e,t)}});function u(e,t){var n=t.size().length,u=e.size().length;if(n>1)throw Error(`first object must be one dimensional`);if(u>1)throw Error(`second object must be one dimensional`);if(n!==u)throw Error(`Length of two vectors must be equal`);if(i(e)===0)throw Error(`Sum of elements in first object must be non zero`);if(i(t)===0)throw Error(`Sum of elements in second object must be non zero`);var d=r(e,i(e)),f=i(a(d,o(s(d,r(t,i(t))),e=>c(e))));return l(f)?f:NaN}}),XL=`multinomial`,ZL=Y(XL,[`typed`,`add`,`divide`,`multiply`,`factorial`,`isInteger`,`isPositive`],e=>{var{typed:t,add:n,divide:r,multiply:i,factorial:a,isInteger:o,isPositive:s}=e;return t(XL,{"Array | Matrix":function(e){var t=0,c=1;return Kw(e,function(e){if(!o(e)||!s(e))throw TypeError(`Positive integer value expected in function multinomial`);t=n(t,e),c=i(c,a(e))}),r(a(t),c)}})}),QL=`permutations`,$L=Y(QL,[`typed`,`factorial`],e=>{var{typed:t,factorial:n}=e;return t(QL,{"number | BigNumber":n,"number, number":function(e,t){if(!X(e)||e<0||!X(t)||t<0)throw TypeError(`Positive integer value expected in function permutations`);if(t>e)throw TypeError(`second argument k must be less than or equal to first argument n`);return IT(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var n,r;if(!eR(e)||!eR(t))throw TypeError(`Positive integer value expected in function permutations`);if(t.gt(e))throw TypeError(`second argument k must be less than or equal to first argument n`);for(n=e.mul(0).add(1),r=e.minus(t).plus(1);r.lte(e);r=r.plus(1))n=n.times(r);return n}})});function eR(e){return e.isInteger()&&e.gte(0)}var tR=o(((e,t)=>{(function(e,t,n){function r(e){var t=this,n=o();t.next=function(){var e=2091639*t.s0+t.c*23283064365386963e-26;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=e|0)},t.c=1,t.s0=n(` `),t.s1=n(` `),t.s2=n(` `),t.s0-=n(e),t.s0<0&&(t.s0+=1),t.s1-=n(e),t.s1<0&&(t.s1+=1),t.s2-=n(e),t.s2<0&&(t.s2+=1),n=null}function i(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function a(e,t){var n=new r(e),a=t&&t.state,o=n.next;return o.int32=function(){return n.next()*4294967296|0},o.double=function(){return o()+(o()*2097152|0)*11102230246251565e-32},o.quick=o,a&&(typeof a==`object`&&i(a,n),o.state=function(){return i(n,{})}),o}function o(){var e=4022871197;return function(t){t=String(t);for(var n=0;n>>0,r-=e,r*=e,e=r>>>0,r-=e,e+=r*4294967296}return(e>>>0)*23283064365386963e-26}}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.alea=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),nR=o(((e,t)=>{(function(e,t,n){function r(e){var t=this,n=``;t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(e|0)?t.x=e:n+=e;for(var r=0;r>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(typeof a==`object`&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xor128=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),rR=o(((e,t)=>{(function(e,t,n){function r(e){var t=this,n=``;t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^(e^e<<1))|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(e|0)?t.x=e:n+=e;for(var r=0;r>>4),t.next()}function i(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function a(e,t){var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(typeof a==`object`&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xorwow=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),iR=o(((e,t)=>{(function(e,t,n){function r(e){var t=this;t.next=function(){var e=t.x,n=t.i,r=e[n],i;return r^=r>>>7,i=r^r<<24,r=e[n+1&7],i^=r^r>>>10,r=e[n+3&7],i^=r^r>>>3,r=e[n+4&7],i^=r^r<<7,r=e[n+7&7],r^=r<<13,i^=r^r<<9,e[n]=i,t.i=n+1&7,i};function n(e,t){var n,r=[];if(t===(t|0))r[0]=t;else for(t=``+t,n=0;n0;--n)e.next()}n(t,e)}function i(e,t){return t.x=e.x.slice(),t.i=e.i,t}function a(e,t){e??=+new Date;var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(a.x&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xorshift7=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),aR=o(((e,t)=>{(function(e,t,n){function r(e){var t=this;t.next=function(){var e=t.w,n=t.X,r=t.i,i,a;return t.w=e=e+1640531527|0,a=n[r+34&127],i=n[r=r+1&127],a^=a<<13,i^=i<<17,a^=a>>>15,i^=i>>>12,a=n[r]=a^i,t.i=r,a+(e^e>>>16)|0};function n(e,t){var n,r,i,a,o,s=[],c=128;for(t===(t|0)?(r=t,t=null):(t+=`\0`,r=0,c=Math.max(c,t.length)),i=0,a=-32;a>>15,r^=r<<4,r^=r>>>13,a>=0&&(o=o+1640531527|0,n=s[a&127]^=r+o,i=n==0?i+1:0);for(i>=128&&(s[(t&&t.length||0)&127]=-1),i=127,a=512;a>0;--a)r=s[i+34&127],n=s[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[i]=r^n;e.w=o,e.X=s,e.i=i}n(t,e)}function i(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function a(e,t){e??=+new Date;var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(a.X&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xor4096=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),oR=o(((e,t)=>{(function(e,t,n){function r(e){var t=this,n=``;t.next=function(){var e=t.b,n=t.c,r=t.d,i=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=e|0):n+=e;for(var r=0;r>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(typeof a==`object`&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.tychei=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),sR=o(((e,t)=>{(function(e,n,r){var i=256,a=6,o=52,s=`random`,c=r.pow(i,a),l=r.pow(2,o),u=l*2,d=i-1,f;function p(e,t,o){var d=[];t=t==1?{entropy:!0}:t||{};var f=_(g(t.entropy?[e,y(n)]:e??v(),3),d),p=new m(d),b=function(){for(var e=p.g(a),t=c,n=0;e=u;)e/=2,t/=2,n>>>=1;return(e+n)/t};return b.int32=function(){return p.g(4)|0},b.quick=function(){return p.g(4)/4294967296},b.double=b,_(y(p.S),n),(t.pass||o||function(e,t,n,i){return i&&(i.S&&h(i,p),e.state=function(){return h(p,{})}),n?(r[s]=e,t):e})(b,f,`global`in t?t.global:this==r,t.state)}function m(e){var t,n=e.length,r=this,a=0,o=r.i=r.j=0,s=r.S=[];for(n||(e=[n++]);a{var n=tR(),r=nR(),i=rR(),a=iR(),o=aR(),s=oR(),c=sR();c.alea=n,c.xor128=r,c.xorwow=i,c.xorshift7=a,c.xor4096=o,c.tychei=s,t.exports=c}))(),1),lR=(0,cR.default)(Date.now());function uR(e){var t;function n(e){t=e===null?lR:(0,cR.default)(String(e))}n(e);function r(){return t()}return r}var dR=`pickRandom`,fR=Y(dR,[`typed`,`config`,`?on`],e=>{var{typed:t,config:n,on:r}=e,i=uR(n.randomSeed);return r&&r(`config`,function(e,t){e.randomSeed!==t.randomSeed&&(i=uR(e.randomSeed))}),t(dR,{"Array | Matrix":function(e){return a(e,{})},"Array | Matrix, Object":function(e,t){return a(e,t)},"Array | Matrix, number":function(e,t){return a(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return a(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,n){return a(e,{number:n,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,n){return a(e,{number:t,weights:n})}});function a(e,t){var{number:n,weights:r,elementWise:a=!0}=t,o=n===void 0;o&&(n=1);var s=Ny(e)?e.create:Ny(r)?r.create:null;e=e.valueOf(),r&&=r.valueOf(),a===!0&&(e=gw(e),r=gw(r));var c=0;if(r!==void 0){if(r.length!==e.length)throw Error(`Weights must have the same length as possibles`);for(var l=0,u=r.length;l1)for(var r=0,i=e.shift();r{var{typed:t,config:n,on:r}=e,i=uR(n.randomSeed);return r&&r(`config`,function(e,t){e.randomSeed!==t.randomSeed&&(i=uR(e.randomSeed))}),t(mR,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,n)=>a(e,t,n)});function a(e,t,n){var r=pR(e.valueOf(),()=>o(t,n));return Ny(e)?e.create(r,`number`):r}function o(e,t){return e+i()*(t-e)}}),gR=`randomInt`,_R=Y(gR,[`typed`,`config`,`log2`,`?on`],e=>{var{typed:t,config:n,log2:r,on:i}=e,a=uR(n.randomSeed);return i&&i(`config`,function(e,t){e.randomSeed!==t.randomSeed&&(a=uR(e.randomSeed))}),t(gR,{"":()=>s(0,2),number:e=>s(0,e),"number, number":(e,t)=>s(e,t),bigint:e=>c(0n,e),"bigint, bigint":c,"Array | Matrix":e=>o(e,0,1),"Array | Matrix, number":(e,t)=>o(e,0,t),"Array | Matrix, number, number":(e,t,n)=>o(e,t,n)});function o(e,t,n){var r=pR(e.valueOf(),()=>s(t,n));return Ny(e)?e.create(r,`number`):r}function s(e,t){return Math.floor(e+a()*(t-e))}function c(e,t){var n=2n**30n,i=t-e;if(i<=n)return e+BigInt(s(0,Number(i)));for(var o=r(i),c=i;c>=i;){c=0n;for(var l=0;l{var{typed:t,addScalar:n,subtractScalar:r,multiplyScalar:i,divideScalar:a,pow:o,factorial:s,combinations:c,isNegative:l,isInteger:u,number:d,bignumber:f,larger:p}=e,m=[],h=[];return t(vR,{"number | BigNumber, number | BigNumber":function(e,t){if(!u(e)||l(e)||!u(t)||l(t))throw TypeError(`Non-negative integer value expected in function stirlingS2`);if(p(t,e))throw TypeError(`k must be less than or equal to n in function stirlingS2`);var r=!(Ty(e)&&Ty(t)),a=r?h:m,o=r?f:d,s=d(e),c=d(t);if(a[s]&&a[s].length>c)return a[s][c];for(var g=0;g<=s;++g)if(a[g]||(a[g]=[o(+(g===0))]),g!==0)for(var _=a[g],v=a[g-1],y=_.length;y<=g&&y<=c;++y)y===g?_[y]=1:_[y]=n(i(o(y),v[y]),v[y-1]);return a[s][c]}})}),bR=`bellNumbers`,xR=Y(bR,[`typed`,`addScalar`,`isNegative`,`isInteger`,`stirlingS2`],e=>{var{typed:t,addScalar:n,isNegative:r,isInteger:i,stirlingS2:a}=e;return t(bR,{"number | BigNumber":function(e){if(!i(e)||r(e))throw TypeError(`Non-negative integer value expected in function bellNumbers`);for(var t=0,o=0;o<=e;o++)t=n(t,a(e,o));return t}})}),SR=`catalan`,CR=Y(SR,[`typed`,`addScalar`,`divideScalar`,`multiplyScalar`,`combinations`,`isNegative`,`isInteger`],e=>{var{typed:t,addScalar:n,divideScalar:r,multiplyScalar:i,combinations:a,isNegative:o,isInteger:s}=e;return t(SR,{"number | BigNumber":function(e){if(!s(e)||o(e))throw TypeError(`Non-negative integer value expected in function catalan`);return r(a(i(e,2),e),n(e,1))}})}),wR=`composition`,TR=Y(wR,[`typed`,`addScalar`,`combinations`,`isNegative`,`isPositive`,`isInteger`,`larger`],e=>{var{typed:t,addScalar:n,combinations:r,isPositive:i,isNegative:a,isInteger:o,larger:s}=e;return t(wR,{"number | BigNumber, number | BigNumber":function(e,t){if(!o(e)||!i(e)||!o(t)||!i(t))throw TypeError(`Positive integer value expected in function composition`);if(s(t,e))throw TypeError(`k must be less than or equal to n in function composition`);return r(n(e,-1),n(t,-1))}})}),ER=`leafCount`,DR=Y(ER,[`parse`,`typed`],e=>{var{parse:t,typed:n}=e;function r(e){var t=0;return e.forEach(e=>{t+=r(e)}),t||1}return n(ER,{Node:function(e){return r(e)}})});function OR(e){return nb(e)||lb(e)&&e.isUnary()&&nb(e.args[0])}function kR(e){return!!(nb(e)||(ab(e)||lb(e))&&e.args.every(kR)||ub(e)&&kR(e.content))}function AR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function jR(e){for(var t=1;t{var{FunctionNode:t,OperatorNode:n,SymbolNode:r}=e,i=!0,a=!1,o=`defaultF`,s={add:{trivial:i,total:i,commutative:i,associative:i},unaryPlus:{trivial:i,total:i,commutative:i,associative:i},subtract:{trivial:a,total:i,commutative:a,associative:a},multiply:{trivial:i,total:i,commutative:i,associative:i},divide:{trivial:a,total:i,commutative:a,associative:a},paren:{trivial:i,total:i,commutative:i,associative:a},defaultF:{trivial:a,total:i,commutative:a,associative:a}},c={divide:{total:a},log:{total:a}},l={subtract:{total:a},abs:{trivial:i},log:{total:i}};function u(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:s,r=o;if(typeof e==`string`?r=e:lb(e)?r=e.fn.toString():ab(e)?r=e.name:ub(e)&&(r=`paren`),J(n,r)){var i=n[r];if(J(i,t))return i[t];if(J(s,r))return s[r][t]}if(J(n,o)){var a=n[o];return J(a,t)?a[t]:s[o][t]}if(J(s,r)){var c=s[r];if(J(c,t))return c[t]}return s[o][t]}function d(e){return u(e,`commutative`,arguments.length>1&&arguments[1]!==void 0?arguments[1]:s)}function f(e){return u(e,`associative`,arguments.length>1&&arguments[1]!==void 0?arguments[1]:s)}function p(e,t){var n=jR({},e);for(var r in t)J(e,r)?n[r]=jR(jR({},t[r]),e[r]):n[r]=t[r];return n}function m(e,t){if(!e.args||e.args.length===0)return e;e.args=h(e,t);for(var n=0;n2&&f(e,t)){for(var a=e.args.pop();e.args.length>0;)a=n([e.args.pop(),a]);e.args=a.args}}}function _(e,t){if(!(!e.args||e.args.length===0)){for(var n=v(e),r=e.args.length,i=0;i2&&f(e,t)){for(var a=e.args.shift();e.args.length>0;)a=n([a,e.args.shift()]);e.args=a.args}}}function v(e){return lb(e)?function(t){try{return new n(e.op,e.fn,t,e.implicit)}catch(e){return console.error(e),[]}}:function(n){return new t(new r(e.name),n)}}return{createMakeNodeFunction:v,hasProperty:u,isCommutative:d,isAssociative:f,mergeContext:p,flatten:m,allChildren:h,unflattenr:g,unflattenl:_,defaultContext:s,realContext:c,positiveContext:l}}),NR=Y(`simplify`,[`typed`,`parse`,`equal`,`resolve`,`simplifyConstant`,`simplifyCore`,`AccessorNode`,`ArrayNode`,`ConstantNode`,`FunctionNode`,`IndexNode`,`ObjectNode`,`OperatorNode`,`ParenthesisNode`,`SymbolNode`,`replacer`],e=>{var{typed:t,parse:n,equal:r,resolve:i,simplifyConstant:a,simplifyCore:o,AccessorNode:s,ArrayNode:c,ConstantNode:l,FunctionNode:u,IndexNode:d,ObjectNode:f,OperatorNode:p,ParenthesisNode:m,SymbolNode:h,replacer:g}=e,{hasProperty:_,isCommutative:v,isAssociative:y,mergeContext:b,flatten:x,unflattenr:S,unflattenl:C,createMakeNodeFunction:w,defaultContext:T,realContext:E,positiveContext:D}=MR({FunctionNode:u,OperatorNode:p,SymbolNode:h});t.addConversion({from:`Object`,to:`Map`,convert:Cy});var O=t(`simplify`,{Node:te,"Node, Map":(e,t)=>te(e,!1,t),"Node, Map, Object":(e,t,n)=>te(e,!1,t,n),"Node, Array":te,"Node, Array, Map":te,"Node, Array, Map, Object":te});t.removeConversion({from:`Object`,to:`Map`,convert:Cy}),O.defaultContext=T,O.realContext=E,O.positiveContext=D;function k(e){return e.transform(function(e){return ub(e)?k(e.content):e})}var A={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};O.rules=[o,{l:`log(e)`,r:`1`},{s:`n-n1 -> n+-n1`,assuming:{subtract:{total:!0}}},{s:`n-n -> 0`,assuming:{subtract:{total:!1}}},{s:`-(cl*v) -> v * (-cl)`,assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:`-(cl*v) -> (-cl) * v`,assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:`-(v*cl) -> v * (-cl)`,assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:`-(n1/n2)`,r:`-n1/n2`},{l:`-v`,r:`v * (-1)`},{l:`(n1 + n2)*(-1)`,r:`n1*(-1) + n2*(-1)`,repeat:!0},{l:`n/n1^n2`,r:`n*n1^-n2`},{l:`n/n1`,r:`n*n1^-1`},{s:`(n1*n2)^n3 -> n1^n3 * n2^n3`,assuming:{multiply:{commutative:!0}}},{s:`(n1*n2)^(-1) -> n2^(-1) * n1^(-1)`,assuming:{multiply:{commutative:!1}}},{s:`(n ^ n1) ^ n2 -> n ^ (n1 * n2)`,assuming:{divide:{total:!0}}},{l:` vd * ( vd * n1 + n2)`,r:`vd^2 * n1 + vd * n2`},{s:` vd * (vd^n4 * n1 + n2) -> vd^(1+n4) * n1 + vd * n2`,assuming:{divide:{total:!0}}},{s:`vd^n3 * ( vd * n1 + n2) -> vd^(n3+1) * n1 + vd^n3 * n2`,assuming:{divide:{total:!0}}},{s:`vd^n3 * (vd^n4 * n1 + n2) -> vd^(n3+n4) * n1 + vd^n3 * n2`,assuming:{divide:{total:!0}}},{l:`n*n`,r:`n^2`},{s:`n * n^n1 -> n^(n1+1)`,assuming:{divide:{total:!0}}},{s:`n^n1 * n^n2 -> n^(n1+n2)`,assuming:{divide:{total:!0}}},a,{s:`n+n -> 2*n`,assuming:{add:{total:!0}}},{l:`n+-n`,r:`0`},{l:`vd*n + vd`,r:`vd*(n+1)`},{l:`n3*n1 + n3*n2`,r:`n3*(n1+n2)`},{l:`n3^(-n4)*n1 + n3 * n2`,r:`n3^(-n4)*(n1 + n3^(n4+1) *n2)`},{l:`n3^(-n4)*n1 + n3^n5 * n2`,r:`n3^(-n4)*(n1 + n3^(n4+n5)*n2)`},{s:`n*vd + vd -> (n+1)*vd`,assuming:{multiply:{commutative:!1}}},{s:`vd + n*vd -> (1+n)*vd`,assuming:{multiply:{commutative:!1}}},{s:`n1*n3 + n2*n3 -> (n1+n2)*n3`,assuming:{multiply:{commutative:!1}}},{s:`n^n1 * n -> n^(n1+1)`,assuming:{divide:{total:!0},multiply:{commutative:!1}}},{s:`n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)`,assuming:{multiply:{commutative:!1}}},{s:`n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)`,assuming:{multiply:{commutative:!1}}},{l:`n*cd + cd`,r:`(n+1)*cd`},{s:`cd*n + cd -> cd*(n+1)`,assuming:{multiply:{commutative:!1}}},{s:`cd + cd*n -> cd*(1+n)`,assuming:{multiply:{commutative:!1}}},a,{s:`(-n)*n1 -> -(n*n1)`,assuming:{subtract:{total:!0}}},{s:`n1*(-n) -> -(n1*n)`,assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:`ce+ve -> ve+ce`,assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:`vd*cd -> cd*vd`,assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:`n+-n1`,r:`n-n1`},{l:`n+-(n1)`,r:`n-(n1)`},{s:`n*(n1^-1) -> n/n1`,assuming:{multiply:{commutative:!0}}},{s:`n*n1^-n2 -> n/n1^n2`,assuming:{multiply:{commutative:!0}}},{s:`n^-1 -> 1/n`,assuming:{multiply:{commutative:!0}}},{l:`n^1`,r:`n`},{s:`n*(n1/n2) -> (n*n1)/n2`,assuming:{multiply:{associative:!0}}},{s:`n-(n1+n2) -> n-n1-n2`,assuming:{addition:{associative:!0,commutative:!0}}},{l:`1*n`,r:`n`,imposeContext:{multiply:{commutative:!0}}},{s:`n1/(n2/n3) -> (n1*n3)/n2`,assuming:{multiply:{associative:!0}}},{l:`n1/(-n2)`,r:`-n1/n2`}];function j(e,t){var r={};if(e.s){var i=e.s.split(`->`);if(i.length===2)r.l=i[0],r.r=i[1];else throw SyntaxError(`Could not parse rule: `+e.s)}else r.l=e.l,r.r=e.r;r.l=k(n(r.l)),r.r=k(n(r.r));for(var a of[`imposeContext`,`repeat`,`assuming`])a in e&&(r[a]=e[a]);if(e.evaluate&&(r.evaluate=n(e.evaluate)),y(r.l,t)){var o=!v(r.l,t),s;o&&(s=ee());var c=w(r.l),l=ee();r.expanded={},r.expanded.l=c([r.l,l]),x(r.expanded.l,t),S(r.expanded.l,t),r.expanded.r=c([r.r,l]),o&&(r.expandedNC1={},r.expandedNC1.l=c([s,r.l]),r.expandedNC1.r=c([s,r.r]),r.expandedNC2={},r.expandedNC2.l=c([s,r.expanded.l]),r.expandedNC2.r=c([s,r.expanded.r]))}return r}function M(e,t){for(var n=[],r=0;r2&&arguments[2]!==void 0?arguments[2]:Sy(),r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},a=r.consoleDebug;t=M(t||O.rules,r.context);var o=i(e,n);o=k(o);for(var s={},c=o.toString({parenthesis:`all`});!s[c];){s[c]=!0,N=0;var l=c;a&&console.log(`Working on: `,c);for(var u=0;u ${t[u].r.toString()}`)),a){var f=o.toString({parenthesis:`all`});f!==l&&(console.log(`Applying`,d,`produced`,f),l=f)}C(o,r.context)}c=o.toString({parenthesis:`all`})}return o}function ne(e,t,n){var r=e;if(e)for(var i=0;i1&&(c=a(e.args.slice(0,s))),i=e.args.slice(s),r=i.length===1?i[0]:a(i),n.push(a([c,r]))}return n}function F(e,t){var n={placeholders:{}};if(!e.placeholders&&!t.placeholders)return n;if(!e.placeholders)return t;if(!t.placeholders)return e;for(var r in e.placeholders)if(J(e.placeholders,r)&&(n.placeholders[r]=e.placeholders[r],J(t.placeholders,r)&&!oe(e.placeholders[r],t.placeholders[r])))return null;for(var i in t.placeholders)J(t.placeholders,i)&&(n.placeholders[i]=t.placeholders[i]);return n}function ie(e,t){var n=[];if(e.length===0||t.length===0)return n;for(var r,i=0;i2)throw Error(`permuting >2 commutative non-associative rule arguments not yet implemented`);var d=ae(e.args[0],t.args[1],n);if(d.length===0)return[];var f=ae(e.args[1],t.args[0],n);if(f.length===0)return[];o=[d,f]}a=I(o)}else if(t.args.length>=2&&e.args.length===2){for(var m=P(t,n),g=[],_=0;_2)throw Error(`Unexpected non-binary associative function: `+e.toString());else return[]}else if(e instanceof h){if(e.name.length===0)throw Error(`Symbol in rule has 0 length...!?`);if(A[e.name]){if(e.name!==t.name)return[]}else switch(e.name[1]>=`a`&&e.name[1]<=`z`?e.name.substring(0,2):e.name[0]){case`n`:case`_p`:a[0].placeholders[e.name]=t;break;case`c`:case`cl`:if(nb(t))a[0].placeholders[e.name]=t;else return[];break;case`v`:if(!nb(t))a[0].placeholders[e.name]=t;else return[];break;case`vl`:if(pb(t))a[0].placeholders[e.name]=t;else return[];break;case`cd`:if(OR(t))a[0].placeholders[e.name]=t;else return[];break;case`vd`:if(!OR(t))a[0].placeholders[e.name]=t;else return[];break;case`ce`:if(kR(t))a[0].placeholders[e.name]=t;else return[];break;case`ve`:if(!kR(t))a[0].placeholders[e.name]=t;else return[];break;default:throw Error(`Invalid symbol in rule: `+e.name)}}else if(e instanceof l){if(!r(e.value,t.value))return[]}else return[];return a}function oe(e,t){if(e instanceof l&&t instanceof l){if(!r(e.value,t.value))return!1}else if(e instanceof h&&t instanceof h){if(e.name!==t.name)return!1}else if(e instanceof p&&t instanceof p||e instanceof u&&t instanceof u){if(e instanceof p){if(e.op!==t.op||e.fn!==t.fn)return!1}else if(e instanceof u&&e.name!==t.name)return!1;if(e.args.length!==t.args.length)return!1;for(var n=0;n{var{typed:t,config:n,mathWithTransform:r,matrix:i,isBounded:a,fraction:o,bignumber:s,AccessorNode:c,ArrayNode:l,ConstantNode:u,FunctionNode:d,IndexNode:f,ObjectNode:p,OperatorNode:m,SymbolNode:h}=e,{isCommutative:g,isAssociative:_,allChildren:v,createMakeNodeFunction:y}=MR({FunctionNode:d,OperatorNode:m,SymbolNode:h}),b=t(`simplifyConstant`,{Node:e=>w(j(e,{})),"Node, Object":function(e,t){return w(j(e,t))}});function x(e){return ky(e)?e.valueOf():e instanceof Array?e.map(x):Ny(e)?i(x(e.valueOf())):e}function S(e,t,n){try{return r[e].apply(null,t)}catch{return t=t.map(x),E(r[e].apply(null,t),n)}}var C=t({Fraction:O,number:function(e){return e<0?D(new u(-e)):new u(e)},BigNumber:function(e){return e<0?D(new u(-e)):new u(e)},bigint:function(e){return e<0n?D(new u(-e)):new u(e)},Complex:function(e){throw Error(`Cannot convert Complex number to Node`)},string:function(e){return new u(e)},Matrix:function(e){return new l(e.valueOf().map(e=>C(e)))}});function w(e){return sb(e)?e:C(e)}function T(e,t){if(t&&t.exactFractions!==!1&&a(e)&&o){var n=o(e),r=t&&typeof t.fractionsLimit==`number`?t.fractionsLimit:1/0;if(n.valueOf()===e&&n.nn.number===`BigNumber`&&s?s(e):Number(e),r=e.s*e.n,i=r<0n?new m(`-`,`unaryMinus`,[new u(-t(r))]):new u(t(r));return e.d===1n?i:new m(`/`,`divide`,[i,new u(t(e.d))])}function k(e,t,n){if(!ob(t))return new c(w(e),w(t));if(Qy(e)||Ny(e)){for(var r=Array.from(t.dimensions);r.length>0;)if(nb(r[0])&&typeof r[0].value!=`string`){var a=E(r.shift().value,n);Qy(e)?e=e.items[a-1]:(e=e.valueOf()[a-1],e instanceof Array&&(e=i(e)))}else if(r.length>1&&nb(r[1])&&typeof r[1].value!=`string`){var o=E(r[1].value,n),s=[],d=Qy(e)?e.items:e.valueOf();for(var p of d)if(Qy(p))s.push(p.items[o-1]);else if(Ny(e))s.push(p[o-1]);else break;if(s.length===d.length)e=Qy(e)?new l(s):i(s),r.splice(1,1);else break}else break;return r.length===t.dimensions.length?new c(w(e),t):r.length>0?(t=new f(r),new c(w(e),t)):e}if(cb(e)&&t.dimensions.length===1&&nb(t.dimensions[0])){var m=t.dimensions[0].value;return m in e.properties?e.properties[m]:new u}return new c(w(e),t)}function A(e,t,n,r){var i=t.shift(),a=t.reduce((t,i)=>{if(!sb(i)){var a=t.pop();if(sb(a))return[a,i];try{return t.push(S(e,[a,i],r)),t}catch{t.push(a)}}return t.push(w(t.pop())),[n([t.length===1?t[0]:n(t),w(i)])]},[i]);return a.length===1?a[0]:n([a[0],C(a[1])])}function j(e,t){switch(e.type){case`SymbolNode`:return e;case`ConstantNode`:switch(typeof e.value){case`number`:return E(e.value,t);case`bigint`:return E(e.value,t);case`string`:return e.value;default:if(!isNaN(e.value))return E(e.value,t)}return e;case`FunctionNode`:if(r[e.name]&&r[e.name].rawArgs)return e;if(![`add`,`multiply`].includes(e.name)){var n=e.args.map(e=>j(e,t));if(!n.some(sb))try{return S(e.name,n,t)}catch{}if(e.name===`size`&&n.length===1&&Qy(n[0])){for(var a=[],o=n[0];Qy(o);)a.push(o.items.length),o=o.items[0];return i(a)}return new d(e.name,n.map(w))}case`OperatorNode`:var s=e.fn.toString(),c,u,m=y(e);if(lb(e)&&e.isUnary())c=[j(e.args[0],t)],u=sb(c[0])?m(c):S(s,c,t);else if(_(e,t.context))if(c=v(e,t.context),c=c.map(e=>j(e,t)),g(s,t.context)){for(var h=[],x=[],C=0;C1?(u=A(s,h,m,t),x.unshift(u),u=A(s,x,m,t)):u=A(s,c,m,t)}else u=A(s,c,m,t);else c=e.args.map(e=>j(e,t)),u=A(s,c,m,t);return u;case`ParenthesisNode`:return j(e.content,t);case`AccessorNode`:return k(j(e.object,t),j(e.index,t),t);case`ArrayNode`:var T=e.items.map(e=>j(e,t));return T.some(sb)?new l(T.map(w)):i(T);case`IndexNode`:return new f(e.dimensions.map(e=>b(e,t)));case`ObjectNode`:var D={};for(var O in e.properties)D[O]=b(e.properties[O],t);return new p(D);default:throw Error(`Unimplemented node type in simplifyConstant: ${e.type}`)}}return b}),FR=`simplifyCore`,IR=Y(FR,[`typed`,`parse`,`equal`,`isZero`,`add`,`subtract`,`multiply`,`divide`,`pow`,`AccessorNode`,`ArrayNode`,`ConstantNode`,`FunctionNode`,`IndexNode`,`ObjectNode`,`OperatorNode`,`ParenthesisNode`,`SymbolNode`],e=>{var{typed:t,parse:n,equal:r,isZero:i,add:a,subtract:o,multiply:s,divide:c,pow:l,AccessorNode:u,ArrayNode:d,ConstantNode:f,FunctionNode:p,IndexNode:m,ObjectNode:h,OperatorNode:g,ParenthesisNode:_,SymbolNode:v}=e,y=new f(0),b=new f(1),x=new f(!0),S=new f(!1);function C(e){return lb(e)&&[`and`,`not`,`or`].includes(e.op)}var{hasProperty:w,isCommutative:T}=MR({FunctionNode:p,OperatorNode:g,SymbolNode:v});function E(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t?t.context:void 0;if(w(e,`trivial`,n)){if(ab(e)&&e.args.length===1)return E(e.args[0],t);var a=!1,o=0;if(e.forEach(e=>{++o,o===1&&(a=E(e,t))}),o===1)return a}var s=e;if(ab(s)){var c=sF(s.name);if(c){if(s.args.length>2&&w(s,`associative`,n))for(;s.args.length>2;){var l=s.args.pop(),f=s.args.pop();s.args.push(new g(c,s.name,[l,f]))}s=new g(c,s.name,s.args)}else return new p(E(s.fn),s.args.map(e=>E(e,t)))}if(lb(s)&&s.isUnary()){var _=E(s.args[0],t);if(s.op===`~`&&lb(_)&&_.isUnary()&&_.op===`~`||s.op===`not`&&lb(_)&&_.isUnary()&&_.op===`not`&&C(_.args[0]))return _.args[0];var v=!0;if(s.op===`-`&&lb(_)&&(_.isBinary()&&_.fn===`subtract`&&(s=new g(`-`,`subtract`,[_.args[1],_.args[0]]),v=!1),_.isUnary()&&_.op===`-`))return _.args[0];if(v)return new g(s.op,s.fn,[_])}if(lb(s)&&s.isBinary()){var D=E(s.args[0],t),O=E(s.args[1],t);if(s.op===`+`){if(nb(D)&&i(D.value))return O;if(nb(O)&&i(O.value))return D;lb(O)&&O.isUnary()&&O.op===`-`&&(O=O.args[0],s=new g(`-`,`subtract`,[D,O]))}if(s.op===`-`)return lb(O)&&O.isUnary()&&O.op===`-`?E(new g(`+`,`add`,[D,O.args[0]]),t):nb(D)&&i(D.value)?E(new g(`-`,`unaryMinus`,[O])):nb(O)&&i(O.value)?D:new g(s.op,s.fn,[D,O]);if(s.op===`*`){if(nb(D)){if(i(D.value))return y;if(r(D.value,1))return O}if(nb(O)){if(i(O.value))return y;if(r(O.value,1))return D;if(T(s,n))return new g(s.op,s.fn,[O,D],s.implicit)}return new g(s.op,s.fn,[D,O],s.implicit)}if(s.op===`/`)return nb(D)&&i(D.value)?y:nb(O)&&r(O.value,1)?D:new g(s.op,s.fn,[D,O]);if(s.op===`^`&&nb(O)){if(i(O.value))return b;if(r(O.value,1))return D}if(s.op===`and`){if(nb(D))if(D.value){if(C(O))return O;if(nb(O))return O.value?x:S}else return S;if(nb(O))if(O.value){if(C(D))return D}else return S}if(s.op===`or`){if(nb(D)){if(D.value)return x;if(C(O))return O}if(nb(O)){if(O.value)return x;if(C(D))return D}}return new g(s.op,s.fn,[D,O])}if(lb(s))return new g(s.op,s.fn,s.args.map(e=>E(e,t)));if(Qy(s))return new d(s.items.map(e=>E(e,t)));if(Zy(s))return new u(E(s.object,t),E(s.index,t));if(ob(s))return new m(s.dimensions.map(e=>E(e,t)));if(cb(s)){var k={};for(var A in s.properties)k[A]=E(s.properties[A],t);return new h(k)}return s}return t(FR,{Node:E,"Node,Object":E})}),LR=Y(`resolve`,[`typed`,`parse`,`ConstantNode`,`FunctionNode`,`OperatorNode`,`ParenthesisNode`],e=>{var{typed:t,parse:n,ConstantNode:r,FunctionNode:i,OperatorNode:a,ParenthesisNode:o}=e;function s(e,t){var c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!t)return e;if(pb(e)){if(c.has(e.name)){var l=Array.from(c).join(`, `);throw ReferenceError(`recursive loop of variable definitions among {${l}}`)}var u=t.get(e.name);if(sb(u)){var d=new Set(c);return d.add(e.name),s(u,t,d)}else if(typeof u==`number`)return n(String(u));else if(u!==void 0)return new r(u);else return e}else if(lb(e)){var f=e.args.map(function(e){return s(e,t,c)});return new a(e.op,e.fn,f,e.implicit)}else if(ub(e))return new o(s(e.content,t,c));else if(ab(e)){var p=e.args.map(function(e){return s(e,t,c)});return new i(e.name,p)}return e.map(e=>s(e,t,c))}return t(`resolve`,{Node:s,"Node, Map | null | undefined":s,"Node, Object":(e,t)=>s(e,Cy(t)),"Array | Matrix":t.referToSelf(e=>t=>t.map(t=>e(t))),"Array | Matrix, null | undefined":t.referToSelf(e=>t=>t.map(t=>e(t))),"Array, Object":t.referTo(`Array,Map`,e=>(t,n)=>e(t,Cy(n))),"Matrix, Object":t.referTo(`Matrix,Map`,e=>(t,n)=>e(t,Cy(n))),"Array | Matrix, Map":t.referToSelf(e=>(t,n)=>t.map(t=>e(t,n)))})}),RR=`symbolicEqual`,zR=Y(RR,[`parse`,`simplify`,`typed`,`OperatorNode`],e=>{var{parse:t,simplify:n,typed:r,OperatorNode:i}=e;function a(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=n(new i(`-`,`subtract`,[e,t]),{},r);return nb(a)&&!a.value}return r(RR,{"Node, Node":a,"Node, Node, Object":a})}),BR=`derivative`,VR=Y(BR,[`typed`,`config`,`parse`,`simplify`,`equal`,`isZero`,`numeric`,`ConstantNode`,`FunctionNode`,`OperatorNode`,`ParenthesisNode`,`SymbolNode`],e=>{var{typed:t,config:n,parse:r,simplify:i,equal:a,isZero:o,numeric:s,ConstantNode:c,FunctionNode:l,OperatorNode:u,ParenthesisNode:d,SymbolNode:f}=e;function p(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{simplify:!0},r=new Map,a=t.name;function o(e){var t=r.get(e);if(t!==void 0)return t;var n=_(o,e,a);return r.set(e,n),n}var s=v(e,o);return n.simplify?i(s):s}function m(e){var t=r(e);if(!t.isSymbolNode)throw TypeError(`Invalid variable. Cannot parse ${JSON.stringify(e)} into a variable in function derivative`);return t}var h=t(BR,{"Node, SymbolNode":p,"Node, SymbolNode, Object":p,"Node, string":(e,t)=>p(e,m(t)),"Node, string, Object":(e,t,n)=>p(e,m(t),n)});h._simplify=!0,h.toTex=function(e){return g.apply(null,e.args)};var g=t(`_derivTex`,{"Node, SymbolNode":function(e,t){return nb(e)&&hb(e.value)===`string`?g(r(e.value).toString(),t.toString(),1):g(e.toTex(),t.toString(),1)},"Node, ConstantNode":function(e,t){if(hb(t.value)===`string`)return g(e,r(t.value));throw Error(`The second parameter to 'derivative' is a non-string constant`)},"Node, SymbolNode, ConstantNode":function(e,t,n){return g(e.toString(),t.name,n.value)},"string, string, number":function(e,t,n){return(n===1?`{d\\over d`+t+`}`:`{d^{`+n+`}\\over d`+t+`^{`+n+`}}`)+`\\left[${e}\\right]`}}),_=t(`_isConst`,{"function, ConstantNode, string":function(){return!0},"function, SymbolNode, string":function(e,t,n){return t.name!==n},"function, ParenthesisNode, string":function(e,t,n){return e(t.content,n)},"function, FunctionAssignmentNode, string":function(e,t,n){return t.params.includes(n)?e(t.expr,n):!0},"function, FunctionNode | OperatorNode, string":function(e,t,n){return t.args.every(t=>e(t,n))}}),v=t(`_derivative`,{"ConstantNode, function":function(){return y(0)},"SymbolNode, function":function(e,t){return t(e)?y(0):y(1)},"ParenthesisNode, function":function(e,t){return new d(v(e.content,t))},"FunctionAssignmentNode, function":function(e,t){return t(e)?y(0):v(e.expr,t)},"FunctionNode, function":function(e,t){if(t(e))return y(0);var n=e.args[0],r,i=!1,a=!1,o;switch(e.name){case`cbrt`:i=!0,o=new u(`*`,`multiply`,[y(3),new u(`^`,`pow`,[n,new u(`/`,`divide`,[y(2),y(3)])])]);break;case`sqrt`:case`nthRoot`:if(e.args.length===1)i=!0,o=new u(`*`,`multiply`,[y(2),new l(`sqrt`,[n])]);else if(e.args.length===2)return r=new u(`/`,`divide`,[y(1),e.args[1]]),v(new u(`^`,`pow`,[n,r]),t);break;case`log10`:r=y(10);case`log`:if(!r&&e.args.length===1)o=n.clone(),i=!0;else if(e.args.length===1&&r||e.args.length===2&&t(e.args[1]))o=new u(`*`,`multiply`,[n.clone(),new l(`log`,[r||e.args[1]])]),i=!0;else if(e.args.length===2)return v(new u(`/`,`divide`,[new l(`log`,[n]),new l(`log`,[e.args[1]])]),t);break;case`pow`:if(e.args.length===2)return v(new u(`^`,`pow`,[n,e.args[1]]),t);break;case`exp`:o=new l(`exp`,[n.clone()]);break;case`sin`:o=new l(`cos`,[n.clone()]);break;case`cos`:o=new u(`-`,`unaryMinus`,[new l(`sin`,[n.clone()])]);break;case`tan`:o=new u(`^`,`pow`,[new l(`sec`,[n.clone()]),y(2)]);break;case`sec`:o=new u(`*`,`multiply`,[e,new l(`tan`,[n.clone()])]);break;case`csc`:a=!0,o=new u(`*`,`multiply`,[e,new l(`cot`,[n.clone()])]);break;case`cot`:a=!0,o=new u(`^`,`pow`,[new l(`csc`,[n.clone()]),y(2)]);break;case`asin`:i=!0,o=new l(`sqrt`,[new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])])]);break;case`acos`:i=!0,a=!0,o=new l(`sqrt`,[new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])])]);break;case`atan`:i=!0,o=new u(`+`,`add`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)]);break;case`asec`:i=!0,o=new u(`*`,`multiply`,[new l(`abs`,[n.clone()]),new l(`sqrt`,[new u(`-`,`subtract`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])])]);break;case`acsc`:i=!0,a=!0,o=new u(`*`,`multiply`,[new l(`abs`,[n.clone()]),new l(`sqrt`,[new u(`-`,`subtract`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])])]);break;case`acot`:i=!0,a=!0,o=new u(`+`,`add`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)]);break;case`sinh`:o=new l(`cosh`,[n.clone()]);break;case`cosh`:o=new l(`sinh`,[n.clone()]);break;case`tanh`:o=new u(`^`,`pow`,[new l(`sech`,[n.clone()]),y(2)]);break;case`sech`:a=!0,o=new u(`*`,`multiply`,[e,new l(`tanh`,[n.clone()])]);break;case`csch`:a=!0,o=new u(`*`,`multiply`,[e,new l(`coth`,[n.clone()])]);break;case`coth`:a=!0,o=new u(`^`,`pow`,[new l(`csch`,[n.clone()]),y(2)]);break;case`asinh`:i=!0,o=new l(`sqrt`,[new u(`+`,`add`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])]);break;case`acosh`:i=!0,o=new l(`sqrt`,[new u(`-`,`subtract`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])]);break;case`atanh`:i=!0,o=new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])]);break;case`asech`:i=!0,a=!0,o=new u(`*`,`multiply`,[n.clone(),new l(`sqrt`,[new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])])])]);break;case`acsch`:i=!0,a=!0,o=new u(`*`,`multiply`,[new l(`abs`,[n.clone()]),new l(`sqrt`,[new u(`+`,`add`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])])]);break;case`acoth`:i=!0,a=!0,o=new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])]);break;case`abs`:o=new u(`/`,`divide`,[new l(new f(`abs`),[n.clone()]),n.clone()]);break;default:throw Error(`Cannot process function "`+e.name+`" in derivative: the function is not supported, undefined, or the number of arguments passed to it are not supported`)}var s,c;i?(s=`/`,c=`divide`):(s=`*`,c=`multiply`);var d=v(n,t);return a&&(d=new u(`-`,`unaryMinus`,[d])),new u(s,c,[d,o])},"OperatorNode, function":function(e,t){if(t(e))return y(0);if(e.op===`+`)return new u(e.op,e.fn,e.args.map(function(e){return v(e,t)}));if(e.op===`-`){if(e.isUnary())return new u(e.op,e.fn,[v(e.args[0],t)]);if(e.isBinary())return new u(e.op,e.fn,[v(e.args[0],t),v(e.args[1],t)])}if(e.op===`*`){var n=e.args.filter(function(e){return t(e)});if(n.length>0){var r=e.args.filter(function(e){return!t(e)}),i=r.length===1?r[0]:new u(`*`,`multiply`,r);return new u(`*`,`multiply`,n.concat(v(i,t)))}return new u(`+`,`add`,e.args.map(function(n){return new u(`*`,`multiply`,e.args.map(function(e){return e===n?v(e,t):e.clone()}))}))}if(e.op===`/`&&e.isBinary()){var s=e.args[0],c=e.args[1];return t(c)?new u(`/`,`divide`,[v(s,t),c]):t(s)?new u(`*`,`multiply`,[new u(`-`,`unaryMinus`,[s]),new u(`/`,`divide`,[v(c,t),new u(`^`,`pow`,[c.clone(),y(2)])])]):new u(`/`,`divide`,[new u(`-`,`subtract`,[new u(`*`,`multiply`,[v(s,t),c.clone()]),new u(`*`,`multiply`,[s.clone(),v(c,t)])]),new u(`^`,`pow`,[c.clone(),y(2)])])}if(e.op===`^`&&e.isBinary()){var d=e.args[0],f=e.args[1];if(t(d))return nb(d)&&(o(d.value)||a(d.value,1))?y(0):new u(`*`,`multiply`,[e,new u(`*`,`multiply`,[new l(`log`,[d.clone()]),v(f.clone(),t)])]);if(t(f)){if(nb(f)){if(o(f.value))return y(0);if(a(f.value,1))return v(d,t)}var p=new u(`^`,`pow`,[d.clone(),new u(`-`,`subtract`,[f,y(1)])]);return new u(`*`,`multiply`,[f.clone(),new u(`*`,`multiply`,[v(d,t),p])])}return new u(`*`,`multiply`,[new u(`^`,`pow`,[d.clone(),f.clone()]),new u(`+`,`add`,[new u(`*`,`multiply`,[v(d,t),new u(`/`,`divide`,[f.clone(),d.clone()])]),new u(`*`,`multiply`,[v(f,t),new l(`log`,[d.clone()])])])])}throw Error(`Cannot process operator "`+e.op+`" in derivative: the operator is not supported, undefined, or the number of arguments passed to it are not supported`)}});function y(e,t){return new c(s(e,t||Fb(String(e),n)))}return h}),HR=`rationalize`,UR=Y(HR,`config.typed.equal.isZero.add.subtract.multiply.divide.pow.parse.simplifyConstant.simplifyCore.simplify.?bignumber.?fraction.mathWithTransform.matrix.AccessorNode.ArrayNode.ConstantNode.FunctionNode.IndexNode.ObjectNode.OperatorNode.SymbolNode.ParenthesisNode`.split(`.`),e=>{var{config:t,typed:n,equal:r,isZero:i,add:a,subtract:o,multiply:s,divide:c,pow:l,parse:u,simplifyConstant:d,simplifyCore:f,simplify:p,fraction:m,bignumber:h,mathWithTransform:g,matrix:_,AccessorNode:v,ArrayNode:y,ConstantNode:b,FunctionNode:x,IndexNode:S,ObjectNode:C,OperatorNode:w,SymbolNode:T,ParenthesisNode:E}=e;function D(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=k(),i=O(e,t,!0,r.firstRules),a=i.variables.length,o={exactFractions:!1},s={exactFractions:!0};if(e=i.expression,a>=1){e=A(e);var c,l,u=!0,d=!1;e=p(e,r.firstRules,{},o);for(var f;l=u?r.distrDivRules:r.sucDivRules,e=p(e,l,{},s),u=!u,f=e.toString(),f!==c;)d=!0,c=f;d&&(e=p(e,r.firstRulesAgain,{},o)),e=p(e,r.finalRules,{},o)}var m=[],h={};return e.type===`OperatorNode`&&e.isBinary()&&e.op===`/`?(a===1&&(e.args[0]=j(e.args[0],m),e.args[1]=j(e.args[1])),n&&(h.numerator=e.args[0],h.denominator=e.args[1])):(a===1&&(e=j(e,m)),n&&(h.numerator=e,h.denominator=null)),n?(h.coefficients=m,h.variables=i.variables,h.expression=e,h):e}return n(HR,{Node:D,"Node, boolean":(e,t)=>D(e,{},t),"Node, Object":D,"Node, Object, boolean":D});function O(e,t,n,r){var i=[],a=p(e,r,t,{exactFractions:!1});n=!!n;var o=`+-*`+(n?`/`:``);c(a);var s={};return s.expression=a,s.variables=i,s;function c(e){var t=e.type;if(t===`FunctionNode`)throw Error(`There is an unsolved function call`);if(t===`OperatorNode`)if(e.op===`^`){if(e.args[1].type!==`ConstantNode`||!X(parseFloat(e.args[1].value)))throw Error(`There is a non-integer exponent`);c(e.args[0])}else{if(!o.includes(e.op))throw Error(`Operator `+e.op+` invalid in polynomial expression`);for(var n=0;n1;if(r===`OperatorNode`&&e.isBinary()){var a=!1,o;if(e.op===`^`&&(e.args[0].type===`ParenthesisNode`||e.args[0].type===`OperatorNode`)&&e.args[1].type===`ConstantNode`&&(o=parseFloat(e.args[1].value),a=o>=2&&X(o)),a){if(o>2){var s=e.args[0];e=new w(`*`,`multiply`,[s,new w(`^`,`pow`,[e.args[0].cloneDeep(),new b(o-1)])])}else e=new w(`*`,`multiply`,[e.args[0],e.args[0].cloneDeep()]);i&&(n===`content`?t.content=e:t.args[n]=e)}}if(r===`ParenthesisNode`)A(e.content,e,`content`);else if(r!==`ConstantNode`&&r!==`SymbolNode`)for(var c=0;c=0;s--)if(t[s]!==0){var c=new b(a?t[s]:Math.abs(t[s])),l=t[s]<0?`-`:`+`;if(s>0){var u=new T(i);if(s>1){var d=new b(s);u=new w(`^`,`pow`,[u,d])}c=t[s]===-1&&a?new w(`-`,`unaryMinus`,[u]):Math.abs(t[s])===1?u:new w(`*`,`multiply`,[c,u])}o=a?c:l===`+`?new w(`+`,`add`,[o,c]):new w(`-`,`subtract`,[o,c]),a=!1}if(a)return new b(0);return o;function f(e,n,a){var o=e.type;if(o===`FunctionNode`)throw Error(`There is an unsolved function call`);if(o===`OperatorNode`){if(!`+-*^`.includes(e.op))throw Error(`Operator `+e.op+` invalid`);if(n!==null&&((e.fn===`unaryMinus`||e.fn===`pow`)&&n.fn!==`add`&&n.fn!==`subtract`&&n.fn!==`multiply`||(e.fn===`subtract`||e.fn===`add`||e.fn===`multiply`)&&n.fn!==`add`&&n.fn!==`subtract`||(e.fn===`subtract`||e.fn===`add`||e.fn===`unaryMinus`)&&a.noFil!==0))throw Error(`Invalid `+e.op+` placing`);(e.op===`^`||e.op===`*`)&&(a.fire=e.op);for(var s=0;sr&&(t[c]=0),t[c]+=a.cte*(a.oper===`+`?1:-1),r=Math.max(c,r);return}a.cte=c,a.fire===``&&(t[0]+=a.cte*(a.oper===`+`?1:-1))}else throw Error(`Type `+o+` is not allowed`)}}}),WR=`zpk2tf`,GR=Y(WR,[`typed`,`add`,`multiply`,`Complex`,`number`],e=>{var{typed:t,add:n,multiply:r,Complex:i,number:a}=e;return t(WR,{"Array,Array,number":function(e,t,n){return o(e,t,n)},"Array,Array":function(e,t){return o(e,t,1)},"Matrix,Matrix,number":function(e,t,n){return o(e.valueOf(),t.valueOf(),n)},"Matrix,Matrix":function(e,t){return o(e.valueOf(),t.valueOf(),1)}});function o(e,t,n){e.some(e=>e.type===`BigNumber`)&&(e=e.map(e=>a(e))),t.some(e=>e.type===`BigNumber`)&&(t=t.map(e=>a(e)));for(var o=[i(1,0)],c=[i(1,0)],l=0;l=0&&o-s{var{typed:t,add:n,multiply:r,Complex:i,divide:a,matrix:o}=e;return t(KR,{"Array, Array":function(e,t){return s(e,t,c(512))},"Array, Array, Array":function(e,t,n){return s(e,t,n)},"Array, Array, number":function(e,t,n){if(n<0)throw Error(`w must be a positive number`);return s(e,t,c(n))},"Matrix, Matrix":function(e,t){var n=c(512),{w:r,h:i}=s(e.valueOf(),t.valueOf(),n);return{w:o(r),h:o(i)}},"Matrix, Matrix, Matrix":function(e,t,n){var{h:r}=s(e.valueOf(),t.valueOf(),n.valueOf());return{h:o(r),w:o(n)}},"Matrix, Matrix, number":function(e,t,n){if(n<0)throw Error(`w must be a positive number`);var r=c(n),{h:i}=s(e.valueOf(),t.valueOf(),r);return{h:o(i),w:o(r)}}});function s(e,t,o){for(var s=[],c=[],l=0;l{var{classes:t}=e;return function(e,n){var r=t[n&&n.mathjs];return r&&typeof r.fromJSON==`function`?r.fromJSON(n):n}}),YR=Y(`replacer`,[],()=>function(e,t){return typeof t==`number`&&(!Number.isFinite(t)||isNaN(t))?{mathjs:`number`,value:String(t)}:typeof t==`bigint`?{mathjs:`bigint`,value:String(t)}:t}),XR=`15.2.0`,ZR=Y(`true`,[],()=>!0),QR=Y(`false`,[],()=>!1),$R=Y(`null`,[],()=>null),ez=gz(`Infinity`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(1/0):1/0}),tz=gz(`NaN`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(NaN):NaN}),nz=gz(`pi`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?uN(n):RT}),rz=gz(`tau`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?dN(n):zT}),iz=gz(`e`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?cN(n):BT}),az=gz(`phi`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?lN(n):VT}),oz=gz(`LN2`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(2).ln():Math.LN2}),sz=gz(`LN10`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(10).ln():Math.LN10}),cz=gz(`LOG2E`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(1).div(new n(2).ln()):Math.LOG2E}),lz=gz(`LOG10E`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(1).div(new n(10).ln()):Math.LOG10E}),uz=gz(`SQRT1_2`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(`0.5`).sqrt():Math.SQRT1_2}),dz=gz(`SQRT2`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(2).sqrt():Math.SQRT2}),fz=gz(`i`,[`Complex`],e=>{var{Complex:t}=e;return t.I}),pz=Y(`PI`,[`pi`],e=>{var{pi:t}=e;return t}),mz=Y(`E`,[`e`],e=>{var{e:t}=e;return t}),hz=Y(`version`,[],()=>XR);function gz(e,t,n){return Y(e,t,n,{recreateOnConfigChange:!0})}var _z=mB(`speedOfLight`,`299792458`,`m s^-1`),vz=mB(`gravitationConstant`,`6.67430e-11`,`m^3 kg^-1 s^-2`),yz=mB(`planckConstant`,`6.62607015e-34`,`J s`),bz=mB(`reducedPlanckConstant`,`1.0545718176461565e-34`,`J s`),xz=mB(`magneticConstant`,`1.25663706212e-6`,`N A^-2`),Sz=mB(`electricConstant`,`8.8541878128e-12`,`F m^-1`),Cz=mB(`vacuumImpedance`,`376.730313667`,`ohm`),wz=mB(`coulomb`,`8.987551792261171e9`,`N m^2 C^-2`),Tz=mB(`coulombConstant`,`8.987551792261171e9`,`N m^2 C^-2`),Ez=mB(`elementaryCharge`,`1.602176634e-19`,`C`),Dz=mB(`bohrMagneton`,`9.2740100783e-24`,`J T^-1`),Oz=mB(`conductanceQuantum`,`7.748091729863649e-5`,`S`),kz=mB(`inverseConductanceQuantum`,`12906.403729652257`,`ohm`),Az=mB(`magneticFluxQuantum`,`2.0678338484619295e-15`,`Wb`),jz=mB(`nuclearMagneton`,`5.0507837461e-27`,`J T^-1`),Mz=mB(`klitzing`,`25812.807459304513`,`ohm`),Nz=mB(`bohrRadius`,`5.29177210903e-11`,`m`),Pz=mB(`classicalElectronRadius`,`2.8179403262e-15`,`m`),Fz=mB(`electronMass`,`9.1093837015e-31`,`kg`),Iz=mB(`fermiCoupling`,`1.1663787e-5`,`GeV^-2`),Lz=hB(`fineStructure`,.0072973525693),Rz=mB(`hartreeEnergy`,`4.3597447222071e-18`,`J`),zz=mB(`protonMass`,`1.67262192369e-27`,`kg`),Bz=mB(`deuteronMass`,`3.3435830926e-27`,`kg`),Vz=mB(`neutronMass`,`1.6749271613e-27`,`kg`),Hz=mB(`quantumOfCirculation`,`3.6369475516e-4`,`m^2 s^-1`),Uz=mB(`rydberg`,`10973731.568160`,`m^-1`),Wz=mB(`thomsonCrossSection`,`6.6524587321e-29`,`m^2`),Gz=hB(`weakMixingAngle`,.2229),Kz=hB(`efimovFactor`,22.7),qz=mB(`atomicMass`,`1.66053906660e-27`,`kg`),Jz=mB(`avogadro`,`6.02214076e23`,`mol^-1`),Yz=mB(`boltzmann`,`1.380649e-23`,`J K^-1`),Xz=mB(`faraday`,`96485.33212331001`,`C mol^-1`),Zz=mB(`firstRadiation`,`3.7417718521927573e-16`,`W m^2`),Qz=mB(`loschmidt`,`2.686780111798444e25`,`m^-3`),$z=mB(`gasConstant`,`8.31446261815324`,`J K^-1 mol^-1`),eB=mB(`molarPlanckConstant`,`3.990312712893431e-10`,`J s mol^-1`),tB=mB(`molarVolume`,`0.022413969545014137`,`m^3 mol^-1`),nB=hB(`sackurTetrode`,-1.16487052358),rB=mB(`secondRadiation`,`0.014387768775039337`,`m K`),iB=mB(`stefanBoltzmann`,`5.67037441918443e-8`,`W m^-2 K^-4`),aB=mB(`wienDisplacement`,`2.897771955e-3`,`m K`),oB=mB(`molarMass`,`0.99999999965e-3`,`kg mol^-1`),sB=mB(`molarMassC12`,`11.9999999958e-3`,`kg mol^-1`),cB=mB(`gravity`,`9.80665`,`m s^-2`),lB=mB(`planckLength`,`1.616255e-35`,`m`),uB=mB(`planckMass`,`2.176435e-8`,`kg`),dB=mB(`planckTime`,`5.391245e-44`,`s`),fB=mB(`planckCharge`,`1.87554603778e-18`,`C`),pB=mB(`planckTemperature`,`1.416785e+32`,`K`);function mB(e,t,n){return Y(e,[`config`,`Unit`,`BigNumber`],e=>{var{config:r,Unit:i,BigNumber:a}=e,o=new i(r.number===`BigNumber`?new a(t):parseFloat(t),n);return o.fixPrefix=!0,o})}function hB(e,t){return Y(e,[`config`,`BigNumber`],e=>{var{config:n,BigNumber:r}=e;return n.number===`BigNumber`?new r(t):t})}function gB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _B(e){for(var t=1;t{var{typed:t,isInteger:n}=e,r=ND({typed:t,isInteger:n});return t(`mapSlices`,{"...any":function(e){var t=e[1];Ty(t)?e[1]=t-1:Ey(t)&&(e[1]=t.minus(1));try{return r.apply(null,e)}catch(e){throw YP(e)}}})},_B({isTransformFunction:!0},ND.meta)),yB=Y(`column`,[`typed`,`Index`,`matrix`,`range`],e=>{var{typed:t,Index:n,matrix:r,range:i}=e,a=Vk({typed:t,Index:n,matrix:r,range:i});return t(`column`,{"...any":function(e){var t=e.length-1,n=e[t];Ty(n)&&(e[t]=n-1);try{return a.apply(null,e)}catch(e){throw YP(e)}}})},{isTransformFunction:!0});function bB(e,t,n){var r=e.filter(function(e){return pb(e)&&!(e.name in t)&&!n.has(e.name)})[0];if(!r)throw Error(`No undefined variable found in inline expression "`+e+`"`);var i=r.name,a=new Map,o=new by(n,a,new Set([i])),s=e.compile();return function(e){return a.set(i,e),s.evaluate(o)}}var xB=Y(`transformCallback`,[`typed`],e=>{var{typed:t}=e;return function(e,r){return t.isTypedFunction(e)?n(e,r):SB(e,e.length,r)};function n(e,r){var i=Object.fromEntries(Object.entries(e.signatures).map(e=>{var[i,a]=e,o=i.split(`,`).length;return t.isTypedFunction(a)?[i,n(a,r)]:[i,SB(a,o,r)]}));return typeof e.name==`string`?t(e.name,i):t(i)}});function SB(e,t,n){return t===n?e:t===n+1?function(){for(var t=arguments.length,r=Array(t),i=0;in+1?function(){for(var t=arguments.length,r=Array(t),i=0;ie+1)}var wB=Y(`filter`,[`typed`],e=>{var{typed:t}=e;function n(e,n,i){var a=Jk({typed:t}),o=xB({typed:t});if(e.length===0)return a();var s=e[0];if(e.length===1)return a(s);var c=e.length-1,l=e[c];return s&&=r(s,i),l&&=pb(l)||ib(l)?r(l,i):bB(l,n,i),a(s,o(l,c))}n.rawArgs=!0;function r(e,t){return e.compile().evaluate(t)}return n},{isTransformFunction:!0}),TB=Y(`forEach`,[`typed`],e=>{var{typed:t}=e,n=$k({typed:t}),r=xB({typed:t});function i(e,t,i){if(e.length===0)return n();var o=e[0];if(e.length===1)return n(o);var s=e.length-1,c=e[s];return o&&=a(o,i),c&&=pb(c)||ib(c)?a(c,i):bB(c,t,i),n(o,r(c,s))}i.rawArgs=!0;function a(e,t){return e.compile().evaluate(t)}return i},{isTransformFunction:!0}),EB=Y(`index`,[`Index`,`getMatrixDataType`],e=>{var{Index:t,getMatrixDataType:n}=e;return function(){for(var e=[],r=0,i=arguments.length;r0?0:2;else if(a&&a.isSet===!0)a=a.map(function(e){return e-1});else if(My(a)||Ny(a))n(a)!==`boolean`&&(a=a.map(function(e){return e-1}));else if(Ty(a)||Dy(a))a--;else if(Ey(a))a=a.toNumber()-1;else if(typeof a!=`string`)throw TypeError(`Dimension must be an Array, Matrix, number, bigint, string, or Range`);e[r]=a}var o=new t;return t.apply(o,e),o}},{isTransformFunction:!0}),DB=Y(`map`,[`typed`],e=>{var{typed:t}=e,n=cA({typed:t}),r=xB({typed:t});function i(e,t,i){if(e.length===0)return n();if(e.length===1)return n(e[0]);var a=e.length-1,o=e.slice(0,a),s=e[a];return o=o.map(e=>c(e,i)),s&&=pb(s)||ib(s)?c(s,i):bB(s,t,i),n(...o,r(s,a));function c(e,t){return e.compile().evaluate(t)}}return i.rawArgs=!0,i},{isTransformFunction:!0});function OB(e){return Ty(e)?e-1:Ey(e)?e.minus(1):e}function kB(e){return Ty(e)||Ey(e)}function AB(e){if(e.length===2&&Py(e[0])){e=e.slice();var t=e[1];kB(t)&&(e[1]=OB(t))}return e}var jB=Y(`max`,[`typed`,`config`,`numeric`,`larger`,`isNaN`],e=>{var{typed:t,config:n,numeric:r,larger:i,isNaN:a}=e,o=QM({typed:t,config:n,numeric:r,larger:i,isNaN:a});return t(`max`,{"...any":function(e){e=AB(e);try{return o.apply(null,e)}catch(e){throw YP(e)}}})},{isTransformFunction:!0}),MB=Y(`mean`,[`typed`,`add`,`divide`],e=>{var{typed:t,add:n,divide:r}=e,i=yL({typed:t,add:n,divide:r});return t(`mean`,{"...any":function(e){e=AB(e);try{return i.apply(null,e)}catch(e){throw YP(e)}}})},{isTransformFunction:!0}),NB=Y(`min`,[`typed`,`config`,`numeric`,`smaller`,`isNaN`],e=>{var{typed:t,config:n,numeric:r,smaller:i,isNaN:a}=e,o=eN({typed:t,config:n,numeric:r,smaller:i,isNaN:a});return t(`min`,{"...any":function(e){e=AB(e);try{return o.apply(null,e)}catch(e){throw YP(e)}}})},{isTransformFunction:!0}),PB=Y(`range`,[`typed`,`config`,`?matrix`,`?bignumber`,`equal`,`smaller`,`smallerEq`,`larger`,`largerEq`,`add`,`isZero`,`isPositive`],e=>{var{typed:t,config:n,matrix:r,bignumber:i,equal:a,smaller:o,smallerEq:s,larger:c,largerEq:l,add:u,isZero:d,isPositive:f}=e,p=gA({typed:t,config:n,matrix:r,bignumber:i,equal:a,smaller:o,smallerEq:s,larger:c,largerEq:l,add:u,isZero:d,isPositive:f});return t(`range`,{"...any":function(e){return typeof e[e.length-1]!=`boolean`&&e.push(!0),p.apply(null,e)}})},{isTransformFunction:!0}),FB=Y(`row`,[`typed`,`Index`,`matrix`,`range`],e=>{var{typed:t,Index:n,matrix:r,range:i}=e,a=TA({typed:t,Index:n,matrix:r,range:i});return t(`row`,{"...any":function(e){var t=e.length-1,n=e[t];Ty(n)&&(e[t]=n-1);try{return a.apply(null,e)}catch(e){throw YP(e)}}})},{isTransformFunction:!0}),IB=Y(`subset`,[`typed`,`matrix`,`zeros`,`add`],e=>{var{typed:t,matrix:n,zeros:r,add:i}=e,a=jA({typed:t,matrix:n,zeros:r,add:i});return t(`subset`,{"...any":function(e){try{return a.apply(null,e)}catch(e){throw YP(e)}}})},{isTransformFunction:!0}),LB=Y(`concat`,[`typed`,`matrix`,`isInteger`],e=>{var{typed:t,matrix:n,isInteger:r}=e,i=zk({typed:t,matrix:n,isInteger:r});return t(`concat`,{"...any":function(e){var t=e.length-1,n=e[t];Ty(n)?e[t]=n-1:Ey(n)&&(e[t]=n.minus(1));try{return i.apply(null,e)}catch(e){throw YP(e)}}})},{isTransformFunction:!0}),RB=`diff`,zB=Y(RB,[`typed`,`matrix`,`subtract`,`number`,`bignumber`],e=>{var{typed:t,matrix:n,subtract:r,number:i,bignumber:a}=e,o=uA({typed:t,matrix:n,subtract:r,number:i,bignumber:a});return t(RB,{"...any":function(e){e=AB(e);try{return o.apply(null,e)}catch(e){throw YP(e)}}})},{isTransformFunction:!0}),BB=Y(`std`,[`typed`,`map`,`sqrt`,`variance`],e=>{var{typed:t,map:n,sqrt:r,variance:i}=e,a=AL({typed:t,map:n,sqrt:r,variance:i});return t(`std`,{"...any":function(e){e=AB(e);try{return a.apply(null,e)}catch(e){throw YP(e)}}})},{isTransformFunction:!0}),VB=`sum`,HB=Y(VB,[`typed`,`config`,`add`,`numeric`],e=>{var{typed:t,config:n,add:r,numeric:i}=e,a=hL({typed:t,config:n,add:r,numeric:i});return t(VB,{"...any":function(e){e=AB(e);try{return a.apply(null,e)}catch(e){throw YP(e)}}})},{isTransformFunction:!0}),UB=Y(`quantileSeq`,[`typed`,`bignumber`,`add`,`subtract`,`divide`,`multiply`,`partitionSelect`,`compare`,`isInteger`,`smaller`,`smallerEq`,`larger`,`mapSlices`],e=>{var{typed:t,bignumber:n,add:r,subtract:i,divide:a,multiply:o,partitionSelect:s,compare:c,isInteger:l,smaller:u,smallerEq:d,larger:f,mapSlices:p}=e,m=OL({typed:t,bignumber:n,add:r,subtract:i,divide:a,multiply:o,partitionSelect:s,compare:c,isInteger:l,smaller:u,smallerEq:d,larger:f,mapSlices:p});return t(`quantileSeq`,{"Array | Matrix, number | BigNumber":m,"Array | Matrix, number | BigNumber, number":(e,t,n)=>m(e,t,h(n)),"Array | Matrix, number | BigNumber, boolean":m,"Array | Matrix, number | BigNumber, boolean, number":(e,t,n,r)=>m(e,t,n,h(r)),"Array | Matrix, Array | Matrix":m,"Array | Matrix, Array | Matrix, number":(e,t,n)=>m(e,t,h(n)),"Array | Matrix, Array | Matrix, boolean":m,"Array | Matrix, Array | Matrix, boolean, number":(e,t,n,r)=>m(e,t,n,h(r))});function h(e){return AB([[],e])[1]}},{isTransformFunction:!0}),WB=`cumsum`,GB=Y(WB,[`typed`,`add`,`unaryPlus`],e=>{var{typed:t,add:n,unaryPlus:r}=e,i=_L({typed:t,add:n,unaryPlus:r});return t(WB,{"...any":function(e){if(e.length===2&&Py(e[0])){var t=e[1];Ty(t)?e[1]=t-1:Ey(t)&&(e[1]=t.minus(1))}try{return i.apply(null,e)}catch(e){throw YP(e)}}})},{isTransformFunction:!0}),KB=`variance`,qB=Y(KB,[`typed`,`add`,`subtract`,`multiply`,`divide`,`mapSlices`,`isNaN`],e=>{var{typed:t,add:n,subtract:r,multiply:i,divide:a,mapSlices:o,isNaN:s}=e,c=EL({typed:t,add:n,subtract:r,multiply:i,divide:a,mapSlices:o,isNaN:s});return t(KB,{"...any":function(e){e=AB(e);try{return c.apply(null,e)}catch(e){throw YP(e)}}})},{isTransformFunction:!0}),JB=`print`,YB=Y(JB,[`typed`,`matrix`,`zeros`,`add`],e=>{var{typed:t,matrix:n,zeros:r,add:i}=e,a=Sj({typed:t,matrix:n,zeros:r,add:i});return t(JB,{"string, Object | Array":function(e,t){return a(o(e),t)},"string, Object | Array, number | Object":function(e,t,n){return a(o(e),t,n)}});function o(e){return e.replace(bj,e=>`$`+e.slice(1).split(`.`).map(function(e){return!isNaN(e)&&e.length>0?parseInt(e)-1:e}).join(`.`))}},{isTransformFunction:!0}),XB=Y(`and`,[`typed`,`matrix`,`zeros`,`add`,`equalScalar`,`not`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o}=e,s=mM({typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o});function c(e,t,n){var r=e[0].compile().evaluate(n);return!Py(r)&&!s(r,!0)?!1:s(r,e[1].compile().evaluate(n))}return c.rawArgs=!0,c},{isTransformFunction:!0}),ZB=Y(`or`,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a}=e,o=Fk({typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a});function s(e,t,n){var r=e[0].compile().evaluate(n);return!Py(r)&&o(r,!1)?!0:o(r,e[1].compile().evaluate(n))}return s.rawArgs=!0,s},{isTransformFunction:!0}),QB=Y(`nullish`,[`typed`,`matrix`,`size`,`flatten`,`deepEqual`],e=>{var{typed:t,matrix:n,size:r,flatten:i,deepEqual:a}=e,o=Nk({typed:t,matrix:n,size:r,flatten:i,deepEqual:a});function s(e,t,n){var r=e[0].compile().evaluate(n);return!Py(r)&&r!=null&&r!==void 0?r:o(r,e[1].compile().evaluate(n))}return s.rawArgs=!0,s},{isTransformFunction:!0}),$B=Y(`bitAnd`,[`typed`,`matrix`,`zeros`,`add`,`equalScalar`,`not`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o}=e,s=mk({typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o});function c(e,t,n){var r=e[0].compile().evaluate(n);if(!Py(r)){if(isNaN(r))return NaN;if(r===0||r===!1)return 0}return s(r,e[1].compile().evaluate(n))}return c.rawArgs=!0,c},{isTransformFunction:!0}),eV=Y(`bitOr`,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a}=e,o=vk({typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a});function s(e,t,n){var r=e[0].compile().evaluate(n);if(!Py(r)){if(isNaN(r))return NaN;if(r===-1)return-1;if(r===!0)return 1}return o(r,e[1].compile().evaluate(n))}return s.rawArgs=!0,s},{isTransformFunction:!0}),tV=`num`,nV=Y(tV,[`typed`,`fraction`],e=>{var{typed:t,fraction:n}=e;return t(tV,{Fraction:e=>e.s*e.n,BigNumber:e=>{var t=n(e);return t.s*t.n},"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),rV=`den`,iV=Y(rV,[`typed`,`fraction`],e=>{var{typed:t,fraction:n}=e;return t(rV,{Fraction:e=>e.d,BigNumber:e=>n(e).d,"Array | Matrix":t.referToSelf(e=>t=>qw(t,e))})}),aV=s({createAbs:()=>jD,createAccessorNode:()=>QP,createAcos:()=>CN,createAcosh:()=>TN,createAcot:()=>DN,createAcoth:()=>kN,createAcsc:()=>jN,createAcsch:()=>NN,createAdd:()=>LP,createAddScalar:()=>LD,createAnd:()=>mM,createAndTransform:()=>XB,createArg:()=>Ck,createArrayNode:()=>eF,createAsec:()=>FN,createAsech:()=>LN,createAsin:()=>zN,createAsinh:()=>BN,createAssignmentNode:()=>lF,createAtan:()=>VN,createAtan2:()=>UN,createAtanh:()=>GN,createAtomicMass:()=>qz,createAvogadro:()=>Jz,createBellNumbers:()=>xR,createBernoulli:()=>PL,createBigNumberClass:()=>rC,createBigint:()=>cD,createBignumber:()=>pD,createBin:()=>hj,createBitAnd:()=>mk,createBitAndTransform:()=>$B,createBitNot:()=>gk,createBitOr:()=>vk,createBitOrTransform:()=>eV,createBitXor:()=>xk,createBlockNode:()=>dF,createBohrMagneton:()=>Dz,createBohrRadius:()=>Nz,createBoltzmann:()=>Yz,createBoolean:()=>fD,createCatalan:()=>CR,createCbrt:()=>VD,createCeil:()=>YD,createChain:()=>WI,createChainClass:()=>DI,createClassicalElectronRadius:()=>Pz,createClone:()=>Uw,createColumn:()=>Vk,createColumnTransform:()=>yB,createCombinations:()=>LL,createCombinationsWithRep:()=>BL,createCompare:()=>gM,createCompareNatural:()=>bM,createCompareText:()=>wM,createCompile:()=>GF,createComplex:()=>mD,createComplexClass:()=>fC,createComposition:()=>TR,createConcat:()=>zk,createConcatTransform:()=>LB,createConditionalNode:()=>pF,createConductanceQuantum:()=>Oz,createConj:()=>Tk,createConstantNode:()=>CF,createCorr:()=>ML,createCos:()=>JN,createCosh:()=>XN,createCot:()=>QN,createCoth:()=>eP,createCoulomb:()=>wz,createCoulombConstant:()=>Tz,createCount:()=>Uk,createCreateUnit:()=>xN,createCross:()=>Gk,createCsc:()=>nP,createCsch:()=>iP,createCtranspose:()=>zA,createCube:()=>ZD,createCumSum:()=>_L,createCumSumTransform:()=>GB,createDeepEqual:()=>UM,createDen:()=>iV,createDenseMatrixClass:()=>Vw,createDerivative:()=>VR,createDet:()=>KI,createDeuteronMass:()=>Bz,createDiag:()=>qk,createDiff:()=>uA,createDiffTransform:()=>zB,createDistance:()=>fL,createDivide:()=>uL,createDivideScalar:()=>Mj,createDot:()=>UP,createDotDivide:()=>Yj,createDotMultiply:()=>ik,createDotPow:()=>qj,createE:()=>iz,createEfimovFactor:()=>Kz,createEigs:()=>$I,createElectricConstant:()=>Sz,createElectronMass:()=>Fz,createElementaryCharge:()=>Ez,createEqual:()=>EM,createEqualScalar:()=>tD,createEqualText:()=>kM,createErf:()=>$A,createEvaluate:()=>qF,createExp:()=>$D,createExpm:()=>tL,createExpm1:()=>tO,createFactorial:()=>qL,createFalse:()=>QR,createFaraday:()=>Xz,createFermiCoupling:()=>Iz,createFft:()=>UA,createFibonacciHeapClass:()=>iN,createFilter:()=>Jk,createFilterTransform:()=>wB,createFineStructure:()=>Lz,createFirstRadiation:()=>Zz,createFix:()=>aO,createFlatten:()=>Zk,createFloor:()=>uO,createForEach:()=>$k,createForEachTransform:()=>TB,createFormat:()=>pj,createFraction:()=>hD,createFractionClass:()=>PC,createFreqz:()=>qR,createFunctionAssignmentNode:()=>TF,createFunctionNode:()=>VF,createGamma:()=>UL,createGasConstant:()=>$z,createGcd:()=>kO,createGetMatrixDataType:()=>nA,createGravitationConstant:()=>vz,createGravity:()=>cB,createHartreeEnergy:()=>Rz,createHasNumericValue:()=>zE,createHelp:()=>HI,createHelpClass:()=>EI,createHex:()=>yj,createHypot:()=>zP,createI:()=>fz,createIdentity:()=>iA,createIfft:()=>GA,createIm:()=>Dk,createImmutableDenseMatrixClass:()=>tN,createIndex:()=>KP,createIndexClass:()=>nN,createIndexNode:()=>DF,createIndexTransform:()=>EB,createInfinity:()=>ez,createIntersect:()=>pL,createInv:()=>JI,createInverseConductanceQuantum:()=>kz,createInvmod:()=>tk,createIsBounded:()=>qE,createIsFinite:()=>YE,createIsInteger:()=>Qw,createIsNaN:()=>GE,createIsNegative:()=>FE,createIsNumeric:()=>LE,createIsPositive:()=>VE,createIsPrime:()=>kj,createIsZero:()=>UE,createKldivergence:()=>YL,createKlitzing:()=>Mz,createKron:()=>oA,createLN10:()=>sz,createLN2:()=>oz,createLOG10E:()=>lz,createLOG2E:()=>cz,createLarger:()=>LM,createLargerEq:()=>BM,createLcm:()=>MO,createLeafCount:()=>DR,createLeftShift:()=>cM,createLgamma:()=>GL,createLog:()=>Vj,createLog10:()=>LO,createLog1p:()=>Uj,createLog2:()=>zO,createLoschmidt:()=>Qz,createLsolve:()=>Qj,createLsolveAll:()=>nM,createLup:()=>$F,createLusolve:()=>CI,createLyap:()=>lL,createMad:()=>CL,createMagneticConstant:()=>xz,createMagneticFluxQuantum:()=>Az,createMap:()=>cA,createMapSlices:()=>ND,createMapSlicesTransform:()=>vB,createMapTransform:()=>DB,createMatrix:()=>_D,createMatrixClass:()=>IC,createMatrixFromColumns:()=>CD,createMatrixFromFunction:()=>yD,createMatrixFromRows:()=>xD,createMax:()=>QM,createMaxTransform:()=>jB,createMean:()=>yL,createMeanTransform:()=>MB,createMedian:()=>xL,createMin:()=>eN,createMinTransform:()=>NB,createMod:()=>yO,createMode:()=>cj,createMolarMass:()=>oB,createMolarMassC12:()=>sB,createMolarPlanckConstant:()=>eB,createMolarVolume:()=>tB,createMultinomial:()=>ZL,createMultiply:()=>HO,createMultiplyScalar:()=>BO,createNaN:()=>tz,createNeutronMass:()=>Vz,createNode:()=>JP,createNorm:()=>VP,createNot:()=>jk,createNthRoot:()=>WO,createNthRoots:()=>Gj,createNuclearMagneton:()=>jz,createNull:()=>$R,createNullish:()=>Nk,createNullishTransform:()=>QB,createNum:()=>nV,createNumber:()=>sD,createNumeric:()=>Aj,createObjectNode:()=>kF,createOct:()=>_j,createOnes:()=>dA,createOperatorNode:()=>MF,createOr:()=>Fk,createOrTransform:()=>ZB,createParenthesisNode:()=>PF,createParse:()=>UF,createParser:()=>ZF,createParserClass:()=>JF,createPartitionSelect:()=>JM,createPermutations:()=>$L,createPhi:()=>az,createPi:()=>nz,createPickRandom:()=>fR,createPinv:()=>XI,createPlanckCharge:()=>fB,createPlanckConstant:()=>yz,createPlanckLength:()=>lB,createPlanckMass:()=>uB,createPlanckTemperature:()=>pB,createPlanckTime:()=>dB,createPolynomialRoot:()=>TI,createPow:()=>Pj,createPrint:()=>Sj,createPrintTransform:()=>YB,createProd:()=>dj,createProtonMass:()=>zz,createQr:()=>tI,createQuantileSeq:()=>OL,createQuantileSeqTransform:()=>UB,createQuantumOfCirculation:()=>Hz,createRandom:()=>hR,createRandomInt:()=>_R,createRange:()=>gA,createRangeClass:()=>FC,createRangeNode:()=>IF,createRangeTransform:()=>PB,createRationalize:()=>UR,createRe:()=>kk,createReducedPlanckConstant:()=>bz,createRelationalNode:()=>RF,createReplacer:()=>YR,createReshape:()=>vA,createResize:()=>yA,createResolve:()=>LR,createResultSet:()=>gx,createReviver:()=>JR,createRightArithShift:()=>uM,createRightLogShift:()=>fM,createRotate:()=>xA,createRotationMatrix:()=>CA,createRound:()=>Lj,createRow:()=>TA,createRowTransform:()=>FB,createRydberg:()=>Uz,createSQRT1_2:()=>uz,createSQRT2:()=>dz,createSackurTetrode:()=>nB,createSchur:()=>sL,createSec:()=>oP,createSech:()=>cP,createSecondRadiation:()=>rB,createSetCartesian:()=>_P,createSetDifference:()=>yP,createSetDistinct:()=>xP,createSetIntersect:()=>CP,createSetIsSubset:()=>TP,createSetMultiplicity:()=>DP,createSetPowerset:()=>kP,createSetSize:()=>jP,createSetSymDifference:()=>NP,createSetUnion:()=>FP,createSign:()=>KO,createSimplify:()=>NR,createSimplifyConstant:()=>PR,createSimplifyCore:()=>IR,createSin:()=>uP,createSinh:()=>fP,createSize:()=>DA,createSlu:()=>bI,createSmaller:()=>jM,createSmallerEq:()=>PM,createSolveODE:()=>QA,createSort:()=>XM,createSpaClass:()=>aN,createSparse:()=>yN,createSparseMatrixClass:()=>nD,createSpeedOfLight:()=>_z,createSplitUnit:()=>TD,createSqrt:()=>qO,createSqrtm:()=>rL,createSquare:()=>YO,createSqueeze:()=>kA,createStd:()=>AL,createStdTransform:()=>BB,createStefanBoltzmann:()=>iB,createStirlingS2:()=>yR,createString:()=>uD,createSubset:()=>jA,createSubsetTransform:()=>IB,createSubtract:()=>ZO,createSubtractScalar:()=>zD,createSum:()=>hL,createSumTransform:()=>HB,createSylvester:()=>aL,createSymbolNode:()=>zF,createSymbolicEqual:()=>zR,createTan:()=>mP,createTanh:()=>hP,createTau:()=>rz,createThomsonCrossSection:()=>Wz,createTo:()=>Tj,createToBest:()=>Dj,createTrace:()=>WP,createTranspose:()=>LA,createTrue:()=>ZR,createTypeOf:()=>ZE,createTyped:()=>dx,createUnaryMinus:()=>DD,createUnaryPlus:()=>kD,createUnequal:()=>GM,createUnitClass:()=>hN,createUnitFunction:()=>_N,createUppercaseE:()=>mz,createUppercasePi:()=>pz,createUsolve:()=>eM,createUsolveAll:()=>iM,createVacuumImpedance:()=>Cz,createVariance:()=>EL,createVarianceTransform:()=>qB,createVersion:()=>hz,createWeakMixingAngle:()=>Gz,createWienDisplacement:()=>aB,createXgcd:()=>$O,createXor:()=>Lk,createZeros:()=>VA,createZeta:()=>oj,createZpk2tf:()=>GR}),oV=l(o(((e,t)=>{function n(){}n.prototype={on:function(e,t,n){var r=this.e||={};return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function i(){r.off(e,i),t.apply(n,arguments)}return i._=t,this.on(e,i,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||={})[e]||[]).slice(),r=0,i=n.length;rr(e,t));else if(Gy(n)||d(n))for(var a in n)J(n,a)&&r(e,n[a],a);else if(jb(n)||i!==void 0){var o=jb(n)?h(n)?n.fn+`.transform`:n.fn:i;if(J(e,o)&&e[o]!==n&&!t.silent)throw Error(`Cannot import "`+o+`" twice`);e[o]=n}else if(!t.silent)throw TypeError(`Factory, Object, or Array expected`)}var i={};for(var o in r(i,e),i)if(J(i,o)){var s=i[o];if(jb(s))l(s,t);else if(u(s))a(o,s,t);else if(!t.silent)throw TypeError(`Factory, Object, or Array expected`)}}function a(t,i,a){if(a.wrap&&typeof i==`function`&&(i=c(i)),f(i)&&(i=e(t,{[i.signature]:i})),e.isTypedFunction(n[t])&&e.isTypedFunction(i)){i=a.override?e(t,i.signatures):e(n[t],i),n[t]=i,delete r[t],o(t,i),n.emit(`import`,t,function(){return i});return}var s=n[t]!==void 0,l=n.Unit?.isValuelessUnit(t);if(!s&&!l||a.override){n[t]=i,delete r[t],o(t,i),n.emit(`import`,t,function(){return i});return}if(!a.silent)throw Error(`Cannot import "`+t+`": already exists`)}function o(e,t){t&&typeof t.transform==`function`?(n.expression.transform[e]=t.transform,p(e)&&(n.expression.mathWithTransform[e]=t.transform)):(delete n.expression.transform[e],p(e)&&(n.expression.mathWithTransform[e]=t))}function s(e){delete n.expression.transform[e],p(e)?n.expression.mathWithTransform[e]=n[e]:delete n.expression.mathWithTransform[e]}function c(e){var t=function(){for(var t=[],r=0,i=arguments.length;r2&&arguments[2]!==void 0?arguments[2]:t.fn;if(a.includes(`.`))throw Error(`Factory name should not contain a nested path. Name: `+JSON.stringify(a));var o=h(t)?n.expression.transform:n,c=a in n.expression.transform,l=J(o,a)?o[a]:void 0,u=function(){var r={};t.dependencies.map(Pb).forEach(e=>{if(e.includes(`.`))throw Error(`Factory dependency should not contain a nested path. Name: `+JSON.stringify(e));e===`math`?r.math=n:e===`mathWithTransform`?r.mathWithTransform=n.expression.mathWithTransform:e===`classes`?r.classes=n:r[e]=n[e]});var o=t(r);if(o&&typeof o.transform==`function`)throw Error(`Transforms cannot be attached to factory functions. Please create a separate function for it with export const path = "expression.transform"`);if(l===void 0||i.override)return o;if(e.isTypedFunction(l)&&e.isTypedFunction(o))return e(l,o);if(i.silent)return l;throw Error(`Cannot import "`+a+`": already exists`)},d=t.meta?.formerly??``,f=h(t)||m(t),p=n.expression.mathWithTransform;!t.meta||t.meta.lazy!==!1?(Cb(o,a,u),d&&Cb(o,d,u),l&&c?(s(a),d&&s(d)):f&&(Cb(p,a,()=>o[a]),d&&Cb(p,d,()=>o[a]))):(o[a]=u(),d&&(o[d]=o[a]),l&&c?(s(a),d&&s(d)):f&&(Cb(p,a,()=>o[a]),d&&Cb(p,d,()=>o[a]))),r[a]=t,n.emit(`import`,a,u)}function u(e){return typeof e==`function`||typeof e==`number`||typeof e==`string`||typeof e==`boolean`||e===null||Ay(e)||Oy(e)||Ey(e)||ky(e)||Ny(e)||Array.isArray(e)}function d(e){return typeof e==`object`&&e[Symbol.toStringTag]===`Module`}function f(e){return typeof e==`function`&&typeof e.signature==`string`}function p(e){return!J(g,e)}function m(e){return!e.fn.includes(`.`)&&!J(g,e.fn)&&(!e.meta||!e.meta.isClass)}function h(e){return e!==void 0&&e.meta!==void 0&&e.meta.isTransformFunction===!0||!1}var g={expression:!0,type:!0,docs:!0,error:!0,json:!0,chain:!0};return i}function lV(e,t){var n=cy({},ly,t);if(typeof Object.create!=`function`)throw Error(`ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.`);var r=sV({isNumber:Ty,isComplex:Oy,isBigNumber:Ey,isBigInt:Dy,isFraction:ky,isUnit:Ay,isString:jy,isArray:My,isMatrix:Ny,isCollection:Py,isDenseMatrix:Fy,isSparseMatrix:Iy,isRange:Ly,isIndex:Ry,isBoolean:zy,isResultSet:By,isHelp:Vy,isFunction:Hy,isDate:Uy,isRegExp:Wy,isObject:Gy,isMap:Ky,isPartitionedMap:qy,isObjectWrappingMap:Jy,isNull:Yy,isUndefined:Xy,isAccessorNode:Zy,isArrayNode:Qy,isAssignmentNode:$y,isBlockNode:eb,isConditionalNode:tb,isConstantNode:nb,isFunctionAssignmentNode:ib,isFunctionNode:ab,isIndexNode:ob,isNode:sb,isObjectNode:cb,isOperatorNode:lb,isParenthesisNode:ub,isRangeNode:db,isRelationalNode:fb,isSymbolNode:pb,isChain:mb});r.config=Ob(n,r.emit),r.expression={transform:{},mathWithTransform:{config:r.config}};var i=[],a=[];function o(e){if(jb(e))return e(r);var t=e[Object.keys(e)[0]];if(jb(t))return t(r);if(!wb(e))throw console.warn("Factory object with properties `type`, `name`, and `factory` expected",e),Error("Factory object with properties `type`, `name`, and `factory` expected");var s=i.indexOf(e),c;return s===-1?(c=e.math===!0?e.factory(r.type,n,o,r.typed,r):e.factory(r.type,n,o,r.typed),i.push(e),a.push(c)):c=a[s],c}var s={};function c(){for(var e=arguments.length,t=Array(e),n=0;n{Object.values(s).forEach(e=>{e&&e.meta&&e.meta.recreateOnConfigChange&&l(e,{override:!0})})}),r.create=lV.bind(null,e),r.factory=Y,r.import(Object.values(xb(e))),r.ArgumentsError=CO,r.DimensionError=QC,r.IndexError=$C,r}function uV(){return lV(aV,{})}var dV=function(e){return e.DEV=`dev`,e.CANARY=`canary`,e.RELEASE=`release`,e}({}),fV=class{api;internal;file;inputFieldParser;viewFieldParser;jsViewFieldParser;buttonParser;bindTargetParser;dateParser;syntaxHighlighting;inputFieldFactory;viewFieldFactory;buttonActionRunner;buttonManager;metadataManager;mountableManager;domHelpers;math;build;constructor(){this.inputFieldParser=new Gv(this),this.viewFieldParser=new ty(this),this.jsViewFieldParser=new Kv(this),this.buttonParser=new mv(this),this.bindTargetParser=new Bu(this),this.dateParser=new hv(this),this.syntaxHighlighting=new It(this),this.inputFieldFactory=new eu(this),this.viewFieldFactory=new pu(this),this.buttonActionRunner=new wn(this),this.buttonManager=new Dn(this),this.metadataManager=new Iu,this.mountableManager=new Lu,this.math=uV(),this.build=`1.5.1`.includes(`canary`)?`canary`:`release`}setComponents(e){Object.assign(this,e)}setSettings(e){this.updateInternalSettings(e),this.saveSettings(e)}updateSettings(e){let t=this.getSettings();e(t),this.setSettings(t)}loadTemplates(){let e=this.getSettings(),t=this.inputFieldParser.parseTemplates(e.inputFieldTemplates);t.hasErrors()&&console.warn(`meta-bind | failed to parse input field templates`,t);let n=this.buttonManager.setButtonTemplates(e.buttonTemplates);n.hasErrors()&&console.warn(`meta-bind | failed to parse button templates`,n)}updateInternalSettings(e){ry(e.firstWeekday),this.loadTemplates()}destroy(){this.mountableManager.unload()}},pV=class{createElement(e,t,n){let r=e.ownerDocument.createElement(t);return n?.text&&(r.innerText=n.text),n?.class&&(r.className=n.class),e.appendChild(r),r}showUnloadedMessage(e,t){this.empty(e),this.removeAllClasses(e),this.createElement(e,`span`,{text:`[MB_UNLOADED] ${t}`,class:`mb-warning mb-unloaded`})}addClass(e,t){e.classList.add(...t.split(` `))}addClasses(e,t){e.classList.add(...t)}removeClass(e,t){e.classList.remove(...t.split(` `))}hasClass(e,t){return e.classList.contains(t)}removeAllClasses(e){e.className=``}empty(e){e.replaceChildren()}},mV=class{id;manager;cache;constructor(e,t){this.id=e,this.manager=t,this.cache=new Map}validateStoragePath(e,t,n,r){return r.validateStoragePathAsFilePath(e,n)}resolveBindTargetScope(e,t,n){return e}getOrCreateCacheItem(e){let t=this.getCacheItemForStoragePath(e);return t===void 0&&(t=this.getDefaultCacheItem(e),this.cache.set(e,t)),t}subscribe(e){if(e.bindTarget===void 0)throw new ve({errorLevel:z.CRITICAL,effect:`can not subscribe`,cause:`subscription bind target undefined`});let t=this.getOrCreateCacheItem(e.bindTarget.storagePath);return t.subscriptions.push(e),t}unsubscribe(e){if(e.bindTarget===void 0)throw new ve({errorLevel:z.CRITICAL,effect:`can not unsubscribe`,cause:`subscription bind target undefined`});let t=this.cache.get(e.bindTarget.storagePath);if(t===void 0)throw new ve({errorLevel:z.CRITICAL,effect:`can not unsubscribe`,cause:`cache item does not exist`});return t.subscriptions=t.subscriptions.filter(t=>t.uuid!==e.uuid),t}getCacheItemForStoragePath(e){return this.cache.get(e)}onCycle(e){}getCacheItems(){return Array.from(this.cache.values())}shouldDelete(e){return!0}deleteCache(e){this.cache.delete(e.storagePath)}writeCache(e,t){let n=this.getOrCreateCacheItem(t.storagePath);return Mu.setAndCreate(n.data,t.storageProp,e),n}writeEntireCache(e,t){t.data=e}readCache(e){if(e.storageType!==this.id)throw new ve({errorLevel:z.ERROR,effect:`can not read cache`,cause:`Source "${e.storageType}" does not match`});let t=this.getCacheItemForStoragePath(e.storagePath);return t===void 0?Mu.tryGet(this.readExternal(e.storagePath),e.storageProp):this.readCacheItem(t,e.storageProp)}readCacheItem(e,t){return Mu.tryGet(e.data,t)}readEntireCacheItem(e){return e.data}usesStoragePath(){return!0}},hV=class extends mV{readExternal(e){return{}}getDefaultCacheItem(e){return{data:{},storagePath:e,...this.manager.constructDefaultCacheItem()}}syncExternal(e){return Promise.resolve()}},gV=class{id;manager;cache;constructor(e,t){this.id=e,this.manager=t,this.cache={data:{},...this.manager.constructDefaultCacheItem()}}getOrCreateCacheItem(e){return this.cache}validateStoragePath(e,t,n,r){if(t)throw new Ae(z.ERROR,`Bind target validator`,`Failed to parse bind target. Bind target storage type 'global_memory' does not support a storage path.`,n,e.position);return``}deleteCache(e){}getCacheItemForStoragePath(e){return this.cache}getCacheItems(){return[this.cache]}onCycle(e){}readCache(e){return this.readCacheItem(this.cache,e.storageProp)}readCacheItem(e,t){return Mu.tryGet(e.data,t)}shouldDelete(e){return!1}subscribe(e){return this.cache.subscriptions.push(e),this.cache}syncExternal(e){return Promise.resolve()}unsubscribe(e){return this.cache.subscriptions=this.cache.subscriptions.filter(t=>t.uuid!==e.uuid),this.cache}writeCache(e,t){return Mu.setAndCreate(this.cache.data,t.storageProp,e),this.cache}writeEntireCache(e,t){t.data=e}readEntireCacheItem(e){return e.data}usesStoragePath(){return!1}},_V=class{id;manager;constructor(e,t){this.id=e,this.manager=t}getOrCreateCacheItem(e){throw new ve({errorLevel:z.CRITICAL,effect:`action not permitted`,cause:`source 'scope' should have no cache items or subscriptions`})}validateStoragePath(e,t,n,r){if(t)throw new Ae(z.ERROR,`Bind Target Validator`,`Failed to parse bind target. Bind target storage type 'scope' does not support a storage path.`,n,e.position);return``}deleteCache(e){}getCacheItemForStoragePath(e){}getCacheItems(){return[]}onCycle(e){}readCache(e){}readCacheItem(e,t){}shouldDelete(e){return!0}subscribe(e){throw new ve({errorLevel:z.CRITICAL,effect:`action not permitted`,cause:`source 'scope' should have no cache items or subscriptions`})}syncExternal(e){return Promise.resolve()}unsubscribe(e){throw new ve({errorLevel:z.CRITICAL,effect:`action not permitted`,cause:`source 'scope' should have no cache items or subscriptions`})}writeCache(e,t){throw new ve({errorLevel:z.CRITICAL,effect:`action not permitted`,cause:`source 'scope' should have no cache items or subscriptions`})}writeEntireCache(e,t){}readEntireCacheItem(e){throw new ve({errorLevel:z.CRITICAL,effect:`action not permitted`,cause:`source 'scope' should have no cache items or subscriptions`})}usesStoragePath(){return!1}};function vV(e){if(!e.getSettings().enableSyntaxHighlighting)return;window.CodeMirror.defineMode(`meta-bind-button`,e=>window.CodeMirror.getMode(e,`yaml`)),window.CodeMirror.defineMode(`meta-bind-js-view`,e=>window.CodeMirror.getMode(e,`javascript`));let t=/^\s*(```+|~~~+)/;window.CodeMirror.defineMode(`meta-bind`,n=>({startState:()=>({str:void 0,mdrcType:void 0,highlights:void 0,line:1}),token:(n,r)=>{if(r.str===void 0){let i=[n.string],a=1,o=n.lookAhead(a);for(;o!==void 0&&!t.test(o)&&(i.push(o),a+=1,o=n.lookAhead(a),!(a>100)););r.str=i.filter(e=>e.trim()!==``).join(` `);let s=e.api.isInlineFieldDeclarationAndGetType(r.str.trim());s===void 0?r.highlights=new Ft(r.str,[]):(r.fieldType=s,r.highlights=e.syntaxHighlighting.highlight(r.str,r.fieldType,!0))}let i=(r.highlights?.getHighlights().map(e=>({highlight:e,from:r.str?re(r.str,e.range.from):{line:1,column:1},to:r.str?re(r.str,e.range.to):{line:1,column:1}})).filter(e=>e.from.line===r.line))?.find(e=>e.from.column===n.pos+1);return i===void 0?(n.next(),n.eol()&&(r.line+=1),`line-HyperMD-codeblock`):(n.eatWhile(()=>i.to.line===r.line?n.pos+1=t&&r.from<=n)return!0;return!1}static checkRangeOverlap(e,t,n,r){return e<=r&&n<=t}static getContent(e,t,n){return e.sliceDoc(t,n)}static getCurrentFile(e){return e.state.field(f.editorInfoField).file}static existsDecorationBetween(e,t,n){let r=!1;return e.between(t,n,()=>{r=!0}),r}static existsDecorationOfTypeBetween(e,t,n,r){let i=!1;return e.between(n,r,(e,n,r)=>{r.spec.mb_widgetType===t&&(i=!0)}),i}};function xV(e){return d.ViewPlugin.fromClass(class{decorations;component;constructor(e){this.component=new f.Component,this.component.load(),this.decorations=this.renderWidgets(e)??d.Decoration.none,e.dom.addEventListener(`click`,e=>this.handleClick(e))}handleClick(e){if(e.target instanceof HTMLElement){let t=e.target;for(;t!==null;){if(t.classList.contains(`mb-input`)){e.stopPropagation();break}t=t.parentElement}}}isLivePreview(e){return e.field(f.editorLivePreviewField)}update(e){this.decorations=this.decorations.map(e.changes),this.updateWidgets(e.view)}updateWidgets(e){this.decorations=this.decorations.update({filter:(t,n,r)=>xu(e.visibleRanges,e=>bV.checkRangeOverlap(t,n,e.from,e.to))?!0:(r.spec.mb_unload?.(),!1)});for(let{from:t,to:n}of e.visibleRanges)(0,u.syntaxTree)(e.state).iterate({from:t,to:n,enter:t=>{let n=t.node,r=this.getRenderInfo(e,n);if(!r.data)return;if(!r.data.widgetType){this.removeDecoration(n);return}let i=r.data;r.shouldRender?(this.removeDecoration(n,yV.FIELD),this.addDecoration(n,e,yV.FIELD,i)):r.shouldHighlight?(this.removeDecoration(n),this.addDecoration(n,e,yV.HIGHLIGHT,i)):this.removeDecoration(n)}})}removeDecoration(e,t){this.decorations=this.decorations.update({filterFrom:e.from-1,filterTo:e.to+1,filter:(e,n,r)=>{let i=r.spec;return!!(!i.mb_widgetType||t&&i.mb_widgetType===t)}})}addDecoration(e,t,n,r){if(bV.existsDecorationOfTypeBetween(this.decorations,n,e.from,e.to))return;let i=bV.getCurrentFile(t);if(!i)return;let a=this.renderWidget(e,n,r,i),o=Array.isArray(a)?a:[a];o.length!==0&&(this.decorations=this.decorations.update({add:o}))}getRenderInfo(t,n){let r=new Set(n.type.name?.split(`_`));if(r.has(`inline-code`)&&!r.has(`formatting`)){let r=this.readNode(t,n.from,n.to);if(!r.trulyInline)return{shouldRender:!1,shouldHighlight:!1,data:void 0};let i=bV.checkSelectionOverlap(t.state.selection,n.from-1,n.to+1),a=this.isLivePreview(t.state),o=!i&&a;return{shouldRender:o,shouldHighlight:!o&&e.getSettings().enableSyntaxHighlighting,data:r}}return{shouldRender:!1,shouldHighlight:!1,data:void 0}}readNode(t,n,r){let i=!1;try{let e=bV.getContent(t.state,n-1,r+1);i=e.startsWith("`")&&e.endsWith("`")}catch{}let a=bV.getContent(t.state,n,r);return{content:a,widgetType:e.api.isInlineFieldDeclarationAndGetType(a),trulyInline:i}}renderWidgets(e){let t=bV.getCurrentFile(e);if(!t)return;let n=[];for(let r of e.visibleRanges)(0,u.syntaxTree)(e.state).iterate({from:r.from,to:r.to,enter:r=>{let i=r.node,a=this.getRenderInfo(e,i);if(!a.data?.widgetType)return;let o=a.data,s;a.shouldRender?s=this.renderWidget(i,yV.FIELD,o,t):a.shouldHighlight&&(s=this.renderWidget(i,yV.HIGHLIGHT,o,t)),s&&(Array.isArray(s)?n.push(...s):n.push(s))}});return d.Decoration.set(n,!0)}renderWidget(t,n,r,i){if(n===yV.FIELD){let n=e.api.constructMDRCWidget(r.widgetType,r.content,i.path,this.component);return d.Decoration.replace({widget:n,mb_widgetType:yV.FIELD,mb_unload:()=>{n.renderChild?.unload()}}).range(t.from-1,t.to+1)}else return e.syntaxHighlighting.highlight(r.content,r.widgetType,!1).getHighlights().map(e=>d.Decoration.mark({class:`mb-highlight-${e.tokenClass}`,mb_widgetType:yV.HIGHLIGHT}).range(t.from+e.range.from,t.from+e.range.to))}destroy(){this.component.unload()}},{decorations:e=>e.decorations})}var SV=P.sequenceMap((e,t,n,r)=>new CV(parseInt(e),parseInt(t),parseInt(n),r),R.digits().skip(P.string(`.`)),R.digits().skip(P.string(`.`)),R.digits(),P.string(`-`).then(R.remaining()).optional()),CV=class e{major;minor;patch;prerelease;constructor(e,t,n,r){this.major=e,this.minor=t,this.patch=n,this.prerelease=r}static fromString(e){return Oe(SV,e)}static lessThan(e,t){return e.majort.major?!1:e.minort.minor?!1:e.patcht.patch||e.prerelease===void 0?!1:t.prerelease===void 0?!0:e.prereleaset.pluginId===e);if(t===void 0)throw new De({errorLevel:z.CRITICAL,effect:`Dependency violation detected`,cause:`Attempted to access dependency ${e} which is not a listed dependency. Please report this error.`});return t}getPlugin(e){return this.mb.app.plugins.getPlugin(e)}throwPluginNotFound(e){this.throwDependencyError(`Plugin ${e} is required, but not installed. Please install the plugin.`)}throwDependencyError(e){throw new f.Notice(`meta-bind | Dependency Error: ${e}`,0),new De({errorLevel:z.ERROR,effect:`Dependency violation detected`,cause:e})}checkDependencyVersion(e,t){CV.lessThan(t,e.minVersion)&&this.throwDependencyError(`Plugin ${e.pluginId} is outdated. Required version is at least ${e.minVersion.toString()}, installed version is ${t.toString()}. Please update the plugin.`),e.maxVersion!==void 0&&(CV.greaterThan(t,e.maxVersion)||CV.equals(t,e.maxVersion))&&this.throwDependencyError(`Plugin ${e.pluginId} is too new. Required version is lower than ${e.maxVersion.toString()}, installed version is ${t.toString()}. Please downgrade the plugin.`)}checkDependency(e){let t=this.getDependency(e),n=this.getPlugin(e);if(n==null)throw this.throwPluginNotFound(e),Error(`unreachable`);let r=CV.fromString(n.manifest.version);return this.checkDependencyVersion(t,r),n}},TV={date:`date`,datePicker:`datePicker`,dateTime:`dateTime`,editor:`editor`,imageSuggester:`imageSuggester(optionQuery(""))`,imageListSuggester:`imageListSuggester(optionQuery(""))`,inlineList:`inlineList`,inlineListSuggester:`inlineListSuggester(option(apple), option(banana), option(lemon))`,inlineSelect:`inlineSelect(option(apple), option(banana), option(lemon))`,list:`list`,listSuggester:`listSuggester(option(apple), option(banana), option(lemon))`,multiSelect:`multiSelect(option(apple), option(banana), option(lemon))`,number:`number`,progressBar:`progressBar`,select:`select(option(apple), option(banana), option(lemon))`,slider:`slider(addLabels)`,suggester:`suggester(option(apple), option(banana), option(lemon))`,text:`text`,textArea:`textArea`,time:`time`,toggle:`toggle`,invalid:``},EV={image:[{title:`Image`,declaration:`VIEW[{globalMemory^MB_VF_image_example}][image]`,display:`VIEW[{imageExampleProperty}][image]`,inputField:`INPUT[imageSuggester(optionQuery("")):globalMemory^MB_VF_image_example]`}],link:[{title:`Link`,declaration:`VIEW[{globalMemory^MB_VF_link_example}][link]`,display:`VIEW[{linkExampleProperty}][link]`,inputField:`INPUT[suggester(optionQuery("")):globalMemory^MB_VF_link_example]`}],math:[{title:`Math`,declaration:`VIEW[{globalMemory^MB_VF_math_example} + 2][math]`,display:`VIEW[{mathExampleProperty} + 2][math]`,inputField:`INPUT[number:globalMemory^MB_VF_math_example]`}],text:[{title:`Text`,declaration:`VIEW[some text {globalMemory^MB_VF_text_example}][text]`,display:`VIEW[some text {textExampleProperty}][text]`,inputField:`INPUT[text:globalMemory^MB_VF_text_example]`},{title:`Markdown`,declaration:`VIEW[**some markdown** {globalMemory^MB_VF_text_markdown_example}][text(renderMarkdown)]`,display:`VIEW[**some markdown** {markdownExampleProperty}][text(renderMarkdown)]`,inputField:`INPUT[text:globalMemory^MB_VF_text_markdown_example]`}],invalid:[]};function DV(e){let t=[];for(let[n,r]of Object.entries(TV)){if(r===``)continue;let i=e.inputFieldParser.fromString(`INPUT[${r}]`),a=e.inputFieldParser.fromSimpleDeclaration({inputFieldType:void 0,templateName:void 0,bindTarget:void 0,arguments:[{name:kn.SHOWCASE,value:[`true`]},{name:kn.TITLE,value:[n]}]});i=e.inputFieldParser.merge(i,a),i.declarationString=`INPUT[${r}]`;let o=e.inputFieldParser.validate(i,``,void 0);t.push([n,o])}return t}function OV(e){let t=[];for(let[e,n]of Object.entries(TV)){if(n===``)continue;let r=e,i;i=An[r].allowInline?`\`INPUT[${n}:exampleProperty]\``:`\n\`\`\`meta-bind\nINPUT[${n}:exampleProperty]\n\`\`\`\n`,t.push([r,i])}return t.sort((e,t)=>e[0].localeCompare(t[0])),t}function kV(e){let t=[];for(let e of Object.values(EV))for(let n of e)t.push([n.title,`\`${n.display}\``]);return t.sort((e,t)=>e[0].localeCompare(t[0])),t}function AV(e,t,n){let r=OV(n),i=kV(n);e.addItem(e=>{e.setTitle(`Meta Bind`),e.setIcon(`blocks`);let a=e.setSubmenu();a.addItem(e=>{e.setTitle(`Input field`);let n=e.setSubmenu();for(let[e,i]of r)n.addItem(n=>{n.setTitle(e),n.onClick(()=>jV(t,i))})}),a.addItem(e=>{e.setTitle(`View field`);let n=e.setSubmenu();for(let[e,r]of i)n.addItem(n=>{n.setTitle(e),n.onClick(()=>jV(t,r))})}),a.addItem(e=>{e.setTitle(`Inline button`),e.onClick(()=>{jV(t,"`BUTTON[example-id]`")})}),a.addItem(e=>{e.setTitle(`Button`),e.onClick(()=>{n.internal.openButtonBuilderModal({onOkay:e=>{jV(t,`\`\`\`meta-bind-button\n${(0,f.stringifyYaml)(e)}\n\`\`\``)},submitText:`Insert`})})})})}function jV(e,t){e.replaceSelection(t)}var MV=class extends sc{mb;filePath;uuid;constructor(e,t,n){super(),this.mb=e,this.filePath=n,this.uuid=t}getUuid(){return this.uuid}getFilePath(){return this.filePath}onMount(e){this.mb.mountableManager.registerMountable(this)}onUnmount(e){this.mb.mountableManager.unregisterMountable(this)}},NV=class{scope;constructor(e){this.scope=e}},PV=R_()(hg()),FV=R_()(s_(fe)),IV=R_()(s_(pe)),LV=R_()(s_(On)),RV=R_()(Ug()),zV=R_()(P_(NV));R_()(P_(lc)),R_()(I_()),R_()(P_(MV));var BV=R_()(P_(sc)),VV=R_()(P_(me)),HV=R_()(Zg({from:Lg(),to:Lg()})),UV=R_()(Zg({value:hg(),position:HV.optional()})),WV=R_()(Zg({name:UV,value:UV.array()})),GV=R_()(Zg({type:s_(Be),prop:UV})),KV=R_()(Zg({storageType:UV.optional(),storagePath:UV.optional(),storageProp:GV.array(),listenToChildren:Vg()}));R_()(Zg({declarationString:hg().optional(),inputFieldType:UV.optional(),templateName:UV.optional(),bindTarget:KV.optional(),arguments:WV.array(),errorCollection:P_(Tn)})),R_()(Zg({declarationString:hg().optional(),templateDeclaration:Yg($g([hg(),KV])).optional(),viewFieldType:UV.optional(),arguments:WV.array(),writeToBindTarget:KV.optional(),errorCollection:P_(Tn)}));var qV=R_()(Zg({storageType:hg(),storagePath:hg(),storageProp:P_(zu),listenToChildren:Vg()})),JV=R_()(Zg({name:hg(),value:hg().array()}));R_()(Zg({type:s_(Be),prop:hg()}));var YV=R_()(Zg({inputFieldType:LV.optional(),templateName:hg().optional(),bindTarget:qV.optional(),arguments:JV.array().optional()})),XV=R_()(Zg({viewFieldType:LV.optional(),templateDeclaration:$g([hg(),qV]).array().optional(),arguments:JV.array().optional(),writeToBindTarget:qV.optional()})),ZV=R_()(Zg({bindTarget:qV,name:hg()})),QV=R_()(Zg({bindTargetMappings:ZV.array(),writeToBindTarget:qV.optional(),code:hg()})),$V=R_()(Zg({referencedButtonIds:hg().array()})),eH=R_()(Zg({renderChildType:FV,declaration:$g([hg(),YV]),scope:zV.optional()})),tH=R_()(Zg({renderChildType:FV,declaration:$g([hg(),XV]),scope:zV.optional()})),nH=R_()(Zg({declaration:$g([hg(),QV])})),rH=R_()(Zg({bindTarget:qV,tableHead:hg().array(),columns:Yg($g([YV,XV,hg()]))})),iH=R_()(Zg({renderChildType:FV,declaration:$g([hg(),$V]),position:VV.optional()})),aH=R_()(Zg({declaration:$g([hg(),fv]),position:VV.optional(),isPreview:Vg()})),oH=R_()(Zg({depth:Lg(),content:hg()})),sH=G(``);function cH(e,t){ii(t,!0);let n=nc(t,`variant`,19,()=>Lt.DEFAULT),r=nc(t,`disabled`,7,!1),i=nc(t,`tooltip`,3,``),a=nc(t,`label`,3,``),o=nc(t,`icon`,3,``),s=nc(t,`cssStyle`,3,``),c=nc(t,`backgroundImage`,3,``),l=nc(t,`error`,3,!1),u=nc(t,`onclick`,3,()=>{}),d=nc(t,`onauxclick`,3,()=>{});async function f(e,n){if(!r()){r(!0);try{n===zt.LEFT?await u()(e):n===zt.MIDDLE&&await d()(e)}catch(e){console.warn(`failed to run button component on click`,e),t.mb.internal.showNotice(`meta-bind | Error while running button action. Check the console for details.`)}finally{r(!1)}}}var p=sH();let m,h;var g=H(p),_=e=>{gc(e,{get mb(){return t.mb},get iconName(){return o()}})};ps(g,e=>{o()&&e(_)});var v=U(g);V(p),Xa(()=>{m=Ns(p,1,`mb-button-inner`,null,m,{"mod-cta":n()===Lt.PRIMARY,"mod-warning":n()===Lt.DESTRUCTIVE,"mod-plain":n()===Lt.PLAIN,disabled:r(),"mb-error":l()}),h=Fs(p,s(),h,{"background-image":c()?`url("${c()}")`:void 0}),qs(p,`aria-label`,i()),p.disabled=r(),os(v,` ${a()??``}`)}),Jo(`click`,p,e=>f(e,zt.LEFT)),qo(`auxclick`,p,e=>f(e,zt.MIDDLE)),K(e,p),ai()}Yo([`click`]);var lH=class extends sc{mb;config;filePath;isInline;position;buttonComponent;isInGroup;isPreview;constructor(e,t,n,r,i,a,o){super(),this.mb=e,this.config=t,this.filePath=n,this.isInline=r===fe.INLINE,this.position=i,this.isInGroup=a,this.isPreview=o}onMount(e){this.mb.domHelpers.empty(e),this.mb.domHelpers.removeAllClasses(e),this.mb.domHelpers.addClasses(e,[`mb-button`,this.isInline?`mb-button-inline`:`mb-button-block`]),!(!this.isInline&&!this.isPreview&&!this.isInGroup&&(this.config.id&&this.mb.buttonManager.addButton(this.filePath,this.config),this.config.hidden))&&(this.config.class&&this.mb.domHelpers.addClasses(e,this.config.class.split(` `).filter(e=>e!==``)),this.buttonComponent=ss(cH,{target:e,props:{mb:this.mb,icon:this.config.icon,variant:this.config.style,label:this.config.label,tooltip:w(this.config.tooltip)?this.config.tooltip:void 0,cssStyle:this.config.cssStyle,backgroundImage:w(this.config.backgroundImage)?this.mb.internal.imagePathToUri(this.config.backgroundImage):void 0,onclick:async e=>{await this.mb.buttonActionRunner.runButtonActions(this.config,this.filePath,this.getContext(),Rt.fromMouseEvent(e,zt.LEFT))},onauxclick:async e=>{await this.mb.buttonActionRunner.runButtonActions(this.config,this.filePath,this.getContext(),Rt.fromMouseEvent(e,zt.MIDDLE))}}}))}getContext(){return{position:this.position?.getPosition(),isInGroup:this.isInGroup,isInline:this.isInline}}onUnmount(){this.buttonComponent&&ds(this.buttonComponent),!this.isInline&&!this.isPreview&&this.config?.id&&this.mb.buttonManager.removeButton(this.filePath,this.config.id)}},uH=class extends sc{mb;referencedIds;filePath;renderChildType;notePosition;constructor(e,t,n,r,i){super(),this.mb=e,this.referencedIds=t,this.filePath=n,this.renderChildType=r,this.notePosition=i}renderInitialButton(e,t){return this.mb.domHelpers.removeAllClasses(e),this.mb.domHelpers.addClasses(e,[`mb-button`,this.renderChildType===fe.INLINE?`mb-button-inline`:`mb-button-block`]),ss(cH,{target:e,props:{mb:this.mb,variant:Lt.DEFAULT,label:`Button ID not Found`,tooltip:`No button with id '${t}' found`,error:!0,onclick:async()=>{}}})}onMount(e){this.mb.domHelpers.empty(e),this.mb.domHelpers.addClasses(e,[`mb-button-group`,this.renderChildType===fe.INLINE?`mb-button-group-inline`:`mb-button-group-block`]);for(let t of this.referencedIds){let n=this.mb.domHelpers.createElement(e,`span`),r=this.renderInitialButton(n,t),i,a=this.mb.buttonManager.registerButtonLoadListener(this.filePath,t,e=>{r&&ds(r),r=void 0,i=new lH(this.mb,e,this.filePath,this.renderChildType,this.notePosition,!0,!1),i.mount(n)});this.registerUnmountCb(()=>{r&&ds(r),r=void 0,i?.unmount(),a()})}}onUnmount(e){this.mb.domHelpers.empty(e)}},dH=class extends MV{errorCollection;declaration;buttonField;renderChildType;position;constructor(e,t,n,r,i,a){super(e,t,n),this.declaration=r,this.errorCollection=new Tn(this.getUuid()),this.errorCollection.merge(r.errorCollection),this.renderChildType=i,this.position=a}onMount(e){if(super.onMount(e),this.mb.domHelpers.removeAllClasses(e),this.declaration.errorCollection.isEmpty())try{this.buttonField=new uH(this.mb,this.declaration.referencedButtonIds,this.getFilePath(),this.renderChildType,this.position),this.buttonField.mount(e)}catch(t){this.errorCollection.add(t),this.renderErrorIndicator(e)}else this.renderErrorIndicator(e)}renderErrorIndicator(e){this.mb.internal.createErrorIndicator(e,{errorCollection:this.errorCollection,errorText:`Errors caused the creation of the field to fail. Sometimes one error only occurs because of another.`,warningText:`Warnings will not cause the creation of a field to fail, but they indicate that a part of the declaration was invalid or uses deprecated functionality.`,code:this.declaration.declarationString})}onUnmount(e){super.onUnmount(e),this.buttonField?.unmount(),this.mb.domHelpers.showUnloadedMessage(e,`inline button`)}},fH=class extends MV{errorCollection;declaration;position;buttonField;isPreview;constructor(e,t,n,r,i,a){super(e,t,n),this.declaration=r,this.position=i,this.isPreview=a,this.errorCollection=new Tn(this.getUuid()),this.errorCollection.merge(r.errorCollection)}onMount(e){if(super.onMount(e),this.mb.domHelpers.removeAllClasses(e),this.declaration.config&&this.declaration.errorCollection.isEmpty())try{this.buttonField=new lH(this.mb,this.declaration.config,this.getFilePath(),fe.BLOCK,this.position,!1,this.isPreview),this.buttonField.mount(e)}catch(t){this.errorCollection.add(t),this.renderErrorIndicator(e)}else this.renderErrorIndicator(e)}renderErrorIndicator(e){this.mb.internal.createErrorIndicator(e,{errorCollection:this.errorCollection,errorText:`Errors caused the creation of the field to fail. Sometimes one error only occurs because of another.`,warningText:`Warnings will not cause the creation of a field to fail, but they indicate that a part of the declaration was invalid or uses deprecated functionality.`,code:this.declaration.declarationString})}onUnmount(e){super.onUnmount(e),this.buttonField?.unmount(),this.mb.domHelpers.showUnloadedMessage(e,`button`)}},pH=class extends MV{depth;content;markdownUnloadCallback;constructor(e,t,n,r,i){super(e,t,n),this.depth=r,this.content=i}async parseContent(){let e=this.content.split(` `).map(e=>e.trim()).filter(e=>e.length>0);if(e.length===0)return{content:``};if(e.length>1)return{error:`Embed may only contain one link`};let t=e[0],n=rn.parseLink(t);if(!n.internal)return{error:`${t} is not an internal link`};let r=this.mb.file.getPathByName(n.target,this.getFilePath());return r===void 0?{error:`"${n.target}" is not created yet`}:{content:await this.mb.file.read(r)}}exceedsMaxDepth(){return this.depth>8}createEmbedMessage(e,t){this.mb.domHelpers.createElement(e,`span`,{text:t,class:`mb-embed-message`})}async renderContent(e){try{if(this.exceedsMaxDepth()){this.createEmbedMessage(e,`Max embed depth exceeded`);return}let t=await this.parseContent();if(t.error){this.createEmbedMessage(e,t.error);return}if(t.content===void 0){this.createEmbedMessage(e,`Embed content not found`);return}let n=t.content.replace(/(```+|~~~+)meta-bind-embed.*/g,`$1meta-bind-embed-internal-${this.depth+1}`);this.markdownUnloadCallback=await this.mb.internal.renderMarkdown(n,e,this.getFilePath())}catch(t){let n=new Tn(`Embed`);n.add(t),this.mb.internal.createErrorIndicator(e,{errorCollection:n})}}onMount(e){super.onMount(e),this.mb.domHelpers.addClass(e,`mb-embed`),this.renderContent(e)}onUnmount(e){super.onUnmount(e),this.mb.domHelpers.removeClass(e,`mb-embed`),this.markdownUnloadCallback?.(),this.mb.domHelpers.showUnloadedMessage(e,`Embed`)}},mH=class extends MV{constructor(e,t,n){super(e,t,n)}onMount(e){super.onMount(e),this.mb.domHelpers.empty(e),this.mb.domHelpers.createElement(e,`span`,{text:`[META_BIND] This folder has been excluded in the settings`,class:`mb-error`})}onUnmount(e){super.onUnmount(e),this.mb.domHelpers.empty(e),this.mb.domHelpers.showUnloadedMessage(e,`Excluded`)}},hH=class extends MV{renderChildType;errorCollection;inputField;declarationString;declaration;constructor(e,t,n,r,i){super(e,t,n),this.renderChildType=r,this.declaration=i,this.declarationString=i.declarationString,this.errorCollection=new Tn(this.getUuid()),this.errorCollection.merge(i.errorCollection)}hasArgument(e){return this.getArguments(e).length>0}getArgument(e){return this.getArguments(e).at(0)}getArguments(e){if(this.declaration.errorCollection.hasErrors())throw new ve({errorLevel:z.CRITICAL,effect:`can not retrieve arguments`,cause:`inputFieldDeclaration has errors`});return this.declaration.argumentContainer.getAll(e)}getBindTarget(){return this.declaration.bindTarget}shouldAddCardContainer(){let e=this.declaration.inputFieldType===On.SELECT||this.declaration.inputFieldType===On.MULTI_SELECT||this.declaration.inputFieldType===On.LIST,t=this.hasArgument(kn.SHOWCASE)||this.hasArgument(kn.TITLE);return this.renderChildType===fe.BLOCK&&(e||t)}createContainer(e){if(this.shouldAddCardContainer()){let t=this.mb.domHelpers.createElement(e,`div`);this.mb.domHelpers.addClass(t,`mb-card`);let n=this.getArgument(kn.TITLE);return n&&this.mb.domHelpers.createElement(t,`h3`,{text:n.value}),t}return e}addShowcase(e){if(this.getArgument(kn.SHOWCASE)&&this.shouldAddCardContainer()){let t=this.mb.domHelpers.createElement(e,`code`,{class:`mb-none`}),n=this.mb.domHelpers.createElement(t,`a`,{text:this.declarationString,class:`mb-no-link`});n.href=$l.linkToInputField(this.declaration.inputFieldType)}}createInputField(){if(!this.errorCollection.hasErrors())try{this.inputField=this.mb.inputFieldFactory.createInputField(this)}catch(e){this.errorCollection.add(e)}!this.errorCollection.hasErrors()&&!this.inputField&&this.errorCollection.add(new ve({errorLevel:z.CRITICAL,effect:`can't render input field`,cause:`input field is undefined`}))}createErrorIndicator(e){this.mb.internal.createErrorIndicator(e,{errorCollection:this.errorCollection,errorText:`Errors caused the creation of the field to fail. Sometimes one error only occurs because of another.`,warningText:`Warnings will not cause the creation of a field to fail, but they indicate that a part of the declaration was invalid or uses deprecated functionality.`,code:this.declarationString})}onMount(e){if(super.onMount(e),this.mb.domHelpers.empty(e),this.mb.domHelpers.addClass(e,`mb-input`),this.createInputField(),this.errorCollection.hasErrors()){this.createErrorIndicator(e);return}let t=this.createContainer(e);this.createErrorIndicator(t);let n=this.mb.domHelpers.createElement(t,`div`,{class:`mb-input-wrapper`});this.inputField?.mount(n);let r=this.getArguments(kn.CLASS);for(let e of r)this.mb.domHelpers.addClasses(n,e.value);this.mb.domHelpers.addClass(n,`mb-input-type-${this.declaration.inputFieldType}`),this.renderChildType===fe.BLOCK?this.mb.domHelpers.addClass(e,`mb-input-block`):this.mb.domHelpers.addClass(e,`mb-input-inline`),this.addShowcase(t)}onUnmount(e){super.onUnmount(e),this.inputField?.unmount(),this.mb.domHelpers.showUnloadedMessage(e,`input field`)}};function gH(e){return new zu(e.map(e=>Yt.tryParse(e).success?new We(Be.ARRAY,e):new We(Be.OBJECT,e)))}var _H=G(`
`);function vH(e,t){ii(t,!0);let n,r;Wa(()=>{r?.unmount(),r=t.mountable,r.mount(n)}),ic(()=>{r?.unmount()});var i=_H();tc(i,e=>n=e,()=>n),K(e,i),ai()}var yH=G(` `),bH=G(``),xH=G(`invalid data`),SH=G(``),CH=G(`
`,1);function wH(e,t){ii(t,!0);let n=nc(t,`tableHead`,19,()=>[]),r=da(va([]));function i(e){pa(r,e,!0)}var a={updateTable:i},o=CH(),s=ka(o),c=H(s),l=H(c),u=H(l);vs(H(u),17,n,ms,(e,t)=>{var n=yH(),r=H(n,!0);V(n),Xa(()=>os(r,W(t))),K(e,n)}),Gr(),V(u),V(l);var d=U(l);return vs(d,21,()=>W(r),e=>e.index,(e,r)=>{var i=SH(),a=H(i),o=e=>{var t=as();vs(ka(t),17,()=>W(r).cells,ms,(e,t)=>{var n=bH();vH(H(n),{get mountable(){return W(t)}}),V(n),K(e,n)}),K(e,t)},s=e=>{var t=xH();Xa(()=>qs(t,`colspan`,n().length)),K(e,t)};ps(a,e=>{W(r).isValid?e(o):e(s,-1)});var c=U(a);Ac(H(c),{onclick:()=>t.table.removeColumn(W(r).index),children:(e,n)=>{gc(e,{get mb(){return t.table.mb},iconName:`x`})},$$slots:{default:!0}}),V(c),V(i),K(e,i)}),V(d),V(c),V(s),Ac(U(s,2),{onclick:()=>t.table.addColumn(),children:(e,t)=>{Gr(),K(e,is(`Add Row`))},$$slots:{default:!0}}),K(e,o),ai(a)}var TH=class extends MV{bindTarget;tableHead;columns;tableComponent;inputSignal;metadataSubscription;constructor(e,t,n,r,i,a){super(e,t,n),this.bindTarget=r,this.tableHead=i,this.columns=a,this.inputSignal=new lc(void 0)}registerSelfToMetadataManager(){this.metadataSubscription=this.mb.metadataManager.subscribe(this.getUuid(),this.inputSignal,this.bindTarget,()=>this.unmount())}unregisterSelfFromMetadataManager(){this.metadataSubscription?.unsubscribe()}updateMetadataManager(e){this.metadataSubscription?.write(e)}getValue(){return this.parseTableData(this.metadataSubscription?.read())}parseTableData(e){return Array.isArray(e)?e:[]}updateDisplayValue(e){e??=[];let t=[];for(let n=0;n{if(typeof e==`string`)return this.mb.api.createInlineFieldFromString(e,this.getFilePath(),r,fe.INLINE);if(`inputFieldType`in e)return this.mb.api.createInputFieldMountable(this.getFilePath(),{declaration:e,scope:r,renderChildType:fe.INLINE});if(`viewFieldType`in e)return this.mb.api.createViewFieldMountable(this.getFilePath(),{declaration:e,scope:r,renderChildType:fe.INLINE});throw Error(`Unknown column type: ${JSON.stringify(e)}`)});t.push({cells:i,index:n,value:e[n],isValid:!0})}else t.push({cells:[],index:n,value:e[n],isValid:!1});this.tableComponent?.updateTable(t)}removeColumn(e){let t=this.getValue();t.splice(e,1),this.updateDisplayValue(t),this.updateMetadataManager(t)}addColumn(){let e=this.getValue();e.push({}),this.updateDisplayValue(e),this.updateMetadataManager(e)}onMount(e){super.onMount(e),this.tableComponent=ss(wH,{target:e,props:{table:this,tableHead:this.tableHead}}),this.inputSignal.registerListener({callback:e=>{this.updateDisplayValue(this.parseTableData(e))}}),this.registerSelfToMetadataManager()}onUnmount(e){super.onUnmount(e),this.unregisterSelfFromMetadataManager(),this.tableComponent&&ds(this.tableComponent),this.mb.domHelpers.showUnloadedMessage(e,`table`)}},EH=class extends MV{errorCollection;declarationString;declaration;variables;metadataSubscription;jsRenderer;constructor(e,t,n,r){super(e,t,n),this.declaration=r,this.declarationString=r.declarationString,this.errorCollection=new Tn(this.getUuid()),this.errorCollection.merge(r.errorCollection),this.variables=[],this.buildVariables()}buildVariables(){if(this.errorCollection.isEmpty())try{for(let e of this.declaration.bindTargetMappings??[])this.variables.push({bindTargetDeclaration:e.bindTarget,metadataSignal:new lc(void 0),uuid:E(),contextName:e.name})}catch(e){this.errorCollection.add(e)}}buildContext(){let e={};for(let t of this.variables??[])!t.contextName||!t.metadataSignal||(e[t.contextName]=t.metadataSignal.get());return e}async evaluate(){return this.jsRenderer?.evaluate({bound:this.buildContext()})}registerSelfToMetadataManager(){this.metadataSubscription=this.mb.metadataManager.subscribeDerived(this.getUuid(),this.declaration.writeToBindTarget,this.variables.map(e=>e.bindTargetDeclaration),this.variables.map(e=>e.metadataSignal),async()=>await this.evaluate(),()=>this.unmount())}unregisterSelfFromMetadataManager(){this.metadataSubscription?.unsubscribe()}createErrorIndicator(e){this.mb.internal.createErrorIndicator(e,{errorCollection:this.errorCollection,errorText:`Errors caused the creation of the field to fail. Sometimes one error only occurs because of another.`,warningText:`Warnings will not cause the creation of a field to fail, but they indicate that a part of the declaration was invalid or uses deprecated functionality.`,code:this.declarationString})}onMount(e){if(super.onMount(e),this.mb.domHelpers.addClass(e,`mb-view`),this.mb.domHelpers.empty(e),this.mb.internal.isJsEngineAvailable()||this.errorCollection.add(new Ce({errorLevel:z.ERROR,effect:`can not create js view field`,cause:`The JS Engine plugin is not installed and enabled.`})),this.mb.getSettings().enableJs||this.errorCollection.add(new Ce({errorLevel:z.CRITICAL,effect:`Can't evaluate expression.`,cause:`JS evaluation is disabled in the plugin settings.`})),this.createErrorIndicator(e),this.errorCollection.hasErrors())return;let t=this.mb.domHelpers.createElement(e,`div`);this.mb.domHelpers.addClass(t,`mb-view-wrapper`),this.mb.domHelpers.addClass(e,`mb-view-rendered`),this.jsRenderer=this.mb.internal.createJsRenderer(t,this.getFilePath(),this.declaration.code,this.declaration.hidden),this.registerSelfToMetadataManager()}onUnmount(e){super.onUnmount(e),this.unregisterSelfFromMetadataManager(),this.mb.domHelpers.showUnloadedMessage(e,`js view field`)}},DH=class extends MV{renderChildType;errorCollection;viewField;declarationString;declaration;constructor(e,t,n,r,i){super(e,t,n),this.renderChildType=r,this.declaration=i,this.declarationString=i.declarationString,this.errorCollection=new Tn(this.getUuid()),this.errorCollection.merge(i.errorCollection)}hasArgument(e){return this.getArguments(e).length>0}getArgument(e){return this.getArguments(e).at(0)}getArguments(e){if(this.declaration.errorCollection.hasErrors())throw new ve({errorLevel:z.ERROR,effect:`an not retrieve arguments`,cause:`viewFieldDeclaration has errors`});return this.declaration.argumentContainer.getAll(e)}getDeclaration(){return this.declaration}createViewField(){if(!this.errorCollection.hasErrors())try{this.viewField=this.mb.viewFieldFactory.createViewField(this)}catch(e){this.errorCollection.add(e)}!this.errorCollection.hasErrors()&&!this.viewField&&this.errorCollection.add(new ve({errorLevel:z.CRITICAL,effect:`can't render view field`,cause:`view field is undefined`}))}createErrorIndicator(e){this.mb.internal.createErrorIndicator(e,{errorCollection:this.errorCollection,errorText:`Errors caused the creation of the field to fail. Sometimes one error only occurs because of another.`,warningText:`Warnings will not cause the creation of a field to fail, but they indicate that a part of the declaration was invalid or uses deprecated functionality.`,code:this.declarationString})}onMount(e){if(super.onMount(e),this.mb.domHelpers.empty(e),this.mb.domHelpers.addClass(e,`mb-view`),this.createViewField(),this.errorCollection.hasErrors()){this.createErrorIndicator(e);return}let t=this.mb.domHelpers.createElement(e,`div`);this.mb.domHelpers.addClass(t,`mb-view-wrapper`),this.mb.domHelpers.addClass(e,`mb-view-rendered`);try{this.viewField?.mount(t)}catch(e){this.errorCollection.add(e)}this.createErrorIndicator(e);let n=this.getArguments(Pn.CLASS);for(let e of n)this.mb.domHelpers.addClasses(t,e.value);this.mb.domHelpers.addClass(t,`mb-view-type-${this.declaration.viewFieldType}`),this.renderChildType===fe.BLOCK?this.mb.domHelpers.addClass(e,`mb-view-block`):this.mb.domHelpers.addClass(e,`mb-view-inline`)}onUnmount(e){super.onUnmount(e),this.viewField?.unmount(),this.mb.domHelpers.showUnloadedMessage(e,`view field`)}},OH=class{mb;constructor(e){this.mb=e}createField(e,t,n,r=!0){if(z_(Zg({type:IV,filePath:PV,options:Ug(),honorExcludedSetting:Vg()}),{type:e,filePath:t,options:n,honorExcludedSetting:r}),this.mb.file.isExcludedFromRendering(t)&&r)return this.createExcludedMountable(t);if(e===pe.INPUT)return this.createInputFieldMountable(t,n);if(e===pe.VIEW)return this.createViewFieldMountable(t,n);if(e===pe.JS_VIEW)return this.createJsViewFieldMountable(t,n);if(e===pe.TABLE)return this.createTableMountable(t,n);if(e===pe.BUTTON_GROUP)return this.createButtonGroupMountable(t,n);if(e===pe.BUTTON)return this.createButtonMountable(t,n);if(e===pe.EMBED)return this.createEmbedMountable(t,n);if(e===pe.EXCLUDED)return this.createExcludedMountable(t);throw new ve({errorLevel:z.CRITICAL,effect:`failed to create field`,cause:`Unknown field type "${e}". Valid types are: ${Object.values(pe).join(`, `)}`})}createInlineFieldFromString(e,t,n,r=fe.INLINE,i,a=!0){z_(Zg({fieldString:hg(),filePath:PV,scope:zV.optional(),renderChildType:FV,honorExcludedSetting:Vg()}),{fieldString:e,filePath:t,scope:n,renderChildType:r,honorExcludedSetting:a});let o=this.isInlineFieldDeclarationAndGetType(e);if(o===void 0)throw new ve({errorLevel:z.CRITICAL,effect:`failed to create inline field`,cause:`Invalid inline mdrc type "${o}"`});return this.createInlineFieldOfTypeFromString(o,e,t,n,r,i,a)}createInlineFieldOfTypeFromString(e,t,n,r,i=fe.INLINE,a,o=!0){if(z_(Zg({type:IV,declaration:hg(),filePath:PV,scope:zV.optional(),renderChildType:FV,honorExcludedSetting:Vg()}),{type:e,declaration:t,filePath:n,scope:r,renderChildType:i,honorExcludedSetting:o}),this.mb.file.isExcludedFromRendering(n)&&o)return this.createExcludedMountable(n);if(e===pe.INPUT)return this.createInputFieldMountable(n,{renderChildType:i,declaration:t,scope:r});if(e===pe.VIEW)return this.createViewFieldMountable(n,{renderChildType:i,declaration:t,scope:r});if(e===pe.BUTTON_GROUP)return this.createButtonGroupMountable(n,{renderChildType:i,declaration:t,position:a});throw new ve({errorLevel:z.CRITICAL,effect:`failed to create inline field`,cause:`Invalid inline mdrc type "${e}"`})}createInputFieldMountable(e,t){z_(Zg({filePath:PV,options:eH}),{filePath:e,options:t});let n=E(),r;return r=typeof t.declaration==`string`?this.mb.inputFieldParser.fromStringAndValidate(t.declaration,e,t.scope):this.mb.inputFieldParser.fromSimpleDeclarationAndValidate(t.declaration,e,t.scope),new hH(this.mb,n,e,t.renderChildType,r)}createViewFieldMountable(e,t){z_(Zg({filePath:PV,options:tH}),{filePath:e,options:t});let n=E(),r;return r=typeof t.declaration==`string`?this.mb.viewFieldParser.fromStringAndValidate(t.declaration,e,t.scope):this.mb.viewFieldParser.fromSimpleDeclarationAndValidate(t.declaration,e,t.scope),new DH(this.mb,n,e,t.renderChildType,r)}createJsViewFieldMountable(e,t){z_(Zg({filePath:PV,options:nH}),{filePath:e,options:t});let n=E(),r;return r=typeof t.declaration==`string`?this.mb.jsViewFieldParser.fromStringAndValidate(t.declaration,e):this.mb.jsViewFieldParser.fromSimpleDeclarationAndValidate(t.declaration,e),new EH(this.mb,n,e,r)}createTableMountable(e,t){z_(Zg({filePath:PV,options:rH}),{filePath:e,options:t});let n=E();return new TH(this.mb,n,e,t.bindTarget,t.tableHead,t.columns)}createButtonGroupMountable(e,t){z_(Zg({filePath:PV,options:iH}),{filePath:e,options:t});let n=E(),r;return r=typeof t.declaration==`string`?this.mb.buttonParser.fromGroupString(t.declaration):this.mb.buttonParser.validateGroup(t.declaration),new dH(this.mb,n,e,r,t.renderChildType,t.position)}createButtonMountable(e,t){z_(Zg({filePath:PV,options:aH}),{filePath:e,options:t});let n=E(),r;return r=typeof t.declaration==`string`?this.mb.buttonParser.fromString(t.declaration):this.mb.buttonParser.validate(t.declaration),new fH(this.mb,n,e,r,t.position,t.isPreview)}createEmbedMountable(e,t){z_(Zg({filePath:PV,options:oH}),{filePath:e,options:t});let n=E();return new pH(this.mb,n,e,t.depth,t.content)}createExcludedMountable(e){z_(Zg({filePath:PV}),{filePath:e});let t=E();return new mH(this.mb,t,e)}getInlineFieldDeclarationPrefix(e){if(z_(Zg({fieldType:IV}),{fieldType:e}),e===pe.INPUT)return`INPUT`;if(e===pe.VIEW)return`VIEW`;if(e===pe.BUTTON_GROUP)return`BUTTON`;throw new ve({errorLevel:z.CRITICAL,effect:`failed to get declaration prefix`,cause:`Invalid inline mdrc type "${e}"`})}isInlineFieldDeclaration(e,t){z_(Zg({fieldType:IV,str:hg()}),{fieldType:e,str:t});let n=this.getInlineFieldDeclarationPrefix(e)+`[`;return t.startsWith(n)&&t.endsWith(`]`)}isInlineFieldDeclarationAndGetType(e){if(z_(Zg({str:hg()}),{str:e}),e.endsWith(`]`))for(let t of Object.values(pe)){if(!he(t))continue;let n=this.getInlineFieldDeclarationPrefix(t)+`[`;if(e.startsWith(n))return t}}createSignal(e){return new lc(e)}createBindTarget(e,t,n,r=!1){return z_(Zg({storageType:hg(),storagePath:hg(),property:hg().array(),listenToChildren:Vg()}),{storageType:e,storagePath:t,property:n,listenToChildren:r}),{storageType:e,storagePath:t,storageProp:gH(n),listenToChildren:r}}parseBindTarget(e,t,n){return z_(Zg({declarationString:hg(),filePath:PV,scope:zV.optional()}),{declarationString:e,filePath:t,scope:n}),this.mb.bindTargetParser.fromStringAndValidate(e,t,n)}setMetadata(e,t){z_(Zg({bindTarget:qV}),{bindTarget:e}),this.mb.metadataManager.write(t,e)}getMetadata(e){return z_(Zg({bindTarget:qV}),{bindTarget:e}),this.mb.metadataManager.read(e)}updateMetadata(e,t){z_(Zg({bindTarget:qV,updateFn:I_()}),{bindTarget:e,updateFn:t});let n=t(this.mb.metadataManager.read(e));this.mb.metadataManager.write(n,e)}subscribeToMetadata(e,t,n){z_(Zg({bindTarget:qV,lifecycleHook:this.mb.internal.getLifecycleHookValidator(),callback:I_()}),{bindTarget:e,lifecycleHook:t,callback:n});let r=E(),i=new lc(void 0);i.registerListener({callback:n});let a=this.mb.metadataManager.subscribe(r,i,e,()=>{i.unregisterAllListeners()});t.register(()=>{a.unsubscribe()})}createNotePosition(e,t){return z_(Zg({lineStart:Lg(),lineEnd:Lg()}),{lineStart:e,lineEnd:t}),new me({lineStart:e,lineEnd:t})}mathJSImport(e,t){this.mb.math.import(e,t)}},kH=class extends d.WidgetType{mb;type;content;filePath;parentComponent;renderChild;constructor(e,t,n,r,i){super(),this.type=e,this.content=t,this.filePath=n,this.parentComponent=r,this.mb=i}eq(e){return e.content===this.content}toDOM(e){let t=createSpan();t.addClass(`cm-inline-code`),t.addClass(`mb-inline-widget-rendered`);let n=this.mb.api.createInlineFieldOfTypeFromString(this.type,this.content,this.filePath,void 0);return this.renderChild=this.mb.api.wrapInMDRC(n,t,this.parentComponent),t}destroy(e){this.renderChild?.unload(),super.destroy(e)}},AH=class extends f.MarkdownRenderChild{mb;mountable;constructor(e,t,n){super(n),this.mb=e,this.mountable=t,this.mountable.registerUnmountCb(()=>{this.unload()})}onload(){this.containerEl.addClass(`interactive-child`),this.mountable.mount(this.containerEl),super.onload()}onunload(){this.mountable.isMounted()&&this.mountable.unmount(),super.onunload()}};function jH(e){return e.dependencyManager.checkDependency(`dataview`).api}function MH(e){return e.dependencyManager.checkDependency(`js-engine`).api}var NH=function(e){return e[e.CreateNewFromTemplate=0]=`CreateNewFromTemplate`,e[e.AppendActiveFile=1]=`AppendActiveFile`,e[e.OverwriteFile=2]=`OverwriteFile`,e[e.OverwriteActiveFile=3]=`OverwriteActiveFile`,e[e.DynamicProcessor=4]=`DynamicProcessor`,e[e.StartupTemplate=5]=`StartupTemplate`,e}({});function PH(e){return e.dependencyManager.checkDependency(`templater-obsidian`).templater}var FH=Zg({addChild:I_()}),IH=class extends OH{omb;constructor(e){super(e),this.omb=e}wrapInMDRC(e,t,n){z_(Zg({field:BV,containerEl:RV,component:FH}),{field:e,containerEl:t,component:n});let r=new AH(this.omb,e,t);return n.addChild(r),r}constructMDRCWidget(e,t,n,r){if(he(e))return new kH(e,t,n,r,this.omb);throw new ve({errorLevel:z.CRITICAL,effect:`failed to construct mdrc`,cause:`Invalid inline field type "${e}"`})}reactiveMetadata(e,t,n){z_(Zg({bindTargets:qV.array(),lifecycleHook:this.mb.internal.getLifecycleHookValidator(),callback:I_()}),{bindTargets:e,lifecycleHook:t,callback:n});let r=MH(this.omb),i=E(),a=e.map(()=>new lc(void 0)),o=()=>Promise.resolve(),s=this.mb.metadataManager.subscribeEffect(i,e,a,()=>o(),()=>{});t.register(()=>s.unsubscribe());let c=r.reactive(n,...a.map(e=>e.get()));return o=()=>c.refresh(...a.map(e=>e.get())),c}},LH=class{mb;constructor(e){this.mb=e}getFrontmatterLocation(e){let t=e.split(` `);if(t.at(0)===`---`){for(let e=1;et(e))}async create(e,t,n,r=!1,i=!1){let a=this.app.vault.getAvailablePath((0,f.normalizePath)(e+`/`+t),n),o=await this.app.vault.create(a,``);return r&&await this.openInSourceMode(o,i),o.path}getAllFiles(){return this.app.vault.getAllLoadedFiles().filter(e=>e instanceof f.TFile).map(e=>e.path)}getAllFolders(){return this.app.vault.getAllLoadedFiles().filter(e=>e instanceof f.TFolder).map(e=>e.path)}async open(e,t,n){this.app.workspace.openLinkText(e,t,n)}async openInSourceMode(e,t){let n=this.app.workspace.getLeaf(t?`tab`:!1);n&&await n.openFile(e,{state:{mode:`source`}})}getPathByName(e,t=``){return this.app.metadataCache.getFirstLinkpathDest(e,t)?.path}},zH=class extends sc{modal;setModal(e){this.modal=e}closeModal(){if(this.modal!==void 0)this.modal.close();else throw new ve({errorLevel:z.CRITICAL,effect:`Failed to close modal`,cause:`Modal reference in ModalContent is undefined`})}},BH=G(`
`);function VH(e,t){let n=nc(t,`name`,3,``),r=nc(t,`description`,3,``),i=nc(t,`heading`,3,!1),a=nc(t,`vertical`,3,!1);var o=BH();let s;var c=H(o),l=H(c),u=H(l,!0);V(l);var d=U(l,2),f=H(d,!0);V(d),V(c);var p=U(c,2);let m;var h=H(p),g=e=>{var n=as();ws(ka(n),()=>t.children),K(e,n)};ps(h,e=>{t.children&&e(g)}),V(p),V(o),Xa(()=>{s=Ns(o,1,`setting-item`,null,s,{"setting-item-heading":i(),"mb-vertical":a()}),os(u,n()),os(f,r()),m=Ns(p,1,`setting-item-control`,null,m,{"mb-vertical-control":a()})}),K(e,o)}function HH(e,t){ii(t,!0);let n=nc(t,`action`,15);function r(){t.mb.internal.openCommandSelectModal(e=>{n(n().command=e.id,!0)})}{let t=Mi(()=>n().command||`none`);VH(e,{get name(){return`Command: ${W(t)??``}`},description:`The command to execute when this action runs.`,children:(e,t)=>{Ac(e,{get variant(){return Lt.PRIMARY},onclick:()=>r(),children:(e,t)=>{Gr(),K(e,is(`Change`))},$$slots:{default:!0}})},$$slots:{default:!0}})}ai()}var UH=G(`
`);function WH(e,t){ii(t,!0);let n=nc(t,`checked`,15),r=Mi(()=>n()??!1);var i=UH();let a;var o=H(i);Ws(o),V(i),Xa(()=>{a=Ns(i,1,`checkbox-container`,null,a,{"is-enabled":W(r)}),qs(i,`aria-checked`,W(r)),Ks(o,W(r))}),Jo(`click`,i,()=>n(!W(r))),Jo(`keydown`,i,e=>{e.key===` `&&n(!W(r))}),K(e,i),ai()}Yo([`click`,`keydown`]);var GH=G(``),KH=G(` `,1);function qH(e,t){ii(t,!0);let n=nc(t,`action`,15);function r(){t.mb.internal.openFolderSelectModal(e=>{n(n().folderPath=e,!0)})}var i=KH(),a=ka(i);{let e=Mi(()=>n().folderPath||`none`);VH(a,{get name(){return`Folder: ${W(e)??``}`},description:`The folder to create a new note in.`,children:(e,t)=>{Ac(e,{get variant(){return Lt.PRIMARY},onclick:()=>r(),tooltip:`Select from vault`,children:(e,t)=>{Gr(),K(e,is(`Change`))},$$slots:{default:!0}})},$$slots:{default:!0}})}var o=U(a,2);{let e=Mi(()=>n().fileName||`default`);VH(o,{get name(){return`File name: ${W(e)??``}`},description:`The file name of the new note.`,children:(e,t)=>{var r=GH();Ws(r),Zs(r,()=>n().fileName,e=>n(n().fileName=e,!0)),K(e,r)},$$slots:{default:!0}})}var s=U(o,2);VH(s,{name:`Open note`,description:`Whether to open the new note after this action ran.`,children:(e,t)=>{WH(e,{get checked(){return n().openNote},set checked(e){n(n().openNote=e,!0)}})},$$slots:{default:!0}}),VH(U(s,2),{name:`Open if note already exists`,description:`Whether to open the note instead of creating a new one if the note already exists.`,children:(e,t)=>{WH(e,{get checked(){return n().openIfAlreadyExists},set checked(e){n(n().openIfAlreadyExists=e,!0)}})},$$slots:{default:!0}}),K(e,i),ai()}function JH(e,t){ii(t,!0);let n=nc(t,`action`,15);function r(){t.mb.internal.openMarkdownFileSelectModal(e=>{n(n().templateFile=e,!0)})}{let t=Mi(()=>n().templateFile||`default`);VH(e,{get name(){return`File path: ${W(t)??``}`},description:`The path to the templater file, relative to the vault root.`,children:(e,t)=>{Ac(e,{get variant(){return Lt.PRIMARY},onclick:()=>r(),tooltip:`Select from vault`,children:(e,t)=>{Gr(),K(e,is(`Change`))},$$slots:{default:!0}})},$$slots:{default:!0}})}ai()}var YH=G(`
`,1);function XH(e,t){ii(t,!0);let n=nc(t,`action`,15);var r=YH(),i=ka(r);VH(i,{name:`JS code`,description:`The JavaScript code to run.`});var a=U(i,2),o=H(a);Pa(o),V(a),Zs(o,()=>n().code,e=>n(n().code=e,!0)),K(e,r),ai()}var ZH=G(``);function QH(e,t){ii(t,!0);let n=nc(t,`action`,15);VH(e,{name:`Text`,description:`The text to input at the cursor.`,children:(e,t)=>{var r=ZH();Ws(r),Zs(r,()=>n().str,e=>n(n().str=e,!0)),K(e,r)},$$slots:{default:!0}}),ai()}var $H=G(``),eU=G(`
`,1);function tU(e,t){ii(t,!0);let n=nc(t,`action`,15);var r=eU(),i=ka(r);VH(i,{name:`Line`,description:`The line number to insert at.`,children:(e,t)=>{var r=$H();Ws(r),Zs(r,()=>n().line,e=>n(n().line=e,!0)),K(e,r)},$$slots:{default:!0}});var a=U(i,2);VH(a,{name:`Text to insert`,description:`The text to insert into the note.`});var o=U(a,2),s=H(o);Pa(s),V(o),Zs(s,()=>n().value,e=>n(n().value=e,!0)),K(e,r),ai()}function nU(e,t){ii(t,!0);let n=nc(t,`action`,15);function r(){t.mb.internal.openFilteredFileSelectModal(e=>{n(n().file=e,!0)},e=>e.endsWith(`.js`))}VH(e,{name:`JS file`,description:`The JavaScript file to run.`,children:(e,t)=>{Ac(e,{get variant(){return Lt.PRIMARY},onclick:()=>r(),tooltip:`Select from vault`,children:(e,t)=>{Gr(),K(e,is(`Change`))},$$slots:{default:!0}})},$$slots:{default:!0}}),ai()}var rU=G(` `,1),iU=G(` `,1);function aU(e,t){ii(t,!0);let n=nc(t,`action`,15);function r(){t.mb.internal.openMarkdownFileSelectModal(e=>{n(n().link=e,!0)})}var i=iU(),a=ka(i);VH(a,{name:`Link`,description:`The link to open.`,children:(e,i)=>{var a=rU(),o=ka(a);Ws(o),Ac(U(o,2),{get variant(){return Lt.PRIMARY},onclick:()=>r(),tooltip:`Select from vault`,children:(e,n)=>{gc(e,{iconName:`list`,get mb(){return t.mb}})},$$slots:{default:!0}}),Zs(o,()=>n().link,e=>n(n().link=e,!0)),K(e,a)},$$slots:{default:!0}}),VH(U(a,2),{name:`New tab`,description:`Whether to open the link in a new tab.`,children:(e,t)=>{WH(e,{get checked(){return n().newTab},set checked(e){n(n().newTab=e,!0)}})},$$slots:{default:!0}}),K(e,i),ai()}var oU=G(``),sU=G(``),cU=G(`
`,1);function lU(e,t){ii(t,!0);let n=nc(t,`action`,15);var r=cU(),i=ka(r);VH(i,{name:`Regexp`,description:`The regexp to find replacements.`,children:(e,t)=>{var r=oU();Ws(r),Zs(r,()=>n().regexp,e=>n(n().regexp=e,!0)),K(e,r)},$$slots:{default:!0}});var a=U(i,2);VH(a,{name:`Regexp flags`,description:`The regexp flags for this regexp.`,children:(e,t)=>{var r=sU();Ws(r),Zs(r,()=>n().regexpFlags,e=>n(n().regexpFlags=e,!0)),K(e,r)},$$slots:{default:!0}});var o=U(a,2);VH(o,{name:`Replacement text`,description:`The text to replace the button with.`});var s=U(o,2),c=H(s);Pa(c),V(s),Zs(c,()=>n().replacement,e=>n(n().replacement=e,!0)),K(e,r),ai()}var uU=G(``),dU=G(`
`,1);function fU(e,t){ii(t,!0);let n=nc(t,`action`,15);var r=dU(),i=ka(r);VH(i,{name:`Line from`,description:`The line that marks the start of the area to replace.`,children:(e,t)=>{var r=uU();Ws(r),Zs(r,()=>n().fromLine,e=>n(n().fromLine=e,!0)),K(e,r)},$$slots:{default:!0}});var a=U(i,2);VH(a,{name:`Line to`,description:`The line that marks the end of the area to replace.`,children:(e,t)=>{var r=uU();Ws(r),Zs(r,()=>n().toLine,e=>n(n().toLine=e,!0)),K(e,r)},$$slots:{default:!0}});var o=U(a,2);VH(o,{name:`Replacement text`,description:`The text to replace the note section.`});var s=U(o,2),c=H(s);Pa(c),V(s),Zs(c,()=>n().replacement,e=>n(n().replacement=e,!0)),K(e,r),ai()}var pU=G(`
`,1);function mU(e,t){ii(t,!0);let n=nc(t,`action`,15);var r=pU(),i=ka(r);VH(i,{name:`Replacement text`,description:`The text to replace the match with.`});var a=U(i,2),o=H(a);Pa(o),V(a),Zs(o,()=>n().replacement,e=>n(n().replacement=e,!0)),K(e,r),ai()}var hU=G(``);function gU(e,t){ii(t,!0);let n=nc(t,`action`,15);VH(e,{name:`Sleep time`,description:`The time to sleep in milliseconds.`,children:(e,t)=>{var r=hU();Ws(r),Zs(r,()=>n().ms,e=>n(n().ms=e,!0)),K(e,r)},$$slots:{default:!0}}),ai()}var _U=G(``),vU=G(` `,1);function yU(e,t){ii(t,!0);let n=nc(t,`action`,15);function r(e){t.mb.internal.openFileSelectModal(t=>{e.templateFile=t})}function i(e){t.mb.internal.openFolderSelectModal(t=>{e.folderPath=t})}var a=vU(),o=ka(a);{let e=Mi(()=>n().templateFile||`none`);VH(o,{get name(){return`Template file: ${W(e)??``}`},description:`The template file to create a new note of.`,children:(e,t)=>{Ac(e,{get variant(){return Lt.PRIMARY},onclick:()=>r(n()),tooltip:`Select from vault`,children:(e,t)=>{Gr(),K(e,is(`Change`))},$$slots:{default:!0}})},$$slots:{default:!0}})}var s=U(o,2);{let e=Mi(()=>n().folderPath||`none`);VH(s,{get name(){return`Folder: ${W(e)??``}`},description:`The folder to create a new note in.`,children:(e,t)=>{Ac(e,{get variant(){return Lt.PRIMARY},onclick:()=>i(n()),tooltip:`Select from vault`,children:(e,t)=>{Gr(),K(e,is(`Change`))},$$slots:{default:!0}})},$$slots:{default:!0}})}var c=U(s,2);{let e=Mi(()=>n().fileName||`default`);VH(c,{get name(){return`File name: ${W(e)??``}`},description:`The file name of the new note.`,children:(e,t)=>{var r=_U();Ws(r),Zs(r,()=>n().fileName,e=>n(n().fileName=e,!0)),K(e,r)},$$slots:{default:!0}})}var l=U(c,2);VH(l,{name:`Open note`,description:`Whether to open the new note after this action ran.`,children:(e,t)=>{WH(e,{get checked(){return n().openNote},set checked(e){n(n().openNote=e,!0)}})},$$slots:{default:!0}}),VH(U(l,2),{name:`Open if note already exists`,description:`Whether to open the note instead of creating a new one if the note already exists.`,children:(e,t)=>{WH(e,{get checked(){return n().openIfAlreadyExists},set checked(e){n(n().openIfAlreadyExists=e,!0)}})},$$slots:{default:!0}}),K(e,a),ai()}var bU=G(``),xU=G(` `,1);function SU(e,t){ii(t,!0);let n=nc(t,`action`,15);var r=xU(),i=ka(r);VH(i,{name:`Metadata property`,description:`The metadata property in form of a bind target.`,children:(e,t)=>{var r=bU();Ws(r),Zs(r,()=>n().bindTarget,e=>n(n().bindTarget=e,!0)),K(e,r)},$$slots:{default:!0}});var a=U(i,2);VH(a,{name:`Value`,description:`The new value.`,children:(e,t)=>{var r=bU();Ws(r),Zs(r,()=>n().value,e=>n(n().value=e,!0)),K(e,r)},$$slots:{default:!0}}),VH(U(a,2),{name:`Evaluate`,description:`Whether to evaluate the value as a JS expression.`,children:(e,t)=>{WH(e,{get checked(){return n().evaluate},set checked(e){n(n().evaluate=e,!0)}})},$$slots:{default:!0}}),K(e,r),ai()}var CU=G(`
`);function wU(e,t){ii(t,!0);let n=nc(t,`reverse`,3,!1),r=nc(t,`stretchChildren`,3,!1),i=Mi(()=>[n()?`mb-flex-row-reverse`:`mb-flex-row`,r()?`mb-flex-row-stretch`:``].join(` `));var a=CU();ws(H(a),()=>t.children),V(a),Xa(()=>Ns(a,1,Ds(W(i)))),K(e,a),ai()}var TU=G(``);function EU(e,t){var n=TU();ws(H(n),()=>t.children),V(n),K(e,n)}var DU=G(``),OU=G(``),kU=G(``),AU=G(` `,1),jU=G(`
`,1),MU=G(` `,1),NU=G(` `,1),PU=G(`

Actions

Add action of type

Preview

`,1);function FU(e,t){ii(t,!0);let n=va(t.buttonConfig),r,i,a=da(va(B.COMMAND));ic(()=>{i?.unmount()}),Wa(()=>{i?.unmount(),r&&(t.mb.domHelpers.empty(r),i=new lH(t.mb,ei(n),``,fe.BLOCK,void 0,!1,!0),i.mount(r))});function o(){n.actions?.push(t.mb.buttonActionRunner.createDefaultAction(W(a)))}function s(e){n.actions?.splice(e,1)}function c(e){return t.mb.buttonActionRunner.getActionLabel(e)}function l(e,r){if(n.actions===void 0)return;let i=[];e>0&&i.push({name:`Move up`,icon:`arrow-up`,onclick:()=>{if(n.actions===void 0)return;let t=n.actions[e-1];n.actions[e-1]=n.actions[e],n.actions[e]=t}}),e{if(n.actions===void 0)return;let t=n.actions[e+1];n.actions[e+1]=n.actions[e],n.actions[e]=t}}),i.push({name:`Remove`,icon:`x`,warning:!0,onclick:()=>s(e)}),t.mb.internal.createContextMenu(i).showWithEvent(r)}function u(){t.mb.internal.openImageFileSelectModal(e=>{n.backgroundImage=e})}function d(){n.backgroundImage=void 0}var f=PU(),p=ka(f);VH(p,{name:`Label`,description:`The label shown on the button.`,children:(e,t)=>{var r=DU();Ws(r),Zs(r,()=>n.label,e=>n.label=e),K(e,r)},$$slots:{default:!0}});var m=U(p,2);VH(m,{name:`Icon`,description:`The icon shown on the button. If left empty, no icon will show`,children:(e,t)=>{var r=DU();Ws(r),Zs(r,()=>n.icon,e=>n.icon=e),K(e,r)},$$slots:{default:!0}});var h=U(m,2);VH(h,{name:`Style`,description:`The style variant of the button`,children:(e,t)=>{var r=kU();vs(r,21,()=>Object.values(Lt),ms,(e,t)=>{var n=OU(),r=H(n,!0);V(n);var i={};Xa(()=>{os(r,W(t)),i!==(i=W(t))&&(n.value=(n.__value=W(t))??``)}),K(e,n)}),V(r),Rs(r,()=>n.style,e=>n.style=e),K(e,r)},$$slots:{default:!0}});var g=U(h,2);VH(g,{name:`CSS classes`,description:`A list of CSS classes to add to the button. Multiple classes should be separated by a space.`,children:(e,t)=>{var r=DU();Ws(r),Zs(r,()=>n.class,e=>n.class=e),K(e,r)},$$slots:{default:!0}});var _=U(g,2);VH(_,{name:`CSS styles`,description:`CSS styles to directly apply to the button.`,children:(e,t)=>{var r=DU();Ws(r),Zs(r,()=>n.cssStyle,e=>n.cssStyle=e),K(e,r)},$$slots:{default:!0}});var v=U(_,2);VH(v,{name:`Background image`,description:`A background image to use in the button.`,children:(e,r)=>{var i=AU(),a=ka(i),o=H(a,!0);V(a);var s=U(a,2);Ac(s,{get variant(){return Lt.PRIMARY},onclick:()=>u(),tooltip:`Select from vault`,children:(e,t)=>{Gr(),K(e,is(`Change`))},$$slots:{default:!0}}),Ac(U(s,2),{get variant(){return Lt.DEFAULT},onclick:()=>d(),tooltip:`Reset to none`,children:(e,n)=>{gc(e,{get mb(){return t.mb},iconName:`x`})},$$slots:{default:!0}}),Xa(()=>os(o,n.backgroundImage||`none`)),K(e,i)},$$slots:{default:!0}});var y=U(v,2);VH(y,{name:`Tooltip`,description:`A tooltip to show when hovering the button. If not set, the button label will be shown instead.`,children:(e,t)=>{var r=DU();Ws(r),Zs(r,()=>n.tooltip,e=>n.tooltip=e),K(e,r)},$$slots:{default:!0}});var b=U(y,2);VH(b,{name:`ID`,description:`An ID that allows the button to be referenced in inline buttons.`,children:(e,t)=>{var r=DU();Ws(r),Zs(r,()=>n.id,e=>n.id=e),K(e,r)},$$slots:{default:!0}});var x=U(b,2);VH(x,{name:`Hidden`,description:`Whether to not render this button. This can be useful when using inline buttons.`,children:(e,t)=>{WH(e,{get checked(){return n.hidden},set checked(e){n.hidden=e}})},$$slots:{default:!0}});var S=U(x,4);vs(S,21,()=>Object.values(B),ms,(e,t)=>{var n=OU(),r=H(n,!0);V(n);var i={};Xa(()=>{os(r,W(t)),i!==(i=W(t))&&(n.value=(n.__value=W(t))??``)}),K(e,n)}),V(S);var C=U(S,2);Ac(C,{get variant(){return Lt.PRIMARY},onclick:()=>o(),children:(e,t)=>{Gr(),K(e,is(`Add Action`))},$$slots:{default:!0}});var w=U(C,2),T=e=>{var r=as();vs(ka(r),17,()=>n.actions??[],ms,(e,r,i)=>{var a=MU(),o=ka(a);wU(o,{children:(e,n)=>{var a=jU(),o=ka(a),s=H(o,!0);V(o),Ac(U(o,2),{get variant(){return Lt.PLAIN},onclick:e=>l(i,e),children:(e,n)=>{gc(e,{iconName:`more-vertical`,get mb(){return t.mb}})},$$slots:{default:!0}}),Xa(e=>os(s,e),[()=>c(W(r).type)]),K(e,a)},$$slots:{default:!0}});var s=U(o,2),u=e=>{HH(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};ps(s,e=>{W(r).type===B.COMMAND&&e(u)});var d=U(s,2),f=e=>{aU(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};ps(d,e=>{W(r).type===B.OPEN&&e(f)});var p=U(d,2),m=e=>{nU(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};ps(p,e=>{W(r).type===B.JS&&e(m)});var h=U(p,2),g=e=>{QH(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};ps(h,e=>{W(r).type===B.INPUT&&e(g)});var _=U(h,2),v=e=>{gU(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};ps(_,e=>{W(r).type===B.SLEEP&&e(v)});var y=U(_,2),b=e=>{yU(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};ps(y,e=>{W(r).type===B.TEMPLATER_CREATE_NOTE&&e(b)});var x=U(y,2),S=e=>{SU(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};ps(x,e=>{W(r).type===B.UPDATE_METADATA&&e(S)});var C=U(x,2),w=e=>{qH(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};ps(C,e=>{W(r).type===B.CREATE_NOTE&&e(w)});var T=U(C,2),E=e=>{JH(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};ps(T,e=>{W(r).type===B.RUN_TEMPLATER_FILE&&e(E)});var D=U(T,2),O=e=>{fU(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};ps(D,e=>{W(r).type===B.REPLACE_IN_NOTE&&e(O)});var k=U(D,2),A=e=>{lU(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};ps(k,e=>{W(r).type===B.REGEXP_REPLACE_IN_NOTE&&e(A)});var j=U(k,2),M=e=>{mU(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};ps(j,e=>{W(r).type===B.REPLACE_SELF&&e(M)});var N=U(j,2),ee=e=>{tU(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};ps(N,e=>{W(r).type===B.INSERT_INTO_NOTE&&e(ee)});var te=U(N,2),ne=e=>{XH(e,{get mb(){return t.mb},get action(){return n.actions[i]},set action(e){n.actions[i]=e}})};ps(te,e=>{W(r).type===B.INLINE_JS&&e(ne)}),K(e,a)}),K(e,r)};ps(w,e=>{n.actions&&e(T)});var E=U(w,4);tc(E,e=>r=e,()=>r),EU(U(E,2),{children:(e,r)=>{var i=NU(),a=ka(i);Ac(a,{get variant(){return Lt.PRIMARY},onclick:()=>t.modal.okay(ei(n)),children:(e,n)=>{Gr();var r=is();Xa(()=>os(r,t.modal.options.submitText)),K(e,r)},$$slots:{default:!0}}),Ac(U(a,2),{get variant(){return Lt.DEFAULT},onclick:()=>t.modal.cancel(),children:(e,t)=>{Gr(),K(e,is(`Cancel`))},$$slots:{default:!0}}),K(e,i)},$$slots:{default:!0}}),Rs(S,()=>W(a),e=>pa(a,e)),K(e,f),ai()}var IU=class extends zH{mb;component;options;constructor(e,t){super(),this.mb=e,this.options=t}onMount(e){this.mb.domHelpers.empty(e),this.component&&ds(this.component),this.component=ss(FU,{target:e,props:{mb:this.mb,modal:this,buttonConfig:this.options.config??this.mb.buttonActionRunner.createDefaultButtonConfig()}})}onUnmount(e){this.mb.domHelpers.empty(e),this.component&&ds(this.component)}okay(e){this.closeModal(),this.options.onOkay(e)}cancel(){this.closeModal()}},LU=class extends zH{component;createComponent;constructor(e){super(),this.createComponent=e}onMount(e){e.replaceChildren(),this.component=this.createComponent(this,e)}onUnmount(e){this.component&&ds(this.component),e.replaceChildren()}},RU=class{mb;selectCallback;constructor(e,t){this.mb=e,this.selectCallback=t}onSelected(e){this.selectCallback(e)}},zU=class extends RU{getItemText(e){return e.name}getItemDescription(e){}getItems(){return this.mb.internal.getAllCommands()}},BU=class extends RU{filterFunction;constructor(e,t,n){super(e,t),this.filterFunction=n}getItemText(e){return e}getItemDescription(e){}getItems(){return this.filterFunction===void 0?this.mb.file.getAllFiles():this.mb.file.getAllFiles().filter(e=>this.filterFunction(e))}},VU=class extends RU{getItemText(e){return e}getItemDescription(e){}getItems(){return this.mb.file.getAllFolders()}},HU=class extends RU{ipf;constructor(e,t,n){super(e,t),this.ipf=n}getItemText(e){return e.displayValue}getItemDescription(e){return e.displayDescription}getItems(){return this.mb.internal.getSuggesterOptions(this.ipf)}},UU=G(`
`),WU=G(`
`),GU=G(`
`);function KU(e,t){ii(t,!0);let n=Mi(()=>ay(t.month,t.year));function r(e){e&&t.dateChange(t.mb.dateParser.fromDate(new Date(t.year,t.month,e)))}function i(e,t){e.key===` `&&r(t)}var a=GU(),o=H(a);vs(o,21,sy,ms,(e,t)=>{var n=UU(),r=H(n),i=H(r,!0);V(r),V(n),Xa(()=>os(i,W(t))),K(e,n)}),V(o);var s=U(o,2);vs(s,21,()=>W(n),ms,(e,n)=>{var a=WU();let o;var s=H(a),c=H(s,!0);V(s),V(a),Xa(e=>{o=Ns(a,1,`mb-calendar-cell`,null,o,e),os(c,W(n)||``)},[()=>({"mb-calendar-highlight":W(n),"mb-calendar-content-cell":W(n),"mb-calendar-selected":t.selectedDate?.year()===t.year&&t.selectedDate?.month()===t.month&&t.selectedDate?.date()===W(n)})]),Jo(`click`,a,()=>r(W(n))),Jo(`keydown`,a,e=>i(e,W(n))),K(e,a)}),V(s),V(a),K(e,a),ai()}Yo([`click`,`keydown`]);var qU=G(`
`);function JU(e,t){ii(t,!0);let n=nc(t,`selectedDate`,7),r=da(0),i=da(0);Wa(()=>{if(n())pa(r,n().month(),!0),pa(i,n().year(),!0);else{let e=t.mb.dateParser.getDefaultDate();pa(r,e.month(),!0),pa(i,e.year(),!0)}});function a(){if(W(r)===11){pa(r,0),pa(i,W(i)+1);return}pa(r,W(r)+1)}function o(){if(W(r)===0){pa(r,11),pa(i,W(i)-1);return}pa(r,W(r)-1)}function s(e){let t=e.target.value,n=Number.parseInt(t);Number.isNaN(n)||pa(i,n,!0)}function c(e){n(e),t.dateChangeCallback(e)}function l(){n(null),t.dateChangeCallback(null)}function u(){n(t.mb.dateParser.getDefaultDate()),t.dateChangeCallback(n())}var d=qU(),f=H(d),p=H(f),m=U(p,2),h=H(m),g=H(h,!0);V(h);var _=U(h,2);Ws(_),V(m);var v=U(m,2);V(f);var y=U(f,2);KU(y,{get mb(){return t.mb},dateChange:c,get month(){return W(r)},get year(){return W(i)},get selectedDate(){return n()}});var b=U(y,2),x=H(b),S=U(x,2);V(b),V(d),Xa((e,t)=>{os(g,e),Gs(_,t)},[()=>iy(W(r)),()=>W(i).toString()]),Jo(`click`,p,o),Jo(`input`,_,s),Jo(`click`,v,a),Jo(`click`,x,l),Jo(`click`,S,u),K(e,d),ai()}Yo([`click`,`input`]),new Set([`$$slots`,`$$events`,`$$legacy`]);var YU=G(`
`);function XU(e,t){ii(t,!0);function n(e,n){e.key===` `&&t.onSelect(n)}var r=YU(),i=H(r),a=U(i,2),o=H(a),s=H(o,!0);V(o),V(a),V(r),Xa(e=>{qs(i,`src`,e),qs(i,`alt`,t.image),os(s,t.image)},[()=>t.mb.internal.imagePathToUri(t.image)]),Jo(`click`,r,()=>t.onSelect(t.image)),Jo(`keydown`,r,e=>n(e,t.image)),K(e,r),ai()}Yo([`click`,`keydown`]);var ZU=G(` `,1),QU=G(`
`,1);function $U(e,t){ii(t,!0);let n=da(``),r=t.mb.internal.createFuzzySearch(),i=Mi(()=>W(n)?(r.setSearch(W(n)),r.filterItems(t.options,e=>e.value)):t.options);var a=QU(),o=ka(a),s=H(o);Ws(s),V(o);var c=U(o,2);vs(c,21,()=>W(i),ms,(e,n)=>{XU(e,{get mb(){return t.mb},get image(){return W(n).value},get onSelect(){return t.onSelect}})}),V(c),EU(U(c,2),{children:(e,n)=>{var r=ZU(),i=ka(r),a=e=>{Ac(e,{get variant(){return Lt.PRIMARY},onclick:()=>t.onSelect(void 0),children:(e,t)=>{Gr(),K(e,is(`Select none`))},$$slots:{default:!0}})};ps(i,e=>{t.canSelectNone&&e(a)}),Ac(U(i,2),{onclick:()=>t.onCancel(),children:(e,t)=>{Gr(),K(e,is(`Cancel`))},$$slots:{default:!0}}),K(e,r)},$$slots:{default:!0}}),Zs(s,()=>W(n),e=>pa(n,e)),K(e,a),ai()}var eW=G(``),tW=G(``),nW=G(` `,1),rW=G(`

`,1);function iW(e,t){ii(t,!0);let n=da(va(t.options.value));var r=rW(),i=ka(r),a=H(i,!0);V(i);var o=U(i,2),s=H(o),c=e=>{var t=eW();Pa(t),Zs(t,()=>W(n),e=>pa(n,e)),K(e,t)},l=e=>{var t=tW();Ws(t),Zs(t,()=>W(n),e=>pa(n,e)),K(e,t)};ps(s,e=>{t.options.multiline?e(c):e(l,-1)}),V(o),EU(U(o,2),{children:(e,r)=>{var i=nW(),a=ka(i);Ac(a,{get variant(){return Lt.PRIMARY},onclick:()=>t.options.onSubmit(ei(W(n))),children:(e,t)=>{Gr(),K(e,is(`OK`))},$$slots:{default:!0}}),Ac(U(a,2),{onclick:()=>t.options.onCancel(),children:(e,t)=>{Gr(),K(e,is(`Cancel`))},$$slots:{default:!0}}),K(e,i)},$$slots:{default:!0}}),Xa(()=>os(a,t.options.subTitle)),K(e,r),ai()}var aW=G(`
 
`),oW=G(`Tip `),sW=G(`
`,1),cW=G(`Docs`),lW=G(`Context
 
`),uW=G(`
Cause
Effect
`),dW=G(`
 
`);function fW(e,t){ii(t,!0);var n=as(),r=ka(n),i=e=>{var n=uW(),r=H(n),i=H(r),a=H(i);V(i);var o=U(i);V(r);var s=U(r,2),c=e=>{var n=aW(),r=H(n),i=H(r,!0);V(r),V(n),Xa(()=>os(i,t.error.positionContext)),K(e,n)};ps(s,e=>{t.error.positionContext&&e(c)});var l=U(s,2),u=H(l),d=H(u),f=U(H(d)),p=H(f,!0);V(f),V(d);var m=U(d),h=U(H(m)),g=H(h,!0);V(h),V(m);var _=U(m),v=e=>{var n=oW(),r=U(H(n)),i=H(r,!0);V(r),V(n),Xa(()=>os(i,t.error.tip)),K(e,n)};ps(_,e=>{t.error.tip&&e(v)});var y=U(_),b=e=>{var n=cW(),r=U(H(n));vs(r,21,()=>t.error.docs,ms,(e,t)=>{var n=sW(),r=ka(n),i=H(r,!0);V(r),Gr(),Xa(()=>{qs(r,`href`,W(t)),os(i,W(t))}),K(e,n)}),V(r),V(n),K(e,n)};ps(y,e=>{t.error.docs&&e(b)});var x=U(y),S=e=>{var n=lW(),r=U(H(n)),i=H(r),a=H(i),o=H(a,!0);V(a),V(i),V(r),V(n),Xa(e=>os(o,e),[()=>JSON.stringify(t.error.context,null,4)]),K(e,n)};ps(x,e=>{t.error.context&&e(S)}),V(u),V(l),V(n),Xa(e=>{Ns(i,1,Ds(t.error.errorLevel===z.WARNING?`mb-warning-text`:`mb-error-text`)),os(a,`${t.error.errorLevel??``} [${e??``}]`),os(o,` - ${t.error.effect??``}`),os(p,t.error.cause),os(g,t.error.effect)},[()=>t.error.getErrorType()]),K(e,n)},a=e=>{var n=dW(),r=H(n),i=H(r),a=H(i,!0);V(i),V(r),V(n),Xa(()=>os(a,t.error.stack)),K(e,n)};ps(r,e=>{t.error instanceof _e?e(i):e(a,-1)}),K(e,n),ai()}var pW=G(`

`),mW=G(`
 
`),hW=G(`
Errors
`,1),gW=G(`
Warnings
`,1),_W=G(` `,1);function vW(e,t){ii(t,!0);var n=_W(),r=ka(n),i=e=>{var n=pW(),r=H(n,!0);V(n),Xa(()=>os(r,t.settings.text)),K(e,n)};ps(r,e=>{t.settings.text&&e(i)});var a=U(r,2),o=e=>{var n=mW(),r=H(n),i=H(r,!0);V(r),V(n),Xa(()=>os(i,t.settings.code)),K(e,n)};ps(a,e=>{t.settings.code&&e(o)});var s=U(a,2),c=e=>{var n=hW(),r=U(ka(n),2),i=e=>{var n=pW(),r=H(n,!0);V(n),Xa(()=>os(r,t.settings.errorText)),K(e,n)};ps(r,e=>{t.settings.errorText&&e(i)}),vs(U(r,2),17,()=>t.settings.errorCollection.getErrors(),ms,(e,t)=>{fW(e,{get error(){return W(t)}})}),K(e,n)},l=Mi(()=>t.settings.errorCollection.hasErrors());ps(s,e=>{W(l)&&e(c)});var u=U(s,2),d=e=>{var n=gW(),r=U(ka(n),2),i=e=>{var n=pW(),r=H(n,!0);V(n),Xa(()=>os(r,t.settings.warningText)),K(e,n)};ps(r,e=>{t.settings.warningText&&e(i)}),vs(U(r,2),17,()=>t.settings.errorCollection.getWarnings(),ms,(e,t)=>{fW(e,{get error(){return W(t)}})}),K(e,n)},f=Mi(()=>t.settings.errorCollection.hasWarnings());ps(u,e=>{W(f)&&e(d)}),K(e,n),ai()}var yW=G(` [META_BIND_ERROR]`,1),bW=rs(``),xW=rs(``),SW=G(`
`);function CW(e,t){ii(t,!0);function n(){t.mb.internal.openErrorCollectionViewModal(t.settings)}var r=as(),i=ka(r),a=e=>{var r=SW(),i=H(r),a=e=>{var t=yW();Gr(2),K(e,t)},o=Mi(()=>t.settings.errorCollection.hasErrors()),s=e=>{K(e,bW())},c=Mi(()=>t.settings.errorCollection.hasWarnings()),l=e=>{K(e,xW())};ps(i,e=>{W(o)?e(a):W(c)?e(s,1):e(l,-1)}),V(r),Jo(`click`,r,()=>n()),Jo(`keydown`,r,e=>{e.key===` `&&n()}),K(e,r)},o=Mi(()=>!t.settings.errorCollection.isEmpty());ps(i,e=>{W(o)&&e(a)}),K(e,r),ai()}Yo([`click`,`keydown`]);var wW=[`apng`,`avif`,`gif`,`jpg`,`jpeg`,`jfif`,`pjpeg`,`pjp`,`png`,`svg`,`webp`],TW=wW.map(e=>`.${e}`),EW=class{mb;constructor(e){this.mb=e}openCommandSelectModal(e){this.createSearchModal(new zU(this.mb,e)).open()}openFileSelectModal(e){this.createSearchModal(new BU(this.mb,e)).open()}openFilteredFileSelectModal(e,t){this.createSearchModal(new BU(this.mb,e,t)).open()}openMarkdownFileSelectModal(e){this.openFilteredFileSelectModal(e,e=>e.endsWith(`.md`))}openImageFileSelectModal(e){this.openFilteredFileSelectModal(e,e=>TW.some(t=>e.endsWith(t)))}openFolderSelectModal(e){this.createSearchModal(new VU(this.mb,e)).open()}openButtonBuilderModal(e){this.createModal(new IU(this.mb,e),{title:`Meta Bind Button Builder`}).open()}openSuggesterModal(e,t){this.createSearchModal(new HU(this.mb,t,e)).open()}openImageSuggesterModal(e,t,n){this.createModal(new LU((r,i)=>ss($U,{target:i,props:{mb:this.mb,options:this.getImageSuggesterOptions(e),canSelectNone:t,onSelect:e=>{n(e),r.closeModal()},onCancel:()=>{r.closeModal()}}})),{title:`Select an image from your Vault`,classes:[`mb-image-suggester-modal`]}).open()}openDatePickerModal(e,t){this.createModal(new LU((n,r)=>ss(JU,{target:r,props:{mb:this.mb,selectedDate:e,dateChangeCallback:e=>{t(e),n.closeModal()}}})),{title:`Meta Bind date picker`}).open()}openTextPromptModal(e){this.createModal(new LU((t,n)=>ss(iW,{target:n,props:{options:{...e,onSubmit:n=>{e.onSubmit(n),t.closeModal()},onCancel:()=>{e.onCancel(),t.closeModal()}}}})),e).open()}openErrorCollectionViewModal(e){this.createModal(new LU((t,n)=>ss(vW,{target:n,props:{settings:e}})),{title:`Meta Bind error overview`,classes:[`mb-error-collection-modal`,`markdown-rendered`]}).open()}createErrorIndicator(e,t){let n=ss(CW,{target:e,props:{mb:this.mb,settings:t}});return()=>{ds(n)}}},DW=class{preparedSearch;constructor(){}setSearch(e){this.preparedSearch=(0,f.prepareFuzzySearch)(e)}filterItems(e,t){return this.preparedSearch?e.filter(e=>this.preparedSearch?.(t(e))?.score!=null):e}},OW=class{value;displayValue;displayDescription;constructor(e,t,n){this.value=e,this.displayValue=t,this.displayDescription=n}valueAsString(){return this.value?.toString()??`null`}};function kW(e){let t=[];for(let n of e.children)n instanceof f.TFile&&jW(n.extension)&&t.push(new OW(n.path,n.name)),n instanceof f.TFolder&&t.push(...kW(n));return t}function AW(e,t,n){let r=[];for(let t of n){let n=t.value;if(n.startsWith(`"`)&&n.endsWith(`"`))n=n.substring(1,n.length-1);else{let e=new Se({errorLevel:z.ERROR,effect:`failed to get suggest options`,cause:`expected suggest option query for image suggester to start and end with double quotation marks`});new f.Notice(`meta-bind | ${e.message}`),console.warn(e);continue}let i;if(i=n===``||n===`.`?e.app.vault.getRoot():e.app.vault.getAbstractFileByPath(n),i==null){let e=new Se({errorLevel:z.ERROR,effect:`failed to get suggest options`,cause:`expected suggest option query ${n} for image suggester to exist`});new f.Notice(`meta-bind | ${e.message}`),console.warn(e);continue}if(!(i instanceof f.TFolder)){let e=new Se({errorLevel:z.ERROR,effect:`failed to get suggest options`,cause:`expected suggest option query ${t.value} for image suggester to be a folder`});new f.Notice(`meta-bind | ${e.message}`),console.warn(e);continue}r.push(...kW(i))}for(let n of t){let t=pn(n.value);if(!t){let e=new Se({errorLevel:z.ERROR,effect:`failed to get suggest options`,cause:`expected suggest option ${n.value} to be truthy`});new f.Notice(`meta-bind | ${e.message}`),console.warn(e);continue}let i=e.app.vault.getAbstractFileByPath(t);if(!i){let e=new Se({errorLevel:z.ERROR,effect:`failed to get suggest options`,cause:`expected suggest option ${n.value} for image suggester to exist`});new f.Notice(`meta-bind | ${e.message}`),console.warn(e);continue}if(!(i instanceof f.TFile)){let e=new Se({errorLevel:z.ERROR,effect:`failed to get suggest options`,cause:`expected suggest option ${n.value} for image suggester to be a file`});new f.Notice(`meta-bind | ${e.message}`),console.warn(e);continue}if(!jW(i.extension)){let e=new Se({errorLevel:z.ERROR,effect:`failed to get suggest options`,cause:`expected suggest option ${n.value} for image suggester to be an image file`});new f.Notice(`meta-bind | ${e.message}`),console.warn(e);continue}r.push(new OW(i.path,i.name))}return r}function jW(e){return wW.contains(e)}function MW(e,t){return AW(e,t.mountable.getArguments(kn.OPTION),t.mountable.getArguments(kn.OPTION_QUERY))}var NW=class extends f.Modal{content;options;mb;constructor(e,t,n){super(e.app),this.mb=e,this.options=n,this.content=t,t.setModal(this)}onOpen(){this.options?.title&&this.titleEl.setText(this.options.title),this.options?.classes&&this.mb.domHelpers.addClasses(this.modalEl,this.options.classes),this.content.mount(this.contentEl)}onClose(){this.content.unmount()}},PW=class extends f.FuzzySuggestModal{content;constructor(e,t){super(e.app),this.content=t}renderSuggestion(e,t){(0,f.renderResults)(t.createDiv(),this.content.getItemText(e.item),e.match);let n=this.content.getItemDescription(e.item);n&&(0,f.renderResults)(t.createEl(`small`,{cls:`mb-search-modal-element-description`}),n,{score:0,matches:[]})}getItems(){return this.content.getItems()}getItemText(e){return this.content.getItemText(e)}onChooseItem(e,t){this.content.onSelected(e)}};function FW(e,t,n,r,i){let a=[];for(let e of n)a.push(new OW(e.value,e.name,`option`));if(r.length>0){let n;try{n=jH(e)}catch(e){return new f.Notice(`meta-bind | Dataview needs to be installed and enabled to use suggest option queries. Check the console for more information.`),console.warn(`meta-bind | failed to get dataview api`,e),a}let o=Zg({name:hg().min(1),path:hg().min(1)});for(let e of r)n.pages(e.value,t).forEach(e=>{try{let t=e.file;if(!o.safeParse(t).success)return;let n=Iv(t.path,t.name,i);a.push(new OW(n,t.name,`file: ${t.path}`))}catch(e){console.warn(`meta-bind | error while computing suggest options`,e)}})}return a}function IW(e,t){let n=t.mountable.getArguments(kn.OPTION),r=t.mountable.getArguments(kn.OPTION_QUERY),i=t.mountable.getArgument(kn.USE_LINKS);return FW(e,t.mountable.getFilePath(),n,r,i===void 0?jn.TRUE:i.value)}var LW=class{menu;domHelpers;constructor(e){this.menu=new f.Menu,this.domHelpers=e}setItems(e){for(let t of e)this.menu.addItem(e=>{e.setTitle(t.name),t.icon&&e.setIcon(t.icon),t.warning&&e.setWarning(t.warning),e.onClick(t.onclick)})}show(e,t){this.menu.showAtPosition({x:e,y:t},this.domHelpers.activeDocument)}showAtElement(e){this.menu.showAtPosition({x:e.getBoundingClientRect().right,y:e.getBoundingClientRect().bottom},this.domHelpers.activeDocument)}showWithEvent(e){this.menu.showAtMouseEvent(e),e.stopImmediatePropagation(),e.preventDefault()}},RW=class{mb;containerEl;filePath;jsEngine;code;hidden;renderComponent;constructor(e,t,n,r,i){this.mb=e,this.containerEl=t,this.filePath=n,this.code=r,this.hidden=i,this.jsEngine=MH(this.mb),this.renderComponent=new f.Component}async evaluateCode(e){let t=await this.jsEngine.internal.getContextForMarkdownOther(this.filePath);return this.jsEngine.internal.execute({code:this.code,context:t,container:this.containerEl,component:this.renderComponent,contextOverrides:e})}async evaluate(e){try{this.mb.domHelpers.empty(this.containerEl),this.mb.domHelpers.removeClass(this.containerEl,`mb-error`),this.renderComponent.unload(),this.renderComponent=new f.Component,this.renderComponent.load();let t=await this.evaluateCode(e),n=this.jsEngine.internal.createRenderer(this.containerEl,this.filePath,this.renderComponent);return this.hidden||await n.render(t.result),n.convertToSimpleObject(t.result)}catch(e){e instanceof Error&&(this.containerEl.innerText=e.message,this.mb.domHelpers.addClass(this.containerEl,`mb-error`));return}}unload(){this.renderComponent.unload()}},zW=class extends EW{omb;app;constructor(e){super(e),this.omb=e,this.app=e.app}getLifecycleHookValidator(){return P_(f.Component)}getImageSuggesterOptions(e){return MW(this.omb,e)}getSuggesterOptions(e){return IW(this.omb,e)}async renderMarkdown(e,t,n){let r=new f.Component;return r.load(),await f.MarkdownRenderer.render(this.app,e,t,n,r),()=>r.unload()}executeCommandById(e){return this.app.commands.executeCommandById(e)}isJsEngineAvailable(){try{return MH(this.omb),!0}catch{return!1}}async jsEngineRunFile(e,t,n,r){let i=MH(this.omb),a=await i.internal.getContextForMarkdownCallingJSFile(t,e),o=new f.Component;return await i.internal.executeFile(e,{component:o,container:r,context:a,contextOverrides:n}),()=>o.unload()}async jsEngineRunCode(e,t,n,r){let i=MH(this.omb),a=await i.internal.getContextForMarkdownOther(t),o=new f.Component;return await i.internal.execute({code:e,component:o,container:r,context:a,contextOverrides:n}),()=>o.unload()}async jsEngineExecuteCustom(e,t,n){return MH(this.omb).internal.executeCustom(e,t,n)}createJsRenderer(e,t,n,r){return new RW(this.omb,e,t,n,r)}showNotice(e){new f.Notice(e)}parseYaml(e){return(0,f.parseYaml)(e)}stringifyYaml(e){return(0,f.stringifyYaml)(e)}setIcon(e,t){(0,f.setIcon)(e,t)}imagePathToUri(e){return this.app.vault.adapter.getResourcePath(e)}createModal(e,t){return new NW(this.omb,e,t)}createSearchModal(e){return new PW(this.omb,e)}getAllCommands(){return this.app.commands.listCommands().map(e=>({id:e.id,name:e.name}))}createFuzzySearch(){return new DW}createContextMenu(e){let t=new LW(this.omb.domHelpers);return t.setItems(e),t}createDate(e,t){return(0,f.moment)(e,t)}async evaluateTemplaterTemplate(e,t){let n=PH(this.omb),r=this.app.vault.getAbstractFileByPath(e);if(!r||!(r instanceof f.TFile))throw Error(`Template file not found: ${e}`);let i=this.app.vault.getAbstractFileByPath(t);if(!i||!(i instanceof f.TFile))throw Error(`Target file not found: ${t}`);let a=n.create_running_config(r,i,NH.DynamicProcessor);return await n.read_and_parse_template(a)}async createNoteWithTemplater(e,t,n,r=!1,i=!1){let a=PH(this.omb),o=this.app.vault.getAbstractFileByPath(e);if(!o||!(o instanceof f.TFile))throw Error(`Template file not found: ${e}`);let s;if(t!==void 0){let e=this.app.vault.getAbstractFileByPath(t);if(!e||!(e instanceof f.TFolder))throw Error(`Folder not found: ${t}`);s=e}let c=await a.create_new_note_from_template(o,s,n,!1);return r&&c&&await this.mb.file.openInSourceMode(c,i),c?.path}},BW=class extends mV{mb;constructor(e,t,n){super(t,n),this.mb=e,this.mb.plugin.registerEvent(this.mb.app.metadataCache.on(`changed`,(e,t,n)=>{this.manager.onExternalUpdate(this,e.path,structuredClone(n.frontmatter)??{})}))}readExternal(e){let t=this.mb.app.vault.getAbstractFileByPath(e);if(t==null||!(t instanceof f.TFile))throw new ve({errorLevel:z.CRITICAL,effect:`can not get default cache item`,cause:`no file for path "${e}" found or path is not a file`});let n=this.mb.app.metadataCache.getFileCache(t)?.frontmatter;return structuredClone(n)??{}}getDefaultCacheItem(e){let t=this.mb.app.vault.getAbstractFileByPath(e);if(t==null||!(t instanceof f.TFile))throw new ve({errorLevel:z.CRITICAL,effect:`can not get default cache item`,cause:`no file for path "${e}" found or path is not a file`});let n=this.mb.app.metadataCache.getFileCache(t)?.frontmatter;return{data:structuredClone(n)??{},storagePath:e,file:t,...this.manager.constructDefaultCacheItem()}}async syncExternal(e){return this.mb.app.fileManager.processFrontMatter(e.file,t=>{Object.assign(t,e.data)})}},VW=class extends me{ctx;element;constructor(e,t){super(void 0),this.ctx=e,this.element=t}getPosition(){let e=this.ctx.getSectionInfo(this.element);if(e)return{lineStart:e.lineStart,lineEnd:e.lineEnd}}};function HW(e,t){ii(t,!0);let n=new hH(t.mb,E(),``,fe.BLOCK,t.declaration);vH(e,{get mountable(){return n}}),ai()}var UW=G(`

`);function WW(e,t){ii(t,!0);let n=t.mb.api.createInlineFieldFromString(t.declaration.inputField,``,void 0,fe.BLOCK),r=t.mb.api.createInlineFieldFromString(t.declaration.declaration,``,void 0,fe.BLOCK);var i=UW(),a=H(i),o=H(a,!0);V(a);var s=U(a,2);vH(s,{get mountable(){return n}});var c=U(s,2);vH(c,{get mountable(){return r}});var l=U(c,2),u=H(l,!0);V(l),V(i),Xa(()=>{os(o,t.declaration.title),os(u,t.declaration.display)}),K(e,i),ai()}var GW=G(`

Meta Bind Playground

`,1),KW=G(`

Quick Reference

Error Messages

When creating Input Fields or View Fields warnings ( ) and errors ( ) can occur. These are clickable and will show a modal with detailed information about the error when clicked.

Unloaded Message

A message like this [MB_UNLOADED] ... means that Obsidian told Meta Bind to unload the field that was once displayed there. This usually happens when Meta Bind was disabled, such as after a plugin update, or when another plugin is interfering with Meta Bind.

Usually reopening the note or restarting Obsidian causes the field to display normally again.

Bind Targets

Bind Targets let the plugin know what frontmatter properties to bind Input Fields and View Fields to.

Playground

Input Fields

Input Fields let you change the frontmatter of your notes from inside of notes.

View Fields

View Fields let you view and perform calculations using the frontmatter of your notes from inside of notes. They will update instantly to reflect changes to the frontmatter made by input fields and as fast as obsidian allows it for changes from other sources.

`);function qW(e,t){ii(t,!0);let n=va(new Tn(`exampleWarningErrorCollection`)),r=va(new Tn(`exampleErrorErrorCollection`));rc(()=>{n.add(new Te({errorLevel:z.WARNING,effect:`some example warning`,cause:`some example reason`})),r.add(new Te({errorLevel:z.ERROR,effect:`some example error`,cause:`some example reason`}))});var i=KW(),a=H(i);wU(a,{children:(e,t)=>{var n=GW(),r=U(ka(n),2),i=H(r);Ac(i,{get variant(){return Lt.PRIMARY},onclick:()=>{$l.open($l.linkToHome())},children:(e,t)=>{Gr(),K(e,is(`Docs`))},$$slots:{default:!0}});var a=U(i,2);Ac(a,{onclick:()=>{$l.open($l.linkToGithub())},children:(e,t)=>{Gr(),K(e,is(`GitHub`))},$$slots:{default:!0}}),Ac(U(a,2),{onclick:()=>{$l.open($l.linkToIssues())},children:(e,t)=>{Gr(),K(e,is(`Report Issue`))},$$slots:{default:!0}}),V(r),K(e,n)},$$slots:{default:!0}});var o=U(a,6),s=U(H(o)),c=U(s,2),l=U(c,4);{let e=Mi(()=>({errorCollection:n,code:`INPUT[someInputFieldDeclaration]`}));CW(l,{get mb(){return t.mb},get settings(){return W(e)}})}var u=U(l,4);{let e=Mi(()=>({errorCollection:r,code:`INPUT[someInputFieldDeclaration]`}));CW(u,{get mb(){return t.mb},get settings(){return W(e)}})}Gr(3),V(o);var d=U(o,10),f=U(H(d),2),p=U(f,2);Gr(),V(d);var m=U(d,6),h=H(m);Gr(),V(m);var g=U(m,2);vs(g,17,()=>DV(t.mb),ms,(e,n)=>{HW(e,{get declaration(){return W(n)[1]},get mb(){return t.mb}})});var _=U(g,4),v=H(_);Gr(),V(_),vs(U(_,2),17,()=>Object.values(EV),ms,(e,n)=>{var r=as();vs(ka(r),17,()=>W(n),ms,(e,n)=>{WW(e,{get declaration(){return W(n)},get mb(){return t.mb}})}),K(e,r)}),V(i),Xa((e,t,n,r,i,a)=>{qs(s,`href`,e),qs(c,`href`,t),qs(f,`href`,n),qs(p,`href`,r),qs(h,`href`,i),qs(v,`href`,a)},[()=>$l.linkToInputFields(),()=>$l.linkToViewFields(),()=>$l.linkToInputFields(),()=>$l.linkToViewFields(),()=>$l.linkToInputFields(),()=>$l.linkToViewFields()]),K(e,i),ai()}var JW=`mb-playground-view-type`,YW=class extends f.ItemView{component;mb;constructor(e,t){super(e),this.mb=t}getViewType(){return JW}getDisplayText(){return`Meta Bind playground`}async onOpen(){this.contentEl.empty(),this.component=ss(qW,{target:this.contentEl,props:{mb:this.mb}})}async onClose(){this.component&&ds(this.component)}};function XW(e,t){return{type:`list`,heading:t.heading,emptyState:t.emptyState,items:t.items.map((e,n)=>t.renderItem(e,n)),addItem:{name:t.addItems.label,action:n=>{t.addItems.type===`single`?t.addItems.action():e.internal.createContextMenu(t.addItems.options.map(e=>({name:e.label,onclick:()=>{e.action()}}))).showAtElement(n)}},onDelete:e=>{QW(t.items,t=>{t.splice(e,1)},t.applyItems,t.onUpdate)},onReorder:(e,n)=>{QW(t.items,t=>{$W(t,e,n)},t.applyItems,t.onUpdate)}}}function ZW(e,t){return e instanceof _e?e.cause instanceof Error?e.cause.message:e.cause:e instanceof Error?e.message:t}function QW(e,t,n,r){let i=structuredClone(e);return t(i),n(i)?(r(),!0):!1}function $W(e,t,n){let[r]=e.splice(t,1);e.splice(n,0,r)}var eG=class{mb;onUpdate;constructor(e,t){this.mb=e,this.onUpdate=t}getDisplayValue(){let e=this.mb.getSettings().buttonTemplates.length;return`${e} template${e===1?``:`s`}`}getStatus(){let e=this.mb.getSettings().buttonTemplates;return e.some((t,n)=>this.getButtonTemplateWarning(t,n,e)!==null)?`warning`:null}getDefinitions(){let e=this.mb.getSettings().buttonTemplates;return[XW(this.mb,{heading:`Templates`,emptyState:`No button templates configured.`,items:e,addItems:{type:`multiple`,label:`Add`,options:[{label:`Create new template`,action:()=>{this.mb.internal.openButtonBuilderModal({submitText:`Add`,config:this.createDefaultButtonTemplate(),onOkay:e=>{QW(this.mb.getSettings().buttonTemplates,t=>{t.push(e)},e=>this.applyButtonTemplates(e),this.onUpdate)}})}},{label:`From clipboard`,action:()=>{this.addButtonTemplateFromClipboard()}}]},renderItem:(e,t)=>this.getButtonTemplateSetting(e,t),applyItems:e=>this.applyButtonTemplates(e),onUpdate:this.onUpdate})]}getButtonTemplateSetting(e,t){let n=e.actions?.length??+!!e.action,r=this.getButtonTemplateWarning(e,t,this.mb.getSettings().buttonTemplates);return{name:e.id??e.label??`Button template ${t+1}`,desc:r??`${e.label??`No label`} - ${n} action${n===1?``:`s`}`,searchable:!0,aliases:[e.id,e.label,e.tooltip].filter(e=>e!==void 0),render:n=>{r!==null&&n.addDisplayValue(e=>{e.setValue(`Invalid`).setStatus(`warning`)}),n.addExtraButton(n=>{n.setIcon(`pencil`),n.setTooltip(`Edit template`),n.onClick(()=>{this.mb.internal.openButtonBuilderModal({submitText:`Submit`,config:structuredClone(e),onOkay:e=>{QW(this.mb.getSettings().buttonTemplates,n=>{n[t]=e},e=>this.applyButtonTemplates(e),this.onUpdate)}})})}),n.addExtraButton(t=>{t.setIcon(`copy`),t.setTooltip(`Copy template YAML`),t.onClick(()=>{navigator.clipboard.writeText((0,f.stringifyYaml)(e)),new f.Notice(`meta-bind | Copied to clipboard`)})})}}}getButtonTemplateWarning(e,t,n){try{this.mb.buttonParser.validateConfig(e)}catch(e){return ZW(e,`This button template is invalid.`)}return e.id===void 0||e.id===``?`Button templates must have an ID.`:n.some((n,r)=>r!==t&&n.id===e.id)?`The button ID "${e.id}" is used by another template.`:null}applyButtonTemplates(e){let t=this.mb.getSettings().buttonTemplates,n=this.mb.buttonManager.setButtonTemplates(e);if(n.hasErrors()){let e=n.getErrors();return this.mb.buttonManager.setButtonTemplates(t),console.warn(`meta-bind | failed to save button templates`,e),new f.Notice(`meta-bind | Button template could not be saved: ${e[0]?.message??`Unknown validation error.`}`),!1}return this.mb.updateSettings(t=>{t.buttonTemplates=e}),!0}async addButtonTemplateFromClipboard(){let e;try{e=this.mb.buttonParser.parseConfig(await navigator.clipboard.readText()),(e.id===void 0||e.id===``)&&(e.id=this.createUniqueButtonTemplateId())}catch(e){console.warn(e),new f.Notice(`meta-bind | Can not parse button config. Check your button syntax.`);return}this.mb.internal.openButtonBuilderModal({submitText:`Add`,config:e,onOkay:e=>{QW(this.mb.getSettings().buttonTemplates,t=>{t.push(e)},e=>this.applyButtonTemplates(e),this.onUpdate)}})}createDefaultButtonTemplate(){return{...this.mb.buttonActionRunner.createDefaultButtonConfig(),id:this.createUniqueButtonTemplateId()}}createUniqueButtonTemplateId(){let e=new Set(this.mb.getSettings().buttonTemplates.map(e=>e.id).filter(e=>e)),t=`button-template`,n=t,r=2;for(;e.has(n);)n=`${t}-${r}`,r+=1;return n}},tG=class extends f.AbstractInputSuggest{inputEl;constructor(e,t){super(e,t),this.inputEl=t}getSuggestions(e){let t=e.toLowerCase();return this.app.vault.getAllFolders().filter(e=>e.path.toLowerCase().includes(t)).slice(0,1e3)}renderSuggestion(e,t){t.setText(e.path)}selectSuggestion(e){this.setValue(e.path),this.inputEl.trigger(`input`),this.close()}},nG=class extends f.Modal{initialFolder;onSubmit;draft;constructor(e,t,n){super(e),this.initialFolder=t??``,this.draft=this.initialFolder,this.onSubmit=n}onOpen(){this.contentEl.empty(),this.setTitle(this.initialFolder===``?`Add excluded folder`:`Edit excluded folder`),new f.Setting(this.contentEl).setName(`Folder path`).addText(e=>{new tG(this.app,e.inputEl),e.setPlaceholder(`path/to/folder`),e.setValue(this.draft),e.onChange(e=>{this.draft=e})}),this.addModalButtons()}addModalButtons(){new f.Setting(this.contentEl).addButton(e=>{e.setCta(),e.setButtonText(`Save`),e.onClick(()=>{if(this.draft===``){new f.Notice(`meta-bind | Folder path may not be empty.`);return}this.onSubmit(this.draft),this.close()})}).addButton(e=>{e.setButtonText(`Cancel`),e.onClick(()=>{this.close()})})}},rG=class{app;mb;onUpdate;constructor(e,t,n){this.app=e,this.mb=t,this.onUpdate=n}getDisplayValue(){let e=this.mb.getSettings().excludedFolders.length;return`${e} folder${e===1?``:`s`}`}getStatus(){return this.mb.getSettings().excludedFolders.some(e=>this.getFolderWarning(e)!==null)?`warning`:null}getDefinitions(){let e=this.mb.getSettings().excludedFolders;return[XW(this.mb,{heading:`Folders`,emptyState:`No excluded folders configured.`,items:e,addItems:{type:`single`,label:`Add folder`,action:()=>{this.openExcludedFolderModal(void 0,e=>{QW(this.mb.getSettings().excludedFolders,t=>{t.push(e)},e=>this.applyExcludedFolders(e),this.onUpdate)})}},renderItem:(e,t)=>this.getExcludedFolderSetting(e,t),applyItems:e=>this.applyExcludedFolders(e),onUpdate:this.onUpdate})]}getExcludedFolderSetting(e,t){let n=this.getFolderWarning(e);return{name:e||`Excluded folder ${t+1}`,desc:n??`Plugin behavior is disabled in this folder.`,searchable:e!==``,render:r=>{n!==null&&r.addDisplayValue(t=>{t.setValue(e===``?`Invalid`:`Missing`).setStatus(`warning`)}),r.addExtraButton(n=>{n.setIcon(`pencil`),n.setTooltip(`Edit folder`),n.onClick(()=>{this.openExcludedFolderModal(e,e=>{QW(this.mb.getSettings().excludedFolders,n=>{n[t]=e},e=>this.applyExcludedFolders(e),this.onUpdate)})})})}}}getFolderWarning(e){return e===``?`Folder path may not be empty.`:this.app.workspace.layoutReady&&this.app.vault.getFolderByPath(e)===null?`This folder does not exist in the vault.`:null}applyExcludedFolders(e){return this.mb.updateSettings(t=>{t.excludedFolders=e}),!0}openExcludedFolderModal(e,t){new nG(this.app,e,t).open()}},iG=class extends f.Modal{initialTemplate;onSubmit;draft;constructor(e,t,n){super(e),this.initialTemplate=structuredClone(t??{name:``,declaration:``}),this.draft=structuredClone(this.initialTemplate),this.onSubmit=n}onOpen(){this.contentEl.empty(),this.setTitle(this.initialTemplate.name===``?`Add input field template`:`Edit input field template`),new f.Setting(this.contentEl).setName(`Name`).addText(e=>{e.setPlaceholder(`template-name`),e.setValue(this.draft.name),e.onChange(e=>{this.draft.name=e})}),new f.Setting(this.contentEl).setName(`Declaration`).setDesc(`Template declaration used after the template name.`).addTextArea(e=>{e.setPlaceholder(`INPUT[slider(addLabels)]`),e.setValue(this.draft.declaration),e.inputEl.addClass(`mb-settings-list-modal-textarea`),e.onChange(e=>{this.draft.declaration=e})}),this.addModalButtons()}addModalButtons(){new f.Setting(this.contentEl).addButton(e=>{e.setCta(),e.setButtonText(`Save`),e.onClick(()=>{this.onSubmit(structuredClone(this.draft))!==!1&&this.close()})}).addButton(e=>{e.setButtonText(`Cancel`),e.onClick(()=>{this.close()})})}},aG=class{app;mb;onUpdate;constructor(e,t,n){this.app=e,this.mb=t,this.onUpdate=n}getDisplayValue(){let e=this.mb.getSettings().inputFieldTemplates.length;return`${e} template${e===1?``:`s`}`}getStatus(){let e=this.mb.getSettings().inputFieldTemplates;return e.some((t,n)=>this.getInputFieldTemplateWarning(t,n,e)!==null)?`warning`:null}getDefinitions(){let e=this.mb.getSettings().inputFieldTemplates;return[XW(this.mb,{heading:`Templates`,emptyState:`No input field templates configured.`,items:e,addItems:{type:`single`,label:`Add template`,action:()=>{this.openInputFieldTemplateModal(void 0,e=>QW(this.mb.getSettings().inputFieldTemplates,t=>{t.push(e)},e=>this.applyInputFieldTemplates(e),this.onUpdate))}},renderItem:(e,t)=>this.getInputFieldTemplateSetting(e,t),applyItems:e=>this.applyInputFieldTemplates(e),onUpdate:this.onUpdate})]}getInputFieldTemplateSetting(e,t){let n=this.getInputFieldTemplateWarning(e,t,this.mb.getSettings().inputFieldTemplates);return{name:e.name||`Input field template ${t+1}`,desc:n??(e.declaration||`No declaration.`),searchable:!0,aliases:[e.name,e.declaration].filter(e=>e!==``),render:r=>{n!==null&&r.addDisplayValue(e=>{e.setValue(`Invalid`).setStatus(`warning`)}),r.addExtraButton(n=>{n.setIcon(`pencil`),n.setTooltip(`Edit template`),n.onClick(()=>{this.openInputFieldTemplateModal(e,e=>QW(this.mb.getSettings().inputFieldTemplates,n=>{n[t]=e},e=>this.applyInputFieldTemplates(e),this.onUpdate))})})}}}getInputFieldTemplateWarning(e,t,n){if(e.name===``)return`Input field templates must have a name.`;if(n.some((n,r)=>r!==t&&n.name===e.name))return`The template name "${e.name}" is used by another template.`;let r=this.mb.inputFieldParser.validateTemplate(e).getErrors();return r.length>0?ZW(r[0],`This input field template is invalid.`):null}applyInputFieldTemplates(e){let t=this.mb.getSettings().inputFieldTemplates,n=this.mb.inputFieldParser.parseTemplates(e);if(n.hasErrors()){let e=n.getErrors();return this.mb.inputFieldParser.parseTemplates(t),console.warn(`meta-bind | failed to save input field templates`,e),new f.Notice(`meta-bind | Input field template could not be saved: ${e[0]?.message??`Unknown validation error.`}`),!1}return this.mb.updateSettings(t=>{t.inputFieldTemplates=e}),!0}openInputFieldTemplateModal(e,t){new iG(this.app,e,t).open()}},oG=class extends f.PluginSettingTab{mb;constructor(e,t){super(e,t.plugin),this.mb=t}getSettingDefinitions(){let e=[],t=new aG(this.app,this.mb,()=>this.update()),n=new eG(this.mb,()=>this.update()),r=new rG(this.app,this.mb,()=>this.update());return(this.mb.build===dV.DEV||this.mb.build===dV.CANARY)&&e.push({name:`Development build`,desc:`You are using a ${this.mb.build} build (1.5.1). This build is not intended for production use. Use at your own risk.`,render:e=>{e.setClass(`mb-error`),e.addButton(e=>{e.setCta(),e.setButtonText(`Learn about canary builds`),e.onClick(()=>{$l.open($l.linkToCanaryBuilds())})})}}),e.push({name:`Quick access`,render:e=>{this.addQuickAccessButtons(e)}},{name:`Enable syntax highlighting`,desc:`Enable syntax highlighting for meta bind syntax. Restart required.`,control:{type:`toggle`,key:`enableSyntaxHighlighting`}},{name:`Enable editor right-click menu`,desc:`Enable a meta bind menu section in the editor right-click menu. Restart required.`,control:{type:`toggle`,key:`enableEditorRightClickMenu`}},{name:`Enable JavaScript`,desc:`Enable features that run user written JavaScript. This is potentially DANGEROUS, thus it's disabled by default. Restart required.`,control:{type:`toggle`,key:`enableJs`}},{name:`View fields display null as empty`,desc:`Display nothing instead of null, if the frontmatter value is empty, in text view fields.`,control:{type:`toggle`,key:`viewFieldDisplayNullAsEmpty`}},{type:`page`,name:`Input field templates`,desc:"You can specify input field templates here, and access them using `INPUT[template_name][overrides (optional)]` in your notes.",displayValue:t.getDisplayValue(),status:t.getStatus(),items:t.getDefinitions()},{type:`page`,name:`Button templates`,desc:`You can specify button field templates here, and access them in inline buttons.`,displayValue:n.getDisplayValue(),status:n.getStatus(),items:n.getDefinitions()},{type:`page`,name:`Excluded folders`,desc:`You can specify excluded folders here. The plugin will not work within excluded folders.`,displayValue:r.getDisplayValue(),status:r.getStatus(),items:r.getDefinitions()},{type:`group`,heading:`Date and time`,items:[{name:`Date format`,desc:`The date format to be used by this plugin. Changing this setting will break the parsing of existing date inputs. Here is a list of all available date tokes https://momentjs.com/docs/#/displaying/.`,control:{type:`text`,key:`preferredDateFormat`}},{name:`First weekday`,desc:`Specify the first weekday for the datepicker.`,control:{type:`dropdown`,key:`firstWeekday`,options:Object.fromEntries(m.map(e=>[e.name,e.name]))}}]},{type:`group`,heading:`Advanced`,items:[{name:`Dev mode`,desc:`Enable dev mode. Not recommended unless you want to debug this plugin.`,control:{type:`toggle`,key:`devMode`}},{name:`Disable code block restrictions`,desc:`Disable restrictions on which input fields can be created in which code blocks. Not recommended unless you know what you are doing.`,control:{type:`toggle`,key:`ignoreCodeBlockRestrictions`}},{name:`Sync interval`,desc:`The interval in milli-seconds between disk writes. Changing this number is not recommended except if your hard drive is exceptionally slow. Standard: ${_.syncInterval}; Minimum: 50; Maximum: ${v}`,control:{type:`number`,key:`syncInterval`,defaultValue:_.syncInterval,min:50,max:v,step:1,validate:e=>{if(e<50||e>1e3)return`Sync interval must be between 50 and ${v}.`}}}]}),e}getControlValue(e){return this.mb.getSettings()[e]}setControlValue(e,t){this.mb.updateSettings(n=>{n[e]=t})}display(){let{containerEl:e}=this;e.empty(),e.createEl(`p`,{text:`Meta Bind settings require Obsidian 1.13.0 or newer. This app appears to be running an older version.`})}addQuickAccessButtons(e){e.addButton(e=>{e.setCta(),e.setButtonText(`Docs`),e.onClick(()=>{$l.open($l.linkToHome())})}).addButton(e=>{e.setButtonText(`Open FAQ`),e.onClick(()=>{this.mb.activateView(JW)})}).addButton(e=>{e.setButtonText(`GitHub`),e.onClick(()=>{$l.open($l.linkToGithub())})}).addButton(e=>{e.setButtonText(`Report issue`),e.onClick(()=>{$l.open($l.linkToIssues())})})}},sG=class extends pV{get activeDocument(){return activeDocument}},cG=class extends fV{app;plugin;dependencyManager;constructor(e){super(),this.app=e.app,this.plugin=e,this.domHelpers=new sG,this.setComponents({api:new IH(this),internal:new zW(this),file:new RH(this)});let t=new oG(this.app,this);this.plugin.addSettingTab(t),this.app.workspace.onLayoutReady(()=>{let e=(0,f.debounce)(()=>t.update(),200,!0);t.update(),this.plugin.registerEvent(this.app.vault.on(`create`,e)),this.plugin.registerEvent(this.app.vault.on(`delete`,e)),this.plugin.registerEvent(this.app.vault.on(`rename`,e))}),this.dependencyManager=new wV(this,[]),this.setUpDependencies(),this.setUpMetadataManager(),this.loadTemplates(),this.addPostProcessors(),this.plugin.registerEditorExtension(xV(this)),this.addCommands(),vV(this),this.plugin.registerView(JW,e=>new YW(e,this)),this.addStatusBarBuildIndicator(),this.getSettings().enableEditorRightClickMenu&&this.plugin.registerEvent(this.app.workspace.on(`editor-menu`,(e,t)=>{AV(e,t,this)}))}setUpDependencies(){this.dependencyManager.dependencies=[{name:`Dataview`,pluginId:`dataview`,minVersion:new CV(0,5,64)},{name:`JS Engine`,pluginId:`js-engine`,minVersion:new CV(0,3,5)},{name:`Templater`,pluginId:`templater-obsidian`,minVersion:new CV(2,2,3)}]}setUpMetadataManager(){this.metadataManager=new Iu,this.metadataManager.registerSource(new BW(this,Ru.FRONTMATTER,this.metadataManager)),this.metadataManager.registerSource(new hV(Ru.MEMORY,this.metadataManager)),this.metadataManager.registerSource(new gV(Ru.GLOBAL_MEMORY,this.metadataManager)),this.metadataManager.registerSource(new _V(Ru.SCOPE,this.metadataManager)),this.metadataManager.setDefaultSource(Ru.FRONTMATTER),this.plugin.registerEvent(this.app.vault.on(`rename`,(e,t)=>{this.mountableManager.unloadFile(t),this.metadataManager.onStoragePathRenamed(t,e.path)})),this.plugin.registerEvent(this.app.vault.on(`delete`,e=>{this.mountableManager.unloadFile(e.path),this.metadataManager.onStoragePathDeleted(e.path)})),this.plugin.registerInterval(window.setInterval(()=>void this.metadataManager.cycle(),this.getSettings().syncInterval))}addPostProcessors(){this.plugin.registerMarkdownPostProcessor((e,t)=>{let n=e.querySelectorAll(`code`),r=t.sourcePath;for(let e=0;e{await(0,f.loadPrism)();let r=t,i=e.trim(),a=n.sourcePath,o=this.api.isInlineFieldDeclarationAndGetType(i);if(o===void 0)return;let s=this.api.createInlineFieldOfTypeFromString(o,i,a,void 0,fe.BLOCK,new VW(n,t));this.api.wrapInMDRC(s,r,n)}),this.plugin.registerMarkdownCodeBlockProcessor(`meta-bind-js-view`,async(e,t,n)=>{await(0,f.loadPrism)();let r=this.api.createJsViewFieldMountable(n.sourcePath,{declaration:e});this.api.wrapInMDRC(r,t,n)}),this.plugin.registerMarkdownCodeBlockProcessor(`meta-bind-embed`,async(e,t,n)=>{await(0,f.loadPrism)();let r=this.api.createEmbedMountable(n.sourcePath,{content:e,depth:0});this.api.wrapInMDRC(r,t,n)});for(let e=1;e<=8;e++)this.plugin.registerMarkdownCodeBlockProcessor(`meta-bind-embed-internal-${e}`,async(t,n,r)=>{await(0,f.loadPrism)();let i=this.api.createEmbedMountable(r.sourcePath,{content:t,depth:e});this.api.wrapInMDRC(i,n,r)});this.plugin.registerMarkdownCodeBlockProcessor(`meta-bind-button`,async(e,t,n)=>{await(0,f.loadPrism)();let r=this.api.createButtonMountable(n.sourcePath,{declaration:e,isPreview:!1,position:new VW(n,t)});this.api.wrapInMDRC(r,t,n)})}addCommands(){this.plugin.addCommand({id:`open-docs`,name:`Open docs`,callback:()=>{window.open(`https://moritzjung.dev/obsidian-meta-bind-plugin-docs/`,`_blank`)}}),this.plugin.addCommand({id:`open-playground`,name:`Open playground`,callback:()=>{this.activateView(JW)}}),this.plugin.addCommand({id:`open-help`,name:`Open help`,callback:()=>{this.activateView(JW)}}),this.plugin.addCommand({id:`open-button-builder`,name:`Open button builder`,callback:()=>{this.internal.openButtonBuilderModal({onOkay:e=>{window.navigator.clipboard.writeText(`\`\`\`meta-bind-button\n${(0,f.stringifyYaml)(e)}\n\`\`\``)},submitText:`Copy to clipboard`})}}),this.plugin.addCommand({id:`copy-command-id`,name:`Select and copy command ID`,callback:()=>{this.internal.openCommandSelectModal(e=>{window.navigator.clipboard.writeText(e.id)})}})}addStatusBarBuildIndicator(){if(this.build===dV.DEV){let e=this.plugin.addStatusBarItem();e.setText(`Meta Bind Dev Build`),e.addClass(`mb-error`),this.plugin.register(()=>e.remove())}if(this.build===dV.CANARY){let e=this.plugin.addStatusBarItem();e.setText(`Meta Bind Canary Build (1.5.1)`),e.addClass(`mb-error`),this.plugin.register(()=>e.remove())}}async activateView(e){let{workspace:t}=this.app,n,r=t.getLeavesOfType(e);r.length>0?n=r[0]:(n=t.getLeaf(`tab`),await n.setViewState({type:e,active:!0})),await t.revealLeaf(n)}getSettings(){return this.plugin.settings}saveSettings(e){this.plugin.settings=e,this.plugin.saveSettings()}},lG=class extends f.Plugin{mb;api;settings;async onload(){await this.loadSettings(),this.mb=new cG(this),this.api=this.mb.api,this.mb.updateInternalSettings(this.settings)}onunload(){this.mb.destroy()}async loadSettings(){let e=await this.loadData()??{};typeof e==`object`&&e&&(delete e.inputTemplates,delete e.useUsDateInputOrder,e.firstWeekday=g(e.firstWeekday)),this.settings=Object.assign({},_,e),C(e,this.settings)||await this.saveSettings()}async saveSettings(){await this.saveData(this.settings)}async onExternalSettingsChange(){await this.loadSettings(),this.mb.updateInternalSettings(this.settings)}};module.exports=lG; /* nosourcemap */