PageSourceSearch

https://tourist.at/_nuxt/BTtzL2l5.js

js tourist.at collected 2026-10-05 20:40:05 UTC 5,835 bytes, 1 lines download raw bytes

1import{_ as O,K as G,aj as q,af as J,e as Q,ar as $,ag as W,o as X,M as Z,c as u,v,h as y,j as A,x as ee,u as _,F as te,E as ne,t as x,f as p,a as i,O as se,U as ae,V as z,P as oe}from"./CH6TUU2o.js";import{_ as ie}from"./BlQTKQ6M.js";import{_ as le}from"./DPR7hHog.js";const ue={class:"mycities"},re={class:"mycities__container"},ce={key:0,class:"mycities__loading"},_e={key:1,class:"mycities__empty"},me={key:2,class:"mycities__list"},de=["onClick"],ye={class:"mycities__name"},fe={class:"mycities__sub"},ge={key:0,class:"mycities__flag"},ve={key:1,class:"mycities__country"},pe=["disabled","aria-label","onClick"],he={key:3,class:"mycities__error"},U="mynew:active_city_slug",Ce=3e4,be=15e4,ke={__name:"cities",setup(we){const{$apiFetch:E}=G(),h=q(),o=p([]),S=p(!0),f=p(null),g=p(""),C=p(!1),N=J("tourist:my:hub_seed",{default:()=>null,maxAge:3600*24*365,sameSite:"lax"});function I(e){return e?String(e).toLowerCase().trim().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""):""}function P(e){if(!e||e.length!==2)return"";try{return String.fromCodePoint(...e.toUpperCase().split("").map(s=>127462+s.charCodeAt(0)-65))}catch{return""}}function b(e){return{id:e.id||null,name:e.name||e.city||e.title||"",slug:e.slug||I(e.name||e.city||e.title||""),flag:e.flag||e.country_flag||e.flag_icon||P(e.country_code||""),country:e.country||e.country_name||e.country_en||"",country_code:e.country_code||"",lat:e.lat!=null?Number(e.lat):null,lng:(e.lng??e.lon)!=null?Number(e.lng??e.lon):null}}async function T(){S.value=!0;try{const e=await E("api/user/recent-cities"),s=Array.isArray(e==null?void 0:e.data)?e.data:Array.isArray(e)?e:[];o.value=s.map(b).filter(r=>r.name)}catch{o.value=[]}finally{S.value=!1}}function M(e){!(e!=null&&e.slug)||!(e!=null&&e.name)||(N.value={name:e.name,slug:e.slug,flag:e.flag||"",country:e.country||"",lat:e.lat!=null?Number(e.lat):null,lng:e.lng!=null?Number(e.lng):null})}function D(e){if(!e)return;const s=e.slug||I(e.name);try{localStorage.setItem(U,s)}catch{}M(e),$("/my")}async function H(e){var r,l,m;if(!e)return;const s=e.id||e.slug;if(!f.value){if(g.value="",f.value=s,!e.id){g.value="Could not remove this city.",f.value=null;return}try{const t=await E(`api/user/recent-cities/${e.id}`,{method:"DELETE"}),n=Array.isArray(t==null?void 0:t.data)?t.data:Array.isArray(t)?t:null;n?o.value=n.map(b).filter(d=>d.name):o.value=o.value.filter(d=>(d.id||d.slug)!==s);const a=o.value[0];if(a&&((r=N.value)!=null&&r.slug)&&!o.value.some(d=>d.slug===N.value.slug)){try{localStorage.setItem(U,a.slug)}catch{}M(a)}}catch(t){const n=((l=t==null?void 0:t.response)==null?void 0:l.status)||(t==null?void 0:t.status)||(t==null?void 0:t.statusCode),a=(t==null?void 0:t.data)||((m=t==null?void 0:t.response)==null?void 0:m._data)||{};n===422||(a==null?void 0:a.error)==="last_city"?g.value=(a==null?void 0:a.message)||"You must keep at least one city.":g.value=(a==null?void 0:a.message)||(t==null?void 0:t.message)||"Could not remove this city."}finally{f.value=null}}}function Y(){C.value=!0}async function j(e){var F,V;if(C.value=!1,!e)return;const s=e.name_eng||e.name||"";if(!s)return;const r=I(s),l=((F=e.country)==null?void 0:F.name)||e.country_name||"",m=((V=e.country)==null?void 0:V.code)||e.country_code||"",t=e.flag_icon||e.flag||P(m),n=e.lat!=null?Number(e.lat):null,a=(e.lng??e.lon)!=null?Number(e.lng??e.lon):null;if(o.value.find(c=>(c.slug||"").toLowerCase()===r.toLowerCase())||(o.value=[...o.value,b({id:e.id||null,name:s,country:l,country_code:m,flag:t,lat:n,lng:a})]),e.id)try{const c=await E("api/user/recent-cities",{method:"POST",body:{id:Number(e.id),name:s,country:l||null,country_code:m||null}}),B=Array.isArray(c==null?void 0:c.data)?c.data:Array.isArray(c)?c:null;B&&(o.value=B.map(b).filter(K=>K.name))}catch{}}let k=null,L=0;function R(e=!1){if(!h.user)return;const s=Date.now();!e&&s-L<Ce||(L=s,T())}function w(){typeof document<"u"&&document.visibilityState==="visible"&&R()}return Q(async()=>{if(h.isUserLoaded||await h.getProfile(),!h.user){$("/sign-in?return="+encodeURIComponent("/my/cities"));return}T(),L=Date.now(),document.addEventListener("visibilitychange",w),window.addEventListener("focus",w),k=W(()=>{typeof document<"u"&&document.visibilityState==="hidden"||R()},be)}
1),X(()=>{document.removeEventListener("visibilitychange",w),window.removeEventListener("focus",w),k&&(clearInterval(k),k=null)}),Z({title:"My Cities — Tourist",robots:"noindex, nofollow"}),(e,s)=>{const r=se,l=ae,m=ie,t=oe;return i(),u("div",null,[v(r),y("div",ue,[y("div",re,[v(m,{title:"My Cities",subtitle:"Cities shown on your Tourist home","back-to":"/my"},{actions:ee(()=>[y("button",{type:"button",class:"mycities__add",onClick:Y},[v(l,{name:"lucide:plus",size:"16px"}),s[1]||(s[1]=y("span",null,"Add city",-1))])]),_:1}),_(S)?(i(),u("div",ce,[v(l,{name:"lucide:loader",size:"22px",class:"mycities__spin"})])):_(o).length?(i(),u("ul",me,[(i(!0),u(te,null,ne(_(o),n=>(i(),u("li",{key:n.id||n.slug||n.name,class:"mycities__row"},[y("button",{type:"button",class:"mycities__row-main",onClick:a=>D(n)},[y("span",ye,x(n.name),1),y("span",fe,[n.flag?(i(),u("span",ge,x(n.flag),1)):A("",!0),n.country?(i(),u("span",ve,x(n.country),1)):A("",!0)])],8,de),_(o).length>1?(i(),u("button",{key:0,type:"button",class:"mycities__remove",disabled:_(f)===(n.id||n.slug),"aria-label":`Remove ${n.name}`,onClick:a=>H(n)},[_(f)===(n.id||n.slug)?(i(),z(l,{key:0,name:"lucide:loader",size:"16px",class:"mycities__spin"})):(i(),z(l,{key:1,name:"lucide:x",size:"18px"}))],8,pe)):A("",!0)]))),128))])):(i(),u("p",_e,` You don't have any cities yet. Tap "Add city" to add one. `)),_(g)?(i(),u("p",he,x(_(g)),1)):A("",!0)])]),v(le,{open:_(C),mode:"city","country-code":"","selected-id":null,onClose:s[0]||(s[0]=n=>C.value=!1),onPick:j},null,8,["open"]),v(t)])}}},Se=O(ke,[["__scopeId","data-v-f008baee"]]);export{Se 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.