@aceshooting/lyra-ui 23.0.0 → 24.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/CHANGELOG.md +9 -43
  2. package/README.md +72 -35
  3. package/custom-elements.json +1 -1
  4. package/design-tokens.json +1 -1
  5. package/dist/cli/lyra-rename-ledger.mjs +1 -1
  6. package/dist/cli/migration-contract.json +1 -1
  7. package/dist/cli/migration-contract.mjs +1 -1
  8. package/dist/cli/migration-renames.mjs +2 -2
  9. package/dist/cli/migration-transforms.mjs +2 -2
  10. package/dist/components/agent-tools/approval-queue/approval-queue.class.d.ts +1 -4
  11. package/dist/components/agent-tools/approval-queue/approval-queue.class.js +1 -3
  12. package/dist/components/agent-tools/compare-panel/compare-panel.class.d.ts +1 -4
  13. package/dist/components/agent-tools/compare-panel/compare-panel.class.js +1 -1
  14. package/dist/components/agent-tools/confirm-bar/confirm-bar.class.d.ts +1 -7
  15. package/dist/components/agent-tools/confirm-bar/confirm-bar.class.js +2 -2
  16. package/dist/components/agent-tools/context-inspector/context-inspector.class.d.ts +1 -1
  17. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.d.ts +2 -5
  18. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +1 -3
  19. package/dist/components/agent-tools/terminal/terminal.class.d.ts +1 -4
  20. package/dist/components/agent-tools/terminal/terminal.class.js +2 -2
  21. package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.class.d.ts +1 -7
  22. package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.class.js +1 -1
  23. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.d.ts +1 -4
  24. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.js +1 -3
  25. package/dist/components/charts/chart/lite-chart-axis-layout.d.ts +13 -0
  26. package/dist/components/charts/chart/lite-chart-axis-layout.js +1 -0
  27. package/dist/components/charts/chart/lite-chart.class.d.ts +1 -11
  28. package/dist/components/charts/chart/lite-chart.class.js +4 -4
  29. package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +2 -2
  30. package/dist/components/conversation/agent-workspace/agent-workspace.class.js +0 -1
  31. package/dist/components/conversation/chat-message/chat-message.class.d.ts +3 -9
  32. package/dist/components/conversation/chat-message/chat-message.class.js +1 -1
  33. package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
  34. package/dist/components/conversation/code-block/code-block-core.class.d.ts +6 -8
  35. package/dist/components/conversation/code-block/code-block-shared.d.ts +1 -4
  36. package/dist/components/conversation/code-block/code-block.class.d.ts +4 -6
  37. package/dist/components/conversation/markdown/markdown-base.class.d.ts +1 -3
  38. package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
  39. package/dist/components/conversation/markdown/markdown-core.class.d.ts +1 -4
  40. package/dist/components/conversation/markdown/markdown.class.d.ts +1 -4
  41. package/dist/components/conversation/message-actions/message-actions.class.d.ts +1 -4
  42. package/dist/components/conversation/message-actions/message-actions.class.js +1 -1
  43. package/dist/components/conversation/message-feedback/message-feedback.class.d.ts +1 -4
  44. package/dist/components/conversation/message-feedback/message-feedback.class.js +2 -2
  45. package/dist/components/conversation/message-parts/message-parts.class.d.ts +2 -5
  46. package/dist/components/conversation/message-parts/message-parts.class.js +3 -3
  47. package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +1 -1
  48. package/dist/components/conversation/streaming-text/streaming-text-core.class.d.ts +2 -0
  49. package/dist/components/conversation/streaming-text/streaming-text-core.class.js +0 -1
  50. package/dist/components/conversation/streaming-text/streaming-text.class.d.ts +2 -0
  51. package/dist/components/conversation/streaming-text/streaming-text.class.js +0 -1
  52. package/dist/components/conversation/thread-list/thread-list.class.d.ts +6 -17
  53. package/dist/components/conversation/thread-list/thread-list.class.js +6 -6
  54. package/dist/components/data/context-meter/context-meter.class.d.ts +1 -6
  55. package/dist/components/data/context-meter/context-meter.class.js +1 -1
  56. package/dist/components/data/data-grid/data-grid.class.d.ts +0 -1
  57. package/dist/components/data/data-grid/data-grid.class.js +2 -2
  58. package/dist/components/data/document-library/document-library.class.d.ts +6 -13
  59. package/dist/components/data/document-library/document-library.class.js +1 -2
  60. package/dist/components/data/heatmap/heatmap-grid-navigation.d.ts +7 -0
  61. package/dist/components/data/heatmap/heatmap-grid-navigation.js +1 -0
  62. package/dist/components/data/heatmap/heatmap.class.d.ts +3 -23
  63. package/dist/components/data/heatmap/heatmap.class.js +2 -2
  64. package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +3 -9
  65. package/dist/components/data/sequence-strip/sequence-strip.class.js +3 -3
  66. package/dist/components/data/table/table.class.d.ts +5 -14
  67. package/dist/components/data/table/table.class.js +6 -6
  68. package/dist/components/forms/button/button.class.d.ts +2 -2
  69. package/dist/components/forms/button/button.class.js +9 -9
  70. package/dist/components/forms/combobox/combobox.class.d.ts +1 -4
  71. package/dist/components/forms/combobox/combobox.class.js +2 -2
  72. package/dist/components/forms/input/time-input.class.d.ts +1 -1
  73. package/dist/components/forms/input/time-input.class.js +1 -1
  74. package/dist/components/forms/select/select.class.d.ts +1 -2
  75. package/dist/components/layout/app-rail/app-rail-item.class.d.ts +3 -6
  76. package/dist/components/layout/app-rail/app-rail-item.class.js +1 -1
  77. package/dist/components/layout/app-rail/app-rail.class.d.ts +2 -4
  78. package/dist/components/layout/app-rail/app-rail.class.js +1 -1
  79. package/dist/components/layout/app-rail-group/app-rail-group.class.d.ts +2 -6
  80. package/dist/components/layout/app-rail-group/app-rail-group.class.js +1 -1
  81. package/dist/components/layout/carousel/carousel.class.d.ts +1 -4
  82. package/dist/components/layout/carousel/carousel.class.js +2 -2
  83. package/dist/components/layout/command-palette/command-palette.class.js +1 -1
  84. package/dist/components/layout/details/details.class.d.ts +2 -4
  85. package/dist/components/layout/details/details.class.js +1 -1
  86. package/dist/components/layout/dock-panel/dock-panel.class.d.ts +3 -7
  87. package/dist/components/layout/dock-panel/dock-panel.class.js +1 -1
  88. package/dist/components/layout/menu/menu.class.js +1 -1
  89. package/dist/components/layout/multi-split/multi-split.class.d.ts +2 -4
  90. package/dist/components/layout/multi-split/multi-split.class.js +1 -1
  91. package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.d.ts +2 -4
  92. package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.js +1 -1
  93. package/dist/components/layout/reorder-list/reorder-item.class.d.ts +1 -4
  94. package/dist/components/layout/reorder-list/reorder-item.class.js +2 -2
  95. package/dist/components/media/attachment-trigger/attachment-trigger.class.d.ts +5 -9
  96. package/dist/components/media/attachment-trigger/attachment-trigger.class.js +5 -5
  97. package/dist/components/media/av-player/av-player.class.js +3 -3
  98. package/dist/components/media/file-input/file-input.class.d.ts +3 -6
  99. package/dist/components/media/file-input/file-input.class.js +3 -3
  100. package/dist/components/media/lightbox/lightbox.class.d.ts +11 -20
  101. package/dist/components/media/lightbox/lightbox.class.js +1 -1
  102. package/dist/components/media/map/map-data-layers.d.ts +20 -0
  103. package/dist/components/media/map/map-data-layers.js +1 -0
  104. package/dist/components/media/map/map.class.js +3 -3
  105. package/dist/components/media/media-time.d.ts +2 -0
  106. package/dist/components/media/media-time.js +1 -0
  107. package/dist/components/media/video/video.class.js +5 -5
  108. package/dist/components/media/video-playlist/video-playlist.class.js +2 -2
  109. package/dist/components/overlays/callout/callout.class.d.ts +2 -5
  110. package/dist/components/overlays/callout/callout.class.js +2 -2
  111. package/dist/components/overlays/dialog/dialog.class.d.ts +4 -7
  112. package/dist/components/overlays/dialog/dialog.class.js +2 -2
  113. package/dist/components/overlays/overlay/dropdown.class.d.ts +5 -10
  114. package/dist/components/overlays/overlay/dropdown.class.js +2 -2
  115. package/dist/components/overlays/overlay/popover.class.d.ts +2 -3
  116. package/dist/components/overlays/popup/popup.class.js +1 -1
  117. package/dist/components/overlays/progress/progress-bar.class.d.ts +1 -4
  118. package/dist/components/overlays/progress/progress-bar.class.js +2 -2
  119. package/dist/components/overlays/progress/progress-ring.class.d.ts +1 -4
  120. package/dist/components/overlays/progress/progress-ring.class.js +2 -2
  121. package/dist/components/overlays/progress/progress-shared.d.ts +3 -3
  122. package/dist/components/overlays/progress/progress-shared.js +1 -1
  123. package/dist/components/overlays/toast/toast-item.class.js +1 -1
  124. package/dist/components/retrieval/graph/graph.class.d.ts +5 -10
  125. package/dist/components/retrieval/graph/graph.class.js +1 -1
  126. package/dist/components/retrieval/knowledge-base/knowledge-base.class.d.ts +7 -14
  127. package/dist/components/retrieval/knowledge-base/knowledge-base.class.js +2 -3
  128. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +2 -8
  129. package/dist/components/retrieval/memory-panel/memory-panel.class.js +0 -4
  130. package/dist/components/retrieval/rag-answer/rag-answer.class.js +1 -1
  131. package/dist/components/utility/export-button/export-button.class.d.ts +6 -10
  132. package/dist/components/utility/export-button/export-button.class.js +1 -1
  133. package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
  134. package/dist/components/viewers/geojson-view/geojson-view.class.d.ts +1 -1
  135. package/dist/components/viewers/highlight-layer/highlight-layer-timing.js +1 -1
  136. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +4 -4
  137. package/dist/events.d.ts +17 -78
  138. package/dist/framework-types.d.ts +1 -1
  139. package/dist/internal/catalog-picker.js +1 -1
  140. package/dist/internal/css-motion-time.d.ts +7 -0
  141. package/dist/internal/css-motion-time.js +1 -0
  142. package/dist/internal/data-state-renderer.d.ts +1 -3
  143. package/dist/internal/data-state-renderer.js +1 -1
  144. package/dist/internal/localization-runtime.d.ts +2 -0
  145. package/dist/internal/localization-runtime.js +1 -1
  146. package/dist/internal/lyra-element.js +2 -2
  147. package/dist/internal/package-metadata.d.ts +1 -1
  148. package/dist/internal/package-metadata.js +1 -1
  149. package/dist/looks/data.css +1 -1
  150. package/dist/looks/terminal.css +1 -1
  151. package/dist/lyra.d.ts +1 -592
  152. package/dist/lyra.js +1 -1
  153. package/dist/testing/event-factory.d.ts +2 -2
  154. package/dist/testing/interaction-drivers.d.ts +5 -3
  155. package/dist/testing/lyra-tag-event-map.js +1 -1
  156. package/dist/theme/looks/data.d.ts +1 -1
  157. package/dist/theme/looks/data.js +1 -1
  158. package/dist/theme/looks/terminal.d.ts +1 -1
  159. package/dist/theme/looks/terminal.js +1 -1
  160. package/dist/theme/theme.d.ts +2 -80
  161. package/dist/theme/theme.js +1 -1
  162. package/llms/components/lr-agent-workspace.md +1 -1
  163. package/llms/components/lr-alert.md +1 -1
  164. package/llms/components/lr-animation.md +1 -1
  165. package/llms/components/lr-app-rail.md +8 -10
  166. package/llms/components/lr-approval-queue.md +2 -4
  167. package/llms/components/lr-attachment-trigger.md +3 -4
  168. package/llms/components/lr-badge.md +2 -2
  169. package/llms/components/lr-button.md +45 -99
  170. package/llms/components/lr-callout.md +3 -4
  171. package/llms/components/lr-carousel.md +3 -5
  172. package/llms/components/lr-chat-message.md +1 -2
  173. package/llms/components/lr-claim-evidence.md +1 -1
  174. package/llms/components/lr-code-block-core.md +2 -2
  175. package/llms/components/lr-code-block.md +5 -6
  176. package/llms/components/lr-color-picker.md +1 -1
  177. package/llms/components/lr-combobox.md +5 -6
  178. package/llms/components/lr-compare-panel.md +2 -4
  179. package/llms/components/lr-confirm-bar.md +3 -7
  180. package/llms/components/lr-context-inspector.md +3 -2
  181. package/llms/components/lr-context-menu.md +2 -2
  182. package/llms/components/lr-context-meter.md +2 -4
  183. package/llms/components/lr-copy-button.md +1 -1
  184. package/llms/components/lr-data-grid.md +4 -7
  185. package/llms/components/lr-details.md +3 -3
  186. package/llms/components/lr-dialog.md +4 -6
  187. package/llms/components/lr-dock-panel.md +5 -6
  188. package/llms/components/lr-document-library.md +5 -7
  189. package/llms/components/lr-drawer.md +3 -3
  190. package/llms/components/lr-dropdown.md +4 -5
  191. package/llms/components/lr-eval-run.md +3 -5
  192. package/llms/components/lr-export-button.md +4 -7
  193. package/llms/components/lr-file-input.md +0 -5
  194. package/llms/components/lr-funnel.md +1 -1
  195. package/llms/components/lr-graph.md +3 -7
  196. package/llms/components/lr-icon.md +1 -1
  197. package/llms/components/lr-include.md +1 -1
  198. package/llms/components/lr-input.md +31 -79
  199. package/llms/components/lr-json-viewer.md +1 -1
  200. package/llms/components/lr-knowledge-base.md +4 -6
  201. package/llms/components/lr-knowledge-graph-explorer.md +2 -5
  202. package/llms/components/lr-known-date.md +1 -1
  203. package/llms/components/lr-lightbox.md +9 -7
  204. package/llms/components/lr-lite-chart.md +1 -5
  205. package/llms/components/lr-markdown-core.md +3 -4
  206. package/llms/components/lr-markdown.md +3 -5
  207. package/llms/components/lr-mcp-app.md +1 -1
  208. package/llms/components/lr-message-actions.md +2 -3
  209. package/llms/components/lr-message-feedback.md +1 -3
  210. package/llms/components/lr-message-parts.md +4 -5
  211. package/llms/components/lr-multi-split.md +8 -7
  212. package/llms/components/lr-native-time-input.md +1 -1
  213. package/llms/components/lr-navigation-menu.md +5 -5
  214. package/llms/components/lr-number-input.md +3 -1
  215. package/llms/components/lr-otp-input.md +2 -0
  216. package/llms/components/lr-page.md +1 -1
  217. package/llms/components/lr-pan-zoom.md +1 -1
  218. package/llms/components/lr-phone-input.md +3 -1
  219. package/llms/components/lr-popover.md +2 -2
  220. package/llms/components/lr-progress-bar.md +3 -5
  221. package/llms/components/lr-progress-ring.md +5 -7
  222. package/llms/components/lr-prompt-input.md +1 -1
  223. package/llms/components/lr-prompt-queue.md +1 -1
  224. package/llms/components/lr-prompt-studio.md +1 -1
  225. package/llms/components/lr-rag-eval-dashboard.md +1 -1
  226. package/llms/components/lr-rating.md +2 -2
  227. package/llms/components/lr-realtime-session.md +1 -1
  228. package/llms/components/lr-reorder-item.md +1 -1
  229. package/llms/components/lr-reorder-list.md +2 -3
  230. package/llms/components/lr-retrieval-compare.md +1 -1
  231. package/llms/components/lr-select.md +3 -1
  232. package/llms/components/lr-selection-toolbar.md +1 -1
  233. package/llms/components/lr-sequence-strip.md +3 -8
  234. package/llms/components/lr-span-waterfall.md +1 -1
  235. package/llms/components/lr-split-panel.md +1 -1
  236. package/llms/components/lr-streaming-text-core.md +2 -1
  237. package/llms/components/lr-streaming-text.md +3 -2
  238. package/llms/components/lr-subagent-panel.md +1 -1
  239. package/llms/components/lr-swatch-picker.md +4 -4
  240. package/llms/components/lr-switch.md +3 -1
  241. package/llms/components/lr-table.md +33 -85
  242. package/llms/components/lr-terminal.md +2 -5
  243. package/llms/components/lr-textarea.md +1 -1
  244. package/llms/components/lr-thread-list.md +8 -14
  245. package/llms/components/lr-time-input.md +1 -1
  246. package/llms/components/lr-toggle-group.md +2 -2
  247. package/llms/components/lr-toggle.md +1 -1
  248. package/llms/components/lr-tool-approval-dialog.md +4 -7
  249. package/llms/components/lr-tool-call-block.md +1 -1
  250. package/llms/components/lr-tool-timeline.md +2 -5
  251. package/llms/components/lr-video-playlist.md +1 -1
  252. package/llms/components/lr-video.md +1 -1
  253. package/llms/components/lr-widget-renderer.md +7 -6
  254. package/llms/components/lr-zoomable-frame.md +1 -1
  255. package/llms/index.md +3 -618
  256. package/llms/migration.md +614 -614
  257. package/llms/shared/events-and-types.md +25 -24
  258. package/llms/shared/frameworks-and-ssr.md +7 -3
  259. package/llms/shared/imports-and-registration.md +22 -22
  260. package/llms/shared/localization-and-rtl.md +2 -2
  261. package/llms/shared/native-styles-and-utilities.md +263 -0
  262. package/llms/shared/styles-and-tokens.md +85 -676
  263. package/llms/shared/testing-and-utilities.md +12 -11
  264. package/llms/shared/v23-to-v24-migration.md +167 -0
  265. package/llms/shared.md +142 -487
  266. package/llms/tokens.md +3 -3
  267. package/llms.txt +9 -4
  268. package/package.json +7 -311
  269. package/registrations.json +1 -1
  270. package/vscode-html-data.json +1 -1
  271. package/web-types.json +1 -1
  272. package/dist/ssr-loader.d.ts +0 -2
  273. package/dist/ssr-loader.js +0 -1
  274. package/dist/theme/presets/shadcn.d.ts +0 -22
  275. package/dist/theme/presets/shadcn.js +0 -1
  276. package/dist/theme/presets.d.ts +0 -49
  277. package/dist/theme/presets.js +0 -1
  278. package/dist/themes/shadcn.css +0 -1
