@sheetxl/scripting-react 0.8.0-beta.1 → 0.8.0-beta.3

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,41 +1,42 @@
1
1
  (function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`._script-editor_1kuph_5{& .monaco-editor{position:absolute;& .margin-icon{background-position:50%;background-repeat:no-repeat;background-size:contain;width:16px;height:16px;display:block}& .formula{cursor:pointer;background-image:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\" fill=\\"grey\\"><path d=\\"m 12.106007,8.1692949 c 0.124174,-0.1578352 0.181773,-0.3565642 0.283755,-0.5271169 0.10273,-0.1715492 0.04413,-0.2027176 -0.129161,-0.2014713 -0.685452,0.00576 -1.371152,-0.00277 -2.056604,0.00501 C 10.021228,7.4479573 9.9586414,7.407817 9.9935503,7.2080883 10.145401,6.3413623 10.291269,5.4736396 10.51219,4.6213758 10.642847,4.1167002 10.782479,3.6117747 11.061498,3.1622046 11.339518,2.7138809 11.726751,2.5974365 12.2035,2.829328 c 0.398455,0.1934923 0.722604,0.4827333 0.990152,0.8340617 0.116944,0.1535968 0.27079,0.2740306 0.449073,0.1715499 0.343348,-0.1974819 0.644807,-0.4383502 0.819599,-0.826332 0.100985,-0.2244112 0.157836,-0.476001 0.04039,-0.7058977 C 14.339646,1.9840253 14.038187,1.7618584 13.707056,1.6394296 13.156999,1.4362128 12.562559,1.4840872 12.017239,1.6758341 11.38789,1.8970037 10.783727,2.2625445 10.259602,2.6724688 10.066109,2.8238217 9.8783519,2.9839017 9.7013165,3.1547035 9.0502751,3.7823067 8.5657962,4.529097 8.2246919,5.3651534 7.9823276,5.9595939 7.7888351,6.5660026 7.6913412,7.2015842 7.673637,7.318528 7.6357391,7.423253 7.5065759,7.4432009 7.3472438,7.4678879 7.1592376,7.4436995 6.9974121,7.4441728 6.6351128,7.4451447 6.2598478,7.3676233 5.9915515,7.6815496 5.8721151,7.8211835 5.7461952,7.9840062 5.6439635,8.1371045 c -0.1009847,0.1518511 -0.093255,0.3002122 0.085027,0.367535 0.1957362,0.073561 0.4528118,0.026182 0.6530361,0.0197 0.2645558,-0.00847 0.5291116,0.00501 0.7936674,-7.476e-4 0.1820229,-0.00374 0.2413669,0.030421 0.2064588,0.2358807 C 7.3487406,8.9587006 7.3095941,9.1492003 7.2804197,9.3464333 7.1804317,10.024404 7.0667304,10.700629 6.9525298,11.376606 6.7936963,12.314146 6.6371075,13.252434 6.4655575,14.188478 6.3017374,15.082631 6.1855427,15.985013 5.983074,16.873433 5.8249883,17.568607 5.7240037,18.277248 5.5556954,18.969682 5.4145655,19.550158 5.293882,20.143601 4.9722259,20.665731 4.7380909,21.045734 4.3959882,21.206312 3.9663652,21.104829 3.5778849,21.012322 3.2115961,20.866205 2.8951763,20.608631 2.6862246,20.438328 2.4473513,20.31141 2.1920214,20.458026 1.9519014,20.595915 1.7791048,20.851743 1.646453,21.088123 1.2205704,21.847879 1.915497,22.569984 2.6655289,22.684434 3.1692071,22.760986 3.666153,22.580208 4.1087416,22.356046 4.6996913,22.056582 5.2103511,21.635437 5.6387269,21.13874 5.9898058,20.731558 6.3575906,20.343327 6.6500737,19.890016 6.8450616,19.58756 7.0238427,19.274881 7.1866655,18.954471 7.7639005,17.817206 8.1227091,16.589926 8.4189318,15.354418 8.5613081,14.760227 8.716401,14.169777 8.8478064,13.572843 9.0268365,12.760724 9.1741996,11.934891 9.3083481,11.114294 9.3749255,10.707112 9.4310263,10.300679 9.5160532,9.8967389 9.5861222,9.5636133 9.6442168,9.2185186 9.6890985,8.8814035 9.7414633,8.4891827 9.990308,8.5136187 10.329668,8.4762164 c 0.286249,-0.03167 0.574492,-0.046376 0.861739,-0.067571 0.230395,-0.016703 0.494951,0.00396 0.711881,-0.088019 0.07754,-0.032911 0.147613,-0.080788 0.202719,-0.1513533 z\\"/><path d=\\"M 22.473802,7.8481382 C 22.426924,7.6912996 22.341898,7.5501696 22.231437,7.4294861 22.130452,7.3192756 21.987827,7.1749046 21.851933,7.1098255 21.411589,6.8988785 20.817398,7.0838898 20.436149,7.3422154 20.23343,7.479854 20.052405,7.6519026 19.871131,7.8167201 19.691352,7.9802913 19.517061,8.1488492 19.35723,8.3321177 19.025101,8.7128687 18.724639,9.1210479 18.436396,9.5354601 18.296263,9.7374301 17.901549,10.472252 17.781115,10.399942 17.654198,10.323892 17.495365,9.5905657 17.435023,9.3843566 17.351243,9.0978583 17.29539,8.8016361 17.161741,8.5323425 16.97922,8.1643081 16.865268,7.7623629 16.608941,7.4307332 16.325934,7.0639457 16.001036,6.9584722 15.558946,7.092371 c -0.43436,0.1314054 -0.78469,0.4049374 -1.128539,0.6819608 -0.503927,0.4056851 -0.879442,0.926319 -1.256951,1.4439609 -0.28226,0.387483 -0.284753,0.3857373 0.04488,0.7380631 0.206458,0.2211702 0.202718,0.2184272 0.389229,-0.00847 0.2663,-0.3251469 0.524872,-0.6595196 0.882433,-0.8934057 0.261315,-0.1713009 0.417904,-0.1368908 0.57948,0.1326518 0.07929,0.1326517 0.146866,0.2752777 0.200225,0.4208957 0.335619,0.9141014 0.590201,1.8541344 0.89191,2.7784594 0.03815,0.117691 -0.01122,0.193991 -0.06707,0.278519 -0.356565,0.538837 -0.719363,1.074182 -1.123054,1.578607 -0.320409,0.401198 -0.643312,0.803891 -1.073932,1.097621 -0.187757,0.128912 -0.40768,0.217679 -0.635831,0.156839 -0.233887,-0.06283 -0.37377,-0.27478 -0.587459,-0.373521 -0.006,-0.003 -0.01272,-0.0052 -0.01895,-0.0079 -0.09974,-0.04064 -0.249845,-0.0389 -0.353074,-0.01571 -0.454059,0.102482 -0.697669,0.614139 -0.790177,1.023813 -0.08379,0.371776 -0.0013,0.778209 0.261315,1.062463 0.228899,0.24785 0.572248,0.351327 0.901634,0.356315 0.189003,0.0028 0.39995,-0.04663 0.57549,-0.11445 0.670241,-0.262062 1.181649,-0.887172 1.605038,-1.441717 0.285501,-0.374517 0.550555,-0.763994 0.829573,-1.143499 0.230645,-0.313677 0.68595,-1.247726 0.81586,-1.250718 0.07854,-0.0017 0.09924,0.185762 0.114199,0.241117 0.03341,0.123675 0.06658,0.247351 0.102232,0.370279 0.167561,0.578481 0.343848,1.156464 0.525122,1.730458 0.120934,0.384242 0.315921,0.782697 0.560779,1.103356 0.07431,0.09749 0.167311,0.190749 0.26306,0.266799 0.371276,0.296972 0.838799,0.27453 1.266177,0.123177 0.191498,-0.06757 0.370029,-0.163071 0.539335,-0.275527 0.781948,-0.519886 1.340732,-1.244235 1.868598,-2.002495 0.124423,-0.178781 0.107467,-0.278769 -0.03441,-0.428127 -0.367286,-0.386237 -0.357062,-0.389727 -0.705149,0.01995 -0.261066,0.306446 -0.527117,0.612643 -0.879442,0.818851 -0.245855,0.144621 -0.413416,0.103229 -0.592696,-0.118439 -0.14861,-0.183518 -0.246353,-0.396709 -0.33138,-0.614886 -0.349831,-0.901136 -0.588954,-1.838675 -0.885177,-2.757515 -0.21743,-0.674231 -0.223414,-0.680464 0.20945,-1.248723 0.447575,-0.587708 0.875703,-1.1968602 1.462163,-1.6613914 0.431119,-0.3416031 0.73183,-0.3226534 1.129037,0.059094 0.0788,0.075801 0.207456,0.1388856 0.316919,0.1476127 0.369781,0.029674 0.691187,-0.3024566 0.880939,-0.5792304 0.188006,-0.2727835 0.259319,-0.6183768 0.163072,-0.9392845 z\\"/></svg>")}& .macro{cursor:pointer;background-image:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\" fill=\\"grey\\"><path d=\\"m 7.3808594,2.8925781 c 0.6501558,0 1.3048608,0.1705676 1.8886719,0.5078125 l 9.2343747,5.3242188 c 1.167878,0.6758404 1.882813,1.9216266 1.882813,3.2675786 0,1.306438 -0.674828,2.517089 -1.783203,3.205078 L 9.2617188,20.595703 C 8.1035923,21.277644 6.6635531,21.275631 5.4960937,20.589844 4.3295773,19.917617 3.6132812,18.67473 3.6132813,17.330078 V 6.6660156 c 0,-1.3461361 0.7160606,-2.5932648 1.8828124,-3.265625 C 6.0817308,3.0628871 6.7318751,2.8925781 7.3808594,2.8925781 Z M 7.375,5.1835937 C 7.1238145,5.188954 6.883074,5.2521559 6.6601562,5.3691406 l -0.00781,0.00586 -0.00781,0.00391 C 6.1849913,5.6446615 5.9023438,6.1366335 5.9023437,6.6660156 V 17.330078 c 0,0.524949 0.2791508,1.016586 0.7363282,1.275391 0.4554716,0.266714 1.013907,0.272881 1.4785156,0.0098 l 9.2441405,-5.34375 c 0.450764,-0.263898 0.736328,-0.74603 0.736328,-1.27539 0,-0.52882 -0.290494,-1.018444 -0.742187,-1.277344 L 8.1171875,5.3789062 C 7.8951499,5.2512094 7.6461047,5.183439 7.375,5.1835937 Z\\"/></svg>")}& .autorun{cursor:pointer;background-image:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\" fill=\\"grey\\"><path d=\\"m 11.999964,1.7500508 c -0.462401,0 -0.923676,0.3281109 -0.924272,0.9260918 V 13.159721 c -0.0012,1.23176 1.847315,1.231936 1.848545,0 V 2.6761426 c 5.97e-4,-0.598201 -0.461872,-0.9260918 -0.924273,-0.9260918 z m 5.998674,2.6454569 c -0.728133,0.068914 -1.207022,1.0512547 -0.5149,1.63931 1.880223,1.6037705 2.962848,3.9512403 2.962038,6.4226023 -4.23e-4,4.655627 -3.790565,8.443993 -8.445812,8.443993 -4.6552096,0 -8.443993,-3.789762 -8.443993,-8.445813 C 3.5560359,10.008191 4.6172167,7.6804932 6.4634264,6.0784841 7.4240529,5.2735715 6.1821863,3.8462722 5.2535029,4.6829783 -1.9571321,10.940557 2.4945266,22.78839 12.039992,22.749957 21.585452,22.711525 25.944958,10.82919 18.684564,4.6302147 18.515847,4.4852865 18.331563,4.4098479 18.146012,4.3955077 c -0.05049,-0.0039 -0.09883,-0.00459 -0.147374,0 z\\"/></svg>")}}}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();
2
2
  /**
3
- * @license @sheetxl/scripting-react - Scripting React - Monaco based script editor and scripting UI for SheetXL. - v0.8.0-beta.1
3
+ * @license @sheetxl/scripting-react - Scripting React - Monaco based script editor and scripting UI for SheetXL. - v0.8.0-beta.3
4
4
  *
5
5
  * (C) 2026-present SheetXL Inc. & Michael T. Ford
6
6
  * License: The license can be found at https://www.sheetxl.com/license.
7
7
  */
8
- import { n as e } from "./B_Y2Mt7_n3R6KUaa.mjs";
9
- import { Suspense as t, forwardRef as n, lazy as r, memo as i, useEffect as a, useMemo as o, useRef as s, useState as c, version as l } from "react";
10
- import { createRoot as u } from "react-dom/client";
11
- import { CommonUtils as d, TimerUtils as f, messageKey as p } from "@sheetxl/utils";
8
+ import { n as e } from "./C-pWSiDCyb8QdSfE.mjs";
9
+ import { Suspense as t, forwardRef as n, memo as r, useEffect as i, useMemo as a, useRef as o, useState as s, version as c } from "react";
10
+ import { createRoot as l } from "react-dom/client";
11
+ import { CommonUtils as u, TimerUtils as d, defineLazyModule as f, messageKey as p } from "@sheetxl/utils";
12
12
  import { DocTags as m } from "@sheetxl/scripting";
13
- import { Command as h, useCallbackRef as g, useCommands as ee, useImperativeElement as te, useNotifier as _, useTranslator as ne } from "@sheetxl/utils-react";
14
- import { DefaultTaskPaneRegistry as v, useModelListener as re, useTaskPaneArea as ie, useWorkbook as ae } from "@sheetxl/react";
15
- import { jsx as y, jsxs as oe } from "react/jsx-runtime";
16
- function b(e) {
13
+ import { IScript as h } from "@sheetxl/sdk";
14
+ import { Command as g, lazyComponent as ee, useCallbackRef as _, useCommands as te, useImperativeElement as ne, useLazyRetry as v, useNotifier as re, useTranslator as ie } from "@sheetxl/utils-react";
15
+ import { jsx as y, jsxs as ae } from "react/jsx-runtime";
16
+ import { DefaultTaskPaneRegistry as b, useModelListener as oe, useTaskPaneArea as x, useWorkbook as se } from "@sheetxl/react";
17
+ function S(e) {
17
18
  var t, n, r = "";
18
19
  if (typeof e == "string" || typeof e == "number") r += e;
19
20
  else if (typeof e == "object") if (Array.isArray(e)) {
20
21
  var i = e.length;
21
- for (t = 0; t < i; t++) e[t] && (n = b(e[t])) && (r && (r += " "), r += n);
22
+ for (t = 0; t < i; t++) e[t] && (n = S(e[t])) && (r && (r += " "), r += n);
22
23
  } else for (n in e) e[n] && (r && (r += " "), r += n);
23
24
  return r;
24
25
  }
25
- function se() {
26
- for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = b(e)) && (r && (r += " "), r += t);
26
+ function ce() {
27
+ for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = S(e)) && (r && (r += " "), r += t);
27
28
  return r;
28
29
  }
29
- function x(e, t) {
30
+ function C(e, t) {
30
31
  if (typeof e == "function") return e(t);
31
32
  e && (e.current = t);
32
33
  }
33
- var ce = parseInt(l.split(".")[0], 10) >= 19 ? function(e) {
34
+ var le = parseInt(c.split(".")[0], 10) >= 19 ? function(e) {
34
35
  return (t) => {
35
36
  let n = [];
36
37
  for (let r of e) {
37
- let e = x(r, t), i = typeof e == "function";
38
- n.push(i ? e : () => x(r, null));
38
+ let e = C(r, t), i = typeof e == "function";
39
+ n.push(i ? e : () => C(r, null));
39
40
  }
40
41
  return () => {
41
42
  for (let e of n) e();
@@ -43,9 +44,9 @@ var ce = parseInt(l.split(".")[0], 10) >= 19 ? function(e) {
43
44
  };
44
45
  } : function(e) {
45
46
  return (t) => {
46
- for (let n of e) x(n, t);
47
+ for (let n of e) C(n, t);
47
48
  };
48
- }, S = {
49
+ }, w = {
49
50
  defaultToken: "invalid",
50
51
  tokenPostfix: ".ts",
51
52
  keywords: /* @__PURE__ */ "abstract.any.as.asserts.bigint.boolean.break.case.catch.class.continue.const.constructor.debugger.declare.default.delete.do.else.enum.export.extends.false.finally.for.from.function.get.if.implements.import.in.infer.instanceof.interface.is.keyof.let.module.namespace.never.new.null.number.object.out.package.private.protected.public.override.readonly.require.global.return.satisfies.set.static.string.super.switch.symbol.this.throw.true.try.type.typeof.undefined.unique.unknown.var.void.while.with.yield.async.await.of".split("."),
@@ -262,7 +263,7 @@ var ce = parseInt(l.split(".")[0], 10) >= 19 ? function(e) {
262
263
  { include: "common" }
263
264
  ]
264
265
  }
265
- }, le = {
266
+ }, ue = {
266
267
  lightbulb: { enabled: !1 },
267
268
  tabSize: 2,
268
269
  acceptSuggestionOnCommitCharacter: !0,
@@ -325,7 +326,10 @@ var ce = parseInt(l.split(".")[0], 10) >= 19 ? function(e) {
325
326
  wordWrapColumn: 80,
326
327
  wordWrapMinified: !0,
327
328
  wrappingIndent: "none"
328
- }, ue = "_script-editor_1kuph_5", C, de = r(async () => (function() {
329
+ }, de = "_script-editor_1kuph_5", fe = (e) => {
330
+ let t = e?.getModules();
331
+ return t && t.getByName(h.DEFAULT_MODULE), h.DEFAULT_MODULE;
332
+ }, T = (e) => e?.getModules()?.getByName(fe(e)) ?? null, E, D = f("scripting-react:monaco", async () => (function() {
329
333
  if (typeof window > "u") return;
330
334
  let e = window;
331
335
  if (e.__sxlDefineShim) return;
@@ -343,14 +347,31 @@ var ce = parseInt(l.split(".")[0], 10) >= 19 ? function(e) {
343
347
  } catch {}
344
348
  }
345
349
  });
346
- }(), import("./DVwFOTQu-orFdbBG.mjs"))), w = ["define", "require"], fe = !1, T = "@0.8.0-beta.1";
347
- T !== "@local" && T !== "@0.0.0" || (T = "");
348
- var E = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${T}/types/scripting.d.ts`, D = (e) => {
350
+ }(), import("./ByQ00IVdf-MhieaE.mjs")), { prefetch: !1 }), pe = ({ error: e }) => {
351
+ let t = v(), n = ie();
352
+ return ae("div", {
353
+ style: {
354
+ display: "flex",
355
+ flexDirection: "column",
356
+ alignItems: "center",
357
+ justifyContent: "center",
358
+ gap: "8px",
359
+ flex: "1 1 100%"
360
+ },
361
+ children: [y("span", { children: e instanceof Error ? e.message : String(e) }), t ? y("button", {
362
+ type: "button",
363
+ onClick: t,
364
+ children: n("scriptEditor.retry")
365
+ }) : null]
366
+ });
367
+ }, O = ee(D.load, { renderError: (e) => y(pe, { error: e }) }), k = ["define", "require"], me = !1, A = "@0.8.0-beta.3";
368
+ A !== "@local" && A !== "@0.0.0" || (A = "");
369
+ var j = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${A}/types/scripting.d.ts`, M = (e) => {
349
370
  try {
350
- e.languages.setMonarchTokensProvider("typescript", S);
371
+ e.languages.setMonarchTokensProvider("typescript", w);
351
372
  } catch {}
352
- }, O = !1;
353
- function pe(e, t) {
373
+ }, N = !1;
374
+ function he(e, t) {
354
375
  let n = null, r = e.length;
355
376
  for (let i = 0; !n && i < r; i++) {
356
377
  let r = e[i];
@@ -358,47 +379,47 @@ function pe(e, t) {
358
379
  }
359
380
  return n ? n.getContext() : "formula";
360
381
  }
361
- function k(e, t, n, r, i = []) {
382
+ function P(e, t, n, r, i = []) {
362
383
  if (r.kind === "function" && r.kindModifiers === "export") {
363
384
  let t = r.spans[0].start, a = e.getPositionAt(t);
364
385
  i.push({
365
386
  name: r.text,
366
- type: pe(n, r),
387
+ type: he(n, r),
367
388
  lineNumber: a.lineNumber
368
389
  });
369
390
  }
370
- if (r.childItems) for (let a of r.childItems) k(e, t, n, a, i);
391
+ if (r.childItems) for (let a of r.childItems) P(e, t, n, a, i);
371
392
  return i;
372
393
  }
373
- function A(e, t, n = "function", r) {
394
+ function F(e, t, n = "function", r) {
374
395
  let i = e.spans, a = i.length;
375
396
  for (let o = 0; o < a; o++) {
376
397
  let a = i[o];
377
398
  if (a.start <= t && t < a.start + a.length) {
378
399
  if (e.kind === n && (!r || e.kindModifiers === r)) return e;
379
400
  for (let i of e.childItems || []) {
380
- let e = A(i, t, n, r);
401
+ let e = F(i, t, n, r);
381
402
  if (e) return e;
382
403
  }
383
404
  }
384
405
  return null;
385
406
  }
386
407
  }
387
- function me(e) {
408
+ function ge(e) {
388
409
  return e.kind === "comment";
389
410
  }
390
- var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { current: null }, L = (e, t) => {
391
- M = {
411
+ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { current: null }, U = (e, t) => {
412
+ L = {
392
413
  editor: e,
393
414
  monaco: t
394
- }, N && (P = N(e, t));
395
- }, _e = (e) => {
396
- F || (F = !0, e.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
415
+ }, R && (z = R(e, t));
416
+ }, ve = (e) => {
417
+ V || (V = !0, e.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
397
418
  noSemanticValidation: !0,
398
419
  noSyntaxValidation: !1,
399
420
  diagnosticCodesToIgnore: [2307]
400
- }), e.languages.typescript.typescriptDefaults.setEagerModelSync(!0), e.languages.json.jsonDefaults.setDiagnosticsOptions({ validate: !0 }), D(e), ((e) => {
401
- O || (O = !0, e.languages.registerCompletionItemProvider("typescript", {
421
+ }), e.languages.typescript.typescriptDefaults.setEagerModelSync(!0), e.languages.json.jsonDefaults.setDiagnosticsOptions({ validate: !0 }), M(e), ((e) => {
422
+ N || (N = !0, e.languages.registerCompletionItemProvider("typescript", {
402
423
  triggerCharacters: ["@"],
403
424
  provideCompletionItems: (t, n) => {
404
425
  let r = t.getValueInRange({
@@ -475,7 +496,7 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
475
496
  }), (async () => {
476
497
  let t = !1;
477
498
  try {
478
- let n = await (async () => await (await fetch(E)).text())(), r = e.Uri.parse("inmemory://model/\"sheetxl-models\".d.ts"), i = e.editor.getModel(r);
499
+ let n = await (async () => await (await fetch(j)).text())(), r = e.Uri.parse("inmemory://model/\"sheetxl-models\".d.ts"), i = e.editor.getModel(r);
479
500
  i ? t = !0 : i = e.editor.createModel(n, "typescript", r), e.editor.setModelMarkers(i, "default", []);
480
501
  } catch (e) {
481
502
  console.warn("cant load types", e);
@@ -493,7 +514,7 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
493
514
  let p = d[d.length - 1];
494
515
  p !== "`" && p !== "'" && p !== "\"" || (c++, d = d.substring(0, d.length - 1));
