@allyhub/sdk 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/NOTICE +46 -49
- package/dist/dom.d.ts +1 -209
- package/dist/dom.js +1 -1
- package/dist/image.d.ts +2 -0
- package/dist/image.js +2 -0
- package/dist/index.d.ts +1 -21
- package/dist/index.js +1 -1
- package/dist/media.d.ts +1 -5
- package/dist/media.js +1 -1
- package/dist/node_modules/@allyhub/audio/dist/levels.d.ts +4 -5
- package/dist/node_modules/@allyhub/audio/dist/levels.js +1 -1
- package/dist/node_modules/@allyhub/audio/dist/node/ffmpeg.d.ts +1 -6
- package/dist/node_modules/@allyhub/audio/dist/node/ffmpeg.js +1 -1
- package/dist/node_modules/@allyhub/audio/package.json +1 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-file.js +1 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-xml.d.ts +4 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +2 -2
- package/dist/node_modules/@allyhub/chart/dist/chart.d.ts +22 -0
- package/dist/node_modules/@allyhub/chart/dist/chart.js +1 -1
- package/dist/node_modules/@allyhub/chart/package.json +1 -1
- package/dist/node_modules/@allyhub/diagnostics/LICENSE +241 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/fact.d.ts +37 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/fact.js +2 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/index.d.ts +4 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/index.js +2 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/problem.d.ts +43 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/problem.js +2 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/rules.d.ts +30 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/rules.js +2 -0
- package/dist/node_modules/@allyhub/diagnostics/package.json +14 -0
- package/dist/node_modules/@allyhub/formats/dist/contributed.d.ts +126 -0
- package/dist/node_modules/@allyhub/formats/dist/contributed.js +2 -0
- package/dist/node_modules/@allyhub/formats/dist/data/faces.d.ts +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/reference.d.ts +7 -12
- package/dist/node_modules/@allyhub/formats/dist/data/reference.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/script.d.ts +9 -4
- package/dist/node_modules/@allyhub/formats/dist/data/script.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +107 -83
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +185 -8
- package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/website.d.ts +2 -1
- package/dist/node_modules/@allyhub/formats/dist/data/website.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/work.d.ts +42 -0
- package/dist/node_modules/@allyhub/formats/dist/data/work.js +2 -0
- package/dist/node_modules/@allyhub/formats/dist/extension.d.ts +91 -0
- package/dist/node_modules/@allyhub/formats/dist/extension.js +2 -0
- package/dist/node_modules/@allyhub/formats/dist/files.d.ts +51 -0
- package/dist/node_modules/@allyhub/formats/dist/files.js +2 -0
- package/dist/node_modules/@allyhub/formats/dist/index.d.ts +5 -1
- package/dist/node_modules/@allyhub/formats/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/items.d.ts +226 -90
- package/dist/node_modules/@allyhub/formats/dist/items.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/layout.d.ts +7 -1
- package/dist/node_modules/@allyhub/formats/dist/layout.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +96 -42
- package/dist/node_modules/@allyhub/formats/dist/schemas.js +1 -1
- package/dist/node_modules/@allyhub/formats/package.json +1 -1
- package/dist/node_modules/@allyhub/image-draw/LICENSE +241 -0
- package/dist/node_modules/@allyhub/image-draw/dist/context.d.ts +5 -0
- package/dist/node_modules/@allyhub/image-draw/dist/context.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/contrast.d.ts +13 -0
- package/dist/node_modules/@allyhub/image-draw/dist/contrast.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/env.d.ts +112 -0
- package/dist/node_modules/@allyhub/image-draw/dist/env.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/errors.d.ts +20 -0
- package/dist/node_modules/@allyhub/image-draw/dist/errors.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/fonts.d.ts +110 -0
- package/dist/node_modules/@allyhub/image-draw/dist/fonts.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/guards.d.ts +32 -0
- package/dist/node_modules/@allyhub/image-draw/dist/guards.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/hash.d.ts +3 -0
- package/dist/node_modules/@allyhub/image-draw/dist/hash.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/inspect.d.ts +113 -0
- package/dist/node_modules/@allyhub/image-draw/dist/inspect.js +3 -0
- package/dist/node_modules/@allyhub/image-draw/dist/layer-style.d.ts +151 -0
- package/dist/node_modules/@allyhub/image-draw/dist/layer-style.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/paint.d.ts +29 -0
- package/dist/node_modules/@allyhub/image-draw/dist/paint.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/pictures.d.ts +39 -0
- package/dist/node_modules/@allyhub/image-draw/dist/pictures.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/plan.d.ts +52 -0
- package/dist/node_modules/@allyhub/image-draw/dist/plan.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/reads.d.ts +145 -0
- package/dist/node_modules/@allyhub/image-draw/dist/reads.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/shape-path.d.ts +26 -0
- package/dist/node_modules/@allyhub/image-draw/dist/shape-path.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/stage.d.ts +56 -0
- package/dist/node_modules/@allyhub/image-draw/dist/stage.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/styles.d.ts +35 -0
- package/dist/node_modules/@allyhub/image-draw/dist/styles.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/tone.d.ts +53 -0
- package/dist/node_modules/@allyhub/image-draw/dist/tone.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/package.json +14 -0
- package/dist/node_modules/@allyhub/image-measure/LICENSE +241 -0
- package/dist/node_modules/@allyhub/image-measure/dist/contrast.d.ts +43 -0
- package/dist/node_modules/@allyhub/image-measure/dist/contrast.js +2 -0
- package/dist/node_modules/@allyhub/image-measure/dist/layout.d.ts +186 -0
- package/dist/node_modules/@allyhub/image-measure/dist/layout.js +5 -0
- package/dist/node_modules/@allyhub/image-measure/package.json +14 -0
- package/dist/node_modules/@allyhub/image-sdk/LICENSE +241 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/adjustment.d.ts +13 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/adjustment.js +2 -0
- package/dist/{define.d.ts → node_modules/@allyhub/image-sdk/dist/define.d.ts} +21 -4
- package/dist/node_modules/@allyhub/image-sdk/dist/define.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/dom.d.ts +210 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/dom.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/fill.d.ts +21 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/fill.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/group.d.ts +17 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/group.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/index.d.ts +166 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/index.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/media.d.ts +6 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/media.js +2 -0
- package/dist/{messages.d.ts → node_modules/@allyhub/image-sdk/dist/messages.d.ts} +1 -1
- package/dist/node_modules/@allyhub/image-sdk/dist/picture.d.ts +59 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/picture.js +2 -0
- package/dist/{props.d.ts → node_modules/@allyhub/image-sdk/dist/props.d.ts} +4 -4
- package/dist/node_modules/@allyhub/image-sdk/dist/shape.d.ts +34 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/shape.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/stack.d.ts +16 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/stack.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/text-layer.d.ts +38 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/text-layer.js +2 -0
- package/dist/{written.js → node_modules/@allyhub/image-sdk/dist/written.js} +1 -1
- package/dist/node_modules/@allyhub/image-sdk/package.json +19 -0
- package/dist/node_modules/@allyhub/measure/LICENSE +241 -0
- package/dist/node_modules/@allyhub/measure/dist/compare.d.ts +195 -0
- package/dist/node_modules/@allyhub/measure/dist/compare.js +2 -0
- package/dist/node_modules/@allyhub/measure/dist/grain.d.ts +8 -0
- package/dist/node_modules/@allyhub/measure/dist/grain.js +2 -0
- package/dist/node_modules/@allyhub/measure/dist/image.d.ts +16 -0
- package/dist/node_modules/@allyhub/measure/dist/image.js +2 -0
- package/dist/node_modules/@allyhub/measure/dist/index.d.ts +4 -0
- package/dist/node_modules/@allyhub/measure/dist/index.js +2 -0
- package/dist/node_modules/@allyhub/measure/package.json +13 -0
- package/dist/node_modules/@allyhub/ooxml/dist/generated/presets.d.ts +4 -1
- package/dist/node_modules/@allyhub/ooxml/dist/generated/presets.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/geometry/index.d.ts +15 -1
- package/dist/node_modules/@allyhub/ooxml/dist/geometry/index.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
- package/dist/node_modules/@allyhub/piece/LICENSE +241 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/anchors.d.ts +1 -9
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/component.js +1 -1
- package/dist/node_modules/@allyhub/piece/dist/context.d.ts +39 -0
- package/dist/node_modules/@allyhub/piece/dist/context.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/contrast.d.ts +2 -2
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/export.d.ts +27 -10
- package/dist/node_modules/@allyhub/piece/dist/export.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/formats.d.ts +12 -68
- package/dist/node_modules/@allyhub/piece/dist/formats.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/gen.d.ts +104 -0
- package/dist/node_modules/@allyhub/piece/dist/index.d.ts +26 -0
- package/dist/node_modules/@allyhub/piece/dist/index.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/layer-style.d.ts +1558 -0
- package/dist/node_modules/@allyhub/piece/dist/layer-style.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +389 -0
- package/dist/node_modules/@allyhub/piece/dist/layer.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/layout.d.ts +437 -0
- package/dist/node_modules/@allyhub/piece/dist/layout.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/look.d.ts +1 -1
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/media.d.ts +39 -9
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/media.js +1 -1
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/messages.d.ts +6 -0
- package/dist/node_modules/@allyhub/piece/dist/names.d.ts +26 -0
- package/dist/node_modules/@allyhub/piece/dist/names.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/page/console.d.ts +21 -0
- package/dist/node_modules/@allyhub/piece/dist/page/console.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +3 -0
- package/dist/node_modules/@allyhub/piece/dist/page/index.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/page/locate.d.ts +4 -0
- package/dist/node_modules/@allyhub/piece/dist/page/locate.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/picture.d.ts +62 -0
- package/dist/node_modules/@allyhub/piece/dist/picture.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/piece.d.ts +15 -0
- package/dist/node_modules/@allyhub/piece/dist/piece.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/script.d.ts +9 -4
- package/dist/node_modules/@allyhub/piece/dist/script.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/source.d.ts +131 -0
- package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +291 -0
- package/dist/node_modules/@allyhub/piece/dist/stage.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/version.d.ts +15 -0
- package/dist/node_modules/@allyhub/piece/dist/version.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/voice.d.ts +1 -20
- package/dist/node_modules/@allyhub/piece/package.json +18 -0
- package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +271 -0
- package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/app.d.ts +3 -10
- package/dist/node_modules/@allyhub/protocol/dist/app.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/auth.d.ts +19 -1
- package/dist/node_modules/@allyhub/protocol/dist/auth.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.d.ts +337 -0
- package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/cli.d.ts +12 -1
- package/dist/node_modules/@allyhub/protocol/dist/cli.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +155 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +235 -133
- package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/files.d.ts +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/files.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +65 -197
- package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/image.d.ts +8 -0
- package/dist/node_modules/@allyhub/protocol/dist/image.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +6 -0
- package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +6 -6
- package/dist/node_modules/@allyhub/protocol/dist/kinds.d.ts +98 -0
- package/dist/node_modules/@allyhub/protocol/dist/kinds.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/mail.d.ts +274 -0
- package/dist/node_modules/@allyhub/protocol/dist/mail.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +77 -91
- package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/peer.d.ts +59 -0
- package/dist/node_modules/@allyhub/protocol/dist/peer.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/place.d.ts +21 -0
- package/dist/node_modules/@allyhub/protocol/dist/place.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/presence.d.ts +125 -0
- package/dist/node_modules/@allyhub/protocol/dist/presence.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/registry.d.ts +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/routes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/shape.d.ts +35 -0
- package/dist/node_modules/@allyhub/protocol/dist/shape.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/shares.d.ts +2 -8
- package/dist/node_modules/@allyhub/protocol/dist/shares.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +70 -40
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +224 -177
- package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
- package/dist/node_modules/@allyhub/protocol/package.json +5 -1
- package/dist/node_modules/@allyhub/runtimes/dist/bundled.js +1 -1
- package/dist/node_modules/@allyhub/runtimes/dist/declared.d.ts +14 -0
- package/dist/node_modules/@allyhub/runtimes/dist/declared.js +2 -0
- package/dist/node_modules/@allyhub/runtimes/dist/ffmpeg.d.ts +15 -0
- package/dist/node_modules/@allyhub/runtimes/dist/ffmpeg.js +2 -0
- package/dist/node_modules/@allyhub/runtimes/dist/index.d.ts +2 -0
- package/dist/node_modules/@allyhub/runtimes/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/runtimes/dist/packages.js +3 -3
- package/dist/node_modules/@allyhub/runtimes/dist/runtimes.d.ts +1 -0
- package/dist/node_modules/@allyhub/runtimes/dist/runtimes.js +1 -1
- package/dist/node_modules/@allyhub/runtimes/manifest.json +0 -82
- package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery/dist/define.d.ts +2 -0
- package/dist/node_modules/@allyhub/scenery/dist/define.js +1 -1
- package/dist/node_modules/@allyhub/scenery/dist/index.d.ts +2 -2
- package/dist/node_modules/@allyhub/scenery/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/scenery/dist/moire.d.ts +45 -5
- package/dist/node_modules/@allyhub/scenery/dist/moire.js +2 -2
- package/dist/node_modules/@allyhub/scenery/dist/phone.d.ts +4 -3
- package/dist/node_modules/@allyhub/scenery/dist/phone.js +1 -1
- package/dist/node_modules/@allyhub/scenery/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/capabilities.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/code.d.ts +4 -4
- package/dist/node_modules/@allyhub/sheet/dist/api/code.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/workbook.d.ts +15 -11
- package/dist/node_modules/@allyhub/sheet/dist/api/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/coerce.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/engine.d.ts +70 -0
- package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.d.ts +6 -0
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/date.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/define.d.ts +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/define.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/info.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/kernels.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/lookup.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/maths.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/text.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/indexes.d.ts +9 -0
- package/dist/node_modules/@allyhub/sheet/dist/calc/indexes.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/server.d.ts +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/types.d.ts +6 -0
- package/dist/node_modules/@allyhub/sheet/dist/calc/types.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/chart.d.ts +9 -0
- package/dist/node_modules/@allyhub/sheet/dist/chart.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/export.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/file.d.ts +5 -0
- package/dist/node_modules/@allyhub/sheet/dist/file.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/ast.d.ts +12 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/move.d.ts +5 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/move.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/parse.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/print.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/generated.d.ts +5 -19
- package/dist/node_modules/@allyhub/sheet/dist/generated.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/import.d.ts +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/import.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/index.d.ts +5 -5
- package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/inspect.d.ts +88 -3
- package/dist/node_modules/@allyhub/sheet/dist/inspect.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/patch.d.ts +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/patch.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/printed.d.ts +19 -0
- package/dist/node_modules/@allyhub/sheet/dist/printed.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/sdk.d.ts +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/sdk.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/values.d.ts +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/values.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/workbook.d.ts +8 -6
- package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/write.js +15 -15
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.d.ts +6 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/formula.js +2 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.d.ts +2 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.d.ts +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/sax.d.ts +7 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/sax.js +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.d.ts +6 -0
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.d.ts +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/xml.d.ts +12 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/xml.js +3 -2
- package/dist/node_modules/@allyhub/sheet/package.json +5 -1
- package/dist/node_modules/@allyhub/slides-core/dist/animation.d.ts +23 -7
- package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/api.d.ts +101 -11
- package/dist/node_modules/@allyhub/slides-core/dist/api.js +2 -2
- package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/chart-api.d.ts +18 -1
- package/dist/node_modules/@allyhub/slides-core/dist/chart-api.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/code.d.ts +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/connect.d.ts +62 -0
- package/dist/node_modules/@allyhub/slides-core/dist/connect.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/enums.d.ts +24 -0
- package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/fact.d.ts +223 -0
- package/dist/node_modules/@allyhub/slides-core/dist/fact.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/file.d.ts +4 -4
- package/dist/node_modules/@allyhub/slides-core/dist/file.js +2 -2
- package/dist/node_modules/@allyhub/slides-core/dist/index.d.ts +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/measure.d.ts +4 -2
- package/dist/node_modules/@allyhub/slides-core/dist/measure.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/merge.d.ts +5 -5
- package/dist/node_modules/@allyhub/slides-core/dist/merge.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/model.d.ts +25 -4
- package/dist/node_modules/@allyhub/slides-core/dist/office.d.ts +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/path.d.ts +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.d.ts +20 -11
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/sdk.d.ts +18 -0
- package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/stage.d.ts +28 -11
- package/dist/node_modules/@allyhub/slides-core/dist/units.d.ts +3 -6
- package/dist/node_modules/@allyhub/slides-core/dist/units.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/package.json +5 -1
- package/dist/node_modules/@allyhub/video-core/dist/audio-types.d.ts +1 -2
- package/dist/node_modules/@allyhub/video-core/dist/captions.d.ts +1 -10
- package/dist/node_modules/@allyhub/video-core/dist/captions.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/check.d.ts +62 -0
- package/dist/node_modules/@allyhub/video-core/dist/check.js +2 -0
- package/dist/node_modules/@allyhub/video-core/dist/cut-report.d.ts +2 -2
- package/dist/node_modules/@allyhub/video-core/dist/cut-report.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/edits.d.ts +3 -3
- package/dist/node_modules/@allyhub/video-core/dist/edits.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/fact.d.ts +21 -762
- package/dist/node_modules/@allyhub/video-core/dist/fact.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/footage-motion.d.ts +3 -2
- package/dist/node_modules/@allyhub/video-core/dist/footage-motion.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/index.d.ts +3 -17
- package/dist/node_modules/@allyhub/video-core/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/measure.d.ts +72 -423
- package/dist/node_modules/@allyhub/video-core/dist/measure.js +1 -4
- package/dist/node_modules/@allyhub/video-core/dist/mix-plan.d.ts +44 -0
- package/dist/node_modules/@allyhub/video-core/dist/mix-plan.js +2 -0
- package/dist/node_modules/@allyhub/video-core/dist/motion.d.ts +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/piece.d.ts +24 -432
- package/dist/node_modules/@allyhub/video-core/dist/piece.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/placement.d.ts +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/schema.d.ts +8 -14
- package/dist/node_modules/@allyhub/video-core/dist/schema.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/script-edit.d.ts +11 -6
- package/dist/node_modules/@allyhub/video-core/dist/script-edit.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/seams.d.ts +2 -3
- package/dist/node_modules/@allyhub/video-core/dist/sound-under.d.ts +2 -2
- package/dist/node_modules/@allyhub/video-core/dist/sound-under.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/speech.d.ts +2 -4
- package/dist/node_modules/@allyhub/video-core/dist/speech.js +2 -2
- package/dist/node_modules/@allyhub/video-core/dist/stage.d.ts +52 -0
- package/dist/node_modules/@allyhub/video-core/dist/stage.js +2 -0
- package/dist/node_modules/@allyhub/video-core/dist/timeline.d.ts +18 -136
- package/dist/node_modules/@allyhub/video-core/dist/timeline.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/timing.d.ts +3 -3
- package/dist/node_modules/@allyhub/video-core/dist/timing.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/transcript.d.ts +2 -2
- package/dist/node_modules/@allyhub/video-core/dist/transcript.js +1 -1
- package/dist/node_modules/@allyhub/video-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-sdk/LICENSE +241 -0
- package/dist/node_modules/@allyhub/video-sdk/NOTICE +118 -0
- package/dist/{free.d.ts → node_modules/@allyhub/video-sdk/dist/free.d.ts} +14 -10
- package/dist/node_modules/@allyhub/video-sdk/dist/free.js +2 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/index.d.ts +28 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/index.js +2 -0
- package/dist/{input.d.ts → node_modules/@allyhub/video-sdk/dist/input.d.ts} +76 -22
- package/dist/node_modules/@allyhub/video-sdk/dist/input.js +2 -0
- package/dist/{module.d.ts → node_modules/@allyhub/video-sdk/dist/module.d.ts} +6 -4
- package/dist/node_modules/@allyhub/video-sdk/dist/module.js +2 -0
- package/dist/{parts.d.ts → node_modules/@allyhub/video-sdk/dist/parts.d.ts} +15 -6
- package/dist/node_modules/@allyhub/video-sdk/dist/parts.js +2 -0
- package/dist/{phone.d.ts → node_modules/@allyhub/video-sdk/dist/phone.d.ts} +12 -5
- package/dist/node_modules/@allyhub/video-sdk/dist/phone.js +2 -0
- package/dist/{piece.d.ts → node_modules/@allyhub/video-sdk/dist/piece.d.ts} +26 -16
- package/dist/node_modules/@allyhub/video-sdk/dist/piece.js +2 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/route.d.ts +46 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/route.js +2 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/scenery.d.ts +2 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/scenery.js +2 -0
- package/dist/node_modules/@allyhub/video-sdk/package.json +19 -0
- package/dist/scenery.d.ts +1 -1
- package/dist/scenery.js +1 -1
- package/dist/sheets.d.ts +1 -1
- package/dist/sheets.js +1 -1
- package/dist/slides.d.ts +1 -9
- package/dist/slides.js +1 -1
- package/docs/README.md +10 -6
- package/docs/batches.md +5 -5
- package/docs/canvas.md +28 -0
- package/docs/contract.md +2 -2
- package/docs/defaults.md +298 -22
- package/docs/docs.md +80 -66
- package/docs/footage.md +7 -7
- package/docs/image.md +165 -0
- package/docs/layers.md +22 -13
- package/docs/modeling.md +4 -4
- package/docs/pictures.md +65 -0
- package/docs/project.md +51 -31
- package/docs/scenery.md +14 -15
- package/docs/sheets.md +46 -28
- package/docs/slides.md +121 -67
- package/docs/sound.md +3 -3
- package/docs/speech.md +8 -8
- package/docs/video.md +16 -13
- package/docs/websites.md +4 -4
- package/docs/x.md +73 -0
- package/package.json +7 -2
- package/dist/define.js +0 -2
- package/dist/free.js +0 -2
- package/dist/input.js +0 -2
- package/dist/module.js +0 -2
- package/dist/node_modules/@allyhub/formats/dist/data/comments.d.ts +0 -94
- package/dist/node_modules/@allyhub/formats/dist/data/comments.js +0 -2
- package/dist/node_modules/@allyhub/runtimes/pins/onnxruntime-node/package-lock.json +0 -227
- package/dist/node_modules/@allyhub/runtimes/pins/onnxruntime-node/package.json +0 -8
- package/dist/node_modules/@allyhub/runtimes/pins/sherpa-onnx-node/package-lock.json +0 -105
- package/dist/node_modules/@allyhub/runtimes/pins/sherpa-onnx-node/package.json +0 -8
- package/dist/node_modules/@allyhub/runtimes/pins/tesseract.js/package-lock.json +0 -128
- package/dist/node_modules/@allyhub/runtimes/pins/tesseract.js/package.json +0 -9
- package/dist/node_modules/@allyhub/video-core/dist/export.js +0 -2
- package/dist/node_modules/@allyhub/video-core/dist/formats.js +0 -2
- package/dist/node_modules/@allyhub/video-core/dist/gen.d.ts +0 -37
- package/dist/node_modules/@allyhub/video-core/dist/problem.d.ts +0 -278
- package/dist/node_modules/@allyhub/video-core/dist/problem.js +0 -2
- package/dist/node_modules/@allyhub/video-core/dist/script.js +0 -2
- package/dist/node_modules/@allyhub/video-core/dist/source.d.ts +0 -7
- package/dist/parts.js +0 -2
- package/dist/phone.js +0 -2
- package/dist/piece.js +0 -2
- /package/dist/node_modules/@allyhub/{sheet → formats}/dist/csv.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{sheet → formats}/dist/csv.js +0 -0
- /package/dist/{fit.d.ts → node_modules/@allyhub/image-sdk/dist/fit.d.ts} +0 -0
- /package/dist/{fit.js → node_modules/@allyhub/image-sdk/dist/fit.js} +0 -0
- /package/dist/{messages.js → node_modules/@allyhub/image-sdk/dist/messages.js} +0 -0
- /package/dist/{props.js → node_modules/@allyhub/image-sdk/dist/props.js} +0 -0
- /package/dist/{text.d.ts → node_modules/@allyhub/image-sdk/dist/text.d.ts} +0 -0
- /package/dist/{text.js → node_modules/@allyhub/image-sdk/dist/text.js} +0 -0
- /package/dist/{written.d.ts → node_modules/@allyhub/image-sdk/dist/written.d.ts} +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/anchors.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/component.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/console.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/console.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/contrast.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/gen.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/look.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/marks.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/marks.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/matrix.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/matrix.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/messages.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/source.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/voice.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/words.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/words.js +0 -0
- /package/dist/{anim.d.ts → node_modules/@allyhub/video-sdk/dist/anim.d.ts} +0 -0
- /package/dist/{anim.js → node_modules/@allyhub/video-sdk/dist/anim.js} +0 -0
- /package/dist/{noise.d.ts → node_modules/@allyhub/video-sdk/dist/noise.d.ts} +0 -0
- /package/dist/{noise.js → node_modules/@allyhub/video-sdk/dist/noise.js} +0 -0
- /package/dist/{paths.d.ts → node_modules/@allyhub/video-sdk/dist/paths.d.ts} +0 -0
- /package/dist/{paths.js → node_modules/@allyhub/video-sdk/dist/paths.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import*as
|
|
2
|
+
import*as X from"@formulajs/formulajs";import{CellError as u,ERR as l,errorOf as k,numberText as g}from"../../values.js";import{Missing as y}from"../types.js";import{toBool as B,toNumber as N,toText as h}from"../coerce.js";import{alias as V,cellsOf as b,eachArg as x,numbersOf as H,numbersOfA as j,raw as D,scalar as d}from"./define.js";const w=X;function m(n){const t=n.split(".").reduce((r,e)=>r?.[e],w);if(typeof t!="function")throw new Error(`@formulajs/formulajs has no ${n}.`);return t}function v(n){return typeof n=="number"?Number.isFinite(n)?n:l.NUM:n instanceof Error?k(n.message)??l.VALUE:typeof n=="boolean"||typeof n=="string"?n:l.VALUE}const L=(n,t)=>{try{return v(n(...t))}catch{return l.VALUE}};function K(n,t){return H([n],t)}function Q(n,t){const r=b(n,t);if(r instanceof u)return r;const e=[];for(let f=0;f<r.rows;f++){const s=[];for(let E=0;E<r.cols;E++){const o=r.at(f,E);if(o instanceof u)return o;s.push(typeof o=="number"?o:0)}e.push(s)}return e}function c(n,t,r){const e=t.split("?")[0]?.length??0,f=t.replace("?",""),s=m(r);d(n,e,f.length,(...E)=>{const o=[];for(const[i,I]of E.entries()){if(I===void 0){o.push(void 0);continue}const R=f.charAt(i),a=R==="n"?N(I):R==="b"?B(I):h(I);if(a instanceof u)return a;o.push(a)}return L(s,o)},{from:"formulajs"})}function O(n,t,r){const e=t.replace("?",""),f=e.endsWith("r"),s=m(r),E=Array.from({length:t.length},(o,i)=>{const I=t.charAt(i);return I==="?"?"?":f&&i===t.length-1?"(r)":"lm".includes(I)?"r":"v"}).join("");D(n,E,(o,i)=>{const I=[];for(const[R,a]of o.entries()){const P=f&&R>=e.length-1?"r":e.charAt(R);if(P==="r"){const A=H(o.slice(R),i);if(A instanceof u)return A;I.push(A);break}if(a instanceof y){I.push(void 0);continue}let T;if(P==="l")T=K(a,i);else if(P==="m")T=Q(a,i);else{const A=i.calc.scalar(a,i.frame);T=P==="n"?N(A):P==="b"?B(A):h(A)}if(T instanceof u)return T;I.push(T)}return L(s,I)},{from:"formulajs"})}function M(n,t,r="",e=1){const f=m(t),s=r.length;D(n,`${"v".repeat(s)}rr`,(E,o)=>{const i=[];for(const A of E.slice(0,s)){const S=N(o.calc.scalar(A,o.frame));if(S instanceof u)return S;i.push(S)}const I=b(E[s],o),R=b(E[s+1],o);if(I instanceof u)return I;if(R instanceof u)return R;if(I.rows*I.cols!==R.rows*R.cols)return l.NA;const a=[],P=[];for(let A=0;A<I.rows;A++)for(let S=0;S<I.cols;S++){const p=I.at(A,S),U=R.rows===I.rows?R.at(A,S):R.at(S,A);if(p instanceof u)return p;if(U instanceof u)return U;typeof p=="number"&&typeof U=="number"&&(a.push(p),P.push(U))}if(a.length<e)return l.DIV0;const T=L(f,[...i,a,P]);return T===l.NUM?l.DIV0:T},{from:"formulajs"})}function C(n,t,r=!1,e=1,f=l.DIV0){const s=m(t);D(n,"(r)",(E,o)=>{const i=r?j(E,o):H(E,o);if(i instanceof u)return i;if(i.length<e)return f;const I=L(s,[i]);return I===l.NUM&&f===l.DIV0?l.DIV0:I},{from:"formulajs"})}function G(n){const t=/^([+-]?[\d.]+(?:e[+-]?\d+)?)?(?:([+-]?)([\d.]+(?:e[+-]?\d+)?)?([ij]))?$/iu.exec(n);if(!t)return n;const[,r,e,f,s]=t,E=r===void 0?"":g(Number(r));if(s===void 0)return E;const o=f===void 0?"":g(Number(f));return`${E}${e??""}${o==="1"?"":o}${s}`}function F(n,t){const r=m(n);d(n,t.length,t.length,(...e)=>{const f=[];for(const[E,o]of e.entries()){const i=t.charAt(E)==="n"?N(o):h(o);if(i instanceof u)return i;f.push(i)}const s=L(r,f);return typeof s=="string"?G(s):s},{from:"formulajs"})}for(const n of["ABS","ACOS","ACOSH","ACOT","ACOTH","ASIN","ASINH","ATAN","ATANH","COS","COSH","COT","COTH","CSC","CSCH","DEGREES","EVEN","EXP","INT","LN","LOG10","ODD","RADIANS","SEC","SECH","SIGN","SIN","SINH","SQRT","SQRTPI","TAN","TANH"])c(n,"n",n);for(const n of["COMBIN","COMBINA","MROUND","PERMUT","PERMUTATIONA","POWER"])c(n,"nn",n);c("TRUNC","n?n","TRUNC"),c("CEILING","nn","CEILING"),d("FLOOR",2,2,(n,t)=>{const r=N(n??0);if(r instanceof u)return r;const e=N(t??0);return e instanceof u?e:r===0&&e===0?0:L(m("FLOOR"),[r,e])}),c("CEILING.MATH","n?nn","CEILINGMATH"),c("FLOOR.MATH","n?nn","FLOORMATH"),c("CEILING.PRECISE","n?n","CEILINGPRECISE"),c("FLOOR.PRECISE","n?n","FLOORPRECISE"),V("ISO.CEILING","CEILING.PRECISE"),d("PI",0,0,()=>Math.PI),D("RAND","",(n,t)=>t.calc.random(),{volatile:!0}),D("RANDBETWEEN","vv",(n,t)=>{const r=N(t.calc.scalar(n[0],t.frame)),e=N(t.calc.scalar(n[1],t.frame));if(r instanceof u)return r;if(e instanceof u)return e;const f=Math.ceil(r),s=Math.floor(e);return f>s?l.NUM:f+Math.floor(t.calc.random()*(s-f+1))},{volatile:!0}),C("MULTINOMIAL","MULTINOMIAL"),C("AVEDEV","AVEDEV",!1,1,l.NUM),C("DEVSQ","DEVSQ",!1,1,l.NUM),C("MEDIAN","MEDIAN",!1,1,l.NUM),C("SKEW","SKEW",!1,3),C("SKEW.P","SKEW.P",!1,3),C("STDEV.S","STDEV.S",!1,2),C("STDEV.P","STDEV.P",!1,1),C("VAR.S","VAR.S",!1,2),C("VAR.P","VAR.P",!1,1),C("STDEVA","STDEVA",!0,2),C("STDEVPA","STDEVPA",!0,1),C("VARA","VARA",!0,2),C("VARPA","VARPA",!0,1);for(const[n,t]of[["STDEV","STDEV.S"],["STDEVP","STDEV.P"],["VAR","VAR.S"],["VARP","VAR.P"]])V(n,t);O("PERCENTILE.INC","ln","PERCENTILE.INC"),O("PERCENTILE.EXC","ln","PERCENTILE.EXC"),O("PERCENTRANK.INC","ln?n","PERCENTRANK.INC"),O("PERCENTRANK.EXC","ln?n","PERCENTRANK.EXC"),O("QUARTILE.EXC","ln","QUARTILE.EXC"),D("TRIMMEAN","rv",(n,t)=>{const r=H([n[0]],t);if(r instanceof u)return r;const e=N(t.calc.scalar(n[1],t.frame));if(e instanceof u)return e;if(e<0||e>=1||r.length===0)return l.NUM;const f=Math.floor(r.length*e/2),s=[...r].sort((E,o)=>E-o).slice(f,r.length-f);return s.reduce((E,o)=>E+o,0)/s.length}),V("PERCENTILE","PERCENTILE.INC"),V("PERCENTRANK","PERCENTRANK.INC"),M("CORREL","CORREL"),M("PEARSON","PEARSON"),M("RSQ","RSQ"),M("SLOPE","SLOPE"),M("INTERCEPT","INTERCEPT"),M("STEYX","STEYX","",3),M("COVARIANCE.P","COVARIANCE.P"),M("COVARIANCE.S","COVARIANCE.S","",2),M("FORECAST","FORECAST","n"),V("FORECAST.LINEAR","FORECAST"),V("COVAR","COVARIANCE.P"),c("PV","nnn?nn","PV"),c("NPER","nnn?nn","NPER"),c("RATE","nnn?nnn","RATE"),c("SYD","nnnn","SYD"),c("DDB","nnnn?n","DDB"),c("ISPMT","nnnn","ISPMT"),c("EFFECT","nn","EFFECT"),c("NOMINAL","nn","NOMINAL"),c("CUMIPMT","nnnnnn","CUMIPMT"),c("CUMPRINC","nnnnnn","CUMPRINC"),c("DOLLARDE","nn","DOLLARDE"),c("DOLLARFR","nn","DOLLARFR"),c("PDURATION","nnn","PDURATION"),c("RRI","nnn","RRI"),O("IRR","l?n","IRR"),O("MIRR","lnn","MIRR"),O("NPV","nr","NPV"),O("FVSCHEDULE","nl","FVSCHEDULE");for(const n of["BIN2DEC","HEX2DEC","OCT2DEC","IMABS","IMAGINARY","IMARGUMENT","IMREAL"])c(n,"t",n);for(const n of["IMCONJUGATE","IMCOS","IMCOSH","IMCOT","IMCSC","IMCSCH","IMEXP","IMLN","IMLOG10","IMLOG2","IMSEC","IMSECH","IMSIN","IMSINH","IMSQRT","IMTAN"])F(n,"t");for(const n of["BIN2OCT","HEX2BIN","HEX2OCT","OCT2BIN"])c(n,"t?n",n);for(const n of["DEC2BIN","DEC2OCT"])c(n,"n?n",n);for(const[n,t]of[["BIN2HEX","t"],["OCT2HEX","t"],["DEC2HEX","n"]]){const r=m(n);d(n,1,2,(e,f)=>{const s=t==="n"?N(e):h(e);if(s instanceof u)return s;const E=f===void 0?void 0:N(f);if(E instanceof u)return E;const o=L(r,[s,E]);return typeof o=="string"?o.toUpperCase():o},{from:"formulajs"})}F("IMDIV","tt"),F("IMSUB","tt"),F("IMPOWER","tn"),c("COMPLEX","nn?t","COMPLEX"),c("DECIMAL","tn","DECIMAL"),c("ARABIC","t","ARABIC");for(const n of["IMSUM","IMPRODUCT"]){const t=m(n);D(n,"(r)",(r,e)=>{const f=[];let s;if(x(r,e,o=>{if(s||o===null)return;const i=h(o);i instanceof u?s=i:f.push(i)}),s)return s;const E=L(t,f);return typeof E=="string"?G(E):E},{from:"formulajs"})}c("DELTA","n?n","DELTA"),c("GESTEP","n?n","GESTEP");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{CellError as a,ERR as
|
|
2
|
+
import{CellError as a,ERR as p,Matrix as k}from"../../values.js";import{cellName as K,columnLetter as g,MAX_COLUMNS as W,MAX_ROWS as L}from"../../address.js";import{sheetPrefix as q}from"../../formula/print.js";import{parseFormula as G}from"../../formula/parse.js";import{compare as v,toBool as U,toNumber as M,toText as H}from"../coerce.js";import{Missing as O,Reference as x,Union as F}from"../types.js";import{cellsOf as R,lazy as J,raw as A,scalar as Q}from"./define.js";import{indexKeyOf as Y}from"../indexes.js";import{hasWildcard as Z,indexKey as C,literalOf as nn,wildcard as tn}from"./criteria.js";const I=(n,t)=>typeof n==typeof t&&!(n instanceof a)&&n!==null;function T(n){if(n.rows===1)return{length:n.cols,at:t=>n.at(0,t)};if(n.cols===1)return{length:n.rows,at:t=>n.at(t,0)}}const P=new WeakMap;function en(n,t){const e=P.get(n);if(e)return e;if(e===void 0){P.set(n,null);return}const o=t();return P.set(n,o),o}function V(n,t,e,o,r,s=0,c=1){const f=typeof n=="string"?n:void 0,i=r&&f!==void 0&&Z(f)?nn(f):f;if(f!==void 0&&i===void 0){const l=tn(f);for(let d=s;d>=0&&d<t.length;d+=c){const h=t.at(d);if(typeof h=="string"&&l(h))return d}return-1}const u=C(i??n);if(u===void 0)return-1;if(t.length>=64&&s===0&&c===1){const l=()=>{const w=new Map;for(let m=t.length-1;m>=0;m--){const E=C(t.at(m));E!==void 0&&w.set(E,[m])}return w},d=e.reference,h=d?o.calc.indexes.ofRepeated(Y("find",d),[d],l):e.array&&en(e.array,l);if(h)return h.get(u)?.[0]??-1}for(let l=s;l>=0&&l<t.length;l+=c)if(C(t.at(l))===u)return l;return-1}function N(n,t,e=!1){let o=0,r=t.length-1,s=-1;for(;o<=r;){const c=o+r>>1;let f=c;for(;f>=o&&!I(t.at(f),n);)f-=1;if(f<o){o=c+1;continue}const i=v(t.at(f),n);(e?i>=0:i<=0)?(s=f,o=c+1):r=f-1}return s}const y=(n,t)=>t.calc.scalar(n??null,t.frame),rn=(n,t,e)=>n===void 0?e:n instanceof O?!1:U(t.calc.scalar(n,t.frame));function X(n){return(t,e)=>{const o=y(t[0],e);if(o instanceof a)return o;const r=R(t[1],e);if(r instanceof a)return r;const s=M(e.calc.scalar(t[2],e.frame));if(s instanceof a)return s;const c=Math.trunc(s);if(c<1)return p.VALUE;if(c>(n?r.cols:r.rows))return p.REF;const f=rn(t[3],e,!0);if(f instanceof a)return f;const i={length:n?r.rows:r.cols,at:d=>n?r.at(d,0):r.at(0,d)},u={rows:n?r.rows:1,cols:n?1:r.cols,at:(d,h)=>r.at(d,h),...r.reference?{reference:new x(r.reference.sheet,r.reference.top,r.reference.left,n?r.reference.bottom:r.reference.top,n?r.reference.left:r.reference.right)}:{}},l=f?N(o,i):V(o,i,u,e,!0);return l<0?p.NA:n?r.at(l,c-1):r.at(c-1,l)}}A("VLOOKUP","vrv?v",X(!0)),A("HLOOKUP","vrv?v",X(!1)),A("MATCH","vr?v",(n,t)=>{const e=y(n[0],t);if(e instanceof a)return e;const o=R(n[1],t);if(o instanceof a)return o;const r=T(o);if(!r)return p.NA;const s=n[2]===void 0?1:n[2]instanceof O?0:M(t.calc.scalar(n[2],t.frame));if(s instanceof a)return s;const c=s===0?V(e,r,o,t,!0):N(e,r,s<0);return c<0?p.NA:c+1}),A("LOOKUP","vr?r",(n,t)=>{const e=y(n[0],t);if(e instanceof a)return e;const o=R(n[1],t);if(o instanceof a)return o;const r=o.rows>=o.cols,s={length:r?o.rows:o.cols,at:u=>r?o.at(u,0):o.at(0,u)},c=N(e,s);if(c<0)return p.NA;if(n[2]===void 0)return r?o.at(c,o.cols-1):o.at(o.rows-1,c);const f=R(n[2],t);if(f instanceof a)return f;const i=T(f);return i?i.at(c):p.NA});function D(n,t,e,o,r){const s=T(t);if(!s)return-1;const c=r===-1;if(Math.abs(r)===2){const l=N(n,s,r<0);if(l>=0&&v(s.at(l),n)===0)return l;if(o===0)return-1}const i=V(n,s,t,e,o===2,c?s.length-1:0,c?-1:1);if(i>=0||o===0||o===2)return i;let u=-1;for(let l=0;l<s.length;l++){const d=s.at(l);if(!I(d,n))continue;const h=v(d,n),w=u<0||(o<0?v(d,s.at(u))>0:v(d,s.at(u))<0);(o<0?h<0:h>0)&&w&&(u=l)}return u}const _=(n,t,e)=>{const o=(c,f)=>c===void 0||c instanceof O?f:M(e.calc.scalar(c,e.frame)),r=o(n,0);if(r instanceof a)return r;const s=o(t,1);return s instanceof a?s:[r,s]};A("XLOOKUP","vrr?rvv",(n,t)=>{const e=y(n[0],t);if(e instanceof a)return e;const o=R(n[1],t);if(o instanceof a)return o;const r=R(n[2],t);if(r instanceof a)return r;const s=_(n[4],n[5],t);if(s instanceof a)return s;const c=D(e,o,t,s[0],s[1]);if(c<0){const i=n[3];return i===void 0||i instanceof O?p.NA:t.calc.flat(i)}if(o.cols===1){if(r.cols===1)return r.at(c,0);const i=[];for(let u=0;u<r.cols;u++)i.push(r.at(c,u));return new k(1,r.cols,i)}if(r.rows===1)return r.at(0,c);const f=[];for(let i=0;i<r.rows;i++)f.push(r.at(i,c));return new k(r.rows,1,f)}),A("XMATCH","vr?vv",(n,t)=>{const e=y(n[0],t);if(e instanceof a)return e;const o=R(n[1],t);if(o instanceof a)return o;const r=_(n[2],n[3],t);if(r instanceof a)return r;const s=D(e,o,t,r[0],r[1]);return s<0?p.NA:s+1}),A("INDEX","rv?vv",(n,t)=>{let e=n[0];const o=w=>{if(w===void 0||w instanceof O)return 0;const m=M(t.calc.scalar(w,t.frame));return m instanceof a?m:Math.trunc(m)};if(e instanceof F){const w=o(n[3]??1);if(w instanceof a)return w;const m=e.parts[w-1];if(!m)return p.REF;e=m}if(e instanceof a)return e;const r=o(n[1]);if(r instanceof a)return r;const s=o(n[2]);if(s instanceof a)return s;if(r<0||s<0)return p.VALUE;if(e instanceof x){const w=n[2]===void 0&&e.rows===1,m=w?1:r,E=w?r:s;return m>e.rows||E>e.cols?p.REF:new x(e.sheet,m===0?e.top:e.top+m-1,E===0?e.left:e.left+E-1,m===0?e.bottom:e.top+m-1,E===0?e.right:e.left+E-1)}const c=R(e,t);if(c instanceof a)return c;const f=n[2]===void 0&&c.rows===1,i=f?1:r,u=f?r:s===0&&c.cols===1?1:s;if(i>c.rows||u>c.cols)return p.REF;if(i>0&&u>0)return c.at(i-1,u-1);const l=i===0?c.rows:1,d=u===0?c.cols:1,h=[];for(let w=0;w<l;w++)for(let m=0;m<d;m++)h.push(c.at(i===0?w:i-1,u===0?m:u-1));return new k(l,d,h)}),A("OFFSET","rvv?vv",(n,t)=>{const e=n[0];if(e instanceof a)return e;if(!(e instanceof x))return p.VALUE;const o=(b,B)=>{if(b===void 0||b instanceof O)return B;const S=M(t.calc.scalar(b,t.frame));return S instanceof a?S:Math.trunc(S)},r=o(n[1],0),s=o(n[2],0),c=o(n[3],e.rows),f=o(n[4],e.cols);for(const b of[r,s,c,f])if(b instanceof a)return b;const[i,u,l,d]=[r,s,c,f];if(l===0||d===0)return p.REF;const h=e.top+(i??0),w=e.left+(u??0),m=h+(l??1)-1,E=w+(d??1)-1;return Math.min(h,m)<0||Math.min(w,E)<0||Math.max(h,m)>=L||Math.max(w,E)>=W?p.REF:new x(e.sheet,Math.min(h,m),Math.min(w,E),Math.max(h,m),Math.max(w,E))},{volatile:!0});const on=/^(?:(.*)!)?R(\[-?\d+\]|\d+)?C(\[-?\d+\]|\d+)?(?::R(\[-?\d+\]|\d+)?C(\[-?\d+\]|\d+)?)?$/iu,$=(n,t)=>n===void 0?t:n.startsWith("[")?t+Number(n.slice(1,-1)):Number(n)-1;function sn(n,t,e){const o=on.exec(n.trim());if(!o)return;const[,r,s,c,f,i]=o,u={row:$(s,t),col:$(c,e)};if(u.row<0||u.col<0)return;const l=K(u),d=r===void 0?"":`${r}!`;if(f===void 0&&i===void 0)return`${d}${l}`;const h={row:$(f,t),col:$(i,e)};return h.row<0||h.col<0?void 0:`${d}${l}:${K(h)}`}A("INDIRECT","v?v",(n,t)=>{const e=H(t.calc.scalar(n[0],t.frame));if(e instanceof a)return e;const o=n[1]===void 0?!0:U(t.calc.scalar(n[1],t.frame));if(o instanceof a)return o;const r=o?e:sn(e,t.frame.row,t.frame.col);if(r===void 0)return p.REF;const s=G(r);if(!s.ok)return p.REF;const{node:c}=s;if(c.kind!=="ref"&&c.kind!=="structured"&&c.kind!=="name"&&!(c.kind==="binary"&&c.op===":"))return p.REF;const f=t.calc.eval(c,{...t.frame,dr:0,dc:0});return f instanceof x||f instanceof F?f:p.REF},{volatile:!0});const j=(n,t,e)=>{if(n===void 0||n instanceof O)return t+1;if(n instanceof a)return n;if(!(n instanceof x))return p.VALUE;const[o,r]=e(n);if(r<=1)return o+1;const s=Array.from({length:r},(c,f)=>o+f+1);return e===z?new k(r,1,s):new k(1,r,s)},z=n=>[n.top,n.bottom===L-1?Math.min(n.rows,n.sheet.lastRow-n.top+1):n.rows],cn=n=>[n.left,n.cols];A("ROW","?r",(n,t)=>j(n[0],t.frame.row,z)),A("COLUMN","?r",(n,t)=>j(n[0],t.frame.col,cn)),A("ROWS","r",(n,t)=>{const e=n[0];if(e instanceof x)return e.rows;const o=R(e,t);return o instanceof a?o:o.rows}),A("COLUMNS","r",(n,t)=>{const e=n[0];if(e instanceof x)return e.cols;const o=R(e,t);return o instanceof a?o:o.cols}),A("AREAS","r",n=>{const t=n[0];return t instanceof x?1:t instanceof F?t.parts.length:p.VALUE}),Q("ADDRESS",2,5,(n,t,e,o,r)=>{const s=M(n),c=M(t),f=e==null?1:M(e);for(const b of[s,c,f])if(b instanceof a)return b;const[i,u,l]=[s,c,f];if((i??0)<1||(u??0)<1||(i??0)>L||(u??0)>W)return p.VALUE;const d=o==null?!0:U(o);if(d instanceof a)return d;const h=l===1||l===2,w=l===1||l===3,m=d?`${w?"$":""}${g((u??1)-1)}${h?"$":""}${String(i)}`:`R${h?String(i):`[${String(i)}]`}C${w?String(u):`[${String(u)}]`}`;if(r==null)return m;const E=H(r);return E instanceof a?E:`${q(E)}${m}`}),A("TRANSPOSE","r",(n,t)=>{const e=R(n[0],t);if(e instanceof a)return e;const o=[];for(let r=0;r<e.cols;r++)for(let s=0;s<e.rows;s++)o.push(e.at(s,r));return new k(e.cols,e.rows,o)}),J("SHEET",0,1,(n,t)=>{const e=n[0];if(e===void 0)return t.frame.sheet.index+1;const o=t.calc.eval(e,t.frame);if(o instanceof x)return o.sheet.index+1;const r=t.calc.scalar(o,t.frame);if(typeof r!="string")return p.NA;const s=t.calc.wb.sheet(r);return s?s.index+1:p.NA}),A("SHEETS","?r",(n,t)=>t.calc.wb.sheets.length);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{CellError as a,ERR as l,Matrix as R}from"../../values.js";import{toBool as _,toNumber as A}from"../coerce.js";import{Reference as Q,Union as st}from"../types.js";import{FUNCTIONS as ot,alias as O,cellsOf as v,eachRow as ct,number as U,numbersOf as S,raw as N,scalar as T}from"./define.js";import{besselI as it,besselJ as ft,besselK as at,besselY as ut,betaI as q,gammaQ as lt,normalCdf as ht}from"./special.js";const P=2**48;function K(e,r){const[t="0",n="0"]=e.toExponential().split("e");return+`${t}e${String(Number(n)+r)}`}const Mt=e=>Number(e.toPrecision(15));function C(e,r,t){const n=Math.trunc(r),s=Math.abs(Mt(e)),o=K(s,n);if(o>=2**53)return e;const c=K(t(o),-n);return e<0?-c:c}T("ROUND",2,2,U((e=0,r=0)=>C(e,r,t=>Math.floor(t+.5)))),T("ROUNDUP",2,2,U((e=0,r=0)=>C(e,r,Math.ceil))),T("ROUNDDOWN",2,2,U((e=0,r=0)=>C(e,r,Math.floor))),T("MOD",2,2,U((e=0,r=0)=>{if(r===0)return l.DIV0;const t=e%r;return t!==0&&t<0!=r<0?t+r:t})),T("QUOTIENT",2,2,U((e=0,r=0)=>r===0?l.DIV0:Math.trunc(e/r))),T("POWER",2,2,U((e=0,r=0)=>{if(e===0&&r===0)return l.NUM;if(e===0&&r<0)return l.DIV0;const t=e**r;return Number.isFinite(t)?t:l.NUM})),T("LOG",1,2,(e,r)=>{const t=A(e),n=r==null?10:A(r);return t instanceof a?t:n instanceof a?n:t<=0||n<=0?l.NUM:n===1?l.DIV0:n===10?Math.log10(t):n===2?Math.log2(t):Math.log(t)/Math.log(n)});function X(e,r){let[t,n]=[e,r];for(;n!==0;)[t,n]=[n,t%n];return t}function H(e,r){const t=S(e,r);if(t instanceof a)return t;const n=t.map(Math.trunc);return n.some(s=>s<0||s>=2**53)?l.NUM:n}N("GCD","(r)",(e,r)=>{const t=H(e,r);return t instanceof a?t:t.reduce(X,0)}),N("LCM","(r)",(e,r)=>{const t=H(e,r);if(t instanceof a)return t;if(t.includes(0))return 0;const n=t.reduce((s,o)=>s*o/X(s,o),1);return Number.isFinite(n)?n:l.NUM}),T("BASE",2,3,U((e=0,r=0,t=Number.NaN)=>{const n=Math.trunc(e),s=Math.trunc(r),o=Number.isNaN(t)?0:Math.trunc(t);return n<0||n>=2**53||s<2||s>36||o<0||o>255?l.NUM:n.toString(s).toUpperCase().padStart(o,"0")}));const mt="MDCLXVI",Y=[1e3,500,100,50,10,5,1];function Nt(e,r){const t=f=>Y[f]??1,n=f=>mt.charAt(f),s=Y.length-1;let o=e,c="";for(let f=0;f<=s/2;f++){const i=2*f,u=Math.floor(o/t(i));if(u%5===4){const h=u===4?i-1:i-2;let M=i,m=0;for(;m<r&&M<s;)m+=1,t(h)-t(M+1)<=o?M+=1:m=r;c+=n(M)+n(h),o+=t(M)-t(h)}else u>4&&(c+=n(i-1)),c+=n(i).repeat(u%5),o%=t(i)}return c}T("ROMAN",1,2,(e,r)=>{const t=A(e);if(t instanceof a)return t;let n=0;if(typeof r=="boolean")n=r?0:4;else if(r!=null){const o=A(r);if(o instanceof a)return o;n=Math.trunc(o)}const s=Math.trunc(t);return s<0||s>3999||n<0||n>4?l.VALUE:Nt(s,n)});function B(e){return!Number.isInteger(e)||e<0||e>=P?l.NUM:BigInt(e)}for(const[e,r]of[["BITAND",(t,n)=>t&n],["BITOR",(t,n)=>t|n],["BITXOR",(t,n)=>t^n]])T(e,2,2,U((t=0,n=0)=>{const s=B(t),o=B(n);return s instanceof a?s:o instanceof a?o:Number(r(s,o))}));for(const[e,r]of[["BITLSHIFT",1],["BITRSHIFT",-1]])T(e,2,2,U((t=0,n=0)=>{const s=B(t);if(s instanceof a)return s;const o=Math.trunc(n)*r;if(Math.abs(o)>53)return l.NUM;const c=o>=0?s<<BigInt(o):s>>BigInt(-o);return c>=BigInt(P)?l.NUM:Number(c)}));for(const[e,r,t]of[["BESSELJ",ft,!1],["BESSELI",it,!1],["BESSELY",ut,!0],["BESSELK",at,!0]])T(e,2,2,U((n=0,s=0)=>{const o=Math.trunc(s);if(o<0||t&&n<=0)return l.NUM;const c=r(o,n);return Number.isFinite(c)?c:l.NUM}));T("SLN",3,3,U((e=0,r=0,t=0)=>t===0?l.DIV0:(e-r)/t)),N("GEOMEAN","(r)",(e,r)=>{const t=S(e,r);return t instanceof a?t:t.length===0||t.some(n=>n<=0)?l.NUM:Math.exp(t.reduce((n,s)=>n+Math.log(s),0)/t.length)}),N("HARMEAN","(r)",(e,r)=>{const t=S(e,r);return t instanceof a?t:t.length===0||t.some(n=>n<=0)?l.NUM:t.length/t.reduce((n,s)=>n+1/s,0)}),N("KURT","(r)",(e,r)=>{const t=S(e,r);if(t instanceof a)return t;const n=t.length;if(n<4)return l.DIV0;const s=t.reduce((f,i)=>f+i,0)/n,o=t.reduce((f,i)=>f+(i-s)**2,0)/(n-1);if(o===0)return l.DIV0;const c=t.reduce((f,i)=>f+(i-s)**4,0)/o**2;return n*(n+1)/((n-1)*(n-2)*(n-3))*c-3*(n-1)**2/((n-2)*(n-3))});function z(e,r){const t=[];let n;return ct(e,r,(s,o)=>{if(!n){if(s instanceof a)n=s;else if(typeof s=="number")t.push(s);else if(o&&s!==null){const c=A(s);c instanceof a?n=c:t.push(c)}}}),n??t}N("MODE.SNGL","(r)",(e,r)=>{const t=z(e,r);if(t instanceof a)return t;const n=new Map;for(const c of t)n.set(c,(n.get(c)??0)+1);let s,o=1;for(const[c,f]of n)f>o&&(s=c,o=f);return s??l.NA}),O("MODE","MODE.SNGL"),N("MODE.MULT","(r)",(e,r)=>{const t=z(e,r);if(t instanceof a)return t;const n=new Map;for(const c of t)n.set(c,(n.get(c)??0)+1);let s=0;for(const c of n.values())s=Math.max(s,c);if(s<2)return l.NA;const o=[...n].filter(([,c])=>c===s).map(([c])=>c);return new R(o.length,1,o)});function dt(e,r){const t=r*(e.length-1),n=Math.floor(t),s=e[n]??0,o=e[n+1]??s;return s+(t-n)*(o-s)}N("QUARTILE.INC","rv",(e,r)=>{const t=S([e[0]],r);if(t instanceof a)return t;const n=A(r.calc.scalar(e[1],r.frame));if(n instanceof a)return n;const s=Math.trunc(n);return t.length===0||s<0||s>4?l.NUM:dt([...t].sort((o,c)=>o-c),s/4)}),O("QUARTILE","QUARTILE.INC");function W(e,r){const t=A(r.calc.scalar(e[0],r.frame));if(t instanceof a)return t;const n=S([e[1]],r);if(n instanceof a)return n;const s=e[2]===void 0?0:A(r.calc.scalar(e[2],r.frame));if(s instanceof a)return s;const o=n.filter(c=>c===t).length;return o===0?l.NA:{before:n.filter(c=>s===0?c>t:c<t).length,ties:o}}N("RANK.EQ","vr?v",(e,r)=>{const t=W(e,r);return t instanceof a?t:t.before+1}),N("RANK.AVG","vr?v",(e,r)=>{const t=W(e,r);return t instanceof a?t:t.before+(t.ties+1)/2}),O("RANK","RANK.EQ");function L(e,r){const t=v(e,r);if(t instanceof a)return t;const n=[];for(let s=0;s<t.rows;s++){const o=[];for(let c=0;c<t.cols;c++){const f=t.at(s,c);if(f instanceof a)return f;if(typeof f!="number")return l.VALUE;o.push(f)}n.push(o)}return n}const F=e=>new R(e.length,e[0]?.length??0,e.flat());function pt(e,r){const t=r[0]?.length??0;return e.map(n=>Array.from({length:t},(s,o)=>n.reduce((c,f,i)=>c+f*(r[i]?.[o]??0),0)))}N("MMULT","rr",(e,r)=>{const t=L(e[0],r),n=L(e[1],r);return t instanceof a?t:n instanceof a?n:(t[0]?.length??0)!==n.length?l.VALUE:F(pt(t,n))});function V(e){const r=e.length,t=e.map((o,c)=>[...o,...Array.from({length:r},(f,i)=>c===i?1:0)]),n=(o,c)=>t[o]?.[c]??0;let s=1;for(let o=0;o<r;o++){let c=o;for(let i=o+1;i<r;i++)Math.abs(n(i,o))>Math.abs(n(c,o))&&(c=i);if(n(c,o)===0)return{determinant:0};if(c!==o){const[i=[],u=[]]=[t[o],t[c]];t[o]=u,t[c]=i,s=-s}const f=n(o,o);s*=f,t[o]=(t[o]??[]).map(i=>i/f);for(let i=0;i<r;i++){if(i===o)continue;const u=n(i,o),h=t[o]??[];t[i]=(t[i]??[]).map((M,m)=>M-u*(h[m]??0))}}return{determinant:s,inverse:t.map(o=>o.slice(r))}}const Z=e=>e.length>0&&e.every(r=>r.length===e.length);N("MDETERM","r",(e,r)=>{const t=L(e[0],r);return t instanceof a?t:Z(t)?V(t).determinant:l.VALUE}),N("MINVERSE","r",(e,r)=>{const t=L(e[0],r);if(t instanceof a)return t;if(!Z(t))return l.VALUE;const{inverse:n}=V(t);return n?F(n):l.NUM}),T("MUNIT",1,1,U((e=0)=>{const r=Math.trunc(e);return r<1||r>73?l.VALUE:F(Array.from({length:r},(t,n)=>Array.from({length:r},(s,o)=>n===o?1:0)))}));function G(e,r,t){const n=v(e,t),s=v(r,t);if(n instanceof a)return n;if(s instanceof a)return s;if(n.rows*n.cols!==s.rows*s.cols)return l.NA;const o=[],c=[];for(let f=0;f<n.rows;f++)for(let i=0;i<n.cols;i++){const u=n.at(f,i),h=s.rows===n.rows?s.at(f,i):s.at(i,f);if(u instanceof a)return u;if(h instanceof a)return h;typeof u=="number"&&typeof h=="number"&&(o.push(u),c.push(h))}return{xs:o,ys:c}}for(const[e,r]of[["SUMX2MY2",(t,n)=>t*t-n*n],["SUMX2PY2",(t,n)=>t*t+n*n],["SUMXMY2",(t,n)=>(t-n)**2]])N(e,"rr",(t,n)=>{const s=G(t[0],t[1],n);return s instanceof a?s:s.xs.length===0?l.DIV0:s.xs.reduce((o,c,f)=>o+r(c,s.ys[f]??0),0)});N("SERIESSUM","vvvr",(e,r)=>{const[t,n,s]=e.slice(0,3).map(c=>A(r.calc.scalar(c,r.frame)));if(t instanceof a)return t;if(n instanceof a)return n;if(s instanceof a)return s;const o=S([e[3]],r);return o instanceof a?o:o.reduce((c,f,i)=>c+f*(t??0)**((n??0)+i*(s??0)),0)}),N("FREQUENCY","rr",(e,r)=>{const t=S([e[0]],r),n=S([e[1]],r);if(t instanceof a)return t;if(n instanceof a)return n;const s=n.map((c,f)=>({b:c,i:f})).sort((c,f)=>c.b-f.b),o=new Array(n.length+1).fill(0);for(const c of t){const f=s.find(u=>c<=u.b),i=f?f.i:n.length;o[i]=(o[i]??0)+1}return new R(o.length,1,o)}),N("PROB","rrv?v",(e,r)=>{const t=G(e[0],e[1],r);if(t instanceof a)return t;const n=A(r.calc.scalar(e[2],r.frame));if(n instanceof a)return n;const s=e[3]===void 0?n:A(r.calc.scalar(e[3],r.frame));if(s instanceof a)return s;const o=t.ys.reduce((c,f)=>c+f,0);return t.ys.some(c=>c<=0||c>1)||Math.abs(o-1)>1e-12?l.NUM:t.xs.reduce((c,f,i)=>f>=n&&f<=s?c+(t.ys[i]??0):c,0)});const J=e=>e.reduce((r,t)=>r+t,0);function $(e,r,t){const n=r.map(u=>t?[...u,1]:[...u]),s=n[0]?.length??0,o=Array.from({length:s},(u,h)=>Array.from({length:s},(M,m)=>n.reduce((E,g)=>E+(g[h]??0)*(g[m]??0),0))),{inverse:c}=V(o);if(!c)return;const f=Array.from({length:s},(u,h)=>n.reduce((M,m,E)=>M+(m[h]??0)*(e[E]??0),0)),i=c.map(u=>u.reduce((h,M,m)=>h+M*(f[m]??0),0));return t?i:[...i,0]}function j(e,r,t){const n=L(e[0],r);if(n instanceof a)return n;const s=n.length===1,o=n.flat();if(t&&o.some(h=>h<=0))return l.NUM;const c=t?o.map(Math.log):o,f=e[1];if(f===void 0||!x(f))return{ys:c,xs:o.map((h,M)=>[M+1]),byRow:s};const i=L(f,r);if(i instanceof a)return i;const u=i[0]?.length??0;return s?u!==c.length?l.REF:{ys:c,xs:Array.from({length:u},(h,M)=>i.map(m=>m[M]??0)),byRow:s}:i.length!==c.length?l.REF:{ys:c,xs:i,byRow:s}}const x=e=>e instanceof Q||e instanceof R||typeof e=="number",tt=(e,r)=>e===void 0||!x(e)&&typeof e!="boolean"?!0:_(r.calc.scalar(e,r.frame));function nt(e){return(r,t)=>{const n=j(r,t,e);if(n instanceof a)return n;const s=tt(r[3],t);if(s instanceof a)return s;const o=$(n.ys,n.xs,s);if(!o)return l.NUM;const c=r[2];let f=n.xs;if(c!==void 0&&x(c)){const u=L(c,t);if(u instanceof a)return u;const h=n.xs[0]?.length??1,M=u[0]?.length??0;f=n.byRow||h===1&&u.length===1?Array.from({length:M},(m,E)=>u.map(g=>g[E]??0)):u}const i=f.map(u=>{const h=u.reduce((M,m,E)=>M+m*(o[E]??0),0)+(o[u.length]??0);return e?Math.exp(h):h});return n.byRow?new R(1,i.length,i):new R(i.length,1,i)}}N("TREND","r?rrv",nt(!1)),N("GROWTH","r?rrv",nt(!0));function Et(e,r,t,n){const s=r.map(p=>n?[...p,1]:[...p]),o=s[0]?.length??0,{inverse:c}=V(Array.from({length:o},(p,d)=>Array.from({length:o},(b,D)=>s.reduce((rt,k)=>rt+(k[d]??0)*(k[D]??0),0))));if(!c)return;const f=r.map(p=>p.reduce((d,b,D)=>d+b*(t[D]??0),0)+(t[p.length]??0)),i=e.reduce((p,d,b)=>p+(d-(f[b]??0))**2,0),u=n?J(e)/e.length:0,h=e.reduce((p,d)=>p+(d-u)**2,0),M=h-i,m=e.length-o,E=m>0?i/m:0,g=c.map((p,d)=>Math.sqrt(Math.max(0,(p[d]??0)*E))),I=r[0]?.length??0;return{errors:g,r2:h===0?1:M/h,sey:Math.sqrt(E),f:m>0&&i>0?M/I/(i/m):0,df:m,ssreg:M,ssresid:i}}function et(e){return(r,t)=>{const n=j(r,t,e);if(n instanceof a)return n;const s=tt(r[2],t);if(s instanceof a)return s;const o=$(n.ys,n.xs,s);if(!o)return l.NUM;const f=[...o.slice(0,-1).reverse(),o[o.length-1]??0],i=e?f.map(Math.exp):f,u=r[3],h=u===void 0||!gt(u)?!1:_(t.calc.scalar(u,t.frame));if(h instanceof a)return h;if(!h)return new R(1,i.length,i);const M=Et(n.ys,n.xs,o,s);if(!M)return l.NUM;const m=i.length,E=I=>[...I,...new Array(m-I.length).fill(l.NA)],g=s?[...M.errors.slice(0,-1).reverse(),M.errors[M.errors.length-1]??0]:[...[...M.errors].reverse(),l.NA];return new R(5,m,[...i,...g,...E([M.r2,M.sey]),...E([M.f,M.df]),...E([M.ssreg,M.ssresid])])}}const gt=e=>x(e)||typeof e=="boolean";N("LINEST","r?rvv",et(!1)),N("LOGEST","r?rvv",et(!0));const y=e=>J(e)/e.length,w=e=>{const r=y(e);return e.reduce((t,n)=>t+(n-r)**2,0)/(e.length-1)};N("CHISQ.TEST","rr",(e,r)=>{const t=L(e[0],r),n=L(e[1],r);if(t instanceof a)return t;if(n instanceof a)return n;const s=t.length,o=t[0]?.length??0;if(n.length!==s||(n[0]?.length??0)!==o)return l.NA;if(s*o<2)return l.NA;let c=0;for(let i=0;i<s;i++)for(let u=0;u<o;u++){const h=n[i]?.[u]??0;if(h<0)return l.NUM;if(h===0)return l.DIV0;c+=((t[i]?.[u]??0)-h)**2/h}const f=s>1&&o>1?(s-1)*(o-1):s>1?s-1:o-1;return lt(f/2,c/2)}),O("CHITEST","CHISQ.TEST"),N("T.TEST","rrvv",(e,r)=>{const t=A(r.calc.scalar(e[2],r.frame)),n=A(r.calc.scalar(e[3],r.frame));if(t instanceof a)return t;if(n instanceof a)return n;const s=Math.trunc(t),o=Math.trunc(n);if(s!==1&&s!==2||o<1||o>3)return l.NUM;let c,f;if(o===1){const u=G(e[0],e[1],r);if(u instanceof a)return u;const h=u.xs.map((M,m)=>M-(u.ys[m]??0));if(h.length<2)return l.DIV0;c=y(h)/Math.sqrt(w(h)/h.length),f=h.length-1}else{const u=S([e[0]],r),h=S([e[1]],r);if(u instanceof a)return u;if(h instanceof a)return h;if(u.length<2||h.length<2)return l.DIV0;const[M,m,E,g]=[w(u),w(h),u.length,h.length],I=Math.abs(y(u)-y(h));if(o===2){f=E+g-2;const p=((E-1)*M+(g-1)*m)/f;c=I/Math.sqrt(p*(1/E+1/g))}else{const p=M/E,d=m/g;c=I/Math.sqrt(p+d),f=(p+d)**2/(p**2/(E-1)+d**2/(g-1))}}return Number.isFinite(c)?q(f/2,.5,f/(f+c*c))*s/2:l.DIV0}),O("TTEST","T.TEST"),N("F.TEST","rr",(e,r)=>{const t=S([e[0]],r),n=S([e[1]],r);if(t instanceof a)return t;if(n instanceof a)return n;if(t.length<2||n.length<2)return l.DIV0;const[s,o]=[w(t),w(n)];if(s===0||o===0)return l.DIV0;const c=s/o,[f,i]=[t.length-1,n.length-1],u=q(i/2,f/2,i/(f*c+i));return 2*Math.min(u,1-u)}),O("FTEST","F.TEST"),N("Z.TEST","rv?v",(e,r)=>{const t=S([e[0]],r);if(t instanceof a)return t;const n=A(r.calc.scalar(e[1],r.frame));if(n instanceof a)return n;if(t.length===0)return l.NA;const s=e[2]===void 0?t.length<2?l.DIV0:Math.sqrt(w(t)):A(r.calc.scalar(e[2],r.frame));return s instanceof a?s:s===0?l.DIV0:1-ht((y(t)-n)/(s/Math.sqrt(t.length)))}),O("ZTEST","Z.TEST");const At={1:"AVERAGE",2:"COUNT",3:"COUNTA",4:"MAX",5:"MIN",6:"PRODUCT",7:"STDEV.S",8:"STDEV.P",9:"SUM",10:"VAR.S",11:"VAR.P",12:"MEDIAN",13:"MODE.SNGL",14:"LARGE",15:"SMALL",16:"PERCENTILE.INC",17:"QUARTILE.INC",18:"PERCENTILE.EXC",19:"QUARTILE.EXC"};N("AGGREGATE","vv(r)",(e,r)=>{const t=A(r.calc.scalar(e[0],r.frame)),n=A(r.calc.scalar(e[1],r.frame));if(t instanceof a)return t;if(n instanceof a)return n;const s=At[Math.trunc(t)],o=s===void 0?void 0:ot.get(s);if(o===void 0)return l.VALUE;const c=![2,3,6,7].includes(Math.trunc(n)),f=[1,3,5,7].includes(Math.trunc(n)),i=m=>{const E=m instanceof st?m.parts:[m],g=[];for(const p of E)if(p instanceof Q){const d=p;for(let b=d.top;b<=Math.min(d.bottom,d.sheet.lastRow);b++)if(!(f&&(d.sheet.spec.rows?.[String(b+1)]?.hidden===!0||r.calc.filtered(d.sheet).has(b))))for(let D=d.left;D<=d.right;D++)g.push(r.calc.read(d.sheet,b,D))}else{const d=r.calc.flat(p);d instanceof R?g.push(...d.data):g.push(d)}const I=c?g:g.filter(p=>!(p instanceof a));return new R(I.length,1,I)},u=Math.trunc(t)>=14,h=e.slice(2),M=u?[i(h[0]),...h.slice(1)]:h.map(i);return r.calc.applyFunction(o,M,r.frame)}),T("FACT",1,1,U(e=>{if(e<0)return l.NUM;let r=1;for(let t=2;t<=Math.trunc(e);t++)r*=t;return Number.isFinite(r)?r:l.NUM})),T("FACTDOUBLE",1,1,U(e=>{if(e<0)return l.NUM;let r=1;for(let t=Math.trunc(e);t>1;t-=2)r*=t;return Number.isFinite(r)?r:l.NUM})),T("ATAN2",2,2,U((e,r)=>e===0&&r===0?l.DIV0:Math.atan2(r,e)));for(const[e,r]of[["LARGE",!0],["SMALL",!1]])N(e,"rv",(t,n)=>{const s=S([t[0]],n);if(s instanceof a)return s;const o=A(t[1]);if(o instanceof a)return o;const c=Math.ceil(o);return c<1||c>s.length?l.NUM:(s.sort((f,i)=>r?i-f:f-i),s[c-1]??l.NUM)});
|
|
2
|
+
import{CellError as a,ERR as l,Matrix as I}from"../../values.js";import{toBool as Q,toNumber as A}from"../coerce.js";import{Reference as C,Union as ot,pushAll as ct}from"../types.js";import{indexKeyOf as it}from"../indexes.js";import{FUNCTIONS as ft,alias as L,cellsOf as v,eachArg as at,eachRow as ut,number as U,numbersOf as S,raw as d,scalar as T}from"./define.js";import{besselI as lt,besselJ as ht,besselK as mt,besselY as Mt,betaI as q,gammaQ as dt,normalCdf as Nt}from"./special.js";const P=2**48;function K(e,r){const[t="0",n="0"]=e.toExponential().split("e");return+`${t}e${String(Number(n)+r)}`}const pt=e=>Number(e.toPrecision(15));function k(e,r,t){const n=Math.trunc(r),s=Math.abs(pt(e)),o=K(s,n);if(o>=2**53)return e;const c=K(t(o),-n);return e<0?-c:c}T("ROUND",2,2,U((e=0,r=0)=>k(e,r,t=>Math.floor(t+.5)))),T("ROUNDUP",2,2,U((e=0,r=0)=>k(e,r,Math.ceil))),T("ROUNDDOWN",2,2,U((e=0,r=0)=>k(e,r,Math.floor))),T("MOD",2,2,U((e=0,r=0)=>{if(r===0)return l.DIV0;const t=e%r;return t!==0&&t<0!=r<0?t+r:t})),T("QUOTIENT",2,2,U((e=0,r=0)=>r===0?l.DIV0:Math.trunc(e/r))),T("POWER",2,2,U((e=0,r=0)=>{if(e===0&&r===0)return l.NUM;if(e===0&&r<0)return l.DIV0;const t=e**r;return Number.isFinite(t)?t:l.NUM})),T("LOG",1,2,(e,r)=>{const t=A(e),n=r==null?10:A(r);return t instanceof a?t:n instanceof a?n:t<=0||n<=0?l.NUM:n===1?l.DIV0:n===10?Math.log10(t):n===2?Math.log2(t):Math.log(t)/Math.log(n)});function X(e,r){let[t,n]=[e,r];for(;n!==0;)[t,n]=[n,t%n];return t}function H(e,r){const t=S(e,r);if(t instanceof a)return t;const n=t.map(Math.trunc);return n.some(s=>s<0||s>=2**53)?l.NUM:n}d("GCD","(r)",(e,r)=>{const t=H(e,r);return t instanceof a?t:t.reduce(X,0)}),d("LCM","(r)",(e,r)=>{const t=H(e,r);if(t instanceof a)return t;if(t.includes(0))return 0;const n=t.reduce((s,o)=>s*o/X(s,o),1);return Number.isFinite(n)?n:l.NUM}),T("BASE",2,3,U((e=0,r=0,t=Number.NaN)=>{const n=Math.trunc(e),s=Math.trunc(r),o=Number.isNaN(t)?0:Math.trunc(t);return n<0||n>=2**53||s<2||s>36||o<0||o>255?l.NUM:n.toString(s).toUpperCase().padStart(o,"0")}));const gt="MDCLXVI",Y=[1e3,500,100,50,10,5,1];function Et(e,r){const t=f=>Y[f]??1,n=f=>gt.charAt(f),s=Y.length-1;let o=e,c="";for(let f=0;f<=s/2;f++){const i=2*f,u=Math.floor(o/t(i));if(u%5===4){const h=u===4?i-1:i-2;let m=i,M=0;for(;M<r&&m<s;)M+=1,t(h)-t(m+1)<=o?m+=1:M=r;c+=n(m)+n(h),o+=t(m)-t(h)}else u>4&&(c+=n(i-1)),c+=n(i).repeat(u%5),o%=t(i)}return c}T("ROMAN",1,2,(e,r)=>{const t=A(e);if(t instanceof a)return t;let n=0;if(typeof r=="boolean")n=r?0:4;else if(r!=null){const o=A(r);if(o instanceof a)return o;n=Math.trunc(o)}const s=Math.trunc(t);return s<0||s>3999||n<0||n>4?l.VALUE:Et(s,n)});function B(e){return!Number.isInteger(e)||e<0||e>=P?l.NUM:BigInt(e)}for(const[e,r]of[["BITAND",(t,n)=>t&n],["BITOR",(t,n)=>t|n],["BITXOR",(t,n)=>t^n]])T(e,2,2,U((t=0,n=0)=>{const s=B(t),o=B(n);return s instanceof a?s:o instanceof a?o:Number(r(s,o))}));for(const[e,r]of[["BITLSHIFT",1],["BITRSHIFT",-1]])T(e,2,2,U((t=0,n=0)=>{const s=B(t);if(s instanceof a)return s;const o=Math.trunc(n)*r;if(Math.abs(o)>53)return l.NUM;const c=o>=0?s<<BigInt(o):s>>BigInt(-o);return c>=BigInt(P)?l.NUM:Number(c)}));for(const[e,r,t]of[["BESSELJ",ht,!1],["BESSELI",lt,!1],["BESSELY",Mt,!0],["BESSELK",mt,!0]])T(e,2,2,U((n=0,s=0)=>{const o=Math.trunc(s);if(o<0||t&&n<=0)return l.NUM;const c=r(o,n);return Number.isFinite(c)?c:l.NUM}));T("SLN",3,3,U((e=0,r=0,t=0)=>t===0?l.DIV0:(e-r)/t)),d("GEOMEAN","(r)",(e,r)=>{const t=S(e,r);return t instanceof a?t:t.length===0||t.some(n=>n<=0)?l.NUM:Math.exp(t.reduce((n,s)=>n+Math.log(s),0)/t.length)}),d("HARMEAN","(r)",(e,r)=>{const t=S(e,r);return t instanceof a?t:t.length===0||t.some(n=>n<=0)?l.NUM:t.length/t.reduce((n,s)=>n+1/s,0)}),d("KURT","(r)",(e,r)=>{const t=S(e,r);if(t instanceof a)return t;const n=t.length;if(n<4)return l.DIV0;const s=t.reduce((f,i)=>f+i,0)/n,o=t.reduce((f,i)=>f+(i-s)**2,0)/(n-1);if(o===0)return l.DIV0;const c=t.reduce((f,i)=>f+(i-s)**4,0)/o**2;return n*(n+1)/((n-1)*(n-2)*(n-3))*c-3*(n-1)**2/((n-2)*(n-3))});function W(e,r){const t=[];let n;return ut(e,r,(s,o)=>{if(!n){if(s instanceof a)n=s;else if(typeof s=="number")t.push(s);else if(o&&s!==null){const c=A(s);c instanceof a?n=c:t.push(c)}}}),n??t}d("MODE.SNGL","(r)",(e,r)=>{const t=W(e,r);if(t instanceof a)return t;const n=new Map;for(const c of t)n.set(c,(n.get(c)??0)+1);let s,o=1;for(const[c,f]of n)f>o&&(s=c,o=f);return s??l.NA}),L("MODE","MODE.SNGL"),d("MODE.MULT","(r)",(e,r)=>{const t=W(e,r);if(t instanceof a)return t;const n=new Map;for(const c of t)n.set(c,(n.get(c)??0)+1);let s=0;for(const c of n.values())s=Math.max(s,c);if(s<2)return l.NA;const o=[...n].filter(([,c])=>c===s).map(([c])=>c);return new I(o.length,1,o)});function At(e,r){const t=r*(e.length-1),n=Math.floor(t),s=e[n]??0,o=e[n+1]??s;return s+(t-n)*(o-s)}d("QUARTILE.INC","rv",(e,r)=>{const t=S([e[0]],r);if(t instanceof a)return t;const n=A(r.calc.scalar(e[1],r.frame));if(n instanceof a)return n;const s=Math.trunc(n);return t.length===0||s<0||s>4?l.NUM:At([...t].sort((o,c)=>o-c),s/4)}),L("QUARTILE","QUARTILE.INC");function z(e,r){const t=A(r.calc.scalar(e[0],r.frame));if(t instanceof a)return t;const n=S([e[1]],r);if(n instanceof a)return n;const s=e[2]===void 0?0:A(r.calc.scalar(e[2],r.frame));if(s instanceof a)return s;const o=n.filter(c=>c===t).length;return o===0?l.NA:{before:n.filter(c=>s===0?c>t:c<t).length,ties:o}}d("RANK.EQ","vr?v",(e,r)=>{const t=z(e,r);return t instanceof a?t:t.before+1}),d("RANK.AVG","vr?v",(e,r)=>{const t=z(e,r);return t instanceof a?t:t.before+(t.ties+1)/2}),L("RANK","RANK.EQ");function w(e,r){const t=v(e,r);if(t instanceof a)return t;const n=[];for(let s=0;s<t.rows;s++){const o=[];for(let c=0;c<t.cols;c++){const f=t.at(s,c);if(f instanceof a)return f;if(typeof f!="number")return l.VALUE;o.push(f)}n.push(o)}return n}const F=e=>new I(e.length,e[0]?.length??0,e.flat());function Tt(e,r){const t=r[0]?.length??0;return e.map(n=>Array.from({length:t},(s,o)=>n.reduce((c,f,i)=>c+f*(r[i]?.[o]??0),0)))}d("MMULT","rr",(e,r)=>{const t=w(e[0],r),n=w(e[1],r);return t instanceof a?t:n instanceof a?n:(t[0]?.length??0)!==n.length?l.VALUE:F(Tt(t,n))});function x(e){const r=e.length,t=e.map((o,c)=>[...o,...Array.from({length:r},(f,i)=>c===i?1:0)]),n=(o,c)=>t[o]?.[c]??0;let s=1;for(let o=0;o<r;o++){let c=o;for(let i=o+1;i<r;i++)Math.abs(n(i,o))>Math.abs(n(c,o))&&(c=i);if(n(c,o)===0)return{determinant:0};if(c!==o){const[i=[],u=[]]=[t[o],t[c]];t[o]=u,t[c]=i,s=-s}const f=n(o,o);s*=f,t[o]=(t[o]??[]).map(i=>i/f);for(let i=0;i<r;i++){if(i===o)continue;const u=n(i,o),h=t[o]??[];t[i]=(t[i]??[]).map((m,M)=>m-u*(h[M]??0))}}return{determinant:s,inverse:t.map(o=>o.slice(r))}}const Z=e=>e.length>0&&e.every(r=>r.length===e.length);d("MDETERM","r",(e,r)=>{const t=w(e[0],r);return t instanceof a?t:Z(t)?x(t).determinant:l.VALUE}),d("MINVERSE","r",(e,r)=>{const t=w(e[0],r);if(t instanceof a)return t;if(!Z(t))return l.VALUE;const{inverse:n}=x(t);return n?F(n):l.NUM}),T("MUNIT",1,1,U((e=0)=>{const r=Math.trunc(e);return r<1||r>73?l.VALUE:F(Array.from({length:r},(t,n)=>Array.from({length:r},(s,o)=>n===o?1:0)))}));function G(e,r,t){const n=v(e,t),s=v(r,t);if(n instanceof a)return n;if(s instanceof a)return s;if(n.rows*n.cols!==s.rows*s.cols)return l.NA;const o=[],c=[];for(let f=0;f<n.rows;f++)for(let i=0;i<n.cols;i++){const u=n.at(f,i),h=s.rows===n.rows?s.at(f,i):s.at(i,f);if(u instanceof a)return u;if(h instanceof a)return h;typeof u=="number"&&typeof h=="number"&&(o.push(u),c.push(h))}return{xs:o,ys:c}}for(const[e,r]of[["SUMX2MY2",(t,n)=>t*t-n*n],["SUMX2PY2",(t,n)=>t*t+n*n],["SUMXMY2",(t,n)=>(t-n)**2]])d(e,"rr",(t,n)=>{const s=G(t[0],t[1],n);return s instanceof a?s:s.xs.length===0?l.DIV0:s.xs.reduce((o,c,f)=>o+r(c,s.ys[f]??0),0)});d("SERIESSUM","vvvr",(e,r)=>{const[t,n,s]=e.slice(0,3).map(c=>A(r.calc.scalar(c,r.frame)));if(t instanceof a)return t;if(n instanceof a)return n;if(s instanceof a)return s;const o=S([e[3]],r);return o instanceof a?o:o.reduce((c,f,i)=>c+f*(t??0)**((n??0)+i*(s??0)),0)}),d("FREQUENCY","rr",(e,r)=>{const t=S([e[0]],r);if(t instanceof a)return t;const n=[];at([e[1]],r,c=>{typeof c=="number"&&n.push(c)});const s=n.map((c,f)=>({b:c,i:f})).sort((c,f)=>c.b-f.b),o=new Array(n.length+1).fill(0);for(const c of t){let f=0,i=s.length;for(;f<i;){const h=f+i>>1;c<=(s[h]?.b??1/0)?i=h:f=h+1}const u=s[f]?.i??n.length;o[u]=(o[u]??0)+1}return new I(o.length,1,o)}),d("PROB","rrv?v",(e,r)=>{const t=G(e[0],e[1],r);if(t instanceof a)return t;const n=A(r.calc.scalar(e[2],r.frame));if(n instanceof a)return n;const s=e[3]===void 0?n:A(r.calc.scalar(e[3],r.frame));if(s instanceof a)return s;const o=t.ys.reduce((c,f)=>c+f,0);return t.ys.some(c=>c<=0||c>1)||Math.abs(o-1)>1e-12?l.NUM:t.xs.reduce((c,f,i)=>f>=n&&f<=s?c+(t.ys[i]??0):c,0)});const J=e=>e.reduce((r,t)=>r+t,0);function $(e,r,t){const n=r.map(u=>t?[...u,1]:[...u]),s=n[0]?.length??0,o=Array.from({length:s},(u,h)=>Array.from({length:s},(m,M)=>n.reduce((g,E)=>g+(E[h]??0)*(E[M]??0),0))),{inverse:c}=x(o);if(!c)return;const f=Array.from({length:s},(u,h)=>n.reduce((m,M,g)=>m+(M[h]??0)*(e[g]??0),0)),i=c.map(u=>u.reduce((h,m,M)=>h+m*(f[M]??0),0));return t?i:[...i,0]}function j(e,r,t){const n=w(e[0],r);if(n instanceof a)return n;const s=n.length===1,o=n.flat();if(t&&o.some(h=>h<=0))return l.NUM;const c=t?o.map(Math.log):o,f=e[1];if(f===void 0||!V(f))return{ys:c,xs:o.map((h,m)=>[m+1]),byRow:s};const i=w(f,r);if(i instanceof a)return i;const u=i[0]?.length??0;return s?u!==c.length?l.REF:{ys:c,xs:Array.from({length:u},(h,m)=>i.map(M=>M[m]??0)),byRow:s}:i.length!==c.length?l.REF:{ys:c,xs:i,byRow:s}}const V=e=>e instanceof C||e instanceof I||typeof e=="number",tt=(e,r)=>e===void 0||!V(e)&&typeof e!="boolean"?!0:Q(r.calc.scalar(e,r.frame));function nt(e){return(r,t)=>{const n=j(r,t,e);if(n instanceof a)return n;const s=tt(r[3],t);if(s instanceof a)return s;const o=$(n.ys,n.xs,s);if(!o)return l.NUM;const c=r[2];let f=n.xs;if(c!==void 0&&V(c)){const u=w(c,t);if(u instanceof a)return u;const h=n.xs[0]?.length??1,m=u[0]?.length??0;f=n.byRow||h===1&&u.length===1?Array.from({length:m},(M,g)=>u.map(E=>E[g]??0)):u}const i=f.map(u=>{const h=u.reduce((m,M,g)=>m+M*(o[g]??0),0)+(o[u.length]??0);return e?Math.exp(h):h});return n.byRow?new I(1,i.length,i):new I(i.length,1,i)}}d("TREND","r?rrv",nt(!1)),d("GROWTH","r?rrv",nt(!0));function Ut(e,r,t,n){const s=r.map(p=>n?[...p,1]:[...p]),o=s[0]?.length??0,{inverse:c}=x(Array.from({length:o},(p,N)=>Array.from({length:o},(R,y)=>s.reduce((st,_)=>st+(_[N]??0)*(_[y]??0),0))));if(!c)return;const f=r.map(p=>p.reduce((N,R,y)=>N+R*(t[y]??0),0)+(t[p.length]??0)),i=e.reduce((p,N,R)=>p+(N-(f[R]??0))**2,0),u=n?J(e)/e.length:0,h=e.reduce((p,N)=>p+(N-u)**2,0),m=h-i,M=e.length-o,g=M>0?i/M:0,E=c.map((p,N)=>Math.sqrt(Math.max(0,(p[N]??0)*g))),b=r[0]?.length??0;return{errors:E,r2:h===0?1:m/h,sey:Math.sqrt(g),f:M>0&&i>0?m/b/(i/M):0,df:M,ssreg:m,ssresid:i}}function et(e){return(r,t)=>{const n=j(r,t,e);if(n instanceof a)return n;const s=tt(r[2],t);if(s instanceof a)return s;const o=$(n.ys,n.xs,s);if(!o)return l.NUM;const f=[...o.slice(0,-1).reverse(),o[o.length-1]??0],i=e?f.map(Math.exp):f,u=r[3],h=u===void 0||!St(u)?!1:Q(t.calc.scalar(u,t.frame));if(h instanceof a)return h;if(!h)return new I(1,i.length,i);const m=Ut(n.ys,n.xs,o,s);if(!m)return l.NUM;const M=i.length,g=b=>[...b,...new Array(M-b.length).fill(l.NA)],E=s?[...m.errors.slice(0,-1).reverse(),m.errors[m.errors.length-1]??0]:[...[...m.errors].reverse(),l.NA];return new I(5,M,[...i,...E,...g([m.r2,m.sey]),...g([m.f,m.df]),...g([m.ssreg,m.ssresid])])}}const St=e=>V(e)||typeof e=="boolean";d("LINEST","r?rvv",et(!1)),d("LOGEST","r?rvv",et(!0));const D=e=>J(e)/e.length,O=e=>{const r=D(e);return e.reduce((t,n)=>t+(n-r)**2,0)/(e.length-1)};d("CHISQ.TEST","rr",(e,r)=>{const t=w(e[0],r),n=w(e[1],r);if(t instanceof a)return t;if(n instanceof a)return n;const s=t.length,o=t[0]?.length??0;if(n.length!==s||(n[0]?.length??0)!==o)return l.NA;if(s*o<2)return l.NA;let c=0;for(let i=0;i<s;i++)for(let u=0;u<o;u++){const h=n[i]?.[u]??0;if(h<0)return l.NUM;if(h===0)return l.DIV0;c+=((t[i]?.[u]??0)-h)**2/h}const f=s>1&&o>1?(s-1)*(o-1):s>1?s-1:o-1;return dt(f/2,c/2)}),L("CHITEST","CHISQ.TEST"),d("T.TEST","rrvv",(e,r)=>{const t=A(r.calc.scalar(e[2],r.frame)),n=A(r.calc.scalar(e[3],r.frame));if(t instanceof a)return t;if(n instanceof a)return n;const s=Math.trunc(t),o=Math.trunc(n);if(s!==1&&s!==2||o<1||o>3)return l.NUM;let c,f;if(o===1){const u=G(e[0],e[1],r);if(u instanceof a)return u;const h=u.xs.map((m,M)=>m-(u.ys[M]??0));if(h.length<2)return l.DIV0;c=D(h)/Math.sqrt(O(h)/h.length),f=h.length-1}else{const u=S([e[0]],r),h=S([e[1]],r);if(u instanceof a)return u;if(h instanceof a)return h;if(u.length<2||h.length<2)return l.DIV0;const[m,M,g,E]=[O(u),O(h),u.length,h.length],b=Math.abs(D(u)-D(h));if(o===2){f=g+E-2;const p=((g-1)*m+(E-1)*M)/f;c=b/Math.sqrt(p*(1/g+1/E))}else{const p=m/g,N=M/E;c=b/Math.sqrt(p+N),f=(p+N)**2/(p**2/(g-1)+N**2/(E-1))}}return Number.isFinite(c)?q(f/2,.5,f/(f+c*c))*s/2:l.DIV0}),L("TTEST","T.TEST"),d("F.TEST","rr",(e,r)=>{const t=S([e[0]],r),n=S([e[1]],r);if(t instanceof a)return t;if(n instanceof a)return n;if(t.length<2||n.length<2)return l.DIV0;const[s,o]=[O(t),O(n)];if(s===0||o===0)return l.DIV0;const c=s/o,[f,i]=[t.length-1,n.length-1],u=q(i/2,f/2,i/(f*c+i));return 2*Math.min(u,1-u)}),L("FTEST","F.TEST"),d("Z.TEST","rv?v",(e,r)=>{const t=S([e[0]],r);if(t instanceof a)return t;const n=A(r.calc.scalar(e[1],r.frame));if(n instanceof a)return n;if(t.length===0)return l.NA;const s=e[2]===void 0?t.length<2?l.DIV0:Math.sqrt(O(t)):A(r.calc.scalar(e[2],r.frame));return s instanceof a?s:s===0?l.DIV0:1-Nt((D(t)-n)/(s/Math.sqrt(t.length)))}),L("ZTEST","Z.TEST");const It={1:"AVERAGE",2:"COUNT",3:"COUNTA",4:"MAX",5:"MIN",6:"PRODUCT",7:"STDEV.S",8:"STDEV.P",9:"SUM",10:"VAR.S",11:"VAR.P",12:"MEDIAN",13:"MODE.SNGL",14:"LARGE",15:"SMALL",16:"PERCENTILE.INC",17:"QUARTILE.INC",18:"PERCENTILE.EXC",19:"QUARTILE.EXC"};d("AGGREGATE","vv(r)",(e,r)=>{const t=A(r.calc.scalar(e[0],r.frame)),n=A(r.calc.scalar(e[1],r.frame));if(t instanceof a)return t;if(n instanceof a)return n;const s=It[Math.trunc(t)],o=s===void 0?void 0:ft.get(s);if(o===void 0)return l.VALUE;const c=![2,3,6,7].includes(Math.trunc(n)),f=[1,3,5,7].includes(Math.trunc(n)),i=M=>{const g=M instanceof ot?M.parts:[M],E=[];for(const p of g)if(p instanceof C){const N=p;for(let R=N.top;R<=Math.min(N.bottom,N.sheet.lastRow);R++)if(!(f&&(N.sheet.spec.rows?.[String(R+1)]?.hidden===!0||r.calc.filtered(N.sheet).has(R))))for(let y=N.left;y<=N.right;y++)E.push(r.calc.read(N.sheet,R,y))}else{const N=r.calc.flat(p);N instanceof I?ct(E,N.data):E.push(N)}const b=c?E:E.filter(p=>!(p instanceof a));return new I(b.length,1,b)},u=Math.trunc(t)>=14,h=e.slice(2),m=u?[i(h[0]),...h.slice(1)]:h.map(i);return r.calc.applyFunction(o,m,r.frame)}),T("FACT",1,1,U(e=>{if(e<0)return l.NUM;let r=1;for(let t=2;t<=Math.trunc(e);t++)r*=t;return Number.isFinite(r)?r:l.NUM})),T("FACTDOUBLE",1,1,U(e=>{if(e<0)return l.NUM;let r=1;for(let t=Math.trunc(e);t>1;t-=2)r*=t;return Number.isFinite(r)?r:l.NUM})),T("ATAN2",2,2,U((e,r)=>e===0&&r===0?l.DIV0:Math.atan2(r,e)));const rt={largest:new WeakMap,smallest:new WeakMap};function bt(e,r,t){const n=()=>{const f=S([e],t);return f instanceof a?f:f.sort((i,u)=>r?u-i:i-u)};if(e instanceof C)return t.calc.indexes.ofRepeated(it(r?"large":"small",e),[e],()=>{const i=n();return new Map(i instanceof a?[]:[["",i]])})?.get("")??n();if(!(e instanceof I))return n();const s=r?rt.largest:rt.smallest,o=s.get(e);if(o)return o;const c=n();return c instanceof a||s.set(e,o===null?c:null),c}for(const[e,r]of[["LARGE",!0],["SMALL",!1]])d(e,"rv",(t,n)=>{const s=bt(t[0],r,n);if(s instanceof a)return s;const o=A(t[1]);if(o instanceof a)return o;const c=Math.ceil(o);return c<1||c>s.length?l.NUM:s[c-1]??l.NUM});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{format as $,isValidFormat as D}from"numfmt";import{CellError as i,ERR as
|
|
2
|
+
import{format as $,isValidFormat as D}from"numfmt";import{CellError as i,ERR as d}from"../../values.js";import{numberOfText as N,toBool as b,toNumber as p,toText as u}from"../coerce.js";import{Missing as F}from"../types.js";import{alias as H,cellsOf as S,eachRow as O,many as B,number as x,numberArg as V,raw as M,scalar as f}from"./define.js";import{literalOf as X,wildcard as j}from"./criteria.js";import{delimiters as k,eachLetter as G,lowerLetters as _,occurrences as J}from"./delimiters.js";const g=n=>r=>{const t=u(r);return t instanceof i?t:n(t)},T=(n,r)=>{if(n===void 0)return r;const t=p(n);return t instanceof i?t:t<0?d.VALUE:Math.trunc(t)},I=n=>G(n,r=>r.toUpperCase()),y=_;f("LEFT",1,2,(n,r)=>{const t=u(n),e=T(r,1);return t instanceof i?t:e instanceof i?e:t.slice(0,e)}),f("RIGHT",1,2,(n,r)=>{const t=u(n),e=T(r,1);return t instanceof i?t:e instanceof i?e:e===0?"":t.slice(-e)}),f("MID",3,3,(n,r,t)=>{const e=u(n),s=p(r),o=T(t,0);if(e instanceof i)return e;if(s instanceof i)return s;if(o instanceof i)return o;if(s<1)return d.VALUE;const c=Math.trunc(s)-1;return e.slice(c,c+o)}),f("LEN",1,1,g(n=>n.length)),f("LOWER",1,1,g(y)),f("UPPER",1,1,g(I)),f("PROPER",1,1,g(n=>y(n).replace(/(^|[^\p{L}])(\p{L})/gu,(r,t,e)=>`${t}${I(e)}`))),f("TRIM",1,1,g(n=>n.replace(/ +/gu," ").replace(/^ | $/gu,""))),f("CLEAN",1,1,g(n=>n.replace(/[\u0000-\u001f]/gu,""))),f("T",1,1,n=>typeof n=="string"?n:""),f("EXACT",2,2,(n,r)=>{const t=u(n),e=u(r);return t instanceof i?t:e instanceof i?e:t===e}),f("REPT",2,2,(n,r)=>{const t=u(n),e=T(r,0);return t instanceof i?t:e instanceof i?e:t.length*e>32767?d.VALUE:t.repeat(e)}),f("CHAR",1,1,x(n=>{const r=Math.trunc(n);return r<1||r>255?d.VALUE:W(r)})),f("UNICHAR",1,1,x(n=>{const r=Math.trunc(n);return r<1||r>1114111?d.VALUE:String.fromCodePoint(r)})),f("CODE",1,1,g(n=>n===""?d.VALUE:n.charCodeAt(0))),f("UNICODE",1,1,g(n=>n.codePointAt(0)??d.VALUE));const K="€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ";function W(n){return n>=128&&n<160?K.charAt(n-128):String.fromCharCode(n)}M("CONCAT","(r)",(n,r)=>{let t="",e;return O(n,r,s=>{if(e)return;const o=u(s);o instanceof i?e=o:t+=o}),e??t}),f("CONCATENATE",1,B,(...n)=>{let r="";for(const t of n){const e=u(t);if(e instanceof i)return e;r+=e}return r}),M("TEXTJOIN","rv(r)",(n,r)=>{const[t,e,...s]=n,o=S(t??"",r);if(o instanceof i)return o;const c=[];for(let h=0;h<o.rows;h++)for(let A=0;A<o.cols;A++){const m=u(o.at(h,A));if(m instanceof i)return m;c.push(m)}const l=b(r.calc.scalar(e??!0,r.frame));if(l instanceof i)return l;const E=[];let a;if(O(s,r,h=>{if(a)return;const A=u(h);A instanceof i?a=A:(!l||A!=="")&&E.push(A)}),a)return a;let L=E[0]??"";for(let h=1;h<E.length;h++)L+=`${c.length>0?c[(h-1)%c.length]??"":""}${E[h]??""}`;return L}),f("SUBSTITUTE",3,4,(n,r,t,e)=>{const s=u(n),o=u(r),c=u(t);if(s instanceof i)return s;if(o instanceof i)return o;if(c instanceof i)return c;if(o==="")return s;if(e===void 0)return s.split(o).join(c);const l=p(e);if(l instanceof i)return l;if(l<1)return d.VALUE;let E=-1;for(let a=0;a<Math.trunc(l);a++)if(E=s.indexOf(o,E+1),E<0)return s;return`${s.slice(0,E)}${c}${s.slice(E+o.length)}`}),f("REPLACE",4,4,(n,r,t,e)=>{const s=u(n),o=p(r),c=T(t,0),l=u(e);if(s instanceof i)return s;if(o instanceof i)return o;if(c instanceof i)return c;if(l instanceof i)return l;if(o<1)return d.VALUE;const E=Math.trunc(o)-1;return`${s.slice(0,E)}${l}${s.slice(E+c)}`}),f("FIND",2,3,(n,r,t)=>{const e=u(n),s=u(r),o=t===void 0?1:p(t);if(e instanceof i)return e;if(s instanceof i)return s;if(o instanceof i)return o;if(o<1||o>s.length+1)return d.VALUE;const c=s.indexOf(e,Math.trunc(o)-1);return c<0?d.VALUE:c+1}),f("SEARCH",2,3,(n,r,t)=>{const e=u(n),s=u(r),o=t===void 0?1:p(t);if(e instanceof i)return e;if(s instanceof i)return s;if(o instanceof i)return o;if(o<1||o>s.length+1)return d.VALUE;const c=Math.trunc(o)-1,l=X(e);if(l!==void 0){const a=s.toLowerCase(),L=l.toLowerCase();if(a.length===s.length&&L.length===l.length){const h=a.indexOf(L,c);return h<0?d.VALUE:h+1}}const E=j(`${e}*`);for(let a=c;a<=s.length;a++)if(E(s.slice(a)))return a+1;return d.VALUE}),f("VALUE",1,1,n=>typeof n=="number"?n:n==null?0:typeof n!="string"?d.VALUE:N(n)??d.VALUE),f("NUMBERVALUE",1,3,(n,r,t)=>{const e=u(n),s=u(r??"."),o=u(t??",");if(e instanceof i)return e;if(s instanceof i)return s;if(o instanceof i)return o;const c=e.replace(/\s/gu,"").split(o).join("").replace(s,".");if(c==="")return 0;const l=/%*$/u.exec(c)?.[0].length??0,E=Number(c.slice(0,c.length-l));return Number.isNaN(E)?d.VALUE:E/100**l}),f("TEXT",2,2,(n,r)=>{const t=u(r);if(t instanceof i)return t;if(!D(t))return d.VALUE;if(typeof n=="boolean")return n?"TRUE":"FALSE";const e=typeof n=="string"?N(n)??n:n??0;if(e instanceof i)return e;try{return $(t,e)}catch{return d.VALUE}});function w(n,r,t){const e=t?"#,##0":"0",s=r>0?`.${"0".repeat(r)}`:"";return $(`${e}${s}`,n)}const v=(n,r)=>{const t=10**r;return Math.sign(n)*Math.round(Math.abs(n)*t+1e-9)/t};f("FIXED",1,3,(n,r,t)=>{const e=p(n),s=r==null?2:p(r),o=t===void 0?!1:b(t);if(e instanceof i)return e;if(s instanceof i)return s;if(o instanceof i)return o;const c=Math.trunc(s);return w(v(e,c),Math.max(0,c),!o)}),f("DOLLAR",1,2,(n,r)=>{const t=p(n),e=r==null?2:p(r);if(t instanceof i)return t;if(e instanceof i)return e;const s=Math.trunc(e),o=w(Math.abs(v(t,s)),Math.max(0,s),!0);return t<0?`($${o})`:`$${o}`});function Y(n,r,t,e,s){const o=J(n,r,e);return t>0?(s&&o.push({at:n.length,length:0}),o[t-1]):(s&&o.unshift({at:0,length:0}),o[o.length+t])}function P(n){return(r,t)=>{const[e,s,o,c,l,E]=r.map(U=>U instanceof F?void 0:U),a=u(e??null),L=k(s,t),h=V(o,1),A=V(c,0),m=V(l,0);if(a instanceof i)return a;if(L instanceof i)return L;if(h instanceof i)return h;if(A instanceof i)return A;if(m instanceof i)return m;const C=Math.trunc(h);if(C===0||Math.abs(C)>Math.max(a.length,1))return d.VALUE;if(L.length>0&&L.every(U=>U===""))return C>0===(n==="before")?"":a;const R=Y(a,L,C,A===1,m===1);return R?n==="before"?a.slice(0,R.at):a.slice(R.at+R.length):E===void 0?d.NA:E}}M("TEXTBEFORE","vr?vvvv",P("before")),M("TEXTAFTER","vr?vvvv",P("after")),f("HYPERLINK",1,2,(n,r)=>r===void 0?n??null:r),f("ENCODEURL",1,1,g(n=>encodeURIComponent(n)));for(const n of["LEN","LEFT","RIGHT","MID","FIND","SEARCH","REPLACE"])H(`${n}B`,n);
|
|
@@ -6,6 +6,15 @@ export declare class RangeCache<T> {
|
|
|
6
6
|
private readonly kept;
|
|
7
7
|
/** What `key` names, worked out over the ranges `over` read, once while they stay as they are. */
|
|
8
8
|
of(key: string, over: readonly Reference[], build: () => T): T;
|
|
9
|
+
/** Keys asked for once, whose value was not worked out. */
|
|
10
|
+
private readonly asked;
|
|
11
|
+
/**
|
|
12
|
+
* What `key` names, worked out the second time it is asked for: the
|
|
13
|
+
* first time, nothing, and the caller reads the range itself. Ranges
|
|
14
|
+
* asked for once each (COUNTIF($B$2:B2,B2) filled down 13,000 rows, a
|
|
15
|
+
* new range a row) would keep an index each, past memory.
|
|
16
|
+
*/
|
|
17
|
+
ofRepeated(key: string, over: readonly Reference[], build: () => T): T | undefined;
|
|
9
18
|
/** What `key` names, if it is kept. */
|
|
10
19
|
get(key: string): T | undefined;
|
|
11
20
|
/** Keeps what `key` names, worked out over the ranges `over` read. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{overlaps as
|
|
2
|
+
import{overlaps as n}from"../address.js";const h=s=>({top:s.top,left:s.left,bottom:s.bottom,right:s.right});export class RangeCache{kept=new Map;of(e,a,o){const t=this.kept.get(e);if(t)return t.value;const r=o();return this.kept.set(e,{over:a.map(i=>({sheet:i.sheet,area:h(i)})),value:r}),r}asked=new Set;ofRepeated(e,a,o){const t=this.kept.get(e);if(t)return t.value;if(!this.asked.has(e)){this.asked.add(e);return}return this.asked.delete(e),this.of(e,a,o)}get(e){return this.kept.get(e)?.value}set(e,a,o){this.kept.set(e,{over:a.map(t=>({sheet:t.sheet,area:h(t)})),value:o})}changed(e,a){if(this.kept.size!==0)for(const[o,t]of this.kept)t.over.some(r=>r.sheet===e&&n(r.area,a))&&this.kept.delete(o)}clear(){this.kept.clear(),this.asked.clear()}}export const indexKeyOf=(s,e)=>`${s}:${e.key}`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SheetFile } from "@allyhub/formats";
|
|
2
2
|
import type { BookEdit } from "../edit.js";
|
|
3
|
-
import type { GeneratedSheets } from "
|
|
3
|
+
import type { GeneratedSheets } from "@allyhub/formats";
|
|
4
4
|
import { type CsvRows, type Workbook } from "../workbook.js";
|
|
5
5
|
import { Calc } from "./engine.js";
|
|
6
6
|
import type { Computed } from "./remote.js";
|
|
@@ -52,4 +52,10 @@ export interface Frame {
|
|
|
52
52
|
dc: number;
|
|
53
53
|
scope?: Scope;
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Every item of a list put on another's end: `push(...list)` passes each as
|
|
57
|
+
* an argument, and a list of a hundred thousand (a column's readers, a
|
|
58
|
+
* whole column's values) runs past what a call can take.
|
|
59
|
+
*/
|
|
60
|
+
export declare function pushAll<T>(to: T[], items: Iterable<T>): void;
|
|
55
61
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
export class Reference{sheet;top;left;bottom;right;constructor(t,i,r,e,o){this.sheet=t,this.top=i,this.left=r,this.bottom=e,this.right=o}get rows(){return this.bottom-this.top+1}get cols(){return this.right-this.left+1}get single(){return this.top===this.bottom&&this.left===this.right}get key(){return`${String(this.sheet.index)}!${String(this.top)},${String(this.left)}:${String(this.bottom)},${String(this.right)}`}}export class Union{parts;constructor(t){this.parts=t}}export class Lambda{params;body;frame;named;constructor(t,i,r,e){this.params=t,this.body=i,this.frame=r,this.named=e}}export class Missing{missing=!0}export const MISSING=new Missing;
|
|
2
|
+
export class Reference{sheet;top;left;bottom;right;constructor(t,i,r,e,o){this.sheet=t,this.top=i,this.left=r,this.bottom=e,this.right=o}get rows(){return this.bottom-this.top+1}get cols(){return this.right-this.left+1}get single(){return this.top===this.bottom&&this.left===this.right}get key(){return`${String(this.sheet.index)}!${String(this.top)},${String(this.left)}:${String(this.bottom)},${String(this.right)}`}}export class Union{parts;constructor(t){this.parts=t}}export class Lambda{params;body;frame;named;constructor(t,i,r,e){this.params=t,this.body=i,this.frame=r,this.named=e}}export class Missing{missing=!0}export const MISSING=new Missing;export function pushAll(s,t){for(const i of t)s.push(i)}
|
|
@@ -15,6 +15,15 @@ export declare const SHEET_CHART_DEFAULTS: {
|
|
|
15
15
|
/** Pixels to the point, at 96 to the inch. */
|
|
16
16
|
readonly pixelsToPoints: 0.75;
|
|
17
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* A chart's categories as the numbers its cells hold (dates, years) and
|
|
20
|
+
* their cells' number format, for its file to cache as numbers and show as
|
|
21
|
+
* the cells do; undefined when it names no cells.
|
|
22
|
+
*/
|
|
23
|
+
export declare function categoryNumbers(calc: Calc, sheet: Worksheet, chart: Chart): {
|
|
24
|
+
values: (number | null)[];
|
|
25
|
+
format: string | undefined;
|
|
26
|
+
} | undefined;
|
|
18
27
|
/** A chart as it is drawn now: what its cells compute, from the sheet it is on. */
|
|
19
28
|
export declare function chartDef(calc: Calc, sheet: Worksheet, chart: Chart): ChartDef;
|
|
20
29
|
/** A chart's size on the sheet, pixels. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{chartSvg as
|
|
2
|
+
import{chartSvg as L,isRound as M,isScatter as P}from"@allyhub/chart";import{cellName as F,columnLetter as H,contains as U,rangeName as T,readAddress as I,readArea as V}from"./address.js";import{Reference as j,Union as W}from"./calc/types.js";import{shownValue as q}from"./format.js";import{sheetPrefix as k}from"./formula/print.js";import{CellError as B,Matrix as D}from"./values.js";export const SHEET_CHART_DEFAULTS={width:480,height:288,size:9,titleSize:14,ink:"#595959",pixelsToPoints:.75};function y(e,n,o){const{node:t}=o;if(!t)return[];const i=e.eval(t,{sheet:n,row:0,col:0,dr:0,dc:0}),d=l=>{const p=l.sheet,b=e.filtered(p),a=[],_=Math.min(l.bottom,p.lastRow),h=Math.min(l.right,p.columnsUsed-1);for(let f=l.top;f<=_;f++)if(!(b.has(f)||p.spec.rows?.[String(f+1)]?.hidden===!0))for(let c=l.left;c<=h;c++)p.spec.columns?.[H(c)]?.hidden!==!0&&a.push({value:e.value(p,f,c),sheet:p,row:f,col:c});return a};if(i instanceof j)return d(i);if(i instanceof W)return i.parts.flatMap(d);if(i instanceof D)return i.data.map(l=>({value:l}));const r=e.flat(i);return r instanceof D?r.data.map(l=>({value:l})):[{value:r}]}const O=e=>{if(e.value===null)return"";const n=e.sheet&&e.row!==void 0&&e.col!==void 0?e.sheet.lookAt(e.row,e.col).format:void 0;return q(e.value,n)};function R(e){return typeof e=="number"?Number.isFinite(e)?e:null:e===null||e instanceof B?null:typeof e=="boolean"&&e?1:0}const C=e=>e&&{...e.min===void 0?{}:{minimum_scale:e.min},...e.max===void 0?{}:{maximum_scale:e.max},...e.major===void 0?{}:{major_unit:e.major},...e.gridlines===void 0?{}:{has_major_gridlines:e.gridlines},...e.visible===void 0?{}:{visible:e.visible},...e.format===void 0?{}:{number_format:e.format},...e.reverse===void 0?{}:{reverse_order:e.reverse},...e.title===void 0||e.title===""?{}:{title:e.title}},N=e=>e===void 0?void 0:{rgb:e};function G(e){if(e===void 0||e===!1)return;if(e===!0)return{show_value:!0};const n=typeof e.color=="string"?N(e.color):void 0;return{...e.value===void 0?{}:{show_value:e.value},...e.percentage===void 0?{}:{show_percentage:e.percentage},...e.category===void 0?{}:{show_category_name:e.category},...e.series===void 0?{}:{show_series_name:e.series},...e.format===void 0?{}:{number_format:e.format},...e.position===void 0?{}:{position:e.position},...e.size===void 0?{}:{size:e.size},...n?{color:n}:{}}}const E=e=>{const n=e.find(o=>o.sheet);return n?.sheet&&n.row!==void 0&&n.col!==void 0?n.sheet.lookAt(n.row,n.col).format:void 0};export function categoryNumbers(e,n,o){if(!o.categories)return;const t=y(e,n,o.categories);return{values:t.map(i=>R(i.value)),format:E(t)}}export function chartDef(e,n,o){const{spec:t}=o,i=P(t.type),d=o.categories?y(e,n,o.categories):void 0,r=o.series.map((m,v)=>{const u=t.series[v],w=y(e,n,m.values),A=m.name?y(e,n,m.name)[0]:void 0,x=m.x?y(e,n,m.x):i?d:void 0,z=u.format??E(w),s=N(u.color);return{name:(A?O(A):u.name)??`Series${String(v+1)}`,values:w.map(g=>R(g.value)),...x?{x:x.map(g=>R(g.value))}:{},...z===void 0?{}:{number_format:z},...s?{color:s}:{},...u.smooth===void 0?{}:{smooth:u.smooth},...u.line_width===void 0?{}:{line_width:u.line_width},...u.marker_size===void 0?{}:{marker_size:u.marker_size},...u.type===void 0?{}:{type:u.type},...u.secondary===!0?{secondary:!0}:{}}}),l=Math.max(0,...r.map(m=>m.values.length)),p=d?d.map(O):Array.from({length:l},(m,v)=>String(v+1)),b=o.title?y(e,n,o.title)[0]:void 0,a=b?O(b):t.title,_=G(t.labels),h=C(t.value_axis),f=C(t.category_axis),c=C(t.secondary_axis);return{type:t.type,categories:p,series:r,...a===void 0||a===""?{}:{title:a},...t.legend===void 0?{}:{legend:t.legend},..._?{labels:_}:{},...t.gap_width===void 0?{}:{gap_width:t.gap_width},...t.overlap===void 0?{}:{overlap:t.overlap},...t.vary_by_categories===void 0?{}:{vary_by_categories:t.vary_by_categories},...t.hole_size===void 0?{}:{hole_size:t.hole_size},...h?{value_axis:h}:{},...f?{category_axis:f}:{},...c?{secondary_axis:c}:{},font_size:t.size??SHEET_CHART_DEFAULTS.size,title_size:t.title_size??SHEET_CHART_DEFAULTS.titleSize,font_color:N(t.color)??{rgb:SHEET_CHART_DEFAULTS.ink}}}export const chartSize=e=>({width:e.width??SHEET_CHART_DEFAULTS.width,height:e.height??SHEET_CHART_DEFAULTS.height}),chartSvg=(e,n,o,t={})=>L(e,n,o,{pointsPerPixel:SHEET_CHART_DEFAULTS.pixelsToPoints,...t});export function chartAfter(e,n){const o=i=>i?.startsWith("=")===!0?n(i):i,t=o(e.title);return{...e,...t===void 0?{}:{title:t},...e.categories===void 0?{}:{categories:n(e.categories)},series:e.series.map(i=>{const d=o(i.name);return{...i,values:n(i.values),...i.x===void 0?{}:{x:n(i.x)},...d===void 0?{}:{name:d}}})}}function J(e,n,o,t){if(t){const i=t.data;if(o.top===i.top&&o.bottom===i.bottom&&o.left===o.right){const d=t.columns[o.left-t.at.col];if(d)return`${t.name}[${d.name}]`}}return`${n===e?"":k(n.name)}${T(o)}`}const K=(e,n,o,t)=>typeof e.value(n,o,t)=="number",Q=(e,n,o,t)=>{const i=e.value(n,o,t);if(typeof i=="string")return!0;const d=n.lookAt(o,t).format;return typeof i=="number"&&d!==void 0&&/[ymd]/iu.test(d)};export function chartOfRange(e,n,o,t,i){const d=t.bottom-t.top+1,r=t.right-t.left+1,l=n.tables.find(s=>U(s.area,t.top,t.left)),p=s=>J(o,n,s,l),b=P(i),a=d>1&&Array.from({length:r},(s,g)=>t.left+g).some(s=>!K(e,n,t.top,s)),_=r>1&&(b||Array.from({length:d-(a?1:0)},(s,g)=>g).every(s=>Q(e,n,t.top+(a?1:0)+s,t.left)||e.value(n,t.top+(a?1:0)+s,t.left)===null)),h=t.top+(a?1:0),f=t.left+(_?1:0);if(h>t.bottom||f>t.right)return;const c=!b&&!M(i)&&t.right-f>t.bottom-h,m=[],v=(s,g)=>e.value(n,s,g)===null?void 0:`=${n===o?"":k(n.name)}${F({row:s,col:g})}`,u=c?{first:h,last:t.bottom}:{first:f,last:t.right};for(let s=u.first;s<=u.last;s++){const g=c?{top:s,left:f,bottom:s,right:t.right}:{top:h,left:s,bottom:t.bottom,right:s},$=c?_?v(s,t.left):void 0:a?v(t.top,s):void 0;m.push({values:p(g),...$===void 0?{}:{name:$}})}const w=c?a?{top:t.top,left:f,bottom:t.top,right:t.right}:void 0:_?{top:h,left:t.left,bottom:t.bottom,right:t.left}:void 0,A=m.length>1&&!M(i),x=M(i)?m.slice(0,1):m,z=x.length===1?x[0]?.name:void 0;return{type:i,...w?{categories:p(w)}:{},series:x,...A||M(i)?{legend:"bottom"}:{},...z===void 0?{}:{title:z}}}function S(e,n,o){if(!o?.node)return;const t=e.eval(o.node,{sheet:n,row:0,col:0,dr:0,dc:0});return t instanceof j?{sheet:t.sheet,area:{top:t.top,left:t.left,bottom:Math.min(t.bottom,Math.max(t.top,t.sheet.lastRow)),right:t.right}}:void 0}export function chartDataRange(e,n,o){const t=[S(e,n,o.categories),...o.series.flatMap(r=>[S(e,n,r.values),S(e,n,r.name),S(e,n,r.x)])].filter(r=>r!==void 0),i=t[0];if(!i||t.some(r=>r.sheet!==i.sheet))return;const d={top:Math.min(...t.map(r=>r.area.top)),left:Math.min(...t.map(r=>r.area.left)),bottom:Math.max(...t.map(r=>r.area.bottom)),right:Math.max(...t.map(r=>r.area.right))};return`${i.sheet===n?"":k(i.sheet.name)}${T(d)}`}export function readDataRange(e,n,o){const t=o.lastIndexOf("!"),i=t<0?void 0:o.slice(0,t).replace(/^'|'$/gu,""),d=i===void 0?n:e.wb.sheet(i.replaceAll("''","'")),r=V(o.slice(t+1).replaceAll("$",""));return d&&r?{sheet:d,area:r}:void 0}export function chartPlace(e,n,o){const t=I(e.at)??{row:0,col:0};return{left:o(t.col)+(e.x??0),top:n(t.row)+(e.y??0),...chartSize(e)}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{writeCsv as S}from"
|
|
2
|
+
import{writeCsv as S}from"@allyhub/formats";import{isDateCode as k,shownValue as b}from"./format.js";import{CellError as w,dateOf as j}from"./values.js";const y=t=>(t.split(";")[0]??"").replace(/"[^"]*"|\\.|_.|\*./gu,"").replace(/\[(?![hms]+\])[^\]]*\]/giu,""),h=new Map;function _(t){if(t===void 0)return;if(h.has(t))return h.get(t);let n;if(k(t)){const r=y(t).toLowerCase(),o=/\[(h+|m+|s+)\]/u.test(r),e=[...r.matchAll(/\[?([ydhms])\1*\]?|am\/pm|a\/p/gu)].map(c=>c[0]);let s=!1,i=!1,u=!1;for(const[c,a]of e.entries()){const f=a.replace(/[[\]]/gu,"")[0];if(f==="y"||f==="d")s=!0;else if(f==="h"||a.includes("/"))i=!0;else if(f==="s")i=!0,u=!0;else if(f==="m"){const l=e[c-1]?.replace(/[[\]]/gu,"")[0],m=e[c+1]?.replace(/[[\]]/gu,"")[0];a.startsWith("[")||l==="h"||m==="s"?i=!0:s=!0}}o?n={kind:"duration",seconds:u}:s&&i?n={kind:"datetime",seconds:u}:i?n={kind:"time",seconds:u}:s&&(n={kind:"date",seconds:!1})}return h.set(t,n),n}const $=864e5,A=2958465,d=(t,n=2)=>String(t).padStart(n,"0");export const excelNumber=t=>t===0?0:Number(t.toPrecision(15));function x(t,n,r=2){const o=Math.floor(t/1e3),e=t%1e3;let s=`${d(Math.floor(o/3600),r)}:${d(Math.floor(o/60)%60)}`;return(n||o%60!==0||e!==0)&&(s+=`:${d(o%60)}`),e!==0&&(s+=`.${d(e,3).replace(/0+$/u,"")}`),s}function T(t){const n=t<0?"-":"";let r=Math.abs(t);const o=Math.floor(r/36e5);r-=o*36e5;const e=Math.floor(r/6e4);r-=e*6e4;const s=[o>0?`${String(o)}H`:"",e>0?`${String(e)}M`:"",r>0?`${String(r/1e3)}S`:""].join("");return`${n}PT${s||"0S"}`}function M(t,n,r){const o=Math.round(t*$);if(n.kind==="duration")return r==="json"?T(o):`${o<0?"-":""}${x(Math.abs(o),n.seconds,1)}`;if(t<0||t>=A+1)return;const e=Math.floor(o/$),s=x(o-e*$,n.seconds||r==="json");if(e===0||n.kind==="time")return s;if(e===60)return;const{year:i,month:u,day:c}=j(e),a=`${d(i,4)}-${d(u)}-${d(c)}`;return n.kind==="date"?a:`${a}${r==="json"?"T":" "}${s}`}export function csvText(t,n,r="data"){if(t===null)return"";if(r==="shown")return b(t,n);if(typeof t=="boolean")return t?"TRUE":"FALSE";if(t instanceof w)return t.code;if(typeof t=="string")return t;const o=_(n);return(o&&M(t,o,"csv"))??String(excelNumber(t))}export function dataValue(t,n,r="data"){if(t===null)return null;if(r==="shown")return b(t,n);if(t instanceof w)return t.code;if(typeof t!="number")return t;const o=_(n);return(o&&M(t,o,"json"))??excelNumber(t)}const p=(t,n,r)=>t.lookAt(n,r).format;function g(t,n){const r=t.used;if(!r)return[];const o=[];for(let e=0;e<=r.bottom;e++){const s=[];for(let i=0;i<=r.right;i++)s.push(n(e,i));o.push(s)}return o}export function csvOf(t,n,r={}){const o=g(n,(e,s)=>csvText(t.value(n,e,s),p(n,e,s),r.values));return S(o,{delimiter:",",newline:`\r
|
|
3
3
|
`,bom:r.bom??!0,finalNewline:!0})}const E=t=>t.replaceAll("|","\\|").replace(/\r?\n/gu,"<br>");export function markdownOf(t,n,r={}){const o=r.values??"shown",e=[],s=g(n,(f,l)=>{const m=t.value(n,f,l);return f>0&&m!==null&&(e[l]=(e[l]??!0)&&typeof m=="number"),csvText(m,p(n,f,l),o)}),[i,...u]=s;if(!i)return"";const c=f=>`| ${f.map(E).join(" | ")} |`,a=i.map((f,l)=>e[l]===!0?"---:":"---");return`${[c(i),`| ${a.join(" | ")} |`,...u.map(c)].join(`
|
|
4
4
|
`)}
|
|
5
5
|
`}export function tableRows(t,n,r={}){const{sheet:o,at:e}=n,s=[];for(let i=0;i<n.rows;i++){const u={};for(const c of n.columns){const a=e.row+1+i,f=e.col+c.index;u[c.name]=dataValue(t.value(o,a,f),p(o,a,f),r.values)}s.push(u)}return s}export function jsonOf(t,n={}){const{wb:r}=t,o={};for(const e of r.sheets){const s={};for(const i of e.tables)s[i.name]=tableRows(t,i,n);o[e.name]={rows:g(e,(i,u)=>dataValue(t.value(e,i,u),p(e,i,u),n.values)),...e.tables.length>0?{tables:s}:{}}}return{...r.title===void 0?{}:{title:r.title},sheets:o}}
|
|
@@ -6,13 +6,18 @@ export interface SheetProblem {
|
|
|
6
6
|
line?: number;
|
|
7
7
|
message: string;
|
|
8
8
|
}
|
|
9
|
+
/** What the model calls a sheet's own file, whatever it is named: the build says which file it is. */
|
|
9
10
|
export declare const ENTRY = "sheet.yaml";
|
|
11
|
+
/** What the model calls a sheet's code (its file's `code`), whatever it is named. */
|
|
12
|
+
export declare const CODE = "sheet.ts";
|
|
10
13
|
export type YamlPath = readonly (string | number)[];
|
|
11
14
|
export interface ReadFile {
|
|
12
15
|
file?: SheetFile;
|
|
13
16
|
problems: SheetProblem[];
|
|
14
17
|
lineOf: (path: YamlPath) => number | undefined;
|
|
15
18
|
}
|
|
19
|
+
/** The module a sheet's file names as its code (`code`), from its folder. */
|
|
20
|
+
export declare const codeOf: (text: string) => string | undefined;
|
|
16
21
|
/** The CSV files a sheet.yaml names, from its folder. */
|
|
17
22
|
export declare function dataFilesOf(text: string): string[];
|
|
18
23
|
export declare function readSheetFile(text: string): ReadFile;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{readDataFile as c}from"@allyhub/formats";import{LineCounter as p,isMap as
|
|
2
|
+
import{readDataFile as c}from"@allyhub/formats";import{LineCounter as p,isMap as d,isScalar as f,parseDocument as m,visit as h}from"yaml";export const ENTRY="sheet.yaml",CODE="sheet.ts",codeOf=i=>readSheetFile(i).file?.code;export function dataFilesOf(i){const{file:t}=readSheetFile(i);return[...new Set(t?.sheets.flatMap(s=>[...(s.tables??[]).map(n=>n.rows),...(s.blocks??[]).map(n=>n.rows)])??[])]}function g(i){const t=[];return h(i,{Map(s,n){if(!d(n))return;const a=new Set;for(const o of n.items){const e=f(o.key)?String(o.key.value):void 0;if(e!==void 0)if(a.has(e)){const r=f(o.key)?o.key.range?.[0]??0:0;t.push({at:r,key:e})}else a.add(e)}}}),t}export function readSheetFile(i){const t=new p,s=m(i,{lineCounter:t,uniqueKeys:!1}),n=e=>{for(let r=e.length;r>=0;r--){const u=s.getIn(e.slice(0,r),!0)?.range?.[0];if(u!==void 0)return t.linePos(u).line}},a=g(s);if(s.errors.length>0||a.length>0)return{problems:[...s.errors.map(e=>({file:ENTRY,line:t.linePos(e.pos[0]).line,message:`not YAML: ${e.message.split(`
|
|
3
3
|
`)[0]??""}`})),...a.map(e=>({file:ENTRY,line:t.linePos(e.at).line,message:`not YAML: Map keys must be unique (${e.key})`}))],lineOf:n};const o=c("sheet",s.toJS()??{});return o.ok?{file:o.value,problems:[],lineOf:n}:{problems:o.problems.map(e=>{const r=n(e.path===""?[]:e.path.split(".").map(l=>/^\d+$/u.test(l)?Number(l):l));return{file:ENTRY,...r===void 0?{}:{line:r},message:`${e.path===""?"":`${e.path}: `}${e.message}`}}),lineOf:n}}
|
|
@@ -42,7 +42,16 @@ export type BinaryOp = "+" | "-" | "*" | "/" | "^" | "&" | "=" | "<>" | "<" | "<
|
|
|
42
42
|
| " "
|
|
43
43
|
/** Union, inside parentheses. */
|
|
44
44
|
| ",";
|
|
45
|
-
|
|
45
|
+
/** The blanks a formula's text has around a part, kept so it prints as it was written. */
|
|
46
|
+
export interface Spacing {
|
|
47
|
+
/** Before it. */
|
|
48
|
+
before?: string;
|
|
49
|
+
/** Before a binary's operator, or before the closing bracket of a call, an invocation or parentheses. */
|
|
50
|
+
inner?: string;
|
|
51
|
+
/** After it, before the comma that ends it: an argument's. */
|
|
52
|
+
after?: string;
|
|
53
|
+
}
|
|
54
|
+
export type Node = ({
|
|
46
55
|
kind: "number";
|
|
47
56
|
value: number;
|
|
48
57
|
raw: string;
|
|
@@ -96,6 +105,8 @@ export type Node = {
|
|
|
96
105
|
} | {
|
|
97
106
|
kind: "paren";
|
|
98
107
|
arg: Node;
|
|
108
|
+
}) & {
|
|
109
|
+
space?: Spacing;
|
|
99
110
|
};
|
|
100
111
|
/** A formula that does not parse, and where in its text. */
|
|
101
112
|
export interface ParseError {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Node } from "./ast.js";
|
|
2
2
|
/** A formula as it reads `rows` down and `columns` across from where it is. */
|
|
3
3
|
export declare function moveFormula(node: Node, rows: number, columns: number): Node;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* The same text for every cell a fill of one formula gives: its relative
|
|
6
|
+
* references as distances. Written by hand: JSON.stringify with a replacer
|
|
7
|
+
* took 12 s of a sheet of 39,000 long formulas.
|
|
8
|
+
*/
|
|
5
9
|
export declare function relativeKey(node: Node, row: number, col: number): string;
|
|
6
10
|
//# sourceMappingURL=move.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{MAX_COLUMNS as
|
|
2
|
+
import{MAX_COLUMNS as f,MAX_ROWS as p}from"../address.js";import{mapNode as d}from"./walk.js";function h(t,u,c){if(t.abs||u===0)return t;const r=t.index+u;return r<0||r>=c?void 0:{...t,index:r}}function l(t,u,c){const r=t.col&&h(t.col,c,f),s=t.col2&&h(t.col2,c,f),i=t.row&&h(t.row,u,p),a=t.row2&&h(t.row2,u,p),o=(e,n)=>e!==void 0&&n===void 0;return o(t.col,r)||o(t.col2,s)||o(t.row,i)||o(t.row2,a)?{kind:"error",code:"#REF!",...t.sheet===void 0?{}:{sheet:t.sheet}}:r===t.col&&s===t.col2&&i===t.row&&a===t.row2?t:{...t,...r?{col:r}:{},...s?{col2:s}:{},...i?{row:i}:{},...a?{row2:a}:{}}}export function moveFormula(t,u,c){return u===0&&c===0?t:d(t,r=>r.kind==="ref"?l(r,u,c):r)}export function relativeKey(t,u,c){const r=[],s=e=>e===void 0?"~":JSON.stringify(e),i=(e,n)=>e===void 0?"~":e.abs?`$${String(e.index)}`:`^${String(e.index-n)}`,a=e=>{r.push("(");for(const n of e)o(n);r.push(")")},o=e=>{switch(e.kind){case"number":r.push("n",String(e.value),s(e.raw));return;case"string":r.push("s",s(e.value));return;case"boolean":r.push(e.value?"T":"F");return;case"error":r.push("e",e.code,s(e.sheet));return;case"missing":r.push("m");return;case"ref":r.push(e.range?"R":"r",s(e.sheet),s(e.lastSheet),i(e.col,c),i(e.row,u),i(e.col2,c),i(e.row2,u));return;case"structured":r.push("t",s(e.table),JSON.stringify(e.sections),JSON.stringify(e.columns),e.thisRow?"@":"-");return;case"name":r.push("a",s(e.name),s(e.sheet));return;case"unary":case"postfix":r.push(e.kind==="unary"?"u":"p",e.op),o(e.arg);return;case"paren":r.push("{"),o(e.arg),r.push("}");return;case"binary":r.push("b",JSON.stringify(e.op)),o(e.left),o(e.right);return;case"call":r.push("c",s(e.name),s(e.written)),a(e.args);return;case"invoke":r.push("i"),o(e.callee),a(e.args);return;case"array":r.push("[");for(const n of e.rows)a(n);r.push("]");return}};return o(t),r.join(" ")}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{MAX_COLUMNS as y,MAX_ROWS as l,columnIndex as d}from"../address.js";import{errorOf as v}from"../values.js";import{TABLE_SECTIONS as N}from"./ast.js";class m extends Error{at;constructor(t,s){super(t),this.at=s}}const R=new Set(["=","<>","<","<=",">",">="]),b={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"&":2,"+":3,"-":3,"*":4,"/":4,"^":5},g=i=>i>="0"&&i<="9",p=i=>/[\p{L}_\\]/u.test(i)||i>="\uD800"&&i<="\uDFFF",w=i=>/[\p{L}\p{N}\p{M}_.?\\]/u.test(i)||i>="\uD800"&&i<="\uDFFF",f=(i,t)=>({index:i,abs:t});class C{at=0;s;constructor(t){this.s=t}blanks(){const t=this.at;for(;/\s/u.test(this.s.charAt(this.at));)this.at+=1;return this.at>t}peek(t){return this.s.startsWith(t,this.at)}eat(t){return this.peek(t)?(this.at+=t.length,!0):!1}stop(t,s=this.at){throw new m(t,s)}parse(){this.eat("="),this.blanks(),this.at>=this.s.length&&this.stop("a formula with nothing in it");const t=this.expression(0);return this.blanks(),this.at<this.s.length&&this.stop(`"${this.s.charAt(this.at)}" where an operator should be`),t}operator(){this.blanks();const t=this.s.slice(this.at,this.at+2);if(R.has(t))return t;const s=this.s.charAt(this.at);return b[s]===void 0?void 0:s}expression(t){let s=this.prefix();for(;;){const e=this.operator();if(e===void 0)return s;const n=b[e]??0;if(n<=t)return s;this.at+=e.length,this.blanks();const r=this.expression(n);s={kind:"binary",op:e,left:s,right:r}}}prefix(){this.blanks();for(const t of["-","+","@"])if(this.eat(t))return{kind:"unary",op:t,arg:this.prefix()};return this.postfix()}postfix(){let t=this.references();for(;;){const s=this.at;if(this.blanks(),this.eat("%")){t={kind:"postfix",op:"%",arg:t};continue}if(this.at=s,this.peek("#")&&!A(this.s,this.at)){this.at+=1,t={kind:"postfix",op:"#",arg:t};continue}if(this.peek("(")&&(t.kind==="call"||t.kind==="paren")){const{args:e}=this.call("");t={kind:"invoke",callee:t,args:e};continue}return t}}references(){let t=this.primary();for(;;){if(this.peek(":")){this.at+=1,this.blanks();const e=this.primary();t={kind:"binary",op:":",left:t,right:e};continue}const s=this.at;if(E(t)&&this.blanks()&&this.startsReference()){const e=this.primary();t={kind:"binary",op:" ",left:t,right:e};continue}return this.at=s,t}}startsReference(){const t=this.s.charAt(this.at);return t==="$"||t==="'"||t==="("||t==="["||p(t)}primary(){this.blanks();const t=this.s.charAt(this.at);if(t===""&&this.stop("the formula ends where a value should be"),t==="(")return this.parenthesis();if(t==="{")return this.arrayConstant();if(t==='"')return{kind:"string",value:this.text()};if(g(t)||t==="."){const s=k(this.s,this.at);return s?(this.at=s.end,{kind:"ref",...s.ref}):this.number()}return t==="#"?this.errorLiteral(void 0):t==="["?this.bracket(void 0):t==="$"||t==="'"||p(t)?this.word():this.stop(`"${t}" where a value should be`)}parenthesis(){const t=this.at;this.at+=1;let s=this.expression(0);for(this.blanks();this.eat(",");){const e=this.expression(0);s={kind:"binary",op:",",left:s,right:e},this.blanks()}return this.eat(")")||this.stop("a ( that is never closed",t),{kind:"paren",arg:s}}number(){const t=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/u.exec(this.s.slice(this.at));return t?(this.at+=t[0].length,{kind:"number",value:Number(t[0]),raw:t[0]}):this.stop("a number that is not one")}text(){const t=this.at;this.at+=1;let s="";for(;;){this.at>=this.s.length&&this.stop('a " that is never closed',t);const e=this.s.charAt(this.at);if(e==='"'){if(this.s.charAt(this.at+1)!=='"')return this.at+=1,s;this.at+=1}s+=e,this.at+=1}}errorLiteral(t){const s=A(this.s,this.at);return s===void 0?this.stop("a # that names no error"):(this.at+=s.length,{kind:"error",code:s,...t===void 0?{}:{sheet:t}})}arrayConstant(){const t=this.at;this.at+=1;const s=[[]];for(;;)if(this.blanks(),s[s.length-1]?.push(this.arrayItem()),this.blanks(),!this.eat(",")){if(this.eat(";")){s.push([]);continue}if(this.eat("}"))break;this.stop("a { that is never closed",t)}const e=s[0]?.length;return s.some(n=>n.length!==e)&&this.stop("an array whose rows are not all as long",t),{kind:"array",rows:s}}arrayItem(){const t=this.s.charAt(this.at);if(t==='"')return{kind:"string",value:this.text()};if(t==="#")return this.errorLiteral(void 0);if(t==="-"||t==="+")return this.at+=1,{kind:"unary",op:t,arg:this.number()};if(g(t)||t===".")return this.number();const s=this.name(),e=s.toUpperCase();return e==="TRUE"||e==="FALSE"?{kind:"boolean",value:e==="TRUE"}:this.stop(`${s} in an array: an array holds only constants`)}name(){const t=this.at;for(;this.at<this.s.length&&w(this.s.charAt(this.at));)this.at+=1;return this.s.slice(t,this.at)}quoted(){const t=this.at;this.at+=1;let s="";for(;;){this.at>=this.s.length&&this.stop("a ' that is never closed",t);const e=this.s.charAt(this.at);if(e==="'"){if(this.s.charAt(this.at+1)!=="'")return this.at+=1,s;this.at+=1}s+=e,this.at+=1}}word(){const t=this.sheetPrefix();if(t)return this.afterSheet(t.first,t.last);const s=k(this.s,this.at);if(s)return this.at=s.end,{kind:"ref",...s.ref};const e=x(this.s,this.at);if(e)return this.at=e.end,{kind:"ref",...e.ref};if(this.peek("$"))return this.stop('a "$" that is not part of a reference');const n=this.at,r=this.name();if(r==="")return this.stop(`"${this.s.charAt(n)}" in a name`);if(this.peek("("))return this.call(r);if(this.peek("["))return this.bracket(r);const h=r.toUpperCase();return h==="TRUE"||h==="FALSE"?{kind:"boolean",value:h==="TRUE"}:{kind:"name",name:r}}sheetPrefix(){const t=this.at;if(this.peek("'")){const e=this.quoted();if(!this.eat("!")){this.at=t;return}const n=e.indexOf(":");return n>0?{first:e.slice(0,n),last:e.slice(n+1)}:{first:e}}const s=this.name();if(s!==""&&this.eat("!"))return{first:s};if(s!==""&&this.eat(":")){const e=this.name();if(e!==""&&this.eat("!"))return{first:s,last:e}}this.at=t}afterSheet(t,s){const e={sheet:t,...s===void 0?{}:{lastSheet:s}};if(this.peek("#"))return this.errorLiteral(t);const n=k(this.s,this.at);if(n)return this.at=n.end,{kind:"ref",...e,...n.ref};const r=x(this.s,this.at);if(r)return this.at=r.end,{kind:"ref",...e,...r.ref};const h=this.name();return h===""?this.stop(`nothing after ${t}!`):{kind:"name",name:h,sheet:t}}call(t){const s=this.at;this.at+=1;const e=[];this.blanks();const n=()=>({kind:"call",name:t.toUpperCase(),written:t,args:e});if(this.eat(")"))return n();for(;;)if(this.blanks(),this.peek(",")||this.peek(")")?e.push({kind:"missing"}):e.push(this.expression(0)),this.blanks(),!this.eat(",")){if(this.eat(")"))return n();this.stop(`a ( of ${t.toUpperCase()} that is never closed`,s)}}columnName(){let t="";for(;;){this.at>=this.s.length&&this.stop("a [ that is never closed");const s=this.s.charAt(this.at);if(s==="]")return t;if(s==="["&&this.stop("a [ inside a column's name"),s==="'"){this.at+=1,t+=this.s.charAt(this.at),this.at+=1;continue}t+=s,this.at+=1}}bracket(t){const s=this.at;this.at+=1;const e={kind:"structured",...t===void 0?{}:{table:t},sections:[],columns:[],thisRow:!1};if(this.eat("]"))return e;if(!(this.peek("[")||this.peek("#")||this.peek("@"))){const r=this.columnName();return this.at+=1,t===void 0&&/[!']/u.test(this.s.charAt(this.at))&&this.stop("a formula that reaches into another workbook",s),t===void 0&&p(this.s.charAt(this.at))&&this.stop("a formula that reaches into another workbook",s),e.columns=[r.trim()],e}return this.eat("@")?(e.thisRow=!0,this.eat("]")||(this.peek("[")?this.items(e):e.columns=[this.columnName().trim()],this.eat("]")||this.stop("a [ that is never closed",s)),e):(this.items(e),this.eat("]")||this.stop("a [ that is never closed",s),e)}items(t){for(;;){if(this.blanks(),this.peek("#"))this.section(t);else if(this.eat("["))if(this.peek("#"))this.section(t),this.eat("]")||this.stop("a [ that is never closed");else{const s=this.columnName().trim();this.at+=1,t.columns.push(s),this.eat(":")&&(this.eat("[")||this.stop("a column's name after :"),t.columns.push(this.columnName().trim()),this.at+=1)}else this.stop("a column or a section of a table");if(this.blanks(),!this.eat(","))return}}section(t){const s=this.s.slice(this.at).toLowerCase(),e=N.find(n=>s.startsWith(n.toLowerCase()));e===void 0&&this.stop("a section of a table that is not one"),this.at+=e.length,e==="#This Row"?t.thisRow=!0:t.sections.push(e)}}const E=i=>i.kind==="ref"||i.kind==="name"||i.kind==="structured"||i.kind==="call"||i.kind==="paren"||i.kind==="binary"&&(i.op===":"||i.op===" ");function A(i,t){const s=/^#[A-Za-z0-9_/]+[!?]?/u.exec(i.slice(t));return s?v(s[0])?.code:void 0}const u=(i,t)=>{const s=i.charAt(t);return s!==""&&(w(s)||s==="("||s==="!"||s==="[")};function x(i,t){const s=i.slice(t),e=/^(\$?)([A-Za-z]{1,3}):(\$?)([A-Za-z]{1,3})/u.exec(s);if(e){const a=t+e[0].length,o=d(e[2]??""),c=d(e[4]??"");if(o!==void 0&&c!==void 0&&!u(i,a))return{ref:{col:f(o,e[1]==="$"),col2:f(c,e[3]==="$"),range:!0},end:a}}const n=/^(\$?)([A-Za-z]{1,3})(\$?)([1-9]\d*)/u.exec(s);if(!n)return;const r=$(n),h=t+n[0].length;if(!(!r||u(i,h))){if(i.charAt(h)===":"){const a=/^(\$?)([A-Za-z]{1,3})(\$?)([1-9]\d*)/u.exec(i.slice(h+1));if(a){const o=$(a),c=h+1+a[0].length;if(o&&!u(i,c))return{ref:{...r,col2:o.col,row2:o.row,range:!0},end:c}}}return{ref:{...r,range:!1},end:h}}}function $(i){const t=d(i[2]??""),s=Number(i[4])-1;if(!(t===void 0||t>=y||s>=l))return{col:f(t,i[1]==="$"),row:f(s,i[3]==="$")}}function k(i,t){const s=/^(\$?)([1-9]\d*):(\$?)([1-9]\d*)/u.exec(i.slice(t));if(!s)return;const e=t+s[0].length,n=Number(s[2])-1,r=Number(s[4])-1;if(!(n>=l||r>=l||u(i,e)))return{ref:{row:f(n,s[1]==="$"),row2:f(r,s[3]==="$"),range:!0},end:e}}export function parseFormula(i){try{return{ok:!0,node:new C(i).parse()}}catch(t){if(t instanceof m)return{ok:!1,error:{message:t.message,at:t.at}};throw t}}
|
|
2
|
+
import{MAX_COLUMNS as N,MAX_ROWS as d,columnIndex as p}from"../address.js";import{errorOf as R}from"../values.js";import{TABLE_SECTIONS as C}from"./ast.js";class g extends Error{at;constructor(t,s){super(t),this.at=s}}const E=new Set(["=","<>","<","<=",">",">="]),w={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"&":2,"+":3,"-":3,"*":4,"/":4,"^":5},x=i=>i>="0"&&i<="9",m=i=>/[\p{L}_\\]/u.test(i)||i>="\uD800"&&i<="\uDFFF",A=i=>/[\p{L}\p{N}\p{M}_.?\\]/u.test(i)||i>="\uD800"&&i<="\uDFFF",u=(i,t)=>({index:i,abs:t});function f(i,t){const s={};return t.before&&(s.before=t.before),t.inner&&(s.inner=t.inner),t.after&&(s.after=t.after),Object.keys(s).length===0?i:{...i,space:{...i.space,...s}}}class L{at=0;s;constructor(t){this.s=t}blanks(){return this.space()!==""}space(){const t=this.at;for(;/\s/u.test(this.s.charAt(this.at));)this.at+=1;return this.s.slice(t,this.at)}peek(t){return this.s.startsWith(t,this.at)}eat(t){return this.peek(t)?(this.at+=t.length,!0):!1}stop(t,s=this.at){throw new g(t,s)}parse(){this.eat("="),this.s.slice(this.at).trim()===""&&this.stop("a formula with nothing in it",this.s.length);const t=this.expression(0);return this.blanks(),this.at<this.s.length&&this.stop(`"${this.s.charAt(this.at)}" where an operator should be`),t}operator(){const t=this.at,s=this.space(),e=this.s.slice(this.at,this.at+2),n=this.s.charAt(this.at);return this.at=t,E.has(e)?{op:e,inner:s}:w[n]===void 0?void 0:{op:n,inner:s}}expression(t){let s=this.prefix();for(;;){const e=this.operator();if(e===void 0)return s;const{op:n,inner:r}=e,h=w[n]??0;if(h<=t)return s;this.at+=r.length+n.length;const a=this.expression(h);s=f({kind:"binary",op:n,left:s,right:a},{inner:r})}}prefix(){const t=this.at,s=this.space();for(const e of["-","+","@"])if(this.eat(e))return f({kind:"unary",op:e,arg:this.prefix()},{before:s});return this.at=t,this.postfix()}postfix(){let t=this.references();for(;;){const s=this.at;if(this.blanks(),this.eat("%")){t={kind:"postfix",op:"%",arg:t};continue}if(this.at=s,this.peek("#")&&!$(this.s,this.at)){this.at+=1,t={kind:"postfix",op:"#",arg:t};continue}if(this.peek("(")&&(t.kind==="call"||t.kind==="paren")){const{args:e}=this.call("");t={kind:"invoke",callee:t,args:e};continue}return t}}references(){let t=this.primary();for(;;){if(this.peek(":")){this.at+=1,this.blanks();const e=this.primary();t={kind:"binary",op:":",left:t,right:e};continue}const s=this.at;if(S(t)&&this.blanks()&&this.startsReference()){const e=this.primary();t={kind:"binary",op:" ",left:t,right:e};continue}return this.at=s,t}}startsReference(){const t=this.s.charAt(this.at);return t==="$"||t==="'"||t==="("||t==="["||m(t)}primary(){const t=this.space();return f(this.bare(),{before:t})}bare(){const t=this.s.charAt(this.at);if(t===""&&this.stop("the formula ends where a value should be"),t==="(")return this.parenthesis();if(t==="{")return this.arrayConstant();if(t==='"')return{kind:"string",value:this.text()};if(x(t)||t==="."){const s=k(this.s,this.at);return s?(this.at=s.end,{kind:"ref",...s.ref}):this.number()}return t==="#"?this.errorLiteral(void 0):t==="["?this.bracket(void 0):t==="$"||t==="'"||m(t)?this.word():this.stop(`"${t}" where a value should be`)}parenthesis(){const t=this.at;this.at+=1;let s=this.expression(0),e=this.space();for(;this.eat(",");){const n=this.expression(0);s=f({kind:"binary",op:",",left:s,right:n},{inner:e}),e=this.space()}return this.eat(")")||this.stop("a ( that is never closed",t),f({kind:"paren",arg:s},{inner:e})}number(){const t=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/u.exec(this.s.slice(this.at));return t?(this.at+=t[0].length,{kind:"number",value:Number(t[0]),raw:t[0]}):this.stop("a number that is not one")}text(){const t=this.at;this.at+=1;let s="";for(;;){this.at>=this.s.length&&this.stop('a " that is never closed',t);const e=this.s.charAt(this.at);if(e==='"'){if(this.s.charAt(this.at+1)!=='"')return this.at+=1,s;this.at+=1}s+=e,this.at+=1}}errorLiteral(t){const s=$(this.s,this.at);return s===void 0?this.stop("a # that names no error"):(this.at+=s.length,{kind:"error",code:s,...t===void 0?{}:{sheet:t}})}arrayConstant(){const t=this.at;this.at+=1;const s=[[]];for(;;)if(this.blanks(),s[s.length-1]?.push(this.arrayItem()),this.blanks(),!this.eat(",")){if(this.eat(";")){s.push([]);continue}if(this.eat("}"))break;this.stop("a { that is never closed",t)}const e=s[0]?.length;return s.some(n=>n.length!==e)&&this.stop("an array whose rows are not all as long",t),{kind:"array",rows:s}}arrayItem(){const t=this.s.charAt(this.at);if(t==='"')return{kind:"string",value:this.text()};if(t==="#")return this.errorLiteral(void 0);if(t==="-"||t==="+")return this.at+=1,{kind:"unary",op:t,arg:this.number()};if(x(t)||t===".")return this.number();const s=this.name(),e=s.toUpperCase();return e==="TRUE"||e==="FALSE"?{kind:"boolean",value:e==="TRUE"}:this.stop(`${s} in an array: an array holds only constants`)}name(){const t=this.at;for(;this.at<this.s.length&&A(this.s.charAt(this.at));)this.at+=1;return this.s.slice(t,this.at)}quoted(){const t=this.at;this.at+=1;let s="";for(;;){this.at>=this.s.length&&this.stop("a ' that is never closed",t);const e=this.s.charAt(this.at);if(e==="'"){if(this.s.charAt(this.at+1)!=="'")return this.at+=1,s;this.at+=1}s+=e,this.at+=1}}word(){const t=this.sheetPrefix();if(t)return this.afterSheet(t.first,t.last);const s=k(this.s,this.at);if(s)return this.at=s.end,{kind:"ref",...s.ref};const e=y(this.s,this.at);if(e)return this.at=e.end,{kind:"ref",...e.ref};if(this.peek("$"))return this.stop('a "$" that is not part of a reference');const n=this.at,r=this.name();if(r==="")return this.stop(`"${this.s.charAt(n)}" in a name`);if(this.peek("("))return this.call(r);if(this.peek("["))return this.bracket(r);const h=r.toUpperCase();return h==="TRUE"||h==="FALSE"?{kind:"boolean",value:h==="TRUE"}:{kind:"name",name:r}}sheetPrefix(){const t=this.at;if(this.peek("'")){const e=this.quoted();if(!this.eat("!")){this.at=t;return}const n=e.indexOf(":");return n>0?{first:e.slice(0,n),last:e.slice(n+1)}:{first:e}}const s=this.name();if(s!==""&&this.eat("!"))return{first:s};if(s!==""&&this.eat(":")){const e=this.name();if(e!==""&&this.eat("!"))return{first:s,last:e}}this.at=t}afterSheet(t,s){const e={sheet:t,...s===void 0?{}:{lastSheet:s}};if(this.peek("#"))return this.errorLiteral(t);const n=k(this.s,this.at);if(n)return this.at=n.end,{kind:"ref",...e,...n.ref};const r=y(this.s,this.at);if(r)return this.at=r.end,{kind:"ref",...e,...r.ref};const h=this.name();return h===""?this.stop(`nothing after ${t}!`):{kind:"name",name:h,sheet:t}}call(t){const s=this.at;this.at+=1;const e=[],n=a=>f({kind:"call",name:t.toUpperCase(),written:t,args:e},{inner:a}),r=this.at,h=this.space();if(this.eat(")"))return n(h);for(this.at=r;;){const a=this.at,c=this.space();let o;this.peek(",")||this.peek(")")?o=f({kind:"missing"},{before:c}):(this.at=a,o=this.expression(0));const b=this.space();if(this.eat(",")){e.push(f(o,{after:b}));continue}if(e.push(o),this.eat(")"))return n(b);this.stop(`a ( of ${t.toUpperCase()} that is never closed`,s)}}columnName(){let t="";for(;;){this.at>=this.s.length&&this.stop("a [ that is never closed");const s=this.s.charAt(this.at);if(s==="]")return t;if(s==="["&&this.stop("a [ inside a column's name"),s==="'"){this.at+=1,t+=this.s.charAt(this.at),this.at+=1;continue}t+=s,this.at+=1}}bracket(t){const s=this.at;this.at+=1;const e={kind:"structured",...t===void 0?{}:{table:t},sections:[],columns:[],thisRow:!1};if(this.eat("]"))return e;if(!(this.peek("[")||this.peek("#")||this.peek("@"))){const r=this.columnName();return this.at+=1,t===void 0&&/[!']/u.test(this.s.charAt(this.at))&&this.stop("a formula that reaches into another workbook",s),t===void 0&&m(this.s.charAt(this.at))&&this.stop("a formula that reaches into another workbook",s),e.columns=[r.trim()],e}return this.eat("@")?(e.thisRow=!0,this.eat("]")||(this.peek("[")?this.items(e):e.columns=[this.columnName().trim()],this.eat("]")||this.stop("a [ that is never closed",s)),e):(this.items(e),this.eat("]")||this.stop("a [ that is never closed",s),e)}items(t){for(;;){if(this.blanks(),this.peek("#"))this.section(t);else if(this.eat("["))if(this.peek("#"))this.section(t),this.eat("]")||this.stop("a [ that is never closed");else{const s=this.columnName().trim();this.at+=1,t.columns.push(s),this.eat(":")&&(this.eat("[")||this.stop("a column's name after :"),t.columns.push(this.columnName().trim()),this.at+=1)}else this.stop("a column or a section of a table");if(this.blanks(),!this.eat(","))return}}section(t){const s=this.s.slice(this.at).toLowerCase(),e=C.find(n=>s.startsWith(n.toLowerCase()));e===void 0&&this.stop("a section of a table that is not one"),this.at+=e.length,e==="#This Row"?t.thisRow=!0:t.sections.push(e)}}const S=i=>i.kind==="ref"||i.kind==="name"||i.kind==="structured"||i.kind==="call"||i.kind==="paren"||i.kind==="binary"&&(i.op===":"||i.op===" ");function $(i,t){const s=/^#[A-Za-z0-9_/]+[!?]?/u.exec(i.slice(t));return s?R(s[0])?.code:void 0}const l=(i,t)=>{const s=i.charAt(t);return s!==""&&(A(s)||s==="("||s==="!"||s==="[")};function y(i,t){const s=i.slice(t),e=/^(\$?)([A-Za-z]{1,3}):(\$?)([A-Za-z]{1,3})/u.exec(s);if(e){const a=t+e[0].length,c=p(e[2]??""),o=p(e[4]??"");if(c!==void 0&&o!==void 0&&!l(i,a))return{ref:{col:u(c,e[1]==="$"),col2:u(o,e[3]==="$"),range:!0},end:a}}const n=/^(\$?)([A-Za-z]{1,3})(\$?)([1-9]\d*)/u.exec(s);if(!n)return;const r=v(n),h=t+n[0].length;if(!(!r||l(i,h))){if(i.charAt(h)===":"){const a=/^(\$?)([A-Za-z]{1,3})(\$?)([1-9]\d*)/u.exec(i.slice(h+1));if(a){const c=v(a),o=h+1+a[0].length;if(c&&!l(i,o))return{ref:{...r,col2:c.col,row2:c.row,range:!0},end:o}}}return{ref:{...r,range:!1},end:h}}}function v(i){const t=p(i[2]??""),s=Number(i[4])-1;if(!(t===void 0||t>=N||s>=d))return{col:u(t,i[1]==="$"),row:u(s,i[3]==="$")}}function k(i,t){const s=/^(\$?)([1-9]\d*):(\$?)([1-9]\d*)/u.exec(i.slice(t));if(!s)return;const e=t+s[0].length,n=Number(s[2])-1,r=Number(s[4])-1;if(!(n>=d||r>=d||l(i,e)))return{ref:{row:u(n,s[1]==="$"),row2:u(r,s[3]==="$"),range:!0},end:e}}export function parseFormula(i){try{return{ok:!0,node:new L(i).parse()}}catch(t){if(t instanceof g)return{ok:!1,error:{message:t.message,at:t.at}};throw t}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{columnLetter as
|
|
2
|
+
import{columnLetter as f}from"../address.js";const n=e=>`${e.abs?"$":""}${f(e.index)}`,s=e=>`${e.abs?"$":""}${String(e.index+1)}`;export function sheetPrefix(e,r){const t=r===void 0?e:`${e}:${r}`;return/^[\p{L}_][\p{L}\p{N}_.]*$/u.test(e)&&!/^[A-Za-z]{1,3}\d+$/u.test(e)&&!/^(?:TRUE|FALSE)$/iu.test(e)&&(r===void 0||/^[\p{L}_][\p{L}\p{N}_.]*$/u.test(r))?`${t}!`:`'${t.replaceAll("'","''")}'!`}function l(e){const r=e.sheet===void 0?"":sheetPrefix(e.sheet,e.lastSheet);if(e.row===void 0&&e.col&&e.col2)return`${r}${n(e.col)}:${n(e.col2)}`;if(e.col===void 0&&e.row&&e.row2)return`${r}${s(e.row)}:${s(e.row2)}`;if(!e.col||!e.row)return`${r}#REF!`;const t=`${n(e.col)}${s(e.row)}`;return e.col2&&e.row2?`${r}${t}:${n(e.col2)}${s(e.row2)}`:`${r}${t}`}const i=e=>e.replace(/([[\]#'@])/gu,"'$1"),p=e=>/^[\p{L}\p{N}_]+$/u.test(e);function d(e){const r=e.table??"",[t,u]=e.columns,$=e.columns.map(c=>`[${i(c)}]`).join(":");if(e.sections.length===0)return e.thisRow?t===void 0?`${r}[@]`:u!==void 0?`${r}[@${$}]`:`${r}[@${p(t)?i(t):$}]`:t===void 0?r===""?"[]":r:u!==void 0?`${r}[${$}]`:`${r}[${i(t)}]`;if(t===void 0&&e.sections.length===1)return`${r}[${e.sections[0]??""}]`;const a=e.sections.map(c=>`[${c}]`);return $!==""&&a.push($),`${r}[${a.join(",")}]`}function o(e){const{before:r="",after:t=""}=e.space??{};return`${r}${m(e)}${t}`}function m(e){const r=e.space?.inner??"";switch(e.kind){case"number":return e.raw;case"string":return`"${e.value.replaceAll('"','""')}"`;case"boolean":return e.value?"TRUE":"FALSE";case"error":return`${e.sheet===void 0?"":sheetPrefix(e.sheet)}${e.code}`;case"missing":return"";case"ref":return l(e);case"structured":return d(e);case"name":return`${e.sheet===void 0?"":sheetPrefix(e.sheet)}${e.name}`;case"unary":return`${e.op}${o(e.arg)}`;case"postfix":return`${o(e.arg)}${e.op}`;case"binary":return`${o(e.left)}${r}${e.op}${o(e.right)}`;case"call":return`${e.written}(${e.args.map(o).join(",")}${r})`;case"invoke":return`${o(e.callee)}(${e.args.map(o).join(",")}${r})`;case"array":return`{${e.rows.map(t=>t.map(o).join(",")).join(";")}}`;case"paren":return`(${o(e.arg)}${r})`}}export const printFormula=e=>`=${o(e)}`;
|