function t(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}console.groupCollapsed("%c🌊 SEA TEMPERATURES CARD%cv3.1.0","color: orange; font-weight: bold; background: black; padding: 2px 4px; border-radius: 2px 0 0 2px;","color: white; font-weight: bold; background: dimgray; padding: 2px 4px; border-radius: 0 2px 2px 0;"),console.info("A Lovelace card to display sea temperatures."),console.info("Github: https://github.com/timmaurice/sea-temperatures.git"),console.info("Sponsor: https://buymeacoffee.com/timmaurice"),console.groupEnd(),"function"==typeof SuppressedError&&SuppressedError; /** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const e=globalThis,n=e.ShadowRoot&&(void 0===e.ShadyCSS||e.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,r=Symbol(),i=new WeakMap;let o=class{constructor(t,e,n){if(this._$cssResult$=!0,n!==r)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(n&&void 0===t){const n=void 0!==e&&1===e.length;n&&(t=i.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&i.set(e,t))}return t}toString(){return this.cssText}};const a=t=>new o("string"==typeof t?t:t+"",void 0,r),s=(t,...e)=>{const n=1===t.length?t[0]:e.reduce((e,n,r)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+t[r+1],t[0]);return new o(n,t,r)},l=n?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return a(e)})(t):t,{is:u,defineProperty:c,getOwnPropertyDescriptor:h,getOwnPropertyNames:f,getOwnPropertySymbols:d,getPrototypeOf:p}=Object,g=globalThis,_=g.trustedTypes,m=_?_.emptyScript:"",y=g.reactiveElementPolyfillSupport,v=(t,e)=>t,w={toAttribute(t,e){switch(e){case Boolean:t=t?m:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=null!==t;break;case Number:n=null===t?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch(t){n=null}}return n}},x=(t,e)=>!u(t,e),b={attribute:!0,type:String,converter:w,reflect:!1,useDefault:!1,hasChanged:x}; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */Symbol.metadata??=Symbol("metadata"),g.litPropertyMetadata??=new WeakMap;let $=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=b){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const n=Symbol(),r=this.getPropertyDescriptor(t,n,e);void 0!==r&&c(this.prototype,t,r)}}static getPropertyDescriptor(t,e,n){const{get:r,set:i}=h(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:r,set(e){const o=r?.call(this);i?.call(this,e),this.requestUpdate(t,o,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=p(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...f(t),...d(t)];for(const n of e)this.createProperty(n,t[n])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,n]of e)this.elementProperties.set(t,n)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const n=this._$Eu(t,e);void 0!==n&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const n=new Set(t.flat(1/0).reverse());for(const t of n)e.unshift(l(t))}else void 0!==t&&e.push(l(t));return e}static _$Eu(t,e){const n=e.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const n of e.keys())this.hasOwnProperty(n)&&(t.set(n,this[n]),delete this[n]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,r)=>{if(n)t.adoptedStyleSheets=r.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const n of r){const r=document.createElement("style"),i=e.litNonce;void 0!==i&&r.setAttribute("nonce",i),r.textContent=n.cssText,t.appendChild(r)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,n){this._$AK(t,n)}_$ET(t,e){const n=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,n);if(void 0!==r&&!0===n.reflect){const i=(void 0!==n.converter?.toAttribute?n.converter:w).toAttribute(e,n.type);this._$Em=t,null==i?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(t,e){const n=this.constructor,r=n._$Eh.get(t);if(void 0!==r&&this._$Em!==r){const t=n.getPropertyOptions(r),i="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:w;this._$Em=r;const o=i.fromAttribute(e,t.type);this[r]=o??this._$Ej?.get(r)??o,this._$Em=null}}requestUpdate(t,e,n,r=!1,i){if(void 0!==t){const o=this.constructor;if(!1===r&&(i=this[t]),n??=o.getPropertyOptions(t),!((n.hasChanged??x)(i,e)||n.useDefault&&n.reflect&&i===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,n))))return;this.C(t,e,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:n,reflect:r,wrapped:i},o){n&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),!0!==i||void 0!==o)||(this._$AL.has(t)||(this.hasUpdated||n||(e=void 0),this._$AL.set(t,e)),!0===r&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,n]of t){const{wrapped:t}=n,r=this[e];!0!==t||this._$AL.has(e)||void 0===r||this.C(e,void 0,n,r)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};$.elementStyles=[],$.shadowRootOptions={mode:"open"},$[v("elementProperties")]=new Map,$[v("finalized")]=new Map,y?.({ReactiveElement:$}),(g.reactiveElementVersions??=[]).push("2.1.2"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const A=globalThis,M=t=>t,S=A.trustedTypes,C=S?S.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",E=`lit$${Math.random().toFixed(9).slice(2)}$`,N="?"+E,k=`<${N}>`,D=document,U=()=>D.createComment(""),P=t=>null===t||"object"!=typeof t&&"function"!=typeof t,O=Array.isArray,F="[ \t\n\f\r]",H=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,L=/-->/g,z=/>/g,j=RegExp(`>|${F}(?:([^\\s"'>=/]+)(${F}*=${F}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Y=/'/g,R=/"/g,q=/^(?:script|style|textarea|title)$/i,I=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),W=I(1),X=I(2),V=Symbol.for("lit-noChange"),B=Symbol.for("lit-nothing"),Z=new WeakMap,G=D.createTreeWalker(D,129);function J(t,e){if(!O(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==C?C.createHTML(e):e}const Q=(t,e)=>{const n=t.length-1,r=[];let i,o=2===e?"":3===e?"":"",a=H;for(let e=0;e"===l[0]?(a=i??H,u=-1):void 0===l[1]?u=-2:(u=a.lastIndex-l[2].length,s=l[1],a=void 0===l[3]?j:'"'===l[3]?R:Y):a===R||a===Y?a=j:a===L||a===z?a=H:(a=j,i=void 0);const h=a===j&&t[e+1].startsWith("/>")?" ":"";o+=a===H?n+k:u>=0?(r.push(s),n.slice(0,u)+T+n.slice(u)+E+h):n+E+(-2===u?e:h)}return[J(t,o+(t[n]||"")+(2===e?"":3===e?"":"")),r]};class K{constructor({strings:t,_$litType$:e},n){let r;this.parts=[];let i=0,o=0;const a=t.length-1,s=this.parts,[l,u]=Q(t,e);if(this.el=K.createElement(l,n),G.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=G.nextNode())&&s.length0){r.textContent=S?S.emptyScript:"";for(let n=0;nO(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==B&&P(this._$AH)?this._$AA.nextSibling.data=t:this.T(D.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:n}=t,r="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=K.createElement(J(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(e);else{const t=new et(r,this),n=t.u(this.options);t.p(e),this.T(n),this._$AH=t}}_$AC(t){let e=Z.get(t.strings);return void 0===e&&Z.set(t.strings,e=new K(t)),e}k(t){O(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,r=0;for(const i of t)r===e.length?e.push(n=new nt(this.O(U()),this.O(U()),this,this.options)):n=e[r],n._$AI(i),r++;r2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=B}_$AI(t,e=this,n,r){const i=this.strings;let o=!1;if(void 0===i)t=tt(this,t,e,0),o=!P(t)||t!==this._$AH&&t!==V,o&&(this._$AH=t);else{const r=t;let a,s;for(t=i[0],a=0;a{const r=n?.renderBefore??e;let i=r._$litPart$;if(void 0===i){const t=n?.renderBefore??null;r._$litPart$=i=new nt(e.insertBefore(U(),t),t,void 0,n??{})}return i._$AI(t),i})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return V}}ct._$litElement$=!0,ct.finalized=!0,ut.litElementHydrateSupport?.({LitElement:ct});const ht=ut.litElementPolyfillSupport;ht?.({LitElement:ct}),(ut.litElementVersions??=[]).push("4.2.2"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const ft={attribute:!0,type:String,converter:w,reflect:!1,hasChanged:x},dt=(t=ft,e,n)=>{const{kind:r,metadata:i}=n;let o=globalThis.litPropertyMetadata.get(i);if(void 0===o&&globalThis.litPropertyMetadata.set(i,o=new Map),"setter"===r&&((t=Object.create(t)).wrapped=!0),o.set(n.name,t),"accessor"===r){const{name:r}=n;return{set(n){const i=e.get.call(this);e.set.call(this,n),this.requestUpdate(r,i,t,!0,n)},init(e){return void 0!==e&&this.C(r,void 0,t,e),e}}}if("setter"===r){const{name:r}=n;return function(n){const i=this[r];e.call(this,n),this.requestUpdate(r,i,t,!0,n)}}throw Error("Unsupported decorator location: "+r)}; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */function pt(t){return(e,n)=>"object"==typeof n?dt(t,e,n):((t,e,n)=>{const r=e.hasOwnProperty(n);return e.constructor.createProperty(n,t),r?Object.getOwnPropertyDescriptor(e,n):void 0})(t,e,n)} /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */function gt(t){return pt({...t,state:!0,attribute:!1})} /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */const _t={en:{editor:{groups:{display:"Display"},title:"Title (Optional)",places:"Places",show_trend:"Show trend indicators (vs Yesterday)",show_last_updated:"Show last updated",show_stats:"Show statistics (Yesterday, Last Week, 10-Year Avg)",show_chart:"Show historical chart (30d)",show_country:"Append country to place name",chart_smoothing:"Chart smoothing",chart_smoothing_options:{smooth:"Smooth",linear:"Linear",step:"Step"},sort_by:"Sort places by",sort_by_options:{default:"Default (Manual)",name:"Name (A-Z)",temp_asc:"Temperature (Coldest First)",temp_desc:"Temperature (Warmest First)"},add_place:"Add Place"},card:{yesterday:"Yesterday",last_week:"Last Week",average_avg:"10-Year Avg",averages:"Averages",min:"Min",max:"Max",avg:"Avg"},common:{errors:{no_places:"You need to define at least one place.",duplicate_place:"This place is already in your list."}}},de:{editor:{groups:{display:"Anzeige"},title:"Titel (Optional)",places:"Orte",show_trend:"Zeige Trend-Indikatoren (vs Gestern)",show_last_updated:"Zuletzt aktualisiert anzeigen",show_stats:"Statistiken anzeigen (Gestern, Letzte Woche, 10-Jahres-Ø)",show_chart:"Historisches Diagramm anzeigen (30t)",show_country:"Land an den Ortsnamen anhängen",chart_smoothing:"Kurvenglättung",chart_smoothing_options:{smooth:"Weich",linear:"Linear",step:"Stufen"},sort_by:"Orte sortieren nach",sort_by_options:{default:"Standard (Manuell)",name:"Name (A-Z)",temp_asc:"Temperatur (Kälteste zuerst)",temp_desc:"Temperatur (Wärmste zuerst)"},add_place:"Ort hinzufügen"},card:{yesterday:"Gestern",last_week:"Letzte Woche",average_avg:"10-Jahres-Ø",averages:"Durchschnitte",min:"Min",max:"Max",avg:"Ø"},common:{errors:{no_places:"Du musst mindestens einen Ort definieren.",duplicate_place:"Dieser Ort ist bereits in deiner Liste."}}},fr:{editor:{groups:{display:"Affichage"},title:"Titre (Optionnel)",places:"Lieux",show_trend:"Afficher les indicateurs de tendance (vs Hier)",show_last_updated:"Afficher la dernière mise à jour",show_stats:"Afficher les statistiques (Hier, La semaine dernière, Moy. 10 ans)",show_chart:"Afficher le graphique historique (30j)",show_country:"Ajouter le pays au nom du lieu",chart_smoothing:"Lissage du graphique",chart_smoothing_options:{smooth:"Lisse",linear:"Linéaire",step:"En escalier"},sort_by:"Trier les lieux par",sort_by_options:{default:"Défaut (Manuel)",name:"Nom (A-Z)",temp_asc:"Température (Le plus froid d'abord)",temp_desc:"Température (Le plus chaud d'abord)"},add_place:"Ajouter un lieu"},card:{yesterday:"Hier",last_week:"La semaine dernière",average_avg:"Moy. 10 ans",averages:"Moyennes",min:"Min",max:"Max",avg:"Moy"},common:{errors:{no_places:"Vous devez définir au moins un lieu.",duplicate_place:"Ce lieu est déjà dans votre liste."}}},es:{editor:{groups:{display:"Pantalla"},title:"Título (Opcional)",places:"Lugares",show_trend:"Mostrar indicadores de tendencia (vs Ayer)",show_last_updated:"Mostrar última actualización",show_stats:"Mostrar estadísticas (Ayer, Semana pasada, Media 10 años)",show_chart:"Mostrar gráfico histórico (30d)",show_country:"Añadir el país al nombre del lugar",chart_smoothing:"Suavizado del gráfico",chart_smoothing_options:{smooth:"Suave",linear:"Lineal",step:"Escalonado"},sort_by:"Ordenar lugares por",sort_by_options:{default:"Por defecto (Manual)",name:"Nombre (A-Z)",temp_asc:"Temperatura (Más frío primero)",temp_desc:"Temperatura (Más cálido primero)"},add_place:"Añadir Lugar"},card:{yesterday:"Ayer",last_week:"Semana Pasada",average_avg:"Media 10 años",averages:"Medias",min:"Mín",max:"Máx",avg:"Med"},common:{errors:{no_places:"Debes definir al menos un lugar.",duplicate_place:"Este lugar ya está en tu lista."}}},it:{editor:{groups:{display:"Visualizzazione"},title:"Titolo (Opzionale)",places:"Luoghi",show_trend:"Mostra indicatori di tendenza (vs Ieri)",show_last_updated:"Mostra ultimo aggiornamento",show_stats:"Mostra statistiche (Ieri, Settimana scorsa, Media 10 anni)",show_chart:"Mostra grafico storico (30g)",show_country:"Aggiungi il paese al nome del luogo",chart_smoothing:"Arrotondamento grafico",chart_smoothing_options:{smooth:"Morbido",linear:"Lineare",step:"A gradini"},sort_by:"Ordina luoghi per",sort_by_options:{default:"Predefinito (Manuale)",name:"Nome (A-Z)",temp_asc:"Temperatura (Più freddo prima)",temp_desc:"Temperatura (Più caldo prima)"},add_place:"Aggiungi Luogo"},card:{yesterday:"Ieri",last_week:"Settimana Scorsa",average_avg:"Media 10 anni",averages:"Medie",min:"Min",max:"Max",avg:"Med"},common:{errors:{no_places:"Devi definire almeno un luogo.",duplicate_place:"Questo luogo è già nella tua lista."}}}};function mt(t,e){let n=_t[t];for(const t of e){if("object"!=typeof n||null===n)return;n=n[t]}return"string"==typeof n?n:void 0}function yt(t,e,n={}){const r=t?.language||"en",i=e.replace("component.sea-temperatures-card.","").split("."),o=mt(r,i)??mt("en",i);if("string"==typeof o){let t=o;for(const e in n)t=t.replace(`{${e}}`,String(n[e]));return t}return e}const vt=(t,e,n,r)=>{const i=new CustomEvent(e,{bubbles:!0,cancelable:!1,composed:!0,...r,detail:n});t.dispatchEvent(i)};function wt(t,e){return null==t||null==e?NaN:te?1:t>=e?0:NaN}function xt(t,e){return null==t||null==e?NaN:et?1:e>=t?0:NaN}function bt(t){let e,n,r;function i(t,r,i=0,o=t.length){if(i>>1;n(t[e],r)<0?i=e+1:o=e}while(iwt(t(e),n),r=(e,n)=>t(e)-n):(e=t===wt||t===xt?t:$t,n=t,r=t),{left:i,center:function(t,e,n=0,o=t.length){const a=i(t,e,n,o-1);return a>n&&r(t[a-1],e)>-r(t[a],e)?a-1:a},right:function(t,r,i=0,o=t.length){if(i>>1;n(t[e],r)<=0?i=e+1:o=e}while(i=e&&(n=r=e):(n>e&&(n=e),r=o&&(n=r=o):(n>o&&(n=o),r=St?10:o>=Ct?5:o>=Tt?2:1;let s,l,u;return i<0?(u=Math.pow(10,-i)/a,s=Math.round(t*u),l=Math.round(e*u),s/ue&&--l,u=-u):(u=Math.pow(10,i)*a,s=Math.round(t/u),l=Math.round(e/u),s*ue&&--l),l{}};function Ut(){for(var t,e=0,n=arguments.length,r={};e=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),a=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a0)for(var n,r,i=new Array(n),o=0;o=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),Lt.hasOwnProperty(e)?{space:Lt[e],local:t}:t}function jt(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Ht&&e.documentElement.namespaceURI===Ht?e.createElement(t):e.createElementNS(n,t)}}function Yt(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Rt(t){var e=zt(t);return(e.local?Yt:jt)(e)}function qt(){}function It(t){return null==t?qt:function(){return this.querySelector(t)}}function Wt(){return[]}function Xt(t){return null==t?Wt:function(){return this.querySelectorAll(t)}}function Vt(t){return function(){return function(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}(t.apply(this,arguments))}}function Bt(t){return function(){return this.matches(t)}}function Zt(t){return function(e){return e.matches(t)}}var Gt=Array.prototype.find;function Jt(){return this.firstElementChild}var Qt=Array.prototype.filter;function Kt(){return Array.from(this.children)}function te(t){return new Array(t.length)}function ee(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function ne(t,e,n,r,i,o){for(var a,s=0,l=e.length,u=o.length;se?1:t>=e?0:NaN}function se(t){return function(){this.removeAttribute(t)}}function le(t){return function(){this.removeAttributeNS(t.space,t.local)}}function ue(t,e){return function(){this.setAttribute(t,e)}}function ce(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function he(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function fe(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function de(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function pe(t){return function(){this.style.removeProperty(t)}}function ge(t,e,n){return function(){this.style.setProperty(t,e,n)}}function _e(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function me(t,e){return t.style.getPropertyValue(e)||de(t).getComputedStyle(t,null).getPropertyValue(e)}function ye(t){return function(){delete this[t]}}function ve(t,e){return function(){this[t]=e}}function we(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function xe(t){return t.trim().split(/^|\s+/)}function be(t){return t.classList||new $e(t)}function $e(t){this._node=t,this._names=xe(t.getAttribute("class")||"")}function Ae(t,e){for(var n=be(t),r=-1,i=e.length;++r=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Xe=[null];function Ve(t,e){this._groups=t,this._parents=e}function Be(){return new Ve([[document.documentElement]],Xe)}function Ze(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Ge(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Je(){}Ve.prototype=Be.prototype={constructor:Ve,select:function(t){"function"!=typeof t&&(t=It(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i=w&&(w=v+1);!(y=_[w])&&++w=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=ae);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o1?this.each((null==e?pe:"function"==typeof e?_e:ge)(t,e,null==n?"":n)):me(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?ye:"function"==typeof e?we:ve)(t,e)):this.node()[t]},classed:function(t,e){var n=xe(t+"");if(arguments.length<2){for(var r=be(this.node()),i=-1,o=n.length;++i=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}})}(t+""),a=o.length;if(!(arguments.length<2)){for(s=e?Re:Ye,r=0;r>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?_n(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?_n(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=on.exec(t))?new yn(e[1],e[2],e[3],1):(e=an.exec(t))?new yn(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=sn.exec(t))?_n(e[1],e[2],e[3],e[4]):(e=ln.exec(t))?_n(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=un.exec(t))?An(e[1],e[2]/100,e[3]/100,1):(e=cn.exec(t))?An(e[1],e[2]/100,e[3]/100,e[4]):hn.hasOwnProperty(t)?gn(hn[t]):"transparent"===t?new yn(NaN,NaN,NaN,0):null}function gn(t){return new yn(t>>16&255,t>>8&255,255&t,1)}function _n(t,e,n,r){return r<=0&&(t=e=n=NaN),new yn(t,e,n,r)}function mn(t,e,n,r){return 1===arguments.length?function(t){return t instanceof Je||(t=pn(t)),t?new yn((t=t.rgb()).r,t.g,t.b,t.opacity):new yn}(t):new yn(t,e,n,null==r?1:r)}function yn(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function vn(){return`#${$n(this.r)}${$n(this.g)}${$n(this.b)}`}function wn(){const t=xn(this.opacity);return`${1===t?"rgb(":"rgba("}${bn(this.r)}, ${bn(this.g)}, ${bn(this.b)}${1===t?")":`, ${t})`}`}function xn(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function bn(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function $n(t){return((t=bn(t))<16?"0":"")+t.toString(16)}function An(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Sn(t,e,n,r)}function Mn(t){if(t instanceof Sn)return new Sn(t.h,t.s,t.l,t.opacity);if(t instanceof Je||(t=pn(t)),!t)return new Sn;if(t instanceof Sn)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=NaN,s=o-i,l=(o+i)/2;return s?(a=e===o?(n-r)/s+6*(n0&&l<1?0:a,new Sn(a,s,l,t.opacity)}function Sn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Cn(t){return(t=(t||0)%360)<0?t+360:t}function Tn(t){return Math.max(0,Math.min(1,t||0))}function En(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}Ze(Je,pn,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:fn,formatHex:fn,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Mn(this).formatHsl()},formatRgb:dn,toString:dn}),Ze(yn,mn,Ge(Je,{brighter(t){return t=null==t?Ke:Math.pow(Ke,t),new yn(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Qe:Math.pow(Qe,t),new yn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new yn(bn(this.r),bn(this.g),bn(this.b),xn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:vn,formatHex:vn,formatHex8:function(){return`#${$n(this.r)}${$n(this.g)}${$n(this.b)}${$n(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:wn,toString:wn})),Ze(Sn,function(t,e,n,r){return 1===arguments.length?Mn(t):new Sn(t,e,n,null==r?1:r)},Ge(Je,{brighter(t){return t=null==t?Ke:Math.pow(Ke,t),new Sn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Qe:Math.pow(Qe,t),new Sn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new yn(En(t>=240?t-240:t+120,i,r),En(t,i,r),En(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Sn(Cn(this.h),Tn(this.s),Tn(this.l),xn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=xn(this.opacity);return`${1===t?"hsl(":"hsla("}${Cn(this.h)}, ${100*Tn(this.s)}%, ${100*Tn(this.l)}%${1===t?")":`, ${t})`}`}}));var Nn=t=>()=>t;function kn(t){return 1===(t=+t)?Dn:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):Nn(isNaN(e)?n:e)}}function Dn(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):Nn(isNaN(t)?e:t)}var Un=function t(e){var n=kn(e);function r(t,e){var r=n((t=mn(t)).r,(e=mn(e)).r),i=n(t.g,e.g),o=n(t.b,e.b),a=Dn(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=o(e),t.opacity=a(e),t+""}}return r.gamma=t,r}(1);function Pn(t,e){e||(e=[]);var n,r=t?Math.min(e.length,t.length):0,i=e.slice();return function(o){for(n=0;no&&(i=e.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:Hn(n,r)})),o=jn.lastIndex;return o180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Hn(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(o.rotate,a.rotate,s,l),function(t,e,n,o){t!==e?o.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Hn(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(o.skewX,a.skewX,s,l),function(t,e,n,r,o,a){if(t!==n||e!==r){var s=o.push(i(o)+"scale(",null,",",null,")");a.push({i:s-4,x:Hn(t,n)},{i:s-2,x:Hn(e,r)})}else 1===n&&1===r||o.push(i(o)+"scale("+n+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,s,l),o=a=null,function(t){for(var e,n=-1,r=l.length;++n=0&&e._call.call(void 0,t),e=e._next;--Kn}()}finally{Kn=0,function(){var t,e,n=Zn,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Zn=e);Gn=t,dr(r)}(),rr=0}}function fr(){var t=or.now(),e=t-nr;e>1e3&&(ir-=e,nr=t)}function dr(t){Kn||(tr&&(tr=clearTimeout(tr)),t-rr>24?(t<1/0&&(tr=setTimeout(hr,t-or.now()-ir)),er&&(er=clearInterval(er))):(er||(nr=or.now(),er=setInterval(fr,1e3)),Kn=1,ar(hr)))}function pr(t,e,n){var r=new ur;return e=null==e?0:+e,r.restart(n=>{r.stop(),t(n+e)},e,n),r}ur.prototype=cr.prototype={constructor:ur,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?sr():+n)+(null==e?0:+e),this._next||Gn===this||(Gn?Gn._next=this:Zn=this,Gn=this),this._call=t,this._time=n,dr()},stop:function(){this._call&&(this._call=null,this._time=1/0,dr())}};var gr=Ut("start","end","cancel","interrupt"),_r=[];function mr(t,e,n,r,i,o){var a=t.__transition;if(a){if(n in a)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function o(t){n.state=1,n.timer.restart(a,n.delay,n.time),n.delay<=t&&a(t-n.delay)}function a(o){var u,c,h,f;if(1!==n.state)return l();for(u in i)if((f=i[u]).name===n.name){if(3===f.state)return pr(a);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[u]):+u0)throw new Error("too late; already scheduled");return n}function vr(t,e){var n=wr(t,e);if(n.state>3)throw new Error("too late; already running");return n}function wr(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function xr(t,e){var n,r;return function(){var i=vr(this,t),o=i.tween;if(o!==n)for(var a=0,s=(r=n=o).length;a=0&&(t=t.slice(0,e)),!t||"start"===t})}(e)?yr:vr;return function(){var a=o(this,t),s=a.on;s!==r&&(i=(r=s).copy()).on(e,n),a.on=i}}(n,t,e))},attr:function(t,e){var n=zt(t),r="transform"===n?Qn:Ar;return this.attrTween(t,"function"==typeof e?(n.local?Nr:Er)(n,r,$r(this,"attr."+t,e)):null==e?(n.local?Sr:Mr)(n):(n.local?Tr:Cr)(n,r,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var r=zt(t);return this.tween(n,(r.local?kr:Dr)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?Jn:Ar;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var o=me(this,t),a=(this.style.removeProperty(t),me(this,t));return o===a?null:o===n&&a===r?i:i=e(n=o,r=a)}}(t,r)).on("end.style."+t,Lr(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,o;return function(){var a=me(this,t),s=n(this),l=s+"";return null==s&&(this.style.removeProperty(t),l=s=me(this,t)),a===l?null:a===r&&l===i?o:(i=l,o=e(r=a,s))}}(t,r,$r(this,"style."+t,e))).each(function(t,e){var n,r,i,o,a="style."+e,s="end."+a;return function(){var l=vr(this,t),u=l.on,c=null==l.value[a]?o||(o=Lr(e)):void 0;u===n&&i===c||(r=(n=u).copy()).on(s,i=c),l.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,o=n+"";return function(){var a=me(this,t);return a===o?null:a===r?i:i=e(r=a,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,function(t,e,n){var r,i;function o(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}(t,o,n)),r}return o._value=e,o}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}($r(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&function(t){return function(e){this.textContent=t.call(this,e)}}(r)),e}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=wr(this.node(),n).tween,o=0,a=i.length;o2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete o[i]):a=!1;a&&delete t.__transition}}(this,t)})},Be.prototype.transition=function(t){var e,n;t instanceof jr?(e=t._id,t=t._name):(e=Yr(),(n=qr).time=sr(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,o=0;o=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Zr;const n=10**e;return function(t){this._+=t[0];for(let e=1,r=t.length;eVr)if(Math.abs(c*s-l*u)>Vr&&i){let f=n-o,d=r-a,p=s*s+l*l,g=f*f+d*d,_=Math.sqrt(p),m=Math.sqrt(h),y=i*Math.tan((Wr-Math.acos((p+h-g)/(2*_*m)))/2),v=y/m,w=y/_;Math.abs(v-1)>Vr&&this._append`L${t+v*u},${e+v*c}`,this._append`A${i},${i},0,0,${+(c*f>u*d)},${this._x1=t+w*s},${this._y1=e+w*l}`}else this._append`L${this._x1=t},${this._y1=e}`;else;}arc(t,e,n,r,i,o){if(t=+t,e=+e,o=!!o,(n=+n)<0)throw new Error(`negative radius: ${n}`);let a=n*Math.cos(r),s=n*Math.sin(r),l=t+a,u=e+s,c=1^o,h=o?r-i:i-r;null===this._x1?this._append`M${l},${u}`:(Math.abs(this._x1-l)>Vr||Math.abs(this._y1-u)>Vr)&&this._append`L${l},${u}`,n&&(h<0&&(h=h%Xr+Xr),h>Br?this._append`A${n},${n},0,1,${c},${t-a},${e-s}A${n},${n},0,1,${c},${this._x1=l},${this._y1=u}`:h>Vr&&this._append`A${n},${n},0,${+(h>=Wr)},${c},${this._x1=t+n*Math.cos(i)},${this._y1=e+n*Math.sin(i)}`)}rect(t,e,n,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}}function Jr(t,e){if(!isFinite(t)||0===t)return null;var n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"),r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Qr(t){return(t=Jr(Math.abs(t)))?t[1]:NaN}var Kr,ti=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ei(t){if(!(e=ti.exec(t)))throw new Error("invalid format: "+t);var e;return new ni({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function ni(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function ri(t,e){var n=Jr(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}ei.prototype=ni.prototype,ni.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var ii={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>ri(100*t,e),r:ri,s:function(t,e){var n=Jr(t,e);if(!n)return Kr=void 0,t.toPrecision(e);var r=n[0],i=n[1],o=i-(Kr=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Jr(t,Math.max(0,e+o-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function oi(t){return t}var ai,si,li,ui=Array.prototype.map,ci=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function hi(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?oi:(e=ui.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,o=[],a=0,s=e[0],l=0;i>0&&s>0&&(l+s+1>r&&(s=Math.max(1,r-l)),o.push(t.substring(i-=s,i+s)),!((l+=s+1)>r));)s=e[a=(a+1)%e.length];return o.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",a=void 0===t.decimal?".":t.decimal+"",s=void 0===t.numerals?oi:function(t){return function(e){return e.replace(/[0-9]/g,function(e){return t[+e]})}}(ui.call(t.numerals,String)),l=void 0===t.percent?"%":t.percent+"",u=void 0===t.minus?"−":t.minus+"",c=void 0===t.nan?"NaN":t.nan+"";function h(t,e){var n=(t=ei(t)).fill,h=t.align,f=t.sign,d=t.symbol,p=t.zero,g=t.width,_=t.comma,m=t.precision,y=t.trim,v=t.type;"n"===v?(_=!0,v="g"):ii[v]||(void 0===m&&(m=12),y=!0,v="g"),(p||"0"===n&&"="===h)&&(p=!0,n="0",h="=");var w=(e&&void 0!==e.prefix?e.prefix:"")+("$"===d?i:"#"===d&&/[boxX]/.test(v)?"0"+v.toLowerCase():""),x=("$"===d?o:/[%p]/.test(v)?l:"")+(e&&void 0!==e.suffix?e.suffix:""),b=ii[v],$=/[defgprs%]/.test(v);function A(t){var e,i,o,l=w,d=x;if("c"===v)d=b(t)+d,t="";else{var A=(t=+t)<0||1/t<0;if(t=isNaN(t)?c:b(Math.abs(t),m),y&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),A&&0===+t&&"+"!==f&&(A=!1),l=(A?"("===f?f:u:"-"===f||"("===f?"":f)+l,d=("s"!==v||isNaN(t)||void 0===Kr?"":ci[8+Kr/3])+d+(A&&"("===f?")":""),$)for(e=-1,i=t.length;++e(o=t.charCodeAt(e))||o>57){d=(46===o?a+t.slice(e+1):t.slice(e))+d,t=t.slice(0,e);break}}_&&!p&&(t=r(t,1/0));var M=l.length+t.length+d.length,S=M>1)+l+t+d+S.slice(M);break;default:t=S+l+t+d}return s(t)}return m=void 0===m?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,m)):Math.max(0,Math.min(20,m)),A.toString=function(){return t+""},A}return{format:h,formatPrefix:function(t,e){var n=3*Math.max(-8,Math.min(8,Math.floor(Qr(e)/3))),r=Math.pow(10,-n),i=h(((t=ei(t)).type="f",t),{suffix:ci[8+n/3]});return function(t){return i(r*t)}}}}function fi(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}function di(t){return+t}ai=hi({thousands:",",grouping:[3],currency:["$",""]}),si=ai.format,li=ai.formatPrefix;var pi=[0,1];function gi(t){return t}function _i(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:function(t){return function(){return t}}(isNaN(e)?NaN:.5)}function mi(t,e,n){var r=t[0],i=t[1],o=e[0],a=e[1];return ie&&(n=t,t=e,e=n),function(n){return Math.max(t,Math.min(e,n))}}(a[0],a[t-1])),r=t>2?yi:mi,i=o=null,h}function h(e){return null==e||isNaN(e=+e)?n:(i||(i=r(a.map(t),s,l)))(t(u(e)))}return h.invert=function(n){return u(e((o||(o=r(s,a.map(t),Hn)))(n)))},h.domain=function(t){return arguments.length?(a=Array.from(t,di),c()):a.slice()},h.range=function(t){return arguments.length?(s=Array.from(t),c()):s.slice()},h.rangeRound=function(t){return s=Array.from(t),l=qn,c()},h.clamp=function(t){return arguments.length?(u=!!t||gi,c()):u!==gi},h.interpolate=function(t){return arguments.length?(l=t,c()):l},h.unknown=function(t){return arguments.length?(n=t,h):n},function(n,r){return t=n,e=r,c()}}function xi(){return wi()(gi,gi)}function bi(t,e,n,r){var i,o=kt(t,e,n);switch((r=ei(null==r?",f":r)).type){case"s":var a=Math.max(Math.abs(t),Math.abs(e));return null!=r.precision||isNaN(i=function(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Qr(e)/3)))-Qr(Math.abs(t)))}(o,a))||(r.precision=i),li(r,a);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=function(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Qr(e)-Qr(t))+1}(o,Math.max(Math.abs(t),Math.abs(e))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=function(t){return Math.max(0,-Qr(Math.abs(t)))}(o))||(r.precision=i-2*("%"===r.type))}return si(r)}function $i(t){var e=t.domain;return t.ticks=function(t){var n=e();return function(t,e,n){if(!((n=+n)>0))return[];if((t=+t)===(e=+e))return[t];const r=e=i))return[];const s=o-i+1,l=new Array(s);if(r)if(a<0)for(let t=0;t0;){if((i=Nt(l,u,n))===r)return o[a]=l,o[s]=u,e(o);if(i>0)l=Math.floor(l/i)*i,u=Math.ceil(u/i)*i;else{if(!(i<0))break;l=Math.ceil(l*i)/i,u=Math.floor(u*i)/i}r=i}return t},t}function Ai(){var t=xi();return t.copy=function(){return vi(t,Ai())},fi.apply(t,arguments),$i(t)}const Mi=new Date,Si=new Date;function Ci(t,e,n,r){function i(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return i.floor=e=>(t(e=new Date(+e)),e),i.ceil=n=>(t(n=new Date(n-1)),e(n,1),t(n),n),i.round=t=>{const e=i(t),n=i.ceil(t);return t-e(e(t=new Date(+t),null==n?1:Math.floor(n)),t),i.range=(n,r,o)=>{const a=[];if(n=i.ceil(n),o=null==o?1:Math.floor(o),!(n0))return a;let s;do{a.push(s=new Date(+n)),e(n,o),t(n)}while(sCi(e=>{if(e>=e)for(;t(e),!n(e);)e.setTime(e-1)},(t,r)=>{if(t>=t)if(r<0)for(;++r<=0;)for(;e(t,-1),!n(t););else for(;--r>=0;)for(;e(t,1),!n(t););}),n&&(i.count=(e,r)=>(Mi.setTime(+e),Si.setTime(+r),t(Mi),t(Si),Math.floor(n(Mi,Si))),i.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?e=>r(e)%t===0:e=>i.count(0,e)%t===0):i:null)),i}const Ti=Ci(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Ti.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?Ci(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Ti:null),Ti.range;const Ei=1e3,Ni=6e4,ki=36e5,Di=864e5,Ui=6048e5,Pi=2592e6,Oi=31536e6,Fi=Ci(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Ei)},(t,e)=>(e-t)/Ei,t=>t.getUTCSeconds());Fi.range;const Hi=Ci(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Ei)},(t,e)=>{t.setTime(+t+e*Ni)},(t,e)=>(e-t)/Ni,t=>t.getMinutes());Hi.range;const Li=Ci(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Ni)},(t,e)=>(e-t)/Ni,t=>t.getUTCMinutes());Li.range;const zi=Ci(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Ei-t.getMinutes()*Ni)},(t,e)=>{t.setTime(+t+e*ki)},(t,e)=>(e-t)/ki,t=>t.getHours());zi.range;const ji=Ci(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*ki)},(t,e)=>(e-t)/ki,t=>t.getUTCHours());ji.range;const Yi=Ci(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Ni)/Di,t=>t.getDate()-1);Yi.range;const Ri=Ci(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Di,t=>t.getUTCDate()-1);Ri.range;const qi=Ci(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Di,t=>Math.floor(t/Di));function Ii(t){return Ci(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(t,e)=>{t.setDate(t.getDate()+7*e)},(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Ni)/Ui)}qi.range;const Wi=Ii(0),Xi=Ii(1),Vi=Ii(2),Bi=Ii(3),Zi=Ii(4),Gi=Ii(5),Ji=Ii(6);function Qi(t){return Ci(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+7*e)},(t,e)=>(e-t)/Ui)}Wi.range,Xi.range,Vi.range,Bi.range,Zi.range,Gi.range,Ji.range;const Ki=Qi(0),to=Qi(1),eo=Qi(2),no=Qi(3),ro=Qi(4),io=Qi(5),oo=Qi(6);Ki.range,to.range,eo.range,no.range,ro.range,io.range,oo.range;const ao=Ci(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear()),t=>t.getMonth());ao.range;const so=Ci(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear()),t=>t.getUTCMonth());so.range;const lo=Ci(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());lo.every=t=>isFinite(t=Math.floor(t))&&t>0?Ci(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)}):null,lo.range;const uo=Ci(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());uo.every=t=>isFinite(t=Math.floor(t))&&t>0?Ci(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)}):null,uo.range;const[co,ho]=function(t,e,n,r,i,o){const a=[[Fi,1,Ei],[Fi,5,5e3],[Fi,15,15e3],[Fi,30,3e4],[o,1,Ni],[o,5,3e5],[o,15,9e5],[o,30,18e5],[i,1,ki],[i,3,108e5],[i,6,216e5],[i,12,432e5],[r,1,Di],[r,2,1728e5],[n,1,Ui],[e,1,Pi],[e,3,7776e6],[t,1,Oi]];function s(e,n,r){const i=Math.abs(n-e)/r,o=bt(([,,t])=>t).right(a,i);if(o===a.length)return t.every(kt(e/Oi,n/Oi,r));if(0===o)return Ti.every(Math.max(kt(e,n,r),1));const[s,l]=a[i/a[o-1][2][t.toLowerCase(),e]))}function So(t,e,n){var r=vo.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Co(t,e,n){var r=vo.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function To(t,e,n){var r=vo.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Eo(t,e,n){var r=vo.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function No(t,e,n){var r=vo.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function ko(t,e,n){var r=vo.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Do(t,e,n){var r=vo.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Uo(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function Po(t,e,n){var r=vo.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function Oo(t,e,n){var r=vo.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Fo(t,e,n){var r=vo.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Ho(t,e,n){var r=vo.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function Lo(t,e,n){var r=vo.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function zo(t,e,n){var r=vo.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function jo(t,e,n){var r=vo.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Yo(t,e,n){var r=vo.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Ro(t,e,n){var r=vo.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function qo(t,e,n){var r=wo.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Io(t,e,n){var r=vo.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Wo(t,e,n){var r=vo.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function Xo(t,e){return bo(t.getDate(),e,2)}function Vo(t,e){return bo(t.getHours(),e,2)}function Bo(t,e){return bo(t.getHours()%12||12,e,2)}function Zo(t,e){return bo(1+Yi.count(lo(t),t),e,3)}function Go(t,e){return bo(t.getMilliseconds(),e,3)}function Jo(t,e){return Go(t,e)+"000"}function Qo(t,e){return bo(t.getMonth()+1,e,2)}function Ko(t,e){return bo(t.getMinutes(),e,2)}function ta(t,e){return bo(t.getSeconds(),e,2)}function ea(t){var e=t.getDay();return 0===e?7:e}function na(t,e){return bo(Wi.count(lo(t)-1,t),e,2)}function ra(t){var e=t.getDay();return e>=4||0===e?Zi(t):Zi.ceil(t)}function ia(t,e){return t=ra(t),bo(Zi.count(lo(t),t)+(4===lo(t).getDay()),e,2)}function oa(t){return t.getDay()}function aa(t,e){return bo(Xi.count(lo(t)-1,t),e,2)}function sa(t,e){return bo(t.getFullYear()%100,e,2)}function la(t,e){return bo((t=ra(t)).getFullYear()%100,e,2)}function ua(t,e){return bo(t.getFullYear()%1e4,e,4)}function ca(t,e){var n=t.getDay();return bo((t=n>=4||0===n?Zi(t):Zi.ceil(t)).getFullYear()%1e4,e,4)}function ha(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+bo(e/60|0,"0",2)+bo(e%60,"0",2)}function fa(t,e){return bo(t.getUTCDate(),e,2)}function da(t,e){return bo(t.getUTCHours(),e,2)}function pa(t,e){return bo(t.getUTCHours()%12||12,e,2)}function ga(t,e){return bo(1+Ri.count(uo(t),t),e,3)}function _a(t,e){return bo(t.getUTCMilliseconds(),e,3)}function ma(t,e){return _a(t,e)+"000"}function ya(t,e){return bo(t.getUTCMonth()+1,e,2)}function va(t,e){return bo(t.getUTCMinutes(),e,2)}function wa(t,e){return bo(t.getUTCSeconds(),e,2)}function xa(t){var e=t.getUTCDay();return 0===e?7:e}function ba(t,e){return bo(Ki.count(uo(t)-1,t),e,2)}function $a(t){var e=t.getUTCDay();return e>=4||0===e?ro(t):ro.ceil(t)}function Aa(t,e){return t=$a(t),bo(ro.count(uo(t),t)+(4===uo(t).getUTCDay()),e,2)}function Ma(t){return t.getUTCDay()}function Sa(t,e){return bo(to.count(uo(t)-1,t),e,2)}function Ca(t,e){return bo(t.getUTCFullYear()%100,e,2)}function Ta(t,e){return bo((t=$a(t)).getUTCFullYear()%100,e,2)}function Ea(t,e){return bo(t.getUTCFullYear()%1e4,e,4)}function Na(t,e){var n=t.getUTCDay();return bo((t=n>=4||0===n?ro(t):ro.ceil(t)).getUTCFullYear()%1e4,e,4)}function ka(){return"+0000"}function Da(){return"%"}function Ua(t){return+t}function Pa(t){return Math.floor(+t/1e3)}function Oa(t){return new Date(t)}function Fa(t){return t instanceof Date?+t:+new Date(+t)}function Ha(t,e,n,r,i,o,a,s,l,u){var c=xi(),h=c.invert,f=c.domain,d=u(".%L"),p=u(":%S"),g=u("%I:%M"),_=u("%I %p"),m=u("%a %d"),y=u("%b %d"),v=u("%B"),w=u("%Y");function x(t){return(l(t)=0))throw new RangeError(`invalid digits: ${n}`);e=t}return t},()=>new Gr(e)}function Ya(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function Ra(t){this._context=t}function qa(t){return new Ra(t)}function Ia(t){return t[0]}function Wa(t){return t[1]}function Xa(t,e){var n=za(!0),r=null,i=qa,o=null,a=ja(s);function s(s){var l,u,c,h=(s=Ya(s)).length,f=!1;for(null==r&&(o=i(c=a())),l=0;l<=h;++l)!(l=h;--f)s.point(m[f],y[f]);s.lineEnd(),s.areaEnd()}_&&(m[c]=+t(d,c,u),y[c]=+e(d,c,u),s.point(r?+r(d,c,u):m[c],n?+n(d,c,u):y[c]))}if(p)return s=null,p+""||null}function c(){return Xa().defined(i).curve(a).context(o)}return t="function"==typeof t?t:void 0===t?Ia:za(+t),e="function"==typeof e?e:za(void 0===e?0:+e),n="function"==typeof n?n:void 0===n?Wa:za(+n),u.x=function(e){return arguments.length?(t="function"==typeof e?e:za(+e),r=null,u):t},u.x0=function(e){return arguments.length?(t="function"==typeof e?e:za(+e),u):t},u.x1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:za(+t),u):r},u.y=function(t){return arguments.length?(e="function"==typeof t?t:za(+t),n=null,u):e},u.y0=function(t){return arguments.length?(e="function"==typeof t?t:za(+t),u):e},u.y1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:za(+t),u):n},u.lineX0=u.lineY0=function(){return c().x(t).y(e)},u.lineY1=function(){return c().x(t).y(n)},u.lineX1=function(){return c().x(r).y(e)},u.defined=function(t){return arguments.length?(i="function"==typeof t?t:za(!!t),u):i},u.curve=function(t){return arguments.length?(a=t,null!=o&&(s=a(o)),u):a},u.context=function(t){return arguments.length?(null==t?o=s=null:s=a(o=t),u):o},u}function Ba(t){return t<0?-1:1}function Za(t,e,n){var r=t._x1-t._x0,i=e-t._x1,o=(t._y1-t._y0)/(r||i<0&&-0),a=(n-t._y1)/(i||r<0&&-0),s=(o*i+a*r)/(r+i);return(Ba(o)+Ba(a))*Math.min(Math.abs(o),Math.abs(a),.5*Math.abs(s))||0}function Ga(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function Ja(t,e,n){var r=t._x0,i=t._y0,o=t._x1,a=t._y1,s=(o-r)/3;t._context.bezierCurveTo(r+s,i+s*e,o-s,a-s*n,o,a)}function Qa(t){this._context=t}function Ka(t){return new Qa(t)}function ts(t,e){this._context=t,this._t=e}function es(t){return new ts(t,1)}function ns(t,e,n){this.k=t,this.x=e,this.y=n}!function(t){_o=function(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,o=t.days,a=t.shortDays,s=t.months,l=t.shortMonths,u=Ao(i),c=Mo(i),h=Ao(o),f=Mo(o),d=Ao(a),p=Mo(a),g=Ao(s),_=Mo(s),m=Ao(l),y=Mo(l),v={a:function(t){return a[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return l[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:null,d:Xo,e:Xo,f:Jo,g:la,G:ca,H:Vo,I:Bo,j:Zo,L:Go,m:Qo,M:Ko,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:Ua,s:Pa,S:ta,u:ea,U:na,V:ia,w:oa,W:aa,x:null,X:null,y:sa,Y:ua,Z:ha,"%":Da},w={a:function(t){return a[t.getUTCDay()]},A:function(t){return o[t.getUTCDay()]},b:function(t){return l[t.getUTCMonth()]},B:function(t){return s[t.getUTCMonth()]},c:null,d:fa,e:fa,f:ma,g:Ta,G:Na,H:da,I:pa,j:ga,L:_a,m:ya,M:va,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:Ua,s:Pa,S:wa,u:xa,U:ba,V:Aa,w:Ma,W:Sa,x:null,X:null,y:Ca,Y:Ea,Z:ka,"%":Da},x={a:function(t,e,n){var r=d.exec(e.slice(n));return r?(t.w=p.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(t,e,n){var r=h.exec(e.slice(n));return r?(t.w=f.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(t,e,n){var r=m.exec(e.slice(n));return r?(t.m=y.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(t,e,n){var r=g.exec(e.slice(n));return r?(t.m=_.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(t,n,r){return A(t,e,n,r)},d:Fo,e:Fo,f:Ro,g:Do,G:ko,H:Lo,I:Lo,j:Ho,L:Yo,m:Oo,M:zo,p:function(t,e,n){var r=u.exec(e.slice(n));return r?(t.p=c.get(r[0].toLowerCase()),n+r[0].length):-1},q:Po,Q:Io,s:Wo,S:jo,u:Co,U:To,V:Eo,w:So,W:No,x:function(t,e,r){return A(t,n,e,r)},X:function(t,e,n){return A(t,r,e,n)},y:Do,Y:ko,Z:Uo,"%":qo};function b(t,e){return function(n){var r,i,o,a=[],s=-1,l=0,u=t.length;for(n instanceof Date||(n=new Date(+n));++s53)return null;"w"in o||(o.w=1),"Z"in o?(i=(r=po(go(o.y,0,1))).getUTCDay(),r=i>4||0===i?to.ceil(r):to(r),r=Ri.offset(r,7*(o.V-1)),o.y=r.getUTCFullYear(),o.m=r.getUTCMonth(),o.d=r.getUTCDate()+(o.w+6)%7):(i=(r=fo(go(o.y,0,1))).getDay(),r=i>4||0===i?Xi.ceil(r):Xi(r),r=Yi.offset(r,7*(o.V-1)),o.y=r.getFullYear(),o.m=r.getMonth(),o.d=r.getDate()+(o.w+6)%7)}else("W"in o||"U"in o)&&("w"in o||(o.w="u"in o?o.u%7:"W"in o?1:0),i="Z"in o?po(go(o.y,0,1)).getUTCDay():fo(go(o.y,0,1)).getDay(),o.m=0,o.d="W"in o?(o.w+6)%7+7*o.W-(i+5)%7:o.w+7*o.U-(i+6)%7);return"Z"in o?(o.H+=o.Z/100|0,o.M+=o.Z%100,po(o)):fo(o)}}function A(t,e,n,r){for(var i,o,a=0,s=e.length,l=n.length;a=l)return-1;if(37===(i=e.charCodeAt(a++))){if(i=e.charAt(a++),!(o=x[i in yo?e.charAt(a++):i])||(r=o(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return v.x=b(n,v),v.X=b(r,v),v.c=b(e,v),w.x=b(n,w),w.X=b(r,w),w.c=b(e,w),{format:function(t){var e=b(t+="",v);return e.toString=function(){return t},e},parse:function(t){var e=$(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=b(t+="",w);return e.toString=function(){return t},e},utcParse:function(t){var e=$(t+="",!0);return e.toString=function(){return t},e}}}(t),mo=_o.format,_o.parse,_o.utcFormat,_o.utcParse}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}),Ra.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e)}}},Qa.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Ja(this,this._t0,Ga(this,this._t0))}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){var n=NaN;if(e=+e,(t=+t)!==this._x1||e!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,Ja(this,Ga(this,n=Za(this,t,e)),n);break;default:Ja(this,this._t0,n=Za(this,t,e))}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}},Object.create(Qa.prototype).point=function(t,e){Qa.prototype.point.call(this,e,t)},ts.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e)}}this._x=t,this._y=e}},ns.prototype={constructor:ns,scale:function(t){return 1===t?this:new ns(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new ns(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}},ns.prototype;const rs=s`:host{display:block}:host ::slotted(.card-content),.card-content{display:flex;flex-direction:column;gap:12px;padding:16px}.place-row{padding-bottom:16px;border-bottom:1px solid var(--divider-color, #eee)}.place-row:last-child{border-bottom:none;margin-bottom:0;padding-bottom:0}.place-row .chart-container{margin-top:16px;width:100%;height:120px;background:rgba(var(--rgb-primary-color, 0, 119, 190), 0.03);border-radius:8px;overflow:hidden}.place-row svg{width:100%;height:100%;display:block}.place-row .ref-line{stroke-dasharray:4,4;stroke-width:1;opacity:.5}.place-row .ref-line.min{stroke:#41bdf5}.place-row .ref-line.max{stroke:#ff9800}.place-row .ref-line.avg{stroke:var(--primary-color, #0077be);stroke-dasharray:none;opacity:.3}.place-row .chart-line{stroke-linecap:round;stroke-linejoin:round;filter:drop-shadow(0 2px 4px rgba(var(--rgb-primary-color, 0, 119, 190), 0.2))}.place-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;cursor:pointer;transition:opacity .2s ease}.place-header:hover{opacity:.7}.place-info{display:flex;flex-direction:column}.last-updated{font-size:.75rem;color:var(--secondary-text-color);margin-top:4px}.place-name-container{display:flex;align-items:baseline;gap:6px}.place-name{font-size:1.2rem;font-weight:500;color:var(--primary-text-color)}.place-country{font-size:.85rem;color:var(--secondary-text-color);font-weight:400}.current-temp{display:flex;align-items:baseline;gap:4px}.temp-value{font-size:2rem;font-weight:700;color:var(--primary-color, #0077be)}.temp-unit{font-size:1rem;font-weight:500;color:var(--secondary-text-color)}.stats-grid,.averages-grid{display:grid;grid-template-columns:repeat(3, 1fr);gap:8px;margin-top:8px}.stat-item{display:flex;flex-direction:column;align-items:center;background:var(--card-background-color);padding:8px;border-radius:8px;box-shadow:0 2px 4px rgba(0,0,0,.05)}.stat-label{font-size:.75rem;text-transform:uppercase;color:var(--secondary-text-color);margin-bottom:4px}.stat-value{font-size:.9rem;font-weight:600}.stat-delta{font-size:.75rem;font-weight:500;margin-top:2px}.stat-delta.pos{color:var(--success-color, #4caf50)}.stat-delta.neg{color:var(--error-color, #db4437)}.stat-delta.neu{color:var(--secondary-text-color)}.averages-section{margin-top:16px;padding-top:12px;border-top:1px dashed var(--divider-color)}.averages-header{font-size:.85rem;font-weight:600;color:var(--secondary-text-color);margin-bottom:8px;text-align:center}.current-trend{font-size:1rem;margin-left:8px;margin-top:0}.warning{color:var(--error-color);padding:8px;text-align:center}.ref-label{font-size:8px;font-weight:500;fill:var(--secondary-text-color);dominant-baseline:middle}.ref-label.min{fill:#41bdf5}.ref-label.max{fill:#ff9800}.ref-label.avg{fill:var(--primary-color, #0077be)}.axis-label{font-size:8px;fill:var(--secondary-text-color);opacity:.7}.now-dot{filter:drop-shadow(0 1px 2px rgba(var(--rgb-primary-color, 0, 119, 190), 0.3))}.extrema-dot{filter:drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2))}.extrema-dot.min{fill:#41bdf5}.extrema-dot.max{fill:#ff9800}.hover-group{pointer-events:none;transition:opacity .2s ease-in-out}.hover-line{stroke:var(--secondary-text-color);stroke-width:1;stroke-dasharray:2,2;opacity:.5}.hover-point{fill:var(--card-background-color);stroke:var(--primary-color, #0077be);stroke-width:2}.hover-tooltip-bg{fill:var(--card-background-color);stroke:var(--divider-color, #eee);stroke-width:1;opacity:.95;filter:drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2))}.hover-tooltip-text{fill:var(--primary-text-color);font-size:10px;font-weight:bold}.hover-tooltip-date{fill:var(--secondary-text-color);font-size:8px}.hover-overlay{cursor:crosshair}ha-card.narrow .card-content{padding:12px;gap:8px}ha-card.narrow .place-row{padding-bottom:12px}ha-card.narrow .place-row .chart-container{margin-top:12px}ha-card.narrow .place-name{font-size:1.05rem}ha-card.narrow .temp-value{font-size:1.6rem}ha-card.narrow .stats-grid{gap:6px;margin-top:6px}ha-card.narrow .stat-item{padding:6px 4px;border-radius:6px}ha-card.narrow .stat-label{font-size:.65rem;margin-bottom:2px}ha-card.narrow .stat-value{font-size:.8rem}ha-card.narrow .ref-label{font-size:7px}ha-card.narrow .axis-label{font-size:7px}`,is="sea-temperatures-card",os=`${is}-editor`;class as extends ct{constructor(){super(...arguments),this._chartData={},this._chartWidth=400,this._dataFetched=!1}setConfig(t){if(!t||!t.places||!Array.isArray(t.places)||0===t.places.length)throw new Error(yt(this.hass,"common.errors.no_places"));this._config={show_last_updated:!0,show_trend:!0,show_stats:!0,show_chart:!0,show_country:!1,compact:!1,chart_smoothing:"smooth",...t}}connectedCallback(){super.connectedCallback(),this._resizeObserver=new ResizeObserver(t=>{for(const e of t)if(e.contentRect.width>0){const t=Math.max(200,e.contentRect.width-32);this._chartWidth!==t&&(this._chartWidth=t)}}),this._resizeObserver.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this._resizeObserver?.disconnect()}static async getConfigElement(){return await Promise.resolve().then(function(){return hs}),document.createElement(os)}static getStubConfig(){return{title:"Sea Temperatures",places:[]}}getCardSize(){return this._config?.places?.length||1}_getPlacesData(t,e){const n=[],r=Object.values(t.states);return e.places.forEach(i=>{const o="string"==typeof i?i:i.device,a="object"==typeof i?i.name:void 0;let s,l=t.states[o];if(l)s=t.entities[o]?.device_id;else{s=o;const e=r.filter(e=>t.entities[e.entity_id]?.device_id===s&&e.entity_id.startsWith("sensor."));if(0===e.length)return;l=e.find(t=>void 0!==t.attributes.yesterday)||e.find(t=>"°C"===t.attributes.unit_of_measurement||"°F"===t.attributes.unit_of_measurement)||e[0]}if(l){const r=l.attributes,i=s?t.devices[s]:void 0,o=i?.name_by_user||i?.name||r.friendly_name||"Unknown",u="°F"===r.unit_of_measurement||"F"===r.unit_of_measurement,c=t=>{if(null==t||isNaN(parseFloat(String(t))))return;const e=parseFloat(String(t));return String(u?Math.round(100*(1.8*e+32))/100:e)};n.push({name:a||o,country:e.show_country&&r.country?String(r.country):void 0,temperature:l.state,yesterday:c(r.yesterday),last_week:c(r.last_week),date:r.date?String(r.date):void 0,average_min:c(r.average_min),average_max:c(r.average_max),average_avg:c(r.average_avg),unit:r.unit_of_measurement||"°C",entity_id:l.entity_id})}}),e.sort_by&&n.sort((t,n)=>{if("name"===e.sort_by)return t.name.localeCompare(n.name);if("temp_asc"===e.sort_by||"temp_desc"===e.sort_by){const r=parseFloat(t.temperature),i=parseFloat(n.temperature),o=isNaN(r)?-1/0:r,a=isNaN(i)?-1/0:i;return"temp_asc"===e.sort_by?o-a:a-o}return 0}),n}updated(t){super.updated(t),this.hass&&this._config&&!this._dataFetched&&(this._dataFetched=!0,this._fetchChartData())}shouldUpdate(t){if(t.has("_config"))return!0;const e=t.get("hass");if(e){const n=this._getPlacesData(this.hass,this._config).some(t=>e.states[t.entity_id]!==this.hass.states[t.entity_id]);return n||e.language!==this.hass.language||t.has("_chartData")||t.has("_chartWidth")}return!0}_fetchChartData(){if(!this.hass||!this._config.places)return;const t=this._getPlacesData(this.hass,this._config).map(t=>t.entity_id);if(0===t.length)return;const e={};t.forEach(t=>{const n=this.hass?.states[t],r=n?.attributes?.charts;if(r?.last_thirty?.labels&&r?.last_thirty?.series){const i=r.last_thirty.labels,o=r.last_thirty.series;if(Array.isArray(i)&&Array.isArray(o)&&i.length===o.length){const r=(new Date).getFullYear(),a=(new Date).getMonth()+1,s="°F"===n?.attributes?.unit_of_measurement||"F"===n?.attributes?.unit_of_measurement;e[t]=i.map((t,e)=>{const n=String(t).split("-");if(2!==n.length)return{date:new Date,value:NaN};const i=parseInt(n[0],10),l=parseInt(n[1],10);let u=r;i>a+1&&(u-=1),a>10&&i<3&&(u+=1);let c=parseFloat(String(o[e]));return s&&!isNaN(c)&&(c=Math.round(100*(1.8*c+32))/100),{date:new Date(u,i-1,l),value:c}}).filter(t=>!isNaN(t.value)).sort((t,e)=>t.date.getTime()-e.date.getTime())}}}),this._chartData={...e},this.requestUpdate()}_handleMoreInfo(t){vt(this,"hass-more-info",{entityId:t})}_renderTrend(t,e,n=""){if(!this._config.show_trend)return W``;const r=t;if(void 0===r||isNaN(parseFloat(e))||isNaN(parseFloat(r)))return W``;const i=parseFloat(e)-parseFloat(r),o=Math.round(10*i)/10;if(Math.abs(o)>0){const t=o>0,e=new Intl.NumberFormat(this.hass?.language,{minimumFractionDigits:1,maximumFractionDigits:1}).format(Math.abs(o));return W`
${t?"↑":"↓"} ${t?"+":"-"}${e}${n}
`}return W`
→ 0.0${n}
`}render(){if(!this._config||!this.hass)return W``;const t=this._getPlacesData(this.hass,this._config),e=this._chartWidth<360;return W`
${t.map(t=>W`
this._handleMoreInfo(t.entity_id)}>
${t.name} ${t.country?W`${t.country}`:""}
${this._config.show_last_updated?W`
${this.hass.states[t.entity_id]?new Date(this.hass.states[t.entity_id].last_updated).toLocaleString(this.hass.language||void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):""}
`:""}
${isNaN(Number(t.temperature))?t.temperature:new Intl.NumberFormat(this.hass?.language).format(Number(t.temperature))} ${t.unit} ${this._renderTrend(t.yesterday,t.temperature,t.unit)}
${!1!==this._config.show_stats?W`
${this._renderStat(yt(this.hass,"card.yesterday"),t.yesterday,t.unit)} ${this._renderStat(yt(this.hass,"card.last_week"),t.last_week,t.unit)} ${this._renderStat(yt(this.hass,"card.average_avg"),t.average_avg,t.unit)}
`:""} ${!1!==this._config.show_chart?this._renderChart(t):""}
`)}
`}_renderStat(t,e,n){if(!e||"unknown"===e||"unavailable"===e)return W``;const r=Number(e),i=isNaN(r)?e:new Intl.NumberFormat(this.hass?.language).format(r);return W`
${t} ${i}${n}
`}_renderChart(t){const e=this._chartData[t.entity_id];return!e||e.length<2?W``:W`
${this._drawChart(t.entity_id,e,t)}
`}_handleMouseMove(t,e,n,r,i,o){const a=t.currentTarget.ownerSVGElement;if(!a)return;const s=a.createSVGPoint();s.x=t.clientX,s.y=t.clientY;const l=a.getScreenCTM();if(!l)return;const u=s.matrixTransform(l.inverse()),c=r.invert(u.x),h=bt(t=>t.date).left,f=h(n,c,1),d=n[f-1],p=n[f];let g=d;if(d&&p?g=c.getTime()-d.date.getTime()>p.date.getTime()-c.getTime()?p:d:p&&(g=p),!g)return;const _=a.querySelector(".hover-group");if(!_)return;_.style.opacity="1";const m=r(g.date),y=i(g.value),v=_.querySelector(".hover-line");v.setAttribute("x1",String(m)),v.setAttribute("x2",String(m));const w=_.querySelector(".hover-point");w.setAttribute("cx",String(m)),w.setAttribute("cy",String(y));const x=_.querySelector(".hover-tooltip-bg"),b=_.querySelector(".hover-tooltip-text"),$=_.querySelector(".hover-tooltip-date"),A=this._chartWidth,M=Math.max(0,Math.min(m-35,A-70)),S=M+35,C="middle",T=Math.max(0,y-34),E=T+11,N=T+23;x.setAttribute("x",String(M)),x.setAttribute("y",String(T)),b.setAttribute("x",String(S)),b.setAttribute("y",String(E)),b.setAttribute("text-anchor",C);const k=new Intl.NumberFormat(this.hass?.language).format(g.value);b.textContent=`${k}${o}`,$.setAttribute("x",String(S)),$.setAttribute("y",String(N)),$.setAttribute("text-anchor",C),$.textContent=g.date.toLocaleDateString(this.hass?.language||void 0,{month:"short",day:"numeric"})}_handleMouseLeave(t){const e=t.currentTarget.ownerSVGElement;if(!e)return;const n=e.querySelector(".hover-group");n&&(n.style.opacity="0")}_drawChart(t,e,n){const r=this._chartWidth,i=120,o=r<360,a=15,s=o?48:65,l=25,u=10,c=La().domain(Mt(e,t=>t.date)).range([u,r-s]),h=[...e.map(t=>t.value)];n.average_min&&h.push(parseFloat(n.average_min)),n.average_max&&h.push(parseFloat(n.average_max));const f=Mt(h),d=.1*(f[1]-f[0])||1,p=Ai().domain([f[0]-d,f[1]+d]).range([i-l,a]);let g=Ka;"linear"===this._config.chart_smoothing&&(g=qa),"step"===this._config.chart_smoothing&&(g=es);const _=Xa().x(t=>c(t.date)).y(t=>p(t.value)).curve(g),m=Va().x(t=>c(t.date)).y0(i-l).y1(t=>p(t.value)).curve(g),y=(t,e,i)=>{if(!t)return null;const a=parseFloat(t);if(isNaN(a))return null;const l=p(a),c=n.unit||"°C",h=i?o?`${a.toFixed(1)}${c}`:`${i} ${a.toFixed(1)}${c}`:"";return X` ${h?X`${h}`:""} `},v=t=>t.toLocaleDateString(this.hass?.language||void 0,{month:"short",day:"numeric"}),w=c.domain()[0],x=c.domain()[1],b=e[e.length-1],$=b?X` `:"",A=e.reduce((t,e)=>e.valuee.value>t.value?e:t,e[0]),S=n.unit||"°C",C=X` `;return X` ${v(w)} ${v(x)} ${y(n.average_min,"min",yt(this.hass,"card.min"))} ${y(n.average_max,"max",yt(this.hass,"card.max"))} ${y(n.average_avg,"avg",yt(this.hass,"card.avg"))} ${A?X``:""} ${M?X``:""} ${$} ${C} `}static get styles(){return[a(rs)]}}t([pt({attribute:!1})],as.prototype,"hass",void 0),t([ /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ function(t){return(e,n,r)=>((t,e,n)=>(n.configurable=!0,n.enumerable=!0,Reflect.decorate&&"object"!=typeof e&&Object.defineProperty(t,e,n),n))(e,n,{get(){return(e=>e.renderRoot?.querySelector(t)??null)(this)}})}("ha-card")],as.prototype,"_card",void 0),t([gt()],as.prototype,"_config",void 0),t([gt()],as.prototype,"_chartData",void 0),t([gt()],as.prototype,"_chartWidth",void 0),customElements.get(is)||customElements.define(is,as),window.customCards=window.customCards||[],window.customCards.push({type:is,name:"Sea Temperatures Card",description:"Display current and historical sea temperatures.",preview:!0,documentationURL:"https://github.com/timmaurice/sea-temperatures",getEntitySuggestion:(t,e)=>e.startsWith("sensor.seatemperatures_")&&t.states[e]?{config:{type:`custom:${is}`,places:[e]}}:null});const ss=s`.card-config{display:flex;flex-direction:column;gap:12px}.group{border:1px solid var(--divider-color);border-radius:var(--ha-card-border-radius, 12px);margin-top:0;padding:16px}.group-header{color:var(--primary-text-color);font-size:16px;font-weight:500;margin-bottom:12px}ha-form{display:block}.places-list{border:1px solid var(--divider-color);border-radius:var(--ha-card-border-radius, 12px);padding:16px;margin-bottom:12px}.places-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.places-header h3{margin:0;font-size:16px;font-weight:500;color:var(--primary-text-color)}.places{display:flex;flex-direction:column;gap:8px}.place-item{display:flex;align-items:center;gap:8px}.place-item ha-selector{flex:1}.handle{cursor:grab;color:var(--secondary-text-color);display:flex;align-items:center;justify-content:center}.handle:active{cursor:grabbing}.add-place-container{display:flex;justify-content:flex-end;margin-top:8px}`,ls=[{name:"title",selector:{text:{}}}],us=[{name:"sort_by",selector:{select:{options:[{value:"default",label:"Default"},{value:"name",label:"Name"},{value:"temp_asc",label:"Temperature Asc"},{value:"temp_desc",label:"Temperature Desc"}]}}},{type:"expandable",title:"groups.display",schema:[{name:"show_last_updated",selector:{boolean:{}}},{name:"show_trend",selector:{boolean:{}}},{name:"show_stats",selector:{boolean:{}}},{name:"show_chart",selector:{boolean:{}}},{name:"show_country",selector:{boolean:{}}},{name:"chart_smoothing",selector:{select:{options:["smooth","linear","step"]}}}]}];let cs=class extends ct{setConfig(t){this._config={sort_by:"default",show_trend:!0,show_last_updated:!0,show_stats:!0,show_chart:!0,show_country:!1,chart_smoothing:"smooth",...t}}_valueChanged(t){this.hass&&this._config&&vt(this,"config-changed",{config:{...this._config,...t.detail.value}})}_placeMoved(t){t.stopPropagation();const{oldIndex:e,newIndex:n}=t.detail;if(e===n)return;const r=[...this._config.places||[]],i=r.splice(e,1)[0];r.splice(n,0,i),this._config={...this._config,places:r},vt(this,"config-changed",{config:this._config})}_placeChanged(t,e){if(!e)return void this._removePlace(t);const n=[...this._config.places||[]],r="string"==typeof e?e:e.device,i=n.some((e,n)=>{if(n===t||!e)return!1;return("string"==typeof e?e:e.device)===r});if(i)return vt(this,"hass-notification",{message:yt(this.hass,"common.errors.duplicate_place")}),void this.requestUpdate();n[t]=e,this._config={...this._config,places:n},vt(this,"config-changed",{config:this._config})}_removePlace(t){const e=[...this._config.places||[]];e.splice(t,1),this._config={...this._config,places:e},vt(this,"config-changed",{config:this._config})}_addPlace(){const t=[...this._config.places||[],""];this._config={...this._config,places:t},vt(this,"config-changed",{config:this._config})}render(){if(!this.hass||!this._config)return W``;const t=t=>t.map(t=>{const e={...t};return"sort_by"===e.name&&(e.selector={select:{options:[{value:"default",label:yt(this.hass,"editor.sort_by_options.default")},{value:"name",label:yt(this.hass,"editor.sort_by_options.name")},{value:"temp_asc",label:yt(this.hass,"editor.sort_by_options.temp_asc")},{value:"temp_desc",label:yt(this.hass,"editor.sort_by_options.temp_desc")}]}}),"chart_smoothing"===e.name&&(e.selector={select:{options:[{value:"smooth",label:yt(this.hass,"editor.chart_smoothing_options.smooth")},{value:"linear",label:yt(this.hass,"editor.chart_smoothing_options.linear")},{value:"step",label:yt(this.hass,"editor.chart_smoothing_options.step")}]}}),"expandable"===e.type&&Array.isArray(e.schema)&&(e.title=yt(this.hass,`editor.${e.title}`),e.schema=e.schema.map(t=>({...t}))),e}),e=t(ls),n=t(us);return W`
yt(this.hass,`editor.${t.name}`)} @value-changed=${this._valueChanged} >

${yt(this.hass,"editor.places")}

${this._config.places?.map((t,e)=>W`
this._placeChanged(e,t.detail.value)} >
`)}
${yt(this.hass,"editor.add_place")}
yt(this.hass,`editor.${t.name}`)} @value-changed=${this._valueChanged} >
`}static{this.styles=s` ${a(ss)} `}};t([pt({attribute:!1})],cs.prototype,"hass",void 0),t([gt()],cs.prototype,"_config",void 0),cs=t([(t=>(e,n)=>{void 0!==n?n.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)})("sea-temperatures-card-editor")],cs);var hs=Object.freeze({__proto__:null,get SeaTemperaturesCardEditor(){return cs}});export{as as SeaTemperaturesCard};