solve-engine 2.8.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/chunk-556Q7VZC.cjs +2 -0
  2. package/dist/chunk-556Q7VZC.cjs.map +1 -0
  3. package/dist/{chunk-CIENDLKV.cjs → chunk-6ILXAGWX.cjs} +2 -2
  4. package/dist/{chunk-CIENDLKV.cjs.map → chunk-6ILXAGWX.cjs.map} +1 -1
  5. package/dist/{chunk-YORX7723.cjs → chunk-7VJN65QP.cjs} +3 -3
  6. package/dist/{chunk-YORX7723.cjs.map → chunk-7VJN65QP.cjs.map} +1 -1
  7. package/dist/{chunk-U47GA63S.cjs → chunk-AEPS7W3D.cjs} +3 -3
  8. package/dist/chunk-AEPS7W3D.cjs.map +1 -0
  9. package/dist/chunk-HE7E6M5O.js +3 -0
  10. package/dist/chunk-HE7E6M5O.js.map +1 -0
  11. package/dist/chunk-K4MME6ZT.js +2 -0
  12. package/dist/chunk-K4MME6ZT.js.map +1 -0
  13. package/dist/{chunk-GAAXTO4K.js → chunk-N46DFZLZ.js} +3 -3
  14. package/dist/{chunk-GAAXTO4K.js.map → chunk-N46DFZLZ.js.map} +1 -1
  15. package/dist/{chunk-UKDUFMT5.js → chunk-OVNB7MI5.js} +2 -2
  16. package/dist/{chunk-UKDUFMT5.js.map → chunk-OVNB7MI5.js.map} +1 -1
  17. package/dist/{chunk-OZ6SKIPD.cjs → chunk-OWQF6ZOK.cjs} +4 -4
  18. package/dist/{chunk-OZ6SKIPD.cjs.map → chunk-OWQF6ZOK.cjs.map} +1 -1
  19. package/dist/{chunk-2V44X7GH.js → chunk-P7XWFT45.js} +3 -3
  20. package/dist/{chunk-2V44X7GH.js.map → chunk-P7XWFT45.js.map} +1 -1
  21. package/dist/constants.cjs +1 -1
  22. package/dist/constants.js +1 -1
  23. package/dist/engine.cjs +1 -1
  24. package/dist/engine.js +1 -1
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/packages.cjs +1 -1
  28. package/dist/packages.d.cts +1 -1
  29. package/dist/packages.d.ts +1 -1
  30. package/dist/packages.js +1 -1
  31. package/dist/testing.cjs +2 -2
  32. package/dist/testing.js +1 -1
  33. package/dist/vm.cjs +1 -1
  34. package/dist/vm.js +1 -1
  35. package/dist/worker.cjs +2 -2
  36. package/dist/worker.js +1 -1
  37. package/package.json +1 -1
  38. package/dist/chunk-EOMHELRL.js +0 -2
  39. package/dist/chunk-EOMHELRL.js.map +0 -1
  40. package/dist/chunk-HDVZZ7JN.js +0 -3
  41. package/dist/chunk-HDVZZ7JN.js.map +0 -1
  42. package/dist/chunk-TUBLMUTZ.cjs +0 -2
  43. package/dist/chunk-TUBLMUTZ.cjs.map +0 -1
  44. package/dist/chunk-U47GA63S.cjs.map +0 -1
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkCIENDLKV_cjs=require('./chunk-CIENDLKV.cjs');require('./chunk-SOMGSIO4.cjs');Object.defineProperty(exports,"ConfigManager",{enumerable:true,get:function(){return chunkCIENDLKV_cjs.d}});Object.defineProperty(exports,"DEFAULT_CONFIG",{enumerable:true,get:function(){return chunkCIENDLKV_cjs.b}});Object.defineProperty(exports,"ENGINE_VERSION",{enumerable:true,get:function(){return chunkCIENDLKV_cjs.a}});//# sourceMappingURL=constants.cjs.map
1
+ 'use strict';var chunk6ILXAGWX_cjs=require('./chunk-6ILXAGWX.cjs');require('./chunk-SOMGSIO4.cjs');Object.defineProperty(exports,"ConfigManager",{enumerable:true,get:function(){return chunk6ILXAGWX_cjs.d}});Object.defineProperty(exports,"DEFAULT_CONFIG",{enumerable:true,get:function(){return chunk6ILXAGWX_cjs.b}});Object.defineProperty(exports,"ENGINE_VERSION",{enumerable:true,get:function(){return chunk6ILXAGWX_cjs.a}});//# sourceMappingURL=constants.cjs.map
2
2
  //# sourceMappingURL=constants.cjs.map
package/dist/constants.js CHANGED
@@ -1,2 +1,2 @@
1
- export{d as ConfigManager,b as DEFAULT_CONFIG,a as ENGINE_VERSION}from'./chunk-UKDUFMT5.js';import'./chunk-MPB7KUN5.js';//# sourceMappingURL=constants.js.map
1
+ export{d as ConfigManager,b as DEFAULT_CONFIG,a as ENGINE_VERSION}from'./chunk-OVNB7MI5.js';import'./chunk-MPB7KUN5.js';//# sourceMappingURL=constants.js.map
2
2
  //# sourceMappingURL=constants.js.map
package/dist/engine.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkYORX7723_cjs=require('./chunk-YORX7723.cjs');require('./chunk-EFJCC6FJ.cjs');var chunkOZ6SKIPD_cjs=require('./chunk-OZ6SKIPD.cjs');require('./chunk-FNNIAJNY.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-LNZNJSRW.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-TUBLMUTZ.cjs'),require('./chunk-MVP2YD4X.cjs'),require('./chunk-6TPXH6Y5.cjs'),require('./chunk-R2SZFJTT.cjs'),require('./chunk-WYIOXAFW.cjs'),require('./chunk-4QVBSG6B.cjs'),require('./chunk-C65UDMWH.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-EURCQMZK.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-VBSMA7WJ.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-5TVI2UPZ.cjs'),require('./chunk-75XDS65A.cjs'),require('./chunk-PNDQRCRQ.cjs'),require('./chunk-BKSKZA4W.cjs'),require('./chunk-CIENDLKV.cjs'),require('./chunk-3HYO3QYW.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-SNVPM27Q.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-WEAKI5V5.cjs'),require('./chunk-6QRHN3I6.cjs'),require('./chunk-SOMGSIO4.cjs');Object.defineProperty(exports,"DocumentModel",{enumerable:true,get:function(){return chunkYORX7723_cjs.a}});Object.defineProperty(exports,"EvalTier",{enumerable:true,get:function(){return chunkYORX7723_cjs.b}});Object.defineProperty(exports,"ThreeTierEvaluator",{enumerable:true,get:function(){return chunkYORX7723_cjs.c}});Object.defineProperty(exports,"evaluateDocument",{enumerable:true,get:function(){return chunkYORX7723_cjs.d}});Object.defineProperty(exports,"AsyncResolutionBatcher",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.h}});Object.defineProperty(exports,"ExpressionEngine",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.n}});Object.defineProperty(exports,"SNAPSHOT_FORMAT",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.d}});Object.defineProperty(exports,"SNAPSHOT_VERSION",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.e}});Object.defineProperty(exports,"SnapshotErrorCodes",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.f}});Object.defineProperty(exports,"checkExpressionComplexity",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.j}});Object.defineProperty(exports,"checkExpressionLength",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.i}});Object.defineProperty(exports,"extractReadsAndWrites",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.k}});Object.defineProperty(exports,"findInlineSolvesInLine",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.m}});Object.defineProperty(exports,"isEmptyLine",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.l}});//# sourceMappingURL=engine.cjs.map
1
+ 'use strict';var chunk7VJN65QP_cjs=require('./chunk-7VJN65QP.cjs');require('./chunk-EFJCC6FJ.cjs');var chunkOWQF6ZOK_cjs=require('./chunk-OWQF6ZOK.cjs');require('./chunk-FNNIAJNY.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-LNZNJSRW.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-556Q7VZC.cjs'),require('./chunk-MVP2YD4X.cjs'),require('./chunk-6TPXH6Y5.cjs'),require('./chunk-R2SZFJTT.cjs'),require('./chunk-WYIOXAFW.cjs'),require('./chunk-4QVBSG6B.cjs'),require('./chunk-C65UDMWH.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-EURCQMZK.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-VBSMA7WJ.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-5TVI2UPZ.cjs'),require('./chunk-75XDS65A.cjs'),require('./chunk-PNDQRCRQ.cjs'),require('./chunk-BKSKZA4W.cjs'),require('./chunk-6ILXAGWX.cjs'),require('./chunk-3HYO3QYW.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-SNVPM27Q.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-WEAKI5V5.cjs'),require('./chunk-6QRHN3I6.cjs'),require('./chunk-SOMGSIO4.cjs');Object.defineProperty(exports,"DocumentModel",{enumerable:true,get:function(){return chunk7VJN65QP_cjs.a}});Object.defineProperty(exports,"EvalTier",{enumerable:true,get:function(){return chunk7VJN65QP_cjs.b}});Object.defineProperty(exports,"ThreeTierEvaluator",{enumerable:true,get:function(){return chunk7VJN65QP_cjs.c}});Object.defineProperty(exports,"evaluateDocument",{enumerable:true,get:function(){return chunk7VJN65QP_cjs.d}});Object.defineProperty(exports,"AsyncResolutionBatcher",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.h}});Object.defineProperty(exports,"ExpressionEngine",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.n}});Object.defineProperty(exports,"SNAPSHOT_FORMAT",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.d}});Object.defineProperty(exports,"SNAPSHOT_VERSION",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.e}});Object.defineProperty(exports,"SnapshotErrorCodes",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.f}});Object.defineProperty(exports,"checkExpressionComplexity",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.j}});Object.defineProperty(exports,"checkExpressionLength",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.i}});Object.defineProperty(exports,"extractReadsAndWrites",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.k}});Object.defineProperty(exports,"findInlineSolvesInLine",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.m}});Object.defineProperty(exports,"isEmptyLine",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.l}});//# sourceMappingURL=engine.cjs.map
2
2
  //# sourceMappingURL=engine.cjs.map