@@ -1 +1 @@
1
- import{devWarnOnce,litDevWarnings,warnDeprecatedUsage}from"../internal/dev-warning.js";import{readStyleOwnership}from"./style-ownership.js";const STORAGE_KEY="lyra-theme",TOKEN_NAME_PATTERN=/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/,TOKEN_NAME_MAX_LENGTH=80,TOKEN_RESERVED_NAME="--lr-theme-accent",TOKEN_ENTRY_MAX=512,TOKEN_SYNTHESIZED_MAX=16,TOKEN_VALUE_MAX_LENGTH=256,TOKEN_FORBIDDEN_PATTERN=/[\x00-\x1f\x7f\\;{}!<>@[\]`$^|~=?&:\u2028\u2029]|\/\*|\*\//,TOKEN_CSS_WIDE_PATTERN=/^(?:inherit|initial|revert(?:-layer)?|unset)$/i,TOKEN_FUNCTION_PATTERN=/([a-z0-9_-]+)\s*\(/gi,TOKEN_ALLOWED_FUNCTIONS="rgb rgba hsl hsla hwb lab lch oklab oklch color color-mix light-dark calc min max clamp var cubic-bezier steps linear".split(" "),TOKEN_OWNERSHIP_MAX=TOKEN_ENTRY_MAX+TOKEN_SYNTHESIZED_MAX,TOKEN_OWNERSHIP_SYMBOL="@aceshooting/lyra-ui.theme-tokens.v1",MODE_DEFAULTS={light:{surface:[255,255,255],raised:[246,248,250],text:[26,26,26],overlayStrongAlpha:.92},dark:{surface:[26,26,26],raised:[34,39,46],text:[242,242,242],overlayStrongAlpha:.95}},COLOR_SCHEME_QUERY="(prefers-color-scheme: dark)",SEMANTIC_ROLES=["brand","success","warning","danger","neutral"],RAMP_CHANNELS=["fill","border","on"],RAMP_TIERS=["quiet","normal","loud"];function roleRampProperties(role){const properties=[];for(const channel of RAMP_CHANNELS)for(const tier of RAMP_TIERS)properties.push(`--lr-theme-color-${role}-${channel}-${tier}`);return properties}const ALL_RAMP_PROPERTIES=[...SEMANTIC_ROLES.flatMap(roleRampProperties),"--lr-theme-color-focus"],MODE_ATTRIBUTES=["data-lr-theme","data-theme"];function isBalancedCssValue(value){let depth=0,quote="";for(const character of value){if(quote){character===quote&&(quote="");continue}if(character==="'"||character==='"')quote=character;else if(character==="(")depth+=1;else if(character===")"&&(depth-=1)<0)return!1}return quote===""&&depth===0}function isLyraThemeTokenName(name){return typeof name=="string"&&name.length<=TOKEN_NAME_MAX_LENGTH&&TOKEN_NAME_PATTERN.test(name)&&name!==TOKEN_RESERVED_NAME}function isSafeLyraThemeTokenValue(value){if(typeof value!="string")return!1;const trimmed=value.trim();if(!trimmed||trimmed.length>TOKEN_VALUE_MAX_LENGTH||TOKEN_FORBIDDEN_PATTERN.test(trimmed)||TOKEN_CSS_WIDE_PATTERN.test(trimmed))return!1;for(const match of trimmed.matchAll(TOKEN_FUNCTION_PATTERN))if(!TOKEN_ALLOWED_FUNCTIONS.includes((match[1]??"").toLowerCase()))return!1;return isBalancedCssValue(trimmed)}function isPlainRecord(value){if(typeof value!="object"||value===null||Array.isArray(value))return!1;const prototype=Object.getPrototypeOf(value);if(prototype===Object.prototype||prototype===null)return!0;if(Object.getPrototypeOf(prototype)!==null)return!1;const constructor=Object.getOwnPropertyDescriptor(prototype,"constructor")?.value;return typeof constructor=="function"&&Function.prototype.toString.call(constructor)===Function.prototype.toString.call(Object)}function normalizeTokenBranch(value){return isSafeLyraThemeTokenValue(value)?value.trim():null}function normalizeTokens(raw){try{if(!isPlainRecord(raw))return null;const names=Object.keys(raw);if(names.length===0||names.length>TOKEN_ENTRY_MAX)return null;const result={};let kept=0;for(const name of names){if(!isLyraThemeTokenName(name))continue;const value=ownField(raw,name);if(typeof value=="string"){const normalized=normalizeTokenBranch(value);if(normalized===null)continue;result[name]=normalized,kept+=1;continue}if(!isPlainRecord(value))continue;const keys=Object.keys(value),hasLight=Object.prototype.hasOwnProperty.call(value,"light"),hasDark=Object.prototype.hasOwnProperty.call(value,"dark");if(!hasLight&&!hasDark||keys.some(key=>key!=="light"&&key!=="dark"))continue;const light=normalizeTokenBranch(ownField(value,"light")),dark=normalizeTokenBranch(ownField(value,"dark"));light===null&&dark===null||(result[name]=Object.freeze({light,dark}),kept+=1)}return kept>0?Object.freeze(result):null}catch{return null}}function tokensEqual(left,right){const leftNames=left?Object.keys(left):[],rightNames=right?Object.keys(right):[];if(leftNames.length!==rightNames.length)return!1;if(leftNames.length===0)return!0;const leftMap=left,rightMap=right;return leftNames.every(name=>{if(!Object.prototype.hasOwnProperty.call(rightMap,name))return!1;const a=leftMap[name],b=rightMap[name];return typeof a=="string"||typeof b=="string"?a===b:!a||!b?!1:(a.light??null)===(b.light??null)&&(a.dark??null)===(b.dark??null)})}function normalizeColor(value,owner=document){if(typeof value!="string"||!value.trim())return null;const candidate=value.trim();if(!isBalancedCssValue(candidate)||TOKEN_CSS_WIDE_PATTERN.test(candidate)||/^(?:accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)$/i.test(candidate)||/\bcurrentcolor\b/i.test(candidate)||/\bvar\s*\(/i.test(candidate)||/\blight-dark\s*\(/i.test(candidate)||/\b(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)\s*\(\s*from\b/i.test(candidate))return null;const probe=owner.createElement("span");return probe.style.color=candidate,probe.style.color?candidate:null}function normalizeAccentValue(value){if(typeof value=="string"||value===null)return normalizeColor(value);if(typeof value!="object"||Array.isArray(value))return null;const record=value;if(!("light"in record)&&!("dark"in record))return null;const light=normalizeColor(record.light),dark=normalizeColor(record.dark);return light||dark?{light,dark}:null}function normalizeAccent(value){if(typeof value=="string")return normalizeColor(value);if(value===null||typeof value!="object"||Array.isArray(value))return null;const record=value,result={};let hasRole=!1;for(const role of SEMANTIC_ROLES)role in record&&(hasRole=!0,result[role]=normalizeAccentValue(record[role]));return hasRole?result:null}function resolveAccentValueForMode(value,mode){return typeof value=="string"?value:value?value[mode]??null:null}function accentValueEqual(left,right){return left===right?!0:typeof left=="string"||typeof right=="string"||left===null||right===null?!1:(left.light??null)===(right.light??null)&&(left.dark??null)===(right.dark??null)}function accentsEqual(left,right){if(left===right)return!0;if(typeof left=="string"||typeof right=="string"||left===null||right===null)return!1;const leftKeys=Object.keys(left),rightKeys=Object.keys(right);return leftKeys.length!==rightKeys.length?!1:leftKeys.every(role=>accentValueEqual(left[role],right[role]))}function parseResolvedRgb(value,background,owner=document){if(!normalizeColor(value,owner))return null;try{const canvas=owner.createElement("canvas");canvas.width=1,canvas.height=1;const context=canvas.getContext("2d",{willReadFrequently:!0});if(!context)return null;context.clearRect(0,0,1,1),context.fillStyle=value,context.fillRect(0,0,1,1);const channels=context.getImageData(0,0,1,1).data,red=channels[0]??0,green=channels[1]??0,blue=channels[2]??0,alpha=(channels[3]??0)/255;return[Math.round(red*alpha+background[0]*(1-alpha)),Math.round(green*alpha+background[1]*(1-alpha)),Math.round(blue*alpha+background[2]*(1-alpha))]}catch{return null}}function mixRgb(base,color,colorWeight){return[Math.round(base[0]*(1-colorWeight)+color[0]*colorWeight),Math.round(base[1]*(1-colorWeight)+color[1]*colorWeight),Math.round(base[2]*(1-colorWeight)+color[2]*colorWeight)]}function serializeRgb(color){return`rgb(${color.join(" ")})`}function relativeLuminance(color){const linearize=channel=>{const normalized=channel/255;return normalized<=.04045?normalized/12.92:((normalized+.055)/1.055)**2.4};return linearize(color[0])*.2126+linearize(color[1])*.7152+linearize(color[2])*.0722}function contrastRatio(left,right){const a=relativeLuminance(left),b=relativeLuminance(right);return(Math.max(a,b)+.05)/(Math.min(a,b)+.05)}function contrastForeground(fill){const black=[0,0,0],white=[255,255,255];return contrastRatio(fill,black)>=contrastRatio(fill,white)?black:white}function ensureSurfaceContrast(color,background,minimum=3,alsoAgainst=background,references=[]){const passes=candidate=>contrastRatio(candidate,background)>=minimum&&contrastRatio(candidate,alsoAgainst)>=minimum&&references.every(reference=>contrastRatio(candidate,reference)>=minimum);if(passes(color))return color;const black=[0,0,0],white=[255,255,255],target=contrastRatio(background,black)>=contrastRatio(background,white)?black:white;for(let step=1;step<=10;step+=1){const candidate=mixRgb(color,target,step/10);if(passes(candidate))return candidate}return target}function createRoleRamp(role,base,mode,background,owner=document){const references=STYLE_CONTRAST_SURFACES[mode].flatMap(color=>{const value=parseResolvedRgb(color,MODE_DEFAULTS[mode].surface,owner);return value?[value]:[]}),resolved=parseResolvedRgb(base,background,owner);if(!resolved)return null;const quiet=mixRgb(background,resolved,mode==="dark"?.24:.14),normal=mixRgb(background,resolved,mode==="dark"?.62:.55),loud=ensureSurfaceContrast(resolved,background,4.5,quiet,references),borderTarget=mode==="dark"?[255,255,255]:[0,0,0],borderQuiet=mixRgb(background,resolved,mode==="dark"?.46:.38),borderNormal=ensureSurfaceContrast(mixRgb(background,resolved,mode==="dark"?.78:.72),background,3,background,references),borderLoud=ensureSurfaceContrast(mixRgb(loud,borderTarget,.2),background,3,background,references),prefix=`--lr-theme-color-${role}`,ramp={[`${prefix}-fill-quiet`]:serializeRgb(quiet),[`${prefix}-fill-normal`]:serializeRgb(normal),[`${prefix}-fill-loud`]:serializeRgb(loud),[`${prefix}-border-quiet`]:serializeRgb(borderQuiet),[`${prefix}-border-normal`]:serializeRgb(borderNormal),[`${prefix}-border-loud`]:serializeRgb(borderLoud),[`${prefix}-on-quiet`]:serializeRgb(contrastForeground(quiet)),[`${prefix}-on-normal`]:serializeRgb(contrastForeground(normal)),[`${prefix}-on-loud`]:serializeRgb(contrastForeground(loud))};return role==="brand"&&(ramp["--lr-theme-color-focus"]=serializeRgb(ensureSurfaceContrast(resolved,background,3,background,references))),ramp}function paintAccent(accent,mode,background,owner=document){const properties=new Map;if(!accent)return{applied:null,properties};if(!mode)return{applied:accent,properties};if(typeof accent=="string"){const ramp=createRoleRamp("brand",accent,mode,background,owner);if(!ramp)return{applied:null,properties};properties.set("--lr-theme-accent",accent);for(const[property,value]of Object.entries(ramp))properties.set(property,value);return{applied:accent,properties}}const applied={};let appliedBrandColor=null;for(const role of SEMANTIC_ROLES){const value=accent[role];if(!value)continue;const isPerMode=typeof value!="string",base=resolveAccentValueForMode(value,mode);let painted=!1;if(base){const ramp=createRoleRamp(role,base,mode,background,owner);if(ramp){for(const[property,propertyValue]of Object.entries(ramp))properties.set(property,propertyValue);painted=!0,role==="brand"&&(appliedBrandColor=base)}}(painted||isPerMode)&&(applied[role]=value)}return appliedBrandColor&&properties.set("--lr-theme-accent",appliedBrandColor),{applied:Object.keys(applied).length>0?applied:null,properties}}function tokenEntries(tokens,mode){const entries=new Map;if(!tokens)return entries;for(const[name,value]of Object.entries(tokens))if(typeof value=="string")entries.set(name,value);else if(mode){const branch=value[mode];branch&&entries.set(name,branch)}return entries}function resolveTokenColor(value,background,owner){return value===void 0||!background||!normalizeColor(value,owner)?null:parseResolvedRgb(value,background,owner)}function floorTokenEntries(entries,mode,surface,owner=document){const resolveColor=(value,background)=>resolveTokenColor(value,background,owner),painted=new Map(entries),prefix="--lr-theme-",defaults=MODE_DEFAULTS[mode],raised=((name,fallback)=>entries.has(prefix+name)?resolveColor(entries.get(prefix+name),surface):fallback)("color-surface-raised",defaults.raised),floor=(name,over,against,minimum,alsoAgainst)=>{const value=painted.get(name);if(value===void 0||!against||alsoAgainst===null)return;const color=resolveColor(value,over);if(!color)return;const repaired=ensureSurfaceContrast(color,against,minimum,alsoAgainst??against);repaired!==color&&painted.set(name,serializeRgb(repaired))};floor(`${prefix}color-text-normal`,surface,surface,4.5,raised),floor(`${prefix}color-text-quiet`,surface,surface,4.5,raised);const text=entries.has(`${prefix}color-text-normal`)?resolveColor(painted.get(`${prefix}color-text-normal`),surface):defaults.text,synthesized=new Map,pairForeground=(onName,fill)=>{if(!fill)return;const on=painted.get(onName);if(on===void 0){synthesized.set(onName,serializeRgb(contrastForeground(fill)));return}const color=resolveColor(on,fill);color&&contrastRatio(color,fill)<4.5&&painted.set(onName,serializeRgb(contrastForeground(fill)))};for(const role of SEMANTIC_ROLES)for(const tier of RAMP_TIERS){const fillName=`${prefix}color-${role}-fill-${tier}`;entries.has(fillName)&&pairForeground(`${prefix}color-${role}-on-${tier}`,resolveColor(entries.get(fillName),surface))}const overlayName=`${prefix}color-overlay-strong`,overlay=entries.has(overlayName)?resolveColor(entries.get(overlayName),surface):mixRgb(surface,[0,0,0],defaults.overlayStrongAlpha);(entries.has(overlayName)||entries.has(`${prefix}color-on-strong-overlay`))&&pairForeground(`${prefix}color-on-strong-overlay`,overlay);const boundaries=[...SEMANTIC_ROLES.flatMap(role=>[`${prefix}color-${role}-border-normal`,`${prefix}color-${role}-border-loud`]),`${prefix}color-surface-border`,`${prefix}color-border-strong`,`${prefix}color-focus`];for(const name of boundaries)floor(name,surface,surface,3);for(const name of entries.keys())/^--lr-theme-color-chart-\d+$/.test(name)?floor(name,surface,surface,3):/^--lr-theme-terminal-color-[a-z0-9-]+$/.test(name)?floor(name,raised,raised,4.5):/^--lr-theme-terminal-bg-[a-z0-9-]+$/.test(name)&&floor(name,raised,text,4.5);for(const[name,value]of synthesized)painted.set(name,value);return painted}function readOwnershipList(){try{const list=document.documentElement[Symbol.for(TOKEN_OWNERSHIP_SYMBOL)];if(!Array.isArray(list))return[];const names=[],length=Math.min(list.length,TOKEN_OWNERSHIP_MAX);for(let index=0;index<length;index+=1){const name=list[index];isLyraThemeTokenName(name)&&names.push(name)}return names}catch{return[]}}function setLyraTheme(theme){warnDeprecatedUsage("./theme.js","function","setLyraTheme","setLyraStyle; review surface and token semantics");const before=readStyleState(),next={...before};if(theme.mode!==void 0&&(next.mode=theme.mode==="auto"?"system":theme.mode==="light"||theme.mode==="dark"||theme.mode==="unset"?theme.mode:"system"),theme.accent!==void 0&&(next.accent=typeof document>"u"?styleAccent(theme.accent):normalizeAccent(theme.accent),next.accentName=null),theme.surface!==void 0&&(next.accentBackground=typeof document>"u"?styleColor(theme.surface):normalizeColor(theme.surface)),theme.tokens!==void 0){next.tokens=normalizeTokens(theme.tokens);const stamp=theme.tokens&&theme.tokens[LOOK_STAMP];next.look=next.tokens?styleId(stamp)?stamp:"custom":"lyra",next.overrides=null}commitStyle(before,next)}function getLyraTheme(){return warnDeprecatedUsage("./theme.js","function","getLyraTheme","getLyraStyle"),legacyStyleSnapshot(readStyleState())}function applyStoredThemeBeforePaint(A){try{const x=A.record,S=x.mode==="light"||x.mode==="dark"||x.mode==="unset"?x.mode:"auto";let a=null;S==="light"||S==="dark"?a=S:S==="auto"&&(a=matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");const N=A.root,i=N.style,O=["brand","success","warning","danger","neutral"],rt=["fill","border","on"],W=["quiet","normal","loud"],B=[];for(const t of O)for(const e of rt)for(const o of W)B.push(`--lr-theme-color-${t}-${e}-${o}`);B.push("--lr-theme-color-focus");const nt=/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/,st=80,ct="--lr-theme-accent",_=512,lt=16,at=256,it=/[\x00-\x1f\x7f\\;{}!<>@[\]`$^|~=?&:\u2028\u2029]|\/\*|\*\//,G=/^(?:inherit|initial|revert(?:-layer)?|unset)$/i,ft=/([a-z0-9_-]+)\s*\(/gi,ut="rgb rgba hsl hsla hwb lab lch oklab oklch color color-mix light-dark calc min max clamp var cubic-bezier steps linear".split(" "),H=Symbol.for("@aceshooting/lyra-ui.theme-tokens.v1"),ht={light:{surface:[255,255,255],raised:[246,248,250],text:[26,26,26],overlayStrongAlpha:.92},dark:{surface:[26,26,26],raised:[34,39,46],text:[242,242,242],overlayStrongAlpha:.95}},J=t=>{let e=0,o="";for(const r of t){if(o){r===o&&(o="");continue}if(r==="'"||r==='"')o=r;else if(r==="(")e+=1;else if(r===")"&&(e-=1)<0)return!1}return o===""&&e===0},U=t=>typeof t=="string"&&t.length<=st&&nt.test(t)&&t!==ct,C=t=>{if(typeof t!="string")return null;const e=t.trim();if(!e||e.length>at||it.test(e)||G.test(e))return null;for(const o of e.matchAll(ft))if(!ut.includes((o[1]??"").toLowerCase()))return null;return J(e)?e:null},D=t=>{if(typeof t!="object"||t===null||Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null},E=[];try{const t=N[H];if(Array.isArray(t)){const e=Math.min(t.length,_+lt);for(let o=0;o<e;o+=1){const r=t[o];U(r)&&E.push(r)}}}catch{E.length=0}for(const t of[...B,"--lr-theme-accent",...E])i.removeProperty(t);const R={};try{const t=x.tokens,e=D(t)?Object.keys(t):[];if(D(t)&&e.length<=_)for(const o of e){if(!U(o))continue;const r=t[o];if(typeof r=="string"){const m=C(r);m!==null&&(R[o]=m);continue}if(!D(r))continue;const c=Object.prototype.hasOwnProperty.call(r,"light"),p=Object.prototype.hasOwnProperty.call(r,"dark");if(!c&&!p||Object.keys(r).some(m=>m!=="light"&&m!=="dark"))continue;const f=C(r.light),d=C(r.dark);(f!==null||d!==null)&&(R[o]={light:f,dark:d})}}catch{}if(A.normalizeOnly)return R;const u=new Map;for(const[t,e]of Object.entries(A.tokens??R)){const o=typeof e=="string"?e:a?e[a]:null;o&&u.set(t,o)}const dt=t=>G.test(t)||/^(?:accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)$/i.test(t)||/\bcurrentcolor\b/i.test(t)||/\bvar\s*\(/i.test(t)||/\blight-dark\s*\(/i.test(t)||/\b(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)\s*\(\s*from\b/i.test(t),v=t=>{if(typeof t!="string")return null;const e=t.trim();if(!e||!J(e)||dt(e))return null;const o=document.createElement("span");return o.style.color=e,o.style.color?e:null},mt=t=>{if(typeof t=="string")return v(t);if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;return!a||!("light"in e)&&!("dark"in e)?null:v(e[a])},T={},z=x.accent;if(typeof z=="string"){const t=v(z);t&&(T.brand=t)}else if(z&&typeof z=="object"&&!Array.isArray(z))for(const t of O){const e=mt(z[t]);e&&(T[t]=e)}let b=null;if(a&&(u.size>0||Object.keys(T).length>0))try{const t=document.createElement("canvas");t.width=1,t.height=1,b=t.getContext("2d",{willReadFrequently:!0})}catch{b=null}const V=(t,e)=>{if(!b)return null;try{b.clearRect(0,0,1,1),b.fillStyle=t,b.fillRect(0,0,1,1);const o=[...b.getImageData(0,0,1,1).data],r=(o[3]??0)/255;return[0,1,2].map(c=>Math.round((o[c]??0)*r+(e[c]??0)*(1-r)))}catch{return null}},P=(t,e,o)=>t.map((r,c)=>Math.round(r*(1-o)+(e[c]??0)*o)),X=t=>{const e=t.map(o=>{const r=o/255;return r<=.04045?r/12.92:((r+.055)/1.055)**2.4});return(e[0]??0)*.2126+(e[1]??0)*.7152+(e[2]??0)*.0722},k=(t,e)=>{const o=X(t),r=X(e);return(Math.max(o,r)+.05)/(Math.min(o,r)+.05)},M=[0,0,0],j=[255,255,255],w=t=>k(t,M)>=k(t,j)?M:j,q=(t,e,o=3,r=e)=>{const c=f=>k(f,e)>=o&&k(f,r)>=o&&(A.references??[]).every(d=>k(f,d)>=o);if(c(t))return t;const p=k(e,M)>=k(e,j)?M:j;for(let f=1;f<=10;f+=1){const d=P(t,p,f/10);if(c(d))return d}return p},h=t=>`rgb(${t.join(" ")})`,F=ht[a??"light"],Y=F.surface,Z=v(x.surface)??v(u.get("--lr-theme-color-surface-default")),s=Z&&V(Z,Y)||Y,$=new Map(u);if(a){const t="--lr-theme-",e=(n,l)=>n!==void 0&&l&&v(n)?V(n,l):null,r=((n,l)=>u.has(t+n)?e(u.get(t+n),s):l)("color-surface-raised",F.raised),c=(n,l,g,L,tt)=>{const et=$.get(n);if(et===void 0||!g||tt===null)return;const Q=e(et,l);if(!Q)return;const ot=q(Q,g,L,tt??g);ot!==Q&&$.set(n,h(ot))};c(`${t}color-text-normal`,s,s,4.5,r),c(`${t}color-text-quiet`,s,s,4.5,r);const p=u.has(`${t}color-text-normal`)?e($.get(`${t}color-text-normal`),s):F.text,f=new Map,d=(n,l)=>{if(!l)return;const g=$.get(n);if(g===void 0){f.set(n,h(w(l)));return}const L=e(g,l);L&&k(L,l)<4.5&&$.set(n,h(w(l)))};for(const n of O)for(const l of W){const g=`${t}color-${n}-fill-${l}`;u.has(g)&&d(`${t}color-${n}-on-${l}`,e(u.get(g),s))}const m=`${t}color-overlay-strong`,K=u.has(m)?e(u.get(m),s):P(s,M,F.overlayStrongAlpha);(u.has(m)||u.has(`${t}color-on-strong-overlay`))&&d(`${t}color-on-strong-overlay`,K);const y=[...O.flatMap(n=>[`${t}color-${n}-border-normal`,`${t}color-${n}-border-loud`]),`${t}color-surface-border`,`${t}color-border-strong`,`${t}color-focus`];for(const n of y)c(n,s,s,3);for(const n of u.keys())/^--lr-theme-color-chart-\d+$/.test(n)?c(n,s,s,3):/^--lr-theme-terminal-color-[a-z0-9-]+$/.test(n)?c(n,r,r,4.5):/^--lr-theme-terminal-bg-[a-z0-9-]+$/.test(n)&&c(n,r,p,4.5);for(const[n,l]of f)$.set(n,l)}try{N[H]=Object.freeze([...$.keys()])}catch{}for(const[t,e]of $)i.setProperty(t,e);if(!a||!b){i.removeProperty("--lr-theme-accent");return}let I=null;for(const t of O){const e=T[t];if(!e)continue;const o=V(e,s);if(!o)continue;const r=P(s,o,a==="dark"?.24:.14),c=P(s,o,a==="dark"?.62:.55),p=q(o,s,4.5,r),f=a==="dark"?j:M,d=P(s,o,a==="dark"?.46:.38),m=q(P(s,o,a==="dark"?.78:.72),s),K=q(P(p,f,.2),s),y=`--lr-theme-color-${t}`;i.setProperty(`${y}-fill-quiet`,h(r)),i.setProperty(`${y}-fill-normal`,h(c)),i.setProperty(`${y}-fill-loud`,h(p)),i.setProperty(`${y}-border-quiet`,h(d)),i.setProperty(`${y}-border-normal`,h(m)),i.setProperty(`${y}-border-loud`,h(K)),i.setProperty(`${y}-on-quiet`,h(w(r))),i.setProperty(`${y}-on-normal`,h(w(c))),i.setProperty(`${y}-on-loud`,h(w(p))),t==="brand"&&(i.setProperty("--lr-theme-color-focus",h(q(o,s))),I=e)}I?i.setProperty("--lr-theme-accent",I):i.removeProperty("--lr-theme-accent")}catch{}}function applyStoredStyleBeforePaint(U,W,T,L,q,z){const{surfaces:N,contrastSurfaces:G,gemstones:j}=z,S=[],R=[],E=[],P=[];for(const s of z.inputs.split(" ")){const n=Number(s[0]),c=`--lr-theme-${s.slice(1)}`;S.push(c),n&1&&R.push(c),n&2&&E.push(c),n&4&&P.push(c)}function g(s,n,c=!1){return`--_lr-${c?"a":"l"}${n==="light"?"l":"d"}-${s.slice(11)}`}function M(s,n){let c=`var(${g(s,n)})`;if(E.includes(s)){const u=n==="light"?"l":"d",b=s.replace(/color-(?:success|warning|danger|neutral)-/,"color-brand-");c=`var(--_lr-f${u}-${s.slice(11)},${c})var(--_lr-o${u}-${s.slice(11)},var(${g(b,n,!0)},var(${g(b,n)})))`}return P.includes(s)?`var(${g(s,n,!0)},${c})`:c}function J(s){const n=`var(--_lr-dark-on,${M(s,"light")})var(--_lr-light-on,${M(s,"dark")})`;if(!R.includes(s))return n;const c=s.startsWith("--lr-theme-space-");return`var(--_lr-dense-on,${n})var(--_lr-dense-off,max(calc((${n}) * var(--_lr-density-${c?"space":"control"},1)),${c?"0px":"var(--_lr-density-target-min,0px)"}))`}try{const s=document.currentScript,n=s?.getAttribute("data-lr-theme-storage-key"),c=n&&n.length<=200?n:U,u=s?.getAttribute("data-lr-theme-attributes")?.trim().split(/\s+/),b=u?.length&&u.length<=8&&new Set(u).size===u.length&&u.every(e=>e.length<=64&&/^data-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e))?u:W;let t={};const H=localStorage.getItem(c);try{const e=JSON.parse(H??"null");e&&typeof e=="object"&&!Array.isArray(e)&&(t=e)}catch{}t.version!==void 0&&t.version!==2&&(t={});const h=t.mode==="light"||t.mode==="dark"||t.mode==="unset"?t.mode:"system",v=h==="unset"?null:h==="system"?matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":h,o=document.documentElement,y={},Q=getComputedStyle(o).getPropertyValue("--_lr-style-resolver").trim()==="1",X=e=>typeof e=="string"&&e.length<=64&&/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e),V=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},Y=e=>T({root:document.createElement("div"),record:{mode:"unset",tokens:e},normalizeOnly:!0})??{},I=Y(t.tokens),Z=Object.fromEntries(Object.entries(Y(t.overrides)).filter(([e,r])=>L(e,r,S))),m={...I,...Z},C=X(t.look)?t.look:Object.keys(I).length?"custom":"lyra";if(y["data-lr-look"]=C,y["data-lr-density"]=t.density==="compact"||t.density==="touch"?t.density:"comfortable",y["data-lr-surface"]=t.treatment==="glass"?"glass":"solid",h!=="unset"&&(y["data-lr-mode"]=h),v)for(const e of b)y[e]=v;const $=t.version===2&&typeof t.accentName=="string"&&Object.hasOwn(j,t.accentName)?t.accentName:null,_=$?j[$]:t.accent;y["data-lr-accent"]=$??(_?"custom":"none");const a=new Map;if(h==="unset")for(const[e,r]of Object.entries(m))typeof r=="string"&&a.set(e,r);for(const e of["light","dark"]){const r=typeof t.surface=="string"?t.surface:V(t.surface)[e],A=typeof m["--lr-theme-color-surface-default"]=="string"?m["--lr-theme-color-surface-default"]:V(m["--lr-theme-color-surface-default"])[e],f=r??A??N[C]?.[e];for(const p of[!1,!0]){if(p&&(!_||$))continue;const w=document.createElement("div");T({root:w,tokens:p?{}:m,references:p?G[e].map(i=>[1,3,5].map(d=>parseInt(i.slice(d,d+2),16))):[],record:{mode:e,surface:p&&$?N.lyra?.[e]:f,tokens:p?null:m,accent:p?_:null}});for(const i of w.style){const d=w.style.getPropertyValue(i);if(i==="--lr-theme-accent"){e===v&&a.set(i,d);continue}if(S.includes(i)&&L(i,d,S)){const K=i.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1],O=!p&&K&&d===`var(--lr-theme-color-brand-${K})`,B=i.slice(11),D=e==="light"?"l":"d";O||a.set(g(i,e,p),d),!p&&E.includes(i)&&(a.set(`--_lr-f${D}-${B}`,O?" ":"initial"),a.set(`--_lr-o${D}-${B}`,O?"initial":" ")),e===v&&a.set(i,Q?J(i):d)}else e===v&&a.set(i,d)}}}a.size&&(y["data-lr-theme-scope"]="");const F=Symbol.for("@aceshooting/lyra-ui.style-ownership.v1"),k=o;let x;try{x=q(k[F])}catch{}const l=x??{attributes:new Map,properties:new Map};if(h==="unset")for(const e of b)l.attributes.has(e)||o.removeAttribute(e);try{const e=Symbol.for("@aceshooting/lyra-ui.theme-tokens.v1"),r=k[e];if(Array.isArray(r)){const A=r.slice(0,528).filter(f=>typeof f=="string"&&f.length<=80&&/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(f));for(const f of[...A,...P,"--lr-theme-accent"])!l.properties.has(f)&&o.style.getPropertyValue(f)&&l.properties.set(f,{before:null,priority:"",written:o.style.getPropertyValue(f)});try{delete k[e]}catch{}}}catch{}for(const[e,r]of l.attributes)Object.hasOwn(y,e)||(o.getAttribute(e)===r.written&&(r.before===null?o.removeAttribute(e):o.setAttribute(e,r.before)),l.attributes.delete(e));for(const[e,r]of Object.entries(y))l.attributes.has(e)||l.attributes.set(e,{before:o.getAttribute(e),priority:"",written:r}),o.setAttribute(e,r),l.attributes.get(e).written=r;for(const[e,r]of l.properties)a.has(e)||(o.style.getPropertyValue(e)===r.written&&!o.style.getPropertyPriority(e)&&(r.before?o.style.setProperty(e,r.before,r.priority):o.style.removeProperty(e)),l.properties.delete(e));for(const[e,r]of a)l.properties.has(e)||l.properties.set(e,{before:o.style.getPropertyValue(e),priority:o.style.getPropertyPriority(e),written:null}),o.style.getPropertyPriority(e)&&o.style.removeProperty(e),o.style.setProperty(e,r,""),l.properties.get(e).written=o.style.getPropertyValue(e);try{k[F]=l}catch{}}catch{}}const LINE_SEPARATOR="\u2028",PARAGRAPH_SEPARATOR="\u2029";function serializeInlineScriptData(value){return JSON.stringify(value).replace(/</g,"\\u003c").replace(new RegExp(LINE_SEPARATOR,"g"),"\\u2028").replace(new RegExp(PARAGRAPH_SEPARATOR,"g"),"\\u2029")}function createLyraThemeBootstrap(options={}){const storageKey=options.storageKey??STORAGE_KEY,inputs=STYLE_SLOTTED.map(name=>`${Number(STYLE_DENSITY.includes(name))|Number(STYLE_FOLLOW.includes(name))<<1|Number(ALL_RAMP_PROPERTIES.includes(name))<<2}${name.slice(11)}`).join(" "),model=JSON.stringify({inputs,surfaces:STYLE_REFERENCE_SURFACES,contrastSurfaces:STYLE_CONTRAST_SURFACES,gemstones:STYLE_GEMSTONES});return`(${applyStoredStyleBeforePaint.toString()})(${serializeInlineScriptData(storageKey)},${serializeInlineScriptData(MODE_ATTRIBUTES)},${applyStoredThemeBeforePaint.toString()},${styleTokenAllowed.toString()},${readStyleOwnership.toString()},${model});`}const STYLE_SLOTTED=["--lr-theme-color-border-strong","--lr-theme-color-brand-border-loud","--lr-theme-color-brand-border-normal","--lr-theme-color-brand-border-quiet","--lr-theme-color-brand-fill-loud","--lr-theme-color-brand-fill-normal","--lr-theme-color-brand-fill-quiet","--lr-theme-color-brand-on-loud","--lr-theme-color-brand-on-normal","--lr-theme-color-brand-on-quiet","--lr-theme-color-chart-1","--lr-theme-color-chart-2","--lr-theme-color-chart-3","--lr-theme-color-chart-4","--lr-theme-color-chart-5","--lr-theme-color-chart-6","--lr-theme-color-chart-7","--lr-theme-color-chart-8","--lr-theme-color-chart-diverging-1","--lr-theme-color-chart-diverging-2","--lr-theme-color-chart-diverging-3","--lr-theme-color-chart-sequential-1","--lr-theme-color-chart-sequential-2","--lr-theme-color-chart-sequential-3","--lr-theme-color-danger-border-loud","--lr-theme-color-danger-border-normal","--lr-theme-color-danger-border-quiet","--lr-theme-color-danger-fill-loud","--lr-theme-color-danger-fill-normal","--lr-theme-color-danger-fill-quiet","--lr-theme-color-danger-on-loud","--lr-theme-color-danger-on-normal","--lr-theme-color-danger-on-quiet","--lr-theme-color-focus","--lr-theme-color-mix-partner","--lr-theme-color-neutral-border-loud","--lr-theme-color-neutral-border-normal","--lr-theme-color-neutral-border-quiet","--lr-theme-color-neutral-fill-loud","--lr-theme-color-neutral-fill-normal","--lr-theme-color-neutral-fill-quiet","--lr-theme-color-neutral-on-loud","--lr-theme-color-neutral-on-normal","--lr-theme-color-neutral-on-quiet","--lr-theme-color-no-data","--lr-theme-color-on-strong-overlay","--lr-theme-color-overlay","--lr-theme-color-overlay-strong","--lr-theme-color-success-border-loud","--lr-theme-color-success-border-normal","--lr-theme-color-success-border-quiet","--lr-theme-color-success-fill-loud","--lr-theme-color-success-fill-normal","--lr-theme-color-success-fill-quiet","--lr-theme-color-success-on-loud","--lr-theme-color-success-on-normal","--lr-theme-color-success-on-quiet","--lr-theme-color-surface-border","--lr-theme-color-surface-border-subtle","--lr-theme-color-surface-container","--lr-theme-color-surface-container-high","--lr-theme-color-surface-container-highest","--lr-theme-color-surface-container-low","--lr-theme-color-surface-container-lowest","--lr-theme-color-surface-default","--lr-theme-color-surface-overlay","--lr-theme-color-surface-raised","--lr-theme-color-text-normal","--lr-theme-color-text-quiet","--lr-theme-color-warning-border-loud","--lr-theme-color-warning-border-normal","--lr-theme-color-warning-border-quiet","--lr-theme-color-warning-fill-loud","--lr-theme-color-warning-fill-normal","--lr-theme-color-warning-fill-quiet","--lr-theme-color-warning-on-loud","--lr-theme-color-warning-on-normal","--lr-theme-color-warning-on-quiet","--lr-theme-form-control-height-2xs","--lr-theme-form-control-height-l","--lr-theme-form-control-height-m","--lr-theme-form-control-height-s","--lr-theme-form-control-height-xl","--lr-theme-form-control-height-xs","--lr-theme-graph-cat-1","--lr-theme-graph-cat-2","--lr-theme-graph-cat-3","--lr-theme-graph-cat-4","--lr-theme-graph-cat-5","--lr-theme-graph-cat-6","--lr-theme-graph-cat-7","--lr-theme-graph-cat-8","--lr-theme-icon-button-size","--lr-theme-shadow-l","--lr-theme-shadow-m","--lr-theme-shadow-s","--lr-theme-shadow-xl","--lr-theme-shadow-xs","--lr-theme-space-2xl","--lr-theme-space-2xs","--lr-theme-space-l","--lr-theme-space-m","--lr-theme-space-s","--lr-theme-space-xs","--lr-theme-terminal-bg-black","--lr-theme-terminal-bg-blue","--lr-theme-terminal-bg-bright-black","--lr-theme-terminal-bg-bright-blue","--lr-theme-terminal-bg-bright-cyan","--lr-theme-terminal-bg-bright-green","--lr-theme-terminal-bg-bright-magenta","--lr-theme-terminal-bg-bright-red","--lr-theme-terminal-bg-bright-white","--lr-theme-terminal-bg-bright-yellow","--lr-theme-terminal-bg-cyan","--lr-theme-terminal-bg-green","--lr-theme-terminal-bg-magenta","--lr-theme-terminal-bg-red","--lr-theme-terminal-bg-white","--lr-theme-terminal-bg-yellow","--lr-theme-terminal-color-black","--lr-theme-terminal-color-blue","--lr-theme-terminal-color-bright-black","--lr-theme-terminal-color-bright-blue","--lr-theme-terminal-color-bright-cyan","--lr-theme-terminal-color-bright-green","--lr-theme-terminal-color-bright-magenta","--lr-theme-terminal-color-bright-red","--lr-theme-terminal-color-bright-white","--lr-theme-terminal-color-bright-yellow","--lr-theme-terminal-color-cyan","--lr-theme-terminal-color-green","--lr-theme-terminal-color-magenta","--lr-theme-terminal-color-red","--lr-theme-terminal-color-white","--lr-theme-terminal-color-yellow"],STYLE_DENSITY=["--lr-theme-space-2xs","--lr-theme-space-xs","--lr-theme-space-s","--lr-theme-space-m","--lr-theme-space-l","--lr-theme-space-2xl","--lr-theme-form-control-height-2xs","--lr-theme-form-control-height-xs","--lr-theme-form-control-height-s","--lr-theme-form-control-height-m","--lr-theme-form-control-height-l","--lr-theme-form-control-height-xl","--lr-theme-icon-button-size"],STYLE_FOLLOW=["--lr-theme-color-danger-border-loud","--lr-theme-color-danger-border-normal","--lr-theme-color-danger-border-quiet","--lr-theme-color-danger-fill-loud","--lr-theme-color-danger-fill-normal","--lr-theme-color-danger-fill-quiet","--lr-theme-color-danger-on-loud","--lr-theme-color-danger-on-normal","--lr-theme-color-danger-on-quiet","--lr-theme-color-neutral-border-loud","--lr-theme-color-neutral-border-normal","--lr-theme-color-neutral-border-quiet","--lr-theme-color-neutral-fill-loud","--lr-theme-color-neutral-fill-normal","--lr-theme-color-neutral-fill-quiet","--lr-theme-color-neutral-on-loud","--lr-theme-color-neutral-on-normal","--lr-theme-color-neutral-on-quiet","--lr-theme-color-success-border-loud","--lr-theme-color-success-border-normal","--lr-theme-color-success-border-quiet","--lr-theme-color-success-fill-loud","--lr-theme-color-success-fill-normal","--lr-theme-color-success-fill-quiet","--lr-theme-color-success-on-loud","--lr-theme-color-success-on-normal","--lr-theme-color-success-on-quiet","--lr-theme-color-warning-border-loud","--lr-theme-color-warning-border-normal","--lr-theme-color-warning-border-quiet","--lr-theme-color-warning-fill-loud","--lr-theme-color-warning-fill-normal","--lr-theme-color-warning-fill-quiet","--lr-theme-color-warning-on-loud","--lr-theme-color-warning-on-normal","--lr-theme-color-warning-on-quiet"],STYLE_REFERENCE_SURFACES={lyra:{light:"#ffffff",dark:"#1a1a1a"},data:{light:"#ffffff",dark:"#101820"},"high-contrast":{light:"#ffffff",dark:"#000000"},material:{light:"#fff8f5",dark:"#18120f"},shadcn:{light:"#ffffff",dark:"#0a0a0a"},terminal:{light:"#fcfdf9",dark:"#0e1713"}},STYLE_CONTRAST_SURFACES={light:["#ffffff","#f6f8fa","#f2f5f8","#fff8f5","#f8eeea","#fcf2ed","#f2e7e0","#ecdfd7","#fafafa","#fcfdf9","#f1f5eb"],dark:["#1a1a1a","#22272e","#2b3038","#101820","#192630","#202e39","#000000","#18120f","#251d19","#302621","#120d0a","#211914","#3a2f29","#0a0a0a","#171717","#0e1713","#18271e","#203227"]},STYLE_GEMSTONES={emerald:"#34d399",peridot:"#a8d84a",topaz:"#f0a83c",ruby:"#e63950",tourmaline:"#ec4899",amethyst:"#9d6df0",aquamarine:"#22d3ee",sapphire:"#4f8ff7",hematite:"#94a3b8"},LOOK_ID=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,LOOK_STAMP=Symbol.for("@aceshooting/lyra-ui.look.v1"),STYLE_OWNERSHIP=Symbol.for("@aceshooting/lyra-ui.style-ownership.v1"),STYLE_FIELDS=["look","surface","density","mode","accent","accentBackground","overrides"],DEFAULT_STYLE=Object.freeze({look:"lyra",tokens:null,surface:"solid",density:"comfortable",mode:"system",accent:null,accentName:null,accentBackground:null,overrides:null});let lastStyle={...DEFAULT_STYLE},stylePersistenceFailed=!1,styleModeCleanup,styleModeRoot;const styleOwnershipFallback=new WeakMap,scopeModes=new WeakMap;function ownField(value,key){const descriptor=Object.getOwnPropertyDescriptor(value,key);return descriptor&&"value"in descriptor?descriptor.value:void 0}function styleId(value){return typeof value=="string"&&value.length<=64&&LOOK_ID.test(value)}function styleTokenAllowed(e,r,o=STYLE_SLOTTED){if(e.startsWith("--lr-theme-surface-")||typeof r!="string"&&!o.includes(e))return!1;for(const t of typeof r=="string"?[r]:[r.light,r.dark])if(t)for(const c of t.matchAll(/var\(\s*(--[\w-]+)/g)){if(c[1]==="--lr-theme-shadow-color")continue;const n=e.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1];if(!n||t!==`var(--lr-theme-color-brand-${n})`)return!1}return!0}function styleTokens(value){const tokens=normalizeTokens(value);if(!tokens)return null;const entries=Object.entries(tokens).filter(([name,input])=>styleTokenAllowed(name,input));return entries.length?Object.freeze(Object.fromEntries(entries)):null}function defineLyraLook(look){if(!look||!styleId(ownField(look,"id"))||look.id==="custom")throw new TypeError("Invalid look id");const raw=ownField(look,"tokens");if(!isPlainRecord(raw)||Object.keys(raw).length>TOKEN_ENTRY_MAX)throw new TypeError("Invalid look tokens");for(const[name,descriptor]of Object.entries(Object.getOwnPropertyDescriptors(raw))){if(!("value"in descriptor))throw new TypeError(`Look inputs must be data properties: ${name}`);const value=descriptor.value;if(typeof value=="string"){if(!isSafeLyraThemeTokenValue(value))throw new TypeError(`Invalid look value: ${name}`);continue}if(!isPlainRecord(value)||!STYLE_SLOTTED.includes(name))throw new TypeError(`Invalid per-mode look input: ${name}`);const branches=Object.entries(Object.getOwnPropertyDescriptors(value));if(!branches.length||branches.some(([key,branch])=>!["light","dark"].includes(key)||!("value"in branch)||branch.value!==null&&!isSafeLyraThemeTokenValue(branch.value)))throw new TypeError(`Invalid look mode pair: ${name}`)}const tokens=styleTokens(raw);if(Object.keys(raw).length!==Object.keys(tokens??{}).length)throw new TypeError("Invalid look token or cross-axis reference");const stamped={...tokens,[LOOK_STAMP]:look.id};return Object.freeze(stamped),Object.freeze({id:look.id,tokens:stamped})}function styleColor(value){if(!isSafeLyraThemeTokenValue(value))return null;const text=value.trim();return/\b(?:var|light-dark)\s*\(|\b(?:currentcolor|from)\b/i.test(text)||/^(?:accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)$/i.test(text)?null:/^(?:#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})|[a-z]+|(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix)\(.+\))$/i.test(text)?text:null}function styleColorPair(value){if(typeof value=="string")return styleColor(value);if(!isPlainRecord(value))return null;const light=styleColor(ownField(value,"light")),dark=styleColor(ownField(value,"dark"));return light||dark?Object.freeze({light,dark}):null}function styleAccent(value){if(typeof value=="string")return styleColor(value);if(!isPlainRecord(value))return null;const entries=SEMANTIC_ROLES.filter(role=>Object.hasOwn(value,role)).map(role=>[role,styleColorPair(ownField(value,role))]);return entries.length?Object.freeze(Object.fromEntries(entries)):null}function normalizeStyleChoices(raw,base){const next={...base};if(!isPlainRecord(raw))return next;const look=ownField(raw,"look");if(look!==void 0){if(next.look="lyra",next.tokens=null,styleId(look))next.look=look;else if(isPlainRecord(look))try{const definition=defineLyraLook(look);next.look=definition.id,next.tokens=definition.tokens}catch{}}const surface=ownField(raw,"surface");surface!==void 0&&(next.surface=surface==="glass"?"glass":"solid");const density=ownField(raw,"density");density!==void 0&&(next.density=density==="compact"||density==="touch"?density:"comfortable");const mode=ownField(raw,"mode");mode!==void 0&&(next.mode=mode==="light"||mode==="dark"||mode==="unset"?mode:"system");const accent=ownField(raw,"accent");accent!==void 0&&(next.accentName=typeof accent=="string"&&Object.hasOwn(STYLE_GEMSTONES,accent)?accent:null,next.accent=next.accentName?STYLE_GEMSTONES[next.accentName]:styleAccent(accent));const background=ownField(raw,"accentBackground");background!==void 0&&(next.accentBackground=styleColorPair(background));const overrides=ownField(raw,"overrides");return overrides!==void 0&&(next.overrides=styleTokens(overrides)),next}function styleFromRecord(value){if(!isPlainRecord(value))return{...DEFAULT_STYLE};const version=ownField(value,"version");if(version!==void 0&&version!==2)return{...DEFAULT_STYLE};const state=normalizeStyleChoices({look:ownField(value,"look"),mode:ownField(value,"mode"),density:ownField(value,"density"),surface:ownField(value,"treatment"),overrides:ownField(value,"overrides"),accentBackground:ownField(value,"surface")},{...DEFAULT_STYLE});state.accent=styleAccent(ownField(value,"accent"));const accentName=ownField(value,"accentName");return version===2&&typeof accentName=="string"&&Object.hasOwn(STYLE_GEMSTONES,accentName)&&(state.accentName=accentName,state.accent=STYLE_GEMSTONES[accentName]),state.tokens=normalizeTokens(ownField(value,"tokens")),state.tokens&&!styleId(ownField(value,"look"))&&(state.look="custom"),state}function styleRecord(state){return{version:2,mode:state.mode,look:state.look,density:state.density,treatment:state.surface,accent:state.accent,surface:state.accentBackground,...state.accentName?{accentName:state.accentName}:{},...state.tokens?{tokens:state.tokens}:{},...state.overrides?{overrides:state.overrides}:{}}}function styleResolvedMode(mode,view){return mode==="unset"?null:mode!=="system"?mode:view?.matchMedia?.(COLOR_SCHEME_QUERY).matches?"dark":"light"}function styleSnapshot(state,view){return Object.freeze({look:state.look,lookForm:state.tokens?"runtime":"stylesheet",surface:state.surface,density:state.density,mode:state.mode,accent:state.accentName??state.accent,accentName:state.accentName,accentBackground:state.accentBackground,...state.overrides?{overrides:state.overrides}:{},resolvedMode:styleResolvedMode(state.mode,view)})}function parseLyraStyleRecord(value){const state=styleFromRecord(value),result=styleSnapshot(state);return state.mode==="system"?Object.freeze({...result,resolvedMode:null}):result}function lyraStyleAttributes(style){const attributes={};return styleId(style.look)&&(attributes["data-lr-look"]=style.look),(style.surface==="solid"||style.surface==="glass")&&(attributes["data-lr-surface"]=style.surface),(style.density==="compact"||style.density==="comfortable"||style.density==="touch")&&(attributes["data-lr-density"]=style.density),(style.mode==="light"||style.mode==="dark"||style.mode==="system")&&(attributes["data-lr-mode"]=style.mode),style.accent!==void 0&&(attributes["data-lr-accent"]=style.accent===null?"none":style.accentName===null?"custom":typeof style.accent=="string"&&Object.hasOwn(STYLE_GEMSTONES,style.accent)?style.accent:"custom"),Object.freeze(attributes)}function readStyleState(){if(stylePersistenceFailed)return{...lastStyle};let stored;try{stored=localStorage.getItem(STORAGE_KEY)}catch{return{...lastStyle}}try{return styleFromRecord(JSON.parse(stored??"null"))}catch{return{...DEFAULT_STYLE}}}function persistStyle(state){try{localStorage.setItem(STORAGE_KEY,JSON.stringify(styleRecord(state))),stylePersistenceFailed=!1}catch{stylePersistenceFailed=!0}lastStyle=state}function ownershipFor(element){const node=element;try{const existing=readStyleOwnership(node[STYLE_OWNERSHIP]);if(existing){styleOwnershipFallback.set(element,existing);try{node[STYLE_OWNERSHIP]=existing}catch{}return existing}}catch{}const fallback=styleOwnershipFallback.get(element);if(fallback)return fallback;const record={attributes:new Map,properties:new Map};styleOwnershipFallback.set(element,record);try{node[STYLE_OWNERSHIP]=record}catch{}return record}function writeStyleAttributes(element,desired){const ownership=ownershipFor(element).attributes;for(const[name,value]of ownership)Object.hasOwn(desired,name)||(element.getAttribute(name)===value.written&&(value.before===null?element.removeAttribute(name):element.setAttribute(name,value.before)),ownership.delete(name));for(const[name,value]of Object.entries(desired))ownership.has(name)||ownership.set(name,{before:element.getAttribute(name),priority:"",written:value}),element.getAttribute(name)!==value&&element.setAttribute(name,value),ownership.get(name).written=value}function writeStyleProperties(element,desired){const style=element.style;if(!style)return;const ownership=ownershipFor(element).properties;for(const[name,value]of ownership)desired.has(name)||(style.getPropertyValue(name)===value.written&&style.getPropertyPriority(name)===""&&(value.before?style.setProperty(name,value.before,value.priority):style.removeProperty(name)),ownership.delete(name));for(const[name,value]of desired){ownership.has(name)||ownership.set(name,{before:style.getPropertyValue(name),priority:style.getPropertyPriority(name),written:null});const record=ownership.get(name);(style.getPropertyPriority(name)!==""||style.getPropertyValue(name)!==value&&!(record.requested===value&&record.written===style.getPropertyValue(name)))&&(style.getPropertyPriority(name)&&style.removeProperty(name),style.setProperty(name,value,"")),record.requested=value,record.written=style.getPropertyValue(name)}}function styleSlot(name,mode,accent=!1){return`--_lr-${accent?"a":"l"}${mode==="light"?"l":"d"}-${name.slice(11)}`}function styleFollow(name,value){const channel=name.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1];return!!(channel&&value===`var(--lr-theme-color-brand-${channel})`)}function styleBranch(name,mode){let result=`var(${styleSlot(name,mode)})`;if(STYLE_FOLLOW.includes(name)){const key=mode==="light"?"l":"d",target=name.replace(/color-(?:success|warning|danger|neutral)-/,"color-brand-");result=`var(--_lr-f${key}-${name.slice(11)},${result})var(--_lr-o${key}-${name.slice(11)},var(${styleSlot(target,mode,!0)},var(${styleSlot(target,mode)})))`}return ALL_RAMP_PROPERTIES.includes(name)?`var(${styleSlot(name,mode,!0)},${result})`:result}function styleResolvedInput(name){const input=`var(--_lr-dark-on,${styleBranch(name,"light")})var(--_lr-light-on,${styleBranch(name,"dark")})`;if(!STYLE_DENSITY.includes(name))return input;const spacing=name.startsWith("--lr-theme-space-");return`var(--_lr-dense-on,${input})var(--_lr-dense-off,max(calc((${input}) * var(--_lr-density-${spacing?"space":"control"},1)),${spacing?"0px":"var(--_lr-density-target-min,0px)"}))`}function styleBackground(state,entries,mode,element){const explicit=typeof state.accentBackground=="string"?state.accentBackground:state.accentBackground?.[mode],ownLook=element.getAttribute("data-lr-look");let reference=explicit??entries.get("--lr-theme-color-surface-default")??(ownLook?(STYLE_REFERENCE_SURFACES[ownLook]??STYLE_REFERENCE_SURFACES.lyra)?.[mode]:void 0);if(!reference){const slot=styleSlot("--lr-theme-color-surface-default",mode),style=element.style,owned=ownershipFor(element).properties.get(slot),suspend=owned&&style?.getPropertyValue(slot)===owned.written&&!style.getPropertyPriority(slot);try{suspend&&(owned.before?style.setProperty(slot,owned.before,owned.priority):style.removeProperty(slot)),reference=element.ownerDocument.defaultView?.getComputedStyle(element).getPropertyValue(slot).trim()}finally{suspend&&owned.written!==null&&style.setProperty(slot,owned.written)}}return reference}const stylePaintCache=new WeakMap;function stylePaint(state,element,wholeDocument){const desired=new Map,mode=styleResolvedMode(state.mode,element.ownerDocument.defaultView),tokens={...state.tokens,...state.overrides};if(wholeDocument&&mode===null)for(const[name,value]of tokenEntries(tokens,null))desired.set(name,value);if(!Object.keys(tokens).length&&(!state.accent||state.accentName))return stylePaintCache.delete(element),desired;const resolver=element.ownerDocument.defaultView?.getComputedStyle(element).getPropertyValue("--_lr-style-resolver").trim()==="1";let cache=stylePaintCache.get(element);cache||(cache=new Map,stylePaintCache.set(element,cache));let applied=state.accent;for(const branch of["light","dark"]){const entries=tokenEntries(tokens,branch),reference=styleBackground(state,entries,branch,element),key=JSON.stringify([tokens,state.accent,state.accentName,reference]);let cached=cache.get(branch);if(!cached||cached.key!==key){const background=reference?parseResolvedRgb(reference,MODE_DEFAULTS[branch].surface,element.ownerDocument)??MODE_DEFAULTS[branch].surface:MODE_DEFAULTS[branch].surface,accent=state.accentName?{applied:state.accent,properties:new Map}:paintAccent(state.accent,branch,background,element.ownerDocument);cached={key,tokens:floorTokenEntries(entries,branch,background,element.ownerDocument),accent:accent.properties,applied:accent.applied},cache.set(branch,cached)}branch===mode&&(applied=cached.applied);const painted=cached.tokens;for(const[name,value]of painted)STYLE_SLOTTED.includes(name)&&styleTokenAllowed(name,value)?(styleFollow(name,value)?(desired.set(`--_lr-f${branch==="light"?"l":"d"}-${name.slice(11)}`," "),desired.set(`--_lr-o${branch==="light"?"l":"d"}-${name.slice(11)}`,"initial")):(desired.set(styleSlot(name,branch),value),STYLE_FOLLOW.includes(name)&&(desired.set(`--_lr-f${branch==="light"?"l":"d"}-${name.slice(11)}`,"initial"),desired.set(`--_lr-o${branch==="light"?"l":"d"}-${name.slice(11)}`," "))),wholeDocument&&branch===mode&&desired.set(name,resolver?styleResolvedInput(name):value)):(wholeDocument?branch===mode:typeof tokens[name]=="string"&&!STYLE_SLOTTED.includes(name))&&desired.set(name,value);if(state.accent&&!state.accentName)for(const[name,value]of cached.accent){if(name==="--lr-theme-accent"){branch===mode&&desired.set(name,value);continue}desired.set(styleSlot(name,branch,!0),value),wholeDocument&&branch===mode&&desired.set(name,resolver?styleResolvedInput(name):value)}}return state.accent=applied,desired}const styleModeGroups=new WeakMap;function attachStyleMode(element,callback){const view=element.ownerDocument.defaultView;if(!view?.matchMedia)return()=>{};let group=styleModeGroups.get(view);if(!group){const query=view.matchMedia(COLOR_SCHEME_QUERY),subscriptions=new Set,modern=typeof query.addEventListener=="function"&&typeof query.removeEventListener=="function",detach=()=>{modern?query.removeEventListener("change",listener):query.removeListener?.(listener)},listener=()=>{for(const subscription2 of subscriptions){const node=subscription2.element.deref();node?.ownerDocument.defaultView===view?subscription2.callback(node):subscriptions.delete(subscription2)}subscriptions.size||(detach(),styleModeGroups.delete(view))};group={query,subscriptions,detach},styleModeGroups.set(view,group),modern?query.addEventListener("change",listener):query.addListener?.(listener)}const subscription={element:new WeakRef(element),callback};group.subscriptions.add(subscription);const active=group;return()=>{active.subscriptions.delete(subscription),active.subscriptions.size||(active.detach(),styleModeGroups.delete(view))}}function applyStyleState(element,state,fields){const snapshot=styleSnapshot(state,element.ownerDocument.defaultView),attributes={...lyraStyleAttributes(snapshot)};if(fields)for(const[field,name]of[["look","look"],["surface","surface"],["density","density"],["mode","mode"],["accent","accent"]])fields.has(field)||delete attributes[`data-lr-${name}`];state.accent&&!state.accentName&&(!fields||fields.has("accent"))&&(attributes["data-lr-accent"]="custom"),(!fields||fields.has("mode"))&&snapshot.resolvedMode&&(attributes["data-lr-theme"]=snapshot.resolvedMode,attributes["data-theme"]=snapshot.resolvedMode),(state.tokens||state.overrides||state.accent&&!state.accentName)&&(attributes["data-lr-theme-scope"]=""),writeStyleAttributes(element,attributes);const desired=stylePaint(state,element,!fields);!state.accent&&snapshot.accent&&(attributes["data-lr-accent"]="none",!state.tokens&&!state.overrides&&delete attributes["data-lr-theme-scope"],writeStyleAttributes(element,attributes)),writeStyleProperties(element,desired),diagnoseStyleSheets(element,state,fields)}function diagnoseStyleSheets(element,state,fields){if(!litDevWarnings())return;const selected=field=>!fields||fields.has(field),required=[];selected("look")&&!state.tokens&&state.look!=="lyra"&&required.push(["--_lr-look-installed",`${state.look}-1`,`the stylesheet for look '${state.look}'`]),selected("surface")&&state.surface==="glass"&&required.push(["--_lr-surface-installed","1","surfaces/glass.css"]),selected("density")&&state.density!=="comfortable"&&required.push(["--_lr-density-installed","1","density.css"]),selected("accent")&&state.accentName&&required.push(["--_lr-accent-installed",`${state.accentName}-1`,"accents.css"]);const scopedRuntime=!!(fields&&(state.tokens||state.overrides||state.accent&&!state.accentName));if(!required.length&&!scopedRuntime)return;const computed=element.ownerDocument.defaultView?.getComputedStyle(element);if(computed){computed.getPropertyValue("--_lr-style-resolver").trim()!=="1"&&devWarnOnce("lyra-style:resolver","Lyra style choices require theme.css in the scope that owns their attributes.");for(const[property,expected,stylesheet]of required)computed.getPropertyValue(property).trim()!==expected&&devWarnOnce(`lyra-style:${property}:${expected}`,`Lyra could not find ${stylesheet} in this style scope; import or adopt the stylesheet before selecting it.`)}}function emitStyleChange(state,changed){const style=styleSnapshot(state,window);window.dispatchEvent(new CustomEvent("lr-style-change",{detail:Object.freeze({style,changed:Object.freeze([...changed])})})),window.dispatchEvent(new CustomEvent("lr-theme-change",{detail:legacyStyleSnapshot(state)}))}function legacyStyleSnapshot(state){const surface=typeof state.accentBackground=="string"?state.accentBackground:state.accentBackground?.[styleResolvedMode(state.mode,typeof window>"u"?void 0:window)??"light"]??null,tokens=state.tokens||state.overrides?Object.freeze({...state.tokens,...state.overrides}):null;return{mode:state.mode==="system"?"auto":state.mode,accent:state.accent,surface,...tokens?{tokens}:{}}}function setLyraStyle(choices){const before=readStyleState();return commitStyle(before,normalizeStyleChoices(choices,before))}function commitStyle(before,next){if(typeof document<"u"&&(next.accent=normalizeAccent(next.accent),typeof next.accentBackground=="string"&&(next.accentBackground=normalizeColor(next.accentBackground)),next.accent||(next.accentName=null)),persistStyle(next),typeof document<"u"){const root=document.documentElement;(next.mode!=="system"||styleModeRoot?.deref()!==root)&&(styleModeCleanup?.(),styleModeCleanup=void 0,styleModeRoot=void 0),root.removeAttribute("data-lr-theme-preset"),adoptLegacyOwnership(root);const requestedAccent=next.accent;applyStyleState(root,next),accentsEqual(requestedAccent,next.accent)||persistStyle(next),next.mode==="system"&&!styleModeCleanup&&(styleModeRoot=new WeakRef(root),styleModeCleanup=attachStyleMode(root,element=>{applyStyleState(element,lastStyle),emitStyleChange(lastStyle,["resolvedMode"])}));const changed=STYLE_FIELDS.filter(field=>field==="look"?before.look!==next.look||!tokensEqual(before.tokens,next.tokens):field==="accent"?before.accentName!==next.accentName||!accentsEqual(before.accent,next.accent):JSON.stringify(before[field])!==JSON.stringify(next[field]));emitStyleChange(next,changed)}return styleSnapshot(next,typeof window>"u"?void 0:window)}function adoptLegacyOwnership(root){const symbol=Symbol.for(TOKEN_OWNERSHIP_SYMBOL),node=root;try{if(!Array.isArray(node[symbol]))return}catch{return}const ownership=ownershipFor(root).properties;for(const name of[...readOwnershipList(),...ALL_RAMP_PROPERTIES,"--lr-theme-accent"])ownership.has(name)||!root.style.getPropertyValue(name)||ownership.set(name,{before:null,priority:"",written:root.style.getPropertyValue(name)});try{delete node[symbol]}catch{}}function getLyraStyle(){return styleSnapshot(readStyleState(),typeof window>"u"?void 0:window)}function resetLyraStyle(fields=STYLE_FIELDS){return setLyraStyle(Object.fromEntries(fields.filter(field=>STYLE_FIELDS.includes(field)).map(field=>[field,null])))}function applyLyraStyleScope(element,choices){if(scopeModes.get(element)?.(),scopeModes.delete(element),choices===null){writeStyleAttributes(element,{}),writeStyleProperties(element,new Map);return}const state=normalizeStyleChoices(choices,{...DEFAULT_STYLE}),fields=new Set(STYLE_FIELDS.filter(field=>ownField(choices,field)!==void 0));applyStyleState(element,state,fields),choices.mode==="system"&&scopeModes.set(element,attachStyleMode(element,node=>applyStyleState(node,state,fields)))}const lyraThemeBootstrap=createLyraThemeBootstrap();export{accentsEqual,applyLyraStyleScope,createLyraThemeBootstrap,defineLyraLook,getLyraStyle,getLyraTheme,isLyraThemeTokenName,isSafeLyraThemeTokenValue,lyraStyleAttributes,lyraThemeBootstrap,parseLyraStyleRecord,resetLyraStyle,setLyraStyle,setLyraTheme,tokensEqual};
1
+ import{devWarnOnce,litDevWarnings}from"../internal/dev-warning.js";import{readStyleOwnership}from"./style-ownership.js";const STORAGE_KEY="lyra-theme",TOKEN_NAME_PATTERN=/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/,TOKEN_NAME_MAX_LENGTH=80,TOKEN_RESERVED_NAME="--lr-theme-accent",TOKEN_ENTRY_MAX=512,TOKEN_SYNTHESIZED_MAX=16,TOKEN_VALUE_MAX_LENGTH=256,TOKEN_FORBIDDEN_PATTERN=/[\x00-\x1f\x7f\\;{}!<>@[\]`$^|~=?&:\u2028\u2029]|\/\*|\*\//,TOKEN_CSS_WIDE_PATTERN=/^(?:inherit|initial|revert(?:-layer)?|unset)$/i,TOKEN_FUNCTION_PATTERN=/([a-z0-9_-]+)\s*\(/gi,TOKEN_ALLOWED_FUNCTIONS="rgb rgba hsl hsla hwb lab lch oklab oklch color color-mix light-dark calc min max clamp var cubic-bezier steps linear".split(" "),TOKEN_OWNERSHIP_MAX=TOKEN_ENTRY_MAX+TOKEN_SYNTHESIZED_MAX,TOKEN_OWNERSHIP_SYMBOL="@aceshooting/lyra-ui.theme-tokens.v1",MODE_DEFAULTS={light:{surface:[255,255,255],raised:[246,248,250],text:[26,26,26],overlayStrongAlpha:.92},dark:{surface:[26,26,26],raised:[34,39,46],text:[242,242,242],overlayStrongAlpha:.95}},COLOR_SCHEME_QUERY="(prefers-color-scheme: dark)",SEMANTIC_ROLES=["brand","success","warning","danger","neutral"],RAMP_CHANNELS=["fill","border","on"],RAMP_TIERS=["quiet","normal","loud"];function roleRampProperties(role){const properties=[];for(const channel of RAMP_CHANNELS)for(const tier of RAMP_TIERS)properties.push(`--lr-theme-color-${role}-${channel}-${tier}`);return properties}const ALL_RAMP_PROPERTIES=[...SEMANTIC_ROLES.flatMap(roleRampProperties),"--lr-theme-color-focus"],MODE_ATTRIBUTES=["data-lr-theme","data-theme"];function isBalancedCssValue(value){let depth=0,quote="";for(const character of value){if(quote){character===quote&&(quote="");continue}if(character==="'"||character==='"')quote=character;else if(character==="(")depth+=1;else if(character===")"&&(depth-=1)<0)return!1}return quote===""&&depth===0}function isLyraThemeTokenName(name){return typeof name=="string"&&name.length<=TOKEN_NAME_MAX_LENGTH&&TOKEN_NAME_PATTERN.test(name)&&name!==TOKEN_RESERVED_NAME}function isSafeLyraThemeTokenValue(value){if(typeof value!="string")return!1;const trimmed=value.trim();if(!trimmed||trimmed.length>TOKEN_VALUE_MAX_LENGTH||TOKEN_FORBIDDEN_PATTERN.test(trimmed)||TOKEN_CSS_WIDE_PATTERN.test(trimmed))return!1;for(const match of trimmed.matchAll(TOKEN_FUNCTION_PATTERN))if(!TOKEN_ALLOWED_FUNCTIONS.includes((match[1]??"").toLowerCase()))return!1;return isBalancedCssValue(trimmed)}function isPlainRecord(value){if(typeof value!="object"||value===null||Array.isArray(value))return!1;const prototype=Object.getPrototypeOf(value);if(prototype===Object.prototype||prototype===null)return!0;if(Object.getPrototypeOf(prototype)!==null)return!1;const constructor=Object.getOwnPropertyDescriptor(prototype,"constructor")?.value;return typeof constructor=="function"&&Function.prototype.toString.call(constructor)===Function.prototype.toString.call(Object)}function normalizeTokenBranch(value){return isSafeLyraThemeTokenValue(value)?value.trim():null}function normalizeTokens(raw){try{if(!isPlainRecord(raw))return null;const names=Object.keys(raw);if(names.length===0||names.length>TOKEN_ENTRY_MAX)return null;const result={};let kept=0;for(const name of names){if(!isLyraThemeTokenName(name))continue;const value=ownField(raw,name);if(typeof value=="string"){const normalized=normalizeTokenBranch(value);if(normalized===null)continue;result[name]=normalized,kept+=1;continue}if(!isPlainRecord(value))continue;const keys=Object.keys(value),hasLight=Object.prototype.hasOwnProperty.call(value,"light"),hasDark=Object.prototype.hasOwnProperty.call(value,"dark");if(!hasLight&&!hasDark||keys.some(key=>key!=="light"&&key!=="dark"))continue;const light=normalizeTokenBranch(ownField(value,"light")),dark=normalizeTokenBranch(ownField(value,"dark"));light===null&&dark===null||(result[name]=Object.freeze({light,dark}),kept+=1)}return kept>0?Object.freeze(result):null}catch{return null}}function tokensEqual(left,right){const leftNames=left?Object.keys(left):[],rightNames=right?Object.keys(right):[];if(leftNames.length!==rightNames.length)return!1;if(leftNames.length===0)return!0;const leftMap=left,rightMap=right;return leftNames.every(name=>{if(!Object.prototype.hasOwnProperty.call(rightMap,name))return!1;const a=leftMap[name],b=rightMap[name];return typeof a=="string"||typeof b=="string"?a===b:!a||!b?!1:(a.light??null)===(b.light??null)&&(a.dark??null)===(b.dark??null)})}function normalizeColor(value,owner=document){if(typeof value!="string"||!value.trim())return null;const candidate=value.trim();if(!isBalancedCssValue(candidate)||TOKEN_CSS_WIDE_PATTERN.test(candidate)||/^(?:accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)$/i.test(candidate)||/\bcurrentcolor\b/i.test(candidate)||/\bvar\s*\(/i.test(candidate)||/\blight-dark\s*\(/i.test(candidate)||/\b(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)\s*\(\s*from\b/i.test(candidate))return null;const probe=owner.createElement("span");return probe.style.color=candidate,probe.style.color?candidate:null}function normalizeAccentValue(value){if(typeof value=="string"||value===null)return normalizeColor(value);if(typeof value!="object"||Array.isArray(value))return null;const record=value;if(!("light"in record)&&!("dark"in record))return null;const light=normalizeColor(record.light),dark=normalizeColor(record.dark);return light||dark?{light,dark}:null}function normalizeAccent(value){if(typeof value=="string")return normalizeColor(value);if(value===null||typeof value!="object"||Array.isArray(value))return null;const record=value,result={};let hasRole=!1;for(const role of SEMANTIC_ROLES)role in record&&(hasRole=!0,result[role]=normalizeAccentValue(record[role]));return hasRole?result:null}function resolveAccentValueForMode(value,mode){return typeof value=="string"?value:value?value[mode]??null:null}function accentValueEqual(left,right){return left===right?!0:typeof left=="string"||typeof right=="string"||left===null||right===null?!1:(left.light??null)===(right.light??null)&&(left.dark??null)===(right.dark??null)}function accentsEqual(left,right){if(left===right)return!0;if(typeof left=="string"||typeof right=="string"||left===null||right===null)return!1;const leftKeys=Object.keys(left),rightKeys=Object.keys(right);return leftKeys.length!==rightKeys.length?!1:leftKeys.every(role=>accentValueEqual(left[role],right[role]))}function parseResolvedRgb(value,background,owner=document){if(!normalizeColor(value,owner))return null;try{const canvas=owner.createElement("canvas");canvas.width=1,canvas.height=1;const context=canvas.getContext("2d",{willReadFrequently:!0});if(!context)return null;context.clearRect(0,0,1,1),context.fillStyle=value,context.fillRect(0,0,1,1);const channels=context.getImageData(0,0,1,1).data,red=channels[0]??0,green=channels[1]??0,blue=channels[2]??0,alpha=(channels[3]??0)/255;return[Math.round(red*alpha+background[0]*(1-alpha)),Math.round(green*alpha+background[1]*(1-alpha)),Math.round(blue*alpha+background[2]*(1-alpha))]}catch{return null}}function mixRgb(base,color,colorWeight){return[Math.round(base[0]*(1-colorWeight)+color[0]*colorWeight),Math.round(base[1]*(1-colorWeight)+color[1]*colorWeight),Math.round(base[2]*(1-colorWeight)+color[2]*colorWeight)]}function serializeRgb(color){return`rgb(${color.join(" ")})`}function relativeLuminance(color){const linearize=channel=>{const normalized=channel/255;return normalized<=.04045?normalized/12.92:((normalized+.055)/1.055)**2.4};return linearize(color[0])*.2126+linearize(color[1])*.7152+linearize(color[2])*.0722}function contrastRatio(left,right){const a=relativeLuminance(left),b=relativeLuminance(right);return(Math.max(a,b)+.05)/(Math.min(a,b)+.05)}function contrastForeground(fill){const black=[0,0,0],white=[255,255,255];return contrastRatio(fill,black)>=contrastRatio(fill,white)?black:white}function ensureSurfaceContrast(color,background,minimum=3,alsoAgainst=background,references=[]){const passes=candidate=>contrastRatio(candidate,background)>=minimum&&contrastRatio(candidate,alsoAgainst)>=minimum&&references.every(reference=>contrastRatio(candidate,reference)>=minimum);if(passes(color))return color;const black=[0,0,0],white=[255,255,255],target=contrastRatio(background,black)>=contrastRatio(background,white)?black:white;for(let step=1;step<=10;step+=1){const candidate=mixRgb(color,target,step/10);if(passes(candidate))return candidate}return target}function createRoleRamp(role,base,mode,background,owner=document){const references=STYLE_CONTRAST_SURFACES[mode].flatMap(color=>{const value=parseResolvedRgb(color,MODE_DEFAULTS[mode].surface,owner);return value?[value]:[]}),resolved=parseResolvedRgb(base,background,owner);if(!resolved)return null;const quiet=mixRgb(background,resolved,mode==="dark"?.24:.14),normal=mixRgb(background,resolved,mode==="dark"?.62:.55),loud=ensureSurfaceContrast(resolved,background,4.5,quiet,references),borderTarget=mode==="dark"?[255,255,255]:[0,0,0],borderQuiet=mixRgb(background,resolved,mode==="dark"?.46:.38),borderNormal=ensureSurfaceContrast(mixRgb(background,resolved,mode==="dark"?.78:.72),background,3,background,references),borderLoud=ensureSurfaceContrast(mixRgb(loud,borderTarget,.2),background,3,background,references),prefix=`--lr-theme-color-${role}`,ramp={[`${prefix}-fill-quiet`]:serializeRgb(quiet),[`${prefix}-fill-normal`]:serializeRgb(normal),[`${prefix}-fill-loud`]:serializeRgb(loud),[`${prefix}-border-quiet`]:serializeRgb(borderQuiet),[`${prefix}-border-normal`]:serializeRgb(borderNormal),[`${prefix}-border-loud`]:serializeRgb(borderLoud),[`${prefix}-on-quiet`]:serializeRgb(contrastForeground(quiet)),[`${prefix}-on-normal`]:serializeRgb(contrastForeground(normal)),[`${prefix}-on-loud`]:serializeRgb(contrastForeground(loud))};return role==="brand"&&(ramp["--lr-theme-color-focus"]=serializeRgb(ensureSurfaceContrast(resolved,background,3,background,references))),ramp}function paintAccent(accent,mode,background,owner=document){const properties=new Map;if(!accent)return{applied:null,properties};if(!mode)return{applied:accent,properties};if(typeof accent=="string"){const ramp=createRoleRamp("brand",accent,mode,background,owner);if(!ramp)return{applied:null,properties};properties.set("--lr-theme-accent",accent);for(const[property,value]of Object.entries(ramp))properties.set(property,value);return{applied:accent,properties}}const applied={};let appliedBrandColor=null;for(const role of SEMANTIC_ROLES){const value=accent[role];if(!value)continue;const isPerMode=typeof value!="string",base=resolveAccentValueForMode(value,mode);let painted=!1;if(base){const ramp=createRoleRamp(role,base,mode,background,owner);if(ramp){for(const[property,propertyValue]of Object.entries(ramp))properties.set(property,propertyValue);painted=!0,role==="brand"&&(appliedBrandColor=base)}}(painted||isPerMode)&&(applied[role]=value)}return appliedBrandColor&&properties.set("--lr-theme-accent",appliedBrandColor),{applied:Object.keys(applied).length>0?applied:null,properties}}function tokenEntries(tokens,mode){const entries=new Map;if(!tokens)return entries;for(const[name,value]of Object.entries(tokens))if(typeof value=="string")entries.set(name,value);else if(mode){const branch=value[mode];branch&&entries.set(name,branch)}return entries}function resolveTokenColor(value,background,owner){return value===void 0||!background||!normalizeColor(value,owner)?null:parseResolvedRgb(value,background,owner)}function floorTokenEntries(entries,mode,surface,owner=document){const resolveColor=(value,background)=>resolveTokenColor(value,background,owner),painted=new Map(entries),prefix="--lr-theme-",defaults=MODE_DEFAULTS[mode],raised=((name,fallback)=>entries.has(prefix+name)?resolveColor(entries.get(prefix+name),surface):fallback)("color-surface-raised",defaults.raised),floor=(name,over,against,minimum,alsoAgainst)=>{const value=painted.get(name);if(value===void 0||!against||alsoAgainst===null)return;const color=resolveColor(value,over);if(!color)return;const repaired=ensureSurfaceContrast(color,against,minimum,alsoAgainst??against);repaired!==color&&painted.set(name,serializeRgb(repaired))};floor(`${prefix}color-text-normal`,surface,surface,4.5,raised),floor(`${prefix}color-text-quiet`,surface,surface,4.5,raised);const text=entries.has(`${prefix}color-text-normal`)?resolveColor(painted.get(`${prefix}color-text-normal`),surface):defaults.text,synthesized=new Map,pairForeground=(onName,fill)=>{if(!fill)return;const on=painted.get(onName);if(on===void 0){synthesized.set(onName,serializeRgb(contrastForeground(fill)));return}const color=resolveColor(on,fill);color&&contrastRatio(color,fill)<4.5&&painted.set(onName,serializeRgb(contrastForeground(fill)))};for(const role of SEMANTIC_ROLES)for(const tier of RAMP_TIERS){const fillName=`${prefix}color-${role}-fill-${tier}`;entries.has(fillName)&&pairForeground(`${prefix}color-${role}-on-${tier}`,resolveColor(entries.get(fillName),surface))}const overlayName=`${prefix}color-overlay-strong`,overlay=entries.has(overlayName)?resolveColor(entries.get(overlayName),surface):mixRgb(surface,[0,0,0],defaults.overlayStrongAlpha);(entries.has(overlayName)||entries.has(`${prefix}color-on-strong-overlay`))&&pairForeground(`${prefix}color-on-strong-overlay`,overlay);const boundaries=[...SEMANTIC_ROLES.flatMap(role=>[`${prefix}color-${role}-border-normal`,`${prefix}color-${role}-border-loud`]),`${prefix}color-surface-border`,`${prefix}color-border-strong`,`${prefix}color-focus`];for(const name of boundaries)floor(name,surface,surface,3);for(const name of entries.keys())/^--lr-theme-color-chart-\d+$/.test(name)?floor(name,surface,surface,3):/^--lr-theme-terminal-color-[a-z0-9-]+$/.test(name)?floor(name,raised,raised,4.5):/^--lr-theme-terminal-bg-[a-z0-9-]+$/.test(name)&&floor(name,raised,text,4.5);for(const[name,value]of synthesized)painted.set(name,value);return painted}function readOwnershipList(){try{const list=document.documentElement[Symbol.for(TOKEN_OWNERSHIP_SYMBOL)];if(!Array.isArray(list))return[];const names=[],length=Math.min(list.length,TOKEN_OWNERSHIP_MAX);for(let index=0;index<length;index+=1){const name=list[index];isLyraThemeTokenName(name)&&names.push(name)}return names}catch{return[]}}function applyStoredThemeBeforePaint(A){try{const x=A.record,S=x.mode==="light"||x.mode==="dark"||x.mode==="unset"?x.mode:"auto";let a=null;S==="light"||S==="dark"?a=S:S==="auto"&&(a=matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");const N=A.root,i=N.style,O=["brand","success","warning","danger","neutral"],rt=["fill","border","on"],W=["quiet","normal","loud"],B=[];for(const t of O)for(const e of rt)for(const o of W)B.push(`--lr-theme-color-${t}-${e}-${o}`);B.push("--lr-theme-color-focus");const nt=/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/,st=80,ct="--lr-theme-accent",_=512,lt=16,at=256,it=/[\x00-\x1f\x7f\\;{}!<>@[\]`$^|~=?&:\u2028\u2029]|\/\*|\*\//,G=/^(?:inherit|initial|revert(?:-layer)?|unset)$/i,ft=/([a-z0-9_-]+)\s*\(/gi,ut="rgb rgba hsl hsla hwb lab lch oklab oklch color color-mix light-dark calc min max clamp var cubic-bezier steps linear".split(" "),H=Symbol.for("@aceshooting/lyra-ui.theme-tokens.v1"),ht={light:{surface:[255,255,255],raised:[246,248,250],text:[26,26,26],overlayStrongAlpha:.92},dark:{surface:[26,26,26],raised:[34,39,46],text:[242,242,242],overlayStrongAlpha:.95}},J=t=>{let e=0,o="";for(const r of t){if(o){r===o&&(o="");continue}if(r==="'"||r==='"')o=r;else if(r==="(")e+=1;else if(r===")"&&(e-=1)<0)return!1}return o===""&&e===0},U=t=>typeof t=="string"&&t.length<=st&&nt.test(t)&&t!==ct,C=t=>{if(typeof t!="string")return null;const e=t.trim();if(!e||e.length>at||it.test(e)||G.test(e))return null;for(const o of e.matchAll(ft))if(!ut.includes((o[1]??"").toLowerCase()))return null;return J(e)?e:null},D=t=>{if(typeof t!="object"||t===null||Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null},E=[];try{const t=N[H];if(Array.isArray(t)){const e=Math.min(t.length,_+lt);for(let o=0;o<e;o+=1){const r=t[o];U(r)&&E.push(r)}}}catch{E.length=0}for(const t of[...B,"--lr-theme-accent",...E])i.removeProperty(t);const R={};try{const t=x.tokens,e=D(t)?Object.keys(t):[];if(D(t)&&e.length<=_)for(const o of e){if(!U(o))continue;const r=t[o];if(typeof r=="string"){const m=C(r);m!==null&&(R[o]=m);continue}if(!D(r))continue;const c=Object.prototype.hasOwnProperty.call(r,"light"),p=Object.prototype.hasOwnProperty.call(r,"dark");if(!c&&!p||Object.keys(r).some(m=>m!=="light"&&m!=="dark"))continue;const f=C(r.light),d=C(r.dark);(f!==null||d!==null)&&(R[o]={light:f,dark:d})}}catch{}if(A.normalizeOnly)return R;const u=new Map;for(const[t,e]of Object.entries(A.tokens??R)){const o=typeof e=="string"?e:a?e[a]:null;o&&u.set(t,o)}const dt=t=>G.test(t)||/^(?:accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)$/i.test(t)||/\bcurrentcolor\b/i.test(t)||/\bvar\s*\(/i.test(t)||/\blight-dark\s*\(/i.test(t)||/\b(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)\s*\(\s*from\b/i.test(t),v=t=>{if(typeof t!="string")return null;const e=t.trim();if(!e||!J(e)||dt(e))return null;const o=document.createElement("span");return o.style.color=e,o.style.color?e:null},mt=t=>{if(typeof t=="string")return v(t);if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;return!a||!("light"in e)&&!("dark"in e)?null:v(e[a])},T={},z=x.accent;if(typeof z=="string"){const t=v(z);t&&(T.brand=t)}else if(z&&typeof z=="object"&&!Array.isArray(z))for(const t of O){const e=mt(z[t]);e&&(T[t]=e)}let b=null;if(a&&(u.size>0||Object.keys(T).length>0))try{const t=document.createElement("canvas");t.width=1,t.height=1,b=t.getContext("2d",{willReadFrequently:!0})}catch{b=null}const V=(t,e)=>{if(!b)return null;try{b.clearRect(0,0,1,1),b.fillStyle=t,b.fillRect(0,0,1,1);const o=[...b.getImageData(0,0,1,1).data],r=(o[3]??0)/255;return[0,1,2].map(c=>Math.round((o[c]??0)*r+(e[c]??0)*(1-r)))}catch{return null}},P=(t,e,o)=>t.map((r,c)=>Math.round(r*(1-o)+(e[c]??0)*o)),X=t=>{const e=t.map(o=>{const r=o/255;return r<=.04045?r/12.92:((r+.055)/1.055)**2.4});return(e[0]??0)*.2126+(e[1]??0)*.7152+(e[2]??0)*.0722},k=(t,e)=>{const o=X(t),r=X(e);return(Math.max(o,r)+.05)/(Math.min(o,r)+.05)},M=[0,0,0],j=[255,255,255],w=t=>k(t,M)>=k(t,j)?M:j,q=(t,e,o=3,r=e)=>{const c=f=>k(f,e)>=o&&k(f,r)>=o&&(A.references??[]).every(d=>k(f,d)>=o);if(c(t))return t;const p=k(e,M)>=k(e,j)?M:j;for(let f=1;f<=10;f+=1){const d=P(t,p,f/10);if(c(d))return d}return p},h=t=>`rgb(${t.join(" ")})`,F=ht[a??"light"],Y=F.surface,Z=v(x.surface)??v(u.get("--lr-theme-color-surface-default")),s=Z&&V(Z,Y)||Y,$=new Map(u);if(a){const t="--lr-theme-",e=(n,l)=>n!==void 0&&l&&v(n)?V(n,l):null,r=((n,l)=>u.has(t+n)?e(u.get(t+n),s):l)("color-surface-raised",F.raised),c=(n,l,g,L,tt)=>{const et=$.get(n);if(et===void 0||!g||tt===null)return;const Q=e(et,l);if(!Q)return;const ot=q(Q,g,L,tt??g);ot!==Q&&$.set(n,h(ot))};c(`${t}color-text-normal`,s,s,4.5,r),c(`${t}color-text-quiet`,s,s,4.5,r);const p=u.has(`${t}color-text-normal`)?e($.get(`${t}color-text-normal`),s):F.text,f=new Map,d=(n,l)=>{if(!l)return;const g=$.get(n);if(g===void 0){f.set(n,h(w(l)));return}const L=e(g,l);L&&k(L,l)<4.5&&$.set(n,h(w(l)))};for(const n of O)for(const l of W){const g=`${t}color-${n}-fill-${l}`;u.has(g)&&d(`${t}color-${n}-on-${l}`,e(u.get(g),s))}const m=`${t}color-overlay-strong`,K=u.has(m)?e(u.get(m),s):P(s,M,F.overlayStrongAlpha);(u.has(m)||u.has(`${t}color-on-strong-overlay`))&&d(`${t}color-on-strong-overlay`,K);const y=[...O.flatMap(n=>[`${t}color-${n}-border-normal`,`${t}color-${n}-border-loud`]),`${t}color-surface-border`,`${t}color-border-strong`,`${t}color-focus`];for(const n of y)c(n,s,s,3);for(const n of u.keys())/^--lr-theme-color-chart-\d+$/.test(n)?c(n,s,s,3):/^--lr-theme-terminal-color-[a-z0-9-]+$/.test(n)?c(n,r,r,4.5):/^--lr-theme-terminal-bg-[a-z0-9-]+$/.test(n)&&c(n,r,p,4.5);for(const[n,l]of f)$.set(n,l)}try{N[H]=Object.freeze([...$.keys()])}catch{}for(const[t,e]of $)i.setProperty(t,e);if(!a||!b){i.removeProperty("--lr-theme-accent");return}let I=null;for(const t of O){const e=T[t];if(!e)continue;const o=V(e,s);if(!o)continue;const r=P(s,o,a==="dark"?.24:.14),c=P(s,o,a==="dark"?.62:.55),p=q(o,s,4.5,r),f=a==="dark"?j:M,d=P(s,o,a==="dark"?.46:.38),m=q(P(s,o,a==="dark"?.78:.72),s),K=q(P(p,f,.2),s),y=`--lr-theme-color-${t}`;i.setProperty(`${y}-fill-quiet`,h(r)),i.setProperty(`${y}-fill-normal`,h(c)),i.setProperty(`${y}-fill-loud`,h(p)),i.setProperty(`${y}-border-quiet`,h(d)),i.setProperty(`${y}-border-normal`,h(m)),i.setProperty(`${y}-border-loud`,h(K)),i.setProperty(`${y}-on-quiet`,h(w(r))),i.setProperty(`${y}-on-normal`,h(w(c))),i.setProperty(`${y}-on-loud`,h(w(p))),t==="brand"&&(i.setProperty("--lr-theme-color-focus",h(q(o,s))),I=e)}I?i.setProperty("--lr-theme-accent",I):i.removeProperty("--lr-theme-accent")}catch{}}function applyStoredStyleBeforePaint(U,W,T,L,q,z){const{surfaces:N,contrastSurfaces:G,gemstones:j}=z,S=[],R=[],E=[],P=[];for(const s of z.inputs.split(" ")){const n=Number(s[0]),c=`--lr-theme-${s.slice(1)}`;S.push(c),n&1&&R.push(c),n&2&&E.push(c),n&4&&P.push(c)}function g(s,n,c=!1){return`--_lr-${c?"a":"l"}${n==="light"?"l":"d"}-${s.slice(11)}`}function M(s,n){let c=`var(${g(s,n)})`;if(E.includes(s)){const u=n==="light"?"l":"d",b=s.replace(/color-(?:success|warning|danger|neutral)-/,"color-brand-");c=`var(--_lr-f${u}-${s.slice(11)},${c})var(--_lr-o${u}-${s.slice(11)},var(${g(b,n,!0)},var(${g(b,n)})))`}return P.includes(s)?`var(${g(s,n,!0)},${c})`:c}function J(s){const n=`var(--_lr-dark-on,${M(s,"light")})var(--_lr-light-on,${M(s,"dark")})`;if(!R.includes(s))return n;const c=s.startsWith("--lr-theme-space-");return`var(--_lr-dense-on,${n})var(--_lr-dense-off,max(calc((${n}) * var(--_lr-density-${c?"space":"control"},1)),${c?"0px":"var(--_lr-density-target-min,0px)"}))`}try{const s=document.currentScript,n=s?.getAttribute("data-lr-theme-storage-key"),c=n&&n.length<=200?n:U,u=s?.getAttribute("data-lr-theme-attributes")?.trim().split(/\s+/),b=u?.length&&u.length<=8&&new Set(u).size===u.length&&u.every(e=>e.length<=64&&/^data-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e))?u:W;let t={};const H=localStorage.getItem(c);try{const e=JSON.parse(H??"null");e&&typeof e=="object"&&!Array.isArray(e)&&(t=e)}catch{}t.version!==void 0&&t.version!==2&&(t={});const h=t.mode==="light"||t.mode==="dark"||t.mode==="unset"?t.mode:"system",v=h==="unset"?null:h==="system"?matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":h,o=document.documentElement,y={},Q=getComputedStyle(o).getPropertyValue("--_lr-style-resolver").trim()==="1",X=e=>typeof e=="string"&&e.length<=64&&/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e),V=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},Y=e=>T({root:document.createElement("div"),record:{mode:"unset",tokens:e},normalizeOnly:!0})??{},I=Y(t.tokens),Z=Object.fromEntries(Object.entries(Y(t.overrides)).filter(([e,r])=>L(e,r,S))),m={...I,...Z},C=X(t.look)?t.look:Object.keys(I).length?"custom":"lyra";if(y["data-lr-look"]=C,y["data-lr-density"]=t.density==="compact"||t.density==="touch"?t.density:"comfortable",y["data-lr-surface"]=t.treatment==="glass"?"glass":"solid",h!=="unset"&&(y["data-lr-mode"]=h),v)for(const e of b)y[e]=v;const $=t.version===2&&typeof t.accentName=="string"&&Object.hasOwn(j,t.accentName)?t.accentName:null,_=$?j[$]:t.accent;y["data-lr-accent"]=$??(_?"custom":"none");const a=new Map;if(h==="unset")for(const[e,r]of Object.entries(m))typeof r=="string"&&a.set(e,r);for(const e of["light","dark"]){const r=typeof t.surface=="string"?t.surface:V(t.surface)[e],A=typeof m["--lr-theme-color-surface-default"]=="string"?m["--lr-theme-color-surface-default"]:V(m["--lr-theme-color-surface-default"])[e],f=r??A??N[C]?.[e];for(const p of[!1,!0]){if(p&&(!_||$))continue;const w=document.createElement("div");T({root:w,tokens:p?{}:m,references:p?G[e].map(i=>[1,3,5].map(d=>parseInt(i.slice(d,d+2),16))):[],record:{mode:e,surface:p&&$?N.lyra?.[e]:f,tokens:p?null:m,accent:p?_:null}});for(const i of w.style){const d=w.style.getPropertyValue(i);if(i==="--lr-theme-accent"){e===v&&a.set(i,d);continue}if(S.includes(i)&&L(i,d,S)){const K=i.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1],O=!p&&K&&d===`var(--lr-theme-color-brand-${K})`,B=i.slice(11),D=e==="light"?"l":"d";O||a.set(g(i,e,p),d),!p&&E.includes(i)&&(a.set(`--_lr-f${D}-${B}`,O?" ":"initial"),a.set(`--_lr-o${D}-${B}`,O?"initial":" ")),e===v&&a.set(i,Q?J(i):d)}else e===v&&a.set(i,d)}}}a.size&&(y["data-lr-theme-scope"]="");const F=Symbol.for("@aceshooting/lyra-ui.style-ownership.v1"),k=o;let x;try{x=q(k[F])}catch{}const l=x??{attributes:new Map,properties:new Map};if(h==="unset")for(const e of b)l.attributes.has(e)||o.removeAttribute(e);try{const e=Symbol.for("@aceshooting/lyra-ui.theme-tokens.v1"),r=k[e];if(Array.isArray(r)){const A=r.slice(0,528).filter(f=>typeof f=="string"&&f.length<=80&&/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(f));for(const f of[...A,...P,"--lr-theme-accent"])!l.properties.has(f)&&o.style.getPropertyValue(f)&&l.properties.set(f,{before:null,priority:"",written:o.style.getPropertyValue(f)});try{delete k[e]}catch{}}}catch{}for(const[e,r]of l.attributes)Object.hasOwn(y,e)||(o.getAttribute(e)===r.written&&(r.before===null?o.removeAttribute(e):o.setAttribute(e,r.before)),l.attributes.delete(e));for(const[e,r]of Object.entries(y))l.attributes.has(e)||l.attributes.set(e,{before:o.getAttribute(e),priority:"",written:r}),o.setAttribute(e,r),l.attributes.get(e).written=r;for(const[e,r]of l.properties)a.has(e)||(o.style.getPropertyValue(e)===r.written&&!o.style.getPropertyPriority(e)&&(r.before?o.style.setProperty(e,r.before,r.priority):o.style.removeProperty(e)),l.properties.delete(e));for(const[e,r]of a)l.properties.has(e)||l.properties.set(e,{before:o.style.getPropertyValue(e),priority:o.style.getPropertyPriority(e),written:null}),o.style.getPropertyPriority(e)&&o.style.removeProperty(e),o.style.setProperty(e,r,""),l.properties.get(e).written=o.style.getPropertyValue(e);try{k[F]=l}catch{}}catch{}}const LINE_SEPARATOR="\u2028",PARAGRAPH_SEPARATOR="\u2029";function serializeInlineScriptData(value){return JSON.stringify(value).replace(/</g,"\\u003c").replace(new RegExp(LINE_SEPARATOR,"g"),"\\u2028").replace(new RegExp(PARAGRAPH_SEPARATOR,"g"),"\\u2029")}function createLyraThemeBootstrap(options={}){const storageKey=options.storageKey??STORAGE_KEY,inputs=STYLE_SLOTTED.map(name=>`${Number(STYLE_DENSITY.includes(name))|Number(STYLE_FOLLOW.includes(name))<<1|Number(ALL_RAMP_PROPERTIES.includes(name))<<2}${name.slice(11)}`).join(" "),model=JSON.stringify({inputs,surfaces:STYLE_REFERENCE_SURFACES,contrastSurfaces:STYLE_CONTRAST_SURFACES,gemstones:STYLE_GEMSTONES});return`(${applyStoredStyleBeforePaint.toString()})(${serializeInlineScriptData(storageKey)},${serializeInlineScriptData(MODE_ATTRIBUTES)},${applyStoredThemeBeforePaint.toString()},${styleTokenAllowed.toString()},${readStyleOwnership.toString()},${model});`}const STYLE_SLOTTED=["--lr-theme-color-border-strong","--lr-theme-color-brand-border-loud","--lr-theme-color-brand-border-normal","--lr-theme-color-brand-border-quiet","--lr-theme-color-brand-fill-loud","--lr-theme-color-brand-fill-normal","--lr-theme-color-brand-fill-quiet","--lr-theme-color-brand-on-loud","--lr-theme-color-brand-on-normal","--lr-theme-color-brand-on-quiet","--lr-theme-color-chart-1","--lr-theme-color-chart-2","--lr-theme-color-chart-3","--lr-theme-color-chart-4","--lr-theme-color-chart-5","--lr-theme-color-chart-6","--lr-theme-color-chart-7","--lr-theme-color-chart-8","--lr-theme-color-chart-diverging-1","--lr-theme-color-chart-diverging-2","--lr-theme-color-chart-diverging-3","--lr-theme-color-chart-sequential-1","--lr-theme-color-chart-sequential-2","--lr-theme-color-chart-sequential-3","--lr-theme-color-danger-border-loud","--lr-theme-color-danger-border-normal","--lr-theme-color-danger-border-quiet","--lr-theme-color-danger-fill-loud","--lr-theme-color-danger-fill-normal","--lr-theme-color-danger-fill-quiet","--lr-theme-color-danger-on-loud","--lr-theme-color-danger-on-normal","--lr-theme-color-danger-on-quiet","--lr-theme-color-focus","--lr-theme-color-mix-partner","--lr-theme-color-neutral-border-loud","--lr-theme-color-neutral-border-normal","--lr-theme-color-neutral-border-quiet","--lr-theme-color-neutral-fill-loud","--lr-theme-color-neutral-fill-normal","--lr-theme-color-neutral-fill-quiet","--lr-theme-color-neutral-on-loud","--lr-theme-color-neutral-on-normal","--lr-theme-color-neutral-on-quiet","--lr-theme-color-no-data","--lr-theme-color-on-strong-overlay","--lr-theme-color-overlay","--lr-theme-color-overlay-strong","--lr-theme-color-success-border-loud","--lr-theme-color-success-border-normal","--lr-theme-color-success-border-quiet","--lr-theme-color-success-fill-loud","--lr-theme-color-success-fill-normal","--lr-theme-color-success-fill-quiet","--lr-theme-color-success-on-loud","--lr-theme-color-success-on-normal","--lr-theme-color-success-on-quiet","--lr-theme-color-surface-border","--lr-theme-color-surface-border-subtle","--lr-theme-color-surface-container","--lr-theme-color-surface-container-high","--lr-theme-color-surface-container-highest","--lr-theme-color-surface-container-low","--lr-theme-color-surface-container-lowest","--lr-theme-color-surface-default","--lr-theme-color-surface-overlay","--lr-theme-color-surface-raised","--lr-theme-color-text-normal","--lr-theme-color-text-quiet","--lr-theme-color-warning-border-loud","--lr-theme-color-warning-border-normal","--lr-theme-color-warning-border-quiet","--lr-theme-color-warning-fill-loud","--lr-theme-color-warning-fill-normal","--lr-theme-color-warning-fill-quiet","--lr-theme-color-warning-on-loud","--lr-theme-color-warning-on-normal","--lr-theme-color-warning-on-quiet","--lr-theme-form-control-height-2xs","--lr-theme-form-control-height-l","--lr-theme-form-control-height-m","--lr-theme-form-control-height-s","--lr-theme-form-control-height-xl","--lr-theme-form-control-height-xs","--lr-theme-graph-cat-1","--lr-theme-graph-cat-2","--lr-theme-graph-cat-3","--lr-theme-graph-cat-4","--lr-theme-graph-cat-5","--lr-theme-graph-cat-6","--lr-theme-graph-cat-7","--lr-theme-graph-cat-8","--lr-theme-icon-button-size","--lr-theme-shadow-l","--lr-theme-shadow-m","--lr-theme-shadow-s","--lr-theme-shadow-xl","--lr-theme-shadow-xs","--lr-theme-space-2xl","--lr-theme-space-2xs","--lr-theme-space-l","--lr-theme-space-m","--lr-theme-space-s","--lr-theme-space-xs","--lr-theme-terminal-bg-black","--lr-theme-terminal-bg-blue","--lr-theme-terminal-bg-bright-black","--lr-theme-terminal-bg-bright-blue","--lr-theme-terminal-bg-bright-cyan","--lr-theme-terminal-bg-bright-green","--lr-theme-terminal-bg-bright-magenta","--lr-theme-terminal-bg-bright-red","--lr-theme-terminal-bg-bright-white","--lr-theme-terminal-bg-bright-yellow","--lr-theme-terminal-bg-cyan","--lr-theme-terminal-bg-green","--lr-theme-terminal-bg-magenta","--lr-theme-terminal-bg-red","--lr-theme-terminal-bg-white","--lr-theme-terminal-bg-yellow","--lr-theme-terminal-color-black","--lr-theme-terminal-color-blue","--lr-theme-terminal-color-bright-black","--lr-theme-terminal-color-bright-blue","--lr-theme-terminal-color-bright-cyan","--lr-theme-terminal-color-bright-green","--lr-theme-terminal-color-bright-magenta","--lr-theme-terminal-color-bright-red","--lr-theme-terminal-color-bright-white","--lr-theme-terminal-color-bright-yellow","--lr-theme-terminal-color-cyan","--lr-theme-terminal-color-green","--lr-theme-terminal-color-magenta","--lr-theme-terminal-color-red","--lr-theme-terminal-color-white","--lr-theme-terminal-color-yellow"],STYLE_DENSITY=["--lr-theme-space-2xs","--lr-theme-space-xs","--lr-theme-space-s","--lr-theme-space-m","--lr-theme-space-l","--lr-theme-space-2xl","--lr-theme-form-control-height-2xs","--lr-theme-form-control-height-xs","--lr-theme-form-control-height-s","--lr-theme-form-control-height-m","--lr-theme-form-control-height-l","--lr-theme-form-control-height-xl","--lr-theme-icon-button-size"],STYLE_FOLLOW=["--lr-theme-color-danger-border-loud","--lr-theme-color-danger-border-normal","--lr-theme-color-danger-border-quiet","--lr-theme-color-danger-fill-loud","--lr-theme-color-danger-fill-normal","--lr-theme-color-danger-fill-quiet","--lr-theme-color-danger-on-loud","--lr-theme-color-danger-on-normal","--lr-theme-color-danger-on-quiet","--lr-theme-color-neutral-border-loud","--lr-theme-color-neutral-border-normal","--lr-theme-color-neutral-border-quiet","--lr-theme-color-neutral-fill-loud","--lr-theme-color-neutral-fill-normal","--lr-theme-color-neutral-fill-quiet","--lr-theme-color-neutral-on-loud","--lr-theme-color-neutral-on-normal","--lr-theme-color-neutral-on-quiet","--lr-theme-color-success-border-loud","--lr-theme-color-success-border-normal","--lr-theme-color-success-border-quiet","--lr-theme-color-success-fill-loud","--lr-theme-color-success-fill-normal","--lr-theme-color-success-fill-quiet","--lr-theme-color-success-on-loud","--lr-theme-color-success-on-normal","--lr-theme-color-success-on-quiet","--lr-theme-color-warning-border-loud","--lr-theme-color-warning-border-normal","--lr-theme-color-warning-border-quiet","--lr-theme-color-warning-fill-loud","--lr-theme-color-warning-fill-normal","--lr-theme-color-warning-fill-quiet","--lr-theme-color-warning-on-loud","--lr-theme-color-warning-on-normal","--lr-theme-color-warning-on-quiet"],STYLE_REFERENCE_SURFACES={lyra:{light:"#ffffff",dark:"#1a1a1a"},data:{light:"#ffffff",dark:"#101820"},"high-contrast":{light:"#ffffff",dark:"#000000"},material:{light:"#fff8f5",dark:"#18120f"},shadcn:{light:"#ffffff",dark:"#0a0a0a"},terminal:{light:"#fcfdf9",dark:"#0e1713"}},STYLE_CONTRAST_SURFACES={light:["#ffffff","#f6f8fa","#f2f5f8","#fff8f5","#f8eeea","#fcf2ed","#f2e7e0","#ecdfd7","#fafafa","#fcfdf9","#f1f5eb"],dark:["#1a1a1a","#22272e","#2b3038","#101820","#192630","#202e39","#000000","#18120f","#251d19","#302621","#120d0a","#211914","#3a2f29","#0a0a0a","#171717","#0e1713","#18271e","#203227"]},STYLE_GEMSTONES={emerald:"#34d399",peridot:"#a8d84a",topaz:"#f0a83c",ruby:"#e63950",tourmaline:"#ec4899",amethyst:"#9d6df0",aquamarine:"#22d3ee",sapphire:"#4f8ff7",hematite:"#94a3b8"},LOOK_ID=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,LOOK_STAMP=Symbol.for("@aceshooting/lyra-ui.look.v1"),STYLE_OWNERSHIP=Symbol.for("@aceshooting/lyra-ui.style-ownership.v1"),STYLE_FIELDS=["look","surface","density","mode","accent","accentBackground","overrides"],DEFAULT_STYLE=Object.freeze({look:"lyra",tokens:null,surface:"solid",density:"comfortable",mode:"system",accent:null,accentName:null,accentBackground:null,overrides:null});let lastStyle={...DEFAULT_STYLE},stylePersistenceFailed=!1,styleModeCleanup,styleModeRoot;const styleOwnershipFallback=new WeakMap,scopeModes=new WeakMap;function ownField(value,key){const descriptor=Object.getOwnPropertyDescriptor(value,key);return descriptor&&"value"in descriptor?descriptor.value:void 0}function styleId(value){return typeof value=="string"&&value.length<=64&&LOOK_ID.test(value)}function styleTokenAllowed(e,r,o=STYLE_SLOTTED){if(e.startsWith("--lr-theme-surface-")||typeof r!="string"&&!o.includes(e))return!1;for(const t of typeof r=="string"?[r]:[r.light,r.dark])if(t)for(const c of t.matchAll(/var\(\s*(--[\w-]+)/g)){if(c[1]==="--lr-theme-shadow-color")continue;const n=e.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1];if(!n||t!==`var(--lr-theme-color-brand-${n})`)return!1}return!0}function styleTokens(value){const tokens=normalizeTokens(value);if(!tokens)return null;const entries=Object.entries(tokens).filter(([name,input])=>styleTokenAllowed(name,input));return entries.length?Object.freeze(Object.fromEntries(entries)):null}function defineLyraLook(look){if(!look||!styleId(ownField(look,"id"))||look.id==="custom")throw new TypeError("Invalid look id");const raw=ownField(look,"tokens");if(!isPlainRecord(raw)||Object.keys(raw).length>TOKEN_ENTRY_MAX)throw new TypeError("Invalid look tokens");for(const[name,descriptor]of Object.entries(Object.getOwnPropertyDescriptors(raw))){if(!("value"in descriptor))throw new TypeError(`Look inputs must be data properties: ${name}`);const value=descriptor.value;if(typeof value=="string"){if(!isSafeLyraThemeTokenValue(value))throw new TypeError(`Invalid look value: ${name}`);continue}if(!isPlainRecord(value)||!STYLE_SLOTTED.includes(name))throw new TypeError(`Invalid per-mode look input: ${name}`);const branches=Object.entries(Object.getOwnPropertyDescriptors(value));if(!branches.length||branches.some(([key,branch])=>!["light","dark"].includes(key)||!("value"in branch)||branch.value!==null&&!isSafeLyraThemeTokenValue(branch.value)))throw new TypeError(`Invalid look mode pair: ${name}`)}const tokens=styleTokens(raw);if(Object.keys(raw).length!==Object.keys(tokens??{}).length)throw new TypeError("Invalid look token or cross-axis reference");const stamped={...tokens,[LOOK_STAMP]:look.id};return Object.freeze(stamped),Object.freeze({id:look.id,tokens:stamped})}function styleColor(value){if(!isSafeLyraThemeTokenValue(value))return null;const text=value.trim();return/\b(?:var|light-dark)\s*\(|\b(?:currentcolor|from)\b/i.test(text)||/^(?:accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)$/i.test(text)?null:/^(?:#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})|[a-z]+|(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix)\(.+\))$/i.test(text)?text:null}function styleColorPair(value){if(typeof value=="string")return styleColor(value);if(!isPlainRecord(value))return null;const light=styleColor(ownField(value,"light")),dark=styleColor(ownField(value,"dark"));return light||dark?Object.freeze({light,dark}):null}function styleAccent(value){if(typeof value=="string")return styleColor(value);if(!isPlainRecord(value))return null;const entries=SEMANTIC_ROLES.filter(role=>Object.hasOwn(value,role)).map(role=>[role,styleColorPair(ownField(value,role))]);return entries.length?Object.freeze(Object.fromEntries(entries)):null}function normalizeStyleChoices(raw,base){const next={...base};if(!isPlainRecord(raw))return next;const look=ownField(raw,"look");if(look!==void 0){if(next.look="lyra",next.tokens=null,styleId(look))next.look=look;else if(isPlainRecord(look))try{const definition=defineLyraLook(look);next.look=definition.id,next.tokens=definition.tokens}catch{}}const surface=ownField(raw,"surface");surface!==void 0&&(next.surface=surface==="glass"?"glass":"solid");const density=ownField(raw,"density");density!==void 0&&(next.density=density==="compact"||density==="touch"?density:"comfortable");const mode=ownField(raw,"mode");mode!==void 0&&(next.mode=mode==="light"||mode==="dark"||mode==="unset"?mode:"system");const accent=ownField(raw,"accent");accent!==void 0&&(next.accentName=typeof accent=="string"&&Object.hasOwn(STYLE_GEMSTONES,accent)?accent:null,next.accent=next.accentName?STYLE_GEMSTONES[next.accentName]:styleAccent(accent));const background=ownField(raw,"accentBackground");background!==void 0&&(next.accentBackground=styleColorPair(background));const overrides=ownField(raw,"overrides");return overrides!==void 0&&(next.overrides=styleTokens(overrides)),next}function styleFromRecord(value){if(!isPlainRecord(value))return{...DEFAULT_STYLE};const version=ownField(value,"version");if(version!==void 0&&version!==2)return{...DEFAULT_STYLE};const state=normalizeStyleChoices({look:ownField(value,"look"),mode:ownField(value,"mode"),density:ownField(value,"density"),surface:ownField(value,"treatment"),overrides:ownField(value,"overrides"),accentBackground:ownField(value,"surface")},{...DEFAULT_STYLE});state.accent=styleAccent(ownField(value,"accent"));const accentName=ownField(value,"accentName");return version===2&&typeof accentName=="string"&&Object.hasOwn(STYLE_GEMSTONES,accentName)&&(state.accentName=accentName,state.accent=STYLE_GEMSTONES[accentName]),state.tokens=normalizeTokens(ownField(value,"tokens")),state.tokens&&!styleId(ownField(value,"look"))&&(state.look="custom"),state}function styleRecord(state){return{version:2,mode:state.mode,look:state.look,density:state.density,treatment:state.surface,accent:state.accent,surface:state.accentBackground,...state.accentName?{accentName:state.accentName}:{},...state.tokens?{tokens:state.tokens}:{},...state.overrides?{overrides:state.overrides}:{}}}function styleResolvedMode(mode,view){return mode==="unset"?null:mode!=="system"?mode:view?.matchMedia?.(COLOR_SCHEME_QUERY).matches?"dark":"light"}function styleSnapshot(state,view){return Object.freeze({look:state.look,lookForm:state.tokens?"runtime":"stylesheet",surface:state.surface,density:state.density,mode:state.mode,accent:state.accentName??state.accent,accentName:state.accentName,accentBackground:state.accentBackground,...state.overrides?{overrides:state.overrides}:{},resolvedMode:styleResolvedMode(state.mode,view)})}function parseLyraStyleRecord(value){const state=styleFromRecord(value),result=styleSnapshot(state);return state.mode==="system"?Object.freeze({...result,resolvedMode:null}):result}function lyraStyleAttributes(style){const attributes={};return styleId(style.look)&&(attributes["data-lr-look"]=style.look),(style.surface==="solid"||style.surface==="glass")&&(attributes["data-lr-surface"]=style.surface),(style.density==="compact"||style.density==="comfortable"||style.density==="touch")&&(attributes["data-lr-density"]=style.density),(style.mode==="light"||style.mode==="dark"||style.mode==="system")&&(attributes["data-lr-mode"]=style.mode),style.accent!==void 0&&(attributes["data-lr-accent"]=style.accent===null?"none":style.accentName===null?"custom":typeof style.accent=="string"&&Object.hasOwn(STYLE_GEMSTONES,style.accent)?style.accent:"custom"),Object.freeze(attributes)}function readStyleState(){if(stylePersistenceFailed)return{...lastStyle};let stored;try{stored=localStorage.getItem(STORAGE_KEY)}catch{return{...lastStyle}}try{return styleFromRecord(JSON.parse(stored??"null"))}catch{return{...DEFAULT_STYLE}}}function persistStyle(state){try{localStorage.setItem(STORAGE_KEY,JSON.stringify(styleRecord(state))),stylePersistenceFailed=!1}catch{stylePersistenceFailed=!0}lastStyle=state}function ownershipFor(element){const node=element;try{const existing=readStyleOwnership(node[STYLE_OWNERSHIP]);if(existing){styleOwnershipFallback.set(element,existing);try{node[STYLE_OWNERSHIP]=existing}catch{}return existing}}catch{}const fallback=styleOwnershipFallback.get(element);if(fallback)return fallback;const record={attributes:new Map,properties:new Map};styleOwnershipFallback.set(element,record);try{node[STYLE_OWNERSHIP]=record}catch{}return record}function writeStyleAttributes(element,desired){const ownership=ownershipFor(element).attributes;for(const[name,value]of ownership)Object.hasOwn(desired,name)||(element.getAttribute(name)===value.written&&(value.before===null?element.removeAttribute(name):element.setAttribute(name,value.before)),ownership.delete(name));for(const[name,value]of Object.entries(desired))ownership.has(name)||ownership.set(name,{before:element.getAttribute(name),priority:"",written:value}),element.getAttribute(name)!==value&&element.setAttribute(name,value),ownership.get(name).written=value}function writeStyleProperties(element,desired){const style=element.style;if(!style)return;const ownership=ownershipFor(element).properties;for(const[name,value]of ownership)desired.has(name)||(style.getPropertyValue(name)===value.written&&style.getPropertyPriority(name)===""&&(value.before?style.setProperty(name,value.before,value.priority):style.removeProperty(name)),ownership.delete(name));for(const[name,value]of desired){ownership.has(name)||ownership.set(name,{before:style.getPropertyValue(name),priority:style.getPropertyPriority(name),written:null});const record=ownership.get(name);(style.getPropertyPriority(name)!==""||style.getPropertyValue(name)!==value&&!(record.requested===value&&record.written===style.getPropertyValue(name)))&&(style.getPropertyPriority(name)&&style.removeProperty(name),style.setProperty(name,value,"")),record.requested=value,record.written=style.getPropertyValue(name)}}function styleSlot(name,mode,accent=!1){return`--_lr-${accent?"a":"l"}${mode==="light"?"l":"d"}-${name.slice(11)}`}function styleFollow(name,value){const channel=name.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1];return!!(channel&&value===`var(--lr-theme-color-brand-${channel})`)}function styleBranch(name,mode){let result=`var(${styleSlot(name,mode)})`;if(STYLE_FOLLOW.includes(name)){const key=mode==="light"?"l":"d",target=name.replace(/color-(?:success|warning|danger|neutral)-/,"color-brand-");result=`var(--_lr-f${key}-${name.slice(11)},${result})var(--_lr-o${key}-${name.slice(11)},var(${styleSlot(target,mode,!0)},var(${styleSlot(target,mode)})))`}return ALL_RAMP_PROPERTIES.includes(name)?`var(${styleSlot(name,mode,!0)},${result})`:result}function styleResolvedInput(name){const input=`var(--_lr-dark-on,${styleBranch(name,"light")})var(--_lr-light-on,${styleBranch(name,"dark")})`;if(!STYLE_DENSITY.includes(name))return input;const spacing=name.startsWith("--lr-theme-space-");return`var(--_lr-dense-on,${input})var(--_lr-dense-off,max(calc((${input}) * var(--_lr-density-${spacing?"space":"control"},1)),${spacing?"0px":"var(--_lr-density-target-min,0px)"}))`}function styleBackground(state,entries,mode,element){const explicit=typeof state.accentBackground=="string"?state.accentBackground:state.accentBackground?.[mode],ownLook=element.getAttribute("data-lr-look");let reference=explicit??entries.get("--lr-theme-color-surface-default")??(ownLook?(STYLE_REFERENCE_SURFACES[ownLook]??STYLE_REFERENCE_SURFACES.lyra)?.[mode]:void 0);if(!reference){const slot=styleSlot("--lr-theme-color-surface-default",mode),style=element.style,owned=ownershipFor(element).properties.get(slot),suspend=owned&&style?.getPropertyValue(slot)===owned.written&&!style.getPropertyPriority(slot);try{suspend&&(owned.before?style.setProperty(slot,owned.before,owned.priority):style.removeProperty(slot)),reference=element.ownerDocument.defaultView?.getComputedStyle(element).getPropertyValue(slot).trim()}finally{suspend&&owned.written!==null&&style.setProperty(slot,owned.written)}}return reference}const stylePaintCache=new WeakMap;function stylePaint(state,element,wholeDocument){const desired=new Map,mode=styleResolvedMode(state.mode,element.ownerDocument.defaultView),tokens={...state.tokens,...state.overrides};if(wholeDocument&&mode===null)for(const[name,value]of tokenEntries(tokens,null))desired.set(name,value);if(!Object.keys(tokens).length&&(!state.accent||state.accentName))return stylePaintCache.delete(element),desired;const resolver=element.ownerDocument.defaultView?.getComputedStyle(element).getPropertyValue("--_lr-style-resolver").trim()==="1";let cache=stylePaintCache.get(element);cache||(cache=new Map,stylePaintCache.set(element,cache));let applied=state.accent;for(const branch of["light","dark"]){const entries=tokenEntries(tokens,branch),reference=styleBackground(state,entries,branch,element),key=JSON.stringify([tokens,state.accent,state.accentName,reference]);let cached=cache.get(branch);if(!cached||cached.key!==key){const background=reference?parseResolvedRgb(reference,MODE_DEFAULTS[branch].surface,element.ownerDocument)??MODE_DEFAULTS[branch].surface:MODE_DEFAULTS[branch].surface,accent=state.accentName?{applied:state.accent,properties:new Map}:paintAccent(state.accent,branch,background,element.ownerDocument);cached={key,tokens:floorTokenEntries(entries,branch,background,element.ownerDocument),accent:accent.properties,applied:accent.applied},cache.set(branch,cached)}branch===mode&&(applied=cached.applied);const painted=cached.tokens;for(const[name,value]of painted)STYLE_SLOTTED.includes(name)&&styleTokenAllowed(name,value)?(styleFollow(name,value)?(desired.set(`--_lr-f${branch==="light"?"l":"d"}-${name.slice(11)}`," "),desired.set(`--_lr-o${branch==="light"?"l":"d"}-${name.slice(11)}`,"initial")):(desired.set(styleSlot(name,branch),value),STYLE_FOLLOW.includes(name)&&(desired.set(`--_lr-f${branch==="light"?"l":"d"}-${name.slice(11)}`,"initial"),desired.set(`--_lr-o${branch==="light"?"l":"d"}-${name.slice(11)}`," "))),wholeDocument&&branch===mode&&desired.set(name,resolver?styleResolvedInput(name):value)):(wholeDocument?branch===mode:typeof tokens[name]=="string"&&!STYLE_SLOTTED.includes(name))&&desired.set(name,value);if(state.accent&&!state.accentName)for(const[name,value]of cached.accent){if(name==="--lr-theme-accent"){branch===mode&&desired.set(name,value);continue}desired.set(styleSlot(name,branch,!0),value),wholeDocument&&branch===mode&&desired.set(name,resolver?styleResolvedInput(name):value)}}return state.accent=applied,desired}const styleModeGroups=new WeakMap;function attachStyleMode(element,callback){const view=element.ownerDocument.defaultView;if(!view?.matchMedia)return()=>{};let group=styleModeGroups.get(view);if(!group){const query=view.matchMedia(COLOR_SCHEME_QUERY),subscriptions=new Set,modern=typeof query.addEventListener=="function"&&typeof query.removeEventListener=="function",detach=()=>{modern?query.removeEventListener("change",listener):query.removeListener?.(listener)},listener=()=>{for(const subscription2 of subscriptions){const node=subscription2.element.deref();node?.ownerDocument.defaultView===view?subscription2.callback(node):subscriptions.delete(subscription2)}subscriptions.size||(detach(),styleModeGroups.delete(view))};group={query,subscriptions,detach},styleModeGroups.set(view,group),modern?query.addEventListener("change",listener):query.addListener?.(listener)}const subscription={element:new WeakRef(element),callback};group.subscriptions.add(subscription);const active=group;return()=>{active.subscriptions.delete(subscription),active.subscriptions.size||(active.detach(),styleModeGroups.delete(view))}}function applyStyleState(element,state,fields){const snapshot=styleSnapshot(state,element.ownerDocument.defaultView),attributes={...lyraStyleAttributes(snapshot)};if(fields)for(const[field,name]of[["look","look"],["surface","surface"],["density","density"],["mode","mode"],["accent","accent"]])fields.has(field)||delete attributes[`data-lr-${name}`];state.accent&&!state.accentName&&(!fields||fields.has("accent"))&&(attributes["data-lr-accent"]="custom"),(!fields||fields.has("mode"))&&snapshot.resolvedMode&&(attributes["data-lr-theme"]=snapshot.resolvedMode,attributes["data-theme"]=snapshot.resolvedMode),(state.tokens||state.overrides||state.accent&&!state.accentName)&&(attributes["data-lr-theme-scope"]=""),writeStyleAttributes(element,attributes);const desired=stylePaint(state,element,!fields);!state.accent&&snapshot.accent&&(attributes["data-lr-accent"]="none",!state.tokens&&!state.overrides&&delete attributes["data-lr-theme-scope"],writeStyleAttributes(element,attributes)),writeStyleProperties(element,desired),diagnoseStyleSheets(element,state,fields)}function diagnoseStyleSheets(element,state,fields){if(!litDevWarnings())return;const selected=field=>!fields||fields.has(field),required=[];selected("look")&&!state.tokens&&state.look!=="lyra"&&required.push(["--_lr-look-installed",`${state.look}-1`,`the stylesheet for look '${state.look}'`]),selected("surface")&&state.surface==="glass"&&required.push(["--_lr-surface-installed","1","surfaces/glass.css"]),selected("density")&&state.density!=="comfortable"&&required.push(["--_lr-density-installed","1","density.css"]),selected("accent")&&state.accentName&&required.push(["--_lr-accent-installed",`${state.accentName}-1`,"accents.css"]);const scopedRuntime=!!(fields&&(state.tokens||state.overrides||state.accent&&!state.accentName));if(!required.length&&!scopedRuntime)return;const computed=element.ownerDocument.defaultView?.getComputedStyle(element);if(computed){computed.getPropertyValue("--_lr-style-resolver").trim()!=="1"&&devWarnOnce("lyra-style:resolver","Lyra style choices require theme.css in the scope that owns their attributes.");for(const[property,expected,stylesheet]of required)computed.getPropertyValue(property).trim()!==expected&&devWarnOnce(`lyra-style:${property}:${expected}`,`Lyra could not find ${stylesheet} in this style scope; import or adopt the stylesheet before selecting it.`)}}function emitStyleChange(state,changed){const style=styleSnapshot(state,window);window.dispatchEvent(new CustomEvent("lr-style-change",{detail:Object.freeze({style,changed:Object.freeze([...changed])})}))}function setLyraStyle(choices){const before=readStyleState();return commitStyle(before,normalizeStyleChoices(choices,before))}function commitStyle(before,next){if(typeof document<"u"&&(next.accent=normalizeAccent(next.accent),typeof next.accentBackground=="string"&&(next.accentBackground=normalizeColor(next.accentBackground)),next.accent||(next.accentName=null)),persistStyle(next),typeof document<"u"){const root=document.documentElement;(next.mode!=="system"||styleModeRoot?.deref()!==root)&&(styleModeCleanup?.(),styleModeCleanup=void 0,styleModeRoot=void 0),adoptLegacyOwnership(root);const requestedAccent=next.accent;applyStyleState(root,next),accentsEqual(requestedAccent,next.accent)||persistStyle(next),next.mode==="system"&&!styleModeCleanup&&(styleModeRoot=new WeakRef(root),styleModeCleanup=attachStyleMode(root,element=>{applyStyleState(element,lastStyle),emitStyleChange(lastStyle,["resolvedMode"])}));const changed=STYLE_FIELDS.filter(field=>field==="look"?before.look!==next.look||!tokensEqual(before.tokens,next.tokens):field==="accent"?before.accentName!==next.accentName||!accentsEqual(before.accent,next.accent):JSON.stringify(before[field])!==JSON.stringify(next[field]));emitStyleChange(next,changed)}return styleSnapshot(next,typeof window>"u"?void 0:window)}function adoptLegacyOwnership(root){const symbol=Symbol.for(TOKEN_OWNERSHIP_SYMBOL),node=root;try{if(!Array.isArray(node[symbol]))return}catch{return}const ownership=ownershipFor(root).properties;for(const name of[...readOwnershipList(),...ALL_RAMP_PROPERTIES,"--lr-theme-accent"])ownership.has(name)||!root.style.getPropertyValue(name)||ownership.set(name,{before:null,priority:"",written:root.style.getPropertyValue(name)});try{delete node[symbol]}catch{}}function getLyraStyle(){return styleSnapshot(readStyleState(),typeof window>"u"?void 0:window)}function resetLyraStyle(fields=STYLE_FIELDS){return setLyraStyle(Object.fromEntries(fields.filter(field=>STYLE_FIELDS.includes(field)).map(field=>[field,null])))}function applyLyraStyleScope(element,choices){if(scopeModes.get(element)?.(),scopeModes.delete(element),choices===null){writeStyleAttributes(element,{}),writeStyleProperties(element,new Map);return}const state=normalizeStyleChoices(choices,{...DEFAULT_STYLE}),fields=new Set(STYLE_FIELDS.filter(field=>ownField(choices,field)!==void 0));applyStyleState(element,state,fields),choices.mode==="system"&&scopeModes.set(element,attachStyleMode(element,node=>applyStyleState(node,state,fields)))}const lyraThemeBootstrap=createLyraThemeBootstrap();export{accentsEqual,applyLyraStyleScope,createLyraThemeBootstrap,defineLyraLook,getLyraStyle,isLyraThemeTokenName,isSafeLyraThemeTokenValue,lyraStyleAttributes,lyraThemeBootstrap,parseLyraStyleRecord,resetLyraStyle,setLyraStyle,tokensEqual};
@@ -100,7 +100,7 @@ Citation; truncated?: boolean; omittedTokens?: number; redactions?: ContextInspe
100
100
  RetrievalChunk[] }`) — forwarded from the built-in retrieval results.
101
101
  - `lr-citation-select` (`detail: CitationSelectEventDetail` = `{ citation: Citation }`, from
102
102
  `@aceshooting/lyra-ui/ai`) — forwarded from the built-in grounding summary.
103
- - `lr-tool-approval-decide` (`detail: ToolTimelineApprovalDetail` = `ToolApprovalEventDetail &
103
+ - `lr-tool-approval-decide-request` (`detail: ToolTimelineApprovalDetail` = `ToolApprovalEventDetail &
104
104
  { args?: unknown }` = `{ invocationId: string; approved: boolean; args?: unknown }`) — forwarded
