hyper-html-api 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/conformance/MANIFEST.json +2 -2
- package/conformance/cases/all-matches-read-quoted.expected.json +3 -0
- package/conformance/cases/all-matches-read-quoted.html +5 -0
- package/conformance/cases/all-matches-read-quoted.meta +7 -0
- package/conformance/cases/all-matches-read-quoted.parsed.json +3 -0
- package/conformance/cases/all-matches-read.expected.json +3 -0
- package/conformance/cases/all-matches-read.html +6 -0
- package/conformance/cases/all-matches-read.meta +7 -0
- package/conformance/cases/all-matches-read.parsed.json +3 -0
- package/conformance/cases/codec-form-nested.error.json +5 -0
- package/conformance/cases/codec-form-nested.html +4 -0
- package/conformance/cases/codec-form-nested.meta +6 -0
- package/conformance/cases/codec-form-nested.parsed.json +5 -0
- package/conformance/cases/codec-form-star.error.json +5 -0
- package/conformance/cases/codec-form-star.html +4 -0
- package/conformance/cases/codec-form-star.meta +6 -0
- package/conformance/cases/codec-form-star.parsed.json +3 -0
- package/conformance/cases/codec-form-under-v1.error.json +5 -0
- package/conformance/cases/codec-form-under-v1.html +4 -0
- package/conformance/cases/codec-form-under-v1.meta +6 -0
- package/conformance/cases/codec-form-under-v1.parsed.json +3 -0
- package/conformance/cases/codec-unknown-name.error.json +5 -0
- package/conformance/cases/codec-unknown-name.html +4 -0
- package/conformance/cases/codec-unknown-name.meta +6 -0
- package/conformance/cases/codec-unknown-name.parsed.json +3 -0
- package/conformance/cases/tag-version-2-plain.expected.json +7 -0
- package/conformance/cases/tag-version-2-plain.html +5 -0
- package/conformance/cases/tag-version-2-plain.meta +6 -0
- package/conformance/cases/tag-version-2-plain.parsed.json +4 -0
- package/conformance/cases/tag-wrong-version.error.json +1 -1
- package/conformance/cases/tag-wrong-version.html +1 -1
- package/conformance/cases/write-all-matches-attr.after.html +1 -0
- package/conformance/cases/write-all-matches-attr.after.json +3 -0
- package/conformance/cases/write-all-matches-attr.data.json +1 -0
- package/conformance/cases/write-all-matches-attr.html +1 -0
- package/conformance/cases/write-all-matches-attr.meta +6 -0
- package/conformance/cases/write-all-matches-attr.write.json +4 -0
- package/conformance/cases/write-all-matches-group.after.html +1 -0
- package/conformance/cases/write-all-matches-group.after.json +3 -0
- package/conformance/cases/write-all-matches-group.data.json +1 -0
- package/conformance/cases/write-all-matches-group.html +1 -0
- package/conformance/cases/write-all-matches-group.meta +6 -0
- package/conformance/cases/write-all-matches-group.write.json +4 -0
- package/conformance/cases/write-all-matches-text.after.html +1 -0
- package/conformance/cases/write-all-matches-text.after.json +3 -0
- package/conformance/cases/write-all-matches-text.data.json +1 -0
- package/conformance/cases/write-all-matches-text.html +1 -0
- package/conformance/cases/write-all-matches-text.meta +6 -0
- package/conformance/cases/write-all-matches-text.write.json +4 -0
- package/conformance/cases/write-all-matches-unmatched.data.json +1 -0
- package/conformance/cases/write-all-matches-unmatched.error.json +14 -0
- package/conformance/cases/write-all-matches-unmatched.html +1 -0
- package/conformance/cases/write-all-matches-unmatched.meta +6 -0
- package/conformance/sheet/body-data-write.body.json +3 -0
- package/conformance/sheet/body-data-write.data.json +3 -0
- package/conformance/sheet/body-data-write.html +25 -0
- package/conformance/sheet/body-data-write.meta +5 -0
- package/conformance/sheet/body-patch-key-in-rules.body.json +3 -0
- package/conformance/sheet/body-patch-key-in-rules.data.json +13 -0
- package/conformance/sheet/body-patch-key-in-rules.html +18 -0
- package/conformance/sheet/body-patch-key-in-rules.meta +5 -0
- package/conformance/sheet/body-patch-not-array.body.json +3 -0
- package/conformance/sheet/body-patch-not-array.data.json +3 -0
- package/conformance/sheet/body-patch-not-array.html +25 -0
- package/conformance/sheet/body-patch-not-array.meta +5 -0
- package/conformance/sheet/body-patch-on-sheet.body.json +3 -0
- package/conformance/sheet/body-patch-on-sheet.data.json +14 -0
- package/conformance/sheet/body-patch-on-sheet.html +25 -0
- package/conformance/sheet/body-patch-on-sheet.meta +5 -0
- package/conformance/sheet/body-patch-version-1.body.json +3 -0
- package/conformance/sheet/body-patch-version-1.data.json +13 -0
- package/conformance/sheet/body-patch-version-1.html +4 -0
- package/conformance/sheet/body-patch-version-1.meta +5 -0
- package/conformance/sheet/body-patch-with-other-key.body.json +3 -0
- package/conformance/sheet/body-patch-with-other-key.data.json +14 -0
- package/conformance/sheet/body-patch-with-other-key.html +25 -0
- package/conformance/sheet/body-patch-with-other-key.meta +5 -0
- package/conformance/sheet/body-patch-without-operation-id.body.json +3 -0
- package/conformance/sheet/body-patch-without-operation-id.data.json +13 -0
- package/conformance/sheet/body-patch-without-operation-id.html +25 -0
- package/conformance/sheet/body-patch-without-operation-id.meta +5 -0
- package/conformance/sheet/params-bad-range.error.json +6 -0
- package/conformance/sheet/params-bad-range.html +25 -0
- package/conformance/sheet/params-bad-range.meta +6 -0
- package/conformance/sheet/params-bad-render.error.json +6 -0
- package/conformance/sheet/params-bad-render.html +25 -0
- package/conformance/sheet/params-bad-render.meta +6 -0
- package/conformance/sheet/params-bad-shape.error.json +6 -0
- package/conformance/sheet/params-bad-shape.html +25 -0
- package/conformance/sheet/params-bad-shape.meta +6 -0
- package/conformance/sheet/params-cache-buster.expected.json +128 -0
- package/conformance/sheet/params-cache-buster.html +25 -0
- package/conformance/sheet/params-cache-buster.meta +6 -0
- package/conformance/sheet/params-data-alone.expected.json +128 -0
- package/conformance/sheet/params-data-alone.html +25 -0
- package/conformance/sheet/params-data-alone.meta +6 -0
- package/conformance/sheet/params-empty.error.json +6 -0
- package/conformance/sheet/params-empty.html +25 -0
- package/conformance/sheet/params-empty.meta +6 -0
- package/conformance/sheet/params-index.expected.json +19 -0
- package/conformance/sheet/params-index.html +25 -0
- package/conformance/sheet/params-index.meta +6 -0
- package/conformance/sheet/params-none.expected.json +128 -0
- package/conformance/sheet/params-none.html +25 -0
- package/conformance/sheet/params-none.meta +6 -0
- package/conformance/sheet/params-range.expected.json +17 -0
- package/conformance/sheet/params-range.html +25 -0
- package/conformance/sheet/params-range.meta +6 -0
- package/conformance/sheet/params-render-without-range.error.json +6 -0
- package/conformance/sheet/params-render-without-range.html +25 -0
- package/conformance/sheet/params-render-without-range.meta +6 -0
- package/conformance/sheet/params-repeated.error.json +6 -0
- package/conformance/sheet/params-repeated.html +25 -0
- package/conformance/sheet/params-repeated.meta +6 -0
- package/conformance/sheet/params-unknown-sheet.error.json +6 -0
- package/conformance/sheet/params-unknown-sheet.html +25 -0
- package/conformance/sheet/params-unknown-sheet.meta +6 -0
- package/conformance/sheet/params-with-data.error.json +6 -0
- package/conformance/sheet/params-with-data.html +25 -0
- package/conformance/sheet/params-with-data.meta +6 -0
- package/conformance/sheet/sheet-contract-cells.expected.json +57 -0
- package/conformance/sheet/sheet-contract-cells.html +10 -0
- package/conformance/sheet/sheet-contract-cells.meta +6 -0
- package/conformance/sheet/sheet-contract-formulas.expected.json +29 -0
- package/conformance/sheet/sheet-contract-formulas.html +10 -0
- package/conformance/sheet/sheet-contract-formulas.meta +6 -0
- package/conformance/sheet/sheet-contract-values.expected.json +29 -0
- package/conformance/sheet/sheet-contract-values.html +10 -0
- package/conformance/sheet/sheet-contract-values.meta +6 -0
- package/conformance/sheet/sheet-contract-whole.expected.json +59 -0
- package/conformance/sheet/sheet-contract-whole.html +10 -0
- package/conformance/sheet/sheet-contract-whole.meta +5 -0
- package/conformance/sheet/sheet-hostile-01.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-01.html +6 -0
- package/conformance/sheet/sheet-hostile-01.meta +5 -0
- package/conformance/sheet/sheet-hostile-02.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-02.html +6 -0
- package/conformance/sheet/sheet-hostile-02.meta +5 -0
- package/conformance/sheet/sheet-hostile-03.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-03.html +6 -0
- package/conformance/sheet/sheet-hostile-03.meta +5 -0
- package/conformance/sheet/sheet-hostile-04.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-04.html +6 -0
- package/conformance/sheet/sheet-hostile-04.meta +5 -0
- package/conformance/sheet/sheet-hostile-05.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-05.html +6 -0
- package/conformance/sheet/sheet-hostile-05.meta +5 -0
- package/conformance/sheet/sheet-hostile-06.expected.json +21 -0
- package/conformance/sheet/sheet-hostile-06.html +6 -0
- package/conformance/sheet/sheet-hostile-06.meta +5 -0
- package/conformance/sheet/sheet-hostile-07.expected.json +21 -0
- package/conformance/sheet/sheet-hostile-07.html +6 -0
- package/conformance/sheet/sheet-hostile-07.meta +5 -0
- package/conformance/sheet/sheet-hostile-08.expected.json +21 -0
- package/conformance/sheet/sheet-hostile-08.html +6 -0
- package/conformance/sheet/sheet-hostile-08.meta +5 -0
- package/conformance/sheet/sheet-hostile-09.expected.json +21 -0
- package/conformance/sheet/sheet-hostile-09.html +6 -0
- package/conformance/sheet/sheet-hostile-09.meta +5 -0
- package/conformance/sheet/sheet-hostile-10.expected.json +21 -0
- package/conformance/sheet/sheet-hostile-10.html +6 -0
- package/conformance/sheet/sheet-hostile-10.meta +5 -0
- package/conformance/sheet/sheet-hostile-11.expected.json +22 -0
- package/conformance/sheet/sheet-hostile-11.html +6 -0
- package/conformance/sheet/sheet-hostile-11.meta +5 -0
- package/conformance/sheet/sheet-hostile-12.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-12.html +6 -0
- package/conformance/sheet/sheet-hostile-12.meta +5 -0
- package/conformance/sheet/sheet-hostile-13.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-13.html +6 -0
- package/conformance/sheet/sheet-hostile-13.meta +5 -0
- package/conformance/sheet/sheet-hostile-14.expected.json +21 -0
- package/conformance/sheet/sheet-hostile-14.html +6 -0
- package/conformance/sheet/sheet-hostile-14.meta +5 -0
- package/conformance/sheet/sheet-hostile-15.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-15.html +0 -0
- package/conformance/sheet/sheet-hostile-15.meta +5 -0
- package/conformance/sheet/sheet-hostile-16.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-16.html +6 -0
- package/conformance/sheet/sheet-hostile-16.meta +5 -0
- package/conformance/sheet/sheet-hostile-17.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-17.html +6 -0
- package/conformance/sheet/sheet-hostile-17.meta +5 -0
- package/conformance/sheet/sheet-hostile-18.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-18.html +6 -0
- package/conformance/sheet/sheet-hostile-18.meta +5 -0
- package/conformance/sheet/sheet-hostile-19.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-19.html +6 -0
- package/conformance/sheet/sheet-hostile-19.meta +5 -0
- package/conformance/sheet/sheet-hostile-20.expected.json +16 -0
- package/conformance/sheet/sheet-hostile-20.html +6 -0
- package/conformance/sheet/sheet-hostile-20.meta +5 -0
- package/conformance/sheet/sheet-hostile-21.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-21.html +6 -0
- package/conformance/sheet/sheet-hostile-21.meta +5 -0
- package/conformance/sheet/sheet-hostile-22.expected.json +21 -0
- package/conformance/sheet/sheet-hostile-22.html +6 -0
- package/conformance/sheet/sheet-hostile-22.meta +5 -0
- package/conformance/sheet/sheet-hostile-23.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-23.html +6 -0
- package/conformance/sheet/sheet-hostile-23.meta +5 -0
- package/conformance/sheet/sheet-hostile-24.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-24.html +6 -0
- package/conformance/sheet/sheet-hostile-24.meta +5 -0
- package/conformance/sheet/sheet-hostile-25.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-25.html +6 -0
- package/conformance/sheet/sheet-hostile-25.meta +5 -0
- package/conformance/sheet/sheet-hostile-26.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-26.html +6 -0
- package/conformance/sheet/sheet-hostile-26.meta +5 -0
- package/conformance/sheet/sheet-hostile-27.expected.json +24 -0
- package/conformance/sheet/sheet-hostile-27.html +7 -0
- package/conformance/sheet/sheet-hostile-27.meta +5 -0
- package/conformance/sheet/sheet-hostile-28.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-28.html +6 -0
- package/conformance/sheet/sheet-hostile-28.meta +5 -0
- package/conformance/sheet/sheet-hostile-29.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-29.html +6 -0
- package/conformance/sheet/sheet-hostile-29.meta +5 -0
- package/conformance/sheet/sheet-hostile-30.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-30.html +6 -0
- package/conformance/sheet/sheet-hostile-30.meta +5 -0
- package/conformance/sheet/sheet-hostile-31.expected.json +19 -0
- package/conformance/sheet/sheet-hostile-31.html +6 -0
- package/conformance/sheet/sheet-hostile-31.meta +5 -0
- package/conformance/sheet/sheet-hostile-32.expected.json +24 -0
- package/conformance/sheet/sheet-hostile-32.html +6 -0
- package/conformance/sheet/sheet-hostile-32.meta +5 -0
- package/conformance/sheet/sheet-hostile-33.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-33.html +6 -0
- package/conformance/sheet/sheet-hostile-33.meta +5 -0
- package/conformance/sheet/sheet-hostile-34.expected.json +24 -0
- package/conformance/sheet/sheet-hostile-34.html +8 -0
- package/conformance/sheet/sheet-hostile-34.meta +5 -0
- package/conformance/sheet/sheet-hostile-35.expected.json +24 -0
- package/conformance/sheet/sheet-hostile-35.html +8 -0
- package/conformance/sheet/sheet-hostile-35.meta +5 -0
- package/conformance/sheet/sheet-patch-append.after.html +27 -0
- package/conformance/sheet/sheet-patch-append.after.json +143 -0
- package/conformance/sheet/sheet-patch-append.data.json +15 -0
- package/conformance/sheet/sheet-patch-append.html +25 -0
- package/conformance/sheet/sheet-patch-append.meta +5 -0
- package/conformance/sheet/sheet-patch-append.write.json +7 -0
- package/conformance/sheet/sheet-patch-bad-range.data.json +11 -0
- package/conformance/sheet/sheet-patch-bad-range.error.json +6 -0
- package/conformance/sheet/sheet-patch-bad-range.html +25 -0
- package/conformance/sheet/sheet-patch-bad-range.meta +5 -0
- package/conformance/sheet/sheet-patch-bad-value.data.json +13 -0
- package/conformance/sheet/sheet-patch-bad-value.error.json +6 -0
- package/conformance/sheet/sheet-patch-bad-value.html +25 -0
- package/conformance/sheet/sheet-patch-bad-value.meta +5 -0
- package/conformance/sheet/sheet-patch-clean-tab-beside-edited.after.html +25 -0
- package/conformance/sheet/sheet-patch-clean-tab-beside-edited.after.json +129 -0
- package/conformance/sheet/sheet-patch-clean-tab-beside-edited.data.json +11 -0
- package/conformance/sheet/sheet-patch-clean-tab-beside-edited.html +25 -0
- package/conformance/sheet/sheet-patch-clean-tab-beside-edited.meta +5 -0
- package/conformance/sheet/sheet-patch-clean-tab-beside-edited.write.json +7 -0
- package/conformance/sheet/sheet-patch-covered-cell.data.json +10 -0
- package/conformance/sheet/sheet-patch-covered-cell.error.json +6 -0
- package/conformance/sheet/sheet-patch-covered-cell.html +10 -0
- package/conformance/sheet/sheet-patch-covered-cell.meta +5 -0
- package/conformance/sheet/sheet-patch-empty.data.json +1 -0
- package/conformance/sheet/sheet-patch-empty.error.json +6 -0
- package/conformance/sheet/sheet-patch-empty.html +25 -0
- package/conformance/sheet/sheet-patch-empty.meta +5 -0
- package/conformance/sheet/sheet-patch-fallback-route.after.html +24 -0
- package/conformance/sheet/sheet-patch-fallback-route.after.json +86 -0
- package/conformance/sheet/sheet-patch-fallback-route.data.json +10 -0
- package/conformance/sheet/sheet-patch-fallback-route.html +24 -0
- package/conformance/sheet/sheet-patch-fallback-route.meta +5 -0
- package/conformance/sheet/sheet-patch-fallback-route.write.json +7 -0
- package/conformance/sheet/sheet-patch-first-tab.after.html +25 -0
- package/conformance/sheet/sheet-patch-first-tab.after.json +129 -0
- package/conformance/sheet/sheet-patch-first-tab.data.json +10 -0
- package/conformance/sheet/sheet-patch-first-tab.html +25 -0
- package/conformance/sheet/sheet-patch-first-tab.meta +5 -0
- package/conformance/sheet/sheet-patch-first-tab.write.json +7 -0
- package/conformance/sheet/sheet-patch-formula.after.html +25 -0
- package/conformance/sheet/sheet-patch-formula.after.json +128 -0
- package/conformance/sheet/sheet-patch-formula.data.json +11 -0
- package/conformance/sheet/sheet-patch-formula.html +25 -0
- package/conformance/sheet/sheet-patch-formula.meta +5 -0
- package/conformance/sheet/sheet-patch-formula.write.json +7 -0
- package/conformance/sheet/sheet-patch-no-sheet-rule.data.json +10 -0
- package/conformance/sheet/sheet-patch-no-sheet-rule.error.json +6 -0
- package/conformance/sheet/sheet-patch-no-sheet-rule.html +18 -0
- package/conformance/sheet/sheet-patch-no-sheet-rule.meta +5 -0
- package/conformance/sheet/sheet-patch-no-values.data.json +6 -0
- package/conformance/sheet/sheet-patch-no-values.error.json +6 -0
- package/conformance/sheet/sheet-patch-no-values.html +25 -0
- package/conformance/sheet/sheet-patch-no-values.meta +5 -0
- package/conformance/sheet/sheet-patch-not-canonical.data.json +11 -0
- package/conformance/sheet/sheet-patch-not-canonical.error.json +6 -0
- package/conformance/sheet/sheet-patch-not-canonical.html +25 -0
- package/conformance/sheet/sheet-patch-not-canonical.meta +5 -0
- package/conformance/sheet/sheet-patch-outside-sheet.data.json +11 -0
- package/conformance/sheet/sheet-patch-outside-sheet.error.json +6 -0
- package/conformance/sheet/sheet-patch-outside-sheet.html +25 -0
- package/conformance/sheet/sheet-patch-outside-sheet.meta +5 -0
- package/conformance/sheet/sheet-patch-range.after.html +25 -0
- package/conformance/sheet/sheet-patch-range.after.json +126 -0
- package/conformance/sheet/sheet-patch-range.data.json +11 -0
- package/conformance/sheet/sheet-patch-range.html +25 -0
- package/conformance/sheet/sheet-patch-range.meta +5 -0
- package/conformance/sheet/sheet-patch-range.write.json +7 -0
- package/conformance/sheet/sheet-patch-two-tabs.after.html +25 -0
- package/conformance/sheet/sheet-patch-two-tabs.after.json +130 -0
- package/conformance/sheet/sheet-patch-two-tabs.data.json +20 -0
- package/conformance/sheet/sheet-patch-two-tabs.html +25 -0
- package/conformance/sheet/sheet-patch-two-tabs.meta +5 -0
- package/conformance/sheet/sheet-patch-two-tabs.write.json +7 -0
- package/conformance/sheet/sheet-patch-typed.after.html +25 -0
- package/conformance/sheet/sheet-patch-typed.after.json +121 -0
- package/conformance/sheet/sheet-patch-typed.data.json +13 -0
- package/conformance/sheet/sheet-patch-typed.html +25 -0
- package/conformance/sheet/sheet-patch-typed.meta +5 -0
- package/conformance/sheet/sheet-patch-typed.write.json +7 -0
- package/conformance/sheet/sheet-patch-unknown-sheet.data.json +11 -0
- package/conformance/sheet/sheet-patch-unknown-sheet.error.json +6 -0
- package/conformance/sheet/sheet-patch-unknown-sheet.html +25 -0
- package/conformance/sheet/sheet-patch-unknown-sheet.meta +5 -0
- package/conformance/sheet/sheet-read-bad-range.error.json +6 -0
- package/conformance/sheet/sheet-read-bad-range.html +25 -0
- package/conformance/sheet/sheet-read-bad-range.meta +6 -0
- package/conformance/sheet/sheet-read-bad-render.error.json +6 -0
- package/conformance/sheet/sheet-read-bad-render.html +25 -0
- package/conformance/sheet/sheet-read-bad-render.meta +6 -0
- package/conformance/sheet/sheet-read-digest.expected.json +91 -0
- package/conformance/sheet/sheet-read-digest.html +25 -0
- package/conformance/sheet/sheet-read-digest.meta +6 -0
- package/conformance/sheet/sheet-read-empty.expected.json +11 -0
- package/conformance/sheet/sheet-read-empty.html +6 -0
- package/conformance/sheet/sheet-read-empty.meta +5 -0
- package/conformance/sheet/sheet-read-escapes.expected.json +108 -0
- package/conformance/sheet/sheet-read-escapes.html +22 -0
- package/conformance/sheet/sheet-read-escapes.meta +5 -0
- package/conformance/sheet/sheet-read-formulas-formatted.expected.json +298 -0
- package/conformance/sheet/sheet-read-formulas-formatted.html +16 -0
- package/conformance/sheet/sheet-read-formulas-formatted.meta +5 -0
- package/conformance/sheet/sheet-read-grid-in-comment.expected.json +85 -0
- package/conformance/sheet/sheet-read-grid-in-comment.html +24 -0
- package/conformance/sheet/sheet-read-grid-in-comment.meta +5 -0
- package/conformance/sheet/sheet-read-grid-in-script.expected.json +85 -0
- package/conformance/sheet/sheet-read-grid-in-script.html +24 -0
- package/conformance/sheet/sheet-read-grid-in-script.meta +5 -0
- package/conformance/sheet/sheet-read-grid-in-template.expected.json +85 -0
- package/conformance/sheet/sheet-read-grid-in-template.html +24 -0
- package/conformance/sheet/sheet-read-grid-in-template.meta +5 -0
- package/conformance/sheet/sheet-read-grid-in-textarea.expected.json +85 -0
- package/conformance/sheet/sheet-read-grid-in-textarea.html +24 -0
- package/conformance/sheet/sheet-read-grid-in-textarea.meta +5 -0
- package/conformance/sheet/sheet-read-grid-outside-read-by-rule.expected.json +94 -0
- package/conformance/sheet/sheet-read-grid-outside-read-by-rule.html +24 -0
- package/conformance/sheet/sheet-read-grid-outside-read-by-rule.meta +5 -0
- package/conformance/sheet/sheet-read-grid-outside-sheet.expected.json +85 -0
- package/conformance/sheet/sheet-read-grid-outside-sheet.html +24 -0
- package/conformance/sheet/sheet-read-grid-outside-sheet.meta +5 -0
- package/conformance/sheet/sheet-read-hand-edited.expected.json +85 -0
- package/conformance/sheet/sheet-read-hand-edited.html +18 -0
- package/conformance/sheet/sheet-read-hand-edited.meta +5 -0
- package/conformance/sheet/sheet-read-index.expected.json +19 -0
- package/conformance/sheet/sheet-read-index.html +25 -0
- package/conformance/sheet/sheet-read-index.meta +6 -0
- package/conformance/sheet/sheet-read-merged.expected.json +59 -0
- package/conformance/sheet/sheet-read-merged.html +10 -0
- package/conformance/sheet/sheet-read-merged.meta +5 -0
- package/conformance/sheet/sheet-read-no-tag.error.json +5 -0
- package/conformance/sheet/sheet-read-no-tag.html +18 -0
- package/conformance/sheet/sheet-read-no-tag.meta +5 -0
- package/conformance/sheet/sheet-read-padded-name-index.expected.json +19 -0
- package/conformance/sheet/sheet-read-padded-name-index.html +25 -0
- package/conformance/sheet/sheet-read-padded-name-index.meta +6 -0
- package/conformance/sheet/sheet-read-padded-name-lookup.expected.json +83 -0
- package/conformance/sheet/sheet-read-padded-name-lookup.html +25 -0
- package/conformance/sheet/sheet-read-padded-name-lookup.meta +6 -0
- package/conformance/sheet/sheet-read-padded-name-trimmed-lookup.error.json +6 -0
- package/conformance/sheet/sheet-read-padded-name-trimmed-lookup.html +25 -0
- package/conformance/sheet/sheet-read-padded-name-trimmed-lookup.meta +6 -0
- package/conformance/sheet/sheet-read-padded-name.expected.json +128 -0
- package/conformance/sheet/sheet-read-padded-name.html +25 -0
- package/conformance/sheet/sheet-read-padded-name.meta +5 -0
- package/conformance/sheet/sheet-read-range-cells.expected.json +55 -0
- package/conformance/sheet/sheet-read-range-cells.html +25 -0
- package/conformance/sheet/sheet-read-range-cells.meta +6 -0
- package/conformance/sheet/sheet-read-range-first-tab.expected.json +12 -0
- package/conformance/sheet/sheet-read-range-first-tab.html +25 -0
- package/conformance/sheet/sheet-read-range-first-tab.meta +6 -0
- package/conformance/sheet/sheet-read-range-formulas.expected.json +24 -0
- package/conformance/sheet/sheet-read-range-formulas.html +25 -0
- package/conformance/sheet/sheet-read-range-formulas.meta +6 -0
- package/conformance/sheet/sheet-read-range-values.expected.json +24 -0
- package/conformance/sheet/sheet-read-range-values.html +25 -0
- package/conformance/sheet/sheet-read-range-values.meta +6 -0
- package/conformance/sheet/sheet-read-sheet-by-id.expected.json +46 -0
- package/conformance/sheet/sheet-read-sheet-by-id.html +25 -0
- package/conformance/sheet/sheet-read-sheet-by-id.meta +6 -0
- package/conformance/sheet/sheet-read-sheet-by-name.expected.json +46 -0
- package/conformance/sheet/sheet-read-sheet-by-name.html +25 -0
- package/conformance/sheet/sheet-read-sheet-by-name.meta +6 -0
- package/conformance/sheet/sheet-read-styled.expected.json +48 -0
- package/conformance/sheet/sheet-read-styled.html +10 -0
- package/conformance/sheet/sheet-read-styled.meta +5 -0
- package/conformance/sheet/sheet-read-tiny.expected.json +85 -0
- package/conformance/sheet/sheet-read-tiny.html +18 -0
- package/conformance/sheet/sheet-read-tiny.meta +5 -0
- package/conformance/sheet/sheet-read-two-tabs.expected.json +128 -0
- package/conformance/sheet/sheet-read-two-tabs.html +25 -0
- package/conformance/sheet/sheet-read-two-tabs.meta +5 -0
- package/conformance/sheet/sheet-read-unknown-sheet.error.json +6 -0
- package/conformance/sheet/sheet-read-unknown-sheet.html +25 -0
- package/conformance/sheet/sheet-read-unknown-sheet.meta +6 -0
- package/conformance/sheet/sheet-read-version-1-codec.error.json +5 -0
- package/conformance/sheet/sheet-read-version-1-codec.html +25 -0
- package/conformance/sheet/sheet-read-version-1-codec.meta +5 -0
- package/conformance/sheet/sheet-write-whole-refused.data.json +3 -0
- package/conformance/sheet/sheet-write-whole-refused.error.json +7 -0
- package/conformance/sheet/sheet-write-whole-refused.html +25 -0
- package/conformance/sheet/sheet-write-whole-refused.meta +5 -0
- package/conformance/sheet-guard-extraction.json +616 -0
- package/conformance/sheet-guard.json +32362 -0
- package/conformance/sheet-read-shapes.json +1 -0
- package/dist/hyper-html-api.engine.esm.js +1 -1
- package/dist/hyper-html-api.engine.min.js +1 -1
- package/dist/hyper-html-api.min.js +8 -8
- package/dist/hyper-html-api.upgrade.min.js +2 -2
- package/package.json +6 -3
- package/src/codecs/sheet.js +127 -0
- package/src/codecs/sheet.vendor.js +887 -0
- package/src/dom-api.js +20 -11
- package/src/engine/apply.js +17 -7
- package/src/engine/codecs.js +80 -0
- package/src/engine/errors.js +20 -1
- package/src/engine/extract.js +17 -3
- package/src/engine/index.js +9 -5
- package/src/engine/round-trip.js +24 -10
- package/src/engine/rule-syntax.js +29 -3
- package/src/engine/rules-tag.js +3 -2
- package/src/engine/write-plan.js +4 -3
- package/src/page.js +15 -5
- package/src/patch-document.js +122 -0
- package/src/read.js +163 -0
- package/src/site.js +164 -0
- package/src/upgrade/codec-carry.js +23 -0
- package/src/upgrade/extract-all.js +12 -3
- package/src/upgrade/migrate.js +31 -3
- package/src/upgrade/rules-tags.js +4 -4
- package/src/upgrade/shape-match.js +32 -13
- package/src/write.js +44 -5
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var hyperHtmlApiUpgrade=(()=>{var fe=Object.defineProperty;var dt=Object.getOwnPropertyDescriptor;var pt=Object.getOwnPropertyNames;var ht=Object.prototype.hasOwnProperty;var Pe=(e,t)=>{for(var n in t)fe(e,n,{get:t[n],enumerable:!0})},mt=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of pt(t))!ht.call(e,r)&&r!==n&&fe(e,r,{get:()=>t[r],enumerable:!(o=dt(t,r))||o.enumerable});return e};var yt=e=>mt(fe({},"__esModule",{value:!0}),e);var ln={};Pe(ln,{default:()=>cn,engine:()=>Se,upgrade:()=>ut});var G=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],Z=new Set(G),ue=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Q=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),Me=new Set(["checked","selected","disabled","readOnly","paused"]);function ae(e,t){return t==null?Me.has(e)?!1:"":Me.has(e)?t==="false"?!1:!!t:t}var ne={};Pe(ne,{EmptyListInsert:()=>P,MAX_RULE_DEPTH:()=>D,MaxRuleDepthExceeded:()=>k,NoRulesTag:()=>de,RuleTargetReadOnly:()=>H,RulesParseError:()=>_,ShapeMismatch:()=>U,UnknownRulesVersion:()=>M,WriteNotRoundTripped:()=>te,WriteRefused:()=>ee,WriteRejected:()=>pe});var _=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},M=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},D=20,k=class extends Error{constructor(t){super(`rule depth exceeded ${D} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},U=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},P=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},H=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},ee=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function gt(e){return e.reduce((n,o)=>typeof o=="number"?`${n}[${o}]`:n?`${n}.${o}`:String(o),"")||"(root)"}var te=class extends Error{constructor(t){super(`write did not round-trip at "${gt(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},de=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},pe=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}};function S(e){let t=0,n=null,o=-1;for(let r=0;r<e.length;r++){let i=e[r];i==="\\"?r++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:i==="@"&&t===0&&(o=r)}return o}function he(e){let t=S(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function me(e){let t=0,n=null,o=-1,r=!1;for(let i=0;i<e.length;i++){let s=e[i];s==="\\"?i++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:t===0&&s===">"?o=i:t===0&&s===","&&(r=!0)}return r||o===-1||!At(e,o+1)?null:e.slice(0,o).trim()||null}function At(e,t){let n=t,o=e.replace(/\s+$/,"").length;for(;n<o&&/\s/.test(e[n]);)n++;let r=0,i=null;for(;n<o;n++){let s=e[n];if(s==="\\")n++;else if(i)s===i&&(i=null);else if(s==='"'||s==="'")i=s;else if(s==="["||s==="(")r++;else if(s==="]"||s===")")r>0&&r--;else if(r===0&&(s==="+"||s==="~"||/\s/.test(s)))return!1}return!0}var wt=/^--[A-Za-z0-9_-]+$/;function I(e){return typeof e=="string"&&wt.test(e)}function ke(e){let t=[],n=[],o=null,r=0;for(let i=0;i<e.length;i++){let s=e[i];if(o){s==="\\"?i++:s===o&&(o=null);continue}if(s==="/"&&e[i+1]==="*"){let c=e.indexOf("*/",i+2);i=c===-1?e.length:c+1;continue}s==='"'||s==="'"?o=s:s==="("?n.push(")"):s==="["?n.push("]"):s==="{"?n.push("}"):(s===")"||s==="]"||s==="}")&&n[n.length-1]===s?n.pop():s===";"&&n.length===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function Tt(e){let t="",n=null;for(let o=0;o<e.length;o++){let r=e[o];if(n){t+=r,r==="\\"&&o+1<e.length?t+=e[++o]:r===n&&(n=null);continue}if(r==="/"&&e[o+1]==="*"){let i=e.indexOf("*/",o+2);o=i===-1?e.length:i+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function Ie(e){e=Tt(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),o=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(o);return r&&(o=o.slice(0,r.index).trim()),{name:n,value:o,important:!!r}}function q(e,t){if(e==null)return null;let n=null;for(let o of ke(String(e))){let r=Ie(o);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function Le(e,t,n){let o=e==null?"":String(e),r=n==null||n==="",i=ke(o),s=i.map(Ie),c=s.some(h=>h&&h.name===t&&h.important),l=[],u=!1;i.forEach((h,m)=>{let T=s[m];if(!T||T.name!==t){l.push(h);return}if(r||u)return;let f=/^\s*/.exec(h)[0];l.push(`${f}${t}: ${n}${c?" !important":""}`),u=!0});let d=l.join(";");if(!r&&!u){let h=d.trimEnd();d=h===""?`${t}: ${n}`:`${h}${h.endsWith(";")?" ":"; "}${t}: ${n}`}return d.trim()===""?null:d}function ye(e,t,n,o){let r=e.attr(t,"style");if((q(r,n)??"")===o)return;let i=Le(r,n,o);i==null?e.removeAttr(t,"style"):e.attr(t,"style",i)}function N(e,t,n,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return ge(e,t,n,{depth:0,path:[]},o)}function ge(e,t,n,o,r){if(o.depth>D)throw new k(o.path);if(typeof n=="string")return xt(e,t,n,o,r);if(Array.isArray(n)){let[i,s]=n,c=e.find(t,i,r);return $e(r,o,c),c.map((l,u)=>ge(e,l,s,{depth:o.depth+1,path:[...o.path,u]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[s,c]of Object.entries(n))i[s]=ge(e,t,c,{depth:o.depth+1,path:[...o.path,s]},r);return i}return null}function xt(e,t,n,o,r){if(n.endsWith("[]")){let c=n.slice(0,-2),l=e.find(t,c,r);return $e(r,o,l),l.map(u=>e.text(u))}if(n.startsWith("@"))return je(e,t,n.slice(1));let i=S(n);if(i!==-1){let c=n.slice(0,i),l=n.slice(i+1),u=c?e.find(t,c,r):[t];return u.length===0?null:je(e,u[0],l)}if(n===".")return e.text(t);let s=e.find(t,n,r);return s.length===0?null:e.text(s[0])}function $e(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function je(e,t,n){if(I(n))return q(e.attr(t,"style"),n);if(Z.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o??null}function ve(e,t,n,o){let r=e.length,i=t.length,s=new Array(r).fill(-1);if(o){let a=new Set;for(let y=0;y<r;y++){let A=o[y];!(A>=0&&A<i)||a.has(A)||(s[y]=A,a.add(A))}}if(r===0||i===0)return s;let c=e.map(a=>_e(a,n)),l=t.map(a=>_e(a,n)),u=new Array(i).fill(!1);for(let a of s)a>=0&&(u[a]=!0);let d=new Map;l.forEach((a,y)=>{u[y]||d.set(a,d.has(a)?-1:y)});let h=new Map;c.forEach((a,y)=>{s[y]>=0||h.set(a,(h.get(a)||0)+1)}),c.forEach((a,y)=>{if(s[y]>=0||h.get(a)!==1)return;let A=d.get(a);A===void 0||A===-1||u[A]||(s[y]=A,u[A]=!0)});let m=[];for(let a=0;a<r;a++)s[a]<0&&m.push(a);let T=[];for(let a=0;a<i;a++)u[a]||T.push(a);if(m.length===0||T.length===0)return s;let f=r*i+1,p=Ot(e,t,n),g=(a,y)=>p(a,y)*f+Math.abs(a-y);for(let[a,y]of Et(m,T,g))s[a]=y;return s}var We=e=>typeof e=="object"&&e!==null;function _e(e,t){if(!We(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function Ot(e,t,n){if(!We(n))return(c,l)=>e[c]===t[l]?0:1;let o=Object.keys(n),r=c=>o.map(l=>JSON.stringify(c?.[l])),i=e.map(r),s=t.map(r);return(c,l)=>{let u=i[c],d=s[l],h=0;for(let m=0;m<o.length;m++)u[m]!==d[m]&&h++;return h}}function Et(e,t,n){return e.length<=t.length?De(e,t,n,!1):De(t,e,(o,r)=>n(r,o),!0)}function De(e,t,n,o){let r=e.length,i=t.length,s=[];for(let h=0;h<=r;h++)s.push(new Float64Array(i+1).fill(1/0));let c=[];for(let h=0;h<=r;h++)c.push(new Uint8Array(i+1));for(let h=0;h<=i;h++)s[r][h]=0;for(let h=r-1;h>=0;h--)for(let m=i-1;m>=0;m--){let T=n(e[h],t[m])+s[h+1][m+1],f=s[h][m+1];T<=f?(s[h][m]=T,c[h][m]=1):s[h][m]=f}let l=[],u=0,d=0;for(;u<r&&d<i;)c[u][d]&&(l.push(o?[t[d],e[u]]:[e[u],t[d]]),u++),d++;return l}function we(e,t,n,o,r,i,s,c={}){let l=e.find(t,n,c);if(r.length===0){l.forEach(w=>e.remove(w)),Ae(c,"onRowsApplied",i.path,[]);return}let u=r.length>l.length,d=l[0]||null;if(u&&!d&&(d=Nt(e,t,n,c),!d))throw new P(i.path);let h=l.map(w=>Rt(e,w,o,c)),m=null;if(u&&d){m=e.clone(d),c.templateAttr&&e.removeAttr(m,c.templateAttr);let w=e.stripIds(m);w>0&&console.warn(`[hyper-html-api] stripped ${w} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let T=ve(r,h,o,bt(e,l,r,i,c)),f=l.length>0?e.parent(l[0]):kt(e,t,n,d,i,c),p=l.length>0?Be(e,f,l[0]):0,g=jt(e,l),a=new Set,y=[],A=r.map((w,b)=>{let O=T[b];if(O>=0)return a.add(O),y.push(!1),l[O];y.push(!0);let x=e.clone(m);return e.stripIds(x),x});l.forEach((w,b)=>{a.has(b)||e.remove(w)}),g?Lt(e,f,p,A,y):$t(e,A,y,f,p),St(e,A,o,r,i,s,c),Ae(c,"onRowsApplied",i.path,A)}function Ae(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function bt(e,t,n,o,r){let i=Ae(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let s=new Array(n.length).fill(-1),c=new Set,l=new Map(t.map((u,d)=>[e.identity(u),d]));for(let u=0;u<n.length;u++){if(!i[u])continue;let d=l.get(e.identity(i[u]));d===void 0||c.has(d)||(s[u]=d,c.add(d))}return s}function St(e,t,n,o,r,i,s){t.forEach((c,l)=>{if(n===null){let u=o[l],d=u==null?"":String(u);e.text(c)!==d&&e.text(c,d)}else{let u=i(e,c,n,o[l],{depth:r.depth+1,path:[...r.path,l]},s);u&&u!==c&&(t[l]=u)}})}function Rt(e,t,n,o){return n===null?e.text(t):N(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Be(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function Nt(e,t,n,o){if(!o.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),i=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),s=n.replace(/^\s*:scope\s*>\s*/,"").replace(i,""),c=r?Ct(s):0,l=me(s),u=t;for(;u;){let d=e.find(u,s,{includeRulesTag:!1,templateAttr:null});for(let h of d)if(e.attr(h,o.templateAttr)!=null&&!(r&&!Mt(e,t,h,c))&&!(l&&!e.matches(e.parent(h),l)))return h;u=e.parent(u)}return null}function Ct(e){let t=0,n=null,o=1;for(let r=0;r<e.length;r++){let i=e[r];if(i==="\\")r++;else if(n)i===n&&(n=null);else if(i==='"'||i==="'")n=i;else if(i==="["||i==="(")t++;else if(i==="]"||i===")")t>0&&t--;else if(t===0&&i===">")o++;else{if(t===0&&(i==="+"||i==="~"))return null;if(t===0&&/\s/.test(i)){if(!Pt(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return o}function Pt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let o=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return Ue(o)||Ue(r)}function Ue(e){return e===">"||e==="+"||e==="~"}function Mt(e,t,n,o){if(o===null)return!0;let r=n;for(let l=0;l<o;l++)if(r=e.parent(r),!r)return!1;let i=e.prop(t,"tagName");if(!i)return!0;let s=e.prop(r,"tagName");if(!s||String(s).toLowerCase()!==String(i).toLowerCase())return!1;let c=new Set(He(e,r));return He(e,t).every(l=>c.has(l))}function He(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function kt(e,t,n,o,r,i){let s=e.parent(o);if(s&&It(e,t,s)&&!Ve(e,s,i))return s;let c=me(n);if(!c)throw new P(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let u=(c===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,c,i)).filter(d=>!Ve(e,d,i));if(u.length===0)throw new P(r.path,`no container matching "${c}" inside this context to hold the new rows`);if(u.length>1)throw new P(r.path,`"${c}" matches ${u.length} containers inside this context, so the new rows have no single destination`);return u[0]}function It(e,t,n){let o=n;for(;o;){if(e.sameNode(o,t))return!0;o=e.parent(o)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var qe=["no-data","editor-ui"];function Ve(e,t,n){let o=t;for(;o;){if(n.templateAttr&&e.attr(o,n.templateAttr)!=null||qe.some(i=>e.attr(o,i)!=null))return!0;let r=e.attr(o,"clay");if(r&&r.split(/\s+/).some(i=>qe.includes(i)))return!0;o=e.parent(o)}return!1}function Lt(e,t,n,o,r){let i=e.children(t),s=i.map(l=>e.identity(l)),c=!1;o.forEach((l,u)=>{let d=e.identity(l),h=n+u;if(s[h]===d)return;if(!r[u]){let T=s.indexOf(d);T!==-1&&(s.splice(T,1),i.splice(T,1))}let m=Math.min(h,i.length);m<i.length?e.insertBefore(i[m],l):i.length?c?e.insertAfter(i[i.length-1],l):(e.insertAt(t,l,h),c=!0):e.insertAt(t,l,0),s.splice(m,0,d),i.splice(m,0,l)})}function jt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=new Map(e.children(n).map((i,s)=>[e.identity(i),s])),r=[];for(let i of t){let s=o.get(e.identity(i));if(s===void 0)return!1;r.push(s)}return r.sort((i,s)=>i-s),r[r.length-1]-r[0]===r.length-1}function $t(e,t,n,o,r){let i=null,s=r;for(let c=0;c<t.length;c++){if(!n[c]){i=t[c];continue}let l=i?e.parent(i):o;if(!l)continue;let u=i?Be(e,l,i)+1:s++;e.insertAt(l,t[c],u),i=t[c]}}function L(e,t,n,o,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let i=[];if(Te(n,o,[],i),i.length)throw new U(i);re(e,t,n,o,{depth:0,path:[]},r)}function re(e,t,n,o,r,i={}){if(r.depth>D)throw new k(r.path);if(o===void 0)return t;if(typeof n=="string")return _t(e,t,n,o,r,i);if(Array.isArray(n)){let[s,c]=n;return we(e,t,s,c,o,r,re,i),t}if(typeof n=="object"&&n!==null){for(let[s,c]of Object.entries(n)){let l=re(e,t,c,o==null?o:o[s],{depth:r.depth+1,path:[...r.path,s]},i);l&&l!==t&&(t=l)}return t}return t}function _t(e,t,n,o,r,i){if(n.endsWith("[]")){let l=n.slice(0,-2);return we(e,t,l,null,o,r,re,i),t}if(n.startsWith("@"))return Fe(e,t,n.slice(1),o);let s=S(n);if(s!==-1){let l=n.slice(0,s),u=n.slice(s+1),d=l?e.find(t,l,i):[t];return d.length===0||Fe(e,d[0],u,o),t}if(n===".")return ze(e,t,o),t;let c=e.find(t,n,i);return c.length===0||ze(e,c[0],o),t}function ze(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function Dt(e,t,n,o){if(e.styleVar){e.styleVar(t,n,o);return}ye(e,t,n,o)}function Fe(e,t,n,o){if(I(n))return Dt(e,t,n,o==null?"":String(o).trim()),t;if(Q.has(n)){let r=e.prop(t,n);if(r===o||r!=null&&o!=null&&String(r)===String(o))return t;throw new H(n)}if(n==="outerHTML"){let r=o==null?"":String(o);return e.replaceWith(t,r)}if(ue.has(n)){let r=ae(n,o);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(o==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(o);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function Te(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,i)=>{typeof r=="object"&&r!==null&&o.push({path:B([...n,i]),expected:"scalar",got:V(r)})}):o.push({path:B(n),expected:"array",got:V(t)});return}t!==null&&typeof t=="object"&&o.push({path:B(n),expected:"scalar",got:V(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:B(n),expected:"array",got:V(t)});return}let r=e[1];t.forEach((i,s)=>Te(r,i,[...n,s],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:B(n),expected:"object",got:V(t)});return}for(let[r,i]of Object.entries(e))Te(i,t[r],[...n,r],o)}}}function V(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function B(e){return e.join(".")}function xe(e){try{return JSON.parse(e)}catch(t){throw new _(`Invalid strict JSON: ${t.message}`,t)}}function j(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let i=[],s=0;for(;s<r.length;){let c=r[s];if(/\s/.test(c)){s++;continue}if("{}".includes(c)){i.push({type:c,value:c}),s++;continue}if(c==="["){let h=!1,m=s+1;for(;m<r.length&&/\s/.test(r[m]);)m++;if(m<r.length&&/[a-zA-Z_]/.test(r[m])&&(h=!0),!h){i.push({type:c,value:c}),s++;continue}}if(c==="]"){i.push({type:c,value:c}),s++;continue}if(c===":"){i.push({type:t.COLON,value:c}),s++;continue}if(c===","){i.push({type:t.COMMA,value:c}),s++;continue}if(c==='"'||c==="'"){let h=c,m=s+1;for(;m<r.length&&r[m]!==h;)r[m]==="\\"&&m++,m++;i.push({type:t.STRING,value:r.substring(s+1,m),quoted:!0,sourceQuote:h}),s=m+1;continue}let l=s,u;for(;l<r.length&&!/[{},]/.test(r[l]);)if(r[l]===":"){let h=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],m=!1;for(let T of h){let f=T.substring(1);if(r.substring(l+1,l+1+f.length)===f){m=!0,l+=f.length;break}}if(!m)break}else if(r[l]==="["){for(l++;l<r.length&&r[l]!=="]";){if(r[l]==='"'||r[l]==="'"){let h=r[l];for(l++;l<r.length&&r[l]!==h;)r[l]==="\\"&&l++,l++}l++}l<r.length&&r[l]==="]"&&l++}else l++;u=r.substring(s,l);let d=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?d=t.NUMBER:u==="true"||u==="false"||u==="null"?d=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(d=t.SELECTOR),i.push({type:d,value:u,quoted:!1}),s=l}return i}function o(r){let i="";for(let s=0;s<r.length;s++){let c=r[s];if("{}".includes(c.type)||"[]".includes(c.type)){i+=c.value;continue}if(c.type===t.COLON){i+=c.value;continue}if(c.type===t.COMMA){let l=r[s+1];if(l&&(l.type==="}"||l.type==="]"))continue;i+=c.value;continue}if(c.type===t.STRING&&c.quoted){let l=c.value;c.sourceQuote==="'"&&(l=l.replace(/\\'/g,"'"),l=l.replace(/(\\*)"/g,(u,d)=>d.length%2===0?d+'\\"':u)),i+=`"${l}"`;continue}if(c.type===t.NUMBER||c.type===t.BOOLEAN){i+=c.value;continue}if(c.type===t.SELECTOR||c.type===t.IDENTIFIER){i+=`"${c.value}"`;continue}i+=`"${c.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new _("Invalid extraction rules syntax: "+r.message,r)}}var Oe="1",Ke=/^[a-zA-Z0-9_-]+$/;function z(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!Ke.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Ke})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let i=r[0],s=e.attr(i,"data-rules-version");if(s!==Oe)throw new M(s);return{rules:j(e.text(i)),tagNode:i}}var oe=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),vt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Je=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function F(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Ee(e,t){if(F(e,t))return!0;for(let[n,o]of Object.entries(vt))if(o.includes(t)&&F(e,n))return!0;return!1}function K(e){let t=oe[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Wt(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=oe[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>Ee(n,r))||o.bundles.some(r=>F(n,r)))return n;n=n.parentElement}return null}function Ye(e,t){return!!Wt(e,t)}var Ut=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...Je],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})});function be(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return z(e,o,n)}return null}var Bt=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function zt(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Xe(e,t,n,o){if(o)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function Ge(e,t,n,o,r,i){return(i?Ye(e,t):Xe(e,n,r,!1))||!!(o&&(i&&e!==r?e.matches(o):Xe(e,o,r,i)))}function Ft(e,t){let n=oe[t];return n.tokens.some(o=>Ee(e,o))||n.bundles.some(o=>F(e,o))}var Kt=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Ze(e,t,n,o){if(e.nodeType===1&&o(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,i=t;if(e.nodeType===1){if(Kt.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,i=t.content,n.cloneToLive.set(i,r),n.liveToClone.set(r,i)}}else if(e.nodeType!==11)return;let s=i.firstChild;for(let c=r.firstChild;c&&s;c=c.nextSibling)Ze(c,s,n,o),s=s.nextSibling}function J(e,{capability:t="data",exclude:n=null,inherit:o=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let i=e.nodeType===9?e:e.ownerDocument;if(!i?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=i.implementation.createHTMLDocument(""),c=r||new WeakMap,l=new WeakMap,u=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let d=K(t),h=o?f=>Ft(f,t)||!!(n&&f.matches(n)):f=>Ge(f,t,d,n,u,!1),m=null;if(u.nodeType!==1||!Ge(u,t,d,n,u,o)){m=s.importNode(u,!0);let f={cloneToLive:c,liveToClone:l,dropped:[],controls:[]};Ze(u,m,f,h);for(let p of f.dropped)p.remove();for(let p=0;p<f.controls.length;p+=2)zt(f.controls[p],f.controls[p+1])}e.nodeType===9&&m&&(s.replaceChild(m,s.documentElement),l.set(e,s),c.set(s,e));let T=f=>{if(Bt.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:m,document:s,capability:t,selector:K(t),cloneToLive:c,liveToClone:l,original(f){return c.get(f)||null},cloneOf(f){return l.get(f)||null},query(f,p=m){return T(f),Array.from(p.querySelectorAll(f),g=>c.get(g)||g)},text(f=m){return(f===m?m:l.get(f))?.textContent||""},html(f=m){return(f===m?m:l.get(f))?.innerHTML??""},clone(f=m){let p=f===m?m:l.get(f);return p?s.importNode(p,!0):null}}}function et(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Jt(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function Qe(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function tt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function nt(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let o=n.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var E={semanticExclude:!0,find(e,t,n={}){let o=Jt(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(c=>!et(c)));let i=[];n.skip&&i.push(n.skip);let s=n.templateAttr===null?null:n.templateAttr||"cms-template";if(s&&i.push("["+s+"]"),i.length){let c=i.join(", ");r=r.filter(l=>!l.closest||!l.closest(c))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,tt(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),Qe(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),Qe(e,t,null)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return nt(t),t},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function Y(e,t={}){if(t.exclude===null)return E;let n=[K("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return E;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,s=e.nodeType===9?e:e.ownerDocument,c=null,l=()=>c||(c=J(i,{capability:"data",exclude:t.exclude||null})),u=f=>{let p=l();return f===e?p.cloneOf(e):p.cloneOf(f)||f},d=f=>c?.original(f)||f,h=(f,p)=>{l().liveToClone.set(f,p),l().cloneToLive.set(p,f);let g=f.childNodes||[],a=p.childNodes||[];for(let y=0;y<Math.min(g.length,a.length);y++)h(g[y],a[y])},m=(f,p,g,a)=>{let y=Array.from(f.childNodes).filter(x=>c.cloneOf(x)),w=y[0];for(;w&&y.includes(w);)w=w.nextSibling;for(let x of y)x.remove();if(g==="innerHTML"){let x=s.createElement("template");x.innerHTML=a;for(let W of Array.from(x.content.childNodes))f.insertBefore(W,w||null)}else f.insertBefore(s.createTextNode(a),w||null),tt(f,a);let b=J(f,{capability:"data",exclude:t.exclude||null});p.replaceChildren(...Array.from(b.root?.childNodes||[]));let O=x=>{let W=b.original(x);W&&(c.liveToClone.set(W,x),c.cloneToLive.set(x,W));for(let at of Array.from(x.childNodes||[]))O(at)};for(let x of Array.from(p.childNodes))O(x)},T={...E,find(f,p,g={}){let a=u(f);if(!a?.querySelectorAll)return[];let y=l().query(p,a);g.includeRulesTag||(y=y.filter(b=>!et(b)));let A=[];g.skip&&A.push(g.skip);let w=g.templateAttr===null?null:g.templateAttr||"cms-template";if(w&&A.push(`[${w}]`),A.length){let b=A.join(", ");y=y.filter(O=>!O.closest?.(b))}return y},parent(f){let p=u(f)?.parentElement;return p?d(p):null},children(f){return Array.from(u(f)?.children||[],d)},text(f,p){if(p===void 0){let y=d(f);return!y?.matches?.(n)&&!y?.querySelector?.(n)?E.text(y):(u(f)?.textContent||"").trim()}let g=d(f);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!c){E.text(g,p);return}let a=l().cloneOf(g);a?m(g,a,"textContent",p):E.text(g,p)},attr(f,p,g){let a=d(f);if(g===void 0)return E.attr(a,p);E.attr(a,p,g);let y=c?.cloneOf(a);y&&(E.attr(y,p,g),J(a,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),c.liveToClone.delete(a),c.cloneToLive.delete(y)))},removeAttr(f,p){let g=d(f);E.removeAttr(g,p);let a=c?.cloneOf(g);a&&E.removeAttr(a,p)},prop(f,p,g){let a=d(f);if(g===void 0)return p==="innerHTML"||p==="outerHTML"||p==="textContent"||p==="innerText"?E.prop(u(a),p):E.prop(a,p);let y=p==="innerHTML"||p==="textContent"||p==="innerText",A=y?l().cloneOf(a):c?.cloneOf(a);A&&y?m(a,A,p,g):(E.prop(a,p,g),A&&E.prop(A,p,g))},clone(f){let p=u(f);if(p===f)return E.clone(f);let g=s.importNode(p,!0);return nt(g),g},insertAt(f,p,g){let a=d(f),A=T.children(a)[g]||(()=>{for(let O=a.children.length-1;O>=0;O--){let x=a.children[O];if(l().cloneOf(x))return x.nextElementSibling}return a.firstElementChild})(),w=d(p);a.insertBefore(w,A||null);let b=l().cloneOf(a);if(b){let O=l().cloneOf(w);O||(O=s.importNode(w,!0),h(w,O));let x=Array.from(b.children);b.insertBefore(O,x[g]||null)}},insertBefore(f,p){let g=d(f),a=d(p);g.parentNode.insertBefore(a,g);let y=l().cloneOf(g.parentNode);if(y){let A=l().cloneOf(a);A||(A=s.importNode(a,!0),h(a,A));let w=l().cloneOf(g);w?w.before(A):y.appendChild(A)}},insertAfter(f,p){let g=d(f),a=d(p);g.parentNode.insertBefore(a,g.nextSibling);let y=l().cloneOf(g.parentNode);if(y){let A=l().cloneOf(a);A||(A=s.importNode(a,!0),h(a,A));let w=l().cloneOf(g);w?w.after(A):y.appendChild(A)}},identity(f){return d(f)||null},remove(f){let p=d(f),g=l().cloneOf(p);E.remove(p),g&&E.remove(g)},replaceWith(f,p){let g=d(f),a=l().cloneOf(g),y=E.replaceWith(g,p);if(a){let A=J(y,{capability:"data",exclude:t.exclude||null});if(!A.root)a.remove();else{a.replaceWith(A.root);let w=b=>{let O=A.original(b);O&&(c.liveToClone.set(O,b),c.cloneToLive.set(b,O));for(let x of Array.from(b.childNodes||[]))w(x)};w(A.root)}}return y}};return T}var R=E;var Se={extract:(e,t,n={})=>N(Y(e,n),e,t,n),apply:(e,t,n,o={})=>L(Y(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>z(R,e,t),findRules:(e,t)=>be(R,e,t),bind:(e,t,n={})=>{let o=be(R,e,t);if(!o){let r=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...o,get:()=>N(Y(e,n),e,o.rules,n),set:r=>L(Y(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:xe,parseRelaxed:j,ruleAttrIndex:S,splitRule:he,errors:ne,DOM_PROPERTIES:G};var Yt="hha:upgrade-check:";function C(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function rt(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Xt(e,t){let n=rt(e),o=rt(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let i=0;i<r;i++){let s=n[i]||0,c=o[i]||0;if(s!==c)return s>c}return!1}function Gt(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Zt(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function ot({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:i=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(m=>fetch(m)),r=r??Date.now(),!t)return null;let s=C(t,"hyper-source");if(!s)return null;let c=C(t,"hyper-version"),l;try{l=new URL(s,n?n.href:void 0)}catch{return null}if(n&&l.origin===n.origin&&l.pathname===n.pathname)return null;let u=`${Yt}${l.href}:${c||"none"}`,d,h=e?null:Gt(u);if(h&&typeof h.checkedAt=="number"&&r-h.checkedAt<i)d=h.sourceVersion;else{try{let m=await o(l.href);if(!m.ok)throw new Error(`HTTP ${m.status}`);let T=await m.text(),f=new DOMParser().parseFromString(T,"text/html");d=C(f,"hyper-version")}catch{d=null}Zt(u,{checkedAt:r,sourceVersion:d})}return d?{available:Xt(d,c||"0.0.0"),currentVersion:c,sourceVersion:d,sourceUrl:l.href}:null}var Qt="script[data-rules-name]";function en(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ie(e,t){let n=e.find(t,Qt,{includeRulesTag:!0}),o=new Set,r=[];for(let i of n){let s=en(e.attr(i,"data-rules-name"));if(!s)continue;if(o.has(s)){console.warn(`hyper-html-api: duplicate rules tag name "${s}"; using the first.`);continue}let c=e.attr(i,"data-rules-version");if(c!==Oe)throw new M(c);o.add(s),r.push({name:s,rules:j(e.text(i))})}return r}function Re(e,t){let n={};for(let{name:o,rules:r}of ie(e,t))n[o]=N(e,t,r);return n}function it(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Re(R,t),version:C(n,"hyper-version")}}var X=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},se=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},$=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},ce=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var tn="text/hyper-upgrade";function st(e,t){let n=e.find(t,`script[type="${tn}"]`);if(n.length===0)return null;if(n.length>1)throw new ce(n.length);return e.text(n[0])||null}var nn=new Function("url","return import(url)");async function ct(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await nn(n)}catch(r){throw new $(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new $("transform must `export default` a function");return o.default}function le(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=Ne(t,e,n);return Ce(t,e,n),{data:o,summary:n}}function Ne(e,t,n){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):void 0:t==null||typeof t=="object"?void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,o]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(r=>Ne(o,r,n))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,i]of Object.entries(e)){let s=Ne(i,t?.[r],n);s!==void 0&&(o[r]=s)}return o}}function Ce(e,t,n){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let o=new Set(Object.keys(e));for(let r of Object.keys(t))o.has(r)?Ce(e[r],t[r],n):n.discarded+=v(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>Ce(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=v(t))}}function v(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+v(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+v(n),0):1}function lt(e,t,n){let o=ie(e,t),r={carriedOver:0,discarded:0,listItems:0},i={},s=new Set;for(let{name:c,rules:l}of o){if(s.add(c),!Object.prototype.hasOwnProperty.call(n,c)){i[c]={carriedOver:0,discarded:0,listItems:0};continue}let{data:u,summary:d}=le(n[c],l);L(e,t,l,u),i[c]=d,r.carriedOver+=d.carriedOver,r.discarded+=d.discarded,r.listItems+=d.listItems}for(let c of Object.keys(n))s.has(c)||(r.discarded+=v(n[c]));return{totals:r,byName:i,rulesTagCount:o.length}}async function ft({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:i}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),i=i||(a=>fetch(a)),!o)throw new Error("upgrade.run requires a document context");if(e=e||C(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let s=new URL(e,r?r.href:void 0);n=n!==void 0?n:C(o,"hyper-version"),t=t||Re(R,o);let c;try{c=await i(s.href)}catch(a){throw new X(s.href,a)}if(!c.ok)throw new X(s.href,new Error(`HTTP ${c.status}`));let l=await c.text(),u=new DOMParser().parseFromString(l,"text/html"),d=C(u,"hyper-version"),h=t,m=!1,T=st(R,u);if(T){let y=await(await ct(T))(h,{fromVersion:n,toVersion:d});if(!y||typeof y!="object"||Array.isArray(y))throw new $("transform must return a plain object map of { rulesName: data }");h=y,m=!0}let{totals:f,byName:p,rulesTagCount:g}=lt(R,u,h);if(g===0&&Object.keys(h).length>0)throw new se(s.href);return{html:on(u),fromVersion:n,toVersion:d,summary:{transformApplied:m,totals:f,byName:p}}}function rn(e){for(let t of e.querySelectorAll("input")){let n=(t.getAttribute("type")||"").toLowerCase();n!=="file"&&(n==="checkbox"||n==="radio"?t.checked!==t.hasAttribute("checked")&&t.toggleAttribute("checked",t.checked):t.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",t.value))}for(let t of e.querySelectorAll("textarea"))t.value!==t.textContent&&(t.textContent=t.value);for(let t of e.querySelectorAll("select")){let n=[...t.options];if(!t.multiple){let o=n.findIndex(r=>r.hasAttribute("selected"));if(t.selectedIndex===o||o===-1&&t.selectedIndex<=0)continue}for(let o of n)o.selected!==o.hasAttribute("selected")&&o.toggleAttribute("selected",o.selected)}}function on(e){return rn(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
2
|
-
`+e.documentElement.outerHTML}var
|
|
1
|
+
var hyperHtmlApiUpgrade=(()=>{var ge=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var Nt=Object.getOwnPropertyNames;var kt=Object.prototype.hasOwnProperty;var qe=(e,t)=>{for(var n in t)ge(e,n,{get:t[n],enumerable:!0})},Pt=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Nt(t))!kt.call(e,r)&&r!==n&&ge(e,r,{get:()=>t[r],enumerable:!(o=Ct(t,r))||o.enumerable});return e};var Mt=e=>Pt(ge({},"__esModule",{value:!0}),e);var kn={};qe(kn,{default:()=>Nn,engine:()=>ve,upgrade:()=>bt});var ne=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],re=new Set(ne),we=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),W=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),Ve=new Set(["checked","selected","disabled","readOnly","paused"]);function Ae(e,t){return t==null?Ve.has(e)?!1:"":Ve.has(e)?t==="false"?!1:!!t:t}var se={};qe(se,{CodecRefused:()=>xe,EmptyListInsert:()=>I,MAX_RULE_DEPTH:()=>L,MaxRuleDepthExceeded:()=>$,NoRulesTag:()=>Te,RuleTargetReadOnly:()=>z,RulesParseError:()=>C,ShapeMismatch:()=>B,UnknownCodec:()=>F,UnknownRulesVersion:()=>j,WriteNotRoundTripped:()=>ie,WriteRefused:()=>oe,WriteRejected:()=>Oe});var C=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},j=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=t}},L=20,$=class extends Error{constructor(t){super(`rule depth exceeded ${L} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},B=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},I=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},z=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},oe=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function It(e){return e.reduce((n,o)=>typeof o=="number"?`${n}[${o}]`:n?`${n}.${o}`:String(o),"")||"(root)"}var ie=class extends Error{constructor(t){super(`write did not round-trip at "${It(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},Te=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},Oe=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}},F=class extends Error{constructor(t){super(`unknown codec "${t}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=t}},xe=class extends Error{constructor(t,n){super(n),this.name="CodecRefused",this.code=t}};function b(e){let t=0,n=null,o=-1;for(let r=0;r<e.length;r++){let i=e[r];i==="\\"?r++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:i==="@"&&t===0&&(o=r)}return o}var Be="[*]";function R(e){let t=b(e),n=t===-1?e:e.slice(0,t),o=n.endsWith(Be),r={selector:o?n.slice(0,-Be.length):n,prop:t===-1?null:e.slice(t+1)||null};return o&&(r.all=!0),r}function Ee(e){let t=0,n=null,o=-1,r=!1;for(let i=0;i<e.length;i++){let s=e[i];s==="\\"?i++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:t===0&&s===">"?o=i:t===0&&s===","&&(r=!0)}return r||o===-1||!Lt(e,o+1)?null:e.slice(0,o).trim()||null}function Lt(e,t){let n=t,o=e.replace(/\s+$/,"").length;for(;n<o&&/\s/.test(e[n]);)n++;let r=0,i=null;for(;n<o;n++){let s=e[n];if(s==="\\")n++;else if(i)s===i&&(i=null);else if(s==='"'||s==="'")i=s;else if(s==="["||s==="(")r++;else if(s==="]"||s===")")r>0&&r--;else if(r===0&&(s==="+"||s==="~"||/\s/.test(s)))return!1}return!0}var jt=/^codec\(([a-z][a-z0-9-]*)\)$/;function k(e){if(typeof e!="string")return null;let t=b(e);if(t===-1)return null;let n=jt.exec(e.slice(t+1));if(!n)return null;let{selector:o,all:r}=R(e);if(r)throw new C("A @codec(name) rule cannot use [*].");return{selector:o,name:n[1]}}var $t=/^--[A-Za-z0-9_-]+$/;function _(e){return typeof e=="string"&&$t.test(e)}function ze(e){let t=[],n=[],o=null,r=0;for(let i=0;i<e.length;i++){let s=e[i];if(o){s==="\\"?i++:s===o&&(o=null);continue}if(s==="/"&&e[i+1]==="*"){let c=e.indexOf("*/",i+2);i=c===-1?e.length:c+1;continue}s==='"'||s==="'"?o=s:s==="("?n.push(")"):s==="["?n.push("]"):s==="{"?n.push("}"):(s===")"||s==="]"||s==="}")&&n[n.length-1]===s?n.pop():s===";"&&n.length===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function _t(e){let t="",n=null;for(let o=0;o<e.length;o++){let r=e[o];if(n){t+=r,r==="\\"&&o+1<e.length?t+=e[++o]:r===n&&(n=null);continue}if(r==="/"&&e[o+1]==="*"){let i=e.indexOf("*/",o+2);o=i===-1?e.length:i+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function Fe(e){e=_t(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),o=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(o);return r&&(o=o.slice(0,r.index).trim()),{name:n,value:o,important:!!r}}function K(e,t){if(e==null)return null;let n=null;for(let o of ze(String(e))){let r=Fe(o);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function Ke(e,t,n){let o=e==null?"":String(e),r=n==null||n==="",i=ze(o),s=i.map(Fe),c=s.some(d=>d&&d.name===t&&d.important),l=[],p=!1;i.forEach((d,h)=>{let A=s[h];if(!A||A.name!==t){l.push(d);return}if(r||p)return;let f=/^\s*/.exec(d)[0];l.push(`${f}${t}: ${n}${c?" !important":""}`),p=!0});let u=l.join(";");if(!r&&!p){let d=u.trimEnd();u=d===""?`${t}: ${n}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${n}`}return u.trim()===""?null:u}function Se(e,t,n,o){let r=e.attr(t,"style");if((K(r,n)??"")===o)return;let i=Ke(r,n,o);i==null?e.removeAttr(t,"style"):e.attr(t,"style",i)}var Je=/^[a-z][a-z0-9-]*$/,be=new Map;function Re(e,t){if(typeof e!="string"||!Je.test(e))throw new Error(`hyper-html-api: invalid codec name ${JSON.stringify(e)} (must match ${Je})`);if(!t||typeof t.read!="function"||typeof t.write!="function"||typeof t.same!="function")throw new Error(`hyper-html-api: codec "${e}" needs read, write and same functions`);be.set(e,t)}function Ce(e){return be.get(e)??null}function Ne(){return Object.fromEntries(be)}var Dt='The @codec(name) rule form needs a rules tag with data-rules-version="2".',vt="A @codec(name) rule must be the value of a top level key.";function ce(e,t){let n=k(e);return n?{...n,codec:t.codecs[n.name]}:null}function H(e,t={}){let n=t.version??"1",o=t.codecs??{};r(e,0);function r(i,s){if(!(s>L)){if(typeof i=="string"){let c=k(i);if(!c)return;if(n!=="2")throw new C(Dt);if(s!==1)throw new C(vt);if(!Object.prototype.hasOwnProperty.call(o,c.name))throw new F(c.name);return}if(Array.isArray(i)){r(i[1],s+1);return}if(i&&typeof i=="object")for(let c of Object.values(i))r(c,s+1)}}}function P(e,t,n,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return H(n,o),Pe(e,t,n,{depth:0,path:[]},o)}function Pe(e,t,n,o,r){if(o.depth>L)throw new $(o.path);if(typeof n=="string")return Ut(e,t,n,o,r);if(Array.isArray(n)){let[i,s]=n,c=e.find(t,i,r);return Ye(r,o,c),c.map((l,p)=>Pe(e,l,s,{depth:o.depth+1,path:[...o.path,p]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[s,c]of Object.entries(n))i[s]=Pe(e,t,c,{depth:o.depth+1,path:[...o.path,s]},r);return i}return null}function Ut(e,t,n,o,r){if(n.endsWith("[]")){let u=n.slice(0,-2),d=e.find(t,u,r);return Ye(r,o,d),d.map(h=>e.text(h))}let i=ce(n,r);if(i)return Wt(e,t,i,r);if(n.startsWith("@"))return ke(e,t,n.slice(1));let s=b(n);if(s!==-1){let{selector:u,all:d}=R(n),h=n.slice(s+1),A=u?e.find(t,u,r):[t];return d&&r.allMatches?A.map(f=>ke(e,f,h)):A.length===0?null:ke(e,A[0],h)}if(n===".")return e.text(t);let{selector:c,all:l}=R(n),p=e.find(t,c,r);return l&&r.allMatches?p.map(u=>e.text(u)):p.length===0?null:e.text(p[0])}function Wt(e,t,{selector:n,codec:o},r){let i=n?e.find(t,n,r):[t];return i.length===0?null:o.read(e,i[0],{query:r.query,view:r.view,region:r.region})}function Ye(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function ke(e,t,n){if(_(n))return K(e.attr(t,"style"),n);if(re.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o??null}function Ze(e,t,n,o){let r=e.length,i=t.length,s=new Array(r).fill(-1);if(o){let a=new Set;for(let y=0;y<r;y++){let w=o[y];!(w>=0&&w<i)||a.has(w)||(s[y]=w,a.add(w))}}if(r===0||i===0)return s;let c=e.map(a=>Xe(a,n)),l=t.map(a=>Xe(a,n)),p=new Array(i).fill(!1);for(let a of s)a>=0&&(p[a]=!0);let u=new Map;l.forEach((a,y)=>{p[y]||u.set(a,u.has(a)?-1:y)});let d=new Map;c.forEach((a,y)=>{s[y]>=0||d.set(a,(d.get(a)||0)+1)}),c.forEach((a,y)=>{if(s[y]>=0||d.get(a)!==1)return;let w=u.get(a);w===void 0||w===-1||p[w]||(s[y]=w,p[w]=!0)});let h=[];for(let a=0;a<r;a++)s[a]<0&&h.push(a);let A=[];for(let a=0;a<i;a++)p[a]||A.push(a);if(h.length===0||A.length===0)return s;let f=r*i+1,m=Ht(e,t,n),g=(a,y)=>m(a,y)*f+Math.abs(a-y);for(let[a,y]of qt(h,A,g))s[a]=y;return s}var Qe=e=>typeof e=="object"&&e!==null;function Xe(e,t){if(!Qe(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function Ht(e,t,n){if(!Qe(n))return(c,l)=>e[c]===t[l]?0:1;let o=Object.keys(n),r=c=>o.map(l=>JSON.stringify(c?.[l])),i=e.map(r),s=t.map(r);return(c,l)=>{let p=i[c],u=s[l],d=0;for(let h=0;h<o.length;h++)p[h]!==u[h]&&d++;return d}}function qt(e,t,n){return e.length<=t.length?Ge(e,t,n,!1):Ge(t,e,(o,r)=>n(r,o),!0)}function Ge(e,t,n,o){let r=e.length,i=t.length,s=[];for(let d=0;d<=r;d++)s.push(new Float64Array(i+1).fill(1/0));let c=[];for(let d=0;d<=r;d++)c.push(new Uint8Array(i+1));for(let d=0;d<=i;d++)s[r][d]=0;for(let d=r-1;d>=0;d--)for(let h=i-1;h>=0;h--){let A=n(e[d],t[h])+s[d+1][h+1],f=s[d][h+1];A<=f?(s[d][h]=A,c[d][h]=1):s[d][h]=f}let l=[],p=0,u=0;for(;p<r&&u<i;)c[p][u]&&(l.push(o?[t[u],e[p]]:[e[p],t[u]]),p++),u++;return l}function Ie(e,t,n,o,r,i,s,c={}){let l=e.find(t,n,c);if(r.length===0){l.forEach(T=>e.remove(T)),Me(c,"onRowsApplied",i.path,[]);return}let p=r.length>l.length,u=l[0]||null;if(p&&!u&&(u=Ft(e,t,n,c),!u))throw new I(i.path);let d=l.map(T=>zt(e,T,o,c)),h=null;if(p&&u){h=e.clone(u),c.templateAttr&&e.removeAttr(h,c.templateAttr);let T=e.stripIds(h);T>0&&console.warn(`[hyper-html-api] stripped ${T} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let A=Ze(r,d,o,Vt(e,l,r,i,c)),f=l.length>0?e.parent(l[0]):Xt(e,t,n,u,i,c),m=l.length>0?ot(e,f,l[0]):0,g=Qt(e,l),a=new Set,y=[],w=r.map((T,S)=>{let x=A[S];if(x>=0)return a.add(x),y.push(!1),l[x];y.push(!0);let O=e.clone(h);return e.stripIds(O),O});l.forEach((T,S)=>{a.has(S)||e.remove(T)}),g?Zt(e,f,m,w,y):en(e,w,y,f,m),Bt(e,w,o,r,i,s,c),Me(c,"onRowsApplied",i.path,w)}function Me(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function Vt(e,t,n,o,r){let i=Me(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let s=new Array(n.length).fill(-1),c=new Set,l=new Map(t.map((p,u)=>[e.identity(p),u]));for(let p=0;p<n.length;p++){if(!i[p])continue;let u=l.get(e.identity(i[p]));u===void 0||c.has(u)||(s[p]=u,c.add(u))}return s}function Bt(e,t,n,o,r,i,s){t.forEach((c,l)=>{if(n===null){let p=o[l],u=p==null?"":String(p);e.text(c)!==u&&e.text(c,u)}else{let p=i(e,c,n,o[l],{depth:r.depth+1,path:[...r.path,l]},s);p&&p!==c&&(t[l]=p)}})}function zt(e,t,n,o){return n===null?e.text(t):P(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function ot(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function Ft(e,t,n,o){if(!o.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),i=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),s=n.replace(/^\s*:scope\s*>\s*/,"").replace(i,""),c=r?Kt(s):0,l=Ee(s),p=t;for(;p;){let u=e.find(p,s,{includeRulesTag:!1,templateAttr:null});for(let d of u)if(e.attr(d,o.templateAttr)!=null&&!(r&&!Yt(e,t,d,c))&&!(l&&!e.matches(e.parent(d),l)))return d;p=e.parent(p)}return null}function Kt(e){let t=0,n=null,o=1;for(let r=0;r<e.length;r++){let i=e[r];if(i==="\\")r++;else if(n)i===n&&(n=null);else if(i==='"'||i==="'")n=i;else if(i==="["||i==="(")t++;else if(i==="]"||i===")")t>0&&t--;else if(t===0&&i===">")o++;else{if(t===0&&(i==="+"||i==="~"))return null;if(t===0&&/\s/.test(i)){if(!Jt(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return o}function Jt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let o=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return et(o)||et(r)}function et(e){return e===">"||e==="+"||e==="~"}function Yt(e,t,n,o){if(o===null)return!0;let r=n;for(let l=0;l<o;l++)if(r=e.parent(r),!r)return!1;let i=e.prop(t,"tagName");if(!i)return!0;let s=e.prop(r,"tagName");if(!s||String(s).toLowerCase()!==String(i).toLowerCase())return!1;let c=new Set(tt(e,r));return tt(e,t).every(l=>c.has(l))}function tt(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Xt(e,t,n,o,r,i){let s=e.parent(o);if(s&&Gt(e,t,s)&&!rt(e,s,i))return s;let c=Ee(n);if(!c)throw new I(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let p=(c===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,c,i)).filter(u=>!rt(e,u,i));if(p.length===0)throw new I(r.path,`no container matching "${c}" inside this context to hold the new rows`);if(p.length>1)throw new I(r.path,`"${c}" matches ${p.length} containers inside this context, so the new rows have no single destination`);return p[0]}function Gt(e,t,n){let o=n;for(;o;){if(e.sameNode(o,t))return!0;o=e.parent(o)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var nt=["no-data","editor-ui"];function rt(e,t,n){let o=t;for(;o;){if(n.templateAttr&&e.attr(o,n.templateAttr)!=null||nt.some(i=>e.attr(o,i)!=null))return!0;let r=e.attr(o,"clay");if(r&&r.split(/\s+/).some(i=>nt.includes(i)))return!0;o=e.parent(o)}return!1}function Zt(e,t,n,o,r){let i=e.children(t),s=i.map(l=>e.identity(l)),c=!1;o.forEach((l,p)=>{let u=e.identity(l),d=n+p;if(s[d]===u)return;if(!r[p]){let A=s.indexOf(u);A!==-1&&(s.splice(A,1),i.splice(A,1))}let h=Math.min(d,i.length);h<i.length?e.insertBefore(i[h],l):i.length?c?e.insertAfter(i[i.length-1],l):(e.insertAt(t,l,d),c=!0):e.insertAt(t,l,0),s.splice(h,0,u),i.splice(h,0,l)})}function Qt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=new Map(e.children(n).map((i,s)=>[e.identity(i),s])),r=[];for(let i of t){let s=o.get(e.identity(i));if(s===void 0)return!1;r.push(s)}return r.sort((i,s)=>i-s),r[r.length-1]-r[0]===r.length-1}function en(e,t,n,o,r){let i=null,s=r;for(let c=0;c<t.length;c++){if(!n[c]){i=t[c];continue}let l=i?e.parent(i):o;if(!l)continue;let p=i?ot(e,l,i)+1:s++;e.insertAt(l,t[c],p),i=t[c]}}function D(e,t,n,o,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");H(n,r);let i=[];if(Le(n,o,[],i),i.length)throw new B(i);le(e,t,n,o,{depth:0,path:[]},r)}function le(e,t,n,o,r,i={}){if(r.depth>L)throw new $(r.path);if(o===void 0)return t;if(typeof n=="string")return tn(e,t,n,o,r,i);if(Array.isArray(n)){let[s,c]=n;return Ie(e,t,s,c,o,r,le,i),t}if(typeof n=="object"&&n!==null){for(let[s,c]of Object.entries(n)){let l=le(e,t,c,o==null?o:o[s],{depth:r.depth+1,path:[...r.path,s]},i);l&&l!==t&&(t=l)}return t}return t}function tn(e,t,n,o,r,i){if(n.endsWith("[]")){let d=n.slice(0,-2);return Ie(e,t,d,null,o,r,le,i),t}let s=ce(n,i);if(s){let d=s.selector?e.find(t,s.selector,i):[t];return d.length&&s.codec.write(e,d[0],o,{query:i.query}),t}if(n.startsWith("@"))return st(e,t,n.slice(1),o);let c=b(n);if(c!==-1){let{selector:d,all:h}=R(n),A=n.slice(c+1),f=d?e.find(t,d,i):[t];for(let m of h?f:f.slice(0,1))st(e,m,A,o);return t}if(n===".")return it(e,t,o),t;let{selector:l,all:p}=R(n),u=e.find(t,l,i);for(let d of p?u:u.slice(0,1))it(e,d,o);return t}function it(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function nn(e,t,n,o){if(e.styleVar){e.styleVar(t,n,o);return}Se(e,t,n,o)}function st(e,t,n,o){if(_(n))return nn(e,t,n,o==null?"":String(o).trim()),t;if(W.has(n)){let r=e.prop(t,n);if(r===o||r!=null&&o!=null&&String(r)===String(o))return t;throw new z(n)}if(n==="outerHTML"){let r=o==null?"":String(o);return e.replaceWith(t,r)}if(we.has(n)){let r=Ae(n,o);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(o==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(o);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function Le(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(k(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,i)=>{typeof r=="object"&&r!==null&&o.push({path:Y([...n,i]),expected:"scalar",got:J(r)})}):o.push({path:Y(n),expected:"array",got:J(t)});return}t!==null&&typeof t=="object"&&o.push({path:Y(n),expected:"scalar",got:J(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:Y(n),expected:"array",got:J(t)});return}let r=e[1];t.forEach((i,s)=>Le(r,i,[...n,s],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:Y(n),expected:"object",got:J(t)});return}for(let[r,i]of Object.entries(e))Le(i,t[r],[...n,r],o)}}}function J(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Y(e){return e.join(".")}function je(e){try{return JSON.parse(e)}catch(t){throw new C(`Invalid strict JSON: ${t.message}`,t)}}function v(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let i=[],s=0;for(;s<r.length;){let c=r[s];if(/\s/.test(c)){s++;continue}if("{}".includes(c)){i.push({type:c,value:c}),s++;continue}if(c==="["){let d=!1,h=s+1;for(;h<r.length&&/\s/.test(r[h]);)h++;if(h<r.length&&/[a-zA-Z_]/.test(r[h])&&(d=!0),!d){i.push({type:c,value:c}),s++;continue}}if(c==="]"){i.push({type:c,value:c}),s++;continue}if(c===":"){i.push({type:t.COLON,value:c}),s++;continue}if(c===","){i.push({type:t.COMMA,value:c}),s++;continue}if(c==='"'||c==="'"){let d=c,h=s+1;for(;h<r.length&&r[h]!==d;)r[h]==="\\"&&h++,h++;i.push({type:t.STRING,value:r.substring(s+1,h),quoted:!0,sourceQuote:d}),s=h+1;continue}let l=s,p;for(;l<r.length&&!/[{},]/.test(r[l]);)if(r[l]===":"){let d=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],h=!1;for(let A of d){let f=A.substring(1);if(r.substring(l+1,l+1+f.length)===f){h=!0,l+=f.length;break}}if(!h)break}else if(r[l]==="["){for(l++;l<r.length&&r[l]!=="]";){if(r[l]==='"'||r[l]==="'"){let d=r[l];for(l++;l<r.length&&r[l]!==d;)r[l]==="\\"&&l++,l++}l++}l<r.length&&r[l]==="]"&&l++}else l++;p=r.substring(s,l);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(p)?u=t.NUMBER:p==="true"||p==="false"||p==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(p)&&(u=t.SELECTOR),i.push({type:u,value:p,quoted:!1}),s=l}return i}function o(r){let i="";for(let s=0;s<r.length;s++){let c=r[s];if("{}".includes(c.type)||"[]".includes(c.type)){i+=c.value;continue}if(c.type===t.COLON){i+=c.value;continue}if(c.type===t.COMMA){let l=r[s+1];if(l&&(l.type==="}"||l.type==="]"))continue;i+=c.value;continue}if(c.type===t.STRING&&c.quoted){let l=c.value;c.sourceQuote==="'"&&(l=l.replace(/\\'/g,"'"),l=l.replace(/(\\*)"/g,(p,u)=>u.length%2===0?u+'\\"':p)),i+=`"${l}"`;continue}if(c.type===t.NUMBER||c.type===t.BOOLEAN){i+=c.value;continue}if(c.type===t.SELECTOR||c.type===t.IDENTIFIER){i+=`"${c.value}"`;continue}i+=`"${c.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new C("Invalid extraction rules syntax: "+r.message,r)}}var fe=["1","2"],ct=/^[a-zA-Z0-9_-]+$/;function X(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!ct.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${ct})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let i=r[0],s=e.attr(i,"data-rules-version");if(!fe.includes(s))throw new j(s);return{rules:v(e.text(i)),tagNode:i,version:s}}var ue=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),rn=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),lt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function G(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function $e(e,t){if(G(e,t))return!0;for(let[n,o]of Object.entries(rn))if(o.includes(t)&&G(e,n))return!0;return!1}function Z(e){let t=ue[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function on(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=ue[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>$e(n,r))||o.bundles.some(r=>G(n,r)))return n;n=n.parentElement}return null}function ft(e,t){return!!on(e,t)}var sn=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...lt],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})});function _e(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null,version:"1"};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return X(e,o,n)}return null}var un=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function an(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function ut(e,t,n,o){if(o)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function at(e,t,n,o,r,i){return(i?ft(e,t):ut(e,n,r,!1))||!!(o&&(i&&e!==r?e.matches(o):ut(e,o,r,i)))}function dn(e,t){let n=ue[t];return n.tokens.some(o=>$e(e,o))||n.bundles.some(o=>G(e,o))}var pn=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function dt(e,t,n,o){if(e.nodeType===1&&o(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,i=t;if(e.nodeType===1){if(pn.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,i=t.content,n.cloneToLive.set(i,r),n.liveToClone.set(r,i)}}else if(e.nodeType!==11)return;let s=i.firstChild;for(let c=r.firstChild;c&&s;c=c.nextSibling)dt(c,s,n,o),s=s.nextSibling}function Q(e,{capability:t="data",exclude:n=null,inherit:o=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let i=e.nodeType===9?e:e.ownerDocument;if(!i?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=i.implementation.createHTMLDocument(""),c=r||new WeakMap,l=new WeakMap,p=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let u=Z(t),d=o?f=>dn(f,t)||!!(n&&f.matches(n)):f=>at(f,t,u,n,p,!1),h=null;if(p.nodeType!==1||!at(p,t,u,n,p,o)){h=s.importNode(p,!0);let f={cloneToLive:c,liveToClone:l,dropped:[],controls:[]};dt(p,h,f,d);for(let m of f.dropped)m.remove();for(let m=0;m<f.controls.length;m+=2)an(f.controls[m],f.controls[m+1])}e.nodeType===9&&h&&(s.replaceChild(h,s.documentElement),l.set(e,s),c.set(s,e));let A=f=>{if(un.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:h,document:s,capability:t,selector:Z(t),cloneToLive:c,liveToClone:l,original(f){return c.get(f)||null},cloneOf(f){return l.get(f)||null},query(f,m=h){return A(f),Array.from(m.querySelectorAll(f),g=>c.get(g)||g)},text(f=h){return(f===h?h:l.get(f))?.textContent||""},html(f=h){return(f===h?h:l.get(f))?.innerHTML??""},clone(f=h){let m=f===h?h:l.get(f);return m?s.importNode(m,!0):null}}}function ht(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function hn(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function pt(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function mt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function yt(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let o=n.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var E={semanticExclude:!0,find(e,t,n={}){let o=hn(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(c=>!ht(c)));let i=[];n.skip&&i.push(n.skip);let s=n.templateAttr===null?null:n.templateAttr||"cms-template";if(s&&i.push("["+s+"]"),i.length){let c=i.join(", ");r=r.filter(l=>!l.closest||!l.closest(c))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,mt(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),pt(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),pt(e,t,null)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return yt(t),t},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function ee(e,t={}){if(t.exclude===null)return E;let n=[Z("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return E;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,s=e.nodeType===9?e:e.ownerDocument,c=null,l=()=>c||(c=Q(i,{capability:"data",exclude:t.exclude||null})),p=f=>{let m=l();return f===e?m.cloneOf(e):m.cloneOf(f)||f},u=f=>c?.original(f)||f,d=(f,m)=>{l().liveToClone.set(f,m),l().cloneToLive.set(m,f);let g=f.childNodes||[],a=m.childNodes||[];for(let y=0;y<Math.min(g.length,a.length);y++)d(g[y],a[y])},h=(f,m,g,a)=>{let y=Array.from(f.childNodes).filter(O=>c.cloneOf(O)),T=y[0];for(;T&&y.includes(T);)T=T.nextSibling;for(let O of y)O.remove();if(g==="innerHTML"){let O=s.createElement("template");O.innerHTML=a;for(let V of Array.from(O.content.childNodes))f.insertBefore(V,T||null)}else f.insertBefore(s.createTextNode(a),T||null),mt(f,a);let S=Q(f,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(S.root?.childNodes||[]));let x=O=>{let V=S.original(O);V&&(c.liveToClone.set(V,O),c.cloneToLive.set(O,V));for(let Rt of Array.from(O.childNodes||[]))x(Rt)};for(let O of Array.from(m.childNodes))x(O)},A={...E,find(f,m,g={}){let a=p(f);if(!a?.querySelectorAll)return[];let y=l().query(m,a);g.includeRulesTag||(y=y.filter(S=>!ht(S)));let w=[];g.skip&&w.push(g.skip);let T=g.templateAttr===null?null:g.templateAttr||"cms-template";if(T&&w.push(`[${T}]`),w.length){let S=w.join(", ");y=y.filter(x=>!x.closest?.(S))}return y},parent(f){let m=p(f)?.parentElement;return m?u(m):null},children(f){return Array.from(p(f)?.children||[],u)},text(f,m){if(m===void 0){let y=u(f);return!y?.matches?.(n)&&!y?.querySelector?.(n)?E.text(y):(p(f)?.textContent||"").trim()}let g=u(f);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!c){E.text(g,m);return}let a=l().cloneOf(g);a?h(g,a,"textContent",m):E.text(g,m)},attr(f,m,g){let a=u(f);if(g===void 0)return E.attr(a,m);E.attr(a,m,g);let y=c?.cloneOf(a);y&&(E.attr(y,m,g),Q(a,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),c.liveToClone.delete(a),c.cloneToLive.delete(y)))},removeAttr(f,m){let g=u(f);E.removeAttr(g,m);let a=c?.cloneOf(g);a&&E.removeAttr(a,m)},prop(f,m,g){let a=u(f);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?E.prop(p(a),m):E.prop(a,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",w=y?l().cloneOf(a):c?.cloneOf(a);w&&y?h(a,w,m,g):(E.prop(a,m,g),w&&E.prop(w,m,g))},clone(f){let m=p(f);if(m===f)return E.clone(f);let g=s.importNode(m,!0);return yt(g),g},insertAt(f,m,g){let a=u(f),w=A.children(a)[g]||(()=>{for(let x=a.children.length-1;x>=0;x--){let O=a.children[x];if(l().cloneOf(O))return O.nextElementSibling}return a.firstElementChild})(),T=u(m);a.insertBefore(T,w||null);let S=l().cloneOf(a);if(S){let x=l().cloneOf(T);x||(x=s.importNode(T,!0),d(T,x));let O=Array.from(S.children);S.insertBefore(x,O[g]||null)}},insertBefore(f,m){let g=u(f),a=u(m);g.parentNode.insertBefore(a,g);let y=l().cloneOf(g.parentNode);if(y){let w=l().cloneOf(a);w||(w=s.importNode(a,!0),d(a,w));let T=l().cloneOf(g);T?T.before(w):y.appendChild(w)}},insertAfter(f,m){let g=u(f),a=u(m);g.parentNode.insertBefore(a,g.nextSibling);let y=l().cloneOf(g.parentNode);if(y){let w=l().cloneOf(a);w||(w=s.importNode(a,!0),d(a,w));let T=l().cloneOf(g);T?T.after(w):y.appendChild(w)}},identity(f){return u(f)||null},remove(f){let m=u(f),g=l().cloneOf(m);E.remove(m),g&&E.remove(g)},replaceWith(f,m){let g=u(f),a=l().cloneOf(g),y=E.replaceWith(g,m);if(a){let w=Q(y,{capability:"data",exclude:t.exclude||null});if(!w.root)a.remove();else{a.replaceWith(w.root);let T=S=>{let x=w.original(S);x&&(c.liveToClone.set(x,S),c.cloneToLive.set(S,x));for(let O of Array.from(S.childNodes||[]))T(O)};T(w.root)}}return y}};return A}var N=E;var De=e=>({codecs:Ne(),...e}),ve={extract:(e,t,n={})=>P(ee(e,n),e,t,De(n)),apply:(e,t,n,o={})=>D(ee(e,{...o,_write:!0}),e,t,n,De(o)),findRulesIn:(e,t)=>X(N,e,t),findRules:(e,t)=>_e(N,e,t),bind:(e,t,n={})=>{let o=_e(N,e,t);if(!o){let i=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${i}`)}let r=De({version:o.version,...n});return{...o,get:()=>P(ee(e,n),e,o.rules,r),set:i=>D(ee(e,{...n,_write:!0}),e,o.rules,i,r)}},codecs:{register:Re,get:Ce},parseStrict:je,parseRelaxed:v,ruleAttrIndex:b,splitRule:R,errors:se,DOM_PROPERTIES:ne};var mn="hha:upgrade-check:";function M(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function gt(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function yn(e,t){let n=gt(e),o=gt(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let i=0;i<r;i++){let s=n[i]||0,c=o[i]||0;if(s!==c)return s>c}return!1}function gn(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function wn(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function wt({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:i=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(h=>fetch(h)),r=r??Date.now(),!t)return null;let s=M(t,"hyper-source");if(!s)return null;let c=M(t,"hyper-version"),l;try{l=new URL(s,n?n.href:void 0)}catch{return null}if(n&&l.origin===n.origin&&l.pathname===n.pathname)return null;let p=`${mn}${l.href}:${c||"none"}`,u,d=e?null:gn(p);if(d&&typeof d.checkedAt=="number"&&r-d.checkedAt<i)u=d.sourceVersion;else{try{let h=await o(l.href);if(!h.ok)throw new Error(`HTTP ${h.status}`);let A=await h.text(),f=new DOMParser().parseFromString(A,"text/html");u=M(f,"hyper-version")}catch{u=null}wn(p,{checkedAt:r,sourceVersion:u})}return u?{available:yn(u,c||"0.0.0"),currentVersion:c,sourceVersion:u,sourceUrl:l.href}:null}var An="script[data-rules-name]";function Tn(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ae(e,t){let n=e.find(t,An,{includeRulesTag:!0}),o=new Set,r=[];for(let i of n){let s=Tn(e.attr(i,"data-rules-name"));if(!s)continue;if(o.has(s)){console.warn(`hyper-html-api: duplicate rules tag name "${s}"; using the first.`);continue}let c=e.attr(i,"data-rules-version");if(!fe.includes(c))throw new j(c);o.add(s),r.push({name:s,rules:v(e.text(i)),version:c})}return r}function de(e,t){if(t!=="2"||!e||typeof e!="object"||Array.isArray(e))return{rules:e,carried:[]};let n={},o=[];for(let[r,i]of Object.entries(e)){let s=k(i);s?o.push({key:r,selector:s.selector}):n[r]=i}return{rules:n,carried:o}}function pe(e,t,n){return e.find(t,n)[0]||null}function Ue(e,t){let n={};for(let{name:o,rules:r,version:i}of ae(e,t)){let{rules:s,carried:c}=de(r,i),l=P(e,t,s,{version:i});for(let{key:p,selector:u}of c){let d=pe(e,t,u);l[p]=d?e.prop(d,"innerHTML"):null}n[o]=l}return n}function At(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Ue(N,t),version:M(n,"hyper-version")}}var te=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},he=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},U=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},me=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var On="text/hyper-upgrade";function Tt(e,t){let n=e.find(t,`script[type="${On}"]`);if(n.length===0)return null;if(n.length>1)throw new me(n.length);return e.text(n[0])||null}var xn=new Function("url","return import(url)");async function Ot(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await xn(n)}catch(r){throw new U(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new U("transform must `export default` a function");return o.default}function ye(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=We(t,e,n);return He(t,e,n),{data:o,summary:n}}function We(e,t,n,o=!1){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):o?[]:void 0:t==null||typeof t=="object"?o&&!En(e)?null:void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,r]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(i=>We(r,i,n,!0))):o?[]:void 0}if(typeof e=="object"&&e!==null){let r={};for(let[i,s]of Object.entries(e)){let c=We(s,t?.[i],n,o);c!==void 0&&(r[i]=c)}return r}}function En(e){let t=b(e);return t!==-1&&W.has(e.slice(t+1))}function He(e,t,n){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let o=new Set(Object.keys(e));for(let r of Object.keys(t))o.has(r)?He(e[r],t[r],n):n.discarded+=q(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>He(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=q(t))}}function q(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+q(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+q(n),0):1}function xt(e,t,n){let o=ae(e,t),r={carriedOver:0,discarded:0,listItems:0},i={},s=new Set;for(let{name:c,rules:l,version:p}of o){if(s.add(c),!Object.prototype.hasOwnProperty.call(n,c)){i[c]={carriedOver:0,discarded:0,listItems:0};continue}let{rules:u,carried:d}=de(l,p),h=n[c],{data:A,summary:f}=ye(Sn(h,d),u);D(e,t,u,A,{templateAttr:"cms-template"});for(let{key:m,selector:g}of d){let a=Et(h)?h[m]:void 0;if(a==null)continue;let y=pe(e,t,g);typeof a=="string"&&y?(e.prop(y,"innerHTML",a),f.carriedOver+=1):f.discarded+=1}i[c]=f,r.carriedOver+=f.carriedOver,r.discarded+=f.discarded,r.listItems+=f.listItems}for(let c of Object.keys(n))s.has(c)||(r.discarded+=q(n[c]));return{totals:r,byName:i,rulesTagCount:o.length}}function Et(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Sn(e,t){if(!t.length||!Et(e))return e;let n={...e};for(let{key:o}of t)delete n[o];return n}async function St({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:i}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),i=i||(a=>fetch(a)),!o)throw new Error("upgrade.run requires a document context");if(e=e||M(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let s=new URL(e,r?r.href:void 0);n=n!==void 0?n:M(o,"hyper-version"),t=t||Ue(N,o);let c;try{c=await i(s.href)}catch(a){throw new te(s.href,a)}if(!c.ok)throw new te(s.href,new Error(`HTTP ${c.status}`));let l=await c.text(),p=new DOMParser().parseFromString(l,"text/html"),u=M(p,"hyper-version"),d=t,h=!1,A=Tt(N,p);if(A){let y=await(await Ot(A))(d,{fromVersion:n,toVersion:u});if(!y||typeof y!="object"||Array.isArray(y))throw new U("transform must return a plain object map of { rulesName: data }");d=y,h=!0}let{totals:f,byName:m,rulesTagCount:g}=xt(N,p,d);if(g===0&&Object.keys(d).length>0)throw new he(s.href);return{html:Rn(p),fromVersion:n,toVersion:u,summary:{transformApplied:h,totals:f,byName:m}}}function bn(e){for(let t of e.querySelectorAll("input")){let n=(t.getAttribute("type")||"").toLowerCase();n!=="file"&&(n==="checkbox"||n==="radio"?t.checked!==t.hasAttribute("checked")&&t.toggleAttribute("checked",t.checked):t.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",t.value))}for(let t of e.querySelectorAll("textarea"))t.value!==t.textContent&&(t.textContent=t.value);for(let t of e.querySelectorAll("select")){let n=[...t.options];if(!t.multiple){let o=n.findIndex(r=>r.hasAttribute("selected"));if(t.selectedIndex===o||o===-1&&t.selectedIndex<=0)continue}for(let o of n)o.selected!==o.hasAttribute("selected")&&o.toggleAttribute("selected",o.selected)}}function Rn(e){return bn(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
2
|
+
`+e.documentElement.outerHTML}var bt={checkForUpdate:wt,run:St,extractAll:At,shapeMatch:ye};var Cn={engine:ve,upgrade:bt},Nn=Cn;return Mt(kn);})();
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"apply",
|
|
10
10
|
"CMS"
|
|
11
11
|
],
|
|
12
|
-
"version": "0.
|
|
12
|
+
"version": "0.15.0",
|
|
13
13
|
"homepage": "https://github.com/panphora/hyper-html-api",
|
|
14
14
|
"bugs": {
|
|
15
15
|
"url": "https://github.com/panphora/hyper-html-api/issues"
|
|
@@ -35,7 +35,10 @@
|
|
|
35
35
|
"./data": "./src/data.js",
|
|
36
36
|
"./upgrade": "./src/upgrade.js",
|
|
37
37
|
"./page": "./src/page.js",
|
|
38
|
-
"./write": "./src/write.js"
|
|
38
|
+
"./write": "./src/write.js",
|
|
39
|
+
"./site": "./src/site.js",
|
|
40
|
+
"./codecs/sheet": "./src/codecs/sheet.js",
|
|
41
|
+
"./read": "./src/read.js"
|
|
39
42
|
},
|
|
40
43
|
"scripts": {
|
|
41
44
|
"build": "npx esbuild src/hyper-html-api.js --bundle --minify --format=iife --global-name=HyperHtmlApi --outfile=dist/hyper-html-api.min.js && npm run build:engine && npm run build:engine:esm",
|
|
@@ -68,7 +71,7 @@
|
|
|
68
71
|
"hyper-morph": "^1.7.0"
|
|
69
72
|
},
|
|
70
73
|
"devDependencies": {
|
|
71
|
-
"@panphora/clayjs": "^1.
|
|
74
|
+
"@panphora/clayjs": "^1.24.0",
|
|
72
75
|
"@web/test-runner": "^0.20.0",
|
|
73
76
|
"@web/test-runner-playwright": "^0.11.0",
|
|
74
77
|
"chai": "^4.3.6",
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// The sheet codec as the engine sees it, for the rule "[items=sheets]@codec(sheet)".
|
|
2
|
+
// The rule selects the tabs container. Each tab is a <section item data-id> holding
|
|
3
|
+
// an <h2 bind="name"> and one <table grid> (sapjs/src/grid/codec/GRAMMAR.md).
|
|
4
|
+
//
|
|
5
|
+
// A read takes a table's canonical bytes from ctx.region(table) when a host cut
|
|
6
|
+
// them out of the source (the fast route, readDocument), and otherwise reads the
|
|
7
|
+
// table the HTML parser built (the tree route). Both give the same model.
|
|
8
|
+
//
|
|
9
|
+
// Query shapes (ctx.query):
|
|
10
|
+
// none -> [{ id, name, cols, rows, stale? }] every tab
|
|
11
|
+
// { shape: 'index' } -> [{ id, name, rows, cols, frozenRows }]
|
|
12
|
+
// { sheet } -> { id, name, cols, rows, stale? } one tab
|
|
13
|
+
// { sheet?, range, render? } -> { sheet, range, values } or { sheet, range, cols, rows }
|
|
14
|
+
// ctx.view === 'digest' -> [{ id, name, cols, rows }] for the data loss guard:
|
|
15
|
+
// cols names the column behind each row digest's mask bits
|
|
16
|
+
// `sheet` matches a tab's name first, then its id; a range with no sheet reads the first tab.
|
|
17
|
+
|
|
18
|
+
import { CodecRefused } from '../engine/errors.js'
|
|
19
|
+
import {
|
|
20
|
+
QueryRefused,
|
|
21
|
+
STYLE_PROPERTIES,
|
|
22
|
+
cutGrids,
|
|
23
|
+
gridModel,
|
|
24
|
+
readRange,
|
|
25
|
+
tabIndex,
|
|
26
|
+
tabDigest,
|
|
27
|
+
tabJson,
|
|
28
|
+
treeModel,
|
|
29
|
+
} from './sheet.vendor.js'
|
|
30
|
+
|
|
31
|
+
const TAGS = ['table', 'colgroup', 'col', 'thead', 'tbody', 'tfoot', 'tr', 'td', 'th', 'caption']
|
|
32
|
+
|
|
33
|
+
// The engine adapter as the codec's tree route wants it. Text is textContent,
|
|
34
|
+
// never the engine's trimmed text(), because a cell's text is never trimmed.
|
|
35
|
+
export function treeAdapter(adapter) {
|
|
36
|
+
return {
|
|
37
|
+
name: (node) => TAGS.find((tag) => adapter.matches(node, tag)) ?? '',
|
|
38
|
+
attr: (node, name) => adapter.attr(node, name) ?? null,
|
|
39
|
+
children: (node) => adapter.children(node),
|
|
40
|
+
text: (node) => String(adapter.prop(node, 'textContent') ?? ''),
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const childMatching = (adapter, node, selector) => adapter.children(node).find((child) => adapter.matches(child, selector))
|
|
45
|
+
|
|
46
|
+
// Each tab under the container: { id, name, table } (table is null when the
|
|
47
|
+
// section has none). Shared by reads and by patchDocument.
|
|
48
|
+
export function tabNodes(adapter, node) {
|
|
49
|
+
const tree = treeAdapter(adapter)
|
|
50
|
+
return adapter.children(node)
|
|
51
|
+
.filter((child) => adapter.matches(child, 'section[item]'))
|
|
52
|
+
.map((section) => {
|
|
53
|
+
const heading = childMatching(adapter, section, 'h2[bind="name"]')
|
|
54
|
+
return {
|
|
55
|
+
id: adapter.attr(section, 'data-id') ?? '',
|
|
56
|
+
name: heading ? tree.text(heading) : '',
|
|
57
|
+
table: childMatching(adapter, section, 'table[grid]') ?? null,
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function tabsOf(adapter, node, ctx) {
|
|
63
|
+
const tree = treeAdapter(adapter)
|
|
64
|
+
return tabNodes(adapter, node).map(({ id, name, table }) => {
|
|
65
|
+
const bytes = table && typeof ctx.region === 'function' ? ctx.region(table) : null
|
|
66
|
+
const sheet = bytes != null ? gridModel(bytes, 0) : table ? treeModel(tree, table) : { cols: [], rows: [] }
|
|
67
|
+
return { id, name, sheet }
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// The tab a query or a patch names: by name first, then by id; no name means the first tab.
|
|
72
|
+
export function pickTab(tabs, wanted) {
|
|
73
|
+
if (wanted === undefined) {
|
|
74
|
+
if (tabs.length === 0) throw new QueryRefused('unknown_sheet', 'this document has no sheets')
|
|
75
|
+
return tabs[0]
|
|
76
|
+
}
|
|
77
|
+
const tab = tabs.find((t) => t.name === wanted) ?? tabs.find((t) => t.id === wanted)
|
|
78
|
+
if (!tab) throw new QueryRefused('unknown_sheet', `no sheet named ${JSON.stringify(wanted)}; ask for shape=index to list them`)
|
|
79
|
+
return tab
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function read(adapter, node, ctx = {}) {
|
|
83
|
+
const tabs = tabsOf(adapter, node, ctx)
|
|
84
|
+
const query = ctx.query ?? {}
|
|
85
|
+
if (ctx.view === 'digest') return tabs.map(({ id, name, sheet }) => ({ id, name, ...tabDigest(sheet) }))
|
|
86
|
+
if (query.shape !== undefined && query.shape !== 'index') {
|
|
87
|
+
throw new QueryRefused('bad_shape', `unknown shape ${JSON.stringify(query.shape)}; the only shape is index`)
|
|
88
|
+
}
|
|
89
|
+
if (query.render !== undefined && query.range === undefined) {
|
|
90
|
+
throw new QueryRefused('bad_render', 'render needs a range, for example range=A1:C10&render=formulas')
|
|
91
|
+
}
|
|
92
|
+
if (query.shape === 'index') return tabs.map(({ id, name, sheet }) => ({ id, name, ...tabIndex(sheet) }))
|
|
93
|
+
if (query.range !== undefined) {
|
|
94
|
+
const tab = pickTab(tabs, query.sheet)
|
|
95
|
+
return { sheet: tab.name, range: query.range, ...readRange(tab.sheet, query.range, query.render ?? 'values') }
|
|
96
|
+
}
|
|
97
|
+
if (query.sheet !== undefined) {
|
|
98
|
+
const { id, name, sheet } = pickTab(tabs, query.sheet)
|
|
99
|
+
return { id, name, ...tabJson(sheet) }
|
|
100
|
+
}
|
|
101
|
+
return tabs.map(({ id, name, sheet }) => ({ id, name, ...tabJson(sheet) }))
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const WRITE_UNAVAILABLE_MESSAGE =
|
|
105
|
+
'A sheet cannot be replaced as a whole value yet: send patch operations instead, for example [{ "sheet": "Budget", "range": "B3", "values": [[450]] }].'
|
|
106
|
+
|
|
107
|
+
// Whole replace is a follow-up with its own spec (whether a missing tab is
|
|
108
|
+
// deleted changes user data). Hosts answer this refusal with 409.
|
|
109
|
+
function write() {
|
|
110
|
+
throw new CodecRefused('sheet-write-unavailable', WRITE_UNAVAILABLE_MESSAGE)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function same(written, reread) {
|
|
114
|
+
return JSON.stringify(written) === JSON.stringify(reread)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const sheet = {
|
|
118
|
+
name: 'sheet',
|
|
119
|
+
read,
|
|
120
|
+
write,
|
|
121
|
+
same,
|
|
122
|
+
styles: STYLE_PROPERTIES,
|
|
123
|
+
cut: cutGrids,
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { QueryRefused }
|
|
127
|
+
export * as grid from './sheet.vendor.js'
|