package/dist/engine.js CHANGED
@@ -1,2 +1,2 @@
1
- export{a as DocumentModel,b as EvalTier,c as ThreeTierEvaluator,d as evaluateDocument}from'./chunk-GAAXTO4K.js';import'./chunk-RAF57WYO.js';export{h as AsyncResolutionBatcher,n as ExpressionEngine,d as SNAPSHOT_FORMAT,e as SNAPSHOT_VERSION,f as SnapshotErrorCodes,j as checkExpressionComplexity,i as checkExpressionLength,k as extractReadsAndWrites,m as findInlineSolvesInLine,l as isEmptyLine}from'./chunk-2V44X7GH.js';import'./chunk-JQBG3LX4.js';import'./chunk-2RWAXT6O.js';import'./chunk-7E7NXKQ5.js';import'./chunk-MIQBJGGR.js';import'./chunk-EOMHELRL.js';import'./chunk-KHCNMNZZ.js';import'./chunk-LH7URJZT.js';import'./chunk-XEIDV5JP.js';import'./chunk-T3FBAFRR.js';import'./chunk-YVKHEAFT.js';import'./chunk-3GAWAMT4.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-YTCTUBR2.js';import'./chunk-YAYBVVG2.js';import'./chunk-YNMMRH44.js';import'./chunk-HFKDWQUL.js';import'./chunk-5TCSFTZD.js';import'./chunk-WTEXBPBR.js';import'./chunk-A33K7NY4.js';import'./chunk-DLAKPF5T.js';import'./chunk-UKDUFMT5.js';import'./chunk-QYO7IEPR.js';import'./chunk-JPFCXLJV.js';import'./chunk-GMSBBLUQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-UWAXJX5G.js';import'./chunk-44EOEWGP.js';import'./chunk-MPB7KUN5.js';//# sourceMappingURL=engine.js.map
1
+ export{a as DocumentModel,b as EvalTier,c as ThreeTierEvaluator,d as evaluateDocument}from'./chunk-N46DFZLZ.js';import'./chunk-RAF57WYO.js';export{h as AsyncResolutionBatcher,n as ExpressionEngine,d as SNAPSHOT_FORMAT,e as SNAPSHOT_VERSION,f as SnapshotErrorCodes,j as checkExpressionComplexity,i as checkExpressionLength,k as extractReadsAndWrites,m as findInlineSolvesInLine,l as isEmptyLine}from'./chunk-P7XWFT45.js';import'./chunk-JQBG3LX4.js';import'./chunk-2RWAXT6O.js';import'./chunk-7E7NXKQ5.js';import'./chunk-MIQBJGGR.js';import'./chunk-K4MME6ZT.js';import'./chunk-KHCNMNZZ.js';import'./chunk-LH7URJZT.js';import'./chunk-XEIDV5JP.js';import'./chunk-T3FBAFRR.js';import'./chunk-YVKHEAFT.js';import'./chunk-3GAWAMT4.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-YTCTUBR2.js';import'./chunk-YAYBVVG2.js';import'./chunk-YNMMRH44.js';import'./chunk-HFKDWQUL.js';import'./chunk-5TCSFTZD.js';import'./chunk-WTEXBPBR.js';import'./chunk-A33K7NY4.js';import'./chunk-DLAKPF5T.js';import'./chunk-OVNB7MI5.js';import'./chunk-QYO7IEPR.js';import'./chunk-JPFCXLJV.js';import'./chunk-GMSBBLUQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-UWAXJX5G.js';import'./chunk-44EOEWGP.js';import'./chunk-MPB7KUN5.js';//# sourceMappingURL=engine.js.map
2
2
  //# sourceMappingURL=engine.js.map
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';require('./chunk-YORX7723.cjs'),require('./chunk-EFJCC6FJ.cjs');var chunkOZ6SKIPD_cjs=require('./chunk-OZ6SKIPD.cjs');require('./chunk-FNNIAJNY.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-LNZNJSRW.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-TUBLMUTZ.cjs'),require('./chunk-MVP2YD4X.cjs'),require('./chunk-6TPXH6Y5.cjs'),require('./chunk-R2SZFJTT.cjs');var chunkU47GA63S_cjs=require('./chunk-U47GA63S.cjs');require('./chunk-FUDVKPB7.cjs'),require('./chunk-WYIOXAFW.cjs');var chunk4QVBSG6B_cjs=require('./chunk-4QVBSG6B.cjs');require('./chunk-C65UDMWH.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-EURCQMZK.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-VBSMA7WJ.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-5TVI2UPZ.cjs'),require('./chunk-75XDS65A.cjs');var chunkPNDQRCRQ_cjs=require('./chunk-PNDQRCRQ.cjs');require('./chunk-BKSKZA4W.cjs');var chunkCIENDLKV_cjs=require('./chunk-CIENDLKV.cjs');require('./chunk-3HYO3QYW.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-SNVPM27Q.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-WEAKI5V5.cjs'),require('./chunk-6QRHN3I6.cjs');var chunkSOMGSIO4_cjs=require('./chunk-SOMGSIO4.cjs');var r={DEFINE_FUNCTION_INVALID_NAME:"DEFINE_FUNCTION_INVALID_NAME",DEFINE_FUNCTION_INVALID_SPEC:"DEFINE_FUNCTION_INVALID_SPEC",DEFINE_FUNCTION_ARITY_MISMATCH:"DEFINE_FUNCTION_ARITY_MISMATCH",DEFINE_FUNCTION_ARGUMENT_TYPE:"DEFINE_FUNCTION_ARGUMENT_TYPE",DEFINE_FUNCTION_RETURN_TYPE:"DEFINE_FUNCTION_RETURN_TYPE"},b=/^[a-z_][a-z0-9_]*$/i,y=new Set(["number","string","boolean"]);function u(e){return e===1?"1 argument":`${e} arguments`}function f(e){switch(e.type){case 0:case 1:return "a number";case 3:return "a string";case 10:return "a boolean";case 2:return "a big integer";case 5:return "a percentage";case 6:return "a value with a unit";case 4:return "a date";case 7:return "a matrix";case 8:return "a range";case 9:return "a symbolic expression";default:return "an unsupported value"}}function A(e,n,t){switch(n.type){case "number":if(e.type===0||e.type===1)return e.toNumber();break;case "string":if(e.type===3)return e.value;break;case "boolean":if(e.type===10)return e.value;break}throw chunkSOMGSIO4_cjs.c.execution({code:r.DEFINE_FUNCTION_ARGUMENT_TYPE,message:`${t}() expects "${n.name}" to be a ${n.type}, but was given ${f(e)}`,expected:`a ${n.type}`,found:f(e),context:{functionName:t,argName:n.name,expectedType:n.type}})}function S(e,n,t){switch(n){case "number":if(typeof e=="number")return chunkPNDQRCRQ_cjs.n(e);break;case "string":if(typeof e=="string")return chunkPNDQRCRQ_cjs.t(e);break;case "boolean":if(typeof e=="boolean")return chunkPNDQRCRQ_cjs.L(e);break}throw chunkSOMGSIO4_cjs.c.internal({code:r.DEFINE_FUNCTION_RETURN_TYPE,message:`${t}() is declared to return a ${n}, but its implementation returned ${typeof e}`,expected:`a ${n}`,found:typeof e,context:{functionName:t,expectedType:n}})}var p=class{constructor(n){this.fnName=n;this.category="Function";}parse(n,t,i){n.consume("LPAREN");let a=0;if(n.peek()?.type!=="RPAREN")for(n.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,i),a++;n.match("COMMA");)n.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,i),a++;n.consume("RPAREN"),i.emitPluginCall(this.fnName,a);}};function P(e){let n=e.args.length;return t=>{if(t.length!==n)throw chunkSOMGSIO4_cjs.c.execution({code:r.DEFINE_FUNCTION_ARITY_MISMATCH,message:`${e.name}() takes ${u(n)}, but was given ${t.length===0?"none":u(t.length)}`,expected:u(n),found:t.length===0?"none":u(t.length),context:{functionName:e.name,expected:n,actual:t.length}});let i=new Array(n);for(let s=0;s<n;s++)i[s]=A(t[s],e.args[s],e.name);let a=e.call(...i);return S(a,e.returns,e.name)}}function V(e){if(typeof e?.name!="string"||!b.test(e.name))throw chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_NAME,message:`defineFunction: name must be a single identifier, got ${JSON.stringify(e?.name)}`,suggestion:'e.g. "vat" or "net_price"',context:{name:e?.name}});if(!Array.isArray(e.args))throw chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" args must be an array`,context:{name:e.name}});for(let n of e.args){if(typeof n?.name!="string"||n.name.length===0)throw chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has an argument with no name`,context:{name:e.name}});if(!y.has(n.type))throw chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" argument "${n.name}" has unsupported type ${JSON.stringify(n.type)}`,suggestion:"supported argument types are number, string, boolean",context:{name:e.name,argName:n.name,type:n.type}})}if(!y.has(e.returns))throw chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has unsupported return type ${JSON.stringify(e.returns)}`,suggestion:"supported return types are number, string, boolean",context:{name:e.name,returns:e.returns}});if(typeof e.call!="function")throw chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" is missing a call implementation`,context:{name:e.name}})}function O(e){V(e);let n=e.name,t=`DEFINE_FN_${n.toUpperCase()}`;return {name:`solve-fn-${n}`,lexerVocabulary:{keywords:{[n.toLowerCase()]:t}},prefixParselets:{[t]:new p(n)},pluginFunctions:{[n]:P(e)}}}function h(e={}){let{extraPackages:n=[],...t}=e;return new chunkOZ6SKIPD_cjs.n({...t,packages:n.length>0?[...chunkU47GA63S_cjs.y,...n]:chunkU47GA63S_cjs.y})}Object.defineProperty(exports,"ExpressionEngine",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.n}});Object.defineProperty(exports,"SNAPSHOT_FORMAT",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.d}});Object.defineProperty(exports,"SNAPSHOT_VERSION",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.e}});Object.defineProperty(exports,"SnapshotErrorCodes",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.f}});Object.defineProperty(exports,"assertEngineVersionCompatible",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.c}});Object.defineProperty(exports,"checkEngineVersionCompatibility",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.b}});Object.defineProperty(exports,"checkPackageCompatibility",{enumerable:true,get:function(){return chunkOZ6SKIPD_cjs.a}});Object.defineProperty(exports,"ENGINE_VERSION",{enumerable:true,get:function(){return chunkCIENDLKV_cjs.a}});exports.DefineFunctionErrorCodes=r;exports.createEngine=h;exports.defineFunction=O;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';require('./chunk-7VJN65QP.cjs'),require('./chunk-EFJCC6FJ.cjs');var chunkOWQF6ZOK_cjs=require('./chunk-OWQF6ZOK.cjs');require('./chunk-FNNIAJNY.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-LNZNJSRW.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-556Q7VZC.cjs'),require('./chunk-MVP2YD4X.cjs'),require('./chunk-6TPXH6Y5.cjs'),require('./chunk-R2SZFJTT.cjs');var chunkAEPS7W3D_cjs=require('./chunk-AEPS7W3D.cjs');require('./chunk-FUDVKPB7.cjs'),require('./chunk-WYIOXAFW.cjs');var chunk4QVBSG6B_cjs=require('./chunk-4QVBSG6B.cjs');require('./chunk-C65UDMWH.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-EURCQMZK.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-VBSMA7WJ.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-5TVI2UPZ.cjs'),require('./chunk-75XDS65A.cjs');var chunkPNDQRCRQ_cjs=require('./chunk-PNDQRCRQ.cjs');require('./chunk-BKSKZA4W.cjs');var chunk6ILXAGWX_cjs=require('./chunk-6ILXAGWX.cjs');require('./chunk-3HYO3QYW.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-SNVPM27Q.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-WEAKI5V5.cjs'),require('./chunk-6QRHN3I6.cjs');var chunkSOMGSIO4_cjs=require('./chunk-SOMGSIO4.cjs');var r={DEFINE_FUNCTION_INVALID_NAME:"DEFINE_FUNCTION_INVALID_NAME",DEFINE_FUNCTION_INVALID_SPEC:"DEFINE_FUNCTION_INVALID_SPEC",DEFINE_FUNCTION_ARITY_MISMATCH:"DEFINE_FUNCTION_ARITY_MISMATCH",DEFINE_FUNCTION_ARGUMENT_TYPE:"DEFINE_FUNCTION_ARGUMENT_TYPE",DEFINE_FUNCTION_RETURN_TYPE:"DEFINE_FUNCTION_RETURN_TYPE"},b=/^[a-z_][a-z0-9_]*$/i,y=new Set(["number","string","boolean"]);function u(e){return e===1?"1 argument":`${e} arguments`}function f(e){switch(e.type){case 0:case 1:return "a number";case 3:return "a string";case 10:return "a boolean";case 2:return "a big integer";case 5:return "a percentage";case 6:return "a value with a unit";case 4:return "a date";case 7:return "a matrix";case 8:return "a range";case 9:return "a symbolic expression";default:return "an unsupported value"}}function A(e,n,t){switch(n.type){case "number":if(e.type===0||e.type===1)return e.toNumber();break;case "string":if(e.type===3)return e.value;break;case "boolean":if(e.type===10)return e.value;break}throw chunkSOMGSIO4_cjs.c.execution({code:r.DEFINE_FUNCTION_ARGUMENT_TYPE,message:`${t}() expects "${n.name}" to be a ${n.type}, but was given ${f(e)}`,expected:`a ${n.type}`,found:f(e),context:{functionName:t,argName:n.name,expectedType:n.type}})}function S(e,n,t){switch(n){case "number":if(typeof e=="number")return chunkPNDQRCRQ_cjs.n(e);break;case "string":if(typeof e=="string")return chunkPNDQRCRQ_cjs.t(e);break;case "boolean":if(typeof e=="boolean")return chunkPNDQRCRQ_cjs.L(e);break}throw chunkSOMGSIO4_cjs.c.internal({code:r.DEFINE_FUNCTION_RETURN_TYPE,message:`${t}() is declared to return a ${n}, but its implementation returned ${typeof e}`,expected:`a ${n}`,found:typeof e,context:{functionName:t,expectedType:n}})}var p=class{constructor(n){this.fnName=n;this.category="Function";}parse(n,t,i){n.consume("LPAREN");let a=0;if(n.peek()?.type!=="RPAREN")for(n.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,i),a++;n.match("COMMA");)n.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,i),a++;n.consume("RPAREN"),i.emitPluginCall(this.fnName,a);}};function P(e){let n=e.args.length;return t=>{if(t.length!==n)throw chunkSOMGSIO4_cjs.c.execution({code:r.DEFINE_FUNCTION_ARITY_MISMATCH,message:`${e.name}() takes ${u(n)}, but was given ${t.length===0?"none":u(t.length)}`,expected:u(n),found:t.length===0?"none":u(t.length),context:{functionName:e.name,expected:n,actual:t.length}});let i=new Array(n);for(let s=0;s<n;s++)i[s]=A(t[s],e.args[s],e.name);let a=e.call(...i);return S(a,e.returns,e.name)}}function V(e){if(typeof e?.name!="string"||!b.test(e.name))throw chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_NAME,message:`defineFunction: name must be a single identifier, got ${JSON.stringify(e?.name)}`,suggestion:'e.g. "vat" or "net_price"',context:{name:e?.name}});if(!Array.isArray(e.args))throw chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" args must be an array`,context:{name:e.name}});for(let n of e.args){if(typeof n?.name!="string"||n.name.length===0)throw chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has an argument with no name`,context:{name:e.name}});if(!y.has(n.type))throw chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" argument "${n.name}" has unsupported type ${JSON.stringify(n.type)}`,suggestion:"supported argument types are number, string, boolean",context:{name:e.name,argName:n.name,type:n.type}})}if(!y.has(e.returns))throw chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has unsupported return type ${JSON.stringify(e.returns)}`,suggestion:"supported return types are number, string, boolean",context:{name:e.name,returns:e.returns}});if(typeof e.call!="function")throw chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" is missing a call implementation`,context:{name:e.name}})}function O(e){V(e);let n=e.name,t=`DEFINE_FN_${n.toUpperCase()}`;return {name:`solve-fn-${n}`,lexerVocabulary:{keywords:{[n.toLowerCase()]:t}},prefixParselets:{[t]:new p(n)},pluginFunctions:{[n]:P(e)}}}function h(e={}){let{extraPackages:n=[],...t}=e;return new chunkOWQF6ZOK_cjs.n({...t,packages:n.length>0?[...chunkAEPS7W3D_cjs.y,...n]:chunkAEPS7W3D_cjs.y})}Object.defineProperty(exports,"ExpressionEngine",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.n}});Object.defineProperty(exports,"SNAPSHOT_FORMAT",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.d}});Object.defineProperty(exports,"SNAPSHOT_VERSION",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.e}});Object.defineProperty(exports,"SnapshotErrorCodes",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.f}});Object.defineProperty(exports,"assertEngineVersionCompatible",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.c}});Object.defineProperty(exports,"checkEngineVersionCompatibility",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.b}});Object.defineProperty(exports,"checkPackageCompatibility",{enumerable:true,get:function(){return chunkOWQF6ZOK_cjs.a}});Object.defineProperty(exports,"ENGINE_VERSION",{enumerable:true,get:function(){return chunk6ILXAGWX_cjs.a}});exports.DefineFunctionErrorCodes=r;exports.createEngine=h;exports.defineFunction=O;//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import'./chunk-GAAXTO4K.js';import'./chunk-RAF57WYO.js';import {n}from'./chunk-2V44X7GH.js';export{n as ExpressionEngine,d as SNAPSHOT_FORMAT,e as SNAPSHOT_VERSION,f as SnapshotErrorCodes,c as assertEngineVersionCompatible,b as checkEngineVersionCompatibility,a as checkPackageCompatibility}from'./chunk-2V44X7GH.js';import'./chunk-JQBG3LX4.js';import'./chunk-2RWAXT6O.js';import'./chunk-7E7NXKQ5.js';import'./chunk-MIQBJGGR.js';import'./chunk-EOMHELRL.js';import'./chunk-KHCNMNZZ.js';import'./chunk-LH7URJZT.js';import'./chunk-XEIDV5JP.js';import {y as y$1}from'./chunk-HDVZZ7JN.js';import'./chunk-JEFMG6CV.js';import'./chunk-T3FBAFRR.js';import {a}from'./chunk-YVKHEAFT.js';import'./chunk-3GAWAMT4.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-YTCTUBR2.js';import'./chunk-YAYBVVG2.js';import'./chunk-YNMMRH44.js';import'./chunk-HFKDWQUL.js';import'./chunk-5TCSFTZD.js';import'./chunk-WTEXBPBR.js';import {L,t,n as n$1}from'./chunk-A33K7NY4.js';import'./chunk-DLAKPF5T.js';export{a as ENGINE_VERSION}from'./chunk-UKDUFMT5.js';import'./chunk-QYO7IEPR.js';import'./chunk-JPFCXLJV.js';import'./chunk-GMSBBLUQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-UWAXJX5G.js';import'./chunk-44EOEWGP.js';import {c}from'./chunk-MPB7KUN5.js';var r={DEFINE_FUNCTION_INVALID_NAME:"DEFINE_FUNCTION_INVALID_NAME",DEFINE_FUNCTION_INVALID_SPEC:"DEFINE_FUNCTION_INVALID_SPEC",DEFINE_FUNCTION_ARITY_MISMATCH:"DEFINE_FUNCTION_ARITY_MISMATCH",DEFINE_FUNCTION_ARGUMENT_TYPE:"DEFINE_FUNCTION_ARGUMENT_TYPE",DEFINE_FUNCTION_RETURN_TYPE:"DEFINE_FUNCTION_RETURN_TYPE"},b=/^[a-z_][a-z0-9_]*$/i,y=new Set(["number","string","boolean"]);function u(e){return e===1?"1 argument":`${e} arguments`}function f(e){switch(e.type){case 0:case 1:return "a number";case 3:return "a string";case 10:return "a boolean";case 2:return "a big integer";case 5:return "a percentage";case 6:return "a value with a unit";case 4:return "a date";case 7:return "a matrix";case 8:return "a range";case 9:return "a symbolic expression";default:return "an unsupported value"}}function A(e,n,t){switch(n.type){case "number":if(e.type===0||e.type===1)return e.toNumber();break;case "string":if(e.type===3)return e.value;break;case "boolean":if(e.type===10)return e.value;break}throw c.execution({code:r.DEFINE_FUNCTION_ARGUMENT_TYPE,message:`${t}() expects "${n.name}" to be a ${n.type}, but was given ${f(e)}`,expected:`a ${n.type}`,found:f(e),context:{functionName:t,argName:n.name,expectedType:n.type}})}function S(e,n,t$1){switch(n){case "number":if(typeof e=="number")return n$1(e);break;case "string":if(typeof e=="string")return t(e);break;case "boolean":if(typeof e=="boolean")return L(e);break}throw c.internal({code:r.DEFINE_FUNCTION_RETURN_TYPE,message:`${t$1}() is declared to return a ${n}, but its implementation returned ${typeof e}`,expected:`a ${n}`,found:typeof e,context:{functionName:t$1,expectedType:n}})}var p=class{constructor(n){this.fnName=n;this.category="Function";}parse(n,t,i){n.consume("LPAREN");let a$1=0;if(n.peek()?.type!=="RPAREN")for(n.parseExpression(a.Lowest,i),a$1++;n.match("COMMA");)n.parseExpression(a.Lowest,i),a$1++;n.consume("RPAREN"),i.emitPluginCall(this.fnName,a$1);}};function P(e){let n=e.args.length;return t=>{if(t.length!==n)throw c.execution({code:r.DEFINE_FUNCTION_ARITY_MISMATCH,message:`${e.name}() takes ${u(n)}, but was given ${t.length===0?"none":u(t.length)}`,expected:u(n),found:t.length===0?"none":u(t.length),context:{functionName:e.name,expected:n,actual:t.length}});let i=new Array(n);for(let s=0;s<n;s++)i[s]=A(t[s],e.args[s],e.name);let a=e.call(...i);return S(a,e.returns,e.name)}}function V(e){if(typeof e?.name!="string"||!b.test(e.name))throw c.config({code:r.DEFINE_FUNCTION_INVALID_NAME,message:`defineFunction: name must be a single identifier, got ${JSON.stringify(e?.name)}`,suggestion:'e.g. "vat" or "net_price"',context:{name:e?.name}});if(!Array.isArray(e.args))throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" args must be an array`,context:{name:e.name}});for(let n of e.args){if(typeof n?.name!="string"||n.name.length===0)throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has an argument with no name`,context:{name:e.name}});if(!y.has(n.type))throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" argument "${n.name}" has unsupported type ${JSON.stringify(n.type)}`,suggestion:"supported argument types are number, string, boolean",context:{name:e.name,argName:n.name,type:n.type}})}if(!y.has(e.returns))throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has unsupported return type ${JSON.stringify(e.returns)}`,suggestion:"supported return types are number, string, boolean",context:{name:e.name,returns:e.returns}});if(typeof e.call!="function")throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" is missing a call implementation`,context:{name:e.name}})}function O(e){V(e);let n=e.name,t=`DEFINE_FN_${n.toUpperCase()}`;return {name:`solve-fn-${n}`,lexerVocabulary:{keywords:{[n.toLowerCase()]:t}},prefixParselets:{[t]:new p(n)},pluginFunctions:{[n]:P(e)}}}function h(e={}){let{extraPackages:n$1=[],...t}=e;return new n({...t,packages:n$1.length>0?[...y$1,...n$1]:y$1})}export{r as DefineFunctionErrorCodes,h as createEngine,O as defineFunction};//# sourceMappingURL=index.js.map
1
+ import'./chunk-N46DFZLZ.js';import'./chunk-RAF57WYO.js';import {n}from'./chunk-P7XWFT45.js';export{n as ExpressionEngine,d as SNAPSHOT_FORMAT,e as SNAPSHOT_VERSION,f as SnapshotErrorCodes,c as assertEngineVersionCompatible,b as checkEngineVersionCompatibility,a as checkPackageCompatibility}from'./chunk-P7XWFT45.js';import'./chunk-JQBG3LX4.js';import'./chunk-2RWAXT6O.js';import'./chunk-7E7NXKQ5.js';import'./chunk-MIQBJGGR.js';import'./chunk-K4MME6ZT.js';import'./chunk-KHCNMNZZ.js';import'./chunk-LH7URJZT.js';import'./chunk-XEIDV5JP.js';import {y as y$1}from'./chunk-HE7E6M5O.js';import'./chunk-JEFMG6CV.js';import'./chunk-T3FBAFRR.js';import {a}from'./chunk-YVKHEAFT.js';import'./chunk-3GAWAMT4.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-YTCTUBR2.js';import'./chunk-YAYBVVG2.js';import'./chunk-YNMMRH44.js';import'./chunk-HFKDWQUL.js';import'./chunk-5TCSFTZD.js';import'./chunk-WTEXBPBR.js';import {L,t,n as n$1}from'./chunk-A33K7NY4.js';import'./chunk-DLAKPF5T.js';export{a as ENGINE_VERSION}from'./chunk-OVNB7MI5.js';import'./chunk-QYO7IEPR.js';import'./chunk-JPFCXLJV.js';import'./chunk-GMSBBLUQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-UWAXJX5G.js';import'./chunk-44EOEWGP.js';import {c}from'./chunk-MPB7KUN5.js';var r={DEFINE_FUNCTION_INVALID_NAME:"DEFINE_FUNCTION_INVALID_NAME",DEFINE_FUNCTION_INVALID_SPEC:"DEFINE_FUNCTION_INVALID_SPEC",DEFINE_FUNCTION_ARITY_MISMATCH:"DEFINE_FUNCTION_ARITY_MISMATCH",DEFINE_FUNCTION_ARGUMENT_TYPE:"DEFINE_FUNCTION_ARGUMENT_TYPE",DEFINE_FUNCTION_RETURN_TYPE:"DEFINE_FUNCTION_RETURN_TYPE"},b=/^[a-z_][a-z0-9_]*$/i,y=new Set(["number","string","boolean"]);function u(e){return e===1?"1 argument":`${e} arguments`}function f(e){switch(e.type){case 0:case 1:return "a number";case 3:return "a string";case 10:return "a boolean";case 2:return "a big integer";case 5:return "a percentage";case 6:return "a value with a unit";case 4:return "a date";case 7:return "a matrix";case 8:return "a range";case 9:return "a symbolic expression";default:return "an unsupported value"}}function A(e,n,t){switch(n.type){case "number":if(e.type===0||e.type===1)return e.toNumber();break;case "string":if(e.type===3)return e.value;break;case "boolean":if(e.type===10)return e.value;break}throw c.execution({code:r.DEFINE_FUNCTION_ARGUMENT_TYPE,message:`${t}() expects "${n.name}" to be a ${n.type}, but was given ${f(e)}`,expected:`a ${n.type}`,found:f(e),context:{functionName:t,argName:n.name,expectedType:n.type}})}function S(e,n,t$1){switch(n){case "number":if(typeof e=="number")return n$1(e);break;case "string":if(typeof e=="string")return t(e);break;case "boolean":if(typeof e=="boolean")return L(e);break}throw c.internal({code:r.DEFINE_FUNCTION_RETURN_TYPE,message:`${t$1}() is declared to return a ${n}, but its implementation returned ${typeof e}`,expected:`a ${n}`,found:typeof e,context:{functionName:t$1,expectedType:n}})}var p=class{constructor(n){this.fnName=n;this.category="Function";}parse(n,t,i){n.consume("LPAREN");let a$1=0;if(n.peek()?.type!=="RPAREN")for(n.parseExpression(a.Lowest,i),a$1++;n.match("COMMA");)n.parseExpression(a.Lowest,i),a$1++;n.consume("RPAREN"),i.emitPluginCall(this.fnName,a$1);}};function P(e){let n=e.args.length;return t=>{if(t.length!==n)throw c.execution({code:r.DEFINE_FUNCTION_ARITY_MISMATCH,message:`${e.name}() takes ${u(n)}, but was given ${t.length===0?"none":u(t.length)}`,expected:u(n),found:t.length===0?"none":u(t.length),context:{functionName:e.name,expected:n,actual:t.length}});let i=new Array(n);for(let s=0;s<n;s++)i[s]=A(t[s],e.args[s],e.name);let a=e.call(...i);return S(a,e.returns,e.name)}}function V(e){if(typeof e?.name!="string"||!b.test(e.name))throw c.config({code:r.DEFINE_FUNCTION_INVALID_NAME,message:`defineFunction: name must be a single identifier, got ${JSON.stringify(e?.name)}`,suggestion:'e.g. "vat" or "net_price"',context:{name:e?.name}});if(!Array.isArray(e.args))throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" args must be an array`,context:{name:e.name}});for(let n of e.args){if(typeof n?.name!="string"||n.name.length===0)throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has an argument with no name`,context:{name:e.name}});if(!y.has(n.type))throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" argument "${n.name}" has unsupported type ${JSON.stringify(n.type)}`,suggestion:"supported argument types are number, string, boolean",context:{name:e.name,argName:n.name,type:n.type}})}if(!y.has(e.returns))throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has unsupported return type ${JSON.stringify(e.returns)}`,suggestion:"supported return types are number, string, boolean",context:{name:e.name,returns:e.returns}});if(typeof e.call!="function")throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" is missing a call implementation`,context:{name:e.name}})}function O(e){V(e);let n=e.name,t=`DEFINE_FN_${n.toUpperCase()}`;return {name:`solve-fn-${n}`,lexerVocabulary:{keywords:{[n.toLowerCase()]:t}},prefixParselets:{[t]:new p(n)},pluginFunctions:{[n]:P(e)}}}function h(e={}){let{extraPackages:n$1=[],...t}=e;return new n({...t,packages:n$1.length>0?[...y$1,...n$1]:y$1})}export{r as DefineFunctionErrorCodes,h as createEngine,O as defineFunction};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
package/dist/packages.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkU47GA63S_cjs=require('./chunk-U47GA63S.cjs');require('./chunk-FUDVKPB7.cjs');var chunkWYIOXAFW_cjs=require('./chunk-WYIOXAFW.cjs');require('./chunk-4QVBSG6B.cjs'),require('./chunk-C65UDMWH.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-EURCQMZK.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-VBSMA7WJ.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-5TVI2UPZ.cjs'),require('./chunk-75XDS65A.cjs'),require('./chunk-PNDQRCRQ.cjs'),require('./chunk-BKSKZA4W.cjs'),require('./chunk-SNVPM27Q.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-WEAKI5V5.cjs'),require('./chunk-6QRHN3I6.cjs'),require('./chunk-SOMGSIO4.cjs');Object.defineProperty(exports,"ARITHMETIC_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.a}});Object.defineProperty(exports,"BIGINT_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.n}});Object.defineProperty(exports,"BUILTIN_PACKAGES",{enumerable:true,get:function(){return chunkU47GA63S_cjs.y}});Object.defineProperty(exports,"CONDITIONALS_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.o}});Object.defineProperty(exports,"CONVERTERS_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.p}});Object.defineProperty(exports,"CURRENCY_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.j}});Object.defineProperty(exports,"DATETIME_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.d}});Object.defineProperty(exports,"DICE_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.f}});Object.defineProperty(exports,"FINANCE_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.r}});Object.defineProperty(exports,"FUNCTION_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.c}});Object.defineProperty(exports,"LINES_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.v}});Object.defineProperty(exports,"MAPREDUCE_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.m}});Object.defineProperty(exports,"MATHPHRASES_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.q}});Object.defineProperty(exports,"MATRIX_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.l}});Object.defineProperty(exports,"PERCENTAGE_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.b}});Object.defineProperty(exports,"TABLES_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.w}});Object.defineProperty(exports,"TAGS_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.x}});Object.defineProperty(exports,"TIME_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.e}});Object.defineProperty(exports,"UOM_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.h}});Object.defineProperty(exports,"VARIABLES_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.g}});Object.defineProperty(exports,"VECTOR_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.k}});Object.defineProperty(exports,"WEATHER_PACKAGE",{enumerable:true,get:function(){return chunkU47GA63S_cjs.s}});Object.defineProperty(exports,"createCurrencyPackage",{enumerable:true,get:function(){return chunkU47GA63S_cjs.i}});Object.defineProperty(exports,"createKnowledgePackage",{enumerable:true,get:function(){return chunkU47GA63S_cjs.u}});Object.defineProperty(exports,"createStocksPackage",{enumerable:true,get:function(){return chunkU47GA63S_cjs.t}});Object.defineProperty(exports,"SYMBOLIC_PACKAGE",{enumerable:true,get:function(){return chunkWYIOXAFW_cjs.a}});//# sourceMappingURL=packages.cjs.map
1
+ 'use strict';var chunkAEPS7W3D_cjs=require('./chunk-AEPS7W3D.cjs');require('./chunk-FUDVKPB7.cjs');var chunkWYIOXAFW_cjs=require('./chunk-WYIOXAFW.cjs');require('./chunk-4QVBSG6B.cjs'),require('./chunk-C65UDMWH.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-EURCQMZK.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-VBSMA7WJ.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-5TVI2UPZ.cjs'),require('./chunk-75XDS65A.cjs'),require('./chunk-PNDQRCRQ.cjs'),require('./chunk-BKSKZA4W.cjs'),require('./chunk-SNVPM27Q.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-WEAKI5V5.cjs'),require('./chunk-6QRHN3I6.cjs'),require('./chunk-SOMGSIO4.cjs');Object.defineProperty(exports,"ARITHMETIC_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.a}});Object.defineProperty(exports,"BIGINT_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.n}});Object.defineProperty(exports,"BUILTIN_PACKAGES",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.y}});Object.defineProperty(exports,"CONDITIONALS_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.o}});Object.defineProperty(exports,"CONVERTERS_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.p}});Object.defineProperty(exports,"CURRENCY_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.j}});Object.defineProperty(exports,"DATETIME_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.d}});Object.defineProperty(exports,"DICE_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.f}});Object.defineProperty(exports,"FINANCE_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.r}});Object.defineProperty(exports,"FUNCTION_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.c}});Object.defineProperty(exports,"LINES_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.v}});Object.defineProperty(exports,"MAPREDUCE_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.m}});Object.defineProperty(exports,"MATHPHRASES_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.q}});Object.defineProperty(exports,"MATRIX_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.l}});Object.defineProperty(exports,"PERCENTAGE_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.b}});Object.defineProperty(exports,"TABLES_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.w}});Object.defineProperty(exports,"TAGS_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.x}});Object.defineProperty(exports,"TIME_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.e}});Object.defineProperty(exports,"UOM_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.h}});Object.defineProperty(exports,"VARIABLES_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.g}});Object.defineProperty(exports,"VECTOR_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.k}});Object.defineProperty(exports,"WEATHER_PACKAGE",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.s}});Object.defineProperty(exports,"createCurrencyPackage",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.i}});Object.defineProperty(exports,"createKnowledgePackage",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.u}});Object.defineProperty(exports,"createStocksPackage",{enumerable:true,get:function(){return chunkAEPS7W3D_cjs.t}});Object.defineProperty(exports,"SYMBOLIC_PACKAGE",{enumerable:true,get:function(){return chunkWYIOXAFW_cjs.a}});//# sourceMappingURL=packages.cjs.map
2
2
  //# sourceMappingURL=packages.cjs.map
