diff --git a/README.md b/README.md index 5748eb1..5ae4960 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,9 @@ or added by clicking the "Add to lovelace" button on the HACS dashboard after in | date_locale | string | | Override the locale used for the date and time formatting | | image_clickable | boolean | `false` | Click on image leads to wikipedia, or not | | show_carnumber | boolean | `false` | Show the number of the car | -| location_clickable | boolean | `false` | Click on the location leads to wikipedia | -| previous_race | enum | | Hide/strikethrough or make the past races italic options are (hide, strikethrough or italic) | +| location_clickable| boolean | `false` | Click on the location leads to wikipedia | +| previous_race | enum | | Hide/strikethrough or make the past races italic options are (hide, strikethrough or italic) | +| standings | object | | Configuration for the driver standings card | ``` type: custom:formulaone-card @@ -72,6 +73,19 @@ title: Driver Standings ``` ![image](https://user-images.githubusercontent.com/10223677/194120796-28532a9d-a62d-44bb-8cb8-403bfa434a8b.png) +This card can also show the flags and team names of the driver: + +``` +type: custom:formulaone-card +card_type: driver_standings +sensor: sensor.formula_one_sensor_drivers +title: Driver Standings +standings: + show_flag: true + show_team: true + +``` + ``` type: custom:formulaone-card card_type: schedule diff --git a/formulaone-card.js b/formulaone-card.js index c56b696..5f534ea 100644 --- a/formulaone-card.js +++ b/formulaone-card.js @@ -1,11 +1,11 @@ /*! For license information please see formulaone-card.js.LICENSE.txt */ -(()=>{"use strict";var t={197:(t,e,r)=>{r.r(e),r.d(e,{DEFAULT_DOMAIN_ICON:()=>J,DEFAULT_PANEL:()=>Z,DEFAULT_VIEW_ENTITY_ID:()=>st,DOMAINS_HIDE_MORE_INFO:()=>et,DOMAINS_MORE_INFO_NO_HISTORY:()=>rt,DOMAINS_TOGGLE:()=>nt,DOMAINS_WITH_CARD:()=>X,DOMAINS_WITH_MORE_INFO:()=>tt,NumberFormat:()=>i,STATES_OFF:()=>it,TimeFormat:()=>n,UNIT_C:()=>at,UNIT_F:()=>ot,applyThemesOnElement:()=>U,computeCardSize:()=>L,computeDomain:()=>j,computeEntity:()=>H,computeRTL:()=>B,computeRTLDirection:()=>W,computeStateDisplay:()=>Q,computeStateDomain:()=>q,createThing:()=>dt,debounce:()=>ht,domainIcon:()=>pt,evaluateFilter:()=>ft,fireEvent:()=>ct,fixedIcons:()=>mt,formatDate:()=>u,formatDateMonth:()=>_,formatDateMonthYear:()=>g,formatDateNumeric:()=>h,formatDateShort:()=>p,formatDateTime:()=>A,formatDateTimeNumeric:()=>C,formatDateTimeWithSeconds:()=>E,formatDateWeekday:()=>c,formatDateYear:()=>b,formatNumber:()=>Y,formatTime:()=>T,formatTimeWeekday:()=>P,formatTimeWithSeconds:()=>N,forwardHaptic:()=>gt,getLovelace:()=>Ct,handleAction:()=>wt,handleActionConfig:()=>bt,handleClick:()=>$t,hasAction:()=>At,hasConfigOrEntityChanged:()=>St,hasDoubleClick:()=>Et,isNumericState:()=>z,navigate:()=>vt,numberFormatToLocale:()=>V,relativeTime:()=>R,round:()=>K,stateIcon:()=>Dt,timerTimeRemaining:()=>I,toggleEntity:()=>yt,turnOnOffEntities:()=>xt,turnOnOffEntity:()=>_t});var i,n,a,o=function(){return o=Object.assign||function(t){for(var e,r=1,i=arguments.length;r0)return{value:Math.round(h),unit:"year"};var m=12*h+u.getMonth()-d.getMonth();if(Math.round(Math.abs(m))>0)return{value:Math.round(m),unit:"month"};var p=n/604800;return{value:Math.round(p),unit:"week"}}(t,r);return i?function(t){return new Intl.RelativeTimeFormat(t.language,{numeric:"auto"})}(e).format(n.value,n.unit):Intl.NumberFormat(e.language,{style:"unit",unit:n.unit,unitDisplay:"long"}).format(Math.abs(n.value))};function I(t){var e,r=3600*(e=t.attributes.remaining.split(":").map(Number))[0]+60*e[1]+e[2];if("active"===t.state){var i=(new Date).getTime(),n=new Date(t.last_changed).getTime();r=Math.max(r-(i-n)/1e3,0)}return r}function F(){return(F=Object.assign||function(t){for(var e=1;e-1?t.split(".")[1].length:0;r.minimumFractionDigits=i,r.maximumFractionDigits=i}return r},Q=function(t,e,r,i){var n=void 0!==i?i:e.state;if("unknown"===n||"unavailable"===n)return t("state.default."+n);if(z(e)){if("monetary"===e.attributes.device_class)try{return Y(n,r,{style:"currency",currency:e.attributes.unit_of_measurement})}catch(t){}return Y(n,r)+(e.attributes.unit_of_measurement?" "+e.attributes.unit_of_measurement:"")}var a=q(e);if("input_datetime"===a){var o;if(void 0===i)return e.attributes.has_date&&e.attributes.has_time?(o=new Date(e.attributes.year,e.attributes.month-1,e.attributes.day,e.attributes.hour,e.attributes.minute),A(o,r)):e.attributes.has_date?(o=new Date(e.attributes.year,e.attributes.month-1,e.attributes.day),u(o,r)):e.attributes.has_time?((o=new Date).setHours(e.attributes.hour,e.attributes.minute),T(o,r)):e.state;try{var s=i.split(" ");if(2===s.length)return A(new Date(s.join("T")),r);if(1===s.length){if(i.includes("-"))return u(new Date(i+"T00:00"),r);if(i.includes(":")){var c=new Date;return T(new Date(c.toISOString().split("T")[0]+"T"+i),r)}}return i}catch(t){return i}}return"humidifier"===a&&"on"===n&&e.attributes.humidity?e.attributes.humidity+" %":"counter"===a||"number"===a||"input_number"===a?Y(n,r):e.attributes.device_class&&t("component."+a+".state."+e.attributes.device_class+"."+n)||t("component."+a+".state._."+n)||n},J="mdi:bookmark",Z="lovelace",X=["climate","cover","configurator","input_select","input_number","input_text","lock","media_player","scene","script","timer","vacuum","water_heater","weblink"],tt=["alarm_control_panel","automation","camera","climate","configurator","cover","fan","group","history_graph","input_datetime","light","lock","media_player","script","sun","updater","vacuum","water_heater","weather"],et=["input_number","input_select","input_text","scene","weblink"],rt=["camera","configurator","history_graph","scene"],it=["closed","locked","off"],nt=new Set(["fan","input_boolean","light","switch","group","automation"]),at="°C",ot="°F",st="group.default_view",ct=function(t,e,r,i){i=i||{},r=null==r?{}:r;var n=new Event(e,{bubbles:void 0===i.bubbles||i.bubbles,cancelable:Boolean(i.cancelable),composed:void 0===i.composed||i.composed});return n.detail=r,t.dispatchEvent(n),n},lt=new Set(["call-service","divider","section","weblink","cast","select"]),ut={alert:"toggle",automation:"toggle",climate:"climate",cover:"cover",fan:"toggle",group:"group",input_boolean:"toggle",input_number:"input-number",input_select:"input-select",input_text:"input-text",light:"toggle",lock:"lock",media_player:"media-player",remote:"toggle",scene:"scene",script:"script",sensor:"sensor",timer:"timer",switch:"toggle",vacuum:"toggle",water_heater:"climate",input_datetime:"input-datetime"},dt=function(t,e){void 0===e&&(e=!1);var r=function(t,e){return i("hui-error-card",{type:"error",error:t,config:e})},i=function(t,e){var i=window.document.createElement(t);try{if(!i.setConfig)return;i.setConfig(e)}catch(i){return console.error(t,i),r(i.message,e)}return i};if(!t||"object"!=typeof t||!e&&!t.type)return r("No type defined",t);var n=t.type;if(n&&n.startsWith("custom:"))n=n.substr("custom:".length);else if(e)if(lt.has(n))n="hui-"+n+"-row";else{if(!t.entity)return r("Invalid config given.",t);var a=t.entity.split(".",1)[0];n="hui-"+(ut[a]||"text")+"-entity-row"}else n="hui-"+n+"-card";if(customElements.get(n))return i(n,t);var o=r("Custom element doesn't exist: "+t.type+".",t);o.style.display="None";var s=setTimeout((function(){o.style.display=""}),2e3);return customElements.whenDefined(t.type).then((function(){clearTimeout(s),ct(o,"ll-rebuild",{},o)})),o},ht=function(t,e,r){var i;return void 0===r&&(r=!1),function(){var n=[].slice.call(arguments),a=this,o=function(){i=null,r||t.apply(a,n)},s=r&&!i;clearTimeout(i),i=setTimeout(o,e),s&&t.apply(a,n)}},mt={alert:"mdi:alert",automation:"mdi:playlist-play",calendar:"mdi:calendar",camera:"mdi:video",climate:"mdi:thermostat",configurator:"mdi:settings",conversation:"mdi:text-to-speech",device_tracker:"mdi:account",fan:"mdi:fan",group:"mdi:google-circles-communities",history_graph:"mdi:chart-line",homeassistant:"mdi:home-assistant",homekit:"mdi:home-automation",image_processing:"mdi:image-filter-frames",input_boolean:"mdi:drawing",input_datetime:"mdi:calendar-clock",input_number:"mdi:ray-vertex",input_select:"mdi:format-list-bulleted",input_text:"mdi:textbox",light:"mdi:lightbulb",mailbox:"mdi:mailbox",notify:"mdi:comment-alert",person:"mdi:account",plant:"mdi:flower",proximity:"mdi:apple-safari",remote:"mdi:remote",scene:"mdi:google-pages",script:"mdi:file-document",sensor:"mdi:eye",simple_alarm:"mdi:bell",sun:"mdi:white-balance-sunny",switch:"mdi:flash",timer:"mdi:timer",updater:"mdi:cloud-upload",vacuum:"mdi:robot-vacuum",water_heater:"mdi:thermometer",weblink:"mdi:open-in-new"};function pt(t,e){if(t in mt)return mt[t];switch(t){case"alarm_control_panel":switch(e){case"armed_home":return"mdi:bell-plus";case"armed_night":return"mdi:bell-sleep";case"disarmed":return"mdi:bell-outline";case"triggered":return"mdi:bell-ring";default:return"mdi:bell"}case"binary_sensor":return e&&"off"===e?"mdi:radiobox-blank":"mdi:checkbox-marked-circle";case"cover":return"closed"===e?"mdi:window-closed":"mdi:window-open";case"lock":return e&&"unlocked"===e?"mdi:lock-open":"mdi:lock";case"media_player":return e&&"off"!==e&&"idle"!==e?"mdi:cast-connected":"mdi:cast";case"zwave":switch(e){case"dead":return"mdi:emoticon-dead";case"sleeping":return"mdi:sleep";case"initializing":return"mdi:timer-sand";default:return"mdi:z-wave"}default:return console.warn("Unable to find icon for domain "+t+" ("+e+")"),"mdi:bookmark"}}var ft=function(t,e){var r=e.value||e,i=e.attribute?t.attributes[e.attribute]:t.state;switch(e.operator||"=="){case"==":return i===r;case"<=":return i<=r;case"<":return i=":return i>=r;case">":return i>r;case"!=":return i!==r;case"regex":return i.match(r);default:return!1}},gt=function(t){ct(window,"haptic",t)},vt=function(t,e,r){void 0===r&&(r=!1),r?history.replaceState(null,"",e):history.pushState(null,"",e),ct(window,"location-changed",{replace:r})},_t=function(t,e,r){void 0===r&&(r=!0);var i,n=j(e),a="group"===n?"homeassistant":n;switch(n){case"lock":i=r?"unlock":"lock";break;case"cover":i=r?"open_cover":"close_cover";break;default:i=r?"turn_on":"turn_off"}return t.callService(a,i,{entity_id:e})},yt=function(t,e){var r=it.includes(t.states[e].state);return _t(t,e,r)},bt=function(t,e,r,i){if(i||(i={action:"more-info"}),!i.confirmation||i.confirmation.exemptions&&i.confirmation.exemptions.some((function(t){return t.user===e.user.id}))||(gt("warning"),confirm(i.confirmation.text||"Are you sure you want to "+i.action+"?")))switch(i.action){case"more-info":(r.entity||r.camera_image)&&ct(t,"hass-more-info",{entityId:r.entity?r.entity:r.camera_image});break;case"navigate":i.navigation_path&&vt(0,i.navigation_path);break;case"url":i.url_path&&window.open(i.url_path);break;case"toggle":r.entity&&(yt(e,r.entity),gt("success"));break;case"call-service":if(!i.service)return void gt("failure");var n=i.service.split(".",2);e.callService(n[0],n[1],i.service_data,i.target),gt("success");break;case"fire-dom-event":ct(t,"ll-custom",i)}},wt=function(t,e,r,i){var n;"double_tap"===i&&r.double_tap_action?n=r.double_tap_action:"hold"===i&&r.hold_action?n=r.hold_action:"tap"===i&&r.tap_action&&(n=r.tap_action),bt(t,e,r,n)},$t=function(t,e,r,i,n){var a;if(n&&r.double_tap_action?a=r.double_tap_action:i&&r.hold_action?a=r.hold_action:!i&&r.tap_action&&(a=r.tap_action),a||(a={action:"more-info"}),!a.confirmation||a.confirmation.exemptions&&a.confirmation.exemptions.some((function(t){return t.user===e.user.id}))||confirm(a.confirmation.text||"Are you sure you want to "+a.action+"?"))switch(a.action){case"more-info":(a.entity||r.entity||r.camera_image)&&(ct(t,"hass-more-info",{entityId:a.entity?a.entity:r.entity?r.entity:r.camera_image}),a.haptic&>(a.haptic));break;case"navigate":a.navigation_path&&(vt(0,a.navigation_path),a.haptic&>(a.haptic));break;case"url":a.url_path&&window.open(a.url_path),a.haptic&>(a.haptic);break;case"toggle":r.entity&&(yt(e,r.entity),a.haptic&>(a.haptic));break;case"call-service":if(!a.service)return;var o=a.service.split(".",2),s=o[0],c=o[1],l=F({},a.service_data);"entity"===l.entity_id&&(l.entity_id=r.entity),e.callService(s,c,l,a.target),a.haptic&>(a.haptic);break;case"fire-dom-event":ct(t,"ll-custom",a),a.haptic&>(a.haptic)}};function At(t){return void 0!==t&&"none"!==t.action}function St(t,e,r){if(e.has("config")||r)return!0;if(t.config.entity){var i=e.get("hass");return!i||i.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}function Et(t){return void 0!==t&&"none"!==t.action}var xt=function(t,e,r){void 0===r&&(r=!0);var i={};e.forEach((function(e){if(it.includes(t.states[e].state)===r){var n=j(e),a=["cover","lock"].includes(n)?n:"homeassistant";a in i||(i[a]=[]),i[a].push(e)}})),Object.keys(i).forEach((function(e){var n;switch(e){case"lock":n=r?"unlock":"lock";break;case"cover":n=r?"open_cover":"close_cover";break;default:n=r?"turn_on":"turn_off"}t.callService(e,n,{entity_id:i[e]})}))},Ct=function(){var t=document.querySelector("home-assistant");if(t=(t=(t=(t=(t=(t=(t=(t=t&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root")){var e=t.lovelace;return e.current_view=t.___curView,e}return null},kt={humidity:"mdi:water-percent",illuminance:"mdi:brightness-5",temperature:"mdi:thermometer",pressure:"mdi:gauge",power:"mdi:flash",signal_strength:"mdi:wifi"},Tt={binary_sensor:function(t,e){var r="off"===t;switch(null==e?void 0:e.attributes.device_class){case"battery":return r?"mdi:battery":"mdi:battery-outline";case"battery_charging":return r?"mdi:battery":"mdi:battery-charging";case"cold":return r?"mdi:thermometer":"mdi:snowflake";case"connectivity":return r?"mdi:server-network-off":"mdi:server-network";case"door":return r?"mdi:door-closed":"mdi:door-open";case"garage_door":return r?"mdi:garage":"mdi:garage-open";case"power":case"plug":return r?"mdi:power-plug-off":"mdi:power-plug";case"gas":case"problem":case"safety":case"tamper":return r?"mdi:check-circle":"mdi:alert-circle";case"smoke":return r?"mdi:check-circle":"mdi:smoke";case"heat":return r?"mdi:thermometer":"mdi:fire";case"light":return r?"mdi:brightness-5":"mdi:brightness-7";case"lock":return r?"mdi:lock":"mdi:lock-open";case"moisture":return r?"mdi:water-off":"mdi:water";case"motion":return r?"mdi:walk":"mdi:run";case"occupancy":case"presence":return r?"mdi:home-outline":"mdi:home";case"opening":return r?"mdi:square":"mdi:square-outline";case"running":return r?"mdi:stop":"mdi:play";case"sound":return r?"mdi:music-note-off":"mdi:music-note";case"update":return r?"mdi:package":"mdi:package-up";case"vibration":return r?"mdi:crop-portrait":"mdi:vibrate";case"window":return r?"mdi:window-closed":"mdi:window-open";default:return r?"mdi:radiobox-blank":"mdi:checkbox-marked-circle"}},cover:function(t){var e="closed"!==t.state;switch(t.attributes.device_class){case"garage":return e?"mdi:garage-open":"mdi:garage";case"door":return e?"mdi:door-open":"mdi:door-closed";case"shutter":return e?"mdi:window-shutter-open":"mdi:window-shutter";case"blind":return e?"mdi:blinds-open":"mdi:blinds";case"window":return e?"mdi:window-open":"mdi:window-closed";default:return pt("cover",t.state)}},sensor:function(t){var e=t.attributes.device_class;if(e&&e in kt)return kt[e];if("battery"===e){var r=Number(t.state);if(isNaN(r))return"mdi:battery-unknown";var i=10*Math.round(r/10);return i>=100?"mdi:battery":i<=0?"mdi:battery-alert":"hass:battery-"+i}var n=t.attributes.unit_of_measurement;return"°C"===n||"°F"===n?"mdi:thermometer":pt("sensor")},input_datetime:function(t){return t.attributes.has_date?t.attributes.has_time?pt("input_datetime"):"mdi:calendar":"mdi:clock"}},Dt=function(t){if(!t)return"mdi:bookmark";if(t.attributes.icon)return t.attributes.icon;var e=j(t.entity_id);return e in Tt?Tt[e](t):pt(e,t.state)}},243:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BaseCard=void 0,e.BaseCard=class{constructor(t,e,r){this.sensor_entity_id=t,this.hass=e,this.config=r,this.sensor=this.getSensor()}getSensor(){const t=this.hass.states[this.sensor_entity_id];return{last_update:new Date(t.attributes.last_update),data:t.attributes.data}}}},521:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=r(692),n=r(243);class a extends n.BaseCard{constructor(t,e,r){super(t,e,r)}renderStandingRow(t){return i.html` +(()=>{"use strict";var t={197:(t,e,i)=>{i.r(e),i.d(e,{DEFAULT_DOMAIN_ICON:()=>J,DEFAULT_PANEL:()=>Q,DEFAULT_VIEW_ENTITY_ID:()=>st,DOMAINS_HIDE_MORE_INFO:()=>et,DOMAINS_MORE_INFO_NO_HISTORY:()=>it,DOMAINS_TOGGLE:()=>rt,DOMAINS_WITH_CARD:()=>X,DOMAINS_WITH_MORE_INFO:()=>tt,NumberFormat:()=>n,STATES_OFF:()=>nt,TimeFormat:()=>r,UNIT_C:()=>at,UNIT_F:()=>ot,applyThemesOnElement:()=>F,computeCardSize:()=>L,computeDomain:()=>B,computeEntity:()=>H,computeRTL:()=>j,computeRTLDirection:()=>z,computeStateDisplay:()=>Z,computeStateDomain:()=>K,createThing:()=>dt,debounce:()=>ht,domainIcon:()=>yt,evaluateFilter:()=>pt,fireEvent:()=>lt,fixedIcons:()=>mt,formatDate:()=>c,formatDateMonth:()=>v,formatDateMonthYear:()=>f,formatDateNumeric:()=>h,formatDateShort:()=>y,formatDateTime:()=>w,formatDateTimeNumeric:()=>A,formatDateTimeWithSeconds:()=>N,formatDateWeekday:()=>l,formatDateYear:()=>C,formatNumber:()=>V,formatTime:()=>E,formatTimeWeekday:()=>D,formatTimeWithSeconds:()=>k,forwardHaptic:()=>ft,getLovelace:()=>At,handleAction:()=>bt,handleActionConfig:()=>Ct,handleClick:()=>St,hasAction:()=>wt,hasConfigOrEntityChanged:()=>$t,hasDoubleClick:()=>Nt,isNumericState:()=>W,navigate:()=>gt,numberFormatToLocale:()=>G,relativeTime:()=>M,round:()=>q,stateIcon:()=>Tt,timerTimeRemaining:()=>R,toggleEntity:()=>_t,turnOnOffEntities:()=>Ot,turnOnOffEntity:()=>vt});var n,r,a,o=function(){return o=Object.assign||function(t){for(var e,i=1,n=arguments.length;i0)return{value:Math.round(h),unit:"year"};var m=12*h+c.getMonth()-d.getMonth();if(Math.round(Math.abs(m))>0)return{value:Math.round(m),unit:"month"};var y=r/604800;return{value:Math.round(y),unit:"week"}}(t,i);return n?function(t){return new Intl.RelativeTimeFormat(t.language,{numeric:"auto"})}(e).format(r.value,r.unit):Intl.NumberFormat(e.language,{style:"unit",unit:r.unit,unitDisplay:"long"}).format(Math.abs(r.value))};function R(t){var e,i=3600*(e=t.attributes.remaining.split(":").map(Number))[0]+60*e[1]+e[2];if("active"===t.state){var n=(new Date).getTime(),r=new Date(t.last_changed).getTime();i=Math.max(i-(n-r)/1e3,0)}return i}function U(){return(U=Object.assign||function(t){for(var e=1;e-1?t.split(".")[1].length:0;i.minimumFractionDigits=n,i.maximumFractionDigits=n}return i},Z=function(t,e,i,n){var r=void 0!==n?n:e.state;if("unknown"===r||"unavailable"===r)return t("state.default."+r);if(W(e)){if("monetary"===e.attributes.device_class)try{return V(r,i,{style:"currency",currency:e.attributes.unit_of_measurement})}catch(t){}return V(r,i)+(e.attributes.unit_of_measurement?" "+e.attributes.unit_of_measurement:"")}var a=K(e);if("input_datetime"===a){var o;if(void 0===n)return e.attributes.has_date&&e.attributes.has_time?(o=new Date(e.attributes.year,e.attributes.month-1,e.attributes.day,e.attributes.hour,e.attributes.minute),w(o,i)):e.attributes.has_date?(o=new Date(e.attributes.year,e.attributes.month-1,e.attributes.day),c(o,i)):e.attributes.has_time?((o=new Date).setHours(e.attributes.hour,e.attributes.minute),E(o,i)):e.state;try{var s=n.split(" ");if(2===s.length)return w(new Date(s.join("T")),i);if(1===s.length){if(n.includes("-"))return c(new Date(n+"T00:00"),i);if(n.includes(":")){var l=new Date;return E(new Date(l.toISOString().split("T")[0]+"T"+n),i)}}return n}catch(t){return n}}return"humidifier"===a&&"on"===r&&e.attributes.humidity?e.attributes.humidity+" %":"counter"===a||"number"===a||"input_number"===a?V(r,i):e.attributes.device_class&&t("component."+a+".state."+e.attributes.device_class+"."+r)||t("component."+a+".state._."+r)||r},J="mdi:bookmark",Q="lovelace",X=["climate","cover","configurator","input_select","input_number","input_text","lock","media_player","scene","script","timer","vacuum","water_heater","weblink"],tt=["alarm_control_panel","automation","camera","climate","configurator","cover","fan","group","history_graph","input_datetime","light","lock","media_player","script","sun","updater","vacuum","water_heater","weather"],et=["input_number","input_select","input_text","scene","weblink"],it=["camera","configurator","history_graph","scene"],nt=["closed","locked","off"],rt=new Set(["fan","input_boolean","light","switch","group","automation"]),at="°C",ot="°F",st="group.default_view",lt=function(t,e,i,n){n=n||{},i=null==i?{}:i;var r=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return r.detail=i,t.dispatchEvent(r),r},ut=new Set(["call-service","divider","section","weblink","cast","select"]),ct={alert:"toggle",automation:"toggle",climate:"climate",cover:"cover",fan:"toggle",group:"group",input_boolean:"toggle",input_number:"input-number",input_select:"input-select",input_text:"input-text",light:"toggle",lock:"lock",media_player:"media-player",remote:"toggle",scene:"scene",script:"script",sensor:"sensor",timer:"timer",switch:"toggle",vacuum:"toggle",water_heater:"climate",input_datetime:"input-datetime"},dt=function(t,e){void 0===e&&(e=!1);var i=function(t,e){return n("hui-error-card",{type:"error",error:t,config:e})},n=function(t,e){var n=window.document.createElement(t);try{if(!n.setConfig)return;n.setConfig(e)}catch(n){return console.error(t,n),i(n.message,e)}return n};if(!t||"object"!=typeof t||!e&&!t.type)return i("No type defined",t);var r=t.type;if(r&&r.startsWith("custom:"))r=r.substr("custom:".length);else if(e)if(ut.has(r))r="hui-"+r+"-row";else{if(!t.entity)return i("Invalid config given.",t);var a=t.entity.split(".",1)[0];r="hui-"+(ct[a]||"text")+"-entity-row"}else r="hui-"+r+"-card";if(customElements.get(r))return n(r,t);var o=i("Custom element doesn't exist: "+t.type+".",t);o.style.display="None";var s=setTimeout((function(){o.style.display=""}),2e3);return customElements.whenDefined(t.type).then((function(){clearTimeout(s),lt(o,"ll-rebuild",{},o)})),o},ht=function(t,e,i){var n;return void 0===i&&(i=!1),function(){var r=[].slice.call(arguments),a=this,o=function(){n=null,i||t.apply(a,r)},s=i&&!n;clearTimeout(n),n=setTimeout(o,e),s&&t.apply(a,r)}},mt={alert:"mdi:alert",automation:"mdi:playlist-play",calendar:"mdi:calendar",camera:"mdi:video",climate:"mdi:thermostat",configurator:"mdi:settings",conversation:"mdi:text-to-speech",device_tracker:"mdi:account",fan:"mdi:fan",group:"mdi:google-circles-communities",history_graph:"mdi:chart-line",homeassistant:"mdi:home-assistant",homekit:"mdi:home-automation",image_processing:"mdi:image-filter-frames",input_boolean:"mdi:drawing",input_datetime:"mdi:calendar-clock",input_number:"mdi:ray-vertex",input_select:"mdi:format-list-bulleted",input_text:"mdi:textbox",light:"mdi:lightbulb",mailbox:"mdi:mailbox",notify:"mdi:comment-alert",person:"mdi:account",plant:"mdi:flower",proximity:"mdi:apple-safari",remote:"mdi:remote",scene:"mdi:google-pages",script:"mdi:file-document",sensor:"mdi:eye",simple_alarm:"mdi:bell",sun:"mdi:white-balance-sunny",switch:"mdi:flash",timer:"mdi:timer",updater:"mdi:cloud-upload",vacuum:"mdi:robot-vacuum",water_heater:"mdi:thermometer",weblink:"mdi:open-in-new"};function yt(t,e){if(t in mt)return mt[t];switch(t){case"alarm_control_panel":switch(e){case"armed_home":return"mdi:bell-plus";case"armed_night":return"mdi:bell-sleep";case"disarmed":return"mdi:bell-outline";case"triggered":return"mdi:bell-ring";default:return"mdi:bell"}case"binary_sensor":return e&&"off"===e?"mdi:radiobox-blank":"mdi:checkbox-marked-circle";case"cover":return"closed"===e?"mdi:window-closed":"mdi:window-open";case"lock":return e&&"unlocked"===e?"mdi:lock-open":"mdi:lock";case"media_player":return e&&"off"!==e&&"idle"!==e?"mdi:cast-connected":"mdi:cast";case"zwave":switch(e){case"dead":return"mdi:emoticon-dead";case"sleeping":return"mdi:sleep";case"initializing":return"mdi:timer-sand";default:return"mdi:z-wave"}default:return console.warn("Unable to find icon for domain "+t+" ("+e+")"),"mdi:bookmark"}}var pt=function(t,e){var i=e.value||e,n=e.attribute?t.attributes[e.attribute]:t.state;switch(e.operator||"=="){case"==":return n===i;case"<=":return n<=i;case"<":return n=":return n>=i;case">":return n>i;case"!=":return n!==i;case"regex":return n.match(i);default:return!1}},ft=function(t){lt(window,"haptic",t)},gt=function(t,e,i){void 0===i&&(i=!1),i?history.replaceState(null,"",e):history.pushState(null,"",e),lt(window,"location-changed",{replace:i})},vt=function(t,e,i){void 0===i&&(i=!0);var n,r=B(e),a="group"===r?"homeassistant":r;switch(r){case"lock":n=i?"unlock":"lock";break;case"cover":n=i?"open_cover":"close_cover";break;default:n=i?"turn_on":"turn_off"}return t.callService(a,n,{entity_id:e})},_t=function(t,e){var i=nt.includes(t.states[e].state);return vt(t,e,i)},Ct=function(t,e,i,n){if(n||(n={action:"more-info"}),!n.confirmation||n.confirmation.exemptions&&n.confirmation.exemptions.some((function(t){return t.user===e.user.id}))||(ft("warning"),confirm(n.confirmation.text||"Are you sure you want to "+n.action+"?")))switch(n.action){case"more-info":(i.entity||i.camera_image)&<(t,"hass-more-info",{entityId:i.entity?i.entity:i.camera_image});break;case"navigate":n.navigation_path&>(0,n.navigation_path);break;case"url":n.url_path&&window.open(n.url_path);break;case"toggle":i.entity&&(_t(e,i.entity),ft("success"));break;case"call-service":if(!n.service)return void ft("failure");var r=n.service.split(".",2);e.callService(r[0],r[1],n.service_data,n.target),ft("success");break;case"fire-dom-event":lt(t,"ll-custom",n)}},bt=function(t,e,i,n){var r;"double_tap"===n&&i.double_tap_action?r=i.double_tap_action:"hold"===n&&i.hold_action?r=i.hold_action:"tap"===n&&i.tap_action&&(r=i.tap_action),Ct(t,e,i,r)},St=function(t,e,i,n,r){var a;if(r&&i.double_tap_action?a=i.double_tap_action:n&&i.hold_action?a=i.hold_action:!n&&i.tap_action&&(a=i.tap_action),a||(a={action:"more-info"}),!a.confirmation||a.confirmation.exemptions&&a.confirmation.exemptions.some((function(t){return t.user===e.user.id}))||confirm(a.confirmation.text||"Are you sure you want to "+a.action+"?"))switch(a.action){case"more-info":(a.entity||i.entity||i.camera_image)&&(lt(t,"hass-more-info",{entityId:a.entity?a.entity:i.entity?i.entity:i.camera_image}),a.haptic&&ft(a.haptic));break;case"navigate":a.navigation_path&&(gt(0,a.navigation_path),a.haptic&&ft(a.haptic));break;case"url":a.url_path&&window.open(a.url_path),a.haptic&&ft(a.haptic);break;case"toggle":i.entity&&(_t(e,i.entity),a.haptic&&ft(a.haptic));break;case"call-service":if(!a.service)return;var o=a.service.split(".",2),s=o[0],l=o[1],u=U({},a.service_data);"entity"===u.entity_id&&(u.entity_id=i.entity),e.callService(s,l,u,a.target),a.haptic&&ft(a.haptic);break;case"fire-dom-event":lt(t,"ll-custom",a),a.haptic&&ft(a.haptic)}};function wt(t){return void 0!==t&&"none"!==t.action}function $t(t,e,i){if(e.has("config")||i)return!0;if(t.config.entity){var n=e.get("hass");return!n||n.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}function Nt(t){return void 0!==t&&"none"!==t.action}var Ot=function(t,e,i){void 0===i&&(i=!0);var n={};e.forEach((function(e){if(nt.includes(t.states[e].state)===i){var r=B(e),a=["cover","lock"].includes(r)?r:"homeassistant";a in n||(n[a]=[]),n[a].push(e)}})),Object.keys(n).forEach((function(e){var r;switch(e){case"lock":r=i?"unlock":"lock";break;case"cover":r=i?"open_cover":"close_cover";break;default:r=i?"turn_on":"turn_off"}t.callService(e,r,{entity_id:n[e]})}))},At=function(){var t=document.querySelector("home-assistant");if(t=(t=(t=(t=(t=(t=(t=(t=t&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root")){var e=t.lovelace;return e.current_view=t.___curView,e}return null},It={humidity:"mdi:water-percent",illuminance:"mdi:brightness-5",temperature:"mdi:thermometer",pressure:"mdi:gauge",power:"mdi:flash",signal_strength:"mdi:wifi"},Et={binary_sensor:function(t,e){var i="off"===t;switch(null==e?void 0:e.attributes.device_class){case"battery":return i?"mdi:battery":"mdi:battery-outline";case"battery_charging":return i?"mdi:battery":"mdi:battery-charging";case"cold":return i?"mdi:thermometer":"mdi:snowflake";case"connectivity":return i?"mdi:server-network-off":"mdi:server-network";case"door":return i?"mdi:door-closed":"mdi:door-open";case"garage_door":return i?"mdi:garage":"mdi:garage-open";case"power":case"plug":return i?"mdi:power-plug-off":"mdi:power-plug";case"gas":case"problem":case"safety":case"tamper":return i?"mdi:check-circle":"mdi:alert-circle";case"smoke":return i?"mdi:check-circle":"mdi:smoke";case"heat":return i?"mdi:thermometer":"mdi:fire";case"light":return i?"mdi:brightness-5":"mdi:brightness-7";case"lock":return i?"mdi:lock":"mdi:lock-open";case"moisture":return i?"mdi:water-off":"mdi:water";case"motion":return i?"mdi:walk":"mdi:run";case"occupancy":case"presence":return i?"mdi:home-outline":"mdi:home";case"opening":return i?"mdi:square":"mdi:square-outline";case"running":return i?"mdi:stop":"mdi:play";case"sound":return i?"mdi:music-note-off":"mdi:music-note";case"update":return i?"mdi:package":"mdi:package-up";case"vibration":return i?"mdi:crop-portrait":"mdi:vibrate";case"window":return i?"mdi:window-closed":"mdi:window-open";default:return i?"mdi:radiobox-blank":"mdi:checkbox-marked-circle"}},cover:function(t){var e="closed"!==t.state;switch(t.attributes.device_class){case"garage":return e?"mdi:garage-open":"mdi:garage";case"door":return e?"mdi:door-open":"mdi:door-closed";case"shutter":return e?"mdi:window-shutter-open":"mdi:window-shutter";case"blind":return e?"mdi:blinds-open":"mdi:blinds";case"window":return e?"mdi:window-open":"mdi:window-closed";default:return yt("cover",t.state)}},sensor:function(t){var e=t.attributes.device_class;if(e&&e in It)return It[e];if("battery"===e){var i=Number(t.state);if(isNaN(i))return"mdi:battery-unknown";var n=10*Math.round(i/10);return n>=100?"mdi:battery":n<=0?"mdi:battery-alert":"hass:battery-"+n}var r=t.attributes.unit_of_measurement;return"°C"===r||"°F"===r?"mdi:thermometer":yt("sensor")},input_datetime:function(t){return t.attributes.has_date?t.attributes.has_time?yt("input_datetime"):"mdi:calendar":"mdi:clock"}},Tt=function(t){if(!t)return"mdi:bookmark";if(t.attributes.icon)return t.attributes.icon;var e=B(t.entity_id);return e in Et?Et[e](t):yt(e,t.state)}},243:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BaseCard=void 0,e.BaseCard=class{constructor(t,e,i){this.sensor_entity_id=t,this.hass=e,this.config=i,this.sensor=this.getSensor()}getSensor(){const t=this.hass.states[this.sensor_entity_id];return{last_update:new Date(t.attributes.last_update),data:t.attributes.data}}}},521:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=i(692),r=i(243);class a extends r.BaseCard{constructor(t,e,i){super(t,e,i)}renderStandingRow(t){return n.html` ${t.position} ${t.Constructor.name} ${t.points} ${t.wins} - `}render(){const t=this.sensor.data;if(!this.sensor_entity_id.endsWith("_constructors")||void 0===t)throw new Error("Please pass the correct sensor (constructors)");return i.html` + `}render(){const t=this.sensor.data;if(!this.sensor_entity_id.endsWith("_constructors")||void 0===t)throw new Error("Please pass the correct sensor (constructors)");return n.html` @@ -19,35 +19,37 @@ ${t.map((t=>this.renderStandingRow(t)))}
- `}}e.default=a},412:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=r(692),n=r(593),a=r(243);class o extends a.BaseCard{constructor(t,e,r){super(t,e,r)}renderStandingRow(t){return i.html` + `}}e.default=a},412:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=i(692),r=i(593),a=i(243),o=i(634);class s extends a.BaseCard{constructor(t,e,i){super(t,e,i),this.getCountryFlag=t=>{console.log(t,o.filter((e=>e.Nationality===t)).length);const e=o.filter((e=>e.Nationality===t))[0].Country.replace(" ","-");return(0,r.getCountryFlagUrl)(e)}}renderStandingRow(t){var e,i;return n.html` - ${t.position} - ${t.Driver.code} - ${(0,n.getDriverName)(t.Driver,this.config)} + ${t.position} + ${(null===(e=this.config.standings)||void 0===e?void 0:e.show_flag)?n.html` `:""}${t.Driver.code} + ${(0,r.getDriverName)(t.Driver,this.config)} + ${(null===(i=this.config.standings)||void 0===i?void 0:i.show_team)?n.html`${t.Constructors[0].name}`:""} ${t.points} ${t.wins} - `}render(){const t=this.sensor.data;if(!this.sensor_entity_id.endsWith("_drivers")||void 0===t)throw new Error("Please pass the correct sensor (drivers)");return i.html` + `}render(){var t;const e=this.sensor.data;if(!this.sensor_entity_id.endsWith("_drivers")||void 0===e)throw new Error("Please pass the correct sensor (drivers)");return n.html` - + + ${(null===(t=this.config.standings)||void 0===t?void 0:t.show_team)?n.html``:""} - ${t.map((t=>this.renderStandingRow(t)))} + ${e.map((t=>this.renderStandingRow(t)))}
 DriverDriverTeamPts Wins
- `}}e.default=o},958:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=r(692),n=r(593),a=r(243);class o extends a.BaseCard{constructor(t,e,r){super(t,e,r)}renderResultRow(t){return i.html` + `}}e.default=s},958:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=i(692),r=i(593),a=i(243);class o extends a.BaseCard{constructor(t,e,i){super(t,e,i)}renderResultRow(t){return n.html` ${t.position} - ${(0,n.getDriverName)(t.Driver,this.config)} + ${(0,r.getDriverName)(t.Driver,this.config)} ${t.grid} ${t.points} ${t.status} - `}renderHeader(){const t=this.sensor.data,e=t.Circuit.Location.country.replace(" ","-"),r=i.html``,a=this.config.image_clickable?i.html`${r}`:r;return i.html`

  ${t.round} : ${t.raceName}

${a}
`}render(){const t=this.sensor.data;if(!this.sensor_entity_id.endsWith("_last_result")||void 0===t)throw new Error("Please pass the correct sensor (last_result)");return i.html` + `}renderHeader(){const t=this.sensor.data,e=t.Circuit.Location.country.replace(" ","-"),i=n.html``,a=this.config.image_clickable?n.html`${i}`:i;return n.html`

  ${t.round} : ${t.raceName}

${a}
`}render(){const t=this.sensor.data;if(!this.sensor_entity_id.endsWith("_last_result")||void 0===t)throw new Error("Please pass the correct sensor (last_result)");return n.html` @@ -68,29 +70,29 @@ ${t.Results.map((t=>this.renderResultRow(t)))}
- `}}e.default=o},249:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=r(692),n=r(247),a=r(347),o=r(593),s=r(243);class c extends s.BaseCard{constructor(t,e,r){super(t,e,r);const i=this.hass.states[this.sensor_entity_id];this.next_race=i.attributes.next_race}renderHeader(){const t=this.next_race.Circuit.Location.country.replace(" ","-"),e=i.html``,r=this.config.image_clickable?i.html`${e}`:e;return i.html`

  ${this.next_race.round} : ${this.next_race.raceName}

${r}
`}render(){if(!this.sensor_entity_id.endsWith("_races")||void 0===this.next_race)throw new Error("Please pass the correct sensor (races)");const t=new Date(this.next_race.date+"T"+this.next_race.time),e=(0,a.formatDateTimeRaceInfo)(new Date(this.next_race.FirstPractice.date+"T"+this.next_race.FirstPractice.time),this.hass.locale),r=(0,a.formatDateTimeRaceInfo)(new Date(this.next_race.SecondPractice.date+"T"+this.next_race.SecondPractice.time),this.hass.locale),o=void 0!==this.next_race.ThirdPractice?(0,a.formatDateTimeRaceInfo)(new Date(this.next_race.ThirdPractice.date+"T"+this.next_race.ThirdPractice.time),this.hass.locale):"-",s=(0,a.formatDateTimeRaceInfo)(t,this.hass.locale),c=void 0!==this.next_race.Qualifying?(0,a.formatDateTimeRaceInfo)(new Date(this.next_race.Qualifying.date+"T"+this.next_race.Qualifying.time),this.hass.locale):"-",l=void 0!==this.next_race.Sprint?(0,a.formatDateTimeRaceInfo)(new Date(this.next_race.Sprint.date+"T"+this.next_race.Sprint.time),this.hass.locale):"-";return i.html` + `}}e.default=o},249:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=i(692),r=i(247),a=i(347),o=i(593),s=i(243);class l extends s.BaseCard{constructor(t,e,i){super(t,e,i);const n=this.hass.states[this.sensor_entity_id];this.next_race=n.attributes.next_race}renderHeader(){const t=this.next_race.Circuit.Location.country.replace(" ","-"),e=n.html``,i=this.config.image_clickable?n.html`${e}`:e;return n.html`

  ${this.next_race.round} : ${this.next_race.raceName}

${i}
`}render(){if(!this.sensor_entity_id.endsWith("_races")||void 0===this.next_race)throw new Error("Please pass the correct sensor (races)");const t=new Date(this.next_race.date+"T"+this.next_race.time),e=(0,a.formatDateTimeRaceInfo)(new Date(this.next_race.FirstPractice.date+"T"+this.next_race.FirstPractice.time),this.hass.locale),i=(0,a.formatDateTimeRaceInfo)(new Date(this.next_race.SecondPractice.date+"T"+this.next_race.SecondPractice.time),this.hass.locale),o=void 0!==this.next_race.ThirdPractice?(0,a.formatDateTimeRaceInfo)(new Date(this.next_race.ThirdPractice.date+"T"+this.next_race.ThirdPractice.time),this.hass.locale):"-",s=(0,a.formatDateTimeRaceInfo)(t,this.hass.locale),l=void 0!==this.next_race.Qualifying?(0,a.formatDateTimeRaceInfo)(new Date(this.next_race.Qualifying.date+"T"+this.next_race.Qualifying.time),this.hass.locale):"-",u=void 0!==this.next_race.Sprint?(0,a.formatDateTimeRaceInfo)(new Date(this.next_race.Sprint.date+"T"+this.next_race.Sprint.time),this.hass.locale):"-";return n.html` - - + + - - + +
${this.renderHeader()}
Date${(0,n.formatDateNumeric)(t,this.hass.locale,this.config.date_locale)} Practice 1${e}
Race${this.next_race.round} Practice 2${r}
Date${(0,r.formatDateNumeric)(t,this.hass.locale,this.config.date_locale)} Practice 1${e}
Race${this.next_race.round} Practice 2${i}
Race name${this.next_race.raceName} Practice 3${o}
Circuit name${this.next_race.Circuit.circuitName} Qualifying${c}
Location${this.next_race.Circuit.Location.country} Sprint${l}
Circuit name${this.next_race.Circuit.circuitName} Qualifying${l}
Location${this.next_race.Circuit.Location.country} Sprint${u}
City${this.next_race.Circuit.Location.locality} Race${s}
- `}}e.default=c},269:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=r(197),n=r(692),a=r(247),o=r(243);class s extends o.BaseCard{constructor(t,e,r){super(t,e,r)}renderLocation(t){const e=`${t.Location.locality}, ${t.Location.country}`;return this.config.location_clickable?n.html`${e}`:e}renderScheduleRow(t){const e=new Date(t.date+"T"+t.time),r=this.config.previous_race&&e + `}}e.default=l},269:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=i(197),r=i(692),a=i(247),o=i(243);class s extends o.BaseCard{constructor(t,e,i){super(t,e,i)}renderLocation(t){const e=`${t.Location.locality}, ${t.Location.country}`;return this.config.location_clickable?r.html`${e}`:e}renderScheduleRow(t){const e=new Date(t.date+"T"+t.time),i=this.config.previous_race&&e ${t.round} ${t.Circuit.circuitName} ${this.renderLocation(t.Circuit)} ${(0,a.formatDate)(e,this.hass.locale,this.config.date_locale)} - ${(0,i.formatTime)(e,this.hass.locale)} - `}render(){const t=this.sensor.data;if(!this.sensor_entity_id.endsWith("_races")||void 0===t)throw new Error("Please pass the correct sensor (races)");return n.html` + ${(0,n.formatTime)(e,this.hass.locale)} + `}render(){const t=this.sensor.data;if(!this.sensor_entity_id.endsWith("_races")||void 0===t)throw new Error("Please pass the correct sensor (races)");return r.html` @@ -105,12 +107,12 @@ ${t.map((t=>this.renderScheduleRow(t)))}
- `}}e.default=s},607:function(t,e,r){var i=this&&this.__decorate||function(t,e,r,i){var n,a=arguments.length,o=a<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,r,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(o=(a<3?n(o):a>3?n(e,r,o):n(e,r))||o);return a>3&&o&&Object.defineProperty(e,r,o),o};Object.defineProperty(e,"__esModule",{value:!0});const n=r(147),a=r(595),o=r(98),s=r(392),c=r(593),l=r(299),u=r(521),d=r(412),h=r(269),m=r(249),p=r(958);console.info(`%c FORMULAONE-CARD %c ${n.version}`,"color: cyan; background: black; font-weight: bold;","color: darkblue; background: white; font-weight: bold;"),window.customCards=window.customCards||[],window.customCards.push({type:"formulaone-card",name:"FormulaOne card",preview:!1,description:"Present the data of hass-formulaoneapi in a pretty way"});let f=class extends s.LitElement{setConfig(t){(0,c.checkConfig)(t),this.config=Object.assign({},t)}shouldUpdate(t){return(0,c.hasConfigOrEntitiesChanged)(this.config,t)}set hass(t){this._hass=t,this.config.hass=t}static get styles(){return l.style}renderCardType(){switch(this.config.card_type){case o.FormulaOneCardType.ConstructorStandings:return new u.default(this.config.sensor,this._hass,this.config).render();case o.FormulaOneCardType.DriverStandings:return new d.default(this.config.sensor,this._hass,this.config).render();case o.FormulaOneCardType.Schedule:return new h.default(this.config.sensor,this._hass,this.config).render();case o.FormulaOneCardType.NextRace:return new m.default(this.config.sensor,this._hass,this.config).render();case o.FormulaOneCardType.LastResult:return new p.default(this.config.sensor,this._hass,this.config).render()}}render(){if(!this._hass||!this.config)return s.html``;try{return s.html` + `}}e.default=s},607:function(t,e,i){var n=this&&this.__decorate||function(t,e,i,n){var r,a=arguments.length,o=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(o=(a<3?r(o):a>3?r(e,i,o):r(e,i))||o);return a>3&&o&&Object.defineProperty(e,i,o),o};Object.defineProperty(e,"__esModule",{value:!0});const r=i(147),a=i(595),o=i(98),s=i(392),l=i(593),u=i(299),c=i(521),d=i(412),h=i(269),m=i(249),y=i(958);console.info(`%c FORMULAONE-CARD %c ${r.version}`,"color: cyan; background: black; font-weight: bold;","color: darkblue; background: white; font-weight: bold;"),window.customCards=window.customCards||[],window.customCards.push({type:"formulaone-card",name:"FormulaOne card",preview:!1,description:"Present the data of hass-formulaoneapi in a pretty way"});let p=class extends s.LitElement{setConfig(t){(0,l.checkConfig)(t),this.config=Object.assign({},t)}shouldUpdate(t){return(0,l.hasConfigOrEntitiesChanged)(this.config,t)}set hass(t){this._hass=t,this.config.hass=t}static get styles(){return u.style}renderCardType(){switch(this.config.card_type){case o.FormulaOneCardType.ConstructorStandings:return new c.default(this.config.sensor,this._hass,this.config).render();case o.FormulaOneCardType.DriverStandings:return new d.default(this.config.sensor,this._hass,this.config).render();case o.FormulaOneCardType.Schedule:return new h.default(this.config.sensor,this._hass,this.config).render();case o.FormulaOneCardType.NextRace:return new m.default(this.config.sensor,this._hass,this.config).render();case o.FormulaOneCardType.LastResult:return new y.default(this.config.sensor,this._hass,this.config).render()}}render(){if(!this._hass||!this.config)return s.html``;try{return s.html` ${this.config.title?s.html`

${this.config.title}

`:""} ${this.renderCardType()}
- `}catch(t){return s.html`${t.toString()}`}}};i([(0,a.property)()],f.prototype,"_hass",void 0),i([(0,a.property)()],f.prototype,"config",void 0),f=i([(0,a.customElement)("formulaone-card")],f),e.default=f},623:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TimeFormat=e.NumberFormat=e.SECONDARY_INFO_VALUES=e.TIMESTAMP_FORMATS=e.LAST_UPDATED=e.LAST_CHANGED=e.UNAVAILABLE_STATES=e.UNKNOWN=e.UNAVAILABLE=void 0,e.UNAVAILABLE="unavailable",e.UNKNOWN="unknown",e.UNAVAILABLE_STATES=[e.UNAVAILABLE,e.UNKNOWN],e.LAST_CHANGED="last-changed",e.LAST_UPDATED="last-updated",e.TIMESTAMP_FORMATS=["relative","total","date","time","datetime"],e.SECONDARY_INFO_VALUES=["entity-id","last-changed","last-updated","last-triggered","position","tilt-position","brightness"],e.NumberFormat={language:"language",system:"system",comma_decimal:"comma_decimal",decimal_comma:"decimal_comma",space_comma:"space_comma",none:"none"},e.TimeFormat={language:"language",system:"system",am_pm:"12",twenty_four:"24"}},247:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatDateNumeric=e.formatDate=void 0,e.formatDate=(t,e,r)=>new Intl.DateTimeFormat(null!=r?r:e.language,{month:"2-digit",day:"2-digit"}).format(t),e.formatDateNumeric=(t,e,r)=>new Intl.DateTimeFormat(null!=r?r:e.language,{year:"2-digit",month:"2-digit",day:"2-digit"}).format(t)},347:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatDateTimeRaceInfo=e.formatDateTime=void 0;const i=r(100);e.formatDateTime=(t,e)=>new Intl.DateTimeFormat(e.language,{year:"numeric",month:"long",day:"numeric",hour:(0,i.useAmPm)(e)?"numeric":"2-digit",minute:"2-digit",hour12:(0,i.useAmPm)(e)}).format(t),e.formatDateTimeRaceInfo=(t,e)=>new Intl.DateTimeFormat(e.language,{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:(0,i.useAmPm)(e)}).format(t)},100:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.useAmPm=void 0;const i=r(623);e.useAmPm=t=>{if(t.time_format===i.TimeFormat.language||t.time_format===i.TimeFormat.system){const e=t.time_format===i.TimeFormat.language?t.language:void 0,r=(new Date).toLocaleString(e);return r.includes("AM")||r.includes("PM")}return t.time_format===i.TimeFormat.am_pm}},299:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.style=void 0;const i=r(392);e.style=i.css` + `}catch(t){return s.html`${t.toString()}`}}};n([(0,a.property)()],p.prototype,"_hass",void 0),n([(0,a.property)()],p.prototype,"config",void 0),p=n([(0,a.customElement)("formulaone-card")],p),e.default=p},623:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TimeFormat=e.NumberFormat=e.SECONDARY_INFO_VALUES=e.TIMESTAMP_FORMATS=e.LAST_UPDATED=e.LAST_CHANGED=e.UNAVAILABLE_STATES=e.UNKNOWN=e.UNAVAILABLE=void 0,e.UNAVAILABLE="unavailable",e.UNKNOWN="unknown",e.UNAVAILABLE_STATES=[e.UNAVAILABLE,e.UNKNOWN],e.LAST_CHANGED="last-changed",e.LAST_UPDATED="last-updated",e.TIMESTAMP_FORMATS=["relative","total","date","time","datetime"],e.SECONDARY_INFO_VALUES=["entity-id","last-changed","last-updated","last-triggered","position","tilt-position","brightness"],e.NumberFormat={language:"language",system:"system",comma_decimal:"comma_decimal",decimal_comma:"decimal_comma",space_comma:"space_comma",none:"none"},e.TimeFormat={language:"language",system:"system",am_pm:"12",twenty_four:"24"}},247:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatDateNumeric=e.formatDate=void 0,e.formatDate=(t,e,i)=>new Intl.DateTimeFormat(null!=i?i:e.language,{month:"2-digit",day:"2-digit"}).format(t),e.formatDateNumeric=(t,e,i)=>new Intl.DateTimeFormat(null!=i?i:e.language,{year:"2-digit",month:"2-digit",day:"2-digit"}).format(t)},347:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatDateTimeRaceInfo=e.formatDateTime=void 0;const n=i(100);e.formatDateTime=(t,e)=>new Intl.DateTimeFormat(e.language,{year:"numeric",month:"long",day:"numeric",hour:(0,n.useAmPm)(e)?"numeric":"2-digit",minute:"2-digit",hour12:(0,n.useAmPm)(e)}).format(t),e.formatDateTimeRaceInfo=(t,e)=>new Intl.DateTimeFormat(e.language,{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:(0,n.useAmPm)(e)}).format(t)},100:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.useAmPm=void 0;const n=i(623);e.useAmPm=t=>{if(t.time_format===n.TimeFormat.language||t.time_format===n.TimeFormat.system){const e=t.time_format===n.TimeFormat.language?t.language:void 0,i=(new Date).toLocaleString(e);return i.includes("AM")||i.includes("PM")}return t.time_format===n.TimeFormat.am_pm}},299:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.style=void 0;const n=i(392);e.style=n.css` table { width: 100%; border-spacing: 0; @@ -134,7 +136,7 @@ text-align: center; } .width-40 { - width: 50px; + width: 40px; } .width-50 { width: 50px; @@ -155,4 +157,4 @@ text-decoration: none; color: var(--secondary-text-color); } -`},98:(t,e)=>{var r,i;Object.defineProperty(e,"__esModule",{value:!0}),e.FormulaOneCardType=e.PreviousRaceDisplay=void 0,(i=e.PreviousRaceDisplay||(e.PreviousRaceDisplay={})).Strikethrough="strikethrough",i.Italic="italic",i.Hide="hide",(r=e.FormulaOneCardType||(e.FormulaOneCardType={})).DriverStandings="driver_standings",r.ConstructorStandings="constructor_standings",r.NextRace="next_race",r.Schedule="schedule",r.LastResult="last_result"},593:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getDriverName=e.getCountryFlagUrl=e.checkConfig=e.hasConfigOrEntitiesChanged=void 0,e.hasConfigOrEntitiesChanged=(t,e)=>{if(e.has("config"))return!0;const r=e.get("_hass");return!!r&&r.states[t.sensor]!==t.hass.states[t.sensor]},e.checkConfig=t=>{if(void 0===t.card_type)throw new Error("Please define FormulaOne card type (card_type).");if(void 0===t.sensor)throw new Error("Please define FormulaOne sensor.")},e.getCountryFlagUrl=t=>{const e=[{countryDashed:"USA",name:"United-States-of-America"}].filter((e=>e.countryDashed==t));return e.length>0&&(t=e[0].name),`https://www.countries-ofthe-world.com/flags-normal/flag-of-${t}.png`},e.getDriverName=(t,e)=>{const r="VER"==t.code?1:t.permanentNumber;return`${t.givenName} ${t.familyName}${e.show_carnumber?` #${r}`:""}`}},692:(t,e,r)=>{var i;r.r(e),r.d(e,{_$LH:()=>H,html:()=>A,noChange:()=>E,nothing:()=>x,render:()=>k,svg:()=>S});const n=window,a=n.trustedTypes,o=a?a.createPolicy("lit-html",{createHTML:t=>t}):void 0,s=`lit$${(Math.random()+"").slice(9)}$`,c="?"+s,l=`<${c}>`,u=document,d=(t="")=>u.createComment(t),h=t=>null===t||"object"!=typeof t&&"function"!=typeof t,m=Array.isArray,p=t=>m(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]),f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,g=/-->/g,v=/>/g,_=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),y=/'/g,b=/"/g,w=/^(?:script|style|textarea|title)$/i,$=t=>(e,...r)=>({_$litType$:t,strings:e,values:r}),A=$(1),S=$(2),E=Symbol.for("lit-noChange"),x=Symbol.for("lit-nothing"),C=new WeakMap,k=(t,e,r)=>{var i,n;const a=null!==(i=null==r?void 0:r.renderBefore)&&void 0!==i?i:e;let o=a._$litPart$;if(void 0===o){const t=null!==(n=null==r?void 0:r.renderBefore)&&void 0!==n?n:null;a._$litPart$=o=new M(e.insertBefore(d(),t),t,void 0,null!=r?r:{})}return o._$AI(t),o},T=u.createTreeWalker(u,129,null,!1),D=(t,e)=>{const r=t.length-1,i=[];let n,a=2===e?"":"",c=f;for(let e=0;e"===u[0]?(c=null!=n?n:f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,o=u[1],c=void 0===u[3]?_:'"'===u[3]?b:y):c===b||c===y?c=_:c===g||c===v?c=f:(c=_,n=void 0);const m=c===_&&t[e+1].startsWith("/>")?" ":"";a+=c===f?r+l:d>=0?(i.push(o),r.slice(0,d)+"$lit$"+r.slice(d)+s+m):r+s+(-2===d?(i.push(void 0),e):m)}const u=a+(t[r]||"")+(2===e?"":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==o?o.createHTML(u):u,i]};class N{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let n=0,o=0;const l=t.length-1,u=this.parts,[h,m]=D(t,e);if(this.el=N.createElement(h,r),T.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(i=T.nextNode())&&u.length0){i.textContent=a?a.emptyScript:"";for(let r=0;r2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=x}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,r,i){const n=this.strings;let a=!1;if(void 0===n)t=O(this,t,e,0),a=!h(t)||t!==this._$AH&&t!==E,a&&(this._$AH=t);else{const i=t;let o,s;for(t=n[0],o=0;o{r.r(e),r.d(e,{customElement:()=>i,eventOptions:()=>c,property:()=>a,query:()=>l,queryAll:()=>u,queryAssignedElements:()=>p,queryAssignedNodes:()=>f,queryAsync:()=>d,state:()=>o});const i=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:r,elements:i}=e;return{kind:r,elements:i,finisher(e){customElements.define(t,e)}}})(t,e),n=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(r){r.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(r){r.createProperty(e.key,t)}};function a(t){return(e,r)=>void 0!==r?((t,e,r)=>{e.constructor.createProperty(r,t)})(t,e,r):n(t,e)}function o(t){return a({...t,state:!0})}const s=({finisher:t,descriptor:e})=>(r,i)=>{var n;if(void 0===i){const i=null!==(n=r.originalKey)&&void 0!==n?n:r.key,a=null!=e?{kind:"method",placement:"prototype",key:i,descriptor:e(r.key)}:{...r,key:i};return null!=t&&(a.finisher=function(e){t(e,i)}),a}{const n=r.constructor;void 0!==e&&Object.defineProperty(r,i,e(i)),null==t||t(n,i)}};function c(t){return s({finisher:(e,r)=>{Object.assign(e.prototype[r],t)}})}function l(t,e){return s({descriptor:r=>{const i={get(){var e,r;return null!==(r=null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t))&&void 0!==r?r:null},enumerable:!0,configurable:!0};if(e){const e="symbol"==typeof r?Symbol():"__"+r;i.get=function(){var r,i;return void 0===this[e]&&(this[e]=null!==(i=null===(r=this.renderRoot)||void 0===r?void 0:r.querySelector(t))&&void 0!==i?i:null),this[e]}}return i}})}function u(t){return s({descriptor:e=>({get(){var e,r;return null!==(r=null===(e=this.renderRoot)||void 0===e?void 0:e.querySelectorAll(t))&&void 0!==r?r:[]},enumerable:!0,configurable:!0})})}function d(t){return s({descriptor:e=>({async get(){var e;return await this.updateComplete,null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t)},enumerable:!0,configurable:!0})})}var h;const m=null!=(null===(h=window.HTMLSlotElement)||void 0===h?void 0:h.prototype.assignedElements)?(t,e)=>t.assignedElements(e):(t,e)=>t.assignedNodes(e).filter((t=>t.nodeType===Node.ELEMENT_NODE));function p(t){const{slot:e,selector:r}=null!=t?t:{};return s({descriptor:i=>({get(){var i;const n="slot"+(e?`[name=${e}]`:":not([name])"),a=null===(i=this.renderRoot)||void 0===i?void 0:i.querySelector(n),o=null!=a?m(a,t):[];return r?o.filter((t=>t.matches(r))):o},enumerable:!0,configurable:!0})})}function f(t,e,r){let i,n=t;return"object"==typeof t?(n=t.slot,i=t):i={flatten:e},r?p({slot:n,flatten:e,selector:r}):s({descriptor:t=>({get(){var t,e;const r="slot"+(n?`[name=${n}]`:":not([name])"),a=null===(t=this.renderRoot)||void 0===t?void 0:t.querySelector(r);return null!==(e=null==a?void 0:a.assignedNodes(i))&&void 0!==e?e:[]},enumerable:!0,configurable:!0})})}},392:(t,e,r)=>{r.r(e),r.d(e,{CSSResult:()=>s,LitElement:()=>E,ReactiveElement:()=>b,UpdatingElement:()=>S,_$LE:()=>C,_$LH:()=>A._$LH,adoptStyles:()=>u,css:()=>l,defaultConverter:()=>v,getCompatibleStyle:()=>d,html:()=>A.html,noChange:()=>A.noChange,notEqual:()=>_,nothing:()=>A.nothing,render:()=>A.render,supportsAdoptingStyleSheets:()=>n,svg:()=>A.svg,unsafeCSS:()=>c});const i=window,n=i.ShadowRoot&&(void 0===i.ShadyCSS||i.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,a=Symbol(),o=new WeakMap;class s{constructor(t,e,r){if(this._$cssResult$=!0,r!==a)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 r=void 0!==e&&1===e.length;r&&(t=o.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&o.set(e,t))}return t}toString(){return this.cssText}}const c=t=>new s("string"==typeof t?t:t+"",void 0,a),l=(t,...e)=>{const r=1===t.length?t[0]:e.reduce(((e,r,i)=>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.")})(r)+t[i+1]),t[0]);return new s(r,t,a)},u=(t,e)=>{n?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const r=document.createElement("style"),n=i.litNonce;void 0!==n&&r.setAttribute("nonce",n),r.textContent=e.cssText,t.appendChild(r)}))},d=n?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const r of t.cssRules)e+=r.cssText;return c(e)})(t):t;var h;const m=window,p=m.trustedTypes,f=p?p.emptyScript:"",g=m.reactiveElementPolyfillSupport,v={toAttribute(t,e){switch(e){case Boolean:t=t?f:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let r=t;switch(e){case Boolean:r=null!==t;break;case Number:r=null===t?null:Number(t);break;case Object:case Array:try{r=JSON.parse(t)}catch(t){r=null}}return r}},_=(t,e)=>e!==t&&(e==e||t==t),y={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:_};class b extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;null!==(e=this.h)&&void 0!==e||(this.h=[]),this.h.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,r)=>{const i=this._$Ep(r,e);void 0!==i&&(this._$Ev.set(i,r),t.push(i))})),t}static createProperty(t,e=y){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const r="symbol"==typeof t?Symbol():"__"+t,i=this.getPropertyDescriptor(t,r,e);void 0!==i&&Object.defineProperty(this.prototype,t,i)}}static getPropertyDescriptor(t,e,r){return{get(){return this[e]},set(i){const n=this[t];this[e]=i,this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||y}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const r of e)this.createProperty(r,t[r])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const r=new Set(t.flat(1/0).reverse());for(const t of r)e.unshift(d(t))}else void 0!==t&&e.push(d(t));return e}static _$Ep(t,e){const r=e.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,r;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(r=t.hostConnected)||void 0===r||r.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return u(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$EO(t,e,r=y){var i;const n=this.constructor._$Ep(t,r);if(void 0!==n&&!0===r.reflect){const a=(void 0!==(null===(i=r.converter)||void 0===i?void 0:i.toAttribute)?r.converter:v).toAttribute(e,r.type);this._$El=t,null==a?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(t,e){var r;const i=this.constructor,n=i._$Ev.get(t);if(void 0!==n&&this._$El!==n){const t=i.getPropertyOptions(n),a="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(r=t.converter)||void 0===r?void 0:r.fromAttribute)?t.converter:v;this._$El=n,this[n]=a.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,r){let i=!0;void 0!==t&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||_)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===r.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,r))):i=!1),!this.isUpdatePending&&i&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const r=this._$AL;try{e=this.shouldUpdate(r),e?(this.willUpdate(r),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(r)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(r)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}b.finalized=!0,b.elementProperties=new Map,b.elementStyles=[],b.shadowRootOptions={mode:"open"},null==g||g({ReactiveElement:b}),(null!==(h=m.reactiveElementVersions)&&void 0!==h?h:m.reactiveElementVersions=[]).push("1.4.1");var w,$,A=r(692);const S=b;class E extends b{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e;const r=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=r.firstChild),r}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=(0,A.render)(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return A.noChange}}E.finalized=!0,E._$litElement$=!0,null===(w=globalThis.litElementHydrateSupport)||void 0===w||w.call(globalThis,{LitElement:E});const x=globalThis.litElementPolyfillSupport;null==x||x({LitElement:E});const C={_$AK:(t,e,r)=>{t._$AK(e,r)},_$AL:t=>t._$AL};(null!==($=globalThis.litElementVersions)&&void 0!==$?$:globalThis.litElementVersions=[]).push("3.2.2")},147:t=>{t.exports=JSON.parse('{"name":"formulaone-card","version":"0.1.2","description":"Frontend card for hass-formulaoneapi","main":"index.js","scripts":{"lint":"eslint src/**/*.ts","dev":"webpack -c webpack.config.js","build":"yarn lint && webpack -c webpack.config.js","test":"jest","coverage":"jest --coverage","workflow":"jest --coverage --json --outputFile=/home/runner/work/formulaone-card/formulaone-card/jest.results.json"},"repository":{"type":"git","url":"git+https://github.com/marcokreeft87/formulaone-card.git"},"keywords":[],"author":"","license":"ISC","bugs":{"url":"https://github.com/marcokreeft87/formulaone-card/issues"},"homepage":"https://github.com/marcokreeft87/formulaone-card#readme","devDependencies":{"@types/jest":"^29.1.1","@typescript-eslint/eslint-plugin":"^5.39.0","@typescript-eslint/parser":"^5.39.0","eslint":"^8.24.0","home-assistant-js-websocket":"^8.0.0","lit":"^2.3.1","typescript":"^4.8.4","webpack":"^5.74.0","webpack-cli":"^4.10.0"},"dependencies":{"@babel/plugin-transform-runtime":"^7.19.1","@babel/preset-env":"^7.19.3","@lit-labs/scoped-registry-mixin":"^1.0.1","babel-jest":"^29.1.2","compression-webpack-plugin":"^10.0.0","custom-card-helpers":"^1.9.0","jest-environment-jsdom":"^29.1.2","jest-ts-auto-mock":"^2.1.0","ts-auto-mock":"^3.6.2","ts-jest":"^29.0.3","ts-loader":"^9.4.1","ttypescript":"^1.5.13","yarn":"^1.22.19"}}')}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var a=e[i]={exports:{}};return t[i].call(a.exports,a,a.exports,r),a.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r(607)})(); \ No newline at end of file +`},98:(t,e)=>{var i,n;Object.defineProperty(e,"__esModule",{value:!0}),e.FormulaOneCardType=e.PreviousRaceDisplay=void 0,(n=e.PreviousRaceDisplay||(e.PreviousRaceDisplay={})).Strikethrough="strikethrough",n.Italic="italic",n.Hide="hide",(i=e.FormulaOneCardType||(e.FormulaOneCardType={})).DriverStandings="driver_standings",i.ConstructorStandings="constructor_standings",i.NextRace="next_race",i.Schedule="schedule",i.LastResult="last_result"},593:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getDriverName=e.getCountryFlagUrl=e.checkConfig=e.hasConfigOrEntitiesChanged=void 0,e.hasConfigOrEntitiesChanged=(t,e)=>{if(e.has("config"))return!0;const i=e.get("_hass");return!!i&&i.states[t.sensor]!==t.hass.states[t.sensor]},e.checkConfig=t=>{if(void 0===t.card_type)throw new Error("Please define FormulaOne card type (card_type).");if(void 0===t.sensor)throw new Error("Please define FormulaOne sensor.")},e.getCountryFlagUrl=t=>{const e=[{countryDashed:"USA",name:"United-States-of-America"}].filter((e=>e.countryDashed==t));return e.length>0&&(t=e[0].name),`https://www.countries-ofthe-world.com/flags-normal/flag-of-${t}.png`},e.getDriverName=(t,e)=>{const i="VER"==t.code?1:t.permanentNumber;return`${t.givenName} ${t.familyName}${e.show_carnumber?` #${i}`:""}`}},692:(t,e,i)=>{var n;i.r(e),i.d(e,{_$LH:()=>H,html:()=>w,noChange:()=>N,nothing:()=>O,render:()=>I,svg:()=>$});const r=window,a=r.trustedTypes,o=a?a.createPolicy("lit-html",{createHTML:t=>t}):void 0,s=`lit$${(Math.random()+"").slice(9)}$`,l="?"+s,u=`<${l}>`,c=document,d=(t="")=>c.createComment(t),h=t=>null===t||"object"!=typeof t&&"function"!=typeof t,m=Array.isArray,y=t=>m(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]),p=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,f=/-->/g,g=/>/g,v=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),_=/'/g,C=/"/g,b=/^(?:script|style|textarea|title)$/i,S=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),w=S(1),$=S(2),N=Symbol.for("lit-noChange"),O=Symbol.for("lit-nothing"),A=new WeakMap,I=(t,e,i)=>{var n,r;const a=null!==(n=null==i?void 0:i.renderBefore)&&void 0!==n?n:e;let o=a._$litPart$;if(void 0===o){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;a._$litPart$=o=new P(e.insertBefore(d(),t),t,void 0,null!=i?i:{})}return o._$AI(t),o},E=c.createTreeWalker(c,129,null,!1),T=(t,e)=>{const i=t.length-1,n=[];let r,a=2===e?"":"",l=p;for(let e=0;e"===c[0]?(l=null!=r?r:p,d=-1):void 0===c[1]?d=-2:(d=l.lastIndex-c[2].length,o=c[1],l=void 0===c[3]?v:'"'===c[3]?C:_):l===C||l===_?l=v:l===f||l===g?l=p:(l=v,r=void 0);const m=l===v&&t[e+1].startsWith("/>")?" ":"";a+=l===p?i+u:d>=0?(n.push(o),i.slice(0,d)+"$lit$"+i.slice(d)+s+m):i+s+(-2===d?(n.push(void 0),e):m)}const c=a+(t[i]||"")+(2===e?"":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==o?o.createHTML(c):c,n]};class k{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let r=0,o=0;const u=t.length-1,c=this.parts,[h,m]=T(t,e);if(this.el=k.createElement(h,i),E.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(n=E.nextNode())&&c.length0){n.textContent=a?a.emptyScript:"";for(let i=0;i2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=O}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,n){const r=this.strings;let a=!1;if(void 0===r)t=x(this,t,e,0),a=!h(t)||t!==this._$AH&&t!==N,a&&(this._$AH=t);else{const n=t;let o,s;for(t=r[0],o=0;o{i.r(e),i.d(e,{customElement:()=>n,eventOptions:()=>l,property:()=>a,query:()=>u,queryAll:()=>c,queryAssignedElements:()=>y,queryAssignedNodes:()=>p,queryAsync:()=>d,state:()=>o});const n=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){customElements.define(t,e)}}})(t,e),r=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function a(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):r(t,e)}function o(t){return a({...t,state:!0})}const s=({finisher:t,descriptor:e})=>(i,n)=>{var r;if(void 0===n){const n=null!==(r=i.originalKey)&&void 0!==r?r:i.key,a=null!=e?{kind:"method",placement:"prototype",key:n,descriptor:e(i.key)}:{...i,key:n};return null!=t&&(a.finisher=function(e){t(e,n)}),a}{const r=i.constructor;void 0!==e&&Object.defineProperty(i,n,e(n)),null==t||t(r,n)}};function l(t){return s({finisher:(e,i)=>{Object.assign(e.prototype[i],t)}})}function u(t,e){return s({descriptor:i=>{const n={get(){var e,i;return null!==(i=null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t))&&void 0!==i?i:null},enumerable:!0,configurable:!0};if(e){const e="symbol"==typeof i?Symbol():"__"+i;n.get=function(){var i,n;return void 0===this[e]&&(this[e]=null!==(n=null===(i=this.renderRoot)||void 0===i?void 0:i.querySelector(t))&&void 0!==n?n:null),this[e]}}return n}})}function c(t){return s({descriptor:e=>({get(){var e,i;return null!==(i=null===(e=this.renderRoot)||void 0===e?void 0:e.querySelectorAll(t))&&void 0!==i?i:[]},enumerable:!0,configurable:!0})})}function d(t){return s({descriptor:e=>({async get(){var e;return await this.updateComplete,null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t)},enumerable:!0,configurable:!0})})}var h;const m=null!=(null===(h=window.HTMLSlotElement)||void 0===h?void 0:h.prototype.assignedElements)?(t,e)=>t.assignedElements(e):(t,e)=>t.assignedNodes(e).filter((t=>t.nodeType===Node.ELEMENT_NODE));function y(t){const{slot:e,selector:i}=null!=t?t:{};return s({descriptor:n=>({get(){var n;const r="slot"+(e?`[name=${e}]`:":not([name])"),a=null===(n=this.renderRoot)||void 0===n?void 0:n.querySelector(r),o=null!=a?m(a,t):[];return i?o.filter((t=>t.matches(i))):o},enumerable:!0,configurable:!0})})}function p(t,e,i){let n,r=t;return"object"==typeof t?(r=t.slot,n=t):n={flatten:e},i?y({slot:r,flatten:e,selector:i}):s({descriptor:t=>({get(){var t,e;const i="slot"+(r?`[name=${r}]`:":not([name])"),a=null===(t=this.renderRoot)||void 0===t?void 0:t.querySelector(i);return null!==(e=null==a?void 0:a.assignedNodes(n))&&void 0!==e?e:[]},enumerable:!0,configurable:!0})})}},392:(t,e,i)=>{i.r(e),i.d(e,{CSSResult:()=>s,LitElement:()=>N,ReactiveElement:()=>C,UpdatingElement:()=>$,_$LE:()=>A,_$LH:()=>w._$LH,adoptStyles:()=>c,css:()=>u,defaultConverter:()=>g,getCompatibleStyle:()=>d,html:()=>w.html,noChange:()=>w.noChange,notEqual:()=>v,nothing:()=>w.nothing,render:()=>w.render,supportsAdoptingStyleSheets:()=>r,svg:()=>w.svg,unsafeCSS:()=>l});const n=window,r=n.ShadowRoot&&(void 0===n.ShadyCSS||n.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,a=Symbol(),o=new WeakMap;class s{constructor(t,e,i){if(this._$cssResult$=!0,i!==a)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(r&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=o.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&o.set(e,t))}return t}toString(){return this.cssText}}const l=t=>new s("string"==typeof t?t:t+"",void 0,a),u=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>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.")})(i)+t[n+1]),t[0]);return new s(i,t,a)},c=(t,e)=>{r?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),r=n.litNonce;void 0!==r&&i.setAttribute("nonce",r),i.textContent=e.cssText,t.appendChild(i)}))},d=r?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return l(e)})(t):t;var h;const m=window,y=m.trustedTypes,p=y?y.emptyScript:"",f=m.reactiveElementPolyfillSupport,g={toAttribute(t,e){switch(e){case Boolean:t=t?p:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},v=(t,e)=>e!==t&&(e==e||t==t),_={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:v};class C extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;null!==(e=this.h)&&void 0!==e||(this.h=[]),this.h.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const n=this._$Ep(i,e);void 0!==n&&(this._$Ev.set(n,i),t.push(n))})),t}static createProperty(t,e=_){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,n=this.getPropertyDescriptor(t,i,e);void 0!==n&&Object.defineProperty(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(n){const r=this[t];this[e]=n,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||_}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(d(t))}else void 0!==t&&e.push(d(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return c(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=_){var n;const r=this.constructor._$Ep(t,i);if(void 0!==r&&!0===i.reflect){const a=(void 0!==(null===(n=i.converter)||void 0===n?void 0:n.toAttribute)?i.converter:g).toAttribute(e,i.type);this._$El=t,null==a?this.removeAttribute(r):this.setAttribute(r,a),this._$El=null}}_$AK(t,e){var i;const n=this.constructor,r=n._$Ev.get(t);if(void 0!==r&&this._$El!==r){const t=n.getPropertyOptions(r),a="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:g;this._$El=r,this[r]=a.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let n=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||v)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}C.finalized=!0,C.elementProperties=new Map,C.elementStyles=[],C.shadowRootOptions={mode:"open"},null==f||f({ReactiveElement:C}),(null!==(h=m.reactiveElementVersions)&&void 0!==h?h:m.reactiveElementVersions=[]).push("1.4.1");var b,S,w=i(692);const $=C;class N extends C{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=(0,w.render)(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return w.noChange}}N.finalized=!0,N._$litElement$=!0,null===(b=globalThis.litElementHydrateSupport)||void 0===b||b.call(globalThis,{LitElement:N});const O=globalThis.litElementPolyfillSupport;null==O||O({LitElement:N});const A={_$AK:(t,e,i)=>{t._$AK(e,i)},_$AL:t=>t._$AL};(null!==(S=globalThis.litElementVersions)&&void 0!==S?S:globalThis.litElementVersions=[]).push("3.2.2")},147:t=>{t.exports=JSON.parse('{"name":"formulaone-card","version":"0.1.2","description":"Frontend card for hass-formulaoneapi","main":"index.js","scripts":{"lint":"eslint src/**/*.ts","dev":"webpack -c webpack.config.js","build":"yarn lint && webpack -c webpack.config.js","test":"jest","coverage":"jest --coverage","workflow":"jest --coverage --json --outputFile=/home/runner/work/formulaone-card/formulaone-card/jest.results.json"},"repository":{"type":"git","url":"git+https://github.com/marcokreeft87/formulaone-card.git"},"keywords":[],"author":"","license":"ISC","bugs":{"url":"https://github.com/marcokreeft87/formulaone-card/issues"},"homepage":"https://github.com/marcokreeft87/formulaone-card#readme","devDependencies":{"@types/jest":"^29.1.1","@typescript-eslint/eslint-plugin":"^5.39.0","@typescript-eslint/parser":"^5.39.0","eslint":"^8.24.0","home-assistant-js-websocket":"^8.0.0","lit":"^2.3.1","typescript":"^4.8.4","webpack":"^5.74.0","webpack-cli":"^4.10.0"},"dependencies":{"@babel/plugin-transform-runtime":"^7.19.1","@babel/preset-env":"^7.19.3","@lit-labs/scoped-registry-mixin":"^1.0.1","babel-jest":"^29.1.2","compression-webpack-plugin":"^10.0.0","custom-card-helpers":"^1.9.0","jest-environment-jsdom":"^29.1.2","jest-ts-auto-mock":"^2.1.0","ts-auto-mock":"^3.6.2","ts-jest":"^29.0.3","ts-loader":"^9.4.1","ttypescript":"^1.5.13","yarn":"^1.22.19"}}')},634:t=>{t.exports=JSON.parse('[{"Code":"AD","Country":"Andorra","ISO":"53","Nationality":"Andorian"},{"Code":"AE","Country":"United Arab Emirates","ISO":"126","Nationality":"Emirian"},{"Code":"AF","Country":"Afghanistan","ISO":"133","Nationality":"Afghani"},{"Code":"AI","Country":"Anguilla","ISO":"55","Nationality":"Anguillan"},{"Code":"AM","Country":"Armenia","ISO":"58","Nationality":"Armenian"},{"Code":"AO","Country":"Angola","ISO":"54","Nationality":"Angolian"},{"Code":"AQ","Country":"Antarctica","ISO":"55","Nationality":"Antarctic"},{"Code":"AR","Country":"Argentina","ISO":"57","Nationality":"Argentine"},{"Code":"AS","Country":"Austria","ISO":"3","Nationality":"Austrian"},{"Code":"AU","Country":"Australia","ISO":"2","Nationality":"Australian"},{"Code":"AW","Country":"Aruba","ISO":"59","Nationality":"Arubian"},{"Code":"BA","Country":"Bangladesh","ISO":"45","Nationality":"Bangladeshi"},{"Code":"BB","Country":"Barbados","ISO":"63","Nationality":"Barbadian"},{"Code":"BE","Country":"Belgium","ISO":"4","Nationality":"Belgian"},{"Code":"BH","Country":"Bahrain","ISO":"62","Nationality":"Bahrainian"},{"Code":"BM","Country":"Bermuda","ISO":"67","Nationality":"Bermuda"},{"Code":"BO","Country":"Bolivia","ISO":"69","Nationality":"Bolivian"},{"Code":"BR","Country":"Brazil","ISO":"43","Nationality":"Brazilian"},{"Code":"BS","Country":"Bahamas","ISO":"61","Nationality":"Bahameese"},{"Code":"BT","Country":"Bhutan","ISO":"68","Nationality":"Bhutanese"},{"Code":"BU","Country":"Bulgaria","ISO":"44","Nationality":"Bulgarian"},{"Code":"BY","Country":"Belarus","ISO":"64","Nationality":"Belarusian"},{"Code":"BZ","Country":"Belize","ISO":"65","Nationality":"Belizean"},{"Code":"CA","Country":"Canada","ISO":"6","Nationality":"Canadian"},{"Code":"CG","Country":"Congo","ISO":"72","Nationality":"Congolese"},{"Code":"CH","Country":"China","ISO":"51","Nationality":"Chinese"},{"Code":"CH","Country":"Switzerland","ISO":"35","Nationality":"Swiss"},{"Code":"CL","Country":"Chile","ISO":"71","Nationality":"Chilean"},{"Code":"CM","Country":"Cambodia","ISO":"5","Nationality":"Cambodian"},{"Code":"CM","Country":"Cameroon","ISO":"70","Nationality":"Cameroonian"},{"Code":"CO","Country":"Columbia","ISO":"46","Nationality":"Columbian"},{"Code":"CR","Country":"Czech Republic","ISO":"50","Nationality":"Czech"},{"Code":"CR","Country":"Costa Rica","ISO":"73","Nationality":"Costa Rican"},{"Code":"CU","Country":"Cuba","ISO":"75","Nationality":"Cuban"},{"Code":"CY","Country":"Cyprus","ISO":"76","Nationality":"Cypriot"},{"Code":"DE","Country":"Germany","ISO":"10","Nationality":"German"},{"Code":"DK","Country":"Denmark","ISO":"7","Nationality":"Danish"},{"Code":"DM","Country":"Dominica","ISO":"77","Nationality":"Dominican"},{"Code":"EC","Country":"Ecuador","ISO":"78","Nationality":"Ecuadorean"},{"Code":"EE","Country":"Estonia","ISO":"79","Nationality":"Estonian"},{"Code":"EG","Country":"Egypt","ISO":"8","Nationality":"Egyptian"},{"Code":"ET","Country":"Ethiopia","ISO":"80","Nationality":"Ethiopian"},{"Code":"FI","Country":"Finland","ISO":"82","Nationality":"Finnish"},{"Code":"FJ","Country":"Fiji","ISO":"81","Nationality":"Fijian"},{"Code":"FR","Country":"France","ISO":"9","Nationality":"French"},{"Code":"GB","Country":"United Kingdom","ISO":"39","Nationality":"British"},{"Code":"GE","Country":"Georgia","ISO":"83","Nationality":"Georgian"},{"Code":"GH","Country":"Ghana","ISO":"84","Nationality":"Ghanaian"},{"Code":"GN","Country":"Guinea","ISO":"86","Nationality":"Guinean"},{"Code":"GR","Country":"Greece","ISO":"11","Nationality":"Greek"},{"Code":"GY","Country":"Guyana","ISO":"87","Nationality":"Guyanese"},{"Code":"HK","Country":"Hong Kong","ISO":"13","Nationality":"Chinese"},{"Code":"HR","Country":"Croatia","ISO":"74","Nationality":"Croatian"},{"Code":"HU","Country":"Hungary","ISO":"14","Nationality":"Hungarian"},{"Code":"ID","Country":"Indonesia","ISO":"16","Nationality":"Indonesian"},{"Code":"IE","Country":"Ireland","ISO":"90","Nationality":"Irish"},{"Code":"IN","Country":"India","ISO":"15","Nationality":"Indian"},{"Code":"IQ","Country":"Iraq","ISO":"89","Nationality":"Iraqi"},{"Code":"IR","Country":"Iran","ISO":"17","Nationality":"Iranian"},{"Code":"IS","Country":"Israel","ISO":"18","Nationality":"Israeli"},{"Code":"IS","Country":"Iceland","ISO":"88","Nationality":"Icelander"},{"Code":"IT","Country":"Italy","ISO":"19","Nationality":"Italian"},{"Code":"JM","Country":"Jamaica","ISO":"91","Nationality":"Jamaican"},{"Code":"JO","Country":"Jordan","ISO":"92","Nationality":"Jordanian"},{"Code":"JP","Country":"Japan","ISO":"20","Nationality":"Japanese"},{"Code":"KE","Country":"Kenya","ISO":"94","Nationality":"Kenyan"},{"Code":"KO","Country":"Korea","ISO":"21","Nationality":"Korean"},{"Code":"KW","Country":"Kuwait","ISO":"95","Nationality":"Kuwaiti"},{"Code":"KZ","Country":"Kazakhstan","ISO":"134","Nationality":"Kazakhstani"},{"Code":"KZ","Country":"Kazakhstan","ISO":"93","Nationality":"Kazakhstani"},{"Code":"LB","Country":"Lebanon","ISO":"96","Nationality":"Lebanese"},{"Code":"LK","Country":"Sri Lanka","ISO":"33","Nationality":"Sri Lankan"},{"Code":"LT","Country":"Lithuania","ISO":"97","Nationality":"Lithuanian"},{"Code":"LU","Country":"Luxembourg","ISO":"98","Nationality":"Luxembourger"},{"Code":"MA","Country":"Morocco","ISO":"104","Nationality":"Moroccan"},{"Code":"MC","Country":"Monaco","ISO":"102","Nationality":"Monegasque"},{"Code":"ME","Country":"Mexico","ISO":"47","Nationality":"Mexican"},{"Code":"MM","Country":"Myanmar","ISO":"105","Nationality":"Mayanmarese"},{"Code":"MN","Country":"Mongolia","ISO":"103","Nationality":"Mongolian"},{"Code":"MO","Country":"Macau","ISO":"42","Nationality":"Macau"},{"Code":"MU","Country":"Mauritius","ISO":"100","Nationality":"Mauritian"},{"Code":"MV","Country":"Maldives","ISO":"99","Nationality":"Maldivan"},{"Code":"MY","Country":"Malaysia","ISO":"22","Nationality":"Malaysian"},{"Code":"NA","Country":"Namibia","ISO":"106","Nationality":"Namibian"},{"Code":"NG","Country":"Nigeria","ISO":"108","Nationality":"Nigerian"},{"Code":"NL","Country":"Netherlands","ISO":"12","Nationality":"Dutch"},{"Code":"NO","Country":"Norway","ISO":"24","Nationality":"Norwegian"},{"Code":"NP","Country":"Nepal","ISO":"107","Nationality":"Nepalese"},{"Code":"NZ","Country":"New Zealand","ISO":"23","Nationality":"New Zealander"},{"Code":"OM","Country":"Oman","ISO":"109","Nationality":"Omani"},{"Code":"PA","Country":"Panama","ISO":"110","Nationality":"Panamanian"},{"Code":"PE","Country":"Peru","ISO":"112","Nationality":"Peruvian"},{"Code":"PH","Country":"Philippines","ISO":"27","Nationality":"Filipino"},{"Code":"PK","Country":"Pakistan","ISO":"26","Nationality":"Pakistani"},{"Code":"PO","Country":"Poland","ISO":"28","Nationality":"Polish"},{"Code":"PT","Country":"Portugal","ISO":"113","Nationality":"Portugees"},{"Code":"PY","Country":"Paraguay","ISO":"111","Nationality":"Paraguayan"},{"Code":"QA","Country":"Qatar","ISO":"115","Nationality":"Qatari"},{"Code":"RO","Country":"Romania","ISO":"48","Nationality":"Romanian"},{"Code":"RU","Country":"Russia","ISO":"29","Nationality":"Russian"},{"Code":"SA","Country":"Saudi Arabia","ISO":"116","Nationality":"Saudi Arabian"},{"Code":"SC","Country":"Seychelles","ISO":"119","Nationality":"Seychellois"},{"Code":"SE","Country":"Sweden","ISO":"34","Nationality":"Swedish"},{"Code":"SG","Country":"Singapore","ISO":"30","Nationality":"Singaporean"},{"Code":"SK","Country":"Slovakia","ISO":"120","Nationality":"Slovakian"},{"Code":"SN","Country":"Senegal","ISO":"117","Nationality":"Senegalese"},{"Code":"SO","Country":"Somalia","ISO":"121","Nationality":"Somali"},{"Code":"SP","Country":"Spain","ISO":"32","Nationality":"Spanish"},{"Code":"TH","Country":"Thailand","ISO":"37","Nationality":"Thai"},{"Code":"TN","Country":"Tunisia","ISO":"123","Nationality":"Tunisian"},{"Code":"TR","Country":"Turkey","ISO":"38","Nationality":"Turkish"},{"Code":"TW","Country":"Taiwan","ISO":"36","Nationality":"Taiwanese"},{"Code":"TZ","Country":"Tanzania","ISO":"122","Nationality":"Tanzanian"},{"Code":"UA","Country":"Ukraine","ISO":"125","Nationality":"Ukrainian"},{"Code":"UG","Country":"Uganda","ISO":"124","Nationality":"Ugandan"},{"Code":"US","Country":"United States of America","ISO":"40","Nationality":"American"},{"Code":"UY","Country":"Uruguay","ISO":"127","Nationality":"Uruguayan"},{"Code":"UZ","Country":"Uzbekistan","ISO":"128","Nationality":"Uzbekistani"},{"Code":"VE","Country":"Venezuela","ISO":"49","Nationality":"Venezuelan"},{"Code":"VN","Country":"Vietnam","ISO":"1","Nationality":"Vietnamese"},{"Code":"YE","Country":"Yemen","ISO":"130","Nationality":"Yemeni"},{"Code":"ZA","Country":"South Africa","ISO":"31","Nationality":"South African"},{"Code":"ZM","Country":"Zambia","ISO":"131","Nationality":"Zambian"},{"Code":"ZW","Country":"Zimbabwe","ISO":"132","Nationality":"Zimbabwean"}]')}},e={};function i(n){var r=e[n];if(void 0!==r)return r.exports;var a=e[n]={exports:{}};return t[n].call(a.exports,a,a.exports,i),a.exports}i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i(607)})(); \ No newline at end of file diff --git a/formulaone-card.js.gz b/formulaone-card.js.gz index 9a2bd78..e4967fc 100644 Binary files a/formulaone-card.js.gz and b/formulaone-card.js.gz differ diff --git a/package.json b/package.json index baff108..b928b9f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "formulaone-card", - "version": "0.1.2", + "version": "0.1.3", "description": "Frontend card for hass-formulaoneapi", "main": "index.js", "scripts": { diff --git a/src/cards/driver-standings.ts b/src/cards/driver-standings.ts index 3450701..a0288ef 100644 --- a/src/cards/driver-standings.ts +++ b/src/cards/driver-standings.ts @@ -1,8 +1,9 @@ import { HomeAssistant } from "custom-card-helpers"; import { html, HTMLTemplateResult } from "lit-html"; import { DriverStanding, FormulaOneCardConfig } from "../types/formulaone-card-types"; -import { getDriverName } from "../utils"; +import { getCountryFlagUrl, getDriverName } from "../utils"; import { BaseCard } from "./base-card"; +import * as countries from '../data/countries.json'; export default class DriverStandings extends BaseCard { @@ -10,12 +11,21 @@ export default class DriverStandings extends BaseCard { super(sensor, hass, config); } + getCountryFlag = (nationality: string) => { + console.log(nationality, countries.filter(x => x.Nationality === nationality).length); + const country = countries.filter(x => x.Nationality === nationality)[0].Country; + const countryDashed = country.replace(" ","-"); + + return getCountryFlagUrl(countryDashed); + } + renderStandingRow(standing: DriverStanding): HTMLTemplateResult { return html` - ${standing.position} - ${standing.Driver.code} + ${standing.position} + ${(this.config.standings?.show_flag ? html` ` : '')}${standing.Driver.code} ${getDriverName(standing.Driver, this.config)} + ${(this.config.standings?.show_team ? html`${standing.Constructors[0].name}` : '')} ${standing.points} ${standing.wins} `; @@ -33,7 +43,8 @@ export default class DriverStandings extends BaseCard {   - Driver + Driver + ${(this.config.standings?.show_team ? html`Team` : '')} Pts Wins diff --git a/src/data/countries.json b/src/data/countries.json new file mode 100644 index 0000000..6ae90f4 --- /dev/null +++ b/src/data/countries.json @@ -0,0 +1 @@ +[{"Code":"AD","Country":"Andorra","ISO":"53","Nationality":"Andorian"},{"Code":"AE","Country":"United Arab Emirates","ISO":"126","Nationality":"Emirian"},{"Code":"AF","Country":"Afghanistan","ISO":"133","Nationality":"Afghani"},{"Code":"AI","Country":"Anguilla","ISO":"55","Nationality":"Anguillan"},{"Code":"AM","Country":"Armenia","ISO":"58","Nationality":"Armenian"},{"Code":"AO","Country":"Angola","ISO":"54","Nationality":"Angolian"},{"Code":"AQ","Country":"Antarctica","ISO":"55","Nationality":"Antarctic"},{"Code":"AR","Country":"Argentina","ISO":"57","Nationality":"Argentine"},{"Code":"AS","Country":"Austria","ISO":"3","Nationality":"Austrian"},{"Code":"AU","Country":"Australia","ISO":"2","Nationality":"Australian"},{"Code":"AW","Country":"Aruba","ISO":"59","Nationality":"Arubian"},{"Code":"BA","Country":"Bangladesh","ISO":"45","Nationality":"Bangladeshi"},{"Code":"BB","Country":"Barbados","ISO":"63","Nationality":"Barbadian"},{"Code":"BE","Country":"Belgium","ISO":"4","Nationality":"Belgian"},{"Code":"BH","Country":"Bahrain","ISO":"62","Nationality":"Bahrainian"},{"Code":"BM","Country":"Bermuda","ISO":"67","Nationality":"Bermuda"},{"Code":"BO","Country":"Bolivia","ISO":"69","Nationality":"Bolivian"},{"Code":"BR","Country":"Brazil","ISO":"43","Nationality":"Brazilian"},{"Code":"BS","Country":"Bahamas","ISO":"61","Nationality":"Bahameese"},{"Code":"BT","Country":"Bhutan","ISO":"68","Nationality":"Bhutanese"},{"Code":"BU","Country":"Bulgaria","ISO":"44","Nationality":"Bulgarian"},{"Code":"BY","Country":"Belarus","ISO":"64","Nationality":"Belarusian"},{"Code":"BZ","Country":"Belize","ISO":"65","Nationality":"Belizean"},{"Code":"CA","Country":"Canada","ISO":"6","Nationality":"Canadian"},{"Code":"CG","Country":"Congo","ISO":"72","Nationality":"Congolese"},{"Code":"CH","Country":"China","ISO":"51","Nationality":"Chinese"},{"Code":"CH","Country":"Switzerland","ISO":"35","Nationality":"Swiss"},{"Code":"CL","Country":"Chile","ISO":"71","Nationality":"Chilean"},{"Code":"CM","Country":"Cambodia","ISO":"5","Nationality":"Cambodian"},{"Code":"CM","Country":"Cameroon","ISO":"70","Nationality":"Cameroonian"},{"Code":"CO","Country":"Columbia","ISO":"46","Nationality":"Columbian"},{"Code":"CR","Country":"Czech Republic","ISO":"50","Nationality":"Czech"},{"Code":"CR","Country":"Costa Rica","ISO":"73","Nationality":"Costa Rican"},{"Code":"CU","Country":"Cuba","ISO":"75","Nationality":"Cuban"},{"Code":"CY","Country":"Cyprus","ISO":"76","Nationality":"Cypriot"},{"Code":"DE","Country":"Germany","ISO":"10","Nationality":"German"},{"Code":"DK","Country":"Denmark","ISO":"7","Nationality":"Danish"},{"Code":"DM","Country":"Dominica","ISO":"77","Nationality":"Dominican"},{"Code":"EC","Country":"Ecuador","ISO":"78","Nationality":"Ecuadorean"},{"Code":"EE","Country":"Estonia","ISO":"79","Nationality":"Estonian"},{"Code":"EG","Country":"Egypt","ISO":"8","Nationality":"Egyptian"},{"Code":"ET","Country":"Ethiopia","ISO":"80","Nationality":"Ethiopian"},{"Code":"FI","Country":"Finland","ISO":"82","Nationality":"Finnish"},{"Code":"FJ","Country":"Fiji","ISO":"81","Nationality":"Fijian"},{"Code":"FR","Country":"France","ISO":"9","Nationality":"French"},{"Code":"GB","Country":"United Kingdom","ISO":"39","Nationality":"British"},{"Code":"GE","Country":"Georgia","ISO":"83","Nationality":"Georgian"},{"Code":"GH","Country":"Ghana","ISO":"84","Nationality":"Ghanaian"},{"Code":"GN","Country":"Guinea","ISO":"86","Nationality":"Guinean"},{"Code":"GR","Country":"Greece","ISO":"11","Nationality":"Greek"},{"Code":"GY","Country":"Guyana","ISO":"87","Nationality":"Guyanese"},{"Code":"HK","Country":"Hong Kong","ISO":"13","Nationality":"Chinese"},{"Code":"HR","Country":"Croatia","ISO":"74","Nationality":"Croatian"},{"Code":"HU","Country":"Hungary","ISO":"14","Nationality":"Hungarian"},{"Code":"ID","Country":"Indonesia","ISO":"16","Nationality":"Indonesian"},{"Code":"IE","Country":"Ireland","ISO":"90","Nationality":"Irish"},{"Code":"IN","Country":"India","ISO":"15","Nationality":"Indian"},{"Code":"IQ","Country":"Iraq","ISO":"89","Nationality":"Iraqi"},{"Code":"IR","Country":"Iran","ISO":"17","Nationality":"Iranian"},{"Code":"IS","Country":"Israel","ISO":"18","Nationality":"Israeli"},{"Code":"IS","Country":"Iceland","ISO":"88","Nationality":"Icelander"},{"Code":"IT","Country":"Italy","ISO":"19","Nationality":"Italian"},{"Code":"JM","Country":"Jamaica","ISO":"91","Nationality":"Jamaican"},{"Code":"JO","Country":"Jordan","ISO":"92","Nationality":"Jordanian"},{"Code":"JP","Country":"Japan","ISO":"20","Nationality":"Japanese"},{"Code":"KE","Country":"Kenya","ISO":"94","Nationality":"Kenyan"},{"Code":"KO","Country":"Korea","ISO":"21","Nationality":"Korean"},{"Code":"KW","Country":"Kuwait","ISO":"95","Nationality":"Kuwaiti"},{"Code":"KZ","Country":"Kazakhstan","ISO":"134","Nationality":"Kazakhstani"},{"Code":"KZ","Country":"Kazakhstan","ISO":"93","Nationality":"Kazakhstani"},{"Code":"LB","Country":"Lebanon","ISO":"96","Nationality":"Lebanese"},{"Code":"LK","Country":"Sri Lanka","ISO":"33","Nationality":"Sri Lankan"},{"Code":"LT","Country":"Lithuania","ISO":"97","Nationality":"Lithuanian"},{"Code":"LU","Country":"Luxembourg","ISO":"98","Nationality":"Luxembourger"},{"Code":"MA","Country":"Morocco","ISO":"104","Nationality":"Moroccan"},{"Code":"MC","Country":"Monaco","ISO":"102","Nationality":"Monegasque"},{"Code":"ME","Country":"Mexico","ISO":"47","Nationality":"Mexican"},{"Code":"MM","Country":"Myanmar","ISO":"105","Nationality":"Mayanmarese"},{"Code":"MN","Country":"Mongolia","ISO":"103","Nationality":"Mongolian"},{"Code":"MO","Country":"Macau","ISO":"42","Nationality":"Macau"},{"Code":"MU","Country":"Mauritius","ISO":"100","Nationality":"Mauritian"},{"Code":"MV","Country":"Maldives","ISO":"99","Nationality":"Maldivan"},{"Code":"MY","Country":"Malaysia","ISO":"22","Nationality":"Malaysian"},{"Code":"NA","Country":"Namibia","ISO":"106","Nationality":"Namibian"},{"Code":"NG","Country":"Nigeria","ISO":"108","Nationality":"Nigerian"},{"Code":"NL","Country":"Netherlands","ISO":"12","Nationality":"Dutch"},{"Code":"NO","Country":"Norway","ISO":"24","Nationality":"Norwegian"},{"Code":"NP","Country":"Nepal","ISO":"107","Nationality":"Nepalese"},{"Code":"NZ","Country":"New Zealand","ISO":"23","Nationality":"New Zealander"},{"Code":"OM","Country":"Oman","ISO":"109","Nationality":"Omani"},{"Code":"PA","Country":"Panama","ISO":"110","Nationality":"Panamanian"},{"Code":"PE","Country":"Peru","ISO":"112","Nationality":"Peruvian"},{"Code":"PH","Country":"Philippines","ISO":"27","Nationality":"Filipino"},{"Code":"PK","Country":"Pakistan","ISO":"26","Nationality":"Pakistani"},{"Code":"PO","Country":"Poland","ISO":"28","Nationality":"Polish"},{"Code":"PT","Country":"Portugal","ISO":"113","Nationality":"Portugees"},{"Code":"PY","Country":"Paraguay","ISO":"111","Nationality":"Paraguayan"},{"Code":"QA","Country":"Qatar","ISO":"115","Nationality":"Qatari"},{"Code":"RO","Country":"Romania","ISO":"48","Nationality":"Romanian"},{"Code":"RU","Country":"Russia","ISO":"29","Nationality":"Russian"},{"Code":"SA","Country":"Saudi Arabia","ISO":"116","Nationality":"Saudi Arabian"},{"Code":"SC","Country":"Seychelles","ISO":"119","Nationality":"Seychellois"},{"Code":"SE","Country":"Sweden","ISO":"34","Nationality":"Swedish"},{"Code":"SG","Country":"Singapore","ISO":"30","Nationality":"Singaporean"},{"Code":"SK","Country":"Slovakia","ISO":"120","Nationality":"Slovakian"},{"Code":"SN","Country":"Senegal","ISO":"117","Nationality":"Senegalese"},{"Code":"SO","Country":"Somalia","ISO":"121","Nationality":"Somali"},{"Code":"SP","Country":"Spain","ISO":"32","Nationality":"Spanish"},{"Code":"TH","Country":"Thailand","ISO":"37","Nationality":"Thai"},{"Code":"TN","Country":"Tunisia","ISO":"123","Nationality":"Tunisian"},{"Code":"TR","Country":"Turkey","ISO":"38","Nationality":"Turkish"},{"Code":"TW","Country":"Taiwan","ISO":"36","Nationality":"Taiwanese"},{"Code":"TZ","Country":"Tanzania","ISO":"122","Nationality":"Tanzanian"},{"Code":"UA","Country":"Ukraine","ISO":"125","Nationality":"Ukrainian"},{"Code":"UG","Country":"Uganda","ISO":"124","Nationality":"Ugandan"},{"Code":"US","Country":"United States of America","ISO":"40","Nationality":"American"},{"Code":"UY","Country":"Uruguay","ISO":"127","Nationality":"Uruguayan"},{"Code":"UZ","Country":"Uzbekistan","ISO":"128","Nationality":"Uzbekistani"},{"Code":"VE","Country":"Venezuela","ISO":"49","Nationality":"Venezuelan"},{"Code":"VN","Country":"Vietnam","ISO":"1","Nationality":"Vietnamese"},{"Code":"YE","Country":"Yemen","ISO":"130","Nationality":"Yemeni"},{"Code":"ZA","Country":"South Africa","ISO":"31","Nationality":"South African"},{"Code":"ZM","Country":"Zambia","ISO":"131","Nationality":"Zambian"},{"Code":"ZW","Country":"Zimbabwe","ISO":"132","Nationality":"Zimbabwean"}] \ No newline at end of file diff --git a/src/styles.ts b/src/styles.ts index 53d8645..79fc326 100644 --- a/src/styles.ts +++ b/src/styles.ts @@ -24,7 +24,7 @@ export const style = css` text-align: center; } .width-40 { - width: 50px; + width: 40px; } .width-50 { width: 50px; diff --git a/src/types/formulaone-card-types.ts b/src/types/formulaone-card-types.ts index f0476b9..2af1fab 100644 --- a/src/types/formulaone-card-types.ts +++ b/src/types/formulaone-card-types.ts @@ -12,6 +12,12 @@ export interface FormulaOneCardConfig extends LovelaceCardConfig { show_carnumber?: boolean; location_clickable?: boolean; previous_race?: PreviousRaceDisplay; + standings?: StandingDisplayOptions; +} + +export interface StandingDisplayOptions { + show_team?: boolean; + show_flag?: boolean; } export enum PreviousRaceDisplay { diff --git a/tests/cards/driver-standings.test.ts b/tests/cards/driver-standings.test.ts index dff9131..9f77705 100644 --- a/tests/cards/driver-standings.test.ts +++ b/tests/cards/driver-standings.test.ts @@ -40,6 +40,22 @@ describe('Testing driver-standings file', () => { const result = card.render(); const htmlResult = getRenderString(result); - expect(htmlResult).toMatch('
  Driver Pts Wins
1 VER Max Verstappen 341 11
2 LEC Charles Leclerc 237 3
3 PER Sergio Pérez 235 2
4 RUS George Russell 203 0
5 SAI Carlos Sainz 202 1
6 HAM Lewis Hamilton 170 0
7 NOR Lando Norris 100 0
8 OCO Esteban Ocon 66 0
9 ALO Fernando Alonso 59 0
10 BOT Valtteri Bottas 46 0
11 RIC Daniel Ricciardo 29 0
12 VET Sebastian Vettel 24 0
13 GAS Pierre Gasly 23 0
14 MAG Kevin Magnussen 22 0
15 STR Lance Stroll 13 0
16 MSC Mick Schumacher 12 0
17 TSU Yuki Tsunoda 11 0
18 ZHO Guanyu Zhou 6 0
19 ALB Alexander Albon 4 0
20 DEV Nyck de Vries 2 0
21 LAT Nicholas Latifi 0 0
22 HUL Nico Hülkenberg 0 0
'); + expect(htmlResult).toMatch('
  Driver Pts Wins
1 VER Max Verstappen 341 11
2 LEC Charles Leclerc 237 3
3 PER Sergio Pérez 235 2
4 RUS George Russell 203 0
5 SAI Carlos Sainz 202 1
6 HAM Lewis Hamilton 170 0
7 NOR Lando Norris 100 0
8 OCO Esteban Ocon 66 0
9 ALO Fernando Alonso 59 0
10 BOT Valtteri Bottas 46 0
11 RIC Daniel Ricciardo 29 0
12 VET Sebastian Vettel 24 0
13 GAS Pierre Gasly 23 0
14 MAG Kevin Magnussen 22 0
15 STR Lance Stroll 13 0
16 MSC Mick Schumacher 12 0
17 TSU Yuki Tsunoda 11 0
18 ZHO Guanyu Zhou 6 0
19 ALB Alexander Albon 4 0
20 DEV Nyck de Vries 2 0
21 LAT Nicholas Latifi 0 0
22 HUL Nico Hülkenberg 0 0
'); + }), + test('Calling render with hass and sensor and showing flag and team', () => { + config.standings = { + show_flag: true, + show_team: true + } + hassEntity.attributes['data'] = data as DriverStanding[]; + hass.states = { + 'sensor.test_sensor_drivers': hassEntity + }; + + const card = new DriverStandings('sensor.test_sensor_drivers', hass, config); + const result = card.render(); + const htmlResult = getRenderString(result); + + expect(htmlResult).toMatch('
  Driver Team Pts Wins
1  VER Max Verstappen Red Bull 341 11
2  LEC Charles Leclerc Ferrari 237 3
3  PER Sergio Pérez Red Bull 235 2
4  RUS George Russell Mercedes 203 0
5  SAI Carlos Sainz Ferrari 202 1
6  HAM Lewis Hamilton Mercedes 170 0
7  NOR Lando Norris McLaren 100 0
8  OCO Esteban Ocon Alpine F1 Team 66 0
9  ALO Fernando Alonso Alpine F1 Team 59 0
10  BOT Valtteri Bottas Alfa Romeo 46 0
11  RIC Daniel Ricciardo McLaren 29 0
12  VET Sebastian Vettel Aston Martin 24 0
13  GAS Pierre Gasly AlphaTauri 23 0
14  MAG Kevin Magnussen Haas F1 Team 22 0
15  STR Lance Stroll Aston Martin 13 0
16  MSC Mick Schumacher Haas F1 Team 12 0
17  TSU Yuki Tsunoda AlphaTauri 11 0
18  ZHO Guanyu Zhou Alfa Romeo 6 0
19  ALB Alexander Albon Williams 4 0
20  DEV Nyck de Vries Williams 2 0
21  LAT Nicholas Latifi Williams 0 0
22  HUL Nico Hülkenberg Aston Martin 0 0
'); }) }); \ No newline at end of file