@sheetxl/scripting 0.4.12 → 0.4.14

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.
@@ -1,9 +1,9 @@
1
1
  "use strict";/**
2
- * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.4.12
2
+ * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.4.14
3
3
  *
4
4
  * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
6
- */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const he=require("./DKBHGmlcuuioi8Lf.cjs"),ie="n",ge="s",we="b",Ce="e",ae="z";var se,J,r;(J=se||(se={})).Orientation={Column:"column",Row:"row"},J.Orientations={...J.Orientation,Both:"both"},J.Direction={Up:"up",Down:"down",Left:"left",Right:"right"},(e=>{e.Code={Parse:0,Null:1,Div0:2,Value:3,Ref:4,Name:5,Num:6,NA:7,GettingData:8,Spill:9,Connect:10,Blocked:11,Unknown:12,Field:13,Calc:14,Busy:16,Python:19,Timeout:20},e.Label={Parse:"#PARSE!",Null:"#NULL!",Div0:"#DIV/0!",Value:"#VALUE!",Ref:"#REF!",Name:"#NAME?",Num:"#NUM!",NA:"#N/A",GettingData:"#GETTING_DATA",Spill:"#SPILL!",Connect:"#CONNECT!",Blocked:"#BLOCKED!",Unknown:"#UNKNOWN!",Field:"#FIELD!",Calc:"#CALC!",Busy:"#BUSY!",Python:"#PYTHON!",Timeout:"#TIMEOUT!"};class a extends Error{constructor(n,o,L,q){super(L,q),this._label=o,this._code=n,this.details=q}static{this.code=e.Code.Unknown}get isFormulaError(){return!0}getLabel(){return this._label}getCode(){return this._code}equals(n){return!!n&&(this._code===n._code||this._code===n.code)}get[Symbol.toStringTag](){return"[FormulaError]"}toString(){return this.message||this._label}}e.Known=a;class C extends a{constructor(n,o){super(e.Code.Parse,e.Label.Parse,n,o)}static{this.code=e.Code.Parse}getDetails(){const n=this.details;return{line:n?.line??1,column:n?.column??1,offset:n?.offset??0,length:n?.length??0}}}e.Parse=C;class p extends a{constructor(n,o){super(e.Code.Null,e.Label.Null,n,o)}static{this.code=e.Code.Null}}e.Null=p;class F extends a{constructor(n,o){super(e.Code.Div0,e.Label.Div0,n,o)}static{this.code=e.Code.Div0}}e.Div0=F;class R extends a{constructor(n,o){super(e.Code.Value,e.Label.Value,n,o)}static{this.code=e.Code.Value}}e.Value=R;class s extends a{constructor(n,o){super(e.Code.Ref,e.Label.Ref,n,o)}static{this.code=e.Code.Ref}}e.Ref=s;class K extends a{constructor(n,o){super(e.Code.Name,e.Label.Name,n,o)}static{this.code=e.Code.Name}}e.Name=K;class k extends a{constructor(n,o){super(e.Code.Num,e.Label.Num,n,o)}static{this.code=e.Code.Num}}e.Num=k;class b extends a{constructor(n,o){super(e.Code.NA,e.Label.NA,n,o)}static{this.code=e.Code.NA}}e.NA=b;class N extends a{constructor(n,o){super(e.Code.GettingData,e.Label.GettingData,n,o)}static{this.code=e.Code.GettingData}}e.GettingData=N;class d extends a{constructor(n,o){super(e.Code.Spill,e.Label.Spill,n,o)}static{this.code=e.Code.Spill}}e.Spill=d;class S extends a{constructor(n,o){super(e.Code.Connect,e.Label.Connect,n,o)}static{this.code=e.Code.Connect}}e.Connect=S;class G extends a{constructor(n,o){super(e.Code.Blocked,e.Label.Blocked,n,o)}static{this.code=e.Code.Blocked}}e.Blocked=G;class _ extends a{constructor(n,o){super(e.Code.Unknown,e.Label.Unknown,n,o)}static{this.code=e.Code.Unknown}}e.Unknown=_;class B extends a{constructor(n,o){super(e.Code.Field,e.Label.Field,n,o)}static{this.code=e.Code.Field}}e.Field=B;class X extends a{constructor(n,o){super(e.Code.Calc,e.Label.Calc,n,o)}static{this.code=e.Code.Calc}}e.Calc=X;class I extends a{constructor(n,o){super(e.Code.Busy,e.Label.Busy,n,o)}static{this.code=e.Code.Busy}}e.Busy=I;class A extends a{constructor(n,o){super(e.Code.Python,e.Label.Python,n,o)}static{this.code=e.Code.Python}}e.Python=A;class Y extends a{constructor(n,o){super(e.Code.Timeout,e.Label.Timeout,n,o)}static{this.code=e.Code.Timeout}}e.Timeout=Y})(r||(r={}));const y={};y[r.Code.Parse]=r.Parse,y[r.Code.Null]=r.Null,y[r.Code.Div0]=r.Div0,y[r.Code.Value]=r.Value,y[r.Code.Ref]=r.Ref,y[r.Code.Name]=r.Name,y[r.Code.Num]=r.Num,y[r.Code.NA]=r.NA,y[r.Code.GettingData]=r.GettingData,y[r.Code.Spill]=r.Spill,y[r.Code.Connect]=r.Connect,y[r.Code.Blocked]=r.Blocked,y[r.Code.Unknown]=r.Unknown,y[r.Code.Field]=r.Field,y[r.Code.Calc]=r.Calc,y[r.Code.Busy]=r.Busy,y[r.Code.Python]=r.Python,y[r.Code.Timeout]=r.Timeout;const ce=new Map,ne=new Map,de=new Map,ue=new Map,le=Object.keys(y);for(let e=0;e<le.length;e++){const a=le[e],C=y[a];de.set(r.Label[a],C),ue.set(r.Code[a],C);const p=new C;ce.set(p.getLabel(),p),ne.set(p.getCode(),p)}const xe=ne.get(r.Code.Unknown);var u;(u=r||(r={})).BuiltIn={Parse:new u.Parse,Null:new u.Null,Div0:new u.Div0,Value:new u.Value,Ref:new u.Ref,Name:new u.Name,Num:new u.Num,NA:new u.NA,GettingData:new u.GettingData,Spill:new u.Spill,Connect:new u.Connect,Blocked:new u.Blocked,Unknown:new u.Unknown,Field:new u.Field,Calc:new u.Calc,Busy:new u.Busy,Python:new u.Python,Timeout:new u.Timeout},u.getBuiltInByLabel=e=>ce.get(e),u.newTypedError=(e,a,C)=>{let p;return p=typeof e=="string"?de.get(e):ue.get(e),p||(p=u.Unknown),new p(a,C)},u.getBuiltInById=e=>ne.get(e)||xe;let z=null,H=null;const be={compilerOptions:{target:"esnext"}};async function Te(e,a,C="/script.js",p="__SHEETXL"){try{const F=await async function(){if(z)return z;if(H){if(await H,!z)throw new Error("ESBuild initialization promise resolved, but instance is not available.");return z}let b,N;H=new Promise((d,S)=>{b=d,N=S});try{const{initialize:d}=await Promise.resolve().then(()=>require("./CBrxfIVjVoHo8-IX.cjs"));return z=await d(),b(),z}catch(d){throw console.error("Failed to import or initialize esbuild:",d),H=null,N(d),d}}(),R="@sheetxl/primitives",s=`
6
+ */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const he=require("./BQPfgN0ijC5ILY6C.cjs"),ie="n",ge="s",we="b",Ce="e",ae="z";var se,J,r;(J=se||(se={})).Orientation={Column:"column",Row:"row"},J.Orientations={...J.Orientation,Both:"both"},J.Direction={Up:"up",Down:"down",Left:"left",Right:"right"},(e=>{e.Code={Parse:0,Null:1,Div0:2,Value:3,Ref:4,Name:5,Num:6,NA:7,GettingData:8,Spill:9,Connect:10,Blocked:11,Unknown:12,Field:13,Calc:14,Busy:16,Python:19,Timeout:20},e.Label={Parse:"#PARSE!",Null:"#NULL!",Div0:"#DIV/0!",Value:"#VALUE!",Ref:"#REF!",Name:"#NAME?",Num:"#NUM!",NA:"#N/A",GettingData:"#GETTING_DATA",Spill:"#SPILL!",Connect:"#CONNECT!",Blocked:"#BLOCKED!",Unknown:"#UNKNOWN!",Field:"#FIELD!",Calc:"#CALC!",Busy:"#BUSY!",Python:"#PYTHON!",Timeout:"#TIMEOUT!"};class a extends Error{constructor(n,o,L,q){super(L,q),this._label=o,this._code=n,this.details=q}static{this.code=e.Code.Unknown}get isFormulaError(){return!0}getLabel(){return this._label}getCode(){return this._code}equals(n){return!!n&&(this._code===n._code||this._code===n.code)}get[Symbol.toStringTag](){return"[FormulaError]"}toString(){return this.message||this._label}}e.Known=a;class C extends a{constructor(n,o){super(e.Code.Parse,e.Label.Parse,n,o)}static{this.code=e.Code.Parse}getDetails(){const n=this.details;return{line:n?.line??1,column:n?.column??1,offset:n?.offset??0,length:n?.length??0}}}e.Parse=C;class p extends a{constructor(n,o){super(e.Code.Null,e.Label.Null,n,o)}static{this.code=e.Code.Null}}e.Null=p;class F extends a{constructor(n,o){super(e.Code.Div0,e.Label.Div0,n,o)}static{this.code=e.Code.Div0}}e.Div0=F;class R extends a{constructor(n,o){super(e.Code.Value,e.Label.Value,n,o)}static{this.code=e.Code.Value}}e.Value=R;class s extends a{constructor(n,o){super(e.Code.Ref,e.Label.Ref,n,o)}static{this.code=e.Code.Ref}}e.Ref=s;class K extends a{constructor(n,o){super(e.Code.Name,e.Label.Name,n,o)}static{this.code=e.Code.Name}}e.Name=K;class k extends a{constructor(n,o){super(e.Code.Num,e.Label.Num,n,o)}static{this.code=e.Code.Num}}e.Num=k;class b extends a{constructor(n,o){super(e.Code.NA,e.Label.NA,n,o)}static{this.code=e.Code.NA}}e.NA=b;class N extends a{constructor(n,o){super(e.Code.GettingData,e.Label.GettingData,n,o)}static{this.code=e.Code.GettingData}}e.GettingData=N;class d extends a{constructor(n,o){super(e.Code.Spill,e.Label.Spill,n,o)}static{this.code=e.Code.Spill}}e.Spill=d;class S extends a{constructor(n,o){super(e.Code.Connect,e.Label.Connect,n,o)}static{this.code=e.Code.Connect}}e.Connect=S;class G extends a{constructor(n,o){super(e.Code.Blocked,e.Label.Blocked,n,o)}static{this.code=e.Code.Blocked}}e.Blocked=G;class _ extends a{constructor(n,o){super(e.Code.Unknown,e.Label.Unknown,n,o)}static{this.code=e.Code.Unknown}}e.Unknown=_;class B extends a{constructor(n,o){super(e.Code.Field,e.Label.Field,n,o)}static{this.code=e.Code.Field}}e.Field=B;class W extends a{constructor(n,o){super(e.Code.Calc,e.Label.Calc,n,o)}static{this.code=e.Code.Calc}}e.Calc=W;class I extends a{constructor(n,o){super(e.Code.Busy,e.Label.Busy,n,o)}static{this.code=e.Code.Busy}}e.Busy=I;class A extends a{constructor(n,o){super(e.Code.Python,e.Label.Python,n,o)}static{this.code=e.Code.Python}}e.Python=A;class X extends a{constructor(n,o){super(e.Code.Timeout,e.Label.Timeout,n,o)}static{this.code=e.Code.Timeout}}e.Timeout=X})(r||(r={}));const y={};y[r.Code.Parse]=r.Parse,y[r.Code.Null]=r.Null,y[r.Code.Div0]=r.Div0,y[r.Code.Value]=r.Value,y[r.Code.Ref]=r.Ref,y[r.Code.Name]=r.Name,y[r.Code.Num]=r.Num,y[r.Code.NA]=r.NA,y[r.Code.GettingData]=r.GettingData,y[r.Code.Spill]=r.Spill,y[r.Code.Connect]=r.Connect,y[r.Code.Blocked]=r.Blocked,y[r.Code.Unknown]=r.Unknown,y[r.Code.Field]=r.Field,y[r.Code.Calc]=r.Calc,y[r.Code.Busy]=r.Busy,y[r.Code.Python]=r.Python,y[r.Code.Timeout]=r.Timeout;const ce=new Map,ne=new Map,de=new Map,ue=new Map,le=Object.keys(y);for(let e=0;e<le.length;e++){const a=le[e],C=y[a];de.set(r.Label[a],C),ue.set(r.Code[a],C);const p=new C;ce.set(p.getLabel(),p),ne.set(p.getCode(),p)}const xe=ne.get(r.Code.Unknown);var u;(u=r||(r={})).BuiltIn={Parse:new u.Parse,Null:new u.Null,Div0:new u.Div0,Value:new u.Value,Ref:new u.Ref,Name:new u.Name,Num:new u.Num,NA:new u.NA,GettingData:new u.GettingData,Spill:new u.Spill,Connect:new u.Connect,Blocked:new u.Blocked,Unknown:new u.Unknown,Field:new u.Field,Calc:new u.Calc,Busy:new u.Busy,Python:new u.Python,Timeout:new u.Timeout},u.getBuiltInByLabel=e=>ce.get(e),u.newTypedError=(e,a,C)=>{let p;return p=typeof e=="string"?de.get(e):ue.get(e),p||(p=u.Unknown),new p(a,C)},u.getBuiltInById=e=>ne.get(e)||xe;let z=null,Y=null;const be={compilerOptions:{target:"esnext"}};async function Te(e,a,C="/script.js",p="__SHEETXL"){try{const F=await async function(){if(z)return z;if(Y){if(await Y,!z)throw new Error("ESBuild initialization promise resolved, but instance is not available.");return z}let b,N;Y=new Promise((d,S)=>{b=d,N=S});try{const{initialize:d}=await Promise.resolve().then(()=>require("./SjXlAXqNYDgBMqmK.cjs"));return z=await d(),b(),z}catch(d){throw console.error("Failed to import or initialize esbuild:",d),Y=null,N(d),d}}(),R="@sheetxl/primitives",s=`
7
7
  export const FormulaContext = globalThis.${p}?.FormulaContext;
8
8
  export const ScalarType = globalThis.${p}?.ScalarType;
9
9
  export const Observable = globalThis.${p}?.Observable;
@@ -15,7 +15,7 @@
15
15
  interface FirstTest {
16
16
  isTrue?: boolean;
17
17
  }
18
- `,pe=new Map([["IReferenceRange","r"],["IRange","l"]]),me=new Map([["IWorkbook","workbook"],["ISheet","sheet"],["ICellRanges","ranges"],["ICellRange","range"],["IFormulaContext","context"]]),ee=(e,a)=>{Array.from(a.keys()).forEach(C=>{const p=a.get(C);a.set(`${e}.${C}`,p)})},Ne=new Map([["Scalar","*"],["FormulaError.Known",Ce],["Date","Date"],["JSON","JSON"]]),Se=new Map([]),te="SheetXL";ee(te,pe),ee(te,me),ee(te,Se);const Ee=new Map([["Promise",()=>({async:!0})],["Observable",()=>({stream:!0})]]);let W=null;async function Le(){if(W)return W;try{return await(await Promise.resolve().then(()=>require("./a3Iep33Vu7URpTHP.cjs"))).initialize()}catch(e){throw W=null,e}finally{W=null}}exports.compileModule=async function(e){const a=e?.source??null;if(!a)return null;const C=(e.disableBundle||e.declarationsOnly)??!1,p=[ke(),Le()],F=await Promise.all(p),R=F[0],s=F[1];let K="",k=null;const b=[],N={allowJs:!0,declaration:!1,sourceMap:!1,inlineSourceMap:!1,inlineSources:!1,isolatedModules:!0,preserveConstEnums:!1,module:99,noResolve:!0,emitDeclarationOnly:!1,target:s.ScriptTarget.ES2020},d="script",S=`${d}.ts`,G="lib.d.ts",_="global.d.ts",B={[S]:a,[G]:`
18
+ `,pe=new Map([["IReferenceRange","r"],["IRange","l"]]),me=new Map([["IWorkbook","workbook"],["ISheet","sheet"],["ICellRanges","ranges"],["ICellRange","range"],["IFormulaContext","context"]]),ee=(e,a)=>{Array.from(a.keys()).forEach(C=>{const p=a.get(C);a.set(`${e}.${C}`,p)})},Ne=new Map([["Scalar","*"],["FormulaError.Known",Ce],["Date","Date"],["JSON","JSON"]]),Se=new Map([]),te="SheetXL";ee(te,pe),ee(te,me),ee(te,Se);const Ee=new Map([["Promise",()=>({async:!0})],["Observable",()=>({stream:!0})]]);let H=null;async function Le(){if(H)return H;try{return await(await Promise.resolve().then(()=>require("./BoCQDYgHzE7jNyA1.cjs"))).initialize()}catch(e){throw H=null,e}finally{H=null}}exports.compileModule=async function(e){const a=e?.source??null;if(!a)return null;const C=(e.disableBundle||e.declarationsOnly)??!1,p=[ke(),Le()],F=await Promise.all(p),R=F[0],s=F[1];let K="",k=null;const b=[],N={allowJs:!0,declaration:!1,sourceMap:!1,inlineSourceMap:!1,inlineSources:!1,isolatedModules:!0,preserveConstEnums:!1,module:99,noResolve:!0,emitDeclarationOnly:!1,target:s.ScriptTarget.ES2020},d="script",S=`${d}.ts`,G="lib.d.ts",_="global.d.ts",B={[S]:a,[G]:`
19
19
  /**
20
20
  * Represents the completion of an asynchronous operation
21
21
  */
@@ -28,5 +28,5 @@ interface Promise<T> {
28
28
  */
29
29
  finally(onfinally?: (() => void) | undefined | null): Promise<T>;
30
30
  }
31
- `,[_]:R},X={getSourceFile:(t,i,T,E)=>s.createSourceFile(t,B[t],s.ScriptTarget.Latest,!0),fileExists:t=>B[t]!==void 0,readFile:t=>B[t],writeFile:(t,i)=>{B[t]=i},getCurrentDirectory:()=>"./",getCanonicalFileName:t=>t,useCaseSensitiveFileNames:()=>!0,getDefaultLibFileName:t=>G,getNewLine:()=>`
32
- `},I=s.createProgram([S,_],N,X),A=I.getTypeChecker(),Y=I.getSourceFile(S),m=I.emit();m.diagnostics.length>0&&console.warn(m.diagnostics),K=B[`${d}.js`];const n=(t,i,T,E)=>{if(t){if(t.kind===s.SyntaxKind.NumberKeyword)i.scalar=ie;else if(t.kind===s.SyntaxKind.StringKeyword)i.scalar=ge;else if(t.kind===s.SyntaxKind.BooleanKeyword)i.scalar=we;else if(t.kind===s.SyntaxKind.UndefinedKeyword||t.kind===s.SyntaxKind.NullKeyword||t.kind===s.SyntaxKind.VoidKeyword){if(E)return void L(t,new Error(`'undefined' is not a valid type for input: '${t?.parent?.name?.escapedText}'.`));i.scalar=ae}else if(t.kind===s.SyntaxKind.BigIntKeyword)i.scalar=ie;else if(t.kind===s.SyntaxKind.AnyKeyword)i.scalar=ae;else if(t.kind===s.SyntaxKind.ArrayType){const f=t.elementType;if(!f)return void L(t,new Error(`'Array' must be typed: '${t?.parent?.name?.escapedText}'.`));i.arrayDepth=(i.arrayDepth??0)+1,n(f,i,T,E)}else if(t.kind!==s.SyntaxKind.TupleType){if(t.kind===s.SyntaxKind.TypeReference){const f=t.typeName?.getText?.()??null,V=pe.get(f);let P=!1;V&&(i.range=V,P=!0);const M=Ne.get(f);if(M&&(i.scalar=M),M!==void 0&&(P=!0),E){const l=me.get(f);if(l)return l}else{const l=Ee.get(f);if(l){const h={...i,...l()};let v=0;if(h.async&&v++,h.stream&&v++,v>1)return void L(t,new Error(`'${f}' cannot have multiple modifiers: '${t?.parent?.name?.escapedText}'.`));i=h,P=!0}}if(!P)return void L("node",new Error(`'${f}' is not a valid type: '${t?.parent?.name?.escapedText}'.`));const x=t.typeArguments;if(x){if(x.length!==1)return void L(t,new Error(`'${f}' must be typed with exactly 1 type: '${t?.parent?.name?.escapedText}'.`));n(x[0],i,T,E)}}}}else L(t,new Error(`Type is not defined for '${i?.name??"return"}'.`))},o=[],L=(t,i)=>{o.push(i)};if(s.forEachChild(Y,t=>{if((i=>(s.getCombinedModifierFlags(i)&s.ModifierFlags.Export)!==0)(t)&&s.isFunctionDeclaration(t)){const i={},T={parameters:{}},E=t?.name?.getText();try{i.name=E;const f=A.getSymbolAtLocation(t.name).getDocumentationComment(A);if(f&&f.length>0&&f[0].text){let x=f[0].text;x=x.replace(/[\r\n]+/g,"\\n").trim(),T.summary=x}const V={};n(t.type,V,i,!1),i.returnType=V;const P={};(x=>(s.getCombinedModifierFlags(x)&s.ModifierFlags.Default)!==0)(t)&&(P.default=!0,k=E),Object.keys(P).length>0&&(i.behavior=P),i.parameters=[];const M=new Map;for(let x=0;x<t.parameters.length;x++){const l=t.parameters[x],h={};h.name=l.name?.getText();const v=n(l.type,h,i,!0);if(v){if(i.parameters.length!==0){const U=t?.parent,w=U?.name?.getText();return void L(t,new Error(`'${i.name}' contexts must be the first parameter: '${w}'.`))}i.context=v;continue}let D;if((l.initializer!==void 0&&l.initializer!==null||l.questionToken!==void 0&&l.questionToken!==null)&&(h.optional=!0,l.initializer))try{D=l.initializer.kind===s.SyntaxKind.StringLiteral?l.initializer.text:l.initializer.kind===s.SyntaxKind.NumericLiteral?parseFloat(l.initializer.text):l.initializer.kind===s.SyntaxKind.TrueKeyword||l.initializer.kind===s.SyntaxKind.FalseKeyword?l.initializer.kind===s.SyntaxKind.TrueKeyword:l.initializer.kind===s.SyntaxKind.NullKeyword?null:l.initializer.kind===s.SyntaxKind.ObjectLiteralExpression||l.initializer.kind===s.SyntaxKind.ArrayLiteralExpression?l.initializer.getText():l.initializer.getText?.()}catch(U){console.warn(`Couldn't extract default value for parameter '${h.name}'`,U)}l.dotDotDotToken&&(h.rest=!0),i.parameters.push(h);const g={description:""};T.parameters[h.name]=g;const c=A.getSymbolAtLocation(l.name).getDocumentationComment(A);c&&c.length>0&&c[0].text&&(g.description=c[0].text),D!==void 0&&(g.defaultValue=D),M.set(h.name,h)}if(t.jsDoc&&t.jsDoc.length>0){const x=t.jsDoc;for(let l=0;l<x.length;l++){const h=x[l]?.tags;if(h)for(let v=0;v<h.length;v++){const D=h[v];let g=D?.tagName?.text;if(!g)continue;g=g.toLowerCase();let c=D.comment;const U=g==="hidden";if((typeof c=="string"||U)&&(typeof c=="string"&&(c=c.replace(/[\r\n]+/g,"\\n").trim()),U||!c||(c=c.split(/\\n/)[0],c&&c.length!==0))){if(c&&typeof c=="string"){const w=/\{@link(code|plain)?\s+([^}|]+)(?:\s*\|\s*([^}]+))?\}/g;let $,O=c,j=[];for(;($=w.exec(c))!==null;){const[Q,Z,ye,re]=$,fe=[ye.trim()];re&&fe.push(re.trim())}c=O,j.length>0&&g==="see"&&(T.links||(T.links=[]),T.links.push(...j))}if(g==="name"){const w=c;w!==E&&(T.name=w)}else if(g!=="description"){if(g==="summary"){const w=c;w&&(T.summary=w)}else if(g==="param"){const w=D.name?.text,$=M.get(w);if(!$){o.push(new Error(`Parameter '${w}' not found in function '${E}'.`));continue}if(D.typeExpression&&D.typeExpression.type)try{const O=D.typeExpression.type;if(O.kind===s.SyntaxKind.UnionType){const j=[];$.enums=j,O.types.forEach(Q=>{if(Q.kind===s.SyntaxKind.LiteralType){const Z=Q.literal.text;Z&&j.push(Z)}})}}catch(O){console.warn("Error parsing JSDoc type expression:",O)}}else if(g==="returns"||g==="return")i.returnType.description=c;else if(g==="category")T.category=c;else if(g==="hidden"){let w=!0;const $=c?.toLowerCase();$==="false"?w=!1:$!=="true"&&(w=c),w!==!1&&(T.hidden=w??!0)}}}}}}Object.keys(i.returnType).length===0&&delete i.returnType,b.push([i,T])}catch(f){L(t,new Error(`'${E}': ${f.message}`))}}}),o.length>0)throw console.warn(o),new Error("There were compilation errors.",{cause:o});if(b.length===0)throw new Error("No exported functions.");const q=`${he.et.uuidV4()}-script`;try{C||o.length!==0||(K=await Te(0,K,d))}catch{console.warn("Error bundling script")}const oe={functions:b,commitId:q,source:a,name:"Script",language:"typescript",compiled:K};return k&&(oe.autoRun=k),oe};
31
+ `,[_]:R},W={getSourceFile:(t,i,T,E)=>s.createSourceFile(t,B[t],s.ScriptTarget.Latest,!0),fileExists:t=>B[t]!==void 0,readFile:t=>B[t],writeFile:(t,i)=>{B[t]=i},getCurrentDirectory:()=>"./",getCanonicalFileName:t=>t,useCaseSensitiveFileNames:()=>!0,getDefaultLibFileName:t=>G,getNewLine:()=>`
32
+ `},I=s.createProgram([S,_],N,W),A=I.getTypeChecker(),X=I.getSourceFile(S),m=I.emit();m.diagnostics.length>0&&console.warn(m.diagnostics),K=B[`${d}.js`];const n=(t,i,T,E)=>{if(t){if(t.kind===s.SyntaxKind.NumberKeyword)i.scalar=ie;else if(t.kind===s.SyntaxKind.StringKeyword)i.scalar=ge;else if(t.kind===s.SyntaxKind.BooleanKeyword)i.scalar=we;else if(t.kind===s.SyntaxKind.UndefinedKeyword||t.kind===s.SyntaxKind.NullKeyword||t.kind===s.SyntaxKind.VoidKeyword){if(E)return void L(t,new Error(`'undefined' is not a valid type for input: '${t?.parent?.name?.escapedText}'.`));i.scalar=ae}else if(t.kind===s.SyntaxKind.BigIntKeyword)i.scalar=ie;else if(t.kind===s.SyntaxKind.AnyKeyword)i.scalar=ae;else if(t.kind===s.SyntaxKind.ArrayType){const f=t.elementType;if(!f)return void L(t,new Error(`'Array' must be typed: '${t?.parent?.name?.escapedText}'.`));i.arrayDepth=(i.arrayDepth??0)+1,n(f,i,T,E)}else if(t.kind!==s.SyntaxKind.TupleType){if(t.kind===s.SyntaxKind.TypeReference){const f=t.typeName?.getText?.()??null,V=pe.get(f);let P=!1;V&&(i.range=V,P=!0);const M=Ne.get(f);if(M&&(i.scalar=M),M!==void 0&&(P=!0),E){const l=me.get(f);if(l)return l}else{const l=Ee.get(f);if(l){const h={...i,...l()};let v=0;if(h.async&&v++,h.stream&&v++,v>1)return void L(t,new Error(`'${f}' cannot have multiple modifiers: '${t?.parent?.name?.escapedText}'.`));i=h,P=!0}}if(!P)return void L("node",new Error(`'${f}' is not a valid type: '${t?.parent?.name?.escapedText}'.`));const x=t.typeArguments;if(x){if(x.length!==1)return void L(t,new Error(`'${f}' must be typed with exactly 1 type: '${t?.parent?.name?.escapedText}'.`));n(x[0],i,T,E)}}}}else L(t,new Error(`Type is not defined for '${i?.name??"return"}'.`))},o=[],L=(t,i)=>{o.push(i)};if(s.forEachChild(X,t=>{if((i=>(s.getCombinedModifierFlags(i)&s.ModifierFlags.Export)!==0)(t)&&s.isFunctionDeclaration(t)){const i={},T={parameters:{}},E=t?.name?.getText();try{i.name=E;const f=A.getSymbolAtLocation(t.name).getDocumentationComment(A);if(f&&f.length>0&&f[0].text){let x=f[0].text;x=x.replace(/[\r\n]+/g,"\\n").trim(),T.summary=x}const V={};n(t.type,V,i,!1),i.returnType=V;const P={};(x=>(s.getCombinedModifierFlags(x)&s.ModifierFlags.Default)!==0)(t)&&(P.default=!0,k=E),Object.keys(P).length>0&&(i.behavior=P),i.parameters=[];const M=new Map;for(let x=0;x<t.parameters.length;x++){const l=t.parameters[x],h={};h.name=l.name?.getText();const v=n(l.type,h,i,!0);if(v){if(i.parameters.length!==0){const U=t?.parent,w=U?.name?.getText();return void L(t,new Error(`'${i.name}' contexts must be the first parameter: '${w}'.`))}i.context=v;continue}let D;if((l.initializer!==void 0&&l.initializer!==null||l.questionToken!==void 0&&l.questionToken!==null)&&(h.optional=!0,l.initializer))try{D=l.initializer.kind===s.SyntaxKind.StringLiteral?l.initializer.text:l.initializer.kind===s.SyntaxKind.NumericLiteral?parseFloat(l.initializer.text):l.initializer.kind===s.SyntaxKind.TrueKeyword||l.initializer.kind===s.SyntaxKind.FalseKeyword?l.initializer.kind===s.SyntaxKind.TrueKeyword:l.initializer.kind===s.SyntaxKind.NullKeyword?null:l.initializer.kind===s.SyntaxKind.ObjectLiteralExpression||l.initializer.kind===s.SyntaxKind.ArrayLiteralExpression?l.initializer.getText():l.initializer.getText?.()}catch(U){console.warn(`Couldn't extract default value for parameter '${h.name}'`,U)}l.dotDotDotToken&&(h.rest=!0),i.parameters.push(h);const g={description:""};T.parameters[h.name]=g;const c=A.getSymbolAtLocation(l.name).getDocumentationComment(A);c&&c.length>0&&c[0].text&&(g.description=c[0].text),D!==void 0&&(g.defaultValue=D),M.set(h.name,h)}if(t.jsDoc&&t.jsDoc.length>0){const x=t.jsDoc;for(let l=0;l<x.length;l++){const h=x[l]?.tags;if(h)for(let v=0;v<h.length;v++){const D=h[v];let g=D?.tagName?.text;if(!g)continue;g=g.toLowerCase();let c=D.comment;const U=g==="hidden";if((typeof c=="string"||U)&&(typeof c=="string"&&(c=c.replace(/[\r\n]+/g,"\\n").trim()),U||!c||(c=c.split(/\\n/)[0],c&&c.length!==0))){if(c&&typeof c=="string"){const w=/\{@link(code|plain)?\s+([^}|]+)(?:\s*\|\s*([^}]+))?\}/g;let $,O=c,j=[];for(;($=w.exec(c))!==null;){const[Q,Z,ye,re]=$,fe=[ye.trim()];re&&fe.push(re.trim())}c=O,j.length>0&&g==="see"&&(T.links||(T.links=[]),T.links.push(...j))}if(g==="name"){const w=c;w!==E&&(T.name=w)}else if(g!=="description"){if(g==="summary"){const w=c;w&&(T.summary=w)}else if(g==="param"){const w=D.name?.text,$=M.get(w);if(!$){o.push(new Error(`Parameter '${w}' not found in function '${E}'.`));continue}if(D.typeExpression&&D.typeExpression.type)try{const O=D.typeExpression.type;if(O.kind===s.SyntaxKind.UnionType){const j=[];$.enums=j,O.types.forEach(Q=>{if(Q.kind===s.SyntaxKind.LiteralType){const Z=Q.literal.text;Z&&j.push(Z)}})}}catch(O){console.warn("Error parsing JSDoc type expression:",O)}}else if(g==="returns"||g==="return")i.returnType.description=c;else if(g==="category")T.category=c;else if(g==="hidden"){let w=!0;const $=c?.toLowerCase();$==="false"?w=!1:$!=="true"&&(w=c),w!==!1&&(T.hidden=w??!0)}}}}}}Object.keys(i.returnType).length===0&&delete i.returnType,b.push([i,T])}catch(f){L(t,new Error(`'${E}': ${f.message}`))}}}),o.length>0)throw console.warn(o),new Error("There were compilation errors.",{cause:o});if(b.length===0)throw new Error("No exported functions.");const q=`${he.Yt.uuidV4()}-script`;try{C||o.length!==0||(K=await Te(0,K,d))}catch{console.warn("Error bundling script")}const oe={functions:b,commitId:q,source:a,name:"Script",language:"typescript",compiled:K};return k&&(oe.autoRun=k),oe};
@@ -1,5 +1,5 @@
1
1
  "use strict";/**
2
- * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.4.12
2
+ * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.4.14
3
3
  *
4
4
  * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
@@ -1,6 +1,6 @@
1
1
  "use strict";/**
2
- * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.4.12
2
+ * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.4.14
3
3
  *
4
4
  * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
6
- */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./DKBHGmlcuuioi8Lf.cjs");exports.ScriptingUtils=t.ScriptingUtils;
6
+ */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./BQPfgN0ijC5ILY6C.cjs");exports.ScriptingUtils=t.ScriptingUtils;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.4.12
2
+ * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.4.14
3
3
  *
4
4
  * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
@@ -1,12 +1,12 @@
1
1
  /**
2
- * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.4.12
2
+ * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.4.14
3
3
  *
4
4
  * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
6
6
  */
7
7
  const h = "text/html", b = "text/plain", L = "image/png", Tt = Object.freeze({ left: 0, top: 0 }), Ct = Object.freeze({ left: 0, top: 0, bottom: 0, right: 0 }), Mt = Object.freeze({ x: 0, y: 0, width: 0, height: 0 });
8
8
  Object.freeze(Object.defineProperty({ __proto__: null, EmptyBounds: Mt, EmptyRect: Ct, EmptyTopLeft: Tt }, Symbol.toStringTag, { value: "Module" }));
9
- const m = "column", j = "row", Rt = Object.freeze({ colIndex: 0, rowIndex: 0 }), At = Object.freeze({ colStart: 0, rowStart: 0, colEnd: 0, rowEnd: 0 }), yt = (e, t) => e.colStart === t.colStart ? e.rowStart - t.rowStart : e.colStart - t.colStart, gt = (e, t) => e.rowStart === t.rowStart ? e.colStart - t.colStart : e.rowStart - t.rowStart, Ft = (e, t) => e.rowEnd === t.rowEnd ? t.colEnd - e.colEnd : t.rowEnd - e.rowEnd, Lt = (e, t) => e.colEnd === t.colEnd ? t.rowEnd - e.rowEnd : t.colEnd - e.colEnd, J = (e, t) => e.colIndex === t.colIndex ? e.rowIndex - t.rowIndex : e.colIndex - t.colIndex, H = (e, t) => e.rowIndex === t.rowIndex ? e.colIndex - t.colIndex : e.rowIndex - t.rowIndex, bt = (e = j, t = !1) => t ? e !== m ? Ft : Lt : e !== m ? gt : yt, K = (e, t) => e === t || !(!e || !t) && e.rowIndex === t.rowIndex && e.colIndex === t.colIndex, D = (e, t) => e === t || !(!e || !t) && e.rowStart === t.rowStart && e.rowEnd === t.rowEnd && e.colStart === t.colStart && e.colEnd === t.colEnd, $ = (e, t) => !(!e || !t || e.colStart > t.colEnd || t.colStart > e.colEnd || e.rowStart > t.rowEnd || t.rowStart > e.rowEnd), Y = (e, t) => {
9
+ const m = "column", j = "row", Rt = Object.freeze({ colIndex: 0, rowIndex: 0 }), At = Object.freeze({ colStart: 0, rowStart: 0, colEnd: 0, rowEnd: 0 }), yt = (e, t) => e.colStart === t.colStart ? e.rowStart - t.rowStart : e.colStart - t.colStart, gt = (e, t) => e.rowStart === t.rowStart ? e.colStart - t.colStart : e.rowStart - t.rowStart, Ft = (e, t) => e.rowEnd === t.rowEnd ? t.colEnd - e.colEnd : t.rowEnd - e.rowEnd, Lt = (e, t) => e.colEnd === t.colEnd ? t.rowEnd - e.rowEnd : t.colEnd - e.colEnd, J = (e, t) => e.colIndex === t.colIndex ? e.rowIndex - t.rowIndex : e.colIndex - t.colIndex, H = (e, t) => e.rowIndex === t.rowIndex ? e.colIndex - t.colIndex : e.rowIndex - t.rowIndex, bt = (e = j, t = !1) => t ? e !== m ? Ft : Lt : e !== m ? gt : yt, Y = (e, t) => e === t || !(!e || !t) && e.rowIndex === t.rowIndex && e.colIndex === t.colIndex, D = (e, t) => e === t || !(!e || !t) && e.rowStart === t.rowStart && e.rowEnd === t.rowEnd && e.colStart === t.colStart && e.colEnd === t.colEnd, $ = (e, t) => !(!e || !t || e.colStart > t.colEnd || t.colStart > e.colEnd || e.rowStart > t.rowEnd || t.rowStart > e.rowEnd), K = (e, t) => {
10
10
  if (e === t) return !0;
11
11
  if (!e || !t || e.length !== t.length) return !1;
12
12
  for (let n = 0; n < e.length; n++) if (!D(e[n], t[n])) return !1;
@@ -36,23 +36,23 @@ function X(e, t = 2, n, r = j, o) {
36
36
  do {
37
37
  const c = a.sort(bt(i ? j : m));
38
38
  a = [], a.push(c[0]);
39
- const u = c.length;
40
- let w = 0, d = c[0], f = d.colStart, p = d.rowStart, x = d.colEnd, O = d.rowEnd;
41
- for (let A = 1; A < u; A++) {
39
+ const d = c.length;
40
+ let w = 0, u = c[0], f = u.colStart, p = u.rowStart, x = u.colEnd, O = u.rowEnd;
41
+ for (let A = 1; A < d; A++) {
42
42
  const g = c[A];
43
43
  let G = !1;
44
- if (G = i ? d && p === g.rowStart && O === g.rowEnd && x + 1 === g.colStart : d && f === g.colStart && x === g.colEnd && O + 1 === g.rowStart, G) {
44
+ if (G = i ? u && p === g.rowStart && O === g.rowEnd && x + 1 === g.colStart : u && f === g.colStart && x === g.colEnd && O + 1 === g.rowStart, G) {
45
45
  let S = { colStart: f, rowStart: p, colEnd: i ? g.colEnd : x, rowEnd: i ? O : g.rowEnd };
46
- if (d.value !== void 0 && (S.value = d.value), n) {
46
+ if (u.value !== void 0 && (S.value = u.value), n) {
47
47
  const F = o ?? [null, null];
48
- F[0] = d, F[1] = g, S = n(F, S, r);
48
+ F[0] = u, F[1] = g, S = n(F, S, r);
49
49
  }
50
50
  if (S) {
51
- a[w] = S, s = !0, d = S, f = d.colStart, p = d.rowStart, x = d.colEnd, O = d.rowEnd;
51
+ a[w] = S, s = !0, u = S, f = u.colStart, p = u.rowStart, x = u.colEnd, O = u.rowEnd;
52
52
  continue;
53
53
  }
54
54
  }
55
- a[++w] = g, d = g, f = d.colStart, p = d.rowStart, x = d.colEnd, O = d.rowEnd;
55
+ a[++w] = g, u = g, f = u.colStart, p = u.rowStart, x = u.colEnd, O = u.rowEnd;
56
56
  }
57
57
  l++, i = !i, l === 1 && (s = !0);
58
58
  } while (l < t && s && a.length > 1);
@@ -66,16 +66,16 @@ Object.freeze(Object.defineProperty({ __proto__: null, EmptyCell: Rt, EmptyRange
66
66
  const n = [];
67
67
  let r, o, a = Number.MIN_SAFE_INTEGER, i = Number.MIN_SAFE_INTEGER;
68
68
  return { append: (l, s, c) => {
69
- let u = !0;
69
+ let d = !0;
70
70
  const w = c !== void 0;
71
71
  if (w) {
72
72
  const p = e ? e(o, c, t) : o === c ? c : void 0;
73
- p === void 0 ? u = !1 : c = p;
73
+ p === void 0 ? d = !1 : c = p;
74
74
  }
75
- if (u && s === i + 1 && l === a) return t ? r.rowEnd = s : r.colEnd = s, i = s, void (o = c);
75
+ if (d && s === i + 1 && l === a) return t ? r.rowEnd = s : r.colEnd = s, i = s, void (o = c);
76
76
  r && n.push(r);
77
- const d = t ? l : s, f = t ? s : l;
78
- r = { colStart: d, rowStart: f, colEnd: d, rowEnd: f }, w && (r.value = c), a = l, i = s, o = c;
77
+ const u = t ? l : s, f = t ? s : l;
78
+ r = { colStart: u, rowStart: f, colEnd: u, rowEnd: f }, w && (r.value = c), a = l, i = s, o = c;
79
79
  }, done: (l) => (r && (n.push(r), r = null), l ? X(n, 3, l === !0 ? Pt : l, t ? m : j, Ut) : n) };
80
80
  }, createRangeComparator: bt, defaultRange: (e, t, n) => e ? n ? (n.colStart = e.colStart ?? t.colStart, n.rowStart = e.rowStart ?? t.rowStart, n.colEnd = e.colEnd ?? t.colEnd, n.rowEnd = e.rowEnd ?? t.rowEnd, n) : { colStart: e.colStart ?? t.colStart, rowStart: e.rowStart ?? t.rowStart, colEnd: e.colEnd ?? t.colEnd, rowEnd: e.rowEnd ?? t.rowEnd } : t, extendRangeToIntersectingRanges: Z, extendRangeToUnionRanges: (e, t) => {
81
81
  if (!t || t.length === 0) return e;
@@ -93,7 +93,7 @@ Object.freeze(Object.defineProperty({ __proto__: null, EmptyCell: Rt, EmptyRange
93
93
  const r = Math.max(e.colStart, t.colStart), o = Math.max(e.rowStart, t.rowStart), a = Math.min(e.colEnd, t.colEnd), i = Math.min(e.rowEnd, t.rowEnd);
94
94
  let l = n;
95
95
  return l ? (l.colStart = r, l.rowStart = o, l.colEnd = a, l.rowEnd = i) : l = { colStart: r, rowStart: o, colEnd: a, rowEnd: i }, l;
96
- }, isCellWithinRange: (e, t) => !(!e || !t || e.rowIndex < t.rowStart || e.rowIndex > t.rowEnd || e.colIndex < t.colStart || e.colIndex > t.colEnd), isEqualCells: K, isEqualRanges: D, isEqualRangesArrays: Y, isEqualSelectionCoords: (e, t) => e === t || !(!e || !t) && e.rangeIndex === t.rangeIndex && !!K(e.cell, t.cell) && Y(e.ranges, t.ranges), isRangeWithinRange: (e, t) => !(e.rowStart < t.rowStart || e.rowEnd > t.rowEnd || e.colStart < t.colStart || e.colEnd > t.colEnd), isRangesIntersect: $, isSingleCell: (e) => !!e && e.rowEnd === e.rowStart && e.colStart === e.colEnd, isValidRange: (e) => !(!e || typeof e.colStart != "number" || e.colStart < 0 || typeof e.colEnd != "number" || e.colEnd < e.colStart || typeof e.rowStart != "number" || e.rowStart < 0 || typeof e.rowEnd != "number" || e.rowEnd < e.rowStart), mergeRangedValues: X, rowFirstCellComparator: H, rowFirstRangeComparator: gt, sanitizeRange: (e) => e ? { colStart: e.colIndex ?? e.colStart ?? 0, rowStart: e.rowIndex ?? e.rowStart ?? 0, colEnd: e.colIndex ?? e.colEnd ?? 0, rowEnd: e.rowIndex ?? e.rowEnd ?? 0 } : null, translateRange: (e, t = -e.rowStart, n = -e.colStart, r) => r ? (r.colStart = e.colStart + n, r.rowStart = e.rowStart + t, r.colEnd = e.colEnd + n, r.rowEnd = e.rowEnd + t, r) : { colStart: e.colStart + n, rowStart: e.rowStart + t, colEnd: e.colEnd + n, rowEnd: e.rowEnd + t }, unionRanges: U, unionRangesArrays: (e, t, n) => {
96
+ }, isCellWithinRange: (e, t) => !(!e || !t || e.rowIndex < t.rowStart || e.rowIndex > t.rowEnd || e.colIndex < t.colStart || e.colIndex > t.colEnd), isEqualCells: Y, isEqualRanges: D, isEqualRangesArrays: K, isEqualSelectionCoords: (e, t) => e === t || !(!e || !t) && e.rangeIndex === t.rangeIndex && !!Y(e.cell, t.cell) && K(e.ranges, t.ranges), isRangeWithinRange: (e, t) => !(e.rowStart < t.rowStart || e.rowEnd > t.rowEnd || e.colStart < t.colStart || e.colEnd > t.colEnd), isRangesIntersect: $, isSingleCell: (e) => !!e && e.rowEnd === e.rowStart && e.colStart === e.colEnd, isValidRange: (e) => !(!e || typeof e.colStart != "number" || e.colStart < 0 || typeof e.colEnd != "number" || e.colEnd < e.colStart || typeof e.rowStart != "number" || e.rowStart < 0 || typeof e.rowEnd != "number" || e.rowEnd < e.rowStart), mergeRangedValues: X, rowFirstCellComparator: H, rowFirstRangeComparator: gt, sanitizeRange: (e) => e ? { colStart: e.colIndex ?? e.colStart ?? 0, rowStart: e.rowIndex ?? e.rowStart ?? 0, colEnd: e.colIndex ?? e.colEnd ?? 0, rowEnd: e.rowIndex ?? e.rowEnd ?? 0 } : null, translateRange: (e, t = -e.rowStart, n = -e.colStart, r) => r ? (r.colStart = e.colStart + n, r.rowStart = e.rowStart + t, r.colEnd = e.colEnd + n, r.rowEnd = e.rowEnd + t, r) : { colStart: e.colStart + n, rowStart: e.rowStart + t, colEnd: e.colEnd + n, rowEnd: e.rowEnd + t }, unionRanges: U, unionRangesArrays: (e, t, n) => {
97
97
  if (!e || e.length === 0) return null;
98
98
  if (e.length === 1 && !t) return e[0];
99
99
  let r = e[0];
@@ -106,9 +106,7 @@ function Nt(e) {
106
106
  return !!t && typeof t == "object";
107
107
  }(e) && !function(t) {
108
108
  const n = Object.prototype.toString.call(t);
109
- return n === "[object RegExp]" || n === "[object Date]" || function(r) {
110
- return r.$$typeof === kt;
111
- }(t);
109
+ return n === "[object RegExp]" || n === "[object Date]" || t.$$typeof === kt;
112
110
  }(e);
113
111
  }
114
112
  function I(e, t) {
@@ -121,11 +119,10 @@ function Bt(e, t, n) {
121
119
  });
122
120
  }
123
121
  function Q(e) {
124
- return Object.keys(e).concat(function(t) {
125
- return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(n) {
126
- return Object.propertyIsEnumerable.call(t, n);
127
- }) : [];
128
- }(e));
122
+ return Object.keys(e).concat((t = e, Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(n) {
123
+ return Object.propertyIsEnumerable.call(t, n);
124
+ }) : []));
125
+ var t;
129
126
  }
130
127
  function tt(e, t) {
131
128
  try {
@@ -142,12 +139,11 @@ function E(e, t, n) {
142
139
  return i.isMergeableObject(o) && Q(o).forEach(function(s) {
143
140
  l[s] = I(o[s], i);
144
141
  }), Q(a).forEach(function(s) {
145
- (function(c, u) {
146
- return tt(c, u) && !(Object.hasOwnProperty.call(c, u) && Object.propertyIsEnumerable.call(c, u));
147
- })(o, s) || (tt(o, s) && i.isMergeableObject(a[s]) ? l[s] = function(c, u) {
142
+ var c, d;
143
+ tt(c = o, d = s) && (!Object.hasOwnProperty.call(c, d) || !Object.propertyIsEnumerable.call(c, d)) || (tt(o, s) && i.isMergeableObject(a[s]) ? l[s] = function(w, u) {
148
144
  if (!u.customMerge) return E;
149
- const w = u.customMerge(c);
150
- return typeof w == "function" ? w : E;
145
+ const f = u.customMerge(w);
146
+ return typeof f == "function" ? f : E;
151
147
  }(s, i)(o[s], a[s], i) : l[s] = I(a[s], i));
152
148
  }), l;
153
149
  }(e, t, n) : I(t, n);
@@ -199,14 +195,14 @@ const it = (e, t = !1) => (document.hasFocus() || t) && (e === document.activeEl
199
195
  }), debounce: function(e, t = 300, n = !1) {
200
196
  let r, o, a, i, l = 0;
201
197
  function s() {
202
- let u = Date.now() - l;
203
- u < t && u >= 0 ? r = setTimeout(s, t - u) : (r = null, n || (i = e.apply(a, o), a = o = null));
198
+ let d = Date.now() - l;
199
+ d < t && d >= 0 ? r = setTimeout(s, t - d) : (r = null, n || (i = e.apply(a, o), a = o = null));
204
200
  }
205
201
  t == null && (t = 100);
206
202
  const c = function() {
207
203
  a = globalThis, o = arguments, l = Date.now();
208
- var u = n && !r;
209
- return r || (r = setTimeout(s, t)), u && (i = e.apply(a, o), a = o = null), i;
204
+ var d = n && !r;
205
+ return r || (r = setTimeout(s, t)), d && (i = e.apply(a, o), a = o = null), i;
210
206
  };
211
207
  return c.clear = function() {
212
208
  r && (clearTimeout(r), r = null);
@@ -508,19 +504,17 @@ Object.freeze(Object.defineProperty({ __proto__: null, DATA_URL_PNG_PREFIX: Ot,
508
504
  const a = t?.properties, i = t?.arrayType ?? !1;
509
505
  let l = o;
510
506
  if (t && t.merge && l && r) l = t.merge(l, r, n);
511
- else if (!i) {
512
- if (a) {
513
- const s = Object.keys({ ...o, ...r });
514
- l = null;
515
- for (let c = 0; c < s.length; c++) {
516
- const u = s[c];
517
- let w, d = o[u];
518
- if (d !== void 0) {
519
- const f = a[u];
520
- w = f ? (0, ct.resolveTypedUpdates)(d, f, n, r?.[u]) : d;
521
- } else w = r?.[u];
522
- w != null && (l = l ?? {}, l[u] = w);
523
- }
507
+ else if (!i && a) {
508
+ const s = Object.keys({ ...o, ...r });
509
+ l = null;
510
+ for (let c = 0; c < s.length; c++) {
511
+ const d = s[c];
512
+ let w, u = o[d];
513
+ if (u !== void 0) {
514
+ const f = a[d];
515
+ w = f ? (0, ct.resolveTypedUpdates)(u, f, n, r?.[d]) : u;
516
+ } else w = r?.[d];
517
+ w != null && (l = l ?? {}, l[d] = w);
524
518
  }
525
519
  }
526
520
  return l;
@@ -694,29 +688,29 @@ class wt {
694
688
  await N(), o && a.length === 0 && (a.push(new ClipboardItem({ [v]: new Blob([o], { type: v }) })), a.push(new ClipboardItem({ [h]: new Blob([ft(o)], { type: h }) })));
695
689
  for (let l = 0; l < Math.min(1, a.length); l++) {
696
690
  const s = a[l];
697
- let c = s.types.indexOf(h), u = null;
691
+ let c = s.types.indexOf(h), d = null;
698
692
  if (c !== -1) {
699
693
  const f = await s.getType(h);
700
- u = await W(f), u && (u = Wt(o, u));
694
+ d = await W(f), d && (d = Wt(o, d));
701
695
  }
702
- if (!u && s.types.includes(b)) {
696
+ if (!d && s.types.includes(b)) {
703
697
  const f = await s.getType(b);
704
698
  if (f) {
705
699
  let p = null;
706
- typeof f == "string" ? (console.warn("text as string", f), p = f) : p = await W(f), p && (u = `<div ${C}="${o}">${p}</div>`);
700
+ typeof f == "string" ? (console.warn("text as string", f), p = f) : p = await W(f), p && (d = `<div ${C}="${o}">${p}</div>`);
707
701
  }
708
702
  }
709
- if (!u && s.types.includes(L)) {
703
+ if (!d && s.types.includes(L)) {
710
704
  const f = await s.getType(L), p = xt(await f.arrayBuffer());
711
- u = `<div ${C}="${o}"><img src="${Ot + p}"/></div>`;
705
+ d = `<div ${C}="${o}"><img src="${Ot + p}"/></div>`;
712
706
  }
713
- !u && o && (u = ft(o));
714
- const w = new Blob([u ?? ""], { type: h }), d = {};
707
+ !d && o && (d = ft(o));
708
+ const w = new Blob([d ?? ""], { type: h }), u = {};
715
709
  for (let f = 0; f < s.types.length; f++) {
716
710
  const p = s.types[f];
717
- d[p] = f === c ? w : s.getType(p);
711
+ u[p] = f === c ? w : s.getType(p);
718
712
  }
719
- u && c === -1 && (d[h] = w), o && (d[v] = new Blob([o], { type: v })), r.push(new ClipboardItem(d));
713
+ d && c === -1 && (u[h] = w), o && (u[v] = new Blob([o], { type: v })), r.push(new ClipboardItem(u));
720
714
  }
721
715
  try {
722
716
  r && r.length !== 0 ? await this._nativeClipboard.write(r) : await (async (l) => {
@@ -815,12 +809,12 @@ const Vt = Object.freeze({ compileTypescript: async function(e) {
815
809
  if (q && $t.deepEqual(q, e)) return ht;
816
810
  const t = await async function() {
817
811
  if (M) return M;
818
- const { TypeScriptCompiler: r } = await import("./DIuEZ8oh1MzdXn0j.mjs");
812
+ const { TypeScriptCompiler: r } = await import("./CbmE8l8M_7bxAd3f.mjs");
819
813
  return M = new r(), M;
820
814
  }(), n = await t.compileModule(e);
821
815
  return ht = n, q = e, n;
822
816
  } });
823
817
  export {
824
818
  Vt as S,
825
- $t as e
819
+ $t as Y
826
820
  };
@@ -1,6 +1,6 @@
1
- import { e as he } from "./ZcaR45N07z-TrTku.mjs";
1
+ import { Y as he } from "./BFwy2jitcSC4h5RC.mjs";
2
2
  /**
3
- * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.4.12
3
+ * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.4.14
4
4
  *
5
5
  * (C) 2025-present SheetXL Inc. & Michael T. Ford
6
6
  * License: The license can be found at https://www.sheetxl.com/license.
@@ -166,7 +166,7 @@ var se, q, r;
166
166
  }
167
167
  }
168
168
  e.Field = B;
169
- class X extends a {
169
+ class W extends a {
170
170
  constructor(n, o) {
171
171
  super(e.Code.Calc, e.Label.Calc, n, o);
172
172
  }
@@ -174,7 +174,7 @@ var se, q, r;
174
174
  this.code = e.Code.Calc;
175
175
  }
176
176
  }
177
- e.Calc = X;
177
+ e.Calc = W;
178
178
  class O extends a {
179
179
  constructor(n, o) {
180
180
  super(e.Code.Busy, e.Label.Busy, n, o);
@@ -193,7 +193,7 @@ var se, q, r;
193
193
  }
194
194
  }
195
195
  e.Python = A;
196
- class Y extends a {
196
+ class X extends a {
197
197
  constructor(n, o) {
198
198
  super(e.Code.Timeout, e.Label.Timeout, n, o);
199
199
  }
@@ -201,7 +201,7 @@ var se, q, r;
201
201
  this.code = e.Code.Timeout;
202
202
  }
203
203
  }
204
- e.Timeout = Y;
204
+ e.Timeout = X;
205
205
  })(r || (r = {}));
206
206
  const f = {};
207
207
  f[r.Code.Parse] = r.Parse, f[r.Code.Null] = r.Null, f[r.Code.Div0] = r.Div0, f[r.Code.Value] = r.Value, f[r.Code.Ref] = r.Ref, f[r.Code.Name] = r.Name, f[r.Code.Num] = r.Num, f[r.Code.NA] = r.NA, f[r.Code.GettingData] = r.GettingData, f[r.Code.Spill] = r.Spill, f[r.Code.Connect] = r.Connect, f[r.Code.Blocked] = r.Blocked, f[r.Code.Unknown] = r.Unknown, f[r.Code.Field] = r.Field, f[r.Code.Calc] = r.Calc, f[r.Code.Busy] = r.Busy, f[r.Code.Python] = r.Python, f[r.Code.Timeout] = r.Timeout;
@@ -218,25 +218,25 @@ var u;
218
218
  let p;
219
219
  return p = typeof e == "string" ? de.get(e) : ue.get(e), p || (p = u.Unknown), new p(a, C);
220
220
  }, u.getBuiltInById = (e) => ne.get(e) || xe;
221
- let I = null, H = null;
221
+ let I = null, Y = null;
222
222
  const be = { compilerOptions: { target: "esnext" } };
223
223
  async function Te(e, a, C = "/script.js", p = "__SHEETXL") {
224
224
  try {
225
225
  const F = await async function() {
226
226
  if (I) return I;
227
- if (H) {
228
- if (await H, !I) throw new Error("ESBuild initialization promise resolved, but instance is not available.");
227
+ if (Y) {
228
+ if (await Y, !I) throw new Error("ESBuild initialization promise resolved, but instance is not available.");
229
229
  return I;
230
230
  }
231
231
  let b, N;
232
- H = new Promise((d, S) => {
232
+ Y = new Promise((d, S) => {
233
233
  b = d, N = S;
234
234
  });
235
235
  try {
236
- const { initialize: d } = await import("./Db_V2k1ItiCEuVFp.mjs");
236
+ const { initialize: d } = await import("./Be0y183_rp_NlCOK.mjs");
237
237
  return I = await d(), b(), I;
238
238
  } catch (d) {
239
- throw console.error("Failed to import or initialize esbuild:", d), H = null, N(d), d;
239
+ throw console.error("Failed to import or initialize esbuild:", d), Y = null, N(d), d;
240
240
  }
241
241
  }(), R = "@sheetxl/primitives", s = `
242
242
  export const FormulaContext = globalThis.${p}?.FormulaContext;
@@ -278,15 +278,15 @@ const ke = async () => `
278
278
  }, Ne = /* @__PURE__ */ new Map([["Scalar", "*"], ["FormulaError.Known", Ce], ["Date", "Date"], ["JSON", "JSON"]]), Se = /* @__PURE__ */ new Map([]), te = "SheetXL";
279
279
  ee(te, pe), ee(te, me), ee(te, Se);
280
280
  const Ee = /* @__PURE__ */ new Map([["Promise", () => ({ async: !0 })], ["Observable", () => ({ stream: !0 })]]);
281
- let W = null;
281
+ let H = null;
282
282
  async function Le() {
283
- if (W) return W;
283
+ if (H) return H;
284
284
  try {
285
- return await (await import("./CzvqUn8m8ZE1sVnx.mjs")).initialize();
285
+ return await (await import("./B1cgd2ZlEFvvIRHz.mjs")).initialize();
286
286
  } catch (e) {
287
- throw W = null, e;
287
+ throw H = null, e;
288
288
  } finally {
289
- W = null;
289
+ H = null;
290
290
  }
291
291
  }
292
292
  async function ve(e) {
@@ -307,10 +307,10 @@ interface Promise<T> {
307
307
  */
308
308
  finally(onfinally?: (() => void) | undefined | null): Promise<T>;
309
309
  }
310
- `, [_]: R }, X = { getSourceFile: (t, i, T, E) => s.createSourceFile(t, B[t], s.ScriptTarget.Latest, !0), fileExists: (t) => B[t] !== void 0, readFile: (t) => B[t], writeFile: (t, i) => {
310
+ `, [_]: R }, W = { getSourceFile: (t, i, T, E) => s.createSourceFile(t, B[t], s.ScriptTarget.Latest, !0), fileExists: (t) => B[t] !== void 0, readFile: (t) => B[t], writeFile: (t, i) => {
311
311
  B[t] = i;
312
312
  }, getCurrentDirectory: () => "./", getCanonicalFileName: (t) => t, useCaseSensitiveFileNames: () => !0, getDefaultLibFileName: (t) => G, getNewLine: () => `
313
- ` }, O = s.createProgram([S, _], N, X), A = O.getTypeChecker(), Y = O.getSourceFile(S), m = O.emit();
313
+ ` }, O = s.createProgram([S, _], N, W), A = O.getTypeChecker(), X = O.getSourceFile(S), m = O.emit();
314
314
  m.diagnostics.length > 0 && console.warn(m.diagnostics), K = B[`${d}.js`];
315
315
  const n = (t, i, T, E) => {
316
316
  if (t) {
@@ -356,7 +356,7 @@ interface Promise<T> {
356
356
  }, o = [], L = (t, i) => {
357
357
  o.push(i);
358
358
  };
359
- if (s.forEachChild(Y, (t) => {
359
+ if (s.forEachChild(X, (t) => {
360
360
  if (((i) => (s.getCombinedModifierFlags(i) & s.ModifierFlags.Export) !== 0)(t) && s.isFunctionDeclaration(t)) {
361
361
  const i = {}, T = { parameters: {} }, E = t?.name?.getText();
362
362
  try {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.4.12
2
+ * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.4.14
3
3
  *
4
4
  * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.