contour-ds 1.7.2 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +80 -11
  2. package/dist/agent-rules.json +16 -0
  3. package/dist/build-manifest.json +181 -104
  4. package/dist/contour-wc-content.esm.js +5125 -0
  5. package/dist/contour-wc-content.esm.min.js +1 -0
  6. package/dist/contour-wc-dashboard.esm.js +8654 -0
  7. package/dist/contour-wc-dashboard.esm.min.js +1 -0
  8. package/dist/contour-wc-data.esm.js +8260 -0
  9. package/dist/contour-wc-data.esm.min.js +1 -0
  10. package/dist/contour-wc-docs.esm.js +4305 -0
  11. package/dist/contour-wc-docs.esm.min.js +1 -0
  12. package/dist/contour-wc-feedback.esm.js +4917 -0
  13. package/dist/contour-wc-feedback.esm.min.js +1 -0
  14. package/dist/contour-wc-forms.esm.js +5688 -0
  15. package/dist/contour-wc-forms.esm.min.js +1 -0
  16. package/dist/contour-wc-interaction.esm.js +4580 -0
  17. package/dist/contour-wc-interaction.esm.min.js +1 -0
  18. package/dist/contour-wc-layout.esm.js +4174 -0
  19. package/dist/contour-wc-layout.esm.min.js +1 -0
  20. package/dist/contour-wc-map.esm.js +5205 -0
  21. package/dist/contour-wc-map.esm.min.js +1 -0
  22. package/dist/contour-wc-misc.esm.js +4264 -0
  23. package/dist/contour-wc-misc.esm.min.js +1 -0
  24. package/dist/contour-wc-navigation.esm.js +5844 -0
  25. package/dist/contour-wc-navigation.esm.min.js +1 -0
  26. package/dist/contour-wc-ui.esm.js +9009 -0
  27. package/dist/contour-wc-ui.esm.min.js +1 -0
  28. package/dist/contour-wc.esm.js +6109 -1641
  29. package/dist/contour-wc.esm.min.js +1 -1
  30. package/dist/contour-wc.js +6108 -1641
  31. package/dist/contour-wc.min.js +1 -1
  32. package/dist/contour.code-snippets +4512 -0
  33. package/dist/contour.components.json +2597 -799
  34. package/dist/contour.css +5275 -4050
  35. package/dist/contour.d.ts +560 -1085
  36. package/dist/contour.esm.js +7 -0
  37. package/dist/contour.esm.min.js +1 -1
  38. package/dist/contour.html-data.json +10311 -0
  39. package/dist/contour.js +7 -0
  40. package/dist/contour.min.css +1 -1
  41. package/dist/contour.min.js +1 -1
  42. package/dist/contour.react.d.ts +420 -0
  43. package/dist/contour.single.html +17 -0
  44. package/dist/contour.single.min.css +1 -0
  45. package/dist/contour.tokens.json +940 -902
  46. package/dist/contour.vue.d.ts +418 -0
  47. package/dist/contour.web-types.json +10703 -0
  48. package/dist/custom-elements.json +30708 -0
  49. package/dist/docs/actions.md +3 -2
  50. package/dist/docs/affordances.md +23 -9
  51. package/dist/docs/apireference.md +1 -1
  52. package/dist/docs/colour.md +1 -1
  53. package/dist/docs/componentindex.md +6 -2
  54. package/dist/docs/data.md +7 -2
  55. package/dist/docs/docs.md +9 -2
  56. package/dist/docs/feedback.md +1 -1
  57. package/dist/docs/field.md +1 -1
  58. package/dist/docs/forms.md +1 -1
  59. package/dist/docs/index.json +22 -20
  60. package/dist/docs/install.md +1 -1
  61. package/dist/docs/landing.md +1 -1
  62. package/dist/docs/mapengine.md +19 -2
  63. package/dist/docs/motion.md +1 -1
  64. package/dist/docs/navigation.md +1 -1
  65. package/dist/docs/overlays.md +1 -1
  66. package/dist/docs/overview.md +1 -1
  67. package/dist/docs/patterns.md +2 -2
  68. package/dist/docs/playground.md +22 -2
  69. package/dist/docs/principles.md +1 -1
  70. package/dist/docs/recipes.md +13 -8
  71. package/dist/docs/space.md +1 -1
  72. package/dist/docs/status.md +14 -2
  73. package/dist/docs/surfaces.md +1 -1
  74. package/dist/docs/theming.md +1 -1
  75. package/dist/docs/type.md +1 -1
  76. package/dist/docs/webcomponents.md +17 -3
  77. package/dist/registry/items/contour-core.json +2 -2
  78. package/dist/registry/items/contour-data.json +2 -2
  79. package/dist/registry/items/contour-docs.json +2 -2
  80. package/dist/registry/items/contour-landing.json +2 -2
  81. package/dist/registry/registry.json +8 -8
  82. package/dist/surfaces/contour-core.min.css +1 -1
  83. package/dist/surfaces/contour-data.min.css +1 -1
  84. package/dist/surfaces/contour-docs.min.css +1 -1
  85. package/dist/surfaces/contour-landing.min.css +1 -1
  86. package/dist/wc/behaviours.mjs +45 -57
  87. package/dist/wc/content.mjs +263 -63
  88. package/dist/wc/core.mjs +390 -71
  89. package/dist/wc/dashboard.mjs +220 -13
  90. package/dist/wc/data.mjs +1075 -460
  91. package/dist/wc/docs.mjs +105 -12
  92. package/dist/wc/feedback.mjs +63 -14
  93. package/dist/wc/forms.mjs +733 -104
  94. package/dist/wc/index.mjs +9 -2
  95. package/dist/wc/interaction.mjs +182 -28
  96. package/dist/wc/layout.mjs +95 -25
  97. package/dist/wc/map.mjs +185 -118
  98. package/dist/wc/misc.mjs +124 -24
  99. package/dist/wc/navigation.mjs +384 -115
  100. package/dist/wc/shadow.mjs +94 -18
  101. package/dist/wc/states.mjs +21 -3
  102. package/dist/wc/svg.mjs +104 -0
  103. package/dist/wc/ui.mjs +1988 -476
  104. package/integrations/README.md +2 -0
  105. package/integrations/ai/CLAUDE.md +3 -3
  106. package/integrations/frameworks/README.md +235 -0
  107. package/integrations/native/style-dictionary.config.json +1 -1
  108. package/integrations/tailwind/contour-theme.css +5 -6
  109. package/package.json +53 -24
@@ -1 +1 @@
1
- "use strict";export const REGISTERED=[];const DISPOSERS=new WeakMap();export const onDispose=(host,fn)=>{let list=DISPOSERS.get(host);if(!list){list=[];DISPOSERS.set(host,list)}list.push(fn)};function contourDebugEnabled(){try{if(typeof window!=="undefined"&&(window.ContourDebug||window.__CONTOUR_DEBUG__))return true}catch(e){}try{if(typeof process!=="undefined"&&process.env&&process.env.NODE_ENV!=="production"&&process.env.CONTOUR_DEBUG)return true}catch(e){}return false}const runDisposers=(host)=>{const list=DISPOSERS.get(host);if(!list)return;DISPOSERS.delete(host);for(const fn of list){try{fn()}catch(e){if(contourDebugEnabled()){try{console.warn("Contour disposer failed for",host&&host.tagName,e)}catch(err){}}}}};let _contourIdCounter=0;export const contourId=(prefix)=>prefix+"-"+(++_contourIdCounter).toString(36);export const define=(name,cls)=>{if(typeof customElements==="undefined"||!customElements||typeof customElements.define!=="function")return;if(customElements.get(name))return;customElements.define(name,cls);REGISTERED.push(name)};export const MODS=["variant","size","color"];export const CONTOUR_EVENTS=Object.freeze({"contour:activate":{payload:["row"],composed:true},"contour:add":{payload:["value"],composed:true},"contour:activity-select":{payload:["index","text"],composed:true},"contour:break-change":{payload:["layer","value"],composed:true},"contour:style-resolved":{payload:["applied","items","layer","property","value"],composed:true},"contour:advanced-toggle":{payload:["title"],composed:true},"contour:affordance-activate":{payload:["name"],composed:true},"contour:aggregate":{payload:["aggregate"],composed:true},"contour:bearing":{payload:["direction","degrees"],composed:true},"contour:btn-group-change":{payload:["index","label"],composed:true},"contour:brush-start":{payload:["end","start","value"],composed:true},"contour:brush-end":{payload:["end","start","value"],composed:true},"contour:brush":{payload:["end","start","value"],composed:true},"contour:change":{payload:["checked","color","direction","end","files","high","index","low","month","name","speed","start","unit","value","year"],composed:true},"contour:collapse":{payload:["collapsed"],composed:true},"contour:cluster-toggle":{payload:["count","expanded"],composed:true},"contour:clear":{payload:[],composed:true},"contour:clear-all":{payload:[],composed:true},"contour:close":{payload:["index","label"],composed:true},"contour:copy":{payload:["text"],composed:true},"contour:dash-action":{payload:["label"],composed:true},"contour:diff-activate":{payload:["kind","text"],composed:true},"contour:draw-start":{payload:["mode"],composed:true},"contour:drag":{payload:["delta","key","value"],composed:true},"contour:do-dont-activate":{payload:["kind","text"],composed:true},"contour:docs-nav-select":{payload:["label","href"],composed:true},"contour:dragend":{payload:["value"],composed:true},"contour:dragstart":{payload:["value"],composed:true},"contour:drop":{payload:["value","label"],composed:true},"contour:empty-action":{payload:["state"],composed:true},"contour:filter":{payload:["query"],composed:true},"contour:error":{payload:["src","message","name","status"],composed:true},"contour:export":{payload:["format"],composed:true},"contour:refresh":{payload:[],composed:true},"contour:hide":{payload:[],composed:true},"contour:hover":{payload:["row"],composed:true},"contour:input":{payload:["name","value","checked"],composed:true},"contour:layer-opacity":{payload:["name","opacity"],composed:true},"contour:layer-rename":{payload:["name","newName"],composed:true},"contour:layer-duplicate":{payload:["name"],composed:true},"contour:layer-zoom":{payload:["name"],composed:true},"contour:layer-projection":{payload:["name","projection"],composed:true},"contour:layer-remove":{payload:["name"],composed:true},"contour:layer-reorder":{payload:["layerIds"],composed:true},"contour:layer-toggle":{payload:["name","visible"],composed:true},"contour:layer-visibility":{payload:["name","visible"],composed:true},"contour:legend-toggle":{payload:["key","label","pressed"],composed:true},"contour:leave":{payload:[],composed:true},"contour:load":{payload:["src","count"],composed:true},"contour:map-control":{payload:["control"],composed:true},"contour:map-attach":{payload:[],composed:true},"contour:map-detach":{payload:[],composed:true},"contour:mode-change":{payload:["mode"],composed:true},"contour:move":{payload:["direction","from","to"],composed:true},"contour:open":{payload:[],composed:true},"contour:page":{payload:["page"],composed:true},"contour:ready":{payload:["version","count"],composed:true},"contour:remove":{payload:["key","label","value"],composed:true},"contour:reorder":{payload:["from","to"],composed:true},"contour:range-change":{payload:["value"],composed:true},"contour:resize":{payload:["height","width"],composed:true},"contour:retry":{payload:["src"],composed:true},"contour:loop-change":{payload:["loop"],composed:true},"contour:pause":{payload:[],composed:true},"contour:play":{payload:[],composed:true},"contour:seek":{payload:["progress","value"],composed:true},"contour:select":{payload:["area","col","index","key","label","labels","path","row","rows","series","value"],composed:true},"contour:search":{payload:["query"],composed:true},"contour:speed-change":{payload:["speed"],composed:true},"contour:showcase-activate":{payload:["title"],composed:true},"contour:step-activate":{payload:["index","title"],composed:true},"contour:step-change":{payload:["direction","index","title"],composed:true},"contour:show":{payload:[],composed:true},"contour:sort":{payload:["column","direction"],composed:true},"contour:submit":{payload:["submitting"],composed:true},"contour:stream-state":{payload:["running"],composed:true},"contour:tab-change":{payload:["index","label"],composed:true},"contour:theme-change":{payload:["theme"],composed:true},"contour:tick":{payload:["frame"],composed:true},"contour:time-change":{payload:["progress","value"],composed:true},"contour:time-range-change":{payload:["value"],composed:true},"contour:toggle":{payload:["expanded","label","open","path","playing"],composed:true},"contour:view-enter":{payload:[],composed:true},"contour:view-leave":{payload:[],composed:true},});export function sanitizeHtml(input){const str=String(input==null?"":input);if(typeof DOMParser==="undefined"){return str.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const doc=new DOMParser().parseFromString(str,"text/html");const drop=new Set(["script","iframe","object","embed","style","link","meta","base","form","input","button"]);const walk=(node)=>{const children=Array.from(node.childNodes);for(const c of children){if(c.nodeType===1){const tag=c.tagName.toLowerCase();if(drop.has(tag)){c.remove();continue}for(const attr of Array.from(c.attributes)){const name=attr.name.toLowerCase();if(name.startsWith("on")){c.removeAttribute(attr.name);continue}const val=String(attr.value||"").trim().toLowerCase();if((name==="href"||name==="src"||name==="xlink:href")&&(val.startsWith("javascript:")||val.startsWith("data:text/html"))){c.removeAttribute(attr.name)}}walk(c)}}};walk(doc.body);return doc.body.innerHTML}export const OBSERVED=["accept","action","actions","active","after","allow-duplicate","allow-remove","allow-rename","allow-zoom","alpha","anchor","answer","area","article","attribution","attribution-mark","audit","autoplay","axis","axis-x","axis-y","brownout","brownout-level","before","body","brand","breakpoint","breaks","brush","brush-end","brush-max","brush-min","brush-start","cache-key","canvas","center","clearable","cols","columns","color","command","cells","checked","chrome","debounce","closable","collapsed","collapsible","classification","colors","continuous","content","controls","copyable","count","data","data-table","date","delta","description","glyphs","demo","density","desc","dir","direction","disabled","distance","dismissible","divider","do","dont","dot","ends","high","input","layer","low","mode","modes","n","opacity","palette","polarity","precision","range","single","empty","exclusive","fallback","filename","format","heading","help","hint","href","icon","illustration","instrument","interval","items","key","layers","level","range-end","range-start","label","lazy","lede","legend","line","limit","link","links","live","loading","locale","loop","max","media","message","method","menu","min","multiple","name","needle","next","no","no-cache","no-data-message","nodes","note","norm","normalize","options","orientation","page-size","pages","pause","paused","pausable","persist","placeholder","playing","point","points","prev","presets","progress","prompt","question","recent","required","quote","ramp","refresh","removable","resolution","reverse","rings","retry","results","rows","scale","selectable","segments","show-header","sparkline","threshold","thresholds","selected","separator","series","shortcut","side","size","skeleton","sort","sort-dir","speed","status","step","submit","submitting","timeout","trigger","virtual","sticky","cluster-count","cluster-expanded","time","resizable","state","steps","style","subtitle","summary","src","table","tabs","tag","text","ticks","title","type","unit","cluster-items","row-height","variant","values","viewport","yes","zoomable","x","y","caption","current-time","is-playing","loop-label","no-data-color","property","show-loop","show-thumb","show-thumb-caption","speeds","item-height","pause-label","play-label","speed-label","time-label","shimmer",];export function headingTag(host,fallback="h3"){const v=host&&host.getAttribute?host.getAttribute("heading"):null;return/^h[1-6]$/.test(v||"")?v:fallback}const _ContourBaseParent=(typeof HTMLElement!=="undefined")?HTMLElement:Object;export class ContourBase extends _ContourBaseParent{static formAssociated=false;constructor(){super();if(this.constructor.formAssociated&&typeof this.attachInternals==="function"){this._internals=this.attachInternals()}}static get observed(){return OBSERVED}static get observedAttributes(){return this.observed}static get properties(){return{}}static get updateMode(){return"scaffold"}brownoutLevel(){const raw=this.getAttribute("brownout-level")||this.getAttribute("brownout")||"0";const n=parseInt(raw,10);return Number.isFinite(n)?n:0}shed(kind,threshold){return this.brownoutLevel()>=(threshold||1)}get renderCount(){return this._contourRenderCount||0}_countRender(){this._contourRenderCount=(this._contourRenderCount||0)+1}static _propsInstalled=false;_installProperties(){const ctor=this.constructor;if(ctor._propsInstalled)return;ctor._propsInstalled=true;const props=ctor.properties||{};for(const[name,spec]of Object.entries(props)){const attr=(spec&&spec.attribute)||name;const type=(spec&&spec.type)||String;Object.defineProperty(ctor.prototype,name,{get(){const raw=this.getAttribute(attr);if(type===Boolean)return raw!==null;if(raw===null)return spec&&spec.default!==undefined?spec.default:null;if(type===Number){const n=Number(raw);return Number.isNaN(n)?null:n}return raw},set(v){if(v===null||v===undefined||v===false)this.removeAttribute(attr);else if(type===Boolean){if(v)this.setAttribute(attr,"");else this.removeAttribute(attr)}else this.setAttribute(attr,String(v))},configurable:true,})}}connectedCallback(){if(this._contourAuthored){this._wireFormData();return}this._installProperties();this._contourAuthored={nodes:Array.from(this.childNodes),cls:this.getAttribute("class"),};const before=Array.from(this.childNodes);this._contourRenderGen=(this._contourRenderGen||0)+1;this._ensureCache=new Map();this._ensureCacheGen=this._contourRenderGen;this._countRender();try{this.render()}catch(e){console.error("Contour render error:",e);this.textContent="Component failed to render."}this._contourGenerated=Array.from(this.childNodes).filter((n)=>!before.includes(n));this._applyParts(this);this._applyDensity();this.enhance();this._detachInnerFormControls();this._wireFormData()}attributeChangedCallback(name,oldValue,newValue){if(oldValue===newValue)return;if(!this.isConnected||!this._contourAuthored)return;if(this._batchDepth>0){this._batchDirty=true;return}if(this._contourRendering){if(!this._pendingRerender){this._pendingRerender=true;queueMicrotask(()=>{this._pendingRerender=false;if(!this.isConnected||!this._contourAuthored)return;this.attributeChangedCallback("__rerender__",null,"")})}return}if(name==="checked")this._checkedAttrChanged=true;this._contourRendering=true;try{const savedControls=Array.from(this.querySelectorAll("input, textarea, select"));const savedValues=savedControls.map((el)=>({key:el.name||el.id||null,value:el.value,checked:el.checked,type:el.type}));const hadFocus=this.contains(document.activeElement)?document.activeElement:null;const _focusableSelector="button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])";const _focusablesBefore=Array.from(this.querySelectorAll(_focusableSelector));const hadFocusIndex=hadFocus?_focusablesBefore.indexOf(hadFocus):-1;const hadFocusName=hadFocus?(hadFocus.getAttribute("name")||null):null;const savedScrolls=Array.from(this.querySelectorAll("*")).filter((el)=>el.scrollHeight>el.clientHeight||el.scrollWidth>el.clientWidth).map((el)=>({el,top:el.scrollTop,left:el.scrollLeft}));const savedDetails=Array.from(this.querySelectorAll("details")).map((d)=>({id:d.id||null,open:d.open}));for(const g of(this._contourGenerated||[])){if(!g||g.parentNode!==this)continue;let wrapper=null;if(g.classList&&(g.classList.contains("c-panel__body")||g.classList.contains("c-dialog__body")))wrapper=g;else if(g.tagName==="PRE")wrapper=g.querySelector("code")||g;if(wrapper){while(wrapper.firstChild)this.insertBefore(wrapper.firstChild,g)}}for(const g of(this._contourGenerated||[])){if(g.parentNode===this)this.removeChild(g)}const generated=new Set(this._contourGenerated||[]);const authoredNow=Array.from(this.childNodes).filter((n)=>!generated.has(n));this._contourAuthored.nodes=authoredNow;while(this.firstChild)this.removeChild(this.firstChild);for(const node of this._contourAuthored.nodes)this.appendChild(node);if(this._contourAuthored.cls===null)this.removeAttribute("class");else this.setAttribute("class",this._contourAuthored.cls);const before=Array.from(this.childNodes);this._contourRenderGen=(this._contourRenderGen||0)+1;this._ensureCache=new Map();this._ensureCacheGen=this._contourRenderGen;this._countRender();try{this.render()}catch(e){console.error("Contour render error:",e);this.textContent="Component failed to render."}this._contourGenerated=Array.from(this.childNodes).filter((n)=>!before.includes(n));this._applyParts(this);this._applyDensity();const newControls=Array.from(this.querySelectorAll("input, textarea, select"));const keyed=savedValues.filter((sv)=>sv.key);const unkeyed=savedValues.filter((sv)=>!sv.key);const used=new Set();for(const el of newControls){const key=el.name||el.id||null;if(!key)continue;const match=keyed.find((sv)=>sv.key===key&&!used.has(sv));if(!match)continue;used.add(match);if(el.value===""&&el.getAttribute("value")===null){el.value=match.value}if((el.type==="checkbox"||el.type==="radio")&&typeof match.checked==="boolean"&&!this._checkedAttrChanged){el.checked=match.checked}}let u=0;for(const el of newControls){if(el.name||el.id)continue;const saved=unkeyed[u];u+=1;if(!saved)continue;if(el.value===""&&el.getAttribute("value")===null){el.value=saved.value}if((el.type==="checkbox"||el.type==="radio")&&typeof saved.checked==="boolean"&&!this._checkedAttrChanged){el.checked=saved.checked}}const newDetails=Array.from(this.querySelectorAll("details"));const keyedDetails=savedDetails.filter((sd)=>sd.id);const usedIds=new Set();for(const d of newDetails){const id=d.id||null;if(!id)continue;const match=keyedDetails.find((sd)=>sd.id===id&&!usedIds.has(sd.id));if(!match)continue;usedIds.add(match.id);d.open=match.open}let di=0;const plainSaved=savedDetails.filter((sd)=>!sd.id);for(const d of newDetails){if(d.id)continue;const sd=plainSaved[di];di+=1;if(!sd)break;d.open=sd.open}const newScrolls=Array.from(this.querySelectorAll("*")).filter((el)=>el.scrollHeight>el.clientHeight||el.scrollWidth>el.clientWidth);const keyedScrolls=savedScrolls.filter((s)=>s.el.id);const usedScrolls=new Set();for(const el of newScrolls){const id=el.id||null;if(!id)continue;const match=keyedScrolls.find((s)=>s.el.id===id&&!usedScrolls.has(s.el));if(!match)continue;usedScrolls.add(match.el);el.scrollTop=match.top;el.scrollLeft=match.left}let si=0;const plainScrolls=savedScrolls.filter((s)=>!s.el.id);for(const el of newScrolls){if(el.id)continue;const s=plainScrolls[si];si+=1;if(!s)break;el.scrollTop=s.top;el.scrollLeft=s.left}if(hadFocus){let target=null;if(hadFocus.id){try{target=this.querySelector("#"+CSS.escape(hadFocus.id))}catch(e){target=null}}if(!target&&hadFocusName){try{target=this.querySelector('[name="'+CSS.escape(hadFocusName)+'"]')}catch(e){target=null}}if(!target&&hadFocusIndex>=0){const after=Array.from(this.querySelectorAll(_focusableSelector));if(after.length){target=after[Math.min(hadFocusIndex,after.length-1)]}}if(target&&typeof target.focus==="function"){try{target.focus()}catch(e){}}else if(document.contains(hadFocus)){try{hadFocus.focus()}catch(e){}}else{const first=this.querySelector(_focusableSelector);if(first)try{first.focus()}catch(e){}else try{this.focus()}catch(e){}}}this.enhance();this._detachInnerFormControls();this._checkedAttrChanged=false}finally{this._contourRendering=false}}disconnectedCallback(){this._pendingRerender=false;this._ensureCache=null;this._batchDepth=0;this._batchDirty=false;this._wiredFormData=false;runDisposers(this)}adoptedCallback(){if(this._contourAuthored){this._applyParts(this);this._applyDensity()}}enhance(){}_syncFormValue(){if(!this._internals)return;const ctl=this.querySelector("input:checked, textarea, select")||this.querySelector("input, textarea, select");if(!ctl)return;const boolean=ctl.type==="checkbox"||ctl.type==="radio";const value=boolean?(ctl.checked?(ctl.value||"on"):null):ctl.value;this._internals.setFormValue(value);this._syncValidity(this.hasAttribute("required")&&!value)}_syncValidity(valueMissing){if(!this._internals)return;if(valueMissing)this._internals.setValidity({valueMissing:true},"This field is required.");else this._internals.setValidity({});this._setCustomState("data-invalid",!!valueMissing)}_setCustomState(name,on){let internals=this._internals;if(!internals){if(this._stateInternals)internals=this._stateInternals;else if(typeof this.attachInternals==="function"){try{internals=this._stateInternals=this.attachInternals()}catch(e){return}}}const states=internals&&internals.states;if(!states)return;if(on){if(!states.has(name))states.add(name)}else if(states.has(name))states.delete(name)}_emitForm(type){if(!this._internals)return;const ctl=this.querySelector("input:checked, textarea, select")||this.querySelector("input, textarea, select");if(!ctl)return;const boolean=ctl.type==="checkbox"||ctl.type==="radio";this.dispatchEvent(new CustomEvent(type,{bubbles:true,composed:true,detail:{name:this.getAttribute("name"),value:boolean?(ctl.checked?(ctl.value||"on"):null):ctl.value,checked:boolean?ctl.checked:null,},}))}formResetCallback(){for(const ctl of this.querySelectorAll("input, textarea, select")){if(ctl.type==="checkbox"||ctl.type==="radio"){ctl.checked=this.hasAttribute("checked")}else if(ctl.tagName==="SELECT"){const chosen=ctl.querySelector("option[selected], option:first-of-type");ctl.value=chosen?chosen.value:""}else{ctl.value=this.hasAttribute("value")?this.getAttribute("value"):(ctl.getAttribute("value")||"")}}this._syncFormValue()}formDisabledCallback(disabled){for(const ctl of this.querySelectorAll("input, textarea, select, button")){if(disabled)ctl.setAttribute("disabled","");else ctl.removeAttribute("disabled")}}formStateRestoreCallback(state){if(!this._internals||state===null||state===undefined)return;const controls=Array.from(this.querySelectorAll("input, textarea, select"));const str=String(state);const match=controls.find((c)=>(c.type==="checkbox"||c.type==="radio")&&c.value===str);if(match){match.checked=true;for(const other of controls){if(other!==match&&other.type==="radio"&&other.name===match.name)other.checked=false}}else if(controls.length){controls[0].value=str}this._syncFormValue()}checkValidity(){return this._internals?this._internals.checkValidity():true}reportValidity(){return this._internals?this._internals.reportValidity():true}_wireFormData(){if(!this._internals||this._wiredFormData)return;const form=this._internals.form;if(!form)return;this._wiredFormData=true;const myName=this.getAttribute("name");const onFormChange=(e)=>{const t=e.target;if(t&&t.type==="radio"&&t.name&&t.name===myName)this._syncFormValue()};form.addEventListener("change",onFormChange);const onFormData=()=>this._syncFormValue();form.addEventListener("formdata",onFormData);onDispose(this,()=>{form.removeEventListener("change",onFormChange);form.removeEventListener("formdata",onFormData)})}_detachInnerFormControls(){if(!this._internals)return;for(const ctl of this.querySelectorAll("input, textarea, select")){if(ctl.hasAttribute("name")&&ctl.getAttribute("form")!=="")ctl.setAttribute("form","")}}batch(fn){if(typeof fn!=="function")return;this._batchDepth=(this._batchDepth||0)+1;this._batchDirty=this._batchDirty||false;try{fn()}finally{this._batchDepth-=1;if(this._batchDepth===0&&this._batchDirty){this._batchDirty=false;if(this.isConnected&&this._contourAuthored){this.attributeChangedCallback("__rerender__",null,"")}}}}requestRender(){if(this._contourRerenderQueued)return;this._contourRerenderQueued=true;queueMicrotask(()=>{this._contourRerenderQueued=false;if(!this.isConnected||!this._contourAuthored)return;this.attributeChangedCallback("__rerender__",null,"")})}_applyParts(root){const scope=root||this;const nodes=scope.querySelectorAll?Array.from(scope.querySelectorAll("[class]")):[];for(const node of nodes){if(node.hasAttribute("part"))continue;if(typeof node.className!=="string")continue;for(const c of node.className.split(/\s+/)){const m=c.match(/^c-[a-z0-9-]+__([a-z0-9-]+)$/);if(m){node.setAttribute("part",m[1]);break}}}}_applyDensity(){const density=this.getAttribute("density");if(density!==null)this.setAttribute("data-density",density);else if(this.hasAttribute("data-density"))this.removeAttribute("data-density")}_ownerBetween(node,root){for(let p=node.parentElement;p&&p!==root;p=p.parentElement){if(p instanceof ContourBase)return p}return null}ensure(selector,factory,parent){const root=parent||this;if(!root._ensureCache||root._ensureCacheGen!==this._contourRenderGen){root._ensureCache=new Map();root._ensureCacheGen=this._contourRenderGen}const cache=root._ensureCache;const key=root===this?selector:"\u0000"+root+"\u0000"+selector;let node=cache.get(key);if(node===undefined){node=null;for(const candidate of root.querySelectorAll(selector)){if(!this._ownerBetween(candidate,root)){node=candidate;break}}cache.set(key,node)}if(!node){node=factory();if(node&&node.setAttribute&&!node.hasAttribute("part")){const m=String(selector).match(/\.c-[a-z0-9-]+__([a-z0-9-]+)/);if(m)node.setAttribute("part",m[1])}root.appendChild(node);cache.set(key,node)}return node}}export function withBrownout(Base){return class extends Base{static get observed(){const base=(super.observed&&Array.isArray(super.observed))?super.observed:[];const extra=["brownout","brownout-level"];return Array.from(new Set(base.concat(extra)))}brownoutLevel(){return super.brownoutLevel?super.brownoutLevel():(parseInt(this.getAttribute("brownout-level")||this.getAttribute("brownout")||"0",10)||0)}shed(kind,threshold){return this.brownoutLevel()>=(threshold||1)}}}export const simple=(classes)=>class extends ContourBase{render(){classes.forEach((c)=>this.classList.add(c));for(const c of Array.from(this.classList)){if(classes.some((base)=>c.startsWith(base+"--")))this.classList.remove(c)}MODS.forEach((attr)=>{if(this.hasAttribute(attr)){const val=this.getAttribute(attr);classes.forEach((c)=>{const prefix=c.replace("c-","");this.classList.add(`c-${prefix}--${val}`)})}})}};export const CLASS_ONLY=["box","cluster","container","row","scrim","stack"];export function supportsUntilFound(){try{const t=document.createElement("div");t.setAttribute("hidden","until-found");return t.getAttribute("hidden")==="until-found"}catch(e){return false}}export function formatValue(value,format,locale,unit){if(!format)return value;const loc=locale||(typeof navigator!=="undefined"&&navigator.language)||"en";if(format==="date"||format==="time"){try{const opts=format==="time"?{timeStyle:"short"}:undefined;return new Intl.DateTimeFormat(loc,opts).format(new Date(value))}catch(e){return value}}if(format==="relative"){try{const num=Number(value);let seconds=num;if(Number.isNaN(num)){const then=new Date(value).getTime();if(Number.isFinite(then))seconds=(then-Date.now())/1000}const rtf=new Intl.RelativeTimeFormat(loc,{numeric:"auto"});if(Math.abs(seconds)<60)return rtf.format(Math.round(seconds),"second");if(Math.abs(seconds)<3600)return rtf.format(Math.round(seconds/60),"minute");if(Math.abs(seconds)<86400)return rtf.format(Math.round(seconds/3600),"hour");return rtf.format(Math.round(seconds/86400),"day")}catch(e){return value}}let opts={};if(format==="currency")opts={style:"currency",currency:"USD"};else if(format==="percent")opts={style:"percent"};else if(format==="compact")opts={notation:"compact"};else if(format==="unit")opts={style:"unit",unit:unit||"meter"};else if(format!=="number"){try{opts=JSON.parse(format)}catch(e){return value}}try{return new Intl.NumberFormat(loc,opts).format(Number(value))}catch(e){return value}}export function haversine(lat1,lon1,lat2,lon2){const R=6371000;const toRad=(d)=>d*Math.PI/180;const dLat=toRad(lat2-lat1);const dLon=toRad(lon2-lon1);const a=Math.sin(dLat/2)**2+Math.cos(toRad(lat1))*Math.cos(toRad(lat2))*Math.sin(dLon/2)**2;return 2*R*Math.asin(Math.sqrt(a))}export function bearing(lat1,lon1,lat2,lon2){const toRad=(d)=>d*Math.PI/180;const toDeg=(r)=>r*180/Math.PI;const dLon=toRad(lon2-lon1);const y=Math.sin(dLon)*Math.cos(toRad(lat2));const x=Math.cos(toRad(lat1))*Math.sin(toRad(lat2))-Math.sin(toRad(lat1))*Math.cos(toRad(lat2))*Math.cos(dLon);return(toDeg(Math.atan2(y,x))+360)%360}export function mercatorResolution(lat,zoom){return 156543.03392*Math.cos(lat*Math.PI/180)/Math.pow(2,zoom)}"use strict";export function arcPath(cx,cy,r,inner,startAngle,endAngle){cx=Number.isFinite(cx)?cx:0;cy=Number.isFinite(cy)?cy:0;r=Number.isFinite(r)&&r>0?r:0;inner=Number.isFinite(inner)&&inner>=0?inner:0;startAngle=Number.isFinite(startAngle)?startAngle:0;endAngle=Number.isFinite(endAngle)?endAngle:0;const largeArc=endAngle-startAngle>Math.PI?1:0;const x1=cx+r*Math.cos(startAngle);const y1=cy+r*Math.sin(startAngle);const x2=cx+r*Math.cos(endAngle);const y2=cy+r*Math.sin(endAngle);if(inner<=0){return`M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${largeArc} 1 ${x2} ${y2} Z`}const ix1=cx+inner*Math.cos(endAngle);const iy1=cy+inner*Math.sin(endAngle);const ix2=cx+inner*Math.cos(startAngle);const iy2=cy+inner*Math.sin(startAngle);return`M ${x1} ${y1} A ${r} ${r} 0 ${largeArc} 1 ${x2} ${y2} L ${ix1} ${iy1} A ${inner} ${inner} 0 ${largeArc} 0 ${ix2} ${iy2} Z`}export function donutSlices(values,opts){opts=opts||{};const cx=opts.cx!=null?opts.cx:100;const cy=opts.cy!=null?opts.cy:100;const r=opts.r!=null?opts.r:90;const inner=opts.inner!=null?opts.inner:55;const gap=opts.gap!=null?opts.gap:0.02;const total=values.reduce((a,b)=>a+(Number(b)||0),0)||1;let angle=-Math.PI/2;const out=[];values.forEach((v,i)=>{const num=Number(v)||0;const frac=num/total;if(!(num>0)){angle+=frac*Math.PI*2;return}const sweep=frac*Math.PI*2-gap;const start=angle+gap/2;const end=start+Math.max(0,sweep);out.push({path:arcPath(cx,cy,r,inner,start,end),value:num,index:i});angle+=frac*Math.PI*2});return out}export function barRects(values,opts){opts=opts||{};const width=opts.width!=null?opts.width:300;const height=opts.height!=null?opts.height:120;const gap=opts.gap!=null?opts.gap:2;const max=opts.max!=null?opts.max:(Math.max.apply(null,values.map((v)=>Number(v)||0))||1);if(!Number.isFinite(max)||max<=0)return values.map(()=>({x:0,y:height,width:0,height:0}));const n=values.length||1;const slot=width/n;const barW=Math.max(1,slot-gap);return values.map((v,i)=>{const h=((Number(v)||0)/max)*height;return{x:i*slot+gap/2,y:height-h,width:barW,height:h}})}export function polylinePoints(values,opts){opts=opts||{};const width=opts.width!=null?opts.width:300;const height=opts.height!=null?opts.height:120;const nums=values.map((v)=>Number(v)||0);if(!nums.length)return"";const max=opts.max!=null?opts.max:Math.max.apply(null,nums);const min=opts.min!=null?opts.min:Math.min.apply(null,nums);const range=(Number.isFinite(max-min)&&(max-min)!==0)?(max-min):1;const n=nums.length||1;return nums.map((v,i)=>{const x=(i/Math.max(1,n-1))*width;const y=height-((v-min)/range)*height;return x.toFixed(2)+","+y.toFixed(2)}).join(" ")}export function smoothPath(values,opts){const pts=polylinePoints(values,opts).split(" ").map((p)=>p.split(",").map(Number));if(!pts.length)return"";let d=`M ${pts[0][0]} ${pts[0][1]}`;for(let i=1;i<pts.length;i++){const prev=pts[i-1];const cur=pts[i];const cpx=(prev[0]+cur[0])/2;d+=` C ${cpx} ${prev[1]}, ${cpx} ${cur[1]}, ${cur[0]} ${cur[1]}`}return d}export function compassNeedle(cx,cy,length,angleDeg,width){angleDeg=angleDeg==null?0:angleDeg;width=width==null?3:width;const a=(angleDeg-90)*Math.PI/180;const tipX=cx+length*Math.cos(a);const tipY=cy+length*Math.sin(a);const tail=length*0.25;const tailX=cx-tail*Math.cos(a);const tailY=cy-tail*Math.sin(a);const perpX=Math.cos(a+Math.PI/2);const perpY=Math.sin(a+Math.PI/2);const b1x=cx+width*perpX;const b1y=cy+width*perpY;const b2x=cx-width*perpX;const b2y=cy-width*perpY;return`M ${tipX.toFixed(2)} ${tipY.toFixed(2)} L ${b1x.toFixed(2)} ${b1y.toFixed(2)} L ${tailX.toFixed(2)} ${tailY.toFixed(2)} L ${b2x.toFixed(2)} ${b2y.toFixed(2)} Z`}export function scaleBarTicks(value,segments){value=Number(value)||0;segments=Math.max(1,Math.round(segments||4));const out=[];for(let i=0;i<=segments;i++){out.push((value/segments)*i)}return out}export const MARKER_SHAPES=["circle","square","triangle","diamond","star"];export function markerStyles(shape){const map={circle:"border-radius:50%",square:"border-radius:0",triangle:"clip-path:polygon(50% 0%,0% 100%,100% 100%)",diamond:"transform:rotate(45deg)",star:"clip-path:polygon(50% 0%,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%)",};return map[shape]||""}export function assignMarkers(items){return(items||[]).map((it,i)=>({...it,marker:MARKER_SHAPES[i%MARKER_SHAPES.length]}))}const WIRED_HOSTS=new WeakMap();export const wcReset=(host)=>{WIRED_HOSTS.delete(host)};const wcClaim=(host,name)=>{let set=WIRED_HOSTS.get(host);if(!set){set=new Set();WIRED_HOSTS.set(host,set)}if(set.has(name))return false;set.add(name);return true};const wcScopes=(host)=>(host.shadowRoot?[host,host.shadowRoot]:[host]);const wcAll=(host,sel)=>{const found=[];for(const scope of wcScopes(host)){for(const el of scope.querySelectorAll(sel))if(!found.includes(el))found.push(el)}return found};const wcOne=(host,sel)=>wcAll(host,sel)[0]||null;const wcSelfOrAll=(host,sel)=>{const found=typeof host.matches==="function"&&host.matches(sel)?[host]:[];for(const el of wcAll(host,sel))if(!found.includes(el))found.push(el);return found};const wcShadowOf=(node)=>{const root=node&&node.getRootNode?node.getRootNode():null;return root&&root.host?root:null};const wcGroup=(host,group,sel)=>{const found=Array.from(group.querySelectorAll(sel));if(wcShadowOf(group)&&wcShadowOf(group).host===host){for(const el of host.querySelectorAll(sel))if(!found.includes(el))found.push(el)}return found};const HEARD=new WeakMap();const wcListen=(host,type,handler)=>{const scoped=(e)=>{let seen=HEARD.get(e);if(!seen){seen=new Set();HEARD.set(e,seen)}if(seen.has(scoped))return;seen.add(scoped);handler(e)};for(const scope of wcScopes(host))scope.addEventListener(type,scoped)};const wcOwned=(host,node)=>!!node&&wcScopes(host).some((scope)=>scope.contains(node));const wcClosest=(host,target,sel)=>(typeof target?.closest==="function"&&wcOwned(host,target))?target.closest(sel):null;const wcEmit=(host,name,detail)=>{host.dispatchEvent(new CustomEvent(name,{detail,bubbles:true,composed:true}))};function isRtl(host){let el=host;while(el&&el.nodeType===1){const d=el.getAttribute&&el.getAttribute("dir");if(d)return d.toLowerCase()==="rtl";el=el.parentElement}try{return(document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl"}catch(e){return false}}export function wireTabs(host){if(!wcClaim(host,"tabs"))return;for(const list of wcSelfOrAll(host,".c-tabs__list, .c-code-tabs__list")){const isCode=list.classList.contains("c-code-tabs__list");const panelSel=isCode?".c-code-tabs__panel":".c-tabs__panel";const tabsOf=()=>wcGroup(host,list,"[role='tab']");const activate=(tab,focus)=>{const tabs=tabsOf();tabs.forEach((t)=>{const selected=t===tab;t.setAttribute("aria-selected",String(selected));t.tabIndex=selected?0:-1;const ctrl=t.getAttribute("aria-controls");if(!ctrl)return;const panel=wcOne(host,"#"+CSS.escape(ctrl))||document.getElementById(ctrl);if(panel)panel.hidden=!selected});const panels=wcAll(host,panelSel);if(panels.length){const index=tabs.indexOf(tab);panels.forEach((p,i)=>{p.hidden=i!==index})}if(focus)try{tab.focus()}catch(e){}const name=tab.getAttribute("aria-controls")||tab.textContent||"";host.dispatchEvent(new CustomEvent("contour:tab-change",{bubbles:true,composed:true,detail:{index:tabs.indexOf(tab),label:name}}))};const runActivation=(tab,focus)=>{const can=!focus&&typeof document.startViewTransition==="function"&&!(typeof matchMedia==="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches);if(can){try{document.startViewTransition(()=>activate(tab,focus));return}catch(e){}}activate(tab,focus)};wcListen(host,"click",(e)=>{const tab=wcClosest(host,e.target,"[role='tab']");if(tab&&tabsOf().includes(tab))runActivation(tab,false)});wcListen(host,"keydown",(e)=>{let tab=wcClosest(host,e.target,"[role='tab']");if(!tab&&e.target&&e.target.getAttribute&&e.target.getAttribute("role")==="tab"&&wcOwned(host,e.target))tab=e.target;const tabs=tabsOf();const index=tabs.indexOf(tab);if(index<0)return;const vertical=host.getAttribute("orientation")==="vertical";const rtl=isRtl(host);const move=vertical?(rtl?{ArrowDown:index-1,ArrowUp:index+1,Home:tabs.length-1,End:0}:{ArrowDown:index+1,ArrowUp:index-1,Home:0,End:tabs.length-1}):(rtl?{ArrowRight:index-1,ArrowLeft:index+1,Home:tabs.length-1,End:0}:{ArrowRight:index+1,ArrowLeft:index-1,Home:0,End:tabs.length-1});if(!(e.key in move))return;e.preventDefault();const next=tabs[(move[e.key]+tabs.length)%tabs.length];if(next)runActivation(next,true)});const tabs=tabsOf();const persist=host.getAttribute("persist");let restored=null;if(persist==="storage"&&host.id){try{restored=localStorage.getItem("contour-tabs:"+host.id)}catch(e){restored=null}}else if(persist==="url"){try{const params=new URLSearchParams(window.location.search);const v=params.get("c-tabs");if(v!==null)restored=v}catch(e){restored=null}}const marked=tabs.find((t)=>t.getAttribute("aria-selected")==="true");let first=marked||tabs[0];if(restored!==null){const idx=parseInt(restored,10);if(Number.isFinite(idx)&&tabs[idx])first=tabs[idx]}if(first)activate(first,false);if(persist==="storage"&&host.id){host.addEventListener("contour:tab-change",(e)=>{try{localStorage.setItem("contour-tabs:"+host.id,String(e.detail&&e.detail.index))}catch(err){}})}else if(persist==="url"){host.addEventListener("contour:tab-change",(e)=>{try{const url=new URL(window.location.href);url.searchParams.set("c-tabs",String(e.detail&&e.detail.index));window.history.replaceState(null,"",url.toString())}catch(err){}})}}}export function wireSegmented(host){const groups=wcSelfOrAll(host,".c-segmented");const normalize=()=>{const authored=host.getAttribute("value");const chosen=authored!==host._segAuthorValue?authored:null;if(chosen!==null)host._segAuthorValue=authored;let seen=0;for(const g of groups){if(!g.hasAttribute("role"))g.setAttribute("role","group");const label=host.getAttribute("label");if(label&&!g.hasAttribute("aria-label"))g.setAttribute("aria-label",label);const opts=wcGroup(host,g,"button");seen+=opts.length;opts.forEach((b)=>{b.classList.add("c-segmented__option");b.setAttribute("aria-pressed",chosen!==null&&chosen!==undefined?String(b.dataset.value===chosen):(b.getAttribute("aria-pressed")==="true"?"true":"false"))});const chosenOpt=opts.find((b)=>b.getAttribute("aria-pressed")==="true")||opts[0];opts.forEach((b)=>{b.tabIndex=b===chosenOpt?0:-1})}return seen};if(!normalize()){if(!host._segRetryScheduled){host._segRetryScheduled=true;setTimeout(()=>{host._segRetryScheduled=false;normalize()},0)}}if(!wcClaim(host,"segmented"))return;const activate=(btn)=>{const seg=groups.find((g)=>wcGroup(host,g,"button").includes(btn));if(!seg)return;wcGroup(host,seg,"button").forEach((o)=>{const on=o===btn;o.setAttribute("aria-pressed",String(on));o.tabIndex=on?0:-1});wcEmit(host,"contour:change",{value:btn.dataset.value||btn.textContent.trim()})};wcListen(host,"click",(e)=>{const btn=wcClosest(host,e.target,"button");if(!btn)return;activate(btn)});wcListen(host,"keydown",(e)=>{const btn=wcClosest(host,e.target,"button");if(!btn)return;const seg=groups.find((g)=>wcGroup(host,g,"button").includes(btn));if(!seg)return;const opts=wcGroup(host,seg,"button");const idx=opts.indexOf(btn);let next=-1;const rtl=isRtl(host);if(e.key==="ArrowRight"||e.key==="ArrowDown")next=rtl?Math.max(idx-1,0):Math.min(idx+1,opts.length-1);else if(e.key==="ArrowLeft"||e.key==="ArrowUp")next=rtl?Math.min(idx+1,opts.length-1):Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=opts.length-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();activate(btn);return}if(next>=0&&next!==idx){e.preventDefault();opts[next].focus()}})}export function wireCombobox(host){wireComboboxDocDismiss();const input=wcOne(host,".c-combobox__input");const list=wcOne(host,".c-combobox__list");if(!input||!list)return;const optionList=()=>wcAll(host,".c-combobox__option");if(!list.id)list.id=contourId("c-combobox-list");list.setAttribute("role","listbox");input.setAttribute("role","combobox");input.setAttribute("aria-haspopup","listbox");input.setAttribute("aria-controls",list.id);input.setAttribute("aria-expanded",list.hasAttribute("hidden")?"false":"true");if(!input.hasAttribute("aria-autocomplete"))input.setAttribute("aria-autocomplete","list");optionList().forEach((opt,i)=>{if(!opt.id)opt.id=contourId("c-combobox-option");opt.setAttribute("role","option");if(!opt.hasAttribute("aria-selected"))opt.setAttribute("aria-selected","false")});if(!wcClaim(host,"combobox"))return;const liveInput=()=>wcOne(host,".c-combobox__input");const liveList=()=>wcOne(host,".c-combobox__list");let cursor=-1;const mark=(visible)=>{const field=liveInput();visible.forEach((o,i)=>{const on=i===cursor;o.classList.toggle("c-combobox__option--active",on);o.setAttribute("aria-selected",String(on))});if(field){const active=cursor>=0?visible[cursor]:null;if(active)field.setAttribute("aria-activedescendant",active.id);else field.removeAttribute("aria-activedescendant")}};const filter=(query)=>{const q=(query||"").toLowerCase();if(host._comboboxVirtual&&typeof host._renderComboboxWindow==="function"){host._renderComboboxWindow(q,true);cursor=-1;return}optionList().forEach((o)=>{o.hidden=!!(q&&!o.textContent.toLowerCase().includes(q))});cursor=-1};const open=()=>{const l=liveList();if(!l)return;l.removeAttribute("hidden");const field=liveInput();if(field)field.setAttribute("aria-expanded","true")};const close=()=>{const l=liveList();if(l)l.setAttribute("hidden","");const field=liveInput();if(field){field.setAttribute("aria-expanded","false");field.removeAttribute("aria-activedescendant")}cursor=-1;optionList().forEach((o)=>{o.classList.remove("c-combobox__option--active");o.setAttribute("aria-selected","false")})};if(host._comboboxVirtual&&list&&!list._contourVirtualScroll){list._contourVirtualScroll=true;list.addEventListener("scroll",()=>{if(typeof host._renderComboboxWindow==="function")host._renderComboboxWindow(host._comboboxQuery||"")},{passive:true})}const commit=(opt)=>{const field=liveInput();if(!field)return;if(host.hasAttribute("multiple")){const now=opt.getAttribute("aria-selected")==="true";opt.setAttribute("aria-selected",String(!now));opt.classList.toggle("c-combobox__option--selected",!now);const selected=(host.getAttribute("value")||"").split(",").map((v)=>v.trim()).filter(Boolean);const value=host._comboboxVirtual&&host._comboboxFiltered?host._comboboxFiltered.find((item)=>item.index===Number(opt.dataset.optionIndex))?.value:opt.textContent.trim();const position=selected.indexOf(String(value));if(now&&position>=0)selected.splice(position,1);if(!now&&position<0)selected.push(String(value));host.setAttribute("value",selected.join(","));if(typeof host._syncFormValue==="function")host._syncFormValue();wcEmit(host,"contour:select",{value:selected});field.focus();return}field.value=opt.textContent;wcEmit(host,"contour:select",{value:field.value});close();field.focus()};const isField=(target)=>wcClosest(host,target,".c-combobox__input")!==null;wcListen(host,"input",(e)=>{if(!isField(e.target))return;host._comboboxQuery=e.target.value;filter(e.target.value);open();if(typeof host._emitForm==="function")host._emitForm("contour:input")});wcListen(host,"focusin",(e)=>{if(!isField(e.target))return;filter(e.target.value);open()});wcListen(host,"keydown",(e)=>{if(!isField(e.target))return;const visible=optionList().filter((o)=>!o.hidden);if(e.key==="ArrowDown"){e.preventDefault();cursor=Math.min(cursor+1,visible.length-1);mark(visible)}else if(e.key==="ArrowUp"){e.preventDefault();cursor=Math.max(cursor-1,0);mark(visible)}else if(e.key==="Home"){e.preventDefault();cursor=0;mark(visible)}else if(e.key==="End"){e.preventDefault();cursor=Math.max(0,visible.length-1);mark(visible)}else if(e.key==="Enter"||e.key===" "){e.preventDefault();if(cursor>=0&&visible[cursor])commit(visible[cursor])}else if(e.key==="Escape")close()});wcListen(host,"click",(e)=>{const opt=wcClosest(host,e.target,".c-combobox__option");if(opt){commit(opt);return}if(!wcOwned(host,e.target)||!host.contains(e.target))close()})}let _comboboxDocWired=false;function wireComboboxDocDismiss(){if(_comboboxDocWired)return;_comboboxDocWired=true;document.addEventListener("click",(e)=>{for(const host of document.querySelectorAll("contour-combobox, contour-shadow-combobox")){const list=host.shadowRoot?host.shadowRoot.querySelector(".c-combobox__list"):host.querySelector(".c-combobox__list");const input=host.shadowRoot?host.shadowRoot.querySelector(".c-combobox__input"):host.querySelector(".c-combobox__input");if(!list||list.hasAttribute("hidden"))continue;const root=host.shadowRoot||host;if(root.contains(e.target))continue;list.setAttribute("hidden","")}})}const visibleStops=(host)=>wcAll(host,".c-tree__toggle, .c-tree__leaf").filter((el)=>!el.closest(".c-tree__children[hidden]"));export function wireTree(host){const nodes=()=>wcAll(host,".c-tree__node");const rootList=wcSelfOrAll(host,"ul.c-tree")[0];if(rootList&&!rootList.hasAttribute("role"))rootList.setAttribute("role","tree");wcAll(host,".c-tree__children").forEach((ul)=>{if(!ul.hasAttribute("role"))ul.setAttribute("role","group")});const levelOf=(node)=>{let level=1;for(let p=node.parentElement;p;p=p.parentElement)if(p.classList&&p.classList.contains("c-tree__children"))level++;return level};nodes().forEach((node)=>{if(node.getAttribute("role")!=="treeitem")node.setAttribute("role","treeitem");node.setAttribute("aria-level",String(levelOf(node)));const row=node.querySelector(":scope > .c-tree__row");if(row)node.setAttribute("aria-expanded",row.querySelector(":scope > .c-tree__toggle")?.getAttribute("aria-expanded")||"false");else if(node.hasAttribute("aria-expanded"))node.removeAttribute("aria-expanded")});const stops=visibleStops(host);const authored=stops.find((el)=>el.getAttribute("tabindex")==="0");const active=authored||stops.find((el)=>el===document.activeElement)||stops[0];stops.forEach((el)=>el.setAttribute("tabindex",el===active?"0":"-1"));wcAll(host,".c-tree__toggle, .c-tree__leaf").forEach((el)=>{if(!stops.includes(el))el.setAttribute("tabindex","-1")});if(!wcClaim(host,"tree"))return;host._selectedTree=host._selectedTree||new Set();let lastTreeIndex=-1;wcListen(host,"change",(e)=>{const cb=e.target&&e.target.closest?e.target.closest(".c-tree__select"):null;if(!cb||!host.contains(cb))return;const cbs=Array.from(host.querySelectorAll(".c-tree__select"));const idx=cbs.indexOf(cb);const label=(cb.parentElement&&cb.parentElement.textContent||"").trim().slice(0,120);if(e.shiftKey&&lastTreeIndex>=0){const from=Math.min(lastTreeIndex,idx);const to=Math.max(lastTreeIndex,idx);for(let i=from;i<=to;i++){cbs[i].checked=cb.checked;const lbl=(cbs[i].parentElement&&cbs[i].parentElement.textContent||"").trim().slice(0,120);if(cb.checked)host._selectedTree.add(lbl);else host._selectedTree.delete(lbl)}}else if(!e.ctrlKey&&!e.metaKey){if(cb.checked){cbs.forEach((c,i)=>{if(i!==idx&&c.checked){c.checked=false;const lbl=(c.parentElement&&c.parentElement.textContent||"").trim().slice(0,120);host._selectedTree.delete(lbl)}})}if(cb.checked)host._selectedTree.add(label);else host._selectedTree.delete(label)}else{if(cb.checked)host._selectedTree.add(label);else host._selectedTree.delete(label)}lastTreeIndex=idx;wcEmit(host,"contour:select",{labels:Array.from(host._selectedTree)})});wcAll(host,".c-tree__node, .c-tree__leaf").forEach((n)=>{if(!n.hasAttribute("draggable"))n.setAttribute("draggable","true")});let dragLabel=null;wcListen(host,"dragstart",(e)=>{const node=wcClosest(host,e.target,".c-tree__node, .c-tree__leaf");if(!node)return;dragLabel=(node.textContent||"").trim().slice(0,120);if(e.dataTransfer){e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",dragLabel)}catch(err){}}});wcListen(host,"dragover",(e)=>{const node=wcClosest(host,e.target,".c-tree__node, .c-tree__leaf");if(!node)return;e.preventDefault();if(e.dataTransfer)e.dataTransfer.dropEffect="move"});wcListen(host,"drop",(e)=>{const node=wcClosest(host,e.target,".c-tree__node, .c-tree__leaf");if(!node||!dragLabel)return;e.preventDefault();const toLabel=(node.textContent||"").trim().slice(0,120);if(toLabel&&toLabel!==dragLabel){wcEmit(host,"contour:move",{from:dragLabel,to:toLabel})}dragLabel=null});const persist=host.getAttribute("persist");if(persist==="storage"&&host.id){try{const saved=localStorage.getItem("contour-tree:"+host.id);if(saved!==null){const labels=JSON.parse(saved);if(Array.isArray(labels)){const want=new Set(labels.map((l)=>String(l)));wcAll(host,".c-tree__row").forEach((row)=>{const currentToggle=row.querySelector(":scope > .c-tree__toggle");if(currentToggle?.getAttribute("aria-expanded")==="true")return;const label=(row.textContent||"").trim().slice(0,120);if(!want.has(label))return;const toggle=row.querySelector(":scope > .c-tree__toggle");if(!toggle)return;const node=row.closest(".c-tree__node");const children=node?node.querySelector(":scope > .c-tree__children"):null;toggle.setAttribute("aria-expanded","true");if(node)node.setAttribute("aria-expanded","true");if(children)children.removeAttribute("hidden")})}}}catch(e){}}else if(persist==="url"){try{const v=new URLSearchParams(window.location.search).get("c-tree");if(v!==null){const labels=JSON.parse(v);if(Array.isArray(labels)){const want=new Set(labels.map((l)=>String(l)));wcAll(host,".c-tree__row").forEach((row)=>{const currentToggle=row.querySelector(":scope > .c-tree__toggle");if(currentToggle?.getAttribute("aria-expanded")==="true")return;const label=(row.textContent||"").trim().slice(0,120);if(!want.has(label))return;const toggle=row.querySelector(":scope > .c-tree__toggle");if(!toggle)return;const node=row.closest(".c-tree__node");const children=node?node.querySelector(":scope > .c-tree__children"):null;toggle.setAttribute("aria-expanded","true");if(node)node.setAttribute("aria-expanded","true");if(children)children.removeAttribute("hidden")})}}}catch(e){}}const toggleNode=(toggle)=>{const wasOpen=toggle.getAttribute("aria-expanded")==="true";toggle.setAttribute("aria-expanded",String(!wasOpen));const row=toggle.closest(".c-tree__row")||toggle.parentElement;const node=toggle.closest(".c-tree__node");const children=node?node.querySelector(":scope > .c-tree__children"):null;if(children){if(wasOpen){if(supportsUntilFound())children.setAttribute("hidden","until-found");else children.hidden=true}else{children.removeAttribute("hidden")}}if(node)node.setAttribute("aria-expanded",String(!wasOpen));wcEmit(host,"contour:toggle",{open:!wasOpen,label:(row?row.textContent:"").trim().slice(0,120)});if(persist==="storage"&&host.id){try{const open=[];wcAll(host,".c-tree__row").forEach((r)=>{const toggle=r.querySelector(":scope > .c-tree__toggle");if(toggle?.getAttribute("aria-expanded")==="true")open.push((r.textContent||"").trim().slice(0,120))});localStorage.setItem("contour-tree:"+host.id,JSON.stringify(open))}catch(e){}}else if(persist==="url"){try{const open=[];wcAll(host,".c-tree__row").forEach((r)=>{const toggle=r.querySelector(":scope > .c-tree__toggle");if(toggle?.getAttribute("aria-expanded")==="true")open.push((r.textContent||"").trim().slice(0,120))});const url=new URL(window.location.href);url.searchParams.set("c-tree",JSON.stringify(open));window.history.replaceState(null,"",url.toString())}catch(e){}}};const branchOf=(el)=>(el.classList&&el.classList.contains("c-tree__toggle")?el:null);const stopsOf=()=>visibleStops(host);const rove=(keep)=>{wcAll(host,".c-tree__toggle, .c-tree__leaf").forEach((el)=>el.setAttribute("tabindex",el===keep?"0":"-1"))};wcListen(host,"click",(e)=>{let toggle=wcClosest(host,e.target,".c-tree__toggle");if(!toggle){const row=wcClosest(host,e.target,".c-tree__row");if(row)toggle=row.querySelector(":scope > .c-tree__toggle")}if(!toggle)return;e.preventDefault();e.stopPropagation();toggleNode(toggle)});wcListen(host,"focusin",(e)=>{if(!wcClosest(host,e.target,".c-tree__toggle, .c-tree__leaf"))return;rove(e.target)});wcListen(host,"keydown",(e)=>{const toggle=wcClosest(host,e.target,".c-tree__toggle, .c-tree__leaf");if(!toggle)return;const items=stopsOf();const idx=items.indexOf(toggle);if(e.key==="Enter"||e.key===" "){if(branchOf(toggle)){e.preventDefault();toggleNode(toggle)}return}if(e.key==="ArrowRight"){const branch=branchOf(toggle);const closed=branch&&branch.getAttribute("aria-expanded")==="false";e.preventDefault();if(closed){toggleNode(branch);rove(toggle)}else{const next=items[idx+1];if(next){next.focus();rove(next)}}return}if(e.key==="ArrowLeft"){const branch=branchOf(toggle);if(branch&&branch.getAttribute("aria-expanded")==="true"){e.preventDefault();toggleNode(branch);rove(toggle)}else{const parent=toggle.closest(".c-tree__children");const owner=parent?parent.closest(".c-tree__node"):null;const up=owner?owner.querySelector(":scope > .c-tree__row > .c-tree__toggle"):null;if(up){e.preventDefault();up.focus();rove(up)}}return}let next=-1;if(e.key==="ArrowDown")next=Math.min(idx+1,items.length-1);else if(e.key==="ArrowUp")next=Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=items.length-1;if(next>=0&&next!==idx){e.preventDefault();items[next].focus();rove(items[next])}})}export function wireMenu(host){wcAll(host,"[role='menuitem']").forEach((it)=>{if(!it.hasAttribute("tabindex"))it.setAttribute("tabindex",it.getAttribute("aria-disabled")==="true"?"-1":"-1")});const all=()=>wcAll(host,"[role='menuitem']");if(!all().some((it)=>it.getAttribute("tabindex")==="0")&&all().length){const first=all().find((it)=>it.getAttribute("aria-disabled")!=="true");if(first)first.setAttribute("tabindex","0")}if(!wcClaim(host,"menu"))return;const submenusOf=(item)=>item.querySelector(":scope > ul.c-menu, :scope > .c-menu");const closeAllSubmenus=()=>{wcAll(host,"[aria-haspopup='menu']").forEach((it)=>it.setAttribute("aria-expanded","false"))};wcListen(host,"keydown",(e)=>{const its=all().filter((it)=>it.getAttribute("aria-disabled")!=="true");if(!its.length)return;const index=its.indexOf(e.target);const target=index>=0?its[index]:null;const sub=target?submenusOf(target):null;if(target&&target.getAttribute("aria-haspopup")==="menu"&&(e.key==="ArrowRight"||e.key==="Enter"||e.key===" ")){if(sub){e.preventDefault();closeAllSubmenus();target.setAttribute("aria-expanded","true");const firstSub=sub.querySelector("[role='menuitem']");if(firstSub){firstSub.setAttribute("tabindex","0");try{firstSub.focus()}catch(err){}}return}}if(e.key==="ArrowLeft"||e.key==="Escape"){const parent=target?target.closest("ul.c-menu"):null;let ancestor=null;if(target){const ul=target.parentElement&&target.parentElement.tagName==="UL"?target.parentElement:null;let node=target.parentElement;while(node&&node!==host){if(node.getAttribute&&node.getAttribute("aria-haspopup")==="menu"&&node.contains(target)&&node!==target){ancestor=node;break}node=node.parentElement}}if(ancestor){e.preventDefault();ancestor.setAttribute("aria-expanded","false");try{ancestor.focus()}catch(err){}return}if(e.key==="Escape"){closeAllSubmenus()}}let next=-1;if(e.key==="ArrowDown")next=index<0?0:Math.min(index+1,its.length-1);else if(e.key==="ArrowUp")next=index<0?its.length-1:Math.max(index-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=its.length-1;if(next>=0){e.preventDefault();its[next].focus();return}if((e.key==="Enter"||e.key===" ")&&index>=0&&!(target&&target.getAttribute("aria-haspopup")==="menu")){e.preventDefault();wcEmit(host,"contour:select",{index,label:its[index].textContent.trim()});closeAllSubmenus()}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const ch=e.key.toLowerCase();const match=its.findIndex((it)=>(it.textContent||"").trim().toLowerCase().startsWith(ch));if(match>=0){e.preventDefault();its[match].focus()}}});wcListen(host,"click",(e)=>{const item=wcClosest(host,e.target,"[role='menuitem']");if(!item)return;if(item.getAttribute("aria-disabled")==="true")return;if(item.getAttribute("aria-haspopup")==="menu"){const sub=submenusOf(item);if(sub){const open=item.getAttribute("aria-expanded")==="true";closeAllSubmenus();item.setAttribute("aria-expanded",open?"false":"true");return}}const index=all().indexOf(item);if(index>=0){wcEmit(host,"contour:select",{index,label:item.textContent.trim()});closeAllSubmenus();if(typeof host.hidePopover==="function"){try{host.hidePopover()}catch(e){}}}})}export function wirePagination(host){wcAll(host,".c-pagination__link").forEach((b)=>{if(!b.hasAttribute("tabindex"))b.setAttribute("tabindex","0")});if(!wcClaim(host,"pagination"))return;const activate=(btn)=>{const page=parseInt(btn.textContent,10);if(!Number.isFinite(page))return;wcAll(host,".c-pagination__link").forEach((b)=>{if(parseInt(b.textContent,10)===page)b.setAttribute("aria-current","page");else b.removeAttribute("aria-current")});host.setAttribute("page",String(page));wcEmit(host,"contour:page",{page});if(host.getAttribute("persist")==="storage"&&host.id){try{localStorage.setItem("contour-pagination:"+host.id,String(page))}catch(e){}}else if(host.getAttribute("persist")==="url"){try{const url=new URL(window.location.href);url.searchParams.set("c-pagination",String(page));window.history.replaceState(null,"",url.toString())}catch(e){}}};wcListen(host,"click",(e)=>{const btn=wcClosest(host,e.target,".c-pagination__link");if(!btn)return;e.preventDefault();const action=btn.getAttribute("data-action");if(action==="prev"||action==="next"){const links=wcAll(host,".c-pagination__link").filter((b)=>!b.getAttribute("data-action"));const cur=links.find((b)=>b.getAttribute("aria-current")==="page");const curPage=cur?(parseInt(cur.textContent,10)||1):1;const page=action==="prev"?Math.max(1,curPage-1):Math.min(links.length,curPage+1);const target=links.find((b)=>parseInt(b.textContent,10)===page);if(target){activate(target);return}}activate(btn)});wcListen(host,"keydown",(e)=>{const btn=wcClosest(host,e.target,".c-pagination__link");if(!btn)return;const links=wcAll(host,".c-pagination__link");const idx=links.indexOf(btn);let next=-1;const rtl=isRtl(host);if(e.key==="ArrowRight")next=rtl?Math.max(idx-1,0):Math.min(idx+1,links.length-1);else if(e.key==="ArrowLeft")next=rtl?Math.min(idx+1,links.length-1):Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=links.length-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();activate(btn);return}if(next>=0&&next!==idx){e.preventDefault();links[next].focus()}})}export function wireCopy(host){if(!wcClaim(host,"copy"))return;wcListen(host,"click",(e)=>{const btn=wcClosest(host,e.target,".c-code__copy, .c-install__copy");if(!btn)return;const owner=wcClosest(host,btn,".c-code")||wcClosest(host,btn,".c-install")||host;const src=owner.querySelector("code, .c-install__command");const text=(src?src.textContent:owner.textContent)||"";const confirm=(ok)=>{const icon=btn.querySelector("use");const originalHref=icon&&icon.getAttribute("href");const originalLabel=btn.getAttribute("aria-label")||btn.title||"";if(ok&&icon)icon.setAttribute("href","#i-check");btn.setAttribute("aria-label",ok?"Copied":"Copy failed");btn.dataset.copied=String(ok);const timer=setTimeout(()=>{if(!btn.isConnected)return;if(icon&&originalHref)icon.setAttribute("href",originalHref);btn.setAttribute("aria-label",originalLabel);delete btn.dataset.copied},1600);onDispose(host,()=>clearTimeout(timer))};const doCopy=async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText){await navigator.clipboard.writeText(text);return true}}catch(e){}try{const ta=document.createElement("textarea");ta.value=text;ta.setAttribute("readonly","");ta.style.position="fixed";ta.style.top="-9999px";ta.style.opacity="0";document.body.append(ta);ta.select();const ok=document.execCommand("copy");ta.remove();return ok}catch(e){return false}};doCopy().then((ok)=>confirm(ok));wcEmit(host,"contour:copy",{text})})}export function wireRemovable(host){if(!wcClaim(host,"removable"))return;wcListen(host,"click",(e)=>{const drop=(node)=>{if(node&&node.parentNode)node.parentNode.removeChild(node)};const tagBtn=wcClosest(host,e.target,".c-tag__remove");if(tagBtn){e.preventDefault();const tag=wcClosest(host,tagBtn,".c-tag");wcEmit(host,"contour:remove",{label:(tag&&tag.getAttribute("label"))||(tag?tag.textContent.trim():"")});drop(tag);return}const pillBtn=wcClosest(host,e.target,".c-filter-pill__remove");if(pillBtn){e.preventDefault();const pill=wcClosest(host,pillBtn,".c-filter-pill");wcEmit(host,"contour:remove",{key:pill&&pill.getAttribute("key"),value:pill&&pill.getAttribute("value")});drop(pill);return}if(wcClosest(host,e.target,"[data-empty-action]")){wcEmit(host,"contour:empty-action",{state:host.getAttribute("state")||"empty"})}const alertClose=wcClosest(host,e.target,".c-alert__close");if(alertClose){e.preventDefault();wcEmit(host,"contour:close",{});if(host.shadowRoot?host.shadowRoot.contains(alertClose):true){try{host.remove()}catch(err){}}return}const calloutClose=wcClosest(host,e.target,".c-callout__close");if(calloutClose){e.preventDefault();wcEmit(host,"contour:close",{});try{host.remove()}catch(err){}return}})}const modalDepth={n:0};let modalSavedOverflow=null;let modalSavedX=0;let modalSavedY=0;const modalInerted=new Set();const modalStack=[];let modalTrapWired=false;function modalFocusables(host){return Array.from(host.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")).filter((el)=>!el.hasAttribute("disabled")&&el.getAttribute("aria-hidden")!=="true")}function modalTrapHandler(e){if(e.key!=="Tab")return;const host=modalStack[modalStack.length-1];if(!host)return;const f=modalFocusables(host);if(!f.length){e.preventDefault();return}const first=f[0];const last=f[f.length-1];const active=document.activeElement;if(e.shiftKey){if(active===first||!host.contains(active)){e.preventDefault();last.focus()}}else{if(active===last){e.preventDefault();first.focus()}}}export function modalContain(host,open){if(open){if(modalDepth.n===0){modalSavedX=window.scrollX;modalSavedY=window.scrollY;modalSavedOverflow=document.documentElement.style.overflow;document.documentElement.style.overflow="hidden"}modalDepth.n+=1;modalStack.push(host);if(modalDepth.n===1&&!modalTrapWired){modalTrapWired=true;document.addEventListener("keydown",modalTrapHandler)}for(let el=host;el&&el!==document.body;el=el.parentElement){for(const sib of el.parentElement.children){if(sib===el||sib.inert||modalInerted.has(sib))continue;sib.inert=true;modalInerted.add(sib)}}}else{const idx=modalStack.lastIndexOf(host);if(idx>=0)modalStack.splice(idx,1);modalDepth.n=Math.max(0,modalDepth.n-1);if(modalDepth.n===0){for(const el of modalInerted)el.inert=false;modalInerted.clear();document.documentElement.style.overflow=modalSavedOverflow||"";window.scrollTo(modalSavedX,modalSavedY);if(modalTrapWired){document.removeEventListener("keydown",modalTrapHandler);modalTrapWired=false}}}}export const STATE_FALLBACK={empty:"No data",loading:"Loading…",error:"Could not load.",};const remoteInflight=new Map();const REMOTE_CACHE_MAX=64;const remoteCache=new Map();function cacheResult(src,data){if(remoteCache.size>=REMOTE_CACHE_MAX)remoteCache.delete(remoteCache.keys().next().value);remoteCache.set(src,data)}function setStatus(host,status){host._remoteStatus=status;if(status!=="error")host._remoteError=null;if(status==="loading")host.setAttribute("aria-busy","true");else host.removeAttribute("aria-busy");if(typeof host._setCustomState==="function")host._setCustomState("data-loading",status==="loading")}function emitState(host,name,detail){host.dispatchEvent(new CustomEvent(name,{detail,bubbles:true,composed:true}))}function countOf(data){if(Array.isArray(data))return data.length;if(data&&typeof data==="object")return Object.keys(data).length;return data===null||data===undefined?0:1}function leaveRequest(host){const entry=host._remoteEntry;host._remoteEntry=null;if(!entry)return;entry.hosts.delete(host);if(entry.hosts.size===0&&entry.controller)entry.controller.abort()}export function loadRemote(host,fields){const src=host.getAttribute("src");if(!src){leaveRequest(host);setStatus(host,host._remoteData!==undefined?"ready":"idle");return}remoteRefresh(host);const wanted=typeof fields==="string"?[fields]:fields;if(wanted.every((f)=>host.getAttribute(f)!==null)){leaveRequest(host);setStatus(host,"ready");return}if(!remoteVisible(host)){setStatus(host,"loading");return}const noCache=host.hasAttribute("no-cache");const cacheKey=host.getAttribute("cache-key")||src;if(noCache){if(host._remoteSrc===src&&host._remoteData!==undefined){setStatus(host,"ready");return}}else{const cached=remoteCache.get(cacheKey);if(cached!==undefined){host._remoteSrc=src;host._remoteData=cached;setStatus(host,"ready");return}}if(host._remoteSrc===src&&(host._remoteStatus==="loading"||host._remoteStatus==="error"))return;leaveRequest(host);host._remoteSrc=src;setStatus(host,"loading");let entry=remoteInflight.get(src);if(!entry){entry={hosts:new Set(),controller:new AbortController(),cacheKey};remoteInflight.set(src,entry);entry.promise=startFetch(host,src,entry).then((data)=>{if(remoteInflight.get(src)===entry)remoteInflight.delete(src);cacheResult(src,data);const namedKey=entry.cacheKey;if(namedKey&&namedKey!==src)cacheResult(namedKey,data);for(const h of entry.hosts){h._remoteData=data;h._remoteEntry=null;setStatus(h,"ready");emitState(h,"contour:load",{src,count:countOf(data)})}},(err)=>{if(remoteInflight.get(src)===entry)remoteInflight.delete(src);for(const h of entry.hosts){h._remoteEntry=null;setStatus(h,"error");h._remoteError=err&&err.name==="HttpError"?`Could not load (${err.status})`:STATE_FALLBACK.error;emitState(h,"contour:error",{src,message:h._remoteError,name:err&&err.name,status:err&&err.status,})}}).finally(()=>{for(const h of entry.hosts)if(h.isConnected)h.requestRender();entry.hosts.clear()})}entry.hosts.add(host);host._remoteEntry=entry;if(!host._remoteDisposeRegistered){host._remoteDisposeRegistered=true;onDispose(host,()=>{host._remoteDisposeRegistered=false;leaveRequest(host)})}}export function remoteInvalidate(srcOrKey){remoteCache.delete(srcOrKey)}function startFetch(host,src,entry){const ms=parseInt(host.getAttribute("timeout")||"",10);let timer=null;let signal=entry.controller.signal;if(Number.isFinite(ms)&&ms>0){if(typeof AbortSignal!=="undefined"&&AbortSignal.timeout){signal=AbortSignal.any([signal,AbortSignal.timeout(ms)])}else{timer=setTimeout(()=>entry.controller.abort(),ms)}}onDispose(host,()=>{if(timer)clearTimeout(timer)});return fetch(src,{signal}).then((res)=>{if(timer)clearTimeout(timer);if(!res.ok){const e=new Error(`Could not load (${res.status})`);e.name="HttpError";e.status=res.status;throw e}return res.text()}).then((text)=>{try{return JSON.parse(text)}catch(err){const e=new Error(STATE_FALLBACK.error);e.name="ParseError";e.cause=err;throw e}})}export function remoteData(host,field){const authored=host.getAttribute(field);if(authored!==null)return authored;const data=host._remoteData;if(data===undefined||data===null)return null;if(Array.isArray(data))return JSON.stringify(data);if(typeof data==="object"){const keys=typeof field==="string"?[field]:field;for(const k of keys){if(data[k]===undefined)continue;return typeof data[k]==="string"?data[k]:JSON.stringify(data[k])}return null}return String(data)}export function remoteRefresh(host){const seconds=parseFloat(host.getAttribute("refresh")||"");const want=host.hasAttribute("src")&&Number.isFinite(seconds)&&seconds>0;if(!want){if(host._remoteTimer!==undefined){clearTimeout(host._remoteTimer);host._remoteTimer=undefined}host._remoteLoop=false;return}if(host._remoteLoop)return;host._remoteLoop=true;const tick=()=>{host._remoteTimer=undefined;if(!host.isConnected||!host.hasAttribute("refresh")){host._remoteLoop=false;return}if(document.hidden){host._remoteTimer=setTimeout(tick,1000);return}const src=host.getAttribute("src");const namedKey=host.getAttribute("cache-key");if(namedKey)remoteCache.delete(namedKey);remoteCache.delete(src);host._remoteSrc=null;host._remoteLoop=false;host.requestRender()};host._remoteTimer=setTimeout(tick,Math.max(1000,seconds*1000));onDispose(host,()=>{clearTimeout(host._remoteTimer);host._remoteTimer=undefined;host._remoteLoop=false})}let _sharedLazyIO=null;const _sharedLazyTargets=new Map();export function remoteVisible(host){if(!host.hasAttribute("lazy"))return true;if(typeof IntersectionObserver!=="function")return true;if(host._remoteVisible)return true;if(host._lazyRegistered)return false;if(!_sharedLazyIO){_sharedLazyIO=new IntersectionObserver((records)=>{for(const r of records){const activate=_sharedLazyTargets.get(r.target);if(!activate||!r.isIntersecting)continue;_sharedLazyTargets.delete(r.target);_sharedLazyIO.unobserve(r.target);activate()}},{rootMargin:"200px"})}const activate=()=>{host._remoteVisible=true;host._lazyRegistered=false;host.requestRender()};host._lazyRegistered=true;_sharedLazyTargets.set(host,activate);_sharedLazyIO.observe(host);onDispose(host,()=>{_sharedLazyIO.unobserve(host);_sharedLazyTargets.delete(host);host._lazyRegistered=false});return false}export function watchViewport(host){if(host._contourViewWired)return()=>{};host._contourViewWired=true;const emit=(type)=>host.dispatchEvent(new CustomEvent(type,{bubbles:true,composed:true}));if(typeof IntersectionObserver!=="function"){emit("contour:view-enter");return()=>{}}const io=new IntersectionObserver((records)=>{for(const r of records){if(r.isIntersecting)emit("contour:view-enter");else emit("contour:view-leave")}});io.observe(host);onDispose(host,()=>io.disconnect());return()=>io.disconnect()}function stateNode(block,kind,text){const node=document.createElement("div");node.className="c-"+block+"__"+kind;node.dataset.contourState=kind;node.textContent=text;return node}function skeletonRow(i,total){const node=document.createElement("div");node.className="c-skeleton "+(i===0&&total>1?"c-skeleton--title":"c-skeleton--text");node.dataset.contourState="skeleton";return node}export function renderStates(host,block,opts){const options=opts||{};const loading=host.getAttribute("loading");if(loading!==null||host._remoteStatus==="loading"){host.appendChild(stateNode(block,"loading",loading||STATE_FALLBACK.loading));return true}const error=host.getAttribute("error");if(error!==null||host._remoteStatus==="error"){const message=(error!==null&&error!=="")?error:(host._remoteError||STATE_FALLBACK.error);const node=stateNode(block,"error",message);if(host.hasAttribute("retry")){const btn=document.createElement("button");btn.type="button";btn.className="c-btn c-btn--ghost c-btn--sm";btn.textContent=host.getAttribute("retry")||"Retry";btn.dataset.action="retry";node.appendChild(btn)}host.appendChild(node);return true}if(host.hasAttribute("skeleton")){const asked=parseInt(host.getAttribute("skeleton")||"3",10);const count=Math.min(options.max||6,Math.max(1,Number.isFinite(asked)?asked:3));for(let i=0;i<count;i++)host.appendChild(skeletonRow(i,count));return true}return false}export function renderEmpty(host,block){host.appendChild(stateNode(block,"empty",host.getAttribute("empty")||STATE_FALLBACK.empty))}export function wireStates(host){if(host._contourStatesWired)return;host._contourStatesWired=true;host.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest('[data-action="retry"]'):null;if(!btn||!host.contains(btn))return;e.preventDefault();const src=host.getAttribute("src");const namedKey=host.getAttribute("cache-key");if(namedKey)remoteCache.delete(namedKey);if(src)remoteCache.delete(src);leaveRequest(host);host._remoteSrc=null;host._remoteData=undefined;setStatus(host,"idle");emitState(host,"contour:retry",{src});host.requestRender()})}class ContourCard extends ContourBase{static get observed(){return["title","variant","heading"]}static get properties(){return{title:{attribute:"title"},variant:{attribute:"variant"}}}render(){this.classList.add("c-card");const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-card--"))this.classList.remove(c)});if(variant)this.classList.add("c-card--"+variant);const title=this.getAttribute("title");if(title){const h=this.ensure(".c-card__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-card__title";return el});if(h.parentNode===this&&this.firstChild!==h)this.prepend(h);h.textContent=title}else{const h=this.querySelector(".c-card__title");if(h)h.remove()}}}define("contour-card",ContourCard);class ContourFeature extends ContourBase{static get observed(){return["index","title","body","heading"]}static get properties(){return{index:{attribute:"index"},title:{attribute:"title"},body:{attribute:"body"}}}render(){this.classList.add("c-feature");const index=this.getAttribute("index");const title=this.getAttribute("title");const body=this.getAttribute("body");if(index){const x=this.ensure(".c-feature__index",()=>{const el=document.createElement("span");el.className="c-feature__index";return el});x.textContent=index}else{const x=this.querySelector(".c-feature__index");if(x)x.remove()}if(title){const t=this.ensure(".c-feature__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-feature__title";return el});t.textContent=title}else{const t=this.querySelector(".c-feature__title");if(t)t.remove()}if(body){const b=this.ensure(".c-feature__body",()=>{const el=document.createElement("p");el.className="c-feature__body";return el});b.textContent=body}else{const b=this.querySelector(".c-feature__body");if(b)b.remove()}}}define("contour-feature",ContourFeature);class ContourSteps extends ContourBase{static get observed(){return["steps","current","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","heading"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current",type:Number},src:{attribute:"src"}}}render(){this.classList.add("c-steps");this.setAttribute("role","list");wireStates(this);loadRemote(this,"steps");if(renderStates(this,"steps"))return;const steps=remoteData(this,"steps");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-steps__item"));if(steps&&!authored.length){Array.from(this.querySelectorAll(".c-steps__item")).forEach((n)=>n.remove());try{const parsed=JSON.parse(steps);parsed.forEach((st,i)=>{const item=document.createElement("div");item.className="c-steps__item";item.setAttribute("role","listitem");item.tabIndex=-1;const title=typeof st==="string"?st:st.title;const body=typeof st==="string"?"":st.body;if(title){const h=document.createElement(headingTag(this,"h3"));h.className="c-steps__title";h.textContent=title;item.appendChild(h)}if(body){const p=document.createElement("p");p.className="c-steps__body";p.textContent=body;item.appendChild(p)}this.appendChild(item)})}catch(e){}}else if(!steps&&!authored.length){renderEmpty(this,"steps")}const attrCurrent=this.getAttribute("current");const current=(this._current!=null)?this._current:(attrCurrent!=null?parseInt(attrCurrent,10):NaN);const items=Array.from(this.querySelectorAll(".c-steps__item"));items.forEach((it,i)=>{if(Number.isFinite(current)&&i===current)it.setAttribute("aria-current","step");else it.removeAttribute("aria-current");it.tabIndex=(Number.isFinite(current)&&i===current)?0:-1});if(items.length&&!Number.isFinite(current)){items[0].tabIndex=0}}enhance(){if(!this._wiredSteps){this._wiredSteps=true;this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-steps__item"));if(!items.length)return;const active=document.activeElement;const idx=items.indexOf(active);let next=-1;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";if(e.key==="ArrowDown")next=idx<0?0:Math.min(items.length-1,idx+1);else if(e.key==="ArrowUp")next=idx<0?0:Math.max(0,idx-1);else if(e.key==="ArrowRight")next=rtl?(idx<0?0:Math.max(0,idx-1)):(idx<0?0:Math.min(items.length-1,idx+1));else if(e.key==="ArrowLeft")next=rtl?(idx<0?0:Math.min(items.length-1,idx+1)):(idx<0?0:Math.max(0,idx-1));else if(e.key==="Home")next=0;else if(e.key==="End")next=items.length-1;if(next>=0&&next!==idx){e.preventDefault();items[next].focus();this._current=next;items.forEach((it,i)=>{if(i===next)it.setAttribute("aria-current","step");else it.removeAttribute("aria-current");it.tabIndex=i===next?0:-1});if(idx>=0)items[idx].tabIndex=-1;const title=items[next].querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{index:next,title}}))}if((e.key==="Enter"||e.key===" ")&&idx>=0){e.preventDefault();const title=items[idx].querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-activate",{bubbles:true,composed:true,detail:{index:idx,title}}))}});this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-steps__item"):null;if(!item||!this.contains(item))return;const items=Array.from(this.querySelectorAll(".c-steps__item"));const idx=items.indexOf(item);if(idx<0)return;this._current=idx;items.forEach((it,i)=>{if(i===idx)it.setAttribute("aria-current","step");else it.removeAttribute("aria-current");it.tabIndex=i===idx?0:-1});const title=item.querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-activate",{bubbles:true,composed:true,detail:{index:idx,title}}))})}}}define("contour-steps",ContourSteps);class ContourLink extends ContourBase{static get observed(){return["href","label"]}static get properties(){return{href:{attribute:"href"},label:{attribute:"label"}}}render(){this.classList.add("c-link");const href=this.getAttribute("href");const label=this.getAttribute("label");const prevLink=this.querySelector("a");if(prevLink)prevLink.remove();if(href&&label){const a=document.createElement("a");a.href=href;a.textContent=label;const ariaLabel=this.getAttribute("aria-label");if(ariaLabel)a.setAttribute("aria-label",ariaLabel);this.appendChild(a)}}}define("contour-link",ContourLink);class ContourBrand extends ContourBase{static get observed(){return["name","tag"]}static get properties(){return{name:{attribute:"name"},tag:{attribute:"tag"}}}render(){this.classList.add("c-brand");const name=this.getAttribute("name");const tag=this.getAttribute("tag");if(name){const n=this.ensure(".c-brand__name",()=>{const el=document.createElement("span");el.className="c-brand__name";return el});n.textContent=name}else{const n=this.querySelector(".c-brand__name");if(n)n.remove()}if(tag){const t=this.ensure(".c-brand__tag",()=>{const el=document.createElement("span");el.className="c-brand__tag";return el});t.textContent=tag}else{const t=this.querySelector(".c-brand__tag");if(t)t.remove()}}}define("contour-brand",ContourBrand);class ContourSectionHead extends ContourBase{static get observed(){return["title","desc","heading"]}static get properties(){return{title:{attribute:"title"},desc:{attribute:"desc"}}}render(){this.classList.add("c-section-head");const title=this.getAttribute("title");const desc=this.getAttribute("desc");if(!this.querySelector(".c-icon-badge")){const badge=document.createElement("div");badge.className="c-icon-badge";badge.innerHTML='<svg aria-hidden="true"><use href="#i-crosshair" /></svg>';this.prepend(badge)}let content=this.querySelector(":scope > div:not(.c-icon-badge)");if(!content){content=document.createElement("div");this.appendChild(content)}if(title){const t=this.ensure(".c-section-head__title",()=>{const el=document.createElement(headingTag(this,"h2"));el.className="c-section-head__title";return el});t.textContent=title;if(t.parentNode!==content)content.appendChild(t)}else{const t=this.querySelector(".c-section-head__title");if(t)t.remove()}if(desc){const d=this.ensure(".c-section-head__desc",()=>{const el=document.createElement("p");el.className="c-section-head__desc";return el});d.textContent=desc;if(d.parentNode!==content)content.appendChild(d)}else{const d=this.querySelector(".c-section-head__desc");if(d)d.remove()}}}define("contour-section-head",ContourSectionHead);class ContourDiff extends ContourBase{static get observed(){return["before","after"]}static get properties(){return{before:{attribute:"before"},after:{attribute:"after"}}}render(){this.classList.add("c-diff");this.setAttribute("role","group");this.setAttribute("aria-label","Diff");Array.from(this.querySelectorAll(".c-diff__line")).forEach((n)=>n.remove());const line=(kind,sign,text)=>{const el=document.createElement("div");el.className=kind?`c-diff__line c-diff__line--${kind}`:"c-diff__line";el.setAttribute("role","listitem");el.setAttribute("tabindex","0");const s=document.createElement("span");s.className="c-diff__sign";s.textContent=sign;const code=document.createElement("span");code.textContent=text;el.append(s,code);return el};const before=this.getAttribute("before");const after=this.getAttribute("after");if(before)this.appendChild(line("del","−",before));if(after)this.appendChild(line("add","+",after))}enhance(){if(this._wiredDiff)return;this._wiredDiff=true;this.addEventListener("click",(e)=>{const line=e.target&&e.target.closest?e.target.closest(".c-diff__line"):null;if(line&&this.contains(line)){const kind=line.classList.contains("c-diff__line--add")?"add":line.classList.contains("c-diff__line--del")?"del":"context";const text=line.querySelector("span:last-child")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:diff-activate",{bubbles:true,composed:true,detail:{kind,text}}))}});this.addEventListener("keydown",(e)=>{const line=e.target&&e.target.closest?e.target.closest(".c-diff__line"):null;if(!line||!this.contains(line))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();line.click()}})}}define("contour-diff",ContourDiff);class ContourDoDont extends ContourBase{static get observed(){return["do","dont"]}static get properties(){return{do:{attribute:"do"},dont:{attribute:"dont"}}}render(){this.classList.add("c-do-dont");this.setAttribute("role","group");this.setAttribute("aria-label","Do and don't");Array.from(this.querySelectorAll(".c-do-dont__item")).forEach((n)=>n.remove());const item=(kind,word,text)=>{const el=document.createElement("div");el.className=`c-do-dont__item c-do-dont__item--${kind}`;el.setAttribute("role","listitem");const label=document.createElement("p");label.className="c-do-dont__label";label.textContent=word;const body=document.createElement("p");body.className="u-muted";body.textContent=text;el.append(label,body);return el};const doText=this.getAttribute("do");const dontText=this.getAttribute("dont");if(doText)this.appendChild(item("do","Do",doText));if(dontText)this.appendChild(item("dont","Don't",dontText))}enhance(){if(this._wiredDoDont)return;this._wiredDoDont=true;this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-do-dont__item"):null;if(item&&this.contains(item)){const kind=item.classList.contains("c-do-dont__item--do")?"do":"dont";const text=item.querySelector(".u-muted")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:do-dont-activate",{bubbles:true,composed:true,detail:{kind,text}}))}});Array.from(this.querySelectorAll(".c-do-dont__item")).forEach((it)=>{if(!it.hasAttribute("tabindex"))it.setAttribute("tabindex","0");if(!it.hasAttribute("role"))it.setAttribute("role","button")});this.addEventListener("keydown",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-do-dont__item"):null;if(!item||!this.contains(item))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();item.click()}})}}define("contour-do-dont",ContourDoDont);class ContourFlag extends ContourBase{static get observed(){return["variant","label"]}static get properties(){return{variant:{attribute:"variant"},label:{attribute:"label"}}}render(){this.classList.add("c-flag");const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-flag--"))this.classList.remove(c)});if(variant)this.classList.add("c-flag--"+variant);const label=this.getAttribute("label");if(label){this.textContent=label}}}define("contour-flag",ContourFlag);class ContourInstallFull extends ContourBase{static get observed(){return["command","prompt","copyable"]}static get properties(){return{command:{attribute:"command"},prompt:{attribute:"prompt"},copyable:{attribute:"copyable"}}}render(){this.classList.add("c-install");const prompt=this.getAttribute("prompt")||"$";const command=this.getAttribute("command")||"";if(command){const p=this.ensure(".c-install__prompt",()=>{const el=document.createElement("span");el.className="c-install__prompt";return el});p.textContent=prompt;const c=this.ensure(".c-install__command",()=>{const el=document.createElement("span");el.className="c-install__command";return el});c.textContent=command;if(this.hasAttribute("copyable")){this.ensure(".c-install__copy",()=>{const btn=document.createElement("button");btn.className="c-btn c-btn--ghost c-btn--sm c-install__copy";btn.type="button";btn.setAttribute("aria-label","Copy command");btn.textContent="Copy";return btn})}else{const btn=this.querySelector(".c-install__copy");if(btn)btn.remove()}}}enhance(){wireCopy(this)}}define("contour-install",ContourInstallFull);class ContourTestimonialFull extends ContourBase{static get observed(){return["quote","name","role"]}static get properties(){return{quote:{attribute:"quote"},name:{attribute:"name"},role:{attribute:"role"}}}render(){this.classList.add("c-testimonial");const quote=this.getAttribute("quote");if(quote){const q=this.ensure(".c-testimonial__quote",()=>{const el=document.createElement("blockquote");el.className="c-testimonial__quote";return el});q.textContent=quote}else{const q=this.querySelector(".c-testimonial__quote");if(q)q.remove()}const name=this.getAttribute("name");const role=this.getAttribute("role");if(name){const by=this.ensure(".c-testimonial__byline",()=>{const el=document.createElement("div");el.className="c-testimonial__byline";return el});const n=by.querySelector(".c-testimonial__name")||(()=>{const el=document.createElement("span");el.className="c-testimonial__name";by.appendChild(el);return el})();n.className="c-testimonial__name";n.textContent=name;if(role){const r=by.querySelector(".c-testimonial__role")||(()=>{const el=document.createElement("span");el.className="c-testimonial__role";by.appendChild(el);return el})();r.className="c-testimonial__role";r.textContent=role}else{const r=by.querySelector(".c-testimonial__role");if(r)r.remove()}}else{const by=this.querySelector(".c-testimonial__byline");if(by)by.remove()}}}define("contour-testimonial",ContourTestimonialFull);class ContourShowcaseFull extends ContourBase{static get observed(){return["title","text","media","reverse","items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","heading"]}static get properties(){return{title:{attribute:"title"},text:{attribute:"text"},media:{attribute:"media"},reverse:{attribute:"reverse"},items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-showcase");this.setAttribute("role","list");if(this.hasAttribute("reverse"))this.classList.add("c-showcase--reverse");else this.classList.remove("c-showcase--reverse");const title=this.getAttribute("title");if(title)this.setAttribute("aria-label",title);else this.removeAttribute("aria-label");this.setAttribute("role","region");wireStates(this);loadRemote(this,"items");if(renderStates(this,"showcase"))return;const items=remoteData(this,"items");const text=this.getAttribute("text");const media=this.getAttribute("media");if(media){const m=this.ensure(".c-showcase__media",()=>{const el=document.createElement("div");el.className="c-showcase__media";el.setAttribute("role","img");return el});m.innerHTML=sanitizeHtml(media);if(title)m.setAttribute("aria-label",title)}else{const m=this.querySelector(".c-showcase__media");if(m)m.remove()}if(title){const t=this.ensure(".c-showcase__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-showcase__title";return el});t.textContent=title}else{const t=this.querySelector(".c-showcase__title");if(t)t.remove()}if(text){const p=this.ensure(".c-showcase__text",()=>{const el=document.createElement("p");el.className="c-showcase__text";return el});p.textContent=text}else{const p=this.querySelector(".c-showcase__text");if(p)p.remove()}const ul=this.querySelector(".c-showcase__list");const authored=ul?Array.from(ul.children).filter((n)=>n.tagName==="LI"):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const l=this.ensure(".c-showcase__list",()=>{const el=document.createElement("ul");el.className="c-showcase__list";return el});l.innerHTML="";parsed.forEach((it)=>{const li=document.createElement("li");li.textContent=typeof it==="string"?it:it.label;l.appendChild(li)})}catch(e){}}else if(!items&&!authored.length&&!title&&!text&&!media){renderEmpty(this,"showcase")}else if(!items&&ul){ul.remove()}}enhance(){if(this._wiredShowcase)return;this._wiredShowcase=true;this.addEventListener("click",(e)=>{const media=e.target&&e.target.closest?e.target.closest(".c-showcase__media"):null;if(media&&this.contains(media)){const title=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:showcase-activate",{bubbles:true,composed:true,detail:{title}}))}})}}define("contour-showcase",ContourShowcaseFull);class ContourPricingFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-pricing")}}define("contour-pricing",ContourPricingFull);class ContourRecipeFull extends ContourBase{static get observed(){return["title","body","canvas","heading"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},canvas:{attribute:"canvas"}}}render(){this.classList.add("c-recipe");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-recipe__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-recipe__title";return el});t.textContent=title}else{const t=this.querySelector(".c-recipe__title");if(t)t.remove()}const body=this.getAttribute("body");if(body){const b=this.ensure(".c-recipe__desc",()=>{const el=document.createElement("p");el.className="c-recipe__desc";return el});b.textContent=body}else{const b=this.querySelector(".c-recipe__desc");if(b)b.remove()}const canvas=this.getAttribute("canvas");if(canvas){const c=this.ensure(".c-recipe__canvas",()=>{const el=document.createElement("div");el.className="c-recipe__canvas";return el});c.innerHTML=sanitizeHtml(canvas)}else{const c=this.querySelector(".c-recipe__canvas");if(c)c.remove()}}}define("contour-recipe",ContourRecipeFull);class ContourLogosFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-logos");if(!this.querySelector(".c-logos__item")){for(const name of["Cartolab","Nordwand"]){const span=document.createElement("span");span.className="c-logos__item";span.textContent=name;this.appendChild(span)}}}}define("contour-logos",ContourLogosFull);class ContourLandingFeaturesFull extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-landing-features");wireStates(this);loadRemote(this,"items");if(renderStates(this,"landing-features"))return;const items=remoteData(this,"items");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-landing-features__item"));if(items&&!authored.length){try{const parsed=JSON.parse(items);this.querySelectorAll(".c-landing-features__item").forEach((el)=>el.remove());parsed.forEach((it)=>{const item=document.createElement("div");item.className="c-landing-features__item";if(it.icon){const ic=document.createElement("span");ic.className="c-landing-features__icon";ic.innerHTML='<svg aria-hidden="true"><use href="#'+String(it.icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>';item.appendChild(ic)}if(it.title){const t=document.createElement("span");t.className="c-landing-features__title";t.textContent=it.title;item.appendChild(t)}if(it.text){const tx=document.createElement("p");tx.className="c-landing-features__text";tx.textContent=it.text;item.appendChild(tx)}this.appendChild(item)})}catch(e){}}else if(!items&&!authored.length){this.querySelectorAll(".c-landing-features__item").forEach((el)=>el.remove());renderEmpty(this,"landing-features")}}}define("contour-landing-features",ContourLandingFeaturesFull);class ContourLandingHeroFull extends ContourBase{static get observed(){return["actions","title","text","heading"]}static get properties(){return{actions:{attribute:"actions"},title:{attribute:"title"},text:{attribute:"text"}}}render(){this.classList.add("c-landing-hero");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-landing-hero__title",()=>{const el=document.createElement(headingTag(this,"h1"));el.className="c-landing-hero__title";return el});t.textContent=title}const text=this.getAttribute("text");if(text){const t=this.ensure(".c-landing-hero__text",()=>{const el=document.createElement("p");el.className="c-landing-hero__text";return el});t.textContent=text}const actions=this.getAttribute("actions");const a=this.querySelector(".c-landing-hero__actions");const authored=a?Array.from(a.children):[];if(actions&&!authored.length){const el=this.ensure(".c-landing-hero__actions",()=>{const e=document.createElement("div");e.className="c-landing-hero__actions";return e});el.innerHTML=sanitizeHtml(actions)}else if(!actions&&a&&!authored.length){a.remove()}}}define("contour-landing-hero",ContourLandingHeroFull);class ContourLinkishFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-linkish")}}define("contour-linkish",ContourLinkishFull);class ContourPriceFull extends ContourBase{static get observed(){return["value","format","locale"]}static get properties(){return{value:{attribute:"value"},format:{attribute:"format"},locale:{attribute:"locale"}}}render(){this.classList.add("c-price");const value=this.getAttribute("value");if(value)this.textContent=formatValue(value,this.getAttribute("format"),this.getAttribute("locale"))}}define("contour-price",ContourPriceFull);class ContourProseFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-prose")}}define("contour-prose",ContourProseFull);class ContourPanel extends ContourBase{static get observed(){return["title","subtitle","status","heading","collapsible","collapsed"]}static get properties(){return{title:{attribute:"title"},subtitle:{attribute:"subtitle"},status:{attribute:"status"},collapsible:{attribute:"collapsible",type:Boolean},collapsed:{attribute:"collapsed",type:Boolean}}}render(){this.classList.add("c-panel");const title=this.getAttribute("title");const subtitle=this.getAttribute("subtitle");const status=this.getAttribute("status");if(title){const h=this.ensure(".c-panel__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-panel__title";return el});if(h.parentNode===this&&this.firstChild!==h)this.prepend(h);h.textContent=title}else{const h=this.querySelector(".c-panel__title");if(h)h.remove()}if(subtitle){const sub=this.ensure(".c-panel__subtitle",()=>{const el=document.createElement("p");el.className="c-panel__subtitle";return el});sub.textContent=subtitle}else{const sub=this.querySelector(".c-panel__subtitle");if(sub)sub.remove()}if(status){const st=this.ensure(".c-panel__status",()=>{const el=document.createElement("span");el.className="c-panel__status";return el});st.textContent=status}else{const st=this.querySelector(".c-panel__status");if(st)st.remove()}if(this.hasAttribute("collapsible")){let btn=this.querySelector(".c-panel__collapse");if(!btn){btn=document.createElement("button");btn.type="button";btn.className="c-panel__collapse c-btn c-btn--ghost c-btn--sm";btn.setAttribute("aria-label","Toggle panel");btn.textContent="▾";this.appendChild(btn)}if(this.hasAttribute("collapsed")){this.classList.add("c-panel--collapsed");btn.setAttribute("aria-expanded","false");btn.textContent="▸"}else{this.classList.remove("c-panel--collapsed");btn.setAttribute("aria-expanded","true");btn.textContent="▾"}}else{const btn=this.querySelector(".c-panel__collapse");if(btn)btn.remove();this.classList.remove("c-panel--collapsed")}const body=this.ensure(".c-panel__body",()=>{const el=document.createElement("div");el.className="c-panel__body";return el});const head=this.querySelector(".c-panel__head");Array.from(this.childNodes).forEach((n)=>{if(n===body||n===head)return;if(n.nodeType===1&&(n.classList.contains("c-panel__title")||n.classList.contains("c-panel__subtitle")||n.classList.contains("c-panel__status")))return;body.appendChild(n)});if(!body.parentNode)this.appendChild(body);if(head&&head.parentNode===this&&body.parentNode===this&&head.compareDocumentPosition(body)&Node.DOCUMENT_POSITION_PRECEDING){this.insertBefore(body,head.nextSibling)}}enhance(){if(this._wiredPanel)return;this._wiredPanel=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-panel__collapse"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.toggleAttribute("collapsed");this.dispatchEvent(new CustomEvent("contour:collapse",{bubbles:true,composed:true,detail:{collapsed:this.hasAttribute("collapsed")}}))})}}define("contour-panel",ContourPanel);class ContourCta extends ContourBase{static get observed(){return["title","text","actions","heading"]}static get properties(){return{title:{attribute:"title"},text:{attribute:"text"},actions:{attribute:"actions"}}}render(){this.classList.add("c-cta");const title=this.getAttribute("title");const text=this.getAttribute("text");if(title){const t=this.ensure(".c-cta__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-cta__title";return el});t.textContent=title}else{const t=this.querySelector(".c-cta__title");if(t)t.remove()}if(text){const p=this.ensure(".c-cta__text",()=>{const el=document.createElement("p");el.className="c-cta__text";return el});p.textContent=text}else{const p=this.querySelector(".c-cta__text");if(p)p.remove()}const actions=this.getAttribute("actions");const prevWrap=this.querySelector(".c-cta__actions");if(prevWrap)prevWrap.remove();if(actions){try{const parsed=JSON.parse(actions);const wrap=document.createElement("div");wrap.className="c-cta__actions";parsed.forEach((a)=>{const btn=document.createElement("button");btn.className="c-btn c-btn--primary";btn.type="button";btn.textContent=typeof a==="string"?a:(a.label||a);wrap.appendChild(btn)});this.appendChild(wrap)}catch(e){}}}}define("contour-cta",ContourCta);class ContourCode extends ContourBase{static get observed(){return["title","copyable"]}static get properties(){return{title:{attribute:"title"},copyable:{attribute:"copyable",type:Boolean}}}render(){this.classList.add("c-code");const title=this.getAttribute("title");if(title){const head=this.ensure(".c-code__head",()=>{const el=document.createElement("div");el.className="c-code__head";return el});if(head.parentNode===this&&this.firstChild!==head)this.prepend(head);const t=head.querySelector(".c-code__title")||(()=>{const el=document.createElement("div");el.className="c-code__title";head.appendChild(el);return el})();t.textContent=title}else{const head=this.querySelector(".c-code__head");if(head)head.remove();const t=this.querySelector(".c-code__title");if(t)t.remove()}if(this.hasAttribute("copyable")){this.ensure(".c-code__copy",()=>{const btn=document.createElement("button");btn.className="c-code__copy";btn.type="button";btn.textContent="Copy";return btn})}else{const btn=this.querySelector(".c-code__copy");if(btn)btn.remove()}const pre=this.ensure("pre",()=>{const el=document.createElement("pre");return el});Array.from(this.childNodes).forEach((n)=>{if(n===pre||(n.nodeType===1&&(n.classList.contains("c-code__head")||n.classList.contains("c-code__copy"))))return;pre.appendChild(n)});if(!pre.querySelector("code")){const code=document.createElement("code");while(pre.firstChild)code.appendChild(pre.firstChild);pre.appendChild(code)}if(pre.parentNode!==this)this.appendChild(pre);const head=this.querySelector(".c-code__head");if(head&&head.parentNode===this&&pre.parentNode===this&&head.compareDocumentPosition(pre)&Node.DOCUMENT_POSITION_PRECEDING){this.insertBefore(pre,head.nextSibling)}}enhance(){wireCopy(this)}}define("contour-code",ContourCode);class ContourPlate extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-plate")}}define("contour-plate",ContourPlate);class ContourPullquote extends ContourBase{static get observed(){return["quote","name"]}static get properties(){return{quote:{attribute:"quote"},name:{attribute:"name"}}}render(){this.classList.add("c-pullquote");const quote=this.getAttribute("quote");if(quote){Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===3)n.remove()});const cite=this.querySelector("cite");this.insertBefore(document.createTextNode(quote),cite)}const name=this.getAttribute("name");if(name){const by=this.ensure("cite",()=>{const el=document.createElement("cite");this.appendChild(el);return el});by.textContent=name}else{const by=this.querySelector("cite");if(by)by.remove()}}}define("contour-pullquote",ContourPullquote);class ContourAnchor extends ContourBase{static get observed(){return["href","label"]}static get properties(){return{href:{attribute:"href"},label:{attribute:"label"}}}render(){this.classList.add("c-anchor");const href=this.getAttribute("href");const label=this.getAttribute("label");const prevAnchor=this.querySelector("a");if(prevAnchor)prevAnchor.remove();if(href&&label){const a=document.createElement("a");a.href=href;a.textContent=label;const ariaLabel=this.getAttribute("aria-label");if(ariaLabel)a.setAttribute("aria-label",ariaLabel);this.appendChild(a)}}}define("contour-anchor",ContourAnchor);class ContourGeocoder extends ContourBase{static get observed(){return["placeholder","value","results","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{placeholder:{attribute:"placeholder"},value:{attribute:"value"},results:{attribute:"results"},src:{attribute:"src"}}}render(){this.classList.add("c-geocoder");wireStates(this);loadRemote(this,["results"]);if(renderStates(this,"geocoder"))return;let inp=this.querySelector(".c-geocoder__input");if(!inp){inp=document.createElement("input");inp.type="search";inp.className="c-geocoder__input";this.appendChild(inp)}const ph=this.getAttribute("placeholder");if(ph)inp.setAttribute("placeholder",ph);const val=this.getAttribute("value");if(val!==null&&inp.value!==val)inp.value=val;Array.from(this.querySelectorAll(".c-geocoder__result")).forEach((n)=>n.remove());let results=[];const rAttr=this.getAttribute("results");if(rAttr){try{results=JSON.parse(rAttr)}catch(e){results=[]}}const remote=remoteData(this,"results");if(Array.isArray(remote))results=remote;if(Array.isArray(results)&&results.length){const list=document.createElement("ul");list.className="c-geocoder__list";list.setAttribute("role","listbox");results.forEach((r,idx)=>{const li=document.createElement("li");li.className="c-geocoder__result";li.setAttribute("role","option");li.setAttribute("tabindex",idx===0?"0":"-1");li.textContent=(typeof r==="object")?(r.label||r.name||""):String(r);if(typeof r==="object"){if(r.lat!=null)li.dataset.lat=String(r.lat);if(r.lon!=null)li.dataset.lon=String(r.lon)}list.appendChild(li)});this.appendChild(list)}else if(!this.hasAttribute("loading")&&!this.hasAttribute("error")){renderEmpty(this,"geocoder")}}enhance(){if(this._wiredGeocoder)return;this._wiredGeocoder=true;const inp=this.querySelector(".c-geocoder__input");if(inp){let timer=null;inp.addEventListener("input",()=>{if(timer)clearTimeout(timer);timer=setTimeout(()=>{this.dispatchEvent(new CustomEvent("contour:search",{bubbles:true,composed:true,detail:{query:inp.value}}))},200)});inp.addEventListener("keydown",(e)=>{if(e.key==="Enter"){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:search",{bubbles:true,composed:true,detail:{query:inp.value}}))}})}this.addEventListener("click",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-geocoder__result"):null;if(!li||!this.contains(li))return;const result={label:li.textContent.trim(),lat:li.dataset.lat,lon:li.dataset.lon};this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{result}}))});this.addEventListener("keydown",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-geocoder__result"):null;if(!li||!this.contains(li))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();const result={label:li.textContent.trim(),lat:li.dataset.lat,lon:li.dataset.lon};this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{result}}))}})}}define("contour-geocoder",ContourGeocoder);class ContourDashShell extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-dash-shell");this.setAttribute("role","region");const title=this.getAttribute("title");if(title){const bar=this.ensure(".c-dash-toolbar",()=>{const el=document.createElement("div");el.className="c-dash-toolbar";return el});const h=bar.querySelector(".c-dash-toolbar__title")||(()=>{const el=document.createElement("span");el.className="c-dash-toolbar__title";bar.appendChild(el);return el})();h.textContent=title;this.setAttribute("aria-label",title)}}}define("contour-dash-shell",ContourDashShell);class ContourDashToolbar extends ContourBase{static get observed(){return["title","actions"]}static get properties(){return{title:{attribute:"title"},actions:{attribute:"actions"}}}render(){this.classList.add("c-dash-toolbar");this.setAttribute("role","toolbar");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-dash-toolbar__title",()=>{const el=document.createElement("span");el.className="c-dash-toolbar__title";return el});t.textContent=title;this.setAttribute("aria-label",title)}else{const t=this.querySelector(".c-dash-toolbar__title");if(t)t.remove()}const actions=this.getAttribute("actions");if(actions){try{const parsed=JSON.parse(actions);const wrap=this.ensure(".c-dash-toolbar__actions",()=>{const el=document.createElement("div");el.className="c-dash-toolbar__actions";return el});wrap.innerHTML="";parsed.forEach((a)=>{const btn=document.createElement("button");btn.className="c-btn c-btn--ghost c-btn--sm";btn.type="button";btn.textContent=typeof a==="string"?a:(a.label||a);wrap.appendChild(btn)})}catch(e){}}else{const w=this.querySelector(".c-dash-toolbar__actions");if(w)w.remove()}}enhance(){if(this._wiredDashToolbar)return;this._wiredDashToolbar=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-btn"):null;if(btn&&this.contains(btn)){const label=btn.textContent||"";this.dispatchEvent(new CustomEvent("contour:dash-action",{bubbles:true,composed:true,detail:{label}}))}});this.addEventListener("keydown",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-btn"):null;if(!btn||!this.contains(btn))return;const btns=Array.from(this.querySelectorAll(".c-btn"));const idx=btns.indexOf(btn);let next=-1;if(e.key==="ArrowRight")next=Math.min(btns.length-1,idx+1);else if(e.key==="ArrowLeft")next=Math.max(0,idx-1);if(next>=0){e.preventDefault();try{btns[next].focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();btn.click()}})}}define("contour-dash-toolbar",ContourDashToolbar);class ContourDashKpiRow extends ContourBase{static get observed(){return["items"]}static get properties(){return{items:{attribute:"items"}}}render(){this.classList.add("c-dash-kpi-row");this.setAttribute("role","group");Array.from(this.querySelectorAll("contour-kpi")).forEach((n)=>n.remove());const items=this.getAttribute("items");let parsed=null;if(items){try{parsed=JSON.parse(items)}catch(e){parsed=null}}if(Array.isArray(parsed)&&parsed.length){parsed.forEach((it)=>{const k=document.createElement("contour-kpi");if(typeof it==="object"&&it!==null){if(it.value!==undefined)k.setAttribute("value",String(it.value));if(it.label!==undefined)k.setAttribute("label",String(it.label))}else{k.setAttribute("value",String(it))}this.appendChild(k)})}else if(!this.querySelector("contour-kpi")){const k=document.createElement("contour-kpi");k.setAttribute("value","0");k.setAttribute("label","KPI");this.appendChild(k)}}enhance(){if(this._wiredDashKpiRow)return;this._wiredDashKpiRow=true;this.addEventListener("click",(e)=>{const kpi=e.target&&e.target.closest?e.target.closest("contour-kpi"):null;if(kpi&&this.contains(kpi)){const kpis=Array.from(this.querySelectorAll("contour-kpi"));const idx=kpis.indexOf(kpi);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx}}))}})}}define("contour-dash-kpi-row",ContourDashKpiRow);class ContourDashFreshness extends ContourBase{static get observed(){return["label","value","format","locale"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},format:{attribute:"format"},locale:{attribute:"locale"}}}render(){this.classList.add("c-dash-freshness");this.setAttribute("role","status");this.setAttribute("aria-live","polite");const label=this.getAttribute("label");const value=this.getAttribute("value");const dot=this.ensure(".c-dot",()=>{const el=document.createElement("span");el.className="c-dot c-dot--live c-dot--accent";el.setAttribute("aria-hidden","true");return el});if(dot.parentNode!==this)this.appendChild(dot);if(!this._freshnessText||!this._freshnessText.parentNode){this._freshnessText=document.createTextNode("");this.appendChild(this._freshnessText)}const formattedValue=value?formatValue(value,this.getAttribute("format"),this.getAttribute("locale")):value;this._freshnessText.nodeValue=[label,formattedValue].filter(Boolean).join(" ")}}define("contour-dash-freshness",ContourDashFreshness);class ContourReadout extends ContourBase{static get observed(){return["rows","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","format","locale"]}static get properties(){return{rows:{attribute:"rows"},format:{attribute:"format"},locale:{attribute:"locale"},src:{attribute:"src"}}}render(){this.classList.add("c-readout");wireStates(this);loadRemote(this,"rows");if(renderStates(this,"readout"))return;const rows=remoteData(this,"rows");Array.from(this.querySelectorAll(".c-readout__row")).forEach((n)=>n.remove());const authored=Array.from(this.children).filter((n)=>!n.classList||!n.classList.contains("c-readout__row"));if(rows&&!authored.length){try{const parsed=JSON.parse(rows);parsed.forEach((r)=>{const row=document.createElement("div");row.className="c-readout__row";const key=document.createElement("span");key.className="c-readout__key";key.textContent=r.key||r[0];const val=document.createElement("span");val.className="c-readout__value"+(r.primary?" c-readout__value--primary":"")+(r.accent?" c-readout__value--accent":"")+(r.coord?" c-readout__value--coord":"");val.setAttribute("aria-live","polite");val.textContent=formatValue(r.value||r[1],this.getAttribute("format"),this.getAttribute("locale"),(r.unit!==undefined?r.unit:this.getAttribute("unit")));row.appendChild(key);row.appendChild(val);if(r.order){const ord=document.createElement("span");ord.className="c-readout__order";ord.textContent=r.order;row.appendChild(ord)}this.appendChild(row)})}catch(e){}}else if(!rows&&!authored.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"]}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(){this.classList.add("c-kpi");wireStates(this);loadRemote(this,["value","label"]);if(renderStates(this,"kpi"))return;const value=remoteData(this,"value");const label=remoteData(this,"label");const delta=this.getAttribute("delta");const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-kpi--"))this.classList.remove(c)});if(variant)this.classList.add("c-kpi--"+variant);if(value){const v=this.ensure(".c-kpi__value",()=>{const el=document.createElement("div");el.className="c-kpi__value";el.setAttribute("aria-live","polite");return el});v.textContent=formatValue(value,this.getAttribute("format"),this.getAttribute("locale"),this.getAttribute("unit"))}else{const v=this.querySelector(".c-kpi__value");if(v)v.remove()}if(label){const h=this.ensure(".c-kpi__head",()=>{const el=document.createElement("div");el.className="c-kpi__head";return el});let l=h.querySelector(".c-kpi__label");if(!l){l=document.createElement("div");l.className="c-kpi__label";h.appendChild(l)}l.textContent=label;if(h.parentNode!==this)this.insertBefore(h,this.firstChild)}else{const h=this.querySelector(".c-kpi__head");if(h)h.remove()}if(delta){const f=this.ensure(".c-kpi__foot",()=>{const el=document.createElement("div");el.className="c-kpi__foot";return el});const d=f.querySelector(".c-delta")||document.createElement("span");if(!d.parentNode)f.insertBefore(d,f.firstChild);const dir=this.getAttribute("direction")||"up";const polarity=this.getAttribute("polarity")||"neutral";let tone="neutral";if(polarity==="good")tone=(dir==="up")?"good":"bad";else if(polarity==="bad")tone=(dir==="up")?"bad":"good";d.className="c-delta c-delta--"+dir+" c-delta--"+tone;d.textContent=delta}else{const d=this.querySelector(".c-kpi__foot .c-delta");if(d)d.remove()}const note=this.getAttribute("note");if(note){const f=this.ensure(".c-kpi__foot",()=>{const el=document.createElement("div");el.className="c-kpi__foot";return el});const n=f.querySelector(".c-kpi__note")||(()=>{const el=document.createElement("span");el.className="c-kpi__note";f.appendChild(el);return el})();n.textContent=note}else{const n=this.querySelector(".c-kpi__note");if(n)n.remove()}const unit=this.getAttribute("unit");const v=this.querySelector(".c-kpi__value");if(v){if(unit){let u=v.querySelector(".c-kpi__unit");if(!u){u=document.createElement("span");u.className="c-kpi__unit";v.appendChild(u)}u.textContent=unit}else{const u=v.querySelector(".c-kpi__unit");if(u)u.remove()}}const threshold=this.getAttribute("threshold")||this.getAttribute("thresholds");if(threshold){const f=this.ensure(".c-kpi__foot",()=>{const el=document.createElement("div");el.className="c-kpi__foot";return el});let badge=f.querySelector(".c-kpi__threshold-badge");if(!badge){badge=document.createElement("span");badge.className="c-kpi__threshold-badge";f.appendChild(badge)}badge.textContent=threshold;badge.setAttribute("part","threshold-badge")}else{const b=this.querySelector(".c-kpi__threshold-badge");if(b)b.remove()}const foot=this.querySelector(".c-kpi__foot");if(foot&&!foot.querySelector(".c-delta, .c-kpi__note, .c-kpi__threshold-badge"))foot.remove();const spark=this.getAttribute("sparkline");if(spark){let canvas=this.querySelector(".c-kpi__sparkline-canvas");if(!canvas){canvas=document.createElement("canvas");canvas.className="c-kpi__sparkline-canvas";canvas.setAttribute("part","sparkline-canvas");this.appendChild(canvas)}}else{const c=this.querySelector(".c-kpi__sparkline-canvas");if(c)c.remove()}if(!value&&!label){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","empty","loading","error","retry","skeleton","persist"]}static get properties(){return{columns:{attribute:"columns"},rows:{attribute:"rows"},page:{attribute:"page",type:Number},pageSize:{attribute:"page-size",type:Number}}}_cellValue(cell){if(cell===null||cell===undefined)return"";if(typeof cell==="object")return cell.value!==undefined?cell.value:(cell.label!==undefined?cell.label:JSON.stringify(cell));return cell}_compare(a,b,type){const av=this._cellValue(a);const bv=this._cellValue(b);if(type==="number"||type==="numeric"){return(parseFloat(av)||0)-(parseFloat(bv)||0)}return String(av).localeCompare(String(bv),undefined,{numeric:true})}render(){this.setAttribute("role","region");this.setAttribute("aria-label","Table");const columns=this.getAttribute("columns");const rows=this.getAttribute("rows");const authored=Array.from(this.children).filter((n)=>!n.classList||!n.classList.contains("c-table-wrap"));if(columns&&rows&&!authored.length){try{const cols=JSON.parse(columns);const data=JSON.parse(rows);if(this.hasAttribute("loading")){const wrap=this.ensure(".c-table-wrap",()=>{const el=document.createElement("div");el.className="c-table-wrap";return el});const colsKey=JSON.stringify(cols);const table=(wrap.querySelector("table.c-table")&&this._tableCols===colsKey)?wrap.querySelector("table.c-table"):(()=>{const t=document.createElement("table");t.className="c-table";const thead=document.createElement("thead");const tr=document.createElement("tr");cols.forEach((c)=>{const colLabel=typeof c==="string"?c:(c.label||c.title||c);const th=document.createElement("th");th.textContent=colLabel;tr.appendChild(th)});thead.appendChild(tr);t.appendChild(thead);t.appendChild(document.createElement("tbody"));return t})();this._tableCols=colsKey;const tbody=table.querySelector("tbody");tbody.innerHTML="";const tr=document.createElement("tr");const td=document.createElement("td");td.colSpan=cols.length;td.style.textAlign="center";td.style.color="var(--color-text-muted)";td.textContent=this.getAttribute("loading")||"Loading…";tr.appendChild(td);tbody.appendChild(tr);if(table.parentNode!==wrap){wrap.innerHTML="";wrap.appendChild(table)}if(wrap.parentNode!==this)this.appendChild(wrap);const footer=this.querySelector(".c-table__pagination");if(footer)footer.remove();return}if(this.hasAttribute("error")){const wrap=this.ensure(".c-table-wrap",()=>{const el=document.createElement("div");el.className="c-table-wrap";return el});const colsKey=JSON.stringify(cols);const table=(wrap.querySelector("table.c-table")&&this._tableCols===colsKey)?wrap.querySelector("table.c-table"):(()=>{const t=document.createElement("table");t.className="c-table";const thead=document.createElement("thead");const tr=document.createElement("tr");cols.forEach((c)=>{const colLabel=typeof c==="string"?c:(c.label||c.title||c);const th=document.createElement("th");th.textContent=colLabel;tr.appendChild(th)});thead.appendChild(tr);t.appendChild(thead);t.appendChild(document.createElement("tbody"));return t})();this._tableCols=colsKey;const tbody=table.querySelector("tbody");tbody.innerHTML="";const tr=document.createElement("tr");const td=document.createElement("td");td.colSpan=cols.length;td.textContent=this.getAttribute("error")||"Error";td.style.textAlign="center";td.style.color="var(--color-danger, var(--color-text))";if(this.hasAttribute("retry")){const btn=document.createElement("button");btn.className="c-btn c-btn--ghost c-btn--sm";btn.type="button";btn.textContent=this.getAttribute("retry")||"Retry";btn.classList.add("u-ms-sm");btn.dataset.action="retry";td.appendChild(btn)}tr.appendChild(td);tbody.appendChild(tr);if(table.parentNode!==wrap){wrap.innerHTML="";wrap.appendChild(table)}if(wrap.parentNode!==this)this.appendChild(wrap);const footer=this.querySelector(".c-table__pagination");if(footer)footer.remove();return}if(this.hasAttribute("skeleton")){const wrap=this.ensure(".c-table-wrap",()=>{const el=document.createElement("div");el.className="c-table-wrap";return el});const colsKey=JSON.stringify(cols);const table=(wrap.querySelector("table.c-table")&&this._tableCols===colsKey)?wrap.querySelector("table.c-table"):(()=>{const t=document.createElement("table");t.className="c-table";const thead=document.createElement("thead");const tr=document.createElement("tr");cols.forEach((c)=>{const colLabel=typeof c==="string"?c:(c.label||c.title||c);const th=document.createElement("th");th.textContent=colLabel;tr.appendChild(th)});thead.appendChild(tr);t.appendChild(thead);t.appendChild(document.createElement("tbody"));return t})();this._tableCols=colsKey;const tbody=table.querySelector("tbody");tbody.innerHTML="";const count=Math.min(5,Math.max(1,parseInt(this.getAttribute("skeleton")||"3",10)||3));for(let i=0;i<count;i++){const tr=document.createElement("tr");cols.forEach(()=>{const td=document.createElement("td");const sk=document.createElement("span");sk.className="c-skeleton";sk.style.display="inline-block";sk.style.inlineSize="60%";sk.style.blockSize="0.8rem";td.appendChild(sk);tr.appendChild(td)});tbody.appendChild(tr)}if(table.parentNode!==wrap){wrap.innerHTML="";wrap.appendChild(table)}if(wrap.parentNode!==this)this.appendChild(wrap);const footer=this.querySelector(".c-table__pagination");if(footer)footer.remove();return}if(this._sortCol===undefined){const sortAttr=this.getAttribute("sort");if(sortAttr!==null){const idx=Number(sortAttr);this._sortCol=Number.isFinite(idx)?idx:cols.findIndex((c)=>(typeof c==="object"&&c&&(c.label||c.title||c)===sortAttr));if(this._sortCol<0)this._sortCol=null}else{this._sortCol=null}const dirAttr=this.getAttribute("sort-dir");this._sortDir=dirAttr==="descending"||dirAttr==="desc"?-1:1}let working=Array.isArray(data)?data.slice():[];if(this._sortCol!==null&&this._sortCol!==undefined&&this._sortCol>=0&&this._sortCol<cols.length){const col=this._sortCol;const dir=this._sortDir||1;const colSpec=cols[col];const type=(typeof colSpec==="object"&&colSpec&&colSpec.sortType)?colSpec.sortType:"text";working.sort((a,b)=>this._compare(a&&a[col],b&&b[col],type)*dir)}if(!this._filters)this._filters={};const activeFilters=Object.keys(this._filters).filter((k)=>this._filters[k]);if(activeFilters.length){working=working.filter((row)=>activeFilters.every((k)=>{const ci=Number(k);const q=String(this._filters[ci]||"").toLowerCase();if(!q)return true;return String(this._cellValue(row[ci])).toLowerCase().includes(q)}))}const pageSizeRaw=this.getAttribute("page-size");const pageSize=pageSizeRaw!==null?parseInt(pageSizeRaw,10):NaN;const usePaging=Number.isFinite(pageSize)&&pageSize>0;let pageAttr=this.getAttribute("page");if(this.getAttribute("persist")&&this.id){const mode=this.getAttribute("persist");let stored=null;if(mode==="storage"){try{stored=localStorage.getItem("contour-table:"+this.id)}catch(e){}}else if(mode==="url"){try{stored=new URLSearchParams(window.location.search).get("c-table")}catch(e){}}if(stored!==null)pageAttr=stored}if(this._pageInternal){this._pageInternal=false;this._pageAttrLast=pageAttr}else if(pageAttr!==this._pageAttrLast){this._page=null;this._pageAttrLast=pageAttr}let page=this._page!==null?this._page:(parseInt(pageAttr||"1",10));if(!Number.isFinite(page)||page<1)page=1;let totalPages=1;let pageData=working;if(usePaging){totalPages=Math.max(1,Math.ceil(working.length/pageSize));if(page>totalPages)page=totalPages;const start=(page-1)*pageSize;pageData=working.slice(start,start+pageSize)}this._page=page;this._totalPages=totalPages;this._pageSize=pageSize;const wrap=this.ensure(".c-table-wrap",()=>{const el=document.createElement("div");el.className="c-table-wrap";return el});const colsKey=JSON.stringify(cols);const table=(wrap.querySelector("table.c-table")&&this._tableCols===colsKey)?wrap.querySelector("table.c-table"):(()=>{const t=document.createElement("table");t.className="c-table";const thead=document.createElement("thead");const tr=document.createElement("tr");cols.forEach((c,i)=>{const colLabel=typeof c==="string"?c:(c.label||c.title||c);const th=document.createElement("th");const sortable=(typeof c==="object"&&c!==null&&c.sort);const isSelect=(typeof c==="object"&&c!==null&&c.select);const isFilter=(typeof c==="object"&&c!==null&&c.filter);if(isFilter){th.className=(th.className+" c-table__filter").trim();const inp=document.createElement("input");inp.type="search";inp.className="c-table__filter-input";inp.placeholder=colLabel;inp.dataset.filterIndex=String(i);if(this._filters&&this._filters[i])inp.value=this._filters[i];th.appendChild(inp)}else if(isSelect){th.className=(th.className+" c-table__select").trim();const cb=document.createElement("input");cb.type="checkbox";cb.className="c-table__select-all";cb.setAttribute("aria-label","Select all rows");th.appendChild(cb)}else if(sortable){th.setAttribute("aria-sort",(this._sortCol===i)?(this._sortDir===-1?"descending":"ascending"):"none");const wrapEl=document.createElement("span");wrapEl.className="c-table__sort";wrapEl.textContent=colLabel;const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("aria-hidden","true");svg.innerHTML='<use href="#i-chevron-down" />';wrapEl.appendChild(svg);th.appendChild(wrapEl)}else if(typeof c==="object"&&c!==null&&c.pinned){th.className="c-table__pinned";th.textContent=colLabel}else{th.textContent=colLabel}if(sortable){th.setAttribute("tabindex","0");th.setAttribute("role","columnheader");th.dataset.sortIndex=String(i)}tr.appendChild(th)});thead.appendChild(tr);t.appendChild(thead);t.appendChild(document.createElement("tbody"));return t})();this._tableCols=colsKey;cols.forEach((c,i)=>{if(typeof c==="object"&&c!==null&&c.sort){const th=table.querySelector("thead tr th:nth-child("+(i+1)+")");if(th)th.setAttribute("aria-sort",(this._sortCol===i)?(this._sortDir===-1?"descending":"ascending"):"none")}});const tbody=table.querySelector("tbody");tbody.innerHTML="";const useVirtual=this.hasAttribute("virtual")&&!usePaging&&pageData.length>100;const rowHeight=36;const windowSize=30;const overscan=10;let windowStart=0;let visibleData=pageData;if(useVirtual){const maxStart=Math.max(0,pageData.length-windowSize);windowStart=Math.min(maxStart,Math.max(0,Math.floor(wrap.scrollTop/rowHeight)-overscan));visibleData=pageData.slice(windowStart,windowStart+windowSize+overscan*2);table.setAttribute("aria-rowcount",String(pageData.length+1))}else{table.removeAttribute("aria-rowcount")}const addSpacer=(height)=>{const tr=document.createElement("tr");tr.setAttribute("aria-hidden","true");const td=document.createElement("td");td.colSpan=cols.length;td.style.blockSize=`${height}px`;td.style.padding="0";tr.appendChild(td);tbody.appendChild(tr)};if(useVirtual)addSpacer(windowStart*rowHeight);if(visibleData.length===0){const tr=document.createElement("tr");const td=document.createElement("td");td.colSpan=cols.length;td.textContent=this.getAttribute("empty")||"No data";td.style.textAlign="center";td.style.color="var(--color-text-muted)";tr.appendChild(td);tbody.appendChild(tr)}else{visibleData.forEach((row,ri)=>{const tr=document.createElement("tr");tr.dataset.rowIndex=String(windowStart+ri);tr.setAttribute("tabindex","0");cols.forEach((c,ci)=>{const isSelect=(typeof c==="object"&&c!==null&&c.select);const td=document.createElement("td");if(isSelect){const cb=document.createElement("input");cb.type="checkbox";cb.className="c-table__row-select";cb.dataset.rowIndex=String(windowStart+ri);if(this._selectedRows&&this._selectedRows.has(windowStart+ri))cb.checked=true;td.appendChild(cb)}else{td.textContent=this._cellValue(row[ci])}tr.appendChild(td)});tbody.appendChild(tr)})}if(useVirtual)addSpacer(Math.max(0,pageData.length-windowStart-visibleData.length)*rowHeight);if(table.parentNode!==wrap){wrap.innerHTML="";wrap.appendChild(table)}if(wrap.parentNode!==this)this.appendChild(wrap);if(this.hasAttribute("virtual")){wrap.style.maxHeight=wrap.style.maxHeight||"24rem";wrap.style.overflow="auto";table.classList.add("c-table--virtual")}else{wrap.style.maxHeight="";wrap.style.overflow="";table.classList.remove("c-table--virtual")}if(usePaging){const footer=this.ensure(".c-table__pagination",()=>{const el=document.createElement("div");el.className="c-table__pagination";return el});footer.innerHTML="";const prev=document.createElement("button");prev.className="c-btn c-btn--ghost c-btn--sm";prev.type="button";prev.textContent="Previous";prev.disabled=page<=1;prev.dataset.action="prev";const info=document.createElement("span");info.textContent=`Page ${page} of ${totalPages}`;const next=document.createElement("button");next.className="c-btn c-btn--ghost c-btn--sm";next.type="button";next.textContent="Next";next.disabled=page>=totalPages;next.dataset.action="next";footer.appendChild(prev);footer.appendChild(info);footer.appendChild(next)}else{const footer=this.querySelector(".c-table__pagination");if(footer)footer.remove()}}catch(e){}}}enhance(){if(this._wiredTable)return;this._wiredTable=true;const handleSort=(th)=>{const idx=Number(th.dataset.sortIndex);if(!Number.isFinite(idx))return;if(this._sortCol===idx){this._sortDir=(this._sortDir===1)?-1:1}else{this._sortCol=idx;this._sortDir=1}this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:true,composed:true,detail:{column:idx,direction:this._sortDir===1?"ascending":"descending"}}));this.requestRender()};this.addEventListener("click",(e)=>{const retryBtn=e.target&&e.target.closest?e.target.closest('button[data-action="retry"]'):null;if(retryBtn&&this.contains(retryBtn)){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:retry",{detail:{src:this.getAttribute("src")},bubbles:true,composed:true}));return}const th=e.target&&e.target.closest?e.target.closest("th[aria-sort]"):null;if(th&&this.contains(th)){e.preventDefault();handleSort(th);return}const btn=e.target&&e.target.closest?e.target.closest(".c-table__pagination button"):null;if(btn&&this.contains(btn)){e.preventDefault();const action=btn.dataset.action;let page=this._page!==null?this._page:(parseInt(this.getAttribute("page")||"1",10));if(!Number.isFinite(page)||page<1)page=1;if(action==="prev"&&page>1)page-=1;if(action==="next")page+=1;this._page=page;this._pageAttrLast=String(page);this._pageInternal=true;this.setAttribute("page",String(page));this.dispatchEvent(new CustomEvent("contour:page",{bubbles:true,composed:true,detail:{page}}));const persist=this.getAttribute("persist");if(persist==="storage"&&this.id){try{localStorage.setItem("contour-table:"+this.id,String(page))}catch(e){}}else if(persist==="url"){try{const url=new URL(window.location.href);url.searchParams.set("c-table",String(page));window.history.replaceState(null,"",url.toString())}catch(e){}}}});this.addEventListener("keydown",(e)=>{if(e.key!=="Enter"&&e.key!==" ")return;const th=e.target&&e.target.closest?e.target.closest("th[aria-sort]"):null;if(th&&this.contains(th)){e.preventDefault();handleSort(th)}});this.addEventListener("input",(e)=>{const inp=e.target&&e.target.closest?e.target.closest(".c-table__filter-input"):null;if(!inp||!this.contains(inp))return;const idx=Number(inp.dataset.filterIndex);if(!Number.isFinite(idx))return;if(!this._filters)this._filters={};this._filters[idx]=inp.value;this.requestRender()});this.addEventListener("scroll",(e)=>{if(!this.hasAttribute("virtual")||!e.target||!e.target.classList||!e.target.classList.contains("c-table-wrap"))return;if(this._tableVirtualRaf)return;const run=()=>{this._tableVirtualRaf=0;this.requestRender()};this._tableVirtualRaf=typeof requestAnimationFrame==="function"?requestAnimationFrame(run):setTimeout(run,16)},true);this._selectedRows=this._selectedRows||new Set();this.addEventListener("change",(e)=>{const cb=e.target&&e.target.closest?e.target.closest(".c-table__row-select"):null;if(cb&&this.contains(cb)){const idx=Number(cb.dataset.rowIndex);if(!Number.isFinite(idx))return;if(cb.checked)this._selectedRows.add(idx);else this._selectedRows.delete(idx);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{rows:Array.from(this._selectedRows)}}));return}const all=e.target&&e.target.closest?e.target.closest(".c-table__select-all"):null;if(all&&this.contains(all)){const cbs=Array.from(this.querySelectorAll(".c-table__row-select"));cbs.forEach((c)=>{c.checked=all.checked});this._selectedRows=new Set(all.checked?cbs.map((c)=>Number(c.dataset.rowIndex)):[]);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{rows:Array.from(this._selectedRows)}}))}});this.addEventListener("mouseover",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tbody tr"):null;if(!tr||!this.contains(tr))return;const idx=Number(tr.dataset.rowIndex);if(!Number.isFinite(idx))return;if(this._hoveredRow===idx)return;this._hoveredRow=idx;this.dispatchEvent(new CustomEvent("contour:hover",{bubbles:true,composed:true,detail:{row:idx}}))});this.addEventListener("mouseout",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tbody tr"):null;if(!tr||!this.contains(tr))return;const related=e.relatedTarget&&e.relatedTarget.closest?e.relatedTarget.closest("tbody tr"):null;if(related===tr)return;this._hoveredRow=null;this.dispatchEvent(new CustomEvent("contour:leave",{bubbles:true,composed:true,detail:{}}))});this.addEventListener("keydown",(e)=>{if(e.key!=="Enter"&&e.key!==" ")return;const tr=e.target&&e.target.closest?e.target.closest("tbody tr"):null;if(!tr||!this.contains(tr))return;e.preventDefault();const idx=Number(tr.dataset.rowIndex);if(!Number.isFinite(idx))return;this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true,detail:{row:idx}}))})}}define("contour-table",ContourTable);class ContourDataTable extends ContourTable{render(){super.render();this.classList.add("c-data-table");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Data table")}}define("contour-data-table",ContourDataTable);class ContourChart extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["series","axis","empty","loading","error","retry","skeleton","zoomable","data-table","brush","brush-min","brush-max","brush-start","brush-end","note"]}static get properties(){return{series:{attribute:"series"},axis:{attribute:"axis"},zoomable:{attribute:"zoomable",type:Boolean},brush:{attribute:"brush",type:Boolean},note:{attribute:"note"}}}render(){this.classList.add("c-chart");if(!this.hasAttribute("role"))this.setAttribute("role","img");if(this.getAttribute("axis")&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("axis"));if(this.hasAttribute("loading")){const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const loading=document.createElement("div");loading.className="c-chart__loading";loading.textContent=this.getAttribute("loading")||"Loading…";loading.style.display="grid";loading.style.placeItems="center";loading.style.height="100%";loading.style.color="var(--color-text-muted)";plot.appendChild(loading);const axis=this.getAttribute("axis");if(axis){const ax=this.ensure(".c-chart__axis",()=>{const el=document.createElement("div");el.className="c-chart__axis";return el});ax.textContent=axis}return}if(this.hasAttribute("error")){const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const err=document.createElement("div");err.className="c-chart__error";err.textContent=this.getAttribute("error")||"Error";err.style.display="grid";err.style.placeItems="center";err.style.height="100%";err.style.color="var(--color-danger, var(--color-text))";if(this.hasAttribute("retry")){const btn=document.createElement("button");btn.className="c-btn c-btn--ghost c-btn--sm";btn.type="button";btn.textContent=this.getAttribute("retry")||"Retry";btn.dataset.action="retry";btn.classList.add("u-mbs-sm");err.appendChild(btn)}plot.appendChild(err);const axis=this.getAttribute("axis");if(axis){const ax=this.ensure(".c-chart__axis",()=>{const el=document.createElement("div");el.className="c-chart__axis";return el});ax.textContent=axis}return}if(this.hasAttribute("skeleton")){const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const count=Math.min(5,Math.max(1,parseInt(this.getAttribute("skeleton")||"3",10)||3));for(let i=0;i<count;i++){const sk=document.createElement("div");sk.className="c-skeleton";sk.style.display="block";sk.style.inlineSize="100%";sk.style.blockSize="0.6rem";sk.classList.add("u-mbe-2xs");plot.appendChild(sk)}const axis=this.getAttribute("axis");if(axis){const ax=this.ensure(".c-chart__axis",()=>{const el=document.createElement("div");el.className="c-chart__axis";return el});ax.textContent=axis}return}const axis=this.getAttribute("axis");if(axis){const ax=this.ensure(".c-chart__axis",()=>{const el=document.createElement("div");el.className="c-chart__axis";return el});ax.textContent=axis}else{const ax=this.querySelector(".c-chart__axis");if(ax)ax.remove()}const series=this.getAttribute("series");if(series){let parsed=null;try{parsed=JSON.parse(series);const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const hasStructured=parsed.some((s)=>s&&Array.isArray(s.values));if(hasStructured){parsed.forEach((s,i)=>{const color=`var(--chart-${i + 1})`;if(s.type==="donut"){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 200 200");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";svg.setAttribute("aria-hidden","true");donutSlices(s.values).forEach((sl,si)=>{const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-chart__line");path.setAttribute("data-series",String(i+1));path.style.setProperty("--c",color);path.setAttribute("d",sl.path);path.setAttribute("title",String(s.values[si]));path.setAttribute("aria-label","Series "+(i+1)+": "+String(s.values[si]));path.setAttribute("role","img");svg.appendChild(path)});plot.appendChild(svg)}else if(s.type==="histogram"){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";barRects(s.values).forEach((r,ri)=>{const rect=document.createElementNS("http://www.w3.org/2000/svg","rect");rect.setAttribute("class","c-chart__bar");rect.setAttribute("data-series",String(i+1));rect.style.setProperty("--c",color);rect.setAttribute("x",r.x);rect.setAttribute("y",r.y);rect.setAttribute("width",r.width);rect.setAttribute("height",r.height);rect.setAttribute("title",String(s.values[ri]));rect.setAttribute("aria-label","Series "+(i+1)+": "+String(s.values[ri]));rect.setAttribute("tabindex","0");rect.setAttribute("role","button");rect.dataset.index=String(ri);svg.appendChild(rect)});plot.appendChild(svg)}else if(s.type==="scatter"){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const pts=(Array.isArray(s.values)?s.values:[]).map((v)=>{if(Array.isArray(v))return{x:Number(v[0])||0,y:Number(v[1])||0};return{x:Number(v&&v.x)||0,y:Number(v&&v.y)||0}});const xs=pts.map((p)=>p.x);const ys=pts.map((p)=>p.y);const minX=xs.length?Math.min.apply(null,xs):0;const maxX=xs.length?Math.max.apply(null,xs):1;const minY=ys.length?Math.min.apply(null,ys):0;const maxY=ys.length?Math.max.apply(null,ys):1;const xRange=(maxX-minX)||1;const yRange=(maxY-minY)||1;pts.forEach((p,pi)=>{const circle=document.createElementNS("http://www.w3.org/2000/svg","circle");circle.setAttribute("class","c-chart__point");circle.setAttribute("data-series",String(i+1));circle.setAttribute("data-index",String(pi));circle.style.setProperty("--c",color);const cx=((p.x-minX)/xRange)*300;const cy=120-((p.y-minY)/yRange)*120;circle.setAttribute("cx",cx.toFixed(2));circle.setAttribute("cy",cy.toFixed(2));circle.setAttribute("r","3");circle.setAttribute("tabindex",pi===0?"0":"-1");circle.setAttribute("role","button");circle.setAttribute("title",p.x+", "+p.y);circle.setAttribute("aria-label","Series "+(i+1)+": "+p.x+", "+p.y);svg.appendChild(circle)});plot.appendChild(svg)}else{const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-chart__line");path.setAttribute("data-series",String(i+1));path.style.setProperty("--c",color);path.setAttribute("d",smoothPath(s.values));svg.appendChild(path);const pts=polylinePoints(s.values).split(" ").map((p)=>p.split(",").map(Number));pts.forEach((pt,pi)=>{const circle=document.createElementNS("http://www.w3.org/2000/svg","circle");circle.setAttribute("class","c-chart__point");circle.setAttribute("data-series",String(i+1));circle.setAttribute("data-index",String(pi));circle.style.setProperty("--c",color);circle.setAttribute("cx",String(pt[0]));circle.setAttribute("cy",String(pt[1]));circle.setAttribute("r","3");circle.setAttribute("tabindex",pi===0?"0":"-1");circle.setAttribute("role","button");circle.setAttribute("title",String(s.values[pi]));circle.setAttribute("aria-label","Series "+(i+1)+": "+String(s.values[pi]));svg.appendChild(circle)});plot.appendChild(svg)}})}else{const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";svg.setAttribute("aria-hidden","true");parsed.forEach((s,i)=>{const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-chart__line");path.setAttribute("data-series",String(i+1));path.style.setProperty("--c",`var(--chart-${i + 1})`);path.setAttribute("d",s.d||s);svg.appendChild(path)});plot.appendChild(svg)}}catch(e){}const tip=this.ensure(".c-chart__tooltip",()=>{const el=document.createElement("div");el.className="c-chart__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","");if(this.hasAttribute("data-table")){let table=this.querySelector(".c-chart__data-table");if(!table){table=document.createElement("table");table.className="c-chart__data-table visually-hidden";this.appendChild(table)}table.innerHTML="";const thead=document.createElement("thead");const hr=document.createElement("tr");const h=document.createElement("th");h.textContent="Series";hr.appendChild(h);const maxLen=parsed.reduce((m,s)=>Math.max(m,Array.isArray(s.values)?s.values.length:(Array.isArray(s)?s.length:0)),0);for(let i=0;i<maxLen;i++){const th=document.createElement("th");th.textContent="Value "+(i+1);hr.appendChild(th)}thead.appendChild(hr);table.appendChild(thead);const tbody=document.createElement("tbody");parsed.forEach((s,si)=>{const vals=Array.isArray(s.values)?s.values:(Array.isArray(s)?s:[]);const tr=document.createElement("tr");const td0=document.createElement("td");td0.textContent=s.label||("Series "+(si+1));tr.appendChild(td0);for(let i=0;i<maxLen;i++){const td=document.createElement("td");td.textContent=vals[i]!=null?String(vals[i]):"";tr.appendChild(td)}tbody.appendChild(tr)});table.appendChild(tbody)}else{const old=this.querySelector(".c-chart__data-table");if(old)old.remove()}if(this.hasAttribute("brush")){const brush=this.ensure("contour-brush",()=>document.createElement("contour-brush"));brush.setAttribute("min",this.getAttribute("brush-min")||"0");brush.setAttribute("max",this.getAttribute("brush-max")||"100");brush.setAttribute("start",this.getAttribute("brush-start")||this.getAttribute("brush-min")||"0");brush.setAttribute("end",this.getAttribute("brush-end")||this.getAttribute("brush-max")||"100");if(brush.previousElementSibling!==plot)this.appendChild(brush)}else{const brush=this.querySelector("contour-brush");if(brush)brush.remove()}const note=this.getAttribute("note");let noteEl=this.querySelector(".c-chart__note");if(note){if(!noteEl){noteEl=document.createElement("div");noteEl.className="c-chart__note";this.appendChild(noteEl)}noteEl.textContent=note}else if(noteEl){noteEl.remove()}}else{const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const empty=document.createElement("div");empty.className="c-chart__empty";empty.textContent=this.getAttribute("empty")||"No data";empty.style.display="grid";empty.style.placeItems="center";empty.style.height="100%";empty.style.color="var(--color-text-muted)";plot.appendChild(empty);const note=this.getAttribute("note");let noteEl2=this.querySelector(".c-chart__note");if(note){if(!noteEl2){noteEl2=document.createElement("div");noteEl2.className="c-chart__note";this.appendChild(noteEl2)}noteEl2.textContent=note}else if(noteEl2){noteEl2.remove()}}}enhance(){if(this._wiredChart)return;this._wiredChart=true;if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");this.addEventListener("contour:legend-toggle",(e)=>{const key=e&&e.detail&&(e.detail.key||e.detail.label);const pressed=e&&e.detail&&e.detail.pressed;if(key==null)return;const nodes=this.querySelectorAll("[data-series]");nodes.forEach((n)=>{const s=n.getAttribute("data-series");if(String(s)===String(key)||n.getAttribute("data-key")===String(key)){n.style.display=pressed===false?"none":""}})});this.addEventListener("contour:brush-end",(e)=>{if(!this.hasAttribute("brush")||!e.target||!e.target.matches("contour-brush"))return;this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:e.detail,}))});if(this.hasAttribute("zoomable")){let zoom=1,panX=0,panY=0;const plot=this.querySelector(".c-chart__plot");const apply=()=>{if(!plot)return;plot.style.transform=`translate(${panX}px, ${panY}px) scale(${zoom})`;plot.style.transformOrigin="center center"};this.addEventListener("wheel",(e)=>{e.preventDefault();const factor=e.deltaY<0?1.1:0.9;zoom=Math.min(5,Math.max(0.5,zoom*factor));apply()},{passive:false});let dragging=false,startX=0,startY=0,startPanX=0,startPanY=0;this.addEventListener("mousedown",(e)=>{if(e.button!==0)return;dragging=true;startX=e.clientX;startY=e.clientY;startPanX=panX;startPanY=panY;this.style.cursor="grabbing"});const onMove=(e)=>{if(!dragging)return;panX=startPanX+(e.clientX-startX);panY=startPanY+(e.clientY-startY);apply()};const onUp=()=>{if(dragging){dragging=false;this.style.cursor=""}};window.addEventListener("mousemove",onMove);window.addEventListener("mouseup",onUp);onDispose(this,()=>{window.removeEventListener("mousemove",onMove);window.removeEventListener("mouseup",onUp)});this.addEventListener("dblclick",()=>{zoom=1;panX=0;panY=0;apply()})}let plotRectCache=null;let plotRectObserver=null;const invalidatePlotRect=()=>{plotRectCache=null};const showTip=(e)=>{const plot=this.querySelector(".c-chart__plot");const tip=this.querySelector(".c-chart__tooltip");if(!plot||!tip)return;const mark=e.target&&e.target.closest?e.target.closest(".c-chart__bar, .c-chart__point, .c-chart__line"):null;if(!mark||!plot.contains(mark)){tip.setAttribute("hidden","");return}const title=mark.getAttribute("title");if(title)tip.textContent=title;if(!plotRectCache){plotRectCache=plot.getBoundingClientRect();if(!plotRectObserver&&typeof ResizeObserver==="function"){plotRectObserver=new ResizeObserver(invalidatePlotRect);plotRectObserver.observe(plot)}}const rect=plotRectCache;const mr=mark.getBoundingClientRect();const x=mr.left-rect.left+mr.width/2;const y=mr.top-rect.top;plot.style.setProperty("--chart-tip-inline-start",x+"px");plot.style.setProperty("--chart-tip-block-start",y+"px");tip.removeAttribute("hidden")};const hideTip=()=>{const tip=this.querySelector(".c-chart__tooltip");if(tip)tip.setAttribute("hidden","")};this.addEventListener("mousemove",showTip);this.addEventListener("mouseleave",hideTip);onDispose(this,()=>{if(plotRectObserver){plotRectObserver.disconnect();plotRectObserver=null}});this.addEventListener("focusin",(e)=>{const mark=e.target&&e.target.closest?e.target.closest(".c-chart__bar, .c-chart__point, .c-chart__line"):null;if(mark&&this.contains(mark))showTip({target:mark})});this.addEventListener("focusout",(e)=>{if(!this.contains(e.relatedTarget))hideTip()});this.addEventListener("click",(e)=>{const plot2=this.querySelector(".c-chart__plot");if(!plot2)return;const bar=e.target&&e.target.closest?e.target.closest(".c-chart__bar"):null;if(bar&&plot2.contains(bar)){const series=parseInt(bar.getAttribute("data-series")||"1",10);const index=parseInt(bar.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series,index}}));return}const point=e.target&&e.target.closest?e.target.closest(".c-chart__point"):null;if(point&&plot2.contains(point)){const series=parseInt(point.getAttribute("data-series")||"1",10);const index=parseInt(point.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series,index}}))}});this.addEventListener("keydown",(e)=>{const plot2=this.querySelector(".c-chart__plot");if(!plot2)return;const bar=e.target&&e.target.closest?e.target.closest(".c-chart__bar"):null;if(bar&&plot2.contains(bar)){if(e.key==="Enter"||e.key===" "){e.preventDefault();const series=parseInt(bar.getAttribute("data-series")||"1",10);const index=parseInt(bar.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series,index}}))}return}const point=e.target&&e.target.closest?e.target.closest(".c-chart__point"):null;if(point&&plot2.contains(point)){if(e.key==="Enter"||e.key===" "){e.preventDefault();const series=parseInt(point.getAttribute("data-series")||"1",10);const index=parseInt(point.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series,index}}))}else if(e.key==="ArrowRight"||e.key==="ArrowLeft"){e.preventDefault();const points=Array.from(plot2.querySelectorAll('.c-chart__point[data-series="'+point.getAttribute("data-series")+'"]'));const idx=points.indexOf(point);const next=e.key==="ArrowRight"?Math.min(idx+1,points.length-1):Math.max(idx-1,0);if(next!==idx&&points[next]){points.forEach((p,i)=>p.setAttribute("tabindex",i===next?"0":"-1"));try{points[next].focus()}catch(err){}}}}});this.addEventListener("keydown",(e)=>{if(e.target!==this)return;let seriesCount=0;try{seriesCount=JSON.parse(this.getAttribute("series")||"[]").length}catch(e){seriesCount=0}if(seriesCount===0)return;if(this._activeSeries===undefined)this._activeSeries=0;let next=this._activeSeries;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";if(e.key==="ArrowRight")next=rtl?Math.max(this._activeSeries-1,0):Math.min(this._activeSeries+1,seriesCount-1);else if(e.key==="ArrowLeft")next=rtl?Math.min(this._activeSeries+1,seriesCount-1):Math.max(this._activeSeries-1,0);else if(e.key==="ArrowDown")next=Math.min(this._activeSeries+1,seriesCount-1);else if(e.key==="ArrowUp")next=Math.max(this._activeSeries-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=seriesCount-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:this._activeSeries}}));return}else return;if(next!==this._activeSeries){e.preventDefault();this._activeSeries=next;this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:next}}))}})}}define("contour-chart",ContourChart);class ContourComparison extends ContourBase{static get observed(){return["divider","value","before","after"]}static get properties(){return{divider:{attribute:"divider"},value:{attribute:"value"},before:{attribute:"before"},after:{attribute:"after"}}}render(){this.classList.add("c-comparison");this.setAttribute("role","group");this.setAttribute("aria-label","Comparison");if(!this.style.blockSize)this.style.blockSize="12rem";this.style.setProperty("--comparison-pos",(this.getAttribute("value")||"50")+"%");const beforeLabel=this.getAttribute("before")||"Before";const afterLabel=this.getAttribute("after")||"After";if(!this.querySelector(".c-comparison__pane--before")){const p=document.createElement("div");p.className="c-comparison__pane c-comparison__pane--before";p.textContent=beforeLabel;this.appendChild(p)}else{const p=this.querySelector(".c-comparison__pane--before");if(p)p.textContent=beforeLabel}if(!this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)")){const p=document.createElement("div");p.className="c-comparison__pane";p.textContent=afterLabel;this.appendChild(p)}else{const p=this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)");if(p)p.textContent=afterLabel}const divider=this.getAttribute("divider");if(divider!==null){const d=this.ensure(".c-comparison__divider",()=>{const el=document.createElement("div");el.className="c-comparison__divider";el.setAttribute("role","separator");el.setAttribute("aria-orientation","vertical");el.setAttribute("tabindex","0");return el});if(divider)d.textContent=divider}else{const d=this.querySelector(".c-comparison__divider");if(d)d.remove()}}enhance(){if(this._wiredComparison)return;this._wiredComparison=true;const divider=()=>this.querySelector(".c-comparison__divider");const setPos=(pct)=>{const clamped=Math.max(0,Math.min(100,pct));this.style.setProperty("--comparison-pos",clamped+"%");this.setAttribute("value",String(Math.round(clamped)));this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:true,composed:true,detail:{value:clamped}}))};let dragging=false;const onMove=(e)=>{if(!dragging)return;const rect=this.getBoundingClientRect();const pct=((e.clientX-rect.left)/rect.width)*100;setPos(pct)};const onUp=()=>{dragging=false;window.removeEventListener("mousemove",onMove);window.removeEventListener("mouseup",onUp)};onDispose(this,()=>{dragging=false;window.removeEventListener("mousemove",onMove);window.removeEventListener("mouseup",onUp)});this.addEventListener("mousedown",(e)=>{const d=divider();if(!d||!d.contains(e.target))return;dragging=true;window.addEventListener("mousemove",onMove);window.addEventListener("mouseup",onUp);e.preventDefault()});this.addEventListener("keydown",(e)=>{const d=divider();if(!d||document.activeElement!==d)return;const cur=parseFloat(this.style.getPropertyValue("--comparison-pos"))||50;if(e.key==="ArrowLeft"){e.preventDefault();setPos(cur-5)}else if(e.key==="ArrowRight"){e.preventDefault();setPos(cur+5)}})}}define("contour-comparison",ContourComparison);class ContourStreamingChart extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["line","dot","interval","pause","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{line:{attribute:"line"},dot:{attribute:"dot"},interval:{attribute:"interval",type:Number},pause:{attribute:"pause",type:Boolean},src:{attribute:"src"}}}render(){this.classList.add("c-streaming-chart");this.setAttribute("role","img");this.setAttribute("aria-label","Streaming chart");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");wireStates(this);loadRemote(this,"line");if(renderStates(this,"streaming-chart"))return;const line=remoteData(this,"line");const dot=remoteData(this,"dot");if(!line){const svg=this.querySelector("svg");if(svg)svg.remove();renderEmpty(this,"streaming-chart");return}if(line){let svg=this.querySelector("svg");if(!svg){svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 192");svg.setAttribute("aria-hidden","true");this.appendChild(svg)}let path=svg.querySelector(".c-streaming-chart__line");if(!path){path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-streaming-chart__line");svg.appendChild(path)}path.setAttribute("d",line);if(dot){let circle=svg.querySelector(".c-streaming-chart__live-dot");if(!circle){circle=document.createElementNS("http://www.w3.org/2000/svg","circle");circle.setAttribute("class","c-streaming-chart__live-dot");circle.setAttribute("r","4");svg.appendChild(circle)}const parts=dot.split(/[ ,]+/);if(parts.length>=2){circle.setAttribute("cx",parts[0]);circle.setAttribute("cy",parts[1])}}}}enhance(){const sync=()=>{const seconds=parseFloat(this.getAttribute("interval")||"");const want=Number.isFinite(seconds)&&seconds>0&&!this.hasAttribute("pause")&&!this._streamPausedByUser&&this._viewVisible!==false;if(want===this._streamRunning)return;this._streamRunning=want;if(this._streamTimer!==undefined){clearInterval(this._streamTimer);this._streamTimer=undefined}this.dispatchEvent(new CustomEvent("contour:stream-state",{detail:{running:want},bubbles:true,composed:true}));if(!want)return;this._streamTimer=setInterval(()=>{if(!this.isConnected||this.hasAttribute("pause"))return;this._streamFrame+=1;this.dispatchEvent(new CustomEvent("contour:tick",{detail:{frame:this._streamFrame},bubbles:true,composed:true}));const src=this.getAttribute("src");if(src){remoteInvalidate(src);this.requestRender()}},Math.max(1000,seconds*1000))};sync();if(!this._wiredStreamView){this._wiredStreamView=true;this._viewVisible=true;watchViewport(this);this.addEventListener("contour:view-enter",()=>{this._viewVisible=true;sync()});this.addEventListener("contour:view-leave",()=>{this._viewVisible=false;sync()})}if(this._wiredStream)return;this._wiredStream=true;this._streamFrame=0;onDispose(this,()=>{if(this._streamTimer!==undefined){clearInterval(this._streamTimer);this._streamTimer=undefined}});this._streamPausedByUser=false;this.addEventListener("keydown",(e)=>{if(e.key===" "||e.key==="Enter"){e.preventDefault();this._streamPausedByUser=!this._streamPausedByUser;if(this._streamPausedByUser)this.setAttribute("data-user-paused","");else this.removeAttribute("data-user-paused");sync()}})}}define("contour-streaming-chart",ContourStreamingChart);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"]}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(){this.classList.add("c-meter");wireStates(this);loadRemote(this,["value","label"]);if(renderStates(this,"meter"))return;const rValue=remoteData(this,"value")||(this._remoteData&&this._remoteData.value);const label=remoteData(this,"label")||(this._remoteData&&this._remoteData.label)||"";const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-meter--"))this.classList.remove(c)});if(variant)this.classList.add("c-meter--"+variant);if(!rValue&&!label){renderEmpty(this,"meter");return}if(rValue===null){this.style.removeProperty("--meter-value")}else{const num=parseFloat(rValue);if(Number.isFinite(num))this.style.setProperty("--meter-value",rValue);else this.style.removeProperty("--meter-value")}const core=this.ensure(".c-meter__core",()=>{const el=document.createElement("span");el.className="c-meter__core";return el});let val=core.querySelector(".c-meter__value");if(!val){val=document.createElement("span");val.className="c-meter__value";core.appendChild(val)}const num=parseFloat(rValue);val.textContent=(Number.isFinite(num)?Math.round(num*100):0)+"%";if(label){const lbl=core.querySelector(".c-meter__label")||(()=>{const el=document.createElement("span");el.className="c-meter__label";core.appendChild(el);return el})();lbl.textContent=label}if(!this.hasAttribute("role"))this.setAttribute("role","meter");if(label&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label);const ariaValue=rValue===null?"0":rValue;const prevVal=this._meterAriaValue;if(!this.hasAttribute("aria-valuenow")||this.getAttribute("aria-valuenow")===prevVal){this.setAttribute("aria-valuenow",ariaValue);this._meterAriaValue=ariaValue}const min=this.getAttribute("min");const max=this.getAttribute("max");if(min!==null)this.setAttribute("aria-valuemin",min);else if(!this.hasAttribute("aria-valuemin"))this.setAttribute("aria-valuemin","0");if(max!==null)this.setAttribute("aria-valuemax",max);else if(!this.hasAttribute("aria-valuemax"))this.setAttribute("aria-valuemax","1");for(const a of["low","high","optimum"]){const v=this.getAttribute(a);if(v!==null)this.setAttribute("data-"+a,v);else this.removeAttribute("data-"+a)}}}define("contour-meter",ContourMeter);class ContourDelta extends ContourBase{static get observed(){return["value","direction","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{value:{attribute:"value"},direction:{attribute:"direction"},src:{attribute:"src"}}}render(){this.classList.add("c-delta");wireStates(this);loadRemote(this,"value");if(renderStates(this,"delta"))return;const value=remoteData(this,"value")||"";Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-delta--"))this.classList.remove(c)});const direction=this.getAttribute("direction")||(this._remoteData&&this._remoteData.direction)||"up";if(!value){renderEmpty(this,"delta");return}this.classList.add("c-delta--"+direction);const icon={up:"#i-arrow-up",down:"#i-arrow-down",flat:"#i-minus"}[direction]||"#i-arrow-up";this.querySelectorAll("svg").forEach((s)=>s.remove());const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href",icon);svg.appendChild(use);this.appendChild(svg);this.appendChild(document.createTextNode(" "+value))}}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"]}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(){this.classList.add("c-stat");wireStates(this);loadRemote(this,["value","label"]);if(renderStates(this,"stat"))return;const value=remoteData(this,"value");const label=remoteData(this,"label");const delta=this.getAttribute("delta");if(value){const v=this.ensure(".c-stat__value",()=>{const el=document.createElement("div");el.className="c-stat__value";el.setAttribute("aria-live","polite");return el});v.textContent=formatValue(value,this.getAttribute("format"),this.getAttribute("locale"),this.getAttribute("unit"))}else{const v=this.querySelector(".c-stat__value");if(v)v.remove()}if(label){const l=this.ensure(".c-stat__label",()=>{const el=document.createElement("div");el.className="c-stat__label";return el});l.textContent=label}else{const l=this.querySelector(".c-stat__label");if(l)l.remove()}if(delta){const d=this.ensure(".c-stat__delta",()=>{const el=document.createElement("div");el.className="c-stat__delta";return el});d.textContent=delta}else{const d=this.querySelector(".c-stat__delta");if(d)d.remove()}const unit=this.getAttribute("unit");const v=this.querySelector(".c-stat__value");if(v){if(unit){let u=v.querySelector(".c-stat__unit");if(!u){u=document.createElement("span");u.className="c-stat__unit";v.appendChild(u)}u.textContent=unit}else{const u=v.querySelector(".c-stat__unit");if(u)u.remove()}}if(!value&&!label){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"]}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(){this.classList.add("c-gauge");wireStates(this);loadRemote(this,["value"]);if(renderStates(this,"gauge"))return;const rawValue=this.getAttribute("value");const num=parseFloat(rawValue);const hasValue=rawValue!==null&&rawValue!==""&&Number.isFinite(num);const min=parseFloat(this.getAttribute("min")||"0");const max=parseFloat(this.getAttribute("max")||"100");const heading=this.getAttribute("heading");const showHeader=this.getAttribute("show-header")!=="false";const description=this.getAttribute("description");const noDataMessage=this.getAttribute("no-data-message")||"No readings in view";const brownoutLevel=this.brownoutLevel();if(!hasValue){if(heading&&showHeader){const t=this.ensure(".c-gauge__title",()=>{const el=document.createElement("div");el.className="c-gauge__title";return el});t.textContent=heading}const empty=this.ensure(".c-gauge__empty",()=>{const el=document.createElement("div");el.className="c-gauge__empty";el.setAttribute("part","empty");return el});empty.textContent=noDataMessage;[".c-gauge__dial",".c-gauge__value",".c-gauge__band"].forEach((sel)=>{const n=this.querySelector(sel);if(n)n.remove()});return}if(heading&&showHeader){const t=this.ensure(".c-gauge__title",()=>{const el=document.createElement("div");el.className="c-gauge__title";el.setAttribute("part","title");return el});t.textContent=heading}else{const t=this.querySelector(".c-gauge__title");if(t)t.remove()}let thresholds=[];const tAttr=this.getAttribute("thresholds");if(tAttr){try{thresholds=JSON.parse(tAttr)}catch(e){thresholds=[]}}let band=null;if(thresholds&&thresholds.length){const sorted=[...thresholds].sort((a,b)=>(a.value||0)-(b.value||0));for(let i=sorted.length-1;i>=0;i--){if(num>=(sorted[i].value||0)){band=sorted[i];break}}}const shedDial=this.shed("dial",3);let dial=this.querySelector(".c-gauge__dial");if(shedDial){if(dial)dial.remove()}else{if(!dial){dial=document.createElementNS("http://www.w3.org/2000/svg","svg");dial.setAttribute("class","c-gauge__dial");dial.setAttribute("part","dial");dial.setAttribute("aria-hidden","true");dial.setAttribute("viewBox","0 0 100 100");this.appendChild(dial)}dial.innerHTML="";const track=document.createElementNS("http://www.w3.org/2000/svg","path");track.setAttribute("class","c-gauge__track");track.setAttribute("d","M 10 90 A 40 40 0 0 1 90 90");dial.appendChild(track);if(thresholds&&thresholds.length){const sorted=[...thresholds].sort((a,b)=>(a.value||0)-(b.value||0));const toPoint=(v)=>{const pos=(1-(v-min)/(max-min||1))*Math.PI;return{x:50+40*Math.cos(pos),y:90-40*Math.sin(pos)}};for(let i=0;i<sorted.length;i++){const v1=sorted[i].value||0;const v2=(i+1<sorted.length)?(sorted[i+1].value||max):max;const p1=toPoint(v1);const p2=toPoint(v2);const z=document.createElementNS("http://www.w3.org/2000/svg","path");z.setAttribute("class","c-gauge__zone");z.setAttribute("stroke",sorted[i].color||"var(--color-primary)");z.setAttribute("d","M "+p1.x.toFixed(2)+" "+p1.y.toFixed(2)+" A 40 40 0 0 1 "+p2.x.toFixed(2)+" "+p2.y.toFixed(2));dial.appendChild(z)}}const ratio=(num-min)/(max-min||1);const angle=Math.PI*(1-ratio);const needle=document.createElementNS("http://www.w3.org/2000/svg","line");needle.setAttribute("class","c-gauge__needle needle");needle.setAttribute("x1","50");needle.setAttribute("y1","90");needle.setAttribute("x2",String(50+35*Math.cos(angle)));needle.setAttribute("y2",String(90-35*Math.sin(angle)));dial.appendChild(needle);const hub=document.createElementNS("http://www.w3.org/2000/svg","circle");hub.setAttribute("class","c-gauge__hub hub");hub.setAttribute("cx","50");hub.setAttribute("cy","90");hub.setAttribute("r","4");dial.appendChild(hub)}const valueEl=this.ensure(".c-gauge__value",()=>{const el=document.createElement("div");el.className="c-gauge__value";el.setAttribute("part","value");return el});valueEl.textContent=formatValue(String(num),this.getAttribute("format"),this.getAttribute("locale"))+(this.getAttribute("unit")?" "+this.getAttribute("unit"):"");valueEl.setAttribute("role","meter");valueEl.setAttribute("aria-valuenow",String(num));valueEl.setAttribute("aria-valuemin",String(min));valueEl.setAttribute("aria-valuemax",String(max));if(heading){if(!valueEl.id)valueEl.id=contourId("gauge-value")}if(band){valueEl.setAttribute("aria-valuetext",num+", "+(band.label||(">= "+band.value)))}else{valueEl.setAttribute("aria-valuetext",String(num))}const titleEl=this.querySelector(".c-gauge__title");if(titleEl){if(!titleEl.id)titleEl.id=contourId("gauge-title");valueEl.setAttribute("aria-labelledby",titleEl.id);valueEl.removeAttribute("aria-label")}else{valueEl.removeAttribute("aria-labelledby");if(heading)valueEl.setAttribute("aria-label",heading)}const bandEl=this.querySelector(".c-gauge__band");if(band){const b=this.ensure(".c-gauge__band",()=>{const el=document.createElement("div");el.className="c-gauge__band";el.setAttribute("part","band");return el});b.textContent=band.label||(">= "+band.value)}else{if(bandEl)bandEl.remove()}if(description){let d=this.querySelector(".c-gauge__desc");if(!d){d=document.createElement("div");d.className="c-gauge__desc";this.appendChild(d)}d.textContent=description}}enhance(){}}define("contour-gauge",ContourGauge);class ContourAxis extends ContourBase{static get observed(){return["orientation","values","ticks","format","locale","padding","min","max","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{orientation:{attribute:"orientation"},values:{attribute:"values"},ticks:{attribute:"ticks"},format:{attribute:"format"},locale:{attribute:"locale"},padding:{attribute:"padding"},min:{attribute:"min"},max:{attribute:"max"},src:{attribute:"src"}}}render(){this.classList.add("c-axis");this.setAttribute("role","img");this.setAttribute("aria-label","Axis");const orientation=this.getAttribute("orientation")||"horizontal";this.classList.toggle("c-axis--horizontal",orientation==="horizontal");this.classList.toggle("c-axis--vertical",orientation==="vertical");if(orientation==="horizontal")this.setAttribute("part","axis-x");else this.setAttribute("part","axis-y");wireStates(this);loadRemote(this,["values"]);if(renderStates(this,"axis"))return;let values=[];const vAttr=this.getAttribute("values");if(vAttr){try{values=JSON.parse(vAttr)}catch(e){values=vAttr.split(",").map((x)=>x.trim())}}const ticks=parseInt(this.getAttribute("ticks")||"0",10)||values.length;const authoredTicks=Array.from(this.querySelectorAll(":scope > .c-axis__tick"));if(authoredTicks.length){authoredTicks.forEach((tick)=>{const label=tick.querySelector(".c-axis__label");if(label&&!label.textContent)label.textContent=tick.textContent})}else{Array.from(this.querySelectorAll(".c-axis__tick")).forEach((n)=>n.remove());const list=values.length?values:Array.from({length:ticks},(_,i)=>i);list.forEach((v)=>{const tick=document.createElement("span");tick.className="c-axis__tick";const label=document.createElement("span");label.className="c-axis__label";label.textContent=formatValue(String(v),this.getAttribute("format"),this.getAttribute("locale"));tick.appendChild(label);this.appendChild(tick)})}}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"]}static get properties(){return{start:{attribute:"start"},end:{attribute:"end"},min:{attribute:"min"},max:{attribute:"max"},src:{attribute:"src"}}}render(){this.classList.add("c-brush");this.setAttribute("role","group");this.setAttribute("aria-label","Brush selection");wireStates(this);loadRemote(this,[]);if(renderStates(this,"brush"))return;let sel=this.querySelector(".c-brush__selection");if(!sel){sel=document.createElement("div");sel.className="c-brush__selection";this.appendChild(sel)}const start=parseFloat(this.getAttribute("start")||"0");const end=parseFloat(this.getAttribute("end")||"100");const min=parseFloat(this.getAttribute("min")||"0");const max=parseFloat(this.getAttribute("max")||"100");const range=max-min||1;const left=((start-min)/range)*100;const width=((end-start)/range)*100;sel.style.insetInlineStart=left+"%";sel.style.inlineSize=width+"%";["start","end"].forEach((h)=>{let handle=this.querySelector(".c-brush__handle--"+h);if(!handle){handle=document.createElement("div");handle.className="c-brush__handle c-brush__handle--"+h;this.appendChild(handle)}const val=h==="start"?start:end;handle.style.insetInlineStart=(((val-min)/range)*100)+"%"})}enhance(){if(this._wiredBrush)return;this._wiredBrush=true;let dragging=null;const min=()=>parseFloat(this.getAttribute("min")||"0");const max=()=>parseFloat(this.getAttribute("max")||"100");const toValue=(clientX)=>{const r=this.getBoundingClientRect();const ratio=Math.max(0,Math.min(1,(clientX-r.left)/(r.width||1)));return min()+ratio*(max()-min())};this.addEventListener("pointerdown",(e)=>{const handle=e.target&&e.target.classList&&e.target.classList.contains("c-brush__handle")?e.target:null;dragging=handle?(handle.classList.contains("c-brush__handle--start")?"start":"end"):"move";try{this.setPointerCapture(e.pointerId)}catch(err){}this.dispatchEvent(new CustomEvent("contour:brush-start",{bubbles:true,composed:true,detail:{value:this.getAttribute("start"),start:this.getAttribute("start"),end:this.getAttribute("end")}}))});this.addEventListener("pointermove",(e)=>{if(!dragging)return;const v=toValue(e.clientX);const mn=min(),mx=max(),range=mx-mn||1;const sel=this.querySelector(".c-brush__selection");let ns=parseFloat(this.getAttribute("start")||"0");let ne=parseFloat(this.getAttribute("end")||"100");if(dragging==="start"){ns=Math.min(v,ne)}else if(dragging==="end"){ne=Math.max(v,ns)}else{const width=ne-ns;ns=v-width/2;ne=v+width/2;if(ns<mn){ne+=mn-ns;ns=mn}if(ne>mx){ns-=ne-mx;ne=mx}}ns=Math.max(mn,Math.min(mx,ns));ne=Math.max(mn,Math.min(mx,ne));if(sel){sel.style.insetInlineStart=(((ns-mn)/range)*100)+"%";sel.style.inlineSize=(((ne-ns)/range)*100)+"%"}const sh=this.querySelector(".c-brush__handle--start");const eh=this.querySelector(".c-brush__handle--end");if(sh)sh.style.insetInlineStart=(((ns-mn)/range)*100)+"%";if(eh)eh.style.insetInlineStart=(((ne-mn)/range)*100)+"%";this._brushPending={start:ns,end:ne};this.dispatchEvent(new CustomEvent("contour:brush",{bubbles:true,composed:true,detail:{start:ns,end:ne,value:ns}}))});this.addEventListener("pointerup",(e)=>{if(!dragging)return;dragging=null;const p=this._brushPending;if(p){this.setAttribute("start",String(p.start));this.setAttribute("end",String(p.end));this._brushPending=null}this.dispatchEvent(new CustomEvent("contour:brush-end",{bubbles:true,composed:true,detail:{value:this.getAttribute("end"),start:this.getAttribute("start"),end:this.getAttribute("end")}}));this.dispatchEvent(new CustomEvent("contour:brush",{bubbles:true,composed:true,detail:{start:this.getAttribute("start"),end:this.getAttribute("end"),value:this.getAttribute("end")}}))});if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:brush-start",{bubbles:true,composed:true,detail:{value:this.getAttribute("start"),start:this.getAttribute("start"),end:this.getAttribute("end")}}))}})}}define("contour-brush",ContourBrush);class ContourStackedBar extends ContourBase{static get observed(){return["segments","values","colors","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","normalize"]}static get properties(){return{segments:{attribute:"segments"},values:{attribute:"values"},colors:{attribute:"colors"},src:{attribute:"src"},normalize:{attribute:"normalize"}}}render(){this.classList.add("c-stacked-bar");this.setAttribute("role","img");this.setAttribute("aria-label","Stacked bar");wireStates(this);loadRemote(this,["segments","values"]);if(renderStates(this,"stacked-bar"))return;Array.from(this.querySelectorAll(".c-stacked-bar__segment")).forEach((n)=>n.remove());const authoredSegments=Array.from(this.querySelectorAll(":scope > .c-stacked-bar__segment"));let segments=[];if(authoredSegments.length){segments=authoredSegments.map((el)=>({label:el.getAttribute("title")||el.textContent||"",value:parseFloat(el.style.inlineSize)||0,color:(el.dataset&&el.dataset.color)||el.style.background||undefined,}));authoredSegments.forEach((el)=>el.remove())}else{const sAttr=this.getAttribute("segments");if(sAttr){try{segments=JSON.parse(sAttr)}catch(e){segments=[]}}}const values=segments.map((seg)=>(typeof seg==="object"?(seg.value||0):Number(seg)||0));const total=values.reduce((a,b)=>a+b,0)||1;const normalize=this.hasAttribute("normalize");const denom=normalize?total:(parseFloat(this.getAttribute("max")||String(total))||total);segments.forEach((seg,i)=>{const v=values[i];const el=document.createElement("div");el.className="c-stacked-bar__segment";el.style.inlineSize=((v/denom)*100)+"%";el.style.background=(typeof seg==="object"&&seg.color)?seg.color:"var(--chart-"+((i%8)+1)+")";el.dataset.color=(typeof seg==="object"&&seg.color)?seg.color:el.style.background;el.setAttribute("title",(typeof seg==="object"?(seg.label||""):"")+" "+v);this.appendChild(el)});if(!segments.length)renderEmpty(this,"stacked-bar")}enhance(){}}define("contour-stacked-bar",ContourStackedBar);class ContourCategory extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","search","note","limit","sort"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"},search:{attribute:"search"},note:{attribute:"note"},limit:{attribute:"limit"},sort:{attribute:"sort"}}}render(){this.classList.add("c-category");this.setAttribute("role","listbox");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Category");wireStates(this);loadRemote(this,["items"]);if(renderStates(this,"category"))return;Array.from(this.querySelectorAll(".c-category__item")).forEach((n)=>n.remove());const authoredItems=Array.from(this.querySelectorAll(":scope > .c-category__item"));let items=[];if(authoredItems.length){authoredItems.forEach((el)=>{const lbl=el.querySelector(".c-category__label");items.push({label:lbl?lbl.textContent:el.textContent,value:0})});authoredItems.forEach((el)=>el.remove())}else{const iAttr=this.getAttribute("items");if(iAttr){try{items=JSON.parse(iAttr)}catch(e){items=[]}}}const sort=this.getAttribute("sort")||"value-desc";items.sort((a,b)=>{const va=(typeof a==="object")?(a.value||0):(Number(a)||0);const vb=(typeof b==="object")?(b.value||0):(Number(b)||0);const la=(typeof a==="object")?(a.label||a.name||""):String(a);const lb=(typeof b==="object")?(b.label||b.name||""):String(b);if(sort==="value-asc")return va-vb;if(sort==="alpha-asc")return String(la).localeCompare(String(lb));if(sort==="alpha-desc")return String(lb).localeCompare(String(la));return vb-va});const limit=parseInt(this.getAttribute("limit")||"0",10);if(limit>0)items=items.slice(0,limit);const max=items.reduce((m,it)=>Math.max(m,(typeof it==="object"?(it.value||0):Number(it)||0)),0)||1;items.forEach((it,idx)=>{const value=(typeof it==="object")?(it.value||0):(Number(it)||0);const label=(typeof it==="object")?(it.label||it.name||""):String(it);const item=document.createElement("div");item.className="c-category__item";item.setAttribute("role","option");item.setAttribute("aria-selected","false");item.setAttribute("tabindex",idx===0?"0":"-1");const lbl=document.createElement("span");lbl.className="c-category__label";lbl.textContent=label;const barWrap=document.createElement("div");barWrap.style.flex="1";const bar=document.createElement("div");bar.className="c-category__bar";bar.style.inlineSize=((value/max)*100)+"%";barWrap.appendChild(bar);const val=document.createElement("span");val.className="c-category__value";val.textContent=String(value);item.appendChild(lbl);item.appendChild(barWrap);item.appendChild(val);this.appendChild(item)});if(!items.length)renderEmpty(this,"category");const note=this.getAttribute("note");let noteEl=this.querySelector(".c-category__note");if(note){if(!noteEl){noteEl=document.createElement("div");noteEl.className="c-category__note";this.appendChild(noteEl)}noteEl.textContent=note}else if(noteEl){noteEl.remove()}}enhance(){if(this._wiredCategory)return;this._wiredCategory=true;const items=()=>Array.from(this.querySelectorAll(".c-category__item"));const showTip=(e)=>{};this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-category__item"):null;if(!item||!this.contains(item))return;const all=items();const idx=all.indexOf(item);all.forEach((o,i)=>o.setAttribute("aria-selected",i===idx?"true":"false"));this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx,label:item.querySelector(".c-category__label")?item.querySelector(".c-category__label").textContent:item.textContent.trim()}}))});this.addEventListener("keydown",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-category__item"):null;if(!item||!this.contains(item))return;const all=items();const idx=all.indexOf(item);if(e.key==="Enter"||e.key===" "){e.preventDefault();all.forEach((o,i)=>o.setAttribute("aria-selected",i===idx?"true":"false"));this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx,label:item.querySelector(".c-category__label")?item.querySelector(".c-category__label").textContent:item.textContent.trim()}}));return}let next=-1;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";if(e.key==="ArrowDown")next=Math.min(idx+1,all.length-1);else if(e.key==="ArrowUp")next=Math.max(idx-1,0);else if(e.key==="ArrowRight")next=rtl?Math.max(idx-1,0):Math.min(idx+1,all.length-1);else if(e.key==="ArrowLeft")next=rtl?Math.min(idx+1,all.length-1):Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=all.length-1;if(next<0||next===idx)return;e.preventDefault();all.forEach((c,i)=>c.setAttribute("tabindex",i===next?"0":"-1"));try{all[next].focus()}catch(err){}})}}define("contour-category",ContourCategory);class ContourDonut extends ContourBase{static get observed(){return["value","values","items","label","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","brownout","brownout-level","note"]}static get properties(){return{value:{attribute:"value"},values:{attribute:"values"},items:{attribute:"items"},label:{attribute:"label"},src:{attribute:"src"},note:{attribute:"note"}}}render(){this.classList.add("c-donut");this.setAttribute("role","img");this.setAttribute("aria-label","Donut chart");wireStates(this);loadRemote(this,["items","values"]);if(renderStates(this,"donut"))return;Array.from(this.querySelectorAll(".c-donut__ring, .c-donut__center, .c-donut__list, .c-donut__empty")).forEach((n)=>n.remove());const authoredItems=Array.from(this.querySelectorAll(":scope > .c-donut__item"));let items=[];if(authoredItems.length){authoredItems.forEach((el)=>{const sw=el.querySelector(".c-donut__swatch");const lbl=el.querySelector("span:last-child");const text=lbl?lbl.textContent:el.textContent;const match=text.match(/—\s*(\d+(?:\.\d+)?)$/);items.push({label:text.replace(/—\s*\d+(?:\.\d+)?$/,"").trim(),value:match?Number(match[1]):0,color:sw?(sw.dataset&&sw.dataset.color)||sw.style.background:undefined})});authoredItems.forEach((el)=>el.remove())}else{const iAttr=this.getAttribute("items");if(iAttr){try{items=JSON.parse(iAttr)}catch(e){items=[]}}}const values=items.map((it)=>(typeof it==="object"?(it.value||0):Number(it)||0));const total=values.reduce((a,b)=>a+b,0)||1;const brownoutLevel=this.brownoutLevel();const shedRing=this.shed("ring",3);if(!shedRing){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("class","c-donut__ring");svg.setAttribute("viewBox","0 0 32 32");let offset=0;items.forEach((it,i)=>{const v=values[i];const pct=v/total;const circle=document.createElementNS("http://www.w3.org/2000/svg","circle");circle.setAttribute("cx","16");circle.setAttribute("cy","16");circle.setAttribute("r","12");circle.setAttribute("fill","none");circle.setAttribute("stroke",(typeof it==="object"&&it.color)?it.color:"var(--chart-"+((i%8)+1)+")");circle.setAttribute("stroke-width","6");const circ=2*Math.PI*12;circle.setAttribute("stroke-dasharray",(pct*circ)+" "+(circ-pct*circ));circle.setAttribute("stroke-dashoffset",String(-offset*circ));circle.setAttribute("transform","rotate(-90 16 16)");svg.appendChild(circle);offset+=pct});const hole=document.createElementNS("http://www.w3.org/2000/svg","circle");hole.setAttribute("cx","16");hole.setAttribute("cy","16");hole.setAttribute("r","9");hole.setAttribute("fill","var(--color-surface-0)");svg.appendChild(hole);this.appendChild(svg)}const center=document.createElement("div");center.className="c-donut__center";center.textContent=this.getAttribute("value")||String(total);this.appendChild(center);const list=document.createElement("div");list.className="c-donut__list";list.setAttribute("role","list");items.forEach((it,i)=>{const row=document.createElement("div");row.className="c-donut__item";row.setAttribute("role","listitem");const sw=document.createElement("span");sw.className="c-donut__swatch";sw.style.background=(typeof it==="object"&&it.color)?it.color:"var(--chart-"+((i%8)+1)+")";if(sw.style.background)sw.dataset.color=(typeof it==="object"&&it.color)?it.color:sw.style.background;row.appendChild(sw);const lbl=document.createElement("span");lbl.textContent=(typeof it==="object"?(it.label||""):String(it))+" — "+values[i];row.appendChild(lbl);list.appendChild(row)});this.appendChild(list);if(!items.length)renderEmpty(this,"donut");const note=this.getAttribute("note");let noteEl=this.querySelector(".c-donut__note");if(note){if(!noteEl){noteEl=document.createElement("div");noteEl.className="c-donut__note";this.appendChild(noteEl)}noteEl.textContent=note}else if(noteEl){noteEl.remove()}}enhance(){}}define("contour-donut",ContourDonut);class ContourTimeSeries extends ContourBase{static get observed(){return["values","points","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","annotations","note","style"]}static get properties(){return{values:{attribute:"values"},points:{attribute:"points"},src:{attribute:"src"},annotations:{attribute:"annotations"},note:{attribute:"note"},style:{attribute:"style"}}}render(){this.classList.add("c-time-series");this.setAttribute("role","img");this.setAttribute("aria-label","Time series");wireStates(this);loadRemote(this,["values","points"]);if(renderStates(this,"time-series"))return;Array.from(this.querySelectorAll(".c-time-series__plot, .c-time-series__axis")).forEach((n)=>n.remove());let values=[];const vAttr=this.getAttribute("values");if(vAttr){try{values=JSON.parse(vAttr)}catch(e){values=vAttr.split(",").map(Number)}}const max=Math.max(...values,1);const min=Math.min(...values,0);const style=this.getAttribute("style")||"bar";const plot=document.createElement("div");plot.className="c-time-series__plot";plot.setAttribute("part","plot");if(style==="line"){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const range=(max-min)||1;const n=values.length||1;const pts=values.map((v,i)=>{const x=(i/Math.max(1,n-1))*300;const y=120-((v-min)/range)*120;return x.toFixed(2)+","+y.toFixed(2)}).join(" ");const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-time-series__line");path.setAttribute("d","M "+pts.replace(/ /g," L "));path.style.stroke="var(--chart-1)";path.style.fill="none";path.style.strokeWidth="2";svg.appendChild(path);values.forEach((v,i)=>{const x=(i/Math.max(1,n-1))*300;const y=120-((v-min)/range)*120;const c=document.createElementNS("http://www.w3.org/2000/svg","circle");c.setAttribute("class","c-time-series__point");c.setAttribute("cx",x.toFixed(2));c.setAttribute("cy",y.toFixed(2));c.setAttribute("r","3");c.setAttribute("tabindex",i===0?"0":"-1");c.setAttribute("role","button");c.setAttribute("title",String(v));c.setAttribute("aria-label","Value "+v);svg.appendChild(c)});plot.appendChild(svg)}else{values.forEach((v,i)=>{const bar=document.createElement("div");bar.className="c-time-series__bar";bar.style.blockSize=((v/max)*100)+"%";bar.setAttribute("title",String(v));bar.setAttribute("role","img");bar.setAttribute("aria-label","Value "+v);bar.setAttribute("tabindex",i===0?"0":"-1");plot.appendChild(bar)})}this.appendChild(plot);if(!values.length)renderEmpty(this,"time-series");const note=this.getAttribute("note");let noteEl=this.querySelector(".c-time-series__note");if(note){if(!noteEl){noteEl=document.createElement("div");noteEl.className="c-time-series__note";this.appendChild(noteEl)}noteEl.textContent=note}else if(noteEl){noteEl.remove()}}enhance(){if(this._wiredTimeSeries)return;this._wiredTimeSeries=true;const bars=()=>Array.from(this.querySelectorAll(".c-time-series__bar"));this.addEventListener("click",(e)=>{const bar=e.target&&e.target.closest?e.target.closest(".c-time-series__bar"):null;if(!bar||!this.contains(bar))return;const idx=bars().indexOf(bar);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx,value:bar.getAttribute("title")}}))});this.addEventListener("keydown",(e)=>{const bar=e.target&&e.target.closest?e.target.closest(".c-time-series__bar"):null;if(!bar||!this.contains(bar))return;const all=bars();const idx=all.indexOf(bar);if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx,value:bar.getAttribute("title")}}));return}let next=-1;if(e.key==="ArrowRight"||e.key==="ArrowDown")next=Math.min(idx+1,all.length-1);else if(e.key==="ArrowLeft"||e.key==="ArrowUp")next=Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=all.length-1;if(next<0||next===idx)return;e.preventDefault();all.forEach((b,i)=>b.setAttribute("tabindex",i===next?"0":"-1"));try{all[next].focus()}catch(err){}});this.addEventListener("focusin",(e)=>{const bar=e.target&&e.target.closest?e.target.closest(".c-time-series__bar"):null;if(bar&&this.contains(bar)){const tip=this.querySelector(".c-time-series__tooltip");if(tip){tip.textContent=bar.getAttribute("title");tip.removeAttribute("hidden")}}});this.addEventListener("focusout",(e)=>{const tip=this.querySelector(".c-time-series__tooltip");if(tip&&!this.contains(e.relatedTarget))tip.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"]}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(name){const n=(name||"sum").toLowerCase();if(n==="avg"||n==="average"||n==="mean")return(vals)=>vals.length?vals.reduce((a,b)=>a+b,0)/vals.length:0;if(n==="count")return(vals)=>vals.length;if(n==="min")return(vals)=>vals.length?Math.min(...vals):0;if(n==="max")return(vals)=>vals.length?Math.max(...vals):0;return(vals)=>vals.reduce((a,b)=>a+b,0)}render(){this.classList.add("c-pivot");wireStates(this);loadRemote(this,["data"]);if(renderStates(this,"pivot"))return;Array.from(this.querySelectorAll("table, .c-pivot__toolbar")).forEach((n)=>n.remove());let data=[];const dAttr=this.getAttribute("data");if(dAttr){try{data=JSON.parse(dAttr)}catch(e){data=[]}}const rows=this.getAttribute("rows")?this.getAttribute("rows").split(",").map((s)=>s.trim()).filter(Boolean):[];const cols=this.getAttribute("columns")?this.getAttribute("columns").split(",").map((s)=>s.trim()).filter(Boolean):[];const aggName=this.getAttribute("aggregate")||"sum";const aggFn=this._aggregateFn(aggName);const filterQ=(this.getAttribute("filter")||"").toLowerCase().trim();const toolbar=document.createElement("div");toolbar.className="c-pivot__toolbar";toolbar.style.display="flex";const filterInput=document.createElement("input");filterInput.type="search";filterInput.className="c-input c-pivot__filter";filterInput.placeholder="Filter…";filterInput.value=this.getAttribute("filter")||"";filterInput.setAttribute("aria-label","Filter pivot");const aggSelect=document.createElement("select");aggSelect.className="c-select c-pivot__aggregate";aggSelect.setAttribute("aria-label","Aggregation");["sum","avg","count","min","max"].forEach((a)=>{const opt=document.createElement("option");opt.value=a;opt.textContent=a;if(a===aggName)opt.selected=true;aggSelect.appendChild(opt)});toolbar.appendChild(filterInput);toolbar.appendChild(aggSelect);this.appendChild(toolbar);let visibleRows=rows;let visibleCols=cols;if(filterQ){visibleRows=rows.filter((r)=>r.toLowerCase().includes(filterQ)||data.some((d)=>d.row===r&&String(d.value).toLowerCase().includes(filterQ)));visibleCols=cols.filter((c)=>c.toLowerCase().includes(filterQ)||data.some((d)=>d.col===c&&String(d.value).toLowerCase().includes(filterQ)));if(!visibleRows.length)visibleRows=rows;if(!visibleCols.length)visibleCols=cols}const table=document.createElement("table");table.setAttribute("role","grid");table.setAttribute("aria-rowcount",String(visibleRows.length+1));table.setAttribute("aria-colcount",String(visibleCols.length+1));const thead=document.createElement("thead");const hr=document.createElement("tr");const corner=document.createElement("th");corner.textContent="";corner.setAttribute("role","columnheader");corner.setAttribute("aria-label","Row");hr.appendChild(corner);visibleCols.forEach((c)=>{const th=document.createElement("th");th.textContent=c;th.setAttribute("role","columnheader");th.setAttribute("tabindex","0");hr.appendChild(th)});thead.appendChild(hr);table.appendChild(thead);const tbody=document.createElement("tbody");visibleRows.forEach((r)=>{const tr=document.createElement("tr");tr.setAttribute("role","row");const th=document.createElement("th");th.textContent=r;th.setAttribute("role","rowheader");th.setAttribute("tabindex","0");tr.appendChild(th);visibleCols.forEach((c)=>{const td=document.createElement("td");td.setAttribute("role","gridcell");td.setAttribute("tabindex","0");const cellData=data.filter((d)=>d.row===r&&d.col===c);const vals=cellData.map((d)=>Number(d.value)).filter((n)=>Number.isFinite(n));if(cellData.length&&vals.length===cellData.length&&vals.length){const v=aggFn(vals);td.textContent=Number.isInteger(v)?String(v):v.toFixed(2)}else if(cellData.length){td.textContent=cellData.map((d)=>d.value).join(", ")}else{td.textContent=""}if(!td.textContent.trim())td.setAttribute("aria-label","Empty");tr.appendChild(td)});tbody.appendChild(tr)});table.appendChild(tbody);this.appendChild(table);if(!data.length&&!rows.length&&!cols.length)renderEmpty(this,"pivot")}enhance(){if(this._wiredPivot)return;this._wiredPivot=true;this.addEventListener("click",(e)=>{const th=e.target&&e.target.closest?e.target.closest("th"):null;const td=e.target&&e.target.closest?e.target.closest("td"):null;const filterInput=e.target&&e.target.closest?e.target.closest(".c-pivot__filter"):null;const aggSelect=e.target&&e.target.closest?e.target.closest(".c-pivot__aggregate"):null;if(filterInput)return;if(aggSelect)return;if(th&&this.contains(th)&&th.parentElement&&th.parentElement.parentElement&&th.parentElement.parentElement.tagName==="THEAD"){this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:true,composed:true,detail:{column:th.textContent.trim()}}));return}if(td&&this.contains(td)){this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:td.textContent}}))}});this.addEventListener("input",(e)=>{const fi=e.target&&e.target.closest?e.target.closest(".c-pivot__filter"):null;if(fi&&this.contains(fi)){this.setAttribute("filter",fi.value);this.render();this.dispatchEvent(new CustomEvent("contour:filter",{bubbles:true,composed:true,detail:{query:fi.value}}))}});this.addEventListener("change",(e)=>{const as=e.target&&e.target.closest?e.target.closest(".c-pivot__aggregate"):null;if(as&&this.contains(as)){this.setAttribute("aggregate",as.value);this.render();this.dispatchEvent(new CustomEvent("contour:aggregate",{bubbles:true,composed:true,detail:{aggregate:as.value}}))}});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest("th, td"):null;if(!cell||!this.contains(cell))return;const table=this.querySelector("table");if(!table)return;const rows=Array.from(table.querySelectorAll("tr"));const ri=rows.indexOf(cell.parentElement);const ci=Array.from(cell.parentElement.children).indexOf(cell);let target=null;if(e.key==="ArrowRight")target=cell.parentElement.children[ci+1];else if(e.key==="ArrowLeft")target=cell.parentElement.children[ci-1];else if(e.key==="ArrowDown")target=rows[ri+1]&&rows[ri+1].children[ci];else if(e.key==="ArrowUp")target=rows[ri-1]&&rows[ri-1].children[ci];else if(e.key==="Home")target=cell.parentElement.children[0];else if(e.key==="End")target=cell.parentElement.children[cell.parentElement.children.length-1];if(target){e.preventDefault();try{target.focus()}catch(err){}}})}}define("contour-pivot",ContourPivot);class ContourWidgetState extends ContourBase{static get observed(){return["loading","error","empty","retry","src","lazy","refresh","timeout","skeleton"]}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,[]);if(renderStates(this,"widget-state"))return}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 level=this.getAttribute("level")||"0";this.dataset.level=level;this.setAttribute("data-level",level)}enhance(){}}define("contour-brownout",ContourBrownout);class ContourInstrument extends ContourBase{static get observed(){return["rows","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{rows:{attribute:"rows"},src:{attribute:"src"}}}render(){this.classList.add("c-instrument");wireStates(this);loadRemote(this,"rows");if(renderStates(this,"instrument"))return;const rows=remoteData(this,"rows");Array.from(this.querySelectorAll(".c-instrument__item")).forEach((n)=>n.remove());if(rows){try{const parsed=JSON.parse(rows);parsed.forEach((r)=>{const item=document.createElement("span");item.className="c-instrument__item";item.appendChild(document.createTextNode(String(r.key||r[0]||"")));const val=document.createElement("span");val.className="c-instrument__value";val.textContent=r.value||r[1]||"";item.appendChild(val);this.appendChild(item)})}catch(e){}}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"}}}render(){this.classList.add("c-bivariate");this.setAttribute("role","group");this.setAttribute("aria-label","Bivariate legend");const size=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3));const matrix=this.ensure(".c-bivariate__matrix",()=>{const el=document.createElement("div");el.className="c-bivariate__matrix";return el});matrix.style.gridTemplateColumns=`repeat(${size}, 1fr)`;matrix.style.gridTemplateRows=`repeat(${size}, 1fr)`;const authored=Array.from(matrix.children).filter((n)=>n.classList&&n.classList.contains("c-bivariate__cell"));if(!authored.length){matrix.innerHTML="";let colors=[];const cAttr=this.getAttribute("colors");if(cAttr){try{colors=JSON.parse(cAttr)}catch(e){colors=[]}}for(let r=0;r<size;r++){for(let c=0;c<size;c++){const cell=document.createElement("div");cell.className="c-bivariate__cell";cell.setAttribute("role","button");cell.setAttribute("tabindex","0");cell.setAttribute("aria-label","Cell "+c+","+r);const srcIndex=(size-1-r)*size+c;if(colors[srcIndex]){cell.style.background=colors[srcIndex];cell.dataset.color=colors[srcIndex]}matrix.appendChild(cell)}}const sel=this.getAttribute("selected");if(sel){const parts=sel.split(",");const sr=parseInt(parts[0],10);const sc=parseInt(parts[1],10);const cells=Array.from(matrix.querySelectorAll(".c-bivariate__cell"));cells.forEach((cell,i)=>{const rr=Math.floor(i/size);const cc=i%size;if(rr===sr&&cc===sc)cell.setAttribute("data-selected","");else cell.removeAttribute("data-selected")})}let live=this.querySelector(".c-bivariate__live");if(!live){live=document.createElement("div");live.className="c-bivariate__live";live.setAttribute("aria-live","polite");live.style.position="absolute";live.style.width="1px";live.style.height="1px";live.style.overflow="hidden";live.style.clip="rect(0,0,0,0)";this.appendChild(live)}}const axisX=this.getAttribute("axis-x");if(axisX){const ax=this.ensure(".c-bivariate__axis--x",()=>{const el=document.createElement("div");el.className="c-bivariate__axis c-bivariate__axis--x";return el});ax.textContent=axisX}else{const ax=this.querySelector(".c-bivariate__axis--x");if(ax)ax.remove()}const axisY=this.getAttribute("axis-y");if(axisY){const ay=this.ensure(".c-bivariate__axis--y",()=>{const el=document.createElement("div");el.className="c-bivariate__axis c-bivariate__axis--y";return el});ay.textContent=axisY}else{const ay=this.querySelector(".c-bivariate__axis--y");if(ay)ay.remove()}}enhance(){if(this._wiredBivariate)return;this._wiredBivariate=true;const selectCell=(cell)=>{const matrix=this.querySelector(".c-bivariate__matrix");const cells=Array.from(matrix?matrix.querySelectorAll(".c-bivariate__cell"):[]);const idx=cells.indexOf(cell);if(idx<0)return;const size=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3));const row=Math.floor(idx/size);const col=idx%size;cells.forEach((cell,i)=>{const rr=Math.floor(i/size);const cc=i%size;if(rr===row&&cc===col)cell.setAttribute("data-selected","");else cell.removeAttribute("data-selected")});this.dispatchEvent(new CustomEvent("contour:select",{detail:{row,col},bubbles:true,composed:true}))};this.addEventListener("click",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-bivariate__cell"):null;if(cell&&this.contains(cell))selectCell(cell)});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-bivariate__cell"):null;if(!cell||!this.contains(cell))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();selectCell(cell)}})}clear(){this.removeAttribute("selected");this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:true,composed:true}))}}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"}}}render(){super.render();this.classList.add("c-bivariate-legend")}enhance(){if(this._wiredBivLegend)return;this._wiredBivLegend=true;const selectCell=(cell)=>{const matrix=this.querySelector(".c-bivariate__matrix");const cells=Array.from(matrix?matrix.querySelectorAll(".c-bivariate__cell"):[]);const idx=cells.indexOf(cell);if(idx<0)return;const size=Math.min(8,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3));const row=Math.floor(idx/size);const col=idx%size;cells.forEach((cell,i)=>{const rr=Math.floor(i/size);const cc=i%size;if(rr===row&&cc===col)cell.setAttribute("data-selected","");else cell.removeAttribute("data-selected")});this.dispatchEvent(new CustomEvent("contour:select",{detail:{row,col},bubbles:true,composed:true}))};this.addEventListener("click",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-bivariate__cell"):null;if(cell&&this.contains(cell))selectCell(cell)});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-bivariate__cell"):null;if(!cell||!this.contains(cell))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();selectCell(cell)}})}clear(){this.removeAttribute("selected");this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:true,composed:true}))}}define("contour-bivariate-legend",ContourBivariateLegend);class ContourSurvey extends ContourBase{static get observed(){return["date","instrument","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{date:{attribute:"date"},instrument:{attribute:"instrument"},src:{attribute:"src"}}}render(){this.classList.add("c-survey");wireStates(this);loadRemote(this,"date");if(renderStates(this,"survey"))return;const date=remoteData(this,"date");Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===Node.TEXT_NODE){if(n.textContent.trim()==="Surveyed"||n.textContent.trim()==="·")n.remove()}else if(n.classList&&(n.classList.contains("c-survey__value")||n.classList.contains("c-survey__sep")))n.remove()});const rDate=date||(this._remoteData&&this._remoteData.date);const instrument=this.getAttribute("instrument")||(this._remoteData&&this._remoteData.instrument);if(!rDate){renderEmpty(this,"survey");return}const v=document.createElement("span");v.className="c-survey__value";v.textContent=rDate;this.appendChild(document.createTextNode("Surveyed "));this.appendChild(v);if(instrument){const sep=document.createElement("span");sep.className="c-survey__sep";sep.textContent="·";this.appendChild(sep);const v2=document.createElement("span");v2.className="c-survey__value";v2.textContent=instrument;this.appendChild(v2)}}}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"]}static get properties(){return{label:{attribute:"label"},norm:{attribute:"norm"},state:{attribute:"state"},value:{attribute:"value"},src:{attribute:"src"}}}render(){this.classList.add("c-threshold");wireStates(this);loadRemote(this,"value");if(renderStates(this,"threshold"))return;const pct=(v)=>{const n=Number(v);if(!Number.isFinite(n))return String(v);return(n<=1?n*100:n)+"%"};const rValue=remoteData(this,"value")||(this._remoteData&&this._remoteData.value);const target=this.getAttribute("norm")||(this._remoteData&&this._remoteData.norm);const state=this.getAttribute("state")||(this._remoteData&&this._remoteData.state);const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(!rValue&&!target&&!label){renderEmpty(this,"threshold");return}if(rValue){const v=this.ensure(".c-threshold__fill",()=>{const el=document.createElement("span");el.className="c-threshold__fill";return el});v.style.setProperty("--value",pct(rValue))}else{const v=this.querySelector(".c-threshold__fill");if(v)v.remove()}if(target){const t=this.ensure(".c-threshold__target",()=>{const el=document.createElement("span");el.className="c-threshold__target";return el});t.style.setProperty("--target",pct(target))}else{const t=this.querySelector(".c-threshold__target");if(t)t.remove()}if(state)this.setAttribute("data-state",state);else this.removeAttribute("data-state");if(label)this.setAttribute("aria-label",label)}}define("contour-threshold",ContourThreshold);class ContourMetricsFull extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-metrics");this.setAttribute("role","list");wireStates(this);loadRemote(this,"items");if(renderStates(this,"metrics"))return;const items=remoteData(this,"items");Array.from(this.querySelectorAll(".c-metrics__item")).forEach((n)=>n.remove());let parsed=null;if(items){try{parsed=JSON.parse(items)}catch(e){parsed=null}}if(Array.isArray(parsed)&&parsed.length){parsed.forEach((it)=>{const item=document.createElement("div");item.className="c-metrics__item";item.setAttribute("role","listitem");const v=document.createElement("div");v.className="c-metrics__value";v.textContent=(typeof it==="object"&&it!==null)?(it.value??it.v??""):String(it);const l=document.createElement("div");l.className="c-metrics__label";l.textContent=(typeof it==="object"&&it!==null)?(it.label??it.l??""):"";item.appendChild(v);item.appendChild(l);this.appendChild(item)})}else if(!items){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","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","glyphs","thresholds","breaks","no-data-color","size","table","classification","audit","continuous","ends","caption"]}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"}}}render(){this.classList.add("c-legend");const continuous=this.hasAttribute("continuous");if(continuous||this.hasAttribute("selectable")){this.setAttribute("role","group")}else{this.setAttribute("role","list")}wireStates(this);loadRemote(this,"items");if(renderStates(this,"legend"))return;const selectable=this.hasAttribute("selectable");const authoredLegendItems=Array.from(this.querySelectorAll(":scope > .c-legend__item"));let items=remoteData(this,"items");if(authoredLegendItems.length){items=JSON.stringify(authoredLegendItems.map((el)=>{const sw=el.querySelector(".c-legend__swatch");const lbl=el.querySelector(".c-legend__label")||el;return{label:lbl?lbl.textContent.trim():el.textContent.trim(),color:sw?(sw.dataset&&sw.dataset.color)||sw.style.background||undefined:undefined}}));authoredLegendItems.forEach((el)=>el.remove())}const title=this.getAttribute("title");if(title){const t=this.ensure(".c-legend__title",()=>{const el=document.createElement("div");el.className="c-legend__title";return el});t.textContent=title}else{const t=this.querySelector(".c-legend__title");if(t)t.remove()}if(items){try{const parsed=JSON.parse(items);const list=this.ensure(".c-legend__items",()=>{const el=document.createElement("div");el.className="c-legend__items";return el});if(this.hasAttribute("selectable")){list.setAttribute("role","group")}else{list.setAttribute("role","listbox")}if(title)list.setAttribute("aria-label",title);list.innerHTML="";parsed.forEach((it)=>{const label=typeof it==="string"?it:(it.label||String(it));const key=typeof it==="string"?it:(it.key||it.label||String(it));const item=document.createElement("div");item.className="c-legend__item";item.setAttribute("tabindex","-1");if(selectable){item.setAttribute("role","button");item.setAttribute("aria-pressed","true");item.dataset.key=key}else{item.setAttribute("role","option");item.setAttribute("aria-selected","false")}const sw=document.createElement("span");sw.className="c-legend__swatch";if(it&&it.color){sw.style.background=it.color;sw.dataset.color=it.color}item.appendChild(sw);const glyphShape=(it&&(it.shape||it.marker||it.glyph))||this.getAttribute("glyphs");if(glyphShape){const g=document.createElement("span");g.className="c-legend__glyph";g.setAttribute("part","glyph");g.textContent=glyphShape==="circle"?"●":glyphShape==="square"?"■":glyphShape==="triangle"?"▲":glyphShape==="diamond"?"◆":glyphShape==="star"?"★":String(glyphShape);if(it&&it.size!=null)g.style.fontSize=(typeof it.size==="number"?it.size+"px":String(it.size));item.appendChild(g)}if(it&&it.break!=null){const b=document.createElement("span");b.className="c-legend__break";b.textContent=String(it.break);item.appendChild(b)}const lbl=document.createElement("span");lbl.textContent=label;item.appendChild(lbl);const caption=(typeof it==="object"&&it)?(it.caption||it.note||""):"";if(caption){const cap=document.createElement("span");cap.className="c-legend__caption";cap.textContent=caption;item.appendChild(cap)}if(it&&(it.threshold||it.break!=null)){sw.style.outline="2px solid var(--color-border-strong)"}list.appendChild(item)})}catch(e){}}else{const list=this.querySelector(".c-legend__items");if(list)list.remove();const hasOther=this.getAttribute("title")||this.getAttribute("ramp")||this.getAttribute("scale")||this.getAttribute("method")||this.getAttribute("norm");if(!hasOther){renderEmpty(this,"legend")}}const caption=this.getAttribute("caption");let captionEl=this.querySelector(".c-legend__caption");if(caption){if(!captionEl){captionEl=document.createElement("span");captionEl.className="c-legend__caption";this.appendChild(captionEl)}captionEl.id=captionEl.id||("legend-caption-"+Math.random().toString(36).slice(2));captionEl.textContent=caption;captionEl.style.position="absolute";captionEl.style.width="1px";captionEl.style.height="1px";captionEl.style.overflow="hidden";captionEl.style.clip="rect(0,0,0,0)"}else if(captionEl){captionEl.remove()}const _items=this.querySelector(".c-legend__items");if(_items){const opts=Array.from(_items.querySelectorAll(".c-legend__item"));opts.forEach((o,i)=>o.setAttribute("tabindex",i===0?"0":"-1"));if(captionEl)opts.forEach((o)=>o.setAttribute("aria-describedby",captionEl.id))}const ndColor=this.getAttribute("no-data-color");if(ndColor){let nd=this.querySelector(".c-legend__no-data");if(!nd){nd=document.createElement("div");nd.className="c-legend__no-data";this.appendChild(nd)}nd.setAttribute("part","no-data");nd.textContent="No data";const glyph=document.createElement("span");glyph.className="glyph";glyph.style.background=ndColor;glyph.dataset.color=ndColor;nd.prepend(glyph)}else{const nd=this.querySelector(".c-legend__no-data");if(nd)nd.remove()}const audit=this.getAttribute("audit");if(audit){const a=this.ensure(".c-legend__audit",()=>{const el=document.createElement("div");el.className="c-legend__audit";return el});a.textContent=audit}else{const a=this.querySelector(".c-legend__audit");if(a)a.remove()}if(this.hasAttribute("continuous")){const ends=this.getAttribute("ends");let parsedEnds=null;if(ends){try{parsedEnds=JSON.parse(ends)}catch(e){parsedEnds=ends.split(",")}}if(Array.isArray(parsedEnds)&&parsedEnds.length>=2){const r=this.ensure(".c-legend__ramp",()=>{const el=document.createElement("div");el.className="c-legend__ramp";return el});let left=this.querySelector(".c-legend__ramp-label--start");if(!left){left=document.createElement("span");left.className="c-legend__ramp-label c-legend__ramp-label--start";r.appendChild(left)}left.textContent=parsedEnds[0];let right=this.querySelector(".c-legend__ramp-label--end");if(!right){right=document.createElement("span");right.className="c-legend__ramp-label c-legend__ramp-label--end";r.appendChild(right)}right.textContent=parsedEnds[parsedEnds.length-1]}}const sizeAttr=this.getAttribute("size");if(sizeAttr){const sc=this.ensure(".c-legend__size",()=>{const el=document.createElement("div");el.className="c-legend__size";return el});sc.textContent=sizeAttr}else{const sc=this.querySelector(".c-legend__size");if(sc)sc.remove()}const classification=this.getAttribute("classification");if(classification){const c=this.ensure(".c-legend__classification",()=>{const el=document.createElement("div");el.className="c-legend__classification";return el});c.textContent=classification}else{const c=this.querySelector(".c-legend__classification");if(c)c.remove()}const tableAttr=this.getAttribute("table");if(tableAttr){let parsed=null;try{parsed=JSON.parse(tableAttr)}catch(e){parsed=null}if(Array.isArray(parsed)){let det=this.querySelector(".c-legend__table-wrap");if(!det){det=document.createElement("details");det.className="c-legend__table-wrap";this.appendChild(det)}det.innerHTML="";const sum=document.createElement("summary");sum.textContent="Data table";det.appendChild(sum);const tbl=document.createElement("table");tbl.className="c-legend__table";const tbody=document.createElement("tbody");parsed.forEach((row)=>{const tr=document.createElement("tr");const cells=Array.isArray(row)?row:[row.label??row.key??"",row.value??""];cells.forEach((cell)=>{const td=document.createElement("td");td.textContent=cell;tr.appendChild(td)});tbody.appendChild(tr)});tbl.appendChild(tbody);det.appendChild(tbl)}}else{const det=this.querySelector(".c-legend__table-wrap");if(det)det.remove()}if(items){}const method=this.getAttribute("method");if(method){const m=this.ensure(".c-legend__method",()=>{const el=document.createElement("div");el.className="c-legend__method";return el});m.textContent=method}else{const m=this.querySelector(".c-legend__method");if(m)m.remove()}const norm=this.getAttribute("norm");if(norm){const n=this.ensure(".c-legend__norm",()=>{const el=document.createElement("span");el.className="c-legend__norm";return el});n.textContent=norm}else{const n=this.querySelector(".c-legend__norm");if(n)n.remove()}const ramp=this.getAttribute("ramp");if(ramp){const r=this.ensure(".c-legend__ramp",()=>{const el=document.createElement("div");el.className="c-legend__ramp";return el});r.style.background=ramp;const breaksAttr=this.getAttribute("breaks");if(breaksAttr){let breaks=null;try{breaks=JSON.parse(breaksAttr)}catch(e){breaks=breaksAttr.split(",").map((s)=>s.trim())}if(Array.isArray(breaks)){Array.from(r.querySelectorAll(".c-legend__ramp-segment")).forEach((n)=>n.remove());breaks.forEach((b,i)=>{const seg=document.createElement("span");seg.className="c-legend__ramp-segment";seg.style.flex="1";const lbl=document.createElement("span");lbl.className="c-legend__ramp-break";lbl.textContent=String(b);seg.appendChild(lbl);r.appendChild(seg)})}}}else{const r=this.querySelector(".c-legend__ramp");if(r)r.remove()}const scale=this.getAttribute("scale");if(scale){const sc=this.ensure(".c-legend__scale",()=>{const el=document.createElement("div");el.className="c-legend__scale";return el});sc.textContent=scale}else{const sc=this.querySelector(".c-legend__scale");if(sc)sc.remove()}}enhance(){if(this._wiredLegend)return;this._wiredLegend=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-legend__item"):null;if(!btn||!this.contains(btn))return;let selected;const isPressed=btn.getAttribute("aria-pressed");if(btn.getAttribute("aria-pressed")!==null){const pressed=btn.getAttribute("aria-pressed")!=="true";btn.setAttribute("aria-pressed",String(pressed));selected=pressed}else{const selected2=btn.getAttribute("aria-selected")!=="true";btn.setAttribute("aria-selected",String(selected2));selected=selected2}this.dispatchEvent(new CustomEvent("contour:legend-toggle",{detail:{label:btn.textContent.trim(),key:btn.dataset.key||btn.textContent.trim(),pressed:selected},bubbles:true,composed:true,}));this.dispatchEvent(new CustomEvent("contour:select",{detail:{label:btn.textContent.trim(),key:btn.dataset.key||btn.textContent.trim(),value:btn.dataset.key||btn.textContent.trim()},bubbles:true,composed:true,}))});try{let parsed=null;try{parsed=JSON.parse(this.getAttribute("items")||"null")}catch(e){parsed=this.getAttribute("items")}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:this.getAttribute("items"),items:parsed},bubbles:true,composed:true}))}catch(e){}this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList&&t.classList.contains("c-legend__break-input")){this.dispatchEvent(new CustomEvent("contour:break-change",{detail:{value:t.value},bubbles:true,composed:true}))}});this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-legend__item"));if(!items.length)return;const idx=items.indexOf(document.activeElement);if(e.key==="ArrowDown"||e.key==="ArrowRight"){e.preventDefault();const next=items[(idx+1)%items.length];if(next){next.focus();items.forEach((o,i)=>o.setAttribute("tabindex",o===next?"0":"-1"))}}else if(e.key==="ArrowUp"||e.key==="ArrowLeft"){e.preventDefault();const prev=items[(idx-1+items.length)%items.length];if(prev){prev.focus();items.forEach((o)=>o.setAttribute("tabindex",o===prev?"0":"-1"))}}else if(e.key==="Home"){if(items.length>4){e.preventDefault();items[0].focus();items.forEach((o,i)=>o.setAttribute("tabindex",i===0?"0":"-1"))}}else if(e.key==="End"){if(items.length>4){e.preventDefault();const last=items[items.length-1];last.focus();items.forEach((o)=>o.setAttribute("tabindex",o===last?"0":"-1"))}}else if(e.key==="Escape"){items.forEach((o)=>{if(o.getAttribute("role")==="option")o.setAttribute("aria-selected","false");else o.setAttribute("aria-pressed","false")});this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:true,composed:true}))}else if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){if(items.length>7){const start=idx>=0?idx+1:0;for(let i=0;i<items.length;i++){const ii=(start+i)%items.length;const txt=(items[ii].textContent||"").trim().toLowerCase();if(txt.startsWith(e.key.toLowerCase())){e.preventDefault();items[ii].focus();items.forEach((o,j)=>o.setAttribute("tabindex",j===ii?"0":"-1"));break}}}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();if(document.activeElement&&document.activeElement.classList.contains("c-legend__item")){document.activeElement.click()}}})}}define("contour-legend",ContourLegend);class ContourMeasure extends ContourBase{static get observed(){return["label","value","point","line","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},point:{attribute:"point"},line:{attribute:"line"},src:{attribute:"src"}}}render(){this.classList.add("c-measure");this.setAttribute("role","group");this.setAttribute("aria-label","Measure");wireStates(this);loadRemote(this,["label","value","point","line"]);if(renderStates(this,"measure"))return;const rLabel=remoteData(this,"label");const rValue=remoteData(this,"value");const rPoint=remoteData(this,"point");const rLine=remoteData(this,"line");if(!rLabel&&!rValue&&!rPoint&&!rLine){renderEmpty(this,"measure");return}if(rLabel){const l=this.ensure(".c-measure__label",()=>{const el=document.createElement("span");el.className="c-measure__label";return el});l.textContent=rLabel}else{const l=this.querySelector(".c-measure__label");if(l)l.remove()}if(rValue){const r=this.ensure(".c-measure__readout",()=>{const el=document.createElement("span");el.className="c-measure__readout";return el});r.textContent=rValue}else{const r=this.querySelector(".c-measure__readout");if(r)r.remove()}let sel=this.querySelector(".c-measure__unit-select");if(!sel){sel=document.createElement("select");sel.className="c-measure__unit-select";this.appendChild(sel)}["m","km","mi","ft"].forEach((u)=>{if(!sel.querySelector('option[value="'+u+'"]')){const o=document.createElement("option");o.value=u;o.textContent=u;sel.appendChild(o)}});if(rPoint){const p=this.ensure(".c-measure__point",()=>{const el=document.createElement("span");el.className="c-measure__point";return el});p.textContent=rPoint}else{const p=this.querySelector(".c-measure__point");if(p)p.remove()}if(!rLine){const svg=this.querySelector("svg");if(svg)svg.remove();return}if(rLine){const ln=this.ensure(".c-measure__line",()=>{const el=document.createElement("span");el.className="c-measure__line";return el});ln.style.inlineSize=rLine}else{const ln=this.querySelector(".c-measure__line");if(ln)ln.remove()}}enhance(){if(this._wiredMeasure)return;this._wiredMeasure=true;this.addEventListener("change",(e)=>{const sel=e.target&&e.target.closest?e.target.closest(".c-measure__unit-select"):null;if(sel&&this.contains(sel)){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{unit:sel.value}}))}})}}define("contour-measure",ContourMeasure);class ContourTimeline extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-timeline");this.setAttribute("role","list");wireStates(this);loadRemote(this,"items");if(renderStates(this,"timeline"))return;const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-timeline__item"));const items=remoteData(this,"items");if(items&&!authored.length){Array.from(this.querySelectorAll(".c-timeline__item")).forEach((n)=>n.remove());try{const parsed=JSON.parse(items);parsed.forEach((it)=>{const item=document.createElement("div");item.className="c-timeline__item";item.setAttribute("role","listitem");item.setAttribute("tabindex","-1");if(it.time){const t=document.createElement("time");t.className="c-timeline__time";t.textContent=it.time;item.appendChild(t)}if(it.title){const ti=document.createElement("div");ti.className="c-timeline__title";ti.textContent=it.title;item.appendChild(ti)}if(it.text){const tx=document.createElement("div");tx.className="c-timeline__text";tx.textContent=it.text;item.appendChild(tx)}this.appendChild(item)})}catch(e){}}else if(!authored.length){renderEmpty(this,"timeline")}}enhance(){if(this._wiredTimeline)return;this._wiredTimeline=true;const items=Array.from(this.querySelectorAll(".c-timeline__item"));items.forEach((it,i)=>it.setAttribute("tabindex",i===0?"0":"-1"));this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-timeline__item"):null;if(!item||!this.contains(item))return;const items=Array.from(this.querySelectorAll(".c-timeline__item"));const idx=items.indexOf(item);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx}}))});this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-timeline__item"));if(!items.length)return;const active=this.querySelector(".c-timeline__item:focus")||items[0];const idx=items.indexOf(active);let next=-1;if(e.key==="ArrowDown")next=Math.min(idx+1,items.length-1);else if(e.key==="ArrowUp")next=Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=items.length-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx}}));return}if(next<0||next===idx)return;e.preventDefault();items.forEach((it,i)=>it.setAttribute("tabindex",i===next?"0":"-1"));try{items[next].focus()}catch(err){}})}}define("contour-timeline",ContourTimeline);class ContourHeatmap extends ContourBase{static get observed(){return["cells","count","legend","empty","loading","values","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{cells:{attribute:"cells"},count:{attribute:"count"},legend:{attribute:"legend"},src:{attribute:"src"}}}render(){this.classList.add("c-heatmap");if(!this.hasAttribute("role"))this.setAttribute("role","grid");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Heatmap");wireStates(this);loadRemote(this,"cells");if(renderStates(this,"heatmap"))return;const authoredCells=Array.from(this.querySelectorAll(":scope > .c-heatmap__cell"));if(authoredCells.length){const cols=Math.ceil(Math.sqrt(authoredCells.length));this.style.gridTemplateColumns="repeat("+cols+", 1fr)";this.style.inlineSize="16rem"}else{Array.from(this.querySelectorAll(".c-heatmap__cell")).forEach((n)=>n.remove());const count=Math.min(200,Math.max(0,parseInt(this.getAttribute("cells")||this.getAttribute("count")||"0",10)||0));const cols=count>0?Math.ceil(Math.sqrt(count)):1;this.style.gridTemplateColumns="repeat("+cols+", 1fr)";this.style.inlineSize="16rem";if(count>0){let values=[];try{values=JSON.parse(this.getAttribute("values")||"[]")}catch(e){values=[]}for(let i=0;i<count;i++){const cell=document.createElement("div");cell.className="c-heatmap__cell";cell.setAttribute("role","gridcell");cell.setAttribute("tabindex",i===0?"0":"-1");cell.dataset.index=String(i);if(values[i]!==undefined)cell.setAttribute("title",String(values[i]));this.appendChild(cell)}const tip=this.ensure(".c-heatmap__tooltip",()=>{const el=document.createElement("div");el.className="c-heatmap__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}else if(!authoredCells.length){renderEmpty(this,"heatmap")}}if(this.hasAttribute("legend")){const leg=this.ensure(".c-heatmap__legend",()=>{const el=document.createElement("div");el.className="c-heatmap__legend";const bar=document.createElement("div");bar.className="c-heatmap__legend-bar";el.appendChild(bar);return el})}else{const leg=this.querySelector(".c-heatmap__legend");if(leg)leg.remove()}}enhance(){if(this._wiredHeatmap)return;this._wiredHeatmap=true;const cells=()=>Array.from(this.querySelectorAll(".c-heatmap__cell"));const showTip=(e)=>{const tip=this.querySelector(".c-heatmap__tooltip");if(!tip)return;const cell=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!cell||!this.contains(cell)){tip.setAttribute("hidden","");return}const title=cell.getAttribute("title");if(title)tip.textContent=title;else tip.textContent="Cell "+(cell.dataset.index||"");const rect=this.getBoundingClientRect();const cr=cell.getBoundingClientRect();this.style.position=this.style.position||"relative";tip.style.setProperty("--chart-tip-inline-start",(cr.left-rect.left+cr.width/2)+"px");tip.style.setProperty("--chart-tip-block-start",(cr.top-rect.top)+"px");tip.removeAttribute("hidden")};const hideTip=()=>{const tip=this.querySelector(".c-heatmap__tooltip");if(tip)tip.setAttribute("hidden","")};this.addEventListener("mouseover",showTip);this.addEventListener("mouseout",(e)=>{if(!e.relatedTarget||!this.contains(e.relatedTarget))hideTip()});this.addEventListener("focusin",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(cell&&this.contains(cell))showTip({target:cell})});this.addEventListener("focusout",(e)=>{if(!this.contains(e.relatedTarget))hideTip()});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!cell||!this.contains(cell))return;const list=cells();const idx=list.indexOf(cell);let next=-1;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";if(e.key==="ArrowRight")next=rtl?Math.max(idx-1,0):Math.min(idx+1,list.length-1);else if(e.key==="ArrowLeft")next=rtl?Math.min(idx+1,list.length-1):Math.max(idx-1,0);else if(e.key==="ArrowDown")next=Math.min(idx+Math.ceil(Math.sqrt(list.length)),list.length-1);else if(e.key==="ArrowUp")next=Math.max(idx-Math.ceil(Math.sqrt(list.length)),0);else if(e.key==="Home")next=0;else if(e.key==="End")next=list.length-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:1,index:idx}}));return}if(next>=0&&next!==idx){e.preventDefault();list.forEach((c,i)=>c.setAttribute("tabindex",i===next?"0":"-1"));try{list[next].focus()}catch(e){}}});this.addEventListener("click",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!cell||!this.contains(cell))return;const idx=cells().indexOf(cell);if(idx>=0)this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:1,index:idx}}))})}}define("contour-heatmap",ContourHeatmap);class ContourCompare extends ContourBase{static get observed(){return["no","text","yes","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}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");this.setAttribute("aria-label","Comparison");wireStates(this);loadRemote(this,["no","text","yes"]);if(renderStates(this,"compare"))return;const rYes=remoteData(this,"yes")||(this._remoteData&&this._remoteData.yes);const rNo=remoteData(this,"no")||(this._remoteData&&this._remoteData.no);const rText=remoteData(this,"text")||(this._remoteData&&this._remoteData.text);Array.from(this.querySelectorAll(".c-compare__yes, .c-compare__no, .c-compare__text")).forEach((n)=>n.remove());if(rYes){const y=document.createElement("span");y.className="c-compare__yes";y.innerHTML='<svg aria-hidden="true"><use href="#i-check" /></svg>';this.appendChild(y)}if(rNo){const n=document.createElement("div");n.className="c-compare__no";n.textContent=rNo;this.appendChild(n)}if(rText){const t=document.createElement("p");t.className="c-compare__text";t.textContent=rText;this.appendChild(t)}if(!rYes&&!rNo&&!rText){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"]}static get properties(){return{points:{attribute:"points"},src:{attribute:"src"}}}render(){this.classList.add("c-sparkline");if(!this.hasAttribute("role"))this.setAttribute("role","img");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Sparkline");wireStates(this);loadRemote(this,"points");if(renderStates(this,"sparkline"))return;const points=remoteData(this,"points");if(points){try{const parsed=JSON.parse(points);if(!Array.isArray(parsed)||parsed.length===0)throw new Error("empty");Array.from(this.querySelectorAll(".c-sparkline__dot, .c-sparkline__line, .c-sparkline__area")).forEach((n)=>n.remove());const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("class","c-sparkline__line");svg.setAttribute("viewBox","0 0 100 30");svg.setAttribute("preserveAspectRatio","none");svg.style.inlineSize="100%";svg.style.blockSize="100%";svg.setAttribute("width","100%");svg.setAttribute("height","100%");svg.setAttribute("title",this.getAttribute("aria-label")||"Sparkline");const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("d",parsed.map((p,i)=>(i===0?"M":"L")+" "+(i*100/(parsed.length-1))+" "+(30-p*30)).join(" "));svg.appendChild(path);const dot=document.createElementNS("http://www.w3.org/2000/svg","circle");dot.setAttribute("class","c-sparkline__dot");dot.setAttribute("r","2");dot.setAttribute("cx","0");dot.setAttribute("cy","15");dot.setAttribute("hidden","");svg.appendChild(dot);this.appendChild(svg);this._sparkPoints=parsed;const tip=this.ensure(".c-sparkline__tooltip",()=>{const el=document.createElement("div");el.className="c-sparkline__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}catch(e){Array.from(this.querySelectorAll("svg")).forEach((n)=>n.remove());renderEmpty(this,"sparkline")}}else{renderEmpty(this,"sparkline")}}enhance(){if(this._wiredSparkline)return;this._wiredSparkline=true;if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");const showTip=(e)=>{const svg=this.querySelector("svg");const tip=this.querySelector(".c-sparkline__tooltip");const dot=this.querySelector(".c-sparkline__dot");if(!tip||!svg)return;const rect=svg.getBoundingClientRect();const x=e.clientX-rect.left;const pct=Math.max(0,Math.min(1,x/rect.width));const pts=this._sparkPoints||[];if(pts.length===0)return;const idx=Math.round(pct*(pts.length-1));const val=pts[idx];const cx=(idx*100/(pts.length-1));const cy=30-val*30;if(dot){dot.setAttribute("cx",String(cx));dot.setAttribute("cy",String(cy));dot.removeAttribute("hidden")}tip.textContent=String(val);const tipX=(cx/100)*rect.width;tip.style.setProperty("--chart-tip-inline-start",tipX+"px");tip.style.setProperty("--chart-tip-block-start","0px");tip.removeAttribute("hidden")};const hideTip=()=>{const tip=this.querySelector(".c-sparkline__tooltip");const dot=this.querySelector(".c-sparkline__dot");if(tip)tip.setAttribute("hidden","");if(dot)dot.setAttribute("hidden","")};this.addEventListener("mousemove",showTip);this.addEventListener("mouseleave",hideTip);this.addEventListener("focusin",()=>{const pts=this._sparkPoints||[];if(!pts.length)return;const svg=this.querySelector("svg");if(!svg)return;const r=svg.getBoundingClientRect();showTip({clientX:r.left+r.width-1})});this.addEventListener("focusout",hideTip);this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,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"]}static get properties(){return{title:{attribute:"title"},series:{attribute:"series"},src:{attribute:"src"}}}render(){this.classList.add("c-chart-grid");this.setAttribute("role","group");this.setAttribute("aria-label","Chart grid");wireStates(this);loadRemote(this,"series");if(renderStates(this,"chart-grid"))return;const title=this.getAttribute("title");if(title){const t=this.ensure(".c-chart-grid__title",()=>{const el=document.createElement("div");el.className="c-chart-grid__title";return el});t.textContent=title}const series=remoteData(this,"series");if(!series&&!title)renderEmpty(this,"chart-grid")}}define("contour-chart-grid",ContourChartGrid);class ContourContourPlot extends ContourBase{static get observed(){return["axis","label"]}static get properties(){return{axis:{attribute:"axis"},label:{attribute:"label"}}}render(){this.classList.add("c-contour-plot");this.setAttribute("role","img");this.setAttribute("aria-label","Contour plot");const axis=this.getAttribute("axis");if(axis){let svg=this.querySelector("svg");if(!svg){svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 100 100");svg.setAttribute("aria-hidden","true");this.appendChild(svg)}let ax=svg.querySelector(".c-contour-plot__axis");if(!ax){ax=document.createElementNS("http://www.w3.org/2000/svg","line");ax.setAttribute("class","c-contour-plot__axis");svg.appendChild(ax)}}const label=this.getAttribute("label");if(label){let svg=this.querySelector("svg");if(!svg){svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 100 100");svg.setAttribute("aria-hidden","true");this.appendChild(svg)}let lbl=svg.querySelector(".c-contour-plot__label");if(!lbl){lbl=document.createElementNS("http://www.w3.org/2000/svg","text");lbl.setAttribute("class","c-contour-plot__label");svg.appendChild(lbl)}lbl.textContent=label}}}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.setAttribute("role","region");this.setAttribute("aria-live","polite");const err=this.getAttribute("error");if(err){this.dataset.state="error";Array.from(this.children).forEach((c)=>{if(!c.hasAttribute("data-fallback"))c.style.display="none"});let fb=this.querySelector("[data-fallback]");if(!fb){fb=document.createElement("div");fb.className="c-error-boundary__fallback";fb.dataset.fallback="";fb.textContent=this.getAttribute("fallback")||"Something went wrong.";this.appendChild(fb)}else{fb.textContent=this.getAttribute("fallback")||fb.textContent||"Something went wrong."}}else{this.dataset.state="ready";Array.from(this.children).forEach((c)=>{c.style.display=""});const fb=this.querySelector("[data-fallback]");if(fb)fb.remove()}}enhance(){if(this._wiredErrorBoundary)return;this._wiredErrorBoundary=true;this.addEventListener("error",(e)=>{e.stopPropagation();const msg=(e&&e.error&&e.error.message)?e.error.message:(e&&e.message)?e.message:"Unknown error";this.setAttribute("error",msg)},true)}}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");const fmt=(this.getAttribute("format")||"json").toLowerCase();const btn=this.ensure(".c-data-export__btn",()=>{const b=document.createElement("button");b.className="c-data-export__btn";b.type="button";return b});btn.textContent=this.getAttribute("label")||("Export "+fmt.toUpperCase());if(btn.parentNode!==this)this.appendChild(btn)}enhance(){if(this._wiredDataExport)return;this._wiredDataExport=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-data-export__btn"):null;if(!btn||!this.contains(btn))return;const fmt=(this.getAttribute("format")||"json").toLowerCase();const raw=this.getAttribute("data")||"[]";let text=raw;if(fmt==="csv"){try{const arr=JSON.parse(raw);if(Array.isArray(arr)&&arr.length){const keys=Object.keys(arr[0]);text=[keys.join(",")].concat(arr.map((r)=>keys.map((k)=>JSON.stringify(r[k]??"")).join(","))).join("\n")}}catch(e){}}const blob=new Blob([text],{type:fmt==="csv"?"text/csv":"application/json"});const url=URL.createObjectURL(blob);const a=document.createElement("a");a.href=url;a.download=this.getAttribute("filename")||("export."+fmt);document.body.appendChild(a);a.click();a.remove();URL.revokeObjectURL(url);this.dispatchEvent(new CustomEvent("contour:export",{bubbles:true,composed:true,detail:{format:fmt}}))})}}define("contour-data-export",ContourDataExport);class ContourDocsNav extends ContourBase{static get observed(){return["items","title","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},title:{attribute:"title"},src:{attribute:"src"}}}render(){this.classList.add("c-docs-nav");this.setAttribute("role","navigation");const title=this.getAttribute("title");if(title)this.setAttribute("aria-label",title);else this.setAttribute("aria-label","Documentation navigation");wireStates(this);loadRemote(this,"items");if(renderStates(this,"docs-nav"))return;const _remote=remoteData(this,"items");const items=this.hasAttribute("src")?_remote:(_remote||(this.hasAttribute("items")?this.getAttribute("items"):null));const list=this.querySelector(".c-docs-nav__list");const authored=list?Array.from(list.children).filter((n)=>n.classList&&n.classList.contains("c-docs-nav__group")):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const list=this.ensure(".c-docs-nav__list",()=>{const el=document.createElement("div");el.className="c-docs-nav__list";return el});list.innerHTML="";parsed.forEach((g)=>{const group=document.createElement("div");group.className="c-docs-nav__group";if(g.title){const gt=document.createElement("div");gt.className="c-docs-nav__group-title";gt.textContent=g.title;group.appendChild(gt)}const ul=document.createElement("div");ul.className="c-docs-nav__list";(g.links||g.items||[]).forEach((l)=>{const a=document.createElement("a");a.className="c-docs-nav__link";a.href=(typeof l==="string"?"#":(l.href||"#"));const label=typeof l==="string"?l:(l.label||l);if(typeof l==="object"&&l!==null&&l.badge){const b=document.createElement("span");b.className="c-docs-nav__badge";b.textContent=l.badge;a.appendChild(b)}a.appendChild(document.createTextNode(label));if(typeof l==="object"&&l!==null&&l.chevron){const ch=document.createElement("span");ch.className="c-docs-nav__chevron";ch.textContent=l.chevron;a.appendChild(ch)}if(typeof l==="object"&&l!==null&&Array.isArray(l.items)){a.classList.add("c-docs-nav__link--nested");const nested=document.createElement("div");nested.className="c-docs-nav__list c-docs-nav__list--nested";l.items.forEach((nl)=>{const na=document.createElement("a");na.className="c-docs-nav__link";na.href=(typeof nl==="string"?"#":(nl.href||"#"));na.textContent=typeof nl==="string"?nl:(nl.label||nl);nested.appendChild(na)});ul.appendChild(a);ul.appendChild(nested)}else{ul.appendChild(a)}});group.appendChild(ul);list.appendChild(group)})}catch(e){}}else if(!items&&list){list.remove();renderEmpty(this,"docs-nav")}else if(!items&&!list){renderEmpty(this,"docs-nav")}}enhance(){if(this._wiredDocsNav)return;this._wiredDocsNav=true;this.addEventListener("click",(e)=>{const link=e.target&&e.target.closest?e.target.closest(".c-docs-nav__link"):null;if(link&&this.contains(link)){const label=link.textContent||"";this.dispatchEvent(new CustomEvent("contour:docs-nav-select",{bubbles:true,composed:true,detail:{label,href:link.getAttribute("href")}}))}})}}define("contour-docs-nav",ContourDocsNav);class ContourDocsShell extends ContourBase{static get observed(){return["title","lede","article","heading"]}static get properties(){return{title:{attribute:"title"},lede:{attribute:"lede"},article:{attribute:"article"}}}render(){this.classList.add("c-docs-shell");this.setAttribute("role","region");const title=this.getAttribute("title");if(title){const h=this.ensure(".c-docs-shell__title",()=>{const el=document.createElement(headingTag(this,"h1"));el.className="c-docs-shell__title";return el});h.textContent=title;this.setAttribute("aria-label",title)}else{const h=this.querySelector(".c-docs-shell__title");if(h)h.remove()}const lede=this.getAttribute("lede");if(lede){const p=this.ensure(".c-docs-shell__lede",()=>{const el=document.createElement("p");el.className="c-docs-shell__lede";return el});p.textContent=lede}else{const p=this.querySelector(".c-docs-shell__lede");if(p)p.remove()}const article=this.getAttribute("article");if(article){const a=this.ensure(".c-docs-shell__article",()=>{const el=document.createElement("article");el.className="c-docs-shell__article";return el});a.innerHTML=sanitizeHtml(article)}else{const a=this.querySelector(".c-docs-shell__article");if(a)a.remove()}}}define("contour-docs-shell",ContourDocsShell);class ContourFileTree extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items"]}static get properties(){return{items:{attribute:"items"}}}render(){this.classList.add("c-file-tree");const items=this.getAttribute("items");if(items){try{const parsed=JSON.parse(items);const renderNode=(node,depth)=>{const row=document.createElement("div");row.className="c-file-tree__row"+(node.dir?" c-file-tree__row--dir":"")+(node.active?" c-file-tree__row--active":"");row.style.paddingInlineStart=(depth*1)+"rem";const label=document.createElement("span");label.textContent=node.label||node.name||"";row.appendChild(label);this.appendChild(row);if(Array.isArray(node.children)){node.children.forEach((c)=>renderNode(c,depth+1))}};Array.from(this.querySelectorAll(".c-file-tree__row")).forEach((n)=>n.remove());parsed.forEach((n)=>renderNode(n,0))}catch(e){}}}}define("contour-file-tree",ContourFileTree);class ContourChangelog extends ContourBase{static get observed(){return["src","max","loading","error"]}static get properties(){return{src:{attribute:"src"},max:{attribute:"max",type:Number}}}render(){this.classList.add("c-changelog");const src=this.getAttribute("src");if(src){if(this.dataset.loaded===src)return;this.dataset.loaded="";const loading=this.ensure(".c-changelog__loading",()=>{const el=document.createElement("div");el.className="c-changelog__loading";el.textContent="Loading…";return el});Array.from(this.querySelectorAll(".c-changelog__entry, .c-changelog__error")).forEach((n)=>n.remove());if(!this.querySelector(".c-changelog__loading"))this.appendChild(loading);fetch(src).then((r)=>{if(!r.ok)throw new Error("HTTP "+r.status);return r.text()}).then((text)=>{const ld=this.querySelector(".c-changelog__loading");if(ld)ld.remove();this.dataset.loaded=src;const entries=parseChangelog(text);const max=parseInt(this.getAttribute("max")||"0",10);const list=(max>0)?entries.slice(0,max):entries;if(!list.length){const empty=document.createElement("div");empty.className="c-changelog__empty";empty.textContent="No releases found.";this.appendChild(empty);return}list.forEach((e)=>{const det=document.createElement("details");det.className="c-changelog__entry";const sum=document.createElement("summary");sum.className="c-changelog__summary";const ver=document.createElement("span");ver.className="c-changelog__version";ver.textContent=e.version;sum.appendChild(ver);if(e.date){const d=document.createElement("span");d.className="c-changelog__date";d.textContent=e.date;sum.appendChild(d)}det.appendChild(sum);const body=document.createElement("div");body.className="c-changelog__body";body.innerHTML=renderChangelogBody(e.body);det.appendChild(body);this.appendChild(det)})}).catch((err)=>{const ld=this.querySelector(".c-changelog__loading");if(ld)ld.remove();const er=document.createElement("div");er.className="c-changelog__error";er.textContent="Failed to load changelog: "+(err&&err.message?err.message:err);this.appendChild(er)})}}}define("contour-changelog",ContourChangelog);function parseChangelog(text){const lines=String(text).split(/\r?\n/);const entries=[];let cur=null;for(const line of lines){const m=line.match(/^##\s+\[?([^\]\n]+)\]?\s*[-–—]?\s*(.*)$/);if(m&&(line.startsWith("## "))){const ver=m[1].trim();const rest=m[2].trim();if(/^\d|unreleased/i.test(ver)){if(cur)entries.push(cur);cur={version:ver,date:rest.replace(/^[-–—]\s*/,"").trim(),body:""};continue}}if(cur)cur.body+=line+"\n"}if(cur)entries.push(cur);return entries}function escapeHtml(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function renderChangelogBody(body){const lines=String(body).trim().split(/\r?\n/);const out=[];let inList=false;for(const raw of lines){const line=raw.trimEnd();if(/^###\s+/.test(line)){if(inList){out.push("</ul>");inList=false}out.push("<h4>"+escapeHtml(line.replace(/^###\s+/,""))+"</h4>")}else if(/^##\s+/.test(line)){if(inList){out.push("</ul>");inList=false}out.push("<h3>"+escapeHtml(line.replace(/^##\s+/,""))+"</h3>")}else if(/^[-*]\s+/.test(line)){if(!inList){out.push("<ul>");inList=true}out.push("<li>"+escapeHtml(line.replace(/^[-*]\s+/,""))+"</li>")}else if(line.trim()===""){if(inList){out.push("</ul>");inList=false}}else{if(inList){out.push("</ul>");inList=false}out.push("<p>"+escapeHtml(line)+"</p>")}}if(inList)out.push("</ul>");return out.join("")}class ContourDialog extends ContourBase{static get observed(){return["title","size","heading"]}static get properties(){return{title:{attribute:"title"},size:{attribute:"size"}}}render(){this.classList.add("c-dialog");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-dialog--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-dialog--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","dialog");const title=this.getAttribute("title");let head=this.querySelector(".c-dialog__head");if(title){if(!head){head=document.createElement("div");head.className="c-dialog__head";const h=document.createElement(headingTag(this,"h2"));h.className="c-dialog__title";head.appendChild(h);const closeBtn=document.createElement("button");closeBtn.className="c-btn c-btn--icon c-btn--ghost c-dialog__close";closeBtn.setAttribute("type","button");closeBtn.setAttribute("aria-label","Close");closeBtn.innerHTML='<svg aria-hidden="true"><use href="#i-close" /></svg>';head.appendChild(closeBtn)}const h=head.querySelector(".c-dialog__title");if(h){h.textContent=title;if(!h.id)h.id="contour-dialog-title-"+(this._dialogTitleId=(this._dialogTitleId||0)+1);this.setAttribute("aria-labelledby",h.id)}}if(head&&head.parentNode!==this)this.prepend(head);const body=this.ensure(".c-dialog__body",()=>{const el=document.createElement("div");el.className="c-dialog__body";return el});Array.from(this.childNodes).forEach((n)=>{if(n===body||n===head)return;if(n.nodeType===1&&n.classList&&n.classList.contains("c-dialog__head"))return;body.appendChild(n)});if(head&&head.parentNode===this){if(body.parentNode!==this)this.insertBefore(body,head.nextSibling);else if(head.compareDocumentPosition(body)&Node.DOCUMENT_POSITION_PRECEDING)this.insertBefore(body,head.nextSibling)}else{if(body.parentNode!==this)this.appendChild(body)}}enhance(){if(this._wiredDialog)return;this._wiredDialog=true;onDispose(this,()=>{if(this.hasAttribute("open"))modalContain(this,false)});this.show=()=>{if(this.hasAttribute("open"))return;this._dialogLastFocus=document.activeElement;this.setAttribute("open","");this.setAttribute("aria-modal","true");const dlg=this.querySelector("dialog")||(this.tagName==="DIALOG"?this:null);if(dlg&&typeof dlg.showModal==="function"){try{dlg.showModal()}catch(e){}}modalContain(this,true);const focusable=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable){try{focusable.focus()}catch(e){}}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))};this.close=()=>{const wasOpen=this.hasAttribute("open");const dlg=this.querySelector("dialog")||(this.tagName==="DIALOG"?this:null);if(dlg&&typeof dlg.close==="function")dlg.close();if(this.hasAttribute("open"))this.removeAttribute("open");this.removeAttribute("aria-modal");if(wasOpen){modalContain(this,false);this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));const last=this._dialogLastFocus;if(last&&typeof last.focus==="function"){try{last.focus()}catch(e){}}}};this.focus=()=>{const focusable=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable){try{focusable.focus()}catch(e){}}else{try{HTMLElement.prototype.focus.call(this)}catch(e){}}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-dialog__close"):null;if(btn&&this.contains(btn)){this.close();return}if(e.target===this)this.close()});this.addEventListener("keydown",(e)=>{if(e.key==="Escape"&&this.hasAttribute("open"))this.close()})}}define("contour-dialog",ContourDialog);class ContourAlert extends ContourBase{static get observed(){return["title","body","variant","icon","closable","action","actions","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},variant:{attribute:"variant"},icon:{attribute:"icon"},closable:{attribute:"closable",type:Boolean},action:{attribute:"action"},actions:{attribute:"actions"}}}render(){this.classList.add("c-alert");if(!this.hasAttribute("role"))this.setAttribute("role","alert");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live","assertive");wireStates(this);loadRemote(this,"title");if(renderStates(this,"alert"))return;const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-alert--"))this.classList.remove(c)});if(variant)this.classList.add("c-alert--"+variant);const icon=this.getAttribute("icon");if(icon){const ic=this.ensure(".c-alert__icon",()=>{const el=document.createElement("span");el.className="c-alert__icon";return el});if(ic.parentNode===this&&this.firstChild!==ic)this.prepend(ic);ic.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'}else{const ic=this.querySelector(".c-alert__icon");if(ic)ic.remove()}const title=this.getAttribute("title")||(this._remoteData&&this._remoteData.title);if(title){const t=this.ensure(".c-alert__title",()=>{const el=document.createElement("div");el.className="c-alert__title";return el});if(t.parentNode===this&&this.firstChild!==t)this.prepend(t);t.textContent=title}else{const t=this.querySelector(".c-alert__title");if(t)t.remove()}const body=this.getAttribute("body");if(body){const b=this.ensure(".c-alert__body",()=>{const el=document.createElement("div");el.className="c-alert__body";return el});b.textContent=body}else{const b=this.querySelector(".c-alert__body");if(b)b.remove()}Array.from(this.querySelectorAll(".c-alert__action")).forEach((n)=>n.remove());const actionsAttr=this.getAttribute("actions");let actionList=[];if(actionsAttr){try{const parsed=JSON.parse(actionsAttr);if(Array.isArray(parsed))actionList=parsed.map((x)=>String(x))}catch(e){actionList=[actionsAttr]}}else{const single=this.getAttribute("action");if(single)actionList=[single]}actionList.forEach((label)=>{const a=document.createElement("button");a.className="c-btn c-btn--sm c-alert__action";a.type="button";a.setAttribute("data-alert-action","");a.textContent=label;this.appendChild(a)});if(this.hasAttribute("closable")){this.ensure(".c-alert__close",()=>{const btn=document.createElement("button");btn.className="c-alert__close";btn.type="button";btn.setAttribute("aria-label","Close");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-alert__close");if(btn)btn.remove()}if(!title&&!body&&!icon){renderEmpty(this,"alert")}}}ContourAlert.prototype.enhance=function(){if(this._wiredAlert)return;this._wiredAlert=true;this.addEventListener("click",(e)=>{const actionBtn=e.target&&e.target.closest?e.target.closest(".c-alert__action"):null;if(actionBtn&&this.contains(actionBtn)){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:empty-action",{bubbles:true,composed:true,detail:{state:actionBtn.textContent.trim()}}));return}const btn=e.target&&e.target.closest?e.target.closest(".c-alert__close"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));this.remove()})};define("contour-alert",ContourAlert);class ContourDisclosure extends ContourBase{static get observed(){return["summary","icon"]}static get properties(){return{summary:{attribute:"summary"},icon:{attribute:"icon"}}}disconnectedCallback(){this._disclosureContent=null;super.disconnectedCallback()}connectedCallback(){if(this.innerHTML.trim()&&!this._disclosureContent){this._disclosureContent=this.innerHTML}super.connectedCallback()}attributeChangedCallback(name,oldValue,newValue){const details=this.querySelector("details");if(details){const body=details.querySelector(".c-disclosure__body");if(body)this._disclosureContent=body.innerHTML}else if(this.innerHTML.trim()){this._disclosureContent=this.innerHTML}super.attributeChangedCallback(name,oldValue,newValue)}render(){this.classList.add("c-disclosure");const summary=this.getAttribute("summary");const icon=this.getAttribute("icon");if(summary){let captured=this.innerHTML.trim()?this.innerHTML:(this._disclosureContent||"");if(captured.trim())this._disclosureContent=captured;const details=this.ensure("details",()=>{const d=document.createElement("details");const summ=document.createElement("summary");summ.className="c-disclosure__summary";if(icon){const ic=document.createElement("span");ic.className="c-disclosure__icon";ic.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>';summ.appendChild(ic)}summ.appendChild(document.createTextNode(summary));d.appendChild(summ);const content=document.createElement("div");content.className="c-disclosure__body";content.innerHTML=captured;d.appendChild(content);return d});const summ=details.querySelector("summary");if(summ){const ic=summ.querySelector(".c-disclosure__icon");if(icon&&!ic){const newIc=document.createElement("span");newIc.className="c-disclosure__icon";newIc.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>';summ.insertBefore(newIc,summ.firstChild)}else if(!icon&&ic){ic.remove()}const textNodes=Array.from(summ.childNodes).filter(n=>n.nodeType===3);textNodes.forEach(n=>n.remove());summ.appendChild(document.createTextNode(summary))}const body=details.querySelector(".c-disclosure__body");if(body)body.innerHTML=captured;if(details.parentNode!==this){this.innerHTML="";this.appendChild(details)}}else{const details=this.querySelector("details");if(details)details.remove()}}enhance(){if(this._wiredDisclosure)return;this._wiredDisclosure=true;this.addEventListener("toggle",(e)=>{const t=e.target;if(t&&t.tagName==="DETAILS"){this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:t.open},bubbles:true,composed:true}))}},true)}}define("contour-disclosure",ContourDisclosure);class ContourCallout extends ContourBase{static get observed(){return["variant","title","icon","closable"]}static get properties(){return{variant:{attribute:"variant"},title:{attribute:"title"},icon:{attribute:"icon"},closable:{attribute:"closable",type:Boolean}}}render(){this.classList.add("c-callout");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-callout--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-callout--"+variant);const icon=this.getAttribute("icon");if(icon){const ic=this.ensure(".c-callout__icon",()=>{const el=document.createElement("span");el.className="c-callout__icon";return el});if(ic.parentNode===this&&this.firstChild!==ic)this.prepend(ic);ic.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'}else{const ic=this.querySelector(".c-callout__icon");if(ic)ic.remove()}const title=this.getAttribute("title");if(title){const t=this.ensure(".c-callout__title",()=>{const el=document.createElement("div");el.className="c-callout__title";return el});if(t.parentNode===this&&this.firstChild!==t)this.prepend(t);t.textContent=title}else{const t=this.querySelector(".c-callout__title");if(t)t.remove()}if(this.hasAttribute("closable")){this.ensure(".c-callout__close",()=>{const btn=document.createElement("button");btn.className="c-callout__close";btn.type="button";btn.setAttribute("aria-label","Close");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-callout__close");if(btn)btn.remove()}}}ContourCallout.prototype.enhance=function(){if(this._wiredCallout)return;this._wiredCallout=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-callout__close"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));this.remove()})};define("contour-callout",ContourCallout);class ContourEmpty extends ContourBase{static get observed(){return["state","title","body","action","icon","illustration","heading"]}static get properties(){return{state:{attribute:"state"},title:{attribute:"title"},body:{attribute:"body"},action:{attribute:"action"},icon:{attribute:"icon"},illustration:{attribute:"illustration"}}}render(){this.classList.add("c-empty");if(!this.hasAttribute("role"))this.setAttribute("role","status");const state=this.getAttribute("state")||"empty";const title=this.getAttribute("title")||(state==="filtered"?"Nothing matches":state==="error"?"Could not load":"No data yet");const body=this.getAttribute("body")||(state==="filtered"?"Try clearing some filters.":state==="error"?"Check your connection and try again.":"There is nothing to show here yet.");const action=this.getAttribute("action")||(state==="filtered"?"Clear filters":state==="error"?"Retry":"");const icon=this.getAttribute("icon");if(icon){const ic=this.ensure(".c-empty__icon",()=>{const el=document.createElement("span");el.className="c-empty__icon";return el});ic.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'}else{const ic=this.querySelector(".c-empty__icon");if(ic)ic.remove()}const illustration=this.getAttribute("illustration");if(illustration){const il=this.ensure(".c-empty__illustration",()=>{const el=document.createElement("div");el.className="c-empty__illustration";return el});il.innerHTML=sanitizeHtml(illustration)}else{const il=this.querySelector(".c-empty__illustration");if(il)il.remove()}if(title){const t=this.ensure(".c-empty__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-empty__title";return el});t.textContent=title}else{const t=this.querySelector(".c-empty__title");if(t)t.remove()}if(body){const b=this.ensure(".c-empty__text",()=>{const el=document.createElement("p");el.className="c-empty__text";return el});b.textContent=body}else{const b=this.querySelector(".c-empty__text");if(b)b.remove()}if(action){const a=this.ensure("button.c-btn[data-empty-action]",()=>{const el=document.createElement("button");el.className="c-btn c-btn--primary";el.type="button";el.setAttribute("data-empty-action","");return el});a.textContent=action}else{const a=this.querySelector("[data-empty-action]");if(a)a.remove()}}enhance(){wireRemovable(this)}}define("contour-empty",ContourEmpty);class ContourFaq extends ContourBase{static get observed(){return["question","answer","items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{question:{attribute:"question"},answer:{attribute:"answer"},items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-faq");wireStates(this);loadRemote(this,"items");if(renderStates(this,"faq"))return;const items=remoteData(this,"items");const question=this.getAttribute("question");const answer=this.getAttribute("answer");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-faq__item"));if(items&&!authored.length){try{const parsed=JSON.parse(items);Array.from(this.querySelectorAll(".c-faq__item")).forEach((n)=>n.remove());parsed.forEach((it,i)=>{const item=document.createElement("details");item.className="c-faq__item";if(i===0)item.setAttribute("open","");const q=document.createElement("summary");q.className="c-faq__question";q.textContent=typeof it==="string"?it:(it.question||it.q||"");const sign=document.createElement("span");sign.className="c-faq__sign";sign.setAttribute("aria-hidden","true");sign.innerHTML='<svg aria-hidden="true"><use href="#i-plus" /></svg>';q.appendChild(sign);item.appendChild(q);const a=document.createElement("div");a.className="c-faq__answer";a.textContent=typeof it==="string"?"":(it.answer||it.a||"");item.appendChild(a);this.appendChild(item)})}catch(e){}}else if(!items){if(!question&&!answer){renderEmpty(this,"faq")}else{const item=this.ensure("details.c-faq__item",()=>{const el=document.createElement("details");el.className="c-faq__item";return el});if(!item.hasAttribute("open"))item.setAttribute("open","");const q=this.ensure("summary.c-faq__question",()=>{const el=document.createElement("summary");el.className="c-faq__question";return el},item);q.textContent=question||"";const sign=this.ensure(".c-faq__sign",()=>{const el=document.createElement("span");el.className="c-faq__sign";return el},q);sign.setAttribute("aria-hidden","true");sign.innerHTML='<svg aria-hidden="true"><use href="#i-plus" /></svg>';const a=this.ensure(".c-faq__answer",()=>{const el=document.createElement("div");el.className="c-faq__answer";return el},item);a.textContent=answer||""}}}}define("contour-faq",ContourFaq);class ContourAccordion extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist","exclusive"]}static get properties(){return{items:{attribute:"items"},exclusive:{attribute:"exclusive",type:Boolean},src:{attribute:"src"}}}render(){const authored=Array.from(this.children).filter((n)=>n.tagName==="DETAILS");wireStates(this);loadRemote(this,"items");if(renderStates(this,"accordion"))return;const items=remoteData(this,"items");if(items&&!authored.length){Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>d.remove());try{const parsed=JSON.parse(items);parsed.forEach((item)=>{const details=document.createElement("details");details.className="c-disclosure";const summary=document.createElement("summary");summary.className="c-disclosure__summary";summary.textContent=item.title||item.question||item.q||item.label||"";details.appendChild(summary);const body=document.createElement("div");body.className="c-disclosure__body";body.textContent=item.body||item.answer||item.a||item.content||"";details.appendChild(body);this.appendChild(details)})}catch(e){}}else if(!items&&!authored.length){renderEmpty(this,"accordion")}const persist=this.getAttribute("persist");if(persist){let saved=null;if(persist==="storage"&&this.id){try{saved=localStorage.getItem("contour-accordion:"+this.id)}catch(e){}}else if(persist==="url"){try{saved=new URLSearchParams(window.location.search).get("c-accordion")}catch(e){}}if(saved!==null){try{const labels=JSON.parse(saved);if(Array.isArray(labels)){const want=new Set(labels.map((l)=>String(l)));Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>{const summary=d.querySelector("summary");const label=(summary?summary.textContent:"").trim().slice(0,120);if(want.has(label))d.open=true})}}catch(e){}}}}enhance(){if(this._wiredAccordion)return;this._wiredAccordion=true;this.addEventListener("toggle",(e)=>{const t=e.target;if(t&&t.tagName==="DETAILS"){if(t.open&&this.hasAttribute("exclusive")){Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>{if(d!==t)d.open=false})}this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:t.open},bubbles:true,composed:true}));const persist=this.getAttribute("persist");if(persist==="storage"&&this.id){try{const open=[];Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>{if(d.open){const s=d.querySelector("summary");open.push((s?s.textContent:"").trim().slice(0,120))}});localStorage.setItem("contour-accordion:"+this.id,JSON.stringify(open))}catch(e){}}else if(persist==="url"){try{const open=[];Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>{if(d.open){const s=d.querySelector("summary");open.push((s?s.textContent:"").trim().slice(0,120))}});const url=new URL(window.location.href);url.searchParams.set("c-accordion",JSON.stringify(open));window.history.replaceState(null,"",url.toString())}catch(e){}}}},true)}}define("contour-accordion",ContourAccordion);class ContourDrawer extends ContourBase{static get observed(){return["title","body","size"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},size:{attribute:"size"}}}render(){this.classList.add("c-drawer");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-drawer--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-drawer--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","dialog");const title=this.getAttribute("title");let head=this.querySelector(".c-drawer__head");if(title){if(!head){head=document.createElement("div");head.className="c-drawer__head";const t=document.createElement("div");t.className="c-drawer__title";head.appendChild(t);const closeBtn=document.createElement("button");closeBtn.className="c-btn c-btn--icon c-btn--ghost c-drawer__close";closeBtn.setAttribute("type","button");closeBtn.setAttribute("aria-label","Close");closeBtn.innerHTML='<svg aria-hidden="true"><use href="#i-close" /></svg>';head.appendChild(closeBtn)}const t=head.querySelector(".c-drawer__title");if(t){t.textContent=title;if(!t.id)t.id="contour-drawer-title-"+(this._drawerTitleId=(this._drawerTitleId||0)+1);this.setAttribute("aria-labelledby",t.id)}if(head.parentNode!==this)this.prepend(head)}else if(head){head.remove()}if(this.hasAttribute("open"))this.classList.add("is-open");else this.classList.remove("is-open");const body=this.getAttribute("body");const b=this.querySelector(".c-drawer__body");const authored=b?Array.from(b.children):[];if(body&&!authored.length){const el=this.ensure(".c-drawer__body",()=>{const e=document.createElement("div");e.className="c-drawer__body";return e});el.innerHTML=sanitizeHtml(body)}else if(!body&&b&&!authored.length){b.remove()}}enhance(){if(this._wiredDrawer)return;this._wiredDrawer=true;onDispose(this,()=>{if(this.hasAttribute("open"))modalContain(this,false)});this._drawerLastFocus=null;this.show=()=>{if(this.hasAttribute("open"))return;this._drawerLastFocus=document.activeElement;this.setAttribute("open","");this.setAttribute("aria-modal","true");this.classList.add("is-open");modalContain(this,true);const focusable=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable){try{focusable.focus()}catch(e){}}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))};this.close=()=>{if(!this.hasAttribute("open"))return;this.removeAttribute("open");this.removeAttribute("aria-modal");this.classList.remove("is-open");modalContain(this,false);this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));const last=this._drawerLastFocus;if(last&&typeof last.focus==="function"){try{last.focus()}catch(e){}}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-drawer__close"):null;if(btn&&this.contains(btn)){this.close();return}if(e.target===this)this.close()});this.addEventListener("keydown",(e)=>{if(e.key==="Escape"&&this.hasAttribute("open"))this.close()});let touchStartX=0,touchStartY=0;this.addEventListener("touchstart",(e)=>{if(!this.hasAttribute("open"))return;const t=e.touches&&e.touches[0];if(t){touchStartX=t.clientX;touchStartY=t.clientY}},{passive:true});this.addEventListener("touchend",(e)=>{if(!this.hasAttribute("open"))return;const t=e.changedTouches&&e.changedTouches[0];if(!t)return;const dx=t.clientX-touchStartX;const dy=t.clientY-touchStartY;if(Math.abs(dx)>60&&Math.abs(dx)>Math.abs(dy)*1.5)this.close()},{passive:true})}}define("contour-drawer",ContourDrawer);class ContourSheet extends ContourBase{static get observed(){return["title","body","size"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},size:{attribute:"size"}}}render(){this.classList.add("c-sheet");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-sheet--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-sheet--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","dialog");const title=this.getAttribute("title");let head=this.querySelector(".c-sheet__head");if(title){if(!head){head=document.createElement("div");head.className="c-sheet__head";const t=document.createElement("div");t.className="c-sheet__title";head.appendChild(t);const closeBtn=document.createElement("button");closeBtn.className="c-btn c-btn--icon c-btn--ghost c-sheet__close";closeBtn.setAttribute("type","button");closeBtn.setAttribute("aria-label","Close");closeBtn.innerHTML='<svg aria-hidden="true"><use href="#i-close" /></svg>';head.appendChild(closeBtn)}const t=head.querySelector(".c-sheet__title");if(t){t.textContent=title;if(!t.id)t.id="contour-sheet-title-"+(this._sheetTitleId=(this._sheetTitleId||0)+1);this.setAttribute("aria-labelledby",t.id)}if(head.parentNode!==this)this.prepend(head)}else if(head){head.remove()}if(this.hasAttribute("open"))this.classList.add("is-open");else this.classList.remove("is-open");const body=this.getAttribute("body");const b=this.querySelector(".c-sheet__body");const authored=b?Array.from(b.children):[];if(body&&!authored.length){const el=this.ensure(".c-sheet__body",()=>{const e=document.createElement("div");e.className="c-sheet__body";return e});el.innerHTML=sanitizeHtml(body)}else if(!body&&b&&!authored.length){b.remove()}}enhance(){if(this._wiredSheet)return;this._wiredSheet=true;onDispose(this,()=>{if(this.hasAttribute("open"))modalContain(this,false)});this._sheetLastFocus=null;this.show=()=>{if(this.hasAttribute("open"))return;this._sheetLastFocus=document.activeElement;this.setAttribute("open","");this.setAttribute("aria-modal","true");this.classList.add("is-open");modalContain(this,true);const focusable=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable){try{focusable.focus()}catch(e){}}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))};this.close=()=>{if(!this.hasAttribute("open"))return;this.removeAttribute("open");this.removeAttribute("aria-modal");this.classList.remove("is-open");modalContain(this,false);this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));const last=this._sheetLastFocus;if(last&&typeof last.focus==="function"){try{last.focus()}catch(e){}}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-sheet__close"):null;if(btn&&this.contains(btn)){this.close();return}if(e.target===this)this.close()});this.addEventListener("keydown",(e)=>{if(e.key==="Escape"&&this.hasAttribute("open"))this.close()});let touchStartY=0,touchStartX=0;this.addEventListener("touchstart",(e)=>{if(!this.hasAttribute("open"))return;const t=e.touches&&e.touches[0];if(t){touchStartX=t.clientX;touchStartY=t.clientY}},{passive:true});this.addEventListener("touchend",(e)=>{if(!this.hasAttribute("open"))return;const t=e.changedTouches&&e.changedTouches[0];if(!t)return;const dy=t.clientY-touchStartY;const dx=t.clientX-touchStartX;if(dy>60&&Math.abs(dy)>Math.abs(dx)*1.5)this.close()},{passive:true})}}define("contour-sheet",ContourSheet);class ContourToast extends ContourBase{static get observed(){return["message","variant","duration"]}static get properties(){return{message:{attribute:"message"},variant:{attribute:"variant"},duration:{attribute:"duration",type:Number}}}render(){this.classList.add("c-toast");if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live","polite");if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true");const message=this.getAttribute("message");if(message&&!this.hasChildNodes()){this.textContent=message}const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-toast--"))this.classList.remove(c)});if(variant)this.classList.add("c-toast--"+variant)}enhance(){if(this._wiredToast)return;this._wiredToast=true;const ms=(this.duration&&this.duration>0)?this.duration:1500;const timer=setTimeout(()=>{if(!this.isConnected)return;this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));this.remove()},ms);onDispose(this,()=>clearTimeout(timer))}}define("contour-toast",ContourToast);class ContourExpandable extends ContourBase{static get observed(){return["summary"]}static get properties(){return{summary:{attribute:"summary"}}}disconnectedCallback(){this._expandableContent=null;super.disconnectedCallback()}connectedCallback(){if(this.innerHTML.trim()&&!this._expandableContent){this._expandableContent=this.innerHTML}super.connectedCallback()}attributeChangedCallback(name,oldValue,newValue){const details=this.querySelector("details");if(details){const body=details.querySelector(".c-expandable__body");if(body)this._expandableContent=body.innerHTML}else if(this.innerHTML.trim()){this._expandableContent=this.innerHTML}super.attributeChangedCallback(name,oldValue,newValue)}render(){this.classList.add("c-expandable");const summary=this.getAttribute("summary");if(summary){let captured=this.innerHTML.trim()?this.innerHTML:(this._expandableContent||"");if(captured.trim())this._expandableContent=captured;const details=this.ensure("details",()=>{const d=document.createElement("details");const summ=document.createElement("summary");summ.className="c-expandable__summary";summ.textContent=summary;d.appendChild(summ);const content=document.createElement("div");content.className="c-expandable__body";content.innerHTML=captured;d.appendChild(content);return d});const summ=details.querySelector("summary");if(summ)summ.textContent=summary;const body=details.querySelector(".c-expandable__body");if(body)body.innerHTML=captured;if(details.parentNode!==this){this.innerHTML="";this.appendChild(details)}}else{const details=this.querySelector("details");if(details)details.remove()}}enhance(){if(this._wiredExpandable)return;this._wiredExpandable=true;this.addEventListener("toggle",(e)=>{const t=e.target;if(t&&t.tagName==="DETAILS"){this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:t.open},bubbles:true,composed:true}))}},true)}}define("contour-expandable",ContourExpandable);class ContourToastHost extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-toast-host");if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live","polite");if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}enhance(){if(this._wiredToastHost)return;this._wiredToastHost=true;this._toastQueue=[];this._toastActive=null;const buildToast=(message,opts)=>{opts=opts||{};const toast=document.createElement("div");toast.className="c-toast";toast.setAttribute("role","status");toast.setAttribute("aria-live","polite");toast.setAttribute("aria-atomic","true");if(opts.variant)toast.classList.add("c-toast--"+opts.variant);toast.dataset.message=message==null?"":String(message);const text=document.createElement("span");text.className="c-toast__text";text.textContent=message==null?"":String(message);toast.appendChild(text);if(opts.action&&(typeof opts.action==="string"||(opts.action.label))){const label=(typeof opts.action==="string")?opts.action:opts.action.label;const btn=document.createElement("button");btn.type="button";btn.className="c-btn c-btn--ghost c-toast__action";btn.textContent=label;btn.addEventListener("click",(e)=>{e.stopPropagation();if(typeof opts.action==="object"&&typeof opts.action.onClick==="function"){try{opts.action.onClick()}catch(err){}}dismiss(toast)});toast.appendChild(btn)}return toast};const dismiss=(toast)=>{if(!toast||!toast.parentNode)return;if(toast._timer){clearTimeout(toast._timer);toast._timer=null}toast.parentNode.removeChild(toast);if(this._toastActive===toast)this._toastActive=null;this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true,detail:{message:toast.textContent}}));pump()};const pump=()=>{if(this._toastActive&&this._toastActive.parentNode)return;while(this._toastQueue.length){const next=this._toastQueue.shift();if(next._deduped)continue;const toast=buildToast(next.message,next.opts);this._toastActive=toast;this.appendChild(toast);const ms=(next.opts&&next.opts.duration&&next.opts.duration>0)?next.opts.duration:3000;toast._timer=setTimeout(()=>dismiss(toast),ms);return}this._toastActive=null};this.show=(message,opts)=>{opts=opts||{};const key=String(message==null?"":message);const active=this._toastActive;if(active&&active.dataset&&active.dataset.message===key&&key!==""){if(active._timer){clearTimeout(active._timer)}const ms=(opts.duration&&opts.duration>0)?opts.duration:3000;active._timer=setTimeout(()=>dismiss(active),ms);return active}const queuedDup=this._toastQueue.find((q)=>String(q.message)===key&&key!=="");if(queuedDup){queuedDup.opts=Object.assign({},queuedDup.opts,opts);return null}const entry={message,opts,_deduped:false};this._toastQueue.push(entry);pump();return this._toastActive};this.hide=()=>{if(this._toastActive)dismiss(this._toastActive);this._toastQueue.length=0;Array.from(this.querySelectorAll(".c-toast")).forEach((t)=>{if(t._timer)clearTimeout(t._timer);if(t.parentNode)t.parentNode.removeChild(t)});this._toastActive=null}}}define("contour-toast-host",ContourToastHost);class ContourCombobox extends ContourBase{static get observed(){return["options","placeholder","label","value","multiple","loading","error","retry","src","lazy","refresh","timeout","empty","skeleton","virtual"]}static get formAssociated(){return true}static get properties(){return{options:{attribute:"options"},placeholder:{attribute:"placeholder"},label:{attribute:"label"},value:{attribute:"value"},multiple:{attribute:"multiple",type:Boolean},virtual:{attribute:"virtual",type:Boolean},src:{attribute:"src"}}}render(){this.classList.add("c-combobox");wireStates(this);loadRemote(this,"options");if(renderStates(this,"combobox"))return;const options=remoteData(this,"options");const authored=Array.from(this.children).filter((n)=>!n.classList||(!n.classList.contains("c-combobox__input")&&!n.classList.contains("c-combobox__list")));if((options)&&!authored.length){try{const parsed=options?JSON.parse(options):[];const input=this.ensure(".c-combobox__input",()=>{const el=document.createElement("input");el.className="c-combobox__input";el.type="text";return el});input.type="text";input.placeholder=this.getAttribute("placeholder")||"Search…";input.setAttribute("aria-label",this.getAttribute("label")||"Search");const val=this.getAttribute("value");if(val!==null)input.value=val;const list=this.ensure(".c-combobox__list",()=>{const el=document.createElement("ul");el.className="c-combobox__list";el.setAttribute("hidden","");return el});list.innerHTML="";list.setAttribute("hidden","");this._comboboxOptions=parsed;this._comboboxVirtual=this.hasAttribute("virtual")&&parsed.length>100;if(this._comboboxVirtual){list.classList.add("c-combobox__list--virtual");list.style.maxBlockSize="20rem";list.style.overflow="auto";this._renderComboboxWindow("",true)}else{list.classList.remove("c-combobox__list--virtual");list.style.maxBlockSize="";list.style.overflow="";this._renderComboboxWindow("",true)}}catch(e){}}else if(!authored.length&&!options){renderEmpty(this,"combobox")}if(this.getAttribute("value")){this.ensure(".c-combobox__clear",()=>{const btn=document.createElement("button");btn.className="c-combobox__clear";btn.type="button";btn.setAttribute("aria-label","Clear");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-combobox__clear");if(btn)btn.remove()}}_renderComboboxWindow(query="",reset=false){const list=this.querySelector(".c-combobox__list");const options=this._comboboxOptions||[];if(!list)return;const q=String(query||"").toLowerCase();const filtered=options.map((opt,index)=>({opt,index,label:typeof opt==="string"?opt:opt.label,value:typeof opt==="string"?opt:opt.value,})).filter((item)=>!q||String(item.label).toLowerCase().includes(q));this._comboboxFiltered=filtered;const rowHeight=32;const windowSize=20;const overscan=6;const oldScrollTop=list.scrollTop;const start=this._comboboxVirtual&&!reset?Math.min(Math.max(0,filtered.length-windowSize),Math.max(0,Math.floor(oldScrollTop/rowHeight)-overscan)):0;this._comboboxWindowStart=start;const end=this._comboboxVirtual?Math.min(filtered.length,start+windowSize+overscan*2):filtered.length;const selectedVals=(this.getAttribute("value")||"").split(",").map((v)=>v.trim()).filter(Boolean);list.innerHTML="";const addSpacer=(height)=>{const spacer=document.createElement("li");spacer.setAttribute("aria-hidden","true");spacer.style.blockSize=`${height}px`;list.appendChild(spacer)};if(this._comboboxVirtual)addSpacer(start*rowHeight);if(!filtered.length){const empty=document.createElement("li");empty.className="c-combobox__empty";empty.setAttribute("role","status");empty.textContent=this.getAttribute("empty")||"No matches";list.appendChild(empty)}if(this.hasAttribute("multiple"))list.setAttribute("aria-multiselectable","true");else list.removeAttribute("aria-multiselectable");filtered.slice(start,end).forEach((item)=>{const li=document.createElement("li");li.className="c-combobox__option";li.dataset.optionIndex=String(item.index);li.setAttribute("role","option");const label=String(item.label);const q=String(query||"").toLowerCase();if(q&&label.toLowerCase().includes(q)){const idx=label.toLowerCase().indexOf(q);const before=label.slice(0,idx);const match=label.slice(idx,idx+q.length);const after=label.slice(idx+q.length);li.innerHTML="";if(before)li.appendChild(document.createTextNode(before));const mark=document.createElement("mark");mark.className="c-combobox__match";mark.textContent=match;li.appendChild(mark);if(after)li.appendChild(document.createTextNode(after))}else{li.textContent=label}const isSelected=this.hasAttribute("multiple")&&selectedVals.includes(String(item.value));li.setAttribute("aria-selected",String(isSelected));if(isSelected)li.classList.add("c-combobox__option--selected");list.appendChild(li)});if(this._comboboxVirtual)addSpacer(Math.max(0,filtered.length-end)*rowHeight);if(this._comboboxVirtual&&!reset)list.scrollTop=oldScrollTop}enhance(){wireCombobox(this);if(this._internals&&!this._wiredComboboxForm){this._wiredComboboxForm=true;this._syncFormValue();this.addEventListener("contour:select",(e)=>{const v=e&&e.detail&&(e.detail.value||e.detail.label);if(v!=null)this.setAttribute("value",String(v));this._syncFormValue()})}if(!this._wiredComboboxClear){this._wiredComboboxClear=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-combobox__clear"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.removeAttribute("value");const input=this.querySelector(".c-combobox__input");if(input)input.value="";this._syncFormValue();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{name:this.getAttribute("name"),value:null,checked:null}}))})}}}define("contour-combobox",ContourCombobox);class ContourField extends ContourBase{static get observed(){return["label","hint","error","placeholder","type","required"]}static get formAssociated(){return true}static get properties(){return{label:{attribute:"label"},hint:{attribute:"hint"},error:{attribute:"error"},placeholder:{attribute:"placeholder"},type:{attribute:"type"},required:{attribute:"required",type:Boolean}}}render(){this.classList.add("c-field");const label=this.getAttribute("label");const hint=this.getAttribute("hint");const error=this.getAttribute("error");const placeholder=this.getAttribute("placeholder")||"";if(label){const lbl=this.ensure(".c-field__label",()=>{const el=document.createElement("label");el.className="c-field__label";return el});lbl.textContent=label}else{const lbl=this.querySelector(".c-field__label");if(lbl)lbl.remove()}const input=this.ensure("input.c-input, textarea, select",()=>{const el=document.createElement("input");el.className="c-input";return el});input.type=this.getAttribute("type")||"text";input.placeholder=placeholder;if(!input.id)input.id=contourId("contour-field");const lbl=this.querySelector(".c-field__label");if(lbl){if(!input.id)input.id=contourId("contour-field");lbl.setAttribute("for",input.id);input.setAttribute("aria-label",lbl.textContent)}if(hint){const h=this.ensure(".c-field__hint",()=>{const el=document.createElement("span");el.className="c-field__hint";return el});h.textContent=hint}else{const h=this.querySelector(".c-field__hint");if(h)h.remove()}if(error){const e=this.ensure(".c-field__error",()=>{const el=document.createElement("span");el.className="c-field__error";return el});e.textContent=error}else{const e=this.querySelector(".c-field__error");if(e)e.remove()}const hintEl=this.querySelector(".c-field__hint");const errEl=this.querySelector(".c-field__error");const describedBy=[];if(hintEl){if(!hintEl.id)hintEl.id=contourId("hint");describedBy.push(hintEl.id)}if(errEl){if(!errEl.id)errEl.id=contourId("err");describedBy.push(errEl.id)}if(describedBy.length)input.setAttribute("aria-describedby",describedBy.join(" "));if(this.hasAttribute("required"))input.setAttribute("aria-required","true")}}ContourField.prototype.enhance=function(){if(this._wiredField)return;this._wiredField=true;const sync=()=>{const input=this.querySelector("input, textarea, select");if(!input||!this._internals)return;this._internals.setFormValue(input.value)};this.addEventListener("input",(e)=>{const input=this.querySelector("input, textarea, select");if(!input||e.target!==input)return;sync();this._emitForm("contour:input")});this.addEventListener("change",(e)=>{const input=this.querySelector("input, textarea, select");if(!input||e.target!==input)return;sync();this._emitForm("contour:change")});this.addEventListener("blur",(e)=>{const input=this.querySelector("input, textarea, select");if(!input||e.target!==input)return;const valid=input.checkValidity();if(valid){input.setAttribute("aria-invalid","false");this.classList.remove("is-invalid");this.removeAttribute("data-invalid")}else{input.setAttribute("aria-invalid","true");this.classList.add("is-invalid");this.setAttribute("data-invalid","");if(!this.getAttribute("error")){const msg=input.validationMessage||"Invalid value";let errEl=this.querySelector(".c-field__error");if(!errEl){errEl=document.createElement("span");errEl.className="c-field__error";this.appendChild(errEl)}errEl.textContent=msg;if(!errEl.id)errEl.id=contourId("err");input.setAttribute("aria-describedby",(input.getAttribute("aria-describedby")||"").split(" ").filter((x)=>x&&x!==errEl.id).concat(errEl.id).join(" "))}}sync()},true);sync()};define("contour-field",ContourField);class ContourFieldGroup extends ContourBase{static get observed(){return["label","hint","error","required"]}static get properties(){return{label:{attribute:"label"},hint:{attribute:"hint"},error:{attribute:"error"},required:{attribute:"required",type:Boolean}}}render(){this.classList.add("c-field-group");this.setAttribute("role","group");const label=this.getAttribute("label");if(label){const lbl=this.ensure(".c-field-group__label",()=>{const el=document.createElement("div");el.className="c-field-group__label";return el});lbl.textContent=label}else{const lbl=this.querySelector(".c-field-group__label");if(lbl)lbl.remove()}const hint=this.getAttribute("hint");if(hint){const h=this.ensure(".c-field-group__hint",()=>{const el=document.createElement("span");el.className="c-field-group__hint";return el});h.textContent=hint}else{const h=this.querySelector(".c-field-group__hint");if(h)h.remove()}const error=this.getAttribute("error");if(error){const e=this.ensure(".c-field-group__error",()=>{const el=document.createElement("span");el.className="c-field-group__error";return el});e.textContent=error}else{const e=this.querySelector(".c-field-group__error");if(e)e.remove()}if(error)this.classList.add("is-error");else this.classList.remove("is-error");if(this.hasAttribute("required"))this.setAttribute("aria-required","true");else this.removeAttribute("aria-required")}enhance(){if(this._wiredFieldGroup)return;this._wiredFieldGroup=true}}define("contour-field-group",ContourFieldGroup);class ContourForm extends ContourBase{static get observed(){return["submitting","error","summary"]}static get properties(){return{submitting:{attribute:"submitting",type:Boolean},error:{attribute:"error"},summary:{attribute:"summary"}}}render(){this.classList.add("c-form");if(this.hasAttribute("submitting"))this.classList.add("is-submitting");else this.classList.remove("is-submitting");const summaryText=this.getAttribute("summary")||this.getAttribute("error");let summary=this.querySelector(".c-form__summary");if(summaryText){if(!summary){summary=document.createElement("div");summary.className="c-form__summary";summary.setAttribute("role","alert");this.prepend(summary)}summary.textContent=summaryText;summary.removeAttribute("hidden")}else if(summary){summary.setAttribute("hidden","")}const submit=this.querySelector("[type='submit'], .c-form__submit");if(submit){if(this.hasAttribute("submitting"))submit.setAttribute("disabled","");else submit.removeAttribute("disabled")}}enhance(){if(this._wiredForm)return;this._wiredForm=true;this.addEventListener("submit",(e)=>{const form=e.target;if(form&&typeof form.checkValidity==="function"&&!form.checkValidity()){e.preventDefault();const invalid=Array.from(form.querySelectorAll(":invalid"));const names=invalid.map((el)=>el.getAttribute("aria-label")||el.name||el.id||"field").join(", ");let summary=this.querySelector(".c-form__summary");if(!summary){summary=document.createElement("div");summary.className="c-form__summary";summary.setAttribute("role","alert");this.prepend(summary)}summary.textContent="Please fix: "+(names||"invalid fields");summary.removeAttribute("hidden");return}this.classList.add("is-submitting");const submit=this.querySelector("[type='submit'], .c-form__submit");if(submit)submit.setAttribute("disabled","");this.dispatchEvent(new CustomEvent("contour:submit",{bubbles:true,composed:true,detail:{submitting:true}}))})}}define("contour-form",ContourForm);class ContourRange extends ContourBase{static get observed(){return["min","max","value","low","high","range","sparkline","label","disabled","error","help"]}static get formAssociated(){return true}static get properties(){return{min:{attribute:"min"},max:{attribute:"max"},value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-range");const min=this.getAttribute("min")||"0";const max=this.getAttribute("max")||"100";const rangeMode=this.hasAttribute("range")||this.hasAttribute("low")||this.hasAttribute("high");const spark=this.getAttribute("sparkline");if(spark){let canvas=this.querySelector(".c-range__sparkline");if(!canvas){canvas=document.createElement("canvas");canvas.className="c-range__sparkline";canvas.setAttribute("part","sparkline-canvas");this.insertBefore(canvas,this.firstChild)}}else{const c=this.querySelector(".c-range__sparkline");if(c)c.remove()}if(rangeMode){const single=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");let lowInput=this.querySelector("input.c-range__low");if(!lowInput){lowInput=document.createElement("input");lowInput.type="range";lowInput.className="c-range c-range__low";this.appendChild(lowInput)}let highInput=this.querySelector("input.c-range__high");if(!highInput){highInput=document.createElement("input");highInput.type="range";highInput.className="c-range c-range__high";this.appendChild(highInput)}lowInput.min=min;lowInput.max=max;highInput.min=min;highInput.max=max;const lowVal=this.getAttribute("low")||min;const highVal=this.getAttribute("high")||max;if(this._rangeUserLow!==null&&this._rangeAttrLowAtDirty===(this.getAttribute("low")||min))lowInput.value=this._rangeUserLow;else{lowInput.value=lowVal;this._rangeUserLow=null;this._rangeAttrLowAtDirty=null}if(this._rangeUserHigh!==null&&this._rangeAttrHighAtDirty===(this.getAttribute("high")||max))highInput.value=this._rangeUserHigh;else{highInput.value=highVal;this._rangeUserHigh=null;this._rangeAttrHighAtDirty=null}const label=this.getAttribute("label");if(label){lowInput.setAttribute("aria-label",label+" low");highInput.setAttribute("aria-label",label+" high")}}else{Array.from(this.querySelectorAll("input.c-range__low, input.c-range__high")).forEach((n)=>n.remove());const input=this.ensure("input.c-range",()=>{const el=document.createElement("input");el.type="range";return el});input.className="c-range";input.type="range";input.min=min;input.max=max;const attrVal=this.getAttribute("value")||"50";if(this._rangeUserValue!==null&&this._rangeAttrAtDirty===(this.getAttribute("value")||"50")){input.value=this._rangeUserValue}else{input.value=attrVal;this._rangeUserValue=null;this._rangeAttrAtDirty=null}const label=this.getAttribute("label");if(label)input.setAttribute("aria-label",label);else if(!input.hasAttribute("aria-label"))input.setAttribute("aria-label","Range");const updateFill=()=>{const mn=Number(input.min)||0;const mx=Number(input.max)||100;const val=Number(input.value)||0;const pct=mx>mn?((val-mn)/(mx-mn))*100:0;input.style.setProperty("--fill",pct+"%")};updateFill();if(!input._fillWired){input._fillWired=true;input.addEventListener("input",updateFill)}}}}const _origRangeRender=ContourRange.prototype.render;ContourRange.prototype.attributeChangedCallback=function(name,oldValue,newValue){if(name==="value"){this._rangeUserValue=null;this._rangeAttrAtDirty=null}if(name==="low"){this._rangeUserLow=null;this._rangeAttrLowAtDirty=null}if(name==="high"){this._rangeUserHigh=null;this._rangeAttrHighAtDirty=null}return ContourBase.prototype.attributeChangedCallback.call(this,name,oldValue,newValue)};ContourRange.prototype.enhance=function(){if(this._wiredRange)return;this._wiredRange=true;const sync=()=>{const low=this.querySelector("input.c-range__low");const high=this.querySelector("input.c-range__high");const single=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");if(this._internals){if(low&&high)this._internals.setFormValue(low.value+","+high.value);else if(single)this._internals.setFormValue(single.value)}};this.addEventListener("input",(e)=>{const low=this.querySelector("input.c-range__low");const high=this.querySelector("input.c-range__high");const single=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");if(low&&high&&(e.target===low||e.target===high)){this._rangeUserLow=low.value;this._rangeUserHigh=high.value;this._rangeAttrLowAtDirty=this.getAttribute("low")||(this.getAttribute("min")||"0");this._rangeAttrHighAtDirty=this.getAttribute("high")||(this.getAttribute("max")||"100");sync();this._emitForm("contour:input",{low:Number(low.value),high:Number(high.value)});this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{low:Number(low.value),high:Number(high.value)}}))}else if(single&&e.target===single){this._rangeUserValue=single.value;this._rangeAttrAtDirty=this.getAttribute("value")||"50";sync();this._emitForm("contour:input")}});this.addEventListener("change",(e)=>{const low=this.querySelector("input.c-range__low");const high=this.querySelector("input.c-range__high");const single=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");if(low&&high&&(e.target===low||e.target===high)){sync();this._emitForm("contour:change",{low:Number(low.value),high:Number(high.value)});this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{low:Number(low.value),high:Number(high.value)}}))}else if(single&&e.target===single){sync();this._emitForm("contour:change")}});sync()};define("contour-range",ContourRange);class ContourSwitch extends ContourBase{static get observed(){return["label","required","checked","disabled","error","help"]}static get properties(){return{label:{attribute:"label"},required:{attribute:"required",type:Boolean},checked:{attribute:"checked",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return true}render(){this.classList.add("c-switch");const label=this.getAttribute("label");const input=this.ensure("input.c-switch__input",()=>{const el=document.createElement("input");el.className="c-switch__input";el.type="checkbox";return el});input.checked=this.hasAttribute("checked");input.setAttribute("role","switch");input.setAttribute("aria-checked",String(input.checked));this._setCustomState("data-checked",input.checked);if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-switch__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-switch__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-switch__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");if(!input.nextElementSibling||!input.nextElementSibling.classList.contains("c-switch__track")){const track=document.createElement("span");track.className="c-switch__track";track.setAttribute("aria-hidden","true");if(input.nextSibling)this.insertBefore(track,input.nextSibling);else this.appendChild(track)}if(label){input.setAttribute("aria-label",label);const txt=this.querySelector(":scope > span:not([class]):not(.c-switch__track)")||(()=>{const el=document.createElement("span");this.appendChild(el);return el})();txt.textContent=label}}enhance(){const input=this.querySelector("input");if(input&&this._internals){input.setAttribute("aria-checked",String(input.checked));this._setCustomState("data-checked",input.checked);this._internals.setFormValue(input.checked?(input.value||"on"):null);this._syncValidity(this.hasAttribute("required")&&!input.checked)}if(this._wiredSwitch)return;this._wiredSwitch=true;this.addEventListener("change",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;inp.setAttribute("aria-checked",String(inp.checked));this._setCustomState("data-checked",inp.checked);this._internals.setFormValue(inp.checked?(inp.value||"on"):null);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!inp.checked)})}}define("contour-switch",ContourSwitch);class ContourCheck extends ContourBase{static get observed(){return["label","name","value","required","type","checked","disabled","error","help"]}static get properties(){return{label:{attribute:"label"},name:{attribute:"name"},value:{attribute:"value"},required:{attribute:"required",type:Boolean},type:{attribute:"type"},checked:{attribute:"checked",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return true}render(){this.classList.add("c-check");const label=this.getAttribute("label");const input=this.ensure("input.c-check__input",()=>{const el=document.createElement("input");el.className="c-check__input";el.type=this.getAttribute("type")==="radio"?"radio":"checkbox";return el});input.checked=this.hasAttribute("checked");if(!input.nextElementSibling||!input.nextElementSibling.classList.contains("c-check__box")){const box=document.createElement("span");box.className="c-check__box";box.setAttribute("aria-hidden","true");if(input.nextSibling)this.insertBefore(box,input.nextSibling);else this.appendChild(box)}if(label){input.setAttribute("aria-label",label);const txt=this.querySelector(":scope > span:not([class]):not(.c-check__box)")||(()=>{const el=document.createElement("span");this.appendChild(el);return el})();txt.textContent=label}if(this.hasAttribute("name"))input.name=this.getAttribute("name");if(this.hasAttribute("value"))input.value=this.getAttribute("value");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-check__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-check__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-check__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error")}enhance(){const input=this.querySelector("input");if(input&&this._internals){this._setCustomState("data-checked",input.checked);this._internals.setFormValue(input.checked?(input.value||"on"):null);this._syncValidity(this.hasAttribute("required")&&!input.checked)}if(this._wiredCheck)return;this._wiredCheck=true;this.addEventListener("change",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;this._setCustomState("data-checked",inp.checked);this._internals.setFormValue(inp.checked?(inp.value||"on"):null);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!inp.checked)})}}define("contour-check",ContourCheck);class ContourRadio extends ContourBase{static get observed(){return["label","name","value","required","checked","disabled","error","help"]}static get properties(){return{label:{attribute:"label"},name:{attribute:"name"},value:{attribute:"value"},required:{attribute:"required",type:Boolean},checked:{attribute:"checked",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return true}render(){this.classList.add("c-radio");const label=this.getAttribute("label");const input=this.ensure("input.c-radio__input",()=>{const el=document.createElement("input");el.className="c-radio__input";el.type="radio";return el});input.checked=this.hasAttribute("checked");if(this.hasAttribute("name"))input.name=this.getAttribute("name");if(this.hasAttribute("value"))input.value=this.getAttribute("value");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-radio__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-radio__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-radio__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");if(label){input.setAttribute("aria-label",label);const txt=this.querySelector(":scope > span:not([class])")||(()=>{const el=document.createElement("span");this.appendChild(el);return el})();txt.textContent=label}}enhance(){const input=this.querySelector("input");if(input&&this._internals){this._setCustomState("data-checked",input.checked);this._internals.setFormValue(input.checked?(input.value||"on"):null);this._syncValidity(this.hasAttribute("required")&&!input.checked)}if(this._wiredRadio)return;this._wiredRadio=true;this.addEventListener("change",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;this._setCustomState("data-checked",inp.checked);this._internals.setFormValue(inp.checked?(inp.value||"on"):null);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!inp.checked)})}}define("contour-radio",ContourRadio);class ContourSelect extends ContourBase{static get observed(){return["options","required","label","placeholder","disabled","error","help"]}static get properties(){return{options:{attribute:"options"},required:{attribute:"required",type:Boolean},label:{attribute:"label"},placeholder:{attribute:"placeholder"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return true}render(){this.classList.add("c-select");const options=this.getAttribute("options");const generated=new Set(this._contourGenerated||[]);const authored=Array.from(this.children).filter((n)=>!generated.has(n));if(options&&!authored.length){try{const parsed=JSON.parse(options);const select=this.ensure("select.c-select",()=>{const el=document.createElement("select");el.className="c-select";return el});select.innerHTML="";const label=this.getAttribute("label");if(label){select.setAttribute("aria-label",label)}const placeholder=this.getAttribute("placeholder");if(placeholder){const ph=document.createElement("option");ph.value="";ph.textContent=placeholder;ph.disabled=true;ph.selected=true;select.appendChild(ph)}const groups={};parsed.forEach((opt)=>{const g=(typeof opt==="object"&&opt!==null)?opt.group:null;if(g){if(!groups[g]){groups[g]=document.createElement("optgroup");groups[g].label=g;select.appendChild(groups[g])}const option=document.createElement("option");option.value=typeof opt==="string"?opt:opt.value;option.textContent=typeof opt==="string"?opt:opt.label;groups[g].appendChild(option)}else{const option=document.createElement("option");option.value=typeof opt==="string"?opt:opt.value;option.textContent=typeof opt==="string"?opt:opt.label;select.appendChild(option)}});if(select.parentNode!==this)this.appendChild(select);this.classList.remove("c-select");select.classList.add("c-select")}catch(e){}}const authoredSel=this.querySelector("select");if(authoredSel&&!authoredSel.classList.contains("c-select")){authoredSel.classList.add("c-select");this.classList.remove("c-select")}const sel=this.querySelector("select");if(sel){if(this.hasAttribute("disabled")){sel.setAttribute("disabled","");this.classList.add("is-disabled")}else{sel.removeAttribute("disabled");this.classList.remove("is-disabled")}}const label=this.getAttribute("label");if(label){let lbl=this.querySelector("label.c-select__label");if(!lbl){lbl=document.createElement("label");lbl.className="c-select__label";this.insertBefore(lbl,sel||this.firstChild)}lbl.textContent=label;if(sel)sel.setAttribute("aria-label",label)}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-select__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-select__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-select__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error")}enhance(){const select=this.querySelector("select");if(select&&this._internals){this._internals.setFormValue(select.value);this._syncValidity(this.hasAttribute("required")&&!select.value)}if(this._wiredSelect)return;this._wiredSelect=true;this.addEventListener("change",(e)=>{const sel=this.querySelector("select");if(!sel||e.target!==sel||!this._internals)return;this._internals.setFormValue(sel.value);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!sel.value)})}}define("contour-select",ContourSelect);class ContourVersion extends ContourBase{static get observed(){return["options"]}static get formAssociated(){return true}static get properties(){return{options:{attribute:"options"}}}render(){this.classList.add("c-version");const options=this.getAttribute("options");const generated=new Set(this._contourGenerated||[]);const authored=Array.from(this.children).filter((n)=>!generated.has(n));if(options&&!authored.length){try{const parsed=JSON.parse(options);const select=this.ensure("select.c-version",()=>{const el=document.createElement("select");el.className="c-version";return el});select.innerHTML="";if(!select.hasAttribute("aria-label"))select.setAttribute("aria-label","Version");parsed.forEach((opt)=>{const option=document.createElement("option");if(typeof opt==="string"){option.value=opt;option.textContent=opt}else{option.value=opt.value||opt.label;option.textContent=opt.label||opt.value;if(opt.selected)option.selected=true}select.appendChild(option)});if(select.parentNode!==this)this.appendChild(select);this.classList.remove("c-version");select.classList.add("c-version")}catch(e){}}}enhance(){if(this._wiredVersion)return;this._wiredVersion=true;const sync=()=>{const select=this.querySelector("select");if(!select||!this._internals)return;this._internals.setFormValue(select.value)};this.addEventListener("change",(e)=>{const select=this.querySelector("select");if(!select||e.target!==select)return;sync();this._emitForm("contour:change")});sync()}}define("contour-version",ContourVersion);class ContourTextarea extends ContourBase{static get observed(){return["placeholder","required","disabled","error","help"]}static get properties(){return{placeholder:{attribute:"placeholder"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return true}render(){const ta=this.ensure("textarea",()=>{const el=document.createElement("textarea");el.className="c-textarea";return el});ta.className="c-textarea";ta.placeholder=this.getAttribute("placeholder")||"";if(this.hasAttribute("required"))ta.setAttribute("required","");else ta.removeAttribute("required");if(this.hasAttribute("disabled")){ta.setAttribute("disabled","");this.classList.add("is-disabled")}else{ta.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-textarea__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-textarea__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-textarea__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error")}enhance(){const ta=this.querySelector("textarea");if(ta&&this._internals){this._internals.setFormValue(ta.value);this._syncValidity(this.hasAttribute("required")&&!ta.value.trim())}if(this._wiredTextarea)return;this._wiredTextarea=true;this.addEventListener("input",(e)=>{const t=this.querySelector("textarea");if(!t||e.target!==t||!this._internals)return;this._internals.setFormValue(t.value);this._emitForm("contour:input");this._syncValidity(this.hasAttribute("required")&&!t.value.trim())});this.addEventListener("change",(e)=>{const t=this.querySelector("textarea");if(!t||e.target!==t||!this._internals)return;this._internals.setFormValue(t.value);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!t.value.trim())})}}define("contour-textarea",ContourTextarea);class ContourInputFull extends ContourBase{static get observed(){return["type","placeholder","required","value","disabled","error","help","label"]}static get properties(){return{type:{attribute:"type"},placeholder:{attribute:"placeholder"},required:{attribute:"required",type:Boolean},value:{attribute:"value"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},label:{attribute:"label"}}}static get formAssociated(){return true}render(){this.classList.add("c-input");const input=this.ensure("input",()=>{const el=document.createElement("input");el.className="c-input";return el});input.className="c-input";input.type=this.getAttribute("type")||"text";input.placeholder=this.getAttribute("placeholder")||"";let label=this.getAttribute("label");if(!label){const field=this.closest("contour-field");if(field)label=field.getAttribute("label")}if(label)input.setAttribute("aria-label",label);else if(!input.getAttribute("aria-label"))input.setAttribute("aria-label","Input");if(this.hasAttribute("value"))input.value=this.getAttribute("value");if(this.hasAttribute("required"))input.setAttribute("required","");else input.removeAttribute("required");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-input__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-input__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-input__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error")}enhance(){const input=this.querySelector("input");if(input&&this._internals){this._internals.setFormValue(input.value);this._syncValidity(this.hasAttribute("required")&&!input.value.trim())}if(this._wiredInput)return;this._wiredInput=true;this.addEventListener("input",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;this._internals.setFormValue(inp.value);this._emitForm("contour:input");this._syncValidity(this.hasAttribute("required")&&!inp.value.trim())});this.addEventListener("change",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;this._internals.setFormValue(inp.value);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!inp.value.trim())})}}define("contour-input",ContourInputFull);class ContourInputGroup extends ContourBase{static get observed(){return["label","placeholder","clearable","submit"]}static get properties(){return{label:{attribute:"label"},placeholder:{attribute:"placeholder"},clearable:{attribute:"clearable",type:Boolean},submit:{attribute:"submit",type:Boolean}}}render(){this.classList.add("c-input-group");const icon=this.ensure("svg",()=>{const el=document.createElementNS("http://www.w3.org/2000/svg","svg");el.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href","#i-search");el.appendChild(use);return el});const input=this.ensure("input.c-input",()=>{const el=document.createElement("input");el.className="c-input";el.type="text";return el});input.placeholder=this.getAttribute("placeholder")||this.getAttribute("label")||"";const oldClear=this.querySelector(".c-input-group__clear");if(oldClear)oldClear.remove();if(this.hasAttribute("clearable")){const btn=document.createElement("button");btn.className="c-input-group__clear";btn.type="button";btn.setAttribute("aria-label","Clear");btn.textContent="×";this.appendChild(btn)}const oldSubmit=this.querySelector(".c-input-group__submit");if(oldSubmit)oldSubmit.remove();if(this.hasAttribute("submit")){const btn=document.createElement("button");btn.className="c-input-group__submit";btn.type="submit";btn.setAttribute("aria-label","Submit");btn.textContent="→";this.appendChild(btn)}}enhance(){if(this._wiredInputGroup)return;this._wiredInputGroup=true;this.addEventListener("click",(e)=>{const clear=e.target&&e.target.closest?e.target.closest(".c-input-group__clear"):null;if(clear&&this.contains(clear)){e.preventDefault();const input=this.querySelector("input.c-input");if(input){input.value="";input.focus()}this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:""}}))}})}}define("contour-input-group",ContourInputGroup);class ContourRadioList extends ContourBase{static get observed(){return["items","name","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},name:{attribute:"name"},src:{attribute:"src"}}}static get formAssociated(){return true}render(){this.classList.add("c-radio-list");this.setAttribute("role","radiogroup");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("name")||"Options");wireStates(this);loadRemote(this,"items");if(renderStates(this,"radio-list"))return;const items=remoteData(this,"items");Array.from(this.querySelectorAll("label.c-radio")).forEach((l)=>l.remove());if(items){try{const parsed=JSON.parse(items);const groupName=this.getAttribute("name")||contourId("radio-list");parsed.forEach((it)=>{const lbl=document.createElement("label");lbl.className="c-radio";const input=document.createElement("input");input.type="radio";input.className="c-radio__input";input.name=groupName;input.tabIndex=-1;if(typeof it==="string"){input.value=it;lbl.appendChild(input);lbl.appendChild(document.createTextNode(" "+it))}else{input.value=it.value||it.label;if(it.checked)input.checked=true;lbl.appendChild(input);const span=document.createElement("span");span.textContent=it.label||it.value;lbl.appendChild(span)}this.appendChild(lbl)});const radios=Array.from(this.querySelectorAll("input.c-radio__input"));const checked=radios.find((r)=>r.checked)||radios[0];if(checked)checked.tabIndex=0}catch(e){}}else{renderEmpty(this,"radio-list")}}enhance(){const sync=()=>{if(!this._internals)return;const checked=this.querySelector("input.c-radio__input:checked");this._internals.setFormValue(checked?checked.value:null)};sync();if(this._wiredRadioList)return;this._wiredRadioList=true;this.addEventListener("change",(e)=>{const input=e.target&&e.target.closest?e.target.closest("input.c-radio__input"):null;if(!input||!this.contains(input))return;sync();this._emitForm("contour:change")});this.addEventListener("keydown",(e)=>{const radios=Array.from(this.querySelectorAll("input.c-radio__input"));if(!radios.length)return;const idx=radios.indexOf(e.target);if(idx===-1)return;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";let next=-1;if(e.key==="ArrowDown")next=(idx+1)%radios.length;else if(e.key==="ArrowUp")next=(idx-1+radios.length)%radios.length;else if(e.key==="ArrowRight")next=rtl?(idx-1+radios.length)%radios.length:(idx+1)%radios.length;else if(e.key==="ArrowLeft")next=rtl?(idx+1)%radios.length:(idx-1+radios.length)%radios.length;else if(e.key==="Home")next=0;else if(e.key==="End")next=radios.length-1;else return;e.preventDefault();const before=radios.find((r)=>r.checked);for(const r of radios)r.tabIndex=-1;radios[next].tabIndex=0;radios[next].checked=true;radios[next].focus();sync();if(before!==radios[next])this._emitForm("contour:change")})}formResetCallback(){if(this._contourAuthored)this.requestRender()}}define("contour-radio-list",ContourRadioList);class ContourPressableFull extends ContourBase{static get observed(){return["disabled"]}static get properties(){return{disabled:{attribute:"disabled",type:Boolean}}}render(){this.classList.add("c-pressable");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(this.hasAttribute("disabled")){this.setAttribute("aria-disabled","true");this.setAttribute("tabindex","-1")}else{this.removeAttribute("aria-disabled");if(!this.hasAttribute("tabindex")||this.getAttribute("tabindex")==="-1")this.setAttribute("tabindex","0")}}enhance(){if(this._wiredPressable)return;this._wiredPressable=true;this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.click();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}})}}define("contour-pressable",ContourPressableFull);class ContourResizeHandleFull extends ContourBase{render(){this.classList.add("c-resize-handle");if(!this.hasAttribute("role"))this.setAttribute("role","separator");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Resize handle");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(!this.hasAttribute("aria-orientation"))this.setAttribute("aria-orientation","horizontal")}}define("contour-resize-handle",ContourResizeHandleFull);class ContourSearchTriggerFull extends ContourBase{static get observed(){return["label","shortcut"]}static get properties(){return{label:{attribute:"label"},shortcut:{attribute:"shortcut"}}}render(){this.classList.add("c-search-trigger");const label=this.getAttribute("label")||"Search";if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label);const span=this.ensure(".c-search-trigger__text",()=>{const el=document.createElement("span");el.className="c-search-trigger__text";return el});span.className="c-search-trigger__text";if(!span.textContent.trim()||span.textContent.trim()!==label)span.textContent=label;const kbd=this.ensure("kbd.c-search-trigger__kbd",()=>{const el=document.createElement("kbd");el.className="c-search-trigger__kbd";return el});kbd.className="c-search-trigger__kbd";kbd.textContent=this.getAttribute("shortcut")||"⌘K"}}define("contour-search-trigger",ContourSearchTriggerFull);class ContourShortcutListFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-shortcut-list");this.setAttribute("role","list");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-shortcut-list__title",()=>{const el=document.createElement("div");el.className="c-shortcut-list__title";el.style.padding="var(--space-sm)";el.style.fontWeight="var(--weight-semibold)";return el});t.textContent=title}}}define("contour-shortcut-list",ContourShortcutListFull);class ContourShortcutRowFull extends ContourBase{static get observed(){return["desc","key"]}static get properties(){return{desc:{attribute:"desc"},key:{attribute:"key"}}}render(){this.classList.add("c-shortcut-row");this.setAttribute("role","listitem");const key=this.getAttribute("key");const desc=this.getAttribute("desc");if(key){const k=this.ensure(".c-shortcut-row__keys",()=>{const el=document.createElement("kbd");el.className="c-shortcut-row__keys";return el});k.className="c-shortcut-row__keys";k.textContent=key}else{const k=this.querySelector(".c-shortcut-row__keys");if(k)k.remove()}if(desc){const s=this.ensure(".c-shortcut-row__label",()=>{const el=document.createElement("span");el.className="c-shortcut-row__label";return el});s.className="c-shortcut-row__label";s.textContent=desc}else{const s=this.querySelector(".c-shortcut-row__label");if(s)s.remove()}}}define("contour-shortcut-row",ContourShortcutRowFull);class ContourShortcutPanelFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-shortcut-panel");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-shortcut-panel__title",()=>{const el=document.createElement("div");el.className="c-shortcut-panel__title";return el});t.textContent=title}else{const t=this.querySelector(".c-shortcut-panel__title");if(t)t.remove()}}}define("contour-shortcut-panel",ContourShortcutPanelFull);class ContourShortcutOverlayFull extends ContourBase{static get observed(){return["title","open"]}static get properties(){return{title:{attribute:"title"},open:{attribute:"open",type:Boolean}}}render(){this.classList.add("c-shortcut-overlay");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-shortcut-overlay__title",()=>{const el=document.createElement("div");el.className="c-shortcut-overlay__title";return el});t.textContent=title}if(this.hasAttribute("open"))this.removeAttribute("hidden");else if(!this.hasAttribute("hidden"))this.setAttribute("hidden","")}show(){this.setAttribute("open","");this.removeAttribute("hidden");this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))}hide(){this.removeAttribute("open");this.setAttribute("hidden","");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))}toggle(){if(this.hasAttribute("open"))this.hide();else this.show()}enhance(){if(this._wiredShortcutOverlay)return;this._wiredShortcutOverlay=true;const keyHandler=(e)=>{if(e.key==="?"&&!e.metaKey&&!e.ctrlKey&&!e.altKey){const tag=(e.target&&e.target.tagName)||"";if(tag==="INPUT"||tag==="TEXTAREA"||(e.target&&e.target.isContentEditable))return;e.preventDefault();this.toggle()}else if(e.key==="Escape"&&this.hasAttribute("open")){this.hide()}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("click",(e)=>{if(e.target===this)this.hide()})}}define("contour-shortcut-overlay",ContourShortcutOverlayFull);class ContourRowActionFull extends ContourBase{static get observed(){return["label","disabled"]}static get properties(){return{label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean}}}render(){this.classList.add("c-row-action");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(this.hasAttribute("disabled")){this.setAttribute("aria-disabled","true");this.setAttribute("tabindex","-1")}else{this.removeAttribute("aria-disabled");if(!this.hasAttribute("tabindex")||this.getAttribute("tabindex")==="-1")this.setAttribute("tabindex","0")}const label=this.getAttribute("label");if(label&&!this.hasChildNodes())this.textContent=label}enhance(){if(this._wiredRowAction)return;this._wiredRowAction=true;this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.click();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}})}}define("contour-row-action",ContourRowActionFull);class ContourSegmented extends ContourBase{static get observed(){return["options","selected","label","value"]}static get properties(){return{options:{attribute:"options"},selected:{attribute:"selected"},label:{attribute:"label"},value:{attribute:"value"}}}render(){this.classList.add("c-segmented");const options=this.getAttribute("options");if(options){let parsed=null;try{parsed=JSON.parse(options)}catch(e){parsed=null}if(Array.isArray(parsed)){Array.from(this.querySelectorAll("button.c-segmented__option")).forEach((n)=>n.remove());const selected=this.getAttribute("selected")||this.getAttribute("value");parsed.forEach((opt,i)=>{const label=typeof opt==="string"?opt:(opt.label||opt.value||"");const val=typeof opt==="string"?opt:(opt.value||opt.label||"");const btn=document.createElement("button");btn.className="c-segmented__option";btn.type="button";btn.textContent=label;btn.dataset.value=val;if(selected!==null&&String(val)===String(selected))btn.setAttribute("aria-pressed","true");else if(selected===null&&i===0)btn.setAttribute("aria-pressed","true");else btn.setAttribute("aria-pressed","false");this.appendChild(btn)})}}}enhance(){wireSegmented(this)}}define("contour-segmented",ContourSegmented);class ContourDraggable extends ContourBase{render(){this.classList.add("c-draggable");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(!this.hasAttribute("draggable"))this.setAttribute("draggable","true")}_dragValue(){return this.getAttribute("value")||this.getAttribute("label")||(this.textContent||"").trim()||"draggable"}enhance(){if(this._wiredDraggable)return;this._wiredDraggable=true;this.addEventListener("dragstart",(e)=>{if(!e.dataTransfer)return;const value=this._dragValue();try{e.dataTransfer.effectAllowed="move"}catch(err){}e.dataTransfer.setData("text/plain",value);this.classList.add("c-draggable--dragging");this.dispatchEvent(new CustomEvent("contour:dragstart",{bubbles:true,composed:true,detail:{value}}))});this.addEventListener("dragend",()=>{this.classList.remove("c-draggable--dragging");this.dispatchEvent(new CustomEvent("contour:dragend",{bubbles:true,composed:true,detail:{value:this._dragValue()}}))});this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}));return}if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:move",{bubbles:true,composed:true,detail:{direction:e.key==="ArrowUp"?"up":"down"}}))}})}}define("contour-draggable",ContourDraggable);class ContourDragHandle extends ContourBase{render(){this.classList.add("c-drag-handle");if(!this.hasAttribute("role"))this.setAttribute("role","separator");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(!this.hasAttribute("aria-orientation"))this.setAttribute("aria-orientation","horizontal")}enhance(){if(this._wiredDragHandle)return;this._wiredDragHandle=true;this.addEventListener("keydown",(e)=>{let delta=0;if(e.key==="ArrowLeft"||e.key==="ArrowDown")delta=-1;else if(e.key==="ArrowRight"||e.key==="ArrowUp")delta=1;else if(e.key==="Home")delta=-Infinity;else if(e.key==="End")delta=Infinity;else return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:true,composed:true,detail:{key:e.key,delta}}))})}}define("contour-drag-handle",ContourDragHandle);class ContourDropIndicator extends ContourBase{static get observed(){return["label"]}static get properties(){return{label:{attribute:"label"}}}render(){this.classList.add("c-drop-indicator");this.classList.add("c-drop-indicator--visible");Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===Node.TEXT_NODE)n.remove();else if(n.nodeType===Node.ELEMENT_NODE&&n.tagName==="SPAN")n.remove()});const label=this.getAttribute("label");if(label){const t=this.ensure(".c-drop-indicator__label",()=>{const el=document.createElement("span");el.className="c-drop-indicator__label";return el});t.textContent=label}}}define("contour-drop-indicator",ContourDropIndicator);class ContourDropZone extends ContourBase{static get observed(){return["label"]}static get properties(){return{label:{attribute:"label"}}}render(){this.classList.add("c-drop-zone");Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===Node.TEXT_NODE)n.remove();else if(n.nodeType===Node.ELEMENT_NODE&&n.tagName==="SPAN")n.remove()});const label=this.getAttribute("label");if(label){const t=this.ensure(".c-drop-zone__label",()=>{const el=document.createElement("p");el.className="c-drop-zone__label";return el});t.textContent=label}}enhance(){if(this._wiredDropZone)return;this._wiredDropZone=true;const accepts=(e)=>e.dataTransfer&&Array.from(e.dataTransfer.types).includes("text/plain");const clear=()=>{this.classList.remove("c-drop-zone--active","c-drop-zone--reject")};this.addEventListener("dragenter",(e)=>{if(!e.dataTransfer)return;this.classList.toggle("c-drop-zone--reject",!accepts(e));if(accepts(e)){e.preventDefault();this.classList.add("c-drop-zone--active")}});this.addEventListener("dragover",(e)=>{if(!e.dataTransfer)return;this.classList.toggle("c-drop-zone--reject",!accepts(e));if(accepts(e)){e.preventDefault();this.classList.add("c-drop-zone--active")}});this.addEventListener("dragleave",clear);this.addEventListener("drop",(e)=>{if(!accepts(e))return;e.preventDefault();clear();const value=e.dataTransfer.getData("text/plain")||"";this.dispatchEvent(new CustomEvent("contour:drop",{bubbles:true,composed:true,detail:{value,label:this.getAttribute("label")}}))})}}define("contour-drop-zone",ContourDropZone);class ContourResizable extends ContourBase{static get observed(){return["direction","value"]}static get properties(){return{direction:{attribute:"direction"},value:{attribute:"value"}}}render(){this.classList.add("c-resizable");this.classList.remove("c-resizable--vertical","c-resizable--horizontal");const vertical=this.getAttribute("direction")==="vertical";this.classList.add(vertical?"c-resizable--vertical":"c-resizable--horizontal");if(!this.querySelector(".c-resizable__pane")){const p1=document.createElement("div");p1.className="c-resizable__pane";p1.textContent="Pane A";const handle=document.createElement("div");handle.className="c-resize-handle";handle.setAttribute("tabindex","0");handle.setAttribute("role","separator");const p2=document.createElement("div");p2.className="c-resizable__pane";p2.textContent="Pane B";this.appendChild(p1);this.appendChild(handle);this.appendChild(p2)}const v=this._splitValue||this.getAttribute("value");if(v){const p1=this.querySelector(".c-resizable__pane");if(p1)p1.style.flex=`0 0 ${v}%`}}enhance(){if(this._wiredResizable)return;this._wiredResizable=true;const setSplit=(clientX,clientY)=>{const rect=this.getBoundingClientRect();const vertical=this.classList.contains("c-resizable--vertical");const span=vertical?rect.height:rect.width;const pos=vertical?clientY-rect.top:clientX-rect.left;const frac=span>0?Math.min(0.9,Math.max(0.1,pos/span)):0.5;const p1=this.querySelector(".c-resizable__pane");if(p1)p1.style.flex=`0 0 ${Math.round(frac * 100)}%`;this._splitValue=String(Math.round(frac*100))};this.addEventListener("pointerdown",(e)=>{const handle=this.querySelector(".c-resize-handle");if(!handle||e.target!==handle)return;this._resizing=true;handle.classList.add("c-resize-handle--dragging");if(handle.setPointerCapture){try{handle.setPointerCapture(e.pointerId)}catch(err){}}e.preventDefault()});this.addEventListener("pointermove",(e)=>{if(!this._resizing)return;setSplit(e.clientX,e.clientY)});const stopResize=(e)=>{if(!this._resizing)return;this._resizing=false;if(this._splitValue){this.setAttribute("value",this._splitValue);this._splitValue=null}const handle=this.querySelector(".c-resize-handle");if(handle){handle.classList.remove("c-resize-handle--dragging");if(handle.hasPointerCapture&&handle.hasPointerCapture(e.pointerId)){try{handle.releasePointerCapture(e.pointerId)}catch(err){}}}};this.addEventListener("pointerup",stopResize);this.addEventListener("pointercancel",stopResize);this.addEventListener("keydown",(e)=>{const handle=this.querySelector(".c-resize-handle");if(!handle||document.activeElement!==handle)return;const vertical=this.classList.contains("c-resizable--vertical");const cur=parseFloat(this.getAttribute("value"))||50;if(e.key==="ArrowLeft"||e.key==="ArrowDown"){e.preventDefault();setSplit&&setSplit;const p1=this.querySelector(".c-resizable__pane");if(p1){const nv=Math.max(10,cur-5);p1.style.flex=`0 0 ${nv}%`;this.setAttribute("value",String(nv))}}else if(e.key==="ArrowRight"||e.key==="ArrowUp"){e.preventDefault();const p1=this.querySelector(".c-resizable__pane");if(p1){const nv=Math.min(90,cur+5);p1.style.flex=`0 0 ${nv}%`;this.setAttribute("value",String(nv))}}})}}define("contour-resizable",ContourResizable);class ContourTableWrap extends ContourBase{static get observed(){return[]}static get properties(){return{}}render(){this.classList.add("c-table-wrap");Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===Node.TEXT_NODE)n.remove();else if(n.nodeType===Node.ELEMENT_NODE&&n.tagName==="SPAN")n.remove()});if(!this.querySelector("table")){const t=document.createElement("table");t.className="c-table";const thead=document.createElement("thead");const tr=document.createElement("tr");for(const h of["A","B"]){const th=document.createElement("th");th.textContent=h;tr.appendChild(th)}thead.appendChild(tr);t.appendChild(thead);const tbody=document.createElement("tbody");const tr2=document.createElement("tr");for(const v of["1","2"]){const td=document.createElement("td");td.textContent=v;tr2.appendChild(td)}tbody.appendChild(tr2);t.appendChild(tbody);this.appendChild(t)}}}define("contour-table-wrap",ContourTableWrap);class ContourScrollArea extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-scroll-area");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-scroll-area__title",()=>{const el=document.createElement("div");el.className="c-scroll-area__title";el.style.padding="var(--space-sm)";el.style.fontWeight="var(--weight-semibold)";return el});t.textContent=title}}}define("contour-scroll-area",ContourScrollArea);class ContourBtn extends ContourBase{static get observed(){return["variant","size","color","label","disabled"]}static get properties(){return{variant:{attribute:"variant"},size:{attribute:"size"},color:{attribute:"color"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean}}}render(){this.classList.add("c-btn");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-btn--"))this.classList.remove(c)});for(const attr of["variant","size","color"]){const val=this.getAttribute(attr);if(val)this.classList.add("c-btn--"+val)}if(!this.hasAttribute("role"))this.setAttribute("role","button");if(this.hasAttribute("disabled")){this.setAttribute("aria-disabled","true");this.setAttribute("tabindex","-1")}else{this.removeAttribute("aria-disabled");if(!this.hasAttribute("tabindex")||this.getAttribute("tabindex")==="-1")this.setAttribute("tabindex","0")}const label=this.getAttribute("label");if(label&&!this.hasChildNodes())this.textContent=label;if(label&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label)}enhance(){if(this._wiredBtn)return;this._wiredBtn=true;this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.click();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}})}}define("contour-btn",ContourBtn);class ContourApp extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-app");const header=this.ensure(".c-app__header",()=>{const el=document.createElement("header");el.className="c-app__header";return el});const title=this.getAttribute("title");if(title){const t=this.ensure(".c-app__title",()=>{const el=document.createElement("div");el.className="c-app__title";return el});t.textContent=title;if(t.parentNode!==header)header.appendChild(t)}const main=this.ensure(".c-app__main",()=>{const el=document.createElement("main");el.className="c-app__main";return el});if(main.parentNode!==this)this.appendChild(main);if(header.parentNode!==this)this.insertBefore(header,main)}}define("contour-app",ContourApp);class ContourAppBody extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-app-body");const main=this.ensure(".c-app-body__main",()=>{const el=document.createElement("main");el.className="c-app-body__main";return el});const title=this.getAttribute("title");if(title){const t=this.ensure(".c-app-body__title",()=>{const el=document.createElement("div");el.className="c-app-body__title";return el});t.textContent=title;if(t.parentNode!==main)main.appendChild(t)}if(main.parentNode!==this)this.appendChild(main)}}define("contour-app-body",ContourAppBody);class ContourBtnGroup extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-btn-group");this.setAttribute("role","group");if(this.getAttribute("title"))this.setAttribute("aria-label",this.getAttribute("title"));if(!this.querySelector(".c-btn")){for(const lbl of["One","Two","Three"]){const b=document.createElement("button");b.className="c-btn c-btn--sm";b.type="button";b.textContent=lbl;this.appendChild(b)}}}enhance(){if(this._wiredBtnGroup)return;this._wiredBtnGroup=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-btn"):null;if(btn&&this.contains(btn)){const buttons=Array.from(this.querySelectorAll(".c-btn"));const index=buttons.indexOf(btn);this.dispatchEvent(new CustomEvent("contour:btn-group-change",{bubbles:true,composed:true,detail:{index,label:btn.textContent}}))}});this.addEventListener("keydown",(e)=>{const buttons=Array.from(this.querySelectorAll(".c-btn"));if(!buttons.length)return;const active=document.activeElement;const idx=buttons.indexOf(active);let next=-1;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";if(e.key==="ArrowDown")next=idx<0?0:Math.min(buttons.length-1,idx+1);else if(e.key==="ArrowUp")next=idx<0?0:Math.max(0,idx-1);else if(e.key==="ArrowRight")next=rtl?(idx<0?0:Math.max(0,idx-1)):(idx<0?0:Math.min(buttons.length-1,idx+1));else if(e.key==="ArrowLeft")next=rtl?(idx<0?0:Math.min(buttons.length-1,idx+1)):(idx<0?0:Math.max(0,idx-1));else if(e.key==="Home")next=0;else if(e.key==="End")next=buttons.length-1;if(next>=0&&next!==idx){e.preventDefault();buttons[next].focus()}})}}define("contour-btn-group",ContourBtnGroup);class ContourRangeScale extends ContourBase{static get observed(){return["label","value","ticks"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},ticks:{attribute:"ticks"}}}render(){this.classList.add("c-range-scale");this.setAttribute("role","group");if(this.getAttribute("label"))this.setAttribute("aria-label",this.getAttribute("label"));const label=this.getAttribute("label");if(label){const t=this.ensure(".c-range-scale__label",()=>{const el=document.createElement("span");el.className="c-range-scale__label";return el});t.textContent=label}const ticksAttr=this.getAttribute("ticks");Array.from(this.querySelectorAll(".c-range-scale__tick")).forEach((n)=>n.remove());if(ticksAttr){ticksAttr.split(",").map((s)=>s.trim()).filter(Boolean).forEach((tk)=>{const t=document.createElement("span");t.className="c-range-scale__tick";t.textContent=tk;this.appendChild(t)})}}enhance(){if(this._wiredRangeScale)return;this._wiredRangeScale=true;this.addEventListener("input",(e)=>{const t=e.target;if(t&&t.matches&&t.matches("input")){this.dispatchEvent(new CustomEvent("contour:range-change",{bubbles:true,composed:true,detail:{value:t.value}}))}});this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.matches&&t.matches("input")){this.dispatchEvent(new CustomEvent("contour:range-change",{bubbles:true,composed:true,detail:{value:t.value}}))}})}}define("contour-range-scale",ContourRangeScale);class ContourTimeRange extends ContourBase{static get observed(){return["label","value","ticks"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},ticks:{attribute:"ticks"}}}render(){this.classList.add("c-time-range");this.setAttribute("role","group");if(this.getAttribute("label"))this.setAttribute("aria-label",this.getAttribute("label"));const label=this.getAttribute("label");if(label){const t=this.ensure(".c-time-range__label",()=>{const el=document.createElement("span");el.className="c-time-range__label";return el});t.textContent=label}const ticksAttr=this.getAttribute("ticks");Array.from(this.querySelectorAll(".c-time-range__tick")).forEach((n)=>n.remove());if(ticksAttr){ticksAttr.split(",").map((s)=>s.trim()).filter(Boolean).forEach((tk)=>{const t=document.createElement("span");t.className="c-time-range__tick";t.textContent=tk;this.appendChild(t)})}}enhance(){if(this._wiredTimeRange)return;this._wiredTimeRange=true;this.addEventListener("input",(e)=>{const t=e.target;if(t&&t.matches&&t.matches("input")){this.dispatchEvent(new CustomEvent("contour:time-range-change",{bubbles:true,composed:true,detail:{value:t.value}}))}});this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.matches&&t.matches("input")){this.dispatchEvent(new CustomEvent("contour:time-range-change",{bubbles:true,composed:true,detail:{value:t.value}}))}})}}define("contour-time-range",ContourTimeRange);function wireMapItems(host,itemSelector,tooltipClass){if(host._wiredMapItems)return;host._wiredMapItems=true;const items=()=>Array.from(host.querySelectorAll(itemSelector));const showTip=(e)=>{const tip=host.querySelector(tooltipClass);if(!tip)return;const item=e&&e.target&&typeof e.target.closest==="function"?e.target.closest(itemSelector):null;if(!item||!host.contains(item)){tip.setAttribute("hidden","");return}const title=item.getAttribute("title");if(title)tip.textContent=title;const rect=host.getBoundingClientRect();const ir=item.getBoundingClientRect();tip.style.setProperty("--chart-tip-inline-start",(ir.left-rect.left+ir.width/2)+"px");tip.style.setProperty("--chart-tip-block-start",(ir.top-rect.top)+"px");tip.removeAttribute("hidden")};const hideTip=()=>{const tip=host.querySelector(tooltipClass);if(tip)tip.setAttribute("hidden","")};host.addEventListener("mouseover",showTip);host.addEventListener("mouseout",(e)=>{if(!e.relatedTarget||!host.contains(e.relatedTarget))hideTip()});host.addEventListener("focusin",(e)=>{const item=e&&e.target&&typeof e.target.closest==="function"?e.target.closest(itemSelector):null;if(item&&host.contains(item))showTip({target:item})});host.addEventListener("focusout",(e)=>{if(!host.contains(e.relatedTarget))hideTip()});host.addEventListener("click",(e)=>{const item=e&&e.target&&typeof e.target.closest==="function"?e.target.closest(itemSelector):null;if(!item||!host.contains(item))return;const all=items();const index=all.indexOf(item);if(index<0)return;host.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index,label:item.getAttribute("title")||item.textContent.trim()}}))});host.addEventListener("keydown",(e)=>{const item=e&&e.target&&typeof e.target.closest==="function"?e.target.closest(itemSelector):null;if(!item||!host.contains(item))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();const all=items();const index=all.indexOf(item);if(index<0)return;host.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index,label:item.getAttribute("title")||item.textContent.trim()}}))}const all=items();const idx=all.indexOf(item);if(idx<0)return;let next=-1;const rtl=(host.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";if(e.key==="ArrowDown")next=Math.min(idx+1,all.length-1);else if(e.key==="ArrowUp")next=Math.max(idx-1,0);else if(e.key==="ArrowRight")next=rtl?Math.max(idx-1,0):Math.min(idx+1,all.length-1);else if(e.key==="ArrowLeft")next=rtl?Math.min(idx+1,all.length-1):Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=all.length-1;if(next<0||next===idx)return;e.preventDefault();all.forEach((c,i)=>c.setAttribute("tabindex",i===next?"0":"-1"));try{all[next].focus()}catch(err){}})}class ContourMinimap extends ContourBase{static get observed(){return["label","viewport","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},viewport:{attribute:"viewport"},src:{attribute:"src"}}}render(){this.classList.add("c-minimap");this.setAttribute("role","img");this.setAttribute("aria-label","Minimap");wireStates(this);loadRemote(this,["label","viewport"]);if(renderStates(this,"minimap"))return;const label=remoteData(this,"label")||(this._remoteData&&this._remoteData.label);const viewport=remoteData(this,"viewport")||(this._remoteData&&(this._remoteData.viewport||this._remoteData.value));if(!label&&!viewport){renderEmpty(this,"minimap");return}if(label){const l=this.ensure(".c-minimap__label",()=>{const el=document.createElement("span");el.className="c-minimap__label";return el});l.textContent=label}else{const l=this.querySelector(".c-minimap__label");if(l)l.remove()}if(viewport){const v=this.ensure(".c-minimap__viewport",()=>{const el=document.createElement("div");el.className="c-minimap__viewport";return el});v.textContent=viewport}else{const v=this.querySelector(".c-minimap__viewport");if(v)v.remove()}}enhance(){if(this._wiredMinimap)return;this._wiredMinimap=true;if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");let dragging=false;this.addEventListener("pointerdown",(e)=>{const vp=this.querySelector(".c-minimap__viewport");if(!vp||!vp.contains(e.target))return;dragging=true;try{vp.setPointerCapture(e.pointerId)}catch(err){}});this.addEventListener("pointermove",(e)=>{if(!dragging)return;this.dispatchEvent(new CustomEvent("contour:move",{detail:{direction:"drag"},bubbles:true,composed:true}))});this.addEventListener("pointerup",()=>{dragging=false});this.addEventListener("keydown",(e)=>{let dir=null;if(e.key==="ArrowUp")dir="up";else if(e.key==="ArrowDown")dir="down";else if(e.key==="ArrowLeft")dir="left";else if(e.key==="ArrowRight")dir="right";else if(e.key==="Home")dir="home";else if(e.key==="End")dir="end";if(!dir)return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:move",{detail:{direction:dir},bubbles:true,composed:true}))})}}define("contour-minimap",ContourMinimap);class ContourCoordinate extends ContourBase{static get observed(){return["value","format","locale","precision","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{value:{attribute:"value"},format:{attribute:"format"},locale:{attribute:"locale"},precision:{attribute:"precision"},src:{attribute:"src"}}}render(){this.classList.add("c-coordinate");wireStates(this);loadRemote(this,"value");if(renderStates(this,"coordinate"))return;const value=remoteData(this,"value")||(this._remoteData&&(this._remoteData.value||this._remoteData.coordinate));if(!value){renderEmpty(this,"coordinate");return}const format=this.getAttribute("format")||"decimal";let text=String(value);if(format==="dms"){const parts=String(value).split(/[,\s]+/).map(Number);if(parts.length>=2&&Number.isFinite(parts[0])&&Number.isFinite(parts[1])){const prec=parseInt(this.getAttribute("precision")||"1",10);const secDigits=Number.isFinite(prec)&&prec>=0?prec:1;const toDMS=(d,axis)=>{const deg=Math.floor(Math.abs(d));const min=Math.floor((Math.abs(d)-deg)*60);const sec=(((Math.abs(d)-deg)*60)-min)*60;const hemi=axis==="lat"?(d<0?"S":"N"):(d<0?"W":"E");return deg+"°"+min+"'"+sec.toFixed(secDigits)+'"'+hemi};text=toDMS(parts[0],"lat")+" "+toDMS(parts[1],"lon")}}else if(format==="web-mercator"){const parts=String(value).split(/[,\s]+/).map(Number);if(parts.length>=2&&Number.isFinite(parts[0])&&Number.isFinite(parts[1])){const x=parts[1]*20037508.34/180;const y=Math.log(Math.tan((90+parts[0])*Math.PI/360))/(Math.PI/180)*20037508.34/180;text=x.toFixed(2)+", "+y.toFixed(2)}}else{text=formatValue(value,this.getAttribute("format"),this.getAttribute("locale"))}const span=this.ensure(".c-coordinate__value",()=>{const el=document.createElement("span");el.className="c-coordinate__value";el.setAttribute("role","status");el.setAttribute("aria-live","polite");return el});span.textContent=text;let btn=this.querySelector(".c-coordinate__copy");if(!btn){btn=document.createElement("button");btn.type="button";btn.className="c-coordinate__copy";btn.textContent="Copy";btn.setAttribute("aria-label","Copy coordinate");this.appendChild(btn)}btn.onclick=()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText){navigator.clipboard.writeText(text).catch(()=>{fallbackCopy(text)})}else{fallbackCopy(text)}}catch(e){fallbackCopy(text)}this.dispatchEvent(new CustomEvent("contour:copy",{detail:{text},bubbles:true,composed:true}))};function fallbackCopy(t){try{const ta=document.createElement("textarea");ta.value=t;ta.style.position="fixed";ta.style.opacity="0";document.body.appendChild(ta);ta.select();document.execCommand("copy");document.body.removeChild(ta)}catch(e){}}}}define("contour-coordinate",ContourCoordinate);class ContourLayerPanel extends ContourBase{static get observed(){return["label","items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","allow-rename","allow-remove","allow-duplicate","allow-zoom"]}static get properties(){return{label:{attribute:"label"},items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-layer-panel");this.setAttribute("role","group");this.setAttribute("aria-label","Layer panel");wireStates(this);loadRemote(this,"items");if(renderStates(this,"layer-panel"))return;const items=remoteData(this,"items");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-layer-panel__label",()=>{const el=document.createElement("span");el.className="c-layer-panel__label";return el});l.textContent=label}else{const l=this.querySelector(".c-layer-panel__label");if(l)l.remove()}const authoredLayerItems=Array.from(this.querySelectorAll(":scope > .c-layer-panel__item"));const savedVisibility=new Map();this.querySelectorAll(".c-layer-panel__item").forEach((el)=>{const nm=el.querySelector(".c-layer-panel__name");const tg=el.querySelector(".c-layer-panel__toggle");if(nm&&tg){const v=tg.hasAttribute("aria-pressed")?tg.getAttribute("aria-pressed")==="true":!!tg.checked;savedVisibility.set(nm.textContent,v)}});let parsed=null;if(authoredLayerItems.length){parsed=authoredLayerItems.map((el)=>{const nm=el.querySelector(".c-layer-panel__name");const tg=el.querySelector(".c-layer-panel__toggle");const visible=tg?(tg.hasAttribute("aria-pressed")?tg.getAttribute("aria-pressed")==="true":!!tg.checked):true;const cap=el.querySelector(".c-layer-panel__caption");return{name:nm?nm.textContent:"",visible,caption:cap?cap.textContent:(el.dataset.caption||undefined)}});authoredLayerItems.forEach((el)=>el.remove())}else if(items){try{parsed=JSON.parse(items);Array.from(this.querySelectorAll(".c-layer-panel__item")).forEach((el)=>el.remove())}catch(e){}}if(parsed){parsed.forEach((it)=>{const name=typeof it==="string"?it:(it.name||it.label||"");const caption=(typeof it==="object"&&it)?(it.caption||it.subtitle||""):"";const item=document.createElement("div");item.className="c-layer-panel__item"+(it.dragging?" c-layer-panel__item--dragging":"");const toggle=document.createElement("button");toggle.type="button";toggle.className="c-layer-panel__toggle";toggle.setAttribute("part","visibility-toggle");toggle.setAttribute("aria-label","Toggle "+(name||"layer"));const isVisible=savedVisibility.has(name)?savedVisibility.get(name):(typeof it==="object"&&it.visible!==false);toggle.setAttribute("aria-pressed",String(!!isVisible));toggle.checked=!!isVisible;toggle.innerHTML=isVisible?'<svg aria-hidden="true"><use href="#i-check" /></svg>':'<svg aria-hidden="true"><use href="#i-minus" /></svg>';item.appendChild(toggle);const nm=document.createElement("span");nm.className="c-layer-panel__name";nm.textContent=name;item.appendChild(nm);if(caption){const cap=document.createElement("span");cap.className="c-layer-panel__caption";cap.textContent=caption;item.appendChild(cap)}const opacity=document.createElement("input");opacity.type="range";opacity.className="c-layer-panel__opacity";opacity.min="0";opacity.max="100";opacity.setAttribute("aria-label","Opacity of "+(name||"layer"));opacity.value=(typeof it==="object"&&it.opacity!=null)?it.opacity:"100";item.appendChild(opacity);if(this.getAttribute("allow-rename")!=="false"){const renameBtn=document.createElement("button");renameBtn.type="button";renameBtn.className="c-layer-panel__rename";renameBtn.textContent="Rename";renameBtn.setAttribute("aria-label","Rename "+(name||"layer"));item.appendChild(renameBtn)}if(this.getAttribute("allow-duplicate")!=="false"){const dupBtn=document.createElement("button");dupBtn.type="button";dupBtn.className="c-layer-panel__duplicate";dupBtn.textContent="Duplicate";dupBtn.setAttribute("aria-label","Duplicate "+(name||"layer"));item.appendChild(dupBtn)}if(this.getAttribute("allow-zoom")!=="false"){const zoomBtn=document.createElement("button");zoomBtn.type="button";zoomBtn.className="c-layer-panel__zoom";zoomBtn.textContent="Zoom";zoomBtn.setAttribute("aria-label","Zoom to "+(name||"layer"));item.appendChild(zoomBtn)}if(this.getAttribute("allow-remove")!=="false"){const removeBtn=document.createElement("button");removeBtn.type="button";removeBtn.className="c-layer-panel__remove";removeBtn.innerHTML='<svg aria-hidden="true"><use href="#i-minus" /></svg>';removeBtn.setAttribute("aria-label","Remove "+(name||"layer"));item.appendChild(removeBtn)}const projSel=document.createElement("select");projSel.className="c-select c-layer-panel__projection";projSel.setAttribute("aria-label","Projection of "+(name||"layer"));["EPSG:4326","EPSG:3857"].forEach((p)=>{const o=document.createElement("option");o.value=p;o.textContent=p;projSel.appendChild(o)});item.appendChild(projSel);this.appendChild(item)})}if(!parsed&&!authoredLayerItems.length&&!items){Array.from(this.querySelectorAll(".c-layer-panel__item")).forEach((el)=>el.remove());renderEmpty(this,"layer-panel")}}enhance(){if(this._wiredLayerPanel)return;this._wiredLayerPanel=true;this.addEventListener("change",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-layer-panel__item"):null;if(!item||!this.contains(item))return;const name=item.querySelector(".c-layer-panel__name")?.textContent||"";if(e.target.classList.contains("c-layer-panel__toggle")){const now=(typeof e.target.checked==="boolean")?e.target.checked:(e.target.getAttribute("aria-pressed")!=="true");e.target.checked=now;e.target.setAttribute("aria-pressed",String(now));e.target.innerHTML=now?'<svg aria-hidden="true"><use href="#i-check" /></svg>':'<svg aria-hidden="true"><use href="#i-minus" /></svg>';this.dispatchEvent(new CustomEvent("contour:layer-visibility",{bubbles:true,composed:true,detail:{name,visible:now}}))}else if(e.target.classList.contains("c-layer-panel__opacity")){this.dispatchEvent(new CustomEvent("contour:layer-opacity",{bubbles:true,composed:true,detail:{name,opacity:Number(e.target.value)}}))}else if(e.target.classList.contains("c-layer-panel__projection")){this.dispatchEvent(new CustomEvent("contour:layer-projection",{bubbles:true,composed:true,detail:{name,projection:e.target.value}}))}});this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest("button"):null;if(!btn||!this.contains(btn))return;const item=btn.closest(".c-layer-panel__item");if(btn.classList.contains("c-layer-panel__toggle")){if(!item)return;const name=item.querySelector(".c-layer-panel__name")?.textContent||"";const now=btn.getAttribute("aria-pressed")!=="true";btn.setAttribute("aria-pressed",String(now));btn.checked=now;btn.innerHTML=now?'<svg aria-hidden="true"><use href="#i-check" /></svg>':'<svg aria-hidden="true"><use href="#i-minus" /></svg>';this.dispatchEvent(new CustomEvent("contour:layer-visibility",{bubbles:true,composed:true,detail:{name,visible:now}}));return}if(!item)return;const name=item.querySelector(".c-layer-panel__name")?.textContent||"";if(btn.classList.contains("c-layer-panel__rename")){const nm=item.querySelector(".c-layer-panel__name");if(nm){const input=document.createElement("input");input.type="text";input.className="c-input c-layer-panel__rename-input";input.value=name;input.setAttribute("aria-label","Rename layer");nm.replaceWith(input);input.focus();input.select();const commit=()=>{const trimmed=(input.value||"").trim();const span=document.createElement("span");span.className="c-layer-panel__name";span.textContent=trimmed||name;input.replaceWith(span);if(trimmed&&trimmed!==name){this.dispatchEvent(new CustomEvent("contour:layer-rename",{bubbles:true,composed:true,detail:{name,newName:trimmed}}))}};input.addEventListener("keydown",(ev)=>{if(ev.key==="Enter"){ev.preventDefault();commit()}else if(ev.key==="Escape"){ev.preventDefault();input.value=name;commit()}});input.addEventListener("blur",commit,{once:true})}}else if(btn.classList.contains("c-layer-panel__duplicate")){this.dispatchEvent(new CustomEvent("contour:layer-duplicate",{bubbles:true,composed:true,detail:{name}}))}else if(btn.classList.contains("c-layer-panel__zoom")){this.dispatchEvent(new CustomEvent("contour:layer-zoom",{bubbles:true,composed:true,detail:{name}}))}else if(btn.classList.contains("c-layer-panel__remove")){this.dispatchEvent(new CustomEvent("contour:layer-remove",{bubbles:true,composed:true,detail:{name}}))}});this.addEventListener("keydown",(e)=>{if(e.target&&e.target.classList&&e.target.classList.contains("c-layer-panel__toggle")&&(e.key==="Enter"||e.key===" ")){e.preventDefault();e.target.click();return}const item=e.target&&e.target.closest?e.target.closest(".c-layer-panel__item"):null;if(!item||!this.contains(item))return;if(!(e.altKey)||(e.key!=="ArrowUp"&&e.key!=="ArrowDown"))return;e.preventDefault();const items=Array.from(this.querySelectorAll(".c-layer-panel__item"));const idx=items.indexOf(item);if(idx<0)return;const dir=e.key==="ArrowUp"?-1:1;const newIdx=idx+dir;if(newIdx<0||newIdx>=items.length)return;item.classList.add("c-layer-panel__item--dragging");if(dir<0)this.insertBefore(item,items[newIdx]);else this.insertBefore(items[newIdx],item);item.focus();setTimeout(()=>item.classList.remove("c-layer-panel__item--dragging"),200);const layerIds=Array.from(this.querySelectorAll(".c-layer-panel__item")).map((el)=>el.querySelector(".c-layer-panel__name")?.textContent||"");this.dispatchEvent(new CustomEvent("contour:layer-reorder",{bubbles:true,composed:true,detail:{layerIds}}))})}}define("contour-layer-panel",ContourLayerPanel);class ContourTimeSlider extends ContourBase{static get observed(){return["label","value","loop","speed","speeds","show-loop","loop-label","current-time","time-format","is-playing","play-label","pause-label","time-label","speed-label"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},distance:{attribute:"distance"},resolution:{attribute:"resolution"},latitude:{attribute:"latitude"},src:{attribute:"src"},loop:{attribute:"loop",type:Boolean},speed:{attribute:"speed"},speeds:{attribute:"speeds"},showLoop:{attribute:"show-loop",type:Boolean},loopLabel:{attribute:"loop-label"},currentTime:{attribute:"current-time"},timeFormat:{attribute:"time-format"},isPlaying:{attribute:"is-playing",type:Boolean},playLabel:{attribute:"play-label"},pauseLabel:{attribute:"pause-label"},timeLabel:{attribute:"time-label"},speedLabel:{attribute:"speed-label"}}}render(){this.classList.add("c-time-slider");const play=this.ensure(".c-time-slider__play",()=>{const el=document.createElement("button");el.className="c-time-slider__play";el.type="button";el.setAttribute("aria-label",this.getAttribute("play-label")||"Play");el.setAttribute("data-state","play");const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href","#i-play");svg.appendChild(use);el.appendChild(svg);return el});const track=this.ensure(".c-time-slider__track",()=>{const el=document.createElement("input");el.className="c-time-slider__track";el.type="range";el.min="0";el.max="100";el.setAttribute("aria-label",this.getAttribute("time-label")||"Time");return el});const _attrVal=this.getAttribute("value")||"0";if(this._timeSliderAttrLast!==_attrVal){track.value=_attrVal;this._timeSliderAttrLast=_attrVal}track.setAttribute("aria-label",this.getAttribute("label")||this.getAttribute("time-label")||"Time");const time=this.ensure(".c-time-slider__time",()=>{const el=document.createElement("span");el.className="c-time-slider__time";return el});const ct=this.getAttribute("current-time");time.textContent=ct?ct:(this.getAttribute("label")||"");let speeds=null;const speedsAttr=this.getAttribute("speeds");if(speedsAttr){try{speeds=JSON.parse(speedsAttr)}catch(e){speeds=null}}const speedSel=this.ensure(".c-time-slider__speed",()=>{const el=document.createElement("select");el.className="c-select c-time-slider__speed";el.setAttribute("aria-label",this.getAttribute("speed-label")||"Speed");return el});speedSel.innerHTML="";const speedList=Array.isArray(speeds)?speeds:[0.5,1,2,5,10];speedList.forEach((sp)=>{const opt=document.createElement("option");opt.value=String(sp);opt.textContent=String(sp);if(String(sp)===(this.getAttribute("speed")||""))opt.selected=true;speedSel.appendChild(opt)});const speedAttr=this.getAttribute("speed");if(speedAttr)speedSel.value=speedAttr;const showLoop=this.hasAttribute("show-loop");if(showLoop){const loopBtn=this.ensure(".c-time-slider__loop",()=>{const el=document.createElement("button");el.className="c-time-slider__loop";el.type="button";el.setAttribute("aria-label",this.getAttribute("loop-label")||"Loop");return el});loopBtn.setAttribute("aria-pressed",this.hasAttribute("loop")?"true":"false");loopBtn.textContent=this.getAttribute("loop-label")||"Loop"}else{const lb=this.querySelector(".c-time-slider__loop");if(lb)lb.remove()}if(this.hasAttribute("is-playing")){play.setAttribute("data-state","pause");play.setAttribute("aria-label",this.getAttribute("pause-label")||"Pause");const use=play.querySelector("use");if(use)use.setAttribute("href","#i-pause")}}enhance(){if(this._wiredTimeSlider)return;this._wiredTimeSlider=true;let timer=undefined;const stop=()=>{if(timer!==undefined){clearInterval(timer);timer=undefined}};const step=()=>{const track=this.querySelector(".c-time-slider__track");if(!track){stop();return}const max=Number(track.max)||100;const loop=this.hasAttribute("loop");let next=(Number(track.value)||0)+1;if(next>max){if(loop)next=0;else next=max}track.value=String(next);this.dispatchEvent(new CustomEvent("contour:time-change",{detail:{value:String(next)},bubbles:true,composed:true}));if(!loop&&next>=max){stop();const btn=this.querySelector(".c-time-slider__play");if(btn){btn.setAttribute("data-state","play");btn.setAttribute("aria-label",this.getAttribute("play-label")||"Play");const use=btn.querySelector("use");if(use)use.setAttribute("href","#i-play")}}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-time-slider__play"):null;if(btn){const playing=btn.getAttribute("data-state")==="play";btn.setAttribute("data-state",playing?"pause":"play");btn.setAttribute("aria-label",playing?(this.getAttribute("pause-label")||"Pause"):(this.getAttribute("play-label")||"Play"));const use=btn.querySelector("use");if(use)use.setAttribute("href",playing?"#i-pause":"#i-play");if(playing){stop();const speed=parseFloat(this.getAttribute("speed")||"1")||1;const delay=Math.max(100,1000/speed);timer=setInterval(step,delay);this.dispatchEvent(new CustomEvent("contour:play",{bubbles:true,composed:true}))}else{stop();this.dispatchEvent(new CustomEvent("contour:pause",{bubbles:true,composed:true}))}return}const loopBtn=e.target&&e.target.closest?e.target.closest(".c-time-slider__loop"):null;if(loopBtn){const next=loopBtn.getAttribute("aria-pressed")!=="true";loopBtn.setAttribute("aria-pressed",String(next));this.toggleAttribute("loop",next);this.dispatchEvent(new CustomEvent("contour:loop-change",{detail:{loop:next},bubbles:true,composed:true}))}});this.addEventListener("change",(e)=>{const sel=e.target&&e.target.closest?e.target.closest(".c-time-slider__speed"):null;if(!sel)return;const speed=Number(sel.value);this.dispatchEvent(new CustomEvent("contour:speed-change",{detail:{speed},bubbles:true,composed:true}))});onDispose(this,stop)}disconnectedCallback(){super.disconnectedCallback();this._wiredTimeSlider=false}}define("contour-time-slider",ContourTimeSlider);class ContourHexbin extends ContourBase{static get observed(){return["label","cells","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},cells:{attribute:"cells"},src:{attribute:"src"}}}render(){this.classList.add("c-hexbin");this.setAttribute("role","img");this.setAttribute("aria-label","Hexbin");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-hexbin__label",()=>{const el=document.createElement("span");el.className="c-hexbin__label";return el});l.textContent=label}else{const l=this.querySelector(".c-hexbin__label");if(l)l.remove()}wireStates(this);loadRemote(this,"cells");if(renderStates(this,"hexbin"))return;const cells=remoteData(this,"cells");const effectiveCells=cells||(this._remoteData&&this._remoteData.cells?JSON.stringify(this._remoteData.cells):null);const authoredCells=Array.from(this.querySelectorAll(":scope > .c-hexbin__cell"));let parsed=null;if(authoredCells.length){parsed=authoredCells.map((el)=>el.textContent||el.getAttribute("title")||"");authoredCells.forEach((el)=>el.remove())}else if(effectiveCells){try{parsed=JSON.parse(effectiveCells)}catch(e){parsed=null}}if(parsed){try{Array.from(this.querySelectorAll(".c-hexbin__cell")).forEach((n)=>n.remove());const cols=Math.ceil(Math.sqrt(parsed.length||1));this.style.gridTemplateColumns="repeat("+cols+", 1fr)";this.style.inlineSize="16rem";parsed.forEach((c,i)=>{const cell=document.createElement("div");cell.className="c-hexbin__cell";cell.setAttribute("tabindex",i===0?"0":"-1");if(typeof c==="object"&&c.value!=null){cell.textContent=c.value;cell.setAttribute("title",String(c.value))}else if(typeof c!=="object"){cell.textContent=c;cell.setAttribute("title",String(c))}this.appendChild(cell)});const tip=this.ensure(".c-hexbin__tooltip",()=>{const el=document.createElement("div");el.className="c-hexbin__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}catch(e){}}else if(!parsed){Array.from(this.querySelectorAll(".c-hexbin__cell")).forEach((n)=>n.remove());renderEmpty(this,"hexbin")}}enhance(){if(this._wiredHexbin)return;this._wiredHexbin=true;wireMapItems(this,".c-hexbin__cell",".c-hexbin__tooltip")}}define("contour-hexbin",ContourHexbin);class ContourFlowMap extends ContourBase{static get observed(){return["label","nodes","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},nodes:{attribute:"nodes"},src:{attribute:"src"}}}render(){this.classList.add("c-flow-map");this.setAttribute("role","img");this.setAttribute("aria-label","Flow map");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-flow-map__label",()=>{const el=document.createElement("span");el.className="c-flow-map__label";return el});l.textContent=label}else{const l=this.querySelector(".c-flow-map__label");if(l)l.remove()}wireStates(this);loadRemote(this,"nodes");if(renderStates(this,"flow-map"))return;const nodes=remoteData(this,"nodes");const effectiveNodes=nodes||(this._remoteData&&this._remoteData.nodes?JSON.stringify(this._remoteData.nodes):null);const authoredNodes=Array.from(this.querySelectorAll(":scope > .c-flow-map__node"));let parsed=null;if(authoredNodes.length){parsed=authoredNodes.map((el)=>el.textContent||el.getAttribute("title")||"");authoredNodes.forEach((el)=>el.remove())}else if(effectiveNodes){try{parsed=JSON.parse(effectiveNodes)}catch(e){parsed=null}}if(parsed){try{Array.from(this.querySelectorAll(".c-flow-map__node")).forEach((n)=>n.remove());parsed.forEach((n,i)=>{const node=document.createElement("span");node.className="c-flow-map__node"+(n.source?" c-flow-map__node--source":"")+(n.target?" c-flow-map__node--target":"");node.setAttribute("tabindex",i===0?"0":"-1");node.textContent=typeof n==="string"?n:(n.label||n.name||"");if(typeof n==="object"&&(n.label||n.name))node.setAttribute("title",n.label||n.name);this.appendChild(node)});const tip=this.ensure(".c-flow-map__tooltip",()=>{const el=document.createElement("div");el.className="c-flow-map__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}catch(e){}}else if(!parsed){Array.from(this.querySelectorAll(".c-flow-map__node")).forEach((n)=>n.remove());renderEmpty(this,"flow-map")}}enhance(){if(this._wiredFlowMap)return;this._wiredFlowMap=true;wireMapItems(this,".c-flow-map__node",".c-flow-map__tooltip")}}define("contour-flow-map",ContourFlowMap);class ContourIsochrone extends ContourBase{static get observed(){return["label","center","rings","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},center:{attribute:"center"},rings:{attribute:"rings"},src:{attribute:"src"}}}render(){this.classList.add("c-isochrone");this.setAttribute("role","img");this.setAttribute("aria-label","Isochrone");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-isochrone__label",()=>{const el=document.createElement("span");el.className="c-isochrone__label";return el});l.textContent=label}else{const l=this.querySelector(".c-isochrone__label");if(l)l.remove()}const center=this.getAttribute("center")||(this._remoteData&&this._remoteData.center);if(center){const c=this.ensure(".c-isochrone__center",()=>{const el=document.createElement("span");el.className="c-isochrone__center";return el});c.textContent=center}else{const c=this.querySelector(".c-isochrone__center");if(c)c.remove()}wireStates(this);loadRemote(this,"rings");if(renderStates(this,"isochrone"))return;const rings=remoteData(this,"rings");const effectiveRings=rings||(this._remoteData&&this._remoteData.rings?JSON.stringify(this._remoteData.rings):null);const authoredRings=Array.from(this.querySelectorAll(":scope > .c-isochrone__ring"));let parsed=null;if(authoredRings.length){parsed=authoredRings.map((el)=>el.textContent||el.getAttribute("title")||"");authoredRings.forEach((el)=>el.remove())}else if(effectiveRings){try{parsed=JSON.parse(effectiveRings)}catch(e){parsed=null}}if(parsed){try{Array.from(this.querySelectorAll(".c-isochrone__ring")).forEach((n)=>n.remove());parsed.forEach((r,i)=>{const ring=document.createElement("span");ring.className="c-isochrone__ring c-isochrone__ring--"+(r.label||r);ring.setAttribute("tabindex",i===0?"0":"-1");if(r.label)ring.setAttribute("title",r.label||r);this.appendChild(ring)});const tip=this.ensure(".c-isochrone__tooltip",()=>{const el=document.createElement("div");el.className="c-isochrone__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}catch(e){}}else if(!parsed){Array.from(this.querySelectorAll(".c-isochrone__ring")).forEach((n)=>n.remove());renderEmpty(this,"isochrone")}}enhance(){if(this._wiredIsochrone)return;this._wiredIsochrone=true;wireMapItems(this,".c-isochrone__ring",".c-isochrone__tooltip")}}define("contour-isochrone",ContourIsochrone);class ContourCatchment extends ContourBase{static get observed(){return["label","area","center","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},area:{attribute:"area"},center:{attribute:"center"},src:{attribute:"src"}}}render(){this.classList.add("c-catchment");this.setAttribute("role","img");this.setAttribute("aria-label","Catchment");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-catchment__label",()=>{const el=document.createElement("span");el.className="c-catchment__label";return el});l.textContent=label}else{const l=this.querySelector(".c-catchment__label");if(l)l.remove()}const area=this.getAttribute("area")||(this._remoteData&&this._remoteData.area);if(area){const a=this.ensure(".c-catchment__area",()=>{const el=document.createElement("span");el.className="c-catchment__area";return el});a.textContent=area}else{const a=this.querySelector(".c-catchment__area");if(a)a.remove()}const center=this.getAttribute("center")||(this._remoteData&&this._remoteData.center);if(center){const c=this.ensure(".c-catchment__center",()=>{const el=document.createElement("span");el.className="c-catchment__center";return el});c.textContent=center}else{const c=this.querySelector(".c-catchment__center");if(c)c.remove()}wireStates(this);loadRemote(this,["label","area","center"]);if(renderStates(this,"catchment"))return;const rLabel=remoteData(this,"label")||(this._remoteData&&this._remoteData.label);const rArea=remoteData(this,"area")||(this._remoteData&&this._remoteData.area);const rCenter=remoteData(this,"center")||(this._remoteData&&this._remoteData.center);if(!rLabel&&!rArea&&!rCenter){renderEmpty(this,"catchment");return}const tip=this.ensure(".c-catchment__tooltip",()=>{const el=document.createElement("div");el.className="c-catchment__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","");if(rArea)tip.textContent=rArea}enhance(){if(this._wiredCatchment)return;this._wiredCatchment=true;const showTip=()=>{const tip=this.querySelector(".c-catchment__tooltip");if(tip)tip.removeAttribute("hidden")};const hideTip=()=>{const tip=this.querySelector(".c-catchment__tooltip");if(tip)tip.setAttribute("hidden","")};this.addEventListener("mouseenter",showTip);this.addEventListener("mouseleave",hideTip);if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");this.addEventListener("focusin",showTip);this.addEventListener("focusout",hideTip);this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{area:this.getAttribute("area")}}))}})}}define("contour-catchment",ContourCatchment);class ContourCompassFull extends ContourBase{static get observed(){return["label","needle","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},needle:{attribute:"needle"},src:{attribute:"src"}}}render(){this.classList.add("c-compass");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);wireStates(this);loadRemote(this,"needle");if(renderStates(this,"compass"))return;const needle=remoteData(this,"needle")||(this._remoteData&&(this._remoteData.needle||this._remoteData.value));for(const dir of["n","s","e","w"]){const cls=".c-compass__label--"+dir;let l=this.querySelector(cls);if(!l){l=document.createElement("span");l.className="c-compass__label "+cls.slice(1);l.textContent=dir.toUpperCase();l.setAttribute("role","button");l.setAttribute("tabindex","0");this.appendChild(l)}}if(label&&label.toLowerCase()!=="compass"){const l=this.ensure(".c-compass__label:not([class*='--'])",()=>{const el=document.createElement("span");el.className="c-compass__label";return el});l.textContent=label}if(needle){const deg=Number(needle)||0;const n=this.ensure("svg.c-compass__needle",()=>{const el=document.createElementNS("http://www.w3.org/2000/svg","svg");el.setAttribute("class","c-compass__needle");el.setAttribute("viewBox","0 0 40 40");el.setAttribute("aria-hidden","true");const pathN=document.createElementNS("http://www.w3.org/2000/svg","path");pathN.setAttribute("class","c-compass__needle--n");pathN.setAttribute("d",compassNeedle(20,20,16,deg));el.appendChild(pathN);const pathS=document.createElementNS("http://www.w3.org/2000/svg","path");pathS.setAttribute("class","c-compass__needle--s");pathS.setAttribute("d",compassNeedle(20,20,16,deg+180));el.appendChild(pathS);return el});const pathN=n.querySelector(".c-compass__needle--n");if(pathN)pathN.setAttribute("d",compassNeedle(20,20,16,deg));const pathS=n.querySelector(".c-compass__needle--s");if(pathS)pathS.setAttribute("d",compassNeedle(20,20,16,deg+180))}else{const n=this.querySelector("svg.c-compass__needle, .c-compass__needle");if(n)n.remove()}if(!needle&&!label){renderEmpty(this,"compass")}}enhance(){if(this._wiredCompass)return;this._wiredCompass=true;const DEGREES={n:0,e:90,s:180,w:270};const setBearing=(dir)=>{const deg=DEGREES[dir];if(deg===undefined)return;const n=this.querySelector(".c-compass__needle");if(n){const pathN=n.querySelector(".c-compass__needle--n");if(pathN)pathN.setAttribute("d",compassNeedle(20,20,16,deg));const pathS=n.querySelector(".c-compass__needle--s");if(pathS)pathS.setAttribute("d",compassNeedle(20,20,16,deg+180))}this.dispatchEvent(new CustomEvent("contour:bearing",{bubbles:true,composed:true,detail:{direction:dir,degrees:deg}}))};this.addEventListener("click",(e)=>{const label=e.target&&e.target.closest?e.target.closest(".c-compass__label--n, .c-compass__label--e, .c-compass__label--s, .c-compass__label--w"):null;if(!label||!this.contains(label))return;const m=label.className.match(/c-compass__label--([nsew])/);if(m)setBearing(m[1])});this.addEventListener("keydown",(e)=>{if(e.key!=="Enter"&&e.key!==" ")return;const label=e.target&&e.target.closest?e.target.closest(".c-compass__label--n, .c-compass__label--e, .c-compass__label--s, .c-compass__label--w"):null;if(!label||!this.contains(label))return;e.preventDefault();const m=label.className.match(/c-compass__label--([nsew])/);if(m)setBearing(m[1])})}}define("contour-compass",ContourCompassFull);class ContourLayerSwitch extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-layer-switch");wireStates(this);loadRemote(this,"items");if(renderStates(this,"layer-switch"))return;const items=remoteData(this,"items");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-layer-switch__item"));if(items&&!authored.length){Array.from(this.querySelectorAll(".c-layer-switch__item")).forEach((n)=>n.remove());try{const parsed=JSON.parse(items);const capped=Array.isArray(parsed)?parsed.slice(0,50):parsed;capped.forEach((it)=>{const item=document.createElement("div");item.className="c-layer-switch__item";item.setAttribute("role","group");const sw=document.createElement("span");sw.className="c-layer-switch__swatch";if(it.color)sw.style.background=it.color;sw.setAttribute("aria-hidden","true");item.appendChild(sw);const name=document.createElement("span");name.className="c-layer-switch__name";name.textContent=typeof it==="string"?it:(it.name||it.label||"");item.appendChild(name);if(it.count!=null){const c=document.createElement("span");c.className="c-layer-switch__count";c.textContent=it.count;item.appendChild(c)}const toggle=document.createElement("button");toggle.className="c-layer-switch__toggle";toggle.type="button";toggle.setAttribute("aria-label","Toggle "+(typeof it==="string"?it:(it.name||it.label||"layer")));toggle.setAttribute("aria-pressed","true");toggle.innerHTML='<svg aria-hidden="true"><use href="#i-check" /></svg>';item.appendChild(toggle);this.appendChild(item)})}catch(e){}}else if(!items&&!authored.length){Array.from(this.querySelectorAll(".c-layer-switch__item")).forEach((n)=>n.remove());renderEmpty(this,"layer-switch")}}enhance(){if(this._wiredLayerSwitch)return;this._wiredLayerSwitch=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-layer-switch__toggle"):null;if(!btn||!this.contains(btn))return;const item=btn.closest(".c-layer-switch__item");const name=item?(item.querySelector(".c-layer-switch__name")?.textContent||""):"";const now=btn.getAttribute("aria-pressed")!=="true";btn.setAttribute("aria-pressed",String(now));this.dispatchEvent(new CustomEvent("contour:layer-toggle",{bubbles:true,composed:true,detail:{name,visible:now}}))});this.addEventListener("keydown",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-layer-switch__toggle"):null;if(!btn||!this.contains(btn))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();btn.click()}})}}define("contour-layer-switch",ContourLayerSwitch);class ContourMapSlot extends ContourBase{static get observed(){return["attribution","scale","chrome"]}static get properties(){return{attribution:{attribute:"attribution"},scale:{attribute:"scale"},chrome:{attribute:"chrome"}}}render(){this.classList.add("c-map-slot");const chrome=this.getAttribute("chrome");if(chrome){const c=this.ensure(".c-map-slot__chrome",()=>{const el=document.createElement("div");el.className="c-map-slot__chrome";return el});c.textContent=chrome}else{const c=this.querySelector(".c-map-slot__chrome");if(c)c.remove()}const attribution=this.getAttribute("attribution");if(attribution){const a=this.ensure(".c-map-slot__attribution",()=>{const el=document.createElement("div");el.className="c-map-slot__attribution";return el});a.textContent=attribution}else{const a=this.querySelector(".c-map-slot__attribution");if(a)a.remove()}const scale=this.getAttribute("scale");if(scale){const sc=this.ensure(".c-map-slot__scale",()=>{const el=document.createElement("div");el.className="c-map-slot__scale";return el});sc.textContent=scale}else{const sc=this.querySelector(".c-map-slot__scale");if(sc)sc.remove()}}}define("contour-map-slot",ContourMapSlot);class ContourMapArea extends ContourBase{static get observed(){return["attribution","attribution-mark","scale","controls"]}static get properties(){return{attribution:{attribute:"attribution"},"attribution-mark":{attribute:"attribution-mark"},scale:{attribute:"scale"},controls:{attribute:"controls"}}}render(){this.classList.add("c-map-area");const attribution=this.getAttribute("attribution");if(attribution){const a=this.ensure(".c-map-slot__attribution",()=>{const el=document.createElement("div");el.className="c-map-slot__attribution";return el});a.textContent=attribution}else{const a=this.querySelector(".c-map-slot__attribution");if(a)a.remove()}const mark=this.getAttribute("attribution-mark");if(mark){const m=this.ensure(".c-map-slot__attribution-mark",()=>{const el=document.createElement("span");el.className="c-map-slot__attribution-mark";return el});m.textContent=mark}else{const m=this.querySelector(".c-map-slot__attribution-mark");if(m)m.remove()}const scale=this.getAttribute("scale");if(scale){const sc=this.ensure(".c-map-slot__scale",()=>{const el=document.createElement("div");el.className="c-map-slot__scale";return el});sc.textContent=scale}else{const sc=this.querySelector(".c-map-slot__scale");if(sc)sc.remove()}const controls=this.getAttribute("controls");if(controls){try{const parsed=JSON.parse(controls);const wrap=this.ensure(".c-map-slot__controls",()=>{const el=document.createElement("div");el.className="c-map-slot__controls";return el});wrap.innerHTML="";parsed.forEach((c)=>{const btn=document.createElement("button");btn.className="c-map-slot__control";btn.type="button";btn.textContent=typeof c==="string"?c:(c.label||c);wrap.appendChild(btn)})}catch(e){}}else{const w=this.querySelector(".c-map-slot__controls");if(w)w.remove()}}enhance(){if(this._wiredMapArea)return;this._wiredMapArea=true;this._map=null;this.attachMap=(map)=>{this._map=map||null;this.dispatchEvent(new CustomEvent("contour:map-attach",{bubbles:true,composed:true}))};this.detachMap=()=>{this._map=null;this.dispatchEvent(new CustomEvent("contour:map-detach",{bubbles:true,composed:true}))};Object.defineProperty(this,"map",{get:()=>this._map,set:(m)=>this.attachMap(m)});this.getViewport=()=>{const m=this._map;if(!m)return null;try{if(typeof m.getBounds==="function"){const b=m.getBounds();return{west:b.getWest(),south:b.getSouth(),east:b.getEast(),north:b.getNorth()}}if(m.transform&&typeof m.transform==="object"){return{zoom:m.transform.zoom,center:m.transform.center}}}catch(e){}return null};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-map-slot__control"):null;if(!btn||!this.contains(btn))return;this.dispatchEvent(new CustomEvent("contour:map-control",{bubbles:true,composed:true,detail:{control:btn.textContent}}))})}}define("contour-map-area",ContourMapArea);class ContourMapPanel extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-map-panel");if(!this.hasAttribute("role"))this.setAttribute("role","region");const title=this.getAttribute("title");if(title){if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",title)}else{if(this.getAttribute("aria-label")===this.getAttribute("title"))this.removeAttribute("aria-label")}}}define("contour-map-panel",ContourMapPanel);class ContourMapFooter extends ContourBase{static get observed(){return["brand"]}static get properties(){return{brand:{attribute:"brand"}}}render(){this.classList.add("c-map-footer");if(!this.hasAttribute("role"))this.setAttribute("role","contentinfo");const brand=this.getAttribute("brand");if(brand){const b=this.ensure("[data-map-footer-brand]",()=>{const el=document.createElement("span");el.setAttribute("data-map-footer-brand","");return el});b.textContent=brand}else{const b=this.querySelector("[data-map-footer-brand]");if(b)b.remove()}}}define("contour-map-footer",ContourMapFooter);class ContourScaleBar extends ContourBase{static get observed(){return["label","value","distance","resolution","latitude","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},distance:{attribute:"distance"},resolution:{attribute:"resolution"},latitude:{attribute:"latitude"},src:{attribute:"src"}}}render(){this.classList.add("c-scale-bar");wireStates(this);loadRemote(this,["label","value"]);if(renderStates(this,"scale-bar"))return;let value=remoteData(this,"value")||(this._remoteData&&this._remoteData.value);const resolution=parseFloat(this.getAttribute("resolution"));let derivedLabel=null;if(Number.isFinite(resolution)&&resolution>0){const distance=parseFloat(this.getAttribute("distance"))||1000;value=String(Math.round(distance/resolution));if(!this.getAttribute("label")&&!remoteData(this,"label")){derivedLabel=distance>=1000?(distance/1000)+" km":distance+" m"}}const label=derivedLabel||remoteData(this,"label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-scale-bar__label",()=>{const el=document.createElement("span");el.className="c-scale-bar__label";return el});l.textContent=label}else{const l=this.querySelector(".c-scale-bar__label");if(l)l.remove()}if(!value){renderEmpty(this,"scale-bar");return}const line=this.ensure(".c-scale-bar__line",()=>{const el=document.createElement("span");el.className="c-scale-bar__line";return el});line.style.inlineSize=/^\d+(\.\d+)?$/.test(String(value))?value+"px":value;const ticks=scaleBarTicks(parseFloat(value)||0,4);const max=ticks[ticks.length-1]||1;Array.from(line.querySelectorAll(".c-scale-bar__tick")).forEach((t)=>t.remove());ticks.forEach((tv)=>{const tick=document.createElement("span");tick.className="c-scale-bar__tick";tick.style.insetInlineStart=((tv/max)*100)+"%";line.appendChild(tick)})}}define("contour-scale-bar",ContourScaleBar);class ContourSplitMap extends ContourBase{static get observed(){return["left","right"]}static get properties(){return{left:{attribute:"left"},right:{attribute:"right"}}}render(){this.classList.add("c-split-map");const left=this.ensure(".c-split-map__pane--left",()=>{const e=document.createElement("div");e.className="c-split-map__pane c-split-map__pane--left";return e});const right=this.ensure(".c-split-map__pane--right",()=>{const e=document.createElement("div");e.className="c-split-map__pane c-split-map__pane--right";return e});if(left.parentNode!==this)this.appendChild(left);if(right.parentNode!==this)this.appendChild(right)}}define("contour-split-map",ContourSplitMap);class ContourResizeObserver extends ContourBase{static get observed(){return["debounce"]}static get properties(){return{debounce:{attribute:"debounce"}}}render(){this.classList.add("c-resize-observer");this.setAttribute("aria-hidden","true")}enhance(){if(this._wiredResizeObserver)return;this._wiredResizeObserver=true;if(typeof ResizeObserver!=="function")return;const debounce=parseInt(this.getAttribute("debounce")||"0",10)||0;let timer=null;const ro=new ResizeObserver((entries)=>{const fire=()=>{const e=entries[entries.length-1];const cr=e&&e.contentRect?e.contentRect:this.getBoundingClientRect();this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:true,composed:true,detail:{width:cr.width,height:cr.height}}))};if(debounce>0){clearTimeout(timer);timer=setTimeout(fire,debounce)}else fire()});ro.observe(this);onDispose(this,()=>{ro.disconnect();clearTimeout(timer)})}}define("contour-resize-observer",ContourResizeObserver);class ContourReservedFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-reserved");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-reserved__title",()=>{const el=document.createElement("div");el.className="c-reserved__title";return el});t.textContent=title}}}define("contour-reserved",ContourReservedFull);class ContourThemeScopeFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-theme-scope");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-theme-scope__title",()=>{const el=document.createElement("div");el.className="c-theme-scope__title";el.style.padding="var(--space-sm)";el.style.fontWeight="var(--weight-semibold)";return el});t.textContent=title}}}define("contour-theme-scope",ContourThemeScopeFull);class ContourActivity extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-activity");this.setAttribute("role","list");wireStates(this);loadRemote(this,"items");if(renderStates(this,"activity"))return;const items=remoteData(this,"items");if(items){try{const parsed=JSON.parse(items);Array.from(this.querySelectorAll(".c-activity__item")).forEach((n)=>n.remove());parsed.forEach((it,i)=>{const item=document.createElement("div");item.className="c-activity__item";item.setAttribute("role","listitem");item.tabIndex=-1;const dot=document.createElement("span");dot.className="c-activity__dot c-activity__dot--"+(it.variant||"primary");dot.setAttribute("aria-hidden","true");item.appendChild(dot);const text=document.createElement("span");text.className="c-activity__text";text.textContent=typeof it==="string"?it:(it.text||it.label||"");item.appendChild(text);if(it.time){const time=document.createElement("span");time.className="c-activity__time";time.textContent=it.time;item.appendChild(time)}this.appendChild(item)})}catch(e){}}else{renderEmpty(this,"activity")}}enhance(){if(this._wiredActivity)return;this._wiredActivity=true;this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-activity__item"):null;if(item&&this.contains(item)){const items=Array.from(this.querySelectorAll(".c-activity__item"));const index=items.indexOf(item);const text=item.querySelector(".c-activity__text")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:activity-select",{bubbles:true,composed:true,detail:{index,text}}))}});this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-activity__item"));if(!items.length)return;const active=document.activeElement;const idx=items.indexOf(active);let next=-1;if(e.key==="ArrowDown")next=idx<0?0:Math.min(items.length-1,idx+1);else if(e.key==="ArrowUp")next=idx<0?0:Math.max(0,idx-1);else if(e.key==="Home")next=0;else if(e.key==="End")next=items.length-1;if(next>=0&&next!==idx){e.preventDefault();items[next].focus();items[next].tabIndex=0;if(idx>=0)items[idx].tabIndex=-1}if((e.key==="Enter"||e.key===" ")&&idx>=0){e.preventDefault();const text=items[idx].querySelector(".c-activity__text")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:activity-select",{bubbles:true,composed:true,detail:{index:idx,text}}))}})}}define("contour-activity",ContourActivity);class ContourAdvanced extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-advanced");this.setAttribute("role","region");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-advanced__title",()=>{const el=document.createElement("div");el.className="c-advanced__title";return el});t.textContent=title;this.setAttribute("aria-label",title)}}enhance(){if(this._wiredAdvanced)return;this._wiredAdvanced=true;this.addEventListener("click",(e)=>{const title=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:advanced-toggle",{bubbles:true,composed:true,detail:{title}}))});this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();const title=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:advanced-toggle",{bubbles:true,composed:true,detail:{title}}))}})}}define("contour-advanced",ContourAdvanced);class ContourAffordance extends ContourBase{static get observed(){return["name","note","demo"]}static get properties(){return{name:{attribute:"name"},note:{attribute:"note"},demo:{attribute:"demo"}}}render(){this.classList.add("c-affordance");this.setAttribute("role","group");const name=this.getAttribute("name");if(name){const n=this.ensure(".c-affordance__name",()=>{const el=document.createElement("div");el.className="c-affordance__name";return el});n.textContent=name;this.setAttribute("aria-label",name)}else{const n=this.querySelector(".c-affordance__name");if(n)n.remove()}const note=this.getAttribute("note");if(note){const nt=this.ensure(".c-affordance__note",()=>{const el=document.createElement("div");el.className="c-affordance__note";return el});nt.textContent=note}else{const nt=this.querySelector(".c-affordance__note");if(nt)nt.remove()}const demo=this.getAttribute("demo");if(demo){const d=this.ensure(".c-affordance__demo",()=>{const el=document.createElement("div");el.className="c-affordance__demo";return el});d.textContent=demo}else{const d=this.querySelector(".c-affordance__demo");if(d)d.remove()}}enhance(){if(this._wiredAffordance)return;this._wiredAffordance=true;this.addEventListener("click",(e)=>{const name=this.getAttribute("name")||"";this.dispatchEvent(new CustomEvent("contour:affordance-activate",{bubbles:true,composed:true,detail:{name}}))})}}define("contour-affordance",ContourAffordance);class ContourAffordances extends ContourBase{static get observed(){return["name","title"]}static get properties(){return{name:{attribute:"name"},title:{attribute:"title"}}}render(){this.classList.add("c-affordances");this.setAttribute("role","group");if(!this.querySelector(".c-affordance")){const aff=document.createElement("div");aff.className="c-affordance";const name=this.getAttribute("name")||this.getAttribute("title")||"Affordance";const n=document.createElement("div");n.className="c-affordance__name";n.textContent=name;aff.appendChild(n);const demo=document.createElement("div");demo.className="c-affordance__demo";demo.textContent="Demo";aff.appendChild(demo);this.appendChild(aff)}}}define("contour-affordances",ContourAffordances);class ContourMenu extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-menu");if(!this.hasAttribute("role"))this.setAttribute("role","menu");wireStates(this);loadRemote(this,"items");if(renderStates(this,"menu"))return;const items=remoteData(this,"items");const authored=Array.from(this.children).filter((n)=>!n.classList||!n.classList.contains("c-menu"));if(authored.length){if(this.querySelector("ul.c-menu"))return;const ul=document.createElement("ul");ul.className="c-menu";ul.setAttribute("role","menu");this.appendChild(ul);return}if(items){try{const parsed=JSON.parse(items);const ul=this.ensure("ul.c-menu",()=>{const el=document.createElement("ul");el.className="c-menu";el.setAttribute("role","menu");return el});ul.innerHTML="";ul.setAttribute("role","menu");parsed.forEach((item)=>{if(item==="---"||item==="separator"){const li=document.createElement("li");li.className="c-menu__separator";li.setAttribute("role","separator");ul.appendChild(li)}else if(typeof item==="string"){const li=document.createElement("li");li.className="c-menu__item";li.setAttribute("role","menuitem");li.textContent=item;ul.appendChild(li)}else if(item.group){const li=document.createElement("li");li.className="c-menu__group";li.setAttribute("role","group");if(item.group)li.setAttribute("aria-label",String(item.group));const hdr=document.createElement("div");hdr.className="c-menu__group-label";hdr.textContent=String(item.group);li.appendChild(hdr);if(Array.isArray(item.items)){const sub=document.createElement("ul");sub.className="c-menu";sub.setAttribute("role","menu");item.items.forEach((subItem)=>{const sli=document.createElement("li");sli.className="c-menu__item"+(subItem.danger?" c-menu__item--danger":"")+(subItem.disabled?" c-menu__item--disabled":"");sli.setAttribute("role","menuitem");if(subItem.disabled)sli.setAttribute("aria-disabled","true");if(subItem.label||subItem.title){const lbl=document.createElement("span");lbl.className="c-menu__label";lbl.textContent=subItem.label||subItem.title||"";sli.appendChild(lbl)}sub.appendChild(sli)});li.appendChild(sub)}ul.appendChild(li)}else{const li=document.createElement("li");li.className="c-menu__item"+(item.danger?" c-menu__item--danger":"")+(item.disabled?" c-menu__item--disabled":"");li.setAttribute("role","menuitem");if(item.disabled)li.setAttribute("aria-disabled","true");if(item.items&&Array.isArray(item.items)){li.setAttribute("aria-haspopup","menu");li.setAttribute("aria-expanded","false")}if(item.label||item.title){const lbl=document.createElement("span");lbl.className="c-menu__label";lbl.textContent=item.label||item.title||"";li.appendChild(lbl)}if(item.shortcut){const sc=document.createElement("span");sc.className="c-menu__shortcut";sc.textContent=item.shortcut;li.appendChild(sc)}ul.appendChild(li)}});if(ul.parentNode!==this)this.appendChild(ul);this.classList.remove("c-menu");ul.classList.add("c-menu")}catch(e){}}else{renderEmpty(this,"menu")}}enhance(){wireMenu(this)}}define("contour-menu",ContourMenu);class ContourTabs extends ContourBase{static get observed(){return["tabs","autoplay","pause","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist","orientation","closable"]}static get properties(){return{tabs:{attribute:"tabs"},autoplay:{attribute:"autoplay",type:Number},pause:{attribute:"pause",type:Boolean},src:{attribute:"src"},orientation:{attribute:"orientation"},closable:{attribute:"closable",type:Boolean}}}render(){this.classList.add("c-tabs");wireStates(this);loadRemote(this,"tabs");if(renderStates(this,"tabs"))return;const tabs=remoteData(this,"tabs");const authored=Array.from(this.children).filter((n)=>!n.classList||!n.classList.contains("c-tabs__list"));if(tabs&&!authored.length){try{const parsed=JSON.parse(tabs);const list=this.ensure(".c-tabs__list",()=>{const el=document.createElement("div");el.className="c-tabs__list";el.setAttribute("role","tablist");return el});list.setAttribute("role","tablist");const orientation=this.getAttribute("orientation")==="vertical"?"vertical":"horizontal";list.setAttribute("aria-orientation",orientation);if(orientation==="vertical")this.classList.add("c-tabs--vertical");else this.classList.remove("c-tabs--vertical");const _prevTabs=Array.from(list.querySelectorAll("[role='tab']"));const _prevSel=_prevTabs.findIndex((t)=>t.getAttribute("aria-selected")==="true");const _keepIdx=_prevSel>=0?_prevSel:0;list.innerHTML="";Array.from(this.querySelectorAll(".c-tabs__panel")).forEach((n)=>n.remove());parsed.forEach((t,i)=>{const label=typeof t==="string"?t:(t.label||t.title||"");const panelId=contourId("c-tabs-panel");const btn=document.createElement("button");btn.className="c-tabs__tab";btn.setAttribute("role","tab");btn.setAttribute("aria-selected",String(i===_keepIdx));btn.setAttribute("aria-controls",panelId);btn.tabIndex=i===_keepIdx?0:-1;btn.textContent=label;if(this.hasAttribute("closable")){const closeBtn=document.createElement("button");closeBtn.type="button";closeBtn.className="c-tabs__close";closeBtn.setAttribute("aria-label","Close "+label);closeBtn.textContent="×";closeBtn.addEventListener("click",(e)=>{e.stopPropagation();const idx=Array.from(list.querySelectorAll("[role='tab']")).indexOf(btn);const ctrl=btn.getAttribute("aria-controls");const panel=ctrl?document.getElementById(ctrl):null;btn.remove();if(panel)panel.remove();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true,detail:{index:idx,label}}));const remaining=list.querySelectorAll("[role='tab']");if(remaining.length)remaining[0].click()});btn.appendChild(closeBtn)}list.appendChild(btn);const panel=document.createElement("div");panel.className="c-tabs__panel";panel.id=panelId;panel.setAttribute("role","tabpanel");if(typeof t==="object"&&t!==null&&t.content!==undefined){panel.textContent=String(t.content)}if(i!==_keepIdx)panel.hidden=true;this.appendChild(panel)});if(list.parentNode!==this)this.prepend(list)}catch(e){}}else if(!tabs&&!authored.length){const list=this.querySelector(".c-tabs__list");if(list)list.remove();renderEmpty(this,"tabs")}}enhance(){wireTabs(this);const sync=()=>{const seconds=parseFloat(this.getAttribute("autoplay")||"");const paused=this.hasAttribute("pause")||this._tabsHover||this._tabsFocus;const reduced=typeof matchMedia==="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches;const want=Number.isFinite(seconds)&&seconds>0&&!paused&&!reduced;if(want===this._tabsAutoplayRunning)return;this._tabsAutoplayRunning=want;if(this._tabsTimer!==undefined){clearInterval(this._tabsTimer);this._tabsTimer=undefined}if(!want)return;this._tabsTimer=setInterval(()=>{if(!this.isConnected||this.hasAttribute("pause")||this._tabsHover||this._tabsFocus)return;const list=this.querySelector(".c-tabs__list");const tabs=list?Array.from(list.querySelectorAll("[role='tab']")):[];if(!tabs.length)return;const cur=tabs.findIndex((t)=>t.getAttribute("aria-selected")==="true");const next=tabs[(cur+1)%tabs.length];if(next)next.click()},Math.max(1000,seconds*1000))};sync();if(this._wiredTabsAutoplay)return;this._wiredTabsAutoplay=true;this.addEventListener("pointerenter",()=>{this._tabsHover=true;sync()});this.addEventListener("pointerleave",()=>{this._tabsHover=false;sync()});this.addEventListener("focusin",()=>{this._tabsFocus=true;sync()});this.addEventListener("focusout",()=>{this._tabsFocus=false;sync()});onDispose(this,()=>{if(this._tabsTimer!==undefined){clearInterval(this._tabsTimer);this._tabsTimer=undefined}})}}define("contour-tabs",ContourTabs);class ContourHeader extends ContourBase{static get observed(){return["brand","links"]}static get properties(){return{brand:{attribute:"brand"},links:{attribute:"links"}}}render(){this.classList.add("c-header");const brand=this.getAttribute("brand");const links=this.getAttribute("links");const inner=this.ensure(".c-header__inner",()=>{const el=document.createElement("div");el.className="container c-header__inner";return el});inner.className="container c-header__inner";let brandEl=inner.querySelector(".c-brand");if(brand){if(!brandEl){brandEl=document.createElement("a");brandEl.className="c-brand";brandEl.setAttribute("data-contour-generated","");brandEl.href="#";brandEl.innerHTML=`<span class="c-mark"><svg aria-hidden="true"><use href="#i-mark" /></svg></span>`;const brandName=document.createElement("span");brandName.className="c-brand__name";brandEl.appendChild(brandName);inner.insertBefore(brandEl,inner.firstChild)}const brandName=brandEl.querySelector(".c-brand__name");if(brandName)brandName.textContent=brand}else if(brandEl&&brandEl.hasAttribute("data-contour-generated")){brandEl.remove()}let nav=inner.querySelector(".c-header__nav");const authoredNav=nav?Array.from(nav.children).filter((n)=>n.tagName==="A"):[];if(links&&!authoredNav.length){try{const parsed=JSON.parse(links);if(!nav){nav=document.createElement("nav");nav.className="c-header__nav";nav.setAttribute("aria-label","Main");nav.setAttribute("data-contour-generated","");inner.appendChild(nav)}nav.innerHTML="";parsed.forEach((l)=>{const a=document.createElement("a");a.href=l.href||"#";a.textContent=l.label||l;nav.appendChild(a)})}catch(e){}}else if(links&&authoredNav.length){}else if(nav&&!links&&!authoredNav.length&&nav.hasAttribute("data-contour-generated")){nav.remove()}if(!inner.querySelector(".c-header__actions")){const actions=document.createElement("div");actions.className="c-header__actions";inner.appendChild(actions)}const navEl=inner.querySelector(".c-header__nav");if(navEl){if(!navEl.id)navEl.id="contour-header-nav";const actions=inner.querySelector(".c-header__actions");if(actions&&!actions.querySelector(".c-header__toggle")){const toggle=document.createElement("button");toggle.type="button";toggle.className="c-header__toggle";toggle.setAttribute("aria-label","Toggle navigation");toggle.setAttribute("aria-expanded","false");toggle.setAttribute("aria-controls",navEl.id);toggle.innerHTML='<svg aria-hidden="true"><use href="#i-grid" /></svg>';actions.appendChild(toggle)}}if(inner.parentNode!==this)this.appendChild(inner)}enhance(){if(this._wiredHeader)return;this._wiredHeader=true;const update=()=>{const y=window.scrollY||document.documentElement.scrollTop||0;this.classList.toggle("c-header--scrolled",y>8)};update();window.addEventListener("scroll",update,{passive:true});onDispose(this,()=>window.removeEventListener("scroll",update));this.addEventListener("click",(e)=>{const toggle=e.target&&e.target.closest?e.target.closest(".c-header__toggle"):null;if(!toggle||!this.contains(toggle))return;const nav=this.querySelector("#"+CSS.escape(toggle.getAttribute("aria-controls")||""));if(!nav)return;const open=nav.classList.toggle("is-open");toggle.setAttribute("aria-expanded",String(open))});this.addEventListener("keydown",(e)=>{if(e.key!=="Escape")return;const toggle=this.querySelector(".c-header__toggle");const nav=toggle&&this.querySelector("#"+CSS.escape(toggle.getAttribute("aria-controls")||""));if(!toggle||!nav||!nav.classList.contains("is-open"))return;nav.classList.remove("is-open");toggle.setAttribute("aria-expanded","false")})}}define("contour-header",ContourHeader);class ContourTree extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","virtual","item-height","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist","selectable"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"},"item-height":{attribute:"item-height"}}}_itemHeight(){const h=Number(this.getAttribute("item-height"));return Number.isFinite(h)&&h>0?h:28}_labelToPaths(nodes,pathPrefix,map){(nodes||[]).forEach((node,i)=>{const p=pathPrefix+"."+i;const label=String(node.label||node).trim().slice(0,120);if(!map.has(label))map.set(label,[]);map.get(label).push(p);if(Array.isArray(node.children))this._labelToPaths(node.children,p,map)})}_restoreExpanded(){const persist=this.getAttribute("persist");if(!persist||!this._treeData)return;let labels=null;try{if(persist==="storage"&&this.id){const saved=localStorage.getItem("contour-tree:"+this.id);if(saved!==null)labels=JSON.parse(saved)}else if(persist==="url"){const v=new URLSearchParams(window.location.search).get("c-tree");if(v!==null)labels=JSON.parse(v)}}catch(e){labels=null}if(!Array.isArray(labels))return;const want=new Set(labels.map((l)=>String(l)));const map=new Map();this._labelToPaths(this._treeData,"",map);const expanded=this._expanded||(this._expanded=new Set());for(const lbl of want){const paths=map.get(lbl);if(paths)paths.forEach((p)=>expanded.add(p))}}_persistExpanded(){const persist=this.getAttribute("persist");if(!persist||!this._expanded)return;const pathToNode=new Map();const walk=(nodes,pathPrefix)=>{(nodes||[]).forEach((node,i)=>{const p=pathPrefix+"."+i;pathToNode.set(p,node);if(Array.isArray(node.children))walk(node.children,p)})};walk(this._treeData,"");const open=[];for(const p of this._expanded){const node=pathToNode.get(p);if(node)open.push(String(node.label||node).trim().slice(0,120))}try{if(persist==="storage"&&this.id){localStorage.setItem("contour-tree:"+this.id,JSON.stringify(open))}else if(persist==="url"){const url=new URL(window.location.href);url.searchParams.set("c-tree",JSON.stringify(open));window.history.replaceState(null,"",url.toString())}}catch(e){}}_flatten(nodes,pathPrefix,depth,expanded,out){(nodes||[]).forEach((node,i)=>{const p=pathPrefix+"."+i;const hasChildren=Array.isArray(node.children)&&node.children.length>0;const isExpanded=expanded.has(p);out.push({node,path:p,depth,hasChildren,expanded:isExpanded});if(hasChildren&&isExpanded){this._flatten(node.children,p,depth+1,expanded,out)}})}_renderNodeFlat(rootUl,f){const node=f.node;const depth=f.depth;const li=document.createElement("div");li.className="c-tree__node";li.setAttribute("role","treeitem");li.setAttribute("aria-level",String(depth));li.dataset.path=f.path;if(f.hasChildren){li.setAttribute("aria-expanded",String(f.expanded));const row=document.createElement("div");row.className="c-tree__row"+(node.active?" c-tree__row--active":"")+(node.dir?" c-tree__row--dir":"");row.style.paddingInlineStart=((depth-1)*1)+"rem";const toggle=document.createElement("button");toggle.className="c-tree__toggle";toggle.setAttribute("type","button");toggle.setAttribute("aria-expanded",String(f.expanded));toggle.setAttribute("aria-label","Toggle");toggle.innerHTML='<svg aria-hidden="true"><use href="#i-chevron-right" /></svg>';row.appendChild(toggle);const span=document.createElement("span");span.textContent=node.label;row.appendChild(span);li.appendChild(row)}else{const leaf=document.createElement("div");leaf.className="c-tree__leaf"+(node.active?" c-tree__row--active":"")+(node.dir?" c-tree__row--dir":"");leaf.style.paddingInlineStart=(depth*1)+"rem";if(this.hasAttribute("selectable")){const cb=document.createElement("input");cb.type="checkbox";cb.className="c-tree__select";cb.setAttribute("aria-label","Select "+(node.label||node));const label=String(node.label||node).trim().slice(0,120);if(this._selectedTree&&this._selectedTree.has(label))cb.checked=true;leaf.insertBefore(cb,leaf.firstChild)}leaf.appendChild(document.createTextNode(node.label||node));li.appendChild(leaf)}return li}_renderWindow(rootUl,scrollTop){if(!this._treeData)return;const ih=this._itemHeight();const expanded=this._expanded||(this._expanded=new Set());const flat=[];this._flatten(this._treeData,"",1,expanded,flat);const total=flat.length;const viewportSize=rootUl.clientHeight||320;const visibleCount=Math.ceil(viewportSize/ih)+6;let start=Math.floor((scrollTop||0)/ih);if(start<0)start=0;if(start>Math.max(0,total-visibleCount))start=Math.max(0,total-visibleCount);const end=Math.min(total,start+visibleCount);const topSize=start*ih;const bottomSize=Math.max(0,(total-end)*ih);rootUl.innerHTML="";const top=document.createElement("div");top.className="c-tree__spacer c-tree__spacer--top";top.style.height=topSize+"px";rootUl.appendChild(top);for(let i=start;i<end;i++){rootUl.appendChild(this._renderNodeFlat(rootUl,flat[i]))}const bottom=document.createElement("div");bottom.className="c-tree__spacer c-tree__spacer--bottom";bottom.style.height=bottomSize+"px";rootUl.appendChild(bottom)}render(){this.classList.add("c-tree");const authored=Array.from(this.children).filter((n)=>!n.classList||!n.classList.contains("c-tree"));wireStates(this);loadRemote(this,"items");if(renderStates(this,"tree"))return;const items=remoteData(this,"items");if(items&&!authored.length){try{const parsed=JSON.parse(items);const rootUl=this.ensure("div.c-tree",()=>{const el=document.createElement("div");el.className="c-tree";el.setAttribute("role","tree");return el});rootUl.innerHTML="";rootUl.className="c-tree";rootUl.setAttribute("role","tree");const virtual=this.hasAttribute("virtual");if(virtual){this._treeData=parsed;this._expanded=this._expanded||new Set();this._treeRoot=rootUl;this._restoreExpanded();rootUl.style.maxHeight=rootUl.style.maxHeight||"24rem";rootUl.style.overflow="auto";const scrollTop=this._treeScrollTop||0;this._renderWindow(rootUl,scrollTop);try{rootUl.scrollTop=scrollTop}catch(e){}}else{this._treeData=null;const render=(nodes,parent,depth)=>{const ul=parent?document.createElement("div"):rootUl;if(parent){ul.className="c-tree__children";ul.setAttribute("role","group");if(supportsUntilFound())ul.setAttribute("hidden","until-found");else ul.setAttribute("hidden","")}nodes.forEach((node)=>{const li=document.createElement("div");li.className="c-tree__node";li.setAttribute("role","treeitem");li.setAttribute("aria-level",String(depth));if(node.children){li.setAttribute("aria-expanded","false");const row=document.createElement("div");row.className="c-tree__row"+(node.active?" c-tree__row--active":"")+(node.dir?" c-tree__row--dir":"");if(node.indent){const ind=document.createElement("span");ind.className="c-tree__indent";ind.style.inlineSize=(node.indent*1)+"rem";row.appendChild(ind)}const toggle=document.createElement("button");toggle.className="c-tree__toggle";toggle.setAttribute("type","button");toggle.setAttribute("aria-expanded","false");toggle.setAttribute("aria-label","Toggle");toggle.innerHTML='<svg aria-hidden="true"><use href="#i-chevron-right" /></svg>';row.appendChild(toggle);const span=document.createElement("span");span.textContent=node.label;row.appendChild(span);li.appendChild(row);render(node.children,li,depth+1)}else{const leaf=document.createElement("div");leaf.className="c-tree__leaf"+(node.active?" c-tree__row--active":"")+(node.dir?" c-tree__row--dir":"");if(node.indent){const ind=document.createElement("span");ind.className="c-tree__indent";ind.style.inlineSize=(node.indent*1)+"rem";leaf.appendChild(ind)}if(this.hasAttribute("selectable")){const cb=document.createElement("input");cb.type="checkbox";cb.className="c-tree__select";cb.setAttribute("aria-label","Select "+(node.label||node));leaf.insertBefore(cb,leaf.firstChild)}leaf.appendChild(document.createTextNode(node.label||node));li.appendChild(leaf)}ul.appendChild(li)});if(parent)parent.appendChild(ul)};render(parsed,null,1)}this.classList.remove("c-tree");rootUl.classList.add("c-tree");if(rootUl.parentNode!==this)this.appendChild(rootUl)}catch(e){}}else if(!items&&!authored.length){renderEmpty(this,"tree")}}enhance(){if(!this._wiredTreeToggle){this._wiredTreeToggle=true;this.addEventListener("click",(e)=>{const toggle=e.target&&e.target.closest?e.target.closest(".c-tree__toggle"):null;if(!toggle||!this.contains(toggle))return;e.stopPropagation();const nodeEl=toggle.closest(".c-tree__node");const path=nodeEl&&nodeEl.dataset?nodeEl.dataset.path:null;const expanded=toggle.getAttribute("aria-expanded")==="true";if(path&&this._expanded){if(expanded)this._expanded.delete(path);else this._expanded.add(path)}toggle.setAttribute("aria-expanded",String(!expanded));const row=toggle.closest(".c-tree__row");if(row)row.setAttribute("aria-expanded",String(!expanded));if(this.hasAttribute("virtual")&&this._treeRoot){const s=this._treeRoot;this._treeScrollTop=s.scrollTop||0;this._renderWindow(s,this._treeScrollTop);try{s.scrollTop=this._treeScrollTop}catch(err){}this._persistExpanded()}})}if(this.hasAttribute("virtual")&&!this._wiredTreeScroll){this._wiredTreeScroll=true;const attach=()=>{const s=this.querySelector(".c-tree");if(!s||s._treeScrollWired)return;s._treeScrollWired=true;let raf=0;const onScroll=()=>{if(raf)return;raf=requestAnimationFrame(()=>{raf=0;this._treeScrollTop=s.scrollTop||0;this._renderWindow(s,this._treeScrollTop);try{s.scrollTop=this._treeScrollTop}catch(err){}})};s.addEventListener("scroll",onScroll,{passive:true});onDispose(this,()=>{s.removeEventListener("scroll",onScroll);if(raf)cancelAnimationFrame(raf)})};attach();if(!this.querySelector(".c-tree")){const mo=new MutationObserver(()=>{if(this.querySelector(".c-tree")){attach();mo.disconnect()}});mo.observe(this,{childList:true,subtree:true});onDispose(this,()=>mo.disconnect())}}if(this.hasAttribute("virtual")&&!this._wiredTreeDragScroll){this._wiredTreeDragScroll=true;let dragScrollRaf=0;let dragScrollDir=0;const tick=()=>{if(!dragScrollDir){dragScrollRaf=0;return}const s=this._treeRoot;if(s){s.scrollTop+=dragScrollDir*8;this._treeScrollTop=s.scrollTop;this._renderWindow(s,this._treeScrollTop)}dragScrollRaf=requestAnimationFrame(tick)};this.addEventListener("dragover",(e)=>{const s=this._treeRoot;if(!s)return;const rect=s.getBoundingClientRect();const edge=40;if(e.clientY<rect.top+edge)dragScrollDir=-1;else if(e.clientY>rect.bottom-edge)dragScrollDir=1;else dragScrollDir=0;if(dragScrollDir&&!dragScrollRaf)dragScrollRaf=requestAnimationFrame(tick)});const stop=()=>{dragScrollDir=0;if(dragScrollRaf){cancelAnimationFrame(dragScrollRaf);dragScrollRaf=0}};this.addEventListener("dragend",stop);this.addEventListener("drop",stop)}wireTree(this)}}define("contour-tree",ContourTree);class ContourCodeTabs extends ContourBase{static get observed(){return["tabs","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist"]}static get properties(){return{tabs:{attribute:"tabs"},src:{attribute:"src"}}}render(){this.classList.add("c-code-tabs");wireStates(this);loadRemote(this,"tabs");if(renderStates(this,"code-tabs"))return;const tabs=remoteData(this,"tabs");const list=this.querySelector(".c-code-tabs__list");const authored=list?Array.from(list.children).filter((n)=>n.getAttribute&&n.getAttribute("role")==="tab"):[];if(tabs&&!authored.length){try{const parsed=JSON.parse(tabs);const l=this.ensure(".c-code-tabs__list",()=>{const el=document.createElement("div");el.className="c-code-tabs__list";el.setAttribute("role","tablist");return el});l.setAttribute("role","tablist");const _prevCodeTabs=Array.from(l.querySelectorAll("[role='tab']"));const _prevCodeSel=_prevCodeTabs.findIndex((t)=>t.getAttribute("aria-selected")==="true");const _keepCodeIdx=_prevCodeSel>=0?_prevCodeSel:0;l.innerHTML="";Array.from(this.querySelectorAll(".c-code-tabs__panel")).forEach((n)=>n.remove());parsed.forEach((t,i)=>{const label=typeof t==="string"?t:(t.label||t.title||"");const panelId=contourId("c-code-tabs-panel");const btn=document.createElement("button");btn.className="c-code-tabs__tab";btn.setAttribute("role","tab");btn.setAttribute("aria-selected",String(i===_keepCodeIdx));btn.setAttribute("aria-controls",panelId);btn.tabIndex=i===_keepCodeIdx?0:-1;btn.textContent=label;l.appendChild(btn);const panel=document.createElement("div");panel.className="c-code-tabs__panel";panel.id=panelId;panel.setAttribute("role","tabpanel");if(typeof t==="object"&&t!==null&&t.content!==undefined){panel.textContent=String(t.content)}if(i!==_keepCodeIdx)panel.hidden=true;this.appendChild(panel)});if(l.parentNode!==this)this.prepend(l)}catch(e){}}else if(!tabs&&list){list.remove();renderEmpty(this,"code-tabs")}else if(!tabs&&!list){renderEmpty(this,"code-tabs")}}enhance(){wireTabs(this)}}define("contour-code-tabs",ContourCodeTabs);class ContourBreadcrumb extends ContourBase{static get observed(){return["items","separator","max","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},separator:{attribute:"separator"},max:{attribute:"max",type:Number},src:{attribute:"src"}}};render(){this.classList.add("c-breadcrumb");wireStates(this);loadRemote(this,"items");if(renderStates(this,"breadcrumb"))return;const items=remoteData(this,"items");const nav=this.querySelector("nav");const ol=nav?nav.querySelector("ol"):null;const authored=ol?Array.from(ol.children).filter((n)=>n.tagName==="LI"):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const n=this.ensure("nav",()=>{const el=document.createElement("nav");el.setAttribute("aria-label","Breadcrumb");el.id="contour-breadcrumb-list";return el});n.setAttribute("aria-label","Breadcrumb");n.id="contour-breadcrumb-list";n.innerHTML="";const sep=this.getAttribute("separator")||"/";const max=this._overflowExpanded?null:this.max;const shown=Number.isFinite(max)&&max>1&&parsed.length>max?parsed.slice(-max):parsed;if(Number.isFinite(max)&&max>1&&parsed.length>max){const btn=document.createElement("button");btn.type="button";btn.className="c-breadcrumb__overflow";btn.setAttribute("aria-label",`Show ${parsed.length - shown.length + 1} more items`);btn.setAttribute("aria-expanded","false");btn.setAttribute("aria-controls","contour-breadcrumb-list");btn.textContent="…";btn.addEventListener("click",()=>{this._overflowExpanded=true;this.requestRender()});n.appendChild(btn)}shown.forEach((item,i)=>{if(i<shown.length-1){const a=document.createElement("a");a.href=item.href||"#";a.textContent=item.label||item;n.appendChild(a);const s=document.createElement("span");s.className="c-breadcrumb__sep";s.setAttribute("aria-hidden","true");s.textContent=sep;n.appendChild(s)}else{const span=document.createElement("span");span.textContent=item.label||item;span.setAttribute("aria-current","page");n.appendChild(span)}})}catch(e){}}else if(!items&&nav){nav.remove()}else if(!items&&!nav){renderEmpty(this,"breadcrumb")}}}define("contour-breadcrumb",ContourBreadcrumb);class ContourPagination extends ContourBase{static get observed(){return["pages","current","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist"]}static get properties(){return{pages:{attribute:"pages"},current:{attribute:"current"},src:{attribute:"src"}}}render(){this.classList.add("c-pagination");wireStates(this);loadRemote(this,"pages");if(renderStates(this,"pagination"))return;const pages=remoteData(this,"pages");Array.from(this.querySelectorAll(".c-pagination__link")).forEach((n)=>n.remove());let currentAttr=this.getAttribute("current")||"1";if(this.getAttribute("persist")==="storage"&&this.id){try{const stored=localStorage.getItem("contour-pagination:"+this.id);if(stored!==null)currentAttr=stored}catch(e){}}else if(this.getAttribute("persist")==="url"){try{const v=new URLSearchParams(window.location.search).get("c-pagination");if(v!==null)currentAttr=v}catch(e){}}const current=parseInt(currentAttr,"10")||1;if(pages){let count=parseInt(pages,10);if(!Number.isFinite(count)||count<1){try{const p=JSON.parse(pages);if(Array.isArray(p))count=p.length}catch(e){}}const prev=document.createElement("button");prev.type="button";prev.className="c-pagination__link c-pagination__prev";prev.setAttribute("data-action","prev");prev.textContent="‹";prev.setAttribute("aria-label","Previous page");this.appendChild(prev);for(let i=1;i<=count;i++){const btn=document.createElement("button");btn.type="button";btn.className="c-pagination__link";btn.textContent=String(i);if(i===current){btn.setAttribute("aria-current","page")}this.appendChild(btn)}const next=document.createElement("button");next.type="button";next.className="c-pagination__link c-pagination__next";next.setAttribute("data-action","next");next.textContent="›";next.setAttribute("aria-label","Next page");this.appendChild(next)}else{renderEmpty(this,"pagination")}}enhance(){wirePagination(this)}}define("contour-pagination",ContourPagination);class ContourPagerFull extends ContourBase{static get observed(){return["prev","next"]}static get properties(){return{prev:{attribute:"prev"},next:{attribute:"next"}}}render(){this.classList.add("c-pager");Array.from(this.querySelectorAll(".c-pager__link")).forEach((n)=>n.remove());const prev=this.getAttribute("prev");const next=this.getAttribute("next");if(prev){const a=document.createElement("a");a.className="c-pager__link";a.href=prev.split("|")[1]||"#";const dir=document.createElement("span");dir.className="c-pager__dir";dir.textContent="← Previous";a.appendChild(dir);const title=document.createElement("span");title.className="c-pager__title";title.textContent=prev.split("|")[0];a.appendChild(title);this.appendChild(a)}if(next){const a=document.createElement("a");a.className="c-pager__link c-pager__link--next";a.href=next.split("|")[1]||"#";const dir=document.createElement("span");dir.className="c-pager__dir";dir.textContent="Next →";a.appendChild(dir);const title=document.createElement("span");title.className="c-pager__title";title.textContent=next.split("|")[0];a.appendChild(title);this.appendChild(a)}}}define("contour-pager",ContourPagerFull);class ContourTocFull extends ContourBase{static get observed(){return["title","items","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{title:{attribute:"title"},items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-toc");this.setAttribute("role","list");wireStates(this);loadRemote(this,"items");if(renderStates(this,"toc"))return;const items=remoteData(this,"items");const title=this.getAttribute("title")||"On this page";const titleEl=this.ensure(".c-toc__title",()=>{const el=document.createElement("div");el.className="c-toc__title";return el});titleEl.textContent=title;const list=this.querySelector(".c-toc__list");const authored=list?Array.from(list.children).filter((n)=>n.tagName==="A"):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const l=this.ensure(".c-toc__list",()=>{const el=document.createElement("nav");el.className="c-toc__list";return el});l.className="c-toc__list";l.setAttribute("aria-label",title);l.innerHTML="";parsed.forEach((item)=>{const a=document.createElement("a");a.className="c-toc__link"+(item.sub?" c-toc__link--sub":"");a.href=item.href||"#";a.textContent=item.label||item;if(item.current)a.setAttribute("aria-current","true");l.appendChild(a)})}catch(e){}}else if(!items&&list){list.remove();renderEmpty(this,"toc")}else if(!items&&!list){renderEmpty(this,"toc")}}enhance(){if(this._wiredTocSpy)return;if(typeof IntersectionObserver!=="function")return;const links=()=>Array.from(this.querySelectorAll(".c-toc__link"));const targets=links().map((a)=>{const href=a.getAttribute("href")||"";if(!href.startsWith("#")||href.length<2)return null;return document.getElementById(href.slice(1))}).filter(Boolean);if(!targets.length)return;this._wiredTocSpy=true;const spy=new IntersectionObserver((entries)=>{const visible=entries.filter((en)=>en.isIntersecting).map((en)=>en.target.id);if(!visible.length)return;const top=visible[0];links().forEach((a)=>{const href=a.getAttribute("href")||"";const isCurrent=href==="#"+top;if(isCurrent&&a.getAttribute("aria-current")!=="true")a.setAttribute("aria-current","true");else if(!isCurrent&&a.hasAttribute("aria-current"))a.removeAttribute("aria-current")})},{rootMargin:"0px 0px -60% 0px",threshold:0});targets.forEach((t)=>spy.observe(t));onDispose(this,()=>spy.disconnect());if(!this._wiredTocScroll){this._wiredTocScroll=true;this.addEventListener("click",(e)=>{const a=e.target&&e.target.closest?e.target.closest(".c-toc__link"):null;if(!a||!this.contains(a))return;const href=a.getAttribute("href")||"";if(!href.startsWith("#")||href.length<2)return;const target=document.getElementById(href.slice(1));if(!target)return;e.preventDefault();try{target.scrollIntoView({behavior:"smooth",block:"start"})}catch(err){target.scrollIntoView()}})}}}define("contour-toc",ContourTocFull);class ContourFilterBar extends ContourBase{static get observed(){return["label","divider","items","input","placeholder","mode","modes","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","count","clearable"]}static get properties(){return{label:{attribute:"label"},divider:{attribute:"divider"},items:{attribute:"items"},src:{attribute:"src"},count:{attribute:"count"},clearable:{attribute:"clearable"}}}render(){this.classList.add("c-filter-bar");wireStates(this);loadRemote(this,"items");if(renderStates(this,"filter-bar"))return;const label=this.getAttribute("label");if(label){const l=this.ensure(".c-filter-bar__label",()=>{const el=document.createElement("span");el.className="c-filter-bar__label";return el});l.textContent=label}else{const l=this.querySelector(".c-filter-bar__label");if(l)l.remove()}if(this.hasAttribute("divider")){this.ensure(".c-filter-bar__divider",()=>{const el=document.createElement("span");el.className="c-filter-bar__divider";return el})}else{const d=this.querySelector(".c-filter-bar__divider");if(d)d.remove()}if(this.hasAttribute("input")||this.hasAttribute("placeholder")){let inp=this.querySelector(".c-filter-bar__input");if(!inp){inp=document.createElement("input");inp.type="search";inp.className="c-filter-bar__input";this.appendChild(inp)}const ph=this.getAttribute("placeholder");if(ph)inp.setAttribute("placeholder",ph)}else{const inp=this.querySelector(".c-filter-bar__input");if(inp)inp.remove()}const modesAttr=this.getAttribute("modes");let modes=null;if(modesAttr){try{modes=JSON.parse(modesAttr)}catch(e){modes=modesAttr.split(",").map((s)=>s.trim())}}if(modes||this.hasAttribute("mode")){let bar=this.querySelector(".c-filter-bar__modes");if(!bar){bar=document.createElement("div");bar.className="c-filter-bar__modes";bar.setAttribute("role","toolbar");bar.setAttribute("aria-label",label||"Filter modes");this.appendChild(bar)}bar.innerHTML="";const current=this.getAttribute("mode");const list=Array.isArray(modes)?modes:["draw","erase","select"];list.forEach((m)=>{const name=typeof m==="string"?m:(m.label||m.value||m);const val=typeof m==="string"?m:(m.value||m.label||m);const btn=document.createElement("button");btn.type="button";btn.className="c-filter-bar__mode";btn.textContent=name;btn.dataset.mode=val;if(current&&current===val)btn.setAttribute("aria-pressed","true");bar.appendChild(btn)})}else{const bar=this.querySelector(".c-filter-bar__modes");if(bar)bar.remove()}Array.from(this.querySelectorAll(".c-filter-pill")).forEach((n)=>n.remove());const items=remoteData(this,"items");const authoredPills=Array.from(this.querySelectorAll(":scope > .c-filter-pill"));let parsed=null;if(authoredPills.length){parsed=authoredPills.map((p)=>p.textContent.trim());authoredPills.forEach((p)=>p.remove())}else if(items){try{parsed=JSON.parse(items)}catch(e){parsed=null}}if(Array.isArray(parsed)){parsed.forEach((it)=>{const pill=document.createElement("span");pill.className="c-filter-pill";const txt=typeof it==="string"?it:(it.label||it.value||"");pill.textContent=txt;if(typeof it==="object"&&it!==null&&it.removable!==false){const btn=document.createElement("button");btn.className="c-filter-pill__remove";btn.type="button";btn.setAttribute("aria-label","Remove "+txt);btn.textContent="×";pill.appendChild(btn)}this.appendChild(pill)})}Array.from(this.querySelectorAll(".c-filter-bar__clear-all")).forEach((n)=>n.remove());if(this.hasAttribute("clearable")){const btn=document.createElement("button");btn.type="button";btn.className="c-btn c-btn--ghost c-btn--sm c-filter-bar__clear-all";const count=this.getAttribute("count");btn.textContent=count?("Clear all ("+count+")"):"Clear all";this.appendChild(btn)}if(!parsed&&!label)renderEmpty(this,"filter-bar")}enhance(){wireRemovable(this);if(this._wiredFilterBar)return;this._wiredFilterBar=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-filter-bar__mode"):null;if(!btn||!this.contains(btn))return;const mode=btn.dataset.mode||btn.textContent.trim();Array.from(this.querySelectorAll(".c-filter-bar__mode")).forEach((b)=>b.setAttribute("aria-pressed",String(b===btn)));this.dispatchEvent(new CustomEvent("contour:mode-change",{bubbles:true,composed:true,detail:{mode}}))});this.addEventListener("keydown",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-filter-bar__mode"):null;if(!btn||!this.contains(btn))return;const modes=Array.from(this.querySelectorAll(".c-filter-bar__mode"));const idx=modes.indexOf(btn);let next=-1;if(e.key==="ArrowRight")next=Math.min(modes.length-1,idx+1);else if(e.key==="ArrowLeft")next=Math.max(0,idx-1);if(next>=0){e.preventDefault();try{modes[next].focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();btn.click()}});const inp=this.querySelector(".c-filter-bar__input");if(inp&&!inp._wiredFilterInput){inp._wiredFilterInput=true;inp.addEventListener("input",()=>{this.dispatchEvent(new CustomEvent("contour:input",{bubbles:true,composed:true,detail:{value:inp.value}}))});inp.addEventListener("change",()=>{this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:inp.value}}))})}if(!this._wiredClearAll){this._wiredClearAll=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-filter-bar__clear-all"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:clear-all",{bubbles:true,composed:true,detail:{}}))})}}}define("contour-filter-bar",ContourFilterBar);class ContourCommand extends ContourBase{static get observed(){return["placeholder","items","recent","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{placeholder:{attribute:"placeholder"},items:{attribute:"items"},recent:{attribute:"recent"},empty:{attribute:"empty"},src:{attribute:"src"}}}render(){this.classList.add("c-command");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Command palette");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");wireStates(this);loadRemote(this,"items");if(renderStates(this,"command"))return;const placeholder=this.getAttribute("placeholder")||"Search…";const input=this.ensure(".c-command__input",()=>{const el=document.createElement("input");el.className="c-command__input";el.type="text";return el});input.type="text";input.placeholder=placeholder;input.setAttribute("aria-label","Command");input.setAttribute("role","combobox");input.setAttribute("aria-autocomplete","list");input.setAttribute("aria-expanded","true");const list=this.querySelector(".c-command__list");if(list&&!list.id)list.id=contourId("c-command-list");if(list&&list.id)input.setAttribute("aria-controls",list.id);const items=remoteData(this,"items");const list2=this.querySelector(".c-command__list");const authored=list2?Array.from(list2.children).filter((n)=>n.classList&&n.classList.contains("c-command__item")||n.classList&&n.classList.contains("c-command__group")):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const l=this.ensure(".c-command__list",()=>{const el=document.createElement("div");el.className="c-command__list";el.setAttribute("role","listbox");el.id=contourId("c-command-list");return el});l.setAttribute("role","listbox");l.innerHTML="";const recentRaw=this.getAttribute("recent");if(recentRaw){try{const recentParsed=JSON.parse(recentRaw);const group=document.createElement("div");group.className="c-command__group";const gt=document.createElement("div");gt.className="c-command__group-title";gt.textContent="Recent";group.appendChild(gt);recentParsed.forEach((it)=>{const item=document.createElement("div");item.className="c-command__item";item.setAttribute("role","option");const body=document.createElement("div");body.className="c-command__item-body";const t=document.createElement("div");t.className="c-command__item-title";t.textContent=typeof it==="string"?it:(it.title||it.label||"");body.appendChild(t);item.appendChild(body);group.appendChild(item)});l.appendChild(group)}catch(e){}}parsed.forEach((it)=>{if(it.group){const group=document.createElement("div");group.className="c-command__group";const gt=document.createElement("div");gt.className="c-command__group-title";gt.textContent=it.group;group.appendChild(gt);const item=document.createElement("div");item.className="c-command__item";item.setAttribute("role","option");if(it.icon){const ic=document.createElement("span");ic.className="c-command__item-icon";ic.textContent=it.icon;item.appendChild(ic)}const body=document.createElement("div");body.className="c-command__item-body";if(it.title||it.label){const t=document.createElement("div");t.className="c-command__item-title";t.textContent=it.title||it.label;body.appendChild(t)}if(it.hint){const h=document.createElement("span");h.className="c-command__item-hint";h.textContent=it.hint;body.appendChild(h)}if(it.shortcut){const sc=document.createElement("kbd");sc.className="c-command__item-shortcut";sc.textContent=it.shortcut;item.appendChild(sc)}item.appendChild(body);group.appendChild(item);l.appendChild(group)}else{const item=document.createElement("div");item.className="c-command__item";item.setAttribute("role","option");if(it.icon){const ic=document.createElement("span");ic.className="c-command__item-icon";ic.textContent=it.icon;item.appendChild(ic)}const body=document.createElement("div");body.className="c-command__item-body";if(it.title||it.label){const t=document.createElement("div");t.className="c-command__item-title";t.textContent=it.title||it.label;body.appendChild(t)}if(it.hint){const h=document.createElement("span");h.className="c-command__item-hint";h.textContent=it.hint;body.appendChild(h)}if(it.shortcut){const sc=document.createElement("kbd");sc.className="c-command__item-shortcut";sc.textContent=it.shortcut;item.appendChild(sc)}item.appendChild(body);l.appendChild(item)}})}catch(e){}}else if(!items&&list){list.remove()}const empty=this.getAttribute("empty");if(empty){const e=this.ensure(".c-command__empty",()=>{const el=document.createElement("div");el.className="c-command__empty";return el});e.textContent=empty}else{const e=this.querySelector(".c-command__empty");if(e)e.remove()}const status=this.ensure(".c-command__status",()=>{const el=document.createElement("div");el.className="c-command__status";el.setAttribute("role","status");return el});status.textContent="";if(!items&&!list){renderEmpty(this,"command")}}enhance(){if(this._wiredCommand)return;this._wiredCommand=true;const input=()=>this.querySelector(".c-command__input");const items=()=>Array.from(this.querySelectorAll(".c-command__item"));let cursor=-1;const mark=()=>{items().forEach((it,i)=>{it.classList.toggle("c-command__item--active",i===cursor);it.setAttribute("aria-selected",String(i===cursor));if(i===cursor){if(!it.id)it.id="contour-command-option-"+i;const inp=input();if(inp)inp.setAttribute("aria-activedescendant",it.id)}});if(cursor<0){const inp=input();if(inp)inp.removeAttribute("aria-activedescendant")}};this.addEventListener("keydown",(e)=>{const inp=input();if(!inp||e.target!==inp)return;const its=items();if(!its.length)return;if(e.key==="ArrowDown"){e.preventDefault();cursor=Math.min(cursor+1,its.length-1);mark()}else if(e.key==="ArrowUp"){e.preventDefault();cursor=Math.max(cursor-1,0);mark()}else if(e.key==="Home"){e.preventDefault();cursor=0;mark()}else if(e.key==="End"){e.preventDefault();cursor=its.length-1;mark()}else if(e.key==="Enter"){e.preventDefault();if(cursor>=0&&its[cursor]){const item=its[cursor];const idx=items().indexOf(item);this.dispatchEvent(new CustomEvent("contour:select",{detail:{index:idx,label:item.textContent.trim()},bubbles:true,composed:true}))}}else if(e.key==="Escape"){if(typeof this.hidePopover==="function")this.hidePopover()}});this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-command__item"):null;if(item&&this.contains(item)){const idx=items().indexOf(item);this.dispatchEvent(new CustomEvent("contour:select",{detail:{index:idx,label:item.textContent.trim()},bubbles:true,composed:true}))}});this.addEventListener("input",(e)=>{const inp=input();if(!inp||e.target!==inp)return;const q=inp.value.trim().toLowerCase();const all=items();let visible=0;all.forEach((it)=>{const match=!q||(it.textContent||"").toLowerCase().includes(q);it.hidden=!match;if(match)visible+=1});this.querySelectorAll(".c-command__group").forEach((g)=>{const hasVisible=Array.from(g.querySelectorAll(".c-command__item")).some((it)=>!it.hidden);g.hidden=!hasVisible});cursor=-1;mark();const status=this.querySelector(".c-command__status");if(status)status.textContent=q?`${visible} of ${all.length}`:""})}}define("contour-command",ContourCommand);class ContourFooter extends ContourBase{static get observed(){return["brand","note","links","cols","heading"]}static get properties(){return{brand:{attribute:"brand"},note:{attribute:"note"},links:{attribute:"links"},cols:{attribute:"cols"}}}render(){this.classList.add("c-footer");const brand=this.getAttribute("brand");if(brand){const b=this.ensure(".c-footer__brand",()=>{const el=document.createElement("div");el.className="c-footer__brand";return el});b.textContent=brand}else{const b=this.querySelector(".c-footer__brand");if(b)b.remove()}const note=this.getAttribute("note");if(note){const n=this.ensure(".c-footer__note",()=>{const el=document.createElement("p");el.className="c-footer__note";return el});n.textContent=note}else{const n=this.querySelector(".c-footer__note");if(n)n.remove()}const links=this.getAttribute("links");if(links){try{const parsed=JSON.parse(links);const wrap=this.ensure(".c-footer__links",()=>{const el=document.createElement("div");el.className="c-footer__links";return el});wrap.innerHTML="";parsed.forEach((l)=>{const a=document.createElement("a");a.href=typeof l==="string"?"#":(l.href||"#");a.textContent=typeof l==="string"?l:(l.label||l);wrap.appendChild(a)})}catch(e){}}else{const w=this.querySelector(".c-footer__links");if(w)w.remove()}const cols=this.getAttribute("cols");if(cols){try{const parsed=JSON.parse(cols);this.querySelectorAll(".c-footer__col").forEach((c)=>c.remove());parsed.forEach((col)=>{const c=document.createElement("div");c.className="c-footer__col";if(col.title){const h=document.createElement(headingTag(this,"h3"));h.textContent=col.title;c.appendChild(h)}(col.links||[]).forEach((l)=>{const a=document.createElement("a");a.href=typeof l==="string"?"#":(l.href||"#");a.textContent=typeof l==="string"?l:(l.label||l);c.appendChild(a)});this.appendChild(c)})}catch(e){}}else{this.querySelectorAll(".c-footer__col").forEach((c)=>c.remove())}}}define("contour-footer",ContourFooter);class ContourSchemeToggle extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-scheme-toggle")}enhance(){if(this._wiredScheme)return;this._wiredScheme=true;this.addEventListener("click",()=>{const root=document.documentElement;root.classList.add("is-theme-switching");const current=root.getAttribute("data-theme")||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");const next=current==="dark"?"light":"dark";root.setAttribute("data-theme",next);try{localStorage.setItem("contour-theme",next)}catch(e){}requestAnimationFrame(()=>requestAnimationFrame(()=>root.classList.remove("is-theme-switching")));this.dispatchEvent(new CustomEvent("contour:theme-change",{detail:{theme:next},bubbles:true,composed:true}))});try{const stored=localStorage.getItem("contour-theme");if(stored)document.documentElement.setAttribute("data-theme",stored)}catch(e){}}}define("contour-scheme-toggle",ContourSchemeToggle);class ContourSidebar extends ContourBase{static get observed(){return["title","items","collapsed"]}static get properties(){return{title:{attribute:"title"},items:{attribute:"items"},collapsed:{attribute:"collapsed",type:Boolean}}}render(){this.classList.add("c-sidebar");if(this.hasAttribute("collapsed"))this.classList.add("c-sidebar--collapsed");else this.classList.remove("c-sidebar--collapsed");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-sidebar__title",()=>{const el=document.createElement("div");el.className="c-sidebar__title";return el});t.textContent=title}else{const t=this.querySelector(".c-sidebar__title");if(t)t.remove()}const items=this.getAttribute("items");if(items){try{const parsed=JSON.parse(items);const nav=this.ensure("nav.c-sidebar__nav",()=>{const el=document.createElement("nav");el.className="c-sidebar__nav";return el});nav.innerHTML="";parsed.forEach((it)=>{const a=document.createElement("a");a.className="c-sidebar__link";a.href=(it&&it.href)||"#";a.textContent=(it&&(it.label||it))||"";nav.appendChild(a)})}catch(e){}}}enhance(){if(this._wiredSidebar)return;this._wiredSidebar=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-sidebar__toggle"):null;if(!btn||!this.contains(btn))return;this.toggleAttribute("collapsed")})}}define("contour-sidebar",ContourSidebar);class ContourToolbar extends ContourBase{static get observed(){return["title","actions","overflow"]}static get properties(){return{title:{attribute:"title"},actions:{attribute:"actions"},overflow:{attribute:"overflow",type:Number}}}render(){this.classList.add("c-toolbar");const title=this.getAttribute("title");this.setAttribute("role","toolbar");if(title)this.setAttribute("aria-label",title);const actions=this.getAttribute("actions");if(actions){try{const parsed=JSON.parse(actions);const limit=this.overflow&&this.overflow>0?this.overflow:parsed.length;const visible=parsed.slice(0,limit);const excess=parsed.slice(limit);visible.forEach((a)=>{const btn=document.createElement("button");btn.className="c-toolbar__btn";btn.type="button";btn.textContent=typeof a==="string"?a:(a.label||a);this.appendChild(btn)});if(excess.length){const wrap=document.createElement("div");wrap.className="c-toolbar__overflow";const btn=document.createElement("button");btn.className="c-toolbar__btn c-toolbar__overflow-btn";btn.type="button";btn.setAttribute("aria-haspopup","menu");btn.setAttribute("aria-expanded","false");btn.textContent="…";wrap.appendChild(btn);const menu=document.createElement("div");menu.className="c-toolbar__overflow-menu";menu.setAttribute("role","menu");menu.setAttribute("hidden","");excess.forEach((a)=>{const mbtn=document.createElement("button");mbtn.className="c-toolbar__btn";mbtn.type="button";mbtn.setAttribute("role","menuitem");mbtn.textContent=typeof a==="string"?a:(a.label||a);menu.appendChild(mbtn)});wrap.appendChild(menu);this.appendChild(wrap)}}catch(e){}}}enhance(){if(this._wiredToolbar)return;this._wiredToolbar=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-toolbar__overflow-btn"):null;if(!btn||!this.contains(btn))return;const menu=btn.parentElement&&btn.parentElement.querySelector(".c-toolbar__overflow-menu");if(!menu)return;const open=menu.hasAttribute("hidden");if(open)menu.removeAttribute("hidden");else menu.setAttribute("hidden","");btn.setAttribute("aria-expanded",String(open))})}}define("contour-toolbar",ContourToolbar);class ContourSpatialFilter extends ContourBase{static get observed(){return["modes","mode","active","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{modes:{attribute:"modes"},mode:{attribute:"mode"},active:{attribute:"active"},src:{attribute:"src"}}}render(){this.classList.add("c-spatial-filter");wireStates(this);loadRemote(this,[]);if(renderStates(this,"spatial-filter"))return;const modesAttr=this.getAttribute("modes");let modes=null;if(modesAttr){try{modes=JSON.parse(modesAttr)}catch(e){modes=modesAttr.split(",").map((s)=>s.trim())}}const list=Array.isArray(modes)?modes:["rect","circle","polygon","clear"];let bar=this.querySelector(".c-spatial-filter__modes");if(!bar){bar=document.createElement("div");bar.className="c-spatial-filter__modes";bar.setAttribute("role","toolbar");this.appendChild(bar)}bar.innerHTML="";const current=this.getAttribute("mode");list.forEach((m)=>{const name=typeof m==="string"?m:(m.label||m.value||m);const val=typeof m==="string"?m:(m.value||m.label||m);const btn=document.createElement("button");btn.type="button";btn.className="c-spatial-filter__mode c-btn c-btn--ghost c-btn--sm";btn.textContent=name;btn.dataset.mode=val;if(current&&current===val)btn.setAttribute("aria-pressed","true");bar.appendChild(btn)});if(this.hasAttribute("active")){this.classList.add("c-spatial-filter--active")}else{this.classList.remove("c-spatial-filter--active")}}enhance(){if(this._wiredSpatialFilter)return;this._wiredSpatialFilter=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-spatial-filter__mode"):null;if(!btn||!this.contains(btn))return;const mode=btn.dataset.mode||btn.textContent.trim();if(mode==="clear"){this.classList.remove("c-spatial-filter--active");Array.from(this.querySelectorAll(".c-spatial-filter__mode")).forEach((b)=>b.setAttribute("aria-pressed","false"));this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:true,composed:true,detail:{}}));return}this.classList.add("c-spatial-filter--active");Array.from(this.querySelectorAll(".c-spatial-filter__mode")).forEach((b)=>b.setAttribute("aria-pressed",String(b===btn)));this.dispatchEvent(new CustomEvent("contour:draw-start",{bubbles:true,composed:true,detail:{mode}}))});this.addEventListener("keydown",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-spatial-filter__mode"):null;if(!btn||!this.contains(btn))return;const modes=Array.from(this.querySelectorAll(".c-spatial-filter__mode"));const idx=modes.indexOf(btn);let next=-1;if(e.key==="ArrowRight")next=Math.min(modes.length-1,idx+1);else if(e.key==="ArrowLeft")next=Math.max(0,idx-1);if(next>=0){e.preventDefault();try{modes[next].focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();btn.click()}})}}define("contour-spatial-filter",ContourSpatialFilter);class ContourAvatar extends ContourBase{static get observed(){return["name","size","variant","src","status"]}static get properties(){return{name:{attribute:"name"},size:{attribute:"size"},variant:{attribute:"variant"},src:{attribute:"src"},status:{attribute:"status"}}}render(){this.classList.add("c-avatar");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-avatar--"))this.classList.remove(c)});const name=this.getAttribute("name");const size=this.getAttribute("size");if(size)this.classList.add("c-avatar--"+size);const variant=this.getAttribute("variant");if(variant)this.classList.add("c-avatar--"+variant);const oldImg=this.querySelector("img.c-avatar__img");if(oldImg)oldImg.remove();const oldDot=this.querySelector(".c-avatar__status");if(oldDot)oldDot.remove();const src=this.getAttribute("src");if(src){this.textContent="";const img=document.createElement("img");img.className="c-avatar__img";img.src=src;img.alt=name||"";img.loading="lazy";img.decoding="async";this.appendChild(img)}else if(name){const initials=name.split(" ").map((w)=>w[0]).join("").toUpperCase().slice(0,2);if(!this.querySelector("img.c-avatar__img")){}this.textContent=initials}const status=this.getAttribute("status");if(status){const dot=document.createElement("span");dot.className="c-avatar__status c-avatar__status--"+status;dot.setAttribute("aria-hidden","true");this.appendChild(dot)}}}define("contour-avatar",ContourAvatar);class ContourBadgeFull extends ContourBase{static get observed(){return["variant","label","size","removable"]}static get properties(){return{variant:{attribute:"variant"},label:{attribute:"label"},size:{attribute:"size"},removable:{attribute:"removable",type:Boolean}}}render(){this.classList.add("c-badge");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-badge--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-badge--"+variant);const size=this.getAttribute("size");if(size)this.classList.add("c-badge--"+size);const label=this.getAttribute("label");if(label){let textNode=null;for(const n of this.childNodes){if(n.nodeType===3){textNode=n;break}}if(textNode)textNode.nodeValue=label;else this.insertBefore(document.createTextNode(label),this.firstChild)}if(this.hasAttribute("removable")){this.ensure(".c-badge__remove",()=>{const btn=document.createElement("button");btn.className="c-badge__remove";btn.type="button";btn.setAttribute("aria-label","Remove");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-badge__remove");if(btn)btn.remove()}}enhance(){wireRemovable(this)}}define("contour-badge",ContourBadgeFull);class ContourChipFull extends ContourBase{static get observed(){return["variant","key","value"]}static get properties(){return{variant:{attribute:"variant"},key:{attribute:"key"},value:{attribute:"value"}}}render(){this.classList.add("c-chip");if(!this.hasAttribute("role"))this.setAttribute("role","status");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-chip--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-chip--"+variant);const key=this.getAttribute("key");const value=this.getAttribute("value");if(key){const k=this.ensure(".c-chip__key",()=>{const el=document.createElement("span");el.className="c-chip__key";return el});k.textContent=key}else{const k=this.querySelector(".c-chip__key");if(k)k.remove()}if(value){const v=this.ensure(".c-chip__value",()=>{const el=document.createElement("span");el.className="c-chip__value";return el});v.textContent=value}else{const v=this.querySelector(".c-chip__value");if(v)v.remove()}}}define("contour-chip",ContourChipFull);class ContourTag extends ContourBase{static get observed(){return["label","removable","variant"]}static get properties(){return{label:{attribute:"label"},removable:{attribute:"removable",type:Boolean},variant:{attribute:"variant"}}}render(){this.classList.add("c-tag");if(!this.hasAttribute("role"))this.setAttribute("role","status");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-tag--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-tag--"+variant);const label=this.getAttribute("label");if(label){let textNode=null;for(const n of this.childNodes){if(n.nodeType===3){textNode=n;break}}if(textNode)textNode.nodeValue=label+" ";else this.insertBefore(document.createTextNode(label+" "),this.firstChild)}if(this.hasAttribute("removable")){this.ensure(".c-tag__remove",()=>{const btn=document.createElement("button");btn.className="c-tag__remove";btn.type="button";btn.setAttribute("aria-label","Remove");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-tag__remove");if(btn)btn.remove()}}enhance(){wireRemovable(this)}}define("contour-tag",ContourTag);class ContourDot extends ContourBase{static get observed(){return["variant","live"]}static get properties(){return{variant:{attribute:"variant"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-dot");if(!this.hasAttribute("role"))this.setAttribute("role","img");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","status indicator");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-dot--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-dot--"+variant);if(this.hasAttribute("live"))this.classList.add("c-dot--live");else this.classList.remove("c-dot--live")}}define("contour-dot",ContourDot);class ContourPill extends ContourBase{static get observed(){return["label","live","variant"]}static get properties(){return{label:{attribute:"label"},live:{attribute:"live",type:Boolean},variant:{attribute:"variant"}}}render(){this.classList.add("c-pill");if(!this.hasAttribute("role"))this.setAttribute("role","status");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-pill--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-pill--"+variant);const label=this.getAttribute("label");if(label){this.textContent=label}if(this.hasAttribute("live"))this.classList.add("c-pill--live");else this.classList.remove("c-pill--live")}}define("contour-pill",ContourPill);class ContourKbd extends ContourBase{static get observed(){return["key"]}static get properties(){return{key:{attribute:"key"}}}render(){this.classList.add("c-kbd");const key=this.getAttribute("key");if(key){this.textContent=key}}}define("contour-kbd",ContourKbd);class ContourSpinner extends ContourBase{static get observed(){return["size"]}static get properties(){return{size:{attribute:"size"}}}render(){this.classList.add("c-spinner");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-spinner--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-spinner--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Loading")}}define("contour-spinner",ContourSpinner);class ContourSkeleton extends ContourBase{static get observed(){return["size","shimmer"]}static get properties(){return{size:{attribute:"size"},shimmer:{attribute:"shimmer",type:Boolean}}}render(){this.classList.add("c-skeleton");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-skeleton--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-skeleton--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Loading");if(!this.hasAttribute("aria-busy"))this.setAttribute("aria-busy","true");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true");const shimmer=this.getAttribute("shimmer");if(shimmer==="false"||shimmer==="off")this.classList.add("c-skeleton--static");else this.classList.remove("c-skeleton--static")}}define("contour-skeleton",ContourSkeleton);class ContourTooltip extends ContourBase{static get observed(){return["text","anchor","delay","trigger"]}static get properties(){return{text:{attribute:"text"},anchor:{attribute:"anchor"},delay:{attribute:"delay",type:Number},trigger:{attribute:"trigger"}}}render(){this.classList.add("c-tooltip");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.hasAttribute("role"))this.setAttribute("role","tooltip");if(!this.id)this.id=contourId("tip");const text=this.getAttribute("text");if(text!==null&&!this.hasChildNodes()){this.textContent=text}}enhance(){if(this._wiredTooltip)return;this._wiredTooltip=true;const anchorSel=this.getAttribute("anchor");if(anchorSel){let trigger=null;if(anchorSel.startsWith("#")){trigger=document.getElementById(anchorSel.slice(1))}else{trigger=document.querySelector(anchorSel)}if(trigger){trigger.setAttribute("popovertarget",this.id||(this.id=contourId("tip")));trigger.setAttribute("aria-describedby",this.id)}}const delayMs=(this.delay&&this.delay>0)?this.delay:0;let showTimer=null;const hasPopover=typeof this.showPopover==="function";const show=()=>{if(showTimer)clearTimeout(showTimer);if(delayMs>0)showTimer=setTimeout(()=>{if(hasPopover){try{this.showPopover()}catch(e){}}else this.classList.add("is-open");try{requestAnimationFrame(flipIfNeeded)}catch(e){flipIfNeeded()}},delayMs);else{if(hasPopover){try{this.showPopover()}catch(e){}}else this.classList.add("is-open");try{requestAnimationFrame(flipIfNeeded)}catch(e){flipIfNeeded()}}};const hide=()=>{if(showTimer){clearTimeout(showTimer);showTimer=null}if(hasPopover){try{this.hidePopover()}catch(e){}}else this.classList.remove("is-open")};const triggerMode=this.getAttribute("trigger")||"hover";const trigger=anchorSel?(anchorSel.startsWith("#")?document.getElementById(anchorSel.slice(1)):document.querySelector(anchorSel)):null;const target=trigger||this;const onEnter=()=>{if(triggerMode!=="click")show()};const onLeave=()=>{if(triggerMode!=="click")hide()};const onFocus=()=>{if(triggerMode!=="click")show()};const onBlur=()=>{if(triggerMode!=="click")hide()};const onClick=()=>{if(triggerMode==="click"||triggerMode==="hover"){if(this.matches(":popover-open"))hide();else show()}};const onTouchStart=()=>{if(triggerMode!=="click")show()};const onTouchEnd=()=>{if(triggerMode!=="click"){setTimeout(hide,1500)}};target.addEventListener("mouseenter",onEnter);target.addEventListener("mouseleave",onLeave);target.addEventListener("focus",onFocus);target.addEventListener("blur",onBlur);target.addEventListener("click",onClick);target.addEventListener("touchstart",onTouchStart,{passive:true});target.addEventListener("touchend",onTouchEnd,{passive:true});const flipIfNeeded=()=>{try{const r=this.getBoundingClientRect();if(r.right>window.innerWidth)this.classList.add("c-tooltip--flip-x");else this.classList.remove("c-tooltip--flip-x");if(r.bottom>window.innerHeight)this.classList.add("c-tooltip--flip-y");else this.classList.remove("c-tooltip--flip-y")}catch(e){}};const origShow=show;onDispose(this,()=>{target.removeEventListener("mouseenter",onEnter);target.removeEventListener("mouseleave",onLeave);target.removeEventListener("focus",onFocus);target.removeEventListener("blur",onBlur);target.removeEventListener("click",onClick);target.removeEventListener("touchstart",onTouchStart);target.removeEventListener("touchend",onTouchEnd);if(showTimer)clearTimeout(showTimer)});this.addEventListener("toggle",(e)=>{const t=e.target;if(t&&t===this){this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:this.matches(":popover-open")},bubbles:true,composed:true}))}});this.addEventListener("beforetoggle",(e)=>{this.dispatchEvent(new CustomEvent(e.newState==="open"?"contour:show":"contour:hide",{bubbles:true,composed:true}))})}}define("contour-tooltip",ContourTooltip);class ContourProgress extends ContourBase{static get observed(){return["value","label","min","max","paused","pausable"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},min:{attribute:"min"},max:{attribute:"max"},paused:{attribute:"paused",type:Boolean},pausable:{attribute:"pausable",type:Boolean}}}render(){this.classList.add("c-progress");const value=this.getAttribute("value");if(value===null){this.style.removeProperty("--progress");if(this.getAttribute("aria-valuenow")===this._progressAriaValue){this.removeAttribute("aria-valuenow")}this._progressAriaValue=null}else{const num=Number(value);const pct=Number.isFinite(num)?(num<=1&&value.includes(".")?num*100:num):0;const pctStr=Math.max(0,Math.min(100,pct))+"%";this.style.setProperty("--progress",pctStr);const prevVal=this._progressAriaValue;if(!this.hasAttribute("aria-valuenow")||this.getAttribute("aria-valuenow")===prevVal){this.setAttribute("aria-valuenow",String(pct));this._progressAriaValue=String(pct)}}this.ensure(".c-progress__bar",()=>{const el=document.createElement("span");el.className="c-progress__bar";return el});if(!this.hasAttribute("role"))this.setAttribute("role","progressbar");const label=this.getAttribute("label");if(label&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label);const min=this.getAttribute("min");const max=this.getAttribute("max");if(min!==null)this.setAttribute("aria-valuemin",min);else if(!this.hasAttribute("aria-valuemin"))this.setAttribute("aria-valuemin","0");if(max!==null)this.setAttribute("aria-valuemax",max);else if(!this.hasAttribute("aria-valuemax"))this.setAttribute("aria-valuemax","100");if(this.hasAttribute("paused"))this.classList.add("c-progress--paused");else Array.from(this.classList).forEach((c)=>{if(c==="c-progress--paused")this.classList.remove(c)});if(this.hasAttribute("pausable")){this.ensure(".c-progress__pause",()=>{const btn=document.createElement("button");btn.className="c-progress__pause";btn.type="button";btn.setAttribute("aria-label","Pause");btn.textContent="⏸";return btn})}else{const btn=this.querySelector(".c-progress__pause");if(btn)btn.remove()}}}define("contour-progress",ContourProgress);class ContourMark extends ContourBase{render(){this.classList.add("c-mark")}}define("contour-mark",ContourMark);class ContourLoading extends ContourBase{render(){this.classList.add("c-loading");if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live","polite");this.ensure(".c-spinner",()=>{const el=document.createElement("span");el.className="c-spinner";el.setAttribute("aria-hidden","true");return el})}}define("contour-loading",ContourLoading);class ContourElevation extends ContourBase{render(){this.classList.add("c-elevation")}}define("contour-elevation",ContourElevation);class ContourVersionBannerFull extends ContourBase{static get observed(){return["message","link","href","dismissible"]}static get properties(){return{message:{attribute:"message"},link:{attribute:"link"},href:{attribute:"href"},dismissible:{attribute:"dismissible",type:Boolean}}}render(){this.classList.add("c-version-banner");Array.from(this.children).forEach((n)=>n.remove());const message=this.getAttribute("message");if(message){const icon=document.createElement("svg");icon.setAttribute("aria-hidden","true");icon.innerHTML='<use href="#i-info" />';this.appendChild(icon);const span=document.createElement("span");span.textContent=message;this.appendChild(span)}const link=this.getAttribute("link");const href=this.getAttribute("href");if(link&&href){const a=document.createElement("a");a.className="c-version-banner__link";a.href=href;a.textContent=link;this.appendChild(a)}if(this.hasAttribute("dismissible")){const btn=document.createElement("button");btn.className="c-version-banner__dismiss";btn.type="button";btn.setAttribute("aria-label","Dismiss");btn.textContent="×";this.appendChild(btn)}}enhance(){if(this._wiredVersionBanner)return;this._wiredVersionBanner=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-version-banner__dismiss"):null;if(btn&&this.contains(btn)){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));this.remove()}})}}define("contour-version-banner",ContourVersionBannerFull);class ContourBanner extends ContourBase{static get observed(){return["message","variant"]}static get properties(){return{message:{attribute:"message"},variant:{attribute:"variant"}}}render(){this.classList.add("c-banner");const variant=this.getAttribute("variant");if(variant)this.classList.add("c-banner--"+variant);const message=this.getAttribute("message");if(message){const span=this.ensure(".c-banner__message",()=>{const el=document.createElement("span");el.className="c-banner__message";return el});span.textContent=message}}}define("contour-banner",ContourBanner);class ContourFilterPill extends ContourBase{static get observed(){return["key","value","removable"]}static get properties(){return{key:{attribute:"key"},value:{attribute:"value"},removable:{attribute:"removable",type:Boolean}}}render(){this.classList.add("c-filter-pill");const key=this.getAttribute("key");const value=this.getAttribute("value");if(key){const k=this.ensure(".c-filter-pill__key",()=>{const el=document.createElement("span");el.className="c-filter-pill__key";return el});k.textContent=key}else{const k=this.querySelector(".c-filter-pill__key");if(k)k.remove()}if(value){const v=this.ensure(".c-filter-pill__value",()=>{const el=document.createElement("span");el.className="c-filter-pill__value";return el});v.textContent=value}else{const v=this.querySelector(".c-filter-pill__value");if(v)v.remove()}if(this.hasAttribute("removable")){this.ensure(".c-filter-pill__remove",()=>{const btn=document.createElement("button");btn.className="c-filter-pill__remove";btn.type="button";btn.setAttribute("aria-label","Remove filter");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-filter-pill__remove");if(btn)btn.remove()}}enhance(){wireRemovable(this)}}define("contour-filter-pill",ContourFilterPill);class ContourDatamark extends ContourBase{static get observed(){return["value","unit","label"]}static get properties(){return{value:{attribute:"value"},unit:{attribute:"unit"},label:{attribute:"label"}}}render(){this.classList.add("c-datamark");const value=this.getAttribute("value");const unit=this.getAttribute("unit");const label=this.getAttribute("label");const text=value||label;if(text){this.textContent=text;if(unit){const u=document.createElement("span");u.className="u-subtle";u.textContent=" "+unit;this.appendChild(u)}}}}define("contour-datamark",ContourDatamark);class ContourDestructiveHint extends ContourBase{static get observed(){return["text"]}static get properties(){return{text:{attribute:"text"}}}render(){this.classList.add("c-destructive-hint");const text=this.getAttribute("text");if(text)this.textContent=text}}define("contour-destructive-hint",ContourDestructiveHint);class ContourIconBadge extends ContourBase{static get observed(){return["icon"]}static get properties(){return{icon:{attribute:"icon"}}}render(){this.classList.add("c-icon-badge");const icon=this.getAttribute("icon");if(icon){const sanitized=String(icon).replace(/[^a-zA-Z0-9_-]/g,"");if(sanitized&&!sanitized.startsWith("i-")){if(typeof console!=="undefined"&&console.warn){console.warn("ContourIconBadge: icon '"+icon+"' may not exist in the sprite (expected i-* name).")}}const existing=this.querySelector("svg");const svg=existing||document.createElementNS("http://www.w3.org/2000/svg","svg");if(!existing){svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href","#"+sanitized);svg.appendChild(use);this.appendChild(svg)}else{const use=svg.querySelector("use");if(use)use.setAttribute("href","#"+sanitized)}}else{const svg=this.querySelector("svg");if(svg)svg.remove()}}}define("contour-icon-badge",ContourIconBadge);class ContourLiveBadge extends ContourBase{static get observed(){return["label","state","live"]}static get properties(){return{label:{attribute:"label"},state:{attribute:"state"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-live-badge");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-live-badge--"))this.classList.remove(c)});const state=this.getAttribute("state");if(state){this.classList.add("c-live-badge--"+state)}else if(this.hasAttribute("live")){this.classList.add("c-live-badge--connected")}const label=this.getAttribute("label");if(label&&!this.hasChildNodes())this.textContent=label}}define("contour-live-badge",ContourLiveBadge);class ContourSkeletonGroup extends ContourBase{static get observed(){return["count"]}static get properties(){return{count:{attribute:"count",type:Number}}}render(){this.classList.add("c-skeleton-group");const count=Math.max(1,parseInt(this.getAttribute("count")||"3",10)||3);Array.from(this.querySelectorAll(".c-skeleton")).forEach((n)=>n.remove());for(let i=0;i<count;i++){const sk=document.createElement("div");sk.className="c-skeleton";this.appendChild(sk)}}}define("contour-skeleton-group",ContourSkeletonGroup);class ContourMapPopup extends ContourBase{static get observed(){return["title","content","cluster-count","cluster-expanded","cluster-items"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"},"cluster-count":{attribute:"cluster-count",type:Number},"cluster-expanded":{attribute:"cluster-expanded",type:Boolean},"cluster-items":{attribute:"cluster-items"}}}render(){this.classList.add("c-map-popup");this.setAttribute("role","dialog");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("map-popup");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-map-popup__title",()=>{const el=document.createElement("div");el.className="c-map-popup__title";return el});t.textContent=title}const content=this.getAttribute("content");if(content){const c=this.ensure(".c-map-popup__body",()=>{const el=document.createElement("div");el.className="c-map-popup__body";return el});c.textContent=content}const clusterCount=Number(this.getAttribute("cluster-count"));if(Number.isFinite(clusterCount)&&clusterCount>1){const badge=this.ensure(".c-map-popup__cluster",()=>{const el=document.createElement("button");el.className="c-map-popup__cluster c-btn c-btn--sm";el.type="button";return el});const expanded=this.hasAttribute("cluster-expanded");badge.textContent=expanded?"Hide locations":`${clusterCount} locations`;badge.setAttribute("aria-expanded",String(expanded));badge.setAttribute("aria-label",expanded?"Hide locations":`Show ${clusterCount} locations`)}else{const badge=this.querySelector(".c-map-popup__cluster");if(badge)badge.remove()}const expanded=this.hasAttribute("cluster-expanded");let items=[];try{items=this.getAttribute("cluster-items")?JSON.parse(this.getAttribute("cluster-items")):[]}catch(e){items=[]}const list=this.querySelector(".c-map-popup__cluster-list");if(expanded&&Array.isArray(items)&&items.length){const ul=list||document.createElement("ul");ul.className="c-map-popup__cluster-list";ul.innerHTML="";items.forEach((it)=>{const li=document.createElement("li");li.className="c-map-popup__cluster-item";li.textContent=typeof it==="string"?it:(it.label||it.name||JSON.stringify(it));ul.appendChild(li)});if(ul.parentNode!==this)this.appendChild(ul)}else if(list){list.remove()}if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",title||"Map popup")}enhance(){if(this._wiredMapPopup)return;this._wiredMapPopup=true;const close=()=>{try{this.hidePopover()}catch(e){}this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))};const keyHandler=(e)=>{if(e.key==="Escape"&&(this.classList.contains("is-open")||this.matches(":popover-open"))){e.preventDefault();close()}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-map-popup__close"):null;if(btn&&this.contains(btn))close();const cluster=e.target&&e.target.closest?e.target.closest(".c-map-popup__cluster"):null;if(cluster&&this.contains(cluster)){const expanded=!this.hasAttribute("cluster-expanded");this.toggleAttribute("cluster-expanded",expanded);this.dispatchEvent(new CustomEvent("contour:cluster-toggle",{bubbles:true,composed:true,detail:{count:Number(this.getAttribute("cluster-count")),expanded}}))}})}}define("contour-map-popup",ContourMapPopup);class ContourAnimationControls extends ContourBase{static get observed(){return["playing","speed","progress","min","max","caption","show-thumb","show-thumb-caption"]}static get properties(){return{playing:{attribute:"playing",type:Boolean},speed:{attribute:"speed"},progress:{attribute:"progress"},min:{attribute:"min"},max:{attribute:"max"}}}render(){this.classList.add("c-animation-controls");this.setAttribute("role","toolbar");this.setAttribute("aria-label","Animation controls");const playBtn=this.ensure(".c-animation-controls__play",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-animation-controls__play";el.type="button";return el});playBtn.textContent=this.hasAttribute("playing")?"Pause":"Play";playBtn.setAttribute("aria-label",this.hasAttribute("playing")?"Pause":"Play");const speed=this.getAttribute("speed")||"1x";const speedBtn=this.ensure(".c-animation-controls__speed",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-animation-controls__speed";el.type="button";return el});speedBtn.textContent=speed;const scrubber=this.ensure(".c-animation-controls__scrubber",()=>{const el=document.createElement("input");el.className="c-range c-animation-controls__scrubber";el.type="range";return el});if(this.getAttribute("show-thumb")==="false")scrubber.classList.remove("c-animation-controls__scrubber--thumb");else scrubber.classList.add("c-animation-controls__scrubber--thumb");scrubber.min=this.getAttribute("min")||"0";scrubber.max=this.getAttribute("max")||"100";scrubber.value=this.getAttribute("progress")||"0";const caption=this.getAttribute("caption");if(caption)scrubber.setAttribute("aria-label",caption);else if(!scrubber.getAttribute("aria-label"))scrubber.setAttribute("aria-label","Playhead");const showCaption=this.hasAttribute("show-thumb-caption")||this.hasAttribute("show-thumb");if(caption&&showCaption){const cap=this.ensure(".c-animation-controls__caption",()=>{const el=document.createElement("span");el.className="c-animation-controls__caption";return el});cap.textContent=caption}else{const cap=this.querySelector(".c-animation-controls__caption");if(cap)cap.remove()}}enhance(){if(this._wiredAnimControls)return;this._wiredAnimControls=true;this.addEventListener("click",(e)=>{const play=e.target&&e.target.closest?e.target.closest(".c-animation-controls__play"):null;const speed=e.target&&e.target.closest?e.target.closest(".c-animation-controls__speed"):null;if(play&&this.contains(play)){this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{playing:!this.hasAttribute("playing")}}))}if(speed&&this.contains(speed)){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{speed:speed.textContent}}))}});this.addEventListener("input",(e)=>{const scrubber=e.target&&e.target.closest?e.target.closest(".c-animation-controls__scrubber"):null;if(scrubber&&this.contains(scrubber)){const v=Number(scrubber.value);this.dispatchEvent(new CustomEvent("contour:seek",{bubbles:true,composed:true,detail:{progress:v,value:v}}))}});this.addEventListener("keydown",(e)=>{if(e.key===" "||e.key==="Enter"){const play=this.querySelector(".c-animation-controls__play");if(play&&(e.target===play||!e.target||e.target===this)){e.preventDefault();play.click()}}else if(e.key==="ArrowRight"||e.key==="ArrowLeft"){const scrubber=this.querySelector(".c-animation-controls__scrubber");if(scrubber){e.preventDefault();const step=e.key==="ArrowRight"?1:-1;scrubber.value=String(Number(scrubber.value)+step);scrubber.dispatchEvent(new Event("input",{bubbles:true}))}}});let timer=null;const speedFactor=()=>{const s=this.getAttribute("speed")||"1x";const n=parseFloat(s);return Number.isFinite(n)&&n>0?n:1};const tick=()=>{const scrubber=this.querySelector(".c-animation-controls__scrubber");if(!scrubber)return;const min=Number(scrubber.min||0);const max=Number(scrubber.max||100);let v=Number(scrubber.value||0)+speedFactor();if(v>max)v=min;scrubber.value=String(v);this.dispatchEvent(new CustomEvent("contour:time-change",{bubbles:true,composed:true,detail:{progress:v,value:v}}))};const start=()=>{if(timer)return;timer=setInterval(tick,100)};const stop=()=>{if(timer){clearInterval(timer);timer=null}};if(this.hasAttribute("playing"))start();const obs=new MutationObserver(()=>{if(this.hasAttribute("playing"))start();else stop()});obs.observe(this,{attributes:true,attributeFilter:["playing"]});onDispose(this,()=>{stop();obs.disconnect()})}}define("contour-animation-controls",ContourAnimationControls);class ContourDropdown extends ContourBase{static get observed(){return["label","items"]}static get properties(){return{label:{attribute:"label"},items:{attribute:"items"}}}render(){this.classList.add("c-dropdown");const btn=this.ensure(".c-dropdown__trigger",()=>{const el=document.createElement("button");el.className="c-dropdown__trigger c-btn c-btn--sm";el.type="button";return el});btn.textContent=this.getAttribute("label")||"Menu";const menu=this.ensure(".c-dropdown__menu",()=>{const el=document.createElement("div");el.className="c-dropdown__menu c-menu";el.setAttribute("role","menu");el.hidden=true;return el});const authoredItems=Array.from(this.querySelectorAll(":scope > .c-menu__item"));const items=this.getAttribute("items");if(authoredItems.length){menu.innerHTML="";authoredItems.forEach((it)=>{menu.appendChild(it)})}else if(items){try{const parsed=JSON.parse(items);menu.innerHTML="";parsed.forEach((it)=>{const li=document.createElement("button");li.className="c-menu__item";li.setAttribute("role","menuitem");li.textContent=typeof it==="string"?it:(it.label||it.title||"");menu.appendChild(li)})}catch(e){}}if(menu.parentNode!==this)this.appendChild(menu);if(btn.parentNode!==this)this.insertBefore(btn,menu)}enhance(){if(this._wiredDropdown)return;this._wiredDropdown=true;const btn=()=>this.querySelector(".c-dropdown__trigger");const menu=()=>this.querySelector(".c-dropdown__menu");this.addEventListener("click",(e)=>{const b=btn();const m=menu();const item=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;if(item&&m&&m.contains(item)&&!m.hidden){const idx=Array.from(m.querySelectorAll(".c-menu__item")).indexOf(item);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx,value:item.textContent}}));m.hidden=true;if(b){b.setAttribute("aria-expanded","false");try{b.focus()}catch(err){}}return}if(e.target===b||(b&&b.contains(e.target))){if(m){m.hidden=!m.hidden;b.setAttribute("aria-expanded",String(!m.hidden));if(!m.hidden){if(!m.id)m.id=(this.id||contourId("dd"))+"-menu";b.setAttribute("aria-controls",m.id);const first=m.querySelector(".c-menu__item");if(first)try{first.focus()}catch(err){}}}}});const docClick=(e)=>{const m=menu();const b=btn();if(m&&!m.hidden&&!this.contains(e.target)){m.hidden=true;if(b)b.setAttribute("aria-expanded","false")}};document.addEventListener("click",docClick);onDispose(this,()=>document.removeEventListener("click",docClick));const keyHandler=(e)=>{const m=menu();const b=btn();if(e.key==="Escape"&&m&&!m.hidden){e.preventDefault();m.hidden=true;if(b){b.setAttribute("aria-expanded","false");try{b.focus()}catch(err){}}return}if(!m||m.hidden)return;const items=Array.from(m.querySelectorAll(".c-menu__item"));const active=document.activeElement;const idx=items.indexOf(active);if(e.key==="ArrowDown"){e.preventDefault();const next=items[Math.min(items.length-1,idx+1)]||items[0];if(next)try{next.focus()}catch(err){}}else if(e.key==="ArrowUp"){e.preventDefault();const prev=items[Math.max(0,idx-1)]||items[items.length-1];if(prev)try{prev.focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){if(active&&items.includes(active)){e.preventDefault();active.click()}}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler))}}define("contour-dropdown",ContourDropdown);class ContourAnnotation extends ContourBase{static get observed(){return["label","x","y"]}static get properties(){return{label:{attribute:"label"},x:{attribute:"x"},y:{attribute:"y"}}}render(){this.classList.add("c-annotation");this.setAttribute("role","note");const label=this.getAttribute("label");if(label)this.setAttribute("aria-label",label);if(label){const l=this.ensure(".c-annotation__label",()=>{const el=document.createElement("span");el.className="c-annotation__label";return el});l.textContent=label}const x=this.getAttribute("x");const y=this.getAttribute("y");if(x!==null)this.style.setProperty("--annotation-x",x);if(y!==null)this.style.setProperty("--annotation-y",y)}}define("contour-annotation",ContourAnnotation);class ContourStyleSwitcher extends ContourBase{static get observed(){return["items","value"]}static get properties(){return{items:{attribute:"items"},value:{attribute:"value"}}}render(){this.classList.add("c-style-switcher");const items=this.getAttribute("items");const value=this.getAttribute("value");Array.from(this.querySelectorAll(".c-style-switcher__option")).forEach((n)=>n.remove());if(items){try{const parsed=JSON.parse(items);parsed.forEach((it)=>{const name=typeof it==="string"?it:(it.name||it.label||"");const btn=document.createElement("button");btn.className="c-style-switcher__option c-btn c-btn--sm";btn.type="button";btn.textContent=name;if(name===value)btn.classList.add("c-style-switcher__option--active");btn.dataset.value=name;this.appendChild(btn)})}catch(e){}}}enhance(){if(this._wiredStyleSwitcher)return;this._wiredStyleSwitcher=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-style-switcher__option"):null;if(btn&&this.contains(btn)){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:btn.dataset.value}}))}})}}define("contour-style-switcher",ContourStyleSwitcher);class ContourStylePanel extends ContourBase{static get observed(){return["title","layers","layer","single","classification","palette","breaks","opacity","n","colors","property"]}static get properties(){return{title:{attribute:"title"},layers:{attribute:"layers"},classification:{attribute:"classification"},palette:{attribute:"palette"},breaks:{attribute:"breaks"},opacity:{attribute:"opacity"}}}render(){this.classList.add("c-style-panel");this.setAttribute("role","group");this.setAttribute("aria-label","Style panel");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-style-panel__title",()=>{const el=document.createElement("div");el.className="c-style-panel__title";return el});t.textContent=title}const singleMode=this.hasAttribute("single")||!!this.getAttribute("layer");if(singleMode){const body=this.ensure(".c-style-panel__body",()=>{const el=document.createElement("div");el.className="c-style-panel__body";return el});body.innerHTML="";const propLabel=document.createElement("label");propLabel.textContent="Colour field";propLabel.setAttribute("for","property");body.appendChild(propLabel);const propIn=document.createElement("input");propIn.type="text";propIn.id="property";propIn.className="c-style-panel__property c-input";propIn.setAttribute("aria-label","Colour field");const pv=this.getAttribute("property");if(pv)propIn.value=pv;body.appendChild(propIn);const clsLabel=document.createElement("label");clsLabel.textContent="Classification";clsLabel.setAttribute("for","policy");body.appendChild(clsLabel);const clsSel=document.createElement("select");clsSel.id="policy";clsSel.className="c-style-panel__classification c-input";clsSel.setAttribute("aria-label","Classification method");["equal","quantile","jenks","manual"].forEach((m)=>{const o=document.createElement("option");o.value=m;o.textContent=m;clsSel.appendChild(o)});const cls=this.getAttribute("classification");if(cls)clsSel.value=cls;body.appendChild(clsSel);const palLabel=document.createElement("label");palLabel.textContent="Palette";palLabel.setAttribute("for","palette");body.appendChild(palLabel);const pal=document.createElement("input");pal.type="text";pal.id="palette";pal.className="c-style-panel__palette c-input";pal.placeholder="palette";pal.setAttribute("aria-label","Palette");const palv=this.getAttribute("palette");if(palv)pal.value=palv;body.appendChild(pal);const nLabel=document.createElement("label");nLabel.textContent="Classes";nLabel.setAttribute("for","n");body.appendChild(nLabel);const nIn=document.createElement("input");nIn.type="number";nIn.id="n";nIn.className="c-style-panel__n c-input";nIn.min="2";nIn.max="12";nIn.setAttribute("aria-label","Class count");const nv=this.getAttribute("n");if(nv)nIn.value=nv;else nIn.value="5";body.appendChild(nIn);const op=document.createElement("input");op.type="range";op.className="c-style-panel__opacity";op.setAttribute("aria-label","Opacity");op.min="0";op.max="100";const ov=this.getAttribute("opacity");op.value=ov!=null?ov:"100";body.appendChild(op);const breaksAttr=this.getAttribute("breaks");let breaksArr=null;if(breaksAttr){try{breaksArr=JSON.parse(breaksAttr)}catch(e){breaksArr=breaksAttr.split(",").map((s)=>s.trim())}}if(Array.isArray(breaksArr)&&breaksArr.length){const breaksWrap=document.createElement("div");breaksWrap.className="c-style-panel__breaks";breaksArr.forEach((b,i)=>{const br=document.createElement("div");br.className="break";const span=document.createElement("span");span.textContent=String(b);br.appendChild(span);const inp=document.createElement("input");inp.type="number";inp.className="c-style-panel__breaks c-input";inp.setAttribute("aria-label","Class lower bound");inp.value=String(b);br.appendChild(inp);breaksWrap.appendChild(br)});body.appendChild(breaksWrap)}const colorsAttr=this.getAttribute("colors");let colors=null;if(colorsAttr){try{colors=JSON.parse(colorsAttr)}catch(e){colors=colorsAttr.split(",").map((s)=>s.trim())}}if(Array.isArray(colors)){const list=document.createElement("div");list.className="c-style-panel__colors";colors.forEach((c,i)=>{const sw=document.createElement("input");sw.type="color";sw.className="c-style-panel__color c-input";sw.setAttribute("aria-label","Colour for class "+(i+1));sw.value=c;sw.addEventListener("input",()=>{sw.setAttribute("data-edited","true")});list.appendChild(sw)});body.appendChild(list)}const actions=document.createElement("div");actions.className="c-style-panel__actions c-btn-group";const applyBtn=document.createElement("button");applyBtn.type="button";applyBtn.className="c-btn c-btn--primary";applyBtn.textContent="Apply";const revertBtn=document.createElement("button");revertBtn.type="button";revertBtn.className="c-btn";revertBtn.textContent="Revert";actions.appendChild(applyBtn);actions.appendChild(revertBtn);body.appendChild(actions);return}const layers=this.getAttribute("layers");const body=this.ensure(".c-style-panel__body",()=>{const el=document.createElement("div");el.className="c-style-panel__body";return el});const authoredRows=Array.from(this.querySelectorAll(":scope > .c-style-panel__row"));let parsed=null;if(authoredRows.length){parsed=authoredRows.map((row)=>({name:row.querySelector(".c-style-panel__name")?.textContent||"",color:row.querySelector(".c-style-panel__color")?.value,classification:row.querySelector(".c-style-panel__classification")?.value,palette:row.querySelector(".c-style-panel__palette")?.value,breaks:row.querySelector(".c-style-panel__breaks")?.value,opacity:row.querySelector(".c-style-panel__opacity")?.value,}));authoredRows.forEach((row)=>row.remove())}else if(layers){try{parsed=JSON.parse(layers)}catch(e){parsed=null}}if(parsed){body.innerHTML="";parsed.forEach((l)=>{const row=document.createElement("div");row.className="c-style-panel__row";const name=document.createElement("span");name.className="c-style-panel__name";name.textContent=typeof l==="string"?l:(l.name||l.label||"");row.appendChild(name);const input=document.createElement("input");input.type="color";input.className="c-style-panel__color";input.setAttribute("aria-label","Colour for "+(typeof l==="string"?l:(l.name||l.label||"layer")));if(typeof l==="object"&&l.color)input.value=l.color;row.appendChild(input);const clsSel=document.createElement("select");clsSel.className="c-style-panel__classification";clsSel.setAttribute("aria-label","Classification method");["equal","quantile","jenks","manual"].forEach((m)=>{const o=document.createElement("option");o.value=m;o.textContent=m;clsSel.appendChild(o)});if(typeof l==="object"&&l.classification)clsSel.value=l.classification;row.appendChild(clsSel);const pal=document.createElement("input");pal.type="text";pal.className="c-style-panel__palette";pal.setAttribute("aria-label","Palette");pal.placeholder="palette";if(typeof l==="object"&&l.palette)pal.value=l.palette;row.appendChild(pal);const breaks=document.createElement("input");breaks.type="text";breaks.className="c-style-panel__breaks";breaks.placeholder="breaks";if(typeof l==="object"&&l.breaks)breaks.value=(Array.isArray(l.breaks)?l.breaks.join(","):l.breaks);row.appendChild(breaks);const op=document.createElement("input");op.type="range";op.className="c-style-panel__opacity";op.setAttribute("aria-label","Opacity");op.min="0";op.max="100";op.value=(typeof l==="object"&&l.opacity!=null)?l.opacity:"100";row.appendChild(op);body.appendChild(row)})}}enhance(){if(this._wiredStylePanel)return;this._wiredStylePanel=true;this.addEventListener("change",(e)=>{const t=e.target;if(!t||!this.contains(t))return;const row=t.closest(".c-style-panel__row");const name=row?(row.querySelector(".c-style-panel__name")?.textContent||""):"";if(t.classList.contains("c-style-panel__color")){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:t.value,layer:name,property:"color"},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__classification")){this.dispatchEvent(new CustomEvent("contour:break-change",{detail:{value:t.value,layer:name},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__opacity")){this.dispatchEvent(new CustomEvent("contour:layer-opacity",{detail:{name,opacity:Number(t.value)},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__property")){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:t.value,layer:name,property:"property"},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__n")){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:Number(t.value),layer:name,property:"n"},bubbles:true,composed:true}))}});this.addEventListener("input",(e)=>{const t=e.target;if(!t||!this.contains(t))return;if(t.classList.contains("c-style-panel__palette")||t.classList.contains("c-style-panel__breaks")){const row=t.closest(".c-style-panel__row");const name=row?(row.querySelector(".c-style-panel__name")?.textContent||""):"";this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:t.value,layer:name,property:t.classList.contains("c-style-panel__palette")?"palette":"breaks"},bubbles:true,composed:true}))}});this.addEventListener("click",(e)=>{const t=e.target&&e.target.closest?e.target.closest("button"):null;if(!t||!this.contains(t))return;if(t.textContent.trim()==="Apply"){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{applied:true},bubbles:true,composed:true}))}else if(t.textContent.trim()==="Revert"){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{applied:false},bubbles:true,composed:true}))}})}}define("contour-style-panel",ContourStylePanel);class ContourResponsiveContent extends ContourBase{static get observed(){return["breakpoint"]}static get properties(){return{breakpoint:{attribute:"breakpoint"}}}render(){this.classList.add("c-responsive-content");const bp=this.getAttribute("breakpoint")||"md";this.dataset.breakpoint=bp}}define("contour-responsive-content",ContourResponsiveContent);class ContourAvatarGroup extends ContourBase{static get observed(){return["items","max"]}static get properties(){return{items:{attribute:"items"},max:{attribute:"max",type:Number}}}render(){this.classList.add("c-avatar-group");const items=this.getAttribute("items");const max=parseInt(this.getAttribute("max")||"4",10)||4;Array.from(this.querySelectorAll(".c-avatar, .c-avatar-group__overflow")).forEach((n)=>n.remove());if(items){try{const parsed=JSON.parse(items);const shown=parsed.slice(0,max);shown.forEach((it)=>{const av=document.createElement("span");av.className="c-avatar";const name=typeof it==="string"?it:(it.name||it.label||"");av.textContent=name.slice(0,2).toUpperCase();if(typeof it==="object"&&it.color){av.style.background=it.color;av.dataset.color=it.color}this.appendChild(av)});if(parsed.length>max){const overflow=document.createElement("span");overflow.className="c-avatar c-avatar-group__overflow";overflow.textContent="+"+(parsed.length-max);this.appendChild(overflow)}}catch(e){}}}}define("contour-avatar-group",ContourAvatarGroup);class ContourDivider extends ContourBase{static get observed(){return["label","orientation"]}static get properties(){return{label:{attribute:"label"},orientation:{attribute:"orientation"}}}render(){this.classList.add("c-divider");const orientation=this.getAttribute("orientation")||"horizontal";this.classList.add("c-divider--"+orientation);const label=this.getAttribute("label");if(label){const l=this.ensure(".c-divider__label",()=>{const el=document.createElement("span");el.className="c-divider__label";return el});l.textContent=label}}}define("contour-divider",ContourDivider);class ContourStatusLight extends ContourBase{static get observed(){return["status","label"]}static get properties(){return{status:{attribute:"status"},label:{attribute:"label"}}}render(){this.classList.add("c-status-light");const status=this.getAttribute("status")||"neutral";this.classList.add("c-status-light--"+status);const label=this.getAttribute("label");if(label){const l=this.ensure(".c-status-light__label",()=>{const el=document.createElement("span");el.className="c-status-light__label";return el});l.textContent=label}}}define("contour-status-light",ContourStatusLight);class ContourSplitButton extends ContourBase{static get observed(){return["label","menu"]}static get properties(){return{label:{attribute:"label"},menu:{attribute:"menu"}}}render(){this.classList.add("c-split-button");const main=this.ensure(".c-split-button__main",()=>{const el=document.createElement("button");el.className="c-btn c-split-button__main";el.type="button";return el});main.textContent=this.getAttribute("label")||"Action";const toggle=this.ensure(".c-split-button__toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--icon c-split-button__toggle";el.type="button";el.setAttribute("aria-label","More options");el.textContent="▾";return el});const menu=this.ensure(".c-split-button__menu",()=>{const el=document.createElement("div");el.className="c-menu c-split-button__menu";el.setAttribute("role","menu");el.hidden=true;return el});const items=this.getAttribute("menu");if(items){try{const parsed=JSON.parse(items);menu.innerHTML="";parsed.forEach((it)=>{const li=document.createElement("button");li.className="c-menu__item";li.setAttribute("role","menuitem");li.textContent=typeof it==="string"?it:(it.label||it.title||"");menu.appendChild(li)})}catch(e){}}if(main.parentNode!==this)this.appendChild(main);if(toggle.parentNode!==this)this.appendChild(toggle);if(menu.parentNode!==this)this.appendChild(menu)}enhance(){if(this._wiredSplitButton)return;this._wiredSplitButton=true;const toggle=()=>this.querySelector(".c-split-button__toggle");const menu=()=>this.querySelector(".c-split-button__menu");this.addEventListener("click",(e)=>{const t=toggle();if(e.target===t||(t&&t.contains(e.target))){const m=menu();if(m){m.hidden=!m.hidden;t.setAttribute("aria-expanded",String(!m.hidden));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{open:!m.hidden}}))}}const item=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;if(item&&this.contains(item)){const m=menu();if(m){m.hidden=true;const t=toggle();if(t)t.setAttribute("aria-expanded","false")}this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{label:item.textContent}}))}});this.addEventListener("keydown",(e)=>{const t=toggle();if((e.target===t||(t&&t.contains(e.target)))&&(e.key==="Enter"||e.key===" ")){e.preventDefault();const m=menu();if(m){m.hidden=!m.hidden;t.setAttribute("aria-expanded",String(!m.hidden))}}else if(e.key==="Escape"){const m=menu();if(m&&!m.hidden){m.hidden=true;if(t)t.setAttribute("aria-expanded","false")}}});const docClick=(e)=>{const m=menu();const t=toggle();if(m&&!m.hidden&&!this.contains(e.target)){m.hidden=true;if(t)t.setAttribute("aria-expanded","false")}};document.addEventListener("click",docClick);onDispose(this,()=>document.removeEventListener("click",docClick))}}define("contour-split-button",ContourSplitButton);class ContourPaletteEditor extends ContourBase{static get observed(){return["colors"]}static get properties(){return{colors:{attribute:"colors"}}}render(){this.classList.add("c-palette-editor");const colors=this.getAttribute("colors");Array.from(this.querySelectorAll(".c-palette-editor__swatch")).forEach((n)=>n.remove());if(colors){try{const parsed=JSON.parse(colors);parsed.forEach((c)=>{const sw=document.createElement("button");sw.className="c-palette-editor__swatch c-swatch";sw.type="button";sw.style.background=typeof c==="string"?c:(c.color||c.value||"");sw.dataset.color=typeof c==="string"?c:(c.color||c.value||"");sw.setAttribute("aria-label",typeof c==="string"?c:(c.name||c.label||"color"));this.appendChild(sw)})}catch(e){}}}enhance(){if(this._wiredPaletteEditor)return;this._wiredPaletteEditor=true;this.addEventListener("click",(e)=>{const sw=e.target&&e.target.closest?e.target.closest(".c-palette-editor__swatch"):null;if(sw&&this.contains(sw)){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{color:(sw.dataset&&sw.dataset.color)||sw.style.background}}))}});this.addEventListener("keydown",(e)=>{const swatches=Array.from(this.querySelectorAll(".c-palette-editor__swatch"));const active=document.activeElement;const idx=swatches.indexOf(active);if(e.key==="ArrowRight"){e.preventDefault();const next=swatches[Math.min(swatches.length-1,idx+1)]||swatches[0];if(next)try{next.focus()}catch(err){}}else if(e.key==="ArrowLeft"){e.preventDefault();const prev=swatches[Math.max(0,idx-1)]||swatches[swatches.length-1];if(prev)try{prev.focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();if(active&&active.classList.contains("c-palette-editor__swatch"))active.click()}})}}define("contour-palette-editor",ContourPaletteEditor);class ContourDateRange extends ContourBase{static get observed(){return["start","end","label","time","min","max","locale"]}static get properties(){return{start:{attribute:"start"},end:{attribute:"end"},label:{attribute:"label"},time:{attribute:"time",type:Boolean},min:{attribute:"min"},max:{attribute:"max"},locale:{attribute:"locale"}}}render(){this.classList.add("c-date-range");this.setAttribute("role","group");this.setAttribute("aria-label","Date range");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-date-range__label",()=>{const el=document.createElement("span");el.className="c-date-range__label";return el});l.textContent=label}const start=this.ensure(".c-date-range__start",()=>{const el=document.createElement("input");el.className="c-input c-date-range__start";return el});start.type=this.hasAttribute("time")?"datetime-local":"date";start.value=this.getAttribute("start")||"";const end=this.ensure(".c-date-range__end",()=>{const el=document.createElement("input");el.className="c-input c-date-range__end";return el});end.type=start.type;end.value=this.getAttribute("end")||"";const min=this.getAttribute("min");const max=this.getAttribute("max");[start,end].forEach((input)=>{if(min)input.min=min;else input.removeAttribute("min");if(max)input.max=max;else input.removeAttribute("max");if(this.getAttribute("locale"))input.lang=this.getAttribute("locale")})}enhance(){if(this._wiredDateRange)return;this._wiredDateRange=true;this.addEventListener("change",(e)=>{const t=e.target;if(t&&(t.classList.contains("c-date-range__start")||t.classList.contains("c-date-range__end"))){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{start:this.querySelector(".c-date-range__start")?.value,end:this.querySelector(".c-date-range__end")?.value}}))}})}}define("contour-date-range",ContourDateRange);class ContourShortcut extends ContourBase{static get observed(){return["key","label"]}static get properties(){return{key:{attribute:"key"},label:{attribute:"label"}}}render(){this.classList.add("c-shortcut");const key=this.getAttribute("key")||"";const label=this.getAttribute("label")||"";if(key){const k=this.ensure(".c-shortcut__key",()=>{const el=document.createElement("kbd");el.className="c-shortcut__key";return el});k.textContent=key}if(label){const l=this.ensure(".c-shortcut__label",()=>{const el=document.createElement("span");el.className="c-shortcut__label";return el});l.textContent=label}}enhance(){if(this._wiredShortcut)return;this._wiredShortcut=true;const key=this.getAttribute("key");if(key){const handler=(e)=>{if(e.key===key&&(e.metaKey||e.ctrlKey)){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}};document.addEventListener("keydown",handler);onDispose(this,()=>document.removeEventListener("keydown",handler))}}}define("contour-shortcut",ContourShortcut);class ContourPopover extends ContourBase{static get observed(){return["title","content"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"}}}render(){this.classList.add("c-popover");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Popover");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("popover");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-popover__title",()=>{const el=document.createElement("div");el.className="c-popover__title";return el});t.textContent=title}const content=this.getAttribute("content");if(content){const c=this.ensure(".c-popover__body",()=>{const el=document.createElement("div");el.className="c-popover__body";return el});c.textContent=content}}enhance(){if(this._wiredPopover)return;this._wiredPopover=true;const close=()=>{try{this.hidePopover()}catch(e){}this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))};const keyHandler=(e)=>{const open=this.classList.contains("is-open")||this.matches(":popover-open");if(!open)return;if(e.key==="Escape"){e.preventDefault();close();return}if(e.key==="Tab"){const focusable=Array.from(this.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(!focusable.length){e.preventDefault();return}const first=focusable[0];const last=focusable[focusable.length-1];if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus()}else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus()}}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("contour:show",(e)=>{if(e.target&&e.target!==this&&this.contains(e.target)){this.classList.add("is-parent")}});this.addEventListener("contour:close",(e)=>{if(e.target&&e.target!==this){this.classList.remove("is-parent")}});this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-popover__close"):null;if(btn&&this.contains(btn))close()})}}define("contour-popover",ContourPopover);class ContourDatePicker extends ContourBase{static get observed(){return["value","range","range-start","range-end","label","disabled","error","help","time","min","max","locale"]}static get properties(){return{value:{attribute:"value"},range:{attribute:"range",type:Boolean},rangeStart:{attribute:"range-start"},rangeEnd:{attribute:"range-end"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},time:{attribute:"time",type:Boolean},min:{attribute:"min"},max:{attribute:"max"},locale:{attribute:"locale"}}}render(){this.classList.add("c-date-picker");this.setAttribute("role","group");this.setAttribute("aria-label","Date picker");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-date-picker__label",()=>{const el=document.createElement("label");el.className="c-date-picker__label";return el});l.textContent=label}const input=this.ensure(".c-date-picker__input",()=>{const el=document.createElement("input");el.className="c-input c-date-picker__input";return el});const range=this.hasAttribute("range");const type=this.hasAttribute("time")?"datetime-local":"date";const configure=(control,value,name)=>{control.type=type;control.value=value||"";control.setAttribute("aria-label",name);if(this.hasAttribute("min"))control.min=this.getAttribute("min");else control.removeAttribute("min");if(this.hasAttribute("max"))control.max=this.getAttribute("max");else control.removeAttribute("max");if(this.hasAttribute("locale"))control.lang=this.getAttribute("locale");else control.removeAttribute("lang");if(this.hasAttribute("disabled"))control.setAttribute("disabled","");else control.removeAttribute("disabled")};configure(input,range?this.getAttribute("range-start"):this.getAttribute("value"),range?"Start date":(label||"Date"));let end=this.querySelector(".c-date-picker__end");if(range){end=end||document.createElement("input");end.className="c-input c-date-picker__input c-date-picker__end";configure(end,this.getAttribute("range-end"),"End date");if(end.parentNode!==this)this.appendChild(end)}else if(end)end.remove();if(this.hasAttribute("disabled"))this.classList.add("is-disabled");else this.classList.remove("is-disabled");const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-date-picker__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-date-picker__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-date-picker__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}}_renderCalendar(){const cal=this.querySelector(".c-date-picker__calendar");if(!cal)return;const input=this.querySelector(".c-date-picker__input");const base=(input&&input.value)?new Date(input.value):new Date();const month=this._calMonth||new Date(base.getFullYear(),base.getMonth(),1);this._calMonth=month;const y=month.getFullYear();const m=month.getMonth();const first=new Date(y,m,1);const startDay=first.getDay();const daysInMonth=new Date(y,m+1,0).getDate();cal.innerHTML="";const header=document.createElement("div");header.className="c-date-picker__calendar-header";const prev=document.createElement("button");prev.type="button";prev.className="c-btn c-btn--sm";prev.textContent="‹";prev.setAttribute("aria-label","Previous month");const title=document.createElement("span");title.className="c-date-picker__calendar-title";title.textContent=month.toLocaleString(this.getAttribute("locale")||undefined,{month:"long",year:"numeric"});const next=document.createElement("button");next.type="button";next.className="c-btn c-btn--sm";next.textContent="›";next.setAttribute("aria-label","Next month");header.appendChild(prev);header.appendChild(title);header.appendChild(next);cal.appendChild(header);const grid=document.createElement("div");grid.className="c-date-picker__calendar-grid";grid.setAttribute("role","grid");const weekdays=["Su","Mo","Tu","We","Th","Fr","Sa"];weekdays.forEach((w)=>{const h=document.createElement("div");h.className="c-date-picker__calendar-weekday";h.textContent=w;grid.appendChild(h)});for(let i=0;i<startDay;i++){const empty=document.createElement("div");empty.className="c-date-picker__calendar-day c-date-picker__calendar-day--empty";grid.appendChild(empty)}const selected=input?input.value:"";for(let d=1;d<=daysInMonth;d++){const btn=document.createElement("button");btn.type="button";btn.className="c-date-picker__calendar-day";btn.textContent=String(d);const iso=`${y}-${String(m + 1).padStart(2, "0")}-${String(d).padStart(2, "0")}`;if(selected&&selected.startsWith(iso))btn.classList.add("is-selected");btn.addEventListener("click",()=>{if(input){input.value=iso;input.dispatchEvent(new Event("change",{bubbles:true}))}cal.setAttribute("hidden","");const tgl=this.querySelector(".c-date-picker__calendar-toggle");if(tgl)tgl.setAttribute("aria-expanded","false")});grid.appendChild(btn)}cal.appendChild(grid);prev.addEventListener("click",()=>{this._calMonth=new Date(y,m-1,1);this._renderCalendar()});next.addEventListener("click",()=>{this._calMonth=new Date(y,m+1,1);this._renderCalendar()})}enhance(){if(this._wiredDatePicker)return;this._wiredDatePicker=true;this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-date-picker__input")){const end=this.querySelector(".c-date-picker__end");const detail=end?{start:this.querySelector(".c-date-picker__input").value,end:end.value}:{value:t.value};this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail}))}});const toggle=()=>{const cal=this.querySelector(".c-date-picker__calendar");const btn=this.querySelector(".c-date-picker__calendar-toggle");if(!cal)return;const hidden=cal.hasAttribute("hidden");if(hidden){cal.removeAttribute("hidden");if(btn)btn.setAttribute("aria-expanded","true");this._renderCalendar()}else{cal.setAttribute("hidden","");if(btn)btn.setAttribute("aria-expanded","false")}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-date-picker__calendar-toggle"):null;if(btn&&this.contains(btn)){e.preventDefault();toggle()}})}}define("contour-date-picker",ContourDatePicker);class ContourRating extends ContourBase{static get observed(){return["value","max","color"]}static get properties(){return{value:{attribute:"value",type:Number},max:{attribute:"max",type:Number},color:{attribute:"color"}}}render(){this.classList.add("c-rating");this.setAttribute("role","radiogroup");this.setAttribute("aria-label","Rating");const max=parseInt(this.getAttribute("max")||"5",10)||5;const value=parseInt(this.getAttribute("value")||"0",10)||0;const color=this.getAttribute("color");Array.from(this.querySelectorAll(".c-rating__star")).forEach((n)=>n.remove());for(let i=1;i<=max;i++){const star=document.createElement("button");star.className="c-rating__star"+(i<=value?" c-rating__star--filled":"");star.type="button";star.setAttribute("role","radio");star.setAttribute("aria-checked",String(i===value));star.innerHTML='<span class="c-rating__swatch'+(i<=value?' c-rating__swatch--filled':'')+'" aria-hidden="true"'+(color&&i<=value?' style="background:'+color+';border-color:'+color+'"':'')+'></span>';star.dataset.value=String(i);star.setAttribute("aria-label",i+" star"+(i>1?"s":""));this.appendChild(star)}}enhance(){if(this._wiredRating)return;this._wiredRating=true;this.addEventListener("click",(e)=>{const star=e.target&&e.target.closest?e.target.closest(".c-rating__star"):null;if(star&&this.contains(star)){const v=parseInt(star.dataset.value,10);Array.from(this.querySelectorAll(".c-rating__star")).forEach((st)=>st.setAttribute("aria-checked",String(parseInt(st.dataset.value,10)===v)));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:v}}))}});this.addEventListener("keydown",(e)=>{const stars=Array.from(this.querySelectorAll(".c-rating__star"));const active=document.activeElement;const idx=stars.indexOf(active);if(e.key==="ArrowRight"||e.key==="ArrowUp"){e.preventDefault();const next=stars[Math.min(stars.length-1,idx+1)]||stars[0];if(next){try{next.focus()}catch(err){}}}else if(e.key==="ArrowLeft"||e.key==="ArrowDown"){e.preventDefault();const prev=stars[Math.max(0,idx-1)]||stars[stars.length-1];if(prev){try{prev.focus()}catch(err){}}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();if(active&&active.classList.contains("c-rating__star")){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:parseInt(active.dataset.value,10)}}))}}})}}define("contour-rating",ContourRating);class ContourTimePicker extends ContourBase{static get observed(){return["value","label","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-time-picker");this.setAttribute("role","group");this.setAttribute("aria-label","Time picker");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-time-picker__label",()=>{const el=document.createElement("label");el.className="c-time-picker__label";return el});l.textContent=label}const input=this.ensure(".c-time-picker__input",()=>{const el=document.createElement("input");el.className="c-input c-time-picker__input";el.type="time";return el});input.value=this.getAttribute("value")||"";if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-time-picker__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-time-picker__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-time-picker__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}}enhance(){if(this._wiredTimePicker)return;this._wiredTimePicker=true;this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-time-picker__input")){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:t.value}}))}})}}define("contour-time-picker",ContourTimePicker);class ContourColorPicker extends ContourBase{static get observed(){return["value","label","disabled","error","help","alpha","presets"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},alpha:{attribute:"alpha",type:Boolean},presets:{attribute:"presets"}}}render(){this.classList.add("c-color-picker");this.setAttribute("role","group");this.setAttribute("aria-label","Color picker");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-color-picker__label",()=>{const el=document.createElement("label");el.className="c-color-picker__label";return el});l.textContent=label}const input=this.ensure(".c-color-picker__input",()=>{const el=document.createElement("input");el.className="c-color-picker__input";el.type="color";return el});input.value=(this.getAttribute("value")||"#000000").slice(0,7);if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}if(this.hasAttribute("alpha")){const alpha=this.ensure(".c-color-picker__alpha",()=>{const el=document.createElement("input");el.className="c-color-picker__alpha";el.type="range";el.min="0";el.max="1";el.step="0.01";return el});const v=this.getAttribute("value")||"#000000";const a=v.length===9?parseInt(v.slice(7,9),16)/255:1;alpha.value=String(a);alpha.setAttribute("aria-label","Alpha")}else{const a=this.querySelector(".c-color-picker__alpha");if(a)a.remove()}const presetsAttr=this.getAttribute("presets");let presets=[];if(presetsAttr){try{presets=JSON.parse(presetsAttr)}catch(e){presets=[]}}const oldPresets=this.querySelector(".c-color-picker__presets");if(oldPresets)oldPresets.remove();if(Array.isArray(presets)&&presets.length){const wrap=document.createElement("div");wrap.className="c-color-picker__presets";presets.forEach((c)=>{const btn=document.createElement("button");btn.type="button";btn.className="c-color-picker__preset";btn.style.background=c;btn.dataset.color=c;btn.setAttribute("aria-label","Preset "+c);wrap.appendChild(btn)});this.appendChild(wrap)}if(typeof window!=="undefined"&&"EyeDropper"in window){const ed=this.ensure(".c-color-picker__eyedropper",()=>{const el=document.createElement("button");el.className="c-color-picker__eyedropper";el.type="button";el.textContent="Pick";el.setAttribute("aria-label","Pick color from screen");return el});if(this.hasAttribute("disabled"))ed.setAttribute("disabled","");else ed.removeAttribute("disabled")}else{const ed=this.querySelector(".c-color-picker__eyedropper");if(ed)ed.remove()}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-color-picker__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-color-picker__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-color-picker__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}}enhance(){if(this._wiredColorPicker)return;this._wiredColorPicker=true;this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-color-picker__input")){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:t.value}}))}if(t&&t.classList.contains("c-color-picker__alpha")){const base=(this.getAttribute("value")||"#000000").slice(0,7);const a=Math.round(parseFloat(t.value)*255).toString(16).padStart(2,"0");const val=base+a;this.setAttribute("value",val);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:val}}))}});this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-color-picker__preset"):null;if(btn&&this.contains(btn)){const c=btn.dataset.color;if(c){this.setAttribute("value",c);const input=this.querySelector(".c-color-picker__input");if(input)input.value=c.slice(0,7);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:c}}))}}const ed=e.target&&e.target.closest?e.target.closest(".c-color-picker__eyedropper"):null;if(ed&&this.contains(ed)&&typeof window!=="undefined"&&"EyeDropper"in window){e.preventDefault();const dropper=new window.EyeDropper();dropper.open().then((r)=>{if(r&&r.sRGBHex){this.setAttribute("value",r.sRGBHex);const input=this.querySelector(".c-color-picker__input");if(input)input.value=r.sRGBHex;this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:r.sRGBHex}}))}}).catch(()=>{})}})}}define("contour-color-picker",ContourColorPicker);class ContourNumberField extends ContourBase{static get observed(){return["value","min","max","step","label","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},min:{attribute:"min"},max:{attribute:"max"},step:{attribute:"step"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-number-field");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-number-field__label",()=>{const el=document.createElement("label");el.className="c-number-field__label";return el});l.textContent=label}const input=this.ensure(".c-number-field__input",()=>{const el=document.createElement("input");el.className="c-input c-number-field__input";el.type="number";el.setAttribute("role","spinbutton");return el});if(this.getAttribute("value")!==null)input.value=this.getAttribute("value");if(this.getAttribute("min")!==null)input.min=this.getAttribute("min");if(this.getAttribute("max")!==null)input.max=this.getAttribute("max");if(this.getAttribute("step")!==null)input.step=this.getAttribute("step");const v=input.value;input.setAttribute("aria-valuenow",v===""?"":v);if(input.min!=="")input.setAttribute("aria-valuemin",input.min);if(input.max!=="")input.setAttribute("aria-valuemax",input.max);if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-number-field__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-number-field__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-number-field__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}}enhance(){if(this._wiredNumberField)return;this._wiredNumberField=true;this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-number-field__input")){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:t.value}}))}});this.addEventListener("keydown",(e)=>{const input=this.querySelector(".c-number-field__input");if(!input||document.activeElement!==input)return;const step=Number(input.step)||1;const min=input.min===""?-Infinity:Number(input.min);const max=input.max===""?Infinity:Number(input.max);let next=null;if(e.key==="ArrowUp")next=(Number(input.value)||0)+step;else if(e.key==="ArrowDown")next=(Number(input.value)||0)-step;else if(e.key==="Home")next=min===-Infinity?0:min;else if(e.key==="End")next=max===Infinity?(Number(input.value)||0):max;if(next!==null){e.preventDefault();next=Math.min(max,Math.max(min,next));input.value=String(next);input.setAttribute("aria-valuenow",String(next));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:input.value}}))}})}}define("contour-number-field",ContourNumberField);class ContourHoverCard extends ContourBase{static get observed(){return["title","content","anchor"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"},anchor:{attribute:"anchor"}}}render(){this.classList.add("c-hover-card");if(!this.hasAttribute("role"))this.setAttribute("role","tooltip");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Hover card");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("hover-card");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-hover-card__title",()=>{const el=document.createElement("div");el.className="c-hover-card__title";return el});t.textContent=title}const content=this.getAttribute("content");if(content){const c=this.ensure(".c-hover-card__body",()=>{const el=document.createElement("div");el.className="c-hover-card__body";return el});c.textContent=content}}enhance(){if(this._wiredHoverCard)return;this._wiredHoverCard=true;const anchorSel=this.getAttribute("anchor");if(anchorSel){const trigger=anchorSel.startsWith("#")?document.getElementById(anchorSel.slice(1)):document.querySelector(anchorSel);if(trigger){trigger.setAttribute("popovertarget",this.id);let showTimer=null;const hasPopover=typeof this.showPopover==="function";const show=()=>{if(hasPopover){try{this.showPopover()}catch(e){}}else this.classList.add("is-open");this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))};const hide=()=>{if(showTimer)clearTimeout(showTimer);if(hasPopover){try{this.hidePopover()}catch(e){}}else this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))};trigger.addEventListener("mouseenter",()=>{showTimer=setTimeout(show,300)});trigger.addEventListener("mouseleave",()=>{hide()});trigger.addEventListener("focus",show);trigger.addEventListener("blur",()=>{setTimeout(hide,100)});onDispose(this,()=>{if(showTimer){clearTimeout(showTimer);showTimer=null}})}}const keyHandler=(e)=>{if(e.key==="Escape"&&(this.classList.contains("is-open")||this.matches(":popover-open"))){e.preventDefault();if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(err){}}this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler))}}define("contour-hover-card",ContourHoverCard);class ContourContextMenu extends ContourBase{static get observed(){return["items"]}static get properties(){return{items:{attribute:"items"}}}render(){this.classList.add("c-context-menu");if(!this.hasAttribute("role"))this.setAttribute("role","menu");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("context-menu");const items=this.getAttribute("items");if(items){try{const parsed=JSON.parse(items);this.innerHTML="";parsed.forEach((it)=>{const btn=document.createElement("button");btn.className="c-menu__item";btn.setAttribute("role","menuitem");btn.textContent=typeof it==="string"?it:(it.label||it.title||"");this.appendChild(btn)})}catch(e){}}}enhance(){if(this._wiredContextMenu)return;this._wiredContextMenu=true;this.addEventListener("contextmenu",(e)=>{e.preventDefault();if(typeof this.showPopover==="function"){try{this.showPopover()}catch(err){}}else this.classList.toggle("is-open")});this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;if(item&&this.contains(item)){this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{label:item.textContent.trim()}}));if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(err){}}this.classList.remove("is-open")}});this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-menu__item"));const active=document.activeElement;const idx=items.indexOf(active);if(e.key==="ArrowDown"){e.preventDefault();const next=items[Math.min(items.length-1,idx+1)]||items[0];if(next)try{next.focus()}catch(err){}}else if(e.key==="ArrowUp"){e.preventDefault();const prev=items[Math.max(0,idx-1)]||items[items.length-1];if(prev)try{prev.focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();if(active&&active.classList.contains("c-menu__item"))active.click()}else if(e.key==="Escape"){e.preventDefault();if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(err){}}this.classList.remove("is-open")}})}}define("contour-context-menu",ContourContextMenu);class ContourFab extends ContourBase{static get observed(){return["label","icon"]}static get properties(){return{label:{attribute:"label"},icon:{attribute:"icon"}}}render(){this.classList.add("c-fab");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");const label=this.getAttribute("label");if(label)this.setAttribute("aria-label",label);const icon=this.getAttribute("icon");if(icon&&!this.hasChildNodes())this.textContent=icon}enhance(){if(this._wiredFab)return;this._wiredFab=true;this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))});this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}})}}define("contour-fab",ContourFab);class ContourFileUpload extends ContourBase{static get observed(){return["label","accept","multiple","progress"]}static get properties(){return{label:{attribute:"label"},accept:{attribute:"accept"},multiple:{attribute:"multiple",type:Boolean},progress:{attribute:"progress"}}}render(){this.classList.add("c-file-upload");const label=this.getAttribute("label")||"Drop files here or click to browse";const dz=this.ensure(".c-file-upload__dropzone",()=>{const el=document.createElement("div");el.className="c-file-upload__dropzone";el.setAttribute("role","button");el.tabIndex=0;return el});dz.textContent=label;const input=this.ensure(".c-file-upload__input",()=>{const el=document.createElement("input");el.className="c-file-upload__input";el.type="file";el.hidden=true;return el});input.accept=this.getAttribute("accept")||"";input.multiple=this.hasAttribute("multiple");const p=this.getAttribute("progress");if(p!==null){const bar=this.ensure(".c-file-upload__progress",()=>{const el=document.createElement("progress");el.className="c-file-upload__progress";return el});bar.value=Number(p)||0;bar.max=100}else{const bar=this.querySelector(".c-file-upload__progress");if(bar)bar.remove()}const preview=this.ensure(".c-file-upload__preview",()=>{const el=document.createElement("div");el.className="c-file-upload__preview";return el});if(!preview){}}enhance(){if(this._wiredFileUpload)return;this._wiredFileUpload=true;const dz=()=>this.querySelector(".c-file-upload__dropzone");const input=()=>this.querySelector(".c-file-upload__input");const activate=()=>{const i=input();if(i)i.click()};this.addEventListener("click",(e)=>{const d=dz();if(e.target===d||(d&&d.contains(e.target))){activate()}});this.addEventListener("keydown",(e)=>{const d=dz();if((e.target===d||(d&&d.contains(e.target)))&&(e.key==="Enter"||e.key===" ")){e.preventDefault();activate()}});const renderPreview=(files)=>{const preview=this.querySelector(".c-file-upload__preview");if(!preview)return;preview.innerHTML="";Array.from(files||[]).forEach((f)=>{const item=document.createElement("div");item.className="c-file-upload__preview-item";if(f.type&&f.type.startsWith("image/")){const img=document.createElement("img");img.className="c-file-upload__preview-thumb";img.alt=f.name;img.loading="lazy";img.decoding="async";try{img.src=URL.createObjectURL(f)}catch(e){}item.appendChild(img)}else{const name=document.createElement("span");name.className="c-file-upload__preview-name";name.textContent=f.name;item.appendChild(name)}preview.appendChild(item)})};this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-file-upload__input")){renderPreview(t.files);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{files:t.files}}))}});this.addEventListener("dragover",(e)=>{e.preventDefault();this.classList.add("is-dragover")});this.addEventListener("dragleave",()=>this.classList.remove("is-dragover"));this.addEventListener("drop",(e)=>{e.preventDefault();this.classList.remove("is-dragover");const i=input();if(i&&e.dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files.length){try{i.files=e.dataTransfer.files}catch(err){}const preview=this.querySelector(".c-file-upload__preview");if(preview){preview.innerHTML="";Array.from(e.dataTransfer.files).forEach((f)=>{const item=document.createElement("div");item.className="c-file-upload__preview-item";if(f.type&&f.type.startsWith("image/")){const img=document.createElement("img");img.className="c-file-upload__preview-thumb";img.alt=f.name;try{img.src=URL.createObjectURL(f)}catch(err2){}item.appendChild(img)}else{const name=document.createElement("span");name.className="c-file-upload__preview-name";name.textContent=f.name;item.appendChild(name)}preview.appendChild(item)})}this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{files:e.dataTransfer.files}}))}})}}define("contour-file-upload",ContourFileUpload);class ContourNotificationCenter extends ContourBase{static get observed(){return["count","items","color"]}static get properties(){return{count:{attribute:"count"},items:{attribute:"items"},color:{attribute:"color"}}}render(){this.classList.add("c-notification-center");this.setAttribute("role","list");const btn=this.ensure(".c-notification-center__trigger",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-notification-center__trigger";el.type="button";el.innerHTML='<span class="c-notification-center__bullet" aria-hidden="true"></span>';el.setAttribute("aria-haspopup","dialog");el.setAttribute("aria-expanded","false");return el});const color=this.getAttribute("color");const bullet=btn.querySelector(".c-notification-center__bullet");if(bullet&&color){bullet.style.background=color;bullet.dataset.color=color}const count=this.getAttribute("count");let badge=btn.querySelector(".c-notification-center__badge");if(count&&Number(count)>0){if(!badge){badge=document.createElement("span");badge.className="c-notification-center__badge c-badge c-badge--dot";btn.appendChild(badge)}badge.textContent=count}else if(badge){badge.remove()}const panel=this.ensure(".c-notification-center__panel",()=>{const el=document.createElement("div");el.className="c-notification-center__panel";el.hidden=true;el.setAttribute("role","dialog");el.setAttribute("aria-label","Notifications");return el});const authoredItems=Array.from(this.querySelectorAll(":scope > .c-notification-center__item"));const items=this.getAttribute("items");if(authoredItems.length){panel.innerHTML="";authoredItems.forEach((it)=>{panel.appendChild(it)})}else if(items){try{const parsed=JSON.parse(items);panel.innerHTML="";parsed.forEach((it)=>{const row=document.createElement("div");row.className="c-notification-center__item";row.setAttribute("tabindex","0");row.setAttribute("role","option");row.textContent=typeof it==="string"?it:(it.text||it.title||"");panel.appendChild(row)})}catch(e){}}}enhance(){if(this._wiredNotifCenter)return;this._wiredNotifCenter=true;this.addEventListener("click",(e)=>{const btn=this.querySelector(".c-notification-center__trigger");const panel=this.querySelector(".c-notification-center__panel");if(btn&&(e.target===btn||btn.contains(e.target))){if(panel){panel.hidden=!panel.hidden;btn.setAttribute("aria-expanded",String(!panel.hidden));this.dispatchEvent(new CustomEvent(panel.hidden?"contour:close":"contour:open",{bubbles:true,composed:true}))}}});this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-notification-center__item"):null;if(item&&this.contains(item)){this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{label:item.textContent}}))}});const docClick=(e)=>{const panel=this.querySelector(".c-notification-center__panel");const btn=this.querySelector(".c-notification-center__trigger");if(panel&&!panel.hidden&&!this.contains(e.target)){panel.hidden=true;if(btn)btn.setAttribute("aria-expanded","false")}};document.addEventListener("click",docClick);onDispose(this,()=>document.removeEventListener("click",docClick));const keyHandler=(e)=>{const panel=this.querySelector(".c-notification-center__panel");const btn=this.querySelector(".c-notification-center__trigger");if(e.key==="Escape"&&panel&&!panel.hidden){panel.hidden=true;if(btn){btn.setAttribute("aria-expanded","false");try{btn.focus()}catch(err){}}return}if(!panel||panel.hidden)return;const items=Array.from(panel.querySelectorAll(".c-notification-center__item"));if(!items.length)return;const active=document.activeElement;const idx=items.indexOf(active);if(e.key==="ArrowDown"){e.preventDefault();const next=items[Math.min(items.length-1,idx+1)]||items[0];if(next)try{next.focus()}catch(err){}}else if(e.key==="ArrowUp"){e.preventDefault();const prev=items[Math.max(0,idx-1)]||items[items.length-1];if(prev)try{prev.focus()}catch(err){}}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler))}}define("contour-notification-center",ContourNotificationCenter);class ContourStepper extends ContourBase{static get observed(){return["steps","current"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current"}}}render(){this.classList.add("c-stepper");const steps=this.getAttribute("steps");const current=Number(this.getAttribute("current")||0);const list=this.ensure(".c-stepper__list",()=>{const el=document.createElement("ol");el.className="c-stepper__list";return el});list.innerHTML="";const authoredSteps=Array.from(this.querySelectorAll(":scope > .c-stepper__step"));let parsed=[];if(authoredSteps.length){parsed=authoredSteps.map((el)=>el.textContent.trim());authoredSteps.forEach((el)=>el.remove())}else{try{parsed=steps?JSON.parse(steps):[]}catch(e){parsed=[]}}parsed.forEach((s,i)=>{const li=document.createElement("li");li.className="c-stepper__step"+(i===current?" is-current":"")+(i<current?" is-done":"");if(i===current)li.setAttribute("aria-current","step");li.textContent=typeof s==="string"?s:(s.title||s.label||"");list.appendChild(li)});const nav=this.ensure(".c-stepper__nav",()=>{const el=document.createElement("div");el.className="c-stepper__nav c-btn-group";return el});const prev=this.ensure(".c-stepper__prev",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-stepper__prev";el.type="button";el.textContent="Back";return el});const next=this.ensure(".c-stepper__next",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-stepper__next";el.type="button";el.textContent="Next";return el});if(!nav.contains(prev))nav.appendChild(prev);if(!nav.contains(next))nav.appendChild(next);if(nav.parentNode!==this)this.appendChild(nav)}enhance(){if(this._wiredStepper)return;this._wiredStepper=true;const go=(dir)=>{const list=this.querySelector(".c-stepper__list");const total=list?list.querySelectorAll(".c-stepper__step").length:0;if(!total)return;let cur=Number(this.getAttribute("current")||0);if(dir==="prev")cur=Math.max(0,cur-1);else cur=Math.min(total-1,cur+1);this.setAttribute("current",String(cur));this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{direction:dir,index:cur}}))};this.addEventListener("click",(e)=>{const prev=e.target&&e.target.closest?e.target.closest(".c-stepper__prev"):null;const next=e.target&&e.target.closest?e.target.closest(".c-stepper__next"):null;if(prev&&this.contains(prev))go("prev");if(next&&this.contains(next))go("next")});this.addEventListener("keydown",(e)=>{if(e.key==="ArrowLeft"){e.preventDefault();go("prev")}else if(e.key==="ArrowRight"){e.preventDefault();go("next")}})}}define("contour-stepper",ContourStepper);class ContourVirtualList extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","item-height","orientation","sticky"]}static get properties(){return{items:{attribute:"items"},"item-height":{attribute:"item-height"},orientation:{attribute:"orientation"},sticky:{attribute:"sticky",type:Boolean}}}_items(){const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}return Array.isArray(parsed)?parsed:[]}_itemHeight(){const h=Number(this.getAttribute("item-height"));return Number.isFinite(h)&&h>0?h:28}_autoHeight(){return this.getAttribute("item-height")==="auto"}render(){this.classList.add("c-virtual-list");this.setAttribute("role","list");const scroller=this.ensure(".c-virtual-list__scroller",()=>{const el=document.createElement("div");el.className="c-virtual-list__scroller";return el});scroller.setAttribute("role","presentation");const horizontal=this.getAttribute("orientation")==="horizontal";scroller.style.overflowX=horizontal?"auto":"hidden";scroller.style.overflowY=horizontal?"hidden":"auto";const inner=this.ensure(".c-virtual-list__inner",()=>{const el=document.createElement("div");el.className="c-virtual-list__inner";el.style.position="relative";return el});if(inner.parentNode!==scroller)scroller.appendChild(inner);this._renderWindow(scroller,inner,horizontal?(scroller.scrollLeft||0):(scroller.scrollTop||0))}_measureHeights(inner,horizontal){const rows=Array.from(inner.querySelectorAll(".c-virtual-list__item"));return rows.map((r)=>horizontal?(r.getBoundingClientRect().width||28):(r.getBoundingClientRect().height||28))}_renderWindow(scroller,inner,scrollTop){const items=this._items();const ih=this._itemHeight();const horizontal=this.getAttribute("orientation")==="horizontal";const autoHeight=this._autoHeight();const viewportSize=horizontal?(scroller.clientWidth||320):(scroller.clientHeight||320);const total=items.length;if(this._vlItemCount!==total){this._vlHeights=null;this._vlItemCount=total}let heights=autoHeight?this._vlHeights:null;let cumulative=null;if(autoHeight&&heights&&heights.length===total){cumulative=[0];for(let i=0;i<total;i++)cumulative.push(cumulative[i]+(heights[i]||28))}const visibleCount=autoHeight&&!cumulative?total:(autoHeight?Math.ceil(viewportSize/28)+6:Math.ceil(viewportSize/ih)+4);let start=0;if(autoHeight&&cumulative){let lo=0,hi=total;while(lo<hi){const mid=(lo+hi)>>1;if(cumulative[mid]<(scrollTop||0))lo=mid+1;else hi=mid}start=Math.max(0,lo-3)}else if(!autoHeight){start=Math.floor((scrollTop||0)/ih)}if(start<0)start=0;const end=autoHeight&&cumulative?Math.min(total,start+visibleCount):Math.min(total,start+visibleCount);if(start>Math.max(0,total-visibleCount)&&!autoHeight)start=Math.max(0,total-visibleCount);const topSpacerSize=autoHeight&&cumulative?cumulative[start]:(autoHeight?0:start*ih);const bottomSpacerSize=autoHeight&&cumulative?Math.max(0,cumulative[total]-cumulative[end]):(autoHeight?0:Math.max(0,(total-end)*ih));inner.style.display=horizontal?"flex":"block";inner.style.width=horizontal&&autoHeight?"max-content":"";inner.style.height=horizontal||autoHeight?"":(total*ih)+"px";inner.innerHTML="";const top=document.createElement("div");top.className="c-virtual-list__spacer c-virtual-list__spacer--top";top.style[horizontal?"width":"height"]=topSpacerSize+"px";inner.appendChild(top);for(let i=start;i<end;i++){const row=document.createElement("div");row.className="c-virtual-list__item";row.setAttribute("role","listitem");row.setAttribute("tabindex",i===0?"0":"-1");row.textContent=typeof items[i]==="string"?items[i]:(items[i].label||items[i].text||JSON.stringify(items[i]));if(this.hasAttribute("sticky")&&items[i]&&items[i].sticky){row.style.position="sticky";row.style.insetBlockStart="0";row.style.zIndex="1"}if(horizontal&&!autoHeight)row.style.flex="0 0 "+ih+"px";row.dataset.index=String(i);inner.appendChild(row)}const bottom=document.createElement("div");bottom.className="c-virtual-list__spacer c-virtual-list__spacer--bottom";bottom.style[horizontal?"width":"height"]=bottomSpacerSize+"px";inner.appendChild(bottom);if(horizontal&&!autoHeight)inner.style.width=(total*ih)+"px";if(autoHeight&&!this._vlHeights){requestAnimationFrame(()=>{this._vlHeights=this._measureHeights(inner,horizontal);const s=scroller;const i=inner;if(s&&i)this._renderWindow(s,i,s.scrollTop||0)})}}enhance(){if(this._wiredVirtualList)return;this._wiredVirtualList=true;const scroller=()=>this.querySelector(".c-virtual-list__scroller");const inner=()=>this.querySelector(".c-virtual-list__inner");let raf=0;const onScroll=()=>{if(raf)return;raf=requestAnimationFrame(()=>{raf=0;const s=scroller();const i=inner();if(s&&i)this._renderWindow(s,i,this.getAttribute("orientation")==="horizontal"?s.scrollLeft:s.scrollTop)})};const s=scroller();if(s){s.addEventListener("scroll",onScroll,{passive:true});onDispose(this,()=>{s.removeEventListener("scroll",onScroll);if(raf)cancelAnimationFrame(raf)})}this.addEventListener("keydown",(e)=>{const rows=Array.from(this.querySelectorAll(".c-virtual-list__item"));if(!rows.length)return;const active=this.querySelector(".c-virtual-list__item:focus")||rows[0];const idx=rows.indexOf(active);let next=-1;if(e.key==="ArrowDown")next=Math.min(idx+1,rows.length-1);else if(e.key==="ArrowUp")next=Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=rows.length-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();const i=Number(active.dataset.index);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:i,value:active.textContent}}));return}if(next<0||next===idx)return;e.preventDefault();rows.forEach((r,i)=>r.setAttribute("tabindex",i===next?"0":"-1"));try{rows[next].focus()}catch(err){}});this.addEventListener("click",(e)=>{const row=e.target&&e.target.closest?e.target.closest(".c-virtual-list__item"):null;if(!row||!this.contains(row))return;const i=Number(row.dataset.index);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:i,value:row.textContent}}))})}}define("contour-virtual-list",ContourVirtualList);class ContourCommandPalette extends ContourBase{static get observed(){return["open","items"]}static get properties(){return{open:{attribute:"open",type:Boolean},items:{attribute:"items"}}}render(){this.classList.add("c-command-palette");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("aria-modal"))this.setAttribute("aria-modal","true");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");const search=this.ensure(".c-command-palette__search",()=>{const el=document.createElement("input");el.className="c-input c-command-palette__search";el.type="search";el.placeholder="Search…";el.setAttribute("aria-label","Search commands");return el});const list=this.ensure(".c-command-palette__list",()=>{const el=document.createElement("div");el.className="c-command-palette__list";el.setAttribute("role","listbox");return el});const items=this.getAttribute("items");if(items){try{const parsed=JSON.parse(items);list.innerHTML="";parsed.forEach((it,i)=>{const row=document.createElement("div");row.className="c-command-palette__item";row.setAttribute("role","option");row.id=this.id+"-opt-"+i;row.textContent=typeof it==="string"?it:(it.label||it.title||"");row.dataset.index=String(i);row.dataset.label=row.textContent;list.appendChild(row)})}catch(e){}}}show(){if(typeof this.showPopover==="function"){try{this.showPopover()}catch(e){}}this.classList.add("is-open")}hide(){if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(e){}}this.classList.remove("is-open")}toggle(){if(this.classList.contains("is-open")||this.matches(":popover-open"))this.hide();else this.show()}enhance(){this._wiredCmdPalette=true;const search=()=>this.querySelector(".c-command-palette__search");const list=()=>this.querySelector(".c-command-palette__list");const items=()=>Array.from(this.querySelectorAll(".c-command-palette__item"));const visibleItems=()=>items().filter((it)=>!it.hidden);const setActive=(idx)=>{const vis=visibleItems();vis.forEach((it,i)=>it.classList.toggle("is-active",i===idx));const active=vis[idx];const s=search();if(s&&active)s.setAttribute("aria-activedescendant",active.id);else if(s)s.removeAttribute("aria-activedescendant")};const filter=(q)=>{const needle=(q||"").toLowerCase().trim();items().forEach((it)=>{const label=(it.dataset.label||it.textContent||"").toLowerCase();it.hidden=needle!==""&&!label.includes(needle)});setActive(0)};const select=(it)=>{if(!it)return;this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:Number(it.dataset.index),label:it.dataset.label||it.textContent}}));try{this.hidePopover()}catch(e){}this.classList.remove("is-open")};const s=search();if(s){s.setAttribute("role","combobox");s.setAttribute("aria-autocomplete","list");s.setAttribute("aria-controls",list()?list().id||"":"");if(!list().id)list().id=this.id+"-list";s.setAttribute("aria-controls",list().id);s.addEventListener("input",(e)=>filter(e.target.value));s.addEventListener("keydown",(e)=>{const vis=visibleItems();const active=this.querySelector(".c-command-palette__item.is-active");let idx=active?vis.indexOf(active):-1;if(e.key==="ArrowDown"){e.preventDefault();idx=Math.min(vis.length-1,idx+1);if(idx<0)idx=0;setActive(idx)}else if(e.key==="ArrowUp"){e.preventDefault();idx=Math.max(0,idx-1);if(vis.length&&idx<0)idx=0;setActive(idx)}else if(e.key==="Home"){e.preventDefault();setActive(0)}else if(e.key==="End"){e.preventDefault();setActive(vis.length-1)}else if(e.key==="Enter"){e.preventDefault();if(active)select(active)}else if(e.key==="Escape"){e.preventDefault();try{this.hidePopover()}catch(e){}this.classList.remove("is-open")}})}this.addEventListener("click",(e)=>{const it=e.target&&e.target.closest?e.target.closest(".c-command-palette__item"):null;if(it&&this.contains(it)&&!it.hidden)select(it)});let lastFocus=null;this.addEventListener("beforetoggle",(e)=>{if(e.newState==="open")lastFocus=document.activeElement;else if(lastFocus&&typeof lastFocus.focus==="function"){try{lastFocus.focus()}catch(err){}}});setActive(0)}}define("contour-command-palette",ContourCommandPalette);class ContourBadgeOverflow extends ContourBase{static get observed(){return["count","max"]}static get properties(){return{count:{attribute:"count"},max:{attribute:"max"}}}render(){this.classList.add("c-badge-overflow");const count=Number(this.getAttribute("count")||0);const max=Number(this.getAttribute("max")||3);const extra=Math.max(0,count-max);this.textContent="";if(extra>0){const b=document.createElement("span");b.className="c-badge c-badge-overflow__more";b.textContent="+"+extra;this.appendChild(b)}}}define("contour-badge-overflow",ContourBadgeOverflow);class ContourSideSheet extends ContourBase{static get observed(){return["open","side","title"]}static get properties(){return{open:{attribute:"open",type:Boolean},side:{attribute:"side"},title:{attribute:"title"}}}render(){this.classList.add("c-side-sheet");this.setAttribute("role","dialog");this.setAttribute("aria-modal","true");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Side sheet");const side=this.getAttribute("side")||"end";this.classList.add("c-side-sheet--"+side);if(this.hasAttribute("open"))this.classList.add("is-open");else this.classList.remove("is-open");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-side-sheet__title",()=>{const el=document.createElement("div");el.className="c-side-sheet__title";return el});t.textContent=title}}enhance(){if(this._wiredSideSheet)return;this._wiredSideSheet=true;let lastFocus=null;const close=()=>this.removeAttribute("open");const keyHandler=(e)=>{if(e.key==="Escape"&&this.hasAttribute("open")){e.preventDefault();close();return}if(e.key==="Tab"&&this.hasAttribute("open")){const focusables=Array.from(this.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")).filter((el)=>!el.hasAttribute("disabled"));if(!focusables.length){e.preventDefault();return}const first=focusables[0],last=focusables[focusables.length-1];if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus()}else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus()}}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("click",(e)=>{if(e.target===this)close()});const obs=new MutationObserver(()=>{if(this.hasAttribute("open")){lastFocus=document.activeElement;const first=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(first)try{first.focus()}catch(err){}}else if(lastFocus){try{lastFocus.focus()}catch(err){}lastFocus=null}});obs.observe(this,{attributes:true,attributeFilter:["open"]});onDispose(this,()=>obs.disconnect())}}define("contour-side-sheet",ContourSideSheet);class ContourTour extends ContourBase{static get observed(){return["steps","current"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current"}}}render(){this.classList.add("c-tour");this.setAttribute("role","dialog");this.setAttribute("aria-modal","true");this.setAttribute("aria-label","Tour");const steps=this.getAttribute("steps");const current=Number(this.getAttribute("current")||0);let parsed=[];try{parsed=steps?JSON.parse(steps):[]}catch(e){parsed=[]}const step=parsed[current]||{};const tip=this.ensure(".c-tour__tip",()=>{const el=document.createElement("div");el.className="c-tour__tip";return el});tip.textContent=typeof step==="string"?step:(step.text||step.title||"");const nav=this.ensure(".c-tour__nav",()=>{const el=document.createElement("div");el.className="c-tour__nav c-btn-group";return el});const next=this.ensure(".c-tour__next",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-tour__next";el.type="button";el.textContent="Next";return el});if(!nav.contains(next))nav.appendChild(next)}enhance(){if(this._wiredTour)return;this._wiredTour=true;const nextBtn=this.querySelector(".c-tour__next");if(nextBtn)try{nextBtn.focus()}catch(err){}this.addEventListener("click",(e)=>{const next=e.target&&e.target.closest?e.target.closest(".c-tour__next"):null;if(next&&this.contains(next))this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{direction:"next"}}))});const keyHandler=(e)=>{if(e.key==="Escape")this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler))}}define("contour-tour",ContourTour);class ContourTagsInput extends ContourBase{static get observed(){return["value","placeholder","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},placeholder:{attribute:"placeholder"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-tags-input");const input=this.ensure(".c-tags-input__input",()=>{const el=document.createElement("input");el.className="c-input c-tags-input__input";el.type="text";el.setAttribute("aria-label","Add tag");return el});input.placeholder=this.getAttribute("placeholder")||"Add tag…";if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-tags-input__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-tags-input__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-tags-input__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const tags=this.getAttribute("value");let parsed=[];try{parsed=tags?JSON.parse(tags):[]}catch(e){parsed=tags?tags.split(",").map((s)=>s.trim()).filter(Boolean):[]}Array.from(this.querySelectorAll(".c-tags-input__tag")).forEach((n)=>n.remove());parsed.forEach((t)=>{const chip=document.createElement("span");chip.className="c-tag c-tags-input__tag";chip.textContent=t;const rm=document.createElement("button");rm.className="c-tags-input__remove";rm.type="button";rm.textContent="×";rm.dataset.value=t;chip.appendChild(rm);this.insertBefore(chip,input)})}enhance(){if(this._wiredTagsInput)return;this._wiredTagsInput=true;let live=this.querySelector(".c-tags-input__live");if(!live){live=document.createElement("span");live.className="c-tags-input__live visually-hidden";live.setAttribute("aria-live","polite");live.setAttribute("aria-atomic","true");this.appendChild(live)}const announce=(msg)=>{if(live)live.textContent=msg};this.addEventListener("keydown",(e)=>{const input=this.querySelector(".c-tags-input__input");if(!input)return;if(e.key==="Enter"&&e.target===input){e.preventDefault();const v=input.value.trim();if(v){let tags=[];try{tags=JSON.parse(this.getAttribute("value")||"[]")}catch(err){tags=(this.getAttribute("value")||"").split(",").map((s)=>s.trim()).filter(Boolean)}if(!Array.isArray(tags))tags=[];if(!tags.includes(v))tags.push(v);this.setAttribute("value",JSON.stringify(tags));input.value="";announce("Added "+v);this.dispatchEvent(new CustomEvent("contour:add",{bubbles:true,composed:true,detail:{value:v}}))}}else if(e.key==="Backspace"&&e.target===input&&input.value===""){let tags=[];try{tags=JSON.parse(this.getAttribute("value")||"[]")}catch(err){tags=(this.getAttribute("value")||"").split(",").map((s)=>s.trim()).filter(Boolean)}if(!Array.isArray(tags))tags=[];if(tags.length){const removed=tags.pop();this.setAttribute("value",JSON.stringify(tags));announce("Removed "+removed);this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:true,composed:true,detail:{value:removed}}))}}});this.addEventListener("click",(e)=>{const rm=e.target&&e.target.closest?e.target.closest(".c-tags-input__remove"):null;if(rm&&this.contains(rm)){const val=rm.dataset.value;let tags=[];try{tags=JSON.parse(this.getAttribute("value")||"[]")}catch(err){tags=(this.getAttribute("value")||"").split(",").map((s)=>s.trim()).filter(Boolean)}if(!Array.isArray(tags))tags=[];const next=tags.filter((t)=>t!==val);this.setAttribute("value",JSON.stringify(next));announce("Removed "+val);this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:true,composed:true,detail:{value:val}}))}})}}define("contour-tags-input",ContourTagsInput);class ContourSortableList extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items"]}static get properties(){return{items:{attribute:"items"}}}render(){this.classList.add("c-sortable-list");const list=this.ensure(".c-sortable-list__list",()=>{const el=document.createElement("ul");el.className="c-sortable-list__list";return el});const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}list.innerHTML="";parsed.forEach((it,i)=>{const li=document.createElement("li");li.className="c-sortable-list__item";li.setAttribute("draggable","true");li.dataset.index=String(i);const handle=document.createElement("span");handle.className="c-sortable-list__handle";handle.textContent="⋮⋮";handle.setAttribute("role","button");handle.tabIndex=0;li.appendChild(handle);const label=document.createElement("span");label.className="c-sortable-list__label";label.textContent=typeof it==="string"?it:(it.label||it.text||"");li.appendChild(label);list.appendChild(li)})}enhance(){if(this._wiredSortableList)return;this._wiredSortableList=true;const list=()=>this.querySelector(".c-sortable-list__list");let live=this.querySelector(".c-sortable-list__live");if(!live){live=document.createElement("span");live.className="c-sortable-list__live visually-hidden";live.setAttribute("aria-live","polite");live.setAttribute("aria-atomic","true");this.appendChild(live)}const announce=(msg)=>{if(live)live.textContent=msg};const index=(li)=>Array.from(list().children).indexOf(li);let dragFrom=null;this.addEventListener("dragstart",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-sortable-list__item"):null;if(!li||!this.contains(li))return;dragFrom=index(li);if(e.dataTransfer){e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",String(dragFrom))}catch(err){}}li.classList.add("is-dragging")});this.addEventListener("dragover",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-sortable-list__item"):null;if(!li||!this.contains(li)||dragFrom===null)return;e.preventDefault();if(e.dataTransfer)e.dataTransfer.dropEffect="move"});this.addEventListener("drop",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-sortable-list__item"):null;if(!li||!this.contains(li)||dragFrom===null)return;e.preventDefault();const to=index(li);const l=list();const fromLi=l.children[dragFrom];if(fromLi&&dragFrom!==to){if(dragFrom<to)l.insertBefore(fromLi,l.children[to+1]||null);else l.insertBefore(fromLi,l.children[to]);const item=fromLi.querySelector(".c-sortable-list__label");announce((item?item.textContent:"Item")+" moved to position "+(to+1));this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:true,composed:true,detail:{from:dragFrom,to}}))}dragFrom=null;Array.from(l.children).forEach((n)=>n.classList.remove("is-dragging"))});this.addEventListener("dragend",()=>{dragFrom=null;const l=list();if(l)Array.from(l.children).forEach((n)=>n.classList.remove("is-dragging"))});this.addEventListener("keydown",(e)=>{const handle=e.target&&e.target.closest?e.target.closest(".c-sortable-list__handle"):null;if(!handle)return;const li=handle.closest(".c-sortable-list__item");if(!li)return;const l=list();const from=index(li);if(e.key==="ArrowUp"&&li.previousElementSibling){e.preventDefault();l.insertBefore(li,li.previousElementSibling);const to=index(li);const label=li.querySelector(".c-sortable-list__label");announce((label?label.textContent:"Item")+" moved to position "+(to+1));this.dispatchEvent(new CustomEvent("contour:move",{bubbles:true,composed:true,detail:{direction:"up",from,to}}));this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:true,composed:true,detail:{from,to}}))}if(e.key==="ArrowDown"&&li.nextElementSibling){e.preventDefault();l.insertBefore(li.nextElementSibling,li);const to=index(li);const label=li.querySelector(".c-sortable-list__label");announce((label?label.textContent:"Item")+" moved to position "+(to+1));this.dispatchEvent(new CustomEvent("contour:move",{bubbles:true,composed:true,detail:{direction:"down",from,to}}));this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:true,composed:true,detail:{from,to}}))}})}}define("contour-sortable-list",ContourSortableList);class ContourSwatch extends ContourBase{static get observed(){return["color","selected","label"]}static get properties(){return{color:{attribute:"color"},selected:{attribute:"selected",type:Boolean},label:{attribute:"label"}}}render(){this.classList.add("c-swatch");const color=this.getAttribute("color")||"#000";this.style.setProperty("--swatch-color",color);if(this.hasAttribute("selected"))this.classList.add("is-selected");else this.classList.remove("is-selected");if(!this.hasAttribute("aria-label")){const label=this.getAttribute("label")||color;this.setAttribute("aria-label",label)}if(!this.querySelector("button")&&!this.querySelector("span")){const btn=document.createElement("button");btn.className="c-swatch__btn";btn.type="button";this.appendChild(btn)}}enhance(){if(this._wiredSwatch)return;this._wiredSwatch=true;this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:this.getAttribute("color")}}))})}}define("contour-swatch",ContourSwatch);class ContourCalendar extends ContourBase{static get observed(){return["value"]}static get properties(){return{value:{attribute:"value"},month:{attribute:"month"},year:{attribute:"year"}}}render(){this.classList.add("c-calendar");const now=new Date();const year=Number(this.getAttribute("year"))||now.getFullYear();const month=Number(this.getAttribute("month"))||now.getMonth();const header=this.ensure(".c-calendar__header",()=>{const el=document.createElement("div");el.className="c-calendar__header";return el});header.innerHTML="";const prev=document.createElement("button");prev.type="button";prev.className="c-btn c-btn--sm c-calendar__prev";prev.textContent="‹";prev.setAttribute("aria-label","Previous month");const title=document.createElement("span");title.className="c-calendar__title";title.textContent=new Date(year,month,1).toLocaleString(undefined,{month:"long",year:"numeric"});const next=document.createElement("button");next.type="button";next.className="c-btn c-btn--sm c-calendar__next";next.textContent="›";next.setAttribute("aria-label","Next month");header.appendChild(prev);header.appendChild(title);header.appendChild(next);const grid=this.ensure(".c-calendar__grid",()=>{const el=document.createElement("div");el.className="c-calendar__grid";el.setAttribute("role","grid");return el});grid.setAttribute("aria-label",title.textContent);grid.innerHTML="";const first=new Date(year,month,1);const startDay=first.getDay();const daysInMonth=new Date(year,month+1,0).getDate();const selected=this.getAttribute("value");for(let i=0;i<startDay;i++){const empty=document.createElement("div");empty.className="c-calendar__day c-calendar__day--empty";grid.appendChild(empty)}for(let d=1;d<=daysInMonth;d++){const cell=document.createElement("button");cell.className="c-calendar__day";cell.type="button";cell.setAttribute("role","gridcell");cell.setAttribute("tabindex","0");cell.textContent=String(d);const iso=year+"-"+String(month+1).padStart(2,"0")+"-"+String(d).padStart(2,"0");if(iso===selected){cell.classList.add("is-selected");cell.setAttribute("aria-selected","true")}else cell.setAttribute("aria-selected","false");const todayIso=now.getFullYear()+"-"+String(now.getMonth()+1).padStart(2,"0")+"-"+String(now.getDate()).padStart(2,"0");if(iso===todayIso)cell.setAttribute("aria-current","date");cell.dataset.value=iso;grid.appendChild(cell)}if(header.parentNode!==this)this.insertBefore(header,grid)}enhance(){if(this._wiredCalendar)return;this._wiredCalendar=true;this.addEventListener("click",(e)=>{const prev=e.target&&e.target.closest?e.target.closest(".c-calendar__prev"):null;const next=e.target&&e.target.closest?e.target.closest(".c-calendar__next"):null;if(prev&&this.contains(prev)){let m=Number(this.getAttribute("month"))||new Date().getMonth();let y=Number(this.getAttribute("year"))||new Date().getFullYear();m-=1;if(m<0){m=11;y-=1}this.setAttribute("month",String(m));this.setAttribute("year",String(y));this.render();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{month:m,year:y}}));return}if(next&&this.contains(next)){let m=Number(this.getAttribute("month"))||new Date().getMonth();let y=Number(this.getAttribute("year"))||new Date().getFullYear();m+=1;if(m>11){m=0;y+=1}this.setAttribute("month",String(m));this.setAttribute("year",String(y));this.render();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{month:m,year:y}}));return}const cell=e.target&&e.target.closest?e.target.closest(".c-calendar__day"):null;if(cell&&this.contains(cell)&&cell.dataset.value){this.setAttribute("value",cell.dataset.value);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:cell.dataset.value}}))}});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-calendar__day"):null;if(!cell||!this.contains(cell))return;const cells=Array.from(this.querySelectorAll(".c-calendar__day:not(.c-calendar__day--empty)"));const idx=cells.indexOf(cell);let next=null;if(e.key==="ArrowRight")next=cells[idx+1];else if(e.key==="ArrowLeft")next=cells[idx-1];else if(e.key==="ArrowDown")next=cells[idx+7];else if(e.key==="ArrowUp")next=cells[idx-7];else if(e.key==="Enter"||e.key===" "){e.preventDefault();cell.click();return}if(next){e.preventDefault();try{next.focus()}catch(err){}}})}}define("contour-calendar",ContourCalendar);class ContourCarousel extends ContourBase{static get observed(){return["items","index"]}static get properties(){return{items:{attribute:"items"},index:{attribute:"index"}}}_items(){const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}return Array.isArray(parsed)?parsed:[]}_index(){const i=Number(this.getAttribute("index"));const items=this._items();if(Number.isFinite(i)&&i>=0&&i<items.length)return i;return 0}render(){this.classList.add("c-carousel");this.setAttribute("role","region");this.setAttribute("aria-roledescription","carousel");const track=this.ensure(".c-carousel__track",()=>{const el=document.createElement("div");el.className="c-carousel__track";el.setAttribute("role","group");el.setAttribute("aria-roledescription","slide container");return el});const items=this._items();track.innerHTML="";const idx=this._index();items.forEach((it,i)=>{const slide=document.createElement("div");slide.className="c-carousel__slide"+(i===idx?" is-active":"");slide.setAttribute("role","group");slide.setAttribute("aria-roledescription","slide");slide.setAttribute("aria-label",(i+1)+" of "+items.length);slide.setAttribute("aria-hidden",i===idx?"false":"true");slide.textContent=typeof it==="string"?it:(it.label||it.text||"");slide.dataset.index=String(i);track.appendChild(slide)});const prev=this.ensure(".c-carousel__prev",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-carousel__prev";el.type="button";el.textContent="‹";el.setAttribute("aria-label","Previous slide");return el});const next=this.ensure(".c-carousel__next",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-carousel__next";el.type="button";el.textContent="›";el.setAttribute("aria-label","Next slide");return el});const status=this.ensure(".c-carousel__status",()=>{const el=document.createElement("span");el.className="c-carousel__status";el.setAttribute("aria-live","polite");return el});status.textContent=(idx+1)+" of "+items.length}enhance(){if(this._wiredCarousel)return;this._wiredCarousel=true;const go=(dir)=>{const items=this._items();if(!items.length)return;let idx=this._index();if(dir==="prev")idx=(idx-1+items.length)%items.length;else idx=(idx+1)%items.length;this.setAttribute("index",String(idx));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:idx,direction:dir}}))};this.addEventListener("click",(e)=>{const prev=e.target&&e.target.closest?e.target.closest(".c-carousel__prev"):null;const next=e.target&&e.target.closest?e.target.closest(".c-carousel__next"):null;if(prev&&this.contains(prev))go("prev");if(next&&this.contains(next))go("next")});this.addEventListener("keydown",(e)=>{if(e.key==="ArrowLeft"){e.preventDefault();go("prev")}else if(e.key==="ArrowRight"){e.preventDefault();go("next")}else if(e.key==="Home"){e.preventDefault();this.setAttribute("index","0");this.render();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:0,direction:"home"}}))}else if(e.key==="End"){e.preventDefault();const last=this._items().length-1;if(last>=0){this.setAttribute("index",String(last));this.render();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:last,direction:"end"}}))}}})}}define("contour-carousel",ContourCarousel);class ContourDataGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["columns","rows","page","filter","page-size","resizable","virtual","row-height"]}static get properties(){return{columns:{attribute:"columns"},rows:{attribute:"rows"},page:{attribute:"page"},filter:{attribute:"filter"},"page-size":{attribute:"page-size"},resizable:{attribute:"resizable",type:Boolean},virtual:{attribute:"virtual",type:Boolean},"row-height":{attribute:"row-height"}}}render(){this.classList.add("c-data-grid");if(this.hasAttribute("loading")||this.hasAttribute("error")||this.hasAttribute("empty")){const table=this.ensure(".c-data-grid__table",()=>{const el=document.createElement("table");el.className="c-table c-data-grid__table";el.setAttribute("role","grid");return el});const tbody=this.ensure("tbody",()=>{const el=document.createElement("tbody");return el});if(tbody.parentNode!==table)table.appendChild(tbody);tbody.innerHTML="";const tr=document.createElement("tr");const td=document.createElement("td");td.colSpan=1;td.style.textAlign="center";td.style.color="var(--color-text-muted)";if(this.hasAttribute("loading"))td.textContent=this.getAttribute("loading")||"Loading…";else if(this.hasAttribute("error"))td.textContent=this.getAttribute("error")||"Error";else td.textContent=this.getAttribute("empty")||"No data";tr.appendChild(td);tbody.appendChild(tr);let wrap=this.querySelector(".c-data-grid__wrap");if(!wrap){wrap=document.createElement("div");wrap.className="c-data-grid__wrap";wrap.style.maxHeight="400px";wrap.style.overflow="auto"}if(table.parentNode!==wrap)wrap.appendChild(table);if(wrap.parentNode!==this)this.appendChild(wrap);return}const table=this.ensure(".c-data-grid__table",()=>{const el=document.createElement("table");el.className="c-table c-data-grid__table";el.setAttribute("role","grid");return el});const thead=this.ensure("thead",()=>{const el=document.createElement("thead");return el});const tbody=this.ensure("tbody",()=>{const el=document.createElement("tbody");return el});if(thead.parentNode!==table)table.appendChild(thead);if(tbody.parentNode!==table)table.appendChild(tbody);const cols=this.getAttribute("columns");let parsedCols=[];try{parsedCols=cols?JSON.parse(cols):[]}catch(e){parsedCols=[]}if(parsedCols.length&&!thead.querySelector("tr")){const tr=document.createElement("tr");parsedCols.forEach((c)=>{const th=document.createElement("th");th.setAttribute("role","columnheader");th.setAttribute("aria-sort","none");th.setAttribute("tabindex","0");th.textContent=typeof c==="string"?c:(c.label||c.key||"");tr.appendChild(th)});thead.appendChild(tr)}if(this.hasAttribute("resizable")){Array.from(thead.querySelectorAll("th")).forEach((th)=>{th.style.position="relative";th.setAttribute("data-resizable","true")})}const rows=this.getAttribute("rows");let parsedRows=[];try{parsedRows=rows?JSON.parse(rows):[]}catch(e){parsedRows=[]}table.setAttribute("aria-rowcount",String(parsedRows.length));table.setAttribute("aria-colcount",String(parsedCols.length));const filter=this.getAttribute("filter");if(filter){const q=filter.toLowerCase();parsedRows=parsedRows.filter((r)=>JSON.stringify(r).toLowerCase().includes(q))}const page=Number(this.getAttribute("page")||1);const pageSize=Number(this.getAttribute("page-size")||0);if(pageSize>0){const start=(page-1)*pageSize;parsedRows=parsedRows.slice(start,start+pageSize)}this._dgCols=parsedCols;this._dgRows=parsedRows;this._dgFilteredRows=parsedRows;const virtual=this.hasAttribute("virtual")&&!(Number(this.getAttribute("page-size"))>0);if(virtual){this._renderDataGridWindow(0)}else{tbody.innerHTML="";parsedRows.forEach((r)=>{const tr=document.createElement("tr");parsedCols.forEach((c)=>{const key=typeof c==="string"?c:(c.key||c.label||"");const td=document.createElement("td");td.setAttribute("role","gridcell");td.setAttribute("tabindex","0");td.textContent=r&&r[key]!=null?r[key]:"";if(!String(td.textContent).trim())td.setAttribute("aria-label","Empty");tr.appendChild(td)});tbody.appendChild(tr)})}let wrap=this.querySelector(".c-data-grid__wrap");if(!wrap){wrap=document.createElement("div");wrap.className="c-data-grid__wrap";wrap.style.maxHeight="400px";wrap.style.overflow="auto"}if(table.parentNode!==wrap)wrap.appendChild(table);if(wrap.parentNode!==this)this.appendChild(wrap)}_rowHeight(){const h=Number(this.getAttribute("row-height"));return Number.isFinite(h)&&h>0?h:32}_renderDataGridWindow(scrollTop){const table=this.querySelector(".c-data-grid__table");const tbody=table&&table.querySelector("tbody");if(!tbody)return;const cols=this._dgCols||[];const rows=this._dgRows||[];const rh=this._rowHeight();const viewport=400;const visibleCount=Math.ceil(viewport/rh)+6;let start=Math.floor((scrollTop||0)/rh);if(start<0)start=0;if(start>Math.max(0,rows.length-visibleCount))start=Math.max(0,rows.length-visibleCount);const end=Math.min(rows.length,start+visibleCount);tbody.innerHTML="";if(start>0){const sp=document.createElement("tr");const td=document.createElement("td");td.colSpan=Math.max(1,cols.length);td.style.blockSize=(start*rh)+"px";td.style.padding="0";sp.appendChild(td);tbody.appendChild(sp)}for(let i=start;i<end;i++){const r=rows[i];const tr=document.createElement("tr");tr.dataset.index=String(i);cols.forEach((c)=>{const key=typeof c==="string"?c:(c.key||c.label||"");const td=document.createElement("td");td.setAttribute("role","gridcell");td.setAttribute("tabindex","0");td.textContent=r&&r[key]!=null?r[key]:"";if(!String(td.textContent).trim())td.setAttribute("aria-label","Empty");tr.appendChild(td)});tbody.appendChild(tr)}if(end<rows.length){const sp=document.createElement("tr");const td=document.createElement("td");td.colSpan=Math.max(1,cols.length);td.style.blockSize=((rows.length-end)*rh)+"px";td.style.padding="0";sp.appendChild(td);tbody.appendChild(sp)}}enhance(){if(this._wiredDataGrid)return;this._wiredDataGrid=true;const wrap=()=>this.querySelector(".c-data-grid__wrap");const onScroll=()=>{const w=wrap();if(w&&this.hasAttribute("virtual"))this._renderDataGridWindow(w.scrollTop)};this.addEventListener("scroll",(e)=>{const w=e.target&&e.target.classList&&e.target.classList.contains("c-data-grid__wrap")?e.target:null;if(w&&this.hasAttribute("virtual"))this._renderDataGridWindow(w.scrollTop)},true);let sortCol=-1,sortDir="asc";this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest("[role='gridcell'], [role='columnheader']"):null;if(!cell||!this.contains(cell))return;const row=cell.parentElement;const table=this.querySelector(".c-data-grid__table");if(!table)return;const rows=Array.from(table.querySelectorAll("tr"));const ri=rows.indexOf(row);const ci=Array.from(row.children).indexOf(cell);let target=null;if(e.key==="ArrowRight")target=row.children[ci+1];else if(e.key==="ArrowLeft")target=row.children[ci-1];else if(e.key==="ArrowDown")target=rows[ri+1]&&rows[ri+1].children[ci];else if(e.key==="ArrowUp")target=rows[ri-1]&&rows[ri-1].children[ci];if(target){e.preventDefault();try{target.focus()}catch(err){}}});this.addEventListener("click",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tr"):null;const th=e.target&&e.target.closest?e.target.closest("th"):null;if(tr&&this.contains(tr)&&!th){const idx=Array.from(tr.parentElement.children).indexOf(tr);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{row:idx}}))}if(th&&this.contains(th)){const idx=Array.from(th.parentElement.children).indexOf(th);if(sortCol===idx)sortDir=sortDir==="asc"?"desc":"asc";else{sortCol=idx;sortDir="asc"}const table=this.querySelector(".c-data-grid__table");const tbody=table&&table.querySelector("tbody");const thead=table&&table.querySelector("thead");if(tbody&&thead){const cols=Array.from(thead.querySelectorAll("th")).map((h)=>h.textContent);const rows=Array.from(tbody.querySelectorAll("tr")).map((tr)=>Array.from(tr.querySelectorAll("td")).map((td)=>td.textContent));rows.sort((a,b)=>{const va=a[idx]||"",vb=b[idx]||"";const na=Number(va),nb=Number(vb);const cmp=(!isNaN(na)&&!isNaN(nb))?na-nb:String(va).localeCompare(String(vb));return sortDir==="asc"?cmp:-cmp});tbody.innerHTML="";rows.forEach((r)=>{const tr=document.createElement("tr");r.forEach((v)=>{const td=document.createElement("td");td.textContent=v;tr.appendChild(td)});tbody.appendChild(tr)})}Array.from(thead.querySelectorAll("th")).forEach((h,i)=>{h.setAttribute("aria-sort",i===idx?(sortDir==="asc"?"ascending":"descending"):"none")});this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:true,composed:true,detail:{column:idx,direction:sortDir}}))}});this.addEventListener("pointerdown",(e)=>{if(!this.hasAttribute("resizable"))return;const th=e.target&&e.target.closest?e.target.closest("th[data-resizable]"):null;if(!th||!this.contains(th)||th.getBoundingClientRect().right-e.clientX>10)return;e.preventDefault();const startX=e.clientX;const startWidth=th.getBoundingClientRect().width;const index=Array.from(th.parentElement.children).indexOf(th);const move=(event)=>{const width=Math.max(48,startWidth+event.clientX-startX);const table=this.querySelector(".c-data-grid__table");if(table)Array.from(table.rows).forEach((row)=>{if(row.children[index])row.children[index].style.inlineSize=width+"px"})};const stop=()=>window.removeEventListener("pointermove",move);window.addEventListener("pointermove",move);window.addEventListener("pointerup",stop,{once:true});onDispose(this,stop)})}}define("contour-data-grid",ContourDataGrid);class ContourTreeGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","expanded"]}static get properties(){return{items:{attribute:"items"},expanded:{attribute:"expanded"}}}_expandedSet(){const raw=this.getAttribute("expanded");if(!raw)return new Set();try{return new Set(JSON.parse(raw))}catch(e){return new Set([raw])}}render(){this.classList.add("c-tree-grid");const table=this.ensure(".c-tree-grid__table",()=>{const el=document.createElement("table");el.className="c-table c-tree-grid__table";el.setAttribute("role","treegrid");return el});table.setAttribute("aria-label","Tree grid");const tbody=this.ensure("tbody",()=>{const el=document.createElement("tbody");return el});if(tbody.parentNode!==table)table.appendChild(tbody);const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}const expanded=this._expandedSet();tbody.innerHTML="";const rows=[];const renderNode=(node,depth,path)=>{const tr=document.createElement("tr");tr.setAttribute("role","row");tr.setAttribute("tabindex","0");tr.setAttribute("aria-level",String(depth+1));tr.dataset.path=path;const hasChildren=!!(node&&Array.isArray(node.children)&&node.children.length);if(hasChildren){tr.setAttribute("aria-expanded",expanded.has(path)?"true":"false")}const td=document.createElement("td");td.setAttribute("role","gridcell");td.style.paddingInlineStart=(depth*1.25)+"rem";const label=(node&&(node.label||node.text||node.name))||"";if(hasChildren){const toggle=document.createElement("button");toggle.type="button";toggle.className="c-tree-grid__toggle";toggle.textContent=expanded.has(path)?"▾":"▸";toggle.setAttribute("aria-label",(expanded.has(path)?"Collapse":"Expand")+" "+label);td.appendChild(toggle)}const span=document.createElement("span");span.className="c-tree-grid__label";span.textContent=label;td.appendChild(span);tr.appendChild(td);tbody.appendChild(tr);rows.push(tr);if(hasChildren&&expanded.has(path)){node.children.forEach((c,i)=>renderNode(c,depth+1,path+"."+i))}};parsed.forEach((n,i)=>renderNode(n,0,String(i)));if(table.parentNode!==this)this.appendChild(table)}enhance(){if(this._wiredTreeGrid)return;this._wiredTreeGrid=true;const rows=()=>Array.from(this.querySelectorAll("tr[role='row']"));this.addEventListener("click",(e)=>{const toggle=e.target&&e.target.closest?e.target.closest(".c-tree-grid__toggle"):null;const tr=e.target&&e.target.closest?e.target.closest("tr[role='row']"):null;if(!tr||!this.contains(tr))return;const path=tr.dataset.path;if(toggle){e.preventDefault();const expanded=this._expandedSet();if(expanded.has(path))expanded.delete(path);else expanded.add(path);this.setAttribute("expanded",JSON.stringify([...expanded]));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{path,expanded:expanded.has(path)}}))}else{this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{path}}))}});this.addEventListener("keydown",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tr[role='row']"):null;if(!tr||!this.contains(tr))return;const all=rows();const idx=all.indexOf(tr);const path=tr.dataset.path;const hasChildren=tr.getAttribute("aria-expanded")!==null;const expanded=this._expandedSet();if(e.key==="ArrowRight"&&hasChildren&&!expanded.has(path)){e.preventDefault();expanded.add(path);this.setAttribute("expanded",JSON.stringify([...expanded]));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{path,expanded:true}}))}else if(e.key==="ArrowLeft"&&hasChildren&&expanded.has(path)){e.preventDefault();expanded.delete(path);this.setAttribute("expanded",JSON.stringify([...expanded]));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{path,expanded:false}}))}else if(e.key==="ArrowDown"){e.preventDefault();if(all[idx+1])try{all[idx+1].focus()}catch(err){}}else if(e.key==="ArrowUp"){e.preventDefault();if(all[idx-1])try{all[idx-1].focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();const toggle=tr.querySelector(".c-tree-grid__toggle");if(toggle)toggle.click()}})}}define("contour-tree-grid",ContourTreeGrid);class ContourPullToRefresh extends ContourBase{static get observed(){return["threshold"]}static get properties(){return{threshold:{attribute:"threshold"}}}render(){this.classList.add("c-pull-to-refresh");const ind=this.ensure(".c-pull-to-refresh__indicator",()=>{const e=document.createElement("div");e.className="c-pull-to-refresh__indicator";e.textContent="Pull to refresh";return e});if(ind.parentNode!==this)this.prepend(ind)}enhance(){if(this._wiredPullToRefresh)return;this._wiredPullToRefresh=true;let startY=0;let pulling=false;this.addEventListener("touchstart",(e)=>{if(this.scrollTop>0)return;const t=e.touches&&e.touches[0];if(t){startY=t.clientY;pulling=true}},{passive:true});this.addEventListener("touchmove",(e)=>{if(!pulling)return;const t=e.touches&&e.touches[0];if(!t)return;const dy=t.clientY-startY;if(dy>0&&dy<120){this.style.setProperty("--ptr-offset",dy+"px")}},{passive:true});this.addEventListener("touchend",(e)=>{if(!pulling)return;pulling=false;const t=e.changedTouches&&e.changedTouches[0];const dy=t?t.clientY-startY:0;const thr=Number(this.getAttribute("threshold"))||60;if(dy>=thr){this.classList.add("is-refreshing");this.dispatchEvent(new CustomEvent("contour:refresh",{bubbles:true,composed:true}));setTimeout(()=>this.classList.remove("is-refreshing"),800)}this.style.removeProperty("--ptr-offset")},{passive:true})}}define("contour-pull-to-refresh",ContourPullToRefresh);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"]));let ADOPTED=null;let ADOPTED_KEY="";const adoptedSheets=()=>{let key=document.styleSheets.length+":";for(const sheet of document.styleSheets){let rules=-1;try{rules=sheet.cssRules.length}catch(e){}key+=(sheet.href||"")+"~"+rules+"|"}if(ADOPTED&&key===ADOPTED_KEY)return ADOPTED;ADOPTED_KEY=key;ADOPTED=[];const collect=(sheet,out)=>{let rules;try{rules=sheet.cssRules}catch(e){return}if(!rules)return;for(const r of rules){if(r instanceof CSSImportRule){if(r.styleSheet)collect(r.styleSheet,out)}else{try{out.push(r.cssText)}catch(e){}}}};for(const sheet of document.styleSheets){try{if(sheet.href&&new URL(sheet.href).origin===location.origin){const collected=[];collect(sheet,collected);const built=new CSSStyleSheet();if(collected.length)built.replaceSync(collected.join("\n"));ADOPTED.push(built)}}catch(e){}}return ADOPTED};const _ShadowParent=(typeof HTMLElement!=="undefined")?HTMLElement:Object;class ContourShadow extends _ShadowParent{static get observedAttributes(){return MODS}constructor(){super();const root=this.attachShadow({mode:"open"});const sheets=adoptedSheets();if(sheets.length)root.adoptedStyleSheets=sheets;root.appendChild(this.constructor.contourTemplate.content.cloneNode(true));this._shadowBase=root.firstElementChild?root.firstElementChild.className:""}enhance(root){if(!root)root=this.shadowRoot;if(!root)return;root.querySelectorAll("details").forEach((d)=>{const summary=d.querySelector("summary");if(summary&&!summary.hasAttribute("aria-expanded")){summary.setAttribute("aria-expanded",String(d.open));d.addEventListener("toggle",()=>{summary.setAttribute("aria-expanded",String(d.open))})}});root.querySelectorAll("[data-live]").forEach((el)=>{if(!el.hasAttribute("role"))el.setAttribute("role","status");if(!el.hasAttribute("aria-live"))el.setAttribute("aria-live","polite")});root.querySelectorAll(".c-spinner").forEach((el)=>{if(!el.hasAttribute("role"))el.setAttribute("role","status");if(!el.hasAttribute("aria-live"))el.setAttribute("aria-live","polite")});root.querySelectorAll(".c-toast, .c-toast-host").forEach((el)=>{if(!el.hasAttribute("role"))el.setAttribute("role","status");if(!el.hasAttribute("aria-live"))el.setAttribute("aria-live","polite");if(!el.hasAttribute("aria-atomic"))el.setAttribute("aria-atomic","true")});root.querySelectorAll("[role='tab']").forEach((tab)=>{const ctrl=tab.getAttribute("aria-controls");if(ctrl){const panel=root.querySelector("#"+CSS.escape(ctrl))||document.getElementById(ctrl);if(panel&&!panel.hasAttribute("aria-labelledby")){if(!tab.id)tab.id=contourId("tab");panel.setAttribute("aria-labelledby",tab.id)}}});root.querySelectorAll("input, textarea, select").forEach((input)=>{if(input.hasAttribute("aria-describedby"))return;const field=input.closest(".c-field");if(field){const hint=field.querySelector(".c-field__hint");if(hint){if(!hint.id)hint.id=contourId("hint");input.setAttribute("aria-describedby",hint.id)}const err=field.querySelector(".c-field__error");if(err){if(!err.id)err.id=contourId("err");const existing=input.getAttribute("aria-describedby")||"";input.setAttribute("aria-describedby",(existing+" "+err.id).trim())}}});root.querySelectorAll(".c-alert").forEach((el)=>{if(!el.hasAttribute("role"))el.setAttribute("role","alert");if(!el.hasAttribute("aria-live"))el.setAttribute("aria-live","assertive")});root.querySelectorAll("input[required], textarea[required], select[required]").forEach((el)=>{if(!el.hasAttribute("aria-required"))el.setAttribute("aria-required","true")})}connectedCallback(){this.applyMods();try{this.enhance(this.shadowRoot)}catch(e){}try{wcReset(this);wireTabs(this);wireSegmented(this);wireCombobox(this);wireTree(this);wireMenu(this);wirePagination(this);wireCopy(this);wireRemovable(this)}catch(e){}if(this.shadowRoot&&!this._wiredSlotchange){this._wiredSlotchange=true;this.shadowRoot.addEventListener("slotchange",()=>{try{this.enhance(this.shadowRoot);wireTabs(this);wireSegmented(this);wireCombobox(this);wireTree(this);wireMenu(this);wirePagination(this);wireCopy(this);wireRemovable(this)}catch(e){}})}}attributeChangedCallback(){this.applyMods()}applyMods(){const el=this.shadowRoot.firstElementChild;if(!el||!this._shadowBase)return;const mods=[];for(const attr of MODS){const val=this.getAttribute(attr);if(!val)continue;for(const cls of this._shadowBase.split(/\s+/)){if(cls)mods.push("c-"+cls.replace(/^c-/,"")+"--"+val)}}el.className=(this._shadowBase+" "+mods.join(" ")).trim()}}const SHADOW_PARTS_PUBLIC={};const shadow=(name,markup)=>{if(typeof document==="undefined")return;const tpl=document.createElement("template");tpl.innerHTML=markup;SHADOW_PARTS_PUBLIC[name]=[...tpl.content.querySelectorAll("[part]")].flatMap((node)=>(node.getAttribute("part")||"").split(/\s+/)).filter(Boolean);const cls=class extends ContourShadow{};cls.contourTemplate=tpl;define(name,cls)};const slotWrapper=(tag,block,part)=>"<"+tag+' class="c-'+block+'" part="'+(part||block)+'"'+(tag==="button"?' type="button"':"")+"><slot></slot></"+tag+">";const 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","scheme-toggle"],span:["avatar","badge","chip","dot","flag","live-badge","mark","pill"],a:["link","linkish"],kbd:["kbd"],label:["check","radio","switch"],select:["select"],nav:["docs-nav"],};const SHADOW_PARTS={"version-banner":"banner","contour-plot":"plot",};if(typeof document!=="undefined"){for(const[tag,blocks]of Object.entries(SHADOW_SLOTS)){for(const block of blocks){const part=SHADOW_PARTS[block]||block;shadow("contour-shadow-"+block,slotWrapper(tag,block,part))}}}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-table",`<div class="c-table-wrap" part="wrap"><table class="c-table" part="table"><thead><slot name="head"></slot></thead><tbody><slot></slot></tbody></table></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-input",`<input class="c-input" part="input" />`);shadow("contour-shadow-spinner",`<span class="c-spinner" part="spinner" aria-label="Loading"></span>`);shadow("contour-shadow-textarea",`<textarea class="c-textarea" part="textarea"></textarea>`);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>`);class ContourShadowDialog extends ContourShadow{static contourTemplate=(typeof document!=="undefined")?(()=>{const tpl=document.createElement("template");tpl.innerHTML="<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\"><use href=\"#i-close\" /></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>";return tpl})():null;enhance(root){super.enhance(root);if(this._wiredShadowDialog)return;this._wiredShadowDialog=true;const dlg=root.querySelector("dialog");const close=root.querySelector('[part="close"]');if(close)close.addEventListener("click",()=>dlg?.close());if(dlg){let lastFocus=null;dlg.addEventListener("beforetoggle",(e)=>{if(e.newState==="open"){lastFocus=document.activeElement;this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}));const focusable=dlg.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable)try{focusable.focus()}catch(e){}}else if(e.newState==="closed"){this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));if(lastFocus&&typeof lastFocus.focus==="function"){try{lastFocus.focus()}catch(e){}}}});dlg.addEventListener("keydown",(e)=>{if(e.key!=="Tab")return;const focusables=Array.from(dlg.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])"));if(!focusables.length)return;const first=focusables[0];const last=focusables[focusables.length-1];if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus()}else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus()}})}}show(){this.shadowRoot?.querySelector("dialog")?.showModal()}close(){this.shadowRoot?.querySelector("dialog")?.close()}}define("contour-shadow-dialog",ContourShadowDialog);if(typeof window!=="undefined"){window.ContourElements=Object.freeze(REGISTERED.slice());window.ContourShadowParts=Object.freeze(Object.fromEntries(Object.entries(SHADOW_PARTS_PUBLIC).map(([name,parts])=>[name,Object.freeze([...new Set(parts)])]),));window.ContourEvents=Object.freeze(CONTOUR_EVENTS)}
1
+ "use strict";export const REGISTERED=[];const DISPOSERS=new WeakMap();export const onDispose=(host,fn)=>{let list=DISPOSERS.get(host);if(!list){list=[];DISPOSERS.set(host,list)}list.push(fn)};function contourDebugEnabled(){try{if(typeof window!=="undefined"&&(window.ContourDebug||window.__CONTOUR_DEBUG__))return true}catch(e){}try{if(typeof process!=="undefined"&&process.env&&process.env.NODE_ENV!=="production"&&process.env.CONTOUR_DEBUG)return true}catch(e){}return false}const runDisposers=(host)=>{const list=DISPOSERS.get(host);if(!list)return;DISPOSERS.delete(host);for(const fn of list){try{fn()}catch(e){if(contourDebugEnabled()){try{console.warn("Contour disposer failed for",host&&host.tagName,e)}catch(err){}}}}};let _contourIdCounter=0;export const contourId=(prefix)=>prefix+"-"+(++_contourIdCounter).toString(36);export const define=(name,cls)=>{if(typeof customElements==="undefined"||!customElements||typeof customElements.define!=="function")return;if(customElements.get(name))return;customElements.define(name,cls);REGISTERED.push(name)};export const MODS=["variant","size","color"];export const CONTOUR_EVENTS=Object.freeze({"contour:activate":{payload:["files","label","row","value"],composed:true},"contour:add":{payload:["value"],composed:true},"contour:activity-clear":{payload:[],composed:true},"contour:activity-filter":{payload:["unread"],composed:true},"contour:activity-select":{payload:["index","text"],composed:true},"contour:break-change":{payload:["layer","value"],composed:true},"contour:style-resolved":{payload:["applied","classification","colors","items","layer","n","palette","property","value"],composed:true},"contour:advanced-toggle":{payload:["title"],composed:true},"contour:affordance-activate":{payload:["name"],composed:true},"contour:aggregate":{payload:["aggregate"],composed:true},"contour:bearing":{payload:["direction","degrees"],composed:true},"contour:btn-group-change":{payload:["index","label"],composed:true},"contour:brush-start":{payload:["end","range","start","value"],composed:true},"contour:brush-end":{payload:["end","range","start","value"],composed:true},"contour:brush":{payload:["end","range","start","value"],composed:true},"contour:change":{payload:["checked","color","direction","end","files","high","index","low","month","name","paused","query","speed","start","unit","value","values","year"],composed:true},"contour:collapse":{payload:["collapsed"],composed:true},"contour:cluster-toggle":{payload:["count","expanded"],composed:true},"contour:clear":{payload:[],composed:true},"contour:clear-all":{payload:[],composed:true},"contour:close":{payload:["count","index","label","message","open","value"],composed:true},"contour:copy":{payload:["text"],composed:true},"contour:apply":{payload:["name"],composed:true},"contour:dash-action":{payload:["label"],composed:true},"contour:diff-activate":{payload:["kind","text"],composed:true},"contour:dismiss":{payload:["label"],composed:true},"contour:draw-start":{payload:["mode"],composed:true},"contour:drag":{payload:["delta","key","value"],composed:true},"contour:do-dont-activate":{payload:["kind","text"],composed:true},"contour:docs-nav-select":{payload:["label","href"],composed:true},"contour:dragend":{payload:["value"],composed:true},"contour:dragstart":{payload:["value"],composed:true},"contour:drop":{payload:["value","label"],composed:true},"contour:empty-action":{payload:["state"],composed:true},"contour:filter":{payload:["query"],composed:true},"contour:filter-change":{payload:["source","filter"],composed:true},"contour:error":{payload:["src","message","name","status"],composed:true},"contour:export":{payload:["format"],composed:true},"contour:refresh":{payload:[],composed:true},"contour:hide":{payload:[],composed:true},"contour:hover":{payload:["row"],composed:true},"contour:input":{payload:["name","value","checked"],composed:true},"contour:invalid":{payload:["field","input","message"],composed:true,cancelable:true},"contour:inspect-action":{payload:["label"],composed:true},"contour:layer-opacity":{payload:["name","opacity"],composed:true},"contour:layer-rename":{payload:["name","newName"],composed:true},"contour:layer-duplicate":{payload:["name"],composed:true},"contour:layer-zoom":{payload:["name"],composed:true},"contour:zoom":{payload:["data","index","row"],composed:true},"contour:layer-projection":{payload:["name","projection"],composed:true},"contour:layer-remove":{payload:["name"],composed:true},"contour:layer-reorder":{payload:["layerIds"],composed:true},"contour:layer-toggle":{payload:["name","visible"],composed:true},"contour:layer-visibility":{payload:["name","visible"],composed:true},"contour:legend-toggle":{payload:["index","key","label","pressed"],composed:true},"contour:leave":{payload:[],composed:true},"contour:load":{payload:["src","count"],composed:true},"contour:map-control":{payload:["control"],composed:true},"contour:map-attach":{payload:[],composed:true},"contour:map-detach":{payload:[],composed:true},"contour:map-popup-reposition":{payload:["anchor","flippedX","flippedY","left","top"],composed:true},"contour:mode-change":{payload:["mode"],composed:true},"contour:scope-change":{payload:["scope"],composed:true},"contour:move":{payload:["direction","from","to"],composed:true},"contour:open":{payload:[],composed:true},"contour:page":{payload:["page"],composed:true},"contour:ready":{payload:["version","count"],composed:true},"contour:read":{payload:["label"],composed:true},"contour:remove":{payload:["key","label","name","value"],composed:true},"contour:reorder":{payload:["from","to"],composed:true},"contour:range-change":{payload:["value"],composed:true},"contour:resize":{payload:["delta","height","value","width"],composed:true},"contour:retry":{payload:["src"],composed:true},"contour:loop-change":{payload:["loop"],composed:true},"contour:pause":{payload:[],composed:true},"contour:play":{payload:[],composed:true},"contour:seek":{payload:["progress","value"],composed:true},"contour:select":{payload:["area","col","expanded","href","index","key","label","labels","path","range","result","row","rows","series","value"],composed:true},"contour:search":{payload:["query"],composed:true},"contour:spatial-filter":{payload:["action","mode","operator"],composed:true},"contour:split-change":{payload:["value","width","height"],composed:true},"contour:speed-change":{payload:["speed"],composed:true},"contour:showcase-activate":{payload:["title"],composed:true},"contour:step-activate":{payload:["index","title"],composed:true},"contour:step-change":{payload:["direction","index","title"],composed:true},"contour:show":{payload:[],composed:true},"contour:sort":{payload:["column","direction"],composed:true},"contour:submit":{payload:["submitting"],composed:true},"contour:stream-state":{payload:["running"],composed:true},"contour:tab-change":{payload:["index","label"],composed:true},"contour:theme-change":{payload:["theme"],composed:true},"contour:tick":{payload:["frame"],composed:true},"contour:time-change":{payload:["progress","value"],composed:true},"contour:time-range-change":{payload:["value"],composed:true},"contour:toggle":{payload:["collapsed","expanded","label","open","path","playing"],composed:true},"contour:view-enter":{payload:[],composed:true},"contour:view-leave":{payload:[],composed:true},});export function sanitizeHtml(input){const str=String(input==null?"":input);if(typeof DOMParser==="undefined"){return str.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const doc=new DOMParser().parseFromString(str,"text/html");const drop=new Set(["script","iframe","object","embed","style","link","meta","base","form","input","button"]);const walk=(node)=>{const children=Array.from(node.childNodes);for(const c of children){if(c.nodeType===1){const tag=c.tagName.toLowerCase();if(drop.has(tag)){c.remove();continue}for(const attr of Array.from(c.attributes)){const name=attr.name.toLowerCase();if(name.startsWith("on")){c.removeAttribute(attr.name);continue}const val=String(attr.value||"").trim().toLowerCase();if((name==="href"||name==="src"||name==="xlink:href")&&(val.startsWith("javascript:")||val.startsWith("data:text/html"))){c.removeAttribute(attr.name)}}walk(c)}}};walk(doc.body);return doc.body.innerHTML}export function safeColor(value){const raw=String(value==null?"":value).trim();if(!raw)return"";if(/[;{}<>"'`\\]/.test(raw))return"";if(/url\s*\(/i.test(raw)||/expression\s*\(/i.test(raw))return"";if(/^#[0-9a-f]{3,8}$/i.test(raw))return raw;if(/^(rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)\(/i.test(raw))return raw;if(/^[a-z]+$/i.test(raw))return raw;return""}export function safeHref(value){const raw=String(value==null?"":value).trim();if(!raw)return"#";if(raw.startsWith("#")||raw.startsWith("/")||raw.startsWith("./")||raw.startsWith("../")||raw.startsWith("?"))return raw;if(typeof document==="undefined"||!document.baseURI)return"#";try{const url=new URL(raw,document.baseURI);return["http:","https:","mailto:","tel:"].includes(url.protocol)?raw:"#"}catch(e){return"#"}}export function cssLength(name,fallback){if(typeof getComputedStyle==="undefined"||typeof document==="undefined")return fallback;const v=parseFloat(getComputedStyle(document.documentElement).getPropertyValue(name));return Number.isFinite(v)&&v>0?v:fallback}export function warnBadJson(host,label,error){if(typeof console==="undefined"||!console.warn)return;const name=host&&host.tagName?host.tagName.toLowerCase():"component";const msg=(error&&error.message)||String(error);console.warn(`[contour] ${name}: malformed ${label || "attribute"} — ${msg}`)}export const OBSERVED=["accept","action","actions","active","after","allow-duplicate","allow-remove","allow-rename","allow-zoom","alpha","anchor","answer","area","article","attribution","attribution-mark","audit","autoplay","axis","axis-x","axis-y","brownout","brownout-level","before","body","brand","bounds","breakpoint","breaks","brush","brush-end","brush-max","brush-min","brush-start","cache-key","canvas","center","clearable","cols","columns","color","command","cells","checked","chrome","confidence","coverage","debounce","closable","collapsed","collapsible","classification","continuous","content","controls","copyable","count","data","data-table","date","delta","description","glyphs","graduated","demo","density","desc","dir","direction","disabled","distance","dismissible","divider","do","dont","dot","ends","high","input","layer","low","mode","modes","n","opacity","palette","polarity","precision","range","single","empty","exclusive","fallback","filename","format","heading","help","hint","href","icon","illustration","instrument","interval","items","key","layers","level","markers","range-end","range-start","label","labels","lazy","lede","legend","left-label","right-label","line","limit","link","links","live","loading","locale","loop","max","media","message","method","methodology","menu","min","multiple","name","needle","next","no","no-cache","no-data-message","nodes","note","norm","normalize","options","orientation","page-size","pages","pause","paused","pausable","persist","placeholder","playing","point","points","prev","presets","prompt","question","recent","required","quote","ramp","refresh","removable","resolution","reverse","rings","retry","results","rows","scale","selectable","segments","show-header","sparkline","threshold","thresholds","selected","separator","series","shortcut","side","size","skeleton","sort","sort-dir","status","step","submit","submitting","timeout","trigger","virtual","sticky","cluster-count","cluster-expanded","time","resizable","state","steps","style","subtitle","summary","src","source","table","tabs","tag","text","ticks","title","type","unread-only","unit","updated","cluster-items","row-height","variant","values","viewport","warning","yes","zoomable","caption","current-time","is-playing","loop-label","no-data-color","no-data-label","property","show-loop","show-thumb","show-thumb-caption","speeds","item-height","pause-label","play-label","speed-label","time-label","shimmer","search","numbered","bucket-count","limit-values","autocomplete","levels","submit-label","fields","gap","controls","flush","head","preview","tags","url","custom-error",];export function headingTag(host,fallback="h3"){const v=host&&host.getAttribute?host.getAttribute("heading"):null;return/^h[1-6]$/.test(v||"")?v:fallback}export function labelText(host,key,fallback){const def=fallback!==undefined?fallback:key;const raw=host&&host.getAttribute?host.getAttribute("labels"):null;if(!raw)return def;try{const parsed=JSON.parse(raw);if(parsed&&typeof parsed==="object"&&typeof parsed[key]==="string"&&parsed[key])return parsed[key]}catch(e){}return def}export function applyLabel(node,host,key,fallback){if(!node)return;if(node.dataset&&node.dataset.contourLabel==="true"){node.textContent=labelText(host,key,fallback)}else if(!node.textContent){node.textContent=labelText(host,key,fallback);if(node.dataset)node.dataset.contourLabel="true"}}const _ContourBaseParent=(typeof HTMLElement!=="undefined")?HTMLElement:Object;export class ContourBase extends _ContourBaseParent{static formAssociated=false;constructor(){super();if(this.constructor.formAssociated&&typeof this.attachInternals==="function"){this._internals=this.attachInternals()}}static get observed(){return OBSERVED}static get observedAttributes(){const list=this.observed;return list.includes("labels")?list:[...list,"labels"]}static get properties(){return{}}static get updateMode(){return"scaffold"}brownoutLevel(){const raw=this.getAttribute("brownout-level")||this.getAttribute("brownout")||"0";const n=parseInt(raw,10);return Number.isFinite(n)?n:0}shed(kind,threshold){return this.brownoutLevel()>=(threshold||1)}get renderCount(){return this._contourRenderCount||0}_countRender(){this._contourRenderCount=(this._contourRenderCount||0)+1}static _propsInstalled=false;_installProperties(){const ctor=this.constructor;if(ctor._propsInstalled)return;ctor._propsInstalled=true;const props=ctor.properties||{};const declared=new Set();for(const[name,spec]of Object.entries(props)){const attr=(spec&&spec.attribute)||name;declared.add(attr);const type=(spec&&spec.type)||String;Object.defineProperty(ctor.prototype,name,{get(){const raw=this.getAttribute(attr);if(type===Boolean)return raw!==null;if(raw===null)return spec&&spec.default!==undefined?spec.default:null;if(type===Number){const n=Number(raw);return Number.isNaN(n)?null:n}return raw},set(v){if(v===null||v===undefined||v===false)this.removeAttribute(attr);else if(type===Boolean){if(v)this.setAttribute(attr,"");else this.removeAttribute(attr)}else this.setAttribute(attr,String(v))},configurable:true,})}const observed=ctor.observedAttributes;for(const attr of observed){if(declared.has(attr))continue;const prop=attr.replace(/-([a-z])/g,(_,c)=>c.toUpperCase());if(!/^[a-zA-Z_$][\w$]*$/.test(prop))continue;if(prop in ctor.prototype)continue;const isBool=attr==="disabled"||attr==="checked"||attr==="required"||attr==="readonly"||attr==="multiple"||attr==="selected"||attr==="open"||attr==="hidden";Object.defineProperty(ctor.prototype,prop,{get(){const raw=this.getAttribute(attr);if(isBool)return raw!==null;return raw},set(v){if(v===null||v===undefined||v===false)this.removeAttribute(attr);else if(isBool){if(v)this.setAttribute(attr,"");else this.removeAttribute(attr)}else this.setAttribute(attr,String(v))},configurable:true,})}}connectedCallback(){if(this._contourAuthored){this._wireFormData();return}this._installProperties();this._contourAuthored={nodes:Array.from(this.childNodes),cls:this.getAttribute("class"),};const before=Array.from(this.childNodes);this._contourRenderGen=(this._contourRenderGen||0)+1;this._ensureCache=new Map();this._ensureCacheGen=this._contourRenderGen;this._countRender();try{this.render()}catch(e){console.error("Contour render error:",e);this.textContent=labelText(this,"render-error","Component failed to render.")}this._contourGenerated=Array.from(this.childNodes).filter((n)=>!before.includes(n));this._applyParts(this);this._applyDensity();this.enhance();this._detachInnerFormControls();this._wireFormData();this._wireValueTracking()}attributeChangedCallback(name,oldValue,newValue){if(oldValue===newValue)return;if(!this.isConnected||!this._contourAuthored)return;if(this._batchDepth>0){this._batchDirty=true;return}if(this._contourRendering){if(!this._pendingRerender){this._pendingRerender=true;queueMicrotask(()=>{this._pendingRerender=false;if(!this.isConnected||!this._contourAuthored)return;this.attributeChangedCallback("__rerender__",null,"")})}return}if(name==="checked")this._checkedAttrChanged=true;this._contourRendering=true;try{const savedControls=Array.from(this.querySelectorAll("input, textarea, select"));const savedValues=savedControls.map((el)=>({key:el.name||el.id||null,preserveKey:el.getAttribute("data-contour-preserve-key")||null,value:el.value,checked:el.checked,type:el.type,dirty:!!el._contourUserDirty,attrAtDirty:el._contourAttrAtDirty,selected:el.tagName==="SELECT"&&el.multiple?Array.from(el.selectedOptions).map((o)=>o.value):null,}));const hadFocus=this.contains(document.activeElement)?document.activeElement:null;const _focusableSelector="button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])";const _focusablesBefore=Array.from(this.querySelectorAll(_focusableSelector));const hadFocusIndex=hadFocus?_focusablesBefore.indexOf(hadFocus):-1;const hadFocusKey=hadFocus?(hadFocus.id||null):null;const hadFocusPreserveKey=hadFocus?(hadFocus.getAttribute("data-contour-preserve-key")||null):null;const hadFocusName=hadFocus?(hadFocus.getAttribute("name")||null):null;const savedScrolls=Array.from(this.querySelectorAll("*")).filter((el)=>el.scrollHeight>el.clientHeight||el.scrollWidth>el.clientWidth).map((el)=>({el,id:el.id||null,preserveKey:el.getAttribute("data-contour-preserve-key")||null,top:el.scrollTop,left:el.scrollLeft}));const savedDetails=Array.from(this.querySelectorAll("details")).map((d)=>({id:d.id||null,preserveKey:d.getAttribute("data-contour-preserve-key")||null,open:d.open}));for(const g of(this._contourGenerated||[])){if(!g||g.parentNode!==this)continue;let wrapper=null;if(g.classList&&(g.classList.contains("c-panel__body")||g.classList.contains("c-dialog__body")))wrapper=g;else if(g.tagName==="PRE")wrapper=g.querySelector("code")||g;if(wrapper){while(wrapper.firstChild)this.insertBefore(wrapper.firstChild,g)}}for(const g of(this._contourGenerated||[])){if(g.parentNode===this)this.removeChild(g)}const generated=new Set(this._contourGenerated||[]);const authoredNow=Array.from(this.childNodes).filter((n)=>!generated.has(n));this._contourAuthored.nodes=authoredNow;while(this.firstChild)this.removeChild(this.firstChild);for(const node of this._contourAuthored.nodes)this.appendChild(node);if(this._contourAuthored.cls===null)this.removeAttribute("class");else this.setAttribute("class",this._contourAuthored.cls);const before=Array.from(this.childNodes);this._contourRenderGen=(this._contourRenderGen||0)+1;this._ensureCache=new Map();this._ensureCacheGen=this._contourRenderGen;this._countRender();try{this.render()}catch(e){console.error("Contour render error:",e);this.textContent=labelText(this,"render-error","Component failed to render.")}this._contourGenerated=Array.from(this.childNodes).filter((n)=>!before.includes(n));this._applyParts(this);this._applyDensity();const newControls=Array.from(this.querySelectorAll("input, textarea, select"));const keyed=savedValues.filter((sv)=>sv.key||sv.preserveKey);const unkeyed=savedValues.filter((sv)=>!sv.key&&!sv.preserveKey);const used=new Set();for(const el of newControls){const key=el.name||el.id||el.getAttribute("data-contour-preserve-key")||null;if(!key)continue;const match=keyed.find((sv)=>(sv.key===key||sv.preserveKey===key)&&!used.has(sv));if(!match)continue;used.add(match);if(!this._contourResetting)this._restoreControlValue(el,match);if((el.type==="checkbox"||el.type==="radio")&&typeof match.checked==="boolean"&&!this._checkedAttrChanged&&!this._contourResetting){el.checked=match.checked}}const savedByType=new Map();for(const sv of unkeyed){const group=savedByType.get(sv.type)||[];group.push(sv);savedByType.set(sv.type,group)}const usedByType=new Map();for(const el of newControls){if(el.name||el.id)continue;const type=el.type;const group=savedByType.get(type)||[];const used=usedByType.get(type)||0;if(used>=group.length)continue;const saved=group[used];usedByType.set(type,used+1);if(!this._contourResetting)this._restoreControlValue(el,saved);if((el.type==="checkbox"||el.type==="radio")&&typeof saved.checked==="boolean"&&!this._checkedAttrChanged&&!this._contourResetting){el.checked=saved.checked}}const newDetails=Array.from(this.querySelectorAll("details"));const keyedDetails=savedDetails.filter((sd)=>sd.id||sd.preserveKey);const usedIds=new Set();for(const d of newDetails){const id=d.id||null;const preserveKey=d.getAttribute("data-contour-preserve-key")||null;if(!id&&!preserveKey)continue;const match=keyedDetails.find((sd)=>(sd.id===id||sd.preserveKey===preserveKey)&&!usedIds.has(sd.id||sd.preserveKey));if(!match)continue;usedIds.add(match.id||match.preserveKey);d.open=match.open}let di=0;const plainSaved=savedDetails.filter((sd)=>!sd.id);for(const d of newDetails){if(d.id)continue;const sd=plainSaved[di];di+=1;if(!sd)break;d.open=sd.open}const newScrolls=Array.from(this.querySelectorAll("*")).filter((el)=>el.scrollHeight>el.clientHeight||el.scrollWidth>el.clientWidth);const keyedScrolls=savedScrolls.filter((s)=>s.id||s.preserveKey);const usedScrolls=new Set();for(const el of newScrolls){const id=el.id||null;const preserveKey=el.getAttribute("data-contour-preserve-key")||null;if(!id&&!preserveKey)continue;const match=keyedScrolls.find((s)=>(s.id===id||s.preserveKey===preserveKey)&&!usedScrolls.has(s.el));if(!match)continue;usedScrolls.add(match.el);el.scrollTop=match.top;el.scrollLeft=match.left}let si=0;const plainScrolls=savedScrolls.filter((s)=>!s.id&&!s.preserveKey);for(const el of newScrolls){if(el.id)continue;const s=plainScrolls[si];si+=1;if(!s)break;el.scrollTop=s.top;el.scrollLeft=s.left}if(hadFocus){let target=null;if(hadFocusKey){try{target=this.querySelector("#"+CSS.escape(hadFocusKey))}catch(e){target=null}}if(!target&&hadFocusPreserveKey){try{target=this.querySelector('[data-contour-preserve-key="'+CSS.escape(hadFocusPreserveKey)+'"]')}catch(e){target=null}}if(!target&&hadFocusName){try{target=this.querySelector('[name="'+CSS.escape(hadFocusName)+'"]')}catch(e){target=null}}if(!target&&hadFocusIndex>=0){const after=Array.from(this.querySelectorAll(_focusableSelector));if(after.length){target=after[Math.min(hadFocusIndex,after.length-1)]}}if(target&&typeof target.focus==="function"){try{target.focus()}catch(e){}}else if(document.contains(hadFocus)){try{hadFocus.focus()}catch(e){}}else{const first=this.querySelector(_focusableSelector);if(first)try{first.focus()}catch(e){}else try{this.focus()}catch(e){}}}this.enhance();this._detachInnerFormControls();this._checkedAttrChanged=false;this._contourResetting=false}finally{this._contourRendering=false}}disconnectedCallback(){this._pendingRerender=false;this._ensureCache=null;this._batchDepth=0;this._batchDirty=false;this._wiredFormData=false;runDisposers(this)}adoptedCallback(){if(this._contourAuthored){this._applyParts(this);this._applyDensity()}}enhance(){}_syncFormValue(){if(!this._internals)return;const ctl=this.querySelector("input:checked, textarea, select")||this.querySelector("input, textarea, select");if(!ctl)return;const boolean=ctl.type==="checkbox"||ctl.type==="radio";const value=boolean?(ctl.checked?(ctl.value||"on"):null):ctl.value;this._internals.setFormValue(value);this._syncValidity(this.hasAttribute("required")&&!value)}_syncValidity(valueMissing){if(!this._internals)return;if(valueMissing)this._internals.setValidity({valueMissing:true},"This field is required.");else this._internals.setValidity({});this._setCustomState("data-invalid",!!valueMissing)}_setCustomState(name,on){let internals=this._internals;if(!internals){if(this._stateInternals)internals=this._stateInternals;else if(typeof this.attachInternals==="function"){try{internals=this._stateInternals=this.attachInternals()}catch(e){return}}}const states=internals&&internals.states;if(!states)return;if(on){if(!states.has(name))states.add(name)}else if(states.has(name))states.delete(name)}_emitForm(type){if(!this._internals)return;const ctl=this.querySelector("input:checked, textarea, select")||this.querySelector("input, textarea, select");if(!ctl)return;const boolean=ctl.type==="checkbox"||ctl.type==="radio";this.dispatchEvent(new CustomEvent(type,{bubbles:true,composed:true,detail:{name:this.getAttribute("name"),value:boolean?(ctl.checked?(ctl.value||"on"):null):ctl.value,checked:boolean?ctl.checked:null,},}))}formResetCallback(){for(const ctl of this.querySelectorAll("input, textarea, select")){ctl._contourUserDirty=false;if(ctl.type==="checkbox"||ctl.type==="radio"){ctl.checked=this.hasAttribute("checked")}else if(ctl.tagName==="SELECT"){const chosen=ctl.querySelector("option[selected], option:first-of-type");ctl.value=chosen?chosen.value:""}else{ctl.value=this.hasAttribute("value")?this.getAttribute("value"):(ctl.getAttribute("value")||"")}}this._syncFormValue()}formDisabledCallback(disabled){for(const ctl of this.querySelectorAll("input, textarea, select, button")){if(disabled)ctl.setAttribute("disabled","");else ctl.removeAttribute("disabled")}}formStateRestoreCallback(state){if(!this._internals||state===null||state===undefined)return;const controls=Array.from(this.querySelectorAll("input, textarea, select"));const str=String(state);const match=controls.find((c)=>(c.type==="checkbox"||c.type==="radio")&&c.value===str);if(match){match.checked=true;for(const other of controls){if(other!==match&&other.type==="radio"&&other.name===match.name)other.checked=false}}else if(controls.length){controls[0].value=str}this._syncFormValue()}checkValidity(){return this._internals?this._internals.checkValidity():true}reportValidity(){return this._internals?this._internals.reportValidity():true}_wireFormData(){if(!this._internals||this._wiredFormData)return;const form=this._internals.form;if(!form)return;this._wiredFormData=true;const myName=this.getAttribute("name");const onFormChange=(e)=>{const t=e.target;if(t&&t.type==="radio"&&t.name&&t.name===myName)this._syncFormValue()};form.addEventListener("change",onFormChange);const onFormData=()=>this._syncFormValue();form.addEventListener("formdata",onFormData);onDispose(this,()=>{form.removeEventListener("change",onFormChange);form.removeEventListener("formdata",onFormData)})}_wireValueTracking(){if(!this._internals||this._wiredValueTracking)return;this._wiredValueTracking=true;const mark=(e)=>{const t=e.target;if(!t||!t.matches||!t.matches("input, textarea, select"))return;if(this._ownerBetween(t,this))return;t._contourUserDirty=true;t._contourAttrAtDirty=this.getAttribute("value")};this.addEventListener("input",mark);this.addEventListener("change",mark)}_restoreControlValue(el,saved){if(saved.dirty&&saved.attrAtDirty===this.getAttribute("value")){if(saved.selected&&el.tagName==="SELECT"&&el.multiple){const wanted=new Set(saved.selected);for(const o of el.options)o.selected=wanted.has(o.value)}else{el.value=saved.value}el._contourUserDirty=true;el._contourAttrAtDirty=saved.attrAtDirty;return}if(el.value===""&&el.getAttribute("value")===null)el.value=saved.value}_detachInnerFormControls(){if(!this._internals)return;for(const ctl of this.querySelectorAll("input, textarea, select")){if(ctl.hasAttribute("name")&&ctl.getAttribute("form")!=="")ctl.setAttribute("form","")}}batch(fn){if(typeof fn!=="function")return;this._batchDepth=(this._batchDepth||0)+1;this._batchDirty=this._batchDirty||false;try{fn()}finally{this._batchDepth-=1;if(this._batchDepth===0&&this._batchDirty){this._batchDirty=false;if(this.isConnected&&this._contourAuthored){this.attributeChangedCallback("__rerender__",null,"")}}}}requestRender(){if(this._contourRerenderQueued)return;this._contourRerenderQueued=true;queueMicrotask(()=>{this._contourRerenderQueued=false;if(!this.isConnected||!this._contourAuthored)return;this.attributeChangedCallback("__rerender__",null,"")})}_applyParts(root){const scope=root||this;const nodes=scope.querySelectorAll?Array.from(scope.querySelectorAll("[class]")):[];for(const node of nodes){if(node.hasAttribute("part"))continue;if(typeof node.className!=="string")continue;for(const c of node.className.split(/\s+/)){const m=c.match(/^c-[a-z0-9-]+__([a-z0-9-]+)$/);if(m){node.setAttribute("part",m[1]);break}}}}_applyDensity(){const density=this.getAttribute("density");if(density!==null)this.setAttribute("data-density",density);else if(this.hasAttribute("data-density"))this.removeAttribute("data-density")}_ownerBetween(node,root){for(let p=node.parentElement;p&&p!==root;p=p.parentElement){if(p instanceof ContourBase)return p}return null}ensure(selector,factory,parent){const root=parent||this;if(!root._ensureCache||root._ensureCacheGen!==this._contourRenderGen){root._ensureCache=new Map();root._ensureCacheGen=this._contourRenderGen}const cache=root._ensureCache;const key=root===this?selector:"\u0000"+root+"\u0000"+selector;let node=cache.get(key);if(node===undefined){node=null;for(const candidate of root.querySelectorAll(selector)){if(!this._ownerBetween(candidate,root)){node=candidate;break}}cache.set(key,node)}if(!node){node=factory();if(node&&node.setAttribute&&!node.hasAttribute("part")){const m=String(selector).match(/\.c-[a-z0-9-]+__([a-z0-9-]+)/);if(m)node.setAttribute("part",m[1])}root.appendChild(node);cache.set(key,node)}return node}}export function withBrownout(Base){return class extends Base{static get observed(){const base=(super.observed&&Array.isArray(super.observed))?super.observed:[];const extra=["brownout","brownout-level"];return Array.from(new Set(base.concat(extra)))}brownoutLevel(){return super.brownoutLevel?super.brownoutLevel():(parseInt(this.getAttribute("brownout-level")||this.getAttribute("brownout")||"0",10)||0)}shed(kind,threshold){return this.brownoutLevel()>=(threshold||1)}}}export const simple=(classes)=>class extends ContourBase{render(){classes.forEach((c)=>this.classList.add(c));for(const c of Array.from(this.classList)){if(classes.some((base)=>c.startsWith(base+"--")))this.classList.remove(c)}MODS.forEach((attr)=>{if(this.hasAttribute(attr)){const val=this.getAttribute(attr);classes.forEach((c)=>{const prefix=c.replace("c-","");this.classList.add(`c-${prefix}--${val}`)})}})}};export const CLASS_ONLY=["box","cluster","container","row","scrim","stack"];export function supportsUntilFound(){try{const t=document.createElement("div");t.setAttribute("hidden","until-found");return t.getAttribute("hidden")==="until-found"}catch(e){return false}}export function formatValue(value,format,locale,unit){if(!format)return value;const loc=locale||(typeof navigator!=="undefined"&&navigator.language)||"en";if(format==="date"||format==="time"){try{const opts=format==="time"?{timeStyle:"short"}:undefined;return new Intl.DateTimeFormat(loc,opts).format(new Date(value))}catch(e){return value}}if(format==="relative"){try{const num=Number(value);let seconds=num;if(Number.isNaN(num)){const then=new Date(value).getTime();if(Number.isFinite(then))seconds=(then-Date.now())/1000}const rtf=new Intl.RelativeTimeFormat(loc,{numeric:"auto"});if(Math.abs(seconds)<60)return rtf.format(Math.round(seconds),"second");if(Math.abs(seconds)<3600)return rtf.format(Math.round(seconds/60),"minute");if(Math.abs(seconds)<86400)return rtf.format(Math.round(seconds/3600),"hour");return rtf.format(Math.round(seconds/86400),"day")}catch(e){return value}}let opts={};if(format==="currency")opts={style:"currency",currency:"USD"};else if(format==="percent")opts={style:"percent"};else if(format==="compact")opts={notation:"compact"};else if(format==="unit")opts={style:"unit",unit:unit||"meter"};else if(format!=="number"){try{opts=JSON.parse(format)}catch(e){return value}}try{return new Intl.NumberFormat(loc,opts).format(Number(value))}catch(e){return value}}export function navKey(e,items,{wrap=true,enter=true,homeEnd=false,onKey,onNavigate,rtl}={}){const idx=items.indexOf(document.activeElement);if(idx<0)return;let next=-1;const fwdKey=rtl?"ArrowLeft":"ArrowRight";const revKey=rtl?"ArrowRight":"ArrowLeft";if(e.key===fwdKey||e.key==="ArrowDown")next=wrap?(idx+1)%items.length:Math.min(idx+1,items.length-1);else if(e.key===revKey||e.key==="ArrowUp")next=wrap?(idx-1+items.length)%items.length:Math.max(0,idx-1);else if((homeEnd||wrap)&&e.key==="Home")next=0;else if((homeEnd||wrap)&&e.key==="End")next=items.length-1;if(next>=0&&next!==idx){e.preventDefault();try{items[next].focus()}catch(_){}if(onNavigate)onNavigate(next);if(onKey)onKey(e.key,idx,items[idx])}else if((enter||wrap)&&(e.key==="Enter"||e.key===" ")){e.preventDefault();if(onKey)onKey(e.key,idx,items[idx])}}export function isRtl(el){let node=el;while(node&&node.nodeType===1){const d=node.getAttribute&&node.getAttribute("dir");if(d)return d.toLowerCase()==="rtl";node=node.parentElement}try{return(typeof document!=="undefined"&&(document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl")}catch(e){return false}}export function haversine(lat1,lon1,lat2,lon2){const R=6371000;const toRad=(d)=>d*Math.PI/180;const dLat=toRad(lat2-lat1);const dLon=toRad(lon2-lon1);const a=Math.sin(dLat/2)**2+Math.cos(toRad(lat1))*Math.cos(toRad(lat2))*Math.sin(dLon/2)**2;return 2*R*Math.asin(Math.sqrt(a))}export function bearing(lat1,lon1,lat2,lon2){const toRad=(d)=>d*Math.PI/180;const toDeg=(r)=>r*180/Math.PI;const dLon=toRad(lon2-lon1);const y=Math.sin(dLon)*Math.cos(toRad(lat2));const x=Math.cos(toRad(lat1))*Math.sin(toRad(lat2))-Math.sin(toRad(lat1))*Math.cos(toRad(lat2))*Math.cos(dLon);return(toDeg(Math.atan2(y,x))+360)%360}export function mercatorResolution(lat,zoom){return 156543.03392*Math.cos(lat*Math.PI/180)/Math.pow(2,zoom)}"use strict";export function arcPath(cx,cy,r,inner,startAngle,endAngle){cx=Number.isFinite(cx)?cx:0;cy=Number.isFinite(cy)?cy:0;r=Number.isFinite(r)&&r>0?r:0;inner=Number.isFinite(inner)&&inner>=0?inner:0;startAngle=Number.isFinite(startAngle)?startAngle:0;endAngle=Number.isFinite(endAngle)?endAngle:0;const largeArc=endAngle-startAngle>Math.PI?1:0;const x1=cx+r*Math.cos(startAngle);const y1=cy+r*Math.sin(startAngle);const x2=cx+r*Math.cos(endAngle);const y2=cy+r*Math.sin(endAngle);if(inner<=0){return`M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${largeArc} 1 ${x2} ${y2} Z`}const ix1=cx+inner*Math.cos(endAngle);const iy1=cy+inner*Math.sin(endAngle);const ix2=cx+inner*Math.cos(startAngle);const iy2=cy+inner*Math.sin(startAngle);return`M ${x1} ${y1} A ${r} ${r} 0 ${largeArc} 1 ${x2} ${y2} L ${ix1} ${iy1} A ${inner} ${inner} 0 ${largeArc} 0 ${ix2} ${iy2} Z`}export function donutSlices(values,opts){opts=opts||{};const cx=opts.cx!=null?opts.cx:100;const cy=opts.cy!=null?opts.cy:100;const r=opts.r!=null?opts.r:90;const inner=opts.inner!=null?opts.inner:55;const gap=opts.gap!=null?opts.gap:0.02;const total=values.reduce((a,b)=>a+(Number(b)||0),0)||1;let angle=-Math.PI/2;const out=[];values.forEach((v,i)=>{const num=Number(v)||0;const frac=num/total;if(!(num>0)){angle+=frac*Math.PI*2;return}const sweep=frac*Math.PI*2-gap;const start=angle+gap/2;const end=start+Math.max(0,sweep);out.push({path:arcPath(cx,cy,r,inner,start,end),value:num,index:i});angle+=frac*Math.PI*2});return out}export function barRects(values,opts){opts=opts||{};const width=opts.width!=null?opts.width:300;const height=opts.height!=null?opts.height:120;const gap=opts.gap!=null?opts.gap:2;const max=opts.max!=null?opts.max:(Math.max.apply(null,values.map((v)=>Number(v)||0))||1);if(!Number.isFinite(max)||max<=0)return values.map(()=>({x:0,y:height,width:0,height:0}));const n=values.length||1;const slot=width/n;const barW=Math.max(1,slot-gap);return values.map((v,i)=>{const h=((Number(v)||0)/max)*height;return{x:i*slot+gap/2,y:height-h,width:barW,height:h}})}export function polylinePoints(values,opts){opts=opts||{};const width=opts.width!=null?opts.width:300;const height=opts.height!=null?opts.height:120;const nums=values.map((v)=>Number(v)||0);if(!nums.length)return"";const max=opts.max!=null?opts.max:Math.max.apply(null,nums);const min=opts.min!=null?opts.min:Math.min.apply(null,nums);const range=(Number.isFinite(max-min)&&(max-min)!==0)?(max-min):1;const n=nums.length||1;return nums.map((v,i)=>{const x=(i/Math.max(1,n-1))*width;const y=height-((v-min)/range)*height;return x.toFixed(2)+","+y.toFixed(2)}).join(" ")}export function smoothPath(values,opts){const pts=polylinePoints(values,opts).split(" ").map((p)=>p.split(",").map(Number));if(!pts.length)return"";let d=`M ${pts[0][0]} ${pts[0][1]}`;for(let i=1;i<pts.length;i++){const prev=pts[i-1];const cur=pts[i];const cpx=(prev[0]+cur[0])/2;d+=` C ${cpx} ${prev[1]}, ${cpx} ${cur[1]}, ${cur[0]} ${cur[1]}`}return d}export function compassNeedle(cx,cy,length,angleDeg,width){angleDeg=angleDeg==null?0:angleDeg;width=width==null?3:width;const a=(angleDeg-90)*Math.PI/180;const tipX=cx+length*Math.cos(a);const tipY=cy+length*Math.sin(a);const tail=length*0.25;const tailX=cx-tail*Math.cos(a);const tailY=cy-tail*Math.sin(a);const perpX=Math.cos(a+Math.PI/2);const perpY=Math.sin(a+Math.PI/2);const b1x=cx+width*perpX;const b1y=cy+width*perpY;const b2x=cx-width*perpX;const b2y=cy-width*perpY;return`M ${tipX.toFixed(2)} ${tipY.toFixed(2)} L ${b1x.toFixed(2)} ${b1y.toFixed(2)} L ${tailX.toFixed(2)} ${tailY.toFixed(2)} L ${b2x.toFixed(2)} ${b2y.toFixed(2)} Z`}export function scaleBarTicks(value,segments){value=Number(value)||0;segments=Math.max(1,Math.round(segments||4));const out=[];for(let i=0;i<=segments;i++){out.push((value/segments)*i)}return out}export const MARKER_SHAPES=["circle","square","triangle","diamond","star"];export function markerStyles(shape){const map={circle:"border-radius:50%",square:"border-radius:0",triangle:"clip-path:polygon(50% 0%,0% 100%,100% 100%)",diamond:"transform:rotate(45deg)",star:"clip-path:polygon(50% 0%,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%)",};return map[shape]||""}export function assignMarkers(items){return(items||[]).map((it,i)=>({...it,marker:MARKER_SHAPES[i%MARKER_SHAPES.length]}))}export function marchingSquares(grid,level){const rows=grid.length;const cols=rows?grid[0].length:0;const segments=[];if(!rows||!cols)return segments;const lerp=(a,b,va,vb)=>(vb===va?0.5:(level-va)/(vb-va));for(let y=0;y<rows-1;y++){for(let x=0;x<cols-1;x++){const tl=grid[y][x];const tr=grid[y][x+1];const bl=grid[y+1][x];const br=grid[y+1][x+1];const code=(tl>=level?8:0)|(tr>=level?4:0)|(br>=level?2:0)|(bl>=level?1:0);if(code===0||code===15)continue;const top={x:x+lerp(tl,tr,tl,tr),y};const right={x:x+1,y:y+lerp(tr,br,tr,br)};const bottom={x:x+lerp(bl,br,bl,br),y:y+1};const left={x,y:y+lerp(tl,bl,tl,bl)};let connect;if(code===5){const center=(tl+tr+bl+br)/4;connect=center>=level?"top-bottom":"left-right"}else if(code===10){const center=(tl+tr+bl+br)/4;connect=center>=level?"left-right":"top-bottom"}switch(code){case 1:case 14:segments.push([left,bottom]);break;case 2:case 13:segments.push([bottom,right]);break;case 3:case 12:segments.push([left,right]);break;case 4:case 11:segments.push([top,right]);break;case 6:case 9:segments.push([top,bottom]);break;case 7:case 8:segments.push([left,top]);break;case 5:if(connect==="top-bottom"){segments.push([top,bottom],[left,right])}else{segments.push([top,right],[left,bottom])}break;case 10:if(connect==="left-right"){segments.push([left,right],[top,bottom])}else{segments.push([top,right],[left,bottom])}break}}}return segments}export function contourPaths(grid,levels,width,height){const rows=grid.length;const cols=rows?grid[0].length:0;if(rows<2||cols<2)return[];const sx=width/(cols-1);const sy=height/(rows-1);return(levels||[]).map((level)=>{const segs=marchingSquares(grid,level);let d="";for(const[a,b]of segs){d+=`M ${(a.x * sx).toFixed(2)} ${(a.y * sy).toFixed(2)} L ${(b.x * sx).toFixed(2)} ${(b.y * sy).toFixed(2)} `}return{level,d:d.trim()}})}const WIRED_HOSTS=new WeakMap();export const wcReset=(host)=>{WIRED_HOSTS.delete(host)};const wcClaim=(host,name)=>{let set=WIRED_HOSTS.get(host);if(!set){set=new Set();WIRED_HOSTS.set(host,set)}if(set.has(name))return false;set.add(name);return true};const wcScopes=(host)=>(host.shadowRoot?[host,host.shadowRoot]:[host]);const wcAll=(host,sel)=>{const found=[];for(const scope of wcScopes(host)){for(const el of scope.querySelectorAll(sel))if(!found.includes(el))found.push(el)}return found};const wcOne=(host,sel)=>wcAll(host,sel)[0]||null;const wcSelfOrAll=(host,sel)=>{const found=typeof host.matches==="function"&&host.matches(sel)?[host]:[];for(const el of wcAll(host,sel))if(!found.includes(el))found.push(el);return found};const wcShadowOf=(node)=>{const root=node&&node.getRootNode?node.getRootNode():null;return root&&root.host?root:null};const wcGroup=(host,group,sel)=>{const found=Array.from(group.querySelectorAll(sel));if(wcShadowOf(group)&&wcShadowOf(group).host===host){for(const el of host.querySelectorAll(sel))if(!found.includes(el))found.push(el)}return found};const HEARD=new WeakMap();const wcListen=(host,type,handler)=>{const scoped=(e)=>{let seen=HEARD.get(e);if(!seen){seen=new Set();HEARD.set(e,seen)}if(seen.has(scoped))return;seen.add(scoped);handler(e)};for(const scope of wcScopes(host))scope.addEventListener(type,scoped)};const wcOwned=(host,node)=>!!node&&wcScopes(host).some((scope)=>scope.contains(node));const wcClosest=(host,target,sel)=>(typeof target?.closest==="function"&&wcOwned(host,target))?target.closest(sel):null;const wcEmit=(host,name,detail)=>{host.dispatchEvent(new CustomEvent(name,{detail,bubbles:true,composed:true}))};export function wireTabs(host){if(!wcClaim(host,"tabs"))return;for(const list of wcSelfOrAll(host,".c-tabs__list, .c-code-tabs__list")){const isCode=list.classList.contains("c-code-tabs__list");const panelSel=isCode?".c-code-tabs__panel":".c-tabs__panel";const tabsOf=()=>wcGroup(host,list,"[role='tab']");const activate=(tab,focus)=>{const tabs=tabsOf();if(!tab.id)tab.id=contourId("c-tab");tabs.forEach((t)=>{const selected=t===tab;t.setAttribute("aria-selected",String(selected));t.tabIndex=selected?0:-1;const ctrl=t.getAttribute("aria-controls");if(!ctrl)return;const panel=wcOne(host,"#"+CSS.escape(ctrl))||document.getElementById(ctrl);if(panel){panel.hidden=!selected;if(selected)panel.setAttribute("aria-labelledby",t.id)}});const panels=wcAll(host,panelSel);if(panels.length){const index=tabs.indexOf(tab);panels.forEach((p,i)=>{p.hidden=i!==index})}if(focus)try{tab.focus()}catch(e){}const name=tab.getAttribute("aria-controls")||tab.textContent||"";host.dispatchEvent(new CustomEvent("contour:tab-change",{bubbles:true,composed:true,detail:{index:tabs.indexOf(tab),label:name}}))};const runActivation=(tab,focus)=>{const can=!focus&&typeof document.startViewTransition==="function"&&!(typeof matchMedia==="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches);if(can){try{document.startViewTransition(()=>activate(tab,focus));return}catch(e){}}activate(tab,focus)};wcListen(host,"click",(e)=>{const tab=wcClosest(host,e.target,"[role='tab']");if(tab&&tabsOf().includes(tab)){const inner=e.target&&e.target.closest?e.target.closest("button"):null;if(inner&&inner!==tab&&tab.contains(inner))return;runActivation(tab,false)}});wcListen(host,"keydown",(e)=>{let tab=wcClosest(host,e.target,"[role='tab']");if(!tab&&e.target&&e.target.getAttribute&&e.target.getAttribute("role")==="tab"&&wcOwned(host,e.target))tab=e.target;const tabs=tabsOf();const index=tabs.indexOf(tab);if(index<0)return;const vertical=host.getAttribute("orientation")==="vertical";const rtl=isRtl(host);const move=vertical?(rtl?{ArrowDown:index-1,ArrowUp:index+1,Home:tabs.length-1,End:0}:{ArrowDown:index+1,ArrowUp:index-1,Home:0,End:tabs.length-1}):(rtl?{ArrowRight:index-1,ArrowLeft:index+1,Home:tabs.length-1,End:0}:{ArrowRight:index+1,ArrowLeft:index-1,Home:0,End:tabs.length-1});if(!(e.key in move))return;e.preventDefault();const next=tabs[(move[e.key]+tabs.length)%tabs.length];if(next)runActivation(next,true)});const tabs=tabsOf();const persist=host.getAttribute("persist");let restored=null;if(persist==="storage"&&host.id){try{restored=localStorage.getItem("contour-tabs:"+host.id)}catch(e){restored=null}}else if(persist==="url"){try{const params=new URLSearchParams(window.location.search);const v=params.get("c-tabs");if(v!==null)restored=v}catch(e){restored=null}}const marked=tabs.find((t)=>t.getAttribute("aria-selected")==="true");let first=marked||tabs[0];if(restored!==null){const idx=parseInt(restored,10);if(Number.isFinite(idx)&&tabs[idx])first=tabs[idx]}if(first)activate(first,false);if(persist==="storage"&&host.id){host.addEventListener("contour:tab-change",(e)=>{try{localStorage.setItem("contour-tabs:"+host.id,String(e.detail&&e.detail.index))}catch(err){}})}else if(persist==="url"){host.addEventListener("contour:tab-change",(e)=>{try{const url=new URL(window.location.href);url.searchParams.set("c-tabs",String(e.detail&&e.detail.index));window.history.replaceState(null,"",url.toString())}catch(err){}})}}}export function wireSegmented(host){const groups=wcSelfOrAll(host,".c-segmented");const normalize=()=>{const authored=host.getAttribute("value");const chosen=authored!==host._segAuthorValue?authored:null;if(chosen!==null)host._segAuthorValue=authored;let seen=0;for(const g of groups){if(!g.hasAttribute("role"))g.setAttribute("role","group");const label=host.getAttribute("label");if(label&&!g.hasAttribute("aria-label"))g.setAttribute("aria-label",label);const opts=wcGroup(host,g,"button");seen+=opts.length;opts.forEach((b)=>{b.classList.add("c-segmented__option");b.setAttribute("aria-pressed",chosen!==null&&chosen!==undefined?String(b.dataset.value===chosen):(b.getAttribute("aria-pressed")==="true"?"true":"false"))});const chosenOpt=opts.find((b)=>b.getAttribute("aria-pressed")==="true")||opts[0];opts.forEach((b)=>{b.tabIndex=b===chosenOpt?0:-1})}return seen};if(!normalize()){if(!host._segRetryScheduled){host._segRetryScheduled=true;setTimeout(()=>{host._segRetryScheduled=false;normalize()},0)}}if(!wcClaim(host,"segmented"))return;const activate=(btn)=>{const seg=groups.find((g)=>wcGroup(host,g,"button").includes(btn));if(!seg)return;wcGroup(host,seg,"button").forEach((o)=>{const on=o===btn;o.setAttribute("aria-pressed",String(on));o.tabIndex=on?0:-1});wcEmit(host,"contour:change",{value:btn.dataset.value||btn.textContent.trim()})};wcListen(host,"click",(e)=>{const btn=wcClosest(host,e.target,"button");if(!btn)return;activate(btn)});wcListen(host,"keydown",(e)=>{const btn=wcClosest(host,e.target,"button");if(!btn)return;const seg=groups.find((g)=>wcGroup(host,g,"button").includes(btn));if(!seg)return;const opts=wcGroup(host,seg,"button");navKey(e,opts,{wrap:false,homeEnd:true,rtl:isRtl(host),onNavigate:(i)=>activate(opts[i]),onKey:()=>activate(btn)})})}export function wireCombobox(host){wireComboboxDocDismiss();const input=wcOne(host,".c-combobox__input");const list=wcOne(host,".c-combobox__list");if(!input||!list)return;const optionList=()=>wcAll(host,".c-combobox__option");if(!list.id)list.id=contourId("c-combobox-list");list.setAttribute("role","listbox");input.setAttribute("role","combobox");input.setAttribute("aria-haspopup","listbox");input.setAttribute("aria-controls",list.id);input.setAttribute("aria-expanded",list.hasAttribute("hidden")?"false":"true");if(!input.hasAttribute("aria-autocomplete"))input.setAttribute("aria-autocomplete","list");optionList().forEach((opt,i)=>{if(!opt.id)opt.id=contourId("c-combobox-option");opt.setAttribute("role","option");if(!opt.hasAttribute("aria-selected"))opt.setAttribute("aria-selected","false")});if(!wcClaim(host,"combobox"))return;const liveInput=()=>wcOne(host,".c-combobox__input");const liveList=()=>wcOne(host,".c-combobox__list");let cursor=-1;const mark=(visible)=>{const field=liveInput();visible.forEach((o,i)=>{const on=i===cursor;o.classList.toggle("c-combobox__option--active",on);o.setAttribute("aria-selected",String(on))});if(field){const active=cursor>=0?visible[cursor]:null;if(active)field.setAttribute("aria-activedescendant",active.id);else field.removeAttribute("aria-activedescendant")}};const filter=(query)=>{const q=(query||"").toLowerCase();if(host._comboboxVirtual&&typeof host._renderComboboxWindow==="function"){host._renderComboboxWindow(q,true);cursor=-1;return}optionList().forEach((o)=>{o.hidden=!!(q&&!o.textContent.toLowerCase().includes(q))});cursor=-1};const open=()=>{const l=liveList();if(!l)return;l.removeAttribute("hidden");const field=liveInput();if(field)field.setAttribute("aria-expanded","true")};const close=()=>{const l=liveList();if(l)l.setAttribute("hidden","");const field=liveInput();if(field){field.setAttribute("aria-expanded","false");field.removeAttribute("aria-activedescendant")}cursor=-1;optionList().forEach((o)=>{o.classList.remove("c-combobox__option--active");o.setAttribute("aria-selected","false")})};if(host._comboboxVirtual&&list&&!list._contourVirtualScroll){list._contourVirtualScroll=true;list.addEventListener("scroll",()=>{if(typeof host._renderComboboxWindow==="function")host._renderComboboxWindow(host._comboboxQuery||"")},{passive:true})}const commit=(opt)=>{const field=liveInput();if(!field)return;if(host.hasAttribute("multiple")){const now=opt.getAttribute("aria-selected")==="true";opt.setAttribute("aria-selected",String(!now));opt.classList.toggle("c-combobox__option--selected",!now);const selected=(host.getAttribute("value")||"").split(",").map((v)=>v.trim()).filter(Boolean);const value=host._comboboxVirtual&&host._comboboxFiltered?host._comboboxFiltered.find((item)=>item.index===Number(opt.dataset.optionIndex))?.value:(opt.dataset.optionValue!=null?opt.dataset.optionValue:opt.textContent.trim());const position=selected.indexOf(String(value));if(now&&position>=0)selected.splice(position,1);if(!now&&position<0)selected.push(String(value));host.setAttribute("value",selected.join(","));if(typeof host._syncFormValue==="function")host._syncFormValue();wcEmit(host,"contour:select",{value:selected});field.focus();return}const value=opt.dataset.optionValue!=null?opt.dataset.optionValue:opt.textContent.trim();field.value=opt.textContent;host.setAttribute("value",value);if(typeof host._syncFormValue==="function")host._syncFormValue();wcEmit(host,"contour:select",{value});close();field.focus()};const isField=(target)=>wcClosest(host,target,".c-combobox__input")!==null;wcListen(host,"input",(e)=>{if(!isField(e.target))return;host._comboboxQuery=e.target.value;filter(e.target.value);open();if(typeof host._emitForm==="function")host._emitForm("contour:input")});wcListen(host,"focusin",(e)=>{if(!isField(e.target))return;filter(e.target.value);open()});wcListen(host,"keydown",(e)=>{if(!isField(e.target))return;const visible=optionList().filter((o)=>!o.hidden);if(e.key==="ArrowDown"){e.preventDefault();cursor=Math.min(cursor+1,visible.length-1);mark(visible)}else if(e.key==="ArrowUp"){e.preventDefault();cursor=Math.max(cursor-1,0);mark(visible)}else if(e.key==="Home"){e.preventDefault();cursor=0;mark(visible)}else if(e.key==="End"){e.preventDefault();cursor=Math.max(0,visible.length-1);mark(visible)}else if(e.key==="Enter"||e.key===" "){e.preventDefault();if(cursor>=0&&visible[cursor])commit(visible[cursor])}else if(e.key==="Escape")close()});wcListen(host,"click",(e)=>{const opt=wcClosest(host,e.target,".c-combobox__option");if(opt){commit(opt);return}if(!wcOwned(host,e.target)||!host.contains(e.target))close()})}let _comboboxDocWired=false;function wireComboboxDocDismiss(){if(_comboboxDocWired)return;_comboboxDocWired=true;document.addEventListener("click",(e)=>{for(const host of document.querySelectorAll("contour-combobox, contour-shadow-combobox")){const list=host.shadowRoot?host.shadowRoot.querySelector(".c-combobox__list"):host.querySelector(".c-combobox__list");const input=host.shadowRoot?host.shadowRoot.querySelector(".c-combobox__input"):host.querySelector(".c-combobox__input");if(!list||list.hasAttribute("hidden"))continue;const root=host.shadowRoot||host;if(root.contains(e.target))continue;list.setAttribute("hidden","")}})}const visibleStops=(host)=>wcAll(host,".c-tree__toggle, .c-tree__leaf").filter((el)=>!el.closest(".c-tree__children[hidden]"));export function wireTree(host){const nodes=()=>wcAll(host,".c-tree__node");const rootList=wcSelfOrAll(host,"ul.c-tree")[0];if(rootList&&!rootList.hasAttribute("role"))rootList.setAttribute("role","tree");wcAll(host,".c-tree__children").forEach((ul)=>{if(!ul.hasAttribute("role"))ul.setAttribute("role","group")});const levelOf=(node)=>{let level=1;for(let p=node.parentElement;p;p=p.parentElement)if(p.classList&&p.classList.contains("c-tree__children"))level++;return level};nodes().forEach((node)=>{if(node.getAttribute("role")!=="treeitem")node.setAttribute("role","treeitem");node.setAttribute("aria-level",String(levelOf(node)));const row=node.querySelector(":scope > .c-tree__row");if(row)node.setAttribute("aria-expanded",row.querySelector(":scope > .c-tree__toggle")?.getAttribute("aria-expanded")||"false");else if(node.hasAttribute("aria-expanded"))node.removeAttribute("aria-expanded")});const stops=visibleStops(host);const authored=stops.find((el)=>el.getAttribute("tabindex")==="0");const active=authored||stops.find((el)=>el===document.activeElement)||stops[0];stops.forEach((el)=>el.setAttribute("tabindex",el===active?"0":"-1"));wcAll(host,".c-tree__toggle, .c-tree__leaf").forEach((el)=>{if(!stops.includes(el))el.setAttribute("tabindex","-1")});if(!wcClaim(host,"tree"))return;host._selectedTree=host._selectedTree||new Set();let lastTreeIndex=-1;wcListen(host,"change",(e)=>{const cb=e.target&&e.target.closest?e.target.closest(".c-tree__select"):null;if(!cb||!host.contains(cb))return;const cbs=Array.from(host.querySelectorAll(".c-tree__select"));const idx=cbs.indexOf(cb);const label=(cb.parentElement&&cb.parentElement.textContent||"").trim().slice(0,120);if(e.shiftKey&&lastTreeIndex>=0){const from=Math.min(lastTreeIndex,idx);const to=Math.max(lastTreeIndex,idx);for(let i=from;i<=to;i++){cbs[i].checked=cb.checked;const lbl=(cbs[i].parentElement&&cbs[i].parentElement.textContent||"").trim().slice(0,120);if(cb.checked)host._selectedTree.add(lbl);else host._selectedTree.delete(lbl)}}else if(!e.ctrlKey&&!e.metaKey){if(cb.checked){cbs.forEach((c,i)=>{if(i!==idx&&c.checked){c.checked=false;const lbl=(c.parentElement&&c.parentElement.textContent||"").trim().slice(0,120);host._selectedTree.delete(lbl)}})}if(cb.checked)host._selectedTree.add(label);else host._selectedTree.delete(label)}else{if(cb.checked)host._selectedTree.add(label);else host._selectedTree.delete(label)}lastTreeIndex=idx;wcEmit(host,"contour:select",{labels:Array.from(host._selectedTree)})});wcAll(host,".c-tree__node, .c-tree__leaf").forEach((n)=>{if(!n.hasAttribute("draggable"))n.setAttribute("draggable","true")});let dragLabel=null;wcListen(host,"dragstart",(e)=>{const node=wcClosest(host,e.target,".c-tree__node, .c-tree__leaf");if(!node)return;dragLabel=(node.textContent||"").trim().slice(0,120);if(e.dataTransfer){e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",dragLabel)}catch(err){}}});wcListen(host,"dragover",(e)=>{const node=wcClosest(host,e.target,".c-tree__node, .c-tree__leaf");if(!node)return;e.preventDefault();if(e.dataTransfer)e.dataTransfer.dropEffect="move"});wcListen(host,"drop",(e)=>{const node=wcClosest(host,e.target,".c-tree__node, .c-tree__leaf");if(!node||!dragLabel)return;e.preventDefault();const toLabel=(node.textContent||"").trim().slice(0,120);if(toLabel&&toLabel!==dragLabel){wcEmit(host,"contour:move",{from:dragLabel,to:toLabel})}dragLabel=null});const persist=host.getAttribute("persist");if(persist==="storage"&&host.id){try{const saved=localStorage.getItem("contour-tree:"+host.id);if(saved!==null){const labels=JSON.parse(saved);if(Array.isArray(labels)){const want=new Set(labels.map((l)=>String(l)));wcAll(host,".c-tree__row").forEach((row)=>{const currentToggle=row.querySelector(":scope > .c-tree__toggle");if(currentToggle?.getAttribute("aria-expanded")==="true")return;const label=(row.textContent||"").trim().slice(0,120);if(!want.has(label))return;const toggle=row.querySelector(":scope > .c-tree__toggle");if(!toggle)return;const node=row.closest(".c-tree__node");const children=node?node.querySelector(":scope > .c-tree__children"):null;toggle.setAttribute("aria-expanded","true");if(node)node.setAttribute("aria-expanded","true");if(children)children.removeAttribute("hidden")})}}}catch(e){}}else if(persist==="url"){try{const v=new URLSearchParams(window.location.search).get("c-tree");if(v!==null){const labels=JSON.parse(v);if(Array.isArray(labels)){const want=new Set(labels.map((l)=>String(l)));wcAll(host,".c-tree__row").forEach((row)=>{const currentToggle=row.querySelector(":scope > .c-tree__toggle");if(currentToggle?.getAttribute("aria-expanded")==="true")return;const label=(row.textContent||"").trim().slice(0,120);if(!want.has(label))return;const toggle=row.querySelector(":scope > .c-tree__toggle");if(!toggle)return;const node=row.closest(".c-tree__node");const children=node?node.querySelector(":scope > .c-tree__children"):null;toggle.setAttribute("aria-expanded","true");if(node)node.setAttribute("aria-expanded","true");if(children)children.removeAttribute("hidden")})}}}catch(e){}}const toggleNode=(toggle)=>{const wasOpen=toggle.getAttribute("aria-expanded")==="true";toggle.setAttribute("aria-expanded",String(!wasOpen));const row=toggle.closest(".c-tree__row")||toggle.parentElement;const node=toggle.closest(".c-tree__node");const children=node?node.querySelector(":scope > .c-tree__children"):null;if(children){if(wasOpen){if(supportsUntilFound())children.setAttribute("hidden","until-found");else children.hidden=true}else{children.removeAttribute("hidden")}}if(node)node.setAttribute("aria-expanded",String(!wasOpen));wcEmit(host,"contour:toggle",{open:!wasOpen,label:(row?row.textContent:"").trim().slice(0,120)});if(persist==="storage"&&host.id){try{const open=[];wcAll(host,".c-tree__row").forEach((r)=>{const toggle=r.querySelector(":scope > .c-tree__toggle");if(toggle?.getAttribute("aria-expanded")==="true")open.push((r.textContent||"").trim().slice(0,120))});localStorage.setItem("contour-tree:"+host.id,JSON.stringify(open))}catch(e){}}else if(persist==="url"){try{const open=[];wcAll(host,".c-tree__row").forEach((r)=>{const toggle=r.querySelector(":scope > .c-tree__toggle");if(toggle?.getAttribute("aria-expanded")==="true")open.push((r.textContent||"").trim().slice(0,120))});const url=new URL(window.location.href);url.searchParams.set("c-tree",JSON.stringify(open));window.history.replaceState(null,"",url.toString())}catch(e){}}};const branchOf=(el)=>(el.classList&&el.classList.contains("c-tree__toggle")?el:null);const stopsOf=()=>visibleStops(host);const rove=(keep)=>{wcAll(host,".c-tree__toggle, .c-tree__leaf").forEach((el)=>el.setAttribute("tabindex",el===keep?"0":"-1"))};wcListen(host,"click",(e)=>{let toggle=wcClosest(host,e.target,".c-tree__toggle");if(!toggle){const row=wcClosest(host,e.target,".c-tree__row");if(row)toggle=row.querySelector(":scope > .c-tree__toggle")}if(!toggle)return;e.preventDefault();e.stopPropagation();toggleNode(toggle)});wcListen(host,"focusin",(e)=>{if(!wcClosest(host,e.target,".c-tree__toggle, .c-tree__leaf"))return;rove(e.target)});wcListen(host,"keydown",(e)=>{const toggle=wcClosest(host,e.target,".c-tree__toggle, .c-tree__leaf");if(!toggle)return;const items=stopsOf();const idx=items.indexOf(toggle);if(e.key==="Enter"||e.key===" "){if(branchOf(toggle)){e.preventDefault();toggleNode(toggle)}return}if(e.key==="ArrowRight"){const branch=branchOf(toggle);const closed=branch&&branch.getAttribute("aria-expanded")==="false";e.preventDefault();if(closed){toggleNode(branch);rove(toggle)}else{const next=items[idx+1];if(next){next.focus();rove(next)}}return}if(e.key==="ArrowLeft"){const branch=branchOf(toggle);if(branch&&branch.getAttribute("aria-expanded")==="true"){e.preventDefault();toggleNode(branch);rove(toggle)}else{const parent=toggle.closest(".c-tree__children");const owner=parent?parent.closest(".c-tree__node"):null;const up=owner?owner.querySelector(":scope > .c-tree__row > .c-tree__toggle"):null;if(up){e.preventDefault();up.focus();rove(up)}}return}navKey(e,items,{wrap:false,homeEnd:true,onNavigate:(i)=>rove(items[i])})})}export function wireMenu(host){wcAll(host,"[role='menuitem']").forEach((it)=>{if(!it.hasAttribute("tabindex"))it.setAttribute("tabindex",it.getAttribute("aria-disabled")==="true"?"-1":"-1")});const all=()=>wcAll(host,"[role='menuitem']");if(!all().some((it)=>it.getAttribute("tabindex")==="0")&&all().length){const first=all().find((it)=>it.getAttribute("aria-disabled")!=="true");if(first)first.setAttribute("tabindex","0")}if(!wcClaim(host,"menu"))return;const submenusOf=(item)=>item.querySelector(":scope > ul.c-menu, :scope > .c-menu");const closeAllSubmenus=()=>{wcAll(host,"[aria-haspopup='menu']").forEach((it)=>it.setAttribute("aria-expanded","false"))};wcListen(host,"keydown",(e)=>{const its=all().filter((it)=>it.getAttribute("aria-disabled")!=="true");if(!its.length)return;const index=its.indexOf(e.target);const target=index>=0?its[index]:null;const sub=target?submenusOf(target):null;if(target&&target.getAttribute("aria-haspopup")==="menu"&&(e.key==="ArrowRight"||e.key==="Enter"||e.key===" ")){if(sub){e.preventDefault();closeAllSubmenus();target.setAttribute("aria-expanded","true");const firstSub=sub.querySelector("[role='menuitem']");if(firstSub){firstSub.setAttribute("tabindex","0");try{firstSub.focus()}catch(err){}}return}}if(e.key==="ArrowLeft"||e.key==="Escape"){const parent=target?target.closest("ul.c-menu"):null;let ancestor=null;if(target){const ul=target.parentElement&&target.parentElement.tagName==="UL"?target.parentElement:null;let node=target.parentElement;while(node&&node!==host){if(node.getAttribute&&node.getAttribute("aria-haspopup")==="menu"&&node.contains(target)&&node!==target){ancestor=node;break}node=node.parentElement}}if(ancestor){e.preventDefault();ancestor.setAttribute("aria-expanded","false");try{ancestor.focus()}catch(err){}return}if(e.key==="Escape"){closeAllSubmenus()}}navKey(e,its,{wrap:true,homeEnd:true,onKey:()=>{if(e.key==="Enter"||e.key===" "){const idx=its.indexOf(document.activeElement);if(idx>=0&&!(target&&target.getAttribute("aria-haspopup")==="menu")){wcEmit(host,"contour:select",{index:idx,label:its[idx].textContent.trim()});closeAllSubmenus()}}}});if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const ch=e.key.toLowerCase();const match=its.findIndex((it)=>(it.textContent||"").trim().toLowerCase().startsWith(ch));if(match>=0){e.preventDefault();its[match].focus()}}});wcListen(host,"click",(e)=>{const item=wcClosest(host,e.target,"[role='menuitem']");if(!item)return;if(item.getAttribute("aria-disabled")==="true")return;if(item.getAttribute("aria-haspopup")==="menu"){const sub=submenusOf(item);if(sub){const open=item.getAttribute("aria-expanded")==="true";closeAllSubmenus();item.setAttribute("aria-expanded",open?"false":"true");return}}const index=all().indexOf(item);if(index>=0){wcEmit(host,"contour:select",{index,label:item.textContent.trim()});closeAllSubmenus();if(typeof host.hidePopover==="function"){try{host.hidePopover()}catch(e){}}}})}export function wirePagination(host){wcAll(host,".c-pagination__link").forEach((b)=>{if(!b.hasAttribute("tabindex"))b.setAttribute("tabindex","0")});if(!wcClaim(host,"pagination"))return;const activate=(btn)=>{const page=parseInt(btn.textContent,10);if(!Number.isFinite(page))return;wcAll(host,".c-pagination__link").forEach((b)=>{if(parseInt(b.textContent,10)===page)b.setAttribute("aria-current","page");else b.removeAttribute("aria-current")});host.setAttribute("page",String(page));wcEmit(host,"contour:page",{page});if(host.getAttribute("persist")==="storage"&&host.id){try{localStorage.setItem("contour-pagination:"+host.id,String(page))}catch(e){}}else if(host.getAttribute("persist")==="url"){try{const url=new URL(window.location.href);url.searchParams.set("c-pagination",String(page));window.history.replaceState(null,"",url.toString())}catch(e){}}};wcListen(host,"click",(e)=>{const btn=wcClosest(host,e.target,".c-pagination__link");if(!btn)return;e.preventDefault();const action=btn.getAttribute("data-action");if(action==="prev"||action==="next"){const links=wcAll(host,".c-pagination__link").filter((b)=>!b.getAttribute("data-action"));const cur=links.find((b)=>b.getAttribute("aria-current")==="page");const curPage=cur?(parseInt(cur.textContent,10)||1):1;const page=action==="prev"?Math.max(1,curPage-1):Math.min(links.length,curPage+1);const target=links.find((b)=>parseInt(b.textContent,10)===page);if(target){activate(target);return}}activate(btn)});wcListen(host,"keydown",(e)=>{const btn=wcClosest(host,e.target,".c-pagination__link");if(!btn)return;const links=wcAll(host,".c-pagination__link");const idx=links.indexOf(btn);let next=-1;const rtl=isRtl(host);if(e.key==="ArrowRight")next=rtl?Math.max(idx-1,0):Math.min(idx+1,links.length-1);else if(e.key==="ArrowLeft")next=rtl?Math.min(idx+1,links.length-1):Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=links.length-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();activate(btn);return}if(next>=0&&next!==idx){e.preventDefault();links[next].focus()}})}export function wireCopy(host){if(!wcClaim(host,"copy"))return;wcListen(host,"click",(e)=>{const btn=wcClosest(host,e.target,".c-code__copy, .c-install__copy");if(!btn)return;const owner=wcClosest(host,btn,".c-code")||wcClosest(host,btn,".c-install")||host;const src=owner.querySelector("code, .c-install__command");const readSource=(el)=>{const lines=el&&el.querySelectorAll?el.querySelectorAll(".c-code__line"):null;if(!lines||!lines.length)return el?el.textContent||"":"";return Array.from(lines).map((l)=>Array.from(l.childNodes).filter((n)=>!(n.classList&&n.classList.contains("c-code__line-number"))).map((n)=>n.textContent).join("")).join("\n")};const text=readSource(src)||(src?"":owner.textContent)||"";const confirm=(ok)=>{const icon=btn.querySelector("use");const originalHref=icon&&icon.getAttribute("href");const originalLabel=btn.getAttribute("aria-label")||btn.title||"";if(ok&&icon)icon.setAttribute("href","#i-check");btn.setAttribute("aria-label",ok?"Copied":"Copy failed");btn.dataset.copied=String(ok);const timer=setTimeout(()=>{if(!btn.isConnected)return;if(icon&&originalHref)icon.setAttribute("href",originalHref);btn.setAttribute("aria-label",originalLabel);delete btn.dataset.copied},1600);onDispose(host,()=>clearTimeout(timer))};const doCopy=async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText){await navigator.clipboard.writeText(text);return true}}catch(e){}try{const ta=document.createElement("textarea");ta.value=text;ta.setAttribute("readonly","");ta.style.position="fixed";ta.style.top="-9999px";ta.style.opacity="0";document.body.append(ta);ta.select();const ok=document.execCommand("copy");ta.remove();return ok}catch(e){return false}};doCopy().then((ok)=>confirm(ok));wcEmit(host,"contour:copy",{text})})}export function wireRemovable(host){if(!wcClaim(host,"removable"))return;wcListen(host,"click",(e)=>{const drop=(node)=>{if(node&&node.parentNode)node.parentNode.removeChild(node)};const tagBtn=wcClosest(host,e.target,".c-tag__remove");if(tagBtn){e.preventDefault();const tag=wcClosest(host,tagBtn,".c-tag");wcEmit(host,"contour:remove",{label:(tag&&tag.getAttribute("label"))||(tag?tag.textContent.trim():"")});drop(tag);return}const pillBtn=wcClosest(host,e.target,".c-filter-pill__remove");if(pillBtn){e.preventDefault();const pill=wcClosest(host,pillBtn,".c-filter-pill");wcEmit(host,"contour:remove",{key:pill&&pill.getAttribute("key"),value:pill&&pill.getAttribute("value")});drop(pill);return}if(wcClosest(host,e.target,"[data-empty-action]")){wcEmit(host,"contour:empty-action",{state:host.getAttribute("state")||"empty"})}const alertClose=wcClosest(host,e.target,".c-alert__close");if(alertClose){e.preventDefault();wcEmit(host,"contour:close",{});if(host.shadowRoot?host.shadowRoot.contains(alertClose):true){try{host.remove()}catch(err){}}return}const calloutClose=wcClosest(host,e.target,".c-callout__close");if(calloutClose){e.preventDefault();wcEmit(host,"contour:close",{});try{host.remove()}catch(err){}return}})}const modalDepth={n:0};let modalSavedOverflow=null;let modalSavedX=0;let modalSavedY=0;const modalInerted=new Set();const modalStack=[];let modalTrapWired=false;function modalFocusables(host){return Array.from(host.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")).filter((el)=>!el.hasAttribute("disabled")&&el.getAttribute("aria-hidden")!=="true")}function modalTrapHandler(e){if(e.key!=="Tab")return;const host=modalStack[modalStack.length-1];if(!host)return;const f=modalFocusables(host);if(!f.length){e.preventDefault();return}const first=f[0];const last=f[f.length-1];const active=document.activeElement;if(e.shiftKey){if(active===first||!host.contains(active)){e.preventDefault();last.focus()}}else{if(active===last){e.preventDefault();first.focus()}}}export function modalContain(host,open){if(open){if(modalDepth.n===0){modalSavedX=window.scrollX;modalSavedY=window.scrollY;modalSavedOverflow=document.documentElement.style.overflow;document.documentElement.style.overflow="hidden"}modalDepth.n+=1;modalStack.push(host);if(modalDepth.n===1&&!modalTrapWired){modalTrapWired=true;document.addEventListener("keydown",modalTrapHandler)}for(let el=host;el&&el!==document.body;el=el.parentElement){for(const sib of el.parentElement.children){if(sib===el||sib.inert||modalInerted.has(sib))continue;sib.inert=true;modalInerted.add(sib)}}}else{const idx=modalStack.lastIndexOf(host);if(idx>=0)modalStack.splice(idx,1);modalDepth.n=Math.max(0,modalDepth.n-1);if(modalDepth.n===0){for(const el of modalInerted)el.inert=false;modalInerted.clear();document.documentElement.style.overflow=modalSavedOverflow||"";window.scrollTo(modalSavedX,modalSavedY);if(modalTrapWired){document.removeEventListener("keydown",modalTrapHandler);modalTrapWired=false}}}}export const STATE_FALLBACK={empty:"No data",loading:"Loading…",error:"Could not load.",};export function stateLabel(host,key){const fallback=STATE_FALLBACK[key]||key;const raw=host&&host.getAttribute?host.getAttribute("labels"):null;if(!raw)return fallback;try{const parsed=JSON.parse(raw);if(parsed&&typeof parsed==="object"&&typeof parsed[key]==="string"&&parsed[key])return parsed[key]}catch(e){}return fallback}const remoteInflight=new Map();const REMOTE_CACHE_MAX=64;const remoteCache=new Map();function cacheResult(src,data){if(remoteCache.size>=REMOTE_CACHE_MAX)remoteCache.delete(remoteCache.keys().next().value);remoteCache.set(src,data)}function setStatus(host,status){host._remoteStatus=status;if(status!=="error")host._remoteError=null;if(status==="loading")host.setAttribute("aria-busy","true");else host.removeAttribute("aria-busy");if(typeof host._setCustomState==="function")host._setCustomState("data-loading",status==="loading")}function emitState(host,name,detail){host.dispatchEvent(new CustomEvent(name,{detail,bubbles:true,composed:true}))}function countOf(data){if(Array.isArray(data))return data.length;if(data&&typeof data==="object")return Object.keys(data).length;return data===null||data===undefined?0:1}function leaveRequest(host){const entry=host._remoteEntry;host._remoteEntry=null;if(!entry)return;entry.hosts.delete(host);if(entry.hosts.size===0&&entry.controller)entry.controller.abort()}export function loadRemote(host,fields){const src=host.getAttribute("src");if(!src){leaveRequest(host);setStatus(host,host._remoteData!==undefined?"ready":"idle");return}remoteRefresh(host);const wanted=typeof fields==="string"?[fields]:fields;if(wanted.every((f)=>host.getAttribute(f)!==null)){leaveRequest(host);setStatus(host,"ready");return}if(!remoteVisible(host)){setStatus(host,"loading");return}const noCache=host.hasAttribute("no-cache");const cacheKey=host.getAttribute("cache-key")||src;if(noCache){if(host._remoteSrc===src&&host._remoteData!==undefined){setStatus(host,"ready");return}}else{const cached=remoteCache.get(cacheKey);if(cached!==undefined){host._remoteSrc=src;host._remoteData=cached;setStatus(host,"ready");return}}if(host._remoteSrc===src&&(host._remoteStatus==="loading"||host._remoteStatus==="error"))return;leaveRequest(host);host._remoteSrc=src;setStatus(host,"loading");let entry=remoteInflight.get(src);if(!entry){entry={hosts:new Set(),controller:new AbortController(),cacheKey};remoteInflight.set(src,entry);entry.promise=startFetch(host,src,entry).then((data)=>{if(remoteInflight.get(src)===entry)remoteInflight.delete(src);cacheResult(src,data);const namedKey=entry.cacheKey;if(namedKey&&namedKey!==src)cacheResult(namedKey,data);for(const h of entry.hosts){h._remoteData=data;h._remoteEntry=null;setStatus(h,"ready");emitState(h,"contour:load",{src,count:countOf(data)})}},(err)=>{if(remoteInflight.get(src)===entry)remoteInflight.delete(src);for(const h of entry.hosts){h._remoteEntry=null;setStatus(h,"error");h._remoteError=err&&err.name==="HttpError"?`Could not load (${err.status})`:STATE_FALLBACK.error;emitState(h,"contour:error",{src,message:h._remoteError,name:err&&err.name,status:err&&err.status,})}}).finally(()=>{for(const h of entry.hosts)if(h.isConnected)h.requestRender();entry.hosts.clear()})}entry.hosts.add(host);host._remoteEntry=entry;if(!host._remoteDisposeRegistered){host._remoteDisposeRegistered=true;onDispose(host,()=>{host._remoteDisposeRegistered=false;leaveRequest(host)})}}export function remoteInvalidate(srcOrKey){remoteCache.delete(srcOrKey)}function startFetch(host,src,entry){const ms=parseInt(host.getAttribute("timeout")||"",10);let timer=null;let signal=entry.controller.signal;if(Number.isFinite(ms)&&ms>0){if(typeof AbortSignal!=="undefined"&&AbortSignal.timeout){signal=AbortSignal.any([signal,AbortSignal.timeout(ms)])}else{timer=setTimeout(()=>entry.controller.abort(),ms)}}onDispose(host,()=>{if(timer)clearTimeout(timer)});return fetch(src,{signal}).then((res)=>{if(timer)clearTimeout(timer);if(!res.ok){const e=new Error(`Could not load (${res.status})`);e.name="HttpError";e.status=res.status;throw e}return res.text()}).then((text)=>{try{return JSON.parse(text)}catch(err){const e=new Error(STATE_FALLBACK.error);e.name="ParseError";e.cause=err;throw e}})}export function remoteData(host,field){const authored=host.getAttribute(field);if(authored!==null)return authored;const data=host._remoteData;if(data===undefined||data===null)return null;if(Array.isArray(data))return JSON.stringify(data);if(typeof data==="object"){const keys=typeof field==="string"?[field]:field;for(const k of keys){if(data[k]===undefined)continue;return typeof data[k]==="string"?data[k]:JSON.stringify(data[k])}return null}return String(data)}export function remoteRefresh(host){const seconds=parseFloat(host.getAttribute("refresh")||"");const want=host.hasAttribute("src")&&Number.isFinite(seconds)&&seconds>0;if(!want){if(host._remoteTimer!==undefined){clearTimeout(host._remoteTimer);host._remoteTimer=undefined}host._remoteLoop=false;return}if(host._remoteLoop)return;host._remoteLoop=true;const tick=()=>{host._remoteTimer=undefined;if(!host.isConnected||!host.hasAttribute("refresh")){host._remoteLoop=false;return}if(document.hidden){host._remoteTimer=setTimeout(tick,1000);return}const src=host.getAttribute("src");const namedKey=host.getAttribute("cache-key");if(namedKey)remoteCache.delete(namedKey);remoteCache.delete(src);host._remoteSrc=null;host._remoteLoop=false;host.requestRender()};host._remoteTimer=setTimeout(tick,Math.max(1000,seconds*1000));onDispose(host,()=>{clearTimeout(host._remoteTimer);host._remoteTimer=undefined;host._remoteLoop=false})}let _sharedLazyIO=null;const _sharedLazyTargets=new Map();export function remoteVisible(host){if(!host.hasAttribute("lazy"))return true;if(typeof IntersectionObserver!=="function")return true;if(host._remoteVisible)return true;if(host._lazyRegistered)return false;if(!_sharedLazyIO){_sharedLazyIO=new IntersectionObserver((records)=>{for(const r of records){const activate=_sharedLazyTargets.get(r.target);if(!activate||!r.isIntersecting)continue;_sharedLazyTargets.delete(r.target);_sharedLazyIO.unobserve(r.target);activate()}},{rootMargin:"200px"})}const activate=()=>{host._remoteVisible=true;host._lazyRegistered=false;host.requestRender()};host._lazyRegistered=true;_sharedLazyTargets.set(host,activate);_sharedLazyIO.observe(host);onDispose(host,()=>{_sharedLazyIO.unobserve(host);_sharedLazyTargets.delete(host);host._lazyRegistered=false});return false}export function watchViewport(host){if(host._contourViewWired)return()=>{};host._contourViewWired=true;const emit=(type)=>host.dispatchEvent(new CustomEvent(type,{bubbles:true,composed:true}));if(typeof IntersectionObserver!=="function"){emit("contour:view-enter");return()=>{}}const io=new IntersectionObserver((records)=>{for(const r of records){if(r.isIntersecting)emit("contour:view-enter");else emit("contour:view-leave")}});io.observe(host);onDispose(host,()=>io.disconnect());return()=>io.disconnect()}function stateNode(block,kind,text){const node=document.createElement("div");node.className="c-"+block+"__"+kind;node.dataset.contourState=kind;node.textContent=text;return node}function skeletonRow(i,total){const node=document.createElement("div");node.className="c-skeleton "+(i===0&&total>1?"c-skeleton--title":"c-skeleton--text");node.dataset.contourState="skeleton";return node}export function renderStates(host,block,opts){const options=opts||{};const loading=host.getAttribute("loading");if(loading!==null||host._remoteStatus==="loading"){host.appendChild(stateNode(block,"loading",loading||stateLabel(host,"loading")));return true}const error=host.getAttribute("error");if(error!==null||host._remoteStatus==="error"){const message=(error!==null&&error!=="")?error:(host._remoteError||stateLabel(host,"error"));const node=stateNode(block,"error",message);if(host.hasAttribute("retry")){const btn=document.createElement("button");btn.type="button";btn.className="c-btn c-btn--ghost c-btn--sm";btn.textContent=host.getAttribute("retry")||"Retry";btn.dataset.action="retry";node.appendChild(btn)}host.appendChild(node);return true}if(host.hasAttribute("skeleton")){const asked=parseInt(host.getAttribute("skeleton")||"3",10);const count=Math.min(options.max||6,Math.max(1,Number.isFinite(asked)?asked:3));for(let i=0;i<count;i++)host.appendChild(skeletonRow(i,count));return true}return false}export function renderEmpty(host,block){host.appendChild(stateNode(block,"empty",host.getAttribute("empty")||stateLabel(host,"empty")))}export function wireStates(host){if(host._contourStatesWired)return;host._contourStatesWired=true;host.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest('[data-action="retry"]'):null;if(!btn||!host.contains(btn))return;e.preventDefault();const src=host.getAttribute("src");const namedKey=host.getAttribute("cache-key");if(namedKey)remoteCache.delete(namedKey);if(src)remoteCache.delete(src);leaveRequest(host);host._remoteSrc=null;host._remoteData=undefined;setStatus(host,"idle");emitState(host,"contour:retry",{src});host.requestRender()})}const splitCodeLines=(code)=>{const lines=[];let line=null;const add=(n)=>{if(!line){line=document.createElement("span");line.className="c-code__line";lines.push(line)}line.appendChild(n)};Array.from(code.childNodes).forEach((n)=>{if(n.nodeType!==3){add(n);return}String(n.textContent||"").split("\n").forEach((p,i)=>{if(i)line=null;if(p)add(document.createTextNode(p))})});const last=lines[lines.length-1];if(last&&!last.textContent&&lines.length>1)lines.pop();if(!lines.length)return;const frag=document.createDocumentFragment();lines.forEach((l,i)=>{const num=document.createElement("span");num.className="c-code__line-number";num.setAttribute("aria-hidden","true");num.textContent=String(i+1);l.prepend(num);frag.appendChild(l)});code.textContent="";code.appendChild(frag)};const joinCodeLines=(code)=>{const frag=document.createDocumentFragment();Array.from(code.querySelectorAll(".c-code__line")).forEach((l)=>{Array.from(l.childNodes).forEach((n)=>{if(n.classList&&n.classList.contains("c-code__line-number"))return;frag.appendChild(n)});frag.appendChild(document.createTextNode("\n"))});code.textContent="";code.appendChild(frag)};class ContourCard extends ContourBase{static get observed(){return["title","variant","heading"]}static get properties(){return{title:{attribute:"title"},variant:{attribute:"variant"}}}render(){this.classList.add("c-card");const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-card--"))this.classList.remove(c)});if(variant)this.classList.add("c-card--"+variant);const title=this.getAttribute("title");if(title){const h=this.ensure(".c-card__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-card__title";return el});if(h.parentNode===this&&this.firstChild!==h)this.prepend(h);h.textContent=title}else{const h=this.querySelector(".c-card__title");if(h)h.remove()}}}define("contour-card",ContourCard);class ContourFeature extends ContourBase{static get observed(){return["index","title","body","heading"]}static get properties(){return{index:{attribute:"index"},title:{attribute:"title"},body:{attribute:"body"}}}render(){this.classList.add("c-feature");const index=this.getAttribute("index");const title=this.getAttribute("title");const body=this.getAttribute("body");if(index){const x=this.ensure(".c-feature__index",()=>{const el=document.createElement("span");el.className="c-feature__index";return el});x.textContent=index}else{const x=this.querySelector(".c-feature__index");if(x)x.remove()}if(title){const t=this.ensure(".c-feature__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-feature__title";return el});t.textContent=title}else{const t=this.querySelector(".c-feature__title");if(t)t.remove()}if(body){const b=this.ensure(".c-feature__body",()=>{const el=document.createElement("p");el.className="c-feature__body";return el});b.textContent=body}else{const b=this.querySelector(".c-feature__body");if(b)b.remove()}}}define("contour-feature",ContourFeature);class ContourSteps extends ContourBase{static get observed(){return["steps","current","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","heading"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current",type:Number},src:{attribute:"src"}}}render(){this.classList.add("c-steps");let list=this.querySelector(".c-steps__list");if(!list){list=document.createElement("ol");list.className="c-steps__list";list.setAttribute("aria-label",this.getAttribute("aria-label")||"Steps");this.appendChild(list)}wireStates(this);loadRemote(this,"steps");if(renderStates(this,"steps"))return;const steps=remoteData(this,"steps");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-steps__item"));if(steps&&!authored.length){Array.from(list.querySelectorAll(".c-steps__item")).forEach((n)=>n.remove());try{const parsed=JSON.parse(steps);parsed.forEach((st,i)=>{const item=document.createElement("li");item.className="c-steps__item";item.tabIndex=-1;const title=typeof st==="string"?st:st.title;const body=typeof st==="string"?"":st.body;if(title){const h=document.createElement(headingTag(this,"h3"));h.className="c-steps__title";h.textContent=title;item.appendChild(h)}if(body){const p=document.createElement("p");p.className="c-steps__body";p.textContent=body;item.appendChild(p)}list.appendChild(item)})}catch(e){warnBadJson(this,"attribute",e)}}else if(!steps&&!authored.length){renderEmpty(this,"steps")}const attrCurrent=this.getAttribute("current");const current=(this._current!=null)?this._current:(attrCurrent!=null?parseInt(attrCurrent,10):NaN);const items=Array.from(this.querySelectorAll(".c-steps__item"));items.forEach((it,i)=>{if(Number.isFinite(current)&&i===current)it.setAttribute("aria-current","step");else it.removeAttribute("aria-current");it.tabIndex=(Number.isFinite(current)&&i===current)?0:-1});if(items.length&&!Number.isFinite(current)){items[0].tabIndex=0}}enhance(){if(!this._wiredSteps){this._wiredSteps=true;this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-steps__item"));if(!items.length)return;navKey(e,items,{wrap:false,homeEnd:true,rtl:isRtl(this),onNavigate:(i)=>{this._current=i;items.forEach((it,j)=>{it.setAttribute("aria-current",j===i?"step":"");it.tabIndex=j===i?0:-1});const title=items[i].querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{index:i,title}}))},onKey:()=>{if(e.key==="Enter"||e.key===" "){const idx=items.indexOf(document.activeElement);const title=document.activeElement.querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-activate",{bubbles:true,composed:true,detail:{index:idx,title}}))}}})});this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-steps__item"):null;if(!item||!this.contains(item))return;const items=Array.from(this.querySelectorAll(".c-steps__item"));const idx=items.indexOf(item);if(idx<0)return;this._current=idx;items.forEach((it,i)=>{if(i===idx)it.setAttribute("aria-current","step");else it.removeAttribute("aria-current");it.tabIndex=i===idx?0:-1});const title=item.querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-activate",{bubbles:true,composed:true,detail:{index:idx,title}}))})}}}define("contour-steps",ContourSteps);class ContourLink extends ContourBase{static get observed(){return["href","label"]}static get properties(){return{href:{attribute:"href"},label:{attribute:"label"}}}render(){this.classList.add("c-link");const href=this.getAttribute("href");const label=this.getAttribute("label");const prevLink=this.querySelector("a");if(prevLink)prevLink.remove();if(href&&label){const a=document.createElement("a");a.href=safeHref(href);a.textContent=label;const ariaLabel=this.getAttribute("aria-label");if(ariaLabel)a.setAttribute("aria-label",ariaLabel);this.appendChild(a)}}}define("contour-link",ContourLink);class ContourBrand extends ContourBase{static get observed(){return["name","tag"]}static get properties(){return{name:{attribute:"name"},tag:{attribute:"tag"}}}render(){this.classList.add("c-brand");const name=this.getAttribute("name");const tag=this.getAttribute("tag");if(name){const n=this.ensure(".c-brand__name",()=>{const el=document.createElement("span");el.className="c-brand__name";return el});n.textContent=name}else{const n=this.querySelector(".c-brand__name");if(n)n.remove()}if(tag){const t=this.ensure(".c-brand__tag",()=>{const el=document.createElement("span");el.className="c-brand__tag";return el});t.textContent=tag}else{const t=this.querySelector(".c-brand__tag");if(t)t.remove()}}}define("contour-brand",ContourBrand);class ContourSectionHead extends ContourBase{static get observed(){return["title","desc","heading"]}static get properties(){return{title:{attribute:"title"},desc:{attribute:"desc"}}}render(){this.classList.add("c-section-head");const title=this.getAttribute("title");const desc=this.getAttribute("desc");if(!this.querySelector(".c-icon-badge")){const badge=document.createElement("div");badge.className="c-icon-badge";const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href","#i-crosshair");svg.appendChild(use);badge.replaceChildren(svg);this.prepend(badge)}let content=this.querySelector(":scope > div:not(.c-icon-badge)");if(!content){content=document.createElement("div");this.appendChild(content)}if(title){const t=this.ensure(".c-section-head__title",()=>{const el=document.createElement(headingTag(this,"h2"));el.className="c-section-head__title";return el});t.textContent=title;if(t.parentNode!==content)content.appendChild(t)}else{const t=this.querySelector(".c-section-head__title");if(t)t.remove()}if(desc){const d=this.ensure(".c-section-head__desc",()=>{const el=document.createElement("p");el.className="c-section-head__desc";return el});d.textContent=desc;if(d.parentNode!==content)content.appendChild(d)}else{const d=this.querySelector(".c-section-head__desc");if(d)d.remove()}}}define("contour-section-head",ContourSectionHead);class ContourDiff extends ContourBase{static get observed(){return["before","after"]}static get properties(){return{before:{attribute:"before"},after:{attribute:"after"}}}render(){this.classList.add("c-diff");this.setAttribute("role","group");this.setAttribute("aria-label","Diff");Array.from(this.querySelectorAll(".c-diff__line")).forEach((n)=>n.remove());const line=(kind,sign,text)=>{const el=document.createElement("div");el.className=kind?`c-diff__line c-diff__line--${kind}`:"c-diff__line";el.setAttribute("role","listitem");el.setAttribute("tabindex","0");const s=document.createElement("span");s.className="c-diff__sign";s.textContent=sign;const code=document.createElement("span");code.textContent=text;el.append(s,code);return el};const before=this.getAttribute("before");const after=this.getAttribute("after");if(before)this.appendChild(line("del","−",before));if(after)this.appendChild(line("add","+",after))}enhance(){if(this._wiredDiff)return;this._wiredDiff=true;this.addEventListener("click",(e)=>{const line=e.target&&e.target.closest?e.target.closest(".c-diff__line"):null;if(line&&this.contains(line)){const kind=line.classList.contains("c-diff__line--add")?"add":line.classList.contains("c-diff__line--del")?"del":"context";const text=line.querySelector("span:last-child")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:diff-activate",{bubbles:true,composed:true,detail:{kind,text}}))}});this.addEventListener("keydown",(e)=>{const line=e.target&&e.target.closest?e.target.closest(".c-diff__line"):null;if(!line||!this.contains(line))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();line.click()}})}}define("contour-diff",ContourDiff);class ContourDoDont extends ContourBase{static get observed(){return["do","dont"]}static get properties(){return{do:{attribute:"do"},dont:{attribute:"dont"}}}render(){this.classList.add("c-do-dont");this.setAttribute("role","group");this.setAttribute("aria-label","Do and don't");Array.from(this.querySelectorAll(".c-do-dont__item")).forEach((n)=>n.remove());const item=(kind,word,text)=>{const el=document.createElement("div");el.className=`c-do-dont__item c-do-dont__item--${kind}`;el.setAttribute("role","listitem");const label=document.createElement("p");label.className="c-do-dont__label";label.textContent=word;const body=document.createElement("p");body.className="u-muted";body.textContent=text;el.append(label,body);return el};const doText=this.getAttribute("do");const dontText=this.getAttribute("dont");if(doText)this.appendChild(item("do","Do",doText));if(dontText)this.appendChild(item("dont","Don't",dontText))}enhance(){if(this._wiredDoDont)return;this._wiredDoDont=true;this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-do-dont__item"):null;if(item&&this.contains(item)){const kind=item.classList.contains("c-do-dont__item--do")?"do":"dont";const text=item.querySelector(".u-muted")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:do-dont-activate",{bubbles:true,composed:true,detail:{kind,text}}))}});Array.from(this.querySelectorAll(".c-do-dont__item")).forEach((it)=>{if(!it.hasAttribute("tabindex"))it.setAttribute("tabindex","0");if(!it.hasAttribute("role"))it.setAttribute("role","button")});this.addEventListener("keydown",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-do-dont__item"):null;if(!item||!this.contains(item))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();item.click()}})}}define("contour-do-dont",ContourDoDont);class ContourFlag extends ContourBase{static get observed(){return["variant","label"]}static get properties(){return{variant:{attribute:"variant"},label:{attribute:"label"}}}render(){this.classList.add("c-flag");const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-flag--"))this.classList.remove(c)});if(variant)this.classList.add("c-flag--"+variant);const label=this.getAttribute("label");if(label){this.textContent=label}}}define("contour-flag",ContourFlag);class ContourInstallFull extends ContourBase{static get observed(){return["command","prompt","copyable"]}static get properties(){return{command:{attribute:"command"},prompt:{attribute:"prompt"},copyable:{attribute:"copyable"}}}render(){this.classList.add("c-install");const prompt=this.getAttribute("prompt")||"$";const command=this.getAttribute("command")||"";if(command){const p=this.ensure(".c-install__prompt",()=>{const el=document.createElement("span");el.className="c-install__prompt";return el});p.textContent=prompt;const c=this.ensure(".c-install__command",()=>{const el=document.createElement("span");el.className="c-install__command";return el});c.textContent=command;if(this.hasAttribute("copyable")){this.ensure(".c-install__copy",()=>{const btn=document.createElement("button");btn.className="c-btn c-btn--ghost c-btn--sm c-install__copy";btn.type="button";btn.setAttribute("aria-label",labelText(this,"copy-command","Copy command"));btn.textContent=labelText(this,"copy","Copy");return btn})}else{const btn=this.querySelector(".c-install__copy");if(btn)btn.remove()}}}enhance(){wireCopy(this)}}define("contour-install",ContourInstallFull);class ContourTestimonialFull extends ContourBase{static get observed(){return["quote","name","role"]}static get properties(){return{quote:{attribute:"quote"},name:{attribute:"name"},role:{attribute:"role"}}}render(){this.classList.add("c-testimonial");const quote=this.getAttribute("quote");if(quote){const q=this.ensure(".c-testimonial__quote",()=>{const el=document.createElement("blockquote");el.className="c-testimonial__quote";return el});q.textContent=quote}else{const q=this.querySelector(".c-testimonial__quote");if(q)q.remove()}const name=this.getAttribute("name");const role=this.getAttribute("role");if(name){const by=this.ensure(".c-testimonial__byline",()=>{const el=document.createElement("figcaption");el.className="c-testimonial__byline";return el});const n=by.querySelector(".c-testimonial__name")||(()=>{const el=document.createElement("cite");el.className="c-testimonial__name";by.appendChild(el);return el})();n.className="c-testimonial__name";n.textContent=name;if(role){const r=by.querySelector(".c-testimonial__role")||(()=>{const el=document.createElement("span");el.className="c-testimonial__role";by.appendChild(el);return el})();r.className="c-testimonial__role";r.textContent=role}else{const r=by.querySelector(".c-testimonial__role");if(r)r.remove()}}else{const by=this.querySelector(".c-testimonial__byline");if(by)by.remove()}}}define("contour-testimonial",ContourTestimonialFull);class ContourShowcaseFull extends ContourBase{static get observed(){return["title","text","media","reverse","items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","heading"]}static get properties(){return{title:{attribute:"title"},text:{attribute:"text"},media:{attribute:"media"},reverse:{attribute:"reverse"},items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-showcase");this.setAttribute("role","list");if(this.hasAttribute("reverse"))this.classList.add("c-showcase--reverse");else this.classList.remove("c-showcase--reverse");const title=this.getAttribute("title");if(title)this.setAttribute("aria-label",title);else this.removeAttribute("aria-label");this.setAttribute("role","region");wireStates(this);loadRemote(this,"items");if(renderStates(this,"showcase"))return;const items=remoteData(this,"items");const text=this.getAttribute("text");const media=this.getAttribute("media");if(media){const m=this.ensure(".c-showcase__media",()=>{const el=document.createElement("figure");el.className="c-showcase__media";return el});if(/^https?:\/\/|^\/|^\.\/|\.(png|jpg|jpeg|svg|webp|gif|avif)$/i.test(media.trim())){let img=m.querySelector("img");if(!img){img=document.createElement("img");m.appendChild(img)}img.src=media.trim();img.alt=title||""}else{m.innerHTML=sanitizeHtml(media)}if(title){let cap=m.querySelector(".c-showcase__caption");if(!cap){cap=document.createElement("figcaption");cap.className="c-showcase__caption";m.appendChild(cap)}cap.textContent=title}}else{const m=this.querySelector(".c-showcase__media");if(m)m.remove()}if(title){const t=this.ensure(".c-showcase__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-showcase__title";return el});t.textContent=title}else{const t=this.querySelector(".c-showcase__title");if(t)t.remove()}if(text){const p=this.ensure(".c-showcase__text",()=>{const el=document.createElement("p");el.className="c-showcase__text";return el});p.textContent=text}else{const p=this.querySelector(".c-showcase__text");if(p)p.remove()}const ul=this.querySelector(".c-showcase__list");const authored=ul?Array.from(ul.children).filter((n)=>n.tagName==="LI"):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const l=this.ensure(".c-showcase__list",()=>{const el=document.createElement("ul");el.className="c-showcase__list";return el});l.replaceChildren();parsed.forEach((it)=>{const li=document.createElement("li");li.textContent=typeof it==="string"?it:(it.label||it.title||"");l.appendChild(li)})}catch(e){warnBadJson(this,"attribute",e)}}else if(!items&&!authored.length&&!title&&!text&&!media){renderEmpty(this,"showcase")}else if(!items&&ul){ul.remove()}}enhance(){if(this._wiredShowcase)return;this._wiredShowcase=true;this.addEventListener("click",(e)=>{const media=e.target&&e.target.closest?e.target.closest(".c-showcase__media"):null;if(media&&this.contains(media)){const title=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:showcase-activate",{bubbles:true,composed:true,detail:{title}}))}});this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){const media=this.querySelector(".c-showcase__media");if(media){e.preventDefault();const title=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:showcase-activate",{bubbles:true,composed:true,detail:{title}}))}}})}}define("contour-showcase",ContourShowcaseFull);class ContourPricingFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-pricing")}}define("contour-pricing",ContourPricingFull);class ContourRecipeFull extends ContourBase{static get observed(){return["title","body","canvas","heading","url","tags","head","index"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},canvas:{attribute:"canvas"},url:{attribute:"url"},tags:{attribute:"tags"},head:{attribute:"head"},index:{attribute:"index"}}}render(){this.classList.add("c-recipe");const url=this.getAttribute("url");let frame=this.querySelector(".c-recipe__frame");if(url){if(!frame){frame=document.createElement("div");frame.className="c-recipe__frame";const bar=document.createElement("div");bar.className="c-recipe__frame-bar";for(let i=0;i<3;i++){const dot=document.createElement("span");dot.className="c-recipe__frame-dot";bar.appendChild(dot)}const urlEl=document.createElement("span");urlEl.className="c-recipe__frame-url";bar.appendChild(urlEl);frame.appendChild(bar);this.prepend(frame)}const urlEl=frame.querySelector(".c-recipe__frame-url");if(urlEl)urlEl.textContent=url}else if(frame){frame.remove()}const head=this.getAttribute("head");if(head){const h=this.ensure(".c-recipe__head",()=>{const el=document.createElement("div");el.className="c-recipe__head";return el});h.textContent=head}else{const h=this.querySelector(".c-recipe__head");if(h)h.remove()}const title=this.getAttribute("title");if(title){const t=this.ensure(".c-recipe__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-recipe__title";return el});t.textContent=title}else{const t=this.querySelector(".c-recipe__title");if(t)t.remove()}const index=this.getAttribute("index");if(index){const idx=this.ensure(".c-recipe__index",()=>{const el=document.createElement("span");el.className="c-recipe__index";return el});idx.textContent=index}else{const idx=this.querySelector(".c-recipe__index");if(idx)idx.remove()}const body=this.getAttribute("body");if(body){const b=this.ensure(".c-recipe__desc",()=>{const el=document.createElement("p");el.className="c-recipe__desc";return el});b.textContent=body}else{const b=this.querySelector(".c-recipe__desc");if(b)b.remove()}const tags=this.getAttribute("tags");if(tags){const t=this.ensure(".c-recipe__tags",()=>{const el=document.createElement("div");el.className="c-recipe__tags";return el});t.innerHTML="";tags.split(",").map((s)=>s.trim()).filter(Boolean).forEach((tag)=>{const span=document.createElement("span");span.textContent=tag;t.appendChild(span)})}else{const t=this.querySelector(".c-recipe__tags");if(t)t.remove()}const canvas=this.getAttribute("canvas");if(canvas){const c=this.ensure(".c-recipe__canvas",()=>{const el=document.createElement("div");el.className="c-recipe__canvas";return el});if(/^https?:\/\/|^\/|^\.\/|\.(png|jpg|jpeg|svg|webp|gif|avif)$/i.test(canvas.trim())){let img=c.querySelector("img");if(!img){img=document.createElement("img");c.appendChild(img)}img.src=canvas.trim();img.alt=""}else{c.innerHTML=sanitizeHtml(canvas)}}else{const c=this.querySelector(".c-recipe__canvas");if(c)c.remove()}}}define("contour-recipe",ContourRecipeFull);class ContourLogosFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-logos");if(!this.querySelector(".c-logos__item")){for(const name of["Cartolab","Nordwand"]){const span=document.createElement("span");span.className="c-logos__item";span.textContent=name;this.appendChild(span)}}}}define("contour-logos",ContourLogosFull);class ContourLandingFeaturesFull extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-landing-features");wireStates(this);loadRemote(this,"items");if(renderStates(this,"landing-features"))return;const items=remoteData(this,"items");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-landing-features__item"));if(items&&!authored.length){try{const parsed=JSON.parse(items);this.querySelectorAll(".c-landing-features__item").forEach((el)=>el.remove());parsed.forEach((it)=>{const item=document.createElement("div");item.className="c-landing-features__item";if(it.icon){const ic=document.createElement("span");ic.className="c-landing-features__icon";const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href","#"+String(it.icon).replace(/[^a-zA-Z0-9_-]/g,""));svg.appendChild(use);ic.appendChild(svg);item.appendChild(ic)}if(it.title){const t=document.createElement("span");t.className="c-landing-features__title";t.textContent=it.title;item.appendChild(t)}if(it.text){const tx=document.createElement("p");tx.className="c-landing-features__text";tx.textContent=it.text;item.appendChild(tx)}this.appendChild(item)})}catch(e){warnBadJson(this,"attribute",e)}}else if(!items&&!authored.length){this.querySelectorAll(".c-landing-features__item").forEach((el)=>el.remove());renderEmpty(this,"landing-features")}}}define("contour-landing-features",ContourLandingFeaturesFull);class ContourLandingHeroFull extends ContourBase{static get observed(){return["actions","title","text","heading","preview"]}static get properties(){return{actions:{attribute:"actions"},title:{attribute:"title"},text:{attribute:"text"},preview:{attribute:"preview"}}}render(){this.classList.add("c-landing-hero");const preview=this.getAttribute("preview");let pv=this.querySelector(".c-landing-hero__preview");if(preview){if(!pv){pv=document.createElement("div");pv.className="c-landing-hero__preview";const bar=document.createElement("div");bar.className="c-landing-hero__preview-bar";for(let i=0;i<3;i++){const dot=document.createElement("span");dot.className="c-landing-hero__preview-dot";bar.appendChild(dot)}const body=document.createElement("div");body.className="c-landing-hero__preview-body";pv.appendChild(bar);pv.appendChild(body);this.appendChild(pv)}const body=pv.querySelector(".c-landing-hero__preview-body");if(body){if(/^https?:\/\/|^\/|^\.\/|\.(png|jpg|jpeg|svg|webp|gif|avif)$/i.test(preview.trim())){body.innerHTML="";const img=document.createElement("img");img.src=preview.trim();img.alt="";body.appendChild(img)}else{body.innerHTML=sanitizeHtml(preview)}}}else if(pv){pv.remove()}const title=this.getAttribute("title");if(title){const t=this.ensure(".c-landing-hero__title",()=>{const el=document.createElement(headingTag(this,"h2"));el.className="c-landing-hero__title";return el});t.textContent=title}const text=this.getAttribute("text");if(text){const t=this.ensure(".c-landing-hero__text",()=>{const el=document.createElement("p");el.className="c-landing-hero__text";return el});t.textContent=text}const actions=this.getAttribute("actions");const a=this.querySelector(".c-landing-hero__actions");const authored=a?Array.from(a.children):[];if(actions&&!authored.length){const el=this.ensure(".c-landing-hero__actions",()=>{const e=document.createElement("div");e.className="c-landing-hero__actions";return e});try{const parsed=JSON.parse(actions);if(Array.isArray(parsed)){el.replaceChildren();parsed.forEach((act)=>{const btn=document.createElement(act.href?"a":"button");btn.className="c-btn"+(act.primary?" c-btn--primary":"");if(act.href)btn.href=safeHref(act.href);else btn.type="button";btn.textContent=act.label||act.text||"";el.appendChild(btn)})}else{el.innerHTML=sanitizeHtml(actions)}}catch(_){el.innerHTML=sanitizeHtml(actions)}}else if(!actions&&a&&!authored.length){a.remove()}}}define("contour-landing-hero",ContourLandingHeroFull);class ContourLinkishFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-linkish")}}define("contour-linkish",ContourLinkishFull);class ContourPriceFull extends ContourBase{static get observed(){return["value","format","locale"]}static get properties(){return{value:{attribute:"value"},format:{attribute:"format"},locale:{attribute:"locale"}}}render(){this.classList.add("c-price");const value=this.getAttribute("value");if(value)this.textContent=formatValue(value,this.getAttribute("format"),this.getAttribute("locale"))}}define("contour-price",ContourPriceFull);class ContourProseFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-prose")}}define("contour-prose",ContourProseFull);class ContourPanel extends ContourBase{static get observed(){return["title","subtitle","status","heading","collapsible","collapsed","flush"]}static get properties(){return{title:{attribute:"title"},subtitle:{attribute:"subtitle"},status:{attribute:"status"},collapsible:{attribute:"collapsible",type:Boolean},collapsed:{attribute:"collapsed",type:Boolean},flush:{attribute:"flush",type:Boolean}}}render(){this.classList.add("c-panel");if(!this.hasAttribute("role"))this.setAttribute("role","region");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("title")||"Panel");const title=this.getAttribute("title");const subtitle=this.getAttribute("subtitle");const status=this.getAttribute("status");if(title){const h=this.ensure(".c-panel__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-panel__title";return el});if(h.parentNode===this&&this.firstChild!==h)this.prepend(h);h.textContent=title}else{const h=this.querySelector(".c-panel__title");if(h)h.remove()}if(subtitle){const sub=this.ensure(".c-panel__subtitle",()=>{const el=document.createElement("p");el.className="c-panel__subtitle";return el});sub.textContent=subtitle}else{const sub=this.querySelector(".c-panel__subtitle");if(sub)sub.remove()}if(status){const st=this.ensure(".c-panel__status",()=>{const el=document.createElement("span");el.className="c-panel__status";return el});Array.from(st.classList).forEach((c)=>{if(c.startsWith("c-panel__status--"))st.classList.remove(c)});if(status==="error"||status==="live")st.classList.add("c-panel__status--"+status);st.textContent=status}else{const st=this.querySelector(".c-panel__status");if(st)st.remove()}if(this.hasAttribute("collapsible")){let btn=this.querySelector(".c-panel__collapse");if(!btn){btn=document.createElement("button");btn.type="button";btn.className="c-panel__collapse c-btn c-btn--ghost c-btn--sm";btn.setAttribute("aria-label","Toggle panel");btn.textContent="▾";this.appendChild(btn)}if(this.hasAttribute("collapsed")){this.classList.add("c-panel--collapsed");btn.setAttribute("aria-expanded","false");btn.textContent="▸"}else{this.classList.remove("c-panel--collapsed");btn.setAttribute("aria-expanded","true");btn.textContent="▾"}}else{const btn=this.querySelector(".c-panel__collapse");if(btn)btn.remove();this.classList.remove("c-panel--collapsed")}const body=this.ensure(".c-panel__body",()=>{const el=document.createElement("div");el.className="c-panel__body";return el});body.classList.toggle("c-panel__body--flush",this.hasAttribute("flush"));const head=this.querySelector(".c-panel__head");Array.from(this.childNodes).forEach((n)=>{if(n===body||n===head)return;if(n.nodeType===1&&(n.classList.contains("c-panel__title")||n.classList.contains("c-panel__subtitle")||n.classList.contains("c-panel__status")))return;body.appendChild(n)});if(!body.parentNode)this.appendChild(body);if(head&&head.parentNode===this&&body.parentNode===this&&head.compareDocumentPosition(body)&Node.DOCUMENT_POSITION_PRECEDING){this.insertBefore(body,head.nextSibling)}}enhance(){if(this._wiredPanel)return;this._wiredPanel=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-panel__collapse"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.toggleAttribute("collapsed");this.dispatchEvent(new CustomEvent("contour:collapse",{bubbles:true,composed:true,detail:{collapsed:this.hasAttribute("collapsed")}}))})}}define("contour-panel",ContourPanel);class ContourCta extends ContourBase{static get observed(){return["title","text","actions","heading"]}static get properties(){return{title:{attribute:"title"},text:{attribute:"text"},actions:{attribute:"actions"}}}render(){this.classList.add("c-cta");const title=this.getAttribute("title");const text=this.getAttribute("text");if(title){const t=this.ensure(".c-cta__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-cta__title";return el});t.textContent=title}else{const t=this.querySelector(".c-cta__title");if(t)t.remove()}if(text){const p=this.ensure(".c-cta__text",()=>{const el=document.createElement("p");el.className="c-cta__text";return el});p.textContent=text}else{const p=this.querySelector(".c-cta__text");if(p)p.remove()}const actions=this.getAttribute("actions");const prevWrap=this.querySelector(".c-cta__actions");if(prevWrap)prevWrap.remove();if(actions){try{const parsed=JSON.parse(actions);const wrap=document.createElement("div");wrap.className="c-cta__actions";parsed.forEach((a)=>{const btn=document.createElement("button");btn.className="c-btn c-btn--primary";btn.type="button";btn.textContent=typeof a==="string"?a:(a.label||a);wrap.appendChild(btn)});this.appendChild(wrap)}catch(e){warnBadJson(this,"attribute",e)}}}}define("contour-cta",ContourCta);class ContourCode extends ContourBase{static get observed(){return["title","copyable","numbered"]}static get properties(){return{title:{attribute:"title"},copyable:{attribute:"copyable",type:Boolean},numbered:{attribute:"numbered",type:Boolean}}}render(){this.classList.add("c-code");const title=this.getAttribute("title");if(title){const head=this.ensure(".c-code__head",()=>{const el=document.createElement("div");el.className="c-code__head";return el});if(head.parentNode===this&&this.firstChild!==head)this.prepend(head);const t=head.querySelector(".c-code__title")||(()=>{const el=document.createElement("div");el.className="c-code__title";head.appendChild(el);return el})();t.textContent=title}else{const head=this.querySelector(".c-code__head");if(head)head.remove();const t=this.querySelector(".c-code__title");if(t)t.remove()}if(this.hasAttribute("copyable")){this.ensure(".c-code__copy",()=>{const btn=document.createElement("button");btn.className="c-code__copy";btn.type="button";btn.textContent=labelText(this,"copy","Copy");return btn})}else{const btn=this.querySelector(".c-code__copy");if(btn)btn.remove()}const pre=this.ensure("pre",()=>{const el=document.createElement("pre");return el});Array.from(this.childNodes).forEach((n)=>{if(n===pre||(n.nodeType===1&&(n.classList.contains("c-code__head")||n.classList.contains("c-code__copy"))))return;pre.appendChild(n)});if(!pre.querySelector("code")){const code=document.createElement("code");while(pre.firstChild)code.appendChild(pre.firstChild);pre.appendChild(code)}if(pre.parentNode!==this)this.appendChild(pre);const head=this.querySelector(".c-code__head");if(head&&head.parentNode===this&&pre.parentNode===this&&head.compareDocumentPosition(pre)&Node.DOCUMENT_POSITION_PRECEDING){this.insertBefore(pre,head.nextSibling)}const numbered=this.hasAttribute("numbered");this.classList.toggle("c-code--numbered",numbered);const codeEl=pre.querySelector("code");if(codeEl){const split=codeEl.dataset.contourLines==="1";if(numbered&&!split){splitCodeLines(codeEl);codeEl.dataset.contourLines="1"}else if(!numbered&&split){joinCodeLines(codeEl);delete codeEl.dataset.contourLines}}}enhance(){wireCopy(this)}}define("contour-code",ContourCode);class ContourPlate extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-plate")}}define("contour-plate",ContourPlate);class ContourPullquote extends ContourBase{static get observed(){return["quote","name"]}static get properties(){return{quote:{attribute:"quote"},name:{attribute:"name"}}}render(){this.classList.add("c-pullquote");const quote=this.getAttribute("quote");if(quote){Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===3)n.remove()});const cite=this.querySelector("cite");this.insertBefore(document.createTextNode(quote),cite)}const name=this.getAttribute("name");if(name){const by=this.ensure("cite",()=>{const el=document.createElement("cite");this.appendChild(el);return el});by.textContent=name}else{const by=this.querySelector("cite");if(by)by.remove()}}}define("contour-pullquote",ContourPullquote);class ContourAnchor extends ContourBase{static get observed(){return["href","label"]}static get properties(){return{href:{attribute:"href"},label:{attribute:"label"}}}render(){this.classList.add("c-anchor");const href=this.getAttribute("href");const label=this.getAttribute("label");const prevAnchor=this.querySelector("a");if(prevAnchor)prevAnchor.remove();if(href&&label){const a=document.createElement("a");a.href=safeHref(href);a.textContent=label;const ariaLabel=this.getAttribute("aria-label");if(ariaLabel)a.setAttribute("aria-label",ariaLabel);this.appendChild(a)}}}define("contour-anchor",ContourAnchor);class ContourGeocoder extends ContourBase{static get observed(){return["placeholder","value","results","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{placeholder:{attribute:"placeholder"},value:{attribute:"value"},results:{attribute:"results"},src:{attribute:"src"}}}render(){this.classList.add("c-geocoder");wireStates(this);loadRemote(this,["results"]);if(renderStates(this,"geocoder"))return;let inp=this.querySelector(".c-geocoder__input");if(!inp){inp=document.createElement("input");inp.type="search";inp.className="c-geocoder__input";if(!inp.hasAttribute("aria-label"))inp.setAttribute("aria-label",this.getAttribute("placeholder")||"Search location");this.appendChild(inp)}const ph=this.getAttribute("placeholder");if(ph)inp.setAttribute("placeholder",ph);const val=this.getAttribute("value");if(val!==null&&inp.value!==val)inp.value=val;Array.from(this.querySelectorAll(".c-geocoder__result")).forEach((n)=>n.remove());let results=[];const rAttr=this.getAttribute("results");if(rAttr){try{results=JSON.parse(rAttr)}catch(e){results=[]}}const remote=remoteData(this,"results");if(Array.isArray(remote))results=remote;if(Array.isArray(results)&&results.length){const list=document.createElement("ul");list.className="c-geocoder__list";list.setAttribute("role","listbox");results.forEach((r,idx)=>{const li=document.createElement("li");li.className="c-geocoder__result";li.setAttribute("role","option");li.setAttribute("tabindex",idx===0?"0":"-1");li.textContent=(typeof r==="object")?(r.label||r.name||""):String(r);if(typeof r==="object"){if(r.lat!=null)li.dataset.lat=String(r.lat);if(r.lon!=null)li.dataset.lon=String(r.lon)}list.appendChild(li)});this.appendChild(list)}else if(!this.hasAttribute("loading")&&!this.hasAttribute("error")){renderEmpty(this,"geocoder")}}enhance(){if(this._wiredGeocoder)return;this._wiredGeocoder=true;const inp=this.querySelector(".c-geocoder__input");if(inp){let timer=null;inp.addEventListener("input",()=>{if(timer)clearTimeout(timer);timer=setTimeout(()=>{this.dispatchEvent(new CustomEvent("contour:search",{bubbles:true,composed:true,detail:{query:inp.value}}))},200)});inp.addEventListener("keydown",(e)=>{if(e.key==="Enter"){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:search",{bubbles:true,composed:true,detail:{query:inp.value}}))}})}this.addEventListener("click",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-geocoder__result"):null;if(!li||!this.contains(li))return;const result={label:li.textContent.trim(),lat:li.dataset.lat,lon:li.dataset.lon};this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{result}}))});this.addEventListener("keydown",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-geocoder__result"):null;if(!li||!this.contains(li))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();const result={label:li.textContent.trim(),lat:li.dataset.lat,lon:li.dataset.lon};this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{result}}))}})}}define("contour-geocoder",ContourGeocoder);class ContourDashShell extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-dash-shell");this.setAttribute("role","region");const title=this.getAttribute("title");if(title){const bar=this.ensure(".c-dash-toolbar",()=>{const el=document.createElement("div");el.className="c-dash-toolbar";return el});const h=bar.querySelector(".c-dash-toolbar__title")||(()=>{const el=document.createElement("span");el.className="c-dash-toolbar__title";bar.appendChild(el);return el})();h.textContent=title;this.setAttribute("aria-label",title)}}}define("contour-dash-shell",ContourDashShell);class ContourDashToolbar extends ContourBase{static get observed(){return["title","actions"]}static get properties(){return{title:{attribute:"title"},actions:{attribute:"actions"}}}render(){this.classList.add("c-dash-toolbar");this.setAttribute("role","toolbar");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-dash-toolbar__title",()=>{const el=document.createElement("span");el.className="c-dash-toolbar__title";return el});t.textContent=title;this.setAttribute("aria-label",title)}else{const t=this.querySelector(".c-dash-toolbar__title");if(t)t.remove()}const actions=this.getAttribute("actions");if(actions){try{const parsed=JSON.parse(actions);const wrap=this.ensure(".c-dash-toolbar__actions",()=>{const el=document.createElement("div");el.className="c-dash-toolbar__actions";return el});wrap.innerHTML="";parsed.forEach((a)=>{const btn=document.createElement("button");btn.className="c-btn c-btn--ghost c-btn--sm";btn.type="button";btn.textContent=typeof a==="string"?a:(a.label||a);wrap.appendChild(btn)})}catch(e){warnBadJson(this,"attribute",e)}}else{const w=this.querySelector(".c-dash-toolbar__actions");if(w)w.remove()}}enhance(){if(this._wiredDashToolbar)return;this._wiredDashToolbar=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-btn"):null;if(btn&&this.contains(btn)){const label=btn.textContent||"";this.dispatchEvent(new CustomEvent("contour:dash-action",{bubbles:true,composed:true,detail:{label}}))}});this.addEventListener("keydown",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-btn"):null;if(!btn||!this.contains(btn))return;const btns=Array.from(this.querySelectorAll(".c-btn"));const idx=btns.indexOf(btn);let next=-1;if(e.key==="ArrowRight")next=Math.min(btns.length-1,idx+1);else if(e.key==="ArrowLeft")next=Math.max(0,idx-1);if(next>=0){e.preventDefault();try{btns[next].focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();btn.click()}})}}define("contour-dash-toolbar",ContourDashToolbar);class ContourDashKpiRow extends ContourBase{static get observed(){return["items","title"]}static get properties(){return{items:{attribute:"items"}}}render(){this.classList.add("c-dash-kpi-row");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("title")||"KPI row");Array.from(this.querySelectorAll("contour-kpi")).forEach((n)=>n.remove());const items=this.getAttribute("items");let parsed=null;if(items){try{parsed=JSON.parse(items)}catch(e){parsed=null}}if(Array.isArray(parsed)&&parsed.length){const passthrough=["value","label","delta","direction","note","unit","format","variant","thresholds","threshold","sparkline","polarity","locale"];parsed.forEach((it,i)=>{const k=document.createElement("contour-kpi");if(typeof it==="object"&&it!==null){for(const key of passthrough){if(it[key]!==undefined&&it[key]!==null)k.setAttribute(key,String(it[key]))}}else{k.setAttribute("value",String(it))}k.setAttribute("tabindex",i===0?"0":"-1");this.appendChild(k)})}}enhance(){if(this._wiredDashKpiRow)return;this._wiredDashKpiRow=true;this.addEventListener("click",(e)=>{const kpi=e.target&&e.target.closest?e.target.closest("contour-kpi"):null;if(kpi&&this.contains(kpi)){const kpis=Array.from(this.querySelectorAll("contour-kpi"));const idx=kpis.indexOf(kpi);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx}}))}});this.addEventListener("keydown",(e)=>{const kpis=Array.from(this.querySelectorAll("contour-kpi"));if(!kpis.length)return;navKey(e,kpis,{wrap:true,homeEnd:true,onNavigate:(i)=>{kpis.forEach((k,j)=>k.setAttribute("tabindex",j===i?"0":"-1"));this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:i}}))},onKey:(key,i)=>{if(key==="Enter"||key===" ")this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:i}}))},})})}}define("contour-dash-kpi-row",ContourDashKpiRow);class ContourDashFreshness extends ContourBase{static get observed(){return["label","value","format","locale"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},format:{attribute:"format"},locale:{attribute:"locale"}}}render(){this.classList.add("c-dash-freshness");this.setAttribute("role","status");this.setAttribute("aria-live","polite");const label=this.getAttribute("label");const value=this.getAttribute("value");const dot=this.ensure(".c-dot",()=>{const el=document.createElement("span");el.className="c-dot c-dot--live c-dot--accent";el.setAttribute("aria-hidden","true");return el});if(dot.parentNode!==this)this.appendChild(dot);if(!this._freshnessText||!this._freshnessText.parentNode){this._freshnessText=document.createTextNode("");this.appendChild(this._freshnessText)}const formattedValue=value?formatValue(value,this.getAttribute("format"),this.getAttribute("locale")):value;this._freshnessText.nodeValue=[label,formattedValue].filter(Boolean).join(" ")}}define("contour-dash-freshness",ContourDashFreshness);class ContourSavedView extends ContourBase{static get observed(){return["name","updated","source","active"]}static get properties(){return{name:{attribute:"name"},updated:{attribute:"updated"},source:{attribute:"source"},active:{attribute:"active",type:Boolean}}}render(){this.classList.add("c-saved-view");this.setAttribute("role","region");if(this.getAttribute("name"))this.setAttribute("aria-label",this.getAttribute("name"));if(this.hasAttribute("active")){this.classList.add("c-saved-view--active")}else{this.classList.remove("c-saved-view--active")}const thumb=this.ensure(".c-saved-view__thumb",()=>{const el=document.createElement("div");el.className="c-saved-view__thumb";el.setAttribute("aria-hidden","true");return el});if(thumb.parentNode!==this)this.appendChild(thumb);const name=this.ensure(".c-saved-view__name",()=>{const el=document.createElement("div");el.className="c-saved-view__name";return el});name.textContent=this.getAttribute("name")||"Saved view";let meta=this.querySelector(".c-saved-view__meta");if(!meta){meta=document.createElement("div");meta.className="c-saved-view__meta";this.appendChild(meta)}const updated=this.getAttribute("updated");const source=this.getAttribute("source");meta.replaceChildren();if(updated){const wrap=document.createElement("span");wrap.textContent=`Updated ${updated}`;meta.appendChild(wrap)}if(source){if(meta.childNodes.length)meta.appendChild(document.createTextNode(" · "));const wrap=document.createElement("span");wrap.textContent=`${labelText(this, "source", "Source")}: ${source}`;meta.appendChild(wrap)}let actions=this.querySelector(".c-saved-view__actions");if(!actions){actions=document.createElement("div");actions.className="c-saved-view__actions";this.appendChild(actions)}const apply=actions.querySelector(".c-saved-view__apply")||(()=>{const b=document.createElement("button");b.type="button";b.className="c-btn c-btn--ghost c-btn--sm";b.setAttribute("data-saved-view-apply","");actions.appendChild(b);return b})();applyLabel(apply,this,"apply","Apply");const remove=actions.querySelector(".c-saved-view__remove")||(()=>{const b=document.createElement("button");b.type="button";b.className="c-btn c-btn--ghost c-btn--sm";b.setAttribute("data-saved-view-remove","");actions.appendChild(b);return b})();applyLabel(remove,this,"remove","Remove")}enhance(){if(this._wiredSavedView)return;this._wiredSavedView=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest("button"):null;if(!btn||!this.contains(btn))return;if(btn.hasAttribute("data-saved-view-apply")){this.dispatchEvent(new CustomEvent("contour:apply",{bubbles:true,composed:true,detail:{name:this.getAttribute("name")}}))}else if(btn.hasAttribute("data-saved-view-remove")){this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:true,composed:true,detail:{name:this.getAttribute("name")}}))}})}}define("contour-saved-view",ContourSavedView);class ContourProvenance extends ContourBase{static get observed(){return["source","confidence","resolution","coverage","warning","methodology"]}static get properties(){return{source:{attribute:"source"},confidence:{attribute:"confidence"},resolution:{attribute:"resolution"},coverage:{attribute:"coverage"},warning:{attribute:"warning"},methodology:{attribute:"methodology"}}}render(){this.classList.add("c-provenance");this.setAttribute("role","group");this.setAttribute("aria-label",labelText(this,"provenance","Data provenance"));const source=this.getAttribute("source");if(source){const s=this.ensure(".c-provenance__source",()=>{const el=document.createElement("span");el.className="c-provenance__source";return el});const b=document.createElement("b");b.textContent=labelText(this,"source","Source")+":";s.replaceChildren(b,document.createTextNode(" "+source))}else{const s=this.querySelector(".c-provenance__source");if(s)s.remove()}const confidence=this.getAttribute("confidence");if(confidence){const c=this.ensure(".c-provenance__confidence",()=>{const el=document.createElement("span");el.className="c-provenance__confidence";return el});c.className=`c-provenance__confidence c-provenance__confidence--${confidence}`;c.textContent=`Confidence: ${confidence}`}else{const c=this.querySelector(".c-provenance__confidence");if(c)c.remove()}const resolution=this.getAttribute("resolution");if(resolution){const r=this.ensure(".c-provenance__resolution",()=>{const el=document.createElement("span");el.className="c-provenance__resolution";return el});r.textContent=`Resolution: ${resolution}`}else{const r=this.querySelector(".c-provenance__resolution");if(r)r.remove()}const coverage=this.getAttribute("coverage");if(coverage){const c=this.ensure(".c-provenance__coverage",()=>{const el=document.createElement("span");el.className="c-provenance__coverage";return el});c.textContent=`Coverage: ${coverage}`}else{const c=this.querySelector(".c-provenance__coverage");if(c)c.remove()}const methodology=this.getAttribute("methodology");if(methodology){const m=this.ensure(".c-provenance__methodology",()=>{const el=document.createElement("span");el.className="c-provenance__methodology";return el});m.textContent=`Methodology: ${methodology}`}else{const m=this.querySelector(".c-provenance__methodology");if(m)m.remove()}const warning=this.getAttribute("warning");if(warning){const w=this.ensure(".c-provenance__warning",()=>{const el=document.createElement("span");el.className="c-provenance__warning";return el});w.textContent=`Warning: ${warning}`}else{const w=this.querySelector(".c-provenance__warning");if(w)w.remove()}}}define("contour-provenance",ContourProvenance);class ContourFeatureInspector extends ContourBase{static get observed(){return["title","open","data","actions"]}static get properties(){return{title:{attribute:"title"},open:{attribute:"open",type:Boolean},data:{attribute:"data"}}}render(){this.classList.add("c-feature-inspector");if(!this.hasAttribute("role"))this.setAttribute("role","region");if(this.getAttribute("title"))this.setAttribute("aria-label",this.getAttribute("title"));if(this.hasAttribute("open"))this.setAttribute("open","");else this.removeAttribute("open");const head=this.ensure(".c-feature-inspector__head",()=>{const el=document.createElement("div");el.className="c-feature-inspector__head";return el});const title=this.ensure(".c-feature-inspector__title",()=>{const el=document.createElement("span");el.className="c-feature-inspector__title";return el});title.textContent=this.getAttribute("title")||"Feature inspector";const body=this.ensure(".c-feature-inspector__body",()=>{const el=document.createElement("div");el.className="c-feature-inspector__body";return el});const fields=this.querySelectorAll(".c-feature-inspector__field");fields.forEach((f)=>f.remove());const data=this.getAttribute("data");if(data){try{const parsed=JSON.parse(data);for(const[k,v]of Object.entries(parsed)){const field=document.createElement("div");field.className="c-feature-inspector__field";const label=document.createElement("span");label.className="c-feature-inspector__label";label.textContent=k;const value=document.createElement("span");value.className="c-feature-inspector__value";value.textContent=String(v);field.appendChild(label);field.appendChild(value);body.appendChild(field)}}catch(e){warnBadJson(this,"attribute",e)}}const actions=this.ensure(".c-feature-inspector__actions",()=>{const el=document.createElement("div");el.className="c-feature-inspector__actions";return el});Array.from(actions.querySelectorAll("[data-inspect-action]")).forEach((n)=>n.remove());const actionsAttr=this.getAttribute("actions");if(actionsAttr){try{const list=JSON.parse(actionsAttr);if(Array.isArray(list)){list.forEach((it)=>{const btn=document.createElement("button");btn.type="button";btn.className="c-btn c-btn--sm c-feature-inspector__action";btn.setAttribute("data-inspect-action","");btn.textContent=typeof it==="string"?it:(it&&(it.label||it.action))||"";if(it&&typeof it==="object"&&it.value!==undefined)btn.setAttribute("data-action",String(it.value));actions.appendChild(btn)})}}catch(e){warnBadJson(this,"attribute",e)}}}enhance(){if(this._wiredFeatureInspector)return;this._wiredFeatureInspector=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest("button"):null;if(!btn||!this.contains(btn))return;this.dispatchEvent(new CustomEvent("contour:inspect-action",{bubbles:true,composed:true,detail:{label:btn.textContent}}))})}}define("contour-feature-inspector",ContourFeatureInspector);class ContourReadout extends ContourBase{static get observed(){return["rows","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","format","locale"]}static get properties(){return{rows:{attribute:"rows"},format:{attribute:"format"},locale:{attribute:"locale"},src:{attribute:"src"}}}render(){this.classList.add("c-readout");wireStates(this);loadRemote(this,"rows");if(renderStates(this,"readout"))return;const rows=remoteData(this,"rows");Array.from(this.querySelectorAll(".c-readout__row")).forEach((n)=>n.remove());const authored=Array.from(this.children).filter((n)=>!n.classList||!n.classList.contains("c-readout__row"));if(rows&&!authored.length){try{const parsed=JSON.parse(rows);parsed.forEach((r)=>{const row=document.createElement("div");row.className="c-readout__row";const key=document.createElement("span");key.className="c-readout__key";key.textContent=r.key||r[0];const val=document.createElement("span");val.className="c-readout__value"+(r.primary?" c-readout__value--primary":"")+(r.accent?" c-readout__value--accent":"")+(r.coord?" c-readout__value--coord":"");val.setAttribute("aria-live","polite");val.textContent=formatValue(r.value||r[1],this.getAttribute("format"),this.getAttribute("locale"),(r.unit!==undefined?r.unit:this.getAttribute("unit")));row.appendChild(key);row.appendChild(val);if(r.order){const ord=document.createElement("span");ord.className="c-readout__order";ord.textContent=r.order;row.appendChild(ord)}this.appendChild(row)})}catch(e){warnBadJson(this,"attribute",e)}}else if(!rows&&!authored.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"]}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(){this.classList.add("c-kpi");wireStates(this);loadRemote(this,["value","label"]);if(renderStates(this,"kpi"))return;const value=remoteData(this,"value");const label=remoteData(this,"label");const delta=this.getAttribute("delta");const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-kpi--"))this.classList.remove(c)});if(variant)this.classList.add("c-kpi--"+variant);if(value){const v=this.ensure(".c-kpi__value",()=>{const el=document.createElement("div");el.className="c-kpi__value";el.setAttribute("aria-live","polite");return el});v.textContent=formatValue(value,this.getAttribute("format"),this.getAttribute("locale"),this.getAttribute("unit"))}else{const v=this.querySelector(".c-kpi__value");if(v)v.remove()}if(label){const h=this.ensure(".c-kpi__head",()=>{const el=document.createElement("div");el.className="c-kpi__head";return el});let l=h.querySelector(".c-kpi__label");if(!l){l=document.createElement("div");l.className="c-kpi__label";h.appendChild(l)}l.textContent=label;if(h.parentNode!==this)this.insertBefore(h,this.firstChild)}else{const h=this.querySelector(".c-kpi__head");if(h)h.remove()}if(delta){const f=this.ensure(".c-kpi__foot",()=>{const el=document.createElement("div");el.className="c-kpi__foot";return el});const d=f.querySelector(".c-delta")||document.createElement("span");if(!d.parentNode)f.insertBefore(d,f.firstChild);const dir=this.getAttribute("direction")||"up";const polarity=this.getAttribute("polarity")||"neutral";let tone="neutral";if(polarity==="good")tone=(dir==="up")?"good":"bad";else if(polarity==="bad")tone=(dir==="up")?"bad":"good";d.className="c-delta c-delta--"+dir+" c-delta--"+tone;d.textContent=delta}else{const d=this.querySelector(".c-kpi__foot .c-delta");if(d)d.remove()}const note=this.getAttribute("note");if(note){const f=this.ensure(".c-kpi__foot",()=>{const el=document.createElement("div");el.className="c-kpi__foot";return el});const n=f.querySelector(".c-kpi__note")||(()=>{const el=document.createElement("span");el.className="c-kpi__note";f.appendChild(el);return el})();n.textContent=note}else{const n=this.querySelector(".c-kpi__note");if(n)n.remove()}const unit=this.getAttribute("unit");const v=this.querySelector(".c-kpi__value");if(v){if(unit){let u=v.querySelector(".c-kpi__unit");if(!u){u=document.createElement("span");u.className="c-kpi__unit";v.appendChild(u)}u.textContent=unit}else{const u=v.querySelector(".c-kpi__unit");if(u)u.remove()}}const threshold=this.getAttribute("threshold")||this.getAttribute("thresholds");if(threshold){const f=this.ensure(".c-kpi__foot",()=>{const el=document.createElement("div");el.className="c-kpi__foot";return el});let badge=f.querySelector(".c-kpi__threshold-badge");if(!badge){badge=document.createElement("span");badge.className="c-kpi__threshold-badge";f.appendChild(badge)}badge.textContent=threshold;badge.setAttribute("part","threshold-badge")}else{const b=this.querySelector(".c-kpi__threshold-badge");if(b)b.remove()}const foot=this.querySelector(".c-kpi__foot");if(foot&&!foot.querySelector(".c-delta, .c-kpi__note, .c-kpi__threshold-badge"))foot.remove();const spark=this.getAttribute("sparkline");if(spark){let canvas=this.querySelector(".c-kpi__sparkline-canvas");if(!canvas){canvas=document.createElement("canvas");canvas.className="c-kpi__sparkline-canvas";canvas.setAttribute("part","sparkline-canvas");this.appendChild(canvas)}}else{const c=this.querySelector(".c-kpi__sparkline-canvas");if(c)c.remove()}if(!value&&!label){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","empty","loading","error","retry","skeleton","persist"]}static get properties(){return{columns:{attribute:"columns"},rows:{attribute:"rows"},page:{attribute:"page",type:Number},pageSize:{attribute:"page-size",type:Number}}}_cellValue(cell){if(cell===null||cell===undefined)return"";if(typeof cell==="object")return cell.value!==undefined?cell.value:(cell.label!==undefined?cell.label:JSON.stringify(cell));return cell}_compare(a,b,type){const av=this._cellValue(a);const bv=this._cellValue(b);if(type==="number"||type==="numeric"){return(parseFloat(av)||0)-(parseFloat(bv)||0)}return String(av).localeCompare(String(bv),undefined,{numeric:true})}render(){if(!this.hasAttribute("role"))this.setAttribute("role","region");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("title")||"Table");wireStates(this);loadRemote(this,"rows");if(renderStates(this,"table"))return;const columns=this.getAttribute("columns");const rows=remoteData(this,"rows");const authored=Array.from(this.children).filter((n)=>!n.classList||!n.classList.contains("c-table-wrap"));if(columns&&rows&&!authored.length){try{const cols=JSON.parse(columns);const data=JSON.parse(rows);if(this._sortCol===undefined){const sortAttr=this.getAttribute("sort");if(sortAttr!==null){const idx=Number(sortAttr);this._sortCol=Number.isFinite(idx)?idx:cols.findIndex((c)=>(typeof c==="object"&&c&&(c.label||c.title||c)===sortAttr));if(this._sortCol<0)this._sortCol=null}else{this._sortCol=null}const dirAttr=this.getAttribute("sort-dir");this._sortDir=dirAttr==="descending"||dirAttr==="desc"?-1:1}let working=Array.isArray(data)?data.slice():[];if(this._sortCol!==null&&this._sortCol!==undefined&&this._sortCol>=0&&this._sortCol<cols.length){const col=this._sortCol;const dir=this._sortDir||1;const colSpec=cols[col];const type=(typeof colSpec==="object"&&colSpec&&colSpec.sortType)?colSpec.sortType:"text";working.sort((a,b)=>this._compare(a&&a[col],b&&b[col],type)*dir)}if(!this._filters)this._filters={};const activeFilters=Object.keys(this._filters).filter((k)=>this._filters[k]);if(activeFilters.length){working=working.filter((row)=>activeFilters.every((k)=>{const ci=Number(k);const q=String(this._filters[ci]||"").toLowerCase();if(!q)return true;return String(this._cellValue(row[ci])).toLowerCase().includes(q)}))}const pageSizeRaw=this.getAttribute("page-size");const pageSize=pageSizeRaw!==null?parseInt(pageSizeRaw,10):NaN;const usePaging=Number.isFinite(pageSize)&&pageSize>0;let pageAttr=this.getAttribute("page");if(this.getAttribute("persist")&&this.id){const mode=this.getAttribute("persist");let stored=null;if(mode==="storage"){try{stored=localStorage.getItem("contour-table:"+this.id)}catch(e){}}else if(mode==="url"){try{stored=new URLSearchParams(window.location.search).get("c-table")}catch(e){}}if(stored!==null)pageAttr=stored}if(this._pageInternal){this._pageInternal=false;this._pageAttrLast=pageAttr}else if(pageAttr!==this._pageAttrLast){this._page=null;this._pageAttrLast=pageAttr}let page=this._page!==null?this._page:(parseInt(pageAttr||"1",10));if(!Number.isFinite(page)||page<1)page=1;let totalPages=1;let pageData=working;if(usePaging){totalPages=Math.max(1,Math.ceil(working.length/pageSize));if(page>totalPages)page=totalPages;const start=(page-1)*pageSize;pageData=working.slice(start,start+pageSize)}this._page=page;this._totalPages=totalPages;this._pageSize=pageSize;this._rowData=pageData;const wrap=this.ensure(".c-table-wrap",()=>{const el=document.createElement("div");el.className="c-table-wrap";return el});const colsKey=JSON.stringify(cols);const table=(wrap.querySelector("table.c-table")&&this._tableCols===colsKey)?wrap.querySelector("table.c-table"):(()=>{const t=document.createElement("table");t.className="c-table";const captionEl=document.createElement("caption");captionEl.className="visually-hidden";captionEl.textContent=this.getAttribute("title")||this.getAttribute("aria-label")||"Table";t.appendChild(captionEl);const thead=document.createElement("thead");const tr=document.createElement("tr");cols.forEach((c,i)=>{const colLabel=typeof c==="string"?c:(c.label||c.title||c);const th=document.createElement("th");const sortable=(typeof c==="object"&&c!==null&&c.sort);const isSelect=(typeof c==="object"&&c!==null&&c.select);const isFilter=(typeof c==="object"&&c!==null&&c.filter);if(isFilter){th.className=(th.className+" c-table__filter").trim();const inp=document.createElement("input");inp.type="search";inp.className="c-table__filter-input";inp.placeholder=colLabel;inp.setAttribute("aria-label","Filter "+colLabel);inp.dataset.filterIndex=String(i);if(this._filters&&this._filters[i])inp.value=this._filters[i];th.appendChild(inp)}else if(isSelect){th.className=(th.className+" c-table__select").trim();const cb=document.createElement("input");cb.type="checkbox";cb.className="c-table__select-all";cb.setAttribute("aria-label","Select all rows");th.appendChild(cb)}else if(sortable){th.setAttribute("aria-sort",(this._sortCol===i)?(this._sortDir===-1?"descending":"ascending"):"none");const wrapEl=document.createElement("span");wrapEl.className="c-table__sort";wrapEl.textContent=colLabel;const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("aria-hidden","true");svg.innerHTML='<use href="#i-chevron-down" />';wrapEl.appendChild(svg);th.appendChild(wrapEl)}else if(typeof c==="object"&&c!==null&&c.pinned){th.className="c-table__pinned";th.textContent=colLabel}else{th.textContent=colLabel}if(sortable){th.setAttribute("tabindex","0");th.setAttribute("role","columnheader");th.dataset.sortIndex=String(i)}tr.appendChild(th)});thead.appendChild(tr);t.appendChild(thead);t.appendChild(document.createElement("tbody"));return t})();this._tableCols=colsKey;cols.forEach((c,i)=>{if(typeof c==="object"&&c!==null&&c.sort){const th=table.querySelector("thead tr th:nth-child("+(i+1)+")");if(th)th.setAttribute("aria-sort",(this._sortCol===i)?(this._sortDir===-1?"descending":"ascending"):"none")}});const tbody=table.querySelector("tbody");tbody.innerHTML="";const useVirtual=this.hasAttribute("virtual")&&!usePaging&&pageData.length>100;const rowHeight=this._measuredRowHeight||cssLength("--data-grid-row-height",36);const windowSize=30;const overscan=10;let windowStart=0;let visibleData=pageData;if(useVirtual){const maxStart=Math.max(0,pageData.length-windowSize);windowStart=Math.min(maxStart,Math.max(0,Math.floor(wrap.scrollTop/rowHeight)-overscan));visibleData=pageData.slice(windowStart,windowStart+windowSize+overscan*2);table.setAttribute("aria-rowcount",String(pageData.length+1))}else{table.removeAttribute("aria-rowcount")}const addSpacer=(height)=>{const tr=document.createElement("tr");tr.setAttribute("aria-hidden","true");const td=document.createElement("td");td.colSpan=cols.length;td.style.blockSize=`${height}px`;td.style.padding="0";tr.appendChild(td);tbody.appendChild(tr)};if(useVirtual)addSpacer(windowStart*rowHeight);if(visibleData.length===0){const tr=document.createElement("tr");const td=document.createElement("td");td.colSpan=cols.length;td.textContent=this.getAttribute("empty")||"No data";td.style.textAlign="center";td.style.color="var(--color-text-muted)";tr.appendChild(td);tbody.appendChild(tr)}else{visibleData.forEach((row,ri)=>{const tr=document.createElement("tr");tr.dataset.rowIndex=String(windowStart+ri);tr.setAttribute("tabindex","-1");cols.forEach((c,ci)=>{const isSelect=(typeof c==="object"&&c!==null&&c.select);const td=document.createElement("td");if(isSelect){const cb=document.createElement("input");cb.type="checkbox";cb.className="c-table__row-select";cb.dataset.rowIndex=String(windowStart+ri);if(this._selectedRows&&this._selectedRows.has(windowStart+ri))cb.checked=true;td.appendChild(cb)}else{td.textContent=this._cellValue(row[ci])}tr.appendChild(td)});tbody.appendChild(tr)})}if(useVirtual)addSpacer(Math.max(0,pageData.length-windowStart-visibleData.length)*rowHeight);if(!tbody.querySelector('tr[tabindex="0"]')){const first=tbody.querySelector("tr[data-row-index]");if(first)first.setAttribute("tabindex","0")}if(!this._measuredRowHeight&&!this._measuringRow){const firstRow=tbody.querySelector("tr[data-row-index]");const h=firstRow?firstRow.getBoundingClientRect().height:0;if(h>0){this._measuredRowHeight=h;if(Math.abs(h-rowHeight)>1){this._measuringRow=true;requestAnimationFrame(()=>{this._measuringRow=false;this.render()})}}}if(table.parentNode!==wrap){wrap.innerHTML="";wrap.appendChild(table)}if(wrap.parentNode!==this)this.appendChild(wrap);if(this.hasAttribute("virtual")){wrap.style.maxHeight=wrap.style.maxHeight||"24rem";wrap.style.overflow="auto";table.classList.add("c-table--virtual")}else{wrap.style.maxHeight="";wrap.style.overflow="";table.classList.remove("c-table--virtual")}if(usePaging){const footer=this.ensure(".c-table__pagination",()=>{const el=document.createElement("div");el.className="c-table__pagination";return el});footer.innerHTML="";const prev=document.createElement("button");prev.className="c-btn c-btn--ghost c-btn--sm";prev.type="button";prev.textContent=labelText(this,"prev","Previous");prev.disabled=page<=1;prev.dataset.action="prev";const info=document.createElement("span");info.textContent=`${labelText(this, "page", "Page")} ${page} ${labelText(this, "of", "of")} ${totalPages}`;const next=document.createElement("button");next.className="c-btn c-btn--ghost c-btn--sm";next.type="button";next.textContent=labelText(this,"next","Next");next.disabled=page>=totalPages;next.dataset.action="next";footer.appendChild(prev);footer.appendChild(info);footer.appendChild(next)}else{const footer=this.querySelector(".c-table__pagination");if(footer)footer.remove()}}catch(e){warnBadJson(this,"attribute",e)}}else if(!rows&&!authored.length){renderEmpty(this,"table")}}enhance(){if(this._wiredTable)return;this._wiredTable=true;const handleSort=(th)=>{const idx=Number(th.dataset.sortIndex);if(!Number.isFinite(idx))return;if(this._sortCol===idx){this._sortDir=(this._sortDir===1)?-1:1}else{this._sortCol=idx;this._sortDir=1}this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:true,composed:true,detail:{column:idx,direction:this._sortDir===1?"ascending":"descending"}}));this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:true,composed:true,detail:{source:"table",filter:{sort:idx,sortDir:this._sortDir===1?"ascending":"descending"}}}));this.requestRender()};this.addEventListener("click",(e)=>{const retryBtn=e.target&&e.target.closest?e.target.closest('button[data-action="retry"]'):null;if(retryBtn&&this.contains(retryBtn)){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:retry",{detail:{src:this.getAttribute("src")},bubbles:true,composed:true}));return}const th=e.target&&e.target.closest?e.target.closest("th[aria-sort]"):null;if(th&&this.contains(th)){e.preventDefault();handleSort(th);return}const btn=e.target&&e.target.closest?e.target.closest(".c-table__pagination button"):null;if(btn&&this.contains(btn)){e.preventDefault();const action=btn.dataset.action;let page=this._page!==null?this._page:(parseInt(this.getAttribute("page")||"1",10));if(!Number.isFinite(page)||page<1)page=1;if(action==="prev"&&page>1)page-=1;if(action==="next")page+=1;this._page=page;this._pageAttrLast=String(page);this._pageInternal=true;this.setAttribute("page",String(page));this.dispatchEvent(new CustomEvent("contour:page",{bubbles:true,composed:true,detail:{page}}));this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:true,composed:true,detail:{source:"table",filter:{page}}}));const persist=this.getAttribute("persist");if(persist==="storage"&&this.id){try{localStorage.setItem("contour-table:"+this.id,String(page))}catch(e){}}else if(persist==="url"){try{const url=new URL(window.location.href);url.searchParams.set("c-table",String(page));window.history.replaceState(null,"",url.toString())}catch(e){}}}});this.addEventListener("keydown",(e)=>{if(e.key!=="Enter"&&e.key!==" ")return;const th=e.target&&e.target.closest?e.target.closest("th[aria-sort]"):null;if(th&&this.contains(th)){e.preventDefault();handleSort(th)}});this.addEventListener("input",(e)=>{const inp=e.target&&e.target.closest?e.target.closest(".c-table__filter-input"):null;if(!inp||!this.contains(inp))return;const idx=Number(inp.dataset.filterIndex);if(!Number.isFinite(idx))return;if(!this._filters)this._filters={};this._filters[idx]=inp.value;this.requestRender();this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:true,composed:true,detail:{source:"table",filter:{column:idx,value:inp.value}}}))});this.addEventListener("scroll",(e)=>{if(!this.hasAttribute("virtual")||!e.target||!e.target.classList||!e.target.classList.contains("c-table-wrap"))return;if(this._tableVirtualRaf)return;const run=()=>{this._tableVirtualRaf=0;this.requestRender()};this._tableVirtualRaf=typeof requestAnimationFrame==="function"?requestAnimationFrame(run):setTimeout(run,16)},true);this._selectedRows=this._selectedRows||new Set();this.addEventListener("change",(e)=>{const cb=e.target&&e.target.closest?e.target.closest(".c-table__row-select"):null;if(cb&&this.contains(cb)){const idx=Number(cb.dataset.rowIndex);if(!Number.isFinite(idx))return;if(cb.checked)this._selectedRows.add(idx);else this._selectedRows.delete(idx);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{rows:Array.from(this._selectedRows)}}));this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:true,composed:true,detail:{source:"table",filter:{selectedRows:Array.from(this._selectedRows)}}}));return}const all=e.target&&e.target.closest?e.target.closest(".c-table__select-all"):null;if(all&&this.contains(all)){const cbs=Array.from(this.querySelectorAll(".c-table__row-select"));cbs.forEach((c)=>{c.checked=all.checked});this._selectedRows=new Set(all.checked?cbs.map((c)=>Number(c.dataset.rowIndex)):[]);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{rows:Array.from(this._selectedRows)}}));this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:true,composed:true,detail:{source:"table",filter:{selectedRows:Array.from(this._selectedRows)}}}))}});this.addEventListener("mouseover",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tbody tr"):null;if(!tr||!this.contains(tr))return;const idx=Number(tr.dataset.rowIndex);if(!Number.isFinite(idx))return;if(this._hoveredRow===idx)return;this._hoveredRow=idx;this.dispatchEvent(new CustomEvent("contour:hover",{bubbles:true,composed:true,detail:{row:idx}}))});this.addEventListener("mouseout",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tbody tr"):null;if(!tr||!this.contains(tr))return;const related=e.relatedTarget&&e.relatedTarget.closest?e.relatedTarget.closest("tbody tr"):null;if(related===tr)return;this._hoveredRow=null;this.dispatchEvent(new CustomEvent("contour:leave",{bubbles:true,composed:true,detail:{}}))});this.addEventListener("click",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tbody tr"):null;if(!tr||!this.contains(tr))return;const idx=Number(tr.dataset.rowIndex);if(!Number.isFinite(idx))return;const rowData=(this._rowData&&this._rowData[idx])||null;this.dispatchEvent(new CustomEvent("contour:zoom",{bubbles:true,composed:true,detail:{row:idx,index:idx,data:rowData}}))});this.addEventListener("keydown",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tbody tr"):null;if(!tr||!this.contains(tr))return;const idx=Number(tr.dataset.rowIndex);if(!Number.isFinite(idx))return;if(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="Home"||e.key==="End"){const rows=Array.from(this.querySelectorAll("tbody tr[data-row-index]"));const at=rows.indexOf(tr);let next=at;if(e.key==="ArrowDown")next=Math.min(rows.length-1,at+1);else if(e.key==="ArrowUp")next=Math.max(0,at-1);else if(e.key==="Home")next=0;else if(e.key==="End")next=rows.length-1;if(next!==at&&rows[next]){e.preventDefault();rows.forEach((r)=>r.setAttribute("tabindex","-1"));rows[next].setAttribute("tabindex","0");try{rows[next].focus()}catch(err){}}return}if(e.key!=="Enter"&&e.key!==" ")return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true,detail:{row:idx}}))});this.addEventListener("contour:clear-all",()=>{let changed=false;if(this.hasAttribute("sort")){this.removeAttribute("sort");changed=true}if(this.hasAttribute("sort-dir")){this.removeAttribute("sort-dir");changed=true}if(this.hasAttribute("page")){this.removeAttribute("page");changed=true}if(this._filters&&Object.keys(this._filters).length){this._filters={};changed=true}if(changed){this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:true,composed:true,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");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Data table")}}define("contour-data-table",ContourDataTable);const normalizeChartBin=(bin)=>{if(!bin||typeof bin!=="object")return null;const x0=Number(bin.x0);const x1=Number(bin.x1);const count=Number(bin.count);if(!Number.isFinite(x0)||!Number.isFinite(x1)||!Number.isFinite(count))return null;const out={x0,x1,count};const normalized=Number(bin.normalized);if(Number.isFinite(normalized))out.normalized=normalized;return out};class ContourChart extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["series","axis","color","empty","loading","error","retry","skeleton","zoomable","data-table","brush","brush-min","brush-max","brush-start","brush-end","note","bucket-count","limit-values"]}static get properties(){return{series:{attribute:"series"},axis:{attribute:"axis"},color:{attribute:"color"},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 pushed=this._pushedBins;return(pushed&&pushed.length?pushed:this._renderedBins||[]).map((b)=>({...b}))}set bins(value){this._pushedBins=Array.isArray(value)?value.map(normalizeChartBin).filter(Boolean):[];this.requestRender()}get backgroundData(){const pushed=this._pushedBackground;return(pushed&&pushed.length?pushed:this._renderedBackground||[]).map((b)=>({...b}))}set backgroundData(value){this._pushedBackground=Array.isArray(value)?value.map(normalizeChartBin).filter(Boolean):[];this.requestRender()}_showsBrush(){return this.hasAttribute("brush")||this._rangeOverride!==undefined}get range(){const override=this._rangeOverride;if(override!==undefined)return override?override.slice():null;if(!this.hasAttribute("brush"))return null;const start=parseFloat(this.getAttribute("brush-start"));const end=parseFloat(this.getAttribute("brush-end"));return Number.isFinite(start)&&Number.isFinite(end)?[start,end]:null}set range(value){if(value==null){this._rangeOverride=null;this.requestRender();return}const pair=Array.isArray(value)?value:[value,value];const start=Number(pair[0]);const end=Number(pair[1]);if(!Number.isFinite(start)||!Number.isFinite(end))return;this._rangeOverride=[start,end];this.requestRender()}_axisLabel(){const raw=this.getAttribute("axis");if(!raw)return"";try{const parsed=JSON.parse(raw);if(parsed&&typeof parsed==="object")return parsed.label||parsed.title||parsed.name||"";return String(parsed)}catch(e){return raw}}_axisConfig(){const raw=this.getAttribute("axis");if(!raw)return null;try{const parsed=JSON.parse(raw);return(parsed&&typeof parsed==="object")?parsed:null}catch(e){return null}}_valueDomain(){const series=this.getAttribute("series");if(!series)return null;try{const parsed=JSON.parse(series);let min=Infinity,max=-Infinity;(Array.isArray(parsed)?parsed:[]).forEach((s)=>{if(s&&Array.isArray(s.values))s.values.forEach((v)=>{const n=Number(v);if(Number.isFinite(n)){if(n<min)min=n;if(n>max)max=n}})});return Number.isFinite(min)&&Number.isFinite(max)?[min,max]:null}catch(e){return null}}_renderValueAxis(){const ax=this.querySelector(".c-chart__axis");if(!ax)return;const cfg=this._axisConfig();const y=cfg&&cfg.y;const domain=(y&&y.domain)||this._valueDomain();if(!domain){ax.textContent=this._axisLabel();return}const chart=(typeof window!=="undefined"&&window.Contour&&window.Contour.chart)||null;const ticks=(y&&y.ticks)||(chart&&chart.ticks?chart.ticks(domain[0],domain[1],5):[domain[0],domain[1]]);const format=(y&&y.format)||((v)=>String(v));ax.textContent="";ticks.forEach((t)=>{const span=document.createElement("span");span.className="c-chart__tick";span.textContent=typeof format==="function"?format(t):String(t);ax.appendChild(span)});this.style.setProperty("--chart-ticks",String(ticks.length))}_renderLegend(){const series=this.getAttribute("series");if(!series)return;try{const parsed=JSON.parse(series);const labelled=(Array.isArray(parsed)?parsed:[]).filter((s)=>s&&s.label);let legend=this.querySelector(".c-chart__legend");if(!labelled.length){if(legend)legend.remove();return}if(!legend){legend=document.createElement("div");legend.className="c-chart__legend";this.appendChild(legend)}legend.textContent="";labelled.forEach((s,i)=>{const item=document.createElement("span");item.className="c-chart__legend-item";const swatch=document.createElement("span");swatch.className="c-chart__legend-swatch";swatch.style.setProperty("--c",this.getAttribute("color")||`var(--chart-${i + 1})`);item.appendChild(swatch);item.appendChild(document.createTextNode(s.label));legend.appendChild(item)})}catch(e){}}render(){this.classList.add("c-chart");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-roledescription"))this.setAttribute("aria-roledescription","chart");if(this.getAttribute("axis")&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this._axisLabel());if(this.hasAttribute("loading")){const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const loading=document.createElement("div");loading.className="c-chart__loading";loading.textContent=this.getAttribute("loading")||"Loading…";loading.style.display="grid";loading.style.placeItems="center";loading.style.height="100%";loading.style.color="var(--color-text-muted)";plot.appendChild(loading);const axis=this.getAttribute("axis");if(axis){const ax=this.ensure(".c-chart__axis",()=>{const el=document.createElement("div");el.className="c-chart__axis";return el});ax.textContent=this._axisLabel()}return}if(this.hasAttribute("error")){const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const err=document.createElement("div");err.className="c-chart__error";err.textContent=this.getAttribute("error")||"Error";err.style.display="grid";err.style.placeItems="center";err.style.height="100%";err.style.color="var(--color-danger, var(--color-text))";if(this.hasAttribute("retry")){const btn=document.createElement("button");btn.className="c-btn c-btn--ghost c-btn--sm";btn.type="button";btn.textContent=this.getAttribute("retry")||"Retry";btn.dataset.action="retry";btn.classList.add("u-mbs-sm");err.appendChild(btn)}plot.appendChild(err);const axis=this.getAttribute("axis");if(axis){const ax=this.ensure(".c-chart__axis",()=>{const el=document.createElement("div");el.className="c-chart__axis";return el});ax.textContent=this._axisLabel()}return}if(this.hasAttribute("skeleton")){const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const count=Math.min(5,Math.max(1,parseInt(this.getAttribute("skeleton")||"3",10)||3));for(let i=0;i<count;i++){const sk=document.createElement("div");sk.className="c-skeleton";sk.style.display="block";sk.style.inlineSize="100%";sk.style.blockSize="0.6rem";sk.classList.add("u-mbe-2xs");plot.appendChild(sk)}const axis=this.getAttribute("axis");if(axis){const ax=this.ensure(".c-chart__axis",()=>{const el=document.createElement("div");el.className="c-chart__axis";return el});ax.textContent=this._axisLabel()}return}const axis=this.getAttribute("axis");if(axis){const ax=this.ensure(".c-chart__axis",()=>{const el=document.createElement("div");el.className="c-chart__axis";return el});ax.textContent=this._axisLabel()}else{const ax=this.querySelector(".c-chart__axis");if(ax)ax.remove()}this._renderValueAxis();this._renderLegend();let series=this.getAttribute("series");if(!series&&this._pushedBins&&this._pushedBins.length){series=JSON.stringify([{type:"histogram",bins:this._pushedBins}])}if(series){let parsed=null;try{parsed=JSON.parse(series);const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const hasStructured=parsed.some((s)=>s&&(Array.isArray(s.values)||Array.isArray(s.bins)));if(hasStructured){this._renderedBins=[];this._renderedBackground=[];parsed.forEach((s,i)=>{const layerColor=this.getAttribute("color");const color=layerColor||`var(--chart-${i + 1})`;if(s.type==="donut"){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 200 200");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";svg.setAttribute("aria-hidden","true");donutSlices(s.values).forEach((sl,si)=>{const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-chart__line");path.setAttribute("data-series",String(i+1));path.style.setProperty("--c",color);path.setAttribute("d",sl.path);path.setAttribute("title",String(s.values[si]));path.setAttribute("aria-label","Series "+(i+1)+": "+String(s.values[si]));path.setAttribute("role","img");svg.appendChild(path)});plot.appendChild(svg)}else if(s.type==="bar"){const vals=Array.isArray(s.values)?s.values:[];const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";barRects(vals).forEach((r,ri)=>{const rect=document.createElementNS("http://www.w3.org/2000/svg","rect");rect.setAttribute("class","c-chart__bar");rect.setAttribute("data-series",String(i+1));rect.style.setProperty("--c",color);rect.setAttribute("x",r.x);rect.setAttribute("y",r.y);rect.setAttribute("width",r.width);rect.setAttribute("height",r.height);rect.setAttribute("title",String(vals[ri]));rect.setAttribute("aria-label","Series "+(i+1)+": "+String(vals[ri]));rect.setAttribute("tabindex","0");rect.setAttribute("role","button");rect.dataset.index=String(ri);svg.appendChild(rect)});plot.appendChild(svg)}else if(s.type==="histogram"){let vals=Array.isArray(s.values)?s.values.slice():[];const limitValues=parseInt(this.getAttribute("limit-values")||"0",10);if(limitValues>0)vals=vals.slice(0,limitValues);const bucketCount=parseInt(this.getAttribute("bucket-count")||"0",10);const pushedBins=this._pushedBins&&this._pushedBins.length?this._pushedBins:null;const declaredBins=Array.isArray(s.bins)?s.bins.map(normalizeChartBin).filter(Boolean):null;let bins=pushedBins||(declaredBins&&declaredBins.length?declaredBins:null);let plotVals=vals;if(!bins&&bucketCount>0&&vals.length){const nums=vals.map((v)=>Number(v)||0);const min=Math.min.apply(null,nums);const max=Math.max.apply(null,nums);const range=max-min||1;const width=range/bucketCount;const buckets=new Array(bucketCount).fill(0);nums.forEach((v)=>{const bi=Math.min(bucketCount-1,Math.floor((v-min)/width));buckets[bi]+=1});plotVals=buckets;bins=buckets.map((count,bi)=>({x0:min+bi*width,x1:min+(bi+1)*width,count}))}if(bins)plotVals=bins.map((b)=>b.count);this._renderedBins=bins?bins.slice():[];const pushedBackground=this._pushedBackground&&this._pushedBackground.length?this._pushedBackground:null;const declaredBackground=Array.isArray(s.background)?s.background.map(normalizeChartBin).filter(Boolean):null;const background=pushedBackground||(declaredBackground&&declaredBackground.length?declaredBackground:[]);this._renderedBackground=background.slice();const backgroundVals=background.map((b)=>Number(b.count)||0);let sharedMax=1;if(backgroundVals.length){plotVals.concat(backgroundVals).forEach((v)=>{const n=Number(v)||0;if(n>sharedMax)sharedMax=n})}const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";if(backgroundVals.length){barRects(backgroundVals,{max:sharedMax}).forEach((r)=>{const rect=document.createElementNS("http://www.w3.org/2000/svg","rect");rect.setAttribute("class","c-chart__bar");rect.setAttribute("data-context","");rect.setAttribute("aria-hidden","true");rect.style.setProperty("--c",color);rect.setAttribute("x",r.x);rect.setAttribute("y",r.y);rect.setAttribute("width",r.width);rect.setAttribute("height",r.height);svg.appendChild(rect)})}barRects(plotVals,backgroundVals.length?{max:sharedMax}:undefined).forEach((r,ri)=>{const rect=document.createElementNS("http://www.w3.org/2000/svg","rect");rect.setAttribute("class","c-chart__bar");rect.setAttribute("data-series",String(i+1));rect.style.setProperty("--c",color);rect.setAttribute("x",r.x);rect.setAttribute("y",r.y);rect.setAttribute("width",r.width);rect.setAttribute("height",r.height);const markValue=bins?bins[ri].count:(Array.isArray(s.values)?s.values[ri]:ri);rect.setAttribute("title",String(markValue));rect.setAttribute("aria-label","Series "+(i+1)+": "+String(markValue));rect.setAttribute("tabindex","0");rect.setAttribute("role","button");rect.dataset.index=String(ri);svg.appendChild(rect)});plot.appendChild(svg)}else if(s.type==="scatter"){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const pts=(Array.isArray(s.values)?s.values:[]).map((v)=>{if(Array.isArray(v))return{x:Number(v[0])||0,y:Number(v[1])||0};return{x:Number(v&&v.x)||0,y:Number(v&&v.y)||0}});const xs=pts.map((p)=>p.x);const ys=pts.map((p)=>p.y);const minX=xs.length?Math.min.apply(null,xs):0;const maxX=xs.length?Math.max.apply(null,xs):1;const minY=ys.length?Math.min.apply(null,ys):0;const maxY=ys.length?Math.max.apply(null,ys):1;const xRange=(maxX-minX)||1;const yRange=(maxY-minY)||1;pts.forEach((p,pi)=>{const circle=document.createElementNS("http://www.w3.org/2000/svg","circle");circle.setAttribute("class","c-chart__point");circle.setAttribute("data-series",String(i+1));circle.setAttribute("data-index",String(pi));circle.style.setProperty("--c",color);const cx=((p.x-minX)/xRange)*300;const cy=120-((p.y-minY)/yRange)*120;circle.setAttribute("cx",cx.toFixed(2));circle.setAttribute("cy",cy.toFixed(2));circle.setAttribute("r","3");circle.setAttribute("tabindex",pi===0?"0":"-1");circle.setAttribute("role","button");circle.setAttribute("title",p.x+", "+p.y);circle.setAttribute("aria-label","Series "+(i+1)+": "+p.x+", "+p.y);svg.appendChild(circle)});plot.appendChild(svg)}else{const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-chart__line");path.setAttribute("data-series",String(i+1));path.style.setProperty("--c",color);path.setAttribute("d",smoothPath(s.values));svg.appendChild(path);const pts=polylinePoints(s.values).split(" ").map((p)=>p.split(",").map(Number));pts.forEach((pt,pi)=>{const circle=document.createElementNS("http://www.w3.org/2000/svg","circle");circle.setAttribute("class","c-chart__point");circle.setAttribute("data-series",String(i+1));circle.setAttribute("data-index",String(pi));circle.style.setProperty("--c",color);circle.setAttribute("cx",String(pt[0]));circle.setAttribute("cy",String(pt[1]));circle.setAttribute("r","3");circle.setAttribute("tabindex",pi===0?"0":"-1");circle.setAttribute("role","button");circle.setAttribute("title",String(s.values[pi]));circle.setAttribute("aria-label","Series "+(i+1)+": "+String(s.values[pi]));svg.appendChild(circle)});plot.appendChild(svg)}})}else{const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";svg.setAttribute("aria-hidden","true");parsed.forEach((s,i)=>{const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-chart__line");path.setAttribute("data-series",String(i+1));path.style.setProperty("--c",`var(--chart-${i + 1})`);path.setAttribute("d",s.d||s);svg.appendChild(path)});plot.appendChild(svg)}}catch(e){warnBadJson(this,"attribute",e)}const tip=this.ensure(".c-chart__tooltip",()=>{const el=document.createElement("div");el.className="c-chart__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","");if(this.hasAttribute("data-table")){let table=this.querySelector(".c-chart__data-table");if(!table){table=document.createElement("table");table.className="c-chart__data-table visually-hidden";this.appendChild(table)}table.innerHTML="";const title=this.getAttribute("title")||this.getAttribute("aria-label")||labelText(this,"chart-data","Chart data");const cap=document.createElement("caption");cap.textContent=title;table.appendChild(cap);const thead=document.createElement("thead");const hr=document.createElement("tr");const h=document.createElement("th");h.setAttribute("scope","col");h.textContent=labelText(this,"series","Series");hr.appendChild(h);const maxLen=parsed.reduce((m,s)=>Math.max(m,Array.isArray(s.values)?s.values.length:(Array.isArray(s)?s.length:0)),0);for(let i=0;i<maxLen;i++){const th=document.createElement("th");th.setAttribute("scope","col");th.textContent=labelText(this,"value","Value")+" "+(i+1);hr.appendChild(th)}thead.appendChild(hr);table.appendChild(thead);const tbody=document.createElement("tbody");parsed.forEach((s,si)=>{const vals=Array.isArray(s.values)?s.values:(Array.isArray(s)?s:[]);const tr=document.createElement("tr");const td0=document.createElement("th");td0.setAttribute("scope","row");td0.textContent=s.label||("Series "+(si+1));tr.appendChild(td0);for(let i=0;i<maxLen;i++){const td=document.createElement("td");td.textContent=vals[i]!=null?String(vals[i]):"";tr.appendChild(td)}tbody.appendChild(tr)});table.appendChild(tbody)}else{const old=this.querySelector(".c-chart__data-table");if(old)old.remove()}if(this._showsBrush()){const brush=this.ensure("contour-brush",()=>document.createElement("contour-brush"));const drawnBins=this._renderedBins||[];const trackMin=this.getAttribute("brush-min")||(drawnBins.length?String(drawnBins[0].x0):"0");const trackMax=this.getAttribute("brush-max")||(drawnBins.length?String(drawnBins[drawnBins.length-1].x1):"100");const override=Array.isArray(this._rangeOverride)?this._rangeOverride:null;const cleared=this._rangeOverride===null;brush.setAttribute("min",trackMin);brush.setAttribute("max",trackMax);brush.setAttribute("start",override?String(override[0]):cleared?trackMin:(this.getAttribute("brush-start")||trackMin));brush.setAttribute("end",override?String(override[1]):cleared?trackMax:(this.getAttribute("brush-end")||trackMax));const plotEl=this.querySelector(".c-chart__plot");if(brush.previousElementSibling!==plotEl)this.insertBefore(brush,plotEl?plotEl.nextSibling:null)}else{const brush=this.querySelector("contour-brush");if(brush)brush.remove()}const note=this.getAttribute("note");let noteEl=this.querySelector(".c-chart__note");if(note){if(!noteEl){noteEl=document.createElement("div");noteEl.className="c-chart__note";this.appendChild(noteEl)}noteEl.textContent=note}else if(noteEl){noteEl.remove()}}else{this._renderedBins=[];this._renderedBackground=[];const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const empty=document.createElement("div");empty.className="c-chart__empty";empty.textContent=this.getAttribute("empty")||"No data";empty.style.display="grid";empty.style.placeItems="center";empty.style.height="100%";empty.style.color="var(--color-text-muted)";plot.appendChild(empty);const note=this.getAttribute("note");let noteEl2=this.querySelector(".c-chart__note");if(note){if(!noteEl2){noteEl2=document.createElement("div");noteEl2.className="c-chart__note";this.appendChild(noteEl2)}noteEl2.textContent=note}else if(noteEl2){noteEl2.remove()}}}enhance(){if(this._wiredChart)return;this._wiredChart=true;const legendHost=this.parentElement||document;const onLegendToggle=(e)=>{const key=e&&e.detail&&(e.detail.key!=null?e.detail.key:e.detail.label);const index=e&&e.detail&&e.detail.index;const pressed=e&&e.detail&&e.detail.pressed;if(key==null&&index==null)return;const nodes=this.querySelectorAll("[data-series]");nodes.forEach((n)=>{const s=n.getAttribute("data-series");const match=String(s)===String(key)||n.getAttribute("data-key")===String(key)||(index!=null&&String(s)===String(index+1));if(match)n.style.display=pressed===false?"none":""})};legendHost.addEventListener("contour:legend-toggle",onLegendToggle);onDispose(this,()=>legendHost.removeEventListener("contour:legend-toggle",onLegendToggle));this.addEventListener("contour:brush-end",(e)=>{if(!this._showsBrush()||!e.target||!e.target.matches("contour-brush"))return;if(this._rangeOverride!==undefined&&e.detail&&Array.isArray(e.detail.range)){this._rangeOverride=e.detail.range.slice()}this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:e.detail,}))});if(this.hasAttribute("zoomable")){let zoom=1,panX=0,panY=0;const plot=this.querySelector(".c-chart__plot");const apply=()=>{if(!plot)return;plot.style.transform=`translate(${panX}px, ${panY}px) scale(${zoom})`;plot.style.transformOrigin="center center"};this.addEventListener("wheel",(e)=>{e.preventDefault();const factor=e.deltaY<0?1.1:0.9;zoom=Math.min(5,Math.max(0.5,zoom*factor));apply()},{passive:false});let dragging=false,startX=0,startY=0,startPanX=0,startPanY=0;this.addEventListener("mousedown",(e)=>{if(e.button!==0)return;dragging=true;startX=e.clientX;startY=e.clientY;startPanX=panX;startPanY=panY;this.style.cursor="grabbing"});const onMove=(e)=>{if(!dragging)return;panX=startPanX+(e.clientX-startX);panY=startPanY+(e.clientY-startY);apply()};const onUp=()=>{if(dragging){dragging=false;this.style.cursor=""}};window.addEventListener("mousemove",onMove);window.addEventListener("mouseup",onUp);onDispose(this,()=>{window.removeEventListener("mousemove",onMove);window.removeEventListener("mouseup",onUp)});this.addEventListener("dblclick",()=>{zoom=1;panX=0;panY=0;apply()})}let plotRectCache=null;let plotRectObserver=null;const invalidatePlotRect=()=>{plotRectCache=null};const showTip=(e)=>{const plot=this.querySelector(".c-chart__plot");const tip=this.querySelector(".c-chart__tooltip");if(!plot||!tip)return;const mark=e.target&&e.target.closest?e.target.closest(".c-chart__bar, .c-chart__point, .c-chart__line"):null;if(!mark||!plot.contains(mark)){tip.setAttribute("hidden","");return}const title=mark.getAttribute("title");if(title)tip.textContent=title;if(!plotRectCache){plotRectCache=plot.getBoundingClientRect();if(!plotRectObserver&&typeof ResizeObserver==="function"){plotRectObserver=new ResizeObserver(invalidatePlotRect);plotRectObserver.observe(plot)}}const rect=plotRectCache;const mr=mark.getBoundingClientRect();const x=mr.left-rect.left+mr.width/2;const y=mr.top-rect.top;plot.style.setProperty("--chart-tip-inline-start",x+"px");plot.style.setProperty("--chart-tip-block-start",y+"px");tip.removeAttribute("hidden")};const hideTip=()=>{const tip=this.querySelector(".c-chart__tooltip");if(tip)tip.setAttribute("hidden","")};this.addEventListener("mousemove",showTip);this.addEventListener("mouseleave",hideTip);onDispose(this,()=>{if(plotRectObserver){plotRectObserver.disconnect();plotRectObserver=null}});this.addEventListener("focusin",(e)=>{const mark=e.target&&e.target.closest?e.target.closest(".c-chart__bar, .c-chart__point, .c-chart__line"):null;if(mark&&this.contains(mark))showTip({target:mark})});this.addEventListener("focusout",(e)=>{if(!this.contains(e.relatedTarget))hideTip()});this.addEventListener("click",(e)=>{const plot2=this.querySelector(".c-chart__plot");if(!plot2)return;const bar=e.target&&e.target.closest?e.target.closest(".c-chart__bar"):null;if(bar&&plot2.contains(bar)){const series=parseInt(bar.getAttribute("data-series")||"1",10);const index=parseInt(bar.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series,index}}));return}const point=e.target&&e.target.closest?e.target.closest(".c-chart__point"):null;if(point&&plot2.contains(point)){const series=parseInt(point.getAttribute("data-series")||"1",10);const index=parseInt(point.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series,index}}))}});this.addEventListener("keydown",(e)=>{const plot2=this.querySelector(".c-chart__plot");if(!plot2)return;const bar=e.target&&e.target.closest?e.target.closest(".c-chart__bar"):null;if(bar&&plot2.contains(bar)){if(e.key==="Enter"||e.key===" "){e.preventDefault();const series=parseInt(bar.getAttribute("data-series")||"1",10);const index=parseInt(bar.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series,index}}))}return}const point=e.target&&e.target.closest?e.target.closest(".c-chart__point"):null;if(!point||!plot2.contains(point))return;const series=parseInt(point.getAttribute("data-series")||"1",10);const points=Array.from(plot2.querySelectorAll('.c-chart__point[data-series="'+series+'"]'));const idx=points.indexOf(point);if(e.key==="Enter"||e.key===" "){e.preventDefault();const index=parseInt(point.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series,index}}));return}navKey(e,points,{wrap:false,rtl:isRtl(this),onNavigate:(i)=>points.forEach((p,j)=>p.setAttribute("tabindex",j===i?"0":"-1")),onKey:()=>{}})});this.addEventListener("keydown",(e)=>{if(e.target!==this)return;let seriesCount=0;try{seriesCount=JSON.parse(this.getAttribute("series")||"[]").length}catch(e){seriesCount=0}if(seriesCount===0)return;if(this._activeSeries===undefined)this._activeSeries=0;let next=this._activeSeries;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";if(e.key==="ArrowRight")next=rtl?Math.max(this._activeSeries-1,0):Math.min(this._activeSeries+1,seriesCount-1);else if(e.key==="ArrowLeft")next=rtl?Math.min(this._activeSeries+1,seriesCount-1):Math.max(this._activeSeries-1,0);else if(e.key==="ArrowDown")next=Math.min(this._activeSeries+1,seriesCount-1);else if(e.key==="ArrowUp")next=Math.max(this._activeSeries-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=seriesCount-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:this._activeSeries}}));return}else return;if(next!==this._activeSeries){e.preventDefault();this._activeSeries=next;this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:next}}))}});this.addEventListener("contour:clear-all",()=>{if(this.hasAttribute("brush")){this.removeAttribute("brush");this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:true,composed:true,detail:{source:"chart",filter:{brush:null}}}));this.requestRender()}})}}define("contour-chart",ContourChart);class ContourComparison extends ContourBase{static get observed(){return["divider","value","before","after"]}static get properties(){return{divider:{attribute:"divider"},value:{attribute:"value"},before:{attribute:"before"},after:{attribute:"after"}}}render(){this.classList.add("c-comparison");this.setAttribute("role","group");this.setAttribute("aria-label","Comparison");if(!this.style.blockSize)this.style.blockSize="12rem";this.style.setProperty("--comparison-pos",(this.getAttribute("value")||"50")+"%");const beforeLabel=this.getAttribute("before")||"Before";const afterLabel=this.getAttribute("after")||"After";if(!this.querySelector(".c-comparison__pane--before")){const p=document.createElement("div");p.className="c-comparison__pane c-comparison__pane--before";p.textContent=beforeLabel;this.appendChild(p)}else{const p=this.querySelector(".c-comparison__pane--before");if(p)p.textContent=beforeLabel}if(!this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)")){const p=document.createElement("div");p.className="c-comparison__pane";p.textContent=afterLabel;this.appendChild(p)}else{const p=this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)");if(p)p.textContent=afterLabel}const beforePane=this.querySelector(".c-comparison__pane--before");if(beforePane){let lbl=beforePane.querySelector(".c-comparison__label--before");if(!lbl){lbl=document.createElement("span");lbl.className="c-comparison__label c-comparison__label--before";beforePane.appendChild(lbl)}lbl.textContent=beforeLabel}const afterPane=this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)");if(afterPane){let lbl=afterPane.querySelector(".c-comparison__label--after");if(!lbl){lbl=document.createElement("span");lbl.className="c-comparison__label c-comparison__label--after";afterPane.appendChild(lbl)}lbl.textContent=afterLabel}const divider=this.getAttribute("divider");if(divider!==null){const d=this.ensure(".c-comparison__divider",()=>{const el=document.createElement("div");el.className="c-comparison__divider";el.setAttribute("role","slider");el.setAttribute("aria-orientation","vertical");el.setAttribute("aria-valuemin","0");el.setAttribute("aria-valuemax","100");el.setAttribute("aria-valuenow","50");el.setAttribute("aria-label","Comparison divider");el.setAttribute("tabindex","0");return el});if(divider)d.textContent=divider}else{const d=this.querySelector(".c-comparison__divider");if(d)d.remove()}}enhance(){if(this._wiredComparison)return;this._wiredComparison=true;const divider=()=>this.querySelector(".c-comparison__divider");const setPos=(pct)=>{const clamped=Math.max(0,Math.min(100,pct));this.style.setProperty("--comparison-pos",clamped+"%");this.setAttribute("value",String(Math.round(clamped)));const divider=this.querySelector(".c-comparison__divider");if(divider)divider.setAttribute("aria-valuenow",String(Math.round(clamped)));this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:true,composed:true,detail:{value:clamped}}))};let dragging=false;const onMove=(e)=>{if(!dragging)return;const rect=this.getBoundingClientRect();const pct=((e.clientX-rect.left)/rect.width)*100;setPos(pct)};const onUp=()=>{dragging=false;window.removeEventListener("mousemove",onMove);window.removeEventListener("mouseup",onUp)};onDispose(this,()=>{dragging=false;window.removeEventListener("mousemove",onMove);window.removeEventListener("mouseup",onUp)});this.addEventListener("mousedown",(e)=>{const d=divider();if(!d||!d.contains(e.target))return;dragging=true;window.addEventListener("mousemove",onMove);window.addEventListener("mouseup",onUp);e.preventDefault()});this.addEventListener("keydown",(e)=>{const d=divider();if(!d||document.activeElement!==d)return;const cur=parseFloat(this.style.getPropertyValue("--comparison-pos"))||50;if(e.key==="ArrowLeft"){e.preventDefault();setPos(cur-5)}else if(e.key==="ArrowRight"){e.preventDefault();setPos(cur+5)}})}}define("contour-comparison",ContourComparison);class ContourStreamingChart extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["line","dot","interval","pause","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{line:{attribute:"line"},dot:{attribute:"dot"},interval:{attribute:"interval",type:Number},pause:{attribute:"pause",type:Boolean},src:{attribute:"src"}}}render(){this.classList.add("c-streaming-chart");if(!this.hasAttribute("role"))this.setAttribute("role","img");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Streaming chart");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");wireStates(this);loadRemote(this,"line");if(renderStates(this,"streaming-chart"))return;const line=remoteData(this,"line");const dot=remoteData(this,"dot");if(!line){const svg=this.querySelector("svg");if(svg)svg.remove();renderEmpty(this,"streaming-chart");return}if(line){let svg=this.querySelector("svg");if(!svg){svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 192");svg.setAttribute("aria-hidden","true");this.appendChild(svg)}let path=svg.querySelector(".c-streaming-chart__line");if(!path){path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-streaming-chart__line");svg.appendChild(path)}path.setAttribute("d",line);if(dot){let circle=svg.querySelector(".c-streaming-chart__live-dot");if(!circle){circle=document.createElementNS("http://www.w3.org/2000/svg","circle");circle.setAttribute("class","c-streaming-chart__live-dot");circle.setAttribute("r","4");svg.appendChild(circle)}const parts=dot.split(/[ ,]+/);if(parts.length>=2){circle.setAttribute("cx",parts[0]);circle.setAttribute("cy",parts[1])}}}}enhance(){const sync=()=>{const seconds=parseFloat(this.getAttribute("interval")||"");const want=Number.isFinite(seconds)&&seconds>0&&!this.hasAttribute("pause")&&!this._streamPausedByUser&&this._viewVisible!==false;if(want===this._streamRunning)return;this._streamRunning=want;if(this._streamTimer!==undefined){clearInterval(this._streamTimer);this._streamTimer=undefined}this.dispatchEvent(new CustomEvent("contour:stream-state",{detail:{running:want},bubbles:true,composed:true}));if(!want)return;this._streamTimer=setInterval(()=>{if(!this.isConnected||this.hasAttribute("pause"))return;this._streamFrame+=1;this.dispatchEvent(new CustomEvent("contour:tick",{detail:{frame:this._streamFrame},bubbles:true,composed:true}));const src=this.getAttribute("src");if(src){remoteInvalidate(src);this.requestRender()}},Math.max(1000,seconds*1000))};sync();if(!this._wiredStreamView){this._wiredStreamView=true;this._viewVisible=true;watchViewport(this);this.addEventListener("contour:view-enter",()=>{this._viewVisible=true;sync()});this.addEventListener("contour:view-leave",()=>{this._viewVisible=false;sync()})}if(this._wiredStream)return;this._wiredStream=true;this._streamFrame=0;onDispose(this,()=>{if(this._streamTimer!==undefined){clearInterval(this._streamTimer);this._streamTimer=undefined}});this._streamPausedByUser=false;this.addEventListener("keydown",(e)=>{if(e.key===" "||e.key==="Enter"){e.preventDefault();this._streamPausedByUser=!this._streamPausedByUser;if(this._streamPausedByUser)this.setAttribute("data-user-paused","");else this.removeAttribute("data-user-paused");sync()}})}}define("contour-streaming-chart",ContourStreamingChart);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"]}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(){this.classList.add("c-meter");wireStates(this);loadRemote(this,["value","label"]);if(renderStates(this,"meter"))return;const rValue=remoteData(this,"value")||(this._remoteData&&this._remoteData.value);const label=remoteData(this,"label")||(this._remoteData&&this._remoteData.label)||"";const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-meter--"))this.classList.remove(c)});if(variant)this.classList.add("c-meter--"+variant);if(!rValue&&!label){renderEmpty(this,"meter");return}if(rValue===null){this.style.removeProperty("--meter-value")}else{const num=parseFloat(rValue);if(Number.isFinite(num))this.style.setProperty("--meter-value",rValue);else this.style.removeProperty("--meter-value")}const core=this.ensure(".c-meter__core",()=>{const el=document.createElement("span");el.className="c-meter__core";return el});let val=core.querySelector(".c-meter__value");if(!val){val=document.createElement("span");val.className="c-meter__value";core.appendChild(val)}const num=parseFloat(rValue);val.textContent=(Number.isFinite(num)?Math.round(num*100):0)+"%";if(label){const lbl=core.querySelector(".c-meter__label")||(()=>{const el=document.createElement("span");el.className="c-meter__label";core.appendChild(el);return el})();lbl.textContent=label}if(!this.hasAttribute("role"))this.setAttribute("role","meter");if(label&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label);const ariaValue=rValue===null?"0":rValue;const prevVal=this._meterAriaValue;if(!this.hasAttribute("aria-valuenow")||this.getAttribute("aria-valuenow")===prevVal){this.setAttribute("aria-valuenow",ariaValue);this._meterAriaValue=ariaValue}const min=this.getAttribute("min");const max=this.getAttribute("max");if(min!==null)this.setAttribute("aria-valuemin",min);else if(!this.hasAttribute("aria-valuemin"))this.setAttribute("aria-valuemin","0");if(max!==null)this.setAttribute("aria-valuemax",max);else if(!this.hasAttribute("aria-valuemax"))this.setAttribute("aria-valuemax","1");for(const a of["low","high","optimum"]){const v=this.getAttribute(a);if(v!==null)this.setAttribute("data-"+a,v);else this.removeAttribute("data-"+a)}}}define("contour-meter",ContourMeter);class ContourDelta extends ContourBase{static get observed(){return["value","direction","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{value:{attribute:"value"},direction:{attribute:"direction"},src:{attribute:"src"}}}render(){this.classList.add("c-delta");wireStates(this);loadRemote(this,"value");if(renderStates(this,"delta"))return;const value=remoteData(this,"value")||"";Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-delta--"))this.classList.remove(c)});const direction=this.getAttribute("direction")||(this._remoteData&&this._remoteData.direction)||"up";if(!value){renderEmpty(this,"delta");return}this.classList.add("c-delta--"+direction);const icon={up:"#i-arrow-up",down:"#i-arrow-down",flat:"#i-minus"}[direction]||"#i-arrow-up";this.querySelectorAll("svg").forEach((s)=>s.remove());const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href",icon);svg.appendChild(use);this.appendChild(svg);this.appendChild(document.createTextNode(" "+value))}}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"]}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(){this.classList.add("c-stat");wireStates(this);loadRemote(this,["value","label"]);if(renderStates(this,"stat"))return;const value=remoteData(this,"value");const label=remoteData(this,"label");const delta=this.getAttribute("delta");if(value){const v=this.ensure(".c-stat__value",()=>{const el=document.createElement("div");el.className="c-stat__value";el.setAttribute("aria-live","polite");return el});v.textContent=formatValue(value,this.getAttribute("format"),this.getAttribute("locale"),this.getAttribute("unit"))}else{const v=this.querySelector(".c-stat__value");if(v)v.remove()}if(label){const l=this.ensure(".c-stat__label",()=>{const el=document.createElement("div");el.className="c-stat__label";return el});l.textContent=label}else{const l=this.querySelector(".c-stat__label");if(l)l.remove()}if(delta){const d=this.ensure(".c-stat__delta",()=>{const el=document.createElement("div");el.className="c-stat__delta";return el});d.textContent=delta}else{const d=this.querySelector(".c-stat__delta");if(d)d.remove()}const unit=this.getAttribute("unit");const v=this.querySelector(".c-stat__value");if(v){if(unit){let u=v.querySelector(".c-stat__unit");if(!u){u=document.createElement("span");u.className="c-stat__unit";v.appendChild(u)}u.textContent=unit}else{const u=v.querySelector(".c-stat__unit");if(u)u.remove()}}if(!value&&!label){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"]}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(){this.classList.add("c-gauge");wireStates(this);loadRemote(this,["value"]);if(renderStates(this,"gauge"))return;const rawValue=this.getAttribute("value");const num=parseFloat(rawValue);const hasValue=rawValue!==null&&rawValue!==""&&Number.isFinite(num);const min=parseFloat(this.getAttribute("min")||"0");const max=parseFloat(this.getAttribute("max")||"100");const heading=this.getAttribute("heading");const showHeader=this.getAttribute("show-header")!=="false";const description=this.getAttribute("description");const noDataMessage=this.getAttribute("no-data-message")||"No readings in view";const brownoutLevel=this.brownoutLevel();if(!hasValue){if(heading&&showHeader){const t=this.ensure(".c-gauge__title",()=>{const el=document.createElement("div");el.className="c-gauge__title";return el});t.textContent=heading}const empty=this.ensure(".c-gauge__empty",()=>{const el=document.createElement("div");el.className="c-gauge__empty";el.setAttribute("part","empty");return el});empty.textContent=noDataMessage;[".c-gauge__dial",".c-gauge__value",".c-gauge__band"].forEach((sel)=>{const n=this.querySelector(sel);if(n)n.remove()});return}if(heading&&showHeader){const t=this.ensure(".c-gauge__title",()=>{const el=document.createElement("div");el.className="c-gauge__title";el.setAttribute("part","title");return el});t.textContent=heading}else{const t=this.querySelector(".c-gauge__title");if(t)t.remove()}let thresholds=[];const tAttr=this.getAttribute("thresholds");if(tAttr){try{thresholds=JSON.parse(tAttr)}catch(e){thresholds=[]}}let band=null;if(thresholds&&thresholds.length){const sorted=[...thresholds].sort((a,b)=>(a.value||0)-(b.value||0));for(let i=sorted.length-1;i>=0;i--){if(num>=(sorted[i].value||0)){band=sorted[i];break}}}const shedDial=this.shed("dial",3);let dial=this.querySelector(".c-gauge__dial");if(shedDial){if(dial)dial.remove()}else{if(!dial){dial=document.createElementNS("http://www.w3.org/2000/svg","svg");dial.setAttribute("class","c-gauge__dial");dial.setAttribute("part","dial");dial.setAttribute("aria-hidden","true");dial.setAttribute("viewBox","0 0 100 100");this.appendChild(dial)}dial.innerHTML="";const track=document.createElementNS("http://www.w3.org/2000/svg","path");track.setAttribute("class","c-gauge__track");track.setAttribute("d","M 10 90 A 40 40 0 0 1 90 90");dial.appendChild(track);if(thresholds&&thresholds.length){const sorted=[...thresholds].sort((a,b)=>(a.value||0)-(b.value||0));const toPoint=(v)=>{const pos=(1-(v-min)/(max-min||1))*Math.PI;return{x:50+40*Math.cos(pos),y:90-40*Math.sin(pos)}};for(let i=0;i<sorted.length;i++){const v1=sorted[i].value||0;const v2=(i+1<sorted.length)?(sorted[i+1].value||max):max;const p1=toPoint(v1);const p2=toPoint(v2);const z=document.createElementNS("http://www.w3.org/2000/svg","path");z.setAttribute("class","c-gauge__zone");z.setAttribute("stroke",sorted[i].color||"var(--color-primary)");z.setAttribute("d","M "+p1.x.toFixed(2)+" "+p1.y.toFixed(2)+" A 40 40 0 0 1 "+p2.x.toFixed(2)+" "+p2.y.toFixed(2));dial.appendChild(z)}}const ratio=(num-min)/(max-min||1);const angle=Math.PI*(1-ratio);const needle=document.createElementNS("http://www.w3.org/2000/svg","line");needle.setAttribute("class","c-gauge__needle needle");needle.setAttribute("x1","50");needle.setAttribute("y1","90");needle.setAttribute("x2",String(50+35*Math.cos(angle)));needle.setAttribute("y2",String(90-35*Math.sin(angle)));dial.appendChild(needle);const hub=document.createElementNS("http://www.w3.org/2000/svg","circle");hub.setAttribute("class","c-gauge__hub hub");hub.setAttribute("cx","50");hub.setAttribute("cy","90");hub.setAttribute("r","4");dial.appendChild(hub)}const valueEl=this.ensure(".c-gauge__value",()=>{const el=document.createElement("div");el.className="c-gauge__value";el.setAttribute("part","value");return el});valueEl.textContent=formatValue(String(num),this.getAttribute("format"),this.getAttribute("locale"))+(this.getAttribute("unit")?" "+this.getAttribute("unit"):"");valueEl.setAttribute("role","meter");valueEl.setAttribute("aria-valuenow",String(num));valueEl.setAttribute("aria-valuemin",String(min));valueEl.setAttribute("aria-valuemax",String(max));if(heading){if(!valueEl.id)valueEl.id=contourId("gauge-value")}if(band){valueEl.setAttribute("aria-valuetext",num+", "+(band.label||(">= "+band.value)))}else{valueEl.setAttribute("aria-valuetext",String(num))}const titleEl=this.querySelector(".c-gauge__title");if(titleEl){if(!titleEl.id)titleEl.id=contourId("gauge-title");valueEl.setAttribute("aria-labelledby",titleEl.id);valueEl.removeAttribute("aria-label")}else{valueEl.removeAttribute("aria-labelledby");if(heading)valueEl.setAttribute("aria-label",heading);else valueEl.setAttribute("aria-label",valueEl.textContent||"Gauge")}const bandEl=this.querySelector(".c-gauge__band");if(band){const b=this.ensure(".c-gauge__band",()=>{const el=document.createElement("div");el.className="c-gauge__band";el.setAttribute("part","band");return el});b.textContent=band.label||(">= "+band.value)}else{if(bandEl)bandEl.remove()}if(description){let d=this.querySelector(".c-gauge__desc");if(!d){d=document.createElement("div");d.className="c-gauge__desc";this.appendChild(d)}d.textContent=description}}enhance(){}}define("contour-gauge",ContourGauge);class ContourAxis extends ContourBase{static get observed(){return["orientation","values","ticks","format","locale","padding","min","max","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{orientation:{attribute:"orientation"},values:{attribute:"values"},ticks:{attribute:"ticks"},format:{attribute:"format"},locale:{attribute:"locale"},padding:{attribute:"padding"},min:{attribute:"min"},max:{attribute:"max"},src:{attribute:"src"}}}render(){this.classList.add("c-axis");if(!this.hasAttribute("role"))this.setAttribute("role","img");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Axis");const orientation=this.getAttribute("orientation")||"horizontal";this.classList.toggle("c-axis--horizontal",orientation==="horizontal");this.classList.toggle("c-axis--vertical",orientation==="vertical");if(orientation==="horizontal")this.setAttribute("part","axis-x");else this.setAttribute("part","axis-y");wireStates(this);loadRemote(this,["values"]);if(renderStates(this,"axis"))return;let values=[];const vAttr=this.getAttribute("values");if(vAttr){try{values=JSON.parse(vAttr)}catch(e){values=vAttr.split(",").map((x)=>x.trim())}}const ticks=parseInt(this.getAttribute("ticks")||"0",10)||values.length;const authoredTicks=Array.from(this.querySelectorAll(":scope > .c-axis__tick"));if(authoredTicks.length){authoredTicks.forEach((tick)=>{const label=tick.querySelector(".c-axis__label");if(label&&!label.textContent)label.textContent=tick.textContent})}else{Array.from(this.querySelectorAll(".c-axis__tick")).forEach((n)=>n.remove());const list=values.length?values:Array.from({length:ticks},(_,i)=>i);list.forEach((v)=>{const tick=document.createElement("span");tick.className="c-axis__tick";const label=document.createElement("span");label.className="c-axis__label";label.textContent=formatValue(String(v),this.getAttribute("format"),this.getAttribute("locale"));tick.appendChild(label);this.appendChild(tick)})}}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"]}static get properties(){return{start:{attribute:"start"},end:{attribute:"end"},min:{attribute:"min"},max:{attribute:"max"},src:{attribute:"src"}}}_rangeValue(){const start=parseFloat(this.getAttribute("start"));const end=parseFloat(this.getAttribute("end"));return Number.isFinite(start)&&Number.isFinite(end)?[start,end]:null}render(){this.classList.add("c-brush");this.setAttribute("role","group");this.setAttribute("aria-label","Brush selection");wireStates(this);loadRemote(this,[]);if(renderStates(this,"brush"))return;let sel=this.querySelector(".c-brush__selection");if(!sel){sel=document.createElement("div");sel.className="c-brush__selection";this.appendChild(sel)}const start=parseFloat(this.getAttribute("start")||"0");const end=parseFloat(this.getAttribute("end")||"100");const min=parseFloat(this.getAttribute("min")||"0");const max=parseFloat(this.getAttribute("max")||"100");const range=max-min||1;const left=((start-min)/range)*100;const width=((end-start)/range)*100;sel.style.insetInlineStart=left+"%";sel.style.inlineSize=width+"%";["start","end"].forEach((h)=>{let handle=this.querySelector(".c-brush__handle--"+h);if(!handle){handle=document.createElement("div");handle.className="c-brush__handle c-brush__handle--"+h;this.appendChild(handle)}const val=h==="start"?start:end;handle.style.insetInlineStart=(((val-min)/range)*100)+"%"})}enhance(){if(this._wiredBrush)return;this._wiredBrush=true;let dragging=null;const min=()=>parseFloat(this.getAttribute("min")||"0");const max=()=>parseFloat(this.getAttribute("max")||"100");const toValue=(clientX)=>{const r=this.getBoundingClientRect();const ratio=Math.max(0,Math.min(1,(clientX-r.left)/(r.width||1)));return min()+ratio*(max()-min())};this.addEventListener("pointerdown",(e)=>{const handle=e.target&&e.target.classList&&e.target.classList.contains("c-brush__handle")?e.target:null;dragging=handle?(handle.classList.contains("c-brush__handle--start")?"start":"end"):"move";try{this.setPointerCapture(e.pointerId)}catch(err){}this.dispatchEvent(new CustomEvent("contour:brush-start",{bubbles:true,composed:true,detail:{value:this.getAttribute("start"),start:this.getAttribute("start"),end:this.getAttribute("end"),range:this._rangeValue()}}))});this.addEventListener("pointermove",(e)=>{if(!dragging)return;const v=toValue(e.clientX);const mn=min(),mx=max(),range=mx-mn||1;const sel=this.querySelector(".c-brush__selection");let ns=parseFloat(this.getAttribute("start")||"0");let ne=parseFloat(this.getAttribute("end")||"100");if(dragging==="start"){ns=Math.min(v,ne)}else if(dragging==="end"){ne=Math.max(v,ns)}else{const width=ne-ns;ns=v-width/2;ne=v+width/2;if(ns<mn){ne+=mn-ns;ns=mn}if(ne>mx){ns-=ne-mx;ne=mx}}ns=Math.max(mn,Math.min(mx,ns));ne=Math.max(mn,Math.min(mx,ne));if(sel){sel.style.insetInlineStart=(((ns-mn)/range)*100)+"%";sel.style.inlineSize=(((ne-ns)/range)*100)+"%"}const sh=this.querySelector(".c-brush__handle--start");const eh=this.querySelector(".c-brush__handle--end");if(sh)sh.style.insetInlineStart=(((ns-mn)/range)*100)+"%";if(eh)eh.style.insetInlineStart=(((ne-mn)/range)*100)+"%";this._brushPending={start:ns,end:ne};this.dispatchEvent(new CustomEvent("contour:brush",{bubbles:true,composed:true,detail:{start:ns,end:ne,value:ns,range:[ns,ne]}}))});this.addEventListener("pointerup",(e)=>{if(!dragging)return;dragging=null;const p=this._brushPending;if(p){this.setAttribute("start",String(p.start));this.setAttribute("end",String(p.end));this._brushPending=null}this.dispatchEvent(new CustomEvent("contour:brush-end",{bubbles:true,composed:true,detail:{value:this.getAttribute("end"),start:this.getAttribute("start"),end:this.getAttribute("end"),range:this._rangeValue()}}));this.dispatchEvent(new CustomEvent("contour:brush",{bubbles:true,composed:true,detail:{start:this.getAttribute("start"),end:this.getAttribute("end"),value:this.getAttribute("end"),range:this._rangeValue()}}))});if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:brush-start",{bubbles:true,composed:true,detail:{value:this.getAttribute("start"),start:this.getAttribute("start"),end:this.getAttribute("end"),range:this._rangeValue()}}))}});this.addEventListener("contour:clear-all",()=>{if(this.hasAttribute("start")||this.hasAttribute("end")){this.removeAttribute("start");this.removeAttribute("end");this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:true,composed:true,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","normalize"]}static get properties(){return{segments:{attribute:"segments"},values:{attribute:"values"},colors:{attribute:"colors"},src:{attribute:"src"},normalize:{attribute:"normalize"}}}render(){this.classList.add("c-stacked-bar");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Stacked bar");wireStates(this);loadRemote(this,["segments","values"]);if(renderStates(this,"stacked-bar"))return;Array.from(this.querySelectorAll(".c-stacked-bar__segment")).forEach((n)=>n.remove());const authoredSegments=Array.from(this.querySelectorAll(":scope > .c-stacked-bar__segment"));let segments=[];if(authoredSegments.length){segments=authoredSegments.map((el)=>({label:el.getAttribute("title")||el.textContent||"",value:parseFloat(el.style.inlineSize)||0,color:(el.dataset&&el.dataset.color)||el.style.background||undefined,}));authoredSegments.forEach((el)=>el.remove())}else{const sAttr=this.getAttribute("segments");if(sAttr){try{segments=JSON.parse(sAttr)}catch(e){segments=[]}}}const values=segments.map((seg)=>(typeof seg==="object"?(seg.value||0):Number(seg)||0));const total=values.reduce((a,b)=>a+b,0)||1;const normalize=this.hasAttribute("normalize");const denom=normalize?total:(parseFloat(this.getAttribute("max")||String(total))||total);segments.forEach((seg,i)=>{const v=values[i];const el=document.createElement("div");el.className="c-stacked-bar__segment";el.style.inlineSize=((v/denom)*100)+"%";el.style.background=(typeof seg==="object"&&seg.color)?seg.color:"var(--chart-"+((i%8)+1)+")";el.dataset.color=(typeof seg==="object"&&seg.color)?seg.color:el.style.background;el.setAttribute("title",(typeof seg==="object"?(seg.label||""):"")+" "+v);this.appendChild(el)});if(!segments.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"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"},search:{attribute:"search"},note:{attribute:"note"},limit:{attribute:"limit"},sort:{attribute:"sort"}}}render(){this.classList.add("c-category");this.setAttribute("role","listbox");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Category");wireStates(this);loadRemote(this,["items"]);if(renderStates(this,"category"))return;Array.from(this.querySelectorAll(".c-category__item")).forEach((n)=>n.remove());const authoredItems=Array.from(this.querySelectorAll(":scope > .c-category__item"));let items=[];if(authoredItems.length){authoredItems.forEach((el)=>{const lbl=el.querySelector(".c-category__label");items.push({label:lbl?lbl.textContent:el.textContent,value:0})});authoredItems.forEach((el)=>el.remove())}else{const iAttr=this.getAttribute("items");if(iAttr){try{items=JSON.parse(iAttr)}catch(e){items=[]}}}const sort=this.getAttribute("sort")||"value-desc";items.sort((a,b)=>{const va=(typeof a==="object")?(a.value||0):(Number(a)||0);const vb=(typeof b==="object")?(b.value||0):(Number(b)||0);const la=(typeof a==="object")?(a.label||a.name||""):String(a);const lb=(typeof b==="object")?(b.label||b.name||""):String(b);if(sort==="value-asc")return va-vb;if(sort==="alpha-asc")return String(la).localeCompare(String(lb));if(sort==="alpha-desc")return String(lb).localeCompare(String(la));return vb-va});const limit=parseInt(this.getAttribute("limit")||"0",10);if(limit>0)items=items.slice(0,limit);const max=items.reduce((m,it)=>Math.max(m,(typeof it==="object"?(it.value||0):Number(it)||0)),0)||1;items.forEach((it,idx)=>{const value=(typeof it==="object")?(it.value||0):(Number(it)||0);const label=(typeof it==="object")?(it.label||it.name||""):String(it);const item=document.createElement("div");item.className="c-category__item";item.setAttribute("role","option");item.setAttribute("aria-selected","false");item.setAttribute("tabindex",idx===0?"0":"-1");const lbl=document.createElement("span");lbl.className="c-category__label";lbl.textContent=label;const barWrap=document.createElement("div");barWrap.style.flex="1";const bar=document.createElement("div");bar.className="c-category__bar";bar.style.inlineSize=((value/max)*100)+"%";barWrap.appendChild(bar);const val=document.createElement("span");val.className="c-category__value";val.textContent=String(value);item.appendChild(lbl);item.appendChild(barWrap);item.appendChild(val);this.appendChild(item)});if(!items.length)renderEmpty(this,"category");const note=this.getAttribute("note");let noteEl=this.querySelector(".c-category__note");if(note){if(!noteEl){noteEl=document.createElement("div");noteEl.className="c-category__note";this.appendChild(noteEl)}noteEl.textContent=note}else if(noteEl){noteEl.remove()}}enhance(){if(this._wiredCategory)return;this._wiredCategory=true;const items=()=>Array.from(this.querySelectorAll(".c-category__item"));const showTip=(e)=>{};this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-category__item"):null;if(!item||!this.contains(item))return;const all=items();const idx=all.indexOf(item);all.forEach((o,i)=>o.setAttribute("aria-selected",i===idx?"true":"false"));this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx,label:item.querySelector(".c-category__label")?item.querySelector(".c-category__label").textContent:item.textContent.trim()}}))});this.addEventListener("keydown",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-category__item"):null;if(!item||!this.contains(item))return;const all=items();const idx=all.indexOf(item);if(e.key==="Enter"||e.key===" "){e.preventDefault();all.forEach((o,i)=>o.setAttribute("aria-selected",i===idx?"true":"false"));this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx,label:item.querySelector(".c-category__label")?item.querySelector(".c-category__label").textContent:item.textContent.trim()}}));return}navKey(e,all,{wrap:false,homeEnd:true,rtl:isRtl(this),onNavigate:(i)=>all.forEach((it,j)=>it.setAttribute("tabindex",j===i?"0":"-1")),onKey:()=>{if(e.key==="Enter"||e.key===" "){const idx2=all.indexOf(document.activeElement);all.forEach((o,j)=>o.setAttribute("aria-selected",j===idx2?"true":"false"));this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx2,label:document.activeElement.querySelector(".c-category__label")?document.activeElement.querySelector(".c-category__label").textContent:document.activeElement.textContent.trim()}}))}}})});this.addEventListener("contour:clear-all",()=>{if(this.hasAttribute("search")){this.removeAttribute("search");this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:true,composed:true,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"]}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(){this.classList.add("c-donut");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Donut chart");wireStates(this);loadRemote(this,["items","values"]);if(renderStates(this,"donut"))return;Array.from(this.querySelectorAll(".c-donut__ring, .c-donut__center, .c-donut__list, .c-donut__empty")).forEach((n)=>n.remove());const authoredItems=Array.from(this.querySelectorAll(":scope > .c-donut__item"));let items=[];if(authoredItems.length){authoredItems.forEach((el)=>{const sw=el.querySelector(".c-donut__swatch");const lbl=el.querySelector("span:last-child");const text=lbl?lbl.textContent:el.textContent;const match=text.match(/—\s*(\d+(?:\.\d+)?)$/);items.push({label:text.replace(/—\s*\d+(?:\.\d+)?$/,"").trim(),value:match?Number(match[1]):0,color:sw?(sw.dataset&&sw.dataset.color)||sw.style.background:undefined})});authoredItems.forEach((el)=>el.remove())}else{const iAttr=this.getAttribute("items");if(iAttr){try{items=JSON.parse(iAttr)}catch(e){items=[]}}}const values=items.map((it)=>(typeof it==="object"?(it.value||0):Number(it)||0));const total=values.reduce((a,b)=>a+b,0)||1;const brownoutLevel=this.brownoutLevel();const layerColor=this.getAttribute("color");const shedRing=this.shed("ring",3);if(!shedRing){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("class","c-donut__ring");svg.setAttribute("viewBox","0 0 32 32");let offset=0;items.forEach((it,i)=>{const v=values[i];const pct=v/total;const circle=document.createElementNS("http://www.w3.org/2000/svg","circle");circle.setAttribute("cx","16");circle.setAttribute("cy","16");circle.setAttribute("r","12");circle.setAttribute("fill","none");circle.setAttribute("stroke",layerColor||(typeof it==="object"&&it.color?it.color:"var(--chart-"+((i%8)+1)+")"));circle.setAttribute("stroke-width","6");const circ=2*Math.PI*12;circle.setAttribute("stroke-dasharray",(pct*circ)+" "+(circ-pct*circ));circle.setAttribute("stroke-dashoffset",String(-offset*circ));circle.setAttribute("transform","rotate(-90 16 16)");svg.appendChild(circle);offset+=pct});const hole=document.createElementNS("http://www.w3.org/2000/svg","circle");hole.setAttribute("cx","16");hole.setAttribute("cy","16");hole.setAttribute("r","9");hole.setAttribute("fill","var(--color-surface-0)");svg.appendChild(hole);this.appendChild(svg)}const center=document.createElement("div");center.className="c-donut__center";center.textContent=this.getAttribute("value")||String(total);this.appendChild(center);const list=document.createElement("div");list.className="c-donut__list";list.setAttribute("role","list");items.forEach((it,i)=>{const row=document.createElement("div");row.className="c-donut__item";row.setAttribute("role","listitem");const sw=document.createElement("span");sw.className="c-donut__swatch";sw.style.background=layerColor||(typeof it==="object"&&it.color?it.color:"var(--chart-"+((i%8)+1)+")");if(sw.style.background)sw.dataset.color=layerColor||(typeof it==="object"&&it.color?it.color:sw.style.background);row.appendChild(sw);const lbl=document.createElement("span");lbl.textContent=(typeof it==="object"?(it.label||""):String(it))+" — "+values[i];row.appendChild(lbl);list.appendChild(row)});this.appendChild(list);if(!items.length)renderEmpty(this,"donut");const note=this.getAttribute("note");let noteEl=this.querySelector(".c-donut__note");if(note){if(!noteEl){noteEl=document.createElement("div");noteEl.className="c-donut__note";this.appendChild(noteEl)}noteEl.textContent=note}else if(noteEl){noteEl.remove()}}enhance(){}}define("contour-donut",ContourDonut);class ContourTimeSeries extends ContourBase{static get observed(){return["values","points","series","style","title","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","annotations","note"]}static get properties(){return{values:{attribute:"values"},points:{attribute:"points"},series:{attribute:"series"},style:{attribute:"style"},src:{attribute:"src"},annotations:{attribute:"annotations"},note:{attribute:"note"}}}render(){this.classList.add("c-time-series");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("title")||"Time series");wireStates(this);loadRemote(this,["values","points","series"]);if(renderStates(this,"time-series"))return;Array.from(this.querySelectorAll(".c-time-series__plot, .c-time-series__axis")).forEach((n)=>n.remove());let series=[];const sAttr=this.getAttribute("series");if(sAttr){try{series=JSON.parse(sAttr)}catch(e){series=[]}}const remote=remoteData(this,"series");if(Array.isArray(remote))series=remote;if(!series.length){let values=[];const vAttr=this.getAttribute("values");if(vAttr){try{values=JSON.parse(vAttr)}catch(e){values=vAttr.split(",").map(Number)}}if(values.length){series=[{label:"Series 1",values,style:this.getAttribute("style")||"bar",color:"var(--chart-1)"}]}}const max=series.reduce((m,s)=>{const v=Array.isArray(s.values)?Math.max(...s.values,0):0;return Math.max(m,v)},1);const min=series.reduce((m,s)=>{const v=Array.isArray(s.values)?Math.min(...s.values,0):0;return Math.min(m,v)},0);const plot=document.createElement("div");plot.className="c-time-series__plot";plot.setAttribute("part","plot");series.forEach((s,si)=>{const values=Array.isArray(s.values)?s.values:[];const style=s.style||"bar";const color=s.color||`var(--chart-${((si % 8) + 1)})`;const label=s.label||`Series ${si + 1}`;if(style==="line"){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const range=(max-min)||1;const n=values.length||1;const pts=values.map((v,i)=>{const x=(i/Math.max(1,n-1))*300;const y=120-((v-min)/range)*120;return x.toFixed(2)+","+y.toFixed(2)}).join(" ");const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-time-series__line");path.setAttribute("data-series",String(si));path.setAttribute("d","M "+pts.replace(/ /g," L "));path.style.stroke=color;path.style.fill="none";path.style.strokeWidth="2";svg.appendChild(path);values.forEach((v,i)=>{const x=(i/Math.max(1,n-1))*300;const y=120-((v-min)/range)*120;const c=document.createElementNS("http://www.w3.org/2000/svg","circle");c.setAttribute("class","c-time-series__point");c.setAttribute("data-series",String(si));c.setAttribute("data-index",String(i));c.setAttribute("cx",x.toFixed(2));c.setAttribute("cy",y.toFixed(2));c.setAttribute("r","3");c.setAttribute("tabindex",i===0&&si===0?"0":"-1");c.setAttribute("role","button");c.setAttribute("title",String(v));c.setAttribute("aria-label",label+": "+String(v));svg.appendChild(c)});plot.appendChild(svg)}else{values.forEach((v,i)=>{const bar=document.createElement("div");bar.className="c-time-series__bar";bar.setAttribute("data-series",String(si));bar.setAttribute("data-index",String(i));bar.style.blockSize=((v/max)*100)+"%";bar.style.background=color;bar.setAttribute("title",String(v));bar.setAttribute("role","button");bar.setAttribute("aria-label",label+": "+String(v));bar.setAttribute("tabindex",i===0&&si===0?"0":"-1");plot.appendChild(bar)})}});this.appendChild(plot);if(!series.length||!series.some((s)=>Array.isArray(s.values)&&s.values.length))renderEmpty(this,"time-series");const note=this.getAttribute("note");let noteEl=this.querySelector(".c-time-series__note");if(note){if(!noteEl){noteEl=document.createElement("div");noteEl.className="c-time-series__note";this.appendChild(noteEl)}noteEl.textContent=note}else if(noteEl){noteEl.remove()}}enhance(){if(this._wiredTimeSeries)return;this._wiredTimeSeries=true;const bars=()=>Array.from(this.querySelectorAll(".c-time-series__bar"));const points=()=>Array.from(this.querySelectorAll(".c-time-series__point"));this.addEventListener("click",(e)=>{const bar=e.target&&e.target.closest?e.target.closest(".c-time-series__bar"):null;if(!bar||!this.contains(bar))return;const seriesIdx=Number(bar.dataset.series||"0");const idx=Number(bar.dataset.index||"0");this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:seriesIdx,index:idx,value:bar.getAttribute("title")}}));return});const pointClick=(e)=>{const point=e.target&&e.target.closest?e.target.closest(".c-time-series__point"):null;if(!point||!this.contains(point))return;const seriesIdx=Number(point.dataset.series||"0");const idx=Number(point.dataset.index||"0");this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:seriesIdx,index:idx,value:point.getAttribute("title")}}))};this.addEventListener("click",pointClick);this.addEventListener("keydown",(e)=>{const bar=e.target&&e.target.closest?e.target.closest(".c-time-series__bar"):null;if(!bar||!this.contains(bar))return;const all=bars();const idx=all.indexOf(bar);if(e.key==="Enter"||e.key===" "){e.preventDefault();const seriesIdx=Number(bar.dataset.series||"0");this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:seriesIdx,index:idx,value:bar.getAttribute("title")}}));return}navKey(e,all,{wrap:false,homeEnd:true,rtl:isRtl(this),onNavigate:(i)=>all.forEach((b,j)=>b.setAttribute("tabindex",j===i?"0":"-1")),onKey:()=>{}})});this.addEventListener("focusin",(e)=>{const bar=e.target&&e.target.closest?e.target.closest(".c-time-series__bar"):null;if(bar&&this.contains(bar)){const tip=this.querySelector(".c-time-series__tooltip");if(tip){tip.textContent=bar.getAttribute("title");tip.removeAttribute("hidden")}}const point=e.target&&e.target.closest?e.target.closest(".c-time-series__point"):null;if(point&&this.contains(point)){const tip=this.querySelector(".c-time-series__tooltip");if(tip){tip.textContent=point.getAttribute("title");tip.removeAttribute("hidden")}}});this.addEventListener("focusout",(e)=>{const tip=this.querySelector(".c-time-series__tooltip");if(tip&&!this.contains(e.relatedTarget))tip.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"]}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(name){const n=(name||"sum").toLowerCase();if(n==="avg"||n==="average"||n==="mean")return(vals)=>vals.length?vals.reduce((a,b)=>a+b,0)/vals.length:0;if(n==="count")return(vals)=>vals.length;if(n==="min")return(vals)=>vals.length?Math.min(...vals):0;if(n==="max")return(vals)=>vals.length?Math.max(...vals):0;return(vals)=>vals.reduce((a,b)=>a+b,0)}render(){this.classList.add("c-pivot");wireStates(this);loadRemote(this,["data"]);if(renderStates(this,"pivot"))return;Array.from(this.querySelectorAll("table, .c-pivot__toolbar")).forEach((n)=>n.remove());let data=[];const dAttr=this.getAttribute("data");if(dAttr){try{data=JSON.parse(dAttr)}catch(e){data=[]}}const rows=this.getAttribute("rows")?this.getAttribute("rows").split(",").map((s)=>s.trim()).filter(Boolean):[];const cols=this.getAttribute("columns")?this.getAttribute("columns").split(",").map((s)=>s.trim()).filter(Boolean):[];const aggName=this.getAttribute("aggregate")||"sum";const aggFn=this._aggregateFn(aggName);const filterQ=(this.getAttribute("filter")||"").toLowerCase().trim();const toolbar=document.createElement("div");toolbar.className="c-pivot__toolbar";toolbar.style.display="flex";const filterInput=document.createElement("input");filterInput.type="search";filterInput.className="c-input c-pivot__filter";filterInput.placeholder="Filter…";filterInput.value=this.getAttribute("filter")||"";filterInput.setAttribute("aria-label","Filter pivot");const aggSelect=document.createElement("select");aggSelect.className="c-select c-pivot__aggregate";aggSelect.setAttribute("aria-label","Aggregation");["sum","avg","count","min","max"].forEach((a)=>{const opt=document.createElement("option");opt.value=a;opt.textContent=a;if(a===aggName)opt.selected=true;aggSelect.appendChild(opt)});toolbar.appendChild(filterInput);toolbar.appendChild(aggSelect);this.appendChild(toolbar);let visibleRows=rows;let visibleCols=cols;if(filterQ){visibleRows=rows.filter((r)=>r.toLowerCase().includes(filterQ)||data.some((d)=>d.row===r&&String(d.value).toLowerCase().includes(filterQ)));visibleCols=cols.filter((c)=>c.toLowerCase().includes(filterQ)||data.some((d)=>d.col===c&&String(d.value).toLowerCase().includes(filterQ)));if(!visibleRows.length)visibleRows=rows;if(!visibleCols.length)visibleCols=cols}const table=document.createElement("table");table.setAttribute("role","grid");table.setAttribute("aria-rowcount",String(visibleRows.length+1));table.setAttribute("aria-colcount",String(visibleCols.length+1));const thead=document.createElement("thead");const hr=document.createElement("tr");const corner=document.createElement("th");corner.textContent="";corner.setAttribute("role","columnheader");corner.setAttribute("aria-label","Row");hr.appendChild(corner);visibleCols.forEach((c)=>{const th=document.createElement("th");th.textContent=c;th.setAttribute("role","columnheader");th.setAttribute("tabindex","0");hr.appendChild(th)});thead.appendChild(hr);table.appendChild(thead);const tbody=document.createElement("tbody");visibleRows.forEach((r)=>{const tr=document.createElement("tr");tr.setAttribute("role","row");const th=document.createElement("th");th.textContent=r;th.setAttribute("role","rowheader");th.setAttribute("tabindex","0");tr.appendChild(th);visibleCols.forEach((c)=>{const td=document.createElement("td");td.setAttribute("role","gridcell");td.setAttribute("tabindex","0");const cellData=data.filter((d)=>d.row===r&&d.col===c);const vals=cellData.map((d)=>Number(d.value)).filter((n)=>Number.isFinite(n));if(cellData.length&&vals.length===cellData.length&&vals.length){const v=aggFn(vals);td.textContent=Number.isInteger(v)?String(v):v.toFixed(2)}else if(cellData.length){td.textContent=cellData.map((d)=>d.value).join(", ")}else{td.textContent=""}if(!td.textContent.trim())td.setAttribute("aria-label","Empty");tr.appendChild(td)});tbody.appendChild(tr)});table.appendChild(tbody);this.appendChild(table);if(!data.length&&!rows.length&&!cols.length)renderEmpty(this,"pivot")}enhance(){if(this._wiredPivot)return;this._wiredPivot=true;this.addEventListener("click",(e)=>{const th=e.target&&e.target.closest?e.target.closest("th"):null;const td=e.target&&e.target.closest?e.target.closest("td"):null;const filterInput=e.target&&e.target.closest?e.target.closest(".c-pivot__filter"):null;const aggSelect=e.target&&e.target.closest?e.target.closest(".c-pivot__aggregate"):null;if(filterInput)return;if(aggSelect)return;if(th&&this.contains(th)&&th.parentElement&&th.parentElement.parentElement&&th.parentElement.parentElement.tagName==="THEAD"){this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:true,composed:true,detail:{column:th.textContent.trim()}}));return}if(td&&this.contains(td)){this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:td.textContent}}))}});this.addEventListener("input",(e)=>{const fi=e.target&&e.target.closest?e.target.closest(".c-pivot__filter"):null;if(fi&&this.contains(fi)){this.setAttribute("filter",fi.value);this.render();this.dispatchEvent(new CustomEvent("contour:filter",{bubbles:true,composed:true,detail:{query:fi.value}}));this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:true,composed:true,detail:{source:"pivot",filter:{filter:fi.value}}}))}});this.addEventListener("change",(e)=>{const as=e.target&&e.target.closest?e.target.closest(".c-pivot__aggregate"):null;if(as&&this.contains(as)){this.setAttribute("aggregate",as.value);this.render();this.dispatchEvent(new CustomEvent("contour:aggregate",{bubbles:true,composed:true,detail:{aggregate:as.value}}))}});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest("th, td"):null;if(!cell||!this.contains(cell))return;const table=this.querySelector("table");if(!table)return;const rows=Array.from(table.querySelectorAll("tr"));const ri=rows.indexOf(cell.parentElement);const ci=Array.from(cell.parentElement.children).indexOf(cell);let target=null;if(e.key==="ArrowRight")target=cell.parentElement.children[ci+1];else if(e.key==="ArrowLeft")target=cell.parentElement.children[ci-1];else if(e.key==="ArrowDown")target=rows[ri+1]&&rows[ri+1].children[ci];else if(e.key==="ArrowUp")target=rows[ri-1]&&rows[ri-1].children[ci];else if(e.key==="Home")target=cell.parentElement.children[0];else if(e.key==="End")target=cell.parentElement.children[cell.parentElement.children.length-1];if(target){e.preventDefault();try{target.focus()}catch(err){}}});this.addEventListener("contour:clear-all",()=>{if(this.hasAttribute("filter")){this.removeAttribute("filter");this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:true,composed:true,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"]}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,[]);if(renderStates(this,"widget-state"))return}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 level=this.getAttribute("level")||"0";this.dataset.level=level;this.setAttribute("data-level",level);let deco=this.querySelector(".c-brownout__decorative");if(!deco){deco=document.createElement("span");deco.className="c-brownout__decorative";deco.setAttribute("aria-hidden","true");this.appendChild(deco)}let lbl=this.querySelector(".c-brownout__label");if(!lbl){lbl=document.createElement("span");lbl.className="c-brownout__label";this.appendChild(lbl)}lbl.textContent="Level "+level}enhance(){}}define("contour-brownout",ContourBrownout);class ContourInstrument extends ContourBase{static get observed(){return["rows","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{rows:{attribute:"rows"},src:{attribute:"src"}}}render(){this.classList.add("c-instrument");wireStates(this);loadRemote(this,"rows");if(renderStates(this,"instrument"))return;const rows=remoteData(this,"rows");Array.from(this.querySelectorAll(".c-instrument__item")).forEach((n)=>n.remove());if(rows){try{const parsed=JSON.parse(rows);parsed.forEach((r)=>{const item=document.createElement("span");item.className="c-instrument__item";item.appendChild(document.createTextNode(String(r.key||r[0]||"")));const val=document.createElement("span");val.className="c-instrument__value";val.textContent=r.value||r[1]||"";item.appendChild(val);this.appendChild(item)})}catch(e){warnBadJson(this,"attribute",e)}}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"}}}render(){this.classList.add("c-bivariate");this.setAttribute("role","group");this.setAttribute("aria-label","Bivariate legend");const size=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3));const matrix=this.ensure(".c-bivariate__matrix",()=>{const el=document.createElement("div");el.className="c-bivariate__matrix";return el});matrix.style.gridTemplateColumns=`repeat(${size}, 1fr)`;matrix.style.gridTemplateRows=`repeat(${size}, 1fr)`;const authored=Array.from(matrix.children).filter((n)=>n.classList&&n.classList.contains("c-bivariate__cell"));if(!authored.length){matrix.innerHTML="";let colors=[];const cAttr=this.getAttribute("colors");if(cAttr){try{colors=JSON.parse(cAttr)}catch(e){colors=[]}}for(let r=0;r<size;r++){for(let c=0;c<size;c++){const cell=document.createElement("div");cell.className="c-bivariate__cell";cell.setAttribute("role","button");cell.setAttribute("tabindex","0");cell.setAttribute("aria-label","Cell "+c+","+r);const srcIndex=(size-1-r)*size+c;if(colors[srcIndex]){cell.style.background=colors[srcIndex];cell.dataset.color=colors[srcIndex]}matrix.appendChild(cell)}}const sel=this.getAttribute("selected");if(sel){const parts=sel.split(",");const sr=parseInt(parts[0],10);const sc=parseInt(parts[1],10);const cells=Array.from(matrix.querySelectorAll(".c-bivariate__cell"));cells.forEach((cell,i)=>{const rr=Math.floor(i/size);const cc=i%size;if(rr===sr&&cc===sc)cell.setAttribute("data-selected","");else cell.removeAttribute("data-selected")})}let live=this.querySelector(".c-bivariate__live");if(!live){live=document.createElement("div");live.className="c-bivariate__live";live.setAttribute("aria-live","polite");live.style.position="absolute";live.style.width="1px";live.style.height="1px";live.style.overflow="hidden";live.style.clip="rect(0,0,0,0)";this.appendChild(live)}}const axisX=this.getAttribute("axis-x");if(axisX){const ax=this.ensure(".c-bivariate__axis--x",()=>{const el=document.createElement("div");el.className="c-bivariate__axis c-bivariate__axis--x";return el});ax.textContent=axisX}else{const ax=this.querySelector(".c-bivariate__axis--x");if(ax)ax.remove()}const axisY=this.getAttribute("axis-y");if(axisY){const ay=this.ensure(".c-bivariate__axis--y",()=>{const el=document.createElement("div");el.className="c-bivariate__axis c-bivariate__axis--y";return el});ay.textContent=axisY}else{const ay=this.querySelector(".c-bivariate__axis--y");if(ay)ay.remove()}}enhance(){if(this._wiredBivariate)return;this._wiredBivariate=true;const selectCell=(cell)=>{const matrix=this.querySelector(".c-bivariate__matrix");const cells=Array.from(matrix?matrix.querySelectorAll(".c-bivariate__cell"):[]);const idx=cells.indexOf(cell);if(idx<0)return;const size=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3));const row=Math.floor(idx/size);const col=idx%size;cells.forEach((cell,i)=>{const rr=Math.floor(i/size);const cc=i%size;if(rr===row&&cc===col)cell.setAttribute("data-selected","");else cell.removeAttribute("data-selected")});this.dispatchEvent(new CustomEvent("contour:select",{detail:{row,col},bubbles:true,composed:true}))};this.addEventListener("click",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-bivariate__cell"):null;if(cell&&this.contains(cell))selectCell(cell)});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-bivariate__cell"):null;if(!cell||!this.contains(cell))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();selectCell(cell)}})}clear(){this.removeAttribute("selected");this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:true,composed:true}))}}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"}}}render(){this.classList.add("c-bivariate-legend");this.setAttribute("role","group");this.setAttribute("aria-label","Bivariate legend");const size=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3));const matrix=this.ensure(".c-bivariate-legend__matrix",()=>{const el=document.createElement("div");el.className="c-bivariate-legend__matrix";return el});matrix.style.gridTemplateColumns=`repeat(${size}, 1fr)`;matrix.style.gridTemplateRows=`repeat(${size}, 1fr)`;const authored=Array.from(matrix.children).filter((n)=>n.classList&&n.classList.contains("c-bivariate-legend__cell"));if(!authored.length){matrix.innerHTML="";let colors=[];const cAttr=this.getAttribute("colors");if(cAttr){try{colors=JSON.parse(cAttr)}catch(e){colors=[]}}for(let r=0;r<size;r++){for(let c=0;c<size;c++){const cell=document.createElement("div");cell.className="c-bivariate-legend__cell";cell.setAttribute("role","button");cell.setAttribute("tabindex","0");cell.setAttribute("aria-label","Cell "+c+","+r);const srcIndex=(size-1-r)*size+c;if(colors[srcIndex]){cell.style.background=colors[srcIndex];cell.dataset.color=colors[srcIndex]}matrix.appendChild(cell)}}const sel=this.getAttribute("selected");if(sel){const parts=sel.split(",");const sr=parseInt(parts[0],10);const sc=parseInt(parts[1],10);const cells=Array.from(matrix.querySelectorAll(".c-bivariate-legend__cell"));cells.forEach((cell,i)=>{const rr=Math.floor(i/size);const cc=i%size;if(rr===sr&&cc===sc)cell.setAttribute("data-selected","");else cell.removeAttribute("data-selected")})}let live=this.querySelector(".c-bivariate-legend__live");if(!live){live=document.createElement("div");live.className="c-bivariate-legend__live";live.setAttribute("aria-live","polite");live.style.position="absolute";live.style.width="1px";live.style.height="1px";live.style.overflow="hidden";live.style.clip="rect(0,0,0,0)";this.appendChild(live)}}const axisX=this.getAttribute("axis-x");if(axisX){const ax=this.ensure(".c-bivariate-legend__axis--x",()=>{const el=document.createElement("div");el.className="c-bivariate-legend__axis c-bivariate-legend__axis--x";return el});ax.textContent=axisX}else{const ax=this.querySelector(".c-bivariate-legend__axis--x");if(ax)ax.remove()}const axisY=this.getAttribute("axis-y");if(axisY){const ay=this.ensure(".c-bivariate-legend__axis--y",()=>{const el=document.createElement("div");el.className="c-bivariate-legend__axis c-bivariate-legend__axis--y";return el});ay.textContent=axisY}else{const ay=this.querySelector(".c-bivariate-legend__axis--y");if(ay)ay.remove()}}enhance(){if(this._wiredBivLegend)return;this._wiredBivLegend=true;const selectCell=(cell)=>{const matrix=this.querySelector(".c-bivariate-legend__matrix");const cells=Array.from(matrix?matrix.querySelectorAll(".c-bivariate-legend__cell"):[]);const idx=cells.indexOf(cell);if(idx<0)return;const size=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3));const row=Math.floor(idx/size);const col=idx%size;cells.forEach((cell,i)=>{const rr=Math.floor(i/size);const cc=i%size;if(rr===row&&cc===col)cell.setAttribute("data-selected","");else cell.removeAttribute("data-selected")});this.dispatchEvent(new CustomEvent("contour:select",{detail:{row,col},bubbles:true,composed:true}))};this.addEventListener("click",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-bivariate-legend__cell"):null;if(cell&&this.contains(cell))selectCell(cell)});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-bivariate-legend__cell"):null;if(!cell||!this.contains(cell))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();selectCell(cell)}})}clear(){this.removeAttribute("selected");const cells=Array.from(this.querySelectorAll(".c-bivariate-legend__cell"));cells.forEach((c)=>c.removeAttribute("data-selected"));this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:true,composed:true}))}}define("contour-bivariate-legend",ContourBivariateLegend);class ContourSurvey extends ContourBase{static get observed(){return["date","instrument","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{date:{attribute:"date"},instrument:{attribute:"instrument"},src:{attribute:"src"}}}render(){this.classList.add("c-survey");wireStates(this);loadRemote(this,"date");if(renderStates(this,"survey"))return;const date=remoteData(this,"date");Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===Node.TEXT_NODE){if(n.textContent.trim()==="Surveyed"||n.textContent.trim()==="·")n.remove()}else if(n.classList&&(n.classList.contains("c-survey__value")||n.classList.contains("c-survey__sep")))n.remove()});const rDate=date||(this._remoteData&&this._remoteData.date);const instrument=this.getAttribute("instrument")||(this._remoteData&&this._remoteData.instrument);if(!rDate){renderEmpty(this,"survey");return}const v=document.createElement("span");v.className="c-survey__value";v.textContent=rDate;this.appendChild(document.createTextNode("Surveyed "));this.appendChild(v);if(instrument){const sep=document.createElement("span");sep.className="c-survey__sep";sep.textContent="·";this.appendChild(sep);const v2=document.createElement("span");v2.className="c-survey__value";v2.textContent=instrument;this.appendChild(v2)}}}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"]}static get properties(){return{label:{attribute:"label"},norm:{attribute:"norm"},state:{attribute:"state"},value:{attribute:"value"},src:{attribute:"src"}}}render(){this.classList.add("c-threshold");wireStates(this);loadRemote(this,"value");if(renderStates(this,"threshold"))return;const pct=(v)=>{const n=Number(v);if(!Number.isFinite(n))return String(v);return(n<=1?n*100:n)+"%"};const rValue=remoteData(this,"value")||(this._remoteData&&this._remoteData.value);const target=this.getAttribute("norm")||(this._remoteData&&this._remoteData.norm);const state=this.getAttribute("state")||(this._remoteData&&this._remoteData.state);const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(!rValue&&!target&&!label){renderEmpty(this,"threshold");return}if(rValue){const v=this.ensure(".c-threshold__fill",()=>{const el=document.createElement("span");el.className="c-threshold__fill";return el});v.style.setProperty("--value",pct(rValue))}else{const v=this.querySelector(".c-threshold__fill");if(v)v.remove()}if(target){const t=this.ensure(".c-threshold__target",()=>{const el=document.createElement("span");el.className="c-threshold__target";return el});t.style.setProperty("--target",pct(target))}else{const t=this.querySelector(".c-threshold__target");if(t)t.remove()}if(state)this.setAttribute("data-state",state);else this.removeAttribute("data-state");if(label)this.setAttribute("aria-label",label)}enhance(){if(this._wiredThreshold)return;this._wiredThreshold=true;this.addEventListener("contour:clear-all",()=>{if(this.hasAttribute("norm")||this.hasAttribute("value")){this.removeAttribute("norm");this.removeAttribute("value");this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:true,composed:true,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"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-metrics");this.setAttribute("role","list");wireStates(this);loadRemote(this,"items");if(renderStates(this,"metrics"))return;const items=remoteData(this,"items");Array.from(this.querySelectorAll(".c-metrics__item")).forEach((n)=>n.remove());let parsed=null;if(items){try{parsed=JSON.parse(items)}catch(e){parsed=null}}if(Array.isArray(parsed)&&parsed.length){parsed.forEach((it)=>{const item=document.createElement("div");item.className="c-metrics__item";item.setAttribute("role","listitem");const v=document.createElement("div");v.className="c-metrics__value";v.textContent=(typeof it==="object"&&it!==null)?(it.value??it.v??""):String(it);const l=document.createElement("div");l.className="c-metrics__label";l.textContent=(typeof it==="object"&&it!==null)?(it.label??it.l??""):"";item.appendChild(v);item.appendChild(l);this.appendChild(item)})}else if(!items){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","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"]}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 graduated=this.hasAttribute("graduated");if(graduated)this.classList.add("c-legend--graduated");const continuous=this.hasAttribute("continuous");if(continuous||this.hasAttribute("selectable")){this.setAttribute("role","group")}else{this.setAttribute("role","list")}wireStates(this);loadRemote(this,"items");if(renderStates(this,"legend"))return;const selectable=this.hasAttribute("selectable");const authoredLegendItems=Array.from(this.querySelectorAll(":scope > .c-legend__item"));let items=remoteData(this,"items");if(authoredLegendItems.length){items=JSON.stringify(authoredLegendItems.map((el)=>{const sw=el.querySelector(".c-legend__swatch");const lbl=el.querySelector(".c-legend__label")||el;return{label:lbl?lbl.textContent.trim():el.textContent.trim(),color:sw?(sw.dataset&&sw.dataset.color)||sw.style.background||undefined:undefined}}));authoredLegendItems.forEach((el)=>el.remove())}const title=this.getAttribute("title");if(title){const t=this.ensure(".c-legend__title",()=>{const el=document.createElement("div");el.className="c-legend__title";return el});t.textContent=title}else{const t=this.querySelector(".c-legend__title");if(t)t.remove()}if(items){try{const parsed=JSON.parse(items);const list=this.ensure(".c-legend__items",()=>{const el=document.createElement("div");el.className="c-legend__items";return el});if(this.hasAttribute("selectable")){list.setAttribute("role","group")}else{list.removeAttribute("role")}if(title)list.setAttribute("aria-label",title);list.innerHTML="";parsed.forEach((it)=>{const label=typeof it==="string"?it:(it.label||String(it));const key=typeof it==="string"?it:(it.key||it.label||String(it));const item=document.createElement("div");item.className="c-legend__item";item.setAttribute("tabindex","-1");if(selectable){item.setAttribute("role","button");item.setAttribute("aria-pressed","true");item.dataset.key=key}else{item.setAttribute("role","listitem")}const sw=document.createElement("span");if(graduated){sw.className="c-legend__swatch c-legend__swatch--graduated";const gSize=it&&it.size!=null?it.size:(it&&it.value!=null?it.value:1);const sizePx=Math.max(6,Math.min(24,parseFloat(gSize)*4));sw.style.inlineSize=sizePx+"px";sw.style.blockSize=sizePx+"px"}else{sw.className="c-legend__swatch"}if(it&&it.color){sw.style.background=it.color;sw.dataset.color=it.color}item.appendChild(sw);if(graduated&&(it&&it.break!=null)){const bl=document.createElement("span");bl.className="c-legend__break-label";bl.textContent=String(it.break);item.appendChild(bl)}const glyphShape=(it&&(it.shape||it.marker||it.glyph))||this.getAttribute("glyphs");if(glyphShape){const g=document.createElement("span");g.className="c-legend__glyph";g.setAttribute("part","glyph");g.textContent=glyphShape==="circle"?"●":glyphShape==="square"?"■":glyphShape==="triangle"?"▲":glyphShape==="diamond"?"◆":glyphShape==="star"?"★":String(glyphShape);if(it&&it.size!=null)g.style.fontSize=(typeof it.size==="number"?it.size+"px":String(it.size));item.appendChild(g)}if(it&&it.break!=null){const b=document.createElement("span");b.className="c-legend__break";b.textContent=String(it.break);item.appendChild(b)}const lbl=document.createElement("span");lbl.textContent=label;item.appendChild(lbl);const caption=(typeof it==="object"&&it)?(it.caption||it.note||""):"";if(caption){const cap=document.createElement("span");cap.className="c-legend__caption";cap.textContent=caption;item.appendChild(cap)}if(it&&(it.threshold||it.break!=null)){sw.style.outline="2px solid var(--color-border-strong)"}list.appendChild(item)})}catch(e){warnBadJson(this,"attribute",e)}}else{const list=this.querySelector(".c-legend__items");if(list)list.remove();const hasOther=this.getAttribute("title")||this.getAttribute("ramp")||this.getAttribute("scale")||this.getAttribute("method")||this.getAttribute("norm");if(!hasOther){renderEmpty(this,"legend")}}const caption=this.getAttribute("caption");let captionEl=this.querySelector(".c-legend__caption");if(caption){if(!captionEl){captionEl=document.createElement("span");captionEl.className="c-legend__caption";this.appendChild(captionEl)}captionEl.id=captionEl.id||("legend-caption-"+Math.random().toString(36).slice(2));captionEl.textContent=caption;captionEl.style.position="absolute";captionEl.style.width="1px";captionEl.style.height="1px";captionEl.style.overflow="hidden";captionEl.style.clip="rect(0,0,0,0)"}else if(captionEl){captionEl.remove()}const _items=this.querySelector(".c-legend__items");if(_items){const opts=Array.from(_items.querySelectorAll(".c-legend__item"));opts.forEach((o,i)=>o.setAttribute("tabindex",i===0?"0":"-1"));if(captionEl)opts.forEach((o)=>o.setAttribute("aria-describedby",captionEl.id))}const ndColor=this.getAttribute("no-data-color");const ndLabel=this.getAttribute("no-data-label")||"No data";if(ndColor){let nd=this.querySelector(".c-legend__no-data");if(!nd){nd=document.createElement("div");nd.className="c-legend__no-data";this.appendChild(nd)}nd.setAttribute("part","no-data");nd.setAttribute("aria-label",ndLabel);nd.textContent=ndLabel;const glyph=document.createElement("span");glyph.className="glyph";glyph.style.background=ndColor;glyph.dataset.color=ndColor;nd.prepend(glyph)}else{const nd=this.querySelector(".c-legend__no-data");if(nd)nd.remove()}const audit=this.getAttribute("audit");if(audit){const a=this.ensure(".c-legend__audit",()=>{const el=document.createElement("div");el.className="c-legend__audit";return el});a.textContent=audit}else{const a=this.querySelector(".c-legend__audit");if(a)a.remove()}if(this.hasAttribute("continuous")){const ends=this.getAttribute("ends");let parsedEnds=null;if(ends){try{parsedEnds=JSON.parse(ends)}catch(e){parsedEnds=ends.split(",")}}if(Array.isArray(parsedEnds)&&parsedEnds.length>=2){const r=this.ensure(".c-legend__ramp",()=>{const el=document.createElement("div");el.className="c-legend__ramp";return el});let left=this.querySelector(".c-legend__ramp-label--start");if(!left){left=document.createElement("span");left.className="c-legend__ramp-label c-legend__ramp-label--start";r.appendChild(left)}left.textContent=parsedEnds[0];let right=this.querySelector(".c-legend__ramp-label--end");if(!right){right=document.createElement("span");right.className="c-legend__ramp-label c-legend__ramp-label--end";r.appendChild(right)}right.textContent=parsedEnds[parsedEnds.length-1]}}const sizeAttr=this.getAttribute("size");if(sizeAttr){const sc=this.ensure(".c-legend__size",()=>{const el=document.createElement("div");el.className="c-legend__size";return el});sc.textContent=sizeAttr}else{const sc=this.querySelector(".c-legend__size");if(sc)sc.remove()}const classification=this.getAttribute("classification");if(classification){const c=this.ensure(".c-legend__classification",()=>{const el=document.createElement("div");el.className="c-legend__classification";return el});c.textContent=classification}else{const c=this.querySelector(".c-legend__classification");if(c)c.remove()}const tableAttr=this.getAttribute("table");if(tableAttr){let parsed=null;try{parsed=JSON.parse(tableAttr)}catch(e){parsed=null}if(Array.isArray(parsed)){let det=this.querySelector(".c-legend__table-wrap");if(!det){det=document.createElement("details");det.className="c-legend__table-wrap";this.appendChild(det)}det.innerHTML="";const sum=document.createElement("summary");sum.textContent=labelText(this,"data-table","Data table");det.appendChild(sum);const tbl=document.createElement("table");tbl.className="c-legend__table";const tbody=document.createElement("tbody");parsed.forEach((row)=>{const tr=document.createElement("tr");const cells=Array.isArray(row)?row:[row.label??row.key??"",row.value??""];cells.forEach((cell)=>{const td=document.createElement("td");td.textContent=cell;tr.appendChild(td)});tbody.appendChild(tr)});tbl.appendChild(tbody);det.appendChild(tbl)}}else{const det=this.querySelector(".c-legend__table-wrap");if(det)det.remove()}if(items){}const method=this.getAttribute("method");if(method){const m=this.ensure(".c-legend__method",()=>{const el=document.createElement("div");el.className="c-legend__method";return el});m.textContent=method}else{const m=this.querySelector(".c-legend__method");if(m)m.remove()}const norm=this.getAttribute("norm");if(norm){const n=this.ensure(".c-legend__norm",()=>{const el=document.createElement("span");el.className="c-legend__norm";return el});n.textContent=norm}else{const n=this.querySelector(".c-legend__norm");if(n)n.remove()}const ramp=this.getAttribute("ramp");if(ramp){const r=this.ensure(".c-legend__ramp",()=>{const el=document.createElement("div");el.className="c-legend__ramp";return el});r.style.background=ramp;const breaksAttr=this.getAttribute("breaks");if(breaksAttr){let breaks=null;try{breaks=JSON.parse(breaksAttr)}catch(e){breaks=breaksAttr.split(",").map((s)=>s.trim())}if(Array.isArray(breaks)){Array.from(r.querySelectorAll(".c-legend__ramp-segment")).forEach((n)=>n.remove());breaks.forEach((b,i)=>{const seg=document.createElement("span");seg.className="c-legend__ramp-segment";seg.style.flex="1";const lbl=document.createElement("span");lbl.className="c-legend__ramp-break";lbl.textContent=String(b);seg.appendChild(lbl);r.appendChild(seg)})}}}else{const r=this.querySelector(".c-legend__ramp");if(r)r.remove()}const scale=this.getAttribute("scale");if(scale){const sc=this.ensure(".c-legend__scale",()=>{const el=document.createElement("div");el.className="c-legend__scale";return el});sc.textContent=scale}else{const sc=this.querySelector(".c-legend__scale");if(sc)sc.remove()}}enhance(){if(this._wiredLegend)return;this._wiredLegend=true;const selectable=this.hasAttribute("selectable");this.addEventListener("click",(e)=>{if(!selectable)return;const btn=e.target&&e.target.closest?e.target.closest(".c-legend__item"):null;if(!btn||!this.contains(btn))return;const pressed=btn.getAttribute("aria-pressed")!=="true";btn.setAttribute("aria-pressed",String(pressed));const items=Array.from(this.querySelectorAll(".c-legend__item"));const index=items.indexOf(btn);this.dispatchEvent(new CustomEvent("contour:legend-toggle",{detail:{label:btn.textContent.trim(),key:btn.dataset.key||btn.textContent.trim(),pressed,index},bubbles:true,composed:true,}));this.dispatchEvent(new CustomEvent("contour:select",{detail:{label:btn.textContent.trim(),key:btn.dataset.key||btn.textContent.trim(),value:btn.dataset.key||btn.textContent.trim()},bubbles:true,composed:true,}))});try{let parsed=null;try{parsed=JSON.parse(this.getAttribute("items")||"null")}catch(e){parsed=this.getAttribute("items")}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:this.getAttribute("items"),items:parsed},bubbles:true,composed:true}))}catch(e){}this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList&&t.classList.contains("c-legend__break-input")){this.dispatchEvent(new CustomEvent("contour:break-change",{detail:{value:t.value},bubbles:true,composed:true}))}});if(selectable){this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-legend__item"));if(!items.length)return;const active=document.activeElement;const idx=items.indexOf(active);if(e.key==="Escape"){items.forEach((o)=>o.setAttribute("aria-pressed","false"));this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:true,composed:true}));return}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){if(items.length>7){const start=idx>=0?idx+1:0;for(let i=0;i<items.length;i++){const ii=(start+i)%items.length;const txt=(items[ii].textContent||"").trim().toLowerCase();if(txt.startsWith(e.key.toLowerCase())){e.preventDefault();items[ii].focus();items.forEach((o,j)=>o.setAttribute("tabindex",j===ii?"0":"-1"));break}}}return}if(e.key==="Enter"||e.key===" "){e.preventDefault();if(active&&active.classList.contains("c-legend__item")){active.click()}return}navKey(e,items,{wrap:true,homeEnd:true,rtl:isRtl(this),onNavigate:(i)=>items.forEach((o,j)=>o.setAttribute("tabindex",j===i?"0":"-1")),onKey:()=>{}})})}this.addEventListener("contour:clear-all",()=>{const items=Array.from(this.querySelectorAll(".c-legend__item"));let changed=false;items.forEach((o)=>{if(o.getAttribute("role")==="button"&&o.getAttribute("aria-pressed")==="true"){o.setAttribute("aria-pressed","false");changed=true}});if(changed){this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:true,composed:true,detail:{source:"legend",filter:{selection:null}}}))}})}}define("contour-legend",ContourLegend);class ContourMeasure extends ContourBase{static get observed(){return["label","value","point","line","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},point:{attribute:"point"},line:{attribute:"line"},src:{attribute:"src"}}}render(){this.classList.add("c-measure");this.setAttribute("role","group");this.setAttribute("aria-label","Measure");wireStates(this);loadRemote(this,["label","value","point","line"]);if(renderStates(this,"measure"))return;const rLabel=remoteData(this,"label");const rValue=remoteData(this,"value");const rPoint=remoteData(this,"point");const rLine=remoteData(this,"line");if(!rLabel&&!rValue&&!rPoint&&!rLine){renderEmpty(this,"measure");return}if(rLabel){const l=this.ensure(".c-measure__label",()=>{const el=document.createElement("span");el.className="c-measure__label";return el});l.textContent=rLabel}else{const l=this.querySelector(".c-measure__label");if(l)l.remove()}if(rValue){const r=this.ensure(".c-measure__readout",()=>{const el=document.createElement("span");el.className="c-measure__readout";return el});r.textContent=rValue}else{const r=this.querySelector(".c-measure__readout");if(r)r.remove()}let sel=this.querySelector(".c-measure__unit-select");if(!sel){sel=document.createElement("select");sel.className="c-measure__unit-select";this.appendChild(sel)}["m","km","mi","ft"].forEach((u)=>{if(!sel.querySelector('option[value="'+u+'"]')){const o=document.createElement("option");o.value=u;o.textContent=u;sel.appendChild(o)}});if(rPoint){const p=this.ensure(".c-measure__point",()=>{const el=document.createElement("span");el.className="c-measure__point";return el});p.textContent=rPoint}else{const p=this.querySelector(".c-measure__point");if(p)p.remove()}if(!rLine){const svg=this.querySelector("svg");if(svg)svg.remove();return}if(rLine){const ln=this.ensure(".c-measure__line",()=>{const el=document.createElement("span");el.className="c-measure__line";return el});ln.style.inlineSize=rLine}else{const ln=this.querySelector(".c-measure__line");if(ln)ln.remove()}}enhance(){if(this._wiredMeasure)return;this._wiredMeasure=true;this.addEventListener("change",(e)=>{const sel=e.target&&e.target.closest?e.target.closest(".c-measure__unit-select"):null;if(sel&&this.contains(sel)){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{unit:sel.value}}))}})}}define("contour-measure",ContourMeasure);class ContourTimeline extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-timeline");let list=this.querySelector(".c-timeline__list");if(!list){list=document.createElement("ol");list.className="c-timeline__list";list.setAttribute("aria-label",this.getAttribute("aria-label")||"Timeline");this.appendChild(list)}wireStates(this);loadRemote(this,"items");if(renderStates(this,"timeline"))return;const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-timeline__item"));const items=remoteData(this,"items");if(items&&!authored.length){Array.from(list.querySelectorAll(".c-timeline__item")).forEach((n)=>n.remove());try{const parsed=JSON.parse(items);parsed.forEach((it)=>{const item=document.createElement("li");item.className="c-timeline__item";item.setAttribute("tabindex","-1");if(it.time){const t=document.createElement("time");t.className="c-timeline__time";t.setAttribute("datetime",String(it.time));t.textContent=it.time;item.appendChild(t)}if(it.title){const ti=document.createElement("div");ti.className="c-timeline__title";ti.textContent=it.title;item.appendChild(ti)}if(it.text){const tx=document.createElement("div");tx.className="c-timeline__text";tx.textContent=it.text;item.appendChild(tx)}list.appendChild(item)})}catch(e){warnBadJson(this,"attribute",e)}}else if(!authored.length){renderEmpty(this,"timeline")}}enhance(){if(this._wiredTimeline)return;this._wiredTimeline=true;const items=Array.from(this.querySelectorAll(".c-timeline__item"));items.forEach((it,i)=>it.setAttribute("tabindex",i===0?"0":"-1"));this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-timeline__item"):null;if(!item||!this.contains(item))return;const items=Array.from(this.querySelectorAll(".c-timeline__item"));const idx=items.indexOf(item);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx}}))});this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-timeline__item"));if(!items.length)return;navKey(e,items,{wrap:false,homeEnd:true,onNavigate:(i)=>items.forEach((it,j)=>it.setAttribute("tabindex",j===i?"0":"-1")),onKey:()=>{if(e.key==="Enter"||e.key===" ")this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:items.indexOf(document.activeElement)}}))}})})}}define("contour-timeline",ContourTimeline);class ContourHeatmap extends ContourBase{static get observed(){return["cells","count","legend","empty","loading","values","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{cells:{attribute:"cells"},count:{attribute:"count"},legend:{attribute:"legend"},src:{attribute:"src"}}}render(){this.classList.add("c-heatmap");if(!this.hasAttribute("role"))this.setAttribute("role","grid");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Heatmap");wireStates(this);loadRemote(this,"cells");if(renderStates(this,"heatmap"))return;const authoredCells=Array.from(this.querySelectorAll(":scope > .c-heatmap__cell"));if(authoredCells.length){const cols=Math.ceil(Math.sqrt(authoredCells.length));this.style.gridTemplateColumns="repeat("+cols+", 1fr)";this.style.inlineSize="16rem";let row=null;let col=0;const newRow=()=>{row=document.createElement("div");row.setAttribute("role","row");this.appendChild(row);col=0};newRow();authoredCells.forEach((cell)=>{cell.setAttribute("role","gridcell");row.appendChild(cell);col++;if(col===cols)newRow()})}else{Array.from(this.querySelectorAll(".c-heatmap__cell")).forEach((n)=>n.remove());const count=Math.min(200,Math.max(0,parseInt(this.getAttribute("cells")||this.getAttribute("count")||"0",10)||0));const cols=count>0?Math.ceil(Math.sqrt(count)):1;this.style.gridTemplateColumns="repeat("+cols+", 1fr)";this.style.inlineSize="16rem";if(count>0){let values=[];try{values=JSON.parse(this.getAttribute("values")||"[]")}catch(e){values=[]}let row=null;let col=0;const newRow=()=>{row=document.createElement("div");row.setAttribute("role","row");this.appendChild(row);col=0};newRow();for(let i=0;i<count;i++){const cell=document.createElement("div");cell.className="c-heatmap__cell";cell.setAttribute("role","gridcell");cell.setAttribute("tabindex",i===0?"0":"-1");cell.dataset.index=String(i);if(values[i]!==undefined)cell.setAttribute("title",String(values[i]));row.appendChild(cell);col++;if(col===cols&&i<count-1)newRow()}const tip=this.ensure(".c-heatmap__tooltip",()=>{const el=document.createElement("div");el.className="c-heatmap__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}else if(!authoredCells.length){renderEmpty(this,"heatmap")}}if(this.hasAttribute("legend")){const leg=this.ensure(".c-heatmap__legend",()=>{const el=document.createElement("div");el.className="c-heatmap__legend";const bar=document.createElement("div");bar.className="c-heatmap__legend-bar";el.appendChild(bar);return el})}else{const leg=this.querySelector(".c-heatmap__legend");if(leg)leg.remove()}}enhance(){if(this._wiredHeatmap)return;this._wiredHeatmap=true;const cells=()=>Array.from(this.querySelectorAll(".c-heatmap__cell"));const showTip=(e)=>{const tip=this.querySelector(".c-heatmap__tooltip");if(!tip)return;const cell=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!cell||!this.contains(cell)){tip.setAttribute("hidden","");return}const title=cell.getAttribute("title");if(title)tip.textContent=title;else tip.textContent=labelText(this,"cell","Cell")+" "+(cell.dataset.index||"");const rect=this.getBoundingClientRect();const cr=cell.getBoundingClientRect();this.style.position=this.style.position||"relative";tip.style.setProperty("--chart-tip-inline-start",(cr.left-rect.left+cr.width/2)+"px");tip.style.setProperty("--chart-tip-block-start",(cr.top-rect.top)+"px");tip.removeAttribute("hidden")};const hideTip=()=>{const tip=this.querySelector(".c-heatmap__tooltip");if(tip)tip.setAttribute("hidden","")};this.addEventListener("mouseover",showTip);this.addEventListener("mouseout",(e)=>{if(!e.relatedTarget||!this.contains(e.relatedTarget))hideTip()});this.addEventListener("focusin",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(cell&&this.contains(cell))showTip({target:cell})});this.addEventListener("focusout",(e)=>{if(!this.contains(e.relatedTarget))hideTip()});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!cell||!this.contains(cell))return;const list=cells();const idx=list.indexOf(cell);let next=-1;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";if(e.key==="ArrowRight")next=rtl?Math.max(idx-1,0):Math.min(idx+1,list.length-1);else if(e.key==="ArrowLeft")next=rtl?Math.min(idx+1,list.length-1):Math.max(idx-1,0);else if(e.key==="ArrowDown")next=Math.min(idx+Math.ceil(Math.sqrt(list.length)),list.length-1);else if(e.key==="ArrowUp")next=Math.max(idx-Math.ceil(Math.sqrt(list.length)),0);else if(e.key==="Home")next=0;else if(e.key==="End")next=list.length-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:1,index:idx}}));return}if(next>=0&&next!==idx){e.preventDefault();list.forEach((c,i)=>c.setAttribute("tabindex",i===next?"0":"-1"));try{list[next].focus()}catch(e){}}});this.addEventListener("click",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!cell||!this.contains(cell))return;const idx=cells().indexOf(cell);if(idx>=0)this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:1,index:idx}}))})}}define("contour-heatmap",ContourHeatmap);class ContourCompare extends ContourBase{static get observed(){return["no","text","yes","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}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");this.setAttribute("aria-label","Comparison");wireStates(this);loadRemote(this,["no","text","yes"]);if(renderStates(this,"compare"))return;const rYes=remoteData(this,"yes")||(this._remoteData&&this._remoteData.yes);const rNo=remoteData(this,"no")||(this._remoteData&&this._remoteData.no);const rText=remoteData(this,"text")||(this._remoteData&&this._remoteData.text);Array.from(this.querySelectorAll(".c-compare__yes, .c-compare__no, .c-compare__text")).forEach((n)=>n.remove());if(rYes){const y=document.createElement("span");y.className="c-compare__yes";y.innerHTML='<svg aria-hidden="true"><use href="#i-check" /></svg>';this.appendChild(y)}if(rNo){const n=document.createElement("div");n.className="c-compare__no";n.textContent=rNo;this.appendChild(n)}if(rText){const t=document.createElement("p");t.className="c-compare__text";t.textContent=rText;this.appendChild(t)}if(!rYes&&!rNo&&!rText){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"]}static get properties(){return{points:{attribute:"points"},src:{attribute:"src"}}}render(){this.classList.add("c-sparkline");if(!this.hasAttribute("role"))this.setAttribute("role","img");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Sparkline");wireStates(this);loadRemote(this,"points");if(renderStates(this,"sparkline"))return;const points=remoteData(this,"points");if(points){try{const parsed=JSON.parse(points);if(!Array.isArray(parsed)||parsed.length===0)throw new Error("empty");Array.from(this.querySelectorAll(".c-sparkline__dot, .c-sparkline__line, .c-sparkline__area")).forEach((n)=>n.remove());const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("class","c-sparkline__line");svg.setAttribute("viewBox","0 0 100 30");svg.setAttribute("preserveAspectRatio","none");svg.style.inlineSize="100%";svg.style.blockSize="100%";svg.setAttribute("width","100%");svg.setAttribute("height","100%");svg.setAttribute("title",this.getAttribute("aria-label")||"Sparkline");const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("d",parsed.map((p,i)=>(i===0?"M":"L")+" "+(i*100/(parsed.length-1))+" "+(30-p*30)).join(" "));svg.appendChild(path);const dot=document.createElementNS("http://www.w3.org/2000/svg","circle");dot.setAttribute("class","c-sparkline__dot");dot.setAttribute("r","2");dot.setAttribute("cx","0");dot.setAttribute("cy","15");dot.setAttribute("hidden","");svg.appendChild(dot);this.appendChild(svg);this._sparkPoints=parsed;const tip=this.ensure(".c-sparkline__tooltip",()=>{const el=document.createElement("div");el.className="c-sparkline__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}catch(e){Array.from(this.querySelectorAll("svg")).forEach((n)=>n.remove());renderEmpty(this,"sparkline")}}else{renderEmpty(this,"sparkline")}}enhance(){if(this._wiredSparkline)return;this._wiredSparkline=true;if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");const showTip=(e)=>{const svg=this.querySelector("svg");const tip=this.querySelector(".c-sparkline__tooltip");const dot=this.querySelector(".c-sparkline__dot");if(!tip||!svg)return;const rect=svg.getBoundingClientRect();const x=e.clientX-rect.left;const pct=Math.max(0,Math.min(1,x/rect.width));const pts=this._sparkPoints||[];if(pts.length===0)return;const idx=Math.round(pct*(pts.length-1));const val=pts[idx];const cx=(idx*100/(pts.length-1));const cy=30-val*30;if(dot){dot.setAttribute("cx",String(cx));dot.setAttribute("cy",String(cy));dot.removeAttribute("hidden")}tip.textContent=String(val);const tipX=(cx/100)*rect.width;tip.style.setProperty("--chart-tip-inline-start",tipX+"px");tip.style.setProperty("--chart-tip-block-start","0px");tip.removeAttribute("hidden")};const hideTip=()=>{const tip=this.querySelector(".c-sparkline__tooltip");const dot=this.querySelector(".c-sparkline__dot");if(tip)tip.setAttribute("hidden","");if(dot)dot.setAttribute("hidden","")};this.addEventListener("mousemove",showTip);this.addEventListener("mouseleave",hideTip);this.addEventListener("focusin",()=>{const pts=this._sparkPoints||[];if(!pts.length)return;const svg=this.querySelector("svg");if(!svg)return;const r=svg.getBoundingClientRect();showTip({clientX:r.left+r.width-1})});this.addEventListener("focusout",hideTip);this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,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"]}static get properties(){return{title:{attribute:"title"},series:{attribute:"series"},src:{attribute:"src"}}}render(){this.classList.add("c-chart-grid");this.setAttribute("role","group");this.setAttribute("aria-label","Chart grid");wireStates(this);loadRemote(this,"series");if(renderStates(this,"chart-grid"))return;const title=this.getAttribute("title");if(title){const t=this.ensure(".c-chart-grid__title",()=>{const el=document.createElement("div");el.className="c-chart-grid__title";return el});t.textContent=title}const series=remoteData(this,"series");if(!series&&!title)renderEmpty(this,"chart-grid")}}define("contour-chart-grid",ContourChartGrid);class ContourContourPlot extends ContourBase{static get observed(){return["values","levels","label"]}static get properties(){return{values:{attribute:"values"},levels:{attribute:"levels"},label:{attribute:"label"}}}render(){this.classList.add("c-contour-plot");if(!this.hasAttribute("role"))this.setAttribute("role","img");const label=this.getAttribute("label");if(label||!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label||"Contour plot");const valuesAttr=this.getAttribute("values");const levelsAttr=this.getAttribute("levels");let grid=null;if(valuesAttr){try{grid=JSON.parse(valuesAttr)}catch(e){grid=null}}let levels=[0.3,0.5,0.7];if(levelsAttr){try{const l=JSON.parse(levelsAttr);if(Array.isArray(l)&&l.length)levels=l}catch(e){}}let svg=this.querySelector("svg");if(!svg){svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("class","c-contour-plot__svg");svg.setAttribute("aria-hidden","true");this.appendChild(svg)}Array.from(svg.querySelectorAll(".c-contour-plot__contour")).forEach((n)=>n.remove());if(Array.isArray(grid)&&grid.length>1&&Array.isArray(grid[0])&&grid[0].length>1){const draw=()=>{const w=this.clientWidth||300;const h=this.clientHeight||300;svg.setAttribute("viewBox",`0 0 ${w} ${h}`);svg.querySelectorAll(".c-contour-plot__contour").forEach((n)=>n.remove());contourPaths(grid,levels,w,h).forEach((line,li)=>{if(!line.d)return;const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("d",line.d);path.setAttribute("class","c-contour-plot__contour"+(li>0?" c-contour-plot__contour--level-"+(li+1):""));svg.appendChild(path)})};draw();if(typeof ResizeObserver!=="undefined"&&!this._contourResize){this._contourResize=new ResizeObserver(()=>draw());this._contourResize.observe(this);onDispose(this,()=>{this._contourResize.disconnect();this._contourResize=null})}}else if(!Array.isArray(grid)){const empty=document.createElement("div");empty.className="c-contour-plot__empty";empty.textContent=this.getAttribute("empty")||"No field";this.appendChild(empty)}}}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.setAttribute("role","region");this.setAttribute("aria-live","polite");const err=this.getAttribute("error");if(err){this.dataset.state="error";Array.from(this.children).forEach((c)=>{if(!c.hasAttribute("data-fallback"))c.style.display="none"});let fb=this.querySelector("[data-fallback]");if(!fb){fb=document.createElement("div");fb.className="c-error-boundary__fallback";fb.dataset.fallback="";fb.textContent=this.getAttribute("fallback")||"Something went wrong.";this.appendChild(fb)}else{fb.textContent=this.getAttribute("fallback")||fb.textContent||"Something went wrong."}}else{this.dataset.state="ready";Array.from(this.children).forEach((c)=>{c.style.display=""});const fb=this.querySelector("[data-fallback]");if(fb)fb.remove()}}enhance(){if(this._wiredErrorBoundary)return;this._wiredErrorBoundary=true;this.addEventListener("error",(e)=>{e.stopPropagation();const msg=(e&&e.error&&e.error.message)?e.error.message:(e&&e.message)?e.message:"Unknown error";this.setAttribute("error",msg);this.dispatchEvent(new CustomEvent("contour:error",{bubbles:true,composed:true,detail:{message:msg}}))},true)}}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");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Data export");const fmt=(this.getAttribute("format")||"json").toLowerCase();const btn=this.ensure(".c-data-export__btn",()=>{const b=document.createElement("button");b.className="c-data-export__btn";b.type="button";return b});btn.textContent=this.getAttribute("label")||("Export "+fmt.toUpperCase());if(btn.parentNode!==this)this.appendChild(btn)}enhance(){if(this._wiredDataExport)return;this._wiredDataExport=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-data-export__btn"):null;if(!btn||!this.contains(btn))return;const fmt=(this.getAttribute("format")||"json").toLowerCase();const raw=this.getAttribute("data")||"[]";let text=raw;if(fmt==="csv"){try{const arr=JSON.parse(raw);if(Array.isArray(arr)&&arr.length){const keys=Object.keys(arr[0]);text=[keys.join(",")].concat(arr.map((r)=>keys.map((k)=>JSON.stringify(r[k]??"")).join(","))).join("\n")}}catch(e){}}const blob=new Blob([text],{type:fmt==="csv"?"text/csv":"application/json"});const url=URL.createObjectURL(blob);const a=document.createElement("a");a.href=url;a.download=this.getAttribute("filename")||("export."+fmt);document.body.appendChild(a);a.click();a.remove();URL.revokeObjectURL(url);this.dispatchEvent(new CustomEvent("contour:export",{bubbles:true,composed:true,detail:{format:fmt}}))})}}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"}}}render(){this.classList.add("c-query-builder");const fields=this.getAttribute("fields");let fieldList=[];if(fields){try{fieldList=JSON.parse(fields)}catch(e){fieldList=[]}}const query=this.getAttribute("query");let rules=[];if(query){try{rules=JSON.parse(query)}catch(e){rules=[]}}const list=this.ensure(".c-query-builder__list",()=>{const el=document.createElement("div");el.className="c-query-builder__list";return el});Array.from(list.querySelectorAll(".c-query-builder__row, .c-query-builder__connector")).forEach((n)=>n.remove());rules.forEach((rule,i)=>{if(i>0){const conn=document.createElement("div");conn.className="c-query-builder__connector";const sel=document.createElement("select");sel.className="c-query-builder__op";sel.setAttribute("aria-label","Connector "+i);["AND","OR"].forEach((c)=>{const opt=document.createElement("option");opt.value=c;opt.textContent=c;if(c===(rule.connector||"AND"))opt.selected=true;sel.appendChild(opt)});conn.appendChild(sel);list.appendChild(conn)}const row=document.createElement("div");row.className="c-query-builder__row";const field=document.createElement("select");field.className="c-query-builder__field";field.setAttribute("aria-label","Field "+(i+1));fieldList.forEach((f)=>{const opt=document.createElement("option");opt.value=typeof f==="string"?f:(f.value||f.label||"");opt.textContent=typeof f==="string"?f:(f.label||f.value||"");if(opt.value===rule.field)opt.selected=true;field.appendChild(opt)});const op=document.createElement("select");op.className="c-query-builder__op";op.setAttribute("aria-label","Operator "+(i+1));["=","!=",">","<","contains"].forEach((o)=>{const opt=document.createElement("option");opt.value=o;opt.textContent=o;if(o===rule.op)opt.selected=true;op.appendChild(opt)});const val=document.createElement("input");val.className="c-query-builder__value";val.type="text";val.value=rule.value||"";val.setAttribute("aria-label","Value "+(i+1));const remove=document.createElement("button");remove.type="button";remove.className="c-btn c-btn--sm c-btn--ghost c-query-builder__remove";remove.setAttribute("aria-label","Remove rule "+(i+1));remove.textContent="×";row.appendChild(field);row.appendChild(op);row.appendChild(val);row.appendChild(remove);list.appendChild(row)});const add=this.ensure(".c-query-builder__add",()=>{const b=document.createElement("button");b.type="button";b.className="c-btn c-btn--sm c-query-builder__add";return b});add.textContent=labelText(this,"add-rule","Add rule");if(add.parentNode!==this)this.appendChild(add)}enhance(){if(this._wiredQueryBuilder)return;this._wiredQueryBuilder=true;this.addEventListener("click",(e)=>{const t=e.target;if(t&&t.closest&&t.closest(".c-query-builder__add")){const rows=Array.from(this.querySelectorAll(".c-query-builder__row")).map((r)=>({field:r.querySelector(".c-query-builder__field")?.value||"",op:r.querySelector(".c-query-builder__op")?.value||"=",value:r.querySelector(".c-query-builder__value")?.value||"",}));rows.push({field:"",op:"=",value:""});this.setAttribute("query",JSON.stringify(rows));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{query:rows}}))}if(t&&t.closest&&t.closest(".c-query-builder__remove")){const row=t.closest(".c-query-builder__row");if(!row)return;const rows=Array.from(this.querySelectorAll(".c-query-builder__row")).map((r)=>({field:r.querySelector(".c-query-builder__field")?.value||"",op:r.querySelector(".c-query-builder__op")?.value||"=",value:r.querySelector(".c-query-builder__value")?.value||"",}));const idx=Array.from(this.querySelectorAll(".c-query-builder__row")).indexOf(row);if(idx>=0)rows.splice(idx,1);this.setAttribute("query",JSON.stringify(rows));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{query:rows}}))}})}}define("contour-query-builder",ContourQueryBuilder);const routeKey=(value)=>{const raw=String(value==null?"":value).trim();if(!raw)return"";if(raw.startsWith("#"))return"hash:"+raw;try{const base=typeof location!=="undefined"?location.href:"http://localhost/";const url=new URL(raw,base);return"path:"+url.pathname.replace(/\/+$/,"")+url.search}catch(e){return"raw:"+raw}};const hereKey=(explicit)=>{const raw=String(explicit==null?"":explicit).trim();if(raw)return routeKey(raw);if(typeof location==="undefined")return"";return"path:"+String(location.pathname||"").replace(/\/+$/,"")+(location.search||"")};const hashMatchesHere=(hash)=>{if(typeof location==="undefined")return false;if(location.hash&&location.hash===hash)return true;const segment=String(location.pathname||"").split("/").filter(Boolean).pop()||"";return Boolean(segment)&&hash==="#"+segment};class ContourDocsNav extends ContourBase{static get observed(){return["items","title","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},title:{attribute:"title"},src:{attribute:"src"}}}render(){this.classList.add("c-docs-nav");this.setAttribute("role","navigation");const title=this.getAttribute("title");if(title)this.setAttribute("aria-label",title);else this.setAttribute("aria-label","Documentation navigation");wireStates(this);loadRemote(this,"items");if(renderStates(this,"docs-nav"))return;const _remote=remoteData(this,"items");const items=this.hasAttribute("src")?_remote:(_remote||(this.hasAttribute("items")?this.getAttribute("items"):null));const list=this.querySelector(".c-docs-nav__list");const authored=list?Array.from(list.children).filter((n)=>n.classList&&n.classList.contains("c-docs-nav__group")):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const list=this.ensure(".c-docs-nav__list",()=>{const el=document.createElement("div");el.className="c-docs-nav__list";return el});list.innerHTML="";parsed.forEach((g)=>{const group=document.createElement("div");group.className="c-docs-nav__group";if(g.title){const gt=document.createElement("div");gt.className="c-docs-nav__group-title";gt.textContent=g.title;group.appendChild(gt)}const ul=document.createElement("div");ul.className="c-docs-nav__list";(g.links||g.items||[]).forEach((l)=>{const a=document.createElement("a");a.className="c-docs-nav__link";a.href=safeHref(typeof l==="string"?"#":(l.href||"#"));const label=typeof l==="string"?l:(l.label||l);if(typeof l==="object"&&l!==null&&l.badge){const b=document.createElement("span");b.className="c-docs-nav__badge";b.textContent=l.badge;a.appendChild(b)}a.appendChild(document.createTextNode(label));if(typeof l==="object"&&l!==null&&l.chevron){const ch=document.createElement("span");ch.className="c-docs-nav__chevron";ch.textContent=l.chevron;a.appendChild(ch)}if(typeof l==="object"&&l!==null&&Array.isArray(l.items)){a.classList.add("c-docs-nav__link--nested");const nested=document.createElement("div");nested.className="c-docs-nav__list c-docs-nav__list--nested";l.items.forEach((nl)=>{const na=document.createElement("a");na.className="c-docs-nav__link";na.href=safeHref(typeof nl==="string"?"#":(nl.href||"#"));na.textContent=typeof nl==="string"?nl:(nl.label||nl);nested.appendChild(na)});ul.appendChild(a);ul.appendChild(nested)}else{ul.appendChild(a)}});group.appendChild(ul);list.appendChild(group)})}catch(e){warnBadJson(this,"attribute",e)}}else if(!items&&list){list.remove();renderEmpty(this,"docs-nav")}else if(!items&&!list){renderEmpty(this,"docs-nav")}this.applyCurrent()}applyCurrent(){const links=Array.from(this.querySelectorAll(".c-docs-nav__link"));if(!links.length)return;const explicit=this.getAttribute("current");const here=hereKey(explicit);links.forEach((a)=>{const href=a.getAttribute("href")||"";const key=routeKey(href);const hit=Boolean(here)&&((key&&key===here)||(href.startsWith("#")&&!explicit&&hashMatchesHere(href)));if(hit)a.setAttribute("aria-current","page");else a.removeAttribute("aria-current")})}enhance(){if(this._wiredDocsNav)return;this._wiredDocsNav=true;this.addEventListener("click",(e)=>{const link=e.target&&e.target.closest?e.target.closest(".c-docs-nav__link"):null;if(link&&this.contains(link)){const label=link.textContent||"";this.dispatchEvent(new CustomEvent("contour:docs-nav-select",{bubbles:true,composed:true,detail:{label,href:link.getAttribute("href")}}))}});this.addEventListener("keydown",(e)=>{const links=Array.from(this.querySelectorAll(".c-docs-nav__link"));if(!links.length)return;if(!links.some((l)=>l.tabIndex===0))links.forEach((l,i)=>l.tabIndex=i===0?0:-1);navKey(e,links,{wrap:true,homeEnd:true,onNavigate:(i)=>{links.forEach((l,j)=>l.tabIndex=j===i?0:-1)},onKey:(k)=>{if(k==="Enter"){const a=document.activeElement;if(a){e.preventDefault();a.click()}}}})});if(typeof window!=="undefined"&&window.addEventListener){const sync=()=>this.applyCurrent();window.addEventListener("hashchange",sync);window.addEventListener("popstate",sync);onDispose(this,()=>{window.removeEventListener("hashchange",sync);window.removeEventListener("popstate",sync)})}}}define("contour-docs-nav",ContourDocsNav);class ContourDocsShell extends ContourBase{static get observed(){return["title","lede","article","heading"]}static get properties(){return{title:{attribute:"title"},lede:{attribute:"lede"},article:{attribute:"article"}}}render(){this.classList.add("c-docs-shell");this.setAttribute("role","region");const title=this.getAttribute("title");if(title){const h=this.ensure(".c-docs-shell__title",()=>{const el=document.createElement(headingTag(this,"h2"));el.className="c-docs-shell__title";return el});h.textContent=title;this.setAttribute("aria-label",title)}else{const h=this.querySelector(".c-docs-shell__title");if(h)h.remove()}const lede=this.getAttribute("lede");if(lede){const p=this.ensure(".c-docs-shell__lede",()=>{const el=document.createElement("p");el.className="c-docs-shell__lede";return el});p.textContent=lede}else{const p=this.querySelector(".c-docs-shell__lede");if(p)p.remove()}const article=this.getAttribute("article");if(article){const a=this.ensure(".c-docs-shell__article",()=>{const el=document.createElement("article");el.className="c-docs-shell__article";return el});a.innerHTML=sanitizeHtml(article)}else{const a=this.querySelector(".c-docs-shell__article");if(a)a.remove()}}}define("contour-docs-shell",ContourDocsShell);class ContourFileTree extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items"]}static get properties(){return{items:{attribute:"items"}}}render(){this.classList.add("c-file-tree");const items=this.getAttribute("items");if(items){try{const parsed=JSON.parse(items);const renderNode=(node,depth)=>{const row=document.createElement("div");row.className="c-file-tree__row"+(node.dir?" c-file-tree__row--dir":"")+(node.active?" c-file-tree__row--active":"");row.style.paddingInlineStart=(depth*1)+"rem";const label=document.createElement("span");label.textContent=node.label||node.name||"";row.appendChild(label);this.appendChild(row);if(Array.isArray(node.children)){node.children.forEach((c)=>renderNode(c,depth+1))}};Array.from(this.querySelectorAll(".c-file-tree__row")).forEach((n)=>n.remove());parsed.forEach((n)=>renderNode(n,0))}catch(e){warnBadJson(this,"attribute",e)}}}}define("contour-file-tree",ContourFileTree);class ContourChangelog extends ContourBase{static get observed(){return["src","max","loading","error"]}static get properties(){return{src:{attribute:"src"},max:{attribute:"max",type:Number}}}render(){this.classList.add("c-changelog");const src=this.getAttribute("src");if(src){if(this.dataset.loaded===src)return;this.dataset.loaded="";const loading=this.ensure(".c-changelog__loading",()=>{const el=document.createElement("div");el.className="c-changelog__loading";return el});loading.textContent=labelText(this,"loading","Loading…");Array.from(this.querySelectorAll(".c-changelog__entry, .c-changelog__error")).forEach((n)=>n.remove());if(!this.querySelector(".c-changelog__loading"))this.appendChild(loading);try{if(this._changelogAbort)this._changelogAbort.abort()}catch(e){}this._changelogAbort=typeof AbortController!=="undefined"?new AbortController():null;fetch(src,this._changelogAbort?{signal:this._changelogAbort.signal}:undefined).then((r)=>{if(!r.ok)throw new Error("HTTP "+r.status);return r.text()}).then((text)=>{if(!this.isConnected)return;const ld=this.querySelector(".c-changelog__loading");if(ld)ld.remove();this.dataset.loaded=src;const entries=parseChangelog(text);const max=parseInt(this.getAttribute("max")||"0",10);const list=(max>0)?entries.slice(0,max):entries;if(!list.length){const empty=document.createElement("div");empty.className="c-changelog__empty";empty.textContent=labelText(this,"empty","No releases found.");this.appendChild(empty);return}list.forEach((e)=>{const det=document.createElement("details");det.className="c-changelog__entry";const sum=document.createElement("summary");sum.className="c-changelog__summary";const ver=document.createElement("span");ver.className="c-changelog__version";ver.textContent=e.version;sum.appendChild(ver);if(e.date){const d=document.createElement("span");d.className="c-changelog__date";d.textContent=e.date;sum.appendChild(d)}det.appendChild(sum);const body=document.createElement("div");body.className="c-changelog__body";body.innerHTML=renderChangelogBody(e.body);det.appendChild(body);this.appendChild(det)})}).catch((err)=>{if(!this.isConnected)return;const ld=this.querySelector(".c-changelog__loading");if(ld)ld.remove();const er=document.createElement("div");er.className="c-changelog__error";er.textContent=labelText(this,"load-error","Failed to load changelog")+": "+(err&&err.message?err.message:err);this.appendChild(er)})}}disconnectedCallback(){super.disconnectedCallback();try{if(this._changelogAbort)this._changelogAbort.abort()}catch(e){}this._changelogAbort=null}}define("contour-changelog",ContourChangelog);function parseChangelog(text){const lines=String(text).split(/\r?\n/);const entries=[];let cur=null;for(const line of lines){const m=line.match(/^##\s+\[?([^\]\n]+)\]?\s*[-–—]?\s*(.*)$/);if(m&&(line.startsWith("## "))){const ver=m[1].trim();const rest=m[2].trim();if(/^\d|unreleased/i.test(ver)){if(cur)entries.push(cur);cur={version:ver,date:rest.replace(/^[-–—]\s*/,"").trim(),body:""};continue}}if(cur)cur.body+=line+"\n"}if(cur)entries.push(cur);return entries}function escapeHtml(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function renderChangelogBody(body){const lines=String(body).trim().split(/\r?\n/);const out=[];let inList=false;for(const raw of lines){const line=raw.trimEnd();if(/^###\s+/.test(line)){if(inList){out.push("</ul>");inList=false}out.push("<h3>"+escapeHtml(line.replace(/^###\s+/,""))+"</h3>")}else if(/^##\s+/.test(line)){if(inList){out.push("</ul>");inList=false}out.push("<h2>"+escapeHtml(line.replace(/^##\s+/,""))+"</h2>")}else if(/^#\s+/.test(line)){if(inList){out.push("</ul>");inList=false}out.push("<h2>"+escapeHtml(line.replace(/^#\s+/,""))+"</h2>")}else if(/^[-*]\s+/.test(line)){if(!inList){out.push("<ul>");inList=true}out.push("<li>"+escapeHtml(line.replace(/^[-*]\s+/,""))+"</li>")}else if(line.trim()===""){if(inList){out.push("</ul>");inList=false}}else{if(inList){out.push("</ul>");inList=false}out.push("<p>"+escapeHtml(line)+"</p>")}}if(inList)out.push("</ul>");return out.join("")}class ContourDialog extends ContourBase{static get observed(){return["title","size","heading"]}static get properties(){return{title:{attribute:"title"},size:{attribute:"size"}}}showModal(){this.show()}get open(){return this.hasAttribute("open")}set open(v){if(v)this.show();else this.close()}render(){this.classList.add("c-dialog");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-dialog--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-dialog--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","dialog");const title=this.getAttribute("title");let head=this.querySelector(".c-dialog__head");if(title){if(!head){head=document.createElement("div");head.className="c-dialog__head";const h=document.createElement(headingTag(this,"h2"));h.className="c-dialog__title";head.appendChild(h);const closeBtn=document.createElement("button");closeBtn.className="c-btn c-btn--icon c-btn--ghost c-dialog__close";closeBtn.setAttribute("type","button");closeBtn.setAttribute("aria-label","Close");closeBtn.innerHTML='<svg aria-hidden="true"><use href="#i-x" /></svg>';head.appendChild(closeBtn)}const h=head.querySelector(".c-dialog__title");if(h){h.textContent=title;if(!h.id)h.id=contourId("contour-dialog-title");this.setAttribute("aria-labelledby",h.id)}}if(head&&head.parentNode!==this)this.prepend(head);const body=this.ensure(".c-dialog__body",()=>{const el=document.createElement("div");el.className="c-dialog__body";return el});Array.from(this.childNodes).forEach((n)=>{if(n===body||n===head)return;if(n.nodeType===1&&n.classList&&n.classList.contains("c-dialog__head"))return;body.appendChild(n)});if(head&&head.parentNode===this){if(body.parentNode!==this)this.insertBefore(body,head.nextSibling);else if(head.compareDocumentPosition(body)&Node.DOCUMENT_POSITION_PRECEDING)this.insertBefore(body,head.nextSibling)}else{if(body.parentNode!==this)this.appendChild(body)}}enhance(){if(this._wiredDialog)return;this._wiredDialog=true;this.returnValue="";onDispose(this,()=>{if(this.hasAttribute("open"))modalContain(this,false)});this.show=()=>{if(this.hasAttribute("open"))return;this._dialogLastFocus=document.activeElement;this.setAttribute("open","");this.setAttribute("aria-modal","true");const dlg=this.querySelector("dialog")||(this.tagName==="DIALOG"?this:null);if(dlg&&typeof dlg.showModal==="function"){try{dlg.showModal()}catch(e){}}modalContain(this,true);const focusable=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable){try{focusable.focus()}catch(e){}}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))};this.close=()=>{const wasOpen=this.hasAttribute("open");const dlg=this.querySelector("dialog")||(this.tagName==="DIALOG"?this:null);if(dlg&&typeof dlg.close==="function")dlg.close();if(this.hasAttribute("open"))this.removeAttribute("open");this.removeAttribute("aria-modal");if(wasOpen){modalContain(this,false);this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));const last=this._dialogLastFocus;if(last&&typeof last.focus==="function"){try{last.focus()}catch(e){}}}};this.focus=()=>{const focusable=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable){try{focusable.focus()}catch(e){}}else{try{HTMLElement.prototype.focus.call(this)}catch(e){}}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-dialog__close"):null;if(btn&&this.contains(btn)){this.close();return}if(e.target===this)this.close()});this.addEventListener("keydown",(e)=>{if(e.key==="Escape"&&this.hasAttribute("open"))this.close()})}}define("contour-dialog",ContourDialog);class ContourAlert extends ContourBase{static get observed(){return["title","body","variant","icon","closable","action","actions","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},variant:{attribute:"variant"},icon:{attribute:"icon"},closable:{attribute:"closable",type:Boolean},action:{attribute:"action"},actions:{attribute:"actions"}}}render(){this.classList.add("c-alert");const urgent=/^(warning|danger)$/.test(this.getAttribute("variant")||"");const role=urgent?"alert":"status";const live=urgent?"assertive":"polite";if(!this.hasAttribute("role")||this.getAttribute("role")===this._autoRole){this.setAttribute("role",role);this._autoRole=role}if(!this.hasAttribute("aria-live")||this.getAttribute("aria-live")===this._autoLive){this.setAttribute("aria-live",live);this._autoLive=live}wireStates(this);loadRemote(this,"title");if(renderStates(this,"alert"))return;const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-alert--"))this.classList.remove(c)});if(variant)this.classList.add("c-alert--"+variant);const icon=this.getAttribute("icon");if(icon){const ic=this.ensure(".c-alert__icon",()=>{const el=document.createElement("span");el.className="c-alert__icon";return el});if(ic.parentNode===this&&this.firstChild!==ic)this.prepend(ic);ic.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'}else{const ic=this.querySelector(".c-alert__icon");if(ic)ic.remove()}const title=this.getAttribute("title")||(this._remoteData&&this._remoteData.title);if(title){const t=this.ensure(".c-alert__title",()=>{const el=document.createElement("div");el.className="c-alert__title";return el});if(t.parentNode===this&&this.firstChild!==t)this.prepend(t);t.textContent=title}else{const t=this.querySelector(".c-alert__title");if(t)t.remove()}const body=this.getAttribute("body");if(body){const b=this.ensure(".c-alert__body",()=>{const el=document.createElement("div");el.className="c-alert__body";return el});b.textContent=body}else{const b=this.querySelector(".c-alert__body");if(b)b.remove()}Array.from(this.querySelectorAll(".c-alert__action")).forEach((n)=>n.remove());const actionsAttr=this.getAttribute("actions");let actionList=[];if(actionsAttr){try{const parsed=JSON.parse(actionsAttr);if(Array.isArray(parsed))actionList=parsed.map((x)=>String(x))}catch(e){actionList=[actionsAttr]}}else{const single=this.getAttribute("action");if(single)actionList=[single]}actionList.forEach((label)=>{const a=document.createElement("button");a.className="c-btn c-btn--sm c-alert__action";a.type="button";a.setAttribute("data-alert-action","");a.textContent=label;this.appendChild(a)});if(this.hasAttribute("closable")){this.ensure(".c-alert__close",()=>{const btn=document.createElement("button");btn.className="c-alert__close";btn.type="button";btn.setAttribute("aria-label","Close");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-alert__close");if(btn)btn.remove()}if(!title&&!body&&!icon){renderEmpty(this,"alert")}}}ContourAlert.prototype.enhance=function(){if(this._wiredAlert)return;this._wiredAlert=true;this.addEventListener("click",(e)=>{const actionBtn=e.target&&e.target.closest?e.target.closest(".c-alert__action"):null;if(actionBtn&&this.contains(actionBtn)){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:empty-action",{bubbles:true,composed:true,detail:{state:actionBtn.textContent.trim()}}));return}const btn=e.target&&e.target.closest?e.target.closest(".c-alert__close"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));this.remove()})};define("contour-alert",ContourAlert);class ContourDisclosure extends ContourBase{static get observed(){return["summary","icon"]}static get properties(){return{summary:{attribute:"summary"},icon:{attribute:"icon"}}}disconnectedCallback(){this._disclosureContent=null;super.disconnectedCallback()}connectedCallback(){if(this.innerHTML.trim()&&!this._disclosureContent){this._disclosureContent=this.innerHTML}super.connectedCallback()}attributeChangedCallback(name,oldValue,newValue){const details=this.querySelector("details");if(details){const body=details.querySelector(".c-disclosure__body");if(body)this._disclosureContent=body.innerHTML}else if(this.innerHTML.trim()){this._disclosureContent=this.innerHTML}super.attributeChangedCallback(name,oldValue,newValue)}render(){this.classList.add("c-disclosure");const summary=this.getAttribute("summary");const icon=this.getAttribute("icon");if(summary){let captured=this.innerHTML.trim()?this.innerHTML:(this._disclosureContent||"");if(captured.trim())this._disclosureContent=captured;const details=this.ensure("details",()=>{const d=document.createElement("details");const summ=document.createElement("summary");summ.className="c-disclosure__summary";if(icon){const ic=document.createElement("span");ic.className="c-disclosure__icon";ic.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>';summ.appendChild(ic)}summ.appendChild(document.createTextNode(summary));d.appendChild(summ);const content=document.createElement("div");content.className="c-disclosure__body";content.innerHTML=captured;d.appendChild(content);return d});const summ=details.querySelector("summary");if(summ){const ic=summ.querySelector(".c-disclosure__icon");if(icon&&!ic){const newIc=document.createElement("span");newIc.className="c-disclosure__icon";newIc.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>';summ.insertBefore(newIc,summ.firstChild)}else if(!icon&&ic){ic.remove()}const textNodes=Array.from(summ.childNodes).filter(n=>n.nodeType===3);textNodes.forEach(n=>n.remove());summ.appendChild(document.createTextNode(summary))}const body=details.querySelector(".c-disclosure__body");if(body)body.innerHTML=captured;if(details.parentNode!==this){this.innerHTML="";this.appendChild(details)}}else{const details=this.querySelector("details");if(details)details.remove()}}enhance(){if(this._wiredDisclosure)return;this._wiredDisclosure=true;this.addEventListener("toggle",(e)=>{const t=e.target;if(t&&t.tagName==="DETAILS"){this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:t.open},bubbles:true,composed:true}))}},true)}}define("contour-disclosure",ContourDisclosure);class ContourCallout extends ContourBase{static get observed(){return["variant","title","icon","closable"]}static get properties(){return{variant:{attribute:"variant"},title:{attribute:"title"},icon:{attribute:"icon"},closable:{attribute:"closable",type:Boolean}}}render(){this.classList.add("c-callout");if(!this.hasAttribute("role"))this.setAttribute("role","note");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("title")||"Callout");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-callout--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-callout--"+variant);const icon=this.getAttribute("icon");if(icon){const ic=this.ensure(".c-callout__icon",()=>{const el=document.createElement("span");el.className="c-callout__icon";return el});if(ic.parentNode===this&&this.firstChild!==ic)this.prepend(ic);ic.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'}else{const ic=this.querySelector(".c-callout__icon");if(ic)ic.remove()}const title=this.getAttribute("title");if(title){const t=this.ensure(".c-callout__title",()=>{const el=document.createElement("div");el.className="c-callout__title";return el});if(t.parentNode===this&&this.firstChild!==t)this.prepend(t);t.textContent=title}else{const t=this.querySelector(".c-callout__title");if(t)t.remove()}if(this.hasAttribute("closable")){this.ensure(".c-callout__close",()=>{const btn=document.createElement("button");btn.className="c-callout__close";btn.type="button";btn.setAttribute("aria-label","Close");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-callout__close");if(btn)btn.remove()}}}ContourCallout.prototype.enhance=function(){if(this._wiredCallout)return;this._wiredCallout=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-callout__close"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));this.remove()})};define("contour-callout",ContourCallout);class ContourEmpty extends ContourBase{static get observed(){return["state","title","body","action","icon","illustration","heading"]}static get properties(){return{state:{attribute:"state"},title:{attribute:"title"},body:{attribute:"body"},action:{attribute:"action"},icon:{attribute:"icon"},illustration:{attribute:"illustration"}}}render(){this.classList.add("c-empty");if(!this.hasAttribute("role"))this.setAttribute("role","status");const state=this.getAttribute("state")||"empty";const title=this.getAttribute("title")||(state==="filtered"?"Nothing matches":state==="error"?"Could not load":"No data yet");const body=this.getAttribute("body")||(state==="filtered"?"Try clearing some filters.":state==="error"?"Check your connection and try again.":"There is nothing to show here yet.");const action=this.getAttribute("action")||(state==="filtered"?"Clear filters":state==="error"?"Retry":"");const icon=this.getAttribute("icon");if(icon){const ic=this.ensure(".c-empty__icon",()=>{const el=document.createElement("span");el.className="c-empty__icon";return el});ic.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'}else{const ic=this.querySelector(".c-empty__icon");if(ic)ic.remove()}const illustration=this.getAttribute("illustration");if(illustration){const il=this.ensure(".c-empty__illustration",()=>{const el=document.createElement("div");el.className="c-empty__illustration";return el});il.innerHTML=sanitizeHtml(illustration)}else{const il=this.querySelector(".c-empty__illustration");if(il)il.remove()}if(title){const t=this.ensure(".c-empty__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-empty__title";return el});t.textContent=title}else{const t=this.querySelector(".c-empty__title");if(t)t.remove()}if(body){const b=this.ensure(".c-empty__text",()=>{const el=document.createElement("p");el.className="c-empty__text";return el});b.textContent=body}else{const b=this.querySelector(".c-empty__text");if(b)b.remove()}if(action){const a=this.ensure("button.c-btn[data-empty-action]",()=>{const el=document.createElement("button");el.className="c-btn c-btn--primary";el.type="button";el.setAttribute("data-empty-action","");return el});a.textContent=action}else{const a=this.querySelector("[data-empty-action]");if(a)a.remove()}}enhance(){wireRemovable(this)}}define("contour-empty",ContourEmpty);class ContourFaq extends ContourBase{static get observed(){return["question","answer","items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{question:{attribute:"question"},answer:{attribute:"answer"},items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-faq");wireStates(this);loadRemote(this,"items");if(renderStates(this,"faq"))return;const items=remoteData(this,"items");const question=this.getAttribute("question");const answer=this.getAttribute("answer");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-faq__item"));if(items&&!authored.length){try{const parsed=JSON.parse(items);Array.from(this.querySelectorAll(".c-faq__item")).forEach((n)=>n.remove());parsed.forEach((it,i)=>{const item=document.createElement("details");item.className="c-faq__item";if(i===0)item.setAttribute("open","");const q=document.createElement("summary");q.className="c-faq__question";q.textContent=typeof it==="string"?it:(it.question||it.q||"");const sign=document.createElement("span");sign.className="c-faq__sign";sign.setAttribute("aria-hidden","true");sign.innerHTML='<svg aria-hidden="true"><use href="#i-plus" /></svg>';q.appendChild(sign);item.appendChild(q);const a=document.createElement("div");a.className="c-faq__answer";a.textContent=typeof it==="string"?"":(it.answer||it.a||"");item.appendChild(a);this.appendChild(item)})}catch(e){warnBadJson(this,"attribute",e)}}else if(!items){if(!question&&!answer){renderEmpty(this,"faq")}else{const item=this.ensure("details.c-faq__item",()=>{const el=document.createElement("details");el.className="c-faq__item";return el});if(!item.hasAttribute("open"))item.setAttribute("open","");const q=this.ensure("summary.c-faq__question",()=>{const el=document.createElement("summary");el.className="c-faq__question";return el},item);q.textContent=question||"";const sign=this.ensure(".c-faq__sign",()=>{const el=document.createElement("span");el.className="c-faq__sign";return el},q);sign.setAttribute("aria-hidden","true");sign.innerHTML='<svg aria-hidden="true"><use href="#i-plus" /></svg>';const a=this.ensure(".c-faq__answer",()=>{const el=document.createElement("div");el.className="c-faq__answer";return el},item);a.textContent=answer||""}}}}define("contour-faq",ContourFaq);class ContourAccordion extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist","exclusive"]}static get properties(){return{items:{attribute:"items"},exclusive:{attribute:"exclusive",type:Boolean},src:{attribute:"src"}}}render(){if(!this.hasAttribute("role"))this.setAttribute("role","region");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Accordion");const authored=Array.from(this.children).filter((n)=>n.tagName==="DETAILS");wireStates(this);loadRemote(this,"items");if(renderStates(this,"accordion"))return;const items=remoteData(this,"items");if(items&&!authored.length){Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>d.remove());try{const parsed=JSON.parse(items);parsed.forEach((item)=>{const details=document.createElement("details");details.className="c-disclosure";const summary=document.createElement("summary");summary.className="c-disclosure__summary";summary.textContent=item.title||item.question||item.q||item.label||"";details.appendChild(summary);const body=document.createElement("div");body.className="c-disclosure__body";body.textContent=item.body||item.answer||item.a||item.content||"";details.appendChild(body);this.appendChild(details)})}catch(e){warnBadJson(this,"attribute",e)}}else if(!items&&!authored.length){renderEmpty(this,"accordion")}const persist=this.getAttribute("persist");if(persist){let saved=null;if(persist==="storage"&&this.id){try{saved=localStorage.getItem("contour-accordion:"+this.id)}catch(e){}}else if(persist==="url"){try{saved=new URLSearchParams(window.location.search).get("c-accordion")}catch(e){}}if(saved!==null){try{const labels=JSON.parse(saved);if(Array.isArray(labels)){const want=new Set(labels.map((l)=>String(l)));Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>{const summary=d.querySelector("summary");const label=(summary?summary.textContent:"").trim().slice(0,120);if(want.has(label))d.open=true})}}catch(e){}}}}enhance(){if(this._wiredAccordion)return;this._wiredAccordion=true;this.addEventListener("toggle",(e)=>{const t=e.target;if(t&&t.tagName==="DETAILS"){if(t.open&&this.hasAttribute("exclusive")){Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>{if(d!==t)d.open=false})}this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:t.open},bubbles:true,composed:true}));const persist=this.getAttribute("persist");if(persist==="storage"&&this.id){try{const open=[];Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>{if(d.open){const s=d.querySelector("summary");open.push((s?s.textContent:"").trim().slice(0,120))}});localStorage.setItem("contour-accordion:"+this.id,JSON.stringify(open))}catch(e){}}else if(persist==="url"){try{const open=[];Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>{if(d.open){const s=d.querySelector("summary");open.push((s?s.textContent:"").trim().slice(0,120))}});const url=new URL(window.location.href);url.searchParams.set("c-accordion",JSON.stringify(open));window.history.replaceState(null,"",url.toString())}catch(e){}}}},true)}}define("contour-accordion",ContourAccordion);class ContourDrawer extends ContourBase{static get observed(){return["title","body","size"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},size:{attribute:"size"}}}showModal(){this.show()}get open(){return this.hasAttribute("open")}set open(v){if(v)this.show();else this.close()}render(){this.classList.add("c-drawer");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-drawer--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-drawer--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","dialog");const title=this.getAttribute("title");let head=this.querySelector(".c-drawer__head");if(title){if(!head){head=document.createElement("div");head.className="c-drawer__head";const t=document.createElement("div");t.className="c-drawer__title";head.appendChild(t);const closeBtn=document.createElement("button");closeBtn.className="c-btn c-btn--icon c-btn--ghost c-drawer__close";closeBtn.setAttribute("type","button");closeBtn.setAttribute("aria-label","Close");closeBtn.innerHTML='<svg aria-hidden="true"><use href="#i-x" /></svg>';head.appendChild(closeBtn)}const t=head.querySelector(".c-drawer__title");if(t){t.textContent=title;if(!t.id)t.id="contour-drawer-title-"+(this._drawerTitleId=(this._drawerTitleId||0)+1);this.setAttribute("aria-labelledby",t.id)}if(head.parentNode!==this)this.prepend(head)}else if(head){head.remove()}if(this.hasAttribute("open"))this.classList.add("is-open");else this.classList.remove("is-open");const body=this.getAttribute("body");const b=this.querySelector(".c-drawer__body");const authored=b?Array.from(b.children):[];if(body&&!authored.length){const el=this.ensure(".c-drawer__body",()=>{const e=document.createElement("div");e.className="c-drawer__body";return e});el.innerHTML=sanitizeHtml(body)}else if(!body&&b&&!authored.length){b.remove()}}enhance(){if(this._wiredDrawer)return;this._wiredDrawer=true;this.returnValue="";onDispose(this,()=>{if(this.hasAttribute("open"))modalContain(this,false)});this._drawerLastFocus=null;this.show=()=>{if(this.hasAttribute("open"))return;this._drawerLastFocus=document.activeElement;this.setAttribute("open","");this.setAttribute("aria-modal","true");this.classList.add("is-open");modalContain(this,true);const focusable=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable){try{focusable.focus()}catch(e){}}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))};this.close=()=>{if(!this.hasAttribute("open"))return;this.removeAttribute("open");this.removeAttribute("aria-modal");this.classList.remove("is-open");modalContain(this,false);this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));const last=this._drawerLastFocus;if(last&&typeof last.focus==="function"){try{last.focus()}catch(e){}}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-drawer__close"):null;if(btn&&this.contains(btn)){this.close();return}if(e.target===this)this.close()});this.addEventListener("keydown",(e)=>{if(e.key==="Escape"&&this.hasAttribute("open"))this.close()});let touchStartX=0,touchStartY=0;this.addEventListener("touchstart",(e)=>{if(!this.hasAttribute("open"))return;const t=e.touches&&e.touches[0];if(t){touchStartX=t.clientX;touchStartY=t.clientY}},{passive:true});this.addEventListener("touchend",(e)=>{if(!this.hasAttribute("open"))return;const t=e.changedTouches&&e.changedTouches[0];if(!t)return;const dx=t.clientX-touchStartX;const dy=t.clientY-touchStartY;if(Math.abs(dx)>60&&Math.abs(dx)>Math.abs(dy)*1.5)this.close()},{passive:true})}}define("contour-drawer",ContourDrawer);class ContourSheet extends ContourBase{static get observed(){return["title","body","size"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},size:{attribute:"size"}}}showModal(){this.show()}get open(){return this.hasAttribute("open")}set open(v){if(v)this.show();else this.close()}render(){this.classList.add("c-sheet");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-sheet--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-sheet--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","dialog");const title=this.getAttribute("title");let head=this.querySelector(".c-sheet__head");if(title){if(!head){head=document.createElement("div");head.className="c-sheet__head";const t=document.createElement("div");t.className="c-sheet__title";head.appendChild(t);const closeBtn=document.createElement("button");closeBtn.className="c-btn c-btn--icon c-btn--ghost c-sheet__close";closeBtn.setAttribute("type","button");closeBtn.setAttribute("aria-label","Close");closeBtn.innerHTML='<svg aria-hidden="true"><use href="#i-x" /></svg>';head.appendChild(closeBtn)}const t=head.querySelector(".c-sheet__title");if(t){t.textContent=title;if(!t.id)t.id="contour-sheet-title-"+(this._sheetTitleId=(this._sheetTitleId||0)+1);this.setAttribute("aria-labelledby",t.id)}if(head.parentNode!==this)this.prepend(head)}else if(head){head.remove()}if(this.hasAttribute("open"))this.classList.add("is-open");else this.classList.remove("is-open");const body=this.getAttribute("body");const b=this.querySelector(".c-sheet__body");const authored=b?Array.from(b.children):[];if(body&&!authored.length){const el=this.ensure(".c-sheet__body",()=>{const e=document.createElement("div");e.className="c-sheet__body";return e});el.innerHTML=sanitizeHtml(body)}else if(!body&&b&&!authored.length){b.remove()}}enhance(){if(this._wiredSheet)return;this._wiredSheet=true;this.returnValue="";onDispose(this,()=>{if(this.hasAttribute("open"))modalContain(this,false)});this._sheetLastFocus=null;this.show=()=>{if(this.hasAttribute("open"))return;this._sheetLastFocus=document.activeElement;this.setAttribute("open","");this.setAttribute("aria-modal","true");this.classList.add("is-open");modalContain(this,true);const focusable=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable){try{focusable.focus()}catch(e){}}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))};this.close=()=>{if(!this.hasAttribute("open"))return;this.removeAttribute("open");this.removeAttribute("aria-modal");this.classList.remove("is-open");modalContain(this,false);this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));const last=this._sheetLastFocus;if(last&&typeof last.focus==="function"){try{last.focus()}catch(e){}}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-sheet__close"):null;if(btn&&this.contains(btn)){this.close();return}if(e.target===this)this.close()});this.addEventListener("keydown",(e)=>{if(e.key==="Escape"&&this.hasAttribute("open"))this.close()});let touchStartY=0,touchStartX=0;this.addEventListener("touchstart",(e)=>{if(!this.hasAttribute("open"))return;const t=e.touches&&e.touches[0];if(t){touchStartX=t.clientX;touchStartY=t.clientY}},{passive:true});this.addEventListener("touchend",(e)=>{if(!this.hasAttribute("open"))return;const t=e.changedTouches&&e.changedTouches[0];if(!t)return;const dy=t.clientY-touchStartY;const dx=t.clientX-touchStartX;if(dy>60&&Math.abs(dy)>Math.abs(dx)*1.5)this.close()},{passive:true})}}define("contour-sheet",ContourSheet);class ContourToast extends ContourBase{static get observed(){return["message","variant","duration","action"]}static get properties(){return{message:{attribute:"message"},variant:{attribute:"variant"},duration:{attribute:"duration",type:Number},action:{attribute:"action"}}}render(){this.classList.add("c-toast");if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live","polite");if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true");const message=this.getAttribute("message");if(message&&!this.hasChildNodes()){this.textContent=message}const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-toast--"))this.classList.remove(c)});if(variant)this.classList.add("c-toast--"+variant);const action=this.getAttribute("action");let btn=this.querySelector(".c-toast__action");if(action){if(!btn){btn=document.createElement("button");btn.className="c-toast__action";btn.type="button";this.appendChild(btn)}btn.textContent=action}else if(btn){btn.remove()}}enhance(){if(this._wiredToast)return;this._wiredToast=true;const ms=(this.duration&&this.duration>0)?this.duration:1500;const timer=setTimeout(()=>{if(!this.isConnected)return;this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));this.remove()},ms);onDispose(this,()=>clearTimeout(timer))}}define("contour-toast",ContourToast);class ContourExpandable extends ContourBase{static get observed(){return["summary"]}static get properties(){return{summary:{attribute:"summary"}}}disconnectedCallback(){this._expandableContent=null;super.disconnectedCallback()}connectedCallback(){if(this.innerHTML.trim()&&!this._expandableContent){this._expandableContent=this.innerHTML}super.connectedCallback()}attributeChangedCallback(name,oldValue,newValue){const details=this.querySelector("details");if(details){const body=details.querySelector(".c-expandable__body");if(body)this._expandableContent=body.innerHTML}else if(this.innerHTML.trim()){this._expandableContent=this.innerHTML}super.attributeChangedCallback(name,oldValue,newValue)}render(){this.classList.add("c-expandable");if(!this.hasAttribute("role"))this.setAttribute("role","region");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("summary")||"Expandable");const summary=this.getAttribute("summary");if(summary){let captured=this.innerHTML.trim()?this.innerHTML:(this._expandableContent||"");if(captured.trim())this._expandableContent=captured;const details=this.ensure("details",()=>{const d=document.createElement("details");const summ=document.createElement("summary");summ.className="c-expandable__summary";summ.textContent=summary;d.appendChild(summ);const content=document.createElement("div");content.className="c-expandable__body";content.innerHTML=captured;d.appendChild(content);return d});const summ=details.querySelector("summary");if(summ)summ.textContent=summary;const body=details.querySelector(".c-expandable__body");if(body)body.innerHTML=captured;if(details.parentNode!==this){this.innerHTML="";this.appendChild(details)}}else{const details=this.querySelector("details");if(details)details.remove()}}enhance(){if(this._wiredExpandable)return;this._wiredExpandable=true;this.addEventListener("toggle",(e)=>{const t=e.target;if(t&&t.tagName==="DETAILS"){this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:t.open},bubbles:true,composed:true}))}},true)}}define("contour-expandable",ContourExpandable);class ContourToastHost extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-toast-host");if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Toast host");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live","polite");if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}enhance(){if(this._wiredToastHost)return;this._wiredToastHost=true;this._toastQueue=[];this._toastActive=null;const buildToast=(message,opts)=>{opts=opts||{};const toast=document.createElement("div");toast.className="c-toast";toast.setAttribute("role","status");toast.setAttribute("aria-live","polite");toast.setAttribute("aria-atomic","true");if(opts.variant)toast.classList.add("c-toast--"+opts.variant);toast.dataset.message=message==null?"":String(message);const text=document.createElement("span");text.className="c-toast__text";text.textContent=message==null?"":String(message);toast.appendChild(text);if(opts.action&&(typeof opts.action==="string"||(opts.action.label))){const label=(typeof opts.action==="string")?opts.action:opts.action.label;const btn=document.createElement("button");btn.type="button";btn.className="c-btn c-btn--ghost c-toast__action";btn.textContent=label;btn.addEventListener("click",(e)=>{e.stopPropagation();if(typeof opts.action==="object"&&typeof opts.action.onClick==="function"){try{opts.action.onClick()}catch(err){}}dismiss(toast)});toast.appendChild(btn)}return toast};const dismiss=(toast)=>{if(!toast||!toast.parentNode)return;if(toast._timer){clearTimeout(toast._timer);toast._timer=null}toast.parentNode.removeChild(toast);if(this._toastActive===toast)this._toastActive=null;this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true,detail:{message:toast.textContent}}));pump()};const pump=()=>{if(this._toastActive&&this._toastActive.parentNode)return;while(this._toastQueue.length){const next=this._toastQueue.shift();if(next._deduped)continue;const toast=buildToast(next.message,next.opts);this._toastActive=toast;this.appendChild(toast);const ms=(next.opts&&next.opts.duration&&next.opts.duration>0)?next.opts.duration:3000;toast._timer=setTimeout(()=>dismiss(toast),ms);return}this._toastActive=null};this.show=(message,opts)=>{opts=opts||{};const key=String(message==null?"":message);const active=this._toastActive;if(active&&active.dataset&&active.dataset.message===key&&key!==""){if(active._timer){clearTimeout(active._timer)}const ms=(opts.duration&&opts.duration>0)?opts.duration:3000;active._timer=setTimeout(()=>dismiss(active),ms);return active}const queuedDup=this._toastQueue.find((q)=>String(q.message)===key&&key!=="");if(queuedDup){queuedDup.opts=Object.assign({},queuedDup.opts,opts);return null}const entry={message,opts,_deduped:false};this._toastQueue.push(entry);pump();return this._toastActive};this.hide=()=>{if(this._toastActive)dismiss(this._toastActive);this._toastQueue.length=0;Array.from(this.querySelectorAll(".c-toast")).forEach((t)=>{if(t._timer)clearTimeout(t._timer);if(t.parentNode)t.parentNode.removeChild(t)});this._toastActive=null}}}define("contour-toast-host",ContourToastHost);class ContourCombobox extends ContourBase{static get observed(){return["options","placeholder","label","value","multiple","loading","error","retry","src","lazy","refresh","timeout","empty","skeleton","virtual","disabled","required","name"]}static get formAssociated(){return true}static get properties(){return{options:{attribute:"options"},placeholder:{attribute:"placeholder"},label:{attribute:"label"},value:{attribute:"value"},multiple:{attribute:"multiple",type:Boolean},virtual:{attribute:"virtual",type:Boolean},src:{attribute:"src"},disabled:{attribute:"disabled",type:Boolean},required:{attribute:"required",type:Boolean},name:{attribute:"name"}}}render(){this.classList.add("c-combobox");if(this._comboboxDefault===undefined)this._comboboxDefault=this.getAttribute("value");wireStates(this);loadRemote(this,"options");if(renderStates(this,"combobox"))return;const options=remoteData(this,"options");const authored=Array.from(this.children).filter((n)=>!n.classList||(!n.classList.contains("c-combobox__input")&&!n.classList.contains("c-combobox__list")));if((options)&&!authored.length){try{const parsed=options?JSON.parse(options):[];this._comboboxOptions=parsed;const input=this.ensure(".c-combobox__input",()=>{const el=document.createElement("input");el.className="c-combobox__input";el.type="text";return el});input.type="text";input.placeholder=this.getAttribute("placeholder")||"Search…";input.setAttribute("aria-label",this.getAttribute("label")||"Search");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}if(this.hasAttribute("required")){input.setAttribute("required","");input.setAttribute("aria-required","true")}else{input.removeAttribute("required");input.removeAttribute("aria-required")}if(this.hasAttribute("name"))input.setAttribute("name",this.getAttribute("name"));const val=this.getAttribute("value");if(val!==null){const match=parsed.find((o)=>String(typeof o==="string"?o:o.value)===String(val));input.value=match?String(typeof match==="string"?match:match.label):val}const list=this.ensure(".c-combobox__list",()=>{const el=document.createElement("ul");el.className="c-combobox__list";el.setAttribute("hidden","");return el});list.innerHTML="";list.setAttribute("hidden","");this._comboboxVirtual=this.hasAttribute("virtual")&&parsed.length>100;if(this._comboboxVirtual){list.classList.add("c-combobox__list--virtual");list.style.maxBlockSize="20rem";list.style.overflow="auto";this._renderComboboxWindow("",true)}else{list.classList.remove("c-combobox__list--virtual");list.style.maxBlockSize="";list.style.overflow="";this._renderComboboxWindow("",true)}}catch(e){warnBadJson(this,"attribute",e)}}else if(!authored.length&&!options){renderEmpty(this,"combobox")}if(this.getAttribute("value")){this.ensure(".c-combobox__clear",()=>{const btn=document.createElement("button");btn.className="c-combobox__clear";btn.type="button";btn.setAttribute("aria-label","Clear");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-combobox__clear");if(btn)btn.remove()}}_renderComboboxWindow(query="",reset=false){const list=this.querySelector(".c-combobox__list");const options=this._comboboxOptions||[];if(!list)return;const q=String(query||"").toLowerCase();const filtered=options.map((opt,index)=>({opt,index,label:typeof opt==="string"?opt:opt.label,value:typeof opt==="string"?opt:opt.value,})).filter((item)=>!q||String(item.label).toLowerCase().includes(q));this._comboboxFiltered=filtered;const rowHeight=cssLength("--combobox-row-height",32);const windowSize=20;const overscan=6;const oldScrollTop=list.scrollTop;const start=this._comboboxVirtual&&!reset?Math.min(Math.max(0,filtered.length-windowSize),Math.max(0,Math.floor(oldScrollTop/rowHeight)-overscan)):0;this._comboboxWindowStart=start;const end=this._comboboxVirtual?Math.min(filtered.length,start+windowSize+overscan*2):filtered.length;const selectedVals=(this.getAttribute("value")||"").split(",").map((v)=>v.trim()).filter(Boolean);list.innerHTML="";const addSpacer=(height)=>{const spacer=document.createElement("li");spacer.setAttribute("aria-hidden","true");spacer.style.blockSize=`${height}px`;list.appendChild(spacer)};if(this._comboboxVirtual)addSpacer(start*rowHeight);if(!filtered.length){const empty=document.createElement("li");empty.className="c-combobox__empty";empty.setAttribute("role","status");empty.textContent=this.getAttribute("empty")||"No matches";list.appendChild(empty)}if(this.hasAttribute("multiple"))list.setAttribute("aria-multiselectable","true");else list.removeAttribute("aria-multiselectable");filtered.slice(start,end).forEach((item)=>{const li=document.createElement("li");li.className="c-combobox__option";li.dataset.optionIndex=String(item.index);li.dataset.optionValue=String(item.value!=null?item.value:item.label);li.setAttribute("role","option");const label=String(item.label);const q=String(query||"").toLowerCase();if(q&&label.toLowerCase().includes(q)){const idx=label.toLowerCase().indexOf(q);const before=label.slice(0,idx);const match=label.slice(idx,idx+q.length);const after=label.slice(idx+q.length);li.innerHTML="";if(before)li.appendChild(document.createTextNode(before));const mark=document.createElement("mark");mark.className="c-combobox__match";mark.textContent=match;li.appendChild(mark);if(after)li.appendChild(document.createTextNode(after))}else{li.textContent=label}const isSelected=this.hasAttribute("multiple")&&selectedVals.includes(String(item.value));li.setAttribute("aria-selected",String(isSelected));if(isSelected)li.classList.add("c-combobox__option--selected");list.appendChild(li)});if(this._comboboxVirtual)addSpacer(Math.max(0,filtered.length-end)*rowHeight);if(this._comboboxVirtual&&!reset)list.scrollTop=oldScrollTop}_syncFormValue(){if(!this._internals)return;const raw=this.getAttribute("value");const value=raw!=null&&raw!==""?raw:null;this._internals.setFormValue(value);this._syncValidity(this.hasAttribute("required")&&!value)}enhance(){wireCombobox(this);if(this._internals&&!this._wiredComboboxForm){this._wiredComboboxForm=true;this._syncFormValue();this.addEventListener("contour:select",(e)=>{const v=e&&e.detail&&(e.detail.value||e.detail.label);if(v!=null)this.setAttribute("value",String(v));this._syncFormValue()})}if(!this._wiredComboboxClear){this._wiredComboboxClear=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-combobox__clear"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.removeAttribute("value");const input=this.querySelector(".c-combobox__input");if(input)input.value="";this._syncFormValue();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{name:this.getAttribute("name"),value:null,checked:null}}))})}}formResetCallback(){this._contourResetting=true;try{const def=this._comboboxDefault??null;if(def===null)this.removeAttribute("value");else this.setAttribute("value",def);this._syncFormValue()}finally{this._contourResetting=false}}}define("contour-combobox",ContourCombobox);class ContourField extends ContourBase{static get observed(){return["label","hint","error","placeholder","type","required","name","value","disabled","custom-error"]}static get formAssociated(){return true}static get properties(){return{label:{attribute:"label"},hint:{attribute:"hint"},error:{attribute:"error"},placeholder:{attribute:"placeholder"},type:{attribute:"type"},required:{attribute:"required",type:Boolean},name:{attribute:"name"},value:{attribute:"value"},disabled:{attribute:"disabled",type:Boolean},customError:{attribute:"custom-error"}}}render(){this.classList.add("c-field");const label=this.getAttribute("label");const hint=this.getAttribute("hint");const error=this.getAttribute("error");const placeholder=this.getAttribute("placeholder")||"";if(label){const lbl=this.ensure(".c-field__label",()=>{const el=document.createElement("label");el.className="c-field__label";return el});lbl.textContent=label}else{const lbl=this.querySelector(".c-field__label");if(lbl)lbl.remove()}const input=this.ensure("input.c-input, textarea, select",()=>{const el=document.createElement("input");el.className="c-input";return el});input.type=this.getAttribute("type")||"text";input.placeholder=placeholder;if(!input.id)input.id=this._fieldInputId||(this._fieldInputId=contourId("contour-field"));const lbl=this.querySelector(".c-field__label");if(lbl){if(!input.id)input.id=contourId("contour-field");lbl.setAttribute("for",input.id);input.setAttribute("aria-label",lbl.textContent)}else if(!input.hasAttribute("aria-label"))input.setAttribute("aria-label","Field");if(hint){const h=this.ensure(".c-field__hint",()=>{const el=document.createElement("span");el.className="c-field__hint";return el});h.textContent=hint}else{const h=this.querySelector(".c-field__hint");if(h)h.remove()}if(error){const e=this.ensure(".c-field__error",()=>{const el=document.createElement("span");el.className="c-field__error";return el});e.textContent=error}else{const e=this.querySelector(".c-field__error");if(e)e.remove()}const customError=this.getAttribute("custom-error");if(customError!==null){input.setAttribute("aria-invalid","true");this.classList.add("is-invalid");this.setAttribute("data-invalid","");let errEl=this.querySelector(".c-field__error");if(!errEl){errEl=document.createElement("span");errEl.className="c-field__error";this.appendChild(errEl)}errEl.textContent=customError;if(!errEl.id)errEl.id=contourId("err");input.setAttribute("aria-describedby",(input.getAttribute("aria-describedby")||"").split(" ").filter((x)=>x&&x!==errEl.id).concat(errEl.id).join(" "))}const hintEl=this.querySelector(".c-field__hint");const errEl=this.querySelector(".c-field__error");const describedBy=[];if(hintEl){if(!hintEl.id)hintEl.id=contourId("hint");describedBy.push(hintEl.id)}if(errEl){if(!errEl.id)errEl.id=contourId("err");describedBy.push(errEl.id)}if(describedBy.length)input.setAttribute("aria-describedby",describedBy.join(" "));if(this.hasAttribute("required")){input.setAttribute("aria-required","true");input.setAttribute("required","")}else{input.removeAttribute("aria-required");input.removeAttribute("required")}if(this.hasAttribute("name"))input.setAttribute("name",this.getAttribute("name"));if(this.hasAttribute("value"))input.value=this.getAttribute("value");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}}}ContourField.prototype.enhance=function(){if(this._wiredField)return;this._wiredField=true;const sync=()=>{const input=this.querySelector("input, textarea, select");if(!input||!this._internals)return;this._internals.setFormValue(input.value)};this.addEventListener("input",(e)=>{const input=this.querySelector("input, textarea, select");if(!input||e.target!==input)return;sync();this._emitForm("contour:input")});this.addEventListener("change",(e)=>{const input=this.querySelector("input, textarea, select");if(!input||e.target!==input)return;sync();this._emitForm("contour:change")});this.addEventListener("focusout",(e)=>{const input=this.querySelector("input, textarea, select");if(!input||e.target!==input)return;const valid=input.checkValidity();if(valid){input.setAttribute("aria-invalid","false");this.classList.remove("is-invalid");this.removeAttribute("data-invalid");if(!this.getAttribute("error")){const stale=this.querySelector(".c-field__error");if(stale){const id=stale.id;stale.remove();if(id)input.setAttribute("aria-describedby",(input.getAttribute("aria-describedby")||"").split(" ").filter((x)=>x&&x!==id).join(" "))}}}else{input.setAttribute("aria-invalid","true");this.classList.add("is-invalid");this.setAttribute("data-invalid","");const invalidEvent=new CustomEvent("contour:invalid",{bubbles:true,composed:true,cancelable:true,detail:{field:this,input,message:input.validationMessage||"Invalid value"},});const notCancelled=this.dispatchEvent(invalidEvent);if(notCancelled){if(!this.getAttribute("error")&&!this.getAttribute("custom-error")){const msg=input.validationMessage||"Invalid value";let errEl=this.querySelector(".c-field__error");if(!errEl){errEl=document.createElement("span");errEl.className="c-field__error";this.appendChild(errEl)}errEl.textContent=msg;if(!errEl.id)errEl.id=contourId("err");input.setAttribute("aria-describedby",(input.getAttribute("aria-describedby")||"").split(" ").filter((x)=>x&&x!==errEl.id).concat(errEl.id).join(" "))}}}sync()},true);sync()};define("contour-field",ContourField);class ContourFieldGroup extends ContourBase{static get observed(){return["label","hint","error","required"]}static get properties(){return{label:{attribute:"label"},hint:{attribute:"hint"},error:{attribute:"error"},required:{attribute:"required",type:Boolean}}}render(){this.classList.add("c-field-group");this.setAttribute("role","group");const label=this.getAttribute("label");if(label){const lbl=this.ensure(".c-field-group__label",()=>{const el=document.createElement("div");el.className="c-field-group__label";return el});lbl.textContent=label}else{const lbl=this.querySelector(".c-field-group__label");if(lbl)lbl.remove()}const hint=this.getAttribute("hint");if(hint){const h=this.ensure(".c-field-group__hint",()=>{const el=document.createElement("span");el.className="c-field-group__hint";return el});h.textContent=hint}else{const h=this.querySelector(".c-field-group__hint");if(h)h.remove()}const error=this.getAttribute("error");if(error){const e=this.ensure(".c-field-group__error",()=>{const el=document.createElement("span");el.className="c-field-group__error";return el});e.textContent=error}else{const e=this.querySelector(".c-field-group__error");if(e)e.remove()}if(error)this.classList.add("is-error");else this.classList.remove("is-error");if(this.hasAttribute("required"))this.setAttribute("aria-required","true");else this.removeAttribute("aria-required")}enhance(){if(this._wiredFieldGroup)return;this._wiredFieldGroup=true}}define("contour-field-group",ContourFieldGroup);class ContourForm extends ContourBase{static get observed(){return["submitting","error","summary","title","submit-label"]}static get properties(){return{submitting:{attribute:"submitting",type:Boolean},error:{attribute:"error"},summary:{attribute:"summary"},title:{attribute:"title"},submitLabel:{attribute:"submit-label"}}}render(){this.classList.add("c-form");if(this.hasAttribute("submitting"))this.classList.add("is-submitting");else this.classList.remove("is-submitting");const title=this.getAttribute("title");let titleEl=this.querySelector(".c-form__title");if(title){if(!titleEl){titleEl=document.createElement("h2");titleEl.className="c-form__title";this.prepend(titleEl)}titleEl.textContent=title}else if(titleEl){titleEl.remove()}const summaryText=this.getAttribute("summary")||this.getAttribute("error");let summary=this.querySelector(".c-form__summary");if(summaryText){if(!summary){summary=document.createElement("div");summary.className="c-form__summary";summary.setAttribute("role","alert");this.prepend(summary)}summary.textContent=summaryText;summary.removeAttribute("hidden")}else if(summary){summary.setAttribute("hidden","")}const submitLabel=this.getAttribute("submit-label");let submit=this.querySelector(".c-form__submit");if(!submit){submit=document.createElement("button");submit.type="submit";submit.className="c-btn c-btn--primary c-form__submit";this.appendChild(submit)}if(submitLabel){submit.textContent=submitLabel;if(submit.dataset)delete submit.dataset.contourLabel}else{applyLabel(submit,this,"submit","Submit")}if(this.hasAttribute("submitting"))submit.setAttribute("disabled","");else submit.removeAttribute("disabled")}enhance(){if(this._wiredForm)return;this._wiredForm=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-form__submit"):null;if(!btn||!this.contains(btn))return;if(e.target.closest("form"))return;e.preventDefault();this._submit()});this.addEventListener("submit",(e)=>{const form=e.target;e.preventDefault();if(form&&typeof form.checkValidity==="function"&&!form.checkValidity()){const invalid=Array.from(form.querySelectorAll(":invalid"));const names=invalid.map((el)=>el.getAttribute("aria-label")||el.name||el.id||"field").join(", ");let summary=this.querySelector(".c-form__summary");if(!summary){summary=document.createElement("div");summary.className="c-form__summary";summary.setAttribute("role","alert");this.prepend(summary)}summary.textContent=labelText(this,"validation-summary","Please fix")+": "+(names||labelText(this,"invalid-fields","invalid fields"));summary.removeAttribute("hidden");return}this._submit()})}_submit(){this.classList.add("is-submitting");const submit=this.querySelector("[type='submit'], .c-form__submit");if(submit)submit.setAttribute("disabled","");this.dispatchEvent(new CustomEvent("contour:submit",{bubbles:true,composed:true,detail:{submitting:true}}))}}define("contour-form",ContourForm);class ContourRange extends ContourBase{static get observed(){return["min","max","value","low","high","range","sparkline","label","disabled","error","help","name","step"]}static get formAssociated(){return true}static get properties(){return{min:{attribute:"min"},max:{attribute:"max"},value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},name:{attribute:"name"},step:{attribute:"step"}}}render(){this.classList.add("c-range");const min=this.getAttribute("min")||"0";const max=this.getAttribute("max")||"100";const rangeMode=this.hasAttribute("range")||this.hasAttribute("low")||this.hasAttribute("high");const spark=this.getAttribute("sparkline");if(spark){let canvas=this.querySelector(".c-range__sparkline");if(!canvas){canvas=document.createElement("canvas");canvas.className="c-range__sparkline";canvas.setAttribute("part","sparkline-canvas");this.insertBefore(canvas,this.firstChild)}}else{const c=this.querySelector(".c-range__sparkline");if(c)c.remove()}if(rangeMode){const single=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");let lowInput=this.querySelector("input.c-range__low");if(!lowInput){lowInput=document.createElement("input");lowInput.type="range";lowInput.className="c-range c-range__low";lowInput.setAttribute("part","input");this.appendChild(lowInput)}let highInput=this.querySelector("input.c-range__high");if(!highInput){highInput=document.createElement("input");highInput.type="range";highInput.className="c-range c-range__high";highInput.setAttribute("part","input");this.appendChild(highInput)}lowInput.min=min;lowInput.max=max;highInput.min=min;highInput.max=max;const step=this.getAttribute("step");if(step){lowInput.step=step;highInput.step=step}else{lowInput.removeAttribute("step");highInput.removeAttribute("step")}if(this.hasAttribute("disabled")){lowInput.setAttribute("disabled","");highInput.setAttribute("disabled","")}else{lowInput.removeAttribute("disabled");highInput.removeAttribute("disabled")}const lowVal=this.getAttribute("low")||min;const highVal=this.getAttribute("high")||max;if(this._rangeUserLow!==null&&this._rangeAttrLowAtDirty===(this.getAttribute("low")||min))lowInput.value=this._rangeUserLow;else{lowInput.value=lowVal;this._rangeUserLow=null;this._rangeAttrLowAtDirty=null}if(this._rangeUserHigh!==null&&this._rangeAttrHighAtDirty===(this.getAttribute("high")||max))highInput.value=this._rangeUserHigh;else{highInput.value=highVal;this._rangeUserHigh=null;this._rangeAttrHighAtDirty=null}const label=this.getAttribute("label");if(label){lowInput.setAttribute("aria-label",label+" low");highInput.setAttribute("aria-label",label+" high")}Array.from(this.querySelectorAll('input[type="hidden"][data-range]')).forEach((n)=>n.remove())}else{Array.from(this.querySelectorAll("input.c-range__low, input.c-range__high, input[type='hidden'][data-range]")).forEach((n)=>n.remove());const input=this.ensure("input.c-range",()=>{const el=document.createElement("input");el.type="range";el.setAttribute("part","input");return el});input.className="c-range";input.type="range";input.min=min;input.max=max;const step=this.getAttribute("step");if(step)input.step=step;else input.removeAttribute("step");if(this.hasAttribute("disabled"))input.setAttribute("disabled","");else input.removeAttribute("disabled");const attrVal=this.getAttribute("value")||"50";if(this._rangeUserValue!==null&&this._rangeAttrAtDirty===(this.getAttribute("value")||"50")){input.value=this._rangeUserValue}else{input.value=attrVal;this._rangeUserValue=null;this._rangeAttrAtDirty=null}const label=this.getAttribute("label");if(label)input.setAttribute("aria-label",label);else if(!input.hasAttribute("aria-label"))input.setAttribute("aria-label","Range");const updateFill=()=>{const mn=Number(input.min)||0;const mx=Number(input.max)||100;const val=Number(input.value)||0;const pct=mx>mn?((val-mn)/(mx-mn))*100:0;input.style.setProperty("--fill",pct+"%")};updateFill();if(!input._fillWired){input._fillWired=true;input.addEventListener("input",updateFill)}}}}const _origRangeRender=ContourRange.prototype.render;ContourRange.prototype.attributeChangedCallback=function(name,oldValue,newValue){if(name==="value"){this._rangeUserValue=null;this._rangeAttrAtDirty=null}if(name==="low"){this._rangeUserLow=null;this._rangeAttrLowAtDirty=null}if(name==="high"){this._rangeUserHigh=null;this._rangeAttrHighAtDirty=null}return ContourBase.prototype.attributeChangedCallback.call(this,name,oldValue,newValue)};ContourRange.prototype._syncFormValue=function(){if(!this._internals)return;const low=this.querySelector("input.c-range__low");const high=this.querySelector("input.c-range__high");if(low&&high){const name=this.getAttribute("name");if(name){const fd=new FormData();fd.append(name,low.value);fd.append(name,high.value);this._internals.setFormValue(fd)}else{this._internals.setFormValue(null)}}else{const single=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");if(single)this._internals.setFormValue(single.value)}};ContourRange.prototype.formResetCallback=function(){this._contourResetting=true;try{this._rangeUserValue=null;this._rangeAttrAtDirty=null;this._rangeUserLow=null;this._rangeAttrLowAtDirty=null;this._rangeUserHigh=null;this._rangeAttrHighAtDirty=null;if(this.isConnected&&this._contourAuthored)this.attributeChangedCallback("__rerender__",null,"");this._syncFormValue()}finally{this._contourResetting=false}};ContourRange.prototype.formStateRestoreCallback=function(state){if(!this._internals||state===null||state===undefined)return;const low=this.querySelector("input.c-range__low");const high=this.querySelector("input.c-range__high");if(low&&high&&state instanceof FormData){const vals=state.getAll(this.getAttribute("name"));if(vals.length>=2){low.value=String(vals[0]);high.value=String(vals[1])}}else{const single=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");if(single)single.value=String(state)}this._syncFormValue()};ContourRange.prototype.enhance=function(){if(this._wiredRange)return;this._wiredRange=true;const sync=()=>{this._syncFormValue()};this.addEventListener("input",(e)=>{const low=this.querySelector("input.c-range__low");const high=this.querySelector("input.c-range__high");const single=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");if(low&&high&&(e.target===low||e.target===high)){this._rangeUserLow=low.value;this._rangeUserHigh=high.value;this._rangeAttrLowAtDirty=this.getAttribute("low")||(this.getAttribute("min")||"0");this._rangeAttrHighAtDirty=this.getAttribute("high")||(this.getAttribute("max")||"100");sync();this._emitForm("contour:input",{low:Number(low.value),high:Number(high.value)});this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{low:Number(low.value),high:Number(high.value)}}))}else if(single&&e.target===single){this._rangeUserValue=single.value;this._rangeAttrAtDirty=this.getAttribute("value")||"50";sync();this._emitForm("contour:input")}});this.addEventListener("change",(e)=>{const low=this.querySelector("input.c-range__low");const high=this.querySelector("input.c-range__high");const single=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");if(low&&high&&(e.target===low||e.target===high)){sync();this._emitForm("contour:change",{low:Number(low.value),high:Number(high.value)});this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{low:Number(low.value),high:Number(high.value)}}))}else if(single&&e.target===single){sync();this._emitForm("contour:change")}});sync()};define("contour-range",ContourRange);class ContourSwitch extends ContourBase{static get observed(){return["label","required","checked","disabled","error","help"]}static get properties(){return{label:{attribute:"label"},required:{attribute:"required",type:Boolean},checked:{attribute:"checked",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return true}render(){this.classList.add("c-switch");if(this._switchDefaultChecked===undefined)this._switchDefaultChecked=this.hasAttribute("checked");const label=this.getAttribute("label");const input=this.ensure("input.c-switch__input",()=>{const el=document.createElement("input");el.className="c-switch__input";el.type="checkbox";return el});input.checked=this.hasAttribute("checked");input.setAttribute("role","switch");input.setAttribute("aria-checked",String(input.checked));this._setCustomState("data-checked",input.checked);if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-switch__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-switch__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-switch__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");if(label){input.setAttribute("aria-label",label);const txt=this.querySelector(":scope > span:not([class])")||(()=>{const el=document.createElement("span");this.appendChild(el);return el})();txt.textContent=label}if(!input.hasAttribute("aria-label"))input.setAttribute("aria-label","Switch")}enhance(){const input=this.querySelector("input");if(input&&this._internals){input.setAttribute("aria-checked",String(input.checked));this._setCustomState("data-checked",input.checked);this._internals.setFormValue(input.checked?(input.value||"on"):null);this._syncValidity(this.hasAttribute("required")&&!input.checked)}if(this._wiredSwitch)return;this._wiredSwitch=true;this.addEventListener("click",(e)=>{if(e.target&&e.target.closest&&e.target.closest("input"))return;const inp=this.querySelector("input");if(!inp||inp.disabled)return;e.preventDefault();inp.click()});this.addEventListener("change",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;inp.setAttribute("aria-checked",String(inp.checked));this._setCustomState("data-checked",inp.checked);this.toggleAttribute("checked",inp.checked);this._internals.setFormValue(inp.checked?(inp.value||"on"):null);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!inp.checked)})}formResetCallback(){this._contourResetting=true;try{this.toggleAttribute("checked",!!this._switchDefaultChecked);const inp=this.querySelector("input");if(inp)inp.checked=this.hasAttribute("checked");this._syncFormValue()}finally{this._contourResetting=false}}}define("contour-switch",ContourSwitch);class ContourCheck extends ContourBase{static get observed(){return["label","name","value","required","type","checked","disabled","error","help"]}static get properties(){return{label:{attribute:"label"},name:{attribute:"name"},value:{attribute:"value"},required:{attribute:"required",type:Boolean},type:{attribute:"type"},checked:{attribute:"checked",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return true}render(){this.classList.add("c-check");if(this._checkDefaultChecked===undefined)this._checkDefaultChecked=this.hasAttribute("checked");const label=this.getAttribute("label");const input=this.ensure("input.c-check__input",()=>{const el=document.createElement("input");el.className="c-check__input";el.type=this.getAttribute("type")==="radio"?"radio":"checkbox";return el});input.checked=this.hasAttribute("checked");if(label){input.setAttribute("aria-label",label);const txt=this.querySelector(":scope > span:not([class])")||(()=>{const el=document.createElement("span");this.appendChild(el);return el})();txt.textContent=label}if(!input.hasAttribute("aria-label"))input.setAttribute("aria-label","Checkbox");if(this.hasAttribute("name"))input.name=this.getAttribute("name");if(this.hasAttribute("value"))input.value=this.getAttribute("value");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-check__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-check__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-check__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error")}enhance(){const input=this.querySelector("input");if(input&&this._internals){this._setCustomState("data-checked",input.checked);this._internals.setFormValue(input.checked?(input.value||"on"):null);this._syncValidity(this.hasAttribute("required")&&!input.checked)}if(this._wiredCheck)return;this._wiredCheck=true;this.addEventListener("click",(e)=>{if(e.target&&e.target.closest&&e.target.closest("input"))return;const inp=this.querySelector("input");if(!inp||inp.disabled)return;e.preventDefault();inp.click()});this.addEventListener("change",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;this._setCustomState("data-checked",inp.checked);this.toggleAttribute("checked",inp.checked);this._internals.setFormValue(inp.checked?(inp.value||"on"):null);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!inp.checked)})}formResetCallback(){this._contourResetting=true;try{this.toggleAttribute("checked",!!this._checkDefaultChecked);const inp=this.querySelector("input");if(inp)inp.checked=this.hasAttribute("checked");this._syncFormValue()}finally{this._contourResetting=false}}}define("contour-check",ContourCheck);class ContourRadio extends ContourBase{static get observed(){return["label","name","value","required","checked","disabled","error","help"]}static get properties(){return{label:{attribute:"label"},name:{attribute:"name"},value:{attribute:"value"},required:{attribute:"required",type:Boolean},checked:{attribute:"checked",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return true}render(){this.classList.add("c-radio");const label=this.getAttribute("label");const input=this.ensure("input.c-radio__input",()=>{const el=document.createElement("input");el.className="c-radio__input";el.type="radio";return el});input.checked=this.hasAttribute("checked");if(this.hasAttribute("name"))input.name=this.getAttribute("name");if(this.hasAttribute("value"))input.value=this.getAttribute("value");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-radio__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-radio__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-radio__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");if(label){input.setAttribute("aria-label",label);const txt=this.querySelector(":scope > span:not([class])")||(()=>{const el=document.createElement("span");this.appendChild(el);return el})();txt.textContent=label}if(!input.hasAttribute("aria-label"))input.setAttribute("aria-label","Radio")}enhance(){const input=this.querySelector("input");if(input&&this._internals){this._setCustomState("data-checked",input.checked);this._internals.setFormValue(input.checked?(input.value||"on"):null);this._syncValidity(this.hasAttribute("required")&&!input.checked)}if(this._wiredRadio)return;this._wiredRadio=true;this.addEventListener("click",(e)=>{if(e.target&&e.target.closest&&e.target.closest("input"))return;const inp=this.querySelector("input");if(!inp||inp.disabled)return;e.preventDefault();inp.click()});this.addEventListener("change",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;this._setCustomState("data-checked",inp.checked);this._internals.setFormValue(inp.checked?(inp.value||"on"):null);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!inp.checked)})}}define("contour-radio",ContourRadio);class ContourSelect extends ContourBase{static get observed(){return["options","required","label","placeholder","disabled","error","help","value","name","multiple","autocomplete"]}static get properties(){return{options:{attribute:"options"},required:{attribute:"required",type:Boolean},label:{attribute:"label"},placeholder:{attribute:"placeholder"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},value:{attribute:"value"},name:{attribute:"name"},multiple:{attribute:"multiple",type:Boolean},autocomplete:{attribute:"autocomplete"}}}static get formAssociated(){return true}render(){this.classList.add("c-select");if(this._selectDefault===undefined)this._selectDefault=this.getAttribute("value");const options=this.getAttribute("options");const generated=new Set(this._contourGenerated||[]);const authored=Array.from(this.children).filter((n)=>!generated.has(n));if(options&&!authored.length){try{const parsed=JSON.parse(options);const select=this.ensure("select.c-select",()=>{const el=document.createElement("select");el.className="c-select";return el});select.innerHTML="";const label=this.getAttribute("label");if(label){select.setAttribute("aria-label",label)}const placeholder=this.getAttribute("placeholder");if(placeholder){const ph=document.createElement("option");ph.value="";ph.textContent=placeholder;ph.disabled=true;ph.selected=true;select.appendChild(ph)}const groups={};parsed.forEach((opt)=>{const g=(typeof opt==="object"&&opt!==null)?opt.group:null;if(g){if(!groups[g]){groups[g]=document.createElement("optgroup");groups[g].label=g;select.appendChild(groups[g])}const option=document.createElement("option");option.value=typeof opt==="string"?opt:opt.value;option.textContent=typeof opt==="string"?opt:opt.label;groups[g].appendChild(option)}else{const option=document.createElement("option");option.value=typeof opt==="string"?opt:opt.value;option.textContent=typeof opt==="string"?opt:opt.label;select.appendChild(option)}});if(select.parentNode!==this)this.appendChild(select);this.classList.remove("c-select");select.classList.add("c-select")}catch(e){warnBadJson(this,"attribute",e)}}const authoredSel=this.querySelector("select");if(authoredSel&&!authoredSel.classList.contains("c-select")){authoredSel.classList.add("c-select");this.classList.remove("c-select")}const sel=this.querySelector("select");if(sel){if(this.hasAttribute("disabled")){sel.setAttribute("disabled","");this.classList.add("is-disabled")}else{sel.removeAttribute("disabled");this.classList.remove("is-disabled")}if(this.hasAttribute("name"))sel.setAttribute("name",this.getAttribute("name"));if(this.hasAttribute("multiple"))sel.setAttribute("multiple","");else sel.removeAttribute("multiple");if(this.hasAttribute("autocomplete"))sel.setAttribute("autocomplete",this.getAttribute("autocomplete"));if(this.hasAttribute("required"))sel.setAttribute("required","");else sel.removeAttribute("required");const val=this.getAttribute("value");if(val!==null){if(sel.multiple){const wanted=new Set(String(val).split(",").map((v)=>v.trim()).filter(Boolean));Array.from(sel.options).forEach((o)=>{o.selected=wanted.has(o.value)})}else{sel.value=val}}}const label=this.getAttribute("label");if(label){let lbl=this.querySelector("label.c-select__label");if(!lbl){lbl=document.createElement("label");lbl.className="c-select__label";this.insertBefore(lbl,sel||this.firstChild)}lbl.textContent=label;if(sel){if(!sel.id)sel.id=contourId("contour-select");lbl.setAttribute("for",sel.id);sel.setAttribute("aria-label",label)}}if(!this.querySelector("select")?.hasAttribute("aria-label")){const sel=this.querySelector("select");if(sel)sel.setAttribute("aria-label","Select")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-select__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-select__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-select__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error")}enhance(){if(this._internals)this._syncFormValue();if(this._wiredSelect)return;this._wiredSelect=true;this.addEventListener("input",(e)=>{const sel=this.querySelector("select");if(!sel||e.target!==sel)return;this._emitForm("contour:input")});this.addEventListener("change",(e)=>{const sel=this.querySelector("select");if(!sel||e.target!==sel||!this._internals)return;const committed=sel.multiple?Array.from(sel.selectedOptions).map((o)=>o.value).join(","):sel.value;this.setAttribute("value",committed);this._syncFormValue();this._emitForm("contour:change")})}_syncFormValue(){if(!this._internals)return;const sel=this.querySelector("select");if(!sel)return;if(sel.multiple){const chosen=Array.from(sel.selectedOptions).map((o)=>o.value);const name=this.getAttribute("name");if(name&&chosen.length){const fd=new FormData();for(const v of chosen)fd.append(name,v);this._internals.setFormValue(fd)}else{this._internals.setFormValue(null)}this._syncValidity(this.hasAttribute("required")&&!chosen.length)}else{this._internals.setFormValue(sel.value);this._syncValidity(this.hasAttribute("required")&&!sel.value)}}formResetCallback(){this._contourResetting=true;try{const def=this._selectDefault??null;if(def===null)this.removeAttribute("value");else this.setAttribute("value",def);this._syncFormValue()}finally{this._contourResetting=false}}formStateRestoreCallback(state){const sel=this.querySelector("select");if(!sel||!this._internals)return;const values=state instanceof FormData?Array.from(state.getAll(this.getAttribute("name"))).map(String):(state==null?[]:String(state).split(",").map((v)=>v.trim()).filter(Boolean));this._contourResetting=true;try{if(sel.multiple){const wanted=new Set(values);for(const o of sel.options)o.selected=wanted.has(o.value);this.setAttribute("value",values.join(","))}else{sel.value=values[0]||"";this.setAttribute("value",sel.value)}this._syncFormValue()}finally{this._contourResetting=false}}}define("contour-select",ContourSelect);class ContourVersion extends ContourBase{static get observed(){return["options","value","name"]}static get formAssociated(){return true}static get properties(){return{options:{attribute:"options"},value:{attribute:"value"},name:{attribute:"name"}}}render(){this.classList.add("c-version");if(this._versionDefault===undefined)this._versionDefault=this.getAttribute("value");const options=this.getAttribute("options");const generated=new Set(this._contourGenerated||[]);const authored=Array.from(this.children).filter((n)=>!generated.has(n));if(options&&!authored.length){try{const parsed=JSON.parse(options);const select=this.ensure("select.c-version",()=>{const el=document.createElement("select");el.className="c-version";return el});select.innerHTML="";if(!select.hasAttribute("aria-label"))select.setAttribute("aria-label","Version");parsed.forEach((opt)=>{const option=document.createElement("option");if(typeof opt==="string"){option.value=opt;option.textContent=opt}else{option.value=opt.value||opt.label;option.textContent=opt.label||opt.value;if(opt.selected)option.selected=true}select.appendChild(option)});if(select.parentNode!==this)this.appendChild(select);this.classList.remove("c-version");select.classList.add("c-version")}catch(e){warnBadJson(this,"attribute",e)}}const sel=this.querySelector("select");if(sel){if(this.hasAttribute("name"))sel.setAttribute("name",this.getAttribute("name"));const val=this.getAttribute("value");if(val!==null)sel.value=val}}enhance(){const sync=()=>{const select=this.querySelector("select");if(!select||!this._internals)return;this._internals.setFormValue(select.value)};sync();if(this._wiredVersion)return;this._wiredVersion=true;this.addEventListener("change",(e)=>{const select=this.querySelector("select");if(!select||e.target!==select)return;this.setAttribute("value",select.value);sync();this._emitForm("contour:change")})}formResetCallback(){this._contourResetting=true;try{const def=this._versionDefault??null;if(def===null)this.removeAttribute("value");else this.setAttribute("value",def);this._syncFormValue()}finally{this._contourResetting=false}}}define("contour-version",ContourVersion);class ContourTextarea extends ContourBase{static get observed(){return["placeholder","required","disabled","error","help","value","name","label"]}static get properties(){return{placeholder:{attribute:"placeholder"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},value:{attribute:"value"},name:{attribute:"name"},label:{attribute:"label"}}}static get formAssociated(){return true}render(){const ta=this.ensure("textarea",()=>{const el=document.createElement("textarea");el.className="c-textarea";return el});ta.className="c-textarea";if(this.hasAttribute("name"))ta.name=this.getAttribute("name");else ta.removeAttribute("name");if(this.hasAttribute("value"))ta.value=this.getAttribute("value");if(this.hasAttribute("aria-label")&&!ta.hasAttribute("aria-label"))ta.setAttribute("aria-label",this.getAttribute("aria-label"));if(this.hasAttribute("label")&&!ta.hasAttribute("aria-label"))ta.setAttribute("aria-label",this.getAttribute("label"));if(!ta.hasAttribute("aria-label"))ta.setAttribute("aria-label","Textarea");if(this.hasAttribute("placeholder"))ta.placeholder=this.getAttribute("placeholder");else ta.removeAttribute("placeholder");if(this.hasAttribute("required"))ta.setAttribute("required","");else ta.removeAttribute("required");if(this.hasAttribute("disabled")){ta.setAttribute("disabled","");this.classList.add("is-disabled")}else{ta.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-textarea__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-textarea__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-textarea__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error")}enhance(){const ta=this.querySelector("textarea");if(ta&&this._internals){this._internals.setFormValue(ta.value);this._syncValidity(this.hasAttribute("required")&&!ta.value.trim())}if(this._wiredTextarea)return;this._wiredTextarea=true;this.addEventListener("input",(e)=>{const t=this.querySelector("textarea");if(!t||e.target!==t||!this._internals)return;this._internals.setFormValue(t.value);this._emitForm("contour:input");this._syncValidity(this.hasAttribute("required")&&!t.value.trim())});this.addEventListener("change",(e)=>{const t=this.querySelector("textarea");if(!t||e.target!==t||!this._internals)return;this._internals.setFormValue(t.value);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!t.value.trim())})}}define("contour-textarea",ContourTextarea);class ContourInputFull extends ContourBase{static get observed(){return["type","placeholder","required","value","disabled","error","help","label","name"]}static get properties(){return{type:{attribute:"type"},placeholder:{attribute:"placeholder"},required:{attribute:"required",type:Boolean},value:{attribute:"value"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},label:{attribute:"label"},name:{attribute:"name"}}}static get formAssociated(){return true}render(){this.classList.add("c-input");const input=this.ensure("input",()=>{const el=document.createElement("input");el.className="c-input";return el});input.className="c-input";input.type=this.getAttribute("type")||"text";input.placeholder=this.getAttribute("placeholder")||"";if(this.hasAttribute("name"))input.name=this.getAttribute("name");else input.removeAttribute("name");let label=this.getAttribute("label");if(!label){const field=this.closest("contour-field");if(field)label=field.getAttribute("label")}if(label)input.setAttribute("aria-label",label);else if(!input.getAttribute("aria-label"))input.setAttribute("aria-label","Input");if(this.hasAttribute("value"))input.value=this.getAttribute("value");if(this.hasAttribute("required"))input.setAttribute("required","");else input.removeAttribute("required");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-input__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-input__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-input__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error")}enhance(){const input=this.querySelector("input");if(input&&this._internals){this._internals.setFormValue(input.value);this._syncValidity(this.hasAttribute("required")&&!input.value.trim())}if(this._wiredInput)return;this._wiredInput=true;this.addEventListener("input",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;this._internals.setFormValue(inp.value);this._emitForm("contour:input");this._syncValidity(this.hasAttribute("required")&&!inp.value.trim())});this.addEventListener("change",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;this._internals.setFormValue(inp.value);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!inp.value.trim())})}}define("contour-input",ContourInputFull);class ContourInputGroup extends ContourBase{static get observed(){return["label","placeholder","clearable","submit","value","name","required","disabled"]}static get properties(){return{label:{attribute:"label"},placeholder:{attribute:"placeholder"},clearable:{attribute:"clearable",type:Boolean},submit:{attribute:"submit",type:Boolean},value:{attribute:"value"},name:{attribute:"name"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean}}}static get formAssociated(){return true}render(){this.classList.add("c-input-group");const icon=this.ensure("svg",()=>{const el=document.createElementNS("http://www.w3.org/2000/svg","svg");el.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href","#i-search");el.appendChild(use);return el});const input=this.ensure("input.c-input",()=>{const el=document.createElement("input");el.className="c-input";el.type="text";return el});input.placeholder=this.getAttribute("placeholder")||this.getAttribute("label")||"";if(this.hasAttribute("name"))input.name=this.getAttribute("name");else input.removeAttribute("name");if(this.hasAttribute("value"))input.value=this.getAttribute("value");if(this.hasAttribute("required"))input.setAttribute("required","");else input.removeAttribute("required");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const label=this.getAttribute("label");if(!input.hasAttribute("aria-label"))input.setAttribute("aria-label",label||"Search");const oldClear=this.querySelector(".c-input-group__clear");if(oldClear)oldClear.remove();if(this.hasAttribute("clearable")){const btn=document.createElement("button");btn.className="c-input-group__clear";btn.type="button";btn.setAttribute("aria-label","Clear");btn.textContent="×";this.appendChild(btn)}const oldSubmit=this.querySelector(".c-input-group__submit");if(oldSubmit)oldSubmit.remove();if(this.hasAttribute("submit")){const btn=document.createElement("button");btn.className="c-input-group__submit";btn.type="submit";btn.setAttribute("aria-label","Submit");btn.textContent="→";this.appendChild(btn)}}enhance(){const input=this.querySelector("input.c-input");if(input&&this._internals){this._internals.setFormValue(input.value);this._syncValidity(this.hasAttribute("required")&&!input.value.trim())}if(this._wiredInputGroup)return;this._wiredInputGroup=true;this.addEventListener("input",(e)=>{const inp=this.querySelector("input.c-input");if(!inp||e.target!==inp||!this._internals)return;this._internals.setFormValue(inp.value);this._emitForm("contour:input");this._syncValidity(this.hasAttribute("required")&&!inp.value.trim())});this.addEventListener("change",(e)=>{const inp=this.querySelector("input.c-input");if(!inp||e.target!==inp||!this._internals)return;this._internals.setFormValue(inp.value);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!inp.value.trim())});this.addEventListener("click",(e)=>{const clear=e.target&&e.target.closest?e.target.closest(".c-input-group__clear"):null;if(clear&&this.contains(clear)){e.preventDefault();const input=this.querySelector("input.c-input");if(input){input.value="";input.focus()}if(this._internals){this._internals.setFormValue("");this._syncValidity(this.hasAttribute("required"))}this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:""}}))}})}}define("contour-input-group",ContourInputGroup);class ContourRadioList extends ContourBase{static get observed(){return["items","name","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},name:{attribute:"name"},src:{attribute:"src"}}}static get formAssociated(){return true}render(){this.classList.add("c-radio-list");this.setAttribute("role","radiogroup");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("name")||"Options");wireStates(this);loadRemote(this,"items");if(renderStates(this,"radio-list"))return;const items=remoteData(this,"items");Array.from(this.querySelectorAll("label.c-radio")).forEach((l)=>l.remove());if(items){try{const parsed=JSON.parse(items);const groupName=this.getAttribute("name")||contourId("radio-list");parsed.forEach((it)=>{const lbl=document.createElement("label");lbl.className="c-radio";const input=document.createElement("input");input.type="radio";input.className="c-radio__input";input.name=groupName;input.tabIndex=-1;if(typeof it==="string"){input.value=it;lbl.appendChild(input);lbl.appendChild(document.createTextNode(" "+it))}else{input.value=it.value||it.label;if(it.checked)input.checked=true;lbl.appendChild(input);const span=document.createElement("span");span.textContent=it.label||it.value;lbl.appendChild(span)}this.appendChild(lbl)});const radios=Array.from(this.querySelectorAll("input.c-radio__input"));const checked=radios.find((r)=>r.checked)||radios[0];if(checked)checked.tabIndex=0}catch(e){warnBadJson(this,"attribute",e)}}else{renderEmpty(this,"radio-list")}}enhance(){const sync=()=>{if(!this._internals)return;const checked=this.querySelector("input.c-radio__input:checked");this._internals.setFormValue(checked?checked.value:null)};sync();if(this._wiredRadioList)return;this._wiredRadioList=true;this.addEventListener("change",(e)=>{const input=e.target&&e.target.closest?e.target.closest("input.c-radio__input"):null;if(!input||!this.contains(input))return;sync();this._emitForm("contour:change")});this.addEventListener("keydown",(e)=>{const radios=Array.from(this.querySelectorAll("input.c-radio__input"));if(!radios.length)return;const idx=radios.indexOf(e.target);if(idx===-1)return;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";let next=-1;if(e.key==="ArrowDown")next=(idx+1)%radios.length;else if(e.key==="ArrowUp")next=(idx-1+radios.length)%radios.length;else if(e.key==="ArrowRight")next=rtl?(idx-1+radios.length)%radios.length:(idx+1)%radios.length;else if(e.key==="ArrowLeft")next=rtl?(idx+1)%radios.length:(idx-1+radios.length)%radios.length;else if(e.key==="Home")next=0;else if(e.key==="End")next=radios.length-1;else return;e.preventDefault();const before=radios.find((r)=>r.checked);for(const r of radios)r.tabIndex=-1;radios[next].tabIndex=0;radios[next].checked=true;radios[next].focus();sync();if(before!==radios[next])this._emitForm("contour:change")})}formResetCallback(){this._contourResetting=true;try{if(this.isConnected&&this._contourAuthored)this.attributeChangedCallback("__rerender__",null,"");this._syncFormValue()}finally{this._contourResetting=false}}}define("contour-radio-list",ContourRadioList);class ContourFieldset extends ContourBase{static get observed(){return["legend","disabled"]}static get properties(){return{legend:{attribute:"legend"},disabled:{attribute:"disabled",type:Boolean}}}render(){const fs=this.ensure("fieldset",()=>{const el=document.createElement("fieldset");el.className="c-fieldset";return el});if(this.hasAttribute("disabled"))fs.setAttribute("disabled","");else fs.removeAttribute("disabled");const legend=this.getAttribute("legend");let lg=fs.querySelector("legend");if(legend){if(!lg){lg=document.createElement("legend");lg.className="c-fieldset__legend";fs.prepend(lg)}lg.textContent=legend}else if(lg)lg.remove();const authored=Array.from(this.children).filter((c)=>c!==fs);if(authored.length){authored.forEach((c)=>fs.appendChild(c))}}}define("contour-fieldset",ContourFieldset);class ContourCheckboxGroup extends ContourBase{static get observed(){return["legend","name","options","value","required","disabled"]}static get properties(){return{legend:{attribute:"legend"},name:{attribute:"name"},options:{attribute:"options"},value:{attribute:"value"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean}}}static get formAssociated(){return true}render(){this.classList.add("c-checkbox-group");if(this._checkboxGroupDefault===undefined)this._checkboxGroupDefault=this.getAttribute("value");const fs=this.ensure("fieldset",()=>{const el=document.createElement("fieldset");el.className="c-checkbox-group__fieldset";return el});if(this.hasAttribute("disabled"))fs.setAttribute("disabled","");else fs.removeAttribute("disabled");if(this.hasAttribute("required"))fs.setAttribute("aria-required","true");else fs.removeAttribute("aria-required");const legend=this.getAttribute("legend");let lg=fs.querySelector("legend");if(legend){if(!lg){lg=document.createElement("legend");lg.className="c-checkbox-group__legend";fs.prepend(lg)}lg.textContent=legend}else if(lg)lg.remove();const name=this.getAttribute("name")||"group";const options=this.getAttribute("options");const selected=(this.getAttribute("value")||"").split(",").map((s)=>s.trim()).filter(Boolean);if(options){try{const parsed=JSON.parse(options);Array.from(fs.querySelectorAll(".c-check")).forEach((n)=>n.remove());parsed.forEach((opt)=>{const label=typeof opt==="string"?opt:(opt.label||opt.value||"");const value=typeof opt==="string"?opt:(opt.value||opt.label||"");const wrap=document.createElement("label");wrap.className="c-check";const input=document.createElement("input");input.type="checkbox";input.className="c-check__input";input.name=name;input.value=value;input.setAttribute("data-contour-preserve-key",value);if(selected.includes(value))input.checked=true;const span=document.createElement("span");span.textContent=label;wrap.appendChild(input);wrap.appendChild(span);fs.appendChild(wrap)})}catch(e){warnBadJson(this,"attribute",e)}}}enhance(){if(this._internals)this._syncFormValue();if(this._wiredCheckboxGroup)return;this._wiredCheckboxGroup=true;this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.matches&&t.matches("input[type=checkbox]")){const values=Array.from(this.querySelectorAll("input[type=checkbox]:checked")).map((i)=>i.value);this.setAttribute("value",values.join(","));this._syncFormValue();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:values.join(","),values}}))}})}_syncFormValue(){if(!this._internals)return;const checked=Array.from(this.querySelectorAll("input[type=checkbox]:checked"));const name=this.getAttribute("name");if(name&&checked.length){const fd=new FormData();for(const c of checked)fd.append(name,c.value);this._internals.setFormValue(fd)}else{this._internals.setFormValue(null)}this._syncValidity(this.hasAttribute("required")&&!checked.length)}formResetCallback(){this._contourResetting=true;try{const def=this._checkboxGroupDefault??null;if(def===null)this.removeAttribute("value");else this.setAttribute("value",def);this._syncFormValue()}finally{this._contourResetting=false}}formStateRestoreCallback(state){const values=state instanceof FormData?Array.from(state.getAll(this.getAttribute("name"))).map(String):(state==null?[]:String(state).split(",").map((v)=>v.trim()).filter(Boolean));this._contourResetting=true;try{this.setAttribute("value",values.join(","));this._syncFormValue()}finally{this._contourResetting=false}}}define("contour-checkbox-group",ContourCheckboxGroup);class ContourSearchField extends ContourBase{static get observed(){return["value","placeholder","label","name","required","disabled"]}static get properties(){return{value:{attribute:"value"},placeholder:{attribute:"placeholder"},label:{attribute:"label"},name:{attribute:"name"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean}}}static get formAssociated(){return true}render(){this.classList.add("c-search-field");const input=this.ensure("input",()=>{const el=document.createElement("input");el.type="search";el.className="c-search-field__input";return el});input.placeholder=this.getAttribute("placeholder")||"Search";if(this.getAttribute("value")!==null)input.value=this.getAttribute("value");if(this.hasAttribute("name"))input.name=this.getAttribute("name");if(this.hasAttribute("required"))input.setAttribute("required","");else input.removeAttribute("required");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const label=this.getAttribute("label");if(label)input.setAttribute("aria-label",label);else if(!input.hasAttribute("aria-label"))input.setAttribute("aria-label","Search")}enhance(){const input=this.querySelector("input");if(input&&this._internals){this._internals.setFormValue(input.value);this._syncValidity(this.hasAttribute("required")&&!input.value.trim())}if(this._wiredSearchField)return;this._wiredSearchField=true;this.addEventListener("input",(e)=>{const t=e.target;if(t&&t.matches&&t.matches("input")){if(this._internals){this._internals.setFormValue(t.value);this._syncValidity(this.hasAttribute("required")&&!t.value.trim())}this._emitForm("contour:input")}});this.addEventListener("change",(e)=>{const t=e.target;if(!t||!t.matches||!t.matches("input")||!this._internals)return;this._internals.setFormValue(t.value);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!t.value.trim())})}}define("contour-search-field",ContourSearchField);class ContourDensityToggle extends ContourBase{static get observed(){return["value","label"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"}}}render(){this.classList.add("c-density-toggle");const value=this.getAttribute("value")||"comfortable";this.setAttribute("data-density",value);const btn=this.ensure("button",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-density-toggle__btn";el.type="button";return el});const label=this.getAttribute("label")||(value==="compact"?"Compact":"Comfortable");btn.textContent=label;btn.setAttribute("aria-pressed",value==="compact"?"true":"false")}enhance(){if(this._wiredDensityToggle)return;this._wiredDensityToggle=true;this.addEventListener("click",()=>{const next=this.getAttribute("data-density")==="compact"?"comfortable":"compact";this.setAttribute("value",next);this.setAttribute("data-density",next);const btn=this.querySelector(".c-density-toggle__btn");if(btn){btn.textContent=next==="compact"?"Compact":"Comfortable";btn.setAttribute("aria-pressed",next==="compact"?"true":"false")}this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:next}}))})}}define("contour-density-toggle",ContourDensityToggle);class ContourPressableFull extends ContourBase{static get observed(){return["disabled"]}static get properties(){return{disabled:{attribute:"disabled",type:Boolean}}}render(){this.classList.add("c-pressable");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"Pressable");if(this.hasAttribute("disabled")){this.setAttribute("aria-disabled","true");this.setAttribute("tabindex","-1")}else{this.removeAttribute("aria-disabled");if(!this.hasAttribute("tabindex")||this.getAttribute("tabindex")==="-1")this.setAttribute("tabindex","0")}}enhance(){if(this._wiredPressable)return;this._wiredPressable=true;this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.click();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}})}}define("contour-pressable",ContourPressableFull);class ContourResizeHandleFull extends ContourBase{render(){this.classList.add("c-resize-handle");if(!this.hasAttribute("role"))this.setAttribute("role","separator");if(!this.hasAttribute("aria-valuenow"))this.setAttribute("aria-valuenow","0");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Resize handle");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(!this.hasAttribute("aria-orientation"))this.setAttribute("aria-orientation","horizontal")}enhance(){if(this._wiredResizeHandle)return;this._wiredResizeHandle=true;this.addEventListener("keydown",(e)=>{let delta=0;if(e.key==="ArrowLeft"||e.key==="ArrowDown")delta=-5;else if(e.key==="ArrowRight"||e.key==="ArrowUp")delta=5;else if(e.key==="Home")delta=-Infinity;else if(e.key==="End")delta=Infinity;else return;e.preventDefault();const cur=Number(this.getAttribute("aria-valuenow"))||0;let next;if(delta===-Infinity)next=0;else if(delta===Infinity)next=100;else next=Math.min(100,Math.max(0,cur+delta));this.setAttribute("aria-valuenow",String(next));this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:true,composed:true,detail:{value:next,delta}}))})}}define("contour-resize-handle",ContourResizeHandleFull);class ContourSearchTriggerFull extends ContourBase{static get observed(){return["label","shortcut"]}static get properties(){return{label:{attribute:"label"},shortcut:{attribute:"shortcut"}}}render(){this.classList.add("c-search-trigger");const label=this.getAttribute("label")||"Search";if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label);const span=this.ensure(".c-search-trigger__text",()=>{const el=document.createElement("span");el.className="c-search-trigger__text";return el});span.className="c-search-trigger__text";if(!span.textContent.trim()||span.textContent.trim()!==label)span.textContent=label;const kbd=this.ensure("kbd.c-search-trigger__kbd",()=>{const el=document.createElement("kbd");el.className="c-search-trigger__kbd";return el});kbd.className="c-search-trigger__kbd";kbd.textContent=this.getAttribute("shortcut")||"⌘K"}}define("contour-search-trigger",ContourSearchTriggerFull);class ContourShortcutListFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-shortcut-list");this.setAttribute("role","list");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-shortcut-list__title",()=>{const el=document.createElement("div");el.className="c-shortcut-list__title";el.style.padding="var(--space-sm)";el.style.fontWeight="var(--weight-semibold)";return el});t.textContent=title}}}define("contour-shortcut-list",ContourShortcutListFull);class ContourShortcutRowFull extends ContourBase{static get observed(){return["desc","key"]}static get properties(){return{desc:{attribute:"desc"},key:{attribute:"key"}}}render(){this.classList.add("c-shortcut-row");const key=this.getAttribute("key");const desc=this.getAttribute("desc");if(key){const k=this.ensure(".c-shortcut-row__keys",()=>{const el=document.createElement("kbd");el.className="c-shortcut-row__keys";return el});k.className="c-shortcut-row__keys";k.textContent=key}else{const k=this.querySelector(".c-shortcut-row__keys");if(k)k.remove()}if(desc){const s=this.ensure(".c-shortcut-row__label",()=>{const el=document.createElement("span");el.className="c-shortcut-row__label";return el});s.className="c-shortcut-row__label";s.textContent=desc}else{const s=this.querySelector(".c-shortcut-row__label");if(s)s.remove()}}}define("contour-shortcut-row",ContourShortcutRowFull);class ContourShortcutPanelFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-shortcut-panel");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-shortcut-panel__title",()=>{const el=document.createElement("div");el.className="c-shortcut-panel__title";return el});t.textContent=title}else{const t=this.querySelector(".c-shortcut-panel__title");if(t)t.remove()}}}define("contour-shortcut-panel",ContourShortcutPanelFull);class ContourShortcutOverlayFull extends ContourBase{static get observed(){return["title","open"]}static get properties(){return{title:{attribute:"title"},open:{attribute:"open",type:Boolean}}}render(){this.classList.add("c-shortcut-overlay");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("aria-modal"))this.setAttribute("aria-modal","true");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("title")||"Keyboard shortcuts");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-shortcut-overlay__title",()=>{const el=document.createElement("div");el.className="c-shortcut-overlay__title";return el});t.textContent=title}if(this.hasAttribute("open"))this.removeAttribute("hidden");else if(!this.hasAttribute("hidden"))this.setAttribute("hidden","")}show(){this.setAttribute("open","");this.removeAttribute("hidden");modalContain(this,true);this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))}hide(){this.removeAttribute("open");this.setAttribute("hidden","");modalContain(this,false);this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))}toggle(){if(this.hasAttribute("open"))this.hide();else this.show()}enhance(){if(this._wiredShortcutOverlay)return;this._wiredShortcutOverlay=true;const keyHandler=(e)=>{if(e.key==="?"&&!e.metaKey&&!e.ctrlKey&&!e.altKey){const tag=(e.target&&e.target.tagName)||"";if(tag==="INPUT"||tag==="TEXTAREA"||(e.target&&e.target.isContentEditable))return;e.preventDefault();this.toggle()}else if(e.key==="Escape"&&this.hasAttribute("open")){this.hide()}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("click",(e)=>{if(e.target===this)this.hide()})}}define("contour-shortcut-overlay",ContourShortcutOverlayFull);class ContourRowActionFull extends ContourBase{static get observed(){return["label","disabled"]}static get properties(){return{label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean}}}render(){this.classList.add("c-row-action");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(this.hasAttribute("disabled")){this.setAttribute("aria-disabled","true");this.setAttribute("tabindex","-1")}else{this.removeAttribute("aria-disabled");if(!this.hasAttribute("tabindex")||this.getAttribute("tabindex")==="-1")this.setAttribute("tabindex","0")}const label=this.getAttribute("label");if(label&&!this.hasChildNodes())this.textContent=label;if(label&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label)}enhance(){if(this._wiredRowAction)return;this._wiredRowAction=true;this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.click();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}})}}define("contour-row-action",ContourRowActionFull);class ContourSegmented extends ContourBase{static get observed(){return["options","selected","label","value"]}static get properties(){return{options:{attribute:"options"},selected:{attribute:"selected"},label:{attribute:"label"},value:{attribute:"value"}}}render(){this.classList.add("c-segmented");const options=this.getAttribute("options");if(options){let parsed=null;try{parsed=JSON.parse(options)}catch(e){parsed=null}if(Array.isArray(parsed)){Array.from(this.querySelectorAll("button.c-segmented__option")).forEach((n)=>n.remove());const selected=this.getAttribute("selected")||this.getAttribute("value");parsed.forEach((opt,i)=>{const label=typeof opt==="string"?opt:(opt.label||opt.value||"");const val=typeof opt==="string"?opt:(opt.value||opt.label||"");const btn=document.createElement("button");btn.className="c-segmented__option";btn.type="button";btn.textContent=label;btn.dataset.value=val;if(selected!==null&&String(val)===String(selected))btn.setAttribute("aria-pressed","true");else if(selected===null&&i===0)btn.setAttribute("aria-pressed","true");else btn.setAttribute("aria-pressed","false");this.appendChild(btn)})}}}enhance(){wireSegmented(this)}}define("contour-segmented",ContourSegmented);class ContourDraggable extends ContourBase{render(){this.classList.add("c-draggable");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(!this.hasAttribute("draggable"))this.setAttribute("draggable","true");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"Draggable item")}_dragValue(){return this.getAttribute("value")||this.getAttribute("label")||(this.textContent||"").trim()||"draggable"}enhance(){if(this._wiredDraggable)return;this._wiredDraggable=true;this.addEventListener("dragstart",(e)=>{if(!e.dataTransfer)return;const value=this._dragValue();try{e.dataTransfer.effectAllowed="move"}catch(err){}e.dataTransfer.setData("text/plain",value);this.classList.add("c-draggable--dragging");this.dispatchEvent(new CustomEvent("contour:dragstart",{bubbles:true,composed:true,detail:{value}}))});this.addEventListener("dragend",()=>{this.classList.remove("c-draggable--dragging");this.dispatchEvent(new CustomEvent("contour:dragend",{bubbles:true,composed:true,detail:{value:this._dragValue()}}))});this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}));return}if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:move",{bubbles:true,composed:true,detail:{direction:e.key==="ArrowUp"?"up":"down"}}))}})}}define("contour-draggable",ContourDraggable);class ContourDragHandle extends ContourBase{render(){this.classList.add("c-drag-handle");if(!this.hasAttribute("role"))this.setAttribute("role","separator");const min=this.getAttribute("min")||"0";const max=this.getAttribute("max")||"100";if(!this.hasAttribute("aria-valuenow"))this.setAttribute("aria-valuenow",min);if(!this.hasAttribute("aria-valuemin"))this.setAttribute("aria-valuemin",min);if(!this.hasAttribute("aria-valuemax"))this.setAttribute("aria-valuemax",max);if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"Drag handle");if(!this.hasAttribute("aria-orientation"))this.setAttribute("aria-orientation","horizontal");const controls=this.getAttribute("controls");if(controls&&!this.hasAttribute("aria-controls"))this.setAttribute("aria-controls",controls)}enhance(){if(this._wiredDragHandle)return;this._wiredDragHandle=true;this.addEventListener("keydown",(e)=>{const now=Number(this.getAttribute("aria-valuenow")||0);const min=Number(this.getAttribute("aria-valuemin")||0);const max=Number(this.getAttribute("aria-valuemax")||100);let delta=0;if(e.key==="ArrowLeft"||e.key==="ArrowDown")delta=-1;else if(e.key==="ArrowRight"||e.key==="ArrowUp")delta=1;else if(e.key==="Home")delta=min-now;else if(e.key==="End")delta=max-now;else return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:true,composed:true,detail:{key:e.key,delta,value:now}}))})}}define("contour-drag-handle",ContourDragHandle);class ContourDropIndicator extends ContourBase{static get observed(){return["label","open"]}static get properties(){return{label:{attribute:"label"},open:{attribute:"open",type:Boolean}}}render(){this.classList.add("c-drop-indicator");this.classList.toggle("c-drop-indicator--visible",this.hasAttribute("open"));if(!this.hasAttribute("role"))this.setAttribute("role","presentation");if(this.getAttribute("role")==="presentation"){this.removeAttribute("aria-label");this.removeAttribute("aria-labelledby")}Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===Node.TEXT_NODE)n.remove();else if(n.nodeType===Node.ELEMENT_NODE&&n.tagName==="SPAN")n.remove()});const label=this.getAttribute("label");if(label){const t=this.ensure(".c-drop-indicator__label",()=>{const el=document.createElement("span");el.className="c-drop-indicator__label";return el});t.textContent=label}}}define("contour-drop-indicator",ContourDropIndicator);class ContourDropZone extends ContourBase{static get observed(){return["label"]}static get properties(){return{label:{attribute:"label"}}}render(){this.classList.add("c-drop-zone");if(!this.hasAttribute("role"))this.setAttribute("role","region");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"Drop zone");Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===Node.TEXT_NODE)n.remove();else if(n.nodeType===Node.ELEMENT_NODE&&n.tagName==="SPAN")n.remove()});const label=this.getAttribute("label");if(label){const t=this.ensure(".c-drop-zone__label",()=>{const el=document.createElement("p");el.className="c-drop-zone__label";return el});t.textContent=label}}enhance(){if(this._wiredDropZone)return;this._wiredDropZone=true;const accepts=(e)=>e.dataTransfer&&Array.from(e.dataTransfer.types).includes("text/plain");const clear=()=>{this.classList.remove("c-drop-zone--active","c-drop-zone--reject")};this.addEventListener("dragenter",(e)=>{if(!e.dataTransfer)return;this.classList.toggle("c-drop-zone--reject",!accepts(e));if(accepts(e)){e.preventDefault();this.classList.add("c-drop-zone--active")}});this.addEventListener("dragover",(e)=>{if(!e.dataTransfer)return;this.classList.toggle("c-drop-zone--reject",!accepts(e));if(accepts(e)){e.preventDefault();this.classList.add("c-drop-zone--active")}});this.addEventListener("dragleave",clear);this.addEventListener("drop",(e)=>{if(!accepts(e))return;e.preventDefault();clear();const value=e.dataTransfer.getData("text/plain")||"";this.dispatchEvent(new CustomEvent("contour:drop",{bubbles:true,composed:true,detail:{value,label:this.getAttribute("label")}}))})}}define("contour-drop-zone",ContourDropZone);class ContourResizable extends ContourBase{static get observed(){return["direction","value"]}static get properties(){return{direction:{attribute:"direction"},value:{attribute:"value"}}}render(){this.classList.add("c-resizable");this.classList.remove("c-resizable--vertical","c-resizable--horizontal");const vertical=this.getAttribute("direction")==="vertical";this.classList.add(vertical?"c-resizable--vertical":"c-resizable--horizontal");if(!this.querySelector(".c-resizable__pane")){const p1=document.createElement("div");p1.className="c-resizable__pane";const handle=document.createElement("div");handle.className="c-resize-handle";handle.setAttribute("tabindex","0");handle.setAttribute("role","separator");handle.setAttribute("aria-valuenow","0");const p2=document.createElement("div");p2.className="c-resizable__pane";this.appendChild(p1);this.appendChild(handle);this.appendChild(p2)}const v=this._splitValue||this.getAttribute("value");if(v){const p1=this.querySelector(".c-resizable__pane");if(p1)p1.style.flex=`0 0 ${v}%`}}enhance(){if(this._wiredResizable)return;this._wiredResizable=true;const setSplit=(clientX,clientY)=>{const rect=this.getBoundingClientRect();const vertical=this.classList.contains("c-resizable--vertical");const span=vertical?rect.height:rect.width;const pos=vertical?clientY-rect.top:clientX-rect.left;const frac=span>0?Math.min(0.9,Math.max(0.1,pos/span)):0.5;const p1=this.querySelector(".c-resizable__pane");if(p1)p1.style.flex=`0 0 ${Math.round(frac * 100)}%`;this._splitValue=String(Math.round(frac*100))};this.addEventListener("pointerdown",(e)=>{const handle=this.querySelector(".c-resize-handle");if(!handle||e.target!==handle)return;this._resizing=true;handle.classList.add("c-resize-handle--dragging");if(handle.setPointerCapture){try{handle.setPointerCapture(e.pointerId)}catch(err){}}e.preventDefault()});this.addEventListener("pointermove",(e)=>{if(!this._resizing)return;setSplit(e.clientX,e.clientY)});const stopResize=(e)=>{if(!this._resizing)return;this._resizing=false;if(this._splitValue){this.setAttribute("value",this._splitValue);this._splitValue=null}const rect=this.getBoundingClientRect();this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:true,composed:true,detail:{width:Math.round(rect.width),height:Math.round(rect.height)}}));const handle=this.querySelector(".c-resize-handle");if(handle){handle.classList.remove("c-resize-handle--dragging");if(handle.hasPointerCapture&&handle.hasPointerCapture(e.pointerId)){try{handle.releasePointerCapture(e.pointerId)}catch(err){}}}};this.addEventListener("pointerup",stopResize);this.addEventListener("pointercancel",stopResize);this.addEventListener("keydown",(e)=>{const handle=this.querySelector(".c-resize-handle");if(!handle||document.activeElement!==handle)return;const vertical=this.classList.contains("c-resizable--vertical");const cur=parseFloat(this.getAttribute("value"))||50;if(e.key==="ArrowLeft"||e.key==="ArrowDown"){e.preventDefault();setSplit&&setSplit;const p1=this.querySelector(".c-resizable__pane");if(p1){const nv=Math.max(10,cur-5);p1.style.flex=`0 0 ${nv}%`;this.setAttribute("value",String(nv))}}else if(e.key==="ArrowRight"||e.key==="ArrowUp"){e.preventDefault();const p1=this.querySelector(".c-resizable__pane");if(p1){const nv=Math.min(90,cur+5);p1.style.flex=`0 0 ${nv}%`;this.setAttribute("value",String(nv))}}const r=this.getBoundingClientRect();this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:true,composed:true,detail:{width:Math.round(r.width),height:Math.round(r.height)}}))})}}define("contour-resizable",ContourResizable);class ContourSplitView extends ContourBase{static get observed(){return["direction","value","left-label","right-label"]}static get properties(){return{direction:{attribute:"direction"},value:{attribute:"value"},"left-label":{attribute:"left-label"},"right-label":{attribute:"right-label"}}}render(){this.classList.add("c-split-view");this.setAttribute("role","region");const vertical=this.getAttribute("direction")==="vertical";if(vertical){this.classList.add("c-split-view--vertical");this.classList.remove("c-split-view--horizontal")}else{this.classList.add("c-split-view--horizontal");this.classList.remove("c-split-view--vertical")}if(this.getAttribute("left-label"))this.setAttribute("aria-label",this.getAttribute("left-label"));if(!this.querySelector(".c-split-view__pane")){const p1=document.createElement("div");p1.className="c-split-view__pane c-split-view__pane--left";if(this.getAttribute("left-label"))p1.setAttribute("aria-label",this.getAttribute("left-label"));const divider=document.createElement("div");divider.className="c-split-view__divider";divider.setAttribute("tabindex","0");divider.setAttribute("role","separator");divider.setAttribute("aria-valuenow",this.getAttribute("value")||"50");divider.setAttribute("aria-label","Split divider");const p2=document.createElement("div");p2.className="c-split-view__pane c-split-view__pane--right";if(this.getAttribute("right-label"))p2.setAttribute("aria-label",this.getAttribute("right-label"));this.appendChild(p1);this.appendChild(divider);this.appendChild(p2)}if(!this.querySelector(".c-split-view__divider")){const divider=document.createElement("div");divider.className="c-split-view__divider";divider.setAttribute("tabindex","0");divider.setAttribute("role","separator");divider.setAttribute("aria-valuenow",this.getAttribute("value")||"50");divider.setAttribute("aria-label","Split divider");this.appendChild(divider)}const v=this.getAttribute("value")||"50";const p1=this.querySelector(".c-split-view__pane--left");if(p1)p1.style.flex=`0 0 ${v}%`;const divider=this.querySelector(".c-split-view__divider");if(divider)divider.setAttribute("aria-valuenow",v)}enhance(){if(this._wiredSplitView)return;this._wiredSplitView=true;const setSplit=(clientX,clientY)=>{const rect=this.getBoundingClientRect();const vertical=this.classList.contains("c-split-view--vertical");const span=vertical?rect.height:rect.width;const pos=vertical?clientY-rect.top:clientX-rect.left;const frac=span>0?Math.min(0.9,Math.max(0.1,pos/span)):0.5;const pct=Math.round(frac*100);const p1=this.querySelector(".c-split-view__pane--left");if(p1)p1.style.flex=`0 0 ${pct}%`;const divider=this.querySelector(".c-split-view__divider");if(divider)divider.setAttribute("aria-valuenow",String(pct));this.setAttribute("value",String(pct))};this.addEventListener("pointerdown",(e)=>{const divider=this.querySelector(".c-split-view__divider");if(!divider||e.target!==divider)return;this._resizing=true;divider.classList.add("c-split-view__divider--dragging");if(divider.setPointerCapture){try{divider.setPointerCapture(e.pointerId)}catch(err){}}e.preventDefault()});this.addEventListener("pointermove",(e)=>{if(!this._resizing)return;setSplit(e.clientX,e.clientY)});const stopResize=(e)=>{if(!this._resizing)return;this._resizing=false;const divider=this.querySelector(".c-split-view__divider");if(divider){divider.classList.remove("c-split-view__divider--dragging");if(divider.hasPointerCapture&&divider.hasPointerCapture(e.pointerId)){try{divider.releasePointerCapture(e.pointerId)}catch(err){}}}const r=this.getBoundingClientRect();this.dispatchEvent(new CustomEvent("contour:split-change",{bubbles:true,composed:true,detail:{value:this.getAttribute("value"),width:Math.round(r.width),height:Math.round(r.height)}}))};this.addEventListener("pointerup",stopResize);this.addEventListener("pointercancel",stopResize);this.addEventListener("keydown",(e)=>{const divider=this.querySelector(".c-split-view__divider");if(!divider||document.activeElement!==divider)return;const cur=parseFloat(this.getAttribute("value"))||50;if(e.key==="ArrowLeft"||e.key==="ArrowDown"){e.preventDefault();const nv=Math.max(10,cur-5);const p1=this.querySelector(".c-split-view__pane--left");if(p1)p1.style.flex=`0 0 ${nv}%`;this.setAttribute("value",String(nv));const d=this.querySelector(".c-split-view__divider");if(d)d.setAttribute("aria-valuenow",String(nv))}else if(e.key==="ArrowRight"||e.key==="ArrowUp"){e.preventDefault();const nv=Math.min(90,cur+5);const p1=this.querySelector(".c-split-view__pane--left");if(p1)p1.style.flex=`0 0 ${nv}%`;this.setAttribute("value",String(nv));const d=this.querySelector(".c-split-view__divider");if(d)d.setAttribute("aria-valuenow",String(nv))}const r=this.getBoundingClientRect();this.dispatchEvent(new CustomEvent("contour:split-change",{bubbles:true,composed:true,detail:{value:this.getAttribute("value"),width:Math.round(r.width),height:Math.round(r.height)}}))})}}define("contour-split-view",ContourSplitView);class ContourTableWrap extends ContourBase{static get observed(){return[]}static get properties(){return{}}render(){this.classList.add("c-table-wrap");Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===Node.TEXT_NODE)n.remove();else if(n.nodeType===Node.ELEMENT_NODE&&n.tagName==="SPAN")n.remove()})}}define("contour-table-wrap",ContourTableWrap);class ContourScrollArea extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-scroll-area");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-scroll-area__title",()=>{const el=document.createElement("div");el.className="c-scroll-area__title";el.style.padding="var(--space-sm)";el.style.fontWeight="var(--weight-semibold)";return el});t.textContent=title}}}define("contour-scroll-area",ContourScrollArea);class ContourBtn extends ContourBase{static get observed(){return["variant","size","color","label","disabled"]}static get properties(){return{variant:{attribute:"variant"},size:{attribute:"size"},color:{attribute:"color"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean}}}render(){this.classList.add("c-btn");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-btn--"))this.classList.remove(c)});for(const attr of["variant","size","color"]){const val=this.getAttribute(attr);if(val)this.classList.add("c-btn--"+val)}if(!this.hasAttribute("role"))this.setAttribute("role","button");if(this.hasAttribute("disabled")){this.setAttribute("aria-disabled","true");this.setAttribute("tabindex","-1")}else{this.removeAttribute("aria-disabled");if(!this.hasAttribute("tabindex")||this.getAttribute("tabindex")==="-1")this.setAttribute("tabindex","0")}const label=this.getAttribute("label");if(label&&!this.hasChildNodes())this.textContent=label;if(label&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label)}enhance(){if(this._wiredBtn)return;this._wiredBtn=true;this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.click();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}})}}define("contour-btn",ContourBtn);class ContourApp extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-app");const header=this.ensure(".c-app__header",()=>{const el=document.createElement("header");el.className="c-app__header";return el});const title=this.getAttribute("title");if(title){const t=this.ensure(".c-app__title",()=>{const el=document.createElement("div");el.className="c-app__title";return el});t.textContent=title;if(t.parentNode!==header)header.appendChild(t)}const main=this.ensure(".c-app__main",()=>{const el=document.createElement("main");el.className="c-app__main";return el});if(main.parentNode!==this)this.appendChild(main);if(header.parentNode!==this)this.insertBefore(header,main);Array.from(this.children).forEach((child)=>{if(child===header||child===main)return;main.appendChild(child)})}}define("contour-app",ContourApp);class ContourAppBody extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-app-body");const nested=!!(this.parentElement&&this.parentElement.closest&&this.parentElement.closest("contour-app"));const tag=nested?"div":"main";let main=this.querySelector(":scope > .c-app-body__main");if(main&&main.tagName.toLowerCase()!==tag){main.remove();main=null}if(!main){main=document.createElement(tag);main.className="c-app-body__main";this.appendChild(main)}const title=this.getAttribute("title");if(title){const t=this.ensure(".c-app-body__title",()=>{const el=document.createElement("div");el.className="c-app-body__title";return el});t.textContent=title;if(t.parentNode!==main)main.appendChild(t)}if(main.parentNode!==this)this.appendChild(main)}}define("contour-app-body",ContourAppBody);class ContourBtnGroup extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-btn-group");this.setAttribute("role","group");if(this.getAttribute("title"))this.setAttribute("aria-label",this.getAttribute("title"))}enhance(){if(this._wiredBtnGroup)return;this._wiredBtnGroup=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-btn"):null;if(btn&&this.contains(btn)){const buttons=Array.from(this.querySelectorAll(".c-btn"));const index=buttons.indexOf(btn);this.dispatchEvent(new CustomEvent("contour:btn-group-change",{bubbles:true,composed:true,detail:{index,label:btn.textContent}}))}});this.addEventListener("keydown",(e)=>{const buttons=Array.from(this.querySelectorAll(".c-btn"));if(!buttons.length)return;navKey(e,buttons,{wrap:false,homeEnd:true,rtl:isRtl(this)})})}}define("contour-btn-group",ContourBtnGroup);class ContourRangeScale extends ContourBase{static get observed(){return["label","value","ticks"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},ticks:{attribute:"ticks"}}}render(){this.classList.add("c-range-scale");this.setAttribute("role","group");if(this.getAttribute("label"))this.setAttribute("aria-label",this.getAttribute("label"));const label=this.getAttribute("label");if(label){const t=this.ensure(".c-range-scale__label",()=>{const el=document.createElement("span");el.className="c-range-scale__label";return el});t.textContent=label}const ticksAttr=this.getAttribute("ticks");Array.from(this.querySelectorAll(".c-range-scale__tick")).forEach((n)=>n.remove());if(ticksAttr){ticksAttr.split(",").map((s)=>s.trim()).filter(Boolean).forEach((tk)=>{const t=document.createElement("span");t.className="c-range-scale__tick";t.textContent=tk;this.appendChild(t)})}}enhance(){if(this._wiredRangeScale)return;this._wiredRangeScale=true;this.addEventListener("input",(e)=>{const t=e.target;if(t&&t.matches&&t.matches("input")){this.dispatchEvent(new CustomEvent("contour:range-change",{bubbles:true,composed:true,detail:{value:t.value}}))}});this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.matches&&t.matches("input")){this.dispatchEvent(new CustomEvent("contour:range-change",{bubbles:true,composed:true,detail:{value:t.value}}))}})}}define("contour-range-scale",ContourRangeScale);class ContourTimeRange extends ContourBase{static get observed(){return["label","value","ticks"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},ticks:{attribute:"ticks"}}}render(){this.classList.add("c-time-range");this.setAttribute("role","group");if(this.getAttribute("label"))this.setAttribute("aria-label",this.getAttribute("label"));const label=this.getAttribute("label");if(label){const t=this.ensure(".c-time-range__label",()=>{const el=document.createElement("span");el.className="c-time-range__label";return el});t.textContent=label}const ticksAttr=this.getAttribute("ticks");Array.from(this.querySelectorAll(".c-time-range__tick")).forEach((n)=>n.remove());if(ticksAttr){ticksAttr.split(",").map((s)=>s.trim()).filter(Boolean).forEach((tk)=>{const t=document.createElement("span");t.className="c-time-range__tick";t.textContent=tk;this.appendChild(t)})}}enhance(){if(this._wiredTimeRange)return;this._wiredTimeRange=true;this.addEventListener("input",(e)=>{const t=e.target;if(t&&t.matches&&t.matches("input")){this.dispatchEvent(new CustomEvent("contour:time-range-change",{bubbles:true,composed:true,detail:{value:t.value}}))}});this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.matches&&t.matches("input")){this.dispatchEvent(new CustomEvent("contour:time-range-change",{bubbles:true,composed:true,detail:{value:t.value}}))}})}}define("contour-time-range",ContourTimeRange);class ContourSkipLink extends ContourBase{static get observed(){return["href","label"]}static get properties(){return{href:{attribute:"href"},label:{attribute:"label"}}}render(){const a=this.ensure("a",()=>{const el=document.createElement("a");el.className="c-skip-link";return el});a.setAttribute("href",this.getAttribute("href")||"#main");a.textContent=this.getAttribute("label")||"Skip to content"}}define("contour-skip-link",ContourSkipLink);class ContourIcon extends ContourBase{static get observed(){return["name","size","label"]}static get properties(){return{name:{attribute:"name"},size:{attribute:"size"},label:{attribute:"label"}}}render(){const name=this.getAttribute("name")||"";const size=this.getAttribute("size");const label=this.getAttribute("label");this.innerHTML="";const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("class","c-icon");svg.setAttribute("aria-hidden","true");if(size)svg.style.width=size,svg.style.height=size;const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href","#i-"+name);svg.appendChild(use);this.appendChild(svg);if(label){this.setAttribute("role","img");this.setAttribute("aria-label",label)}else{this.removeAttribute("role");this.removeAttribute("aria-label")}}}define("contour-icon",ContourIcon);class ContourDashboardGrid extends ContourBase{static get observed(){return["cols","gap"]}static get properties(){return{cols:{attribute:"cols"},gap:{attribute:"gap"}}}render(){this.classList.add("c-dashboard-grid");const cols=this.getAttribute("cols");if(cols)this.style.setProperty("--dashboard-grid-cols",cols);const gap=this.getAttribute("gap");if(gap)this.style.setProperty("--dashboard-grid-gap",gap)}}define("contour-dashboard-grid",ContourDashboardGrid);class ContourAnalysisStack extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-analysis-stack");const title=this.getAttribute("title");let header=this.querySelector(".c-analysis-stack__header");if(title){if(!header){header=document.createElement("div");header.className="c-analysis-stack__header";this.prepend(header)}let h=header.querySelector(".c-analysis-stack__title");if(!h){h=document.createElement("h3");h.className="c-analysis-stack__title";header.appendChild(h)}h.textContent=title}else if(header)header.remove()}}define("contour-analysis-stack",ContourAnalysisStack);function wireMapItems(host,itemSelector,tooltipClass){if(host._wiredMapItems)return;host._wiredMapItems=true;const items=()=>Array.from(host.querySelectorAll(itemSelector));const showTip=(e)=>{const tip=host.querySelector(tooltipClass);if(!tip)return;const item=e&&e.target&&typeof e.target.closest==="function"?e.target.closest(itemSelector):null;if(!item||!host.contains(item)){tip.setAttribute("hidden","");return}const title=item.getAttribute("title");if(title)tip.textContent=title;const rect=host.getBoundingClientRect();const ir=item.getBoundingClientRect();tip.style.setProperty("--chart-tip-inline-start",(ir.left-rect.left+ir.width/2)+"px");tip.style.setProperty("--chart-tip-block-start",(ir.top-rect.top)+"px");tip.removeAttribute("hidden")};const hideTip=()=>{const tip=host.querySelector(tooltipClass);if(tip)tip.setAttribute("hidden","")};host.addEventListener("mouseover",showTip);host.addEventListener("mouseout",(e)=>{if(!e.relatedTarget||!host.contains(e.relatedTarget))hideTip()});host.addEventListener("focusin",(e)=>{const item=e&&e.target&&typeof e.target.closest==="function"?e.target.closest(itemSelector):null;if(item&&host.contains(item))showTip({target:item})});host.addEventListener("focusout",(e)=>{if(!host.contains(e.relatedTarget))hideTip()});host.addEventListener("click",(e)=>{const item=e&&e.target&&typeof e.target.closest==="function"?e.target.closest(itemSelector):null;if(!item||!host.contains(item))return;const all=items();const index=all.indexOf(item);if(index<0)return;host.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index,label:item.getAttribute("title")||item.textContent.trim()}}))});host.addEventListener("keydown",(e)=>{const item=e&&e.target&&typeof e.target.closest==="function"?e.target.closest(itemSelector):null;if(!item||!host.contains(item))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();const all=items();const index=all.indexOf(item);if(index>=0)host.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index,label:item.getAttribute("title")||item.textContent.trim()}}))}else{const all=items();navKey(e,all,{wrap:false,homeEnd:true,rtl:isRtl(host),onNavigate:(i)=>all.forEach((c,j)=>c.setAttribute("tabindex",j===i?"0":"-1"))})}})}class ContourMinimap extends ContourBase{static get observed(){return["label","viewport","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},viewport:{attribute:"viewport"},src:{attribute:"src"}}}render(){this.classList.add("c-minimap");if(!this.hasAttribute("role"))this.setAttribute("role","img");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"Minimap");wireStates(this);loadRemote(this,["label","viewport"]);if(renderStates(this,"minimap"))return;const label=remoteData(this,"label")||(this._remoteData&&this._remoteData.label);const viewport=remoteData(this,"viewport")||(this._remoteData&&(this._remoteData.viewport||this._remoteData.value));if(!label&&!viewport){renderEmpty(this,"minimap");return}if(label){const l=this.ensure(".c-minimap__label",()=>{const el=document.createElement("span");el.className="c-minimap__label";return el});l.textContent=label}else{const l=this.querySelector(".c-minimap__label");if(l)l.remove()}if(viewport){const v=this.ensure(".c-minimap__viewport",()=>{const el=document.createElement("div");el.className="c-minimap__viewport";return el});v.textContent=viewport}else{const v=this.querySelector(".c-minimap__viewport");if(v)v.remove()}}enhance(){if(this._wiredMinimap)return;this._wiredMinimap=true;if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");let dragging=false;this.addEventListener("pointerdown",(e)=>{const vp=this.querySelector(".c-minimap__viewport");if(!vp||!vp.contains(e.target))return;dragging=true;try{vp.setPointerCapture(e.pointerId)}catch(err){}});this.addEventListener("pointermove",(e)=>{if(!dragging)return;this.dispatchEvent(new CustomEvent("contour:move",{detail:{direction:"drag"},bubbles:true,composed:true}))});this.addEventListener("pointerup",()=>{dragging=false});this.addEventListener("keydown",(e)=>{let dir=null;if(e.key==="ArrowUp")dir="up";else if(e.key==="ArrowDown")dir="down";else if(e.key==="ArrowLeft")dir="left";else if(e.key==="ArrowRight")dir="right";else if(e.key==="Home")dir="home";else if(e.key==="End")dir="end";if(!dir)return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:move",{detail:{direction:dir},bubbles:true,composed:true}))})}}define("contour-minimap",ContourMinimap);class ContourCoordinate extends ContourBase{static get observed(){return["value","format","locale","precision","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{value:{attribute:"value"},format:{attribute:"format"},locale:{attribute:"locale"},precision:{attribute:"precision"},src:{attribute:"src"}}}render(){this.classList.add("c-coordinate");wireStates(this);loadRemote(this,"value");if(renderStates(this,"coordinate"))return;const value=remoteData(this,"value")||(this._remoteData&&(this._remoteData.value||this._remoteData.coordinate));if(!value){renderEmpty(this,"coordinate");return}const format=this.getAttribute("format")||"decimal";let text=String(value);if(format==="dms"){const parts=String(value).split(/[,\s]+/).map(Number);if(parts.length>=2&&Number.isFinite(parts[0])&&Number.isFinite(parts[1])){const prec=parseInt(this.getAttribute("precision")||"1",10);const secDigits=Number.isFinite(prec)&&prec>=0?prec:1;const toDMS=(d,axis)=>{const deg=Math.floor(Math.abs(d));const min=Math.floor((Math.abs(d)-deg)*60);const sec=(((Math.abs(d)-deg)*60)-min)*60;const hemi=axis==="lat"?(d<0?"S":"N"):(d<0?"W":"E");return deg+"°"+min+"'"+sec.toFixed(secDigits)+'"'+hemi};text=toDMS(parts[0],"lat")+" "+toDMS(parts[1],"lon")}}else if(format==="web-mercator"){const parts=String(value).split(/[,\s]+/).map(Number);if(parts.length>=2&&Number.isFinite(parts[0])&&Number.isFinite(parts[1])){const x=parts[1]*20037508.34/180;const y=Math.log(Math.tan((90+parts[0])*Math.PI/360))/(Math.PI/180)*20037508.34/180;text=x.toFixed(2)+", "+y.toFixed(2)}}else{text=formatValue(value,this.getAttribute("format"),this.getAttribute("locale"))}const span=this.ensure(".c-coordinate__value",()=>{const el=document.createElement("span");el.className="c-coordinate__value";el.setAttribute("role","status");el.setAttribute("aria-live","polite");return el});span.textContent=text;let btn=this.querySelector(".c-coordinate__copy");if(!btn){btn=document.createElement("button");btn.type="button";btn.className="c-coordinate__copy";btn.textContent=labelText(this,"copy","Copy");btn.setAttribute("aria-label",labelText(this,"copy-coordinate","Copy coordinate"));this.appendChild(btn)}btn.onclick=()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText){navigator.clipboard.writeText(text).catch(()=>{fallbackCopy(text)})}else{fallbackCopy(text)}}catch(e){fallbackCopy(text)}this.dispatchEvent(new CustomEvent("contour:copy",{detail:{text},bubbles:true,composed:true}))};function fallbackCopy(t){try{const ta=document.createElement("textarea");ta.value=t;ta.style.position="fixed";ta.style.opacity="0";document.body.appendChild(ta);ta.select();document.execCommand("copy");document.body.removeChild(ta)}catch(e){}}}}define("contour-coordinate",ContourCoordinate);class ContourLayerPanel extends ContourBase{static get observed(){return["label","items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","allow-rename","allow-remove","allow-duplicate","allow-zoom"]}static get properties(){return{label:{attribute:"label"},items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-layer-panel");this.setAttribute("role","group");this.setAttribute("aria-label","Layer panel");wireStates(this);loadRemote(this,"items");if(renderStates(this,"layer-panel"))return;const items=remoteData(this,"items");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-layer-panel__label",()=>{const el=document.createElement("span");el.className="c-layer-panel__label";return el});l.textContent=label}else{const l=this.querySelector(".c-layer-panel__label");if(l)l.remove()}const authoredLayerItems=Array.from(this.querySelectorAll(":scope > .c-layer-panel__item"));const savedVisibility=new Map();this.querySelectorAll(".c-layer-panel__item").forEach((el)=>{const nm=el.querySelector(".c-layer-panel__name");const tg=el.querySelector(".c-layer-panel__toggle");if(nm&&tg){const v=tg.hasAttribute("aria-pressed")?tg.getAttribute("aria-pressed")==="true":!!tg.checked;savedVisibility.set(nm.textContent,v)}});let parsed=null;if(authoredLayerItems.length){parsed=authoredLayerItems.map((el)=>{const nm=el.querySelector(".c-layer-panel__name");const tg=el.querySelector(".c-layer-panel__toggle");const visible=tg?(tg.hasAttribute("aria-pressed")?tg.getAttribute("aria-pressed")==="true":!!tg.checked):true;const cap=el.querySelector(".c-layer-panel__caption");return{name:nm?nm.textContent:"",visible,caption:cap?cap.textContent:(el.dataset.caption||undefined)}});authoredLayerItems.forEach((el)=>el.remove())}else if(items){try{parsed=JSON.parse(items);Array.from(this.querySelectorAll(".c-layer-panel__item")).forEach((el)=>el.remove())}catch(e){warnBadJson(this,"attribute",e)}}if(parsed){parsed.forEach((it)=>{const name=typeof it==="string"?it:(it.name||it.label||"");const caption=(typeof it==="object"&&it)?(it.caption||it.subtitle||""):"";const item=document.createElement("div");item.className="c-layer-panel__item"+(it.dragging?" c-layer-panel__item--dragging":"");const drag=document.createElement("button");drag.type="button";drag.className="c-drag-handle--dots";drag.setAttribute("aria-label","Reorder "+(name||"layer"));drag.setAttribute("tabindex","0");item.appendChild(drag);const toggle=document.createElement("button");toggle.type="button";toggle.className="c-layer-panel__toggle";toggle.setAttribute("part","visibility-toggle");toggle.setAttribute("aria-label","Toggle "+(name||"layer"));const isVisible=savedVisibility.has(name)?savedVisibility.get(name):(typeof it==="object"&&it.visible!==false);toggle.setAttribute("aria-pressed",String(!!isVisible));toggle.checked=!!isVisible;toggle.innerHTML=isVisible?'<svg aria-hidden="true"><use href="#i-check" /></svg>':'<svg aria-hidden="true"><use href="#i-minus" /></svg>';item.appendChild(toggle);const nm=document.createElement("span");nm.className="c-layer-panel__name";nm.textContent=name;item.appendChild(nm);if(caption){const cap=document.createElement("span");cap.className="c-layer-panel__caption";cap.textContent=caption;item.appendChild(cap)}const opacity=document.createElement("input");opacity.type="range";opacity.className="c-layer-panel__opacity";opacity.min="0";opacity.max="100";opacity.setAttribute("aria-label",labelText(this,"opacity-of","Opacity of")+" "+(name||"layer"));opacity.value=(typeof it==="object"&&it.opacity!=null)?it.opacity:"100";item.appendChild(opacity);if(this.getAttribute("allow-rename")!=="false"){const renameBtn=document.createElement("button");renameBtn.type="button";renameBtn.className="c-layer-panel__rename";renameBtn.textContent=labelText(this,"rename","Rename");renameBtn.setAttribute("aria-label",labelText(this,"rename","Rename")+" "+(name||"layer"));item.appendChild(renameBtn)}if(this.getAttribute("allow-duplicate")!=="false"){const dupBtn=document.createElement("button");dupBtn.type="button";dupBtn.className="c-layer-panel__duplicate";dupBtn.textContent=labelText(this,"duplicate","Duplicate");dupBtn.setAttribute("aria-label",labelText(this,"duplicate","Duplicate")+" "+(name||"layer"));item.appendChild(dupBtn)}if(this.getAttribute("allow-zoom")!=="false"){const zoomBtn=document.createElement("button");zoomBtn.type="button";zoomBtn.className="c-layer-panel__zoom";zoomBtn.textContent=labelText(this,"zoom","Zoom");zoomBtn.setAttribute("aria-label",labelText(this,"zoom-to","Zoom to")+" "+(name||"layer"));item.appendChild(zoomBtn)}if(this.getAttribute("allow-remove")!=="false"){const removeBtn=document.createElement("button");removeBtn.type="button";removeBtn.className="c-layer-panel__remove";removeBtn.innerHTML='<svg aria-hidden="true"><use href="#i-minus" /></svg>';removeBtn.setAttribute("aria-label",labelText(this,"remove","Remove")+" "+(name||"layer"));item.appendChild(removeBtn)}const projSel=document.createElement("select");projSel.className="c-select c-layer-panel__projection";projSel.setAttribute("aria-label","Projection of "+(name||"layer"));["EPSG:4326","EPSG:3857"].forEach((p)=>{const o=document.createElement("option");o.value=p;o.textContent=p;projSel.appendChild(o)});item.appendChild(projSel);this.appendChild(item)})}if(!parsed&&!authoredLayerItems.length&&!items){Array.from(this.querySelectorAll(".c-layer-panel__item")).forEach((el)=>el.remove());renderEmpty(this,"layer-panel")}}enhance(){if(this._wiredLayerPanel)return;this._wiredLayerPanel=true;this.addEventListener("change",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-layer-panel__item"):null;if(!item||!this.contains(item))return;const name=item.querySelector(".c-layer-panel__name")?.textContent||"";if(e.target.classList.contains("c-layer-panel__toggle")){const now=(typeof e.target.checked==="boolean")?e.target.checked:(e.target.getAttribute("aria-pressed")!=="true");e.target.checked=now;e.target.setAttribute("aria-pressed",String(now));e.target.innerHTML=now?'<svg aria-hidden="true"><use href="#i-check" /></svg>':'<svg aria-hidden="true"><use href="#i-minus" /></svg>';this.dispatchEvent(new CustomEvent("contour:layer-visibility",{bubbles:true,composed:true,detail:{name,visible:now}}))}else if(e.target.classList.contains("c-layer-panel__opacity")){this.dispatchEvent(new CustomEvent("contour:layer-opacity",{bubbles:true,composed:true,detail:{name,opacity:Number(e.target.value)}}))}else if(e.target.classList.contains("c-layer-panel__projection")){this.dispatchEvent(new CustomEvent("contour:layer-projection",{bubbles:true,composed:true,detail:{name,projection:e.target.value}}))}});this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest("button"):null;if(!btn||!this.contains(btn))return;const item=btn.closest(".c-layer-panel__item");if(btn.classList.contains("c-layer-panel__toggle")){if(!item)return;const name=item.querySelector(".c-layer-panel__name")?.textContent||"";const now=btn.getAttribute("aria-pressed")!=="true";btn.setAttribute("aria-pressed",String(now));btn.checked=now;btn.innerHTML=now?'<svg aria-hidden="true"><use href="#i-check" /></svg>':'<svg aria-hidden="true"><use href="#i-minus" /></svg>';this.dispatchEvent(new CustomEvent("contour:layer-visibility",{bubbles:true,composed:true,detail:{name,visible:now}}));return}if(!item)return;const name=item.querySelector(".c-layer-panel__name")?.textContent||"";if(btn.classList.contains("c-layer-panel__rename")){const nm=item.querySelector(".c-layer-panel__name");if(nm){const input=document.createElement("input");input.type="text";input.className="c-input c-layer-panel__rename-input";input.value=name;input.setAttribute("aria-label","Rename layer");nm.replaceWith(input);input.focus();input.select();const commit=()=>{const trimmed=(input.value||"").trim();const span=document.createElement("span");span.className="c-layer-panel__name";span.textContent=trimmed||name;input.replaceWith(span);if(trimmed&&trimmed!==name){this.dispatchEvent(new CustomEvent("contour:layer-rename",{bubbles:true,composed:true,detail:{name,newName:trimmed}}))}};input.addEventListener("keydown",(ev)=>{if(ev.key==="Enter"){ev.preventDefault();commit()}else if(ev.key==="Escape"){ev.preventDefault();input.value=name;commit()}});input.addEventListener("blur",commit,{once:true})}}else if(btn.classList.contains("c-layer-panel__duplicate")){this.dispatchEvent(new CustomEvent("contour:layer-duplicate",{bubbles:true,composed:true,detail:{name}}))}else if(btn.classList.contains("c-layer-panel__zoom")){this.dispatchEvent(new CustomEvent("contour:layer-zoom",{bubbles:true,composed:true,detail:{name}}))}else if(btn.classList.contains("c-layer-panel__remove")){this.dispatchEvent(new CustomEvent("contour:layer-remove",{bubbles:true,composed:true,detail:{name}}))}});this.addEventListener("keydown",(e)=>{if(e.target&&e.target.classList&&e.target.classList.contains("c-layer-panel__toggle")&&(e.key==="Enter"||e.key===" ")){e.preventDefault();e.target.click();return}const item=e.target&&e.target.closest?e.target.closest(".c-layer-panel__item"):null;if(!item||!this.contains(item))return;const isDrag=e.target&&e.target.classList&&e.target.classList.contains("c-drag-handle--dots");if((isDrag&&(e.key==="ArrowUp"||e.key==="ArrowDown"))||(e.altKey&&(e.key==="ArrowUp"||e.key==="ArrowDown"))){e.preventDefault();const items=Array.from(this.querySelectorAll(".c-layer-panel__item"));const idx=items.indexOf(item);if(idx<0)return;const dir=e.key==="ArrowUp"?-1:1;const newIdx=idx+dir;if(newIdx<0||newIdx>=items.length)return;item.classList.add("c-layer-panel__item--dragging");if(dir<0)this.insertBefore(item,items[newIdx]);else this.insertBefore(items[newIdx],item);(isDrag?e.target:item).focus();setTimeout(()=>item.classList.remove("c-layer-panel__item--dragging"),200);const layerIds=Array.from(this.querySelectorAll(".c-layer-panel__item")).map((el)=>el.querySelector(".c-layer-panel__name")?.textContent||"");this.dispatchEvent(new CustomEvent("contour:layer-reorder",{bubbles:true,composed:true,detail:{layerIds}}))}})}}define("contour-layer-panel",ContourLayerPanel);class ContourTimeSlider extends ContourBase{static get observed(){return["label","value","min","max","loop","speed","speeds","show-loop","loop-label","current-time","time-format","is-playing","play-label","pause-label","time-label","speed-label"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},min:{attribute:"min"},max:{attribute:"max"},distance:{attribute:"distance"},resolution:{attribute:"resolution"},latitude:{attribute:"latitude"},src:{attribute:"src"},loop:{attribute:"loop",type:Boolean},speed:{attribute:"speed"},speeds:{attribute:"speeds"},showLoop:{attribute:"show-loop",type:Boolean},loopLabel:{attribute:"loop-label"},currentTime:{attribute:"current-time"},timeFormat:{attribute:"time-format"},isPlaying:{attribute:"is-playing",type:Boolean},playLabel:{attribute:"play-label"},pauseLabel:{attribute:"pause-label"},timeLabel:{attribute:"time-label"},speedLabel:{attribute:"speed-label"}}}render(){this.classList.add("c-time-slider");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"Time slider");const play=this.ensure(".c-time-slider__play",()=>{const el=document.createElement("button");el.className="c-time-slider__play";el.type="button";el.setAttribute("aria-label",this.getAttribute("play-label")||"Play");el.setAttribute("data-state","play");const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href","#i-play");svg.appendChild(use);el.appendChild(svg);return el});const track=this.ensure(".c-time-slider__track",()=>{const el=document.createElement("input");el.className="c-time-slider__track";el.type="range";el.min="0";el.max="100";el.setAttribute("part","input");el.setAttribute("aria-label",this.getAttribute("time-label")||"Time");return el});track.min=this.getAttribute("min")||"0";track.max=this.getAttribute("max")||"100";const _attrVal=this.getAttribute("value")||"0";if(this._timeSliderAttrLast!==_attrVal){track.value=_attrVal;this._timeSliderAttrLast=_attrVal}track.setAttribute("aria-label",this.getAttribute("label")||this.getAttribute("time-label")||"Time");const time=this.ensure(".c-time-slider__time",()=>{const el=document.createElement("span");el.className="c-time-slider__time";return el});const ct=this.getAttribute("current-time");time.textContent=ct?ct:String(track.value);if(ct)track.setAttribute("aria-valuetext",ct);else track.removeAttribute("aria-valuetext");let speeds=null;const speedsAttr=this.getAttribute("speeds");if(speedsAttr){try{speeds=JSON.parse(speedsAttr)}catch(e){speeds=null}}const speedSel=this.ensure(".c-time-slider__speed",()=>{const el=document.createElement("select");el.className="c-select c-time-slider__speed";el.setAttribute("aria-label",this.getAttribute("speed-label")||"Speed");return el});speedSel.innerHTML="";const speedList=Array.isArray(speeds)?speeds:[0.5,1,2,5,10];speedList.forEach((sp)=>{const opt=document.createElement("option");opt.value=String(sp);opt.textContent=String(sp);if(String(sp)===(this.getAttribute("speed")||""))opt.selected=true;speedSel.appendChild(opt)});const speedAttr=this.getAttribute("speed");if(speedAttr)speedSel.value=speedAttr;const showLoop=this.hasAttribute("show-loop");if(showLoop){const loopBtn=this.ensure(".c-time-slider__loop",()=>{const el=document.createElement("button");el.className="c-time-slider__loop";el.type="button";el.setAttribute("aria-label",this.getAttribute("loop-label")||"Loop");return el});loopBtn.setAttribute("aria-pressed",this.hasAttribute("loop")?"true":"false");loopBtn.textContent=this.getAttribute("loop-label")||"Loop"}else{const lb=this.querySelector(".c-time-slider__loop");if(lb)lb.remove()}const playing=this.hasAttribute("is-playing");play.setAttribute("data-state",playing?"pause":"play");play.setAttribute("aria-label",playing?(this.getAttribute("pause-label")||"Pause"):(this.getAttribute("play-label")||"Play"));const use=play.querySelector("use");if(use)use.setAttribute("href",playing?"#i-pause":"#i-play")}enhance(){if(this._timeSliderReconcile)this._timeSliderReconcile();if(this._wiredTimeSlider)return;this._wiredTimeSlider=true;let timer=undefined;const stop=()=>{if(timer!==undefined){clearInterval(timer);timer=undefined}};const syncReadout=()=>{const track=this.querySelector(".c-time-slider__track");if(!track)return;const time=this.querySelector(".c-time-slider__time");const ct=this.getAttribute("current-time");if(time)time.textContent=ct?ct:String(track.value);if(ct)track.setAttribute("aria-valuetext",ct);else track.removeAttribute("aria-valuetext")};const step=()=>{const track=this.querySelector(".c-time-slider__track");if(!track){stop();return}const max=Number(track.max)||100;const min=Number(track.min)||0;const loop=this.hasAttribute("loop");let next=(Number(track.value)||0)+1;if(next>max)next=loop?min:max;track.value=String(next);const speedSel=this.querySelector(".c-time-slider__speed");const interacting=this._timeSliderScrubbing||(speedSel&&document.activeElement===speedSel);if(!interacting)this.setAttribute("value",String(next));syncReadout();this.dispatchEvent(new CustomEvent("contour:time-change",{detail:{value:String(next)},bubbles:true,composed:true}));if(!loop&&next>=max){stop();this.removeAttribute("is-playing");this.dispatchEvent(new CustomEvent("contour:pause",{bubbles:true,composed:true}))}};const start=()=>{stop();const speed=parseFloat(this.getAttribute("speed")||"1")||1;timer=setInterval(step,Math.max(100,1000/speed))};this._timeSliderReconcile=()=>{const want=this.hasAttribute("is-playing");if(want&&timer===undefined){start();this.dispatchEvent(new CustomEvent("contour:play",{bubbles:true,composed:true}))}else if(!want&&timer!==undefined){stop();this.dispatchEvent(new CustomEvent("contour:pause",{bubbles:true,composed:true}))}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-time-slider__play"):null;if(btn){this.toggleAttribute("is-playing",!this.hasAttribute("is-playing"));return}const loopBtn=e.target&&e.target.closest?e.target.closest(".c-time-slider__loop"):null;if(loopBtn){const next=loopBtn.getAttribute("aria-pressed")!=="true";loopBtn.setAttribute("aria-pressed",String(next));this.toggleAttribute("loop",next);this.dispatchEvent(new CustomEvent("contour:loop-change",{detail:{loop:next},bubbles:true,composed:true}))}});this.addEventListener("pointerdown",(e)=>{if(e.target&&e.target.closest&&e.target.closest(".c-time-slider__track"))this._timeSliderScrubbing=true},{passive:true});const endScrub=()=>{this._timeSliderScrubbing=false};this.addEventListener("pointerup",endScrub,{passive:true});this.addEventListener("pointercancel",endScrub,{passive:true});this.addEventListener("input",(e)=>{const track=e.target&&e.target.closest?e.target.closest(".c-time-slider__track"):null;if(!track)return;if(!this._timeSliderScrubbing)this.setAttribute("value",track.value);syncReadout();this.dispatchEvent(new CustomEvent("contour:time-change",{detail:{value:track.value},bubbles:true,composed:true}))});this.addEventListener("change",(e)=>{const sel=e.target&&e.target.closest?e.target.closest(".c-time-slider__speed"):null;if(sel){const speed=Number(sel.value);this.setAttribute("speed",String(speed));if(timer!==undefined)start();this.dispatchEvent(new CustomEvent("contour:speed-change",{detail:{speed},bubbles:true,composed:true}));return}const track=e.target&&e.target.closest?e.target.closest(".c-time-slider__track"):null;if(track){this.setAttribute("value",track.value);syncReadout()}});onDispose(this,stop);this._timeSliderReconcile()}disconnectedCallback(){super.disconnectedCallback();this._wiredTimeSlider=false;this._timeSliderReconcile=null}}define("contour-time-slider",ContourTimeSlider);class ContourHexbin extends ContourBase{static get observed(){return["label","cells","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},cells:{attribute:"cells"},src:{attribute:"src"}}}render(){this.classList.add("c-hexbin");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"Hexbin");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-hexbin__label",()=>{const el=document.createElement("span");el.className="c-hexbin__label";return el});l.textContent=label}else{const l=this.querySelector(".c-hexbin__label");if(l)l.remove()}wireStates(this);loadRemote(this,"cells");if(renderStates(this,"hexbin"))return;const cells=remoteData(this,"cells");const effectiveCells=cells||(this._remoteData&&this._remoteData.cells?JSON.stringify(this._remoteData.cells):null);const authoredCells=Array.from(this.querySelectorAll(":scope > .c-hexbin__cell"));let parsed=null;if(authoredCells.length){parsed=authoredCells.map((el)=>el.textContent||el.getAttribute("title")||"");authoredCells.forEach((el)=>el.remove())}else if(effectiveCells){try{parsed=JSON.parse(effectiveCells)}catch(e){parsed=null}}if(parsed){try{Array.from(this.querySelectorAll(".c-hexbin__cell")).forEach((n)=>n.remove());const cols=Math.ceil(Math.sqrt(parsed.length||1));this.style.gridTemplateColumns="repeat("+cols+", 1fr)";this.style.inlineSize="16rem";parsed.forEach((c,i)=>{const cell=document.createElement("div");cell.className="c-hexbin__cell";cell.setAttribute("tabindex",i===0?"0":"-1");if(typeof c==="object"&&c.value!=null){cell.textContent=c.value;cell.setAttribute("title",String(c.value))}else if(typeof c!=="object"){cell.textContent=c;cell.setAttribute("title",String(c))}this.appendChild(cell)});const tip=this.ensure(".c-hexbin__tooltip",()=>{const el=document.createElement("div");el.className="c-hexbin__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}catch(e){warnBadJson(this,"attribute",e)}}else if(!parsed){Array.from(this.querySelectorAll(".c-hexbin__cell")).forEach((n)=>n.remove());renderEmpty(this,"hexbin")}}enhance(){if(this._wiredHexbin)return;this._wiredHexbin=true;wireMapItems(this,".c-hexbin__cell",".c-hexbin__tooltip")}}define("contour-hexbin",ContourHexbin);class ContourFlowMap extends ContourBase{static get observed(){return["label","nodes","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},nodes:{attribute:"nodes"},src:{attribute:"src"}}}render(){this.classList.add("c-flow-map");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"Flow map");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-flow-map__label",()=>{const el=document.createElement("span");el.className="c-flow-map__label";return el});l.textContent=label}else{const l=this.querySelector(".c-flow-map__label");if(l)l.remove()}wireStates(this);loadRemote(this,"nodes");if(renderStates(this,"flow-map"))return;const nodes=remoteData(this,"nodes");const effectiveNodes=nodes||(this._remoteData&&this._remoteData.nodes?JSON.stringify(this._remoteData.nodes):null);const authoredNodes=Array.from(this.querySelectorAll(":scope > .c-flow-map__node"));let parsed=null;if(authoredNodes.length){parsed=authoredNodes.map((el)=>el.textContent||el.getAttribute("title")||"");authoredNodes.forEach((el)=>el.remove())}else if(effectiveNodes){try{parsed=JSON.parse(effectiveNodes)}catch(e){parsed=null}}if(parsed){try{Array.from(this.querySelectorAll(".c-flow-map__node")).forEach((n)=>n.remove());parsed.forEach((n,i)=>{const node=document.createElement("span");node.className="c-flow-map__node"+(n.source?" c-flow-map__node--source":"")+(n.target?" c-flow-map__node--target":"");node.setAttribute("tabindex",i===0?"0":"-1");node.textContent=typeof n==="string"?n:(n.label||n.name||"");if(typeof n==="object"&&(n.label||n.name))node.setAttribute("title",n.label||n.name);this.appendChild(node)});const tip=this.ensure(".c-flow-map__tooltip",()=>{const el=document.createElement("div");el.className="c-flow-map__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}catch(e){warnBadJson(this,"attribute",e)}}else if(!parsed){Array.from(this.querySelectorAll(".c-flow-map__node")).forEach((n)=>n.remove());renderEmpty(this,"flow-map")}}enhance(){if(this._wiredFlowMap)return;this._wiredFlowMap=true;wireMapItems(this,".c-flow-map__node",".c-flow-map__tooltip")}}define("contour-flow-map",ContourFlowMap);class ContourIsochrone extends ContourBase{static get observed(){return["label","center","rings","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},center:{attribute:"center"},rings:{attribute:"rings"},src:{attribute:"src"}}}render(){this.classList.add("c-isochrone");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"Isochrone");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-isochrone__label",()=>{const el=document.createElement("span");el.className="c-isochrone__label";return el});l.textContent=label}else{const l=this.querySelector(".c-isochrone__label");if(l)l.remove()}const center=this.getAttribute("center")||(this._remoteData&&this._remoteData.center);if(center){const c=this.ensure(".c-isochrone__center",()=>{const el=document.createElement("span");el.className="c-isochrone__center";return el});c.textContent=center}else{const c=this.querySelector(".c-isochrone__center");if(c)c.remove()}wireStates(this);loadRemote(this,"rings");if(renderStates(this,"isochrone"))return;const rings=remoteData(this,"rings");const effectiveRings=rings||(this._remoteData&&this._remoteData.rings?JSON.stringify(this._remoteData.rings):null);const authoredRings=Array.from(this.querySelectorAll(":scope > .c-isochrone__ring"));let parsed=null;if(authoredRings.length){parsed=authoredRings.map((el)=>el.textContent||el.getAttribute("title")||"");authoredRings.forEach((el)=>el.remove())}else if(effectiveRings){try{parsed=JSON.parse(effectiveRings)}catch(e){parsed=null}}if(parsed){try{Array.from(this.querySelectorAll(".c-isochrone__ring")).forEach((n)=>n.remove());parsed.forEach((r,i)=>{const ring=document.createElement("span");const raw=typeof r==="string"?r:(r&&(r.label||r.name||r.value||r.min));const ringLabel=raw===undefined||raw===null?"":String(raw);const slug=ringLabel.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");ring.className="c-isochrone__ring"+(slug?" c-isochrone__ring--"+slug:"");ring.setAttribute("tabindex",i===0?"0":"-1");ring.setAttribute("aria-label",ringLabel||"Isochrone ring "+(i+1));if(ringLabel)ring.setAttribute("title",ringLabel);this.appendChild(ring)});const tip=this.ensure(".c-isochrone__tooltip",()=>{const el=document.createElement("div");el.className="c-isochrone__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}catch(e){warnBadJson(this,"attribute",e)}}else if(!parsed){Array.from(this.querySelectorAll(".c-isochrone__ring")).forEach((n)=>n.remove());renderEmpty(this,"isochrone")}}enhance(){if(this._wiredIsochrone)return;this._wiredIsochrone=true;wireMapItems(this,".c-isochrone__ring",".c-isochrone__tooltip")}}define("contour-isochrone",ContourIsochrone);class ContourCatchment extends ContourBase{static get observed(){return["label","area","center","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},area:{attribute:"area"},center:{attribute:"center"},src:{attribute:"src"}}}render(){this.classList.add("c-catchment");if(!this.hasAttribute("role"))this.setAttribute("role","img");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"Catchment");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-catchment__label",()=>{const el=document.createElement("span");el.className="c-catchment__label";return el});l.textContent=label}else{const l=this.querySelector(".c-catchment__label");if(l)l.remove()}const area=this.getAttribute("area")||(this._remoteData&&this._remoteData.area);if(area){const a=this.ensure(".c-catchment__area",()=>{const el=document.createElement("span");el.className="c-catchment__area";return el});a.textContent=area}else{const a=this.querySelector(".c-catchment__area");if(a)a.remove()}const center=this.getAttribute("center")||(this._remoteData&&this._remoteData.center);if(center){const c=this.ensure(".c-catchment__center",()=>{const el=document.createElement("span");el.className="c-catchment__center";return el});c.textContent=center}else{const c=this.querySelector(".c-catchment__center");if(c)c.remove()}wireStates(this);loadRemote(this,["label","area","center"]);if(renderStates(this,"catchment"))return;const rLabel=remoteData(this,"label")||(this._remoteData&&this._remoteData.label);const rArea=remoteData(this,"area")||(this._remoteData&&this._remoteData.area);const rCenter=remoteData(this,"center")||(this._remoteData&&this._remoteData.center);if(!rLabel&&!rArea&&!rCenter){renderEmpty(this,"catchment");return}const tip=this.ensure(".c-catchment__tooltip",()=>{const el=document.createElement("div");el.className="c-catchment__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","");if(rArea)tip.textContent=rArea}enhance(){if(this._wiredCatchment)return;this._wiredCatchment=true;const showTip=()=>{const tip=this.querySelector(".c-catchment__tooltip");if(tip)tip.removeAttribute("hidden")};const hideTip=()=>{const tip=this.querySelector(".c-catchment__tooltip");if(tip)tip.setAttribute("hidden","")};this.addEventListener("mouseenter",showTip);this.addEventListener("mouseleave",hideTip);if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");this.addEventListener("focusin",showTip);this.addEventListener("focusout",hideTip);this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{area:this.getAttribute("area")}}))}})}}define("contour-catchment",ContourCatchment);class ContourCompassFull extends ContourBase{static get observed(){return["label","needle","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},needle:{attribute:"needle"},src:{attribute:"src"}}}render(){this.classList.add("c-compass");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"Compass");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);wireStates(this);loadRemote(this,"needle");if(renderStates(this,"compass"))return;const needle=remoteData(this,"needle")||(this._remoteData&&(this._remoteData.needle||this._remoteData.value));for(const dir of["n","s","e","w"]){const cls=".c-compass__label--"+dir;let l=this.querySelector(cls);if(!l){l=document.createElement("span");l.className="c-compass__label "+cls.slice(1);l.textContent=dir.toUpperCase();l.setAttribute("role","button");l.setAttribute("tabindex","0");this.appendChild(l)}}if(label&&label.toLowerCase()!=="compass"){const l=this.ensure(".c-compass__label:not([class*='--'])",()=>{const el=document.createElement("span");el.className="c-compass__label";return el});l.textContent=label}if(needle){const deg=Number(needle)||0;const n=this.ensure("svg.c-compass__needle",()=>{const el=document.createElementNS("http://www.w3.org/2000/svg","svg");el.setAttribute("class","c-compass__needle");el.setAttribute("viewBox","0 0 40 40");el.setAttribute("aria-hidden","true");const pathN=document.createElementNS("http://www.w3.org/2000/svg","path");pathN.setAttribute("class","c-compass__needle--n");pathN.setAttribute("d",compassNeedle(20,20,16,deg));el.appendChild(pathN);const pathS=document.createElementNS("http://www.w3.org/2000/svg","path");pathS.setAttribute("class","c-compass__needle--s");pathS.setAttribute("d",compassNeedle(20,20,16,deg+180));el.appendChild(pathS);return el});const pathN=n.querySelector(".c-compass__needle--n");if(pathN)pathN.setAttribute("d",compassNeedle(20,20,16,deg));const pathS=n.querySelector(".c-compass__needle--s");if(pathS)pathS.setAttribute("d",compassNeedle(20,20,16,deg+180))}else{const n=this.querySelector("svg.c-compass__needle, .c-compass__needle");if(n)n.remove()}if(!needle&&!label){renderEmpty(this,"compass")}}enhance(){if(this._wiredCompass)return;this._wiredCompass=true;const DEGREES={n:0,e:90,s:180,w:270};const setBearing=(dir)=>{const deg=DEGREES[dir];if(deg===undefined)return;const n=this.querySelector(".c-compass__needle");if(n){const pathN=n.querySelector(".c-compass__needle--n");if(pathN)pathN.setAttribute("d",compassNeedle(20,20,16,deg));const pathS=n.querySelector(".c-compass__needle--s");if(pathS)pathS.setAttribute("d",compassNeedle(20,20,16,deg+180))}this.dispatchEvent(new CustomEvent("contour:bearing",{bubbles:true,composed:true,detail:{direction:dir,degrees:deg}}))};this.addEventListener("click",(e)=>{const label=e.target&&e.target.closest?e.target.closest(".c-compass__label--n, .c-compass__label--e, .c-compass__label--s, .c-compass__label--w"):null;if(!label||!this.contains(label))return;const m=label.className.match(/c-compass__label--([nsew])/);if(m)setBearing(m[1])});this.addEventListener("keydown",(e)=>{if(e.key!=="Enter"&&e.key!==" ")return;const label=e.target&&e.target.closest?e.target.closest(".c-compass__label--n, .c-compass__label--e, .c-compass__label--s, .c-compass__label--w"):null;if(!label||!this.contains(label))return;e.preventDefault();const m=label.className.match(/c-compass__label--([nsew])/);if(m)setBearing(m[1])})}}define("contour-compass",ContourCompassFull);class ContourLayerSwitch extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-layer-switch");wireStates(this);loadRemote(this,"items");if(renderStates(this,"layer-switch"))return;const items=remoteData(this,"items");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-layer-switch__item"));if(items&&!authored.length){Array.from(this.querySelectorAll(".c-layer-switch__item")).forEach((n)=>n.remove());try{const parsed=JSON.parse(items);const capped=Array.isArray(parsed)?parsed.slice(0,50):parsed;capped.forEach((it)=>{const item=document.createElement("div");item.className="c-layer-switch__item";item.setAttribute("role","group");const sw=document.createElement("span");sw.className="c-layer-switch__swatch";if(it.color)sw.style.background=it.color;sw.setAttribute("aria-hidden","true");item.appendChild(sw);const name=document.createElement("span");name.className="c-layer-switch__name";name.textContent=typeof it==="string"?it:(it.name||it.label||"");item.appendChild(name);if(it.count!=null){const c=document.createElement("span");c.className="c-layer-switch__count";c.textContent=it.count;item.appendChild(c)}const toggle=document.createElement("button");toggle.className="c-layer-switch__toggle";toggle.type="button";toggle.setAttribute("aria-label","Toggle "+(typeof it==="string"?it:(it.name||it.label||"layer")));toggle.setAttribute("aria-pressed","true");toggle.innerHTML='<svg aria-hidden="true"><use href="#i-check" /></svg>';item.appendChild(toggle);this.appendChild(item)})}catch(e){warnBadJson(this,"attribute",e)}}else if(!items&&!authored.length){Array.from(this.querySelectorAll(".c-layer-switch__item")).forEach((n)=>n.remove());renderEmpty(this,"layer-switch")}}enhance(){if(this._wiredLayerSwitch)return;this._wiredLayerSwitch=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-layer-switch__toggle"):null;if(!btn||!this.contains(btn))return;const item=btn.closest(".c-layer-switch__item");const name=item?(item.querySelector(".c-layer-switch__name")?.textContent||""):"";const now=btn.getAttribute("aria-pressed")!=="true";btn.setAttribute("aria-pressed",String(now));this.dispatchEvent(new CustomEvent("contour:layer-toggle",{bubbles:true,composed:true,detail:{name,visible:now}}))});this.addEventListener("keydown",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-layer-switch__toggle"):null;if(!btn||!this.contains(btn))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();btn.click()}})}}define("contour-layer-switch",ContourLayerSwitch);class ContourMapSlot extends ContourBase{static get observed(){return["attribution","scale","chrome"]}static get properties(){return{attribution:{attribute:"attribution"},scale:{attribute:"scale"},chrome:{attribute:"chrome"}}}render(){this.classList.add("c-map-slot");const chrome=this.getAttribute("chrome");if(chrome){const c=this.ensure(".c-map-slot__chrome",()=>{const el=document.createElement("div");el.className="c-map-slot__chrome";return el});c.textContent=chrome}else{const c=this.querySelector(".c-map-slot__chrome");if(c)c.remove()}const attribution=this.getAttribute("attribution");if(attribution){const a=this.ensure(".c-map-slot__attribution",()=>{const el=document.createElement("div");el.className="c-map-slot__attribution";return el});a.textContent=attribution}else{const a=this.querySelector(".c-map-slot__attribution");if(a)a.remove()}const scale=this.getAttribute("scale");if(scale){const sc=this.ensure(".c-map-slot__scale",()=>{const el=document.createElement("div");el.className="c-map-slot__scale";return el});sc.textContent=scale}else{const sc=this.querySelector(".c-map-slot__scale");if(sc)sc.remove()}}}define("contour-map-slot",ContourMapSlot);class ContourMapArea extends ContourBase{static get observed(){return["attribution","attribution-mark","scale","controls"]}static get properties(){return{attribution:{attribute:"attribution"},"attribution-mark":{attribute:"attribution-mark"},scale:{attribute:"scale"},controls:{attribute:"controls"}}}render(){this.classList.add("c-map-area");if(!this.hasAttribute("role"))this.setAttribute("role","region");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Map area");const attribution=this.getAttribute("attribution");if(attribution){const a=this.ensure(".c-map-slot__attribution",()=>{const el=document.createElement("div");el.className="c-map-slot__attribution";return el});a.textContent=attribution}else{const a=this.querySelector(".c-map-slot__attribution");if(a)a.remove()}const mark=this.getAttribute("attribution-mark");if(mark){const m=this.ensure(".c-map-slot__attribution-mark",()=>{const el=document.createElement("span");el.className="c-map-slot__attribution-mark";return el});m.textContent=mark}else{const m=this.querySelector(".c-map-slot__attribution-mark");if(m)m.remove()}const scale=this.getAttribute("scale");if(scale){const sc=this.ensure(".c-map-slot__scale",()=>{const el=document.createElement("div");el.className="c-map-slot__scale";return el});sc.textContent=scale}else{const sc=this.querySelector(".c-map-slot__scale");if(sc)sc.remove()}const controls=this.getAttribute("controls");if(controls){try{const parsed=JSON.parse(controls);const wrap=this.ensure(".c-map-slot__controls",()=>{const el=document.createElement("div");el.className="c-map-slot__controls";return el});wrap.innerHTML="";parsed.forEach((c)=>{const btn=document.createElement("button");btn.className="c-map-slot__control";btn.type="button";btn.textContent=typeof c==="string"?c:(c.label||c);wrap.appendChild(btn)})}catch(e){warnBadJson(this,"attribute",e)}}else{const w=this.querySelector(".c-map-slot__controls");if(w)w.remove()}}enhance(){if(this._wiredMapArea)return;this._wiredMapArea=true;this._map=null;this.attachMap=(map)=>{this._map=map||null;this.dispatchEvent(new CustomEvent("contour:map-attach",{bubbles:true,composed:true}))};this.detachMap=()=>{this._map=null;this.dispatchEvent(new CustomEvent("contour:map-detach",{bubbles:true,composed:true}))};Object.defineProperty(this,"map",{get:()=>this._map,set:(m)=>this.attachMap(m)});this.getViewport=()=>{const m=this._map;if(!m)return null;try{if(typeof m.getBounds==="function"){const b=m.getBounds();return{west:b.getWest(),south:b.getSouth(),east:b.getEast(),north:b.getNorth()}}if(m.transform&&typeof m.transform==="object"){return{zoom:m.transform.zoom,center:m.transform.center}}}catch(e){}return null};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-map-slot__control"):null;if(!btn||!this.contains(btn))return;this.dispatchEvent(new CustomEvent("contour:map-control",{bubbles:true,composed:true,detail:{control:btn.textContent}}))})}}define("contour-map-area",ContourMapArea);class ContourMapPanel extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-map-panel");if(!this.hasAttribute("role"))this.setAttribute("role","region");const title=this.getAttribute("title");if(title){if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",title)}else{if(this.getAttribute("aria-label")===this.getAttribute("title"))this.removeAttribute("aria-label")}}}define("contour-map-panel",ContourMapPanel);class ContourMapFooter extends ContourBase{static get observed(){return["brand"]}static get properties(){return{brand:{attribute:"brand"}}}render(){this.classList.add("c-map-footer");if(!this.hasAttribute("role"))this.setAttribute("role","contentinfo");const brand=this.getAttribute("brand");if(brand){const b=this.ensure(".c-map-footer__brand",()=>{const el=document.createElement("span");el.className="c-map-footer__brand";return el});b.textContent=brand}else{const b=this.querySelector(".c-map-footer__brand");if(b)b.remove()}}}define("contour-map-footer",ContourMapFooter);class ContourScaleBar extends ContourBase{static get observed(){return["label","value","distance","resolution","latitude","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},distance:{attribute:"distance"},resolution:{attribute:"resolution"},latitude:{attribute:"latitude"},src:{attribute:"src"}}}render(){this.classList.add("c-scale-bar");wireStates(this);loadRemote(this,["label","value"]);if(renderStates(this,"scale-bar"))return;let value=remoteData(this,"value")||(this._remoteData&&this._remoteData.value);const resolution=parseFloat(this.getAttribute("resolution"));let derivedLabel=null;if(Number.isFinite(resolution)&&resolution>0){const distance=parseFloat(this.getAttribute("distance"))||1000;value=String(Math.round(distance/resolution));if(!this.getAttribute("label")&&!remoteData(this,"label")){derivedLabel=distance>=1000?(distance/1000)+" km":distance+" m"}}const label=derivedLabel||remoteData(this,"label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-scale-bar__label",()=>{const el=document.createElement("span");el.className="c-scale-bar__label";return el});l.textContent=label}else{const l=this.querySelector(".c-scale-bar__label");if(l)l.remove()}if(!value){renderEmpty(this,"scale-bar");return}const line=this.ensure(".c-scale-bar__line",()=>{const el=document.createElement("span");el.className="c-scale-bar__line";return el});line.style.inlineSize=/^\d+(\.\d+)?$/.test(String(value))?value+"px":value;const ticks=scaleBarTicks(parseFloat(value)||0,4);const max=ticks[ticks.length-1]||1;Array.from(line.querySelectorAll(".c-scale-bar__tick")).forEach((t)=>t.remove());ticks.forEach((tv)=>{const tick=document.createElement("span");tick.className="c-scale-bar__tick";tick.style.insetInlineStart=((tv/max)*100)+"%";line.appendChild(tick)})}}define("contour-scale-bar",ContourScaleBar);class ContourSplitMap extends ContourBase{static get observed(){return["left","right"]}static get properties(){return{left:{attribute:"left"},right:{attribute:"right"}}}render(){this.classList.add("c-split-map");const left=this.ensure(".c-split-map__pane--left",()=>{const e=document.createElement("div");e.className="c-split-map__pane c-split-map__pane--left";return e});const right=this.ensure(".c-split-map__pane--right",()=>{const e=document.createElement("div");e.className="c-split-map__pane c-split-map__pane--right";return e});if(left.parentNode!==this)this.appendChild(left);if(right.parentNode!==this)this.appendChild(right)}}define("contour-split-map",ContourSplitMap);class ContourResizeObserver extends ContourBase{static get observed(){return["debounce"]}static get properties(){return{debounce:{attribute:"debounce"}}}render(){this.classList.add("c-resize-observer");this.setAttribute("aria-hidden","true")}enhance(){if(this._wiredResizeObserver)return;this._wiredResizeObserver=true;if(typeof ResizeObserver!=="function")return;const debounce=parseInt(this.getAttribute("debounce")||"0",10)||0;let timer=null;const ro=new ResizeObserver((entries)=>{const fire=()=>{const e=entries[entries.length-1];const cr=e&&e.contentRect?e.contentRect:this.getBoundingClientRect();this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:true,composed:true,detail:{width:cr.width,height:cr.height}}))};if(debounce>0){clearTimeout(timer);timer=setTimeout(fire,debounce)}else fire()});ro.observe(this);onDispose(this,()=>{ro.disconnect();clearTimeout(timer)})}}define("contour-resize-observer",ContourResizeObserver);class ContourReservedFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-reserved");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-reserved__title",()=>{const el=document.createElement("div");el.className="c-reserved__title";return el});t.textContent=title}}}define("contour-reserved",ContourReservedFull);class ContourThemeScopeFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-theme-scope");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-theme-scope__title",()=>{const el=document.createElement("div");el.className="c-theme-scope__title";el.style.padding="var(--space-sm)";el.style.fontWeight="var(--weight-semibold)";return el});t.textContent=title}}}define("contour-theme-scope",ContourThemeScopeFull);class ContourActivity extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-activity");this.setAttribute("role","list");wireStates(this);loadRemote(this,"items");if(renderStates(this,"activity"))return;const items=remoteData(this,"items");if(items){try{const parsed=JSON.parse(items);Array.from(this.querySelectorAll(".c-activity__item")).forEach((n)=>n.remove());parsed.forEach((it,i)=>{const item=document.createElement("div");item.className="c-activity__item";item.setAttribute("role","button");item.setAttribute("tabindex",i===0?"0":"-1");const dot=document.createElement("span");dot.className="c-activity__dot c-activity__dot--"+(it.variant||"primary");dot.setAttribute("aria-hidden","true");item.appendChild(dot);const text=document.createElement("span");text.className="c-activity__text";text.textContent=typeof it==="string"?it:(it.text||it.label||"");if(!item.hasAttribute("aria-label"))item.setAttribute("aria-label",text.textContent);item.appendChild(text);if(it.time){const time=document.createElement("span");time.className="c-activity__time";time.textContent=it.time;item.appendChild(time)}this.appendChild(item)})}catch(e){warnBadJson(this,"attribute",e)}}else{renderEmpty(this,"activity")}}enhance(){if(this._wiredActivity)return;this._wiredActivity=true;this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-activity__item"):null;if(item&&this.contains(item)){const items=Array.from(this.querySelectorAll(".c-activity__item"));const index=items.indexOf(item);const text=item.querySelector(".c-activity__text")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:activity-select",{bubbles:true,composed:true,detail:{index,text}}))}});this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-activity__item"));if(!items.length)return;navKey(e,items,{wrap:false,homeEnd:true,onNavigate:(i)=>{items.forEach((it,j)=>it.tabIndex=j===i?0:-1)},onKey:()=>{if(e.key==="Enter"||e.key===" "){const idx=items.indexOf(document.activeElement);this.dispatchEvent(new CustomEvent("contour:activity-select",{bubbles:true,composed:true,detail:{index:idx,text:document.activeElement.querySelector(".c-activity__text")?.textContent||""}}))}}})})}}define("contour-activity",ContourActivity);class ContourActivityFeed extends ContourBase{static get observed(){return["items","filter","unread-only","empty","loading","error","labels","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},filter:{attribute:"filter"},"unread-only":{attribute:"unread-only",type:Boolean}}}render(){this.classList.add("c-activity-feed");if(!this.hasAttribute("role"))this.setAttribute("role","region");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",labelText(this,"title","Activity feed"));wireStates(this);loadRemote(this,"items");if(renderStates(this,"activity-feed"))return;const items=remoteData(this,"items");const filter=this.getAttribute("filter");const unreadOnly=this.hasAttribute("unread-only");let header=this.querySelector(".c-activity-feed__header");if(!header){header=document.createElement("div");header.className="c-activity-feed__header";this.insertBefore(header,this.firstChild)}let title=header.querySelector(".c-activity-feed__title");if(!title){title=document.createElement("div");title.className="c-activity-feed__title";header.appendChild(title)}title.textContent=labelText(this,"title","Activity feed");let toolbar=this.querySelector(".c-activity-feed__toolbar");if(!toolbar){toolbar=document.createElement("div");toolbar.className="c-activity-feed__toolbar";this.appendChild(toolbar)}const clear=toolbar.querySelector("[data-activity-clear]")||(()=>{const b=document.createElement("button");b.type="button";b.className="c-btn c-btn--ghost c-btn--sm";b.setAttribute("data-activity-clear","");b.textContent=labelText(this,"clear","Clear all");toolbar.appendChild(b);return b})();const unreadBtn=toolbar.querySelector("[data-activity-unread]")||(()=>{const b=document.createElement("button");b.type="button";b.className="c-btn c-btn--ghost c-btn--sm";b.setAttribute("data-activity-unread","");b.textContent=labelText(this,"unread","Unread only");toolbar.appendChild(b);return b})();if(unreadOnly)unreadBtn.setAttribute("aria-pressed","true");let list=this.querySelector(".c-activity-feed__list");if(!list){list=document.createElement("ol");list.className="c-activity-feed__list";this.appendChild(list)}if(items){try{const parsed=JSON.parse(items);let filtered=parsed;if(filter)filtered=filtered.filter((it)=>String(it.severity||it.type||"").toLowerCase()===filter.toLowerCase());if(unreadOnly)filtered=filtered.filter((it)=>!it.read);Array.from(list.querySelectorAll(".c-activity-feed__item")).forEach((n)=>n.remove());if(filtered.length===0){let empty=list.querySelector(".c-activity-feed__empty");if(!empty){empty=document.createElement("div");empty.className="c-activity-feed__empty";empty.textContent=labelText(this,"empty","No activity");list.appendChild(empty)}}else{const empty=list.querySelector(".c-activity-feed__empty");if(empty)empty.remove();filtered.forEach((it,idx)=>{const item=document.createElement("li");item.className="c-activity-feed__item"+(it.read?"":" c-activity-feed__item--unread");item.setAttribute("role","button");item.setAttribute("tabindex",idx===0?"0":"-1");const dot=document.createElement("span");dot.className="c-activity-feed__dot c-activity-feed__dot--"+(it.severity||"info");dot.setAttribute("aria-hidden","true");item.appendChild(dot);const text=document.createElement("span");text.className="c-activity-feed__text";text.textContent=typeof it==="string"?it:(it.text||it.label||"");item.appendChild(text);const time=document.createElement("time");time.className="c-activity-feed__time";if(it.time)time.setAttribute("datetime",String(it.time));time.textContent=it.time||"";item.appendChild(time);const sev=document.createElement("span");sev.className="c-activity-feed__severity";sev.textContent=it.severity||"";item.appendChild(sev);list.appendChild(item)})}}catch(e){warnBadJson(this,"attribute",e)}}}enhance(){if(this._wiredActivityFeed)return;this._wiredActivityFeed=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest("button"):null;if(!btn||!this.contains(btn))return;if(btn.hasAttribute("data-activity-clear")){this.dispatchEvent(new CustomEvent("contour:activity-clear",{bubbles:true,composed:true,detail:{}}))}else if(btn.hasAttribute("data-activity-unread")){this.toggleAttribute("unread-only");this.dispatchEvent(new CustomEvent("contour:activity-filter",{bubbles:true,composed:true,detail:{unread:this.hasAttribute("unread-only")}}))}else{const item=e.target.closest(".c-activity-feed__item");if(item&&this.contains(item)){const items=Array.from(this.querySelectorAll(".c-activity-feed__item"));const index=items.indexOf(item);const text=item.querySelector(".c-activity-feed__text")?.textContent||"";item.classList.remove("c-activity-feed__item--unread");this.dispatchEvent(new CustomEvent("contour:activity-select",{bubbles:true,composed:true,detail:{index,text}}))}}});this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-activity-feed__item"));if(!items.length)return;navKey(e,items,{wrap:false,homeEnd:true,onNavigate:(i)=>{items.forEach((it,j)=>it.tabIndex=j===i?0:-1)},onKey:()=>{if(e.key==="Enter"||e.key===" "){const idx=items.indexOf(document.activeElement);this.dispatchEvent(new CustomEvent("contour:activity-select",{bubbles:true,composed:true,detail:{index:idx,text:document.activeElement.querySelector(".c-activity-feed__text")?.textContent||""}}))}}})})}}define("contour-activity-feed",ContourActivityFeed);class ContourAdvanced extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-advanced");this.setAttribute("role","region");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-advanced__title",()=>{const el=document.createElement("div");el.className="c-advanced__title";return el});t.textContent=title;this.setAttribute("aria-label",title)}}enhance(){if(this._wiredAdvanced)return;this._wiredAdvanced=true;this.addEventListener("click",(e)=>{const t=e.target&&e.target.closest?e.target.closest(".c-advanced__title"):null;if(!t||!this.contains(t))return;const title=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:advanced-toggle",{bubbles:true,composed:true,detail:{title}}))});this.addEventListener("keydown",(e)=>{if(e.target!==this)return;if(e.key==="Enter"||e.key===" "){e.preventDefault();const title=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:advanced-toggle",{bubbles:true,composed:true,detail:{title}}))}})}}define("contour-advanced",ContourAdvanced);class ContourAffordance extends ContourBase{static get observed(){return["name","note","demo"]}static get properties(){return{name:{attribute:"name"},note:{attribute:"note"},demo:{attribute:"demo"}}}render(){this.classList.add("c-affordance");this.setAttribute("role","group");const name=this.getAttribute("name");if(name){const n=this.ensure(".c-affordance__name",()=>{const el=document.createElement("div");el.className="c-affordance__name";return el});n.textContent=name;this.setAttribute("aria-label",name)}else{const n=this.querySelector(".c-affordance__name");if(n)n.remove()}const note=this.getAttribute("note");if(note){const nt=this.ensure(".c-affordance__note",()=>{const el=document.createElement("div");el.className="c-affordance__note";return el});nt.textContent=note}else{const nt=this.querySelector(".c-affordance__note");if(nt)nt.remove()}const demo=this.getAttribute("demo");if(demo){const d=this.ensure(".c-affordance__demo",()=>{const el=document.createElement("div");el.className="c-affordance__demo";return el});d.textContent=demo}else{const d=this.querySelector(".c-affordance__demo");if(d)d.remove()}}enhance(){if(this._wiredAffordance)return;this._wiredAffordance=true;this.addEventListener("click",(e)=>{const name=this.getAttribute("name")||"";this.dispatchEvent(new CustomEvent("contour:affordance-activate",{bubbles:true,composed:true,detail:{name}}))});this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();const name=this.getAttribute("name")||"";this.dispatchEvent(new CustomEvent("contour:affordance-activate",{bubbles:true,composed:true,detail:{name}}))}})}}define("contour-affordance",ContourAffordance);class ContourAffordances extends ContourBase{static get observed(){return["name","title"]}static get properties(){return{name:{attribute:"name"},title:{attribute:"title"}}}render(){this.classList.add("c-affordances");this.setAttribute("role","group");if(!this.querySelector(".c-affordance")){const aff=document.createElement("div");aff.className="c-affordance";const name=this.getAttribute("name")||this.getAttribute("title")||labelText(this,"affordance","Affordance");const n=document.createElement("div");n.className="c-affordance__name";n.textContent=name;aff.appendChild(n);const demo=document.createElement("div");demo.className="c-affordance__demo";demo.textContent=labelText(this,"demo","Demo");aff.appendChild(demo);this.appendChild(aff)}}}define("contour-affordances",ContourAffordances);class ContourMenu extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-menu");if(!this.hasAttribute("role"))this.setAttribute("role","menu");wireStates(this);loadRemote(this,"items");if(renderStates(this,"menu"))return;const items=remoteData(this,"items");const authoredItems=Array.from(this.querySelectorAll("li[role='menuitem'], li.c-menu__item, [role='menuitem']"));const authoredUl=this.querySelector("ul.c-menu");if(authoredItems.length){if(!authoredUl){const ul=document.createElement("ul");ul.className="c-menu";ul.setAttribute("role","menu");for(const item of authoredItems){if(item.parentElement===this)ul.appendChild(item)}this.appendChild(ul)}else{for(const item of authoredItems){if(!item.classList.contains("c-menu__item"))item.classList.add("c-menu__item");if(!item.getAttribute("role"))item.setAttribute("role","menuitem");if(!item.hasAttribute("tabindex"))item.setAttribute("tabindex","-1")}}const first=authoredItems.find((it)=>it.getAttribute("aria-disabled")!=="true");if(first)first.setAttribute("tabindex","0");this.classList.remove("c-menu");if(authoredUl)authoredUl.classList.add("c-menu");return}if(authoredUl){return}if(items){try{const parsed=JSON.parse(items);const ul=this.ensure("ul.c-menu",()=>{const el=document.createElement("ul");el.className="c-menu";el.setAttribute("role","menu");return el});ul.innerHTML="";ul.setAttribute("role","menu");parsed.forEach((item)=>{if(item==="---"||item==="separator"){const li=document.createElement("li");li.className="c-menu__separator";li.setAttribute("role","separator");ul.appendChild(li)}else if(typeof item==="string"){const li=document.createElement("li");li.className="c-menu__item";li.setAttribute("role","menuitem");li.textContent=item;ul.appendChild(li)}else if(item.group){const li=document.createElement("li");li.className="c-menu__group";li.setAttribute("role","group");if(item.group)li.setAttribute("aria-label",String(item.group));const hdr=document.createElement("div");hdr.className="c-menu__group-label";hdr.textContent=String(item.group);li.appendChild(hdr);if(Array.isArray(item.items)){const sub=document.createElement("ul");sub.className="c-menu";sub.setAttribute("role","menu");item.items.forEach((subItem)=>{const sli=document.createElement("li");sli.className="c-menu__item"+(subItem.danger?" c-menu__item--danger":"")+(subItem.disabled?" c-menu__item--disabled":"");sli.setAttribute("role","menuitem");if(subItem.disabled)sli.setAttribute("aria-disabled","true");if(subItem.label||subItem.title){const lbl=document.createElement("span");lbl.className="c-menu__label";lbl.textContent=subItem.label||subItem.title||"";sli.appendChild(lbl)}sub.appendChild(sli)});li.appendChild(sub)}ul.appendChild(li)}else{const li=document.createElement("li");li.className="c-menu__item"+(item.danger?" c-menu__item--danger":"")+(item.disabled?" c-menu__item--disabled":"");const role=item.type==="checkbox"?"menuitemcheckbox":item.type==="radio"?"menuitemradio":"menuitem";li.setAttribute("role",role);if(item.type==="checkbox"||item.type==="radio")li.setAttribute("aria-checked",String(!!item.checked));if(item.disabled)li.setAttribute("aria-disabled","true");if(item.items&&Array.isArray(item.items)){li.setAttribute("aria-haspopup","menu");li.setAttribute("aria-expanded","false")}if(item.label||item.title){const lbl=document.createElement("span");lbl.className="c-menu__label";lbl.textContent=item.label||item.title||"";li.appendChild(lbl)}if(item.shortcut){const sc=document.createElement("span");sc.className="c-menu__shortcut";sc.textContent=item.shortcut;li.appendChild(sc)}if(item.items&&Array.isArray(item.items)){const sub=document.createElement("ul");sub.className="c-menu";sub.setAttribute("role","menu");item.items.forEach((subItem)=>{const sli=document.createElement("li");sli.className="c-menu__item"+(subItem.danger?" c-menu__item--danger":"")+(subItem.disabled?" c-menu__item--disabled":"");sli.setAttribute("role","menuitem");if(subItem.disabled)sli.setAttribute("aria-disabled","true");if(subItem.label||subItem.title){const sl=document.createElement("span");sl.className="c-menu__label";sl.textContent=subItem.label||subItem.title||"";sli.appendChild(sl)}sub.appendChild(sli)});li.appendChild(sub)}ul.appendChild(li)}});if(ul.parentNode!==this)this.appendChild(ul);this.classList.remove("c-menu");ul.classList.add("c-menu")}catch(e){warnBadJson(this,"attribute",e)}}else{renderEmpty(this,"menu")}}enhance(){wireMenu(this)}}define("contour-menu",ContourMenu);class ContourTabs extends ContourBase{static get observed(){return["tabs","autoplay","pause","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist","orientation","closable"]}static get properties(){return{tabs:{attribute:"tabs"},autoplay:{attribute:"autoplay",type:Number},pause:{attribute:"pause",type:Boolean},src:{attribute:"src"},orientation:{attribute:"orientation"},closable:{attribute:"closable",type:Boolean}}}render(){this.classList.add("c-tabs");wireStates(this);loadRemote(this,"tabs");if(renderStates(this,"tabs"))return;const tabs=remoteData(this,"tabs");const authoredTabs=Array.from(this.querySelectorAll("[role='tab']"));const authoredList=this.querySelector(".c-tabs__list");const authoredPanels=Array.from(this.querySelectorAll(".c-tabs__panel"));if(authoredTabs.length){if(!authoredList){const list=document.createElement("div");list.className="c-tabs__list";list.setAttribute("role","tablist");const orientation=this.getAttribute("orientation")==="vertical"?"vertical":"horizontal";list.setAttribute("aria-orientation",orientation);if(orientation==="vertical")this.classList.add("c-tabs--vertical");else this.classList.remove("c-tabs--vertical");for(const tab of authoredTabs){if(tab.parentElement===this)list.appendChild(tab)}this.prepend(list)}const orientation=this.getAttribute("orientation")==="vertical"?"vertical":"horizontal";if(authoredList)authoredList.setAttribute("aria-orientation",orientation);if(orientation==="vertical")this.classList.add("c-tabs--vertical");else this.classList.remove("c-tabs--vertical");authoredTabs.forEach((tab,i)=>{if(!tab.classList.contains("c-tabs__tab"))tab.classList.add("c-tabs__tab");if(!tab.getAttribute("role"))tab.setAttribute("role","tab");let panelId=tab.getAttribute("aria-controls");if(!panelId){panelId=contourId("c-tabs-panel");tab.setAttribute("aria-controls",panelId);let panel=authoredPanels.find((p)=>p.id===panelId);if(!panel){panel=document.createElement("div");panel.className="c-tabs__panel";panel.id=panelId;panel.setAttribute("role","tabpanel");this.appendChild(panel)}}const selected=i===0||tab.getAttribute("aria-selected")==="true";tab.setAttribute("aria-selected",String(selected));tab.tabIndex=selected?0:-1;const ctrl=tab.getAttribute("aria-controls");const panel=ctrl?document.getElementById(ctrl):null;if(panel)panel.hidden=!selected});return}if(tabs&&!authoredTabs.length){try{const parsed=JSON.parse(tabs);const list=this.ensure(".c-tabs__list",()=>{const el=document.createElement("div");el.className="c-tabs__list";el.setAttribute("role","tablist");return el});list.setAttribute("role","tablist");const orientation=this.getAttribute("orientation")==="vertical"?"vertical":"horizontal";list.setAttribute("aria-orientation",orientation);if(orientation==="vertical")this.classList.add("c-tabs--vertical");else this.classList.remove("c-tabs--vertical");const _prevTabs=Array.from(list.querySelectorAll("[role='tab']"));const _prevSel=_prevTabs.findIndex((t)=>t.getAttribute("aria-selected")==="true");const _keepIdx=_prevSel>=0?_prevSel:0;list.innerHTML="";Array.from(this.querySelectorAll(".c-tabs__panel")).forEach((n)=>n.remove());parsed.forEach((t,i)=>{const label=typeof t==="string"?t:(t.label||t.title||"");const panelId=contourId("c-tabs-panel");const btn=document.createElement(this.hasAttribute("closable")?"div":"button");btn.className="c-tabs__tab";if(btn.tagName==="BUTTON")btn.type="button";btn.setAttribute("role","tab");btn.setAttribute("aria-selected",String(i===_keepIdx));btn.setAttribute("aria-controls",panelId);btn.tabIndex=i===_keepIdx?0:-1;const tabLabel=document.createElement("span");tabLabel.textContent=label;btn.textContent="";btn.appendChild(tabLabel);if(this.hasAttribute("closable")){const closeBtn=document.createElement("button");closeBtn.type="button";closeBtn.className="c-tabs__close";closeBtn.setAttribute("aria-label","Close "+label);closeBtn.textContent="×";closeBtn.addEventListener("click",(e)=>{e.stopPropagation();const idx=Array.from(list.querySelectorAll("[role='tab']")).indexOf(btn);const ctrl=btn.getAttribute("aria-controls");const panel=ctrl?document.getElementById(ctrl):null;btn.remove();if(panel)panel.remove();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true,detail:{index:idx,label}}));const remaining=list.querySelectorAll("[role='tab']");if(remaining.length)remaining[0].click()});btn.appendChild(closeBtn)}list.appendChild(btn);const panel=document.createElement("div");panel.className="c-tabs__panel";panel.id=panelId;panel.setAttribute("role","tabpanel");if(typeof t==="object"&&t!==null&&t.content!==undefined){panel.textContent=String(t.content)}if(i!==_keepIdx)panel.hidden=true;this.appendChild(panel)});if(list.parentNode!==this)this.prepend(list)}catch(e){warnBadJson(this,"attribute",e)}}else if(!tabs&&!authoredTabs.length){const list=this.querySelector(".c-tabs__list");if(list)list.remove();renderEmpty(this,"tabs")}}enhance(){wireTabs(this);const sync=()=>{const seconds=parseFloat(this.getAttribute("autoplay")||"");const paused=this.hasAttribute("pause")||this._tabsHover||this._tabsFocus;const reduced=typeof matchMedia==="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches;const want=Number.isFinite(seconds)&&seconds>0&&!paused&&!reduced;if(want===this._tabsAutoplayRunning)return;this._tabsAutoplayRunning=want;if(this._tabsTimer!==undefined){clearInterval(this._tabsTimer);this._tabsTimer=undefined}if(!want)return;this._tabsTimer=setInterval(()=>{if(!this.isConnected||this.hasAttribute("pause")||this._tabsHover||this._tabsFocus)return;const list=this.querySelector(".c-tabs__list");const tabs=list?Array.from(list.querySelectorAll("[role='tab']")):[];if(!tabs.length)return;const cur=tabs.findIndex((t)=>t.getAttribute("aria-selected")==="true");const next=tabs[(cur+1)%tabs.length];if(next)next.click()},Math.max(1000,seconds*1000))};sync();if(this._wiredTabsAutoplay)return;this._wiredTabsAutoplay=true;this.addEventListener("pointerenter",()=>{this._tabsHover=true;sync()});this.addEventListener("pointerleave",()=>{this._tabsHover=false;sync()});this.addEventListener("focusin",()=>{this._tabsFocus=true;sync()});this.addEventListener("focusout",()=>{this._tabsFocus=false;sync()});onDispose(this,()=>{if(this._tabsTimer!==undefined){clearInterval(this._tabsTimer);this._tabsTimer=undefined}})}}define("contour-tabs",ContourTabs);class ContourHeader extends ContourBase{static get observed(){return["brand","links"]}static get properties(){return{brand:{attribute:"brand"},links:{attribute:"links"}}}render(){this.classList.add("c-header");if(!this.hasAttribute("role"))this.setAttribute("role","banner");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("brand")||"Header");const brand=this.getAttribute("brand");const links=this.getAttribute("links");const inner=this.ensure(".c-header__inner",()=>{const el=document.createElement("div");el.className="container c-header__inner";return el});inner.className="container c-header__inner";let brandEl=inner.querySelector(".c-brand");if(brand){if(!brandEl){brandEl=document.createElement("a");brandEl.className="c-brand";brandEl.setAttribute("data-contour-generated","");brandEl.href="#";brandEl.innerHTML=`<span class="c-mark"><svg aria-hidden="true"><use href="#i-mark" /></svg></span>`;const brandName=document.createElement("span");brandName.className="c-brand__name";brandEl.appendChild(brandName);inner.insertBefore(brandEl,inner.firstChild)}const brandName=brandEl.querySelector(".c-brand__name");if(brandName)brandName.textContent=brand}else if(brandEl&&brandEl.hasAttribute("data-contour-generated")){brandEl.remove()}let nav=inner.querySelector(".c-header__nav");const authoredNav=nav?Array.from(nav.children).filter((n)=>n.tagName==="A"):[];if(links&&!authoredNav.length){try{const parsed=JSON.parse(links);if(!nav){nav=document.createElement("nav");nav.className="c-header__nav";nav.setAttribute("aria-label","Main");nav.setAttribute("data-contour-generated","");inner.appendChild(nav)}nav.innerHTML="";parsed.forEach((l)=>{const a=document.createElement("a");a.href=safeHref(l.href||"#");a.textContent=l.label||l;nav.appendChild(a)})}catch(e){}}else if(links&&authoredNav.length){}else if(nav&&!links&&!authoredNav.length&&nav.hasAttribute("data-contour-generated")){nav.remove()}if(!inner.querySelector(".c-header__actions")){const actions=document.createElement("div");actions.className="c-header__actions";inner.appendChild(actions)}const navEl=inner.querySelector(".c-header__nav");if(navEl){if(!navEl.id)navEl.id=contourId("header-nav");const actions=inner.querySelector(".c-header__actions");if(actions&&!actions.querySelector(".c-header__toggle")){const toggle=document.createElement("button");toggle.type="button";toggle.className="c-header__toggle";toggle.setAttribute("aria-label","Toggle navigation");toggle.setAttribute("aria-expanded","false");toggle.setAttribute("aria-controls",navEl.id);toggle.innerHTML='<svg aria-hidden="true"><use href="#i-grid" /></svg>';actions.appendChild(toggle)}}if(inner.parentNode!==this)this.appendChild(inner)}enhance(){if(this._wiredHeader)return;this._wiredHeader=true;const update=()=>{const y=window.scrollY||document.documentElement.scrollTop||0;this.classList.toggle("c-header--scrolled",y>8)};update();window.addEventListener("scroll",update,{passive:true});onDispose(this,()=>window.removeEventListener("scroll",update));this.addEventListener("click",(e)=>{const toggle=e.target&&e.target.closest?e.target.closest(".c-header__toggle"):null;if(!toggle||!this.contains(toggle))return;const nav=this.querySelector("#"+CSS.escape(toggle.getAttribute("aria-controls")||""));if(!nav)return;const open=nav.classList.toggle("is-open");toggle.setAttribute("aria-expanded",String(open));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{open}}))});this.addEventListener("keydown",(e)=>{if(e.key!=="Escape")return;const toggle=this.querySelector(".c-header__toggle");const nav=toggle&&this.querySelector("#"+CSS.escape(toggle.getAttribute("aria-controls")||""));if(!toggle||!nav||!nav.classList.contains("is-open"))return;nav.classList.remove("is-open");toggle.setAttribute("aria-expanded","false")})}}define("contour-header",ContourHeader);class ContourTree extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","virtual","item-height","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist","selectable"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"},"item-height":{attribute:"item-height"}}}_itemHeight(){const h=Number(this.getAttribute("item-height"));if(Number.isFinite(h)&&h>0)return h;return cssLength("--virtual-list-item-height",28)}_labelToPaths(nodes,pathPrefix,map){(nodes||[]).forEach((node,i)=>{const p=pathPrefix+"."+i;const label=String(node.label||node).trim().slice(0,120);if(!map.has(label))map.set(label,[]);map.get(label).push(p);if(Array.isArray(node.children))this._labelToPaths(node.children,p,map)})}_restoreExpanded(){const persist=this.getAttribute("persist");if(!persist||!this._treeData)return;let labels=null;try{if(persist==="storage"&&this.id){const saved=localStorage.getItem("contour-tree:"+this.id);if(saved!==null)labels=JSON.parse(saved)}else if(persist==="url"){const v=new URLSearchParams(window.location.search).get("c-tree");if(v!==null)labels=JSON.parse(v)}}catch(e){labels=null}if(!Array.isArray(labels))return;const want=new Set(labels.map((l)=>String(l)));const map=new Map();this._labelToPaths(this._treeData,"",map);const expanded=this._expanded||(this._expanded=new Set());for(const lbl of want){const paths=map.get(lbl);if(paths)paths.forEach((p)=>expanded.add(p))}}_persistExpanded(){const persist=this.getAttribute("persist");if(!persist||!this._expanded)return;const pathToNode=new Map();const walk=(nodes,pathPrefix)=>{(nodes||[]).forEach((node,i)=>{const p=pathPrefix+"."+i;pathToNode.set(p,node);if(Array.isArray(node.children))walk(node.children,p)})};walk(this._treeData,"");const open=[];for(const p of this._expanded){const node=pathToNode.get(p);if(node)open.push(String(node.label||node).trim().slice(0,120))}try{if(persist==="storage"&&this.id){localStorage.setItem("contour-tree:"+this.id,JSON.stringify(open))}else if(persist==="url"){const url=new URL(window.location.href);url.searchParams.set("c-tree",JSON.stringify(open));window.history.replaceState(null,"",url.toString())}}catch(e){}}_flatten(nodes,pathPrefix,depth,expanded,out){(nodes||[]).forEach((node,i)=>{const p=pathPrefix+"."+i;const hasChildren=Array.isArray(node.children)&&node.children.length>0;const isExpanded=expanded.has(p);out.push({node,path:p,depth,hasChildren,expanded:isExpanded});if(hasChildren&&isExpanded){this._flatten(node.children,p,depth+1,expanded,out)}})}_renderNodeFlat(rootUl,f){const node=f.node;const depth=f.depth;const li=document.createElement("div");li.className="c-tree__node";li.setAttribute("role","treeitem");li.setAttribute("aria-level",String(depth));li.dataset.path=f.path;if(f.hasChildren){li.setAttribute("aria-expanded",String(f.expanded));const row=document.createElement("div");row.className="c-tree__row"+(node.active?" c-tree__row--active":"")+(node.dir?" c-tree__row--dir":"");row.style.paddingInlineStart=((depth-1)*1)+"rem";const toggle=document.createElement("button");toggle.className="c-tree__toggle";toggle.setAttribute("type","button");toggle.setAttribute("aria-expanded",String(f.expanded));toggle.setAttribute("aria-label","Toggle");toggle.innerHTML='<svg aria-hidden="true"><use href="#i-chevron-right" /></svg>';row.appendChild(toggle);const span=document.createElement("span");span.textContent=node.label;row.appendChild(span);li.appendChild(row)}else{const leaf=document.createElement("div");leaf.className="c-tree__leaf"+(node.active?" c-tree__row--active":"")+(node.dir?" c-tree__row--dir":"");leaf.style.paddingInlineStart=(depth*1)+"rem";if(this.hasAttribute("selectable")){const cb=document.createElement("input");cb.type="checkbox";cb.className="c-tree__select";cb.setAttribute("aria-label","Select "+(node.label||node));const label=String(node.label||node).trim().slice(0,120);if(this._selectedTree&&this._selectedTree.has(label))cb.checked=true;leaf.insertBefore(cb,leaf.firstChild)}leaf.appendChild(document.createTextNode(node.label||node));li.appendChild(leaf)}return li}_renderWindow(rootUl,scrollTop){if(!this._treeData)return;const ih=this._itemHeight();const expanded=this._expanded||(this._expanded=new Set());const flat=[];this._flatten(this._treeData,"",1,expanded,flat);const total=flat.length;const viewportSize=rootUl.clientHeight||320;const visibleCount=Math.ceil(viewportSize/ih)+6;let start=Math.floor((scrollTop||0)/ih);if(start<0)start=0;if(start>Math.max(0,total-visibleCount))start=Math.max(0,total-visibleCount);const end=Math.min(total,start+visibleCount);const topSize=start*ih;const bottomSize=Math.max(0,(total-end)*ih);rootUl.innerHTML="";const top=document.createElement("div");top.className="c-tree__spacer c-tree__spacer--top";top.style.height=topSize+"px";rootUl.appendChild(top);for(let i=start;i<end;i++){rootUl.appendChild(this._renderNodeFlat(rootUl,flat[i]))}const bottom=document.createElement("div");bottom.className="c-tree__spacer c-tree__spacer--bottom";bottom.style.height=bottomSize+"px";rootUl.appendChild(bottom)}render(){this.classList.add("c-tree");const authored=Array.from(this.children).filter((n)=>!n.classList||!n.classList.contains("c-tree"));wireStates(this);loadRemote(this,"items");if(renderStates(this,"tree"))return;const items=remoteData(this,"items");if(items&&!authored.length){try{const parsed=JSON.parse(items);const rootUl=this.ensure("div.c-tree",()=>{const el=document.createElement("div");el.className="c-tree";el.setAttribute("role","tree");return el});rootUl.innerHTML="";rootUl.className="c-tree";rootUl.setAttribute("role","tree");const virtual=this.hasAttribute("virtual");if(virtual){this._treeData=parsed;this._expanded=this._expanded||new Set();this._treeRoot=rootUl;this._restoreExpanded();rootUl.style.maxHeight=rootUl.style.maxHeight||"24rem";rootUl.style.overflow="auto";const scrollTop=this._treeScrollTop||0;this._renderWindow(rootUl,scrollTop);try{rootUl.scrollTop=scrollTop}catch(e){}}else{this._treeData=null;const render=(nodes,parent,depth)=>{const ul=parent?document.createElement("div"):rootUl;if(parent){ul.className="c-tree__children";ul.setAttribute("role","group");if(supportsUntilFound())ul.setAttribute("hidden","until-found");else ul.setAttribute("hidden","")}nodes.forEach((node)=>{const li=document.createElement("div");li.className="c-tree__node";li.setAttribute("role","treeitem");li.setAttribute("aria-level",String(depth));if(node.children){li.setAttribute("aria-expanded","false");const row=document.createElement("div");row.className="c-tree__row"+(node.active?" c-tree__row--active":"")+(node.dir?" c-tree__row--dir":"");if(node.indent){const ind=document.createElement("span");ind.className="c-tree__indent";ind.style.inlineSize=(node.indent*1)+"rem";row.appendChild(ind)}const toggle=document.createElement("button");toggle.className="c-tree__toggle";toggle.setAttribute("type","button");toggle.setAttribute("aria-expanded","false");toggle.setAttribute("aria-label","Toggle");toggle.innerHTML='<svg aria-hidden="true"><use href="#i-chevron-right" /></svg>';row.appendChild(toggle);const span=document.createElement("span");span.textContent=node.label;row.appendChild(span);li.appendChild(row);render(node.children,li,depth+1)}else{const leaf=document.createElement("div");leaf.className="c-tree__leaf"+(node.active?" c-tree__row--active":"")+(node.dir?" c-tree__row--dir":"");if(node.indent){const ind=document.createElement("span");ind.className="c-tree__indent";ind.style.inlineSize=(node.indent*1)+"rem";leaf.appendChild(ind)}if(this.hasAttribute("selectable")){const cb=document.createElement("input");cb.type="checkbox";cb.className="c-tree__select";cb.setAttribute("aria-label","Select "+(node.label||node));leaf.insertBefore(cb,leaf.firstChild)}leaf.appendChild(document.createTextNode(node.label||node));li.appendChild(leaf)}ul.appendChild(li)});if(parent)parent.appendChild(ul)};render(parsed,null,1)}this.classList.remove("c-tree");rootUl.classList.add("c-tree");if(rootUl.parentNode!==this)this.appendChild(rootUl)}catch(e){warnBadJson(this,"attribute",e)}}else if(!items&&!authored.length){renderEmpty(this,"tree")}}enhance(){if(!this._wiredTreeToggle){this._wiredTreeToggle=true;this.addEventListener("click",(e)=>{const toggle=e.target&&e.target.closest?e.target.closest(".c-tree__toggle"):null;if(!toggle||!this.contains(toggle))return;e.stopPropagation();const nodeEl=toggle.closest(".c-tree__node");const path=nodeEl&&nodeEl.dataset?nodeEl.dataset.path:null;const expanded=toggle.getAttribute("aria-expanded")==="true";if(path&&this._expanded){if(expanded)this._expanded.delete(path);else this._expanded.add(path)}toggle.setAttribute("aria-expanded",String(!expanded));const row=toggle.closest(".c-tree__row");if(row)row.setAttribute("aria-expanded",String(!expanded));this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{path,expanded:!expanded}}));if(this.hasAttribute("virtual")&&this._treeRoot){const s=this._treeRoot;this._treeScrollTop=s.scrollTop||0;this._renderWindow(s,this._treeScrollTop);try{s.scrollTop=this._treeScrollTop}catch(err){}this._persistExpanded()}})}if(this.hasAttribute("virtual")&&!this._wiredTreeScroll){this._wiredTreeScroll=true;const attach=()=>{const s=this.querySelector(".c-tree");if(!s||s._treeScrollWired)return;s._treeScrollWired=true;let raf=0;const onScroll=()=>{if(raf)return;raf=requestAnimationFrame(()=>{raf=0;this._treeScrollTop=s.scrollTop||0;this._renderWindow(s,this._treeScrollTop);try{s.scrollTop=this._treeScrollTop}catch(err){}})};s.addEventListener("scroll",onScroll,{passive:true});onDispose(this,()=>{s.removeEventListener("scroll",onScroll);if(raf)cancelAnimationFrame(raf)})};attach();if(!this.querySelector(".c-tree")){const mo=new MutationObserver(()=>{if(this.querySelector(".c-tree")){attach();mo.disconnect()}});mo.observe(this,{childList:true,subtree:true});onDispose(this,()=>mo.disconnect())}}if(this.hasAttribute("virtual")&&!this._wiredTreeDragScroll){this._wiredTreeDragScroll=true;let dragScrollRaf=0;let dragScrollDir=0;const tick=()=>{if(!dragScrollDir){dragScrollRaf=0;return}const s=this._treeRoot;if(s){s.scrollTop+=dragScrollDir*8;this._treeScrollTop=s.scrollTop;this._renderWindow(s,this._treeScrollTop)}dragScrollRaf=requestAnimationFrame(tick)};this.addEventListener("dragover",(e)=>{const s=this._treeRoot;if(!s)return;const rect=s.getBoundingClientRect();const edge=40;if(e.clientY<rect.top+edge)dragScrollDir=-1;else if(e.clientY>rect.bottom-edge)dragScrollDir=1;else dragScrollDir=0;if(dragScrollDir&&!dragScrollRaf)dragScrollRaf=requestAnimationFrame(tick)});const stop=()=>{dragScrollDir=0;if(dragScrollRaf){cancelAnimationFrame(dragScrollRaf);dragScrollRaf=0}};this.addEventListener("dragend",stop);this.addEventListener("drop",stop)}wireTree(this)}}define("contour-tree",ContourTree);class ContourCodeTabs extends ContourBase{static get observed(){return["tabs","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist"]}static get properties(){return{tabs:{attribute:"tabs"},src:{attribute:"src"}}}render(){this.classList.add("c-code-tabs");wireStates(this);loadRemote(this,"tabs");if(renderStates(this,"code-tabs"))return;const tabs=remoteData(this,"tabs");const list=this.querySelector(".c-code-tabs__list");const authored=list?Array.from(list.children).filter((n)=>n.getAttribute&&n.getAttribute("role")==="tab"):[];if(tabs&&!authored.length){try{const parsed=JSON.parse(tabs);const l=this.ensure(".c-code-tabs__list",()=>{const el=document.createElement("div");el.className="c-code-tabs__list";el.setAttribute("role","tablist");return el});l.setAttribute("role","tablist");const _prevCodeTabs=Array.from(l.querySelectorAll("[role='tab']"));const _prevCodeSel=_prevCodeTabs.findIndex((t)=>t.getAttribute("aria-selected")==="true");const _keepCodeIdx=_prevCodeSel>=0?_prevCodeSel:0;l.innerHTML="";Array.from(this.querySelectorAll(".c-code-tabs__panel")).forEach((n)=>n.remove());parsed.forEach((t,i)=>{const label=typeof t==="string"?t:(t.label||t.title||"");const panelId=contourId("c-code-tabs-panel");const btn=document.createElement("button");btn.className="c-code-tabs__tab";btn.setAttribute("role","tab");btn.setAttribute("aria-selected",String(i===_keepCodeIdx));btn.setAttribute("aria-controls",panelId);btn.tabIndex=i===_keepCodeIdx?0:-1;btn.textContent=label;l.appendChild(btn);const panel=document.createElement("div");panel.className="c-code-tabs__panel";panel.id=panelId;panel.setAttribute("role","tabpanel");if(typeof t==="object"&&t!==null&&t.content!==undefined){panel.textContent=String(t.content)}if(i!==_keepCodeIdx)panel.hidden=true;this.appendChild(panel)});if(l.parentNode!==this)this.prepend(l)}catch(e){warnBadJson(this,"attribute",e)}}else if(!tabs&&list){list.remove();renderEmpty(this,"code-tabs")}else if(!tabs&&!list){renderEmpty(this,"code-tabs")}}enhance(){wireTabs(this)}}define("contour-code-tabs",ContourCodeTabs);class ContourBreadcrumb extends ContourBase{static get observed(){return["items","separator","max","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},separator:{attribute:"separator"},max:{attribute:"max",type:Number},src:{attribute:"src"}}};render(){this.classList.add("c-breadcrumb");if(!this.hasAttribute("role"))this.setAttribute("role","navigation");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Breadcrumb");wireStates(this);loadRemote(this,"items");if(renderStates(this,"breadcrumb"))return;const items=remoteData(this,"items");const nav=this.querySelector("nav");const ol=nav?nav.querySelector("ol"):null;const authored=ol?Array.from(ol.children).filter((n)=>n.tagName==="LI"):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const n=this.ensure("nav",()=>{const el=document.createElement("nav");el.setAttribute("aria-label","Breadcrumb");return el});n.setAttribute("aria-label","Breadcrumb");if(!n.id)n.id=contourId("contour-breadcrumb-list");n.innerHTML="";const sep=this.getAttribute("separator")||"/";const max=this._overflowExpanded?null:this.max;const shown=Number.isFinite(max)&&max>1&&parsed.length>max?parsed.slice(-max):parsed;if(Number.isFinite(max)&&max>1&&parsed.length>max){const btn=document.createElement("button");btn.type="button";btn.className="c-breadcrumb__overflow";btn.setAttribute("aria-label",`Show ${parsed.length - shown.length + 1} more items`);btn.setAttribute("aria-expanded","false");btn.setAttribute("aria-controls",n.id);btn.textContent="…";btn.addEventListener("click",()=>{this._overflowExpanded=true;this.requestRender();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{expanded:true}}))});n.appendChild(btn)}shown.forEach((item,i)=>{if(i<shown.length-1){const a=document.createElement("a");a.href=safeHref(item.href||"#");a.textContent=item.label||item;n.appendChild(a);const s=document.createElement("span");s.className="c-breadcrumb__sep";s.setAttribute("aria-hidden","true");s.textContent=sep;n.appendChild(s)}else{const span=document.createElement("span");span.textContent=item.label||item;span.setAttribute("aria-current","page");n.appendChild(span)}})}catch(e){warnBadJson(this,"attribute",e)}}else if(!items&&nav){nav.remove()}else if(!items&&!nav){renderEmpty(this,"breadcrumb")}}}define("contour-breadcrumb",ContourBreadcrumb);class ContourPagination extends ContourBase{static get observed(){return["pages","current","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist"]}static get properties(){return{pages:{attribute:"pages"},current:{attribute:"current"},src:{attribute:"src"}}}render(){this.classList.add("c-pagination");if(!this.hasAttribute("role"))this.setAttribute("role","navigation");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Pagination");wireStates(this);loadRemote(this,"pages");if(renderStates(this,"pagination"))return;const pages=remoteData(this,"pages");Array.from(this.querySelectorAll(".c-pagination__link")).forEach((n)=>n.remove());let currentAttr=this.getAttribute("current")||"1";if(this.getAttribute("persist")==="storage"&&this.id){try{const stored=localStorage.getItem("contour-pagination:"+this.id);if(stored!==null)currentAttr=stored}catch(e){}}else if(this.getAttribute("persist")==="url"){try{const v=new URLSearchParams(window.location.search).get("c-pagination");if(v!==null)currentAttr=v}catch(e){}}const current=parseInt(currentAttr,"10")||1;if(pages){let count=parseInt(pages,10);if(!Number.isFinite(count)||count<1){try{const p=JSON.parse(pages);if(Array.isArray(p))count=p.length}catch(e){}}const prev=document.createElement("button");prev.type="button";prev.className="c-pagination__link c-pagination__prev";prev.setAttribute("data-action","prev");prev.textContent="‹";prev.setAttribute("aria-label",labelText(this,"prev","Previous page"));this.appendChild(prev);for(let i=1;i<=count;i++){const btn=document.createElement("button");btn.type="button";btn.className="c-pagination__link";btn.textContent=String(i);if(i===current){btn.setAttribute("aria-current","page")}this.appendChild(btn)}const next=document.createElement("button");next.type="button";next.className="c-pagination__link c-pagination__next";next.setAttribute("data-action","next");next.textContent="›";next.setAttribute("aria-label",labelText(this,"next","Next page"));this.appendChild(next)}else{renderEmpty(this,"pagination")}}enhance(){wirePagination(this)}}define("contour-pagination",ContourPagination);class ContourPagerFull extends ContourBase{static get observed(){return["prev","next"]}static get properties(){return{prev:{attribute:"prev"},next:{attribute:"next"}}}render(){this.classList.add("c-pager");Array.from(this.querySelectorAll(".c-pager__link")).forEach((n)=>n.remove());const prev=this.getAttribute("prev");const next=this.getAttribute("next");if(prev){const a=document.createElement("a");a.className="c-pager__link";a.href=safeHref(prev.split("|")[1]||"#");const dir=document.createElement("span");dir.className="c-pager__dir";dir.textContent="← Previous";a.appendChild(dir);const title=document.createElement("span");title.className="c-pager__title";title.textContent=prev.split("|")[0];a.appendChild(title);this.appendChild(a)}if(next){const a=document.createElement("a");a.className="c-pager__link c-pager__link--next";a.href=safeHref(next.split("|")[1]||"#");const dir=document.createElement("span");dir.className="c-pager__dir";dir.textContent=labelText(this,"next","Next")+" →";a.appendChild(dir);const title=document.createElement("span");title.className="c-pager__title";title.textContent=next.split("|")[0];a.appendChild(title);this.appendChild(a)}}}define("contour-pager",ContourPagerFull);class ContourTocFull extends ContourBase{static get observed(){return["title","items","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{title:{attribute:"title"},items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-toc");this.setAttribute("role","group");wireStates(this);loadRemote(this,"items");if(renderStates(this,"toc"))return;const items=remoteData(this,"items");const title=this.getAttribute("title")||"On this page";const titleEl=this.ensure(".c-toc__title",()=>{const el=document.createElement("div");el.className="c-toc__title";return el});titleEl.textContent=title;const list=this.querySelector(".c-toc__list");const authored=list?Array.from(list.children).filter((n)=>n.tagName==="A"):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const l=this.ensure(".c-toc__list",()=>{const el=document.createElement("nav");el.className="c-toc__list";return el});l.className="c-toc__list";l.setAttribute("aria-label",title);l.innerHTML="";parsed.forEach((item,i)=>{const a=document.createElement("a");a.className="c-toc__link"+(item.sub?" c-toc__link--sub":"");a.href=safeHref(item.href||"#");a.textContent=item.label||item;a.tabIndex=i===0?0:-1;if(item.current)a.setAttribute("aria-current","true");l.appendChild(a)})}catch(e){warnBadJson(this,"attribute",e)}}else if(!items&&list){list.remove();renderEmpty(this,"toc")}else if(!items&&!list){renderEmpty(this,"toc")}}enhance(){if(this._wiredTocSpy)return;const links=()=>Array.from(this.querySelectorAll(".c-toc__link"));const pairs=()=>links().map((a)=>{const href=a.getAttribute("href")||"";if(!href.startsWith("#")||href.length<2)return null;const el=document.getElementById(href.slice(1));return el?{a,el}:null}).filter(Boolean);if(!pairs().length)return;this._wiredTocSpy=true;const readingLine=()=>{const raw=parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--header-height"));return(Number.isFinite(raw)?raw:0)+Math.min(120,window.innerHeight*0.2)};const update=()=>{const all=pairs();if(!all.length)return;const line=readingLine();let current=all[0];for(const p of all){if(p.el.getBoundingClientRect().top<=line)current=p}const scrollable=document.documentElement.scrollHeight>window.innerHeight+2;if(scrollable&&window.innerHeight+window.scrollY>=document.documentElement.scrollHeight-2){current=all[all.length-1]}const id=current.el.id;links().forEach((a)=>{const isCurrent=a.getAttribute("href")==="#"+id;if(isCurrent){if(a.getAttribute("aria-current")!=="true")a.setAttribute("aria-current","true")}else if(a.hasAttribute("aria-current")){a.removeAttribute("aria-current")}})};let queued=0;const schedule=()=>{if(queued)return;queued=requestAnimationFrame(()=>{queued=0;update()})};window.addEventListener("scroll",schedule,{passive:true});window.addEventListener("resize",schedule);window.addEventListener("hashchange",schedule);update();onDispose(this,()=>{window.removeEventListener("scroll",schedule);window.removeEventListener("resize",schedule);window.removeEventListener("hashchange",schedule);if(queued)cancelAnimationFrame(queued)});if(!this._wiredTocScroll){this._wiredTocScroll=true;this.addEventListener("click",(e)=>{const a=e.target&&e.target.closest?e.target.closest(".c-toc__link"):null;if(!a||!this.contains(a))return;const href=a.getAttribute("href")||"";if(!href.startsWith("#")||href.length<2)return;const target=document.getElementById(href.slice(1));if(!target)return;e.preventDefault();try{target.scrollIntoView({behavior:"smooth",block:"start"})}catch(err){target.scrollIntoView()}this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{href}}))});this.addEventListener("keydown",(e)=>{const links=Array.from(this.querySelectorAll(".c-toc__link"));if(!links.length)return;navKey(e,links,{wrap:true,homeEnd:true,onNavigate:(i)=>{links.forEach((a,j)=>a.tabIndex=j===i?0:-1)},onKey:(k)=>{if(k==="Enter"){const a=document.activeElement;if(a){e.preventDefault();a.click()}}}})})}}}define("contour-toc",ContourTocFull);class ContourFilterBar extends ContourBase{static get observed(){return["label","divider","items","input","placeholder","mode","modes","scope","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","count","clearable"]}static get properties(){return{label:{attribute:"label"},divider:{attribute:"divider"},items:{attribute:"items"},src:{attribute:"src"},count:{attribute:"count"},clearable:{attribute:"clearable"},scope:{attribute:"scope"}}}render(){this.classList.add("c-filter-bar");wireStates(this);loadRemote(this,"items");if(renderStates(this,"filter-bar"))return;const label=this.getAttribute("label");if(label){const l=this.ensure(".c-filter-bar__label",()=>{const el=document.createElement("span");el.className="c-filter-bar__label";return el});l.textContent=label}else{const l=this.querySelector(".c-filter-bar__label");if(l)l.remove()}if(this.hasAttribute("divider")){this.ensure(".c-filter-bar__divider",()=>{const el=document.createElement("span");el.className="c-filter-bar__divider";return el})}else{const d=this.querySelector(".c-filter-bar__divider");if(d)d.remove()}if(this.hasAttribute("input")||this.hasAttribute("placeholder")){let inp=this.querySelector(".c-filter-bar__input");if(!inp){inp=document.createElement("input");inp.type="search";inp.className="c-filter-bar__input";this.appendChild(inp)}const ph=this.getAttribute("placeholder");if(ph)inp.setAttribute("placeholder",ph)}else{const inp=this.querySelector(".c-filter-bar__input");if(inp)inp.remove()}const modesAttr=this.getAttribute("modes");let modes=null;if(modesAttr){try{modes=JSON.parse(modesAttr)}catch(e){modes=modesAttr.split(",").map((s)=>s.trim())}}if(modes||this.hasAttribute("mode")){let bar=this.querySelector(".c-filter-bar__modes");if(!bar){bar=document.createElement("div");bar.className="c-filter-bar__modes";bar.setAttribute("role","toolbar");bar.setAttribute("aria-label",label||"Filter modes");this.appendChild(bar)}bar.innerHTML="";const current=this.getAttribute("mode");const list=Array.isArray(modes)?modes:["draw","erase","select"];list.forEach((m)=>{const name=typeof m==="string"?m:(m.label||m.value||m);const val=typeof m==="string"?m:(m.value||m.label||m);const btn=document.createElement("button");btn.type="button";btn.className="c-filter-bar__mode";btn.textContent=name;btn.dataset.mode=val;if(current&&current===val)btn.setAttribute("aria-pressed","true");bar.appendChild(btn)})}else{const bar=this.querySelector(".c-filter-bar__modes");if(bar)bar.remove()}const scope=this.getAttribute("scope");if(scope==="viewport"||scope==="global"){Array.from(this.querySelectorAll(".c-filter-bar__scope")).forEach((n)=>n.remove());const bar=document.createElement("div");bar.className="c-filter-bar__modes c-filter-bar__scope";bar.setAttribute("role","toolbar");bar.setAttribute("aria-label","Data scope");["viewport","global"].forEach((s)=>{const btn=document.createElement("button");btn.type="button";btn.className="c-filter-bar__mode c-filter-bar__scope-btn";btn.textContent=s==="viewport"?"Viewport":"Global";btn.dataset.scope=s;if(scope===s)btn.setAttribute("aria-pressed","true");bar.appendChild(btn)});this.appendChild(bar)}else{const bar=this.querySelector(".c-filter-bar__scope");if(bar)bar.remove()}Array.from(this.querySelectorAll(".c-filter-pill")).forEach((n)=>n.remove());const items=remoteData(this,"items");const authoredPills=Array.from(this.querySelectorAll(":scope > .c-filter-pill"));let parsed=null;if(authoredPills.length){parsed=authoredPills.map((p)=>p.textContent.trim());authoredPills.forEach((p)=>p.remove())}else if(items){try{parsed=JSON.parse(items)}catch(e){parsed=null}}if(Array.isArray(parsed)){parsed.forEach((it)=>{const pill=document.createElement("span");pill.className="c-filter-pill";const txt=typeof it==="string"?it:(it.label||it.value||"");pill.textContent=txt;if(typeof it==="object"&&it!==null&&it.removable!==false){const btn=document.createElement("button");btn.className="c-filter-pill__remove";btn.type="button";btn.setAttribute("aria-label","Remove "+txt);btn.textContent="×";pill.appendChild(btn)}this.appendChild(pill)})}Array.from(this.querySelectorAll(".c-filter-bar__clear-all")).forEach((n)=>n.remove());if(this.hasAttribute("clearable")){const btn=document.createElement("button");btn.type="button";btn.className="c-btn c-btn--ghost c-btn--sm c-filter-bar__clear-all";const count=this.getAttribute("count");btn.textContent=count?("Clear all ("+count+")"):"Clear all";this.appendChild(btn)}if(!parsed&&!label)renderEmpty(this,"filter-bar")}enhance(){wireRemovable(this);if(this._wiredFilterBar)return;this._wiredFilterBar=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-filter-bar__mode"):null;if(!btn||!this.contains(btn))return;const mode=btn.dataset.mode||btn.textContent.trim();Array.from(this.querySelectorAll(".c-filter-bar__mode")).forEach((b)=>b.setAttribute("aria-pressed",String(b===btn)));this.dispatchEvent(new CustomEvent("contour:mode-change",{bubbles:true,composed:true,detail:{mode}}));if(btn.classList.contains("c-filter-bar__scope-btn")){const scope=btn.dataset.scope||null;if(scope)this.setAttribute("scope",scope);this.dispatchEvent(new CustomEvent("contour:scope-change",{bubbles:true,composed:true,detail:{scope}}))}});this.addEventListener("keydown",(e)=>{const modes=Array.from(this.querySelectorAll(".c-filter-bar__mode"));navKey(e,modes,{wrap:false,onKey:()=>{document.activeElement.click()}})});const inp=this.querySelector(".c-filter-bar__input");if(inp&&!inp._wiredFilterInput){inp._wiredFilterInput=true;inp.addEventListener("input",()=>{this.dispatchEvent(new CustomEvent("contour:input",{bubbles:true,composed:true,detail:{value:inp.value}}))});inp.addEventListener("change",()=>{this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:inp.value}}))})}if(!this._wiredClearAll){this._wiredClearAll=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-filter-bar__clear-all"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:clear-all",{bubbles:true,composed:true,detail:{}}))})}}}define("contour-filter-bar",ContourFilterBar);class ContourCommand extends ContourBase{static get observed(){return["placeholder","items","recent","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{placeholder:{attribute:"placeholder"},items:{attribute:"items"},recent:{attribute:"recent"},empty:{attribute:"empty"},src:{attribute:"src"}}}render(){this.classList.add("c-command");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Command palette");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");wireStates(this);loadRemote(this,"items");if(renderStates(this,"command"))return;const placeholder=this.getAttribute("placeholder")||"Search…";const input=this.ensure(".c-command__input",()=>{const el=document.createElement("input");el.className="c-command__input";el.type="text";return el});input.type="text";input.placeholder=placeholder;input.setAttribute("aria-label","Command");input.setAttribute("role","combobox");input.setAttribute("aria-autocomplete","list");input.setAttribute("aria-expanded","true");const list=this.querySelector(".c-command__list");if(list&&!list.id)list.id=contourId("c-command-list");if(list&&list.id)input.setAttribute("aria-controls",list.id);const items=remoteData(this,"items");const list2=this.querySelector(".c-command__list");const authored=list2?Array.from(list2.children).filter((n)=>n.classList&&n.classList.contains("c-command__item")||n.classList&&n.classList.contains("c-command__group")):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const l=this.ensure(".c-command__list",()=>{const el=document.createElement("div");el.className="c-command__list";el.setAttribute("role","listbox");el.id=contourId("c-command-list");return el});l.setAttribute("role","listbox");l.innerHTML="";const recentRaw=this.getAttribute("recent");if(recentRaw){try{const recentParsed=JSON.parse(recentRaw);const group=document.createElement("div");group.className="c-command__group";const gt=document.createElement("div");gt.className="c-command__group-title";gt.textContent=labelText(this,"recent","Recent");group.appendChild(gt);recentParsed.forEach((it)=>{const item=document.createElement("div");item.className="c-command__item";item.setAttribute("role","option");const body=document.createElement("div");body.className="c-command__item-body";const t=document.createElement("div");t.className="c-command__item-title";t.textContent=typeof it==="string"?it:(it.title||it.label||"");body.appendChild(t);item.appendChild(body);group.appendChild(item)});l.appendChild(group)}catch(e){}}parsed.forEach((it)=>{if(it.group){const group=document.createElement("div");group.className="c-command__group";const gt=document.createElement("div");gt.className="c-command__group-title";gt.textContent=it.group;group.appendChild(gt);const item=document.createElement("div");item.className="c-command__item";item.setAttribute("role","option");if(it.icon){const ic=document.createElement("span");ic.className="c-command__item-icon";ic.textContent=it.icon;item.appendChild(ic)}const body=document.createElement("div");body.className="c-command__item-body";if(it.title||it.label){const t=document.createElement("div");t.className="c-command__item-title";t.textContent=it.title||it.label;body.appendChild(t)}if(it.hint){const h=document.createElement("span");h.className="c-command__item-hint";h.textContent=it.hint;body.appendChild(h)}if(it.shortcut){const sc=document.createElement("kbd");sc.className="c-command__item-shortcut";sc.textContent=it.shortcut;item.appendChild(sc)}item.appendChild(body);group.appendChild(item);l.appendChild(group)}else{const item=document.createElement("div");item.className="c-command__item";item.setAttribute("role","option");if(it.icon){const ic=document.createElement("span");ic.className="c-command__item-icon";ic.textContent=it.icon;item.appendChild(ic)}const body=document.createElement("div");body.className="c-command__item-body";if(it.title||it.label){const t=document.createElement("div");t.className="c-command__item-title";t.textContent=it.title||it.label;body.appendChild(t)}if(it.hint){const h=document.createElement("span");h.className="c-command__item-hint";h.textContent=it.hint;body.appendChild(h)}if(it.shortcut){const sc=document.createElement("kbd");sc.className="c-command__item-shortcut";sc.textContent=it.shortcut;item.appendChild(sc)}item.appendChild(body);l.appendChild(item)}})}catch(e){warnBadJson(this,"attribute",e)}}else if(!items&&list){list.remove()}const empty=this.getAttribute("empty");if(empty){const e=this.ensure(".c-command__empty",()=>{const el=document.createElement("div");el.className="c-command__empty";return el});e.textContent=empty}else{const e=this.querySelector(".c-command__empty");if(e)e.remove()}const status=this.ensure(".c-command__status",()=>{const el=document.createElement("div");el.className="c-command__status";el.setAttribute("role","status");return el});status.textContent="";if(!items&&!list){renderEmpty(this,"command")}}enhance(){if(this._wiredCommand)return;this._wiredCommand=true;const input=()=>this.querySelector(".c-command__input");const items=()=>Array.from(this.querySelectorAll(".c-command__item"));let cursor=-1;const mark=()=>{items().forEach((it,i)=>{it.classList.toggle("c-command__item--active",i===cursor);it.setAttribute("aria-selected",String(i===cursor));if(i===cursor){if(!it.id)it.id="contour-command-option-"+i;const inp=input();if(inp)inp.setAttribute("aria-activedescendant",it.id)}});if(cursor<0){const inp=input();if(inp)inp.removeAttribute("aria-activedescendant")}};this.addEventListener("keydown",(e)=>{const inp=input();if(!inp||e.target!==inp)return;const its=items();if(!its.length)return;if(e.key==="ArrowDown"){e.preventDefault();cursor=Math.min(cursor+1,its.length-1);mark()}else if(e.key==="ArrowUp"){e.preventDefault();cursor=Math.max(cursor-1,0);mark()}else if(e.key==="Home"){e.preventDefault();cursor=0;mark()}else if(e.key==="End"){e.preventDefault();cursor=its.length-1;mark()}else if(e.key==="Enter"){e.preventDefault();if(cursor>=0&&its[cursor]){const item=its[cursor];const idx=items().indexOf(item);this.dispatchEvent(new CustomEvent("contour:select",{detail:{index:idx,label:item.textContent.trim()},bubbles:true,composed:true}))}}else if(e.key==="Escape"){if(typeof this.hidePopover==="function")this.hidePopover()}});this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-command__item"):null;if(item&&this.contains(item)){const idx=items().indexOf(item);this.dispatchEvent(new CustomEvent("contour:select",{detail:{index:idx,label:item.textContent.trim()},bubbles:true,composed:true}))}});this.addEventListener("input",(e)=>{const inp=input();if(!inp||e.target!==inp)return;const q=inp.value.trim().toLowerCase();const all=items();let visible=0;all.forEach((it)=>{const match=!q||(it.textContent||"").toLowerCase().includes(q);it.hidden=!match;if(match)visible+=1});this.querySelectorAll(".c-command__group").forEach((g)=>{const hasVisible=Array.from(g.querySelectorAll(".c-command__item")).some((it)=>!it.hidden);g.hidden=!hasVisible});cursor=-1;mark();const status=this.querySelector(".c-command__status");if(status)status.textContent=q?`${visible} of ${all.length}`:""})}}define("contour-command",ContourCommand);class ContourFooter extends ContourBase{static get observed(){return["brand","note","links","cols","heading"]}static get properties(){return{brand:{attribute:"brand"},note:{attribute:"note"},links:{attribute:"links"},cols:{attribute:"cols"}}}render(){this.classList.add("c-footer");if(!this.hasAttribute("role"))this.setAttribute("role","contentinfo");const brand=this.getAttribute("brand");if(brand){const b=this.ensure(".c-footer__brand",()=>{const el=document.createElement("div");el.className="c-footer__brand";return el});b.textContent=brand}else{const b=this.querySelector(".c-footer__brand");if(b)b.remove()}const note=this.getAttribute("note");if(note){const n=this.ensure(".c-footer__note",()=>{const el=document.createElement("p");el.className="c-footer__note";return el});n.textContent=note}else{const n=this.querySelector(".c-footer__note");if(n)n.remove()}const links=this.getAttribute("links");if(links){try{const parsed=JSON.parse(links);const wrap=this.ensure(".c-footer__links",()=>{const el=document.createElement("div");el.className="c-footer__links";return el});wrap.innerHTML="";parsed.forEach((l)=>{const a=document.createElement("a");a.href=safeHref(typeof l==="string"?"#":(l.href||"#"));a.textContent=typeof l==="string"?l:(l.label||l);wrap.appendChild(a)})}catch(e){warnBadJson(this,"attribute",e)}}else{const w=this.querySelector(".c-footer__links");if(w)w.remove()}const cols=this.getAttribute("cols");if(cols){try{const parsed=JSON.parse(cols);this.querySelectorAll(".c-footer__col").forEach((c)=>c.remove());parsed.forEach((col)=>{const c=document.createElement("div");c.className="c-footer__col";if(col.title){const h=document.createElement(headingTag(this,"h3"));h.textContent=col.title;c.appendChild(h)}(col.links||[]).forEach((l)=>{const a=document.createElement("a");a.href=safeHref(typeof l==="string"?"#":(l.href||"#"));a.textContent=typeof l==="string"?l:(l.label||l);c.appendChild(a)});this.appendChild(c)})}catch(e){warnBadJson(this,"attribute",e)}}else{this.querySelectorAll(".c-footer__col").forEach((c)=>c.remove())}}}define("contour-footer",ContourFooter);class ContourSchemeToggle extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-scheme-toggle");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Toggle color scheme")}enhance(){if(this._wiredScheme)return;this._wiredScheme=true;this.addEventListener("click",()=>{const root=document.documentElement;root.classList.add("is-theme-switching");const current=root.getAttribute("data-theme")||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");const next=current==="dark"?"light":"dark";root.setAttribute("data-theme",next);try{localStorage.setItem("contour-theme",next)}catch(e){}requestAnimationFrame(()=>requestAnimationFrame(()=>root.classList.remove("is-theme-switching")));this.dispatchEvent(new CustomEvent("contour:theme-change",{detail:{theme:next},bubbles:true,composed:true}))});this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.click()}});try{const stored=localStorage.getItem("contour-theme");if(stored)document.documentElement.setAttribute("data-theme",stored)}catch(e){}}}define("contour-scheme-toggle",ContourSchemeToggle);class ContourSidebar extends ContourBase{static get observed(){return["title","items","collapsed"]}static get properties(){return{title:{attribute:"title"},items:{attribute:"items"},collapsed:{attribute:"collapsed",type:Boolean}}}render(){this.classList.add("c-sidebar");if(!this.hasAttribute("role"))this.setAttribute("role","navigation");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("title")||"Sidebar");if(this.hasAttribute("collapsed"))this.classList.add("c-sidebar--collapsed");else this.classList.remove("c-sidebar--collapsed");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-sidebar__title",()=>{const el=document.createElement("div");el.className="c-sidebar__title";return el});t.textContent=title}else{const t=this.querySelector(".c-sidebar__title");if(t)t.remove()}const items=this.getAttribute("items");if(items){try{const parsed=JSON.parse(items);const nav=this.ensure("nav.c-sidebar__nav",()=>{const el=document.createElement("nav");el.className="c-sidebar__nav";return el});nav.innerHTML="";parsed.forEach((it,i)=>{const a=document.createElement("a");a.className="c-sidebar__link";a.href=safeHref((it&&it.href)||"#");a.textContent=(it&&(it.label||it))||"";a.tabIndex=i===0?0:-1;nav.appendChild(a)})}catch(e){warnBadJson(this,"attribute",e)}}}enhance(){if(this._wiredSidebar)return;this._wiredSidebar=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-sidebar__toggle"):null;if(!btn||!this.contains(btn))return;this.toggleAttribute("collapsed");this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{collapsed:this.hasAttribute("collapsed")}}))});this.addEventListener("keydown",(e)=>{const nav=this.querySelector("nav.c-sidebar__nav");if(!nav)return;const links=Array.from(nav.querySelectorAll(".c-sidebar__link"));if(!links.length)return;navKey(e,links,{wrap:true,homeEnd:true,onNavigate:(i)=>{links.forEach((l,j)=>l.tabIndex=j===i?0:-1)},onKey:(k)=>{if(k==="Enter"){const a=document.activeElement;if(a){e.preventDefault();a.click()}}}})})}}define("contour-sidebar",ContourSidebar);class ContourToolbar extends ContourBase{static get observed(){return["title","actions","overflow"]}static get properties(){return{title:{attribute:"title"},actions:{attribute:"actions"},overflow:{attribute:"overflow",type:Number}}}render(){this.classList.add("c-toolbar");const title=this.getAttribute("title");this.setAttribute("role","toolbar");if(title)this.setAttribute("aria-label",title);const actions=this.getAttribute("actions");if(actions){try{const parsed=JSON.parse(actions);const limit=this.overflow&&this.overflow>0?this.overflow:parsed.length;const visible=parsed.slice(0,limit);const excess=parsed.slice(limit);visible.forEach((a,i)=>{const btn=document.createElement("button");btn.className="c-toolbar__btn";btn.type="button";btn.tabIndex=i===0?0:-1;btn.textContent=typeof a==="string"?a:(a.label||a);this.appendChild(btn)});if(excess.length){const wrap=document.createElement("div");wrap.className="c-toolbar__overflow";const btn=document.createElement("button");btn.className="c-toolbar__btn c-toolbar__overflow-btn";btn.type="button";btn.setAttribute("aria-haspopup","menu");btn.setAttribute("aria-expanded","false");btn.textContent="…";wrap.appendChild(btn);const menu=document.createElement("div");menu.className="c-toolbar__overflow-menu";menu.setAttribute("role","menu");menu.setAttribute("hidden","");excess.forEach((a)=>{const mbtn=document.createElement("button");mbtn.className="c-toolbar__btn";mbtn.type="button";mbtn.setAttribute("role","menuitem");mbtn.textContent=typeof a==="string"?a:(a.label||a);menu.appendChild(mbtn)});wrap.appendChild(menu);this.appendChild(wrap)}}catch(e){warnBadJson(this,"attribute",e)}}}enhance(){if(this._wiredToolbar)return;this._wiredToolbar=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-toolbar__overflow-btn"):null;if(btn&&this.contains(btn)){const menu=btn.parentElement&&btn.parentElement.querySelector(".c-toolbar__overflow-menu");if(menu){const open=menu.hasAttribute("hidden");if(open)menu.removeAttribute("hidden");else menu.setAttribute("hidden","");btn.setAttribute("aria-expanded",String(open))}return}const actionBtn=e.target&&e.target.closest?e.target.closest(".c-toolbar__btn"):null;if(actionBtn&&this.contains(actionBtn)){this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true,detail:{label:actionBtn.textContent.trim()}}))}});this.addEventListener("keydown",(e)=>{const btns=Array.from(this.querySelectorAll(":scope > .c-toolbar__btn:not(.c-toolbar__overflow-btn)"));if(!btns.length)return;navKey(e,btns,{wrap:true,homeEnd:true,onNavigate:(i)=>{btns.forEach((b,j)=>b.tabIndex=j===i?0:-1)},onKey:(k)=>{if(k==="Enter"||k===" "){const b=document.activeElement;if(b){e.preventDefault();b.click()}}}})})}}define("contour-toolbar",ContourToolbar);class ContourSpatialFilter extends ContourBase{static get observed(){return["modes","mode","active","bounds","operator","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{modes:{attribute:"modes"},mode:{attribute:"mode"},active:{attribute:"active"},bounds:{attribute:"bounds"},operator:{attribute:"operator"},src:{attribute:"src"}}}render(){this.classList.add("c-spatial-filter");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Spatial filter");wireStates(this);loadRemote(this,[]);if(renderStates(this,"spatial-filter"))return;const modesAttr=this.getAttribute("modes");let modes=null;if(modesAttr){try{modes=JSON.parse(modesAttr)}catch(e){modes=modesAttr.split(",").map((s)=>s.trim())}}const list=Array.isArray(modes)?modes:["rect","circle","polygon","clear"];let bar=this.querySelector(".c-spatial-filter__modes");if(!bar){bar=document.createElement("div");bar.className="c-spatial-filter__modes";bar.setAttribute("role","toolbar");this.appendChild(bar)}bar.innerHTML="";const current=this.getAttribute("mode");list.forEach((m)=>{const name=typeof m==="string"?m:(m.label||m.value||m);const val=typeof m==="string"?m:(m.value||m.label||m);const btn=document.createElement("button");btn.type="button";btn.className="c-spatial-filter__mode c-btn c-btn--ghost c-btn--sm";btn.textContent=name;btn.dataset.mode=val;if(current&&current===val)btn.setAttribute("aria-pressed","true");bar.appendChild(btn)});let operator=this.querySelector(".c-spatial-filter__operator");if(!operator){operator=document.createElement("div");operator.className="c-spatial-filter__operator";this.appendChild(operator)}const ops=["intersects","contains","within","disjoint"];const currentOp=this.getAttribute("operator")||"intersects";operator.innerHTML="";const opLabel=document.createElement("span");opLabel.textContent=labelText(this,"operator","Operator")+":";operator.appendChild(opLabel);const opSelect=document.createElement("select");opSelect.className="c-spatial-filter__operator-select";ops.forEach((op)=>{const o=document.createElement("option");o.value=op;o.textContent=op;if(op===currentOp)o.setAttribute("selected","");opSelect.appendChild(o)});operator.appendChild(opSelect);let readout=this.querySelector(".c-spatial-filter__readout");if(!readout){readout=document.createElement("div");readout.className="c-spatial-filter__readout";this.appendChild(readout)}const bounds=this.getAttribute("bounds");readout.textContent=bounds||"—";let clearAll=this.querySelector(".c-spatial-filter__clear-all");if(!clearAll){clearAll=document.createElement("button");clearAll.type="button";clearAll.className="c-spatial-filter__clear-all";this.appendChild(clearAll)}applyLabel(clearAll,this,"clear-all","Clear all");if(this.hasAttribute("active")){this.classList.add("c-spatial-filter--active")}else{this.classList.remove("c-spatial-filter--active")}}enhance(){if(this._wiredSpatialFilter)return;this._wiredSpatialFilter=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest("button"):null;if(!btn||!this.contains(btn))return;if(btn.classList.contains("c-spatial-filter__clear-all")){this.classList.remove("c-spatial-filter--active");Array.from(this.querySelectorAll(".c-spatial-filter__mode")).forEach((b)=>b.setAttribute("aria-pressed","false"));this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:true,composed:true,detail:{}}));this.dispatchEvent(new CustomEvent("contour:spatial-filter",{bubbles:true,composed:true,detail:{action:"clear-all"}}));return}const modeBtn=btn.closest(".c-spatial-filter__mode");if(!modeBtn)return;const mode=modeBtn.dataset.mode||modeBtn.textContent.trim();if(mode==="clear"){this.classList.remove("c-spatial-filter--active");Array.from(this.querySelectorAll(".c-spatial-filter__mode")).forEach((b)=>b.setAttribute("aria-pressed","false"));this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:true,composed:true,detail:{}}));return}this.classList.add("c-spatial-filter--active");Array.from(this.querySelectorAll(".c-spatial-filter__mode")).forEach((b)=>b.setAttribute("aria-pressed",String(b===modeBtn)));this.dispatchEvent(new CustomEvent("contour:draw-start",{bubbles:true,composed:true,detail:{mode}}));this.dispatchEvent(new CustomEvent("contour:spatial-filter",{bubbles:true,composed:true,detail:{action:"draw-start",mode}}))});this.addEventListener("change",(e)=>{const select=e.target;if(select&&select.classList.contains("c-spatial-filter__operator-select")){this.setAttribute("operator",select.value);this.dispatchEvent(new CustomEvent("contour:spatial-filter",{bubbles:true,composed:true,detail:{action:"operator",operator:select.value}}))}});this.addEventListener("keydown",(e)=>{const modes=Array.from(this.querySelectorAll(".c-spatial-filter__mode"));navKey(e,modes,{wrap:false,onKey:()=>{document.activeElement.click()}})})}}define("contour-spatial-filter",ContourSpatialFilter);class ContourAvatar extends ContourBase{static get observed(){return["name","size","variant","src","status"]}static get properties(){return{name:{attribute:"name"},size:{attribute:"size"},variant:{attribute:"variant"},src:{attribute:"src"},status:{attribute:"status"}}}render(){this.classList.add("c-avatar");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-avatar--"))this.classList.remove(c)});const name=this.getAttribute("name");const size=this.getAttribute("size");if(size)this.classList.add("c-avatar--"+size);const variant=this.getAttribute("variant");if(variant)this.classList.add("c-avatar--"+variant);const oldImg=this.querySelector("img.c-avatar__img");if(oldImg)oldImg.remove();const oldDot=this.querySelector(".c-avatar__status");if(oldDot)oldDot.remove();const src=this.getAttribute("src");if(src){this.textContent="";const img=document.createElement("img");img.className="c-avatar__img";img.src=src;img.alt=name||"";img.loading="lazy";img.decoding="async";this.appendChild(img)}else if(name){const initials=name.split(" ").map((w)=>w[0]).join("").toUpperCase().slice(0,2);if(!this.querySelector("img.c-avatar__img")){}this.textContent=initials}const status=this.getAttribute("status");if(status){const dot=document.createElement("span");dot.className="c-avatar__status c-avatar__status--"+status;dot.setAttribute("aria-hidden","true");this.appendChild(dot)}}}define("contour-avatar",ContourAvatar);class ContourBadgeFull extends ContourBase{static get observed(){return["variant","label","size","removable"]}static get properties(){return{variant:{attribute:"variant"},label:{attribute:"label"},size:{attribute:"size"},removable:{attribute:"removable",type:Boolean}}}render(){this.classList.add("c-badge");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-badge--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-badge--"+variant);const size=this.getAttribute("size");if(size)this.classList.add("c-badge--"+size);const label=this.getAttribute("label");if(label){let textNode=null;for(const n of this.childNodes){if(n.nodeType===3){textNode=n;break}}if(textNode)textNode.nodeValue=label;else this.insertBefore(document.createTextNode(label),this.firstChild)}if(this.hasAttribute("removable")){this.ensure(".c-badge__remove",()=>{const btn=document.createElement("button");btn.className="c-badge__remove";btn.type="button";btn.setAttribute("aria-label","Remove");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-badge__remove");if(btn)btn.remove()}}enhance(){wireRemovable(this)}}define("contour-badge",ContourBadgeFull);class ContourChipFull extends ContourBase{static get observed(){return["variant","key","value","live"]}static get properties(){return{variant:{attribute:"variant"},key:{attribute:"key"},value:{attribute:"value"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-chip");if(this.hasAttribute("live")&&!this.hasAttribute("role"))this.setAttribute("role","status");else if(!this.hasAttribute("live")&&this.getAttribute("role")==="status"&&this._autoChipRole)this.removeAttribute("role");this._autoChipRole=this.hasAttribute("live");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-chip--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-chip--"+variant);const key=this.getAttribute("key");const value=this.getAttribute("value");if(key){const k=this.ensure(".c-chip__key",()=>{const el=document.createElement("span");el.className="c-chip__key";return el});k.textContent=key}else{const k=this.querySelector(".c-chip__key");if(k)k.remove()}if(value){const v=this.ensure(".c-chip__value",()=>{const el=document.createElement("span");el.className="c-chip__value";return el});v.textContent=value}else{const v=this.querySelector(".c-chip__value");if(v)v.remove()}}}define("contour-chip",ContourChipFull);class ContourTag extends ContourBase{static get observed(){return["label","removable","variant","live"]}static get properties(){return{label:{attribute:"label"},removable:{attribute:"removable",type:Boolean},variant:{attribute:"variant"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-tag");if(this.hasAttribute("live")&&!this.hasAttribute("role"))this.setAttribute("role","status");else if(!this.hasAttribute("live")&&this.getAttribute("role")==="status"&&this._autoTagRole)this.removeAttribute("role");this._autoTagRole=this.hasAttribute("live");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-tag--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-tag--"+variant);const label=this.getAttribute("label");if(label){let textNode=null;for(const n of this.childNodes){if(n.nodeType===3){textNode=n;break}}if(textNode)textNode.nodeValue=label+" ";else this.insertBefore(document.createTextNode(label+" "),this.firstChild)}if(this.hasAttribute("removable")){this.ensure(".c-tag__remove",()=>{const btn=document.createElement("button");btn.className="c-tag__remove";btn.type="button";btn.setAttribute("aria-label","Remove");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-tag__remove");if(btn)btn.remove()}}enhance(){wireRemovable(this)}}define("contour-tag",ContourTag);class ContourDot extends ContourBase{static get observed(){return["variant","live"]}static get properties(){return{variant:{attribute:"variant"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-dot");if(!this.hasAttribute("role"))this.setAttribute("role","img");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","status indicator");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-dot--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-dot--"+variant);if(this.hasAttribute("live"))this.classList.add("c-dot--live");else this.classList.remove("c-dot--live")}}define("contour-dot",ContourDot);class ContourPill extends ContourBase{static get observed(){return["label","live","variant"]}static get properties(){return{label:{attribute:"label"},live:{attribute:"live",type:Boolean},variant:{attribute:"variant"}}}render(){this.classList.add("c-pill");if(this.hasAttribute("live")&&!this.hasAttribute("role"))this.setAttribute("role","status");else if(!this.hasAttribute("live")&&this.getAttribute("role")==="status"&&this._autoPillRole)this.removeAttribute("role");this._autoPillRole=this.hasAttribute("live");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-pill--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-pill--"+variant);const label=this.getAttribute("label");if(label){this.textContent=label}if(this.hasAttribute("live"))this.classList.add("c-pill--live");else this.classList.remove("c-pill--live")}}define("contour-pill",ContourPill);class ContourKbd extends ContourBase{static get observed(){return["key"]}static get properties(){return{key:{attribute:"key"}}}render(){this.classList.add("c-kbd");const key=this.getAttribute("key");if(key){this.textContent=key}}}define("contour-kbd",ContourKbd);class ContourSpinner extends ContourBase{static get observed(){return["size"]}static get properties(){return{size:{attribute:"size"}}}render(){this.classList.add("c-spinner");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-spinner--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-spinner--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Loading")}}define("contour-spinner",ContourSpinner);class ContourSkeleton extends ContourBase{static get observed(){return["size","shimmer"]}static get properties(){return{size:{attribute:"size"},shimmer:{attribute:"shimmer",type:Boolean}}}render(){this.classList.add("c-skeleton");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-skeleton--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-skeleton--"+size);if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true");const shimmer=this.getAttribute("shimmer");if(shimmer==="false"||shimmer==="off")this.classList.add("c-skeleton--static");else this.classList.remove("c-skeleton--static")}}define("contour-skeleton",ContourSkeleton);class ContourTooltip extends ContourBase{static get observed(){return["text","anchor","delay","trigger"]}static get properties(){return{text:{attribute:"text"},anchor:{attribute:"anchor"},delay:{attribute:"delay",type:Number},trigger:{attribute:"trigger"}}}render(){this.classList.add("c-tooltip");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Tooltip");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.hasAttribute("role"))this.setAttribute("role","tooltip");if(!this.id)this.id=contourId("tip");const text=this.getAttribute("text");if(text!==null&&!this.hasChildNodes()){this.textContent=text}}enhance(){if(this._wiredTooltip)return;this._wiredTooltip=true;const anchorSel=this.getAttribute("anchor");if(anchorSel){let trigger=null;if(anchorSel.startsWith("#")){trigger=document.getElementById(anchorSel.slice(1))}else{trigger=document.querySelector(anchorSel)}if(trigger){trigger.setAttribute("popovertarget",this.id||(this.id=contourId("tip")));trigger.setAttribute("aria-describedby",this.id)}}const delayMs=(this.delay&&this.delay>0)?this.delay:0;let showTimer=null;const hasPopover=typeof this.showPopover==="function";const show=()=>{if(showTimer)clearTimeout(showTimer);if(delayMs>0)showTimer=setTimeout(()=>{if(hasPopover){try{this.showPopover()}catch(e){}}else this.classList.add("is-open");try{requestAnimationFrame(flipIfNeeded)}catch(e){flipIfNeeded()}},delayMs);else{if(hasPopover){try{this.showPopover()}catch(e){}}else this.classList.add("is-open");try{requestAnimationFrame(flipIfNeeded)}catch(e){flipIfNeeded()}}};const hide=()=>{if(showTimer){clearTimeout(showTimer);showTimer=null}if(hasPopover){try{this.hidePopover()}catch(e){}}else this.classList.remove("is-open")};const triggerMode=this.getAttribute("trigger")||"hover";const trigger=anchorSel?(anchorSel.startsWith("#")?document.getElementById(anchorSel.slice(1)):document.querySelector(anchorSel)):null;const target=trigger||this;const onEnter=()=>{if(triggerMode!=="click")show()};const onLeave=()=>{if(triggerMode!=="click")hide()};const onFocus=()=>{if(triggerMode!=="click")show()};const onBlur=()=>{if(triggerMode!=="click")hide()};const onClick=()=>{if(triggerMode==="click"||triggerMode==="hover"){if(this.matches(":popover-open"))hide();else show()}};const onTouchStart=()=>{if(triggerMode!=="click")show()};const onTouchEnd=()=>{if(triggerMode!=="click"){setTimeout(hide,1500)}};target.addEventListener("mouseenter",onEnter);target.addEventListener("mouseleave",onLeave);target.addEventListener("focus",onFocus);target.addEventListener("blur",onBlur);target.addEventListener("click",onClick);target.addEventListener("touchstart",onTouchStart,{passive:true});target.addEventListener("touchend",onTouchEnd,{passive:true});const flipIfNeeded=()=>{try{const r=this.getBoundingClientRect();if(r.right>window.innerWidth)this.classList.add("c-tooltip--flip-x");else this.classList.remove("c-tooltip--flip-x");if(r.bottom>window.innerHeight)this.classList.add("c-tooltip--flip-y");else this.classList.remove("c-tooltip--flip-y")}catch(e){}};const origShow=show;onDispose(this,()=>{target.removeEventListener("mouseenter",onEnter);target.removeEventListener("mouseleave",onLeave);target.removeEventListener("focus",onFocus);target.removeEventListener("blur",onBlur);target.removeEventListener("click",onClick);target.removeEventListener("touchstart",onTouchStart);target.removeEventListener("touchend",onTouchEnd);if(showTimer)clearTimeout(showTimer)});this.addEventListener("toggle",(e)=>{const t=e.target;if(t&&t===this){this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:this.matches(":popover-open")},bubbles:true,composed:true}))}});this.addEventListener("beforetoggle",(e)=>{this.dispatchEvent(new CustomEvent(e.newState==="open"?"contour:show":"contour:hide",{bubbles:true,composed:true}))})}}define("contour-tooltip",ContourTooltip);class ContourProgress extends ContourBase{static get observed(){return["value","label","min","max","paused","pausable"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},min:{attribute:"min"},max:{attribute:"max"},paused:{attribute:"paused",type:Boolean},pausable:{attribute:"pausable",type:Boolean}}}render(){this.classList.add("c-progress");const value=this.getAttribute("value");if(value===null){this.style.removeProperty("--progress");if(this.getAttribute("aria-valuenow")===this._progressAriaValue){this.removeAttribute("aria-valuenow")}this._progressAriaValue=null}else{const num=Number(value);const pct=Number.isFinite(num)?(num<=1&&value.includes(".")?num*100:num):0;const pctStr=Math.max(0,Math.min(100,pct))+"%";this.style.setProperty("--progress",pctStr);const prevVal=this._progressAriaValue;if(!this.hasAttribute("aria-valuenow")||this.getAttribute("aria-valuenow")===prevVal){this.setAttribute("aria-valuenow",String(pct));this._progressAriaValue=String(pct)}}this.ensure(".c-progress__bar",()=>{const el=document.createElement("span");el.className="c-progress__bar";return el});if(!this.hasAttribute("role"))this.setAttribute("role","progressbar");const label=this.getAttribute("label");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label||"Progress");const min=this.getAttribute("min");const max=this.getAttribute("max");const minV=min!==null?Number(min):0;const maxV=max!==null?Number(max):100;if(min!==null)this.setAttribute("aria-valuemin",min);else if(!this.hasAttribute("aria-valuemin"))this.setAttribute("aria-valuemin","0");if(max!==null)this.setAttribute("aria-valuemax",max);else if(!this.hasAttribute("aria-valuemax"))this.setAttribute("aria-valuemax","100");if(this.hasAttribute("aria-valuenow")){const now=Number(this.getAttribute("aria-valuenow"));if(Number.isFinite(now))this.setAttribute("aria-valuenow",String(Math.max(minV,Math.min(maxV,now))))}if(this.hasAttribute("paused"))this.classList.add("c-progress--paused");else Array.from(this.classList).forEach((c)=>{if(c==="c-progress--paused")this.classList.remove(c)});if(this.hasAttribute("pausable")){const paused=this.hasAttribute("paused");const btn=this.ensure(".c-progress__pause",()=>{const el=document.createElement("button");el.className="c-progress__pause";el.type="button";return el});btn.setAttribute("aria-label",paused?"Resume":"Pause");btn.textContent=paused?"▶":"⏸"}else{const btn=this.querySelector(".c-progress__pause");if(btn)btn.remove()}}enhance(){if(this._wiredProgress)return;this._wiredProgress=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-progress__pause"):null;if(!btn||!this.contains(btn))return;e.preventDefault();const paused=!this.hasAttribute("paused");this.toggleAttribute("paused",paused);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{paused}}))})}}define("contour-progress",ContourProgress);class ContourMark extends ContourBase{render(){this.classList.add("c-mark")}}define("contour-mark",ContourMark);class ContourLoading extends ContourBase{static get observed(){return["label"]}static get properties(){return{label:{attribute:"label"}}}render(){this.classList.add("c-loading");if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live","polite");this.ensure(".c-spinner",()=>{const el=document.createElement("span");el.className="c-spinner";el.setAttribute("aria-hidden","true");return el});const label=this.getAttribute("label")||"Loading";let text=this.querySelector("[data-loading-label]");if(!text){text=document.createElement("span");text.className="visually-hidden";text.setAttribute("data-loading-label","");this.appendChild(text)}text.textContent=label;if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label)}}define("contour-loading",ContourLoading);class ContourElevation extends ContourBase{render(){this.classList.add("c-elevation")}}define("contour-elevation",ContourElevation);class ContourVersionBannerFull extends ContourBase{static get observed(){return["message","link","href","dismissible"]}static get properties(){return{message:{attribute:"message"},link:{attribute:"link"},href:{attribute:"href"},dismissible:{attribute:"dismissible",type:Boolean}}}render(){this.classList.add("c-version-banner");if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("message")||"Version banner");Array.from(this.children).forEach((n)=>n.remove());const message=this.getAttribute("message");if(message){const icon=document.createElementNS("http://www.w3.org/2000/svg","svg");icon.setAttribute("aria-hidden","true");icon.innerHTML='<use href="#i-info" />';this.appendChild(icon);const span=document.createElement("span");span.textContent=message;this.appendChild(span)}const link=this.getAttribute("link");const href=this.getAttribute("href");if(link&&href){const a=document.createElement("a");a.className="c-version-banner__link";a.href=safeHref(href);a.textContent=link;this.appendChild(a)}if(this.hasAttribute("dismissible")){const btn=document.createElement("button");btn.className="c-version-banner__dismiss";btn.type="button";btn.setAttribute("aria-label","Dismiss");btn.textContent="×";this.appendChild(btn)}}enhance(){if(this._wiredVersionBanner)return;this._wiredVersionBanner=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-version-banner__dismiss"):null;if(btn&&this.contains(btn)){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));this.remove()}})}}define("contour-version-banner",ContourVersionBannerFull);class ContourBanner extends ContourBase{static get observed(){return["message","variant"]}static get properties(){return{message:{attribute:"message"},variant:{attribute:"variant"}}}render(){this.classList.add("c-banner");const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-banner--"))this.classList.remove(c)});if(variant)this.classList.add("c-banner--"+variant);const message=this.getAttribute("message");if(message){const span=this.ensure(".c-banner__message",()=>{const el=document.createElement("span");el.className="c-banner__message";return el});span.textContent=message}}}define("contour-banner",ContourBanner);class ContourFilterPill extends ContourBase{static get observed(){return["key","value","removable"]}static get properties(){return{key:{attribute:"key"},value:{attribute:"value"},removable:{attribute:"removable",type:Boolean}}}render(){this.classList.add("c-filter-pill");const key=this.getAttribute("key");const value=this.getAttribute("value");if(key){const k=this.ensure(".c-filter-pill__key",()=>{const el=document.createElement("span");el.className="c-filter-pill__key";return el});k.textContent=key}else{const k=this.querySelector(".c-filter-pill__key");if(k)k.remove()}if(value){const v=this.ensure(".c-filter-pill__value",()=>{const el=document.createElement("span");el.className="c-filter-pill__value";return el});v.textContent=value}else{const v=this.querySelector(".c-filter-pill__value");if(v)v.remove()}if(this.hasAttribute("removable")){this.ensure(".c-filter-pill__remove",()=>{const btn=document.createElement("button");btn.className="c-filter-pill__remove";btn.type="button";btn.setAttribute("aria-label","Remove filter");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-filter-pill__remove");if(btn)btn.remove()}}enhance(){wireRemovable(this)}}define("contour-filter-pill",ContourFilterPill);class ContourDatamark extends ContourBase{static get observed(){return["value","unit","label"]}static get properties(){return{value:{attribute:"value"},unit:{attribute:"unit"},label:{attribute:"label"}}}render(){this.classList.add("c-datamark");const value=this.getAttribute("value");const unit=this.getAttribute("unit");const label=this.getAttribute("label");const text=value||label;if(text){this.textContent=text;if(unit){const u=document.createElement("span");u.className="u-subtle";u.textContent=" "+unit;this.appendChild(u)}}}}define("contour-datamark",ContourDatamark);class ContourDestructiveHint extends ContourBase{static get observed(){return["text"]}static get properties(){return{text:{attribute:"text"}}}render(){this.classList.add("c-destructive-hint");const text=this.getAttribute("text");if(text)this.textContent=text}}define("contour-destructive-hint",ContourDestructiveHint);class ContourIconBadge extends ContourBase{static get observed(){return["icon"]}static get properties(){return{icon:{attribute:"icon"}}}render(){this.classList.add("c-icon-badge");const icon=this.getAttribute("icon");if(icon){const sanitized=String(icon).replace(/[^a-zA-Z0-9_-]/g,"");if(sanitized&&!sanitized.startsWith("i-")){if(typeof console!=="undefined"&&console.warn){console.warn("ContourIconBadge: icon '"+icon+"' may not exist in the sprite (expected i-* name).")}}const existing=this.querySelector("svg");const svg=existing||document.createElementNS("http://www.w3.org/2000/svg","svg");if(!existing){svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href","#"+sanitized);svg.appendChild(use);this.appendChild(svg)}else{const use=svg.querySelector("use");if(use)use.setAttribute("href","#"+sanitized)}}else{const svg=this.querySelector("svg");if(svg)svg.remove()}}}define("contour-icon-badge",ContourIconBadge);class ContourLiveBadge extends ContourBase{static get observed(){return["label","state","live"]}static get properties(){return{label:{attribute:"label"},state:{attribute:"state"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-live-badge");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-live-badge--"))this.classList.remove(c)});const state=this.getAttribute("state");if(state){this.classList.add("c-live-badge--"+state)}else if(this.hasAttribute("live")){this.classList.add("c-live-badge--connected")}const label=this.getAttribute("label");if(label&&!this.hasChildNodes())this.textContent=label}}define("contour-live-badge",ContourLiveBadge);class ContourSkeletonGroup extends ContourBase{static get observed(){return["count"]}static get properties(){return{count:{attribute:"count",type:Number}}}render(){this.classList.add("c-skeleton-group");const count=Math.max(1,parseInt(this.getAttribute("count")||"3",10)||3);Array.from(this.querySelectorAll(".c-skeleton")).forEach((n)=>n.remove());for(let i=0;i<count;i++){const sk=document.createElement("div");sk.className="c-skeleton";sk.setAttribute("aria-hidden","true");this.appendChild(sk)}}}define("contour-skeleton-group",ContourSkeletonGroup);class ContourMapPopup extends ContourBase{static get observed(){return["title","content","cluster-count","cluster-expanded","cluster-items","anchor","position","collision"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"},"cluster-count":{attribute:"cluster-count",type:Number},"cluster-expanded":{attribute:"cluster-expanded",type:Boolean},"cluster-items":{attribute:"cluster-items"}}}render(){this.classList.add("c-map-popup");this.setAttribute("role","dialog");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("map-popup");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-map-popup__title",()=>{const el=document.createElement("div");el.className="c-map-popup__title";return el});t.textContent=title}const content=this.getAttribute("content");if(content){const c=this.ensure(".c-map-popup__body",()=>{const el=document.createElement("div");el.className="c-map-popup__body";return el});c.textContent=content}const clusterCount=Number(this.getAttribute("cluster-count"));if(Number.isFinite(clusterCount)&&clusterCount>1){const badge=this.ensure(".c-map-popup__cluster",()=>{const el=document.createElement("button");el.className="c-map-popup__cluster c-btn c-btn--sm";el.type="button";return el});const expanded=this.hasAttribute("cluster-expanded");badge.textContent=expanded?"Hide locations":`${clusterCount} locations`;badge.setAttribute("aria-expanded",String(expanded));badge.setAttribute("aria-label",expanded?"Hide locations":`Show ${clusterCount} locations`)}else{const badge=this.querySelector(".c-map-popup__cluster");if(badge)badge.remove()}const expanded=this.hasAttribute("cluster-expanded");let items=[];try{items=this.getAttribute("cluster-items")?JSON.parse(this.getAttribute("cluster-items")):[]}catch(e){items=[]}const list=this.querySelector(".c-map-popup__cluster-list");if(expanded&&Array.isArray(items)&&items.length){const ul=list||document.createElement("ul");ul.className="c-map-popup__cluster-list";ul.innerHTML="";items.forEach((it)=>{const li=document.createElement("li");li.className="c-map-popup__cluster-item";li.textContent=typeof it==="string"?it:(it.label||it.name||JSON.stringify(it));ul.appendChild(li)});if(ul.parentNode!==this)this.appendChild(ul)}else if(list){list.remove()}if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",title||"Map popup")}enhance(){if(this._wiredMapPopup)return;this._wiredMapPopup=true;const close=()=>{try{this.hidePopover()}catch(e){}this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))};const keyHandler=(e)=>{if(e.key==="Escape"&&(this.classList.contains("is-open")||this.matches(":popover-open"))){e.preventDefault();close()}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-map-popup__close"):null;if(btn&&this.contains(btn))close();const cluster=e.target&&e.target.closest?e.target.closest(".c-map-popup__cluster"):null;if(cluster&&this.contains(cluster)){const expanded=!this.hasAttribute("cluster-expanded");this.toggleAttribute("cluster-expanded",expanded);this.dispatchEvent(new CustomEvent("contour:cluster-toggle",{bubbles:true,composed:true,detail:{count:Number(this.getAttribute("cluster-count")),expanded}}))}});const anchorSel=this.getAttribute("anchor");let anchorEl=null;if(anchorSel){anchorEl=anchorSel.startsWith("#")?document.getElementById(anchorSel.slice(1)):document.querySelector(anchorSel)}const anchorName="--map-popup-"+this.id;const applyAnchor=()=>{if(anchorEl){anchorEl.style.setProperty("anchor-name",anchorName);this.style.setProperty("position-anchor",anchorName)}};const flipIfNeeded=()=>{try{const r=this.getBoundingClientRect();const flipX=r.right>window.innerWidth||r.left<0;const flipY=r.bottom>window.innerHeight||r.top<0;const flipped=flipX||flipY;this.classList.toggle("c-map-popup--flip-x",flipX&&!flipY);this.classList.toggle("c-map-popup--flip-y",flipY&&!flipX);this.classList.toggle("c-map-popup--flip-both",flipX&&flipY);if(flipped){this.dispatchEvent(new CustomEvent("contour:map-popup-reposition",{bubbles:true,composed:true,detail:{anchor:anchorSel||"",flippedX:flipX,flippedY:flipY,left:Math.round(r.left),top:Math.round(r.top)}}))}}catch(e){}};applyAnchor();this.addEventListener("toggle",(e)=>{if(e.newState==="open"){requestAnimationFrame(()=>{applyAnchor();flipIfNeeded()})}});const onResize=()=>flipIfNeeded();window.addEventListener("resize",onResize);onDispose(this,()=>{window.removeEventListener("resize",onResize);if(anchorEl)anchorEl.style.removeProperty("anchor-name")})}}define("contour-map-popup",ContourMapPopup);class ContourAnimationControls extends ContourBase{static get observed(){return["playing","speed","progress","min","max","caption","show-thumb","show-thumb-caption","loop","step","markers"]}static get properties(){return{playing:{attribute:"playing",type:Boolean},speed:{attribute:"speed"},progress:{attribute:"progress"},min:{attribute:"min"},max:{attribute:"max"},loop:{attribute:"loop",type:Boolean},step:{attribute:"step"},markers:{attribute:"markers"}}}render(){this.classList.add("c-animation-controls");this.setAttribute("role","toolbar");this.setAttribute("aria-label","Animation controls");const playBtn=this.ensure(".c-animation-controls__play",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-animation-controls__play";el.type="button";return el});playBtn.textContent=this.hasAttribute("playing")?"Pause":"Play";playBtn.setAttribute("aria-label",this.hasAttribute("playing")?"Pause":"Play");const speed=this.getAttribute("speed")||"1x";const speedBtn=this.ensure(".c-animation-controls__speed",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-animation-controls__speed";el.type="button";return el});speedBtn.textContent=speed;speedBtn.setAttribute("aria-label","Playback speed "+speed);const loopBtn=this.ensure(".c-animation-controls__loop",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-animation-controls__loop";el.type="button";el.textContent="Loop";return el});loopBtn.setAttribute("aria-pressed",String(this.hasAttribute("loop")));playBtn.tabIndex=0;speedBtn.tabIndex=-1;loopBtn.tabIndex=-1;const scrubber=this.ensure(".c-animation-controls__scrubber",()=>{const el=document.createElement("input");el.className="c-range c-animation-controls__scrubber";el.type="range";return el});if(this.getAttribute("show-thumb")==="false")scrubber.classList.remove("c-animation-controls__scrubber--thumb");else scrubber.classList.add("c-animation-controls__scrubber--thumb");scrubber.min=this.getAttribute("min")||"0";scrubber.max=this.getAttribute("max")||"100";scrubber.step=this.getAttribute("step")||"1";scrubber.value=this.getAttribute("progress")||"0";const min=Number(scrubber.min)||0;const max=Number(scrubber.max)||100;const v=Number(scrubber.value)||min;scrubber.setAttribute("aria-valuenow",String(v));scrubber.setAttribute("aria-valuetext",String(Math.round(v)));scrubber.setAttribute("aria-valuemin",String(min));scrubber.setAttribute("aria-valuemax",String(max));const caption=this.getAttribute("caption");if(caption)scrubber.setAttribute("aria-label",caption);else if(!scrubber.getAttribute("aria-label"))scrubber.setAttribute("aria-label","Playhead");const markersRaw=this.getAttribute("markers");let markers=[];if(markersRaw){try{const p=JSON.parse(markersRaw);markers=Array.isArray(p)?p:[]}catch(e){warnBadJson(this,"markers",e)}}const oldList=this.querySelector("datalist.c-animation-controls__markers");if(markers.length){const dl=this.ensure("datalist.c-animation-controls__markers",()=>{const el=document.createElement("datalist");el.className="c-animation-controls__markers";return el});if(!dl.id)dl.id=this._animMarkersId||(this._animMarkersId=contourId("anim-markers"));dl.innerHTML="";markers.forEach((m)=>{const opt=document.createElement("option");const val=typeof m==="object"&&m!==null?m.value:m;opt.value=String(val);if(typeof m==="object"&&m!==null&&m.label)opt.label=String(m.label);dl.appendChild(opt)});scrubber.setAttribute("list",dl.id)}else{if(oldList)oldList.remove();scrubber.removeAttribute("list")}const showCaption=this.hasAttribute("show-thumb-caption")||this.hasAttribute("show-thumb");if(caption&&showCaption){const cap=this.ensure(".c-animation-controls__caption",()=>{const el=document.createElement("span");el.className="c-animation-controls__caption";return el});cap.textContent=caption}else{const cap=this.querySelector(".c-animation-controls__caption");if(cap)cap.remove()}if(this.hasAttribute("loop")){this.setAttribute("aria-label","Animation controls, loop")}}enhance(){if(this._wiredAnimControls)return;this._wiredAnimControls=true;const SPEEDS=[0.5,1,2,4];const writeProgress=(v)=>{if(!this._animScrubbing)this.setAttribute("progress",String(v))};this.addEventListener("pointerdown",(e)=>{if(e.target&&e.target.closest&&e.target.closest(".c-animation-controls__scrubber"))this._animScrubbing=true},{passive:true});const endScrub=()=>{this._animScrubbing=false};this.addEventListener("pointerup",endScrub,{passive:true});this.addEventListener("pointercancel",endScrub,{passive:true});this.addEventListener("click",(e)=>{const play=e.target&&e.target.closest?e.target.closest(".c-animation-controls__play"):null;if(play&&this.contains(play)){const next=!this.hasAttribute("playing");this.toggleAttribute("playing",next);this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{playing:next}}));return}const speed=e.target&&e.target.closest?e.target.closest(".c-animation-controls__speed"):null;if(speed&&this.contains(speed)){const cur=parseFloat(this.getAttribute("speed")||"1x");const idx=SPEEDS.indexOf(Number.isFinite(cur)?cur:1);const next=SPEEDS[(idx+1)%SPEEDS.length];this.setAttribute("speed",next+"x");this.dispatchEvent(new CustomEvent("contour:speed-change",{bubbles:true,composed:true,detail:{speed:next}}));return}const loop=e.target&&e.target.closest?e.target.closest(".c-animation-controls__loop"):null;if(loop&&this.contains(loop)){const next=!this.hasAttribute("loop");this.toggleAttribute("loop",next);this.dispatchEvent(new CustomEvent("contour:loop-change",{bubbles:true,composed:true,detail:{loop:next}}))}});this.addEventListener("input",(e)=>{const scrubber=e.target&&e.target.closest?e.target.closest(".c-animation-controls__scrubber"):null;if(scrubber&&this.contains(scrubber)){const v=Number(scrubber.value);writeProgress(v);this.dispatchEvent(new CustomEvent("contour:seek",{bubbles:true,composed:true,detail:{progress:v,value:v}}))}});this.addEventListener("change",(e)=>{const scrubber=e.target&&e.target.closest?e.target.closest(".c-animation-controls__scrubber"):null;if(scrubber&&this.contains(scrubber))this.setAttribute("progress",scrubber.value)});this.addEventListener("keydown",(e)=>{if(e.target&&e.target.closest&&e.target.closest(".c-animation-controls__scrubber"))return;const buttons=Array.from(this.querySelectorAll(".c-animation-controls__play, .c-animation-controls__speed, .c-animation-controls__loop"));if(!buttons.includes(e.target))return;navKey(e,buttons,{wrap:true,homeEnd:true,onNavigate:(i)=>{buttons.forEach((b,j)=>{b.tabIndex=j===i?0:-1})},onKey:(k,idx,item)=>{if(k==="Enter"||k===" ")item.click()}})});let timer=null;const speedFactor=()=>{const s=this.getAttribute("speed")||"1x";const n=parseFloat(s);return Number.isFinite(n)&&n>0?n:1};const tick=()=>{const scrubber=this.querySelector(".c-animation-controls__scrubber");if(!scrubber)return;const min=Number(scrubber.min||0);const max=Number(scrubber.max||100);let v=Number(scrubber.value||0)+speedFactor();let ended=false;if(v>max){if(this.hasAttribute("loop"))v=min;else{v=max;stop();ended=true}}scrubber.value=String(v);writeProgress(v);this.dispatchEvent(new CustomEvent("contour:time-change",{bubbles:true,composed:true,detail:{progress:v,value:v}}));if(ended){this.removeAttribute("playing");this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{playing:false}}))}};const start=()=>{if(timer)return;timer=setInterval(tick,100)};const stop=()=>{if(timer){clearInterval(timer);timer=null}};if(this.hasAttribute("playing"))start();const obs=new MutationObserver(()=>{if(this.hasAttribute("playing"))start();else stop()});obs.observe(this,{attributes:true,attributeFilter:["playing"]});onDispose(this,()=>{stop();obs.disconnect()})}}define("contour-animation-controls",ContourAnimationControls);class ContourDropdown extends ContourBase{static get observed(){return["label","items"]}static get properties(){return{label:{attribute:"label"},items:{attribute:"items"}}}render(){this.classList.add("c-dropdown");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Dropdown");const btn=this.ensure(".c-dropdown__trigger",()=>{const el=document.createElement("button");el.className="c-dropdown__trigger c-btn c-btn--sm";el.type="button";return el});btn.textContent=this.getAttribute("label")||"Menu";btn.setAttribute("aria-haspopup","menu");btn.setAttribute("aria-expanded","false");const menu=this.ensure(".c-dropdown__menu",()=>{const el=document.createElement("div");el.className="c-dropdown__menu c-menu";el.setAttribute("role","menu");el.hidden=true;return el});if(!menu.id)menu.id=(this.id||contourId("dd"))+"-menu";btn.setAttribute("aria-controls",menu.id);const authoredItems=Array.from(this.querySelectorAll(":scope > .c-menu__item"));const items=this.getAttribute("items");if(authoredItems.length){menu.innerHTML="";authoredItems.forEach((it)=>{menu.appendChild(it)})}else if(items){try{const parsed=JSON.parse(items);menu.innerHTML="";parsed.forEach((it)=>{const li=document.createElement("button");li.className="c-menu__item";li.setAttribute("role","menuitem");li.textContent=typeof it==="string"?it:(it.label||it.title||"");menu.appendChild(li)})}catch(e){warnBadJson(this,"attribute",e)}}if(menu.parentNode!==this)this.appendChild(menu);if(btn.parentNode!==this)this.insertBefore(btn,menu)}enhance(){if(this._wiredDropdown)return;this._wiredDropdown=true;const btn=()=>this.querySelector(".c-dropdown__trigger");const menu=()=>this.querySelector(".c-dropdown__menu");this.addEventListener("click",(e)=>{const b=btn();const m=menu();const item=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;if(item&&m&&m.contains(item)&&!m.hidden){const idx=Array.from(m.querySelectorAll(".c-menu__item")).indexOf(item);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx,value:item.textContent}}));m.hidden=true;if(b){b.setAttribute("aria-expanded","false");try{b.focus()}catch(err){}}return}if(e.target===b||(b&&b.contains(e.target))){if(m){m.hidden=!m.hidden;b.setAttribute("aria-expanded",String(!m.hidden));if(!m.hidden){if(!m.id)m.id=(this.id||contourId("dd"))+"-menu";b.setAttribute("aria-controls",m.id);const first=m.querySelector(".c-menu__item");if(first)try{first.focus()}catch(err){}}}}});const docClick=(e)=>{const m=menu();const b=btn();if(m&&!m.hidden&&!this.contains(e.target)){m.hidden=true;if(b)b.setAttribute("aria-expanded","false")}};document.addEventListener("click",docClick);onDispose(this,()=>document.removeEventListener("click",docClick));const keyHandler=(e)=>{const m=menu();const b=btn();if(e.key==="Escape"&&m&&!m.hidden){e.preventDefault();m.hidden=true;if(b){b.setAttribute("aria-expanded","false");try{b.focus()}catch(err){}}return}if(!m||m.hidden)return;const items=Array.from(m.querySelectorAll(".c-menu__item"));navKey(e,items,{wrap:true,enter:false,onKey:(k)=>{if(k==="Enter"||k===" ")document.activeElement.click()}})};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler))}}define("contour-dropdown",ContourDropdown);class ContourAnnotation extends ContourBase{static get observed(){return["label","x","y"]}static get properties(){return{label:{attribute:"label"},x:{attribute:"x"},y:{attribute:"y"}}}render(){this.classList.add("c-annotation");this.setAttribute("role","note");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");const label=this.getAttribute("label");if(label)this.setAttribute("aria-label",label);if(label){const l=this.ensure(".c-annotation__label",()=>{const el=document.createElement("span");el.className="c-annotation__label";return el});l.textContent=label}const x=this.getAttribute("x");const y=this.getAttribute("y");if(x!==null)this.style.setProperty("--annotation-x",x);if(y!==null)this.style.setProperty("--annotation-y",y)}enhance(){if(this._wiredAnnotation)return;this._wiredAnnotation=true;const pct=(v,fallback)=>{const n=parseFloat(v);return Number.isFinite(n)?Math.min(100,Math.max(0,n)):fallback};const write=(x,y,key)=>{this.batch(()=>{this.setAttribute("x",x+"%");this.setAttribute("y",y+"%")});this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:true,composed:true,detail:{delta:key?1:0,key:key||"pointer",value:x+","+y}}))};let drag=null;this.addEventListener("pointerdown",(e)=>{if(e.button!==undefined&&e.button!==0)return;const parent=this.offsetParent||this.parentElement;if(!parent)return;const rect=parent.getBoundingClientRect();drag={px:e.clientX,py:e.clientY,x:pct(this.getAttribute("x"),50),y:pct(this.getAttribute("y"),50),w:rect.width||1,h:rect.height||1};try{this.setPointerCapture(e.pointerId)}catch(err){}try{this.focus()}catch(err){}e.preventDefault()});this.addEventListener("pointermove",(e)=>{if(!drag)return;const x=Math.round((drag.x+((e.clientX-drag.px)/drag.w)*100)*10)/10;const y=Math.round((drag.y+((e.clientY-drag.py)/drag.h)*100)*10)/10;write(Math.min(100,Math.max(0,x)),Math.min(100,Math.max(0,y)))});const endDrag=()=>{if(!drag)return;drag=null;this.dispatchEvent(new CustomEvent("contour:dragend",{bubbles:true,composed:true,detail:{value:(this.getAttribute("x")||"")+","+(this.getAttribute("y")||"")}}))};this.addEventListener("pointerup",endDrag);this.addEventListener("pointercancel",endDrag);this.addEventListener("keydown",(e)=>{const step=e.shiftKey?10:1;let dx=0,dy=0;if(e.key==="ArrowLeft")dx=-step;else if(e.key==="ArrowRight")dx=step;else if(e.key==="ArrowUp")dy=-step;else if(e.key==="ArrowDown")dy=step;else return;e.preventDefault();const x=Math.min(100,Math.max(0,pct(this.getAttribute("x"),50)+dx));const y=Math.min(100,Math.max(0,pct(this.getAttribute("y"),50)+dy));write(x,y,e.key);this.dispatchEvent(new CustomEvent("contour:dragend",{bubbles:true,composed:true,detail:{value:x+","+y}}))})}}define("contour-annotation",ContourAnnotation);class ContourStyleSwitcher extends ContourBase{static get observed(){return["items","value"]}static get properties(){return{items:{attribute:"items"},value:{attribute:"value"}}}render(){this.classList.add("c-style-switcher");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Style switcher");const items=this.getAttribute("items");const value=this.getAttribute("value");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-style-switcher__option"));if(items&&!authored.length){Array.from(this.querySelectorAll(".c-style-switcher__option")).forEach((n)=>n.remove());try{const parsed=JSON.parse(items);parsed.forEach((it)=>{const name=typeof it==="string"?it:(it.name||it.label||"");const btn=document.createElement("button");btn.className="c-style-switcher__option c-btn c-btn--sm";btn.type="button";btn.textContent=name;btn.dataset.value=name;this.appendChild(btn)})}catch(e){warnBadJson(this,"attribute",e)}}const opts=Array.from(this.querySelectorAll(".c-style-switcher__option"));let active=null;opts.forEach((btn)=>{const v=btn.dataset.value!=null?btn.dataset.value:btn.textContent.trim();const on=v===value;btn.classList.toggle("c-style-switcher__option--active",on);btn.setAttribute("aria-pressed",String(on));btn.tabIndex=-1;if(on&&!active)active=btn});(active||opts[0])?.setAttribute("tabindex","0")}enhance(){if(this._wiredStyleSwitcher)return;this._wiredStyleSwitcher=true;const select=(btn)=>{const v=btn.dataset.value!=null?btn.dataset.value:btn.textContent.trim();this.setAttribute("value",v);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:v}}))};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-style-switcher__option"):null;if(btn&&this.contains(btn))select(btn)});this.addEventListener("keydown",(e)=>{const opts=Array.from(this.querySelectorAll(".c-style-switcher__option"));navKey(e,opts,{onKey:(k)=>{if(k==="Enter"||k===" "){const btn=document.activeElement;if(btn&&btn.classList.contains("c-style-switcher__option"))select(btn)}}})})}}define("contour-style-switcher",ContourStyleSwitcher);class ContourStylePanel extends ContourBase{static get observed(){return["title","layers","layer","single","classification","palette","breaks","opacity","n","colors","property"]}static get properties(){return{title:{attribute:"title"},layers:{attribute:"layers"},classification:{attribute:"classification"},palette:{attribute:"palette"},breaks:{attribute:"breaks"},opacity:{attribute:"opacity"}}}render(){this.classList.add("c-style-panel");if(!this._stylePanelDefault){this._stylePanelDefault={};for(const a of["property","classification","palette","breaks","opacity","n","colors"])this._stylePanelDefault[a]=this.getAttribute(a)}this.setAttribute("role","group");this.setAttribute("aria-label","Style panel");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-style-panel__title",()=>{const el=document.createElement("div");el.className="c-style-panel__title";return el});t.textContent=title}const singleMode=this.hasAttribute("single")||!!this.getAttribute("layer");if(singleMode){const body=this.ensure(".c-style-panel__body",()=>{const el=document.createElement("div");el.className="c-style-panel__body";return el});body.innerHTML="";const uid=contourId("style-panel");const propId=uid+"-property";const policyId=uid+"-policy";const paletteId=uid+"-palette";const nId=uid+"-n";const propLabel=document.createElement("label");propLabel.textContent=labelText(this,"colour-field","Colour field");propLabel.setAttribute("for",propId);body.appendChild(propLabel);const propIn=document.createElement("input");propIn.type="text";propIn.id=propId;propIn.className="c-style-panel__property c-input";propIn.setAttribute("aria-label",labelText(this,"colour-field","Colour field"));const pv=this.getAttribute("property");if(pv)propIn.value=pv;body.appendChild(propIn);const clsLabel=document.createElement("label");clsLabel.textContent=labelText(this,"classification","Classification");clsLabel.setAttribute("for",policyId);body.appendChild(clsLabel);const clsSel=document.createElement("select");clsSel.id=policyId;clsSel.className="c-style-panel__classification c-input";clsSel.setAttribute("aria-label",labelText(this,"classification-method","Classification method"));["equal","quantile","jenks","manual"].forEach((m)=>{const o=document.createElement("option");o.value=m;o.textContent=m;clsSel.appendChild(o)});const cls=this.getAttribute("classification");if(cls)clsSel.value=cls;body.appendChild(clsSel);const palLabel=document.createElement("label");palLabel.textContent=labelText(this,"palette","Palette");palLabel.setAttribute("for",paletteId);body.appendChild(palLabel);const pal=document.createElement("input");pal.type="text";pal.id=paletteId;pal.className="c-style-panel__palette c-input";pal.placeholder=labelText(this,"palette","Palette");pal.setAttribute("aria-label",labelText(this,"palette","Palette"));const palv=this.getAttribute("palette");if(palv)pal.value=palv;body.appendChild(pal);const nLabel=document.createElement("label");nLabel.textContent=labelText(this,"classes","Classes");nLabel.setAttribute("for",nId);body.appendChild(nLabel);const nIn=document.createElement("input");nIn.type="number";nIn.id=nId;nIn.className="c-style-panel__n c-input";nIn.min="2";nIn.max="12";nIn.setAttribute("aria-label",labelText(this,"class-count","Class count"));const nv=this.getAttribute("n");if(nv)nIn.value=nv;else nIn.value="5";body.appendChild(nIn);const op=document.createElement("input");op.type="range";op.className="c-style-panel__opacity";op.setAttribute("aria-label",labelText(this,"opacity","Opacity"));op.min="0";op.max="100";const ov=this.getAttribute("opacity");op.value=ov!=null?ov:"100";body.appendChild(op);const breaksAttr=this.getAttribute("breaks");let breaksArr=null;if(breaksAttr){try{breaksArr=JSON.parse(breaksAttr)}catch(e){breaksArr=breaksAttr.split(",").map((s)=>s.trim())}}if(Array.isArray(breaksArr)&&breaksArr.length){const breaksWrap=document.createElement("div");breaksWrap.className="c-style-panel__breaks";breaksArr.forEach((b,i)=>{const br=document.createElement("div");br.className="break";const span=document.createElement("span");span.textContent=String(b);br.appendChild(span);const inp=document.createElement("input");inp.type="number";inp.className="c-style-panel__breaks c-input";inp.setAttribute("aria-label",labelText(this,"class-lower-bound","Class lower bound"));inp.value=String(b);br.appendChild(inp);breaksWrap.appendChild(br)});body.appendChild(breaksWrap)}const colorsAttr=this.getAttribute("colors");let colors=null;if(colorsAttr){try{colors=JSON.parse(colorsAttr)}catch(e){colors=colorsAttr.split(",").map((s)=>s.trim())}}if(Array.isArray(colors)){const list=document.createElement("div");list.className="c-style-panel__colors";colors.forEach((c,i)=>{const sw=document.createElement("input");sw.type="color";sw.className="c-style-panel__color c-input";sw.setAttribute("aria-label",labelText(this,"colour-for-class","Colour for class")+" "+(i+1));sw.value=c;list.appendChild(sw)});body.appendChild(list)}const actions=document.createElement("div");actions.className="c-style-panel__actions c-btn-group";const applyBtn=document.createElement("button");applyBtn.type="button";applyBtn.className="c-btn c-btn--primary";applyBtn.textContent=labelText(this,"apply","Apply");applyBtn.dataset.action="apply";const revertBtn=document.createElement("button");revertBtn.type="button";revertBtn.className="c-btn";revertBtn.textContent=labelText(this,"revert","Revert");revertBtn.dataset.action="revert";actions.appendChild(applyBtn);actions.appendChild(revertBtn);body.appendChild(actions);return}const layers=this.getAttribute("layers");const body=this.ensure(".c-style-panel__body",()=>{const el=document.createElement("div");el.className="c-style-panel__body";return el});const authoredRows=Array.from(this.querySelectorAll(":scope > .c-style-panel__row"));let parsed=null;if(authoredRows.length){parsed=authoredRows.map((row)=>({name:row.querySelector(".c-style-panel__name")?.textContent||"",color:row.querySelector(".c-style-panel__color")?.value,classification:row.querySelector(".c-style-panel__classification")?.value,palette:row.querySelector(".c-style-panel__palette")?.value,breaks:row.querySelector(".c-style-panel__breaks")?.value,opacity:row.querySelector(".c-style-panel__opacity")?.value,}));authoredRows.forEach((row)=>row.remove())}else if(layers){try{parsed=JSON.parse(layers)}catch(e){parsed=null}}if(parsed){body.innerHTML="";parsed.forEach((l)=>{const row=document.createElement("div");row.className="c-style-panel__row";const name=document.createElement("span");name.className="c-style-panel__name";name.textContent=typeof l==="string"?l:(l.name||l.label||"");row.appendChild(name);const input=document.createElement("input");input.type="color";input.className="c-style-panel__color";input.setAttribute("aria-label","Colour for "+(typeof l==="string"?l:(l.name||l.label||"layer")));if(typeof l==="object"&&l.color)input.value=l.color;row.appendChild(input);const clsSel=document.createElement("select");clsSel.className="c-style-panel__classification";clsSel.setAttribute("aria-label",labelText(this,"classification-method","Classification method"));["equal","quantile","jenks","manual"].forEach((m)=>{const o=document.createElement("option");o.value=m;o.textContent=m;clsSel.appendChild(o)});if(typeof l==="object"&&l.classification)clsSel.value=l.classification;row.appendChild(clsSel);const pal=document.createElement("input");pal.type="text";pal.className="c-style-panel__palette";pal.setAttribute("aria-label","Palette");pal.placeholder="palette";if(typeof l==="object"&&l.palette)pal.value=l.palette;row.appendChild(pal);const breaks=document.createElement("input");breaks.type="text";breaks.className="c-style-panel__breaks";breaks.placeholder="breaks";breaks.setAttribute("aria-label","Class breaks");if(typeof l==="object"&&l.breaks)breaks.value=(Array.isArray(l.breaks)?l.breaks.join(","):l.breaks);row.appendChild(breaks);const op=document.createElement("input");op.type="range";op.className="c-style-panel__opacity";op.setAttribute("aria-label",labelText(this,"opacity","Opacity"));op.min="0";op.max="100";op.value=(typeof l==="object"&&l.opacity!=null)?l.opacity:"100";row.appendChild(op);body.appendChild(row)})}}enhance(){if(this._wiredStylePanel)return;this._wiredStylePanel=true;this.addEventListener("change",(e)=>{const t=e.target;if(!t||!this.contains(t))return;const row=t.closest(".c-style-panel__row");const name=row?(row.querySelector(".c-style-panel__name")?.textContent||""):"";if(t.classList.contains("c-style-panel__color")){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:t.value,layer:name,property:"color"},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__classification")){this.dispatchEvent(new CustomEvent("contour:break-change",{detail:{value:t.value,layer:name},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__opacity")){this.dispatchEvent(new CustomEvent("contour:layer-opacity",{detail:{name,opacity:Number(t.value)},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__property")){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:t.value,layer:name,property:"property"},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__n")){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:Number(t.value),layer:name,property:"n"},bubbles:true,composed:true}))}});this.addEventListener("input",(e)=>{const t=e.target;if(!t||!this.contains(t))return;if(t.classList.contains("c-style-panel__color"))t.setAttribute("data-edited","true");if(t.classList.contains("c-style-panel__palette")||t.classList.contains("c-style-panel__breaks")){const row=t.closest(".c-style-panel__row");const name=row?(row.querySelector(".c-style-panel__name")?.textContent||""):"";this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:t.value,layer:name,property:t.classList.contains("c-style-panel__palette")?"palette":"breaks"},bubbles:true,composed:true}))}});this.addEventListener("click",(e)=>{const t=e.target&&e.target.closest?e.target.closest("button"):null;if(!t||!this.contains(t))return;if(t.dataset.action==="apply"){const body=this.querySelector(".c-style-panel__body");const payload={applied:true};if(body){const prop=body.querySelector(".c-style-panel__property");const cls=body.querySelector(".c-style-panel__classification");const pal=body.querySelector(".c-style-panel__palette");const n=body.querySelector(".c-style-panel__n");const colors=Array.from(body.querySelectorAll(".c-style-panel__color")).map((c)=>c.value);if(prop)payload.property=prop.value;if(cls)payload.classification=cls.value;if(pal)payload.palette=pal.value;if(n)payload.n=Number(n.value);if(colors.length)payload.colors=colors}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:payload,bubbles:true,composed:true}))}else if(t.dataset.action==="revert"){const def=this._stylePanelDefault||{};this._contourResetting=true;try{for(const a of["property","classification","palette","breaks","opacity","n","colors"]){if(def[a]===null||def[a]===undefined)this.removeAttribute(a);else this.setAttribute(a,def[a])}this.attributeChangedCallback("__rerender__",null,"")}finally{this._contourResetting=false}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{applied:false},bubbles:true,composed:true}))}})}}define("contour-style-panel",ContourStylePanel);class ContourResponsiveContent extends ContourBase{static get observed(){return["breakpoint"]}static get properties(){return{breakpoint:{attribute:"breakpoint"}}}render(){this.classList.add("c-responsive-content");const bp=this.getAttribute("breakpoint")||"md";this.dataset.breakpoint=bp}}define("contour-responsive-content",ContourResponsiveContent);class ContourAvatarGroup extends ContourBase{static get observed(){return["items","max"]}static get properties(){return{items:{attribute:"items"},max:{attribute:"max",type:Number}}}render(){this.classList.add("c-avatar-group");const items=this.getAttribute("items");const max=parseInt(this.getAttribute("max")||"4",10)||4;Array.from(this.querySelectorAll(".c-avatar, .c-avatar-group__overflow")).forEach((n)=>n.remove());if(items){try{const parsed=JSON.parse(items);const shown=parsed.slice(0,max);shown.forEach((it)=>{const av=document.createElement("span");av.className="c-avatar";const name=typeof it==="string"?it:(it.name||it.label||"");av.textContent=name.slice(0,2).toUpperCase();if(typeof it==="object"&&it.color){av.style.background=it.color;av.dataset.color=it.color}this.appendChild(av)});if(parsed.length>max){const overflow=document.createElement("span");overflow.className="c-avatar c-avatar-group__overflow";overflow.textContent="+"+(parsed.length-max);this.appendChild(overflow)}}catch(e){warnBadJson(this,"attribute",e)}}}}define("contour-avatar-group",ContourAvatarGroup);class ContourDivider extends ContourBase{static get observed(){return["label","orientation"]}static get properties(){return{label:{attribute:"label"},orientation:{attribute:"orientation"}}}render(){this.classList.add("c-divider");const orientation=this.getAttribute("orientation")||"horizontal";this.classList.add("c-divider--"+orientation);const label=this.getAttribute("label");if(label){const l=this.ensure(".c-divider__label",()=>{const el=document.createElement("span");el.className="c-divider__label";return el});l.textContent=label}}}define("contour-divider",ContourDivider);class ContourStatusLight extends ContourBase{static get observed(){return["status","label"]}static get properties(){return{status:{attribute:"status"},label:{attribute:"label"}}}render(){this.classList.add("c-status-light");const status=this.getAttribute("status")||"neutral";this.classList.add("c-status-light--"+status);if(!this.hasAttribute("role"))this.setAttribute("role","img");const label=this.getAttribute("label");if(label&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label);else if(!label&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",status);if(label){const l=this.ensure(".c-status-light__label",()=>{const el=document.createElement("span");el.className="c-status-light__label";return el});l.textContent=label}}}define("contour-status-light",ContourStatusLight);class ContourSplitButton extends ContourBase{static get observed(){return["label","menu"]}static get properties(){return{label:{attribute:"label"},menu:{attribute:"menu"}}}render(){this.classList.add("c-split-button");const main=this.ensure(".c-split-button__main",()=>{const el=document.createElement("button");el.className="c-btn c-split-button__main";el.type="button";return el});main.textContent=this.getAttribute("label")||"Action";const toggle=this.ensure(".c-split-button__toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--icon c-split-button__toggle";el.type="button";el.setAttribute("aria-label","More options");el.textContent="▾";return el});const menu=this.ensure(".c-split-button__menu",()=>{const el=document.createElement("div");el.className="c-menu c-split-button__menu";el.setAttribute("role","menu");el.hidden=true;return el});if(!menu.id)menu.id=(this.id||contourId("split"))+"-menu";toggle.setAttribute("aria-haspopup","menu");toggle.setAttribute("aria-controls",menu.id);toggle.setAttribute("aria-expanded",String(!menu.hidden));const items=this.getAttribute("menu");if(items){try{const parsed=JSON.parse(items);menu.innerHTML="";parsed.forEach((it)=>{const li=document.createElement("button");li.className="c-menu__item";li.setAttribute("role","menuitem");li.textContent=typeof it==="string"?it:(it.label||it.title||"");menu.appendChild(li)})}catch(e){warnBadJson(this,"attribute",e)}}if(main.parentNode!==this)this.appendChild(main);if(toggle.parentNode!==this)this.appendChild(toggle);if(menu.parentNode!==this)this.appendChild(menu)}enhance(){if(this._wiredSplitButton)return;this._wiredSplitButton=true;const toggle=()=>this.querySelector(".c-split-button__toggle");const menu=()=>this.querySelector(".c-split-button__menu");const items=()=>Array.from(menu()?.querySelectorAll(".c-menu__item")||[]);const setOpen=(open,focusFirst)=>{const m=menu();const t=toggle();if(!m)return;const was=!m.hidden;m.hidden=!open;if(t)t.setAttribute("aria-expanded",String(open));if(open&&focusFirst){const first=items()[0];if(first)try{first.focus()}catch(e){}}if(was!==open)this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{open}}))};this.addEventListener("click",(e)=>{const main=e.target&&e.target.closest?e.target.closest(".c-split-button__main"):null;if(main&&this.contains(main)){this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true,detail:{label:main.textContent}}));return}const t=toggle();if(e.target===t||(t&&t.contains(e.target))){const m=menu();setOpen(m?m.hidden:false,true);return}const item=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;if(item&&this.contains(item)){const index=items().indexOf(item);setOpen(false,false);try{toggle()?.focus()}catch(err){}this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{label:item.textContent,index}}))}});this.addEventListener("keydown",(e)=>{const t=toggle();const m=menu();const list=items();const onToggle=e.target===t||(t&&t.contains(e.target));const idx=list.indexOf(e.target);if(onToggle&&(e.key==="Enter"||e.key===" "||e.key==="ArrowDown")){e.preventDefault();setOpen(true,true)}else if(onToggle&&e.key==="ArrowUp"){e.preventDefault();setOpen(true,false);const last=list[list.length-1];if(last)try{last.focus()}catch(err){}}else if(idx>=0){if(e.key==="ArrowDown"){e.preventDefault();list[(idx+1)%list.length]?.focus()}else if(e.key==="ArrowUp"){e.preventDefault();list[(idx-1+list.length)%list.length]?.focus()}else if(e.key==="Home"){e.preventDefault();list[0]?.focus()}else if(e.key==="End"){e.preventDefault();list[list.length-1]?.focus()}else if(e.key==="Escape"){e.preventDefault();setOpen(false,false);try{t?.focus()}catch(err){}}}else if(e.key==="Escape"&&m&&!m.hidden){setOpen(false,false);try{t?.focus()}catch(err){}}});const docClick=(e)=>{const m=menu();if(m&&!m.hidden&&!this.contains(e.target))setOpen(false,false)};document.addEventListener("click",docClick);onDispose(this,()=>document.removeEventListener("click",docClick))}}define("contour-split-button",ContourSplitButton);class ContourPaletteEditor extends ContourBase{static get observed(){return["colors"]}static get properties(){return{colors:{attribute:"colors"}}}_palette(){let parsed=[];try{const c=this.getAttribute("colors");parsed=c?JSON.parse(c):[]}catch(e){warnBadJson(this,"colors",e)}if(!Array.isArray(parsed))parsed=[];return parsed.map((c)=>typeof c==="string"?{color:c,name:c}:{color:String(c.color||c.value||"#000000"),name:String(c.name||c.label||c.color||c.value||"color")})}_writePalette(entries){this.setAttribute("colors",JSON.stringify(entries.map((e)=>e.name===e.color?e.color:{color:e.color,name:e.name})))}render(){this.classList.add("c-palette-editor");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Palette editor");const entries=this._palette();Array.from(this.querySelectorAll(".c-palette-editor__swatch, .c-palette-editor__edit, .c-palette-editor__remove, .c-palette-editor__add, .c-palette-editor__contrast")).forEach((n)=>n.remove());entries.forEach((entry,i)=>{const sw=document.createElement("button");sw.className="c-palette-editor__swatch c-swatch"+(this._paletteSelected===i?" is-selected":"");sw.type="button";sw.style.background=safeColor(entry.color);sw.dataset.color=entry.color;sw.dataset.index=String(i);sw.setAttribute("aria-label",entry.name);sw.setAttribute("aria-pressed",String(this._paletteSelected===i));this.appendChild(sw);const edit=document.createElement("input");edit.type="color";edit.className="c-palette-editor__edit";edit.value=/^#[0-9a-f]{6}$/i.test(entry.color)?entry.color:"#000000";edit.dataset.index=String(i);edit.setAttribute("aria-label","Edit "+entry.name);this.appendChild(edit);const rm=document.createElement("button");rm.type="button";rm.className="c-palette-editor__remove";rm.dataset.index=String(i);rm.setAttribute("aria-label","Remove "+entry.name);rm.textContent="×";this.appendChild(rm)});const add=document.createElement("button");add.type="button";add.className="c-palette-editor__add";add.setAttribute("aria-label",labelText(this,"add-color","Add color"));add.textContent="+";this.appendChild(add);const sel=entries[this._paletteSelected];if(sel){const lum=(hex)=>{const m=/^#([0-9a-f]{6})$/i.exec(hex);if(!m)return null;const n=parseInt(m[1],16);const ch=[(n>>16)&255,(n>>8)&255,n&255].map((v)=>{v/=255;return v<=0.03928?v/12.92:Math.pow((v+0.055)/1.055,2.4)});return 0.2126*ch[0]+0.7152*ch[1]+0.0722*ch[2]};const l=lum(sel.color);const out=document.createElement("span");out.className="c-palette-editor__contrast";if(l===null){out.textContent=sel.color}else{const ratio=(a,b)=>(Math.max(a,b)+0.05)/(Math.min(a,b)+0.05);const onWhite=ratio(l,1),onBlack=ratio(l,0);const best=Math.max(onWhite,onBlack);out.textContent=sel.name+": "+onWhite.toFixed(1)+":1 on white, "+onBlack.toFixed(1)+":1 on black — "+(best>=4.5?"AA":"below AA")}this.appendChild(out)}}enhance(){if(this._wiredPaletteEditor)return;this._wiredPaletteEditor=true;this.addEventListener("click",(e)=>{const t=e.target&&e.target.closest?e.target:null;if(!t)return;const sw=t.closest(".c-palette-editor__swatch");if(sw&&this.contains(sw)){this._paletteSelected=Number(sw.dataset.index);this.requestRender();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{color:sw.dataset.color}}));return}const rm=t.closest(".c-palette-editor__remove");if(rm&&this.contains(rm)){const entries=this._palette();const i=Number(rm.dataset.index);const[gone]=entries.splice(i,1);if(this._paletteSelected>=entries.length)this._paletteSelected=entries.length-1;this._writePalette(entries);this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:true,composed:true,detail:{value:gone?gone.color:""}}));return}if(t.closest(".c-palette-editor__add")){const entries=this._palette();const next="#888888";entries.push({color:next,name:next});this._paletteSelected=entries.length-1;this._writePalette(entries);this.dispatchEvent(new CustomEvent("contour:add",{bubbles:true,composed:true,detail:{value:next}}))}});this.addEventListener("change",(e)=>{const edit=e.target&&e.target.closest?e.target.closest(".c-palette-editor__edit"):null;if(!edit||!this.contains(edit))return;const entries=this._palette();const i=Number(edit.dataset.index);if(!entries[i])return;entries[i].color=edit.value;if(entries[i].name===entries[i].color||/^#[0-9a-f]{6}$/i.test(entries[i].name))entries[i].name=edit.value;this._writePalette(entries);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{color:edit.value,values:entries.map((en)=>en.color)}}))});this.addEventListener("keydown",(e)=>{const swatches=Array.from(this.querySelectorAll(".c-palette-editor__swatch"));if(!swatches.includes(e.target))return;navKey(e,swatches,{wrap:true,enter:true,onKey:(k,idx,item)=>{if(k==="Enter"||k===" ")item.click()}})})}}define("contour-palette-editor",ContourPaletteEditor);class ContourDateRange extends ContourBase{static get observed(){return["start","end","label","time","min","max","locale","name","required","disabled"]}static get properties(){return{start:{attribute:"start"},end:{attribute:"end"},label:{attribute:"label"},time:{attribute:"time",type:Boolean},min:{attribute:"min"},max:{attribute:"max"},locale:{attribute:"locale"},name:{attribute:"name"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean}}}static get formAssociated(){return true}render(){this.classList.add("c-date-range");if(this._dateRangeDefaultStart===undefined){this._dateRangeDefaultStart=this.getAttribute("start");this._dateRangeDefaultEnd=this.getAttribute("end")}this.setAttribute("role","group");this.setAttribute("aria-label",this.getAttribute("label")||"Date range");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-date-range__label",()=>{const el=document.createElement("span");el.className="c-date-range__label";return el});l.textContent=label}const start=this.ensure(".c-date-range__start",()=>{const el=document.createElement("input");el.className="c-input c-date-range__start";return el});start.type=this.hasAttribute("time")?"datetime-local":"date";start.value=this.getAttribute("start")||"";start.setAttribute("aria-label",label?label+" — start":"Start date");const end=this.ensure(".c-date-range__end",()=>{const el=document.createElement("input");el.className="c-input c-date-range__end";return el});end.type=start.type;end.value=this.getAttribute("end")||"";end.setAttribute("aria-label",label?label+" — end":"End date");const min=this.getAttribute("min");const max=this.getAttribute("max");[start,end].forEach((input)=>{if(min)input.min=min;else input.removeAttribute("min");if(max)input.max=max;else input.removeAttribute("max");if(this.getAttribute("locale"))input.lang=this.getAttribute("locale");if(this.hasAttribute("disabled"))input.setAttribute("disabled","");else input.removeAttribute("disabled")});if(start.value)end.min=min&&min>start.value?min:start.value;if(end.value)start.max=max&&max<end.value?max:end.value;if(this.hasAttribute("required"))this.setAttribute("aria-required","true");else this.removeAttribute("aria-required");if(this._internals)this._syncFormValue()}enhance(){if(this._wiredDateRange)return;this._wiredDateRange=true;this.addEventListener("change",(e)=>{const t=e.target;if(t&&(t.classList.contains("c-date-range__start")||t.classList.contains("c-date-range__end"))){const s=this.querySelector(".c-date-range__start");const en=this.querySelector(".c-date-range__end");this.batch(()=>{if(s)this.setAttribute("start",s.value);if(en)this.setAttribute("end",en.value)});this._syncFormValue();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{start:s?.value,end:en?.value}}))}})}_syncFormValue(){if(!this._internals)return;const start=this.querySelector(".c-date-range__start")?.value||"";const end=this.querySelector(".c-date-range__end")?.value||"";const name=this.getAttribute("name");if(name&&(start||end)){const fd=new FormData();if(start)fd.append(name,start);if(end)fd.append(name,end);this._internals.setFormValue(fd)}else{this._internals.setFormValue(null)}const missing=this.hasAttribute("required")&&(!start||!end);const inverted=!!(start&&end&&start>end);if(missing)this._internals.setValidity({valueMissing:true},"Both dates are required.");else if(inverted)this._internals.setValidity({customError:true},"Start must be on or before end.");else this._internals.setValidity({});this._setCustomState("data-invalid",missing||inverted);for(const input of this.querySelectorAll("input"))input.setAttribute("aria-invalid",String(missing||inverted))}formResetCallback(){this._contourResetting=true;try{if(this._dateRangeDefaultStart===null)this.removeAttribute("start");else this.setAttribute("start",this._dateRangeDefaultStart);if(this._dateRangeDefaultEnd===null)this.removeAttribute("end");else this.setAttribute("end",this._dateRangeDefaultEnd);this._syncFormValue()}finally{this._contourResetting=false}}formStateRestoreCallback(state){if(!this._internals||state==null)return;const values=state instanceof FormData?Array.from(state.getAll(this.getAttribute("name"))).map(String):String(state).split(",");this._contourResetting=true;try{this.setAttribute("start",values[0]||"");this.setAttribute("end",values[1]||"");this._syncFormValue()}finally{this._contourResetting=false}}}define("contour-date-range",ContourDateRange);class ContourShortcut extends ContourBase{static get observed(){return["key","label"]}static get properties(){return{key:{attribute:"key"},label:{attribute:"label"}}}render(){this.classList.add("c-shortcut");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"Keyboard shortcut");const key=this.getAttribute("key")||"";const label=this.getAttribute("label")||"";if(key){const k=this.ensure(".c-shortcut__key",()=>{const el=document.createElement("kbd");el.className="c-shortcut__key";return el});k.textContent=key}if(label){const l=this.ensure(".c-shortcut__label",()=>{const el=document.createElement("span");el.className="c-shortcut__label";return el});l.textContent=label}}enhance(){if(this._wiredShortcut)return;this._wiredShortcut=true;const key=this.getAttribute("key");if(key){const handler=(e)=>{if(e.key===key&&(e.metaKey||e.ctrlKey)){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}};document.addEventListener("keydown",handler);onDispose(this,()=>document.removeEventListener("keydown",handler))}}}define("contour-shortcut",ContourShortcut);class ContourPopover extends ContourBase{static get observed(){return["title","content"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"}}}render(){this.classList.add("c-popover");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Popover");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("popover");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-popover__title",()=>{const el=document.createElement("div");el.className="c-popover__title";return el});t.textContent=title}const content=this.getAttribute("content");if(content){const c=this.ensure(".c-popover__body",()=>{const el=document.createElement("div");el.className="c-popover__body";return el});c.textContent=content}}enhance(){if(this._wiredPopover)return;this._wiredPopover=true;const close=()=>{try{this.hidePopover()}catch(e){}this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))};const keyHandler=(e)=>{const open=this.classList.contains("is-open")||this.matches(":popover-open");if(!open)return;if(e.key==="Escape"){e.preventDefault();close();return}if(e.key==="Tab"){const focusable=Array.from(this.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(!focusable.length){e.preventDefault();return}const first=focusable[0];const last=focusable[focusable.length-1];if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus()}else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus()}}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("contour:show",(e)=>{if(e.target&&e.target!==this&&this.contains(e.target)){this.classList.add("is-parent")}});this.addEventListener("contour:close",(e)=>{if(e.target&&e.target!==this){this.classList.remove("is-parent")}});this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-popover__close"):null;if(btn&&this.contains(btn))close()})}}define("contour-popover",ContourPopover);class ContourDatePicker extends ContourBase{static get formAssociated(){return true}static get observed(){return["value","range","range-start","range-end","label","disabled","error","help","time","min","max","locale"]}static get properties(){return{value:{attribute:"value"},range:{attribute:"range",type:Boolean},rangeStart:{attribute:"range-start"},rangeEnd:{attribute:"range-end"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},time:{attribute:"time",type:Boolean},min:{attribute:"min"},max:{attribute:"max"},locale:{attribute:"locale"}}}render(){this.classList.add("c-date-picker");this.setAttribute("role","group");this.setAttribute("aria-label","Date picker");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-date-picker__label",()=>{const el=document.createElement("label");el.className="c-date-picker__label";return el});l.textContent=label}const input=this.ensure(".c-date-picker__input",()=>{const el=document.createElement("input");el.className="c-input c-date-picker__input";return el});const range=this.hasAttribute("range");const type=this.hasAttribute("time")?"datetime-local":"date";const configure=(control,value,name)=>{control.type=type;const next=value||"";if(document.activeElement!==control&&control.value!==next)control.value=next;control.setAttribute("aria-label",name);if(this.hasAttribute("min"))control.min=this.getAttribute("min");else control.removeAttribute("min");if(this.hasAttribute("max"))control.max=this.getAttribute("max");else control.removeAttribute("max");if(this.hasAttribute("locale"))control.lang=this.getAttribute("locale");else control.removeAttribute("lang");if(this.hasAttribute("disabled"))control.setAttribute("disabled","");else control.removeAttribute("disabled")};configure(input,range?this.getAttribute("range-start"):this.getAttribute("value"),range?"Start date":(label||"Date"));let end=this.querySelector(".c-date-picker__end");if(range){end=end||document.createElement("input");end.className="c-input c-date-picker__input c-date-picker__end";configure(end,this.getAttribute("range-end"),"End date");if(end.parentNode!==this)this.appendChild(end)}else if(end)end.remove();if(this.hasAttribute("disabled"))this.classList.add("is-disabled");else this.classList.remove("is-disabled");const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-date-picker__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-date-picker__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-date-picker__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}}_renderCalendar(){const cal=this.querySelector(".c-date-picker__calendar");if(!cal)return;const input=this.querySelector(".c-date-picker__input");const base=(input&&input.value)?new Date(input.value):new Date();const month=this._calMonth||new Date(base.getFullYear(),base.getMonth(),1);this._calMonth=month;const y=month.getFullYear();const m=month.getMonth();const first=new Date(y,m,1);const startDay=first.getDay();const daysInMonth=new Date(y,m+1,0).getDate();cal.innerHTML="";const header=document.createElement("div");header.className="c-date-picker__calendar-header";const prev=document.createElement("button");prev.type="button";prev.className="c-btn c-btn--sm";prev.textContent="‹";prev.setAttribute("aria-label","Previous month");const title=document.createElement("span");title.className="c-date-picker__calendar-title";title.textContent=month.toLocaleString(this.getAttribute("locale")||undefined,{month:"long",year:"numeric"});const next=document.createElement("button");next.type="button";next.className="c-btn c-btn--sm";next.textContent="›";next.setAttribute("aria-label","Next month");header.appendChild(prev);header.appendChild(title);header.appendChild(next);cal.appendChild(header);const grid=document.createElement("div");grid.className="c-date-picker__calendar-grid";grid.setAttribute("role","grid");grid.setAttribute("aria-label",title.textContent);const rowEl=()=>{const row=document.createElement("div");row.className="c-date-picker__calendar-row";row.setAttribute("role","row");grid.appendChild(row);return row};let row=rowEl();let cells=0;const push=(cell)=>{if(cells===7){row=rowEl();cells=0}row.appendChild(cell);cells++};const weekdays=["Su","Mo","Tu","We","Th","Fr","Sa"];const weekdayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];weekdays.forEach((w,i)=>{const h=document.createElement("div");h.className="c-date-picker__calendar-weekday";h.setAttribute("role","columnheader");h.setAttribute("aria-label",weekdayNames[i]);h.textContent=w;push(h)});for(let i=0;i<startDay;i++){const empty=document.createElement("div");empty.className="c-date-picker__calendar-day c-date-picker__calendar-day--empty";empty.setAttribute("role","gridcell");empty.setAttribute("aria-hidden","true");push(empty)}const selected=input?input.value:"";const inMonth=selected&&selected.slice(0,7)===`${y}-${String(m + 1).padStart(2, "0")}`;const stopDay=inMonth?parseInt(selected.slice(8,10),10)||1:1;for(let d=1;d<=daysInMonth;d++){const btn=document.createElement("button");btn.type="button";btn.className="c-date-picker__calendar-day";btn.textContent=String(d);btn.setAttribute("role","gridcell");btn.setAttribute("tabindex",d===stopDay?"0":"-1");btn.setAttribute("aria-label",new Date(y,m,d).toLocaleDateString(this.getAttribute("locale")||undefined,{weekday:"long",day:"numeric",month:"long",year:"numeric"}));const iso=`${y}-${String(m + 1).padStart(2, "0")}-${String(d).padStart(2, "0")}`;if(selected&&selected.startsWith(iso)){btn.classList.add("is-selected");btn.setAttribute("aria-selected","true")}btn.addEventListener("click",()=>{if(input){input.value=iso;input.dispatchEvent(new Event("change",{bubbles:true}))}cal.setAttribute("hidden","");const tgl=this.querySelector(".c-date-picker__calendar-toggle");if(tgl)tgl.setAttribute("aria-expanded","false")});push(btn)}cal.appendChild(grid);prev.addEventListener("click",()=>{this._calMonth=new Date(y,m-1,1);this._renderCalendar()});next.addEventListener("click",()=>{this._calMonth=new Date(y,m+1,1);this._renderCalendar()});if(this._internals)this._syncFormValue()}_syncFormValue(){if(!this._internals)return;const start=this.querySelector(".c-date-picker__input");const end=this.querySelector(".c-date-picker__end");if(this.hasAttribute("range")&&end){this._internals.setFormValue((start?start.value:"")+","+end.value)}else{this._internals.setFormValue(start&&start.value?start.value:null)}this._syncValidity(this.hasAttribute("required")&&!(start&&start.value))}enhance(){if(this._wiredDatePicker)return;this._wiredDatePicker=true;this._syncFormValue();this.addEventListener("change",()=>{this._syncFormValue()});this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-date-picker__input")){const end=this.querySelector(".c-date-picker__end");const detail=end?{start:this.querySelector(".c-date-picker__input").value,end:end.value}:{value:t.value};this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail}))}});const toggle=()=>{const cal=this.querySelector(".c-date-picker__calendar");const btn=this.querySelector(".c-date-picker__calendar-toggle");if(!cal)return;const hidden=cal.hasAttribute("hidden");if(hidden){cal.removeAttribute("hidden");if(btn)btn.setAttribute("aria-expanded","true");this._renderCalendar()}else{cal.setAttribute("hidden","");if(btn)btn.setAttribute("aria-expanded","false")}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-date-picker__calendar-toggle"):null;if(btn&&this.contains(btn)){e.preventDefault();toggle()}});this.addEventListener("keydown",(e)=>{const cal=this.querySelector(".c-date-picker__calendar");if(!cal||cal.hasAttribute("hidden"))return;const cells=Array.from(cal.querySelectorAll('[role="gridcell"]:not([aria-hidden="true"])'));const i=cells.indexOf(document.activeElement);if(i<0)return;if(e.key==="PageUp"||e.key==="PageDown"){e.preventDefault();const btn=this.querySelector(e.key==="PageUp"?".c-date-picker__calendar-header button:first-child":".c-date-picker__calendar-header button:last-child");if(btn)btn.click();return}let next=-1;if(e.key==="ArrowRight")next=i+1;else if(e.key==="ArrowLeft")next=i-1;else if(e.key==="ArrowDown")next=i+7;else if(e.key==="ArrowUp")next=i-7;else if(e.key==="Home")next=0;else if(e.key==="End")next=cells.length-1;else return;e.preventDefault();if(next<0||next>=cells.length)return;cells.forEach((cell,j)=>cell.setAttribute("tabindex",j===next?"0":"-1"));cells[next].focus()})}}define("contour-date-picker",ContourDatePicker);class ContourRating extends ContourBase{static get observed(){return["value","max","color"]}static get properties(){return{value:{attribute:"value",type:Number},max:{attribute:"max",type:Number},color:{attribute:"color"}}}render(){this.classList.add("c-rating");if(!this.hasAttribute("role"))this.setAttribute("role","radiogroup");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Rating");const max=parseInt(this.getAttribute("max")||"5",10)||5;const value=parseInt(this.getAttribute("value")||"0",10)||0;const color=this.getAttribute("color");Array.from(this.querySelectorAll(".c-rating__star")).forEach((n)=>n.remove());const stop=value>=1&&value<=max?value:1;for(let i=1;i<=max;i++){const star=document.createElement("button");star.className="c-rating__star"+(i<=value?" c-rating__star--filled":"");star.type="button";star.setAttribute("role","radio");star.setAttribute("aria-checked",String(i===value));star.setAttribute("tabindex",String(i===stop?0:-1));star.innerHTML='<span class="c-rating__swatch'+(i<=value?' c-rating__swatch--filled':'')+'" aria-hidden="true"></span>';if(color&&i<=value){const sw=star.firstChild;const safe=safeColor(color);if(sw&&safe){sw.style.backgroundColor=safe;sw.style.borderColor=safe}}star.dataset.value=String(i);star.setAttribute("aria-label",i+" star"+(i>1?"s":""));this.appendChild(star)}}enhance(){if(this._wiredRating)return;this._wiredRating=true;const stars=()=>Array.from(this.querySelectorAll(".c-rating__star"));const select=(v)=>{stars().forEach((st)=>{const on=parseInt(st.dataset.value,10)===v;st.setAttribute("aria-checked",String(on));st.setAttribute("tabindex",on?"0":"-1");st.classList.toggle("c-rating__star--filled",parseInt(st.dataset.value,10)<=v);const sw=st.querySelector(".c-rating__swatch");if(sw)sw.classList.toggle("c-rating__swatch--filled",parseInt(st.dataset.value,10)<=v)});this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:v}}))};this.addEventListener("click",(e)=>{const star=e.target&&e.target.closest?e.target.closest(".c-rating__star"):null;if(star&&this.contains(star))select(parseInt(star.dataset.value,10))});this.addEventListener("keydown",(e)=>{const all=stars();if(!all.length)return;navKey(e,all,{wrap:false,homeEnd:true,onNavigate:(i)=>{select(parseInt(all[i].dataset.value,10))},onKey:(key,i)=>{if(key==="Enter"||key===" ")select(parseInt(all[i].dataset.value,10))},})})}}define("contour-rating",ContourRating);class ContourTimePicker extends ContourBase{static get formAssociated(){return true}static get observed(){return["value","label","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-time-picker");this.setAttribute("role","group");this.setAttribute("aria-label","Time picker");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-time-picker__label",()=>{const el=document.createElement("label");el.className="c-time-picker__label";return el});l.textContent=label}const input=this.ensure(".c-time-picker__input",()=>{const el=document.createElement("input");el.className="c-input c-time-picker__input";el.type="time";el.setAttribute("aria-label",this.getAttribute("label")||"Time picker");return el});input.value=this.getAttribute("value")||"";if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-time-picker__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-time-picker__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-time-picker__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}if(this._internals)this._syncFormValue()}enhance(){if(this._wiredTimePicker)return;this._wiredTimePicker=true;this._syncFormValue();this.addEventListener("change",()=>{this._syncFormValue()});this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-time-picker__input")){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:t.value}}))}})}}define("contour-time-picker",ContourTimePicker);class ContourColorPicker extends ContourBase{static get formAssociated(){return true}static get observed(){return["value","label","disabled","error","help","alpha","presets"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},alpha:{attribute:"alpha",type:Boolean},presets:{attribute:"presets"}}}render(){this.classList.add("c-color-picker");this.setAttribute("role","group");this.setAttribute("aria-label","Color picker");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-color-picker__label",()=>{const el=document.createElement("label");el.className="c-color-picker__label";return el});l.textContent=label}const input=this.ensure(".c-color-picker__input",()=>{const el=document.createElement("input");el.className="c-color-picker__input";el.type="color";return el});input.value=(this.getAttribute("value")||"#000000").slice(0,7);if(!input.hasAttribute("aria-label"))input.setAttribute("aria-label",label||"Color");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}if(this.hasAttribute("alpha")){const alpha=this.ensure(".c-color-picker__alpha",()=>{const el=document.createElement("input");el.className="c-color-picker__alpha";el.type="range";el.min="0";el.max="1";el.step="0.01";return el});const v=this.getAttribute("value")||"#000000";const a=v.length===9?parseInt(v.slice(7,9),16)/255:1;alpha.value=String(a);alpha.setAttribute("aria-label","Alpha")}else{const a=this.querySelector(".c-color-picker__alpha");if(a)a.remove()}const presetsAttr=this.getAttribute("presets");let presets=[];if(presetsAttr){try{presets=JSON.parse(presetsAttr)}catch(e){presets=[]}}const oldPresets=this.querySelector(".c-color-picker__presets");if(oldPresets)oldPresets.remove();if(Array.isArray(presets)&&presets.length){const wrap=document.createElement("div");wrap.className="c-color-picker__presets";presets.forEach((c)=>{const btn=document.createElement("button");btn.type="button";btn.className="c-color-picker__preset";btn.style.background=c;btn.dataset.color=c;btn.setAttribute("aria-label",labelText(this,"preset","Preset")+" "+c);wrap.appendChild(btn)});this.appendChild(wrap)}if(typeof window!=="undefined"&&"EyeDropper"in window){const ed=this.ensure(".c-color-picker__eyedropper",()=>{const el=document.createElement("button");el.className="c-color-picker__eyedropper";el.type="button";el.textContent=labelText(this,"pick","Pick");el.setAttribute("aria-label",labelText(this,"pick-color","Pick color from screen"));return el});if(this.hasAttribute("disabled"))ed.setAttribute("disabled","");else ed.removeAttribute("disabled")}else{const ed=this.querySelector(".c-color-picker__eyedropper");if(ed)ed.remove()}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-color-picker__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-color-picker__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-color-picker__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}if(this._internals)this._syncFormValue()}enhance(){if(this._wiredColorPicker)return;this._wiredColorPicker=true;this._syncFormValue();this.addEventListener("change",()=>{this._syncFormValue()});this.addEventListener("contour:change",()=>{this._syncFormValue()});this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-color-picker__input")){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:t.value}}))}if(t&&t.classList.contains("c-color-picker__alpha")){const base=(this.getAttribute("value")||"#000000").slice(0,7);const a=Math.round(parseFloat(t.value)*255).toString(16).padStart(2,"0");const val=base+a;this.setAttribute("value",val);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:val}}))}});this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-color-picker__preset"):null;if(btn&&this.contains(btn)){const c=btn.dataset.color;if(c){this.setAttribute("value",c);const input=this.querySelector(".c-color-picker__input");if(input)input.value=c.slice(0,7);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:c}}))}}const ed=e.target&&e.target.closest?e.target.closest(".c-color-picker__eyedropper"):null;if(ed&&this.contains(ed)&&typeof window!=="undefined"&&"EyeDropper"in window){e.preventDefault();const dropper=new window.EyeDropper();dropper.open().then((r)=>{if(r&&r.sRGBHex){this.setAttribute("value",r.sRGBHex);const input=this.querySelector(".c-color-picker__input");if(input)input.value=r.sRGBHex;this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:r.sRGBHex}}))}}).catch(()=>{})}})}}define("contour-color-picker",ContourColorPicker);class ContourNumberField extends ContourBase{static get formAssociated(){return true}static get observed(){return["value","min","max","step","label","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},min:{attribute:"min"},max:{attribute:"max"},step:{attribute:"step"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-number-field");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-number-field__label",()=>{const el=document.createElement("label");el.className="c-number-field__label";return el});l.textContent=label}const input=this.ensure(".c-number-field__input",()=>{const el=document.createElement("input");el.className="c-input c-number-field__input";el.type="number";el.setAttribute("role","spinbutton");return el});if(this.getAttribute("value")!==null)input.value=this.getAttribute("value");if(this.getAttribute("min")!==null)input.min=this.getAttribute("min");if(this.getAttribute("max")!==null)input.max=this.getAttribute("max");if(this.getAttribute("step")!==null)input.step=this.getAttribute("step");const v=input.value;input.setAttribute("aria-valuenow",v===""?"":v);if(input.min!=="")input.setAttribute("aria-valuemin",input.min);if(input.max!=="")input.setAttribute("aria-valuemax",input.max);if(!input.hasAttribute("aria-label"))input.setAttribute("aria-label",label||"Number");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-number-field__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-number-field__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-number-field__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}if(this._internals)this._syncFormValue()}enhance(){if(this._wiredNumberField)return;this._wiredNumberField=true;this._syncFormValue();this.addEventListener("change",()=>{this._syncFormValue()});this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-number-field__input")){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:t.value}}))}});this.addEventListener("keydown",(e)=>{const input=this.querySelector(".c-number-field__input");if(!input||document.activeElement!==input)return;const step=Number(input.step)||1;const min=input.min===""?-Infinity:Number(input.min);const max=input.max===""?Infinity:Number(input.max);let next=null;if(e.key==="ArrowUp")next=(Number(input.value)||0)+step;else if(e.key==="ArrowDown")next=(Number(input.value)||0)-step;else if(e.key==="Home")next=min===-Infinity?0:min;else if(e.key==="End")next=max===Infinity?(Number(input.value)||0):max;if(next!==null){e.preventDefault();next=Math.min(max,Math.max(min,next));input.value=String(next);input.setAttribute("aria-valuenow",String(next));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:input.value}}))}})}}define("contour-number-field",ContourNumberField);class ContourHoverCard extends ContourBase{static get observed(){return["title","content","anchor"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"},anchor:{attribute:"anchor"}}}render(){this.classList.add("c-hover-card");if(!this.hasAttribute("role"))this.setAttribute("role","tooltip");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Hover card");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("hover-card");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-hover-card__title",()=>{const el=document.createElement("div");el.className="c-hover-card__title";return el});t.textContent=title}const content=this.getAttribute("content");if(content){const c=this.ensure(".c-hover-card__body",()=>{const el=document.createElement("div");el.className="c-hover-card__body";return el});c.textContent=content}}enhance(){if(this._wiredHoverCard)return;this._wiredHoverCard=true;const anchorSel=this.getAttribute("anchor");if(anchorSel){const trigger=anchorSel.startsWith("#")?document.getElementById(anchorSel.slice(1)):document.querySelector(anchorSel);if(trigger){trigger.setAttribute("popovertarget",this.id);let showTimer=null;const hasPopover=typeof this.showPopover==="function";const show=()=>{if(hasPopover){try{this.showPopover()}catch(e){}}else this.classList.add("is-open");this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))};const hide=()=>{if(showTimer)clearTimeout(showTimer);if(hasPopover){try{this.hidePopover()}catch(e){}}else this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))};const onEnter=()=>{showTimer=setTimeout(show,300)};const onLeave=()=>{hide()};const onFocus=()=>show();const onBlur=()=>{setTimeout(hide,100)};trigger.addEventListener("mouseenter",onEnter);trigger.addEventListener("mouseleave",onLeave);trigger.addEventListener("focus",onFocus);trigger.addEventListener("blur",onBlur);onDispose(this,()=>{if(showTimer){clearTimeout(showTimer);showTimer=null}trigger.removeEventListener("mouseenter",onEnter);trigger.removeEventListener("mouseleave",onLeave);trigger.removeEventListener("focus",onFocus);trigger.removeEventListener("blur",onBlur)})}}const keyHandler=(e)=>{if(e.key==="Escape"&&(this.classList.contains("is-open")||this.matches(":popover-open"))){e.preventDefault();if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(err){}}this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler))}}define("contour-hover-card",ContourHoverCard);class ContourContextMenu extends ContourBase{static get observed(){return["items","trigger"]}static get properties(){return{items:{attribute:"items"},trigger:{attribute:"trigger"}}}render(){this.classList.add("c-context-menu");if(!this.hasAttribute("role"))this.setAttribute("role","menu");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Context menu");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("context-menu");const items=this.getAttribute("items");if(items){try{const parsed=JSON.parse(items);this.innerHTML="";parsed.forEach((it)=>{const btn=document.createElement("button");btn.className="c-menu__item";btn.setAttribute("role","menuitem");btn.textContent=typeof it==="string"?it:(it.label||it.title||"");this.appendChild(btn)})}catch(e){warnBadJson(this,"attribute",e)}}}enhance(){if(this._wiredContextMenu)return;this._wiredContextMenu=true;const openAt=(x,y)=>{if(typeof this.showPopover==="function"){try{this.showPopover()}catch(err){}}else this.classList.add("is-open");if(Number.isFinite(x)&&Number.isFinite(y)){this.style.position="fixed";this.style.left=x+"px";this.style.top=y+"px"}};const triggerSel=this.getAttribute("trigger");if(triggerSel){const trigger=document.querySelector(triggerSel);if(trigger){if(!trigger.hasAttribute("aria-haspopup"))trigger.setAttribute("aria-haspopup","menu");const onCtx=(e)=>{e.preventDefault();openAt(e.clientX,e.clientY)};trigger.addEventListener("contextmenu",onCtx);onDispose(this,()=>trigger.removeEventListener("contextmenu",onCtx))}}this.addEventListener("contextmenu",(e)=>{e.preventDefault();openAt(e.clientX,e.clientY)});this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;if(item&&this.contains(item)){this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{label:item.textContent.trim()}}));if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(err){}}this.classList.remove("is-open")}});this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-menu__item"));navKey(e,items,{wrap:true,onKey:()=>{if(e.key==="Enter"||e.key===" ")document.activeElement.click()}});if(e.key==="Escape"){e.preventDefault();if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(err){}}this.classList.remove("is-open")}})}}define("contour-context-menu",ContourContextMenu);class ContourFab extends ContourBase{static get observed(){return["label","icon"]}static get properties(){return{label:{attribute:"label"},icon:{attribute:"icon"}}}render(){this.classList.add("c-fab");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");const label=this.getAttribute("label");if(label)this.setAttribute("aria-label",label);const icon=this.getAttribute("icon");if(icon&&!this.querySelector("svg")){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href",icon.startsWith("#")?icon:"#"+icon);svg.appendChild(use);this.appendChild(svg)}}enhance(){if(this._wiredFab)return;this._wiredFab=true;this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))});this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}})}}define("contour-fab",ContourFab);class ContourFileUpload extends ContourBase{static get formAssociated(){return true}static get observed(){return["label","accept","multiple","progress","name"]}static get properties(){return{label:{attribute:"label"},accept:{attribute:"accept"},multiple:{attribute:"multiple",type:Boolean},progress:{attribute:"progress"},name:{attribute:"name"}}}render(){this.classList.add("c-file-upload");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"File upload");const label=this.getAttribute("label")||"Drop files here or click to browse";const dz=this.ensure(".c-file-upload__dropzone",()=>{const el=document.createElement("div");el.className="c-file-upload__dropzone";el.setAttribute("role","button");el.tabIndex=0;return el});dz.textContent=label;const input=this.ensure(".c-file-upload__input",()=>{const el=document.createElement("input");el.className="c-file-upload__input";el.type="file";el.hidden=true;return el});input.accept=this.getAttribute("accept")||"";input.multiple=this.hasAttribute("multiple");const p=this.getAttribute("progress");if(p!==null){const bar=this.ensure(".c-file-upload__progress",()=>{const el=document.createElement("progress");el.className="c-file-upload__progress";return el});bar.value=Number(p)||0;bar.max=100}else{const bar=this.querySelector(".c-file-upload__progress");if(bar)bar.remove()}const preview=this.ensure(".c-file-upload__preview",()=>{const el=document.createElement("div");el.className="c-file-upload__preview";return el});if(!preview){}if(this._internals)this._syncFormValue()}enhance(){if(this._wiredFileUpload)return;this._wiredFileUpload=true;this._syncFormValue();this.addEventListener("change",()=>{this._syncFormValue()});const dz=()=>this.querySelector(".c-file-upload__dropzone");const input=()=>this.querySelector(".c-file-upload__input");const activate=()=>{const i=input();if(i)i.click()};this.addEventListener("click",(e)=>{const d=dz();if(e.target===d||(d&&d.contains(e.target))){activate()}});this.addEventListener("keydown",(e)=>{const d=dz();if((e.target===d||(d&&d.contains(e.target)))&&(e.key==="Enter"||e.key===" ")){e.preventDefault();activate()}});const renderPreview=(files)=>{const preview=this.querySelector(".c-file-upload__preview");if(!preview)return;this._revokeObjectUrls();preview.innerHTML="";Array.from(files||[]).forEach((f)=>{const item=document.createElement("div");item.className="c-file-upload__preview-item";if(f.type&&f.type.startsWith("image/")){const img=document.createElement("img");img.className="c-file-upload__preview-thumb";img.alt=f.name;img.loading="lazy";img.decoding="async";try{const u=URL.createObjectURL(f);img.src=u;(this._objectUrls||(this._objectUrls=[])).push(u)}catch(e){}item.appendChild(img)}else{const name=document.createElement("span");name.className="c-file-upload__preview-name";name.textContent=f.name;item.appendChild(name)}preview.appendChild(item)})};this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-file-upload__input")){renderPreview(t.files);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{files:t.files}}))}});this.addEventListener("dragover",(e)=>{e.preventDefault();this.classList.add("is-dragover")});this.addEventListener("dragleave",()=>this.classList.remove("is-dragover"));this.addEventListener("drop",(e)=>{e.preventDefault();this.classList.remove("is-dragover");const i=input();if(i&&e.dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files.length){try{i.files=e.dataTransfer.files}catch(err){}renderPreview(e.dataTransfer.files);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{files:e.dataTransfer.files}}))}})}disconnectedCallback(){super.disconnectedCallback();this._revokeObjectUrls()}_revokeObjectUrls(){if(!this._objectUrls)return;this._objectUrls.forEach((u)=>{try{URL.revokeObjectURL(u)}catch(e){}});this._objectUrls=[]}_syncFormValue(){if(!this._internals)return;const inp=this.querySelector(".c-file-upload__input");if(inp&&inp.files&&inp.files.length){const fd=new FormData();const key=this.getAttribute("name")||"file";Array.from(inp.files).forEach((f)=>fd.append(key,f));this._internals.setFormValue(fd)}else{this._internals.setFormValue(null)}}}define("contour-file-upload",ContourFileUpload);class ContourNotificationCenter extends ContourBase{static get observed(){return["count","items","color"]}static get properties(){return{count:{attribute:"count"},items:{attribute:"items"},color:{attribute:"color"}}}render(){this.classList.add("c-notification-center");this.setAttribute("role","group");const btn=this.ensure(".c-notification-center__trigger",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-notification-center__trigger";el.type="button";el.innerHTML='<span class="c-notification-center__bullet" aria-hidden="true"></span>';el.setAttribute("aria-haspopup","dialog");el.setAttribute("aria-expanded","false");el.setAttribute("aria-label","Notifications");return el});const color=this.getAttribute("color");const bullet=btn.querySelector(".c-notification-center__bullet");if(bullet&&color){bullet.style.background=safeColor(color);bullet.dataset.color=color}const panel=this.ensure(".c-notification-center__panel",()=>{const el=document.createElement("div");el.className="c-notification-center__panel";el.hidden=true;el.setAttribute("role","dialog");el.setAttribute("aria-label","Notifications");return el});panel.hidden=!this._notifOpen;btn.setAttribute("aria-expanded",String(!!this._notifOpen));const authoredItems=Array.from(this.querySelectorAll(":scope > .c-notification-center__item"));const items=this.getAttribute("items");if(authoredItems.length){panel.innerHTML="";const lb=document.createElement("div");lb.setAttribute("role","listbox");lb.setAttribute("aria-label","Notifications");authoredItems.forEach((it)=>{lb.appendChild(it)});panel.appendChild(lb)}else if(items){let parsed=null;try{parsed=JSON.parse(items)}catch(e){warnBadJson(this,"items",e)}panel.innerHTML="";if(!Array.isArray(parsed)){const err=document.createElement("div");err.className="c-notification-center__error";err.setAttribute("role","alert");err.textContent=labelText(this,"error","Could not load notifications");panel.appendChild(err)}else{const lb=document.createElement("div");lb.setAttribute("role","listbox");lb.setAttribute("aria-label","Notifications");const shown=this._notifShown||50;parsed.slice(0,shown).forEach((it)=>{const row=document.createElement("div");row.className="c-notification-center__item"+(it&&it.read?" is-read":"");row.setAttribute("tabindex","-1");row.setAttribute("role","option");row.setAttribute("aria-selected","false");row.dataset.read=it&&it.read?"true":"false";const label=document.createElement("span");label.className="c-notification-center__item-label";label.textContent=typeof it==="string"?it:(it.text||it.title||"");row.appendChild(label);const archive=document.createElement("button");archive.type="button";archive.className="c-notification-center__archive";archive.setAttribute("aria-label",labelText(this,"archive","Archive notification"));archive.textContent="⤓";row.appendChild(archive);const dismiss=document.createElement("button");dismiss.type="button";dismiss.className="c-notification-center__dismiss";dismiss.setAttribute("aria-label",labelText(this,"dismiss","Dismiss notification"));dismiss.textContent="×";row.appendChild(dismiss);lb.appendChild(row)});const firstRow=lb.querySelector(".c-notification-center__item");if(firstRow)firstRow.tabIndex=0;panel.appendChild(lb);if(!parsed.length){const empty=document.createElement("div");empty.className="c-notification-center__empty";empty.textContent=labelText(this,"empty","No notifications");panel.appendChild(empty)}else if(parsed.length>shown){const more=document.createElement("button");more.type="button";more.className="c-btn c-btn--sm c-notification-center__more";more.textContent=labelText(this,"more","Show more")+" ("+(parsed.length-shown)+")";panel.appendChild(more)}}}this._syncNotifBadge()}_syncNotifBadge(){const btn=this.querySelector(".c-notification-center__trigger");if(!btn)return;const rows=Array.from(this.querySelectorAll(".c-notification-center__item"));let unread;if(this._notifInteracted||!this.hasAttribute("count"))unread=rows.filter((r)=>r.dataset.read!=="true").length;else unread=Number(this.getAttribute("count"))||0;let badge=btn.querySelector(".c-notification-center__badge");if(unread>0){if(!badge){badge=document.createElement("span");badge.className="c-notification-center__badge c-badge c-badge--dot";btn.appendChild(badge)}badge.textContent=String(unread)}else if(badge){badge.remove()}}enhance(){if(this._wiredNotifCenter)return;this._wiredNotifCenter=true;const activate=(item)=>{if(item.dataset.read!=="true"){item.dataset.read="true";item.classList.add("is-read");this._notifInteracted=true;this._syncNotifBadge();this.dispatchEvent(new CustomEvent("contour:read",{bubbles:true,composed:true,detail:{label:item.querySelector(".c-notification-center__item-label")?.textContent||item.textContent}}))}for(const r of this.querySelectorAll(".c-notification-center__item"))r.setAttribute("aria-selected",String(r===item));this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{label:item.querySelector(".c-notification-center__item-label")?.textContent||item.textContent}}))};const removeRow=(item,kind)=>{const label=item.querySelector(".c-notification-center__item-label")?.textContent||item.textContent;item.remove();this._notifInteracted=true;this._syncNotifBadge();this.dispatchEvent(new CustomEvent(kind==="archive"?"contour:remove":"contour:dismiss",{bubbles:true,composed:true,detail:{label}}))};this.addEventListener("click",(e)=>{const btn=this.querySelector(".c-notification-center__trigger");const panel=this.querySelector(".c-notification-center__panel");if(btn&&(e.target===btn||btn.contains(e.target))){if(panel){panel.hidden=!panel.hidden;this._notifOpen=!panel.hidden;btn.setAttribute("aria-expanded",String(!panel.hidden));this.dispatchEvent(new CustomEvent(panel.hidden?"contour:close":"contour:open",{bubbles:true,composed:true}))}return}const more=e.target&&e.target.closest?e.target.closest(".c-notification-center__more"):null;if(more&&this.contains(more)){this._notifShown=(this._notifShown||50)+50;this.requestRender();return}const archive=e.target&&e.target.closest?e.target.closest(".c-notification-center__archive"):null;if(archive&&this.contains(archive)){const item=archive.closest(".c-notification-center__item");if(item)removeRow(item,"archive");return}const dismiss=e.target&&e.target.closest?e.target.closest(".c-notification-center__dismiss"):null;if(dismiss&&this.contains(dismiss)){const item=dismiss.closest(".c-notification-center__item");if(item)removeRow(item,"dismiss");return}const item=e.target&&e.target.closest?e.target.closest(".c-notification-center__item"):null;if(item&&this.contains(item))activate(item)});const docClick=(e)=>{const panel=this.querySelector(".c-notification-center__panel");const btn=this.querySelector(".c-notification-center__trigger");if(panel&&!panel.hidden&&!this.contains(e.target)){panel.hidden=true;this._notifOpen=false;if(btn)btn.setAttribute("aria-expanded","false")}};document.addEventListener("click",docClick);onDispose(this,()=>document.removeEventListener("click",docClick));const keyHandler=(e)=>{const panel=this.querySelector(".c-notification-center__panel");const btn=this.querySelector(".c-notification-center__trigger");if(e.key==="Escape"&&panel&&!panel.hidden){panel.hidden=true;this._notifOpen=false;if(btn){btn.setAttribute("aria-expanded","false");try{btn.focus()}catch(err){}}return}if(!panel||panel.hidden)return;const items=Array.from(panel.querySelectorAll(".c-notification-center__item"));if(!items.length)return;if((e.key==="Enter"||e.key===" ")&&items.includes(e.target)){e.preventDefault();activate(e.target);return}if((e.key==="Delete"||e.key==="Backspace")&&items.includes(e.target)){e.preventDefault();const idx=items.indexOf(e.target);removeRow(e.target,"dismiss");const next=items[idx+1]||items[idx-1];if(next&&next.isConnected){try{next.focus()}catch(err){}}return}navKey(e,items,{wrap:true,onNavigate:(i)=>{items.forEach((r,j)=>{r.tabIndex=j===i?0:-1})}})};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler))}}define("contour-notification-center",ContourNotificationCenter);class ContourStepper extends ContourBase{static get observed(){return["steps","current"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current"}}}render(){this.classList.add("c-stepper");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Stepper");const steps=this.getAttribute("steps");const current=Number(this.getAttribute("current")||0);const list=this.ensure(".c-stepper__list",()=>{const el=document.createElement("ol");el.className="c-stepper__list";return el});list.innerHTML="";const authoredSteps=Array.from(this.querySelectorAll(":scope > .c-stepper__step"));let parsed=[];if(authoredSteps.length){parsed=authoredSteps.map((el)=>el.textContent.trim());authoredSteps.forEach((el)=>el.remove())}else{try{parsed=steps?JSON.parse(steps):[]}catch(e){parsed=[]}}parsed.forEach((s,i)=>{const li=document.createElement("li");li.className="c-stepper__step"+(i===current?" is-current":"")+(i<current?" is-done":"");if(i===current)li.setAttribute("aria-current","step");li.textContent=typeof s==="string"?s:(s.title||s.label||"");list.appendChild(li)});const nav=this.ensure(".c-stepper__nav",()=>{const el=document.createElement("div");el.className="c-stepper__nav c-btn-group";return el});const prev=this.ensure(".c-stepper__prev",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-stepper__prev";el.type="button";return el});prev.textContent=labelText(this,"prev","Back");const next=this.ensure(".c-stepper__next",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-stepper__next";el.type="button";return el});next.textContent=labelText(this,"next","Next");if(!nav.contains(prev))nav.appendChild(prev);if(!nav.contains(next))nav.appendChild(next);if(nav.parentNode!==this)this.appendChild(nav)}enhance(){if(this._wiredStepper)return;this._wiredStepper=true;const go=(dir)=>{const list=this.querySelector(".c-stepper__list");const total=list?list.querySelectorAll(".c-stepper__step").length:0;if(!total)return;let cur=Number(this.getAttribute("current")||0);if(dir==="prev")cur=Math.max(0,cur-1);else cur=Math.min(total-1,cur+1);this.setAttribute("current",String(cur));this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{direction:dir,index:cur}}))};this.addEventListener("click",(e)=>{const prev=e.target&&e.target.closest?e.target.closest(".c-stepper__prev"):null;const next=e.target&&e.target.closest?e.target.closest(".c-stepper__next"):null;if(prev&&this.contains(prev)){go("prev");return}if(next&&this.contains(next)){go("next");return}const step=e.target&&e.target.closest?e.target.closest(".c-stepper__step"):null;if(step&&this.contains(step)){const items=Array.from(this.querySelectorAll(".c-stepper__step"));const idx=items.indexOf(step);if(idx>=0&&idx!==Number(this.getAttribute("current")||0)){this.setAttribute("current",String(idx));this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{direction:"jump",index:idx}}))}}});this.addEventListener("keydown",(e)=>{if(e.key==="ArrowLeft"){e.preventDefault();go("prev")}else if(e.key==="ArrowRight"){e.preventDefault();go("next")}})}}define("contour-stepper",ContourStepper);class ContourVirtualList extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","item-height","orientation","sticky"]}static get properties(){return{items:{attribute:"items"},"item-height":{attribute:"item-height"},orientation:{attribute:"orientation"},sticky:{attribute:"sticky",type:Boolean}}}_items(){const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}return Array.isArray(parsed)?parsed:[]}_itemHeight(){const h=Number(this.getAttribute("item-height"));if(Number.isFinite(h)&&h>0)return h;return cssLength("--virtual-list-item-height",28)}_autoHeight(){return this.getAttribute("item-height")==="auto"}render(){this.classList.add("c-virtual-list");this.setAttribute("role","list");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Virtual list");const scroller=this.ensure(".c-virtual-list__scroller",()=>{const el=document.createElement("div");el.className="c-virtual-list__scroller";return el});scroller.setAttribute("role","presentation");const horizontal=this.getAttribute("orientation")==="horizontal";scroller.style.overflowX=horizontal?"auto":"hidden";scroller.style.overflowY=horizontal?"hidden":"auto";const inner=this.ensure(".c-virtual-list__inner",()=>{const el=document.createElement("div");el.className="c-virtual-list__inner";el.style.position="relative";return el});if(inner.parentNode!==scroller)scroller.appendChild(inner);this._renderWindow(scroller,inner,horizontal?(scroller.scrollLeft||0):(scroller.scrollTop||0))}_measureHeights(inner,horizontal){const rows=Array.from(inner.querySelectorAll(".c-virtual-list__item"));return rows.map((r)=>horizontal?(r.getBoundingClientRect().width||this._itemHeight()):(r.getBoundingClientRect().height||this._itemHeight()))}_renderWindow(scroller,inner,scrollTop){const items=this._items();const ih=this._itemHeight();const horizontal=this.getAttribute("orientation")==="horizontal";const autoHeight=this._autoHeight();const viewportSize=horizontal?(scroller.clientWidth||320):(scroller.clientHeight||320);const total=items.length;if(this._vlItemCount!==total){this._vlHeights=null;this._vlItemCount=total}let heights=autoHeight?this._vlHeights:null;let cumulative=null;if(autoHeight&&heights&&heights.length===total){cumulative=[0];for(let i=0;i<total;i++)cumulative.push(cumulative[i]+(heights[i]||this._itemHeight()))}const visibleCount=autoHeight&&!cumulative?total:(autoHeight?Math.ceil(viewportSize/this._itemHeight())+6:Math.ceil(viewportSize/ih)+4);let start=0;if(autoHeight&&cumulative){let lo=0,hi=total;while(lo<hi){const mid=(lo+hi)>>1;if(cumulative[mid]<(scrollTop||0))lo=mid+1;else hi=mid}start=Math.max(0,lo-3)}else if(!autoHeight){start=Math.floor((scrollTop||0)/ih)}if(start<0)start=0;const end=autoHeight&&cumulative?Math.min(total,start+visibleCount):Math.min(total,start+visibleCount);if(start>Math.max(0,total-visibleCount)&&!autoHeight)start=Math.max(0,total-visibleCount);const topSpacerSize=autoHeight&&cumulative?cumulative[start]:(autoHeight?0:start*ih);const bottomSpacerSize=autoHeight&&cumulative?Math.max(0,cumulative[total]-cumulative[end]):(autoHeight?0:Math.max(0,(total-end)*ih));inner.style.display=horizontal?"flex":"block";inner.style.width=horizontal&&autoHeight?"max-content":"";inner.style.height=horizontal||autoHeight?"":(total*ih)+"px";inner.innerHTML="";const top=document.createElement("div");top.className="c-virtual-list__spacer c-virtual-list__spacer--top";top.style[horizontal?"width":"height"]=topSpacerSize+"px";inner.appendChild(top);for(let i=start;i<end;i++){const row=document.createElement("div");row.className="c-virtual-list__item";row.setAttribute("role","listitem");row.setAttribute("aria-setsize",String(total));row.setAttribute("aria-posinset",String(i+1));row.setAttribute("tabindex",i===0?"0":"-1");row.textContent=typeof items[i]==="string"?items[i]:(items[i].label||items[i].text||JSON.stringify(items[i]));if(this.hasAttribute("sticky")&&items[i]&&items[i].sticky){row.style.position="sticky";row.style.insetBlockStart="0";row.style.zIndex="1"}if(horizontal&&!autoHeight)row.style.flex="0 0 "+ih+"px";row.dataset.index=String(i);inner.appendChild(row)}const bottom=document.createElement("div");bottom.className="c-virtual-list__spacer c-virtual-list__spacer--bottom";bottom.style[horizontal?"width":"height"]=bottomSpacerSize+"px";inner.appendChild(bottom);if(horizontal&&!autoHeight)inner.style.width=(total*ih)+"px";if(autoHeight&&!this._vlHeights){requestAnimationFrame(()=>{this._vlHeights=this._measureHeights(inner,horizontal);const s=scroller;const i=inner;if(s&&i)this._renderWindow(s,i,s.scrollTop||0)})}}enhance(){if(this._wiredVirtualList)return;this._wiredVirtualList=true;const scroller=()=>this.querySelector(".c-virtual-list__scroller");const inner=()=>this.querySelector(".c-virtual-list__inner");let raf=0;const onScroll=()=>{if(raf)return;raf=requestAnimationFrame(()=>{raf=0;const s=scroller();const i=inner();if(s&&i)this._renderWindow(s,i,this.getAttribute("orientation")==="horizontal"?s.scrollLeft:s.scrollTop)})};const s=scroller();if(s){s.addEventListener("scroll",onScroll,{passive:true});onDispose(this,()=>{s.removeEventListener("scroll",onScroll);if(raf)cancelAnimationFrame(raf)})}this.addEventListener("keydown",(e)=>{const rows=Array.from(this.querySelectorAll(".c-virtual-list__item"));if(!rows.length)return;const horizontal=this.getAttribute("orientation")==="horizontal";const fwd=horizontal?"ArrowRight":"ArrowDown";const back=horizontal?"ArrowLeft":"ArrowUp";const active=document.activeElement;const at=rows.indexOf(active);const scroller=this.querySelector(".c-virtual-list__scroller");const inner=this.querySelector(".c-virtual-list__inner");if((e.key===fwd&&at===rows.length-1)||(e.key===back&&at===0&&Number(active&&active.dataset.index)>0)){e.preventDefault();if(scroller&&inner){const delta=(e.key===fwd?1:-1)*this._itemHeight();if(horizontal)scroller.scrollLeft+=delta;else scroller.scrollTop+=delta;this._renderWindow(scroller,inner,horizontal?scroller.scrollLeft:scroller.scrollTop);const targetIndex=Number(active&&active.dataset.index)+(e.key===fwd?1:-1);requestAnimationFrame(()=>{const next=this.querySelector(`.c-virtual-list__item[data-index="${targetIndex}"]`);if(next){rows.forEach((r)=>r.setAttribute("tabindex","-1"));next.setAttribute("tabindex","0");try{next.focus()}catch(err){}}})}return}navKey(e,rows,{wrap:false,homeEnd:true,onNavigate:(i)=>rows.forEach((r,j)=>r.setAttribute("tabindex",j===i?"0":"-1")),onKey:()=>{if(e.key==="Enter"||e.key===" "){const i=Number(document.activeElement.dataset.index);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:i,value:document.activeElement.textContent}}))}}})});this.addEventListener("click",(e)=>{const row=e.target&&e.target.closest?e.target.closest(".c-virtual-list__item"):null;if(!row||!this.contains(row))return;const i=Number(row.dataset.index);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:i,value:row.textContent}}))})}}define("contour-virtual-list",ContourVirtualList);class ContourCommandPalette extends ContourBase{static get observed(){return["open","items"]}static get properties(){return{open:{attribute:"open",type:Boolean},items:{attribute:"items"}}}attributeChangedCallback(name,oldValue,newValue){super.attributeChangedCallback(name,oldValue,newValue);if(name==="open"&&this.isConnected&&oldValue!==newValue){if(newValue!==null)this.show();else this.hide()}}_recentsKey(){return"contour-command-palette:"+(this.id||"default")+":recents"}_recents(){try{const r=JSON.parse(localStorage.getItem(this._recentsKey())||"[]");return Array.isArray(r)?r:[]}catch(e){return[]}}_remember(label){try{const r=this._recents().filter((l)=>l!==label);r.unshift(label);localStorage.setItem(this._recentsKey(),JSON.stringify(r.slice(0,5)))}catch(e){}}_cmdRow(label,index,recent){const row=document.createElement("div");row.className="c-command-palette__item";row.setAttribute("role","option");row.id=this.id+"-opt-"+(recent?"r":"")+index;row.textContent=label;row.dataset.index=String(index);row.dataset.label=label;if(recent)row.dataset.recent="true";return row}render(){this.classList.add("c-command-palette");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("aria-modal"))this.setAttribute("aria-modal","true");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("cmd-palette");const search=this.ensure(".c-command-palette__search",()=>{const el=document.createElement("input");el.className="c-input c-command-palette__search";el.type="search";el.placeholder="Search…";el.setAttribute("aria-label","Search commands");el.setAttribute("role","combobox");el.setAttribute("aria-autocomplete","list");el.setAttribute("aria-expanded","false");return el});const list=this.ensure(".c-command-palette__list",()=>{const el=document.createElement("div");el.className="c-command-palette__list";el.setAttribute("role","listbox");return el});if(!list.id)list.id=this.id+"-list";search.setAttribute("aria-controls",list.id);let parsed=[];const items=this.getAttribute("items");if(items){try{parsed=JSON.parse(items)}catch(e){warnBadJson(this,"items",e)}}if(!Array.isArray(parsed))parsed=[];const labelOf=(it)=>typeof it==="string"?it:(it.label||it.title||"");list.innerHTML="";const q=(this._cmdQuery||"").toLowerCase().trim();const recents=q?[]:this._recents().filter((l)=>parsed.some((it)=>labelOf(it)===l));if(recents.length){const g=document.createElement("div");g.className="c-command-palette__group";g.setAttribute("role","presentation");g.textContent=labelText(this,"recent","Recent");list.appendChild(g);recents.forEach((label)=>list.appendChild(this._cmdRow(label,parsed.findIndex((it)=>labelOf(it)===label),true)))}let lastGroup=null;parsed.forEach((it,i)=>{const g=typeof it==="object"&&it!==null?(it.group||null):null;if(g&&g!==lastGroup){const h=document.createElement("div");h.className="c-command-palette__group";h.setAttribute("role","presentation");h.textContent=g;list.appendChild(h);lastGroup=g}list.appendChild(this._cmdRow(labelOf(it),i,false))});if(this._cmdQuery)search.value=this._cmdQuery;if(this._cmdFilter)this._cmdFilter(this._cmdQuery||"");else if(this._cmdSetActive)this._cmdSetActive(this._cmdCursor||0)}show(){if(this.classList.contains("is-open")||this.matches(":popover-open")){if(!this.hasAttribute("open"))this.setAttribute("open","");return}if(typeof this.showPopover==="function"){try{this.showPopover()}catch(e){}}this.classList.add("is-open");modalContain(this,true);const s=this.querySelector(".c-command-palette__search");if(s){s.setAttribute("aria-expanded","true");try{s.focus()}catch(e){}}if(!this.hasAttribute("open"))this.setAttribute("open","")}hide(){const isOpen=this.classList.contains("is-open")||this.matches(":popover-open");if(!isOpen){if(this.hasAttribute("open"))this.removeAttribute("open");return}if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(e){}}this.classList.remove("is-open");modalContain(this,false);const s=this.querySelector(".c-command-palette__search");if(s)s.setAttribute("aria-expanded","false");if(this.hasAttribute("open"))this.removeAttribute("open")}toggle(){if(this.classList.contains("is-open")||this.matches(":popover-open"))this.hide();else this.show()}enhance(){if(this._cmdSetActive)this._cmdSetActive(this._cmdCursor||0);if(this._wiredCmdPalette)return;this._wiredCmdPalette=true;const search=()=>this.querySelector(".c-command-palette__search");const list=()=>this.querySelector(".c-command-palette__list");const items=()=>Array.from(this.querySelectorAll(".c-command-palette__item"));const visibleItems=()=>items().filter((it)=>!it.hidden);const setActive=(idx)=>{const vis=visibleItems();if(!vis.length){this._cmdCursor=0;return}this._cmdCursor=Math.max(0,Math.min(idx,vis.length-1));vis.forEach((it,i)=>it.classList.toggle("is-active",i===this._cmdCursor));const active=vis[this._cmdCursor];const s=search();if(s&&active)s.setAttribute("aria-activedescendant",active.id);else if(s)s.removeAttribute("aria-activedescendant")};const filter=(q)=>{const needle=(q||"").toLowerCase().trim();items().forEach((it)=>{const label=(it.dataset.label||it.textContent||"").toLowerCase();it.hidden=needle!==""&&!label.includes(needle)});Array.from(list().querySelectorAll(".c-command-palette__group")).forEach((g)=>{let n=g.nextElementSibling,any=false;while(n&&!n.classList.contains("c-command-palette__group")){if(!n.hidden&&n.classList.contains("c-command-palette__item"))any=true;n=n.nextElementSibling}g.hidden=!any});let empty=list().querySelector(".c-command-palette__empty");const anyVisible=items().some((it)=>!it.hidden);if(!anyVisible){if(!empty){empty=document.createElement("div");empty.className="c-command-palette__empty";empty.setAttribute("role","status");list().appendChild(empty)}empty.textContent=labelText(this,"no-matches","No matches");empty.hidden=false}else if(empty)empty.hidden=true;setActive(0)};const select=(it)=>{if(!it)return;const detail={index:Number(it.dataset.index),label:it.dataset.label||it.textContent};this.value=detail;this._remember(detail.label);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail}));this.hide()};this._cmdSetActive=setActive;this._cmdFilter=filter;this.addEventListener("input",(e)=>{const s=search();if(!s||e.target!==s)return;this._cmdQuery=s.value;filter(s.value)});this.addEventListener("keydown",(e)=>{const s=search();if(!s||e.target!==s)return;const vis=visibleItems();if(e.key==="Escape"){e.preventDefault();this.hide();return}if(!vis.length)return;if(e.key==="ArrowDown"){e.preventDefault();setActive(this._cmdCursor+1)}else if(e.key==="ArrowUp"){e.preventDefault();setActive(this._cmdCursor-1)}else if(e.key==="Home"){e.preventDefault();setActive(0)}else if(e.key==="End"){e.preventDefault();setActive(vis.length-1)}else if(e.key==="Enter"){e.preventDefault();select(vis[this._cmdCursor])}});this.addEventListener("click",(e)=>{const it=e.target&&e.target.closest?e.target.closest(".c-command-palette__item"):null;if(it&&this.contains(it)&&!it.hidden)select(it)});let lastFocus=null;this.addEventListener("beforetoggle",(e)=>{if(e.newState==="open"){lastFocus=document.activeElement;this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))}else if(lastFocus&&typeof lastFocus.focus==="function"){this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));try{lastFocus.focus()}catch(err){}}});setActive(0)}}define("contour-command-palette",ContourCommandPalette);class ContourBadgeOverflow extends ContourBase{static get observed(){return["count","max"]}static get properties(){return{count:{attribute:"count"},max:{attribute:"max"}}}render(){this.classList.add("c-badge-overflow");const count=Number(this.getAttribute("count")||0);const max=Number(this.getAttribute("max")||3);const extra=Math.max(0,count-max);const existing=this.querySelector(".c-badge-overflow__more");if(existing)existing.remove();if(extra>0){const b=document.createElement("span");b.className="c-badge c-badge-overflow__more";b.textContent="+"+extra;this.appendChild(b)}}}define("contour-badge-overflow",ContourBadgeOverflow);class ContourSideSheet extends ContourBase{static get observed(){return["open","side","title","mode","size"]}static get properties(){return{open:{attribute:"open",type:Boolean},side:{attribute:"side"},title:{attribute:"title"},mode:{attribute:"mode"},size:{attribute:"size"}}}show(){this.setAttribute("open","")}showModal(){this._sheetForceModal=true;this.show()}close(){this.removeAttribute("open")}get open(){return this.hasAttribute("open")}set open(v){if(v)this.show();else this.close()}_modal(){return this._sheetForceModal||(this.getAttribute("mode")||"modal")!=="non-modal"}render(){this.classList.add("c-side-sheet");this.setAttribute("role","dialog");if(this._modal())this.setAttribute("aria-modal","true");else this.removeAttribute("aria-modal");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("title")||"Side sheet");for(const c of Array.from(this.classList)){if(/^c-side-sheet--(start|end|sm|md|lg)$/.test(c))this.classList.remove(c)}const side=this.getAttribute("side")==="start"?"start":"end";this.classList.add("c-side-sheet--"+side);const size=this.getAttribute("size");if(size==="sm"||size==="md"||size==="lg")this.classList.add("c-side-sheet--"+size);if(this.hasAttribute("open"))this.classList.add("is-open");else this.classList.remove("is-open");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-side-sheet__title",()=>{const el=document.createElement("div");el.className="c-side-sheet__title";return el});t.textContent=title}}enhance(){if(this._wiredSideSheet)return;this._wiredSideSheet=true;let lastFocus=null;const keyHandler=(e)=>{if(e.key==="Escape"&&this.hasAttribute("open")){e.preventDefault();this.close();return}if(e.key==="Tab"&&this.hasAttribute("open")&&this._modal()){const focusables=Array.from(this.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")).filter((el)=>!el.hasAttribute("disabled"));if(!focusables.length){e.preventDefault();return}const first=focusables[0],last=focusables[focusables.length-1];if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus()}else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus()}}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("click",(e)=>{if(e.target===this)this.close()});let wasOpen=false;const transition=()=>{const isOpen=this.hasAttribute("open");if(isOpen&&!wasOpen){wasOpen=true;lastFocus=document.activeElement;if(this._modal())modalContain(this,true);const first=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(first)try{first.focus()}catch(err){}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))}else if(!isOpen&&wasOpen){wasOpen=false;if(this._modal())modalContain(this,false);this._sheetForceModal=false;if(lastFocus&&typeof lastFocus.focus==="function")try{lastFocus.focus()}catch(err){}lastFocus=null;this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))}};const obs=new MutationObserver(transition);obs.observe(this,{attributes:true,attributeFilter:["open"]});if(this.hasAttribute("open"))transition();onDispose(this,()=>{obs.disconnect();if(this.hasAttribute("open")&&this._modal())modalContain(this,false)})}}define("contour-side-sheet",ContourSideSheet);class ContourTour extends ContourBase{static get observed(){return["steps","current","open","persist","id"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current"},open:{attribute:"open",type:Boolean},persist:{attribute:"persist",type:Boolean}}}_steps(){let parsed=[];try{const s=this.getAttribute("steps");parsed=s?JSON.parse(s):[]}catch(e){parsed=[]}return Array.isArray(parsed)?parsed:[]}_current(n){const c=Number(this.getAttribute("current")||0);return Number.isFinite(c)?Math.min(Math.max(0,c),Math.max(0,n-1)):0}_storageKey(){return this.id?"contour-tour:"+this.id:null}_completed(){if(!this.hasAttribute("persist"))return false;const key=this._storageKey();try{return key?localStorage.getItem(key)==="done":false}catch(e){return false}}_markCompleted(){if(!this.hasAttribute("persist"))return;const key=this._storageKey();try{if(key)localStorage.setItem(key,"done")}catch(e){}}show(){this.setAttribute("open","")}close(){if(!this.hasAttribute("open"))return;this.removeAttribute("open");this._markCompleted();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))}render(){this.classList.add("c-tour");this.setAttribute("role","dialog");this.setAttribute("aria-label",labelText(this,"tour","Tour"));const parsed=this._steps();if(!this._tourInitialized){this._tourInitialized=true;if(parsed.length&&!this.hasAttribute("open")&&!this._completed())this.setAttribute("open","")}const isOpen=this.hasAttribute("open")&&parsed.length>0;if(isOpen)this.removeAttribute("hidden");else this.setAttribute("hidden","");const current=this._current(parsed.length);const step=parsed[current]||{};const counter=this.ensure(".c-tour__step",()=>{const el=document.createElement("div");el.className="c-tour__step";return el});counter.textContent=labelText(this,"step","Step")+" "+(current+1)+" / "+parsed.length;const tip=this.ensure(".c-tour__tip",()=>{const el=document.createElement("div");el.className="c-tour__tip";return el});tip.textContent=typeof step==="string"?step:(step.text||step.title||"");if(counter.nextSibling!==tip)this.insertBefore(counter,tip);const nav=this.ensure(".c-tour__nav",()=>{const el=document.createElement("div");el.className="c-tour__nav c-btn-group";return el});const back=this.ensure(".c-tour__back",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-tour__back";el.type="button";return el},nav);back.textContent=labelText(this,"back","Back");back.disabled=current===0;const next=this.ensure(".c-tour__next",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-tour__next";el.type="button";return el},nav);next.textContent=current>=parsed.length-1?labelText(this,"done","Done"):labelText(this,"next","Next");const close=this.ensure(".c-tour__close",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-tour__close";el.type="button";return el},nav);close.textContent=labelText(this,"close","Close");if(nav.firstChild!==back)nav.insertBefore(back,nav.firstChild);if(back.nextSibling!==next)nav.insertBefore(next,back.nextSibling);if(next.nextSibling!==close)nav.insertBefore(close,next.nextSibling);if(this._tourTarget&&this._tourTarget.classList)this._tourTarget.classList.remove("c-tour__target");this._tourTarget=null;const targetSel=isOpen&&typeof step==="object"&&step?step.target:null;if(targetSel){const target=document.querySelector(targetSel);if(target&&target.classList){target.classList.add("c-tour__target");this._tourTarget=target}}if(isOpen)this._positionTour()}_positionTour(){const vw=window.innerWidth,vh=window.innerHeight;const w=this.offsetWidth||280,h=this.offsetHeight||120;const target=this._tourTarget;if(target&&target.getBoundingClientRect){const r=target.getBoundingClientRect();let top=r.bottom+8;if(top+h>vh-8)top=Math.max(8,r.top-h-8);const left=Math.min(Math.max(8,r.left),Math.max(8,vw-w-8));this.style.insetBlockStart=top+"px";this.style.insetInlineStart=left+"px";this.style.insetBlockEnd="auto";this.style.transform=""}else{this.style.insetBlockStart="auto";this.style.insetBlockEnd="1rem";this.style.insetInlineStart="50%";this.style.transform="translateX(-50%)"}}enhance(){if(this._wiredTour)return;this._wiredTour=true;const step=(dir)=>{const parsed=this._steps();if(!parsed.length||!this.hasAttribute("open"))return;const cur=this._current(parsed.length);if(dir==="next"){if(cur>=parsed.length-1){this.close();return}this.setAttribute("current",String(cur+1));this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{direction:"next",index:cur+1}}))}else{if(cur===0)return;this.setAttribute("current",String(cur-1));this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{direction:"prev",index:cur-1}}))}};this._tourStep=step;this.addEventListener("click",(e)=>{const t=e.target&&e.target.closest?e.target:null;if(!t)return;if(t.closest(".c-tour__next")){step("next");return}if(t.closest(".c-tour__back")){step("prev");return}if(t.closest(".c-tour__close"))this.close()});const keyHandler=(e)=>{if(!this.hasAttribute("open"))return;const tag=e.target&&e.target.tagName;if(tag==="INPUT"||tag==="TEXTAREA"||tag==="SELECT")return;if(e.key==="Escape"){e.preventDefault();this.close()}else if(e.key==="ArrowRight"){e.preventDefault();step("next")}else if(e.key==="ArrowLeft"){e.preventDefault();step("prev")}};document.addEventListener("keydown",keyHandler);const reposition=()=>{if(this.hasAttribute("open"))this._positionTour()};window.addEventListener("scroll",reposition,{passive:true,capture:true});window.addEventListener("resize",reposition,{passive:true});onDispose(this,()=>{document.removeEventListener("keydown",keyHandler);window.removeEventListener("scroll",reposition,{capture:true});window.removeEventListener("resize",reposition);if(this._tourTarget&&this._tourTarget.classList)this._tourTarget.classList.remove("c-tour__target")})}}define("contour-tour",ContourTour);class ContourTagsInput extends ContourBase{static get formAssociated(){return true}static get observed(){return["value","placeholder","disabled","error","help","required","max"]}static get properties(){return{value:{attribute:"value"},placeholder:{attribute:"placeholder"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},required:{attribute:"required",type:Boolean},max:{attribute:"max"}}}render(){this.classList.add("c-tags-input");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Tags input");const input=this.ensure(".c-tags-input__input",()=>{const el=document.createElement("input");el.className="c-input c-tags-input__input";el.type="text";el.setAttribute("aria-label","Add tag");return el});input.placeholder=this.getAttribute("placeholder")||"Add tag…";if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-tags-input__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-tags-input__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-tags-input__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const tags=this.getAttribute("value");let parsed=[];try{parsed=tags?JSON.parse(tags):[]}catch(e){parsed=tags?tags.split(",").map((s)=>s.trim()).filter(Boolean):[]}Array.from(this.querySelectorAll(".c-tags-input__tag")).forEach((n)=>n.remove());parsed.forEach((t)=>{const chip=document.createElement("span");chip.className="c-tag c-tags-input__tag";chip.textContent=t;const rm=document.createElement("button");rm.className="c-tags-input__remove";rm.type="button";rm.textContent="×";rm.dataset.value=t;chip.appendChild(rm);this.insertBefore(chip,input)});if(this._internals)this._syncFormValue()}enhance(){if(this._wiredTagsInput)return;this._wiredTagsInput=true;this._syncFormValue();this.addEventListener("contour:add",()=>{this._syncFormValue()});this.addEventListener("contour:remove",()=>{this._syncFormValue()});const announce=(msg)=>{let live=this.querySelector(".c-tags-input__live");if(!live){live=document.createElement("span");live.className="c-tags-input__live visually-hidden";live.setAttribute("aria-live","polite");live.setAttribute("aria-atomic","true");this.appendChild(live)}live.textContent=msg};const readTags=()=>{const raw=this.getAttribute("value")||"";let tags=[];try{tags=JSON.parse(raw)}catch(err){tags=raw.split(",").map((s)=>s.trim()).filter(Boolean)}return Array.isArray(tags)?tags.map(String):[]};const addMany=(candidates)=>{if(this.hasAttribute("disabled"))return;const tags=readTags();const max=Number(this.getAttribute("max"));const added=[],dups=[];let limitHit=false;for(const raw of candidates){const v=String(raw).trim();if(!v)continue;if(tags.includes(v)){dups.push(v);continue}if(Number.isFinite(max)&&max>0&&tags.length>=max){limitHit=true;break}tags.push(v);added.push(v)}if(added.length){this.setAttribute("value",JSON.stringify(tags));for(const v of added)this.dispatchEvent(new CustomEvent("contour:add",{bubbles:true,composed:true,detail:{value:v}}))}const parts=[];if(added.length)parts.push("Added "+added.join(", "));if(dups.length)parts.push(dups.join(", ")+" already added");if(limitHit)parts.push("Tag limit reached ("+max+")");if(parts.length)announce(parts.join(". "))};this.addEventListener("keydown",(e)=>{const input=this.querySelector(".c-tags-input__input");if(!input||this.hasAttribute("disabled"))return;if(e.key==="Enter"&&e.target===input){e.preventDefault();const v=input.value;input.value="";addMany([v])}else if(e.key==="Backspace"&&e.target===input&&input.value===""){const tags=readTags();if(tags.length){const removed=tags.pop();this.setAttribute("value",JSON.stringify(tags));announce("Removed "+removed);this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:true,composed:true,detail:{value:removed}}))}}});this.addEventListener("input",(e)=>{const input=this.querySelector(".c-tags-input__input");if(!input||e.target!==input||this.hasAttribute("disabled"))return;if(input.value.includes(",")){const parts=input.value.split(",");input.value=parts.pop();addMany(parts)}});this.addEventListener("paste",(e)=>{const input=this.querySelector(".c-tags-input__input");if(!input||e.target!==input||this.hasAttribute("disabled"))return;const text=e.clipboardData&&e.clipboardData.getData("text/plain");if(text&&/[,;\n]/.test(text)){e.preventDefault();addMany(text.split(/[,;\n]+/))}});this.addEventListener("click",(e)=>{const rm=e.target&&e.target.closest?e.target.closest(".c-tags-input__remove"):null;if(rm&&this.contains(rm)&&!this.hasAttribute("disabled")){const val=rm.dataset.value;const next=readTags().filter((t)=>t!==val);this.setAttribute("value",JSON.stringify(next));announce("Removed "+val);this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:true,composed:true,detail:{value:val}}))}})}_syncFormValue(){if(!this._internals)return;this._internals.setFormValue(this.getAttribute("value")||"[]");let count=0;try{const p=JSON.parse(this.getAttribute("value")||"[]");count=Array.isArray(p)?p.length:0}catch(err){count=(this.getAttribute("value")||"").split(",").filter((s)=>s.trim()).length}this._syncValidity(this.hasAttribute("required")&&count===0)}}define("contour-tags-input",ContourTagsInput);class ContourSortableList extends ContourBase{static get observed(){return["items","order"]}static get properties(){return{items:{attribute:"items"},order:{attribute:"order"}}}render(){this.classList.add("c-sortable-list");const list=this.ensure(".c-sortable-list__list",()=>{const el=document.createElement("ul");el.className="c-sortable-list__list";return el});const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}if(!Array.isArray(parsed))parsed=[];let sourceOrder=Array.from({length:parsed.length},(_,i)=>i);const orderRaw=this.getAttribute("order");if(orderRaw){try{const order=JSON.parse(orderRaw);if(Array.isArray(order)&&order.length===parsed.length&&order.every((i)=>Number.isInteger(i)&&i>=0&&i<parsed.length)){sourceOrder=order.slice();parsed=order.map((i)=>parsed[i])}}catch(e){}}this._sortableSourceOrder=sourceOrder;this._sortableItems=parsed;list.innerHTML="";parsed.forEach((it,i)=>{const li=document.createElement("li");li.className="c-sortable-list__item";li.setAttribute("draggable","true");li.dataset.index=String(i);const itemLabel=typeof it==="string"?it:(it.label||it.text||"");const handle=document.createElement("span");handle.className="c-sortable-list__handle";handle.textContent="⋮⋮";handle.setAttribute("role","button");handle.setAttribute("aria-label",labelText(this,"reorder","Reorder")+" "+(itemLabel||String(i+1)));handle.setAttribute("data-contour-preserve-key",itemLabel||String(i));handle.tabIndex=0;li.appendChild(handle);const labelEl=document.createElement("span");labelEl.className="c-sortable-list__label";labelEl.textContent=itemLabel;li.appendChild(labelEl);list.appendChild(li)})}enhance(){if(this._wiredSortableList)return;this._wiredSortableList=true;const list=()=>this.querySelector(".c-sortable-list__list");const announce=(msg)=>{let live=this.querySelector(".c-sortable-list__live");if(!live){live=document.createElement("span");live.className="c-sortable-list__live visually-hidden";live.setAttribute("aria-live","polite");live.setAttribute("aria-atomic","true");this.appendChild(live)}live.textContent=msg};const index=(li)=>Array.from(list().children).indexOf(li);const writeBack=(from,to)=>{const n=(this._sortableItems||[]).length;const cur=Array.isArray(this._sortableSourceOrder)&&this._sortableSourceOrder.length===n?this._sortableSourceOrder.slice():Array.from({length:n},(_,i)=>i);const[src]=cur.splice(from,1);cur.splice(to,0,src);this.setAttribute("order",JSON.stringify(cur))};let dragFrom=null;this.addEventListener("dragstart",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-sortable-list__item"):null;if(!li||!this.contains(li))return;dragFrom=index(li);if(e.dataTransfer){e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",String(dragFrom))}catch(err){}}li.classList.add("is-dragging")});this.addEventListener("dragover",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-sortable-list__item"):null;if(!li||!this.contains(li)||dragFrom===null)return;e.preventDefault();if(e.dataTransfer)e.dataTransfer.dropEffect="move"});this.addEventListener("drop",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-sortable-list__item"):null;if(!li||!this.contains(li)||dragFrom===null)return;e.preventDefault();const to=index(li);const l=list();const fromLi=l.children[dragFrom];if(fromLi&&dragFrom!==to){if(dragFrom<to)l.insertBefore(fromLi,l.children[to+1]||null);else l.insertBefore(fromLi,l.children[to]);const item=fromLi.querySelector(".c-sortable-list__label");announce((item?item.textContent:"Item")+" moved to position "+(to+1));const from=dragFrom;writeBack(from,to);this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:true,composed:true,detail:{from,to}}))}dragFrom=null;Array.from(l.children).forEach((n)=>n.classList.remove("is-dragging"))});this.addEventListener("dragend",()=>{dragFrom=null;const l=list();if(l)Array.from(l.children).forEach((n)=>n.classList.remove("is-dragging"))});this.addEventListener("keydown",(e)=>{const handle=e.target&&e.target.closest?e.target.closest(".c-sortable-list__handle"):null;if(!handle)return;const li=handle.closest(".c-sortable-list__item");if(!li)return;const l=list();const from=index(li);const moved=(direction,to)=>{const label=li.querySelector(".c-sortable-list__label");announce((label?label.textContent:"Item")+" moved to position "+(to+1));writeBack(from,to);this.dispatchEvent(new CustomEvent("contour:move",{bubbles:true,composed:true,detail:{direction,from,to}}));this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:true,composed:true,detail:{from,to}}))};if(e.key==="ArrowUp"&&li.previousElementSibling){e.preventDefault();l.insertBefore(li,li.previousElementSibling);moved("up",index(li))}else if(e.key==="ArrowDown"&&li.nextElementSibling){e.preventDefault();l.insertBefore(li.nextElementSibling,li);moved("down",index(li))}else if(e.key==="Home"&&from>0){e.preventDefault();l.insertBefore(li,l.firstElementChild);moved("up",0)}else if(e.key==="End"&&from<l.children.length-1){e.preventDefault();l.appendChild(li);moved("down",l.children.length-1)}})}}define("contour-sortable-list",ContourSortableList);class ContourSwatch extends ContourBase{static get observed(){return["color","selected","label"]}static get properties(){return{color:{attribute:"color"},selected:{attribute:"selected",type:Boolean},label:{attribute:"label"}}}render(){this.classList.add("c-swatch");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(this.getAttribute("role")==="button"&&!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||this.getAttribute("color")||"Swatch");const color=this.getAttribute("color")||"#000";this.style.setProperty("--swatch-color",color);if(this.hasAttribute("selected"))this.classList.add("is-selected");else this.classList.remove("is-selected");if(!this.hasAttribute("aria-label")){const label=this.getAttribute("label")||color;this.setAttribute("aria-label",label)}if(!this.querySelector("button")&&!this.querySelector("span")){const span=document.createElement("span");span.className="c-swatch__btn";span.setAttribute("aria-hidden","true");this.appendChild(span)}}enhance(){if(this._wiredSwatch)return;this._wiredSwatch=true;this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:this.getAttribute("color")}}))});this.addEventListener("keydown",(e)=>{if(e.key!=="Enter"&&e.key!==" ")return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:this.getAttribute("color")}}))})}}define("contour-swatch",ContourSwatch);class ContourCalendar extends ContourBase{static get observed(){return["value","month","year","range","start","end"]}static get properties(){return{value:{attribute:"value"},month:{attribute:"month"},year:{attribute:"year"},range:{attribute:"range",type:Boolean},start:{attribute:"start"},end:{attribute:"end"}}}_attrNum(name,fallback){const raw=this.getAttribute(name);const n=Number(raw);return raw!==null&&Number.isFinite(n)?n:fallback}_ym(){const now=new Date();return{year:this._attrNum("year",now.getFullYear()),month:this._attrNum("month",now.getMonth())}}render(){this.classList.add("c-calendar");const now=new Date();const{year,month}=this._ym();const header=this.ensure(".c-calendar__header",()=>{const el=document.createElement("div");el.className="c-calendar__header";return el});header.innerHTML="";const navBtn=(cls,glyph,label)=>{const b=document.createElement("button");b.type="button";b.className="c-btn c-btn--sm "+cls;b.textContent=glyph;b.setAttribute("aria-label",label);return b};const prevYear=navBtn("c-calendar__prev-year","«","Previous year");const prev=navBtn("c-calendar__prev","‹","Previous month");const title=document.createElement("span");title.className="c-calendar__title";title.textContent=new Date(year,month,1).toLocaleString(undefined,{month:"long",year:"numeric"});const next=navBtn("c-calendar__next","›","Next month");const nextYear=navBtn("c-calendar__next-year","»","Next year");header.append(prevYear,prev,title,next,nextYear);const grid=this.ensure(".c-calendar__grid",()=>{const el=document.createElement("div");el.className="c-calendar__grid";el.setAttribute("role","grid");return el});grid.setAttribute("aria-label",title.textContent);grid.innerHTML="";const first=new Date(year,month,1);const startDay=first.getDay();const daysInMonth=new Date(year,month+1,0).getDate();const isRange=this.hasAttribute("range");const selected=this.getAttribute("value");const rStart=this.getAttribute("start");const rEnd=this.getAttribute("end");let row=null;let col=0;const newRow=()=>{row=document.createElement("div");row.className="c-calendar__row";row.setAttribute("role","row");grid.appendChild(row);col=0};const wdFmt=new Intl.DateTimeFormat(undefined,{weekday:"short"});newRow();for(let i=0;i<7;i++){const wd=document.createElement("div");wd.className="c-calendar__weekday";wd.setAttribute("role","columnheader");wd.textContent=wdFmt.format(new Date(2023,0,1+i));row.appendChild(wd)}newRow();for(let i=0;i<startDay;i++){const empty=document.createElement("div");empty.className="c-calendar__day c-calendar__day--empty";row.appendChild(empty);col++;if(col===7)newRow()}const todayIso=now.getFullYear()+"-"+String(now.getMonth()+1).padStart(2,"0")+"-"+String(now.getDate()).padStart(2,"0");const focusIso=(selected&&selected.startsWith(year+"-"+String(month+1).padStart(2,"0")))?selected:(todayIso.startsWith(year+"-"+String(month+1).padStart(2,"0"))?todayIso:year+"-"+String(month+1).padStart(2,"0")+"-01");for(let d=1;d<=daysInMonth;d++){const cell=document.createElement("button");cell.className="c-calendar__day";cell.type="button";cell.setAttribute("role","gridcell");cell.textContent=String(d);const iso=year+"-"+String(month+1).padStart(2,"0")+"-"+String(d).padStart(2,"0");const isSelected=isRange?(iso===rStart||iso===rEnd):iso===selected;if(isSelected)cell.classList.add("is-selected");if(isRange&&rStart&&rEnd&&iso>rStart&&iso<rEnd)cell.classList.add("is-in-range");cell.setAttribute("aria-selected",String(isSelected));if(iso===todayIso)cell.setAttribute("aria-current","date");cell.setAttribute("tabindex",iso===focusIso?"0":"-1");cell.dataset.value=iso;row.appendChild(cell);col++;if(col===7)newRow()}if(header.parentNode!==this)this.insertBefore(header,grid)}enhance(){if(this._wiredCalendar)return;this._wiredCalendar=true;const navigate=(m,y)=>{this.batch(()=>{this.setAttribute("month",String(m));this.setAttribute("year",String(y))});this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{month:m,year:y}}))};const focusIso=(iso)=>{const cell=this.querySelector('.c-calendar__day[data-value="'+iso+'"]');if(cell){try{cell.focus()}catch(err){}}};this.addEventListener("focusin",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-calendar__day:not(.c-calendar__day--empty)"):null;if(!cell||!this.contains(cell))return;for(const c of this.querySelectorAll(".c-calendar__day"))c.tabIndex=-1;cell.tabIndex=0});this.addEventListener("click",(e)=>{const t=e.target&&e.target.closest?e.target:null;if(!t)return;const{year,month}=this._ym();if(t.closest(".c-calendar__prev")){const d=new Date(year,month-1,1);navigate(d.getMonth(),d.getFullYear());return}if(t.closest(".c-calendar__next")){const d=new Date(year,month+1,1);navigate(d.getMonth(),d.getFullYear());return}if(t.closest(".c-calendar__prev-year")){navigate(month,year-1);return}if(t.closest(".c-calendar__next-year")){navigate(month,year+1);return}const cell=t.closest(".c-calendar__day");if(cell&&this.contains(cell)&&cell.dataset.value){const iso=cell.dataset.value;if(this.hasAttribute("range")){const start=this.getAttribute("start");const end=this.getAttribute("end");let s,en;if(!start||(start&&end)){s=iso;en=null}else{s=iso<start?iso:start;en=iso<start?start:iso}this.batch(()=>{this.setAttribute("start",s);if(en===null)this.removeAttribute("end");else this.setAttribute("end",en)});this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:iso,range:en?[s,en]:[s]}}))}else{this.setAttribute("value",iso);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:iso}}))}}});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-calendar__day:not(.c-calendar__day--empty)"):null;if(!cell||!this.contains(cell)||!cell.dataset.value)return;const[y,m,d]=cell.dataset.value.split("-").map(Number);const cur=new Date(y,m-1,d);const{year,month}=this._ym();const daysInMonth=new Date(year,month+1,0).getDate();const isoOf=(dt)=>dt.getFullYear()+"-"+String(dt.getMonth()+1).padStart(2,"0")+"-"+String(dt.getDate()).padStart(2,"0");let target=null;if(e.key==="ArrowRight")target=new Date(y,m-1,d+1);else if(e.key==="ArrowLeft")target=new Date(y,m-1,d-1);else if(e.key==="ArrowDown")target=new Date(y,m-1,d+7);else if(e.key==="ArrowUp")target=new Date(y,m-1,d-7);else if(e.key==="PageUp")target=e.shiftKey?new Date(y-1,m-1,Math.min(d,new Date(y-1,m,0).getDate())):new Date(y,m-2,Math.min(d,new Date(y,m-1,0).getDate()));else if(e.key==="PageDown")target=e.shiftKey?new Date(y+1,m-1,Math.min(d,new Date(y+1,m,0).getDate())):new Date(y,m,Math.min(d,new Date(y,m+1,0).getDate()));else if(e.key==="Home")target=new Date(year,month,1);else if(e.key==="End")target=new Date(year,month,daysInMonth);else return;e.preventDefault();const iso=isoOf(target);if(target.getFullYear()===year&&target.getMonth()===month){focusIso(iso)}else{navigate(target.getMonth(),target.getFullYear());focusIso(iso)}})}}define("contour-calendar",ContourCalendar);class ContourCarousel extends ContourBase{static get observed(){return["items","index","autoplay","paused"]}static get properties(){return{items:{attribute:"items"},index:{attribute:"index"},autoplay:{attribute:"autoplay"},paused:{attribute:"paused",type:Boolean}}}_items(){const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}return Array.isArray(parsed)?parsed:[]}_index(){const i=Number(this.getAttribute("index"));const items=this._items();if(Number.isFinite(i)&&i>=0&&i<items.length)return i;return 0}render(){this.classList.add("c-carousel");this.setAttribute("role","region");this.setAttribute("aria-roledescription","carousel");const track=this.ensure(".c-carousel__track",()=>{const el=document.createElement("div");el.className="c-carousel__track";el.setAttribute("role","group");el.setAttribute("aria-roledescription","slide container");return el});const items=this._items();track.innerHTML="";const idx=this._index();items.forEach((it,i)=>{const slide=document.createElement("div");slide.className="c-carousel__slide"+(i===idx?" is-active":"");slide.setAttribute("role","group");slide.setAttribute("aria-roledescription","slide");slide.setAttribute("aria-label",(i+1)+" of "+items.length);slide.setAttribute("aria-hidden",i===idx?"false":"true");slide.textContent=typeof it==="string"?it:(it.label||it.text||"");slide.dataset.index=String(i);track.appendChild(slide)});const prev=this.ensure(".c-carousel__prev",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-carousel__prev";el.type="button";el.textContent="‹";el.setAttribute("aria-label","Previous slide");return el});const next=this.ensure(".c-carousel__next",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-carousel__next";el.type="button";el.textContent="›";el.setAttribute("aria-label","Next slide");return el});const status=this.ensure(".c-carousel__status",()=>{const el=document.createElement("span");el.className="c-carousel__status";el.setAttribute("aria-live","polite");return el});status.textContent=(idx+1)+" of "+items.length;const dots=this.ensure(".c-carousel__dots",()=>{const el=document.createElement("div");el.className="c-carousel__dots";el.setAttribute("role","tablist");el.setAttribute("aria-label","Slides");return el});dots.innerHTML="";items.forEach((it,i)=>{const dot=document.createElement("button");dot.type="button";dot.className="c-carousel__dot"+(i===idx?" is-active":"");dot.setAttribute("role","tab");dot.setAttribute("aria-label","Go to slide "+(i+1));dot.setAttribute("aria-selected",i===idx?"true":"false");dot.dataset.index=String(i);dots.appendChild(dot)});const autoplay=Number(this.getAttribute("autoplay"));if(Number.isFinite(autoplay)&&autoplay>0){const paused=this.hasAttribute("paused")||this._reducedMotion();const pp=this.ensure(".c-carousel__pause",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-carousel__pause";el.type="button";return el});pp.textContent=paused?"▶":"⏸";pp.setAttribute("aria-label",paused?"Play slides automatically":"Pause automatic slides");pp.setAttribute("aria-pressed",String(paused))}else{const pp=this.querySelector(".c-carousel__pause");if(pp)pp.remove()}}_reducedMotion(){try{return typeof matchMedia==="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}catch(e){return false}}enhance(){const autoplay=Number(this.getAttribute("autoplay"));const want=Number.isFinite(autoplay)&&autoplay>0&&!this.hasAttribute("paused")&&!this._reducedMotion()&&this._items().length>1;if(want&&!this._carouselTimer){this._carouselTimer=setInterval(()=>{const items=this._items();if(!items.length)return;const idx=(this._index()+1)%items.length;this.setAttribute("index",String(idx));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:idx,direction:"next"}}))},Math.max(500,autoplay))}else if(!want&&this._carouselTimer){clearInterval(this._carouselTimer);this._carouselTimer=null}if(this._wiredCarousel)return;this._wiredCarousel=true;onDispose(this,()=>{if(this._carouselTimer){clearInterval(this._carouselTimer);this._carouselTimer=null}});const go=(dir)=>{const items=this._items();if(!items.length)return;let idx=this._index();if(dir==="prev")idx=(idx-1+items.length)%items.length;else idx=(idx+1)%items.length;this.setAttribute("index",String(idx));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:idx,direction:dir}}))};this.addEventListener("click",(e)=>{const pp=e.target&&e.target.closest?e.target.closest(".c-carousel__pause"):null;if(pp&&this.contains(pp)){if(this._reducedMotion())return;const nowPaused=!this.hasAttribute("paused");this.toggleAttribute("paused",nowPaused);this.dispatchEvent(new CustomEvent(nowPaused?"contour:pause":"contour:play",{bubbles:true,composed:true}));return}const prev=e.target&&e.target.closest?e.target.closest(".c-carousel__prev"):null;const next=e.target&&e.target.closest?e.target.closest(".c-carousel__next"):null;if(prev&&this.contains(prev)){go("prev");return}if(next&&this.contains(next)){go("next");return}const dot=e.target&&e.target.closest?e.target.closest(".c-carousel__dot"):null;if(dot&&this.contains(dot)){const i=Number(dot.dataset.index);if(Number.isFinite(i)&&i!==this._index()){this.setAttribute("index",String(i));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:i,direction:"jump"}}))}}});let startX=null;this.addEventListener("pointerdown",(e)=>{startX=e.clientX});this.addEventListener("pointerup",(e)=>{if(startX===null)return;const dx=e.clientX-startX;startX=null;if(Math.abs(dx)>40){if(dx<0)go("next");else go("prev")}});this.addEventListener("pointercancel",()=>{startX=null});this.addEventListener("keydown",(e)=>{if(e.key==="ArrowLeft"){e.preventDefault();go("prev")}else if(e.key==="ArrowRight"){e.preventDefault();go("next")}else if(e.key==="Home"){e.preventDefault();this.setAttribute("index","0");this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:0,direction:"home"}}))}else if(e.key==="End"){e.preventDefault();const last=this._items().length-1;if(last>=0){this.setAttribute("index",String(last));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:last,direction:"end"}}))}}})}}define("contour-carousel",ContourCarousel);class ContourDataGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["columns","rows","page","filter","page-size","resizable","virtual","row-height","loading","error","empty"]}static get properties(){return{columns:{attribute:"columns"},rows:{attribute:"rows"},page:{attribute:"page"},filter:{attribute:"filter"},"page-size":{attribute:"page-size"},resizable:{attribute:"resizable",type:Boolean},virtual:{attribute:"virtual",type:Boolean},"row-height":{attribute:"row-height"},loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"}}}render(){this.classList.add("c-data-grid");if(this.hasAttribute("loading")||this.hasAttribute("error")||this.hasAttribute("empty")){const table=this.ensure(".c-data-grid__table",()=>{const el=document.createElement("table");el.className="c-table c-data-grid__table";el.setAttribute("role","grid");return el});const tbody=this.ensure("tbody",()=>{const el=document.createElement("tbody");return el});if(tbody.parentNode!==table)table.appendChild(tbody);tbody.innerHTML="";const tr=document.createElement("tr");const td=document.createElement("td");td.colSpan=1;td.style.textAlign="center";td.style.color="var(--color-text-muted)";if(this.hasAttribute("loading"))td.textContent=this.getAttribute("loading")||"Loading…";else if(this.hasAttribute("error"))td.textContent=this.getAttribute("error")||"Error";else td.textContent=this.getAttribute("empty")||"No data";tr.appendChild(td);tbody.appendChild(tr);let wrap=this.querySelector(".c-data-grid__wrap");if(!wrap){wrap=document.createElement("div");wrap.className="c-table-wrap c-data-grid__wrap"}if(table.parentNode!==wrap)wrap.appendChild(table);if(wrap.parentNode!==this)this.appendChild(wrap);return}const table=this.ensure(".c-data-grid__table",()=>{const el=document.createElement("table");el.className="c-table c-data-grid__table";el.setAttribute("role","grid");return el});const thead=this.ensure("thead",()=>{const el=document.createElement("thead");return el});const tbody=this.ensure("tbody",()=>{const el=document.createElement("tbody");return el});if(thead.parentNode!==table)table.appendChild(thead);if(tbody.parentNode!==table)table.appendChild(tbody);const cols=this.getAttribute("columns");let parsedCols=[];try{parsedCols=cols?JSON.parse(cols):[]}catch(e){parsedCols=[]}if(parsedCols.length&&!thead.querySelector("tr")){const tr=document.createElement("tr");parsedCols.forEach((c)=>{const th=document.createElement("th");th.setAttribute("role","columnheader");th.setAttribute("aria-sort","none");th.setAttribute("tabindex","0");th.textContent=typeof c==="string"?c:(c.label||c.key||"");tr.appendChild(th)});thead.appendChild(tr)}if(this.hasAttribute("resizable")){Array.from(thead.querySelectorAll("th")).forEach((th)=>{th.style.position="relative";th.setAttribute("data-resizable","true")})}const rows=this.getAttribute("rows");let parsedRows=[];try{parsedRows=rows?JSON.parse(rows):[]}catch(e){parsedRows=[]}table.setAttribute("aria-rowcount",String(parsedRows.length));table.setAttribute("aria-colcount",String(parsedCols.length));const filter=this.getAttribute("filter");if(filter){const q=filter.toLowerCase();parsedRows=parsedRows.filter((r)=>JSON.stringify(r).toLowerCase().includes(q))}const page=Number(this.getAttribute("page")||1);const pageSize=Number(this.getAttribute("page-size")||0);if(pageSize>0){const start=(page-1)*pageSize;parsedRows=parsedRows.slice(start,start+pageSize)}this._dgCols=parsedCols;this._dgRows=parsedRows;this._dgFilteredRows=parsedRows;const virtual=this.hasAttribute("virtual")&&!(Number(this.getAttribute("page-size"))>0);if(virtual){this._renderDataGridWindow(0)}else{tbody.innerHTML="";parsedRows.forEach((r)=>{const tr=document.createElement("tr");parsedCols.forEach((c)=>{const key=typeof c==="string"?c:(c.key||c.label||"");const td=document.createElement("td");td.setAttribute("role","gridcell");td.setAttribute("tabindex","-1");td.textContent=r&&r[key]!=null?r[key]:"";if(!String(td.textContent).trim())td.setAttribute("aria-label","Empty");tr.appendChild(td)});tbody.appendChild(tr)})}let wrap=this.querySelector(".c-data-grid__wrap");if(!wrap){wrap=document.createElement("div");wrap.className="c-table-wrap c-data-grid__wrap"}if(table.parentNode!==wrap)wrap.appendChild(table);if(wrap.parentNode!==this)this.appendChild(wrap);if(!table.querySelector('[tabindex="0"]')){const first=table.querySelector("tbody td, thead th");if(first)first.setAttribute("tabindex","0")}}_rowHeight(){const h=Number(this.getAttribute("row-height"));if(Number.isFinite(h)&&h>0)return h;if(this._measuredRowHeight>0)return this._measuredRowHeight;return cssLength("--data-grid-row-height",32)}_renderDataGridWindow(scrollTop){const table=this.querySelector(".c-data-grid__table");const tbody=table&&table.querySelector("tbody");if(!tbody)return;const cols=this._dgCols||[];const rows=this._dgRows||[];const rh=this._rowHeight();const viewport=400;const visibleCount=Math.ceil(viewport/rh)+6;let start=Math.floor((scrollTop||0)/rh);if(start<0)start=0;if(start>Math.max(0,rows.length-visibleCount))start=Math.max(0,rows.length-visibleCount);const end=Math.min(rows.length,start+visibleCount);tbody.innerHTML="";if(start>0){const sp=document.createElement("tr");const td=document.createElement("td");td.colSpan=Math.max(1,cols.length);td.style.blockSize=(start*rh)+"px";td.style.padding="0";sp.appendChild(td);tbody.appendChild(sp)}for(let i=start;i<end;i++){const r=rows[i];const tr=document.createElement("tr");tr.dataset.index=String(i);cols.forEach((c)=>{const key=typeof c==="string"?c:(c.key||c.label||"");const td=document.createElement("td");td.setAttribute("role","gridcell");td.setAttribute("tabindex","-1");td.textContent=r&&r[key]!=null?r[key]:"";if(!String(td.textContent).trim())td.setAttribute("aria-label","Empty");tr.appendChild(td)});tbody.appendChild(tr)}if(end<rows.length){const sp=document.createElement("tr");const td=document.createElement("td");td.colSpan=Math.max(1,cols.length);td.style.blockSize=((rows.length-end)*rh)+"px";td.style.padding="0";sp.appendChild(td);tbody.appendChild(sp)}if(!tbody.querySelector('[tabindex="0"]')){const first=tbody.querySelector("tr[data-index] td");if(first)first.setAttribute("tabindex","0")}}enhance(){if(this._wiredDataGrid)return;this._wiredDataGrid=true;const wrap=()=>this.querySelector(".c-data-grid__wrap");const onScroll=()=>{const w=wrap();if(w&&this.hasAttribute("virtual"))this._renderDataGridWindow(w.scrollTop)};this.addEventListener("scroll",(e)=>{const w=e.target&&e.target.classList&&e.target.classList.contains("c-data-grid__wrap")?e.target:null;if(w&&this.hasAttribute("virtual"))this._renderDataGridWindow(w.scrollTop)},true);let sortCol=-1,sortDir="asc";this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest("[role='gridcell'], [role='columnheader']"):null;if(!cell||!this.contains(cell))return;const row=cell.parentElement;const table=this.querySelector(".c-data-grid__table");if(!table)return;const rows=Array.from(table.querySelectorAll("tr"));const ri=rows.indexOf(row);const ci=Array.from(row.children).indexOf(cell);let target=null;if(e.key==="ArrowRight")target=row.children[ci+1];else if(e.key==="ArrowLeft")target=row.children[ci-1];else if(e.key==="ArrowDown")target=rows[ri+1]&&rows[ri+1].children[ci];else if(e.key==="ArrowUp")target=rows[ri-1]&&rows[ri-1].children[ci];if(target){e.preventDefault();table.querySelectorAll('[tabindex="0"]').forEach((c)=>c.setAttribute("tabindex","-1"));target.setAttribute("tabindex","0");try{target.focus()}catch(err){}}});this.addEventListener("click",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tr"):null;const th=e.target&&e.target.closest?e.target.closest("th"):null;if(tr&&this.contains(tr)&&!th){const idx=Array.from(tr.parentElement.children).indexOf(tr);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{row:idx}}))}if(th&&this.contains(th)){const idx=Array.from(th.parentElement.children).indexOf(th);if(sortCol===idx)sortDir=sortDir==="asc"?"desc":"asc";else{sortCol=idx;sortDir="asc"}const table=this.querySelector(".c-data-grid__table");const tbody=table&&table.querySelector("tbody");const thead=table&&table.querySelector("thead");const cols=this._dgCols||[];const key=cols[idx]?(typeof cols[idx]==="string"?cols[idx]:(cols[idx].key||cols[idx].label||"")):String(idx);const full=(this._dgFilteredRows||[]).slice();full.sort((a,b)=>{const va=a&&a[key]!=null?a[key]:"";const vb=b&&b[key]!=null?b[key]:"";const na=Number(va),nb=Number(vb);const cmp=(!isNaN(na)&&!isNaN(nb))?na-nb:String(va).localeCompare(String(vb));return sortDir==="asc"?cmp:-cmp});this._dgFilteredRows=full;if(tbody){const page=Number(this.getAttribute("page")||1);const pageSize=Number(this.getAttribute("page-size")||0);let pageRows=full;if(pageSize>0){const start=(page-1)*pageSize;pageRows=full.slice(start,start+pageSize)}tbody.innerHTML="";pageRows.forEach((r)=>{const tr=document.createElement("tr");cols.forEach((c)=>{const k=typeof c==="string"?c:(c.key||c.label||"");const td=document.createElement("td");td.setAttribute("role","gridcell");td.setAttribute("tabindex","-1");td.textContent=r&&r[k]!=null?r[k]:"";tr.appendChild(td)});tbody.appendChild(tr)})}if(thead)Array.from(thead.querySelectorAll("th")).forEach((h,i)=>{h.setAttribute("aria-sort",i===idx?(sortDir==="asc"?"ascending":"descending"):"none")});this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:true,composed:true,detail:{column:idx,direction:sortDir}}))}});this.addEventListener("pointerdown",(e)=>{if(!this.hasAttribute("resizable"))return;const th=e.target&&e.target.closest?e.target.closest("th[data-resizable]"):null;if(!th||!this.contains(th)||th.getBoundingClientRect().right-e.clientX>10)return;e.preventDefault();const startX=e.clientX;const startWidth=th.getBoundingClientRect().width;const index=Array.from(th.parentElement.children).indexOf(th);const move=(event)=>{const width=Math.max(48,startWidth+event.clientX-startX);const table=this.querySelector(".c-data-grid__table");if(table)Array.from(table.rows).forEach((row)=>{if(row.children[index])row.children[index].style.inlineSize=width+"px"})};const stop=()=>window.removeEventListener("pointermove",move);window.addEventListener("pointermove",move);window.addEventListener("pointerup",stop,{once:true});onDispose(this,stop)})}}define("contour-data-grid",ContourDataGrid);class ContourTreeGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","expanded","loading","error","empty"]}static get properties(){return{items:{attribute:"items"},expanded:{attribute:"expanded"},loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"}}}_expandedSet(){const raw=this.getAttribute("expanded");if(!raw)return new Set();try{return new Set(JSON.parse(raw))}catch(e){return new Set([raw])}}render(){this.classList.add("c-tree-grid");const table=this.ensure(".c-tree-grid__table",()=>{const el=document.createElement("table");el.className="c-table c-tree-grid__table";el.setAttribute("role","treegrid");return el});table.setAttribute("aria-label","Tree grid");const tbody=this.ensure("tbody",()=>{const el=document.createElement("tbody");return el});if(tbody.parentNode!==table)table.appendChild(tbody);const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}const expanded=this._expandedSet();tbody.innerHTML="";const rows=[];const renderNode=(node,depth,path)=>{const tr=document.createElement("tr");tr.setAttribute("role","row");tr.setAttribute("tabindex","0");tr.setAttribute("aria-level",String(depth+1));tr.dataset.path=path;const hasChildren=!!(node&&Array.isArray(node.children)&&node.children.length);if(hasChildren){tr.setAttribute("aria-expanded",expanded.has(path)?"true":"false")}const td=document.createElement("td");td.setAttribute("role","gridcell");td.style.paddingInlineStart=(depth*1.25)+"rem";const label=(node&&(node.label||node.text||node.name))||"";if(hasChildren){const toggle=document.createElement("button");toggle.type="button";toggle.className="c-tree-grid__toggle";toggle.textContent=expanded.has(path)?"▾":"▸";toggle.setAttribute("aria-label",(expanded.has(path)?"Collapse":"Expand")+" "+label);td.appendChild(toggle)}const span=document.createElement("span");span.className="c-tree-grid__label";span.textContent=label;td.appendChild(span);tr.appendChild(td);tbody.appendChild(tr);rows.push(tr);if(hasChildren&&expanded.has(path)){node.children.forEach((c,i)=>renderNode(c,depth+1,path+"."+i))}};parsed.forEach((n,i)=>renderNode(n,0,String(i)));let wrap=this.querySelector(".c-tree-grid__wrap");if(!wrap){wrap=document.createElement("div");wrap.className="c-table-wrap c-tree-grid__wrap"}if(table.parentNode!==wrap)wrap.appendChild(table);if(wrap.parentNode!==this)this.appendChild(wrap)}enhance(){if(this._wiredTreeGrid)return;this._wiredTreeGrid=true;const rows=()=>Array.from(this.querySelectorAll("tr[role='row']"));this.addEventListener("click",(e)=>{const toggle=e.target&&e.target.closest?e.target.closest(".c-tree-grid__toggle"):null;const tr=e.target&&e.target.closest?e.target.closest("tr[role='row']"):null;if(!tr||!this.contains(tr))return;const path=tr.dataset.path;if(toggle){e.preventDefault();const expanded=this._expandedSet();if(expanded.has(path))expanded.delete(path);else expanded.add(path);this.setAttribute("expanded",JSON.stringify([...expanded]));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{path,expanded:expanded.has(path)}}))}else{this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{path}}))}});this.addEventListener("keydown",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tr[role='row']"):null;if(!tr||!this.contains(tr))return;const all=rows();const idx=all.indexOf(tr);const path=tr.dataset.path;const hasChildren=tr.getAttribute("aria-expanded")!==null;const expanded=this._expandedSet();if(e.key==="ArrowRight"&&hasChildren&&!expanded.has(path)){e.preventDefault();expanded.add(path);this.setAttribute("expanded",JSON.stringify([...expanded]));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{path,expanded:true}}))}else if(e.key==="ArrowLeft"&&hasChildren&&expanded.has(path)){e.preventDefault();expanded.delete(path);this.setAttribute("expanded",JSON.stringify([...expanded]));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{path,expanded:false}}))}else if(e.key==="ArrowDown"){e.preventDefault();if(all[idx+1])try{all[idx+1].focus()}catch(err){}}else if(e.key==="ArrowUp"){e.preventDefault();if(all[idx-1])try{all[idx-1].focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();const toggle=tr.querySelector(".c-tree-grid__toggle");if(toggle)toggle.click()}})}}define("contour-tree-grid",ContourTreeGrid);class ContourPullToRefresh extends ContourBase{static get observed(){return["threshold"]}static get properties(){return{threshold:{attribute:"threshold"}}}render(){this.classList.add("c-pull-to-refresh");if(!this.hasAttribute("role"))this.setAttribute("role","region");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",labelText(this,"label","Pull to refresh"));const ind=this.ensure(".c-pull-to-refresh__indicator",()=>{const e=document.createElement("div");e.className="c-pull-to-refresh__indicator";return e});ind.innerHTML="";const label=document.createElement("span");label.className="c-pull-to-refresh__label";label.setAttribute("aria-live","polite");label.textContent=this._ptrError?this._ptrError:(this._ptrRefreshing?labelText(this,"refreshing","Refreshing…"):labelText(this,"label","Pull to refresh"));ind.appendChild(label);const btn=document.createElement("button");btn.type="button";btn.className="c-pull-to-refresh__btn";btn.textContent=labelText(this,"refresh","Refresh");ind.appendChild(btn);if(ind.parentNode!==this)this.prepend(ind);this.classList.toggle("is-refreshing",!!this._ptrRefreshing);this.classList.toggle("has-error",!!this._ptrError);this.setAttribute("aria-busy",String(!!this._ptrRefreshing))}complete(){this._ptrRefreshing=false;this._ptrError=null;this.style.removeProperty("--ptr-offset");this.requestRender()}fail(message){this._ptrRefreshing=false;this._ptrError=String(message||labelText(this,"error","Refresh failed"));this.style.removeProperty("--ptr-offset");this.requestRender();this.dispatchEvent(new CustomEvent("contour:error",{bubbles:true,composed:true,detail:{message:this._ptrError}}))}_refresh(){if(this._ptrRefreshing)return;this._ptrRefreshing=true;this._ptrError=null;this.style.removeProperty("--ptr-offset");this.requestRender();this.dispatchEvent(new CustomEvent("contour:refresh",{bubbles:true,composed:true}))}enhance(){if(this._wiredPullToRefresh)return;this._wiredPullToRefresh=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-pull-to-refresh__btn"):null;if(btn&&this.contains(btn))this._refresh()});let startY=0;let pulling=false;let offset=0;this.addEventListener("pointerdown",(e)=>{if(this._ptrRefreshing||this.scrollTop>0)return;if(e.target&&e.target.closest&&e.target.closest(".c-pull-to-refresh__btn"))return;startY=e.clientY;pulling=true;offset=0;try{this.setPointerCapture(e.pointerId)}catch(err){}});this.addEventListener("pointermove",(e)=>{if(!pulling)return;const dy=e.clientY-startY;if(dy>0){offset=Math.min(120,dy*0.6);this.style.setProperty("--ptr-offset",offset+"px")}});const end=()=>{if(!pulling)return;pulling=false;const thr=Number(this.getAttribute("threshold"))||60;if(offset>=thr)this._refresh();else this.style.removeProperty("--ptr-offset");offset=0};this.addEventListener("pointerup",end);this.addEventListener("pointercancel",end)}}define("contour-pull-to-refresh",ContourPullToRefresh);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"]));let ADOPTED=null;let ADOPTED_KEY="";const adoptedSheets=()=>{let key=document.styleSheets.length+":";for(const sheet of document.styleSheets){let rules=-1;try{rules=sheet.cssRules.length}catch(e){}key+=(sheet.href||"")+"~"+rules+"|"}if(ADOPTED&&key===ADOPTED_KEY)return ADOPTED;ADOPTED_KEY=key;ADOPTED=[];const collect=(sheet,out)=>{let rules;try{rules=sheet.cssRules}catch(e){return}if(!rules)return;for(const r of rules){if(r instanceof CSSImportRule){if(r.styleSheet)collect(r.styleSheet,out)}else{try{out.push(r.cssText)}catch(e){}}}};for(const sheet of document.styleSheets){try{if(sheet.href&&new URL(sheet.href).origin===location.origin){const collected=[];collect(sheet,collected);const built=new CSSStyleSheet();if(collected.length)built.replaceSync(collected.join("\n"));ADOPTED.push(built)}}catch(e){}}return ADOPTED};const _ShadowParent=(typeof HTMLElement!=="undefined")?HTMLElement:Object;class ContourShadow extends _ShadowParent{static get observedAttributes(){return MODS}constructor(){super();let root=this.shadowRoot;if(!root){root=this.attachShadow({mode:"open"});if(this.constructor.contourTemplate){root.appendChild(this.constructor.contourTemplate.content.cloneNode(true))}}const sheets=adoptedSheets();if(sheets.length){try{root.adoptedStyleSheets=sheets}catch(e){}}this._shadowBase=root.firstElementChild?root.firstElementChild.className:""}enhance(root){if(!root)root=this.shadowRoot;if(!root)return;root.querySelectorAll("details").forEach((d)=>{const summary=d.querySelector("summary");if(summary&&!summary.hasAttribute("aria-expanded")){summary.setAttribute("aria-expanded",String(d.open));d.addEventListener("toggle",()=>{summary.setAttribute("aria-expanded",String(d.open))})}});root.querySelectorAll("[data-live]").forEach((el)=>{if(!el.hasAttribute("role"))el.setAttribute("role","status");if(!el.hasAttribute("aria-live"))el.setAttribute("aria-live","polite")});root.querySelectorAll(".c-spinner").forEach((el)=>{if(!el.hasAttribute("role"))el.setAttribute("role","status");if(!el.hasAttribute("aria-live"))el.setAttribute("aria-live","polite")});root.querySelectorAll(".c-toast, .c-toast-host").forEach((el)=>{if(!el.hasAttribute("role"))el.setAttribute("role","status");if(!el.hasAttribute("aria-live"))el.setAttribute("aria-live","polite");if(!el.hasAttribute("aria-atomic"))el.setAttribute("aria-atomic","true")});root.querySelectorAll("[role='tab']").forEach((tab)=>{const ctrl=tab.getAttribute("aria-controls");if(ctrl){const panel=root.querySelector("#"+CSS.escape(ctrl))||document.getElementById(ctrl);if(panel&&!panel.hasAttribute("aria-labelledby")){if(!tab.id)tab.id=contourId("tab");panel.setAttribute("aria-labelledby",tab.id)}}});root.querySelectorAll("input, textarea, select").forEach((input)=>{if(input.hasAttribute("aria-describedby"))return;const field=input.closest(".c-field");if(field){const hint=field.querySelector(".c-field__hint");if(hint){if(!hint.id)hint.id=contourId("hint");input.setAttribute("aria-describedby",hint.id)}const err=field.querySelector(".c-field__error");if(err){if(!err.id)err.id=contourId("err");const existing=input.getAttribute("aria-describedby")||"";input.setAttribute("aria-describedby",(existing+" "+err.id).trim())}}});root.querySelectorAll(".c-alert").forEach((el)=>{const urgent=el.classList.contains("c-alert--warning")||el.classList.contains("c-alert--danger");const role=urgent?"alert":"status";const live=urgent?"assertive":"polite";if(!el.hasAttribute("role")||el.dataset.contourAutoRole){el.setAttribute("role",role);el.dataset.contourAutoRole=role}if(!el.hasAttribute("aria-live")||el.dataset.contourAutoLive){el.setAttribute("aria-live",live);el.dataset.contourAutoLive=live}});root.querySelectorAll("input[required], textarea[required], select[required]").forEach((el)=>{if(!el.hasAttribute("aria-required"))el.setAttribute("aria-required","true")})}connectedCallback(){this.applyMods();try{this.enhance(this.shadowRoot)}catch(e){}try{wcReset(this);wireTabs(this);wireSegmented(this);wireCombobox(this);wireTree(this);wireMenu(this);wirePagination(this);wireCopy(this);wireRemovable(this)}catch(e){}if(this.shadowRoot&&!this._wiredSlotchange){this._wiredSlotchange=true;this.shadowRoot.addEventListener("slotchange",()=>{try{this.enhance(this.shadowRoot);wireTabs(this);wireSegmented(this);wireCombobox(this);wireTree(this);wireMenu(this);wirePagination(this);wireCopy(this);wireRemovable(this)}catch(e){}})}}attributeChangedCallback(){this.applyMods()}applyMods(){const el=this.shadowRoot.firstElementChild;if(!el||!this._shadowBase)return;const mods=[];for(const attr of MODS){const val=this.getAttribute(attr);if(!val)continue;for(const cls of this._shadowBase.split(/\s+/)){if(cls)mods.push("c-"+cls.replace(/^c-/,"")+"--"+val)}}el.className=(this._shadowBase+" "+mods.join(" ")).trim();if(el.classList.contains("c-alert")){const urgent=el.classList.contains("c-alert--warning")||el.classList.contains("c-alert--danger");const role=urgent?"alert":"status";const live=urgent?"assertive":"polite";if(!el.hasAttribute("role")||el.dataset.contourAutoRole){el.setAttribute("role",role);el.dataset.contourAutoRole=role}if(!el.hasAttribute("aria-live")||el.dataset.contourAutoLive){el.setAttribute("aria-live",live);el.dataset.contourAutoLive=live}}}}const SHADOW_PARTS_PUBLIC={};const SHADOW_MARKUP={};const recordParts=(name,markup)=>{SHADOW_PARTS_PUBLIC[name]=[...markup.matchAll(/part="([^"]+)"/g)].flatMap((m)=>m[1].split(/\s+/)).filter(Boolean)};const shadow=(name,markup)=>{SHADOW_MARKUP[name]=markup;recordParts(name,markup);if(typeof document==="undefined")return;const tpl=document.createElement("template");tpl.innerHTML=markup;const cls=class extends ContourShadow{};cls.contourTemplate=tpl;define(name,cls)};const slotWrapper=(tag,block,part)=>"<"+tag+' class="c-'+block+'" part="'+(part||block)+'"'+(tag==="button"?' type="button"':"")+"><slot></slot></"+tag+">";const 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","scheme-toggle"],span:["avatar","badge","chip","dot","flag","live-badge","mark","pill"],a:["link","linkish"],kbd:["kbd"],label:["check","radio","switch"],select:["select"],nav:["docs-nav"],};const SHADOW_PARTS={"version-banner":"banner","contour-plot":"plot",};for(const[tag,blocks]of Object.entries(SHADOW_SLOTS)){for(const block of blocks){const part=SHADOW_PARTS[block]||block;shadow("contour-shadow-"+block,slotWrapper(tag,block,part))}}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-table",`<div class="c-table-wrap" part="wrap"><table class="c-table" part="table"><thead><slot name="head"></slot></thead><tbody><slot></slot></tbody></table></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-input",`<input class="c-input" part="input" />`);shadow("contour-shadow-spinner",`<span class="c-spinner" part="spinner" aria-label="Loading"></span>`);shadow("contour-shadow-textarea",`<textarea class="c-textarea" part="textarea"></textarea>`);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\"><use href=\"#i-x\" /></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=(typeof document!=="undefined")?(()=>{const tpl=document.createElement("template");tpl.innerHTML=DIALOG_MARKUP;return tpl})():null;enhance(root){super.enhance(root);if(this._wiredShadowDialog)return;this._wiredShadowDialog=true;const dlg=root.querySelector("dialog");const close=root.querySelector('[part="close"]');if(close)close.addEventListener("click",()=>dlg?.close());if(dlg){let lastFocus=null;dlg.addEventListener("beforetoggle",(e)=>{if(e.newState==="open"){lastFocus=document.activeElement;this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}));const focusable=dlg.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable)try{focusable.focus()}catch(e){}}else if(e.newState==="closed"){this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));if(lastFocus&&typeof lastFocus.focus==="function"){try{lastFocus.focus()}catch(e){}}}});dlg.addEventListener("keydown",(e)=>{if(e.key!=="Tab")return;const focusables=Array.from(dlg.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])"));if(!focusables.length)return;const first=focusables[0];const last=focusables[focusables.length-1];if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus()}else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus()}})}}show(){this.shadowRoot?.querySelector("dialog")?.showModal()}close(){this.shadowRoot?.querySelector("dialog")?.close()}showModal(){this.show()}get open(){return!!this.shadowRoot?.querySelector("dialog")?.open}set open(v){if(v)this.show();else this.close()}get returnValue(){return this.shadowRoot?.querySelector("dialog")?.returnValue??""}set returnValue(v){const d=this.shadowRoot?.querySelector("dialog");if(d)d.returnValue=String(v)}}define("contour-shadow-dialog",ContourShadowDialog);const renderShadowDSD=(tag,attrs="",light="")=>{const markup=SHADOW_MARKUP[tag];if(typeof markup!=="string")return null;const attrStr=attrs?(attrs.startsWith(" ")?attrs:" "+attrs):"";return`<${tag}${attrStr}><template shadowrootmode="open">${markup}</template>${light}</${tag}>`};const FROZEN_SHADOW_MARKUP=Object.freeze({...SHADOW_MARKUP});if(typeof globalThis!=="undefined"){globalThis.ContourShadowTemplates=FROZEN_SHADOW_MARKUP}if(typeof window!=="undefined"){window.ContourElements=Object.freeze(REGISTERED.slice());window.ContourShadowParts=Object.freeze(Object.fromEntries(Object.entries(SHADOW_PARTS_PUBLIC).map(([name,parts])=>[name,Object.freeze([...new Set(parts)])]),));window.ContourEvents=Object.freeze(CONTOUR_EVENTS);if(!window.Contour)window.Contour={};try{window.Contour.shadowTemplates=FROZEN_SHADOW_MARKUP}catch{}}export{SHADOW_MARKUP,renderShadowDSD};