@poe-platform/safe-bash 0.1.745 → 0.1.746

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +5 -1
  2. package/dist/image-ast/browser/sharp.d.ts +1 -1
  3. package/dist/image-ast/index.js +133 -35
  4. package/dist/image-ast/sharp.d.ts +1 -1
  5. package/dist/safe-bash/chunks/{chunk-EAUCLWEZ.js → chunk-3ZNXN3XO.js} +423 -245
  6. package/dist/safe-bash/chunks/{chunk-2F7Q532M.js → chunk-4GK4FAT6.js} +3 -3
  7. package/dist/safe-bash/chunks/{chunk-WCNFCN2G.js → chunk-BS6QFRNX.js} +2 -2
  8. package/dist/safe-bash/chunks/{chunk-IZZ7KX4E.js → chunk-JCXAGOEK.js} +40 -3
  9. package/dist/safe-bash/chunks/{chunk-I3DOFJSJ.js → chunk-MUWJPSGN.js} +2 -2
  10. package/dist/safe-bash/chunks/{chunk-7RP6WOWK.js → chunk-OF2PDE3W.js} +2 -2
  11. package/dist/safe-bash/chunks/{src-FTMTU65U.js → src-T2WAWJXF.js} +2 -2
  12. package/dist/safe-bash/command-chunks/{chunk-DRCPJVZF.js → chunk-44N2IRVP.js} +17 -5
  13. package/dist/safe-bash/command-chunks/{chunk-LYKC7WJB.js → chunk-6742OVAC.js} +37 -3
  14. package/dist/safe-bash/command-chunks/{chunk-BMBXSLVX.js → chunk-6QU5OLPJ.js} +2 -2
  15. package/dist/safe-bash/command-chunks/{chunk-YHANNN7I.js → chunk-S3BO2NJT.js} +7 -0
  16. package/dist/safe-bash/commands/basic.d.ts +2 -0
  17. package/dist/safe-bash/commands/basic.js +236 -9
  18. package/dist/safe-bash/commands/pr/index.browser.js +1 -1
  19. package/dist/safe-bash/commands/streams.js +9 -56
  20. package/dist/safe-bash/commands/table-text/index.js +5 -1
  21. package/dist/safe-bash/commands/text.js +13 -2
  22. package/dist/safe-bash/commands/time-env/shared.js +2 -2
  23. package/dist/safe-bash/commands/time-env/sleep.js +6 -4
  24. package/dist/safe-bash/commands/timeout/index.d.ts +7 -0
  25. package/dist/safe-bash/commands/timeout/index.js +52 -32
  26. package/dist/safe-bash/commands/timeout/scheduler.js +7 -6
  27. package/dist/safe-bash/core.browser.js +2697 -543
  28. package/dist/safe-bash/opt-in/commands/shuf/random.js +2 -3
  29. package/dist/safe-bash/opt-in/shell/extensions/read/index.js +1 -1
  30. package/dist/safe-bash/opt-in/shell/extensions/trap/index.d.ts +1 -2
  31. package/dist/safe-bash/opt-in/shell/extensions/trap/index.js +1 -8
  32. package/dist/safe-bash/playwright/adapter.d.ts +2 -0
  33. package/dist/safe-bash/playwright/private-target-transport.d.ts +1 -0
  34. package/dist/safe-bash/playwright/private-target-transport.js +21 -21
  35. package/dist/safe-bash/shell/runtime.d.ts +20 -1
  36. package/dist/safe-bash/shell/runtime.js +3014 -532
  37. package/dist/safe-bash/shell/sync-jq-expression.d.ts +6 -0
  38. package/dist/safe-bash/shell/sync-jq-expression.js +46 -0
  39. package/dist/safe-bash-command-cal/index.js +32 -12
  40. package/dist/safe-bash-command-hostname/index.js +22 -7
  41. package/dist/safe-bash-command-id/index.js +28 -9
  42. package/dist/safe-bash-command-pandoc/command.js +1 -1
  43. package/dist/safe-bash-command-pandoc/index.js +1 -1
  44. package/dist/safe-bash-command-ssconvert/command.d.ts +2 -2
  45. package/dist/safe-bash-command-ssconvert/contracts.d.ts +4 -0
  46. package/dist/safe-bash-command-ssconvert/engine.d.ts +2 -2
  47. package/dist/safe-bash-command-ssconvert/index.js +410 -237
  48. package/dist/safe-bash-command-whoami/index.js +26 -12
  49. package/dist/safe-bash-query-engine/index.js +3 -3
  50. package/dist/safe-bash-query-engine/interpreter.js +1 -1
  51. package/dist/safe-bash-query-engine/parser.js +1 -1
  52. package/dist/safe-bash-query-engine/query-core.js +3 -3
  53. package/dist/safe-playwright-cloudflare/browser-private-transport.js +8 -13
  54. package/dist/safe-playwright-cloudflare/browser-storage-control.js +13 -4
  55. package/dist/safe-playwright-cloudflare/browser-trace-archive.js +1 -1
  56. package/package.json +18 -14
  57. package/dist/image-ast/streams/node.d.ts +0 -10
  58. package/dist/image-ast/streams/node.js +0 -5
  59. package/dist/image-ast/streams/web.js +0 -94
@@ -27222,9 +27222,9 @@ function parseExpression(source, options) {
27222
27222
  }
27223
27223
  let sheetRelative;
