contour-ds 1.7.2 → 1.9.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 (150) hide show
  1. package/README.md +244 -326
  2. package/dist/agent-cookbook.json +960 -0
  3. package/dist/agent-examples.json +65 -0
  4. package/dist/agent-map-wiring.json +152 -0
  5. package/dist/agent-rules.json +16 -0
  6. package/dist/build-manifest.json +344 -126
  7. package/dist/contour-wc-content.esm.js +1939 -0
  8. package/dist/contour-wc-content.esm.min.js +1 -0
  9. package/dist/contour-wc-core.esm.js +3724 -0
  10. package/dist/contour-wc-core.esm.min.js +1 -0
  11. package/dist/contour-wc-dashboard.esm.js +6986 -0
  12. package/dist/contour-wc-dashboard.esm.min.js +1 -0
  13. package/dist/contour-wc-data.esm.js +6572 -0
  14. package/dist/contour-wc-data.esm.min.js +1 -0
  15. package/dist/contour-wc-docs.esm.js +976 -0
  16. package/dist/contour-wc-docs.esm.min.js +1 -0
  17. package/dist/contour-wc-feedback.esm.js +1742 -0
  18. package/dist/contour-wc-feedback.esm.min.js +1 -0
  19. package/dist/contour-wc-forms.esm.js +2437 -0
  20. package/dist/contour-wc-forms.esm.min.js +1 -0
  21. package/dist/contour-wc-interaction.esm.js +1343 -0
  22. package/dist/contour-wc-interaction.esm.min.js +1 -0
  23. package/dist/contour-wc-layout.esm.js +845 -0
  24. package/dist/contour-wc-layout.esm.min.js +1 -0
  25. package/dist/contour-wc-map.esm.js +2411 -0
  26. package/dist/contour-wc-map.esm.min.js +1 -0
  27. package/dist/contour-wc-misc.esm.js +945 -0
  28. package/dist/contour-wc-misc.esm.min.js +1 -0
  29. package/dist/contour-wc-navigation.esm.js +2842 -0
  30. package/dist/contour-wc-navigation.esm.min.js +1 -0
  31. package/dist/contour-wc-ui.esm.js +6519 -0
  32. package/dist/contour-wc-ui.esm.min.js +1 -0
  33. package/dist/contour-wc.esm.js +14435 -5723
  34. package/dist/contour-wc.esm.min.js +1 -1
  35. package/dist/contour-wc.js +14436 -5725
  36. package/dist/contour-wc.min.js +1 -1
  37. package/dist/contour.a11y.json +402 -0
  38. package/dist/contour.code-snippets +4534 -0
  39. package/dist/contour.components.json +4870 -1222
  40. package/dist/contour.css +6672 -4711
  41. package/dist/contour.d.ts +753 -1085
  42. package/dist/contour.esm.js +440 -18
  43. package/dist/contour.esm.min.js +1 -1
  44. package/dist/contour.html-data.json +11343 -0
  45. package/dist/contour.js +440 -18
  46. package/dist/contour.min.css +1 -1
  47. package/dist/contour.min.js +1 -1
  48. package/dist/contour.react.d.ts +422 -0
  49. package/dist/contour.single.html +17 -0
  50. package/dist/contour.single.min.css +1 -0
  51. package/dist/contour.themes.json +56 -12
  52. package/dist/contour.tokens.json +1318 -1053
  53. package/dist/contour.vue.d.ts +420 -0
  54. package/dist/contour.web-types.json +11703 -0
  55. package/dist/custom-elements.json +36120 -0
  56. package/dist/docs/actions.md +16 -6
  57. package/dist/docs/affordances.md +21 -85
  58. package/dist/docs/apireference.md +9 -5
  59. package/dist/docs/colour.md +10 -4
  60. package/dist/docs/componentindex.md +9 -22
  61. package/dist/docs/data.md +39 -58
  62. package/dist/docs/docs.md +12 -7
  63. package/dist/docs/feedback.md +30 -12
  64. package/dist/docs/field.md +28 -13
  65. package/dist/docs/forms.md +35 -19
  66. package/dist/docs/index.json +70 -61
  67. package/dist/docs/install.md +12 -7
  68. package/dist/docs/landing.md +7 -4
  69. package/dist/docs/mapengine.md +30 -8
  70. package/dist/docs/motion.md +12 -6
  71. package/dist/docs/navigation.md +31 -7
  72. package/dist/docs/overlays.md +32 -25
  73. package/dist/docs/overview.md +3 -2
  74. package/dist/docs/patterns.md +20 -10
  75. package/dist/docs/playground.md +11 -4
  76. package/dist/docs/principles.md +8 -6
  77. package/dist/docs/recipes.md +117 -13
  78. package/dist/docs/space.md +10 -6
  79. package/dist/docs/status.md +13 -14
  80. package/dist/docs/surfaces.md +17 -22
  81. package/dist/docs/theming.md +18 -32
  82. package/dist/docs/type.md +12 -5
  83. package/dist/docs/webcomponents.md +75 -33
  84. package/dist/hljs.css +1 -20
  85. package/dist/map-chrome.mapbox.css +68 -92
  86. package/dist/map-chrome.maplibre.css +68 -92
  87. package/dist/registry/items/contour-core.json +2 -2
  88. package/dist/registry/items/contour-data.json +2 -2
  89. package/dist/registry/items/contour-docs.json +2 -2
  90. package/dist/registry/items/contour-landing.json +2 -2
  91. package/dist/registry/registry.json +8 -8
  92. package/dist/surfaces/contour-core.min.css +1 -1
  93. package/dist/surfaces/contour-data.min.css +1 -1
  94. package/dist/surfaces/contour-docs.min.css +1 -1
  95. package/dist/surfaces/contour-landing.min.css +1 -1
  96. package/dist/svg/icons.svg +367 -0
  97. package/dist/wc/behaviours.mjs +222 -192
  98. package/dist/wc/content.mjs +486 -142
  99. package/dist/wc/core.mjs +917 -395
  100. package/dist/wc/dashboard.mjs +252 -25
  101. package/dist/wc/data-chart.mjs +1333 -0
  102. package/dist/wc/data-export.mjs +391 -0
  103. package/dist/wc/data-gauge.mjs +779 -0
  104. package/dist/wc/data-geo.mjs +696 -0
  105. package/dist/wc/data-glyphs.mjs +133 -0
  106. package/dist/wc/data-legend.mjs +431 -0
  107. package/dist/wc/data-readout.mjs +227 -0
  108. package/dist/wc/data-series.mjs +1004 -0
  109. package/dist/wc/data-table.mjs +751 -0
  110. package/dist/wc/data.mjs +15 -3707
  111. package/dist/wc/docs.mjs +113 -19
  112. package/dist/wc/feedback.mjs +320 -116
  113. package/dist/wc/forms-controls.mjs +635 -0
  114. package/dist/wc/forms-field.mjs +547 -0
  115. package/dist/wc/forms-groups.mjs +347 -0
  116. package/dist/wc/forms-input.mjs +292 -0
  117. package/dist/wc/forms.mjs +10 -1122
  118. package/dist/wc/glyph.mjs +204 -0
  119. package/dist/wc/index.mjs +16 -7
  120. package/dist/wc/interaction.mjs +322 -75
  121. package/dist/wc/layout.mjs +100 -29
  122. package/dist/wc/map.mjs +888 -285
  123. package/dist/wc/misc.mjs +137 -26
  124. package/dist/wc/navigation-menu.mjs +735 -0
  125. package/dist/wc/navigation-shell.mjs +495 -0
  126. package/dist/wc/navigation-tree.mjs +995 -0
  127. package/dist/wc/navigation.mjs +9 -1636
  128. package/dist/wc/registration.mjs +1 -8
  129. package/dist/wc/shadow.mjs +285 -113
  130. package/dist/wc/states.mjs +75 -78
  131. package/dist/wc/svg.mjs +209 -34
  132. package/dist/wc/ui-atoms.mjs +608 -0
  133. package/dist/wc/ui-data.mjs +1404 -0
  134. package/dist/wc/ui-feedback.mjs +419 -0
  135. package/dist/wc/ui-inputs.mjs +1570 -0
  136. package/dist/wc/ui-menus.mjs +307 -0
  137. package/dist/wc/ui-overlays.mjs +1605 -0
  138. package/integrations/README.md +25 -5
  139. package/integrations/ai/CLAUDE.md +6 -3
  140. package/integrations/ai/COPILOT.md +14 -0
  141. package/integrations/ai/GEMINI.md +14 -0
  142. package/integrations/ai/WINDSURF.md +14 -0
  143. package/integrations/ai/v0-prompt.md +13 -1
  144. package/integrations/frameworks/README.md +235 -0
  145. package/integrations/native/README.md +0 -3
  146. package/integrations/native/style-dictionary.config.json +1 -1
  147. package/integrations/tailwind/contour-theme.css +71 -13
  148. package/integrations/validate-markup.mjs +172 -0
  149. package/package.json +103 -39
  150. package/dist/wc/ui.mjs +0 -3560
