Repository: WebAssembly/wabt Branch: main Commit: e8ffd4d030ea Files: 1850 Total size: 8.5 MB Directory structure: gitextract_5fuyu_57/ ├── .clang-format ├── .flake8 ├── .git-blame-ignore-revs ├── .gitattributes ├── .github/ │ ├── actions/ │ │ └── release-archive/ │ │ └── action.yml │ └── workflows/ │ ├── build.yml │ ├── build_release.yml │ ├── build_source_release.yml │ └── wabt-cifuzz.yml ├── .gitignore ├── .gitmodules ├── .style.yapf ├── CMakeLists.txt ├── Contributing.md ├── LICENSE ├── Makefile ├── README.md ├── SECURITY.md ├── docs/ │ ├── decompiler.md │ ├── demo/ │ │ ├── custom.css │ │ ├── index.html │ │ ├── libwabt.js │ │ ├── libwabt.wasm │ │ ├── share.js │ │ ├── third_party/ │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── third_party.bundle.js │ │ ├── wasm2wat/ │ │ │ ├── demo.js │ │ │ ├── examples.js │ │ │ └── index.html │ │ └── wat2wasm/ │ │ ├── demo.js │ │ ├── examples.js │ │ ├── index.html │ │ └── worker.js │ ├── doc/ │ │ ├── spectest-interp.1.html │ │ ├── wasm-decompile.1.html │ │ ├── wasm-interp.1.html │ │ ├── wasm-objdump.1.html │ │ ├── wasm-stats.1.html │ │ ├── wasm-strip.1.html │ │ ├── wasm-validate.1.html │ │ ├── wasm2c.1.html │ │ ├── wasm2wat.1.html │ │ ├── wast2json.1.html │ │ ├── wat-desugar.1.html │ │ └── wat2wasm.1.html │ └── wast2json.md ├── fuzz-in/ │ ├── wasm/ │ │ └── stuff.wasm │ ├── wast/ │ │ └── basic.txt │ └── wast.dict ├── fuzzers/ │ ├── read_binary_interp_fuzzer.cc │ ├── read_binary_ir_fuzzer.cc │ ├── wasm2wat_fuzzer.cc │ ├── wasm_objdump_fuzzer.cc │ └── wat2wasm_fuzzer.cc ├── include/ │ └── wabt/ │ ├── apply-names.h │ ├── base-types.h │ ├── binary-reader-ir.h │ ├── binary-reader-logging.h │ ├── binary-reader-nop.h │ ├── binary-reader-objdump.h │ ├── binary-reader-stats.h │ ├── binary-reader.h │ ├── binary-writer-spec.h │ ├── binary-writer.h │ ├── binary.h │ ├── binding-hash.h │ ├── c-writer.h │ ├── cast.h │ ├── color.h │ ├── common.h │ ├── decompiler-ast.h │ ├── decompiler-ls.h │ ├── decompiler-naming.h │ ├── decompiler.h │ ├── error-formatter.h │ ├── error.h │ ├── expr-visitor.h │ ├── feature.def │ ├── feature.h │ ├── filenames.h │ ├── generate-names.h │ ├── interp/ │ │ ├── binary-reader-interp.h │ │ ├── interp-inl.h │ │ ├── interp-math.h │ │ ├── interp-util.h │ │ ├── interp-wasi.h │ │ ├── interp.h │ │ └── istream.h │ ├── intrusive-list.h │ ├── ir-util.h │ ├── ir.h │ ├── leb128.h │ ├── lexer-source-line-finder.h │ ├── lexer-source.h │ ├── literal.h │ ├── opcode-code-table.h │ ├── opcode.def │ ├── opcode.h │ ├── option-parser.h │ ├── range.h │ ├── resolve-names.h │ ├── result.h │ ├── sha256.h │ ├── shared-validator.h │ ├── stream.h │ ├── string-format.h │ ├── string-util.h │ ├── token.def │ ├── token.h │ ├── tracing.h │ ├── type-checker.h │ ├── type.h │ ├── utf8.h │ ├── validator.h │ ├── wast-lexer.h │ ├── wast-parser.h │ └── wat-writer.h ├── man/ │ ├── spectest-interp.1 │ ├── wasm-decompile.1 │ ├── wasm-interp.1 │ ├── wasm-objdump.1 │ ├── wasm-stats.1 │ ├── wasm-strip.1 │ ├── wasm-validate.1 │ ├── wasm2c.1 │ ├── wasm2wat.1 │ ├── wast2json.1 │ ├── wat-desugar.1 │ └── wat2wasm.1 ├── scripts/ │ ├── TC-s390x.cmake │ ├── check_clean.py │ ├── clang-format-diff.sh │ ├── coverage.sh │ ├── example-project/ │ │ ├── CMakeLists.txt │ │ └── example.cpp │ ├── fuzz-wasm-objdump.sh │ ├── fuzz-wasm2wat.sh │ ├── fuzz-wat2wasm.sh │ ├── gen-emscripten-exported-json.py │ ├── gen-wasm2c-templates.cmake │ ├── generate-html-docs.sh │ ├── help2man.lua │ ├── sha256sum.py │ └── wabt-config.cmake.in ├── src/ │ ├── apply-names.cc │ ├── binary-reader-ir.cc │ ├── binary-reader-logging.cc │ ├── binary-reader-objdump.cc │ ├── binary-reader-stats.cc │ ├── binary-reader.cc │ ├── binary-writer-spec.cc │ ├── binary-writer.cc │ ├── binary.cc │ ├── binding-hash.cc │ ├── c-writer.cc │ ├── color.cc │ ├── common.cc │ ├── config.cc │ ├── config.h.in │ ├── decompiler.cc │ ├── emscripten-exports.txt │ ├── emscripten-helpers.cc │ ├── error-formatter.cc │ ├── expr-visitor.cc │ ├── feature.cc │ ├── filenames.cc │ ├── generate-names.cc │ ├── interp/ │ │ ├── binary-reader-interp.cc │ │ ├── interp-util.cc │ │ ├── interp-wasi.cc │ │ ├── interp-wasm-c-api.cc │ │ ├── interp.cc │ │ ├── istream.cc │ │ └── wasi_api.def │ ├── ir-util.cc │ ├── ir.cc │ ├── leb128.cc │ ├── lexer-keywords.txt │ ├── lexer-source-line-finder.cc │ ├── lexer-source.cc │ ├── literal.cc │ ├── opcode-code-table.c │ ├── opcode.cc │ ├── option-parser.cc │ ├── prebuilt/ │ │ ├── .clang-format │ │ ├── lexer-keywords.cc │ │ ├── wasm2c_atomicops_source_declarations.cc │ │ ├── wasm2c_header_bottom.cc │ │ ├── wasm2c_header_top.cc │ │ ├── wasm2c_simd_source_declarations.cc │ │ ├── wasm2c_source_declarations.cc │ │ └── wasm2c_source_includes.cc │ ├── resolve-names.cc │ ├── sha256.cc │ ├── shared-validator.cc │ ├── stream.cc │ ├── template/ │ │ ├── wasm2c.bottom.h │ │ ├── wasm2c.declarations.c │ │ ├── wasm2c.includes.c │ │ ├── wasm2c.top.h │ │ ├── wasm2c_atomicops.declarations.c │ │ └── wasm2c_simd.declarations.c │ ├── test-binary-reader.cc │ ├── test-filenames.cc │ ├── test-hexfloat.cc │ ├── test-interp.cc │ ├── test-intrusive-list.cc │ ├── test-literal.cc │ ├── test-option-parser.cc │ ├── test-utf8.cc │ ├── test-wast-parser.cc │ ├── token.cc │ ├── tools/ │ │ ├── spectest-interp.cc │ │ ├── wasm-decompile.cc │ │ ├── wasm-interp.cc │ │ ├── wasm-objdump.cc │ │ ├── wasm-stats.cc │ │ ├── wasm-strip.cc │ │ ├── wasm-validate.cc │ │ ├── wasm2c.cc │ │ ├── wasm2wat-fuzz.cc │ │ ├── wasm2wat.cc │ │ ├── wast2json.cc │ │ ├── wat-desugar.cc │ │ └── wat2wasm.cc │ ├── tracing.cc │ ├── type-checker.cc │ ├── utf8.cc │ ├── validator.cc │ ├── wabt.post.js │ ├── wast-lexer.cc │ ├── wast-parser.cc │ └── wat-writer.cc ├── test/ │ ├── README.md │ ├── binary/ │ │ ├── annotations-custom-sections.txt │ │ ├── bad-alignment.txt │ │ ├── bad-brtable-too-big.txt │ │ ├── bad-call-indirect-reserved.txt │ │ ├── bad-callindirect-invalid-sig.txt │ │ ├── bad-code-metadata-function-count.txt │ │ ├── bad-code-metadata-function-duplicate.txt │ │ ├── bad-code-metadata-function-index.txt │ │ ├── bad-code-metadata-function-out-of-order.txt │ │ ├── bad-code-metadata-instance-count.txt │ │ ├── bad-code-metadata-instance-duplicate.txt │ │ ├── bad-code-metadata-instance-out-of-order.txt │ │ ├── bad-data-count-mismatch.txt │ │ ├── bad-data-count-order-after-code.txt │ │ ├── bad-data-count-order-before-elem.txt │ │ ├── bad-data-drop-no-data-count.txt │ │ ├── bad-data-invalid-memidx.txt │ │ ├── bad-data-size.txt │ │ ├── bad-data-without-memory.txt │ │ ├── bad-duplicate-section-around-custom.txt │ │ ├── bad-duplicate-section.txt │ │ ├── bad-duplicate-subsection.txt │ │ ├── bad-elem-flags.txt │ │ ├── bad-export-func.txt │ │ ├── bad-export-out-of-range.txt │ │ ├── bad-extra-end.txt │ │ ├── bad-func-with-struct-type.txt │ │ ├── bad-function-body-count.txt │ │ ├── bad-function-body-size.txt │ │ ├── bad-function-count-missing-code-section.txt │ │ ├── bad-function-local-type.txt │ │ ├── bad-function-names-too-many.txt │ │ ├── bad-function-param-type.txt │ │ ├── bad-function-result-type.txt │ │ ├── bad-function-sig.txt │ │ ├── bad-import-kind.txt │ │ ├── bad-import-sig.txt │ │ ├── bad-init-expr-callindirect.txt │ │ ├── bad-interp-returncallindirect-invalid-sig.txt │ │ ├── bad-linking-data-segment-index.txt │ │ ├── bad-linking-function-index.txt │ │ ├── bad-linking-global-index.txt │ │ ├── bad-linking-metadata.txt │ │ ├── bad-linking-tag-index.txt │ │ ├── bad-logging-basic.txt │ │ ├── bad-magic.txt │ │ ├── bad-memory-grow-reserved.txt │ │ ├── bad-memory-init-max-size.txt │ │ ├── bad-memory-init-no-data-count.txt │ │ ├── bad-memory-init-size.txt │ │ ├── bad-memory-limits-flag-is64.txt │ │ ├── bad-memory-limits-flag-leb128.txt │ │ ├── bad-memory-limits-flag-shared.txt │ │ ├── bad-memory-limits-flag.txt │ │ ├── bad-memory-max-size.txt │ │ ├── bad-memory-size-reserved.txt │ │ ├── bad-multiple-catch-all.txt │ │ ├── bad-name-section-invalid-index.txt │ │ ├── bad-name-section-location.txt │ │ ├── bad-names-duplicate-locals.txt │ │ ├── bad-names-duplicates.txt │ │ ├── bad-names-function-locals-out-of-order.txt │ │ ├── bad-names-locals-out-of-order.txt │ │ ├── bad-names-out-of-order.txt │ │ ├── bad-op-after-end.txt │ │ ├── bad-opcode-prefix.txt │ │ ├── bad-opcode.txt │ │ ├── bad-reference-indicies.txt │ │ ├── bad-reloc-type.txt │ │ ├── bad-relocs.txt │ │ ├── bad-returncall-invalid-func.txt │ │ ├── bad-returncallindirect-invalid-sig.txt │ │ ├── bad-returncallindirect-reserved.txt │ │ ├── bad-section-code-leb128.txt │ │ ├── bad-section-ends-early.txt │ │ ├── bad-section-size-zero.txt │ │ ├── bad-segment-no-memory.txt │ │ ├── bad-start-func.txt │ │ ├── bad-subsection-out-of-order.txt │ │ ├── bad-subsection-size.txt │ │ ├── bad-subsection-unfinished.txt │ │ ├── bad-table-limits-flag-is64.txt │ │ ├── bad-table-limits-flag.txt │ │ ├── bad-tag-after-global.txt │ │ ├── bad-tag-before-memory.txt │ │ ├── bad-too-many-locals.txt │ │ ├── bad-type-form.txt │ │ ├── bad-typecheck-fail.txt │ │ ├── bad-typecheck-missing-drop.txt │ │ ├── bad-unfinished-section.txt │ │ ├── bad-version.txt │ │ ├── basic.txt │ │ ├── code-metadata-section.txt │ │ ├── compact-imports.txt │ │ ├── duplicate-func-names.txt │ │ ├── duplicate-local-names.txt │ │ ├── dylink-section.txt │ │ ├── dylink0-section.txt │ │ ├── function-local-count-zero.txt │ │ ├── gen-wasm-parse-error.txt │ │ ├── ignore-custom-section-error-objdump.txt │ │ ├── ignore-custom-section-error-wasm2wat.txt │ │ ├── invalid-name.txt │ │ ├── linking-section.txt │ │ ├── missing-code-section-empty-function-section.txt │ │ ├── missing-function-section-empty-code-section.txt │ │ ├── names.txt │ │ ├── no-global-names.txt │ │ ├── no-names.txt │ │ ├── relocs.txt │ │ ├── target-features-section.txt │ │ ├── unrecognized-layer.txt │ │ ├── unsupported-component.txt │ │ └── user-section.txt │ ├── decompile/ │ │ ├── basic.txt │ │ ├── code-metadata.txt │ │ ├── loadstore.txt │ │ ├── names.txt │ │ ├── passive-data.txt │ │ ├── precedence.txt │ │ └── stack-flush.txt │ ├── desugar/ │ │ ├── basic.txt │ │ ├── call_indirect.txt │ │ ├── implicit-func-type.txt │ │ ├── locals.txt │ │ └── try.txt │ ├── dump/ │ │ ├── array.txt │ │ ├── atomic.txt │ │ ├── bad-directory.txt │ │ ├── bad-version-logging.txt │ │ ├── bad-version.txt │ │ ├── basic.txt │ │ ├── basic_dump_only.txt │ │ ├── binary.txt │ │ ├── block-257-exprs-br.txt │ │ ├── block-257-exprs.txt │ │ ├── block-multi.txt │ │ ├── block.txt │ │ ├── br-block-named.txt │ │ ├── br-block.txt │ │ ├── br-loop-inner-expr.txt │ │ ├── br-loop-inner.txt │ │ ├── br-loop.txt │ │ ├── brif-loop.txt │ │ ├── brif.txt │ │ ├── brtable-empty.txt │ │ ├── brtable.txt │ │ ├── bulk-memory.txt │ │ ├── bulk-memory64.txt │ │ ├── call.txt │ │ ├── call_ref.txt │ │ ├── callimport.txt │ │ ├── callindirect.txt │ │ ├── cast.txt │ │ ├── code-metadata.txt │ │ ├── compact-imports.txt │ │ ├── compare.txt │ │ ├── const.txt │ │ ├── convert-sat.txt │ │ ├── convert.txt │ │ ├── data-count-section-removed.txt │ │ ├── data-count-section.txt │ │ ├── debug-import-names.txt │ │ ├── debug-names.txt │ │ ├── dedupe-sig.txt │ │ ├── drop.txt │ │ ├── elem-mvp-compat-named.txt │ │ ├── elem-mvp-compat.txt │ │ ├── export-multi.txt │ │ ├── expr-br.txt │ │ ├── expr-brif.txt │ │ ├── extended-const.txt │ │ ├── extended-names.txt │ │ ├── func-exported.txt │ │ ├── func-multi.txt │ │ ├── func-named.txt │ │ ├── func-result-multi.txt │ │ ├── global.txt │ │ ├── globalget.txt │ │ ├── globalset.txt │ │ ├── hexfloat_f32.txt │ │ ├── hexfloat_f64.txt │ │ ├── if-multi.txt │ │ ├── if-then-else-list.txt │ │ ├── if-then-list.txt │ │ ├── if.txt │ │ ├── import.txt │ │ ├── invalid-data-segment-no-memory.txt │ │ ├── invalid-data-segment-offset.txt │ │ ├── invalid-elem-segment-no-table.txt │ │ ├── invalid-elem-segment-offset.txt │ │ ├── invalid-init-exprs.txt │ │ ├── load-aligned.txt │ │ ├── load.txt │ │ ├── load64.txt │ │ ├── local-indices.txt │ │ ├── local-tee.txt │ │ ├── localget-param.txt │ │ ├── localget.txt │ │ ├── locals.txt │ │ ├── localset-param.txt │ │ ├── localset.txt │ │ ├── loop-257-exprs-br.txt │ │ ├── loop-257-exprs.txt │ │ ├── loop-multi.txt │ │ ├── loop.txt │ │ ├── memory-1-byte.txt │ │ ├── memory-data-size.txt │ │ ├── memory-grow.txt │ │ ├── memory-hex.txt │ │ ├── memory-size.txt │ │ ├── memory.txt │ │ ├── memory64.txt │ │ ├── module-name.txt │ │ ├── multi_file.txt │ │ ├── mutable-global.txt │ │ ├── no-canonicalize.txt │ │ ├── nocheck.txt │ │ ├── noncanon-leb128-opcode.txt │ │ ├── nop.txt │ │ ├── param-multi.txt │ │ ├── reference-types.txt │ │ ├── relocations-all-features.txt │ │ ├── relocations-block-types.txt │ │ ├── relocations-long-func-bodies.txt │ │ ├── relocations-long-func-section.txt │ │ ├── relocations-section-target.txt │ │ ├── relocations.txt │ │ ├── result.txt │ │ ├── rethrow.txt │ │ ├── return.txt │ │ ├── section-offsets.txt │ │ ├── select.txt │ │ ├── signatures.txt │ │ ├── simd-basic.txt │ │ ├── simd-binary.txt │ │ ├── simd-bitselect.txt │ │ ├── simd-compare.txt │ │ ├── simd-lane.txt │ │ ├── simd-load-lane.txt │ │ ├── simd-load-store.txt │ │ ├── simd-shift.txt │ │ ├── simd-splat.txt │ │ ├── simd-store-lane.txt │ │ ├── simd-unary.txt │ │ ├── start.txt │ │ ├── store-aligned.txt │ │ ├── store.txt │ │ ├── store64.txt │ │ ├── string-escape.txt │ │ ├── string-hex.txt │ │ ├── struct.txt │ │ ├── symbol-tables-all-features.txt │ │ ├── symbol-tables.txt │ │ ├── table-multi.txt │ │ ├── table.txt │ │ ├── tag.txt │ │ ├── tail-call.txt │ │ ├── throw.txt │ │ ├── try-catch-all.txt │ │ ├── try-delegate.txt │ │ ├── try-multi.txt │ │ ├── try.txt │ │ ├── typed-func-ref-signature.txt │ │ ├── typed-func-refs-locals.txt │ │ ├── typed_func_refs_params.txt │ │ ├── typed_func_refs_results.txt │ │ ├── unary-extend.txt │ │ ├── unary.txt │ │ └── unreachable.txt │ ├── find_exe.py │ ├── gen-spec-empty-prefix.js │ ├── gen-spec-js/ │ │ ├── action.txt │ │ ├── assert_exhaustion.txt │ │ ├── assert_malformed-quote.txt │ │ ├── assert_malformed.txt │ │ ├── assert_return.txt │ │ ├── assert_return_nan.txt │ │ ├── assert_trap.txt │ │ ├── assert_uninstantiable.txt │ │ ├── assert_unlinkable.txt │ │ ├── basic.txt │ │ ├── many-modules.txt │ │ └── register.txt │ ├── gen-spec-js.py │ ├── gen-spec-prefix.js │ ├── gen-spec-wast.py │ ├── gen-wasm.py │ ├── harness/ │ │ └── wasm2c/ │ │ ├── floating_point.txt │ │ ├── simd_formatting.txt │ │ ├── stdin_file.txt │ │ └── stdin_file.wast │ ├── help/ │ │ ├── spectest-interp.txt │ │ ├── wasm-interp.txt │ │ ├── wasm-objdump.txt │ │ ├── wasm-stats.txt │ │ ├── wasm-validate.txt │ │ ├── wasm2wat.txt │ │ ├── wast2json.txt │ │ ├── wat-desugar.txt │ │ └── wat2wasm.txt │ ├── interp/ │ │ ├── atomic-load.txt │ │ ├── atomic-rmw-add.txt │ │ ├── atomic-rmw-and.txt │ │ ├── atomic-rmw-cmpxchg.txt │ │ ├── atomic-rmw-or.txt │ │ ├── atomic-rmw-sub.txt │ │ ├── atomic-rmw-xchg.txt │ │ ├── atomic-rmw-xor.txt │ │ ├── atomic-store.txt │ │ ├── basic-logging.txt │ │ ├── basic-tracing.txt │ │ ├── basic.txt │ │ ├── binary.txt │ │ ├── block-multi.txt │ │ ├── br.txt │ │ ├── brif-loop.txt │ │ ├── brif.txt │ │ ├── brtable.txt │ │ ├── call-dummy-import.txt │ │ ├── call-multi-result.txt │ │ ├── call-zero-args.txt │ │ ├── call.txt │ │ ├── callimport-zero-args.txt │ │ ├── callindirect.txt │ │ ├── cast.txt │ │ ├── compare.txt │ │ ├── convert-sat.txt │ │ ├── convert.txt │ │ ├── custom-page-sizes.txt │ │ ├── empty.txt │ │ ├── expr-block.txt │ │ ├── expr-br.txt │ │ ├── expr-brif.txt │ │ ├── expr-if.txt │ │ ├── if-multi.txt │ │ ├── if.txt │ │ ├── import.txt │ │ ├── load.txt │ │ ├── load64.txt │ │ ├── loop-multi.txt │ │ ├── loop.txt │ │ ├── memory-empty-segment.txt │ │ ├── nested-if.txt │ │ ├── reference-types.txt │ │ ├── rethrow-and-br.txt │ │ ├── rethrow.txt │ │ ├── return-call-import.txt │ │ ├── return-call-indirect-import.txt │ │ ├── return-call-indirect.txt │ │ ├── return-call-local-set.txt │ │ ├── return-call.txt │ │ ├── return-void.txt │ │ ├── return.txt │ │ ├── run-export-as-global.txt │ │ ├── run-export-with-argument.txt │ │ ├── run-export-with-invalid-arguments-size.txt │ │ ├── run-non-func-export.txt │ │ ├── select-ref.txt │ │ ├── select.txt │ │ ├── simd-basic.txt │ │ ├── simd-binary.txt │ │ ├── simd-bitselect.txt │ │ ├── simd-compare.txt │ │ ├── simd-lane.txt │ │ ├── simd-load-store.txt │ │ ├── simd-shift.txt │ │ ├── simd-splat.txt │ │ ├── simd-unary.txt │ │ ├── start-failure.txt │ │ ├── start.txt │ │ ├── store.txt │ │ ├── store64.txt │ │ ├── throw-across-frame.txt │ │ ├── trap-with-callstack.txt │ │ ├── try-delegate.txt │ │ ├── try.txt │ │ ├── unary-extend.txt │ │ ├── unary.txt │ │ └── unreachable.txt │ ├── old-spec/ │ │ └── proposals/ │ │ └── memory64/ │ │ ├── address.wast │ │ ├── address64.wast │ │ ├── align64.wast │ │ ├── binary-leb128.wast │ │ ├── binary.wast │ │ ├── binary0.wast │ │ ├── call_indirect.wast │ │ ├── endianness64.wast │ │ ├── float_memory64.wast │ │ ├── imports.wast │ │ ├── load64.wast │ │ ├── memory.wast │ │ ├── memory64.wast │ │ ├── memory_copy.wast │ │ ├── memory_fill.wast │ │ ├── memory_grow64.wast │ │ ├── memory_init.wast │ │ ├── memory_redundancy64.wast │ │ ├── memory_trap64.wast │ │ ├── simd_address.wast │ │ ├── table.wast │ │ ├── table_copy.wast │ │ ├── table_copy_mixed.wast │ │ ├── table_fill.wast │ │ ├── table_get.wast │ │ ├── table_grow.wast │ │ ├── table_init.wast │ │ ├── table_set.wast │ │ └── table_size.wast │ ├── parse/ │ │ ├── all-features.txt │ │ ├── annotations.txt │ │ ├── assert/ │ │ │ ├── assert-after-module.txt │ │ │ ├── assert-return-arithmetic-nan.txt │ │ │ ├── assert-return-canonical-nan.txt │ │ │ ├── assertexception.txt │ │ │ ├── assertinvalid-binary-module.txt │ │ │ ├── assertinvalid.txt │ │ │ ├── assertmalformed.txt │ │ │ ├── assertreturn.txt │ │ │ ├── bad-assert-before-module.txt │ │ │ ├── bad-assertexception.txt │ │ │ ├── bad-assertreturn-non-const.txt │ │ │ ├── bad-assertreturn-too-few.txt │ │ │ ├── bad-assertreturn-too-many.txt │ │ │ ├── bad-assertreturn-unknown-function.txt │ │ │ ├── bad-invoke-no-module.txt │ │ │ ├── bad-invoke-too-few.txt │ │ │ ├── bad-invoke-too-many.txt │ │ │ ├── bad-invoke-unknown-function.txt │ │ │ └── invoke.txt │ │ ├── bad-annotations.txt │ │ ├── bad-call-ref.txt │ │ ├── bad-crlf.txt │ │ ├── bad-delegate-label.txt │ │ ├── bad-error-long-line.txt │ │ ├── bad-error-long-token.txt │ │ ├── bad-identifiers-with-annotations.txt │ │ ├── bad-identifiers.txt │ │ ├── bad-input-command.txt │ │ ├── bad-output-command.txt │ │ ├── bad-references.txt │ │ ├── bad-refs-in-trytable.txt │ │ ├── bad-single-semicolon.txt │ │ ├── bad-string-eof.txt │ │ ├── bad-string-escape.txt │ │ ├── bad-string-hex-escape.txt │ │ ├── bad-string-unicode-escape-large.txt │ │ ├── bad-string-unicode-escape-short.txt │ │ ├── bad-string-unicode-escape-unallowed.txt │ │ ├── bad-string-unicode-escape-unexpected.txt │ │ ├── bad-string-unicode-escape-unterminated.txt │ │ ├── bad-string-unicode-escape.txt │ │ ├── bad-toplevel.txt │ │ ├── basic.txt │ │ ├── branch-hints.txt │ │ ├── custom-sections.txt │ │ ├── empty-file.txt │ │ ├── export-mutable-global.txt │ │ ├── expr/ │ │ │ ├── atomic-align.txt │ │ │ ├── atomic-disabled.txt │ │ │ ├── atomic.txt │ │ │ ├── atomic64.txt │ │ │ ├── bad-atomic-unnatural-align.txt │ │ │ ├── bad-binary-one-expr.txt │ │ │ ├── bad-block-end-label.txt │ │ │ ├── bad-block-mismatch-label.txt │ │ │ ├── bad-br-bad-depth.txt │ │ │ ├── bad-br-defined-later.txt │ │ │ ├── bad-br-name-undefined.txt │ │ │ ├── bad-br-name.txt │ │ │ ├── bad-br-no-depth.txt │ │ │ ├── bad-br-undefined.txt │ │ │ ├── bad-brtable-bad-depth.txt │ │ │ ├── bad-brtable-no-vars.txt │ │ │ ├── bad-compare-one-expr.txt │ │ │ ├── bad-const-f32-nan-arith.txt │ │ │ ├── bad-const-f32-trailing.txt │ │ │ ├── bad-const-f64-nan-arith.txt │ │ │ ├── bad-const-i32-garbage.txt │ │ │ ├── bad-const-i32-just-negative-sign.txt │ │ │ ├── bad-const-i32-overflow.txt │ │ │ ├── bad-const-i32-trailing.txt │ │ │ ├── bad-const-i32-underflow.txt │ │ │ ├── bad-const-i64-overflow.txt │ │ │ ├── bad-const-type-i32-in-non-simd-const.txt │ │ │ ├── bad-const-v128-i16x8-overflow.txt │ │ │ ├── bad-const-v128-i32x4-overflow.txt │ │ │ ├── bad-const-v128-i8x16-overflow.txt │ │ │ ├── bad-const-v128-nat-overflow.txt │ │ │ ├── bad-const-v128-type-i32-expected.txt │ │ │ ├── bad-convert-float-sign.txt │ │ │ ├── bad-convert-int-no-sign.txt │ │ │ ├── bad-globalget-name-undefined.txt │ │ │ ├── bad-globalget-undefined.txt │ │ │ ├── bad-globalset-name-undefined.txt │ │ │ ├── bad-globalset-undefined.txt │ │ │ ├── bad-if-end-label.txt │ │ │ ├── bad-if-mismatch-label.txt │ │ │ ├── bad-if-no-then.txt │ │ │ ├── bad-load-align-misspelled.txt │ │ │ ├── bad-load-align-negative.txt │ │ │ ├── bad-load-align-not-pot.txt │ │ │ ├── bad-load-align.txt │ │ │ ├── bad-load-float-sign.txt │ │ │ ├── bad-load-offset-negative.txt │ │ │ ├── bad-load-type.txt │ │ │ ├── bad-localget-name-undefined.txt │ │ │ ├── bad-localget-name.txt │ │ │ ├── bad-localget-undefined.txt │ │ │ ├── bad-localset-name-undefined.txt │ │ │ ├── bad-localset-name.txt │ │ │ ├── bad-localset-no-value.txt │ │ │ ├── bad-localset-undefined.txt │ │ │ ├── bad-loop-end-label.txt │ │ │ ├── bad-loop-mismatch-label.txt │ │ │ ├── bad-memory-copy-differing-type.txt │ │ │ ├── bad-nop.txt │ │ │ ├── bad-select-multi.txt │ │ │ ├── bad-simd-shuffle-lane-index-overflow.txt │ │ │ ├── bad-simd-shuffle-lane-index-overflow2.txt │ │ │ ├── bad-simd-shuffle-nat-expected.txt │ │ │ ├── bad-simd-shuffle-not-enough-indices.txt │ │ │ ├── bad-store-align-not-pot.txt │ │ │ ├── bad-store-align.txt │ │ │ ├── bad-store-float.sign.txt │ │ │ ├── bad-store-offset-negative.txt │ │ │ ├── bad-store-type.txt │ │ │ ├── bad-try-clause.txt │ │ │ ├── bad-try-delegate.txt │ │ │ ├── bad-try-multiple-catch.txt │ │ │ ├── bad-unexpected.txt │ │ │ ├── binary.txt │ │ │ ├── block-multi-named.txt │ │ │ ├── block-multi.txt │ │ │ ├── block-named.txt │ │ │ ├── block-return.txt │ │ │ ├── block.txt │ │ │ ├── br-block.txt │ │ │ ├── br-loop.txt │ │ │ ├── br-named.txt │ │ │ ├── br.txt │ │ │ ├── brif-named.txt │ │ │ ├── brif.txt │ │ │ ├── brtable-multi.txt │ │ │ ├── brtable-named.txt │ │ │ ├── brtable.txt │ │ │ ├── bulk-memory-disabled.txt │ │ │ ├── bulk-memory-named.txt │ │ │ ├── bulk-memory-named64.txt │ │ │ ├── call-defined-later.txt │ │ │ ├── call-name-prefix.txt │ │ │ ├── call-named.txt │ │ │ ├── call.txt │ │ │ ├── callimport-defined-later.txt │ │ │ ├── callimport-named.txt │ │ │ ├── callimport-type.txt │ │ │ ├── callimport.txt │ │ │ ├── callindirect-named.txt │ │ │ ├── callindirect.txt │ │ │ ├── callref-imported-function.txt │ │ │ ├── callref-internal-function.txt │ │ │ ├── cast.txt │ │ │ ├── compare.txt │ │ │ ├── const.txt │ │ │ ├── convert-sat.txt │ │ │ ├── convert.txt │ │ │ ├── drop.txt │ │ │ ├── expr-br.txt │ │ │ ├── expr-brif.txt │ │ │ ├── globalget-named.txt │ │ │ ├── globalget.txt │ │ │ ├── globalset-named.txt │ │ │ ├── globalset.txt │ │ │ ├── if-multi-named.txt │ │ │ ├── if-multi.txt │ │ │ ├── if-return.txt │ │ │ ├── if-then-br-named.txt │ │ │ ├── if-then-br.txt │ │ │ ├── if-then-else-br-named.txt │ │ │ ├── if-then-else-br.txt │ │ │ ├── if-then-else-list.txt │ │ │ ├── if-then-else.txt │ │ │ ├── if.txt │ │ │ ├── load-aligned.txt │ │ │ ├── load-offset.txt │ │ │ ├── load.txt │ │ │ ├── load64.txt │ │ │ ├── local-tee.txt │ │ │ ├── localget-index-after-param.txt │ │ │ ├── localget-index-mixed-named-unnamed.txt │ │ │ ├── localget-named.txt │ │ │ ├── localget-param-named.txt │ │ │ ├── localget-param.txt │ │ │ ├── localget.txt │ │ │ ├── localset-index-after-param.txt │ │ │ ├── localset-index-mixed-named-unnamed.txt │ │ │ ├── localset-named.txt │ │ │ ├── localset-param-named.txt │ │ │ ├── localset-param.txt │ │ │ ├── localset.txt │ │ │ ├── loop-multi-named.txt │ │ │ ├── loop-multi.txt │ │ │ ├── loop-named.txt │ │ │ ├── loop.txt │ │ │ ├── memory-copy-differing-type.txt │ │ │ ├── memory-copy.txt │ │ │ ├── memory-copy64.txt │ │ │ ├── memory-drop.txt │ │ │ ├── memory-fill.txt │ │ │ ├── memory-fill64.txt │ │ │ ├── memory-grow.txt │ │ │ ├── memory-grow64.txt │ │ │ ├── memory-init.txt │ │ │ ├── memory-init64.txt │ │ │ ├── memory-size.txt │ │ │ ├── nop.txt │ │ │ ├── reference-types-call-indirect.txt │ │ │ ├── reference-types-named.txt │ │ │ ├── reference-types.txt │ │ │ ├── rethrow.txt │ │ │ ├── return-block.txt │ │ │ ├── return-if.txt │ │ │ ├── return-void.txt │ │ │ ├── return.txt │ │ │ ├── select.txt │ │ │ ├── simd.txt │ │ │ ├── store-aligned.txt │ │ │ ├── store-offset.txt │ │ │ ├── store.txt │ │ │ ├── store64.txt │ │ │ ├── table-copy.txt │ │ │ ├── table-drop.txt │ │ │ ├── table-get.txt │ │ │ ├── table-grow.txt │ │ │ ├── table-init.txt │ │ │ ├── table-set.txt │ │ │ ├── tail-call-disabled.txt │ │ │ ├── tail-call-named.txt │ │ │ ├── tail-call.txt │ │ │ ├── throw.txt │ │ │ ├── try-catch-all.txt │ │ │ ├── try-delegate.txt │ │ │ ├── try-multi.txt │ │ │ ├── try-table.txt │ │ │ ├── try.txt │ │ │ ├── unary-extend.txt │ │ │ ├── unary.txt │ │ │ └── unreachable.txt │ │ ├── force-color.txt │ │ ├── func/ │ │ │ ├── bad-func-name.txt │ │ │ ├── bad-local-binding-no-type.txt │ │ │ ├── bad-local-binding.txt │ │ │ ├── bad-local-name.txt │ │ │ ├── bad-local-redefinition.txt │ │ │ ├── bad-local-type-list.txt │ │ │ ├── bad-local-type.txt │ │ │ ├── bad-param-binding.txt │ │ │ ├── bad-param-name.txt │ │ │ ├── bad-param-redefinition.txt │ │ │ ├── bad-param-type-list.txt │ │ │ ├── bad-param.txt │ │ │ ├── bad-result-type.txt │ │ │ ├── bad-sig-param-type-mismatch.txt │ │ │ ├── bad-sig-params-empty.txt │ │ │ ├── bad-sig-result-type-mismatch.txt │ │ │ ├── bad-sig-result-type-not-void.txt │ │ │ ├── bad-sig-result-type-void.txt │ │ │ ├── bad-sig-too-few-params.txt │ │ │ ├── bad-sig-too-many-params.txt │ │ │ ├── func-named.txt │ │ │ ├── local-empty.txt │ │ │ ├── local-multi.txt │ │ │ ├── local.txt │ │ │ ├── no-space.txt │ │ │ ├── param-binding.txt │ │ │ ├── param-multi.txt │ │ │ ├── param-type-1.txt │ │ │ ├── param-type-2.txt │ │ │ ├── result-empty.txt │ │ │ ├── result-multi.txt │ │ │ ├── result.txt │ │ │ ├── sig-match.txt │ │ │ └── sig.txt │ │ ├── identifiers-with-annotations.txt │ │ ├── line-comment.txt │ │ ├── module/ │ │ │ ├── array-mut-field.txt │ │ │ ├── array.txt │ │ │ ├── bad-array-no-fields.txt │ │ │ ├── bad-array-too-many-fields.txt │ │ │ ├── bad-binary-module-magic.txt │ │ │ ├── bad-elem-redefinition.txt │ │ │ ├── bad-element-followed-by-illegal-expression.txt │ │ │ ├── bad-export-func-empty.txt │ │ │ ├── bad-export-func-name-undefined.txt │ │ │ ├── bad-export-func-name.txt │ │ │ ├── bad-export-func-no-string.txt │ │ │ ├── bad-export-func-too-many.txt │ │ │ ├── bad-export-func-undefined.txt │ │ │ ├── bad-export-global-name-undefined.txt │ │ │ ├── bad-export-global-undefined.txt │ │ │ ├── bad-export-memory-name-undefined.txt │ │ │ ├── bad-export-memory-undefined.txt │ │ │ ├── bad-export-table-name-undefined.txt │ │ │ ├── bad-export-table-undefined.txt │ │ │ ├── bad-func-redefinition.txt │ │ │ ├── bad-global-invalid-expr.txt │ │ │ ├── bad-global-invalid-globalget.txt │ │ │ ├── bad-import-func-not-param.txt │ │ │ ├── bad-import-func-not-result.txt │ │ │ ├── bad-import-func-one-string.txt │ │ │ ├── bad-import-func-redefinition.txt │ │ │ ├── bad-import-global-redefinition.txt │ │ │ ├── bad-import-memory-redefinition.txt │ │ │ ├── bad-import-table-redefinition.txt │ │ │ ├── bad-import-table-shared.txt │ │ │ ├── bad-memory-empty.txt │ │ │ ├── bad-memory-init-size-negative.txt │ │ │ ├── bad-memory-init-size-too-big.txt │ │ │ ├── bad-memory-init-size.txt │ │ │ ├── bad-memory-max-less-than-init.txt │ │ │ ├── bad-memory-max-size-negative.txt │ │ │ ├── bad-memory-max-size-too-big.txt │ │ │ ├── bad-memory-max-size.txt │ │ │ ├── bad-memory-segment-address.txt │ │ │ ├── bad-memory-shared-nomax.txt │ │ │ ├── bad-memory-too-many.txt │ │ │ ├── bad-module-multi.txt │ │ │ ├── bad-module-no-close.txt │ │ │ ├── bad-module-with-assert.txt │ │ │ ├── bad-start-not-nullary.txt │ │ │ ├── bad-start-not-void.txt │ │ │ ├── bad-start-too-many.txt │ │ │ ├── bad-table-elem.txt │ │ │ ├── bad-table-invalid-function.txt │ │ │ ├── bad-table-no-offset.txt │ │ │ ├── bad-table-too-many.txt │ │ │ ├── binary-module.txt │ │ │ ├── data-offset.txt │ │ │ ├── elem-offset.txt │ │ │ ├── export-func-multi.txt │ │ │ ├── export-func-named.txt │ │ │ ├── export-func.txt │ │ │ ├── export-global.txt │ │ │ ├── export-memory-multi.txt │ │ │ ├── export-memory.txt │ │ │ ├── export-table.txt │ │ │ ├── export-tag.txt │ │ │ ├── global.txt │ │ │ ├── import-func-no-param.txt │ │ │ ├── import-func-type.txt │ │ │ ├── import-func.txt │ │ │ ├── import-global-globalget.txt │ │ │ ├── import-global.txt │ │ │ ├── import-memory-shared.txt │ │ │ ├── import-memory.txt │ │ │ ├── import-mutable-global.txt │ │ │ ├── import-table.txt │ │ │ ├── import-tag.txt │ │ │ ├── memory-init-max-size.txt │ │ │ ├── memory-init-size.txt │ │ │ ├── memory-segment-1.txt │ │ │ ├── memory-segment-long.txt │ │ │ ├── memory-segment-many.txt │ │ │ ├── memory-segment-multi-string.txt │ │ │ ├── memory-segment-passive.txt │ │ │ ├── memory-shared.txt │ │ │ ├── module-empty.txt │ │ │ ├── reference-types-disabled.txt │ │ │ ├── start-named.txt │ │ │ ├── start.txt │ │ │ ├── struct-and-func.txt │ │ │ ├── struct-field-name.txt │ │ │ ├── struct-mut-field.txt │ │ │ ├── struct.txt │ │ │ ├── table-elem-expr.txt │ │ │ ├── table-elem-var.txt │ │ │ ├── table-named.txt │ │ │ ├── table.txt │ │ │ ├── tag.txt │ │ │ ├── type-empty-param.txt │ │ │ ├── type-empty.txt │ │ │ ├── type-multi-param.txt │ │ │ ├── type-no-param.txt │ │ │ └── type.txt │ │ ├── nested-comments.txt │ │ ├── stdin.txt │ │ ├── string-escape.txt │ │ └── string-hex.txt │ ├── pipes.txt │ ├── regress/ │ │ ├── bad-annotation.txt │ │ ├── bad-annotation2.txt │ │ ├── bad-missing-end.txt │ │ ├── bad-u64-leb128.txt │ │ ├── empty-quoted-module.txt │ │ ├── huge-offset.txt │ │ ├── interp-ehv3-locals.txt │ │ ├── interp-throw-before-try.txt │ │ ├── issue-2423-wasm2c-no-extension.txt │ │ ├── recursion-issue.txt │ │ ├── regress-1.txt │ │ ├── regress-10.txt │ │ ├── regress-11.txt │ │ ├── regress-12.txt │ │ ├── regress-13.txt │ │ ├── regress-14.txt │ │ ├── regress-15.txt │ │ ├── regress-16.txt │ │ ├── regress-1674.txt │ │ ├── regress-17.txt │ │ ├── regress-18.txt │ │ ├── regress-19.txt │ │ ├── regress-1922.txt │ │ ├── regress-1924.txt │ │ ├── regress-2.txt │ │ ├── regress-20.txt │ │ ├── regress-2034.txt │ │ ├── regress-2039.txt │ │ ├── regress-21.txt │ │ ├── regress-2110.txt │ │ ├── regress-22.txt │ │ ├── regress-23.txt │ │ ├── regress-24.txt │ │ ├── regress-25.txt │ │ ├── regress-26.txt │ │ ├── regress-2670.txt │ │ ├── regress-27.txt │ │ ├── regress-28.txt │ │ ├── regress-29.txt │ │ ├── regress-3.txt │ │ ├── regress-30.txt │ │ ├── regress-31.txt │ │ ├── regress-32.txt │ │ ├── regress-33.txt │ │ ├── regress-34.txt │ │ ├── regress-35.txt │ │ ├── regress-36.txt │ │ ├── regress-37.txt │ │ ├── regress-4.txt │ │ ├── regress-5.txt │ │ ├── regress-6.txt │ │ ├── regress-7.txt │ │ ├── regress-8.txt │ │ ├── regress-9.txt │ │ ├── undefined-shifts.txt │ │ ├── unterminated-annotation.txt │ │ ├── unterminated-annotation2.txt │ │ ├── wasm2c-ehv3-setjmp-volatile.txt │ │ ├── wasm2c-try-br.txt │ │ ├── wasm2c-try-reset.txt │ │ └── write-memuse.txt │ ├── roundtrip/ │ │ ├── apply-global-names.txt │ │ ├── apply-memory-names.txt │ │ ├── bulk-memory.txt │ │ ├── bulk-memory64.txt │ │ ├── code-metadata.txt │ │ ├── custom-page-sizes.txt │ │ ├── custom-sections.txt │ │ ├── debug-import-names.txt │ │ ├── debug-names-after-data.txt │ │ ├── debug-names.txt │ │ ├── elem-declare.txt │ │ ├── elem-nonzero-table.txt │ │ ├── fold-atomic-fence.txt │ │ ├── fold-atomic.txt │ │ ├── fold-basic.txt │ │ ├── fold-block-labels.txt │ │ ├── fold-block.txt │ │ ├── fold-bulk-memory.txt │ │ ├── fold-call-import-gen-names.txt │ │ ├── fold-call.txt │ │ ├── fold-callref.txt │ │ ├── fold-fac.txt │ │ ├── fold-function-references.txt │ │ ├── fold-global-getset.txt │ │ ├── fold-load-store.txt │ │ ├── fold-load-store64.txt │ │ ├── fold-local-getset.txt │ │ ├── fold-multi.txt │ │ ├── fold-nop.txt │ │ ├── fold-reference-types.txt │ │ ├── fold-rethrow.txt │ │ ├── fold-simd.txt │ │ ├── fold-tail-call.txt │ │ ├── fold-throw.txt │ │ ├── fold-try-delegate.txt │ │ ├── fold-try-table.txt │ │ ├── fold-try.txt │ │ ├── fold-unreachable.txt │ │ ├── func-index.txt │ │ ├── generate-bulk-memory-names.txt │ │ ├── generate-existing-name.txt │ │ ├── generate-from-export-name.txt │ │ ├── generate-from-import-name.txt │ │ ├── generate-func-names.txt │ │ ├── generate-func-type-names.txt │ │ ├── generate-global-names.txt │ │ ├── generate-if-label-names.txt │ │ ├── generate-import-names.txt │ │ ├── generate-label-names.txt │ │ ├── generate-local-names.txt │ │ ├── generate-some-names.txt │ │ ├── generate-start-name.txt │ │ ├── generate-tag-names.txt │ │ ├── generate-tail-call.txt │ │ ├── global-index.txt │ │ ├── inline-export-func-name.txt │ │ ├── inline-export-func.txt │ │ ├── inline-export-global.txt │ │ ├── inline-export-memory.txt │ │ ├── inline-export-multi.txt │ │ ├── inline-export-table.txt │ │ ├── inline-export-tag.txt │ │ ├── inline-import-export.txt │ │ ├── inline-import-func.txt │ │ ├── inline-import-global.txt │ │ ├── inline-import-memory.txt │ │ ├── inline-import-table.txt │ │ ├── inline-import-tag.txt │ │ ├── invalid-br-var.txt │ │ ├── invalid-local-index.txt │ │ ├── label.txt │ │ ├── memory-index.txt │ │ ├── memory-index64.txt │ │ ├── memory-max.txt │ │ ├── memory-max64.txt │ │ ├── multi-value-block-type.txt │ │ ├── named-locals.txt │ │ ├── named-params.txt │ │ ├── ref-types.txt │ │ ├── reference-types.txt │ │ ├── rethrow.txt │ │ ├── select-type.txt │ │ ├── simd.txt │ │ ├── string-unicode-escape.txt │ │ ├── table-copy-index.txt │ │ ├── table-import-externref.txt │ │ ├── table-index.txt │ │ ├── table-init-index.txt │ │ ├── try-delegate.txt │ │ ├── try-table.txt │ │ └── typed-func-refs.txt │ ├── run-c-api-examples.py │ ├── run-roundtrip.py │ ├── run-spec-wasm2c.py │ ├── run-tests.py │ ├── spec/ │ │ ├── address.txt │ │ ├── align.txt │ │ ├── binary-leb128.txt │ │ ├── binary.txt │ │ ├── block.txt │ │ ├── br.txt │ │ ├── br_if.txt │ │ ├── br_table.txt │ │ ├── bulk.txt │ │ ├── call.txt │ │ ├── call_indirect.txt │ │ ├── comments.txt │ │ ├── const.txt │ │ ├── conversions.txt │ │ ├── custom-page-sizes/ │ │ │ ├── custom-page-sizes-invalid.txt │ │ │ ├── custom-page-sizes.txt │ │ │ ├── memory_max.txt │ │ │ └── memory_max_i64.txt │ │ ├── custom.txt │ │ ├── data.txt │ │ ├── elem.txt │ │ ├── endianness.txt │ │ ├── exception-handling/ │ │ │ ├── binary.txt │ │ │ ├── exports.txt │ │ │ ├── imports.txt │ │ │ ├── legacy/ │ │ │ │ ├── rethrow.txt │ │ │ │ ├── throw.txt │ │ │ │ ├── try_catch.txt │ │ │ │ └── try_delegate.txt │ │ │ ├── ref_null.txt │ │ │ ├── tag.txt │ │ │ ├── throw.txt │ │ │ ├── throw_ref.txt │ │ │ └── try_table.txt │ │ ├── exports.txt │ │ ├── extended-const/ │ │ │ ├── data.txt │ │ │ ├── elem.txt │ │ │ └── global.txt │ │ ├── f32.txt │ │ ├── f32_bitwise.txt │ │ ├── f32_cmp.txt │ │ ├── f64.txt │ │ ├── f64_bitwise.txt │ │ ├── f64_cmp.txt │ │ ├── fac.txt │ │ ├── float_exprs.txt │ │ ├── float_literals.txt │ │ ├── float_memory.txt │ │ ├── float_misc.txt │ │ ├── forward.txt │ │ ├── func.txt │ │ ├── func_ptrs.txt │ │ ├── function-references/ │ │ │ ├── binary.txt │ │ │ ├── br_on_non_null.txt │ │ │ ├── br_on_null.txt │ │ │ ├── br_table.txt │ │ │ ├── call_ref.txt │ │ │ ├── data.txt │ │ │ ├── elem.txt │ │ │ ├── func.txt │ │ │ ├── global.txt │ │ │ ├── if.txt │ │ │ ├── linking.txt │ │ │ ├── local_get.txt │ │ │ ├── local_init.txt │ │ │ ├── ref.txt │ │ │ ├── ref_as_non_null.txt │ │ │ ├── ref_is_null.txt │ │ │ ├── ref_null.txt │ │ │ ├── return_call.txt │ │ │ ├── return_call_indirect.txt │ │ │ ├── return_call_ref.txt │ │ │ ├── select.txt │ │ │ ├── table-sub.txt │ │ │ ├── table.txt │ │ │ ├── type-equivalence.txt │ │ │ ├── unreached-invalid.txt │ │ │ └── unreached-valid.txt │ │ ├── global.txt │ │ ├── i32.txt │ │ ├── i64.txt │ │ ├── if.txt │ │ ├── imports.txt │ │ ├── inline-module.txt │ │ ├── int_exprs.txt │ │ ├── int_literals.txt │ │ ├── labels.txt │ │ ├── left-to-right.txt │ │ ├── linking.txt │ │ ├── load.txt │ │ ├── local_get.txt │ │ ├── local_set.txt │ │ ├── local_tee.txt │ │ ├── loop.txt │ │ ├── memory.txt │ │ ├── memory64/ │ │ │ ├── address.txt │ │ │ ├── address64.txt │ │ │ ├── align64.txt │ │ │ ├── binary-leb128.txt │ │ │ ├── binary.txt │ │ │ ├── binary0.txt │ │ │ ├── call_indirect.txt │ │ │ ├── endianness64.txt │ │ │ ├── float_memory64.txt │ │ │ ├── imports.txt │ │ │ ├── load64.txt │ │ │ ├── memory.txt │ │ │ ├── memory64.txt │ │ │ ├── memory_copy.txt │ │ │ ├── memory_fill.txt │ │ │ ├── memory_grow64.txt │ │ │ ├── memory_init.txt │ │ │ ├── memory_redundancy64.txt │ │ │ ├── memory_trap64.txt │ │ │ ├── simd_address.txt │ │ │ ├── table.txt │ │ │ ├── table_copy.txt │ │ │ ├── table_copy_mixed.txt │ │ │ ├── table_fill.txt │ │ │ ├── table_get.txt │ │ │ ├── table_grow.txt │ │ │ ├── table_init.txt │ │ │ ├── table_set.txt │ │ │ └── table_size.txt │ │ ├── memory_copy.txt │ │ ├── memory_fill.txt │ │ ├── memory_grow.txt │ │ ├── memory_init.txt │ │ ├── memory_redundancy.txt │ │ ├── memory_size.txt │ │ ├── memory_trap.txt │ │ ├── multi-memory/ │ │ │ ├── address0.txt │ │ │ ├── address1.txt │ │ │ ├── align.txt │ │ │ ├── align0.txt │ │ │ ├── binary.txt │ │ │ ├── binary0.txt │ │ │ ├── data.txt │ │ │ ├── data0.txt │ │ │ ├── data1.txt │ │ │ ├── data_drop0.txt │ │ │ ├── exports0.txt │ │ │ ├── float_exprs0.txt │ │ │ ├── float_exprs1.txt │ │ │ ├── float_memory0.txt │ │ │ ├── imports.txt │ │ │ ├── imports0.txt │ │ │ ├── imports1.txt │ │ │ ├── imports2.txt │ │ │ ├── imports3.txt │ │ │ ├── imports4.txt │ │ │ ├── linking0.txt │ │ │ ├── linking1.txt │ │ │ ├── linking2.txt │ │ │ ├── linking3.txt │ │ │ ├── load.txt │ │ │ ├── load0.txt │ │ │ ├── load1.txt │ │ │ ├── load2.txt │ │ │ ├── memory-multi.txt │ │ │ ├── memory.txt │ │ │ ├── memory_copy0.txt │ │ │ ├── memory_copy1.txt │ │ │ ├── memory_fill0.txt │ │ │ ├── memory_grow.txt │ │ │ ├── memory_init0.txt │ │ │ ├── memory_size.txt │ │ │ ├── memory_size0.txt │ │ │ ├── memory_size1.txt │ │ │ ├── memory_size2.txt │ │ │ ├── memory_size3.txt │ │ │ ├── memory_trap0.txt │ │ │ ├── memory_trap1.txt │ │ │ ├── simd_memory-multi.txt │ │ │ ├── start0.txt │ │ │ ├── store.txt │ │ │ ├── store0.txt │ │ │ ├── store1.txt │ │ │ └── traps0.txt │ │ ├── names.txt │ │ ├── nop.txt │ │ ├── obsolete-keywords.txt │ │ ├── ref_func.txt │ │ ├── ref_is_null.txt │ │ ├── ref_null.txt │ │ ├── relaxed-simd/ │ │ │ ├── i16x8_relaxed_q15mulr_s.txt │ │ │ ├── i32x4_relaxed_trunc.txt │ │ │ ├── i8x16_relaxed_swizzle.txt │ │ │ ├── relaxed_dot_product.txt │ │ │ ├── relaxed_laneselect.txt │ │ │ ├── relaxed_madd_nmadd.txt │ │ │ └── relaxed_min_max.txt │ │ ├── return.txt │ │ ├── select.txt │ │ ├── simd_address.txt │ │ ├── simd_align.txt │ │ ├── simd_bit_shift.txt │ │ ├── simd_bitwise.txt │ │ ├── simd_boolean.txt │ │ ├── simd_const.txt │ │ ├── simd_conversions.txt │ │ ├── simd_f32x4.txt │ │ ├── simd_f32x4_arith.txt │ │ ├── simd_f32x4_cmp.txt │ │ ├── simd_f32x4_pmin_pmax.txt │ │ ├── simd_f32x4_rounding.txt │ │ ├── simd_f64x2.txt │ │ ├── simd_f64x2_arith.txt │ │ ├── simd_f64x2_cmp.txt │ │ ├── simd_f64x2_pmin_pmax.txt │ │ ├── simd_f64x2_rounding.txt │ │ ├── simd_i16x8_arith.txt │ │ ├── simd_i16x8_arith2.txt │ │ ├── simd_i16x8_cmp.txt │ │ ├── simd_i16x8_extadd_pairwise_i8x16.txt │ │ ├── simd_i16x8_extmul_i8x16.txt │ │ ├── simd_i16x8_q15mulr_sat_s.txt │ │ ├── simd_i16x8_sat_arith.txt │ │ ├── simd_i32x4_arith.txt │ │ ├── simd_i32x4_arith2.txt │ │ ├── simd_i32x4_cmp.txt │ │ ├── simd_i32x4_dot_i16x8.txt │ │ ├── simd_i32x4_extadd_pairwise_i16x8.txt │ │ ├── simd_i32x4_extmul_i16x8.txt │ │ ├── simd_i32x4_trunc_sat_f32x4.txt │ │ ├── simd_i32x4_trunc_sat_f64x2.txt │ │ ├── simd_i64x2_arith.txt │ │ ├── simd_i64x2_arith2.txt │ │ ├── simd_i64x2_cmp.txt │ │ ├── simd_i64x2_extmul_i32x4.txt │ │ ├── simd_i8x16_arith.txt │ │ ├── simd_i8x16_arith2.txt │ │ ├── simd_i8x16_cmp.txt │ │ ├── simd_i8x16_sat_arith.txt │ │ ├── simd_int_to_int_extend.txt │ │ ├── simd_lane.txt │ │ ├── simd_linking.txt │ │ ├── simd_load.txt │ │ ├── simd_load16_lane.txt │ │ ├── simd_load32_lane.txt │ │ ├── simd_load64_lane.txt │ │ ├── simd_load8_lane.txt │ │ ├── simd_load_extend.txt │ │ ├── simd_load_splat.txt │ │ ├── simd_load_zero.txt │ │ ├── simd_splat.txt │ │ ├── simd_store.txt │ │ ├── simd_store16_lane.txt │ │ ├── simd_store32_lane.txt │ │ ├── simd_store64_lane.txt │ │ ├── simd_store8_lane.txt │ │ ├── skip-stack-guard-page.txt │ │ ├── stack.txt │ │ ├── start.txt │ │ ├── store.txt │ │ ├── switch.txt │ │ ├── table-sub.txt │ │ ├── table.txt │ │ ├── table_copy.txt │ │ ├── table_fill.txt │ │ ├── table_get.txt │ │ ├── table_grow.txt │ │ ├── table_init.txt │ │ ├── table_set.txt │ │ ├── table_size.txt │ │ ├── tail-call/ │ │ │ ├── return_call.txt │ │ │ └── return_call_indirect.txt │ │ ├── token.txt │ │ ├── traps.txt │ │ ├── type.txt │ │ ├── unreachable.txt │ │ ├── unreached-invalid.txt │ │ ├── unreached-valid.txt │ │ ├── unwind.txt │ │ ├── utf8-custom-section-id.txt │ │ ├── utf8-import-field.txt │ │ ├── utf8-import-module.txt │ │ └── utf8-invalid-encoding.txt │ ├── spec-new/ │ │ ├── README.md │ │ ├── wide-arithmetic.txt │ │ └── wide-arithmetic.wast │ ├── spec-wasm2c-prefix.c │ ├── spectest-interp-assert-failure.txt │ ├── spectest-interp-error-count.txt │ ├── spectest-interp-invalid-literal.txt │ ├── stats/ │ │ ├── basic.txt │ │ ├── cutoff.txt │ │ └── immediates.txt │ ├── strip/ │ │ ├── basic.txt │ │ ├── keep_section.txt │ │ ├── names.txt │ │ ├── no-custom-sections.txt │ │ ├── out_file.txt │ │ └── remove_section.txt │ ├── too-many-arguments.txt │ ├── two-commands.txt │ ├── typecheck/ │ │ ├── atomic-no-shared-memory.txt │ │ ├── bad-assertexception-type-mismatch.txt │ │ ├── bad-assertreturn-invoke-type-mismatch.txt │ │ ├── bad-assertreturn-type-mismatch.txt │ │ ├── bad-atomic-type-mismatch.txt │ │ ├── bad-binary-type-mismatch-1.txt │ │ ├── bad-binary-type-mismatch-2.txt │ │ ├── bad-block-multi-mismatch.txt │ │ ├── bad-brtable-type-mismatch.txt │ │ ├── bad-bulk-memory-invalid-segment.txt │ │ ├── bad-bulk-memory-no-memory.txt │ │ ├── bad-bulk-memory-no-table.txt │ │ ├── bad-bulk-memory-type-mismatch.txt │ │ ├── bad-call-result-mismatch.txt │ │ ├── bad-call-type-mismatch.txt │ │ ├── bad-callimport-type-mismatch.txt │ │ ├── bad-callindirect-func-type-mismatch.txt │ │ ├── bad-callindirect-type-mismatch.txt │ │ ├── bad-callref-empty.txt │ │ ├── bad-callref-int32.txt │ │ ├── bad-callref-nosubtype.txt │ │ ├── bad-callref-null.txt │ │ ├── bad-callref-wrong-signature.txt │ │ ├── bad-cast-type-mismatch.txt │ │ ├── bad-compare-type-mismatch-1.txt │ │ ├── bad-compare-type-mismatch-2.txt │ │ ├── bad-convert-type-mismatch.txt │ │ ├── bad-delegate-depth.txt │ │ ├── bad-empty-catch-all.txt │ │ ├── bad-empty-catch.txt │ │ ├── bad-expr-if.txt │ │ ├── bad-function-result-type-mismatch.txt │ │ ├── bad-global-globalget-type-mismatch.txt │ │ ├── bad-global-no-init-expr.txt │ │ ├── bad-global-type-mismatch.txt │ │ ├── bad-if-condition-type-mismatch.txt │ │ ├── bad-if-multi-mismatch.txt │ │ ├── bad-if-type-mismatch.txt │ │ ├── bad-if-value-void.txt │ │ ├── bad-invoke-type-mismatch.txt │ │ ├── bad-load-type-mismatch.txt │ │ ├── bad-localset-type-mismatch.txt │ │ ├── bad-loop-multi-mismatch.txt │ │ ├── bad-memory-grow-type-mismatch.txt │ │ ├── bad-nested-br.txt │ │ ├── bad-no-shared-memory.txt │ │ ├── bad-reference-types-no-table.txt │ │ ├── bad-rethrow-depth.txt │ │ ├── bad-rethrow-not-in-catch.txt │ │ ├── bad-return-type-mismatch.txt │ │ ├── bad-returncall-type-mismatch.txt │ │ ├── bad-returncallindirect-no-table.txt │ │ ├── bad-returncallindirect-type-mismatch.txt │ │ ├── bad-select-cond.txt │ │ ├── bad-select-value0.txt │ │ ├── bad-select-value1.txt │ │ ├── bad-simd-lane.txt │ │ ├── bad-store-index-type-mismatch.txt │ │ ├── bad-tag-results.txt │ │ ├── bad-typed-select-type-mismatch.txt │ │ ├── bad-unary-type-mismatch.txt │ │ ├── br-multi.txt │ │ ├── br-table-loop.txt │ │ ├── brif-multi.txt │ │ ├── brtable-multi.txt │ │ ├── delegate.txt │ │ ├── if-anyref.txt │ │ ├── if-then-br.txt │ │ ├── if-value.txt │ │ ├── label-redefinition.txt │ │ ├── missing-ref.txt │ │ ├── nested-br.txt │ │ ├── nocheck.txt │ │ ├── rethrow.txt │ │ ├── return-drop-value-2.txt │ │ ├── return-drop-value.txt │ │ ├── return-value.txt │ │ ├── try-delegate.txt │ │ └── typed-select-result-type.txt │ ├── update-spec-tests.py │ ├── utils.py │ ├── wasi/ │ │ ├── clock.txt │ │ ├── empty.txt │ │ ├── exit.txt │ │ ├── oob_trap.txt │ │ └── write_stdout.txt │ ├── wasm2c/ │ │ ├── add.txt │ │ ├── address-overflow.txt │ │ ├── bad-enable-feature.txt │ │ ├── check-imports.txt │ │ ├── duplicate-names.txt │ │ ├── export-names.txt │ │ ├── hello.txt │ │ ├── minimal.txt │ │ ├── spec/ │ │ │ ├── address.txt │ │ │ ├── align.txt │ │ │ ├── binary-leb128.txt │ │ │ ├── binary.txt │ │ │ ├── block.txt │ │ │ ├── br.txt │ │ │ ├── br_if.txt │ │ │ ├── br_table.txt │ │ │ ├── bulk.txt │ │ │ ├── call.txt │ │ │ ├── call_indirect.txt │ │ │ ├── comments.txt │ │ │ ├── const.txt │ │ │ ├── conversions.txt │ │ │ ├── custom-page-sizes/ │ │ │ │ ├── custom-page-sizes-invalid.txt │ │ │ │ ├── custom-page-sizes.txt │ │ │ │ ├── memory_max.txt │ │ │ │ └── memory_max_i64.txt │ │ │ ├── custom.txt │ │ │ ├── data.txt │ │ │ ├── elem.txt │ │ │ ├── endianness.txt │ │ │ ├── exception-handling/ │ │ │ │ ├── binary.txt │ │ │ │ ├── exports.txt │ │ │ │ ├── imports.txt │ │ │ │ ├── legacy/ │ │ │ │ │ ├── rethrow.txt │ │ │ │ │ ├── throw.txt │ │ │ │ │ ├── try_catch.txt │ │ │ │ │ └── try_delegate.txt │ │ │ │ ├── ref_null.txt │ │ │ │ ├── tag.txt │ │ │ │ ├── throw.txt │ │ │ │ ├── throw_ref.txt │ │ │ │ └── try_table.txt │ │ │ ├── exports.txt │ │ │ ├── extended-const/ │ │ │ │ ├── data.txt │ │ │ │ ├── elem.txt │ │ │ │ └── global.txt │ │ │ ├── f32.txt │ │ │ ├── f32_bitwise.txt │ │ │ ├── f32_cmp.txt │ │ │ ├── f64.txt │ │ │ ├── f64_bitwise.txt │ │ │ ├── f64_cmp.txt │ │ │ ├── fac.txt │ │ │ ├── float_exprs.txt │ │ │ ├── float_literals.txt │ │ │ ├── float_memory.txt │ │ │ ├── float_misc.txt │ │ │ ├── forward.txt │ │ │ ├── func.txt │ │ │ ├── func_ptrs.txt │ │ │ ├── global.txt │ │ │ ├── i32.txt │ │ │ ├── i64.txt │ │ │ ├── if.txt │ │ │ ├── imports.txt │ │ │ ├── inline-module.txt │ │ │ ├── int_exprs.txt │ │ │ ├── int_literals.txt │ │ │ ├── labels.txt │ │ │ ├── left-to-right.txt │ │ │ ├── linking.txt │ │ │ ├── load.txt │ │ │ ├── local_get.txt │ │ │ ├── local_set.txt │ │ │ ├── local_tee.txt │ │ │ ├── loop.txt │ │ │ ├── memory.txt │ │ │ ├── memory64/ │ │ │ │ ├── address.txt │ │ │ │ ├── address64.txt │ │ │ │ ├── align64.txt │ │ │ │ ├── binary-leb128.txt │ │ │ │ ├── binary.txt │ │ │ │ ├── binary0.txt │ │ │ │ ├── call_indirect.txt │ │ │ │ ├── endianness64.txt │ │ │ │ ├── float_memory64.txt │ │ │ │ ├── imports.txt │ │ │ │ ├── load64.txt │ │ │ │ ├── memory.txt │ │ │ │ ├── memory64.txt │ │ │ │ ├── memory_copy.txt │ │ │ │ ├── memory_fill.txt │ │ │ │ ├── memory_grow64.txt │ │ │ │ ├── memory_init.txt │ │ │ │ ├── memory_redundancy64.txt │ │ │ │ ├── memory_trap64.txt │ │ │ │ ├── simd_address.txt │ │ │ │ ├── table.txt │ │ │ │ ├── table_copy.txt │ │ │ │ ├── table_copy_mixed.txt │ │ │ │ ├── table_fill.txt │ │ │ │ ├── table_get.txt │ │ │ │ ├── table_grow.txt │ │ │ │ ├── table_init.txt │ │ │ │ ├── table_set.txt │ │ │ │ └── table_size.txt │ │ │ ├── memory_copy.txt │ │ │ ├── memory_fill.txt │ │ │ ├── memory_grow.txt │ │ │ ├── memory_init.txt │ │ │ ├── memory_redundancy.txt │ │ │ ├── memory_size.txt │ │ │ ├── memory_trap.txt │ │ │ ├── multi-memory/ │ │ │ │ ├── address0.txt │ │ │ │ ├── address1.txt │ │ │ │ ├── align.txt │ │ │ │ ├── align0.txt │ │ │ │ ├── binary.txt │ │ │ │ ├── binary0.txt │ │ │ │ ├── data.txt │ │ │ │ ├── data0.txt │ │ │ │ ├── data1.txt │ │ │ │ ├── data_drop0.txt │ │ │ │ ├── exports0.txt │ │ │ │ ├── float_exprs0.txt │ │ │ │ ├── float_exprs1.txt │ │ │ │ ├── float_memory0.txt │ │ │ │ ├── imports.txt │ │ │ │ ├── imports0.txt │ │ │ │ ├── imports1.txt │ │ │ │ ├── imports2.txt │ │ │ │ ├── imports3.txt │ │ │ │ ├── imports4.txt │ │ │ │ ├── linking0.txt │ │ │ │ ├── linking1.txt │ │ │ │ ├── linking2.txt │ │ │ │ ├── linking3.txt │ │ │ │ ├── load.txt │ │ │ │ ├── load0.txt │ │ │ │ ├── load1.txt │ │ │ │ ├── load2.txt │ │ │ │ ├── memory-multi.txt │ │ │ │ ├── memory.txt │ │ │ │ ├── memory_copy0.txt │ │ │ │ ├── memory_copy1.txt │ │ │ │ ├── memory_fill0.txt │ │ │ │ ├── memory_grow.txt │ │ │ │ ├── memory_init0.txt │ │ │ │ ├── memory_size.txt │ │ │ │ ├── memory_size0.txt │ │ │ │ ├── memory_size1.txt │ │ │ │ ├── memory_size2.txt │ │ │ │ ├── memory_size3.txt │ │ │ │ ├── memory_trap0.txt │ │ │ │ ├── memory_trap1.txt │ │ │ │ ├── simd_memory-multi.txt │ │ │ │ ├── start0.txt │ │ │ │ ├── store.txt │ │ │ │ ├── store0.txt │ │ │ │ ├── store1.txt │ │ │ │ └── traps0.txt │ │ │ ├── names.txt │ │ │ ├── nop.txt │ │ │ ├── obsolete-keywords.txt │ │ │ ├── ref_func.txt │ │ │ ├── ref_is_null.txt │ │ │ ├── ref_null.txt │ │ │ ├── return.txt │ │ │ ├── select.txt │ │ │ ├── simd_address.txt │ │ │ ├── simd_align.txt │ │ │ ├── simd_bit_shift.txt │ │ │ ├── simd_bitwise.txt │ │ │ ├── simd_boolean.txt │ │ │ ├── simd_const.txt │ │ │ ├── simd_conversions.txt │ │ │ ├── simd_f32x4.txt │ │ │ ├── simd_f32x4_arith.txt │ │ │ ├── simd_f32x4_cmp.txt │ │ │ ├── simd_f32x4_pmin_pmax.txt │ │ │ ├── simd_f32x4_rounding.txt │ │ │ ├── simd_f64x2.txt │ │ │ ├── simd_f64x2_arith.txt │ │ │ ├── simd_f64x2_cmp.txt │ │ │ ├── simd_f64x2_pmin_pmax.txt │ │ │ ├── simd_f64x2_rounding.txt │ │ │ ├── simd_i16x8_arith.txt │ │ │ ├── simd_i16x8_arith2.txt │ │ │ ├── simd_i16x8_cmp.txt │ │ │ ├── simd_i16x8_extadd_pairwise_i8x16.txt │ │ │ ├── simd_i16x8_extmul_i8x16.txt │ │ │ ├── simd_i16x8_q15mulr_sat_s.txt │ │ │ ├── simd_i16x8_sat_arith.txt │ │ │ ├── simd_i32x4_arith.txt │ │ │ ├── simd_i32x4_arith2.txt │ │ │ ├── simd_i32x4_cmp.txt │ │ │ ├── simd_i32x4_dot_i16x8.txt │ │ │ ├── simd_i32x4_extadd_pairwise_i16x8.txt │ │ │ ├── simd_i32x4_extmul_i16x8.txt │ │ │ ├── simd_i32x4_trunc_sat_f32x4.txt │ │ │ ├── simd_i32x4_trunc_sat_f64x2.txt │ │ │ ├── simd_i64x2_arith.txt │ │ │ ├── simd_i64x2_arith2.txt │ │ │ ├── simd_i64x2_cmp.txt │ │ │ ├── simd_i64x2_extmul_i32x4.txt │ │ │ ├── simd_i8x16_arith.txt │ │ │ ├── simd_i8x16_arith2.txt │ │ │ ├── simd_i8x16_cmp.txt │ │ │ ├── simd_i8x16_sat_arith.txt │ │ │ ├── simd_int_to_int_extend.txt │ │ │ ├── simd_lane.txt │ │ │ ├── simd_linking.txt │ │ │ ├── simd_load.txt │ │ │ ├── simd_load16_lane.txt │ │ │ ├── simd_load32_lane.txt │ │ │ ├── simd_load64_lane.txt │ │ │ ├── simd_load8_lane.txt │ │ │ ├── simd_load_extend.txt │ │ │ ├── simd_load_splat.txt │ │ │ ├── simd_load_zero.txt │ │ │ ├── simd_splat.txt │ │ │ ├── simd_store.txt │ │ │ ├── simd_store16_lane.txt │ │ │ ├── simd_store32_lane.txt │ │ │ ├── simd_store64_lane.txt │ │ │ ├── simd_store8_lane.txt │ │ │ ├── skip-stack-guard-page.txt │ │ │ ├── stack.txt │ │ │ ├── start.txt │ │ │ ├── store.txt │ │ │ ├── switch.txt │ │ │ ├── table-sub.txt │ │ │ ├── table.txt │ │ │ ├── table_copy.txt │ │ │ ├── table_fill.txt │ │ │ ├── table_get.txt │ │ │ ├── table_grow.txt │ │ │ ├── table_init.txt │ │ │ ├── table_set.txt │ │ │ ├── table_size.txt │ │ │ ├── tail-call/ │ │ │ │ ├── return_call.txt │ │ │ │ └── return_call_indirect.txt │ │ │ ├── threads/ │ │ │ │ └── atomic.txt │ │ │ ├── token.txt │ │ │ ├── traps.txt │ │ │ ├── type.txt │ │ │ ├── unreachable.txt │ │ │ ├── unreached-invalid.txt │ │ │ ├── unreached-valid.txt │ │ │ ├── unwind.txt │ │ │ ├── utf8-custom-section-id.txt │ │ │ ├── utf8-import-field.txt │ │ │ ├── utf8-import-module.txt │ │ │ └── utf8-invalid-encoding.txt │ │ ├── spec-multi-output/ │ │ │ ├── call.txt │ │ │ ├── linking.txt │ │ │ └── memory_init.txt │ │ └── tail-calls.txt │ ├── wast2json/ │ │ ├── module-binary.txt │ │ └── test-invalid-quoted-modules.txt │ └── wat2wasm_stdout.txt ├── ubsan.blacklist └── wasm2c/ ├── .gitignore ├── README.md ├── examples/ │ ├── callback/ │ │ ├── Makefile │ │ ├── callback.wat │ │ └── main.c │ ├── fac/ │ │ ├── Makefile │ │ ├── fac.c │ │ ├── fac.h │ │ ├── fac.wat │ │ └── main.c │ ├── rot13/ │ │ ├── Makefile │ │ ├── main.c │ │ └── rot13.wat │ └── threads/ │ ├── Makefile │ ├── sample.wat │ └── threads.c ├── wasm-rt-exceptions-impl.c ├── wasm-rt-exceptions.h ├── wasm-rt-impl-tableops.inc ├── wasm-rt-impl.c ├── wasm-rt-impl.h ├── wasm-rt-mem-impl-helper.inc ├── wasm-rt-mem-impl.c └── wasm-rt.h ================================================ FILE CONTENTS ================================================ ================================================ FILE: .clang-format ================================================ BasedOnStyle: Chromium ================================================ FILE: .flake8 ================================================ [flake8] # E501: line too long # W504: line break after binary operator ignore = E501,W504 exclude = ./third_party ./out ================================================ FILE: .git-blame-ignore-revs ================================================ # This file contains a list of commits that are not likely what you # are looking for in a blame, such as mass reformatting or renaming. # You can set this file as a default ignore file for blame by running # the following command. # # $ git config blame.ignoreRevsFile .git-blame-ignore-revs # Clang-format codebase e59cf9369004a521814222afbc05ae6b59446cd5 ================================================ FILE: .gitattributes ================================================ * text=auto *.c text *.h text *.js text *.l text *.md text *.py text *.rst text *.sh text *.txt text *.y text docs/demo/primer.css binary docs/demo/libwabt.js binary docs/demo/third_party/codemirror/codemirror.css binary docs/demo/third_party/codemirror/codemirror.js binary # Mark these tests as binary so git doesn't change the line endings: test/parse/bad-crlf.txt binary test/parse/bad-string-eof.txt binary test/regress/regress-31.txt binary test/regress/bad-annotation* binary test/regress/unterminated-annotation* binary # Highlight tests like .wast files when displayed on GitHub. test/**/*.txt linguist-language=WebAssembly # Mark test-files as "vendored". This tells GitHub to exclude them when it # calculates the repository's languages summary, and preserves the current # classification as a C++ project. See https://git.io/vr2pO test/**/*.txt linguist-vendored ================================================ FILE: .github/actions/release-archive/action.yml ================================================ name: Upload release archive description: Bundles an archive of artifacts and uploads to a GitHub release. The artifacts must already have been built into the folder "install". inputs: os: description: The OS runner name being built, used in the archive name required: true upload_to_release: description: Whether to upload the archives to the release runs: using: composite steps: - name: archive id: archive shell: bash run: | OSNAME=$(echo ${{ inputs.os }} | sed 's/-latest//') VERSION=${{ github.event.release.tag_name || github.sha }} PKGNAME="wabt-$VERSION-$OSNAME" TARBALL=$PKGNAME.tar.gz SHASUM=$PKGNAME.tar.gz.sha256 mv install wabt-$VERSION tar -czf $TARBALL wabt-$VERSION scripts/sha256sum.py $TARBALL > $SHASUM echo "tarball=$TARBALL" >> $GITHUB_OUTPUT echo "shasum=$SHASUM" >> $GITHUB_OUTPUT - name: upload tarball to CI uses: actions/upload-artifact@v4 with: name: ${{ steps.archive.outputs.tarball }} path: ./${{ steps.archive.outputs.tarball }} - name: upload tarball to release uses: svenstaro/upload-release-action@v2 if: ${{ inputs.upload_to_release }} with: file: ./${{ steps.archive.outputs.tarball }} asset_name: ${{ steps.archive.outputs.tarball }} tag: ${{ github.ref }} - name: upload shasum uses: svenstaro/upload-release-action@v2 if: ${{ inputs.upload_to_release }} with: file: ./${{ steps.archive.outputs.shasum }} asset_name: ${{ steps.archive.outputs.shasum }} tag: ${{ github.ref }} ================================================ FILE: .github/workflows/build.yml ================================================ name: CI on: create: tags: push: branches: - main pull_request: jobs: lint: name: lint runs-on: ubuntu-latest steps: - uses: actions/setup-python@v1 with: python-version: '3.x' - uses: actions/checkout@v1 - name: install tools run: | pip3 install flake8==7.3.0 sudo apt-get install clang-format - run: flake8 - run: ./scripts/clang-format-diff.sh env: GITHUB_EVENT_BEFORE: ${{ github.event.before }} build: name: build runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/setup-python@v5 with: python-version: '3.x' - uses: actions/checkout@v1 with: submodules: true - name: install ninja (linux) run: sudo apt-get install ninja-build if: matrix.os == 'ubuntu-latest' - name: install ninja (osx) run: brew install ninja if: matrix.os == 'macos-latest' - name: install ninja (win) run: choco install ninja if: matrix.os == 'windows-latest' - name: mkdir run: mkdir -p out - name: tool versions run: | cmake --version ninja --version - name: cmake run: cmake .. -G Ninja -DWERROR=ON -Werror=dev -DCMAKE_ERROR_DEPRECATED=OFF working-directory: out if: matrix.os != 'windows-latest' - name: cmake (windows) run: cmake .. -DWERROR=ON -Werror=dev -DCMAKE_ERROR_DEPRECATED=OFF working-directory: out if: matrix.os == 'windows-latest' - name: build run: cmake --build out - name: check if generated files are up-to-date run: python ./scripts/check_clean.py - name: unittests run: cmake --build out --target run-unittests - name: c-api-tests run: cmake --build out --target run-c-api-tests - name: tests run: cmake --build out --target run-tests emscripten: name: emscripten runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 with: submodules: true - name: build run: | docker run -di --name emscripten -v $(pwd):/src emscripten/emsdk:latest bash docker exec emscripten emcc -v docker exec emscripten emcmake cmake -B emscripten -DWERROR=ON docker exec -w /src/emscripten emscripten make -j $(nproc) wasi: name: wasi runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: submodules: true - name: build-tools run: | docker run -di --name wasi-sdk -v $(pwd):/src --workdir /src ghcr.io/webassembly/wasi-sdk:wasi-sdk-20 bash docker exec wasi-sdk cmake -S . -B out -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DBUILD_TESTS=0 -DBUILD_LIBWASM=0 docker exec wasi-sdk cmake --build out --config Release --target install - uses: ./.github/actions/release-archive with: os: wasi sanitize: name: sanitize runs-on: ubuntu-24.04 env: USE_NINJA: "1" CC: "clang" WASM2C_CFLAGS: "-march=x86-64-v2" # currently required for SIMDe to pass some tests on x86-64 strategy: matrix: sanitizer: [asan, ubsan, fuzz] type: [debug, release] steps: - uses: actions/setup-python@v1 with: python-version: '3.x' - uses: actions/checkout@v1 with: submodules: true - run: sudo apt-get install ninja-build - name: workaround for ASLR+ASAN compatibility # See https://github.com/actions/runner/issues/3207 run: sudo sysctl -w vm.mmap_rnd_bits=28 - run: make clang-${{ matrix.type }}-${{ matrix.sanitizer }} - if: ${{ matrix.sanitizer }} != fuzz run: make test-clang-${{ matrix.type }}-${{ matrix.sanitizer }} build-wasm2c-memchecked: name: wasm2c-memchecked runs-on: ubuntu-latest env: USE_NINJA: "1" CC: "clang" # used by the wasm2c tests WASM2C_CFLAGS: "-march=x86-64-v2 -fsanitize=address -DWASM_RT_USE_MMAP=0" steps: - uses: actions/setup-python@v1 with: python-version: '3.x' - uses: actions/checkout@v1 with: submodules: true - run: sudo apt-get install ninja-build - name: workaround for ASLR+ASAN compatibility # See https://github.com/actions/runner/issues/3207 run: sudo sysctl -w vm.mmap_rnd_bits=28 - run: make clang-debug-asan - run: make test-clang-debug-asan build-min-cmake: name: min-cmake runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 with: submodules: true - uses: actions/setup-python@v1 with: python-version: '3.x' - name: Install Ninja run: sudo apt-get install ninja-build - name: Detect minimum CMake version run: > awk 'match($0, /cmake_minimum_required\(VERSION *([0-9]+\.[0-9]+)\)/, a) { print "WABT_CMAKE_VER=" a[1]; exit; }' CMakeLists.txt | tee $GITHUB_ENV - name: Install minimum CMake run: | python -m pip install -U setuptools wheel pip python -m pip install "cmake==${WABT_CMAKE_VER}.*" cmake --version - name: configure (OpenSSL) run: cmake -G Ninja -S . -B out -DCMAKE_BUILD_TYPE=Release - name: build (OpenSSL) run: cmake --build out - name: install (OpenSSL) run: cmake --install out --prefix install - name: configure (PicoSHA2) run: cmake -G Ninja -S . -B out-picosha -DCMAKE_BUILD_TYPE=Release -DUSE_INTERNAL_SHA256=ON - name: build (PicoSHA2) run: cmake --build out-picosha - name: install (PicoSHA2) run: cmake --install out-picosha --prefix install-picosha - name: test CMake package (OpenSSL) run: > ctest --build-and-test scripts/example-project example-openssl --build-generator Ninja --build-options -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$PWD/install --test-command ctest - name: test CMake package (PicoSHA2) run: > ctest --build-and-test scripts/example-project example-picosha --build-generator Ninja --build-options -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$PWD/install-picosha --test-command ctest - name: unittests run: cmake --build out --target run-unittests - name: c-api-tests run: cmake --build out --target run-c-api-tests - name: tests run: cmake --build out --target run-tests build-rlbox: name: rlbox runs-on: ubuntu-latest env: USE_NINJA: "1" WASM2C_CC: "clang" WASM2C_CFLAGS: "-DWASM_RT_USE_MMAP=1 -DWASM_RT_SKIP_SIGNAL_RECOVERY=1 -DWASM_RT_NONCONFORMING_UNCHECKED_STACK_EXHAUSTION=1 -DWASM2C_TEST_EMBEDDER_SIGNAL_HANDLING -DWASM_RT_ALLOW_SEGUE=1 -DWASM_RT_SEGUE_FREE_SEGMENT=1 -mfsgsbase -DWASM_RT_SANITY_CHECKS=1 -Wno-pass-failed" steps: - uses: actions/setup-python@v1 with: python-version: '3.x' - uses: actions/checkout@v1 with: submodules: true - run: sudo apt-get install ninja-build - run: make clang-debug - name: tests (wasm2c tests excluding memory64) run: ./test/run-tests.py wasm2c --exclude-dir memory64 build-cross: runs-on: ubuntu-latest # Temporatily disabled until we can get it fixed: # https://github.com/WebAssembly/wabt/issues/2655 if: ${{ false }} strategy: fail-fast: false matrix: arch: [s390x] services: # still faster on debian... distcc: image: debian:latest options: --health-cmd distccmon-text --health-interval 5s --health-start-period 5m debian:latest bash -c "apt-get update && apt-get install -y g++-s390x-linux-gnu distcc && distccd --daemon --no-detach" ports: - 3632:3632 env: QEMU_LD_PREFIX: /usr/${{matrix.arch}}-linux-gnu/ steps: - uses: actions/setup-python@v1 with: python-version: '3.x' - uses: actions/checkout@v1 with: submodules: true - name: Set up QEMU uses: docker/setup-qemu-action@v2 with: platforms: ${{matrix.arch}} image: "tonistiigi/binfmt:master" - name: apt-get update run: sudo apt-get update - name: install ninja run: sudo apt-get install ninja-build - name: install the toolchain run: sudo apt-get install g++-${{matrix.arch}}-linux-gnu - name: install distcc run: sudo apt-get install distcc - name: mkdir distcc symlinks run: sudo mkdir -p /opt/bin/distcc_symlinks - name: distcc symlink run: sudo ln -s /usr/bin/distcc /opt/bin/distcc_symlinks/${{matrix.arch}}-linux-gnu-gcc # only CC is needed - name: cmake run: cmake -S . -B out -G Ninja -DCMAKE_TOOLCHAIN_FILE=../scripts/TC-${{matrix.arch}}.cmake -DWERROR=OFF -Werror=dev -DCMAKE_ERROR_DEPRECATED=OFF - name: build run: cmake --build out - name: check if generated files are up-to-date run: python ./scripts/check_clean.py - name: unittests run: cmake --build out --target run-unittests - name: tests run: cmake --build out --target run-tests ================================================ FILE: .github/workflows/build_release.yml ================================================ name: Build Release # Trigger whenever a release is created on: release: types: - created permissions: contents: write jobs: build: name: build runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - os: ubuntu-22.04 arch: x86_64 name: linux-x64 - os: ubuntu-22.04-arm arch: aarch64 name: linux-arm64 - os: macos-14 arch: aarch64 name: macos-arm64 - os: windows-latest arch: x86_64 name: windows-x64 defaults: run: shell: bash steps: - uses: actions/setup-python@v5 with: python-version: '3.x' - uses: actions/checkout@v1 with: submodules: true - name: install ninja (linux) run: sudo apt-get install ninja-build if: contains(matrix.os, 'ubuntu') - name: install ninja (osx) run: brew install ninja if: matrix.os == 'macos-14' - name: install ninja (win) run: choco install ninja if: matrix.os == 'windows-latest' - name: mkdir run: mkdir -p out - name: cmake (unix) run: cmake -S . -B out -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install if: matrix.os != 'windows-latest' - name: cmake (win) # -G "Visual Studio 15 2017" run: cmake -S . -B out -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install if: matrix.os == 'windows-latest' - name: build run: cmake --build out --config Release --target install - name: strip run: find bin/ -type f -perm -u=x -exec strip {} + if: matrix.os != 'windows-latest' - uses: ./.github/actions/release-archive with: os: ${{ matrix.name }} upload_to_release: true build-wasi: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: submodules: true - name: built-tools run: | docker run -di --name wasi-sdk -v $(pwd):/src --workdir /src ghcr.io/webassembly/wasi-sdk:wasi-sdk-20 bash docker exec wasi-sdk cmake -S . -B out -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DBUILD_TESTS=0 -DBUILD_LIBWASM=0 docker exec wasi-sdk cmake --build out --config Release --target install - uses: ./.github/actions/release-archive with: os: wasi upload_to_release: true ================================================ FILE: .github/workflows/build_source_release.yml ================================================ name: Build Source Release # Trigger whenever a release is created on: release: types: - created permissions: contents: write jobs: build: name: build runs-on: ubuntu-latest steps: - uses: actions/setup-python@v1 with: python-version: '3.x' - uses: actions/checkout@v1 with: submodules: true - name: archive id: archive run: | VERSION=${{ github.event.release.tag_name }} PKGNAME="wabt-$VERSION" mkdir -p /tmp/$PKGNAME mv * /tmp/$PKGNAME mv /tmp/$PKGNAME . TARBALL=$PKGNAME.tar.xz SHASUM=$PKGNAME.tar.xz.sha256 tar cJf $TARBALL $PKGNAME $PKGNAME/scripts/sha256sum.py $TARBALL > $SHASUM echo "::set-output name=tarball::$TARBALL" echo "::set-output name=shasum::$SHASUM" - name: upload tarball uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ./${{ steps.archive.outputs.tarball }} asset_name: ${{ steps.archive.outputs.tarball }} tag: ${{ github.ref }} - name: upload shasum uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ./${{ steps.archive.outputs.shasum }} asset_name: ${{ steps.archive.outputs.shasum }} tag: ${{ github.ref }} ================================================ FILE: .github/workflows/wabt-cifuzz.yml ================================================ name: CIFuzz on: [pull_request] jobs: Fuzzing: runs-on: ubuntu-latest steps: - name: Build Fuzzers id: build uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master with: oss-fuzz-project-name: 'wabt' - name: Run Fuzzers uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master with: oss-fuzz-project-name: 'wabt' fuzz-seconds: 300 - name: Upload Crash uses: actions/upload-artifact@v4 if: failure() && steps.build.outcome == 'success' with: name: artifacts path: ./out/artifacts ================================================ FILE: .gitignore ================================================ /bin /build /out /fuzz-out /emscripten *.pyc .idea/ .vscode/ /cmake-build-debug/ ================================================ FILE: .gitmodules ================================================ [submodule "third_party/testsuite"] path = third_party/testsuite url = https://github.com/WebAssembly/testsuite [submodule "third_party/gtest"] path = third_party/gtest url = https://github.com/google/googletest [submodule "third_party/ply"] path = third_party/ply url = https://github.com/dabeaz/ply [submodule "third_party/wasm-c-api"] path = third_party/wasm-c-api url = https://github.com/WebAssembly/wasm-c-api [submodule "third_party/uvwasi"] path = third_party/uvwasi url = https://github.com/nodejs/uvwasi [submodule "third_party/picosha2"] path = third_party/picosha2 url = https://github.com/okdshin/PicoSHA2 [submodule "third_party/simde"] path = third_party/simde url = https://github.com/simd-everywhere/simde ================================================ FILE: .style.yapf ================================================ [style] split_before_named_assigns = False based_on_style = chromium column_limit = 79 ================================================ FILE: CMakeLists.txt ================================================ # # Copyright 2016 WebAssembly Community Group participants # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # cmake_minimum_required(VERSION 3.16) project(WABT LANGUAGES C CXX VERSION 1.0.40) include(GNUInstallDirs) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # 10.13 doesn't support std::optional::value (becuase it depends on # std::bad_optional_acces). # See: https://github.com/WebAssembly/wabt/issues/2527 set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version") # Check if wabt is being used directly or via add_subdirectory, FetchContent, etc string(COMPARE EQUAL "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}" PROJECT_IS_TOP_LEVEL) # By default use the project version as the version string set(WABT_VERSION_STRING "${PROJECT_VERSION}") # For git users, attempt to generate a more useful version string if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) find_package(Git) if (Git_FOUND) execute_process( COMMAND "${GIT_EXECUTABLE}" -C "${WABT_SOURCE_DIR}" describe --tags RESULT_VARIABLE GIT_VERSION_RESULT ERROR_VARIABLE GIT_VERSION_ERROR ERROR_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE GIT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ) if (GIT_VERSION_RESULT EQUAL 0) # If we're actually on the tag for this version, don't add the commit description if (NOT GIT_VERSION STREQUAL "${WABT_VERSION_STRING}") string(APPEND WABT_VERSION_STRING " (git~${GIT_VERSION})") endif () elseif (PROJECT_IS_TOP_LEVEL) message(NOTICE "git: ${GIT_VERSION_ERROR}\n ** Did you forget to run `git fetch --tags`?") endif () endif () endif () option(BUILD_TESTS "Build GTest-based tests" ON) option(USE_SYSTEM_GTEST "Use system GTest, instead of building" OFF) option(BUILD_TOOLS "Build wabt commandline tools" ON) option(BUILD_FUZZ_TOOLS "Build tools that can repro fuzz bugs" OFF) option(BUILD_LIBWASM "Build libwasm" ON) option(USE_ASAN "Use address sanitizer" OFF) option(USE_MSAN "Use memory sanitizer" OFF) option(USE_LSAN "Use leak sanitizer" OFF) option(USE_UBSAN "Use undefined behavior sanitizer" OFF) option(CODE_COVERAGE "Build with code coverage enabled" OFF) option(WITH_EXCEPTIONS "Build with exceptions enabled" OFF) option(WERROR "Build with warnings as errors" OFF) option(WABT_INSTALL_RULES "Include WABT's install() rules" "${PROJECT_IS_TOP_LEVEL}") # WASI support is still a work in progress. # Only a handful of syscalls are supported at this point. option(WITH_WASI "Build WASI support via uvwasi" OFF) option(USE_INTERNAL_SHA256 "Use internal PicoSHA2 for SHA-256 support instead of OpenSSL libcrypto" OFF) if (MSVC) set(COMPILER_IS_CLANG 0) set(COMPILER_IS_GNU 0) set(COMPILER_IS_MSVC 1) elseif (CMAKE_C_COMPILER_ID MATCHES "Clang") set(COMPILER_IS_CLANG 1) set(COMPILER_IS_GNU 0) set(COMPILER_IS_MSVC 0) elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") set(COMPILER_IS_CLANG 0) set(COMPILER_IS_GNU 1) set(COMPILER_IS_MSVC 0) elseif (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") set(COMPILER_IS_CLANG 1) set(COMPILER_IS_GNU 0) set(COMPILER_IS_MSVC 0) else () set(COMPILER_IS_CLANG 0) set(COMPILER_IS_GNU 0) set(COMPILER_IS_MSVC 0) endif () include(CheckIncludeFile) include(CheckSymbolExists) check_include_file("alloca.h" HAVE_ALLOCA_H) check_include_file("unistd.h" HAVE_UNISTD_H) check_include_file("setjmp.h" HAVE_SETJMP_H) check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF) check_symbol_exists(strcasecmp "strings.h" HAVE_STRCASECMP) if (NOT USE_INTERNAL_SHA256) find_package(OpenSSL QUIET) if (OpenSSL_FOUND) set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) check_include_file("openssl/sha.h" HAVE_OPENSSL_SHA_H) if (HAVE_OPENSSL_SHA_H) find_package_message(OpenSSL "Using OpenSSL libcrypto for SHA-256" "${HAVE_OPENSSL_SHA_H}") endif() endif() endif() if (WIN32) if(${CMAKE_GENERATOR_PLATFORM} MATCHES "ARM64") # https://discourse.cmake.org/t/visual-studio-error-unable-to-deploy-local-file-c-x64-release-zero-check/2072 # Target ZERO_CHECK blocks remote debugger of ARM64 in Visual Studio set(CMAKE_SUPPRESS_REGENERATION ON) endif() check_symbol_exists(ENABLE_VIRTUAL_TERMINAL_PROCESSING "windows.h" HAVE_WIN32_VT100) endif () include(CheckTypeSize) check_type_size(ssize_t SSIZE_T) check_type_size(size_t SIZEOF_SIZE_T) include(TestBigEndian) # Note: deprecated in CMake 3.20 test_big_endian(WABT_BIG_ENDIAN) if (CMAKE_BUILD_TYPE STREQUAL "Debug") set(WABT_DEBUG 1) endif () configure_file(src/config.h.in include/wabt/config.h @ONLY) if (COMPILER_IS_MSVC) if (WERROR) add_definitions(-WX) endif () # disable warning C4018: signed/unsigned mismatch # disable warning C4056, C4756: overflow in floating-point constant arithmetic # seems to not like float compare w/ HUGE_VALF; bug? # disable warnings C4267 and C4244: conversion/truncation from larger to smaller type. # disable warning C4800: implicit conversion from larger int to bool add_definitions(-W3 -wd4018 -wd4056 -wd4756 -wd4267 -wd4244 -wd4800 -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS) if (NOT WITH_EXCEPTIONS) # disable exception use in C++ library add_definitions(-D_HAS_EXCEPTIONS=0) endif () # multi-core build. add_definitions("/MP") else () if (WERROR) add_definitions(-Werror) endif () # disable -Wunused-parameter: this is really common when implementing # interfaces, etc. # disable -Wpointer-arith: this is a GCC extension, and doesn't work in MSVC. add_definitions( -Wall -Wextra -Wno-unused-parameter -Wpointer-arith -Wuninitialized -Wimplicit-fallthrough ) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast") if (NOT WITH_EXCEPTIONS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") endif () # Need to define __STDC_*_MACROS because C99 specifies that C++ shouldn't # define format (e.g. PRIu64) or limit (e.g. UINT32_MAX) macros without the # definition, and some libcs (e.g. glibc2.17 and earlier) follow that. add_definitions(-D__STDC_LIMIT_MACROS=1 -D__STDC_FORMAT_MACROS=1) if (MINGW OR CYGWIN) # On MINGW, _POSIX_C_SOURCE is needed to ensure we use mingw printf # instead of the VC runtime one. add_definitions(-D_POSIX_C_SOURCE=200809L) endif() if (COMPILER_IS_GNU) # disable -Wclobbered: it seems to be guessing incorrectly about a local # variable being clobbered by longjmp. add_definitions(-Wno-clobbered) endif () # wasm doesn't allow for x87 floating point math if (NOT EMSCRIPTEN) check_symbol_exists(__i386__ "" TARGET_IS_X86_32) check_symbol_exists(__SSE2_MATH__ "" HAVE_SSE2_MATH) if (TARGET_IS_X86_32 AND NOT HAVE_SSE2_MATH) if (COMPILER_IS_GNU OR COMPILER_IS_CLANG) add_compile_options(-msse2 -mfpmath=sse) else () message( WARNING "Unknown compiler ${CMAKE_CXX_COMPILER_ID} appears to target x86-32 with x87 " "math. If you want wasm2c to work in a spec-compliant way, please add flags to " "use SSE2 math and set TARGET_IS_X86_32 and HAVE_SSE2_MATH appropriately at the " "CMake command line." ) endif () endif () endif () endif () set(USE_SANITIZER FALSE) function(sanitizer NAME FLAGS) if (${NAME}) if (USE_SANITIZER) message(FATAL_ERROR "Only one sanitizer allowed") endif () set(USE_SANITIZER TRUE PARENT_SCOPE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}" PARENT_SCOPE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}" PARENT_SCOPE) set(WASM2C_CFLAGS "${WASM2C_CFLAGS} ${FLAGS}" PARENT_SCOPE) endif () endfunction() sanitizer(USE_ASAN "-fsanitize=address") sanitizer(USE_MSAN "-fsanitize=memory") sanitizer(USE_LSAN "-fsanitize=leak") if (USE_UBSAN) # -fno-sanitize-recover was deprecated, see if we are compiling with a newer # clang that requires -fno-sanitize-recover=all. set(UBSAN_BLACKLIST ${WABT_SOURCE_DIR}/ubsan.blacklist) include(CheckCXXCompilerFlag) check_cxx_compiler_flag("-fsanitize=undefined -fno-sanitize-recover -Wall -Werror" HAS_UBSAN_RECOVER_BARE) if (HAS_UBSAN_RECOVER_BARE) sanitizer(USE_UBSAN "-fsanitize=undefined -fno-sanitize-recover -fsanitize-blacklist=${UBSAN_BLACKLIST}") endif () check_cxx_compiler_flag("-fsanitize=undefined -fno-sanitize-recover=all -Wall -Werror" HAS_UBSAN_RECOVER_ALL) # If we already setup UBSAN recover bare, setting it up again here will be an error. if (NOT USE_SANITIZER AND HAS_UBSAN_RECOVER_ALL) sanitizer(USE_UBSAN "-fsanitize=undefined -fno-sanitize-recover=all -fsanitize-blacklist=${UBSAN_BLACKLIST}") endif () if (NOT USE_SANITIZER) message(FATAL_ERROR "UBSAN is not supported") endif () endif () set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${WABT_SOURCE_DIR}/cmake) # CWriter code templates set(TEMPLATE_CMAKE ${WABT_SOURCE_DIR}/scripts/gen-wasm2c-templates.cmake) add_custom_command( OUTPUT gen-wasm2c-prebuilt COMMAND ${CMAKE_COMMAND} -D out="${WABT_SOURCE_DIR}/src/prebuilt/wasm2c_header_top.cc" -D in="${WABT_SOURCE_DIR}/src/template/wasm2c.top.h" -D symbol="s_header_top" -P ${TEMPLATE_CMAKE} COMMAND ${CMAKE_COMMAND} -D out="${WABT_SOURCE_DIR}/src/prebuilt/wasm2c_header_bottom.cc" -D in="${WABT_SOURCE_DIR}/src/template/wasm2c.bottom.h" -D symbol="s_header_bottom" -P ${TEMPLATE_CMAKE} COMMAND ${CMAKE_COMMAND} -D out="${WABT_SOURCE_DIR}/src/prebuilt/wasm2c_source_includes.cc" -D in="${WABT_SOURCE_DIR}/src/template/wasm2c.includes.c" -D symbol="s_source_includes" -P ${TEMPLATE_CMAKE} COMMAND ${CMAKE_COMMAND} -D out="${WABT_SOURCE_DIR}/src/prebuilt/wasm2c_source_declarations.cc" -D in="${WABT_SOURCE_DIR}/src/template/wasm2c.declarations.c" -D symbol="s_source_declarations" -P ${TEMPLATE_CMAKE} COMMAND ${CMAKE_COMMAND} -D out="${WABT_SOURCE_DIR}/src/prebuilt/wasm2c_simd_source_declarations.cc" -D in="${WABT_SOURCE_DIR}/src/template/wasm2c_simd.declarations.c" -D symbol="s_simd_source_declarations" -P ${TEMPLATE_CMAKE} COMMAND ${CMAKE_COMMAND} -D out="${WABT_SOURCE_DIR}/src/prebuilt/wasm2c_atomicops_source_declarations.cc" -D in="${WABT_SOURCE_DIR}/src/template/wasm2c_atomicops.declarations.c" -D symbol="s_atomicops_source_declarations" -P ${TEMPLATE_CMAKE} COMMAND ${CMAKE_COMMAND} -E touch gen-wasm2c-prebuilt DEPENDS ${WABT_SOURCE_DIR}/src/template/wasm2c.top.h ${WABT_SOURCE_DIR}/src/template/wasm2c.bottom.h ${WABT_SOURCE_DIR}/src/template/wasm2c.includes.c ${WABT_SOURCE_DIR}/src/template/wasm2c.declarations.c ${WABT_SOURCE_DIR}/src/template/wasm2c_simd.declarations.c ${WABT_SOURCE_DIR}/src/template/wasm2c_atomicops.declarations.c ) add_custom_target(gen-wasm2c-prebuilt-target DEPENDS gen-wasm2c-prebuilt) set(CWRITER_TEMPLATE_SRC ${WABT_SOURCE_DIR}/src/prebuilt/wasm2c_header_top.cc ${WABT_SOURCE_DIR}/src/prebuilt/wasm2c_header_bottom.cc ${WABT_SOURCE_DIR}/src/prebuilt/wasm2c_source_includes.cc ${WABT_SOURCE_DIR}/src/prebuilt/wasm2c_source_declarations.cc ${WABT_SOURCE_DIR}/src/prebuilt/wasm2c_simd_source_declarations.cc ${WABT_SOURCE_DIR}/src/prebuilt/wasm2c_atomicops_source_declarations.cc) add_custom_target(everything) set(WABT_LIBRARY_CC src/apply-names.cc src/binary-reader-ir.cc src/binary-reader-logging.cc src/binary-reader.cc src/binary-writer-spec.cc src/binary-writer.cc src/binary.cc src/binding-hash.cc src/color.cc src/common.cc src/config.cc src/config.h.in src/decompiler.cc src/error-formatter.cc src/expr-visitor.cc src/feature.cc src/filenames.cc src/generate-names.cc src/ir-util.cc src/ir.cc src/leb128.cc src/lexer-source-line-finder.cc src/lexer-source.cc src/literal.cc src/opcode-code-table.c src/opcode.cc src/option-parser.cc src/resolve-names.cc src/sha256.cc src/shared-validator.cc src/stream.cc src/token.cc src/tracing.cc src/type-checker.cc src/utf8.cc src/validator.cc src/wast-lexer.cc src/wast-parser.cc src/wat-writer.cc src/c-writer.cc ${CWRITER_TEMPLATE_SRC} # TODO(binji): Move this into its own library? src/interp/binary-reader-interp.cc src/interp/interp.cc src/interp/interp-util.cc src/interp/istream.cc ) set(WABT_LIBRARY_H ${WABT_BINARY_DIR}/include/wabt/config.h include/wabt/apply-names.h include/wabt/binary-reader-ir.h include/wabt/binary-reader-logging.h include/wabt/binary-reader.h include/wabt/binary-writer-spec.h include/wabt/binary-writer.h include/wabt/binary.h include/wabt/binding-hash.h include/wabt/color.h include/wabt/common.h include/wabt/decompiler-ast.h include/wabt/decompiler-ls.h include/wabt/decompiler-naming.h include/wabt/decompiler.h include/wabt/error-formatter.h include/wabt/expr-visitor.h include/wabt/feature.h include/wabt/filenames.h include/wabt/generate-names.h include/wabt/ir-util.h include/wabt/ir.h include/wabt/leb128.h include/wabt/lexer-source-line-finder.h include/wabt/lexer-source.h include/wabt/literal.h include/wabt/opcode-code-table.h include/wabt/opcode.h include/wabt/option-parser.h include/wabt/resolve-names.h include/wabt/sha256.h include/wabt/shared-validator.h include/wabt/stream.h include/wabt/string-util.h include/wabt/token.h include/wabt/tracing.h include/wabt/type-checker.h include/wabt/type.h include/wabt/utf8.h include/wabt/validator.h include/wabt/wast-lexer.h include/wabt/wast-parser.h include/wabt/wat-writer.h # TODO(binji): Move this into its own library? include/wabt/interp/binary-reader-interp.h include/wabt/interp/interp-inl.h include/wabt/interp/interp-math.h include/wabt/interp/interp-util.h include/wabt/interp/interp.h include/wabt/interp/istream.h ) set(WABT_LIBRARY_SRC ${WABT_LIBRARY_CC} ${WABT_LIBRARY_H}) add_library(wabt STATIC ${WABT_LIBRARY_SRC}) add_dependencies(wabt gen-wasm2c-prebuilt-target) add_library(wabt::wabt ALIAS wabt) if (HAVE_OPENSSL_SHA_H) target_link_libraries(wabt OpenSSL::Crypto) else() include_directories("${WABT_SOURCE_DIR}/third_party/picosha2") endif() target_compile_features(wabt PUBLIC cxx_std_17) target_include_directories( wabt PUBLIC "$" "$" ) if (WABT_INSTALL_RULES) install( TARGETS wabt EXPORT wabt-targets COMPONENT wabt-development INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) install( DIRECTORY "${WABT_SOURCE_DIR}/include/" "${WABT_BINARY_DIR}/include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT wabt-development ) endif () if (HAVE_SETJMP_H) set(WASM_RT_FILES "wasm2c/wasm-rt-impl.h" "wasm2c/wasm-rt-impl.c" "wasm2c/wasm-rt-exceptions-impl.c" "wasm2c/wasm-rt-mem-impl.c" "wasm2c/wasm-rt-impl-tableops.inc" "wasm2c/wasm-rt-mem-impl-helper.inc") add_library(wasm-rt-impl STATIC ${WASM_RT_FILES}) target_link_libraries(wasm-rt-impl ${CMAKE_THREAD_LIBS_INIT}) add_library(wabt::wasm-rt-impl ALIAS wasm-rt-impl) if (WABT_BIG_ENDIAN) target_compile_definitions(wasm-rt-impl PUBLIC WABT_BIG_ENDIAN=1) endif () if (WABT_INSTALL_RULES) install( TARGETS wasm-rt-impl EXPORT wabt-targets COMPONENT wabt-development INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) install( FILES "wasm2c/wasm-rt.h" "wasm2c/wasm-rt-exceptions.h" TYPE INCLUDE COMPONENT wabt-development ) install( FILES ${WASM_RT_FILES} DESTINATION "${CMAKE_INSTALL_DATADIR}/wabt/wasm2c" COMPONENT wabt-development ) endif () endif () if (BUILD_FUZZ_TOOLS) set(FUZZ_FLAGS "-fsanitize=fuzzer,address") add_library(wabt-fuzz STATIC ${WABT_LIBRARY_SRC}) target_link_libraries(wabt-fuzz PUBLIC wabt) set_target_properties(wabt-fuzz PROPERTIES COMPILE_FLAGS "${FUZZ_FLAGS}" ) endif () # libwasm, which implenents the wasm C API if (BUILD_LIBWASM) add_library(wasm SHARED ${WABT_LIBRARY_SRC} src/interp/interp-wasm-c-api.cc) target_link_libraries(wasm PUBLIC wabt) target_include_directories(wasm PUBLIC third_party/wasm-c-api/include) if (COMPILER_IS_MSVC) target_compile_definitions(wasm PRIVATE "WASM_API_EXTERN=__declspec(dllexport)") else () target_compile_options(wasm PRIVATE $<$:-Wno-old-style-cast>) target_compile_definitions(wasm PRIVATE "WASM_API_EXTERN=__attribute__((visibility(\"default\")))") endif () set_target_properties(wasm PROPERTIES CXX_VISIBILITY_PRESET hidden) endif () if (CODE_COVERAGE) add_definitions("-fprofile-arcs -ftest-coverage") if (COMPILER_IS_CLANG) set(CMAKE_EXE_LINKER_FLAGS "--coverage") else () link_libraries(gcov) endif () endif () include(CMakeParseArguments) function(wabt_executable) cmake_parse_arguments(EXE "WITH_LIBM;FUZZ;INSTALL" "NAME" "SOURCES;LIBS" ${ARGN}) # Always link libwabt. if (EXE_FUZZ) set(EXE_LIBS "${EXE_LIBS};wabt-fuzz") set(EXTRA_LINK_FLAGS "${FUZZ_FLAGS}") else () set(EXE_LIBS "${EXE_LIBS};wabt") endif () # Optionally link libm. if (EXE_WITH_LIBM AND (COMPILER_IS_CLANG OR COMPILER_IS_GNU)) set(EXE_LIBS "${EXE_LIBS};m") endif () add_executable(${EXE_NAME} ${EXE_SOURCES}) add_dependencies(everything ${EXE_NAME}) target_link_libraries(${EXE_NAME} ${EXE_LIBS}) if (EMSCRIPTEN) set(EXTRA_LINK_FLAGS "${EXTRA_LINK_FLAGS} -sNODERAWFS -Oz -sALLOW_MEMORY_GROWTH" ) endif () set_target_properties(${EXE_NAME} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" ) if (EXE_INSTALL) list(APPEND WABT_EXECUTABLES ${EXE_NAME}) set(WABT_EXECUTABLES ${WABT_EXECUTABLES} PARENT_SCOPE) add_custom_target(${EXE_NAME}-copy-to-bin ALL COMMAND ${CMAKE_COMMAND} -E make_directory ${WABT_SOURCE_DIR}/bin COMMAND ${CMAKE_COMMAND} -E copy $ ${WABT_SOURCE_DIR}/bin DEPENDS ${EXE_NAME} ) endif () endfunction() if (BUILD_TOOLS) # wat2wasm wabt_executable( NAME wat2wasm SOURCES src/tools/wat2wasm.cc INSTALL ) # wast2json wabt_executable( NAME wast2json SOURCES src/tools/wast2json.cc INSTALL ) # wasm2wat wabt_executable( NAME wasm2wat SOURCES src/tools/wasm2wat.cc INSTALL ) # wasm2c wabt_executable( NAME wasm2c SOURCES src/tools/wasm2c.cc INSTALL ) # wasm-stats wabt_executable( NAME wasm-stats SOURCES src/tools/wasm-stats.cc src/binary-reader-stats.cc INSTALL ) # wasm-objdump wabt_executable( NAME wasm-objdump SOURCES src/tools/wasm-objdump.cc src/binary-reader-objdump.cc INSTALL ) if(WITH_WASI) # uvwasi uses the deprecated FetchContent_Populate function, disable it to avoid build error set(CMAKE_POLICY_DEFAULT_CMP0169_BACK ${CMAKE_POLICY_DEFAULT_CMP0169}) set(CMAKE_POLICY_DEFAULT_CMP0169 OLD) add_subdirectory("third_party/uvwasi" EXCLUDE_FROM_ALL) set(CMAKE_POLICY_DEFAULT_CMP0169 ${CMAKE_POLICY_DEFAULT_CMP0169_BACK}) include_directories(third_party/uvwasi/include) add_definitions(-DWITH_WASI) set(INTERP_LIBS uvwasi_a) set(EXTRA_INTERP_SRC src/interp/interp-wasi.cc) if (COMPILER_IS_GNU) target_compile_options(uv_a PRIVATE "-Wno-sign-compare") elseif (COMPILER_IS_CLANG) target_compile_options(uv_a PRIVATE "-Wno-implicit-fallthrough") endif() endif() # wasm-interp wabt_executable( NAME wasm-interp SOURCES src/tools/wasm-interp.cc ${EXTRA_INTERP_SRC} LIBS ${INTERP_LIBS} WITH_LIBM INSTALL ) # spectest-interp wabt_executable( NAME spectest-interp SOURCES src/tools/spectest-interp.cc WITH_LIBM INSTALL ) # wat-desugar wabt_executable( NAME wat-desugar SOURCES src/tools/wat-desugar.cc INSTALL ) # wasm-validate wabt_executable( NAME wasm-validate SOURCES src/tools/wasm-validate.cc INSTALL ) # wasm-strip wabt_executable( NAME wasm-strip SOURCES src/tools/wasm-strip.cc INSTALL ) # wasm-decompile wabt_executable( NAME wasm-decompile SOURCES src/tools/wasm-decompile.cc INSTALL ) if(BUILD_FUZZ_TOOLS) # wasm2wat-fuzz wabt_executable( NAME wasm2wat-fuzz SOURCES src/tools/wasm2wat-fuzz.cc FUZZ INSTALL ) endif () endif () if (BUILD_TESTS) if (CMAKE_BUILD_TYPE STREQUAL "Debug") set(WASM2C_CFLAGS "${WASM2C_CFLAGS} -g -O0") endif () if (WABT_BIG_ENDIAN) set(WASM2C_CFLAGS "${WASM2C_CFLAGS} -DWABT_BIG_ENDIAN=1") endif () if (NOT "${CMAKE_OSX_SYSROOT}" STREQUAL "") set(WASM2C_CFLAGS "${WASM2C_CFLAGS} -isysroot ${CMAKE_OSX_SYSROOT}") endif () if (DEFINED ENV{WASM2C_CFLAGS}) set(WASM2C_CFLAGS "${WASM2C_CFLAGS} $ENV{WASM2C_CFLAGS}") endif () set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) # Python 3.5 is the version shipped in Ubuntu Xenial find_package(Python3 3.5 REQUIRED COMPONENTS Interpreter) if (NOT USE_SYSTEM_GTEST) if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/gtest/googletest) message(FATAL_ERROR "Can't find third_party/gtest. Run git submodule update --init, or disable with CMake -DBUILD_TESTS=OFF.") endif () include_directories( third_party/gtest/googletest third_party/gtest/googletest/include ) # gtest add_library(gtest STATIC third_party/gtest/googletest/src/gtest-all.cc ) add_library(gtest_main STATIC third_party/gtest/googletest/src/gtest_main.cc ) if (COMPILER_IS_GNU) target_compile_options(gtest PRIVATE "-Wno-maybe-uninitialized") endif () endif () # hexfloat-test set(HEXFLOAT_TEST_SRCS src/literal.cc src/test-hexfloat.cc ) wabt_executable( NAME hexfloat_test SOURCES ${HEXFLOAT_TEST_SRCS} LIBS gtest_main gtest ${CMAKE_THREAD_LIBS_INIT} ) # wabt-unittests set(UNITTESTS_SRCS src/test-binary-reader.cc src/test-interp.cc src/test-intrusive-list.cc src/test-literal.cc src/test-option-parser.cc src/test-filenames.cc src/test-utf8.cc src/test-wast-parser.cc ) wabt_executable( NAME wabt-unittests SOURCES ${UNITTESTS_SRCS} LIBS gtest_main gtest ${CMAKE_THREAD_LIBS_INIT} ) # test running set(RUN_TESTS_PY ${WABT_SOURCE_DIR}/test/run-tests.py) add_custom_target(run-tests COMMAND ${CMAKE_COMMAND} -E env WASM2C_CC=${CMAKE_C_COMPILER} WASM2C_CFLAGS=${WASM2C_CFLAGS} ${Python3_EXECUTABLE} ${RUN_TESTS_PY} --bindir $ DEPENDS ${WABT_EXECUTABLES} WORKING_DIRECTORY ${WABT_SOURCE_DIR} USES_TERMINAL ) add_custom_target(run-unittests COMMAND $ DEPENDS wabt-unittests WORKING_DIRECTORY ${WABT_SOURCE_DIR} USES_TERMINAL ) add_custom_target(run-c-api-tests COMMAND ${Python3_EXECUTABLE} ${WABT_SOURCE_DIR}/test/run-c-api-examples.py --bindir $ WORKING_DIRECTORY ${WABT_SOURCE_DIR} USES_TERMINAL ) add_custom_target(check DEPENDS run-unittests run-tests run-c-api-tests) function(c_api_example NAME) set(EXENAME wasm-c-api-${NAME}) add_executable(${EXENAME} third_party/wasm-c-api/example/${NAME}.c) if (COMPILER_IS_MSVC) set_target_properties(${EXENAME} PROPERTIES COMPILE_FLAGS "-wd4311") else () set_target_properties(${EXENAME} PROPERTIES COMPILE_FLAGS "-std=gnu11 -Wno-pointer-to-int-cast") endif () target_link_libraries(${EXENAME} wasm Threads::Threads) add_custom_target(${EXENAME}-copy-to-bin ALL COMMAND ${CMAKE_COMMAND} -E make_directory ${WABT_SOURCE_DIR}/bin COMMAND ${CMAKE_COMMAND} -E copy $ ${WABT_SOURCE_DIR}/bin/ COMMAND ${CMAKE_COMMAND} -E copy ${WABT_SOURCE_DIR}/third_party/wasm-c-api/example/${NAME}.wasm $/ COMMAND ${CMAKE_COMMAND} -E copy ${WABT_SOURCE_DIR}/third_party/wasm-c-api/example/${NAME}.wasm ${WABT_SOURCE_DIR}/bin/ DEPENDS ${EXENAME} ) add_dependencies(run-c-api-tests ${EXENAME}) endfunction() c_api_example(callback) c_api_example(finalize) c_api_example(global) c_api_example(hello) c_api_example(hostref) c_api_example(multi) c_api_example(memory) c_api_example(reflect) c_api_example(serialize) c_api_example(start) c_api_example(table) c_api_example(trap) if (CMAKE_USE_PTHREADS_INIT) c_api_example(threads) endif () endif () # install if (WABT_INSTALL_RULES AND (BUILD_TOOLS OR BUILD_TESTS)) install( TARGETS ${WABT_EXECUTABLES} COMPONENT wabt-runtime ) if (UNIX) install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/man/" DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT wabt-documentation FILES_MATCHING PATTERN "*.1" ) endif () endif () if (EMSCRIPTEN) # flags for all emscripten builds # exceptions are never needed set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") # wabt.js # just dump everything into one binary so we can reference it from JavaScript add_definitions(-Wno-warn-absolute-paths) add_executable(libwabtjs src/emscripten-helpers.cc) add_dependencies(everything libwabtjs) target_link_libraries(libwabtjs wabt) set_target_properties(libwabtjs PROPERTIES OUTPUT_NAME libwabt) set(WABT_POST_JS ${WABT_SOURCE_DIR}/src/wabt.post.js) set(EMSCRIPTEN_EXPORTS ${WABT_SOURCE_DIR}/src/emscripten-exports.txt) set(LIBWABT_LINK_FLAGS --post-js ${WABT_POST_JS} -sEXPORTED_FUNCTIONS=@${EMSCRIPTEN_EXPORTS} -sALLOW_TABLE_GROWTH -sALLOW_MEMORY_GROWTH -sEXPORT_ES6 -sEXPORT_NAME=WabtModule -sEXPORTED_RUNTIME_METHODS=stringToNewUTF8,lengthBytesUTF8 -Oz ) string(REPLACE ";" " " LIBWABT_LINK_FLAGS_STR "${LIBWABT_LINK_FLAGS}") set_target_properties(libwabtjs PROPERTIES LINK_FLAGS "${LIBWABT_LINK_FLAGS_STR}" LINK_DEPENDS "${WABT_POST_JS};${EMSCRIPTEN_EXPORTS}" ) endif () # Create find_package configuration files if (WABT_INSTALL_RULES) include(CMakePackageConfigHelpers) set(WABT_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/wabt" CACHE STRING "Path to wabt CMake files") install( EXPORT wabt-targets DESTINATION "${WABT_INSTALL_CMAKEDIR}" NAMESPACE wabt:: FILE wabt-targets.cmake COMPONENT wabt-development ) configure_package_config_file( scripts/wabt-config.cmake.in wabt-config.cmake INSTALL_DESTINATION "${WABT_INSTALL_CMAKEDIR}" NO_SET_AND_CHECK_MACRO ) write_basic_package_version_file( wabt-config-version.cmake COMPATIBILITY ExactVersion ) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/wabt-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/wabt-config-version.cmake" DESTINATION "${WABT_INSTALL_CMAKEDIR}" COMPONENT wabt-development ) endif () ================================================ FILE: Contributing.md ================================================ # Contributing to WebAssembly Interested in participating? Please follow [the same contributing guidelines as the design repository][]. [the same contributing guidelines as the design repository]: https://github.com/WebAssembly/design/blob/master/Contributing.md Also, please be sure to read [the README.md](README.md) for this repository. ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: Makefile ================================================ # # Copyright 2016 WebAssembly Community Group participants # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # .SUFFIXES: MAKEFILE_NAME := $(lastword $(MAKEFILE_LIST)) ROOT_DIR := $(dir $(abspath $(MAKEFILE_NAME))) USE_NINJA ?= 1 CMAKE_CMD ?= cmake DEFAULT_SUFFIX = clang-debug COMPILERS := GCC GCC_I686 CLANG CLANG_I686 EMCC BUILD_TYPES := DEBUG RELEASE SANITIZERS := ASAN MSAN LSAN UBSAN FUZZ CONFIGS := NORMAL $(SANITIZERS) COV NO_TESTS # directory names GCC_DIR := gcc/ GCC_I686_DIR := gcc-i686/ CLANG_DIR := clang/ CLANG_I686_DIR := clang-i686/ EMCC_DIR := emscripten/ DEBUG_DIR := Debug/ RELEASE_DIR := Release/ NORMAL_DIR := ASAN_DIR := asan/ MSAN_DIR := msan/ LSAN_DIR := lsan/ UBSAN_DIR := ubsan/ FUZZ_DIR := fuzz/ COV_DIR := cov/ NO_TESTS_DIR := no-tests/ # CMake flags GCC_FLAG := -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ GCC_I686_FLAG := -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ \ -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 CLANG_FLAG := -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ CLANG_I686_FLAG := -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 DEBUG_FLAG := -DCMAKE_BUILD_TYPE=Debug RELEASE_FLAG := -DCMAKE_BUILD_TYPE=Release NORMAL_FLAG := ASAN_FLAG := -DUSE_ASAN=ON MSAN_FLAG := -DUSE_MSAN=ON LSAN_FLAG := -DUSE_LSAN=ON UBSAN_FLAG := -DUSE_UBSAN=ON FUZZ_FLAG := -DBUILD_FUZZ_TOOLS=ON COV_FLAG := -DCODE_COVERAGE=ON NO_TESTS_FLAG := -DBUILD_TESTS=OFF # make target prefixes GCC_PREFIX := gcc GCC_I686_PREFIX := gcc-i686 CLANG_PREFIX := clang CLANG_I686_PREFIX := clang-i686 EMCC_PREFIX := emscripten DEBUG_PREFIX := -debug RELEASE_PREFIX := -release NORMAL_PREFIX := ASAN_PREFIX := -asan MSAN_PREFIX := -msan LSAN_PREFIX := -lsan UBSAN_PREFIX := -ubsan FUZZ_PREFIX := -fuzz COV_PREFIX := -cov NO_TESTS_PREFIX := -no-tests ifeq ($(USE_NINJA),1) BUILD_CMD := ninja BUILD_FILE := build.ninja GENERATOR := Ninja else BUILD_CMD := +$(MAKE) --no-print-directory BUILD_FILE := Makefile GENERATOR := "Unix Makefiles" endif CMAKE_DIR = out/$($(1)_DIR)$($(2)_DIR)$($(3)_DIR) BUILD_TARGET = $($(1)_PREFIX)$($(2)_PREFIX)$($(3)_PREFIX) INSTALL_TARGET = install-$($(1)_PREFIX)$($(2)_PREFIX)$($(3)_PREFIX) TEST_TARGET = test-$($(1)_PREFIX)$($(2)_PREFIX)$($(3)_PREFIX) define CMAKE $(call CMAKE_DIR,$(1),$(2),$(3)): mkdir -p $(call CMAKE_DIR,$(1),$(2),$(3)) $(call CMAKE_DIR,$(1),$(2),$(3))$$(BUILD_FILE): | $(call CMAKE_DIR,$(1),$(2),$(3)) cd $(call CMAKE_DIR,$(1),$(2),$(3)) && \ $$(if $$(filter EMCC,$(1)),emcmake ,)$$(CMAKE_CMD) -G $$(GENERATOR) $$(ROOT_DIR) $$($(1)_FLAG) $$($(2)_FLAG) $$($(3)_FLAG) endef define BUILD .PHONY: $(call BUILD_TARGET,$(1),$(2),$(3)) $(call BUILD_TARGET,$(1),$(2),$(3)): $(call CMAKE_DIR,$(1),$(2),$(3))$$(BUILD_FILE) $$(BUILD_CMD) -C $(call CMAKE_DIR,$(1),$(2),$(3)) all endef define INSTALL .PHONY: $(call INSTALL_TARGET,$(1),$(2),$(3)) $(call INSTALL_TARGET,$(1),$(2),$(3)): $(call CMAKE_DIR,$(1),$(2),$(3))$$(BUILD_FILE) $$(BUILD_CMD) -C $(call CMAKE_DIR,$(1),$(2),$(3)) install endef define TEST .PHONY: $(call TEST_TARGET,$(1),$(2),$(3)) $(call TEST_TARGET,$(1),$(2),$(3)): $(call CMAKE_DIR,$(1),$(2),$(3))$$(BUILD_FILE) $$(BUILD_CMD) -C $(call CMAKE_DIR,$(1),$(2),$(3)) check test-everything: $(CALL TEST_TARGET,$(1),$(2),$(3)) endef .PHONY: all install test all: $(DEFAULT_SUFFIX) install: install-$(DEFAULT_SUFFIX) test: test-$(DEFAULT_SUFFIX) .PHONY: clean clean: rm -rf out .PHONY: test-everything test-everything: .PHONY: update-gperf update-gperf: src/prebuilt/lexer-keywords.cc src/prebuilt/lexer-keywords.cc: src/lexer-keywords.txt gperf -m 50 -L C++ -N InWordSet -E -t -c --output-file=$@ $< .PHONY: update-wasm2c-fac update-wasm2c-fac: make -C wasm2c/examples/fac .PHONY: demo demo: emscripten-release cp out/emscripten/Release/libwabt.js docs/demo cp out/emscripten/Release/libwabt.wasm docs/demo # running CMake $(foreach CONFIG,$(CONFIGS), \ $(foreach COMPILER,$(COMPILERS), \ $(foreach BUILD_TYPE,$(BUILD_TYPES), \ $(eval $(call CMAKE,$(COMPILER),$(BUILD_TYPE),$(CONFIG)))))) # building $(foreach CONFIG,$(CONFIGS), \ $(foreach COMPILER,$(COMPILERS), \ $(foreach BUILD_TYPE,$(BUILD_TYPES), \ $(eval $(call BUILD,$(COMPILER),$(BUILD_TYPE),$(CONFIG)))))) # installing $(foreach CONFIG,$(CONFIGS), \ $(foreach COMPILER,$(COMPILERS), \ $(foreach BUILD_TYPE,$(BUILD_TYPES), \ $(eval $(call INSTALL,$(COMPILER),$(BUILD_TYPE),$(CONFIG)))))) # test running $(foreach CONFIG,$(CONFIGS), \ $(foreach COMPILER,$(COMPILERS), \ $(foreach BUILD_TYPE,$(BUILD_TYPES), \ $(eval $(call TEST,$(COMPILER),$(BUILD_TYPE),$(CONFIG)))))) ================================================ FILE: README.md ================================================ [![Github CI Status](https://github.com/WebAssembly/wabt/workflows/CI/badge.svg)](https://github.com/WebAssembly/wabt/actions/workflows/build.yml) # WABT: The WebAssembly Binary Toolkit WABT (we pronounce it "wabbit") is a suite of tools for WebAssembly, including: - [**wat2wasm**](https://webassembly.github.io/wabt/doc/wat2wasm.1.html): translate from [WebAssembly text format](https://webassembly.github.io/spec/core/text/index.html) to the [WebAssembly binary format](https://webassembly.github.io/spec/core/binary/index.html) - [**wasm2wat**](https://webassembly.github.io/wabt/doc/wasm2wat.1.html): the inverse of wat2wasm, translate from the binary format back to the text format (also known as a .wat) - [**wasm-objdump**](https://webassembly.github.io/wabt/doc/wasm-objdump.1.html): print information about a wasm binary. Similiar to objdump. - [**wasm-interp**](https://webassembly.github.io/wabt/doc/wasm-interp.1.html): decode and run a WebAssembly binary file using a stack-based interpreter - [**wasm-decompile**](https://webassembly.github.io/wabt/doc/wasm-decompile.1.html): decompile a wasm binary into readable C-like syntax. - [**wat-desugar**](https://webassembly.github.io/wabt/doc/wat-desugar.1.html): parse .wat text form as supported by the spec interpreter (s-expressions, flat syntax, or mixed) and print "canonical" flat format - [**wasm2c**](https://webassembly.github.io/wabt/doc/wasm2c.1.html): convert a WebAssembly binary file to a C source and header - [**wasm-strip**](https://webassembly.github.io/wabt/doc/wasm-strip.1.html): remove sections of a WebAssembly binary file - [**wasm-validate**](https://webassembly.github.io/wabt/doc/wasm-validate.1.html): validate a file in the WebAssembly binary format - [**wast2json**](https://webassembly.github.io/wabt/doc/wast2json.1.html): convert a file in the wasm spec test format to a JSON file and associated wasm binary files - [**wasm-stats**](https://webassembly.github.io/wabt/doc/wasm-stats.1.html): output stats for a module - [**spectest-interp**](https://webassembly.github.io/wabt/doc/spectest-interp.1.html): read a Spectest JSON file, and run its tests in the interpreter These tools are intended for use in (or for development of) toolchains or other systems that want to manipulate WebAssembly files. Unlike the WebAssembly spec interpreter (which is written to be as simple, declarative and "speccy" as possible), they are written in C/C++ and designed for easier integration into other systems. Unlike [Binaryen](https://github.com/WebAssembly/binaryen) these tools do not aim to provide an optimization platform or a higher-level compiler target; instead they aim for full fidelity and compliance with the spec (e.g. 1:1 round-trips with no changes to instructions). ## Online Demos Wabt has been compiled to JavaScript via emscripten. Some of the functionality is available in the following demos: - [index](https://webassembly.github.io/wabt/demo/) - [wat2wasm](https://webassembly.github.io/wabt/demo/wat2wasm/) - [wasm2wat](https://webassembly.github.io/wabt/demo/wasm2wat/) ## Supported Proposals * Proposal: Name and link to the WebAssembly proposal repo * flag: Flag to pass to the tool to enable/disable support for the feature * default: Whether the feature is enabled by default * binary: Whether wabt can read/write the binary format * text: Whether wabt can read/write the text format * validate: Whether wabt can validate the syntax * interpret: Whether wabt can execute these operations in `wasm-interp` or `spectest-interp` * wasm2c: Whether wasm2c supports these operations | Proposal | flag | default | binary | text | validate | interpret | wasm2c | | --------------------- | --------------------------- | - | - | - | - | - | - | | [exception handling][]| `--enable-exceptions` | | ✓ | ✓ | ✓ | ✓ | ✓ | | [mutable globals][] | `--disable-mutable-globals` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | [nontrapping float-to-int conversions][] | `--disable-saturating-float-to-int` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | [sign extension][] | `--disable-sign-extension` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | [simd][] | `--disable-simd` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | [threads][] | `--enable-threads` | | ✓ | ✓ | ✓ | ✓ | | | [multi-value][] | `--disable-multi-value` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | [tail-call][] | `--enable-tail-call` | | ✓ | ✓ | ✓ | ✓ | ✓ | | [bulk memory][] | `--disable-bulk-memory` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | [reference types][] | `--disable-reference-types` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | [annotations][] | `--enable-annotations` | | | ✓ | | | | | [memory64][] | `--enable-memory64` | | ✓ | ✓ | ✓ | ✓ | ✓ | | [multi-memory][] | `--enable-multi-memory` | | ✓ | ✓ | ✓ | ✓ | ✓ | | [extended-const][] | `--enable-extended-const` | | ✓ | ✓ | ✓ | ✓ | ✓ | | [relaxed-simd][] | `--enable-relaxed-simd` | | ✓ | ✓ | ✓ | ✓ | | | [custom-page-sizes][] | `--enable-custom-page-sizes`| | ✓ | ✓ | ✓ | ✓ | ✓ | | [compact-imports][] | `--enable-compact-imports` | | ✓ | | ✓ | | | | [function-references][] | `--enable-function-references` | | ✓ | ✓ | ✓ | ✓ | | | [wide-arithmetic][] | `--enable-wide-arithmetic` | | ✓ | ✓ | ✓ | | | [exception handling]: https://github.com/WebAssembly/exception-handling [mutable globals]: https://github.com/WebAssembly/mutable-global [nontrapping float-to-int conversions]: https://github.com/WebAssembly/nontrapping-float-to-int-conversions [sign extension]: https://github.com/WebAssembly/sign-extension-ops [simd]: https://github.com/WebAssembly/simd [threads]: https://github.com/WebAssembly/threads [multi-value]: https://github.com/WebAssembly/multi-value [tail-call]: https://github.com/WebAssembly/tail-call [bulk memory]: https://github.com/WebAssembly/bulk-memory-operations [reference types]: https://github.com/WebAssembly/reference-types [annotations]: https://github.com/WebAssembly/annotations [memory64]: https://github.com/WebAssembly/memory64 [multi-memory]: https://github.com/WebAssembly/multi-memory [extended-const]: https://github.com/WebAssembly/extended-const [relaxed-simd]: https://github.com/WebAssembly/relaxed-simd [custom-page-sizes]: https://github.com/WebAssembly/custom-page-sizes [function-references]: https://github.com/WebAssembly/function-references [compact-imports]: https://github.com/WebAssembly/compact-import-section [wide-arithmetic]: https://github.com/WebAssembly/wide-arithmetic ## Cloning Clone as normal, but don't forget to get the submodules as well: ```console $ git clone --recursive https://github.com/WebAssembly/wabt $ cd wabt $ git submodule update --init ``` This will fetch the testsuite and gtest repos, which are needed for some tests. ## Building using CMake directly (Linux and macOS) You'll need [CMake](https://cmake.org). You can then run CMake, the normal way: ```console $ mkdir build $ cd build $ cmake .. $ cmake --build . ``` This will produce build files using CMake's default build generator. Read the CMake documentation for more information. **NOTE**: You must create a separate directory for the build artifacts (e.g. `build` above). Running `cmake` from the repo root directory will not work since the build produces an executable called `wasm2c` which conflicts with the `wasm2c` directory. ## Building using the top-level `Makefile` (Linux and macOS) **NOTE**: Under the hood, this uses `make` to run CMake, which then calls `ninja` to perform that actual build. On some systems (typically macOS), this doesn't build properly. If you see these errors, you can build using CMake directly as described above. You'll need [CMake](https://cmake.org) and [Ninja](https://ninja-build.org). If you just run `make`, it will run CMake for you, and put the result in `out/clang/Debug/` by default: > Note: If you are on macOS, you will need to use CMake version 3.2 or higher ```console $ make ``` This will build the default version of the tools: a debug build using the Clang compiler. There are many make targets available for other configurations as well. They are generated from every combination of a compiler, build type and configuration. - compilers: `gcc`, `clang`, `gcc-i686`, `emscripten` - build types: `debug`, `release` - configurations: empty, `asan`, `msan`, `lsan`, `ubsan`, `fuzz`, `no-tests` They are combined with dashes, for example: ```console $ make clang-debug $ make gcc-i686-release $ make clang-debug-lsan $ make gcc-debug-no-tests ``` ## Building (Windows) You'll need [CMake](https://cmake.org). You'll also need [Visual Studio](https://www.visualstudio.com/) (2015 or newer) or [MinGW](https://www.mingw-w64.org/). _Note: Visual Studio 2017 and later come with CMake (and the Ninja build system) out of the box, and should be on your PATH if you open a Developer Command prompt. See for more details._ You can run CMake from the command prompt, or use the CMake GUI tool. See [Running CMake](https://cmake.org/runningcmake/) for more information. When running from the commandline, create a new directory for the build artifacts, then run cmake from this directory: ```console > cd [build dir] > cmake [wabt project root] -DCMAKE_BUILD_TYPE=[config] -DCMAKE_INSTALL_PREFIX=[install directory] -G [generator] ``` The `[config]` parameter should be a CMake build type, typically `DEBUG` or `RELEASE`. The `[generator]` parameter should be the type of project you want to generate, for example `"Visual Studio 14 2015"`. You can see the list of available generators by running `cmake --help`. To build the project, you can use Visual Studio, or you can tell CMake to do it: ```console > cmake --build [wabt project root] --config [config] --target install ``` This will build and install to the installation directory you provided above. So, for example, if you want to build the debug configuration on Visual Studio 2015: ```console > mkdir build > cd build > cmake .. -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_INSTALL_PREFIX=..\ -G "Visual Studio 14 2015" > cmake --build . --config DEBUG --target install ``` ## Adding new keywords to the lexer If you want to add new keywords, you'll need to install [gperf](https://www.gnu.org/software/gperf/). Before you upload your PR, please run `make update-gperf` to update the prebuilt C++ sources in `src/prebuilt/`. ## Running wat2wasm Some examples: ```sh # parse test.wat and write to .wasm binary file with the same name $ bin/wat2wasm test.wat # parse test.wat and write to binary file test.wasm $ bin/wat2wasm test.wat -o test.wasm # parse spec-test.wast, and write verbose output to stdout (including the # meaning of every byte) $ bin/wat2wasm spec-test.wast -v ``` You can use `--help` to get additional help: ```console $ bin/wat2wasm --help ``` Or try the [online demo](https://webassembly.github.io/wabt/demo/wat2wasm/). ## Running wasm2wat Some examples: ```sh # parse binary file test.wasm and write text file test.wat $ bin/wasm2wat test.wasm -o test.wat # parse test.wasm and write test.wat $ bin/wasm2wat test.wasm -o test.wat ``` You can use `--help` to get additional help: ```console $ bin/wasm2wat --help ``` Or try the [online demo](https://webassembly.github.io/wabt/demo/wasm2wat/). ## Running wasm-interp Some examples: ```sh # parse binary file test.wasm, and type-check it $ bin/wasm-interp test.wasm # parse test.wasm and run all its exported functions $ bin/wasm-interp test.wasm --run-all-exports # parse test.wasm, run the exported functions and trace the output $ bin/wasm-interp test.wasm --run-all-exports --trace # parse test.json and run the spec tests $ bin/wasm-interp test.json --spec # parse test.wasm and run all its exported functions, setting the value stack # size to 100 elements $ bin/wasm-interp test.wasm -V 100 --run-all-exports ``` You can use `--help` to get additional help: ```console $ bin/wasm-interp --help ``` ## Running wast2json See [wast2json.md](docs/wast2json.md). ## Running wasm-decompile For example: ```sh # parse binary file test.wasm and write text file test.dcmp $ bin/wasm-decompile test.wasm -o test.dcmp ``` You can use `--help` to get additional help: ```console $ bin/wasm-decompile --help ``` See [decompiler.md](docs/decompiler.md) for more information on the language being generated. ## Running wasm2c See [wasm2c.md](wasm2c/README.md) ## Running the test suite See [test/README.md](test/README.md). ## Sanitizers To build with the [LLVM sanitizers](https://github.com/google/sanitizers), append the sanitizer name to the target: ```console $ make clang-debug-asan $ make clang-debug-msan $ make clang-debug-lsan $ make clang-debug-ubsan ``` There are configurations for the Address Sanitizer (ASAN), Memory Sanitizer (MSAN), Leak Sanitizer (LSAN) and Undefined Behavior Sanitizer (UBSAN). You can read about the behaviors of the sanitizers in the link above, but essentially the Address Sanitizer finds invalid memory accesses (use after free, access out-of-bounds, etc.), Memory Sanitizer finds uses of uninitialized memory, the Leak Sanitizer finds memory leaks, and the Undefined Behavior Sanitizer finds undefined behavior (surprise!). Typically, you'll just want to run all the tests for a given sanitizer: ```console $ make test-asan ``` You can also run the tests for a release build: ```console $ make test-clang-release-asan ... ``` The GitHub actions bots run all of these tests (and more). Before you land a change, you should run them too. One easy way is to use the `test-everything` target: ```console $ make test-everything ``` ## Fuzzing To build using the [LLVM fuzzer support](https://llvm.org/docs/LibFuzzer.html), append `fuzz` to the target: ```console $ make clang-debug-fuzz ``` This will produce a `wasm2wat_fuzz` binary. It can be used to fuzz the binary reader, as well as reproduce fuzzer errors found by [oss-fuzz](https://github.com/google/oss-fuzz/tree/master/projects/wabt). ```console $ out/clang/Debug/fuzz/wasm2wat_fuzz ... ``` See the [libFuzzer documentation](https://llvm.org/docs/LibFuzzer.html) for more information about how to use this tool. ## Installing prebuilt binaries Wabt is available on many platforms as prepackaged binaries. For example, if you use Homebrew you can use: ```sh brew install wabt ``` And you use an apt-based linux distribution you can use: ```sh sudo apt install wabt ``` You can also download prebuilt binaries for many platforms directly from the github releases page. ================================================ FILE: SECURITY.md ================================================ # Security Policy WABT is maintained by volunteers on a reasonable-effort basis. If you have discovered a security vulnerability, please open a GitHub issue to report it. In the future, we may move to a system of private reporting of security issues. Please submit your report by filling out [this form](https://github.com/WebAssembly/wabt/issues/new). Please provide the following information in your report: - A description of the vulnerability and its impact - How to reproduce the issue - Which WABT tools or library functions are affected - Which WebAssembly features (`--enable` flags) must be enabled ================================================ FILE: docs/decompiler.md ================================================ # wasm-decompile Decompiles binary wasm modules into a text format that is significantly more compact and familiar (for users of C-style languages). Example: `bin/wasm-decompile test.wasm -o test.dcmp` ## Goals. This tool is aimed at users that want to be able to "read" large volumes of Wasm code such as language, runtime and tool developers, or any programmers that may not have the source code of the generated wasm available, or are trying to understand what the generated code does. The syntax has been designed to be as light-weight and as readable as possible, while still allowing one to see the underlying Wasm constructs clearly. ## Non-goals. Be a programming language. Though compiling this output code back into a wasm module is possible, such functionality is currently not provided. The format is very low-level, much like Wasm itself, so even though it looks more high level than the .wat format, it wouldn't be any more suitable for general purpose programming. ## Language guide. This section shows some aspects of the language in terms of how they map to Wasm and/or how they might differ from a typical C-like language. It does not try to define the actual semantics of Wasm, the reader is expected to already be mostly familiar with that. ### Naming. wasm-decompile, much like wasm2wat, derives names from the name section (preferrably), or linker symbols (if available), or import/export (if not available in the other 2). For things that have no names, names are generated starting from `a`, `b`, `c` and so forth. In addition, prefixes are used for things that are not arguments/locals: `f_` for functions, `g_` for globals, etc. Existing names may be generated "demangled" C++ function signatures, which in the case of functions using STL types may end up several hundred characters long. Besides removing characters not typically part of an identifier, the decompiler also strips common keywords/types from these in an effort to reduce their size. Linker symbols are typically only available in wasm .o files, though if useful for naming can be retained in fully linked wasm modules using the `--emit-reloc` flag to `wasm.ld`. This gives you names for most functions even when `--strip-debug` was used. ### Top level declarations. Top level items may be preceded with `import` or `export`. Memory is declared like `memory m(initial: 1, max: 0);` Globals: `global my_glob:int;` Data: `data d_a(offset: 0) = "Hello, World!";` Functions (see below for instructions that may appear between `{}`): `function f(a:int, b:int):int { return a + b; }` ### Statements and expressions. An expression is generated for any sequence of Wasm instructions that leave exactly 1 value on the stack. For instructions that leave no value values on the stack, a statement is generated, which is an expression that sits on its own line in the context of a control-flow block, or the function itself. A statement may also be generated for expressions that return a value through control flow, such as a branch instruction. Instructions that leave multiple values on the stack, or otherwise do stack operations that break the "expression order", instead force the values to be written to temporary variables (named `t1`, `t2` etc) which the subsequent instructions can then operate upon (this does not happen with MVP-only code). ### Declaration of arguments and locals. Arguments are defined in the function signature, as shown above. Locals are defined upon first use: `var my_local:int = 1;` ### Types. The decompiler uses `int` and `long` for 32-bit and 64-bit integers, and `float` and `double` for 32-bit and 64-bit floating point numbers. Besides these, there are the types `byte` and `ubyte` (8-bit), `short` and `ushort` (16-bit), and `uint`, which are used exclusively with certain load/store operations. ### Loads and stores. These tend to be the hardest to "read" in Wasm code, as they've lost all context of the data structures and types the language that Wasm was compiled from was operating upon. wasm-decompile has a few features to try and make these more readable. The basic form looks like an array indexing operation, so `o[2]:int` says: read element 2 from `o` when seen as an array of ints. This thus accesses 4 bytes at byte-offset 8. `o` is just declared as an `int`, since there is no such thing as a pointer type in Wasm. But wasm-decompile tries to derive them. For example, if the code is doing `o[0]:int = o[1]:int + o[2]:int`, then wasm-decompile assumes `o` points to a struct with 3 ints, and may instead compile this to: var o:{ a:int, b:int, c:int }; o.a = o.b + o.c The `{}` type is a nameless struct declaration (named ones tbd) that hints the reader at what kind of memory layout `o` is accessing. This seems more informative than just uncorrelated indices all over the code. Sadly, optimized output from a compiler like LLVM often reworks memory accesses in such crazy ways that this "struct detection" fails, for example it falls back to indexing operations when there are holes or overlaps in the memory layout, or types are mixed, etc. This happens even more so when locals such as `o` are being re-used for unrelated things in memory. For accesses that are not contiguous, but at least of the same type, the decompiler will change the pointer type from `o:int` to e.g. `o:float_ptr` (and similarly, it will omit the type from the actual access, `o[2]` instead of `o[2]:int`). Additionally, wasm-decompile tried to clean up typical indexing operations. For example, when accessing any array of 32-bit elements, generated Wasm code often looks like `(base + (index << 2))[0]:int`, since Wasm has no built-in way to scale the index by the type of thing being loaded. wasm-decompile then transforms this into just `base[index]:int`, since the scaling of anything between the `[]` by the type size is already implied. ### Control flow. Wasm's if-then maps fairly directly to a C-like `if (c) { 1; } else { 2; }`. Unlike most languages, these if-thens can also be expressions, as shown in this example (wasm-decompile does not currently use the `?:` ternary). Wasm's loop becomes a `loop L { ...; continue L; }` structure. The inclusion of a label means nested loops can continue any of them. Wasm's blocks are little more than a label for forward jumps, and cause excessive amounts of nesting in other text formats such as .wat, so here they are reduced to what they naturally are: a label. This label uses `{}` for denoting a block only when used as an expression, so typically does not indent, and thus doesn't cause endless nesting: if (c) goto L; ... label L: ### Operator precedence. wasm-decompile uses the following operator precedence to reduce the amount of `()` needed in expressions, from high (needs no `()`) to low (always needs `()` when nested): * `()`, `a`, `1`, `a()` * `[]` * `if () {} else {}` * `*`, `/`, `%` * `+`, `-` * `<<`, `>>` * `==`, `!=`, `<`, `>`, `>=`, `<=` * `&`, `|` * `min`, `max` * `=` Only `+` and `*` are associative, i.e. can have multiple of them in sequence without additional `()`. ================================================ FILE: docs/demo/custom.css ================================================ html { font-size: 80%; line-height: 1.3; } * { box-sizing: border-box; } body { font-family: sans-serif; font-size: 1rem; line-height: 1.3125rem; margin: 0; } h1 { font-size: 2.375rem; line-height: 2.625rem; margin-top: 1.3125rem; margin-bottom: 1.3125rem; } h2 { font-size: 1.75rem; line-height: 2.625rem; margin-top: 1.3125rem; margin-bottom: 1.3125rem; } h3 { font-size: 1.3125rem; line-height: 1.3125rem; margin-top: 1.3125rem; margin-bottom: 0rem; } h4 { font-size: 1rem; line-height: 1.3125rem; margin-top: 1.3125rem; margin-bottom: 0rem; } h5 { font-size: 1rem; line-height: 1.3125rem; margin-top: 1.3125rem; margin-bottom: 0rem; } p, ul { padding-left: 0; margin-top: 0rem; margin-bottom: 1.3125rem; } ul ul, ol ol, ul ol, ol ul { margin-top: 0rem; margin-bottom: 0rem; } pre { margin: 0; } .right { float: right; white-space: nowrap; } .hidden { display: none; } #split-grid { position: absolute; height: 100%; left: 0; right: 0; top: 0; } .CodeMirror, .cm-editor, .output { position: absolute; height: calc(100% - 2.625rem); top: 2.625rem; left: 0; right: 0; } .output { padding: 0.3125rem; overflow: auto; } .toolbar { position: absolute; top: 0; right: 0; left: 0; color: #555; background-color: #eee; z-index: 9; height: 2.625rem; line-height: 2rem; padding: 0.3125rem 0.3125rem 0; box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3); } .split-horizontal, .gutter-horizontal { height: 100%; float: left; } .gutter-horizontal { cursor: ew-resize; background-image: url('assets/vertical.png'); } .gutter-vertical { cursor: ns-resize; background-image: url('assets/horizontal.png'); } .gutter { touch-action: none; user-select: none; background-color: #ddd; background-repeat: no-repeat; background-position: 50%; z-index: 0; } .split { position: relative; overflow: hidden; } body { display: flex; min-height: 100vh; flex-direction: column; } main { flex: 1; position: relative; } header { padding: 0 1em; z-index: 10; box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3); } ul { margin: 1em; list-style: none; } #features { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 0.5rem; margin-bottom: 1rem; } .feature-item { display: flex; align-items: center; gap: 4px; } ================================================ FILE: docs/demo/index.html ================================================ wabt demos

wabt demos

================================================ FILE: docs/demo/libwabt.js ================================================ async function WabtModule(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("node:module");var require=createRequire(import.meta.url)}var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("node:fs");if(_scriptName.startsWith("file:")){scriptDirectory=require("node:path").dirname(require("node:url").fileURLToPath(_scriptName))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{if(isFileURI(url)){return new Promise((resolve,reject)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){resolve(xhr.response);return}reject(xhr.status)};xhr.onerror=reject;xhr.send(null)})}var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var isFileURI=filename=>filename.startsWith("file://");var readyPromiseResolve,readyPromiseReject;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["h"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"]){return locateFile("libwabt.wasm")}return new URL("libwabt.wasm",import.meta.url).href}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){var imports={a:wasmImports};return imports}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(inst,mod)=>{resolve(receiveInstance(inst,mod))})})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var noExitRuntime=true;var __abort_js=()=>abort("");var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var ENV={};var getExecutableName=()=>thisProgram||"./this.program";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8";var env={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:lang,_:getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;i++}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var _environ_get=(__environ,environ_buf)=>{var bufSize=0;var envp=0;for(var string of getEnvStrings()){var ptr=environ_buf+bufSize;HEAPU32[__environ+envp>>2]=ptr;bufSize+=stringToUTF8(string,ptr,Infinity)+1;envp+=4}return 0};var lengthBytesUTF8=str=>{var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var _environ_sizes_get=(penviron_count,penviron_buf_size)=>{var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;for(var string of strings){bufSize+=lengthBytesUTF8(string)+1}HEAPU32[penviron_buf_size>>2]=bufSize;return 0};var _fd_close=fd=>52;var UTF8Decoder=new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ToString=(ptr,maxBytesToRead,ignoreNul)=>{if(!ptr)return"";var end=findStringEnd(HEAPU8,ptr,maxBytesToRead,ignoreNul);return UTF8Decoder.decode(HEAPU8.subarray(ptr,end))};var printCharBuffers=[null,[],[]];var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);return UTF8Decoder.decode(heapOrArray.buffer?heapOrArray.subarray(idx,endPtr):new Uint8Array(heapOrArray.slice(idx,endPtr)))};var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer));buffer.length=0}else{buffer.push(curr)}};var _fd_write=(fd,iov,iovcnt,pnum)=>{var num=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;for(var j=0;j>2]=num;return 0};var stringToNewUTF8=str=>{var size=lengthBytesUTF8(str)+1;var ret=_malloc(size);if(ret)stringToUTF8(str,ret,size);return ret};{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}Module["lengthBytesUTF8"]=lengthBytesUTF8;Module["stringToNewUTF8"]=stringToNewUTF8;var _wabt_new_features,_wabt_destroy_features,_wabt_exceptions_enabled,_wabt_set_exceptions_enabled,_wabt_mutable_globals_enabled,_wabt_set_mutable_globals_enabled,_wabt_sat_float_to_int_enabled,_wabt_set_sat_float_to_int_enabled,_wabt_sign_extension_enabled,_wabt_set_sign_extension_enabled,_wabt_simd_enabled,_wabt_set_simd_enabled,_wabt_threads_enabled,_wabt_set_threads_enabled,_wabt_function_references_enabled,_wabt_set_function_references_enabled,_wabt_multi_value_enabled,_wabt_set_multi_value_enabled,_wabt_tail_call_enabled,_wabt_set_tail_call_enabled,_wabt_bulk_memory_enabled,_wabt_set_bulk_memory_enabled,_wabt_reference_types_enabled,_wabt_set_reference_types_enabled,_wabt_annotations_enabled,_wabt_set_annotations_enabled,_wabt_code_metadata_enabled,_wabt_set_code_metadata_enabled,_wabt_gc_enabled,_wabt_set_gc_enabled,_wabt_memory64_enabled,_wabt_set_memory64_enabled,_wabt_multi_memory_enabled,_wabt_set_multi_memory_enabled,_wabt_extended_const_enabled,_wabt_set_extended_const_enabled,_wabt_relaxed_simd_enabled,_wabt_set_relaxed_simd_enabled,_wabt_custom_page_sizes_enabled,_wabt_set_custom_page_sizes_enabled,_wabt_compact_imports_enabled,_wabt_set_compact_imports_enabled,_wabt_wide_arithmetic_enabled,_wabt_set_wide_arithmetic_enabled,_wabt_new_wast_buffer_lexer,_wabt_parse_wat,_wabt_parse_wast,_wabt_read_binary,_wabt_validate_module,_wabt_validate_script,_wabt_write_binary_spec_script,_wabt_apply_names_module,_wabt_generate_names_module,_wabt_write_binary_module,_wabt_write_text_module,_wabt_destroy_module,_wabt_destroy_wast_lexer,_wabt_new_errors,_wabt_format_text_errors,_wabt_format_binary_errors,_wabt_destroy_errors,_wabt_parse_wat_result_get_result,_wabt_parse_wat_result_release_module,_wabt_destroy_parse_wat_result,_wabt_parse_wast_result_get_result,_wabt_parse_wast_result_release_module,_wabt_read_binary_result_get_result,_wabt_read_binary_result_release_module,_wabt_destroy_read_binary_result,_wabt_write_module_result_get_result,_wabt_write_module_result_release_output_buffer,_wabt_write_module_result_release_log_output_buffer,_wabt_destroy_write_module_result,_wabt_output_buffer_get_data,_wabt_output_buffer_get_size,_wabt_destroy_output_buffer,_free,_malloc,memory,__indirect_function_table,wasmMemory;function assignWasmExports(wasmExports){_wabt_new_features=Module["_wabt_new_features"]=wasmExports["i"];_wabt_destroy_features=Module["_wabt_destroy_features"]=wasmExports["j"];_wabt_exceptions_enabled=Module["_wabt_exceptions_enabled"]=wasmExports["k"];_wabt_set_exceptions_enabled=Module["_wabt_set_exceptions_enabled"]=wasmExports["l"];_wabt_mutable_globals_enabled=Module["_wabt_mutable_globals_enabled"]=wasmExports["m"];_wabt_set_mutable_globals_enabled=Module["_wabt_set_mutable_globals_enabled"]=wasmExports["n"];_wabt_sat_float_to_int_enabled=Module["_wabt_sat_float_to_int_enabled"]=wasmExports["o"];_wabt_set_sat_float_to_int_enabled=Module["_wabt_set_sat_float_to_int_enabled"]=wasmExports["p"];_wabt_sign_extension_enabled=Module["_wabt_sign_extension_enabled"]=wasmExports["q"];_wabt_set_sign_extension_enabled=Module["_wabt_set_sign_extension_enabled"]=wasmExports["r"];_wabt_simd_enabled=Module["_wabt_simd_enabled"]=wasmExports["s"];_wabt_set_simd_enabled=Module["_wabt_set_simd_enabled"]=wasmExports["t"];_wabt_threads_enabled=Module["_wabt_threads_enabled"]=wasmExports["u"];_wabt_set_threads_enabled=Module["_wabt_set_threads_enabled"]=wasmExports["v"];_wabt_function_references_enabled=Module["_wabt_function_references_enabled"]=wasmExports["w"];_wabt_set_function_references_enabled=Module["_wabt_set_function_references_enabled"]=wasmExports["x"];_wabt_multi_value_enabled=Module["_wabt_multi_value_enabled"]=wasmExports["y"];_wabt_set_multi_value_enabled=Module["_wabt_set_multi_value_enabled"]=wasmExports["z"];_wabt_tail_call_enabled=Module["_wabt_tail_call_enabled"]=wasmExports["A"];_wabt_set_tail_call_enabled=Module["_wabt_set_tail_call_enabled"]=wasmExports["B"];_wabt_bulk_memory_enabled=Module["_wabt_bulk_memory_enabled"]=wasmExports["C"];_wabt_set_bulk_memory_enabled=Module["_wabt_set_bulk_memory_enabled"]=wasmExports["D"];_wabt_reference_types_enabled=Module["_wabt_reference_types_enabled"]=wasmExports["E"];_wabt_set_reference_types_enabled=Module["_wabt_set_reference_types_enabled"]=wasmExports["F"];_wabt_annotations_enabled=Module["_wabt_annotations_enabled"]=wasmExports["G"];_wabt_set_annotations_enabled=Module["_wabt_set_annotations_enabled"]=wasmExports["H"];_wabt_code_metadata_enabled=Module["_wabt_code_metadata_enabled"]=wasmExports["I"];_wabt_set_code_metadata_enabled=Module["_wabt_set_code_metadata_enabled"]=wasmExports["J"];_wabt_gc_enabled=Module["_wabt_gc_enabled"]=wasmExports["K"];_wabt_set_gc_enabled=Module["_wabt_set_gc_enabled"]=wasmExports["L"];_wabt_memory64_enabled=Module["_wabt_memory64_enabled"]=wasmExports["M"];_wabt_set_memory64_enabled=Module["_wabt_set_memory64_enabled"]=wasmExports["N"];_wabt_multi_memory_enabled=Module["_wabt_multi_memory_enabled"]=wasmExports["O"];_wabt_set_multi_memory_enabled=Module["_wabt_set_multi_memory_enabled"]=wasmExports["P"];_wabt_extended_const_enabled=Module["_wabt_extended_const_enabled"]=wasmExports["Q"];_wabt_set_extended_const_enabled=Module["_wabt_set_extended_const_enabled"]=wasmExports["R"];_wabt_relaxed_simd_enabled=Module["_wabt_relaxed_simd_enabled"]=wasmExports["S"];_wabt_set_relaxed_simd_enabled=Module["_wabt_set_relaxed_simd_enabled"]=wasmExports["T"];_wabt_custom_page_sizes_enabled=Module["_wabt_custom_page_sizes_enabled"]=wasmExports["U"];_wabt_set_custom_page_sizes_enabled=Module["_wabt_set_custom_page_sizes_enabled"]=wasmExports["V"];_wabt_compact_imports_enabled=Module["_wabt_compact_imports_enabled"]=wasmExports["W"];_wabt_set_compact_imports_enabled=Module["_wabt_set_compact_imports_enabled"]=wasmExports["X"];_wabt_wide_arithmetic_enabled=Module["_wabt_wide_arithmetic_enabled"]=wasmExports["Y"];_wabt_set_wide_arithmetic_enabled=Module["_wabt_set_wide_arithmetic_enabled"]=wasmExports["Z"];_wabt_new_wast_buffer_lexer=Module["_wabt_new_wast_buffer_lexer"]=wasmExports["_"];_wabt_parse_wat=Module["_wabt_parse_wat"]=wasmExports["$"];_wabt_parse_wast=Module["_wabt_parse_wast"]=wasmExports["aa"];_wabt_read_binary=Module["_wabt_read_binary"]=wasmExports["ba"];_wabt_validate_module=Module["_wabt_validate_module"]=wasmExports["ca"];_wabt_validate_script=Module["_wabt_validate_script"]=wasmExports["da"];_wabt_write_binary_spec_script=Module["_wabt_write_binary_spec_script"]=wasmExports["ea"];_wabt_apply_names_module=Module["_wabt_apply_names_module"]=wasmExports["fa"];_wabt_generate_names_module=Module["_wabt_generate_names_module"]=wasmExports["ga"];_wabt_write_binary_module=Module["_wabt_write_binary_module"]=wasmExports["ha"];_wabt_write_text_module=Module["_wabt_write_text_module"]=wasmExports["ia"];_wabt_destroy_module=Module["_wabt_destroy_module"]=wasmExports["ja"];_wabt_destroy_wast_lexer=Module["_wabt_destroy_wast_lexer"]=wasmExports["ka"];_wabt_new_errors=Module["_wabt_new_errors"]=wasmExports["la"];_wabt_format_text_errors=Module["_wabt_format_text_errors"]=wasmExports["ma"];_wabt_format_binary_errors=Module["_wabt_format_binary_errors"]=wasmExports["na"];_wabt_destroy_errors=Module["_wabt_destroy_errors"]=wasmExports["oa"];_wabt_parse_wat_result_get_result=Module["_wabt_parse_wat_result_get_result"]=wasmExports["pa"];_wabt_parse_wat_result_release_module=Module["_wabt_parse_wat_result_release_module"]=wasmExports["qa"];_wabt_destroy_parse_wat_result=Module["_wabt_destroy_parse_wat_result"]=wasmExports["ra"];_wabt_parse_wast_result_get_result=Module["_wabt_parse_wast_result_get_result"]=wasmExports["sa"];_wabt_parse_wast_result_release_module=Module["_wabt_parse_wast_result_release_module"]=wasmExports["ta"];_wabt_read_binary_result_get_result=Module["_wabt_read_binary_result_get_result"]=wasmExports["ua"];_wabt_read_binary_result_release_module=Module["_wabt_read_binary_result_release_module"]=wasmExports["va"];_wabt_destroy_read_binary_result=Module["_wabt_destroy_read_binary_result"]=wasmExports["wa"];_wabt_write_module_result_get_result=Module["_wabt_write_module_result_get_result"]=wasmExports["xa"];_wabt_write_module_result_release_output_buffer=Module["_wabt_write_module_result_release_output_buffer"]=wasmExports["ya"];_wabt_write_module_result_release_log_output_buffer=Module["_wabt_write_module_result_release_log_output_buffer"]=wasmExports["za"];_wabt_destroy_write_module_result=Module["_wabt_destroy_write_module_result"]=wasmExports["Aa"];_wabt_output_buffer_get_data=Module["_wabt_output_buffer_get_data"]=wasmExports["Ba"];_wabt_output_buffer_get_size=Module["_wabt_output_buffer_get_size"]=wasmExports["Ca"];_wabt_destroy_output_buffer=Module["_wabt_destroy_output_buffer"]=wasmExports["Da"];_free=Module["_free"]=wasmExports["Ea"];_malloc=Module["_malloc"]=wasmExports["Fa"];memory=wasmMemory=wasmExports["g"];__indirect_function_table=wasmExports["__indirect_function_table"]}var wasmImports={f:__abort_js,b:_emscripten_resize_heap,c:_environ_get,d:_environ_sizes_get,e:_fd_close,a:_fd_write};function run(){preRun();function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}var wasmExports;wasmExports=await (createWasm());run();const WABT_OK=0;const FEATURES=Object.freeze({exceptions:false,mutable_globals:true,sat_float_to_int:true,sign_extension:true,simd:true,threads:false,function_references:false,multi_value:true,tail_call:false,bulk_memory:true,reference_types:true,annotations:false,code_metadata:false,gc:false,memory64:false,multi_memory:false,extended_const:false,relaxed_simd:false,custom_page_sizes:false,compact_imports:false,wide_arithmetic:false});function malloc(size){const addr=Module._malloc(size);if(addr==0){throw new Error("out of memory")}return addr}function allocateBuffer(buf){let addr;let size;if(buf instanceof ArrayBuffer){size=buf.byteLength;addr=malloc(size);new Uint8Array(HEAPU8.buffer,addr,size).set(new Uint8Array(buf))}else if(ArrayBuffer.isView(buf)){size=buf.byteLength;addr=malloc(size);new Uint8Array(HEAPU8.buffer,addr,size).set(new Uint8Array(buf.buffer,buf.byteOffset,buf.byteLength))}else if(typeof buf=="string"){addr=stringToNewUTF8(buf);size=lengthBytesUTF8(buf)}else{throw new Error("unknown buffer type: "+buf)}return{addr,size}}class Features{constructor(obj={}){this.addr=Module._wabt_new_features();for(const[f,v]of Object.entries(FEATURES)){this[f]=obj[f]??v}}destroy(){Module._wabt_destroy_features(this.addr)}}Object.keys(FEATURES).forEach(function(feature){Object.defineProperty(Features.prototype,feature,{enumerable:true,get:function(){return Module["_wabt_"+feature+"_enabled"](this.addr)},set:function(newValue){Module["_wabt_set_"+feature+"_enabled"](this.addr,newValue|0)}})});class Lexer{constructor(filename,buffer,errors){this.filename=stringToNewUTF8(filename);this.bufferObj=allocateBuffer(buffer);this.addr=Module._wabt_new_wast_buffer_lexer(this.filename,this.bufferObj.addr,this.bufferObj.size,errors.addr)}destroy(){Module._wabt_destroy_wast_lexer(this.addr);Module._free(this.bufferObj.addr);Module._free(this.filename)}}class OutputBuffer{constructor(addr){this.addr=addr}toTypedArray(){if(!this.addr){return null}const addr=Module._wabt_output_buffer_get_data(this.addr);const size=Module._wabt_output_buffer_get_size(this.addr);const buffer=new Uint8Array(size);buffer.set(new Uint8Array(HEAPU8.buffer,addr,size));return buffer}toString(){if(!this.addr){return""}const addr=Module._wabt_output_buffer_get_data(this.addr);const size=Module._wabt_output_buffer_get_size(this.addr);return UTF8ToString(addr,size)}destroy(){Module._wabt_destroy_output_buffer(this.addr)}}class Errors{constructor(kind){this.kind=kind;this.addr=Module._wabt_new_errors()}format(lexer=null){let buffer;switch(this.kind){case"text":buffer=new OutputBuffer(Module._wabt_format_text_errors(this.addr,lexer.addr));break;case"binary":buffer=new OutputBuffer(Module._wabt_format_binary_errors(this.addr));break;default:throw new Error(`Invalid Errors kind: ${this.kind}`)}const message=buffer.toString();buffer.destroy();return message}destroy(){Module._wabt_destroy_errors(this.addr)}}function parseWat(filename,buffer,options){let errors=new Errors("text");let lexer=new Lexer(filename,buffer,errors);const features=new Features(options||{});let parseResult_addr;try{parseResult_addr=Module._wabt_parse_wat(lexer.addr,features.addr,errors.addr);const result=Module._wabt_parse_wat_result_get_result(parseResult_addr);if(result!==WABT_OK){throw new Error("parseWat failed:\n"+errors.format(lexer))}const module_addr=Module._wabt_parse_wat_result_release_module(parseResult_addr);const wasmModule=new WasmModule(module_addr,errors,lexer);errors=null;lexer=null;return wasmModule}finally{Module._wabt_destroy_parse_wat_result(parseResult_addr);features.destroy();if(errors){errors.destroy()}if(lexer){lexer.destroy()}}}function readWasm(buffer,options={}){const bufferObj=allocateBuffer(buffer);let errors=new Errors("binary");const readDebugNames=options.readDebugNames??false;const check=options.check??true;const features=new Features(options);let readBinaryResult_addr;try{readBinaryResult_addr=Module._wabt_read_binary(bufferObj.addr,bufferObj.size,readDebugNames,features.addr,errors.addr);const result=Module._wabt_read_binary_result_get_result(readBinaryResult_addr);if(check&&result!==WABT_OK){throw new Error("readWasm failed:\n"+errors.format())}const module_addr=Module._wabt_read_binary_result_release_module(readBinaryResult_addr);const wasmModule=new WasmModule(module_addr,errors);errors=null;return wasmModule}finally{Module._wabt_destroy_read_binary_result(readBinaryResult_addr);features.destroy();if(errors){errors.destroy()}Module._free(bufferObj.addr)}}class WasmModule{constructor(module_addr,errors,lexer=null){this.module_addr=module_addr;this.errors=errors;this.lexer=lexer}validate(options){const features=new Features(options||{});try{const result=Module._wabt_validate_module(this.module_addr,features.addr,this.errors.addr);if(result!==WABT_OK){throw new Error("validate failed:\n"+this.errors.format(this.lexer))}}finally{features.destroy()}}generateNames(){const result=Module._wabt_generate_names_module(this.module_addr);if(result!==WABT_OK){throw new Error("generateNames failed.")}}applyNames(){const result=Module._wabt_apply_names_module(this.module_addr);if(result!==WABT_OK){throw new Error("applyNames failed.")}}toText(options={}){const foldExprs=options.foldExprs??false;const inlineExport=options.inlineExport??false;const writeModuleResult_addr=Module._wabt_write_text_module(this.module_addr,foldExprs,inlineExport);const result=Module._wabt_write_module_result_get_result(writeModuleResult_addr);let outputBuffer;try{if(result!==WABT_OK){throw new Error("toText failed.")}outputBuffer=new OutputBuffer(Module._wabt_write_module_result_release_output_buffer(writeModuleResult_addr));return outputBuffer.toString()}finally{if(outputBuffer){outputBuffer.destroy()}Module._wabt_destroy_write_module_result(writeModuleResult_addr)}}toBinary(options={}){const log=options.log??false;const canonicalize_lebs=options.canonicalize_lebs??true;const relocatable=options.relocatable??false;const write_debug_names=options.write_debug_names??false;const writeModuleResult_addr=Module._wabt_write_binary_module(this.module_addr,log,canonicalize_lebs,relocatable,write_debug_names);const result=Module._wabt_write_module_result_get_result(writeModuleResult_addr);let binaryOutputBuffer;let logOutputBuffer;try{if(result!==WABT_OK){throw new Error("toBinary failed.")}binaryOutputBuffer=new OutputBuffer(Module._wabt_write_module_result_release_output_buffer(writeModuleResult_addr));logOutputBuffer=new OutputBuffer(Module._wabt_write_module_result_release_log_output_buffer(writeModuleResult_addr));return{buffer:binaryOutputBuffer.toTypedArray(),log:logOutputBuffer.toString()}}finally{if(binaryOutputBuffer){binaryOutputBuffer.destroy()}if(logOutputBuffer){logOutputBuffer.destroy()}Module._wabt_destroy_write_module_result(writeModuleResult_addr)}}destroy(){Module._wabt_destroy_module(this.module_addr);if(this.errors){this.errors.destroy()}if(this.lexer){this.lexer.destroy()}}}Module["parseWat"]=parseWat;Module["readWasm"]=readWasm;Module["FEATURES"]=FEATURES;if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})} ;return moduleRtn}export default WabtModule; ================================================ FILE: docs/demo/share.js ================================================ /* * Copyright 2026 WebAssembly Community Group participants * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ export function getLocalStorageFeatures() { try { return JSON.parse(localStorage && localStorage.getItem('features')) || {}; } catch (e) { console.log(e); return {}; } } export function saveLocalStorageFeatures(features) { if (localStorage) { localStorage.setItem('features', JSON.stringify(features)); } } export function renderFeatures(wabt, features, onChange) { const featuresEl = document.getElementById('features'); const featuresList = Object.entries(wabt.FEATURES).sort(([a], [b]) => a.localeCompare(b)); for (const [f, v] of featuresList) { const featureEl = document.createElement('input'); featureEl.type = 'checkbox'; featureEl.id = f; const isChecked = !!(features[f] !== undefined ? features[f] : v); featureEl.checked = isChecked; features[f] = isChecked; featureEl.addEventListener('change', event => { features[event.target.id] = event.target.checked; if (onChange) { onChange(); } }); const labelEl = document.createElement('label'); labelEl.htmlFor = f; labelEl.textContent = f.replace(/_/g, ' '); const itemEl = document.createElement('div'); itemEl.className = 'feature-item'; itemEl.appendChild(featureEl); itemEl.appendChild(labelEl); featuresEl.appendChild(itemEl); } } ================================================ FILE: docs/demo/third_party/.gitignore ================================================ node_modules ================================================ FILE: docs/demo/third_party/README.md ================================================ # WABT Demo Third-Party Dependencies This directory contains the build configuration for third-party dependencies used by the WABT web demos (located in `docs/demo`). Currently, this is used to generate a single ES Module bundle for **CodeMirror 6**, which is required because CodeMirror 6 consists of many highly-scoped NPM packages that are difficult to load individually via CDNs in a browser without instance-duplication issues. ## Building the Third-Party Bundle The demo applications (`wasm2wat/index.html` and `wat2wasm/index.html`) expect to find a compiled bundle at `docs/demo/third_party.bundle.js`. To regenerate this bundle: 1. Ensure you have [Node.js and npm](https://nodejs.org/) installed. 2. From this directory (`docs/demo/third_party`), execute: ```bash npm install npm run build ``` The `build` script uses `esbuild` to analyze `index.js`, tree-shake the used modules (like `EditorView`, `wast` syntax highlighting, and `javascript` support), and output the final ES Module bundle as `../third_party.bundle.js`. ## Adding or Updating Dependencies 1. If you need to expose new CodeMirror features to the demo apps, add the relevant `export` statement to `index.js`. 2. To update versions of CodeMirror, run `npm update` or manually adjust `package.json` and run `npm install`. 3. Commit both the updated `package.json`/`package-lock.json` and the built `../third_party.bundle.js`. ================================================ FILE: docs/demo/third_party/index.js ================================================ /* * Copyright 2026 WebAssembly Community Group participants * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ export {javascript} from '@codemirror/lang-javascript'; export {StreamLanguage} from '@codemirror/language'; export {wast} from '@codemirror/legacy-modes/mode/wast'; export {EditorState} from '@codemirror/state'; export {basicSetup, EditorView} from 'codemirror'; export {default as Split} from 'split.js'; ================================================ FILE: docs/demo/third_party/package.json ================================================ { "name": "third_party", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "build": "esbuild index.js --bundle --format=esm --minify --sourcemap --outfile=../third_party.bundle.js" }, "keywords": [], "author": "", "license": "ISC", "type": "commonjs", "dependencies": { "@codemirror/commands": "^6.10.3", "@codemirror/lang-javascript": "^6.2.5", "@codemirror/language": "^6.12.2", "@codemirror/legacy-modes": "^6.5.2", "@codemirror/state": "^6.6.0", "@codemirror/view": "^6.40.0", "codemirror": "^6.0.2", "esbuild": "^0.27.4", "split.js": "^1.6.5" } } ================================================ FILE: docs/demo/third_party.bundle.js ================================================ var cp=0,Ui=class{constructor(e,t){this.from=e,this.to=t}},z=class{constructor(e={}){this.id=cp++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=pe.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};z.closedBy=new z({deserialize:n=>n.split(" ")});z.openedBy=new z({deserialize:n=>n.split(" ")});z.group=new z({deserialize:n=>n.split(" ")});z.isolate=new z({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});z.contextHash=new z({perNode:!0});z.lookAhead=new z({perNode:!0});z.mounted=new z({perNode:!0});var Nt=class{constructor(e,t,i,s=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=s}static get(e){return e&&e.props&&e.props[z.mounted.id]}},fp=Object.create(null),pe=class n{constructor(e,t,i,s=0){this.name=e,this.props=t,this.id=i,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):fp,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new n(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(z.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let s of i.split(" "))t[s]=e[i];return i=>{for(let s=i.prop(z.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?i.name:s[r]];if(o)return o}}}};pe.none=new pe("",Object.create(null),0,8);var xi=class n{constructor(e){this.types=e;for(let t=0;t0;for(let a=this.cursor(o|J.IncludeAnonymous);;){let h=!1;if(a.from<=r&&a.to>=s&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Ur(pe.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,s)=>new n(this.type,t,i,s,this.propValues),e.makeTree||((t,i,s)=>new n(pe.none,t,i,s)))}static build(e){return dp(e)}};U.empty=new U(pe.none,[],[],0);var Ir=class n{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new n(this.buffer,this.index)}},Zt=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return pe.none}toString(){let e=[];for(let t=0;t0));a=o[a+3]);return l}slice(e,t,i){let s=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Fi(n,e,t,i){for(var s;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from,u;if(!(!(r&J.EnterBracketed&&c instanceof U&&(u=Nt.get(c))&&!u.overlay&&u.bracketed&&i>=f&&i<=f+c.length)&&!sh(s,i,f,f+c.length))){if(c instanceof Zt){if(r&J.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,t,i-f,s);if(d>-1)return new Gt(new Vr(o,c,e,f),null,d)}else if(r&J.IncludeAnonymous||!c.type.isAnonymous||Gr(c)){let d;if(!(r&J.IgnoreMounts)&&(d=Nt.get(c))&&!d.overlay)return new n(d.tree,f,e,o);let p=new n(c,f,e,o);return r&J.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,s,r)}}}if(r&J.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let s;if(!(i&J.IgnoreOverlays)&&(s=Nt.get(this._tree))&&s.overlay){let r=e-this.from,o=i&J.EnterBracketed&&s.bracketed;for(let{from:l,to:a}of s.overlay)if((t>0||o?l<=r:l=r:a>r))return new n(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function ih(n,e,t,i){let s=n.cursor(),r=[];if(!s.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=s.type.is(t),!s.nextSibling())return r}for(;;){if(i!=null&&s.type.is(i))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return i==null?r:[]}}function qr(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var Vr=class{constructor(e,t,i,s){this.parent=e,this.buffer=t,this.index=i,this.start=s}},Gt=class n extends Hn{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new n(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&J.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new n(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new n(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new n(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,s=this.index+4,r=i.buffer[this.index+3];if(r>s){let o=i.buffer[this.index+1];e.push(i.slice(s,r,o)),t.push(0)}return new U(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function rh(n){if(!n.length)return null;let e=0,t=n[0];for(let r=1;rt.from||o.to=e){let l=new Ne(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[i])).push(Fi(l,e,t,!1))}}return s?rh(s):i}var Hi=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~J.EnterBracketed,e instanceof Ne)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=i+s.buffer[e+1],this.to=i+s.buffer[e+2],!0}yield(e){return e?e instanceof Ne?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&J.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&J.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&J.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(s)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let r=t+e,o=e<0?-1:i._tree.children.length;r!=o;r+=e){let l=i._tree.children[r];if(this.mode&J.IncludeAnonymous||l instanceof Zt||!l.type.isAnonymous||Gr(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;t=o,i=r+1;break e}s=this.stack[--r]}for(let s=i;s=0;r--){if(r<0)return qr(this._tree,e,s);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}};function Gr(n){return n.children.some(e=>e instanceof Zt||!e.type.isAnonymous||Gr(e))}function dp(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:s=1024,reused:r=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new Ir(t,t.length):t,a=i.types,h=0,c=0;function f(w,v,Q,D,W,G){let{id:_,start:X,end:Y,size:q}=l,j=c,fe=h;if(q<0)if(l.next(),q==-1){let Ve=r[_];Q.push(Ve),D.push(X-w);return}else if(q==-3){h=_;return}else if(q==-4){c=_;return}else throw new RangeError(`Unrecognized record size: ${q}`);let ye=a[_],qe,oe,Te=X-w;if(Y-X<=s&&(oe=m(l.pos-v,W))){let Ve=new Uint16Array(oe.size-oe.skip),Ce=l.pos-oe.size,je=Ve.length;for(;l.pos>Ce;)je=g(oe.start,Ve,je);qe=new Zt(Ve,Y-oe.start,i),Te=oe.start-w}else{let Ve=l.pos-q;l.next();let Ce=[],je=[],ke=_>=o?_:-1,bt=0,yi=Y;for(;l.pos>Ve;)ke>=0&&l.id==ke&&l.size>=0?(l.end<=yi-s&&(p(Ce,je,X,bt,l.end,yi,ke,j,fe),bt=Ce.length,yi=l.end),l.next()):G>2500?u(X,Ve,Ce,je):f(X,Ve,Ce,je,ke,G+1);if(ke>=0&&bt>0&&bt-1&&bt>0){let jn=d(ye,fe);qe=Ur(ye,Ce,je,0,Ce.length,0,Y-X,jn,jn)}else qe=O(ye,Ce,je,Y-X,j-Y,fe)}Q.push(qe),D.push(Te)}function u(w,v,Q,D){let W=[],G=0,_=-1;for(;l.pos>v;){let{id:X,start:Y,end:q,size:j}=l;if(j>4)l.next();else{if(_>-1&&Y<_)break;_<0&&(_=q-s),W.push(X,Y,q),G++,l.next()}}if(G){let X=new Uint16Array(G*4),Y=W[W.length-2];for(let q=W.length-3,j=0;q>=0;q-=3)X[j++]=W[q],X[j++]=W[q+1]-Y,X[j++]=W[q+2]-Y,X[j++]=j;Q.push(new Zt(X,W[2]-Y,i)),D.push(Y-w)}}function d(w,v){return(Q,D,W)=>{let G=0,_=Q.length-1,X,Y;if(_>=0&&(X=Q[_])instanceof U){if(!_&&X.type==w&&X.length==W)return X;(Y=X.prop(z.lookAhead))&&(G=D[_]+X.length+Y)}return O(w,Q,D,W,G,v)}}function p(w,v,Q,D,W,G,_,X,Y){let q=[],j=[];for(;w.length>D;)q.push(w.pop()),j.push(v.pop()+Q-W);w.push(O(i.types[_],q,j,G-W,X-G,Y)),v.push(W-Q)}function O(w,v,Q,D,W,G,_){if(G){let X=[z.contextHash,G];_=_?[X].concat(_):[X]}if(W>25){let X=[z.lookAhead,W];_=_?[X].concat(_):[X]}return new U(w,v,Q,D,_)}function m(w,v){let Q=l.fork(),D=0,W=0,G=0,_=Q.end-s,X={size:0,start:0,skip:0};e:for(let Y=Q.pos-w;Q.pos>Y;){let q=Q.size;if(Q.id==v&&q>=0){X.size=D,X.start=W,X.skip=G,G+=4,D+=4,Q.next();continue}let j=Q.pos-q;if(q<0||j=o?4:0,ye=Q.start;for(Q.next();Q.pos>j;){if(Q.size<0)if(Q.size==-3||Q.size==-4)fe+=4;else break e;else Q.id>=o&&(fe+=4);Q.next()}W=ye,D+=q,G+=fe}return(v<0||D==w)&&(X.size=D,X.start=W,X.skip=G),X.size>4?X:void 0}function g(w,v,Q){let{id:D,start:W,end:G,size:_}=l;if(l.next(),_>=0&&D4){let Y=l.pos-(_-4);for(;l.pos>Y;)Q=g(w,v,Q)}v[--Q]=X,v[--Q]=G-w,v[--Q]=W-w,v[--Q]=D}else _==-3?h=D:_==-4&&(c=D);return Q}let S=[],b=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,S,b,-1,0);let A=(e=n.length)!==null&&e!==void 0?e:S.length?b[0]+S[0].length:0;return new U(a[n.topID],S.reverse(),b.reverse(),A)}var nh=new WeakMap;function Fn(n,e){if(!n.isAnonymous||e instanceof Zt||e.type!=n)return 1;let t=nh.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof U)){t=1;break}t+=Fn(n,i)}nh.set(e,t)}return t}function Ur(n,e,t,i,s,r,o,l,a){let h=0;for(let p=i;p=c)break;v+=Q}if(b==A+1){if(v>c){let Q=p[A];d(Q.children,Q.positions,0,Q.children.length,O[A]+S);continue}f.push(p[A])}else{let Q=O[b-1]+p[b-1].length-w;f.push(Ur(n,p,O,A,b,w,Q,null,a))}u.push(w+S-r)}}return d(e,t,i,s,0),(l||a)(f,u,o)}var Kn=class{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let s=this.map.get(e);s||this.map.set(e,s=new Map),s.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof Gt?this.setBuffer(e.context.buffer,e.index,t):e instanceof Ne&&this.map.set(e.tree,t)}get(e){return e instanceof Gt?this.getBuffer(e.context.buffer,e.index):e instanceof Ne?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},Ut=class n{constructor(e,t,i,s,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let s=[new n(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&s.push(r);return s}static applyChanges(e,t,i=128){if(!t.length)return e;let s=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l=i)for(;o&&o.from=u.from||f<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,f)-h;u=d>=p?null:new n(d,p,u.tree,u.offset+h,l>0,!!c)}if(u&&s.push(u),o.to>f)break;o=rnew Ui(s.from,s.to)):[new Ui(0,0)]:[new Ui(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let s=this.startParse(e,t,i);for(;;){let r=s.advance();if(r)return r}}},Nr=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var sx=new z({perNode:!0});var Kr=class n{constructor(e,t,i,s,r,o,l,a,h,c=0,f){this.p=e,this.stack=t,this.state=i,this.reducePos=s,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=h,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let s=e.parser.context;return new n(e,[],t,i,i,0,[],0,s?new Jn(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,s=e&65535,{parser:r}=this.p,o=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(s,h)}storeNode(e,t,i,s=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(t==i)return;if(o.buffer[l-2]>=t){o.buffer[l-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(e,t,i,s);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>i;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=s}}shift(e,t,i,s){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let r=e,{parser:o}=this.p;this.pos=s;let l=o.stateFlag(r,1);!l&&(s>i||t<=o.maxNode)&&(this.reducePos=s),this.pushState(r,l?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,s,4)}else this.pos=s,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,s,4)}apply(e,t,i,s){e&65536?this.reduce(e):this.shift(e,t,i,s)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(i,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new n(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Jr(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let s=[];for(let r=0,o;ra&1&&l==o)||s.push(t[r],o)}t=s}let i=[];for(let s=0;s>19,s=t&65535,r=this.stack.length-i*3;if(r<0||e.getGoto(this.stack[r],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(s,r)=>{if(!t.includes(s))return t.push(s),e.allActions(s,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-r;if(l>1){let a=o&65535,h=this.stack.length-l*3;if(h>=0&&e.getGoto(this.stack[h],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,r+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t0&&this.emitLookAhead()}},Jn=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},Jr=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}},eo=class n{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new n(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new n(this.stack,this.pos,this.index)}};function Ki(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,s=0;i=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}t?t[s++]=r:t=new e(r)}return t}var bi=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},oh=new bi,to=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=oh,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,s=this.rangeIndex,r=this.pos+e;for(;ri.to:r>=i.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-i.to,i=o}return r}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,s;if(t>=0&&t=this.chunk2Pos&&il.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=oh,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let s of this.ranges){if(s.from>=t)break;s.to>e&&(i+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return i}},At=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;fh(this.data,e,t,this.id,i.data,i.tokenPrecTable)}};At.prototype.contextual=At.prototype.fallback=At.prototype.extend=!1;var Si=class{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?Ki(e):e}token(e,t){let i=e.pos,s=0;for(;;){let r=e.next<0,o=e.resolveOffset(1,1);if(fh(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(r||s++,o==null)break;e.reset(o,e.token)}s&&(e.reset(i,e.token),e.acceptToken(this.elseToken,s))}};Si.prototype.contextual=At.prototype.fallback=At.prototype.extend=!1;var Mt=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function fh(n,e,t,i,s,r){let o=0,l=1<0){let p=n[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||Op(p,e.token.value,s,r))){e.acceptToken(p);break}}let c=e.next,f=0,u=n[o+2];if(e.next<0&&u>f&&n[h+u*3-3]==65535){o=n[h+u*3-1];continue e}for(;f>1,p=h+d+(d<<1),O=n[p],m=n[p+1]||65536;if(c=m)f=d+1;else{o=n[p+2],e.advance();continue e}}break}}function lh(n,e,t){for(let i=e,s;(s=n[i])!=65535;i++)if(s==t)return i-e;return-1}function Op(n,e,t,i){let s=lh(t,i,e);return s<0||lh(t,i,n)e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}var io=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?ah(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?ah(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(r instanceof U){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}},no=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new bi)}getActions(e){let t=0,i=null,{parser:s}=e.p,{tokenizers:r}=s,o=s.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let h=0;hf.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let u=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!c.extend&&(i=f,t>u))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!i&&e.pos==this.stream.end&&(i=new bi,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new bi,{pos:i,p:s}=e;return t.start=i,t.end=Math.min(i+1,s.stream.end),t.value=i==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,i){let s=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(s,e),i),e.value>-1){let{parser:r}=i.p;for(let o=0;o=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(s+1)}putAction(e,t,i,s){for(let r=0;re.bufferLength*4?new io(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],s,r;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;ot)i.push(l);else{if(this.advanceStack(l,i,e))continue;{s||(s=[],r=[]),s.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!i.length){let o=s&&mp(s);if(o)return Ee&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Ee&&s&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,i);if(o)return Ee&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o500&&h.buffer.length>500)if((l.score-h.score||l.buffer.length-h.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,c=h?e.curContext.hash:0;for(let f=this.fragments.nodeAt(s);f;){let u=this.parser.nodeSet.types[f.type.id]==f.type?r.getGoto(e.state,f.type.id):-1;if(u>-1&&f.length&&(!h||(f.prop(z.contextHash)||0)==c))return e.useNode(f,u),Ee&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(f.type.id)})`),!0;if(!(f instanceof U)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof U&&f.positions[0]==0)f=d;else break}}let l=r.stateSlot(e.state,4);if(l>0)return e.reduce(l),Ee&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let h=0;hs?t.push(p):i.push(p)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return hh(e,t),!0}}runRecovery(e,t,i){let s=null,r=!1;for(let o=0;o ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),Ee&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let f=l.split(),u=c;for(let d=0;d<10&&f.forceReduce()&&(Ee&&console.log(u+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)Ee&&(u=this.stackID(f)+" -> ");for(let d of l.recoverByInsert(a))Ee&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(h==l.pos&&(h++,a=0),l.recoverByDelete(a,h),Ee&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),hh(l,i)):(!s||s.scoren,es=class{constructor(e){this.start=e.start,this.shift=e.shift||Hr,this.reduce=e.reduce||Hr,this.reuse=e.reuse||Hr,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},ts=class n extends Ft{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;le.topRules[l][1]),s=[];for(let l=0;l=0)r(c,a,l[h++]);else{let f=l[h+-c];for(let u=-c;u>0;u--)r(l[h++],a,f);h++}}}this.nodeSet=new xi(t.map((l,a)=>pe.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:s[a],top:i.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let o=Ki(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new At(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let s=new so(this,e,t,i);for(let r of this.wrappers)s=r(s,e,t,i);return s}getGoto(e,t,i=!1){let s=this.goto;if(t>=s[0])return-1;for(let r=s[t+1];;){let o=s[r++],l=o&1,a=s[r++];if(l&&i)return a;for(let h=r+(o>>1);r0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),s=i?t(i):void 0;for(let r=this.stateSlot(e,1);s==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=St(this.data,r+2);else break;s=t(St(this.data,r+1))}return s}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=St(this.data,i+2);else break;if((this.data[i+2]&1)==0){let s=this.data[i+1];t.some((r,o)=>o&1&&r==s)||t.push(this.data[i],s)}}return t}configure(e){let t=Object.assign(Object.create(n.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let s=e.tokenizers.find(r=>r.from==i);return s?s.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,s)=>{let r=e.specializers.find(l=>l.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return t.specializers[s]=ch(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let r of e.split(" ")){let o=t.indexOf(r);o>=0&&(i[o]=!0)}let s=null;for(let r=0;ri)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}var gp=0,nt=class n{constructor(e,t,i,s){this.name=e,this.set=t,this.base=i,this.modified=s,this.id=gp++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof n&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let s=new n(i,[],null,[]);if(s.set.push(s),t)for(let r of t.set)s.set.push(r);return s}static defineModifier(e){let t=new rs(e);return i=>i.modified.indexOf(t)>-1?i:rs.get(i.base||i,i.modified.concat(t).sort((s,r)=>s.id-r.id))}},yp=0,rs=class n{constructor(e){this.name=e,this.instances=[],this.id=yp++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&xp(t,l.modified));if(i)return i;let s=[],r=new nt(e.name,s,e,t);for(let l of t)l.instances.push(r);let o=bp(t);for(let l of e.set)if(!l.modified.length)for(let a of o)s.push(n.get(l,a));return r}};function xp(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function bp(n){let e=[[]];for(let t=0;ti.length-t.length)}function os(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let s of t.split(" "))if(s){let r=[],o=2,l=s;for(let f=0;;){if(l=="..."&&f>0&&f+3==s.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+s);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==s.length)break;let d=s[f++];if(f==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);l=s.slice(f)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+s);let c=new Kt(i,o,a>0?r.slice(0,a):null);e[h]=c.sort(e[h])}}return ph.add(e)}var ph=new z({combine(n,e){let t,i,s;for(;n||e;){if(!n||e&&n.depth>=e.depth?(s=e,e=e.next):(s=n,n=n.next),t&&t.mode==s.mode&&!s.context&&!t.context)continue;let r=new Kt(s.tags,s.mode,s.context);t?t.next=r:i=r,t=r}return i}}),Kt=class{constructor(e,t,i,s){this.tags=e,this.mode=t,this.context=i,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=s;for(let l of r)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function Sp(n,e){let t=null;for(let i of n){let s=i.style(e);s&&(t=t?t+" "+s:s)}return t}function Oh(n,e,t,i=0,s=n.length){let r=new lo(i,Array.isArray(e)?e:[e],t);r.highlightRange(n.cursor(),i,s,"",r.highlighters),r.flush(s)}var lo=class{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,s,r){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=s,c=wp(e)||Kt.empty,f=Sp(r,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(s+=(s?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(z.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(m=>!m.scope||m.scope(u.tree.type)),O=e.firstChild();for(let m=0,g=l;;m++){let S=m=b||!e.nextSibling())););if(!S||b>i)break;g=S.to+l,g>t&&(this.highlightRange(d.cursor(),Math.max(t,S.from+l),Math.min(i,g),"",p),this.startSpan(Math.min(i,g),h))}O&&e.parent()}else if(e.firstChild()){u&&(s="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,s,r),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}};function wp(n){let e=n.type.prop(ph);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var $=nt.define,is=$(),Rt=$(),uh=$(Rt),dh=$(Rt),Xt=$(),ns=$(Xt),oo=$(Xt),gt=$(),Ht=$(gt),Ot=$(),mt=$(),ao=$(),Ji=$(ao),ss=$(),y={comment:is,lineComment:$(is),blockComment:$(is),docComment:$(is),name:Rt,variableName:$(Rt),typeName:uh,tagName:$(uh),propertyName:dh,attributeName:$(dh),className:$(Rt),labelName:$(Rt),namespace:$(Rt),macroName:$(Rt),literal:Xt,string:ns,docString:$(ns),character:$(ns),attributeValue:$(ns),number:oo,integer:$(oo),float:$(oo),bool:$(Xt),regexp:$(Xt),escape:$(Xt),color:$(Xt),url:$(Xt),keyword:Ot,self:$(Ot),null:$(Ot),atom:$(Ot),unit:$(Ot),modifier:$(Ot),operatorKeyword:$(Ot),controlKeyword:$(Ot),definitionKeyword:$(Ot),moduleKeyword:$(Ot),operator:mt,derefOperator:$(mt),arithmeticOperator:$(mt),logicOperator:$(mt),bitwiseOperator:$(mt),compareOperator:$(mt),updateOperator:$(mt),definitionOperator:$(mt),typeOperator:$(mt),controlOperator:$(mt),punctuation:ao,separator:$(ao),bracket:Ji,angleBracket:$(Ji),squareBracket:$(Ji),paren:$(Ji),brace:$(Ji),content:gt,heading:Ht,heading1:$(Ht),heading2:$(Ht),heading3:$(Ht),heading4:$(Ht),heading5:$(Ht),heading6:$(Ht),contentSeparator:$(gt),list:$(gt),quote:$(gt),emphasis:$(gt),strong:$(gt),link:$(gt),monospace:$(gt),strikethrough:$(gt),inserted:$(),deleted:$(),changed:$(),invalid:$(),meta:ss,documentMeta:$(ss),annotation:$(ss),processingInstruction:$(ss),definition:nt.defineModifier("definition"),constant:nt.defineModifier("constant"),function:nt.defineModifier("function"),standard:nt.defineModifier("standard"),local:nt.defineModifier("local"),special:nt.defineModifier("special")};for(let n in y){let e=y[n];e instanceof nt&&(e.name=n)}var hx=ho([{tag:y.link,class:"tok-link"},{tag:y.heading,class:"tok-heading"},{tag:y.emphasis,class:"tok-emphasis"},{tag:y.strong,class:"tok-strong"},{tag:y.keyword,class:"tok-keyword"},{tag:y.atom,class:"tok-atom"},{tag:y.bool,class:"tok-bool"},{tag:y.url,class:"tok-url"},{tag:y.labelName,class:"tok-labelName"},{tag:y.inserted,class:"tok-inserted"},{tag:y.deleted,class:"tok-deleted"},{tag:y.literal,class:"tok-literal"},{tag:y.string,class:"tok-string"},{tag:y.number,class:"tok-number"},{tag:[y.regexp,y.escape,y.special(y.string)],class:"tok-string2"},{tag:y.variableName,class:"tok-variableName"},{tag:y.local(y.variableName),class:"tok-variableName tok-local"},{tag:y.definition(y.variableName),class:"tok-variableName tok-definition"},{tag:y.special(y.variableName),class:"tok-variableName2"},{tag:y.definition(y.propertyName),class:"tok-propertyName tok-definition"},{tag:y.typeName,class:"tok-typeName"},{tag:y.namespace,class:"tok-namespace"},{tag:y.className,class:"tok-className"},{tag:y.macroName,class:"tok-macroName"},{tag:y.propertyName,class:"tok-propertyName"},{tag:y.operator,class:"tok-operator"},{tag:y.comment,class:"tok-comment"},{tag:y.meta,class:"tok-meta"},{tag:y.invalid,class:"tok-invalid"},{tag:y.punctuation,class:"tok-punctuation"}]);var kp=316,Qp=317,mh=1,vp=2,$p=3,Pp=4,Tp=318,Cp=320,Zp=321,Ap=5,Mp=6,Rp=0,fo=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],gh=125,Xp=59,uo=47,Lp=42,Ep=43,Dp=45,zp=60,_p=44,Wp=63,Bp=46,Yp=91,Ip=new es({start:!1,shift(n,e){return e==Ap||e==Mp||e==Cp?n:e==Zp},strict:!1}),qp=new Mt((n,e)=>{let{next:t}=n;(t==gh||t==-1||e.context)&&n.acceptToken(Tp)},{contextual:!0,fallback:!0}),Vp=new Mt((n,e)=>{let{next:t}=n,i;fo.indexOf(t)>-1||t==uo&&((i=n.peek(1))==uo||i==Lp)||t!=gh&&t!=Xp&&t!=-1&&!e.context&&n.acceptToken(kp)},{contextual:!0}),jp=new Mt((n,e)=>{n.next==Yp&&!e.context&&n.acceptToken(Qp)},{contextual:!0}),Np=new Mt((n,e)=>{let{next:t}=n;if(t==Ep||t==Dp){if(n.advance(),t==n.next){n.advance();let i=!e.context&&e.canShift(mh);n.acceptToken(i?mh:vp)}}else t==Wp&&n.peek(1)==Bp&&(n.advance(),n.advance(),(n.next<48||n.next>57)&&n.acceptToken($p))},{contextual:!0});function co(n,e){return n>=65&&n<=90||n>=97&&n<=122||n==95||n>=192||!e&&n>=48&&n<=57}var Gp=new Mt((n,e)=>{if(n.next!=zp||!e.dialectEnabled(Rp)||(n.advance(),n.next==uo))return;let t=0;for(;fo.indexOf(n.next)>-1;)n.advance(),t++;if(co(n.next,!0)){for(n.advance(),t++;co(n.next,!1);)n.advance(),t++;for(;fo.indexOf(n.next)>-1;)n.advance(),t++;if(n.next==_p)return;for(let i=0;;i++){if(i==7){if(!co(n.next,!0))return;break}if(n.next!="extends".charCodeAt(i))break;n.advance(),t++}}n.acceptToken(Pp,-t)}),Up=os({"get set async static":y.modifier,"for while do if else switch try catch finally return throw break continue default case defer":y.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":y.operatorKeyword,"let var const using function class extends":y.definitionKeyword,"import export from":y.moduleKeyword,"with debugger new":y.keyword,TemplateString:y.special(y.string),super:y.atom,BooleanLiteral:y.bool,this:y.self,null:y.null,Star:y.modifier,VariableName:y.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":y.function(y.variableName),VariableDefinition:y.definition(y.variableName),Label:y.labelName,PropertyName:y.propertyName,PrivatePropertyName:y.special(y.propertyName),"CallExpression/MemberExpression/PropertyName":y.function(y.propertyName),"FunctionDeclaration/VariableDefinition":y.function(y.definition(y.variableName)),"ClassDeclaration/VariableDefinition":y.definition(y.className),"NewExpression/VariableName":y.className,PropertyDefinition:y.definition(y.propertyName),PrivatePropertyDefinition:y.definition(y.special(y.propertyName)),UpdateOp:y.updateOperator,"LineComment Hashbang":y.lineComment,BlockComment:y.blockComment,Number:y.number,String:y.string,Escape:y.escape,ArithOp:y.arithmeticOperator,LogicOp:y.logicOperator,BitOp:y.bitwiseOperator,CompareOp:y.compareOperator,RegExp:y.regexp,Equals:y.definitionOperator,Arrow:y.function(y.punctuation),": Spread":y.punctuation,"( )":y.paren,"[ ]":y.squareBracket,"{ }":y.brace,"InterpolationStart InterpolationEnd":y.special(y.brace),".":y.derefOperator,", ;":y.separator,"@":y.meta,TypeName:y.typeName,TypeDefinition:y.definition(y.typeName),"type enum interface implements namespace module declare":y.definitionKeyword,"abstract global Privacy readonly override":y.modifier,"is keyof unique infer asserts":y.operatorKeyword,JSXAttributeValue:y.attributeValue,JSXText:y.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":y.angleBracket,"JSXIdentifier JSXNameSpacedName":y.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":y.attributeName,"JSXBuiltin/JSXIdentifier":y.standard(y.tagName)}),Fp={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},Hp={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},Kp={__proto__:null,"<":193},yh=ts.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Il'#IlO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JrO6[Q!0MxO'#JsO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO9XQMhO'#F|O9`Q`O'#F{OOQ!0Lf'#Js'#JsOOQ!0Lb'#Jr'#JrO9eQ`O'#GwOOQ['#K_'#K_O9pQ`O'#IYO9uQ!0LrO'#IZOOQ['#J`'#J`OOQ['#I_'#I_Q`QlOOQ`QlOOO9}Q!L^O'#DvO:UQlO'#EOO:]QlO'#EQO9kQ`O'#GsO:dQMhO'#CoO:rQ`O'#EnO:}Q`O'#EyO;hQMhO'#FeO;xQ`O'#GsOOQO'#K`'#K`O;}Q`O'#K`O<]Q`O'#G{O<]Q`O'#G|O<]Q`O'#HOO9kQ`O'#HRO=SQ`O'#HUO>kQ`O'#CeO>{Q`O'#HcO?TQ`O'#HiO?TQ`O'#HkO`QlO'#HmO?TQ`O'#HoO?TQ`O'#HrO?YQ`O'#HxO?_Q!0LsO'#IOO%[QlO'#IQO?jQ!0LsO'#ISO?uQ!0LsO'#IUO9uQ!0LrO'#IWO@QQ!0MxO'#CiOASQpO'#DlQOQ`OOO%[QlO'#EQOAjQ`O'#ETO:dQMhO'#EnOAuQ`O'#EnOBQQ!bO'#FeOOQ['#Cg'#CgOOQ!0Lb'#Dq'#DqOOQ!0Lb'#Jv'#JvO%[QlO'#JvOOQO'#Jy'#JyOOQO'#Ih'#IhOCQQpO'#EgOOQ!0Lb'#Ef'#EfOOQ!0Lb'#J}'#J}OC|Q!0MSO'#EgODWQpO'#EWOOQO'#Jx'#JxODlQpO'#JyOEyQpO'#EWODWQpO'#EgPFWO&2DjO'#CbPOOO)CD})CD}OOOO'#I`'#I`OFcO#tO,59UOOQ!0Lh,59U,59UOOOO'#Ia'#IaOFqO&jO,59UOGPQ!L^O'#DcOOOO'#Ic'#IcOGWO#@ItO,59{OOQ!0Lf,59{,59{OGfQlO'#IdOGyQ`O'#JtOIxQ!fO'#JtO+}QlO'#JtOJPQ`O,5:ROJgQ`O'#EpOJtQ`O'#KTOKPQ`O'#KSOKPQ`O'#KSOKXQ`O,5;^OK^Q`O'#KROOQ!0Ln,5:^,5:^OKeQlO,5:^OMcQ!0MxO,5:fONSQ`O,5:nONmQ!0LrO'#KQONtQ`O'#KPO9eQ`O'#KPO! YQ`O'#KPO! bQ`O,5;]O! gQ`O'#KPO!#lQ!fO'#JsOOQ!0Lh'#Ci'#CiO%[QlO'#ESO!$[Q!fO,5:sOOQS'#Jz'#JzOOQO-EtOOQ['#Jh'#JhOOQ[,5>u,5>uOOQ[-E<]-E<]O!TO`QlO,5>VO!LOQ`O,5>XO`QlO,5>ZO!LTQ`O,5>^O!LYQlO,5>dOOQ[,5>j,5>jO%[QlO,5>jO9uQ!0LrO,5>lOOQ[,5>n,5>nO#!dQ`O,5>nOOQ[,5>p,5>pO#!dQ`O,5>pOOQ[,5>r,5>rO##QQpO'#D_O%[QlO'#JvO##sQpO'#JvO##}QpO'#DmO#$`QpO'#DmO#&qQlO'#DmO#&xQ`O'#JuO#'QQ`O,5:WO#'VQ`O'#EtO#'eQ`O'#KUO#'mQ`O,5;_O#'rQpO'#DmO#(PQpO'#EVOOQ!0Lf,5:o,5:oO%[QlO,5:oO#(WQ`O,5:oO?YQ`O,5;YO!CUQpO,5;YO!C^QMhO,5;YO:dQMhO,5;YO#(`Q`O,5@bO#(eQ07dO,5:sOOQO-EPO$6^Q`O,5>POOQ[1G3i1G3iO`QlO1G3iOOQ[1G3o1G3oOOQ[1G3q1G3qO?TQ`O1G3sO$6cQlO1G3uO$:gQlO'#HtOOQ[1G3x1G3xO$:tQ`O'#HzO?YQ`O'#H|OOQ[1G4O1G4OO$:|QlO1G4OO9uQ!0LrO1G4UOOQ[1G4W1G4WOOQ!0Lb'#G_'#G_O9uQ!0LrO1G4YO9uQ!0LrO1G4[O$?TQ`O,5@bO!)[QlO,5;`O9eQ`O,5;`O?YQ`O,5:XO!)[QlO,5:XO!CUQpO,5:XO$?YQ?MtO,5:XOOQO,5;`,5;`O$?dQpO'#IeO$?zQ`O,5@aOOQ!0Lf1G/r1G/rO$@SQpO'#IkO$@^Q`O,5@pOOQ!0Lb1G0y1G0yO#$`QpO,5:XOOQO'#Ig'#IgO$@fQpO,5:qOOQ!0Ln,5:q,5:qO#(ZQ`O1G0ZOOQ!0Lf1G0Z1G0ZO%[QlO1G0ZOOQ!0Lf1G0t1G0tO?YQ`O1G0tO!CUQpO1G0tO!C^QMhO1G0tOOQ!0Lb1G5|1G5|O!ByQ!0LrO1G0^OOQO1G0m1G0mO%[QlO1G0mO$@mQ!0LrO1G0mO$@xQ!0LrO1G0mO!CUQpO1G0^ODWQpO1G0^O$AWQ!0LrO1G0mOOQO1G0^1G0^O$AlQ!0MxO1G0mPOOO-E<[-E<[POOO1G.h1G.hOOOO1G/i1G/iO$AvQ!bO,5QQpO,5@}OOQ!0Lb1G3c1G3cOOQ[7+$V7+$VO@zQ`O7+$VO9uQ!0LrO7+$VO%>]Q`O7+$VO%[QlO1G6lO%[QlO1G6mO%>bQ!0LrO1G6lO%>lQlO1G3kO%>sQ`O1G3kO%>xQlO1G3kOOQ[7+)T7+)TO9uQ!0LrO7+)_O`QlO7+)aOOQ['#Kh'#KhOOQ['#JS'#JSO%?PQlO,5>`OOQ[,5>`,5>`O%[QlO'#HuO%?^Q`O'#HwOOQ[,5>f,5>fO9eQ`O,5>fOOQ[,5>h,5>hOOQ[7+)j7+)jOOQ[7+)p7+)pOOQ[7+)t7+)tOOQ[7+)v7+)vO%?cQpO1G5|O%?}Q?MtO1G0zO%@XQ`O1G0zOOQO1G/s1G/sO%@dQ?MtO1G/sO?YQ`O1G/sO!)[QlO'#DmOOQO,5?P,5?POOQO-ERQ`O7+,WO&>WQ`O7+,XO%[QlO7+,WO%[QlO7+,XOOQ[7+)V7+)VO&>]Q`O7+)VO&>bQlO7+)VO&>iQ`O7+)VOOQ[<nQ`O,5>aOOQ[,5>c,5>cO&>sQ`O1G4QO9eQ`O7+&fO!)[QlO7+&fOOQO7+%_7+%_O&>xQ?MtO1G6ZO?YQ`O7+%_OOQ!0Lf<yQ?MvO,5?aO'@|Q?MvO,5?cO'CPQ?MvO7+'|O'DuQMjOG27TOOQO<VO!l$xO#jROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]$_Oa$qa'z$qa'w$qa!k$qa!Y$qa!_$qa%i$qa!g$qa~Ol)dO~P!&zOh%VOp%WOr%XOs$tOt$tOz%YO|%ZO!O%]O!S${O!_$|O!i%bO!l$xO#j%cO$W%`O$t%^O$v%_O$y%aO(T(vO(VTO(YUO(a$uO(y$}O(z%PO~Og(pP~P!,TO!Q)iO!g)hO!_$^X$Z$^X$]$^X$_$^X$f$^X~O!g)hO!_({X$Z({X$]({X$_({X$f({X~O!Q)iO~P!.^O!Q)iO!_({X$Z({X$]({X$_({X$f({X~O!_)kO$Z)oO$])jO$_)jO$f)pO~O![)sO~P!)[O$]$hO$_$gO$f)wO~On$zX!Q$zX#S$zX'y$zX(y$zX(z$zX~OgmXg$zXnmX!]mX#`mX~P!0SOx)yO(b)zO(c)|O~On*VO!Q*OO'y*PO(y$}O(z%PO~Og)}O~P!1WOg*WO~Oh%VOr%XOs$tOt$tOz%YO|%ZO!OVO!l$xO#jVO!l$xO#jROe!iOpkOrPO(VTO(YUO(aVO(o[O~O(T=QO~P#$qO!]-]O!^(iX~O!^-_O~O!g-VO#`-UO!]#hX!^#hX~O!]-`O!^(xX~O!^-bO~O!c-cO!d-cO(U!lO~P#$`O!^-fO~P'_On-iO!_'`O~O!Y-nO~Os!{a!b!{a!c!{a!d!{a#T!{a#U!{a#V!{a#W!{a#X!{a#[!{a#]!{a(U!{a(V!{a(Y!{a(e!{a(o!{a~P!#vO!p-sO#`-qO~PChO!c-uO!d-uO(U!lO~PDWOa%nO#`-qO'z%nO~Oa%nO!g#vO#`-qO'z%nO~Oa%nO!g#vO!p-sO#`-qO'z%nO(r'pO~O(P'xO(Q'xO(R-zO~Ov-{O~O!Y'Wa!]'Wa~P!:tO![.PO!Y'WX!]'WX~P%[O!](VO!Y(ha~O!Y(ha~PHRO!](^O!Y(va~O!S%hO![.TO!_%iO(T%gO!Y'^X!]'^X~O#`.VO!](ta!k(taa(ta'z(ta~O!g#vO~P#,wO!](jO!k(sa~O!S%hO!_%iO#j.ZO(T%gO~Op.`O!S%hO![.]O!_%iO!|]O#i._O#j.]O(T%gO!]'aX!k'aX~OR.dO!l#xO~Oh%VOn.gO!_'`O%i.fO~Oa#ci!]#ci'z#ci'w#ci!Y#ci!k#civ#ci!_#ci%i#ci!g#ci~P!:tOn>]O!Q*OO'y*PO(y$}O(z%PO~O#k#_aa#_a#`#_a'z#_a!]#_a!k#_a!_#_a!Y#_a~P#/sO#k(`XP(`XR(`X[(`Xa(`Xj(`Xr(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X'z(`X(a(`X(r(`X!k(`X!Y(`X'w(`Xv(`X!_(`X%i(`X!g(`X~P!6kO!].tO!k(kX~P!:tO!k.wO~O!Y.yO~OP$[OR#zO!Q#yO!S#{O!l#xO!p$[O(aVO[#mia#mij#mir#mi!]#mi#R#mi#o#mi#p#mi#q#mi#r#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#n#mi~P#3cO#n$OO~P#3cOP$[OR#zOr$aO!Q#yO!S#{O!l#xO!p$[O#n$OO#o$PO#p$PO#q$PO(aVO[#mia#mij#mi!]#mi#R#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#r#mi~P#6QO#r$QO~P#6QOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO(aVOa#mi!]#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#v#mi~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO(aVO(z#}Oa#mi!]#mi#z#mi#{#mi'z#mi(r#mi(y#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#x$UO~P#;VO#x#mi~P#;VO#v$SO~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO#x$UO(aVO(y#|O(z#}Oa#mi!]#mi#{#mi'z#mi(r#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#z#mi~P#={O#z$WO~P#={OP]XR]X[]Xj]Xr]X!Q]X!S]X!l]X!p]X#R]X#S]X#`]X#kfX#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#v]X#x]X#z]X#{]X$Q]X(a]X(r]X(y]X(z]X!]]X!^]X~O$O]X~P#@jOP$[OR#zO[]O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P#EyO!]/POg(pX~P!1WOg/RO~Oa$Pi!]$Pi'z$Pi'w$Pi!Y$Pi!k$Piv$Pi!_$Pi%i$Pi!g$Pi~P!:tO$]/SO$_/SO~O$]/TO$_/TO~O!g)hO#`/UO!_$cX$Z$cX$]$cX$_$cX$f$cX~O![/VO~O!_)kO$Z/XO$])jO$_)jO$f/YO~O!]VO!l$xO#j^O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P&,QO#S$dOP(`XR(`X[(`Xj(`Xn(`Xr(`X!Q(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X$O(`X'y(`X(a(`X(r(`X(y(`X(z(`X!](`X!^(`X~O$O$Pi!]$Pi!^$Pi~P#BwO$O!ri!^!ri~P$+oOg']a!]']a~P!1WO!^7nO~O!]'da!^'da~P#BwO!Y7oO~P#/sO!g#vO(r'pO!]'ea!k'ea~O!]/pO!k)Oi~O!]/pO!g#vO!k)Oi~Og$|q!]$|q#`$|q$O$|q~P!1WO!Y'ga!]'ga~P#/sO!g7vO~O!]/yO!Y)Pi~P#/sO!]/yO!Y)Pi~O!Y7yO~Oh%VOr8OO!l%eO(r'pO~Oj8QO!g#vO~Or8TO!g#vO(r'pO~O!Q*OO'y*PO(z%POn'ja(y'ja!]'ja#`'ja~Og'ja$O'ja~P&5RO!Q*OO'y*POn'la(y'la(z'la!]'la#`'la~Og'la$O'la~P&5tOg(_q!](_q~P!1WO#`8VOg(_q!](_q~P!1WO!Y8WO~Og%Oq!]%Oq#`%Oq$O%Oq~P!1WOa$oy!]$oy'z$oy'w$oy!Y$oy!k$oyv$oy!_$oy%i$oy!g$oy~P!:tO!g6rO~O!]5[O!_)Qa~O!_'`OP$TaR$Ta[$Taj$Tar$Ta!Q$Ta!S$Ta!]$Ta!l$Ta!p$Ta#R$Ta#n$Ta#o$Ta#p$Ta#q$Ta#r$Ta#s$Ta#t$Ta#u$Ta#v$Ta#x$Ta#z$Ta#{$Ta(a$Ta(r$Ta(y$Ta(z$Ta~O%i7WO~P&8fO%^8[Oa%[i!_%[i'z%[i!]%[i~Oa#cy!]#cy'z#cy'w#cy!Y#cy!k#cyv#cy!_#cy%i#cy!g#cy~P!:tO[8^O~Ob8`O(T+qO(VTO(YUO~O!]1TO!^)Xi~O`8dO~O(e(|O!]'pX!^'pX~O!]5uO!^)Ua~O!^8nO~P%;eO(o!sO~P$&YO#[8oO~O!_1oO~O!_1oO%i8qO~On8tO!_1oO%i8qO~O[8yO!]'sa!^'sa~O!]1zO!^)Vi~O!k8}O~O!k9OO~O!k9RO~O!k9RO~P%[Oa9TO~O!g9UO~O!k9VO~O!](wi!^(wi~P#BwOa%nO#`9_O'z%nO~O!](ty!k(tya(ty'z(ty~P!:tO!](jO!k(sy~O%i9bO~P&8fO!_'`O%i9bO~O#k$|qP$|qR$|q[$|qa$|qj$|qr$|q!S$|q!]$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q'z$|q(a$|q(r$|q!k$|q!Y$|q'w$|q#`$|qv$|q!_$|q%i$|q!g$|q~P#/sO#k'jaP'jaR'ja['jaa'jaj'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja'z'ja(a'ja(r'ja!k'ja!Y'ja'w'jav'ja!_'ja%i'ja!g'ja~P&5RO#k'laP'laR'la['laa'laj'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la'z'la(a'la(r'la!k'la!Y'la'w'lav'la!_'la%i'la!g'la~P&5tO#k%OqP%OqR%Oq[%Oqa%Oqj%Oqr%Oq!S%Oq!]%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq'z%Oq(a%Oq(r%Oq!k%Oq!Y%Oq'w%Oq#`%Oqv%Oq!_%Oq%i%Oq!g%Oq~P#/sO!]'Yi!k'Yi~P!:tO$O#cq!]#cq!^#cq~P#BwO(y$}OP%aaR%aa[%aaj%aar%aa!S%aa!l%aa!p%aa#R%aa#n%aa#o%aa#p%aa#q%aa#r%aa#s%aa#t%aa#u%aa#v%aa#x%aa#z%aa#{%aa$O%aa(a%aa(r%aa!]%aa!^%aa~On%aa!Q%aa'y%aa(z%aa~P&IyO(z%POP%caR%ca[%caj%car%ca!S%ca!l%ca!p%ca#R%ca#n%ca#o%ca#p%ca#q%ca#r%ca#s%ca#t%ca#u%ca#v%ca#x%ca#z%ca#{%ca$O%ca(a%ca(r%ca!]%ca!^%ca~On%ca!Q%ca'y%ca(y%ca~P&LQOn>^O!Q*OO'y*PO(z%PO~P&IyOn>^O!Q*OO'y*PO(y$}O~P&LQOR0kO!Q0kO!S0lO#S$dOP}a[}aj}an}ar}a!l}a!p}a#R}a#n}a#o}a#p}a#q}a#r}a#s}a#t}a#u}a#v}a#x}a#z}a#{}a$O}a'y}a(a}a(r}a(y}a(z}a!]}a!^}a~O!Q*OO'y*POP$saR$sa[$saj$san$sar$sa!S$sa!l$sa!p$sa#R$sa#n$sa#o$sa#p$sa#q$sa#r$sa#s$sa#t$sa#u$sa#v$sa#x$sa#z$sa#{$sa$O$sa(a$sa(r$sa(y$sa(z$sa!]$sa!^$sa~O!Q*OO'y*POP$uaR$ua[$uaj$uan$uar$ua!S$ua!l$ua!p$ua#R$ua#n$ua#o$ua#p$ua#q$ua#r$ua#s$ua#t$ua#u$ua#v$ua#x$ua#z$ua#{$ua$O$ua(a$ua(r$ua(y$ua(z$ua!]$ua!^$ua~On>^O!Q*OO'y*PO(y$}O(z%PO~OP%TaR%Ta[%Taj%Tar%Ta!S%Ta!l%Ta!p%Ta#R%Ta#n%Ta#o%Ta#p%Ta#q%Ta#r%Ta#s%Ta#t%Ta#u%Ta#v%Ta#x%Ta#z%Ta#{%Ta$O%Ta(a%Ta(r%Ta!]%Ta!^%Ta~P''VO$O$mq!]$mq!^$mq~P#BwO$O$oq!]$oq!^$oq~P#BwO!^9oO~O$O9pO~P!1WO!g#vO!]'ei!k'ei~O!g#vO(r'pO!]'ei!k'ei~O!]/pO!k)Oq~O!Y'gi!]'gi~P#/sO!]/yO!Y)Pq~Or9wO!g#vO(r'pO~O[9yO!Y9xO~P#/sO!Y9xO~Oj:PO!g#vO~Og(_y!](_y~P!1WO!]'na!_'na~P#/sOa%[q!_%[q'z%[q!]%[q~P#/sO[:UO~O!]1TO!^)Xq~O`:YO~O#`:ZO!]'pa!^'pa~O!]5uO!^)Ui~P#BwO!S:]O~O!_1oO%i:`O~O(VTO(YUO(e:eO~O!]1zO!^)Vq~O!k:hO~O!k:iO~O!k:jO~O!k:jO~P%[O#`:mO!]#hy!^#hy~O!]#hy!^#hy~P#BwO%i:rO~P&8fO!_'`O%i:rO~O$O#|y!]#|y!^#|y~P#BwOP$|iR$|i[$|ij$|ir$|i!S$|i!l$|i!p$|i#R$|i#n$|i#o$|i#p$|i#q$|i#r$|i#s$|i#t$|i#u$|i#v$|i#x$|i#z$|i#{$|i$O$|i(a$|i(r$|i!]$|i!^$|i~P''VO!Q*OO'y*PO(z%POP'iaR'ia['iaj'ian'iar'ia!S'ia!l'ia!p'ia#R'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#v'ia#x'ia#z'ia#{'ia$O'ia(a'ia(r'ia(y'ia!]'ia!^'ia~O!Q*OO'y*POP'kaR'ka['kaj'kan'kar'ka!S'ka!l'ka!p'ka#R'ka#n'ka#o'ka#p'ka#q'ka#r'ka#s'ka#t'ka#u'ka#v'ka#x'ka#z'ka#{'ka$O'ka(a'ka(r'ka(y'ka(z'ka!]'ka!^'ka~O(y$}OP%aiR%ai[%aij%ain%air%ai!Q%ai!S%ai!l%ai!p%ai#R%ai#n%ai#o%ai#p%ai#q%ai#r%ai#s%ai#t%ai#u%ai#v%ai#x%ai#z%ai#{%ai$O%ai'y%ai(a%ai(r%ai(z%ai!]%ai!^%ai~O(z%POP%ciR%ci[%cij%cin%cir%ci!Q%ci!S%ci!l%ci!p%ci#R%ci#n%ci#o%ci#p%ci#q%ci#r%ci#s%ci#t%ci#u%ci#v%ci#x%ci#z%ci#{%ci$O%ci'y%ci(a%ci(r%ci(y%ci!]%ci!^%ci~O$O$oy!]$oy!^$oy~P#BwO$O#cy!]#cy!^#cy~P#BwO!g#vO!]'eq!k'eq~O!]/pO!k)Oy~O!Y'gq!]'gq~P#/sOr:|O!g#vO(r'pO~O[;QO!Y;PO~P#/sO!Y;PO~Og(_!R!](_!R~P!1WOa%[y!_%[y'z%[y!]%[y~P#/sO!]1TO!^)Xy~O!]5uO!^)Uq~O(T;XO~O!_1oO%i;[O~O!k;_O~O%i;dO~P&8fOP$|qR$|q[$|qj$|qr$|q!S$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q$O$|q(a$|q(r$|q!]$|q!^$|q~P''VO!Q*OO'y*PO(z%POP'jaR'ja['jaj'jan'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja$O'ja(a'ja(r'ja(y'ja!]'ja!^'ja~O!Q*OO'y*POP'laR'la['laj'lan'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la$O'la(a'la(r'la(y'la(z'la!]'la!^'la~OP%OqR%Oq[%Oqj%Oqr%Oq!S%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq$O%Oq(a%Oq(r%Oq!]%Oq!^%Oq~P''VOg%e!Z!]%e!Z#`%e!Z$O%e!Z~P!1WO!Y;hO~P#/sOr;iO!g#vO(r'pO~O[;kO!Y;hO~P#/sO!]'pq!^'pq~P#BwO!]#h!Z!^#h!Z~P#BwO#k%e!ZP%e!ZR%e!Z[%e!Za%e!Zj%e!Zr%e!Z!S%e!Z!]%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z'z%e!Z(a%e!Z(r%e!Z!k%e!Z!Y%e!Z'w%e!Z#`%e!Zv%e!Z!_%e!Z%i%e!Z!g%e!Z~P#/sOr;tO!g#vO(r'pO~O!Y;uO~P#/sOr;|O!g#vO(r'pO~O!Y;}O~P#/sOP%e!ZR%e!Z[%e!Zj%e!Zr%e!Z!S%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z$O%e!Z(a%e!Z(r%e!Z!]%e!Z!^%e!Z~P''VOrROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]WO!l$xO#jgPPP!>oI[PPPPPPPPP!BOP!C]PPI[!DnPI[PI[I[I[I[I[PI[!FQP!I[P!LbP!Lf!Lp!Lt!LtP!IXP!Lx!LxP#!OP#!SI[PI[#!Y#%_CjA^PA^PA^A^P#&lA^A^#)OA^#+vA^#.SA^A^#.r#1W#1W#1]#1f#1W#1qPP#1WPA^#2ZA^#6YA^A^6mPPP#:_PPP#:x#:xP#:xP#;`#:xPP#;fP#;]P#;]#;y#;]#P#>V#>]#>k#>q#>{#?R#?]#?c#?s#?y#@k#@}#AT#AZ#Ai#BO#Cs#DR#DY#Et#FS#Gt#HS#HY#H`#Hf#Hp#Hv#H|#IW#Ij#IpPPPPPPPPPPP#IvPPPPPPP#Jk#Mx$ b$ i$ qPPP$']P$'f$*_$0x$0{$1O$1}$2Q$2X$2aP$2g$2jP$3W$3[$4S$5b$5g$5}PP$6S$6Y$6^$6a$6e$6i$7e$7|$8e$8i$8l$8o$8y$8|$9Q$9UR!|RoqOXst!Z#d%m&r&t&u&w,s,x2[2_Y!vQ'`-e1o5{Q%tvQ%|yQ&T|Q&j!VS'W!e-]Q'f!iS'l!r!yU*k$|*Z*oQ+o%}S+|&V&WQ,d&dQ-c'_Q-m'gQ-u'mQ0[*qQ1b,OQ1y,eR<{SU+P%]S!S!nQ!r!v!y!z$|'W'_'`'l'm'n*k*o*q*r-]-c-e-u0[0_1o5{5}%[$ti#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^Q&X|Q'U!eS'[%i-`Q+t&PQ,P&WQ,f&gQ0n+SQ1Y+uQ1_+{Q2Q,jQ2R,kQ5f1TQ5o1aQ6[1zQ6_1|Q6`2PQ8`5gQ8c5lQ8|6bQ:X8dQ:f8yQ;V:YR<}*ZrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R,h&k&z^OPXYstuvwz!Z!`!g!j!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'b'r(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mR>S[#]WZ#W#Z'X(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ%wxQ%{yW&Q|&V&W,OQ&_!TQ'c!hQ'e!iQ(q#sS+n%|%}Q+r&PQ,_&bQ,c&dS-l'f'gQ.i(rQ1R+oQ1X+uQ1Z+vQ1^+zQ1t,`S1x,d,eQ2|-mQ5e1TQ5i1WQ5n1`Q6Z1yQ8_5gQ8b5kQ8f5pQ:T8^R;T:U!U$zi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y!^%yy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{Q+h%wQ,T&[Q,W&]Q,b&dQ.h(qQ1s,_U1w,c,d,eQ3e.iQ6U1tS6Y1x1yQ8x6Z#f>T#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o>UPS&[!Q&iQ&]!RQ&^!SU*}%[%d=sR,R&Y%]%Si#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^T)z$u){V+P%]S$i$^c#Y#e%q%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.|.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SQ'Y!eR2q-]!W!nQ!e!r!v!y!z$|'W'_'`'l'm'n*Z*k*o*q*r-]-c-e-u0[0_1o5{5}R1l,ZnqOXst!Z#d%m&r&t&u&w,s,x2[2_Q&y!^Q'v!xS(s#u<^Q+l%zQ,]&_Q,^&aQ-j'dQ-w'oS.r(x=PS0q+X=ZQ1P+mQ1n,[Q2c,zQ2e,{Q2m-WQ2z-kQ2}-oS5Y0r=eQ5a1QS5d1S=fQ6t2oQ6x2{Q6}3SQ8]5bQ9Y6vQ9Z6yQ9^7OR:l9V$d$]c#Y#e%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SS#q]SU$fd)_,mS(p#p'iU*v%R(w4OU0m+O.n7gQ5^0xQ7V3`Q9d7YR:s9em!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}Q't!uS(f#g2US-s'k'wQ/s*]Q0R*jQ3U-vQ4f/tQ4r0TQ4s0UQ4x0^Q7r4`S7}4t4vS8R4y4{Q9r7sQ9v7yQ9{8OQ:Q8TS:{9w9xS;g:|;PS;s;h;iS;{;t;uSSR=o>R%^bOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Q%fj!^%xy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{S&Oz!jQ+k%yQ,a&dW1v,b,c,d,eU6X1w1x1yS8w6Y6ZQ:d8x!r=j$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ=t>QR=u>R%QeOPXYstuvw!Z!`!g!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Y#bWZ#W#Z(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ,n&o!p=k$Z$n)s-U-X/V2p4T5w6s:Z:mSR=n'XU']!e%i*ZR2s-`%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+],p,s,x-i-q.P.V.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3l4z6T6e6f6i6|8t9T9_!r)_$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ,m&oQ0x+gQ3`.gQ7Y3dR9e7[!b$Tc#Y%q(S(Y(t(y)Z)[)`)g+x-x-}.S.U.s.v/b0p3O3V3k3{5X5c6{7Q7a9]:oS)^)q-Z.|2k2n3p4P4X6u7b7k7l8k9X9g9m9n;W;`=vQ>X>ZR>Y>['QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mSS$oh$pR4U/U'XgOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$kf$qQ$ifS)j$l)nR)v$qT$jf$qT)l$l)n'XhOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$oh$pQ$rhR)u$p%^jOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_!s>Q$Z$n'X)s-U-X/V2p4T5w6s:Z:mS#glOPXZst!Z!`!o#S#d#o#{$n%m&k&n&o&r&t&u&w&{'T'b)O)s*i+]+g,p,s,x-i.g/V/n0]0l1r2S2T2V2X2[2_2a3d4T4z6T6e6f6i7[8t9T!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^Q+T%aQ/c*Oo4OP>X>YQ*c$zU*l$|*Z*oQ+U%bQ0W*m#f=q#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^n=rTQ=x>UQ=y>VR=z>W!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o4OP>X>Y>]>^Q,U&]Q1h,WQ5s1gR8h5tV*n$|*Z*oU*n$|*Z*oT5z1o5{S0P*i/nQ4w0]T8S4z:]Q+j%xQ0V*lQ1O+kQ1u,aQ6W1vQ8v6XQ:c8wR;^:d!U%Oi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Yx*R$v)e*S*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>OS0`*t0a#f]>^nZ>[`=T3}7c7f7j9h:t:w;yS=_.l3iT=`7e9k!U%Qi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y|*T$v)e*U*t+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>OS0b*u0c#f]>^nZ>[d=V3}7d7e7j9h9i:t:u:w;yS=a.m3jT=b7f9lrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q&f!UR,p&ornOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R&f!UQ,Y&^R1d,RsnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q1p,_S6R1s1tU8p6P6Q6US:_8r8sS;Y:^:aQ;m;ZR;w;nQ&m!VR,i&iR6_1|R:f8yW&Q|&V&W,OR1Z+vQ&r!WR,s&sR,y&xT2],x2_R,}&yQ,|&yR2f,}Q'y!{R-y'ySsOtQ#dXT%ps#dQ#OTR'{#OQ#RUR'}#RQ){$uR/`){Q#UVR(Q#UQ#XWU(W#X(X.QQ(X#YR.Q(YQ-^'YR2r-^Q.u(yS3m.u3nR3n.vQ-e'`R2v-eY!rQ'`-e1o5{R'j!rQ/Q)eR4S/QU#_W%h*YU(_#_(`.RQ(`#`R.R(ZQ-a']R2t-at`OXst!V!Z#d%m&i&k&r&t&u&w,s,x2[2_S#hZ%eU#r`#h.[R.[(jQ(k#jQ.X(gW.a(k.X3X7RQ3X.YR7R3YQ)n$lR/W)nQ$phR)t$pQ$`cU)a$`-|O>Z>[Q/z*eU4k/z4m7xQ4m/|R7x4lS*o$|*ZR0Y*ox*S$v)e*t*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>O!d.j(u)c*[*e.l.m.q/_/k/|0v1e3h4[4h4l5r7]7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/h*S.j7ca7c3}7e7f7j9h:t:w;yQ0a*tQ3i.lU4}0a3i9kR9k7e|*U$v)e*t*u+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>O!h.k(u)c*[*e.l.m.q/_/k/|0v1e3f3h4[4h4l5r7]7^7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/j*U.k7de7d3}7e7f7j9h9i:t:u:w;yQ0c*uQ3j.mU5P0c3j9lR9l7fQ*z%UR0g*zQ5]0vR8Y5]Q+_%kR0u+_Q5v1jS8j5v:[R:[8kQ,[&_R1m,[Q5{1oR8m5{Q1{,fS6]1{8zR8z6_Q1U+rW5h1U5j8a:VQ5j1XQ8a5iR:V8bQ+w&QR1[+wQ2_,xR6m2_YrOXst#dQ&v!ZQ+a%mQ,r&rQ,t&tQ,u&uQ,w&wQ2Y,sS2],x2_R6l2[Q%opQ&z!_Q&}!aQ'P!bQ'R!cQ'q!uQ+`%lQ+l%zQ,Q&XQ,h&mQ-P&|W-p'k's't'wQ-w'oQ0X*nQ1P+mQ1c,PS2O,i,lQ2g-OQ2h-RQ2i-SQ2}-oW3P-r-s-v-xQ5a1QQ5m1_Q5q1eQ6V1uQ6a2QQ6k2ZU6z3O3R3UQ6}3SQ8]5bQ8e5oQ8g5rQ8l5zQ8u6WQ8{6`S9[6{7PQ9^7OQ:W8cQ:b8vQ:g8|Q:n9]Q;U:XQ;]:cQ;a:oQ;l;VR;o;^Q%zyQ'd!iQ'o!uU+m%{%|%}Q-W'VU-k'e'f'gS-o'k'uQ0Q*jS1Q+n+oQ2o-YS2{-l-mQ3S-tS4p0R0UQ5b1RQ6v2uQ6y2|Q7O3TU7{4r4s4vQ9z7}R;O9{S$wi>PR*{%VU%Ui%V>PR0f*yQ$viS(u#v+iS)c$b$cQ)e$dQ*[$xS*e${*YQ*t%OQ*u%QQ+Q%^Q+R%_Q+V%cQ.lPQ=}>XQ>O>YQ>Z>]R>[>^Q+O%]Q.nSR#[WR'Z!el!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}S'V!e-]U*j$|*Z*oS-Y'W'_S0U*k*qQ0^*rQ2u-cQ4v0[R4{0_R({#xQ!fQT-d'`-e]!qQ!r'`-e1o5{Q#p]R'i < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:Ip,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[Up],skippedNodes:[0,5,6,278],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$i&j(WpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(WpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Wp(Z!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$i&j(Wp(Z!b'|0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(X#S$i&j'}0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$i&j(Wp(Z!b'}0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$i&j!p),Q(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(V':f$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$i&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$d`$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$d``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$d`$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(Z!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$d`(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$i&j(Wp(Z!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$i&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(Z!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$i&j(WpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(WpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Wp(Z!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$i&j!X7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!X7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!X7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$i&j(Z!b!X7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(Z!b!X7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(Z!b!X7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(Z!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$i&j(Z!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!g$b$i&j$O)Lv(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#R-v$?V_!^(CdvBr$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!q7`$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$i&j(Wp(Z!b'|0/l$]#t(T,2j(e$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$i&j(Wp(Z!b'}0/l$]#t(T,2j(e$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[Vp,jp,Np,Gp,2,3,4,5,6,7,8,9,10,11,12,13,14,qp,new Si("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(c~~",141,340),new Si("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:n=>Fp[n]||-1},{term:343,get:n=>Hp[n]||-1},{term:95,get:n=>Kp[n]||-1}],tokenPrec:15201});var Oo=[],wh=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e>1;if(n=wh[i])e=i+1;else return!0;if(e==t)return!1}}function xh(n){return n>=127462&&n<=127487}var bh=8205;function kh(n,e,t=!0,i=!0){return(t?Qh:eO)(n,e,i)}function Qh(n,e,t){if(e==n.length)return e;e&&vh(n.charCodeAt(e))&&$h(n.charCodeAt(e-1))&&e--;let i=po(n,e);for(e+=Sh(i);e=0&&xh(po(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function eO(n,e,t){for(;e>0;){let i=Qh(n,e-2,t);if(i=56320&&n<57344}function $h(n){return n>=55296&&n<56320}function Sh(n){return n<65536?1:2}var B=class n{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=$i(this,e,t);let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),ki.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=$i(this,e,t);let i=[];return this.decompose(e,t,i,0),ki.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new ti(this),r=new ti(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new ti(this,e)}iterRange(e,t=this.length){return new fs(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new us(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?n.empty:e.length<=32?new De(e):ki.from(De.split(e,[]))}},De=class n extends B{constructor(e,t=tO(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new go(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new n(Ph(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=cs(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new n(l,o.length+r.length));else{let a=l.length>>1;i.push(new n(l.slice(0,a)),new n(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof n))return super.replace(e,t,i);[e,t]=$i(this,e,t);let s=cs(this.text,cs(i.text,Ph(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new n(s,r):ki.from(n.split(s,[]),r)}sliceString(e,t=this.length,i=` `){[e,t]=$i(this,e,t);let s="";for(let r=0,o=0;r<=t&&oe&&o&&(s+=i),er&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let r of e)i.push(r),s+=r.length+1,i.length==32&&(t.push(new n(i,s)),i=[],s=-1);return s>-1&&t.push(new n(i,s)),t}},ki=class n extends B{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,s);s=l+1,i=a+1}}decompose(e,t,i,s){for(let r=0,o=0;o<=t&&r=o){let h=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=$i(this,e,t),i.lines=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>h>>6){let c=this.children.slice();return c[s]=a,new n(c,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` `){[e,t]=$i(this,e,t);let s="";for(let r=0,o=0;re&&r&&(s+=i),eo&&(s+=l.sliceString(e-o,t-o,i)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof n))return 0;let i=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return i;let a=this.children[s],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new De(d,t)}let s=Math.max(32,i>>5),r=s<<1,o=s>>1,l=[],a=0,h=-1,c=[];function f(d){let p;if(d.lines>r&&d instanceof n)for(let O of d.children)f(O);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof De&&a&&(p=c[c.length-1])instanceof De&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new De(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>s&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:n.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new n(l,t)}};B.empty=new De([""],0);function tO(n){let e=-1;for(let t of n)e+=t.length+1;return e}function cs(n,e,t=0,i=1e9){for(let s=0,r=0,o=!0;r=t&&(a>i&&(l=l.slice(0,i-s)),s0?1:(e instanceof De?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],o=r>>1,l=s instanceof De?s.text.length:s.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` `,this;e--}else if(s instanceof De){let a=s.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof De?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},fs=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new ti(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},us=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(B.prototype[Symbol.iterator]=function(){return this.iter()},ti.prototype[Symbol.iterator]=fs.prototype[Symbol.iterator]=us.prototype[Symbol.iterator]=function(){return this});var go=class{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}};function $i(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function re(n,e,t=!0,i=!0){return kh(n,e,t,i)}function iO(n){return n>=56320&&n<57344}function nO(n){return n>=55296&&n<56320}function Oe(n,e){let t=n.charCodeAt(e);if(!nO(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return iO(i)?(t-55296<<10)+(i-56320)+65536:t}function on(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function _e(n){return n<65536?1:2}var yo=/\r\n?|\n/,ce=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(ce||(ce={})),wt=class n{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-s);r+=l}else{if(i!=ce.Simple&&h>=e&&(i==ce.TrackDel&&se||i==ce.TrackBefore&&se))return null;if(h>e||h==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i=0&&s<=t&&l>=e)return st?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new n(e)}static create(e){return new n(e)}},Qe=class n extends wt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return xo(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return bo(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;i.length0&&Lt(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!s.length)return;ou||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?B.of(d.split(i||yo)):d:B.empty,O=p.length;if(f==u&&O==0)return;fo&&xe(s,f-o,-1),xe(s,u-f,O),Lt(r,s,p),o=u}}return h(e),a(!l),l}static empty(e){return new n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;sl&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length=0&&t<=0&&t==n[s+1]?n[s]+=e:s>=0&&e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function Lt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(s,h,r,c,f),s=h,r=c}}}function bo(n,e,t,i=!1){let s=[],r=i?[]:null,o=new ii(n),l=new ii(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);xe(s,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}var ii=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?B.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?B.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},wi=class n{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new n(i,s,this.flags)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return x.range(e,t,void 0,void 0,i);let s=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return x.range(this.anchor,s,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return x.range(e.anchor,e.head)}static create(e,t,i){return new n(e,t,i)}},x=class n{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:n.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new n(e.ranges.map(t=>wi.fromJSON(t)),e.main)}static single(e,t=e){return new n([n.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;ss.from-r.from),t=e.indexOf(i);for(let s=1;sr.head?n.range(a,l):n.range(l,a))}}return new n(e,t)}};function Rh(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Zo=0,P=class n{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=Zo++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new n(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Ao),!!e.static,e.enables)}of(e){return new Qi([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Qi(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Qi(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function Ao(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var Qi=class{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=Zo++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||So(f,c)){let d=i(f);if(l?!Th(d,f.values[o],s):!s(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[r];if(p!=null){let O=ms(u,p);if(this.dependencies.every(m=>m instanceof P?u.facet(m)===f.facet(m):m instanceof ne?u.field(m,!1)==f.field(m,!1):!0)||(l?Th(d=i(f),O,s):s(d=i(f),O)))return f.values[o]=O,0}else d=i(f);return f.values[o]=d,1}}}};function Th(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[a.id]),s=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;ci===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ls).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>{let r=i.facet(ls),o=s.facet(ls),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,ls.of({field:this,create:e})]}get extension(){return this}},Jt={lowest:4,low:3,default:2,high:1,highest:0};function en(n){return e=>new ds(e,n)}var Ue={highest:en(Jt.highest),high:en(Jt.high),default:en(Jt.default),low:en(Jt.low),lowest:en(Jt.lowest)},ds=class{constructor(e,t){this.inner=e,this.prec=t}},ps=class n{of(e){return new nn(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},nn=class{constructor(e,t){this.compartment=e,this.inner=t}},Os=class n{constructor(e,t,i,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let s=[],r=Object.create(null),o=new Map;for(let u of rO(e,t,o))u instanceof ne?s.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of s)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i?.config.facets;for(let u in r){let d=r[u],p=d[0].facet,O=c&&c[u]||[];if(d.every(m=>m.type==0))if(l[p.id]=a.length<<1|1,Ao(O,d))a.push(i.facet(p));else{let m=p.combine(d.map(g=>g.value));a.push(i&&p.compare(m,i.facet(p))?i.facet(p):m)}else{for(let m of d)m.type==0?(l[m.id]=a.length<<1|1,a.push(m.value)):(l[m.id]=h.length<<1,h.push(g=>m.dynamicSlot(g)));l[p.id]=h.length<<1,h.push(m=>sO(m,p,d))}}let f=h.map(u=>u(l));return new n(e,o,f,l,a,r)}};function rO(n,e,t){let i=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof nn&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof nn){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof ds)r(o.inner,o.prec);else if(o instanceof ne)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof Qi)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,Jt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(n,Jt.default),i.reduce((o,l)=>o.concat(l))}function tn(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let s=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|s}function ms(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var Xh=P.define(),wo=P.define({combine:n=>n.some(e=>e),static:!0}),Lh=P.define({combine:n=>n.length?n[0]:void 0,static:!0}),Eh=P.define(),Dh=P.define(),zh=P.define(),_h=P.define({combine:n=>n.length?n[0]:!1}),Ze=class{constructor(e,t){this.type=e,this.value=t}static define(){return new ko}},ko=class{of(e){return new Ze(this,e)}},Qo=class{constructor(e){this.map=e}of(e){return new E(this,e)}},E=class n{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new n(this.type,t)}is(e){return this.type==e}static define(e={}){return new Qo(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let r=s.map(t);r&&i.push(r)}return i}};E.reconfigure=E.define();E.appendConfig=E.define();var ae=class n{constructor(e,t,i,s,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Rh(i,t.newLength),r.some(l=>l.type==n.time)||(this.annotations=r.concat(n.time.of(Date.now())))}static create(e,t,i,s,r,o){return new n(e,t,i,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(n.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};ae.time=Ze.define();ae.userEvent=Ze.define();ae.addToHistory=Ze.define();ae.remote=Ze.define();function oO(n,e){let t=[];for(let i=0,s=0;;){let r,o;if(i=n[i]))r=n[i++],o=n[i++];else if(s=0;s--){let r=i[s](n);r instanceof ae?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof ae?n=r[0]:n=Bh(e,vi(r),!1)}return n}function aO(n){let e=n.startState,t=e.facet(zh),i=n;for(let s=t.length-1;s>=0;s--){let r=t[s](n);r&&Object.keys(r).length&&(i=Wh(i,vo(e,r,n.changes.newLength),!0))}return i==n?n:ae.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var hO=[];function vi(n){return n==null?hO:Array.isArray(n)?n:[n]}var F=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(F||(F={})),cO=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,$o;try{$o=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function fO(n){if($o)return $o.test(n);for(let e=0;e"\x80"&&(t.toUpperCase()!=t.toLowerCase()||cO.test(t)))return!0}return!1}function uO(n){return e=>{if(!/\S/.test(e))return F.Space;if(fO(e))return F.Word;for(let t=0;t-1)return F.Word;return F.Other}}var H=class n{constructor(e,t,i,s,r,o){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;ls.set(h,a)),t=null),s.set(l.value.compartment,l.value.extension)):l.is(E.reconfigure)?(t=null,i=l.value):l.is(E.appendConfig)&&(t=null,i=vi(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=Os.resolve(i,s,this),r=new n(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(wo)?e.newSelection:e.newSelection.asSingle();new n(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:x.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],o=vi(i.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return n.create({doc:e.doc,selection:x.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=Os.resolve(e.extensions||[],new Map),i=e.doc instanceof B?e.doc:B.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||yo)),s=e.selection?e.selection instanceof x?e.selection:x.single(e.selection.anchor,e.selection.head):x.single(0);return Rh(s,i.length),t.staticFacet(wo)||(s=s.asSingle()),new n(t,i,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(n.tabSize)}get lineBreak(){return this.facet(n.lineSeparator)||` `}get readOnly(){return this.facet(_h)}phrase(e,...t){for(let i of this.facet(n.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>t.length?i:t[r-1]})),e}languageDataAt(e,t,i=-1){let s=[];for(let r of this.facet(Xh))for(let o of r(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return uO(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=re(t,o,!1);if(r(t.slice(a,o))!=F.Word)break;o=a}for(;ln.length?n[0]:4});H.lineSeparator=Lh;H.readOnly=_h;H.phrases=P.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(s=>n[s]==e[s])}});H.languageData=Xh;H.changeFilter=Eh;H.transactionFilter=Dh;H.transactionExtender=zh;ps.reconfigure=E.define();function be(n,e,t={}){let i={};for(let s of n)for(let r of Object.keys(s)){let o=s[r],l=i[r];if(l===void 0)i[r]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,r))i[r]=t[r](l,o);else throw new Error("Config merge conflict for field "+r)}for(let s in e)i[s]===void 0&&(i[s]=e[s]);return i}var Ge=class{eq(e){return this==e}range(e,t=e){return sn.create(e,t,this)}};Ge.prototype.startSide=Ge.prototype.endSide=0;Ge.prototype.point=!1;Ge.prototype.mapMode=ce.TrackDel;function Mo(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}var sn=class n{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new n(e,t,i)}};function Po(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var To=class n{constructor(e,t,i,s){this.from=e,this.to=t,this.value=i,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,s=0){let r=i?this.to:this.from;for(let o=s,l=r.length;;){if(o==l)return o;let a=o+l>>1,h=r[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,i,s){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,r);rd||u==d&&h.startSide>0&&h.endSide<=0)continue;(d-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(l=Math.max(l,d-u)),i.push(h),s.push(u-o),r.push(d-o))}return{mapped:i.length?new n(s,r,i,l):null,pos:o}}},I=class n{constructor(e,t,i,s){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=s}static create(e,t,i,s){return new n(e,t,i,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:s=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(Po)),this.isEmpty)return t.length?n.of(t):this;let l=new gs(this,null,-1).goto(0),a=0,h=[],c=new ze;for(;l.value||a=0){let f=t[a++];c.addInner(f.from,f.to,f.value)||h.push(f)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||rl.to||r=r&&e<=r+o.length&&o.between(r,e-r,t-r,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return rn.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return rn.from(e).goto(t)}static compare(e,t,i,s,r=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),a=Ch(o,l,i),h=new ei(o,a,r),c=new ei(l,a,r);i.iterGaps((f,u,d)=>Zh(h,f,c,u,d,s)),i.empty&&i.length==0&&Zh(h,0,c,0,0,s)}static eq(e,t,i=0,s){s==null&&(s=999999999);let r=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=Ch(r,o),a=new ei(r,l,0).goto(i),h=new ei(o,l,0).goto(i);for(;;){if(a.to!=h.to||!Co(a.active,h.active)||a.point&&(!h.point||!Mo(a.point,h.point)))return!1;if(a.to>s)return!0;a.next(),h.next()}}static spans(e,t,i,s,r=-1){let o=new ei(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFroml&&(s.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new ze;for(let s of e instanceof sn?[e]:t?dO(e):e)i.add(s.from,s.to,s.value);return i.finish()}static join(e){if(!e.length)return n.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let s=e[i];s!=n.empty;s=s.nextLayer)t=new n(s.chunkPos,s.chunk,t,Math.max(s.maxPoint,t.maxPoint));return t}};I.empty=new I([],[],null,-1);function dO(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(Po);e=i}return n}I.empty.nextLayer=I.empty;var ze=class n{finishChunk(e){this.chunks.push(new To(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new n)).add(e,t,i)}addInner(e,t,i){let s=e-this.lastTo||i.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(I.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=I.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function Ch(n,e,t){let i=new Map;for(let r of n)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&s.push(new gs(o,t,i,r));return s.length==1?s[0]:new n(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)mo(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)mo(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),mo(this.heap,0)}}};function mo(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let s=n[i];if(i+1=0&&(s=n[i+1],i++),t.compare(s)<0)break;n[i]=t,n[e]=s,e=i}}var ei=class{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=rn.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){as(this.active,e),as(this.activeTo,e),as(this.activeRank,e),this.minActive=Ah(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:s,rank:r}=this.cursor;for(;t0;)t++;hs(this.active,t,i),hs(this.activeTo,t,s),hs(this.activeRank,t,r),e&&hs(e,t,this.cursor.from),this.minActive=Ah(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),i&&as(i,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[s]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}};function Zh(n,e,t,i,s,r){n.goto(e),t.goto(i);let o=i+s,l=i,a=i-e,h=!!r.boundChange;for(let c=!1;;){let f=n.to+a-t.to,u=f||n.endSide-t.endSide,d=u<0?n.to+a:t.to,p=Math.min(d,o);if(n.point||t.point?(n.point&&t.point&&Mo(n.point,t.point)&&Co(n.activeForPoint(n.to),t.activeForPoint(t.to))||r.comparePoint(l,p,n.point,t.point),c=!1):(c&&r.boundChange(l),p>l&&!Co(n.active,t.active)&&r.compareRange(l,p,n.active,t.active),h&&po)break;l=d,u<=0&&n.next(),u>=0&&t.next()}}function Co(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function Ah(n,e){let t=-1,i=1e9;for(let s=0;s=e)return s;if(s==n.length)break;r+=n.charCodeAt(s)==9?t-r%t:1,s=re(n,s)}return i===!0?-1:n.length}var Yh=typeof Symbol>"u"?"__\u037C":Symbol.for("\u037C"),Ro=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Ih=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Fe=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))r(d.split(/,\s*/).map(O=>o.map(m=>O.replace(/&/,m))).reduce((O,m)=>O.concat(m)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(s(d),p,c,u)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,O=>"-"+O.toLowerCase())+": "+p+";")}(c.length||u)&&a.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)r(s(o),e[o],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=Ih[Yh]||1;return Ih[Yh]=e+1,"\u037C"+e.toString(36)}static mount(e,t,i){let s=e[Ro],r=i&&i.nonce;s?r&&s.setNonce(r):s=new Xo(e,r),s.mount(Array.isArray(t)?t:[t],e)}},qh=new Map,Xo=class{constructor(e,t){let i=e.ownerDocument||e,s=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let r=qh.get(i);if(r)return e[Ro]=r;this.sheet=new s.CSSStyleSheet,qh.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Ro]=this}mount(e,t){let i=this.sheet,s=0,r=0;for(let o=0;o-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,l),i)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},pO=typeof navigator<"u"&&/Mac/.test(navigator.platform),OO=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(he=0;he<10;he++)Qt[48+he]=Qt[96+he]=String(he);var he;for(he=1;he<=24;he++)Qt[he+111]="F"+he;var he;for(he=65;he<=90;he++)Qt[he]=String.fromCharCode(he+32),Pi[he]=String.fromCharCode(he);var he;for(xs in Qt)Pi.hasOwnProperty(xs)||(Pi[xs]=Qt[xs]);var xs;function Vh(n){var e=pO&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||OO&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Pi:Qt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function V(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=t[i];typeof s=="string"?n.setAttribute(i,s):s!=null&&(n[i]=s)}e++}for(;e2),Z={mac:Uh||/Mac/.test(ve.platform),windows:/Win/.test(ve.platform),linux:/Linux|X11/.test(ve.platform),ie:Ks,ie_version:Ac?qo.documentMode||6:jo?+jo[1]:Vo?+Vo[1]:0,gecko:Nh,gecko_version:Nh?+(/Firefox\/(\d+)/.exec(ve.userAgent)||[0,0])[1]:0,chrome:!!Lo,chrome_version:Lo?+Lo[1]:0,ios:Uh,android:/Android\b/.test(ve.userAgent),webkit:Gh,webkit_version:Gh?+(/\bAppleWebKit\/(\d+)/.exec(ve.userAgent)||[0,0])[1]:0,safari:No,safari_version:No?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ve.userAgent)||[0,0])[1]:0,tabSize:qo.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function _l(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}var Xs=Object.create(null);function Wl(n,e,t){if(n==e)return!0;n||(n=Xs),e||(e=Xs);let i=Object.keys(n),s=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=s.length-(t&&s.indexOf(t)>-1?1:0))return!1;for(let r of i)if(r!=t&&(s.indexOf(r)==-1||n[r]!==e[r]))return!1;return!0}function mO(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function Fh(n,e,t){let i=!1;if(e)for(let s in e)t&&s in t||(i=!0,s=="style"?n.style.cssText="":n.removeAttribute(s));if(t)for(let s in t)e&&e[s]==t[s]||(i=!0,s=="style"?n.style.cssText=t[s]:n.setAttribute(s,t[s]));return i}function gO(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new oi(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,s;if(e.isBlockGap)i=-5e8,s=4e8;else{let{start:r,end:o}=Mc(e,t);i=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new oi(e,i,s,t,e.widget||null,!0)}static line(e){return new bn(e)}static set(e,t=!1){return I.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};R.none=I.empty;var xn=class n extends R{constructor(e){let{start:t,end:i}=Mc(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?_l(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Xs}eq(e){return this==e||e instanceof n&&this.tagName==e.tagName&&Wl(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};xn.prototype.point=!1;var bn=class n extends R{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&Wl(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};bn.prototype.mapMode=ce.TrackBefore;bn.prototype.point=!0;var oi=class n extends R{constructor(e,t,i,s,r,o){super(t,i,r,e),this.block=s,this.isReplace=o,this.mapMode=s?t<=0?ce.TrackBefore:ce.TrackAfter:ce.TrackDel}get type(){return this.startSide!=this.endSide?ge.WidgetRange:this.startSide<=0?ge.WidgetBefore:ge.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&yO(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};oi.prototype.point=!0;function Mc(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function yO(n,e){return n==e||!!(n&&e&&n.compare(e))}function Ri(n,e,t,i=0){let s=t.length-1;s>=0&&t[s]+i>=n?t[s]=Math.max(t[s],e):t.push(n,e)}var Ls=class n extends Ge{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof n&&this.tagName==e.tagName&&Wl(this.attributes,e.attributes)}static create(e){return new n(e.tagName,e.attributes||Xs)}static set(e,t=!1){return I.of(e,t)}};Ls.prototype.startSide=Ls.prototype.endSide=-1;function Sn(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function Go(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function cn(n,e){if(!e.anchorNode)return!1;try{return Go(n,e.anchorNode)}catch{return!1}}function Cs(n){return n.nodeType==3?wn(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function fn(n,e,t,i){return t?Hh(n,e,t,i,-1)||Hh(n,e,t,i,1):!1}function zt(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Es(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function Hh(n,e,t,i,s){for(;;){if(n==t&&e==i)return!0;if(e==(s<0?0:Pt(n))){if(n.nodeName=="DIV")return!1;let r=n.parentNode;if(!r||r.nodeType!=1)return!1;e=zt(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=s<0?Pt(n):0}else return!1}}function Pt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ds(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function xO(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Rc(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function bO(n,e,t,i,s,r,o,l){let a=n.ownerDocument,h=a.defaultView||window;for(let c=n,f=!1;c&&!f;)if(c.nodeType==1){let u,d=c==a.body,p=1,O=1;if(d)u=xO(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let S=c.getBoundingClientRect();({scaleX:p,scaleY:O}=Rc(c,S)),u={left:S.left,right:S.left+c.clientWidth*p,top:S.top,bottom:S.top+c.clientHeight*O}}let m=0,g=0;if(s=="nearest")e.top0&&e.bottom>u.bottom+g&&(g=e.bottom-u.bottom+o)):e.bottom>u.bottom&&(g=e.bottom-u.bottom+o,t<0&&e.top-g0&&e.right>u.right+m&&(m=e.right-u.right+r)):e.right>u.right&&(m=e.right-u.right+r,t<0&&e.leftu.bottom||e.leftu.right)&&(e={left:Math.max(e.left,u.left),right:Math.min(e.right,u.right),top:Math.max(e.top,u.top),bottom:Math.min(e.bottom,u.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function Xc(n,e=!0){let t=n.ownerDocument,i=null,s=null;for(let r=n.parentNode;r&&!(r==t.body||(!e||i)&&s);)if(r.nodeType==1)!s&&r.scrollHeight>r.clientHeight&&(s=r),e&&!i&&r.scrollWidth>r.clientWidth&&(i=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:i,y:s}}var Uo=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?Pt(t):0),i,Math.min(e.focusOffset,i?Pt(i):0))}set(e,t,i,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=s}},ni=null;Z.safari&&Z.safari_version>=26&&(ni=!1);function Lc(n){if(n.setActive)return n.setActive();if(ni)return n.focus(ni);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(ni==null?{get preventScroll(){return ni={preventScroll:!0},!0}}:void 0),!ni){ni=!1;for(let t=0;tMath.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function Dc(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=Pt(t)}else if(t.parentNode&&!Es(t))i=zt(t),t=t.parentNode;else return null}}function zc(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i=t){if(l.level==i)return o;(r<0||(s!=0?s<0?l.fromt:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}};function Bc(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;O-=3)if(yt[O+1]==-d){let m=yt[O+2],g=m&2?s:m&4?m&1?r:s:0;g&&(K[f]=K[yt[O]]=g),l=O;break}}else{if(yt.length==189)break;yt[l++]=f,yt[l++]=u,yt[l++]=a}else if((p=K[f])==2||p==1){let O=p==s;a=O?0:1;for(let m=l-3;m>=0;m-=3){let g=yt[m+2];if(g&2)break;if(O)yt[m+2]|=2;else{if(g&4)break;yt[m+2]|=4}}}}}function TO(n,e,t,i){for(let s=0,r=i;s<=t.length;s++){let o=s?t[s-1].to:n,l=sa;)p==m&&(p=t[--O].from,m=O?t[O-1].to:n),K[--p]=d;a=c}else r=h,a++}}}function Ho(n,e,t,i,s,r,o){let l=i%2?2:1;if(i%2==s%2)for(let a=e,h=0;aa&&o.push(new Je(a,O.from,d));let m=O.direction==li!=!(d%2);Ko(n,m?i+1:i,s,O.inner,O.from,O.to,o),a=O.to}p=O.to}else{if(p==t||(c?K[p]!=l:K[p]==l))break;p++}u?Ho(n,a,p,i+1,s,u,o):ae;){let c=!0,f=!1;if(!h||a>r[h-1].to){let O=K[a-1];O!=l&&(c=!1,f=O==16)}let u=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(h&&p==r[h-1].to){if(f)break e;let O=r[--h];if(!c)for(let m=O.from,g=h;;){if(m==e)break e;if(g&&r[g-1].to==m)m=r[--g].from;else{if(K[m-1]==l)break e;break}}if(u)u.push(O);else{O.toK.length;)K[K.length]=256;let i=[],s=e==li?0:1;return Ko(n,s,s,t,0,n.length,i),i}function Yc(n){return[new Je(0,n,0)]}var Ic="";function ZO(n,e,t,i,s){var r;let o=i.head-n.from,l=Je.find(e,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),a=e[l],h=a.side(s,t);if(o==h){let u=l+=s?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!s,t),h=a.side(s,t)}let c=re(n.text,o,a.forward(s,t));(ca.to)&&(c=h),Ic=n.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return f&&c==h&&f.level+(s?0:1)n.some(e=>e)}),Hc=P.define({combine:n=>n.some(e=>e)}),Kc=P.define(),un=class n{constructor(e,t="nearest",i="nearest",s=5,r=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=s,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new n(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new n(x.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},bs=E.define({map:(n,e)=>n.map(e)}),Jc=E.define();function me(n,e,t){let i=n.facet(Nc);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}var vt=P.define({combine:n=>n.length?n[0]:!0}),MO=0,Ci=P.define({combine(n){return n.filter((e,t)=>{for(let i=0;i{let a=[];return o&&a.push(Js.of(h=>{let c=h.plugin(l);return c?o(c):R.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return n.define((i,s)=>new e(i,s),t)}},dn=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(me(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){me(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){me(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},ef=P.define(),ql=P.define(),Js=P.define(),tf=P.define(),Vl=P.define(),kn=P.define(),nf=P.define();function Jh(n,e){let t=n.state.facet(nf);if(!t.length)return t;let i=t.map(r=>r instanceof Function?r(n):r),s=[];return I.spans(i,e.from,e.to,{point(){},span(r,o,l,a){let h=r-e.from,c=o-e.from,f=s;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=AO(e.text,h,c)),a>0&&f.length&&(p=f[f.length-1]).to==h&&p.direction==d)p.to=c,f=p.inner;else{let O={from:h,to:c,direction:d,inner:[]};f.push(O),f=O.inner}}}}),s}var sf=P.define();function jl(n){let e=0,t=0,i=0,s=0;for(let r of n.state.facet(sf)){let o=r(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:e,right:t,top:i,bottom:s}}var ln=P.define(),rt=class n{constructor(e,t,i,s){this.fromA=e,this.toA=t,this.fromB=i,this.toB=s}join(e){return new n(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let s=e[t-1];if(!(s.fromA>i.toA)){if(s.toAs.push(new rt(r,o,l,a))),this.changedRanges=s}static create(e,t,i){return new n(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},RO=[],te=class{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return RO}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&mO(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let s of this.children){if(s==e)return i;i+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let i=zt(this.dom),s=this.length?e>0:t>0;return new xt(this.parent.dom,i+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Ei)return e;return null}static get(e){return e.cmTile}},Li=class extends te{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,s,r=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,s=i?i.nextSibling:t.firstChild,r&&s!=l.dom&&(r.written=!0),l.dom.parentNode==t)for(;s&&s!=l.dom;)s=ec(s);else t.insertBefore(l.dom,s);i=l.dom}for(s=i?i.nextSibling:t.firstChild,r&&s&&(r.written=!0);s;)s=ec(s);this.length=o}};function ec(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Ei=class extends Li{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=te.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,s=0,r=0;;)if(s==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&r++,s=t.pop()}else{let o=i.children[s++];if(o instanceof $t)t.push(s),i=o,s=0;else{let l=r+o.length,a=e(o,r);if(a!==void 0)return a;r=l+o.breakAfter}}}resolveBlock(e,t){let i,s=-1,r,o=-1;if(this.blockTiles((l,a)=>{let h=a+l.length;if(e>=a&&e<=h){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(ae||e==a&&(t>1?l.length:l.covers(-1)))&&(!r||!l.isWidget()&&r.isWidget())&&(r=l,o=e-a)}}),!i&&!r)throw new Error("No tile at position "+e);return i&&t<0||!r?{tile:i,offset:s}:{tile:r,offset:o}}},$t=class n extends Li{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new n(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}},Di=class n extends Li{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let s=new n(t||document.createElement("div"),e);return(!t||!i)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,t,i){let s=null,r=-1,o=null,l=-1;function a(c,f){for(let u=0,d=0;u=f&&(p.isComposite()?a(p,f-d):(!o||o.isHidden&&(t>0||i&&LO(o,p)))&&(O>f||p.flags&32)?(o=p,l=f-d):(di&&(e=i);let s=e,r=e,o=0;e==0&&t<0||e==i&&t>=0?Z.chrome||Z.gecko||(e?(s--,o=1):r=0)?0:l.length-1];return Z.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?Ds(a,o<0):a||null}static of(e,t){let i=new n(t||document.createTextNode(e),e);return t||(i.flags|=2),i}},ai=class n extends te{constructor(e,t,i,s){super(e,t,s),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let s=this.widget.coordsAt(this.dom,e,t);if(s)return s;if(i)return Ds(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let r=this.dom.getClientRects(),o=null;if(!r.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?r.length-1:0;o=r[a],!(e>0?a==0:a==r.length-1||o.top0;)if(s.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(r==s.children.length){if(!e&&!l.length)break;i&&i.leave(s),o=!!s.breakAfter,{tile:s,index:r}=l.pop(),r++}else{let a=s.children[r],h=a.breakAfter;(t>0?a.length<=e:a.length=0;l--){let a=t.marks[l],h=s.lastChild;if(h instanceof Ae&&h.mark.eq(a.mark))h.dom!=a.dom&&h.setDOM(Eo(a.dom)),s=h;else{if(this.cache.reused.get(a)){let f=te.get(a.dom);f&&f.setDOM(Eo(a.dom))}let c=Ae.of(a.mark,a.dom);s.append(c),s=c}this.cache.reused.set(a,2)}let r=te.get(e.text);r&&this.cache.reused.set(r,2);let o=new si(e.text,e.text.nodeValue);o.flags|=8,s.append(o)}addInlineWidget(e,t,i){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let r=this.ensureMarks(t,i);!s&&!(e.flags&16)&&r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=rf);let s=Di.start(e,t||((i=this.cache.find(Di))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let s=this.curLine;for(let r=e.length-1;r>=0;r--){let o=e[r],l;if(t>0&&(l=s.lastChild)&&l instanceof Ae&&l.mark.eq(o))s=l,t--;else{let a=Ae.of(o,(i=this.cache.find(Ae,h=>h.mark.eq(o)))===null||i===void 0?void 0:i.dom);s.append(a),s=a,t=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!tc(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Z.ios&&tc(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Do,0,32)||new ai(Do.toDOM(),0,Do,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let t=new tl(e.from,e.to,e.value,e.rank),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-t.rank||this.wrappers[i-1].to-t.to)<0;)i--;this.wrappers.splice(i,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let s=t.lastChild;if(i.fromo.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(zi,void 0,1);return i&&(i.flags=t),i||new zi(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},nl=class{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:r,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=s;let l=this.textOff=Math.min(e,s.length);return r?null:s.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}},_s=[ai,Di,si,Ae,zi,$t,Ei];for(let n=0;n<_s.length;n++)_s[n].bucket=n;var sl=class{constructor(e){this.view=e,this.buckets=_s.map(()=>[]),this.index=_s.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let s=e.bucket,r=this.buckets[s],o=this.index[s];for(let l=r.length-1;l>=0;l--){let a=(l+o)%r.length,h=r[a];if((!t||t(h))&&!this.reused.has(h))return r.splice(a,1),a{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let s=0,r=0,o=0;;){let l=os){let h=a-s;this.preserve(h,!o,!l),s=a,r+=h}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let h=a>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Ae&&s.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?s.length&&(s.length=r=0):o instanceof Ae&&(s.shift(),r=Math.min(r,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,s=this.builder,r=0,o=I.spans(this.decorations,e,t,{point:(l,a,h,c,f,u)=>{if(h instanceof oi){if(this.disallowBlockEffectsFor[u]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=c.length,f>c.length)s.continueWidget(a-l);else{let d=h.widget||(h.block?_t.block:_t.inline),p=EO(h),O=this.cache.findWidget(d,a-l,p)||ai.of(d,this.view,a-l,p);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(i),s.addBlockWidget(O)):(s.ensureLine(i),s.addInlineWidget(O,c,f))}i=null}else i=DO(i,h);a>l&&this.text.skip(a-l)},span:(l,a,h,c)=>{for(let f=l;fr,this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let s=e.parentNode;;s=s.parentNode){let r=te.get(s);if(s==this.view.contentDOM)break;r instanceof Ae?t.push(r):r?.isLine()?i=r:r instanceof $t||(s.nodeName=="DIV"&&!i&&s!=this.view.contentDOM?i=new Di(s,rf):i||t.push(Ae.of(new xn({tagName:s.nodeName.toLowerCase(),attributes:gO(s)}),s)))}return{line:i,marks:t}}};function tc(n,e){let t=i=>{for(let s of i.children)if((e?s.isText():s.length)||t(s))return!0;return!1};return t(n)}function EO(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}var rf={class:"cm-line"};function DO(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&_l(t,n),i&&(n.class+=" "+i)),n}function zO(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof Ae&&e.push(i.mark)}return e}function Eo(n){let e=te.get(n);return e&&e.setDOM(n.cloneNode()),n}var _t=class extends $e{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};_t.inline=new _t("span");_t.block=new _t("div");var Do=new class extends $e{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},Ws=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=R.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Ei(e,e.contentDOM),this.updateInner([new rt(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:c,toA:f})=>fthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?s=this.domChanged.newSel.head:!jO(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let r=s>-1?WO(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;i=new rt(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(Z.ie||Z.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=IO(o,this.decorations,e.changes);a.length&&(i=rt.extendWithRanges(i,a));let h=qO(l,this.blockWrappers,e.changes);return h.length&&(i=rt.extendWithRanges(i,h)),r&&!i.some(c=>c.fromA<=r.range.fromA&&c.toA>=r.range.toA)&&(i=r.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,l=new rl(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&te.get(t.text)&&l.cache.reused.set(te.get(t.text),2),this.tile=l.run(e,t),ol(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=Z.chrome||Z.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||i.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&cn(i,this.view.observer.selectionRange)&&!(s&&i.contains(s));if(!(r||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,c;if(a.empty?c=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),Z.gecko&&a.empty&&!this.hasComposition&&_O(h)){let u=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(u,h.node.childNodes[h.offset]||null)),h=c=new xt(u,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!fn(h.node,h.offset,f.anchorNode,f.anchorOffset)||!fn(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{Z.android&&Z.chrome&&i.contains(f.focusNode)&&VO(f.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let u=Sn(this.view.root);if(u)if(a.empty){if(Z.gecko){let d=BO(h.node,h.offset);if(d&&d!=3){let p=(d==1?Dc:zc)(h.node,h.offset);p&&(h=new xt(p.node,p.offset))}}u.collapse(h.node,h.offset),a.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=a.bidiLevel)}else if(u.extend){u.collapse(h.node,h.offset);try{u.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([h,c]=[c,h]),d.setEnd(c.node,c.offset),d.setStart(h.node,h.offset),u.removeAllRanges(),u.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,c)),this.impreciseAnchor=h.precise?null:new xt(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new xt(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&fn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Sn(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&i.collapse(s,r)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=i.posAtStart;if(i.isComposite()){let r;if(e==i.dom)r=i.dom.childNodes[t];else{let o=Pt(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?r=e:r=e.nextSibling}if(r==i.dom.firstChild)return s;for(;r&&!te.get(r);)r=r.nextSibling;if(!r)return s+i.length;for(let o=0,l=s;;o++){let a=i.children[o];if(a.dom==r)return l;l+=a.length+a.breakAfter}}else return i.isText()?e==i.dom?s+t:s+(t?i.length:0):s}domAtPos(e,t){let{tile:i,offset:s}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(e,t):i.domIn(s,t)}inlineDOMNearPos(e,t){let i,s=-1,r=!1,o,l=-1,a=!1;return this.tile.blockTiles((h,c)=>{if(h.isWidget()){if(h.flags&32&&c>=e)return!0;h.flags&16&&(r=!0)}else{let f=c+h.length;if(c<=e&&(i=h,s=e-c,r=f=e&&!o&&(o=h,l=e-c,a=c>e),c>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(r&&o?i=null:a&&i&&(o=null),i&&t<0||!o?i.domIn(s,t):o.domIn(l,t))}coordsAt(e,t){let{tile:i,offset:s}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof pn?null:i.coordsInWidget(s,t,!0):i.coordsIn(s,t)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function s(r,o){if(r.isComposite())for(let l of r.children){if(l.length>=o){let a=s(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(r.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==N.LTR,h=0,c=(f,u,d)=>{for(let p=0;ps);p++){let O=f.children[p],m=u+O.length,g=O.dom.getBoundingClientRect(),{height:S}=g;if(d&&!p&&(h+=g.top-d.top),O instanceof $t)m>i&&c(O,u,g);else if(u>=i&&(h>0&&t.push(-h),t.push(S+h),h=0,o)){let b=O.dom.lastChild,A=b?Cs(b):[];if(A.length){let w=A[A.length-1],v=a?w.right-g.left:g.right-w.left;v>l&&(l=v,this.minWidth=r,this.minWidthFrom=u,this.minWidthTo=m)}}d&&p==f.children.length-1&&(h+=d.bottom-g.bottom),u=m+O.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?N.RTL:N.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let c=Cs(h.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),i,s,r;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=Cs(t.firstChild)[0];i=t.getBoundingClientRect().height,s=o&&o.width?o.width/27:7,r=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:s,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,s=0;;s++){let r=s==t.viewports.length?null:t.viewports[s],o=r?r.from-1:this.view.state.doc.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(R.replace({widget:new pn(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return R.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Js).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),i=!1,s=this.view.state.facet(Vl).map((r,o)=>{let l=typeof r=="function";return l&&(i=!0),l?r(this.view):r});for(s.length&&(this.dynamicDecorationMap[e++]=i,t.push(I.join(s))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof r=="function"?r(this.view):r)}scrollIntoView(e){var t;if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(Kc))try{if(c(this.view,e.range,e))return!0}catch(f){me(this.view.state,f,"scroll handler")}let{range:i}=e,s=this.coordsAt(i.head,(t=i.assoc)!==null&&t!==void 0?t:i.empty?0:i.head>i.anchor?-1:1),r;if(!s)return;!i.empty&&(r=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(s={left:Math.min(s.left,r.left),top:Math.min(s.top,r.top),right:Math.max(s.right,r.right),bottom:Math.max(s.bottom,r.bottom)});let o=jl(this.view),l={left:s.left-o.left,top:s.top-o.top,right:s.right+o.right,bottom:s.bottom+o.bottom},{offsetWidth:a,offsetHeight:h}=this.view.scrollDOM;if(bO(this.view.scrollDOM,l,i.head1&&(s.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||s.bottomi.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){ol(this.tile)}};function ol(n,e){let t=e?.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)ol(i,e)}}function _O(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function of(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=Dc(t.focusNode,t.focusOffset),s=zc(t.focusNode,t.focusOffset),r=i||s;if(s&&i&&s.node!=i.node){let l=te.get(s.node);if(!l||l.isText()&&l.text!=s.node.nodeValue)r=s;else if(n.docView.lastCompositionAfterCursor){let a=te.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(r=s)}}if(n.docView.lastCompositionAfterCursor=r!=i,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function WO(n,e,t){let i=of(n,t);if(!i)return null;let{node:s,from:r,to:o}=i,l=s.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc;return{range:new rt(a.mapPos(r),a.mapPos(o),r,o),text:s}}function BO(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}var pn=class extends $e{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function NO(n,e,t=1){let i=n.charCategorizer(e),s=n.doc.lineAt(e),r=e-s.from;if(s.length==0)return x.cursor(e);r==0?t=1:r==s.length&&(t=-1);let o=r,l=r;t<0?o=re(s.text,r,!1):l=re(s.text,r);let a=i(s.text.slice(o,l));for(;o>0;){let h=re(s.text,o,!1);if(i(s.text.slice(h,o))!=a)break;o=h}for(;ln.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((s-t.top-(n.defaultLineHeight-l)*.5)/l);r+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+ys(o,r,n.state.tabSize)}function al(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let s;for(let r of i.type){if(r.from>e)break;if(!(r.toe)return r;(!s||r.type==ge.Text&&(s.type!=r.type||(t<0?r.frome)))&&(s=r)}}return s||i}return i}function UO(n,e,t,i){let s=al(n,e.head,e.assoc||-1),r=!i||s.type!=ge.Text||!(n.lineWrapping||s.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(r){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(s.from),a=n.posAtCoords({x:t==(l==N.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return x.cursor(a,t?-1:1)}return x.cursor(t?s.to:s.from,t?-1:1)}function ic(n,e,t,i){let s=n.state.doc.lineAt(e.head),r=n.bidiSpans(s),o=n.textDirectionAt(s.from);for(let l=e,a=null;;){let h=ZO(s,r,o,l,t),c=Ic;if(!h){if(s.number==(t?n.state.doc.lines:1))return l;c=` `,s=n.state.doc.line(s.number+(t?1:-1)),r=n.bidiSpans(s),h=n.visualLineSide(s,!t)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function FO(n,e,t){let i=n.state.charCategorizer(e),s=i(t);return r=>{let o=i(r);return s==F.Space&&(s=o),s==o}}function HO(n,e,t,i){let s=e.head,r=t?1:-1;if(s==(t?n.state.doc.length:0))return x.cursor(s,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(s,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),c=n.documentTop;if(h)o==null&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let p=n.viewState.lineBlockAt(s);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(s-p.from))),l=(r<0?p.top:p.bottom)+c}let f=a.left+o,u=n.viewState.heightOracle.textHeight>>1,d=i??u;for(let p=0;;p+=u){let O=l+(d+p)*r,m=hl(n,{x:f,y:O},!1,r);if(t?O>a.bottom:Ol:S{if(e>r&&es(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:x.cursor(i,in.viewState.docHeight)return new Ke(n.state.doc.length,-1);if(h=n.elementAtHeight(a),i==null)break;if(h.type==ge.Text){if(i<0?h.ton.viewport.to)break;let u=n.docView.coordsAt(i<0?h.from:h.to,i>0?-1:1);if(u&&(i<0?u.top<=a+r:u.bottom>=a+r))break}let f=n.viewState.heightOracle.textHeight/2;a=i>0?h.bottom+f:h.top-f}if(n.viewport.from>=h.to||n.viewport.to<=h.from){if(t)return null;if(h.type==ge.Text){let f=GO(n,s,h,o,l);return new Ke(f,f==h.from?1:-1)}}if(h.type!=ge.Text)return a<(h.top+h.bottom)/2?new Ke(h.from,1):new Ke(h.to,-1);let c=n.docView.lineAt(h.from,2);return(!c||c.length!=h.length)&&(c=n.docView.lineAt(h.from,-2)),new cl(n,o,l,n.textDirectionAt(h.from)).scanTile(c,h.from)}var cl=class{constructor(e,t,i,s){this.view=e,this.x=t,this.y=i,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+s.from>1;t:if(r.has(p)){let m=i+Math.floor(Math.random()*d);for(let g=0;g1)){if(g.bottomthis.y)(!a||a.top>g.top)&&(a=g),S=-1;else{let b=g.left>this.x?this.x-g.left:g.right(f.left+f.right)/2==u}}scanText(e,t){let i=[];for(let r=0;r{let o=i[r]-t,l=i[r+1]-t;return wn(e.dom,o,l).getClientRects()});return s.after?new Ke(i[s.i+1],-1):new Ke(i[s.i],1)}scanTile(e,t){if(!e.length)return new Ke(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let i=[t];for(let l=0,a=t;l{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:wn(a.dom,0,a.length)).getClientRects()}),r=e.children[s.i],o=i[s.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):s.after?new Ke(i[s.i+1],-1):new Ke(o,1)}},Ti="\uFFFF",fl=class{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(H.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ti}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let s=e;;){this.findPointBefore(i,s);let r=this.text.length;this.readNode(s);let o=te.get(s),l=s.nextSibling;if(l==t){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=te.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Es(s))||Es(l)&&(s.nodeName!="BR"||o?.isWidget())&&this.text.length>r)&&!JO(l,t)&&this.lineBreak(),s=l}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=s.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(e){let t=te.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let s=i.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(KO(e,i.node,i.offset)?t:0))}};function KO(n,e,t){for(;;){if(!e||t-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=af(e.docView.tile,t,i,0))){let a=r||o?[]:tm(e),h=new fl(a,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=im(a,this.bounds.from)}else{let a=e.observer.selectionRange,h=r&&r.node==a.focusNode&&r.offset==a.focusOffset||!Go(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!Go(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((Z.ios||Z.chrome)&&l.main.empty&&h!=c&&(f.from>0||f.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(x.range(c,h));else if(e.lineWrapping&&c==h&&!(l.main.empty&&l.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let u=e.coordsAtPos(h,-1),d=0;u&&(d=e.inputState.lastTouchY<=u.bottom?-1:1),this.newSel=x.create([x.cursor(h,d)])}else this.newSel=x.single(c,h)}}};function af(n,e,t,i){if(n.isComposite()){let s=-1,r=-1,o=-1,l=-1;for(let a=0,h=i,c=i;at)return af(f,e,t,h);if(u>=e&&s==-1&&(s=a,r=h),h>t&&f.dom.parentNode==n.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:r,to:l<0?i+n.length:l,startDOM:(s?n.children[s-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:o=0?n.children[o].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function hf(n,e){let t,{newSel:i}=e,{state:s}=n,r=s.selection.main,o=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,h=r.from,c=null;(o===8||Z.android&&e.text.length=l&&r.to<=a&&(e.typeOver||f!=e.text)&&f.slice(0,r.from-l)==e.text.slice(0,r.from-l)&&f.slice(r.to-l)==e.text.slice(u=e.text.length-(f.length-(r.to-l)))?t={from:r.from,to:r.to,insert:B.of(e.text.slice(r.from-l,u).split(Ti))}:(d=cf(f,e.text,h-l,c))&&(Z.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==Ti+Ti&&d.toB--,t={from:l+d.from,to:l+d.toA,insert:B.of(e.text.slice(d.from,d.toB).split(Ti))})}else i&&(!n.hasFocus&&s.facet(vt)||Ys(i,r))&&(i=null);if(!t&&!i)return!1;if((Z.mac||Z.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=x.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:B.of([t.insert.toString().replace("."," ")])}):s.doc.lineAt(r.from).toDate.now()-50?t={from:r.from,to:r.to,insert:s.toText(n.inputState.insertingText)}:Z.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==` `&&n.lineWrapping&&(i&&(i=x.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:B.of([" "])}),t)return Nl(n,t,i,o);if(i&&!Ys(i,r)){let l=!1,a="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(l=!0),a=n.inputState.lastSelectionOrigin,a=="select.pointer"&&(i=lf(s.facet(kn).map(h=>h(n)),i))),n.dispatch({selection:i,scrollIntoView:l,userEvent:a}),!0}else return!1}function Nl(n,e,t,i=-1){if(Z.ios&&n.inputState.flushIOSKey(e))return!0;let s=n.state.selection.main;if(Z.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&n.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Xi(n.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||i==8&&e.insert.lengths.head)&&Xi(n.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&Xi(n.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,l=()=>o||(o=em(n,e,t));return n.state.facet(Gc).some(a=>a(n,e.from,e.to,r,l))||n.dispatch(l()),!0}function em(n,e,t){let i,s=n.state,r=s.selection.main,o=-1;if(e.from==e.to&&e.fromr.to){let a=e.fromf(n)),h,a);e.from==c&&(o=c)}if(o>-1)i={changes:e,selection:x.cursor(e.from+e.insert.length,-1)};else if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let a=r.frome.to?s.sliceDoc(e.to,r.to):"";i=s.replaceSelection(n.state.toText(a+e.insert.sliceString(0,void 0,n.state.lineBreak)+h))}else{let a=s.changes(e),h=t&&t.main.to<=a.newLength?t.main:void 0;if(s.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=r.to+10&&e.to>=r.to-10){let c=n.state.sliceDoc(e.from,e.to),f,u=t&&of(n,t.main.head);if(u){let p=e.insert.length-(e.to-e.from);f={from:u.from,to:u.to-p}}else f=n.state.doc.lineAt(r.head);let d=r.to-e.to;i=s.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:a,range:h||p.map(a)};let O=p.to-d,m=O-c.length;if(n.state.sliceDoc(m,O)!=c||O>=f.from&&m<=f.to)return{range:p};let g=s.changes({from:m,to:O,insert:e.insert}),S=p.to-r.to;return{changes:g,range:h?x.range(Math.max(0,h.anchor+S),Math.max(0,h.head+S)):p.map(g)}})}else i={changes:a,selection:h&&s.selection.replaceRange(h)}}let l="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,l+=".compose",n.inputState.compositionFirstChange&&(l+=".start",n.inputState.compositionFirstChange=!1)),s.update(i,{userEvent:l,scrollIntoView:!0})}function cf(n,e,t,i){let s=Math.min(n.length,e.length),r=0;for(;r0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function tm(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}=n.observer.selectionRange;return t&&(e.push(new Bs(t,i)),(s!=t||r!=i)&&e.push(new Bs(s,r))),e}function im(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?x.single(t+e,i+e):null}function Ys(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}var dl=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Z.safari&&e.contentDOM.addEventListener("input",()=>null),Z.gecko&&mm(e.contentDOM.ownerDocument)}handleEvent(e){!hm(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let s of i.observers)s(this.view,t);for(let s of i.handlers){if(t.defaultPrevented)break;if(s(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=nm(e),i=this.handlers,s=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=i[r];l&&o!=!l.handlers.length&&(s.removeEventListener(r,this.handleEvent),l=null),l||s.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!t[r]&&s.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&uf.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Z.android&&Z.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return Z.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=ff.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||sm.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:Z.safari&&!Z.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function nc(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(s){me(t.state,s)}}}function nm(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let s=i.spec,r=s&&s.plugin.domEventHandlers,o=s&&s.plugin.domEventObservers;if(r)for(let l in r){let a=r[l];a&&t(l).handlers.push(nc(i.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(nc(i.value,a))}}for(let i in ot)t(i).handlers.push(ot[i]);for(let i in Me)t(i).observers.push(Me[i]);return e}var ff=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],sm="dthko",uf=[16,17,18,20,91,92,224,225],Ss=6;function ws(n){return Math.max(0,n)*.7+8}function rm(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var pl=class{constructor(e,t,i,s){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Xc(e.contentDOM),this.atoms=e.state.facet(kn).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(H.allowMultipleSelections)&&om(e,t),this.dragging=am(e,t)&&Of(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&rm(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,s=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=jl(this.view);e.clientX-a.left<=s+Ss?t=-ws(s-e.clientX):e.clientX+a.right>=o-Ss&&(t=ws(e.clientX-o)),e.clientY-a.top<=r+Ss?i=-ws(r-e.clientY):e.clientY+a.bottom>=l-Ss&&(i=ws(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=lf(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function om(n,e){let t=n.state.facet(qc);return t.length?t[0](e):Z.mac?e.metaKey:e.ctrlKey}function lm(n,e){let t=n.state.facet(Vc);return t.length?t[0](e):Z.mac?!e.altKey:!e.ctrlKey}function am(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=Sn(n.root);if(!i||i.rangeCount==0)return!0;let s=i.getRangeAt(0).getClientRects();for(let r=0;r=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function hm(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=te.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}var ot=Object.create(null),Me=Object.create(null),df=Z.ie&&Z.ie_version<15||Z.ios&&Z.webkit_version<604;function cm(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),pf(n,t.value)},50)}function er(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function pf(n,e){e=er(n.state,Yl,e);let{state:t}=n,i,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(Ol!=null&&t.selection.ranges.every(a=>a.empty)&&Ol==r.toString()){let a=-1;i=t.changeByRange(h=>{let c=t.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let f=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:x.cursor(h.from+f.length)}})}else o?i=t.changeByRange(a=>{let h=r.line(s++);return{changes:{from:a.from,to:a.to,insert:h.text},range:x.cursor(a.from+h.length)}}):i=t.replaceSelection(r);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Me.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};Me.wheel=Me.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};ot.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);Me.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};Me.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};ot.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(jc))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=um(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new pl(n,e,t,i)),i&&n.observer.ignore(()=>{Lc(n.contentDOM);let r=n.root.activeElement;r&&!r.contains(n.contentDOM)&&r.blur()});let s=n.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function sc(n,e,t,i){if(i==1)return x.cursor(e,t);if(i==2)return NO(n.state,e,t);{let s=n.docView.lineAt(e,t),r=n.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,l=s?s.posAtEnd:r.to;return lDate.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(oc+1)%3:1}function um(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=Of(e),s=n.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),s=s.map(r.changes))},get(r,o,l){let a=n.posAndSideAtCoords({x:r.clientX,y:r.clientY},!1),h,c=sc(n,a.pos,a.assoc,i);if(t.pos!=a.pos&&!o){let f=sc(n,t.pos,t.assoc,i),u=Math.min(f.from,c.from),d=Math.max(f.to,c.to);c=u1&&(h=dm(s,a.pos))?h:l?s.addRange(c):x.create([c])}}}function dm(n,e){for(let t=0;t=e)return x.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}ot.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let s=n.docView.tile.nearest(e.target);if(s&&s.isWidget()){let r=s.posAtStart,o=r+s.length;(r>=t.to||o<=t.from)&&(t=x.range(r,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",er(n.state,Il,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};ot.dragend=n=>(n.inputState.draggedContent=null,!1);function ac(n,e,t,i){if(t=er(n.state,Yl,t),!t)return;let s=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=n.inputState,o=i&&r&&lm(n,e)?{from:r.from,to:r.to}:null,l={from:s,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}ot.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),s=0,r=()=>{++s==t.length&&ac(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return ac(n,e,i,!0),!0}return!1};ot.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=df?null:e.clipboardData;return t?(pf(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(cm(n),!1)};function pm(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function Om(n){let e=[],t=[],i=!1;for(let s of n.selection.ranges)s.empty||(e.push(n.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:r}of n.selection.ranges){let o=n.doc.lineAt(r);o.number>s&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),s=o.number}i=!0}return{text:er(n,Il,e.join(n.lineBreak)),ranges:t,linewise:i}}var Ol=null;ot.copy=ot.cut=(n,e)=>{if(!cn(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:s}=Om(n.state);if(!t&&!s)return!1;Ol=s?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=df?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(pm(n,t),!1)};var mf=Ze.define();function gf(n,e){let t=[];for(let i of n.facet(Uc)){let s=i(n,e);s&&t.push(s)}return t.length?n.update({effects:t,annotations:mf.of(!0)}):null}function yf(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=gf(n.state,e);t?n.dispatch(t):n.update([])}},10)}Me.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),yf(n)};Me.blur=n=>{n.observer.clearSelectionRange(),yf(n)};Me.compositionstart=Me.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};Me.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,Z.chrome&&Z.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};Me.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};ot.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let l=o[0],a=n.posAtDOM(l.startContainer,l.startOffset),h=n.posAtDOM(l.endContainer,l.endOffset);return Nl(n,{from:a,to:h,insert:n.state.toText(r)},null),!0}}let s;if(Z.chrome&&Z.android&&(s=ff.find(r=>r.inputType==e.inputType))&&(n.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let r=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return Z.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),Z.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>Me.compositionend(n,e),20),!1};var hc=new Set;function mm(n){hc.has(n)||(hc.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var cc=["pre-wrap","normal","pre-line","break-spaces"],_i=!1;function fc(){_i=!1}var ml=class{constructor(e){this.lineWrapping=e,this.doc=B.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return cc.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l||Math.abs(i-this.charWidth)>.1;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=s,this.lineLength=r,a){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Zs&&(_i=!0),this.height=e)}replace(e,t,i){return n.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,s){let r=this,o=i.doc;for(let l=s.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=s[l],u=r.lineAt(a,ee.ByPosNoHeight,i.setDoc(t),0,0),d=u.to>=h?u:r.lineAt(h,ee.ByPosNoHeight,i,0,0);for(f+=d.to-h,h=d.to;l>0&&u.from<=s[l-1].toA;)a=s[l-1].fromA,c=s[l-1].fromB,l--,ar*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,s-=l.size}else if(r>s*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(s=r&&o(this.lineAt(0,ee.ByPos,i,s,r))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}},He=class n extends qs{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new st(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let s=i[0];return i.length==1&&(s instanceof n||s instanceof Dt&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof Dt?s=new n(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):We.of(i)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more?this.setMeasuredHeight(s):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},Dt=class n extends We{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,r=s-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:s,perLine:o,perChar:l}}blockAt(e,t,i,s){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,s);if(t.lineWrapping){let h=s+(e0){let r=i[i.length-1];r instanceof n?i[i.length-1]=new n(r.length+s):i.push(null,new n(s-1))}if(e>0){let r=i[0];r instanceof n?i[0]=new n(e+r.length):i.unshift(new n(e-1),null)}return We.of(i)}decomposeLeft(e,t){t.push(new n(e-1),null)}decomposeRight(e,t){t.push(null,new n(this.length-e-1))}updateHeight(e,t=0,i=!1,s){let r=t+this.length;if(s&&s.from<=t+this.length&&s.more){let o=[],l=Math.max(t,s.from),a=-1;for(s.from>t&&o.push(new n(s.from-t-1).updateHeight(e,t));l<=r&&s.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=s.heights[s.index++],u=0;f<0&&(u=-f,f=s.heights[s.index++]),a==-1?a=f:Math.abs(f-a)>=Zs&&(a=-2);let d=new He(c,f,u);d.outdated=!1,o.push(d),l+=c+1}l<=r&&o.push(null,new n(r-l).updateHeight(e,l));let h=We.of(o);return(a<0||Math.abs(h.height-this.height)>=Zs||Math.abs(a-this.heightMetrics(e,t).perLine)>=Zs)&&(_i=!0),Is(this,h)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},yl=class extends We{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,s){let r=i+this.left.height;return el))return h;let c=t==ee.ByPosNoHeight?ee.ByPosNoHeight:ee.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,s,r).join(h)}forEachLine(e,t,i,s,r,o){let l=s+this.left.height,a=r+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,ee.ByPos,i,s,r);e=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,l,a,o)}}replace(e,t,i){let s=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of i)r.push(l);if(e>0&&uc(r,o-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,s=i+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e2*t.size||t.size>2*e.size?We.of(this.break?[e,null,t]:[e,t]):(this.left=Is(this.left,e),this.right=Is(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,s){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return s&&s.from<=t+r.length&&s.more?a=r=r.updateHeight(e,t,i,s):r.updateHeight(e,t,i),s&&s.from<=l+o.length&&s.more?a=o=o.updateHeight(e,l,i,s):o.updateHeight(e,l,i),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function uc(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof Dt&&(i=n[e+1])instanceof Dt&&n.splice(e-1,3,new Dt(t.length+1+i.length))}var ym=5,xl=class n{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof He?s.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new He(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=ym)&&this.addLineDeco(s,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new He(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new Dt(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof He)return e;let t=new He(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof He)&&!this.isCovered?this.nodes.push(new He(0,-1,0)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();r=Math.max(r,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(h==n.parentNode?s.innerHeight:a,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Sm(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function wm(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var mn=class{constructor(e,t,i,s){this.from=e,this.to=t,this.size=i,this.displaySize=s}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new ml(i),this.stateDeco=pc(t),this.heightMap=We.empty().applyChanges(this.stateDeco,B.empty,this.heightOracle.setDoc(t.doc),[new rt(0,0,0,t.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=R.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let s=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);e.push(new Zi(r,o))}}return this.viewports=e.sort((i,s)=>i.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dc:new wl(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(an(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=pc(this.state);let s=e.changedRanges,r=rt.extendWithRanges(s,xm(i,this.stateDeco,e?e.changes:Qe.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);fc(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||_i)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Hc)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?N.RTL:N.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,c=0;if(l.width&&l.height){let{scaleX:w,scaleY:v}=Rc(t,l);(w>.005&&Math.abs(this.scaleX-w)>.005||v>.005&&Math.abs(this.scaleY-v)>.005)&&(this.scaleX=w,this.scaleY=v,h|=16,o=a=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let d=Xc(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=Ec(this.scrollParent||e.win);let O=(this.printing?wm:bm)(t,this.paddingTop),m=O.top-this.pixelViewport.top,g=O.bottom-this.pixelViewport.bottom;this.pixelViewport=O;let S=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(S!=this.inView&&(this.inView=S,S&&(a=!0)),!this.inView&&!this.scrollTarget&&!Sm(e.dom))return 0;let b=l.width;if((this.contentDOMWidth!=b||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),a){let w=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(w)&&(o=!0),o||s.lineWrapping&&Math.abs(b-this.contentDOMWidth)>s.charWidth){let{lineHeight:v,charWidth:Q,textHeight:D}=e.docView.measureTextSize();o=v>0&&s.refresh(r,v,Q,D,Math.max(5,b/Q),w),o&&(e.docView.minWidth=0,h|=16)}m>0&&g>0?c=Math.max(m,g):m<0&&g<0&&(c=Math.min(m,g)),fc();for(let v of this.viewports){let Q=v.from==this.viewport.from?w:e.docView.measureVisibleLineHeights(v);this.heightMap=(o?We.empty().applyChanges(this.stateDeco,B.empty,this.heightOracle,[new rt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new gl(v.from,Q))}_i&&(h|=2)}let A=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return A&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),h|=this.updateForViewport()),(h&2||A)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Zi(s.lineAt(o-i*1e3,ee.ByHeight,r,0,0).from,s.lineAt(l+(1-i)*1e3,ee.ByHeight,r,0,0).to);if(t){let{head:h}=t.range;if(ha.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=s.lineAt(h,ee.ByPos,r,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h=l+Math.max(10,Math.min(i,250)))&&s>o-2*1e3&&r>1,o=s<<1;if(this.defaultTextDirection!=N.LTR&&!i)return[];let l=[],a=(c,f,u,d)=>{if(f-cc&&gg.from>=u.from&&g.to<=u.to&&Math.abs(g.from-c)g.fromS));if(!m){if(fb.from<=f&&b.to>=f)){let b=t.moveToLineBoundary(x.cursor(f),!1,!0).head;b>c&&(f=b)}let g=this.gapSize(u,c,f,d),S=i||g<2e6?g:2e6;m=new mn(c,f,g,S)}l.push(m)},h=c=>{if(c.length2e6)for(let v of e)v.from>=c.from&&v.fromc.from&&a(c.from,d,c,f),pt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];I.spans(t,this.viewport.from,this.viewport.to,{span(r,o){i.push({from:r,to:o})},point(){}},20);let s=0;if(i.length!=this.visibleRanges.length)s=12;else for(let r=0;r=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||an(this.heightMap.lineAt(e,ee.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||an(this.heightMap.lineAt(this.scaler.fromDOM(e),ee.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return an(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Zi=class{constructor(e,t){this.from=e,this.to=t}};function km(n,e,t){let i=[],s=n,r=0;return I.spans(t,n,e,{span(){},point(o,l){o>s&&(i.push({from:s,to:o}),r+=o-s),s=l}},20),s=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let s=0;;s++){let{from:r,to:o}=e[s],l=o-r;if(i<=l)return r+i;i-=l}}function Qs(n,e){let t=0;for(let{from:i,to:s}of n.ranges){if(e<=s){t+=e-i;break}t+=s-i}return t/n.total}function Qm(n,e){for(let t of n)if(e(t))return t}var dc={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function pc(n){let e=n.facet(Js).filter(i=>typeof i!="function"),t=n.facet(Vl).filter(i=>typeof i!="function");return t.length&&e.push(I.join(t)),e}var wl=class n{constructor(e,t,i){let s=0,r=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,ee.ByPos,e,0,0).top,c=t.lineAt(a,ee.ByPos,e,0,0).bottom;return s+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(t.height-s);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,i=0,s=0;;t++){let r=tt.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}};function an(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new st(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(s=>an(s,e)):n._content)}var vs=P.define({combine:n=>n.join(" ")}),kl=P.define({combine:n=>n.indexOf(!0)>-1}),Ql=Fe.newName(),xf=Fe.newName(),bf=Fe.newName(),Sf={"&light":"."+xf,"&dark":"."+bf};function vl(n,e,t){return new Fe(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,s=>{if(s=="&")return n;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):n+" "+i}})}var vm=vl("."+Ql,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Sf),$m={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},_o=Z.ie&&Z.ie_version<=11,$l=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Uo,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(Z.ie&&Z.ie_version<=11||Z.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Z.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Z.chrome&&Z.chrome_version<126)&&(this.editContext=new Pl(e),e.state.facet(vt)&&(e.contentDOM.editContext=this.editContext.editContext)),_o&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,s=this.selectionRange;if(i.state.facet(vt)?i.root.activeElement!=this.dom:!cn(this.dom,s))return;let r=s.anchorNode&&i.docView.tile.nearest(s.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(Z.ie&&Z.ie_version<=11||Z.android&&Z.chrome)&&!i.state.selection.main.empty&&s.focusNode&&fn(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Sn(e.root);if(!t)return!1;let i=Z.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Pm(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let s=cn(this.dom,i);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&Xi(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,s=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(s=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:s}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),s=this.selectionChanged&&cn(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new ul(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,s=hf(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!Ys(this.view.state.selection,t.newSel.main))&&this.view.update([]),s}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=Oc(t,e.previousSibling||e.target.previousSibling,-1),s=Oc(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:s?t.posBefore(s):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(vt)!=e.state.facet(vt)&&(e.view.contentDOM.editContext=e.state.facet(vt)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function Oc(n,e,t){for(;e;){let i=te.get(e);if(i&&i.parent==n)return i;let s=e.parentNode;e=s!=n.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function mc(n,e){let t=e.startContainer,i=e.startOffset,s=e.endContainer,r=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return fn(o.node,o.offset,s,r)&&([t,i,s,r]=[s,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}}function Pm(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return mc(n,s)}let t=null;function i(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?mc(n,t):null}var Pl=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let s=e.state.selection.main,{anchor:r,head:o}=s,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>i.text.length;l==this.from&&rthis.to&&(a=r);let c=cf(e.state.sliceDoc(l,a),i.text,(h?s.from:s.to)-l,h?"end":null);if(!c){let u=x.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Ys(u,s)||e.dispatch({selection:u,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:B.of(i.text.slice(c.from,c.toB).split(` `))};if((Z.mac||Z.android)&&f.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:B.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let u=this.to-this.from+(f.to-f.from+f.insert.length);Nl(e,f,x.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let s=[],r=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o{let s=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(r.rangeStart),h=this.toEditorPos(r.rangeEnd);if(a{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let s=Sn(i.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,s=this.pendingContextChange;return e.changes.iterChanges((r,o,l,a,h)=>{if(i)return;let c=h.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(h)){s=this.pendingContextChange=null,t+=c,this.to+=c;return}else s=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=c,this.to+=c;else if(rthis.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),h.toString()),this.to+=c}t+=c}),s&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),s=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(i,s)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},T=class n{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(s=>s.forEach(r=>i(r,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||SO(e.parent)||document,this.viewState=new Vs(this,e.state||H.create(e)),e.scrollTo&&e.scrollTo.is(bs)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ci).map(s=>new dn(s));for(let s of this.plugins)s.update(this);this.observer=new $l(this),this.inputState=new dl(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Ws(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof ae?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,s,r=this.state;for(let u of e){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(mf))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=gf(r,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(H.phrases)!=this.state.facet(H.phrases))return this.setState(r);s=zs.create(this,r,e),s.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection;f=new un(d.empty?d:x.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of u.effects)d.is(bs)&&(f=d.value.clip(this.state))}this.viewState.update(s,f),this.bidiCache=js.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(ln)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(vs)!=s.state.facet(vs)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let u of this.state.facet(Jo))try{u(s)}catch(d){me(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!hf(this,c)&&h.force&&Xi(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Vs(this,e),this.plugins=e.facet(Ci).map(i=>new dn(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Ws(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Ci),i=e.state.facet(Ci);if(t!=i){let s=[];for(let r of i){let o=t.indexOf(r);if(o<0)s.push(new dn(r));else{let l=this.plugins[o];l.mustUpdate=e,s.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Ec(i||this.win))r=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(s);r=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let c=h.map(d=>{try{return d.read(this)}catch(p){return me(this.state,p),gc}}),f=zs.create(this,this.state,[]),u=!1;f.flags|=a,t?t.flags|=a:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),u=this.docView.update(f),u&&this.docViewUpdate());for(let d=0;d1||p<-1)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+p,i?i.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Jo))l(t)}get themeClasses(){return Ql+" "+(this.state.facet(kl)?bf:xf)+" "+this.state.facet(vs)}updateAttrs(){let e=yc(this,ef,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(vt)?"true":"false",class:"cm-content",style:`${Z.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),yc(this,ql,t);let i=this.observer.ignore(()=>{let s=Fh(this.contentDOM,this.contentAttrs,t),r=Fh(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let s of i.effects)if(s.is(n.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(ln);let e=this.state.facet(n.cspNonce);Fe.mount(this.root,this.styleModules.concat(vm).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ti.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return zo(this,e,ic(this,e,t,i))}moveByGroup(e,t){return zo(this,e,ic(this,e,t,i=>FO(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),s=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return x.cursor(r.side(t,s)+e.from,r.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,i=!0){return UO(this,e,t,i)}moveVertically(e,t,i){return zo(this,e,HO(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=hl(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),hl(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let s=this.state.doc.lineAt(e),r=this.bidiSpans(s),o=r[Je.find(r,e-s.from,-1,t)];return Ds(i,o.dir==N.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Fc)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Tm)return Yc(e.length);let t=this.textDirectionAt(e.from),i;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||Bc(r.isolates,i=Jh(this,e))))return r.order;i||(i=Jh(this,e));let s=CO(e.text,t,i);return this.bidiCache.push(new js(e.from,e.to,t,i,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Z.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Lc(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return bs.of(new un(typeof e=="number"?x.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return bs.of(new un(x.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return ie.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ie.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=Fe.newName(),s=[vs.of(i),ln.of(vl(`.${i}`,e))];return t&&t.dark&&s.push(kl.of(!0)),s}static baseTheme(e){return Ue.lowest(ln.of(vl("."+Ql,e,Sf)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),s=i&&te.get(i)||te.get(e);return((t=s?.root)===null||t===void 0?void 0:t.view)||null}};T.styleModule=ln;T.inputHandler=Gc;T.clipboardInputFilter=Yl;T.clipboardOutputFilter=Il;T.scrollHandler=Kc;T.focusChangeEffect=Uc;T.perLineTextDirection=Fc;T.exceptionSink=Nc;T.updateListener=Jo;T.editable=vt;T.mouseSelectionStyle=jc;T.dragMovesSelection=Vc;T.clickAddsSelectionRange=qc;T.decorations=Js;T.blockWrappers=tf;T.outerDecorations=Vl;T.atomicRanges=kn;T.bidiIsolatedRanges=nf;T.scrollMargins=sf;T.darkTheme=kl;T.cspNonce=P.define({combine:n=>n.length?n[0]:""});T.contentAttributes=ql;T.editorAttributes=ef;T.lineWrapping=T.contentAttributes.of({class:"cm-lineWrapping"});T.announce=E.define();var Tm=4096,gc={},js=class n{constructor(e,t,i,s,r,o){this.from=e,this.to=t,this.dir=i,this.isolates=s,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let i=[],s=e.length?e[e.length-1].dir:N.LTR;for(let r=Math.max(0,e.length-10);r=0;s--){let r=i[s],o=typeof r=="function"?r(n):r;o&&_l(o,t)}return t}var Cm=Z.mac?"mac":Z.windows?"win":Z.linux?"linux":"key";function Zm(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let s,r,o,l;for(let a=0;ai.concat(s),[]))),t}function kf(n,e,t){return Qf(wf(n.state),e,n,t)}var Et=null,Mm=4e3;function Rm(n,e=Cm){let t=Object.create(null),i=Object.create(null),s=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,h,c)=>{var f,u;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(g=>Zm(g,e));for(let g=1;g{let A=Et={view:b,prefix:S,scope:o};return setTimeout(()=>{Et==A&&(Et=null)},Mm),!0}]})}let O=p.join(" ");s(O,!1);let m=d[O]||(d[O]={preventDefault:!1,stopPropagation:!1,run:((u=(f=d._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&m.run.push(a),h&&(m.preventDefault=!0),c&&(m.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=t[h]||(t[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let u in c)c[u].run.push(d=>f(d,Tl))}let a=o[e]||o.key;if(a)for(let h of l)r(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}var Tl=null;function Qf(n,e,t,i){Tl=e;let s=Vh(e),r=Oe(s,0),o=_e(r)==s.length&&s!=" ",l="",a=!1,h=!1,c=!1;Et&&Et.view==t&&Et.scope==i&&(l=Et.prefix+" ",uf.indexOf(e.keyCode)<0&&(h=!0,Et=null));let f=new Set,u=m=>{if(m){for(let g of m.run)if(!f.has(g)&&(f.add(g),g(t)))return m.stopPropagation&&(c=!0),!0;m.preventDefault&&(m.stopPropagation&&(c=!0),h=!0)}return!1},d=n[i],p,O;return d&&(u(d[l+$s(s,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Z.windows&&e.ctrlKey&&e.altKey)&&!(Z.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=Qt[e.keyCode])&&p!=s?(u(d[l+$s(p,e,!0)])||e.shiftKey&&(O=Pi[e.keyCode])!=s&&O!=p&&u(d[l+$s(O,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(d[l+$s(s,e,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),Tl=null,a}var ri=class n{constructor(e,t,i,s,r){this.className=e,this.left=t,this.top=i,this.width=s,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let s=e.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let r=vf(e);return[new n(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return Xm(e,t,i)}};function vf(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==N.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function bc(n,e,t,i){let s=n.coordsAtPos(e,t*2);if(!s)return i;let r=n.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,l=n.posAtCoords({x:r.left+1,y:o}),a=n.posAtCoords({x:r.right-1,y:o});return l==null||a==null?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}function Xm(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),s=Math.min(t.to,n.viewport.to),r=n.textDirection==N.LTR,o=n.contentDOM,l=o.getBoundingClientRect(),a=vf(n),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),f=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),d=al(n,i,1),p=al(n,s,-1),O=d.type==ge.Text?d:null,m=p.type==ge.Text?p:null;if(O&&(n.lineWrapping||d.widgetLineBreaks)&&(O=bc(n,i,1,O)),m&&(n.lineWrapping||p.widgetLineBreaks)&&(m=bc(n,s,-1,m)),O&&m&&O.from==m.from&&O.to==m.to)return S(b(t.from,t.to,O));{let w=O?b(t.from,null,O):A(d,!1),v=m?b(null,t.to,m):A(p,!0),Q=[];return(O||d).to<(m||p).from-(O&&m?1:0)||d.widgetLineBreaks>1&&w.bottom+n.defaultLineHeight/2X&&q.from=fe)break;Te>j&&_(Math.max(oe,j),w==null&&oe<=X,Math.min(Te,fe),v==null&&Te>=Y,qe.dir)}if(j=ye.to+1,j>=fe)break}return G.length==0&&_(X,w==null,Y,v==null,n.textDirection),{top:D,bottom:W,horizontal:G}}function A(w,v){let Q=l.top+(v?w.top:w.bottom);return{top:Q,bottom:Q,horizontal:[]}}}function Lm(n,e){return n.constructor==e.constructor&&n.eq(e)}var Cl=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(As)!=e.state.facet(As)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(As);for(;t!Lm(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[i].constructor&&s.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(s.draw(),t);for(;t;){let s=t.nextSibling;t.remove(),t=s}this.drawn=e,Z.safari&&Z.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},As=P.define();function $f(n){return[ie.define(e=>new Cl(e,n)),As.of(n)]}var Wi=P.define({combine(n){return be(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Pf(n={}){return[Wi.of(n),Em,Dm,zm,Hc.of(!0)]}function Tf(n){return n.startState.facet(Wi)!=n.state.facet(Wi)}var Em=$f({above:!0,markers(n){let{state:e}=n,t=e.facet(Wi),i=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty||t.drawRangeCursor&&!(r&&Z.ios&&t.iosSelectionHandles)){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=s.empty?s:x.cursor(s.head,s.assoc);for(let a of ri.forRange(n,o,l))i.push(a)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Tf(n);return t&&Sc(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){Sc(e.state,n)},class:"cm-cursorLayer"});function Sc(n,e){e.style.animationDuration=n.facet(Wi).cursorBlinkRate+"ms"}var Dm=$f({above:!1,markers(n){let e=[],{main:t,ranges:i}=n.state.selection;for(let s of i)if(!s.empty)for(let r of ri.forRange(n,"cm-selectionBackground",s))e.push(r);if(Z.ios&&!t.empty&&n.state.facet(Wi).iosSelectionHandles){for(let s of ri.forRange(n,"cm-selectionHandle cm-selectionHandle-start",x.cursor(t.from,1)))e.push(s);for(let s of ri.forRange(n,"cm-selectionHandle cm-selectionHandle-end",x.cursor(t.to,1)))e.push(s)}return e},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||Tf(n)},class:"cm-selectionLayer"}),zm=Ue.highest(T.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Cf=E.define({map(n,e){return n==null?null:e.mapPos(n)}}),hn=ne.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(Cf)?i.value:t,n)}}),_m=ie.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(hn);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(hn)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(hn),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(hn)!=n&&this.view.dispatch({effects:Cf.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Zf(){return[hn,_m]}function wc(n,e,t,i,s){e.lastIndex=0;for(let r=n.iterRange(t,i),o=t,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=e.exec(r.value);)s(o+l.index,l)}function Wm(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:s,to:r}of t)s=Math.max(n.state.doc.lineAt(s).from,s-e),r=Math.min(n.state.doc.lineAt(r).to,r+e),i.length&&i[i.length-1].to>=s?i[i.length-1].to=r:i.push({from:s,to:r});return i}var Zl=class{constructor(e){let{regexp:t,decoration:i,decorate:s,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(l,a,h,c)=>s(c,h,h+l[0].length,l,a);else if(typeof i=="function")this.addMatch=(l,a,h,c)=>{let f=i(l,a,h);f&&c(h,h+l[0].length,f)};else if(i)this.addMatch=(l,a,h,c)=>c(h,h+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new ze,i=t.add.bind(t);for(let{from:s,to:r}of Wm(e,this.maxLength))wc(e.state.doc,this.regexp,s,r,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,l,a)=>{a>=e.view.viewport.from&&l<=e.view.viewport.to&&(i=Math.min(l,i),s=Math.max(a,s))}),e.viewportMoved||s-i>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),i,s):t}updateRange(e,t,i,s){for(let r of e.visibleRanges){let o=Math.max(r.from,i),l=Math.min(r.to,s);if(l>=o){let a=e.state.doc.lineAt(o),h=a.toa.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;lu.push(g.range(O,m));if(a==h)for(this.regexp.lastIndex=c-a.from;(d=this.regexp.exec(a.text))&&d.indexthis.addMatch(m,e,O,p));t=t.update({filterFrom:c,filterTo:f,filter:(O,m)=>Of,add:u})}}return t}},Al=/x/.unicode!=null?"gu":"g",Bm=new RegExp(`[\0-\b -\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,Al),Ym={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},Wo=null;function Im(){var n;if(Wo==null&&typeof document<"u"&&document.body){let e=document.body.style;Wo=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Wo||!1}var Ms=P.define({combine(n){let e=be(n,{render:null,specialChars:Bm,addSpecialChars:null});return(e.replaceTabs=!Im())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Al)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Al)),e}});function Af(n={}){return[Ms.of(n),qm()]}var kc=null;function qm(){return kc||(kc=ie.fromClass(class{constructor(n){this.view=n,this.decorations=R.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(Ms)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new Zl({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:s}=t.state,r=Oe(e[0],0);if(r==9){let o=s.lineAt(i),l=t.state.tabSize,a=kt(o.text,l,i-o.from);return R.replace({widget:new Rl((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=R.replace({widget:new Ml(n,r)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(Ms);n.startState.facet(Ms)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}var Vm="\u2022";function jm(n){return n>=32?Vm:n==10?"\u2424":String.fromCharCode(9216+n)}var Ml=class extends $e{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=jm(this.code),i=e.state.phrase("Control character")+" "+(Ym[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}},Rl=class extends $e{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}};function Mf(){return Gm}var Nm=R.line({class:"cm-activeLine"}),Gm=ie.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let s=n.lineBlockAt(i.head);s.from>e&&(t.push(Nm.range(s.from)),e=s.from)}return R.set(t)}},{decorations:n=>n.decorations});var Xl=2e3;function Um(n,e,t){let i=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>Xl||t.off>Xl||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=i;a<=s;a++){let h=n.doc.line(a);h.length<=l&&r.push(x.range(h.from+o,h.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=i;a<=s;a++){let h=n.doc.line(a),c=ys(h.text,o,n.tabSize,!0);if(c<0)r.push(x.cursor(h.to));else{let f=ys(h.text,l,n.tabSize);r.push(x.range(h.from+c,h.from+f))}}}return r}function Fm(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function Qc(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),s=t-i.from,r=s>Xl?-1:s==i.length?Fm(n,e.clientX):kt(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:r,off:s}}function Hm(n,e){let t=Qc(n,e),i=n.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},i=i.map(s.changes)}},get(s,r,o){let l=Qc(n,s);if(!l)return i;let a=Um(n.state,t,l);return a.length?o?x.create(a.concat(i.ranges)):x.create(a):i}}:null}function Rf(n){let e=n?.eventFilter||(t=>t.altKey&&t.button==0);return T.mouseSelectionStyle.of((t,i)=>e(i)?Hm(t,i):null)}var Km={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},Jm={style:"cursor: crosshair"};function Xf(n={}){let[e,t]=Km[n.key||"Alt"],i=ie.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[i,T.contentAttributes.of(s=>{var r;return!((r=s.plugin(i))===null||r===void 0)&&r.isDown?Jm:null})]}var Ps="-10000px",Ns=class{constructor(e,t,i,s){this.facet=t,this.createTooltipView=i,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=i(o,r))}update(e,t){var i;let s=e.state.facet(this.facet),r=s.filter(a=>a);if(s===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;at[h]=a),t.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}};function eg(n){let e=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}var Bo=P.define({combine:n=>{var e,t,i;return{position:Z.ios?"absolute":((e=n.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||eg}}}),vc=new WeakMap,Gl=ie.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Bo);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Ns(n,Qn,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Bo);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=Ps,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(Z.safari){let o=r.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else t=!!r.offsetParent&&r.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(n=r.width/this.parent.offsetWidth,e=r.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),s=jl(this.view);return{visible:{left:i.left+s.left,top:i.top+s.top,right:i.right-s.right,bottom:i.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((r,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(Bo).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:t,space:i,scaleX:s,scaleY:r}=n,o=[];for(let l=0;l=Math.min(t.bottom,i.bottom)||f.rightMath.min(t.right,i.right)+.1)){c.style.top=Ps;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,O=u.right-u.left,m=(e=vc.get(h))!==null&&e!==void 0?e:u.bottom-u.top,g=h.offset||ig,S=this.view.textDirection==N.LTR,b=u.width>i.right-i.left?S?i.left:i.right-u.width:S?Math.max(i.left,Math.min(f.left-(d?14:0)+g.x,i.right-O)):Math.min(Math.max(i.left,f.left-O+(d?14:0)-g.x),i.right-O),A=this.above[l];!a.strictSide&&(A?f.top-m-p-g.yi.bottom)&&A==i.bottom-f.bottom>f.top-i.top&&(A=this.above[l]=!A);let w=(A?f.top-i.top:i.bottom-f.bottom)-p;if(wb&&D.topv&&(v=A?D.top-m-2-p:D.bottom+p+2);if(this.position=="absolute"?(c.style.top=(v-n.parent.top)/r+"px",$c(c,(b-n.parent.left)/s)):(c.style.top=v/r+"px",$c(c,b/s)),d){let D=f.left+(S?g.x:-g.x)-(b+14-7);d.style.left=D/s+"px"}h.overlap!==!0&&o.push({left:b,top:v,right:Q,bottom:v+m}),c.classList.toggle("cm-tooltip-above",A),c.classList.toggle("cm-tooltip-below",!A),h.positioned&&h.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=Ps}},{eventObservers:{scroll(){this.maybeMeasure()}}});function $c(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}var tg=T.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),ig={x:0,y:0},Qn=P.define({enables:[Gl,tg]}),Gs=P.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])}),Us=class n{static create(e){return new n(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Ns(e,Gs,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let s=i[e];if(s!==void 0){if(t===void 0)t=s;else if(t!==s)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},ng=Qn.compute([Gs],n=>{let e=n.facet(Gs);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Us.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Ll=class{constructor(e,t,i,s,r){this.view=e,this.source=t,this.field=i,this.setHover=s,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;el.bottom||t.xl.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(s)).find(c=>c.from<=s&&c.to>=s),h=a&&a.dir==N.RTL?-1:1;r=t.x{this.pending==l&&(this.pending=null,a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])}))},a=>me(e.state,a,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(Gl),t=e?e.manager.tooltips.findIndex(i=>i.create==Us.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:r}=this;if(s.length&&r&&!sg(r.dom,e)||this.pending){let{pos:o}=s[0]||this.pending,l=(i=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!rg(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},Ts=4;function sg(n,e){let{left:t,right:i,top:s,bottom:r}=n.getBoundingClientRect(),o;if(o=n.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();s=Math.min(l.top,s),r=Math.max(l.bottom,r)}return e.clientX>=t-Ts&&e.clientX<=i+Ts&&e.clientY>=s-Ts&&e.clientY<=r+Ts}function rg(n,e,t,i,s,r){let o=n.scrollDOM.getBoundingClientRect(),l=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.rights||Math.min(o.bottom,l)=e&&a<=t}function Lf(n,e={}){let t=E.define(),i=ne.define({create(){return[]},update(s,r){if(s.length&&(e.hideOnChange&&(r.docChanged||r.selection)?s=[]:e.hideOn&&(s=s.filter(o=>!e.hideOn(r,o))),r.docChanged)){let o=[];for(let l of s){let a=r.changes.mapPos(l.pos,-1,ce.TrackDel);if(a!=null){let h=Object.assign(Object.create(null),l);h.pos=a,h.end!=null&&(h.end=r.changes.mapPos(h.end)),o.push(h)}}s=o}for(let o of r.effects)o.is(t)&&(s=o.value),o.is(og)&&(s=[]);return s},provide:s=>Gs.from(s)});return{active:i,extension:[i,ie.define(s=>new Ll(s,n,i,t,e.hoverTime||300)),ng]}}function Ul(n,e){let t=n.plugin(Gl);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}var og=E.define();var Pc=P.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function vn(n,e){let t=n.plugin(Ef),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}var Ef=ie.fromClass(class{constructor(n){this.input=n.state.facet(hi),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(Pc);this.top=new Ai(n,!0,e.topContainer),this.bottom=new Ai(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(Pc);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Ai(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ai(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(hi);if(t!=this.input){let i=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),c;h<0?(c=a(n.view),l.push(c)):(c=this.panels[h],c.update&&c.update(n)),s.push(c),(c.top?r:o).push(c)}this.specs=i,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>T.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Ai=class{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Tc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Tc(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function Tc(n){let e=n.nextSibling;return n.remove(),e}var hi=P.define({enables:Ef});function Df(n,e){let t,i=new Promise(o=>t=o),s=o=>lg(o,e,t);n.state.field(Yo,!1)?n.dispatch({effects:zf.of(s)}):n.dispatch({effects:E.appendConfig.of(Yo.init(()=>[s]))});let r=_f.of(s);return{close:r,result:i.then(o=>((n.win.queueMicrotask||(a=>n.win.setTimeout(a,10)))(()=>{n.state.field(Yo).indexOf(s)>-1&&n.dispatch({effects:r})}),o))}}var Yo=ne.define({create(){return[]},update(n,e){for(let t of e.effects)t.is(zf)?n=[t.value].concat(n):t.is(_f)&&(n=n.filter(i=>i!=t.value));return n},provide:n=>hi.computeN([n],e=>e.field(n))}),zf=E.define(),_f=E.define();function lg(n,e,t){let i=e.content?e.content(n,()=>o(null)):null;if(!i){if(i=V("form"),e.input){let l=V("input",e.input);/^(text|password|number|email|tel|url)$/.test(l.type)&&l.classList.add("cm-textfield"),l.name||(l.name="input"),i.appendChild(V("label",(e.label||"")+": ",l))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(V("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let s=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let l=0;l{h.keyCode==27?(h.preventDefault(),o(null)):h.keyCode==13&&(h.preventDefault(),o(a))}),a.addEventListener("submit",h=>{h.preventDefault(),o(a)})}let r=V("div",i,V("button",{onclick:()=>o(null),"aria-label":n.state.phrase("close"),class:"cm-dialog-close",type:"button"},["\xD7"]));e.class&&(r.className=e.class),r.classList.add("cm-dialog");function o(l){r.contains(r.ownerDocument.activeElement)&&n.focus(),t(l)}return{dom:r,top:e.top,mount:()=>{if(e.focus){let l;typeof e.focus=="string"?l=i.querySelector(e.focus):l=i.querySelector("input")||i.querySelector("button"),l&&"select"in l?l.select():l&&"focus"in l&&l.focus()}}}}var Be=class extends Ge{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Be.prototype.elementClass="";Be.prototype.toDOM=void 0;Be.prototype.mapMode=ce.TrackBefore;Be.prototype.startSide=Be.prototype.endSide=-1;Be.prototype.point=!0;var Rs=P.define(),ag=P.define(),hg={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>I.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},gn=P.define();function Fl(n){return[Wf(),gn.of({...hg,...n})]}var El=P.define({combine:n=>n.some(e=>e)});function Wf(n){let e=[cg];return n&&n.fixed===!1&&e.push(El.of(!0)),e}var cg=ie.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(gn).map(e=>new Fs(n,e)),this.fixed=!n.state.facet(El);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(El)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=I.iter(this.view.state.facet(Rs),this.view.viewport.from),i=[],s=this.gutters.map(r=>new zl(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==ge.Text&&o){Dl(t,i,l.from);for(let a of s)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of s)a.widget(this.view,l)}else if(r.type==ge.Text){Dl(t,i,r.from);for(let o of s)o.line(this.view,r,i)}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(gn),t=n.state.facet(gn),i=n.docChanged||n.heightChanged||n.viewportChanged||!I.eq(n.startState.facet(Rs),n.state.facet(Rs),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(n)&&(i=!0);else{i=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new Fs(this.view,r)):(this.gutters[o].update(n),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=s}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>T.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,s=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==N.LTR?{left:i,right:s}:{right:i,left:s}})});function Cc(n){return Array.isArray(n)?n:[n]}function Dl(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}var zl=class{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=I.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:s}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==s.elements.length){let l=new Hs(e,o,r,i);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(e,o,r,i);this.height=t.bottom,this.i++}line(e,t,i){let s=[];Dl(this.cursor,s,t.from),i.length&&(s=s.concat(i));let r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),s=i?[i]:null;for(let r of e.state.facet(ag)){let o=r(e,t.widget,t);o&&(s||(s=[])).push(o)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},Fs=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=s.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,s)&&s.preventDefault()});this.markers=Cc(t.markers(e)),t.initialSpacer&&(this.spacer=new Hs(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Cc(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let i=e.view.viewport;return!I.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Hs=class{constructor(e,t,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,s)}update(e,t,i,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),fg(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let i="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=rr(l,a,h)||o(l,a,h):o}return i}})}}),yn=class extends Be{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Io(n,e){return n.state.facet(Mi).formatNumber(e,n.state)}var pg=gn.compute([Mi],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(ug)},lineMarker(e,t,i){return i.some(s=>s.toDOM)?null:new yn(Io(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let s of e.state.facet(dg)){let r=s(e,t,i);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(Mi)!=e.state.facet(Mi),initialSpacer(e){return new yn(Io(e,Zc(e.state.doc.lines)))},updateSpacer(e,t){let i=Io(t.view,Zc(t.view.state.doc.lines));return i==e.number?e:new yn(i)},domEventHandlers:n.facet(Mi).domEventHandlers,side:"before"}));function Bf(n={}){return[Mi.of(n),Wf(),pg]}function Zc(n){let e=9;for(;e{let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.head).from;s>t&&(t=s,e.push(Og.range(s)))}return I.of(e)});function Yf(){return mg}var Hl,ci=new z;function ar(n){return P.define({combine:n?e=>e.concat(n):void 0})}var hr=new z,Re=class{constructor(e,t,i=[],s=""){this.data=e,this.name=s,H.prototype.hasOwnProperty("tree")||Object.defineProperty(H.prototype,"tree",{get(){return se(this)}}),this.parser=t,this.extension=[Wt.of(this),H.languageData.of((r,o,l)=>{let a=If(r,o,l),h=a.type.prop(ci);if(!h)return[];let c=r.facet(h),f=a.type.prop(hr);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return If(e,t,i).type.prop(ci)==this.data}findRegions(e){let t=e.facet(Wt);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],s=(r,o)=>{if(r.prop(ci)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(z.mounted);if(l){if(l.tree.prop(ci)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(s(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;ai.isTop?t:void 0)]}),e.name)}configure(e,t){return new n(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function se(n){let e=n.field(Re.state,!1);return e?e.tree:U.empty}var ta=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},$n=null,Tn=class n{constructor(e,t,i=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],U.empty,0,i,[],null)}startParse(){return this.parser.startParse(new ta(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=U.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Ut.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=$n;$n=this;try{return e()}finally{$n=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=qf(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=Ut.applyChanges(i,a),s=U.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);ce.from&&(this.fragments=qf(this.fragments,s,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Ft{createParse(t,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=$n;if(a){for(let h of s)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new U(pe.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return $n}};function qf(n,e,t){return Ut.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var Cn=class n{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new n(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Tn.create(e.facet(Wt).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};Re.state=ne.define({create:Cn.init,update(n,e){for(let t of e.effects)if(t.is(Re.setState))return t.value;return e.startState.facet(Wt)!=e.state.facet(Wt)?Cn.init(e.state):n.apply(e)}});var Kf=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Kf=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var Kl=typeof navigator<"u"&&(!((Hl=navigator.scheduling)===null||Hl===void 0)&&Hl.isInputPending)?()=>navigator.scheduling.isInputPending():null,gg=ie.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Re.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Re.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Kf(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnds+1e3,a=r.context.work(()=>Kl&&Kl()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Re.setState.of(new Cn(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>me(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Wt=P.define({combine(n){return n.length?n[0]:null},enables:n=>[Re.state,gg,T.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),ir=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var yg=P.define(),Yi=P.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Bt(n){let e=n.facet(Yi);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Ii(n,e){let t="",i=n.tabSize,s=n.facet(Yi)[0];if(s==" "){for(;e>=i;)t+=" ",e-=i;s=" "}for(let r=0;r=e?xg(n,t,e):null}var fi=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Bt(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=i.from&&s<=i.to?r&&s==e?{text:"",from:e}:(t<0?s-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return kt(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},fr=new z;function xg(n,e,t){let i=e.resolveStack(t),s=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(s!=i.node){let r=[];for(let o=s;o&&!(o.fromi.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return Jf(i,n,t)}function Jf(n,e,t){for(let i=n;i;i=i.next){let s=Sg(i.node);if(s)return s(ia.create(e,t,i))}return 0}function bg(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Sg(n){let e=n.type.prop(fr);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(z.closedBy))){let s=n.lastChild,r=s&&i.indexOf(s.name)>-1;return o=>tu(o,!0,1,void 0,r&&!bg(o)?s.from:void 0)}return n.parent==null?wg:null}function wg(){return 0}var ia=class n extends fi{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new n(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(kg(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Jf(this.context.next,this.base,this.pos)}};function kg(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Qg(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let s=n.options.simulateBreak,r=n.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+h}}l=a.to}}function eu({closing:n,align:e=!0,units:t=1}){return i=>tu(i,e,t,n)}function tu(n,e,t,i,s){let r=n.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||s==n.pos+o,a=e?Qg(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}var iu=n=>n.baseIndent;function ur({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}var vg=200;function nu(){return H.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,s=t.lineAt(i);if(i>s.from+vg)return n;let r=t.sliceString(s.from,i);if(!e.some(h=>h.test(r)))return n;let{state:o}=n,l=-1,a=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==l)continue;l=c.from;let f=cr(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],d=Ii(o,f);u!=d&&a.push({from:c.from,to:c.from+u.length,insert:d})}return a.length?[n,{changes:a,sequential:!0}]:n})}var $g=P.define(),ca=new z;function su(n){let e=n.firstChild,t=n.lastChild;return e&&e.tot)continue;if(r&&l.from=e&&h.to>t&&(r=h)}}return r}function Tg(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function nr(n,e,t){for(let i of n.facet($g)){let s=i(n,e,t);if(s)return s}return Pg(n,e,t)}function ru(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}var dr=E.define({map:ru}),An=E.define({map:ru});function ou(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}var ui=ne.define({create(){return R.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((t,i)=>n=Vf(n,t,i)),n=n.map(e.changes);for(let t of e.effects)if(t.is(dr)&&!Cg(n,t.value.from,t.value.to)){let{preparePlaceholder:i}=e.state.facet(fa),s=i?R.replace({widget:new na(i(e.state,t.value))}):jf;n=n.update({add:[s.range(t.value.from,t.value.to)]})}else t.is(An)&&(n=n.update({filter:(i,s)=>t.value.from!=i||t.value.to!=s,filterFrom:t.value.from,filterTo:t.value.to}));return e.selection&&(n=Vf(n,e.selection.main.head)),n},provide:n=>T.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,s)=>{t.push(i,s)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{se&&(i=!0)}),i?n.update({filterFrom:e,filterTo:t,filter:(s,r)=>s>=t||r<=e}):n}function sr(n,e,t){var i;let s=null;return(i=n.field(ui,!1))===null||i===void 0||i.between(e,t,(r,o)=>{(!s||s.from>r)&&(s={from:r,to:o})}),s}function Cg(n,e,t){let i=!1;return n.between(e,e,(s,r)=>{s==e&&r==t&&(i=!0)}),i}function lu(n,e){return n.field(ui,!1)?e:e.concat(E.appendConfig.of(cu()))}var Zg=n=>{for(let e of ou(n)){let t=nr(n.state,e.from,e.to);if(t)return n.dispatch({effects:lu(n.state,[dr.of(t),au(n,t)])}),!0}return!1},Ag=n=>{if(!n.state.field(ui,!1))return!1;let e=[];for(let t of ou(n)){let i=sr(n.state,t.from,t.to);i&&e.push(An.of(i),au(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function au(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,s=n.state.doc.lineAt(e.to).number;return T.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${s}.`)}var Mg=n=>{let{state:e}=n,t=[];for(let i=0;i{let e=n.state.field(ui,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,s)=>{t.push(An.of({from:i,to:s}))}),n.dispatch({effects:t}),!0};var hu=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Zg},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Ag},{key:"Ctrl-Alt-[",run:Mg},{key:"Ctrl-Alt-]",run:Rg}],Xg={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},fa=P.define({combine(n){return be(n,Xg)}});function cu(n){let e=[ui,Eg];return n&&e.push(fa.of(n)),e}function fu(n,e){let{state:t}=n,i=t.facet(fa),s=o=>{let l=n.lineBlockAt(n.posAtDOM(o.target)),a=sr(n.state,l.from,l.to);a&&n.dispatch({effects:An.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,s,e);let r=document.createElement("span");return r.textContent=i.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}var jf=R.replace({widget:new class extends $e{toDOM(n){return fu(n,null)}}}),na=class extends $e{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return fu(e,this.value)}},Lg={openText:"\u2304",closedText:"\u203A",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},Pn=class extends Be{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}};function uu(n={}){let e={...Lg,...n},t=new Pn(e,!0),i=new Pn(e,!1),s=ie.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Wt)!=o.state.facet(Wt)||o.startState.field(ui,!1)!=o.state.field(ui,!1)||se(o.startState)!=se(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new ze;for(let a of o.viewportLineBlocks){let h=sr(o.state,a.from,a.to)?i:nr(o.state,a.from,a.to)?t:null;h&&l.add(a.from,a.from,h)}return l.finish()}}),{domEventHandlers:r}=e;return[s,Fl({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(s))===null||l===void 0?void 0:l.markers)||I.empty},initialSpacer(){return new Pn(e,!1)},domEventHandlers:{...r,click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let h=sr(o.state,l.from,l.to);if(h)return o.dispatch({effects:An.of(h)}),!0;let c=nr(o.state,l.from,l.to);return c?(o.dispatch({effects:dr.of(c)}),!0):!1}}}),cu()]}var Eg=T.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}}),rr=class n{constructor(e,t){this.specs=e;let i;function s(l){let a=Fe.newName();return(i||(i=Object.create(null)))["."+a]=l,a}let r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof Re?l=>l.prop(ci)==o.data:o?l=>l==o:void 0,this.style=ho(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new Fe(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},sa=P.define(),du=P.define({combine(n){return n.length?[n[0]]:null}});function Jl(n){let e=n.facet(sa);return e.length?e:n.facet(du)}function pu(n,e){let t=[Dg],i;return n instanceof rr&&(n.module&&t.push(T.styleModule.of(n.module)),i=n.themeType),e?.fallback?t.push(du.of(n)):i?t.push(sa.computeN([T.darkTheme],s=>s.facet(T.darkTheme)==(i=="dark")?[n]:[])):t.push(sa.of(n)),t}var ra=class{constructor(e){this.markCache=Object.create(null),this.tree=se(e.state),this.decorations=this.buildDeco(e,Jl(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=se(e.state),i=Jl(e.state),s=i!=Jl(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return R.none;let i=new ze;for(let{from:s,to:r}of e.visibleRanges)Oh(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=R.mark({class:a})))},s,r);return i.finish()}},Dg=Ue.high(ie.fromClass(ra,{decorations:n=>n.decorations})),Ou=rr.define([{tag:y.meta,color:"#404740"},{tag:y.link,textDecoration:"underline"},{tag:y.heading,textDecoration:"underline",fontWeight:"bold"},{tag:y.emphasis,fontStyle:"italic"},{tag:y.strong,fontWeight:"bold"},{tag:y.strikethrough,textDecoration:"line-through"},{tag:y.keyword,color:"#708"},{tag:[y.atom,y.bool,y.url,y.contentSeparator,y.labelName],color:"#219"},{tag:[y.literal,y.inserted],color:"#164"},{tag:[y.string,y.deleted],color:"#a11"},{tag:[y.regexp,y.escape,y.special(y.string)],color:"#e40"},{tag:y.definition(y.variableName),color:"#00f"},{tag:y.local(y.variableName),color:"#30a"},{tag:[y.typeName,y.namespace],color:"#085"},{tag:y.className,color:"#167"},{tag:[y.special(y.variableName),y.macroName],color:"#256"},{tag:y.definition(y.propertyName),color:"#00c"},{tag:y.comment,color:"#940"},{tag:y.invalid,color:"#f00"}]),zg=T.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),mu=1e4,gu="()[]{}",yu=P.define({combine(n){return be(n,{afterCursor:!0,brackets:gu,maxScanDistance:mu,renderMatch:Bg})}}),_g=R.mark({class:"cm-matchingBracket"}),Wg=R.mark({class:"cm-nonmatchingBracket"});function Bg(n){let e=[],t=n.matched?_g:Wg;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function Nf(n){let e=[],t=n.facet(yu);for(let i of n.selection.ranges){if(!i.empty)continue;let s=lt(n,i.head,-1,t)||i.head>0&<(n,i.head-1,1,t)||t.afterCursor&&(lt(n,i.head,1,t)||i.headn.decorations}),Ig=[Yg,zg];function xu(n={}){return[yu.of(n),Ig]}var qg=new z;function oa(n,e,t){let i=n.prop(e<0?z.openedBy:z.closedBy);if(i)return i;if(n.name.length==1){let s=t.indexOf(n.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function la(n){let e=n.type.prop(qg);return e?e(n.node):n}function lt(n,e,t,i={}){let s=i.maxScanDistance||mu,r=i.brackets||gu,o=se(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=oa(a.type,t,r);if(h&&a.from0?e>=c.from&&ec.from&&e<=c.to))return Vg(n,e,t,a,c,h,r)}}return jg(n,e,t,o,l.type,s,r)}function Vg(n,e,t,i,s,r,o){let l=i.parent,a={from:s.from,to:s.to},h=0,c=l?.cursor();if(c&&(t<0?c.childBefore(i.from):c.childAfter(i.to)))do if(t<0?c.to<=i.from:c.from>=i.to){if(h==0&&r.indexOf(c.type.name)>-1&&c.from0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=r;){let d=c.value;t<0&&(u+=d.length);let p=e+u*t;for(let O=t>0?0:d.length-1,m=t>0?d.length:-1;O!=m;O+=t){let g=o.indexOf(d[O]);if(!(g<0||i.resolveInner(p+O,1).type!=s))if(g%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:p+O,to:p+O+1},matched:g>>1==a>>1};f--}}t>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}function Gf(n,e,t,i=0,s=0){e==null&&(e=n.search(/[^\s\u00a0]/),e==-1&&(e=n.length));let r=s;for(let o=i;o=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.post}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPosi?o.toLowerCase():o,r=this.string.substr(this.pos,e.length);return s(r)==s(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let s=this.string.slice(this.pos).match(e);return s&&s.index>0?null:(s&&t!==!1&&(this.pos+=s[0].length),s)}}current(){return this.string.slice(this.start,this.pos)}};function Ng(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||Gg,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||da,mergeTokens:n.mergeTokens!==!1}}function Gg(n){if(typeof n!="object")return n;let e={};for(let t in n){let i=n[t];e[t]=i instanceof Array?i.slice():i}return e}var Uf=new WeakMap,aa=class n extends Re{constructor(e){let t=ar(e.languageData),i=Ng(e),s,r=new class extends Ft{createParse(o,l,a){return new ha(s,o,l,a)}};super(t,r,[],e.name),this.topNode=Kg(t,this),s=this,this.streamParser=i,this.stateAfter=new z({perNode:!0}),this.tokenTable=e.tokenTable?new lr(i.tokenTable):Hg}static define(e){return new n(e)}getIndent(e){let t,{overrideIndentation:i}=e.options;i&&(t=Uf.get(e.state),t!=null&&t1e4)return null;for(;r=i&&t+e.length<=s&&e.prop(n.stateAfter);if(r)return{state:n.streamParser.copyState(r),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let l=e.children[o],a=t+e.positions[o],h=l instanceof U&&a=e.length)return e;!s&&t==0&&e.type==n.topNode&&(s=!0);for(let r=e.children.length-1;r>=0;r--){let o=e.positions[r],l=e.children[r],a;if(ot&&ua(n,r.tree,0-r.offset,t,l),h;if(a&&a.pos<=i&&(h=bu(n,r.tree,t+r.offset,a.pos+r.offset,!1)))return{state:a.state,tree:h}}return{state:n.streamParser.startState(s?Bt(s):4),tree:U.empty}}var ha=class{constructor(e,t,i,s){this.lang=e,this.input=t,this.fragments=i,this.ranges=s,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=s[s.length-1].to;let r=Tn.get(),o=s[0].from,{state:l,tree:a}=Ug(e,i,o,this.to,r?.state);this.state=l,this.parsedPos=this.chunkStart=o+a.length;for(let h=0;hh.from<=r.viewport.from&&h.to>=r.viewport.from)&&(this.state=this.lang.streamParser.startState(Bt(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let e=Tn.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(t,this.chunkStart+512);for(e&&(i=Math.min(i,e.viewport.to));this.parsedPos=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==` `&&(t="");else{let i=t.indexOf(` `);i>-1&&(t=t.slice(0,i))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),i=e+t.length;for(let s=this.rangeIndex;;){let r=this.ranges[s].to;if(r>=i||(t=t.slice(0,r-(i-t.length)),s++,s==this.ranges.length))break;let o=this.ranges[s].from,l=this.lineAfter(o);t+=l,i=o+l.length}return{line:t,end:i}}skipGapsTo(e,t,i){for(;;){let s=this.ranges[this.rangeIndex].to,r=e+t;if(i>0?s>r:s>=r)break;let o=this.ranges[++this.rangeIndex].from;t+=o-s}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to1){s=this.skipGapsTo(t,s,1),t+=s;let l=this.chunk.length;s=this.skipGapsTo(i,s,-1),i+=s,r+=this.chunk.length-l}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&r==4&&o>=0&&this.chunk[o]==e&&this.chunk[o+2]==t?this.chunk[o+2]=i:this.chunk.push(e,t,i,r),s}parseLine(e){let{line:t,end:i}=this.nextLine(),s=0,{streamParser:r}=this.lang,o=new or(t,e?e.state.tabSize:4,e?Bt(e.state):2);if(o.eol())r.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=Su(r.token,o,this.state);if(l&&(s=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,s)),o.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPose.start)return s}throw new Error("Stream parser failed to advance stream.")}var da=Object.create(null),Zn=[pe.none],Fg=new xi(Zn),Ff=[],Hf=Object.create(null),wu=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])wu[n]=ku(da,e);var lr=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),wu)}resolve(e){return e?this.table[e]||(this.table[e]=ku(this.extra,e)):0}},Hg=new lr(da);function ea(n,e){Ff.indexOf(n)>-1||(Ff.push(n),console.warn(e))}function ku(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=n[h]||y[h];c?typeof c=="function"?a.length?a=a.map(c):ea(h,`Modifier ${h} used at start of tag`):a.length?ea(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:ea(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),s=i+" "+t.map(l=>l.id),r=Hf[s];if(r)return r.id;let o=Hf[s]=pe.define({id:Zn.length,name:i,props:[os({[i]:t})]});return Zn.push(o),o.id}function Kg(n,e){let t=pe.define({id:Zn.length,name:"Document",props:[ci.add(()=>n),fr.add(()=>i=>e.getIndent(i))],top:!0});return Zn.push(t),t}var Bx={rtl:R.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:N.RTL}),ltr:R.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:N.LTR}),auto:R.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var Or=class{constructor(e,t,i,s){this.state=e,this.pos=t,this.explicit=i,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=se(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(Ru(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}};function Qu(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Jg(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;rtypeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:Jg(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}function Mu(n,e){return t=>{for(let i=se(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}var mr=class{constructor(e,t,i,s){this.completion=e,this.source=t,this.match=i,this.score=s}};function pi(n){return n.selection.main.from}function Ru(n,e){var t;let{source:i}=n,s=e&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}var Pa=Ze.define();function e0(n,e,t,i){let{main:s}=n.selection,r=t-s.from,o=i-s.from;return{...n.changeByRange(l=>{if(l!=s&&t!=i&&n.sliceDoc(l.from+r,l.from+o)!=n.sliceDoc(t,i))return{range:l};let a=n.toText(e);return{changes:{from:l.from+r,to:i==s.from?l.to:l.from+o,insert:a},range:x.cursor(l.from+r+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}var vu=new WeakMap;function t0(n){if(!Array.isArray(n))return n;let e=vu.get(n);return e||vu.set(n,e=$a(n)),e}var gr=E.define(),Mn=E.define(),ga=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(v=on(w))!=v.toLowerCase()?1:v!=v.toUpperCase()?2:0;(!S||Q==1&&m||A==0&&Q!=0)&&(t[f]==w||i[f]==w&&(u=!0)?o[f++]=S:o.length&&(g=!1)),A=Q,S+=_e(w)}return f==a&&o[0]==0&&g?this.result(-100+(u?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(O==e.length?0:-100),[0,O]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,O]):f==a?this.result(-100+(u?-200:0)+-700+(g?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[],r=0;for(let o of t){let l=o+(this.astral?_e(Oe(i,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(e-i.length,s)}},ya=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:i0,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>$u(e(i),t(i)),optionClass:(e,t)=>i=>$u(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function $u(n,e){return n?e?n+" "+e:n:e}function i0(n,e,t,i,s,r){let o=n.textDirection==N.RTL,l=o,a=!1,h="top",c,f,u=e.left-s.left,d=s.right-e.right,p=i.right-i.left,O=i.bottom-i.top;if(l&&u=O||S>e.top?c=t.bottom-e.top:(h="bottom",c=e.bottom-t.top)}let m=(e.bottom-e.top)/r.offsetHeight,g=(e.right-e.left)/r.offsetWidth;return{style:`${h}: ${c/m}px; max-width: ${f/g}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}var Ta=E.define();function n0(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let h=0;ha&&o.appendChild(document.createTextNode(l.slice(a,c)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(c,f))),u.className="cm-completionMatchedText",a=f}return at.position-i.position).map(t=>t.render)}function pa(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}var xa=class{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,l=e.state.facet(ue);this.optionContent=n0(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=pa(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:h}=e.state.field(t).open;for(let c=a.target,f;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(f=/-(\d+)$/.exec(c.id))&&+f[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;c!=null&&(e.dispatch({effects:Ta.of(c)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(ue).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:Mn.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=s){let{options:r,selected:o,disabled:l}=i.open;(!s.open||s.open.options!=r)&&(this.range=pa(r.length,o,e.state.facet(ue).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),l!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected=this.range.to)&&(this.range=pa(t.options.length,t.selected,this.view.state.facet(ue).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:s}=t.options[t.selected],{info:r}=s;if(!r)return;let o=typeof r=="string"?document.createTextNode(r):r(s);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,s)}).catch(l=>me(this.view.state,l,"completion info")):(this.addInfoPane(o,s),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;i.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&r0(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottom{o.target==s&&o.preventDefault()});let r=null;for(let o=i.from;oi.from||i.from==0))if(r=u,typeof h!="string"&&h.header)s.appendChild(h.header(h));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=u}}let c=s.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let f=this.optionClass(l);f&&(c.className=f);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&c.appendChild(d)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.tonew xa(t,n,e)}function r0(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),s=t.height/n.offsetHeight;i.topt.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/s)}function Pu(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function o0(n,e){let t=[],i=null,s=null,r=c=>{t.push(c);let{section:f}=c.completion;if(f){i||(i=[]);let u=typeof f=="string"?f:f.name;i.some(d=>d.name==u)||i.push(typeof f=="string"?{name:u}:f)}},o=e.facet(ue);for(let c of n)if(c.hasResult()){let f=c.result.getMatch;if(c.result.filter===!1)for(let u of c.result.options)r(new mr(u,c.source,f?f(u):[],1e9-t.length));else{let u=e.sliceDoc(c.from,c.to),d,p=o.filterStrict?new ya(u):new ga(u);for(let O of c.result.options)if(d=p.match(O.label)){let m=O.displayLabel?f?f(O,d.matched):[]:d.matched,g=d.score+(O.boost||0);if(r(new mr(O,c.source,m,g)),typeof O.section=="object"&&O.section.rank==="dynamic"){let{name:S}=O.section;s||(s=Object.create(null)),s[S]=Math.max(g,s[S]||-1e9)}}}}if(i){let c=Object.create(null),f=0,u=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?s[p.name]-s[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.nameu.score-f.score||h(f.completion,u.completion))){let f=c.completion;!a||a.label!=f.label||a.detail!=f.detail||a.type!=null&&f.type!=null&&a.type!=f.type||a.apply!=f.apply||a.boost!=f.boost?l.push(c):Pu(c.completion)>Pu(a)&&(l[l.length-1]=c),a=c.completion}return l}var ba=class n{constructor(e,t,i,s,r,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new n(this.options,Tu(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,s,r,o){if(s&&!o&&e.some(h=>h.isPending))return s.setDisabled();let l=o0(e,t);if(!l.length)return s&&e.some(h=>h.isPending)?s.setDisabled():null;let a=t.facet(ue).selectOnOpen?0:-1;if(s&&s.selected!=a&&s.selected!=-1){let h=s.options[s.selected].completion;for(let c=0;cc.hasResult()?Math.min(h,c.from):h,1e8),create:u0,above:r.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(e){return new n(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new n(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},Sa=class n{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new n(c0,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(ue),r=(i.override||t.languageDataAt("autocomplete",pi(t)).map(t0)).map(a=>(this.active.find(c=>c.source==a)||new Tt(a,this.active.some(c=>c.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((a,h)=>a==this.active[h])&&(r=this.active);let o=this.open,l=e.effects.some(a=>a.is(Ca));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!l0(r,this.active)||l?o=ba.build(r,t,this.id,o,i,l):o&&o.disabled&&!r.some(a=>a.isPending)&&(o=null),!o&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new Tt(a.source,0):a));for(let a of e.effects)a.is(Ta)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new n(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?a0:h0}};function l0(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}var c0=[];function Xu(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(Pa);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}var Tt=class n{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=Xu(e,t),s=this;(i&8||i&16&&this.touches(e))&&(s=new n(s.source,0)),i&4&&s.state==0&&(s=new n(this.source,1)),s=s.updateFor(e,i);for(let r of e.effects)if(r.is(gr))s=new n(s.source,1,r.value);else if(r.is(Mn))s=new n(s.source,0);else if(r.is(Ca))for(let o of r.value)o.source==s.source&&(s=o);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(pi(e.state))}},yr=class n extends Tt{constructor(e,t,i,s,r,o){super(e,3,t),this.limit=i,this.result=s,this.from=r,this.to=o}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=pi(e.state);if(l>o||!s||t&2&&(pi(e.startState)==this.from||lt.map(e))}}),Xe=ne.define({create(){return Sa.start()},update(n,e){return n.update(e)},provide:n=>[Qn.from(n,e=>e.tooltip),T.contentAttributes.from(n,e=>e.attrs)]});function Za(n,e){let t=e.completion.apply||e.completion.label,i=n.state.field(Xe).active.find(s=>s.source==e.source);return i instanceof yr?(typeof t=="string"?n.dispatch({...e0(n.state,t,i.from,i.to),annotations:Pa.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}var u0=s0(Xe,Za);function pr(n,e="option"){return t=>{let i=t.state.field(Xe,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+s*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:Ta.of(l)}),!0}}var d0=n=>{let e=n.state.field(Xe,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampn.state.field(Xe,!1)?(n.dispatch({effects:gr.of(!0)}),!0):!1,p0=n=>{let e=n.state.field(Xe,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Mn.of(null)}),!0)},wa=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},O0=50,m0=1e3,g0=ie.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(Xe).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(Xe),t=n.state.facet(ue);if(!n.selectionSet&&!n.docChanged&&n.startState.field(Xe)==e)return;let i=n.transactions.some(r=>{let o=Xu(r,t);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;rO0&&Date.now()-o.time>m0){for(let l of o.context.abortListeners)try{l()}catch(a){me(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(r=>r.effects.some(o=>o.is(gr)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of n.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(Xe);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ue).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=pi(e),i=new Or(e,t,n.explicit,this.view),s=new wa(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:Mn.of(null)}),me(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ue).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(ue),i=this.view.state.field(Xe);for(let s=0;sl.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new Tt(r.active.source,0);for(let a of r.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Ca.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(Xe,!1);if(e&&e.tooltip&&this.view.state.facet(ue).closeOnBlur){let t=e.open&&Ul(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Mn.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:gr.of(!1)}),20),this.composing=0}}}),y0=typeof navigator=="object"&&/Win/.test(navigator.platform),x0=Ue.highest(T.domEventHandlers({keydown(n,e){let t=e.state.field(Xe,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(y0&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],s=t.active.find(o=>o.source==i.source),r=i.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(n.key)>-1&&Za(e,i),!1}})),Lu=T.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),ka=class{constructor(e,t,i,s){this.field=e,this.line=t,this.from=i,this.to=s}},Qa=class n{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,ce.TrackDel),i=e.mapPos(this.to,1,ce.TrackDel);return t==null||i==null?null:new n(this.field,t,i)}},va=class n{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(i.length){let h=o,c=/^\t*/.exec(a)[0].length;for(let f=0;fnew Qa(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],s=[],r;for(let o of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=r[1]?+r[1]:null,a=r[2]||r[3]||"",h=-1,c=a.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f=h&&u.field++}for(let f of s)if(f.line==i.length&&f.from>r.index){let u=r[2]?3+(r[1]||"").length:2;f.from-=u,f.to-=u}s.push(new ka(h,i.length,r.index,r.index+c.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}o=o.replace(/\\([{}])/g,(l,a,h)=>{for(let c of s)c.line==i.length&&c.from>h&&(c.from--,c.to--);return a}),i.push(o)}return new n(i,s)}},b0=R.widget({widget:new class extends $e{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),S0=R.mark({class:"cm-snippetField"}),qi=class n{constructor(e,t){this.ranges=e,this.active=t,this.deco=R.set(e.map(i=>(i.from==i.to?b0:S0).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let s=i.map(e);if(!s)return null;t.push(s)}return new n(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}},Ln=E.define({map(n,e){return n&&n.map(e)}}),w0=E.define(),Rn=ne.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(Ln))return t.value;if(t.is(w0)&&n)return new qi(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>T.decorations.from(n,e=>e?e.deco:R.none)});function Aa(n,e){return x.create(n.filter(t=>t.field==e).map(t=>x.range(t.from,t.to)))}function k0(n){let e=va.parse(n);return(t,i,s,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,s),{main:a}=t.state.selection,h={changes:{from:s,to:r==a.from?a.to:r,insert:B.of(o)},scrollIntoView:!0,annotations:i?[Pa.of(i),ae.userEvent.of("input.complete")]:void 0};if(l.length&&(h.selection=Aa(l,0)),l.some(c=>c.field>0)){let c=new qi(l,0),f=h.effects=[Ln.of(c)];t.state.field(Rn,!1)===void 0&&f.push(E.appendConfig.of([Rn,T0,C0,Lu]))}t.dispatch(t.state.update(h))}}function Eu(n){return({state:e,dispatch:t})=>{let i=e.field(Rn,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return t(e.update({selection:Aa(i.ranges,s),effects:Ln.of(r?null:new qi(i.ranges,s)),scrollIntoView:!0})),!0}}var Q0=({state:n,dispatch:e})=>n.field(Rn,!1)?(e(n.update({effects:Ln.of(null)})),!0):!1,v0=Eu(1),$0=Eu(-1);var P0=[{key:"Tab",run:v0,shift:$0},{key:"Escape",run:Q0}],Cu=P.define({combine(n){return n.length?n[0]:P0}}),T0=Ue.highest(Bi.compute([Cu],n=>n.facet(Cu)));function Pe(n,e){return{...e,apply:k0(n)}}var C0=T.domEventHandlers({mousedown(n,e){let t=e.state.field(Rn,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==t.active?!1:(e.dispatch({selection:Aa(t.ranges,s.field),effects:Ln.of(t.ranges.some(r=>r.field>s.field)?new qi(t.ranges,s.field):null),scrollIntoView:!0}),!0)}});var Xn={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},di=E.define({map(n,e){let t=e.mapPos(n,-1,ce.TrackAfter);return t??void 0}}),Ma=new class extends Ge{};Ma.startSide=1;Ma.endSide=-1;var Du=ne.define({create(){return I.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(di)&&(n=n.update({add:[Ma.range(t.value,t.value+1)]}));return n}});function zu(){return[A0,Du]}var ma="()[]{}<>\xAB\xBB\xBB\xAB\uFF3B\uFF3D\uFF5B\uFF5D";function _u(n){for(let e=0;e{if((Z0?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&_e(Oe(i,0))==1||e!=s.from||t!=s.to)return!1;let r=R0(n.state,i);return r?(n.dispatch(r),!0):!1}),M0=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=Wu(n,n.selection.main.head).brackets||Xn.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let l=X0(n.doc,o.head);for(let a of i)if(a==l&&xr(n.doc,o.head)==_u(Oe(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:x.cursor(o.head-a.length)}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},Bu=[{key:"Backspace",run:M0}];function R0(n,e){let t=Wu(n,n.selection.main.head),i=t.brackets||Xn.brackets;for(let s of i){let r=_u(Oe(s,0));if(e==s)return r==s?D0(n,s,i.indexOf(s+s+s)>-1,t):L0(n,s,r,t.before||Xn.before);if(e==r&&Yu(n,n.selection.main.from))return E0(n,s,r)}return null}function Yu(n,e){let t=!1;return n.field(Du).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function xr(n,e){let t=n.sliceString(e,e+2);return t.slice(0,_e(Oe(t,0)))}function X0(n,e){let t=n.sliceString(e-2,e);return _e(Oe(t,0))==t.length?t:t.slice(1)}function L0(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:di.of(o.to+e.length),range:x.range(o.anchor+e.length,o.head+e.length)};let l=xr(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:di.of(o.head+e.length),range:x.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function E0(n,e,t){let i=null,s=n.changeByRange(r=>r.empty&&xr(n.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:x.cursor(r.head+t.length)}:i={range:r});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function D0(n,e,t,i){let s=i.stringPrefixes||Xn.stringPrefixes,r=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:di.of(l.to+e.length),range:x.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=xr(n.doc,a),c;if(h==e){if(Zu(n,a))return{changes:{insert:e+e,from:a},effects:di.of(a+e.length),range:x.cursor(a+e.length)};if(Yu(n,a)){let u=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:x.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(c=Au(n,a-2*e.length,s))>-1&&Zu(n,c))return{changes:{insert:e+e+e+e,from:a},effects:di.of(a+e.length),range:x.cursor(a+e.length)};if(n.charCategorizer(a)(h)!=F.Word&&Au(n,a,s)>-1&&!z0(n,a,e,s))return{changes:{insert:e+e,from:a},effects:di.of(a+e.length),range:x.cursor(a+e.length)}}return{range:r=l}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Zu(n,e){let t=se(n).resolveInner(e+1);return t.parent&&t.from==e}function z0(n,e,t,i){let s=se(n).resolveInner(e,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=s.firstChild;for(;c&&c.from==s.from&&c.to-c.from>t.length+a;){if(n.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let h=s.to==e&&s.parent;if(!h)break;s=h}return!1}function Au(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=F.Word)return e;for(let s of t){let r=e-s.length;if(n.sliceDoc(r,e)==s&&i(n.sliceDoc(r-1,r))!=F.Word)return r}return-1}function Iu(n={}){return[x0,Xe,ue.of(n),g0,_0,Lu]}var Ra=[{key:"Ctrl-Space",run:Oa},{mac:"Alt-`",run:Oa},{mac:"Alt-i",run:Oa},{key:"Escape",run:p0},{key:"ArrowDown",run:pr(!0)},{key:"ArrowUp",run:pr(!1)},{key:"PageDown",run:pr(!0,"page")},{key:"PageUp",run:pr(!1,"page")},{key:"Enter",run:d0}],_0=Ue.highest(Bi.computeN([ue],n=>n.facet(ue).defaultKeymap?[Ra]:[]));var Nu=[Pe("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),Pe("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),Pe("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),Pe("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),Pe("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),Pe(`try { \${} } catch (\${error}) { \${} }`,{label:"try",detail:"/ catch block",type:"keyword"}),Pe("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),Pe(`if (\${}) { \${} } else { \${} }`,{label:"if",detail:"/ else block",type:"keyword"}),Pe(`class \${name} { constructor(\${params}) { \${} } }`,{label:"class",detail:"definition",type:"keyword"}),Pe('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Pe('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],W0=Nu.concat([Pe("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Pe("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Pe("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),qu=new Kn,Gu=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function En(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),!0}}var B0=["FunctionDeclaration"],Y0={FunctionDeclaration:En("function"),ClassDeclaration:En("class"),ClassExpression:()=>!0,EnumDeclaration:En("constant"),TypeAliasDeclaration:En("type"),NamespaceDeclaration:En("namespace"),VariableDefinition(n,e){n.matchContext(B0)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function Uu(n,e){let t=qu.get(e);if(t)return t;let i=[],s=!0;function r(o,l){let a=n.sliceString(o.from,o.to);i.push({label:a,type:l})}return e.cursor(J.IncludeAnonymous).iterate(o=>{if(s)s=!1;else if(o.name){let l=Y0[o.name];if(l&&l(o,r)||Gu.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of Uu(n,o.node))i.push(l);return!1}}),qu.set(e,i),i}var Vu=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Fu=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function I0(n){let e=se(n.state).resolveInner(n.pos,-1);if(Fu.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Vu.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let s=e;s;s=s.parent)Gu.has(s.name)&&(i=i.concat(Uu(n.state.doc,s)));return{options:i,from:t?e.from:n.pos,validFor:Vu}}var Oi=tr.define({name:"javascript",parser:yh.configure({props:[fr.add({IfStatement:ur({except:/^\s*({|else\b)/}),TryStatement:ur({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:iu,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:eu({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":ur({except:/^\s*{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),ca.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":su,BlockComment(n){return{from:n.from+2,to:n.to-2}},JSXElement(n){let e=n.firstChild;if(!e||e.name=="JSXSelfClosingTag")return null;let t=n.lastChild;return{from:e.to,to:t.type.isError?n.to:t.from}},"JSXSelfClosingTag JSXOpenTag"(n){var e;let t=(e=n.firstChild)===null||e===void 0?void 0:e.nextSibling,i=n.lastChild;return!t||t.type.isError?null:{from:t.to,to:i.type.isError?n.to:i.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Hu={test:n=>/^JSX/.test(n.name),facet:ar({commentTokens:{block:{open:"{/*",close:"*/}"}}})},q0=Oi.configure({dialect:"ts"},"typescript"),V0=Oi.configure({dialect:"jsx",props:[hr.add(n=>n.isTop?[Hu]:void 0)]}),j0=Oi.configure({dialect:"jsx ts",props:[hr.add(n=>n.isTop?[Hu]:void 0)]},"typescript"),Ku=n=>({label:n,type:"keyword"}),Ju="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(Ku),N0=Ju.concat(["declare","implements","private","protected","public"].map(Ku));function G0(n={}){let e=n.jsx?n.typescript?j0:V0:n.typescript?q0:Oi,t=n.typescript?W0.concat(N0):Nu.concat(Ju);return new ir(e,[Oi.data.of({autocomplete:Mu(Fu,$a(t))}),Oi.data.of({autocomplete:I0}),n.jsx?H0:[]])}function U0(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(n.name=="JSXEscape"||!n.parent)return null;n=n.parent}}function ju(n,e,t=n.length){for(let i=e?.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}var F0=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),H0=T.inputHandler.of((n,e,t,i,s)=>{if((F0?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!Oi.isActiveAt(n.state,e,-1))return!1;let r=s(),{state:o}=r,l=o.changeByRange(a=>{var h;let{head:c}=a,f=se(o).resolveInner(c-1,-1),u;if(f.name=="JSXStartTag"&&(f=f.parent),!(o.doc.sliceString(c-1,c)!=i||f.name=="JSXAttributeValue"&&f.to>c)){if(i==">"&&f.name=="JSXFragmentTag")return{range:a,changes:{from:c,insert:""}};if(i=="/"&&f.name=="JSXStartCloseTag"){let d=f.parent,p=d.parent;if(p&&d.from==c-2&&((u=ju(o.doc,p.firstChild,c))||((h=p.firstChild)===null||h===void 0?void 0:h.name)=="JSXFragmentTag")){let O=`${u}>`;return{range:x.cursor(c+O.length,-1),changes:{from:c,insert:O}}}}else if(i==">"){let d=U0(f);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(c,c+2))&&(u=ju(o.doc,d,c)))return{range:a,changes:{from:c,insert:``}}}}return{range:a}});return l.changes.empty?!1:(n.dispatch([r,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});function ed(n){td(n,"start");var e={},t=n.languageData||{},i=!1;for(var s in n)if(s!=t&&n.hasOwnProperty(s))for(var r=e[s]=[],o=n[s],l=0;l2&&o.token&&typeof o.token!="string"){t.pending=[];for(var h=2;h-1)return null;var s=t.indent.length-1,r=n[t.state];e:for(;;){for(var o=0;o!\?@#$%&|:\.]+)/,token:"variable"},{regex:/"(?:[^"\\\x00-\x1f\x7f]|\\[nt\\'"]|\\[0-9a-fA-F][0-9a-fA-F])*"/,token:"string"},{regex:/\(;.*?/,token:"comment",next:"comment"},{regex:/;;.*$/,token:"comment"},{regex:/\(/,indent:!0},{regex:/\)/,dedent:!0}],comment:[{regex:/.*?;\)/,token:"comment",next:"start"},{regex:/.*/,token:"comment"}],languageData:{name:"wast",dontIndentStates:["comment"]}});var r1=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Wa(n.state,t.from);return i.line?o1(n):i.block?a1(n):!1};function _a(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=n(e,t);return s?(i(t.update(s)),!0):!1}}var o1=_a(f1,0);var l1=_a(cd,0);var a1=_a((n,e)=>cd(n,e,c1(e)),0);function Wa(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}var Dn=50;function h1(n,{open:e,close:t},i,s){let r=n.sliceDoc(i-Dn,i),o=n.sliceDoc(s,s+Dn),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,h=r.length-l;if(r.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let c,f;s-i<=2*Dn?c=f=n.sliceDoc(i,s):(c=n.sliceDoc(i,i+Dn),f=n.sliceDoc(s-Dn,s));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return c.slice(u,u+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function c1(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),s=t.to<=i.to?i:n.doc.lineAt(t.to);s.from>i.from&&s.from==t.to&&(s=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=s.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return e}function cd(n,e,t=e.selection.ranges){let i=t.map(r=>Wa(e,r.from).block);if(!i.every(r=>r))return null;let s=t.map((r,o)=>h1(e,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,l;os&&(r==o||o>f.from)){s=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+h.length)==h?u:-1;ur.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&r.push({from:l.from+h,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,r.push({from:h,to:c})}return{changes:r}}return null}var La=Ze.define(),u1=Ze.define(),d1=P.define(),fd=P.define({combine(n){return be(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,s)=>e(i,s)||t(i,s)})}}),ud=ne.define({create(){return mi.empty},update(n,e){let t=e.state.facet(fd),i=e.annotation(La);if(i){let a=at.fromTransaction(e,i.selection),h=i.side,c=h==0?n.undone:n.done;return a?c=Sr(c,c.length,t.minDepth,a):c=md(c,e.startState.selection),new mi(h==0?i.rest:c,h==0?c:i.rest)}let s=e.annotation(u1);if((s=="full"||s=="before")&&(n=n.isolate()),e.annotation(ae.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=at.fromTransaction(e),o=e.annotation(ae.time),l=e.annotation(ae.userEvent);return r?n=n.addChanges(r,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new mi(n.done.map(at.fromJSON),n.undone.map(at.fromJSON))}});function dd(n={}){return[ud,fd.of(n),T.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?pd:e.inputType=="historyRedo"?Ea:null;return i?(e.preventDefault(),i(t)):!1}})]}function wr(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let s=t.field(ud,!1);if(!s)return!1;let r=s.pop(n,t,e);return r?(i(r),!0):!1}}var pd=wr(0,!1),Ea=wr(1,!1),p1=wr(0,!0),O1=wr(1,!0);var at=class n{constructor(e,t,i,s,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new n(e.changes&&Qe.fromJSON(e.changes),[],e.mapped&&wt.fromJSON(e.mapped),e.startSelection&&x.fromJSON(e.startSelection),e.selectionsAfter.map(x.fromJSON))}static fromTransaction(e,t){let i=et;for(let s of e.startState.facet(d1)){let r=s(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,et)}static selection(e){return new n(void 0,et,void 0,void 0,e)}};function Sr(n,e,t,i){let s=e+1>t+20?e-t-1:0,r=n.slice(s,e);return r.push(i),r}function m1(n,e){let t=[],i=!1;return n.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a=h&&o<=c&&(i=!0)}}),i}function g1(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Od(n,e){return n.length?e.length?n.concat(e):n:e}var et=[],y1=200;function md(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-y1));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Sr(n,n.length-1,1e9,t.setSelAfter(i)))}else return[at.selection([e])]}function x1(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Xa(n,e){if(!n.length)return n;let t=n.length,i=et;for(;t;){let s=b1(n[t-1],e,i);if(s.changes&&!s.changes.empty||s.effects.length){let r=n.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,i=s.selectionsAfter}return i.length?[at.selection(i)]:et}function b1(n,e,t){let i=Od(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):et,t);if(!n.changes)return at.selection(i);let s=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new at(s,E.mapEffects(n.effects,e),o,n.startSelection.map(r),i)}var S1=/^(input\.type|delete)($|\.)/,mi=class n{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new n(this.done,this.undone):this}addChanges(e,t,i,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||S1.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):kr(t,e))}function Se(n){return n.textDirectionAt(n.state.selection.main.head)==N.LTR}var xd=n=>yd(n,!Se(n)),bd=n=>yd(n,Se(n));function Sd(n,e){return ct(n,t=>t.empty?n.moveByGroup(t,e):kr(t,e))}var w1=n=>Sd(n,!Se(n)),k1=n=>Sd(n,Se(n));var Ob=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Q1(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Qr(n,e,t){let i=se(n).resolveInner(e.head),s=t?z.closedBy:z.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;Q1(n,h,s)?i=h:a=t?h.to:h.from}let r=i.type.prop(s),o,l;return r&&(o=t?lt(n,i.from,1):lt(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,x.cursor(l,t?-1:1)}var v1=n=>ct(n,e=>Qr(n.state,e,!Se(n))),$1=n=>ct(n,e=>Qr(n.state,e,Se(n)));function wd(n,e){return ct(n,t=>{if(!t.empty)return kr(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var kd=n=>wd(n,!1),Qd=n=>wd(n,!0);function vd(n){let e=n.scrollDOM.clientHeighto.empty?n.moveVertically(o,e,t.height):kr(o,e));if(s.eq(i.selection))return!1;let r;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom$d(n,!1),Da=n=>$d(n,!0);function Yt(n,e,t){let i=n.lineBlockAt(e.head),s=n.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?i.to:i.from)&&(s=n.moveToLineBoundary(e,t,!1)),!t&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(s=x.cursor(i.from+r))}return s}var P1=n=>ct(n,e=>Yt(n,e,!0)),T1=n=>ct(n,e=>Yt(n,e,!1)),C1=n=>ct(n,e=>Yt(n,e,!Se(n))),Z1=n=>ct(n,e=>Yt(n,e,Se(n))),A1=n=>ct(n,e=>x.cursor(n.lineBlockAt(e.head).from,1)),M1=n=>ct(n,e=>x.cursor(n.lineBlockAt(e.head).to,-1));function R1(n,e,t){let i=!1,s=Vi(n.selection,r=>{let o=lt(n,r.head,-1)||lt(n,r.head,1)||r.head>0&<(n,r.head-1,1)||r.headR1(n,e,!1);function tt(n,e){let t=Vi(n.state.selection,i=>{let s=e(i);return x.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return t.eq(n.state.selection)?!1:(n.dispatch(ht(n.state,t)),!0)}function Pd(n,e){return tt(n,t=>n.moveByChar(t,e))}var Td=n=>Pd(n,!Se(n)),Cd=n=>Pd(n,Se(n));function Zd(n,e){return tt(n,t=>n.moveByGroup(t,e))}var L1=n=>Zd(n,!Se(n)),E1=n=>Zd(n,Se(n));var D1=n=>tt(n,e=>Qr(n.state,e,!Se(n))),z1=n=>tt(n,e=>Qr(n.state,e,Se(n)));function Ad(n,e){return tt(n,t=>n.moveVertically(t,e))}var Md=n=>Ad(n,!1),Rd=n=>Ad(n,!0);function Xd(n,e){return tt(n,t=>n.moveVertically(t,e,vd(n).height))}var nd=n=>Xd(n,!1),sd=n=>Xd(n,!0),_1=n=>tt(n,e=>Yt(n,e,!0)),W1=n=>tt(n,e=>Yt(n,e,!1)),B1=n=>tt(n,e=>Yt(n,e,!Se(n))),Y1=n=>tt(n,e=>Yt(n,e,Se(n))),I1=n=>tt(n,e=>x.cursor(n.lineBlockAt(e.head).from)),q1=n=>tt(n,e=>x.cursor(n.lineBlockAt(e.head).to)),rd=({state:n,dispatch:e})=>(e(ht(n,{anchor:0})),!0),od=({state:n,dispatch:e})=>(e(ht(n,{anchor:n.doc.length})),!0),ld=({state:n,dispatch:e})=>(e(ht(n,{anchor:n.selection.main.anchor,head:0})),!0),ad=({state:n,dispatch:e})=>(e(ht(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),V1=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),j1=({state:n,dispatch:e})=>{let t=vr(n).map(({from:i,to:s})=>x.range(i,Math.min(s+1,n.doc.length)));return e(n.update({selection:x.create(t),userEvent:"select"})),!0},N1=({state:n,dispatch:e})=>{let t=Vi(n.selection,i=>{let s=se(n),r=s.resolveStack(i.from,1);if(i.empty){let o=s.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:l}=o;if((l.from=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return x.range(l.to,l.from)}return i});return t.eq(n.selection)?!1:(e(ht(n,t)),!0)};function Ld(n,e){let{state:t}=n,i=t.selection,s=t.selection.ranges.slice();for(let r of t.selection.ranges){let o=t.doc.lineAt(r.head);if(e?o.to0)for(let l=r;;){let a=n.moveVertically(l,e);if(a.heado.to){s.some(h=>h.head==a.head)||s.push(a);break}else{if(a.head==l.head)break;l=a}}}return s.length==i.ranges.length?!1:(n.dispatch(ht(t,x.create(s,s.length-1))),!0)}var G1=n=>Ld(n,!1),U1=n=>Ld(n,!0),F1=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=x.create([t.main]):t.main.empty||(i=x.create([x.cursor(t.main.head)])),i?(e(ht(n,i)),!0):!1};function zn(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);ao&&(t="delete.forward",a=br(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=br(n,o,!1),l=br(n,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:x.cursor(o,os(n)))i.between(e,e,(s,r)=>{se&&(e=t?r:s)});return e}var Ed=(n,e,t)=>zn(n,i=>{let s=i.from,{state:r}=n,o=r.doc.lineAt(s),l,a;if(t&&!e&&s>o.from&&sEd(n,!1,!0);var Dd=n=>Ed(n,!0,!1),zd=(n,e)=>zn(n,t=>{let i=t.head,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t.head&&r.number!=(e?s.doc.lines:1)&&(i+=e?1:-1);break}let a=re(r.text,i-r.from,e)+r.from,h=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t.head)&&(l=c),i=a}return i}),_d=n=>zd(n,!1),H1=n=>zd(n,!0);var K1=n=>zn(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headzn(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),ey=n=>zn(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:B.of(["",""])},range:x.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},iy=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:re(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:re(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:n.doc.slice(s,l).append(n.doc.slice(o,s))},range:x.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function vr(n){let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:s.from,to:r.to,ranges:[i]});t=r.number+1}return e}function Wd(n,e,t){if(n.readOnly)return!1;let i=[],s=[];for(let r of vr(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let a of r.ranges)s.push(x.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let a of r.ranges)s.push(x.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:x.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var ny=({state:n,dispatch:e})=>Wd(n,e,!1),sy=({state:n,dispatch:e})=>Wd(n,e,!0);function Bd(n,e,t){if(n.readOnly)return!1;let i=[];for(let r of vr(n))t?i.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):i.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});let s=n.changes(i);return e(n.update({changes:s,selection:n.selection.map(s,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var ry=({state:n,dispatch:e})=>Bd(n,e,!1),oy=({state:n,dispatch:e})=>Bd(n,e,!0),ly=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(vr(e).map(({from:s,to:r})=>(s>0?s--:r{let r;if(n.lineWrapping){let o=n.lineBlockAt(s.head),l=n.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(s,!0,r)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function ay(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=se(n).resolveInner(e),i=t.childBefore(e),s=t.childAfter(e),r;return i&&s&&i.to<=e&&s.from>=e&&(r=i.type.prop(z.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from&&!/\S/.test(n.sliceDoc(i.to,s.from))?{from:i.to,to:s.from}:null}var hd=Yd(!1),hy=Yd(!0);function Yd(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!n&&r==o&&ay(e,r);n&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new fi(e,{simulateBreak:r,simulateDoubleBreak:!!a}),c=cr(h,r);for(c==null&&(c=kt(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));ol.from&&r{let s=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,s,i),t=l.number),o=l.to+1}let r=n.changes(s);return{changes:s,range:x.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}var cy=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new fi(n,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=Ba(n,(r,o,l)=>{let a=cr(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let h=/^\s*/.exec(r.text)[0],c=Ii(n,a);(h!=c||l.fromn.readOnly?!1:(e(n.update(Ba(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Yi)})}),{userEvent:"input.indent"})),!0),uy=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ba(n,(t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=kt(s,n.tabSize),o=0,l=Ii(n,Math.max(0,r-Bt(n)));for(;o(n.setTabFocusMode(),!0);var py=[{key:"Ctrl-b",run:xd,shift:Td,preventDefault:!0},{key:"Ctrl-f",run:bd,shift:Cd},{key:"Ctrl-p",run:kd,shift:Md},{key:"Ctrl-n",run:Qd,shift:Rd},{key:"Ctrl-a",run:A1,shift:I1},{key:"Ctrl-e",run:M1,shift:q1},{key:"Ctrl-d",run:Dd},{key:"Ctrl-h",run:za},{key:"Ctrl-k",run:K1},{key:"Ctrl-Alt-h",run:_d},{key:"Ctrl-o",run:ty},{key:"Ctrl-t",run:iy},{key:"Ctrl-v",run:Da}],Oy=[{key:"ArrowLeft",run:xd,shift:Td,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:w1,shift:L1,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:C1,shift:B1,preventDefault:!0},{key:"ArrowRight",run:bd,shift:Cd,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:k1,shift:E1,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Z1,shift:Y1,preventDefault:!0},{key:"ArrowUp",run:kd,shift:Md,preventDefault:!0},{mac:"Cmd-ArrowUp",run:rd,shift:ld},{mac:"Ctrl-ArrowUp",run:id,shift:nd},{key:"ArrowDown",run:Qd,shift:Rd,preventDefault:!0},{mac:"Cmd-ArrowDown",run:od,shift:ad},{mac:"Ctrl-ArrowDown",run:Da,shift:sd},{key:"PageUp",run:id,shift:nd},{key:"PageDown",run:Da,shift:sd},{key:"Home",run:T1,shift:W1,preventDefault:!0},{key:"Mod-Home",run:rd,shift:ld},{key:"End",run:P1,shift:_1,preventDefault:!0},{key:"Mod-End",run:od,shift:ad},{key:"Enter",run:hd,shift:hd},{key:"Mod-a",run:V1},{key:"Backspace",run:za,shift:za,preventDefault:!0},{key:"Delete",run:Dd,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:_d,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:H1,preventDefault:!0},{mac:"Mod-Backspace",run:J1,preventDefault:!0},{mac:"Mod-Delete",run:ey,preventDefault:!0}].concat(py.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Id=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:v1,shift:D1},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:$1,shift:z1},{key:"Alt-ArrowUp",run:ny},{key:"Shift-Alt-ArrowUp",run:ry},{key:"Alt-ArrowDown",run:sy},{key:"Shift-Alt-ArrowDown",run:oy},{key:"Mod-Alt-ArrowUp",run:G1},{key:"Mod-Alt-ArrowDown",run:U1},{key:"Escape",run:F1},{key:"Mod-Enter",run:hy},{key:"Alt-l",mac:"Ctrl-l",run:j1},{key:"Mod-i",run:N1,preventDefault:!0},{key:"Mod-[",run:uy},{key:"Mod-]",run:fy},{key:"Mod-Alt-\\",run:cy},{key:"Shift-Mod-k",run:ly},{key:"Shift-Mod-\\",run:X1},{key:"Mod-/",run:r1},{key:"Alt-A",run:l1},{key:"Ctrl-m",mac:"Shift-Alt-m",run:dy}].concat(Oy);var qd=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n,qt=class{constructor(e,t,i=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=r?l=>r(qd(l)):qd,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Oe(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=on(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=_e(e);let s=this.normalize(t);if(s.length)for(let r=0,o=i;;r++){let l=s.charCodeAt(r),a=this.match(l,o,this.bufferPos+this.bufferStart);if(r==s.length-1){if(a)return this.value=a,this;break}o==i&&rthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,s=i+t[0].length;if(this.matchPos=Ar(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=i||s.to<=t){let l=new n(t,e.sliceString(t,i));return Ya.set(e,l),l}if(s.from==t&&s.to==i)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,s=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,match:t},this.matchPos=Ar(this.text,s+(i==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Cr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(Tr.prototype[Symbol.iterator]=Zr.prototype[Symbol.iterator]=function(){return this});function my(n){try{return new RegExp(n,Na),!0}catch{return!1}}function Ar(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e=56320&&i<57344;)e++;return e}var gy=n=>{let{state:e}=n,t=String(e.doc.lineAt(n.state.selection.main.head).number),{close:i,result:s}=Df(n,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:t},focus:!0,submitLabel:e.phrase("go")});return s.then(r=>{let o=r&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(r.elements.line.value);if(!o){n.dispatch({effects:i});return}let l=e.doc.lineAt(e.selection.main.head),[,a,h,c,f]=o,u=c?+c.slice(1):0,d=h?+h:l.number;if(h&&f){let m=d/100;a&&(m=m*(a=="-"?-1:1)+l.number/e.doc.lines),d=Math.round(e.doc.lines*m)}else h&&a&&(d=d*(a=="-"?-1:1)+l.number);let p=e.doc.line(Math.max(1,Math.min(e.doc.lines,d))),O=x.cursor(p.from+Math.max(0,Math.min(u,p.length)));n.dispatch({effects:[i,T.scrollIntoView(O.from,{y:"center"})],selection:O})}),!0},yy={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Gd=P.define({combine(n){return be(n,yy,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Ud(n){let e=[ky,wy];return n&&e.push(Gd.of(n)),e}var xy=R.mark({class:"cm-selectionMatch"}),by=R.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Vd(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=F.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=F.Word)}function Sy(n,e,t,i){return n(e.sliceDoc(t,t+1))==F.Word&&n(e.sliceDoc(i-1,i))==F.Word}var wy=ie.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(Gd),{state:t}=n,i=t.selection;if(i.ranges.length>1)return R.none;let s=i.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return R.none;let a=t.wordAt(s.head);if(!a)return R.none;o=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a200)return R.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(Vd(o,t,s.from,s.to)&&Sy(o,t,s.from,s.to)))return R.none}else if(r=t.sliceDoc(s.from,s.to),!r)return R.none}let l=[];for(let a of n.visibleRanges){let h=new qt(t.doc,r,a.from,a.to);for(;!h.next().done;){let{from:c,to:f}=h.value;if((!o||Vd(o,t,c,f))&&(s.empty&&c<=s.from&&f>=s.to?l.push(by.range(c,f)):(c>=s.to||f<=s.from)&&l.push(xy.range(c,f)),l.length>e.maxMatches))return R.none}}return R.set(l)}},{decorations:n=>n.decorations}),ky=T.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Qy=({state:n,dispatch:e})=>{let{selection:t}=n,i=x.create(t.ranges.map(s=>n.wordAt(s.head)||x.cursor(s.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function vy(n,e){let{main:t,ranges:i}=n.selection,s=n.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,l=new qt(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new qt(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(r){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}var $y=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(r=>r.from===r.to))return Qy({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(r=>n.sliceDoc(r.from,r.to)!=i))return!1;let s=vy(n,i);return s?(e(n.update({selection:n.selection.addRange(x.range(s.from,s.to),!1),effects:T.scrollIntoView(s.to)})),!0):!1},Gi=P.define({combine(n){return be(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ja(e),scrollToMatch:e=>T.scrollIntoView(e)})}});var Mr=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||my(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?` `:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new qa(this):new Ia(this)}getCursor(e,t=0,i){let s=e.doc?e:H.create({doc:e});return i==null&&(i=s.doc.length),this.regexp?Ni(this,s,t,i):ji(this,s,t,i)}},Rr=class{constructor(e){this.spec=e}};function Py(n,e,t){return(i,s,r,o)=>{if(t&&!t(i,s,r,o))return!1;let l=i>=o&&s<=o+r.length?r.slice(i-o,s-o):e.doc.sliceString(i,s);return n(l,e,i,s)}}function ji(n,e,t,i){let s;return n.wholeWord&&(s=Ty(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(s=Py(n.test,e,s)),new qt(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),s)}function Ty(n,e){return(t,i,s,r)=>((r>t||r+s.length=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=ji(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}};function Cy(n,e,t){return(i,s,r)=>(!t||t(i,s,r))&&n(r[0],e,i,s)}function Ni(n,e,t,i){let s;return n.wholeWord&&(s=Zy(e.charCategorizer(e.selection.main.head))),n.test&&(s=Cy(n.test,e,s)),new Tr(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:s},t,i)}function Xr(n,e){return n.slice(re(n,e,!1),e)}function Lr(n,e){return n.slice(e,re(n,e))}function Zy(n){return(e,t,i)=>!i[0].length||(n(Xr(i.input,i.index))!=F.Word||n(Lr(i.input,i.index))!=F.Word)&&(n(Lr(i.input,i.index+i[0].length))!=F.Word||n(Xr(i.input,i.index+i[0].length))!=F.Word)}var qa=class extends Rr{nextMatch(e,t,i){let s=Ni(this.spec,e,i,e.doc.length).next();return s.done&&(s=Ni(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=Ni(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let s=i.length;s>0;s--){let r=+i.slice(0,s);if(r>0&&r=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Ni(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}},Wn=E.define(),Ga=E.define(),It=ne.define({create(n){return new _n(Va(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Wn)?n=new _n(t.value.create(),n.panel):t.is(Ga)&&(n=new _n(n.query,t.value?Ua:null));return n},provide:n=>hi.from(n,e=>e.panel)});var _n=class{constructor(e,t){this.query=e,this.panel=t}},Ay=R.mark({class:"cm-searchMatch"}),My=R.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Ry=ie.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(It))}update(n){let e=n.state.field(It);(e!=n.startState.field(It)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return R.none;let{view:t}=this,i=new ze;for(let s=0,r=t.visibleRanges,o=r.length;sr[s+1].from-500;)a=r[++s].to;n.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?My:Ay)})}return i.finish()}},{decorations:n=>n.decorations});function Bn(n){return e=>{let t=e.state.field(It,!1);return t&&t.query.spec.valid?n(e,t):Kd(e)}}var Er=Bn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let s=x.single(i.from,i.to),r=n.state.facet(Gi);return n.dispatch({selection:s,effects:[Fa(n,i),r.scrollToMatch(s.main,n)],userEvent:"select.search"}),Hd(n),!0}),Dr=Bn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,s=e.prevMatch(t,i,i);if(!s)return!1;let r=x.single(s.from,s.to),o=n.state.facet(Gi);return n.dispatch({selection:r,effects:[Fa(n,s),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),Hd(n),!0}),Xy=Bn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:x.create(t.map(i=>x.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),Ly=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:s}=t.main,r=[],o=0;for(let l=new qt(n.doc,n.sliceDoc(i,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(x.range(l.value.from,l.value.to))}return e(n.update({selection:x.create(r,o),userEvent:"select.search.matches"})),!0},jd=Bn((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=r,l=[],a,h,c=[];o.from==i&&o.to==s&&(h=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),o=e.nextMatch(t,o.from,o.to),c.push(T.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+".")));let f=n.state.changes(l);return o&&(a=x.single(o.from,o.to).map(f),c.push(Fa(n,o)),c.push(t.facet(Gi).scrollToMatch(a.main,n))),n.dispatch({changes:f,selection:a,effects:c,userEvent:"input.replace"}),!0}),Ey=Bn((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(s=>{let{from:r,to:o}=s;return{from:r,to:o,insert:e.getReplacement(s)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:T.announce.of(i),userEvent:"input.replace.all"}),!0});function Ua(n){return n.state.facet(Gi).createPanel(n)}function Va(n,e){var t,i,s,r,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=n.facet(Gi);return new Mr({search:((t=e?.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(s=e?.literal)!==null&&s!==void 0?s:h.literal,regexp:(r=e?.regexp)!==null&&r!==void 0?r:h.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function Fd(n){let e=vn(n,Ua);return e&&e.dom.querySelector("[main-field]")}function Hd(n){let e=Fd(n);e&&e==n.root.activeElement&&e.select()}var Kd=n=>{let e=n.state.field(It,!1);if(e&&e.panel){let t=Fd(n);if(t&&t!=n.root.activeElement){let i=Va(n.state,e.query.spec);i.valid&&n.dispatch({effects:Wn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Ga.of(!0),e?Wn.of(Va(n.state,e.query.spec)):E.appendConfig.of(zy)]});return!0},Jd=n=>{let e=n.state.field(It,!1);if(!e||!e.panel)return!1;let t=vn(n,Ua);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Ga.of(!1)}),!0},ep=[{key:"Mod-f",run:Kd,scope:"editor search-panel"},{key:"F3",run:Er,shift:Dr,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Er,shift:Dr,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Jd,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Ly},{key:"Mod-Alt-g",run:gy},{key:"Mod-d",run:$y,preventDefault:!0}],ja=class{constructor(e){this.view=e;let t=this.query=e.state.field(It).query.spec;this.commit=this.commit.bind(this),this.searchField=V("input",{value:t.search,placeholder:Ye(e,"Find"),"aria-label":Ye(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=V("input",{value:t.replace,placeholder:Ye(e,"Replace"),"aria-label":Ye(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=V("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=V("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=V("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(s,r,o){return V("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=V("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>Er(e),[Ye(e,"next")]),i("prev",()=>Dr(e),[Ye(e,"previous")]),i("select",()=>Xy(e),[Ye(e,"all")]),V("label",null,[this.caseField,Ye(e,"match case")]),V("label",null,[this.reField,Ye(e,"regexp")]),V("label",null,[this.wordField,Ye(e,"by word")]),...e.state.readOnly?[]:[V("br"),this.replaceField,i("replace",()=>jd(e),[Ye(e,"replace")]),i("replaceAll",()=>Ey(e),[Ye(e,"replace all")])],V("button",{name:"close",onclick:()=>Jd(e),"aria-label":Ye(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new Mr({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Wn.of(e)}))}keydown(e){kf(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Dr:Er)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),jd(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Wn)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Gi).top}};function Ye(n,e){return n.state.phrase(e)}var $r=30,Pr=/[\s\.,:;?!]/;function Fa(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-$r),o=Math.min(s,t+$r),l=n.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<$r;a++)if(!Pr.test(l[a+1])&&Pr.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-$r;a--)if(!Pr.test(l[a-1])&&Pr.test(l[a])){l=l.slice(0,a);break}}return T.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}var Dy=T.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),zy=[It,Ue.low(Ry),Dy];var _r=class{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}},gi=class n{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=i.facet(Yn).markerFilter;s&&(e=s(e,i));let r=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new ze,l=[],a=0,h=i.doc.iter(),c=0,f=i.doc.length;for(let d=0;;){let p=d==r.length?null:r[d];if(!p&&!l.length)break;let O,m;if(l.length)O=a,m=l.reduce((b,A)=>Math.min(b,A.to),p&&p.from>O?p.from:1e8);else{if(O=p.from,O>f)break;m=p.to,l.push(p),d++}for(;db.from||b.to==O))l.push(b),d++,m=Math.min(b.to,m);else{m=Math.min(b.from,m);break}}m=Math.min(m,f);let g=!1;if(l.some(b=>b.from==O&&(b.to==m||m==f))&&(g=O==m,!g&&m-O<10)){let b=O-(c+h.value.length);b>0&&(h.next(b),c=O);for(let A=O;;){if(A>=m){g=!0;break}if(!h.lineBreak&&c+h.value.length>A)break;A=c+h.value.length,c+=h.value.length,h.next()}}let S=Uy(l);if(g)o.add(O,O,R.widget({widget:new Ha(S),diagnostics:l.slice()}));else{let b=l.reduce((A,w)=>w.markClass?A+" "+w.markClass:A,"");o.add(O,m,R.mark({class:"cm-lintRange cm-lintRange-"+S+b,diagnostics:l.slice(),inclusiveEnd:l.some(A=>A.to>m)}))}if(a=m,a==f)break;for(let b=0;b{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new _r(s,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new _r(i.from,r,i.diagnostic)}}),i}function _y(n,e){let t=e.pos,i=e.end||t,s=n.state.facet(Yn).hideOn(n,t,i);if(s!=null)return s;let r=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(np))||n.changes.touchesRange(r.from,Math.max(r.to,i)))}function Wy(n,e){return n.field(Ie,!1)?e:e.concat(E.appendConfig.of(Fy))}var np=E.define(),Ka=E.define(),sp=E.define(),Ie=ne.define({create(){return new gi(R.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,s=n.panel;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=Vt(t,n.selected.diagnostic,r)||Vt(t,null,r)}!t.size&&s&&e.state.facet(Yn).autoPanel&&(s=null),n=new gi(t,s,i)}for(let t of e.effects)if(t.is(np)){let i=e.state.facet(Yn).autoPanel?t.value.length?In.open:null:n.panel;n=gi.init(t.value,i,e.state)}else t.is(Ka)?n=new gi(n.diagnostics,t.value?In.open:null,n.selected):t.is(sp)&&(n=new gi(n.diagnostics,n.panel,t.value));return n},provide:n=>[hi.from(n,e=>e.panel),T.decorations.from(n,e=>e.diagnostics)]});var By=R.mark({class:"cm-lintRange cm-lintRange-active"});function Yy(n,e,t){let{diagnostics:i}=n.state.field(Ie),s,r=-1,o=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{if(e>=a&&e<=h&&(a==h||(e>a||t>0)&&(elp(n,t,!1)))}var qy=n=>{let e=n.state.field(Ie,!1);(!e||!e.panel)&&n.dispatch({effects:Wy(n.state,[Ka.of(!0)])});let t=vn(n,In.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},tp=n=>{let e=n.state.field(Ie,!1);return!e||!e.panel?!1:(n.dispatch({effects:Ka.of(!1)}),!0)},Vy=n=>{let e=n.state.field(Ie,!1);if(!e)return!1;let t=n.state.selection.main,i=Vt(e.diagnostics,null,t.to+1);return!i&&(i=Vt(e.diagnostics,null,0),!i||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)};var rp=[{key:"Mod-Shift-m",run:qy,preventDefault:!0},{key:"F8",run:Vy}];var Yn=P.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...be(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:ip,tooltipFilter:ip,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,s,r)=>e(i,s,r)||t(i,s,r):e:t,autoPanel:(e,t)=>e||t})}}});function ip(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function op(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;ir.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function lp(n,e,t){var i;let s=t?op(e.actions):[];return V("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},V("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=!1,a=d=>{if(d.preventDefault(),l)return;l=!0;let p=Vt(n.state.field(Ie).diagnostics,e);p&&r.apply(n,p.from,p.to)},{name:h}=r,c=s[o]?h.indexOf(s[o]):-1,f=c<0?h:[h.slice(0,c),V("u",h.slice(c,c+1)),h.slice(c+1)],u=r.markClass?" "+r.markClass:"";return V("button",{type:"button",class:"cm-diagnosticAction"+u,onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${s[o]})"`}.`},f)}),e.source&&V("div",{class:"cm-diagnosticSource"},e.source))}var Ha=class extends $e{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return V("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},Wr=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=lp(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},In=class n{constructor(e){this.view=e,this.items=[];let t=s=>{if(!(s.ctrlKey||s.altKey||s.metaKey)){if(s.keyCode==27)tp(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=op(r.actions);for(let l=0;l{for(let r=0;rtp(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Ie).selected;if(!e)return-1;for(let t=0;t{for(let c of h.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,u;for(let d=i;di&&(this.items.splice(i,f-i),s=!0)),t&&u.diagnostic==t.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),r=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),i++}});i({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let h=a.height/this.list.offsetHeight;l.topa.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Ie),i=Vt(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:sp.of(i)})}static open(e){return new n(e)}};function jy(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function zr(n){return jy(``,'width="6" height="3"')}var Ny=T.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:zr("#d11")},".cm-lintRange-warning":{backgroundImage:zr("orange")},".cm-lintRange-info":{backgroundImage:zr("#999")},".cm-lintRange-hint":{backgroundImage:zr("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Gy(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function Uy(n){let e="hint",t=1;for(let i of n){let s=Gy(i.severity);s>t&&(t=s,e=i.severity)}return e}var Fy=[Ie,T.decorations.compute([Ie],n=>{let{selected:e,panel:t}=n.field(Ie);return!e||!t||e.from==e.to?R.none:R.set([By.range(e.from,e.to)])}),Lf(Yy,{hideOn:_y}),Ny];var Hy=[Bf(),Yf(),Af(),dd(),uu(),Pf(),Zf(),H.allowMultipleSelections.of(!0),nu(),pu(Ou,{fallback:!0}),xu(),zu(),Iu(),Rf(),Xf(),Mf(),Ud(),Bi.of([...Bu,...Id,...ep,...gd,...hu,...Ra,...rp])];var it=typeof window<"u"?window:null,eh=it===null,Vn=eh?void 0:it.document,ft="addEventListener",ut="removeEventListener",Ja="getBoundingClientRect",qn="_a",dt="_b",Ct="_c",Br="horizontal",pt=function(){return!1},Ky=eh?"calc":["","-webkit-","-moz-","-o-"].filter(function(n){var e=Vn.createElement("div");return e.style.cssText="width:"+n+"calc(9px)",!!e.style.length}).shift()+"calc",hp=function(n){return typeof n=="string"||n instanceof String},ap=function(n){if(hp(n)){var e=Vn.querySelector(n);if(!e)throw new Error("Selector "+n+" did not match a DOM element");return e}return n},we=function(n,e,t){var i=n[e];return i!==void 0?i:t},Yr=function(n,e,t,i){if(e){if(i==="end")return 0;if(i==="center")return n/2}else if(t){if(i==="start")return 0;if(i==="center")return n/2}return n},Jy=function(n,e){var t=Vn.createElement("div");return t.className="gutter gutter-"+e,t},ex=function(n,e,t){var i={};return hp(e)?i[n]=e:i[n]=Ky+"("+e+"% - "+t+"px)",i},tx=function(n,e){var t;return t={},t[n]=e+"px",t},ix=function(n,e){if(e===void 0&&(e={}),eh)return{};var t=n,i,s,r,o,l,a;Array.from&&(t=Array.from(t));var h=ap(t[0]),c=h.parentNode,f=getComputedStyle?getComputedStyle(c):null,u=f?f.flexDirection:null,d=we(e,"sizes")||t.map(function(){return 100/t.length}),p=we(e,"minSize",100),O=Array.isArray(p)?p:t.map(function(){return p}),m=we(e,"maxSize",1/0),g=Array.isArray(m)?m:t.map(function(){return m}),S=we(e,"expandToMin",!1),b=we(e,"gutterSize",10),A=we(e,"gutterAlign","center"),w=we(e,"snapOffset",30),v=Array.isArray(w)?w:t.map(function(){return w}),Q=we(e,"dragInterval",1),D=we(e,"direction",Br),W=we(e,"cursor",D===Br?"col-resize":"row-resize"),G=we(e,"gutter",Jy),_=we(e,"elementStyle",ex),X=we(e,"gutterStyle",tx);D===Br?(i="width",s="clientX",r="left",o="right",l="clientWidth"):D==="vertical"&&(i="height",s="clientY",r="top",o="bottom",l="clientHeight");function Y(M,k,C,L){var de=_(i,k,C,L);Object.keys(de).forEach(function(le){M.style[le]=de[le]})}function q(M,k,C){var L=X(i,k,C);Object.keys(L).forEach(function(de){M.style[de]=L[de]})}function j(){return a.map(function(M){return M.size})}function fe(M){return"touches"in M?M.touches[0][s]:M[s]}function ye(M){var k=a[this.a],C=a[this.b],L=k.size+C.size;k.size=M/this.size*L,C.size=L-M/this.size*L,Y(k.element,k.size,this[dt],k.i),Y(C.element,C.size,this[Ct],C.i)}function qe(M){var k,C=a[this.a],L=a[this.b];this.dragging&&(k=fe(M)-this.start+(this[dt]-this.dragOffset),Q>1&&(k=Math.round(k/Q)*Q),k<=C.minSize+C.snapOffset+this[dt]?k=C.minSize+this[dt]:k>=this.size-(L.minSize+L.snapOffset+this[Ct])&&(k=this.size-(L.minSize+this[Ct])),k>=C.maxSize-C.snapOffset+this[dt]?k=C.maxSize+this[dt]:k<=this.size-(L.maxSize-L.snapOffset+this[Ct])&&(k=this.size-(L.maxSize+this[Ct])),ye.call(this,k),we(e,"onDrag",pt)(j()))}function oe(){var M=a[this.a].element,k=a[this.b].element,C=M[Ja](),L=k[Ja]();this.size=C[i]+L[i]+this[dt]+this[Ct],this.start=C[r],this.end=C[o]}function Te(M){if(!getComputedStyle)return null;var k=getComputedStyle(M);if(!k)return null;var C=M[l];return C===0?null:(D===Br?C-=parseFloat(k.paddingLeft)+parseFloat(k.paddingRight):C-=parseFloat(k.paddingTop)+parseFloat(k.paddingBottom),C)}function Ve(M){var k=Te(c);if(k===null||O.reduce(function(le,Le){return le+Le},0)>k)return M;var C=0,L=[],de=M.map(function(le,Le){var jt=k*le/100,Nn=Yr(b,Le===0,Le===M.length-1,A),Gn=O[Le]+Nn;return jt0&&L[Le]-C>0){var Nn=Math.min(C,L[Le]-C);C-=Nn,jt=le-Nn}return jt/k*100})}function Ce(){var M=this,k=a[M.a].element,C=a[M.b].element;M.dragging&&we(e,"onDragEnd",pt)(j()),M.dragging=!1,it[ut]("mouseup",M.stop),it[ut]("touchend",M.stop),it[ut]("touchcancel",M.stop),it[ut]("mousemove",M.move),it[ut]("touchmove",M.move),M.stop=null,M.move=null,k[ut]("selectstart",pt),k[ut]("dragstart",pt),C[ut]("selectstart",pt),C[ut]("dragstart",pt),k.style.userSelect="",k.style.webkitUserSelect="",k.style.MozUserSelect="",k.style.pointerEvents="",C.style.userSelect="",C.style.webkitUserSelect="",C.style.MozUserSelect="",C.style.pointerEvents="",M.gutter.style.cursor="",M.parent.style.cursor="",Vn.body.style.cursor=""}function je(M){if(!("button"in M&&M.button!==0)){var k=this,C=a[k.a].element,L=a[k.b].element;k.dragging||we(e,"onDragStart",pt)(j()),M.preventDefault(),k.dragging=!0,k.move=qe.bind(k),k.stop=Ce.bind(k),it[ft]("mouseup",k.stop),it[ft]("touchend",k.stop),it[ft]("touchcancel",k.stop),it[ft]("mousemove",k.move),it[ft]("touchmove",k.move),C[ft]("selectstart",pt),C[ft]("dragstart",pt),L[ft]("selectstart",pt),L[ft]("dragstart",pt),C.style.userSelect="none",C.style.webkitUserSelect="none",C.style.MozUserSelect="none",C.style.pointerEvents="none",L.style.userSelect="none",L.style.webkitUserSelect="none",L.style.MozUserSelect="none",L.style.pointerEvents="none",k.gutter.style.cursor=W,k.parent.style.cursor=W,Vn.body.style.cursor=W,oe.call(k),k.dragOffset=fe(M)-k.end}}d=Ve(d);var ke=[];a=t.map(function(M,k){var C={element:ap(M),size:d[k],minSize:O[k],maxSize:g[k],snapOffset:v[k],i:k},L;if(k>0&&(L={a:k-1,b:k,dragging:!1,direction:D,parent:c},L[dt]=Yr(b,k-1===0,!1,A),L[Ct]=Yr(b,!1,k===t.length-1,A),u==="row-reverse"||u==="column-reverse")){var de=L.a;L.a=L.b,L.b=de}if(k>0){var le=G(k,D,C.element);q(le,b,k),L[qn]=je.bind(L),le[ft]("mousedown",L[qn]),le[ft]("touchstart",L[qn]),c.insertBefore(le,C.element),L.gutter=le}return Y(C.element,C.size,Yr(b,k===0,k===t.length-1,A),k),k>0&&ke.push(L),C});function bt(M){var k=M.i===ke.length,C=k?ke[M.i-1]:ke[M.i];oe.call(C);var L=k?C.size-M.minSize-C[Ct]:M.minSize+C[dt];ye.call(C,L)}a.forEach(function(M){var k=M.element[Ja]()[i];k0){var de=ke[L-1],le=a[de.a],Le=a[de.b];le.size=k[L-1],Le.size=C,Y(le.element,le.size,de[dt],le.i),Y(Le.element,Le.size,de[Ct],Le.i)}})}function jn(M,k){ke.forEach(function(C){if(k!==!0?C.parent.removeChild(C.gutter):(C.gutter[ut]("mousedown",C[qn]),C.gutter[ut]("touchstart",C[qn])),M!==!0){var L=_(i,C.a.size,C[dt]);Object.keys(L).forEach(function(de){a[C.a].element.style[de]="",a[C.b].element.style[de]=""})}})}return{setSizes:yi,getSizes:j,collapse:function(k){bt(a[k])},destroy:jn,parent:c,pairs:ke}},nx=ix;export{H as EditorState,T as EditorView,nx as Split,aa as StreamLanguage,Hy as basicSetup,G0 as javascript,s1 as wast}; //# sourceMappingURL=third_party.bundle.js.map ================================================ FILE: docs/demo/wasm2wat/demo.js ================================================ /* * Copyright 2017 WebAssembly Community Group participants * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import WabtModule from '../libwabt.js'; import {getLocalStorageFeatures, renderFeatures, saveLocalStorageFeatures} from '../share.js'; import {basicSetup, EditorState, EditorView, StreamLanguage, wast} from '../third_party.bundle.js'; import {examples} from './examples.js'; const features = getLocalStorageFeatures(); const wabt = await WabtModule({ locateFile: (url) => { if (url.endsWith('.wasm')) { return '../' + url; } return url; } }); const editorEl = document.querySelector('.editor'); const uploadEl = document.getElementById('upload'); const selectEl = document.getElementById('select'); const uploadInputEl = document.getElementById('uploadInput'); const generateNamesEl = document.getElementById('generateNames'); const foldExprsEl = document.getElementById('foldExprs'); const inlineExportEl = document.getElementById('inlineExport'); const checkEl = document.getElementById('check'); const readDebugNamesEl = document.getElementById('readDebugNames'); const editor = new EditorView({ state: EditorState.create( {extensions: [basicSetup, StreamLanguage.define(wast)]}), parent: document.querySelector('main') }); const editorContainer = editor.dom; editorContainer.ondrop = (e) => { e.preventDefault(); let file = e.dataTransfer.files[0]; if (!file) { return; } readAndCompileFile(file); }; let fileBuffer = null; renderFeatures(wabt, features, () => { saveLocalStorageFeatures(features); compile(fileBuffer); }); function compile(contents) { if (!contents) { return; } const readDebugNames = readDebugNamesEl.checked; const check = checkEl.checked; const generateNames = generateNamesEl.checked; const foldExprs = foldExprsEl.checked; const inlineExport = inlineExportEl.checked; let module; try { module = wabt.readWasm( contents, {readDebugNames : readDebugNames, check : check, ...features}); if (generateNames) { module.generateNames(); module.applyNames(); } const result = module.toText({foldExprs: foldExprs, inlineExport: inlineExport}); editor.dispatch( {changes: {from: 0, to: editor.state.doc.length, insert: result}}); } catch (e) { editor.dispatch({ changes: {from: 0, to: editor.state.doc.length, insert: e.toString()} }); } finally { if (module) module.destroy(); } } function onUploadClicked(e) { uploadInput.value = ''; // See https://developer.mozilla.com/en-US/docs/Web/API/MouseEvent const event = new MouseEvent('click', { view: window, bubbles: true, cancelable: true, }); uploadInput.dispatchEvent(event); } function onUploadedFile(e) { const file = e.target.files[0]; readAndCompileFile(file); } // extract common util function async function readAndCompileFile(file) { fileBuffer = new Uint8Array(await file.arrayBuffer()); compile(fileBuffer); } function recompileIfChanged(el) { el.addEventListener('change', () => { compile(fileBuffer); }); } function setExample(index) { const contents = examples[index].contents; fileBuffer = contents; compile(contents); } function onSelectChanged(e) { setExample(this.selectedIndex); } uploadEl.addEventListener('click', onUploadClicked); uploadInputEl.addEventListener('change', onUploadedFile); recompileIfChanged(generateNamesEl); recompileIfChanged(foldExprsEl); recompileIfChanged(inlineExportEl); recompileIfChanged(readDebugNamesEl); selectEl.addEventListener('change', onSelectChanged); for (let i = 0; i < examples.length; ++i) { const example = examples[i]; const option = document.createElement('option'); option.textContent = example.name; selectEl.appendChild(option); } selectEl.selectedIndex = 0; setExample(selectEl.selectedIndex); ================================================ FILE: docs/demo/wasm2wat/examples.js ================================================ /* * Copyright 2017 WebAssembly Community Group participants * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ export const examples = [ { name: 'simple', contents: new Uint8Array([ 0, 97, 115, 109, 1, 0, 0, 0, 1, 7, 1, 96, 2, 127, 127, 1, 127, 3, 2, 1, 0, 7, 10, 1, 6, 97, 100, 100, 84, 119, 111, 0, 0, 10, 9, 1, 7, 0, 32, 0, 32, 1, 106, 11, 0, 25, 4, 110, 97, 109, 101, 1, 9, 1, 0, 6, 97, 100, 100, 84, 119, 111, 2, 7, 1, 0, 2, 0, 0, 1, 0 ]), }, { name: 'factorial', contents: new Uint8Array([ 0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 1, 126, 1, 126, 3, 2, 1, 0, 7, 7, 1, 3, 102, 97, 99, 0, 0, 10, 25, 1, 23, 0, 32, 0, 66, 1, 83, 4, 126, 66, 1, 5, 32, 0, 32, 0, 66, 1, 125, 16, 0, 126, 11, 11, 0, 20, 4, 110, 97, 109, 101, 1, 6, 1, 0, 3, 102, 97, 99, 2, 5, 1, 0, 1, 0, 0 ]), }, { name: 'stuff', contents: new Uint8Array([ 0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 3, 96, 1, 125, 0, 96, 1, 127, 1, 127, 96, 0, 0, 2, 11, 1, 3, 102, 111, 111, 3, 98, 97, 114, 0, 0, 3, 3, 2, 2, 0, 4, 5, 1, 112, 1, 0, 1, 5, 4, 1, 1, 1, 1, 7, 9, 1, 5, 102, 117, 110, 99, 49, 0, 1, 8, 1, 1, 10, 10, 2, 2, 0, 11, 5, 0, 65, 42, 26, 11, 11, 8, 1, 0, 65, 0, 11, 2, 104, 105, 0, 44, 4, 110, 97, 109, 101, 1, 24, 3, 0, 7, 105, 109, 112, 111, 114, 116, 48, 1, 5, 102, 117, 110, 99, 48, 2, 5, 102, 117, 110, 99, 49, 2, 11, 3, 0, 1, 0, 0, 1, 0, 2, 1, 0, 0 ]), }, ]; ================================================ FILE: docs/demo/wasm2wat/index.html ================================================ wasm2wat demo

wasm2wat demo

WebAssembly has a text format and a binary format. This demo converts from the binary format to the text format.

Upload a WebAssembly binary file, and the text format will be displayed.

Enabled features:
================================================ FILE: docs/demo/wat2wasm/demo.js ================================================ /* * Copyright 2016 WebAssembly Community Group participants * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import WabtModule from '../libwabt.js'; import {renderFeatures} from '../share.js'; import {basicSetup, EditorState, EditorView, javascript, Split, StreamLanguage, wast} from '../third_party.bundle.js'; import {examples} from './examples.js'; Split(["#top-left", "#top-right"]); Split(["#bottom-left", "#bottom-right"]); Split(["#top-row", "#bottom-row"], { direction: 'vertical' }); const features = {}; const wabt = await WabtModule({ locateFile: (url) => { if (url.endsWith('.wasm')) { return '../' + url; } return url; } }); const kCompileMinMS = 100; let outputShowBase64 = false; let outputLog; let outputBase64; const outputEl = document.getElementById('output'); const jsLogEl = document.getElementById('js_log'); const selectEl = document.getElementById('select'); const downloadEl = document.getElementById('download'); const runEl = document.getElementById('run'); const downloadLink = document.getElementById('downloadLink'); const buildLogEl = document.getElementById('buildLog'); const base64El = document.getElementById('base64'); let binaryBuffer = null; let binaryBlobUrl = null; renderFeatures(wabt, features, () => onWatChange()); const watEditor = new EditorView({ state: EditorState.create({ extensions: [ basicSetup, StreamLanguage.define(wast), EditorView.updateListener.of((update) => { if (update.docChanged) onWatChange(); }) ] }), parent: document.getElementById('top-left') }); const jsEditor = new EditorView({ state: EditorState.create({ extensions: [ basicSetup, javascript(), EditorView.updateListener.of((update) => { if (update.docChanged) onJsChange(); }) ] }), parent: document.getElementById('bottom-left') }); function debounce(f, wait) { let lastTime = 0; let timeoutId = -1; const wrapped = (...args) => { const time = +new Date(); if (time - lastTime < wait) { if (timeoutId == -1) timeoutId = setTimeout(wrapped, (lastTime + wait) - time); return; } if (timeoutId != -1) clearTimeout(timeoutId); timeoutId = -1; lastTime = time; f(...args); }; return wrapped; } function compile() { outputLog = ''; outputBase64 = 'Error occured, base64 output is not available'; let module; try { module = wabt.parseWat('test.wast', watEditor.state.doc.toString(), features); module.resolveNames(); module.validate(features); const binaryOutput = module.toBinary({log: true, write_debug_names: true}); outputLog = binaryOutput.log; binaryBuffer = binaryOutput.buffer; // binaryBuffer is a Uint8Array, so we need to convert it to a string to use // btoa // https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string outputBase64 = btoa(String.fromCharCode.apply(null, binaryBuffer)); const blob = new Blob([binaryOutput.buffer]); if (binaryBlobUrl) { URL.revokeObjectURL(binaryBlobUrl); } binaryBlobUrl = URL.createObjectURL(blob); downloadLink.setAttribute('href', binaryBlobUrl); downloadEl.classList.remove('disabled'); } catch (e) { outputLog += e.toString(); downloadEl.classList.add('disabled'); } finally { if (module) module.destroy(); outputEl.textContent = outputShowBase64 ? outputBase64 : outputLog; } } let activeWorker = null; function run() { if (activeWorker != null) stop(); runEl.textContent = 'Stop'; jsLogEl.textContent = ''; if (binaryBuffer === null) return; const js = jsEditor.state.doc.toString(); activeWorker = new Worker('./worker.js'); activeWorker.addEventListener('message', (event) => { switch (event.data.type) { case 'log': jsLogEl.textContent += event.data.data; break; case 'done': stop(); break; } }); activeWorker.postMessage({binaryBuffer: binaryBuffer.buffer, js}, []); } function stop() { if (activeWorker != null) { activeWorker.terminate(); activeWorker = null; } runEl.textContent = 'Run'; } const onWatChange = debounce(compile, kCompileMinMS); const onJsChange = debounce(run, kCompileMinMS); function setExample(index) { const example = examples[index]; watEditor.dispatch({ changes: {from: 0, to: watEditor.state.doc.length, insert: example.contents} }); jsEditor.dispatch( {changes: {from: 0, to: jsEditor.state.doc.length, insert: example.js}}); } function onSelectChanged(e) { setExample(this.selectedIndex); } function onRunClicked(e) { if (activeWorker != null) { stop(); } else { onJsChange(); } } function onDownloadClicked(e) { // See https://developer.mozilla.com/en-US/docs/Web/API/MouseEvent const event = new MouseEvent('click', { view: window, bubbles: true, cancelable: true, }); downloadLink.dispatchEvent(event); } function onBuildLogClicked(e) { outputShowBase64 = false; outputEl.textContent = outputLog; buildLogEl.style.textDecoration = 'underline'; base64El.style.textDecoration = 'none'; } function onBase64Clicked(e) { outputShowBase64 = true; outputEl.textContent = outputBase64; buildLogEl.style.textDecoration = 'none'; base64El.style.textDecoration = 'underline'; } selectEl.addEventListener('change', onSelectChanged); runEl.addEventListener('click', onRunClicked); downloadEl.addEventListener('click', onDownloadClicked); buildLogEl.addEventListener('click', onBuildLogClicked); base64El.addEventListener('click', onBase64Clicked); for (let i = 0; i < examples.length; ++i) { const example = examples[i]; const option = document.createElement('option'); option.textContent = example.name; selectEl.appendChild(option); } selectEl.selectedIndex = 1; setExample(selectEl.selectedIndex); runEl.classList.remove('disabled'); ================================================ FILE: docs/demo/wat2wasm/examples.js ================================================ /* * Copyright 2016 WebAssembly Community Group participants * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ export const examples = [ { name: 'empty', contents: '(module)', js: '', }, { name: 'simple', contents: `(module (func (export "addTwo") (param i32 i32) (result i32) local.get 0 local.get 1 i32.add)) `, js: `const wasmInstance = new WebAssembly.Instance(wasmModule, {}); const { addTwo } = wasmInstance.exports; for (let i = 0; i < 10; i++) { console.log(addTwo(i, i)); } `, }, { name: 'factorial', contents: `(module (func $fac (export "fac") (param f64) (result f64) local.get 0 f64.const 1 f64.lt if (result f64) f64.const 1 else local.get 0 local.get 0 f64.const 1 f64.sub call $fac f64.mul end)) `, js: `const wasmInstance = new WebAssembly.Instance(wasmModule, {}); const { fac } = wasmInstance.exports; for (let i = 1; i <= 15; i++) { console.log(fac(i)); } `, }, { name: 'stuff', contents: `(module (import "foo" "bar" (func (param f32))) (memory (data "hi")) (type (func (param i32) (result i32))) (start 1) (table 0 1 funcref) (func) (func (type 1) i32.const 42 drop) (export "e" (func 1))) `, js: `const wasmInstance = new WebAssembly.Instance(wasmModule, { foo: { bar() {} }, }); `, }, { name: 'mutable globals', contents: `(module (import "env" "g" (global (mut i32))) (func (export "f") i32.const 100 global.set 0)) `, js: ` const g = new WebAssembly.Global({value: 'i32', mutable: true}); const wasmInstance = new WebAssembly.Instance(wasmModule, {env: {g}}); console.log('before: ' + g.value); wasmInstance.exports.f(); console.log('after: ' + g.value); ` }, { name: 'saturating float-to-int', contents: `(module (func (export "f") (param f32) (result i32) local.get 0 i32.trunc_sat_f32_s))`, js: `const wasmInstance = new WebAssembly.Instance(wasmModule); const {f} = wasmInstance.exports; console.log(f(Infinity));` }, { name: 'sign extension', contents: `(module (func (export "f") (param i32) (result i32) local.get 0 i32.extend8_s)) `, js: `const wasmInstance = new WebAssembly.Instance(wasmModule); const {f} = wasmInstance.exports; console.log(f(0)); console.log(f(127)); console.log(f(128)); console.log(f(255));` }, { name: 'multi value', contents: `(module (func $swap (param i32 i32) (result i32 i32) local.get 1 local.get 0) (func (export "reverseSub") (param i32 i32) (result i32) local.get 0 local.get 1 call $swap i32.sub)) `, js: `const wasmInstance = new WebAssembly.Instance(wasmModule); const {reverseSub} = wasmInstance.exports; console.log(reverseSub(10, 3));` }, { name: 'bulk memory', contents: `(module (memory (export "mem") 1) (func (export "fill") (param i32 i32 i32) local.get 0 local.get 1 local.get 2 memory.fill)) `, js: `const wasmInstance = new WebAssembly.Instance(wasmModule); const {fill, mem} = wasmInstance.exports; fill(0, 13, 5); fill(10, 77, 7); fill(20, 255, 1000); console.log(new Uint8Array(mem.buffer, 0, 50)); ` } ]; ================================================ FILE: docs/demo/wat2wasm/index.html ================================================ wat2wasm demo

wat2wasm demo

WebAssembly has a text format and a binary format. This demo converts from the text format to the binary format.

Enter WebAssembly text in the textarea on the left. The right side will either show an error, or will show a log with a description of the generated binary file.

Enabled features:
WAT

          
JS

          
JS LOG
================================================ FILE: docs/demo/wat2wasm/worker.js ================================================ // This worker runs the generated WebAssembly module and sends console.log // output back to the main thread in order to prevent infinite loops from // locking up the main thread. let wrappedConsole = Object.create(console); wrappedConsole.log = (...args) => { const line = args.map(String).join('') + '\n'; postMessage({type: 'log', data: line}); console.log(...args); }; self.onmessage = async (event) => { console.log("Running WebAssembly"); const { binaryBuffer, js } = event.data; let wasm; try { wasm = new WebAssembly.Module(binaryBuffer); } catch (e) { postMessage({type: 'log', data: String(e)}); } const fn = new Function('wasmModule', 'console', js + '//# sourceURL=demo.js'); fn(wasm, wrappedConsole); postMessage({type: 'done'}); }; ================================================ FILE: docs/doc/spectest-interp.1.html ================================================ WABT(1)
WABT(1) General Commands Manual WABT(1)

spectest-interpread a Spectest JSON file, and run its tests in the interpreter

spectest-interp [options] file

spectest-interp Reads a Spectest JSON file, and runs its tests in the interpreter.

The options are as follows:

Print a help message
Print version information
, --verbose
Use multiple times for more info
Enable Experimental exception handling
Disable Import/export mutable globals
Disable Saturating float-to-int operators
Disable Sign-extension operators
Disable SIMD support
Enable Threading support
Enable Typed function references
Disable Multi-value
Enable Tail-call support
Disable Bulk-memory operations
Disable Reference types (externref)
Enable Custom annotation syntax
Enable Code metadata
Enable Garbage collection
Enable 64-bit memory
Enable Multi-memory
Enable Extended constant expressions
Enable all features
, --value-stack-size=SIZE
Size in elements of the value stack
, --call-stack-size=SIZE
Size in elements of the call stack
, --trace
Trace execution

Parse test.json and run the spec tests

$ spectest-interp test.json

wasm-decompile(1), wasm-interp(1), wasm-objdump(1), wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), wasm2wat(1), wast2json(1), wat-desugar(1), wat2wasm(1)

If you find a bug, please report it at
https://github.com/WebAssembly/wabt/issues.

September 23, 2025 Debian
================================================ FILE: docs/doc/wasm-decompile.1.html ================================================ WABT(1)
WABT(1) General Commands Manual WABT(1)

wasm-decompiletranslate from the binary format to readable C-like syntax

wasm-decompile [options] file

wasm-decompile Read a file in the WebAssembly binary format, and convert it to a decompiled text file.

The options are as follows:

Print a help message
Print version information
, --output=FILENAME
Output file for the decompiled file, by default use stdout
Enable Experimental exception handling
Disable Import/export mutable globals
Disable Saturating float-to-int operators
Disable Sign-extension operators
Disable SIMD support
Enable Threading support
Enable Typed function references
Disable Multi-value
Enable Tail-call support
Disable Bulk-memory operations
Disable Reference types (externref)
Enable Custom annotation syntax
Enable Code metadata
Enable Garbage collection
Enable 64-bit memory
Enable Multi-memory
Enable Extended constant expressions
Enable all features
Ignore errors in custom sections

Parse binary file test.wasm and write text file test.dcmp

$ wasm-decompile test.wasm -o test.dcmp

wasm-interp(1), wasm-objdump(1), wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), wasm2wat(1), wast2json(1), wat-desugar(1), wat2wasm(1), spectest-interp(1)

If you find a bug, please report it at
https://github.com/WebAssembly/wabt/issues.

September 23, 2025 Debian
================================================ FILE: docs/doc/wasm-interp.1.html ================================================ WABT(1)
WABT(1) General Commands Manual WABT(1)

wasm-interpdecode and run a WebAssembly binary file

wasm-interp [options] file

wasm-interp Read a file in the wasm binary format, and run it in a stack-based interpreter.

The options are as follows:

Print a help message
Print version information
, --verbose
Use multiple times for more info
Enable Experimental exception handling
Disable Import/export mutable globals
Disable Saturating float-to-int operators
Disable Sign-extension operators
Disable SIMD support
Enable Threading support
Enable Typed function references
Disable Multi-value
Enable Tail-call support
Disable Bulk-memory operations
Disable Reference types (externref)
Enable Custom annotation syntax
Enable Code metadata
Enable Garbage collection
Enable 64-bit memory
Enable Multi-memory
Enable Extended constant expressions
Enable all features
, --value-stack-size=SIZE
Size in elements of the value stack
, --call-stack-size=SIZE
Size in elements of the call stack
, --trace
Trace execution
Assume input module is WASI compliant (Export WASI API the the module and invoke _start function)
, --env=ENV
Pass the given environment string in the WASI runtime
, --dir=DIR
Pass the given directory the the WASI runtime
Run all the exported functions, in order. Useful for testing
Include an importable function named "host.print" for printing to stdout
Provide a dummy implementation of all imported functions. The function will log the call and return an appropriate zero value.

Parse binary file test.wasm, and type-check it

$ wasm-interp test.wasm

Parse test.wasm and run all its exported functions

$ wasm-interp test.wasm --run-all-exports

Parse test.wasm, run the exported functions and trace the output

$ wasm-interp test.wasm --run-all-exports --trace

Parse test.wasm and run all its exported functions, setting the value stack size to 100 elements

$ wasm-interp test.wasm -V 100 --run-all-exports

wasm-decompile(1), wasm-objdump(1), wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), wasm2wat(1), wast2json(1), wat-desugar(1), wat2wasm(1), spectest-interp(1)

If you find a bug, please report it at
https://github.com/WebAssembly/wabt/issues.

September 23, 2025 Debian
================================================ FILE: docs/doc/wasm-objdump.1.html ================================================ WABT(1)
WABT(1) General Commands Manual WABT(1)

wasm-objdumpprint information about a wasm binary

wasm-objdump [options] file ...

wasm-objdump Print information about the contents of wasm binaries.

The options are as follows:

Print a help message
Print version information
, --headers
Print headers
, --section=SECTION
Select just one section
, --full-contents
Print raw section contents
, --disassemble
Disassemble function bodies
Print extra debug information
, --details
Show section details
, --reloc
Show relocations inline with disassembly
Print section offsets instead of file offsets in code disassembly

$ wasm-objdump test.wasm

wasm-decompile(1), wasm-interp(1), wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), wasm2wat(1), wast2json(1), wat-desugar(1), wat2wasm(1), spectest-interp(1)

If you find a bug, please report it at
https://github.com/WebAssembly/wabt/issues.

September 23, 2025 Debian
================================================ FILE: docs/doc/wasm-stats.1.html ================================================ WABT(1)
WABT(1) General Commands Manual WABT(1)

wasm-statsshow stats for a module

wasm-stats [options] file ...

wasm-stats Read a file in the wasm binary format, and show stats.

The options are as follows:

Print a help message
Print version information
, --verbose
Use multiple times for more info
Enable Experimental exception handling
Disable Import/export mutable globals
Disable Saturating float-to-int operators
Disable Sign-extension operators
Disable SIMD support
Enable Threading support
Enable Typed function references
Disable Multi-value
Enable Tail-call support
Disable Bulk-memory operations
Disable Reference types (externref)
Enable Custom annotation syntax
Enable Code metadata
Enable Garbage collection
Enable 64-bit memory
Enable Multi-memory
Enable Extended constant expressions
Enable all features
, --output=FILENAME
Output file for the opcode counts, by default use stdout
, --cutoff=N
Cutoff for reporting counts less than N
, --separator=SEPARATOR
Separator text between element and count when reporting counts

Parse binary file test.wasm and write opcode dist file test.dist

$ wasm-stats test.wasm -o test.dist

wasm-decompile(1), wasm-interp(1), wasm-objdump(1), wasm-strip(1), wasm-validate(1), wasm2c(1), wasm2wat(1), wast2json(1), wat-desugar(1), wat2wasm(1), spectest-interp(1)

If you find a bug, please report it at
https://github.com/WebAssembly/wabt/issues.

September 23, 2025 Debian
================================================ FILE: docs/doc/wasm-strip.1.html ================================================ WABT(1)
WABT(1) General Commands Manual WABT(1)

wasm-stripremove sections of a WebAssembly binary file

wasm-strip [options] file

wasm-strip Remove sections of a WebAssembly binary file.

The options are as follows:

Print a help message
Print version information
, --output=FILE
output wasm binary file

Remove all custom sections from test.wasm

$ wasm-strip test.wasm

wasm-decompile(1), wasm-interp(1), wasm-objdump(1), wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), wasm2wat(1), wast2json(1), wat-desugar(1), wat2wasm(1), spectest-interp(1)

If you find a bug, please report it at
https://github.com/WebAssembly/wabt/issues.

September 23, 2025 Debian
================================================ FILE: docs/doc/wasm-validate.1.html ================================================ WABT(1)
WABT(1) General Commands Manual WABT(1)

wasm-validatevalidate a file in the WebAssembly binary format

wasm-validate [options] file

wasm-validate Read a file in the WebAssembly binary format, and validate it.

The options are as follows:

Print this help message
Print version information
, --verbose
Use multiple times for more info
Enable Experimental exception handling
Disable Import/export mutable globals
Disable Saturating float-to-int operators
Disable Sign-extension operators
Disable SIMD support
Enable Threading support
Enable Typed function references
Disable Multi-value
Enable Tail-call support
Disable Bulk-memory operations
Disable Reference types (externref)
Enable Custom annotation syntax
Enable Code metadata
Enable Garbage collection
Enable 64-bit memory
Enable Multi-memory
Enable Extended constant expressions
Enable all features
Ignore debug names in the binary file
Ignore errors in custom sections

Validate binary file test.wasm

$ wasm-validate test.wasm

wasm-decompile(1), wasm-interp(1), wasm-objdump(1), wasm-stats(1), wasm-strip(1), wasm2c(1), wasm2wat(1), wast2json(1), wat-desugar(1), wat2wasm(1), spectest-interp(1)

If you find a bug, please report it at
https://github.com/WebAssembly/wabt/issues.

September 23, 2025 Debian
================================================ FILE: docs/doc/wasm2c.1.html ================================================ WABT(1)
WABT(1) General Commands Manual WABT(1)

wasm2cconvert a WebAssembly binary file to a C source and header

wasm2c [options] file

wasm2c takes a WebAssembly module and produces an equivalent C source and header.

The options are as follows:

Print a help message
Print version information
, --verbose
Use multiple times for more info
, --output=FILENAME
Output file for the generated C source file, by default use stdout
, --module-name=MODNAME
Unique name for the module being generated. This name is prefixed to each of the generaed C symbols. By default, the module name from the names section is used. If that is not present the name of the input file is used as the default.
Enable Experimental exception handling
Disable Import/export mutable globals
Disable Saturating float-to-int operators
Disable Sign-extension operators
Disable SIMD support
Enable Threading support
Enable Typed function references
Disable Multi-value
Enable Tail-call support
Disable Bulk-memory operations
Disable Reference types (externref)
Enable Custom annotation syntax
Enable Code metadata
Enable Garbage collection
Enable 64-bit memory
Enable Multi-memory
Enable Extended constant expressions
Enable all features
Ignore debug names in the binary file

Parse binary file test.wasm and write test.c and test.h

$ wasm2c test.wasm -o test.c

Parse test.wasm, write test.c and test.h, but ignore the debug names, if any

$ wasm2c test.wasm --no-debug-names -o test.c

wasm-decompile(1), wasm-interp(1), wasm-objdump(1), wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2wat(1), wast2json(1), wat-desugar(1), wat2wasm(1), spectest-interp(1)

If you find a bug, please report it at
https://github.com/WebAssembly/wabt/issues.

September 23, 2025 Debian
================================================ FILE: docs/doc/wasm2wat.1.html ================================================ WABT(1)
WABT(1) General Commands Manual WABT(1)

wasm2wattranslate from the binary format to the text format

wasm2wat [options] file

wasm2wat Read a file in the WebAssembly binary format, and convert it to the WebAssembly text format.

The options are as follows:

Print a help message
Print version information
, --verbose
Use multiple times for more info
, --output=FILENAME
Output file for the generated wast file, by default use stdout
, --fold-exprs
Write folded expressions where possible
Enable Experimental exception handling
Disable Import/export mutable globals
Disable Saturating float-to-int operators
Disable Sign-extension operators
Disable SIMD support
Enable Threading support
Enable Typed function references
Disable Multi-value
Enable Tail-call support
Disable Bulk-memory operations
Disable Reference types (externref)
Enable Custom annotation syntax
Enable Code metadata
Enable Garbage collection
Enable 64-bit memory
Enable Multi-memory
Enable Extended constant expressions
Enable all features
Write all exports inline
Write all imports inline
Ignore debug names in the binary file
Ignore errors in custom sections
Give auto-generated names to non-named functions, types, etc.
Don't check for invalid modules

Parse binary file test.wasm and write text file test.wast

$ wasm2wat test.wasm -o test.wat

Parse test.wasm, write test.wat, but ignore the debug names, if any

$ wasm2wat test.wasm --no-debug-names -o test.wat

wasm-decompile(1), wasm-interp(1), wasm-objdump(1), wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), wast2json(1), wat-desugar(1), wat2wasm(1), spectest-interp(1)

If you find a bug, please report it at
https://github.com/WebAssembly/wabt/issues.

September 23, 2025 Debian
================================================ FILE: docs/doc/wast2json.1.html ================================================ WABT(1)
WABT(1) General Commands Manual WABT(1)

wast2jsonconvert a file in the wasm spec test format to a JSON file and associated wasm binary files

wast2json [options] file

wast2json Read a file in the wasm spec test format, check it for errors, and convert it to a JSON file and associated wasm binary files.

The options are as follows:

Print this help message
Print version information
, --verbose
Use multiple times for more info
Turn on debugging the parser of wast files
Enable Experimental exception handling
Disable Import/export mutable globals
Disable Saturating float-to-int operators
Disable Sign-extension operators
Disable SIMD support
Enable Threading support
Enable Typed function references
Disable Multi-value
Enable Tail-call support
Disable Bulk-memory operations
Disable Reference types (externref)
Enable Custom annotation syntax
Enable Code metadata
Enable Garbage collection
Enable 64-bit memory
Enable Multi-memory
Enable Extended constant expressions
Enable all features
, --output=FILE
output JSON file
, --relocatable
Create a relocatable wasm binary (suitable for linking with e.g. lld)
Write all LEB128 sizes as 5-bytes instead of their minimal size
Write debug names to the generated binary file
Don't check for invalid modules

Parse spec-test.wast, and write files to spec-test.json. Modules are written to spec-test.0.wasm, spec-test.1.wasm, etc.

$ wast2json spec-test.wast -o spec-test.json

wasm-decompile(1), wasm-interp(1), wasm-objdump(1), wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), wasm2wat(1), wat-desugar(1), wat2wasm(1), spectest-interp(1)

If you find a bug, please report it at
https://github.com/WebAssembly/wabt/issues.

September 23, 2025 Debian
================================================ FILE: docs/doc/wat-desugar.1.html ================================================ WABT(1)
WABT(1) General Commands Manual WABT(1)

wat-desugarparse .wat text form and print canonical flat format

wat-desugar [options] file

wat-desugar Parses .wat text form as supported by the spec interpreter (s-expressions, flat syntax, or mixed) and prints "canonical" flat format.

The options are as follows:

Print this help message
Print version information
, --output=FILE
Output file for the formatted file
Turn on debugging the parser of wat files
, --fold-exprs
Write folded expressions where possible
Write all exports inline
Write all imports inline
Enable Experimental exception handling
Disable Import/export mutable globals
Disable Saturating float-to-int operators
Disable Sign-extension operators
Disable SIMD support
Enable Threading support
Enable Typed function references
Disable Multi-value
Enable Tail-call support
Disable Bulk-memory operations
Disable Reference types (externref)
Enable Custom annotation syntax
Enable Code metadata
Enable Garbage collection
Enable 64-bit memory
Enable Multi-memory
Enable Extended constant expressions
Enable all features
Give auto-generated names to non-named functions, types, etc.

Write output to stdout

$ wat-desugar test.wat

Write output to test2.wat

$ wat-desugar test.wat -o test2.wat

Generate names for indexed variables

$ wat-desugar --generate-names test.wat

wasm-decompile(1), wasm-interp(1), wasm-objdump(1), wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), wasm2wat(1), wast2json(1), wat2wasm(1), spectest-interp(1)

If you find a bug, please report it at
https://github.com/WebAssembly/wabt/issues.

September 23, 2025 Debian
================================================ FILE: docs/doc/wat2wasm.1.html ================================================ WABT(1)
WABT(1) General Commands Manual WABT(1)

wat2wasmtranslate from WebAssembly text format to the WebAssembly binary format

wat2wasm [options] file

wat2wasm Read a file in the wasm text format, check it for errors, and convert it to the wasm binary format.

The options are as follows:

Print this help message
Print version information
, --verbose
Use multiple times for more info
Turn on debugging the parser of wat files
, --dump-module
Print a hexdump of the module to stdout
Enable Experimental exception handling
Disable Import/export mutable globals
Disable Saturating float-to-int operators
Disable Sign-extension operators
Disable SIMD support
Enable Threading support
Enable Typed function references
Disable Multi-value
Enable Tail-call support
Disable Bulk-memory operations
Disable Reference types (externref)
Enable Custom annotation syntax
Enable Code metadata
Enable Garbage collection
Enable 64-bit memory
Enable Multi-memory
Enable Extended constant expressions
Enable all features
, --output=FILE
Output wasm binary file. Use "-" to write to stdout.
, --relocatable
Create a relocatable wasm binary (suitable for linking with e.g. lld)
Write all LEB128 sizes as 5-bytes instead of their minimal size
Write debug names to the generated binary file
Don't check for invalid modules

Parse test.wat and write to .wasm binary file with the same name

$ wat2wasm test.wat

Parse test.wat and write to binary file test.wasm

$ wat2wasm test.wat -o test.wasm

Parse spec-test.wast, and write verbose output to stdout (including the meaning of every byte)

$ wat2wasm spec-test.wast -v

wasm-decompile(1), wasm-interp(1), wasm-objdump(1), wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), wasm2wat(1), wast2json(1), wat-desugar(1), spectest-interp(1)

If you find a bug, please report it at
https://github.com/WebAssembly/wabt/issues.

September 23, 2025 Debian
================================================ FILE: docs/wast2json.md ================================================ # wast2json `wast2json` converts a `.wast` file to a `.json` file, and a collection of associated `.wat` file and `.wasm` files. ## Example ```sh # parse spec-test.wast, and write files to spec-test.json. Modules are written # to spec-test.0.wasm, spec-test.1.wasm, etc. $ bin/wast2json spec-test.wast -o spec-test.json ``` ## Wast The wast format is described in the [spec interpreter](https://github.com/WebAssembly/spec/tree/master/interpreter#scripts). It is an extension of the `.wat` text format, with additional commands for running scripts. The syntax is repeated here: ``` script: * cmd: ;; define, validate, and initialize module ( register ? ) ;; register module for imports module with given failure string ;; perform action and print results ;; assert result of an action ;; meta command module: ... ( module ? binary * ) ;; module in binary format (may be malformed) ( module ? quote * ) ;; module quoted in text (may be malformed) action: ( invoke ? * ) ;; invoke function export ( get ? ) ;; get global export assertion: ( assert_return * ) ;; assert action has expected results ( assert_trap ) ;; assert action traps with given failure string ( assert_exhaustion ) ;; assert action exhausts system resources ( assert_malformed ) ;; assert module cannot be decoded with given failure string ( assert_invalid ) ;; assert module is invalid with given failure string ( assert_unlinkable ) ;; assert module fails to link ( assert_trap ) ;; assert module traps on instantiation result: ( .const ) numpat: ;; literal result nan:canonical ;; NaN in canonical form nan:arithmetic ;; NaN with 1 in MSB of payload meta: ( script ?