@@ -796,7 +796,7 @@ declare const TAGS_PACKAGE: IEnginePackage;
796
796
  /**
797
797
  * The packages an engine registers when the caller names none.
798
798
  *
799
- * Thirty of the thirty-two. Stocks and knowledge are excluded because
799
+ * Thirty-one of the thirty-three. Stocks and knowledge are excluded because
800
800
  * both need a host-supplied data source and do nothing useful without one, so
801
801
  * registering them by default would only produce NOT_CONFIGURED results.
802
802
  *
@@ -796,7 +796,7 @@ declare const TAGS_PACKAGE: IEnginePackage;
796
796
  /**
797
797
  * The packages an engine registers when the caller names none.
798
798
  *
799
- * Thirty of the thirty-two. Stocks and knowledge are excluded because
799
+ * Thirty-one of the thirty-three. Stocks and knowledge are excluded because
800
800
  * both need a host-supplied data source and do nothing useful without one, so
801
801
  * registering them by default would only produce NOT_CONFIGURED results.
802
802
  *
package/dist/packages.js CHANGED
@@ -1,2 +1,2 @@
1
- export{a as ARITHMETIC_PACKAGE,n as BIGINT_PACKAGE,y as BUILTIN_PACKAGES,o as CONDITIONALS_PACKAGE,p as CONVERTERS_PACKAGE,j as CURRENCY_PACKAGE,d as DATETIME_PACKAGE,f as DICE_PACKAGE,r as FINANCE_PACKAGE,c as FUNCTION_PACKAGE,v as LINES_PACKAGE,m as MAPREDUCE_PACKAGE,q as MATHPHRASES_PACKAGE,l as MATRIX_PACKAGE,b as PERCENTAGE_PACKAGE,w as TABLES_PACKAGE,x as TAGS_PACKAGE,e as TIME_PACKAGE,h as UOM_PACKAGE,g as VARIABLES_PACKAGE,k as VECTOR_PACKAGE,s as WEATHER_PACKAGE,i as createCurrencyPackage,u as createKnowledgePackage,t as createStocksPackage}from'./chunk-HDVZZ7JN.js';import'./chunk-JEFMG6CV.js';export{a as SYMBOLIC_PACKAGE}from'./chunk-T3FBAFRR.js';import'./chunk-YVKHEAFT.js';import'./chunk-3GAWAMT4.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-YTCTUBR2.js';import'./chunk-YAYBVVG2.js';import'./chunk-YNMMRH44.js';import'./chunk-HFKDWQUL.js';import'./chunk-5TCSFTZD.js';import'./chunk-WTEXBPBR.js';import'./chunk-A33K7NY4.js';import'./chunk-DLAKPF5T.js';import'./chunk-GMSBBLUQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-UWAXJX5G.js';import'./chunk-44EOEWGP.js';import'./chunk-MPB7KUN5.js';//# sourceMappingURL=packages.js.map
1
+ export{a as ARITHMETIC_PACKAGE,n as BIGINT_PACKAGE,y as BUILTIN_PACKAGES,o as CONDITIONALS_PACKAGE,p as CONVERTERS_PACKAGE,j as CURRENCY_PACKAGE,d as DATETIME_PACKAGE,f as DICE_PACKAGE,r as FINANCE_PACKAGE,c as FUNCTION_PACKAGE,v as LINES_PACKAGE,m as MAPREDUCE_PACKAGE,q as MATHPHRASES_PACKAGE,l as MATRIX_PACKAGE,b as PERCENTAGE_PACKAGE,w as TABLES_PACKAGE,x as TAGS_PACKAGE,e as TIME_PACKAGE,h as UOM_PACKAGE,g as VARIABLES_PACKAGE,k as VECTOR_PACKAGE,s as WEATHER_PACKAGE,i as createCurrencyPackage,u as createKnowledgePackage,t as createStocksPackage}from'./chunk-HE7E6M5O.js';import'./chunk-JEFMG6CV.js';export{a as SYMBOLIC_PACKAGE}from'./chunk-T3FBAFRR.js';import'./chunk-YVKHEAFT.js';import'./chunk-3GAWAMT4.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-YTCTUBR2.js';import'./chunk-YAYBVVG2.js';import'./chunk-YNMMRH44.js';import'./chunk-HFKDWQUL.js';import'./chunk-5TCSFTZD.js';import'./chunk-WTEXBPBR.js';import'./chunk-A33K7NY4.js';import'./chunk-DLAKPF5T.js';import'./chunk-GMSBBLUQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-UWAXJX5G.js';import'./chunk-44EOEWGP.js';import'./chunk-MPB7KUN5.js';//# sourceMappingURL=packages.js.map
2
2
  //# sourceMappingURL=packages.js.map
package/dist/testing.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var chunkOZ6SKIPD_cjs=require('./chunk-OZ6SKIPD.cjs');require('./chunk-FNNIAJNY.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-LNZNJSRW.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-TUBLMUTZ.cjs'),require('./chunk-MVP2YD4X.cjs'),require('./chunk-6TPXH6Y5.cjs'),require('./chunk-R2SZFJTT.cjs');var chunkU47GA63S_cjs=require('./chunk-U47GA63S.cjs');require('./chunk-FUDVKPB7.cjs'),require('./chunk-WYIOXAFW.cjs'),require('./chunk-4QVBSG6B.cjs'),require('./chunk-C65UDMWH.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-EURCQMZK.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-VBSMA7WJ.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-5TVI2UPZ.cjs'),require('./chunk-75XDS65A.cjs');var chunkPNDQRCRQ_cjs=require('./chunk-PNDQRCRQ.cjs');require('./chunk-BKSKZA4W.cjs');var chunkCIENDLKV_cjs=require('./chunk-CIENDLKV.cjs');require('./chunk-3HYO3QYW.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-SNVPM27Q.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-WEAKI5V5.cjs'),require('./chunk-6QRHN3I6.cjs');var chunkSOMGSIO4_cjs=require('./chunk-SOMGSIO4.cjs');var i=class o extends Error{constructor(t){super(t.message),this.name="ExpectationError",this.code=t.code,this.expected=t.expected,this.actual=t.actual,Object.setPrototypeOf(this,o.prototype);}};function V(o=[],t={}){let{locale:e="en",includeBuiltins:r=true}=t,s=new chunkOZ6SKIPD_cjs.n({locale:e,packages:r?chunkU47GA63S_cjs.y:[]});for(let a of o)s.registerPackage(a);return s}function v(o,t){try{let e=o.evaluateExpression(t);return e.isError()?{status:"error",code:e.errorCode??"",message:e.errorMessage??"",source:e}:e.isPending()?{status:"pending",value:e}:{status:"value",value:e}}catch(e){if(e instanceof chunkSOMGSIO4_cjs.b)return {status:"error",code:e.code,message:e.message,source:e};let r=e instanceof Error?e.message:String(e);return {status:"error",code:"UNKNOWN_ERROR",message:r,source:new chunkPNDQRCRQ_cjs.m(13,"UNKNOWN_ERROR",r)}}}function x(o,t){if(Object.is(o,t))return true;if(!Number.isFinite(o)||!Number.isFinite(t))return false;let e=1e-9*Math.max(1,Math.abs(o),Math.abs(t));return Math.abs(o-t)<=e}function l(o){return o.type===3?JSON.stringify(o.value):o.type===6&&typeof o.unit=="string"?`${String(o.value)} ${o.unit}`:String(o.value)}function n(o){switch(o.status){case "value":return l(o.value);case "pending":return "a pending async value";case "error":return `an error (${o.code}: ${o.message})`}}var d=class{constructor(t,e){this.expression=t;this.outcome=e;}get value(){if(this.outcome.status==="error")throw new i({code:"EXPECTED_VALUE",message:`Expected "${this.expression}" to evaluate, but it failed with ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this.outcome.value}toEvaluate(){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EVALUATE",message:`Expected "${this.expression}" to evaluate to a value, but got ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this}toEqual(t,e){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but got ${n(this.outcome)}.`,expected:c(t,e),actual:n(this.outcome)});let r=this.outcome.value,s;if(typeof t=="number"?s=x(r.toNumber(),t):typeof t=="boolean"?s=r.type===10&&r.value===t:s=C(r)===t,!s)throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but it was ${l(r)}.`,expected:c(t,e),actual:l(r)});if(e!==void 0&&r.unit!==e)throw new i({code:"EXPECTED_UNIT",message:`Expected "${this.expression}" to carry the unit "${e}", but it was ${r.unit===void 0?"unitless":`"${r.unit}"`}.`,expected:`unit "${e}"`,actual:r.unit===void 0?"no unit":`unit "${r.unit}"`});return this}toBeError(){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_ERROR",message:`Expected "${this.expression}" to fail, but it produced ${n(this.outcome)}.`,expected:"an error",actual:n(this.outcome)});return this}toFailWith(t){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it produced ${n(this.outcome)}.`,expected:`error code "${t}"`,actual:n(this.outcome)});if(this.outcome.code!==t)throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it failed with "${this.outcome.code}" (${this.outcome.message}).`,expected:`error code "${t}"`,actual:`error code "${this.outcome.code}"`});return this}toBePending(){if(this.outcome.status!=="pending")throw new i({code:"EXPECTED_PENDING",message:`Expected "${this.expression}" to be pending, but got ${n(this.outcome)}.`,expected:"a pending async value",actual:n(this.outcome)});return this}};function c(o,t){let e=typeof o=="string"?JSON.stringify(o):String(o);return t===void 0?e:`${e} ${t}`}function C(o){return String(o.value)}function D(o,t){return new d(t,v(o,t))}var O=["a","an","and","or","but","if","then","the","this","that","these","those","in","on","at","to","of","for","from","with","by","as","per","into","over","is","are","was","were","be","been","being","do","does","did","have","has","had","will","would","can","could","should","may","might","must","price","cost","value","total","sum","count","rate","amount","number","time","date","day","week","month","year","hour","minute","second","add","buy","sell","hold","make","take","give","get","set","run","up","down","out","off","all","some","any","no","not","more","less","one","two","three","first","last","next","each","every","here","there"],$=["error","warning","info"];function k(o){let t=[],e=o.lexerVocabulary;if(e?.keywords)for(let[r,s]of Object.entries(e.keywords))t.push({word:r,via:"keyword",tokenType:s});if(e?.units)for(let r of e.units)t.push({word:r,via:"unit"});if(e?.operators)for(let[r,s]of Object.entries(e.operators))t.push({word:r,via:"operator",tokenType:s});if(o.phrases)for(let[r,s]of Object.entries(o.phrases))r.includes(" ")||t.push({word:r,via:"phrase",tokenType:s});return t}var p=class{constructor(t){this.pkg=t;}notToShadow(t=O){let e=new Set(t.map(s=>s.toLowerCase())),r=k(this.pkg).filter(s=>e.has(s.word.toLowerCase()));if(r.length>0){let s=r.map(a=>`"${a.word}" (${a.via})`).join(", ");throw new i({code:"PACKAGE_SHADOWS_PROSE",message:`Package "${this.pkg.name}" claims prose word(s) as syntax: ${s}. A word that is also ordinary English turns prose into arithmetic; prefer a multi-word phrase or a form that requires a parenthesis.`,expected:"no prose words claimed as syntax",actual:s})}return r}notToCollideWith(t,e="error"){let r=chunkOZ6SKIPD_cjs.a(this.pkg,t),s=$.indexOf(e),a=r.conflicts.filter(u=>$.indexOf(u.severity)<=s);if(a.length>0){let u=a.map(g=>`[${g.severity}] ${g.detail}`).join(`
1
+ 'use strict';var chunkOWQF6ZOK_cjs=require('./chunk-OWQF6ZOK.cjs');require('./chunk-FNNIAJNY.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-LNZNJSRW.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-556Q7VZC.cjs'),require('./chunk-MVP2YD4X.cjs'),require('./chunk-6TPXH6Y5.cjs'),require('./chunk-R2SZFJTT.cjs');var chunkAEPS7W3D_cjs=require('./chunk-AEPS7W3D.cjs');require('./chunk-FUDVKPB7.cjs'),require('./chunk-WYIOXAFW.cjs'),require('./chunk-4QVBSG6B.cjs'),require('./chunk-C65UDMWH.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-EURCQMZK.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-VBSMA7WJ.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-5TVI2UPZ.cjs'),require('./chunk-75XDS65A.cjs');var chunkPNDQRCRQ_cjs=require('./chunk-PNDQRCRQ.cjs');require('./chunk-BKSKZA4W.cjs');var chunk6ILXAGWX_cjs=require('./chunk-6ILXAGWX.cjs');require('./chunk-3HYO3QYW.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-SNVPM27Q.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-WEAKI5V5.cjs'),require('./chunk-6QRHN3I6.cjs');var chunkSOMGSIO4_cjs=require('./chunk-SOMGSIO4.cjs');var i=class o extends Error{constructor(t){super(t.message),this.name="ExpectationError",this.code=t.code,this.expected=t.expected,this.actual=t.actual,Object.setPrototypeOf(this,o.prototype);}};function V(o=[],t={}){let{locale:e="en",includeBuiltins:r=true}=t,s=new chunkOWQF6ZOK_cjs.n({locale:e,packages:r?chunkAEPS7W3D_cjs.y:[]});for(let a of o)s.registerPackage(a);return s}function v(o,t){try{let e=o.evaluateExpression(t);return e.isError()?{status:"error",code:e.errorCode??"",message:e.errorMessage??"",source:e}:e.isPending()?{status:"pending",value:e}:{status:"value",value:e}}catch(e){if(e instanceof chunkSOMGSIO4_cjs.b)return {status:"error",code:e.code,message:e.message,source:e};let r=e instanceof Error?e.message:String(e);return {status:"error",code:"UNKNOWN_ERROR",message:r,source:new chunkPNDQRCRQ_cjs.m(13,"UNKNOWN_ERROR",r)}}}function x(o,t){if(Object.is(o,t))return true;if(!Number.isFinite(o)||!Number.isFinite(t))return false;let e=1e-9*Math.max(1,Math.abs(o),Math.abs(t));return Math.abs(o-t)<=e}function l(o){return o.type===3?JSON.stringify(o.value):o.type===6&&typeof o.unit=="string"?`${String(o.value)} ${o.unit}`:String(o.value)}function n(o){switch(o.status){case "value":return l(o.value);case "pending":return "a pending async value";case "error":return `an error (${o.code}: ${o.message})`}}var d=class{constructor(t,e){this.expression=t;this.outcome=e;}get value(){if(this.outcome.status==="error")throw new i({code:"EXPECTED_VALUE",message:`Expected "${this.expression}" to evaluate, but it failed with ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this.outcome.value}toEvaluate(){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EVALUATE",message:`Expected "${this.expression}" to evaluate to a value, but got ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this}toEqual(t,e){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but got ${n(this.outcome)}.`,expected:c(t,e),actual:n(this.outcome)});let r=this.outcome.value,s;if(typeof t=="number"?s=x(r.toNumber(),t):typeof t=="boolean"?s=r.type===10&&r.value===t:s=C(r)===t,!s)throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but it was ${l(r)}.`,expected:c(t,e),actual:l(r)});if(e!==void 0&&r.unit!==e)throw new i({code:"EXPECTED_UNIT",message:`Expected "${this.expression}" to carry the unit "${e}", but it was ${r.unit===void 0?"unitless":`"${r.unit}"`}.`,expected:`unit "${e}"`,actual:r.unit===void 0?"no unit":`unit "${r.unit}"`});return this}toBeError(){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_ERROR",message:`Expected "${this.expression}" to fail, but it produced ${n(this.outcome)}.`,expected:"an error",actual:n(this.outcome)});return this}toFailWith(t){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it produced ${n(this.outcome)}.`,expected:`error code "${t}"`,actual:n(this.outcome)});if(this.outcome.code!==t)throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it failed with "${this.outcome.code}" (${this.outcome.message}).`,expected:`error code "${t}"`,actual:`error code "${this.outcome.code}"`});return this}toBePending(){if(this.outcome.status!=="pending")throw new i({code:"EXPECTED_PENDING",message:`Expected "${this.expression}" to be pending, but got ${n(this.outcome)}.`,expected:"a pending async value",actual:n(this.outcome)});return this}};function c(o,t){let e=typeof o=="string"?JSON.stringify(o):String(o);return t===void 0?e:`${e} ${t}`}function C(o){return String(o.value)}function D(o,t){return new d(t,v(o,t))}var O=["a","an","and","or","but","if","then","the","this","that","these","those","in","on","at","to","of","for","from","with","by","as","per","into","over","is","are","was","were","be","been","being","do","does","did","have","has","had","will","would","can","could","should","may","might","must","price","cost","value","total","sum","count","rate","amount","number","time","date","day","week","month","year","hour","minute","second","add","buy","sell","hold","make","take","give","get","set","run","up","down","out","off","all","some","any","no","not","more","less","one","two","three","first","last","next","each","every","here","there"],$=["error","warning","info"];function k(o){let t=[],e=o.lexerVocabulary;if(e?.keywords)for(let[r,s]of Object.entries(e.keywords))t.push({word:r,via:"keyword",tokenType:s});if(e?.units)for(let r of e.units)t.push({word:r,via:"unit"});if(e?.operators)for(let[r,s]of Object.entries(e.operators))t.push({word:r,via:"operator",tokenType:s});if(o.phrases)for(let[r,s]of Object.entries(o.phrases))r.includes(" ")||t.push({word:r,via:"phrase",tokenType:s});return t}var p=class{constructor(t){this.pkg=t;}notToShadow(t=O){let e=new Set(t.map(s=>s.toLowerCase())),r=k(this.pkg).filter(s=>e.has(s.word.toLowerCase()));if(r.length>0){let s=r.map(a=>`"${a.word}" (${a.via})`).join(", ");throw new i({code:"PACKAGE_SHADOWS_PROSE",message:`Package "${this.pkg.name}" claims prose word(s) as syntax: ${s}. A word that is also ordinary English turns prose into arithmetic; prefer a multi-word phrase or a form that requires a parenthesis.`,expected:"no prose words claimed as syntax",actual:s})}return r}notToCollideWith(t,e="error"){let r=chunkOWQF6ZOK_cjs.a(this.pkg,t),s=$.indexOf(e),a=r.conflicts.filter(u=>$.indexOf(u.severity)<=s);if(a.length>0){let u=a.map(g=>`[${g.severity}] ${g.detail}`).join(`
2
2
  `);throw new i({code:"PACKAGE_VOCABULARY_COLLISION",message:`Package "${this.pkg.name}" collides with another package:
3
- ${u}`,expected:`no conflicts at or above "${e}" severity`,actual:`${a.length} conflict(s)`})}return r}toDeclareCompatibleEngineVersion(t=chunkCIENDLKV_cjs.a){let e=chunkOZ6SKIPD_cjs.b(this.pkg,t);if(!e.compatible){let r=e.reason==="invalid-range"?`its range "${e.declaredRange}" is not valid semver`:`its range "${e.declaredRange}" is not satisfied by engine version "${e.engineVersion}"`;throw new i({code:"PACKAGE_ENGINE_VERSION_INCOMPATIBLE",message:`Package "${this.pkg.name}" declares an engineVersion that will be rejected at registration: ${r}.`,expected:`an engineVersion satisfied by "${t}"`,actual:`"${e.declaredRange}"`})}return this}};function L(o){return new p(o)}exports.COMMON_PROSE_WORDS=O;exports.ExpectationError=i;exports.ExpressionAssertion=d;exports.PackageAssertion=p;exports.createTestEngine=V;exports.expectExpression=D;exports.expectPackage=L;//# sourceMappingURL=testing.cjs.map
3
+ ${u}`,expected:`no conflicts at or above "${e}" severity`,actual:`${a.length} conflict(s)`})}return r}toDeclareCompatibleEngineVersion(t=chunk6ILXAGWX_cjs.a){let e=chunkOWQF6ZOK_cjs.b(this.pkg,t);if(!e.compatible){let r=e.reason==="invalid-range"?`its range "${e.declaredRange}" is not valid semver`:`its range "${e.declaredRange}" is not satisfied by engine version "${e.engineVersion}"`;throw new i({code:"PACKAGE_ENGINE_VERSION_INCOMPATIBLE",message:`Package "${this.pkg.name}" declares an engineVersion that will be rejected at registration: ${r}.`,expected:`an engineVersion satisfied by "${t}"`,actual:`"${e.declaredRange}"`})}return this}};function L(o){return new p(o)}exports.COMMON_PROSE_WORDS=O;exports.ExpectationError=i;exports.ExpressionAssertion=d;exports.PackageAssertion=p;exports.createTestEngine=V;exports.expectExpression=D;exports.expectPackage=L;//# sourceMappingURL=testing.cjs.map
4
4
  //# sourceMappingURL=testing.cjs.map
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import {n as n$1,a,b}from'./chunk-2V44X7GH.js';import'./chunk-JQBG3LX4.js';import'./chunk-2RWAXT6O.js';import'./chunk-7E7NXKQ5.js';import'./chunk-MIQBJGGR.js';import'./chunk-EOMHELRL.js';import'./chunk-KHCNMNZZ.js';import'./chunk-LH7URJZT.js';import'./chunk-XEIDV5JP.js';import {y}from'./chunk-HDVZZ7JN.js';import'./chunk-JEFMG6CV.js';import'./chunk-T3FBAFRR.js';import'./chunk-YVKHEAFT.js';import'./chunk-3GAWAMT4.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-YTCTUBR2.js';import'./chunk-YAYBVVG2.js';import'./chunk-YNMMRH44.js';import'./chunk-HFKDWQUL.js';import'./chunk-5TCSFTZD.js';import'./chunk-WTEXBPBR.js';import {m}from'./chunk-A33K7NY4.js';import'./chunk-DLAKPF5T.js';import {a as a$1}from'./chunk-UKDUFMT5.js';import'./chunk-QYO7IEPR.js';import'./chunk-JPFCXLJV.js';import'./chunk-GMSBBLUQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-UWAXJX5G.js';import'./chunk-44EOEWGP.js';import {b as b$1}from'./chunk-MPB7KUN5.js';var i=class o extends Error{constructor(t){super(t.message),this.name="ExpectationError",this.code=t.code,this.expected=t.expected,this.actual=t.actual,Object.setPrototypeOf(this,o.prototype);}};function V(o=[],t={}){let{locale:e="en",includeBuiltins:r=true}=t,s=new n$1({locale:e,packages:r?y:[]});for(let a of o)s.registerPackage(a);return s}function v(o,t){try{let e=o.evaluateExpression(t);return e.isError()?{status:"error",code:e.errorCode??"",message:e.errorMessage??"",source:e}:e.isPending()?{status:"pending",value:e}:{status:"value",value:e}}catch(e){if(e instanceof b$1)return {status:"error",code:e.code,message:e.message,source:e};let r=e instanceof Error?e.message:String(e);return {status:"error",code:"UNKNOWN_ERROR",message:r,source:new m(13,"UNKNOWN_ERROR",r)}}}function x(o,t){if(Object.is(o,t))return true;if(!Number.isFinite(o)||!Number.isFinite(t))return false;let e=1e-9*Math.max(1,Math.abs(o),Math.abs(t));return Math.abs(o-t)<=e}function l(o){return o.type===3?JSON.stringify(o.value):o.type===6&&typeof o.unit=="string"?`${String(o.value)} ${o.unit}`:String(o.value)}function n(o){switch(o.status){case "value":return l(o.value);case "pending":return "a pending async value";case "error":return `an error (${o.code}: ${o.message})`}}var d=class{constructor(t,e){this.expression=t;this.outcome=e;}get value(){if(this.outcome.status==="error")throw new i({code:"EXPECTED_VALUE",message:`Expected "${this.expression}" to evaluate, but it failed with ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this.outcome.value}toEvaluate(){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EVALUATE",message:`Expected "${this.expression}" to evaluate to a value, but got ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this}toEqual(t,e){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but got ${n(this.outcome)}.`,expected:c(t,e),actual:n(this.outcome)});let r=this.outcome.value,s;if(typeof t=="number"?s=x(r.toNumber(),t):typeof t=="boolean"?s=r.type===10&&r.value===t:s=C(r)===t,!s)throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but it was ${l(r)}.`,expected:c(t,e),actual:l(r)});if(e!==void 0&&r.unit!==e)throw new i({code:"EXPECTED_UNIT",message:`Expected "${this.expression}" to carry the unit "${e}", but it was ${r.unit===void 0?"unitless":`"${r.unit}"`}.`,expected:`unit "${e}"`,actual:r.unit===void 0?"no unit":`unit "${r.unit}"`});return this}toBeError(){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_ERROR",message:`Expected "${this.expression}" to fail, but it produced ${n(this.outcome)}.`,expected:"an error",actual:n(this.outcome)});return this}toFailWith(t){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it produced ${n(this.outcome)}.`,expected:`error code "${t}"`,actual:n(this.outcome)});if(this.outcome.code!==t)throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it failed with "${this.outcome.code}" (${this.outcome.message}).`,expected:`error code "${t}"`,actual:`error code "${this.outcome.code}"`});return this}toBePending(){if(this.outcome.status!=="pending")throw new i({code:"EXPECTED_PENDING",message:`Expected "${this.expression}" to be pending, but got ${n(this.outcome)}.`,expected:"a pending async value",actual:n(this.outcome)});return this}};function c(o,t){let e=typeof o=="string"?JSON.stringify(o):String(o);return t===void 0?e:`${e} ${t}`}function C(o){return String(o.value)}function D(o,t){return new d(t,v(o,t))}var O=["a","an","and","or","but","if","then","the","this","that","these","those","in","on","at","to","of","for","from","with","by","as","per","into","over","is","are","was","were","be","been","being","do","does","did","have","has","had","will","would","can","could","should","may","might","must","price","cost","value","total","sum","count","rate","amount","number","time","date","day","week","month","year","hour","minute","second","add","buy","sell","hold","make","take","give","get","set","run","up","down","out","off","all","some","any","no","not","more","less","one","two","three","first","last","next","each","every","here","there"],$=["error","warning","info"];function k(o){let t=[],e=o.lexerVocabulary;if(e?.keywords)for(let[r,s]of Object.entries(e.keywords))t.push({word:r,via:"keyword",tokenType:s});if(e?.units)for(let r of e.units)t.push({word:r,via:"unit"});if(e?.operators)for(let[r,s]of Object.entries(e.operators))t.push({word:r,via:"operator",tokenType:s});if(o.phrases)for(let[r,s]of Object.entries(o.phrases))r.includes(" ")||t.push({word:r,via:"phrase",tokenType:s});return t}var p=class{constructor(t){this.pkg=t;}notToShadow(t=O){let e=new Set(t.map(s=>s.toLowerCase())),r=k(this.pkg).filter(s=>e.has(s.word.toLowerCase()));if(r.length>0){let s=r.map(a=>`"${a.word}" (${a.via})`).join(", ");throw new i({code:"PACKAGE_SHADOWS_PROSE",message:`Package "${this.pkg.name}" claims prose word(s) as syntax: ${s}. A word that is also ordinary English turns prose into arithmetic; prefer a multi-word phrase or a form that requires a parenthesis.`,expected:"no prose words claimed as syntax",actual:s})}return r}notToCollideWith(t,e="error"){let r=a(this.pkg,t),s=$.indexOf(e),a$1=r.conflicts.filter(u=>$.indexOf(u.severity)<=s);if(a$1.length>0){let u=a$1.map(g=>`[${g.severity}] ${g.detail}`).join(`
1
+ import {n as n$1,a,b}from'./chunk-P7XWFT45.js';import'./chunk-JQBG3LX4.js';import'./chunk-2RWAXT6O.js';import'./chunk-7E7NXKQ5.js';import'./chunk-MIQBJGGR.js';import'./chunk-K4MME6ZT.js';import'./chunk-KHCNMNZZ.js';import'./chunk-LH7URJZT.js';import'./chunk-XEIDV5JP.js';import {y}from'./chunk-HE7E6M5O.js';import'./chunk-JEFMG6CV.js';import'./chunk-T3FBAFRR.js';import'./chunk-YVKHEAFT.js';import'./chunk-3GAWAMT4.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-YTCTUBR2.js';import'./chunk-YAYBVVG2.js';import'./chunk-YNMMRH44.js';import'./chunk-HFKDWQUL.js';import'./chunk-5TCSFTZD.js';import'./chunk-WTEXBPBR.js';import {m}from'./chunk-A33K7NY4.js';import'./chunk-DLAKPF5T.js';import {a as a$1}from'./chunk-OVNB7MI5.js';import'./chunk-QYO7IEPR.js';import'./chunk-JPFCXLJV.js';import'./chunk-GMSBBLUQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-UWAXJX5G.js';import'./chunk-44EOEWGP.js';import {b as b$1}from'./chunk-MPB7KUN5.js';var i=class o extends Error{constructor(t){super(t.message),this.name="ExpectationError",this.code=t.code,this.expected=t.expected,this.actual=t.actual,Object.setPrototypeOf(this,o.prototype);}};function V(o=[],t={}){let{locale:e="en",includeBuiltins:r=true}=t,s=new n$1({locale:e,packages:r?y:[]});for(let a of o)s.registerPackage(a);return s}function v(o,t){try{let e=o.evaluateExpression(t);return e.isError()?{status:"error",code:e.errorCode??"",message:e.errorMessage??"",source:e}:e.isPending()?{status:"pending",value:e}:{status:"value",value:e}}catch(e){if(e instanceof b$1)return {status:"error",code:e.code,message:e.message,source:e};let r=e instanceof Error?e.message:String(e);return {status:"error",code:"UNKNOWN_ERROR",message:r,source:new m(13,"UNKNOWN_ERROR",r)}}}function x(o,t){if(Object.is(o,t))return true;if(!Number.isFinite(o)||!Number.isFinite(t))return false;let e=1e-9*Math.max(1,Math.abs(o),Math.abs(t));return Math.abs(o-t)<=e}function l(o){return o.type===3?JSON.stringify(o.value):o.type===6&&typeof o.unit=="string"?`${String(o.value)} ${o.unit}`:String(o.value)}function n(o){switch(o.status){case "value":return l(o.value);case "pending":return "a pending async value";case "error":return `an error (${o.code}: ${o.message})`}}var d=class{constructor(t,e){this.expression=t;this.outcome=e;}get value(){if(this.outcome.status==="error")throw new i({code:"EXPECTED_VALUE",message:`Expected "${this.expression}" to evaluate, but it failed with ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this.outcome.value}toEvaluate(){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EVALUATE",message:`Expected "${this.expression}" to evaluate to a value, but got ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this}toEqual(t,e){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but got ${n(this.outcome)}.`,expected:c(t,e),actual:n(this.outcome)});let r=this.outcome.value,s;if(typeof t=="number"?s=x(r.toNumber(),t):typeof t=="boolean"?s=r.type===10&&r.value===t:s=C(r)===t,!s)throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but it was ${l(r)}.`,expected:c(t,e),actual:l(r)});if(e!==void 0&&r.unit!==e)throw new i({code:"EXPECTED_UNIT",message:`Expected "${this.expression}" to carry the unit "${e}", but it was ${r.unit===void 0?"unitless":`"${r.unit}"`}.`,expected:`unit "${e}"`,actual:r.unit===void 0?"no unit":`unit "${r.unit}"`});return this}toBeError(){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_ERROR",message:`Expected "${this.expression}" to fail, but it produced ${n(this.outcome)}.`,expected:"an error",actual:n(this.outcome)});return this}toFailWith(t){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it produced ${n(this.outcome)}.`,expected:`error code "${t}"`,actual:n(this.outcome)});if(this.outcome.code!==t)throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it failed with "${this.outcome.code}" (${this.outcome.message}).`,expected:`error code "${t}"`,actual:`error code "${this.outcome.code}"`});return this}toBePending(){if(this.outcome.status!=="pending")throw new i({code:"EXPECTED_PENDING",message:`Expected "${this.expression}" to be pending, but got ${n(this.outcome)}.`,expected:"a pending async value",actual:n(this.outcome)});return this}};function c(o,t){let e=typeof o=="string"?JSON.stringify(o):String(o);return t===void 0?e:`${e} ${t}`}function C(o){return String(o.value)}function D(o,t){return new d(t,v(o,t))}var O=["a","an","and","or","but","if","then","the","this","that","these","those","in","on","at","to","of","for","from","with","by","as","per","into","over","is","are","was","were","be","been","being","do","does","did","have","has","had","will","would","can","could","should","may","might","must","price","cost","value","total","sum","count","rate","amount","number","time","date","day","week","month","year","hour","minute","second","add","buy","sell","hold","make","take","give","get","set","run","up","down","out","off","all","some","any","no","not","more","less","one","two","three","first","last","next","each","every","here","there"],$=["error","warning","info"];function k(o){let t=[],e=o.lexerVocabulary;if(e?.keywords)for(let[r,s]of Object.entries(e.keywords))t.push({word:r,via:"keyword",tokenType:s});if(e?.units)for(let r of e.units)t.push({word:r,via:"unit"});if(e?.operators)for(let[r,s]of Object.entries(e.operators))t.push({word:r,via:"operator",tokenType:s});if(o.phrases)for(let[r,s]of Object.entries(o.phrases))r.includes(" ")||t.push({word:r,via:"phrase",tokenType:s});return t}var p=class{constructor(t){this.pkg=t;}notToShadow(t=O){let e=new Set(t.map(s=>s.toLowerCase())),r=k(this.pkg).filter(s=>e.has(s.word.toLowerCase()));if(r.length>0){let s=r.map(a=>`"${a.word}" (${a.via})`).join(", ");throw new i({code:"PACKAGE_SHADOWS_PROSE",message:`Package "${this.pkg.name}" claims prose word(s) as syntax: ${s}. A word that is also ordinary English turns prose into arithmetic; prefer a multi-word phrase or a form that requires a parenthesis.`,expected:"no prose words claimed as syntax",actual:s})}return r}notToCollideWith(t,e="error"){let r=a(this.pkg,t),s=$.indexOf(e),a$1=r.conflicts.filter(u=>$.indexOf(u.severity)<=s);if(a$1.length>0){let u=a$1.map(g=>`[${g.severity}] ${g.detail}`).join(`
2
2
  `);throw new i({code:"PACKAGE_VOCABULARY_COLLISION",message:`Package "${this.pkg.name}" collides with another package:
3
3
  ${u}`,expected:`no conflicts at or above "${e}" severity`,actual:`${a$1.length} conflict(s)`})}return r}toDeclareCompatibleEngineVersion(t=a$1){let e=b(this.pkg,t);if(!e.compatible){let r=e.reason==="invalid-range"?`its range "${e.declaredRange}" is not valid semver`:`its range "${e.declaredRange}" is not satisfied by engine version "${e.engineVersion}"`;throw new i({code:"PACKAGE_ENGINE_VERSION_INCOMPATIBLE",message:`Package "${this.pkg.name}" declares an engineVersion that will be rejected at registration: ${r}.`,expected:`an engineVersion satisfied by "${t}"`,actual:`"${e.declaredRange}"`})}return this}};function L(o){return new p(o)}export{O as COMMON_PROSE_WORDS,i as ExpectationError,d as ExpressionAssertion,p as PackageAssertion,V as createTestEngine,D as expectExpression,L as expectPackage};//# sourceMappingURL=testing.js.map
4
4
  //# sourceMappingURL=testing.js.map
package/dist/vm.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkTUBLMUTZ_cjs=require('./chunk-TUBLMUTZ.cjs');require('./chunk-MVP2YD4X.cjs');var chunkEURCQMZK_cjs=require('./chunk-EURCQMZK.cjs');require('./chunk-4BZIYU7S.cjs'),require('./chunk-VBSMA7WJ.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-75XDS65A.cjs');var chunkPNDQRCRQ_cjs=require('./chunk-PNDQRCRQ.cjs');require('./chunk-BKSKZA4W.cjs'),require('./chunk-6QRHN3I6.cjs'),require('./chunk-SOMGSIO4.cjs');var l=class{constructor(t){this.checkpoints=[];this.vm=t;}snapshot(t,n,e){if(e.length===0)return null;let r=this.checkpoints.length>0?this.checkpoints[this.checkpoints.length-1]:null,o=Object.create(r?.variables??null),i=Object.create(r?.functions??null);for(let s of e){if(this.vm.hasUserFunction(s)){let p=this.vm.getUserFunction(s);p&&(i[s]=p);continue}let u=this.vm.getVar(s);u!==void 0&&(o[s]=u);}let c={lineNumber:t,lineId:n,variables:o,functions:i,parent:r};return this.checkpoints.push(c),c}restoreTo(t){let n=this.getNearestCheckpoint(t);if(!n){this.vm.reset();return}let e=[],r=n;for(;r;)e.unshift(r),r=r.parent;this.vm.reset();for(let o of e){for(let i of Object.keys(o.variables))this.vm.setVar(i,o.variables[i]);for(let i of Object.keys(o.functions)){let c=o.functions[i];this.vm.defineUserFunction(c.name,c.params,c.program);}}}getNearestCheckpoint(t){let n=null;for(let e of this.checkpoints)if(e.lineNumber<=t)n=e;else break;return n}getCheckpointAt(t){return this.checkpoints.find(n=>n.lineNumber===t)}getAllCheckpoints(){return this.checkpoints}lookupVariable(t){if(this.checkpoints.length===0)return;let e=this.checkpoints[this.checkpoints.length-1].variables;for(;e;){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];e=Object.getPrototypeOf(e);}}clear(){this.checkpoints=[];}get count(){return this.checkpoints.length}get isEmpty(){return this.checkpoints.length===0}get vmInstance(){return this.vm}};Object.defineProperty(exports,"DependencyGraph",{enumerable:true,get:function(){return chunkTUBLMUTZ_cjs.a}});Object.defineProperty(exports,"ScopeManager",{enumerable:true,get:function(){return chunkTUBLMUTZ_cjs.b}});Object.defineProperty(exports,"createVM",{enumerable:true,get:function(){return chunkTUBLMUTZ_cjs.c}});Object.defineProperty(exports,"executeBytecode",{enumerable:true,get:function(){return chunkTUBLMUTZ_cjs.d}});Object.defineProperty(exports,"OpRegistry",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.v}});Object.defineProperty(exports,"allocatePluginFunctionIndex",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.E}});Object.defineProperty(exports,"binaryOp",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.u}});Object.defineProperty(exports,"builtinFunctions",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.C}});Object.defineProperty(exports,"pluginFunctionIndexFor",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.F}});Object.defineProperty(exports,"pluginFunctionRegistry",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.D}});Object.defineProperty(exports,"sharedOpRegistry",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.w}});Object.defineProperty(exports,"unifyUom",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.j}});Object.defineProperty(exports,"Value",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.m}});Object.defineProperty(exports,"ValueType",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.g}});Object.defineProperty(exports,"bigIntValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.s}});Object.defineProperty(exports,"chargeAllocation",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.c}});Object.defineProperty(exports,"checkAllocation",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.d}});Object.defineProperty(exports,"checkedArray",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.e}});Object.defineProperty(exports,"colVectorValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.E}});Object.defineProperty(exports,"hexValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.r}});Object.defineProperty(exports,"matrixValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.C}});Object.defineProperty(exports,"numberValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.n}});Object.defineProperty(exports,"rangeValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.F}});Object.defineProperty(exports,"rowVectorValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.D}});Object.defineProperty(exports,"stringValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.t}});Object.defineProperty(exports,"uomValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.u}});exports.VMCheckpointer=l;//# sourceMappingURL=vm.cjs.map
1
+ 'use strict';var chunk556Q7VZC_cjs=require('./chunk-556Q7VZC.cjs');require('./chunk-MVP2YD4X.cjs');var chunkEURCQMZK_cjs=require('./chunk-EURCQMZK.cjs');require('./chunk-4BZIYU7S.cjs'),require('./chunk-VBSMA7WJ.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-75XDS65A.cjs');var chunkPNDQRCRQ_cjs=require('./chunk-PNDQRCRQ.cjs');require('./chunk-BKSKZA4W.cjs'),require('./chunk-6QRHN3I6.cjs'),require('./chunk-SOMGSIO4.cjs');var l=class{constructor(t){this.checkpoints=[];this.vm=t;}snapshot(t,n,e){if(e.length===0)return null;let r=this.checkpoints.length>0?this.checkpoints[this.checkpoints.length-1]:null,o=Object.create(r?.variables??null),i=Object.create(r?.functions??null);for(let s of e){if(this.vm.hasUserFunction(s)){let p=this.vm.getUserFunction(s);p&&(i[s]=p);continue}let u=this.vm.getVar(s);u!==void 0&&(o[s]=u);}let c={lineNumber:t,lineId:n,variables:o,functions:i,parent:r};return this.checkpoints.push(c),c}restoreTo(t){let n=this.getNearestCheckpoint(t);if(!n){this.vm.reset();return}let e=[],r=n;for(;r;)e.unshift(r),r=r.parent;this.vm.reset();for(let o of e){for(let i of Object.keys(o.variables))this.vm.setVar(i,o.variables[i]);for(let i of Object.keys(o.functions)){let c=o.functions[i];this.vm.defineUserFunction(c.name,c.params,c.program);}}}getNearestCheckpoint(t){let n=null;for(let e of this.checkpoints)if(e.lineNumber<=t)n=e;else break;return n}getCheckpointAt(t){return this.checkpoints.find(n=>n.lineNumber===t)}getAllCheckpoints(){return this.checkpoints}lookupVariable(t){if(this.checkpoints.length===0)return;let e=this.checkpoints[this.checkpoints.length-1].variables;for(;e;){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];e=Object.getPrototypeOf(e);}}clear(){this.checkpoints=[];}get count(){return this.checkpoints.length}get isEmpty(){return this.checkpoints.length===0}get vmInstance(){return this.vm}};Object.defineProperty(exports,"DependencyGraph",{enumerable:true,get:function(){return chunk556Q7VZC_cjs.a}});Object.defineProperty(exports,"ScopeManager",{enumerable:true,get:function(){return chunk556Q7VZC_cjs.b}});Object.defineProperty(exports,"createVM",{enumerable:true,get:function(){return chunk556Q7VZC_cjs.c}});Object.defineProperty(exports,"executeBytecode",{enumerable:true,get:function(){return chunk556Q7VZC_cjs.d}});Object.defineProperty(exports,"OpRegistry",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.v}});Object.defineProperty(exports,"allocatePluginFunctionIndex",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.E}});Object.defineProperty(exports,"binaryOp",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.u}});Object.defineProperty(exports,"builtinFunctions",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.C}});Object.defineProperty(exports,"pluginFunctionIndexFor",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.F}});Object.defineProperty(exports,"pluginFunctionRegistry",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.D}});Object.defineProperty(exports,"sharedOpRegistry",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.w}});Object.defineProperty(exports,"unifyUom",{enumerable:true,get:function(){return chunkEURCQMZK_cjs.j}});Object.defineProperty(exports,"Value",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.m}});Object.defineProperty(exports,"ValueType",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.g}});Object.defineProperty(exports,"bigIntValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.s}});Object.defineProperty(exports,"chargeAllocation",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.c}});Object.defineProperty(exports,"checkAllocation",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.d}});Object.defineProperty(exports,"checkedArray",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.e}});Object.defineProperty(exports,"colVectorValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.E}});Object.defineProperty(exports,"hexValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.r}});Object.defineProperty(exports,"matrixValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.C}});Object.defineProperty(exports,"numberValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.n}});Object.defineProperty(exports,"rangeValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.F}});Object.defineProperty(exports,"rowVectorValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.D}});Object.defineProperty(exports,"stringValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.t}});Object.defineProperty(exports,"uomValue",{enumerable:true,get:function(){return chunkPNDQRCRQ_cjs.u}});exports.VMCheckpointer=l;//# sourceMappingURL=vm.cjs.map
2
2
  //# sourceMappingURL=vm.cjs.map
package/dist/vm.js CHANGED
@@ -1,2 +1,2 @@
1
- export{a as DependencyGraph,b as ScopeManager,c as createVM,d as executeBytecode}from'./chunk-EOMHELRL.js';import'./chunk-KHCNMNZZ.js';export{v as OpRegistry,E as allocatePluginFunctionIndex,u as binaryOp,C as builtinFunctions,F as pluginFunctionIndexFor,D as pluginFunctionRegistry,w as sharedOpRegistry,j as unifyUom}from'./chunk-YTCTUBR2.js';import'./chunk-YAYBVVG2.js';import'./chunk-YNMMRH44.js';import'./chunk-HFKDWQUL.js';import'./chunk-WTEXBPBR.js';export{m as Value,g as ValueType,s as bigIntValue,c as chargeAllocation,d as checkAllocation,e as checkedArray,E as colVectorValue,r as hexValue,C as matrixValue,n as numberValue,F as rangeValue,D as rowVectorValue,t as stringValue,u as uomValue}from'./chunk-A33K7NY4.js';import'./chunk-DLAKPF5T.js';import'./chunk-44EOEWGP.js';import'./chunk-MPB7KUN5.js';var l=class{constructor(t){this.checkpoints=[];this.vm=t;}snapshot(t,n,e){if(e.length===0)return null;let r=this.checkpoints.length>0?this.checkpoints[this.checkpoints.length-1]:null,o=Object.create(r?.variables??null),i=Object.create(r?.functions??null);for(let s of e){if(this.vm.hasUserFunction(s)){let p=this.vm.getUserFunction(s);p&&(i[s]=p);continue}let u=this.vm.getVar(s);u!==void 0&&(o[s]=u);}let c={lineNumber:t,lineId:n,variables:o,functions:i,parent:r};return this.checkpoints.push(c),c}restoreTo(t){let n=this.getNearestCheckpoint(t);if(!n){this.vm.reset();return}let e=[],r=n;for(;r;)e.unshift(r),r=r.parent;this.vm.reset();for(let o of e){for(let i of Object.keys(o.variables))this.vm.setVar(i,o.variables[i]);for(let i of Object.keys(o.functions)){let c=o.functions[i];this.vm.defineUserFunction(c.name,c.params,c.program);}}}getNearestCheckpoint(t){let n=null;for(let e of this.checkpoints)if(e.lineNumber<=t)n=e;else break;return n}getCheckpointAt(t){return this.checkpoints.find(n=>n.lineNumber===t)}getAllCheckpoints(){return this.checkpoints}lookupVariable(t){if(this.checkpoints.length===0)return;let e=this.checkpoints[this.checkpoints.length-1].variables;for(;e;){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];e=Object.getPrototypeOf(e);}}clear(){this.checkpoints=[];}get count(){return this.checkpoints.length}get isEmpty(){return this.checkpoints.length===0}get vmInstance(){return this.vm}};export{l as VMCheckpointer};//# sourceMappingURL=vm.js.map
1
+ export{a as DependencyGraph,b as ScopeManager,c as createVM,d as executeBytecode}from'./chunk-K4MME6ZT.js';import'./chunk-KHCNMNZZ.js';export{v as OpRegistry,E as allocatePluginFunctionIndex,u as binaryOp,C as builtinFunctions,F as pluginFunctionIndexFor,D as pluginFunctionRegistry,w as sharedOpRegistry,j as unifyUom}from'./chunk-YTCTUBR2.js';import'./chunk-YAYBVVG2.js';import'./chunk-YNMMRH44.js';import'./chunk-HFKDWQUL.js';import'./chunk-WTEXBPBR.js';export{m as Value,g as ValueType,s as bigIntValue,c as chargeAllocation,d as checkAllocation,e as checkedArray,E as colVectorValue,r as hexValue,C as matrixValue,n as numberValue,F as rangeValue,D as rowVectorValue,t as stringValue,u as uomValue}from'./chunk-A33K7NY4.js';import'./chunk-DLAKPF5T.js';import'./chunk-44EOEWGP.js';import'./chunk-MPB7KUN5.js';var l=class{constructor(t){this.checkpoints=[];this.vm=t;}snapshot(t,n,e){if(e.length===0)return null;let r=this.checkpoints.length>0?this.checkpoints[this.checkpoints.length-1]:null,o=Object.create(r?.variables??null),i=Object.create(r?.functions??null);for(let s of e){if(this.vm.hasUserFunction(s)){let p=this.vm.getUserFunction(s);p&&(i[s]=p);continue}let u=this.vm.getVar(s);u!==void 0&&(o[s]=u);}let c={lineNumber:t,lineId:n,variables:o,functions:i,parent:r};return this.checkpoints.push(c),c}restoreTo(t){let n=this.getNearestCheckpoint(t);if(!n){this.vm.reset();return}let e=[],r=n;for(;r;)e.unshift(r),r=r.parent;this.vm.reset();for(let o of e){for(let i of Object.keys(o.variables))this.vm.setVar(i,o.variables[i]);for(let i of Object.keys(o.functions)){let c=o.functions[i];this.vm.defineUserFunction(c.name,c.params,c.program);}}}getNearestCheckpoint(t){let n=null;for(let e of this.checkpoints)if(e.lineNumber<=t)n=e;else break;return n}getCheckpointAt(t){return this.checkpoints.find(n=>n.lineNumber===t)}getAllCheckpoints(){return this.checkpoints}lookupVariable(t){if(this.checkpoints.length===0)return;let e=this.checkpoints[this.checkpoints.length-1].variables;for(;e;){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];e=Object.getPrototypeOf(e);}}clear(){this.checkpoints=[];}get count(){return this.checkpoints.length}get isEmpty(){return this.checkpoints.length===0}get vmInstance(){return this.vm}};export{l as VMCheckpointer};//# sourceMappingURL=vm.js.map
2
2
  //# sourceMappingURL=vm.js.map
package/dist/worker.cjs CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var chunkP6WPEUAJ_cjs=require('./chunk-P6WPEUAJ.cjs'),chunkOZ6SKIPD_cjs=require('./chunk-OZ6SKIPD.cjs');require('./chunk-FNNIAJNY.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-LNZNJSRW.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-TUBLMUTZ.cjs'),require('./chunk-MVP2YD4X.cjs');var chunk6TPXH6Y5_cjs=require('./chunk-6TPXH6Y5.cjs');require('./chunk-R2SZFJTT.cjs');var chunkU47GA63S_cjs=require('./chunk-U47GA63S.cjs');require('./chunk-FUDVKPB7.cjs'),require('./chunk-WYIOXAFW.cjs'),require('./chunk-4QVBSG6B.cjs'),require('./chunk-C65UDMWH.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-EURCQMZK.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-VBSMA7WJ.cjs'),require('./chunk-TLG7VZRX.cjs');var chunk5TVI2UPZ_cjs=require('./chunk-5TVI2UPZ.cjs'),chunk75XDS65A_cjs=require('./chunk-75XDS65A.cjs');require('./chunk-PNDQRCRQ.cjs'),require('./chunk-BKSKZA4W.cjs'),require('./chunk-CIENDLKV.cjs'),require('./chunk-3HYO3QYW.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-SNVPM27Q.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-WEAKI5V5.cjs'),require('./chunk-6QRHN3I6.cjs');var chunkSOMGSIO4_cjs=require('./chunk-SOMGSIO4.cjs');var W=class{constructor(r){this.nextId=1;this.pending=new Map;this.resolvedListeners=new Set;this.asyncErrorListeners=new Set;this.terminated=false;this.transport=r,this.transport.onMessage(n=>this.onMessage(n));}init(r){let n=this.nextId++;return new Promise((t,s)=>{this.pending.set(n,{resolve:()=>t(),reject:s}),this.transport.postMessage({kind:"init",id:n,localeCode:r.localeCode,diagnostics:r.diagnostics,config:r.config,packages:r.packages,formatting:r.formatting});})}parseDocument(r,n){let{signal:t,...s}=n??{},i=Object.keys(s).length>0?s:void 0;return this.call("parseDocument",[r,i],t)}evaluateLines(r,n){return this.call("evaluateLines",[r],n?.signal)}evaluateExpression(r,n){return this.call("evaluateExpression",[r],n?.signal)}onResolved(r){return this.resolvedListeners.add(r),()=>this.resolvedListeners.delete(r)}onAsyncError(r){return this.asyncErrorListeners.add(r),()=>this.asyncErrorListeners.delete(r)}terminate(){if(this.terminated)return;this.terminated=true;let r=chunkP6WPEUAJ_cjs.e();for(let n of this.pending.values())this.unhook(n),n.reject(r);this.pending.clear(),this.resolvedListeners.clear(),this.asyncErrorListeners.clear(),this.transport.terminate();}call(r,n,t){if(this.terminated)return Promise.reject(chunkP6WPEUAJ_cjs.e());if(t?.aborted)return Promise.reject(chunkP6WPEUAJ_cjs.d(r));let s=this.nextId++;return new Promise((i,l)=>{let p={resolve:i,reject:l};if(t){let c=()=>{this.pending.has(s)&&(this.pending.delete(s),this.transport.postMessage({kind:"cancel",id:s}),l(chunkP6WPEUAJ_cjs.d(r)));};p.signal=t,p.onAbort=c,t.addEventListener("abort",c,{once:true});}this.pending.set(s,p),this.transport.postMessage({kind:"request",id:s,method:r,args:n});})}onMessage(r){let n=r;switch(n.kind){case "ready":case "result":{let t=n.kind==="result"?n.value:void 0;this.settle(n.id,s=>s.resolve(t));break}case "error":this.settle(n.id,t=>t.reject(chunkP6WPEUAJ_cjs.c(n.error)));break;case "async-update":for(let t of [...this.resolvedListeners])t(n.lines);break;case "async-error":for(let t of [...this.asyncErrorListeners])t({queryKey:n.queryKey,packageId:n.packageId,error:chunkP6WPEUAJ_cjs.c(n.error)});break}}settle(r,n){let t=this.pending.get(r);t&&(this.pending.delete(r),this.unhook(t),n(t));}unhook(r){r.signal&&r.onAbort&&r.signal.removeEventListener("abort",r.onAbort);}};async function K(e){let r=new W(e.transport);return await r.init(e),r}function C(e){return e>0?"Infinity":e<0?"-Infinity":"NaN"}function U(e){let r=e.data.map(n=>typeof n=="object"&&n!==null?chunk75XDS65A_cjs.R(n):typeof n=="number"&&!Number.isFinite(n)?C(n):n);return {rows:e.rows,cols:e.cols,cells:r,hasSymbolic:e.hasSymbolic}}function m(e,r){let n=e.toNumber(),t={type:e.type,text:chunk6TPXH6Y5_cjs.c(e,r),number:Number.isFinite(n)?n:0};Number.isFinite(n)||(t.nonFinite=C(n)),e.unit!==void 0&&(t.unit=e.unit),e.timedOut!==void 0&&(t.timedOut=e.timedOut);let s=e.value;if(typeof s=="bigint")t.bigint=s.toString();else if(e.type===7)t.matrix=U(s);else if(e.type===8){let i=s;t.range={min:i.min,max:i.max};}else if(e.type===14){let i=s;t.colour={hex:chunk5TVI2UPZ_cjs.f(i),r:i.r,g:i.g,b:i.b,a:i.a,format:i.format,css:chunk5TVI2UPZ_cjs.g(i)};}else if(e.type===16){let i=s;t.chart={kind:i.kind,points:i.points.map(l=>[l[0],l[1]]),label:i.label,domain:[i.domain[0],i.domain[1]],range:[i.range[0],i.range[1]],...i.expr!==void 0?{expr:i.expr}:{}};}else if(e.type===17){let i=s;t.ipCidr={...i.addr!==void 0?{addr:i.addr}:{},...i.prefix!==void 0?{prefix:i.prefix}:{},text:chunk6TPXH6Y5_cjs.c(e).replace(/^=\s*/,"")};}return t}function O(e,r){return e?m(e,r):null}function _(e,r){return {start:e.start,end:e.end,expression:e.expression,lineNumber:e.lineNumber,columnNumber:e.columnNumber,result:O(e.result,r),error:e.error??null}}function y(e,r){return {lineNumber:e.lineNumber,text:e.text,startPosition:e.startPosition,endPosition:e.endPosition,isEmpty:e.isEmpty,hasInlineSolves:e.hasInlineSolves,inlineSolves:e.inlineSolves.map(n=>_(n,r)),expression:e.expression,result:O(e.result,r),error:e.error}}function R(e,r){let n={lines:e.lines.map(t=>y(t,r)),totalLines:e.totalLines,errors:[...e.errors]};return e.diagnostics!==void 0&&(n.diagnostics=e.diagnostics),n}function H(e,r){if(r===void 0)return e;let n=new Map(e.map(s=>[s.name,s])),t=[];for(let s of r){let i=n.get(s);if(!i)throw chunkSOMGSIO4_cjs.c.config(chunkP6WPEUAJ_cjs.a.WORKER_UNKNOWN_PACKAGE,`No package named "${s}" is available in this worker runtime`,{name:s,available:[...n.keys()]});t.push(i);}return t}function B(e,r={}){let n=r.packages??chunkU47GA63S_cjs.y,t=null,s,i=new Map,l=new Map,p=null,c=null,g=o=>e.postMessage(o),h=(o,a)=>{g({kind:"error",id:o,error:chunkP6WPEUAJ_cjs.b(chunkSOMGSIO4_cjs.d(a))});},N=o=>{let a=new Map;return o.method==="parseDocument"?o.args[0].split(`
2
- `).forEach((u,d)=>a.set(d+1,u)):o.method==="evaluateLines"?o.args[0].forEach((u,d)=>a.set(d+1,u)):a.set(-1,o.args[0]),a},q=(o,a)=>{if(a.type==="error"){g({kind:"async-error",queryKey:a.queryKey,packageId:a.packageId,error:chunkP6WPEUAJ_cjs.b(chunkSOMGSIO4_cjs.d(a.error))});return}let u=[];for(let d of a.lineNumbers){let f=l.get(d);if(f!==void 0)try{let L=o.evaluateLine(d,f);L&&u.push({lineNumber:d,value:m(L,s)});}catch{}}u.length>0&&g({kind:"async-update",lines:u});},F=o=>{c?.();let a=o.getEventStream().getReader();c=()=>{a.cancel();},(async()=>{try{for(;;){let{done:u,value:d}=await a.read();if(u)return;q(o,d);}}catch{}})();},D=o=>{try{let a=H(n,o.packages);t=new chunkOZ6SKIPD_cjs.n({locale:o.localeCode??"en",diagnostics:o.diagnostics??!1,config:o.config,packages:a}),s=o.formatting,F(t),g({kind:"ready",id:o.id});}catch(a){h(o.id,a);}},V=(o,a)=>{let{method:u,args:d}=a;switch(u){case "parseDocument":return R(o.parseDocument(d[0],d[1]),s);case "evaluateLines":return o.evaluateLines(d[0]).map(f=>y(f,s));case "evaluateExpression":return m(o.evaluateExpression(d[0]),s);default:throw chunkSOMGSIO4_cjs.c.execution(chunkP6WPEUAJ_cjs.a.WORKER_UNKNOWN_METHOD,`The worker runtime has no method named "${String(u)}"`,{method:u})}},j=o=>{let a=t;if(!a){h(o.id,chunkSOMGSIO4_cjs.c.execution(chunkP6WPEUAJ_cjs.a.WORKER_NOT_INITIALISED,"The worker received a request before its engine finished initialising"));return}p?.abort();let u=new AbortController;p=u,l=N(o),i.set(o.id,u),a.setKeystrokeSignal(u.signal);try{let d=V(a,o);g({kind:"result",id:o.id,value:d});}catch(d){h(o.id,d);}finally{i.delete(o.id),a.setKeystrokeSignal(null);}};return e.onMessage(o=>{let a=o;switch(a.kind){case "init":D(a);break;case "request":j(a);break;case "cancel":i.get(a.id)?.abort();break}}),()=>{c?.(),c=null,p?.abort(),p=null,l=new Map;for(let o of i.values())o.abort();i.clear(),t?.clear(),t=null,e.terminate();}}function G(e){return typeof globalThis.structuredClone=="function"?globalThis.structuredClone(e):JSON.parse(JSON.stringify(e))}function J(){let e=null,r=null,n=true,t=(l,p)=>{let c=G(p);queueMicrotask(()=>{n&&l()?.(c);});};return {client:{postMessage:l=>t(()=>r,l),onMessage:l=>{e=l;},terminate:()=>{n=false;}},host:{postMessage:l=>t(()=>e,l),onMessage:l=>{r=l;},terminate:()=>{n=false;}}}}function $(e){return {postMessage:r=>e.postMessage(r),onMessage:r=>{let n=t=>r(t.data);typeof e.addEventListener=="function"?e.addEventListener("message",n):e.onmessage=n,e.start?.();},terminate:()=>{e.terminate?.(),e.close?.();}}}function Q(e){return {postMessage:r=>e.postMessage(r),onMessage:r=>{e.on("message",n=>r(n));},terminate:()=>{e.terminate?.(),e.close?.();}}}exports.createLinkedTransports=J;exports.createWorkerEngine=K;exports.eventTargetTransport=$;exports.messagePortTransport=Q;exports.serializeParsedLine=y;exports.serializeParsingResult=R;exports.serializeValue=m;exports.startWorkerRuntime=B;//# sourceMappingURL=worker.cjs.map
1
+ 'use strict';var chunkP6WPEUAJ_cjs=require('./chunk-P6WPEUAJ.cjs'),chunkOWQF6ZOK_cjs=require('./chunk-OWQF6ZOK.cjs');require('./chunk-FNNIAJNY.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-LNZNJSRW.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-556Q7VZC.cjs'),require('./chunk-MVP2YD4X.cjs');var chunk6TPXH6Y5_cjs=require('./chunk-6TPXH6Y5.cjs');require('./chunk-R2SZFJTT.cjs');var chunkAEPS7W3D_cjs=require('./chunk-AEPS7W3D.cjs');require('./chunk-FUDVKPB7.cjs'),require('./chunk-WYIOXAFW.cjs'),require('./chunk-4QVBSG6B.cjs'),require('./chunk-C65UDMWH.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-EURCQMZK.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-VBSMA7WJ.cjs'),require('./chunk-TLG7VZRX.cjs');var chunk5TVI2UPZ_cjs=require('./chunk-5TVI2UPZ.cjs'),chunk75XDS65A_cjs=require('./chunk-75XDS65A.cjs');require('./chunk-PNDQRCRQ.cjs'),require('./chunk-BKSKZA4W.cjs'),require('./chunk-6ILXAGWX.cjs'),require('./chunk-3HYO3QYW.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-SNVPM27Q.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-WEAKI5V5.cjs'),require('./chunk-6QRHN3I6.cjs');var chunkSOMGSIO4_cjs=require('./chunk-SOMGSIO4.cjs');var W=class{constructor(r){this.nextId=1;this.pending=new Map;this.resolvedListeners=new Set;this.asyncErrorListeners=new Set;this.terminated=false;this.transport=r,this.transport.onMessage(n=>this.onMessage(n));}init(r){let n=this.nextId++;return new Promise((t,s)=>{this.pending.set(n,{resolve:()=>t(),reject:s}),this.transport.postMessage({kind:"init",id:n,localeCode:r.localeCode,diagnostics:r.diagnostics,config:r.config,packages:r.packages,formatting:r.formatting});})}parseDocument(r,n){let{signal:t,...s}=n??{},i=Object.keys(s).length>0?s:void 0;return this.call("parseDocument",[r,i],t)}evaluateLines(r,n){return this.call("evaluateLines",[r],n?.signal)}evaluateExpression(r,n){return this.call("evaluateExpression",[r],n?.signal)}onResolved(r){return this.resolvedListeners.add(r),()=>this.resolvedListeners.delete(r)}onAsyncError(r){return this.asyncErrorListeners.add(r),()=>this.asyncErrorListeners.delete(r)}terminate(){if(this.terminated)return;this.terminated=true;let r=chunkP6WPEUAJ_cjs.e();for(let n of this.pending.values())this.unhook(n),n.reject(r);this.pending.clear(),this.resolvedListeners.clear(),this.asyncErrorListeners.clear(),this.transport.terminate();}call(r,n,t){if(this.terminated)return Promise.reject(chunkP6WPEUAJ_cjs.e());if(t?.aborted)return Promise.reject(chunkP6WPEUAJ_cjs.d(r));let s=this.nextId++;return new Promise((i,l)=>{let p={resolve:i,reject:l};if(t){let c=()=>{this.pending.has(s)&&(this.pending.delete(s),this.transport.postMessage({kind:"cancel",id:s}),l(chunkP6WPEUAJ_cjs.d(r)));};p.signal=t,p.onAbort=c,t.addEventListener("abort",c,{once:true});}this.pending.set(s,p),this.transport.postMessage({kind:"request",id:s,method:r,args:n});})}onMessage(r){let n=r;switch(n.kind){case "ready":case "result":{let t=n.kind==="result"?n.value:void 0;this.settle(n.id,s=>s.resolve(t));break}case "error":this.settle(n.id,t=>t.reject(chunkP6WPEUAJ_cjs.c(n.error)));break;case "async-update":for(let t of [...this.resolvedListeners])t(n.lines);break;case "async-error":for(let t of [...this.asyncErrorListeners])t({queryKey:n.queryKey,packageId:n.packageId,error:chunkP6WPEUAJ_cjs.c(n.error)});break}}settle(r,n){let t=this.pending.get(r);t&&(this.pending.delete(r),this.unhook(t),n(t));}unhook(r){r.signal&&r.onAbort&&r.signal.removeEventListener("abort",r.onAbort);}};async function K(e){let r=new W(e.transport);return await r.init(e),r}function C(e){return e>0?"Infinity":e<0?"-Infinity":"NaN"}function U(e){let r=e.data.map(n=>typeof n=="object"&&n!==null?chunk75XDS65A_cjs.R(n):typeof n=="number"&&!Number.isFinite(n)?C(n):n);return {rows:e.rows,cols:e.cols,cells:r,hasSymbolic:e.hasSymbolic}}function m(e,r){let n=e.toNumber(),t={type:e.type,text:chunk6TPXH6Y5_cjs.c(e,r),number:Number.isFinite(n)?n:0};Number.isFinite(n)||(t.nonFinite=C(n)),e.unit!==void 0&&(t.unit=e.unit),e.timedOut!==void 0&&(t.timedOut=e.timedOut);let s=e.value;if(typeof s=="bigint")t.bigint=s.toString();else if(e.type===7)t.matrix=U(s);else if(e.type===8){let i=s;t.range={min:i.min,max:i.max};}else if(e.type===14){let i=s;t.colour={hex:chunk5TVI2UPZ_cjs.f(i),r:i.r,g:i.g,b:i.b,a:i.a,format:i.format,css:chunk5TVI2UPZ_cjs.g(i)};}else if(e.type===16){let i=s;t.chart={kind:i.kind,points:i.points.map(l=>[l[0],l[1]]),label:i.label,domain:[i.domain[0],i.domain[1]],range:[i.range[0],i.range[1]],...i.expr!==void 0?{expr:i.expr}:{}};}else if(e.type===17){let i=s;t.ipCidr={...i.addr!==void 0?{addr:i.addr}:{},...i.prefix!==void 0?{prefix:i.prefix}:{},text:chunk6TPXH6Y5_cjs.c(e).replace(/^=\s*/,"")};}return t}function O(e,r){return e?m(e,r):null}function _(e,r){return {start:e.start,end:e.end,expression:e.expression,lineNumber:e.lineNumber,columnNumber:e.columnNumber,result:O(e.result,r),error:e.error??null}}function y(e,r){return {lineNumber:e.lineNumber,text:e.text,startPosition:e.startPosition,endPosition:e.endPosition,isEmpty:e.isEmpty,hasInlineSolves:e.hasInlineSolves,inlineSolves:e.inlineSolves.map(n=>_(n,r)),expression:e.expression,result:O(e.result,r),error:e.error}}function R(e,r){let n={lines:e.lines.map(t=>y(t,r)),totalLines:e.totalLines,errors:[...e.errors]};return e.diagnostics!==void 0&&(n.diagnostics=e.diagnostics),n}function H(e,r){if(r===void 0)return e;let n=new Map(e.map(s=>[s.name,s])),t=[];for(let s of r){let i=n.get(s);if(!i)throw chunkSOMGSIO4_cjs.c.config(chunkP6WPEUAJ_cjs.a.WORKER_UNKNOWN_PACKAGE,`No package named "${s}" is available in this worker runtime`,{name:s,available:[...n.keys()]});t.push(i);}return t}function B(e,r={}){let n=r.packages??chunkAEPS7W3D_cjs.y,t=null,s,i=new Map,l=new Map,p=null,c=null,g=o=>e.postMessage(o),h=(o,a)=>{g({kind:"error",id:o,error:chunkP6WPEUAJ_cjs.b(chunkSOMGSIO4_cjs.d(a))});},N=o=>{let a=new Map;return o.method==="parseDocument"?o.args[0].split(`
2
+ `).forEach((u,d)=>a.set(d+1,u)):o.method==="evaluateLines"?o.args[0].forEach((u,d)=>a.set(d+1,u)):a.set(-1,o.args[0]),a},q=(o,a)=>{if(a.type==="error"){g({kind:"async-error",queryKey:a.queryKey,packageId:a.packageId,error:chunkP6WPEUAJ_cjs.b(chunkSOMGSIO4_cjs.d(a.error))});return}let u=[];for(let d of a.lineNumbers){let f=l.get(d);if(f!==void 0)try{let L=o.evaluateLine(d,f);L&&u.push({lineNumber:d,value:m(L,s)});}catch{}}u.length>0&&g({kind:"async-update",lines:u});},F=o=>{c?.();let a=o.getEventStream().getReader();c=()=>{a.cancel();},(async()=>{try{for(;;){let{done:u,value:d}=await a.read();if(u)return;q(o,d);}}catch{}})();},D=o=>{try{let a=H(n,o.packages);t=new chunkOWQF6ZOK_cjs.n({locale:o.localeCode??"en",diagnostics:o.diagnostics??!1,config:o.config,packages:a}),s=o.formatting,F(t),g({kind:"ready",id:o.id});}catch(a){h(o.id,a);}},V=(o,a)=>{let{method:u,args:d}=a;switch(u){case "parseDocument":return R(o.parseDocument(d[0],d[1]),s);case "evaluateLines":return o.evaluateLines(d[0]).map(f=>y(f,s));case "evaluateExpression":return m(o.evaluateExpression(d[0]),s);default:throw chunkSOMGSIO4_cjs.c.execution(chunkP6WPEUAJ_cjs.a.WORKER_UNKNOWN_METHOD,`The worker runtime has no method named "${String(u)}"`,{method:u})}},j=o=>{let a=t;if(!a){h(o.id,chunkSOMGSIO4_cjs.c.execution(chunkP6WPEUAJ_cjs.a.WORKER_NOT_INITIALISED,"The worker received a request before its engine finished initialising"));return}p?.abort();let u=new AbortController;p=u,l=N(o),i.set(o.id,u),a.setKeystrokeSignal(u.signal);try{let d=V(a,o);g({kind:"result",id:o.id,value:d});}catch(d){h(o.id,d);}finally{i.delete(o.id),a.setKeystrokeSignal(null);}};return e.onMessage(o=>{let a=o;switch(a.kind){case "init":D(a);break;case "request":j(a);break;case "cancel":i.get(a.id)?.abort();break}}),()=>{c?.(),c=null,p?.abort(),p=null,l=new Map;for(let o of i.values())o.abort();i.clear(),t?.clear(),t=null,e.terminate();}}function G(e){return typeof globalThis.structuredClone=="function"?globalThis.structuredClone(e):JSON.parse(JSON.stringify(e))}function J(){let e=null,r=null,n=true,t=(l,p)=>{let c=G(p);queueMicrotask(()=>{n&&l()?.(c);});};return {client:{postMessage:l=>t(()=>r,l),onMessage:l=>{e=l;},terminate:()=>{n=false;}},host:{postMessage:l=>t(()=>e,l),onMessage:l=>{r=l;},terminate:()=>{n=false;}}}}function $(e){return {postMessage:r=>e.postMessage(r),onMessage:r=>{let n=t=>r(t.data);typeof e.addEventListener=="function"?e.addEventListener("message",n):e.onmessage=n,e.start?.();},terminate:()=>{e.terminate?.(),e.close?.();}}}function Q(e){return {postMessage:r=>e.postMessage(r),onMessage:r=>{e.on("message",n=>r(n));},terminate:()=>{e.terminate?.(),e.close?.();}}}exports.createLinkedTransports=J;exports.createWorkerEngine=K;exports.eventTargetTransport=$;exports.messagePortTransport=Q;exports.serializeParsedLine=y;exports.serializeParsingResult=R;exports.serializeValue=m;exports.startWorkerRuntime=B;//# sourceMappingURL=worker.cjs.map
3
3
  //# sourceMappingURL=worker.cjs.map