@@ -0,0 +1 @@
1
+ import{CLASS_ONLY,CONTOUR_EVENTS,ContourBase,MERCATOR_MAX_LAT,MODS,OBSERVED,REGISTERED,applyLabel,bearing,clampLat,contourId,cssLength,define,flagOn,flagOnValue,formatValue,haversine,headingTag,iconMarkup,isRtl,labelText,levelFromAttributes,mercatorResolution,navKey,normaliseLng,onDispose,safeColor,safeHref,sanitizeHtml,setHTML,simple,statusIcon,supportsUntilFound,unwrapBounds,warnBadJson,wcEmitOverlay,withBrownout,MARKER_SHAPES,arcPath,assignMarkers,barRects,compassNeedle,contourPaths,donutSlices,isMissing,marchingSquares,markerStyles,niceTicks,polylinePoints,scaleBarTicks,smoothPath,modalContain,wcReset,wireCombobox,wireCopy,wireMenu,wirePagination,wireRemovable,wireSegmented,wireTabs,wireTree,STATE_FALLBACK,loadRemote,parseArrayAttr,remoteData,remoteInvalidate,remoteRefresh,remoteVisible,renderEmpty,renderStates,stateLabel,watchViewport,wireStates}from"./contour-wc-core.esm.js";define("contour-box",simple(["c-box"])),define("contour-cluster",simple(["c-cluster"])),define("contour-container",simple(["c-container"])),define("contour-row",simple(["c-row"])),define("contour-scrim",simple(["c-scrim"])),define("contour-stack",simple(["c-stack"]));const assignedText=t=>{const e=t.querySelector("slot");return(e?e.assignedElements({flatten:!0}):[]).map(t=>(t.textContent||"").trim()).join(" ").trim()||(t.textContent||"").trim()};let ADOPTED=null,ADOPTED_KEY="";const _hashCss=t=>{let e=2166136261;for(let s=0;s<t.length;s++)e^=t.charCodeAt(s),e=Math.imul(e,16777619);return(e>>>0).toString(36)};export const adoptedSheets=()=>{let t=document.styleSheets.length+":";for(const e of document.styleSheets){let s="-1";try{const t=e.cssRules;let r="";for(let e=0;e<t.length;e++)r+=t[e].cssText+"\n";s=t.length+":"+_hashCss(r)}catch(t){}t+=(e.href||"inline")+"~"+s+"|"}if(ADOPTED&&t===ADOPTED_KEY)return ADOPTED;ADOPTED_KEY=t,ADOPTED=[];const e=(t,s)=>{let r;try{r=t.cssRules}catch(t){return}if(r)for(const t of r)if(t instanceof CSSImportRule)t.styleSheet&&e(t.styleSheet,s);else try{s.push(t.cssText)}catch(t){}};for(const t of document.styleSheets)try{if(!t.href||new URL(t.href).origin===location.origin){const s=[];e(t,s);const r=new CSSStyleSheet;s.length&&r.replaceSync(s.join("\n")),ADOPTED.push(r)}}catch(t){}return ADOPTED};const _ShadowParent="undefined"!=typeof HTMLElement?HTMLElement:Object;class ContourShadow extends _ShadowParent{static get observedAttributes(){return MODS.concat("labels")}constructor(){super();let t=this.shadowRoot;t||(t=this.attachShadow({mode:"open"}),this.constructor.contourTemplate&&t.appendChild(this.constructor.contourTemplate.content.cloneNode(!0)));const e=adoptedSheets();if(e.length)try{t.adoptedStyleSheets=e}catch(t){}this._shadowBase=t.firstElementChild?t.firstElementChild.className:""}enhance(t){t||(t=this.shadowRoot),t&&(t.querySelectorAll("details").forEach(t=>{const e=t.querySelector("summary");e&&!e.hasAttribute("aria-expanded")&&(e.setAttribute("aria-expanded",String(t.open)),t.addEventListener("toggle",()=>{e.setAttribute("aria-expanded",String(t.open))}))}),t.querySelectorAll("[data-live]").forEach(t=>{t.hasAttribute("role")||t.setAttribute("role","status"),t.hasAttribute("aria-live")||t.setAttribute("aria-live","polite")}),t.querySelectorAll(".c-spinner").forEach(t=>{t.hasAttribute("role")||t.setAttribute("role","status"),t.hasAttribute("aria-live")||t.setAttribute("aria-live","polite")}),t.querySelectorAll(".c-toast, .c-toast-host").forEach(t=>{t.hasAttribute("role")||t.setAttribute("role","status"),t.hasAttribute("aria-live")||t.setAttribute("aria-live","polite"),t.hasAttribute("aria-atomic")||t.setAttribute("aria-atomic","true")}),t.querySelectorAll("[role='tab']").forEach(e=>{const s=e.getAttribute("aria-controls");if(s){const r=t.querySelector("#"+CSS.escape(s))||document.getElementById(s);r&&!r.hasAttribute("aria-labelledby")&&(e.id||(e.id=contourId("tab")),r.setAttribute("aria-labelledby",e.id))}}),t.querySelectorAll("input, textarea, select").forEach(t=>{if(t.hasAttribute("aria-describedby"))return;const e=t.closest(".c-field");if(e){const s=e.querySelector(".c-field__hint");s&&(s.id||(s.id=contourId("hint")),t.setAttribute("aria-describedby",s.id));const r=e.querySelector(".c-field__error");if(r){r.id||(r.id=contourId("err"));const e=t.getAttribute("aria-describedby")||"";t.setAttribute("aria-describedby",(e+" "+r.id).trim())}}}),t.querySelectorAll(".c-alert").forEach(t=>{const e=t.classList.contains("c-alert--warning")||t.classList.contains("c-alert--danger"),s=e?"alert":"status",r=e?"assertive":"polite";t.hasAttribute("role")&&!t.dataset.contourAutoRole||(t.setAttribute("role",s),t.dataset.contourAutoRole=s),t.hasAttribute("aria-live")&&!t.dataset.contourAutoLive||(t.setAttribute("aria-live",r),t.dataset.contourAutoLive=r)}),t.querySelectorAll("input[required], textarea[required], select[required]").forEach(t=>{t.hasAttribute("aria-required")||t.setAttribute("aria-required","true")}),this._wireLabels(t),this._wireClose(t))}_wireClose(t){if(!t||this._wiredShadowClose)return;const e=t.querySelectorAll(".c-callout__close, .c-alert__close, .c-tag__remove, .c-filter-pill__remove");if(e.length){this._wiredShadowClose=!0;for(const t of e)t.addEventListener("click",()=>{this.hidden=!0,this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}))})}}_wireLabels(t){t&&t.querySelectorAll("label").forEach(t=>{const e=t.querySelector("slot"),s=t.closest(".c-field")||t.parentElement,r=[];if(e)for(const t of e.assignedElements({flatten:!0}))t.matches("input, textarea, select")&&r.push(t);if(!r.length&&s){const t=s.querySelector('slot[name="input"]');if(t)for(const e of t.assignedElements({flatten:!0}))e.matches("input, textarea, select")&&r.push(e)}for(const e of r){if(e.id||(e.id=contourId("shadow-input")),t.hasAttribute("for")||t.setAttribute("for",e.id),!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")){const s=assignedText(t);s&&e.setAttribute("aria-label",s)}if(e._contourLabelWired||(e._contourLabelWired=!0,t.addEventListener("click",t=>{if(!t.target.closest("a, button, input, textarea, select"))try{e.click()}catch(t){}})),s&&!e.hasAttribute("aria-describedby")){const t=s.querySelector(".c-field__hint"),r=s.querySelector(".c-field__error"),i=[];t&&(t.id||(t.id=contourId("hint")),i.push(t.id)),r&&(r.id||(r.id=contourId("err")),i.push(r.id)),i.length&&e.setAttribute("aria-describedby",i.join(" "))}}})}connectedCallback(){this.applyMods();try{this.enhance(this.shadowRoot)}catch(t){}this._applyLabels();try{wcReset(this),wireTabs(this),wireSegmented(this),wireCombobox(this),wireTree(this),wireMenu(this),wirePagination(this),wireCopy(this),wireRemovable(this)}catch(t){}this.shadowRoot&&!this._wiredSlotchange&&(this._wiredSlotchange=!0,this.shadowRoot.addEventListener("slotchange",()=>{try{this.enhance(this.shadowRoot),this._applyLabels(),wireTabs(this),wireSegmented(this),wireCombobox(this),wireTree(this),wireMenu(this),wirePagination(this),wireCopy(this),wireRemovable(this)}catch(t){}}))}attributeChangedCallback(){this.applyMods(),this._applyLabels()}_applyLabels(){const t=this.shadowRoot;if(!t)return;const e=(e,s,r)=>{const i=t.querySelector(e);i&&i.setAttribute("aria-label",labelText(this,s,r))};e(".c-callout__close","close","Close"),e(".c-alert__close","close","Close"),e(".c-tag__remove","remove","Remove"),e(".c-filter-pill__remove","remove-filter","Remove filter"),e(".c-breadcrumb","breadcrumb","Breadcrumb"),e(".c-spinner","loading","Loading"),e(".c-install__copy","copy-command","Copy command");const s=t.querySelector(".c-install__copy, .c-code__copy");s&&"Copy"===s.textContent.trim()&&(s.textContent=labelText(this,"copy","Copy"))}applyMods(){const t=this.shadowRoot.firstElementChild;if(!t||!this._shadowBase)return;const e=[];for(const t of MODS){const s=this.getAttribute(t);if(s)for(const t of this._shadowBase.split(/\s+/))t&&e.push("c-"+t.replace(/^c-/,"")+"--"+s)}if(t.className=(this._shadowBase+" "+e.join(" ")).trim(),t.classList.contains("c-alert")){const e=t.classList.contains("c-alert--warning")||t.classList.contains("c-alert--danger"),s=e?"alert":"status",r=e?"assertive":"polite";t.hasAttribute("role")&&!t.dataset.contourAutoRole||(t.setAttribute("role",s),t.dataset.contourAutoRole=s),t.hasAttribute("aria-live")&&!t.dataset.contourAutoLive||(t.setAttribute("aria-live",r),t.dataset.contourAutoLive=r)}}}const SHADOW_PARTS_PUBLIC={},SHADOW_MARKUP={},recordParts=(t,e)=>{SHADOW_PARTS_PUBLIC[t]=[...e.matchAll(/part="([^"]+)"/g)].flatMap(t=>t[1].split(/\s+/)).filter(Boolean)},shadow=(t,e)=>{if(SHADOW_MARKUP[t]=e,recordParts(t,e),"undefined"==typeof document)return;const s=document.createElement("template");setHTML(s,e);const r=class extends ContourShadow{};r.contourTemplate=s,define(t,r)},slotWrapper=(t,e,s)=>"<"+t+' class="c-'+e+'" part="'+(s||e)+'"'+("button"===t?' type="button"':"")+"><slot></slot></"+t+">",SHADOW_SLOTS={div:["accordion","activity","advanced","affordance","affordances","anchor","app","app-body","box","btn-group","chart-grid","catchment","cluster","command","compare","comparison","compass","contour-plot","cta","dash-freshness","dash-kpi-row","dash-shell","dash-toolbar","datamark","delta","draggable","drag-handle","drop-indicator","drop-zone","destructive-hint","docs-shell","drawer","elevation","filter-bar","flow-map","heatmap","hexbin","icon-badge","input-group","instrument","range-scale","resizable","table-wrap","time-range","toast-host","scroll-area","isochrone","landing-features","landing-hero","layer-panel","layer-switch","legend","logos","map-area","map-footer","map-panel","map-slot","measure","metrics","minimap","pager","pagination","panel","plate","price","pricing","progress","prose","pullquote","radio-list","range","readout","recipe","reserved","resize-handle","row","row-action","scale-bar","scrim","segmented","sheet","shortcut-list","shortcut-overlay","shortcut-panel","shortcut-row","showcase","sidebar","skeleton","sparkline","stack","steps","streaming-chart","survey","theme-scope","time-slider","timeline","toast","toolbar","tooltip","tree","version","version-banner"],button:["btn","pressable"],span:["avatar","badge","chip","dot","flag","live-badge","mark","pill"],a:["link","linkish"],kbd:["kbd"],label:["check","radio","switch"],nav:["docs-nav"]},SHADOW_PARTS={"version-banner":"banner","contour-plot":"plot"};for(const[t,e]of Object.entries(SHADOW_SLOTS))for(const s of e){shadow("contour-shadow-"+s,slotWrapper(t,s,SHADOW_PARTS[s]||s))}shadow("contour-shadow-callout",'<div class="c-callout" part="callout"><div class="c-callout__title" part="title"><slot name="title"></slot></div><div class="c-callout__body" part="body"><slot></slot></div><button class="c-callout__close" part="close" type="button" aria-label="Close">×</button></div>'),shadow("contour-shadow-empty",'<div class="c-empty" part="empty"><div class="c-empty__illustration" part="illustration"><slot name="illustration"></slot></div><div class="c-empty__title" part="title"><slot name="title"></slot></div><div class="c-empty__text" part="body"><slot></slot></div><div><slot name="action"></slot></div></div>'),shadow("contour-shadow-feature",'<div class="c-feature" part="feature"><span class="c-feature__index" part="index"><slot name="index"></slot></span><div class="c-feature__title" part="title"><slot name="title"></slot></div><div class="c-feature__body" part="body"><slot></slot></div></div>'),shadow("contour-shadow-kpi",'<div class="c-kpi" part="kpi"><div class="c-kpi__value" part="value"><slot name="value"></slot></div><div class="c-kpi__label" part="label"><slot name="label"></slot></div><div class="c-kpi__foot" part="foot"><slot name="delta"></slot><slot name="note"></slot></div></div>'),shadow("contour-shadow-stat",'<div class="c-stat" part="stat"><div class="c-stat__value" part="value"><slot name="value"></slot></div><div class="c-stat__label" part="label"><slot name="label"></slot></div><div class="c-stat__delta" part="delta"><slot name="delta"></slot></div></div>'),shadow("contour-shadow-meter",'<div class="c-meter" part="meter"><span class="c-meter__core" part="core"><span class="c-meter__value" part="value"><slot name="value"></slot></span><span class="c-meter__label" part="label"><slot name="label"></slot></span></span></div>'),shadow("contour-shadow-brownout",'<div class="c-brownout" part="brownout" data-level="0"><slot></slot></div>'),shadow("contour-shadow-widget-state",'<div class="c-widget-state" part="widget-state"><slot></slot></div>'),shadow("contour-shadow-donut",'<div class="c-donut" part="donut"><svg class="c-donut__ring" part="ring" viewBox="0 0 32 32"></svg><div class="c-donut__center" part="center"><slot name="value"></slot></div><div class="c-donut__list" part="list"><slot></slot></div></div>'),shadow("contour-shadow-axis",'<div class="c-axis" part="axis"><slot></slot></div>'),shadow("contour-shadow-brush",'<div class="c-brush" part="brush"><div class="c-brush__selection" part="selection"></div></div>'),shadow("contour-shadow-stacked-bar",'<div class="c-stacked-bar" part="bar"><slot></slot></div>'),shadow("contour-shadow-category",'<div class="c-category" part="category" role="listbox"><slot></slot></div>'),shadow("contour-shadow-gauge",'<div class="c-gauge" part="gauge"><svg class="c-gauge__dial" part="dial" aria-hidden="true" viewBox="0 0 100 100"><path class="c-gauge__track" part="track" d="M 10 90 A 40 40 0 0 1 90 90"></path><g class="c-gauge__zones"></g><line class="c-gauge__needle" part="needle" x1="50" y1="50" x2="50" y2="15"></line><circle class="c-gauge__hub" part="hub" cx="50" cy="50" r="4"></circle></svg><div class="c-gauge__value" part="value"><slot name="value"></slot></div><div class="c-gauge__band" part="band"><slot name="band"></slot></div></div>'),shadow("contour-shadow-diff",'<div class="c-diff" part="diff"><div class="c-diff__line c-diff__line--del" part="before"><span class="c-diff__sign">−</span><span><slot name="before"></slot></span></div><div class="c-diff__line c-diff__line--add" part="after"><span class="c-diff__sign">+</span><span><slot name="after"></slot></span></div></div>'),shadow("contour-shadow-do-dont",'<div class="c-do-dont" part="do-dont"><div class="c-do-dont__item c-do-dont__item--do" part="do"><slot name="do"></slot></div><div class="c-do-dont__item c-do-dont__item--dont" part="dont"><slot name="dont"></slot></div></div>'),shadow("contour-shadow-threshold",'<div class="c-threshold" part="threshold"><span class="c-threshold__fill" part="value"></span><span class="c-threshold__target" part="target"></span></div>'),shadow("contour-shadow-coordinate",'<div class="c-coordinate" part="coordinate"><span class="c-coordinate__value" part="value"><slot name="value"></slot></span></div>'),shadow("contour-shadow-install",'<div class="c-install" part="install"><span class="c-install__prompt" part="prompt"><slot name="prompt"></slot></span><span class="c-install__command" part="command"><slot name="command"></slot></span><button class="c-btn c-btn--ghost c-btn--sm c-install__copy" part="copy" type="button" aria-label="Copy command">Copy</button></div>'),shadow("contour-shadow-toc",'<div class="c-toc" part="toc"><div class="c-toc__title" part="title"><slot name="title"></slot></div><nav class="c-toc__list" part="list"><slot></slot></nav></div>'),shadow("contour-shadow-testimonial",'<div class="c-testimonial" part="testimonial"><blockquote class="c-testimonial__quote" part="quote"><slot name="quote"></slot></blockquote><div class="c-testimonial__byline" part="byline"><span class="c-testimonial__name" part="name"><slot name="name"></slot></span><span class="c-testimonial__role" part="role"><slot name="role"></slot></span></div></div>'),shadow("contour-shadow-search-trigger",'<button class="c-search-trigger" part="trigger"><span><slot name="label"></slot></span><kbd class="c-search-trigger__kbd"><slot name="shortcut"></slot></kbd></button>'),shadow("contour-shadow-brand",'<a class="c-brand" part="brand"><span class="c-mark" part="mark"><slot name="mark"></slot></span><span class="c-brand__name" part="name"><slot name="name"></slot></span></a>'),shadow("contour-shadow-section-head",'<div class="c-section-head" part="head"><h2 class="c-section-head__title" part="title"><slot name="title"></slot></h2><p class="c-section-head__desc" part="desc"><slot name="desc"></slot></p></div>'),shadow("contour-shadow-loading",'<div class="c-loading" part="loading"><span class="c-spinner" part="spinner"></span><slot></slot></div>'),shadow("contour-shadow-tabs",'<div class="c-tabs" part="tabs"><div class="c-tabs__list" part="list" role="tablist"><slot name="tabs"></slot></div><div class="c-tabs__panels" role="presentation"><slot></slot></div></div>'),shadow("contour-shadow-breadcrumb",'<nav class="c-breadcrumb" part="breadcrumb" aria-label="Breadcrumb"><ol><slot></slot></ol></nav>'),shadow("contour-shadow-menu",'<div class="c-menu" part="menu" role="menu"><slot></slot></div>'),shadow("contour-shadow-combobox",'<div class="c-combobox" part="combobox"><input class="c-combobox__input" part="input" type="text" /><ul class="c-combobox__list" part="list" hidden><slot></slot></ul></div>'),shadow("contour-shadow-chart",'<div class="c-chart" part="chart"><div class="c-chart__plot" part="plot"><slot></slot></div></div>'),shadow("contour-shadow-bivariate",'<div class="c-bivariate" part="bivariate"><div class="c-bivariate__matrix" part="matrix"><slot></slot></div></div>'),shadow("contour-shadow-bivariate-legend",'<div class="c-bivariate-legend" part="legend"><div class="c-bivariate-legend__matrix" part="matrix"><slot></slot></div></div>'),shadow("contour-shadow-expandable",'<details class="c-expandable" part="expandable"><summary class="c-expandable__summary"><slot name="summary"></slot></summary><div class="c-expandable__body" part="body"><slot></slot></div></details>'),shadow("contour-shadow-disclosure",'<details class="c-disclosure" part="disclosure"><summary><slot name="summary"></slot></summary><div class="c-disclosure__body" part="body"><slot></slot></div></details>'),shadow("contour-shadow-faq",'<div class="c-faq" part="faq"><div class="c-faq__question" part="question"><slot name="question"></slot></div><div class="c-faq__answer" part="answer"><slot name="answer"></slot></div></div>'),shadow("contour-shadow-code-tabs",'<div class="c-code-tabs" part="code-tabs"><div class="c-code-tabs__list" part="list" role="tablist"><slot name="tabs"></slot></div><div class="c-code-tabs__panels"><slot></slot></div></div>'),shadow("contour-shadow-header",'<header class="c-header" part="header"><div class="container c-header__inner" part="inner"><a class="c-brand" part="brand"><slot name="brand"></slot></a><nav class="c-header__nav" part="nav"><slot name="nav"></slot></nav><div class="c-header__actions" part="actions"><slot name="actions"></slot></div></div></header>'),shadow("contour-shadow-footer",'<footer class="c-footer" part="footer"><div class="container c-footer__grid" part="grid"><div class="c-footer__brand" part="brand"><slot name="brand"></slot></div><div class="c-footer__links" part="links"><slot name="links"></slot></div></div></footer>'),shadow("contour-shadow-container",'<div class="container" part="container"><slot></slot></div>'),shadow("contour-shadow-spinner",'<span class="c-spinner" part="spinner" aria-label="Loading"></span>'),shadow("contour-shadow-code",'<pre class="c-code" part="code"><code><slot></slot></code><button class="c-code__copy" part="copy" type="button">Copy</button></pre>'),shadow("contour-shadow-card",'<div class="c-card" part="card"> <div class="c-card__title" part="head"><slot name="title">Untitled</slot></div> <div class="c-card__body" part="body"><slot></slot></div> <div class="c-card__foot" part="foot"><slot name="foot"></slot></div> </div>'),shadow("contour-shadow-field",'<div class="c-field" part="field"> <label class="c-field__label" part="label"><slot name="label">Label</slot></label> <slot name="input"></slot> <span class="c-field__hint" part="hint"><slot name="hint"></slot></span> </div>'),shadow("contour-shadow-alert",'<div class="c-alert" part="alert"> <div class="c-alert__title" part="title"><slot name="title"></slot></div> <div class="c-alert__body" part="body"><slot></slot></div> <div class="c-alert__actions" part="actions"><slot name="action"></slot></div> <button class="c-alert__close" part="close" type="button" aria-label="Close">×</button> </div>'),shadow("contour-shadow-tag",'<span class="c-tag" part="tag"><slot></slot><button class="c-tag__remove" part="remove" type="button" aria-label="Remove">×</button></span>'),shadow("contour-shadow-filter-pill",'<span class="c-filter-pill" part="filter-pill"><slot></slot><button class="c-filter-pill__remove" part="remove" type="button" aria-label="Remove filter">×</button></span>');const DIALOG_MARKUP='<dialog class="c-dialog" part="dialog"> <div class="c-dialog__head" part="head"> <slot name="title"></slot> <button class="c-btn c-btn--icon c-btn--ghost" part="close" type="button" aria-label="Close"> <svg aria-hidden="true" viewBox="0 0 24 24"><path d="m18 6-12 12M6 6l12 12" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg> </button> </div> <div class="c-dialog__body" part="body"><slot></slot></div> <div class="c-dialog__foot" part="foot"><slot name="foot"></slot></div> </dialog>';SHADOW_MARKUP["contour-shadow-dialog"]=DIALOG_MARKUP,recordParts("contour-shadow-dialog",DIALOG_MARKUP);class ContourShadowDialog extends ContourShadow{static contourTemplate="undefined"!=typeof document?(()=>{const t=document.createElement("template");return setHTML(t,DIALOG_MARKUP),t})():null;enhance(t){if(super.enhance(t),this._wiredShadowDialog)return;this._wiredShadowDialog=!0;const e=t.querySelector("dialog"),s=t.querySelector('[part="close"]');if(s&&s.addEventListener("click",()=>e?.close()),e){let t=null;e.addEventListener("beforetoggle",s=>{if("open"===s.newState){t=document.activeElement,this._syncingOpenAttr=!0,this.hasAttribute("open")||this.setAttribute("open",""),this._syncingOpenAttr=!1,this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}));const r=e.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(r)try{r.focus()}catch(s){}}else if("closed"===s.newState&&(this._syncingOpenAttr=!0,this.hasAttribute("open")&&this.removeAttribute("open"),this._syncingOpenAttr=!1,this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0})),t&&"function"==typeof t.focus))try{t.focus()}catch(s){}});const s=()=>{const t="button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])",s=Array.from(e.querySelectorAll(t));for(const r of e.querySelectorAll("slot"))for(const e of r.assignedElements({flatten:!0})){e.matches(t)&&s.push(e);for(const r of e.querySelectorAll(t))s.push(r)}return s},r=()=>this.shadowRoot&&this.shadowRoot.activeElement||document.activeElement;e.addEventListener("keydown",t=>{if("Tab"!==t.key)return;const e=s();if(!e.length)return;const i=e[0],a=e[e.length-1];t.shiftKey&&r()===i?(t.preventDefault(),a.focus()):t.shiftKey||r()!==a||(t.preventDefault(),i.focus())})}}static get observedAttributes(){return[...super.observedAttributes,"open"]}attributeChangedCallback(t,e,s){if(super.attributeChangedCallback(t,e,s),"open"===t&&this.shadowRoot&&!this._syncingOpenAttr){const t=this.shadowRoot.querySelector("dialog");t&&(null===s||t.open?null===s&&t.open&&this.close():this.show())}}connectedCallback(){super.connectedCallback(),this.hasAttribute("open")&&this.show()}show(){if(!this.isConnected)return void(this.hasAttribute("open")||this.setAttribute("open",""));const t=this.shadowRoot?.querySelector("dialog");t&&!t.open&&t.showModal()}close(){const t=this.shadowRoot?.querySelector("dialog");t&&t.open&&t.close()}showModal(){this.show()}get open(){return!!this.shadowRoot?.querySelector("dialog")?.open}set open(t){t?this.show():this.close()}get returnValue(){return this.shadowRoot?.querySelector("dialog")?.returnValue??""}set returnValue(t){const e=this.shadowRoot?.querySelector("dialog");e&&(e.returnValue=String(t))}}define("contour-shadow-dialog",ContourShadowDialog);const renderShadowDSD=(t,e="",s="")=>{const r=SHADOW_MARKUP[t];if("string"!=typeof r)return null;return`<${t}${e?e.startsWith(" ")?e:" "+e:""}><template shadowrootmode="open">${r}</template>${s}</${t}>`},FROZEN_SHADOW_MARKUP=Object.freeze({...SHADOW_MARKUP});if("undefined"!=typeof globalThis&&(globalThis.ContourShadowTemplates=FROZEN_SHADOW_MARKUP),"undefined"!=typeof window){window.ContourShadowParts=Object.freeze(Object.fromEntries(Object.entries(SHADOW_PARTS_PUBLIC).map(([t,e])=>[t,Object.freeze([...new Set(e)])]))),window.Contour||(window.Contour={});try{window.Contour.shadowTemplates=FROZEN_SHADOW_MARKUP}catch{}}export{SHADOW_MARKUP,renderShadowDSD};class ContourAvatar extends ContourBase{static get observed(){return["name","size","variant","src","status"]}static get properties(){return{name:{attribute:"name"},size:{attribute:"size"},variant:{attribute:"variant"},src:{attribute:"src"},status:{attribute:"status"}}}render(){this.classList.add("c-avatar"),Array.from(this.classList).forEach(t=>{t.startsWith("c-avatar--")&&this.classList.remove(t)});const t=this.getAttribute("name"),e=this.getAttribute("size");e&&this.classList.add("c-avatar--"+e);const s=this.getAttribute("variant");s&&this.classList.add("c-avatar--"+s);const r=this.querySelector("img.c-avatar__img");r&&r.remove();const i=this.querySelector(".c-avatar__status");i&&i.remove();const a=this.getAttribute("src");if(a){this.textContent="";const e=document.createElement("img");e.className="c-avatar__img",e.src=a,e.alt=t||"",e.loading="lazy",e.decoding="async",e.addEventListener("error",()=>{if(e.remove(),t){const e=t.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2);this.textContent=e}}),this.appendChild(e)}else if(t){const e=t.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2);this.querySelector("img.c-avatar__img"),this.textContent=e}const n=this.getAttribute("status");if(n){const t=document.createElement("span");t.className="c-avatar__status c-avatar__status--"+n,t.setAttribute("aria-hidden","true"),this.appendChild(t)}}}define("contour-avatar",ContourAvatar);class ContourBadgeFull extends ContourBase{static get observed(){return["variant","label","size","removable"]}static get properties(){return{variant:{attribute:"variant"},label:{attribute:"label"},size:{attribute:"size"},removable:{attribute:"removable",type:Boolean}}}render(){this.classList.add("c-badge"),Array.from(this.classList).forEach(t=>{t.startsWith("c-badge--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-badge--"+t);const e=this.getAttribute("size");e&&this.classList.add("c-badge--"+e);const s=this.getAttribute("label");if(s){let t=null;for(const e of this.childNodes)if(3===e.nodeType){t=e;break}t?t.nodeValue=s:this.insertBefore(document.createTextNode(s),this.firstChild)}if(flagOn(this,"removable"))this.ensure(".c-badge__remove",()=>{const t=document.createElement("button");return t.className="c-badge__remove",t.type="button",t.setAttribute("aria-label",labelText(this,"remove","Remove")),t.textContent="×",t});else{const t=this.querySelector(".c-badge__remove");t&&t.remove()}}enhance(){wireRemovable(this)}}define("contour-badge",ContourBadgeFull);class ContourChipFull extends ContourBase{static get observed(){return["variant","key","value","live"]}static get properties(){return{variant:{attribute:"variant"},key:{attribute:"key"},value:{attribute:"value"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-chip"),flagOn(this,"live")&&!this.hasAttribute("role")?this.setAttribute("role","status"):!flagOn(this,"live")&&"status"===this.getAttribute("role")&&this._autoChipRole&&this.removeAttribute("role"),this._autoChipRole=flagOn(this,"live"),Array.from(this.classList).forEach(t=>{t.startsWith("c-chip--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-chip--"+t);const e=this.getAttribute("key"),s=this.getAttribute("value");if(e){this.ensure(".c-chip__key",()=>{const t=document.createElement("span");return t.className="c-chip__key",t}).textContent=e}else{const t=this.querySelector(".c-chip__key");t&&t.remove()}if(s){this.ensure(".c-chip__value",()=>{const t=document.createElement("span");return t.className="c-chip__value",t}).textContent=s}else{const t=this.querySelector(".c-chip__value");t&&t.remove()}}}define("contour-chip",ContourChipFull);class ContourTag extends ContourBase{static get observed(){return["label","removable","variant","live"]}static get properties(){return{label:{attribute:"label"},removable:{attribute:"removable",type:Boolean},variant:{attribute:"variant"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-tag"),flagOn(this,"live")&&!this.hasAttribute("role")?this.setAttribute("role","status"):!flagOn(this,"live")&&"status"===this.getAttribute("role")&&this._autoTagRole&&this.removeAttribute("role"),this._autoTagRole=flagOn(this,"live"),Array.from(this.classList).forEach(t=>{t.startsWith("c-tag--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-tag--"+t);const e=this.getAttribute("label");if(e){let t=null;for(const e of this.childNodes)if(3===e.nodeType){t=e;break}t?t.nodeValue=e+" ":this.insertBefore(document.createTextNode(e+" "),this.firstChild)}if(flagOn(this,"removable"))this.ensure(".c-tag__remove",()=>{const t=document.createElement("button");return t.className="c-tag__remove",t.type="button",t.setAttribute("aria-label",labelText(this,"remove","Remove")),t.textContent="×",t});else{const t=this.querySelector(".c-tag__remove");t&&t.remove()}}enhance(){wireRemovable(this)}}define("contour-tag",ContourTag);class ContourDot extends ContourBase{static get observed(){return["variant","live"]}static get properties(){return{variant:{attribute:"variant"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-dot"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","status indicator"),Array.from(this.classList).forEach(t=>{t.startsWith("c-dot--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-dot--"+t),flagOn(this,"live")?this.classList.add("c-dot--live"):this.classList.remove("c-dot--live")}}define("contour-dot",ContourDot);class ContourPill extends ContourBase{static get observed(){return["label","live","variant"]}static get properties(){return{label:{attribute:"label"},live:{attribute:"live",type:Boolean},variant:{attribute:"variant"}}}render(){this.classList.add("c-pill"),flagOn(this,"live")&&!this.hasAttribute("role")?this.setAttribute("role","status"):!flagOn(this,"live")&&"status"===this.getAttribute("role")&&this._autoPillRole&&this.removeAttribute("role"),this._autoPillRole=flagOn(this,"live"),Array.from(this.classList).forEach(t=>{t.startsWith("c-pill--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-pill--"+t);const e=this.getAttribute("label");e&&(this.textContent=e),flagOn(this,"live")?this.classList.add("c-pill--live"):this.classList.remove("c-pill--live")}}define("contour-pill",ContourPill);class ContourKbd extends ContourBase{static get observed(){return["key"]}static get properties(){return{key:{attribute:"key"}}}render(){this.classList.add("c-kbd");const t=this.getAttribute("key");t&&(this.textContent=t)}}define("contour-kbd",ContourKbd);class ContourSpinner extends ContourBase{static get observed(){return["size"]}static get properties(){return{size:{attribute:"size"}}}render(){this.classList.add("c-spinner"),Array.from(this.classList).forEach(t=>{t.startsWith("c-spinner--")&&this.classList.remove(t)});const t=this.getAttribute("size");t&&this.classList.add("c-spinner--"+t),this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"loading","Loading"))}}define("contour-spinner",ContourSpinner);class ContourSkeleton extends ContourBase{static get observed(){return["size","shimmer"]}static get properties(){return{size:{attribute:"size"},shimmer:{attribute:"shimmer",type:Boolean}}}render(){this.classList.add("c-skeleton"),Array.from(this.classList).forEach(t=>{t.startsWith("c-skeleton--")&&this.classList.remove(t)});const t=this.getAttribute("size");t&&this.classList.add("c-skeleton--"+t),this.hasAttribute("aria-hidden")||this.setAttribute("aria-hidden","true");const e=this.getAttribute("shimmer");flagOn(this,"shimmer")&&"off"!==e?this.classList.remove("c-skeleton--static"):this.classList.add("c-skeleton--static")}}define("contour-skeleton",ContourSkeleton);class ContourMark extends ContourBase{static get observed(){return["src","icon","label"]}static get properties(){return{src:{attribute:"src"},icon:{attribute:"icon"},label:{attribute:"label"}}}render(){this.classList.add("c-mark");const t=this.getAttribute("src")||this.getAttribute("icon");if(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),setHTML(e,'<use href="'+safeHref(t)+'" />'),this.appendChild(e)}const e=this.getAttribute("label");if(e&&!this.querySelector("[data-mark-label]")){const t=document.createElement("span");t.className="c-mark__label",t.setAttribute("data-mark-label",""),t.textContent=e,this.appendChild(t)}}}define("contour-mark",ContourMark);class ContourLoading extends ContourBase{static get observed(){return["label"]}static get properties(){return{label:{attribute:"label"}}}render(){this.classList.add("c-loading"),this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite"),this.ensure(".c-spinner",()=>{const t=document.createElement("span");return t.className="c-spinner",t.setAttribute("aria-hidden","true"),t});const t=this.getAttribute("label")||"Loading";let e=this.querySelector("[data-loading-label]");e||(e=document.createElement("span"),e.className="visually-hidden",e.setAttribute("data-loading-label",""),this.appendChild(e)),e.textContent=t,this.hasAttribute("aria-label")||this.setAttribute("aria-label",t)}}define("contour-loading",ContourLoading);class ContourElevation extends ContourBase{render(){this.classList.add("c-elevation")}}define("contour-elevation",ContourElevation);class ContourFilterPill extends ContourBase{static get observed(){return["key","value","removable"]}static get properties(){return{key:{attribute:"key"},value:{attribute:"value"},removable:{attribute:"removable",type:Boolean}}}render(){this.classList.add("c-filter-pill");const t=this.getAttribute("key"),e=this.getAttribute("value");if(t){this.ensure(".c-filter-pill__key",()=>{const t=document.createElement("span");return t.className="c-filter-pill__key",t}).textContent=t}else{const t=this.querySelector(".c-filter-pill__key");t&&t.remove()}if(e){this.ensure(".c-filter-pill__value",()=>{const t=document.createElement("span");return t.className="c-filter-pill__value",t}).textContent=e}else{const t=this.querySelector(".c-filter-pill__value");t&&t.remove()}if(flagOn(this,"removable"))this.ensure(".c-filter-pill__remove",()=>{const t=document.createElement("button");return t.className="c-filter-pill__remove",t.type="button",t.setAttribute("aria-label",labelText(this,"remove-filter","Remove filter")),t.textContent="×",t});else{const t=this.querySelector(".c-filter-pill__remove");t&&t.remove()}}enhance(){wireRemovable(this)}}define("contour-filter-pill",ContourFilterPill);class ContourDatamark extends ContourBase{static get observed(){return["value","unit","label","format","locale"]}static get properties(){return{value:{attribute:"value"},unit:{attribute:"unit"},label:{attribute:"label"},format:{attribute:"format"},locale:{attribute:"locale"}}}render(){this.classList.add("c-datamark");const t=this.getAttribute("value"),e=this.getAttribute("unit"),s=this.getAttribute("label"),r=this.getAttribute("format"),i=this.getAttribute("locale"),a=t||s;if(a){const s=t?formatValue(t,r,i,e):a;if(this.textContent=s,e&&t){const t=document.createElement("span");t.className="u-subtle",t.textContent=" "+e,this.appendChild(t)}}}}define("contour-datamark",ContourDatamark);class ContourDestructiveHint extends ContourBase{static get observed(){return["text"]}static get properties(){return{text:{attribute:"text"}}}render(){this.classList.add("c-destructive-hint");const t=this.getAttribute("text");t&&(this.textContent=t)}}define("contour-destructive-hint",ContourDestructiveHint);class ContourIconBadge extends ContourBase{static get observed(){return["icon"]}static get properties(){return{icon:{attribute:"icon"}}}render(){this.classList.add("c-icon-badge");const t=this.getAttribute("icon");if(t){const e=String(t).replace(/[^a-zA-Z0-9_-]/g,"");e&&!e.startsWith("i-")&&"undefined"!=typeof console&&console.warn&&console.warn("ContourIconBadge: icon '"+t+"' may not exist in the sprite (expected i-* name).");const s=this.querySelector("svg"),r=s||document.createElementNS("http://www.w3.org/2000/svg","svg");if(s){const t=r.querySelector("use");t&&t.setAttribute("href","#"+e)}else{r.setAttribute("aria-hidden","true");const t=document.createElementNS("http://www.w3.org/2000/svg","use");t.setAttribute("href","#"+e),r.appendChild(t),this.appendChild(r)}}else{const t=this.querySelector("svg");t&&t.remove()}}}define("contour-icon-badge",ContourIconBadge);class ContourLiveBadge extends ContourBase{static get observed(){return["label","state","live"]}static get properties(){return{label:{attribute:"label"},state:{attribute:"state"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-live-badge"),this.hasAttribute("role")||this.setAttribute("role","status"),Array.from(this.classList).forEach(t=>{t.startsWith("c-live-badge--")&&this.classList.remove(t)});const t=this.getAttribute("state");t?this.classList.add("c-live-badge--"+t):flagOn(this,"live")&&this.classList.add("c-live-badge--connected");const e=this.getAttribute("label");e&&!this.hasChildNodes()&&(this.textContent=e)}}define("contour-live-badge",ContourLiveBadge);class ContourSkeletonGroup extends ContourBase{static get observed(){return["count","size","shimmer"]}static get properties(){return{count:{attribute:"count",type:Number},size:{attribute:"size"},shimmer:{attribute:"shimmer",type:Boolean}}}render(){this.classList.add("c-skeleton-group");const t=Math.max(0,parseInt(this.getAttribute("count")||"3",10)||3),e=this.getAttribute("size"),s=this.getAttribute("shimmer");Array.from(this.querySelectorAll(".c-skeleton")).forEach(t=>t.remove());for(let r=0;r<t;r++){const t=document.createElement("div");t.className="c-skeleton",e&&t.classList.add("c-skeleton--"+e),t.setAttribute("aria-hidden","true"),flagOn(this,"shimmer")&&"off"!==s?t.classList.remove("c-skeleton--static"):t.classList.add("c-skeleton--static"),this.appendChild(t)}}}define("contour-skeleton-group",ContourSkeletonGroup);class ContourAvatarGroup extends ContourBase{static get observed(){return["items","max"]}static get properties(){return{items:{attribute:"items"},max:{attribute:"max",type:Number}}}render(){this.classList.add("c-avatar-group");const t=this.getAttribute("items"),e=parseInt(this.getAttribute("max")||"4",10)||4;if(Array.from(this.querySelectorAll(".c-avatar, .c-avatar-group__overflow")).forEach(t=>t.remove()),t)try{const s=JSON.parse(t);if(s.slice(0,e).forEach(t=>{const e=document.createElement("span");e.className="c-avatar";const s="string"==typeof t?t:t.name||t.label||"";if(e.textContent=s.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2),"object"==typeof t&&t.color){const s=safeColor(t.color);s&&(e.style.background=s,e.dataset.color=s)}this.appendChild(e)}),s.length>e){const t=document.createElement("span");t.className="c-avatar c-avatar-group__overflow";const r=s.length-e;t.textContent="+"+r,t.setAttribute("aria-label","+"+r+" more"),this.appendChild(t)}}catch(t){warnBadJson(this,"attribute",t)}}}define("contour-avatar-group",ContourAvatarGroup);class ContourDivider extends ContourBase{static get observed(){return["label","orientation"]}static get properties(){return{label:{attribute:"label"},orientation:{attribute:"orientation"}}}render(){this.classList.add("c-divider"),this.hasAttribute("role")||this.setAttribute("role","separator");const t=this.getAttribute("orientation")||"horizontal";this.classList.add("c-divider--"+t);const e=this.getAttribute("label");if(e){this.ensure(".c-divider__label",()=>{const t=document.createElement("span");return t.className="c-divider__label",t}).textContent=e}}}define("contour-divider",ContourDivider);class ContourStatusLight extends ContourBase{static get observed(){return["status","label"]}static get properties(){return{status:{attribute:"status"},label:{attribute:"label"}}}render(){this.classList.add("c-status-light");const t=this.getAttribute("status")||"neutral";this.classList.add("c-status-light--"+t),this.hasAttribute("role")||this.setAttribute("role","img");const e=this.getAttribute("label");if(e&&!this.hasAttribute("aria-label")?this.setAttribute("aria-label",e):e||this.hasAttribute("aria-label")||this.setAttribute("aria-label",t),e){this.ensure(".c-status-light__label",()=>{const t=document.createElement("span");return t.className="c-status-light__label",t}).textContent=e}}}define("contour-status-light",ContourStatusLight);class ContourBadgeOverflow extends ContourBase{static get observed(){return["count","max"]}static get properties(){return{count:{attribute:"count"},max:{attribute:"max"}}}render(){this.classList.add("c-badge-overflow");const t=Number(this.getAttribute("count")||0),e=Number(this.getAttribute("max")||3),s=Math.max(0,t-e),r=this.querySelector(".c-badge-overflow__more");if(r&&r.remove(),s>0){const t=document.createElement("span");t.className="c-badge c-badge-overflow__more",t.textContent="+"+s,this.appendChild(t)}}}define("contour-badge-overflow",ContourBadgeOverflow);class ContourTooltip extends ContourBase{static get observed(){return["text","anchor","delay","trigger"]}static get properties(){return{text:{attribute:"text"},anchor:{attribute:"anchor"},delay:{attribute:"delay",type:Number},trigger:{attribute:"trigger"}}}render(){this.classList.add("c-tooltip"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"tooltip","Tooltip")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.hasAttribute("role")||this.setAttribute("role","tooltip"),this.id||(this.id=contourId("tip"));const t=this.getAttribute("text");null===t||this.hasChildNodes()||(this.textContent=t)}enhance(){if(this._wiredTooltip)return;this._wiredTooltip=!0;const t=this.getAttribute("anchor");if(t){let e=null;e=t.startsWith("#")?document.getElementById(t.slice(1)):document.querySelector(t),e&&(e.setAttribute("popovertarget",this.id||(this.id=contourId("tip"))),e.setAttribute("aria-describedby",this.id))}const e=this.delay&&this.delay>0?this.delay:0,s=this.getAttribute("anchor");let r=null;s&&(r=s.startsWith("#")?document.getElementById(s.slice(1)):document.querySelector(s));const i="--tooltip-"+(this.id||(this.id=contourId("tip")));(()=>{r&&(r.style.setProperty("anchor-name",i),this.style.setProperty("position-anchor",i),this.style.setProperty("position-area","top"))})();const a="function"==typeof this.showPopover;let n=null,o=null;const l=()=>{if(a)try{this.showPopover()}catch(t){}else this.classList.add("is-open"),this.style.zIndex="var(--z-tooltip)";try{requestAnimationFrame(w)}catch(t){w()}},c=()=>{if(o&&(clearTimeout(o),o=null),a)try{this.hidePopover()}catch(t){}else this.classList.remove("is-open"),this.style.removeProperty("z-index")},u=()=>{n&&clearTimeout(n),e>0?n=setTimeout(l,e):l()},d=()=>{n&&(clearTimeout(n),n=null),o&&clearTimeout(o),o=setTimeout(c,300)};this.addEventListener("pointerenter",()=>{o&&(clearTimeout(o),o=null)}),this.addEventListener("pointerleave",d),onDispose(this,()=>{r&&r.style.removeProperty("anchor-name")});const h=this.getAttribute("trigger")||"hover",p=s?s.startsWith("#")?document.getElementById(s.slice(1)):document.querySelector(s):null,b=p||this,m=()=>{"click"!==h&&u()},g=()=>{"click"!==h&&d()},v=()=>{"click"!==h&&u()},_=()=>{"click"!==h&&d()},f=t=>{p&&p.hasAttribute("popovertarget")?"click"!==h&&t&&t.preventDefault&&t.preventDefault():"click"!==h&&"hover"!==h||(this.matches(":popover-open")?d():u())},y=()=>{"click"!==h&&u()},A=()=>{"click"!==h&&setTimeout(d,1500)};b.addEventListener("mouseenter",m),b.addEventListener("mouseleave",g),b.addEventListener("focus",v),b.addEventListener("blur",_),b.addEventListener("click",f),b.addEventListener("touchstart",y,{passive:!0}),b.addEventListener("touchend",A,{passive:!0});const w=()=>{try{const t=this.getBoundingClientRect();t.right>window.innerWidth?this.classList.add("c-tooltip--flip-x"):this.classList.remove("c-tooltip--flip-x"),t.bottom>window.innerHeight?this.classList.add("c-tooltip--flip-y"):this.classList.remove("c-tooltip--flip-y")}catch(t){}};onDispose(this,()=>{b.removeEventListener("mouseenter",m),b.removeEventListener("mouseleave",g),b.removeEventListener("focus",v),b.removeEventListener("blur",_),b.removeEventListener("click",f),b.removeEventListener("touchstart",y),b.removeEventListener("touchend",A),n&&clearTimeout(n)}),this.addEventListener("toggle",t=>{const e=t.target;if(e&&e===this){const t=this.matches(":popover-open");wcEmitOverlay(this,t?"contour:open":"contour:close",{open:t})}})}}define("contour-tooltip",ContourTooltip);class ContourProgress extends ContourBase{static get observed(){return["value","label","min","max","paused","pausable"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},min:{attribute:"min"},max:{attribute:"max"},paused:{attribute:"paused",type:Boolean},pausable:{attribute:"pausable",type:Boolean}}}render(){this.classList.add("c-progress");const t=this.getAttribute("value"),e=this.getAttribute("min"),s=this.getAttribute("max"),r=null!==e?Number(e):0,i=null!==s?Number(s):100,a=i-r||1;if(null===t)this.style.removeProperty("--progress"),this.classList.add("c-progress--indeterminate"),this.getAttribute("aria-valuenow")===this._progressAriaValue&&this.removeAttribute("aria-valuenow"),this._progressAriaValue=null;else{this.classList.remove("c-progress--indeterminate");const e=Number(t);let s;s=Number.isFinite(e)?e<=1&&t.includes(".")?100*e:(e-r)/a*100:0,s=Math.max(0,Math.min(100,s)),this.style.setProperty("--progress",s+"%"),this.classList.toggle("c-progress--complete",s>=100);const n=Number.isFinite(e)?Math.max(r,Math.min(i,e)):r,o=this._progressAriaValue;this.hasAttribute("aria-valuenow")&&this.getAttribute("aria-valuenow")!==o||(this.setAttribute("aria-valuenow",String(n)),this._progressAriaValue=String(n))}this.ensure(".c-progress__bar",()=>{const t=document.createElement("span");return t.className="c-progress__bar",t}),this.hasAttribute("role")||this.setAttribute("role","progressbar");const n=this.getAttribute("label");if(this.hasAttribute("aria-label")||this.setAttribute("aria-label",n||"Progress"),null!==e?this.setAttribute("aria-valuemin",e):this.hasAttribute("aria-valuemin")||this.setAttribute("aria-valuemin","0"),null!==s?this.setAttribute("aria-valuemax",s):this.hasAttribute("aria-valuemax")||this.setAttribute("aria-valuemax","100"),this.hasAttribute("aria-valuenow")){const t=Number(this.getAttribute("aria-valuenow"));Number.isFinite(t)&&this.setAttribute("aria-valuenow",String(Math.max(r,Math.min(i,t))))}if(flagOn(this,"paused")?this.classList.add("c-progress--paused"):Array.from(this.classList).forEach(t=>{"c-progress--paused"===t&&this.classList.remove(t)}),flagOn(this,"pausable")){const t=flagOn(this,"paused"),e=this.ensure(".c-progress__pause",()=>{const t=document.createElement("button");return t.className="c-progress__pause",t.type="button",t});e.setAttribute("aria-label",t?"Resume":"Pause"),e.textContent=t?"▶":"⏸"}else{const t=this.querySelector(".c-progress__pause");t&&t.remove()}}enhance(){this._wiredProgress||(this._wiredProgress=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-progress__pause"):null;if(!e||!this.contains(e))return;t.preventDefault();const s=!flagOn(this,"paused");this.toggleAttribute("paused",s),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{paused:s}}))}))}}define("contour-progress",ContourProgress);class ContourVersionBannerFull extends ContourBase{static get observed(){return["message","link","href","dismissible"]}static get properties(){return{message:{attribute:"message"},link:{attribute:"link"},href:{attribute:"href"},dismissible:{attribute:"dismissible",type:Boolean}}}render(){this.classList.add("c-version-banner"),this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("message")||"Version banner"),Array.from(this.children).forEach(t=>t.remove());const t=this.getAttribute("message");if(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),setHTML(e,'<use href="#i-info" />'),this.appendChild(e);const s=document.createElement("span");s.textContent=t,this.appendChild(s)}const e=this.getAttribute("link"),s=this.getAttribute("href");if(e&&s){const t=document.createElement("a");t.className="c-version-banner__link",t.href=safeHref(s),t.textContent=e,this.appendChild(t)}if(flagOn(this,"dismissible")){const t=document.createElement("button");t.className="c-version-banner__dismiss",t.type="button",t.setAttribute("aria-label",labelText(this,"dismiss","Dismiss")),t.textContent="×",this.appendChild(t)}}enhance(){this._wiredVersionBanner||(this._wiredVersionBanner=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-version-banner__dismiss"):null;e&&this.contains(e)&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0})),this.remove())}))}}define("contour-version-banner",ContourVersionBannerFull);class ContourBanner extends ContourBase{static get observed(){return["message","variant"]}static get properties(){return{message:{attribute:"message"},variant:{attribute:"variant"}}}render(){this.classList.add("c-banner");const t=this.getAttribute("variant");Array.from(this.classList).forEach(t=>{t.startsWith("c-banner--")&&this.classList.remove(t)}),t&&["info","success","warning","danger","error"].includes(t)&&this.classList.add("c-banner--"+t);const e=statusIcon(t);let s=this.querySelector(".c-banner__icon");e?(s||(s=document.createElement("span"),s.className="c-banner__icon"),setHTML(s,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#'+String(e).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'),this.firstChild!==s&&this.prepend(s)):s&&s.remove();const r=this.getAttribute("message");if(r){this.ensure(".c-banner__message",()=>{const t=document.createElement("span");return t.className="c-banner__message",t}).textContent=r}}}define("contour-banner",ContourBanner);class ContourPullToRefresh extends ContourBase{static get observed(){return["threshold"]}static get properties(){return{threshold:{attribute:"threshold"}}}render(){this.classList.add("c-pull-to-refresh"),this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"label","Pull to refresh"));const t=this.ensure(".c-pull-to-refresh__indicator",()=>{const t=document.createElement("div");return t.className="c-pull-to-refresh__indicator",t});t.innerHTML="";const e=document.createElement("span");e.className="c-pull-to-refresh__label",e.setAttribute("aria-live","polite"),e.textContent=this._ptrError?this._ptrError:this._ptrRefreshing?labelText(this,"refreshing","Refreshing…"):labelText(this,"label","Pull to refresh"),t.appendChild(e);const s=document.createElement("button");s.type="button",s.className="c-pull-to-refresh__btn",s.textContent=labelText(this,"refresh","Refresh"),t.appendChild(s),t.parentNode!==this&&this.prepend(t),this.classList.toggle("is-refreshing",!!this._ptrRefreshing),this.classList.toggle("has-error",!!this._ptrError),this.setAttribute("aria-busy",String(!!this._ptrRefreshing))}complete(){this._ptrRefreshing=!1,this._ptrError=null,this.style.removeProperty("--ptr-offset"),this.requestRender()}fail(t){this._ptrRefreshing=!1,this._ptrError=String(t||labelText(this,"error","Refresh failed")),this.style.removeProperty("--ptr-offset"),this.requestRender(),this.dispatchEvent(new CustomEvent("contour:error",{bubbles:!0,composed:!0,detail:{message:this._ptrError}}))}_refresh(){this._ptrRefreshing||(this._ptrRefreshing=!0,this._ptrError=null,this.style.removeProperty("--ptr-offset"),this.requestRender(),this.dispatchEvent(new CustomEvent("contour:refresh",{bubbles:!0,composed:!0})))}enhance(){if(this._wiredPullToRefresh)return;this._wiredPullToRefresh=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-pull-to-refresh__btn"):null;e&&this.contains(e)&&this._refresh()});let t=0,e=!1,s=0;this.addEventListener("pointerdown",r=>{if(!(this._ptrRefreshing||this.scrollTop>0||r.target&&r.target.closest&&r.target.closest(".c-pull-to-refresh__btn"))){t=r.clientY,e=!0,s=0;try{this.setPointerCapture(r.pointerId)}catch(t){}}}),this.addEventListener("pointermove",r=>{if(!e)return;const i=r.clientY-t;i>0&&(s=Math.min(120,.6*i),this.style.setProperty("--ptr-offset",s+"px"))});const r=()=>{if(!e)return;e=!1;const t=Number(this.getAttribute("threshold"))||60;s>=t?this._refresh():this.style.removeProperty("--ptr-offset"),s=0};this.addEventListener("pointerup",r),this.addEventListener("pointercancel",r)}}function menuPopoverCapable(t){return!!t&&"function"==typeof t.showPopover&&"function"==typeof t.hidePopover}function placeMenu(t,e,s,r){if(!t||!e)return;const i=e.getBoundingClientRect(),a=t.offsetWidth||0,n=t.offsetHeight||0;let o=i.bottom+s;o+n>window.innerHeight&&i.top-s-n>=0&&(o=i.top-s-n);let l=r?i.right-a:i.left;l=Math.max(0,Math.min(l,Math.max(0,window.innerWidth-a))),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.top=o+"px",t.style.left=l+"px"}function armMenuReposition(t,e,s,r,i){disarmMenuReposition(t);const a=()=>{e.hidden||placeMenu(e,s(),r,i)};t._menuReposition=a,window.addEventListener("scroll",a,!0),window.addEventListener("resize",a)}function disarmMenuReposition(t){const e=t._menuReposition;e&&(window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e),t._menuReposition=null)}function setMenuOpen(t,e,s,r,i){if(e)if(r){if(e.hidden=!1,menuPopoverCapable(e)){e.style.removeProperty("margin");const r=getComputedStyle(e),a=parseFloat(r.marginBlockStart||r.marginTop)||0;try{e.showPopover()}catch(t){}placeMenu(e,s(),a,i),armMenuReposition(t,e,s,a,i)}}else{if(menuPopoverCapable(e)&&e.matches(":popover-open"))try{e.hidePopover()}catch(t){}disarmMenuReposition(t),e.hidden=!0}}define("contour-pull-to-refresh",ContourPullToRefresh);class ContourDropdown extends ContourBase{static get observed(){return["label","items","empty"]}static get properties(){return{label:{attribute:"label"},items:{attribute:"items"}}}render(){this.classList.add("c-dropdown"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"dropdown","Dropdown"));const t=this.ensure(".c-dropdown__trigger",()=>{const t=document.createElement("button");return t.className="c-dropdown__trigger c-btn c-btn--sm",t.type="button",t});t.textContent=this.getAttribute("label")||"Menu",t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-expanded","false");const e=this.ensure(".c-dropdown__menu",()=>{const t=document.createElement("div");return t.className="c-dropdown__menu c-menu",t.setAttribute("role","menu"),t.hidden=!0,menuPopoverCapable(t)&&t.setAttribute("popover","manual"),t});e.id||(e.id=(this.id||contourId("dd"))+"-menu"),t.setAttribute("aria-controls",e.id);const s=Array.from(this.querySelectorAll(":scope > .c-menu__item")),r=this.getAttribute("items");if(s.length)e.innerHTML="",s.forEach(t=>{e.appendChild(t)});else if(r){const t=parseArrayAttr(this,"items",warnBadJson);e.innerHTML="",0===t.length?renderEmpty(this,"dropdown"):t.forEach(t=>{const s=document.createElement("button");s.className="c-menu__item",s.type="button",s.setAttribute("role","menuitem"),s.textContent="string"==typeof t?t:t.label||t.title||"",e.appendChild(s)})}e.parentNode!==this&&this.appendChild(e),t.parentNode!==this&&this.insertBefore(t,e)}enhance(){if(this._wiredDropdown)return;this._wiredDropdown=!0;const t=()=>this.querySelector(".c-dropdown__trigger"),e=()=>this.querySelector(".c-dropdown__menu");this.addEventListener("click",s=>{const r=t(),i=e(),a=s.target&&s.target.closest?s.target.closest(".c-menu__item"):null;if(a&&i&&i.contains(a)&&!i.hidden){const e=Array.from(i.querySelectorAll(".c-menu__item")).indexOf(a);if(this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:e,value:a.textContent}})),setMenuOpen(this,i,t,!1,!1),r){r.setAttribute("aria-expanded","false");try{r.focus()}catch(t){}}return}if((s.target===r||r&&r.contains(s.target))&&i){const e=i.hidden;if(setMenuOpen(this,i,t,e,!1),r.setAttribute("aria-expanded",String(e)),e){i.id||(i.id=(this.id||contourId("dd"))+"-menu"),r.setAttribute("aria-controls",i.id);const t=i.querySelector(".c-menu__item");if(t)try{t.focus()}catch(t){}}}});const s=s=>{const r=e(),i=t();!r||r.hidden||this.contains(s.target)||(setMenuOpen(this,r,t,!1,!1),i&&i.setAttribute("aria-expanded","false"))};document.addEventListener("click",s),onDispose(this,()=>document.removeEventListener("click",s)),onDispose(this,()=>disarmMenuReposition(this));const r=s=>{const r=e(),i=t();if("Escape"===s.key&&r&&!r.hidden){if(s.preventDefault(),setMenuOpen(this,r,t,!1,!1),i){i.setAttribute("aria-expanded","false");try{i.focus()}catch(t){}}return}if("ArrowDown"===s.key&&s.target===i&&r&&r.hidden){s.preventDefault(),setMenuOpen(this,r,t,!0,!1),i.setAttribute("aria-expanded","true"),r.id||(r.id=(this.id||contourId("dd"))+"-menu"),i.setAttribute("aria-controls",r.id);const e=r.querySelector(".c-menu__item");if(e)try{e.focus()}catch(t){}return}if(!r||r.hidden)return;const a=Array.from(r.querySelectorAll(".c-menu__item"));if(1===s.key.length&&!s.ctrlKey&&!s.metaKey&&!s.altKey){const t=(this._ddTypeaheadQuery||"")+s.key.toLowerCase();this._ddTypeaheadQuery=t,clearTimeout(this._ddTypeaheadTimer),this._ddTypeaheadTimer=setTimeout(()=>{this._ddTypeaheadQuery=""},800);const e=a.find(e=>e.textContent.toLowerCase().startsWith(t));e&&e.focus()}navKey(s,a,{wrap:!0,enter:!1,onKey:t=>{"Enter"!==t&&" "!==t||document.activeElement.click()}})},i=s=>{const r=e();if(r&&!r.hidden&&!this.contains(s.relatedTarget)){setMenuOpen(this,r,t,!1,!1);const e=t();e&&e.setAttribute("aria-expanded","false")}};this.addEventListener("focusout",i),onDispose(this,()=>this.removeEventListener("focusout",i)),document.addEventListener("keydown",r),onDispose(this,()=>document.removeEventListener("keydown",r))}}define("contour-dropdown",ContourDropdown);class ContourSplitButton extends ContourBase{static get observed(){return["label","menu","empty"]}static get properties(){return{label:{attribute:"label"},menu:{attribute:"menu"}}}render(){this.classList.add("c-split-button");const t=this.ensure(".c-split-button__main",()=>{const t=document.createElement("button");return t.className="c-btn c-split-button__main",t.type="button",t});t.textContent=this.getAttribute("label")||labelText(this,"action","Action");const e=this.ensure(".c-split-button__toggle",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--icon c-split-button__toggle",t.type="button",t.setAttribute("aria-label",labelText(this,"more-options","More options")),t.textContent="▾",t}),s=this.ensure(".c-split-button__menu",()=>{const t=document.createElement("div");return t.className="c-menu c-split-button__menu",t.setAttribute("role","menu"),t.hidden=!0,menuPopoverCapable(t)&&t.setAttribute("popover","manual"),t});s.id||(s.id=(this.id||contourId("split"))+"-menu"),e.setAttribute("aria-haspopup","menu"),e.setAttribute("aria-controls",s.id),e.setAttribute("aria-expanded",String(!s.hidden));if(this.getAttribute("menu")){const t=parseArrayAttr(this,"menu",warnBadJson);s.innerHTML="",0===t.length?renderEmpty(this,"split-button"):t.forEach(t=>{const e=document.createElement("button");e.className="c-menu__item",e.type="button",e.setAttribute("role","menuitem"),e.textContent="string"==typeof t?t:t.label||t.title||"",s.appendChild(e)})}t.parentNode!==this&&this.appendChild(t),e.parentNode!==this&&this.appendChild(e),s.parentNode!==this&&this.appendChild(s)}enhance(){if(this._wiredSplitButton)return;this._wiredSplitButton=!0;const t=()=>this.querySelector(".c-split-button__toggle"),e=()=>this.querySelector(".c-split-button__menu"),s=()=>Array.from(e()?.querySelectorAll(".c-menu__item")||[]),r=(r,i)=>{const a=e(),n=t();if(!a)return;const o=!a.hidden;if(setMenuOpen(this,a,t,r,!0),n&&n.setAttribute("aria-expanded",String(r)),r&&i){const t=s()[0];if(t)try{t.focus()}catch(t){}}o!==r&&this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{open:r}}))};onDispose(this,()=>disarmMenuReposition(this)),this.addEventListener("click",i=>{const a=i.target&&i.target.closest?i.target.closest(".c-split-button__main"):null;if(a&&this.contains(a))return void this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0,detail:{label:a.textContent}}));const n=t();if(i.target===n||n&&n.contains(i.target)){const t=e();return void r(!!t&&t.hidden,!0)}const o=i.target&&i.target.closest?i.target.closest(".c-menu__item"):null;if(o&&this.contains(o)){const e=s().indexOf(o);r(!1,!1);try{t()?.focus()}catch(t){}this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{label:o.textContent,index:e}}))}}),this.addEventListener("keydown",i=>{const a=t(),n=e(),o=s(),l=i.target===a||a&&a.contains(i.target),c=o.indexOf(i.target);if(!l||"Enter"!==i.key&&" "!==i.key&&"ArrowDown"!==i.key){if(l&&"ArrowUp"===i.key){i.preventDefault(),r(!0,!1);const t=o[o.length-1];if(t)try{t.focus()}catch(t){}}else if(c>=0){if("ArrowDown"===i.key)i.preventDefault(),o[(c+1)%o.length]?.focus();else if("ArrowUp"===i.key)i.preventDefault(),o[(c-1+o.length)%o.length]?.focus();else if("Home"===i.key)i.preventDefault(),o[0]?.focus();else if("End"===i.key)i.preventDefault(),o[o.length-1]?.focus();else if("Escape"===i.key){i.preventDefault(),r(!1,!1);try{a?.focus()}catch(t){}}}else if("Escape"===i.key&&n&&!n.hidden){r(!1,!1);try{a?.focus()}catch(t){}}}else i.preventDefault(),r(!0,!0);if(1===i.key.length&&!i.ctrlKey&&!i.metaKey&&!i.altKey){const t=(this._sbTypeaheadQuery||"")+i.key.toLowerCase();this._sbTypeaheadQuery=t,clearTimeout(this._sbTypeaheadTimer),this._sbTypeaheadTimer=setTimeout(()=>{this._sbTypeaheadQuery=""},800);const e=o.find(e=>e.textContent.toLowerCase().startsWith(t));e&&e.focus()}});const i=t=>{const s=e();!s||s.hidden||this.contains(t.relatedTarget)||r(!1,!1)};this.addEventListener("focusout",i),onDispose(this,()=>this.removeEventListener("focusout",i));const a=t=>{const s=e();!s||s.hidden||this.contains(t.target)||r(!1,!1)};document.addEventListener("click",a),onDispose(this,()=>document.removeEventListener("click",a))}}define("contour-split-button",ContourSplitButton);class ContourMapPopup extends ContourBase{static get observed(){return["title","content","cluster-count","cluster-expanded","cluster-items","anchor"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"},"cluster-count":{attribute:"cluster-count",type:Number},"cluster-expanded":{attribute:"cluster-expanded",type:Boolean},"cluster-items":{attribute:"cluster-items"}}}render(){this.classList.add("c-map-popup"),this.setAttribute("role","dialog"),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("map-popup"));const t=this.getAttribute("title");if(t){this.ensure(".c-map-popup__title",()=>{const t=document.createElement("div");return t.className="c-map-popup__title",t}).textContent=t}const e=Array.from(this.childNodes).filter(t=>(1!==t.nodeType||!t.classList||!t.classList.contains("c-map-popup__title")&&!t.classList.contains("c-map-popup__body"))&&!(3===t.nodeType&&!t.textContent.trim())),s=this.getAttribute("content");if(e.length){const t=this.ensure(".c-map-popup__body",()=>{const t=document.createElement("div");return t.className="c-map-popup__body",t});for(const s of e)t.appendChild(s)}else if(s){this.ensure(".c-map-popup__body",()=>{const t=document.createElement("div");return t.className="c-map-popup__body",t}).textContent=s}const r=Number(this.getAttribute("cluster-count"));if(Number.isFinite(r)&&r>1){const t=this.ensure(".c-map-popup__cluster",()=>{const t=document.createElement("button");return t.className="c-map-popup__cluster c-btn c-btn--sm",t.type="button",t}),e=this.hasAttribute("cluster-expanded");t.textContent=e?"Hide locations":`${r} locations`,t.setAttribute("aria-expanded",String(e)),t.setAttribute("aria-label",e?"Hide locations":`Show ${r} locations`)}else{const t=this.querySelector(".c-map-popup__cluster");t&&t.remove()}const i=this.hasAttribute("cluster-expanded");let a=parseArrayAttr(this,"cluster-items",warnBadJson);const n=this.querySelector(".c-map-popup__cluster-list");if(i&&Array.isArray(a)&&a.length){const t=n||document.createElement("ul");t.className="c-map-popup__cluster-list",setHTML(t,""),a.forEach(e=>{const s=document.createElement("li");s.className="c-map-popup__cluster-item",s.textContent="string"==typeof e?e:e.label||e.name||JSON.stringify(e),t.appendChild(s)}),t.parentNode!==this&&this.appendChild(t)}else n&&n.remove();this.hasAttribute("aria-label")||this.setAttribute("aria-label",t||"Map popup");const o=this.getAttribute("anchor");let l=null;o&&(l=o.startsWith("#")?document.getElementById(o.slice(1)):document.querySelector(o)),this._mapPopupAnchorEl=l;const c="--map-popup-"+this.id;l&&(l.style.setProperty("anchor-name",c),this.style.setProperty("position-anchor",c))}enhance(){if(this._wiredMapPopup)return;this._wiredMapPopup=!0;const t=()=>{try{this.hidePopover()}catch(t){}this.classList.remove("is-open"),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}))},e=e=>{"Escape"===e.key&&(this.classList.contains("is-open")||this.matches(":popover-open"))&&(e.preventDefault(),t())};document.addEventListener("keydown",e),onDispose(this,()=>document.removeEventListener("keydown",e)),this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-map-popup__close"):null;s&&this.contains(s)&&t();const r=e.target&&e.target.closest?e.target.closest(".c-map-popup__cluster"):null;if(r&&this.contains(r)){const t=!this.hasAttribute("cluster-expanded");this.toggleAttribute("cluster-expanded",t),this.dispatchEvent(new CustomEvent("contour:cluster-toggle",{bubbles:!0,composed:!0,detail:{count:Number(this.getAttribute("cluster-count")),expanded:t}}))}});const s="--map-popup-"+this.id,r=()=>{const t=this._mapPopupAnchorEl;t&&(t.style.setProperty("anchor-name",s),this.style.setProperty("position-anchor",s))},i=()=>{try{const t=this.getBoundingClientRect(),e=t.right>window.innerWidth||t.left<0,s=t.bottom>window.innerHeight||t.top<0,r=e||s;this.classList.toggle("c-map-popup--flip-x",e&&!s),this.classList.toggle("c-map-popup--flip-y",s&&!e),this.classList.toggle("c-map-popup--flip-both",e&&s),r&&this.dispatchEvent(new CustomEvent("contour:map-popup-reposition",{bubbles:!0,composed:!0,detail:{anchor:this.getAttribute("anchor")||"",flippedX:e,flippedY:s,left:Math.round(t.left),top:Math.round(t.top)}}))}catch(t){}};this.addEventListener("toggle",t=>{"open"===t.newState&&requestAnimationFrame(()=>{r(),i()})});const a=()=>i();window.addEventListener("resize",a),onDispose(this,()=>{window.removeEventListener("resize",a),this._mapPopupAnchorEl&&this._mapPopupAnchorEl.style.removeProperty("anchor-name")})}}define("contour-map-popup",ContourMapPopup);class ContourAnimationControls extends ContourBase{static get observed(){return["playing","speed","progress","min","max","caption","show-thumb","show-thumb-caption","loop","step","markers"]}static get properties(){return{playing:{attribute:"playing",type:Boolean},speed:{attribute:"speed"},progress:{attribute:"progress"},min:{attribute:"min"},max:{attribute:"max"},loop:{attribute:"loop",type:Boolean},step:{attribute:"step"},markers:{attribute:"markers"}}}render(){this.classList.add("c-animation-controls"),this.setAttribute("role","toolbar"),this.setAttribute("aria-label",labelText(this,"animation-controls","Animation controls"));const t=this.ensure(".c-animation-controls__play",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-animation-controls__play",t.type="button",t});setHTML(t,this.hasAttribute("playing")?'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-pause" /></svg>':'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-play" /></svg>'),t.setAttribute("aria-label",this.hasAttribute("playing")?labelText(this,"pause","Pause"):labelText(this,"play","Play"));const e=this.getAttribute("speed")||"1x",s=this.ensure(".c-animation-controls__speed",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-animation-controls__speed",t.type="button",t});s.textContent=e,s.setAttribute("aria-label",labelText(this,"playback-speed","Playback speed")+" "+e);const r=this.ensure(".c-animation-controls__loop",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-animation-controls__loop",t.type="button",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-refresh" /></svg>'),t});r.setAttribute("aria-label",labelText(this,"loop","Loop")),r.setAttribute("aria-pressed",String(this.hasAttribute("loop"))),t.tabIndex=0,s.tabIndex=-1,r.tabIndex=-1;const i=this.ensure(".c-animation-controls__scrubber",()=>{const t=document.createElement("input");return t.className="c-range c-animation-controls__scrubber",t.type="range",t});"false"===this.getAttribute("show-thumb")?i.classList.remove("c-animation-controls__scrubber--thumb"):i.classList.add("c-animation-controls__scrubber--thumb"),i.min=this.getAttribute("min")||"0",i.max=this.getAttribute("max")||"100",i.step=this.getAttribute("step")||"1",i.value=this.getAttribute("progress")||"0";{const t=Number(i.min)||0,e=Number(i.max)||100,s=Number(i.value)||0,r=e===t?0:(s-t)/(e-t)*100;i.style.setProperty("--fill",r+"%")}const a=Number(i.min)||0,n=Number(i.max)||100,o=Number(i.value)||a;i.setAttribute("aria-valuenow",String(o)),i.setAttribute("aria-valuetext",String(Math.round(o))),i.setAttribute("aria-valuemin",String(a)),i.setAttribute("aria-valuemax",String(n));const l=this.getAttribute("caption");l?i.setAttribute("aria-label",l):i.getAttribute("aria-label")||i.setAttribute("aria-label",labelText(this,"playhead","Playhead"));const c=this.getAttribute("markers");let u=[];if(c)try{const t=JSON.parse(c);u=Array.isArray(t)?t:[]}catch(t){warnBadJson(this,"markers",t)}const d=this.querySelector("datalist.c-animation-controls__markers");if(u.length){const t=this.ensure("datalist.c-animation-controls__markers",()=>{const t=document.createElement("datalist");return t.className="c-animation-controls__markers",t});t.id||(t.id=this._animMarkersId||(this._animMarkersId=contourId("anim-markers"))),setHTML(t,""),u.forEach(e=>{const s=document.createElement("option"),r="object"==typeof e&&null!==e?e.value:e;s.value=String(r),"object"==typeof e&&null!==e&&e.label&&(s.label=String(e.label)),t.appendChild(s)}),i.setAttribute("list",t.id)}else d&&d.remove(),i.removeAttribute("list");const h=this.hasAttribute("show-thumb-caption")||this.hasAttribute("show-thumb");if(l&&h){this.ensure(".c-animation-controls__caption",()=>{const t=document.createElement("span");return t.className="c-animation-controls__caption",t}).textContent=l}else{const t=this.querySelector(".c-animation-controls__caption");t&&t.remove()}this.hasAttribute("loop")&&this.setAttribute("aria-label",labelText(this,"animation-controls-loop","Animation controls, loop"))}enhance(){if(this._wiredAnimControls)return;this._wiredAnimControls=!0;const t=[.5,1,2,4],e=t=>{this._animScrubbing||this.setAttribute("progress",String(t))};this.addEventListener("pointerdown",t=>{t.target&&t.target.closest&&t.target.closest(".c-animation-controls__scrubber")&&(this._animScrubbing=!0)},{passive:!0});const s=()=>{this._animScrubbing=!1};this.addEventListener("pointerup",s,{passive:!0}),this.addEventListener("pointercancel",s,{passive:!0}),this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-animation-controls__play"):null;if(s&&this.contains(s)){const t=!this.hasAttribute("playing");return this.toggleAttribute("playing",t),void this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{playing:t}}))}const r=e.target&&e.target.closest?e.target.closest(".c-animation-controls__speed"):null;if(r&&this.contains(r)){const e=parseFloat(this.getAttribute("speed")||"1x"),s=t.indexOf(Number.isFinite(e)?e:1),r=t[(s+1)%t.length];return this.setAttribute("speed",r+"x"),void this.dispatchEvent(new CustomEvent("contour:speed-change",{bubbles:!0,composed:!0,detail:{speed:r}}))}const i=e.target&&e.target.closest?e.target.closest(".c-animation-controls__loop"):null;if(i&&this.contains(i)){const t=!this.hasAttribute("loop");this.toggleAttribute("loop",t),this.dispatchEvent(new CustomEvent("contour:loop-change",{bubbles:!0,composed:!0,detail:{loop:t}}))}}),this.addEventListener("input",t=>{const s=t.target&&t.target.closest?t.target.closest(".c-animation-controls__scrubber"):null;if(s&&this.contains(s)){const t=Number(s.value),r=Number(s.min)||0,i=Number(s.max)||100,a=i===r?0:(t-r)/(i-r)*100;s.style.setProperty("--fill",a+"%"),e(t),this.dispatchEvent(new CustomEvent("contour:seek",{bubbles:!0,composed:!0,detail:{progress:t,value:t}}))}}),this.addEventListener("change",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-animation-controls__scrubber"):null;e&&this.contains(e)&&this.setAttribute("progress",e.value)}),this.addEventListener("keydown",t=>{if(t.target&&t.target.closest&&t.target.closest(".c-animation-controls__scrubber"))return;const e=Array.from(this.querySelectorAll(".c-animation-controls__play, .c-animation-controls__speed, .c-animation-controls__loop"));e.includes(t.target)&&navKey(t,e,{wrap:!0,homeEnd:!0,onNavigate:t=>{e.forEach((e,s)=>{e.tabIndex=s===t?0:-1})},onKey:(t,e,s)=>{"Enter"!==t&&" "!==t||s.click()}})});let r=null;const i=()=>{const t=this.getAttribute("speed")||"1x",e=parseFloat(t);return Number.isFinite(e)&&e>0?e:1},a=()=>{const t=this.querySelector(".c-animation-controls__scrubber");if(!t)return;const s=Number(t.min||0),r=Number(t.max||100);let a=Number(t.value||0)+i(),n=!1;a>r&&(this.hasAttribute("loop")?a=s:(a=r,o(),n=!0)),t.value=String(a),e(a),this.dispatchEvent(new CustomEvent("contour:time-change",{bubbles:!0,composed:!0,detail:{progress:a,value:a}})),n&&(this.removeAttribute("playing"),this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{playing:!1}})))},n=()=>{r||(r=setInterval(a,100))},o=()=>{r&&(clearInterval(r),r=null)};this.hasAttribute("playing")&&n();const l=new MutationObserver(()=>{this.hasAttribute("playing")?n():o()});l.observe(this,{attributes:!0,attributeFilter:["playing"]}),onDispose(this,()=>{o(),l.disconnect()})}}define("contour-animation-controls",ContourAnimationControls);class ContourAnnotation extends ContourBase{static get observed(){return["label","x","y"]}static get properties(){return{label:{attribute:"label"},x:{attribute:"x"},y:{attribute:"y"}}}render(){this.classList.add("c-annotation"),this.setAttribute("role","note"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");const t=this.getAttribute("label");if(t&&this.setAttribute("aria-label",t),t){this.ensure(".c-annotation__label",()=>{const t=document.createElement("span");return t.className="c-annotation__label",t}).textContent=t}const e=this.getAttribute("x"),s=this.getAttribute("y");null!==e&&this.style.setProperty("--annotation-x",e),null!==s&&this.style.setProperty("--annotation-y",s)}enhance(){if(this._wiredAnnotation)return;this._wiredAnnotation=!0;const t=(t,e)=>{const s=parseFloat(t);return Number.isFinite(s)?Math.min(100,Math.max(0,s)):e},e=(t,e,s)=>{this.batch(()=>{this.setAttribute("x",t+"%"),this.setAttribute("y",e+"%")}),this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:!0,composed:!0,detail:{delta:s?1:0,key:s||"pointer",value:t+","+e}}))};let s=null;this.addEventListener("pointerdown",e=>{if(void 0!==e.button&&0!==e.button)return;const r=this.offsetParent||this.parentElement;if(!r)return;const i=r.getBoundingClientRect();s={px:e.clientX,py:e.clientY,x:t(this.getAttribute("x"),50),y:t(this.getAttribute("y"),50),w:i.width||1,h:i.height||1};try{this.setPointerCapture(e.pointerId)}catch(t){}try{this.focus()}catch(t){}e.preventDefault()}),this.addEventListener("pointermove",t=>{if(!s)return;const r=Math.round(10*(s.x+(t.clientX-s.px)/s.w*100))/10,i=Math.round(10*(s.y+(t.clientY-s.py)/s.h*100))/10;e(Math.min(100,Math.max(0,r)),Math.min(100,Math.max(0,i)))});const r=()=>{s&&(s=null,this.dispatchEvent(new CustomEvent("contour:dragend",{bubbles:!0,composed:!0,detail:{value:(this.getAttribute("x")||"")+","+(this.getAttribute("y")||"")}})))};this.addEventListener("pointerup",r),this.addEventListener("pointercancel",r),this.addEventListener("keydown",s=>{const r=s.shiftKey?10:1;let i=0,a=0;if("ArrowLeft"===s.key)i=-r;else if("ArrowRight"===s.key)i=r;else if("ArrowUp"===s.key)a=-r;else{if("ArrowDown"!==s.key)return;a=r}s.preventDefault();const n=Math.min(100,Math.max(0,t(this.getAttribute("x"),50)+i)),o=Math.min(100,Math.max(0,t(this.getAttribute("y"),50)+a));e(n,o,s.key),this.dispatchEvent(new CustomEvent("contour:dragend",{bubbles:!0,composed:!0,detail:{value:n+","+o}}))})}}define("contour-annotation",ContourAnnotation);class ContourStyleSwitcher extends ContourBase{static get observed(){return["items","value"]}static get properties(){return{items:{attribute:"items"},value:{attribute:"value"}}}render(){this.classList.add("c-style-switcher"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"style-switcher","Style switcher"));const t=this.getAttribute("items"),e=this.getAttribute("value"),s=Array.from(this.children).filter(t=>t.classList&&t.classList.contains("c-style-switcher__option"));if(t&&!s.length){Array.from(this.querySelectorAll(".c-style-switcher__option")).forEach(t=>t.remove());try{JSON.parse(t).forEach(t=>{const e="string"==typeof t?t:t.name||t.label||"",s=document.createElement("button");s.className="c-style-switcher__option c-btn c-btn--sm",s.type="button",s.textContent=e,s.dataset.value=e,this.appendChild(s)})}catch(t){warnBadJson(this,"attribute",t)}}const r=Array.from(this.querySelectorAll(".c-style-switcher__option"));let i=null;r.forEach(t=>{const s=(null!=t.dataset.value?t.dataset.value:t.textContent.trim())===e;t.classList.toggle("c-style-switcher__option--active",s),t.setAttribute("aria-pressed",String(s)),t.tabIndex=-1,s&&!i&&(i=t)}),(i||r[0])?.setAttribute("tabindex","0")}enhance(){if(this._wiredStyleSwitcher)return;this._wiredStyleSwitcher=!0;const t=t=>{const e=null!=t.dataset.value?t.dataset.value:t.textContent.trim();this.setAttribute("value",e),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e}}))};this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-style-switcher__option"):null;s&&this.contains(s)&&t(s)}),this.addEventListener("keydown",e=>{const s=Array.from(this.querySelectorAll(".c-style-switcher__option"));navKey(e,s,{onKey:e=>{if("Enter"===e||" "===e){const e=document.activeElement;e&&e.classList.contains("c-style-switcher__option")&&t(e)}}})})}}define("contour-style-switcher",ContourStyleSwitcher);class ContourStylePanel extends ContourBase{static get observed(){return["title","layers","layer","single","classification","palette","breaks","opacity","n","colors","property"]}static get properties(){return{title:{attribute:"title"},layers:{attribute:"layers"},classification:{attribute:"classification"},palette:{attribute:"palette"},breaks:{attribute:"breaks"},opacity:{attribute:"opacity"}}}render(){if(this.classList.add("c-style-panel"),!this._stylePanelDefault){this._stylePanelDefault={};for(const t of["property","classification","palette","breaks","opacity","n","colors"])this._stylePanelDefault[t]=this.getAttribute(t)}this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"style-panel","Style panel"));const t=this.getAttribute("title");if(t){this.ensure(".c-style-panel__title",()=>{const t=document.createElement("div");return t.className="c-style-panel__title",t}).textContent=t}if(this.hasAttribute("single")||!!this.getAttribute("layer")){const t=this.ensure(".c-style-panel__body",()=>{const t=document.createElement("div");return t.className="c-style-panel__body",t});setHTML(t,"");const e=contourId("style-panel"),s=e+"-property",r=e+"-policy",i=e+"-palette",a=e+"-n",n=document.createElement("label");n.textContent=labelText(this,"colour-field","Colour field"),n.setAttribute("for",s),t.appendChild(n);const o=document.createElement("input");o.type="text",o.id=s,o.className="c-style-panel__property c-input",o.setAttribute("aria-label",labelText(this,"colour-field","Colour field"));const l=this.getAttribute("property");l&&(o.value=l),t.appendChild(o);const c=document.createElement("label");c.textContent=labelText(this,"classification","Classification"),c.setAttribute("for",r),t.appendChild(c);const u=document.createElement("select");u.id=r,u.className="c-style-panel__classification c-input",u.setAttribute("aria-label",labelText(this,"classification-method","Classification method")),["equal","quantile","jenks","manual"].forEach(t=>{const e=document.createElement("option");e.value=t,e.textContent=t,u.appendChild(e)});const d=this.getAttribute("classification");d&&(u.value=d),t.appendChild(u);const h=document.createElement("label");h.textContent=labelText(this,"palette","Palette"),h.setAttribute("for",i),t.appendChild(h);const p=document.createElement("input");p.type="text",p.id=i,p.className="c-style-panel__palette c-input",p.placeholder=labelText(this,"palette","Palette"),p.setAttribute("aria-label",labelText(this,"palette","Palette"));const b=this.getAttribute("palette");b&&(p.value=b),t.appendChild(p);const m=document.createElement("label");m.textContent=labelText(this,"classes","Classes"),m.setAttribute("for",a),t.appendChild(m);const g=document.createElement("input");g.type="number",g.id=a,g.className="c-style-panel__n c-input",g.min="2",g.max="12",g.setAttribute("aria-label",labelText(this,"class-count","Class count"));const v=this.getAttribute("n");g.value=v||"5",t.appendChild(g);const _=document.createElement("input");_.type="range",_.className="c-style-panel__opacity",_.setAttribute("aria-label",labelText(this,"opacity","Opacity")),_.min="0",_.max="100";const f=this.getAttribute("opacity");_.value=null!=f?f:"100",t.appendChild(_);const y=this.getAttribute("breaks");let A=null;if(y)try{A=JSON.parse(y)}catch(t){A=y.split(",").map(t=>t.trim())}if(Array.isArray(A)&&A.length){const e=document.createElement("div");e.className="c-style-panel__breaks",A.forEach((t,s)=>{const r=document.createElement("div");r.className="break";const i=document.createElement("span");i.textContent=String(t),r.appendChild(i);const a=document.createElement("input");a.type="number",a.className="c-style-panel__breaks c-input",a.setAttribute("aria-label",labelText(this,"class-lower-bound","Class lower bound")),a.value=String(t),r.appendChild(a),e.appendChild(r)}),t.appendChild(e)}const w=this.getAttribute("colors");let E=null;if(w)try{E=JSON.parse(w)}catch(t){E=w.split(",").map(t=>t.trim())}if(Array.isArray(E)){const e=document.createElement("div");e.className="c-style-panel__colors",E.forEach((t,s)=>{const r=document.createElement("input");r.type="color",r.className="c-style-panel__color c-input",r.setAttribute("aria-label",labelText(this,"colour-for-class","Colour for class")+" "+(s+1)),r.value=t,e.appendChild(r)}),t.appendChild(e)}const x=document.createElement("div");x.className="c-style-panel__actions c-btn-group";const C=document.createElement("button");C.type="button",C.className="c-btn c-btn--primary",C.textContent=labelText(this,"apply","Apply"),C.dataset.action="apply";const S=document.createElement("button");return S.type="button",S.className="c-btn",S.textContent=labelText(this,"revert","Revert"),S.dataset.action="revert",x.appendChild(C),x.appendChild(S),void t.appendChild(x)}const e=this.getAttribute("layers"),s=this.ensure(".c-style-panel__body",()=>{const t=document.createElement("div");return t.className="c-style-panel__body",t}),r=Array.from(this.querySelectorAll(":scope > .c-style-panel__row"));let i=null;if(r.length)i=r.map(t=>({name:t.querySelector(".c-style-panel__name")?.textContent||"",color:t.querySelector(".c-style-panel__color")?.value,classification:t.querySelector(".c-style-panel__classification")?.value,palette:t.querySelector(".c-style-panel__palette")?.value,breaks:t.querySelector(".c-style-panel__breaks")?.value,opacity:t.querySelector(".c-style-panel__opacity")?.value})),r.forEach(t=>t.remove());else if(e)try{i=JSON.parse(e)}catch(t){warnBadJson(this,"layers",t),i=null}i&&(setHTML(s,""),i.forEach(t=>{const e=document.createElement("div");e.className="c-style-panel__row";const r=document.createElement("span");r.className="c-style-panel__name",r.textContent="string"==typeof t?t:t.name||t.label||"",e.appendChild(r);const i=document.createElement("input");i.type="color",i.className="c-style-panel__color",i.setAttribute("aria-label",labelText(this,"colour-for","Colour for")+" "+("string"==typeof t?t:t.name||t.label||labelText(this,"layer","layer"))),"object"==typeof t&&t.color&&(i.value=t.color),e.appendChild(i);const a=document.createElement("select");a.className="c-style-panel__classification",a.setAttribute("aria-label",labelText(this,"classification-method","Classification method")),["equal","quantile","jenks","manual"].forEach(t=>{const e=document.createElement("option");e.value=t,e.textContent=t,a.appendChild(e)}),"object"==typeof t&&t.classification&&(a.value=t.classification),e.appendChild(a);const n=document.createElement("input");n.type="text",n.className="c-style-panel__palette",n.setAttribute("aria-label",labelText(this,"palette","Palette")),n.placeholder="palette","object"==typeof t&&t.palette&&(n.value=t.palette),e.appendChild(n);const o=document.createElement("input");o.type="text",o.className="c-style-panel__breaks",o.placeholder="breaks",o.setAttribute("aria-label",labelText(this,"class-breaks","Class breaks")),"object"==typeof t&&t.breaks&&(o.value=Array.isArray(t.breaks)?t.breaks.join(","):t.breaks),e.appendChild(o);const l=document.createElement("input");l.type="range",l.className="c-style-panel__opacity",l.setAttribute("aria-label",labelText(this,"opacity","Opacity")),l.min="0",l.max="100",l.value="object"==typeof t&&null!=t.opacity?t.opacity:"100",e.appendChild(l),s.appendChild(e)}))}enhance(){this._wiredStylePanel||(this._wiredStylePanel=!0,this.addEventListener("change",t=>{const e=t.target;if(!e||!this.contains(e))return;const s=e.closest(".c-style-panel__row"),r=s&&s.querySelector(".c-style-panel__name")?.textContent||"";if(e.classList.contains("c-style-panel__color"))this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:e.value,layer:r,property:"color"},bubbles:!0,composed:!0}));else if(e.classList.contains("c-style-panel__classification"))this.dispatchEvent(new CustomEvent("contour:break-change",{detail:{value:e.value,layer:r},bubbles:!0,composed:!0}));else if(e.classList.contains("c-style-panel__opacity")){const t=r?r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""):"";this.dispatchEvent(new CustomEvent("contour:layer-opacity",{detail:{layerId:t,name:r,opacity:Number(e.value)},bubbles:!0,composed:!0}))}else e.classList.contains("c-style-panel__property")?this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:e.value,layer:r,property:"property"},bubbles:!0,composed:!0})):e.classList.contains("c-style-panel__n")&&this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:Number(e.value),layer:r,property:"n"},bubbles:!0,composed:!0}))}),this.addEventListener("input",t=>{const e=t.target;if(e&&this.contains(e)&&(e.classList.contains("c-style-panel__color")&&e.setAttribute("data-edited","true"),e.classList.contains("c-style-panel__palette")||e.classList.contains("c-style-panel__breaks"))){const t=e.closest(".c-style-panel__row"),s=t&&t.querySelector(".c-style-panel__name")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:e.value,layer:s,property:e.classList.contains("c-style-panel__palette")?"palette":"breaks"},bubbles:!0,composed:!0}))}}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest("button"):null;if(e&&this.contains(e))if("apply"===e.dataset.action){const t=this.querySelector(".c-style-panel__body"),e={applied:!0};if(t){const s=t.querySelector(".c-style-panel__property"),r=t.querySelector(".c-style-panel__classification"),i=t.querySelector(".c-style-panel__palette"),a=t.querySelector(".c-style-panel__n"),n=Array.from(t.querySelectorAll(".c-style-panel__color")).map(t=>t.value);s&&(e.property=s.value),r&&(e.classification=r.value),i&&(e.palette=i.value),a&&(e.n=Number(a.value)),n.length&&(e.colors=n)}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:e,bubbles:!0,composed:!0}))}else if("revert"===e.dataset.action){const t=this._stylePanelDefault||{};this._contourResetting=!0;try{for(const e of["property","classification","palette","breaks","opacity","n","colors"])null===t[e]||void 0===t[e]?this.removeAttribute(e):this.setAttribute(e,t[e]);this.attributeChangedCallback("__rerender__",null,"")}finally{this._contourResetting=!1}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{applied:!1},bubbles:!0,composed:!0}))}}))}}define("contour-style-panel",ContourStylePanel);class ContourPopover extends ContourBase{static get observed(){return["title","content","anchor"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"}}}render(){this.classList.add("c-popover"),this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"popover","Popover")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("popover"));const t=this.getAttribute("title");if(t){this.ensure(".c-popover__title",()=>{const t=document.createElement("div");return t.className="c-popover__title",t}).textContent=t}const e=Array.from(this.childNodes).filter(t=>(1!==t.nodeType||!t.classList||!t.classList.contains("c-popover__title")&&!t.classList.contains("c-popover__body"))&&!(3===t.nodeType&&!t.textContent.trim())),s=this.getAttribute("content");if(e.length){const t=this.ensure(".c-popover__body",()=>{const t=document.createElement("div");return t.className="c-popover__body",t});for(const s of e)t.appendChild(s)}else if(s){this.ensure(".c-popover__body",()=>{const t=document.createElement("div");return t.className="c-popover__body",t}).textContent=s}this._applyPopoverAnchor()}_applyPopoverAnchor(){const t=this.getAttribute("anchor"),e=t?t.startsWith("#")?document.getElementById(t.slice(1)):document.querySelector(t):null;if(this._popoverAnchorEl&&this._popoverAnchorEl!==e&&(this._popoverAnchorEl.style.removeProperty("anchor-name"),this._popoverAnchorEl.removeAttribute("aria-controls"),this._popoverAnchorEl.removeAttribute("aria-expanded")),this._popoverAnchorEl=e||null,e){const t="--popover-"+this.id;e.style.setProperty("anchor-name",t),this.style.setProperty("position-anchor",t),e.setAttribute("aria-controls",this.id),this._popoverAnchorDispose||(this._popoverAnchorDispose=!0,onDispose(this,()=>{this._popoverAnchorEl&&this._popoverAnchorEl.style.removeProperty("anchor-name"),this._popoverAnchorDispose=!1}))}else this.style.removeProperty("position-anchor")}_setPopoverTriggerExpanded(t){const e=this._popoverAnchorEl;e&&(e.setAttribute("aria-controls",this.id),e.setAttribute("aria-expanded",String(!!t)))}enhance(){if(this._wiredPopover)return;this._wiredPopover=!0;const t=()=>{try{this.hidePopover()}catch(t){}this.classList.remove("is-open"),wcEmitOverlay(this,"contour:close",{}),this._setPopoverTriggerExpanded(!1)},e=e=>{if(this.classList.contains("is-open")||this.matches(":popover-open")){if("Escape"===e.key)return e.preventDefault(),void t();if("Tab"===e.key){const t=Array.from(this.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(!t.length)return void e.preventDefault();const s=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===s?(e.preventDefault(),r.focus()):e.shiftKey||document.activeElement!==r||(e.preventDefault(),s.focus())}}};document.addEventListener("keydown",e),onDispose(this,()=>document.removeEventListener("keydown",e));const s=()=>{this.classList.add("is-open"),wcEmitOverlay(this,"contour:open",{});const t=this.querySelector('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(t)try{t.focus()}catch(t){}else try{this.focus()}catch(t){}this._setPopoverTriggerExpanded(!0)};this.addEventListener("beforetoggle",t=>{"open"===t.newState&&s()});const r=t=>{t.target&&t.target!==this&&this.contains(t.target)&&this.classList.add("is-parent")};this.addEventListener("contour:open",r),this.addEventListener("contour:show",r),this.addEventListener("contour:close",t=>{t.target&&t.target!==this&&this.classList.remove("is-parent")}),this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-popover__close"):null;s&&this.contains(s)&&t()})}}define("contour-popover",ContourPopover);class ContourHoverCard extends ContourBase{static get observed(){return["title","content","anchor"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"},anchor:{attribute:"anchor"}}}render(){this.classList.add("c-hover-card"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"hover-card","Hover card")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("hover-card"));const t=this.getAttribute("title");if(t){this.ensure(".c-hover-card__title",()=>{const t=document.createElement("div");return t.className="c-hover-card__title",t}).textContent=t}const e=Array.from(this.childNodes).filter(t=>(1!==t.nodeType||!t.classList||!t.classList.contains("c-hover-card__title")&&!t.classList.contains("c-hover-card__body"))&&!(3===t.nodeType&&!t.textContent.trim())),s=this.getAttribute("content");if(e.length){const t=this.ensure(".c-hover-card__body",()=>{const t=document.createElement("div");return t.className="c-hover-card__body",t});for(const s of e)t.appendChild(s)}else if(s){this.ensure(".c-hover-card__body",()=>{const t=document.createElement("div");return t.className="c-hover-card__body",t}).textContent=s}if(!this.hasAttribute("role")){const t=!!this.querySelector("a[href], button, input, select, textarea");this.setAttribute("role",t?"dialog":"tooltip")}"function"==typeof this._wireHoverAnchor&&this._wireHoverAnchor()}enhance(){if(this._wiredHoverCard)return;this._wiredHoverCard=!0;let t=null,e=null;const s="function"==typeof this.showPopover,r=()=>{t&&(clearTimeout(t),t=null),e&&(clearTimeout(e),e=null)},i=t=>{if(r(),s)try{this.showPopover(t?{source:t}:void 0)}catch(t){try{this.showPopover()}catch(t){}}else this.classList.add("is-open");this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}))},a=()=>{if(r(),s)try{this.hidePopover()}catch(t){}else this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}))},n=()=>{e&&clearTimeout(e),e=setTimeout(a,300)};this.addEventListener("mouseenter",r),this.addEventListener("mouseleave",n),this.addEventListener("focusin",r),this.addEventListener("focusout",t=>{this.contains(t.relatedTarget)||n()}),this._wireHoverAnchor=()=>{const e=this.getAttribute("anchor")||"";if(this._hoverAnchorSel===e&&this._hoverAnchorCleanup)return;if(this._hoverAnchorCleanup&&(this._hoverAnchorCleanup(),this._hoverAnchorCleanup=null),this._hoverAnchorSel=e,!e)return;const s=e.startsWith("#")?document.getElementById(e.slice(1)):document.querySelector(e);if(!s)return;s.setAttribute("popovertarget",this.id),s.setAttribute("aria-describedby",this.id);const a="--hover-card-"+this.id;s.style.setProperty("anchor-name",a),this.style.setProperty("position-anchor",a);const o=()=>{r(),t=setTimeout(()=>i(s),300)},l=()=>{n()},c=()=>i(s),u=()=>{n()},d=t=>{t&&t.preventDefault&&t.preventDefault()};s.addEventListener("mouseenter",o),s.addEventListener("mouseleave",l),s.addEventListener("focus",c),s.addEventListener("blur",u),s.addEventListener("click",d),this._hoverAnchorCleanup=()=>{s.removeEventListener("mouseenter",o),s.removeEventListener("mouseleave",l),s.removeEventListener("focus",c),s.removeEventListener("blur",u),s.removeEventListener("click",d),s.style.removeProperty("anchor-name"),s.getAttribute("aria-describedby")===this.id&&s.removeAttribute("aria-describedby")}},this._wireHoverAnchor();const o=t=>{"Escape"===t.key&&(this.classList.contains("is-open")||this.matches(":popover-open"))&&(t.preventDefault(),a())};document.addEventListener("keydown",o),onDispose(this,()=>{r(),this._hoverAnchorCleanup&&(this._hoverAnchorCleanup(),this._hoverAnchorCleanup=null),this._hoverAnchorSel=null,document.removeEventListener("keydown",o)})}}define("contour-hover-card",ContourHoverCard);class ContourContextMenu extends ContourBase{static get observed(){return["items","trigger"]}static get properties(){return{items:{attribute:"items"},trigger:{attribute:"trigger"}}}render(){this.classList.add("c-context-menu"),this.hasAttribute("role")||this.setAttribute("role","menu"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"context-menu","Context menu")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("context-menu"));const t=this.getAttribute("items");if(t)try{const e=JSON.parse(t);Array.from(this.querySelectorAll("[data-contour-generated='1']")).forEach(t=>t.remove()),e.forEach(t=>{const e=document.createElement("button");e.className="c-menu__item",e.type="button",e.setAttribute("role","menuitem"),e.dataset.contourGenerated="1",e.textContent="string"==typeof t?t:t.label||t.title||"",this.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}}enhance(){if(this._wiredContextMenu)return;this._wiredContextMenu=!0;const t=t=>{if("function"==typeof this.hidePopover)try{this.hidePopover()}catch(t){}if(this.classList.remove("is-open"),t&&this._ctxOpener&&this._ctxOpener.isConnected&&"function"==typeof this._ctxOpener.focus)try{this._ctxOpener.focus()}catch(t){}this._ctxOpener=null},e=(t,e)=>{if(this._ctxOpener=document.activeElement,"function"==typeof this.showPopover)try{this.showPopover()}catch(t){}else this.classList.add("is-open");if(Number.isFinite(t)&&Number.isFinite(e)){this.style.position="fixed",this.style.left=t+"px",this.style.top=e+"px";const s=this.getBoundingClientRect(),r=window.innerWidth||document.documentElement.clientWidth,i=window.innerHeight||document.documentElement.clientHeight,a=Math.max(8,Math.min(t,Math.max(8,r-s.width-8))),n=Math.max(8,Math.min(e,Math.max(8,i-s.height-8)));this.style.left=a+"px",this.style.top=n+"px"}const s=this.querySelector(".c-menu__item:not([disabled])");if(s&&"function"==typeof s.focus)try{s.focus()}catch(t){}},s=this.getAttribute("trigger");if(s){const t=document.querySelector(s);if(t){t.hasAttribute("aria-haspopup")||t.setAttribute("aria-haspopup","menu");const s=t=>{t.preventDefault(),e(t.clientX,t.clientY)};t.addEventListener("contextmenu",s),onDispose(this,()=>t.removeEventListener("contextmenu",s))}}this.addEventListener("contextmenu",t=>{t.preventDefault(),e(t.clientX,t.clientY)}),this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;s&&this.contains(s)&&(this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{label:s.textContent.trim()}})),t(!1))}),this.addEventListener("keydown",e=>{const s=Array.from(this.querySelectorAll(".c-menu__item"));navKey(e,s,{wrap:!0,onKey:()=>{"Enter"!==e.key&&" "!==e.key||document.activeElement.click()}}),"Escape"===e.key&&(e.preventDefault(),t(!0))})}}define("contour-context-menu",ContourContextMenu);class ContourFab extends ContourBase{static get observed(){return["label","icon"]}static get properties(){return{label:{attribute:"label"},icon:{attribute:"icon"}}}render(){this.classList.add("c-fab"),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");const t=this.getAttribute("label");t&&this.setAttribute("aria-label",t);const e=this.getAttribute("icon");if(e&&!this.querySelector("svg")){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("aria-hidden","true"),t.setAttribute("viewBox","0 0 24 24");const s=document.createElementNS("http://www.w3.org/2000/svg","use");s.setAttribute("href",e.startsWith("#")?e:"#"+e),t.appendChild(s),this.appendChild(t)}}enhance(){this._wiredFab||(this._wiredFab=!0,this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0}))}),this.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0})))}))}}define("contour-fab",ContourFab);class ContourCommandPalette extends ContourBase{static get observed(){return["open","items"]}static get properties(){return{open:{attribute:"open",type:Boolean},items:{attribute:"items"}}}attributeChangedCallback(t,e,s){super.attributeChangedCallback(t,e,s),"open"===t&&this.isConnected&&e!==s&&(null!==s?this.show():this.hide())}_recentsKey(){return"contour-command-palette:"+(this.id||"default")+":recents"}_recents(){try{const t=JSON.parse(localStorage.getItem(this._recentsKey())||"[]");return Array.isArray(t)?t:[]}catch(t){return warnBadJson(this,"recents",t),[]}}_remember(t){try{const e=this._recents().filter(e=>e!==t);e.unshift(t),localStorage.setItem(this._recentsKey(),JSON.stringify(e.slice(0,5)))}catch(t){}}_cmdRow(t,e,s){const r=document.createElement("div");return r.className="c-command-palette__item",r.setAttribute("role","option"),r.id=this.id+"-opt-"+(s?"r":"")+e,r.textContent=t,r.dataset.index=String(e),r.dataset.label=t,s&&(r.dataset.recent="true"),r}render(){this.classList.add("c-command-palette"),this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("aria-modal")||this.setAttribute("aria-modal","true"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")||this.setAttribute("aria-label",labelText(this,"command-palette","Command palette")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("cmd-palette"));const t=this.ensure(".c-command__input",()=>{const t=document.createElement("div");return t.className="c-command__input",t}),e=this.ensure(".c-command__field",()=>{const t=document.createElement("input");return t.className="c-command__field",t.type="search",t.placeholder=labelText(this,"search","Search…"),t.setAttribute("aria-label",labelText(this,"search-commands","Search commands")),t.setAttribute("role","combobox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-expanded","false"),t}),s=this.hasAttribute("open")||this.classList.contains("is-open")||"function"==typeof this.matches&&this.matches(":popover-open");e.setAttribute("aria-expanded",String(s)),t.contains(e)||t.appendChild(e);const r=this.ensure(".c-command-palette__list",()=>{const t=document.createElement("div");return t.className="c-command-palette__list",t.setAttribute("role","listbox"),t});r.hasAttribute("aria-label")||r.hasAttribute("aria-labelledby")||r.setAttribute("aria-label",labelText(this,"commands","Commands")),r.id||(r.id=this.id+"-list"),e.setAttribute("aria-controls",r.id);let i=[];const a=this.getAttribute("items");if(a)try{i=JSON.parse(a)}catch(t){warnBadJson(this,"items",t)}Array.isArray(i)||(i=[]);const n=t=>"string"==typeof t?t:t.label||t.title||"";setHTML(r,"");const o=(this._cmdQuery||"").toLowerCase().trim()?[]:this._recents().filter(t=>i.some(e=>n(e)===t));if(o.length){const t=document.createElement("div");t.className="c-command-palette__group",t.setAttribute("role","presentation"),t.textContent=labelText(this,"recent","Recent"),r.appendChild(t),o.forEach(t=>r.appendChild(this._cmdRow(t,i.findIndex(e=>n(e)===t),!0)))}let l=null;i.forEach((t,e)=>{const s="object"==typeof t&&null!==t&&t.group||null;if(s&&s!==l){const t=document.createElement("div");t.className="c-command-palette__group",t.setAttribute("role","presentation"),t.textContent=s,r.appendChild(t),l=s}r.appendChild(this._cmdRow(n(t),e,!1))}),this._cmdQuery&&(e.value=this._cmdQuery),this._cmdFilter?this._cmdFilter(this._cmdQuery||""):this._cmdSetActive&&this._cmdSetActive(this._cmdCursor||0)}show(){if(this.classList.contains("is-open")||this.matches(":popover-open"))return void(this.hasAttribute("open")||this.setAttribute("open",""));if("function"==typeof this.showPopover)try{this.showPopover()}catch(t){}this.classList.add("is-open"),modalContain(this,!0);const t=this.querySelector(".c-command__field");if(t){t.setAttribute("aria-expanded","true");try{t.focus()}catch(t){}}this.hasAttribute("open")||this.setAttribute("open","")}hide(){if(!(this.classList.contains("is-open")||this.matches(":popover-open")))return void(this.hasAttribute("open")&&this.removeAttribute("open"));if("function"==typeof this.hidePopover)try{this.hidePopover()}catch(t){}this.classList.remove("is-open"),modalContain(this,!1);const t=this.querySelector(".c-command__field");t&&t.setAttribute("aria-expanded","false"),this.hasAttribute("open")&&this.removeAttribute("open")}toggle(){this.classList.contains("is-open")||this.matches(":popover-open")?this.hide():this.show()}enhance(){if(this._cmdSetActive&&this._cmdSetActive(this._cmdCursor||0),this._wiredCmdPalette)return;this._wiredCmdPalette=!0;const t=()=>this.querySelector(".c-command__field"),e=()=>this.querySelector(".c-command-palette__list"),s=()=>Array.from(this.querySelectorAll(".c-command-palette__item")),r=()=>s().filter(t=>!t.hidden),i=e=>{const s=r();if(!s.length)return void(this._cmdCursor=0);this._cmdCursor=Math.max(0,Math.min(e,s.length-1)),s.forEach((t,e)=>t.classList.toggle("is-active",e===this._cmdCursor));const i=s[this._cmdCursor],a=t();a&&i?a.setAttribute("aria-activedescendant",i.id):a&&a.removeAttribute("aria-activedescendant")},a=t=>{const r=(t||"").toLowerCase().trim();s().forEach(t=>{const e=(t.dataset.label||t.textContent||"").toLowerCase();t.hidden=""!==r&&!e.includes(r)}),Array.from(e().querySelectorAll(".c-command-palette__group")).forEach(t=>{let e=t.nextElementSibling,s=!1;for(;e&&!e.classList.contains("c-command-palette__group");)!e.hidden&&e.classList.contains("c-command-palette__item")&&(s=!0),e=e.nextElementSibling;t.hidden=!s});let a=e().querySelector(".c-command-palette__empty");s().some(t=>!t.hidden)?a&&(a.hidden=!0):(a||(a=document.createElement("div"),a.className="c-command-palette__empty",a.setAttribute("role","status"),e().appendChild(a)),a.textContent=labelText(this,"no-matches","No matches"),a.hidden=!1),i(0)},n=t=>{if(!t)return;const e={index:Number(t.dataset.index),label:t.dataset.label||t.textContent};this.value=e,this._remember(e.label),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:e})),this.hide()};this._cmdSetActive=i,this._cmdFilter=a,this.addEventListener("input",e=>{const s=t();s&&e.target===s&&(this._cmdQuery=s.value,a(s.value))}),this.addEventListener("keydown",e=>{const s=t();if(!s||e.target!==s)return;const a=r();if("Escape"===e.key)return e.preventDefault(),void this.hide();a.length&&("ArrowDown"===e.key?(e.preventDefault(),i(this._cmdCursor+1)):"ArrowUp"===e.key?(e.preventDefault(),i(this._cmdCursor-1)):"Home"===e.key?(e.preventDefault(),i(0)):"End"===e.key?(e.preventDefault(),i(a.length-1)):"Enter"===e.key&&(e.preventDefault(),n(a[this._cmdCursor])))}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-command-palette__item"):null;e&&this.contains(e)&&!e.hidden&&n(e)});let o=null;this.addEventListener("beforetoggle",t=>{if("open"===t.newState)o=document.activeElement,this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}));else if(modalContain(this,!1),o&&"function"==typeof o.focus){this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}));try{o.focus()}catch(t){}}}),onDispose(this,()=>{(this.classList.contains("is-open")||this.matches(":popover-open"))&&modalContain(this,!1)}),i(0)}}define("contour-command-palette",ContourCommandPalette);class ContourSideSheet extends ContourBase{static get observed(){return["open","side","title","mode","size"]}static get properties(){return{open:{attribute:"open",type:Boolean},side:{attribute:"side"},title:{attribute:"title"},mode:{attribute:"mode"},size:{attribute:"size"}}}show(){this.setAttribute("open","")}showModal(){this._sheetForceModal=!0,this.show()}close(){this.removeAttribute("open")}get open(){return this.hasAttribute("open")}set open(t){t?this.show():this.close()}_modal(){return this._sheetForceModal||"non-modal"!==(this.getAttribute("mode")||"modal")}render(){this.classList.add("c-side-sheet"),this.setAttribute("role","dialog"),this._modal()?this.setAttribute("aria-modal","true"):this.removeAttribute("aria-modal"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("title")||"Side sheet");for(const t of Array.from(this.classList))/^c-side-sheet--(start|end|sm|md|lg)$/.test(t)&&this.classList.remove(t);const t="start"===this.getAttribute("side")?"start":"end";this.classList.add("c-side-sheet--"+t);const e=this.getAttribute("size");"sm"!==e&&"md"!==e&&"lg"!==e||this.classList.add("c-side-sheet--"+e),this.hasAttribute("open")?(this.classList.add("is-open"),this.removeAttribute("inert")):(this.classList.remove("is-open"),this.setAttribute("inert",""));const s=this.getAttribute("title");if(s){this.ensure(".c-side-sheet__title",()=>{const t=document.createElement("div");return t.className="c-side-sheet__title",t}).textContent=s}}enhance(){if(this._wiredSideSheet)return;this._wiredSideSheet=!0;let t=null;const e=t=>{if("Escape"===t.key&&this.hasAttribute("open"))return t.preventDefault(),void this.close();if("Tab"===t.key&&this.hasAttribute("open")&&this._modal()){const e=Array.from(this.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")).filter(t=>!t.hasAttribute("disabled"));if(!e.length)return void t.preventDefault();const s=e[0],r=e[e.length-1];t.shiftKey&&document.activeElement===s?(t.preventDefault(),r.focus()):t.shiftKey||document.activeElement!==r||(t.preventDefault(),s.focus())}};document.addEventListener("keydown",e),onDispose(this,()=>document.removeEventListener("keydown",e)),this.addEventListener("click",t=>{t.target===this&&this.close()});let s=!1;const r=()=>{const e=this.hasAttribute("open");if(e&&!s){s=!0,t=document.activeElement,this._modal()&&modalContain(this,!0);const e=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(e)try{e.focus()}catch(t){}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}))}else if(!e&&s){if(s=!1,this._modal()&&modalContain(this,!1),this._sheetForceModal=!1,t&&"function"==typeof t.focus)try{t.focus()}catch(t){}t=null,this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}))}},i=new MutationObserver(r);i.observe(this,{attributes:!0,attributeFilter:["open"]}),this.hasAttribute("open")&&r(),onDispose(this,()=>{i.disconnect(),this.hasAttribute("open")&&this._modal()&&modalContain(this,!1)})}}define("contour-side-sheet",ContourSideSheet);class ContourTour extends ContourBase{static get observed(){return["steps","current","open","persist","id"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current"},open:{attribute:"open",type:Boolean},persist:{attribute:"persist",type:Boolean}}}_steps(){let t=[];try{const e=this.getAttribute("steps");t=e?JSON.parse(e):[]}catch(e){warnBadJson(this,"steps",e),t=[]}return Array.isArray(t)?t:[]}_current(t){const e=Number(this.getAttribute("current")||0);return Number.isFinite(e)?Math.min(Math.max(0,e),Math.max(0,t-1)):0}_storageKey(){return this.id?"contour-tour:"+this.id:(this.hasAttribute("persist")&&!this._tourWarnedNoId&&(this._tourWarnedNoId=!0,console.warn("[contour-tour] persist requires an id attribute")),null)}_completed(){if(!this.hasAttribute("persist"))return!1;const t=this._storageKey();try{return!!t&&"done"===localStorage.getItem(t)}catch(t){return!1}}_markCompleted(){if(!this.hasAttribute("persist"))return;const t=this._storageKey();try{t&&localStorage.setItem(t,"done")}catch(t){}}show(){this.setAttribute("open","")}close(){this.hasAttribute("open")&&(this.removeAttribute("open"),this._markCompleted(),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0})))}render(){this.classList.add("c-tour"),this.setAttribute("role","dialog"),this.setAttribute("aria-label",labelText(this,"tour","Tour"));const t=this._steps();this._tourInitialized||(this._tourInitialized=!0,!t.length||this.hasAttribute("open")||this._completed()||this.setAttribute("open",""));const e=this.hasAttribute("open")&&t.length>0;e?this.removeAttribute("hidden"):this.setAttribute("hidden","");const s=this._current(t.length),r=t[s]||{},i=this.ensure(".c-tour__step",()=>{const t=document.createElement("div");return t.className="c-tour__step",t});i.textContent=labelText(this,"step","Step")+" "+(s+1)+" / "+t.length;const a=this.ensure(".c-tour__tip",()=>{const t=document.createElement("div");return t.className="c-tour__tip",t});a.setAttribute("aria-live","polite"),a.textContent="string"==typeof r?r:r.text||r.title||"",i.nextSibling!==a&&this.insertBefore(i,a);const n=this.ensure(".c-tour__nav",()=>{const t=document.createElement("div");return t.className="c-tour__nav c-btn-group",t}),o=this.ensure(".c-tour__back",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-tour__back",t.type="button",t},n);o.textContent=labelText(this,"back","Back"),o.disabled=0===s;const l=this.ensure(".c-tour__next",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-tour__next",t.type="button",t},n);l.textContent=s>=t.length-1?labelText(this,"done","Done"):labelText(this,"next","Next");const c=this.ensure(".c-tour__close",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-tour__close",t.type="button",t},n);c.textContent=labelText(this,"close","Close"),n.firstChild!==o&&n.insertBefore(o,n.firstChild),o.nextSibling!==l&&n.insertBefore(l,o.nextSibling),l.nextSibling!==c&&n.insertBefore(c,l.nextSibling),this._tourTarget&&this._tourTarget.classList&&this._tourTarget.classList.remove("c-tour__target"),this._tourTarget=null;const u=e&&"object"==typeof r&&r?r.target:null;if(u){const t=document.querySelector(u);if(t&&t.classList&&(t.classList.add("c-tour__target"),this._tourTarget=t,"function"==typeof t.scrollIntoView))try{t.scrollIntoView({block:"nearest"})}catch(t){}}e&&this._positionTour(),e?this._tourFocusStep===s&&this._tourOpen||(this._tourFocusStep=s,queueMicrotask(()=>{if(!this.isConnected||!this.hasAttribute("open"))return;const t=this._tourTarget,e=t&&t.isConnected&&"function"==typeof t.focus&&!t.disabled&&t.matches("a[href], button, input, select, textarea, [tabindex]:not([tabindex='-1'])")?t:this.querySelector(".c-tour__next");if(e)try{e.focus({preventScroll:!0})}catch(t){try{e.focus()}catch(t){}}})):this._tourFocusStep=null,this._tourOpen=e}_positionTour(){const t=window.innerWidth,e=window.innerHeight,s=this.offsetWidth||280,r=this.offsetHeight||120,i=this._tourTarget;if(i&&i.getBoundingClientRect){const a=i.getBoundingClientRect();let n=a.bottom+8;n+r>e-8&&(n=Math.max(8,a.top-r-8));const o=Math.min(Math.max(8,a.left),Math.max(8,t-s-8));this.style.insetBlockStart=n+"px",this.style.insetInlineStart=o+"px",this.style.insetBlockEnd="auto",this.style.transform=""}else this.style.insetBlockStart="auto",this.style.insetBlockEnd="1rem",this.style.insetInlineStart="50%",this.style.transform="translateX(-50%)"}enhance(){if(this._wiredTour)return;this._wiredTour=!0;const t=t=>{const e=this._steps();if(!e.length||!this.hasAttribute("open"))return;const s=this._current(e.length);if("next"===t){if(s>=e.length-1)return void this.close();this.setAttribute("current",String(s+1)),this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:!0,composed:!0,detail:{direction:"next",index:s+1}}))}else{if(0===s)return;this.setAttribute("current",String(s-1)),this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:!0,composed:!0,detail:{direction:"prev",index:s-1}}))}};this._tourStep=t,this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target:null;s&&(s.closest(".c-tour__next")?t("next"):s.closest(".c-tour__back")?t("prev"):s.closest(".c-tour__close")&&this.close())});const e=e=>{if(!this.hasAttribute("open"))return;const s=e.target&&e.target.tagName;if("INPUT"===s||"TEXTAREA"===s||"SELECT"===s)return;if("Escape"===e.key)return void this.close();(this.contains(e.target)||this._tourTarget&&(e.target===this._tourTarget||this._tourTarget.contains(e.target)))&&("ArrowRight"===e.key?(e.preventDefault(),t("next")):"ArrowLeft"===e.key&&(e.preventDefault(),t("prev")))};document.addEventListener("keydown",e);const s=()=>{this.hasAttribute("open")&&this._positionTour()};window.addEventListener("scroll",s,{passive:!0,capture:!0}),window.addEventListener("resize",s,{passive:!0}),onDispose(this,()=>{document.removeEventListener("keydown",e),window.removeEventListener("scroll",s,{capture:!0}),window.removeEventListener("resize",s),this._tourTarget&&this._tourTarget.classList&&this._tourTarget.classList.remove("c-tour__target")})}}define("contour-tour",ContourTour);class ContourResponsiveContent extends ContourBase{static get observed(){return["breakpoint"]}static get properties(){return{breakpoint:{attribute:"breakpoint"}}}render(){this.classList.add("c-responsive-content");const t=this.getAttribute("breakpoint")||"md";this.dataset.breakpoint=t}}define("contour-responsive-content",ContourResponsiveContent);class ContourPaletteEditor extends ContourBase{static get observed(){return["colors"]}static get properties(){return{colors:{attribute:"colors"}}}_palette(){let t=[];try{const e=this.getAttribute("colors");t=e?JSON.parse(e):[]}catch(t){warnBadJson(this,"colors",t)}return Array.isArray(t)||(t=[]),t.map(t=>"string"==typeof t?{color:t,name:t}:{color:String(t.color||t.value||"#000000"),name:String(t.name||t.label||t.color||t.value||"color")})}_writePalette(t){this.setAttribute("colors",JSON.stringify(t.map(t=>t.name===t.color?t.color:{color:t.color,name:t.name})))}render(){this.classList.add("c-palette-editor"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"palette-editor","Palette editor"));const t=this._palette();Array.from(this.querySelectorAll(".c-palette-editor__swatch, .c-palette-editor__edit, .c-palette-editor__remove, .c-palette-editor__add, .c-palette-editor__contrast")).forEach(t=>t.remove()),t.forEach((t,e)=>{const s=document.createElement("button");s.className="c-palette-editor__swatch c-swatch"+(this._paletteSelected===e?" is-selected":""),s.type="button",s.style.background=safeColor(t.color),s.dataset.color=t.color,s.dataset.index=String(e),s.setAttribute("aria-label",t.name),s.setAttribute("aria-pressed",String(this._paletteSelected===e)),this.appendChild(s);const r=document.createElement("input");r.type="color",r.className="c-palette-editor__edit",r.value=/^#[0-9a-f]{6}$/i.test(t.color)?t.color:"#000000",r.dataset.index=String(e),r.setAttribute("aria-label",labelText(this,"edit","Edit")+" "+t.name),this.appendChild(r);const i=document.createElement("button");i.type="button",i.className="c-palette-editor__remove",i.dataset.index=String(e),i.setAttribute("aria-label",labelText(this,"remove","Remove")+" "+t.name),i.textContent="×",this.appendChild(i)});const e=document.createElement("button");e.type="button",e.className="c-palette-editor__add",e.setAttribute("aria-label",labelText(this,"add-color","Add color")),e.textContent="+",this.appendChild(e);const s=t[this._paletteSelected];if(s){const t=(t=>{const e=/^#([0-9a-f]{6})$/i.exec(t);if(!e)return null;const s=parseInt(e[1],16),r=[s>>16&255,s>>8&255,255&s].map(t=>(t/=255)<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4));return.2126*r[0]+.7152*r[1]+.0722*r[2]})(s.color),e=document.createElement("span");if(e.className="c-palette-editor__contrast",null===t)e.textContent=s.color;else{const r=(t,e)=>(Math.max(t,e)+.05)/(Math.min(t,e)+.05),i=r(t,1),a=r(t,0),n=Math.max(i,a);e.textContent=s.name+": "+i.toFixed(1)+":1 on white, "+a.toFixed(1)+":1 on black — "+(n>=4.5?"AA":"below AA")}this.appendChild(e)}}enhance(){this._wiredPaletteEditor||(this._wiredPaletteEditor=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target:null;if(!e)return;const s=e.closest(".c-palette-editor__swatch");if(s&&this.contains(s))return this._paletteSelected=Number(s.dataset.index),this.requestRender(),void this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{color:s.dataset.color}}));const r=e.closest(".c-palette-editor__remove");if(r&&this.contains(r)){const t=this._palette(),e=Number(r.dataset.index),[s]=t.splice(e,1);return this._paletteSelected>=t.length&&(this._paletteSelected=t.length-1),this._writePalette(t),void this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:!0,composed:!0,detail:{value:s?s.color:""}}))}if(e.closest(".c-palette-editor__add")){const t=this._palette(),e="#888888";t.push({color:e,name:e}),this._paletteSelected=t.length-1,this._writePalette(t),this.dispatchEvent(new CustomEvent("contour:add",{bubbles:!0,composed:!0,detail:{value:e}}))}}),this.addEventListener("change",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-palette-editor__edit"):null;if(!e||!this.contains(e))return;const s=this._palette(),r=Number(e.dataset.index);s[r]&&(s[r].color=e.value,(s[r].name===s[r].color||/^#[0-9a-f]{6}$/i.test(s[r].name))&&(s[r].name=e.value),this._writePalette(s),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{color:e.value,values:s.map(t=>t.color)}})))}),this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll(".c-palette-editor__swatch"));e.includes(t.target)&&navKey(t,e,{wrap:!0,enter:!0,onKey:(t,e,s)=>{"Enter"!==t&&" "!==t||s.click()}})}))}}define("contour-palette-editor",ContourPaletteEditor);class ContourDateRange extends ContourBase{static get observed(){return["start","end","label","time","min","max","locale","name","required","disabled"]}static get properties(){return{start:{attribute:"start"},end:{attribute:"end"},label:{attribute:"label"},time:{attribute:"time",type:Boolean},min:{attribute:"min"},max:{attribute:"max"},locale:{attribute:"locale"},name:{attribute:"name"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean}}}static get formAssociated(){return!0}render(){this.classList.add("c-date-range"),void 0===this._dateRangeDefaultStart&&(this._dateRangeDefaultStart=this.getAttribute("start"),this._dateRangeDefaultEnd=this.getAttribute("end")),this.setAttribute("role","group"),this.setAttribute("aria-label",this.getAttribute("label")||"Date range");const t=this.getAttribute("label");if(t){this.ensure(".c-date-range__label",()=>{const t=document.createElement("span");return t.className="c-date-range__label",t}).textContent=t}const e=this.ensure(".c-date-range__start",()=>{const t=document.createElement("input");return t.className="c-input c-date-range__start",t});e.type=this.hasAttribute("time")?"datetime-local":"date",e.value=this.getAttribute("start")||"",e.setAttribute("aria-label",t?t+" — start":"Start date");const s=this.ensure(".c-date-range__end",()=>{const t=document.createElement("input");return t.className="c-input c-date-range__end",t});s.type=e.type,s.value=this.getAttribute("end")||"",s.setAttribute("aria-label",t?t+" — end":"End date");const r=this.getAttribute("min"),i=this.getAttribute("max");[e,s].forEach(t=>{r?t.min=r:t.removeAttribute("min"),i?t.max=i:t.removeAttribute("max"),this.getAttribute("locale")&&(t.lang=this.getAttribute("locale")),this.hasAttribute("disabled")?t.setAttribute("disabled",""):t.removeAttribute("disabled")}),e.value&&(s.min=r&&r>e.value?r:e.value),s.value&&(e.max=i&&i<s.value?i:s.value),this.hasAttribute("required")?this.setAttribute("aria-required","true"):this.removeAttribute("aria-required"),this._internals&&this._syncFormValue()}enhance(){this._wiredDateRange||(this._wiredDateRange=!0,this.addEventListener("change",t=>{const e=t.target;if(e&&(e.classList.contains("c-date-range__start")||e.classList.contains("c-date-range__end"))){const t=this.querySelector(".c-date-range__start"),e=this.querySelector(".c-date-range__end");this.batch(()=>{t&&this.setAttribute("start",t.value),e&&this.setAttribute("end",e.value)}),this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{start:t?.value,end:e?.value}}))}}))}_syncFormValue(){if(!this._internals)return;const t=this.querySelector(".c-date-range__start")?.value||"",e=this.querySelector(".c-date-range__end")?.value||"",s=this.getAttribute("name");if(s&&(t||e)){const r=new FormData;t&&r.append(s,t),e&&r.append(s,e),this._internals.setFormValue(r)}else this._internals.setFormValue(null);const r=this.hasAttribute("required")&&(!t||!e),i=!!(t&&e&&t>e);r?this._internals.setValidity({valueMissing:!0},"Both dates are required."):i?this._internals.setValidity({customError:!0},"Start must be on or before end."):this._internals.setValidity({}),this._setCustomState("data-invalid",r||i);for(const t of this.querySelectorAll("input"))t.setAttribute("aria-invalid",String(r||i))}formResetCallback(){this._contourResetting=!0;try{null===this._dateRangeDefaultStart?this.removeAttribute("start"):this.setAttribute("start",this._dateRangeDefaultStart),null===this._dateRangeDefaultEnd?this.removeAttribute("end"):this.setAttribute("end",this._dateRangeDefaultEnd),this._syncFormValue()}finally{this._contourResetting=!1}}formStateRestoreCallback(t){if(!this._internals||null==t)return;const e=t instanceof FormData?Array.from(t.getAll(this.getAttribute("name"))).map(String):String(t).split(",");this._contourResetting=!0;try{this.setAttribute("start",e[0]||""),this.setAttribute("end",e[1]||""),this._syncFormValue()}finally{this._contourResetting=!1}}}define("contour-date-range",ContourDateRange);class ContourShortcut extends ContourBase{static get observed(){return["key","label"]}static get properties(){return{key:{attribute:"key"},label:{attribute:"label"}}}render(){this.classList.add("c-shortcut"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"Keyboard shortcut");const t=this.getAttribute("key")||"",e=this.getAttribute("label")||"";if(t){this.ensure(".c-shortcut__key",()=>{const t=document.createElement("kbd");return t.className="c-shortcut__key",t}).textContent=t}if(e){this.ensure(".c-shortcut__label",()=>{const t=document.createElement("span");return t.className="c-shortcut__label",t}).textContent=e}}enhance(){if(this._wiredShortcut)return;this._wiredShortcut=!0;const t=t=>{const e=this.getAttribute("key");e&&t.key===e&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0})))};document.addEventListener("keydown",t),onDispose(this,()=>document.removeEventListener("keydown",t))}}define("contour-shortcut",ContourShortcut);class ContourDatePicker extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","range","range-start","range-end","label","disabled","error","help","time","min","max","locale","required","name"]}static get properties(){return{value:{attribute:"value"},range:{attribute:"range",type:Boolean},rangeStart:{attribute:"range-start"},rangeEnd:{attribute:"range-end"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},time:{attribute:"time",type:Boolean},min:{attribute:"min"},max:{attribute:"max"},locale:{attribute:"locale"}}}render(){this.classList.add("c-date-picker"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"date-picker","Date picker"));const t=this.getAttribute("label");if(t){this.ensure(".c-date-picker__label",()=>{const t=document.createElement("label");return t.className="c-date-picker__label",t}).textContent=t}const e=this.keepNode(this.ensure(".c-date-picker__input",()=>{const t=document.createElement("input");return t.className="c-input c-date-picker__input",t})),s=this.hasAttribute("range"),r=this.hasAttribute("time")?"datetime-local":"date",i=(t,e,s)=>{t.type=r;const i=e||"";document.activeElement!==t&&t.value!==i&&(t.value=i),t.setAttribute("aria-label",s),this.hasAttribute("min")?t.min=this.getAttribute("min"):t.removeAttribute("min"),this.hasAttribute("max")?t.max=this.getAttribute("max"):t.removeAttribute("max"),this.hasAttribute("locale")?t.lang=this.getAttribute("locale"):t.removeAttribute("lang"),this.hasAttribute("disabled")?t.setAttribute("disabled",""):t.removeAttribute("disabled")};i(e,s?this.getAttribute("range-start"):this.getAttribute("value"),s?"Start date":t||"Date");let a=this.querySelector(".c-date-picker__end");s?(a=this.keepNode(a||document.createElement("input")),a.className="c-input c-date-picker__input c-date-picker__end",i(a,this.getAttribute("range-end"),"End date"),a.parentNode!==this&&this.appendChild(a)):a&&a.remove();const n=this.getAttribute("min"),o=this.getAttribute("max"),l=t=>{if(!n&&!o)return;const e=t.value;if(!e)return;let s=e;n&&s<n&&(s=n),o&&s>o&&(s=o),s!==e&&document.activeElement!==t&&(t.value=s)};l(e),a&&l(a),this.hasAttribute("disabled")?this.classList.add("is-disabled"):this.classList.remove("is-disabled");const c=this.getAttribute("error"),u=this.getAttribute("help");let d=this.querySelector(".c-date-picker__message");c||u?(d||(d=document.createElement("div"),d.className="c-date-picker__message",d.id||(d.id=contourId("c-date-picker-message")),this.appendChild(d)),d.textContent=c||u||"",d.classList.toggle("c-date-picker__message--error",!!c)):d&&d.remove(),c?this.classList.add("is-error"):this.classList.remove("is-error");let h=!!c;this.hasAttribute("range")&&(h=h||this._validateRange());const p=d?d.id:"",b=t=>{h?t.setAttribute("aria-invalid","true"):t.removeAttribute("aria-invalid"),p?t.setAttribute("aria-describedby",p):t.removeAttribute("aria-describedby")};b(e);const m=this.querySelector(".c-date-picker__end");m&&b(m);this.keepNode(this.ensure(".c-date-picker__calendar-toggle",()=>{const t=document.createElement("button");t.className="c-btn c-btn--sm c-date-picker__calendar-toggle",t.type="button",t.setAttribute("aria-label",labelText(this,"open-calendar","Open calendar")),t.setAttribute("aria-expanded","false");const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true");const s=document.createElementNS("http://www.w3.org/2000/svg","use");return s.setAttribute("href","#i-chevron-down"),e.appendChild(s),t.appendChild(e),t}));let g=this.querySelector(".c-date-picker__calendar");g||(g=document.createElement("div"),g.className="c-date-picker__calendar",g.setAttribute("hidden",""),g.setAttribute("role","dialog"),g.setAttribute("aria-label",labelText(this,"calendar","Calendar")),this.appendChild(g)),this.keepNode(g),this._internals&&this._syncFormValue()}_renderCalendar(){const t=this.querySelector(".c-date-picker__calendar");if(!t)return;const e=this.querySelector(".c-date-picker__input"),s=e&&e.value?(t=>{const e=/^(\d{4})-(\d{2})-(\d{2})/.exec(t||"");return e?new Date(Number(e[1]),Number(e[2])-1,Number(e[3])):new Date})(e.value):new Date,r=this._calMonth||new Date(s.getFullYear(),s.getMonth(),1);this._calMonth=r;const i=r.getFullYear(),a=r.getMonth(),n=this.getAttribute("locale")||void 0,o=this._datePickerFirstDayOfWeek(n),l=(new Date(i,a,1).getDay()-o+7)%7,c=new Date(i,a+1,0).getDate();setHTML(t,"");const u=document.createElement("div");u.className="c-date-picker__calendar-header";const d=document.createElement("button");d.type="button",d.className="c-btn c-btn--sm c-btn--icon",setHTML(d,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-left" /></svg>'),d.setAttribute("aria-label",labelText(this,"previous-month","Previous month"));const h=document.createElement("span");h.className="c-date-picker__calendar-title",h.textContent=r.toLocaleString(this.getAttribute("locale")||void 0,{month:"long",year:"numeric"});const p=document.createElement("button");p.type="button",p.className="c-btn c-btn--sm c-btn--icon",setHTML(p,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>'),p.setAttribute("aria-label",labelText(this,"next-month","Next month")),u.appendChild(d),u.appendChild(h),u.appendChild(p),t.appendChild(u);const b=document.createElement("div");b.className="c-date-picker__calendar-grid",b.setAttribute("role","grid"),b.setAttribute("aria-label",h.textContent);const m=()=>{const t=document.createElement("div");return t.className="c-date-picker__calendar-row",t.setAttribute("role","row"),b.appendChild(t),t};let g=m(),v=0;const _=t=>{7===v&&(g=m(),v=0),g.appendChild(t),v++},f=["Su","Mo","Tu","We","Th","Fr","Sa"],y=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];for(let t=0;t<7;t++){const e=(o+t)%7,s=document.createElement("div");s.className="c-date-picker__calendar-weekday",s.setAttribute("role","columnheader");const r=new Date(2026,0,e+1);s.setAttribute("aria-label",r.toLocaleDateString(n,{weekday:"long"})||y[e]),s.textContent=r.toLocaleDateString(n,{weekday:"short"})||f[e],_(s)}for(let t=0;t<l;t++){const t=document.createElement("div");t.className="c-date-picker__calendar-day c-date-picker__calendar-day--empty",t.setAttribute("role","gridcell"),t.setAttribute("aria-hidden","true"),_(t)}const A=e?e.value:"",w=A&&A.slice(0,7)===`${i}-${String(a+1).padStart(2,"0")}`&&parseInt(A.slice(8,10),10)||1,E=this.getAttribute("min"),x=this.getAttribute("max");for(let s=1;s<=c;s++){const r=document.createElement("button");r.type="button",r.className="c-date-picker__calendar-day",r.textContent=String(s),r.setAttribute("role","gridcell"),r.setAttribute("tabindex",s===w?"0":"-1"),r.setAttribute("aria-label",new Date(i,a,s).toLocaleDateString(this.getAttribute("locale")||void 0,{weekday:"long",day:"numeric",month:"long",year:"numeric"}));const n=`${i}-${String(a+1).padStart(2,"0")}-${String(s).padStart(2,"0")}`;A&&A.startsWith(n)&&(r.classList.add("is-selected"),r.setAttribute("aria-selected","true"));const o=E&&n<E||x&&n>x;r.disabled=o,o&&r.setAttribute("aria-disabled","true"),r.setAttribute("tabindex",o?"-1":s===w?"0":"-1"),o?_(r):(r.addEventListener("click",()=>{if(!e)return;if(this.hasAttribute("range")){const t=this.querySelector(".c-date-picker__end");!1!==this._rangeStartNext?(this.setAttribute("range-start",n),this._rangeStartNext=!1):t&&(this.setAttribute("range-end",n),this._rangeStartNext=!0)}else this.setAttribute("value",n);t.setAttribute("hidden","");const s=this.querySelector(".c-date-picker__calendar-toggle");s&&s.setAttribute("aria-expanded","false"),this._validateRange(),this._internals&&this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:this.getAttribute("value")}}))}),_(r))}t.appendChild(b),d.addEventListener("click",()=>{this._calMonth=new Date(i,a-1,1),this._renderCalendar()}),p.addEventListener("click",()=>{this._calMonth=new Date(i,a+1,1),this._renderCalendar()}),this._internals&&this._syncFormValue()}_syncFormValue(){if(!this._internals)return;const t=this.querySelector(".c-date-picker__input"),e=this.querySelector(".c-date-picker__end");if(this.hasAttribute("range")&&e){const s=t?t.value:"",r=e.value||"",i=this.getAttribute("name");if(i&&(s||r)){const t=new FormData;s&&t.append(i,s),r&&t.append(i,r),this._internals.setFormValue(t)}else this._internals.setFormValue(null)}else this._internals.setFormValue(t&&t.value?t.value:null);this._syncValidity(this.hasAttribute("required")&&!(t&&t.value))}formResetCallback(){const t=()=>{const t=this.querySelector(".c-date-picker__input"),e=this.querySelector(".c-date-picker__end");t&&(t.value=this.getAttribute("range-start")||this.getAttribute("value")||""),e&&(e.value=this.getAttribute("range-end")||""),this._syncFormValue()};t(),"function"==typeof queueMicrotask&&queueMicrotask(t)}_datePickerFirstDayOfWeek(t){return["en-US","en-CA","en-PH","ja-JP","ko-KR","th-TH","ar-SA","he-IL"].includes(String(t||"").toLowerCase())?0:1}_validateRange(){if(!this.hasAttribute("range"))return!1;const t=this.querySelector(".c-date-picker__input"),e=this.querySelector(".c-date-picker__end");if(!t||!e)return!1;const s=!!t.value&&!!e.value&&t.value>e.value;return this.getAttribute("error")||(s?(t.setAttribute("aria-invalid","true"),e.setAttribute("aria-invalid","true")):(t.removeAttribute("aria-invalid"),e.removeAttribute("aria-invalid"))),s}enhance(){if(this._wiredDatePicker)return;this._wiredDatePicker=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()}),this.addEventListener("change",t=>{const e=t.target;if(e&&e.classList.contains("c-date-picker__input")){const t=this.querySelector(".c-date-picker__end"),s=t?{start:this.querySelector(".c-date-picker__input").value,end:t.value}:{value:e.value};this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:s}))}});const t=()=>{const t=this.querySelector(".c-date-picker__calendar"),e=this.querySelector(".c-date-picker__calendar-toggle");if(!t)return;t.hasAttribute("hidden")?(t.removeAttribute("hidden"),e&&e.setAttribute("aria-expanded","true"),this._renderCalendar()):(t.setAttribute("hidden",""),e&&e.setAttribute("aria-expanded","false"))};this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-date-picker__calendar-toggle"):null;s&&this.contains(s)&&(e.preventDefault(),t());const r=this.querySelector(".c-date-picker__calendar");if(r&&!r.hasAttribute("hidden")&&!r.contains(e.target)&&!s){r.setAttribute("hidden","");const t=this.querySelector(".c-date-picker__calendar-toggle");t&&t.setAttribute("aria-expanded","false")}}),this.addEventListener("keydown",t=>{const e=this.querySelector(".c-date-picker__calendar");if(!e||e.hasAttribute("hidden"))return;if("Escape"===t.key){t.preventDefault(),e.setAttribute("hidden","");const s=this.querySelector(".c-date-picker__calendar-toggle");return void(s&&(s.setAttribute("aria-expanded","false"),s.focus()))}const s=Array.from(e.querySelectorAll('[role="gridcell"]:not([aria-hidden="true"])')),r=s.indexOf(document.activeElement);if(r<0)return;if("PageUp"===t.key||"PageDown"===t.key){t.preventDefault();const e=this.querySelector("PageUp"===t.key?".c-date-picker__calendar-header button:first-child":".c-date-picker__calendar-header button:last-child");return void(e&&e.click())}let i=-1;if("ArrowRight"===t.key)i=r+1;else if("ArrowLeft"===t.key)i=r-1;else if("ArrowDown"===t.key)i=r+7;else if("ArrowUp"===t.key)i=r-7;else if("Home"===t.key)i=0;else{if("End"!==t.key)return;i=s.length-1}t.preventDefault(),i<0||i>=s.length||(s.forEach((t,e)=>t.setAttribute("tabindex",e===i?"0":"-1")),s[i].focus())})}}define("contour-date-picker",ContourDatePicker);class ContourRating extends ContourBase{static get observed(){return["value","max","color","readonly","disabled","name"]}static get properties(){return{value:{attribute:"value",type:Number},max:{attribute:"max",type:Number},color:{attribute:"color"},readonly:{attribute:"readonly",type:Boolean},disabled:{attribute:"disabled",type:Boolean},name:{attribute:"name"}}}static get formAssociated(){return!0}render(){this.classList.add("c-rating"),this.hasAttribute("role")||this.setAttribute("role","radiogroup"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"rating","Rating"));const t=parseInt(this.getAttribute("max")||"5",10)||5,e=parseInt(this.getAttribute("value")||"0",10)||0,s=this.getAttribute("color"),r=flagOn(this,"readonly"),i=flagOn(this,"disabled");Array.from(this.querySelectorAll(".c-rating__star")).forEach(t=>t.remove());const a=e>=1&&e<=t?e:1;for(let n=1;n<=t;n++){const t=document.createElement("button");if(t.className="c-rating__star"+(n<=e?" c-rating__star--filled":""),t.type="button",t.setAttribute("role","radio"),t.setAttribute("aria-checked",String(n===e)),t.setAttribute("aria-label",n+(1===n?" star":" stars")),t.setAttribute("tabindex",String(n===a?0:-1)),(r||i)&&(t.setAttribute("aria-disabled","true"),t.disabled=!0,t.tabIndex=-1),setHTML(t,'<span class="c-rating__swatch'+(n<=e?" c-rating__swatch--filled":"")+'" aria-hidden="true"></span>'),s&&n<=e){const e=t.firstChild,r=safeColor(s);e&&r&&(e.style.backgroundColor=r,e.style.borderColor=r)}t.dataset.value=String(n),t.setAttribute("aria-label",n+" star"+(n>1?"s":"")),this.appendChild(t)}this._internals&&this._syncFormValue()}_syncFormValue(){if(!this._internals)return;const t=this.getAttribute("name"),e=this.getAttribute("value");t&&e?this._internals.setFormValue(e):this._internals.setFormValue(null)}enhance(){if(this._wiredRating)return;this._wiredRating=!0;const t=()=>Array.from(this.querySelectorAll(".c-rating__star")),e=e=>{flagOn(this,"readonly")||flagOn(this,"disabled")||(t().forEach(t=>{const s=parseInt(t.dataset.value,10)===e;t.setAttribute("aria-checked",String(s)),t.setAttribute("tabindex",s?"0":"-1"),t.classList.toggle("c-rating__star--filled",parseInt(t.dataset.value,10)<=e);const r=t.querySelector(".c-rating__swatch");r&&r.classList.toggle("c-rating__swatch--filled",parseInt(t.dataset.value,10)<=e)}),this.setAttribute("value",String(e)),this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e}})))};this.addEventListener("click",t=>{const s=t.target&&t.target.closest?t.target.closest(".c-rating__star"):null;s&&this.contains(s)&&e(parseInt(s.dataset.value,10))}),this.addEventListener("keydown",s=>{const r=t();r.length&&navKey(s,r,{wrap:!1,homeEnd:!0,onNavigate:t=>{e(parseInt(r[t].dataset.value,10))},onKey:(t,s)=>{"Enter"!==t&&" "!==t||e(parseInt(r[s].dataset.value,10))}})})}}define("contour-rating",ContourRating);class ContourTimePicker extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","label","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-time-picker"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"time-picker","Time picker"));const t=this.getAttribute("label");if(t){this.ensure(".c-time-picker__label",()=>{const t=document.createElement("label");return t.className="c-time-picker__label",t}).textContent=t}const e=this.ensure(".c-time-picker__input",()=>{const t=document.createElement("input");return t.className="c-input c-time-picker__input",t.type="time",t.setAttribute("aria-label",this.getAttribute("label")||"Time picker"),t});e.value=this.getAttribute("value")||"",this.hasAttribute("disabled")?(e.setAttribute("disabled",""),this.classList.add("is-disabled")):(e.removeAttribute("disabled"),this.classList.remove("is-disabled"));const s=this.getAttribute("error"),r=this.getAttribute("help");let i=this.querySelector(".c-time-picker__message");s||r?(i||(i=document.createElement("div"),i.className="c-time-picker__message",i.id||(i.id=contourId("c-time-picker-message")),this.appendChild(i)),i.textContent=s||r||"",i.classList.toggle("c-time-picker__message--error",!!s)):i&&i.remove(),s?this.classList.add("is-error"):this.classList.remove("is-error");const a=i?i.id:"";s?e.setAttribute("aria-invalid","true"):e.removeAttribute("aria-invalid"),a?e.setAttribute("aria-describedby",a):e.removeAttribute("aria-describedby"),this._internals&&this._syncFormValue()}enhance(){this._wiredTimePicker||(this._wiredTimePicker=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()}),this.addEventListener("change",t=>{const e=t.target;e&&e.classList.contains("c-time-picker__input")&&this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e.value}}))}))}}define("contour-time-picker",ContourTimePicker);class ContourColorPicker extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","label","disabled","required","error","help","alpha","presets"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},required:{attribute:"required",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},alpha:{attribute:"alpha",type:Boolean},presets:{attribute:"presets"}}}render(){this.classList.add("c-color-picker"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"color-picker","Color picker"));const t=this.getAttribute("label");if(t){this.ensure(".c-color-picker__label",()=>{const t=document.createElement("label");return t.className="c-color-picker__label",t}).textContent=t}const e=this.ensure(".c-color-picker__input",()=>{const t=document.createElement("input");return t.className="c-color-picker__input",t.type="color",t}),s=this.getAttribute("value")||"",r=/^#?[0-9a-f]{6}([0-9a-f]{2})?$/i.test(s);if(r?(e.value=s.slice(0,7),this.removeAttribute("data-empty")):(e.value="",this.setAttribute("data-empty","")),e.hasAttribute("aria-label")||e.setAttribute("aria-label",t||"Color"),this.hasAttribute("required")?e.setAttribute("required",""):e.removeAttribute("required"),this.hasAttribute("disabled")?(e.setAttribute("disabled",""),this.classList.add("is-disabled")):(e.removeAttribute("disabled"),this.classList.remove("is-disabled")),this.hasAttribute("alpha")){const t=this.ensure(".c-color-picker__alpha",()=>{const t=document.createElement("input");return t.className="c-color-picker__alpha",t.type="range",t.min="0",t.max="1",t.step="0.01",t}),e=r&&9===s.length?parseInt(s.slice(7,9),16)/255:1;t.value=String(e),t.setAttribute("aria-label",labelText(this,"alpha","Alpha"))}else{const t=this.querySelector(".c-color-picker__alpha");t&&t.remove()}const i=this.getAttribute("presets");let a=[];if(i)try{a=JSON.parse(i)}catch(t){warnBadJson(this,"presets",t),a=[]}const n=this.querySelector(".c-color-picker__presets");if(n&&n.remove(),Array.isArray(a)&&a.length){const t=document.createElement("div");t.className="c-color-picker__presets",a.forEach(e=>{const s=document.createElement("button");s.type="button",s.className="c-color-picker__preset";const r=safeColor(e);r&&(s.style.background=r,s.dataset.color=r,s.setAttribute("aria-label",labelText(this,"preset","Preset")+" "+e),t.appendChild(s))}),this.appendChild(t)}if("undefined"!=typeof window&&"EyeDropper"in window){const t=this.ensure(".c-color-picker__eyedropper",()=>{const t=document.createElement("button");return t.className="c-color-picker__eyedropper",t.type="button",t.textContent=labelText(this,"pick","Pick"),t.setAttribute("aria-label",labelText(this,"pick-color","Pick color from screen")),t});this.hasAttribute("disabled")?t.setAttribute("disabled",""):t.removeAttribute("disabled")}else{const t=this.querySelector(".c-color-picker__eyedropper");t&&t.remove()}const o=this.getAttribute("error"),l=this.getAttribute("help");let c=this.querySelector(".c-color-picker__message");o||l?(c||(c=document.createElement("div"),c.className="c-color-picker__message",c.id||(c.id=contourId("c-color-picker-message")),this.appendChild(c)),c.textContent=o||l||"",c.classList.toggle("c-color-picker__message--error",!!o)):c&&c.remove(),o?this.classList.add("is-error"):this.classList.remove("is-error");const u=c?c.id:"";o?e.setAttribute("aria-invalid","true"):e.removeAttribute("aria-invalid"),u?e.setAttribute("aria-describedby",u):e.removeAttribute("aria-describedby"),this._internals&&this._syncFormValue()}enhance(){this._wiredColorPicker||(this._wiredColorPicker=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()}),this.addEventListener("contour:change",()=>{this._syncFormValue()}),this.addEventListener("change",t=>{const e=t.target;if(e&&e.classList.contains("c-color-picker__input")){const t=this.getAttribute("value")||"",s=9===t.length?t.slice(7,9):"",r=e.value.slice(0,7)+s;this.setAttribute("value",r),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:r}}))}if(e&&e.classList.contains("c-color-picker__alpha")){const t=(this.getAttribute("value")||"#000000").slice(0,7)+Math.round(255*parseFloat(e.value)).toString(16).padStart(2,"0");this.setAttribute("value",t),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:t}}))}}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-color-picker__preset"):null;if(e&&this.contains(e)){const t=e.dataset.color;if(t){this.setAttribute("value",t);const e=this.querySelector(".c-color-picker__input");e&&(e.value=t.slice(0,7)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:t}}))}}const s=t.target&&t.target.closest?t.target.closest(".c-color-picker__eyedropper"):null;if(s&&this.contains(s)&&"undefined"!=typeof window&&"EyeDropper"in window){t.preventDefault();(new window.EyeDropper).open().then(t=>{if(t&&t.sRGBHex){this.setAttribute("value",t.sRGBHex);const e=this.querySelector(".c-color-picker__input");e&&(e.value=t.sRGBHex),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:t.sRGBHex}}))}}).catch(()=>{})}}))}}define("contour-color-picker",ContourColorPicker);class ContourNumberField extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","min","max","step","label","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},min:{attribute:"min"},max:{attribute:"max"},step:{attribute:"step"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-number-field");const t=this.getAttribute("label");if(t){this.ensure(".c-number-field__label",()=>{const t=document.createElement("label");return t.className="c-number-field__label",t}).textContent=t}const e=this.ensure(".c-number-field__input",()=>{const t=document.createElement("input");return t.className="c-input c-number-field__input",t.type="number",t.setAttribute("role","spinbutton"),t});e.id||(e.id=contourId("nf-input"));const s=this.querySelector(".c-number-field__label");s&&s.setAttribute("for",e.id),null!==this.getAttribute("value")&&(e.value=this.getAttribute("value")),null!==this.getAttribute("min")&&(e.min=this.getAttribute("min")),null!==this.getAttribute("max")&&(e.max=this.getAttribute("max")),null!==this.getAttribute("step")&&(e.step=this.getAttribute("step"));const r=e.value;e.setAttribute("aria-valuenow",""===r?"":r),""!==e.min&&e.setAttribute("aria-valuemin",e.min),""!==e.max&&e.setAttribute("aria-valuemax",e.max),e.hasAttribute("aria-label")||e.setAttribute("aria-label",t||"Number"),this.hasAttribute("disabled")?(e.setAttribute("disabled",""),this.classList.add("is-disabled")):(e.removeAttribute("disabled"),this.classList.remove("is-disabled"));const i=this.getAttribute("error"),a=this.getAttribute("help");let n=this.querySelector(".c-number-field__message");i||a?(n||(n=document.createElement("div"),n.className="c-number-field__message",this.appendChild(n)),n.id||(n.id=contourId("nf-msg")),n.textContent=i||a||"",n.classList.toggle("c-number-field__message--error",!!i),i?n.setAttribute("role","alert"):n.removeAttribute("role"),e.setAttribute("aria-describedby",n.id)):(n&&n.remove(),e.removeAttribute("aria-describedby")),i?(this.classList.add("is-error"),e.setAttribute("aria-invalid","true")):(this.classList.remove("is-error"),e.removeAttribute("aria-invalid")),this._internals&&this._syncFormValue()}enhance(){this._wiredNumberField||(this._wiredNumberField=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()}),this.addEventListener("change",t=>{const e=t.target;e&&e.classList.contains("c-number-field__input")&&this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e.value}}))}),this.addEventListener("keydown",t=>{const e=this.querySelector(".c-number-field__input");if(!e||document.activeElement!==e)return;const s=Number(e.step)||1,r=""===e.min?-1/0:Number(e.min),i=""===e.max?1/0:Number(e.max);let a=null;"ArrowUp"===t.key?a=(Number(e.value)||0)+s:"ArrowDown"===t.key?a=(Number(e.value)||0)-s:"Home"===t.key?a=r===-1/0?0:r:"End"===t.key&&(a=i===1/0?Number(e.value)||0:i),null!==a&&(t.preventDefault(),a=Math.min(i,Math.max(r,a)),e.value=String(a),e.setAttribute("aria-valuenow",String(a)),this.setAttribute("value",String(a)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e.value}})))}))}}define("contour-number-field",ContourNumberField);class ContourFileUpload extends ContourBase{static get formAssociated(){return!0}static get observed(){return["label","accept","multiple","progress","name"]}static get properties(){return{label:{attribute:"label"},accept:{attribute:"accept"},multiple:{attribute:"multiple",type:Boolean},progress:{attribute:"progress"},name:{attribute:"name"}}}render(){this.classList.add("c-file-upload"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"File upload");const t=this.getAttribute("label")||"Drop files here or click to browse";this.ensure(".c-file-upload__dropzone",()=>{const t=document.createElement("div");return t.className="c-file-upload__dropzone",t.setAttribute("role","button"),t.tabIndex=0,t}).textContent=t;const e=this.ensure(".c-file-upload__input",()=>{const t=document.createElement("input");return t.className="c-file-upload__input",t.type="file",t.hidden=!0,t});this.keepNode(e),e.accept=this.getAttribute("accept")||"",e.multiple=this.hasAttribute("multiple");const s=this.getAttribute("progress");if(null!==s){const t=this.ensure(".c-file-upload__progress",()=>{const t=document.createElement("progress");return t.className="c-file-upload__progress",t});t.value=Number(s)||0,t.max=100}else{const t=this.querySelector(".c-file-upload__progress");t&&t.remove()}this.ensure(".c-file-upload__preview",()=>{const t=document.createElement("div");return t.className="c-file-upload__preview",t});this._internals&&this._syncFormValue()}enhance(){if(this._wiredFileUpload)return;this._wiredFileUpload=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()});const t=()=>this.querySelector(".c-file-upload__dropzone"),e=()=>this.querySelector(".c-file-upload__input"),s=()=>{const t=e();t&&t.click()},r=(t,e)=>{try{const s=new DataTransfer;Array.from(e||[]).forEach(t=>s.items.add(t)),t.files=s.files}catch(t){}};this.addEventListener("click",e=>{const r=t();(e.target===r||r&&r.contains(e.target))&&s()}),this.addEventListener("keydown",e=>{const r=t();!(e.target===r||r&&r.contains(e.target))||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),s())});const i=t=>{const e=this.querySelector(".c-file-upload__preview");e&&(this._revokeObjectUrls(),setHTML(e,""),Array.from(t||[]).forEach(t=>{const s=document.createElement("div");if(s.className="c-file-upload__preview-item",t.type&&t.type.startsWith("image/")){const e=document.createElement("img");e.className="c-file-upload__preview-thumb",e.alt=t.name,e.loading="lazy",e.decoding="async";try{const s=URL.createObjectURL(t);e.src=s,(this._objectUrls||(this._objectUrls=[])).push(s)}catch(t){}s.appendChild(e)}else{const e=document.createElement("span");e.className="c-file-upload__preview-name",e.textContent=t.name,s.appendChild(e)}e.appendChild(s)}))};this.addEventListener("change",t=>{const e=t.target;e&&e.classList.contains("c-file-upload__input")&&(i(e.files),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{files:e.files}})))}),this.addEventListener("dragover",t=>{t.preventDefault(),this.classList.add("is-dragover")}),this.addEventListener("dragleave",()=>this.classList.remove("is-dragover")),this.addEventListener("drop",t=>{t.preventDefault(),this.classList.remove("is-dragover");const s=e();if(s&&t.dataTransfer&&t.dataTransfer.files&&t.dataTransfer.files.length){const e=this.getAttribute("accept");if(e){const a=e.split(",").map(t=>t.trim().toLowerCase()),n=Array.from(t.dataTransfer.files).filter(t=>{const e=t.name.toLowerCase();return a.some(s=>s.startsWith(".")?e.endsWith(s):s.endsWith("/*")?t.type.toLowerCase().startsWith(s.slice(0,-1)):t.type.toLowerCase()===s)});if(0===n.length)return;r(s,n),i(n),this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{files:n}}))}else r(s,t.dataTransfer.files),i(t.dataTransfer.files),this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{files:t.dataTransfer.files}}))}})}disconnectedCallback(){super.disconnectedCallback(),this._revokeObjectUrls()}_revokeObjectUrls(){this._objectUrls&&(this._objectUrls.forEach(t=>{try{URL.revokeObjectURL(t)}catch(t){}}),this._objectUrls=[])}_syncFormValue(){if(!this._internals)return;const t=this.querySelector(".c-file-upload__input");if(t&&t.files&&t.files.length){const e=new FormData,s=this.getAttribute("name")||"file";Array.from(t.files).forEach(t=>e.append(s,t)),this._internals.setFormValue(e)}else this._internals.setFormValue(null)}}define("contour-file-upload",ContourFileUpload);class ContourTagsInput extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","placeholder","disabled","error","help","required","max"]}static get properties(){return{value:{attribute:"value"},placeholder:{attribute:"placeholder"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},required:{attribute:"required",type:Boolean},max:{attribute:"max"}}}render(){this.classList.add("c-tags-input"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"tags-input","Tags input"));const t=this.ensure(".c-tags-input__input",()=>{const t=document.createElement("input");return t.className="c-input c-tags-input__input",t.type="text",t.setAttribute("aria-label",labelText(this,"add-tag","Add tag")),t});t.placeholder=this.getAttribute("placeholder")||"Add tag…",this.hasAttribute("disabled")?(t.setAttribute("disabled",""),this.classList.add("is-disabled")):(t.removeAttribute("disabled"),this.classList.remove("is-disabled"));const e=this.getAttribute("error"),s=this.getAttribute("help");let r=this.querySelector(".c-tags-input__message");e||s?(r||(r=document.createElement("div"),r.className="c-tags-input__message",this.appendChild(r)),r.id||(r.id=contourId("ti-msg")),r.textContent=e||s||"",r.classList.toggle("c-tags-input__message--error",!!e),e?r.setAttribute("role","alert"):r.removeAttribute("role"),t.setAttribute("aria-describedby",r.id)):(r&&r.remove(),t.removeAttribute("aria-describedby")),e?(this.classList.add("is-error"),t.setAttribute("aria-invalid","true")):(this.classList.remove("is-error"),t.removeAttribute("aria-invalid"));const i=this.getAttribute("value");let a=[];try{a=i?JSON.parse(i):[]}catch(t){a=i?i.split(",").map(t=>t.trim()).filter(Boolean):[]}Array.from(this.querySelectorAll(".c-tags-input__tag")).forEach(t=>t.remove()),a.forEach(e=>{const s=document.createElement("span");s.className="c-tag c-tags-input__tag",s.textContent=e;const r=document.createElement("button");r.className="c-tags-input__remove",r.type="button",r.textContent="×",r.setAttribute("aria-label",labelText(this,"remove","Remove")+" "+e),r.dataset.value=e,s.appendChild(r),this.insertBefore(s,t)}),this._internals&&this._syncFormValue()}enhance(){if(this._wiredTagsInput)return;this._wiredTagsInput=!0,this._syncFormValue(),this.addEventListener("contour:add",()=>{this._syncFormValue()}),this.addEventListener("contour:remove",()=>{this._syncFormValue()});const t=t=>{let e=this.querySelector(".c-tags-input__live");e||(e=document.createElement("span"),e.className="c-tags-input__live visually-hidden",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),this.appendChild(e)),e.textContent=t},e=()=>{const t=this.getAttribute("value")||"";let e=[];try{e=JSON.parse(t)}catch(s){e=t.split(",").map(t=>t.trim()).filter(Boolean)}return Array.isArray(e)?e.map(String):[]},s=s=>{if(this.hasAttribute("disabled"))return;const r=e(),i=Number(this.getAttribute("max")),a=[],n=[];let o=!1;for(const t of s){const e=String(t).trim();if(e)if(r.includes(e))n.push(e);else{if(Number.isFinite(i)&&i>0&&r.length>=i){o=!0;break}r.push(e),a.push(e)}}if(a.length){this.setAttribute("value",JSON.stringify(r));for(const t of a)this.dispatchEvent(new CustomEvent("contour:add",{bubbles:!0,composed:!0,detail:{value:t}}))}const l=[];a.length&&l.push("Added "+a.join(", ")),n.length&&l.push(n.join(", ")+" already added"),o&&l.push("Tag limit reached ("+i+")"),l.length&&t(l.join(". "))};this.addEventListener("keydown",r=>{const i=this.querySelector(".c-tags-input__input");if(i&&!this.hasAttribute("disabled"))if("Enter"===r.key&&r.target===i){r.preventDefault();const t=i.value;i.value="",s([t])}else if("Backspace"===r.key&&r.target===i&&""===i.value){const s=e();if(s.length){const e=s.pop();this.setAttribute("value",JSON.stringify(s)),t("Removed "+e),this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:!0,composed:!0,detail:{value:e}}))}}}),this.addEventListener("input",t=>{const e=this.querySelector(".c-tags-input__input");if(e&&t.target===e&&!this.hasAttribute("disabled")&&e.value.includes(",")){const t=e.value.split(",");e.value=t.pop(),s(t)}}),this.addEventListener("paste",t=>{const e=this.querySelector(".c-tags-input__input");if(!e||t.target!==e||this.hasAttribute("disabled"))return;const r=t.clipboardData&&t.clipboardData.getData("text/plain");r&&/[,;\n]/.test(r)&&(t.preventDefault(),s(r.split(/[,;\n]+/)))}),this.addEventListener("click",s=>{const r=s.target&&s.target.closest?s.target.closest(".c-tags-input__remove"):null;if(r&&this.contains(r)&&!this.hasAttribute("disabled")){const s=r.dataset.value,i=e().filter(t=>t!==s);this.setAttribute("value",JSON.stringify(i)),t("Removed "+s),this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:!0,composed:!0,detail:{value:s}}))}})}_syncFormValue(){if(!this._internals)return;this._internals.setFormValue(this.getAttribute("value")||"[]");let t=0;try{const e=JSON.parse(this.getAttribute("value")||"[]");t=Array.isArray(e)?e.length:0}catch(e){t=(this.getAttribute("value")||"").split(",").filter(t=>t.trim()).length}this._syncValidity(this.hasAttribute("required")&&0===t)}}define("contour-tags-input",ContourTagsInput);class ContourSwatch extends ContourBase{static get observed(){return["color","selected","label"]}static get properties(){return{color:{attribute:"color"},selected:{attribute:"selected",type:Boolean},label:{attribute:"label"}}}render(){this.classList.add("c-swatch"),this.hasAttribute("role")||this.setAttribute("role","button"),"button"!==this.getAttribute("role")||this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||this.getAttribute("color")||"Swatch");const t=safeColor(this.getAttribute("color"))||"var(--color-surface-3)";if(this.style.setProperty("--swatch-color",t),this.hasAttribute("selected")?this.classList.add("is-selected"):this.classList.remove("is-selected"),"button"===this.getAttribute("role")&&this.setAttribute("aria-pressed",String(this.hasAttribute("selected"))),!this.hasAttribute("aria-label")){const e=this.getAttribute("label")||t;this.setAttribute("aria-label",e)}if(!this.querySelector("button")&&!this.querySelector("span")){const t=document.createElement("span");t.className="c-swatch__btn",t.setAttribute("aria-hidden","true"),this.appendChild(t)}}enhance(){this._wiredSwatch||(this._wiredSwatch=!0,this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{value:this.getAttribute("color")}}))}),this.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{value:this.getAttribute("color")}})))}))}}define("contour-swatch",ContourSwatch);class ContourCalendar extends ContourBase{static get observed(){return["value","month","year","range","start","end"]}static get properties(){return{value:{attribute:"value"},month:{attribute:"month"},year:{attribute:"year"},range:{attribute:"range",type:Boolean},start:{attribute:"start"},end:{attribute:"end"}}}_attrNum(t,e){const s=this.getAttribute(t),r=Number(s);return null!==s&&Number.isFinite(r)?r:e}_ym(){const t=new Date;return{year:this._attrNum("year",t.getFullYear()),month:this._attrNum("month",t.getMonth())}}render(){this.classList.add("c-calendar");const t=new Date,{year:e,month:s}=this._ym(),r=this.ensure(".c-calendar__header",()=>{const t=document.createElement("div");return t.className="c-calendar__header",t});setHTML(r,"");const i=(t,e,s)=>{const r=document.createElement("button");return r.type="button",r.className="c-btn c-btn--sm "+t,r.textContent=e,r.setAttribute("aria-label",s),r},a=i("c-calendar__prev-year","","Previous year");setHTML(a,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevrons-left" /></svg>');const n=i("c-calendar__prev","","Previous month");setHTML(n,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-left" /></svg>');const o=document.createElement("span");o.className="c-calendar__title",o.textContent=new Date(e,s,1).toLocaleString(void 0,{month:"long",year:"numeric"});const l=i("c-calendar__next","","Next month");setHTML(l,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>');const c=i("c-calendar__next-year","","Next year");setHTML(c,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevrons-right" /></svg>'),r.append(a,n,o,l,c);const u=this.ensure(".c-calendar__grid",()=>{const t=document.createElement("div");return t.className="c-calendar__grid",t.setAttribute("role","grid"),t});u.setAttribute("aria-label",o.textContent),setHTML(u,"");const d=new Date(e,s,1).getDay(),h=new Date(e,s+1,0).getDate(),p=this.hasAttribute("range"),b=this.getAttribute("value"),m=this.getAttribute("start"),g=this.getAttribute("end");let v=null,_=0;const f=()=>{v=document.createElement("div"),v.className="c-calendar__row",v.setAttribute("role","row"),u.appendChild(v),_=0},y=new Intl.DateTimeFormat(void 0,{weekday:"short"});f();for(let t=0;t<7;t++){const e=document.createElement("div");e.className="c-calendar__weekday",e.setAttribute("role","columnheader"),e.textContent=y.format(new Date(2023,0,1+t)),v.appendChild(e)}f();for(let t=0;t<d;t++){const t=document.createElement("div");t.className="c-calendar__day c-calendar__day--empty",v.appendChild(t),_++,7===_&&f()}const A=t.getFullYear()+"-"+String(t.getMonth()+1).padStart(2,"0")+"-"+String(t.getDate()).padStart(2,"0"),w=b&&b.startsWith(e+"-"+String(s+1).padStart(2,"0"))?b:A.startsWith(e+"-"+String(s+1).padStart(2,"0"))?A:e+"-"+String(s+1).padStart(2,"0")+"-01";for(let t=1;t<=h;t++){const r=document.createElement("button");r.className="c-calendar__day",r.type="button",r.setAttribute("role","gridcell"),r.textContent=String(t);const i=e+"-"+String(s+1).padStart(2,"0")+"-"+String(t).padStart(2,"0"),a=p?i===m||i===g:i===b;a&&r.classList.add("is-selected"),p&&m&&g&&i>m&&i<g&&r.classList.add("is-in-range"),r.setAttribute("aria-selected",String(a)),i===A&&r.setAttribute("aria-current","date"),r.setAttribute("tabindex",i===w?"0":"-1"),r.dataset.value=i,v.appendChild(r),_++,7===_&&f()}r.parentNode!==this&&this.insertBefore(r,u)}enhance(){if(this._wiredCalendar)return;this._wiredCalendar=!0;const t=(t,e)=>{this.batch(()=>{this.setAttribute("month",String(t)),this.setAttribute("year",String(e))}),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{month:t,year:e}}))},e=t=>{const e=this.querySelector('.c-calendar__day[data-value="'+t+'"]');if(e)try{e.focus()}catch(t){}};this.addEventListener("focusin",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-calendar__day:not(.c-calendar__day--empty)"):null;if(e&&this.contains(e)){for(const t of this.querySelectorAll(".c-calendar__day"))t.tabIndex=-1;e.tabIndex=0}}),this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target:null;if(!s)return;const{year:r,month:i}=this._ym();if(s.closest(".c-calendar__prev")){const e=new Date(r,i-1,1);return void t(e.getMonth(),e.getFullYear())}if(s.closest(".c-calendar__next")){const e=new Date(r,i+1,1);return void t(e.getMonth(),e.getFullYear())}if(s.closest(".c-calendar__prev-year"))return void t(i,r-1);if(s.closest(".c-calendar__next-year"))return void t(i,r+1);const a=s.closest(".c-calendar__day");if(a&&this.contains(a)&&a.dataset.value){const t=a.dataset.value;if(this.hasAttribute("range")){const e=this.getAttribute("start"),s=this.getAttribute("end");let r,i;!e||e&&s?(r=t,i=null):(r=t<e?t:e,i=t<e?e:t),this.batch(()=>{this.setAttribute("start",r),null===i?this.removeAttribute("end"):this.setAttribute("end",i)}),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{value:t,range:i?[r,i]:[r]}}))}else this.setAttribute("value",t),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{value:t}}))}}),this.addEventListener("keydown",s=>{const r=s.target&&s.target.closest?s.target.closest(".c-calendar__day:not(.c-calendar__day--empty)"):null;if(!r||!this.contains(r)||!r.dataset.value)return;const[i,a,n]=r.dataset.value.split("-").map(Number),{year:o,month:l}=(new Date(i,a-1,n),this._ym()),c=new Date(o,l+1,0).getDate();let u=null;if("ArrowRight"===s.key)u=new Date(i,a-1,n+1);else if("ArrowLeft"===s.key)u=new Date(i,a-1,n-1);else if("ArrowDown"===s.key)u=new Date(i,a-1,n+7);else if("ArrowUp"===s.key)u=new Date(i,a-1,n-7);else if("PageUp"===s.key)u=s.shiftKey?new Date(i-1,a-1,Math.min(n,new Date(i-1,a,0).getDate())):new Date(i,a-2,Math.min(n,new Date(i,a-1,0).getDate()));else if("PageDown"===s.key)u=s.shiftKey?new Date(i+1,a-1,Math.min(n,new Date(i+1,a,0).getDate())):new Date(i,a,Math.min(n,new Date(i,a+1,0).getDate()));else if("Home"===s.key)u=new Date(o,l,1);else{if("End"!==s.key)return;u=new Date(o,l,c)}s.preventDefault();const d=(h=u).getFullYear()+"-"+String(h.getMonth()+1).padStart(2,"0")+"-"+String(h.getDate()).padStart(2,"0");var h;u.getFullYear()===o&&u.getMonth()===l||t(u.getMonth(),u.getFullYear()),e(d)})}}define("contour-calendar",ContourCalendar);class ContourNotificationCenter extends ContourBase{static get observed(){return["count","items","color"]}static get properties(){return{count:{attribute:"count"},items:{attribute:"items"},color:{attribute:"color"}}}render(){this.classList.add("c-notification-center"),this.setAttribute("role","group");const t=this.ensure(".c-notification-center__trigger",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-notification-center__trigger",t.type="button",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-bell" /></svg><span class="c-notification-center__bullet" aria-hidden="true"></span>'),t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-label",labelText(this,"notifications","Notifications")),t}),e=this.getAttribute("color"),s=t.querySelector(".c-notification-center__bullet");s&&e&&(s.style.background=safeColor(e),s.dataset.color=e);const r=this.ensure(".c-notification-center__panel",()=>{const t=document.createElement("div");return t.className="c-notification-center__panel",t.hidden=!0,t.setAttribute("role","dialog"),t.setAttribute("aria-label",labelText(this,"notifications","Notifications")),t});r.hidden=!this._notifOpen,t.setAttribute("aria-expanded",String(!!this._notifOpen));const i=Array.from(this.querySelectorAll(":scope > .c-notification-center__item")),a=this.getAttribute("items");if(i.length){setHTML(r,"");const t=document.createElement("div");t.setAttribute("role","list"),t.setAttribute("aria-label",labelText(this,"notifications","Notifications")),this._notifAuthored||(this._notifAuthored=[]),i.forEach(e=>{t.appendChild(e),this._notifAuthored.push(e)}),r.appendChild(t)}else if(a){let t=null;try{t=JSON.parse(a)}catch(t){warnBadJson(this,"items",t)}if(setHTML(r,""),Array.isArray(t)){const e=document.createElement("div");e.setAttribute("role","list"),e.setAttribute("aria-label",labelText(this,"notifications","Notifications"));const s=this._notifShown||50;t.slice(0,s).forEach(t=>{const s=document.createElement("div");s.className="c-notification-center__item"+(t&&t.read?" is-read":""),s.setAttribute("tabindex","-1"),s.setAttribute("role","listitem"),t&&t.current&&s.setAttribute("aria-current","true"),s.dataset.read=t&&t.read?"true":"false";const r=document.createElement("span");r.className="c-notification-center__item-label",r.textContent="string"==typeof t?t:t.text||t.title||"",s.appendChild(r);const i=document.createElement("button");i.type="button",i.className="c-notification-center__archive",i.setAttribute("aria-label",labelText(this,"archive","Archive notification")),i.textContent="⤓",i.tabIndex=-1,s.appendChild(i);const a=document.createElement("button");a.type="button",a.className="c-notification-center__dismiss",a.setAttribute("aria-label",labelText(this,"dismiss","Dismiss notification")),a.textContent="×",a.tabIndex=-1,s.appendChild(a),e.appendChild(s)});const i=e.querySelector(".c-notification-center__item");if(i&&(i.tabIndex=0),r.appendChild(e),t.length){if(t.length>s){const e=document.createElement("button");e.type="button",e.className="c-btn c-btn--sm c-notification-center__more",e.textContent=labelText(this,"more","Show more")+" ("+(t.length-s)+")",r.appendChild(e)}}else{const t=document.createElement("div");t.className="c-notification-center__empty",t.textContent=labelText(this,"empty","No notifications"),r.appendChild(t)}}else{const t=document.createElement("div");t.className="c-notification-center__error",t.setAttribute("role","alert"),t.textContent=labelText(this,"error","Could not load notifications"),r.appendChild(t)}}this._syncNotifBadge()}_syncNotifBadge(){const t=this.querySelector(".c-notification-center__trigger");if(!t)return;const e=Array.from(this.querySelectorAll(".c-notification-center__item"));let s;s=this._notifInteracted||!this.hasAttribute("count")?e.filter(t=>"true"!==t.dataset.read).length:Number(this.getAttribute("count"))||0;let r=t.querySelector(".c-notification-center__badge");s>0?(r||(r=document.createElement("span"),r.className="c-notification-center__badge c-badge c-badge--dot",t.appendChild(r)),r.textContent=String(s)):r&&r.remove()}enhance(){if(this._wiredNotifCenter)return;this._wiredNotifCenter=!0;const t=t=>{"true"!==t.dataset.read&&(t.dataset.read="true",t.classList.add("is-read"),this._notifInteracted=!0,this._syncNotifBadge(),this.dispatchEvent(new CustomEvent("contour:read",{bubbles:!0,composed:!0,detail:{label:t.querySelector(".c-notification-center__item-label")?.textContent||t.textContent}})));for(const e of this.querySelectorAll(".c-notification-center__item"))e===t?e.setAttribute("aria-current","true"):e.removeAttribute("aria-current");this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{label:t.querySelector(".c-notification-center__item-label")?.textContent||t.textContent}}))},e=(t,e)=>{const s=t.querySelector(".c-notification-center__item-label")?.textContent||t.textContent;t.remove(),this._notifInteracted=!0,this._syncNotifBadge(),this.dispatchEvent(new CustomEvent("archive"===e?"contour:remove":"contour:dismiss",{bubbles:!0,composed:!0,detail:{label:s}}))};this.addEventListener("click",s=>{const r=this.querySelector(".c-notification-center__trigger"),i=this.querySelector(".c-notification-center__panel");if(r&&(s.target===r||r.contains(s.target)))return void(i&&(i.hidden=!i.hidden,this._notifOpen=!i.hidden,r.setAttribute("aria-expanded",String(!i.hidden)),this.dispatchEvent(new CustomEvent(i.hidden?"contour:close":"contour:open",{bubbles:!0,composed:!0}))));const a=s.target&&s.target.closest?s.target.closest(".c-notification-center__more"):null;if(a&&this.contains(a))return this._notifShown=(this._notifShown||50)+50,void this.requestRender();const n=s.target&&s.target.closest?s.target.closest(".c-notification-center__archive"):null;if(n&&this.contains(n)){const t=n.closest(".c-notification-center__item");return void(t&&e(t,"archive"))}const o=s.target&&s.target.closest?s.target.closest(".c-notification-center__dismiss"):null;if(o&&this.contains(o)){const t=o.closest(".c-notification-center__item");return void(t&&e(t,"dismiss"))}const l=s.target&&s.target.closest?s.target.closest(".c-notification-center__item"):null;l&&this.contains(l)&&t(l)});const s=t=>{const e=this.querySelector(".c-notification-center__panel"),s=this.querySelector(".c-notification-center__trigger");!e||e.hidden||this.contains(t.target)||(e.hidden=!0,this._notifOpen=!1,s&&s.setAttribute("aria-expanded","false"))};document.addEventListener("click",s),onDispose(this,()=>document.removeEventListener("click",s));const r=s=>{const r=this.querySelector(".c-notification-center__panel"),i=this.querySelector(".c-notification-center__trigger");if("Escape"===s.key&&r&&!r.hidden){if(r.hidden=!0,this._notifOpen=!1,i){i.setAttribute("aria-expanded","false");try{i.focus()}catch(t){}}return}if(!r||r.hidden)return;const a=Array.from(r.querySelectorAll(".c-notification-center__item"));if(a.length){if(("Enter"===s.key||" "===s.key)&&a.includes(s.target))return s.preventDefault(),void t(s.target);if(("Delete"===s.key||"Backspace"===s.key)&&a.includes(s.target)){s.preventDefault();const t=a.indexOf(s.target);e(s.target,"dismiss");const r=a[t+1]||a[t-1];if(r&&r.isConnected)try{r.focus()}catch(t){}return}navKey(s,a,{wrap:!0,onNavigate:t=>{a.forEach((e,s)=>{e.tabIndex=s===t?0:-1})}})}};document.addEventListener("keydown",r),onDispose(this,()=>document.removeEventListener("keydown",r))}}define("contour-notification-center",ContourNotificationCenter);class ContourStepper extends ContourBase{static get observed(){return["steps","current"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current"}}}render(){this.classList.add("c-stepper"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"stepper","Stepper"));const t=this.getAttribute("steps"),e=Number(this.getAttribute("current")||0),s=this.ensure(".c-stepper__list",()=>{const t=document.createElement("ol");return t.className="c-stepper__list",t});setHTML(s,"");const r=Array.from(this.querySelectorAll(":scope > .c-stepper__step"));let i=[];if(r.length)i=r.map(t=>t.textContent.trim()),this._stepperAuthored=i,r.forEach(t=>t.remove());else if(t)try{i=JSON.parse(t)}catch(t){warnBadJson(this,"steps",t),i=this._stepperAuthored||[]}else i=this._stepperAuthored||[];i.forEach((t,r)=>{const i=document.createElement("li");i.className="c-stepper__step"+(r===e?" is-current":"")+(r<e?" is-done":""),r===e&&i.setAttribute("aria-current","step"),i.setAttribute("tabindex",r===e?"0":"-1");const a=document.createElement("span");a.className="c-stepper__marker",a.setAttribute("aria-hidden","true"),r<e?setHTML(a,'<svg viewBox="0 0 24 24"><use href="#i-check" /></svg>'):a.textContent=String(r+1),i.appendChild(a);const n=document.createElement("span");n.className="c-stepper__label",n.textContent="string"==typeof t?t:t.title||t.label||"",i.appendChild(n),s.appendChild(i)});const a=this.ensure(".c-stepper__nav",()=>{const t=document.createElement("div");return t.className="c-stepper__nav c-btn-group",t}),n=this.ensure(".c-stepper__prev",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-stepper__prev",t.type="button",t});n.textContent=labelText(this,"prev","Back"),e<=0?n.setAttribute("disabled",""):n.removeAttribute("disabled");const o=this.ensure(".c-stepper__next",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-stepper__next",t.type="button",t});o.textContent=labelText(this,"next","Next"),e>=i.length-1?o.setAttribute("disabled",""):o.removeAttribute("disabled"),a.contains(n)||a.appendChild(n),a.contains(o)||a.appendChild(o),a.parentNode!==this&&this.appendChild(a)}enhance(){if(this._wiredStepper)return;this._wiredStepper=!0;const t=t=>{const e=this.querySelector(".c-stepper__list"),s=e?e.querySelectorAll(".c-stepper__step").length:0;if(!s)return;let r=Number(this.getAttribute("current")||0);r="prev"===t?Math.max(0,r-1):Math.min(s-1,r+1),this.setAttribute("current",String(r)),this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:!0,composed:!0,detail:{direction:t,index:r}}))};this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-stepper__prev"):null,r=e.target&&e.target.closest?e.target.closest(".c-stepper__next"):null;if(s&&this.contains(s))return void t("prev");if(r&&this.contains(r))return void t("next");const i=e.target&&e.target.closest?e.target.closest(".c-stepper__step"):null;if(i&&this.contains(i)){const t=Array.from(this.querySelectorAll(".c-stepper__step")).indexOf(i);t>=0&&t!==Number(this.getAttribute("current")||0)&&(this.setAttribute("current",String(t)),this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:!0,composed:!0,detail:{direction:"jump",index:t}})))}}),this.addEventListener("keydown",e=>{"ArrowLeft"===e.key?(e.preventDefault(),t("prev")):"ArrowRight"===e.key&&(e.preventDefault(),t("next"))})}}define("contour-stepper",ContourStepper);class ContourVirtualList extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","item-height","orientation","sticky"]}static get properties(){return{items:{attribute:"items"},"item-height":{attribute:"item-height"},orientation:{attribute:"orientation"},sticky:{attribute:"sticky",type:Boolean}}}_items(){const t=this.getAttribute("items");let e=[];try{e=t?JSON.parse(t):[]}catch(t){warnBadJson(this,"items",t),e=[]}return Array.isArray(e)?e:[]}_itemHeight(){const t=Number(this.getAttribute("item-height"));return Number.isFinite(t)&&t>0?t:cssLength("--virtual-list-item-height",28)}_autoHeight(){return"auto"===this.getAttribute("item-height")}render(){this.classList.add("c-virtual-list"),this.setAttribute("role","list"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"virtual-list","Virtual list"));const t=this.ensure(".c-virtual-list__scroller",()=>{const t=document.createElement("div");return t.className="c-virtual-list__scroller",t});t.setAttribute("role","presentation");const e="horizontal"===this.getAttribute("orientation");t.style.overflowX=e?"auto":"hidden",t.style.overflowY=e?"hidden":"auto";const s=this.ensure(".c-virtual-list__inner",()=>{const t=document.createElement("div");return t.className="c-virtual-list__inner",t.style.position="relative",t});s.parentNode!==t&&t.appendChild(s),this._renderWindow(t,s,e?t.scrollLeft||0:t.scrollTop||0)}_measureHeights(t,e){return Array.from(t.querySelectorAll(".c-virtual-list__item")).map(t=>e?t.getBoundingClientRect().width||this._itemHeight():t.getBoundingClientRect().height||this._itemHeight())}_renderWindow(t,e,s){const r=this._items(),i=this._itemHeight(),a="horizontal"===this.getAttribute("orientation"),n=this._autoHeight(),o=a?t.clientWidth||320:t.clientHeight||320,l=r.length;this._vlItemCount!==l&&(this._vlHeights=null,this._vlItemCount=l);let c=n?this._vlHeights:null,u=null;if(n&&c&&c.length===l){u=[0];for(let t=0;t<l;t++)u.push(u[t]+(c[t]||this._itemHeight()))}const d=n&&!u?l:n?Math.ceil(o/this._itemHeight())+6:Math.ceil(o/i)+4;let h=0;if(n&&u){let t=0,e=l;for(;t<e;){const r=t+e>>1;u[r]<(s||0)?t=r+1:e=r}h=Math.max(0,t-3)}else n||(h=Math.floor((s||0)/i));h<0&&(h=0);const p=Math.min(l,h+d);h>Math.max(0,l-d)&&!n&&(h=Math.max(0,l-d));const b=n&&u?u[h]:n?0:h*i,m=n&&u?Math.max(0,u[l]-u[p]):n?0:Math.max(0,(l-p)*i);e.style.display=a?"flex":"block",e.style.width=a&&n?"max-content":"",e.style.height=a||n?"":l*i+"px",setHTML(e,"");const g=document.createElement("div");g.className="c-virtual-list__spacer c-virtual-list__spacer--top",g.style[a?"width":"height"]=b+"px",e.appendChild(g);for(let t=h;t<p;t++){const s=document.createElement("div");s.className="c-virtual-list__item",s.setAttribute("role","listitem"),s.setAttribute("aria-setsize",String(l)),s.setAttribute("aria-posinset",String(t+1)),s.setAttribute("tabindex",0===t?"0":"-1"),s.textContent="string"==typeof r[t]?r[t]:r[t].label||r[t].text||JSON.stringify(r[t]),this.hasAttribute("sticky")&&r[t]&&r[t].sticky&&(s.style.position="sticky",s.style.insetBlockStart="0",s.style.zIndex="1"),a&&!n&&(s.style.flex="0 0 "+i+"px"),s.dataset.index=String(t),e.appendChild(s)}const v=document.createElement("div");v.className="c-virtual-list__spacer c-virtual-list__spacer--bottom",v.style[a?"width":"height"]=m+"px",e.appendChild(v),a&&!n&&(e.style.width=l*i+"px"),n&&!this._vlHeights&&requestAnimationFrame(()=>{this._vlHeights=this._measureHeights(e,a);const s=t,r=e;s&&r&&this._renderWindow(s,r,s.scrollTop||0)})}enhance(){if(this._wiredVirtualList)return;this._wiredVirtualList=!0;const t=()=>this.querySelector(".c-virtual-list__scroller"),e=()=>this.querySelector(".c-virtual-list__inner");let s=0;const r=()=>{s||(s=requestAnimationFrame(()=>{s=0;const r=t(),i=e();r&&i&&this._renderWindow(r,i,"horizontal"===this.getAttribute("orientation")?r.scrollLeft:r.scrollTop)}))};this.addEventListener("scroll",r,{passive:!0,capture:!0}),onDispose(this,()=>{this.removeEventListener("scroll",r,{capture:!0}),s&&cancelAnimationFrame(s)}),this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll(".c-virtual-list__item"));if(!e.length)return;const s="horizontal"===this.getAttribute("orientation"),r=s?"ArrowRight":"ArrowDown",i=s?"ArrowLeft":"ArrowUp",a=document.activeElement,n=e.indexOf(a),o=this.querySelector(".c-virtual-list__scroller"),l=this.querySelector(".c-virtual-list__inner");if(t.key===r&&n===e.length-1||t.key===i&&0===n&&Number(a&&a.dataset.index)>0){if(t.preventDefault(),o&&l){const e=(t.key===r?1:-1)*this._itemHeight();s?o.scrollLeft+=e:o.scrollTop+=e,this._renderWindow(o,l,s?o.scrollLeft:o.scrollTop);const i=Number(a&&a.dataset.index)+(t.key===r?1:-1);requestAnimationFrame(()=>{const t=this.querySelector(`.c-virtual-list__item[data-index="${i}"]`),e=Array.from(this.querySelectorAll(".c-virtual-list__item"));if(t){e.forEach(t=>t.setAttribute("tabindex","-1")),t.setAttribute("tabindex","0");try{t.focus()}catch(t){}}})}}else navKey(t,e,{wrap:!1,homeEnd:!0,onNavigate:t=>e.forEach((e,s)=>e.setAttribute("tabindex",s===t?"0":"-1")),onKey:()=>{if("Enter"===t.key||" "===t.key){const t=Number(document.activeElement.dataset.index);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:t,value:document.activeElement.textContent}}))}}})}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-virtual-list__item"):null;if(!e||!this.contains(e))return;const s=Number(e.dataset.index);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:s,value:e.textContent}}))})}}define("contour-virtual-list",ContourVirtualList);class ContourSortableList extends ContourBase{static get observed(){return["items","order"]}static get properties(){return{items:{attribute:"items"},order:{attribute:"order"}}}render(){this.classList.add("c-sortable-list");const t=this.ensure(".c-sortable-list__list",()=>{const t=document.createElement("ul");return t.className="c-sortable-list__list",t}),e=this.getAttribute("items");let s=[];try{s=e?JSON.parse(e):[]}catch(t){s=[]}Array.isArray(s)||(s=[]);let r=Array.from({length:s.length},(t,e)=>e);const i=this.getAttribute("order");if(i)try{const t=JSON.parse(i);Array.isArray(t)&&t.length===s.length&&t.every(t=>Number.isInteger(t)&&t>=0&&t<s.length)&&(r=t.slice(),s=t.map(t=>s[t]))}catch(t){}this._sortableSourceOrder=r,this._sortableItems=s,setHTML(t,""),s.forEach((e,s)=>{const r=document.createElement("li");r.className="c-sortable-list__item",r.setAttribute("draggable","true"),r.dataset.index=String(s);const i="string"==typeof e?e:e.label||e.text||"",a=document.createElement("span");a.className="c-sortable-list__handle",a.textContent="⋮⋮",a.setAttribute("role","button"),a.setAttribute("aria-label",labelText(this,"reorder","Reorder")+" "+(i||String(s+1))),a.setAttribute("data-contour-preserve-key",i||String(s)),a.tabIndex=0,r.appendChild(a);const n=document.createElement("span");n.className="c-sortable-list__label",n.textContent=i,r.appendChild(n),t.appendChild(r)})}enhance(){if(this._wiredSortableList)return;this._wiredSortableList=!0;const t=()=>this.querySelector(".c-sortable-list__list"),e=t=>{let e=this.querySelector(".c-sortable-list__live");e||(e=document.createElement("span"),e.className="c-sortable-list__live visually-hidden",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),this.appendChild(e)),e.textContent=t},s=e=>Array.from(t().children).indexOf(e),r=(t,e)=>{const s=(this._sortableItems||[]).length,r=Array.isArray(this._sortableSourceOrder)&&this._sortableSourceOrder.length===s?this._sortableSourceOrder.slice():Array.from({length:s},(t,e)=>e),[i]=r.splice(t,1);r.splice(e,0,i),this.setAttribute("order",JSON.stringify(r))};let i=null;this.addEventListener("dragstart",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-sortable-list__item"):null;if(e&&this.contains(e)){if(i=s(e),t.dataTransfer){t.dataTransfer.effectAllowed="move";try{t.dataTransfer.setData("text/plain",String(i))}catch(t){}}e.classList.add("is-dragging")}}),this.addEventListener("dragover",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-sortable-list__item"):null;e&&this.contains(e)&&null!==i&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"))}),this.addEventListener("drop",a=>{const n=a.target&&a.target.closest?a.target.closest(".c-sortable-list__item"):null;if(!n||!this.contains(n)||null===i)return;a.preventDefault();const o=s(n),l=t(),c=l.children[i];if(c&&i!==o){i<o?l.insertBefore(c,l.children[o+1]||null):l.insertBefore(c,l.children[o]);const t=c.querySelector(".c-sortable-list__label");e((t?t.textContent:"Item")+" moved to position "+(o+1));const s=i;r(s,o),this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:!0,composed:!0,detail:{from:s,to:o}}))}i=null,Array.from(l.children).forEach(t=>t.classList.remove("is-dragging"))}),this.addEventListener("dragend",()=>{i=null;const e=t();e&&Array.from(e.children).forEach(t=>t.classList.remove("is-dragging"))}),this.addEventListener("click",t=>{const s=t.target&&t.target.closest?t.target.closest(".c-sortable-list__handle"):null;if(!s||!this.contains(s))return;const r="true"===s.getAttribute("aria-pressed");s.setAttribute("aria-pressed",String(!r)),s.classList.toggle("is-grabbed",!r);const i=s.closest(".c-sortable-list__item"),a=i&&i.querySelector(".c-sortable-list__label"),n=a?a.textContent:"Item";e(r?`${n} released`:`${n} grabbed; use Up or Down arrows to reorder`)}),this.addEventListener("keydown",i=>{const a=i.target&&i.target.closest?i.target.closest(".c-sortable-list__handle"):null;if(!a)return;if("Enter"===i.key||" "===i.key)return i.preventDefault(),void a.click();const n=a.closest(".c-sortable-list__item");if(!n)return;const o=t(),l=s(n),c=(t,s)=>{const i=n.querySelector(".c-sortable-list__label");e((i?i.textContent:"Item")+" moved to position "+(s+1)),r(l,s),this.dispatchEvent(new CustomEvent("contour:move",{bubbles:!0,composed:!0,detail:{direction:t,from:l,to:s}})),this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:!0,composed:!0,detail:{from:l,to:s}}))};"ArrowUp"===i.key&&n.previousElementSibling?(i.preventDefault(),o.insertBefore(n,n.previousElementSibling),c("up",s(n))):"ArrowDown"===i.key&&n.nextElementSibling?(i.preventDefault(),o.insertBefore(n.nextElementSibling,n),c("down",s(n))):"Home"===i.key&&l>0?(i.preventDefault(),o.insertBefore(n,o.firstElementChild),c("up",0)):"End"===i.key&&l<o.children.length-1&&(i.preventDefault(),o.appendChild(n),c("down",o.children.length-1))})}}define("contour-sortable-list",ContourSortableList);class ContourCarousel extends ContourBase{static get observed(){return["items","index","autoplay","paused"]}static get properties(){return{items:{attribute:"items"},index:{attribute:"index"},autoplay:{attribute:"autoplay"},paused:{attribute:"paused",type:Boolean}}}_items(){const t=this.getAttribute("items");let e=[];try{e=t?JSON.parse(t):[]}catch(t){e=[]}return Array.isArray(e)?e:[]}_index(){const t=Number(this.getAttribute("index")),e=this._items();return Number.isFinite(t)&&t>=0&&t<e.length?t:0}render(){this.classList.add("c-carousel"),this.setAttribute("role","region"),this.setAttribute("aria-roledescription","carousel"),Array.from(this.children).forEach(t=>{t.classList&&t.classList.contains("c-carousel__slide")&&t.parentElement===this&&t.remove()});const t=this.ensure(".c-carousel__track",()=>{const t=document.createElement("div");return t.className="c-carousel__track",t.setAttribute("role","group"),t.setAttribute("aria-roledescription","slide container"),t}),e=this._items();setHTML(t,"");const s=this._index();e.forEach((r,i)=>{const a=document.createElement("div");a.className="c-carousel__slide"+(i===s?" is-active":""),a.setAttribute("role","group"),a.setAttribute("aria-roledescription","slide"),a.setAttribute("aria-label",i+1+" of "+e.length),a.setAttribute("aria-hidden",i===s?"false":"true");const n="object"==typeof r&&r?r.src||r.image||r.video:null;if(n){const t=!("object"!=typeof r||!r)&&("video"===r.type||!!r.video);a.classList.add("c-carousel__slide--media");const e=document.createElement(t?"video":"img");e.src=n,t?(e.controls=!0,r.poster&&(e.poster=r.poster)):e.alt="object"==typeof r&&(r.alt||r.label)||"",a.appendChild(e)}else a.textContent="string"==typeof r?r:r.label||r.text||"";a.dataset.index=String(i),t.appendChild(a)});this.ensure(".c-carousel__prev",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-carousel__prev",t.type="button",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-left" /></svg>'),t.setAttribute("aria-label",labelText(this,"previous-slide","Previous slide")),t}),this.ensure(".c-carousel__next",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-carousel__next",t.type="button",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>'),t.setAttribute("aria-label",labelText(this,"next-slide","Next slide")),t});const r=this.ensure(".c-carousel__status",()=>{const t=document.createElement("span");return t.className="c-carousel__status",t}),i=Number(this.getAttribute("autoplay")),a=Number.isFinite(i)&&i>0&&!this.hasAttribute("paused")&&!this._reducedMotion();r.setAttribute("aria-live",a?"off":"polite"),r.textContent=e.length?s+1+" of "+e.length:"0 of 0";const n=this.ensure(".c-carousel__dots",()=>{const t=document.createElement("div");return t.className="c-carousel__dots",t.setAttribute("role","group"),t.setAttribute("aria-label",labelText(this,"slide-controls","Slide controls")),t});n.setAttribute("role","group"),n.setAttribute("aria-label",labelText(this,"slide-controls","Slide controls")),setHTML(n,""),e.forEach((t,e)=>{const r=document.createElement("button");r.type="button",r.className="c-carousel__dot"+(e===s?" is-active":""),r.setAttribute("aria-label",labelText(this,"go-to-slide","Go to slide")+" "+(e+1)),r.setAttribute("aria-current",e===s?"true":"false"),r.tabIndex=e===s?0:-1,r.dataset.index=String(e),n.appendChild(r)});const o=i;if(Number.isFinite(o)&&o>0){const t=this.hasAttribute("paused")||this._reducedMotion(),e=this.ensure(".c-carousel__pause",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-carousel__pause",t.type="button",t});setHTML(e,t?'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-play" /></svg>':'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-pause" /></svg>'),e.setAttribute("aria-label",t?labelText(this,"play-slides","Play slides automatically"):labelText(this,"pause-slides","Pause automatic slides")),e.setAttribute("aria-pressed",String(t)),e.disabled=this._reducedMotion()}else{const t=this.querySelector(".c-carousel__pause");t&&t.remove()}}_reducedMotion(){try{return"function"==typeof matchMedia&&matchMedia("(prefers-reduced-motion: reduce)").matches}catch(t){return!1}}enhance(){const t=Number(this.getAttribute("autoplay")),e=Number.isFinite(t)&&t>0&&!this.hasAttribute("paused")&&!this._reducedMotion()&&this._items().length>1;if(e&&!this._carouselTimer?this._carouselTimer=setInterval(()=>{const t=this._items();if(!t.length)return;const e=(this._index()+1)%t.length;this.setAttribute("index",String(e)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:e,direction:"next"}}))},Math.max(500,t)):!e&&this._carouselTimer&&(clearInterval(this._carouselTimer),this._carouselTimer=null),this._wiredCarousel)return;this._wiredCarousel=!0,onDispose(this,()=>{this._carouselTimer&&(clearInterval(this._carouselTimer),this._carouselTimer=null)});const s=t=>{const e=this._items();if(!e.length)return;let s=this._index();s="prev"===t?(s-1+e.length)%e.length:(s+1)%e.length,this.setAttribute("index",String(s)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:s,direction:t}}))};this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-carousel__pause"):null;if(e&&this.contains(e)){if(this._reducedMotion())return;const t=!this.hasAttribute("paused");return this.toggleAttribute("paused",t),void this.dispatchEvent(new CustomEvent(t?"contour:pause":"contour:play",{bubbles:!0,composed:!0}))}const r=t.target&&t.target.closest?t.target.closest(".c-carousel__prev"):null,i=t.target&&t.target.closest?t.target.closest(".c-carousel__next"):null;if(r&&this.contains(r))return void s("prev");if(i&&this.contains(i))return void s("next");const a=t.target&&t.target.closest?t.target.closest(".c-carousel__dot"):null;if(a&&this.contains(a)){const t=Number(a.dataset.index);Number.isFinite(t)&&t!==this._index()&&(this.setAttribute("index",String(t)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:t,direction:"jump"}})))}});let r=null;this.addEventListener("pointerdown",t=>{r=t.clientX}),this.addEventListener("pointerup",t=>{if(null===r)return;const e=t.clientX-r;r=null,Math.abs(e)>40&&s(e<0?"next":"prev")}),this.addEventListener("pointercancel",()=>{r=null}),this.addEventListener("keydown",t=>{if("ArrowLeft"===t.key)t.preventDefault(),s("prev");else if("ArrowRight"===t.key)t.preventDefault(),s("next");else if("Home"===t.key)t.preventDefault(),this.setAttribute("index","0"),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:0,direction:"home"}}));else if("End"===t.key){t.preventDefault();const e=this._items().length-1;e>=0&&(this.setAttribute("index",String(e)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:e,direction:"end"}})))}})}}define("contour-carousel",ContourCarousel);class ContourDataGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["columns","rows","page","filter","page-size","resizable","virtual","row-height","selected","loading","error","empty"]}static get properties(){return{columns:{attribute:"columns"},rows:{attribute:"rows"},page:{attribute:"page"},filter:{attribute:"filter"},"page-size":{attribute:"page-size"},resizable:{attribute:"resizable",type:Boolean},virtual:{attribute:"virtual",type:Boolean},"row-height":{attribute:"row-height"},loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"}}}get selected(){return Array.from(this._dgSelectedKeys||[])}set selected(t){this._dgPushedSelection=Array.isArray(t)?t.map(String):[],this._dgSelectionControlled=!0,this.requestRender()}_dgRowKey(t){if(t&&"object"==typeof t&&!Array.isArray(t)){if(void 0!==t.id&&null!==t.id)return String(t.id);if(void 0!==t.key&&null!==t.key)return String(t.key)}const e=this._dgCols||[],s=e.findIndex(t=>t&&"object"==typeof t&&!0===t.key);if(s>=0&&t){const r="string"==typeof e[s].label?e[s].label:"",i=r&&null!=t[r]?String(t[r]):"";if(""!==i)return i}return JSON.stringify(void 0===t?null:t)}_dgReadSelection(){if(this._dgPushedSelection)return void(this._dgSelectedKeys=new Set(this._dgPushedSelection));const t=this.getAttribute("selected");if(null!==t&&t!==this._dgLastSelectedRaw){this._dgLastSelectedRaw=t,this._dgSelectionControlled=!0;try{const e=JSON.parse(t);this._dgSelectedKeys=new Set(Array.isArray(e)?e.map(String):[])}catch(t){this._dgSelectedKeys=new Set}}else this._dgSelectedKeys=this._dgSelectedKeys||new Set}_dgApplySelection(t){if(!t)return;const e=this._dgSelectedKeys||new Set;t.querySelectorAll("tr[data-row-key]").forEach(t=>{t.setAttribute("aria-selected",String(e.has(t.dataset.rowKey)))})}render(){if(this.classList.add("c-data-grid"),this.hasAttribute("loading")||this.hasAttribute("error")||this.hasAttribute("empty")){const t=this.ensure(".c-data-grid__table",()=>{const t=document.createElement("table");return t.className="c-table c-data-grid__table",t.setAttribute("role","grid"),t}),e=this.ensure("tbody",()=>document.createElement("tbody"));e.parentNode!==t&&t.appendChild(e),setHTML(e,"");const s=document.createElement("tr"),r=document.createElement("td");r.colSpan=1,r.style.textAlign="center",r.style.color="var(--color-text-muted)",this.hasAttribute("loading")?r.textContent=this.getAttribute("loading")||"Loading…":this.hasAttribute("error")?r.textContent=this.getAttribute("error")||"Error":r.textContent=this.getAttribute("empty")||"No data",s.appendChild(r),e.appendChild(s);let i=this.querySelector(".c-data-grid__wrap");return i||(i=document.createElement("div"),i.className="c-table-wrap c-data-grid__wrap"),t.parentNode!==i&&i.appendChild(t),void(i.parentNode!==this&&this.appendChild(i))}const t=this.ensure(".c-data-grid__table",()=>{const t=document.createElement("table");return t.className="c-table c-data-grid__table",t.setAttribute("role","grid"),t}),e=this.ensure("thead",()=>document.createElement("thead")),s=this.ensure("tbody",()=>document.createElement("tbody"));e.parentNode!==t&&t.appendChild(e),s.parentNode!==t&&t.appendChild(s);const r=this.getAttribute("columns");let i=[];try{i=r?JSON.parse(r):[]}catch(t){i=[]}if(i.length&&!e.querySelector("tr")){const t=document.createElement("tr");i.forEach(e=>{const s=document.createElement("th");s.setAttribute("role","columnheader"),s.setAttribute("aria-sort","none"),s.setAttribute("tabindex","0"),s.textContent="string"==typeof e?e:e.label||e.key||"",t.appendChild(s)}),e.appendChild(t)}this.hasAttribute("resizable")&&Array.from(e.querySelectorAll("th")).forEach(t=>{t.style.position="relative",t.setAttribute("data-resizable","true")});const a=this.getAttribute("rows");let n=[];try{n=a?JSON.parse(a):[]}catch(t){n=[]}t.setAttribute("aria-rowcount",String(n.length)),t.setAttribute("aria-colcount",String(i.length));const o=this.getAttribute("filter");if(o){const t=o.toLowerCase();n=n.filter(e=>JSON.stringify(e).toLowerCase().includes(t))}if(null!=this._dgSortCol&&this._dgSortCol>=0&&this._dgSortCol<i.length){const t=this._dgSortCol,s=this._dgSortDir||"asc",r=i[t],a=r?"string"==typeof r?r:r.key||r.label||"":String(t);n=n.slice().sort((e,r)=>{const i=Array.isArray(e)?e[t]??"":e&&null!=e[a]?e[a]:"",n=Array.isArray(r)?r[t]??"":r&&null!=r[a]?r[a]:"",o=Number(i),l=Number(n),c=""===i||""===n||isNaN(o)||isNaN(l)?String(i).localeCompare(String(n)):o-l;return"asc"===s?c:-c}),Array.from(e.querySelectorAll("th")).forEach((e,r)=>{e.setAttribute("aria-sort",r===t?"asc"===s?"ascending":"descending":"none")})}this._dgFilteredRows=n;const l=Number(this.getAttribute("page")||1),c=Number(this.getAttribute("page-size")||0);if(c>0){const t=(l-1)*c;n=n.slice(t,t+c)}this._dgCols=i,this._dgRows=n,this._dgReadSelection();if(this.hasAttribute("virtual")&&!(Number(this.getAttribute("page-size"))>0)){const t=this.querySelector(".c-data-grid__wrap");this._renderDataGridWindow(t?t.scrollTop:0)}else{setHTML(s,"");const t=c>0?(l-1)*c:0;n.forEach((e,r)=>{const a=document.createElement("tr");a.dataset.rowKey=this._dgRowKey(e),a.dataset.index=String(t+r),i.forEach((t,s)=>{const r="string"==typeof t?t:t.key||t.label||"",i=document.createElement("td");i.setAttribute("role","gridcell"),i.setAttribute("tabindex","-1");const n=Array.isArray(e)?e[s]:e?e[r]:void 0;i.textContent=null!=n?n:"",String(i.textContent).trim()||i.setAttribute("aria-label",labelText(this,"empty","Empty")),a.appendChild(i)}),s.appendChild(a)}),this._dgApplySelection(s)}let u=this.querySelector(".c-data-grid__wrap");if(u||(u=document.createElement("div"),u.className="c-table-wrap c-data-grid__wrap"),t.parentNode!==u&&u.appendChild(t),u.parentNode!==this&&this.appendChild(u),!t.querySelector('[tabindex="0"]')){const e=t.querySelector("tbody td, thead th");e&&e.setAttribute("tabindex","0")}}_rowHeight(){const t=Number(this.getAttribute("row-height"));return Number.isFinite(t)&&t>0?t:this._measuredRowHeight>0?this._measuredRowHeight:cssLength("--data-grid-row-height",32)}_renderDataGridWindow(t){const e=this.querySelector(".c-data-grid__table"),s=e&&e.querySelector("tbody");if(!s)return;const r=this._dgCols||[],i=this._dgRows||[],a=this._rowHeight(),n=Math.ceil(400/a)+6;let o=Math.floor((t||0)/a);o<0&&(o=0),o>Math.max(0,i.length-n)&&(o=Math.max(0,i.length-n));const l=Math.min(i.length,o+n);if(setHTML(s,""),o>0){const t=document.createElement("tr"),e=document.createElement("td");e.colSpan=Math.max(1,r.length),e.style.blockSize=o*a+"px",e.style.padding="0",t.appendChild(e),s.appendChild(t)}for(let t=o;t<l;t++){const e=i[t],a=document.createElement("tr");a.dataset.index=String(t),a.dataset.rowKey=this._dgRowKey(e),r.forEach((t,s)=>{const r="string"==typeof t?t:t.key||t.label||"",i=document.createElement("td");i.setAttribute("role","gridcell"),i.setAttribute("tabindex","-1");const n=Array.isArray(e)?e[s]:e?e[r]:void 0;i.textContent=null!=n?n:"",String(i.textContent).trim()||i.setAttribute("aria-label",labelText(this,"empty","Empty")),a.appendChild(i)}),s.appendChild(a)}if(l<i.length){const t=document.createElement("tr"),e=document.createElement("td");e.colSpan=Math.max(1,r.length),e.style.blockSize=(i.length-l)*a+"px",e.style.padding="0",t.appendChild(e),s.appendChild(t)}if(!s.querySelector('[tabindex="0"]')){const t=s.querySelector("tr[data-index] td");t&&t.setAttribute("tabindex","0")}this._dgApplySelection(s)}enhance(){if(this._wiredDataGrid)return;this._wiredDataGrid=!0;const t=()=>this.querySelector(".c-data-grid__wrap");this.addEventListener("scroll",t=>{const e=t.target&&t.target.classList&&t.target.classList.contains("c-data-grid__wrap")?t.target:null;e&&this.hasAttribute("virtual")&&this._renderDataGridWindow(e.scrollTop)},!0),this.addEventListener("keydown",t=>{const e=t.target&&t.target.closest?t.target.closest("[role='gridcell'], [role='columnheader']"):null;if(!e||!this.contains(e))return;const s=e.parentElement,r=this.querySelector(".c-data-grid__table");if(!r)return;if(t.altKey&&("ArrowLeft"===t.key||"ArrowRight"===t.key)&&e.hasAttribute("data-resizable")){t.preventDefault();const i=Array.from(s.children).indexOf(e),a=e.getBoundingClientRect().width||100,n=Math.max(48,a+("ArrowRight"===t.key?16:-16));return Array.from(r.rows).forEach(t=>{t.children[i]&&(t.children[i].style.inlineSize=n+"px")}),void this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:!0,composed:!0,detail:{column:i,width:n}}))}if("Enter"===t.key||" "===t.key)return t.preventDefault(),void("columnheader"===e.getAttribute("role")?e.click():s&&s.click());const i=Array.from(r.querySelectorAll("tr")),a=i.indexOf(s),n=Array.from(s.children).indexOf(e);let o=null;if("ArrowRight"===t.key?o=s.children[n+1]:"ArrowLeft"===t.key?o=s.children[n-1]:"ArrowDown"===t.key?o=i[a+1]&&i[a+1].children[n]:"ArrowUp"===t.key&&(o=i[a-1]&&i[a-1].children[n]),o){t.preventDefault(),r.querySelectorAll('[tabindex="0"]').forEach(t=>t.setAttribute("tabindex","-1")),o.setAttribute("tabindex","0");try{o.focus()}catch(t){}}}),this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest("tr"):null,r=e.target&&e.target.closest?e.target.closest("th"):null;if(s&&this.contains(s)&&!r&&void 0!==s.dataset.rowKey){const t=s.dataset.rowKey,e=Number(s.dataset.index),r=this._dgSelectedKeys||(this._dgSelectedKeys=new Set);r.has(t)?r.delete(t):r.add(t),this._dgApplySelection(s.parentElement),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{row:e,key:t,index:e}}))}if(r&&this.contains(r)){const e=Array.from(r.parentElement.children).indexOf(r);this._dgSortCol===e?this._dgSortDir="asc"===this._dgSortDir?"desc":"asc":(this._dgSortCol=e,this._dgSortDir="asc");const s=this._dgSortDir,i=this.querySelector(".c-data-grid__table"),a=i&&i.querySelector("tbody"),n=i&&i.querySelector("thead"),o=this._dgCols||[],l=o[e]?"string"==typeof o[e]?o[e]:o[e].key||o[e].label||"":String(e),c=(this._dgFilteredRows||[]).slice();if(c.sort((t,r)=>{const i=Array.isArray(t)?t[e]??"":t&&null!=t[l]?t[l]:"",a=Array.isArray(r)?r[e]??"":r&&null!=r[l]?r[l]:"",n=Number(i),o=Number(a),c=""===i||""===a||isNaN(n)||isNaN(o)?String(i).localeCompare(String(a)):n-o;return"asc"===s?c:-c}),this._dgFilteredRows=c,!this.hasAttribute("virtual")||Number(this.getAttribute("page-size"))>0){if(a){const t=Number(this.getAttribute("page")||1),e=Number(this.getAttribute("page-size")||0);let s=c;if(e>0){const r=(t-1)*e;s=c.slice(r,r+e)}setHTML(a,"");const r=e>0?(t-1)*e:0;s.forEach((t,e)=>{const s=document.createElement("tr");s.dataset.rowKey=this._dgRowKey(t),s.dataset.index=String(r+e),o.forEach((e,r)=>{const i="string"==typeof e?e:e.key||e.label||"",a=document.createElement("td");a.setAttribute("role","gridcell"),a.setAttribute("tabindex","-1");const n=Array.isArray(t)?t[r]:t?t[i]:void 0;a.textContent=null!=n?n:"",s.appendChild(a)}),a.appendChild(s)}),this._dgApplySelection(a)}}else{this._dgRows=c;const e=t();this._renderDataGridWindow(e?e.scrollTop:0)}n&&Array.from(n.querySelectorAll("th")).forEach((t,r)=>{t.setAttribute("aria-sort",r===e?"asc"===s?"ascending":"descending":"none")}),this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:!0,composed:!0,detail:{column:e,direction:s}}))}}),this.addEventListener("pointerdown",t=>{if(!this.hasAttribute("resizable"))return;const e=t.target&&t.target.closest?t.target.closest("th[data-resizable]"):null;if(!e||!this.contains(e)||e.getBoundingClientRect().right-t.clientX>10)return;t.preventDefault();const s=t.clientX,r=e.getBoundingClientRect().width,i=Array.from(e.parentElement.children).indexOf(e);let a=r;const n=t=>{a=Math.max(48,r+t.clientX-s);const e=this.querySelector(".c-data-grid__table");e&&Array.from(e.rows).forEach(t=>{t.children[i]&&(t.children[i].style.inlineSize=a+"px")})},o=()=>{window.removeEventListener("pointermove",n),this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:!0,composed:!0,detail:{column:i,width:a}}))};window.addEventListener("pointermove",n),window.addEventListener("pointerup",o,{once:!0}),onDispose(this,o)}),this._dgApplySelection(this.querySelector(".c-data-grid__table tbody"))}}define("contour-data-grid",ContourDataGrid);class ContourTreeGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","rows","expanded","loading","error","empty"]}static get properties(){return{items:{attribute:"items"},rows:{attribute:"rows"},expanded:{attribute:"expanded"},loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"}}}_expandedSet(){const t=this.getAttribute("expanded");if(!t)return new Set;try{return new Set(JSON.parse(t))}catch(e){return new Set([t])}}render(){this.classList.add("c-tree-grid");const t=this.ensure(".c-tree-grid__table",()=>{const t=document.createElement("table");return t.className="c-table c-tree-grid__table",t.setAttribute("role","treegrid"),t});t.setAttribute("aria-label",labelText(this,"tree-grid","Tree grid"));const e=this.ensure("tbody",()=>document.createElement("tbody"));if(e.parentNode!==t&&t.appendChild(e),setHTML(e,""),this.hasAttribute("loading")||this.hasAttribute("error")||this.hasAttribute("empty")){const t=document.createElement("tr"),s=document.createElement("td");s.style.textAlign="center",s.style.color="var(--color-text-muted)",this.hasAttribute("loading")?s.textContent=this.getAttribute("loading")||"Loading…":this.hasAttribute("error")?s.textContent=this.getAttribute("error")||"Error":s.textContent=this.getAttribute("empty")||"No data",t.appendChild(s),e.appendChild(t)}else{const t=this.getAttribute("items")||this.getAttribute("rows");let s=[];try{s=t?JSON.parse(t):[]}catch(t){s=[]}Array.isArray(s)||(s=[]);const r=this._expandedSet(),i=[],a=(t,s,n,o,l)=>{const c=document.createElement("tr");c.setAttribute("role","row"),c.setAttribute("tabindex",0===i.length?"0":"-1"),c.setAttribute("aria-level",String(s+1)),c.setAttribute("aria-posinset",String(o)),c.setAttribute("aria-setsize",String(l)),c.dataset.path=n,this._tgSelectedPath===n&&c.setAttribute("aria-selected","true");const u=!!(t&&Array.isArray(t.children)&&t.children.length);u&&c.setAttribute("aria-expanded",r.has(n)?"true":"false");const d=document.createElement("td");d.setAttribute("role","gridcell"),d.style.setProperty("--tree-depth",String(s));const h=t&&(t.label||t.text||t.name)||"";if(u){const t=document.createElement("button");t.type="button",t.className="c-tree-grid__toggle",t.tabIndex=-1,t.textContent=r.has(n)?"▾":"▸",t.setAttribute("aria-label",(r.has(n)?"Collapse":"Expand")+" "+h),d.appendChild(t)}const p=document.createElement("span");p.className="c-tree-grid__label",p.textContent=h,d.appendChild(p),c.appendChild(d),e.appendChild(c),i.push(c),u&&r.has(n)&&t.children.forEach((e,r)=>a(e,s+1,n+"."+r,r+1,t.children.length))};s.forEach((t,e)=>a(t,0,String(e),e+1,s.length))}let s=this.querySelector(".c-tree-grid__wrap");s||(s=document.createElement("div"),s.className="c-table-wrap c-tree-grid__wrap"),t.parentNode!==s&&s.appendChild(t),s.parentNode!==this&&this.appendChild(s)}enhance(){if(this._wiredTreeGrid)return;this._wiredTreeGrid=!0;const t=()=>Array.from(this.querySelectorAll("tr[role='row']")),e=e=>{if(e){t().forEach(t=>t.setAttribute("tabindex",t===e?"0":"-1"));try{e.focus()}catch(t){}}};this.addEventListener("click",s=>{const r=s.target&&s.target.closest?s.target.closest(".c-tree-grid__toggle"):null,i=s.target&&s.target.closest?s.target.closest("tr[role='row']"):null;if(!i||!this.contains(i))return;const a=i.dataset.path;if(e(i),r){s.preventDefault();const t=this._expandedSet();t.has(a)?t.delete(a):t.add(a),this.setAttribute("expanded",JSON.stringify([...t])),this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{path:a,expanded:t.has(a)}}))}else this._tgSelectedPath=a,t().forEach(t=>t.setAttribute("aria-selected",String(t===i))),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{path:a}}))}),this.addEventListener("keydown",s=>{const r=s.target&&s.target.closest?s.target.closest("tr[role='row']"):null;if(!r||!this.contains(r))return;const i=t(),a=i.indexOf(r),n=r.dataset.path||"",o=null!==r.getAttribute("aria-expanded"),l=this._expandedSet();if("ArrowRight"===s.key)s.preventDefault(),o&&!l.has(n)?(l.add(n),this.setAttribute("expanded",JSON.stringify([...l])),this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{path:n,expanded:!0}}))):o&&l.has(n)&&i[a+1]&&e(i[a+1]);else if("ArrowLeft"===s.key){if(s.preventDefault(),o&&l.has(n))l.delete(n),this.setAttribute("expanded",JSON.stringify([...l])),this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{path:n,expanded:!1}}));else if(n.includes(".")){const t=n.slice(0,n.lastIndexOf(".")),s=i.find(e=>e.dataset.path===t);s&&e(s)}}else if("ArrowDown"===s.key)s.preventDefault(),i[a+1]&&e(i[a+1]);else if("ArrowUp"===s.key)s.preventDefault(),i[a-1]&&e(i[a-1]);else if("Enter"===s.key||" "===s.key){s.preventDefault();const t=r.querySelector(".c-tree-grid__toggle");"Enter"===s.key&&t?t.click():(this._tgSelectedPath=n,i.forEach(t=>t.setAttribute("aria-selected",String(t===r))),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{path:n}})))}})}}define("contour-tree-grid",ContourTreeGrid);