PageSourceSearch

https://amensagem.pt/wp-content/plugins/rua-news/public/main.bundle.js?ver=2.1.1

js amensagem.pt collected 2026-10-02 03:24:58 UTC 31,391 bytes, 1 lines download raw bytes

1(()=>{"use strict";const e=()=>{if(!window.L)return;const e="undefined"!=typeof ruaGlobalVars&&ruaGlobalVars?.pluginUrl?ruaGlobalVars.pluginUrl:window.ruaGlobalVars?.pluginUrl?window.ruaGlobalVars.pluginUrl:null;if(!e)return;const t=e.replace(/\/$/,"");delete L.Icon.Default.prototype._getIconUrl,L.Icon.Default.imagePath="",L.Icon.Default.mergeOptions({iconUrl:`${t}/assets/img/leaflet/marker-icon.png`,iconRetinaUrl:`${t}/assets/img/leaflet/marker-icon-2x.png`,shadowUrl:`${t}/assets/img/leaflet/marker-shadow.png`,iconSize:[25,26],iconAnchor:[12,26],popupAnchor:[0,-26],shadowSize:[41,41],shadowAnchor:[12,41]})};e();const t=()=>{jQuery((()=>{jQuery(".js-apregoar-option-switch").on("click",(function(){jQuery(this).siblings().removeClass("active"),jQuery(this).addClass("active")}))}))},s=(e,t=!1)=>null==e?"":(e+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+(t||void 0===t?"<br />":"<br>")+"$2"),r=()=>window.innerWidth<ruaGlobalVars.desktopWidth;class a{static async _fetch(e){const t=new URLSearchParams;for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const r=e[s];Array.isArray(r)?r.forEach((e=>{t.append(`${s}[]`,e)})):t.append(s,r)}try{const e=await fetch(ruaGlobalVars.ajaxUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return await e.text()}catch(e){throw console.error("API Service Fetch Error:",e),e}}static getStory(e){return this._fetch({action:"get_story",post_id:e})}static getAuthors(){return this._fetch({action:"get_filter_authors"})}static getStories(e){return this._fetch({action:"get_stories",...e})}}const i=e=>JSON.parse(JSON.stringify(e));class o{static unpackStories(e,t=!0,s=!0){const r=i(e);let a=[],o=[];const n=[];for(const e of r){const r=e.happenings||[];if(s&&delete e.happenings,0===r.length){t||n.push(e);continue}const i=[];for(const e of r){const r=e.locations||[];s&&delete e.locations,0!==r.length?(o.push(...r),i.push(e)):t||i.push(e)}i.length>0?(a.push(...i),s||(e.happenings=i),n.push(e)):t||n.push(e)}return{stories:n,happenings:a,locations:o}}static getLocsFromStories(e,t){let s=[];if(!e)return s;for(const r of e)if(r?.happenings?.length)for(const e of r.happenings)if(e?.locations?.length)for(const a of e.locations){const o=i(a);o.name=r.title,o.date=r.formatted_date,o.url=r.url,o.urlText=t,o.description=r.summary,o.storyID=r.id,o.happening||(o.happening=e.id),s.push(o)}return s}}class n{constructor(e,t={}){this.container=e;const s=Object.fromEntries(Object.entries(t).filter((([e,t])=>null!==t)));this.settings={...this.getDefaultSettings(),...s},this.map=null,this.drawnFeaturesLayer=null,this.markerClusterGroup=null,this.locationLayerGroups={},this.isRendered=!1,this.currentlyHighlightedLayers=new Set,this.currentlyHoveredLayer=null,this.mouseMoveTimeout=null}getDefaultSettings(){return{lat:ruaGlobalVars.defaultCenter[0],lng:ruaGlobalVars.defaultCenter[1],zoom:ruaGlobalVars.defaultZoomOverview,centerOnResults:!1,tileKey:ruaGlobalVars.tileKey,summaryLength:ruaGlobalVars.summaryLength,i18n:ruaGlobalVars.i18n,onFeatureClick:null,isEditable:!1}}render(){if(this.isRendered)return;const e=[this.settings.lat,this.settings.lng];this.map=L.map(this.container,{preferCanvas:!0,maxZoom:20,doubleClickZoom:!1}),this.map.setMaxBounds([[-90,-180],[90,180]]),L.maptilerLayer({apiKey:this.settings.tileKey,noWrap:!0,style:"openstreetmap"}).addTo(this.map),this.map.setView(e,this.settings.zoom),this.drawnFeaturesLayer=new L.FeatureGroup,this.markerClusterGroup=L.markerClusterGroup({iconCreateFunction:e=>this._createClusterIcon(e)}),this.map.addLayer(this.drawnFeaturesLayer),this.map.addLayer(this.markerClusterGroup),new ResizeObserver((()=>{this.invalidateSize()})).observe(this.container),this.settings.isEditable&&this._addLeafletDraw(),this._addMapClickHandler(),this._addMapHoverHandler(),this.isRendered=!0}invalidateSize(){this.map&&this.map.invalidateSize()}renderLocations(e,t=!0){if(this.map&&(this.map.closePopup(),t&&(this.drawnFeaturesLayer.clearLayers(),this.markerClusterGroup.clearLayers(),this.locationLayerGroups={}),e&&e.length)){for(const t of e)t?.geojson?.properties&&(t.resultID=t.happening,t.urlText||(t.urlText=this.settings.i18n.goToStory+" →"),this.drawFeature(t));t&&this.settings.centerOnResults&&this.fitBounds()}}fitBounds(){const e=this.drawnFeaturesLayer.getBounds();e.isValid()&&this.map.fitBounds(e)}drawFeature(e){const t=e?.geojson?.properties?.mapFeatureType||e?.geojson?.geometry?.type,s=this._drawFromGeoJSON(e.geojson,t);this.locationLayerGroups[e.resultID]?this.locationLayerGroups[e.resultID].addLayer(s):this.locationLayerGroups[e.resultID]=s,s.eachLayer((s=>{s.meta={name:e?.name,description:e?.description,resultID:e?.resultID,storyID:e?.storyID,date:e?.date,url:e?.url,urlText:e?.urlText,center:e?.marker?JSON.parse(e.marker).coordinates:null},s.setStyle&&"function"==typeof s.setStyle&&(s.originalStyle={color:s.options.color||"#3388ff",fillColor:s.options.fillColor||"#3388ff",fillOpacity:s.options.fillOpacity||.2,weight:s.options.weight||3,opacity:s.options.opacity||1}),s.on("click",(e=>this.featureClickHandler(e))),this.layerBindPopup(s),"Point"!==t&&this.addMarker(s)}))}featureClickHandler(e){this.settings.onFeatureClick&&"function"==typeof this.settings.onFeatureClick&&this.settings.onFeatureClick(e)}layerBindPopup(e){const t=this.getPopupMarkup(e);e.meta.defaultPopup=t,e.bindPopup(t)}getPopupMarkup(e){let t="";const{name:s="",description:r="",url:a="",urlText:i="",date:o=""}=e?.meta||{},{summaryLength:n}=this.settings;if(s.trim().length&&(t=`<div><b>${s.trim()}</b></div>`),o.trim().length&&(t+=`<div>${o.trim()}</div>`),r.trim().length){let e=r.trim().replaceAll('"',"&quot;");e.length>n&&(e=`${e.substring(0,n)}...`),t+=`<div>
1${e.replace(/\\n/g,"<br>").trim()}</div>`}return a&&a.trim().length&&i.trim().length&&(t+=`<div class="apregoar-spaced"><a href="${a.trim()}">${i.trim()}</a></div>`),e?.meta?.center&&2===e.meta.center.length&&(t+=`\n\t\t\t<div class="apregoar-spaced apregoar-map-directions">\n\t\t\t\t<a href="https://www.google.com/maps/dir/?api=1&destination=${e?.meta?.center[1]},${e?.meta?.center[0]}" target="_blank">\n\t\t\t\t\t${ruaGlobalVars.i18n.getDirections} (Google Maps)\n\t\t\t\t</a>\n\t\t\t</div>`),t}addMarker(t){const s=t.getBounds().getCenter();for(const e of this.markerClusterGroup.getLayers()){const t=e.getLatLng();if(t&&s&&t.equals(s))return}e();const r=L.marker(s);r.meta={...t.meta,autoMarker:!0},r.originalIcon=r.getIcon(),r.isHighlighted=!1,r.addTo(this.markerClusterGroup),r.on("click",(e=>this.featureClickHandler(e))),this.layerBindPopup(r)}highlightFeatures(e,t=!0,s=!1){if(!this.map)return;const r=[];this.currentlyHighlightedLayers=new Set,this.currentlyHoveredLayer&&this.currentlyHoveredLayer.originalStyle&&this.currentlyHoveredLayer.setStyle(this.currentlyHoveredLayer.originalStyle),this.currentlyHoveredLayer=null;const a={color:"#ff4444",fillColor:"#ff4444",fillOpacity:.4,weight:4,opacity:1},i=t=>{const i=e&&(s?t?.meta?.storyID===e:t?.meta?.resultID===e);if(t instanceof L.Marker)if(i&&e){const e=L.icon({iconUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAjCAYAAADxG9hnAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAABnJJREFUeAHFV1tsFFUYPjO7s7vdXmiBUroWWZqCUtA0tgQNphQUrxBrpAhJI40pDxQjlqTGB5tSeRIfbCI8iYGaEAmoEIMJxkjbBB5LpYgKNts1Yi9pQy97v47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,r.push(t)}else t.originalIcon&&t.setIcon(t.originalIcon),t.isHighlighted=!1;else t.setStyle&&"function"==typeof t.setStyle&&(i&&e?(t.setStyle(a),t.bringToFront(),r.push(t),this.currentlyHighlightedLayers.add(t)):t.originalStyle&&t.setStyle(t.originalStyle))};if(this.drawnFeaturesLayer.eachLayer(i),this.markerClusterGroup.eachLayer(i),t&&r.length>0){const e=new L.featureGroup(r).getBounds();e.isValid()&&this.map.fitBounds(e,{paddingTopLeft:[40,40],paddingBottomRight:[40,40]})}this.markerClusterGroup&&this.markerClusterGroup.refreshClusters()}_addLeafletDraw(){const e=new L.Control.Draw({edit:{featureGroup:this.drawnFeaturesLayer,allowIntersection:!1},draw:{polygon:{allowIntersection:!1,showArea:!0},polyline:{allowIntersection:!1},circlemarker:!1}});this.map.addControl(e)}_drawFromGeoJSON(e,t){let s;return"MultiPolygon"!==e?.geometry?.type&&"MultiPolygon"!==e.type||(e?.geometry?e.geometry.coordinates:e.coordinates).forEac
1h((s=>{const r=i(e);return r.geometry={type:"Polygon",coordinates:s},this._drawFromGeoJSON(r,t)})),s="Circle"===t?L.geoJSON(e,{pointToLayer:(e,t)=>new L.circle(t,{radius:e.properties.radius})}):L.geoJSON(e),s.eachLayer((e=>{e.isFromGeoJSON=!0,this.drawnFeaturesLayer.addLayer(e)})),s}_addMapClickHandler(){this.map.on("click",(e=>{let t=!1;this.drawnFeaturesLayer.eachLayer((s=>{t||(s.getBounds?s.getBounds().contains(e.latlng)&&(t=!s.feature||!s.feature.geometry||"function"!=typeof s.contains||s.contains(e.latlng)):s.getLatLng&&e.latlng.distanceTo(s.getLatLng())<50&&(t=!0))})),t||this.markerClusterGroup.eachLayer((s=>{if(!t&&s.getLatLng){const r=this.map.latLngToContainerPoint(e.latlng),a=this.map.latLngToContainerPoint(s.getLatLng());Math.sqrt(Math.pow(r.x-a.x,2)+Math.pow(r.y-a.y,2))<30&&(t=!0)}})),t||(this.highlightFeatures(null),this.settings.onEmptyAreaClick&&"function"==typeof this.settings.onEmptyAreaClick&&this.settings.onEmptyAreaClick())}))}_addMapHoverHandler(){const e={color:"#ff8800",fillColor:"#ff8800",fillOpacity:.3,weight:3,opacity:1};this.map.on("mousemove",(t=>{this.mouseMoveTimeout&&clearTimeout(this.mouseMoveTimeout),this.mouseMoveTimeout=setTimeout((()=>{const s=[];this.drawnFeaturesLayer.eachLayer((e=>{if(e.getBounds&&e.getBounds().contains(t.latlng)){let r=!0;if(e.feature&&e.feature.geometry&&"function"==typeof e.contains&&(r=e.contains(t.latlng)),r){const t=e.getBounds(),r=(t.getEast()-t.getWest())*(t.getNorth()-t.getSouth());s.push({layer:e,area:r})}}}));let r=null;s.length>0&&(s.sort(((e,t)=>e.area-t.area)),r=s[0].layer),r!==this.currentlyHoveredLayer&&(this.currentlyHoveredLayer&&!this.currentlyHighlightedLayers.has(this.currentlyHoveredLayer)&&this.currentlyHoveredLayer.originalStyle&&this.currentlyHoveredLayer.setStyle(this.currentlyHoveredLayer.originalStyle),r&&!this.currentlyHighlightedLayers.has(r)&&(r.setStyle(e),r.bringToFront()),this.currentlyHoveredLayer=r)}),16)})),this.map.on("mouseout",(()=>{this.currentlyHoveredLayer&&!this.currentlyHighlightedLayers.has(this.currentlyHoveredLayer)&&this.currentlyHoveredLayer.originalStyle&&this.currentlyHoveredLayer.setStyle(this.currentlyHoveredLayer.originalStyle),this.currentlyHoveredLayer=null}))}_createClusterIcon(e){const t=e.getAllChildMarkers(),s=t.length;let r="small";s>=100?r="large":s>=10&&(r="medium");const a=`${t.some((e=>!0===e.isHighlighted))?"marker-cluster-highlighted":"marker-cluster"}-${r}`;return new L.DivIcon({html:`<div><span>${s}</span></div>`,className:`marker-cluster ${a}`,iconSize:new L.Point(40,40)})}}const l=jQuery;class h{constructor(e){this.container=e,this.container&&(this.$container=l(this.container),this.$sidebar=this.$container.find(".js-apregoar-sidebar"),this.$sidebarShow=l(".js-apregoar-sidebar-show"),this.$sidebarHide=this.$container.find(".js-apregoar-sidebar-hide"),this.$sidebarExploreBtn=this.$container.find(".js-apregoar-sidebar-explore"),this.$sidebarSearchBtn=this.$container.find(".js-apregoar-sidebar-search"),this.$filtersArea=this.$container.find(".js-apregoar-filters-area"),this.$exploreContainer=this.$container.find(".js-apregoar-explore-container"),this.$searchContainer=this.$container.find(".js-apregoar-search-container"),this.$searchResultsListActions=this.$container.find(".js-apregoar-search-happenings-actions, .js-apregoar-search-stories-actions"),this.$filterAuthors=this.$container.find(".js-apregoar-filters-authors"),this.$searchLoadMore=this.$container.find(".js-apregoar-search-happenings-load-more, .js-apregoar-search-stories-load-more"),this.resultTemplate=l(".js-apregoar-result-template").html(),this.$nearbyLoadMore=this.$container.find(".js-apregoar-nearby-stories-load-more"),this.$nearbyResultsListActions=this.$container.find(".js-apregoar-nearby-stories-actions"),this.ruaMap=null,this.activeResultId=null,this.isFiltersVisible=!1,this.isExploreVisible=!1,this.exploreHappenings=null,this.nearbyStories=null,this.newNearbyStories=null,this.nearbyHappenings=null,this.nearbyPageNum=1,this.nearbyHasNext=!1,this.searchHappenings=null,this.searchStories=null,this.searchHasNext=!1,this.searchPageNum=1,this.currentLocs=[],this.exploreLocs=[],this.nearbyLocs=[],this.searchLocs=[],this.firstSearch=!0,this._init())}async _init(){if(!await this._loadExploreData())return void this.$container.remove();this._bindEvents(),this._initMap(),this.$exploreContainer.scrollTop(0),this.$filtersArea.scrollTop(0);const e=this.$container.find(".js-apregoar-explore-happenings");this._renderResults("happening",this.exploreHappenings,e,"related"),this._toggleResults(e,this.$container.find(".js-apregoar-nearby-stories"));const t=this.exploreHappenings&&this.exploreHappenings.length>0,s=this.exploreLocs&&this.exploreLocs.length>0;t&&s?(this.$sidebar.addClass("has-happenings"),this.$sidebarShow.addClass("active")):(this.$exploreContainer.remove(),this.$sidebarExploreBtn.remove()),(t&&s||r())&&this.$sidebarSearchBtn.addClass("active"),this._toggleLoading(this.$filterAuthors,!0);const i=JSON.parse(await a.getAuthors());if(this._toggleLoading(this.$filterAuthors,!1),i.data)for(const e of i.data)this.$filterAuthors.append(`<option value="${e.id}">${e.name}</option>`);this.$container.addClass("active")}_initMap(){if(this.ruaMap)return;const e=this.$container.find(".js-apregoar-sidebar-map"),t={centerOnResults:!0,onFeatureClick:e=>this._featureClickHandler(e),onEmptyAreaClick:()=>this._emptyAreaClickHandler()};this.ruaMap=new n(e[0],t),this.ruaMap.render(),this.currentLocs=this.exploreLocs,this.ruaMap.renderLocations(this.currentLocs)}_bindEvents(){l(".js-apregoar-search-show, .js-apregoar-overview-search").on("click",(async()=>{this._toggleSidebar(!0),this._toggleFilters(!0)})),this.$sidebarShow.on("click",(()=>{this._toggleSidebar(!0),this.currentLocs=this.exploreLocs,this._updateMap(!0)})),this.$container.on("click",".js-apregoar-sidebar-hide",(()=>{this._toggleSidebar(!1)})),this.$container.on("click",".js-apregoar-sidebar-search",(()=>{this._toggleFilters()})),this.$container.on("click",".js-apregoar-sidebar-explore",(()=>{this._toggleExplore()})),this.$container.on("click",".js-apregoar-close-container",(()=>{this.isFiltersVisible?this._toggleFilters(!1):(this.isExploreVisible||this._toggleFilters(!1),this._toggleExplore(!1))})),this.$container.on("click",".js-apregoar-filters-header",(()=>{this._toggleFilters()})),this.$container.on("click",".js-apregoar-explore-header",(()=>{this._toggleExplore()})),this.$container.on("click",".js-apregoar-filters-apply",(()=>{this._search(1)})),this.$container.on("click",".js-apregoar-search-stories-load-more, .
1js-apregoar-search-happenings-load-more",(()=>{this.searchPageNum++,this._search(this.searchPageNum)})),this.$container.on("click",".js-apregoar-filters-date-default",(e=>{this._showDateInput(l(e.currentTarget))})),this.$container.on("click",".js-apregoar-nearby-stories-load-more",(async()=>{this._toggleLoading(this.$nearbyLoadMore,!0),this.nearbyPageNum++,await this._loadNearbyData(this.nearbyPageNum),this.currentLocs=this.nearbyLocs,this._renderNearbyLocs(),this._toggleLoading(this.$nearbyLoadMore,!1)})),this.$container.on("click",".js-apregoar-result-loc-btn",(e=>{const t=l(e.currentTarget).data("result-id");if(!t)return;const s=l(e.currentTarget).closest(".js-apregoar-result").closest(".js-apregoar-search-stories, .js-apregoar-nearby-stories").length>0;if(this.setActiveResult(t,!1,!0,s),r()){const e=t,r=s;this.$container.find(".js-apregoar-sidebar-story-area").animate({scrollTop:0},500),this._toggleExplore(!1),this._toggleFilters(!1),setTimeout((()=>{this.setActiveResult(e,!1,!1,r)}),100)}})),this.$container.on("click",".js-apregoar-switch-explore-happenings",(()=>{this.currentLocs=this.exploreLocs,this._updateMap(!0),this._toggleResults(this.$container.find(".js-apregoar-explore-happenings"),this.$container.find(".js-apregoar-nearby-stories"))})),this.$container.on("click",".js-apregoar-switch-nearby-stories",(async e=>{const t=l(e.currentTarget);this._toggleResults(this.$container.find(".js-apregoar-nearby-stories"),this.$container.find(".js-apregoar-explore-happenings")),ruaGlobalVars.postID&&!this.nearbyStories&&(t.prop("disabled",!0),this.nearbyStories=[],this._toggleLoading(this.$container.find(".js-apregoar-nearby-stories"),!0),await this._loadNearbyData(1),this._toggleLoading(this.$container.find(".js-apregoar-nearby-stories"),!1),t.prop("disabled",!1),this._renderNearbyLocs()),this.currentLocs=this.nearbyLocs,this._updateMap(!0)})),this.$container.on("click",".js-apregoar-switch-search-happenings",(()=>{this.currentLocs=this.searchLocs,this._toggleResults(this.$container.find(".js-apregoar-search-happenings"),this.$container.find(".js-apregoar-search-stories"))})),this.$container.on("click",".js-apregoar-switch-search-stories",(()=>{this.currentLocs=this.searchLocs,this._toggleResults(this.$container.find(".js-apregoar-search-stories"),this.$container.find(".js-apregoar-search-happenings"))}))}setActiveResult(e,t=!0,s=!0,a=!1){this.activeResultId=e;const i="js-apregoar-result";if(this.$container.find(`.${i}`).removeClass("active"),e){const s=this.$container.find(`.${i}[data-result-id="${e}"]`);if(s.addClass("active"),!r()&&t){const e=s.closest(".js-apregoar-explore-container, .js-apregoar-filters-area");e.length&&e.animate({scrollTop:e.scrollTop()-e.offset().top+s.offset().top-20},500)}}this.ruaMap&&this.ruaMap.highlightFeatures(e,s,a)}_featureClickHandler(e){const t=e?.target?.meta?.resultID,s=e?.target?.meta?.storyID;if(!t)return;let r,a;const i=this.isFiltersVisible&&this.$container.find(".js-apregoar-switch-search-stories").hasClass("active"),o=this.$container.find(".js-apregoar-switch-nearby-stories").hasClass("active");(i||o)&&s?(r=s,a=!0):(r=t,a=!1),this.setActiveResult(r,!0,!1,a)}_emptyAreaClickHandler(){this.setActiveResult(null)}_toggleSidebar(e=null){this.$sidebar.toggleClass("active",e).removeClass("filters-active"),this.$filtersArea.removeClass("active"),this.isFiltersVisible=!1,this.ruaMap&&this.$sidebar.one("transitionstart",(()=>{this.ruaMap.invalidateSize(),this.ruaMap.fitBounds()}))}_toggleFilters(e=null){this.isFiltersVisible=null===e?!this.isFiltersVisible:e,this.isFiltersVisible?(this._toggleExplore(!1),this.currentLocs=this.searchLocs,this.firstSearch&&this._search(1)):this.searchLocs&&this.searchLocs.length>0?this.currentLocs=this.searchLocs:this.currentLocs=this.exploreLocs,this.$sidebar.toggleClass("filters-active",this.isFiltersVisible),this.$filtersArea.toggleClass("active",this.isFiltersVisible),this.$searchResultsListActions.toggleClass("active",this.isFiltersVisible&&this.searchHasNext),r()&&this.$filtersArea.scrollTop(0),this.setActiveResult(null),this._updateMap(!0)}_toggleExplore(e=null){if(this.isExploreVisible=null===e?!this.isExploreVisible:e,this.$exploreContainer.toggleClass("active",this.isExploreVisible),this.isExploreVisible){const e=this.$container.find(".js-apregoar-switch-explore-happenings").hasClass("active")?"explore":"nearby";this.currentLocs="explore"===e?this.exploreLocs:this.nearbyLocs,this._updateMap()}else{const e=this.$container.find(".js-apregoar-switch-explore-happenings").hasClass("active")?"explore":"nearby";this.currentLocs="explore"===e?this.exploreLocs:this.nearbyLocs,this._updateMap(!0)}this.$exploreContainer.animate({scrollTop:0},500)}_renderResults(e,t,r,a,i=!1){if(!t||!r.length)return;const o=r.find(".js-apregoar-results-header-label");let n="";for(const[r,a]of t.entries()){const t="story"===e?a.formatted_authors:"",i=!a?.online;n+=this.resultTemplate.replace(/{{id}}/g,a.id).replace(/{{classJs}}/g,"js-apregoar-result").replace(/{{num}}/g,r).replace(/{{url}}/g,a.url).replace(/{{thumbnailUrl}}/g,a.thumbnail_url??"").replace(/{{thumbnailClass}}/g,a.thumbnail_url?"active":"").replace(/{{title}}/g,`${a.title}`).replace(/{{classActiveDate}}/g,a.formatted_date?"active":"").replace(/{{classActiveAuthor}}/g,"story"===e?"active":"").replace(/{{classBtnHighlightLocs}}/g,"js-apregoar-result-loc-btn "+(i?"active":"")).replace(/{{date}}/g,a.formatted_date).replace(/{{authors}}/g,t).replace(/{{description}}/g,"story"===e?a.formatted_summary:s(a.description)).replace(/{{classActiveStoryCta}}/g,"story"===e?"active":"")}const l=r.find(".js-apregoar-results");i?l.append(n):l.html(n);const h=(i?parseInt(o.html()?.split(" ")[0]||0):0)+t.length,c=1===t.length?`${a}-singular`:`${a}-plural`;o.html(`${h} ${o.data(c)}`)}_toggleResults(e,t){e.addClass("active"),t.removeClass("active")}async _loadExploreData(){if(ruaGlobalVars.postID){this._toggleLoading(this.$filterAuthors,!0);const e=JSON.parse(await a.getStory(ruaGlobalVars.postID));if(this._toggleLoading(this.$filterAuthors,!1),!e?.data?.story?.happenings)return!1;if(this.exploreHappenings=e.data.story.happenings,this.exploreHappenings){const e=this.exploreHappenings.flatMap((e=>!e.online&&e.locations?e.locations.map((e=>({...e,storyID:ruaGlobalVars.postID}))):[]));this.exploreLocs=this.exploreLocs.concat(e)}}return!0}async _loadNearbyData(){this._toggleLoading(this.$container.find(".js-apregoar-nearby-stories"),!0);const e=JSON.parse(await a.getStories({cms_post_id:ruaGlobalVars.postID,nearby_distance:ruaGlobalVars.nearbyDistance,page_num:this.nearbyPageNum}));if(this._toggleLoading(this.$container.find(".js-apregoar-nearby-stories"),!1),e?.data?.stories&&0!==e?.data?.stories?.length){this.newNearbyStories=e.data.stories,this.nearbyHasNext=e.data.has_next,this.nearbyStories=this.nearbyStories.concat(this.newNearbyStories),this.$nearbyResultsListActions.toggleClass("active",this.nearbyHasNext);for(const e of this.newNearbyStories)if(e?.happenings){this.nearbyHappenings=e?.happenings;for(const t of this.nearbyHappenings){let s=[];for(const r of t.locations)r.happening=e.happenings[0].id,r.storyID=e.id,r.url=e.url,r.urlText=l(".js-apregoar-story-url-text").html(),s.push(r);this.nearbyLocs=this.nearbyLocs.concat(s)}}}}async _search(e=1){this.searchPageNum=e;const t=this.$container.find(".js-apregoar-filters-apply");t.prop("disabled",!0);const s=1===this.searchPageNum?this.$searchContainer:this.$searchLoadMore;this._toggleLoading(s,!0),this._toggleNoticeNoResults(!1),await this._loadSearchData(),this._renderSearchResults(),this._toggleLoading(s,!1),t.prop("disabled",!1),this.firstSearch&&(this.firstSearch=!1)}async _loadSearchData(){const e=e=>this.$container.find(e).val(),t=e=>this.$container.find(e).prop("checked")?"1":"0",s={per_page:20,page_num:this.searchPageNum,locations:[e(".js-apregoar-filters-location")],keywords:[e(".js-apregoar-filters-keywords")],authors:[e(".js-apregoar-filters-authors")],tags:e(".js-apregoar-filters-tags").split(","),date_type:null,created_at_from:e(".js-apregoar-filters-published-from"),created_at_from_active:t(".js-apregoar-filters-published-from-active"),created_at_from_use_default:e(".js-apregoar-filters-published-from-use-default"),created_at_to:e(".js-apregoar-filters-published-to"),created_at_to_active:t(".js-apregoar-filters-published-to-active"),created_at_to_use_default:e(".js-apregoar-filters-published-to-use-default"),happening_from:e(".js-apregoar-filters-happening-from"),happening_from_active:t(".js-apregoar-filters-happening-from-active"),happening_from_use_default:e(".js-apregoar-filters-happening-from-use-default"),happening_to:e(".js-apregoar-filters-happening-to"),happening_to_active:t(".js-apregoar-filters-happening-to-active"),happening_to_use_default:e(".js-apregoar-filters-happening-to-use-default")},r=JSON.parse(await a.getStories(s)),i=r?.data?.stories;if(i?.length){const e=o.unpackStories(i,!1,!1);this.searchHasNext=r.data.has_next,this.searchHappenings=e.happenings,this.searchStories=e.stories;const t=this.$container.find(".js-apregoar-story-url-text").html()||"",s=o.getLocsFromStories(i,t).map((e=>{const t=i.find((t=>t.happenings&&t.happenings.some((t=>
1t.id===e.happening))));return{...e,storyID:t?t.id:null}}));this.searchLocs=1===this.searchPageNum?s:this.searchLocs.concat(s)}else this.searchHappenings=[],this.searchStories=[],this.searchLocs=[];this.currentLocs=this.searchLocs}_renderSearchResults(){const e=this.$container.find(".js-apregoar-search-stories"),t=this.$container.find(".js-apregoar-search-happenings"),s=this.searchPageNum>1;this._renderResults("story",this.searchStories??[],e,"search",s),this._renderResults("happening",this.searchHappenings??[],t,"search",s),this.$searchResultsListActions.toggleClass("active",this.searchHasNext),this._updateMap(!0),this.$searchContainer.addClass("active"),1===this.searchPageNum&&(this._toggleResults(t,e),this.$container.find(".js-apregoar-switch-search-happenings").trigger("click"));const r=this.searchHappenings?.length>0||this.searchStories?.length>0;this.$filtersArea.find(".js-apregoar-switch").toggleClass("active",r),this._toggleNoticeNoResults(!r&&!s)}_renderNearbyLocs(){this._updateMap(!0,!0),this._renderResults("story",this.newNearbyStories,this.$container.find(".js-apregoar-nearby-stories"),"nearby",!0)}_updateMap(e=!1,t=!1){this._toggleNoticeNoResults(!1),this.ruaMap&&this.ruaMap.renderLocations(this.currentLocs,e)}_showDateInput(e){const t=e.siblings(".js-apregoar-filters-date");e.siblings(".js-apregoar-filters-use-default").val(0),e.removeClass("active"),t.addClass("active").trigger("focus")}_toggleLoading(e,t){e.toggleClass("apregoar-loading",t)}_toggleNoticeNoResults(e){this.$container.find(".js-apregoar-no-results").toggleClass("active",e)}_getLocsType(){return this.currentLocs===this.exploreLocs?"explore":this.currentLocs===this.nearbyLocs?"nearby":this.currentLocs===this.searchLocs?"search":"unknown"}}const c=jQuery;class p{constructor(e){this.container=e,this.container&&(this.$container=c(this.container),this.ruaMap=null,this.isRendered=!1,this.pageNum=1,this.settings=this._readSettings(),this._bindEvents(),this.settings.autoRender&&this.render())}_readSettings(){const e=e=>this.$container.data(e)||null,t=t=>String(e(t)||"").length>0?String(e(t)).split(","):null;return{locations:t("locations"),keywords:t("keywords"),authors:t("authors"),tags:t("tags"),dateType:e("date_type"),createdAtFrom:e("published_at_from"),createdAtTo:e("published_at_to"),happeningFrom:e("happening_from"),happeningTo:e("happening_to"),lat:e("lat"),lng:e("lng"),zoom:e("zoom"),centerOnResults:e("center_on_results"),autoRender:ruaGlobalVars.autoRenderTiles}}_bindEvents(){this.$container.on("click",".js-apregoar-init-overview-map",(()=>this.render())),this.$container.on("click",".js-apregoar-load-more-overview-map",(e=>this._loadMoreStories(e))),this.$container.on("click",".js-apregoar-overview-map.not-loaded",(()=>this.render()))}async render(){if(this.isRendered)return;const e=this.$container.find(".js-apregoar-overview-map"),t="js-apregoar-map-loading";this.$container.find(".js-apregoar-init-overview-map").replaceWith(`<span class="apregoar-loading ${t}"></span>`),e.removeClass("not-loaded");const s={lat:this.settings.lat,lng:this.settings.lng,zoom:this.settings.zoom,centerOnResults:this.settings.centerOnResults,onFeatureClick:e=>this.featureClickHandler(e)};this.ruaMap=new n(e[0],s),this.ruaMap.render(),this.ruaMap.invalidateSize(),this.isRendered=!0,await this._loadData(),this.$container.find(`.${t}`).remove()}featureClickHandler(e){}_addLocsFromStories(e){if(e&&Array.isArray(e)&&e.length){const t=this.ruaMap.settings.i18n.goToStory+" →",s=o.getLocsFromStories(e,t);this.ruaMap.renderLocations(s,1===this.pageNum)}}async _loadData(){const e=this.$container.find(".js-apregoar-load-more-overview-map");e.prop("disabled",!0);const t={locations:this.settings.locations,keywords:this.settings.keywords,authors:this.settings.authors,tags:this.settings.tags,date_type:this.settings.dateType,created_at_from:this.settings.createdAtFrom,created_at_to:this.settings.createdAtTo,happening_from:this.settings.happeningFrom,happening_to:this.settings.happeningTo,page_num:this.pageNum,created_at_from_active:null!==this.settings.createdAtFrom?1:0,created_at_from_use_default:null===this.settings.createdAtFrom?1:0,created_at_to_active:null!==this.settings.createdAtTo?1:0,created_at_to_use_default:null===this.settings.createdAtTo?1:0,happening_from_active:null!==this.settings.happeningFrom?1:0,happening_from_use_default:null===this.settings.happeningFrom?1:0,happening_to_active:null!==this.settings.happeningTo?1:0,happening_to_use_default:null===this.settings.happeningTo?1:0};try{const s=JSON.parse(await a.getStories(t)),r=s?.data?.stories;r&&(this._addLocsFromStories(r),e.toggleClass("active",s.data.has_next),this.pageNum++)}catch(e){console.error("Failed to load stories:",e)}finally{e.prop("disabled",!1)}}async _loadMoreStories(e){c(e.currentTarget).toggleClass("apregoar-loading",!0),await this._loadData(),c(e.currentTarget).toggleClass("apregoar-loading",!1)}}jQuery((async()=>{t(),jQuery(".js-apregoar-overview-map-shortcode").length&&new p(jQuery(".js-apregoar-overview-map-shortcode")),new h(jQuery(".js-apregoar-sidebar-elements"))}))})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.