@aglyn/aglyn 1.0.0-beta.220 → 1.0.0-beta.222
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/package.json +15 -11
- package/src/lib/app-utils/agent-openapi.js +1 -1
- package/src/lib/app-utils/agent-openapi.js.map +1 -1
- package/src/lib/app-utils/analytics-events.d.ts +3 -2
- package/src/lib/app-utils/analytics-events.js +3 -2
- package/src/lib/app-utils/analytics-events.js.map +1 -1
- package/src/lib/app-utils/api-plugins.d.ts +30 -0
- package/src/lib/app-utils/api-plugins.js +24 -1
- package/src/lib/app-utils/api-plugins.js.map +1 -1
- package/src/lib/app-utils/author-html.d.ts +1 -1
- package/src/lib/app-utils/author-html.js.map +1 -1
- package/src/lib/app-utils/bandwidth-cap.d.ts +12 -1
- package/src/lib/app-utils/bandwidth-cap.js +17 -1
- package/src/lib/app-utils/bandwidth-cap.js.map +1 -1
- package/src/lib/app-utils/compose-reusable-components.d.ts +19 -0
- package/src/lib/app-utils/compose-reusable-components.js +116 -26
- package/src/lib/app-utils/compose-reusable-components.js.map +1 -1
- package/src/lib/app-utils/console-routes.d.ts +4 -0
- package/src/lib/app-utils/console-routes.js +3 -0
- package/src/lib/app-utils/console-routes.js.map +1 -1
- package/src/lib/app-utils/contacts.d.ts +71 -0
- package/src/lib/app-utils/contacts.js +55 -0
- package/src/lib/app-utils/contacts.js.map +1 -1
- package/src/lib/app-utils/contexts.d.ts +1 -0
- package/src/lib/app-utils/contexts.js +1 -0
- package/src/lib/app-utils/contexts.js.map +1 -1
- package/src/lib/app-utils/crm-email-templates.js +21 -4
- package/src/lib/app-utils/crm-email-templates.js.map +1 -1
- package/src/lib/app-utils/crm-kinds.d.ts +2 -0
- package/src/lib/app-utils/crm-kinds.js +1 -0
- package/src/lib/app-utils/crm-kinds.js.map +1 -1
- package/src/lib/app-utils/crm.d.ts +1199 -67
- package/src/lib/app-utils/crm.js +1951 -310
- package/src/lib/app-utils/crm.js.map +1 -1
- package/src/lib/app-utils/csv-import.d.ts +10 -38
- package/src/lib/app-utils/csv-import.js +17 -42
- package/src/lib/app-utils/csv-import.js.map +1 -1
- package/src/lib/app-utils/csv.d.ts +32 -11
- package/src/lib/app-utils/csv.js +43 -5
- package/src/lib/app-utils/csv.js.map +1 -1
- package/src/lib/app-utils/default-site.d.ts +116 -0
- package/src/lib/app-utils/default-site.js +1024 -0
- package/src/lib/app-utils/default-site.js.map +1 -0
- package/src/lib/app-utils/docs-help.generated.d.ts +23 -23
- package/src/lib/app-utils/docs-help.generated.js +47 -10
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +746 -151
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/draft-placeholders.d.ts +76 -0
- package/src/lib/app-utils/draft-placeholders.js +115 -0
- package/src/lib/app-utils/draft-placeholders.js.map +1 -0
- package/src/lib/app-utils/entity-picker-context.d.ts +19 -15
- package/src/lib/app-utils/entity-picker-context.js +4 -4
- package/src/lib/app-utils/entity-picker-context.js.map +1 -1
- package/src/lib/app-utils/expand-repeatables.d.ts +66 -10
- package/src/lib/app-utils/expand-repeatables.js +88 -14
- package/src/lib/app-utils/expand-repeatables.js.map +1 -1
- package/src/lib/app-utils/forms.d.ts +33 -22
- package/src/lib/app-utils/forms.js +47 -28
- package/src/lib/app-utils/forms.js.map +1 -1
- package/src/lib/app-utils/full-use-cost.d.ts +277 -0
- package/src/lib/app-utils/full-use-cost.js +421 -0
- package/src/lib/app-utils/full-use-cost.js.map +1 -0
- package/src/lib/app-utils/health-report.js +33 -0
- package/src/lib/app-utils/health-report.js.map +1 -1
- package/src/lib/app-utils/leaving-notice.d.ts +96 -0
- package/src/lib/app-utils/leaving-notice.js +157 -0
- package/src/lib/app-utils/leaving-notice.js.map +1 -0
- package/src/lib/app-utils/llms-txt.d.ts +20 -0
- package/src/lib/app-utils/llms-txt.js +7 -1
- package/src/lib/app-utils/llms-txt.js.map +1 -1
- package/src/lib/app-utils/media-asset-facts.d.ts +16 -1
- package/src/lib/app-utils/media-asset-facts.js +40 -13
- package/src/lib/app-utils/media-asset-facts.js.map +1 -1
- package/src/lib/app-utils/media-bandwidth.d.ts +52 -0
- package/src/lib/app-utils/media-bandwidth.js +94 -0
- package/src/lib/app-utils/media-bandwidth.js.map +1 -0
- package/src/lib/app-utils/media-ref.d.ts +241 -33
- package/src/lib/app-utils/media-ref.js +324 -43
- package/src/lib/app-utils/media-ref.js.map +1 -1
- package/src/lib/app-utils/media-src.d.ts +8 -8
- package/src/lib/app-utils/media-src.js +27 -11
- package/src/lib/app-utils/media-src.js.map +1 -1
- package/src/lib/app-utils/media-takedown-reach.d.ts +4 -1
- package/src/lib/app-utils/media-takedown-reach.js +6 -3
- package/src/lib/app-utils/media-takedown-reach.js.map +1 -1
- package/src/lib/app-utils/notifications.d.ts +1 -1
- package/src/lib/app-utils/notifications.js +2 -0
- package/src/lib/app-utils/notifications.js.map +1 -1
- package/src/lib/app-utils/operator-alerts.js +17 -0
- package/src/lib/app-utils/operator-alerts.js.map +1 -1
- package/src/lib/app-utils/organizations.d.ts +51 -2
- package/src/lib/app-utils/organizations.js +56 -3
- package/src/lib/app-utils/organizations.js.map +1 -1
- package/src/lib/app-utils/page-record-sources.d.ts +87 -0
- package/src/lib/app-utils/page-record-sources.js +53 -0
- package/src/lib/app-utils/page-record-sources.js.map +1 -0
- package/src/lib/app-utils/paid-media-source.d.ts +3 -7
- package/src/lib/app-utils/paid-media-source.js +5 -19
- package/src/lib/app-utils/paid-media-source.js.map +1 -1
- package/src/lib/app-utils/person-erasure.d.ts +5 -2
- package/src/lib/app-utils/person-erasure.js.map +1 -1
- package/src/lib/app-utils/picklists.d.ts +187 -0
- package/src/lib/app-utils/picklists.js +320 -0
- package/src/lib/app-utils/picklists.js.map +1 -0
- package/src/lib/app-utils/plan-entitlements.d.ts +220 -50
- package/src/lib/app-utils/plan-entitlements.js +309 -115
- package/src/lib/app-utils/plan-entitlements.js.map +1 -1
- package/src/lib/app-utils/realm-host-surface.generated.js +2 -0
- package/src/lib/app-utils/realm-host-surface.generated.js.map +1 -1
- package/src/lib/app-utils/release-flags.d.ts +1 -1
- package/src/lib/app-utils/release-flags.js +11 -0
- package/src/lib/app-utils/release-flags.js.map +1 -1
- package/src/lib/app-utils/rendered-widths.d.ts +121 -0
- package/src/lib/app-utils/rendered-widths.js +211 -0
- package/src/lib/app-utils/rendered-widths.js.map +1 -0
- package/src/lib/app-utils/repeat-sources.d.ts +2 -1
- package/src/lib/app-utils/repeat-sources.js.map +1 -1
- package/src/lib/app-utils/screen-link-context-value.d.ts +7 -0
- package/src/lib/app-utils/screen-link-context-value.js.map +1 -1
- package/src/lib/app-utils/screen-link-context.js +14 -2
- package/src/lib/app-utils/screen-link-context.js.map +1 -1
- package/src/lib/app-utils/screen-route.d.ts +157 -36
- package/src/lib/app-utils/screen-route.js +191 -41
- package/src/lib/app-utils/screen-route.js.map +1 -1
- package/src/lib/app-utils/seo-audit.d.ts +11 -1
- package/src/lib/app-utils/seo-audit.js +33 -13
- package/src/lib/app-utils/seo-audit.js.map +1 -1
- package/src/lib/app-utils/seo-keywords.d.ts +11 -0
- package/src/lib/app-utils/seo-keywords.js +19 -5
- package/src/lib/app-utils/seo-keywords.js.map +1 -1
- package/src/lib/app-utils/seo-page-facts.d.ts +47 -4
- package/src/lib/app-utils/seo-page-facts.js +136 -31
- package/src/lib/app-utils/seo-page-facts.js.map +1 -1
- package/src/lib/app-utils/seo-site-scan.d.ts +42 -4
- package/src/lib/app-utils/seo-site-scan.js +113 -12
- package/src/lib/app-utils/seo-site-scan.js.map +1 -1
- package/src/lib/app-utils/server.d.ts +5 -4
- package/src/lib/app-utils/server.js +14 -5
- package/src/lib/app-utils/server.js.map +1 -1
- package/src/lib/app-utils/site-icon-set.d.ts +195 -0
- package/src/lib/app-utils/site-icon-set.js +351 -0
- package/src/lib/app-utils/site-icon-set.js.map +1 -0
- package/src/lib/app-utils/site-interactions.d.ts +101 -4
- package/src/lib/app-utils/site-interactions.js +120 -4
- package/src/lib/app-utils/site-interactions.js.map +1 -1
- package/src/lib/app-utils/starter-template-nodes.d.ts +7 -0
- package/src/lib/app-utils/starter-template-nodes.js +3 -0
- package/src/lib/app-utils/starter-template-nodes.js.map +1 -1
- package/src/lib/app-utils/starter-templates.d.ts +5 -19
- package/src/lib/app-utils/starter-templates.js +5 -49
- package/src/lib/app-utils/starter-templates.js.map +1 -1
- package/src/lib/app-utils/transfer-launcher-context.d.ts +136 -0
- package/src/lib/app-utils/transfer-launcher-context.js +23 -0
- package/src/lib/app-utils/transfer-launcher-context.js.map +1 -0
- package/src/lib/app-utils/transfer-resume-import.d.ts +39 -0
- package/src/lib/app-utils/transfer-resume-import.js +128 -0
- package/src/lib/app-utils/transfer-resume-import.js.map +1 -0
- package/src/lib/app-utils/upgrade-proposal.d.ts +66 -0
- package/src/lib/app-utils/upgrade-proposal.js +95 -0
- package/src/lib/app-utils/upgrade-proposal.js.map +1 -0
- package/src/lib/app-utils/utc-month.d.ts +33 -0
- package/src/lib/app-utils/utc-month.js +35 -0
- package/src/lib/app-utils/utc-month.js.map +1 -0
- package/src/lib/app-utils/visitor-record-ceiling.d.ts +4 -4
- package/src/lib/app-utils/visitor-record-ceiling.js +4 -4
- package/src/lib/app-utils/visitor-record-ceiling.js.map +1 -1
- package/src/lib/app-utils/wire-nodes.d.ts +39 -19
- package/src/lib/app-utils/wire-nodes.js +120 -34
- package/src/lib/app-utils/wire-nodes.js.map +1 -1
- package/src/lib/data-transfer/access.d.ts +74 -0
- package/src/lib/data-transfer/access.js +93 -0
- package/src/lib/data-transfer/access.js.map +1 -0
- package/src/lib/data-transfer/derive.d.ts +246 -0
- package/src/lib/data-transfer/derive.js +1007 -0
- package/src/lib/data-transfer/derive.js.map +1 -0
- package/src/lib/data-transfer/export-file.d.ts +46 -0
- package/src/lib/data-transfer/export-file.js +146 -0
- package/src/lib/data-transfer/export-file.js.map +1 -0
- package/src/lib/data-transfer/field-catalog.d.ts +134 -0
- package/src/lib/data-transfer/field-catalog.js +278 -0
- package/src/lib/data-transfer/field-catalog.js.map +1 -0
- package/src/lib/data-transfer/header-match.d.ts +129 -0
- package/src/lib/data-transfer/header-match.js +367 -0
- package/src/lib/data-transfer/header-match.js.map +1 -0
- package/src/lib/data-transfer/index.d.ts +34 -0
- package/src/lib/data-transfer/index.js +40 -0
- package/src/lib/data-transfer/index.js.map +1 -0
- package/src/lib/data-transfer/job.d.ts +190 -0
- package/src/lib/data-transfer/job.js +229 -0
- package/src/lib/data-transfer/job.js.map +1 -0
- package/src/lib/data-transfer/lookup.d.ts +45 -0
- package/src/lib/data-transfer/lookup.js +71 -0
- package/src/lib/data-transfer/lookup.js.map +1 -0
- package/src/lib/data-transfer/match.d.ts +99 -0
- package/src/lib/data-transfer/match.js +244 -0
- package/src/lib/data-transfer/match.js.map +1 -0
- package/src/lib/data-transfer/package-plan.d.ts +205 -0
- package/src/lib/data-transfer/package-plan.js +475 -0
- package/src/lib/data-transfer/package-plan.js.map +1 -0
- package/src/lib/data-transfer/package.d.ts +181 -0
- package/src/lib/data-transfer/package.js +426 -0
- package/src/lib/data-transfer/package.js.map +1 -0
- package/src/lib/data-transfer/picklist-map.d.ts +139 -0
- package/src/lib/data-transfer/picklist-map.js +271 -0
- package/src/lib/data-transfer/picklist-map.js.map +1 -0
- package/src/lib/data-transfer/plan.d.ts +176 -0
- package/src/lib/data-transfer/plan.js +451 -0
- package/src/lib/data-transfer/plan.js.map +1 -0
- package/src/lib/data-transfer/policy.d.ts +170 -0
- package/src/lib/data-transfer/policy.js +378 -0
- package/src/lib/data-transfer/policy.js.map +1 -0
- package/src/lib/data-transfer/resource.d.ts +211 -0
- package/src/lib/data-transfer/resource.js +241 -0
- package/src/lib/data-transfer/resource.js.map +1 -0
- package/src/lib/data-transfer/review.d.ts +70 -0
- package/src/lib/data-transfer/review.js +233 -0
- package/src/lib/data-transfer/review.js.map +1 -0
- package/src/lib/data-transfer/similarity.d.ts +40 -0
- package/src/lib/data-transfer/similarity.js +106 -0
- package/src/lib/data-transfer/similarity.js.map +1 -0
- package/src/lib/data-transfer/site-package.d.ts +365 -0
- package/src/lib/data-transfer/site-package.js +1077 -0
- package/src/lib/data-transfer/site-package.js.map +1 -0
- package/src/lib/data-transfer/source.d.ts +74 -0
- package/src/lib/data-transfer/source.js +293 -0
- package/src/lib/data-transfer/source.js.map +1 -0
- package/src/lib/data-transfer/transfer-api.d.ts +898 -0
- package/src/lib/data-transfer/transfer-api.js +107 -0
- package/src/lib/data-transfer/transfer-api.js.map +1 -0
- package/src/lib/foundation/definitions/org-billing.types.d.ts +31 -0
- package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
- package/src/lib/foundation/definitions/organization.types.d.ts +42 -1
- package/src/lib/foundation/definitions/organization.types.js.map +1 -1
- package/src/lib/foundation/definitions/platform.types.d.ts +6 -4
- package/src/lib/foundation/definitions/platform.types.js.map +1 -1
- package/src/lib/foundation/index.d.ts +1 -1
- package/src/lib/foundation/index.js.map +1 -1
- package/src/lib/plugin-manager/feature-plugins.d.ts +91 -2
- package/src/lib/plugin-manager/feature-plugins.js +48 -3
- package/src/lib/plugin-manager/feature-plugins.js.map +1 -1
- package/src/lib/plugin-manager/first-party-plugins.generated.d.ts +56 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js +1132 -27
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
- package/src/lib/plugin-manager/index.d.ts +0 -1
- package/src/lib/plugin-manager/index.js +0 -1
- package/src/lib/plugin-manager/index.js.map +1 -1
- package/src/lib/plugin-manager/interaction-recipes.d.ts +142 -0
- package/src/lib/plugin-manager/interaction-recipes.js +104 -0
- package/src/lib/plugin-manager/interaction-recipes.js.map +1 -0
- package/src/lib/plugin-manager/interaction-step-checks.d.ts +66 -0
- package/src/lib/plugin-manager/interaction-step-checks.js +86 -0
- package/src/lib/plugin-manager/interaction-step-checks.js.map +1 -0
- package/src/lib/plugin-manager/plugin-artifact-types.d.ts +235 -0
- package/src/lib/plugin-manager/plugin-artifact-types.js +99 -0
- package/src/lib/plugin-manager/plugin-artifact-types.js.map +1 -0
- package/src/lib/plugin-manager/plugin-contact-capture.d.ts +8 -0
- package/src/lib/plugin-manager/plugin-contact-capture.js.map +1 -1
- package/src/lib/plugin-manager/plugin-conversion-credit.d.ts +216 -0
- package/src/lib/plugin-manager/plugin-conversion-credit.js +91 -0
- package/src/lib/plugin-manager/plugin-conversion-credit.js.map +1 -0
- package/src/lib/plugin-manager/plugin-entity-pickers.d.ts +83 -0
- package/src/lib/plugin-manager/plugin-entity-pickers.js +87 -0
- package/src/lib/plugin-manager/plugin-entity-pickers.js.map +1 -0
- package/src/lib/plugin-manager/plugin-host-resources.d.ts +6 -0
- package/src/lib/plugin-manager/plugin-host-resources.js +6 -1
- package/src/lib/plugin-manager/plugin-host-resources.js.map +1 -1
- package/src/lib/plugin-manager/plugin-intake-gates.d.ts +75 -0
- package/src/lib/plugin-manager/plugin-intake-gates.js +49 -0
- package/src/lib/plugin-manager/plugin-intake-gates.js.map +1 -0
- package/src/lib/plugin-manager/plugin-jobs.d.ts +5 -5
- package/src/lib/plugin-manager/plugin-jobs.js +7 -7
- package/src/lib/plugin-manager/plugin-jobs.js.map +1 -1
- package/src/lib/plugin-manager/plugin-live-paths.d.ts +70 -0
- package/src/lib/plugin-manager/plugin-live-paths.js +66 -0
- package/src/lib/plugin-manager/plugin-live-paths.js.map +1 -0
- package/src/lib/plugin-manager/plugin-org-erasure.d.ts +3 -2
- package/src/lib/plugin-manager/plugin-org-erasure.js +30 -5
- package/src/lib/plugin-manager/plugin-org-erasure.js.map +1 -1
- package/src/lib/plugin-manager/plugin-person-erasure.d.ts +68 -9
- package/src/lib/plugin-manager/plugin-person-erasure.js +196 -51
- package/src/lib/plugin-manager/plugin-person-erasure.js.map +1 -1
- package/src/lib/plugin-manager/plugin-person-records.d.ts +275 -0
- package/src/lib/plugin-manager/plugin-person-records.js +107 -0
- package/src/lib/plugin-manager/plugin-person-records.js.map +1 -0
- package/src/lib/plugin-manager/plugin-record-counts.d.ts +76 -0
- package/src/lib/plugin-manager/plugin-record-counts.js +49 -0
- package/src/lib/plugin-manager/plugin-record-counts.js.map +1 -0
- package/src/lib/plugin-manager/plugin-record-email-state.d.ts +26 -0
- package/src/lib/plugin-manager/plugin-record-email-state.js +16 -0
- package/src/lib/plugin-manager/plugin-record-email-state.js.map +1 -1
- package/src/lib/plugin-manager/plugin-record-index.d.ts +10 -0
- package/src/lib/plugin-manager/plugin-record-index.js.map +1 -1
- package/src/lib/plugin-manager/plugin-record-lists.d.ts +86 -6
- package/src/lib/plugin-manager/plugin-record-lists.js +42 -5
- package/src/lib/plugin-manager/plugin-record-lists.js.map +1 -1
- package/src/lib/plugin-manager/plugin-record-origin.d.ts +79 -0
- package/src/lib/plugin-manager/plugin-record-origin.js +46 -0
- package/src/lib/plugin-manager/plugin-record-origin.js.map +1 -0
- package/src/lib/plugin-manager/plugin-record-pages.d.ts +37 -0
- package/src/lib/plugin-manager/plugin-record-pages.js +52 -0
- package/src/lib/plugin-manager/plugin-record-pages.js.map +1 -0
- package/src/lib/plugin-manager/plugin-record-timeline.d.ts +60 -0
- package/src/lib/plugin-manager/plugin-record-timeline.js +16 -0
- package/src/lib/plugin-manager/plugin-record-timeline.js.map +1 -1
- package/src/lib/plugin-manager/plugin-resource-drafts.d.ts +5 -5
- package/src/lib/plugin-manager/plugin-resource-drafts.js.map +1 -1
- package/src/lib/plugin-manager/plugin-revocations.d.ts +64 -0
- package/src/lib/plugin-manager/plugin-revocations.js +47 -0
- package/src/lib/plugin-manager/plugin-revocations.js.map +1 -0
- package/src/lib/plugin-manager/plugin-send-tallies.d.ts +69 -0
- package/src/lib/plugin-manager/plugin-send-tallies.js +45 -0
- package/src/lib/plugin-manager/plugin-send-tallies.js.map +1 -0
- package/src/lib/plugin-manager/plugin-server-steps.d.ts +170 -0
- package/src/lib/plugin-manager/plugin-server-steps.js +116 -0
- package/src/lib/plugin-manager/plugin-server-steps.js.map +1 -0
- package/src/lib/plugin-manager/plugin-site-bundle.d.ts +40 -0
- package/src/lib/plugin-manager/plugin-site-bundle.js +4 -0
- package/src/lib/plugin-manager/plugin-site-bundle.js.map +1 -1
- package/src/lib/plugin-manager/plugin-site-export.d.ts +57 -1
- package/src/lib/plugin-manager/plugin-site-export.js +23 -10
- package/src/lib/plugin-manager/plugin-site-export.js.map +1 -1
- package/src/lib/plugin-manager/plugin-sitemap-readers.d.ts +146 -0
- package/src/lib/plugin-manager/plugin-sitemap-readers.js +110 -0
- package/src/lib/plugin-manager/plugin-sitemap-readers.js.map +1 -0
- package/src/lib/plugin-manager/plugin-transfer-resources.d.ts +714 -0
- package/src/lib/plugin-manager/plugin-transfer-resources.js +443 -0
- package/src/lib/plugin-manager/plugin-transfer-resources.js.map +1 -0
- package/src/lib/plugin-manager/plugin-usage-axes.d.ts +54 -5
- package/src/lib/plugin-manager/plugin-usage-axes.js +11 -3
- package/src/lib/plugin-manager/plugin-usage-axes.js.map +1 -1
- package/src/lib/plugin-manager/plugin-user-erasure.js +9 -1
- package/src/lib/plugin-manager/plugin-user-erasure.js.map +1 -1
- package/src/lib/plugin-manager/plugin-visitor-doors.d.ts +104 -0
- package/src/lib/plugin-manager/plugin-visitor-doors.js +108 -0
- package/src/lib/plugin-manager/plugin-visitor-doors.js.map +1 -0
- package/src/lib/plugin-manager/realm-host-aglyn.generated.js +2 -0
- package/src/lib/plugin-manager/realm-host-aglyn.generated.js.map +1 -1
- package/src/lib/plugin-manager/repeat-rows.d.ts +5 -6
- package/src/lib/plugin-manager/repeat-rows.js.map +1 -1
- package/src/lib/app-utils/actions.d.ts +0 -310
- package/src/lib/app-utils/actions.js +0 -506
- package/src/lib/app-utils/actions.js.map +0 -1
- package/src/lib/app-utils/automation-placeholders.d.ts +0 -72
- package/src/lib/app-utils/automation-placeholders.js +0 -207
- package/src/lib/app-utils/automation-placeholders.js.map +0 -1
- package/src/lib/app-utils/dataset-models.d.ts +0 -339
- package/src/lib/app-utils/dataset-models.js +0 -722
- package/src/lib/app-utils/dataset-models.js.map +0 -1
- package/src/lib/app-utils/datasets.d.ts +0 -171
- package/src/lib/app-utils/datasets.js +0 -227
- package/src/lib/app-utils/datasets.js.map +0 -1
- package/src/lib/app-utils/form-abuse-ceiling.d.ts +0 -146
- package/src/lib/app-utils/form-abuse-ceiling.js +0 -158
- package/src/lib/app-utils/form-abuse-ceiling.js.map +0 -1
- package/src/lib/plugin-manager/order-fulfilment.d.ts +0 -142
- package/src/lib/plugin-manager/order-fulfilment.js +0 -104
- package/src/lib/plugin-manager/order-fulfilment.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/media-asset-facts.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * What a placed library asset is NOW, read from its DAM document when the\n * page is composed rather than copied onto the node when it was picked: a\n * film's length, shape and poster (AGL-2807), and an image's pixel pair\n * (AGL-2833).\n *\n * ## Why the pick-time copy is not enough\n *\n * Picking a library asset copies facts onto the node. An image gets its pixel\n * pair ({@link intrinsicMediaSize}), which `image.tsx` renders as the\n * `<img>`'s `width`/`height` attributes so the browser can reserve the box\n * before the bytes arrive. A film gets its running time, its frame's pair and\n * a poster flag ({@link videoMediaProps}): the pair becomes the player's CSS\n * `aspect-ratio`, the running time becomes `VideoObject.duration`, and the\n * flag decides whether a lightbox `<img>` and a `thumbnailUrl` exist at all.\n *\n * A replace (AGL-2732) keeps the asset's id and URL and rewrites its document:\n * an image's `width`/`height`, a film's `video` and `poster` records. It\n * cannot rewrite the nodes, which sit in every screen, layout, component and\n * published version that places the asset. So after a replace with a\n * different shape, every page placing the image reserved the previous\n * picture's box and shifted when the new one decoded, and every page placing\n * the film kept the previous film's length and shape, until someone re-picked\n * it.\n *\n * ## The rule\n *\n * Two surfaces read each placed asset's document and lay what it records over\n * the node here: the tenant's composition, for the page a visitor gets\n * (`libs/tenant/runtime/src/lib/get-media-asset-facts.ts`), and the console,\n * for the besigner canvas an author edits and the Preview that checks it\n * (AGL-2838, AGL-2849). Both decide what a read answers through\n * {@link mediaAssetFactsFromDocument}, so the editor cannot disagree with the\n * page about which assets answer. When the asset cannot be answered for (a\n * failed or pending read, a missing or deleted document, an asset the CDN\n * would not serve under this page's URL, one past the composition's cap), the\n * node keeps what the pick stored. That is the render every page had before\n * this, never a worse one. When the asset answers:\n *\n * - **A film's facts win, including their ABSENCE.** A film the replace left\n * with no `video` record has no known shape, so a stored pair describing\n * the previous film is dropped rather than published, and a poster flag the\n * document no longer backs is dropped with it. One stored value survives: a\n * running time the AUTHOR typed for a film the DAM has no running time for.\n * The pick only ever writes the duration together with the pixel pair\n * ({@link videoMediaProps} is all-or-nothing on the `video` record), and the\n * pair is not an author control. So a duration standing alone is an\n * author's, and a duration standing beside a pair is a copy of a film that\n * may no longer be the one in the bucket.\n * - **An image's pair wins when the document records one.** When it records\n * none (an SVG, which the upload cannot measure, or a file older than\n * AGL-173), the stored pair stays, whether an author typed it through the\n * API or it is a copy of the file the asset held before. The asymmetry with\n * a film is in the render, not the data. A film's pair is the player's\n * permanent box, but an image's is only a reservation\n * (`aspect-ratio: auto w / h`), which the decoded picture's own ratio\n * replaces. Dropping the pair guarantees a shift of the image's full height\n * on every view. A stale pair shifts by the difference between two heights,\n * and a pair typed for a file the DAM cannot measure shifts by nothing.\n *\n * Nothing an author sets for the placement is touched: an image's CSS\n * `width` and `height`, its fit and radius, and a film's own poster describe\n * the placement rather than the file.\n *\n * Imported by path and never through a barrel: every `@aglyn/aglyn` barrel\n * ships to published pages, and nothing here has a reason to reach one, so\n * the composition and the console both import this module by path.\n */\n\nimport { CANVAS_ROOT_ELEMENT_ID } from '../foundation/constants/canvas'\nimport { mediaCdnScopeRefusal, parseMediaCdnScope } from './media-cdn-scope'\nimport { intrinsicMediaSize, videoMediaProps } from './media-metadata'\nimport { hostQualifiedScope, type MediaRef, parseMediaRef } from './media-ref'\nimport { VIDEO_COMPONENT_ID } from './video-object'\n\n/** The Image element's persisted component id (`image.tsx`), never renamed. */\nexport const IMAGE_COMPONENT_ID = 'image'\n\n/**\n * The prop each element that holds a markdown-lite DOCUMENT keeps it in, and\n * therefore every element whose body can name a library image (AGL-3149).\n *\n * The same two elements and the same two prop names `resolveMarkdownSource`\n * walks for a table of contents (AGL-1162), which is the other reader of a\n * body's contents. They differ: the Markdown element calls it `content` and a\n * collection entry's body calls it `markdown`.\n *\n * Both ids are spelled out rather than imported. `markdown` belongs to a\n * plugin, which core may never import; `collectionEntryBody` is exported by\n * `collection-entries.ts`, but that module is 1,860 lines and drags\n * `content-authors.ts` behind it, and this one is deliberately outside the\n * barrel that ships to published pages. A persisted component id is a string\n * that cannot change — renaming one orphans every document that stores it —\n * so the copy cannot drift in the way an imported value would protect against.\n */\nconst MARKDOWN_BODY_PROPS: Readonly<Record<string, string>> = {\n markdown: 'content',\n collectionEntryBody: 'markdown',\n}\n\n/** The root of a composed map, where a walk in document order starts. */\nconst ROOT_NODE_ID: string = CANVAS_ROOT_ELEMENT_ID\n\n/**\n * What a readable asset's media document records, as the overlay consumes it.\n *\n * Raw on purpose: {@link intrinsicMediaSize} and {@link videoMediaProps} are\n * where a pair and a `video` record are bounded, and a second reading of the\n * same numbers here is how two files come to disagree about what a partial\n * record means.\n */\nexport interface MediaAssetFacts {\n /** The document's `width`: an image's, read from its bytes at upload. */\n width?: unknown\n /** The document's `height`, the other half of {@link width}. */\n height?: unknown\n /** The document's `video` record: `durationMs`, `width` and `height`. */\n video?: unknown\n /** The document's generated `poster` record, when it has one. */\n poster?: unknown\n}\n\n/**\n * Every field an asset's facts are decided from, and the projection a reader\n * asks Firestore for: ONE list, whichever surface reads. `width` and `height`\n * (an image's) and `video` and `poster` (a film's) are the facts. The other\n * three are the gates `serveMediaCdn` applies before it will serve an asset at\n * all, so no surface shows the shape of a file its page's URL refuses.\n */\nexport const MEDIA_ASSET_FACT_FIELDS = [\n 'width',\n 'height',\n 'video',\n 'poster',\n 'deletedAt',\n 'private',\n 'visibleTo',\n] as const\n\n/** An asset's media document, as far as {@link MEDIA_ASSET_FACT_FIELDS} reach. */\nexport type MediaAssetDocument = Partial<\n Record<(typeof MEDIA_ASSET_FACT_FIELDS)[number], unknown>\n>\n\n/** The elements whose placements follow their file. */\nexport type MediaAssetElement =\n | typeof IMAGE_COMPONENT_ID\n | typeof VIDEO_COMPONENT_ID\n\nexport interface MediaAssetFactsOptions {\n /**\n * One element's placements only, by persisted component id. Absent means\n * both, which is what the composition asks for.\n */\n only?: MediaAssetElement\n}\n\n/** A node as the composed map holds it: flat, children by id. */\ninterface ComposedMediaNode {\n componentId?: string\n nodes?: unknown\n props?: Record<string, unknown>\n resolvedProps?: Record<string, unknown>\n}\n\nconst owns = (map: object, key: string) =>\n Object.prototype.hasOwnProperty.call(map, key)\n\n/**\n * The key an asset's facts are filed under: the reference's own scope and id.\n *\n * Deliberately NOT the host-qualified scope a page renders. The document lives\n * under the scope's owner whichever site places it, and which site may be\n * shown it is the reader's question, answered once per page.\n */\nexport function mediaAssetFactsKey(\n ref: Pick<MediaRef, 'scope' | 'mediaId'>,\n): string {\n return `${ref.scope}/${ref.mediaId}`\n}\n\n/**\n * Where an asset's media document lives: under the scope's OWNER, `orgs/` for\n * the org library and `hosts/` for a site's own, whichever site places it.\n * `null` for a scope the CDN would not parse, which no read can answer for.\n */\nexport function mediaAssetDocumentPath(\n ref: Pick<MediaRef, 'scope' | 'mediaId'>,\n): string | null {\n const scope = parseMediaCdnScope(ref.scope)\n if (!scope) return null\n return `${scope.isOrg ? 'orgs' : 'hosts'}/${scope.scopeId}/media/${ref.mediaId}`\n}\n\n/**\n * The facts one read of an asset's document yields for a placement rendered\n * on `hostId`'s pages, or `undefined` when the placement keeps its stored\n * props.\n *\n * An answer exists only for a document that was read, is live, is not\n * private, and is visible to that site under the host-qualified scope the page\n * renders: the verdict the CDN reaches when the browser asks for the bytes.\n * The URL a page renders names the site doing the rendering\n * (`resolveMediaSrc`), so visibility is asked of THAT scope, not of the scope\n * the reference was stored with.\n */\nexport function mediaAssetFactsFromDocument(\n document: MediaAssetDocument | null | undefined,\n ref: Pick<MediaRef, 'scope'>,\n hostId: string,\n): MediaAssetFacts | undefined {\n if (!document) return undefined\n if (document.deletedAt || document.private === true) return undefined\n const served = parseMediaCdnScope(hostQualifiedScope(ref.scope, hostId))\n if (!served || mediaCdnScopeRefusal(served, document.visibleTo)) {\n return undefined\n }\n return {\n width: document.width,\n height: document.height,\n video: document.video,\n poster: document.poster,\n }\n}\n\n/** The library asset an Image or Video node places, or null for anything else. */\nfunction placedAsset(\n node: ComposedMediaNode | null | undefined,\n only?: MediaAssetElement,\n): MediaRef | null {\n const componentId = node?.componentId\n if (componentId !== IMAGE_COMPONENT_ID && componentId !== VIDEO_COMPONENT_ID) {\n return null\n }\n if (only && componentId !== only) return null\n // The precedence every other reader of the composed map uses: a node inside\n // a repeated collection carries its bound values in the resolved copy.\n const props = node?.resolvedProps ?? node?.props\n return parseMediaRef(props?.['src'])\n}\n\n/** A compose-time token the tenant has not substituted — never a document. */\nconst UNRESOLVED_TOKEN = /^\\{\\{[^}]+\\}\\}$/\n\n/**\n * The markdown-lite document a node holds, or `''` for a node holding none.\n *\n * `resolvedProps` first, for the reason {@link placedAsset} gives: an entry\n * body is the literal `{{entry.body}}` in `props` and the entry's real text in\n * the resolved copy. An unsubstituted token is not a document — it can name no\n * asset — so it is dropped here rather than walked for images that a canvas\n * surface would never find.\n */\nfunction markdownBodyOf(\n props: Record<string, unknown> | undefined,\n componentId: string | undefined,\n): string {\n const prop =\n componentId && owns(MARKDOWN_BODY_PROPS, componentId)\n ? MARKDOWN_BODY_PROPS[componentId]\n : undefined\n const text = prop ? props?.[prop] : undefined\n if (typeof text !== 'string' || UNRESOLVED_TOKEN.test(text.trim())) return ''\n return text\n}\n\n/** See {@link markdownBodyOf} — the body the page will actually render. */\nfunction markdownBody(node: ComposedMediaNode | null | undefined): string {\n return markdownBodyOf(\n node?.resolvedProps ?? node?.props,\n node?.componentId,\n )\n}\n\n/**\n * A markdown-lite image: ``, capturing only the target, and only\n * up to the first whitespace or `)`.\n *\n * That is the whole of the syntax `markdown-lite.ts` accepts — no title string\n * after the target, no angle-bracket form — so there is nowhere else in a body\n * for a reference to hide, and matching more than the parser does would name\n * assets the renderer never asks for.\n */\nconst MARKDOWN_IMAGE_TARGET = /!\\[[^\\]]*\\]\\(\\s*([^)\\s]+)/g\n\n/**\n * Every library asset a markdown body's images name, in the order the body\n * names them, each beside the target EXACTLY as the body wrote it.\n *\n * The raw target is carried because that is the key the renderer has: it holds\n * the parsed block's `src`, the same string, and looking a pair up by it costs\n * no second parse per image on every render.\n *\n * A target that is not a `media:` reference yields nothing — a hotlinked URL\n * and a legacy stored path have no DAM document to read, and the renderer\n * gives those today's markup unchanged.\n */\nfunction markdownImageRefs(\n text: string,\n): Array<{ target: string; ref: MediaRef }> {\n if (!text.includes('![')) return []\n const found: Array<{ target: string; ref: MediaRef }> = []\n for (const match of text.matchAll(MARKDOWN_IMAGE_TARGET)) {\n const target = match[1]\n const ref = parseMediaRef(target)\n if (ref) found.push({ target, ref })\n }\n return found\n}\n\n/**\n * The map's node ids in document order: depth first from the root through\n * each node's child ids, then every id the walk never reached (a map with no\n * root, an orphan) in the order the map lists it. That puts the top of the\n * page ahead of its footer, and it is the same order for the same map.\n */\nfunction documentOrder(nodes: Record<string, unknown>): string[] {\n const order: string[] = []\n const seen = new Set<string>()\n const stack = owns(nodes, ROOT_NODE_ID) ? [ROOT_NODE_ID] : []\n while (stack.length) {\n const id = stack.pop() as string\n if (seen.has(id) || !owns(nodes, id)) continue\n seen.add(id)\n order.push(id)\n const children = (nodes[id] as ComposedMediaNode | null)?.nodes\n if (!Array.isArray(children)) continue\n for (let index = children.length - 1; index >= 0; index -= 1) {\n const child = children[index]\n if (typeof child === 'string' && !seen.has(child)) stack.push(child)\n }\n }\n for (const id in nodes) if (!seen.has(id)) order.push(id)\n return order\n}\n\n/**\n * Every distinct library asset the Image and Video nodes in a map place:\n * films first, then images, each in document order.\n *\n * A read that is capped honors that order. A film goes first because its\n * stale facts are the worse render (a player of the wrong shape and a\n * thumbnail that 404s, against a reservation that corrects itself when an\n * image decodes), and document order covers the top of the page before its\n * footer.\n *\n * `[]` for a page that places none, so a caller that gates its read on the\n * length spends nothing on it. A pinned and an unpinned reference to one\n * asset are one entry: a pin names bytes, not a different asset.\n */\nexport function mediaAssetRefs(\n nodes: Record<string, unknown> | null | undefined,\n options: MediaAssetFactsOptions = {},\n): MediaRef[] {\n const refs: MediaRef[] = []\n if (!nodes) return refs\n const order = documentOrder(nodes)\n const seen = new Set<string>()\n for (const element of [VIDEO_COMPONENT_ID, IMAGE_COMPONENT_ID] as const) {\n if (options.only && options.only !== element) continue\n for (const id of order) {\n const node = nodes[id] as ComposedMediaNode | null\n if (node?.componentId !== element) continue\n const ref = placedAsset(node)\n if (!ref) continue\n const key = mediaAssetFactsKey(ref)\n if (seen.has(key)) continue\n seen.add(key)\n refs.push(ref)\n }\n }\n // A markdown body's images come LAST, and only when the caller wants every\n // element (AGL-3149). Last because of what a capped read costs each kind: a\n // placement that misses out renders at its pick-time pair, a body image that\n // misses out renders exactly as it does today, and a film that misses out\n // gets a player of the wrong shape. Only-when-unfiltered because `only` asks\n // for one ELEMENT's placements, and a body image is not a placement of the\n // Image element — the video-asset reader would otherwise read image\n // documents it has no use for.\n if (options.only) return refs\n for (const id of order) {\n const body = markdownBody(nodes[id] as ComposedMediaNode | null)\n for (const { ref } of markdownImageRefs(body)) {\n const key = mediaAssetFactsKey(ref)\n if (seen.has(key)) continue\n seen.add(key)\n refs.push(ref)\n }\n }\n return refs\n}\n\nconst usable = (value: unknown): value is number =>\n typeof value === 'number' && Number.isFinite(value) && value > 0\n\n/** A film's props with its asset's facts laid over them. See the module note. */\nfunction withFilmFacts(\n props: Record<string, unknown>,\n facts: MediaAssetFacts,\n): Record<string, unknown> {\n const live = videoMediaProps({\n componentId: VIDEO_COMPONENT_ID,\n propName: 'src',\n assetVideo: facts.video,\n assetPoster: facts.poster,\n })\n const {\n durationSeconds,\n intrinsicWidth,\n intrinsicHeight,\n posterFromSource: _storedPosterFlag,\n ...next\n } = props\n // The pick writes a duration only beside the pixel pair, so a pair is what\n // marks the stored duration as a copy rather than an author's own.\n const typedByAuthor = !(usable(intrinsicWidth) && usable(intrinsicHeight))\n if (live.durationSeconds !== undefined) {\n next['durationSeconds'] = live.durationSeconds\n } else if (typedByAuthor && durationSeconds !== undefined) {\n next['durationSeconds'] = durationSeconds\n }\n if (live.intrinsicWidth !== undefined && live.intrinsicHeight !== undefined) {\n next['intrinsicWidth'] = live.intrinsicWidth\n next['intrinsicHeight'] = live.intrinsicHeight\n }\n if (live.posterFromSource) next['posterFromSource'] = true\n return next\n}\n\n/**\n * An image's props with its asset's pair laid over them, or the SAME object\n * when the document records no usable pair or the stored one already matches.\n * See the module note.\n */\nfunction withImageFacts(\n props: Record<string, unknown>,\n facts: MediaAssetFacts,\n): Record<string, unknown> {\n // Through the pick's own gate, so the overlay and the pick agree on what a\n // usable pair is: both halves, finite and positive.\n const live = intrinsicMediaSize({\n componentId: IMAGE_COMPONENT_ID,\n propName: 'src',\n assetWidth: facts.width,\n assetHeight: facts.height,\n })\n if (live.intrinsicWidth === undefined || live.intrinsicHeight === undefined) {\n return props\n }\n if (\n props['intrinsicWidth'] === live.intrinsicWidth &&\n props['intrinsicHeight'] === live.intrinsicHeight\n ) {\n return props\n }\n return {\n ...props,\n intrinsicWidth: live.intrinsicWidth,\n intrinsicHeight: live.intrinsicHeight,\n }\n}\n\n/**\n * The prop a markdown body carries its images' pixel pairs in, keyed by the\n * target the body wrote (AGL-3149).\n *\n * A body image is not a node, so it cannot take `intrinsicWidth` and\n * `intrinsicHeight` the way a placement does; the pairs travel together on the\n * element that holds the document, and the renderer looks each one up by the\n * parsed block's `src`.\n */\nexport const BODY_IMAGE_SIZES_PROP = 'intrinsicSizes'\n\n/** One body image's pair, as {@link BODY_IMAGE_SIZES_PROP} carries it. */\nexport interface BodyImageSize {\n width: number\n height: number\n}\n\n/**\n * A markdown body's props with a pair for each library image it names, or the\n * SAME object when no image in it can be answered for.\n *\n * Only images whose document records a usable pair get an entry, through the\n * same {@link intrinsicMediaSize} gate a placement goes through. An image left\n * out is one the renderer must give today's markup: `srcSet` without the pair\n * makes `sizes` the image's rendered width, which upscales anything narrower\n * than the column, so a partial answer is worse here than no answer.\n */\nfunction withBodyImageFacts(\n props: Record<string, unknown>,\n componentId: string | undefined,\n facts: ReadonlyMap<string, MediaAssetFacts>,\n): Record<string, unknown> {\n // THIS object's own body, never the node's resolved one: `props` on a bound\n // entry body still holds the `{{entry.body}}` token, and pairs for images it\n // does not name are bytes in the tree that nothing can ever look up.\n let sizes: Record<string, BodyImageSize> | undefined\n for (const { target, ref } of markdownImageRefs(\n markdownBodyOf(props, componentId),\n )) {\n const found = facts.get(mediaAssetFactsKey(ref))\n if (!found) continue\n const live = intrinsicMediaSize({\n componentId: IMAGE_COMPONENT_ID,\n propName: 'src',\n assetWidth: found.width,\n assetHeight: found.height,\n })\n if (\n live.intrinsicWidth === undefined ||\n live.intrinsicHeight === undefined\n ) {\n continue\n }\n if (!sizes) sizes = {}\n sizes[target] = {\n width: live.intrinsicWidth,\n height: live.intrinsicHeight,\n }\n }\n if (!sizes) return props\n return { ...props, [BODY_IMAGE_SIZES_PROP]: sizes }\n}\n\n/**\n * The composed map with each placed asset's facts laid over its node, and each\n * markdown body's images' pairs laid over the element holding the body.\n *\n * `facts` is keyed by {@link mediaAssetFactsKey}. A placement with no entry,\n * because the reader could not answer for its asset, keeps its stored props.\n * The SAME map comes back when nothing changes, so a page with no library\n * asset pays for one walk and no copy, and the input is never mutated either\n * way.\n */\nexport function applyMediaAssetFacts<T extends Record<string, unknown>>(\n nodes: T,\n facts: ReadonlyMap<string, MediaAssetFacts>,\n options: MediaAssetFactsOptions = {},\n): T {\n if (!facts.size) return nodes\n let applied: Record<string, unknown> | undefined\n const write = (id: string, node: ComposedMediaNode, next: {\n props?: Record<string, unknown>\n resolvedProps?: Record<string, unknown>\n }): void => {\n if (!applied) applied = { ...nodes }\n applied[id] = {\n ...node,\n ...(next.props ? { props: next.props } : {}),\n ...(next.resolvedProps ? { resolvedProps: next.resolvedProps } : {}),\n }\n }\n for (const id in nodes) {\n const node = nodes[id] as ComposedMediaNode\n const ref = placedAsset(node, options.only)\n const found = ref ? facts.get(mediaAssetFactsKey(ref)) : undefined\n if (found) {\n const overlay =\n node.componentId === VIDEO_COMPONENT_ID ? withFilmFacts : withImageFacts\n const props = node.props && overlay(node.props, found)\n const resolvedProps =\n node.resolvedProps && overlay(node.resolvedProps, found)\n if (props === node.props && resolvedProps === node.resolvedProps) continue\n write(id, node, { props, resolvedProps })\n continue\n }\n // A markdown body, under the same `only` rule `mediaAssetRefs` collects\n // under: a body image is not a placement of the Image element, so a reader\n // asking for one element's placements is not asking about bodies.\n if (options.only) continue\n const { componentId } = node\n if (!componentId || !owns(MARKDOWN_BODY_PROPS, componentId)) continue\n const props =\n node.props && withBodyImageFacts(node.props, componentId, facts)\n const resolvedProps =\n node.resolvedProps &&\n withBodyImageFacts(node.resolvedProps, componentId, facts)\n if (props === node.props && resolvedProps === node.resolvedProps) continue\n write(id, node, { props, resolvedProps })\n }\n return applied ? (applied as T) : nodes\n}\n"],"names":["CANVAS_ROOT_ELEMENT_ID","mediaCdnScopeRefusal","parseMediaCdnScope","intrinsicMediaSize","videoMediaProps","hostQualifiedScope","parseMediaRef","VIDEO_COMPONENT_ID","IMAGE_COMPONENT_ID","MARKDOWN_BODY_PROPS","markdown","collectionEntryBody","ROOT_NODE_ID","MEDIA_ASSET_FACT_FIELDS","owns","map","key","Object","prototype","hasOwnProperty","call","mediaAssetFactsKey","ref","scope","mediaId","mediaAssetDocumentPath","isOrg","scopeId","mediaAssetFactsFromDocument","document","hostId","undefined","deletedAt","private","served","visibleTo","width","height","video","poster","placedAsset","node","only","componentId","props","resolvedProps","UNRESOLVED_TOKEN","markdownBodyOf","prop","text","test","trim","markdownBody","MARKDOWN_IMAGE_TARGET","markdownImageRefs","includes","found","match","matchAll","target","push","documentOrder","nodes","order","seen","Set","stack","length","id","pop","has","add","children","Array","isArray","index","child","mediaAssetRefs","options","refs","element","body","usable","value","Number","isFinite","withFilmFacts","facts","live","propName","assetVideo","assetPoster","durationSeconds","intrinsicWidth","intrinsicHeight","posterFromSource","_storedPosterFlag","next","typedByAuthor","withImageFacts","assetWidth","assetHeight","BODY_IMAGE_SIZES_PROP","withBodyImageFacts","sizes","get","applyMediaAssetFacts","size","applied","write","overlay"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmEC,GAED,SAASA,sBAAsB,QAAQ,oCAAgC;AACvE,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,uBAAmB;AAC5E,SAASC,kBAAkB,EAAEC,eAAe,QAAQ,sBAAkB;AACtE,SAASC,kBAAkB,EAAiBC,aAAa,QAAQ,iBAAa;AAC9E,SAASC,kBAAkB,QAAQ,oBAAgB;AAEnD,6EAA6E,GAC7E,OAAO,MAAMC,qBAAqB,QAAO;AAEzC;;;;;;;;;;;;;;;;CAgBC,GACD,MAAMC,sBAAwD;IAC5DC,UAAU;IACVC,qBAAqB;AACvB;AAEA,uEAAuE,GACvE,MAAMC,eAAuBZ;AAqB7B;;;;;;CAMC,GACD,OAAO,MAAMa,0BAA0B;IACrC;IACA;IACA;IACA;IACA;IACA;I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3E,kEAAkE;QAClE,IAAIiC,QAAQpC,IAAI,EAAE;QAClB,MAAM,EAAEC,WAAW,EAAE,GAAGF;QACxB,IAAI,CAACE,eAAe,CAAC7B,KAAKL,qBAAqBkC,cAAc;QAC7D,MAAMC,QACJH,KAAKG,KAAK,IAAI2D,mBAAmB9D,KAAKG,KAAK,EAAED,aAAa4C;QAC5D,MAAM1C,gBACJJ,KAAKI,aAAa,IAClB0D,mBAAmB9D,KAAKI,aAAa,EAAEF,aAAa4C;QACtD,IAAI3C,UAAUH,KAAKG,KAAK,IAAIC,kBAAkBJ,KAAKI,aAAa,EAAE;QAClEgE,MAAMzC,IAAI3B,MAAM;YAAEG;YAAOC;QAAc;IACzC;IACA,OAAO+D,UAAWA,UAAgB9C;AACpC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/media-asset-facts.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * What a placed library asset is NOW, read from its DAM document when the\n * page is composed rather than copied onto the node when it was picked: a\n * film's length, shape and poster (AGL-2807), and an image's pixel pair\n * (AGL-2833).\n *\n * ## Why the pick-time copy is not enough\n *\n * Picking a library asset copies facts onto the node. An image gets its pixel\n * pair ({@link intrinsicMediaSize}), which `image.tsx` renders as the\n * `<img>`'s `width`/`height` attributes so the browser can reserve the box\n * before the bytes arrive. A film gets its running time, its frame's pair and\n * a poster flag ({@link videoMediaProps}): the pair becomes the player's CSS\n * `aspect-ratio`, the running time becomes `VideoObject.duration`, and the\n * flag decides whether a lightbox `<img>` and a `thumbnailUrl` exist at all.\n *\n * A replace (AGL-2732) keeps the asset's id and URL and rewrites its document:\n * an image's `width`/`height`, a film's `video` and `poster` records. It\n * cannot rewrite the nodes, which sit in every screen, layout, component and\n * published version that places the asset. So after a replace with a\n * different shape, every page placing the image reserved the previous\n * picture's box and shifted when the new one decoded, and every page placing\n * the film kept the previous film's length and shape, until someone re-picked\n * it.\n *\n * ## The rule\n *\n * Two surfaces read each placed asset's document and lay what it records over\n * the node here: the tenant's composition, for the page a visitor gets\n * (`libs/tenant/runtime/src/lib/get-media-asset-facts.ts`), and the console,\n * for the besigner canvas an author edits and the Preview that checks it\n * (AGL-2838, AGL-2849). Both decide what a read answers through\n * {@link mediaAssetFactsFromDocument}, so the editor cannot disagree with the\n * page about which assets answer. When the asset cannot be answered for (a\n * failed or pending read, a missing or deleted document, an asset the CDN\n * would not serve under this page's URL, one past the composition's cap), the\n * node keeps what the pick stored. That is the render every page had before\n * this, never a worse one. When the asset answers:\n *\n * - **A film's facts win, including their ABSENCE.** A film the replace left\n * with no `video` record has no known shape, so a stored pair describing\n * the previous film is dropped rather than published, and a poster flag the\n * document no longer backs is dropped with it. One stored value survives: a\n * running time the AUTHOR typed for a film the DAM has no running time for.\n * The pick only ever writes the duration together with the pixel pair\n * ({@link videoMediaProps} is all-or-nothing on the `video` record), and the\n * pair is not an author control. So a duration standing alone is an\n * author's, and a duration standing beside a pair is a copy of a film that\n * may no longer be the one in the bucket.\n * - **An image's pair wins when the document records one.** When it records\n * none (an SVG, which the upload cannot measure, or a file older than\n * AGL-173), the stored pair stays, whether an author typed it through the\n * API or it is a copy of the file the asset held before. The asymmetry with\n * a film is in the render, not the data. A film's pair is the player's\n * permanent box, but an image's is only a reservation\n * (`aspect-ratio: auto w / h`), which the decoded picture's own ratio\n * replaces. Dropping the pair guarantees a shift of the image's full height\n * on every view. A stale pair shifts by the difference between two heights,\n * and a pair typed for a file the DAM cannot measure shifts by nothing.\n *\n * Nothing an author sets for the placement is touched: an image's CSS\n * `width` and `height`, its fit and radius, and a film's own poster describe\n * the placement rather than the file.\n *\n * Imported by path and never through a barrel: every `@aglyn/aglyn` barrel\n * ships to published pages, and nothing here has a reason to reach one, so\n * the composition and the console both import this module by path.\n */\n\nimport { CANVAS_ROOT_ELEMENT_ID } from '../foundation/constants/canvas'\nimport { mediaCdnScopeRefusal, parseMediaCdnScope } from './media-cdn-scope'\nimport { intrinsicMediaSize, videoMediaProps } from './media-metadata'\nimport {\n hostQualifiedScope,\n isMediaCdnPath,\n mediaCdnVersionToken,\n type MediaRef,\n mediaRefFromCdnPath,\n parseMediaRef,\n} from './media-ref'\nimport { VIDEO_COMPONENT_ID } from './video-object'\n\n/** The Image element's persisted component id (`image.tsx`), never renamed. */\nexport const IMAGE_COMPONENT_ID = 'image'\n\n/**\n * The prop each element that holds a markdown-lite DOCUMENT keeps it in, and\n * therefore every element whose body can name a library image (AGL-3149).\n *\n * The same two elements and the same two prop names `resolveMarkdownSource`\n * walks for a table of contents (AGL-1162), which is the other reader of a\n * body's contents. They differ: the Markdown element calls it `content` and a\n * collection entry's body calls it `markdown`.\n *\n * Both ids are spelled out rather than imported. `markdown` belongs to a\n * plugin, which core may never import; `collectionEntryBody` is exported by\n * `collection-entries.ts`, but that module is 1,860 lines and drags\n * `content-authors.ts` behind it, and this one is deliberately outside the\n * barrel that ships to published pages. A persisted component id is a string\n * that cannot change — renaming one orphans every document that stores it —\n * so the copy cannot drift in the way an imported value would protect against.\n */\nconst MARKDOWN_BODY_PROPS: Readonly<Record<string, string>> = {\n markdown: 'content',\n collectionEntryBody: 'markdown',\n}\n\n/** The root of a composed map, where a walk in document order starts. */\nconst ROOT_NODE_ID: string = CANVAS_ROOT_ELEMENT_ID\n\n/**\n * What a readable asset's media document records, as the overlay consumes it.\n *\n * Raw on purpose: {@link intrinsicMediaSize} and {@link videoMediaProps} are\n * where a pair and a `video` record are bounded, and a second reading of the\n * same numbers here is how two files come to disagree about what a partial\n * record means.\n */\nexport interface MediaAssetFacts {\n /** The document's `width`: an image's, read from its bytes at upload. */\n width?: unknown\n /** The document's `height`, the other half of {@link width}. */\n height?: unknown\n /** The document's `video` record: `durationMs`, `width` and `height`. */\n video?: unknown\n /** The document's generated `poster` record, when it has one. */\n poster?: unknown\n /**\n * The document's `contentHash`, which a replace changes with the bytes. An\n * image placement carries it as `mediaVersion`, and the URL it renders is\n * then the versioned one the CDN lets every cache keep (AGL-3485).\n */\n contentHash?: unknown\n}\n\n/**\n * Every field an asset's facts are decided from, and the projection a reader\n * asks Firestore for: ONE list, whichever surface reads. `width` and `height`\n * (an image's) and `video` and `poster` (a film's) are the facts. The other\n * three are the gates `serveMediaCdn` applies before it will serve an asset at\n * all, so no surface shows the shape of a file its page's URL refuses.\n */\nexport const MEDIA_ASSET_FACT_FIELDS = [\n 'width',\n 'height',\n 'video',\n 'poster',\n 'contentHash',\n 'deletedAt',\n 'private',\n 'visibleTo',\n] as const\n\n/** An asset's media document, as far as {@link MEDIA_ASSET_FACT_FIELDS} reach. */\nexport type MediaAssetDocument = Partial<\n Record<(typeof MEDIA_ASSET_FACT_FIELDS)[number], unknown>\n>\n\n/** The elements whose placements follow their file. */\nexport type MediaAssetElement =\n | typeof IMAGE_COMPONENT_ID\n | typeof VIDEO_COMPONENT_ID\n\nexport interface MediaAssetFactsOptions {\n /**\n * One element's placements only, by persisted component id. Absent means\n * both, which is what the composition asks for.\n */\n only?: MediaAssetElement\n}\n\n/** A node as the composed map holds it: flat, children by id. */\ninterface ComposedMediaNode {\n componentId?: string\n nodes?: unknown\n props?: Record<string, unknown>\n resolvedProps?: Record<string, unknown>\n}\n\nconst owns = (map: object, key: string) =>\n Object.prototype.hasOwnProperty.call(map, key)\n\n/**\n * The key an asset's facts are filed under: the reference's own scope and id.\n *\n * Deliberately NOT the host-qualified scope a page renders. The document lives\n * under the scope's owner whichever site places it, and which site may be\n * shown it is the reader's question, answered once per page.\n */\nexport function mediaAssetFactsKey(\n ref: Pick<MediaRef, 'scope' | 'mediaId'>,\n): string {\n return `${ref.scope}/${ref.mediaId}`\n}\n\n/**\n * Where an asset's media document lives: under the scope's OWNER, `orgs/` for\n * the org library and `hosts/` for a site's own, whichever site places it.\n * `null` for a scope the CDN would not parse, which no read can answer for.\n */\nexport function mediaAssetDocumentPath(\n ref: Pick<MediaRef, 'scope' | 'mediaId'>,\n): string | null {\n const scope = parseMediaCdnScope(ref.scope)\n if (!scope) return null\n return `${scope.isOrg ? 'orgs' : 'hosts'}/${scope.scopeId}/media/${ref.mediaId}`\n}\n\n/**\n * The facts one read of an asset's document yields for a placement rendered\n * on `hostId`'s pages, or `undefined` when the placement keeps its stored\n * props.\n *\n * An answer exists only for a document that was read, is live, is not\n * private, and is visible to that site under the host-qualified scope the page\n * renders: the verdict the CDN reaches when the browser asks for the bytes.\n * The URL a page renders names the site doing the rendering\n * (`resolveMediaSrc`), so visibility is asked of THAT scope, not of the scope\n * the reference was stored with.\n */\nexport function mediaAssetFactsFromDocument(\n document: MediaAssetDocument | null | undefined,\n ref: Pick<MediaRef, 'scope'>,\n hostId: string,\n): MediaAssetFacts | undefined {\n if (!document) return undefined\n if (document.deletedAt || document.private === true) return undefined\n const served = parseMediaCdnScope(hostQualifiedScope(ref.scope, hostId))\n if (!served || mediaCdnScopeRefusal(served, document.visibleTo)) {\n return undefined\n }\n return {\n width: document.width,\n height: document.height,\n video: document.video,\n poster: document.poster,\n contentHash: document.contentHash,\n }\n}\n\n/** The library asset an Image or Video node places, or null for anything else. */\nfunction placedAsset(\n node: ComposedMediaNode | null | undefined,\n only?: MediaAssetElement,\n): MediaRef | null {\n const componentId = node?.componentId\n if (componentId !== IMAGE_COMPONENT_ID && componentId !== VIDEO_COMPONENT_ID) {\n return null\n }\n if (only && componentId !== only) return null\n // The precedence every other reader of the composed map uses: a node inside\n // a repeated collection carries its bound values in the resolved copy.\n const props = node?.resolvedProps ?? node?.props\n return placedRef(props?.['src'])\n}\n\n/**\n * The library asset a stored `src` names: a `media:` reference, or the\n * site-relative CDN path the first media picker wrote before references\n * existed (AGL-1215). Both name one asset by its id, and the path's are among\n * the oldest placements on the platform — the ones that most need their file's\n * shape read back, since nothing copied it onto the node when they were made.\n * Only the strict root-relative path: a hotlink on another host that happens\n * to contain our route names nothing of ours.\n */\nfunction placedRef(src: unknown): MediaRef | null {\n if (isMediaCdnPath(src)) return parseMediaRef(mediaRefFromCdnPath(src))\n return parseMediaRef(src)\n}\n\n/** A compose-time token the tenant has not substituted — never a document. */\nconst UNRESOLVED_TOKEN = /^\\{\\{[^}]+\\}\\}$/\n\n/**\n * The markdown-lite document a node holds, or `''` for a node holding none.\n *\n * `resolvedProps` first, for the reason {@link placedAsset} gives: an entry\n * body is the literal `{{entry.body}}` in `props` and the entry's real text in\n * the resolved copy. An unsubstituted token is not a document — it can name no\n * asset — so it is dropped here rather than walked for images that a canvas\n * surface would never find.\n */\nfunction markdownBodyOf(\n props: Record<string, unknown> | undefined,\n componentId: string | undefined,\n): string {\n const prop =\n componentId && owns(MARKDOWN_BODY_PROPS, componentId)\n ? MARKDOWN_BODY_PROPS[componentId]\n : undefined\n const text = prop ? props?.[prop] : undefined\n if (typeof text !== 'string' || UNRESOLVED_TOKEN.test(text.trim())) return ''\n return text\n}\n\n/** See {@link markdownBodyOf} — the body the page will actually render. */\nfunction markdownBody(node: ComposedMediaNode | null | undefined): string {\n return markdownBodyOf(\n node?.resolvedProps ?? node?.props,\n node?.componentId,\n )\n}\n\n/**\n * A markdown-lite image: ``, capturing only the target, and only\n * up to the first whitespace or `)`.\n *\n * That is the whole of the syntax `markdown-lite.ts` accepts — no title string\n * after the target, no angle-bracket form — so there is nowhere else in a body\n * for a reference to hide, and matching more than the parser does would name\n * assets the renderer never asks for.\n */\nconst MARKDOWN_IMAGE_TARGET = /!\\[[^\\]]*\\]\\(\\s*([^)\\s]+)/g\n\n/**\n * Every library asset a markdown body's images name, in the order the body\n * names them, each beside the target EXACTLY as the body wrote it.\n *\n * The raw target is carried because that is the key the renderer has: it holds\n * the parsed block's `src`, the same string, and looking a pair up by it costs\n * no second parse per image on every render.\n *\n * A target that is not a `media:` reference yields nothing — a hotlinked URL\n * and a legacy stored path have no DAM document to read, and the renderer\n * gives those today's markup unchanged.\n */\nfunction markdownImageRefs(\n text: string,\n): Array<{ target: string; ref: MediaRef }> {\n if (!text.includes('![')) return []\n const found: Array<{ target: string; ref: MediaRef }> = []\n for (const match of text.matchAll(MARKDOWN_IMAGE_TARGET)) {\n const target = match[1]\n const ref = parseMediaRef(target)\n if (ref) found.push({ target, ref })\n }\n return found\n}\n\n/**\n * The map's node ids in document order: depth first from the root through\n * each node's child ids, then every id the walk never reached (a map with no\n * root, an orphan) in the order the map lists it. That puts the top of the\n * page ahead of its footer, and it is the same order for the same map.\n */\nfunction documentOrder(nodes: Record<string, unknown>): string[] {\n const order: string[] = []\n const seen = new Set<string>()\n const stack = owns(nodes, ROOT_NODE_ID) ? [ROOT_NODE_ID] : []\n while (stack.length) {\n const id = stack.pop() as string\n if (seen.has(id) || !owns(nodes, id)) continue\n seen.add(id)\n order.push(id)\n const children = (nodes[id] as ComposedMediaNode | null)?.nodes\n if (!Array.isArray(children)) continue\n for (let index = children.length - 1; index >= 0; index -= 1) {\n const child = children[index]\n if (typeof child === 'string' && !seen.has(child)) stack.push(child)\n }\n }\n for (const id in nodes) if (!seen.has(id)) order.push(id)\n return order\n}\n\n/**\n * Every distinct library asset the Image and Video nodes in a map place:\n * films first, then images, each in document order.\n *\n * A read that is capped honors that order. A film goes first because its\n * stale facts are the worse render (a player of the wrong shape and a\n * thumbnail that 404s, against a reservation that corrects itself when an\n * image decodes), and document order covers the top of the page before its\n * footer.\n *\n * `[]` for a page that places none, so a caller that gates its read on the\n * length spends nothing on it. A pinned and an unpinned reference to one\n * asset are one entry: a pin names bytes, not a different asset.\n */\nexport function mediaAssetRefs(\n nodes: Record<string, unknown> | null | undefined,\n options: MediaAssetFactsOptions = {},\n): MediaRef[] {\n const refs: MediaRef[] = []\n if (!nodes) return refs\n const order = documentOrder(nodes)\n const seen = new Set<string>()\n for (const element of [VIDEO_COMPONENT_ID, IMAGE_COMPONENT_ID] as const) {\n if (options.only && options.only !== element) continue\n for (const id of order) {\n const node = nodes[id] as ComposedMediaNode | null\n if (node?.componentId !== element) continue\n const ref = placedAsset(node)\n if (!ref) continue\n const key = mediaAssetFactsKey(ref)\n if (seen.has(key)) continue\n seen.add(key)\n refs.push(ref)\n }\n }\n // A markdown body's images come LAST, and only when the caller wants every\n // element (AGL-3149). Last because of what a capped read costs each kind: a\n // placement that misses out renders at its pick-time pair, a body image that\n // misses out renders exactly as it does today, and a film that misses out\n // gets a player of the wrong shape. Only-when-unfiltered because `only` asks\n // for one ELEMENT's placements, and a body image is not a placement of the\n // Image element — the video-asset reader would otherwise read image\n // documents it has no use for.\n if (options.only) return refs\n for (const id of order) {\n const body = markdownBody(nodes[id] as ComposedMediaNode | null)\n for (const { ref } of markdownImageRefs(body)) {\n const key = mediaAssetFactsKey(ref)\n if (seen.has(key)) continue\n seen.add(key)\n refs.push(ref)\n }\n }\n return refs\n}\n\nconst usable = (value: unknown): value is number =>\n typeof value === 'number' && Number.isFinite(value) && value > 0\n\n/** A film's props with its asset's facts laid over them. See the module note. */\nfunction withFilmFacts(\n props: Record<string, unknown>,\n facts: MediaAssetFacts,\n): Record<string, unknown> {\n const live = videoMediaProps({\n componentId: VIDEO_COMPONENT_ID,\n propName: 'src',\n assetVideo: facts.video,\n assetPoster: facts.poster,\n })\n const {\n durationSeconds,\n intrinsicWidth,\n intrinsicHeight,\n posterFromSource: _storedPosterFlag,\n ...next\n } = props\n // The pick writes a duration only beside the pixel pair, so a pair is what\n // marks the stored duration as a copy rather than an author's own.\n const typedByAuthor = !(usable(intrinsicWidth) && usable(intrinsicHeight))\n if (live.durationSeconds !== undefined) {\n next['durationSeconds'] = live.durationSeconds\n } else if (typedByAuthor && durationSeconds !== undefined) {\n next['durationSeconds'] = durationSeconds\n }\n if (live.intrinsicWidth !== undefined && live.intrinsicHeight !== undefined) {\n next['intrinsicWidth'] = live.intrinsicWidth\n next['intrinsicHeight'] = live.intrinsicHeight\n }\n if (live.posterFromSource) next['posterFromSource'] = true\n return next\n}\n\n/**\n * An image's props with its asset's pair laid over them, or the SAME object\n * when the document records no usable pair or the stored one already matches.\n * See the module note.\n */\nfunction withImageFacts(\n props: Record<string, unknown>,\n facts: MediaAssetFacts,\n): Record<string, unknown> {\n // Through the pick's own gate, so the overlay and the pick agree on what a\n // usable pair is: both halves, finite and positive.\n const live = intrinsicMediaSize({\n componentId: IMAGE_COMPONENT_ID,\n propName: 'src',\n assetWidth: facts.width,\n assetHeight: facts.height,\n })\n const version = mediaVersionOf(facts)\n const pair =\n live.intrinsicWidth !== undefined && live.intrinsicHeight !== undefined\n const pairChanged =\n pair &&\n (props['intrinsicWidth'] !== live.intrinsicWidth ||\n props['intrinsicHeight'] !== live.intrinsicHeight)\n const versionChanged =\n version !== undefined && props[IMAGE_MEDIA_VERSION_PROP] !== version\n if (!pairChanged && !versionChanged) return props\n return {\n ...props,\n ...(pairChanged\n ? {\n intrinsicWidth: live.intrinsicWidth,\n intrinsicHeight: live.intrinsicHeight,\n }\n : {}),\n ...(versionChanged ? { [IMAGE_MEDIA_VERSION_PROP]: version } : {}),\n }\n}\n\n/**\n * The prop an Image placement carries its asset's current content hash in\n * (AGL-3485). Laid on at composition like the pixel pair and never an author\n * control: it describes the file, and `image.tsx` hands it to\n * `resolveMediaSrc` so the page names the versioned URL.\n */\nexport const IMAGE_MEDIA_VERSION_PROP = 'mediaVersion'\n\n/** The document's content hash, when it is one a URL can carry. */\nfunction mediaVersionOf(facts: MediaAssetFacts): string | undefined {\n return mediaCdnVersionToken(facts.contentHash) === undefined\n ? undefined\n : (facts.contentHash as string)\n}\n\n/**\n * The prop a markdown body carries its images' pixel pairs in, keyed by the\n * target the body wrote (AGL-3149).\n *\n * A body image is not a node, so it cannot take `intrinsicWidth` and\n * `intrinsicHeight` the way a placement does; the pairs travel together on the\n * element that holds the document, and the renderer looks each one up by the\n * parsed block's `src`.\n */\nexport const BODY_IMAGE_SIZES_PROP = 'intrinsicSizes'\n\n/** One body image's pair, as {@link BODY_IMAGE_SIZES_PROP} carries it. */\nexport interface BodyImageSize {\n width: number\n height: number\n /** The asset's content hash, for the versioned URL (AGL-3485). */\n version?: string\n}\n\n/**\n * A markdown body's props with a pair for each library image it names, or the\n * SAME object when no image in it can be answered for.\n *\n * Only images whose document records a usable pair get an entry, through the\n * same {@link intrinsicMediaSize} gate a placement goes through. An image left\n * out is one the renderer must give today's markup: `srcSet` without the pair\n * makes `sizes` the image's rendered width, which upscales anything narrower\n * than the column, so a partial answer is worse here than no answer.\n */\nfunction withBodyImageFacts(\n props: Record<string, unknown>,\n componentId: string | undefined,\n facts: ReadonlyMap<string, MediaAssetFacts>,\n): Record<string, unknown> {\n // THIS object's own body, never the node's resolved one: `props` on a bound\n // entry body still holds the `{{entry.body}}` token, and pairs for images it\n // does not name are bytes in the tree that nothing can ever look up.\n let sizes: Record<string, BodyImageSize> | undefined\n for (const { target, ref } of markdownImageRefs(\n markdownBodyOf(props, componentId),\n )) {\n const found = facts.get(mediaAssetFactsKey(ref))\n if (!found) continue\n const live = intrinsicMediaSize({\n componentId: IMAGE_COMPONENT_ID,\n propName: 'src',\n assetWidth: found.width,\n assetHeight: found.height,\n })\n if (\n live.intrinsicWidth === undefined ||\n live.intrinsicHeight === undefined\n ) {\n continue\n }\n if (!sizes) sizes = {}\n const version = mediaVersionOf(found)\n sizes[target] = {\n width: live.intrinsicWidth,\n height: live.intrinsicHeight,\n ...(version ? { version } : {}),\n }\n }\n if (!sizes) return props\n return { ...props, [BODY_IMAGE_SIZES_PROP]: sizes }\n}\n\n/**\n * The composed map with each placed asset's facts laid over its node, and each\n * markdown body's images' pairs laid over the element holding the body.\n *\n * `facts` is keyed by {@link mediaAssetFactsKey}. A placement with no entry,\n * because the reader could not answer for its asset, keeps its stored props.\n * The SAME map comes back when nothing changes, so a page with no library\n * asset pays for one walk and no copy, and the input is never mutated either\n * way.\n */\nexport function applyMediaAssetFacts<T extends Record<string, unknown>>(\n nodes: T,\n facts: ReadonlyMap<string, MediaAssetFacts>,\n options: MediaAssetFactsOptions = {},\n): T {\n if (!facts.size) return nodes\n let applied: Record<string, unknown> | undefined\n const write = (id: string, node: ComposedMediaNode, next: {\n props?: Record<string, unknown>\n resolvedProps?: Record<string, unknown>\n }): void => {\n if (!applied) applied = { ...nodes }\n applied[id] = {\n ...node,\n ...(next.props ? { props: next.props } : {}),\n ...(next.resolvedProps ? { resolvedProps: next.resolvedProps } : {}),\n }\n }\n for (const id in nodes) {\n const node = nodes[id] as ComposedMediaNode\n const ref = placedAsset(node, options.only)\n const found = ref ? facts.get(mediaAssetFactsKey(ref)) : undefined\n if (found) {\n const overlay =\n node.componentId === VIDEO_COMPONENT_ID ? withFilmFacts : withImageFacts\n const props = node.props && overlay(node.props, found)\n const resolvedProps =\n node.resolvedProps && overlay(node.resolvedProps, found)\n if (props === node.props && resolvedProps === node.resolvedProps) continue\n write(id, node, { props, resolvedProps })\n continue\n }\n // A markdown body, under the same `only` rule `mediaAssetRefs` collects\n // under: a body image is not a placement of the Image element, so a reader\n // asking for one element's placements is not asking about bodies.\n if (options.only) continue\n const { componentId } = node\n if (!componentId || !owns(MARKDOWN_BODY_PROPS, componentId)) continue\n const props =\n node.props && withBodyImageFacts(node.props, componentId, facts)\n const resolvedProps =\n node.resolvedProps &&\n withBodyImageFacts(node.resolvedProps, componentId, facts)\n if (props === node.props && resolvedProps === node.resolvedProps) continue\n write(id, node, { props, resolvedProps })\n }\n return applied ? (applied as T) : nodes\n}\n"],"names":["CANVAS_ROOT_ELEMENT_ID","mediaCdnScopeRefusal","parseMediaCdnScope","intrinsicMediaSize","videoMediaProps","hostQualifiedScope","isMediaCdnPath","mediaCdnVersionToken","mediaRefFromCdnPath","parseMediaRef","VIDEO_COMPONENT_ID","IMAGE_COMPONENT_ID","MARKDOWN_BODY_PROPS","markdown","collectionEntryBody","ROOT_NODE_ID","MEDIA_ASSET_FACT_FIELDS","owns","map","key","Object","prototype","hasOwnProperty","call","mediaAssetFactsKey","ref","scope","mediaId","mediaAssetDocumentPath","isOrg","scopeId","mediaAssetFactsFromDocument","document","hostId","undefined","deletedAt","private","served","visibleTo","width","height","video","poster","contentHash","placedAsset","node","only","componentId","props","resolvedProps","placedRef","src","UNRESOLVED_TOKEN","markdownBodyOf","prop","text","test","trim","markdownBody","MARKDOWN_IMAGE_TARGET","markdownImageRefs","includes","found","match","matchAll","target","push","documentOrder","nodes","order","seen","Set","stack","length","id","pop","has","add","children","Array","isArray","index","child","mediaAssetRefs","options","refs","element","body","usable","value","Number","isFinite","withFilmFacts","facts","live","propName","assetVideo","assetPoster","durationSeconds","intrinsicWidth","intrinsicHeight","posterFromSource","_storedPosterFlag","next","typedByAuthor","withImageFacts","assetWidth","assetHeight","version","mediaVersionOf","pair","pairChanged","versionChanged","IMAGE_MEDIA_VERSION_PROP","BODY_IMAGE_SIZES_PROP","withBodyImageFacts","sizes","get","applyMediaAssetFacts","size","applied","write","overlay"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmEC,GAED,SAASA,sBAAsB,QAAQ,oCAAgC;AACvE,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,uBAAmB;AAC5E,SAASC,kBAAkB,EAAEC,eAAe,QAAQ,sBAAkB;AACtE,SACEC,kBAAkB,EAClBC,cAAc,EACdC,oBAAoB,EAEpBC,mBAAmB,EACnBC,aAAa,QACR,iBAAa;AACpB,SAASC,kBAAkB,QAAQ,oBAAgB;AAEnD,6EAA6E,GAC7E,OAAO,MAAMC,qBAAqB,QAAO;AAEzC;;;;;;;;;;;;;;;;CAgBC,GACD,MAAMC,sBAAwD;IAC5DC,UAAU;IACVC,qBAAqB;AACvB;AAEA,uEAAuE,GACvE,MAAMC,eAAuBf;AA2B7B;;;;;;CAMC,GACD,OAAO,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yright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The analytics day-document field the media CDN adds its counted bytes to.
|
|
19
|
+
*
|
|
20
|
+
* Top level, beside `total`, rather than inside the per-asset `media` map:
|
|
21
|
+
* the meter needs one number per day, and summing a map keyed by every asset
|
|
22
|
+
* in a library would make each reader walk the whole library to find it.
|
|
23
|
+
*/
|
|
24
|
+
export declare const MEDIA_BANDWIDTH_DAY_FIELD = "mediaBandwidthBytes";
|
|
25
|
+
/**
|
|
26
|
+
* Counted media bytes as the page views the bandwidth band is kept in, at
|
|
27
|
+
* {@link ORIGIN_MEDIA_BANDWIDTH_WEIGHT} — the one place the weight is applied.
|
|
28
|
+
*/
|
|
29
|
+
export declare function pageViewsFromMediaBytes(bytes: unknown): number;
|
|
30
|
+
/** One stretch of analytics day documents, as bandwidth. */
|
|
31
|
+
export interface AnalyticsBandwidthReading {
|
|
32
|
+
/** Page views the analytics beacon counted. */
|
|
33
|
+
pageViews: number;
|
|
34
|
+
/** Video and file bytes the media CDN counted, as served — unweighted. */
|
|
35
|
+
mediaBytes: number;
|
|
36
|
+
/**
|
|
37
|
+
* Both, in page views, the media at its weight — the figure the band, the
|
|
38
|
+
* cap, the ceiling and the invoice are measured in. Fractional once media
|
|
39
|
+
* is in it; round only for display.
|
|
40
|
+
*/
|
|
41
|
+
meteredPageViews: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Sum analytics day documents into the bandwidth they record.
|
|
45
|
+
*
|
|
46
|
+
* Takes anything with `get(field)`, which is what an Admin SDK snapshot and a
|
|
47
|
+
* client SDK snapshot both are, so the routes and the Billing card read the
|
|
48
|
+
* same documents through the same function.
|
|
49
|
+
*/
|
|
50
|
+
export declare function analyticsBandwidthReading(days: Iterable<{
|
|
51
|
+
get(field: string): unknown;
|
|
52
|
+
}>): AnalyticsBandwidthReading;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /**
|
|
17
|
+
* Video and file delivery counted against the bandwidth band (AGL-3474).
|
|
18
|
+
*
|
|
19
|
+
* ## What it counts
|
|
20
|
+
*
|
|
21
|
+
* Every byte the media CDN sends of a type the edge must never hold — video,
|
|
22
|
+
* audio, PDFs, documents, anything that is not an image (`mediaCdnEdgeCacheable`,
|
|
23
|
+
* AGL-1515). Those responses are `private`, so each one is served from origin:
|
|
24
|
+
* Vercel's transfer, its origin transfer and the Storage read are paid on every
|
|
25
|
+
* request, and before this nothing put them in front of the band, the meter,
|
|
26
|
+
* the invoice or the Free cap. A video the delivery provider serves (AGL-2824)
|
|
27
|
+
* counts the bytes its redirect hands over, so moving a film off origin never
|
|
28
|
+
* moves it off the meter.
|
|
29
|
+
*
|
|
30
|
+
* Images are NOT counted here. They are edge-cached, and a page's images are
|
|
31
|
+
* already inside the weight one page view is converted at
|
|
32
|
+
* (`ESTIMATED_PAGE_TRANSFER_BYTES` is measured on a settled page, pictures
|
|
33
|
+
* included), so counting their bytes again would bill them twice.
|
|
34
|
+
*
|
|
35
|
+
* ## How it is carried
|
|
36
|
+
*
|
|
37
|
+
* As BYTES, on the analytics day document the CDN already writes for each
|
|
38
|
+
* served asset — `hosts/{id}/analytics/{day}` for a site's library and
|
|
39
|
+
* `orgs/{id}/analytics/{day}` for the org library — in the same write that
|
|
40
|
+
* records the asset's serves, so counting adds no write to any request.
|
|
41
|
+
*
|
|
42
|
+
* And as PAGE VIEWS wherever bandwidth is measured, because the band is a
|
|
43
|
+
* page-view band: `bandwidthGb` is converted to views through
|
|
44
|
+
* `ESTIMATED_PAGE_TRANSFER_BYTES`, the meter counts views, and the invoice
|
|
45
|
+
* prices views. Media bytes are converted through the same constant, and
|
|
46
|
+
* every reader — the invoice, the Free cap, the abuse ceiling, the usage
|
|
47
|
+
* alerts and the Billing meter — sums one figure through
|
|
48
|
+
* {@link analyticsBandwidthReading} rather than each deciding for itself.
|
|
49
|
+
*
|
|
50
|
+
* ## At a weight
|
|
51
|
+
*
|
|
52
|
+
* A gigabyte served from origin costs more than a gigabyte of pages, so it
|
|
53
|
+
* counts as {@link ORIGIN_MEDIA_BANDWIDTH_WEIGHT} gigabytes of the band —
|
|
54
|
+
* derived beside the cost basis in `plan-entitlements.ts`, as the smallest
|
|
55
|
+
* weight at which both the overage and the band earn cost + 30% after card
|
|
56
|
+
* fees. It is applied in {@link pageViewsFromMediaBytes} and nowhere else, so
|
|
57
|
+
* the wall, the meter and the bill cannot count a film differently.
|
|
58
|
+
*/ import { ESTIMATED_PAGE_TRANSFER_BYTES, ORIGIN_MEDIA_BANDWIDTH_WEIGHT } from "./plan-entitlements.js";
|
|
59
|
+
/**
|
|
60
|
+
* The analytics day-document field the media CDN adds its counted bytes to.
|
|
61
|
+
*
|
|
62
|
+
* Top level, beside `total`, rather than inside the per-asset `media` map:
|
|
63
|
+
* the meter needs one number per day, and summing a map keyed by every asset
|
|
64
|
+
* in a library would make each reader walk the whole library to find it.
|
|
65
|
+
*/ export const MEDIA_BANDWIDTH_DAY_FIELD = 'mediaBandwidthBytes';
|
|
66
|
+
/**
|
|
67
|
+
* Counted media bytes as the page views the bandwidth band is kept in, at
|
|
68
|
+
* {@link ORIGIN_MEDIA_BANDWIDTH_WEIGHT} — the one place the weight is applied.
|
|
69
|
+
*/ export function pageViewsFromMediaBytes(bytes) {
|
|
70
|
+
const value = Number(bytes);
|
|
71
|
+
return Number.isFinite(value) && value > 0 ? value * ORIGIN_MEDIA_BANDWIDTH_WEIGHT / ESTIMATED_PAGE_TRANSFER_BYTES : 0;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Sum analytics day documents into the bandwidth they record.
|
|
75
|
+
*
|
|
76
|
+
* Takes anything with `get(field)`, which is what an Admin SDK snapshot and a
|
|
77
|
+
* client SDK snapshot both are, so the routes and the Billing card read the
|
|
78
|
+
* same documents through the same function.
|
|
79
|
+
*/ export function analyticsBandwidthReading(days) {
|
|
80
|
+
let pageViews = 0;
|
|
81
|
+
let mediaBytes = 0;
|
|
82
|
+
for (const day of days){
|
|
83
|
+
var _day_get, _day_get1;
|
|
84
|
+
pageViews += Math.max(0, Number((_day_get = day.get('total')) != null ? _day_get : 0) || 0);
|
|
85
|
+
mediaBytes += Math.max(0, Number((_day_get1 = day.get(MEDIA_BANDWIDTH_DAY_FIELD)) != null ? _day_get1 : 0) || 0);
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
pageViews,
|
|
89
|
+
mediaBytes,
|
|
90
|
+
meteredPageViews: pageViews + pageViewsFromMediaBytes(mediaBytes)
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=media-bandwidth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/media-bandwidth.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Video and file delivery counted against the bandwidth band (AGL-3474).\n *\n * ## What it counts\n *\n * Every byte the media CDN sends of a type the edge must never hold — video,\n * audio, PDFs, documents, anything that is not an image (`mediaCdnEdgeCacheable`,\n * AGL-1515). Those responses are `private`, so each one is served from origin:\n * Vercel's transfer, its origin transfer and the Storage read are paid on every\n * request, and before this nothing put them in front of the band, the meter,\n * the invoice or the Free cap. A video the delivery provider serves (AGL-2824)\n * counts the bytes its redirect hands over, so moving a film off origin never\n * moves it off the meter.\n *\n * Images are NOT counted here. They are edge-cached, and a page's images are\n * already inside the weight one page view is converted at\n * (`ESTIMATED_PAGE_TRANSFER_BYTES` is measured on a settled page, pictures\n * included), so counting their bytes again would bill them twice.\n *\n * ## How it is carried\n *\n * As BYTES, on the analytics day document the CDN already writes for each\n * served asset — `hosts/{id}/analytics/{day}` for a site's library and\n * `orgs/{id}/analytics/{day}` for the org library — in the same write that\n * records the asset's serves, so counting adds no write to any request.\n *\n * And as PAGE VIEWS wherever bandwidth is measured, because the band is a\n * page-view band: `bandwidthGb` is converted to views through\n * `ESTIMATED_PAGE_TRANSFER_BYTES`, the meter counts views, and the invoice\n * prices views. Media bytes are converted through the same constant, and\n * every reader — the invoice, the Free cap, the abuse ceiling, the usage\n * alerts and the Billing meter — sums one figure through\n * {@link analyticsBandwidthReading} rather than each deciding for itself.\n *\n * ## At a weight\n *\n * A gigabyte served from origin costs more than a gigabyte of pages, so it\n * counts as {@link ORIGIN_MEDIA_BANDWIDTH_WEIGHT} gigabytes of the band —\n * derived beside the cost basis in `plan-entitlements.ts`, as the smallest\n * weight at which both the overage and the band earn cost + 30% after card\n * fees. It is applied in {@link pageViewsFromMediaBytes} and nowhere else, so\n * the wall, the meter and the bill cannot count a film differently.\n */\n\nimport {\n ESTIMATED_PAGE_TRANSFER_BYTES,\n ORIGIN_MEDIA_BANDWIDTH_WEIGHT,\n} from './plan-entitlements'\n\n/**\n * The analytics day-document field the media CDN adds its counted bytes to.\n *\n * Top level, beside `total`, rather than inside the per-asset `media` map:\n * the meter needs one number per day, and summing a map keyed by every asset\n * in a library would make each reader walk the whole library to find it.\n */\nexport const MEDIA_BANDWIDTH_DAY_FIELD = 'mediaBandwidthBytes'\n\n/**\n * Counted media bytes as the page views the bandwidth band is kept in, at\n * {@link ORIGIN_MEDIA_BANDWIDTH_WEIGHT} — the one place the weight is applied.\n */\nexport function pageViewsFromMediaBytes(bytes: unknown): number {\n const value = Number(bytes)\n return Number.isFinite(value) && value > 0\n ? (value * ORIGIN_MEDIA_BANDWIDTH_WEIGHT) / ESTIMATED_PAGE_TRANSFER_BYTES\n : 0\n}\n\n/** One stretch of analytics day documents, as bandwidth. */\nexport interface AnalyticsBandwidthReading {\n /** Page views the analytics beacon counted. */\n pageViews: number\n /** Video and file bytes the media CDN counted, as served — unweighted. */\n mediaBytes: number\n /**\n * Both, in page views, the media at its weight — the figure the band, the\n * cap, the ceiling and the invoice are measured in. Fractional once media\n * is in it; round only for display.\n */\n meteredPageViews: number\n}\n\n/**\n * Sum analytics day documents into the bandwidth they record.\n *\n * Takes anything with `get(field)`, which is what an Admin SDK snapshot and a\n * client SDK snapshot both are, so the routes and the Billing card read the\n * same documents through the same function.\n */\nexport function analyticsBandwidthReading(\n days: Iterable<{ get(field: string): unknown }>,\n): AnalyticsBandwidthReading {\n let pageViews = 0\n let mediaBytes = 0\n for (const day of days) {\n pageViews += Math.max(0, Number(day.get('total') ?? 0) || 0)\n mediaBytes += Math.max(0, Number(day.get(MEDIA_BANDWIDTH_DAY_FIELD) ?? 0) || 0)\n }\n return {\n pageViews,\n mediaBytes,\n meteredPageViews: pageViews + pageViewsFromMediaBytes(mediaBytes),\n }\n}\n"],"names":["ESTIMATED_PAGE_TRANSFER_BYTES","ORIGIN_MEDIA_BANDWIDTH_WEIGHT","MEDIA_BANDWIDTH_DAY_FIELD","pageViewsFromMediaBytes","bytes","value","Number","isFinite","analyticsBandwidthReading","days","pageViews","mediaBytes","day","Math","max","get","meteredPageViews"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CC,GAED,SACEA,6BAA6B,EAC7BC,6BAA6B,QACxB,yBAAqB;AAE5B;;;;;;CAMC,GACD,OAAO,MAAMC,4BAA4B,sBAAqB;AAE9D;;;CAGC,GACD,OAAO,SAASC,wBAAwBC,KAAc;IACpD,MAAMC,QAAQC,OAAOF;IACrB,OAAOE,OAAOC,QAAQ,CAACF,UAAUA,QAAQ,IACrC,AAACA,QAAQJ,gCAAiCD,gCAC1C;AACN;AAgBA;;;;;;CAMC,GACD,OAAO,SAASQ,0BACdC,IAA+C;IAE/C,IAAIC,YAAY;IAChB,IAAIC,aAAa;IACjB,KAAK,MAAMC,OAAOH,KAAM;YACUG,UACCA;QADjCF,aAAaG,KAAKC,GAAG,CAAC,GAAGR,QAAOM,WAAAA,IAAIG,GAAG,CAAC,oBAARH,WAAoB,MAAM;QAC1DD,cAAcE,KAAKC,GAAG,CAAC,GAAGR,QAAOM,YAAAA,IAAIG,GAAG,CAACb,sCAARU,YAAsC,MAAM;IAC/E;IACA,OAAO;QACLF;QACAC;QACAK,kBAAkBN,YAAYP,wBAAwBQ;IACxD;AACF"}
|