"use strict";(self.webpackChunkvt_ui_main=self.webpackChunkvt_ui_main||[]).push([[13420],{13420:(t,e,i)=>{var s=i(13570),r=(i(9891),i(87347)),o=i(48704),n=i(16645),a=i(62832),l=i(52463),h=i.n(l),c=i(42246),d=i(92619),u=i(15323),p=i(68122),m=i(96855),g=i(96987),y=(i(67668),i(77554),i(25076),i(33554),i(51196),i(84034),i(8746),i(28238)),v=i(44052),f=(i(63787),i(72856),i(50071),i(52059),i(69335),i(31856),i(77698)),b=i(22685);let S,w,$,L,O,k=t=>t;var A=function(t,e,i,s){var r,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);return o>3&&n&&Object.defineProperty(e,i,n),n};const C="ALL",T="num_lookups-",M="num_submissions-",x=f.DT.map((t=>({title:t.replace(/"/g,""),value:t})));let D=class extends o.LitElement{constructor(){super(...arguments),this.regionIndexMap=new Map,this.isLoading=!1,this.isEmpty=!1,this.lookupsOnly=!1,this.selectedDate=[f.qf.ALL_HISTORY],this.tempSelectedDate=[f.qf.ALL_HISTORY],this.selectedRegion=C,this.selectedOrder=T,this.shownMetrics="all"}static get styles(){return(0,o.unsafeCSS)(b.A)}get showResetButton(){return this.selectedDate.length&&this.selectedDate[0]!==f.qf.ALL_HISTORY||this.selectedRegion!==C||!this.lookupsOnly&&"all"!==this.shownMetrics}get dateLabel(){var t;const e=null!==(t=this.selectedDate[0])&&void 0!==t?t:f.qf.ALL_HISTORY;return/[\+-]$/.test(e)?"Custom":e.replace(/"/g,"")}get regionLabel(){const t=this.selectedRegion;return this.regionIndexMap.has(t)?m.i.getCountryName(t):"Region"}get sortByLabel(){return this.selectedOrder===T?"Sort by lookups":this.selectedOrder===M?"Sort by submissions":"Sort by"}get shownMetricsLabel(){return"all"===this.shownMetrics?"View all":"submissions"===this.shownMetrics?"View submissions":"View lookups"}get regions(){return[C].concat([...this.regionIndexMap.keys()].sort(((t,e)=>{const i=m.i.getCountryName(t),s=m.i.getCountryName(e);return i.localeCompare(s)})))}willUpdate(t){t.has("lookupsOnly")&&this.lookupsOnly&&(this.shownMetrics="lookups")}handleDateSelected(t){t.stopPropagation(),this.tempSelectedDate.length&&this.selectedDate!==this.tempSelectedDate&&(this.selectedDate=this.tempSelectedDate,this.requestFilter())}handleRegionSelected(t){t.stopPropagation(),this.selectedRegion!==t.detail.selection&&(this.selectedRegion=t.detail.selection||"",this.requestFilter())}requestFilter(){const t=this.selectedDate[0],e=/[\+-]$/.test(t);let i,s;if(e){const e=t.slice(-1),r=this.selectedDate[1];"+"===e?(i=new Date(t.slice(0,-1)).getTime()/1e3,s=r?new Date(r.slice(0,-1)).getTime()/1e3:void 0):(s=new Date(t.slice(0,-1)).getTime()/1e3,i=r?new Date(r.slice(0,-1)).getTime()/1e3:void 0)}const r=new CustomEvent("request-filter",{detail:{filter:{date:{isCustom:e,start:e?i:t,end:s},region:this.selectedRegion===C?"":this.selectedRegion,shownMetrics:this.shownMetrics}},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(r)}handleOrderChanged(t){t.stopPropagation(),this.dispatchOrderChanged(t.detail.value,t.currentTarget)}dispatchOrderChanged(t,e){this.selectedOrder=t;const i=new CustomEvent("order-changed",{detail:{order:t},bubbles:!0,cancelable:!0,composed:!0});(e||this).dispatchEvent(i)}handleShownMetricsChanged(t){t.stopPropagation(),this.shownMetrics!==t.detail.value&&(this.shownMetrics=t.detail.value,"submissions"===this.shownMetrics&&this.selectedOrder===T?this.dispatchOrderChanged(M):"lookups"===this.shownMetrics&&this.selectedOrder===M&&this.dispatchOrderChanged(T),this.requestFilter())}handleFilterReset(t){var e;t.stopPropagation(),this.tempSelectedDate=[f.qf.ALL_HISTORY],this.selectedDate=[f.qf.ALL_HISTORY],this.selectedRegion=C,null===(e=this.regionSelect)||void 0===e||e.reset(),this.shownMetrics=this.lookupsOnly?"lookups":"all";const i=new CustomEvent("clear-filter",{bubbles:!0,cancelable:!0,composed:!0});t.currentTarget.dispatchEvent(i)}updateTempSelectedDate(t){var e;const i=null===(e=t.detail)||void 0===e?void 0:e.filterQuery;this.tempSelectedDate=i&&y.be.parseQuery(i).date_range||[]}render(){var t;return null!==(t=v.NU.currentUser)&&void 0!==t&&t.insightsAccess?(0,o.html)(S||(S=k`
${0} ${0}
`),!0,this.updateTempSelectedDate,this.isLoading,"Clear current filters",this.showResetButton,"Search by title, description or tags",this.handleFilterReset,!0,this.lookupsOnly?o.nothing:(0,o.html)(w||(w=k` `),this.shownMetricsLabel,this.isLoading,[{title:"View all",value:"all"},{title:"View lookups",value:"lookups"},{title:"View submissions",value:"submissions"}],[this.shownMetrics],this.handleShownMetricsChanged),this.dateLabel,this.isLoading,this.handleDateSelected,"date_range",x,this.selectedDate||[f.qf.ALL_HISTORY],this.regionLabel,this.isLoading||!this.regionIndexMap.size,this.regions,this.selectedRegion,(t=>t===C?(0,o.html)($||($=k`${0}`),t):(0,o.html)(L||(L=k` ${0}`),t,m.i.getCountryName(t))),((t,e)=>m.i.getCountryName(t).toLowerCase().includes(e.toLowerCase())),"Search regions",this.handleRegionSelected,this.lookupsOnly?o.nothing:(0,o.html)(O||(O=k` `),this.sortByLabel,this.isLoading||this.isEmpty,[{title:"Lookups",value:T},{title:"Submissions",value:M}],[this.selectedOrder],this.handleOrderChanged)):o.nothing}};A([(0,n.property)({type:Object})],D.prototype,"regionIndexMap",void 0),A([(0,n.property)({type:Boolean})],D.prototype,"isLoading",void 0),A([(0,n.property)({type:Boolean})],D.prototype,"isEmpty",void 0),A([(0,n.property)({type:Boolean})],D.prototype,"lookupsOnly",void 0),A([(0,n.state)()],D.prototype,"selectedDate",void 0),A([(0,n.state)()],D.prototype,"selectedRegion",void 0),A([(0,n.state)()],D.prototype,"selectedOrder",void 0),A([(0,n.state)()],D.prototype,"shownMetrics",void 0),A([(0,n.query)("#region-select")],D.prototype,"regionSelect",void 0),D=A([(0,n.customElement)("ioc-telemetry-filters")],D);var F=i(26416);let _,R,E,I,H,j,q,P,N,Y,B,U,z,V,X,Q,Z,G,J,W,K,tt,et,it,st,rt,ot=t=>t;function nt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var s,r,o,n,a=[],l=!0,h=!1;try{if(o=(i=i.call(t)).next,0===e){if(Object(i)!==i)return;l=!1}else for(;!(l=(s=o.call(i)).done)&&(a.push(s.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(h)throw r}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return at(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?at(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function at(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,s=Array(e);i=0;a--)(r=t[a])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);return o>3&&n&&Object.defineProperty(e,i,n),n};function ut(t){return"UnknownCode"===t.code}let pt=(_=class extends o.LitElement{constructor(){super(...arguments),this.showTotalOnly=!1,this.lookupsOnly=!1,this.params=f.ZG.DEFAULT,this.localDateFilter=null,this.countryIndex=new Map,this.timeMetric=[],this.countryMetric=[],this.visibleCountryMetric=[],this.firstSightings=new f.A1(this,(()=>this.firstSightingsEndpoint),(()=>{const t=this.localDateFilterString||this.dateFilterString,e=this.showLookups!==this.showSubmissions;return{filter:`${t} ${this.countryFilterString} ${e?"metric:"+(this.showLookups?"num_lookups":"num_submissions"):""}`,limit:10}})),this.filterHandler=t=>{let e=t.detail;switch(e.by){case"date":return this.localDateFilter=e.payload,void this.setCountryMetric();case"country":var i;return void this.filter(ht(ht({},this.filters),{},{country:(null===(i=e.payload)||void 0===i?void 0:i.country)||null}))}}}get showLookups(){return this.params.showLookups}get showSubmissions(){return this.params.showSubmissions}get dateFilter(){return this.params.date}get dateFilterString(){return this.serializeDateFilter((0,f.Xp)(this.dateFilter))}get localDateFilterString(){return this.serializeDateFilter(this.localDateFilter)}get countryFilterString(){return""+(this.countryFilter?` country:${this.countryFilter}`:"")}serializeDateFilter(t){if(!t)return"";const e=t.start,i=t.end;return`${""+(i?` end:${i}`:"")}${""+(e?` start:${e}`:"")}`}get countryFilter(){return this.params.country}get order(){return this.params.order}get filters(){return{date:this.dateFilter,country:this.countryFilter,showLookups:this.showLookups,showSubmissions:this.showSubmissions}}get queryString(){return f.ZG.toQueryString(this.params)}connectedCallback(){super.connectedCallback(),this.loadMetric(),this.addEventListener("filter",this.filterHandler)}updated(t){super.updated(t),t.has("params")&&this.dispatchEvent(new CustomEvent("query-string-updated",{detail:this.queryString,bubbles:!0}))}loadMetric(){return this.perDayAndCountryStatsSO=(0,c.hH)((()=>this.endpoint({filter:`${this.dateFilterString}`}).catch((t=>{if(s.H.isApiError(t))return{data:t};throw t}))),(t=>{var e;let i=t.data;return s.H.isApiError(i)?i:(null===(e=i.attributes)||void 0===e||null===(e=e.per_day_and_country)||void 0===e?void 0:e.map((t=>({date:t.day_timestamp,country:t.country,metrics:[t.num_lookups,t.num_submissions]}))))||[]})),this.perDayAndCountryStatsSO.load().then((()=>{const t=this.perDayAndCountryStatsSO.data;s.H.isApiError(t)||(this.setCountryIndex(t),this.setTimeMetric(),this.setCountryMetric())}))}disconnectedCallback(){this.removeEventListener("filter",this.filterHandler),super.disconnectedCallback()}filter(t){const e=this.countryFilter!==t.country,i=(0,f.Xp)(this.dateFilter),s=(0,f.Xp)(t.date),r=i.start!==s.start||i.end!==s.end,o=this.showSubmissions!==t.showSubmissions||this.showLookups!==t.showLookups;(e||r||o)&&(this.params=ht(ht({},this.params),{},{country:t.country,date:t.date,showLookups:t.showLookups,showSubmissions:t.showSubmissions}),r?this.loadMetric():e&&this.setTimeMetric())}setTimeMetric(){const t=this.countryFilter;let e=this.perDayAndCountryStatsSO.data;if(!s.H.isApiError(e)){var i;if(null!==t)e=(null===(i=this.countryIndex.get(t))||void 0===i?void 0:i.map((t=>e[t])))||[];this.timeMetric=Array.from(e.reduce(((t,e)=>{t.has(e.date)||t.set(e.date,[0,0]);const i=nt(t.get(e.date),2),s=i[0],r=i[1],o=nt(e.metrics,2),n=o[0],a=o[1];return t.set(e.date,[s+n,r+a]),t}),new Map).entries()).map((t=>{let e=nt(t,2);return{date:e[0],metrics:e[1]}})),this.timeMetric.length||this.dispatchEvent(new CustomEvent("empty-metrics"))}}setCountryMetric(){const t=this.localDateFilter;let e=this.perDayAndCountryStatsSO.data;if(!s.H.isApiError(e)){if(null!==t){const i=t.start,s=t.end,o=e.map((t=>t.date)),n=(0,r.ahM)(o,i),a=(0,r.Jjl)(o,s);e=e.slice(n,a)}this.countryMetric=Array.from(e.reduce(((t,e)=>{t.has(e.country)||t.set(e.country,[0,0]);const i=nt(t.get(e.country),2),s=i[0],r=i[1],o=nt(e.metrics,2),n=o[0],a=o[1];return t.set(e.country,[s+n,r+a]),t}),new Map).entries()).sort(((t,e)=>{let i=nt(t,2),s=nt(i[1],2),r=s[0],o=s[1],n=nt(e,2),a=nt(n[1],2),l=a[0],h=a[1];return"num_submissions-"===this.order?h-o:l-r})).map((t=>{let e=nt(t,2);return{country:e[0],metrics:e[1]}}))}}setCountryIndex(t){this.countryIndex=t.reduce(((t,e,i)=>(t.has(e.country)||t.set(e.country,[]),t.get(e.country).push(i),t)),new Map)}resetForm(t){Array.from(t.querySelectorAll("vt-ui-searchable-multiselect")).forEach((t=>t.reset())),t.reset(),t.dispatchEvent(new Event("change"))}resetAscendingForm(t){const e=t.composedPath().find((t=>t instanceof HTMLFormElement));e&&this.resetForm(e)}dateFilterFormSubmitted(t){t.preventDefault();const e=t.currentTarget.elements,i=e.namedItem("date-filter").value;let s;if("Custom"===i){var r,o;const t=null===(r=e.namedItem("start").valueAsDate)||void 0===r?void 0:r.valueOf(),i=null===(o=e.namedItem("end").valueAsDate)||void 0===o?void 0:o.valueOf();s=void 0===t&&void 0===i?f.qf.ALL_HISTORY:{start:t?t/1e3:void 0,end:i?i/1e3:void 0}}else s=i;this.localDateFilter=null,this.filter(ht(ht({},this.filters),{},{date:s}))}filterFormSubmitted(t){t.preventDefault();const e=new FormData(t.currentTarget).get("country")||null;this.filter(ht(ht({},this.filters),{},{country:e}))}deleteSingleFilter(t){const e=t.currentTarget.dataset.field;"date-range"===e?this.filter(ht(ht({},this.filters),{},{date:f.qf.ALL_HISTORY})):"from"===e?this.filter(ht(ht({},this.filters),{},{date:ht(ht({},(0,f.Xp)(this.dateFilter)),{},{start:void 0})})):"until"===e?this.filter(ht(ht({},this.filters),{},{date:ht(ht({},(0,f.Xp)(this.dateFilter)),{},{end:void 0})})):"country"===e&&this.filter(ht(ht({},this.filters),{},{country:null}))}sort(t){this.params=ht(ht({},this.params),{},{order:t}),this.setCountryMetric()}visibleDataChanged(t){this.visibleCountryMetric=t.detail.value}onRequestFilter(t){let e;t.preventDefault(),e=t.detail.filter.date.isCustom?{start:t.detail.filter.date.start,end:t.detail.filter.date.end}:t.detail.filter.date.start,this.localDateFilter=null;const i=t.detail.filter.region||null,s=t.detail.filter.shownMetrics,r=["all","lookups"].some((t=>s===t)),o=["all","submissions"].some((t=>s===t));this.filter({date:e,country:i,showLookups:r,showSubmissions:o})}onOrderChanged(t){t.preventDefault(),this.sort(t.detail.order)}onClearFilter(t){t.preventDefault(),this.filter({date:f.qf.ALL_HISTORY,country:null,showLookups:!0,showSubmissions:!this.lookupsOnly})}renderEmpty(t){return this.renderSpecialState("Stats not found",t)}renderSpecialState(t,e){return(0,o.html)(R||(R=ot` ${0} ${0} `),h(),t,e)}renderSpinner(){return(0,o.html)(E||(E=ot`
Loading stats
`))}renderFilters(){return(0,o.html)(I||(I=ot` `),this.countryIndex,this.firstSightings.isLoading||this.perDayAndCountryStatsSO.isLoading,this.firstSightings.isEmpty||!this.timeMetric.length,this.lookupsOnly,this.onRequestFilter,this.onOrderChanged,this.onClearFilter)}render(){return(0,o.html)(H||(H=ot` ${0} ${0} ${0} ${0}
`),this.showTotalOnly?o.nothing:this.renderFilters(),s.H.isApiError(this.perDayAndCountryStatsSO.data)?(0,o.html)(j||(j=ot``),this.renderSpecialState("There was a problem",ut(this.perDayAndCountryStatsSO.data)?"The request timed out.":this.perDayAndCountryStatsSO.data.message)):this.perDayAndCountryStatsSO.isLoading||this.timeMetric.length?(0,o.html)(P||(P=ot` ${0} `),this.showTotalOnly?o.nothing:(0,o.html)(N||(N=ot`
Total Total of lookups${0}. Use the filters or drag the graph to select a specific timeframe. `),this.lookupsOnly?"":" and submissions"),this.timeMetric,this.localDateFilter,(0,f.Xp)(this.filters.date).start,(0,f.Xp)(this.filters.date).end,this.showLookups,this.showSubmissions,this.lookupsLegendLabelTooltipText,this.submissionsLegendLabelTooltipText,this.timeMetric.length?(0,o.html)(Y||(Y=ot` (*) Only displaying the lookups made by free accounts
`)):o.nothing,this.perDayAndCountryStatsSO.isLoading?this.renderSpinner():o.nothing,this.showTotalOnly?o.nothing:(0,o.html)(B||(B=ot`
By region Select a region to view the lookups from that region. ${0}
`),(0,a.classMap)({"loading-chart":this.perDayAndCountryStatsSO.isLoading}),this.visibleCountryMetric,this.countryFilter,this.order,this.showLookups,this.showSubmissions,this.countryMetric,20,u.chevronDownIcon,u.chevronUpIcon,this.visibleDataChanged,this.perDayAndCountryStatsSO.isLoading?this.renderSpinner():o.nothing)):(0,o.html)(q||(q=ot``),this.renderEmpty("There is no data registered for the selected filters")),this.showTotalOnly?o.nothing:(0,o.html)(U||(U=ot`
`)),this.showTotalOnly?o.nothing:(0,o.html)(z||(z=ot` ${0}
`),this.firstSightings.render({error:t=>s.H.isApiError(this.perDayAndCountryStatsSO.data)?o.nothing:this.renderFirstSightingsError(t),loading:()=>this.renderFirstSightingsLoading(),success:t=>this.renderFirstSightings(t),loadingMore:t=>this.renderFirstSightingsLoadingMore(t)})))}renderFirstSightingsError(t){return s.H.isApiError(this.perDayAndCountryStatsSO.data)?o.nothing:(0,o.html)(V||(V=ot``),this.renderSpecialState("There was a problem",ut(t)?"The request timed out.":t.message))}renderFirstSightingsTableHeader(){const t=this.showLookups===this.showSubmissions?"Lookups and submissions":this.showLookups?"Lookups":"Submissions";return(0,o.html)(X||(X=ot`Aggregated information ${0} that we have seen for this IoC geolocated in the selected timeframe
`),t)}renderFirstSightingsTable(t){return(0,o.html)(Q||(Q=ot` Date Region ${0} ${0} ${0}
`),this.showLookups?(0,o.html)(Z||(Z=ot`Lookups `)):o.nothing,this.showSubmissions?(0,o.html)(G||(G=ot`Submissions `)):o.nothing,t.map((t=>(0,o.html)(J||(J=ot` ${0} ${0} ${0} ${0} `),g.w9.parseDateShortFormat(t.day_timestamp),t.country,m.i.getCountryName(t.country),this.showLookups?(0,o.html)(W||(W=ot`${0} `),t.num_lookups):o.nothing,this.showSubmissions?(0,o.html)(K||(K=ot`${0} `),t.num_submissions):o.nothing))))}renderFirstSightingsLoading(){return(0,o.html)(tt||(tt=ot`${0} `),this.renderFirstSightingsTableHeader(),p.z.NeedsListSkeleton)}renderFirstSightings(t){return(0,o.html)(et||(et=ot`${0} ${0} ${0}`),this.renderFirstSightingsTableHeader(),0===t.length?(0,o.html)(it||(it=ot``),this.renderEmpty("There is no data registered for the selected filters")):this.renderFirstSightingsTable(t),this.firstSightings.hasMore?(0,o.html)(st||(st=ot`
`),(()=>{this.firstSightings.loadMore()})):o.nothing)}renderFirstSightingsLoadingMore(t){return(0,o.html)(rt||(rt=ot`${0} ${0}
`),this.renderFirstSightingsTableHeader(),this.renderFirstSightingsTable(t))}},_.styles=(0,o.unsafeCSS)(F.A),_);dt([(0,n.property)({type:Boolean})],pt.prototype,"showTotalOnly",void 0),dt([(0,n.property)({type:String})],pt.prototype,"lookupsLegendLabelTooltipText",void 0),dt([(0,n.property)({type:String})],pt.prototype,"submissionsLegendLabelTooltipText",void 0),dt([(0,n.property)({type:Boolean})],pt.prototype,"lookupsOnly",void 0),dt([(0,n.property)({type:Object})],pt.prototype,"params",void 0),dt([(0,n.property)()],pt.prototype,"endpoint",void 0),dt([(0,n.property)()],pt.prototype,"firstSightingsEndpoint",void 0),dt([(0,d.Q)()],pt.prototype,"perDayAndCountryStatsSO",void 0),dt([(0,n.state)()],pt.prototype,"localDateFilter",void 0),dt([(0,n.state)()],pt.prototype,"countryIndex",void 0),dt([(0,n.state)()],pt.prototype,"timeMetric",void 0),dt([(0,n.state)()],pt.prototype,"countryMetric",void 0),dt([(0,n.state)()],pt.prototype,"visibleCountryMetric",void 0),pt=dt([(0,n.customElement)("ioc-telemetry")],pt)},77698:(t,e,i)=>{i.d(e,{A1:()=>b,DT:()=>p,Xp:()=>m,ZG:()=>y,qf:()=>u});var s=i(69601),r=i(22894),o=i(13570),n=i(87347),a=i(96855);function l(t,e,i,s,r,o,n){try{var a=t[o](n),l=a.value}catch(t){return void i(t)}a.done?e(l):Promise.resolve(l).then(s,r)}function h(t){return function(){var e=this,i=arguments;return new Promise((function(s,r){var o=t.apply(e,i);function n(t){l(o,s,r,n,a,"next",t)}function a(t){l(o,s,r,n,a,"throw",t)}n(void 0)}))}}function c(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var s,r,o,n,a=[],l=!0,h=!1;try{if(o=(i=i.call(t)).next,0===e){if(Object(i)!==i)return;l=!1}else for(;!(l=(s=o.call(i)).done)&&(a.push(s.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(h)throw r}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return d(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?d(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,s=Array(e);it?Number.parseInt(t):void 0)),2),s=t[0],r=t[1];e.date={start:s,end:r}}break}case"country":{const i=t[r]||"";e.country=a.i.getCountryName(i)?i:null;break}}}return e},toQueryString:t=>Object.keys(t).filter((e=>{const i=t[e];return null!=i&&(!(i instanceof Set)||i.size>0)})).map((e=>{if("date"===e){const i=t.date;return[e,"object"==typeof i?`${i.start||""},${i.end||""}`:i]}return"showLookups"===e?["l",t[e].toString()]:"showSubmissions"===e?["s",t[e].toString()]:[e,t[e].toString()]})).reduce(((t,e)=>{let i=c(e,2),s=i[0],r=i[1];return t.append(s,r),t}),new URLSearchParams).toString()},v=t=>{var e,i;return{response:{data:(null===(e=t.data.attributes)||void 0===e?void 0:e.first_sightings)||[]},next:null!==(i=t.links)&&void 0!==i&&i.next?()=>r.h4.createSimpleRequest(r.h4.amendLinkHost(t.links.next)).then(v):void 0}};class f extends s._{constructor(t,e){super((0,r.uv)((()=>e(t).then(v)),2),(t=>t))}}class b{constructor(t,e,i){this.host=t,this.endpoint=e,this.args=i,this.host.addController(this)}hostUpdate(){var t=this;return h((function*(){const e=t.endpoint();if(!e)return;const i=t.args(),s=t.previousArgs;t.previousArgs=i,i===s||void 0===i||void 0!==s&&JSON.stringify(s)===JSON.stringify(i)||(t.smartCollection=new f(i,e),t.smartCollection.subscribe((()=>t.host.requestUpdate())),t.safeLoad(t.smartCollection.load()))}))()}safeLoad(t){var e=this;return h((function*(){e.error=void 0,e.host.requestUpdate();try{return yield t}catch(t){if(!o.H.isApiError(t))throw t;e.error=t,e.host.requestUpdate()}}))()}get hasMore(){var t;return null===(t=this.smartCollection)||void 0===t?void 0:t.hasMore}loadMore(){var t=this;return h((function*(){if(t.smartCollection)return yield t.safeLoad(t.smartCollection.loadMore())}))()}get isLoading(){var t;return null===(t=this.smartCollection)||void 0===t?void 0:t.isLoading}get isEmpty(){return!this.smartCollection||0===this.smartCollection.data.length}render(t){var e,i,s,r,o;return this.smartCollection?this.error?null===(i=t.error)||void 0===i?void 0:i.call(t,this.error,this.smartCollection.data):this.smartCollection.isLoading?0===this.smartCollection.data.length?null===(r=t.loading)||void 0===r?void 0:r.call(t):null===(o=t.loadingMore)||void 0===o?void 0:o.call(t,this.smartCollection.data):null===(s=t.success)||void 0===s?void 0:s.call(t,this.smartCollection.data):null===(e=t.initialState)||void 0===e?void 0:e.call(t)}}},67668:(t,e,i)=>{var s=i(87347),r=i(48704),o=i(16645),n=i(62832),a=i(96855),l=i(96987),h=i(1061),c=i(42408);let d,u,p,m,g,y,v,f,b=t=>t;var S=function(t,e,i,s){var r,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);return o>3&&n&&Object.defineProperty(e,i,n),n};const w=25,$=8.5,L=150,O=40,k=20,A=40;let C=(d=class extends r.LitElement{constructor(){super(...arguments),this.data=[],this.countryFilter=null,this.showLookups=!0,this.showSubmissions=!0,this.width=611,this.height=800,this.xScale=(0,s.m4Y)(),this.yScale=(0,s.WH)(),this.xTicks=this.xScale.ticks(5),this.xAxis=(0,s.tlR)(this.xScale),this.yAxis=(0,s.V4s)(this.yScale).tickFormat((t=>a.i.getCountryShortName(t))).tickSize(0).tickPadding(10),this.resizeObserver=new ResizeObserver((()=>{0!==this.offsetWidth&&(this.width=this.offsetWidth)}))}connectedCallback(){super.connectedCallback(),this.resizeObserver.observe(this)}disconnectedCallback(){this.resizeObserver.disconnect(),super.disconnectedCallback()}updated(t){t.has("data")&&(this.height=this.data.length*w+A+k),(0,s.Ltv)(this.shadowRoot.querySelector("#top-axis")).call(this.xAxis),(0,s.Ltv)(this.shadowRoot.querySelector("#left-axis")).call(this.yAxis)}render(){return this.data.length?(this.xScale.range([0,this.width-L-O]),this.yScale.range([0,this.height-A-k]),this.xScale.domain([0,(0,s.T9B)([...this.showLookups?this.data.map((t=>t.metrics[0])):[],...this.showSubmissions?this.data.map((t=>t.metrics[1])):[]])||1]),this.yScale.domain(this.data.map((t=>t.country))),this.xTicks=this.xScale.ticks(5).filter((t=>Number.isInteger(t))),this.xAxis=(0,s.tlR)(this.xScale).tickValues(this.xTicks).tickSize(0).tickPadding(10).tickFormat((t=>l.w9.humanizeCount(t.valueOf()))),(0,r.html)(u||(u=b` ${0}
`),(0,r.svg)(p||(p=b`
${0} ${0}
`),this.width,this.height,this.renderBars(),this.renderAxes()))):r.nothing}renderBars(){return(0,r.svg)(m||(m=b`
${0}
`),L,O,this.data.map((t=>(0,r.svg)(g||(g=b`
${0}
${0}
`),this.yScale(t.country),w,this.showLookups?(0,r.svg)(y||(y=b`
${0}
`),this.showSubmissions?3:8.25,(0,n.classMap)({selected:t.country===this.countryFilter}),1,this.xScale(t.metrics[0]),(0,n.classMap)({selected:t.country===this.countryFilter}),$,this.xScale(t.metrics[0]),this.xScale(t.metrics[0])+5,7,l.w9.humanizeCount(t.metrics[0])):r.nothing,this.showSubmissions?(0,r.svg)(v||(v=b`
${0}
`),this.showLookups?13.5:8.25,(0,n.classMap)({selected:t.country===this.countryFilter}),1,this.xScale(t.metrics[1]),(0,n.classMap)({selected:t.country===this.countryFilter}),$,this.xScale(t.metrics[1]),this.xScale(t.metrics[1])+5,7,l.w9.humanizeCount(t.metrics[1])):r.nothing,(0,n.classMap)({interaction:!0}),w,this.width-L-O,(()=>this.filter(t.country))))))}filter(t){this.countryFilter===t?this.dispatchEvent((0,h.Zs)({by:"country",payload:null})):this.dispatchEvent((0,h.Zs)({by:"country",payload:{country:t}}))}renderAxes(){return(0,r.html)(f||(f=b` `),this.width,this.height,L,A,L,A)}},d.styles=(0,r.unsafeCSS)(c.A),d);S([(0,o.property)({type:Array})],C.prototype,"data",void 0),S([(0,o.property)({type:String})],C.prototype,"countryFilter",void 0),S([(0,o.property)({type:Boolean})],C.prototype,"showLookups",void 0),S([(0,o.property)({type:Boolean})],C.prototype,"showSubmissions",void 0),S([(0,o.property)({type:Number})],C.prototype,"width",void 0),S([(0,o.state)()],C.prototype,"height",void 0),C=S([(0,o.customElement)("vt-ui-countries-chart")],C)},22685:(t,e,i)=>{var s=i(89547),r=i.n(s),o=i(38532),n=i.n(o),a=i(88869),l=n()(r());l.i(a.A),l.push([t.id,"",""]),e.A=l},26416:(t,e,i)=>{var s=i(89547),r=i.n(s),o=i(38532),n=i.n(o),a=i(88869),l=n()(r());l.i(a.A),l.push([t.id,".loading-chart{min-height:490px}",""]),e.A=l},42408:(t,e,i)=>{var s=i(89547),r=i.n(s),o=i(38532),n=i.n(o),a=i(88869),l=n()(r());l.i(a.A),l.push([t.id,"rect{transition:width var(--vt-transitions, 500ms)}rect.area{fill-opacity:.2}.fill-info{fill:var(--bs-info)}.fill-info-alt{fill:var(--bs-info-text-emphasis)}rect.selected{fill-opacity:1}rect.interaction{fill-opacity:0}rect.interaction:hover{fill-opacity:.1;fill:var(--bs-secondary);cursor:pointer}svg{color:var(--bs-tertiary-color)}svg text{font-family:var(--bs-font-monospace);font-size:10px}g{transition:transform var(--vt-transitions, 500ms)}",""]),e.A=l}}]);
//# sourceMappingURL=13420.5adf94b23972584697b2.js.map