105
105
  from the built-in tool timeline; `args` is present only on approval and may differ from what the
106
106
  entry originally proposed (the dialog's inline edit step).
@@ -130,7 +130,7 @@ reuses the existing Lyra toast layer instead of creating a second placement syst
130
130
  </button>
131
131
 
132
132
  <script type="module">
133
- import "@aceshooting/lyra-ui/components/overlays/alert/alert.js";
133
+ import "@aceshooting/lyra-ui/components/lr-alert.js";
134
134
 
135
135
  const alert = document.querySelector("#session-alert");
136
136
  alert.addEventListener("lr-after-hide", () => console.log("Alert is hidden"));
@@ -91,7 +91,7 @@ normal rebuild (a keyframe/timing/direction change or reconnect); the registry n
91
91
  native timeline that is already running.
92
92
 
93
93
  ```js
94
- import "@aceshooting/lyra-ui/components/media/animation/animation.js";
94
+ import "@aceshooting/lyra-ui/components/lr-animation.js";
95
95
  import { setAnimation } from "@aceshooting/lyra-ui/utilities/animation-registry.js";
96
96
 
97
97
  const animation = document.createElement("lr-animation");
@@ -232,10 +232,10 @@ persisted `preferred-mode` restored on mount (`storage-key` + `persist="preferre
232
232
  restored-on-mount case fires once, from the first `updated()` after that mount's render and
233
233
  attribute reflection have both landed, rather than synchronously during the mount itself; it is
234
234
  not fired for a redundant reassignment to the mode already in effect, nor when no preferred mode
235
- was persisted), `lr-toggle-request` (`detail: LyraAppRailToggleDetail` = `{ expanded: boolean, open: boolean }`;
235
+ was persisted), `lr-toggle-request` (`detail: LyraAppRailToggleDetail` = `{ expanded: boolean }`;
236
236
  cancelable proposal before a user-triggered overlay change), and non-cancelable `lr-toggle` with
