PageSourceSearch

https://petwellhk.com/assets/useClinics-BT6VP7AE.js

js petwellhk.com collected 2026-10-06 05:23:53 UTC 4,818 bytes, 69 lines download raw bytes

1import{u as R,b as x}from"./query-7-WHkg5t.js";import"./main-m_sUF2N4.js";import{g as k}from"./hongKongDistricts--r8_jlh4.js";import{H as N,a as b,n as A,r as S,s as T,i as z,P as y,b as p,g as v,d as F,h as q,c as I}from"./placeSearchConfig-BfT0dFXT.js";import{g as _}from"./serviceOfferings-40B0fv7X.js";import{r as w}from"./react-vendor-BDHNqS4B.js";function D(e){return k(e)}function H(e,s="zh"){var m,g,a,l,h,t;const r=s==="en"?"en":"zh",P=r==="en"?"Unnamed clinic":"未命名診所",o=r==="en"?"Address unavailable":"地址未提供",u=((m=e.name)==null?void 0:m[r])||((g=e.name)==null?void 0:g.zh)||((a=e.name)==null?void 0:a.en)||P,n=((l=e.address)==null?void 0:l[r])||((h=e.address)==null?void 0:h.zh)||((t=e.address)==null?void 0:t.en)||o,c=e.district||"";return{id:e.id,name:u,region:D(c),district:c,address:n,location:e.location||null,phone:e.phoneNo||"",rating:e.totalRating,totalReviews:e.numReviews,services:e.serviceOfferings?e.serviceOfferings.split(",").map(i=>i.trim()):[],availableHours:e.availableHours,image:e.coverPhoto,hasData:!0,is247:e.is247,verified:e.verified,ownerSub:e.ownerSub??null,partnerPlan:e.partnerPlan??null,partnerPlanExpiresAt:e.partnerPlanExpiresAt??null,isPremium:z({ownerSub:e.ownerSub,partnerPlan:e.partnerPlan,partnerPlanExpiresAt:e.partnerPlanExpiresAt})}}async function E(e={},s="zh"){const{region:r,district:P,districts:o,keyword:u,is247:n,limit:c=y,nextToken:m,sortMethod:g="rating-desc"}=e;try{const a={location:e.location??N,limit:c,sortMethod:g};b(a,{region:r,district:P,districts:o}),u&&(a.keyword=u),n!==void 0&&(a.is247=n);const l=A(m);l&&(a.nextToken=l);const{items:h,total:t,nextToken:i}=await S("clinic",a,{fallback:"Failed to search clinics"}),f=h.filter(d=>!!(d!=null&&d.id)).map(d=>H(d,s));return{clinics:g==="location"?f:T(f),total:t,nextToken:i}}catch(a){throw console.error("Error searching clinics:",a),a instanceof Error?a:new Error("Failed to search clinics")}}const K=`
2  query GetClinic($id: ID!) {
3    getClinic(id: $id) {
4      id
5      ownerSub
6      name {
7        zh
8        en
9      }
10      district
11      address {
12        zh
13        en
14      }
15      phoneNo
16      serviceOfferings
17      availableHours {
18        mon { start end }
19        tue { start end }
20        wed { start end }
21        thu { start end }
22        fri { start end }
23        sat { start end }
24        sun { start end }
25        otherConditions
26      }
27      coverPhoto
28      gallery
29      verified
30      photoSource
31      website
32      email
33      totalRating
34      numReviews
35      is247
36      partnerPlan
37      partnerPlanExpiresAt
38      reservationSettings
39      reviews {
40        items {
41          id
42          reviewerId
43          title
44          description
45          totalRating
46          environmentRating
47          personnelRating
48          serviceRating
49          valueRating
50          waitingRating
51          fileAttachments
52          source
53          anonymous
54          partnerReply
55          partnerReplyAt
56          updatedAt
57          reviewer {
58            id
59            displayName
60            firstName
61            profileImage
62          }
63        }
64      }
65      createdAt
66      updatedAt
67    }
68  }
69`;async function M(e){var s;try{const r=await _(K,{id:e});return(s=r.getClinic.reviews)!=null&&s.items&&(r.getClinic.reviews.items=r.getClinic.reviews.items.slice(0,3)),r.getClinic}catch(r){throw console.error("Error fetching clinic:",r),new Error("Failed to fetch clinic")}}function U(e="zh"){return x({queryKey:["clinics","home",p,e],queryFn:async()=>{const{clinics:s}=await E({limit:y,sortMethod:"rating-desc"},e);return s},staleTime:5*60*1e3})}function V(e,s="zh"){var a,l,h;const r=I(e.region),P=((a=e.keyword)==null?void 0:a.trim())||void 0,o=e.location,u=e.sortMethod??"rating-desc",n=R({queryKey:["clinics","search",p,s,r,P,e.is247,u,o==null?void 0:o.lat,o==null?void 0:o.lon],queryFn:({pageParam:t})=>E({region:r,keyword:P,is247:e.is247,location:o,sortMethod:u,limit:y,nextToken:t},s),initialPageParam:void 0,getNextPageParam:t=>v(t.nextToken),staleTime:5*60*1e3}),c=w.useMemo(()=>{var i;const t=((i=n.data)==null?void 0:i.pages)??[];return F(t.map(f=>f.clinics))},[n.data]),m=w.useMemo(()=>{var f;const t=(f=n.data)==null?void 0:f.pages;if(!(t!=null&&t.length))return!1;const i=t[t.length-1];return!v(i==null?void 0:i.nextToken)||q(t.map(d=>({items:d.clinics,nextToken:d.nextToken})))?!1:n.hasNextPage},[n.data,n.hasNextPage]),g=m?c.length:((h=(l=n.data)==null?void 0:l.pages[0])==null?void 0:h.total)??c.length;return{clinics:c,totalCount:g,isLoading:n.isLoading,error:n.error,hasNextPage:m,fetchNextPage:n.fetchNextPage,isFetchingNextPage:n.isFetchingNextPage}}function W(e){return x({queryKey:["clinic",e],queryFn:()=>
69{if(!e)throw new Error("Clinic ID is required");return M(e)},enabled:!!e,staleTime:5*60*1e3})}export{V as a,W as b,U as u};

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.