From 8b5c8c3d28ed30fbcc051b87d0d0da999a10c39a Mon Sep 17 00:00:00 2001 From: Elwin Bockstael Date: Mon, 25 Jul 2022 20:52:54 +0200 Subject: [PATCH] #14 - Updated distance calculation --- dist/fr24_card.js | 2 +- src/javascript/helpers/distance.js | 49 +++++++++++++++++++----------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/dist/fr24_card.js b/dist/fr24_card.js index 1ead5d9..37ee975 100644 --- a/dist/fr24_card.js +++ b/dist/fr24_card.js @@ -1 +1 @@ -(()=>{"use strict";class t{constructor(){this.path=this.getPath()}getPath=function(){const t=document.querySelector('script[src*="fr24_card.js"]').getAttribute("src");return t.substring(0,t.lastIndexOf("/")+1)}}class e{constructor(){this.setRanges()}setRanges=function(){this.ranges=[{start:7340032,end:7344127,country:"Afghanistan",iso_3166_1:"AF"},{start:5246976,end:5247999,country:"Albania",iso_3166_1:"AL"},{start:655360,end:688127,country:"Algeria",iso_3166_1:"DZ"},{start:589824,end:593919,country:"Angola",iso_3166_1:"AO"},{start:827392,end:828415,country:"Antigua and Barbuda",iso_3166_1:"AG"},{start:14680064,end:14942207,country:"Argentina",iso_3166_1:"AR"},{start:6291456,end:6292479,country:"Armenia",iso_3166_1:"AM"},{start:8126464,end:8388607,country:"Australia",iso_3166_1:"AU"},{start:4456448,end:4489215,country:"Austria",iso_3166_1:"AT"},{start:6293504,end:6294527,country:"Azerbaijan",iso_3166_1:"AZ"},{start:688128,end:692223,country:"Bahamas",iso_3166_1:"BS"},{start:8994816,end:8998911,country:"Bahrain",iso_3166_1:"BH"},{start:7348224,end:7352319,country:"Bangladesh",iso_3166_1:"BD"},{start:696320,end:697343,country:"Barbados",iso_3166_1:"BB"},{start:5308416,end:5309439,country:"Belarus",iso_3166_1:"BY"},{start:4489216,end:4521983,country:"Belgium",iso_3166_1:"BE"},{start:700416,end:701439,country:"Belize",iso_3166_1:"BZ"},{start:606208,end:607231,country:"Benin",iso_3166_1:"BJ"},{start:6815744,end:6816767,country:"Bhutan",iso_3166_1:"BT"},{start:15286272,end:15290367,country:"Bolivia",iso_3166_1:"BO"},{start:5320704,end:5321727,country:"Bosnia and Herzegovina",iso_3166_1:"BA"},{start:196608,end:197631,country:"Botswana",iso_3166_1:"BW"},{start:14942208,end:15204351,country:"Brazil",iso_3166_1:"BR"},{start:8998912,end:8999935,country:"Brunei Darussalam",iso_3166_1:"BN"},{start:4521984,end:4554751,country:"Bulgaria",iso_3166_1:"BG"},{start:638976,end:643071,country:"Burkina Faso",iso_3166_1:"BF"},{start:204800,end:208895,country:"Burundi",iso_3166_1:"BI"},{start:7397376,end:7401471,country:"Cambodia",iso_3166_1:"KH"},{start:212992,end:217087,country:"Cameroon",iso_3166_1:"CM"},{start:12582912,end:12845055,country:"Canada",iso_3166_1:"CA"},{start:614400,end:615423,country:"Cape Verde",iso_3166_1:"CV"},{start:442368,end:446463,country:"Central African Republic",iso_3166_1:"CF"},{start:540672,end:544767,country:"Chad",iso_3166_1:"TD"},{start:15204352,end:15208447,country:"Chile",iso_3166_1:"CL"},{start:7864320,end:8126463,country:"China",iso_3166_1:"CN"},{start:704512,end:708607,country:"Colombia",iso_3166_1:"CO"},{start:217088,end:218111,country:"Comoros",iso_3166_1:"KM"},{start:221184,end:225279,country:"Congo",iso_3166_1:"CG"},{start:9441280,end:9442303,country:"Cook Islands",iso_3166_1:"CK"},{start:712704,end:716799,country:"Costa Rica",iso_3166_1:"CR"},{start:229376,end:233471,country:"Cote d'Ivoire",iso_3166_1:"CI"},{start:5250048,end:5251071,country:"Croatia",iso_3166_1:"HR"},{start:720896,end:724991,country:"Cuba",iso_3166_1:"CU"},{start:5013504,end:5014527,country:"Cyprus",iso_3166_1:"CY"},{start:4816896,end:4849663,country:"Czech Republic",iso_3166_1:"CZ"},{start:7471104,end:7503871,country:"Democratic People's Republic of Korea",iso_3166_1:"KP"},{start:573440,end:577535,country:"Democratic Republic of the Congo",iso_3166_1:"CD"},{start:4554752,end:4587519,country:"Denmark",iso_3166_1:"DK"},{start:622592,end:623615,country:"Djibouti",iso_3166_1:"DJ"},{start:802816,end:806911,country:"Dominican Republic",iso_3166_1:"DO"},{start:15220736,end:15224831,country:"Ecuador",iso_3166_1:"EC"},{start:65536,end:98303,country:"Egypt",iso_3166_1:"EG"},{start:729088,end:733183,country:"El Salvador",iso_3166_1:"SV"},{start:270336,end:274431,country:"Equatorial Guinea",iso_3166_1:"GQ"},{start:2105344,end:2106367,country:"Eritrea",iso_3166_1:"ER"},{start:5312512,end:5313535,country:"Estonia",iso_3166_1:"EE"},{start:262144,end:266239,country:"Ethiopia",iso_3166_1:"ET"},{start:13139968,end:13144063,country:"Fiji",iso_3166_1:"FJ"},{start:4587520,end:4620287,country:"Finland",iso_3166_1:"FI"},{start:3670016,end:3932159,country:"France",iso_3166_1:"FR"},{start:253952,end:258047,country:"Gabon",iso_3166_1:"GA"},{start:630784,end:634879,country:"Gambia",iso_3166_1:"GM"},{start:5324800,end:5325823,country:"Georgia",iso_3166_1:"GE"},{start:3932160,end:4194303,country:"Germany",iso_3166_1:"DE"},{start:278528,end:282623,country:"Ghana",iso_3166_1:"GH"},{start:4620288,end:4653055,country:"Greece",iso_3166_1:"GR"},{start:835584,end:836607,country:"Grenada",iso_3166_1:"GD"},{start:737280,end:741375,country:"Guatemala",iso_3166_1:"GT"},{start:286720,end:290815,country:"Guinea",iso_3166_1:"GN"},{start:294912,end:295935,country:"Guinea-Bissau",iso_3166_1:"GW"},{start:745472,end:749567,country:"Guyana",iso_3166_1:"GY"},{start:753664,end:757759,country:"Haiti",iso_3166_1:"HT"},{start:761856,end:765951,country:"Honduras",iso_3166_1:"HN"},{start:4653056,end:4685823,country:"Hungary",iso_3166_1:"HU"},{start:5029888,end:5033983,country:"Iceland",iso_3166_1:"IS"},{start:8388608,end:8650751,country:"India",iso_3166_1:"IN"},{start:9043968,end:9076735,country:"Indonesia",iso_3166_1:"ID"},{start:7536640,end:7569407,country:"Iran, Islamic Republic of",iso_3166_1:"IR"},{start:7503872,end:7536639,country:"Iraq",iso_3166_1:"IQ"},{start:5021696,end:5025791,country:"Ireland",iso_3166_1:"IE"},{start:7569408,end:7602175,country:"Israel",iso_3166_1:"IL"},{start:3145728,end:3407871,country:"Italy",iso_3166_1:"IT"},{start:778240,end:782335,country:"Jamaica",iso_3166_1:"JM"},{start:8650752,end:8912895,country:"Japan",iso_3166_1:"JP"},{start:7602176,end:7634943,country:"Jordan",iso_3166_1:"JO"},{start:6828032,end:6829055,country:"Kazakhstan",iso_3166_1:"KZ"},{start:311296,end:315391,country:"Kenya",iso_3166_1:"KE"},{start:13164544,end:13165567,country:"Kiribati",iso_3166_1:"KI"},{start:7364608,end:7368703,country:"Kuwait",iso_3166_1:"KW"},{start:6295552,end:6296575,country:"Kyrgyzstan",iso_3166_1:"KG"},{start:7372800,end:7376895,country:"Lao People's Democratic Republic",iso_3166_1:"LA"},{start:5254144,end:5255167,country:"Latvia",iso_3166_1:"LV"},{start:7634944,end:7667711,country:"Lebanon",iso_3166_1:"LB"},{start:303104,end:304127,country:"Lesotho",iso_3166_1:"LS"},{start:327680,end:331775,country:"Liberia",iso_3166_1:"LR"},{start:98304,end:131071,country:"Libyan Arab Jamahiriya",iso_3166_1:"LY"},{start:5258240,end:5259263,country:"Lithuania",iso_3166_1:"LT"},{start:5046272,end:5047295,country:"Luxembourg",iso_3166_1:"LU"},{start:344064,end:348159,country:"Madagascar",iso_3166_1:"MG"},{start:360448,end:364543,country:"Malawi",iso_3166_1:"MW"},{start:7667712,end:7700479,country:"Malaysia",iso_3166_1:"MY"},{start:368640,end:369663,country:"Maldives",iso_3166_1:"MV"},{start:376832,end:380927,country:"Mali",iso_3166_1:"ML"},{start:5054464,end:5055487,country:"Malta",iso_3166_1:"MT"},{start:9437184,end:9438207,country:"Marshall Islands",iso_3166_1:"MH"},{start:385024,end:386047,country:"Mauritania",iso_3166_1:"MR"},{start:393216,end:394239,country:"Mauritius",iso_3166_1:"MU"},{start:851968,end:884735,country:"Mexico",iso_3166_1:"MX"},{start:6819840,end:6820863,country:"Micronesia, Federated States of",iso_3166_1:"FM"},{start:5062656,end:5063679,country:"Monaco",iso_3166_1:"MC"},{start:6823936,end:6824959,country:"Mongolia",iso_3166_1:"MN"},{start:5332992,end:5334015,country:"Montenegro",iso_3166_1:"ME"},{start:131072,end:163839,country:"Morocco",iso_3166_1:"MA"},{start:24576,end:28671,country:"Mozambique",iso_3166_1:"MZ"},{start:7356416,end:7360511,country:"Myanmar",iso_3166_1:"MM"},{start:2101248,end:2102271,country:"Namibia",iso_3166_1:"NA"},{start:13148160,end:13149183,country:"Nauru",iso_3166_1:"NR"},{start:7380992,end:7385087,country:"Nepal",iso_3166_1:"NP"},{start:4718592,end:4751359,country:"Netherlands, Kingdom of the",iso_3166_1:"NL"},{start:13107200,end:13139967,country:"New Zealand",iso_3166_1:"NZ"},{start:786432,end:790527,country:"Nicaragua",iso_3166_1:"NI"},{start:401408,end:405503,country:"Niger",iso_3166_1:"NE"},{start:409600,end:413695,country:"Nigeria",iso_3166_1:"NG"},{start:4685824,end:4718591,country:"Norway",iso_3166_1:"NO"},{start:7389184,end:7390207,country:"Oman",iso_3166_1:"OM"},{start:7733248,end:7766015,country:"Pakistan",iso_3166_1:"PK"},{start:6832128,end:6833151,country:"Palau",iso_3166_1:"PW"},{start:794624,end:798719,country:"Panama",iso_3166_1:"PA"},{start:9011200,end:9015295,country:"Papua New Guinea",iso_3166_1:"PG"},{start:15237120,end:15241215,country:"Paraguay",iso_3166_1:"PY"},{start:15253504,end:15257599,country:"Peru",iso_3166_1:"PE"},{start:7700480,end:7733247,country:"Philippines",iso_3166_1:"PH"},{start:4751360,end:4784127,country:"Poland",iso_3166_1:"PL"},{start:4784128,end:4816895,country:"Portugal",iso_3166_1:"PT"},{start:434176,end:435199,country:"Qatar",iso_3166_1:"QA"},{start:7438336,end:7471103,country:"Republic of Korea",iso_3166_1:"KR"},{start:5262336,end:5263359,country:"Republic of Moldova",iso_3166_1:"MD"},{start:4849664,end:4882431,country:"Romania",iso_3166_1:"RO"},{start:1048576,end:2097151,country:"Russian Federation",iso_3166_1:"RU"},{start:450560,end:454655,country:"Rwanda",iso_3166_1:"RW"},{start:13156352,end:13157375,country:"Saint Lucia",iso_3166_1:"LC"},{start:770048,end:771071,country:"Saint Vincent and the Grenadines",iso_3166_1:"VC"},{start:9445376,end:9446399,country:"Samoa",iso_3166_1:"WS"},{start:5242880,end:5243903,country:"San Marino",iso_3166_1:"SM"},{start:647168,end:648191,country:"Sao Tome and Principe",iso_3166_1:"ST"},{start:7405568,end:7438335,country:"Saudi Arabia",iso_3166_1:"SA"},{start:458752,end:462847,country:"Senegal",iso_3166_1:"SN"},{start:4980736,end:5013503,country:"Serbia",iso_3166_1:"RS"},{start:475136,end:476159,country:"Seychelles",iso_3166_1:"SC"},{start:483328,end:484351,country:"Sierra Leone",iso_3166_1:"SL"},{start:7766016,end:7798783,country:"Singapore",iso_3166_1:"SG"},{start:5266432,end:5267455,country:"Slovakia",iso_3166_1:"SK"},{start:5270528,end:5271551,country:"Slovenia",iso_3166_1:"SI"},{start:9007104,end:9008127,country:"Solomon Islands",iso_3166_1:"SB"},{start:491520,end:495615,country:"Somalia",iso_3166_1:"SO"},{start:32768,end:65535,country:"South Africa",iso_3166_1:"ZA"},{start:3407872,end:3670015,country:"Spain",iso_3166_1:"ES"},{start:7798784,end:7831551,country:"Sri Lanka",iso_3166_1:"LK"},{start:507904,end:511999,country:"Sudan",iso_3166_1:"SD"},{start:819200,end:823295,country:"Suriname",iso_3166_1:"SR"},{start:499712,end:500735,country:"Swaziland",iso_3166_1:"SZ"},{start:4882432,end:4915199,country:"Sweden",iso_3166_1:"SE"},{start:4915200,end:4947967,country:"Switzerland",iso_3166_1:"CH"},{start:7831552,end:7864319,country:"Syrian Arab Republic",iso_3166_1:"SY"},{start:5328896,end:5329919,country:"Tajikistan",iso_3166_1:"TJ"},{start:8912896,end:8945663,country:"Thailand",iso_3166_1:"TH"},{start:5316608,end:5317631,country:"North Macedonia",iso_3166_1:"MK"},{start:557056,end:561151,country:"Togo",iso_3166_1:"TG"},{start:13160448,end:13161471,country:"Tonga",iso_3166_1:"TO"},{start:811008,end:815103,country:"Trinidad and Tobago",iso_3166_1:"TT"},{start:163840,end:196607,country:"Tunisia",iso_3166_1:"TN"},{start:4947968,end:4980735,country:"Turkey",iso_3166_1:"TR"},{start:6297600,end:6298623,country:"Turkmenistan",iso_3166_1:"TM"},{start:425984,end:430079,country:"Uganda",iso_3166_1:"UG"},{start:5275648,end:5308415,country:"Ukraine",iso_3166_1:"UA"},{start:9003008,end:9007103,country:"United Arab Emirates",iso_3166_1:"AE"},{start:4194304,end:4456447,country:"United Kingdom",iso_3166_1:"GB"},{start:524288,end:528383,country:"United Republic of Tanzania",iso_3166_1:"TZ"},{start:10485760,end:11534335,country:"United States",iso_3166_1:"US"},{start:15269888,end:15273983,country:"Uruguay",iso_3166_1:"UY"},{start:5274624,end:5275647,country:"Uzbekistan",iso_3166_1:"UZ"},{start:13172736,end:13173759,country:"Vanuatu",iso_3166_1:"VU"},{start:884736,end:917503,country:"Venezuela",iso_3166_1:"VE"},{start:8945664,end:8978431,country:"Viet Nam",iso_3166_1:"VN"},{start:8978432,end:8982527,country:"Yemen",iso_3166_1:"YE"},{start:565248,end:569343,country:"Zambia",iso_3166_1:"ZM"},{start:16384,end:17407,country:"Zimbabwe",iso_3166_1:"ZW"},{start:15728640,end:15761407,country:"ICAO (temporary assignments)",iso_3166_1:null},{start:9015296,end:9016319,country:"ICAO (special use)",iso_3166_1:null},{start:15765504,end:15766527,country:"ICAO (special use)",iso_3166_1:null},{start:2097152,end:2621439,country:"Unassigned (AFI region)",iso_3166_1:null},{start:2621440,end:2686975,country:"Unassigned (SAM region)",iso_3166_1:null},{start:5242880,end:6291455,country:"Unassigned (EUR / NAT regions)",iso_3166_1:null},{start:6291456,end:6815743,country:"Unassigned (MID region)",iso_3166_1:null},{start:6815744,end:7340031,country:"Unassigned (ASIA region)",iso_3166_1:null},{start:9437184,end:10485759,country:"Unassigned (NAM / PAC regions)",iso_3166_1:null},{start:11534336,end:12582911,country:"Unassigned (reserved for future use)",iso_3166_1:null},{start:15466496,end:15728639,country:"Unassigned (CAR region)",iso_3166_1:null},{start:13631488,end:14680063,country:"Unassigned (reserved for future use)",iso_3166_1:null},{start:15728640,end:16777215,country:"Unassigned (reserved for future use)",iso_3166_1:null}]};find=function(t){let e=+("0x"+t);for(let t=0;t=this.ranges[t].start&&e<=this.ranges[t].end)return this.ranges[t];return null}}class n{constructor(){this.limitedAlphabet="ABCDEFGHJKLMNPQRSTUVWXYZ",this.fullAlphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ",this.strideMappings=[{start:32785,s1:676,s2:26,prefix:"ZS-"},{start:3735552,s1:1024,s2:32,prefix:"F-G"},{start:3768320,s1:1024,s2:32,prefix:"F-H"},{start:3949601,s1:1024,s2:32,prefix:"D-A",first:"AAA",last:"OZZ"},{start:3932161,s1:676,s2:26,prefix:"D-A",first:"PAA",last:"ZZZ"},{start:3965985,s1:1024,s2:32,prefix:"D-B",first:"AAA",last:"OZZ"},{start:3940353,s1:676,s2:26,prefix:"D-B",first:"PAA",last:"ZZZ"},{start:3981312,s1:676,s2:26,prefix:"D-C"},{start:3998888,s1:676,s2:26,prefix:"D-E"},{start:4016464,s1:676,s2:26,prefix:"D-F"},{start:4034040,s1:676,s2:26,prefix:"D-G"},{start:4051616,s1:676,s2:26,prefix:"D-H"},{start:4069192,s1:676,s2:26,prefix:"D-I"},{start:4490273,s1:1024,s2:32,prefix:"OO-"},{start:4555809,s1:1024,s2:32,prefix:"OY-"},{start:4587520,s1:676,s2:26,prefix:"OH-"},{start:4621345,s1:1024,s2:32,prefix:"SX-"},{start:4785185,s1:1024,s2:32,prefix:"CS-"},{start:4850721,s1:1024,s2:32,prefix:"YR-"},{start:4949025,s1:1024,s2:32,prefix:"TC-"},{start:7603233,s1:1024,s2:32,prefix:"JY-"},{start:7734305,s1:1024,s2:32,prefix:"AP-"},{start:7767073,s1:1024,s2:32,prefix:"9V-"},{start:7832609,s1:1024,s2:32,prefix:"YK-"},{start:8126464,s1:1296,s2:36,prefix:"VH-"},{start:12582913,s1:676,s2:26,prefix:"C-F"},{start:12600489,s1:676,s2:26,prefix:"C-G"},{start:14684225,s1:4096,s2:64,prefix:"LV-"}],this.numericMappings=[{start:1310720,first:0,count:1e5,template:"RA-00000"},{start:721896,first:1e3,count:1e3,template:"CU-T0000"}];for(let t=0;tn.end)continue;let s=t-n.start+n.offset,a=Math.floor(s/n.s1);s%=n.s1;let o=Math.floor(s/n.s2);s%=n.s2;let r=s;if(!(a<0||a>=n.alphabet.length||o<0||o>=n.alphabet.length||r<0||r>=n.alphabet.length))return n.prefix+n.alphabet.charAt(a)+n.alphabet.charAt(o)+n.alphabet.charAt(r)}return null};numericReg=function(t){let e;for(e=0;en.end)continue;let s=t-n.start+n.first+"";return n.template.substring(0,n.template.length-s.length)+s}};nLetters=function(t){return 0==t?"":(--t,this.limitedAlphabet.charAt(Math.floor(t/25))+this.nLetter(t%25))};nLetter=function(t){return 0==t?"":(--t,this.limitedAlphabet.charAt(t))};nReg=function(t){let e=t-10485761;if(e<0||e>=915399)return null;let n="N"+(Math.floor(e/101711)+1);return e%=101711,e<=600?n+this.nLetters(e):(e-=601,n+=Math.floor(e/10111),e%=10111,e<=600?n+this.nLetters(e):(e-=601,n+=Math.floor(e/951),e%=951,e<=600?n+this.nLetters(e):(e-=601,n+=Math.floor(e/35).toFixed(0),e%=35,e<=24?n+this.nLetter(e):(e-=25,n+e.toFixed(0)))))};hlReg=function(t){return t>=7453184&&t<=7454617?"HL"+(t-7453184+29184).toString(16):t>=7454720&&t<=7454873?"HL"+(t-7454720+32768).toString(16):t>=7455232&&t<=7455385?"HL"+(t-7455232+33280).toString(16):null};jaReg=function(t){let e=t-8650752;if(e<0||e>=229840)return null;let n="JA",s=Math.floor(e/22984);if(s<0||s>9)return null;n+=s,e%=22984;let a=Math.floor(e/916);if(a<0||a>9)return null;if(n+=a,e%=916,e<340){return n+=Math.floor(e/34),e%=34,e<10?n+e:(e-=10,n+this.limitedAlphabet.charAt(e))}e-=340;let o=Math.floor(e/24);return n+this.limitedAlphabet.charAt(o)+this.limitedAlphabet.charAt(e%24)}}class s{constructor(){this.country=new e,this.registration=new n}}var a,o;!function(t){t.language="language",t.system="system",t.comma_decimal="comma_decimal",t.decimal_comma="decimal_comma",t.space_comma="space_comma",t.none="none"}(a||(a={})),function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(o||(o={}));function r(){return(r=Object.assign||function(t){for(var e=1;e-1?t.split(".")[1].length:0;n.minimumFractionDigits=s,n.maximumFractionDigits=s}return n},u=["closed","locked","off"],d=(new Set(["fan","input_boolean","light","switch","group","automation"]),function(t,e,n,s){s=s||{},n=null==n?{}:n;var a=new Event(e,{bubbles:void 0===s.bubbles||s.bubbles,cancelable:Boolean(s.cancelable),composed:void 0===s.composed||s.composed});return a.detail=n,t.dispatchEvent(a),a});new Set(["call-service","divider","section","weblink","cast","select"]);var h=function(t){d(window,"haptic",t)},_=function(t,e,n){void 0===n&&(n=!1),n?history.replaceState(null,"",e):history.pushState(null,"",e),d(window,"location-changed",{replace:n})},p=function(t,e){return function(t,e,n){void 0===n&&(n=!0);var s,a=i(e),o="group"===a?"homeassistant":a;switch(a){case"lock":s=n?"unlock":"lock";break;case"cover":s=n?"open_cover":"close_cover";break;default:s=n?"turn_on":"turn_off"}return t.callService(o,s,{entity_id:e})}(t,e,u.includes(t.states[e].state))},g=function(t,e,n,s,a){var o;if(a&&n.double_tap_action?o=n.double_tap_action:s&&n.hold_action?o=n.hold_action:!s&&n.tap_action&&(o=n.tap_action),o||(o={action:"more-info"}),!o.confirmation||o.confirmation.exemptions&&o.confirmation.exemptions.some((function(t){return t.user===e.user.id}))||confirm(o.confirmation.text||"Are you sure you want to "+o.action+"?"))switch(o.action){case"more-info":(o.entity||n.entity||n.camera_image)&&(d(t,"hass-more-info",{entityId:o.entity?o.entity:n.entity?n.entity:n.camera_image}),o.haptic&&h(o.haptic));break;case"navigate":o.navigation_path&&(_(0,o.navigation_path),o.haptic&&h(o.haptic));break;case"url":o.url_path&&window.open(o.url_path),o.haptic&&h(o.haptic);break;case"toggle":n.entity&&(p(e,n.entity),o.haptic&&h(o.haptic));break;case"call-service":if(!o.service)return;var i=o.service.split(".",2),c=i[0],l=i[1],u=r({},o.service_data);"entity"===u.entity_id&&(u.entity_id=n.entity),e.callService(c,l,u,o.target),o.haptic&&h(o.haptic);break;case"fire-dom-event":d(t,"ll-custom",o),o.haptic&&h(o.haptic)}};class f{constructor(e,n,a,o){this.config=n,this.lang=o;const r=new t;this._path=r.getPath(),this.hex=e.hex.toUpperCase(),this.icon="mdi:airplane",this.flight=e.flight??null,this.squawk=e.squawk??null,this.altitude=e.altitude??e.alt_baro??null,this.speed=e.speed??e.gs??null,this.track=e.track??null,this.vert_rate=e.vert_rate??e.baro_rate??null,this.lat=e.lat??null,this.lon=e.lon??null,this.seen=e.seen??100;const i=new s,c=i.country.find(this.hex),l=i.registration.lookup(this.hex);this.flag=null!==c&&null!==c.iso_3166_1?`${this._path}images/flags/${c.iso_3166_1.toLowerCase()}.svg`:null,this.country=null!==c?c.country:null,this.registration=l,this.distance=a.isSetUp()?a.calculate(this.lat,this.lon):null,this.setIcon(),this.setUnits()}setIcon=function(){this.vert_rate<0?this.icon="mdi:airplane-landing":this.vert_rate>0&&(this.icon="mdi:airplane-takeoff")};setUnits=function(){if("metric"===this.config.units)!0===this.config.larger_units?this.units={altitude:"km",distance:"km",speed:"km/h"}:this.units={altitude:"m",distance:"m",speed:"m/s"},this.units.age="s",!0!==this.config.track_in_text&&(this.units.track="°");else this.units={altitude:"ft",distance:"NM",speed:"kt",track:"°",age:"s"},!0!==this.config.track_in_text&&(this.units.track="°")};value=function(t,e){let n=this,s=this.units[t]??null;switch(t){case"icon":return e?``:``;case"flag":return null!==n.flag?`${n.country}`:"";case"icao":return n.hex;case"age":let a=n.seen??"";return""!==a&&e&&(a+=" "+s),a;case"speed":let o=n.speed??"";if(""!==o){if("metric"===this.config.units)o=this.config.larger_units?c(Math.round(1.852*o)):c(Math.round(.514444444*o));o=c(o),e&&(o+=" "+s)}return o;case"altitude":let r=n.altitude??"";if(""!==r){if("metric"===this.config.units)r=this.config.larger_units?Math.round(.3048*r/1e3*10)/10:Math.round(.3048*r);r=c(r),e&&(r+=" "+s)}return r;case"track":let i=n.track??"";return""!==i&&(!0===this.config.track_in_text?i=this.trackAsText(i,e):e&&(i+=""+s)),i;case"registration":return null===n.registration?this.lang.content.table.data.not_available:n.registration;default:let l=n[t]??"";return""!==l&&"number"==typeof l&&(l=c(l)),e&&""!==l&&null!==s&&(l+=" "+s),l}};trackAsText=function(t,e){let n="n";return t>=11.25&&t<=33.75?n="nne":t>=33.75&&t<=56.25?n="ne":t>=56.25&&t<=78.75?n="ene":t>=78.75&&t<=101.25?n="e":t>=101.25&&t<=123.75?n="ese":t>=123.75&&t<=146.25?n="se":t>=146.25&&t<=168.75?n="sse":t>=168.75&&t<=191.25?n="s":t>=191.25&&t<=213.75?n="ssw":t>=213.75&&t<=236.25?n="sw":t>=236.25&&t<=258.75?n="wsw":t>=258.75&&t<=281.25?n="w":t>=281.25&&t<=303.75?n="wnw":t>=303.75&&t<=326.25?n="nw":t>=326.25&&t<=348.75&&(n="nnw"),e?this.lang.content.track.long[n]:this.lang.content.track.short[n]}}class y{constructor(t,e){this.config=t,this.zone=t.zone,this.units=t.units,this.hass=e,null!==this.zone&&this.getCoordinatesOfZone()}isSetUp=function(){return this.hasOwnProperty("lat")&&this.hasOwnProperty("lon")};getCoordinatesOfZone=function(){let t=this.hass.states[this.zone];void 0!==t&&(this.lat=t.attributes.latitude,this.lon=t.attributes.longitude)};deg2rad=function(t){return t*(Math.PI/180)};calculate=function(t,e){if(null===t||null===e)return"";let n=this.deg2rad(t-this.lat),s=this.deg2rad(e-this.lon),a=Math.sin(n/2)*Math.sin(n/2)+Math.cos(this.deg2rad(this.lat))*Math.cos(this.deg2rad(this.lon))*Math.sin(s/2)*Math.sin(s/2),o=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a)),r=Math.round(6371e3*o);switch(this.units){case"metric":this.config.larger_units&&(r=Math.round(r/1e3*10)/10);break;case"default":r=Math.round(.000539956803*r*10)/10}return r}}const m=JSON.parse('{"icon":{"styles":["width-s"],"weight":1,"popup":false},"icao":{"weight":2,"popup":true},"flag":{"styles":["width-s"],"weight":1,"popup":false},"country":{"weight":4,"popup":true},"registration":{"weight":4,"popup":true},"flight":{"weight":2,"popup":true},"squawk":{"weight":2,"popup":true},"altitude":{"styles":["align-right"],"weight":2,"popup":true},"speed":{"styles":["align-right"],"weight":2,"popup":true},"distance":{"styles":["align-right"],"weight":2,"popup":true},"track":{"styles":["align-right"],"weight":2,"popup":true},"age":{"styles":["align-right"],"weight":3,"popup":true}}');class b{constructor(t,e,n,s,a){this.element=t,this.hass=e,this.config=n,this.lang=s,this.aircrafts=a,this.addEventListeners()}addEventListeners=function(){const t=this;let e=this.element.querySelectorAll("tr[data-hex]");for(let n=0;n{t.hex===n&&(a=t)})),null!==a&&fetch("https://api.planespotters.net/pub/photos/hex/"+a.hex,{cache:"no-store",headers:{"Content-Type":"text/json"}}).then((t=>t.text())).then((function(e){let n=JSON.parse(e),o="";if(n.photos.length>0){let t=n.photos[0].thumbnail_large.src,e=n.photos[0].link,s=n.photos[0].photographer;o+=`![Image](${t})\n`,o+=`© [${s}](${e})\n\n`}o+="## ",a.flag&&(o+=``),o+=`${a.registration||a.flight||a.hex}${a.value("icon",!0)}\n`,o+=`|${t.lang.content.popup.table.head.property}|${t.lang.content.popup.table.head.value}|\n|:-|-:|\n`,Object.keys(m).forEach((e=>{let n=m[e],s=a.value(e,!0);n.popup&&""!==s&&(o+=`|${t.lang.content.table.head[e]}|${s}|\n`)})),g(s,t.hass,{tap_action:{action:"fire-dom-event",browser_mod:{command:"popup",hide_header:!0,card:{type:"markdown",content:o,card_mod:{style:{".":`\n ha-markdown{\n background:${t.config.colors.popup_bg??"var(--card-background-color)"};\n }`,"ha-markdown$":`\n font {\n color: ${t.config.colors.popup_text??t.config.colors.table_text??"var(--primary-text-color)"};\n }\n font a{\n color:${t.config.colors.popup_text??t.config.colors.table_text??"var(--primary-color)"};\n }\n h2{\n display:flex;\n justify-content:space-between;\n color:${t.config.colors.popup_text??t.config.colors.table_text??"var(--primary-text-color)"};\n }\n h2 img{\n height:.8em;\n margin:0 10px 0 0;\n display:inline-block;\n vertical-align:baseline;\n }\n table{\n width:100%;\n border-spacing:0;\n border-collapse:collapse;\n }\n table tr th, table tr td{\n padding:4px;\n }\n table tr th{\n background-color:${t.config.colors.popup_table_head_bg??t.config.colors.table_head_bg??"var(--primary-color)"};\n color:${t.config.colors.popup_table_head_text??t.config.colors.table_head_text??"var(--app-header-text-color, white)"};\n }\n table tr{\n color:${t.config.colors.popup_text??t.config.colors.table_text??"var(--primary-text-color)"};\n }\n table tr:nth-child(even){\n background-color:${t.config.colors.popup_table_even_row_bg??t.config.colors.table_even_row_bg??"var(--primary-background-color)"};\n color:${t.config.colors.popup_table_even_row_text??t.config.colors.table_even_row_text??"var(--primary-text-color)"};\n }`}}}}}})}))}))}}}const w=JSON.parse('{"table":{"head":{"icao":"ICAO Code","country":"Land","registration":"Registration","flight":"Flug","squawk":"Squawk","altitude":"Höhe","speed":"Geschwindigkeit","distance":"Entfernung","track":"Pfad","age":"Letzte Nachricht"},"data":{"not_available":"N/V"}},"popup":{"table":{"head":{"property":"Eigenschaft","value":"Wert"}}},"track":{"short":{"n":"N","nne":"NNO","ne":"NO","ene":"ONO","e":"O","ese":"OSO","se":"SO","sse":"SSO","s":"S","ssw":"SSW","sw":"SW","wsw":"WSW","w":"W","wnw":"WNW","nw":"NW","nnw":"NNW"},"long":{"n":"Nord","nne":"Nord-Nord-Ost","ne":"Nord-Ost","ene":"Ost-Nord-Ost","e":"Ost","ese":"Ost-Süd-Ost","se":"Süd-Ost","sse":"Süd-Süd-Ost","s":"Süd","ssw":"Süd-Süd-West","sw":"Süd-West","wsw":"West-Süd-West","w":"West","wnw":"West-Nord-West","nw":"Nord-West","nnw":"Nord-Nord-West"}}}'),v=JSON.parse('{"table":{"head":{"icao":"ICAO Code","country":"Country","registration":"Registration","flight":"Flight","squawk":"Squawk","altitude":"Altitude","speed":"Speed","distance":"Distance","track":"Track","age":"Last message"},"data":{"not_available":"N/A"}},"popup":{"table":{"head":{"property":"Property","value":"Value"}}},"track":{"short":{"n":"N","nne":"NNE","ne":"NE","ene":"ENE","e":"E","ese":"ESE","se":"SE","sse":"SSE","s":"S","ssw":"SSW","sw":"SW","wsw":"WSW","w":"W","wnw":"WNW","nw":"NW","nnw":"NNW"},"long":{"n":"North","nne":"North-northeast","ne":"Northeast","ene":"East-northeast","e":"East","ese":"East-southeast","se":"Southeast","sse":"South-southeast","s":"South","ssw":"South-southwest","sw":"Southwest","wsw":"West-southwest","w":"West","wnw":"West-northwest","nw":"Northwest","nnw":"North-northwest"}}}'),S=JSON.parse('{"table":{"head":{"icao":"ICAO code","country":"Land","registration":"Registratie","flight":"Vlucht","squawk":"Squawk","altitude":"Hoogte","speed":"Snelheid","distance":"Afstand","track":"Richting","age":"Laatste bericht"},"data":{"not_available":"Nb"}},"popup":{"table":{"head":{"property":"Eigenschap","value":"Waarde"}}},"track":{"short":{"n":"N","nne":"NNO","ne":"NO","ene":"ONO","e":"O","ese":"OZO","se":"ZO","sse":"ZZO","s":"Z","ssw":"ZZW","sw":"ZW","wsw":"WZW","w":"W","wnw":"WNW","nw":"NW","nnw":"NNW"},"long":{"n":"Noord","nne":"Noordnoordoost","ne":"Noordoost","ene":"Oostnoordoost","e":"Oost","ese":"Oostzuidoost","se":"Zuidoost","sse":"Zuidzuidoost","s":"Zuid","ssw":"Zuidzuidwest","sw":"Zuidwest","wsw":"Westzuidwest","w":"West","wnw":"Westnoordwest","nw":"Noordwest","nnw":"Noordnoordwest"}}}'),A=JSON.parse('{"table":{"head":{"icao":"ICAO naslov","country":"Država","registration":"Registracija","flight":"Št. leta","squawk":"Squawk","altitude":"Višina","speed":"Hitrost","distance":"Razdalja","track":"Smer","age":"Zaznano pred"},"data":{"not_available":"N/A"}},"popup":{"table":{"head":{"property":"Karakteristika","value":"Vrednost"}}},"track":{"short":{"n":"S","nne":"SSV","ne":"SV","ene":"VSV","e":"V","ese":"VJV","se":"JV","sse":"JJV","s":"J","ssw":"JJZ","sw":"JZ","wsw":"ZJZ","w":"Z","wnw":"ZSZ","nw":"SZ","nnw":"SSZ"},"long":{"n":"sever","nne":"sever-severovzhod","ne":"severovzhod","ene":"vzhod-severovzhod","e":"vzhod","ese":"vzhod-jugovzhod","se":"jugovzhod","sse":"jug-jugovzhod","s":"jug","ssw":"jug-jugozahod","sw":"jugozahod","wsw":"zahod-jugozahod","w":"zahod","wnw":"zahod-severozahod","nw":"severozahod","nnw":"sever-severozahod"}}}');class x{constructor(t,e){this.config=t,this.hass=e,this.content=v,this.setLang()}setLang=function(){if(null===this.config.lang&&(this.config.lang=this.hass.language),"en"!==this.config.lang)switch(this.config.lang){case"de":this.content=w;break;case"nl":this.content=S;break;case"sl":this.content=A}}}class N{constructor(){this.element=document.createElement("tr")}addCells=function(t=[]){for(let e=0;e0&&s.addAttributes(n),s.addCells(t),e){case"thead":this.thead.appendChild(s.element),this.hasRowsInHead=!0;break;case"tfoot":this.tfoot.appendChild(s.element),this.hasRowsInFoot=!0;break;default:this.tbody.appendChild(s.element),this.hasRowsInBody=!0}};cell=function(t,e=null,n="td",s=null){let a=new M(n);return a.setValue(t),null!=e&&"object"==typeof e&&a.setClasses(e),"object"==typeof s&&null!==s&&Object.keys(s).length>0&&a.addAttributes(s),a}}window.customCards=window.customCards||[],window.customCards.push({type:"fr24-card",name:"Flight Radar card",description:"Card that shows the tracked flights",preview:!1}),window.fr24db=[];class C extends HTMLElement{set hass(t){this._hass=t,this._config&&(this._distance=new y(this._config,this._hass),this._lang=new x(this._config,this._hass),this._parseAircrafts(),this._renderTable())}setConfig(e){const n=new t;this._path=n.getPath(),this._availableColumns=m;const s={attribute:"aircraft",columns:["flag","registration","flight","altitude","speed","distance","track"],hide:{old_messages:!0,empty:[]},lang:null,larger_units:!1,limit:null,order:"asc",popup:!1,sort:"altitude",track_in_text:!1,units:"default",units_in_table:!1,zone:null,colors:{table_head_bg:null,table_head_text:null,table_units_bg:null,table_units_text:null,table_text:null,table_even_row_bg:null,table_even_row_text:null,popup_bg:null,popup_text:null,popup_table_head_bg:null,popup_table_head_text:null,popup_table_even_row_bg:null,popup_table_even_row_text:null}},a={...s.hide,...e.hide},o={...s.colors,...e.colors};if(this._config={...s,...e},this._config.hide=a,this._config.colors=o,!e.entity)throw new Error("You need to define an entity");let r=0;if(this._config.columns.forEach((t=>{if(!this._availableColumns.hasOwnProperty(t))throw new Error("Column '"+t+"' does not exist");r+=this._availableColumns[t].weight})),r>15)throw new Error("Too many columns defined");if(!["default","metric"].includes(this._config.units))throw new Error("Unit '"+this._config.units+"' not supported");if(!["asc","desc"].includes(this._config.order))throw new Error("Order '"+this._config.order+"' not supported");if(!this.setupComplete){this.card=document.createElement("ha-card"),this.contentDiv=document.createElement("div"),this.contentDiv.setAttribute("class","card-content"),this.card.appendChild(this.contentDiv),this.appendChild(this.card);const t=document.createElement("link");if(t.setAttribute("type","text/css"),t.setAttribute("rel","stylesheet"),t.setAttribute("href",this._path+"fr24_card.css"),this.card.appendChild(t),0===window.fr24db.length){const t=document.createElement("script");t.setAttribute("async",""),t.setAttribute("type","text/javascript"),t.setAttribute("src",this._path+"fr24_database.js"),document.head.appendChild(t)}this.setupComplete=!0}this.card.setAttribute("header",e.title??"")}getCardSize(){return Number.isInteger(this._config.limit)?this._config.limit+5:100}static getStubConfig(){return{entity:"sensor.fr24_aircraft"}}_parseAircrafts(){const t=this;this._aircrafts=[];const e=this._hass.states[this._config.entity].attributes[this._config.attribute];this._availableColumns.distance.show=!0,!1===this._distance.isSetUp()&&(this._availableColumns.distance.show=!1),e.forEach((t=>{let e=new f(t,this._config,this._distance,this._lang),n=!0;if(!1!==this._config.hide.old_messages&&e.seen>30)n=!1;else if(this._config.hide.empty.length>0)for(let t=0;t{let n=this._availableColumns[e];if(!1===n.show)return;let a=this._lang.content.table.head[e]??"",o=n.styles??null,r="";null!==this._config.colors.table_head_bg&&(r+="background-color:"+this._config.colors.table_head_bg+" !important;"),null!==this._config.colors.table_head_text&&(r+="color:"+this._config.colors.table_head_text+" !important;");let i=[];r.length>0&&(i.style=r);let c=t.cell(a,o,"th",i);s.push(c)})),t.row(s,"thead");let a=0;for(let s of this._aircrafts){if(e&&!n){n=!0;let e=[];this._config.columns.forEach((n=>{let a=this._availableColumns[n];if(!1===a.show)return;let o=s.units[n]??"",r=a.styles??null,i="";null!==this._config.colors.table_units_bg&&(i+="background-color:"+this._config.colors.table_units_bg+" !important;"),null!==this._config.colors.table_units_text&&(i+="color:"+this._config.colors.table_units_text+" !important;");let c=[];i.length>0&&(c.style=i);let l=t.cell(o,r,"td",c);e.push(l)})),t.row(e,"thead")}let o=[];this._config.columns.forEach((e=>{let n=this._availableColumns[e];if(!1===n.show)return;let r="";a%2==1?(null!==this._config.colors.table_even_row_bg&&(r+="background-color:"+this._config.colors.table_even_row_bg+" !important;"),null!==this._config.colors.table_even_row_text&&(r+="color:"+this._config.colors.table_even_row_text+" !important;")):null!==this._config.colors.table_text&&(r+="color:"+this._config.colors.table_text+" !important;");let i=[];r.length>0&&(i.style=r);let c=t.cell(s.value(e),n.styles??null,"td",i);o.push(c)}));let r=[];if(this._config.popup&&(r["data-hex"]=s.hex),t.row(o,null,r),a++,Number.isInteger(this._config.limit)&&this._config.limit===a)break}if(this.contentDiv.innerHTML=t.getHtml(),this._config.popup){new b(this.contentDiv,this._hass,this._config,this._lang,this._aircrafts)}}}customElements.define("fr24-card",C)})(); \ No newline at end of file +(()=>{"use strict";class t{constructor(){this.path=this.getPath()}getPath=function(){const t=document.querySelector('script[src*="fr24_card.js"]').getAttribute("src");return t.substring(0,t.lastIndexOf("/")+1)}}class e{constructor(){this.setRanges()}setRanges=function(){this.ranges=[{start:7340032,end:7344127,country:"Afghanistan",iso_3166_1:"AF"},{start:5246976,end:5247999,country:"Albania",iso_3166_1:"AL"},{start:655360,end:688127,country:"Algeria",iso_3166_1:"DZ"},{start:589824,end:593919,country:"Angola",iso_3166_1:"AO"},{start:827392,end:828415,country:"Antigua and Barbuda",iso_3166_1:"AG"},{start:14680064,end:14942207,country:"Argentina",iso_3166_1:"AR"},{start:6291456,end:6292479,country:"Armenia",iso_3166_1:"AM"},{start:8126464,end:8388607,country:"Australia",iso_3166_1:"AU"},{start:4456448,end:4489215,country:"Austria",iso_3166_1:"AT"},{start:6293504,end:6294527,country:"Azerbaijan",iso_3166_1:"AZ"},{start:688128,end:692223,country:"Bahamas",iso_3166_1:"BS"},{start:8994816,end:8998911,country:"Bahrain",iso_3166_1:"BH"},{start:7348224,end:7352319,country:"Bangladesh",iso_3166_1:"BD"},{start:696320,end:697343,country:"Barbados",iso_3166_1:"BB"},{start:5308416,end:5309439,country:"Belarus",iso_3166_1:"BY"},{start:4489216,end:4521983,country:"Belgium",iso_3166_1:"BE"},{start:700416,end:701439,country:"Belize",iso_3166_1:"BZ"},{start:606208,end:607231,country:"Benin",iso_3166_1:"BJ"},{start:6815744,end:6816767,country:"Bhutan",iso_3166_1:"BT"},{start:15286272,end:15290367,country:"Bolivia",iso_3166_1:"BO"},{start:5320704,end:5321727,country:"Bosnia and Herzegovina",iso_3166_1:"BA"},{start:196608,end:197631,country:"Botswana",iso_3166_1:"BW"},{start:14942208,end:15204351,country:"Brazil",iso_3166_1:"BR"},{start:8998912,end:8999935,country:"Brunei Darussalam",iso_3166_1:"BN"},{start:4521984,end:4554751,country:"Bulgaria",iso_3166_1:"BG"},{start:638976,end:643071,country:"Burkina Faso",iso_3166_1:"BF"},{start:204800,end:208895,country:"Burundi",iso_3166_1:"BI"},{start:7397376,end:7401471,country:"Cambodia",iso_3166_1:"KH"},{start:212992,end:217087,country:"Cameroon",iso_3166_1:"CM"},{start:12582912,end:12845055,country:"Canada",iso_3166_1:"CA"},{start:614400,end:615423,country:"Cape Verde",iso_3166_1:"CV"},{start:442368,end:446463,country:"Central African Republic",iso_3166_1:"CF"},{start:540672,end:544767,country:"Chad",iso_3166_1:"TD"},{start:15204352,end:15208447,country:"Chile",iso_3166_1:"CL"},{start:7864320,end:8126463,country:"China",iso_3166_1:"CN"},{start:704512,end:708607,country:"Colombia",iso_3166_1:"CO"},{start:217088,end:218111,country:"Comoros",iso_3166_1:"KM"},{start:221184,end:225279,country:"Congo",iso_3166_1:"CG"},{start:9441280,end:9442303,country:"Cook Islands",iso_3166_1:"CK"},{start:712704,end:716799,country:"Costa Rica",iso_3166_1:"CR"},{start:229376,end:233471,country:"Cote d'Ivoire",iso_3166_1:"CI"},{start:5250048,end:5251071,country:"Croatia",iso_3166_1:"HR"},{start:720896,end:724991,country:"Cuba",iso_3166_1:"CU"},{start:5013504,end:5014527,country:"Cyprus",iso_3166_1:"CY"},{start:4816896,end:4849663,country:"Czech Republic",iso_3166_1:"CZ"},{start:7471104,end:7503871,country:"Democratic People's Republic of Korea",iso_3166_1:"KP"},{start:573440,end:577535,country:"Democratic Republic of the Congo",iso_3166_1:"CD"},{start:4554752,end:4587519,country:"Denmark",iso_3166_1:"DK"},{start:622592,end:623615,country:"Djibouti",iso_3166_1:"DJ"},{start:802816,end:806911,country:"Dominican Republic",iso_3166_1:"DO"},{start:15220736,end:15224831,country:"Ecuador",iso_3166_1:"EC"},{start:65536,end:98303,country:"Egypt",iso_3166_1:"EG"},{start:729088,end:733183,country:"El Salvador",iso_3166_1:"SV"},{start:270336,end:274431,country:"Equatorial Guinea",iso_3166_1:"GQ"},{start:2105344,end:2106367,country:"Eritrea",iso_3166_1:"ER"},{start:5312512,end:5313535,country:"Estonia",iso_3166_1:"EE"},{start:262144,end:266239,country:"Ethiopia",iso_3166_1:"ET"},{start:13139968,end:13144063,country:"Fiji",iso_3166_1:"FJ"},{start:4587520,end:4620287,country:"Finland",iso_3166_1:"FI"},{start:3670016,end:3932159,country:"France",iso_3166_1:"FR"},{start:253952,end:258047,country:"Gabon",iso_3166_1:"GA"},{start:630784,end:634879,country:"Gambia",iso_3166_1:"GM"},{start:5324800,end:5325823,country:"Georgia",iso_3166_1:"GE"},{start:3932160,end:4194303,country:"Germany",iso_3166_1:"DE"},{start:278528,end:282623,country:"Ghana",iso_3166_1:"GH"},{start:4620288,end:4653055,country:"Greece",iso_3166_1:"GR"},{start:835584,end:836607,country:"Grenada",iso_3166_1:"GD"},{start:737280,end:741375,country:"Guatemala",iso_3166_1:"GT"},{start:286720,end:290815,country:"Guinea",iso_3166_1:"GN"},{start:294912,end:295935,country:"Guinea-Bissau",iso_3166_1:"GW"},{start:745472,end:749567,country:"Guyana",iso_3166_1:"GY"},{start:753664,end:757759,country:"Haiti",iso_3166_1:"HT"},{start:761856,end:765951,country:"Honduras",iso_3166_1:"HN"},{start:4653056,end:4685823,country:"Hungary",iso_3166_1:"HU"},{start:5029888,end:5033983,country:"Iceland",iso_3166_1:"IS"},{start:8388608,end:8650751,country:"India",iso_3166_1:"IN"},{start:9043968,end:9076735,country:"Indonesia",iso_3166_1:"ID"},{start:7536640,end:7569407,country:"Iran, Islamic Republic of",iso_3166_1:"IR"},{start:7503872,end:7536639,country:"Iraq",iso_3166_1:"IQ"},{start:5021696,end:5025791,country:"Ireland",iso_3166_1:"IE"},{start:7569408,end:7602175,country:"Israel",iso_3166_1:"IL"},{start:3145728,end:3407871,country:"Italy",iso_3166_1:"IT"},{start:778240,end:782335,country:"Jamaica",iso_3166_1:"JM"},{start:8650752,end:8912895,country:"Japan",iso_3166_1:"JP"},{start:7602176,end:7634943,country:"Jordan",iso_3166_1:"JO"},{start:6828032,end:6829055,country:"Kazakhstan",iso_3166_1:"KZ"},{start:311296,end:315391,country:"Kenya",iso_3166_1:"KE"},{start:13164544,end:13165567,country:"Kiribati",iso_3166_1:"KI"},{start:7364608,end:7368703,country:"Kuwait",iso_3166_1:"KW"},{start:6295552,end:6296575,country:"Kyrgyzstan",iso_3166_1:"KG"},{start:7372800,end:7376895,country:"Lao People's Democratic Republic",iso_3166_1:"LA"},{start:5254144,end:5255167,country:"Latvia",iso_3166_1:"LV"},{start:7634944,end:7667711,country:"Lebanon",iso_3166_1:"LB"},{start:303104,end:304127,country:"Lesotho",iso_3166_1:"LS"},{start:327680,end:331775,country:"Liberia",iso_3166_1:"LR"},{start:98304,end:131071,country:"Libyan Arab Jamahiriya",iso_3166_1:"LY"},{start:5258240,end:5259263,country:"Lithuania",iso_3166_1:"LT"},{start:5046272,end:5047295,country:"Luxembourg",iso_3166_1:"LU"},{start:344064,end:348159,country:"Madagascar",iso_3166_1:"MG"},{start:360448,end:364543,country:"Malawi",iso_3166_1:"MW"},{start:7667712,end:7700479,country:"Malaysia",iso_3166_1:"MY"},{start:368640,end:369663,country:"Maldives",iso_3166_1:"MV"},{start:376832,end:380927,country:"Mali",iso_3166_1:"ML"},{start:5054464,end:5055487,country:"Malta",iso_3166_1:"MT"},{start:9437184,end:9438207,country:"Marshall Islands",iso_3166_1:"MH"},{start:385024,end:386047,country:"Mauritania",iso_3166_1:"MR"},{start:393216,end:394239,country:"Mauritius",iso_3166_1:"MU"},{start:851968,end:884735,country:"Mexico",iso_3166_1:"MX"},{start:6819840,end:6820863,country:"Micronesia, Federated States of",iso_3166_1:"FM"},{start:5062656,end:5063679,country:"Monaco",iso_3166_1:"MC"},{start:6823936,end:6824959,country:"Mongolia",iso_3166_1:"MN"},{start:5332992,end:5334015,country:"Montenegro",iso_3166_1:"ME"},{start:131072,end:163839,country:"Morocco",iso_3166_1:"MA"},{start:24576,end:28671,country:"Mozambique",iso_3166_1:"MZ"},{start:7356416,end:7360511,country:"Myanmar",iso_3166_1:"MM"},{start:2101248,end:2102271,country:"Namibia",iso_3166_1:"NA"},{start:13148160,end:13149183,country:"Nauru",iso_3166_1:"NR"},{start:7380992,end:7385087,country:"Nepal",iso_3166_1:"NP"},{start:4718592,end:4751359,country:"Netherlands, Kingdom of the",iso_3166_1:"NL"},{start:13107200,end:13139967,country:"New Zealand",iso_3166_1:"NZ"},{start:786432,end:790527,country:"Nicaragua",iso_3166_1:"NI"},{start:401408,end:405503,country:"Niger",iso_3166_1:"NE"},{start:409600,end:413695,country:"Nigeria",iso_3166_1:"NG"},{start:4685824,end:4718591,country:"Norway",iso_3166_1:"NO"},{start:7389184,end:7390207,country:"Oman",iso_3166_1:"OM"},{start:7733248,end:7766015,country:"Pakistan",iso_3166_1:"PK"},{start:6832128,end:6833151,country:"Palau",iso_3166_1:"PW"},{start:794624,end:798719,country:"Panama",iso_3166_1:"PA"},{start:9011200,end:9015295,country:"Papua New Guinea",iso_3166_1:"PG"},{start:15237120,end:15241215,country:"Paraguay",iso_3166_1:"PY"},{start:15253504,end:15257599,country:"Peru",iso_3166_1:"PE"},{start:7700480,end:7733247,country:"Philippines",iso_3166_1:"PH"},{start:4751360,end:4784127,country:"Poland",iso_3166_1:"PL"},{start:4784128,end:4816895,country:"Portugal",iso_3166_1:"PT"},{start:434176,end:435199,country:"Qatar",iso_3166_1:"QA"},{start:7438336,end:7471103,country:"Republic of Korea",iso_3166_1:"KR"},{start:5262336,end:5263359,country:"Republic of Moldova",iso_3166_1:"MD"},{start:4849664,end:4882431,country:"Romania",iso_3166_1:"RO"},{start:1048576,end:2097151,country:"Russian Federation",iso_3166_1:"RU"},{start:450560,end:454655,country:"Rwanda",iso_3166_1:"RW"},{start:13156352,end:13157375,country:"Saint Lucia",iso_3166_1:"LC"},{start:770048,end:771071,country:"Saint Vincent and the Grenadines",iso_3166_1:"VC"},{start:9445376,end:9446399,country:"Samoa",iso_3166_1:"WS"},{start:5242880,end:5243903,country:"San Marino",iso_3166_1:"SM"},{start:647168,end:648191,country:"Sao Tome and Principe",iso_3166_1:"ST"},{start:7405568,end:7438335,country:"Saudi Arabia",iso_3166_1:"SA"},{start:458752,end:462847,country:"Senegal",iso_3166_1:"SN"},{start:4980736,end:5013503,country:"Serbia",iso_3166_1:"RS"},{start:475136,end:476159,country:"Seychelles",iso_3166_1:"SC"},{start:483328,end:484351,country:"Sierra Leone",iso_3166_1:"SL"},{start:7766016,end:7798783,country:"Singapore",iso_3166_1:"SG"},{start:5266432,end:5267455,country:"Slovakia",iso_3166_1:"SK"},{start:5270528,end:5271551,country:"Slovenia",iso_3166_1:"SI"},{start:9007104,end:9008127,country:"Solomon Islands",iso_3166_1:"SB"},{start:491520,end:495615,country:"Somalia",iso_3166_1:"SO"},{start:32768,end:65535,country:"South Africa",iso_3166_1:"ZA"},{start:3407872,end:3670015,country:"Spain",iso_3166_1:"ES"},{start:7798784,end:7831551,country:"Sri Lanka",iso_3166_1:"LK"},{start:507904,end:511999,country:"Sudan",iso_3166_1:"SD"},{start:819200,end:823295,country:"Suriname",iso_3166_1:"SR"},{start:499712,end:500735,country:"Swaziland",iso_3166_1:"SZ"},{start:4882432,end:4915199,country:"Sweden",iso_3166_1:"SE"},{start:4915200,end:4947967,country:"Switzerland",iso_3166_1:"CH"},{start:7831552,end:7864319,country:"Syrian Arab Republic",iso_3166_1:"SY"},{start:5328896,end:5329919,country:"Tajikistan",iso_3166_1:"TJ"},{start:8912896,end:8945663,country:"Thailand",iso_3166_1:"TH"},{start:5316608,end:5317631,country:"North Macedonia",iso_3166_1:"MK"},{start:557056,end:561151,country:"Togo",iso_3166_1:"TG"},{start:13160448,end:13161471,country:"Tonga",iso_3166_1:"TO"},{start:811008,end:815103,country:"Trinidad and Tobago",iso_3166_1:"TT"},{start:163840,end:196607,country:"Tunisia",iso_3166_1:"TN"},{start:4947968,end:4980735,country:"Turkey",iso_3166_1:"TR"},{start:6297600,end:6298623,country:"Turkmenistan",iso_3166_1:"TM"},{start:425984,end:430079,country:"Uganda",iso_3166_1:"UG"},{start:5275648,end:5308415,country:"Ukraine",iso_3166_1:"UA"},{start:9003008,end:9007103,country:"United Arab Emirates",iso_3166_1:"AE"},{start:4194304,end:4456447,country:"United Kingdom",iso_3166_1:"GB"},{start:524288,end:528383,country:"United Republic of Tanzania",iso_3166_1:"TZ"},{start:10485760,end:11534335,country:"United States",iso_3166_1:"US"},{start:15269888,end:15273983,country:"Uruguay",iso_3166_1:"UY"},{start:5274624,end:5275647,country:"Uzbekistan",iso_3166_1:"UZ"},{start:13172736,end:13173759,country:"Vanuatu",iso_3166_1:"VU"},{start:884736,end:917503,country:"Venezuela",iso_3166_1:"VE"},{start:8945664,end:8978431,country:"Viet Nam",iso_3166_1:"VN"},{start:8978432,end:8982527,country:"Yemen",iso_3166_1:"YE"},{start:565248,end:569343,country:"Zambia",iso_3166_1:"ZM"},{start:16384,end:17407,country:"Zimbabwe",iso_3166_1:"ZW"},{start:15728640,end:15761407,country:"ICAO (temporary assignments)",iso_3166_1:null},{start:9015296,end:9016319,country:"ICAO (special use)",iso_3166_1:null},{start:15765504,end:15766527,country:"ICAO (special use)",iso_3166_1:null},{start:2097152,end:2621439,country:"Unassigned (AFI region)",iso_3166_1:null},{start:2621440,end:2686975,country:"Unassigned (SAM region)",iso_3166_1:null},{start:5242880,end:6291455,country:"Unassigned (EUR / NAT regions)",iso_3166_1:null},{start:6291456,end:6815743,country:"Unassigned (MID region)",iso_3166_1:null},{start:6815744,end:7340031,country:"Unassigned (ASIA region)",iso_3166_1:null},{start:9437184,end:10485759,country:"Unassigned (NAM / PAC regions)",iso_3166_1:null},{start:11534336,end:12582911,country:"Unassigned (reserved for future use)",iso_3166_1:null},{start:15466496,end:15728639,country:"Unassigned (CAR region)",iso_3166_1:null},{start:13631488,end:14680063,country:"Unassigned (reserved for future use)",iso_3166_1:null},{start:15728640,end:16777215,country:"Unassigned (reserved for future use)",iso_3166_1:null}]};find=function(t){let e=+("0x"+t);for(let t=0;t=this.ranges[t].start&&e<=this.ranges[t].end)return this.ranges[t];return null}}class n{constructor(){this.limitedAlphabet="ABCDEFGHJKLMNPQRSTUVWXYZ",this.fullAlphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ",this.strideMappings=[{start:32785,s1:676,s2:26,prefix:"ZS-"},{start:3735552,s1:1024,s2:32,prefix:"F-G"},{start:3768320,s1:1024,s2:32,prefix:"F-H"},{start:3949601,s1:1024,s2:32,prefix:"D-A",first:"AAA",last:"OZZ"},{start:3932161,s1:676,s2:26,prefix:"D-A",first:"PAA",last:"ZZZ"},{start:3965985,s1:1024,s2:32,prefix:"D-B",first:"AAA",last:"OZZ"},{start:3940353,s1:676,s2:26,prefix:"D-B",first:"PAA",last:"ZZZ"},{start:3981312,s1:676,s2:26,prefix:"D-C"},{start:3998888,s1:676,s2:26,prefix:"D-E"},{start:4016464,s1:676,s2:26,prefix:"D-F"},{start:4034040,s1:676,s2:26,prefix:"D-G"},{start:4051616,s1:676,s2:26,prefix:"D-H"},{start:4069192,s1:676,s2:26,prefix:"D-I"},{start:4490273,s1:1024,s2:32,prefix:"OO-"},{start:4555809,s1:1024,s2:32,prefix:"OY-"},{start:4587520,s1:676,s2:26,prefix:"OH-"},{start:4621345,s1:1024,s2:32,prefix:"SX-"},{start:4785185,s1:1024,s2:32,prefix:"CS-"},{start:4850721,s1:1024,s2:32,prefix:"YR-"},{start:4949025,s1:1024,s2:32,prefix:"TC-"},{start:7603233,s1:1024,s2:32,prefix:"JY-"},{start:7734305,s1:1024,s2:32,prefix:"AP-"},{start:7767073,s1:1024,s2:32,prefix:"9V-"},{start:7832609,s1:1024,s2:32,prefix:"YK-"},{start:8126464,s1:1296,s2:36,prefix:"VH-"},{start:12582913,s1:676,s2:26,prefix:"C-F"},{start:12600489,s1:676,s2:26,prefix:"C-G"},{start:14684225,s1:4096,s2:64,prefix:"LV-"}],this.numericMappings=[{start:1310720,first:0,count:1e5,template:"RA-00000"},{start:721896,first:1e3,count:1e3,template:"CU-T0000"}];for(let t=0;tn.end)continue;let s=t-n.start+n.offset,a=Math.floor(s/n.s1);s%=n.s1;let o=Math.floor(s/n.s2);s%=n.s2;let r=s;if(!(a<0||a>=n.alphabet.length||o<0||o>=n.alphabet.length||r<0||r>=n.alphabet.length))return n.prefix+n.alphabet.charAt(a)+n.alphabet.charAt(o)+n.alphabet.charAt(r)}return null};numericReg=function(t){let e;for(e=0;en.end)continue;let s=t-n.start+n.first+"";return n.template.substring(0,n.template.length-s.length)+s}};nLetters=function(t){return 0==t?"":(--t,this.limitedAlphabet.charAt(Math.floor(t/25))+this.nLetter(t%25))};nLetter=function(t){return 0==t?"":(--t,this.limitedAlphabet.charAt(t))};nReg=function(t){let e=t-10485761;if(e<0||e>=915399)return null;let n="N"+(Math.floor(e/101711)+1);return e%=101711,e<=600?n+this.nLetters(e):(e-=601,n+=Math.floor(e/10111),e%=10111,e<=600?n+this.nLetters(e):(e-=601,n+=Math.floor(e/951),e%=951,e<=600?n+this.nLetters(e):(e-=601,n+=Math.floor(e/35).toFixed(0),e%=35,e<=24?n+this.nLetter(e):(e-=25,n+e.toFixed(0)))))};hlReg=function(t){return t>=7453184&&t<=7454617?"HL"+(t-7453184+29184).toString(16):t>=7454720&&t<=7454873?"HL"+(t-7454720+32768).toString(16):t>=7455232&&t<=7455385?"HL"+(t-7455232+33280).toString(16):null};jaReg=function(t){let e=t-8650752;if(e<0||e>=229840)return null;let n="JA",s=Math.floor(e/22984);if(s<0||s>9)return null;n+=s,e%=22984;let a=Math.floor(e/916);if(a<0||a>9)return null;if(n+=a,e%=916,e<340){return n+=Math.floor(e/34),e%=34,e<10?n+e:(e-=10,n+this.limitedAlphabet.charAt(e))}e-=340;let o=Math.floor(e/24);return n+this.limitedAlphabet.charAt(o)+this.limitedAlphabet.charAt(e%24)}}class s{constructor(){this.country=new e,this.registration=new n}}var a,o;!function(t){t.language="language",t.system="system",t.comma_decimal="comma_decimal",t.decimal_comma="decimal_comma",t.space_comma="space_comma",t.none="none"}(a||(a={})),function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(o||(o={}));function r(){return(r=Object.assign||function(t){for(var e=1;e-1?t.split(".")[1].length:0;n.minimumFractionDigits=s,n.maximumFractionDigits=s}return n},u=["closed","locked","off"],d=(new Set(["fan","input_boolean","light","switch","group","automation"]),function(t,e,n,s){s=s||{},n=null==n?{}:n;var a=new Event(e,{bubbles:void 0===s.bubbles||s.bubbles,cancelable:Boolean(s.cancelable),composed:void 0===s.composed||s.composed});return a.detail=n,t.dispatchEvent(a),a});new Set(["call-service","divider","section","weblink","cast","select"]);var h=function(t){d(window,"haptic",t)},_=function(t,e,n){void 0===n&&(n=!1),n?history.replaceState(null,"",e):history.pushState(null,"",e),d(window,"location-changed",{replace:n})},p=function(t,e){return function(t,e,n){void 0===n&&(n=!0);var s,a=i(e),o="group"===a?"homeassistant":a;switch(a){case"lock":s=n?"unlock":"lock";break;case"cover":s=n?"open_cover":"close_cover";break;default:s=n?"turn_on":"turn_off"}return t.callService(o,s,{entity_id:e})}(t,e,u.includes(t.states[e].state))},g=function(t,e,n,s,a){var o;if(a&&n.double_tap_action?o=n.double_tap_action:s&&n.hold_action?o=n.hold_action:!s&&n.tap_action&&(o=n.tap_action),o||(o={action:"more-info"}),!o.confirmation||o.confirmation.exemptions&&o.confirmation.exemptions.some((function(t){return t.user===e.user.id}))||confirm(o.confirmation.text||"Are you sure you want to "+o.action+"?"))switch(o.action){case"more-info":(o.entity||n.entity||n.camera_image)&&(d(t,"hass-more-info",{entityId:o.entity?o.entity:n.entity?n.entity:n.camera_image}),o.haptic&&h(o.haptic));break;case"navigate":o.navigation_path&&(_(0,o.navigation_path),o.haptic&&h(o.haptic));break;case"url":o.url_path&&window.open(o.url_path),o.haptic&&h(o.haptic);break;case"toggle":n.entity&&(p(e,n.entity),o.haptic&&h(o.haptic));break;case"call-service":if(!o.service)return;var i=o.service.split(".",2),c=i[0],l=i[1],u=r({},o.service_data);"entity"===u.entity_id&&(u.entity_id=n.entity),e.callService(c,l,u,o.target),o.haptic&&h(o.haptic);break;case"fire-dom-event":d(t,"ll-custom",o),o.haptic&&h(o.haptic)}};class f{constructor(e,n,a,o){this.config=n,this.lang=o;const r=new t;this._path=r.getPath(),this.hex=e.hex.toUpperCase(),this.icon="mdi:airplane",this.flight=e.flight??null,this.squawk=e.squawk??null,this.altitude=e.altitude??e.alt_baro??null,this.speed=e.speed??e.gs??null,this.track=e.track??null,this.vert_rate=e.vert_rate??e.baro_rate??null,this.lat=e.lat??null,this.lon=e.lon??null,this.seen=e.seen??100;const i=new s,c=i.country.find(this.hex),l=i.registration.lookup(this.hex);this.flag=null!==c&&null!==c.iso_3166_1?`${this._path}images/flags/${c.iso_3166_1.toLowerCase()}.svg`:null,this.country=null!==c?c.country:null,this.registration=l,this.distance=a.isSetUp()?a.calculate(this.lat,this.lon):null,this.setIcon(),this.setUnits()}setIcon=function(){this.vert_rate<0?this.icon="mdi:airplane-landing":this.vert_rate>0&&(this.icon="mdi:airplane-takeoff")};setUnits=function(){if("metric"===this.config.units)!0===this.config.larger_units?this.units={altitude:"km",distance:"km",speed:"km/h"}:this.units={altitude:"m",distance:"m",speed:"m/s"},this.units.age="s",!0!==this.config.track_in_text&&(this.units.track="°");else this.units={altitude:"ft",distance:"NM",speed:"kt",track:"°",age:"s"},!0!==this.config.track_in_text&&(this.units.track="°")};value=function(t,e){let n=this,s=this.units[t]??null;switch(t){case"icon":return e?``:``;case"flag":return null!==n.flag?`${n.country}`:"";case"icao":return n.hex;case"age":let a=n.seen??"";return""!==a&&e&&(a+=" "+s),a;case"speed":let o=n.speed??"";if(""!==o){if("metric"===this.config.units)o=this.config.larger_units?c(Math.round(1.852*o)):c(Math.round(.514444444*o));o=c(o),e&&(o+=" "+s)}return o;case"altitude":let r=n.altitude??"";if(""!==r){if("metric"===this.config.units)r=this.config.larger_units?Math.round(.3048*r/1e3*10)/10:Math.round(.3048*r);r=c(r),e&&(r+=" "+s)}return r;case"track":let i=n.track??"";return""!==i&&(!0===this.config.track_in_text?i=this.trackAsText(i,e):e&&(i+=""+s)),i;case"registration":return null===n.registration?this.lang.content.table.data.not_available:n.registration;default:let l=n[t]??"";return""!==l&&"number"==typeof l&&(l=c(l)),e&&""!==l&&null!==s&&(l+=" "+s),l}};trackAsText=function(t,e){let n="n";return t>=11.25&&t<=33.75?n="nne":t>=33.75&&t<=56.25?n="ne":t>=56.25&&t<=78.75?n="ene":t>=78.75&&t<=101.25?n="e":t>=101.25&&t<=123.75?n="ese":t>=123.75&&t<=146.25?n="se":t>=146.25&&t<=168.75?n="sse":t>=168.75&&t<=191.25?n="s":t>=191.25&&t<=213.75?n="ssw":t>=213.75&&t<=236.25?n="sw":t>=236.25&&t<=258.75?n="wsw":t>=258.75&&t<=281.25?n="w":t>=281.25&&t<=303.75?n="wnw":t>=303.75&&t<=326.25?n="nw":t>=326.25&&t<=348.75&&(n="nnw"),e?this.lang.content.track.long[n]:this.lang.content.track.short[n]}}class y{constructor(t,e){this.config=t,this.zone=t.zone,this.units=t.units,this.hass=e,null!==this.zone&&this.getCoordinatesOfZone()}isSetUp=function(){return this.hasOwnProperty("lat")&&this.hasOwnProperty("lon")};getCoordinatesOfZone=function(){let t=this.hass.states[this.zone];void 0!==t&&(this.lat=t.attributes.latitude,this.lon=t.attributes.longitude)};calculate=function(t,e){if(null===t||null===e)return"";if(t===this.lat&&e===this.lon)return 0;let n=this.lat*(Math.PI/180),s=t*(Math.PI/180),a=s-n,o=(e-this.lon)*(Math.PI/180),r=12742142*Math.asin(Math.sqrt(Math.sin(a/2)*Math.sin(a/2)+Math.cos(n)*Math.cos(s)*Math.sin(o/2)*Math.sin(o/2)));switch(r=Math.round(r),this.units){case"metric":this.config.larger_units&&(r=Math.round(r/1e3*10)/10);break;case"default":r=Math.round(.000539956803*r*10)/10}return r}}const m=JSON.parse('{"icon":{"styles":["width-s"],"weight":1,"popup":false},"icao":{"weight":2,"popup":true},"flag":{"styles":["width-s"],"weight":1,"popup":false},"country":{"weight":4,"popup":true},"registration":{"weight":4,"popup":true},"flight":{"weight":2,"popup":true},"squawk":{"weight":2,"popup":true},"altitude":{"styles":["align-right"],"weight":2,"popup":true},"speed":{"styles":["align-right"],"weight":2,"popup":true},"distance":{"styles":["align-right"],"weight":2,"popup":true},"track":{"styles":["align-right"],"weight":2,"popup":true},"age":{"styles":["align-right"],"weight":3,"popup":true}}');class b{constructor(t,e,n,s,a){this.element=t,this.hass=e,this.config=n,this.lang=s,this.aircrafts=a,this.addEventListeners()}addEventListeners=function(){const t=this;let e=this.element.querySelectorAll("tr[data-hex]");for(let n=0;n{t.hex===n&&(a=t)})),null!==a&&fetch("https://api.planespotters.net/pub/photos/hex/"+a.hex,{cache:"no-store",headers:{"Content-Type":"text/json"}}).then((t=>t.text())).then((function(e){let n=JSON.parse(e),o="";if(n.photos.length>0){let t=n.photos[0].thumbnail_large.src,e=n.photos[0].link,s=n.photos[0].photographer;o+=`![Image](${t})\n`,o+=`© [${s}](${e})\n\n`}o+="## ",a.flag&&(o+=``),o+=`${a.registration||a.flight||a.hex}${a.value("icon",!0)}\n`,o+=`|${t.lang.content.popup.table.head.property}|${t.lang.content.popup.table.head.value}|\n|:-|-:|\n`,Object.keys(m).forEach((e=>{let n=m[e],s=a.value(e,!0);n.popup&&""!==s&&(o+=`|${t.lang.content.table.head[e]}|${s}|\n`)})),g(s,t.hass,{tap_action:{action:"fire-dom-event",browser_mod:{command:"popup",hide_header:!0,card:{type:"markdown",content:o,card_mod:{style:{".":`\n ha-markdown{\n background:${t.config.colors.popup_bg??"var(--card-background-color)"};\n }`,"ha-markdown$":`\n font {\n color: ${t.config.colors.popup_text??t.config.colors.table_text??"var(--primary-text-color)"};\n }\n font a{\n color:${t.config.colors.popup_text??t.config.colors.table_text??"var(--primary-color)"};\n }\n h2{\n display:flex;\n justify-content:space-between;\n color:${t.config.colors.popup_text??t.config.colors.table_text??"var(--primary-text-color)"};\n }\n h2 img{\n height:.8em;\n margin:0 10px 0 0;\n display:inline-block;\n vertical-align:baseline;\n }\n table{\n width:100%;\n border-spacing:0;\n border-collapse:collapse;\n }\n table tr th, table tr td{\n padding:4px;\n }\n table tr th{\n background-color:${t.config.colors.popup_table_head_bg??t.config.colors.table_head_bg??"var(--primary-color)"};\n color:${t.config.colors.popup_table_head_text??t.config.colors.table_head_text??"var(--app-header-text-color, white)"};\n }\n table tr{\n color:${t.config.colors.popup_text??t.config.colors.table_text??"var(--primary-text-color)"};\n }\n table tr:nth-child(even){\n background-color:${t.config.colors.popup_table_even_row_bg??t.config.colors.table_even_row_bg??"var(--primary-background-color)"};\n color:${t.config.colors.popup_table_even_row_text??t.config.colors.table_even_row_text??"var(--primary-text-color)"};\n }`}}}}}})}))}))}}}const w=JSON.parse('{"table":{"head":{"icao":"ICAO Code","country":"Land","registration":"Registration","flight":"Flug","squawk":"Squawk","altitude":"Höhe","speed":"Geschwindigkeit","distance":"Entfernung","track":"Pfad","age":"Letzte Nachricht"},"data":{"not_available":"N/V"}},"popup":{"table":{"head":{"property":"Eigenschaft","value":"Wert"}}},"track":{"short":{"n":"N","nne":"NNO","ne":"NO","ene":"ONO","e":"O","ese":"OSO","se":"SO","sse":"SSO","s":"S","ssw":"SSW","sw":"SW","wsw":"WSW","w":"W","wnw":"WNW","nw":"NW","nnw":"NNW"},"long":{"n":"Nord","nne":"Nord-Nord-Ost","ne":"Nord-Ost","ene":"Ost-Nord-Ost","e":"Ost","ese":"Ost-Süd-Ost","se":"Süd-Ost","sse":"Süd-Süd-Ost","s":"Süd","ssw":"Süd-Süd-West","sw":"Süd-West","wsw":"West-Süd-West","w":"West","wnw":"West-Nord-West","nw":"Nord-West","nnw":"Nord-Nord-West"}}}'),v=JSON.parse('{"table":{"head":{"icao":"ICAO Code","country":"Country","registration":"Registration","flight":"Flight","squawk":"Squawk","altitude":"Altitude","speed":"Speed","distance":"Distance","track":"Track","age":"Last message"},"data":{"not_available":"N/A"}},"popup":{"table":{"head":{"property":"Property","value":"Value"}}},"track":{"short":{"n":"N","nne":"NNE","ne":"NE","ene":"ENE","e":"E","ese":"ESE","se":"SE","sse":"SSE","s":"S","ssw":"SSW","sw":"SW","wsw":"WSW","w":"W","wnw":"WNW","nw":"NW","nnw":"NNW"},"long":{"n":"North","nne":"North-northeast","ne":"Northeast","ene":"East-northeast","e":"East","ese":"East-southeast","se":"Southeast","sse":"South-southeast","s":"South","ssw":"South-southwest","sw":"Southwest","wsw":"West-southwest","w":"West","wnw":"West-northwest","nw":"Northwest","nnw":"North-northwest"}}}'),S=JSON.parse('{"table":{"head":{"icao":"ICAO code","country":"Land","registration":"Registratie","flight":"Vlucht","squawk":"Squawk","altitude":"Hoogte","speed":"Snelheid","distance":"Afstand","track":"Richting","age":"Laatste bericht"},"data":{"not_available":"Nb"}},"popup":{"table":{"head":{"property":"Eigenschap","value":"Waarde"}}},"track":{"short":{"n":"N","nne":"NNO","ne":"NO","ene":"ONO","e":"O","ese":"OZO","se":"ZO","sse":"ZZO","s":"Z","ssw":"ZZW","sw":"ZW","wsw":"WZW","w":"W","wnw":"WNW","nw":"NW","nnw":"NNW"},"long":{"n":"Noord","nne":"Noordnoordoost","ne":"Noordoost","ene":"Oostnoordoost","e":"Oost","ese":"Oostzuidoost","se":"Zuidoost","sse":"Zuidzuidoost","s":"Zuid","ssw":"Zuidzuidwest","sw":"Zuidwest","wsw":"Westzuidwest","w":"West","wnw":"Westnoordwest","nw":"Noordwest","nnw":"Noordnoordwest"}}}'),A=JSON.parse('{"table":{"head":{"icao":"ICAO naslov","country":"Država","registration":"Registracija","flight":"Št. leta","squawk":"Squawk","altitude":"Višina","speed":"Hitrost","distance":"Razdalja","track":"Smer","age":"Zaznano pred"},"data":{"not_available":"N/A"}},"popup":{"table":{"head":{"property":"Karakteristika","value":"Vrednost"}}},"track":{"short":{"n":"S","nne":"SSV","ne":"SV","ene":"VSV","e":"V","ese":"VJV","se":"JV","sse":"JJV","s":"J","ssw":"JJZ","sw":"JZ","wsw":"ZJZ","w":"Z","wnw":"ZSZ","nw":"SZ","nnw":"SSZ"},"long":{"n":"sever","nne":"sever-severovzhod","ne":"severovzhod","ene":"vzhod-severovzhod","e":"vzhod","ese":"vzhod-jugovzhod","se":"jugovzhod","sse":"jug-jugovzhod","s":"jug","ssw":"jug-jugozahod","sw":"jugozahod","wsw":"zahod-jugozahod","w":"zahod","wnw":"zahod-severozahod","nw":"severozahod","nnw":"sever-severozahod"}}}');class x{constructor(t,e){this.config=t,this.hass=e,this.content=v,this.setLang()}setLang=function(){if(null===this.config.lang&&(this.config.lang=this.hass.language),"en"!==this.config.lang)switch(this.config.lang){case"de":this.content=w;break;case"nl":this.content=S;break;case"sl":this.content=A}}}class N{constructor(){this.element=document.createElement("tr")}addCells=function(t=[]){for(let e=0;e0&&s.addAttributes(n),s.addCells(t),e){case"thead":this.thead.appendChild(s.element),this.hasRowsInHead=!0;break;case"tfoot":this.tfoot.appendChild(s.element),this.hasRowsInFoot=!0;break;default:this.tbody.appendChild(s.element),this.hasRowsInBody=!0}};cell=function(t,e=null,n="td",s=null){let a=new M(n);return a.setValue(t),null!=e&&"object"==typeof e&&a.setClasses(e),"object"==typeof s&&null!==s&&Object.keys(s).length>0&&a.addAttributes(s),a}}window.customCards=window.customCards||[],window.customCards.push({type:"fr24-card",name:"Flight Radar card",description:"Card that shows the tracked flights",preview:!1}),window.fr24db=[];class C extends HTMLElement{set hass(t){this._hass=t,this._config&&(this._distance=new y(this._config,this._hass),this._lang=new x(this._config,this._hass),this._parseAircrafts(),this._renderTable())}setConfig(e){const n=new t;this._path=n.getPath(),this._availableColumns=m;const s={attribute:"aircraft",columns:["flag","registration","flight","altitude","speed","distance","track"],hide:{old_messages:!0,empty:[]},lang:null,larger_units:!1,limit:null,order:"asc",popup:!1,sort:"altitude",track_in_text:!1,units:"default",units_in_table:!1,zone:null,colors:{table_head_bg:null,table_head_text:null,table_units_bg:null,table_units_text:null,table_text:null,table_even_row_bg:null,table_even_row_text:null,popup_bg:null,popup_text:null,popup_table_head_bg:null,popup_table_head_text:null,popup_table_even_row_bg:null,popup_table_even_row_text:null}},a={...s.hide,...e.hide},o={...s.colors,...e.colors};if(this._config={...s,...e},this._config.hide=a,this._config.colors=o,!e.entity)throw new Error("You need to define an entity");let r=0;if(this._config.columns.forEach((t=>{if(!this._availableColumns.hasOwnProperty(t))throw new Error("Column '"+t+"' does not exist");r+=this._availableColumns[t].weight})),r>15)throw new Error("Too many columns defined");if(!["default","metric"].includes(this._config.units))throw new Error("Unit '"+this._config.units+"' not supported");if(!["asc","desc"].includes(this._config.order))throw new Error("Order '"+this._config.order+"' not supported");if(!this.setupComplete){this.card=document.createElement("ha-card"),this.contentDiv=document.createElement("div"),this.contentDiv.setAttribute("class","card-content"),this.card.appendChild(this.contentDiv),this.appendChild(this.card);const t=document.createElement("link");if(t.setAttribute("type","text/css"),t.setAttribute("rel","stylesheet"),t.setAttribute("href",this._path+"fr24_card.css"),this.card.appendChild(t),0===window.fr24db.length){const t=document.createElement("script");t.setAttribute("async",""),t.setAttribute("type","text/javascript"),t.setAttribute("src",this._path+"fr24_database.js"),document.head.appendChild(t)}this.setupComplete=!0}this.card.setAttribute("header",e.title??"")}getCardSize(){return Number.isInteger(this._config.limit)?this._config.limit+5:100}static getStubConfig(){return{entity:"sensor.fr24_aircraft"}}_parseAircrafts(){const t=this;this._aircrafts=[];const e=this._hass.states[this._config.entity].attributes[this._config.attribute];this._availableColumns.distance.show=!0,!1===this._distance.isSetUp()&&(this._availableColumns.distance.show=!1),e.forEach((t=>{let e=new f(t,this._config,this._distance,this._lang),n=!0;if(!1!==this._config.hide.old_messages&&e.seen>30)n=!1;else if(this._config.hide.empty.length>0)for(let t=0;t{let n=this._availableColumns[e];if(!1===n.show)return;let a=this._lang.content.table.head[e]??"",o=n.styles??null,r="";null!==this._config.colors.table_head_bg&&(r+="background-color:"+this._config.colors.table_head_bg+" !important;"),null!==this._config.colors.table_head_text&&(r+="color:"+this._config.colors.table_head_text+" !important;");let i=[];r.length>0&&(i.style=r);let c=t.cell(a,o,"th",i);s.push(c)})),t.row(s,"thead");let a=0;for(let s of this._aircrafts){if(e&&!n){n=!0;let e=[];this._config.columns.forEach((n=>{let a=this._availableColumns[n];if(!1===a.show)return;let o=s.units[n]??"",r=a.styles??null,i="";null!==this._config.colors.table_units_bg&&(i+="background-color:"+this._config.colors.table_units_bg+" !important;"),null!==this._config.colors.table_units_text&&(i+="color:"+this._config.colors.table_units_text+" !important;");let c=[];i.length>0&&(c.style=i);let l=t.cell(o,r,"td",c);e.push(l)})),t.row(e,"thead")}let o=[];this._config.columns.forEach((e=>{let n=this._availableColumns[e];if(!1===n.show)return;let r="";a%2==1?(null!==this._config.colors.table_even_row_bg&&(r+="background-color:"+this._config.colors.table_even_row_bg+" !important;"),null!==this._config.colors.table_even_row_text&&(r+="color:"+this._config.colors.table_even_row_text+" !important;")):null!==this._config.colors.table_text&&(r+="color:"+this._config.colors.table_text+" !important;");let i=[];r.length>0&&(i.style=r);let c=t.cell(s.value(e),n.styles??null,"td",i);o.push(c)}));let r=[];if(this._config.popup&&(r["data-hex"]=s.hex),t.row(o,null,r),a++,Number.isInteger(this._config.limit)&&this._config.limit===a)break}if(this.contentDiv.innerHTML=t.getHtml(),this._config.popup){new b(this.contentDiv,this._hass,this._config,this._lang,this._aircrafts)}}}customElements.define("fr24-card",C)})(); \ No newline at end of file diff --git a/src/javascript/helpers/distance.js b/src/javascript/helpers/distance.js index 57f1669..e454f01 100644 --- a/src/javascript/helpers/distance.js +++ b/src/javascript/helpers/distance.js @@ -27,42 +27,55 @@ export default class Distance { } }; - deg2rad = function (deg) { - return deg * (Math.PI / 180); - }; - calculate = function (lat, lon) { + // Check for empty or invalid coordinates if (lat === null || lon === null) { return ""; } - let R = 6371000; // Radius of the earth in m - let dLat = this.deg2rad(lat - this.lat); // deg2rad below - let dLon = this.deg2rad(lon - this.lon); - let a = - Math.sin(dLat / 2) * Math.sin(dLat / 2) + - Math.cos(this.deg2rad(this.lat)) * - Math.cos(this.deg2rad(this.lon)) * - Math.sin(dLon / 2) * - Math.sin(dLon / 2); - let c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); - let d = Math.round(R * c); // Distance in m + // Check for same location + if (lat === this.lat && lon === this.lon) { + return 0; + } + + let R = 6371071; // Radius of the Earth in meter + let rlat1 = this.lat * (Math.PI / 180); // Convert degrees to radians + let rlat2 = lat * (Math.PI / 180); // Convert degrees to radians + let difflat = rlat2 - rlat1; // Radian difference (latitudes) + let difflon = (lon - this.lon) * (Math.PI / 180); // Radian difference (longitudes) + + let distance = + 2 * + R * + Math.asin( + Math.sqrt( + Math.sin(difflat / 2) * Math.sin(difflat / 2) + + Math.cos(rlat1) * + Math.cos(rlat2) * + Math.sin(difflon / 2) * + Math.sin(difflon / 2) + ) + ); + + // Round on the meter + distance = Math.round(distance); // Convert distance to configures unit switch (this.units) { case "metric": if (this.config.larger_units) { // In km - d = Math.round((d / 1000) * 10) / 10; + distance = Math.round((distance / 1000) * 10) / 10; } break; case "default": // In Nautical Miles - d = Math.round(d * 0.000539956803 * 10) / 10; + distance = Math.round(distance * 0.000539956803 * 10) / 10; break; } - return d; + // Return the distance + return distance; }; }