PageSourceSearch

https://singaporebirds.com/assets/HomeScreen-CQMKkdvL.js

js singaporebirds.com collected 2026-09-25 00:11:31 UTC 11,723 bytes, 1 lines download raw bytes

1import{r as m,j as e}from"./react-vendor-eUQHqTr8.js";import{T as n,S as D,B as v,u as b,a as w,E as M,b as F,L as h,D as p,p as R,c as A,d as E,e as _,I as k}from"./index-Wm-ehMmj.js";import"./SpeciesMapPanel-BsLbmfv9.js";import{W as G}from"./WishLifeToggles-BXO7s80R.js";import{T as N,a as P,p as O,L as K,D as Y,R as U}from"./TargetsScreen-BdOWjBtJ.js";import"./Tooltip-QJmVpwZI.js";import"./lists-B-JObJDl.js";n.amber;n.amber;const H=/<(species|hotspot):([a-z0-9\-_]+)>([\s\S]*?)<\/\1>/gi;function q(t){const s=[];let r=0,i;for(H.lastIndex=0;i=H.exec(t);)i.index>r&&s.push({kind:"html",html:t.slice(r,i.index)}),s.push({kind:"ref",refKind:i[1].toLowerCase(),id:i[2],label:i[3]}),r=i.index+i[0].length;return r<t.length&&s.push({kind:"html",html:t.slice(r)}),s}function J({html:t,nav:s,as:r="div",style:i}){const l=m.useMemo(()=>q(t||""),[t]);return e.jsx(r,{style:i,children:l.map((o,d)=>o.kind==="html"?e.jsx("span",{dangerouslySetInnerHTML:{__html:o.html}},d):e.jsx(Q,{kind:o.refKind,id:o.id,label:o.label,nav:s},d))})}function Q({kind:t,id:s,label:r}){const i=t==="species",l={display:"inline-flex",alignItems:"center",gap:4,padding:"0px 7px",margin:"0 1px",borderRadius:4,cursor:"pointer",background:i?n.amberTint:n.sageSoft,border:`1px solid ${i?n.amberDim:n.sage}`,color:n.text,fontSize:12.5,fontWeight:500,fontFamily:v,lineHeight:1.5,verticalAlign:"baseline"},o=e.jsx("span",{dangerouslySetInnerHTML:{__html:r}});return i?e.jsx(D,{screen:"species",params:{id:s},style:l,children:o}):e.jsx("a",{href:`https://ebird.org/hotspot/${s}`,target:"_blank",rel:"noopener noreferrer",style:{...l,textDecoration:"none"},children:o})}const V=[{id:"wishlist",label:"Targets seen recently - list"},{id:"map",label:"Targets seen recently - map"},{id:"list",label:"When to look for your targets"}];function me({nav:t}){const{data:s,error:r,loading:i,reload:l}=b(()=>w.today()),[o,d]=m.useState("wishlist");if(i)return e.jsx(ae,{});if(r)return e.jsx(M,{title:"Couldn't load today's briefing",message:r.message||"The /api/today endpoint returned an error. See backend/schemas.py for the expected response shape.",action:e.jsx(F,{onClick:l,children:"Try again"})});const{userFirstName:c,today:x,briefing:a,wishlistHits24h:f=[],alertCount:g=0}=s,u=L(f).length;return e.jsxs("div",{style:{paddingBottom:24},children:[e.jsx(ee,{today:x,userFirstName:c,headline:a==null?void 0:a.headline}),x&&e.jsx(te,{today:x}),e.jsx(ie,{briefing:a,nav:t}),e.jsx(X,{tab:o,setTab:d,counts:{wishlist:u}}),o==="wishlist"&&e.jsx(re,{wishlistHits:f,alertCount:g,nav:t}),o==="map"&&e.jsx(N,{nav:t}),o==="list"&&e.jsx(P,{nav:t}),e.jsx(Z,{nav:t})]})}function X({tab:t,setTab:s,counts:r}){return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,padding:"6px 22px 4px"},children:V.map(i=>{const l=t===i.id,o=r[i.id];return e.jsxs("button",{onClick:()=>s(i.id),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 14px",borderRadius:999,flexShrink:0,border:`1px solid ${l?n.amberHi:n.rule}`,background:l?n.amberTint:n.panel,color:l?n.amberHi:n.text,fontFamily:v,fontSize:13,fontWeight:600,letterSpacing:-.1,cursor:"pointer",whiteSpace:"nowrap"},children:[i.label,typeof o=="number"&&o>0&&e.jsx("span",{style:{fontFamily:A,fontSize:12,fontWeight:600,padding:"1px 6px",borderRadius:999,minWidth:18,textAlign:"center",background:l?n.amber:n.panelHi,color:l?n.onAmber:n.textMute},children:o})]},i.id)})})}function B({title:t,message:s}){return e.jsx("div",{style:{padding:"20px 22px 0"},children:e.jsxs("div",{style:{background:n.panel,border:`1px solid ${n.ruleSoft}`,borderRadius:12,padding:"22px 20px",textAlign:"center"},children:[e.jsx("div",{style:{fontFamily:p,fontSize:15,fontStyle:"italic",color:n.text,marginBottom:4},children:t}),s&&e.jsx("div",{style:{fontSize:12.5,color:n.textMute,lineHeight:1.5},children:s})]})})}function Z({nav:t}){const{logout:s,user:r}=_(),i={background:"transparent",border:"none",cursor:"pointer",color:n.amber,fontFamily:p,fontSize:11,fontStyle:"italic",fontWeight:600,padding:0};return e.jsxs("div",{style:{padding:"22px 22px 0",fontFamily:p,fontSize:11,color:n.textMute,fontStyle:"italic",display:"flex",justifyContent:"space-between",alignItems:"center",gap:8},children:[e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:(r==null?void 0:r.email)||"SG · 1.3521° N, 103.8198° E"}),e.jsxs("div",{style:{display:"flex",gap:14,flexShrink:0},children:[e.jsx("button",{onClick:()=>t==null?void 0:t("preferences"),style:i,children:"Preferences"}),e.jsx("button",{onClick:s,style:i,children:"Sign out"})]})]})}function ee({today:t,userFirstName:s,headline:r}){return e.jsxs("div",{style:{padding:"20px 22px 12px"},children:[e.jsx("div",{style:{marginBottom:2},children:e.jsx("span",{style:{fontFamily:p,fontSize:13,color:n.textMute,fontStyle:"italic",fontWeight:500},children:t?t.date:""})}),e.jsxs("h1",{style:R(!1),children:[(()=>{const i=new Date().getHours();return i<12?"Good morning":i<17?"Good afternoon":"Good evening"})(),", ",s,"."]}),r&&e.jsx("div",{style:{marginTop:6,fontSize:13,color:n.textDim,lineHeight:1.4},children:r})]})}function te({today:t}){return e.jsx("div",{style:{padding:"0 22px",marginBottom:14},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:1,background:n.rule,border:`1px solid ${n.rule}`,borderRadius:8,overflow:"hidden"},children:[e.jsx(y,{icon:"sun",k:"Sunrise",v:t.sunrise}),e.jsx(y,{icon:"waves",k:"High tide",v:t.highTide.time,sub:`${t.highTide.height}m`}),e.jsx(y,{icon:"wind",k:"Wind",v:`${t.windKt} kt`,sub:t.windDir}),e.jsx(y,{icon:"droplet",k:"Rain",v:t.rainFrom?`${t.rainFrom}+`:"—",tone:t.rainFrom?"coral":null})]})})}function y({icon:t,k:s,v:r,sub:i,tone:l}){return e.jsxs("div",{style:{background:n.panel,padding:"8px 10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:2},children:[e.jsx(k,{name:t,size:11,style:{color:l==="coral"?"#F5A78A":n.textMute}}),e.jsx("span",{style:{fontSize:10.5,color:n.textMute,fontWeight:500},children:s})]}),e.jsx("div",{style:{fontFamily:p,fontSize:16,fontWeight:600,color:l==="coral"?n.coral:n.text,letterSpacing:-.3},children:r}),i&&e.jsx("div",{style:{fontSize:10.5,color:n.textMute},children:i})]})}function ie({briefing:t,nav:s}){return t?e.jsxs("div",{style:{margin:"0 22px 14px",background:`linear-gradient(180deg, ${n.amberSoft} 0%, ${n.panel} 100%)`,border:`1px solid ${n.amberDim}`,borderRadius:12,padding:"14px 16px",position:"relative"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:e.jsxs("span",{style:{fontFamily:p,fontSize:12,color:n.amber,fontStyle:"italic",fontWeight:600},children:["Morning briefing · ",ne(t.generatedAt)]})}),e.jsx(J,{as:"p",html:t.bodyHtml,nav:s,style:{margin:0,fontFamily:v,fontSize:16,lineHeight:1.4,color:n.text,fontWeight:400,letterSpacing:-.1}}),e.jsx("div",{style:{marginTop:14,display:"flex",gap:6,flexWrap:"wrap"},children:t.primaryCta&&t.primaryCtaSpeciesId&&e.jsx(F,{primary:!0,screen:"species",params:{id:t.primaryCtaSpeciesId},children:t.primaryCta})})]}):null}function ne(t){if(!t)return"";try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}catch{return""}}function se(t){if(!t)return"";const s=new Date(t),r=s.toLocaleDateString([],{month:"short",day:"numeric"}),i=s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});return`${r} ${i}`}function L(t){const s=[],r=new Map;for(const i of t)r.has(i.speciesId)||(r.set(i.speciesId,s.length),s.push({speciesId:i.speciesId,species:i.species,rarity:i.rarity,sightings:[]})),s[r.get(i.speciesId)].sightings.push(i);return s}function re({wishlistHits:t,alertCount:s,nav:r}){var W,z;const i=b(()=>w.preferences(),[]),l=(W=i.data)==null?void 0:W.lifelistLabel,o=O(i.data||{}),[d,c]=m.useState(null),x=d??o,[a,f]=m.useState(7),g=x==="wishlist",u=g&&a===7,j=b(()=>u?Promise.resolve(null):w.todayHits(g?"wishlist":"stillNeeded",a),[x,a]),T=u?t:j.data||[],$=!u&&j.loading,I=u?null:j.error,C=a===1?"day":"days";return e.jsxs(e.Fragment,{children:[e.jsx(E,{label:"Targets seen recently - list"}),e.jsxs("div",{style:{padding:"6px 22px 0"},children:[e.jsx(K,{seg:x,onSeg:c,lifelistLabel:l,primary:o,wishlistCount:(z=i.data)==null?void 0:z.wishlistCount}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:e.jsx(Y,{days:a,onChange:f})})]}),$?e.jsx("div",{style:{padding:"12px 22px 0"},children:e.jsx(h,{height:64})}):I?e.jsx(B,{title:"Couldn't load sightings",message:I.message}):T.length===0?e.jsx(B,{title:g?`No wishlist hits in the last ${a} ${C}`:`Nothing still needed logged in the last ${a} ${C}`,message:g?"When eBird logs one of your wishlist species, it shows up here.":"When eBird logs a species you still need, it shows up here."}):e.jsx(oe,{hits:T,nav:r})]})}function oe({hits:t,nav:s}){const r=L(t);return e.jsx("div",{style:{padding:"10px 22px 0",display:"flex",flexDirection:"column",gap:0},children:r.map((i,l)=>{const o=i.species||{};return e.jsxs("div",{style:{borderTop:l===0?"none":`1px solid ${n.ruleSoft}`,padding:"10px 0"},children:[e.jsxs(D,{screen:"species",params:{id:o.slug||i.speciesId},style:{display:"flex",gap:10,alignItems:"center",cursor:"pointer",marginBottom:4},children:[e.jsxs("span",{style:{flex:1,minWidth:0},children:[e.jsx("span",{style:{display:"block",fontFamily:p,fontSize:13.5,fontWeight:600,color:n.text,letterSpacing:-.1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.common||i.speciesId}),e.jsxs("span",{style:{display:"flex",gap:6,alignItems:"center",marginTop:2,flexWrap:"wrap"},children:[e.jsx(U,{rarity:o.rarity||i.rarity}),o.localStatus&&e.jsx("span",{style:{fontFamily:p,fontStyle:"italic",fontSize:12,color:n.textMute},children:o.localStatus})]})]}),e.jsx("span",{style:{display:"flex",alignItems:"center",gap:6},children:e.jsx(G,{species:o,size:"sm"})}),e.jsx(k,{name:"chevron",size:14,style:{color:n.textMute}})]}),e.jsx(le,{sightings:i.sightings})]},i.speciesId)})})}const S=5;function le({sightings:t}){const[s,r]=m.useState(!1),i=s?t:t.slice(0,S),l=t.length-S;return e.jsxs("div",{style:{paddingLeft:12},children:[i.map((o,d)=>{const c=o.hotspot||{};return e.jsxs("a",{href:`https://ebird.org/checklist/${o.subId}`,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:8,padding:"4px 0",borderTop:d>0?`1px solid ${n.ruleSoft}
1`:"none",textDecoration:"none",color:"inherit",cursor:"pointer"},children:[e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8},children:[e.jsx("div",{style:{fontSize:12,color:n.text,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.short||c.name||o.locName||o.hotspotId}),e.jsxs("div",{style:{fontSize:11,color:n.textMute,flexShrink:0},children:[c.distanceKm!=null?`${c.distanceKm} km · `:"",se(o.obsDt)]})]}),e.jsx(k,{name:"arrow",size:12,style:{color:n.textMute,flexShrink:0}})]},d)}),!s&&l>0&&e.jsxs("button",{onClick:()=>r(!0),style:{background:"none",border:"none",cursor:"pointer",padding:"4px 0",fontSize:11,color:n.amber,fontWeight:600},children:["+",l," more"]}),s&&t.length>S&&e.jsx("button",{onClick:()=>r(!1),style:{background:"none",border:"none",cursor:"pointer",padding:"4px 0",fontSize:11,color:n.textMute,fontWeight:600},children:"Show less"})]})}function ae(){return e.jsxs("div",{style:{padding:22},children:[e.jsx(h,{height:12,width:140,style:{marginBottom:12}}),e.jsx(h,{height:32,width:"80%",style:{marginBottom:20}}),e.jsx(h,{height:64,style:{marginBottom:14}}),e.jsx(h,{height:120,style:{marginBottom:14}}),e.jsx(h,{height:80,style:{marginBottom:8}}),e.jsx(h,{height:80})]})}export{me as HomeScreen};

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.