237
237
  the same detail after the accepted state change. Forced responsive closes emit only `lr-toggle`;
238
- direct property writes remain silent. The `open` detail key remains a compatibility alias.
238
+ direct property writes remain silent.
239
239
  `lr-rail-resize-request` (`detail: LyraAppRailResizeDetail` = `{ widthPx: number }`; a cancelable
240
240
  proposed width from drag or keyboard stepping, emitted before the component assigns
241
241
  `railWidth` — call `preventDefault()` to keep the current width. A synchronous request listener
@@ -569,13 +569,12 @@ same precedence supplies the tooltip text when that opt-in flyout is visible, an
569
569
  interpolated `{label}` (see Events below).
570
570
 
571
571
  **Events:** `lr-toggle-request` — cancelable, emitted before `expanded` changes from the built-in
572
- disclosure (`detail: { expanded, open }` — `expanded` is the proposed state and the deprecated
573
- `open` key remains emitted and carries the same value, matching `<lr-app-rail-group>`'s identical
574
- event name and detail shape exactly). Call `preventDefault()` to keep the current state, or assign
572
+ disclosure (`detail: { expanded }` is the proposed state, matching `<lr-app-rail-group>`'s
573
+ event name and detail shape). Call `preventDefault()` to keep the current state, or assign
575
574
  `expanded` from the listener to resolve it yourself; a write during the dispatch suppresses the
576
575
  default commit even when it assigns the value the property already held. Not emitted for a direct
577
576
  `expanded` write. `lr-toggle` — non-cancelable, emitted after `expanded` is written, never for a
578
- vetoed or listener-resolved request (`detail: { expanded, open }`).
577
+ vetoed or listener-resolved request (`detail: { expanded }`).
579
578
 
580
579
  **Methods:** `click(): void` activates the internal native link or button; it is a no-op while
581
580
  `disabled`.
@@ -711,7 +710,7 @@ never disagree with what is rendered inside it.
711
710
 
712
711
  ```html
713
712
  <script type="module">
714
- import '@aceshooting/lyra-ui/components/layout/app-rail-group/app-rail-group.js';
713
+ import '@aceshooting/lyra-ui/components/lr-app-rail-group.js';
715
714
  </script>
716
715
 
717
716
  <lr-app-rail>
@@ -737,12 +736,11 @@ never disagree with what is rendered inside it.
737
736
  own chrome.
738
737
 
739
738
  **Events:** `lr-toggle-request` — cancelable, emitted before `collapsed` changes from the built-in
740
- control (`detail: { expanded, open }` — `expanded` is the proposed state and the deprecated `open`
741
- key remains emitted and carries the same value). Call `preventDefault()` to keep the current state,
739
+ control (`detail: { expanded }` is the proposed state). Call `preventDefault()` to keep the current state,
742
740
  or assign `collapsed` from the listener to resolve it yourself; a write during the dispatch
743
741
  suppresses the default commit even when it assigns the value the property already held. Not
744
742
  emitted for a direct `collapsed` write. `lr-toggle` — non-cancelable, emitted after `collapsed` is
745
- written, never for a vetoed or listener-resolved request (`detail: { expanded, open }`).
743
+ written, never for a vetoed or listener-resolved request (`detail: { expanded }`).
746
744
 
747
745
  **Slots:** default — the group's items, and any nested `<lr-app-rail-group>`s; `heading` — rich
748
746
  heading content; `header-actions` — controls beside the heading, rendered as a sibling of the
@@ -7,7 +7,7 @@
7
7
  - **Family** `components/agent-tools/` — see `llms/index.md` for its siblings
8
8
  - **Status** `stable` since `6.2.0` — see the maturity and deprecation policy in `llms/shared.md`
9
9
  - **Release history** [CHANGELOG.md](../../CHANGELOG.md); family-wide breaking-change summaries: [agent-tools](https://github.com/aceshooting/lyra-ui/blob/main/packages/lyra-ui/llms/agent-tools.md)
10
- - **Deprecated event** `lr-approval-decision` since `22.0.0`; use event `addEventListener('lr-approval-decision-request', event => { /* Call preventDefault() to veto the proposed action. */ })`; removal not before `24.0.0` — Cancelable proposals use request event names. The historical event remains a veto alias during its compatibility window.
10
+ - **Deprecations** none
11
11
  - **Optional peers** none
12
12
  - **Themeable via** 12 parts, 1 custom property — see this component's own `@csspart`/`@cssprop` list below
13
13
  - **Library-wide behavior** (events, form association, `locale`/`strings`, tokens, TS types): `llms/shared.md`
@@ -28,12 +28,10 @@ heading while an explicit empty string renders no heading/name. Later duplicate
28
28
  ids and empty/blank ids are omitted before count, selection, dialog lookup, or decision events are
29
29
  derived.
30
30
 
31
- **Events:** `lr-approval-select` (`{ invocationId }`), `lr-approval-decision-request` and `lr-approval-decision` (`{ invocationId,
31
+ **Events:** `lr-approval-select` (`{ invocationId }`), `lr-approval-decision-request` (`{ invocationId,
32
32
  approved, args? }`), and `lr-approval-close` (`{ invocationId, reason }`).
33
33
  `lr-approval-decision-request` is cancelable; calling `preventDefault()` vetoes the nested approve/deny
34
34
  request and keeps the decision dialog pending.
35
- `lr-approval-decision` is the deprecated cancelable alias, dispatched after the request with the
36
- same detail. Preventing either event keeps the nested decision pending; subscribe to one spelling.
37
35
  The selection and close events are non-cancelable notifications.
38
36
 
39
37
  Resolved rows (`approved`/`denied`) are never actionable. Replacing `requests` reconciles stale
@@ -7,7 +7,7 @@
7
7
  - **Family** `components/media/` — see `llms/index.md` for its siblings
8
8
  - **Status** `stable` since `4.0.0` — see the maturity and deprecation policy in `llms/shared.md`
9
9
  - **Release history** [CHANGELOG.md](../../CHANGELOG.md); family-wide breaking-change summaries: [media](https://github.com/aceshooting/lyra-ui/blob/main/packages/lyra-ui/llms/media.md)
10
- - **Deprecated property** `accessibleLabel` since `22.0.0`; use attribute `Use element.ariaLabel or setAttribute('aria-label', label); host attribute presence takes precedence over the compatibility fallback.`; removal not before `24.0.0` — The native host accessible-name API replaces this fallback property. The earlier accessible-label attribute deprecation has its own published release window; the programmatic property remains supported throughout its later window.
10
+ - **Deprecations** none
11
11
  - **Optional peers** none
12
12
  - **Themeable via** 7 parts, 0 custom properties — see this component's own `@csspart`/`@cssprop` list below
13
13
  - **Library-wide behavior** (events, form association, `locale`/`strings`, tokens, TS types): `llms/shared.md`
@@ -35,12 +35,11 @@ capability as a row.
35
35
  `'.pdf,.docx'`), forwarded to the hidden file input for the `files`/`image` capabilities. `image`
36
36
  defaults it to `'image/*'` unless this prop overrides it; `files` always uses it as-is (empty
37
37
  means "any file type").
38
+ - Host `aria-label` attribute (default absent) — overrides the localized accessible name on the
39
+ single-capability button or multi-capability menu trigger. An explicitly empty value stays empty.
38
40
  - `multiple: boolean = false` (reflected) — forwarded to the hidden file input. Bare `multiple`
39
41
  opts into batches; `multiple="false"` remains false and removal restores single-file mode.
40
42
  - `disabled: boolean = false` (reflected)
41
- - `accessibleLabel?: string` (property only, deprecated; removal not before 24.0.0) — overrides either trigger shape's localized
42
- accessible-name fallback. A host `aria-label`, including explicit empty, wins; in markup, name the
43
- trigger with the host `aria-label`.
44
43
  - `triggerTitle?: string` (attribute `trigger-title`) — forwards a sighted-user hover tooltip to
45
44
  both the single-capability and multi-capability trigger buttons
46
45
  - `appearance: LyraAppearance = 'plain'` (reflected) — how the trigger fills itself, from the
@@ -179,8 +179,8 @@ the remove button's `:hover` fill).
179
179
 
180
180
  <lr-tag variant="brand" appearance="outlined" with-remove>Design</lr-tag>
181
181
  <script type="module">
182
- import "@aceshooting/lyra-ui/components/overlays/badge/badge.js";
183
- import "@aceshooting/lyra-ui/components/overlays/badge/tag.js";
182
+ import "@aceshooting/lyra-ui/components/lr-badge.js";
183
+ import "@aceshooting/lyra-ui/components/lr-tag.js";
184
184
 
185
185
  document.querySelector("lr-tag").addEventListener("lr-remove", (e) => {
186
186
  e.target.remove(); // in an app, update the backing collection instead