PageSourceSearch

https://citizenportal.ai/assets/useUserLocation-DPdfGC7A.js

js citizenportal.ai collected 2026-09-25 19:11:09 UTC 6,529 bytes, 1 lines download raw bytes

1import{r as K}from"./chunk-JZWAC4HX-4nbCDcia.js";import{u as T}from"./useQuery-CURl-kyg.js";import{u as G}from"./QueryClientProvider-c-rq4vaE.js";import{u as B}from"./utils-jhhtTcSe.js";function E(e){return T({queryKey:["userProfileZip"],queryFn:async({signal:n})=>{const t=await fetch("/api/user/profile-zip",{signal:n});if(!t.ok)return{zipcode:null,city:null};const r=await t.json();return{zipcode:r.zipcode||null,city:r.city||null}},enabled:(e==null?void 0:e.enabled)??!0,staleTime:60*1e3,gcTime:300*1e3,retry:0})}function U(e,n){return T({queryKey:["taxonomyBreadcrumb",e],queryFn:async({signal:t})=>{if(!e)return[];const r=await fetch(`/api/breadcrumb?taxonomyId=${e}`,{signal:t});if(!r.ok)throw new Error("Failed to fetch taxonomy breadcrumb");return r.json()},enabled:((n==null?void 0:n.enabled)??!0)&&e!==null,staleTime:3600*1e3,gcTime:7200*1e3,retry:1})}function $(e){return T({queryKey:["ipLocation"],queryFn:async({signal:n})=>{const t=await fetch("/api/user-location",{signal:n});if(!t.ok)throw new Error("Failed to fetch IP location");return t.json()},enabled:(e==null?void 0:e.enabled)??!0,staleTime:3600*1e3,gcTime:7200*1e3,retry:1})}function M(e,n){const t=n==null?void 0:n.preferredCity;return T({queryKey:["zipCodeLocation",e,t],queryFn:async({signal:r})=>{if(!e||e.length<5)return null;const c=await fetch(`/api/geography?action=lookupZip&zipCode=${e}`,{signal:r});if(!c.ok)return null;const s=await c.json(),l=s.cities||[];let i=l[0];if(t&&l.length>1){const u=l.find(L=>L.name.toLowerCase()===t.toLowerCase());u&&(i=u)}const o=s.county,a=s.state;return{zipCode:s.zipCode||e,city:(i==null?void 0:i.name)||"",state:(a==null?void 0:a.name)||"",stateCode:(a==null?void 0:a.id)||(i==null?void 0:i.stateId)||"",county:(o==null?void 0:o.name)||"",cityTaxonomyId:(i==null?void 0:i.taxonomyId)??null,countyTaxonomyId:(o==null?void 0:o.taxonomyId)??null,stateTaxonomyId:(a==null?void 0:a.taxonomyId)??null,countyFipsCode:(o==null?void 0:o.fipsCode)??null}},enabled:((n==null?void 0:n.enabled)??!0)&&!!e&&e.length>=5,staleTime:1440*60*1e3,gcTime:2880*60*1e3,retry:1})}function Z(e,n){return T({queryKey:["cityGeography",e],queryFn:async({signal:t})=>{if(!e)return null;const r=await fetch(`/api/geography/taxonomy/${e}`,{signal:t});return r.ok?r.json():null},enabled:((n==null?void 0:n.enabled)??!0)&&!!e,staleTime:1440*60*1e3,gcTime:2880*60*1e3,retry:1})}function Y(e){var N,P,q,F,v,w,Q;const{isAuthenticated:n}=B(),t=G(),r=K.useRef(n),c=T({queryKey:["userLocations"],queryFn:async({signal:b})=>{const A=await fetch("/api/locations",{signal:b});return A.ok?A.json():{locations:[]}},enabled:!0,staleTime:60*1e3,gcTime:300*1e3,retry:1,refetchOnMount:"always"});K.useEffect(()=>{r.current!==n&&(r.current=n,t.invalidateQueries({queryKey:["userLocations"]}),t.invalidateQueries({queryKey:["userProfileZip"]}),t.invalidateQueries({queryKey:["zipCodeLocation"]}),t.invalidateQueries({queryKey:["cityGeography"]}),t.invalidateQueries({queryKey:["ipLocation"]}))},[n,t]);const s=((N=c.data)==null?void 0:N.locations)??[],l=((P=c.data)==null?void 0:P.locationLimit)??1,i=s.length>0,o=s[0],a=i&&(o==null?void 0:o.locationType)==="city"?o.taxonomyId:null,u=Z(a,{enabled:!!a}),L=U((o==null?void 0:o.taxonomyId)??null,{enabled:i&&!a&&!!(o!=null&&o.taxonomyId)}),h=!c.isLoading&&!i,f=E({enabled:h}),g=((q=f.data)==null?void 0:q.zipcode)??null,H=((F=f.data)==null?void 0:F.city)??null,d=h&&!!g&&g.length>=5,I=M(g,{enabled:d,preferredCity:H}),p=(v=I.data)==null?void 0:v.cityTaxonomyId,x=Z(p,{enabled:d&&!!p}),y=$({enabled:!c.isLoading&&!i&&!d&&!f.isLoading}),k=c.isLoading||!!a&&u.isLoading||i&&!a&&!!(o!=null&&o.taxonomyId)&&L.isLoading||h&&f.isLoading||d&&I.isLoading||d&&!!p&&x.isLoading||!i&&!c.isLoading&&!d&&!f.isLoading&&y.isLoading,j=c.error||u.error||I.error||x.error||y.error||null;let m,C=!1;if(i){if(u.data)m=R(u.data);else if(!(a&&u.isLoading)){if(o!=null&&o.taxonomyId){const b=L.data??[];m=O(o,b)}}}else!c.isLoading&&!i&&(x.data?m=R(x.data):I.data&&I.data.cityTaxonomyId?m=_(I.data):!d&&!f.isLoading&&(y.data&&!y.data.isPrivateIP?m=z(y.data):((w=y.data)!=null&&w.isPrivateIP||!y.isLoading)&&(C=!0,m={source:"none",leafTaxonomyId:null,parentTaxonomyId:null,leafLocationName:"Local",parentLocationName:"Regional",locationType:null,isPrivateIP:(Q=y.data)==null?void 0:Q.isPrivateIP})));return{data:m,isLoading:k,error:j,needsManualLocation:C,savedLocations:s,locationLimit:l}}function O(e,n){const t=e.taxonomyId,r=e.locationName.split(",")[0].trim();
1let c=null,s="Regional",l=null,i="";const o=n.filter(a=>a.taxId!=="0"&&a.taxId!=="2145");if(o.length>=1&&(l=Number(o[0].taxId),i=o[0].title||o[0].name||""),o.length>=2){const a=o[1],u=Number(a.taxId);u!==t&&(c=u,s=a.title||a.name||"Regional")}return{source:"saved",leafTaxonomyId:t,parentTaxonomyId:c,leafLocationName:r,parentLocationName:s,stateTaxonomyId:l,stateName:i,locationType:e.locationType}}function z(e){let n=null,t=null,r="Local",c="Regional",s=null;const l=e.countyTaxonomyIds.length>0?e.countyTaxonomyIds[0]:null,i=e.countyName||void 0,o=e.stateTaxonomyIds.length>0?e.stateTaxonomyIds[0]:null,a=e.regionName||void 0;return l?(t=l,c=i||"County"):o&&(t=o,c=a||"Regional"),e.cityTaxonomyIds.length>0?(n=e.cityTaxonomyIds[0],r=e.cityName||"Local",s="city"):l?(n=l,r=i||"Local",s="county"):o&&(n=o,r=a||"Local",s="state"),n===t&&(t=null),{source:"ip",leafTaxonomyId:n,parentTaxonomyId:t,leafLocationName:r,parentLocationName:c,locationType:s,isPrivateIP:e.isPrivateIP,countyTaxonomyId:l,countyName:i,stateTaxonomyId:o,stateName:a}}function _(e){return{source:"saved",leafTaxonomyId:e.cityTaxonomyId,parentTaxonomyId:e.countyTaxonomyId,leafLocationName:e.city,parentLocationName:e.county||"Regional",stateTaxonomyId:e.stateTaxonomyId,stateName:e.state,countyTaxonomyId:e.countyTaxonomyId,countyName:e.county,countyFipsCode:e.countyFipsCode||void 0,zipCodes:[e.zipCode],locationType:"city"}}function R(e){return{source:"saved",leafTaxonomyId:e.cityTaxonomyId,parentTaxonomyId:e.countyTaxonomyId,leafLocationName:e.cityName,parentLocationName:e.countyName||"Regional",leafHasArticles:e.cityHasArticles,parentHasArticles:e.countyHasArticles,stateTaxonomyId:e.stateTaxonomyId,stateName:e.stateName,stateHasArticles:e.stateHasArticles,countyTaxonomyId:e.countyTaxonomyId,countyName:e.countyName,countyHasArticles:e.countyHasArticles,countyFipsCode:e.countyFipsCode,schoolBoards:e.schoolBoards.map(n=>({id:n.id,name:n.name,taxonomyId:n.taxonomyId,hasArticles:n.hasArticles})),zipCodes:e.zipCodes,locationType:"city"}}function S(e){}export{E as a,Y as b,S as s,$ 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.