495
516
  try {
496
- I.current?.getRanges(d) && r.push({
517
+ H.current?.getRanges(d) && r.push({
497
518
  range: {
498
519
  endColumn: l,
499
520
  endLineNumber: n,
@@ -511,7 +532,7 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
511
532
  } }), e.editor.registerLinkOpener({ open(e) {
512
533
  if (e?.path?.startsWith("/range/")) {
513
534
  try {
514
- I.current?.getRanges(e.path.substring(7))?.select();
535
+ H.current?.getRanges(e.path.substring(7))?.select();
515
536
  } catch (e) {
516
537
  console.warn("invalid range", e);
517
538
  }
@@ -528,6 +549,7 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
528
549
  "es2020",
529
550
  "esnext.asynciterable"
530
551
  ],
552
+ strict: !0,
531
553
  downlevelIteration: !0,
532
554
  moduleResolution: e.languages.typescript.ModuleResolutionKind.NodeJs,
533
555
  allowSyntheticDefaultImports: !0,
@@ -545,13 +567,13 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
545
567
  })();
546
568
  }
547
569
  })());
548
- }, ve = (e) => {
570
+ }, ye = (e) => {
549
571
  let t = !1, n = e ? e.length : 0;
550
572
  for (let r = 0; !t && r < n; r++) e[r].severity === 8 && (t = !0);
551
- }, ye = () => {
552
- let [e, n] = c(() => j.props);
553
- return a(() => (j && (j.setProps = n), () => {
554
- j && (j.setProps = null);
573
+ }, be = () => {
574
+ let [e, n] = s(() => I.props);
575
+ return i(() => (I && (I.setProps = n), () => {
576
+ I && (I.setProps = null);
555
577
  }), []), y("div", {
556
578
  style: {
557
579
  display: "flex",
@@ -559,88 +581,88 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
559
581
  width: "100%",
560
582
  height: "100%"
561
583
  },
562
- children: y(t, { children: y(de, {
584
+ children: y(t, { children: y(O, {
563
585
  theme: e.theme,
564
586
  options: e.options,
565
587
  language: "typescript",
566
588
  value: e.value,
567
589
  onValidate: e.onValidate,
568
590
  beforeMount: e.beforeMount,
569
- onMount: L
591
+ onMount: U
570
592
  }) })
571
593
  });
572
- }, R = i(n((t, n) => {
573
- let { className: r, style: i, readOnly: l = !1, darkMode: m, loadingPanel: v, autoFocus: ie = !0, frame: b, scripts: x, onStatusChange: S, ...de } = t, T = ne(), E = s(null), [O, pe] = c(!1), F = ae(), [L] = ee(["insertFunction"]), [R, z] = c({
594
+ }, W = r(n((t, n) => {
595
+ let { className: r, style: c, readOnly: f = !1, darkMode: m, loadingPanel: h, autoFocus: ee = !0, frame: v, scripts: b, onStatusChange: x, ...S } = t, C = ie(), w = o(null), [D, pe] = s(!1), O = se(), [A] = te(["insertFunction"]), [j, N] = s({
574
596
  message: "Loading",
575
597
  cursor: "",
576
598
  dirty: !1
577
- }), [be, B] = c({
599
+ }), [he, V] = s({
578
600
  loading: !1,
579
601
  compiling: !1,
580
602
  errors: [],
581
603
  warnings: []
582
- }), V = g((e) => {
583
- z((t) => {
604
+ }), U = _((e) => {
605
+ N((t) => {
584
606
  let n = {
585
607
  ...t,
586
608
  ...e
587
609
  };
588
- return d.deepEqual(n, t) ? t : (pe(n.dirty ?? !1), n);
610
+ return u.deepEqual(n, t) ? t : (pe(n.dirty ?? !1), n);
589
611
  });
590
- }, [S]);
591
- a(() => {
592
- S?.(R);
593
- }, [S, R]);
594
- let H = _(), xe = g(async (e) => {
612
+ }, [x]);
613
+ i(() => {
614
+ x?.(j);
615
+ }, [x, j]);
616
+ let W = re(), G = _(async (e) => {
595
617
  let t = null, n = null;
596
618
  try {
597
- e && (n = await H.showBusy(T("scriptEditor.saving")), t = await x.createModule({ source: e })), x.addModule("scripts", t, { replace: !0 }), n?.();
619
+ e && (n = await W.showBusy(C("scriptEditor.saving")), t = await b.createModule({ source: e })), b.addModule(fe(b), t, { replace: !0 }), n?.();
598
620
  } catch (e) {
599
- n?.(), console.warn("Unable to compile", e), H.showError(e);
621
+ n?.(), console.warn("Unable to compile", e), W.showError(e);
600
622
  }
601
623
  return t;
602
- }, [x]), U = g(async () => {
603
- if (!E.current) return;
604
- let e = E.current.editor, t;
605
- if (R.dirty) {
624
+ }, [b]), K = _(async () => {
625
+ if (!w.current || f) return;
626
+ let e = w.current.editor, t;
627
+ if (j.dirty) {
606
628
  let n = e.getValue();
607
- await xe(n), t = x.getModules().getByName("scripts");
629
+ await G(n), t = T(b);
608
630
  let r = t?.getSource(), i = e.getValue(), a = (r?.length ?? 0) !== n.length || r !== i;
609
- V({ dirty: a });
610
- } else t = x.getModules().getByName("scripts");
631
+ U({ dirty: a });
632
+ } else t = T(b);
611
633
  return t;
612
- }, [R, x]);
613
- a(() => {
614
- let e = b?.addListener({ onBeforeHide: async () => (await U(), !0) });
634
+ }, [j, b]);
635
+ i(() => {
636
+ let e = v?.addListener({ onBeforeHide: async () => (await K(), !0) });
615
637
  return () => {
616
638
  e?.();
617
639
  };
618
- }, [b]), a(() => {
619
- if (x) return x.addListeners({ onBeforeSearch: () => U() });
620
- }, [x]), re(F, {
640
+ }, [v]), i(() => {
641
+ if (b) return b.addListeners({ onBeforeSearch: () => K() });
642
+ }, [b]), oe(O, {
621
643
  onBeforeSave: async () => {
622
- await U();
644
+ await K();
623
645
  },
624
646
  onLoad: () => {
625
- let e = E.current?.editor;
626
- e && e.setValue(x?.getModules().getItems()[0]?.getSource() ?? "");
647
+ let e = w.current?.editor;
648
+ e && e.setValue(T(b)?.getSource() ?? "");
627
649
  }
628
650
  });
629
- let W = g(async (e) => {
630
- if (!x) return;
651
+ let q = _(async (e) => {
652
+ if (!b) return;
631
653
  let t = typeof e == "string" ? { functionName: e } : e ?? {}, n = null;
632
654
  if (t?.declaration || t?.functionName) {
633
655
  let e = t.declaration ? t.declaration.getName() : t.functionName;
634
- (await x.searchFunctions({ name: e })).length > 0 && (n = e);
656
+ (await b.searchFunctions({ name: e })).length > 0 && (n = e);
635
657
  }
636
658
  if (n) try {
637
- await x.executeMacro(n);
659
+ await b.executeMacro(n);
638
660
  } catch (e) {
639
- H.showError(e);
661
+ W.showError(e);
640
662
  }
641
- }, [x, H]), [G, Se] = c(!1), Ce = g(async () => {
642
- if (!E.current) return null;
643
- let e = E.current, t = e.editor;
663
+ }, [b, W]), [J, xe] = s(!1), Se = _(async () => {
664
+ if (!w.current) return null;
665
+ let e = w.current, t = e.editor;
644
666
  if (!t) return null;
645
667
  let n = await (async (e, t, n = "export") => {
646
668
  let r = e.getModel();
@@ -649,7 +671,7 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
649
671
  if (!o) return null;
650
672
  let s = o.startLineNumber === o.endLineNumber && o.startColumn === o.endColumn ? r.getLineCount() : Math.min(o.endLineNumber, r.getLineCount());
651
673
  for (let e = o.startLineNumber; !a && e <= s; e++) {
652
- let t = A(i, r.getOffsetAt({
674
+ let t = F(i, r.getOffsetAt({
653
675
  lineNumber: e,
654
676
  column: 1
655
677
  }), "function", n);
@@ -657,25 +679,25 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
657
679
  }
658
680
  return a;
659
681
  })(t, e.monaco);
660
- return V({ message: (n ?? "").toUpperCase() }), n ? {
682
+ return U({ message: (n ?? "").toUpperCase() }), n ? {
661
683
  source: t.getValue(),
662
684
  name: n
663
685
  } : null;
664
686
  }, []);
665
- g(f.debounce(U, 200), []);
666
- let we = g(async (e, t, n) => {
667
- B((e) => ({
687
+ _(d.debounce(K, 200), []);
688
+ let Ce = _(async (e, t, n) => {
689
+ V((e) => ({
668
690
  ...e,
669
691
  compiling: !0
670
692
  }));
671
693
  let r = null;
672
694
  try {
673
- if (r = await x.createModule({
695
+ if (r = await b.createModule({
674
696
  source: n?.getValue(),
675
697
  declarationsOnly: !0
676
698
  }), !r) return;
677
699
  } catch {}
678
- let i = r ? r.getDiagnostics() : d.EmptyArray;
700
+ let i = r ? r.getDiagnostics() : u.EmptyArray;
679
701
  (function(e, t, n) {
680
702
  let r = (n ?? []).map((n) => {
681
703
  let r = e.getPositionAt(n.start), i = e.getPositionAt(n.start + Math.max(n.length, 1));
@@ -691,9 +713,9 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
691
713
  });
692
714
  t.editor.setModelMarkers(e, "sheetxl", r);
693
715
  })(e, t, i), async function(e, t, n, r) {
694
- let i = k(e, t, r, await (await (await t.languages.typescript.getTypeScriptWorker())(e.uri)).getNavigationTree(e.uri.toString())).map((e) => {
716
+ let i = P(e, t, r, await (await (await t.languages.typescript.getTypeScriptWorker())(e.uri)).getNavigationTree(e.uri.toString())).map((e) => {
695
717
  let n = null, r = null;
696
- return e.type === "formula" ? (n = "formula.margin-icon", r = T("scriptEditor.glyph.formula")) : e.type === "macro" ? (n = "macro.margin-icon", r = T("scriptEditor.glyph.macro")) : e.type === "autoRun" && (n = "autorun.margin-icon", r = T("scriptEditor.glyph.autoRun")), {
718
+ return e.type === "formula" ? (n = "formula.margin-icon", r = C("scriptEditor.glyph.formula")) : e.type === "macro" ? (n = "macro.margin-icon", r = C("scriptEditor.glyph.macro")) : e.type === "autoRun" && (n = "autorun.margin-icon", r = C("scriptEditor.glyph.autoRun")), {
697
719
  range: new t.Range(e.lineNumber, 1, e.lineNumber, 1),
698
720
  options: {
699
721
  isWholeLine: !1,
@@ -703,33 +725,33 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
703
725
  }
704
726
  };
705
727
  });
706
- J.current && J.current.clear(), J.current = n.createDecorationsCollection(i);
707
- }(e, t, n, r ? r.getFunctions().getItems() : d.EmptyArray), B((e) => ({
728
+ Z.current && Z.current.clear(), Z.current = n.createDecorationsCollection(i);
729
+ }(e, t, n, r ? r.getFunctions().getItems() : u.EmptyArray), V((e) => ({
708
730
  ...e,
709
731
  compiling: !1,
710
732
  errors: i.filter((e) => e.severity === "error").map((e) => `${e.code}: ${e.message}`),
711
733
  warnings: i.filter((e) => e.severity === "warning").map((e) => `${e.code}: ${e.message}`)
712
734
  }));
713
- }, [x]), K = g(f.debounce(we, 580), []), q = g(async (e) => {
714
- if (!E.current) return;
715
- let t = E.current.editor.getPosition(), n = { cursor: t ? t.toString() : "" };
716
- e !== void 0 && (n.message = e), V(n);
735
+ }, [b]), Y = _(d.debounce(Ce, 580), []), X = _(async (e) => {
736
+ if (!w.current) return;
737
+ let t = w.current.editor.getPosition(), n = { cursor: t ? t.toString() : "" };
738
+ e !== void 0 && (n.message = e), U(n);
717
739
  }, []);
718
- a(() => {}, [be]);
719
- let Te = s(null), Ee = g(async () => {
720
- await U(), b?.close();
721
- }, [b]), De = g((e) => {
722
- let t = E.current?.editor;
740
+ i(() => {}, [he]);
741
+ let we = o(null), Te = _(async () => {
742
+ await K(), v?.close();
743
+ }, [v]), Ee = _((e) => {
744
+ let t = w.current?.editor;
723
745
  return !!t && (t.focus(e), !0);
724
- }, [R]), Oe = g(async () => {
725
- let e = E.current?.editor, t = e?.getModel(), n = e?.getSelection();
746
+ }, [j]), De = _(async () => {
747
+ let e = w.current?.editor, t = e?.getModel(), n = e?.getSelection();
726
748
  if (!t || !n) return;
727
749
  let r = n.isEmpty() ? t.getLineContent(n.positionLineNumber) + "\n" : t.getValueInRange(n);
728
750
  try {
729
751
  await navigator.clipboard?.writeText(r);
730
752
  } catch {}
731
- }, []), ke = g(async () => {
732
- let e = E.current, t = e?.editor, n = t?.getModel(), r = t?.getSelection();
753
+ }, []), Oe = _(async () => {
754
+ let e = w.current, t = e?.editor, n = t?.getModel(), r = t?.getSelection();
733
755
  if (!n || !r) return;
734
756
  let i = r.isEmpty() ? new e.monaco.Range(r.positionLineNumber, 1, r.positionLineNumber + 1, 1) : r, a = n.getValueInRange(i);
735
757
  try {
@@ -742,8 +764,8 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
742
764
  text: "",
743
765
  forceMoveMarkers: !0
744
766
  }]), t.pushUndoStop(), t.focus();
745
- }, []), Ae = g(async () => {
746
- let e = E.current?.editor;
767
+ }, []), ke = _(async () => {
768
+ let e = w.current?.editor;
747
769
  if (!e) return;
748
770
  let t;
749
771
  try {
@@ -758,16 +780,16 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
758
780
  text: t,
759
781
  forceMoveMarkers: !0
760
782
  }]), e.pushUndoStop(), e.focus();
761
- }, []), J = s(null), je = g((t, n) => {
762
- E.current = {
783
+ }, []), Z = o(null), Ae = _((t, n) => {
784
+ w.current = {
763
785
  monaco: n,
764
786
  editor: t
765
- }, I.current = F ?? null;
787
+ }, H.current = O ?? null;
766
788
  let r = t.getModel(), i = [];
767
- Se(!0);
768
- let a = x?.getModules().getItems()[0]?.getSource() ?? "";
769
- return t.getValue() !== a && t.setValue(a), he ? (q(""), K(r, n, t), D(n)) : (he = !0, q("Loading Types"), import("./Cls8yeIK4VLB6jx7.mjs").then((t) => e(t.default, 1)).then(async (e) => {
770
- q(""), e.AutoTypings.create(t, {
789
+ xe(!0);
790
+ let a = T(b)?.getSource() ?? "";
791
+ return t.getValue() !== a && t.setValue(a), B ? (X(""), Y(r, n, t), M(n)) : (B = !0, X("Loading Types"), import("./CeNZ9Uv3ijh9YRlu.mjs").then((t) => e(t.default, 1)).then(async (e) => {
792
+ X(""), e.AutoTypings.create(t, {
771
793
  shareCache: !0,
772
794
  dontAdaptEditorOptions: !0,
773
795
  monaco: n,
@@ -784,8 +806,8 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
784
806
  e === "Not implemented yet" && (e = "Compile Errors"), console.warn("Error compiling types", e);
785
807
  }
786
808
  }).then((e) => {
787
- Te.current = e, K(t.getModel(), n, t), (() => {
788
- if (fe) return;
809
+ we.current = e, Y(t.getModel(), n, t), (() => {
810
+ if (me) return;
789
811
  let e = (e, t) => {
790
812
  try {
791
813
  if (t === void 0) try {
@@ -797,15 +819,17 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
797
819
  }
798
820
  else globalThis[e] = t;
799
821
  } catch {}
800
- }, t = w.length;
822
+ }, t = k.length;
801
823
  for (let n = 0; n < t; n++) {
802
- let t = w[n];
803
- e(t, C[t]);
824
+ let t = k[n];
825
+ e(t, E[t]);
804
826
  }
805
- C = void 0, fe = !0;
806
- })(), D(n);
827
+ E = void 0, me = !0;
828
+ })(), M(n);
807
829
  });
808
- })), ge || (ge = !0, function(e, t) {
830
+ }).catch((e) => {
831
+ B = !1, X(""), console.warn("Auto typings could not be loaded:", e);
832
+ })), _e || (_e = !0, function(e, t) {
809
833
  t.languages.registerInlayHintsProvider("typescript", { provideInlayHints(e, n, r) {
810
834
  let i = [];
811
835
  for (let n = 1; n < e.getLineCount() + 1; n++) {
@@ -834,109 +858,109 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
834
858
  label: "Execute",
835
859
  keybindings: [n.KeyCode.F8],
836
860
  run: async (e) => {
837
- let t = await Ce();
838
- W(t);
861
+ let t = await Se();
862
+ q(t);
839
863
  }
840
864
  })), i.push(t.addAction({
841
865
  id: "saveScript",
842
866
  label: "Save Script",
843
867
  keybindings: [n.KeyMod.CtrlCmd | n.KeyCode.KeyS],
844
868
  run: (e) => {
845
- U();
869
+ K();
846
870
  }
847
871
  })), i.push(t.onMouseDown(async (e) => {
848
872
  if (e.target.type === n.editor.MouseTargetType.GUTTER_GLYPH_MARGIN) {
849
873
  e.event.browserEvent.preventDefault();
850
- let t = e.target.position.lineNumber, i = await (await (await n.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), a = await U();
874
+ let t = e.target.position.lineNumber, i = await (await (await n.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), a = await K();
851
875
  if (!a) return;
852
- let o = a.getFunctions().getItems(), s = k(r, n, o, i).find((e) => e.lineNumber === t);
876
+ let o = a.getFunctions().getItems(), s = P(r, n, o, i).find((e) => e.lineNumber === t);
853
877
  if (s) {
854
878
  let t = e.event.browserEvent.button;
855
879
  if (t === 0) {
856
- if (s.type === "macro" || s.type === "autoRun") W({ functionName: s.name });
880
+ if (s.type === "macro" || s.type === "autoRun") q({ functionName: s.name });
857
881
  else if (s.type === "formula") {
858
882
  let e = o?.find((e) => e.getName() === s.name);
859
- e && L?.execute(e);
883
+ e && A?.execute(e);
860
884
  }
861
885
  } else t === 2 && (console.log("Context menu for function:", s.name), e.event.browserEvent.preventDefault());
862
886
  }
863
887
  }
864
888
  })), i.push(t.onDidChangeModelContent(() => {
865
- V({ dirty: !0 }), K(r, n, t);
889
+ U({ dirty: !0 }), Y(r, n, t);
866
890
  })), i.push(n.editor.onDidChangeMarkers((e) => {
867
891
  e.some((e) => e.toString() === r.uri.toString());
868
892
  })), i.push(r.onDidChangeContent((e) => {
869
- let n = x.getModules().getByName("scripts")?.getSource(), r = t.getValue(), i = (n?.length ?? 0) !== r.length || n !== r;
870
- V({ dirty: i });
893
+ let n = T(b)?.getSource(), r = t.getValue(), i = (n?.length ?? 0) !== r.length || n !== r;
894
+ U({ dirty: i });
871
895
  })), i.push(t.onDidChangeCursorPosition((e) => {
872
- q();
896
+ X();
873
897
  })), () => {
874
898
  for (let e of i) try {
875
899
  e.dispose();
876
900
  } catch {}
877
901
  };
878
- }, [x, F]), Me = o(() => G ? null : v || y("div", {
902
+ }, [b, O]), je = a(() => J ? null : h || y("div", {
879
903
  style: {
880
904
  position: "absolute",
881
905
  width: "100%",
882
906
  height: "100%"
883
907
  },
884
- children: T("scriptEditor.loading")
885
- }), [G, v]), Y = o(() => ({
886
- ...le,
908
+ children: C("scriptEditor.loading")
909
+ }), [J, h]), Me = a(() => ({
910
+ ...ue,
887
911
  fixedOverflowWidgets: !1,
888
912
  contextmenu: !1,
889
- readOnly: l
890
- }), [l]), X = s(null);
891
- a(() => {
913
+ readOnly: f
914
+ }), [f]), Ne = o(null);
915
+ i(() => {
892
916
  let e = {
893
917
  theme: m ? "extended-dark" : "extended",
894
- options: Y,
895
- value: x?.getModules()?.getByName("scripts")?.getSource() ?? "",
896
- beforeMount: _e,
897
- onValidate: ve
918
+ options: Me,
919
+ value: T(b)?.getSource() ?? "",
920
+ beforeMount: ve,
921
+ onValidate: ye
898
922
  }, t = ((e) => {
899
- if (j) return j;
900
- if (!C) {
901
- C = {};
902
- let e = w.length;
923
+ if (I) return I;
924
+ if (!E) {
925
+ E = {};
926
+ let e = k.length;
903
927
  for (let t = 0; t < e; t++) {
904
- let e = w[t];
905
- C[e] = globalThis[e];
928
+ let e = k[t];
929
+ E[e] = globalThis[e];
906
930
  }
907
931
  }
908
932
  let t = document.createElement("div");
909
933
  t.style.display = "none";
910
934
  let n = document.createElement("div");
911
935
  n.style.width = "100%", n.style.height = "100%", n.style.display = "flex", n.style.flex = "1 1 100%", t.appendChild(n), document.body.appendChild(t);
912
- let r = u(n);
913
- return j = {
936
+ let r = l(n);
937
+ return I = {
914
938
  root: r,
915
939
  hostEl: n,
916
940
  stashEl: t,
917
941
  props: e,
918
942
  setProps: null
919
- }, r.render(y(ye, {})), j;
943
+ }, r.render(y(be, {})), I;
920
944
  })(e);
921
- return t.props = e, t.setProps?.(e), N = (e, t) => je(e, t), X.current?.appendChild(t.hostEl), M && (P = je(M.editor, M.monaco)), () => {
922
- P?.(), P = null, N = null, E.current = null, j?.stashEl.appendChild(j.hostEl);
945
+ return t.props = e, t.setProps?.(e), R = (e, t) => Ae(e, t), Ne.current?.appendChild(t.hostEl), L && (z = Ae(L.editor, L.monaco)), () => {
946
+ z?.(), z = null, R = null, w.current = null, I?.stashEl.appendChild(I.hostEl);
923
947
  };
924
- }, []), a(() => {
925
- if (!j) return;
948
+ }, []), i(() => {
949
+ if (!I) return;
926
950
  let e = {
927
- ...j.props,
951
+ ...I.props,
928
952
  theme: m ? "extended-dark" : "extended",
929
- options: Y
953
+ options: Me
930
954
  };
931
- j.props = e, j.setProps?.(e);
932
- }, [m, Y]), a(() => {
933
- let e = E.current, t = e?.editor;
955
+ I.props = e, I.setProps?.(e);
956
+ }, [m, Me]), i(() => {
957
+ let e = w.current, t = e?.editor;
934
958
  if (!t) return;
935
- I.current = F ?? null;
936
- let n = x?.getModules().getItems()[0]?.getSource() ?? "";
937
- t.getValue() !== n && (t.setValue(n), K(t.getModel(), e.monaco, t), V({ dirty: !1 }));
938
- }, [x, F]);
939
- let Ne = oe("div", {
959
+ H.current = O ?? null;
960
+ let n = T(b)?.getSource() ?? "";
961
+ t.getValue() !== n && (t.setValue(n), Y(t.getModel(), e.monaco, t), U({ dirty: !1 }));
962
+ }, [b, O]);
963
+ let Pe = ae("div", {
940
964
  style: {
941
965
  display: "flex",
942
966
  flex: "1 1 100%",
@@ -946,36 +970,36 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
946
970
  boxSizing: "border-box"
947
971
  },
948
972
  children: [y("div", {
949
- ref: X,
973
+ ref: Ne,
950
974
  style: {
951
975
  display: "flex",
952
976
  flex: "1 1 100%",
953
977
  width: "100%",
954
978
  position: "relative"
955
979
  }
956
- }), Me]
957
- }), Z = te(n, () => ({
980
+ }), je]
981
+ }), Q = ne(n, () => ({
958
982
  isScriptEditorElement: () => !0,
959
983
  showCommandPalette: () => {
960
- E.current?.editor && E.current.editor.trigger("keyboard", "editor.action.quickCommand", null);
984
+ w.current?.editor && w.current.editor.trigger("keyboard", "editor.action.quickCommand", null);
961
985
  },
962
- getScripts: () => x,
986
+ getScripts: () => b,
963
987
  focus: (e) => {
964
- De(e);
988
+ Ee(e);
965
989
  },
966
- close: () => Ee(),
967
- insertSnippet: (e) => E.current?.editor ? (async (e, t, n) => {
990
+ close: () => Te(),
991
+ insertSnippet: (e) => w.current?.editor ? (async (e, t, n) => {
968
992
  let r = e.getModel();
969
993
  if (!r) return;
970
994
  let i = await (await (await t.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), a = e.getPosition(), o = { ...a };
971
995
  o.lineNumber = 1, o.column = 1;
972
996
  let s = !1;
973
997
  for (let e = a.lineNumber; e >= 1; e--) if (r.getLineContent(e).trim() === "") {
974
- let t = A(i, r.getOffsetAt({
998
+ let t = F(i, r.getOffsetAt({
975
999
  lineNumber: e,
976
1000
  column: 1
977
1001
  }), "function");
978
- if (!t || me(t)) {
1002
+ if (!t || ge(t)) {
979
1003
  s = !0, o.lineNumber = e + 1;
980
1004
  break;
981
1005
  }
@@ -998,22 +1022,22 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
998
1022
  endLineNumber: f.startLineNumber,
999
1023
  endColumn: f.startColumn
1000
1024
  });
1001
- })(E.current.editor, E.current.monaco, e) : Promise.resolve(),
1025
+ })(w.current.editor, w.current.monaco, e) : Promise.resolve(),
1002
1026
  saveSource: async () => {
1003
- await U();
1027
+ await K();
1004
1028
  },
1005
1029
  runAction: (e) => {
1006
- let t = E.current?.editor;
1030
+ let t = w.current?.editor;
1007
1031
  t && (t.focus(), t.trigger("source", e, null));
1008
1032
  },
1009
- copy: () => Oe(),
1010
- cut: () => ke(),
1011
- paste: () => Ae()
1012
- }), [F]), [Q, Pe] = c(null), Fe = g((e) => {
1013
- e !== null && Pe(e);
1014
- }, []), $ = h.useCommandScope();
1015
- return a(() => {
1016
- if (!$ || !Q) return;
1033
+ copy: () => De(),
1034
+ cut: () => Oe(),
1035
+ paste: () => ke()
1036
+ }), [O]), [Fe, Ie] = s(null), Le = _((e) => {
1037
+ e !== null && Ie(e);
1038
+ }, []), $ = g.useCommandScope();
1039
+ return i(() => {
1040
+ if (!$ || !Fe) return;
1017
1041
  let e = $.contribution();
1018
1042
  return function(e, t) {
1019
1043
  let n = t.scriptEditor, r = t;
@@ -1021,45 +1045,52 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
1021
1045
  window?.open("https://www.sheetxl.com/docs/guides/concepts/scripting");
1022
1046
  } }), e.updateCommand("showScriptingCommands", { callback: () => {
1023
1047
  n.showCommandPalette();
1024
- } }), e.updateCommand("insertScript", { callback: (e) => n.insertSnippet(e ?? "") }), e.updateCommand("saveScripts", {
1025
- disabledReasons: r?.isDirty ? [] : [p("reason.noChangesToSave")],
1048
+ } });
1049
+ let i = r?.readOnly ? [p("reason.scriptsReadOnly")] : [];
1050
+ e.updateCommand("insertScript", {
1051
+ disabledReasons: i,
1052
+ callback: (e) => n.insertSnippet(e ?? "")
1053
+ }), e.updateCommand("saveScripts", {
1054
+ disabledReasons: [...i, ...r?.isDirty ? [] : [p("reason.noChangesToSave")]],
1026
1055
  callback: async () => {
1027
1056
  await n.saveSource();
1028
1057
  }
1029
1058
  }), e.updateCommand("copy", { callback: () => n.copy() }), e.updateCommand("cut", { callback: () => n.cut() }), e.updateCommand("paste", { callback: () => n.paste() }), e.updateCommand("selectAll", { callback: () => n.runAction("editor.action.selectAll") }), e.updateCommand("find", { callback: () => n.runAction("actions.find") }), e.updateCommand("findReplace", { callback: () => n.runAction("editor.action.startFindReplaceAction") }), e.updateCommand("goto", { callback: () => n.runAction("editor.action.gotoLine") });
1030
1059
  }(e, {
1031
- scriptEditor: Q,
1032
- isDirty: O
1060
+ scriptEditor: Fe,
1061
+ isDirty: D,
1062
+ readOnly: f
1033
1063
  }), () => {
1034
1064
  e.remove();
1035
1065
  };
1036
1066
  }, [
1037
1067
  $,
1038
- Q,
1039
- O
1040
- ]), a(() => (ie && requestAnimationFrame(() => {
1041
- Z.current?.focus();
1068
+ Fe,
1069
+ D,
1070
+ f
1071
+ ]), i(() => (ee && requestAnimationFrame(() => {
1072
+ Q.current?.focus();
1042
1073
  }), () => {
1043
- E.current?.editor && requestAnimationFrame(() => {
1044
- Z.current?.contains(document.activeElement) && Z.current?.focus();
1074
+ w.current?.editor && requestAnimationFrame(() => {
1075
+ Q.current?.contains(document.activeElement) && Q.current?.focus();
1045
1076
  });
1046
1077
  }), []), y("div", {
1047
- className: se("script-editor", ue, r),
1078
+ className: ce("script-editor", de, r),
1048
1079
  style: {
1049
1080
  display: "flex",
1050
1081
  flexDirection: "row",
1051
1082
  flex: "1 1 100%",
1052
1083
  position: "relative",
1053
- ...i
1084
+ ...c
1054
1085
  },
1055
- ref: ce([Z, Fe]),
1056
- ...de,
1057
- children: Ne
1086
+ ref: le([Q, Le]),
1087
+ ...S,
1088
+ children: Pe
1058
1089
  });
1059
- })), z = null, be = (e) => {
1060
- z = e;
1061
- }, B = () => z, V = i((e) => {
1062
- let { scope: t, data: n } = e, { workbook: r } = n, i = _(), o = ie(), s = o.getOpen(), c = g(async (e) => {
1090
+ })), G = null, K = (e) => {
1091
+ G = e;
1092
+ }, q = () => G, J = r((e) => {
1093
+ let { scope: t, data: n } = e, { workbook: r } = n, a = re(), o = x(), s = o.getOpen(), c = _(async (e) => {
1063
1094
  if (!r) return;
1064
1095
  let t = null, n = r.getScripts();
1065
1096
  if (e?.declaration || e?.functionName) {
@@ -1069,14 +1100,14 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
1069
1100
  if (t) try {
1070
1101
  await n.executeMacro(t);
1071
1102
  } catch (e) {
1072
- i.showError(e);
1103
+ a.showError(e);
1073
1104
  return;
1074
1105
  }
1075
- }, [r, i]), l = g(() => {
1076
- let e = B();
1106
+ }, [r, a]), l = _(() => {
1107
+ let e = q();
1077
1108
  e ? r && e({ workbook: r }) : o.getOpen().includes("scriptEditor") ? o.close("scriptEditor") : o.activate("scriptEditor", {});
1078
1109
  }, [r, o]), u = s.includes("scriptEditor");
1079
- return a(() => {
1110
+ return i(() => {
1080
1111
  if (!t) return;
1081
1112
  let e = t.contribution();
1082
1113
  return e.updateCommand("showScriptEditor", {
@@ -1093,19 +1124,21 @@ var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { curr
1093
1124
  r,
1094
1125
  c,
1095
1126
  l
1096
- ]), re(r, { onLoad: () => {
1127
+ ]), oe(r, { onLoad: () => {
1097
1128
  r?.getScripts().start();
1098
1129
  } }), null;
1099
1130
  });
1100
- V.displayName = "WorkbookScriptCommands";
1101
- var H = {
1131
+ J.displayName = "WorkbookScriptCommands";
1132
+ var xe = {
1102
1133
  "reason.noChangesToSave": "No changes to save",
1134
+ "reason.scriptsReadOnly": "Scripts can't be changed while the workbook structure is protected.",
1103
1135
  "scriptEditor.glyph.autoRun": "Auto Run",
1104
1136
  "scriptEditor.glyph.formula": "Formula",
1105
1137
  "scriptEditor.glyph.macro": "Macro",
1106
1138
  "scriptEditor.loading": "Loading...",
1139
+ "scriptEditor.retry": "Retry",
1107
1140
  "scriptEditor.saving": "Saving Scripts..."
1108
- }, xe = [
1141
+ }, Se = [
1109
1142
  {
1110
1143
  sourceId: "groups",
1111
1144
  catalog: {
@@ -1187,29 +1220,29 @@ var H = {
1187
1220
  }
1188
1221
  }
1189
1222
  }
1190
- ], { DefaultCommandCatalogService: U } = h, W = !1, G = (e) => {
1223
+ ], { DefaultCommandCatalogService: Ce } = g, Y = !1, X = (e) => {
1191
1224
  let { model: t, entryKey: n, frame: r, ref: i, ...a } = e;
1192
- return y(R, {
1225
+ return y(W, {
1193
1226
  ref: i,
1194
1227
  frame: r,
1195
1228
  scripts: t?.getScripts(),
1196
1229
  ...a
1197
1230
  });
1198
- }, Se = () => {
1199
- v.registerTaskPane({
1231
+ }, we = () => {
1232
+ b.registerTaskPane({
1200
1233
  key: "scriptEditor",
1201
1234
  getTitle: () => "Script (Typescript)",
1202
1235
  getIcon: () => "ScriptRun",
1203
- component: G,
1236
+ component: X,
1204
1237
  keepMounted: !0
1205
1238
  }, !0), function() {
1206
- if (W) return;
1207
- W = !0;
1208
- let e = U;
1239
+ if (Y) return;
1240
+ Y = !0;
1241
+ let e = Ce;
1209
1242
  e.registerFromManifest("@sheetxl/scripting-react", import.meta.url, {
1210
- messages: H,
1211
- catalogs: xe
1243
+ messages: xe,
1244
+ catalogs: Se
1212
1245
  }), e.prefetch();
1213
- }(), h.DefaultCommandRegistry.registerDynamic("workbook", V);
1246
+ }(), g.DefaultCommandRegistry.registerDynamic("workbook", J);
1214
1247
  };
1215
- export { R as ScriptEditor, Se as ScriptingReactPlugin, V as WorkbookScriptCommands, B as getScriptEditorOpener, be as setScriptEditorOpener };
1248
+ export { W as ScriptEditor, we as ScriptingReactPlugin, J as WorkbookScriptCommands, q as getScriptEditorOpener, K as setScriptEditorOpener };