@hagicode/hagilight-core 0.18.0 → 0.19.1-dev.185.1.a85e2a8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/Analytics51LA.astro +19 -3
  2. package/CookieConsent.astro +402 -0
  3. package/Footer.astro +31 -5
  4. package/FooterBrand.astro +23 -3
  5. package/GoogleAnalytics.astro +17 -2
  6. package/PostHog.astro +55 -3
  7. package/PromotoBanner.astro +3 -3
  8. package/README.md +102 -8
  9. package/dist/analytics-events.d.ts +15 -0
  10. package/dist/analytics-events.js +25 -15
  11. package/dist/consent-copy/de-DE.d.ts +2 -0
  12. package/dist/consent-copy/de-DE.js +21 -0
  13. package/dist/consent-copy/en-US.d.ts +2 -0
  14. package/dist/consent-copy/en-US.js +21 -0
  15. package/dist/consent-copy/es-ES.d.ts +2 -0
  16. package/dist/consent-copy/es-ES.js +21 -0
  17. package/dist/consent-copy/fr-FR.d.ts +2 -0
  18. package/dist/consent-copy/fr-FR.js +21 -0
  19. package/dist/consent-copy/index.d.ts +7 -0
  20. package/dist/consent-copy/index.js +31 -0
  21. package/dist/consent-copy/ja-JP.d.ts +2 -0
  22. package/dist/consent-copy/ja-JP.js +21 -0
  23. package/dist/consent-copy/ko-KR.d.ts +2 -0
  24. package/dist/consent-copy/ko-KR.js +21 -0
  25. package/dist/consent-copy/pt-BR.d.ts +2 -0
  26. package/dist/consent-copy/pt-BR.js +21 -0
  27. package/dist/consent-copy/ru-RU.d.ts +2 -0
  28. package/dist/consent-copy/ru-RU.js +21 -0
  29. package/dist/consent-copy/types.d.ts +22 -0
  30. package/dist/consent-copy/types.js +1 -0
  31. package/dist/consent-copy/zh-CN.d.ts +2 -0
  32. package/dist/consent-copy/zh-CN.js +21 -0
  33. package/dist/consent-copy/zh-Hant.d.ts +2 -0
  34. package/dist/consent-copy/zh-Hant.js +21 -0
  35. package/dist/consent-details.d.ts +29 -0
  36. package/dist/consent-details.js +41 -0
  37. package/dist/consent-gate.d.ts +47 -0
  38. package/dist/consent-gate.js +243 -0
  39. package/dist/consent-markup.d.ts +33 -0
  40. package/dist/consent-markup.js +113 -0
  41. package/dist/consent-mount.d.ts +26 -0
  42. package/dist/consent-mount.js +81 -0
  43. package/dist/consent-popup.d.ts +6 -0
  44. package/dist/consent-popup.js +203 -0
  45. package/dist/consent.d.ts +65 -0
  46. package/dist/consent.js +314 -0
  47. package/dist/entity-definition.d.ts +19 -0
  48. package/dist/entity-definition.js +23 -0
  49. package/dist/link-policy.d.ts +7 -2
  50. package/dist/link-policy.js +8 -1
  51. package/dist/links.d.ts +12 -4
  52. package/dist/links.js +16 -10
  53. package/dist/posthog-events.d.ts +95 -0
  54. package/dist/posthog-events.js +263 -0
  55. package/dist/posthog-interactions.d.ts +85 -0
  56. package/dist/posthog-interactions.js +280 -0
  57. package/dist/posthog.d.ts +25 -3
  58. package/dist/posthog.js +64 -6
  59. package/dist/promoto-analytics.d.ts +45 -0
  60. package/dist/promoto-analytics.js +92 -0
  61. package/dist/promoto-banner.js +62 -4
  62. package/dist/related-sites.json +2 -2
  63. package/dist/root-transit.d.ts +7 -1
  64. package/dist/root-transit.js +42 -1
  65. package/dist/seo.d.ts +30 -1
  66. package/dist/seo.js +93 -1
  67. package/dist/site-metadata.d.ts +11 -6
  68. package/dist/site-metadata.js +21 -8
  69. package/package.json +42 -1
@@ -111,7 +111,7 @@ const { fallback, locale = Astro.currentLocale ?? 'en', siteId } = Astro.props;
111
111
  /* Centered in the content area: a theme narrows it by setting these two insets on :root. */
112
112
  inset-inline-start: var(--hagilight-promoto-inset-start, 0px);
113
113
  inset-inline-end: var(--hagilight-promoto-inset-end, 0px);
114
- bottom: max(1rem, env(safe-area-inset-bottom));
114
+ bottom: calc(max(1rem, env(safe-area-inset-bottom)) + var(--hagilight-consent-clearance, 0px));
115
115
  width: min(42rem, calc(100% - var(--hagilight-promoto-inset-start, 0px) - var(--hagilight-promoto-inset-end, 0px) - 1rem - 2 * max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px))));
116
116
  margin-inline: auto;
117
117
  overflow: hidden;
@@ -468,7 +468,7 @@ const { fallback, locale = Astro.currentLocale ?? 'en', siteId } = Astro.props;
468
468
  }
469
469
 
470
470
  .hagilight-promoto__shell {
471
- bottom: calc(env(safe-area-inset-bottom) + 0.5rem);
471
+ bottom: calc(env(safe-area-inset-bottom) + 0.5rem + var(--hagilight-consent-clearance, 0px));
472
472
  width: min(calc(100vw - 1rem - 2 * max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px))), 28rem);
473
473
  border-radius: 0.875rem;
474
474
  }
@@ -537,7 +537,7 @@ const { fallback, locale = Astro.currentLocale ?? 'en', siteId } = Astro.props;
537
537
  }
538
538
 
539
539
  .hagilight-promoto__shell {
540
- bottom: max(0.5rem, env(safe-area-inset-bottom));
540
+ bottom: calc(max(0.5rem, env(safe-area-inset-bottom)) + var(--hagilight-consent-clearance, 0px));
541
541
  }
542
542
 
