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.
- package/README.md +244 -326
- package/dist/agent-cookbook.json +960 -0
- package/dist/agent-examples.json +65 -0
- package/dist/agent-map-wiring.json +152 -0
- package/dist/agent-rules.json +16 -0
- package/dist/build-manifest.json +344 -126
- package/dist/contour-wc-content.esm.js +1939 -0
- package/dist/contour-wc-content.esm.min.js +1 -0
- package/dist/contour-wc-core.esm.js +3724 -0
- package/dist/contour-wc-core.esm.min.js +1 -0
- package/dist/contour-wc-dashboard.esm.js +6986 -0
- package/dist/contour-wc-dashboard.esm.min.js +1 -0
- package/dist/contour-wc-data.esm.js +6572 -0
- package/dist/contour-wc-data.esm.min.js +1 -0
- package/dist/contour-wc-docs.esm.js +976 -0
- package/dist/contour-wc-docs.esm.min.js +1 -0
- package/dist/contour-wc-feedback.esm.js +1742 -0
- package/dist/contour-wc-feedback.esm.min.js +1 -0
- package/dist/contour-wc-forms.esm.js +2437 -0
- package/dist/contour-wc-forms.esm.min.js +1 -0
- package/dist/contour-wc-interaction.esm.js +1343 -0
- package/dist/contour-wc-interaction.esm.min.js +1 -0
- package/dist/contour-wc-layout.esm.js +845 -0
- package/dist/contour-wc-layout.esm.min.js +1 -0
- package/dist/contour-wc-map.esm.js +2411 -0
- package/dist/contour-wc-map.esm.min.js +1 -0
- package/dist/contour-wc-misc.esm.js +945 -0
- package/dist/contour-wc-misc.esm.min.js +1 -0
- package/dist/contour-wc-navigation.esm.js +2842 -0
- package/dist/contour-wc-navigation.esm.min.js +1 -0
- package/dist/contour-wc-ui.esm.js +6519 -0
- package/dist/contour-wc-ui.esm.min.js +1 -0
- package/dist/contour-wc.esm.js +14435 -5723
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +14436 -5725
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.a11y.json +402 -0
- package/dist/contour.code-snippets +4534 -0
- package/dist/contour.components.json +4870 -1222
- package/dist/contour.css +6672 -4711
- package/dist/contour.d.ts +753 -1085
- package/dist/contour.esm.js +440 -18
- package/dist/contour.esm.min.js +1 -1
- package/dist/contour.html-data.json +11343 -0
- package/dist/contour.js +440 -18
- package/dist/contour.min.css +1 -1
- package/dist/contour.min.js +1 -1
- package/dist/contour.react.d.ts +422 -0
- package/dist/contour.single.html +17 -0
- package/dist/contour.single.min.css +1 -0
- package/dist/contour.themes.json +56 -12
- package/dist/contour.tokens.json +1318 -1053
- package/dist/contour.vue.d.ts +420 -0
- package/dist/contour.web-types.json +11703 -0
- package/dist/custom-elements.json +36120 -0
- package/dist/docs/actions.md +16 -6
- package/dist/docs/affordances.md +21 -85
- package/dist/docs/apireference.md +9 -5
- package/dist/docs/colour.md +10 -4
- package/dist/docs/componentindex.md +9 -22
- package/dist/docs/data.md +39 -58
- package/dist/docs/docs.md +12 -7
- package/dist/docs/feedback.md +30 -12
- package/dist/docs/field.md +28 -13
- package/dist/docs/forms.md +35 -19
- package/dist/docs/index.json +70 -61
- package/dist/docs/install.md +12 -7
- package/dist/docs/landing.md +7 -4
- package/dist/docs/mapengine.md +30 -8
- package/dist/docs/motion.md +12 -6
- package/dist/docs/navigation.md +31 -7
- package/dist/docs/overlays.md +32 -25
- package/dist/docs/overview.md +3 -2
- package/dist/docs/patterns.md +20 -10
- package/dist/docs/playground.md +11 -4
- package/dist/docs/principles.md +8 -6
- package/dist/docs/recipes.md +117 -13
- package/dist/docs/space.md +10 -6
- package/dist/docs/status.md +13 -14
- package/dist/docs/surfaces.md +17 -22
- package/dist/docs/theming.md +18 -32
- package/dist/docs/type.md +12 -5
- package/dist/docs/webcomponents.md +75 -33
- package/dist/hljs.css +1 -20
- package/dist/map-chrome.mapbox.css +68 -92
- package/dist/map-chrome.maplibre.css +68 -92
- package/dist/registry/items/contour-core.json +2 -2
- package/dist/registry/items/contour-data.json +2 -2
- package/dist/registry/items/contour-docs.json +2 -2
- package/dist/registry/items/contour-landing.json +2 -2
- package/dist/registry/registry.json +8 -8
- package/dist/surfaces/contour-core.min.css +1 -1
- package/dist/surfaces/contour-data.min.css +1 -1
- package/dist/surfaces/contour-docs.min.css +1 -1
- package/dist/surfaces/contour-landing.min.css +1 -1
- package/dist/svg/icons.svg +367 -0
- package/dist/wc/behaviours.mjs +222 -192
- package/dist/wc/content.mjs +486 -142
- package/dist/wc/core.mjs +917 -395
- package/dist/wc/dashboard.mjs +252 -25
- package/dist/wc/data-chart.mjs +1333 -0
- package/dist/wc/data-export.mjs +391 -0
- package/dist/wc/data-gauge.mjs +779 -0
- package/dist/wc/data-geo.mjs +696 -0
- package/dist/wc/data-glyphs.mjs +133 -0
- package/dist/wc/data-legend.mjs +431 -0
- package/dist/wc/data-readout.mjs +227 -0
- package/dist/wc/data-series.mjs +1004 -0
- package/dist/wc/data-table.mjs +751 -0
- package/dist/wc/data.mjs +15 -3707
- package/dist/wc/docs.mjs +113 -19
- package/dist/wc/feedback.mjs +320 -116
- package/dist/wc/forms-controls.mjs +635 -0
- package/dist/wc/forms-field.mjs +547 -0
- package/dist/wc/forms-groups.mjs +347 -0
- package/dist/wc/forms-input.mjs +292 -0
- package/dist/wc/forms.mjs +10 -1122
- package/dist/wc/glyph.mjs +204 -0
- package/dist/wc/index.mjs +16 -7
- package/dist/wc/interaction.mjs +322 -75
- package/dist/wc/layout.mjs +100 -29
- package/dist/wc/map.mjs +888 -285
- package/dist/wc/misc.mjs +137 -26
- package/dist/wc/navigation-menu.mjs +735 -0
- package/dist/wc/navigation-shell.mjs +495 -0
- package/dist/wc/navigation-tree.mjs +995 -0
- package/dist/wc/navigation.mjs +9 -1636
- package/dist/wc/registration.mjs +1 -8
- package/dist/wc/shadow.mjs +285 -113
- package/dist/wc/states.mjs +75 -78
- package/dist/wc/svg.mjs +209 -34
- package/dist/wc/ui-atoms.mjs +608 -0
- package/dist/wc/ui-data.mjs +1404 -0
- package/dist/wc/ui-feedback.mjs +419 -0
- package/dist/wc/ui-inputs.mjs +1570 -0
- package/dist/wc/ui-menus.mjs +307 -0
- package/dist/wc/ui-overlays.mjs +1605 -0
- package/integrations/README.md +25 -5
- package/integrations/ai/CLAUDE.md +6 -3
- package/integrations/ai/COPILOT.md +14 -0
- package/integrations/ai/GEMINI.md +14 -0
- package/integrations/ai/WINDSURF.md +14 -0
- package/integrations/ai/v0-prompt.md +13 -1
- package/integrations/frameworks/README.md +235 -0
- package/integrations/native/README.md +0 -3
- package/integrations/native/style-dictionary.config.json +1 -1
- package/integrations/tailwind/contour-theme.css +71 -13
- package/integrations/validate-markup.mjs +172 -0
- package/package.json +103 -39
- 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 r=0;r<t.length;r++)e^=t.charCodeAt(r),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 r="-1";try{const t=e.cssRules;let s="";for(let e=0;e<t.length;e++)s+=t[e].cssText+"\n";r=t.length+":"+_hashCss(s)}catch(t){}t+=(e.href||"inline")+"~"+r+"|"}if(ADOPTED&&t===ADOPTED_KEY)return ADOPTED;ADOPTED_KEY=t,ADOPTED=[];const e=(t,r)=>{let s;try{s=t.cssRules}catch(t){return}if(s)for(const t of s)if(t instanceof CSSImportRule)t.styleSheet&&e(t.styleSheet,r);else try{r.push(t.cssText)}catch(t){}};for(const t of document.styleSheets)try{if(!t.href||new URL(t.href).origin===location.origin){const r=[];e(t,r);const s=new CSSStyleSheet;r.length&&s.replaceSync(r.join("\n")),ADOPTED.push(s)}}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 r=e.getAttribute("aria-controls");if(r){const s=t.querySelector("#"+CSS.escape(r))||document.getElementById(r);s&&!s.hasAttribute("aria-labelledby")&&(e.id||(e.id=contourId("tab")),s.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 r=e.querySelector(".c-field__hint");r&&(r.id||(r.id=contourId("hint")),t.setAttribute("aria-describedby",r.id));const s=e.querySelector(".c-field__error");if(s){s.id||(s.id=contourId("err"));const e=t.getAttribute("aria-describedby")||"";t.setAttribute("aria-describedby",(e+" "+s.id).trim())}}}),t.querySelectorAll(".c-alert").forEach(t=>{const e=t.classList.contains("c-alert--warning")||t.classList.contains("c-alert--danger"),r=e?"alert":"status",s=e?"assertive":"polite";t.hasAttribute("role")&&!t.dataset.contourAutoRole||(t.setAttribute("role",r),t.dataset.contourAutoRole=r),t.hasAttribute("aria-live")&&!t.dataset.contourAutoLive||(t.setAttribute("aria-live",s),t.dataset.contourAutoLive=s)}),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"),r=t.closest(".c-field")||t.parentElement,s=[];if(e)for(const t of e.assignedElements({flatten:!0}))t.matches("input, textarea, select")&&s.push(t);if(!s.length&&r){const t=r.querySelector('slot[name="input"]');if(t)for(const e of t.assignedElements({flatten:!0}))e.matches("input, textarea, select")&&s.push(e)}for(const e of s){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 r=assignedText(t);r&&e.setAttribute("aria-label",r)}if(e._contourLabelWired||(e._contourLabelWired=!0,t.addEventListener("click",t=>{if(!t.target.closest("a, button, input, textarea, select"))try{e.click()}catch(t){}})),r&&!e.hasAttribute("aria-describedby")){const t=r.querySelector(".c-field__hint"),s=r.querySelector(".c-field__error"),i=[];t&&(t.id||(t.id=contourId("hint")),i.push(t.id)),s&&(s.id||(s.id=contourId("err")),i.push(s.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,r,s)=>{const i=t.querySelector(e);i&&i.setAttribute("aria-label",labelText(this,r,s))};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 r=t.querySelector(".c-install__copy, .c-code__copy");r&&"Copy"===r.textContent.trim()&&(r.textContent=labelText(this,"copy","Copy"))}applyMods(){const t=this.shadowRoot.firstElementChild;if(!t||!this._shadowBase)return;const e=[];for(const t of MODS){const r=this.getAttribute(t);if(r)for(const t of this._shadowBase.split(/\s+/))t&&e.push("c-"+t.replace(/^c-/,"")+"--"+r)}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"),r=e?"alert":"status",s=e?"assertive":"polite";t.hasAttribute("role")&&!t.dataset.contourAutoRole||(t.setAttribute("role",r),t.dataset.contourAutoRole=r),t.hasAttribute("aria-live")&&!t.dataset.contourAutoLive||(t.setAttribute("aria-live",s),t.dataset.contourAutoLive=s)}}}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 r=document.createElement("template");setHTML(r,e);const s=class extends ContourShadow{};s.contourTemplate=r,define(t,s)},slotWrapper=(t,e,r)=>"<"+t+' class="c-'+e+'" part="'+(r||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 r of e){shadow("contour-shadow-"+r,slotWrapper(t,r,SHADOW_PARTS[r]||r))}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"),r=t.querySelector('[part="close"]');if(r&&r.addEventListener("click",()=>e?.close()),e){let t=null;e.addEventListener("beforetoggle",r=>{if("open"===r.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 s=e.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(s)try{s.focus()}catch(r){}}else if("closed"===r.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(r){}});const r=()=>{const t="button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])",r=Array.from(e.querySelectorAll(t));for(const s of e.querySelectorAll("slot"))for(const e of s.assignedElements({flatten:!0})){e.matches(t)&&r.push(e);for(const s of e.querySelectorAll(t))r.push(s)}return r},s=()=>this.shadowRoot&&this.shadowRoot.activeElement||document.activeElement;e.addEventListener("keydown",t=>{if("Tab"!==t.key)return;const e=r();if(!e.length)return;const i=e[0],a=e[e.length-1];t.shiftKey&&s()===i?(t.preventDefault(),a.focus()):t.shiftKey||s()!==a||(t.preventDefault(),i.focus())})}}static get observedAttributes(){return[...super.observedAttributes,"open"]}attributeChangedCallback(t,e,r){if(super.attributeChangedCallback(t,e,r),"open"===t&&this.shadowRoot&&!this._syncingOpenAttr){const t=this.shadowRoot.querySelector("dialog");t&&(null===r||t.open?null===r&&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="",r="")=>{const s=SHADOW_MARKUP[t];if("string"!=typeof s)return null;return`<${t}${e?e.startsWith(" ")?e:" "+e:""}><template shadowrootmode="open">${s}</template>${r}</${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 ContourReadout extends ContourBase{static get observed(){return["rows","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","format","locale","unit","precision","cache-key","no-cache"]}static get properties(){return{rows:{attribute:"rows"},format:{attribute:"format"},locale:{attribute:"locale"},precision:{attribute:"precision"},src:{attribute:"src"}}}render(){if(this.classList.add("c-readout"),wireStates(this),loadRemote(this,"rows"),renderStates(this,"readout"))return;const t=remoteData(this,"rows");Array.from(this.querySelectorAll(".c-readout__row")).forEach(t=>t.remove());const e=Array.from(this.children).filter(t=>!t.classList||!t.classList.contains("c-readout__row"));if(t&&!e.length)try{JSON.parse(t).forEach(t=>{const e=document.createElement("div");e.className="c-readout__row";const r=document.createElement("span");r.className="c-readout__key",r.textContent=t.key||t[0];const s=document.createElement("span");s.className="c-readout__value"+(t.primary?" c-readout__value--primary":"")+(t.accent?" c-readout__value--accent":"")+(t.coord?" c-readout__value--coord":""),s.setAttribute("aria-live","polite");const i=void 0!==t.value?t.value:t[1],a=void 0!==t.precision?t.precision:this.getAttribute("precision");null!==a&&""!==a&&(s.dataset.precision=String(a));const o=null!==a&&""!==a&&"number"==typeof i&&Number.isFinite(i)?i.toFixed(Math.max(0,Math.min(20,Number(a)||0))):i;if(s.textContent=formatValue(o,this.getAttribute("format"),this.getAttribute("locale"),void 0!==t.unit?t.unit:this.getAttribute("unit")),e.appendChild(r),e.appendChild(s),t.order){const r=document.createElement("span");r.className="c-readout__order",r.textContent=t.order,e.appendChild(r)}this.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}else t||e.length||renderEmpty(this,"readout")}}define("contour-readout",ContourReadout);class ContourKpi extends ContourBase{static get observed(){return["value","label","delta","direction","note","variant","unit","format","locale","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","thresholds","threshold","sparkline","polarity","cache-key","no-cache"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},delta:{attribute:"delta"},direction:{attribute:"direction"},note:{attribute:"note"},variant:{attribute:"variant"},unit:{attribute:"unit"},format:{attribute:"format"},locale:{attribute:"locale"},thresholds:{attribute:"thresholds"},threshold:{attribute:"threshold"},sparkline:{attribute:"sparkline"},polarity:{attribute:"polarity"}}}render(){if(this.classList.add("c-kpi"),wireStates(this),loadRemote(this,["value","label"]),renderStates(this,"kpi"))return;const t=remoteData(this,"value"),e=remoteData(this,"label"),r=this.getAttribute("delta"),s=this.getAttribute("variant");if(Array.from(this.classList).forEach(t=>{t.startsWith("c-kpi--")&&this.classList.remove(t)}),s&&this.classList.add("c-kpi--"+s),t){this.ensure(".c-kpi__value",()=>{const t=document.createElement("div");return t.className="c-kpi__value",t.setAttribute("aria-live","polite"),t}).textContent=formatValue(t,this.getAttribute("format"),this.getAttribute("locale"),this.getAttribute("unit"))}else{const t=this.querySelector(".c-kpi__value");t&&t.remove()}if(e){const t=this.ensure(".c-kpi__head",()=>{const t=document.createElement("div");return t.className="c-kpi__head",t});let r=t.querySelector(".c-kpi__label");r||(r=document.createElement("div"),r.className="c-kpi__label",t.appendChild(r)),r.textContent=e,t.parentNode!==this&&this.insertBefore(t,this.firstChild)}else{const t=this.querySelector(".c-kpi__head");t&&t.remove()}if(r){const t=this.ensure(".c-kpi__foot",()=>{const t=document.createElement("div");return t.className="c-kpi__foot",t}),e=t.querySelector(".c-delta")||document.createElement("span");e.parentNode||t.insertBefore(e,t.firstChild);const s=this.getAttribute("direction")||"up",i=this.getAttribute("polarity")||"neutral";let a="neutral";"good"===i||"up-good"===i||"auto"===i?a="up"===s?"good":"down"===s?"bad":"neutral":"bad"!==i&&"down-good"!==i||(a="up"===s?"bad":"down"===s?"good":"neutral"),e.className="c-delta c-delta--"+s+" c-delta--"+a,e.textContent="";const o={up:"#i-arrow-up",down:"#i-arrow-down",flat:"#i-minus"}[s]||"#i-arrow-up",n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("aria-hidden","true");const l=document.createElementNS("http://www.w3.org/2000/svg","use");l.setAttribute("href",o),n.appendChild(l),e.appendChild(n),e.appendChild(document.createTextNode(" "+r))}else{const t=this.querySelector(".c-kpi__foot .c-delta");t&&t.remove()}const i=this.getAttribute("note");if(i){const t=this.ensure(".c-kpi__foot",()=>{const t=document.createElement("div");return t.className="c-kpi__foot",t});(t.querySelector(".c-kpi__note")||(()=>{const e=document.createElement("span");return e.className="c-kpi__note",t.appendChild(e),e})()).textContent=i}else{const t=this.querySelector(".c-kpi__note");t&&t.remove()}const a=this.getAttribute("unit"),o=this.querySelector(".c-kpi__value");if(o)if(a){let t=o.querySelector(".c-kpi__unit");t||(t=document.createElement("span"),t.className="c-kpi__unit",o.appendChild(t)),t.textContent=a}else{const t=o.querySelector(".c-kpi__unit");t&&t.remove()}const n=this.getAttribute("threshold")||this.getAttribute("thresholds");if(n){const t=this.ensure(".c-kpi__foot",()=>{const t=document.createElement("div");return t.className="c-kpi__foot",t});let e=t.querySelector(".c-kpi__threshold-badge");e||(e=document.createElement("span"),e.className="c-kpi__threshold-badge",t.appendChild(e)),e.textContent=n,e.setAttribute("part","threshold-badge")}else{const t=this.querySelector(".c-kpi__threshold-badge");t&&t.remove()}const l=this.querySelector(".c-kpi__foot");l&&!l.querySelector(".c-delta, .c-kpi__note, .c-kpi__threshold-badge")&&l.remove();const c=this.getAttribute("sparkline"),u=null!==c&&""!==c&&"0"!==c&&"false"!==c.toLowerCase(),d=this.querySelector(".c-kpi__sparkline-canvas");if(d&&d.remove(),u){let t=null;try{t=JSON.parse(c)}catch(e){t=null}Array.isArray(t)||(t=null);const e=(t||[]).map(t=>Number(t)).filter(t=>Number.isFinite(t));if(e.length>1){const t=document.createElement("canvas");t.className="c-kpi__sparkline-canvas",t.setAttribute("part","sparkline-canvas"),t.setAttribute("aria-hidden","true"),this.appendChild(t),this._sparkSeries=e;const r=()=>{if(!t.isConnected)return;const r=t.clientWidth,s=t.clientHeight;if(!r||!s)return;const i="undefined"!=typeof window&&window.devicePixelRatio||1;t.width=Math.round(r*i),t.height=Math.round(s*i);const a=t.getContext&&t.getContext("2d");if(!a)return;a.setTransform(i,0,0,i,0,0),a.clearRect(0,0,r,s);const o=Math.min.apply(null,e),n=Math.max.apply(null,e)-o||1;let l=getComputedStyle(this).getPropertyValue("--chart-1").trim();if(!l||/^(var|light-dark)\(/.test(l)){const t=document.createElement("span");t.style.display="none",t.style.color=l||"var(--chart-1, #666)",this.appendChild(t),l=getComputedStyle(t).color||"#666",t.remove()}a.beginPath(),a.lineWidth=1.5,a.strokeStyle=l,e.forEach((t,i)=>{const l=(t=>t/(e.length-1)*(r-4)+2)(i),c=(t=>s-2-(t-o)/n*(s-4))(t);0===i?a.moveTo(l,c):a.lineTo(l,c)}),a.stroke()};"function"==typeof requestAnimationFrame?requestAnimationFrame(r):r(),"undefined"==typeof ResizeObserver||this._sparkRO||(this._sparkRO=new ResizeObserver(()=>r()),onDispose(this,()=>{this._sparkRO&&(this._sparkRO.disconnect(),this._sparkRO=null)})),this._sparkRO&&this._sparkRO.observe(t)}}t||e||renderEmpty(this,"kpi")}}define("contour-kpi",ContourKpi);class ContourTable extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["columns","rows","page","page-size","sort","sort-dir","virtual","title","selected","empty","loading","error","retry","skeleton","persist","density","visible-columns","cache-key","lazy","no-cache","refresh","src","timeout"]}static get properties(){return{columns:{attribute:"columns"},rows:{attribute:"rows"},page:{attribute:"page",type:Number},pageSize:{attribute:"page-size",type:Number}}}get selected(){return this._selectionKeys()}set selected(t){this._pushedSelection=Array.isArray(t)?t.map(String):[],this.requestRender()}_rowKey(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._keyCol;if(null!=e&&e>=0&&t&&void 0!==t[e]&&null!==t[e]){const r=this._cellValue(t[e]);if(""!==r)return String(r)}return JSON.stringify(void 0===t?null:t)}_selectionKeys(){if(this._selectionControlled)return Array.from(this._selectedKeys||[]);const t=this._rowData||[];return Array.from(this._selectedRows||[]).map(e=>this._rowKey(t[e]))}_syncSelectionRows(){const t=this._rowData||[],e=new Set;t.forEach((t,r)=>{this._selectedKeys.has(this._rowKey(t))&&e.add(r)}),this._selectedRows=e}_cellValue(t){return null==t?"":"object"==typeof t?void 0!==t.value?t.value:void 0!==t.label?t.label:JSON.stringify(t):t}_cellFor(t,e,r){if(t&&"object"==typeof t&&!Array.isArray(t)){const s="string"==typeof e?e:e&&(e.key||e.label||e.title)||"";return s&&void 0!==t[s]?t[s]:t[r]}return t?t[r]:void 0}_compare(t,e,r){const s=this._cellValue(t),i=this._cellValue(e);return"number"===r||"numeric"===r?(parseFloat(s)||0)-(parseFloat(i)||0):String(s).localeCompare(String(i),void 0,{numeric:!0})}_applyVisibleColumns(t){const e=this.getAttribute("visible-columns");if(!e)return;let r=null;try{const t=JSON.parse(e);Array.isArray(t)&&(r=new Set(t.map(Number)))}catch(t){}if(!r||!r.size)return;const s=t=>r.has(t);t.querySelectorAll("thead tr th").forEach((t,e)=>{t.hidden=!s(e)}),t.querySelectorAll("tbody tr").forEach(t=>{1===t.children.length&&t.children[0].hasAttribute("colspan")||Array.from(t.children).forEach((t,e)=>{t.hidden=!s(e)})})}render(){if(this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("title")||"Table"),wireStates(this),loadRemote(this,"rows"),renderStates(this,"table"))return;const t=this.getAttribute("columns"),e=remoteData(this,"rows"),r=Array.from(this.children).filter(t=>!t.classList||!t.classList.contains("c-table-wrap"));if(t&&e&&!r.length)try{const r=JSON.parse(t),s=JSON.parse(e),i=this.getAttribute("sort"),a=this.getAttribute("sort-dir");if(void 0===this._sortCol||i!==this._sortAttrLast||a!==this._sortDirAttrLast){if(this._sortAttrLast=i,this._sortDirAttrLast=a,null!==i){const t=Number(i);this._sortCol=Number.isFinite(t)?t:r.findIndex(t=>"object"==typeof t&&t&&(t.label||t.title||t)===i),this._sortCol<0&&(this._sortCol=null)}else this._sortCol=null;this._sortDir="descending"===a||"desc"===a?-1:1}let o=Array.isArray(s)?s.slice():[];if(null!==this._sortCol&&void 0!==this._sortCol&&this._sortCol>=0&&this._sortCol<r.length){const t=this._sortCol,e=this._sortDir||1,s=r[t],i="object"==typeof s&&s&&s.sortType?s.sortType:"text";o.sort((r,a)=>this._compare(this._cellFor(r,s,t),this._cellFor(a,s,t),i)*e)}this._filters||(this._filters={});const n=Object.keys(this._filters).filter(t=>this._filters[t]);n.length&&(o=o.filter(t=>n.every(e=>{const s=Number(e),i=String(this._filters[s]||"").toLowerCase();return!i||String(this._cellValue(this._cellFor(t,r[s],s))).toLowerCase().includes(i)})));const l=this.getAttribute("page-size"),c=null!==l?parseInt(l,10):NaN,u=Number.isFinite(c)&&c>0;let d=this.getAttribute("page");if(this.getAttribute("persist")&&this.id){const t=this.getAttribute("persist");let e=null;if("storage"===t)try{e=localStorage.getItem("contour-table:"+this.id)}catch(t){}else if("url"===t)try{e=new URLSearchParams(window.location.search).get("c-table-"+this.id)}catch(t){}null!==e&&(d=e)}this._pageInternal?(this._pageInternal=!1,this._pageAttrLast=d):d!==this._pageAttrLast&&(this._page=null,this._pageAttrLast=d);let h=null!==this._page?this._page:parseInt(d||"1",10);(!Number.isFinite(h)||h<1)&&(h=1);let m=1,b=o;if(u){m=Math.max(1,Math.ceil(o.length/c)),h>m&&(h=m);const t=(h-1)*c;b=o.slice(t,t+c)}this._page=h,this._totalPages=m,this._pageSize=c,this._rowData=b,this._keyCol=r.findIndex(t=>"object"==typeof t&&null!==t&&!0===t.key),this._selectedRows=this._selectedRows||new Set,this._selectedKeys=this._selectedKeys||new Set;const p=this.getAttribute("selected");if(p!==this._selectedAttrLast)if(this._selectedAttrLast=p,null!==p)try{const t=JSON.parse(p);Array.isArray(t)?(this._selectedKeys=new Set(t.map(String)),this._selectionControlled=!0):warnBadJson(this,"selected",new Error("not an array"))}catch(t){warnBadJson(this,"selected",t)}else void 0===this._pushedSelection&&(this._selectionControlled=!1);void 0!==this._pushedSelection&&(this._selectedKeys=new Set(this._pushedSelection),this._selectionControlled=!0),this._selectionControlled&&this._syncSelectionRows();const g=this._virtualWrap||this.keepNode(this.ensure(".c-table-wrap",()=>{const t=document.createElement("div");return t.className="c-table-wrap",t.setAttribute("tabindex","0"),t.setAttribute("role","region"),t.setAttribute("aria-label",labelText(this,"table-data","Table data")),t}));this._virtualWrap=g;const _=JSON.stringify(r),v=g.querySelector("table.c-table")&&this._tableCols===_?g.querySelector("table.c-table"):(()=>{const t=document.createElement("table");t.className="c-table";const e=document.createElement("caption");e.className="visually-hidden",e.textContent=this.getAttribute("title")||this.getAttribute("aria-label")||"Table",t.appendChild(e);const s=document.createElement("thead"),i=document.createElement("tr");return r.forEach((t,e)=>{const r="string"==typeof t?t:t.label||t.title||t,s=document.createElement("th"),a="object"==typeof t&&null!==t&&t.sort,o="object"==typeof t&&null!==t&&t.select,n="object"==typeof t&&null!==t&&t.filter;if("object"==typeof t&&null!==t&&("number"===t.type||"numeric"===t.type)&&s.classList.add("c-table__number"),n){s.className=s.className.trim();const t=document.createElement("input");t.type="search",t.className="c-table__filter-input",t.placeholder=r,t.setAttribute("aria-label",labelText(this,"filter","Filter")+" "+r),t.dataset.filterIndex=String(e),this._filters&&this._filters[e]&&(t.value=this._filters[e]),s.appendChild(t)}else if(o){s.className=(s.className+" c-table__select").trim();const t=document.createElement("input");t.type="checkbox",t.className="c-table__select-all",t.setAttribute("aria-label",labelText(this,"select-all-rows","Select all rows")),t.dataset.contourPreserveKey="select-all",s.appendChild(t)}else if(a){s.setAttribute("aria-sort",this._sortCol===e?-1===this._sortDir?"descending":"ascending":"none");const t=document.createElement("span");t.className="c-table__sort",t.textContent=r;const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("aria-hidden","true"),setHTML(i,'<use href="#i-chevron-down" />'),t.appendChild(i),s.appendChild(t)}else"object"==typeof t&&null!==t&&t.pinned?(s.className="c-table__pinned",s.textContent=r):s.textContent=r;a&&(s.setAttribute("tabindex","0"),s.setAttribute("role","columnheader"),s.dataset.sortIndex=String(e)),i.appendChild(s)}),s.appendChild(i),t.appendChild(s),t.appendChild(document.createElement("tbody")),t})();this._tableCols=_,this._applyVisibleColumns(v),r.forEach((t,e)=>{if("object"==typeof t&&null!==t&&t.sort){const t=v.querySelector("thead tr th:nth-child("+(e+1)+")");t&&t.setAttribute("aria-sort",this._sortCol===e?-1===this._sortDir?"descending":"ascending":"none")}});const y=v.querySelector("tbody"),f=null!=this._tablePendingScrollTop?this._tablePendingScrollTop:g.scrollTop;this._tablePendingScrollTop=null,y.innerHTML="";const A=this.hasAttribute("virtual")&&!u&&b.length>100,w=this._measuredRowHeight||cssLength("--data-grid-row-height",32),x=30,C=10;let E=0,S=b;if(A){const t=Math.max(0,b.length-x);E=Math.min(t,Math.max(0,Math.floor(f/w)-C)),S=b.slice(E,E+x+2*C),v.setAttribute("aria-rowcount",String(b.length+1)),this._tableWindowStart=E}else v.removeAttribute("aria-rowcount");const k=t=>{const e=document.createElement("tr");e.setAttribute("aria-hidden","true");const s=document.createElement("td");s.colSpan=r.length,s.style.blockSize=`${t}px`,s.style.padding="0",e.appendChild(s),y.appendChild(e)};if(A&&k(E*w),0===S.length){const t=document.createElement("tr"),e=document.createElement("td");e.colSpan=r.length,e.textContent=this.getAttribute("empty")||"No data",e.style.textAlign="center",e.style.color="var(--color-text-muted)",t.appendChild(e),y.appendChild(t)}else S.forEach((t,e)=>{const s=document.createElement("tr");s.dataset.rowIndex=String(E+e);const i=this._rowKey(t);s.dataset.rowKey=i,s.setAttribute("tabindex","-1"),r.forEach((r,a)=>{const o="object"==typeof r&&null!==r&&r.select,n="object"==typeof r&&null!==r&&("number"===r.type||"numeric"===r.type),l=document.createElement("td");if(n&&l.classList.add("c-table__number"),o){const t=document.createElement("input");t.type="checkbox",t.className="c-table__row-select",t.dataset.rowIndex=String(E+e),t.dataset.contourPreserveKey=i,this._selectionControlled?this._selectedKeys.has(i)&&(t.checked=!0):this._selectedRows&&this._selectedRows.has(E+e)&&(t.checked=!0),l.appendChild(t)}else l.textContent=this._cellValue(this._cellFor(t,r,a));s.appendChild(l)}),y.appendChild(s)});if(A&&k(Math.max(0,b.length-E-S.length)*w),!y.querySelector('tr[tabindex="0"]')){const t=y.querySelector("tr[data-row-index]");t&&t.setAttribute("tabindex","0")}if(!this._measuredRowHeight&&!this._measuringRow){const t=y.querySelector("tr[data-row-index]"),e=t?t.getBoundingClientRect().height:0;e>0&&(this._measuredRowHeight=e,Math.abs(e-w)>1&&(this._measuringRow=!0,requestAnimationFrame(()=>{this._measuringRow=!1,this.render()})))}if(v.parentNode!==g){for(;g.firstChild;)g.removeChild(g.firstChild);g.appendChild(v)}if(g.parentNode!==this&&this.appendChild(g),A&&f>0&&g.scrollTop!==f&&(this._tableScrollRestoredAt="undefined"!=typeof performance&&performance.now?performance.now():Date.now(),g.scrollTop=f),this.hasAttribute("virtual")?(g.style.maxHeight=g.style.maxHeight||"24rem",g.style.overflow="auto",g.style.contentVisibility="visible",v.classList.add("c-table--virtual")):(g.style.maxHeight="",g.style.overflow="",g.style.contentVisibility="",v.classList.remove("c-table--virtual")),u){const t=this.ensure(".c-table__pagination",()=>{const t=document.createElement("div");return t.className="c-table__pagination",t});t.innerHTML="";const e=document.createElement("button");e.className="c-btn c-btn--ghost c-btn--sm",e.type="button",e.textContent=labelText(this,"prev","Previous"),e.disabled=h<=1,e.dataset.action="prev";const r=document.createElement("span");r.textContent=`${labelText(this,"page","Page")} ${h} ${labelText(this,"of","of")} ${m}`;const s=document.createElement("button");s.className="c-btn c-btn--ghost c-btn--sm",s.type="button",s.textContent=labelText(this,"next","Next"),s.disabled=h>=m,s.dataset.action="next",t.appendChild(e),t.appendChild(r),t.appendChild(s)}else{const t=this.querySelector(".c-table__pagination");t&&t.remove()}}catch(t){warnBadJson(this,"attribute",t)}else e||r.length||renderEmpty(this,"table")}_applySelectionToDom(){this.querySelectorAll(".c-table__row-select").forEach(t=>{const e=Number(t.dataset.rowIndex);if(!Number.isFinite(e))return;const r=this._rowData?this._rowData[e]:void 0,s=this._selectionControlled?this._selectedKeys.has(this._rowKey(r)):!(!this._selectedRows||!this._selectedRows.has(e));t.checked!==s&&(t.checked=s)});const t=this.querySelector(".c-table__select-all");if(t){const e=Array.from(this.querySelectorAll(".c-table__row-select")),r=e.filter(t=>t.checked).length;t.checked=e.length>0&&r===e.length,t.indeterminate=r>0&&r<e.length,t.setAttribute("aria-label",flagOn(this,"virtual")?labelText(this,"select-visible-rows","Select visible rows"):labelText(this,"select-all-rows","Select all rows"))}}enhance(){if(this._applySelectionToDom(),this._wiredTable)return;this._wiredTable=!0;const t=t=>{const e=Number(t.dataset.sortIndex);Number.isFinite(e)&&(this._sortCol===e?this._sortDir=1===this._sortDir?-1:1:(this._sortCol=e,this._sortDir=1),this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:!0,composed:!0,detail:{column:e,direction:1===this._sortDir?"ascending":"descending"}})),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{sort:e,sortDir:1===this._sortDir?"ascending":"descending"}}})),this.requestRender())};this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest('button[data-action="retry"]'):null;if(r&&this.contains(r))return e.preventDefault(),void this.dispatchEvent(new CustomEvent("contour:retry",{detail:{src:this.getAttribute("src")},bubbles:!0,composed:!0}));const s=e.target&&e.target.closest?e.target.closest("th[aria-sort]"):null;if(s&&this.contains(s))return e.preventDefault(),void t(s);const i=e.target&&e.target.closest?e.target.closest(".c-table__pagination button"):null;if(i&&this.contains(i)){e.preventDefault();const t=i.dataset.action;let r=null!==this._page?this._page:parseInt(this.getAttribute("page")||"1",10);(!Number.isFinite(r)||r<1)&&(r=1),"prev"===t&&r>1&&(r-=1),"next"===t&&(r+=1),this._page=r,this._pageAttrLast=String(r),this._pageInternal=!0,this.setAttribute("page",String(r)),this.dispatchEvent(new CustomEvent("contour:page",{bubbles:!0,composed:!0,detail:{page:r}})),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{page:r}}}));const s=this.getAttribute("persist");if("storage"===s&&this.id)try{localStorage.setItem("contour-table:"+this.id,String(r))}catch(e){}else if("url"===s&&this.id)try{const t=new URL(window.location.href);t.searchParams.set("c-table-"+this.id,String(r)),window.history.replaceState(null,"",t.toString())}catch(e){}}}),this.addEventListener("keydown",e=>{if("Enter"!==e.key&&" "!==e.key)return;const r=e.target&&e.target.closest?e.target.closest("th[aria-sort]"):null;r&&this.contains(r)&&(e.preventDefault(),t(r))}),this.addEventListener("input",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-table__filter-input"):null;if(!e||!this.contains(e))return;const r=Number(e.dataset.filterIndex);Number.isFinite(r)&&(this._filters||(this._filters={}),this._filters[r]=e.value,this.requestRender(),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{column:r,value:e.value}}})))}),this.addEventListener("scroll",t=>{if(!(this.hasAttribute("virtual")&&t.target&&t.target.classList&&t.target.classList.contains("c-table-wrap")))return;const e=t.target,r=this._measuredRowHeight||cssLength("--data-grid-row-height",32),s=Math.max(0,(this._rowData?this._rowData.length:0)-30),i=Math.min(s,Math.max(0,Math.floor(e.scrollTop/r)-10));if(this._tableWindowStart===i)return;if(this._tableVirtualRaf)return;this._tablePendingScrollTop=e.scrollTop;const a=()=>{this._tableVirtualRaf=0,this.requestRender()};this._tableVirtualRaf="function"==typeof requestAnimationFrame?requestAnimationFrame(a):setTimeout(a,16)},!0),onDispose(this,()=>{this._tableVirtualRaf&&("function"==typeof cancelAnimationFrame?cancelAnimationFrame(this._tableVirtualRaf):clearTimeout(this._tableVirtualRaf),this._tableVirtualRaf=0)}),this._selectedRows=this._selectedRows||new Set,this.addEventListener("change",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-table__row-select"):null;if(e&&this.contains(e)){const t=Number(e.dataset.rowIndex);if(!Number.isFinite(t))return;const r=this._rowKey(this._rowData?this._rowData[t]:void 0);this._selectionControlled?(e.checked?this._selectedKeys.add(r):this._selectedKeys.delete(r),this._syncSelectionRows()):e.checked?this._selectedRows.add(t):this._selectedRows.delete(t),this._applySelectionToDom();const s=Array.from(this._selectedRows),i=this._selectionKeys();return this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{rows:s,key:r,index:t}})),void this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{selectedRows:s,selectedKeys:i}}}))}const r=t.target&&t.target.closest?t.target.closest(".c-table__select-all"):null;if(r&&this.contains(r)){const t=Array.from(this.querySelectorAll(".c-table__row-select"));t.forEach(t=>{t.checked=r.checked}),this._selectionControlled?(t.forEach(t=>{const e=Number(t.dataset.rowIndex),s=this._rowKey(this._rowData?this._rowData[e]:void 0);r.checked?this._selectedKeys.add(s):this._selectedKeys.delete(s)}),this._syncSelectionRows()):this._selectedRows=new Set(r.checked?t.map(t=>Number(t.dataset.rowIndex)):[]),r.indeterminate=!1;const e=Array.from(this._selectedRows),s=this._selectionKeys();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{rows:e}})),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{selectedRows:e,selectedKeys:s}}}))}}),this.addEventListener("mouseover",t=>{const e=t.target&&t.target.closest?t.target.closest("tbody tr"):null;if(!e||!this.contains(e))return;const r=Number(e.dataset.rowIndex);Number.isFinite(r)&&this._hoveredRow!==r&&(this._hoveredRow=r,this.dispatchEvent(new CustomEvent("contour:hover",{bubbles:!0,composed:!0,detail:{row:r}})))}),this.addEventListener("mouseout",t=>{const e=t.target&&t.target.closest?t.target.closest("tbody tr"):null;if(!e||!this.contains(e))return;(t.relatedTarget&&t.relatedTarget.closest?t.relatedTarget.closest("tbody tr"):null)!==e&&(this._hoveredRow=null,this.dispatchEvent(new CustomEvent("contour:leave",{bubbles:!0,composed:!0,detail:{}})))}),this.addEventListener("click",t=>{if(t.target&&t.target.closest&&t.target.closest("input, button, select, textarea, a[href], label"))return;const e=t.target&&t.target.closest?t.target.closest("tbody tr"):null;if(!e||!this.contains(e))return;const r=void 0!==e.dataset.rowIndex?e.dataset.rowIndex:e.dataset.row,s=Number(r);if(!Number.isFinite(s))return;const i=this._rowData&&this._rowData[s]||null;this.dispatchEvent(new CustomEvent("contour:zoom",{bubbles:!0,composed:!0,detail:{row:s,index:s,data:i}}))}),this.addEventListener("keydown",t=>{const e=t.target&&t.target.closest?t.target.closest("tbody tr"):null;if(!e||!this.contains(e))return;const r=Number(e.dataset.rowIndex);if(Number.isFinite(r)){if("ArrowDown"===t.key||"ArrowUp"===t.key||"Home"===t.key||"End"===t.key){const r=Array.from(this.querySelectorAll("tbody tr[data-row-index]")),s=r.indexOf(e);let i=s;if("ArrowDown"===t.key?i=Math.min(r.length-1,s+1):"ArrowUp"===t.key?i=Math.max(0,s-1):"Home"===t.key?i=0:"End"===t.key&&(i=r.length-1),i!==s&&r[i]){t.preventDefault(),r.forEach(t=>t.setAttribute("tabindex","-1")),r[i].setAttribute("tabindex","0");try{r[i].focus()}catch(t){}}return}"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0,detail:{row:r}})))}}),this.addEventListener("contour:clear-all",()=>{let t=!1;this.hasAttribute("sort")&&(this.removeAttribute("sort"),t=!0),this.hasAttribute("sort-dir")&&(this.removeAttribute("sort-dir"),t=!0),null!==this._sortCol&&void 0!==this._sortCol&&(this._sortCol=null,this._sortDir=1,t=!0),this.hasAttribute("page")&&(this.removeAttribute("page"),t=!0),this._filters&&Object.keys(this._filters).length&&(this._filters={},this.querySelectorAll(".c-table__filter-input").forEach(t=>{t.value=""}),t=!0),this._selectedRows&&this._selectedRows.size&&(this._selectedRows.clear(),t=!0),!this._selectionControlled&&this._selectedKeys&&this._selectedKeys.size&&(this._selectedKeys.clear(),t=!0),t&&(this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{sort:null,sortDir:null,page:null,filters:null}}})),this.requestRender())})}}define("contour-table",ContourTable);class ContourDataTable extends ContourTable{render(){super.render(),this.classList.add("c-data-table"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"data-table","Data table"))}}define("contour-data-table",ContourDataTable);class ContourColumnPicker extends ContourBase{static get observed(){return["columns","label"]}static get properties(){return{columns:{attribute:"columns"},label:{attribute:"label"}}}render(){this.classList.add("c-column-picker");const t=this.ensure(".c-column-picker__trigger",()=>{const t=document.createElement("button");return t.type="button",t.className="c-btn c-btn--sm c-column-picker__trigger",t});setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-sliders" /></svg>'),t.appendChild(document.createTextNode(" "+(this.getAttribute("label")||labelText(this,"columns","Columns"))));const e=this.ensure(".c-column-picker__panel",()=>{const t=document.createElement("div");return t.className="c-column-picker__panel",t});let r=[];try{const t=JSON.parse(this.getAttribute("columns")||"[]");Array.isArray(t)&&(r=t)}catch(t){}e.innerHTML="",r.forEach(t=>{const r="string"==typeof t?t:t.label||t.name||t,s="string"==typeof t?t:t.value||t.name||t,i=document.createElement("label");i.className="c-column-picker__item";const a=document.createElement("input");a.type="checkbox",a.checked=!0,a.dataset.column=s,i.appendChild(a),i.appendChild(document.createTextNode(" "+r)),e.appendChild(i)})}enhance(){this._wiredColPicker||(this._wiredColPicker=!0,this.addEventListener("change",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-column-picker__item input"):null;e&&this.contains(e)&&this.dispatchEvent(new CustomEvent("contour:column-toggle",{bubbles:!0,composed:!0,detail:{column:e.dataset.column,visible:e.checked}}))}))}}define("contour-column-picker",ContourColumnPicker);const STREAM_BUFFER_MAX=600,capBuffer=(t,e=600)=>{if(!Array.isArray(t)||t.length<=e)return t;const r=Math.ceil(t.length/e),s=[];for(let e=0;e<t.length;e+=r)s.push(t[e]);const i=t[t.length-1];return s[s.length-1]!==i&&s.push(i),s},patchChildren=(t,e)=>{const r=Array.from(e.childNodes),s=Array.from(t.childNodes),i=Math.max(r.length,s.length);for(let e=0;e<i;e++){const i=s[e],a=r[e];if(i)if(a)if(1===i.nodeType&&1===a.nodeType&&i.tagName===a.tagName){for(const t of Array.from(i.attributes))a.hasAttribute(t.name)||i.removeAttribute(t.name);for(const t of Array.from(a.attributes)){const e=a.getAttribute(t.name);i.getAttribute(t.name)!==e&&i.setAttribute(t.name,e)}patchChildren(i,a)}else 3===i.nodeType&&3===a.nodeType?i.textContent!==a.textContent&&(i.textContent=a.textContent):t.replaceChild(a,i);else t.removeChild(i);else a&&t.appendChild(a)}},normalizeChartBin=t=>{if(!t||"object"!=typeof t)return null;const e=Number(t.x0),r=Number(t.x1),s=Number(t.count);if(!Number.isFinite(e)||!Number.isFinite(r)||!Number.isFinite(s))return null;const i={x0:e,x1:r,count:s},a=Number(t.normalized);return Number.isFinite(a)&&(i.normalized=a),i};class ContourChart extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["series","axis","color","label","legend","brownout","brownout-level","empty","loading","error","retry","skeleton","zoomable","data-table","brush","brush-min","brush-max","brush-start","brush-end","note","bucket-count","limit-values","title","cache-key","dir","src"]}static get properties(){return{series:{attribute:"series"},axis:{attribute:"axis"},color:{attribute:"color"},label:{attribute:"label"},legend:{attribute:"legend"},zoomable:{attribute:"zoomable",type:Boolean},brush:{attribute:"brush",type:Boolean},note:{attribute:"note"},"bucket-count":{attribute:"bucket-count"},"limit-values":{attribute:"limit-values"}}}get bins(){const t=this._pushedBins;return(t&&t.length?t:this._renderedBins||[]).map(t=>({...t}))}set bins(t){this._pushedBins=capBuffer(Array.isArray(t)?t.map(normalizeChartBin).filter(Boolean):[]),this.requestRender()}get backgroundData(){const t=this._pushedBackground;return(t&&t.length?t:this._renderedBackground||[]).map(t=>({...t}))}set backgroundData(t){this._pushedBackground=Array.isArray(t)?t.map(normalizeChartBin).filter(Boolean):[],this.requestRender()}_showsBrush(){return this.hasAttribute("brush")||void 0!==this._rangeOverride}get range(){const t=this._rangeOverride;if(void 0!==t)return t?t.slice():null;if(!this.hasAttribute("brush"))return null;const e=parseFloat(this.getAttribute("brush-start")),r=parseFloat(this.getAttribute("brush-end"));return Number.isFinite(e)&&Number.isFinite(r)?[e,r]:null}set range(t){if(null==t)return this._rangeOverride=null,void this.requestRender();const e=Array.isArray(t)?t:[t,t],r=Number(e[0]),s=Number(e[1]);Number.isFinite(r)&&Number.isFinite(s)&&(this._rangeOverride=[r,s],this.requestRender())}_axisLabel(){const t=this.getAttribute("axis");if(!t)return"";try{const e=JSON.parse(t);if(e&&"object"==typeof e){const t=e.x;return e.label||e.title||e.name||t&&"object"==typeof t&&(t.label||t.title||t.name)||""}return String(e)}catch(e){return t}}_seriesColor(t,e){const r=safeColor(t&&"object"==typeof t?t.color:"");if(r)return r;const s=safeColor(this.getAttribute("color"));return s||"var(--chart-"+(e%12+1)+")"}_legendOff(){const t=(this.getAttribute("legend")||"").trim().toLowerCase();return"off"===t||"false"===t||"none"===t||"0"===t}_applyBrownout(){const t=this.shed("chrome",2),e=this.shed("marks",3),r=this.querySelector(".c-chart__plot");r&&(r.style.backgroundImage=t?"none":"");const s=this.querySelector(".c-chart__axis");s&&(s.style.display=e?"none":"");const i=this.querySelector(".c-chart__note");i&&(i.style.display=e?"none":"");const a=this.querySelector("contour-brush");a&&(a.style.display=e?"none":"")}_axisConfig(){const t=this.getAttribute("axis");if(!t)return null;try{const e=JSON.parse(t);return e&&"object"==typeof e?e:null}catch(t){return null}}_valueDomain(){const t=this.getAttribute("series");if(!t)return null;try{const e=JSON.parse(t);let r=1/0,s=-1/0,i=!1;return(Array.isArray(e)?e:[]).forEach(t=>{!t||"bar"!==t.type&&"histogram"!==t.type&&"stacked"!==t.type||(i=!0),t&&Array.isArray(t.values)&&t.values.forEach(t=>{const e=Number(t);Number.isFinite(e)&&(e<r&&(r=e),e>s&&(s=e))})}),i&&Number.isFinite(r)&&Number.isFinite(s)&&(r=Math.min(0,r),s=Math.max(0,s)),Number.isFinite(r)&&Number.isFinite(s)?[r,s]:null}catch(t){return null}}_renderValueAxis(){const t=this.querySelector(".c-chart__axis");if(!t)return;const e=this._axisConfig(),r=e&&e.y,s=r&&r.domain||this._valueDomain(),i=this.querySelector(".c-chart__axis-x");if(!s)return this.classList.remove("c-chart--value-axis"),t.className="c-chart__axis",t.textContent=this._axisLabel(),void(i&&i.remove());this.classList.add("c-chart--value-axis"),t.className="c-chart__axis c-chart__axis--y";const a=r&&r.ticks||niceTicks(s[0],s[1],5),o=r&&r.format||(t=>String(t));t.textContent="";a.forEach(e=>{const r=document.createElement("span");r.className="c-chart__tick",r.textContent="function"==typeof o?o(e):String(e),t.appendChild(r)}),r&&"object"==typeof r&&(r.label||r.title||r.name)&&t.appendChild(((t,e)=>{const r=document.createElement("span");return r.className="c-chart__tick",r.dataset.axisTitle=e,r.textContent=t,r})(r.label||r.title||r.name,"y"));const n=this._axisLabel();let l=i;n?(l||(l=document.createElement("div"),l.className="c-chart__axis-x",this.appendChild(l)),l.textContent=n):l&&l.remove(),this.style.setProperty("--chart-ticks",String(a.length))}_renderLegend(){const t=this.getAttribute("series");let e=this.querySelector(".c-chart__legend");if(!t||this._legendOff()||this.shed("legend",2))e&&e.remove();else try{const r=JSON.parse(t),s=(Array.isArray(r)?r:[]).map((t,e)=>({s:t,i:e})).filter(t=>t.s&&t.s.label);if(!s.length)return void(e&&e.remove());e||(e=document.createElement("div"),e.className="c-chart__legend",this.appendChild(e)),e.textContent="",s.forEach(({s:t,i:r})=>{const s=document.createElement("span");s.className="c-chart__legend-item";const i=document.createElement("span");i.className="c-chart__legend-swatch",i.style.setProperty("--c",this._seriesColor(t,r)),i.dataset.series=String(r%12+1),i.dataset.style=t.style||"line",s.appendChild(i),s.appendChild(document.createTextNode(t.label)),e.appendChild(s)})}catch(t){}}render(){this.classList.add("c-chart"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-roledescription")||this.setAttribute("aria-roledescription","chart");const t=this.getAttribute("label")||this._axisLabel(),e=this.getAttribute("aria-label");if(!t||null!==e&&e!==this._lastAutoAria||(this.setAttribute("aria-label",t),this._lastAutoAria=t),this.hasAttribute("loading")){this.setAttribute("aria-busy","true");const t=this.ensure(".c-chart__plot",()=>{const t=document.createElement("div");return t.className="c-chart__plot",t});t.innerHTML="";const e=document.createElement("div");e.className="c-chart__loading",e.textContent=this.getAttribute("loading")||"Loading…",e.style.display="grid",e.style.placeItems="center",e.style.height="100%",e.style.color="var(--color-text-muted)",t.appendChild(e);if(this.getAttribute("axis")){this.ensure(".c-chart__axis",()=>{const t=document.createElement("div");return t.className="c-chart__axis",t}).textContent=this._axisLabel()}return}if(this.removeAttribute("aria-busy"),this.hasAttribute("error")){const t=this.ensure(".c-chart__plot",()=>{const t=document.createElement("div");return t.className="c-chart__plot",t});t.innerHTML="";const e=document.createElement("div");if(e.className="c-chart__error",e.textContent=this.getAttribute("error")||"Error",e.style.display="grid",e.style.placeItems="center",e.style.height="100%",e.style.color="var(--color-danger, var(--color-text))",this.hasAttribute("retry")){const t=document.createElement("button");t.className="c-btn c-btn--ghost c-btn--sm",t.type="button",t.textContent=this.getAttribute("retry")||"Retry",t.dataset.action="retry",t.classList.add("u-mbs-sm"),e.appendChild(t)}t.appendChild(e);if(this.getAttribute("axis")){this.ensure(".c-chart__axis",()=>{const t=document.createElement("div");return t.className="c-chart__axis",t}).textContent=this._axisLabel()}return}if(this.hasAttribute("skeleton")){const t=this.ensure(".c-chart__plot",()=>{const t=document.createElement("div");return t.className="c-chart__plot",t});t.innerHTML="";const e=Math.min(5,Math.max(1,parseInt(this.getAttribute("skeleton")||"3",10)||3));for(let r=0;r<e;r++){const e=document.createElement("div");e.className="c-skeleton",e.style.display="block",e.style.inlineSize="100%",e.style.blockSize="0.6rem",e.classList.add("u-mbe-2xs"),t.appendChild(e)}if(this.getAttribute("axis")){this.ensure(".c-chart__axis",()=>{const t=document.createElement("div");return t.className="c-chart__axis",t}).textContent=this._axisLabel()}return}if(this.getAttribute("axis")){this.ensure(".c-chart__axis",()=>{const t=document.createElement("div");return t.className="c-chart__axis",t}).textContent=this._axisLabel()}else{const t=this.querySelector(".c-chart__axis");t&&t.remove()}this._renderValueAxis(),this._renderLegend();let r=this.getAttribute("series");if(!r&&this._pushedBins&&this._pushedBins.length&&(r=JSON.stringify([{type:"histogram",bins:this._pushedBins}])),r){const t=parseArrayAttr(this,"series",warnBadJson);if(0===t.length)return void renderEmpty(this,"chart");const e=this.ensure(".c-chart__plot",()=>{const t=document.createElement("div");return t.className="c-chart__plot",t});this.keepNode(e);const r=document.createDocumentFragment();if(t.some(t=>t&&(Array.isArray(t.values)||Array.isArray(t.bins))))this._renderedBins=[],this._renderedBackground=[],t.forEach((t,e)=>{const s=this._seriesColor(t,e);if("donut"===t.type){const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("viewBox","0 0 200 200"),s.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%",s.setAttribute("role","group"),s.setAttribute("aria-label",t.label||"Donut chart"),donutSlices(t.values).forEach((r,i)=>{const a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("class","c-donut__slice"),a.setAttribute("data-series",String(e+1)),a.dataset.index=String(i),a.style.setProperty("--c",safeColor("var(--chart-"+(i%12+1)+")")||"var(--chart-1)"),a.setAttribute("d",r.path),a.setAttribute("data-title",String(t.values[i])),a.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+": "+String(t.values[i])),a.setAttribute("role","button"),a.setAttribute("tabindex",0===i?"0":"-1"),s.appendChild(a)}),r.appendChild(s)}else if("bar"===t.type){const i=Array.isArray(t.values)?t.values:[],a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("viewBox","0 0 300 120"),a.setAttribute("preserveAspectRatio","none"),a.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%",barRects(i).forEach((t,r)=>{if(t.missing)return;const o=document.createElementNS("http://www.w3.org/2000/svg","rect");o.setAttribute("class","c-chart__bar"),o.setAttribute("data-series",String(e+1)),o.style.setProperty("--c",s),o.setAttribute("x",t.x),o.setAttribute("y",t.y),o.setAttribute("width",t.width),o.setAttribute("height",t.height),o.setAttribute("data-title",String(i[r])),o.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+": "+String(i[r])),o.setAttribute("tabindex","0"),o.setAttribute("role","button"),o.dataset.index=String(r),a.appendChild(o)}),r.appendChild(a)}else if("histogram"===t.type){let i=Array.isArray(t.values)?t.values.slice():[];const a=parseInt(this.getAttribute("limit-values")||"0",10);a>0&&(i=i.slice(0,a));const o=parseInt(this.getAttribute("bucket-count")||"0",10),n=this._pushedBins&&this._pushedBins.length?this._pushedBins:null,l=Array.isArray(t.bins)?t.bins.map(normalizeChartBin).filter(Boolean):null;let c=n||(l&&l.length?l:null),u=i;if(!c&&o>0&&i.length){const t=i.map(t=>Number(t)||0),e=Math.min.apply(null,t),r=(Math.max.apply(null,t)-e||1)/o,s=new Array(o).fill(0);t.forEach(t=>{const i=Math.min(o-1,Math.floor((t-e)/r));s[i]+=1}),u=s,c=s.map((t,s)=>({x0:e+s*r,x1:e+(s+1)*r,count:t}))}c&&(u=c.map(t=>t.count)),this._renderedBins=c?c.slice():[];const d=this._pushedBackground&&this._pushedBackground.length?this._pushedBackground:null,h=Array.isArray(t.background)?t.background.map(normalizeChartBin).filter(Boolean):null,m=d||(h&&h.length?h:[]);this._renderedBackground=m.slice();const b=m.map(t=>Number(t.count)||0);let p=1;b.length&&u.concat(b).forEach(t=>{const e=Number(t)||0;e>p&&(p=e)});const g=document.createElementNS("http://www.w3.org/2000/svg","svg");g.setAttribute("viewBox","0 0 300 120"),g.setAttribute("preserveAspectRatio","none"),g.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%",b.length&&barRects(b,{max:p}).forEach(t=>{const e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("class","c-chart__bar"),e.setAttribute("data-context",""),e.setAttribute("aria-hidden","true"),e.style.setProperty("--c",s),e.setAttribute("x",t.x),e.setAttribute("y",t.y),e.setAttribute("width",t.width),e.setAttribute("height",t.height),g.appendChild(e)}),barRects(u,b.length?{max:p}:void 0).forEach((r,i)=>{if(r.missing)return;const a=document.createElementNS("http://www.w3.org/2000/svg","rect");a.setAttribute("class","c-chart__bar"),a.setAttribute("data-series",String(e+1)),a.style.setProperty("--c",s),a.setAttribute("x",r.x),a.setAttribute("y",r.y),a.setAttribute("width",r.width),a.setAttribute("height",r.height);const o=c?c[i].count:Array.isArray(t.values)?t.values[i]:i;a.setAttribute("data-title",String(o)),a.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+": "+String(o)),a.setAttribute("tabindex","0"),a.setAttribute("role","button"),a.dataset.index=String(i),g.appendChild(a)}),r.appendChild(g)}else if("scatter"===t.type){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("viewBox","0 0 300 120"),i.setAttribute("preserveAspectRatio","none"),i.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const a=(Array.isArray(t.values)?t.values:[]).filter(t=>!isMissing(t)).map(t=>Array.isArray(t)?{x:Number(t[0])||0,y:Number(t[1])||0}:{x:Number(t&&t.x)||0,y:Number(t&&t.y)||0}),o=a.map(t=>t.x),n=a.map(t=>t.y),l=o.length?Math.min.apply(null,o):0,c=o.length?Math.max.apply(null,o):1,u=n.length?Math.min.apply(null,n):0,d=n.length?Math.max.apply(null,n):1,h=c-l||1,m=d-u||1,b=2e3;let p=a;if(a.length>b){const t=Math.ceil(a.length/b);p=a.filter((e,r)=>r%t===0),this.dispatchEvent(new CustomEvent("contour:cap",{bubbles:!0,composed:!0,detail:{series:e+1,total:a.length,shown:p.length}}))}p.forEach((t,r)=>{const a=document.createElementNS("http://www.w3.org/2000/svg","circle");a.setAttribute("class","c-chart__point"),a.setAttribute("data-series",String(e+1)),a.setAttribute("data-index",String(r)),a.style.setProperty("--c",s);const o=(t.x-l)/h*300,n=120-(t.y-u)/m*120;a.setAttribute("cx",o.toFixed(2)),a.setAttribute("cy",n.toFixed(2)),a.setAttribute("r","3"),a.setAttribute("tabindex",0===r?"0":"-1"),a.setAttribute("role","button"),a.setAttribute("data-title",t.x+", "+t.y),a.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+": "+t.x+", "+t.y),i.appendChild(a)}),p.length!==a.length&&(i.setAttribute("data-decimated",String(a.length)),i.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+" ("+p.length+" "+labelText(this,"of","of")+" "+a.length+")")),r.appendChild(i)}else{const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("viewBox","0 0 300 120"),i.setAttribute("preserveAspectRatio","none"),i.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("class","c-chart__line"),a.setAttribute("data-series",String(e+1)),a.style.setProperty("--c",s),a.setAttribute("d",smoothPath(t.values)),i.appendChild(a);const o=t.values.filter(t=>!isMissing(t)).map(Number).filter(t=>Number.isFinite(t)),n=o.reduce((t,e)=>e>t?e:t,o.length?o[0]:1),l=o.reduce((t,e)=>e<t?e:t,o.length?o[0]:0),c=n-l||1,u=t.values.length||1;let d=!0;t.values.forEach((t,r)=>{if(isMissing(t))return;const a=Number(t);if(!Number.isFinite(a))return;const o=r/Math.max(1,u-1)*300,n=120-(a-l)/c*120,h=document.createElementNS("http://www.w3.org/2000/svg","circle");h.setAttribute("class","c-chart__point"),h.setAttribute("data-series",String(e+1)),h.setAttribute("data-index",String(r)),h.style.setProperty("--c",s),h.setAttribute("cx",String(o)),h.setAttribute("cy",String(n)),h.setAttribute("r","3"),h.setAttribute("tabindex",d?"0":"-1"),d=!1,h.setAttribute("role","button"),h.setAttribute("data-title",String(t)),h.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+": "+String(t)),i.appendChild(h)}),r.appendChild(i)}});else{const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox","0 0 300 120"),e.setAttribute("preserveAspectRatio","none"),e.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%",e.setAttribute("aria-hidden","true"),t.forEach((t,r)=>{const s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("class","c-chart__line"),s.setAttribute("data-series",String(r+1)),s.style.setProperty("--c",this._seriesColor(t,r)),s.setAttribute("d","string"==typeof t.d&&t.d.trim()?t.d:Array.isArray(t.values)?smoothPath(t.values):""),e.appendChild(s)}),r.appendChild(e)}if(patchChildren(e,r),this.shed("tooltip",2)){const t=this.querySelector(".c-chart__tooltip");t&&t.remove()}else{this.ensure(".c-chart__tooltip",()=>{const t=document.createElement("div");return t.className="c-chart__tooltip",t.setAttribute("role","tooltip"),t.setAttribute("hidden",""),t.id=contourId("chart-tip"),t}).setAttribute("hidden","")}const s=(this.getAttribute("data-table")||"").trim().toLowerCase(),i="none"===s||"off"===s||"false"===s||"0"===s,a=t.some(t=>Array.isArray(t&&t.values)&&t.values.length);if(!i&&a){let e=this.querySelector(".c-chart__data-table");e||(e=document.createElement("table"),e.className="c-chart__data-table visually-hidden",this.appendChild(e)),e.innerHTML="";const r=this.getAttribute("title")||this.getAttribute("aria-label")||labelText(this,"chart-data","Chart data"),s=document.createElement("caption");s.textContent=r,e.appendChild(s);const i=document.createElement("thead"),a=document.createElement("tr"),o=document.createElement("th");o.setAttribute("scope","col"),o.textContent=labelText(this,"series","Series"),a.appendChild(o);const n=t.reduce((t,e)=>Math.max(t,Array.isArray(e.values)?e.values.length:Array.isArray(e)?e.length:0),0);for(let t=0;t<n;t++){const e=document.createElement("th");e.setAttribute("scope","col"),e.textContent=labelText(this,"value","Value")+" "+(t+1),a.appendChild(e)}i.appendChild(a),e.appendChild(i);const l=document.createElement("tbody");t.forEach((t,e)=>{const r=Array.isArray(t.values)?t.values:Array.isArray(t)?t:[],s=document.createElement("tr"),i=document.createElement("th");i.setAttribute("scope","row"),i.textContent=t.label||"Series "+(e+1),s.appendChild(i);for(let t=0;t<n;t++){const e=document.createElement("td");e.textContent=isMissing(r[t])?"":String(r[t]),s.appendChild(e)}l.appendChild(s)}),e.appendChild(l)}else{const t=this.querySelector(".c-chart__data-table");t&&t.remove()}if(this._showsBrush()){const t=this.ensure("contour-brush",()=>document.createElement("contour-brush")),e=this._renderedBins||[],r=this.getAttribute("brush-min")||(e.length?String(e[0].x0):"0"),s=this.getAttribute("brush-max")||(e.length?String(e[e.length-1].x1):"100"),i=Array.isArray(this._rangeOverride)?this._rangeOverride:null,a=null===this._rangeOverride;t.setAttribute("min",r),t.setAttribute("max",s),t.setAttribute("start",i?String(i[0]):a?r:this.getAttribute("brush-start")||r),t.setAttribute("end",i?String(i[1]):a?s:this.getAttribute("brush-end")||s);const o=this.querySelector(".c-chart__plot");t.previousElementSibling!==o&&this.insertBefore(t,o?o.nextSibling:null)}else{const t=this.querySelector("contour-brush");t&&t.remove()}const o=this.getAttribute("note");let n=this.querySelector(".c-chart__note");o?(n||(n=document.createElement("div"),n.className="c-chart__note",this.appendChild(n)),n.textContent=o):n&&n.remove()}else{this._renderedBins=[],this._renderedBackground=[];const t=this.ensure(".c-chart__plot",()=>{const t=document.createElement("div");return t.className="c-chart__plot",t});t.innerHTML="";const e=document.createElement("div");e.className="c-chart__empty",e.textContent=this.getAttribute("empty")||"No data",e.style.display="grid",e.style.placeItems="center",e.style.height="100%",e.style.color="var(--color-text-muted)",t.appendChild(e);const r=this.getAttribute("note");let s=this.querySelector(".c-chart__note");r?(s||(s=document.createElement("div"),s.className="c-chart__note",this.appendChild(s)),s.textContent=r):s&&s.remove()}this._applyBrownout()}enhance(){if(this._wiredChart)return;this._wiredChart=!0,wireStates(this);const t=this.parentElement||document,e=t=>{const e=t&&t.detail&&(null!=t.detail.key?t.detail.key:t.detail.label),r=t&&t.detail&&t.detail.index,s=t&&t.detail&&t.detail.pressed;if(null==e&&null==r)return;this.querySelectorAll("[data-series]").forEach(t=>{const i=t.getAttribute("data-series");(String(i)===String(e)||t.getAttribute("data-key")===String(e)||null!=r&&String(i)===String(r+1))&&(t.style.display=!1===s?"none":"")})};if(t.addEventListener("contour:legend-toggle",e),onDispose(this,()=>t.removeEventListener("contour:legend-toggle",e)),this.addEventListener("contour:brush-end",t=>{this._showsBrush()&&t.target&&t.target.matches("contour-brush")&&(void 0!==this._rangeOverride&&t.detail&&Array.isArray(t.detail.range)&&(this._rangeOverride=t.detail.range.slice()),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:t.detail})))}),this.hasAttribute("zoomable")){let t=1,e=0,r=0;const s=this.querySelector(".c-chart__plot"),i=()=>{s&&(s.style.transform=`translate(${e}px, ${r}px) scale(${t})`,s.style.transformOrigin="center center")};this.addEventListener("wheel",e=>{e.preventDefault();const r=e.deltaY<0?1.1:.9;t=Math.min(5,Math.max(.5,t*r)),i()},{passive:!1});let a=!1,o=0,n=0,l=0,c=0;this.addEventListener("mousedown",t=>{0===t.button&&(a=!0,o=t.clientX,n=t.clientY,l=e,c=r,this.style.cursor="grabbing")});const u=t=>{a&&(e=l+(t.clientX-o),r=c+(t.clientY-n),i())},d=()=>{a&&(a=!1,this.style.cursor="")};window.addEventListener("mousemove",u),window.addEventListener("mouseup",d),onDispose(this,()=>{window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",d)}),this.addEventListener("dblclick",()=>{t=1,e=0,r=0,i()})}let r=null,s=null;const i=()=>{r=null},a=t=>{const e=this.querySelector(".c-chart__plot"),a=this.querySelector(".c-chart__tooltip");if(!e||!a)return;const o=t.target&&t.target.closest?t.target.closest(".c-chart__bar, .c-chart__point, .c-chart__line, .c-donut__slice"):null;if(!o||!e.contains(o))return void a.setAttribute("hidden","");const n=o.getAttribute("data-title")||o.getAttribute("title");n&&(a.textContent=n),r||(r=e.getBoundingClientRect(),s||"function"!=typeof ResizeObserver||(s=new ResizeObserver(i),s.observe(e)));const l=r,c=o.getBoundingClientRect(),u=c.left-l.left+c.width/2,d=c.top-l.top;e.style.setProperty("--chart-tip-inline-start",u+"px"),e.style.setProperty("--chart-tip-block-start",d+"px"),a.removeAttribute("hidden")},o=()=>{const t=this.querySelector(".c-chart__tooltip");t&&t.setAttribute("hidden","")};this.addEventListener("mousemove",a),this.addEventListener("mouseleave",o),onDispose(this,()=>{s&&(s.disconnect(),s=null)}),this.addEventListener("focusin",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-chart__bar, .c-chart__point, .c-chart__line, .c-donut__slice"):null;if(e&&this.contains(e)){a({target:e});const t=this.querySelector(".c-chart__tooltip");t&&t.id&&e.setAttribute("aria-describedby",t.id)}}),this.addEventListener("focusout",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-chart__bar, .c-chart__point, .c-chart__line, .c-donut__slice"):null;e&&this.contains(e)&&e.removeAttribute("aria-describedby"),this.contains(t.relatedTarget)||o()}),this.addEventListener("click",t=>{const e=this.querySelector(".c-chart__plot");if(!e)return;const r=t.target&&t.target.closest?t.target.closest(".c-chart__bar"):null;if(r&&e.contains(r)){const t=parseInt(r.getAttribute("data-series")||"1",10),e=parseInt(r.dataset.index||"0",10);return void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:t,index:e}}))}const s=t.target&&t.target.closest?t.target.closest(".c-chart__point"):null;if(s&&e.contains(s)){const t=parseInt(s.getAttribute("data-series")||"1",10),e=parseInt(s.dataset.index||"0",10);return void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:t,index:e}}))}const i=t.target&&t.target.closest?t.target.closest(".c-donut__slice"):null;if(i&&e.contains(i)){const t=parseInt(i.getAttribute("data-series")||"1",10),e=parseInt(i.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:t,index:e,value:i.getAttribute("data-title")||i.getAttribute("title")}}))}}),this.addEventListener("keydown",t=>{const e=this.querySelector(".c-chart__plot");if(!e)return;const r=t.target&&t.target.closest?t.target.closest(".c-chart__bar"):null;if(r&&e.contains(r)){if("Enter"===t.key||" "===t.key){t.preventDefault();const e=parseInt(r.getAttribute("data-series")||"1",10),s=parseInt(r.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:e,index:s}}))}const s=r.getAttribute("data-series");if(s){const i=parseInt(s,10),a=Array.from(e.querySelectorAll('.c-chart__bar[data-series="'+i+'"]'));a.indexOf(r)>=0&&navKey(t,a,{wrap:!1,rtl:isRtl(this),onNavigate:t=>a.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{}})}return}const s=t.target&&t.target.closest?t.target.closest(".c-donut__slice"):null;if(s&&e.contains(s)){const r=parseInt(s.getAttribute("data-series")||"1",10);if("Enter"===t.key||" "===t.key){t.preventDefault();const e=parseInt(s.dataset.index||"0",10);return void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:r,index:e,value:s.getAttribute("data-title")||s.getAttribute("title")}}))}const i=Array.from(e.querySelectorAll('.c-donut__slice[data-series="'+r+'"]'));return void navKey(t,i,{wrap:!1,rtl:isRtl(this),onNavigate:t=>i.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{}})}const i=t.target&&t.target.closest?t.target.closest(".c-chart__point"):null;if(!i||!e.contains(i))return;const a=parseInt(i.getAttribute("data-series")||"1",10),o=Array.from(e.querySelectorAll('.c-chart__point[data-series="'+a+'"]'));o.indexOf(i);if("Enter"===t.key||" "===t.key){t.preventDefault();const e=parseInt(i.dataset.index||"0",10);return void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:a,index:e}}))}navKey(t,o,{wrap:!1,rtl:isRtl(this),onNavigate:t=>o.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{}})}),this.addEventListener("keydown",t=>{if(t.target!==this)return;let e=0;try{e=JSON.parse(this.getAttribute("series")||"[]").length}catch(t){e=0}if(0===e)return;void 0===this._activeSeries&&(this._activeSeries=0);let r=this._activeSeries;const s="rtl"===(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase();if("ArrowRight"===t.key)r=s?Math.max(this._activeSeries-1,0):Math.min(this._activeSeries+1,e-1);else if("ArrowLeft"===t.key)r=s?Math.min(this._activeSeries+1,e-1):Math.max(this._activeSeries-1,0);else if("ArrowDown"===t.key)r=Math.min(this._activeSeries+1,e-1);else if("ArrowUp"===t.key)r=Math.max(this._activeSeries-1,0);else if("Home"===t.key)r=0;else{if("End"!==t.key)return"Enter"===t.key||" "===t.key?(t.preventDefault(),void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:this._activeSeries}}))):void 0;r=e-1}r!==this._activeSeries&&(t.preventDefault(),this._activeSeries=r,this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:r}})))}),this.addEventListener("contour:clear-all",()=>{this.hasAttribute("brush")&&(this.removeAttribute("brush"),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"chart",filter:{brush:null}}})),this.requestRender())})}}define("contour-chart",ContourChart);class ContourComparison extends ContourBase{static get observed(){return["divider","value","before","after","before-src","after-src"]}static get properties(){return{divider:{attribute:"divider"},value:{attribute:"value"},before:{attribute:"before"},after:{attribute:"after"},beforeSrc:{attribute:"before-src"},afterSrc:{attribute:"after-src"}}}render(){this.classList.add("c-comparison"),this.setAttribute("role","group");const t="Comparison",e=this.getAttribute("aria-label");null!==e&&e!==this._lastAutoAria||(this.setAttribute("aria-label",t),this._lastAutoAria=t),this.style.blockSize||(this.style.blockSize="12rem");const r=this.getAttribute("value");this.style.setProperty("--comparison-pos",(r??"50")+"%");const s=this.getAttribute("before")??"Before",i=this.getAttribute("after")??"After";if(!this.querySelector(".c-comparison__pane--before")){const t=document.createElement("div");t.className="c-comparison__pane c-comparison__pane--before",this.appendChild(t)}if(!this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)")){const t=document.createElement("div");t.className="c-comparison__pane",this.appendChild(t)}const a=(t,e,r)=>{if(!t)return;let s=t.querySelector(".c-comparison__media--"+r);e?(s||(s=document.createElement("img"),s.className="c-comparison__media c-comparison__media--"+r,s.alt="",t.prepend(s)),s.getAttribute("src")!==e&&s.setAttribute("src",e)):s&&s.remove()};a(this.querySelector(".c-comparison__pane--before"),this.getAttribute("before-src"),"before"),a(this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)"),this.getAttribute("after-src"),"after");const o=this.querySelector(".c-comparison__pane--before");if(o){let t=o.querySelector(".c-comparison__label--before");t||(t=document.createElement("span"),t.className="c-comparison__label c-comparison__label--before",o.appendChild(t)),t.textContent=s}const n=this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)");if(n){let t=n.querySelector(".c-comparison__label--after");t||(t=document.createElement("span"),t.className="c-comparison__label c-comparison__label--after",n.appendChild(t)),t.textContent=i}const l=this.getAttribute("divider");if(null!==l){const t=this.ensure(".c-comparison__divider",()=>{const t=document.createElement("div");return t.className="c-comparison__divider",t.setAttribute("role","slider"),t.setAttribute("aria-orientation","vertical"),t.setAttribute("aria-valuemin","0"),t.setAttribute("aria-valuemax","100"),t.setAttribute("aria-valuenow",String(Math.round(parseFloat(r??"50")))),t.setAttribute("aria-label",labelText(this,"comparison-divider","Comparison divider")),t.setAttribute("tabindex","0"),t});l&&(t.textContent=l)}else{const t=this.querySelector(".c-comparison__divider");t&&t.remove()}}enhance(){if(this._wiredComparison)return;this._wiredComparison=!0;const t=()=>this.querySelector(".c-comparison__divider"),e=t=>{const e=Math.max(0,Math.min(100,t));this.style.setProperty("--comparison-pos",e+"%"),this.setAttribute("value",String(Math.round(e)));const r=this.querySelector(".c-comparison__divider");r&&r.setAttribute("aria-valuenow",String(Math.round(e))),this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:!0,composed:!0,detail:{value:e}}))};let r=!1;const s=t=>{if(!r)return;const s=this.getBoundingClientRect(),i=(t.clientX-s.left)/s.width*100;e(i)},i=()=>{r=!1,window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",i)};onDispose(this,()=>{r=!1,window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",i)}),this.addEventListener("pointerdown",s=>{const i=t();if(!i||!i.contains(s.target))return;r=!0;try{this.setPointerCapture(s.pointerId)}catch(t){}const a=this.getBoundingClientRect(),o=(s.clientX-a.left)/a.width*100;e(o),s.preventDefault()}),this.addEventListener("pointermove",t=>{if(!r)return;const s=this.getBoundingClientRect(),i=(t.clientX-s.left)/s.width*100;e(i)});const a=()=>{r=!1;try{this.releasePointerCapture&&this.releasePointerCapture(this._comparisonPointer)}catch(t){}this._comparisonPointer=null};this.addEventListener("pointerup",a),this.addEventListener("pointercancel",a),onDispose(this,()=>{this.removeEventListener("pointerup",a),this.removeEventListener("pointercancel",a)}),this.addEventListener("keydown",r=>{const s=t();if(!s||document.activeElement!==s)return;const i=parseFloat(this.style.getPropertyValue("--comparison-pos"))||50;"ArrowLeft"===r.key?(r.preventDefault(),e(i-5)):"ArrowRight"===r.key?(r.preventDefault(),e(i+5)):"Home"===r.key?(r.preventDefault(),e(0)):"End"===r.key&&(r.preventDefault(),e(100))})}}define("contour-comparison",ContourComparison);class ContourStreamingChart extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["line","dot","values","interval","pause","brownout","brownout-level","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{line:{attribute:"line"},dot:{attribute:"dot"},interval:{attribute:"interval",type:Number},pause:{attribute:"pause",type:Boolean},src:{attribute:"src"}}}get values(){return(this._valuesNums||[]).slice()}set values(t){this._pushedValues=capBuffer(Array.isArray(t)?t.map(Number).filter(Number.isFinite):[]),this.requestRender()}render(){this.classList.add("c-streaming-chart"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"streaming-chart","Streaming chart")),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");let t=this.querySelector(".c-streaming-chart__pause");t||(t=document.createElement("button"),t.className="c-btn c-btn--icon c-btn--ghost c-btn--sm c-streaming-chart__pause",t.type="button",this.appendChild(t));const e=!!this._streamPausedByUser;if(t.setAttribute("aria-pressed",String(e)),t.setAttribute("aria-label",e?labelText(this,"play-stream","Play stream"):labelText(this,"pause-stream","Pause stream")),setHTML(t,e?'<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>'),wireStates(this),loadRemote(this,["line","values"]),renderStates(this,"streaming-chart"))return;let r=remoteData(this,"line"),s=remoteData(this,"dot"),i=this._pushedValues;if(void 0===i){i=null;const t=remoteData(this,"values");if(t)try{const e=JSON.parse(t);Array.isArray(e)?i=e:warnBadJson(this,"values",new Error("not an array"))}catch(t){warnBadJson(this,"values",t)}}if(i=capBuffer((i||[]).map(Number).filter(Number.isFinite)),this._valuesNums=[],!r&&i.length>1&&(r=smoothPath(i,{width:300,height:192}),this._valuesNums=i,!s)){const t=polylinePoints(i,{width:300,height:192}).split(" ");s=t[t.length-1]}if(!r){const t=this.querySelector(":scope > .c-streaming-chart__plot");return t&&t.remove(),void renderEmpty(this,"streaming-chart")}if(r){let t=this.querySelector(":scope > .c-streaming-chart__plot");t||(t=document.createElementNS("http://www.w3.org/2000/svg","svg"),t.setAttribute("class","c-streaming-chart__plot"),t.setAttribute("viewBox","0 0 300 192"),t.setAttribute("aria-hidden","true"),this.appendChild(t));let e=t.querySelector(".c-streaming-chart__line");if(e||(e=document.createElementNS("http://www.w3.org/2000/svg","path"),e.setAttribute("class","c-streaming-chart__line"),t.appendChild(e)),e.setAttribute("d",r),s&&!this.shed("dot",2)){let e=t.querySelector(".c-streaming-chart__live-dot");e||(e=document.createElementNS("http://www.w3.org/2000/svg","circle"),e.setAttribute("class","c-streaming-chart__live-dot"),e.setAttribute("r","4"),t.appendChild(e));const r=s.split(/[ ,]+/);r.length>=2&&(e.setAttribute("cx",r[0]),e.setAttribute("cy",r[1]))}else{const e=t.querySelector(".c-streaming-chart__live-dot");e&&e.remove()}}}enhance(){const t=()=>{const t=parseFloat(this.getAttribute("interval")||""),e=Number.isFinite(t)&&t>0&&!this.hasAttribute("pause")&&!this._streamPausedByUser&&!1!==this._viewVisible;e!==this._streamRunning&&(this._streamRunning=e,void 0!==this._streamTimer&&(clearInterval(this._streamTimer),this._streamTimer=void 0),this.dispatchEvent(new CustomEvent("contour:stream-state",{detail:{running:e},bubbles:!0,composed:!0})),e&&(this._streamTimer=setInterval(()=>{if(!this.isConnected||this.hasAttribute("pause"))return;this._streamFrame+=1,this.dispatchEvent(new CustomEvent("contour:tick",{detail:{frame:this._streamFrame},bubbles:!0,composed:!0}));const t=this.getAttribute("src");t&&(remoteInvalidate(t),this.requestRender())},Math.max(1e3,1e3*t))))};t(),this._wiredStreamView||(this._wiredStreamView=!0,this._viewVisible=!0,watchViewport(this),this.addEventListener("contour:view-enter",()=>{this._viewVisible=!0,t()}),this.addEventListener("contour:view-leave",()=>{this._viewVisible=!1,t()})),this._wiredStream||(this._wiredStream=!0,this._streamFrame=0,onDispose(this,()=>{void 0!==this._streamTimer&&(clearInterval(this._streamTimer),this._streamTimer=void 0)}),this._streamPausedByUser=!1,this.addEventListener("click",e=>{const r=e.target,s=this.querySelector(".c-streaming-chart__pause");s&&(r===s||s.contains(r))&&(e.preventDefault(),this._streamPausedByUser=!this._streamPausedByUser,s.setAttribute("aria-pressed",String(this._streamPausedByUser)),s.setAttribute("aria-label",this._streamPausedByUser?"Play stream":"Pause stream"),setHTML(s,this._streamPausedByUser?'<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>'),this._streamPausedByUser?(this.setAttribute("data-user-paused",""),this.setAttribute("data-motion","paused")):(this.removeAttribute("data-user-paused"),this.removeAttribute("data-motion")),t())}),this.addEventListener("keydown",e=>{if(" "===e.key||"Enter"===e.key){e.preventDefault(),this._streamPausedByUser=!this._streamPausedByUser,this._streamPausedByUser?(this.setAttribute("data-user-paused",""),this.setAttribute("data-motion","paused")):(this.removeAttribute("data-user-paused"),this.removeAttribute("data-motion"));const r=this.querySelector(".c-streaming-chart__pause");r&&(r.setAttribute("aria-pressed",String(this._streamPausedByUser)),r.setAttribute("aria-label",this._streamPausedByUser?"Play stream":"Pause stream")),t()}}))}}define("contour-streaming-chart",ContourStreamingChart);class ContourReferenceRule extends ContourBase{static get observed(){return["value","direction","label","band"]}static get properties(){return{value:{attribute:"value"},direction:{attribute:"direction"},label:{attribute:"label"},band:{attribute:"band"}}}render(){this.classList.add("c-reference-rule");const t=this.getAttribute("direction")||"horizontal";this.setAttribute("data-direction",t);let e=this.querySelector(".c-reference-rule__line");e||(e=document.createElement("div"),e.className="c-reference-rule__line",this.appendChild(e));const r=this.getAttribute("band");r?this.setAttribute("data-band",r):this.removeAttribute("data-band");const s=this.getAttribute("label");let i=this.querySelector(".c-reference-rule__label");s?(i||(i=document.createElement("span"),i.className="c-reference-rule__label",this.appendChild(i)),i.textContent=s):i&&i.remove()}}define("contour-reference-rule",ContourReferenceRule);class ContourMeter extends ContourBase{static get observed(){return["value","label","variant","min","max","low","high","optimum","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},variant:{attribute:"variant"},min:{attribute:"min"},max:{attribute:"max"},low:{attribute:"low"},high:{attribute:"high"},optimum:{attribute:"optimum"},src:{attribute:"src"}}}render(){if(this.classList.add("c-meter"),wireStates(this),loadRemote(this,["value","label"]),renderStates(this,"meter"))return;const t=remoteData(this,"value")||this._remoteData&&this._remoteData.value,e=remoteData(this,"label")||this._remoteData&&this._remoteData.label||"",r=this.getAttribute("variant");if(Array.from(this.classList).forEach(t=>{t.startsWith("c-meter--")&&this.classList.remove(t)}),r&&this.classList.add("c-meter--"+r),!t&&!e)return void renderEmpty(this,"meter");if(null===t)this.style.removeProperty("--meter-value");else{const e=parseFloat(t),r=parseFloat(this.getAttribute("min"))||0,s=parseFloat(this.getAttribute("max"))||100;if(Number.isFinite(e)){const t=s>r?Math.min(1,Math.max(0,(e-r)/(s-r))):0;this.style.setProperty("--meter-value",String(t))}else this.style.removeProperty("--meter-value")}const s=this.ensure(".c-meter__core",()=>{const t=document.createElement("span");return t.className="c-meter__core",t});let i=s.querySelector(".c-meter__value");i||(i=document.createElement("span"),i.className="c-meter__value",s.appendChild(i));const a=parseFloat(t),o=parseFloat(this.getAttribute("min"))||0,n=parseFloat(this.getAttribute("max"))||100,l=Number.isFinite(a)&&n>o?Math.min(1,Math.max(0,(a-o)/(n-o))):0;if(i.textContent=Math.round(100*l)+"%",e){(s.querySelector(".c-meter__label")||(()=>{const t=document.createElement("span");return t.className="c-meter__label",s.appendChild(t),t})()).textContent=e}this.hasAttribute("role")||this.setAttribute("role","meter"),e&&!this.hasAttribute("aria-label")&&this.setAttribute("aria-label",e);const c=Number.isFinite(a)?String(a):"0",u=this._meterAriaValue;this.hasAttribute("aria-valuenow")&&this.getAttribute("aria-valuenow")!==u||(this.setAttribute("aria-valuenow",c),this._meterAriaValue=c);const d=this.getAttribute("min"),h=this.getAttribute("max");null!==d?this.setAttribute("aria-valuemin",d):this.setAttribute("aria-valuemin",String(o)),null!==h?this.setAttribute("aria-valuemax",h):this.setAttribute("aria-valuemax",String(n));for(const t of["low","high","optimum"]){const e=this.getAttribute(t);null!==e?this.setAttribute("data-"+t,e):this.removeAttribute("data-"+t)}}}define("contour-meter",ContourMeter);class ContourDelta extends ContourBase{static get observed(){return["value","direction","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{value:{attribute:"value"},direction:{attribute:"direction"},src:{attribute:"src"}}}render(){if(this.classList.add("c-delta"),wireStates(this),loadRemote(this,"value"),renderStates(this,"delta"))return;const t=remoteData(this,"value")||"";Array.from(this.classList).forEach(t=>{t.startsWith("c-delta--")&&this.classList.remove(t)});const e=this.getAttribute("direction")||this._remoteData&&this._remoteData.direction||"up";if(!t)return void renderEmpty(this,"delta");this.classList.add("c-delta--"+e);const r={up:"#i-arrow-up",down:"#i-arrow-down",flat:"#i-minus"}[e]||"#i-arrow-up";this.querySelectorAll("svg").forEach(t=>t.remove());const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("aria-hidden","true");const i=document.createElementNS("http://www.w3.org/2000/svg","use");i.setAttribute("href",r),s.appendChild(i),this.appendChild(s),this.appendChild(document.createTextNode(" "+t))}}define("contour-delta",ContourDelta);class ContourStat extends ContourBase{static get observed(){return["value","label","delta","unit","format","locale","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},delta:{attribute:"delta"},unit:{attribute:"unit"},format:{attribute:"format"},locale:{attribute:"locale"},src:{attribute:"src"}}}render(){if(this.classList.add("c-stat"),wireStates(this),loadRemote(this,["value","label"]),renderStates(this,"stat"))return;const t=remoteData(this,"value"),e=remoteData(this,"label"),r=this.getAttribute("delta");if(t){this.ensure(".c-stat__value",()=>{const t=document.createElement("div");return t.className="c-stat__value",t.setAttribute("aria-live","polite"),t}).textContent=formatValue(t,this.getAttribute("format"),this.getAttribute("locale"),this.getAttribute("unit"))}else{const t=this.querySelector(".c-stat__value");t&&t.remove()}if(e){this.ensure(".c-stat__label",()=>{const t=document.createElement("div");return t.className="c-stat__label",t}).textContent=e}else{const t=this.querySelector(".c-stat__label");t&&t.remove()}if(r){this.ensure(".c-stat__delta",()=>{const t=document.createElement("div");return t.className="c-stat__delta",t}).textContent=r}else{const t=this.querySelector(".c-stat__delta");t&&t.remove()}const s=this.getAttribute("unit"),i=this.querySelector(".c-stat__value");if(i)if(s){let t=i.querySelector(".c-stat__unit");t||(t=document.createElement("span"),t.className="c-stat__unit",i.appendChild(t)),t.textContent=s}else{const t=i.querySelector(".c-stat__unit");t&&t.remove()}t||e||renderEmpty(this,"stat")}}define("contour-stat",ContourStat);class ContourGauge extends ContourBase{static get observed(){return["value","min","max","heading","thresholds","format","locale","unit","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","brownout","brownout-level","no-data-message","show-header","description","cache-key","no-cache"]}static get properties(){return{value:{attribute:"value"},min:{attribute:"min"},max:{attribute:"max"},heading:{attribute:"heading"},thresholds:{attribute:"thresholds"},format:{attribute:"format"},locale:{attribute:"locale"},unit:{attribute:"unit"},src:{attribute:"src"},brownout:{attribute:"brownout"}}}render(){if(this.classList.add("c-gauge"),wireStates(this),loadRemote(this,["value"]),renderStates(this,"gauge"))return;const t=this.getAttribute("value"),e=parseFloat(t),r=null!==t&&""!==t&&Number.isFinite(e),s=Number.isFinite(parseFloat(this.getAttribute("min")))?parseFloat(this.getAttribute("min")):0,i=Number.isFinite(parseFloat(this.getAttribute("max")))?parseFloat(this.getAttribute("max")):100,a=this.getAttribute("heading"),o="false"!==this.getAttribute("show-header"),n=this.getAttribute("description"),l=this.getAttribute("no-data-message")||"No readings in view";this.brownoutLevel();if(!r){if(a&&o){this.ensure(".c-gauge__title",()=>{const t=document.createElement("div");return t.className="c-gauge__title",t}).textContent=a}return this.ensure(".c-gauge__empty",()=>{const t=document.createElement("div");return t.className="c-gauge__empty",t.setAttribute("part","empty"),t}).textContent=l,void[".c-gauge__dial",".c-gauge__value",".c-gauge__band"].forEach(t=>{const e=this.querySelector(t);e&&e.remove()})}if(a&&o){this.ensure(".c-gauge__title",()=>{const t=document.createElement("div");return t.className="c-gauge__title",t.setAttribute("part","title"),t}).textContent=a}else{const t=this.querySelector(".c-gauge__title");t&&t.remove()}let c=[];const u=this.getAttribute("thresholds");if(u)try{const t=JSON.parse(u);Array.isArray(t)?c=t:warnBadJson(this,"thresholds",new Error("not an array"))}catch(t){c=[]}let d=null;if(c&&c.length){const t=[...c].sort((t,e)=>(t.value||0)-(e.value||0));for(let r=t.length-1;r>=0;r--)if(e>=(t[r].value||0)){d=t[r];break}}const h=this.shed("dial",3);let m=this.querySelector(".c-gauge__dial");if(h)m&&m.remove();else{m||(m=document.createElementNS("http://www.w3.org/2000/svg","svg"),m.setAttribute("class","c-gauge__dial"),m.setAttribute("part","dial"),m.setAttribute("aria-hidden","true"),m.setAttribute("viewBox","0 0 100 100"),this.appendChild(m)),m.innerHTML="";const t=document.createElementNS("http://www.w3.org/2000/svg","path");if(t.setAttribute("class","c-gauge__track"),t.setAttribute("d","M 10 90 A 40 40 0 0 1 90 90"),m.appendChild(t),c&&c.length){const t=[...c].sort((t,e)=>(t.value||0)-(e.value||0)),e=t=>{const e=(1-(t-s)/(i-s||1))*Math.PI;return{x:50+40*Math.cos(e),y:90-40*Math.sin(e)}};for(let r=0;r<t.length;r++){const s=t[r].value||0,a=r+1<t.length&&t[r+1].value||i,o=e(s),n=e(a),l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("class","c-gauge__zone"),l.setAttribute("stroke",t[r].color||"var(--color-primary)"),l.setAttribute("d","M "+o.x.toFixed(2)+" "+o.y.toFixed(2)+" A 40 40 0 0 1 "+n.x.toFixed(2)+" "+n.y.toFixed(2)),m.appendChild(l)}}const r=Math.max(0,Math.min(1,(e-s)/(i-s||1))),a=Math.PI*(1-r),o=document.createElementNS("http://www.w3.org/2000/svg","line");o.setAttribute("class","c-gauge__needle needle"),o.setAttribute("x1","50"),o.setAttribute("y1","90"),o.setAttribute("x2",String(50+35*Math.cos(a))),o.setAttribute("y2",String(90-35*Math.sin(a))),m.appendChild(o);const n=document.createElementNS("http://www.w3.org/2000/svg","circle");n.setAttribute("class","c-gauge__hub hub"),n.setAttribute("cx","50"),n.setAttribute("cy","90"),n.setAttribute("r","4"),m.appendChild(n)}const b=this.ensure(".c-gauge__value",()=>{const t=document.createElement("div");return t.className="c-gauge__value",t.setAttribute("part","value"),t});b.textContent=formatValue(String(e),this.getAttribute("format"),this.getAttribute("locale"))+(this.getAttribute("unit")?" "+this.getAttribute("unit"):""),b.setAttribute("role","meter");const p=Math.max(s,Math.min(i,e));b.setAttribute("aria-valuenow",String(p)),b.setAttribute("aria-valuemin",String(s)),b.setAttribute("aria-valuemax",String(i)),a&&(b.id||(b.id=contourId("gauge-value"))),d?b.setAttribute("aria-valuetext",e+", "+(d.label||">= "+d.value)):b.setAttribute("aria-valuetext",String(e));const g=this.querySelector(".c-gauge__title");g?(g.id||(g.id=contourId("gauge-title")),b.setAttribute("aria-labelledby",g.id),b.removeAttribute("aria-label")):(b.removeAttribute("aria-labelledby"),a?b.setAttribute("aria-label",a):b.setAttribute("aria-label",b.textContent||"Gauge"));const _=this.querySelector(".c-gauge__band");if(d){this.ensure(".c-gauge__band",()=>{const t=document.createElement("div");return t.className="c-gauge__band",t.setAttribute("part","band"),t}).textContent=d.label||">= "+d.value}else _&&_.remove();if(n){let t=this.querySelector(".c-gauge__desc");t||(t=document.createElement("div"),t.className="c-gauge__desc",this.appendChild(t)),t.textContent=n}}enhance(){}}define("contour-gauge",ContourGauge);class ContourAxis extends ContourBase{static get observed(){return["orientation","values","ticks","format","locale","min","max","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{orientation:{attribute:"orientation"},values:{attribute:"values"},ticks:{attribute:"ticks"},format:{attribute:"format"},locale:{attribute:"locale"},min:{attribute:"min"},max:{attribute:"max"},src:{attribute:"src"}}}render(){this.classList.add("c-axis"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"axis","Axis"));const t=this.getAttribute("orientation")||"horizontal";if(this.classList.toggle("c-axis--horizontal","horizontal"===t),this.classList.toggle("c-axis--vertical","vertical"===t),"horizontal"===t?this.setAttribute("part","axis-x"):this.setAttribute("part","axis-y"),wireStates(this),loadRemote(this,["values"]),renderStates(this,"axis"))return;let e=[];const r=this.getAttribute("values");if(r)try{e=JSON.parse(r)}catch(t){e=r.split(",").map(t=>t.trim())}const s=parseInt(this.getAttribute("ticks")||"0",10)||e.length,i=Array.from(this.querySelectorAll(":scope > .c-axis__tick"));if(this.classList.toggle("c-axis--value-ticks",!i.length),i.length)i.forEach(t=>{const e=t.querySelector(".c-axis__label");e&&!e.textContent&&(e.textContent=t.textContent)});else{Array.from(this.querySelectorAll(".c-axis__tick")).forEach(t=>t.remove());const t=e.length?e:Array.from({length:s},(t,e)=>e),r=t.map(t=>Number(t)).filter(Number.isFinite);let i=r.length?Math.min(...r):0,a=r.length?Math.max(...r):0;const o=parseFloat(this.getAttribute("min")),n=parseFloat(this.getAttribute("max"));Number.isFinite(o)&&(i=o),Number.isFinite(n)&&(a=n);const l=a-i||1;t.forEach(t=>{const e=document.createElement("span");e.className="c-axis__tick";const r=document.createElement("span");r.className="c-axis__label",r.textContent=formatValue(String(t),this.getAttribute("format"),this.getAttribute("locale")),e.appendChild(r);const s=Number(t);e.style.setProperty("--tick-pos",Number.isFinite(s)?(s-i)/l*100+"%":"0%"),this.appendChild(e)})}}enhance(){}}define("contour-axis",ContourAxis);class ContourBrush extends ContourBase{static get observed(){return["start","end","min","max","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{start:{attribute:"start"},end:{attribute:"end"},min:{attribute:"min"},max:{attribute:"max"},src:{attribute:"src"}}}_rangeValue(){const t=parseFloat(this.getAttribute("start")),e=parseFloat(this.getAttribute("end"));return Number.isFinite(t)&&Number.isFinite(e)?[t,e]:null}_brushDetail(){const t=this._rangeValue();return{start:t?t[0]:null,end:t?t[1]:null,value:t?t[1]:null,range:t}}render(){if(this.classList.add("c-brush"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"brush-selection","Brush selection")),wireStates(this),loadRemote(this,[]),renderStates(this,"brush"))return;let t=this.querySelector(".c-brush__selection");t||(t=document.createElement("div"),t.className="c-brush__selection",this.appendChild(t));const e=parseFloat(this.getAttribute("start")||"0"),r=parseFloat(this.getAttribute("end")||"100"),s=parseFloat(this.getAttribute("min")||"0"),i=parseFloat(this.getAttribute("max")||"100"),a=i-s||1,o=(e-s)/a*100,n=(r-e)/a*100;t.style.insetInlineStart=o+"%",t.style.inlineSize=n+"%",["start","end"].forEach(t=>{let o=this.querySelector(".c-brush__handle--"+t);o||(o=document.createElement("div"),o.className="c-brush__handle c-brush__handle--"+t,this.appendChild(o));const n="start"===t?e:r;o.style.insetInlineStart=(n-s)/a*100+"%",o.setAttribute("role","slider"),o.setAttribute("tabindex","0"),o.setAttribute("aria-valuemin",String(s)),o.setAttribute("aria-valuemax",String(i)),o.setAttribute("aria-valuenow",String(n)),o.setAttribute("aria-label","start"===t?"Start":"End")})}enhance(){if(this._wiredBrush)return;this._wiredBrush=!0;let t=null;const e=()=>parseFloat(this.getAttribute("min")||"0"),r=()=>parseFloat(this.getAttribute("max")||"100"),s=t=>{const s=this.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t-s.left)/(s.width||1)));return e()+i*(r()-e())};this.addEventListener("pointerdown",e=>{const r=e.target&&e.target.classList&&e.target.classList.contains("c-brush__handle")?e.target:null;t=r?r.classList.contains("c-brush__handle--start")?"start":"end":"move";try{this.setPointerCapture(e.pointerId)}catch(t){}this.dispatchEvent(new CustomEvent("contour:brush-start",{bubbles:!0,composed:!0,detail:this._brushDetail()}))}),this.addEventListener("pointermove",i=>{if(!t)return;const a=s(i.clientX),o=e(),n=r(),l=n-o||1,c=this.querySelector(".c-brush__selection");let u=parseFloat(this.getAttribute("start")||"0"),d=parseFloat(this.getAttribute("end")||"100");if("start"===t)u=Math.min(a,d);else if("end"===t)d=Math.max(a,u);else{const t=d-u;u=a-t/2,d=a+t/2,u<o&&(d+=o-u,u=o),d>n&&(u-=d-n,d=n)}u=Math.max(o,Math.min(n,u)),d=Math.max(o,Math.min(n,d)),c&&(c.style.insetInlineStart=(u-o)/l*100+"%",c.style.inlineSize=(d-u)/l*100+"%");const h=this.querySelector(".c-brush__handle--start"),m=this.querySelector(".c-brush__handle--end");h&&(h.style.insetInlineStart=(u-o)/l*100+"%"),m&&(m.style.insetInlineStart=(d-o)/l*100+"%"),this._brushPending={start:u,end:d},this.dispatchEvent(new CustomEvent("contour:brush",{bubbles:!0,composed:!0,detail:{start:u,end:d,value:u,range:[u,d]}}))}),this.addEventListener("pointerup",e=>{if(!t)return;t=null;const r=this._brushPending;r&&(this.setAttribute("start",String(r.start)),this.setAttribute("end",String(r.end)),this._brushPending=null),this.dispatchEvent(new CustomEvent("contour:brush-end",{bubbles:!0,composed:!0,detail:this._brushDetail()})),this.dispatchEvent(new CustomEvent("contour:brush",{bubbles:!0,composed:!0,detail:this._brushDetail()}))}),this.addEventListener("pointercancel",()=>{t&&(t=null,this._brushPending=null,this.requestRender())}),this.addEventListener("keydown",t=>{const s=t.target&&t.target.classList&&t.target.classList.contains("c-brush__handle")?t.target:null,i=s?s.classList.contains("c-brush__handle--start")?"start":"end":null,a=e(),o=r(),n=(o-a)/100||1;let l=parseFloat(this.getAttribute("start")||"0"),c=parseFloat(this.getAttribute("end")||"100");if("Enter"===t.key||" "===t.key)return t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:brush-start",{bubbles:!0,composed:!0,detail:this._brushDetail()})),void this.dispatchEvent(new CustomEvent("contour:brush-end",{bubbles:!0,composed:!0,detail:this._brushDetail()}));let u=!0;if("ArrowLeft"===t.key||"ArrowDown"===t.key)if("start"===i)l-=n;else if("end"===i)c-=n;else{const t=c-l;l-=n,c=l+t}else if("ArrowRight"===t.key||"ArrowUp"===t.key)if("start"===i)l+=n;else if("end"===i)c+=n;else{const t=c-l;c+=n,l=c-t}else"Home"===t.key?"end"===i?c=l:l=a:"End"===t.key?"start"===i?l=c:c=o:u=!1;if(u){if(t.preventDefault(),l=Math.max(a,Math.min(o,l)),c=Math.max(a,Math.min(o,c)),l>c){const t=l;l=c,c=t}this.dispatchEvent(new CustomEvent("contour:brush-start",{bubbles:!0,composed:!0,detail:this._brushDetail()})),this.setAttribute("start",String(l)),this.setAttribute("end",String(c)),this.dispatchEvent(new CustomEvent("contour:brush",{bubbles:!0,composed:!0,detail:this._brushDetail()})),this.dispatchEvent(new CustomEvent("contour:brush-end",{bubbles:!0,composed:!0,detail:this._brushDetail()}))}}),this.addEventListener("contour:clear-all",()=>{(this.hasAttribute("start")||this.hasAttribute("end"))&&(this.removeAttribute("start"),this.removeAttribute("end"),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"brush",filter:{start:null,end:null}}})),this.requestRender())})}}define("contour-brush",ContourBrush);class ContourStackedBar extends ContourBase{static get observed(){return["segments","values","colors","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","max","no-cache"]}static get properties(){return{segments:{attribute:"segments"},values:{attribute:"values"},colors:{attribute:"colors"},src:{attribute:"src"},max:{attribute:"max"}}}render(){if(this.classList.add("c-stacked-bar"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"stacked-bar","Stacked bar")),wireStates(this),loadRemote(this,["segments","values"]),renderStates(this,"stacked-bar"))return;Array.from(this.querySelectorAll(".c-stacked-bar__segment")).forEach(t=>t.remove());const t=Array.from(this.querySelectorAll(":scope > .c-stacked-bar__segment"));let e=[];if(t.length)e=t.map(t=>({label:t.getAttribute("data-title")||t.getAttribute("title")||t.textContent||"",value:parseFloat(t.style.inlineSize)||0,color:t.dataset&&t.dataset.color||t.style.background||void 0})),t.forEach(t=>t.remove());else{this.getAttribute("segments")&&(e=parseArrayAttr(this,"segments",warnBadJson))}const r=e.map(t=>"object"==typeof t?t.value||0:Number(t)||0),s=r.some(t=>t<0),i=r.filter(t=>t>0).reduce((t,e)=>t+e,0),a=Math.abs(r.filter(t=>t<0).reduce((t,e)=>t+e,0)),o=i+a,n=Math.max(i,a,1),l=Math.max(1,parseFloat(this.getAttribute("max"))||(s?n:o));this.querySelectorAll(".c-stacked-bar__track").forEach(t=>t.remove());const c=(t,e,s)=>{const i=r[e],a=document.createElement("div");a.className="c-stacked-bar__segment"+(0===i?" c-stacked-bar__segment--zero":""),a.style.inlineSize=s+"%",a.style.background=safeColor("object"==typeof t&&t.color?t.color:"var(--chart-"+(e%8+1)+")"),a.dataset.color="object"==typeof t&&t.color?t.color:a.style.background;const o="object"==typeof t&&t.label||"";return a.setAttribute("data-title",o+" "+i),a.setAttribute("role","img"),a.setAttribute("aria-label",(o?o+": ":"")+i),a};if(s){this.classList.add("c-stacked-bar--diverging");const t=document.createElement("div");t.className="c-stacked-bar__track c-stacked-bar__track--neg";const s=document.createElement("div");s.className="c-stacked-bar__track",e.forEach((e,i)=>{const a=r[i];if(0===a)return;const o=Math.abs(a)/l*100;(a<0?t:s).appendChild(c(e,i,o))}),this.appendChild(t),this.appendChild(s)}else{this.classList.remove("c-stacked-bar--diverging");const t=document.createElement("div");t.className="c-stacked-bar__track",e.forEach((e,s)=>t.appendChild(c(e,s,r[s]/l*100))),this.appendChild(t)}e.length||renderEmpty(this,"stacked-bar")}enhance(){}}define("contour-stacked-bar",ContourStackedBar);class ContourCategory extends ContourBase{static get observed(){return["items","search","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","note","limit","sort","format","locale","unit","cache-key","no-cache"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"},note:{attribute:"note"},limit:{attribute:"limit"},sort:{attribute:"sort"},format:{attribute:"format"},locale:{attribute:"locale"},unit:{attribute:"unit"}}}render(){if(this.classList.add("c-category"),this.setAttribute("role","listbox"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"category","Category")),wireStates(this),loadRemote(this,["items"]),renderStates(this,"category"))return;Array.from(this.querySelectorAll(".c-category__item")).forEach(t=>t.remove());const t=Array.from(this.querySelectorAll(":scope > .c-category__item"));let e=[];if(t.length)t.forEach(t=>{const r=t.querySelector(".c-category__label");e.push({label:r?r.textContent:t.textContent,value:0})}),t.forEach(t=>t.remove());else{this.getAttribute("items")&&(e=parseArrayAttr(this,"items",warnBadJson))}const r=this.getAttribute("sort")||"value-desc";e.sort((t,e)=>{const s="object"==typeof t?t.value||0:Number(t)||0,i="object"==typeof e?e.value||0:Number(e)||0,a="object"==typeof t?t.label||t.name||"":String(t),o="object"==typeof e?e.label||e.name||"":String(e);return"value-asc"===r?s-i:"alpha-asc"===r?String(a).localeCompare(String(o)):"alpha-desc"===r?String(o).localeCompare(String(a)):i-s});const s=parseInt(this.getAttribute("limit")||"0",10);s>0&&(e=e.slice(0,s));const i=e.reduce((t,e)=>Math.max(t,Math.abs("object"==typeof e?e.value||0:Number(e)||0)),0)||1;e.forEach((t,e)=>{const r="object"==typeof t?t.value||0:Number(t)||0,s="object"==typeof t?t.label||t.name||"":String(t),a=document.createElement("div");a.className="c-category__item",a.setAttribute("role","option"),a.setAttribute("aria-selected","false"),a.setAttribute("tabindex",0===e?"0":"-1");const o=document.createElement("span");o.className="c-category__label",o.textContent=s;const n=document.createElement("div");n.style.flex="1";const l=document.createElement("div");l.className="c-category__bar",l.style.inlineSize=Math.abs(r)/i*100+"%",n.appendChild(l);const c=document.createElement("span");c.className="c-category__value",c.textContent=formatValue(r,this.getAttribute("format"),this.getAttribute("locale"),this.getAttribute("unit")),a.appendChild(o),a.appendChild(n),a.appendChild(c),this.appendChild(a)}),e.length||renderEmpty(this,"category");const a=this.getAttribute("note");let o=this.querySelector(".c-category__note");a?(o||(o=document.createElement("div"),o.className="c-category__note",this.appendChild(o)),o.textContent=a):o&&o.remove()}enhance(){if(this._wiredCategory)return;this._wiredCategory=!0;const t=()=>Array.from(this.querySelectorAll(".c-category__item"));this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-category__item"):null;if(!r||!this.contains(r))return;const s=t(),i=s.indexOf(r);s.forEach((t,e)=>t.setAttribute("aria-selected",e===i?"true":"false")),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:i,label:r.querySelector(".c-category__label")?r.querySelector(".c-category__label").textContent:r.textContent.trim()}}))}),this.addEventListener("keydown",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-category__item"):null;if(!r||!this.contains(r))return;const s=t(),i=s.indexOf(r);if("Enter"===e.key||" "===e.key)return e.preventDefault(),s.forEach((t,e)=>t.setAttribute("aria-selected",e===i?"true":"false")),void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:i,label:r.querySelector(".c-category__label")?r.querySelector(".c-category__label").textContent:r.textContent.trim()}}));navKey(e,s,{wrap:!1,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>s.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{if("Enter"===e.key||" "===e.key){const t=s.indexOf(document.activeElement);s.forEach((e,r)=>e.setAttribute("aria-selected",r===t?"true":"false")),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:t,label:document.activeElement.querySelector(".c-category__label")?document.activeElement.querySelector(".c-category__label").textContent:document.activeElement.textContent.trim()}}))}}})}),this.addEventListener("contour:clear-all",()=>{this.hasAttribute("search")&&(this.removeAttribute("search"),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"category",filter:{search:null}}})))})}}define("contour-category",ContourCategory);class ContourDonut extends ContourBase{static get observed(){return["value","values","items","label","color","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","brownout","brownout-level","note","cache-key","no-cache"]}static get properties(){return{value:{attribute:"value"},values:{attribute:"values"},items:{attribute:"items"},label:{attribute:"label"},color:{attribute:"color"},src:{attribute:"src"},note:{attribute:"note"}}}render(){if(this.classList.add("c-donut"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"donut-chart","Donut chart")),wireStates(this),loadRemote(this,["items","values"]),renderStates(this,"donut"))return;Array.from(this.querySelectorAll(".c-donut__ring, .c-donut__center, .c-donut__list, .c-donut__empty")).forEach(t=>t.remove());const t=Array.from(this.querySelectorAll(":scope > .c-donut__item"));let e=[];if(t.length)t.forEach(t=>{const r=t.querySelector(".c-donut__swatch"),s=t.querySelector("span:last-child"),i=s?s.textContent:t.textContent,a=i.match(/—\s*(\d+(?:\.\d+)?)$/);e.push({label:i.replace(/—\s*\d+(?:\.\d+)?$/,"").trim(),value:a?Number(a[1]):0,color:r?r.dataset&&r.dataset.color||r.style.background:void 0})}),t.forEach(t=>t.remove());else{this.getAttribute("items")&&(e=parseArrayAttr(this,"items",warnBadJson))}const r=e.map(t=>"object"==typeof t?t.value||0:Number(t)||0),s=r.reduce((t,e)=>t+(e>0?e:0),0)||1,i=(this.brownoutLevel(),this.getAttribute("color"));if(!this.shed("ring",3)){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("class","c-donut__ring"),t.setAttribute("viewBox","0 0 32 32"),t.setAttribute("role","img");const s=this.getAttribute("label")||"Donut chart";t.setAttribute("aria-label",s);donutSlices(r,{cx:16,cy:16,r:15,inner:9,gap:.03}).forEach((r,s)=>{const a=e[r.index],o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("class","c-donut__slice"),o.setAttribute("d",r.path),o.setAttribute("fill","var(--c, var(--chart-1))"),o.style.setProperty("--c",safeColor(i||("object"==typeof a&&a.color?a.color:"var(--chart-"+(r.index%8+1)+")"))||"var(--chart-1)"),o.dataset.index=String(r.index);const n=("object"==typeof a?a.label||"":String(a))+" — "+r.value;o.setAttribute("data-title",n),o.setAttribute("aria-label",n),o.setAttribute("tabindex",0===s?"0":"-1"),o.setAttribute("role","button"),t.appendChild(o)}),this.appendChild(t)}const a=document.createElement("div");a.className="c-donut__center",a.textContent=this.getAttribute("value")??String(s),this.appendChild(a);const o=document.createElement("div");o.className="c-donut__list",o.setAttribute("role","list"),e.forEach((t,e)=>{const s=document.createElement("div");s.className="c-donut__item",s.setAttribute("role","listitem");const a=document.createElement("span");a.className="c-donut__swatch",a.style.background=safeColor(i||("object"==typeof t&&t.color?t.color:"var(--chart-"+(e%8+1)+")")),a.style.background&&(a.dataset.color=i||("object"==typeof t&&t.color?t.color:a.style.background)),s.appendChild(a);const n=document.createElement("span");n.textContent=("object"==typeof t?t.label||"":String(t))+" — "+r[e],s.appendChild(n),o.appendChild(s)}),this.appendChild(o),e.length||renderEmpty(this,"donut");const n=this.getAttribute("note");let l=this.querySelector(".c-donut__note");n?(l||(l=document.createElement("div"),l.className="c-donut__note",this.appendChild(l)),l.textContent=n):l&&l.remove()}enhance(){if(this._wiredDonut)return;this._wiredDonut=!0;const t=()=>Array.from(this.querySelectorAll(".c-donut__slice")),e=t=>{const e=Number(t.dataset.index);Number.isFinite(e)&&this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:1,index:e,value:t.getAttribute("data-title")||t.getAttribute("title")}}))};this.addEventListener("keydown",r=>{const s=r.target&&r.target.closest?r.target.closest(".c-donut__slice"):null;if(!s||!this.contains(s))return;const i=t(),a=i.indexOf(s);let o=-1;if("ArrowRight"===r.key||"ArrowDown"===r.key)o=Math.min(a+1,i.length-1);else if("ArrowLeft"===r.key||"ArrowUp"===r.key)o=Math.max(a-1,0);else if("Home"===r.key)o=0;else if("End"===r.key)o=i.length-1;else if("Enter"===r.key||" "===r.key)return r.preventDefault(),void e(s);if(o>=0&&o!==a){r.preventDefault(),i.forEach((t,e)=>t.setAttribute("tabindex",e===o?"0":"-1"));try{i[o].focus()}catch(t){}}}),this.addEventListener("click",t=>{const r=t.target&&t.target.closest?t.target.closest(".c-donut__slice"):null;r&&this.contains(r)&&e(r)})}}define("contour-donut",ContourDonut);class ContourTimeSeries extends ContourBase{static get observed(){return["values","points","series","series-style","title","brownout","brownout-level","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","note","cache-key","no-cache"]}static get properties(){return{values:{attribute:"values"},points:{attribute:"points"},series:{attribute:"series"},src:{attribute:"src"},note:{attribute:"note"}}}render(){if(this.classList.add("c-time-series"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("title")||"Time series"),wireStates(this),loadRemote(this,["values","points","series"]),renderStates(this,"time-series"))return;this.ensure(".c-time-series__tooltip",()=>{const t=document.createElement("div");return t.className="c-time-series__tooltip",t.setAttribute("role","tooltip"),t.setAttribute("hidden",""),t.id=contourId("timeseries-tip"),t}),Array.from(this.querySelectorAll(".c-time-series__plot, .c-time-series__axis")).forEach(t=>t.remove());let t=[];this.getAttribute("series")&&(t=parseArrayAttr(this,"series",warnBadJson));const e=remoteData(this,"series");if(Array.isArray(e)&&(t=e),!t.length){let e=[];if(this.getAttribute("values")&&(e=parseArrayAttr(this,"values",warnBadJson)),e.length){const r=(this.getAttribute("style")||"").trim().toLowerCase();t=[{label:"Series 1",values:e,style:this.getAttribute("series-style")||("line"===r||"bar"===r?r:"bar"),color:"var(--chart-1)"}]}}const r=t.reduce((t,e)=>{const r=Array.isArray(e.values)?Math.max(...e.values,0):0;return Math.max(t,r)},1),s=t.reduce((t,e)=>{const r=Array.isArray(e.values)?Math.min(...e.values,0):0;return Math.min(t,r)},0),i=document.createElement("div");i.className="c-time-series__plot",i.setAttribute("part","plot");const a=[];t.forEach((t,e)=>{const o=Array.isArray(t.values)?t.values:[],n=t.style||"bar",l=t.color||`var(--chart-${e%8+1})`,c=t.label||`Series ${e+1}`;if("line"===n){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 300 120"),t.setAttribute("preserveAspectRatio","none"),t.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const a=r-s||1,n=o.length||1,u=o.map((t,e)=>{const r=e/Math.max(1,n-1)*300,i=120-(t-s)/a*120;return r.toFixed(2)+","+i.toFixed(2)}).join(" "),d=document.createElementNS("http://www.w3.org/2000/svg","path");d.setAttribute("class","c-time-series__line"),d.setAttribute("data-series",String(e+1)),d.setAttribute("d","M "+u.replace(/ /g," L ")),d.style.stroke=l,d.style.fill="none",d.style.strokeWidth="2",t.appendChild(d),o.forEach((r,i)=>{const o=i/Math.max(1,n-1)*300,l=120-(r-s)/a*120,u=document.createElementNS("http://www.w3.org/2000/svg","circle");u.setAttribute("class","c-time-series__point"),u.setAttribute("data-series",String(e+1)),u.setAttribute("data-index",String(i)),u.setAttribute("cx",o.toFixed(2)),u.setAttribute("cy",l.toFixed(2)),u.setAttribute("r","3"),u.setAttribute("tabindex",0===i&&0===e?"0":"-1"),u.setAttribute("role","button"),u.setAttribute("data-title",String(r)),u.setAttribute("aria-label",c+": "+String(r)),t.appendChild(u)}),i.appendChild(t)}else o.forEach((t,s)=>{const i=document.createElement("div");i.className="c-time-series__bar",i.setAttribute("data-series",String(e+1)),i.setAttribute("data-index",String(s)),i.style.blockSize=t/r*100+"%",i.style.background=safeColor(l),i.setAttribute("data-title",String(t)),i.setAttribute("role","button"),i.setAttribute("aria-label",c+": "+String(t)),i.setAttribute("tabindex",0===s&&0===e?"0":"-1"),(a[s]||(a[s]=[])).push(i)})}),a.forEach(t=>{t&&t.forEach(t=>i.appendChild(t))}),this.appendChild(i);const o=t.find(t=>Array.isArray(t.values)&&t.values.length),n=o?o.values.length:0;if(n>1){const t=document.createElement("div");t.className="c-time-series__axis";const e=o.x;[0,Math.floor((n-1)/2),n-1].filter((t,e,r)=>t>=0&&r.indexOf(t)===e).forEach(r=>{const s=document.createElement("span");s.className="c-time-series__tick",s.textContent=Array.isArray(e)&&null!=e[r]?String(e[r]):String(r),t.appendChild(s)}),this.appendChild(t)}t.length&&t.some(t=>Array.isArray(t.values)&&t.values.length)||renderEmpty(this,"time-series");const l=this.getAttribute("note");let c=this.querySelector(".c-time-series__note");l&&!this.shed("note",2)?(c||(c=document.createElement("div"),c.className="c-time-series__note",this.appendChild(c)),c.textContent=l):c&&c.remove();const u=this.querySelector(".c-time-series__axis");u&&(u.style.display=this.shed("axis",3)?"none":"")}enhance(){if(this._wiredTimeSeries)return;this._wiredTimeSeries=!0;const t=()=>Array.from(this.querySelectorAll(".c-time-series__bar")),e=()=>Array.from(this.querySelectorAll(".c-time-series__point"));this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-time-series__bar"):null;if(!e||!this.contains(e))return;const r=Number(e.dataset.series||"0"),s=Number(e.dataset.index||"0");this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:r,index:s,value:e.getAttribute("data-title")||e.getAttribute("title")}}))});this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-time-series__point"):null;if(!e||!this.contains(e))return;const r=Number(e.dataset.series||"0"),s=Number(e.dataset.index||"0");this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:r,index:s,value:e.getAttribute("data-title")||e.getAttribute("title")}}))}),this.addEventListener("keydown",r=>{const s=r.target&&r.target.closest?r.target.closest(".c-time-series__bar"):null,i=r.target&&r.target.closest?r.target.closest(".c-time-series__point"):null,a=s||i;if(!a||!this.contains(a))return;const o=s?t():e(),n=o.indexOf(a);if("Enter"===r.key||" "===r.key){r.preventDefault();const t=Number(a.dataset.series||"0");return void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:t,index:n,value:a.getAttribute("data-title")||a.getAttribute("title")}}))}navKey(r,o,{wrap:!1,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>o.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{}})}),this.addEventListener("focusin",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-time-series__bar"):null;if(e&&this.contains(e)){const t=this.querySelector(".c-time-series__tooltip");t&&(t.textContent=e.getAttribute("data-title")||e.getAttribute("title"),t.removeAttribute("hidden"),t.id&&e.setAttribute("aria-describedby",t.id))}const r=t.target&&t.target.closest?t.target.closest(".c-time-series__point"):null;if(r&&this.contains(r)){const t=this.querySelector(".c-time-series__tooltip");t&&(t.textContent=r.getAttribute("data-title")||r.getAttribute("title"),t.removeAttribute("hidden"),t.id&&r.setAttribute("aria-describedby",t.id))}}),this.addEventListener("focusout",t=>{const e=(t.target&&t.target.closest?t.target.closest(".c-time-series__bar"):null)||(t.target&&t.target.closest?t.target.closest(".c-time-series__point"):null);e&&this.contains(e)&&e.removeAttribute("aria-describedby");const r=this.querySelector(".c-time-series__tooltip");r&&!this.contains(t.relatedTarget)&&r.setAttribute("hidden","")})}}define("contour-time-series",ContourTimeSeries);class ContourPivot extends ContourBase{static get observed(){return["rows","columns","values","data","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","filter","aggregate","cache-key","no-cache"]}static get properties(){return{rows:{attribute:"rows"},columns:{attribute:"columns"},values:{attribute:"values"},data:{attribute:"data"},src:{attribute:"src"},filter:{attribute:"filter"},aggregate:{attribute:"aggregate"}}}_aggregateFn(t){const e=(t||"sum").toLowerCase();return"avg"===e||"average"===e||"mean"===e?t=>t.length?t.reduce((t,e)=>t+e,0)/t.length:0:"count"===e?t=>t.length:"min"===e?t=>t.length?Math.min(...t):0:"max"===e?t=>t.length?Math.max(...t):0:t=>t.reduce((t,e)=>t+e,0)}render(){if(this.classList.add("c-pivot"),wireStates(this),loadRemote(this,["data"]),renderStates(this,"pivot"))return;Array.from(this.querySelectorAll("table, .c-pivot__wrap, .c-pivot__toolbar, .c-pivot__empty")).forEach(t=>t.remove());let t=[];const e=this.getAttribute("data");if(e)try{t=JSON.parse(e)}catch(e){warnBadJson(this,"data",e),t=[]}const r=this.getAttribute("rows")?this.getAttribute("rows").split(",").map(t=>t.trim()).filter(Boolean):[],s=this.getAttribute("columns")?this.getAttribute("columns").split(",").map(t=>t.trim()).filter(Boolean):[],i=this.getAttribute("aggregate")||"sum",a=this._aggregateFn(i),o=(this.getAttribute("filter")||"").toLowerCase().trim(),n=document.createElement("div");n.className="c-pivot__toolbar",n.style.display="flex";const l=document.createElement("input");l.type="search",l.className="c-input c-pivot__filter",l.placeholder=labelText(this,"filter","Filter…"),l.value=this.getAttribute("filter")||"",l.setAttribute("aria-label",labelText(this,"filter-pivot","Filter pivot"));const c=document.createElement("select");c.className="c-select c-pivot__aggregate",c.setAttribute("aria-label",labelText(this,"aggregation","Aggregation")),["sum","avg","count","min","max"].forEach(t=>{const e=document.createElement("option");e.value=t,e.textContent=t,t===i&&(e.selected=!0),c.appendChild(e)}),n.appendChild(l),n.appendChild(c),this.appendChild(n);let u=r,d=s;if(o&&(u=r.filter(e=>e.toLowerCase().includes(o)||t.some(t=>t.row===e&&String(t.value).toLowerCase().includes(o))),d=s.filter(e=>e.toLowerCase().includes(o)||t.some(t=>t.col===e&&String(t.value).toLowerCase().includes(o)))),!t.length&&!r.length&&!s.length)return void renderEmpty(this,"pivot");if(o&&(!u.length||!d.length)){const t=document.createElement("div");return t.className="c-pivot__empty",t.setAttribute("role","status"),t.textContent=this.getAttribute("empty")||labelText(this,"empty","No matching data"),void this.appendChild(t)}if(this._pivotSort&&this._pivotSort.col){const e=this._pivotSort.col,r="asc"===this._pivotSort.dir?1:-1,s=r=>a(t.filter(t=>t.row===r&&t.col===e).map(t=>Number(t.value)).filter(t=>Number.isFinite(t)));u=u.slice().sort((t,e)=>(s(t)-s(e))*r)}const h=document.createElement("div");h.className="c-table-wrap c-pivot__wrap";const m=document.createElement("table");m.className="c-table c-pivot__table",m.setAttribute("role","grid"),m.setAttribute("aria-rowcount",String(u.length+1)),m.setAttribute("aria-colcount",String(d.length+1));const b=document.createElement("thead"),p=document.createElement("tr"),g=document.createElement("th");g.textContent="",g.setAttribute("role","columnheader"),g.setAttribute("aria-label",labelText(this,"row","Row")),p.appendChild(g);let _=!1;d.forEach(t=>{const e=document.createElement("th");e.textContent=t,e.setAttribute("role","columnheader"),e.setAttribute("tabindex",_?"-1":"0"),_=!0,p.appendChild(e)}),b.appendChild(p),m.appendChild(b);const v=document.createElement("tbody");u.forEach(e=>{const r=document.createElement("tr");r.setAttribute("role","row");const s=document.createElement("th");s.textContent=e,s.setAttribute("role","rowheader"),s.setAttribute("tabindex",_?"-1":"0"),_=!0,r.appendChild(s),d.forEach(s=>{const i=document.createElement("td");i.setAttribute("role","gridcell"),i.setAttribute("tabindex","-1"),i.dataset.row=e,i.dataset.col=s;const o=t.filter(t=>t.row===e&&t.col===s),n=o.map(t=>Number(t.value)).filter(t=>Number.isFinite(t));if(o.length&&n.length===o.length&&n.length){const t=a(n);i.textContent=Number.isInteger(t)?String(t):t.toFixed(2)}else o.length?i.textContent=o.map(t=>t.value).join(", "):i.textContent="";i.textContent.trim()||i.setAttribute("aria-label",labelText(this,"empty","Empty")),r.appendChild(i)}),v.appendChild(r)}),m.appendChild(v),h.appendChild(m),this.appendChild(h)}enhance(){this._wiredPivot||(this._wiredPivot=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest("th"):null,r=t.target&&t.target.closest?t.target.closest("td"):null,s=t.target&&t.target.closest?t.target.closest(".c-pivot__filter"):null,i=t.target&&t.target.closest?t.target.closest(".c-pivot__aggregate"):null;if(!s&&!i){if(e&&this.contains(e)&&e.parentElement&&e.parentElement.parentElement&&"THEAD"===e.parentElement.parentElement.tagName){const t=e.textContent.trim();if(t){const e=this._pivotSort;this._pivotSort={col:t,dir:e&&e.col===t&&"desc"===e.dir?"asc":"desc"},this.requestRender()}return void this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:!0,composed:!0,detail:{column:t}}))}r&&this.contains(r)&&this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{row:r.dataset.row||"",col:r.dataset.col||"",value:r.textContent}}))}}),this.addEventListener("input",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-pivot__filter"):null;e&&this.contains(e)&&(this.setAttribute("filter",e.value),this.dispatchEvent(new CustomEvent("contour:filter",{bubbles:!0,composed:!0,detail:{query:e.value}})),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"pivot",filter:{filter:e.value}}})))}),this.addEventListener("change",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-pivot__aggregate"):null;e&&this.contains(e)&&(this.setAttribute("aggregate",e.value),this.dispatchEvent(new CustomEvent("contour:aggregate",{bubbles:!0,composed:!0,detail:{aggregate:e.value}})))}),this.addEventListener("keydown",t=>{const e=t.target&&t.target.closest?t.target.closest("th, td"):null;if(!e||!this.contains(e))return;const r=this.querySelector("table");if(!r)return;const s=Array.from(r.querySelectorAll("tr")),i=s.indexOf(e.parentElement),a=Array.from(e.parentElement.children).indexOf(e);let o=null;if("ArrowRight"===t.key?o=e.parentElement.children[a+1]:"ArrowLeft"===t.key?o=e.parentElement.children[a-1]:"ArrowDown"===t.key?o=s[i+1]&&s[i+1].children[a]:"ArrowUp"===t.key?o=s[i-1]&&s[i-1].children[a]:"Home"===t.key?o=e.parentElement.children[0]:"End"===t.key&&(o=e.parentElement.children[e.parentElement.children.length-1]),o){t.preventDefault();try{o.focus()}catch(t){}}}),this.addEventListener("contour:clear-all",()=>{this.hasAttribute("filter")&&(this.removeAttribute("filter"),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"pivot",filter:{filter:null}}})))}))}}define("contour-pivot",ContourPivot);class ContourWidgetState extends ContourBase{static get observed(){return["loading","error","empty","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"},retry:{attribute:"retry"},src:{attribute:"src"}}}render(){this.classList.add("c-widget-state"),wireStates(this),loadRemote(this,[]),renderStates(this,"widget-state")}enhance(){}}define("contour-widget-state",ContourWidgetState);class ContourBrownout extends ContourBase{static get observed(){return["level"]}static get properties(){return{level:{attribute:"level"}}}render(){this.classList.add("c-brownout");const t=this.getAttribute("level")||"0";this.dataset.level=t,this.setAttribute("data-level",t);let e=this.querySelector(".c-brownout__decorative");e||(e=document.createElement("span"),e.className="c-brownout__decorative",e.setAttribute("aria-hidden","true"),this.appendChild(e));let r=this.querySelector(".c-brownout__label");r||(r=document.createElement("span"),r.className="c-brownout__label",this.appendChild(r)),r.textContent=labelText(this,"level","Level")+" "+t;const s=parseInt(t,10)||0;this._shedDisplay||(this._shedDisplay=new WeakMap),Array.from(this.children).forEach(t=>{if(t.classList.contains("c-brownout__decorative")||t.classList.contains("c-brownout__label"))return;const e=parseInt(t.getAttribute("data-shed")||"2",10);!t.hasAttribute("data-essential")&&Number.isFinite(e)&&s>=e?(this._shedDisplay.has(t)||this._shedDisplay.set(t,t.style.display),t.style.display="none"):this._shedDisplay.has(t)&&(t.style.display=this._shedDisplay.get(t),this._shedDisplay.delete(t))})}enhance(){}}define("contour-brownout",ContourBrownout);class ContourInstrument extends ContourBase{static get observed(){return["rows","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{rows:{attribute:"rows"},src:{attribute:"src"}}}render(){if(this.classList.add("c-instrument"),wireStates(this),loadRemote(this,"rows"),renderStates(this,"instrument"))return;const t=remoteData(this,"rows");if(Array.from(this.querySelectorAll(".c-instrument__item")).forEach(t=>t.remove()),t)try{JSON.parse(t).forEach(t=>{const e=document.createElement("span");e.className="c-instrument__item",e.appendChild(document.createTextNode(String(t.key||t[0]||"")));const r=document.createElement("span");r.className="c-instrument__value",r.textContent=t.value||t[1]||"",e.appendChild(r),this.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}else renderEmpty(this,"instrument")}}define("contour-instrument",ContourInstrument);class ContourBivariate extends ContourBase{static get observed(){return["size","axis-x","axis-y","colors","selected"]}static get properties(){return{size:{attribute:"size"},axisX:{attribute:"axis-x"},axisY:{attribute:"axis-y"},colors:{attribute:"colors"},selected:{attribute:"selected"}}}get _bvBlock(){return"c-bivariate"}get _bvDefaultAxisX(){return"Income"}get _bvDefaultAxisY(){return"Density"}get _bvLiveClassName(){return`${this._bvBlock}__live`}get _bvLiveInlineStyles(){return!0}get _bvAnnounce(){return!1}render(){this.classList.add(this._bvBlock),this.setAttribute("role","group");const t="Bivariate legend",e=this.getAttribute("aria-label");null!==e&&e!==this._lastAutoAria||(this.setAttribute("aria-label",t),this._lastAutoAria=t);const r=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")??"3",10)??3)),s=this.getAttribute("axis-y")??this._bvDefaultAxisY,i=this.getAttribute("axis-x")??this._bvDefaultAxisX,a=this.ensure(`.${this._bvBlock}__matrix`,()=>{const t=document.createElement("div");return t.className=`${this._bvBlock}__matrix`,t});a.style.gridTemplateColumns=`repeat(${r}, 1fr)`,a.style.gridTemplateRows=`repeat(${r}, 1fr)`;if(!Array.from(a.children).filter(t=>t.classList&&t.classList.contains(`${this._bvBlock}__cell`)).length){a.innerHTML="";let t=parseArrayAttr(this,"colors",warnBadJson);if(!t.length){t=["#e8e8e8","#b5c0da","#2a5a99","#e4acac","#b07f99","#2d3a6b","#c85a5a","#994d6e","#2a1a30"].slice(0,r*r)}for(let e=0;e<r;e++)for(let o=0;o<r;o++){const n=document.createElement("div");n.className=`${this._bvBlock}__cell`,n.setAttribute("role","button"),n.setAttribute("tabindex",0===e&&0===o?"0":"-1");const l=r-e;n.setAttribute("aria-label",`${s} ${l} of ${r}, ${i} ${o+1} of ${r}`);const c=(r-1-e)*r+o;if(t[c]){const e=safeColor(t[c]);e&&(n.style.background=e,n.dataset.color=e)}a.appendChild(n)}const e=this.getAttribute("selected");if(e){const t=e.split(","),s=parseInt(t[0],10),i=parseInt(t[1],10);Array.from(a.querySelectorAll(`.${this._bvBlock}__cell`)).forEach((t,e)=>{Math.floor(e/r)===s&&e%r===i?t.setAttribute("data-selected",""):t.removeAttribute("data-selected")})}let o=this.querySelector(`.${this._bvBlock}__live`);o||(o=document.createElement("div"),o.className=this._bvLiveClassName,o.setAttribute("aria-live","polite"),this._bvLiveInlineStyles&&(o.style.position="absolute",o.style.width="1px",o.style.height="1px",o.style.overflow="hidden",o.style.clip="rect(0,0,0,0)"),this.appendChild(o))}const o=this.getAttribute("axis-x");if(o){this.ensure(`.${this._bvBlock}__axis--x`,()=>{const t=document.createElement("div");return t.className=`${this._bvBlock}__axis ${this._bvBlock}__axis--x`,t}).textContent=o}else{const t=this.querySelector(`.${this._bvBlock}__axis--x`);t&&t.remove()}const n=this.getAttribute("axis-y");if(n){this.ensure(`.${this._bvBlock}__axis--y`,()=>{const t=document.createElement("div");return t.className=`${this._bvBlock}__axis ${this._bvBlock}__axis--y`,t}).textContent=n}else{const t=this.querySelector(`.${this._bvBlock}__axis--y`);t&&t.remove()}}enhance(){if(this._wiredBivariate)return;this._wiredBivariate=!0;const t=t=>{const e=this.querySelector(`.${this._bvBlock}__matrix`),r=Array.from(e?e.querySelectorAll(`.${this._bvBlock}__cell`):[]),s=r.indexOf(t);if(s<0)return;const i=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3)),a=Math.floor(s/i),o=s%i;if(r.forEach((t,e)=>{Math.floor(e/i)===a&&e%i===o?t.setAttribute("data-selected",""):t.removeAttribute("data-selected")}),this._bvAnnounce){const e=this.querySelector(`.${this._bvBlock}__live`);e&&(e.textContent=t.getAttribute("aria-label")||"")}this.dispatchEvent(new CustomEvent("contour:select",{detail:{row:a,col:o},bubbles:!0,composed:!0}))};this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(`.${this._bvBlock}__cell`):null;r&&this.contains(r)&&t(r)}),this.addEventListener("keydown",e=>{const r=e.target&&e.target.closest?e.target.closest(`.${this._bvBlock}__cell`):null;if(!r||!this.contains(r))return;if("Enter"===e.key||" "===e.key)return e.preventDefault(),void t(r);const s=this.querySelector(`.${this._bvBlock}__matrix`);if(!s)return;const i=Array.from(s.querySelectorAll(`.${this._bvBlock}__cell`)),a=i.indexOf(r);if(a<0)return;const o=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3)),n=Math.floor(a/o),l=a%o;let c=n,u=l;if("ArrowRight"===e.key)u=Math.min(o-1,l+1);else if("ArrowLeft"===e.key)u=Math.max(0,l-1);else if("ArrowDown"===e.key)c=Math.min(o-1,n+1);else if("ArrowUp"===e.key)c=Math.max(0,n-1);else if("Home"===e.key)c=0,u=0;else{if("End"!==e.key)return;c=o-1,u=o-1}e.preventDefault();const d=i[c*o+u];if(d){i.forEach((t,e)=>t.setAttribute("tabindex",e===c*o+u?"0":"-1"));try{d.focus()}catch(t){}}})}clear(){this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:!0,composed:!0}))}}define("contour-bivariate",ContourBivariate);class ContourBivariateLegend extends ContourBivariate{static get observed(){return["size","axis-x","axis-y","colors","selected"]}static get properties(){return{size:{attribute:"size"},axisX:{attribute:"axis-x"},axisY:{attribute:"axis-y"},colors:{attribute:"colors"},selected:{attribute:"selected"}}}get _bvBlock(){return"c-bivariate-legend"}get _bvDefaultAxisX(){return"X"}get _bvDefaultAxisY(){return"Y"}get _bvLiveClassName(){return"visually-hidden c-bivariate-legend__live"}get _bvLiveInlineStyles(){return!1}get _bvAnnounce(){return!0}clear(){this.removeAttribute("selected");Array.from(this.querySelectorAll(".c-bivariate-legend__cell")).forEach(t=>t.removeAttribute("data-selected")),this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:!0,composed:!0}))}}define("contour-bivariate-legend",ContourBivariateLegend);class ContourSurvey extends ContourBase{static get observed(){return["date","instrument","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{date:{attribute:"date"},instrument:{attribute:"instrument"},src:{attribute:"src"}}}render(){if(this.classList.add("c-survey"),wireStates(this),loadRemote(this,"date"),renderStates(this,"survey"))return;const t=remoteData(this,"date");Array.from(this.childNodes).forEach(t=>{t.nodeType===Node.TEXT_NODE?"Surveyed"!==t.textContent.trim()&&"·"!==t.textContent.trim()||t.remove():t.classList&&(t.classList.contains("c-survey__value")||t.classList.contains("c-survey__sep"))&&t.remove()});const e=t||this._remoteData&&this._remoteData.date,r=this.getAttribute("instrument")||this._remoteData&&this._remoteData.instrument;if(!e)return void renderEmpty(this,"survey");const s=document.createElement("span");if(s.className="c-survey__value",s.textContent=e,this.appendChild(document.createTextNode("Surveyed ")),this.appendChild(s),r){const t=document.createElement("span");t.className="c-survey__sep",t.textContent="·",this.appendChild(t);const e=document.createElement("span");e.className="c-survey__value",e.textContent=r,this.appendChild(e)}}}define("contour-survey",ContourSurvey);class ContourThreshold extends ContourBase{static get observed(){return["label","norm","state","value","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{label:{attribute:"label"},norm:{attribute:"norm"},state:{attribute:"state"},value:{attribute:"value"},src:{attribute:"src"}}}render(){if(this.classList.add("c-threshold"),this.hasAttribute("role")||this.setAttribute("role","meter"),wireStates(this),loadRemote(this,"value"),renderStates(this,"threshold"))return;const t=t=>{const e=Number(t);return Number.isFinite(e)?(e<=1?100*e:e)+"%":String(t)},e=remoteData(this,"value")||this._remoteData&&this._remoteData.value,r=this.getAttribute("norm")||this._remoteData&&this._remoteData.norm,s=this.getAttribute("state")||this._remoteData&&this._remoteData.state,i=this.getAttribute("label")||this._remoteData&&this._remoteData.label;if(!e&&!r&&!i)return void renderEmpty(this,"threshold");const a=Number(e);if(Number.isFinite(a)){const t=Math.min(100,Math.max(0,a));this.setAttribute("aria-valuenow",String(t)),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100")}else this.removeAttribute("aria-valuenow"),this.removeAttribute("aria-valuemin"),this.removeAttribute("aria-valuemax");const o=[i,Number.isFinite(a)?String(a):null,r?labelText(this,"target","target")+" "+r:null].filter(Boolean).join(", ");if(o?this.setAttribute("aria-valuetext",o):this.removeAttribute("aria-valuetext"),e){this.ensure(".c-threshold__fill",()=>{const t=document.createElement("span");return t.className="c-threshold__fill",t}).style.setProperty("--value",t(e))}else{const t=this.querySelector(".c-threshold__fill");t&&t.remove()}if(r){this.ensure(".c-threshold__target",()=>{const t=document.createElement("span");return t.className="c-threshold__target",t}).style.setProperty("--target",t(r))}else{const t=this.querySelector(".c-threshold__target");t&&t.remove()}s?this.setAttribute("data-state",s):this.removeAttribute("data-state"),i&&this.setAttribute("aria-label",i)}enhance(){this._wiredThreshold||(this._wiredThreshold=!0,this.addEventListener("contour:clear-all",()=>{(this.hasAttribute("norm")||this.hasAttribute("value"))&&(this.removeAttribute("norm"),this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"threshold",filter:{norm:null,value:null}}})),this.requestRender())}))}}define("contour-threshold",ContourThreshold);class ContourMetricsFull extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){if(this.classList.add("c-metrics"),this.setAttribute("role","list"),wireStates(this),loadRemote(this,"items"),renderStates(this,"metrics"))return;const t=remoteData(this,"items");Array.from(this.querySelectorAll(".c-metrics__item")).forEach(t=>t.remove());let e=null;if(t)try{e=JSON.parse(t)}catch(t){e=null}Array.isArray(e)&&e.length?e.forEach(t=>{const e=document.createElement("div");e.className="c-metrics__item",e.setAttribute("role","listitem");const r=document.createElement("div");r.className="c-metrics__value",r.textContent="object"==typeof t&&null!==t?t.value??t.v??"":String(t);const s=document.createElement("div");s.className="c-metrics__label",s.textContent="object"==typeof t&&null!==t?t.label??t.l??"":"",e.appendChild(r),e.appendChild(s),this.appendChild(e)}):t||renderEmpty(this,"metrics")}enhance(){wireStates(this)}}define("contour-metrics",ContourMetricsFull);class ContourLegend extends ContourBase{static get observed(){return["title","ramp","scale","items","method","norm","selectable","brownout","brownout-level","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","glyphs","thresholds","breaks","no-data-color","no-data-label","size","table","classification","audit","continuous","ends","caption","graduated","cache-key","no-cache"]}static get properties(){return{title:{attribute:"title"},ramp:{attribute:"ramp"},scale:{attribute:"scale"},items:{attribute:"items"},method:{attribute:"method"},norm:{attribute:"norm"},selectable:{attribute:"selectable",type:Boolean},src:{attribute:"src"},graduated:{attribute:"graduated",type:Boolean}}}render(){this.classList.add("c-legend");const t=this.hasAttribute("graduated");t&&this.classList.add("c-legend--graduated");if(this.hasAttribute("continuous")||this.hasAttribute("selectable")?this.setAttribute("role","group"):this.setAttribute("role","list"),wireStates(this),loadRemote(this,"items"),renderStates(this,"legend"))return;const e=this.hasAttribute("selectable");e?this.classList.add("c-legend--interactive"):this.classList.remove("c-legend--interactive");const r=Array.from(this.querySelectorAll(":scope > .c-legend__item"));let s=remoteData(this,"items");r.length&&(s=JSON.stringify(r.map(t=>{const e=t.querySelector(".c-legend__swatch"),r=t.querySelector(".c-legend__label")||t;return{label:r?r.textContent.trim():t.textContent.trim(),color:e&&(e.dataset&&e.dataset.color||e.style.background)||void 0}})),r.forEach(t=>t.remove()));const i=this.getAttribute("title");if(i){this.ensure(".c-legend__title",()=>{const t=document.createElement("div");return t.className="c-legend__title",t}).textContent=i}else{const t=this.querySelector(".c-legend__title");t&&t.remove()}if(s)try{const r=JSON.parse(s),a=this.ensure(".c-legend__items",()=>{const t=document.createElement("div");return t.className="c-legend__items",t});this.hasAttribute("selectable")?a.setAttribute("role","group"):a.removeAttribute("role"),i&&a.setAttribute("aria-label",i),a.innerHTML="",r.forEach(r=>{const s="string"==typeof r?r:r.label||String(r),i="string"==typeof r?r:r.key||r.label||String(r),o=document.createElement("div");if(o.className="c-legend__item",o.setAttribute("tabindex","-1"),e){o.setAttribute("role","button");const t=this._legendUnpressed&&this._legendUnpressed.has(i);o.setAttribute("aria-pressed",t?"false":"true"),o.dataset.key=i}else o.setAttribute("role","listitem");const n=document.createElement("span");if(t){n.className="c-legend__swatch c-legend__swatch--graduated";const t=r&&null!=r.size?r.size:r&&null!=r.value?r.value:1,e=Math.max(6,Math.min(24,4*parseFloat(t)));n.style.inlineSize=e+"px",n.style.blockSize=e+"px"}else n.className="c-legend__swatch";if(r&&r.color){const t=safeColor(r.color);t&&(n.style.background=t,n.dataset.color=t)}if(o.appendChild(n),t&&r&&null!=r.break){const t=document.createElement("span");t.className="c-legend__break-label",t.textContent=String(r.break),o.appendChild(t)}const l=r&&(r.shape||r.marker||r.glyph)||this.getAttribute("glyphs");if(l){const t=document.createElement("span");t.className="c-legend__glyph",t.setAttribute("part","glyph"),t.textContent="circle"===l?"●":"square"===l?"■":"triangle"===l?"▲":"diamond"===l?"◆":"star"===l?"★":String(l),r&&null!=r.size&&(t.style.fontSize="number"==typeof r.size?r.size+"px":String(r.size)),o.appendChild(t)}if(r&&null!=r.break){const t=document.createElement("span");t.className="c-legend__break",t.textContent=String(r.break),o.appendChild(t)}const c=document.createElement("span");c.className="c-legend__label",c.textContent=s,o.dataset.label=s,o.appendChild(c);const u="object"==typeof r&&r&&(r.caption||r.note)||"";if(u){const t=document.createElement("span");t.className="c-legend__caption",t.textContent=u,o.appendChild(t)}r&&(r.threshold||null!=r.break)&&(n.style.outline="2px solid var(--color-border-strong)"),a.appendChild(o)})}catch(t){warnBadJson(this,"attribute",t)}else{const t=this.querySelector(".c-legend__items");t&&t.remove();this.getAttribute("title")||this.getAttribute("ramp")||this.getAttribute("scale")||this.getAttribute("method")||this.getAttribute("norm")||renderEmpty(this,"legend")}const a=this.getAttribute("caption");let o=this.querySelector(".c-legend__caption");if(a)o||(o=document.createElement("span"),o.className="c-legend__caption",this.appendChild(o)),o.id=o.id||contourId("legend-caption"),o.textContent=a,o.style.position="absolute",o.style.width="1px",o.style.height="1px",o.style.overflow="hidden",o.style.clip="rect(0,0,0,0)";else if(o){const t=o.id;o.remove(),t&&this.querySelectorAll(".c-legend__item").forEach(e=>{const r=(e.getAttribute("aria-describedby")||"").split(" ").filter(e=>e&&e!==t);r.length?e.setAttribute("aria-describedby",r.join(" ")):e.removeAttribute("aria-describedby")})}const n=this.querySelector(".c-legend__items");if(n){const t=Array.from(n.querySelectorAll(".c-legend__item"));e?t.forEach((t,e)=>t.setAttribute("tabindex",0===e?"0":"-1")):t.forEach(t=>t.setAttribute("tabindex","-1")),o&&t.forEach(t=>t.setAttribute("aria-describedby",o.id))}const l=this.getAttribute("no-data-color"),c=this.getAttribute("no-data-label")||"No data";if(l){let t=this.querySelector(".c-legend__no-data");t||(t=document.createElement("div"),t.className="c-legend__no-data",this.appendChild(t)),t.setAttribute("part","no-data"),t.setAttribute("aria-label",c),t.textContent=c;const e=document.createElement("span");e.className="glyph",e.style.background=safeColor(l),e.dataset.color=l,t.prepend(e)}else{const t=this.querySelector(".c-legend__no-data");t&&t.remove()}const u=this.getAttribute("audit");if(u){this.ensure(".c-legend__audit",()=>{const t=document.createElement("div");return t.className="c-legend__audit",t}).textContent=u}else{const t=this.querySelector(".c-legend__audit");t&&t.remove()}if(this.hasAttribute("continuous")){const t=this.getAttribute("ends");let e=null;if(t)try{e=JSON.parse(t)}catch(r){e=t.split(",")}if(Array.isArray(e)&&e.length>=2){const t=this.ensure(".c-legend__ramp",()=>{const t=document.createElement("div");return t.className="c-legend__ramp",t});let r=this.querySelector(".c-legend__ramp-label--start");r||(r=document.createElement("span"),r.className="c-legend__ramp-label c-legend__ramp-label--start",t.appendChild(r)),r.textContent=e[0];let s=this.querySelector(".c-legend__ramp-label--end");s||(s=document.createElement("span"),s.className="c-legend__ramp-label c-legend__ramp-label--end",t.appendChild(s)),s.textContent=e[e.length-1]}}const d=this.getAttribute("size");if(d){this.ensure(".c-legend__size",()=>{const t=document.createElement("div");return t.className="c-legend__size",t}).textContent=d}else{const t=this.querySelector(".c-legend__size");t&&t.remove()}const h=this.getAttribute("classification");if(h){this.ensure(".c-legend__classification",()=>{const t=document.createElement("div");return t.className="c-legend__classification",t}).textContent=h}else{const t=this.querySelector(".c-legend__classification");t&&t.remove()}const m=this.getAttribute("table");if(m){let t=null;try{t=JSON.parse(m)}catch(e){t=null}if(Array.isArray(t)){let e=this.querySelector(".c-legend__table-wrap");e||(e=document.createElement("details"),e.className="c-legend__table-wrap",this.appendChild(e)),e.innerHTML="";const r=document.createElement("summary");r.textContent=labelText(this,"data-table","Data table"),e.appendChild(r);const s=document.createElement("table");s.className="c-legend__table";const i=document.createElement("tbody");t.forEach(t=>{const e=document.createElement("tr");(Array.isArray(t)?t:[t.label??t.key??"",t.value??""]).forEach(t=>{const r=document.createElement("td");r.textContent=t,e.appendChild(r)}),i.appendChild(e)}),s.appendChild(i),e.appendChild(s)}}else{const t=this.querySelector(".c-legend__table-wrap");t&&t.remove()}const b=this.getAttribute("method");if(b){this.ensure(".c-legend__method",()=>{const t=document.createElement("div");return t.className="c-legend__method",t}).textContent=b}else{const t=this.querySelector(".c-legend__method");t&&t.remove()}const p=this.getAttribute("norm");if(p){this.ensure(".c-legend__norm",()=>{const t=document.createElement("span");return t.className="c-legend__norm",t}).textContent=p}else{const t=this.querySelector(".c-legend__norm");t&&t.remove()}const g=this.getAttribute("ramp");if(g){const t=this.ensure(".c-legend__ramp",()=>{const t=document.createElement("div");return t.className="c-legend__ramp",t});t.style.background=safeColor(g);const e=this.getAttribute("breaks");if(e){let r=null;try{r=JSON.parse(e)}catch(t){r=e.split(",").map(t=>t.trim())}Array.isArray(r)&&(Array.from(t.querySelectorAll(".c-legend__ramp-segment")).forEach(t=>t.remove()),r.forEach((e,r)=>{const s=document.createElement("span");s.className="c-legend__ramp-segment",s.style.flex="1";const i=document.createElement("span");i.className="c-legend__ramp-break",i.textContent=String(e),s.appendChild(i),t.appendChild(s)}))}}else{const t=this.querySelector(".c-legend__ramp");t&&t.remove()}const _=this.getAttribute("scale");if(_){this.ensure(".c-legend__scale",()=>{const t=document.createElement("div");return t.className="c-legend__scale",t}).textContent=_}else{const t=this.querySelector(".c-legend__scale");t&&t.remove()}const v=this.shed("chrome",2),y=this.shed("items",3);[".c-legend__ramp",".c-legend__scale"].forEach(t=>{const e=this.querySelector(t);e&&(e.style.display=v?"none":"")}),this.querySelectorAll(".c-legend__caption").forEach(t=>{t.style.display=v?"none":""});const f=this.querySelector(".c-legend__items");f&&(f.style.display=y?"none":"")}enhance(){if(!this._wiredLegend){this._wiredLegend=!0,this.addEventListener("click",t=>{if(!this.hasAttribute("selectable"))return;const e=t.target&&t.target.closest?t.target.closest(".c-legend__item"):null;if(!e||!this.contains(e))return;const r="true"!==e.getAttribute("aria-pressed");e.setAttribute("aria-pressed",String(r)),this._legendUnpressed=this._legendUnpressed||new Set;const s=e.dataset.key||e.textContent.trim();s&&(r?this._legendUnpressed.delete(s):this._legendUnpressed.add(s));const i=Array.from(this.querySelectorAll(".c-legend__item")).indexOf(e),a=e.querySelector(".c-legend__label"),o=e.dataset.label||(a?a.textContent.trim():e.textContent.trim());this.dispatchEvent(new CustomEvent("contour:legend-toggle",{detail:{label:o,key:e.dataset.key||o,pressed:r,index:i},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("contour:select",{detail:{label:o,key:e.dataset.key||o,value:e.dataset.key||o},bubbles:!0,composed:!0}))});try{let t=null;try{t=JSON.parse(this.getAttribute("items")||"null")}catch(e){t=this.getAttribute("items")}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:this.getAttribute("items"),items:t},bubbles:!0,composed:!0}))}catch(t){}this.addEventListener("change",t=>{const e=t.target;e&&e.classList&&e.classList.contains("c-legend__break-input")&&this.dispatchEvent(new CustomEvent("contour:break-change",{detail:{value:e.value},bubbles:!0,composed:!0}))}),this.addEventListener("keydown",t=>{if(!this.hasAttribute("selectable"))return;const e=Array.from(this.querySelectorAll(".c-legend__item"));if(!e.length)return;const r=document.activeElement,s=e.indexOf(r);if("Escape"===t.key)return e.forEach(t=>t.setAttribute("aria-pressed","false")),void this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:!0,composed:!0}));if(1!==t.key.length||t.ctrlKey||t.metaKey||t.altKey){if("Enter"===t.key||" "===t.key)return t.preventDefault(),void(r&&r.classList.contains("c-legend__item")&&r.click());navKey(t,e,{wrap:!0,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>e.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{}})}else if(e.length>7){const r=s>=0?s+1:0;for(let s=0;s<e.length;s++){const i=(r+s)%e.length;if((e[i].textContent||"").trim().toLowerCase().startsWith(t.key.toLowerCase())){t.preventDefault(),e[i].focus(),e.forEach((t,e)=>t.setAttribute("tabindex",e===i?"0":"-1"));break}}}}),this.addEventListener("contour:clear-all",()=>{const t=Array.from(this.querySelectorAll(".c-legend__item"));let e=!1;t.forEach(t=>{"button"===t.getAttribute("role")&&"true"===t.getAttribute("aria-pressed")&&(t.setAttribute("aria-pressed","false"),e=!0)}),e&&this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"legend",filter:{selection:null}}}))})}}}define("contour-legend",ContourLegend);class ContourMeasure extends ContourBase{static get observed(){return["label","value","point","line","unit","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},point:{attribute:"point"},line:{attribute:"line"},unit:{attribute:"unit"},src:{attribute:"src"}}}render(){if(this.classList.add("c-measure"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"measure","Measure")),wireStates(this),loadRemote(this,["label","value","point","line"]),renderStates(this,"measure"))return;const t=remoteData(this,"label"),e=remoteData(this,"value"),r=remoteData(this,"point"),s=remoteData(this,"line");if(!(t||e||r||s))return void renderEmpty(this,"measure");if(t){this.ensure(".c-measure__label",()=>{const t=document.createElement("span");return t.className="c-measure__label",t}).textContent=t}else{const t=this.querySelector(".c-measure__label");t&&t.remove()}if(e){this.ensure(".c-measure__readout",()=>{const t=document.createElement("span");return t.className="c-measure__readout",t}).textContent=e}else{const t=this.querySelector(".c-measure__readout");t&&t.remove()}let i=this.querySelector(".c-measure__unit-select");i||(i=document.createElement("select"),i.className="c-measure__unit-select",i.setAttribute("aria-label",labelText(this,"unit","Unit")),i.setAttribute("data-contour-label","true"),this.appendChild(i)),["m","km","mi","ft"].forEach(t=>{if(!i.querySelector('option[value="'+t+'"]')){const e=document.createElement("option");e.value=t,e.textContent=t,i.appendChild(e)}});const a=void 0!==this._measureUnit?this._measureUnit:this.getAttribute("unit");if(a&&i.querySelector('option[value="'+a+'"]')&&(i.value=a),r){this.ensure(".c-measure__point",()=>{const t=document.createElement("span");return t.className="c-measure__point",t}).textContent=r}else{const t=this.querySelector(".c-measure__point");t&&t.remove()}if(!s){const t=this.querySelector("svg");return void(t&&t.remove())}if(s){this.ensure(".c-measure__line",()=>{const t=document.createElement("span");return t.className="c-measure__line",t}).style.inlineSize=s}else{const t=this.querySelector(".c-measure__line");t&&t.remove()}}enhance(){this._wiredMeasure||(this._wiredMeasure=!0,this.addEventListener("change",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-measure__unit-select"):null;e&&this.contains(e)&&(this._measureUnit=e.value,this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{unit:e.value}})))}))}}define("contour-measure",ContourMeasure);class ContourTimeline extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-timeline");let t=this.querySelector(".c-timeline__list");if(t||(t=document.createElement("ol"),t.className="c-timeline__list",t.setAttribute("aria-label",this.getAttribute("aria-label")||"Timeline"),this.appendChild(t)),wireStates(this),loadRemote(this,"items"),renderStates(this,"timeline"))return;const e=Array.from(this.children).filter(t=>t.classList&&t.classList.contains("c-timeline__item")),r=remoteData(this,"items");if(r&&!e.length){Array.from(t.querySelectorAll(".c-timeline__item")).forEach(t=>t.remove());try{JSON.parse(r).forEach((e,r)=>{const s=document.createElement("li");if(s.className="c-timeline__item",s.setAttribute("tabindex",0===r?"0":"-1"),e.time){const t=document.createElement("time");t.className="c-timeline__time",t.setAttribute("datetime",String(e.time)),t.textContent=e.time,s.appendChild(t)}if(e.title){const t=document.createElement("div");t.className="c-timeline__title",t.textContent=e.title,s.appendChild(t)}if(e.text){const t=document.createElement("div");t.className="c-timeline__text",t.textContent=e.text,s.appendChild(t)}t.appendChild(s)})}catch(t){warnBadJson(this,"attribute",t)}}else e.length||renderEmpty(this,"timeline")}enhance(){if(this._wiredTimeline)return;this._wiredTimeline=!0;Array.from(this.querySelectorAll(".c-timeline__item")).forEach((t,e)=>t.setAttribute("tabindex",0===e?"0":"-1")),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-timeline__item"):null;if(!e||!this.contains(e))return;const r=Array.from(this.querySelectorAll(".c-timeline__item")).indexOf(e);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:r}}))}),this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll(".c-timeline__item"));e.length&&navKey(t,e,{wrap:!1,homeEnd:!0,onNavigate:t=>e.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{"Enter"!==t.key&&" "!==t.key||this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:e.indexOf(document.activeElement)}}))}})})}}define("contour-timeline",ContourTimeline);class ContourHeatmap extends ContourBase{static get observed(){return["cells","count","legend","brownout","brownout-level","empty","loading","values","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","dir","no-cache"]}static get properties(){return{cells:{attribute:"cells"},count:{attribute:"count"},legend:{attribute:"legend"},src:{attribute:"src"}}}render(){if(this.classList.add("c-heatmap"),this.hasAttribute("role")||this.setAttribute("role","grid"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"heatmap","Heatmap")),wireStates(this),loadRemote(this,"cells"),renderStates(this,"heatmap"))return;const t=Array.from(this.querySelectorAll(":scope > .c-heatmap__cell"));if(t.length){const e=Math.ceil(Math.sqrt(t.length));this.style.gridTemplateColumns="repeat("+e+", 1fr)",this.style.inlineSize="16rem";let r=null,s=0;const i=()=>{r=document.createElement("div"),r.setAttribute("role","row"),this.appendChild(r),s=0};i(),t.forEach(t=>{t.setAttribute("role","gridcell"),r.appendChild(t),s++,s===e&&i()})}else{Array.from(this.querySelectorAll(".c-heatmap__cell")).forEach(t=>t.remove());const e=Math.min(200,Math.max(0,parseInt(this.getAttribute("cells")||this.getAttribute("count")||"0",10)||0)),r=e>0?Math.ceil(Math.sqrt(e)):1;if(this.style.gridTemplateColumns="repeat("+r+", 1fr)",this.style.inlineSize="16rem",e>0){let t=[];try{t=JSON.parse(this.getAttribute("values")||"[]")}catch(e){t=[]}const s=t.map(t=>{const e=Number(t);return Number.isFinite(e)?e:null}),i=s.filter(t=>null!==t),a=i.length?Math.min.apply(null,i):0,o=(i.length?Math.max.apply(null,i):0)-a,n=t=>null===t?0:o<=0?4:Math.min(7,1+Math.floor((t-a)/o*7));let l=null,c=0;const u=()=>{l=document.createElement("div"),l.setAttribute("role","row"),this.appendChild(l),c=0};u();for(let i=0;i<e;i++){const a=document.createElement("div");a.className="c-heatmap__cell",a.setAttribute("role","gridcell"),a.setAttribute("tabindex",0===i?"0":"-1"),a.dataset.index=String(i);const o=n(s[i]);o&&(a.style.setProperty("--c","var(--chart-seq-"+o+")"),a.dataset.band=String(o)),void 0!==t[i]&&a.setAttribute("data-title",String(t[i])),l.appendChild(a),c++,c===r&&i<e-1&&u()}if(this.shed("tooltip",2)){const t=this.querySelector(".c-heatmap__tooltip");t&&t.remove()}else{this.ensure(".c-heatmap__tooltip",()=>{const t=document.createElement("div");return t.className="c-heatmap__tooltip",t.setAttribute("role","tooltip"),t.setAttribute("hidden",""),t.id=contourId("heatmap-tip"),t}).setAttribute("hidden","")}}else t.length||renderEmpty(this,"heatmap")}if(this.hasAttribute("legend")&&!this.shed("legend",2)){this.ensure(".c-heatmap__legend",()=>{const t=document.createElement("div");t.className="c-heatmap__legend";const e=document.createElement("div");return e.className="c-heatmap__legend-bar",t.appendChild(e),t})}else{const t=this.querySelector(".c-heatmap__legend");t&&t.remove()}}enhance(){if(this._wiredHeatmap)return;this._wiredHeatmap=!0;const t=()=>Array.from(this.querySelectorAll(".c-heatmap__cell")),e=t=>{const e=this.querySelector(".c-heatmap__tooltip");if(!e)return;const r=t.target&&t.target.closest?t.target.closest(".c-heatmap__cell"):null;if(!r||!this.contains(r))return void e.setAttribute("hidden","");const s=r.getAttribute("data-title")||r.getAttribute("title");e.textContent=s||labelText(this,"cell","Cell")+" "+(r.dataset.index||"");const i=this.getBoundingClientRect(),a=r.getBoundingClientRect();this.style.position=this.style.position||"relative",e.style.setProperty("--chart-tip-inline-start",a.left-i.left+a.width/2+"px"),e.style.setProperty("--chart-tip-block-start",a.top-i.top+"px"),e.removeAttribute("hidden")},r=()=>{const t=this.querySelector(".c-heatmap__tooltip");t&&t.setAttribute("hidden","")};this.addEventListener("mouseover",e),this.addEventListener("mouseout",t=>{t.relatedTarget&&this.contains(t.relatedTarget)||r()}),this.addEventListener("focusin",t=>{const r=t.target&&t.target.closest?t.target.closest(".c-heatmap__cell"):null;if(r&&this.contains(r)){e({target:r});const t=this.querySelector(".c-heatmap__tooltip");t&&t.id&&r.setAttribute("aria-describedby",t.id)}}),this.addEventListener("focusout",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-heatmap__cell"):null;e&&this.contains(e)&&e.removeAttribute("aria-describedby"),this.contains(t.relatedTarget)||r()}),this.addEventListener("keydown",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!r||!this.contains(r))return;const s=t(),i=s.indexOf(r);let a=-1;const o="rtl"===(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase();if("ArrowRight"===e.key)a=o?Math.max(i-1,0):Math.min(i+1,s.length-1);else if("ArrowLeft"===e.key)a=o?Math.min(i+1,s.length-1):Math.max(i-1,0);else if("ArrowDown"===e.key)a=Math.min(i+Math.ceil(Math.sqrt(s.length)),s.length-1);else if("ArrowUp"===e.key)a=Math.max(i-Math.ceil(Math.sqrt(s.length)),0);else if("Home"===e.key)a=0;else if("End"===e.key)a=s.length-1;else if("Enter"===e.key||" "===e.key)return e.preventDefault(),void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:1,index:i}}));if(a>=0&&a!==i){e.preventDefault(),s.forEach((t,e)=>t.setAttribute("tabindex",e===a?"0":"-1"));try{s[a].focus()}catch(e){}}}),this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!r||!this.contains(r))return;const s=t().indexOf(r);s>=0&&this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:1,index:s}}))})}}define("contour-heatmap",ContourHeatmap);class ContourCompare extends ContourBase{static get observed(){return["no","text","yes","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{no:{attribute:"no"},text:{attribute:"text"},yes:{attribute:"yes"},src:{attribute:"src"}}}render(){this.classList.add("c-compare"),this.setAttribute("role","group");const t="Comparison",e=this.getAttribute("aria-label");if(null!==e&&e!==this._lastAutoAria||(this.setAttribute("aria-label",t),this._lastAutoAria=t),wireStates(this),loadRemote(this,["no","text","yes"]),renderStates(this,"compare"))return;const r=remoteData(this,"yes")||this._remoteData&&this._remoteData.yes,s=remoteData(this,"no")||this._remoteData&&this._remoteData.no,i=remoteData(this,"text")||this._remoteData&&this._remoteData.text;if(Array.from(this.querySelectorAll(".c-compare__yes, .c-compare__no, .c-compare__text")).forEach(t=>t.remove()),r){const t=document.createElement("span");t.className="c-compare__yes",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-check" /></svg>'),this.appendChild(t)}if(s){const t=document.createElement("div");t.className="c-compare__no",t.textContent=s,this.appendChild(t)}if(i){const t=document.createElement("p");t.className="c-compare__text",t.textContent=i,this.appendChild(t)}r||s||i||renderEmpty(this,"compare")}}define("contour-compare",ContourCompare);class ContourSparkline extends ContourBase{static get observed(){return["points","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{points:{attribute:"points"},src:{attribute:"src"}}}render(){if(this.classList.add("c-sparkline"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"sparkline","Sparkline")),wireStates(this),loadRemote(this,"points"),renderStates(this,"sparkline"))return;const t=remoteData(this,"points");if(t)try{const e=JSON.parse(t),r=Array.isArray(e)?e.filter(Number.isFinite):[];if(0===r.length)throw new Error("empty");Array.from(this.querySelectorAll(".c-sparkline__dot, .c-sparkline__line, .c-sparkline__area")).forEach(t=>t.remove());const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("class","c-sparkline__line"),s.setAttribute("viewBox","0 0 100 30"),s.setAttribute("preserveAspectRatio","none"),s.style.inlineSize="100%",s.style.blockSize="100%",s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("title",this.getAttribute("aria-label")||"Sparkline");const i=Math.min(...r),a=Math.max(...r)-i||1,o=t=>30-(t-i)/a*30;this._sparkScale={min:i,range:a};const n=r.length,l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("d",r.map((t,e)=>(0===e?"M":"L")+" "+(1===n?50:100*e/(n-1))+" "+o(t)).join(" ")),s.appendChild(l);const c=document.createElementNS("http://www.w3.org/2000/svg","circle");c.setAttribute("class","c-sparkline__dot"),c.setAttribute("r","2"),c.setAttribute("cx","0"),c.setAttribute("cy","15"),s.appendChild(c),this.appendChild(s),this._sparkPoints=e;this.ensure(".c-sparkline__tooltip",()=>{const t=document.createElement("div");return t.className="c-sparkline__tooltip",t.setAttribute("role","tooltip"),t.setAttribute("hidden",""),t.id=contourId("sparkline-tip"),t}).setAttribute("hidden","")}catch(t){Array.from(this.querySelectorAll("svg")).forEach(t=>t.remove()),renderEmpty(this,"sparkline")}else renderEmpty(this,"sparkline")}enhance(){if(this._wiredSparkline)return;this._wiredSparkline=!0,this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");const t=t=>{const e=this.querySelector("svg"),r=this.querySelector(".c-sparkline__tooltip"),s=this.querySelector(".c-sparkline__dot");if(!r||!e)return;const i=e.getBoundingClientRect(),a=t.clientX-i.left,o=Math.max(0,Math.min(1,a/i.width)),n=this._sparkPoints||[];if(0===n.length)return;const l=Math.round(o*(n.length-1)),c=n[l],u=1===n.length?50:100*l/(n.length-1),d=this._sparkScale||{min:Math.min(...n),range:Math.max(...n)-Math.min(...n)||1},h=30-(c-d.min)/d.range*30;s&&(s.setAttribute("cx",String(u)),s.setAttribute("cy",String(h)),s.removeAttribute("hidden")),r.textContent=String(c);const m=u/100*i.width;r.style.setProperty("--chart-tip-inline-start",m+"px"),r.style.setProperty("--chart-tip-block-start","0px"),r.removeAttribute("hidden")},e=()=>{const t=this.querySelector(".c-sparkline__tooltip"),e=this.querySelector(".c-sparkline__dot");t&&t.setAttribute("hidden",""),e&&e.setAttribute("hidden","")};this.addEventListener("mousemove",t),this.addEventListener("mouseleave",e),this.addEventListener("focusin",()=>{if(!(this._sparkPoints||[]).length)return;const e=this.querySelector("svg");if(!e)return;const r=e.getBoundingClientRect();t({clientX:r.left+r.width-1});const s=this.querySelector(".c-sparkline__tooltip");s&&s.id&&this.setAttribute("aria-describedby",s.id)}),this.addEventListener("focusout",()=>{this.removeAttribute("aria-describedby"),e()}),this.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:1}})))})}}define("contour-sparkline",ContourSparkline);class ContourChartGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["title","series","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{title:{attribute:"title"},series:{attribute:"series"},src:{attribute:"src"}}}render(){this.classList.add("c-chart-grid"),this.setAttribute("role","group");const t="Chart grid",e=this.getAttribute("aria-label");if(null!==e&&e!==this._lastAutoAria||(this.setAttribute("aria-label",t),this._lastAutoAria=t),wireStates(this),loadRemote(this,"series"),renderStates(this,"chart-grid"))return;const r=this.getAttribute("title");if(r){this.ensure(".c-chart-grid__title",()=>{const t=document.createElement("div");return t.className="c-chart-grid__title",t}).textContent=r}const s=remoteData(this,"series");let i=[];if(s)try{const t=JSON.parse(s);Array.isArray(t)&&(i=t)}catch(t){}Array.from(this.querySelectorAll(".c-chart-grid__cell")).forEach(t=>t.remove()),i.forEach((t,e)=>{const r=Array.isArray(t)?t:t&&Array.isArray(t.values)?t.values:[],s=!Array.isArray(t)&&t&&t.label?t.label:labelText(this,"series","Series")+" "+(e+1),i=r.map(Number).filter(Number.isFinite),a=document.createElement("div");a.className="c-chart-grid__cell";const o=document.createElement("span");if(o.className="c-chart-grid__label",o.textContent=s,a.appendChild(o),i.length>1){const t=Math.min(...i),r=Math.max(...i)-t||1,s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("class","c-chart-grid__spark"),s.setAttribute("viewBox","0 0 100 30"),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("aria-hidden","true");const o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("d",i.map((e,s)=>(0===s?"M":"L")+" "+100*s/(i.length-1)+" "+(30-(e-t)/r*30)).join(" ")),o.style.stroke="var(--chart-"+(e%8+1)+")",o.style.fill="none",o.style.strokeWidth="2",s.appendChild(o),a.appendChild(s)}this.appendChild(a)}),i.length||r||renderEmpty(this,"chart-grid")}}define("contour-chart-grid",ContourChartGrid);class ContourContourPlot extends ContourBase{static get observed(){return["values","levels","label","empty"]}static get properties(){return{values:{attribute:"values"},levels:{attribute:"levels"},label:{attribute:"label"}}}render(){this.classList.add("c-contour-plot"),this.hasAttribute("role")||this.setAttribute("role","group");const t=this.getAttribute("label");!t&&this.hasAttribute("aria-label")||this.setAttribute("aria-label",t||"Contour plot");const e=this.getAttribute("values"),r=this.getAttribute("levels");let s=null;if(e)try{s=JSON.parse(e)}catch(t){s=null}let i=[.3,.5,.7];if(r)try{const t=JSON.parse(r);Array.isArray(t)&&t.length&&(i=t)}catch(t){}let a=this.querySelector("svg");if(a||(a=document.createElementNS("http://www.w3.org/2000/svg","svg"),a.setAttribute("class","c-contour-plot__svg"),this.appendChild(a)),a.removeAttribute("aria-hidden"),Array.from(a.querySelectorAll(".c-contour-plot__contour")).forEach(t=>t.remove()),!Array.isArray(s)||0===s.length||!Array.isArray(s[0])||0===s[0].length){const t=document.createElement("div");return t.className="c-contour-plot__empty",t.textContent=this.getAttribute("empty")||stateLabel(this,"contour"),void this.appendChild(t)}if(Array.isArray(s)&&s.length>1&&Array.isArray(s[0])&&s[0].length>1){const t=()=>{const t=this.clientWidth||300,e=this.clientHeight||300;a.setAttribute("viewBox",`0 0 ${t} ${e}`),a.querySelectorAll(".c-contour-plot__contour").forEach(t=>t.remove());let r=0;contourPaths(s,i,t,e).forEach((t,e)=>{if(!t.d)return;const s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d",t.d),s.setAttribute("class","c-contour-plot__contour"+(e>0?" c-contour-plot__contour--level-"+(e+1):"")),s.setAttribute("tabindex",0===r?"0":"-1"),s.setAttribute("role","button"),s.setAttribute("aria-label",labelText(this,"level","Level")+" "+(e+1)+": "+t.level),s.dataset.level=String(e+1),s.dataset.value=String(t.level),r+=1,a.appendChild(s)})};t(),"undefined"==typeof ResizeObserver||this._contourResize||(this._contourResize=new ResizeObserver(()=>t()),this._contourResize.observe(this),onDispose(this,()=>{this._contourResize.disconnect(),this._contourResize=null}))}else if(!Array.isArray(s)){const t=document.createElement("div");t.className="c-contour-plot__empty",t.textContent=this.getAttribute("empty")||"No field",this.appendChild(t)}}enhance(){if(this._wiredContourPlot)return;this._wiredContourPlot=!0;const t=()=>Array.from(this.querySelectorAll(".c-contour-plot__contour")),e=e=>{const r=t().indexOf(e);if(r<0)return;const s=Number(e.dataset.level),i=Number(e.dataset.value);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{level:s,value:i,index:r}}))};this.addEventListener("click",t=>{const r=t.target&&t.target.closest?t.target.closest(".c-contour-plot__contour"):null;r&&this.contains(r)&&e(r)}),this.addEventListener("keydown",r=>{const s=r.target&&r.target.closest?r.target.closest(".c-contour-plot__contour"):null;if(s&&this.contains(s))if("Enter"===r.key||" "===r.key)r.preventDefault(),e(s);else{const e=t();navKey(r,e,{wrap:!1,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>e.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1"))})}})}}define("contour-contour-plot",ContourContourPlot);class ContourErrorBoundary extends ContourBase{static get observed(){return["fallback","error"]}static get properties(){return{fallback:{attribute:"fallback"},error:{attribute:"error"}}}render(){this.classList.add("c-error-boundary"),this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite");if(this.getAttribute("error")){this.dataset.state="error",Array.from(this.children).forEach(t=>{t.hasAttribute("data-fallback")||(void 0===t.dataset.contourDisplay&&(t.dataset.contourDisplay=t.style.display),t.style.display="none")});let t=this.querySelector("[data-fallback]");t?("none"===t.style.display&&(t.style.display=""),("1"===t.dataset.contourGenerated||this.hasAttribute("fallback"))&&(t.textContent=this.getAttribute("fallback")||t.textContent||"Something went wrong.")):(t=document.createElement("div"),t.className="c-error-boundary__fallback",t.dataset.fallback="",t.dataset.contourGenerated="1",t.textContent=this.getAttribute("fallback")||"Something went wrong.",this.appendChild(t))}else this.dataset.state="ready",Array.from(this.children).forEach(t=>{t.hasAttribute("data-fallback")?"1"===t.dataset.contourGenerated?t.remove():t.style.display="none":void 0!==t.dataset.contourDisplay?(t.style.display=t.dataset.contourDisplay,delete t.dataset.contourDisplay):"none"===t.style.display&&(t.style.display="")})}enhance(){this._wiredErrorBoundary||(this._wiredErrorBoundary=!0,this.addEventListener("error",t=>{t.stopPropagation();const e=t&&t.error&&t.error.message?t.error.message:t&&t.message?t.message:"Unknown error",r=t&&t.target&&(t.target.src||t.target.href)?t.target.src||t.target.href:void 0;this.setAttribute("error",e),this.dispatchEvent(new CustomEvent("contour:error",{bubbles:!0,composed:!0,detail:r?{message:e,src:r}:{message:e}}))},!0))}}define("contour-error-boundary",ContourErrorBoundary);class ContourDataExport extends ContourBase{static get observed(){return["data","format","filename","label"]}static get properties(){return{data:{attribute:"data"},format:{attribute:"format"},filename:{attribute:"filename"},label:{attribute:"label"}}}render(){this.classList.add("c-data-export"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"data-export","Data export"));const t=(this.getAttribute("format")||"json").toLowerCase(),e="csv"===t||"json"===t?t:"json",r=this.ensure(".c-data-export__btn",()=>{const t=document.createElement("button");return t.className="c-btn c-data-export__btn",t.type="button",t});setHTML(r,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-download" /></svg>'),r.appendChild(document.createTextNode(" "+(this.getAttribute("label")||labelText(this,"export","Export")+" "+e.toUpperCase()))),r.parentNode!==this&&this.appendChild(r)}enhance(){if(this._wiredDataExport)return;this._wiredDataExport=!0;const t=t=>{let e=null==t?"":String(t);return/^[=+\-@\t\r]/.test(e)&&(e="'"+e),/[",\r\n]/.test(e)?'"'+e.replace(/"/g,'""')+'"':e};this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-data-export__btn"):null;if(!r||!this.contains(r))return;const s=(this.getAttribute("format")||"json").toLowerCase(),i="csv"===s||"json"===s?s:(console.warn("[contour-data-export] unsupported format:",s),"json"),a=this.getAttribute("data")||"[]";let o=a;if("csv"===i)try{const e=JSON.parse(a);if(Array.isArray(e))if(0===e.length)o="";else{const r=Object.keys(e[0]);o=[r.map(t).join(",")].concat(e.map(e=>r.map(r=>t(e[r])).join(","))).join("\r\n")}}catch(t){warnBadJson(this,"data",t)}const n=new Blob(["csv"===i?"\ufeff"+o:o],{type:"csv"===i?"text/csv":"application/json"}),l=URL.createObjectURL(n),c=document.createElement("a");c.href=l,c.download=this.getAttribute("filename")||"export."+i,document.body.appendChild(c),c.click(),c.remove(),setTimeout(()=>URL.revokeObjectURL(l),0),this.dispatchEvent(new CustomEvent("contour:export",{bubbles:!0,composed:!0,detail:{format:i}}))})}}define("contour-data-export",ContourDataExport);class ContourQueryBuilder extends ContourBase{static get observed(){return["query","fields"]}static get properties(){return{query:{attribute:"query"},fields:{attribute:"fields"}}}readRules(){const t=[],e=Array.from(this.querySelectorAll(".c-query-builder__row")),r=Array.from(this.querySelectorAll(".c-query-builder__connector__op"));return e.forEach((e,s)=>{const i={field:e.querySelector(".c-query-builder__field")?.value||"",op:e.querySelector(".c-query-builder__op")?.value||"=",value:e.querySelector(".c-query-builder__value")?.value||""};s>0&&r[s-1]&&(i.connector=r[s-1].value||"AND");const a=e.closest(".c-query-builder__group");a&&(i.group=a._groupName||""),t.push(i)}),t}static reindexConnectors(t,e){return t.forEach((t,r)=>{r>0&&e&&e[r]?t.connector=e[r]:delete t.connector}),t}attributeChangedCallback(t,e,r){"query"===t&&this._suppressQueryRender||super.attributeChangedCallback(t,e,r)}commit(t,e=!0){if(e)this.setAttribute("query",JSON.stringify(t));else{this._suppressQueryRender=!0;try{this.setAttribute("query",JSON.stringify(t))}finally{this._suppressQueryRender=!1}}this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{query:t}}))}render(){this.classList.add("c-query-builder");const t=this.getAttribute("fields");let e=[];if(t)try{e=JSON.parse(t)}catch(t){e=[]}const r=this.getAttribute("query");let s=[];if(r)try{s=JSON.parse(r)}catch(t){s=[]}const i=this.ensure(".c-query-builder__list",()=>{const t=document.createElement("div");return t.className="c-query-builder__list",t});Array.from(i.querySelectorAll(".c-query-builder__row, .c-query-builder__connector, .c-query-builder__group")).forEach(t=>t.remove());let a=null;s.forEach((t,r)=>{const o=t&&t.group?String(t.group):"",n=!(!o||!a||a._groupName!==o);let l=null;if(r>0){l=document.createElement("div"),l.className="c-query-builder__connector";const e=document.createElement("select");e.className="c-input c-query-builder__connector__op",e.setAttribute("aria-label",labelText(this,"connector","Connector")+" "+r),["AND","OR"].forEach(r=>{const s=document.createElement("option");s.value=r,s.textContent=r,r===(t.connector||"AND")&&(s.selected=!0),e.appendChild(s)}),l.appendChild(e)}if(o)if(n)l&&a.appendChild(l);else{l&&i.appendChild(l),a=document.createElement("div"),a.className="c-query-builder__group",a._groupName=o;const t=document.createElement("div");t.className="c-query-builder__group-head";const e=document.createElement("div");e.className="c-query-builder__group-label",e.textContent=o;const r=document.createElement("button");r.type="button",r.className="c-btn c-btn--sm c-btn--ghost c-query-builder__group-remove",r.setAttribute("aria-label",labelText(this,"remove-group","Remove group")+" "+o),r.setAttribute("data-group",o),r.textContent="×",t.appendChild(e),t.appendChild(r),a.appendChild(t),i.appendChild(a)}else l&&i.appendChild(l),a=null;const c=document.createElement("div");c.className="c-query-builder__row";const u=document.createElement("select");u.className="c-input c-query-builder__field",u.setAttribute("aria-label",labelText(this,"field","Field")+" "+(r+1)),e.forEach(e=>{const r=document.createElement("option");r.value="string"==typeof e?e:e.value||e.label||"",r.textContent="string"==typeof e?e:e.label||e.value||"",r.value===t.field&&(r.selected=!0),u.appendChild(r)});const d=document.createElement("select");d.className="c-input c-query-builder__op",d.setAttribute("aria-label",labelText(this,"operator","Operator")+" "+(r+1)),["=","!=",">","<","contains"].forEach(e=>{const r=document.createElement("option");r.value=e,r.textContent=e,e===t.op&&(r.selected=!0),d.appendChild(r)});const h=document.createElement("input");h.className="c-input c-query-builder__value",h.type="text",h.setAttribute("value",t.value||""),h.value=t.value||"",h.setAttribute("aria-label",labelText(this,"value","Value")+" "+(r+1));const m=document.createElement("button");m.type="button",m.className="c-btn c-btn--sm c-btn--ghost c-query-builder__move c-query-builder__move--up",m.setAttribute("aria-label",labelText(this,"move-rule","Move rule")+" "+(r+1)+" "+labelText(this,"up","up")),m.textContent="↑",0===r&&(m.disabled=!0);const b=document.createElement("button");b.type="button",b.className="c-btn c-btn--sm c-btn--ghost c-query-builder__move c-query-builder__move--down",b.setAttribute("aria-label",labelText(this,"move-rule","Move rule")+" "+(r+1)+" "+labelText(this,"down","down")),b.textContent="↓",r===s.length-1&&(b.disabled=!0);const p=document.createElement("button");p.type="button",p.className="c-btn c-btn--sm c-btn--ghost c-query-builder__remove",p.setAttribute("aria-label",labelText(this,"remove-rule","Remove rule")+" "+(r+1)),p.textContent="×",c.appendChild(u),c.appendChild(d),c.appendChild(h),c.appendChild(m),c.appendChild(b),c.appendChild(p),a?a.appendChild(c):i.appendChild(c)});const o=this.ensure(".c-query-builder__add",()=>{const t=document.createElement("button");return t.type="button",t.className="c-btn c-btn--sm c-query-builder__add",t});setHTML(o,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-plus" /></svg>'),o.appendChild(document.createTextNode(" "+labelText(this,"add-rule","Add rule"))),o.parentNode!==this&&this.appendChild(o);const n=this.ensure(".c-query-builder__add-group",()=>{const t=document.createElement("button");return t.type="button",t.className="c-btn c-btn--sm c-btn--ghost c-query-builder__add-group",t});setHTML(n,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-plus" /></svg>'),n.appendChild(document.createTextNode(" "+labelText(this,"add-group","Add group"))),n.parentNode!==this&&this.appendChild(n)}enhance(){this._wiredQueryBuilder||(this._wiredQueryBuilder=!0,this.addEventListener("change",t=>{const e=t.target;e instanceof Element&&e.matches(".c-query-builder__field, .c-query-builder__op, .c-query-builder__value, .c-query-builder__connector__op")&&this.commit(this.readRules(),!1)}),this.addEventListener("click",t=>{const e=t.target;if(!(e instanceof Element))return;if(e.closest(".c-query-builder__add")){const t=this.readRules().map(t=>t.connector),e=this.readRules();e.push({field:"",op:"=",value:""}),this.commit(ContourQueryBuilder.reindexConnectors(e,t));const r=this.querySelectorAll(".c-query-builder__row"),s=r[r.length-1],i=s&&s.querySelector(".c-query-builder__field");if(i)try{i.focus()}catch(t){}return}if(e.closest(".c-query-builder__add-group")){const t=this.readRules().map(t=>t.connector),e=this.readRules(),r=new Set(e.map(t=>t.group).filter(Boolean));let s=1;for(;r.has("Group "+s);)s++;e.push({field:"",op:"=",value:"",group:"Group "+s}),this.commit(ContourQueryBuilder.reindexConnectors(e,t));const i=this.querySelectorAll(".c-query-builder__row"),a=i[i.length-1],o=a&&a.querySelector(".c-query-builder__field");if(o)try{o.focus()}catch(t){}return}const r=e.closest(".c-query-builder__group-remove");if(r){const t=r.getAttribute("data-group")||"",e=this.readRules().map(t=>t.connector),s=this.readRules().filter(e=>(e.group||"")!==t);return void this.commit(ContourQueryBuilder.reindexConnectors(s,e))}const s=e.closest(".c-query-builder__move");if(s){const t=s.closest(".c-query-builder__row");if(!t)return;const e=s.classList.contains("c-query-builder__move--up"),r=this.readRules().map(t=>t.connector),i=this.readRules(),a=Array.from(this.querySelectorAll(".c-query-builder__row")).indexOf(t);if(a<0)return;const o=e?a-1:a+1;if(o<0||o>=i.length)return;const n=i[o];i[o]=i[a],i[a]=n,this.commit(ContourQueryBuilder.reindexConnectors(i,r));const l=this.querySelectorAll(".c-query-builder__row")[o],c=l&&l.querySelector(e?".c-query-builder__move--up":".c-query-builder__move--down");if(c&&!c.disabled)try{c.focus()}catch(t){}return}if(e.closest(".c-query-builder__remove")){const t=e.closest(".c-query-builder__row");if(!t)return;const r=this.readRules().map(t=>t.connector),s=this.readRules(),i=Array.from(this.querySelectorAll(".c-query-builder__row")).indexOf(t);i>=0&&s.splice(i,1),this.commit(ContourQueryBuilder.reindexConnectors(s,r))}}))}}function tokenColor(t,e,r,s){const i=safeColor(t.getAttribute(e));if(i)return i;try{const e=getComputedStyle(t).getPropertyValue(r).trim();if(e)return e}catch(t){}return s}define("contour-query-builder",ContourQueryBuilder);class ContourDonutGlyph extends ContourBase{static get observed(){return["size","value","color","stroke-width","bg-color","empty","loading","error","cache-key","no-cache","retry","skeleton","src"]}static get properties(){return{size:{attribute:"size"},value:{attribute:"value"},color:{attribute:"color"},strokeWidth:{attribute:"stroke-width"},bgColor:{attribute:"bg-color"}}}render(){if(this.classList.add("c-donut-glyph"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"donut-glyph","Donut glyph")),wireStates(this),renderStates(this,"donut-glyph"))return;const t=this.querySelector("canvas");t&&t.remove();const e=Number(this.getAttribute("size"))||24,r=document.createElement("canvas");r.width=e,r.height=e,r.style.inlineSize=e+"px",r.style.blockSize=e+"px";const s=r.getContext("2d");s&&(paintDonutGlyph(s,{size:e,value:Number(this.getAttribute("value"))||0,color:tokenColor(this,"color","--color-data","#1f77b4"),strokeWidth:this.getAttribute("stroke-width")?Number(this.getAttribute("stroke-width")):void 0,bgColor:this.getAttribute("bg-color")||"transparent"}),this.appendChild(r))}}define("contour-donut-glyph",ContourDonutGlyph);class ContourSparklineGlyph extends ContourBase{static get observed(){return["size","points","color","stroke-width","bg-color","empty","loading","error","cache-key","no-cache","retry","skeleton","src"]}static get properties(){return{size:{attribute:"size"},points:{attribute:"points"},color:{attribute:"color"},strokeWidth:{attribute:"stroke-width"},bgColor:{attribute:"bg-color"}}}render(){if(this.classList.add("c-sparkline-glyph"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"sparkline-glyph","Sparkline glyph")),wireStates(this),renderStates(this,"sparkline-glyph"))return;const t=this.querySelector("canvas");t&&t.remove();const e=Number(this.getAttribute("size"))||24,r=document.createElement("canvas");r.width=e,r.height=e,r.style.inlineSize=e+"px",r.style.blockSize=e+"px";const s=r.getContext("2d");if(!s)return;let i=[];const a=this.getAttribute("points");if(a)try{const t=JSON.parse(a);i=Array.isArray(t)?t.filter(Number.isFinite):[]}catch(t){warnBadJson(this,"points",t)}paintSparklineGlyph(s,{size:e,values:i,color:tokenColor(this,"color","--color-data","#1f77b4"),strokeWidth:this.getAttribute("stroke-width")?Number(this.getAttribute("stroke-width")):void 0,bgColor:this.getAttribute("bg-color")||"transparent"}),this.appendChild(r)}}define("contour-sparkline-glyph",ContourSparklineGlyph);class ContourPurityRing extends ContourBase{static get observed(){return["size","hue","concentration","color","uncertainty","time-step","time-steps","empty","loading","error","cache-key","no-cache","retry","skeleton","src"]}static get properties(){return{size:{attribute:"size"},hue:{attribute:"hue"},concentration:{attribute:"concentration"},color:{attribute:"color"},uncertainty:{attribute:"uncertainty"},timeStep:{attribute:"time-step"},timeSteps:{attribute:"time-steps"}}}render(){if(this.classList.add("c-purity-ring"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"purity-ring","Purity ring")),wireStates(this),renderStates(this,"purity-ring"))return;const t=this.querySelector("canvas");t&&t.remove();const e=Number(this.getAttribute("size"))||32,r=document.createElement("canvas");r.width=e,r.height=e,r.style.inlineSize=e+"px",r.style.blockSize=e+"px";const s=r.getContext("2d");s&&(paintPurityRing(s,{size:e,hue:Number(this.getAttribute("hue"))||0,concentration:Number(this.getAttribute("concentration"))||0,color:tokenColor(this,"color","--color-data",void 0),uncertainty:Number(this.getAttribute("uncertainty"))||0,timeStep:this.getAttribute("time-step")?Number(this.getAttribute("time-step")):void 0,timeSteps:this.getAttribute("time-steps")?Number(this.getAttribute("time-steps")):4}),this.appendChild(r))}}define("contour-purity-ring",ContourPurityRing);const unit=t=>Math.max(0,Math.min(1,Number(t)||0)),quantise=(t,e)=>Math.round(unit(t)*e)/e,categoryColor=(t,e)=>["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd"][Math.max(0,Math.min(4,Math.floor(Number(t)||0)))]||e,spriteStroke=t=>Math.max(1,Math.round((Number(t)||24)/16));export function paintDonutGlyph(t,{size:e=24,value:r=0,color:s="#1f77b4",strokeWidth:i,bgColor:a="transparent"}={}){const o=Number(e)||24,n=null!=i?Number(i):spriteStroke(o),l=unit(r),c=o/2,u=o/2,d=(o-n)/2;a&&"transparent"!==a?(t.fillStyle=a,t.fillRect(0,0,o,o)):t.clearRect(0,0,o,o),t.beginPath(),t.arc(c,u,d,0,2*Math.PI),t.lineWidth=n,t.strokeStyle="rgba(0,0,0,0.12)",t.stroke(),l>0&&(t.beginPath(),t.arc(c,u,d,-Math.PI/2,-Math.PI/2+2*l*Math.PI),t.lineWidth=n,t.strokeStyle=s,t.lineCap="round",t.stroke())}export function paintSparklineGlyph(t,{size:e=24,values:r=[],color:s="#1f77b4",strokeWidth:i,bgColor:a="transparent"}={}){const o=Number(e)||24,n=null!=i?Number(i):spriteStroke(o),l=Array.isArray(r)?r.filter(t=>Number.isFinite(t)):[],c=l.length;if(a&&"transparent"!==a?(t.fillStyle=a,t.fillRect(0,0,o,o)):t.clearRect(0,0,o,o),c<2)return;const u=n+1,d=o-2*u,h=o-2*u,m=Math.min(...l),b=Math.max(...l)-m||1;t.beginPath(),l.forEach((e,r)=>{const s=u+r/(c-1)*d,i=(t=>u+h-(t-m)/b*h)(e);0===r?t.moveTo(s,i):t.lineTo(s,i)}),t.lineWidth=n,t.strokeStyle=s,t.lineCap="round",t.lineJoin="round",t.stroke()}export function paintPurityRing(t,{size:e=32,hue:r=0,concentration:s=0,color:i,uncertainty:a=0,timeStep:o=0,timeSteps:n=4}={}){const l=Number(e)||32,c=spriteStroke(l),u=l/2,d=l/2,h=(l-2*c)/2,m=Math.max(0,Math.min(4,Math.floor(Number(r)||0))),b=i||categoryColor(m,"#1f77b4"),p=quantise(s,8);if(t.clearRect(0,0,l,l),t.beginPath(),t.arc(u,d,h,0,2*Math.PI),t.lineWidth=c,t.strokeStyle="rgba(0,0,0,0.12)",t.stroke(),p>0&&(t.beginPath(),t.arc(u,d,h,-Math.PI/2,-Math.PI/2+2*p*Math.PI),t.lineWidth=c,t.strokeStyle=b,t.lineCap="round",t.stroke()),a>0){const e=h+c,r=1===a?[c,2*c]:[2*c,c];t.beginPath(),t.arc(u,d,e,0,2*Math.PI),t.lineWidth=c,t.strokeStyle=b,t.setLineDash(r),t.stroke(),t.setLineDash([])}if(n>0&&o>=0){const e=Math.max(0,Math.min(n-1,Math.floor(Number(o)||0))),r=-Math.PI/2+e/n*2*Math.PI,s=u+h*Math.cos(r),i=d+h*Math.sin(r);t.beginPath(),t.arc(s,i,.75*c,0,2*Math.PI),t.fillStyle=b,t.fill()}}
|