@poe-platform/safe-bash 0.1.749 → 0.1.751

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.
@@ -1425,6 +1425,11 @@ init_platform();
1425
1425
 
1426
1426
  // packages/safe-bash/src/commands/time-env/shared.ts
1427
1427
  init_platform();
1428
+ var defaultSleepScheduler = {
1429
+ now: () => performance.now(),
1430
+ setTimeout: (callback, milliseconds) => setTimeout(callback, milliseconds),
1431
+ clearTimeout: (handle) => clearTimeout(handle)
1432
+ };
1428
1433
  function settings2(options) {
1429
1434
  const limits = {
1430
1435
  maxArguments: Infinity,
@@ -1441,11 +1446,7 @@ function settings2(options) {
1441
1446
  if (maxTimerMilliseconds !== Infinity && (!Number.isInteger(maxTimerMilliseconds) || maxTimerMilliseconds < 1 || maxTimerMilliseconds > 2147483647)) {
1442
1447
  throw new RangeError("maxTimerMilliseconds must be between 1 and 2147483647 or Infinity");
1443
1448
  }
1444
- const scheduler = options.scheduler ?? {
1445
- now: () => performance.now(),
1446
- setTimeout: (callback, milliseconds) => setTimeout(callback, milliseconds),
1447
- clearTimeout: (handle) => clearTimeout(handle)
1448
- };
1449
+ const scheduler = options.scheduler ?? defaultSleepScheduler;
1449
1450
  if (typeof scheduler.now !== "function" || typeof scheduler.setTimeout !== "function" || typeof scheduler.clearTimeout !== "function") {
1450
1451
  throw new TypeError("Invalid sleep scheduler");
1451
1452
  }
@@ -2065,6 +2066,7 @@ function prCommands(options = {}) {
2065
2066
  }
2066
2067
 
2067
2068
  export {
2069
+ defaultSleepScheduler,
2068
2070
  settings2 as settings,
2069
2071
  CommandFailure,
2070
2072
  checkSize,
@@ -2079,4 +2081,4 @@ export {
2079
2081
  createPrCommands,
2080
2082
  prCommands
2081
2083
  };
2082
- //# sourceMappingURL=chunk-4GK4FAT6.js.map
2084
+ //# sourceMappingURL=chunk-637A2MLA.js.map
@@ -1425,6 +1425,11 @@ init_platform();
1425
1425
 
1426
1426
  // packages/safe-bash/src/commands/time-env/shared.ts
1427
1427
  init_platform();
1428
+ var defaultSleepScheduler = {
1429
+ now: () => performance.now(),
1430
+ setTimeout: (callback, milliseconds) => setTimeout(callback, milliseconds),
1431
+ clearTimeout: (handle) => clearTimeout(handle)
1432
+ };
1428
1433
  function settings2(options) {
1429
1434
  const limits = {
1430
1435
  maxArguments: Infinity,
@@ -1441,11 +1446,7 @@ function settings2(options) {
1441
1446
  if (maxTimerMilliseconds !== Infinity && (!Number.isInteger(maxTimerMilliseconds) || maxTimerMilliseconds < 1 || maxTimerMilliseconds > 2147483647)) {
1442
1447
  throw new RangeError("maxTimerMilliseconds must be between 1 and 2147483647 or Infinity");
1443
1448
  }
1444
- const scheduler = options.scheduler ?? {
1445
- now: () => performance.now(),
1446
- setTimeout: (callback, milliseconds) => setTimeout(callback, milliseconds),
1447
- clearTimeout: (handle) => clearTimeout(handle)
1448
- };
1449
+ const scheduler = options.scheduler ?? defaultSleepScheduler;
1449
1450
  if (typeof scheduler.now !== "function" || typeof scheduler.setTimeout !== "function" || typeof scheduler.clearTimeout !== "function") {
1450
1451
  throw new TypeError("Invalid sleep scheduler");
1451
1452
  }
@@ -2065,6 +2066,7 @@ function prCommands(options = {}) {
2065
2066
  }
2066
2067
 
2067
2068
  export {
2069
+ defaultSleepScheduler,
2068
2070
  settings2 as settings,
2069
2071
  CommandFailure,
2070
2072
  checkSize,
@@ -52122,6 +52122,18 @@ function metadataNode(value3, charge) {
52122
52122
  }
52123
52123
  return visit(value3);
52124
52124
  }
52125
+ var richUnderlines = {
52126
+ none: "none",
52127
+ single: "single",
52128
+ double: "double",
52129
+ low: "singleAccounting",
52130
+ error: "single",
52131
+ "single-line": "single",
52132
+ "double-line": "double",
52133
+ "error-line": "single",
52134
+ singleAccounting: "singleAccounting",
52135
+ doubleAccounting: "doubleAccounting"
52136
+ };
52125
52137
  function writeRichString(value3, runs, xml2, charge, target = "cell") {
52126
52138
  charge?.(value3.length);
52127
52139
  const t2 = (text2) => xml2("t", text2.trim() !== text2 ? { "xml:space": "preserve" } : {}, escapeXlsx(encodeXlsxString(text2)));
@@ -52144,7 +52156,9 @@ function writeRichString(value3, runs, xml2, charge, target = "cell") {
52144
52156
  if (attrs.size !== void 0) properties += xml2("sz", { val: Number(attrs.size) / 1024 });
52145
52157
  if (typeof attrs.family === "string") properties += xml2("rFont", { val: encodeXlsxString(attrs.family) });
52146
52158
  if (typeof attrs.color === "string") properties += xml2("color", { rgb: "FF" + attrs.color.split("x").join("").toUpperCase() });
52147
- if (typeof attrs.underline === "string") properties += xml2("u", { val: attrs.underline === "low" ? "singleAccounting" : attrs.underline === "error" ? "single" : attrs.underline });
52159
+ if (typeof attrs.underline === "string") properties += xml2("u", {
52160
+ val: Object.hasOwn(richUnderlines, attrs.underline) ? richUnderlines[attrs.underline] : "none"
52161
+ });
52148
52162
  if (attrs.subscript || attrs.superscript) properties += xml2("vertAlign", { val: attrs.subscript ? "subscript" : "superscript" });
52149
52163
  result2 += xml2("r", {}, (properties || target === "comment" ? xml2("rPr", {}, properties) : "") + t2(decoder.decode(bytes.subarray(start, end2))));
52150
52164
  }
@@ -62907,6 +62921,40 @@ var BiffOutput = class {
62907
62921
  this.length += bytes.length;
62908
62922
  return at;
62909
62923
  }
62924
+ /** Keep tokens/elements intact; oversized UTF-16 array strings carry width flags. */
62925
+ continuedRecord(opcode, payload, boundaries, strings = []) {
62926
+ const at = this.length;
62927
+ let offset = 0, next = 0, stringIndex = 0;
62928
+ do {
62929
+ while (strings[stringIndex] && strings[stringIndex].end <= offset) stringIndex++;
62930
+ const continuedString = strings[stringIndex] && strings[stringIndex].start < offset;
62931
+ const prefix2 = continuedString ? 1 : 0;
62932
+ const maximum = Math.min(payload.length, offset + this.maximumRecord - prefix2);
62933
+ let end2 = maximum;
62934
+ if (boundaries && maximum < payload.length) {
62935
+ end2 = offset;
62936
+ while (next < boundaries.length && boundaries[next] <= maximum) end2 = boundaries[next++];
62937
+ let candidate = stringIndex;
62938
+ while (strings[candidate] && strings[candidate].end <= maximum) candidate++;
62939
+ const string = strings[candidate];
62940
+ if (string && string.end - string.start + 4 > this.maximumRecord && string.start < maximum && maximum < string.end) {
62941
+ const characterEnd = maximum - (maximum - string.start) % 2;
62942
+ if (characterEnd > string.start) end2 = Math.max(end2, characterEnd);
62943
+ }
62944
+ if (end2 <= offset) throw new SsconvertError("unsupported-feature", "Excel BIFF formula token is too large");
62945
+ }
62946
+ let part = payload.subarray(offset, end2);
62947
+ if (prefix2) {
62948
+ const continued = new Uint8Array(part.length + 1);
62949
+ continued[0] = 1;
62950
+ continued.set(part, 1);
62951
+ part = continued;
62952
+ }
62953
+ this.record(offset === 0 ? opcode : 60, part);
62954
+ offset = end2;
62955
+ } while (offset < payload.length);
62956
+ return at;
62957
+ }
62910
62958
  finish() {
62911
62959
  this.context.signal.throwIfAborted();
62912
62960
  const bytes = new Uint8Array(this.length);
@@ -75035,7 +75083,6 @@ var BiffFormulaWriter = class {
75035
75083
  macroNames = [];
75036
75084
  workbookIndices = /* @__PURE__ */ new Map();
75037
75085
  linkIndices = /* @__PURE__ */ new Map();
75038
- uniqueNameId = 0;
75039
75086
  relocations = [];
75040
75087
  externalBook(workbook) {
75041
75088
  let index2 = this.workbookIndices.get(workbook);
@@ -75156,6 +75203,11 @@ var BiffFormulaWriter = class {
75156
75203
  const relative = definition !== void 0;
75157
75204
  const root = definition ? parseNamedExpression(definition, this.book, parse3, () => this.context.signal.throwIfAborted()) : parse3(source, { sheet, row, column });
75158
75205
  const bytes = [], arrays = [], diagnostics = [];
75206
+ const tokenBoundaries = [], arrayBoundaries = [];
75207
+ const arrayStrings = [];
75208
+ const boundary = () => {
75209
+ if (bytes.length && tokenBoundaries.at(-1) !== bytes.length) tokenBoundaries.push(bytes.length);
75210
+ };
75159
75211
  let sheetLossReported = false;
75160
75212
  const relocations = [];
75161
75213
  const push = (part, target = bytes) => {
@@ -75198,12 +75250,14 @@ var BiffFormulaWriter = class {
75198
75250
  push([23]);
75199
75251
  push(biffString(text2, this.revision, this.context, 1));
75200
75252
  if (index2) push([8]);
75253
+ boundary();
75201
75254
  });
75202
75255
  if (chunks.length > 1) push([21]);
75203
75256
  }
75204
75257
  };
75205
75258
  const visit = (node3) => {
75206
75259
  this.context.signal.throwIfAborted();
75260
+ boundary();
75207
75261
  if (node3.kind === "literal") literal2(node3.value);
75208
75262
  else if (node3.kind === "omitted") push([22]);
75209
75263
  else if (node3.kind === "parentheses") {
@@ -75356,24 +75410,15 @@ var BiffFormulaWriter = class {
75356
75410
  push([28, 29]);
75357
75411
  return;
75358
75412
  }
75359
- if (node3.sheet !== void 0 && scope !== void 0) {
75360
- const data4 = new Uint8Array(this.revision === 8 ? 7 : 25), view2 = new DataView(data4.buffer);
75413
+ if (node3.sheet !== void 0 && scope !== void 0 && this.revision === 8) {
75414
+ const data4 = new Uint8Array(7), view2 = new DataView(data4.buffer);
75361
75415
  data4[0] = 89;
75362
75416
  const scopeIndex = this.book.sheets.indexOf(scope);
75363
- if (this.revision === 8) {
75364
- const externalIndex = this.sheetLink(void 0, scopeIndex, scopeIndex);
75365
- relocations.push({ offset: bytes.length + 1, index: externalIndex, kind: "sheet" });
75366
- view2.setUint16(1, externalIndex, true);
75367
- view2.setUint16(3, index2 + 1, true);
75368
- } else {
75369
- const externalIndex = current === scope ? this.book.sheets.length + 1 : scopeIndex;
75370
- view2.setInt16(1, -(externalIndex + 1), true);
75371
- view2.setUint16(9, 1, true);
75372
- view2.setUint16(11, index2 + 1, true);
75373
- view2.setUint16(19, 15, true);
75374
- view2.setUint32(21, ++this.uniqueNameId, true);
75375
- }
75376
- relocations.push({ offset: bytes.length + (this.revision === 8 ? 3 : 11), index: index2, kind: "name" });
75417
+ const externalIndex = this.sheetLink(void 0, scopeIndex, scopeIndex);
75418
+ relocations.push({ offset: bytes.length + 1, index: externalIndex, kind: "sheet" });
75419
+ view2.setUint16(1, externalIndex, true);
75420
+ view2.setUint16(3, index2 + 1, true);
75421
+ relocations.push({ offset: bytes.length + 3, index: index2, kind: "name" });
75377
75422
  push(data4);
75378
75423
  } else {
75379
75424
  const data4 = new Uint8Array(this.revision === 8 ? 5 : 15);
@@ -75431,12 +75476,15 @@ var BiffFormulaWriter = class {
75431
75476
  if (!columns || columns > 256 || node3.rows.length > 65536) throw new SsconvertError("unsupported-feature", "Excel BIFF array dimensions exceed limits");
75432
75477
  push([64, ...new Uint8Array(7)]);
75433
75478
  push([this.revision === 8 ? columns - 1 : columns & 255, ...words(node3.rows.length - (this.revision === 8 ? 1 : 0))], arrays);
75479
+ arrayBoundaries.push(arrays.length);
75434
75480
  for (const arrayRow of node3.rows) for (const item of arrayRow) {
75435
75481
  if (item.kind !== "literal") throw new SsconvertError("unsupported-feature", "Excel BIFF array requires literals");
75436
75482
  const value3 = item.value;
75437
75483
  if (value3.kind === "string") {
75484
+ const start = arrays.length + 4;
75438
75485
  push([2], arrays);
75439
75486
  push(biffString(value3.value, this.revision, this.context, this.revision === 8 ? 2 : 1), arrays);
75487
+ if (this.revision === 8 && arrays.length > start) arrayStrings.push({ start, end: arrays.length });
75440
75488
  } else {
75441
75489
  const data4 = new Uint8Array(9), view2 = new DataView(data4.buffer);
75442
75490
  data4[0] = value3.kind === "number" ? 1 : value3.kind === "boolean" ? 4 : value3.kind === "error" ? 16 : 0;
@@ -75445,15 +75493,23 @@ var BiffFormulaWriter = class {
75445
75493
  else if (value3.kind === "error") data4[1] = biffError(value3.value);
75446
75494
  push(data4, arrays);
75447
75495
  }
75496
+ arrayBoundaries.push(arrays.length);
75448
75497
  }
75449
75498
  }
75499
+ boundary();
75450
75500
  };
75451
75501
  visit(root);
75502
+ boundary();
75503
+ if (bytes.length > 65535)
75504
+ throw new SsconvertError("unsupported-feature", "Excel BIFF formula token length exceeds version limits");
75452
75505
  const tokens3 = new Uint8Array(bytes);
75453
75506
  for (const relocation of relocations) this.relocations.push({ ...relocation, tokens: tokens3 });
75454
75507
  return {
75455
75508
  tokens: tokens3,
75509
+ tokenBoundaries,
75456
75510
  arrays: new Uint8Array(arrays),
75511
+ arrayBoundaries,
75512
+ arrayStrings,
75457
75513
  diagnostics,
75458
75514
  nameDependencies: relocations.filter((relocation) => relocation.kind === "name").map((relocation) => relocation.index)
75459
75515
  };
@@ -76046,7 +76102,10 @@ async function writeBiffStream(book, revision2, dual, context2, filepass) {
76046
76102
  if (group) {
76047
76103
  formulas.set(cell, {
76048
76104
  tokens: new Uint8Array([dataTables.has(group) ? 2 : 1, ...words(group.range.startRow, group.range.startColumn)]),
76105
+ tokenBoundaries: [5],
76049
76106
  arrays: new Uint8Array(),
76107
+ arrayBoundaries: [],
76108
+ arrayStrings: [],
76050
76109
  diagnostics: [],
76051
76110
  nameDependencies: []
76052
76111
  });
@@ -76136,8 +76195,22 @@ async function writeBiffStream(book, revision2, dual, context2, filepass) {
76136
76195
  header4[3] = text2[0];
76137
76196
  view3.setUint16(4, formula3.tokens.length, true);
76138
76197
  const scope = name5.sheet === void 0 ? 0 : book.sheets.findIndex((sheet) => sheet.id === name5.sheet) + 1;
76139
- view3.setUint16(revision2 === 8 ? 8 : 6, scope, true);
76140
- output2.record(24, join(join(header4, text2.subarray(1)), join(formula3.tokens, formula3.arrays)));
76198
+ if (revision2 === 7 && scope) view3.setUint16(6, scope - 1, true);
76199
+ view3.setUint16(8, scope, true);
76200
+ const start = header4.length + text2.length - 1;
76201
+ output2.continuedRecord(
76202
+ 24,
76203
+ join(join(header4, text2.subarray(1)), join(formula3.tokens, formula3.arrays)),
76204
+ [
76205
+ start,
76206
+ ...formula3.tokenBoundaries.map((offset) => offset + start),
76207
+ ...formula3.arrayBoundaries.map((offset) => offset + start + formula3.tokens.length)
76208
+ ],
76209
+ formula3.arrayStrings.map((span2) => ({
76210
+ start: start + formula3.tokens.length + span2.start,
76211
+ end: start + formula3.tokens.length + span2.end
76212
+ }))
76213
+ );
76141
76214
  }
76142
76215
  if (revision2 === 8) {
76143
76216
  metadata3.global(output2);
@@ -76191,7 +76264,19 @@ async function writeBiffStream(book, revision2, dual, context2, filepass) {
76191
76264
  view3.setUint16(12, formula3.tokens.length, true);
76192
76265
  data4.set(formula3.tokens, 14);
76193
76266
  data4.set(formula3.arrays, 14 + formula3.tokens.length);
76194
- output2.record(545, data4);
76267
+ output2.continuedRecord(
76268
+ 545,
76269
+ data4,
76270
+ [
76271
+ 14,
76272
+ ...formula3.tokenBoundaries.map((offset) => offset + 14),
76273
+ ...formula3.arrayBoundaries.map((offset) => offset + 14 + formula3.tokens.length)
76274
+ ],
76275
+ formula3.arrayStrings.map((span2) => ({
76276
+ start: 14 + formula3.tokens.length + span2.start,
76277
+ end: 14 + formula3.tokens.length + span2.end
76278
+ }))
76279
+ );
76195
76280
  }
76196
76281
  }
76197
76282
  const cached = cell.cachedResult ?? cell.value;
@@ -76273,7 +76358,19 @@ async function writeCell(output2, cell, xf, revision2, strings, context2, formul
76273
76358
  view2.setUint16(20, formula3.tokens.length, true);
76274
76359
  data4.set(formula3.tokens, 22);
76275
76360
  data4.set(formula3.arrays, 22 + formula3.tokens.length);
76276
- output2.record(6, data4);
76361
+ output2.continuedRecord(
76362
+ 6,
76363
+ data4,
76364
+ [
76365
+ 22,
76366
+ ...formula3.tokenBoundaries.map((offset) => offset + 22),
76367
+ ...formula3.arrayBoundaries.map((offset) => offset + 22 + formula3.tokens.length)
76368
+ ],
76369
+ formula3.arrayStrings.map((span2) => ({
76370
+ start: 22 + formula3.tokens.length + span2.start,
76371
+ end: 22 + formula3.tokens.length + span2.end
76372
+ }))
76373
+ );
76277
76374
  return;
76278
76375
  }
76279
76376
  if (value3.kind === "number") {
@@ -77204,6 +77301,33 @@ async function readBiff(borrowed, context2, encoding) {
77204
77301
  while (records[index2 + 1]?.opcode === 60) parts.push(records[++index2].data);
77205
77302
  return { parts, next: index2 };
77206
77303
  };
77304
+ const formulaParts = (index2, offset, length) => {
77305
+ const first = records[index2].data;
77306
+ let tokens3;
77307
+ if (offset + length <= first.bytes.length) {
77308
+ tokens3 = first.slice(offset, length);
77309
+ offset += length;
77310
+ } else {
77311
+ accountFormulaWork(length);
77312
+ tokens3 = new Uint8Array(length);
77313
+ let written = 0;
77314
+ while (written < length) {
77315
+ context2.signal.throwIfAborted();
77316
+ const part = records[index2].data;
77317
+ const count = Math.min(length - written, part.bytes.length - offset);
77318
+ tokens3.set(part.slice(offset, count), written);
77319
+ written += count;
77320
+ offset += count;
77321
+ if (written < length) {
77322
+ if (records[index2 + 1]?.opcode !== 60) invalidBiff("truncated formula tokens/CONTINUE");
77323
+ index2++;
77324
+ offset = 0;
77325
+ }
77326
+ }
77327
+ }
77328
+ const extra = stringParts(index2, offset);
77329
+ return { tokens: tokens3, arrays: extra.parts, next: extra.next };
77330
+ };
77207
77331
  for (let index2 = 0; index2 < records.length; index2++) {
77208
77332
  context2.signal.throwIfAborted();
77209
77333
  const record7 = records[index2], data4 = record7.data, opcode = record7.opcode;
@@ -77402,13 +77526,12 @@ async function readBiff(borrowed, context2, encoding) {
77402
77526
  const name5 = accountText(ver >= 8 ? cursor.unicode(length).text : cursor.legacy(length));
77403
77527
  const end2 = 7 + cursor.consumedBytes;
77404
77528
  const tokenLength = end2 + 2 <= data4.bytes.length ? data4.u16(end2) : 0;
77405
- const tokens3 = tokenLength ? data4.slice(end2 + 2, tokenLength) : new Uint8Array();
77529
+ const formula4 = tokenLength ? formulaParts(index2, end2 + 2, tokenLength) : { tokens: new Uint8Array(), arrays: [], next: index2 };
77406
77530
  const legacyLink = (sheet?.legacyExternalLinks ?? legacyExternalLinks).get((sheet?.legacyExternalSheets ?? legacyExternalSheets).length - 1);
77407
77531
  const table10 = ver >= 8 ? supbooks.at(-1)?.names : legacyLink?.names;
77408
77532
  if (!table10) invalidBiff("EXTERNNAME without workbook link");
77409
- const arrays = tokenLength ? stringParts(index2, end2 + 2 + tokenLength) : { parts: [], next: index2 };
77410
- index2 = arrays.next;
77411
- table10.push({ name: name5, sheetIndex: data4.u16(2), tokens: tokens3, arrays: arrays.parts, revision: ver, codepage, supported: flags2 === 0, record: record7 });
77533
+ index2 = formula4.next;
77534
+ table10.push({ name: name5, sheetIndex: data4.u16(2), tokens: formula4.tokens, arrays: formula4.arrays, revision: ver, codepage, supported: flags2 === 0, record: record7 });
77412
77535
  const addin = ver >= 8 ? supbooks.at(-1)?.kind === "addin" : legacyLink?.addin;
77413
77536
  const externalIdentity = (ver >= 8 ? supbooks.at(-1)?.workbook : legacyLink?.workbook) !== void 0 && flags2 === 0;
77414
77537
  if (!addin || flags2 !== 0) await retain(record7, sheet?.unsupportedRecords ?? unsupported10, !externalIdentity);
@@ -77438,7 +77561,9 @@ async function readBiff(borrowed, context2, encoding) {
77438
77561
  }
77439
77562
  if (opcode === 24 || opcode === 536) {
77440
77563
  const flags2 = data4.u16(0), length = data4.u8(3), tokenLength = ver === 2 ? data4.u8(4) : data4.u16(4);
77441
- const start = ver >= 7 ? 14 : ver >= 3 ? 6 : 5, sheetIndex = ver >= 8 ? data4.u16(8) : ver >= 7 ? data4.u16(6) : 0;
77564
+ const start = ver >= 7 ? 14 : ver >= 3 ? 6 : 5;
77565
+ const scopeIsWorksheet = ver >= 8 || ver >= 7 && data4.u16(8) !== 0;
77566
+ const sheetIndex = scopeIsWorksheet ? data4.u16(8) : ver >= 7 ? data4.u16(6) : 0;
77442
77567
  const cursor = new BiffStrings([new Binary(data4.slice(start, data4.bytes.length - start))], context2, codepage);
77443
77568
  let name5;
77444
77569
  if (flags2 & 32 && length) {
@@ -77462,10 +77587,20 @@ async function readBiff(borrowed, context2, encoding) {
77462
77587
  ][builtin];
77463
77588
  name5 = (base ?? `_BIFF_BUILTIN_${builtin}`) + text2.slice(1);
77464
77589
  } else name5 = ver >= 8 ? cursor.unicode(length).text : cursor.legacy(length);
77465
- const tokens3 = data4.slice(start + cursor.consumedBytes, tokenLength);
77466
- const arrays = stringParts(index2, start + cursor.consumedBytes + tokenLength);
77467
- index2 = arrays.next;
77468
- names2.push({ name: accountText(name5), flags: flags2, tokens: tokens3, arrays: arrays.parts, sheetIndex, revision: ver, codepage, record: record7, ...sheet ? { owner: sheet } : {} });
77590
+ const formula4 = formulaParts(index2, start + cursor.consumedBytes, tokenLength);
77591
+ index2 = formula4.next;
77592
+ names2.push({
77593
+ name: accountText(name5),
77594
+ flags: flags2,
77595
+ tokens: formula4.tokens,
77596
+ arrays: formula4.arrays,
77597
+ sheetIndex,
77598
+ scopeIsWorksheet,
77599
+ revision: ver,
77600
+ codepage,
77601
+ record: record7,
77602
+ ...sheet ? { owner: sheet } : {}
77603
+ });
77469
77604
  continue;
77470
77605
  }
77471
77606
  if (ignoredOpcodes.has(opcode)) continue;
@@ -77539,13 +77674,15 @@ async function readBiff(borrowed, context2, encoding) {
77539
77674
  if (kind > 3) invalidBiff("invalid formula cache tag");
77540
77675
  }
77541
77676
  lastFormula = addCell(sheet, data4, value3, { cachedResult: value3, formulaDirty: !!(data4.u16(14) & 3) });
77542
- lastFormula.tokens = data4.slice(tokenStart, tokenLength);
77543
- const arrays = stringParts(index2, tokenStart + tokenLength);
77544
- index2 = arrays.next;
77545
- lastFormula.arrays = arrays.parts;
77677
+ const formula4 = formulaParts(index2, tokenStart, tokenLength);
77678
+ index2 = formula4.next;
77679
+ lastFormula.tokens = formula4.tokens;
77680
+ lastFormula.arrays = formula4.arrays;
77546
77681
  const nextOpcode = records[index2 + 1]?.opcode;
77547
77682
  const groupFollows = nextOpcode === 1212 || nextOpcode === 33 || nextOpcode === 545 || nextOpcode === 54 || nextOpcode === 55 || nextOpcode === 566;
77548
- const stringOpcode = records[index2 + (groupFollows ? 2 : 1)]?.opcode;
77683
+ let stringIndex = index2 + (groupFollows ? 2 : 1);
77684
+ if (groupFollows) while (records[stringIndex]?.opcode === 60) stringIndex++;
77685
+ const stringOpcode = records[stringIndex]?.opcode;
77549
77686
  if (stringCache2 && stringOpcode !== 7 && stringOpcode !== 519) {
77550
77687
  const error3 = { kind: "error", value: "MISSING STRING" };
77551
77688
  lastFormula.cell = { ...lastFormula.cell, value: error3, cachedResult: error3 };
@@ -77585,10 +77722,17 @@ async function readBiff(borrowed, context2, encoding) {
77585
77722
  }
77586
77723
  const kind = opcode === 1212 ? "shared" : "array";
77587
77724
  const start = kind === "shared" ? 10 : ver === 2 ? 8 : ver <= 4 ? 10 : 14;
77588
- const tokens3 = data4.slice(start, ver === 2 && kind === "array" ? data4.u8(start - 1) : data4.u16(start - 2));
77589
- const arrays = stringParts(index2, start + tokens3.length);
77590
- index2 = arrays.next;
77591
- sheet.groups.push({ id: `biff-${sheet.offset}-${record7.offset}`, kind, range: range5, tokens: tokens3, arrays: arrays.parts, keyRow: lastFormula.cell.row, keyColumn: lastFormula.cell.column });
77725
+ const formula4 = formulaParts(index2, start, ver === 2 && kind === "array" ? data4.u8(start - 1) : data4.u16(start - 2));
77726
+ index2 = formula4.next;
77727
+ sheet.groups.push({
77728
+ id: `biff-${sheet.offset}-${record7.offset}`,
77729
+ kind,
77730
+ range: range5,
77731
+ tokens: formula4.tokens,
77732
+ arrays: formula4.arrays,
77733
+ keyRow: lastFormula.cell.row,
77734
+ keyColumn: lastFormula.cell.column
77735
+ });
77592
77736
  continue;
77593
77737
  }
77594
77738
  if (opcode === 7 || opcode === 519) {
@@ -77696,7 +77840,7 @@ async function readBiff(borrowed, context2, encoding) {
77696
77840
  const localSheets = sheets.map((sheet) => sheet.name);
77697
77841
  const nameSheets = names2.map((name5) => {
77698
77842
  if (!name5.sheetIndex) return void 0;
77699
- return (name5.revision >= 8 ? sheets[name5.sheetIndex - 1]?.name : (name5.owner?.legacyExternalSheets ?? legacyExternalSheets)[name5.sheetIndex - 1]) ?? void 0;
77843
+ return (name5.scopeIsWorksheet ? sheets[name5.sheetIndex - 1]?.name : (name5.owner?.legacyExternalSheets ?? legacyExternalSheets)[name5.sheetIndex - 1]) ?? void 0;
77700
77844
  });
77701
77845
  const externalNameTables = /* @__PURE__ */ new Map();
77702
77846
  const formulaNames = names2.map((name5) => name5.name);
@@ -91155,7 +91299,11 @@ function odfCellStyle(node3, parent, charge) {
91155
91299
  const italic = attr4(p2, "font-style", "fo");
91156
91300
  if (italic !== void 0) font2.Italic = italic === "italic" || italic === "oblique" ? 1 : 0;
91157
91301
  const underline = attr4(p2, "text-underline-style", "style");
91158
- if (underline !== void 0) font2.Underline = underline === "none" ? 0 : attr4(p2, "text-underline-type", "style") === "double" ? 2 : 1;
91302
+ if (underline !== void 0) {
91303
+ const type = attr4(p2, "text-underline-type", "style");
91304
+ const double = type === "double" || attr4(p2, "text-underline-width", "style") === "bold";
91305
+ font2.Underline = underline === "none" || type === "none" ? 0 : (double ? 2 : 1) + (attr4(p2, "text-underline-placement", "gnm") === "low" ? 2 : 0);
91306
+ }
91159
91307
  const strike = attr4(p2, "text-line-through-style", "style");
91160
91308
  if (strike !== void 0) font2.StrikeThrough = strike === "none" ? 0 : 1;
91161
91309
  family = attr4(p2, "font-family", "fo") ?? attr4(p2, "font-name", "style") ?? family;
@@ -91668,8 +91816,13 @@ function createOdfStyles(xml2, extended, book, context2) {
91668
91816
  if (f2.Bold !== void 0) text2["fo:font-weight"] = Number(f2.Bold) ? "bold" : "normal";
91669
91817
  if (f2.Italic !== void 0) text2["fo:font-style"] = Number(f2.Italic) ? "italic" : "normal";
91670
91818
  if (f2.Underline !== void 0) {
91671
- text2["style:text-underline-style"] = Number(f2.Underline) ? "solid" : "none";
91672
- text2["style:text-underline-type"] = Number(f2.Underline) === 2 ? "double" : "single";
91819
+ const underline = Number(f2.Underline), low = underline === 3 || underline === 4;
91820
+ text2["style:text-underline-style"] = underline ? "solid" : "none";
91821
+ text2["style:text-underline-type"] = underline === 2 || underline === 4 ? "double" : underline ? "single" : "none";
91822
+ text2["style:text-underline-width"] = "auto";
91823
+ text2["style:text-underline-color"] = "font-color";
91824
+ text2["style:text-underline-mode"] = "continuous";
91825
+ if (extended && low) text2["gnm:text-underline-placement"] = "low";
91673
91826
  }
91674
91827
  if (f2.StrikeThrough !== void 0) text2["style:text-line-through-style"] = Number(f2.StrikeThrough) ? "solid" : "none";
91675
91828
  }
@@ -164478,4 +164631,4 @@ tslib/tslib.js:
164478
164631
  @noble/ciphers/utils.js:
164479
164632
  (*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
164480
164633
  */
164481
- //# sourceMappingURL=chunk-BQEH4DKJ.js.map
164634
+ //# sourceMappingURL=chunk-ILHNFAZE.js.map
@@ -81,7 +81,7 @@ import {
81
81
  updateWorkbook,
82
82
  validSheetSize,
83
83
  visitFormula
84
- } from "./chunk-BQEH4DKJ.js";
84
+ } from "./chunk-ILHNFAZE.js";
85
85
  import "./chunk-CVAVQZSF.js";
86
86
  import "./chunk-RCM5PZBN.js";
87
87
  import "./chunk-LSRHLNCR.js";
@@ -171,4 +171,4 @@ export {
171
171
  validSheetSize,
172
172
  visitFormula
173
173
  };
174
- //# sourceMappingURL=src-YBSQFQZO.js.map
174
+ //# sourceMappingURL=src-XXKXVO7T.js.map
@@ -84,7 +84,7 @@ export function basicCommands() {
84
84
  return { exitCode: 0 };
85
85
  }),
86
86
  define("basename", async (context) => {
87
- const parsed = options(context.args, "as:z", { multiple: "a", suffix: "s", zero: "z" });
87
+ const parsed = options(context.args, "as:z", { multiple: "a", suffix: "s", zero: "z" }, true);
88
88
  const multiple = parsed.flags.has("a") || parsed.flags.has("s");
89
89
  requireOperands(parsed.operands, 1, multiple ? Infinity : 2);
90
90
  const suffix = value(parsed, "s") ?? (multiple ? undefined : parsed.operands[1]);
@@ -97,7 +97,7 @@ export function basicCommands() {
97
97
  return { exitCode: 0 };
98
98
  }, 1, 1),
99
99
  define("dirname", async (context) => {
100
- const parsed = options(context.args, "z", { zero: "z" });
100
+ const parsed = options(context.args, "z", { zero: "z" }, true);
101
101
  requireOperands(parsed.operands);
102
102
  for (const operand of parsed.operands) {
103
103
  const parent = dirname(operand);
@@ -2,7 +2,7 @@ import {
2
2
  createPrCommand,
3
3
  createPrCommands,
4
4
  prCommands
5
- } from "../../chunks/chunk-MUWJPSGN.js";
5
+ } from "../../chunks/chunk-B7IBQSD4.js";
6
6
  import "../../chunks/chunk-BI6JV62X.js";
7
7
  import "../../chunks/chunk-2G2T5MEM.js";
8
8
  import "../../chunks/chunk-JYGWVGEJ.js";
@@ -4,6 +4,7 @@ export interface SleepScheduler {
4
4
  setTimeout(callback: () => void, milliseconds: number): unknown;
5
5
  clearTimeout(handle: unknown): void;
6
6
  }
7
+ export declare const defaultSleepScheduler: SleepScheduler;
7
8
  export interface TimeEnvLimits {
8
9
  readonly maxArguments: number;
9
10
  readonly maxArgumentBytes: number;
@@ -1,5 +1,10 @@
1
1
  import { writeDiagnostic } from "../../escaping.js";
2
2
  import { FsError, writeBytes } from "../../contracts/index.js";
3
+ export const defaultSleepScheduler = {
4
+ now: () => performance.now(),
5
+ setTimeout: (callback, milliseconds) => setTimeout(callback, milliseconds),
6
+ clearTimeout: handle => clearTimeout(handle),
7
+ };
3
8
  export function settings(options) {
4
9
  const limits = { maxArguments: Infinity, maxArgumentBytes: Infinity, maxOutputBytes: Infinity,
5
10
  maxEnvironmentEntries: Infinity, maxFormatWidth: Infinity, ...options.limits };
@@ -11,11 +16,7 @@ export function settings(options) {
11
16
  if (maxTimerMilliseconds !== Infinity && (!Number.isInteger(maxTimerMilliseconds) || maxTimerMilliseconds < 1 || maxTimerMilliseconds > 2147483647)) {
12
17
  throw new RangeError("maxTimerMilliseconds must be between 1 and 2147483647 or Infinity");
13
18
  }
14
- const scheduler = options.scheduler ?? {
15
- now: () => performance.now(),
16
- setTimeout: (callback, milliseconds) => setTimeout(callback, milliseconds),
17
- clearTimeout: handle => clearTimeout(handle),
18
- };
19
+ const scheduler = options.scheduler ?? defaultSleepScheduler;
19
20
  if (typeof scheduler.now !== "function" || typeof scheduler.setTimeout !== "function" || typeof scheduler.clearTimeout !== "function") {
20
21
  throw new TypeError("Invalid sleep scheduler");
21
22
  }
@@ -1,4 +1,4 @@
1
- import { command, CommandFailure, emit } from "./shared.js";
1
+ import { command, CommandFailure, defaultSleepScheduler, emit } from "./shared.js";
2
2
  function duration(arguments_) {
3
3
  if (!arguments_.length)
4
4
  throw new CommandFailure("missing operand");
@@ -129,8 +129,11 @@ function delay(milliseconds, signal, configuration) {
129
129
  if (!Number.isFinite(now) || Math.abs(now) > Number.MAX_SAFE_INTEGER || (previous !== undefined && now < previous)) {
130
130
  throw new RangeError("sleep scheduler must supply finite monotonic milliseconds");
131
131
  }
132
- if (previous !== undefined)
133
- remaining -= Math.max(step, now - previous);
132
+ if (previous !== undefined) {
133
+ // Host timers may wake early. Injected clocks can instead be coarse
134
+ // or frozen, so retain their scheduled-interval progress contract.
135
+ remaining -= scheduler === defaultSleepScheduler ? now - previous : Math.max(step, now - previous);
136
+ }
134
137
  previous = now;
135
138
  if (remaining <= 0) {
136
139
  finish(false);