543
543
  .hagilight-promoto__media {
package/README.md CHANGED
@@ -29,7 +29,7 @@ attribution by itself. Plain-Astro sites that want the literal
29
29
  `@hagicode/hagilight/Footer`; that component reads the exact build-time version
30
30
  from `@hagicode/hagilight`'s own manifest, not from Astro.
31
31
 
32
- Other entry points include `Copyright`, `PromotoBanner`, `GoogleAnalytics`, `PostHog`, and `Analytics51LA` Astro components; `links`, `favicon`, `seo`, `seo-schema`, `rss`, `rss-ownership`, `promotions`, and `analytics-events` utilities; and `logo.png` and `favicon.ico` assets. For example:
32
+ Other entry points include `Copyright`, `PromotoBanner`, `GoogleAnalytics`, `PostHog`, and `Analytics51LA` Astro components; `@hagicode/hagilight-core/posthog-interactions` provides the interaction observers; `links`, `favicon`, `seo`, `seo-schema`, `rss`, `rss-ownership`, `promotions`, `analytics-events`, and `posthog-events` utilities; and `logo.png` and `favicon.ico` assets. For example:
33
33
 
34
34
  ```ts
35
35
  import { resolveSiteLinks } from '@hagicode/hagilight-core/links';
@@ -367,7 +367,7 @@ The file follows `schemaVersion: 1`. Fields may be added within version 1. Renam
367
367
  "llms": "/llms.txt"
368
368
  },
369
369
  "analytics": { "googleAnalytics": true, "fiftyOneLa": false, "posthog": true },
370
- "features": { "seo": true, "promoto": true }
370
+ "features": { "seo": true, "promoto": true, "consent": true }
371
371
  }
372
372
  ```
373
373
 
@@ -439,6 +439,24 @@ With the unified processor, pass `rehypeContentImages()` in `rehypePlugins` inst
439
439
 
440
440
  The banner is a fixed card at most `42rem` wide, centered between two insets: `--hagilight-promoto-inset-start` and `--hagilight-promoto-inset-end` (both default to `0px`). A layout with a sidebar or a table of contents sets them on `:root` so the card sits in the content column instead of over those rails. `@hagicode/hagilight-starlight` derives them from Starlight's own layout tokens, and `@hagicode/hagilight-docusaurus` measures the doc content column at runtime. A plain Astro site needs nothing.
441
441
 
442
+ ## Promotion analytics
443
+
444
+ The shared banner reports three PostHog events, with `promo_id` equal to the call to action's `data-ga-label` (the promotion id). Positions are 1-based, matching the visible counter.
445
+
446
+ | Event | Sent when | Properties |
447
+ |---|---|---|
448
+ | `promoto_impression` | A promotion has stayed visible for 1000 ms. Once per promotion per page; a new page key (pathname and query) allows it again. | `promo_id`, `position`, `rotating` (automatic rotation was active) |
449
+ | `promoto_dismissed` | The dismiss control is clicked. Sent before the existing dismissal steps, which are unchanged. A repeated click during the exit animation sends nothing. | `promo_id`, `visible_ms` (from the promotion first appearing on this page), `seen_count` (distinct promotions visible on this page, including this one) |
450
+ | `promoto_paged` | The carousel moves. `method` is `auto` for the rotation timer and `click` for previous or next. Pausing sends nothing, and reduced motion sends no `auto` event. | `from`, `to`, `method` |
451
+
452
+ Events are sent only when `window.posthog` has loaded and the visitor has not opted out. Nothing is queued while PostHog is still a stub, and a failing capture never changes display, rotation, dismissal, paging or navigation. The Astro `PromotoBanner` and the Docusaurus card share this element, so both send the same events.
453
+
454
+ Per-promotion click-through is `cta_click` with `category=promotion` divided by `promoto_impression`, grouped by `promo_id`. Dismissal rate should use visitors who had an impression as its denominator, because a dismissal hides the banner for good.
455
+
456
+ ### Close behavior
457
+
458
+ Dismissal is stored in `localStorage` under `hagilight:promoto-banner:dismissed-signature`, not `sessionStorage`. There is no expiry; the value stays until the browser clears site data or the card set changes. The stored value is the signature of all cards, not one promotion id, so one close hides the whole set and changing any card shows it again. It is scoped per origin, so each `*.hagicode.com` site dismisses on its own. If storage is unavailable, the dismissal is not kept and the banner returns on the next load. Hiding at page top (first 30 visits per hostname) and while the footer is in view are not dismissals and are not reported.
459
+
442
460
  ## Promotion platforms
443
461
 
444
462
  The shared banner (`PromotoBanner`, `loadActivePromotions`) displays only promotions whose `platforms` array in Index's `/promote.json` includes `web`, in addition to being enabled, inside their activation window, and matched with `/promote_content.json`. This follows the `platforms` flag documented in the Index README. An entry whose `platforms` is missing, empty, or not an array of strings is not displayed, other values such as `hagicode` are ignored, and matching is exact (`Web` does not match). When no promotion remains, the banner shows its site fallback or stays hidden, as before.
@@ -472,9 +490,9 @@ resolveSiteLinks('en-US', { siteId: 'docs' });
472
490
  // quick → downloadClient: https://www.hagicode.com/en-US/desktop/?utm_source=docs&utm_medium=footer
473
491
  ```
474
492
 
475
- - Footer `quick`, `community` and related-site entries are tagged with `utm_medium=footer`. The banner call to action is tagged with `utm_medium=promoto`. Header and filing links are not tagged.
493
+ - Footer `quick`, `community` and related-site entries are tagged with `utm_medium=footer`, `utm_campaign=<link id>` (the related site's id for ecosystem entries) and `utm_content=footer`. Footer-brand links say `utm_content=footer_brand` instead. The banner call to action is tagged with `utm_medium=promoto`, `utm_campaign=<promotion id>` and `utm_content=promoto_banner`. Article-end promotion links are tagged with `utm_medium=article`, `utm_campaign=<link id>` and `utm_content=article_promotion`. The Store badge and header links are not tagged.
476
494
  - Only `https:` destinations on `hagicode.com` hosts are tagged. GitHub, `mailto:`, `tel:`, third-party, same-origin and relative destinations are left unchanged, and so is every destination when `siteId` is absent or blank.
477
- - Existing `utm_source` or `utm_medium` values win. Other query parameters and the fragment are kept.
495
+ - Existing `utm_source`, `utm_medium`, `utm_campaign` or `utm_content` values win; only missing keys are added. Other query parameters and the fragment are kept.
478
496
  - Tags are added after deduplication, so a tagged and a clean destination still collapse into one entry. `normalizeUrl` is unchanged. Canonical URLs, `og:url` and sitemap entries are built from page URLs and never contain `utm_*`.
479
497
  - Footer clicks report the tagged `href` as `link_url` in the GA click event. The `link_url` dimension therefore includes `utm_source` and `utm_medium` for first-party footer clicks. No new event parameter is added.
480
498
 
@@ -482,7 +500,7 @@ resolveSiteLinks('en-US', { siteId: 'docs' });
482
500
 
483
501
  - `links.siteId` (Starlight, Docusaurus, and the `Footer`/`Header` components) enables footer tags. The Starlight and Docusaurus promotion banners read this same value.
484
502
  - `links.siteUrl` names the hosting site's URL for same-origin classification and for excluding its own Ecosystem Sites entry. When it is not set, the core `Footer` uses the page's Astro `site` (`Astro.site`) instead, so a site built for `https://fullstack.hagicode.com` does not list the HagiCode Fullstack entry on its own footer. An explicit `siteUrl` wins, and with neither value the footer behaves as before. The fallback never sets `siteId`, so no campaign tags are added.
485
- - `PromotoBanner` accepts an optional `siteId` prop, written to `data-site-id`. Without it the banner keeps the class-based `rel` and leaves destinations unchanged.
503
+ - `PromotoBanner` accepts an optional `siteId` prop, written to `data-site-id`. Without it the banner keeps the class-based `rel` and leaves destinations unchanged. The Starlight `PromotoFooter` component takes the same `siteId` prop and forwards it.
486
504
  - Each slide is classified and tagged on its own when it renders, so a rotation from a third-party campaign to a first-party one gets the first-party `rel` and tags.
487
505
 
488
506
  ### Google Analytics cross-domain linker
@@ -513,7 +531,7 @@ import GoogleAnalytics from '@hagicode/hagilight-core/GoogleAnalytics';
513
531
  </html>
514
532
  ```
515
533
 
516
- `<PostHog />` needs no enabled flag or project key. It uses `phc_qiVVihsL925ovhPYNdLJWz4k7aoKVMwYCevgZPE6PER5`, API host `https://us.i.posthog.com`, and SDK defaults `2026-05-30`. It emits no loader or initialization outside production. The SDK is loaded asynchronously with anonymous cross-origin mode from `https://us-assets.i.posthog.com/static/array.js`.
534
+ `<PostHog />` needs no enabled flag or project key. Optional props set the site context: `siteId` (defaults to the site URL's hostname), `framework` (`astro` by default; Starlight passes `starlight`), `version` (defaults to this package's version), and `pageType` (see below). It uses `phc_qiVVihsL925ovhPYNdLJWz4k7aoKVMwYCevgZPE6PER5`, API host `https://t.hagicode.com` (HagiCode's managed proxy), UI host `https://us.posthog.com`, person profiles `identified_only` (profiles are created only for identified users), and SDK defaults `2026-05-30`. It emits no loader or initialization outside production. The SDK is loaded asynchronously with anonymous cross-origin mode from `https://t.hagicode.com/static/array.js`, so the proxy must serve both ingestion and `/static/` assets. Sites with a strict script or connect policy must allow `t.hagicode.com`.
517
535
 
518
536
  For a different project, pass `<PostHog apiKey="phc_Custom123" />`. Keys must match `^phc_[A-Za-z0-9]+$`; invalid values fail rendering before a script is emitted. The host and defaults version stay fixed.
519
537
 
@@ -528,10 +546,86 @@ import {
528
546
  POSTHOG_API_KEY_PATTERN,
529
547
  } from '@hagicode/hagilight-core/posthog';
530
548
 
531
- const script = posthogInitScript(); // optional custom key as the only argument
549
+ const script = posthogInitScript(); // optional custom key as the first argument
550
+ // Optional second argument: the site context, { siteId?, framework, version, pageType? }
551
+ const withContext = posthogInitScript(undefined, { framework: 'astro', version: '0.1.0', siteId: 'docs.example.com' });
532
552
  ```
533
553
 
534
- Initialization runs once per document, including when the script is re-executed before or after the SDK loads. Fresh documents initialize independently. SDK defaults own navigation tracking; Hagilight adds no PostHog capture calls or route listeners. Choose one initialization owner: omit this component when another integration initializes PostHog, or disable the plugin provider when composing it yourself. The plain Astro `hagilight()` integration injects the same script into every production head by default (see its README), so render this component only in a custom head where that integration is not the owner, such as a Starlight site that keeps its own `Head` or a site that sets `analytics: { posthog: { enabled: false } }`.
554
+ Initialization runs once per document, including when the script is re-executed before or after the SDK loads. Fresh documents initialize independently. SDK defaults own navigation tracking. Beyond them, Hagilight makes one `posthog.register` call with the site context, sets `capture_exceptions`, and sends `cta_click` events through one click listener per document. It adds no automatic page-view capture and no route listeners; the interaction events below are its only other captures. Choose one initialization owner: omit this component when another integration initializes PostHog, or disable the plugin provider when composing it yourself. The plain Astro `hagilight()` integration injects the same script into every production head by default (see its README), so render this component only in a custom head where that integration is not the owner, such as a Starlight site that keeps its own `Head` or a site that sets `analytics: { posthog: { enabled: false } }`.
555
+
556
+ ### Site context
557
+
558
+ After initialization, each page registers five super properties once. Empty values are omitted:
559
+
560
+ - `site_id`: `links.siteId` when a site sets it, otherwise the site URL's hostname, otherwise the document hostname at run time. Two sites on one hostname with different base paths share a `site_id` unless `links.siteId` is set.
561
+ - `site_framework`: `astro`, `starlight` or `docusaurus`.
562
+ - `hagilight_version`: the version of the integration that rendered the page.
563
+ - `locale`: the document's `<html lang>`, read at run time.
564
+ - `page_type`: one of `home`, `docs`, `blog`, `compare`, `404` or `other`. A build-time value wins, then `<meta name="hagilight:page-type">`, then `other`. Starlight derives the value per page. Plain Astro sets it with the `pageType` prop of `SEOHead`, which emits the meta element. Docusaurus refreshes `locale` and `page_type` on every route update, including the first page load, from the path. Because it classifies by path only, its 404 page reports a path-derived type (`docs`, `blog` or `compare`) rather than `other`.
565
+
566
+ The site-metadata file keeps its schema; it gains no analytics identifier.
567
+
568
+ ### Event vocabulary and `cta_click`
569
+
570
+ `@hagicode/hagilight-core/posthog-events` is the only place PostHog event names, per-event property allowlists, super-property keys, page types and framework names are spelled. Its interaction additions are `POSTHOG_REQUIRED_PROPERTIES`, `POSTHOG_REDIRECT_REASONS`, `POSTHOG_CONTENT_WIDTHS`, `referrerDomain` and `sanitizePath`. It is browser-safe, with no Astro or Node imports, and it exports `POSTHOG_EVENTS`, `POSTHOG_SUPER_PROPERTIES`, `POSTHOG_PAGE_TYPES`, `POSTHOG_FRAMEWORKS`, `capturePostHogEvent`, `sanitizePostHogProperties`, `destinationOf`, `resolvePageType`, `classifyPagePath`, `installPostHogClickTracking` and `handlePostHogClick`.
571
+
572
+ A marked link (any element with `data-ga-category`, `data-ga-label` and `data-ga-location`) produces one `cta_click` event:
573
+
574
+ - `category`, `label` and `location` come from the same attributes that Google Analytics reads.
575
+ - `destination_host` is the lowercase host of the destination only. The destination comes from `data-ga-url`, then the `href` property, then the `href` attribute. No path, query string, hash or credential is ever sent.
576
+ - `is_external` is `true` only when the destination host differs from the current page's host. A non-HTTP(S) or unparseable destination omits `destination_host` and reports `false`.
577
+
578
+ The click listener is passive and capture-phase. It never cancels, stops or delays a click, and it is installed at most once per document whether or not Google Analytics is enabled. It sends nothing when `window.posthog` is absent or `has_opted_out_capturing()` returns `true`, and it never reads link text or form input or identifies the visitor. Other events in the vocabulary are documented with their features.
579
+
580
+ Changing the vocabulary is a deliberate change: update the table in `packages/core/src/posthog-events.ts` and the snapshot in `test/posthog-events.test.mjs` together.
581
+
582
+ ### Interaction events
583
+
584
+ `@hagicode/hagilight-core/posthog-interactions` installs one delegated observer set per document (`installPostHogInteractions`). Starlight and plain Astro install it from `PostHog.astro`; Docusaurus installs it from its own client module whenever PostHog is enabled, independently of Google Analytics and 51LA. Each event is sent through the single capture helper, with `transport: 'sendBeacon'`, and only with the properties listed here:
585
+
586
+ | Event | Sent when | Properties |
587
+ | --- | --- | --- |
588
+ | `not_found_viewed` | A 404 page is shown (Starlight `NotFoundHero`, Docusaurus `NotFound` wrapper), once per view | `path` (no query or fragment), `referrer_domain` (host name, omitted when absent or unparseable) |
589
+ | `search_used` | A Pagefind search has settled 800 ms after the last keystroke (Starlight only) | `query_length`, `results_count`, `locale`, and `query` only under `searchQuery: 'zero-results'` |
590
+ | `search_result_clicked` | A Pagefind result link is clicked (Starlight only) | `rank` (1-based among rendered links), `results_count` |
591
+ | `code_copied` | A code block copy button is used (Expressive Code or Docusaurus) | `language` (declared language, else `unknown`), `page_type`, `is_install_page` |
592
+ | `article_promotion_impression` | The end-of-article promotion card is at least half visible for one second, once per page (Starlight only) | `variant` (centre fan card's pool key, else `default`), `path` |
593
+ | `locale_changed` | A different language is chosen from the Starlight language chooser or the Docusaurus locale dropdown | `from`, `to` |
594
+ | `locale_redirected` | The root transit forwards automatically to a known locale; a click does not count | `from` (`root`), `to`, `reason` (`query`, `stored`, `browser` or `default`) |
595
+ | `theme_changed` (optional, Starlight only) | The theme picker changes | `theme` |
596
+ | `content_width_changed` (optional, Starlight only) | The content width toggle changes | `choice` (`narrow` or `wide`) |
597
+
598
+ `locale_redirected` has one emitter: the timer-driven forward of the root transit (`reportLocaleRedirect` in `root-transit.ts`). The forward fires only when the destination's first path segment after the base is a known site locale, and a visitor's own click on the transit link never counts. `reason` is the source the locale resolver reports for the transit's own inputs (`?lang=`, stored locale, browser languages, default). The page sets the destination, so `reason` explains why that locale was expected and is not a verified cause. `language-routing` holds no automatic redirect, so the Starlight language chooser never emits `locale_redirected`; it emits `locale_changed` for a choice the visitor makes.
599
+
600
+ The vocabulary, the required properties of each event and the value rules live in `posthog-events.ts`. An event is dropped when a required property is missing or invalid, and a property outside its event's allowlist is dropped. `page_type` uses the shared values (`home`, `docs`, `blog`, `compare`, `404`, `other`).
601
+
602
+ **Capture gate.** An event is sent only when `window.posthog` exists, exposes `capture`, and has not reported opt-out. A stub that has not loaded yet still queues the event, and the SDK applies opt-out when it replays the queue. Reading PostHog that throws is ignored, and listeners never cancel, stop or delay the interaction they observe.
603
+
604
+ **Search text.** The search text is absent from every event by default. `analytics.posthog.searchQuery: 'zero-results'` (see the Starlight and Docusaurus READMEs) adds `query` only when the search returned nothing. The check runs on the whole text before it is cut to 64 code points, and it withholds the text when it contains a hexadecimal run of 16 or more characters, a `/`, `\`, `://`, a leading `~`, a key-like token of 24 or more characters, a known token prefix (`phc_`, `sk-`, `ghp_`, `gho_`, `xox`, `AKIA`, `eyJ`, `Bearer `), or an `@`. A withheld text still lets the rest of the event be sent.
605
+
606
+ **Code.** The copy listener reads the block's declared language and never reads `data-code`, the block's text or the clipboard, so no code reaches an event.
607
+
608
+ **Platform gaps.** Docusaurus uses its own search, so it has no `search_used` or `search_result_clicked`. `article_promotion_impression`, `search_*`, `theme_changed` and `content_width_changed` exist only on Starlight, because only Starlight renders those components.
609
+
610
+ ### Exception capture and privacy limits
611
+
612
+ `posthog.init` sets `capture_exceptions: true`, so unhandled errors are reported as `$exception` events. Project-side prerequisite: `$exception` events also need the `autocapture_exceptions_opt_in` setting enabled in the PostHog project. That setting belongs to the PostHog project owner and not to this repository, so until it is enabled, expect no `$exception` events. Hagilight does not call `identify`, `opt_in_capturing`, `opt_out_capturing` or any session-replay method, so visitors are never identified by Hagilight and no consent state changes.
613
+
614
+ ## Analytics consent
615
+
616
+ Analytics is off until a visitor grants it. With consent on (the default whenever a provider is enabled), Google Analytics, 51LA and PostHog leave only inert `application/json` descriptors in the page. The gate (`@hagicode/hagilight-core/consent-gate`) injects each loader once, after a grant, and nothing from the undecided period is queued or replayed. Consent-off output (`consent` prop `false`, or `analytics.consent.enabled: false` in a framework plugin) keeps the static loaders as before.
617
+
618
+ - `@hagicode/hagilight-core/consent` (browser-safe): `getConsent()` returns `{ necessary: 'granted', analytics: 'granted' | 'denied' | 'undecided' }`; `setConsent({ analytics })`; `onConsentChange(callback)` returns an unsubscribe function; `openConsentPreferences()` reopens the popup. None of them throw. `configureConsent({ regionHook })` takes an optional region check: returning `false` means consent is not required; any other result or a throw means it is.
619
+ - Events: `hagilight:consent-change` on `document`, with the new state as `detail`, after each effective change.
620
+ - Storage: cookie `hagicode_consent` (`Domain=.hagicode.com`, `Path=/`, `SameSite=Lax`, `Secure`, 180 days) on hagicode.com hosts only, and localStorage `hagicode:consent` everywhere. The record is `1|granted|<epoch seconds>|<policyVersion>`, expires after 180 days, and a changed policy version asks again. With storage blocked the choice holds for the page session only.
621
+ - `@hagicode/hagilight-core/CookieConsent` (Astro): renders the popup. Pass `providers` (the enabled analytics providers), and optionally `privacyUrl` (an absolute HTTP(S) URL or a `/` path; omitted means no privacy link) and `policyVersion` (1 to 32 letters, digits, dots, underscores or hyphens). Mount it only when a provider is enabled. The popup publishes `--hagilight-consent-clearance` so the banner and footers stay clear of it.
622
+ - `@hagicode/hagilight-core/consent-markup` holds the shared markup, the config descriptor and the option validators; `@hagicode/hagilight-core/consent-copy` holds the localized copy for every `SITE_LOCALES` code.
623
+
624
+ 51LA is loaded without screen recording or session replay: `LA.init` sets `autoTrack` and `hashMode` and never `screenRecord`. Session replay in this stack is PostHog's, controlled by the project's PostHog settings, and the popup discloses it only for PostHog.
625
+
626
+ Storage names that the details list (and that cleanup removes on withdrawal) are verified in `test/fixtures/consent-sdk-storage.json`: PostHog writes `ph_<key>_posthog` (cookie and localStorage), `__ph_opt_in_out_<key>` and two `ph_<key>_` sessionStorage keys; Google Analytics writes `_ga` and `_ga_<id>`. 51LA's names are not verified yet. Re-verify the SDK names whenever an SDK is upgraded, and update `packages/core/src/consent-gate.ts` and the fixture together.
627
+
628
+ Withdrawal stops collection: PostHog opts out and its `ph_` entries are removed; GA sets `ga-disable-<id>` and its cookies are removed; any provider that cannot stop in place (51LA always, GA and PostHog until the consent browser check confirms otherwise) reloads the page after the denial is saved.
535
629
 
536
630
  ## Google Analytics click events
537
631
 
@@ -34,6 +34,21 @@ export type GaSend = (action: GaAction, params: GaEventParams) => void;
34
34
  export declare function gaEventAttributes(tag: GaEventTag): GaEventAttributes;
35
35
  /** Returns tag attributes for catalog links in `TRACKED_SITE_LINKS` and `{}` for every other link. */
36
36
  export declare function siteLinkGaAttributes(link: Pick<SiteLink, 'id'>, location: string): Partial<GaEventAttributes>;
37
+ /** A validated tagged click: the first `data-ga-*` element in the click path, read without side effects. */
38
+ export interface TaggedClick {
39
+ category: GaCategory;
40
+ label: string;
41
+ location: string;
42
+ /** `data-ga-url`, then the element's `href` property, then its `href` attribute. */
43
+ url?: string;
44
+ }
45
+ /**
46
+ * Reads the first tagged element in the click's composed path. Returns `undefined` when no element
47
+ * is tagged or its category, label or location is invalid. Never touches the event.
48
+ */
49
+ export declare function readTaggedClick(event: {
50
+ composedPath(): readonly unknown[];
51
+ }): TaggedClick | undefined;
37
52
  /**
38
53
  * Reports the first tagged element in the click's composed path. Never throws and never
39
54
  * touches the event, so navigation is unaffected.
@@ -62,28 +62,38 @@ function isTaggedElement(value) {
62
62
  function nonEmpty(value) {
63
63
  return typeof value === 'string' && value.trim() ? value : undefined;
64
64
  }
65
+ /**
66
+ * Reads the first tagged element in the click's composed path. Returns `undefined` when no element
67
+ * is tagged or its category, label or location is invalid. Never touches the event.
68
+ */
69
+ export function readTaggedClick(event) {
70
+ const element = event.composedPath().find(isTaggedElement);
71
+ if (!element)
72
+ return undefined;
73
+ const category = element.getAttribute('data-ga-category');
74
+ const label = nonEmpty(element.getAttribute('data-ga-label'));
75
+ const location = nonEmpty(element.getAttribute('data-ga-location'));
76
+ if (!isCategory(category) || !label || !location)
77
+ return undefined;
78
+ const url = nonEmpty(element.getAttribute('data-ga-url'))
79
+ ?? nonEmpty(element.href)
80
+ ?? nonEmpty(element.getAttribute('href'));
81
+ return { category, label, location, ...(url === undefined ? {} : { url }) };
82
+ }
65
83
  /**
66
84
  * Reports the first tagged element in the click's composed path. Never throws and never
67
85
  * touches the event, so navigation is unaffected.
68
86
  */
69
87
  export function handleGaClick(event, send) {
70
88
  try {
71
- const element = event.composedPath().find(isTaggedElement);
72
- if (!element)
73
- return;
74
- const category = element.getAttribute('data-ga-category');
75
- const label = nonEmpty(element.getAttribute('data-ga-label'));
76
- const location = nonEmpty(element.getAttribute('data-ga-location'));
77
- if (!isCategory(category) || !label || !location)
89
+ const tagged = readTaggedClick(event);
90
+ if (!tagged)
78
91
  return;
79
- const linkUrl = nonEmpty(element.getAttribute('data-ga-url'))
80
- ?? nonEmpty(element.href)
81
- ?? nonEmpty(element.getAttribute('href'));
82
- send(GA_CATEGORY_ACTIONS[category], {
83
- event_category: category,
84
- event_label: label,
85
- link_location: location,
86
- ...(linkUrl === undefined ? {} : { link_url: linkUrl }),
92
+ send(GA_CATEGORY_ACTIONS[tagged.category], {
93
+ event_category: tagged.category,
94
+ event_label: tagged.label,
95
+ link_location: tagged.location,
96
+ ...(tagged.url === undefined ? {} : { link_url: tagged.url }),
87
97
  transport_type: 'beacon',
88
98
  });
89
99
  }
@@ -0,0 +1,2 @@
1
+ import type { ConsentCopy } from './types.js';
2
+ export declare const copy: ConsentCopy;
@@ -0,0 +1,21 @@
1
+ export const copy = {
2
+ dialogLabel: "Cookies und Analyse",
3
+ title: "Cookies und Analyse",
4
+ intro: "HagiCode nutzt Analysen, um zu sehen, wie diese Website genutzt wird. Bis zu Ihrer Auswahl wird nichts geladen.",
5
+ accept: "Analyse akzeptieren",
6
+ reject: "Ablehnen",
7
+ details: "Details",
8
+ hideDetails: "Details ausblenden",
9
+ necessaryTitle: "Notwendig: immer aktiv",
10
+ necessaryBody: "Für den Betrieb der Website und zum Speichern Ihrer Auswahl, Sprache und Design erforderlich.",
11
+ analyticsTitle: "Analyse: bis zur Zustimmung aus",
12
+ analyticsBody: "Sitzungswiedergabe (wenn ein Anbieter Sitzungen aufzeichnet) gehört zur Analyse. Kein Anbieter zeichnet den Bildschirm auf.",
13
+ storageHeading: "Cookies und Speicher",
14
+ privacyLink: "Datenschutzerklärung",
15
+ withdraw: "Sie können dies jederzeit unter „Cookie-Einstellungen“ ändern.",
16
+ footerEntry: "Cookie-Einstellungen",
17
+ choiceLabel: "Ihre Auswahl",
18
+ choiceAccepted: "Akzeptiert",
19
+ choiceRejected: "Abgelehnt",
20
+ choiceUndecided: "Noch nicht ausgewählt",
21
+ };
@@ -0,0 +1,2 @@
1
+ import type { ConsentCopy } from './types.js';
2
+ export declare const copy: ConsentCopy;
@@ -0,0 +1,21 @@
1
+ export const copy = {
2
+ dialogLabel: "Cookies and analytics",
3
+ title: "Cookies and analytics",
4
+ intro: "HagiCode uses analytics to see how this site is used. Nothing loads until you choose.",
5
+ accept: "Accept analytics",
6
+ reject: "Reject",
7
+ details: "Details",
8
+ hideDetails: "Hide details",
9
+ necessaryTitle: "Necessary: always on",
10
+ necessaryBody: "Needed for the site to work and to remember your choices, language and theme.",
11
+ analyticsTitle: "Analytics: off until you accept",
12
+ analyticsBody: "Session replay, where a provider records sessions, is part of analytics. No provider records the screen.",
13
+ storageHeading: "Cookies and storage",
14
+ privacyLink: "Privacy policy",
15
+ withdraw: "You can change this any time in Cookie settings.",
16
+ footerEntry: "Cookie settings",
17
+ choiceLabel: "Your choice",
18
+ choiceAccepted: "Accepted",
19
+ choiceRejected: "Rejected",
20
+ choiceUndecided: "Not chosen yet",
21
+ };
@@ -0,0 +1,2 @@
1
+ import type { ConsentCopy } from './types.js';
2
+ export declare const copy: ConsentCopy;
@@ -0,0 +1,21 @@
1
+ export const copy = {
2
+ dialogLabel: "Cookies y análisis",
3
+ title: "Cookies y análisis",
4
+ intro: "HagiCode usa análisis para ver cómo se usa este sitio. No se carga nada hasta que elijas.",
5
+ accept: "Aceptar análisis",
6
+ reject: "Rechazar",
7
+ details: "Detalles",
8
+ hideDetails: "Ocultar detalles",
9
+ necessaryTitle: "Necesarias: siempre activas",
10
+ necessaryBody: "Necesarias para que el sitio funcione y para recordar tus elecciones, idioma y tema.",
11
+ analyticsTitle: "Análisis: desactivado hasta que aceptes",
12
+ analyticsBody: "La reproducción de sesiones (cuando un proveedor graba sesiones) forma parte del análisis. Ningún proveedor graba la pantalla.",
13
+ storageHeading: "Cookies y almacenamiento",
14
+ privacyLink: "Política de privacidad",
15
+ withdraw: "Puedes cambiarlo en cualquier momento en «Configuración de cookies».",
16
+ footerEntry: "Configuración de cookies",
17
+ choiceLabel: "Tu elección",
18
+ choiceAccepted: "Aceptado",
19
+ choiceRejected: "Rechazado",
20
+ choiceUndecided: "Aún sin elegir",
21
+ };
@@ -0,0 +1,2 @@
1
+ import type { ConsentCopy } from './types.js';
2
+ export declare const copy: ConsentCopy;
@@ -0,0 +1,21 @@
1
+ export const copy = {
2
+ dialogLabel: "Cookies et analyse",
3
+ title: "Cookies et analyse",
4
+ intro: "HagiCode utilise des outils d'analyse pour savoir comment ce site est utilisé. Rien n'est chargé tant que vous n'avez pas choisi.",
5
+ accept: "Accepter l'analyse",
6
+ reject: "Refuser",
7
+ details: "Détails",
8
+ hideDetails: "Masquer les détails",
9
+ necessaryTitle: "Nécessaires : toujours actifs",
10
+ necessaryBody: "Nécessaires au fonctionnement du site et pour mémoriser vos choix, la langue et le thème.",
11
+ analyticsTitle: "Analyse : désactivée jusqu'à acceptation",
12
+ analyticsBody: "La relecture de session (lorsqu'un fournisseur enregistre les sessions) fait partie de l'analyse. Aucun fournisseur n'enregistre l'écran.",
13
+ storageHeading: "Cookies et stockage",
14
+ privacyLink: "Politique de confidentialité",
15
+ withdraw: "Vous pouvez modifier ce choix à tout moment dans « Paramètres des cookies ».",
16
+ footerEntry: "Paramètres des cookies",
17
+ choiceLabel: "Votre choix",
18
+ choiceAccepted: "Accepté",
19
+ choiceRejected: "Refusé",
20
+ choiceUndecided: "Pas encore choisi",
21
+ };
@@ -0,0 +1,7 @@
1
+ import { type SiteLocale } from '../root-transit-locale.js';
2
+ import type { ConsentCopy } from './types.js';
3
+ export type { ConsentCopy } from './types.js';
4
+ /** One catalog entry per `SITE_LOCALES` code. */
5
+ export declare const CONSENT_COPY: Readonly<Record<SiteLocale, ConsentCopy>>;
6
+ /** The popup copy for a page locale. A locale outside `SITE_LOCALES` renders `en-US`. */
7
+ export declare function resolveConsentCopy(locale: unknown): ConsentCopy;
@@ -0,0 +1,31 @@
1
+ import { DEFAULT_LOCALE, SITE_LOCALE_CODES } from '../root-transit-locale.js';
2
+ import { copy as enUS } from './en-US.js';
3
+ import { copy as zhCN } from './zh-CN.js';
4
+ import { copy as zhHant } from './zh-Hant.js';
5
+ import { copy as jaJP } from './ja-JP.js';
6
+ import { copy as koKR } from './ko-KR.js';
7
+ import { copy as deDE } from './de-DE.js';
8
+ import { copy as frFR } from './fr-FR.js';
9
+ import { copy as esES } from './es-ES.js';
10
+ import { copy as ptBR } from './pt-BR.js';
11
+ import { copy as ruRU } from './ru-RU.js';
12
+ /** One catalog entry per `SITE_LOCALES` code. */
13
+ export const CONSENT_COPY = {
14
+ 'en-US': enUS,
15
+ 'zh-CN': zhCN,
16
+ 'zh-Hant': zhHant,
17
+ 'ja-JP': jaJP,
18
+ 'ko-KR': koKR,
19
+ 'de-DE': deDE,
20
+ 'fr-FR': frFR,
21
+ 'es-ES': esES,
22
+ 'pt-BR': ptBR,
23
+ 'ru-RU': ruRU,
24
+ };
25
+ /** The popup copy for a page locale. A locale outside `SITE_LOCALES` renders `en-US`. */
26
+ export function resolveConsentCopy(locale) {
27
+ if (typeof locale === 'string' && SITE_LOCALE_CODES.includes(locale)) {
28
+ return CONSENT_COPY[locale];
29
+ }
30
+ return CONSENT_COPY[DEFAULT_LOCALE];
31
+ }
@@ -0,0 +1,2 @@
1
+ import type { ConsentCopy } from './types.js';
2
+ export declare const copy: ConsentCopy;
@@ -0,0 +1,21 @@
1
+ export const copy = {
2
+ dialogLabel: "Cookieと分析",
3
+ title: "Cookieと分析",
4
+ intro: "HagiCodeは、このサイトの利用状況を把握するために分析を使用します。選択するまで、分析サービスは読み込まれません。",
5
+ accept: "分析を許可",
6
+ reject: "拒否",
7
+ details: "詳細",
8
+ hideDetails: "詳細を閉じる",
9
+ necessaryTitle: "必須:常にオン",
10
+ necessaryBody: "サイトの動作と、言語やテーマなどの選択内容の保存に必要です。",
11
+ analyticsTitle: "分析:許可するまでオフ",
12
+ analyticsBody: "セッションリプレイ(提供元がセッションを記録する場合)は分析に含まれます。画面を録画する提供元はありません。",
13
+ storageHeading: "Cookieとストレージ",
14
+ privacyLink: "プライバシーポリシー",
15
+ withdraw: "いつでも「Cookie設定」から変更できます。",
16
+ footerEntry: "Cookie設定",
17
+ choiceLabel: "現在の選択",
18
+ choiceAccepted: "許可済み",
19
+ choiceRejected: "拒否済み",
20
+ choiceUndecided: "未選択",
21
+ };
@@ -0,0 +1,2 @@
1
+ import type { ConsentCopy } from './types.js';
2
+ export declare const copy: ConsentCopy;
@@ -0,0 +1,21 @@
1
+ export const copy = {
2
+ dialogLabel: "쿠키 및 분석",
3
+ title: "쿠키 및 분석",
4
+ intro: "HagiCode는 이 사이트의 이용 현황을 파악하기 위해 분석을 사용합니다. 선택하기 전에는 분석 서비스가 로드되지 않습니다.",
5
+ accept: "분석 허용",
6
+ reject: "거부",
7
+ details: "자세히",
8
+ hideDetails: "자세히 접기",
9
+ necessaryTitle: "필수: 항상 켜짐",
10
+ necessaryBody: "사이트가 작동하고 언어 및 테마 등 선택 사항을 기억하는 데 필요합니다.",
11
+ analyticsTitle: "분석: 허용 전까지 꺼짐",
12
+ analyticsBody: "세션 리플레이(제공자가 세션을 기록하는 경우)는 분석에 포함됩니다. 화면을 녹화하는 제공자는 없습니다.",
13
+ storageHeading: "쿠키 및 저장소",
14
+ privacyLink: "개인정보처리방침",
15
+ withdraw: "언제든지 '쿠키 설정'에서 변경할 수 있습니다.",
16
+ footerEntry: "쿠키 설정",
17
+ choiceLabel: "현재 선택",
18
+ choiceAccepted: "허용됨",
19
+ choiceRejected: "거부됨",
20
+ choiceUndecided: "아직 선택하지 않음",
21
+ };
@@ -0,0 +1,2 @@
1
+ import type { ConsentCopy } from './types.js';
2
+ export declare const copy: ConsentCopy;
@@ -0,0 +1,21 @@
1
+ export const copy = {
2
+ dialogLabel: "Cookies e análise",
3
+ title: "Cookies e análise",
4
+ intro: "O HagiCode usa análise para entender como este site é usado. Nada é carregado até você escolher.",
5
+ accept: "Aceitar análise",
6
+ reject: "Recusar",
7
+ details: "Detalhes",
8
+ hideDetails: "Ocultar detalhes",
9
+ necessaryTitle: "Necessários: sempre ativos",
10
+ necessaryBody: "Necessários para o site funcionar e para lembrar suas escolhas, idioma e tema.",
11
+ analyticsTitle: "Análise: desligada até você aceitar",
12
+ analyticsBody: "A reprodução de sessão (quando um fornecedor grava sessões) faz parte da análise. Nenhum fornecedor grava a tela.",
13
+ storageHeading: "Cookies e armazenamento",
14
+ privacyLink: "Política de privacidade",
15
+ withdraw: "Você pode mudar isso a qualquer momento em «Configurações de cookies».",
16
+ footerEntry: "Configurações de cookies",
17
+ choiceLabel: "Sua escolha",
18
+ choiceAccepted: "Aceita",
19
+ choiceRejected: "Recusada",
20
+ choiceUndecided: "Ainda não escolhida",
21
+ };
@@ -0,0 +1,2 @@
1
+ import type { ConsentCopy } from './types.js';
2
+ export declare const copy: ConsentCopy;
@@ -0,0 +1,21 @@
1
+ export const copy = {
2
+ dialogLabel: "Cookie и аналитика",
3
+ title: "Cookie и аналитика",
4
+ intro: "HagiCode использует аналитику, чтобы понимать, как используется этот сайт. До вашего выбора ничего не загружается.",
5
+ accept: "Принять аналитику",
6
+ reject: "Отклонить",
7
+ details: "Подробнее",
8
+ hideDetails: "Скрыть подробности",
9
+ necessaryTitle: "Необходимые: всегда включены",
10
+ necessaryBody: "Нужны для работы сайта и для сохранения вашего выбора, языка и темы.",
11
+ analyticsTitle: "Аналитика: выключена до вашего согласия",
12
+ analyticsBody: "Воспроизведение сессий (если провайдер записывает сессии) входит в аналитику. Ни один провайдер не записывает экран.",
13
+ storageHeading: "Cookie и хранилище",
14
+ privacyLink: "Политика конфиденциальности",
15
+ withdraw: "Вы можете изменить это в любое время в разделе «Настройки cookie».",
16
+ footerEntry: "Настройки cookie",
17
+ choiceLabel: "Ваш выбор",
18
+ choiceAccepted: "Принято",
19
+ choiceRejected: "Отклонено",
20
+ choiceUndecided: "Пока не выбрано",
21
+ };
@@ -0,0 +1,22 @@
1
+ /** The popup's copy. Every locale module supplies every key; brand names stay untranslated. */
2
+ export interface ConsentCopy {
3
+ dialogLabel: string;
4
+ title: string;
5
+ intro: string;
6
+ accept: string;
7
+ reject: string;
8
+ details: string;
9
+ hideDetails: string;
10
+ necessaryTitle: string;
11
+ necessaryBody: string;
12
+ analyticsTitle: string;
13
+ analyticsBody: string;
14
+ storageHeading: string;
15
+ privacyLink: string;
16
+ withdraw: string;
17
+ footerEntry: string;
18
+ choiceLabel: string;
19
+ choiceAccepted: string;
20
+ choiceRejected: string;
21
+ choiceUndecided: string;
22
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { ConsentCopy } from './types.js';
2
+ export declare const copy: ConsentCopy;
@@ -0,0 +1,21 @@
1
+ export const copy = {
2
+ dialogLabel: "Cookie 与分析",
3
+ title: "Cookie 与分析",
4
+ intro: "HagiCode 使用分析工具了解本站的使用情况。在你做出选择前,不会加载任何分析服务。",
5
+ accept: "接受分析",
6
+ reject: "拒绝",
7
+ details: "详情",
8
+ hideDetails: "收起详情",
9
+ necessaryTitle: "必要:始终开启",
10
+ necessaryBody: "用于保证网站正常运行,并记住你的选择、语言和主题。",
11
+ analyticsTitle: "分析:接受前关闭",
12
+ analyticsBody: "会话回放(在提供商记录会话时)属于分析功能。没有任何提供商录制屏幕。",
13
+ storageHeading: "Cookie 与存储",
14
+ privacyLink: "隐私政策",
15
+ withdraw: "你可以随时在「Cookie 设置」中更改。",
16
+ footerEntry: "Cookie 设置",
17
+ choiceLabel: "你的选择",
18
+ choiceAccepted: "已接受",
19
+ choiceRejected: "已拒绝",
20
+ choiceUndecided: "尚未选择",
21
+ };
@@ -0,0 +1,2 @@
1
+ import type { ConsentCopy } from './types.js';
2
+ export declare const copy: ConsentCopy;
@@ -0,0 +1,21 @@
1
+ export const copy = {
2
+ dialogLabel: "Cookie 與分析",
3
+ title: "Cookie 與分析",
4
+ intro: "HagiCode 使用分析工具了解本站的使用情況。在你做出選擇前,不會載入任何分析服務。",
5
+ accept: "接受分析",
6
+ reject: "拒絕",
7
+ details: "詳情",
8
+ hideDetails: "收起詳情",
9
+ necessaryTitle: "必要:永遠開啟",
10
+ necessaryBody: "用於維持網站正常運作,並記住你的選擇、語言和主題。",
11
+ analyticsTitle: "分析:接受前關閉",
12
+ analyticsBody: "工作階段重播(提供商記錄工作階段時)屬於分析功能。沒有任何提供商錄製螢幕。",
13
+ storageHeading: "Cookie 與儲存",
14
+ privacyLink: "隱私權政策",
15
+ withdraw: "你可以隨時在「Cookie 設定」中變更。",
16
+ footerEntry: "Cookie 設定",
17
+ choiceLabel: "你的選擇",
18
+ choiceAccepted: "已接受",
19
+ choiceRejected: "已拒絕",
20
+ choiceUndecided: "尚未選擇",
21
+ };