package/dist/worker.js CHANGED
@@ -1,3 +1,3 @@
1
- import {a,e,d,c as c$2,b}from'./chunk-MVZUTETT.js';import {n}from'./chunk-2V44X7GH.js';import'./chunk-JQBG3LX4.js';import'./chunk-2RWAXT6O.js';import'./chunk-7E7NXKQ5.js';import'./chunk-MIQBJGGR.js';import'./chunk-EOMHELRL.js';import'./chunk-KHCNMNZZ.js';import {c}from'./chunk-LH7URJZT.js';import'./chunk-XEIDV5JP.js';import {y as y$1}from'./chunk-HDVZZ7JN.js';import'./chunk-JEFMG6CV.js';import'./chunk-T3FBAFRR.js';import'./chunk-YVKHEAFT.js';import'./chunk-3GAWAMT4.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-YTCTUBR2.js';import'./chunk-YAYBVVG2.js';import'./chunk-YNMMRH44.js';import'./chunk-HFKDWQUL.js';import {g,f}from'./chunk-5TCSFTZD.js';import {R as R$1}from'./chunk-WTEXBPBR.js';import'./chunk-A33K7NY4.js';import'./chunk-DLAKPF5T.js';import'./chunk-UKDUFMT5.js';import'./chunk-QYO7IEPR.js';import'./chunk-JPFCXLJV.js';import'./chunk-GMSBBLUQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-UWAXJX5G.js';import'./chunk-44EOEWGP.js';import {c as c$1,d as d$1}from'./chunk-MPB7KUN5.js';var W=class{constructor(r){this.nextId=1;this.pending=new Map;this.resolvedListeners=new Set;this.asyncErrorListeners=new Set;this.terminated=false;this.transport=r,this.transport.onMessage(n=>this.onMessage(n));}init(r){let n=this.nextId++;return new Promise((t,s)=>{this.pending.set(n,{resolve:()=>t(),reject:s}),this.transport.postMessage({kind:"init",id:n,localeCode:r.localeCode,diagnostics:r.diagnostics,config:r.config,packages:r.packages,formatting:r.formatting});})}parseDocument(r,n){let{signal:t,...s}=n??{},i=Object.keys(s).length>0?s:void 0;return this.call("parseDocument",[r,i],t)}evaluateLines(r,n){return this.call("evaluateLines",[r],n?.signal)}evaluateExpression(r,n){return this.call("evaluateExpression",[r],n?.signal)}onResolved(r){return this.resolvedListeners.add(r),()=>this.resolvedListeners.delete(r)}onAsyncError(r){return this.asyncErrorListeners.add(r),()=>this.asyncErrorListeners.delete(r)}terminate(){if(this.terminated)return;this.terminated=true;let r=e();for(let n of this.pending.values())this.unhook(n),n.reject(r);this.pending.clear(),this.resolvedListeners.clear(),this.asyncErrorListeners.clear(),this.transport.terminate();}call(r,n,t){if(this.terminated)return Promise.reject(e());if(t?.aborted)return Promise.reject(d(r));let s=this.nextId++;return new Promise((i,l)=>{let p={resolve:i,reject:l};if(t){let c=()=>{this.pending.has(s)&&(this.pending.delete(s),this.transport.postMessage({kind:"cancel",id:s}),l(d(r)));};p.signal=t,p.onAbort=c,t.addEventListener("abort",c,{once:true});}this.pending.set(s,p),this.transport.postMessage({kind:"request",id:s,method:r,args:n});})}onMessage(r){let n=r;switch(n.kind){case "ready":case "result":{let t=n.kind==="result"?n.value:void 0;this.settle(n.id,s=>s.resolve(t));break}case "error":this.settle(n.id,t=>t.reject(c$2(n.error)));break;case "async-update":for(let t of [...this.resolvedListeners])t(n.lines);break;case "async-error":for(let t of [...this.asyncErrorListeners])t({queryKey:n.queryKey,packageId:n.packageId,error:c$2(n.error)});break}}settle(r,n){let t=this.pending.get(r);t&&(this.pending.delete(r),this.unhook(t),n(t));}unhook(r){r.signal&&r.onAbort&&r.signal.removeEventListener("abort",r.onAbort);}};async function K(e){let r=new W(e.transport);return await r.init(e),r}function C(e){return e>0?"Infinity":e<0?"-Infinity":"NaN"}function U(e){let r=e.data.map(n=>typeof n=="object"&&n!==null?R$1(n):typeof n=="number"&&!Number.isFinite(n)?C(n):n);return {rows:e.rows,cols:e.cols,cells:r,hasSymbolic:e.hasSymbolic}}function m(e,r){let n=e.toNumber(),t={type:e.type,text:c(e,r),number:Number.isFinite(n)?n:0};Number.isFinite(n)||(t.nonFinite=C(n)),e.unit!==void 0&&(t.unit=e.unit),e.timedOut!==void 0&&(t.timedOut=e.timedOut);let s=e.value;if(typeof s=="bigint")t.bigint=s.toString();else if(e.type===7)t.matrix=U(s);else if(e.type===8){let i=s;t.range={min:i.min,max:i.max};}else if(e.type===14){let i=s;t.colour={hex:f(i),r:i.r,g:i.g,b:i.b,a:i.a,format:i.format,css:g(i)};}else if(e.type===16){let i=s;t.chart={kind:i.kind,points:i.points.map(l=>[l[0],l[1]]),label:i.label,domain:[i.domain[0],i.domain[1]],range:[i.range[0],i.range[1]],...i.expr!==void 0?{expr:i.expr}:{}};}else if(e.type===17){let i=s;t.ipCidr={...i.addr!==void 0?{addr:i.addr}:{},...i.prefix!==void 0?{prefix:i.prefix}:{},text:c(e).replace(/^=\s*/,"")};}return t}function O(e,r){return e?m(e,r):null}function _(e,r){return {start:e.start,end:e.end,expression:e.expression,lineNumber:e.lineNumber,columnNumber:e.columnNumber,result:O(e.result,r),error:e.error??null}}function y(e,r){return {lineNumber:e.lineNumber,text:e.text,startPosition:e.startPosition,endPosition:e.endPosition,isEmpty:e.isEmpty,hasInlineSolves:e.hasInlineSolves,inlineSolves:e.inlineSolves.map(n=>_(n,r)),expression:e.expression,result:O(e.result,r),error:e.error}}function R(e,r){let n={lines:e.lines.map(t=>y(t,r)),totalLines:e.totalLines,errors:[...e.errors]};return e.diagnostics!==void 0&&(n.diagnostics=e.diagnostics),n}function H(e,r){if(r===void 0)return e;let n=new Map(e.map(s=>[s.name,s])),t=[];for(let s of r){let i=n.get(s);if(!i)throw c$1.config(a.WORKER_UNKNOWN_PACKAGE,`No package named "${s}" is available in this worker runtime`,{name:s,available:[...n.keys()]});t.push(i);}return t}function B(e,r={}){let n$1=r.packages??y$1,t=null,s,i=new Map,l=new Map,p=null,c=null,g=o=>e.postMessage(o),h=(o,a)=>{g({kind:"error",id:o,error:b(d$1(a))});},N=o=>{let a=new Map;return o.method==="parseDocument"?o.args[0].split(`
1
+ import {a,e,d,c as c$2,b}from'./chunk-MVZUTETT.js';import {n}from'./chunk-P7XWFT45.js';import'./chunk-JQBG3LX4.js';import'./chunk-2RWAXT6O.js';import'./chunk-7E7NXKQ5.js';import'./chunk-MIQBJGGR.js';import'./chunk-K4MME6ZT.js';import'./chunk-KHCNMNZZ.js';import {c}from'./chunk-LH7URJZT.js';import'./chunk-XEIDV5JP.js';import {y as y$1}from'./chunk-HE7E6M5O.js';import'./chunk-JEFMG6CV.js';import'./chunk-T3FBAFRR.js';import'./chunk-YVKHEAFT.js';import'./chunk-3GAWAMT4.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-YTCTUBR2.js';import'./chunk-YAYBVVG2.js';import'./chunk-YNMMRH44.js';import'./chunk-HFKDWQUL.js';import {g,f}from'./chunk-5TCSFTZD.js';import {R as R$1}from'./chunk-WTEXBPBR.js';import'./chunk-A33K7NY4.js';import'./chunk-DLAKPF5T.js';import'./chunk-OVNB7MI5.js';import'./chunk-QYO7IEPR.js';import'./chunk-JPFCXLJV.js';import'./chunk-GMSBBLUQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-UWAXJX5G.js';import'./chunk-44EOEWGP.js';import {c as c$1,d as d$1}from'./chunk-MPB7KUN5.js';var W=class{constructor(r){this.nextId=1;this.pending=new Map;this.resolvedListeners=new Set;this.asyncErrorListeners=new Set;this.terminated=false;this.transport=r,this.transport.onMessage(n=>this.onMessage(n));}init(r){let n=this.nextId++;return new Promise((t,s)=>{this.pending.set(n,{resolve:()=>t(),reject:s}),this.transport.postMessage({kind:"init",id:n,localeCode:r.localeCode,diagnostics:r.diagnostics,config:r.config,packages:r.packages,formatting:r.formatting});})}parseDocument(r,n){let{signal:t,...s}=n??{},i=Object.keys(s).length>0?s:void 0;return this.call("parseDocument",[r,i],t)}evaluateLines(r,n){return this.call("evaluateLines",[r],n?.signal)}evaluateExpression(r,n){return this.call("evaluateExpression",[r],n?.signal)}onResolved(r){return this.resolvedListeners.add(r),()=>this.resolvedListeners.delete(r)}onAsyncError(r){return this.asyncErrorListeners.add(r),()=>this.asyncErrorListeners.delete(r)}terminate(){if(this.terminated)return;this.terminated=true;let r=e();for(let n of this.pending.values())this.unhook(n),n.reject(r);this.pending.clear(),this.resolvedListeners.clear(),this.asyncErrorListeners.clear(),this.transport.terminate();}call(r,n,t){if(this.terminated)return Promise.reject(e());if(t?.aborted)return Promise.reject(d(r));let s=this.nextId++;return new Promise((i,l)=>{let p={resolve:i,reject:l};if(t){let c=()=>{this.pending.has(s)&&(this.pending.delete(s),this.transport.postMessage({kind:"cancel",id:s}),l(d(r)));};p.signal=t,p.onAbort=c,t.addEventListener("abort",c,{once:true});}this.pending.set(s,p),this.transport.postMessage({kind:"request",id:s,method:r,args:n});})}onMessage(r){let n=r;switch(n.kind){case "ready":case "result":{let t=n.kind==="result"?n.value:void 0;this.settle(n.id,s=>s.resolve(t));break}case "error":this.settle(n.id,t=>t.reject(c$2(n.error)));break;case "async-update":for(let t of [...this.resolvedListeners])t(n.lines);break;case "async-error":for(let t of [...this.asyncErrorListeners])t({queryKey:n.queryKey,packageId:n.packageId,error:c$2(n.error)});break}}settle(r,n){let t=this.pending.get(r);t&&(this.pending.delete(r),this.unhook(t),n(t));}unhook(r){r.signal&&r.onAbort&&r.signal.removeEventListener("abort",r.onAbort);}};async function K(e){let r=new W(e.transport);return await r.init(e),r}function C(e){return e>0?"Infinity":e<0?"-Infinity":"NaN"}function U(e){let r=e.data.map(n=>typeof n=="object"&&n!==null?R$1(n):typeof n=="number"&&!Number.isFinite(n)?C(n):n);return {rows:e.rows,cols:e.cols,cells:r,hasSymbolic:e.hasSymbolic}}function m(e,r){let n=e.toNumber(),t={type:e.type,text:c(e,r),number:Number.isFinite(n)?n:0};Number.isFinite(n)||(t.nonFinite=C(n)),e.unit!==void 0&&(t.unit=e.unit),e.timedOut!==void 0&&(t.timedOut=e.timedOut);let s=e.value;if(typeof s=="bigint")t.bigint=s.toString();else if(e.type===7)t.matrix=U(s);else if(e.type===8){let i=s;t.range={min:i.min,max:i.max};}else if(e.type===14){let i=s;t.colour={hex:f(i),r:i.r,g:i.g,b:i.b,a:i.a,format:i.format,css:g(i)};}else if(e.type===16){let i=s;t.chart={kind:i.kind,points:i.points.map(l=>[l[0],l[1]]),label:i.label,domain:[i.domain[0],i.domain[1]],range:[i.range[0],i.range[1]],...i.expr!==void 0?{expr:i.expr}:{}};}else if(e.type===17){let i=s;t.ipCidr={...i.addr!==void 0?{addr:i.addr}:{},...i.prefix!==void 0?{prefix:i.prefix}:{},text:c(e).replace(/^=\s*/,"")};}return t}function O(e,r){return e?m(e,r):null}function _(e,r){return {start:e.start,end:e.end,expression:e.expression,lineNumber:e.lineNumber,columnNumber:e.columnNumber,result:O(e.result,r),error:e.error??null}}function y(e,r){return {lineNumber:e.lineNumber,text:e.text,startPosition:e.startPosition,endPosition:e.endPosition,isEmpty:e.isEmpty,hasInlineSolves:e.hasInlineSolves,inlineSolves:e.inlineSolves.map(n=>_(n,r)),expression:e.expression,result:O(e.result,r),error:e.error}}function R(e,r){let n={lines:e.lines.map(t=>y(t,r)),totalLines:e.totalLines,errors:[...e.errors]};return e.diagnostics!==void 0&&(n.diagnostics=e.diagnostics),n}function H(e,r){if(r===void 0)return e;let n=new Map(e.map(s=>[s.name,s])),t=[];for(let s of r){let i=n.get(s);if(!i)throw c$1.config(a.WORKER_UNKNOWN_PACKAGE,`No package named "${s}" is available in this worker runtime`,{name:s,available:[...n.keys()]});t.push(i);}return t}function B(e,r={}){let n$1=r.packages??y$1,t=null,s,i=new Map,l=new Map,p=null,c=null,g=o=>e.postMessage(o),h=(o,a)=>{g({kind:"error",id:o,error:b(d$1(a))});},N=o=>{let a=new Map;return o.method==="parseDocument"?o.args[0].split(`
2
2
  `).forEach((u,d)=>a.set(d+1,u)):o.method==="evaluateLines"?o.args[0].forEach((u,d)=>a.set(d+1,u)):a.set(-1,o.args[0]),a},q=(o,a)=>{if(a.type==="error"){g({kind:"async-error",queryKey:a.queryKey,packageId:a.packageId,error:b(d$1(a.error))});return}let u=[];for(let d of a.lineNumbers){let f=l.get(d);if(f!==void 0)try{let L=o.evaluateLine(d,f);L&&u.push({lineNumber:d,value:m(L,s)});}catch{}}u.length>0&&g({kind:"async-update",lines:u});},F=o=>{c?.();let a=o.getEventStream().getReader();c=()=>{a.cancel();},(async()=>{try{for(;;){let{done:u,value:d}=await a.read();if(u)return;q(o,d);}}catch{}})();},D=o=>{try{let a=H(n$1,o.packages);t=new n({locale:o.localeCode??"en",diagnostics:o.diagnostics??!1,config:o.config,packages:a}),s=o.formatting,F(t),g({kind:"ready",id:o.id});}catch(a){h(o.id,a);}},V=(o,a$1)=>{let{method:u,args:d}=a$1;switch(u){case "parseDocument":return R(o.parseDocument(d[0],d[1]),s);case "evaluateLines":return o.evaluateLines(d[0]).map(f=>y(f,s));case "evaluateExpression":return m(o.evaluateExpression(d[0]),s);default:throw c$1.execution(a.WORKER_UNKNOWN_METHOD,`The worker runtime has no method named "${String(u)}"`,{method:u})}},j=o=>{let a$1=t;if(!a$1){h(o.id,c$1.execution(a.WORKER_NOT_INITIALISED,"The worker received a request before its engine finished initialising"));return}p?.abort();let u=new AbortController;p=u,l=N(o),i.set(o.id,u),a$1.setKeystrokeSignal(u.signal);try{let d=V(a$1,o);g({kind:"result",id:o.id,value:d});}catch(d){h(o.id,d);}finally{i.delete(o.id),a$1.setKeystrokeSignal(null);}};return e.onMessage(o=>{let a=o;switch(a.kind){case "init":D(a);break;case "request":j(a);break;case "cancel":i.get(a.id)?.abort();break}}),()=>{c?.(),c=null,p?.abort(),p=null,l=new Map;for(let o of i.values())o.abort();i.clear(),t?.clear(),t=null,e.terminate();}}function G(e){return typeof globalThis.structuredClone=="function"?globalThis.structuredClone(e):JSON.parse(JSON.stringify(e))}function J(){let e=null,r=null,n=true,t=(l,p)=>{let c=G(p);queueMicrotask(()=>{n&&l()?.(c);});};return {client:{postMessage:l=>t(()=>r,l),onMessage:l=>{e=l;},terminate:()=>{n=false;}},host:{postMessage:l=>t(()=>e,l),onMessage:l=>{r=l;},terminate:()=>{n=false;}}}}function $(e){return {postMessage:r=>e.postMessage(r),onMessage:r=>{let n=t=>r(t.data);typeof e.addEventListener=="function"?e.addEventListener("message",n):e.onmessage=n,e.start?.();},terminate:()=>{e.terminate?.(),e.close?.();}}}function Q(e){return {postMessage:r=>e.postMessage(r),onMessage:r=>{e.on("message",n=>r(n));},terminate:()=>{e.terminate?.(),e.close?.();}}}export{J as createLinkedTransports,K as createWorkerEngine,$ as eventTargetTransport,Q as messagePortTransport,y as serializeParsedLine,R as serializeParsingResult,m as serializeValue,B as startWorkerRuntime};//# sourceMappingURL=worker.js.map
3
3
  //# sourceMappingURL=worker.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solve-engine",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "description": "An embeddable expression engine for natural-language calculations: units, currencies, percentages, dates and matrices, with the parsing and evaluation plumbing already built.",
5
5
  "keywords": [
6
6
  "expression-evaluator",
@@ -1,2 +0,0 @@
1
- import {c as c$2}from'./chunk-KHCNMNZZ.js';import {y,C,a as a$1,G,J as J$1,e as e$2,h as h$1,t as t$1,p,k as k$1,m,n as n$1,g as g$1,q as q$3,f as f$2,u as u$1,o as o$1,s as s$1,j as j$2,r as r$2,l,b as b$2,c as c$6}from'./chunk-YTCTUBR2.js';import {c as c$5}from'./chunk-YAYBVVG2.js';import {b}from'./chunk-YNMMRH44.js';import {ea,T,U,X,S,Y,q as q$1,aa as aa$1,ma,j as j$1,$,_,ia,ra,ua}from'./chunk-WTEXBPBR.js';import {n,g,j,a,P,c as c$3,Q,I,e,C as C$1,F,M,x,y as y$1,w,u,t,v,r as r$1,N,G as G$1,k,K,f as f$1,R,L,s,q as q$2,p as p$1,o,d,A,b as b$1,B}from'./chunk-A33K7NY4.js';import {c as c$4,e as e$1,i,h,f,a as a$2}from'./chunk-DLAKPF5T.js';import {a as a$3}from'./chunk-44EOEWGP.js';import {c as c$1,r,d as d$1}from'./chunk-MPB7KUN5.js';var Ot=class{constructor(){this.consumers=new Map;this.dependencies=new Map;this.writes=new Map;this.lineReads=new Map;this.dataSourceDependencies=new Map;this.dataSourceConsumers=new Map;}registerLine(a,s,u){let l=this.lineReads.get(a);if(l)for(let g of l){let b=this.consumers.get(g);b&&b.delete(a);}this.lineReads.set(a,new Set(s));for(let g of s)this.consumers.has(g)||this.consumers.set(g,new Set),this.consumers.get(g).add(a);if(u.length>0){this.dependencies.set(a,new Set(s)),this.writes.set(a,new Set(u));for(let g of u){let b=this.consumers.get(g);b&&b.delete(a);}}}registerLineDataSourceDependency(a,s,u){let l=JSON.stringify(u),g=`${s}:${l}`;this.dataSourceDependencies.has(a)||this.dataSourceDependencies.set(a,new Set),this.dataSourceDependencies.get(a).add(g),this.dataSourceConsumers.has(g)||this.dataSourceConsumers.set(g,new Set),this.dataSourceConsumers.get(g).add(a);}getAffectedLines(a){let s=new Set,u=[a];for(;u.length>0;){let l=u.pop(),g=this.consumers.get(l);if(g)for(let b of g){if(s.has(b))continue;s.add(b);let f=this.writes.get(b);if(f)for(let y of f)u.push(y);}}return s}getAffectedLinesInOrder(a){let s=this.getAffectedLines(a);if(s.size===0)return [];let u=new Map,l=new Map;for(let y of s)u.has(y)||u.set(y,0),l.has(y)||l.set(y,[]);let g=new Map;for(let y of s){let x=this.writes.get(y);if(x)for(let A of x)g.set(A,y);}for(let y of s){let x=this.lineReads.get(y);if(x)for(let A of x){let C=g.get(A);C!==void 0&&C!==y&&(l.get(C).push(y),u.set(y,(u.get(y)??0)+1));}}let b=[];for(let[y,x]of u)x===0&&b.push(y);if(b.length===0&&s.size>0){let y=Array.from(s).sort((x,A)=>x-A);b.push(y[0]);}let f=[];for(;b.length>0;){let y=b.shift();f.push(y);for(let x of l.get(y)??[]){let A=(u.get(x)??1)-1;u.set(x,A),A===0&&b.push(x);}}if(f.length<s.size){let y=new Set(f),x=Array.from(s).filter(A=>!y.has(A)).sort((A,C)=>A-C);f.push(...x);}return f}getAffectedLinesByDataSource(a,s){let u=JSON.stringify(s),l=`${a}:${u}`;return this.dataSourceConsumers.get(l)??new Set}removeLine(a){let s=this.lineReads.get(a);if(s){for(let l of s){let g=this.consumers.get(l);g&&g.delete(a);}this.lineReads.delete(a);}this.dependencies.delete(a),this.writes.delete(a);let u=this.dataSourceDependencies.get(a);if(u){for(let l of u)this.dataSourceConsumers.get(l)?.delete(a);this.dataSourceDependencies.delete(a);}}getConsumers(a){return this.consumers.get(a)??new Set}getDependencies(a){return this.dependencies.get(a)??new Set}getWrites(a){return this.writes.get(a)??new Set}getSnapshot(){let a={};for(let[b,f]of this.consumers)a[b]=Array.from(f);let s={};for(let[b,f]of this.writes)s[b]=Array.from(f);let u={};for(let[b,f]of this.lineReads)u[b]=Array.from(f);let l={};for(let[b,f]of this.dataSourceDependencies)l[b]=Array.from(f);let g={};for(let[b,f]of this.dataSourceConsumers)g[b]=Array.from(f);return {consumers:a,writes:s,reads:u,dataSourceDeps:l,dataSourceConsumers:g}}clear(){this.consumers.clear(),this.dependencies.clear(),this.writes.clear(),this.lineReads.clear(),this.dataSourceDependencies.clear(),this.dataSourceConsumers.clear();}};var vt=class{constructor(){this.definitions=new Map;}write(a,s,u){this.definitions.has(a)||this.definitions.set(a,[]);let l=this.definitions.get(a);l.push({line:s,expr:u}),l.sort((g,b)=>g.line-b.line);}read(a,s){let u=this.definitions.get(a);if(u){for(let l=u.length-1;l>=0;l--)if(u[l].line<=s)return u[l].expr.lastResult}}invalidateDownstream(a,s){let u=this.definitions.get(a);if(!u)return;let l=u.findIndex(g=>g.line===s);l!==-1&&u.splice(l+1);}clear(){this.definitions.clear();}};var je={kg:{dim:[1,0,0,0],si:1},g:{dim:[1,0,0,0],si:.001},tonne:{dim:[1,0,0,0],si:1e3},t:{dim:[1,0,0,0],si:1e3},m:{dim:[0,1,0,0],si:1},cm:{dim:[0,1,0,0],si:.01},mm:{dim:[0,1,0,0],si:.001},km:{dim:[0,1,0,0],si:1e3},s:{dim:[0,0,1,0],si:1},ms:{dim:[0,0,1,0],si:.001},min:{dim:[0,0,1,0],si:60},minute:{dim:[0,0,1,0],si:60},minutes:{dim:[0,0,1,0],si:60},h:{dim:[0,0,1,0],si:3600},hr:{dim:[0,0,1,0],si:3600},hour:{dim:[0,0,1,0],si:3600},hours:{dim:[0,0,1,0],si:3600},A:{dim:[0,0,0,1],si:1},mA:{dim:[0,0,0,1],si:.001},kA:{dim:[0,0,0,1],si:1e3},ampere:{dim:[0,0,0,1],si:1},amperes:{dim:[0,0,0,1],si:1},mps2:{dim:[0,1,-2,0],si:1},N:{dim:[1,1,-2,0],si:1},kN:{dim:[1,1,-2,0],si:1e3},newton:{dim:[1,1,-2,0],si:1},newtons:{dim:[1,1,-2,0],si:1},J:{dim:[1,2,-2,0],si:1},kJ:{dim:[1,2,-2,0],si:1e3},MJ:{dim:[1,2,-2,0],si:1e6},joule:{dim:[1,2,-2,0],si:1},joules:{dim:[1,2,-2,0],si:1},Wh:{dim:[1,2,-2,0],si:3600},kWh:{dim:[1,2,-2,0],si:36e5},W:{dim:[1,2,-3,0],si:1},kW:{dim:[1,2,-3,0],si:1e3},MW:{dim:[1,2,-3,0],si:1e6},watt:{dim:[1,2,-3,0],si:1},watts:{dim:[1,2,-3,0],si:1},Pa:{dim:[1,-1,-2,0],si:1},kPa:{dim:[1,-1,-2,0],si:1e3},MPa:{dim:[1,-1,-2,0],si:1e6},pascal:{dim:[1,-1,-2,0],si:1},pascals:{dim:[1,-1,-2,0],si:1},V:{dim:[1,2,-3,-1],si:1},mV:{dim:[1,2,-3,-1],si:.001},kV:{dim:[1,2,-3,-1],si:1e3},volt:{dim:[1,2,-3,-1],si:1},volts:{dim:[1,2,-3,-1],si:1}},en={"1,1,-2,0":"N","1,2,-2,0":"J","1,2,-3,0":"W","1,-1,-2,0":"Pa","1,2,-3,-1":"V"},tn=r=>r.join(",");function ze(r,a,s){if(r.type!==6||a.type!==6)return null;let u$1=r.unit?je[r.unit]:void 0,l=a.unit?je[a.unit]:void 0;if(u$1===void 0||l===void 0)return null;let g=[u$1.dim[0]+(s?l.dim[0]:-l.dim[0]),u$1.dim[1]+(s?l.dim[1]:-l.dim[1]),u$1.dim[2]+(s?l.dim[2]:-l.dim[2]),u$1.dim[3]+(s?l.dim[3]:-l.dim[3])],b=en[tn(g)];if(b===void 0)return null;let f=r.toNumber()*u$1.si,y=a.toNumber()*l.si,x=s?f*y:f/y;return u(x/je[b].si,b)}function nn(r){let a=new Date(r).getDay();return a===0||a===6}function Vt(r,a){return nn(r)?false:a?!a(r):true}function Rt(r){let a=new Date(r);return new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime()}function Bt(r,a,s,u){let l=Math.trunc(Math.abs(a)),g=a>=0?1:-1,b=new Date(r),f=0;for(;l>0;){if(b.setDate(b.getDate()+g),f++,f>u)return null;Vt(b.getTime(),s)&&l--;}return b.getTime()}function Ft(r,a,s,u){let l=Rt(Math.min(r,a)),g=Rt(Math.max(r,a)),b=Math.round((g-l)/864e5);if(b>u)return null;let f=0,y=new Date(l);for(let x=0;x<=b;x++)Vt(y.getTime(),s)&&f++,y.setDate(y.getDate()+1);return f}var an={0:{name:"sqrt",min:1,max:1},1:{name:"abs",min:1,max:1},2:{name:"sin",min:1,max:1},3:{name:"cos",min:1,max:1},4:{name:"tan",min:1,max:1},5:{name:"log",min:1,max:1},6:{name:"ceil",min:1,max:1},7:{name:"floor",min:1,max:1},8:{name:"round",min:1,max:2},9:{name:"min",min:1,max:1/0},10:{name:"max",min:1,max:1/0},11:{name:"asin",min:1,max:1},12:{name:"acos",min:1,max:1},13:{name:"atan",min:1,max:1},14:{name:"atan2",min:2,max:2},15:{name:"sinh",min:1,max:1},16:{name:"cosh",min:1,max:1},17:{name:"tanh",min:1,max:1},18:{name:"asinh",min:1,max:1},19:{name:"acosh",min:1,max:1},20:{name:"atanh",min:1,max:1},21:{name:"cbrt",min:1,max:1},22:{name:"clz32",min:1,max:1},23:{name:"expm1",min:1,max:1},24:{name:"exp",min:1,max:1},25:{name:"fround",min:1,max:1},26:{name:"hypot",min:1,max:1/0},27:{name:"imul",min:2,max:2},28:{name:"log10",min:1,max:1},29:{name:"log1p",min:1,max:1},30:{name:"log2",min:1,max:1},31:{name:"pow",min:2,max:2},32:{name:"random",min:0,max:0},33:{name:"sign",min:1,max:1},34:{name:"trunc",min:1,max:1},35:{name:"degtorad",min:1,max:1},36:{name:"radtodeg",min:1,max:1},37:{name:"roll",min:2,max:2},38:{name:"gcd",min:2,max:2},39:{name:"lcm",min:2,max:2},40:{name:"permutation",min:2,max:2},41:{name:"combination",min:2,max:2},42:{name:"average",min:0,max:1/0},43:{name:"median",min:0,max:1/0},44:{name:"total",min:0,max:1/0},45:{name:"count",min:0,max:1/0},46:{name:"proportion",min:3,max:3},47:{name:"clamp",min:3,max:3},48:{name:"hex",min:1,max:1},49:{name:"bin",min:1,max:1},50:{name:"int",min:1,max:1},51:{name:"compoundInterest",min:3,max:3},52:{name:"interestEarned",min:3,max:3},53:{name:"compoundInterestRate",min:3,max:3},54:{name:"compoundInterestYears",min:3,max:3},55:{name:"loanRepayment",min:4,max:4},56:{name:"loanInterest",min:4,max:4},57:{name:"monthlyPayment",min:3,max:3},58:{name:"taxAdd",min:2,max:2},59:{name:"taxRemove",min:2,max:2},60:{name:"inflationAdjust",min:3,max:3},61:{name:"root",min:2,max:2},62:{name:"fact",min:1,max:1},63:{name:"transpose",min:1,max:1},64:{name:"det",min:1,max:1},65:{name:"inv",min:1,max:1},66:{name:"dot",min:2,max:2},67:{name:"expand",min:1,max:1},68:{name:"factor",min:1,max:1},69:{name:"solve",min:3,max:3},70:{name:"der",min:2,max:3},71:{name:"integral",min:2,max:2},72:{name:"taylor",min:4,max:4},73:{name:"jacobian",min:1,max:1/0},74:{name:"imaginary",min:1,max:1},75:{name:"conj",min:1,max:1},76:{name:"re",min:1,max:1},77:{name:"im",min:1,max:1},78:{name:"cancel",min:1,max:1},79:{name:"apart",min:1,max:1},80:{name:"compoundInterestEvery",min:4,max:4},81:{name:"compoundInterestEarnedEvery",min:4,max:4},82:{name:"presentValue",min:3,max:3},83:{name:"roi",min:2,max:2},84:{name:"annualisedReturn",min:3,max:3},85:{name:"taxIn",min:2,max:2},86:{name:"taxOn",min:2,max:2},87:{name:"sind",min:1,max:1},88:{name:"cosd",min:1,max:1},89:{name:"tand",min:1,max:1},90:{name:"asind",min:1,max:1},91:{name:"acosd",min:1,max:1},92:{name:"atand",min:1,max:1},93:{name:"daysCount",min:1,max:1},94:{name:"asTwoUnits",min:3,max:3},95:{name:"makeRate",min:2,max:2},96:{name:"atRate",min:2,max:2},97:{name:"roundToPlaces",min:2,max:2},98:{name:"splitEach",min:2,max:2},99:{name:"savingsGoalPayment",min:3,max:3},100:{name:"savingsGoalPeriods",min:5,max:5},101:{name:"standardDeviation",min:0,max:1/0},102:{name:"sampleStandardDeviation",min:0,max:1/0},103:{name:"variance",min:0,max:1/0},104:{name:"sampleVariance",min:0,max:1/0},105:{name:"spread",min:0,max:1/0},106:{name:"mode",min:0,max:1/0},107:{name:"weightedAverage",min:2,max:1/0}};function ke(r){return r===1?"1 argument":`${r} arguments`}function rn(r){return r.max===1/0?`at least ${ke(r.min)}`:r.min===r.max?ke(r.min):`${r.min} to ${ke(r.max)}`}function Lt(r,a){let s=an[r];if(s!==void 0&&!(a>=s.min&&a<=s.max))return c$1.execution("BUILTIN_ARITY_MISMATCH",`${s.name}() takes ${rn(s)}, but was given ${a===0?"none":ke(a)}`,{functionName:s.name,expectedMin:s.min,expectedMax:s.max,actual:a})}function aa(r,a=200,s=5e4,u=50,l=1e5,g=2e6,b=1e4,f=100,y$1=-100,x=y,A){let C=[],I=new Map,L=0,j,$,n$1=[],Q=new Map,G=new Map,K=new Map;return {push(d){C.length<a&&C.push(d);},getMaxStackDepth(){return a},getMaxCollectionSize(){return l},getMaxAllocatedElements(){return g},getMaxFunctionCalls(){return b},getMaxDateOffsetYears(){return f},getMinDateOffsetYears(){return y$1},isHoliday(d){return A?A(d):false},pop(){return C.length===0?n(0):C.pop()},popNumber(){return c(C).toNumber()},popString(){return q(c(C),"VM.popString()")},peek(){return C[C.length-1]},getStack(){return C},registry:r,getVar(d){if(n$1.length>0){let e=n$1[n$1.length-1].get(d);if(e!==void 0)return e}return I.get(d)},setVar(d,e){I.set(d,e);},deleteVar(d){I.delete(d);},pushCallFrame(d){if(n$1.length>=u)throw c$1.execution("FUNCTION_RECURSION_LIMIT_EXCEEDED",`Function call nesting exceeded maximum depth of ${u} (possible infinite recursion, e.g. f(x) = f(x))`,{maxFunctionRecursionDepth:u});n$1.push(d);},popCallFrame(){n$1.pop();},getCallFrame(){return n$1.length>0?n$1[n$1.length-1]:void 0},defineUserFunction(d,e,t){Q.set(d,{name:d,params:e,program:t});},getUserFunction(d){return Q.get(d)},hasUserFunction(d){return Q.has(d)},getVariableEntries(){return Array.from(I.entries())},getUserFunctionDefs(){return Array.from(Q.values())},defineEquation(d,e,t){G.set(d,{variable:d,factorNames:e,rhsProgram:t});},getEquation(d){return G.get(d)},hasEquation(d){return G.has(d)},defineScalarEquation(d,e,t){K.set(d,{variable:d,lhsProgram:e,rhsProgram:t});},getScalarEquation(d){return K.get(d)},hasScalarEquation(d){return K.has(d)},reset(){C.length=0,I.clear(),n$1.length=0,Q.clear(),G.clear(),K.clear(),L=0,$&&($(),$=void 0),j=void 0;},get activeSignal(){return j},set activeSignal(d){j=d;},get abortCurrent(){return $},set abortCurrent(d){$=d;},context:x,getMaxInstructions(){return s},getInstructionCount(){return L},incrementInstructions(d){if(L+=d,L>s)throw c$1.execution("INSTRUCTION_LIMIT_EXCEEDED",`Execution exceeded maximum of ${s} instructions`)}}}function sn(r,a){return r.rows===1&&r.cols===1?a.data.length:a.rows===1&&a.cols===1?r.data.length:r.cols!==a.rows?0:r.rows*a.cols}function on(r,a){return !Number.isInteger(a)||a<0?0:r.rows*r.cols*(1+(a<2?1:2*Math.floor(Math.log2(a))))}function c(r){if(r.length===0)throw c$1.internal({code:"STACK_UNDERFLOW",message:"Stack underflow: an opcode expected a value on the stack but it was empty",expected:"at least one value on the VM stack",found:"an empty stack",suggestion:"this indicates corrupted bytecode or a bug in a package's parselet (mismatched push/pop counts), not a user-input error"});return r.pop()}var Jt="bytecode is caller input on this entry point: rebuild the program with the engine's compiler, or fix the hand-assembled stream";function un(r){return typeof r=="number"?b(r):r}function oe(r,a,s,u,l,g={}){let b=un(a);return c$1.validation({code:r,message:`Malformed bytecode: ${b} ${s}`,expected:u,found:l,suggestion:Jt,context:typeof a=="number"?{opcode:a,opcodeName:b,...g}:{site:b,...g}})}function O(r,a,s,u){if(a>=r.length)throw oe("MALFORMED_BYTECODE_TRUNCATED",s,`is missing its ${u}: the program ends mid-instruction`,`an operand byte at offset ${a}`,`a program only ${r.length} byte(s) long`,{offset:a,length:r.length,role:u});return r[a]}function Je(r,a,s,u,l,g){let b=O(r,a,s,u);if(b>=l)throw oe("MALFORMED_BYTECODE_CONSTANT_INDEX",s,`reads ${g} entry ${b}, which does not exist`,`an index below ${l}`,`${b}`,{index:b,poolSize:l,pool:g});return b}function J(r,a,s,u,l){return Se(s,O(r,a,u,l),u)}function Se(r,a,s){let u=r[a];if(typeof u!="string")throw oe("MALFORMED_BYTECODE_CONSTANT_INDEX",s,`reads string-pool entry ${a}, which is ${a>=r.length?"past the end of the pool":"not a string"}`,`an index below ${r.length}, holding a string`,a>=r.length?`${a}`:typeof u,{index:a,poolSize:r.length,pool:"string-pool"});return u}function q(r,a,s){if(typeof r.value!="string")throw oe("MALFORMED_BYTECODE_OPERAND_TYPE",a,`expected a ${s??"string"} on the stack`,s?`a string value holding the ${s}`:"a string value",`a ${g[r.type]??"unknown"} value`,s?{role:s,valueType:r.type}:{valueType:r.type});return r.value}function $t(r,a,s){if(r!==0&&r!==1&&r!==2)throw oe("MALFORMED_BYTECODE_BODY_KIND",s,`has body kind ${r}, which is not one this VM knows`,"0 (inline body), 1 (builtin function) or 2 (user-defined function)",`${r}`,{kind:r,ref:a})}function mn(r,a){try{return BigInt(r)}catch{throw oe("MALFORMED_BYTECODE_BIGINT_LITERAL",a,`cannot read "${r}" as a whole number`,"a string holding an integer, with no decimal point or separators",`"${r}"`,{literal:r})}}function ln(r){if(r===null||typeof r!="object")return `expected a bytecode program, got ${r===null?"null":typeof r}`;let a=r;return typeof a.opcodes?.length!="number"?"the program has no `opcodes` array":typeof a.numbers?.length!="number"?"the program has no `numbers` pool":typeof a.strings?.length!="number"?"the program has no `strings` pool":null}var Pt=64;function Qe(r,a,s,u,l,g,b,f){let y=new Map;for(let A=0;A<r.length;A++)y.set(r[A],s[A]);u.pushCallFrame(y);let x;try{x=tt(a,u,l,g,b,f);}finally{u.popCallFrame();}if(x.type==="pending")throw c$1.execution("MAP_REDUCE_ASYNC_UNSUPPORTED","map/reduce transform bodies calling an async operation (weather, stocks, currency, ...) aren't supported");if(x.type==="error")throw x.error;return x.value}function cn(r,a,s,u,l,g,b){let f=new Map(s.getCallFrame());f.set(r,K(q$1(r))),s.pushCallFrame(f);let y;try{y=tt(a,s,u,l,g,b);}finally{s.popCallFrame();}if(y.type==="pending")throw c$1.execution("SYMBOLIC_ASYNC_UNSUPPORTED","an algebra verb's expression cannot call an async operation (weather, stocks, currency, ...)");if(y.type==="error")throw y.error;return y.value}function Yt(r,a){if(r.type!==6||a.type!==6)return null;let s=r.unit,u=a.unit;if(s===void 0||u===void 0)return null;let l=s.indexOf("/"),g=u.indexOf("/");if(l<0||g<0||s.slice(0,l)!==u.slice(0,g))return null;let b=a$3[s.slice(l+1).toLowerCase()],f=a$3[u.slice(g+1).toLowerCase()];return b===void 0||f===void 0||b[0]!==f[0]?null:r.toNumber()*(f[1]/b[1])}function Wt(r,a){if(r.type!==6||a.type!==6)return null;let s=r.unit,u$1=a.unit;if(s===void 0||u$1===void 0||s.includes("/")||u$1.includes("/"))return null;let l=ua[s.toUpperCase()]!==void 0,g=ua[u$1.toUpperCase()]!==void 0;return l===g?null:u(r.toNumber()*a.toNumber(),l?s:u$1)}function Xt(r,a,s){if(r.type===5)return a.type===6&&a.unit!==void 0?c$6(a,a.unit,r.toNumber(),s):a.type!==5&&a.type!==0?null:N(r.toNumber()+s*a.toNumber());if(a.type!==5)return null;let u=1+s*a.toNumber();if(r.type===0){let l=r.toNumber()*u;return r.uncertainty!==void 0?q$2(l,Math.abs(r.uncertainty*u)):n(l)}return r.type===6&&r.unit!==void 0?c$6(r,r.unit,a.toNumber(),s):null}function pn(r,a){let s=r.type===5?r:a.type===5?a:null;if(s===null)return null;let u=s===r?a:r;if(u.type!==0||u.uncertainty===void 0)return null;let l=s.toNumber();return q$2(u.toNumber()*l,Math.abs(u.uncertainty*l))}function dn(r,a){let s=r.type===6?r:a,u=r.type===6?a:r;return s.type!==6||s.unit===void 0||!c$5.isCurrency(s.unit)||u.type!==0&&u.type!==5||u.rational!==void 0?null:b$2(s,u.toNumber(),s.unit)}function fn(r,a){if(a.type===5&&r.type===0&&r.uncertainty!==void 0){let s=a.toNumber();return s===0?null:q$2(r.toNumber()/s,Math.abs(r.uncertainty/s))}if(r.type===5&&a.type===0&&a.uncertainty!==void 0){let s=a.toNumber();return s===0?null:q$2(r.toNumber()/s,Math.abs(r.toNumber()*a.uncertainty/(s*s)))}return null}function bn(r){if(r.type===6){let a=r.unit;if(a&&c$4(a)==="time")try{return e$1(r.toNumber(),a,"ms")}catch{}return 0}return r.toNumber()}var Gt=260;function Qt(r,a,s){let u=Math.trunc(Math.abs(a)),g=(a>=0?1:-1)>0?s.getMaxDateOffsetYears():-s.getMinDateOffsetYears(),b=Math.floor(g*Gt);if(u>b)throw c$1.execution("DATE_OFFSET_LIMIT_EXCEEDED",`A date offset of ${u.toLocaleString("en-US")} workdays is about ${Math.round(u/Gt).toLocaleString("en-US")} years, past the limit of ${g} years for a workday offset`,{requestedWorkdays:u,limitYears:g,limitWorkdays:b});let f=b*7+7,y=Bt(r,a,x=>s.isHoliday(x),f);if(y===null)throw c$1.execution("DATE_OFFSET_LIMIT_EXCEEDED",`A working-day offset of ${u.toLocaleString("en-US")} could not be reached within the ${g}-year limit; the configured holiday calendar leaves too few working days`,{requestedWorkdays:u,limitYears:g,maxCalendarSteps:f});return y}var Kt=864e5,hn={month:1,months:1,mo:1,year:12,years:12,yr:12,y:12,a:12,decade:120,decades:120,dec:120,century:1200,centuries:1200,millennium:12e3,millennia:12e3};function gn(r,a){return new Date(r,a+1,0).getDate()}function Zt(r,a){let s=Math.trunc(a),u=new Date(r);u.setDate(u.getDate()+s);let l=u.getTime();return Number.isNaN(l)?r+a*Kt:l+(a-s)*Kt}function yn(r,a){let s=Math.trunc(a),u=new Date(r),l=u.getDate();u.setDate(1),u.setMonth(u.getMonth()+s),u.setDate(Math.min(l,gn(u.getFullYear(),u.getMonth())));let g=u.getTime(),b=e$1(1,"month","ms");return Number.isNaN(g)?r+a*b:g+(a-s)*b}function he(r,a,s,u){if(a.type===6&&a.unit!==void 0){let l=a.unit,g=s*a.toNumber();if(a$2(l))return Qt(r,g,u);let b=hn[l];if(b!==void 0)return yn(r,g*b);if(c$4(l)==="time"){let f=0;try{f=e$1(1,l,"day");}catch{}if(Number.isInteger(f)&&f>=1)return Zt(r,g*f)}}return r+s*bn(a)}function Ht(r,a,s){let u$1=B(r.unit);if(a.type===6&&A(a.unit)){let l=B(a.unit);return l!==u$1?P("TIMECODE_FPS_MISMATCH",`Cannot combine timecodes at different frame rates (${u$1} fps vs ${l} fps)`):s===1?u(r.toNumber()+a.toNumber(),r.unit):u(r.toNumber()-a.toNumber(),"frames")}if(a.type===6&&a.unit==="frames")return u(r.toNumber()+s*a.toNumber(),r.unit);if(a.type===6&&a.unit&&c$4(a.unit)==="time"){let l=e$1(a.toNumber(),a.unit,"s");return u(r.toNumber()+s*l*u$1,r.unit)}return u(r.toNumber()+s*a.toNumber(),r.unit)}function ge(r){return r.type===10?r.value:r.toNumber()!==0}function qt(r,a){let s=l(r,a);return P("INCOMPATIBLE_UNITS",s??`Cannot convert ${r} to ${a}: they do not measure the same thing`)}var Te=65536;function Nn(r,a){if(!Number.isInteger(a)||a<0)return null;if(a===0)return 1;let s=Math.abs(r.toNumber());return s<=1?1:(s<=2?1:Math.log2(s))*a}function xn(r,a){let s=1n,u=r,l=a;for(;l>0n;)l%2n===1n&&(s*=u),l/=2n,l>0n&&(u*=u);return s}var Ze=Te;function jt(r){let a=r<0n?-r:r;if(a===0n)return 0;let s=Number(a);return Number.isFinite(s)?Math.floor(Math.log2(s))+1:a.toString(16).length*4}function zt(r,a,s$1){let u=n$1(r),l=n$1(a);if(u===0n)return s(0n);let g=s$1*Number(l);if(g<=0||jt(u)+g<=Ze)return s(s$1===1?u<<l:u>>l);throw c$1.execution("BIGINT_SHIFT_LIMIT_EXCEEDED",`Shifting by ${l} would build an exact integer of about ${(jt(u)+g).toLocaleString("en-US")} bits, past the limit of ${Ze.toLocaleString("en-US")} bits`,{shift:String(l),limitBits:Ze})}function et(r,a){let{numerator:s,denominator:u$1}=y$1(r.unit),l=c$4(u$1),g=c$4(a.unit);if(!l||l!==g)return P("RATE_MUL_MEASURE_MISMATCH",`Cannot multiply a "${u$1}"-denominated rate by "${a.unit}" \u2014 different measures`);let b=e$1(a.toNumber(),a.unit,u$1),f=r.toNumber()*b;return s?u(f,s):n(f)}function En(r){if(Number.isNaN(r))return "NaN";if(!isFinite(r))return r>0?"Infinity":"-Infinity";let a=r<0,s=Math.abs(r),u=Math.floor(s),l=s-u;if(l<1e-9)return `${a?"-":""}${u}`;let g=0,b=1,f=1,y=0,x=l,A=1e6;for(let I=0;I<30;I++){let L=Math.floor(x+1e-9),j=L*b+g,$=L*y+f;if($>A||(g=b,b=j,f=y,y=$,Math.abs(l-b/y)<1e-9))break;let n=x-L;if(n<1e-9)break;x=1/n;}let C=u*y+b;return `${a?"-":""}${C}/${y}`}function In(r){return r.d===1n?String(r.n):`${r.n}/${r.d}`}function Mn(r){let a=r.toNumber(),s=r.type===5?1+a:a;return `${Math.round(s*1e6)/1e6}x`}function Dn(r){if(!Number.isFinite(r))return String(r);if(r===0)return "0e+0";let[a,s]=r.toExponential().split("e");return `${a.includes(".")?a.replace(/0+$/,"").replace(/\.$/,""):a}e${s}`}function tt(r$3,a$2,s$2,u$2,l,g$2){let b$2=ln(r$3);if(b$2)return {type:"error",error:c$1.validation({code:"MALFORMED_BYTECODE_PROGRAM",message:`Malformed bytecode: ${b$2}`,expected:"a BytecodeProgram with opcodes, numbers and strings",found:b$2,suggestion:Jt})};let{opcodes:f$3,numbers:y,strings:x$1,userFunctionBodies:A$1,anonymousBodies:C$2}=r$3,I$1=0,L$1=0,j$3=a$2.getMaxInstructions(),$$1=a$2.getMaxStackDepth(),n$2=a$2.getStack(),Q$1=s$2?.hasCollectors??false,G$2=j();if(f$3.length===0)return {type:"value",value:n(0)};a(a$2);try{for(;I$1<f$3.length;){if(++L$1>j$3)throw c$1.execution("INSTRUCTION_LIMIT_EXCEEDED",`Execution exceeded maximum of ${j$3} instructions`);if(n$2.length>$$1)throw c$1.execution("STACK_LIMIT_EXCEEDED",`Execution exceeded maximum stack depth of ${$$1}`);let d$1=f$3[I$1++];if(Q$1){let e=n$2.map(t=>({type:t.type,value:t.value,unit:t.unit}));s$2.fireVmStep({type:c$2.VmStep,elapsedNs:0,expression:u$2??"",opcode:d$1,opcodeName:b(d$1),ip:I$1-1,stackDepth:n$2.length,instructionNumber:L$1,stack:e});}switch(d$1){case 0:break;case 1:{let e=c(n$2);return {type:"value",value:G$2?k(e):e}}case 3:{let e=c(n$2);n$2.push(e),n$2.push(e);break}case 2:{let e=c(n$2),t=c(n$2);n$2.push(e),n$2.push(t);break}case 10:n$2.push(n(y[Je(f$3,I$1++,d$1,"constant-pool index",y.length,"number-pool")]));break;case 11:n$2.push(s(mn(J(f$3,I$1++,x$1,d$1,"constant-pool index"),d$1)));break;case 16:{let e=ia(J(f$3,I$1++,x$1,d$1,"constant-pool index"));n$2.push(o(ra(e),e));break}case 12:n$2.push(r$1(y[Je(f$3,I$1++,d$1,"constant-pool index",y.length,"number-pool")]));break;case 13:n$2.push(t(J(f$3,I$1++,x$1,d$1,"constant-pool index")));break;case 14:n$2.push(L(O(f$3,I$1++,d$1,"boolean operand")===1));break;case 20:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.uncertainty!==void 0||e.uncertainty!==void 0){let p=s$1(t,e,"add");if(p){n$2.push(p);break}}if(t.rational!==void 0||e.rational!==void 0){let p=r$2(t,e,"add");if(p){n$2.push(p);break}}let i=Xt(t,e,1),m=i===null?Yt(t,e):null;i!==null?n$2.push(i):m!==null?n$2.push(u(m+e.toNumber(),e.unit)):t.type===0&&e.type===0?n$2.push(n(t.value+e.value)):t.type===10&&e.type===10?n$2.push(L(t.value&&e.value)):t.type===4?e.type===4?n$2.push(P("INVALID_DATETIME_OP","Cannot add two datetimes together")):n$2.push(M(he(t.toNumber(),e,1,a$2))):t.type===6&&A(t.unit)?n$2.push(Ht(t,e,1)):e.type===4?n$2.push(M(he(e.toNumber(),t,1,a$2))):n$2.push(u$1(t,e,(p,h)=>p+h,(p,h)=>p+h,"add"));break}case 21:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.uncertainty!==void 0||e.uncertainty!==void 0){let p=s$1(t,e,"sub");if(p){n$2.push(p);break}}if(t.rational!==void 0||e.rational!==void 0){let p=r$2(t,e,"sub");if(p){n$2.push(p);break}}let i=Xt(t,e,-1),m=i===null?Yt(t,e):null;i!==null?n$2.push(i):m!==null?n$2.push(u(m-e.toNumber(),e.unit)):t.type===0&&e.type===0?n$2.push(n(t.value-e.value)):t.type===4?e.type===4?n$2.push(u(t.toNumber()-e.toNumber(),"ms")):n$2.push(M(he(t.toNumber(),e,-1,a$2))):t.type===6&&A(t.unit)?n$2.push(Ht(t,e,-1)):e.type===4?n$2.push(P("INVALID_DATETIME_OP","Cannot subtract a datetime from a value that is not a datetime")):n$2.push(u$1(t,e,(p,h)=>p-h,(p,h)=>p-h,"sub"));break}case 22:{let e=c(n$2),t=c(n$2),o=pn(t,e);if(o){n$2.push(o);break}if(t.uncertainty!==void 0||e.uncertainty!==void 0){let m=s$1(t,e,"mul");if(m){n$2.push(m);break}}if(t.rational!==void 0||e.rational!==void 0){let m=r$2(t,e,"mul");if(m){n$2.push(m);break}}let i=dn(t,e);if(i){n$2.push(i);break}if(t.type===0&&e.type===0)n$2.push(n(t.value*e.value));else if(t.type===7&&e.type===7)d(sn(t.value,e.value),"matrix cells"),n$2.push(_(t.value,e.value));else if(t.type===6&&x(t.unit)&&e.type===6&&e.unit)n$2.push(et(t,e));else if(e.type===6&&x(e.unit)&&t.type===6&&t.unit)n$2.push(et(e,t));else if(Wt(t,e)!==null)n$2.push(Wt(t,e));else {let m=ze(t,e,!0);m?n$2.push(m):n$2.push(u$1(t,e,(p,h)=>p*h,(p,h)=>p*h,"mul"));}break}case 23:{let e=c(n$2),t=c(n$2),o=fn(t,e);if(o){n$2.push(o);break}if(t.uncertainty!==void 0||e.uncertainty!==void 0){let i=s$1(t,e,"div");if(i){n$2.push(i);break}}if(t.type===6&&e.type===6){let{lv:i,rv:m,sameMeasure:p}=j$2(t,e);if(p)n$2.push(n(i/m));else if(c$5.isCurrency(t.unit)&&c$5.isCurrency(e.unit))n$2.push(P("INCOMPATIBLE_UNITS",`Cannot combine incompatible units: ${t.unit} and ${e.unit}`));else {let h=ze(t,e,!1);if(h){n$2.push(h);break}n$2.push(w(i/m,t.unit,e.unit));}}else {let i=r$2(t,e,"div");if(i){n$2.push(i);break}n$2.push(u$1(t,e,(m,p)=>m/p,(m,p)=>{if(p===0n)throw o$1();return m/p},"div"));}break}case 24:{let e=c(n$2),t=c(n$2);n$2.push(u$1(t,e,(o,i)=>o%i,(o,i)=>{if(i===0n)throw o$1();return o%i}));break}case 25:{let e=c(n$2),t=c(n$2);if(t.type===13){n$2.push(t);break}if(e.type===13){n$2.push(e);break}if(t.type===12){n$2.push(t);break}if(e.type===12){n$2.push(e);break}if(t.type===0&&e.type===0){n$2.push(n(q$3(t.value,e.value)));break}if(t.type===7||e.type===7){if(t.type!==7||e.type!==0){n$2.push(P("MATRIX_POWER_UNSUPPORTED",`^: a matrix may only be the base, raised to a whole number (as in "[1,2;3,4]^2"); "${g[t.type]} ^ ${g[e.type]}" has no matrix reading.`));break}d(on(t.value,e.value),"matrix cells"),n$2.push($(t.value,e.value));break}if(t.type===9||e.type===9){n$2.push(f$2(t,e));break}if(t.type===2||e.type===2){let o=Nn(t,e.toNumber());if(o!==null){if(o>Te)throw c$1.execution("BIGINT_POW_LIMIT_EXCEEDED",`That power would build an exact integer of about ${Math.round(o).toLocaleString("en-US")} bits, past the limit of ${Te.toLocaleString("en-US")} bits`,{limitBits:Te});n$2.push(s(xn(n$1(t),n$1(e))));break}}n$2.push(n(q$3(t.toNumber(),e.toNumber())));break}case 26:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}e.type===2?n$2.push(s(-e.value)):e.type===6&&e.exact!==void 0?n$2.push(v(-e.toNumber(),e.unit,ma(e.exact))):e.type===6?n$2.push(u(-e.toNumber(),e.unit)):e.type===5?n$2.push(N(-e.toNumber())):e.type===9?n$2.push(g$1(e)):e.type===0&&e.rational!==void 0?n$2.push(p$1(-e.toNumber(),j$1(e.rational))):e.type===0&&e.exact!==void 0?n$2.push(o(-e.toNumber(),ma(e.exact))):n$2.push(n(-e.toNumber()));break}case 27:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}e.type===6&&e.exact!==void 0?n$2.push(v(e.toNumber(),e.unit,e.exact)):e.type===6?n$2.push(u(e.toNumber(),e.unit)):e.type===5?n$2.push(N(e.toNumber())):e.type===0&&e.rational!==void 0?n$2.push(p$1(e.toNumber(),e.rational)):e.type===0&&e.exact!==void 0?n$2.push(o(e.toNumber(),e.exact)):n$2.push(n(e.toNumber()));break}case 28:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}n$2.push(q$2(t.toNumber(),Math.abs(e.toNumber())));break}case 30:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}t.type===2||e.type===2?n$2.push(zt(t,e,1)):n$2.push(n(t.toNumber()<<e.toNumber()));break}case 31:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}t.type===2||e.type===2?n$2.push(zt(t,e,-1)):n$2.push(n(t.toNumber()>>e.toNumber()));break}case 32:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}n$2.push(n(t.toNumber()>>>e.toNumber()));break}case 33:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}t.type===2||e.type===2?n$2.push(s(n$1(t)&n$1(e))):n$2.push(n(t.toNumber()&e.toNumber()));break}case 34:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}t.type===2||e.type===2?n$2.push(s(n$1(t)|n$1(e))):n$2.push(n(t.toNumber()|e.toNumber()));break}case 35:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}t.type===2||e.type===2?n$2.push(s(n$1(t)^n$1(e))):n$2.push(n(t.toNumber()^e.toNumber()));break}case 36:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}e.type===2?n$2.push(s(~e.value)):n$2.push(n(~e.toNumber()));break}case 40:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i===0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value===e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()===e.toNumber():i===0));}else if(t.type===3&&e.type===3)n$2.push(L(t.value===e.value));else if(t.type===6&&e.type===6){let{equal:i,sameMeasure:m}=k$1(t,e);n$2.push(L(m&&i));}else if(t.type===7&&e.type===7)n$2.push(aa$1(t.value,e.value,(i,m)=>i===m));else if(t.type===14||e.type===14)if(t.type===14&&e.type===14){let i=t.value,m=e.value;n$2.push(L(i.r===m.r&&i.g===m.g&&i.b===m.b&&i.a===m.a));}else n$2.push(L(!1));else n$2.push(L(t.toNumber()===e.toNumber()));break}case 41:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i!==0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value!==e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()!==e.toNumber():i!==0));}else if(t.type===3&&e.type===3)n$2.push(L(t.value!==e.value));else if(t.type===6&&e.type===6){let{equal:i,sameMeasure:m}=k$1(t,e);n$2.push(L(!m||!i));}else if(t.type===7&&e.type===7)n$2.push(aa$1(t.value,e.value,(i,m)=>i!==m));else if(t.type===14||e.type===14)if(t.type===14&&e.type===14){let i=t.value,m=e.value;n$2.push(L(!(i.r===m.r&&i.g===m.g&&i.b===m.b&&i.a===m.a)));}else n$2.push(L(!0));else n$2.push(L(t.toNumber()!==e.toNumber()));break}case 42:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i<0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value<e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()<e.toNumber():i<0));}else if(t.type===6&&e.type===6){let{lv:i,rv:m$1,equal:p,sameMeasure:h}=k$1(t,e);n$2.push(h?L(!p&&i<m$1):m(t,e));}else t.type===7&&e.type===7?n$2.push(aa$1(t.value,e.value,(i,m)=>i<m)):n$2.push(L(t.toNumber()<e.toNumber()));break}case 43:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i<=0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value<=e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()<=e.toNumber():i<=0));}else if(t.type===6&&e.type===6){let{lv:i,rv:m$1,equal:p,sameMeasure:h}=k$1(t,e);n$2.push(h?L(p||i<=m$1):m(t,e));}else t.type===7&&e.type===7?n$2.push(aa$1(t.value,e.value,(i,m)=>i<=m)):n$2.push(L(t.toNumber()<=e.toNumber()));break}case 44:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i>0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value>e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()>e.toNumber():i>0));}else if(t.type===6&&e.type===6){let{lv:i,rv:m$1,equal:p,sameMeasure:h}=k$1(t,e);n$2.push(h?L(!p&&i>m$1):m(t,e));}else t.type===7&&e.type===7?n$2.push(aa$1(t.value,e.value,(i,m)=>i>m)):n$2.push(L(t.toNumber()>e.toNumber()));break}case 45:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i>=0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value>=e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()>=e.toNumber():i>=0));}else if(t.type===6&&e.type===6){let{lv:i,rv:m$1,equal:p,sameMeasure:h}=k$1(t,e);n$2.push(h?L(p||i>=m$1):m(t,e));}else t.type===7&&e.type===7?n$2.push(aa$1(t.value,e.value,(i,m)=>i>=m)):n$2.push(L(t.toNumber()>=e.toNumber()));break}case 130:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}n$2.push(L(ge(t)&&ge(e)));break}case 131:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}n$2.push(L(ge(t)||ge(e)));break}case 132:{let e=c(n$2),t=c(n$2),o=c(n$2),i=Q(o);if(i){n$2.push(i);break}n$2.push(ge(o)?t:e);break}case 50:{let e=O(f$3,I$1++,d$1,"plugin-function index"),t=O(f$3,I$1++,d$1,"argument count"),o=[];for(let p=0;p<t;p++)o.push(c(n$2));o.reverse();let i=a$2.context.pluginFunctions[e],m=R(o);if(m)n$2.push(m);else if(!i)n$2.push(n(0));else {let p=i(o,l);if(p instanceof Promise){let h=`plugin:${e}:${o.map(B=>String(B.value??"")).join("|")}`,E=a$2.activeSignal,U=a$2.context.pluginFunctionOwners[e]??"";return {type:"pending",queryKey:h,resolver:p,packageId:U,signal:E}}n$2.push(p);}break}case 51:{let e=O(f$3,I$1++,d$1,"builtin-function index"),t=O(f$3,I$1++,d$1,"argument count"),o=Lt(e,t);if(o)throw o;let i=[],m=!1;for(let E=0;E<t;E++){let U=c(n$2);U.type===9&&(m=!0),i.push(U);}let p=R(i);if(p){n$2.push(p);break}let h=C[e];if(h){let E=i.reverse(),U=m&&!e$2.has(e);n$2.push(U?h$1(e,E):h(E));}break}case 150:{let e=O(f$3,I$1++,d$1,"function-body index"),t=A$1?.[e];if(!t)throw c$1.internal("INTERNAL_MISSING_FUNCTION_BODY",`Internal error: DEFINE_USER_FUNCTION referenced missing body index ${e}`,{bodyIdx:e});a$2.defineUserFunction(t.name,t.params,t.program);break}case 151:{let e=J(f$3,I$1++,x$1,d$1,"function-name index"),t=O(f$3,I$1++,d$1,"argument count"),o=[];for(let h=0;h<t;h++)o.push(c(n$2));o.reverse();let i=a$2.getUserFunction(e);if(!i)throw c$1.execution("UNDEFINED_FUNCTION",`Undefined function: ${e}`,{name:e});if(t!==i.params.length)throw c$1.execution("FUNCTION_ARITY_MISMATCH",`${e} expects ${i.params.length} argument(s) but got ${t}`,{name:e,expected:i.params.length,actual:t});let m=new Map;for(let h=0;h<i.params.length;h++)m.set(i.params[h],o[h]);f$1(),a$2.pushCallFrame(m);let p;try{p=tt(i.program,a$2,s$2,u$2,l);}finally{a$2.popCallFrame();}if(p.type==="pending")throw c$1.execution("USER_FUNCTION_ASYNC_UNSUPPORTED",`${e}: user-defined functions with async bodies (weather, stocks, currency, ...) aren't supported`,{name:e});if(p.type==="error")throw p.error;n$2.push(p.value);break}case 60:{let e=J(f$3,I$1++,x$1,d$1,"variable-name index"),t=a$2.getVar(e);if(t!==void 0)n$2.push(t);else if(g$2)n$2.push(K(q$1(e)));else throw c$1.execution("UNDEFINED_VARIABLE",`Undefined variable: ${e}`,{varName:e});break}case 61:{let e=c(n$2),t=J(f$3,I$1++,x$1,d$1,"variable-name index");a$2.setVar(t,G$2?k(e):e),n$2.push(e);break}case 62:{let e=J(f$3,I$1++,x$1,d$1,"variable-name index"),t=J$1.get(e);if(t===void 0)throw c$1.internal({code:"GLOBAL_VARIABLE_NOT_RESOLVED",message:`Global variable "${e}" was read before it resolved`,expected:`global variable "${e}" to already be resolved (async preflight should guarantee this)`,found:"no value in the global variable store",context:{varName:e}});n$2.push(t);break}case 63:{let e=c(n$2),t=J(f$3,I$1++,x$1,d$1,"variable-name index");J$1.set(t,G$2?k(e):e),n$2.push(e);break}case 70:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(n(e.toNumber()));break}case 71:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}if(e.type===14){let o=e.value;n$2.push(G$1({r:o.r,g:o.g,b:o.b,a:o.a,format:"hex"}));break}n$2.push(r$1(e.type===2?e.value:e.toNumber()));break}case 74:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(N(e.toNumber()));break}case 140:{let e=c(n$2),t$1=Q(e);if(t$1){n$2.push(t$1);break}n$2.push(t(e.rational!==void 0?In(e.rational):En(e.toNumber())));break}case 141:{let e=c(n$2),t$1=Q(e);if(t$1){n$2.push(t$1);break}n$2.push(t(Mn(e)));break}case 142:{let e=c(n$2),t$1=Q(e);if(t$1){n$2.push(t$1);break}n$2.push(t(Dn(e.toNumber())));break}case 143:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(r$1(e.type===2?e.value:e.toNumber(),"bin"));break}case 144:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(r$1(e.type===2?e.value:e.toNumber(),"oct"));break}case 145:{let e=q(c(n$2),d$1,"converter name").toLowerCase(),t=c(n$2),o=Q(t);if(o){n$2.push(o);break}let i=G.get(e);i?n$2.push(i(t)):n$2.push(P("UNKNOWN_AS_CONVERTER",`Unknown converter "as ${e}"`));break}case 80:{let e=q(c(n$2),d$1,"unit name"),t=c(n$2),o=Q(t);if(o){n$2.push(o);break}let i=a$1(t,e);i?n$2.push(v(t.toNumber(),e,i)):n$2.push(u(t.toNumber(),e));break}case 81:{let e=q(c(n$2),d$1,"target unit name"),t=q(c(n$2),d$1,"source unit name"),o=c(n$2),i$1=Q(o);if(i$1){n$2.push(i$1);break}let m=o.toNumber(),p=c$4(t),h=c$5.isCurrency(t)&&c$5.isCurrency(e);if(p&&c$4(e)===p)n$2.push(u(e$1(m,t,e),e));else if(h){let E=c$5.convertSync(m,t,e);E!==null?n$2.push(u(E,e)):n$2.push(P("CURRENCY_RATE_UNAVAILABLE",`No exchange rate available for ${t} to ${e}`));}else {let E=i(m,t,e);E!==null?n$2.push(u(E,e)):n$2.push(qt(t,e));}break}case 85:{let e=q(c(n$2),d$1,"unit name"),t$1=f(e);n$2.push(t(t$1.length>0?t$1.join(", "):`No known units for "${e}"`));break}case 83:{let e=q(c(n$2),d$1,"unit name"),t=c(n$2),o=Q(t);if(o){n$2.push(o);break}let{value:i,unit:m}=h(t.toNumber(),e);n$2.push(u(i,m));break}case 84:{let e=q(c(n$2),d$1,"target unit name"),t=c(n$2),o=Q(t);if(o){n$2.push(o);break}if(t.type===6){let i$1=t.unit,m=t.toNumber(),p=c$4(i$1),h=c$5.isCurrency(i$1)&&c$5.isCurrency(e);if(p&&c$4(e)===p)n$2.push(u(e$1(m,i$1,e),e));else if(h){let E=c$5.convertSync(m,i$1,e);E!==null?n$2.push(u(E,e)):n$2.push(P("CURRENCY_RATE_UNAVAILABLE",`No exchange rate available for ${i$1} to ${e}`));}else {let E=i(m,i$1,e);E!==null?n$2.push(u(E,e)):n$2.push(qt(i$1,e));}}else n$2.push(u(t.toNumber(),e));break}case 82:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(n(e.toNumber()));break}case 110:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(e.type!==6||!e.unit){n$2.push(P("RATE_MISSING_DENOMINATOR_UNIT",'Cannot build a rate: the right-hand side of "/" has no unit'));break}let i=t.type===6?t.unit??"":"";n$2.push(w(t.toNumber()/e.toNumber(),i,e.unit));break}case 111:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.type!==6||!x(t.unit)){n$2.push(P("RATE_MUL_LEFT_NOT_A_RATE",'Left-hand side of a rate multiplication must be a rate (e.g. "$50/week")'));break}if(e.type!==6||!e.unit){n$2.push(P("RATE_MUL_RIGHT_MISSING_UNIT","Right-hand side of a rate multiplication must have a unit matching the rate's denominator"));break}n$2.push(et(t,e));break}case 112:{let e=q(c(n$2),d$1,"denominator unit name"),t=c(n$2),o=Q(t);if(o){n$2.push(o);break}if(t.type!==6||!x(t.unit)){n$2.push(P("RATE_CONVERT_NOT_A_RATE","Cannot convert a non-rate value's denominator"));break}let{numerator:i,denominator:m}=y$1(t.unit),p=c$4(m),h=c$4(e);if(!p||p!==h){n$2.push(P("RATE_CONVERT_MEASURE_MISMATCH",`Cannot convert a "${m}"-denominated rate to "${e}" \u2014 different measures`));break}let E=e$1(1,e,m);n$2.push(w(t.toNumber()*E,i,e));break}case 120:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}let o=e.toNumber(),i=new Date,m=new Date(i.getFullYear(),i.getMonth(),i.getDate(),0,0,0,0);m.setMinutes(o),n$2.push(M(m.getTime()));break}case 90:n$2.push(M(Date.now()));break;case 95:n$2.push(M(y[Je(f$3,I$1++,d$1,"constant-pool index",y.length,"number-pool")]));break;case 91:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}n$2.push(M(he(t.toNumber(),e,1,a$2)));break}case 92:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}n$2.push(M(he(t.toNumber(),e,-1,a$2)));break}case 96:{let e=O(f$3,I$1++,d$1,"workday offset direction")===1?-1:1,t=c(n$2),o=c(n$2),i=Q(o,t);if(i){n$2.push(i);break}if(t.type!==4){n$2.push(P(r.WORKDAY_OFFSET_EXPECTED_DATE,`"working days after/before/from" expects a date to count from, got ${g[t.type]??"an unsupported value"}`));break}n$2.push(M(Qt(t.toNumber(),e*o.toNumber(),a$2)));break}case 97:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.type!==4||e.type!==4){n$2.push(P(r.WORKDAYS_BETWEEN_EXPECTED_DATES,`"working days between" expects two dates, got ${g[t.type]??"an unsupported value"} and ${g[e.type]??"an unsupported value"}`));break}let i=Math.ceil((a$2.getMaxDateOffsetYears()-a$2.getMinDateOffsetYears())*366),m=Ft(t.toNumber(),e.toNumber(),p=>a$2.isHoliday(p),i);if(m===null){n$2.push(P(r.WORKDAYS_BETWEEN_RANGE_TOO_LARGE,`The two dates are more than ${a$2.getMaxDateOffsetYears()-a$2.getMinDateOffsetYears()} years apart, past the working-day count's limit`));break}n$2.push(n(m));break}case 93:case 94:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}let i=e.toNumber(),m=t.toNumber(),p=new Date(m).getDay(),h=d$1===93?(i-p+7)%7:(p-i+7)%7;h===0&&(h=7),n$2.push(M(Zt(m,d$1===93?h:-h)));break}case 152:{let e$1=O(f$3,I$1++,d$1,"row count"),t=O(f$3,I$1++,d$1,"column count"),o=e$1*t,i=e(o,"matrix cells"),m=null;for(let p=o-1;p>=0;p--){let h=c(n$2);m===null&&(m=Q(h)),i[p]=h.type===10||h.type===9?h.value:h.toNumber();}if(m){n$2.push(m);break}n$2.push(C$1(e$1,t,Y(e$1,t,i)));break}case 153:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.type!==7){n$2.push(P("MATRIX_INDEX_NOT_A_MATRIX",'Cannot index a non-matrix value with "[...]".'));break}let i=t.value,m=Math.trunc(e.toNumber());if(m<0||m>=i.data.length){n$2.push(P("MATRIX_INDEX_OUT_OF_BOUNDS",`Index ${m} is out of bounds for a ${i.rows}x${i.cols} matrix (valid range: 0-${i.data.length-1}).`));break}let p=S(i,m);n$2.push(X(p));break}case 154:{let e=c(n$2),t=c(n$2),o=c(n$2),i=Q(o,t,e);if(i){n$2.push(i);break}if(o.type!==7){n$2.push(P("MATRIX_INDEX_NOT_A_MATRIX",'Cannot index a non-matrix value with "[...]".'));break}let m=o.value,p=Math.trunc(t.toNumber()),h=Math.trunc(e.toNumber());if(!U(m,p,h)){n$2.push(P("MATRIX_INDEX_OUT_OF_BOUNDS",`[${p}, ${h}] is out of bounds for a ${m.rows}x${m.cols} matrix.`));break}let E=T(m,p,h);n$2.push(X(E));break}case 156:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.type!==0||e.type!==0){n$2.push(P("INVALID_RANGE_BOUND",`A range's bounds must be plain numbers (e.g. "0:3").`));break}let i=t.value,m=e.value;if(!Number.isInteger(i)||!Number.isInteger(m)){n$2.push(P("NON_INTEGER_RANGE_BOUND",`A range's bounds must be whole numbers, got "${i}:${m}".`));break}if(i>m){n$2.push(P("DESCENDING_RANGE",`A range's min (${i}) cannot be greater than its max (${m}) \u2014 did you mean "${m}:${i}"?`));break}n$2.push(F(i,m));break}case 155:{let e$1=c(n$2),t=c(n$2),o=c(n$2),i=Q(o,t,e$1);if(i){n$2.push(i);break}if(o.type!==7){n$2.push(P("MATRIX_INDEX_NOT_A_MATRIX",'Cannot slice a non-matrix value with "[...]".'));break}if(t.type!==8||e$1.type!==8){n$2.push(P("INVALID_MATRIX_SLICE_BOUND",'Matrix slicing needs range bounds (e.g. "a[0:1, 1:2]").'));break}let m=o.value,p=t.value,h=e$1.value;if(p.min<0||p.max>=m.rows||h.min<0||h.max>=m.cols){n$2.push(P("MATRIX_INDEX_OUT_OF_BOUNDS",`Slice [${p.min}:${p.max}, ${h.min}:${h.max}] is out of bounds for a ${m.rows}x${m.cols} matrix.`));break}let E=p.max-p.min+1,U=h.max-h.min+1,B=e(E*U,"matrix cells");for(let V=0;V<E;V++)for(let _=0;_<U;_++)B[V+_*E]=T(m,p.min+V,h.min+_);n$2.push(C$1(E,U,B));break}case 157:{let e$1=O(f$3,I$1++,d$1,"body kind"),t=O(f$3,I$1++,d$1,"body reference"),o=O(f$3,I$1++,d$1,"collection count");$t(e$1,t,d$1);let i=new Array(o);for(let k=o-1;k>=0;k--)i[k]=c(n$2);let m=[],p;if(e$1===0){let k=C$2?.[t];if(!k)throw c$1.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: MAP_INVOKE referenced missing anonymous body index ${t}`,{ref:t});m=k.params,p=k.program;}else if(e$1===2){let k=Se(x$1,t,d$1),v=a$2.getUserFunction(k);if(!v){n$2.push(P("UNDEFINED_FUNCTION",`map: undefined function "${k}"`));break}if(v.params.length!==o){n$2.push(P("FUNCTION_ARITY_MISMATCH",`map: "${k}" expects ${v.params.length} argument(s) but ${o} collection(s) were given`));break}m=v.params,p=v.program;}let h=-1,E=new Array(o),U;for(let k=0;k<o;k++){let v=ea(i[k],a$2.getMaxCollectionSize());if(!Array.isArray(v)){U=v;break}if(c$3(v.length,"collection elements"),h===-1)h=v.length;else if(v.length!==h){U=P("MAP_COLLECTION_LENGTH_MISMATCH",`map: all collections must have the same length (got ${h} and ${v.length}).`);break}E[k]=v;}if(U){n$2.push(U);break}let B=e(h,"matrix cells"),V;for(let k=0;k<h;k++){let v=new Array(o);for(let ye=0;ye<o;ye++)v[ye]=E[ye][k];let ae=e$1===1?C[t]?.(v)??P("UNKNOWN_BUILTIN_FUNCTION",`map: unknown builtin function index ${t}`):Qe(m,p,v,a$2,s$2,u$2,l,!!g$2),nt=Q(ae);if(nt){V=nt;break}B[k]=ae.type===10||ae.type===9?ae.value:ae.toNumber();}if(V){n$2.push(V);break}let _=i[0],R=_?.type===7?_.value:void 0;R&&R.rows*R.cols===h?n$2.push(C$1(R.rows,R.cols,B)):n$2.push(C$1(1,h,B));break}case 160:{let e=O(f$3,I$1++,d$1,"plot body reference"),t=O(f$3,I$1++,d$1,"plot expression"),o=Se(x$1,t,d$1),i=c(n$2).toNumber(),m=c(n$2).toNumber(),p=C$2?.[e];if(!p)throw c$1.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: PLOT_INVOKE referenced missing anonymous body index ${e}`,{ref:e});if(!Number.isFinite(m)||!Number.isFinite(i)){n$2.push(P("PLOT_INVALID_RANGE",`plot: the range bounds must be finite numbers (got ${m} to ${i})`));break}let h=[];for(let _=0;_<Pt;_++){let R=m+_/(Pt-1)*(i-m),k;try{k=Qe(p.params,p.program,[n(R)],a$2,s$2,u$2,l,!!g$2).toNumber();}catch{continue}Number.isFinite(k)&&h.push([R,k]);}let E=h.map(_=>_[1]),U=E.length?Math.min(...E):0,B=E.length?Math.max(...E):0,V=_=>Number.isInteger(_)?String(_):String(Number(_.toFixed(2)));n$2.push(I({kind:"plot",points:h,label:`${o} over [${V(m)}, ${V(i)}]`,domain:[m,i],range:[U,B],expr:o}));break}case 158:{let e=O(f$3,I$1++,d$1,"body kind"),t=O(f$3,I$1++,d$1,"body reference"),o=O(f$3,I$1++,d$1,"initial-value flag");$t(e,t,d$1);let i=o?c(n$2):void 0,m=c(n$2),p=[],h;if(e===0){let _=C$2?.[t];if(!_)throw c$1.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: REDUCE_INVOKE referenced missing anonymous body index ${t}`,{ref:t});p=_.params,h=_.program;}else if(e===2){let _=Se(x$1,t,d$1),R=a$2.getUserFunction(_);if(!R){n$2.push(P("UNDEFINED_FUNCTION",`reduce: undefined function "${_}"`));break}if(R.params.length!==2){n$2.push(P("FUNCTION_ARITY_MISMATCH",`reduce: "${_}" must take exactly 2 arguments (accumulator, element), got ${R.params.length}`));break}p=R.params,h=R.program;}let E=ea(m,a$2.getMaxCollectionSize());if(!Array.isArray(E)){n$2.push(E);break}c$3(E.length,"collection elements");let U,B;if(i!==void 0){let _=Q(i);if(_){n$2.push(_);break}U=i,B=0;}else {if(E.length===0){n$2.push(P("REDUCE_EMPTY_COLLECTION","reduce: cannot reduce an empty collection without an initial value."));break}U=E[0],B=1;}let V;for(let _=B;_<E.length;_++){let R=[U,E[_]],k=e===1?C[t]?.(R)??P("UNKNOWN_BUILTIN_FUNCTION",`reduce: unknown builtin function index ${t}`):Qe(p,h,R,a$2,s$2,u$2,l,!!g$2),v=Q(k);if(v){V=v;break}U=k;}if(V){n$2.push(V);break}n$2.push(U);break}case 159:{let e=O(f$3,I$1++,d$1,"body reference"),t=C$2?.[e];if(!t)throw c$1.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: BIND_UNKNOWN referenced missing anonymous body index ${e}`,{ref:e});n$2.push(cn(t.params[0],t.program,a$2,s$2,u$2,l,!!g$2));break}}}let K$1=c(n$2);return {type:"value",value:G$2?k(K$1):K$1}}catch(K){return {type:"error",error:d$1(K)}}finally{b$1();}}export{Ot as a,vt as b,aa as c,tt as d};//# sourceMappingURL=chunk-EOMHELRL.js.map
2
- //# sourceMappingURL=chunk-EOMHELRL.js.map