27224
27224
  const readSheet = () => {
27225
+ if (grammar3.bracketReferences && grammar3.absoluteSheetReferences) sheetRelative = source[offset] !== "$";
27226
+ if (grammar3.absoluteSheetReferences && source[offset] === "$") offset++;
27225
27227
  if (grammar3.bracketReferences) {
27226
- if (grammar3.absoluteSheetReferences) sheetRelative = source[offset] !== "$";
27227
- if (grammar3.absoluteSheetReferences && source[offset] === "$") offset++;
27228
27228
  if (source[offset] === "'") return quoted("'", grammar3.stringEscape);
27229
27229
  const begin2 = offset;
27230
27230
  while (offset < source.length && source[offset] !== grammar3.sheetSeparator && !" []:' \r\n".includes(source[offset])) offset++;
@@ -27232,7 +27232,6 @@ function parseExpression(source, options) {
27232
27232
  }
27233
27233
  if (grammar3.unquotedSheets) {
27234
27234
  const begin2 = offset;
27235
- if (grammar3.absoluteSheetReferences && source[offset] === "$") offset++;
27236
27235
  while (letter(source[offset]) || digit(source[offset])) offset++;
27237
27236
  return source.slice(begin2, offset);
27238
27237
  }
@@ -27256,7 +27255,6 @@ function parseExpression(source, options) {
27256
27255
  return {};
27257
27256
  }
27258
27257
  offset++;
27259
- if (grammar3.absoluteSheetReferences && !grammar3.bracketReferences && sheet.startsWith("$")) sheet = sheet.slice(1);
27260
27258
  if (sheet.startsWith("[")) {
27261
27259
  const close = sheet.indexOf("]");
27262
27260
  if (close >= 0) {
@@ -29124,6 +29122,383 @@ var chartDataTypes = Object.freeze(Object.fromEntries(Object.entries({
29124
29122
  GODataMatrixVal: { storage: "literal", dimensions: 2 }
29125
29123
  }).map(([name5, descriptor3]) => [name5, Object.freeze(descriptor3)])));
29126
29124
 
29125
+ // packages/safe-bash-command-ssconvert/src/workbook/hyperlinks.ts
29126
+ init_platform();
29127
+
29128
+ // packages/safe-bash-command-ssconvert/src/codecs/odf-write-support.ts
29129
+ init_platform();
29130
+ import { parseXmlSteps } from "@poe-platform/safe-fs/core";
29131
+ var urn = "urn:oasis:names:tc:opendocument:xmlns:";
29132
+ var odfEncryptionNamespace = "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0";
29133
+ var odfNamespaces = {
29134
+ xml: "http://www.w3.org/XML/1998/namespace",
29135
+ office: urn + "office:1.0",
29136
+ style: urn + "style:1.0",
29137
+ text: urn + "text:1.0",
29138
+ table: urn + "table:1.0",
29139
+ draw: urn + "drawing:1.0",
29140
+ fo: urn + "xsl-fo-compatible:1.0",
29141
+ xlink: "http://www.w3.org/1999/xlink",
29142
+ dc: "http://purl.org/dc/elements/1.1/",
29143
+ meta: urn + "meta:1.0",
29144
+ number: urn + "datastyle:1.0",
29145
+ svg: urn + "svg-compatible:1.0",
29146
+ chart: urn + "chart:1.0",
29147
+ config: urn + "config:1.0",
29148
+ form: urn + "form:1.0",
29149
+ script: urn + "script:1.0",
29150
+ of: urn + "of:1.2",
29151
+ manifest: urn + "manifest:1.0",
29152
+ gnm: "http://www.gnumeric.org/odf-extension/1.0",
29153
+ calcext: "urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
29154
+ };
29155
+ function odfObject(value3) {
29156
+ return value3 !== null && typeof value3 === "object" && !Array.isArray(value3) ? value3 : void 0;
29157
+ }
29158
+ function odfAttributes(value3, namespace5) {
29159
+ const source = odfObject(value3)?.attributes;
29160
+ if (Array.isArray(source)) return Object.fromEntries(source.flatMap((a3) => {
29161
+ const v2 = odfObject(a3);
29162
+ return typeof v2?.name === "string" && typeof v2.value === "string" && (namespace5 === void 0 || v2.namespace === namespace5) ? [[v2.name, v2.value]] : [];
29163
+ }));
29164
+ if (namespace5 !== void 0) return {};
29165
+ return Object.fromEntries(Object.entries(odfObject(source) ?? {}).filter((entry2) => typeof entry2[1] === "string"));
29166
+ }
29167
+ function odfChildren(value3) {
29168
+ const source = odfObject(value3)?.children;
29169
+ return Array.isArray(source) ? source : [];
29170
+ }
29171
+ function createOdfXml(context2, extended) {
29172
+ let work = 0, nodes = 0;
29173
+ const encoder2 = new TextEncoder(), names2 = /* @__PURE__ */ new Set();
29174
+ const declarations = {
29175
+ ...Object.fromEntries(Object.entries(odfNamespaces).map(([prefix2, uri]) => ["xmlns:" + prefix2, uri])),
29176
+ "xmlns:loext": odfEncryptionNamespace
29177
+ };
29178
+ function charge(amount = 1) {
29179
+ context2.signal.throwIfAborted();
29180
+ if (!Number.isSafeInteger(amount) || amount < 0 || amount > (context2.limits.workbookWork ?? Infinity) - work)
29181
+ throw new SsconvertError("resource-limit", "ssconvert OpenDocument work limit exceeded");
29182
+ work += amount;
29183
+ }
29184
+ function name5(value3) {
29185
+ charge(value3.length);
29186
+ if (names2.has(value3)) return;
29187
+ try {
29188
+ const parser = parseXmlSteps(`<${value3} ${Object.entries(declarations).map(([k, v2]) => `${k}="${v2}"`).join(" ")}/>`, { maxNodes: 1, maxAttributes: 100 });
29189
+ let step = parser.next();
29190
+ while (!step.done) step = parser.next();
29191
+ if (step.value.name !== value3 || step.value.children.length) throw new Error("name");
29192
+ } catch {
29193
+ throw new SsconvertError("invalid-request", "Invalid OpenDocument XML name");
29194
+ }
29195
+ names2.add(value3);
29196
+ }
29197
+ function escape3(value3) {
29198
+ charge(value3.length);
29199
+ let result2 = "";
29200
+ for (const c4 of value3) {
29201
+ const code2 = c4.codePointAt(0);
29202
+ if (code2 < 32 && !" \n\r".includes(c4) || code2 === 65534 || code2 === 65535 || code2 >= 55296 && code2 <= 57343)
29203
+ throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: non-XML OpenDocument character");
29204
+ result2 += c4 === "&" ? "&amp;" : c4 === "<" ? "&lt;" : c4 === ">" ? "&gt;" : c4 === '"' ? "&quot;" : c4 === "\r" ? "&#13;" : c4 === "\n" ? "&#10;" : c4 === " " ? "&#9;" : c4;
29205
+ }
29206
+ return result2;
29207
+ }
29208
+ function element2(tag3, attributes4 = {}, content2 = "") {
29209
+ charge();
29210
+ if (++nodes > (context2.limits.workbookNodes ?? Infinity))
29211
+ throw new SsconvertError("resource-limit", "ssconvert OpenDocument XML nodes limit exceeded");
29212
+ name5(tag3);
29213
+ let result2 = "<" + tag3;
29214
+ for (const [key2, value3] of Object.entries(attributes4)) if (value3 !== void 0) {
29215
+ if (!key2.startsWith("xmlns:")) name5(key2);
29216
+ result2 += ` ${key2}="${escape3(String(value3))}"`;
29217
+ }
29218
+ result2 += content2 ? ">" + content2 + "</" + tag3 + ">" : "/>";
29219
+ if (result2.length > context2.limits.outputBytes || encoder2.encode(result2).length > context2.limits.outputBytes)
29220
+ throw new SsconvertError("resource-limit", "ssconvert OpenDocument output bytes limit exceeded");
29221
+ return result2;
29222
+ }
29223
+ function text2(value3) {
29224
+ charge(value3.length);
29225
+ let result2 = "", plain = "";
29226
+ function flush() {
29227
+ result2 += escape3(plain);
29228
+ plain = "";
29229
+ }
29230
+ for (let i4 = 0; i4 < value3.length; i4++) {
29231
+ const c4 = value3[i4];
29232
+ if (c4 === " ") {
29233
+ flush();
29234
+ let count = 1;
29235
+ while (value3[i4 + 1] === " ") {
29236
+ i4++;
29237
+ count++;
29238
+ }
29239
+ result2 += element2("text:s", count > 1 ? { "text:c": count } : {});
29240
+ } else if (c4 === " " || c4 === "\n") {
29241
+ flush();
29242
+ result2 += element2(c4 === " " ? "text:tab" : "text:line-break");
29243
+ } else plain += c4;
29244
+ }
29245
+ flush();
29246
+ return result2;
29247
+ }
29248
+ const active = /* @__PURE__ */ new Set();
29249
+ function retained2(value3, depth = 0, hyperlink, hyperlinkContent = false) {
29250
+ charge();
29251
+ const v2 = odfObject(value3);
29252
+ if (!v2 || typeof v2.name !== "string" || typeof v2.namespace !== "string") return "";
29253
+ if (depth > (context2.limits.xmlDepth ?? Infinity)) throw new SsconvertError("resource-limit", "ssconvert OpenDocument metadata depth limit exceeded");
29254
+ if (active.has(v2)) throw new SsconvertError("invalid-request", "Invalid cyclic OpenDocument metadata");
29255
+ const prefix2 = Object.entries(odfNamespaces).find(([, uri]) => uri === v2.namespace)?.[0];
29256
+ if (!prefix2 || !extended && ["gnm", "calcext"].includes(prefix2)) return "";
29257
+ active.add(v2);
29258
+ try {
29259
+ const attributes4 = {};
29260
+ if (Array.isArray(v2.attributes)) for (const a3 of v2.attributes) {
29261
+ charge();
29262
+ const attribute5 = odfObject(a3);
29263
+ if (typeof attribute5?.name !== "string" || typeof attribute5.value !== "string" || typeof attribute5.namespace !== "string") continue;
29264
+ const p2 = Object.entries(odfNamespaces).find(([, uri]) => uri === attribute5.namespace)?.[0];
29265
+ if (attribute5.namespace && (!p2 || !extended && ["gnm", "calcext"].includes(p2))) continue;
29266
+ attributes4[(p2 ? p2 + ":" : "") + attribute5.name] = attribute5.value;
29267
+ }
29268
+ if (prefix2 === "text" && v2.name === "a" && attributes4["xlink:href"] !== void 0 && hyperlink)
29269
+ attributes4["xlink:href"] = hyperlink(attributes4["xlink:href"]);
29270
+ const children7 = odfChildren(v2);
29271
+ const childHyperlinkContent = Boolean(hyperlink) && prefix2 === "text" && v2.name === "a" && attributes4["xlink:href"] !== void 0;
29272
+ const content2 = Array.isArray(v2.content) ? v2.content.map((c4) => {
29273
+ charge();
29274
+ const item = odfObject(c4);
29275
+ if (item?.kind === "text" && typeof item.text === "string") return escape3(item.text);
29276
+ if (item?.kind !== "element") return "";
29277
+ if (item.index === void 0) return retained2(item.value, depth + 1, hyperlink, childHyperlinkContent);
29278
+ if (typeof item.index !== "number" || !Number.isSafeInteger(item.index) || item.index < 0 || item.index >= children7.length)
29279
+ throw new SsconvertError("invalid-request", "Invalid OpenDocument metadata child index");
29280
+ return retained2(children7[item.index], depth + 1, hyperlink, childHyperlinkContent);
29281
+ }).join("") : (typeof v2.text === "string" ? escape3(v2.text) : "") + children7.map((c4) => retained2(c4, depth + 1, hyperlink, childHyperlinkContent)).join("");
29282
+ if (hyperlinkContent && prefix2 === "text" && !content2 && !children7.length) {
29283
+ if (v2.name === "s" && Object.keys(attributes4).every((key2) => key2 === "text:c")) {
29284
+ const count = Number(attributes4["text:c"] ?? "1");
29285
+ if (!Number.isSafeInteger(count) || count < 0) throw new SsconvertError("invalid-request", "Invalid OpenDocument whitespace count");
29286
+ if (count > context2.limits.outputBytes) throw new SsconvertError("resource-limit", "ssconvert OpenDocument output bytes limit exceeded");
29287
+ charge(count);
29288
+ return " ".repeat(count);
29289
+ }
29290
+ if (!Object.keys(attributes4).length && (v2.name === "tab" || v2.name === "line-break"))
29291
+ return escape3(v2.name === "tab" ? " " : "\n");
29292
+ }
29293
+ return element2(prefix2 + ":" + v2.name, attributes4, content2);
29294
+ } finally {
29295
+ active.delete(v2);
29296
+ }
29297
+ }
29298
+ function document6(tag3, body) {
29299
+ return '<?xml version="1.0" encoding="UTF-8"?>\n' + element2(tag3, { ...declarations, "xmlns:loext": void 0, "office:version": "1.2" }, body);
29300
+ }
29301
+ return { element: element2, escape: escape3, text: text2, retained: retained2, document: document6, charge };
29302
+ }
29303
+
29304
+ // packages/safe-bash-command-ssconvert/src/codecs/odf-hyperlinks.ts
29305
+ init_platform();
29306
+ var linkGrammar = { ...excelGrammar, id: "odf-hyperlink", sheetSeparator: ".", absoluteSheetReferences: true };
29307
+ function decodeFragment(source, charge) {
29308
+ let result2 = "";
29309
+ for (let at = 0; at < source.length; ) {
29310
+ charge();
29311
+ const high = "0123456789abcdef".indexOf(source[at + 1]?.toLowerCase() ?? " ");
29312
+ const low = "0123456789abcdef".indexOf(source[at + 2]?.toLowerCase() ?? " ");
29313
+ if (source[at] !== "%" || high < 0 || low < 0) {
29314
+ result2 += source[at++];
29315
+ continue;
29316
+ }
29317
+ const octet = high * 16 + low;
29318
+ const length = octet >= 192 && octet <= 223 ? 6 : octet >= 224 && octet <= 239 ? 9 : octet >= 240 && octet <= 244 ? 12 : 3;
29319
+ const encoded2 = source.slice(at, at + length);
29320
+ try {
29321
+ result2 += decodeURIComponent(encoded2);
29322
+ at += length;
29323
+ } catch {
29324
+ result2 += source.slice(at, at + 3).toUpperCase();
29325
+ at += 3;
29326
+ }
29327
+ }
29328
+ return result2;
29329
+ }
29330
+ function encodeFragment(source) {
29331
+ return "#" + encodeURI(source).split("#").join("%23").split("?").join("%3F");
29332
+ }
29333
+ function translateOdfHyperlink(source, direction2, charge, sheetNames = []) {
29334
+ charge(source.length);
29335
+ if (direction2 === "normalize" && !source.startsWith("#")) return source;
29336
+ function findSheet(name5) {
29337
+ const folded = foldSheetName(name5);
29338
+ return sheetNames.find((candidate) => {
29339
+ charge(candidate.length);
29340
+ return foldSheetName(candidate) === folded;
29341
+ });
29342
+ }
29343
+ let target = direction2 !== "export" && source.startsWith("#") ? source.slice(1) : source;
29344
+ if (direction2 !== "export") {
29345
+ target = decodeFragment(target, charge);
29346
+ const separator2 = target.indexOf(" (");
29347
+ if (separator2 > 0 && target.endsWith(")")) {
29348
+ const name5 = target.slice(0, separator2), sheet = findSheet(target.slice(separator2 + 2, -1));
29349
+ if (sheet !== void 0) {
29350
+ const qualified = quoteNativeSheet(sheet) + "!" + name5;
29351
+ const parsed2 = parseExpression("=" + qualified, { position: { sheet, row: 0, column: 0 }, onWork: charge });
29352
+ if (parsed2.ok && parsed2.document.root.kind === "name" && parsed2.document.root.name === name5 && parsed2.document.root.sheet === sheet)
29353
+ return direction2 === "import" ? qualified : encodeFragment(target);
29354
+ }
29355
+ }
29356
+ }
29357
+ const parsed = parseExpression("=" + target, {
29358
+ grammar: direction2 !== "export" ? linkGrammar : gnumericGrammar,
29359
+ position: { sheet: "", row: 0, column: 0 },
29360
+ onWork: charge
29361
+ });
29362
+ if (parsed.ok) {
29363
+ const node3 = parsed.document.root;
29364
+ if (node3.kind === "name" && node3.workbook === void 0 || node3.kind === "reference" && !node3.label && node3.first.workbook === void 0 && node3.last?.workbook === void 0) {
29365
+ const sheet = direction2 !== "import" && node3.kind === "name" && node3.sheet !== void 0 ? findSheet(node3.sheet) : void 0;
29366
+ if (sheet !== void 0 && node3.kind === "name") return encodeFragment(node3.name + " (" + sheet + ")");
29367
+ if (direction2 !== "normalize") target = serializeExpression(parsed.document, direction2 === "import" ? { ...gnumericGrammar, quoteSheetName: quoteNativeSheet } : linkGrammar, false, true).slice(1);
29368
+ }
29369
+ }
29370
+ return direction2 === "import" ? target : direction2 === "normalize" ? source : encodeFragment(target);
29371
+ }
29372
+
29373
+ // packages/safe-bash-command-ssconvert/src/workbook/hyperlinks.ts
29374
+ function rewriteWorkbookHyperlinks(book, names2, context2) {
29375
+ let work = 0;
29376
+ const maximum = context2.limits.workbookWork ?? context2.limits.inputBytes + context2.limits.cells * 32;
29377
+ function charge(amount = 1) {
29378
+ context2.signal.throwIfAborted();
29379
+ if (amount > maximum - work) throw new SsconvertError("resource-limit", "ssconvert hyperlink work limit exceeded");
29380
+ work += amount;
29381
+ }
29382
+ const sheets = [...book.sheets, ...book.detachedSheets ?? []].map((sheet2) => sheet2.name);
29383
+ const changes = new Map(sheets.flatMap((name5) => {
29384
+ charge(name5.length);
29385
+ const next = names2.get(foldSheetName(name5));
29386
+ return next === void 0 || next === name5 ? [] : [[foldSheetName(name5), next]];
29387
+ }));
29388
+ if (!changes.size) return book;
29389
+ const renamedSheets = sheets.map((name5) => names2.get(foldSheetName(name5)) ?? name5);
29390
+ function target(source, odf) {
29391
+ charge(source.length);
29392
+ if (odf && !source.startsWith("#")) return source;
29393
+ const native = odf ? translateOdfHyperlink(source, "import", charge, sheets) : source;
29394
+ const parsed = parseExpression("=" + native, { position: { sheet: "", row: 0, column: 0 }, onWork: charge, signal: context2.signal });
29395
+ if (!parsed.ok) return source;
29396
+ const node3 = parsed.document.root;
29397
+ const spellings = node3.kind === "name" && node3.workbook === void 0 ? [node3.sheet] : node3.kind === "reference" && !node3.label && node3.first.workbook === void 0 && node3.last?.workbook === void 0 ? [node3.first.sheet, node3.last?.sheet] : [];
29398
+ const replacements = /* @__PURE__ */ new Map();
29399
+ for (const spelling of spellings) if (spelling !== void 0) {
29400
+ charge(spelling.length);
29401
+ const name5 = changes.get(foldSheetName(spelling));
29402
+ if (name5 !== void 0 && name5 !== spelling) replacements.set(spelling, name5);
29403
+ }
29404
+ if (!replacements.size) return source;
29405
+ const rewritten = rewriteReferences(parsed.document, { sheets: replacements, signal: context2.signal }).slice(1);
29406
+ charge(rewritten.length);
29407
+ return odf ? translateOdfHyperlink(rewritten, "export", charge, renamedSheets) : rewritten;
29408
+ }
29409
+ function xml2(value3, odf, root, implicitNamespace = false) {
29410
+ let result2 = value3;
29411
+ const pending = [{ value: value3, role: root, depth: 0, assign: (next) => {
29412
+ result2 = next;
29413
+ } }];
29414
+ while (pending.length) {
29415
+ const item = pending.pop();
29416
+ charge();
29417
+ const node3 = odfObject(item.value);
29418
+ if (!node3 || typeof node3.name !== "string" || node3.name !== item.role) continue;
29419
+ const validNamespace = odf ? node3.namespace === odfNamespaces.text || node3.namespace === "http://openoffice.org/2000/text" : node3.namespace === "http://www.gnumeric.org/v10.dtd" || implicitNamespace && (node3.namespace === void 0 || node3.namespace === "");
29420
+ if (!validNamespace) continue;
29421
+ if (item.depth > (context2.limits.xmlDepth ?? Infinity)) throw new SsconvertError("resource-limit", "ssconvert hyperlink depth limit exceeded");
29422
+ const updated = { ...node3 };
29423
+ item.assign(updated);
29424
+ const attributes4 = odfObject(node3.attributes);
29425
+ const list = Array.isArray(node3.attributes) ? node3.attributes : [];
29426
+ const field = (name5, namespace5) => {
29427
+ if (attributes4 && !namespace5 && typeof attributes4[name5] === "string") return attributes4[name5];
29428
+ for (const value4 of list) {
29429
+ charge();
29430
+ const attribute5 = odfObject(value4);
29431
+ if (attribute5?.name === name5 && attribute5.namespace === namespace5 && typeof attribute5.value === "string") return attribute5.value;
29432
+ }
29433
+ return void 0;
29434
+ };
29435
+ const link = odf ? node3.name === "a" : node3.name === "HyperLink" && field("type", "") === "GnmHLinkCurWB";
29436
+ if (link) {
29437
+ const name5 = odf ? "href" : "target", namespace5 = odf ? odfNamespaces.xlink : "";
29438
+ const source = field(name5, namespace5);
29439
+ if (source !== void 0) {
29440
+ const rewritten = target(source, odf);
29441
+ updated.attributes = attributes4 ? { ...attributes4, [name5]: rewritten } : list.map((value4) => {
29442
+ charge();
29443
+ const attribute5 = odfObject(value4);
29444
+ return attribute5?.name === name5 && attribute5.namespace === namespace5 ? { ...attribute5, value: rewritten } : value4;
29445
+ });
29446
+ }
29447
+ }
29448
+ const childRole = odf ? void 0 : node3.name === "Styles" ? "StyleRegion" : node3.name === "StyleRegion" ? "Style" : node3.name === "Style" ? "HyperLink" : "";
29449
+ const enqueue = (value4, assign) => {
29450
+ charge();
29451
+ const child7 = odfObject(value4);
29452
+ if (typeof child7?.name === "string") pending.push({ value: value4, role: childRole ?? child7.name, depth: item.depth + 1, assign });
29453
+ };
29454
+ if (Array.isArray(node3.children)) {
29455
+ const children7 = [...node3.children];
29456
+ updated.children = children7;
29457
+ children7.forEach((child7, index2) => enqueue(child7, (next) => {
29458
+ children7[index2] = next;
29459
+ }));
29460
+ }
29461
+ if (odf && Array.isArray(node3.content)) {
29462
+ const content2 = [...node3.content];
29463
+ updated.content = content2;
29464
+ content2.forEach((value4, index2) => {
29465
+ charge();
29466
+ const entry2 = odfObject(value4);
29467
+ if (entry2?.kind === "element" && entry2.index === void 0 && entry2.value !== void 0)
29468
+ enqueue(entry2.value, (next) => {
29469
+ content2[index2] = { ...entry2, value: next };
29470
+ });
29471
+ });
29472
+ }
29473
+ }
29474
+ return result2;
29475
+ }
29476
+ const style2 = (value3) => {
29477
+ charge();
29478
+ return value3?.gnumeric === void 0 ? value3 : { ...value3, gnumeric: xml2(value3.gnumeric, false, "Style", true) };
29479
+ };
29480
+ const sheet = (value3) => ({
29481
+ ...value3,
29482
+ cells: value3.cells.map((cell) => {
29483
+ charge();
29484
+ return { ...cell, ...cell.style ? { style: style2(cell.style) } : {} };
29485
+ }),
29486
+ ...value3.rows ? { rows: value3.rows.map((row) => ({ ...row, ...row.style ? { style: style2(row.style) } : {} })) } : {},
29487
+ ...value3.columns ? { columns: value3.columns.map((column) => ({ ...column, ...column.style ? { style: style2(column.style) } : {} })) } : {},
29488
+ ...value3.unsupportedRecords ? { unsupportedRecords: value3.unsupportedRecords.map((record7) => {
29489
+ charge();
29490
+ if (record7.disposition !== "retained" || record7.data === void 0) return record7;
29491
+ if (record7.source === "Gnumeric_XmlIO:sax" && record7.kind === "Styles") return { ...record7, data: xml2(record7.data, false, "Styles") };
29492
+ if (record7.kind === "p" && (record7.source === "Gnumeric_OpenCalc:openoffice" || record7.source === "odf:cell-content")) {
29493
+ const data4 = odfObject(record7.data);
29494
+ return data4?.xml === void 0 ? { ...record7, data: xml2(record7.data, true, "p") } : { ...record7, data: { ...data4, xml: xml2(data4.xml, true, "p") } };
29495
+ }
29496
+ return record7;
29497
+ }) } : {}
29498
+ });
29499
+ return { ...book, sheets: book.sheets.map(sheet), ...book.detachedSheets ? { detachedSheets: book.detachedSheets.map(sheet) } : {} };
29500
+ }
29501
+
29127
29502
  // packages/safe-bash-command-ssconvert/src/formulas/workbook.ts
29128
29503
  function rewriteWorkbook(book, context2, rewrite) {
29129
29504
  let work = 0;
@@ -29181,14 +29556,14 @@ function renameWorkbookSheet(book, sheetId, name5, context2) {
29181
29556
  if (!sheet || !name5 || name5.includes("\0") || book.sheets.some((s) => s.id !== sheetId && foldSheetName(s.name) === foldSheetName(name5)))
29182
29557
  throw new SsconvertError("invalid-request", "Invalid sheet rename");
29183
29558
  if (sheet.name === name5) return book;
29184
- const renamed = rewriteWorkbook(book, context2, (document6) => {
29559
+ const renamed = rewriteWorkbookHyperlinks(rewriteWorkbook(book, context2, (document6) => {
29185
29560
  const spellings = /* @__PURE__ */ new Map();
29186
29561
  visitFormula(document6.root, (node3) => {
29187
29562
  const names2 = node3.kind === "reference" ? [node3.first.sheet, node3.last?.sheet] : node3.kind === "name" ? [node3.sheet] : [];
29188
29563
  for (const spelling of names2) if (spelling !== void 0 && foldSheetName(spelling) === foldSheetName(sheet.name)) spellings.set(spelling, name5);
29189
29564
  });
29190
29565
  return rewriteReferences(document6, { sheets: spellings, signal: context2.signal });
29191
- });
29566
+ }), /* @__PURE__ */ new Map([[foldSheetName(sheet.name), name5]]), context2);
29192
29567
  return snapshotWorkbook({
29193
29568
  ...renamed,
29194
29569
  sheets: renamed.sheets.map((s) => s.id === sheetId ? { ...s, name: name5 } : s),
@@ -29198,15 +29573,15 @@ function renameWorkbookSheet(book, sheetId, name5, context2) {
29198
29573
  function remapWorkbookSheets(book, mapping, context2) {
29199
29574
  context2.signal.throwIfAborted();
29200
29575
  book = snapshotWorkbook(book, context2.limits);
29201
- const names2 = new Map(book.sheets.map((sheet) => [foldSheetName(sheet.name), mapping.get(sheet.id)?.name ?? sheet.name]));
29202
- const rewritten = rewriteWorkbook(book, context2, (document6) => {
29576
+ const names2 = new Map([...book.sheets, ...book.detachedSheets ?? []].map((sheet) => [foldSheetName(sheet.name), mapping.get(sheet.id)?.name ?? sheet.name]));
29577
+ const rewritten = rewriteWorkbookHyperlinks(rewriteWorkbook(book, context2, (document6) => {
29203
29578
  const spellings = /* @__PURE__ */ new Map();
29204
29579
  visitFormula(document6.root, (node3) => {
29205
29580
  const refs = node3.kind === "reference" ? [node3.first.sheet, node3.last?.sheet] : node3.kind === "name" ? [node3.sheet] : [];
29206
29581
  for (const spelling of refs) if (spelling !== void 0 && names2.has(foldSheetName(spelling))) spellings.set(spelling, names2.get(foldSheetName(spelling)));
29207
29582
  });
29208
29583
  return rewriteReferences(document6, { sheets: spellings, signal: context2.signal });
29209
- });
29584
+ }), names2, context2);
29210
29585
  const id = (value3) => mapping.get(value3)?.id ?? value3;
29211
29586
  const renamedTitles = new Map(book.sheets.flatMap((sheet) => {
29212
29587
  const target = mapping.get(sheet.id);
@@ -35342,7 +35717,7 @@ var german = Object.freeze({
35342
35717
  shortWeekdays: Object.freeze(["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"])
35343
35718
  });
35344
35719
  function formattingLocale(name5) {
35345
- if (["C", "POSIX", "C.UTF-8", "C.utf8", "en_US", "en_US.UTF-8"].includes(name5)) return english;
35720
+ if (["C", "POSIX", "C.UTF-8", "C.utf8", "en_US", "en_US.UTF-8", "en_US.utf8"].includes(name5)) return english;
35346
35721
  if (["de_DE", "de_DE.UTF-8", "de_DE.utf8"].includes(name5)) return german;
35347
35722
  throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: uncaptured format locale");
35348
35723
  }
@@ -51587,7 +51962,7 @@ init_platform();
51587
51962
 
51588
51963
  // packages/safe-bash-command-ssconvert/src/codecs/xlsx-write-support.ts
51589
51964
  init_platform();
51590
- import { parseXmlSteps } from "@poe-platform/safe-fs/core";
51965
+ import { parseXmlSteps as parseXmlSteps2 } from "@poe-platform/safe-fs/core";
51591
51966
 
51592
51967
  // packages/safe-bash-command-ssconvert/src/codecs/xlsx-strings.ts
51593
51968
  init_platform();
@@ -51660,7 +52035,7 @@ function createXlsxXml(context2) {
51660
52035
  try {
51661
52036
  if (parts.length > 2) throw new Error("qualified name");
51662
52037
  for (const part of parts) {
51663
- const parser = parseXmlSteps(`<${part}/>`, { maxNodes: 1, maxAttributes: 1 });
52038
+ const parser = parseXmlSteps2(`<${part}/>`, { maxNodes: 1, maxAttributes: 1 });
51664
52039
  let step = parser.next();
51665
52040
  while (!step.done) step = parser.next();
51666
52041
  if (step.value.name !== part || step.value.namespace || step.value.children.length || step.value.attributes.length)
@@ -52118,7 +52493,7 @@ init_platform();
52118
52493
 
52119
52494
  // packages/safe-bash-command-ssconvert/src/codecs/xlsx.ts
52120
52495
  init_platform();
52121
- import { parseXmlSteps as parseXmlSteps2, XmlLimitError } from "@poe-platform/safe-fs/core";
52496
+ import { parseXmlSteps as parseXmlSteps3, XmlLimitError } from "@poe-platform/safe-fs/core";
52122
52497
 
52123
52498
  // packages/safe-bash-command-ssconvert/src/codecs/xlsx-schema.ts
52124
52499
  init_platform();
@@ -53937,7 +54312,10 @@ var capturedLocales = Object.freeze({
53937
54312
  C: "C",
53938
54313
  POSIX: "C",
53939
54314
  "C.UTF-8": "C.UTF-8",
53940
- "C.utf8": "C.UTF-8"
54315
+ "C.utf8": "C.UTF-8",
54316
+ en_US: "en_US",
54317
+ "en_US.UTF-8": "en_US.UTF-8",
54318
+ "en_US.utf8": "en_US.UTF-8"
53941
54319
  });
53942
54320
  function localeCategory(environment, category) {
53943
54321
  const env2 = environment.env;
@@ -55357,7 +55735,7 @@ async function openPackage(bytes, context2) {
55357
55735
  const text2 = new TextDecoder(encoding, { fatal: true }).decode(plain);
55358
55736
  textBytes += plain.length;
55359
55737
  if (textBytes > (context2.limits.workbookTextBytes ?? bounds2.maxTotalBytes)) limit("XML text");
55360
- const parser = parseXmlSteps2(text2, {
55738
+ const parser = parseXmlSteps3(text2, {
55361
55739
  expectedEncoding: encoding,
55362
55740
  maxDepth: context2.limits.xmlDepth ?? Infinity,
55363
55741
  maxNodes: (context2.limits.workbookNodes ?? Infinity) - nodes,
@@ -74436,7 +74814,8 @@ function encodeText(text2, charset, transliterate, context2) {
74436
74814
  const suffixTransliteration = parts.length > 1 && parts.slice(1).every((part) => part.toLowerCase() === "translit");
74437
74815
  if (suffixTransliteration) transliterate = true;
74438
74816
  const base = suffixTransliteration ? parts[0] : charset;
74439
- const name5 = base === "" ? converterLocale(context2.environment) === "C" ? "ascii" : "utf-8" : encodingName(base);
74817
+ const locale = base === "" ? converterLocale(context2.environment) : void 0;
74818
+ const name5 = base === "" ? locale === "C" ? "ascii" : locale === "en_US" ? "iso-8859-1" : "utf-8" : encodingName(base);
74440
74819
  const admit2 = (length) => {
74441
74820
  context2.signal.throwIfAborted();
74442
74821
  if (length > context2.limits.outputBytes)
@@ -77554,7 +77933,7 @@ function rk(bits3) {
77554
77933
 
77555
77934
  // packages/safe-bash-command-ssconvert/src/codecs/spreadsheetml.ts
77556
77935
  init_platform();
77557
- import { parseXmlSteps as parseXmlSteps3, XmlLimitError as XmlLimitError2 } from "@poe-platform/safe-fs/core";
77936
+ import { parseXmlSteps as parseXmlSteps4, XmlLimitError as XmlLimitError2 } from "@poe-platform/safe-fs/core";
77558
77937
 
77559
77938
  // packages/safe-bash-command-ssconvert/src/codecs/spreadsheetml-metadata.ts
77560
77939
  init_platform();
@@ -77796,7 +78175,7 @@ async function document3(bytes, context2, probe = false) {
77796
78175
  const at = text2.indexOf(declared, encodingAt + 8);
77797
78176
  text2 = text2.slice(0, at) + "UTF-8" + text2.slice(at + declared.length);
77798
78177
  } else text2 = new TextDecoder(encoding, { fatal: true }).decode(bytes);
77799
- const parser = parseXmlSteps3(text2, {
78178
+ const parser = parseXmlSteps4(text2, {
77800
78179
  expectedEncoding: encoding,
77801
78180
  maxDepth: context2.limits.xmlDepth ?? Infinity,
77802
78181
  maxNodes: context2.limits.workbookNodes ?? Infinity,
@@ -86418,6 +86797,13 @@ function probeLotus(bytes, context2) {
86418
86797
  return (b3.u16(0) === 0 || b3.u16(0) === 255) && ([1028, 1029, 1030].includes(version2) ? length === 2 : [4098, 4099, 4100, 4101].includes(version2) && length >= 19);
86419
86798
  }
86420
86799
  var lmbcsDoubleByteCodepages = { 16: 932, 17: 949, 18: 950, 19: 936 };
86800
+ function decodeSheetName(bytes) {
86801
+ const zero = bytes.indexOf(0);
86802
+ return Array.from(zero < 0 ? bytes : bytes.subarray(0, zero), (byte) => {
86803
+ const character = singleByteTables["windows-1252"][byte];
86804
+ return character === "\uFFFF" ? String.fromCharCode(byte) : character;
86805
+ }).join("");
86806
+ }
86421
86807
  async function lmbcs(bytes, group, context2) {
86422
86808
  let text2 = "";
86423
86809
  const warn = async (message) => context2.diagnostic?.({ code: "lotus", severity: "warning", message });
@@ -86882,8 +87268,7 @@ async function readLotus(bytes, context2) {
86882
87268
  consumeOperation();
86883
87269
  if (length < 5) await warn(`Record with type 0x23 has wrong length ${length}.`);
86884
87270
  else {
86885
- const nameBytes = data4.bytes.subarray(4), zero = nameBytes.indexOf(0);
86886
- const name5 = new TextDecoder("windows-1252").decode(zero < 0 ? nameBytes : nameBytes.subarray(0, zero));
87271
+ const name5 = decodeSheetName(data4.bytes.subarray(4));
86887
87272
  if (name5) sheet(data4.u16(2)).name = name5;
86888
87273
  }
86889
87274
  continue;
@@ -87085,8 +87470,7 @@ async function readLotus(bytes, context2) {
87085
87470
  consumeOperation();
87086
87471
  if (length < 5) await warn(`Record with type 0x1b has wrong length ${length}.`);
87087
87472
  else {
87088
- const nameBytes = data4.bytes.subarray(4), zero = nameBytes.indexOf(0);
87089
- const name5 = new TextDecoder("windows-1252").decode(zero < 0 ? nameBytes : nameBytes.subarray(0, zero));
87473
+ const name5 = decodeSheetName(data4.bytes.subarray(4));
87090
87474
  if (name5) sheet(data4.u16(2)).name = name5;
87091
87475
  }
87092
87476
  } else if (subtype === 4001) {
@@ -89980,53 +90364,6 @@ function prepareOdfFormulaLabels(book, context2, tick) {
89980
90364
  return { book, documents: documents2 };
89981
90365
  }
89982
90366
 
89983
- // packages/safe-bash-command-ssconvert/src/codecs/odf-hyperlinks.ts
89984
- init_platform();
89985
- var linkGrammar = { ...excelGrammar, id: "odf-hyperlink", sheetSeparator: "." };
89986
- function translateOdfHyperlink(source, direction2, charge, sheetNames = []) {
89987
- charge(source.length);
89988
- if (direction2 === "normalize" && !source.startsWith("#")) return source;
89989
- function findSheet(name5) {
89990
- const folded = foldSheetName(name5);
89991
- return sheetNames.find((candidate) => {
89992
- charge(candidate.length);
89993
- return foldSheetName(candidate) === folded;
89994
- });
89995
- }
89996
- let target = direction2 !== "export" && source.startsWith("#") ? source.slice(1) : source;
89997
- if (direction2 !== "export") {
89998
- try {
89999
- target = decodeURIComponent(target);
90000
- } catch {
90001
- if (direction2 === "normalize") return source;
90002
- }
90003
- const separator2 = target.indexOf(" (");
90004
- if (separator2 > 0 && target.endsWith(")")) {
90005
- const name5 = target.slice(0, separator2), sheet = findSheet(target.slice(separator2 + 2, -1));
90006
- if (sheet !== void 0) {
90007
- const qualified = quoteNativeSheet(sheet) + "!" + name5;
90008
- const parsed2 = parseExpression("=" + qualified, { position: { sheet, row: 0, column: 0 }, onWork: charge });
90009
- if (parsed2.ok && parsed2.document.root.kind === "name" && parsed2.document.root.name === name5 && parsed2.document.root.sheet === sheet)
90010
- return direction2 === "import" ? qualified : source;
90011
- }
90012
- }
90013
- }
90014
- const parsed = parseExpression("=" + target, {
90015
- grammar: direction2 !== "export" ? linkGrammar : gnumericGrammar,
90016
- position: { sheet: "", row: 0, column: 0 },
90017
- onWork: charge
90018
- });
90019
- if (parsed.ok) {
90020
- const node3 = parsed.document.root;
90021
- if (node3.kind === "name" && node3.workbook === void 0 || node3.kind === "reference" && !node3.label && node3.first.workbook === void 0 && node3.last?.workbook === void 0) {
90022
- const sheet = direction2 !== "import" && node3.kind === "name" && node3.sheet !== void 0 ? findSheet(node3.sheet) : void 0;
90023
- if (sheet !== void 0 && node3.kind === "name") return "#" + encodeURI(node3.name + " (" + sheet + ")");
90024
- if (direction2 !== "normalize") target = serializeExpression(parsed.document, direction2 === "import" ? { ...gnumericGrammar, quoteSheetName: quoteNativeSheet } : linkGrammar, false, true).slice(1);
90025
- }
90026
- }
90027
- return direction2 === "import" ? target : direction2 === "normalize" ? source : "#" + encodeURI(target);
90028
- }
90029
-
90030
90367
  // packages/safe-bash-command-ssconvert/src/codecs/odf-schema.ts
90031
90368
  init_platform();
90032
90369
  var odfReaderStates = {
@@ -90140,6 +90477,7 @@ TEXT_SPAN TEXT_LINE_BREAK OO_NS_TEXT line-break
90140
90477
  TEXT_SPAN TEXT_TAB OO_NS_TEXT tab
90141
90478
  TEXT_SPAN TEXT_ADDR OO_NS_TEXT a
90142
90479
  TEXT_ADDR TEXT_S OO_NS_TEXT s
90480
+ TEXT_ADDR TEXT_LINE_BREAK OO_NS_TEXT line-break
90143
90481
  TEXT_ADDR TEXT_TAB OO_NS_TEXT tab
90144
90482
  TEXT_ADDR TEXT_SPAN OO_NS_TEXT span
90145
90483
  CONTENT_VALIDATION HELP_MESSAGE OO_NS_TABLE help-message
@@ -90583,13 +90921,13 @@ MASTER_PAGE_FOOTER MASTER_PAGE_HF_P OO_NS_TEXT p`
90583
90921
 
90584
90922
  // packages/safe-bash-command-ssconvert/src/codecs/odf-metadata.ts
90585
90923
  init_platform();
90586
- var urn = "urn:oasis:names:tc:opendocument:xmlns:";
90924
+ var urn2 = "urn:oasis:names:tc:opendocument:xmlns:";
90587
90925
  var ns = {
90588
- table: [urn + "table:1.0", "http://openoffice.org/2000/table"],
90589
- office: [urn + "office:1.0", "http://openoffice.org/2000/office"],
90590
- text: [urn + "text:1.0", "http://openoffice.org/2000/text"],
90591
- style: [urn + "style:1.0", "http://openoffice.org/2000/style"],
90592
- fo: [urn + "xsl-fo-compatible:1.0", "http://www.w3.org/1999/XSL/Format"],
90926
+ table: [urn2 + "table:1.0", "http://openoffice.org/2000/table"],
90927
+ office: [urn2 + "office:1.0", "http://openoffice.org/2000/office"],
90928
+ text: [urn2 + "text:1.0", "http://openoffice.org/2000/text"],
90929
+ style: [urn2 + "style:1.0", "http://openoffice.org/2000/style"],
90930
+ fo: [urn2 + "xsl-fo-compatible:1.0", "http://www.w3.org/1999/XSL/Format"],
90593
90931
  dc: ["http://purl.org/dc/elements/1.1/"],
90594
90932
  xlink: ["http://www.w3.org/1999/xlink"],
90595
90933
  gnm: ["http://www.gnumeric.org/odf-extension/1.0"]
@@ -90904,170 +91242,6 @@ function readOdfLabelRanges(parent, sheets, context2, charge) {
90904
91242
  });
90905
91243
  }
90906
91244
 
90907
- // packages/safe-bash-command-ssconvert/src/codecs/odf-write-support.ts
90908
- init_platform();
90909
- import { parseXmlSteps as parseXmlSteps4 } from "@poe-platform/safe-fs/core";
90910
- var urn2 = "urn:oasis:names:tc:opendocument:xmlns:";
90911
- var odfEncryptionNamespace = "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0";
90912
- var odfNamespaces = {
90913
- xml: "http://www.w3.org/XML/1998/namespace",
90914
- office: urn2 + "office:1.0",
90915
- style: urn2 + "style:1.0",
90916
- text: urn2 + "text:1.0",
90917
- table: urn2 + "table:1.0",
90918
- draw: urn2 + "drawing:1.0",
90919
- fo: urn2 + "xsl-fo-compatible:1.0",
90920
- xlink: "http://www.w3.org/1999/xlink",
90921
- dc: "http://purl.org/dc/elements/1.1/",
90922
- meta: urn2 + "meta:1.0",
90923
- number: urn2 + "datastyle:1.0",
90924
- svg: urn2 + "svg-compatible:1.0",
90925
- chart: urn2 + "chart:1.0",
90926
- config: urn2 + "config:1.0",
90927
- form: urn2 + "form:1.0",
90928
- script: urn2 + "script:1.0",
90929
- of: urn2 + "of:1.2",
90930
- manifest: urn2 + "manifest:1.0",
90931
- gnm: "http://www.gnumeric.org/odf-extension/1.0",
90932
- calcext: "urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
90933
- };
90934
- function odfObject(value3) {
90935
- return value3 !== null && typeof value3 === "object" && !Array.isArray(value3) ? value3 : void 0;
90936
- }
90937
- function odfAttributes(value3, namespace5) {
90938
- const source = odfObject(value3)?.attributes;
90939
- if (Array.isArray(source)) return Object.fromEntries(source.flatMap((a3) => {
90940
- const v2 = odfObject(a3);
90941
- return typeof v2?.name === "string" && typeof v2.value === "string" && (namespace5 === void 0 || v2.namespace === namespace5) ? [[v2.name, v2.value]] : [];
90942
- }));
90943
- if (namespace5 !== void 0) return {};
90944
- return Object.fromEntries(Object.entries(odfObject(source) ?? {}).filter((entry2) => typeof entry2[1] === "string"));
90945
- }
90946
- function odfChildren(value3) {
90947
- const source = odfObject(value3)?.children;
90948
- return Array.isArray(source) ? source : [];
90949
- }
90950
- function createOdfXml(context2, extended) {
90951
- let work = 0, nodes = 0;
90952
- const encoder2 = new TextEncoder(), names2 = /* @__PURE__ */ new Set();
90953
- const declarations = {
90954
- ...Object.fromEntries(Object.entries(odfNamespaces).map(([prefix2, uri]) => ["xmlns:" + prefix2, uri])),
90955
- "xmlns:loext": odfEncryptionNamespace
90956
- };
90957
- function charge(amount = 1) {
90958
- context2.signal.throwIfAborted();
90959
- if (!Number.isSafeInteger(amount) || amount < 0 || amount > (context2.limits.workbookWork ?? Infinity) - work)
90960
- throw new SsconvertError("resource-limit", "ssconvert OpenDocument work limit exceeded");
90961
- work += amount;
90962
- }
90963
- function name5(value3) {
90964
- charge(value3.length);
90965
- if (names2.has(value3)) return;
90966
- try {
90967
- const parser = parseXmlSteps4(`<${value3} ${Object.entries(declarations).map(([k, v2]) => `${k}="${v2}"`).join(" ")}/>`, { maxNodes: 1, maxAttributes: 100 });
90968
- let step = parser.next();
90969
- while (!step.done) step = parser.next();
90970
- if (step.value.name !== value3 || step.value.children.length) throw new Error("name");
90971
- } catch {
90972
- throw new SsconvertError("invalid-request", "Invalid OpenDocument XML name");
90973
- }
90974
- names2.add(value3);
90975
- }
90976
- function escape3(value3) {
90977
- charge(value3.length);
90978
- let result2 = "";
90979
- for (const c4 of value3) {
90980
- const code2 = c4.codePointAt(0);
90981
- if (code2 < 32 && !" \n\r".includes(c4) || code2 === 65534 || code2 === 65535 || code2 >= 55296 && code2 <= 57343)
90982
- throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: non-XML OpenDocument character");
90983
- result2 += c4 === "&" ? "&amp;" : c4 === "<" ? "&lt;" : c4 === ">" ? "&gt;" : c4 === '"' ? "&quot;" : c4 === "\r" ? "&#13;" : c4 === "\n" ? "&#10;" : c4 === " " ? "&#9;" : c4;
90984
- }
90985
- return result2;
90986
- }
90987
- function element2(tag3, attributes4 = {}, content2 = "") {
90988
- charge();
90989
- if (++nodes > (context2.limits.workbookNodes ?? Infinity))
90990
- throw new SsconvertError("resource-limit", "ssconvert OpenDocument XML nodes limit exceeded");
90991
- name5(tag3);
90992
- let result2 = "<" + tag3;
90993
- for (const [key2, value3] of Object.entries(attributes4)) if (value3 !== void 0) {
90994
- if (!key2.startsWith("xmlns:")) name5(key2);
90995
- result2 += ` ${key2}="${escape3(String(value3))}"`;
90996
- }
90997
- result2 += content2 ? ">" + content2 + "</" + tag3 + ">" : "/>";
90998
- if (result2.length > context2.limits.outputBytes || encoder2.encode(result2).length > context2.limits.outputBytes)
90999
- throw new SsconvertError("resource-limit", "ssconvert OpenDocument output bytes limit exceeded");
91000
- return result2;
91001
- }
91002
- function text2(value3) {
91003
- charge(value3.length);
91004
- let result2 = "", plain = "";
91005
- function flush() {
91006
- result2 += escape3(plain);
91007
- plain = "";
91008
- }
91009
- for (let i4 = 0; i4 < value3.length; i4++) {
91010
- const c4 = value3[i4];
91011
- if (c4 === " ") {
91012
- flush();
91013
- let count = 1;
91014
- while (value3[i4 + 1] === " ") {
91015
- i4++;
91016
- count++;
91017
- }
91018
- result2 += element2("text:s", count > 1 ? { "text:c": count } : {});
91019
- } else if (c4 === " " || c4 === "\n") {
91020
- flush();
91021
- result2 += element2(c4 === " " ? "text:tab" : "text:line-break");
91022
- } else plain += c4;
91023
- }
91024
- flush();
91025
- return result2;
91026
- }
91027
- const active = /* @__PURE__ */ new Set();
91028
- function retained2(value3, depth = 0, hyperlink) {
91029
- charge();
91030
- const v2 = odfObject(value3);
91031
- if (!v2 || typeof v2.name !== "string" || typeof v2.namespace !== "string") return "";
91032
- if (depth > (context2.limits.xmlDepth ?? Infinity)) throw new SsconvertError("resource-limit", "ssconvert OpenDocument metadata depth limit exceeded");
91033
- if (active.has(v2)) throw new SsconvertError("invalid-request", "Invalid cyclic OpenDocument metadata");
91034
- const prefix2 = Object.entries(odfNamespaces).find(([, uri]) => uri === v2.namespace)?.[0];
91035
- if (!prefix2 || !extended && ["gnm", "calcext"].includes(prefix2)) return "";
91036
- active.add(v2);
91037
- try {
91038
- const attributes4 = {};
91039
- if (Array.isArray(v2.attributes)) for (const a3 of v2.attributes) {
91040
- charge();
91041
- const attribute5 = odfObject(a3);
91042
- if (typeof attribute5?.name !== "string" || typeof attribute5.value !== "string" || typeof attribute5.namespace !== "string") continue;
91043
- const p2 = Object.entries(odfNamespaces).find(([, uri]) => uri === attribute5.namespace)?.[0];
91044
- if (attribute5.namespace && (!p2 || !extended && ["gnm", "calcext"].includes(p2))) continue;
91045
- attributes4[(p2 ? p2 + ":" : "") + attribute5.name] = attribute5.value;
91046
- }
91047
- if (prefix2 === "text" && v2.name === "a" && attributes4["xlink:href"] !== void 0 && hyperlink)
91048
- attributes4["xlink:href"] = hyperlink(attributes4["xlink:href"]);
91049
- const children7 = odfChildren(v2);
91050
- const content2 = Array.isArray(v2.content) ? v2.content.map((c4) => {
91051
- charge();
91052
- const item = odfObject(c4);
91053
- if (item?.kind === "text" && typeof item.text === "string") return escape3(item.text);
91054
- if (item?.kind !== "element") return "";
91055
- if (item.index === void 0) return retained2(item.value, depth + 1, hyperlink);
91056
- if (typeof item.index !== "number" || !Number.isSafeInteger(item.index) || item.index < 0 || item.index >= children7.length)
91057
- throw new SsconvertError("invalid-request", "Invalid OpenDocument metadata child index");
91058
- return retained2(children7[item.index], depth + 1, hyperlink);
91059
- }).join("") : (typeof v2.text === "string" ? escape3(v2.text) : "") + children7.map((c4) => retained2(c4, depth + 1, hyperlink)).join("");
91060
- return element2(prefix2 + ":" + v2.name, attributes4, content2);
91061
- } finally {
91062
- active.delete(v2);
91063
- }
91064
- }
91065
- function document6(tag3, body) {
91066
- return '<?xml version="1.0" encoding="UTF-8"?>\n' + element2(tag3, { ...declarations, "xmlns:loext": void 0, "office:version": "1.2" }, body);
91067
- }
91068
- return { element: element2, escape: escape3, text: text2, retained: retained2, document: document6, charge };
91069
- }
91070
-
91071
91245
  // packages/safe-bash-command-ssconvert/src/codecs/odf-encrypted-write.ts
91072
91246
  init_platform();
91073
91247
  var iterations = 1024;
@@ -93102,8 +93276,9 @@ function createOdfWriter(profile) {
93102
93276
  }
93103
93277
  }
93104
93278
  xml2.charge(originalParagraphs.size);
93105
- const renderedText = cell.displayedText ?? await renderCellText(cell, book, context2), rendered2 = xml2.text(renderedText), paragraph = originalParagraphs.get(key2) ?? [...originalParagraphs.values()].find((p2) => row >= p2.range.startRow && row <= p2.range.endRow && start >= p2.range.startColumn && start <= p2.range.endColumn);
93279
+ const renderedText = cell.displayedText ?? await renderCellText(cell, book, context2), paragraph = originalParagraphs.get(key2) ?? [...originalParagraphs.values()].find((p2) => row >= p2.range.startRow && row <= p2.range.endRow && start >= p2.range.startColumn && start <= p2.range.endColumn);
93106
93280
  const link = meta?.link ?? links.get(key2);
93281
+ const rendered2 = link ? xml2.escape(renderedText) : xml2.text(renderedText);
93107
93282
  content2 += paragraph?.text === renderedText ? paragraph.xml : e("text:p", {}, link ? e("text:a", link, rendered2) : rendered2);
93108
93283
  }
93109
93284
  const next = !cell && !merge && meta ? Math.min(meta.range.endColumn + 1, stops.find((s) => s > start) ?? meta.range.endColumn + 1) : start + 1;
@@ -159349,7 +159524,7 @@ function bounded2(value3, maximum, name5) {
159349
159524
  if (!Number.isSafeInteger(value3) || value3 < 0 || value3 > maximum)
159350
159525
  throw new SsconvertError("resource-limit", `ssconvert ${name5} limit exceeded`);
159351
159526
  }
159352
- function createEngine(supplied) {
159527
+ function createEngine(supplied = {}) {
159353
159528
  const config2 = {
159354
159529
  ...supplied,
159355
159530
  ...supplied.entropy === void 0 ? {} : { entropy: Object.freeze({ read: supplied.entropy.read.bind(supplied.entropy) }) },
@@ -159357,16 +159532,19 @@ function createEngine(supplied) {
159357
159532
  ...supplied.fonts === void 0 ? {} : { fonts: Object.freeze({ resolve: supplied.fonts.resolve.bind(supplied.fonts) }) },
159358
159533
  ...supplied.password === void 0 ? {} : { password: Object.freeze({ read: supplied.password.read.bind(supplied.password) }) },
159359
159534
  ...supplied.runtimeFunctions === void 0 ? {} : { runtimeFunctions: snapshotRuntimeFunctions(supplied.runtimeFunctions) },
159535
+ codecs: supplied.codecs ?? [],
159360
159536
  limits: Object.freeze({ ...defaultSsconvertLimits, ...supplied.limits }),
159361
159537
  environment: Object.freeze({
159362
159538
  ...supplied.environment,
159363
- cwd: supplied.filesystem?.cwd ?? supplied.environment.cwd ?? supplied.environment.env.PWD ?? "/",
159364
- env: Object.freeze({ ...supplied.environment.env })
159539
+ locale: supplied.environment?.locale ?? "C",
159540
+ timezone: supplied.environment?.timezone ?? "UTC",
159541
+ cwd: supplied.filesystem?.cwd ?? supplied.environment?.cwd ?? supplied.environment?.env?.PWD ?? "/",
159542
+ env: Object.freeze({ ...supplied.environment?.env })
159365
159543
  })
159366
159544
  };
159367
159545
  if (config2.datasource && Object.hasOwn(config2.runtimeFunctions ?? {}, "ATL_LAST"))
159368
159546
  throw new TypeError("Conflicting ssconvert datasource runtime function: ATL_LAST");
159369
- if ((supplied.filesystem?.cwd !== void 0 || supplied.environment.cwd !== void 0) && (!config2.environment.cwd.startsWith("/") || config2.environment.cwd.includes("\0")))
159547
+ if ((supplied.filesystem?.cwd !== void 0 || supplied.environment?.cwd !== void 0) && (!config2.environment.cwd.startsWith("/") || config2.environment.cwd.includes("\0")))
159370
159548
  throw new TypeError("ssconvert cwd must be an absolute VFS path");
159371
159549
  for (const name5 of ["inputBytes", "outputBytes", "cells", "sheets", "operations"]) {
159372
159550
  const value3 = config2.limits[name5];
@@ -164094,4 +164272,4 @@ tslib/tslib.js:
164094
164272
  @noble/ciphers/utils.js:
164095
164273
  (*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
164096
164274
  */
164097
- //# sourceMappingURL=chunk-EAUCLWEZ.js.map
164275
+ //# sourceMappingURL=chunk-3ZNXN3XO.js.map