1import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n}from"./framework-2k-VFE-j.js";import{t as r}from"./link-B4k5a-Fe.js";import{t as i}from"./image-DvHamRxl.js";import{n as a,r as o}from"./saved-provider-D954f3b7.js";import{c as s}from"./layover-fit-BxkU8z6W.js";import{c,s as l}from"./icons-BXSXUMSX.js";var u=e(t(),1),d=`layover:recent-cities`,f=`layover:cities-changed`,p=[],m=new Map;function h(e){let t=null;try{t=window.localStorage.getItem(e)}catch{return p}let n=m.get(e);if(n&&n.raw===t)return n.value;let r=p;try{let e=t?JSON.parse(t):[];r=Array.isArray(e)?e.filter(e=>typeof e==`string`&&/^[a-z0-9-]+$/.test(e)):p}catch{r=p}return m.set(e,{raw:t,value:r}),r}function g(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}window.dispatchEvent(new Event(f))}function _(e){return window.addEventListener(f,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(f,e),window.removeEventListener(`storage`,e)}}function v(){let e=a(),t=e.items.filter(e=>!e.outing).map(e=>e.slug);return{...e,saved:t,toggle:n=>e.change(t.includes(n)?`remove`:`save`,o(n))}}function y(){return(0,u.useSyncExternalStore)(_,()=>h(d),()=>p)}function b(e){g(d,[e,...h(d).filter(t=>t!==e)].slice(0,8))}var x=n();function S({city:e,saved:t,onToggle:n}){let[a,o]=(0,u.useState)(!1),{ready:l,busy:d}=v();return(0,x.jsxs)(`div`,{className:`city-tile`,children:[(0,x.jsxs)(r,{href:`/guides/${e.slug}`,className:`city-tile-link`,children:[(0,x.jsxs)(`span`,{className:`city-tile-image`,children:[e.image&&(0,x.jsx)(i,{src:e.image.src,alt:``,fill:!0,sizes:`(max-width: 640px) 70vw, 280px`}),(0,x.jsx)(`span`,{className:`city-tile-shade`}),(0,x.jsx)(`span`,{className:`code-chip`,children:e.airportCode})]}),(0,x.jsxs)(`span`,{className:`city-tile-copy`,children:[(0,x.jsx)(`strong`,{children:e.city}),(0,x.jsx)(`small`,{children:e.country}),(0,x.jsx)(`em`,{children:s(e.outings)})]})]}),n&&(0,x.jsx)(`button`,{type:`button`,className:`tile-save`,"aria-pressed":t,"aria-label":t?`Remove ${e.city} from saved`:`Save ${e.city}`,disabled:!l||d,onClick:async()=>o(!await n()),children:(0,x.jsx)(c,{filled:t,size:18})}),a&&(0,x.jsx)(`span`,{role:`status`,children:`Couldnât confirm this change. Try again.`})]})}function C(){let[e,t]=(0,u.useState)(!1);return(0,u.useEffect)(()=>t(!0),[]),e}function w({cities:e}){let t=C(),{saved:n,toggle:i}=v(),a=y(),o=new Map(e.map(e=>[e.slug,e])),s=[...n,...a.filter(e=>!n.includes(e))].filter(e=>o.has(e)).slice(0,10);return!t||!s.length?null:(0,x.jsxs)(`section`,{className:`shelf-section shell`,"aria-labelledby":`your-cities-title`,children:[(0,x.jsxs)(`div`,{className:`shelf-heading`,children:[(0,x.jsx)(`h2`,{id:`your-cities-title`,children:`Your cities`}),(0,x.jsx)(r,{href:`/saved`,children:`See all`})]}),(0,x.jsx)(`div`,{className:`shelf-scroll`,children:s.map(e=>(0,x.jsx)(S,{city:o.get(e),saved:n.includes(e),onToggle:()=>i(e)},e))})]})}function T({cities:e}){let t=C(),{saved:n,toggle:i,ready:a}=v(),o=y(),s=new Map(e.map(e=>[e.slug,e])),c=n.map(e=>s.get(e)).filter(e=>!!e),l=o.filter(e=>!n.includes(e)).map(e=>s.get(e)).filter(e=>!!e);return!t||!a?(0,x.jsx)(`div`,{className:`saved-empty`,"aria-busy":`true`}):(0,x.jsxs)(x.Fragment,{children:[c.length?(0,x.jsx)(`div`,{className:`tile-grid`,children:c.map(e=>(0,x.jsx)(S,{city:e,saved:!0,onToggle:()=>i(e.slug)},e.slug))}):(0,x.jsxs)(`div`,{className:`saved-empty`,children:[(0,x.jsx)(`p`,{children:`Star cities from your roster to keep them here.`}),(0,x.jsx)(r,{className:`conversion-primary`,href:`/guides`,children:`Find a city`})]}),l.length>0&&(0,x.jsxs)(`section`,{className:`saved-recent`,"aria-labelledby":`recent-title`,children:[(0,x.jsx)(`h2`,{id:`recent-title`,children:`Recently opened`}),(0,x.jsx)(`div`,{className:`tile-grid`,children:l.map(e=>(0,x.jsx)(S,{city:e,saved:!1,onToggle:()=>i(e.slug)},e.slug))})]})]})}function E({slug:e,city:t}){let n=C(),{saved:r,toggle:i,ready:a,busy:o,error:s}=v(),[d,f]=(0,u.useState)(``);(0,u.useEffect)(()=>b(e),[e]);let p=n&&r.includes(e);return(0,x.jsxs)(`div`,{className:`guide-hero-actions`,children:[(0,x.jsxs)(`button`,{type:`button`,"aria-pressed":p,disabled:!a||o,onClick:()=>void i(e),children:[(0,x.jsx)(c,{filled:p,size:18}),(0,x.jsx)(`span`,{children:p?`Saved`:`Save`})]}),(0,x.jsxs)(`button`,{type:`button`,onClick:async()=>{let n=`${window.location.origin}/guides/${e}`;try{if(navigator.share){await navigator.share({title:`${t} layover guide â The Layover`,url:n});return}await navigator.clipboard.writeText(n),f(`Link copied`),setTimeout(()=>f(``),2200)}catch{}},children:[(0,x.jsx)(l,{}),(0,x.jsx)(`span`,{children:d||`Share`})]}),s&&(0,x.jsx)(`span`,{role:`status`,children:s})]})}export{S as CityTile,E as GuideHeroActions,T as SavedCitiesPage,w as YourCities,v as t};
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.