1import{L as C}from"./CwphVnsR.js";import{K as J,r as K,g as Q,p as v,w as $,z as Y,aU as G,c as X,o as ee}from"./hpNDvw06.js";import{c as te,u as ne}from"./C7qWptLf.js";import{F as M,n as ae,a as A,c as ie}from"./BNRiLFGh.js";import"./x_rD_Ya3.js";import"./Bf9wae6a.js";import"./BYrMGjzP.js";const L="ag-fires-pane",re='<svg width="100%" height="100%" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.926 20.574a7.26 7.26 0 0 0 3.039 1.511c.107.035.179-.105.107-.175-2.395-2.285-1.079-4.758-.107-5.873.693-.796 1.68-2.107 1.608-3.865 0-.176.18-.317.322-.211 1.359.703 2.288 2.25 2.538 3.515.394-.386.537-.984.537-1.511 0-.176.214-.317.393-.176 1.287 1.16 3.503 5.097-.072 8.19-.071.071 0 .212.072.177a8.761 8.761 0 0 0 3.003-1.442c5.827-4.5 2.037-12.48-.43-15.116-.321-.317-.893-.106-.893.351-.036.95-.322 2.004-1.072 2.707-.572-2.39-2.478-5.105-5.195-6.441-.357-.176-.786.105-.75.492.07 3.27-2.063 5.352-3.922 8.059-1.645 2.425-2.717 6.89.822 9.808z" fill="{fill}"/></svg>',fe=J({__name:"FiresVisualization",props:{map:{},enabled:{type:Boolean}},emits:["loadingChange"],setup(R,{emit:k}){const e=R,O=Y(),{handleApiError:U}=ne(),H=k;let o=null,m=null,f=!1;const x=K(!1);let u=null,d=null;const T=te(P,500);Q(async()=>{await v(),e.enabled&&e.map&&(await S(),E())}),$(()=>e.enabled,async t=>{f||(t&&e.map?(await S(),E()):(p(),F()))},{immediate:!1}),$(()=>e.map,async(t,n)=>{n&&(F(),o&&p()),t&&e.enabled&&setTimeout(async()=>{await S(),E()},100)}),$(x,t=>{H("loadingChange",t)});function p(){o&&e.map&&(e.map.removeLayer(o),o=null)}function B(){if(!e.map)return;const n=e.map.getPane(L)??e.map.createPane(L);n&&(n.style.zIndex="450",n.style.pointerEvents="auto")}function h(){o&&e.map&&e.map.removeLayer(o)}async function P(){if(!(!e.map||!e.enabled))try{if(await I(!0),!m)return;p(),await v(),_()}catch{o&&e.map&&e.enabled&&!e.map.hasLayer(o)&&o.addTo(e.map)}}function j(t,n){var D;const a=t.properties,r=ae(a.confidence),i=a.frp||0,s=ie(i),c=((D=e.map)==null?void 0:D.getZoom())||5,g=c<=5?.35+c*.03:.5+(c-5)*.05,b=s*g*2,l=Math.round(Math.min(34,Math.max(10,b))),y=A[r]||A.nominal,W=re.replace("{fill}",y),N=C.marker(n,{icon:C.divIcon({className:"fire-spot-icon",html:`<div style="width:${l}px;height:${l}px;display:flex;align-items:center;justify-content:center;">${W}</div>`,iconSize:[l,l],iconAnchor:[l/2,l/2]}),interactive:!0,pane:L,zIndexOffset:-1e3}),Z=V(a.acq_date,a.acq_time);return N.bindPopup(q(a,Z,i)),N}function q(t,n,a){const r=document.createElement("div");r.style.fontSize="12px",r.style.lineHeight="1.4";const i=(c,g)=>{const w=document.createElement("strong");w.textContent=c,r.appendChild(w),r.appendChild(document.createTextNode(` ${g}`)),r.appendChild(document.createElement("br"))},s=document.createElement("strong");return s.textContent="Fire Detection",r.appendChild(s),r.appendChild(document.createElement("br")),r.appendChild(document.createElement("br")),i("Date:",n||""),i("Confidence:",String((t==null?void 0:t.confidence)??"")),i("FRP:",`${Number.isFinite(a)?a.toFixed(1):"0.0"} MW`),i("Satellite:",String((t==null?void 0:t.satellite)??"")),r}function V(t,n){const a=typeof t=="string"?t:"",r=z(n);let i="",s=r;if(a)if(a.includes("T")){const c=new Date(a);Number.isNaN(c.getTime())?i=a.split("T")[0]:(i=c.toISOString().slice(0,10),s||(s=c.toISOString().slice(11,16)))}else i=a;return i&&s?`${i} ${s}`:i||s||""}function z(t){if(typeof t=="number"&&Number.isFinite(t))return z(String(t).padStart(4,"0"));if(typeof t!="string")return"";const n=t.trim();return/^\d{2}:\d{2}:\d{2}$/.test(n)?n.slice(0,5):/^\d{2}:\d{2}$/.test(n)?n:/^\d{4}$/.test(n)?`${n.slice(0,2)}:${n.slice(2,4)}`:n}function _(){!m||!e.map||!e.enabled||(B(),o=C.geoJSON(m,{pointToLayer:j}),o.addTo(e.map))}function E(){e.map&&(F(),e.map.on("movestart",h),e.map.on("zoomstart",h),u=()=>{T()},d=()=>{T()},e.map.on("moveend",u),e.map.on("zoomend",d))}function F(){e.map&&(e.map.off("movestart",h),e.map.off("zoomstart",h),u&&(e.map.off("moveend",u),u=null),d&&(e.map.off("zoomend",d),d=null))}async function I(t=!1){if(!(m&&!t)&&e.map){x.value=!0;
1try{const n=e.map.getBounds(),a=n.getWest(),r=n.getEast(),i=n.getSouth(),s=n.getNorth(),c=new AbortController,g=setTimeout(()=>c.abort(),M.timeout),b=`${O.public.apiUrl}/fires-data/current?xmin=${a}&xmax=${r}&ymin=${i}&ymax=${s}&hours=${M.hours}`,l=await fetch(b,{signal:c.signal});if(clearTimeout(g),!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText}`);const y=await l.json();if(!y||y.type!=="FeatureCollection")throw new Error("Invalid fires data format");m=y}catch(n){throw m=null,n}finally{x.value=!1}}}async function S(){if(!f&&e.map&&e.map.getContainer()){f=!0;try{if(p(),await I(!0),!m||(await v(),!e.map||!e.enabled))return;_()}catch(t){U(t,"Failed to load fires data. Please try again."),o=null}finally{f=!1}}}return G(()=>{F(),p(),m=null,f=!1,u=null,d=null}),(t,n)=>(ee(),X("div"))}});export{fe as default};
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.