PageSourceSearch

https://wei.city/_nuxt/C1jJEnP-.js

js wei.city collected 2026-09-24 14:38:16 UTC 4,644 bytes, 1 lines download raw bytes

1import{bt as z,ew as j,aR as H,ea as K,c$ as i,eR as Z,cF as G,cL as o,aB as c,dP as n,aw as b,dD as v,ay as C,f as J,d4 as Q,eZ as X,cv as Y,d5 as ee,at as P,a1 as ae}from"./BQpWByWK.js";const A=()=>j().public.apiBase||void 0;function q(t){const u=t?.data?.code;return typeof u=="string"&&u.length>0?u:"unknown"}async function te(t){return(await $fetch("/api/app/places/autocomplete",{method:"POST",baseURL:A(),credentials:"include",headers:z(),body:{input:t.input,sessionToken:t.sessionToken,region:t.region??"",countryCode:t.countryCode??"",languageCode:t.languageCode??""}}))?.suggestions??[]}async function ne(t,u){return await $fetch(`/api/app/places/details/${encodeURIComponent(t)}`,{baseURL:A(),credentials:"include",headers:z(),query:{sessionToken:u}})}function x(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`s${Date.now().toString(36)}${Math.random().toString(36).slice(2,12)}`}const le={class:"wc-place"},se={key:0,class:"wc-place__picked"},oe={class:"wc-place__picked-text"},ce=["disabled"],ue={key:1,class:"wc-place__search"},re=["value","placeholder","disabled"],ie={key:0,class:"wc-place__spinner","aria-hidden":"true"},de={key:1,class:"wc-place__menu"},pe=["onMousedown"],fe={class:"wc-place__opt-main"},ve={key:0,class:"wc-place__opt-sub"},_e={key:2,class:"wc-place__error"},me={key:3,class:"wc-place__manual"},he=H({__name:"PlaceAddressInput",props:{region:{default:""},countryCode:{default:""},disabled:{type:Boolean,default:!1},placeholder:{default:""},initialSummary:{default:""}},emits:["resolved","cleared","manual"],setup(t,{expose:u,emit:E}){const _=t,$=E,{t:T,locale:B}=K(),m=i(""),d=i([]),l=i(-1),h=i(!1),y=i(!1),p=i(_.initialSummary),f=i(""),r=i(!1);let g=x(),w=null,S=0;const L=P(()=>p.value.length>0);function k(){d.value=[],l.value=-1,h.value=!1}function I(e){const a=e??!r.value;r.value=a,a?D():p.value||(p.value=_.initialSummary||""),$("manual",a)}Z(()=>_.initialSummary,e=>{r.value||(p.value=e||"")});function D(){p.value="",m.value="",f.value="",g=x(),k()}function U(){D(),$("cleared")}function N(e){m.value=e.target.value,f.value="",w&&clearTimeout(w);const a=m.value.trim();if(a.length<3){k();return}w=setTimeout(()=>{W(a)},300)}async function W(e){const a=++S;y.value=!0;try{const s=await te({input:e,sessionToken:g,region:_.region,countryCode:_.countryCode,languageCode:B.value==="en"?"en":B.value==="zh-TW"?"zh-TW":"zh-CN"});if(a!==S)return;d.value=s,l.value=-1,h.value=!0}catch(s){if(a!==S)return;f.value=q(s),k(),r.value||I(!0)}finally{a===S&&(y.value=!1)}}async function M(e){k(),y.value=!0;try{const a=await ne(e.placeId,g);p.value=a.formattedAddress||[e.mainText,e.secondaryText].filter(Boolean).join(", "),m.value="",f.value="",r.value&&I(!1),$("resolved",{placeId:e.placeId,sessionToken:g,details:a}),g=x()}catch(a){f.value=q(a),r.value||I(!0)}finally{y.value=!1}}function F(e){if(h.value)if(e.key==="ArrowDown")e.preventDefault(),l.value=Math.min(l.value+1,d.value.length-1);else if(e.key==="ArrowUp")e.preventDefault(),l.value=Math.max(l.value-1,0);else if(e.key==="Enter"){if(e.isComposing||e.keyCode===229)return;l.value>=0&&l.value<d.value.length&&(e.preventDefault(),M(d.value[l.value]))}else e.key==="Escape"&&k()}function O(){setTimeout(()=>{h.value=!1},130)}const R=P(()=>{switch(f.value){case"":return"";case"places_unavailable":return T("places.err_unavailable");case"rate_limited":return T("places.err_rate_limited");case"place_not_found":return T("places.err_not_found");default:return T("places.err_generic")}});return G(()=>{w&&clearTimeout(w)}),u({clearSelection:U}),(e,a)=>(o(),c("div",le,[n(L)?(o(),c("div",se,[b("span",oe,v(n(p)),1),b("button",{type:"button",class:"wc-place__change",disabled:t.disabled,onClick:U},v(e.$t("places.change")),9,ce)])):(o(),c("div",ue,[b("input",{class:"wc-place__input",value:n(m),placeholder:t.placeholder||e.$t("places.placeholder"),disabled:t.disabled,autocomplete:"off",onInput:N,onKeydown:F,onBlur:O},null,40,re),n(y)?(o(),c("span",ie)):C("",!0),n(h)&&n(d).length>0?(o(),c("ul",de,[(o(!0),c(J,null,Q(n(d),(s,V)=>(o(),c("li",{key:s.placeId,class:Y(["wc-place__opt",{"is-active":V===n(l)}]),onMousedown:X(ye=>M(s),["prevent"])},[b("span",fe,v(s.mainText),1),s.secondaryText?(o(),c("span",ve,v(s.secondaryText),1)):C("",!0)],42,pe))),128))])):C("",!0)])),n(R)?(o(),c("p",_e,v(n(R)),1)):C("",!0),b("button",{type:"button",class:"wc-place__manual-toggle",onClick:a[0]||(a[0]=s=>I())},v(n(r)?e.$t("places.manual_hide"):e.$t("places.manual_show")),1),n(r)?(o(),c("div",me,[ee(e.$slots,"manual",{},void 0,!0)])):C("",!0)]))}}),we=ae(he,[["__scopeId","data-v-f2fc7bfa"]]);export{we as _};

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.