@mapfirst.ai/react 0.0.33 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.mts +2 -6
- package/dist/index.d.ts +2 -6
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -104,7 +104,7 @@ function MapLibreExample() {
|
|
|
104
104
|
|
|
105
105
|
const mapInstance = new maplibregl.Map({
|
|
106
106
|
container: mapContainerRef.current,
|
|
107
|
-
style: "https://
|
|
107
|
+
style: "https://api.mapfirst.ai/static/style.json",
|
|
108
108
|
center: [2.3522, 48.8566], // Paris
|
|
109
109
|
zoom: 12,
|
|
110
110
|
});
|
package/dist/index.d.mts
CHANGED
|
@@ -251,6 +251,7 @@ declare function useMapFirst(options: BaseMapFirstOptions): {
|
|
|
251
251
|
limit?: number;
|
|
252
252
|
};
|
|
253
253
|
smartFiltersClearable?: boolean;
|
|
254
|
+
onError?: (error: unknown) => void;
|
|
254
255
|
}) => Promise<{
|
|
255
256
|
location_id?: number;
|
|
256
257
|
filters: _mapfirst_ai_core.FilterSchema;
|
|
@@ -259,8 +260,6 @@ declare function useMapFirst(options: BaseMapFirstOptions): {
|
|
|
259
260
|
pollingLink: string | undefined;
|
|
260
261
|
durationSeconds: number;
|
|
261
262
|
} | null>;
|
|
262
|
-
isLoading: boolean;
|
|
263
|
-
error: Error | null;
|
|
264
263
|
};
|
|
265
264
|
smartFilterSearch: {
|
|
266
265
|
search: (options: {
|
|
@@ -272,6 +271,7 @@ declare function useMapFirst(options: BaseMapFirstOptions): {
|
|
|
272
271
|
limit?: number;
|
|
273
272
|
language?: string;
|
|
274
273
|
};
|
|
274
|
+
onError?: (error: unknown) => void;
|
|
275
275
|
}) => Promise<{
|
|
276
276
|
location_id?: number;
|
|
277
277
|
filters: _mapfirst_ai_core.FilterSchema;
|
|
@@ -280,8 +280,6 @@ declare function useMapFirst(options: BaseMapFirstOptions): {
|
|
|
280
280
|
pollingLink: string | undefined;
|
|
281
281
|
durationSeconds: number;
|
|
282
282
|
} | null>;
|
|
283
|
-
isLoading: boolean;
|
|
284
|
-
error: Error | null;
|
|
285
283
|
};
|
|
286
284
|
boundsSearch: {
|
|
287
285
|
perform: () => Promise<{
|
|
@@ -292,8 +290,6 @@ declare function useMapFirst(options: BaseMapFirstOptions): {
|
|
|
292
290
|
pollingLink: string | undefined;
|
|
293
291
|
durationSeconds: number;
|
|
294
292
|
} | null>;
|
|
295
|
-
isSearching: boolean;
|
|
296
|
-
error: Error | null;
|
|
297
293
|
};
|
|
298
294
|
attachMapLibre: (map: any, maplibregl: MapLibreNamespace, options?: {
|
|
299
295
|
onMarkerClick?: (marker: Property) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -251,6 +251,7 @@ declare function useMapFirst(options: BaseMapFirstOptions): {
|
|
|
251
251
|
limit?: number;
|
|
252
252
|
};
|
|
253
253
|
smartFiltersClearable?: boolean;
|
|
254
|
+
onError?: (error: unknown) => void;
|
|
254
255
|
}) => Promise<{
|
|
255
256
|
location_id?: number;
|
|
256
257
|
filters: _mapfirst_ai_core.FilterSchema;
|
|
@@ -259,8 +260,6 @@ declare function useMapFirst(options: BaseMapFirstOptions): {
|
|
|
259
260
|
pollingLink: string | undefined;
|
|
260
261
|
durationSeconds: number;
|
|
261
262
|
} | null>;
|
|
262
|
-
isLoading: boolean;
|
|
263
|
-
error: Error | null;
|
|
264
263
|
};
|
|
265
264
|
smartFilterSearch: {
|
|
266
265
|
search: (options: {
|
|
@@ -272,6 +271,7 @@ declare function useMapFirst(options: BaseMapFirstOptions): {
|
|
|
272
271
|
limit?: number;
|
|
273
272
|
language?: string;
|
|
274
273
|
};
|
|
274
|
+
onError?: (error: unknown) => void;
|
|
275
275
|
}) => Promise<{
|
|
276
276
|
location_id?: number;
|
|
277
277
|
filters: _mapfirst_ai_core.FilterSchema;
|
|
@@ -280,8 +280,6 @@ declare function useMapFirst(options: BaseMapFirstOptions): {
|
|
|
280
280
|
pollingLink: string | undefined;
|
|
281
281
|
durationSeconds: number;
|
|
282
282
|
} | null>;
|
|
283
|
-
isLoading: boolean;
|
|
284
|
-
error: Error | null;
|
|
285
283
|
};
|
|
286
284
|
boundsSearch: {
|
|
287
285
|
perform: () => Promise<{
|
|
@@ -292,8 +290,6 @@ declare function useMapFirst(options: BaseMapFirstOptions): {
|
|
|
292
290
|
pollingLink: string | undefined;
|
|
293
291
|
durationSeconds: number;
|
|
294
292
|
} | null>;
|
|
295
|
-
isSearching: boolean;
|
|
296
|
-
error: Error | null;
|
|
297
293
|
};
|
|
298
294
|
attachMapLibre: (map: any, maplibregl: MapLibreNamespace, options?: {
|
|
299
295
|
onMarkerClick?: (marker: Property) => void;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var Me=Object.create;var j=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var Te=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty;var Ae=(e,t)=>{for(var i in t)j(e,i,{get:t[i],enumerable:!0})},Se=(e,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ie(t))!Ne.call(e,a)&&a!==i&&j(e,a,{get:()=>t[a],enumerable:!(o=Be(t,a))||o.enumerable});return e};var ce=(e,t,i)=>(i=e!=null?Me(Te(e)):{},Se(t||!e||!e.__esModule?j(i,"default",{value:e,enumerable:!0}):i,e)),De=e=>Se(j({},"__esModule",{value:!0}),e);var nt={};Ae(nt,{Chip:()=>J,CloseIcon:()=>ue,EditIcon:()=>G,FilterChips:()=>ae,MinRatingFilterChip:()=>Z,NextIcon:()=>X,PriceRangeFilterChip:()=>re,RestaurantPriceLevelChip:()=>ne,SearchIcon:()=>pe,SmartFilter:()=>Le,StarIcon:()=>de,TransformedQueryChip:()=>oe,convertToApiFilters:()=>le.convertToApiFilters,createMinRatingFilterLabel:()=>Qe,createPriceRangeFilterLabel:()=>Ve,formatRatingValue:()=>ee,processApiFilters:()=>le.processApiFilters,renderStars:()=>xe,useFilterScroll:()=>ie,useMapFirst:()=>rt,useTranslation:()=>A});module.exports=De(nt);var P=ce(require("react")),we=require("@mapfirst.ai/core"),le=require("@mapfirst.ai/core");var se=require("react");var ye=ce(require("react"));var Ce=ce(require("react"));var I=require("react/jsx-runtime"),pe=({className:e,style:t})=>(0,I.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[(0,I.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,I.jsx)("path",{d:"m21 21-4.35-4.35"})]}),ue=({className:e,style:t})=>(0,I.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[(0,I.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,I.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),G=({className:e,style:t})=>(0,I.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[(0,I.jsx)("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,I.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),X=({className:e,style:t})=>(0,I.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:(0,I.jsx)("polyline",{points:"9 18 15 12 9 6"})}),de=({className:e,style:t,fill:i="none"})=>(0,I.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:i,stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:(0,I.jsx)("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})});var me=require("react/jsx-runtime"),He={position:"absolute",top:"-8px",right:"-8px",padding:"2px",borderRadius:"50%",backgroundColor:"white",border:"1px solid #03852e",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s"},ze={width:"17px",height:"17px"},H=({onClick:e,style:t})=>{let[i,o]=Ce.default.useState(!1);return(0,me.jsx)("button",{style:{...He,backgroundColor:i?"#e5e5e5":"white",...t},onClick:e,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),"aria-label":"Remove filter",children:(0,me.jsx)(ue,{style:ze})})};var K=require("react/jsx-runtime"),Oe={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,height:"34px"},J=({label:e,icon:t,remove:i,style:o})=>(0,K.jsxs)("div",{style:{...Oe,...o},children:[t&&(0,K.jsx)("span",{style:{display:"flex",alignItems:"center"},children:t}),(0,K.jsx)("span",{style:{whiteSpace:"nowrap"},children:e}),(0,K.jsx)(H,{onClick:i})]});var ve=require("react");var Y=require("react"),_e={"smartFilter.typingPrompt":"Search for hotels, restaurants, or attractions...","smartFilter.nav.previous":"Previous filters","smartFilter.nav.next":"Next filters","smartFilter.toast.locationRequired":"Please select a location first","smartFilter.clearAll":"Clear all","smartFilter.minRating.suffix":"+","smartFilter.minRating.label":"{{value}}+","smartFilter.minRating.remove":"Remove rating filter","smartFilter.minRating.setTo":"Set rating to {{rating}}","smartFilter.priceRange.label":"Price Range","smartFilter.priceRange.remove":"Remove price filter","smartFilter.priceRange.edit":"Edit price","smartFilter.transformedQuery.remove":"Remove search query","smartFilter.transformedQuery.edit":"Edit search query","smartFilter.restaurantPriceLevel.label":"Price Level","smartFilter.restaurantPriceLevel.remove":"Remove price level filter","smartFilter.restaurantPriceLevel.none":"Any","smartFilter.restaurantPriceLevel.options.cheapEats":"Cheap Eats","smartFilter.restaurantPriceLevel.options.midRange":"Mid Range","smartFilter.restaurantPriceLevel.options.fineDining":"Fine Dining"},We=(e,t="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:0}).format(e),A=(e,t)=>{let[i,o]=(0,Y.useState)("en"),a=(0,Y.useCallback)((b,c)=>{let p={..._e,...e}[b]||b;return c&&Object.keys(c).forEach(u=>{p=p.replace(new RegExp(`{{${u}}}`,"g"),String(c[u]))}),p},[e]),m=(0,Y.useCallback)((b,c)=>t?t(b,c):We(b,c),[t]);return{t:a,locale:i,setLocale:o,formatCurrency:m}};var V=require("react/jsx-runtime"),xe=e=>{let t=[],i=Math.floor(e),o=e%1!==0,a={display:"block",width:"12px",height:"12px",borderRadius:"50%",border:"1px solid #03852e",pointerEvents:"none"},m={...a,backgroundColor:"#03852e"},b={...a,background:"linear-gradient(90deg, #03852e 50%, transparent 50%)"};for(let s=0;s<i;s+=1)t.push((0,V.jsx)("span",{style:m},`full-${s}`));o&&t.push((0,V.jsx)("span",{style:b},"half"));let c=Math.max(0,5-Math.ceil(e));for(let s=0;s<c;s+=1)t.push((0,V.jsx)("span",{style:a},`empty-${s}`));return t},Qe=(e,t)=>(0,V.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[(0,V.jsx)("span",{style:{display:"flex",gap:"1px",userSelect:"none"},children:xe(e)})," ",t]}),ee=e=>e.toFixed(1),Ve=(e,t,i,o)=>`${o(e,i)} - ${o(t!=null?t:0,i)}`;var T=require("react/jsx-runtime"),qe={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",gap:"8px",alignItems:"center",justifyContent:"center",flexShrink:0,height:"34px"},Ke={display:"flex",gap:"1px",userSelect:"none"},ge={display:"block",width:"12px",height:"12px",borderRadius:"50%",border:"1px solid #03852e",pointerEvents:"none"},te={position:"absolute",top:0,height:"100%",cursor:"pointer",backgroundColor:"transparent",border:"none",padding:0},Z=({rating:e,onChange:t,onRemove:i,star:o=!1})=>{let[a,m]=(0,ve.useState)(null),{t:b}=A(),c=a!=null?a:e,s=h=>o&&h?h.toString():b("smartFilter.minRating.label",{value:ee(h)}),p=b("smartFilter.minRating.remove"),u=h=>b("smartFilter.minRating.setTo",{rating:ee(h)}),x=h=>{let v=h+1;return c>=v?"full":c>=v-.5?"half":"empty"},f=h=>{m(null),h!==e&&t(h)},R=h=>{var S;let v=h.relatedTarget;(!v||!((S=h.currentTarget.closest("[data-min-rating-chip]"))!=null&&S.contains(v)))&&m(null)};return(0,T.jsxs)("div",{style:qe,"data-min-rating-chip":!0,children:[(0,T.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px"},onMouseLeave:()=>m(null),children:[(0,T.jsx)("div",{style:Ke,children:Array.from({length:5}).map((h,v)=>{let S=x(v),w=v+1,n=w-.5;if(o)return(0,T.jsxs)("div",{style:{position:"relative",width:"16px",height:"16px"},children:[(0,T.jsx)(de,{fill:c>=w?"#03852e":"none",style:{width:"16px",height:"16px",pointerEvents:"none"}}),(0,T.jsx)("button",{type:"button",style:{...te,left:0,width:"50%",borderRadius:"50% 0 0 50%"},onMouseEnter:()=>m(n),onFocus:()=>m(n),onBlur:R,onClick:()=>f(n),"aria-label":u(n),title:s(n)}),(0,T.jsx)("button",{type:"button",style:{...te,left:"50%",width:"50%",borderRadius:"0 50% 50% 0"},onMouseEnter:()=>m(w),onFocus:()=>m(w),onBlur:R,onClick:()=>f(w),"aria-label":u(w),title:s(w)})]},v);let N=S==="full"?{...ge,backgroundColor:"#03852e"}:ge,O={...ge,background:"linear-gradient(90deg, #03852e 50%, transparent 50%)"};return(0,T.jsxs)("div",{style:{position:"relative",width:"12px",height:"12px"},children:[(0,T.jsx)("span",{style:S==="half"?O:N}),(0,T.jsx)("button",{type:"button",style:{...te,left:0,width:"50%",borderRadius:"50% 0 0 50%",outline:"2px solid transparent",outlineOffset:"1px"},onMouseEnter:()=>m(n),onFocus:()=>m(n),onBlur:R,onClick:()=>f(n),"aria-label":u(n),title:s(n)}),(0,T.jsx)("button",{type:"button",style:{...te,left:"50%",width:"50%",borderRadius:"0 50% 50% 0",outline:"2px solid transparent",outlineOffset:"1px"},onMouseEnter:()=>m(w),onFocus:()=>m(w),onBlur:R,onClick:()=>f(w),"aria-label":u(w),title:s(w)})]},v)})}),(0,T.jsx)("span",{style:{whiteSpace:"nowrap"},children:s(c)})]}),(0,T.jsx)(H,{onClick:i})]})};var $=require("react");var B=require("react/jsx-runtime"),$e={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,height:"34px"},Ue={outline:"none",fontSize:"16px",backgroundColor:"transparent",borderRadius:"2px",padding:"2px 8px",width:"64px",textAlign:"center",border:"none"},Ge={padding:"4px",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.2s",border:"none",backgroundColor:"transparent",color:"#737373",display:"flex",alignItems:"center",justifyContent:"center"},ke=({boundary:e,label:t,value:i,placeholder:o,currency:a,isOptional:m=!1,showRemoveButton:b=!1,removeLabel:c,editLabel:s,showAddWhenEmpty:p=!1,onCommit:u,onRemove:x})=>{let[f,R]=(0,$.useState)(i!==void 0?String(i):""),[h,v]=(0,$.useState)(!1),[S,w]=(0,$.useState)(!1),n=i!==void 0;(0,$.useEffect)(()=>{R(i!==void 0?String(i):""),v(!1)},[i]);let N=()=>{R(i!==void 0?String(i):"")},O=()=>{if(f.trim()===""){if(m){u(void 0),R("");return}N();return}let l=Number(f);if(!Number.isFinite(l)){N();return}let L=Math.max(0,l);if(L===i){N();return}u(L)};return(0,B.jsxs)("div",{style:$e,children:[(0,B.jsx)("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:t}),h?(0,B.jsx)("input",{value:f,onChange:l=>{let L=l.target.value.replace(/[^\d]/g,"");R(L)},onBlur:()=>{O(),v(!1)},onKeyDown:l=>{if(l.key==="Enter"){l.preventDefault(),l.currentTarget.blur(),v(!1);return}if(l.key==="Escape"){l.preventDefault(),N(),l.currentTarget.blur(),v(!1);return}l.key.length===1&&/[0-9]/.test(l.key)||l.key==="Backspace"||l.key==="Delete"||l.key==="Tab"||l.key==="ArrowLeft"||l.key==="ArrowRight"||l.key==="Home"||l.key==="End"||l.preventDefault()},placeholder:o,inputMode:"numeric",pattern:"[0-9]*","aria-label":t,style:Ue,autoFocus:!0}):n?(0,B.jsxs)("span",{style:{fontSize:"16px"},children:[a,i]}):p?(0,B.jsx)("button",{type:"button",style:{fontSize:"16px",color:"#737373",cursor:"pointer",border:"none",backgroundColor:"transparent",padding:0},onClick:()=>v(!0),"aria-label":s,children:"+"}):(0,B.jsx)("span",{style:{fontSize:"16px",color:"#737373"},children:"-"}),(!p||p&&h)&&(0,B.jsx)("span",{style:{color:"#737373",fontSize:"12px"},children:a}),!h&&(!p||n)&&(0,B.jsx)("button",{type:"button",style:{...Ge,backgroundColor:S?"#e5e5e5":"transparent"},"aria-label":s,title:s,onClick:()=>v(!0),onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),children:(0,B.jsx)(G,{})}),b&&(0,B.jsx)(H,{onClick:x})]})},re=({priceRange:e,currency:t,onChange:i,onRemove:o})=>{let{t:a}=A(),m="Min",b="Max",c=a("smartFilter.priceRange.remove"),s=a("smartFilter.priceRange.edit"),p=(u,x)=>{let f={min:e.min,max:e.max};u==="min"?(f.min=x,x!==void 0&&e.max!==void 0&&x>e.max&&(f.max=x)):(f.max=x,x!==void 0&&e.min!==void 0&&x<e.min&&(f.min=x)),(f.min!==e.min||f.max!==e.max)&&i(f)};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ke,{boundary:"min",label:m,value:e.min,currency:t,editLabel:s,showRemoveButton:e.min!==void 0&&e.min!==0,onCommit:u=>p("min",u),onRemove:o}),(0,B.jsx)(ke,{boundary:"max",label:b,value:e.max,currency:t,isOptional:!0,showRemoveButton:e.max!==void 0,removeLabel:c,editLabel:s,showAddWhenEmpty:!0,onCommit:u=>p("max",u),onRemove:o})]})};var D=require("react/jsx-runtime"),Ye={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"16px",flexShrink:0,height:"34px"},Fe=[{value:"Cheap Eats",key:"cheapEats"},{value:"Mid Range",key:"midRange"},{value:"Fine Dining",key:"fineDining"}],ne=({values:e,onChange:t,onRemove:i})=>{let{t:o}=A(),a=o("smartFilter.restaurantPriceLevel.label"),m=o("smartFilter.restaurantPriceLevel.remove"),b=o("smartFilter.restaurantPriceLevel.none"),c=s=>{let{value:p,checked:u}=s.target,x=p,f=new Set(e);u?f.add(x):f.delete(x);let R=Fe.filter(h=>f.has(h.value)).map(h=>h.value);t(R)};return(0,D.jsxs)("div",{style:Ye,children:[(0,D.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[(0,D.jsx)("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:a}),(0,D.jsxs)("div",{style:{display:"flex",gap:"12px"},children:[Fe.map(s=>{let p=o(`smartFilter.restaurantPriceLevel.options.${s.key}`),u=`price-level-${s.key}`;return(0,D.jsxs)("label",{htmlFor:u,style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",cursor:"pointer"},children:[(0,D.jsx)("input",{id:u,type:"checkbox",value:s.value,checked:e.includes(s.value),onChange:c,style:{accentColor:"#03852e",cursor:"pointer"}}),(0,D.jsx)("span",{children:p})]},s.value)}),e.length===0&&(0,D.jsx)("span",{style:{fontSize:"12px",color:"#737373"},children:b})]})]}),(0,D.jsx)(H,{onClick:i})]})};var Q=require("react");var W=require("react/jsx-runtime"),Ze={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,userSelect:"none",height:"34px"},je={backgroundColor:"#ececec",borderRadius:"2px",padding:"2px 8px",outline:"none",fontSize:"16px",minWidth:"8ch",border:"none"},Xe={padding:"4px",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.2s",color:"#737373",border:"none",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center"},oe=({value:e,onChange:t,onRemove:i})=>{let o=(0,Q.useRef)(null),[a,m]=(0,Q.useState)(e),[b,c]=(0,Q.useState)(!1),[s,p]=(0,Q.useState)(!1),{t:u}=A(),x=u("smartFilter.transformedQuery.remove"),f=u("smartFilter.transformedQuery.edit");(0,Q.useEffect)(()=>{m(e),c(!1)},[e]);let R=()=>{let S=a.trim();if(!S.length){m(e);return}S!==e&&t(S)};return(0,W.jsxs)("div",{style:Ze,children:[(0,W.jsx)(pe,{style:{width:"16px",height:"16px",color:"#03852e"}}),b?(0,W.jsx)("input",{ref:o,value:a,onChange:S=>{m(S.target.value)},onBlur:()=>{R(),c(!1)},onKeyDown:S=>{if(S.key==="Enter"){S.preventDefault(),S.currentTarget.blur();return}if(S.key==="Escape"){S.preventDefault(),m(e),S.currentTarget.blur();return}},"aria-label":f,style:je,autoFocus:!0}):(0,W.jsx)("span",{style:{fontSize:"16px"},children:e}),!b&&(0,W.jsx)("button",{type:"button",style:{...Xe,backgroundColor:s?"#e5e5e5":"transparent"},"aria-label":f,title:f,onClick:()=>c(!0),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:(0,W.jsx)(G,{})}),(0,W.jsx)(H,{onClick:i})]})};var z=require("react"),ie=e=>{let t=(0,z.useRef)(null),[i,o]=(0,z.useState)(!0),[a,m]=(0,z.useState)(!0),b=(0,z.useCallback)(()=>{let s=t.current;if(!s){o(!0),m(!0);return}let{scrollLeft:p,scrollWidth:u,clientWidth:x}=s;o(p<=0),m(p+x>=u-1)},[]);(0,z.useEffect)(()=>{let s=t.current;if(b(),!s)return;let p=()=>b();return s.addEventListener("scroll",p,{passive:!0}),window.addEventListener("resize",b),()=>{s.removeEventListener("scroll",p),window.removeEventListener("resize",b)}},[e,b]);let c=(0,z.useCallback)(s=>{let p=t.current;if(!p)return;let u=p.clientWidth*.7;p.scrollBy({left:s==="next"?u:-u,behavior:"smooth"})},[]);return{scrollerRef:t,atStart:i,atEnd:a,scrollByDir:c}};var M=require("react/jsx-runtime"),Je={position:"relative",width:"100%"},et={display:"flex",gap:"8px",overflowX:"auto",alignItems:"center",width:"100%",scrollbarWidth:"none",msOverflowStyle:"none"},Re={pointerEvents:"none",position:"absolute",top:0,bottom:0,width:"40px"},Pe={position:"absolute",top:"50%",transform:"translateY(-50%)",backgroundColor:"white",color:"#003c30",border:"1px solid #003c30",padding:"4px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",cursor:"pointer"},ae=({filters:e,currency:t,minRatingSuffix:i,clearAllLabel:o,previousFiltersLabel:a,nextFiltersLabel:m,formatCurrency:b,onFilterChange:c,onResetFilters:s,onClearAll:p})=>{let{scrollerRef:u,atStart:x,atEnd:f,scrollByDir:R}=ie(e.length),[h,v]=ye.default.useState(null),[S,w]=ye.default.useState(!1);return(0,M.jsxs)("div",{style:Je,children:[(0,M.jsxs)("div",{ref:u,style:{...et,padding:"8px",WebkitOverflowScrolling:"touch"},children:[(0,M.jsx)("style",{children:`
|
|
1
|
+
"use strict";var xe=Object.create;var q=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty;var Re=(e,t)=>{for(var a in t)q(e,a,{get:t[a],enumerable:!0})},pe=(e,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Se(t))!Fe.call(e,s)&&s!==a&&q(e,s,{get:()=>t[s],enumerable:!(i=ve(t,s))||i.enumerable});return e};var re=(e,t,a)=>(a=e!=null?xe(ke(e)):{},pe(t||!e||!e.__esModule?q(a,"default",{value:e,enumerable:!0}):a,e)),Pe=e=>pe(q({},"__esModule",{value:!0}),e);var Ue={};Re(Ue,{Chip:()=>$,CloseIcon:()=>oe,EditIcon:()=>W,FilterChips:()=>J,MinRatingFilterChip:()=>V,NextIcon:()=>K,PriceRangeFilterChip:()=>Y,RestaurantPriceLevelChip:()=>Z,SearchIcon:()=>ne,SmartFilter:()=>be,StarIcon:()=>ie,TransformedQueryChip:()=>j,convertToApiFilters:()=>te.convertToApiFilters,createMinRatingFilterLabel:()=>Te,createPriceRangeFilterLabel:()=>Be,formatRatingValue:()=>U,processApiFilters:()=>te.processApiFilters,renderStars:()=>de,useFilterScroll:()=>X,useMapFirst:()=>$e,useTranslation:()=>I});module.exports=Pe(Ue);var P=re(require("react")),Ce=require("@mapfirst.ai/core"),te=require("@mapfirst.ai/core");var ee=require("react");var le=re(require("react"));var ue=re(require("react"));var M=require("react/jsx-runtime"),ne=({className:e,style:t})=>(0,M.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[(0,M.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,M.jsx)("path",{d:"m21 21-4.35-4.35"})]}),oe=({className:e,style:t})=>(0,M.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[(0,M.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,M.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),W=({className:e,style:t})=>(0,M.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[(0,M.jsx)("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,M.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),K=({className:e,style:t})=>(0,M.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:(0,M.jsx)("polyline",{points:"9 18 15 12 9 6"})}),ie=({className:e,style:t,fill:a="none"})=>(0,M.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:a,stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:(0,M.jsx)("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})});var ae=require("react/jsx-runtime"),Le={position:"absolute",top:"-8px",right:"-8px",padding:"2px",borderRadius:"50%",backgroundColor:"white",border:"1px solid #03852e",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s"},we={width:"17px",height:"17px"},B=({onClick:e,style:t})=>{let[a,i]=ue.default.useState(!1);return(0,ae.jsx)("button",{style:{...Le,backgroundColor:a?"#e5e5e5":"white",...t},onClick:e,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),"aria-label":"Remove filter",children:(0,ae.jsx)(oe,{style:we})})};var O=require("react/jsx-runtime"),Me={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,height:"34px"},$=({label:e,icon:t,remove:a,style:i})=>(0,O.jsxs)("div",{style:{...Me,...i},children:[t&&(0,O.jsx)("span",{style:{display:"flex",alignItems:"center"},children:t}),(0,O.jsx)("span",{style:{whiteSpace:"nowrap"},children:e}),(0,O.jsx)(B,{onClick:a})]});var me=require("react");var Q=require("react"),Ee={"smartFilter.typingPrompt":"Search for hotels, restaurants, or attractions...","smartFilter.nav.previous":"Previous filters","smartFilter.nav.next":"Next filters","smartFilter.toast.locationRequired":"Please select a location first","smartFilter.clearAll":"Clear all","smartFilter.minRating.suffix":"+","smartFilter.minRating.label":"{{value}}+","smartFilter.minRating.remove":"Remove rating filter","smartFilter.minRating.setTo":"Set rating to {{rating}}","smartFilter.priceRange.label":"Price Range","smartFilter.priceRange.remove":"Remove price filter","smartFilter.priceRange.edit":"Edit price","smartFilter.transformedQuery.remove":"Remove search query","smartFilter.transformedQuery.edit":"Edit search query","smartFilter.restaurantPriceLevel.label":"Price Level","smartFilter.restaurantPriceLevel.remove":"Remove price level filter","smartFilter.restaurantPriceLevel.none":"Any","smartFilter.restaurantPriceLevel.options.cheapEats":"Cheap Eats","smartFilter.restaurantPriceLevel.options.midRange":"Mid Range","smartFilter.restaurantPriceLevel.options.fineDining":"Fine Dining"},Ie=(e,t="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:0}).format(e),I=(e,t)=>{let[a,i]=(0,Q.useState)("en"),s=(0,Q.useCallback)((h,c)=>{let m={...Ee,...e}[h]||h;return c&&Object.keys(c).forEach(g=>{m=m.replace(new RegExp(`{{${g}}}`,"g"),String(c[g]))}),m},[e]),y=(0,Q.useCallback)((h,c)=>t?t(h,c):Ie(h,c),[t]);return{t:s,locale:a,setLocale:i,formatCurrency:y}};var z=require("react/jsx-runtime"),de=e=>{let t=[],a=Math.floor(e),i=e%1!==0,s={display:"block",width:"12px",height:"12px",borderRadius:"50%",border:"1px solid #03852e",pointerEvents:"none"},y={...s,backgroundColor:"#03852e"},h={...s,background:"linear-gradient(90deg, #03852e 50%, transparent 50%)"};for(let l=0;l<a;l+=1)t.push((0,z.jsx)("span",{style:y},`full-${l}`));i&&t.push((0,z.jsx)("span",{style:h},"half"));let c=Math.max(0,5-Math.ceil(e));for(let l=0;l<c;l+=1)t.push((0,z.jsx)("span",{style:s},`empty-${l}`));return t},Te=(e,t)=>(0,z.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[(0,z.jsx)("span",{style:{display:"flex",gap:"1px",userSelect:"none"},children:de(e)})," ",t]}),U=e=>e.toFixed(1),Be=(e,t,a,i)=>`${i(e,a)} - ${i(t!=null?t:0,a)}`;var E=require("react/jsx-runtime"),Ne={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",gap:"8px",alignItems:"center",justifyContent:"center",flexShrink:0,height:"34px"},Ae={display:"flex",gap:"1px",userSelect:"none"},se={display:"block",width:"12px",height:"12px",borderRadius:"50%",border:"1px solid #03852e",pointerEvents:"none"},G={position:"absolute",top:0,height:"100%",cursor:"pointer",backgroundColor:"transparent",border:"none",padding:0},V=({rating:e,onChange:t,onRemove:a,star:i=!1})=>{let[s,y]=(0,me.useState)(null),{t:h}=I(),c=s!=null?s:e,l=b=>i&&b?b.toString():h("smartFilter.minRating.label",{value:U(b)}),m=h("smartFilter.minRating.remove"),g=b=>h("smartFilter.minRating.setTo",{rating:U(b)}),x=b=>{let C=b+1;return c>=C?"full":c>=C-.5?"half":"empty"},f=b=>{y(null),b!==e&&t(b)},k=b=>{var v;let C=b.relatedTarget;(!C||!((v=b.currentTarget.closest("[data-min-rating-chip]"))!=null&&v.contains(C)))&&y(null)};return(0,E.jsxs)("div",{style:Ne,"data-min-rating-chip":!0,children:[(0,E.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px"},onMouseLeave:()=>y(null),children:[(0,E.jsx)("div",{style:Ae,children:Array.from({length:5}).map((b,C)=>{let v=x(C),p=C+1,n=p-.5;if(i)return(0,E.jsxs)("div",{style:{position:"relative",width:"16px",height:"16px"},children:[(0,E.jsx)(ie,{fill:c>=p?"#03852e":"none",style:{width:"16px",height:"16px",pointerEvents:"none"}}),(0,E.jsx)("button",{type:"button",style:{...G,left:0,width:"50%",borderRadius:"50% 0 0 50%"},onMouseEnter:()=>y(n),onFocus:()=>y(n),onBlur:k,onClick:()=>f(n),"aria-label":g(n),title:l(n)}),(0,E.jsx)("button",{type:"button",style:{...G,left:"50%",width:"50%",borderRadius:"0 50% 50% 0"},onMouseEnter:()=>y(p),onFocus:()=>y(p),onBlur:k,onClick:()=>f(p),"aria-label":g(p),title:l(p)})]},C);let S=v==="full"?{...se,backgroundColor:"#03852e"}:se,u={...se,background:"linear-gradient(90deg, #03852e 50%, transparent 50%)"};return(0,E.jsxs)("div",{style:{position:"relative",width:"12px",height:"12px"},children:[(0,E.jsx)("span",{style:v==="half"?u:S}),(0,E.jsx)("button",{type:"button",style:{...G,left:0,width:"50%",borderRadius:"50% 0 0 50%",outline:"2px solid transparent",outlineOffset:"1px"},onMouseEnter:()=>y(n),onFocus:()=>y(n),onBlur:k,onClick:()=>f(n),"aria-label":g(n),title:l(n)}),(0,E.jsx)("button",{type:"button",style:{...G,left:"50%",width:"50%",borderRadius:"0 50% 50% 0",outline:"2px solid transparent",outlineOffset:"1px"},onMouseEnter:()=>y(p),onFocus:()=>y(p),onBlur:k,onClick:()=>f(p),"aria-label":g(p),title:l(p)})]},C)})}),(0,E.jsx)("span",{style:{whiteSpace:"nowrap"},children:l(c)})]}),(0,E.jsx)(B,{onClick:a})]})};var _=require("react");var L=require("react/jsx-runtime"),De={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,height:"34px"},He={outline:"none",fontSize:"16px",backgroundColor:"transparent",borderRadius:"2px",padding:"2px 8px",width:"64px",textAlign:"center",border:"none"},ze={padding:"4px",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.2s",border:"none",backgroundColor:"transparent",color:"#737373",display:"flex",alignItems:"center",justifyContent:"center"},ge=({boundary:e,label:t,value:a,placeholder:i,currency:s,isOptional:y=!1,showRemoveButton:h=!1,removeLabel:c,editLabel:l,showAddWhenEmpty:m=!1,onCommit:g,onRemove:x})=>{let[f,k]=(0,_.useState)(a!==void 0?String(a):""),[b,C]=(0,_.useState)(!1),[v,p]=(0,_.useState)(!1),n=a!==void 0;(0,_.useEffect)(()=>{k(a!==void 0?String(a):""),C(!1)},[a]);let S=()=>{k(a!==void 0?String(a):"")},u=()=>{if(f.trim()===""){if(y){g(void 0),k("");return}S();return}let r=Number(f);if(!Number.isFinite(r)){S();return}let F=Math.max(0,r);if(F===a){S();return}g(F)};return(0,L.jsxs)("div",{style:De,children:[(0,L.jsx)("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:t}),b?(0,L.jsx)("input",{value:f,onChange:r=>{let F=r.target.value.replace(/[^\d]/g,"");k(F)},onBlur:()=>{u(),C(!1)},onKeyDown:r=>{if(r.key==="Enter"){r.preventDefault(),r.currentTarget.blur(),C(!1);return}if(r.key==="Escape"){r.preventDefault(),S(),r.currentTarget.blur(),C(!1);return}r.key.length===1&&/[0-9]/.test(r.key)||r.key==="Backspace"||r.key==="Delete"||r.key==="Tab"||r.key==="ArrowLeft"||r.key==="ArrowRight"||r.key==="Home"||r.key==="End"||r.preventDefault()},placeholder:i,inputMode:"numeric",pattern:"[0-9]*","aria-label":t,style:He,autoFocus:!0}):n?(0,L.jsxs)("span",{style:{fontSize:"16px"},children:[s,a]}):m?(0,L.jsx)("button",{type:"button",style:{fontSize:"16px",color:"#737373",cursor:"pointer",border:"none",backgroundColor:"transparent",padding:0},onClick:()=>C(!0),"aria-label":l,children:"+"}):(0,L.jsx)("span",{style:{fontSize:"16px",color:"#737373"},children:"-"}),(!m||m&&b)&&(0,L.jsx)("span",{style:{color:"#737373",fontSize:"12px"},children:s}),!b&&(!m||n)&&(0,L.jsx)("button",{type:"button",style:{...ze,backgroundColor:v?"#e5e5e5":"transparent"},"aria-label":l,title:l,onClick:()=>C(!0),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:(0,L.jsx)(W,{})}),h&&(0,L.jsx)(B,{onClick:x})]})},Y=({priceRange:e,currency:t,onChange:a,onRemove:i})=>{let{t:s}=I(),y="Min",h="Max",c=s("smartFilter.priceRange.remove"),l=s("smartFilter.priceRange.edit"),m=(g,x)=>{let f={min:e.min,max:e.max};g==="min"?(f.min=x,x!==void 0&&e.max!==void 0&&x>e.max&&(f.max=x)):(f.max=x,x!==void 0&&e.min!==void 0&&x<e.min&&(f.min=x)),(f.min!==e.min||f.max!==e.max)&&a(f)};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ge,{boundary:"min",label:y,value:e.min,currency:t,editLabel:l,showRemoveButton:e.min!==void 0&&e.min!==0,onCommit:g=>m("min",g),onRemove:i}),(0,L.jsx)(ge,{boundary:"max",label:h,value:e.max,currency:t,isOptional:!0,showRemoveButton:e.max!==void 0,removeLabel:c,editLabel:l,showAddWhenEmpty:!0,onCommit:g=>m("max",g),onRemove:i})]})};var T=require("react/jsx-runtime"),Oe={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"16px",flexShrink:0,height:"34px"},ye=[{value:"Cheap Eats",key:"cheapEats"},{value:"Mid Range",key:"midRange"},{value:"Fine Dining",key:"fineDining"}],Z=({values:e,onChange:t,onRemove:a})=>{let{t:i}=I(),s=i("smartFilter.restaurantPriceLevel.label"),y=i("smartFilter.restaurantPriceLevel.remove"),h=i("smartFilter.restaurantPriceLevel.none"),c=l=>{let{value:m,checked:g}=l.target,x=m,f=new Set(e);g?f.add(x):f.delete(x);let k=ye.filter(b=>f.has(b.value)).map(b=>b.value);t(k)};return(0,T.jsxs)("div",{style:Oe,children:[(0,T.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[(0,T.jsx)("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:s}),(0,T.jsxs)("div",{style:{display:"flex",gap:"12px"},children:[ye.map(l=>{let m=i(`smartFilter.restaurantPriceLevel.options.${l.key}`),g=`price-level-${l.key}`;return(0,T.jsxs)("label",{htmlFor:g,style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",cursor:"pointer"},children:[(0,T.jsx)("input",{id:g,type:"checkbox",value:l.value,checked:e.includes(l.value),onChange:c,style:{accentColor:"#03852e",cursor:"pointer"}}),(0,T.jsx)("span",{children:m})]},l.value)}),e.length===0&&(0,T.jsx)("span",{style:{fontSize:"12px",color:"#737373"},children:h})]})]}),(0,T.jsx)(B,{onClick:a})]})};var D=require("react");var A=require("react/jsx-runtime"),_e={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,userSelect:"none",height:"34px"},We={backgroundColor:"#ececec",borderRadius:"2px",padding:"2px 8px",outline:"none",fontSize:"16px",minWidth:"8ch",border:"none"},Qe={padding:"4px",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.2s",color:"#737373",border:"none",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center"},j=({value:e,onChange:t,onRemove:a})=>{let i=(0,D.useRef)(null),[s,y]=(0,D.useState)(e),[h,c]=(0,D.useState)(!1),[l,m]=(0,D.useState)(!1),{t:g}=I(),x=g("smartFilter.transformedQuery.remove"),f=g("smartFilter.transformedQuery.edit");(0,D.useEffect)(()=>{y(e),c(!1)},[e]);let k=()=>{let v=s.trim();if(!v.length){y(e);return}v!==e&&t(v)};return(0,A.jsxs)("div",{style:_e,children:[(0,A.jsx)(ne,{style:{width:"16px",height:"16px",color:"#03852e"}}),h?(0,A.jsx)("input",{ref:i,value:s,onChange:v=>{y(v.target.value)},onBlur:()=>{k(),c(!1)},onKeyDown:v=>{if(v.key==="Enter"){v.preventDefault(),v.currentTarget.blur();return}if(v.key==="Escape"){v.preventDefault(),y(e),v.currentTarget.blur();return}},"aria-label":f,style:We,autoFocus:!0}):(0,A.jsx)("span",{style:{fontSize:"16px"},children:e}),!h&&(0,A.jsx)("button",{type:"button",style:{...Qe,backgroundColor:l?"#e5e5e5":"transparent"},"aria-label":f,title:f,onClick:()=>c(!0),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:(0,A.jsx)(W,{})}),(0,A.jsx)(B,{onClick:a})]})};var N=require("react"),X=e=>{let t=(0,N.useRef)(null),[a,i]=(0,N.useState)(!0),[s,y]=(0,N.useState)(!0),h=(0,N.useCallback)(()=>{let l=t.current;if(!l){i(!0),y(!0);return}let{scrollLeft:m,scrollWidth:g,clientWidth:x}=l;i(m<=0),y(m+x>=g-1)},[]);(0,N.useEffect)(()=>{let l=t.current;if(h(),!l)return;let m=()=>h();return l.addEventListener("scroll",m,{passive:!0}),window.addEventListener("resize",h),()=>{l.removeEventListener("scroll",m),window.removeEventListener("resize",h)}},[e,h]);let c=(0,N.useCallback)(l=>{let m=t.current;if(!m)return;let g=m.clientWidth*.7;m.scrollBy({left:l==="next"?g:-g,behavior:"smooth"})},[]);return{scrollerRef:t,atStart:a,atEnd:s,scrollByDir:c}};var R=require("react/jsx-runtime"),Ve={position:"relative",width:"100%"},qe={display:"flex",gap:"8px",overflowX:"auto",alignItems:"center",width:"100%",scrollbarWidth:"none",msOverflowStyle:"none"},fe={pointerEvents:"none",position:"absolute",top:0,bottom:0,width:"40px"},he={position:"absolute",top:"50%",transform:"translateY(-50%)",backgroundColor:"white",color:"#003c30",border:"1px solid #003c30",padding:"4px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",cursor:"pointer"},J=({filters:e,currency:t,minRatingSuffix:a,clearAllLabel:i,previousFiltersLabel:s,nextFiltersLabel:y,formatCurrency:h,onFilterChange:c,onResetFilters:l,onClearAll:m})=>{let{scrollerRef:g,atStart:x,atEnd:f,scrollByDir:k}=X(e.length),[b,C]=le.default.useState(null),[v,p]=le.default.useState(!1);return(0,R.jsxs)("div",{style:Ve,children:[(0,R.jsxs)("div",{ref:g,style:{...qe,padding:"8px",WebkitOverflowScrolling:"touch"},children:[(0,R.jsx)("style",{children:`
|
|
2
2
|
div::-webkit-scrollbar {
|
|
3
3
|
display: none;
|
|
4
4
|
}
|
|
5
|
-
`}),e.map(n=>{var
|
|
5
|
+
`}),e.map(n=>{var u,o,d;let S=()=>(0,R.jsx)($,{label:n.label,icon:n.icon,remove:()=>{c(e.filter(r=>r.id!==n.id))}},n.id);if(n.type==="minRating"){let r=(u=n.numericValue)!=null?u:Number(n.value);return Number.isFinite(r)?(0,R.jsx)(V,{rating:r,onChange:F=>{let w=e.map(H=>H.id===n.id?{...H,numericValue:F,value:String(F)}:H);c(w)},onRemove:()=>void c(e.filter(F=>F.id!==n.id))},n.id):S()}if(n.type==="starRating"){let r=(o=n.numericValue)!=null?o:Number(n.value);return Number.isFinite(r)?(0,R.jsx)(V,{star:!0,rating:r,onChange:F=>{let w=e.map(H=>H.id===n.id?{...H,numericValue:F,value:String(F)}:H);c(w)},onRemove:()=>void c(e.filter(F=>F.id!==n.id))},n.id):S()}return n.type==="priceRange"&&n.priceRange?(0,R.jsx)(Y,{priceRange:n.priceRange,currency:t,onChange:r=>{let F=e.map(w=>w.id===n.id?{...w,priceRange:r}:w);c(F)},onRemove:()=>void c(e.filter(r=>r.id!==n.id))},n.id):n.type==="transformed_query"?(0,R.jsx)(j,{value:n.value,onChange:r=>{let F=e.map(w=>w.id===n.id?{...w,value:r}:w);c(F)},onRemove:()=>void c(e.filter(r=>r.id!==n.id))},n.id):n.type==="selected_restaurant_price_levels"?(0,R.jsx)(Z,{values:(d=n.priceLevels)!=null?d:[],onChange:r=>{let F=e.map(w=>w.id===n.id?{...w,priceLevels:r}:w);c(F)},onRemove:()=>void c(e.filter(r=>r.id!==n.id))},n.id):S()}),(0,R.jsx)("button",{style:{flexShrink:0,padding:"4px 16px",borderRadius:"9999px",cursor:"pointer",fontSize:"14px",userSelect:"none",backgroundColor:v?"#eee":"white",color:"black",border:"1px solid #03852e"},onClick:m,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:i})]}),!x&&(0,R.jsx)("div",{"aria-hidden":"true",style:{...fe,left:0,background:"linear-gradient(to right, white, transparent)"}}),!f&&(0,R.jsx)("div",{"aria-hidden":"true",style:{...fe,right:0,background:"linear-gradient(to left, white, transparent)"}}),!x&&(0,R.jsx)("button",{type:"button","aria-label":s,style:{...he,left:"4px",transform:"translateY(-50%) rotate(180deg)",backgroundColor:b==="prev"?"#e5e5e5":"white"},onClick:()=>k("prev"),onMouseEnter:()=>C("prev"),onMouseLeave:()=>C(null),children:(0,R.jsx)(K,{style:{width:"20px",height:"20px"}})}),!f&&(0,R.jsx)("button",{type:"button","aria-label":y,style:{...he,right:"4px",backgroundColor:b==="next"?"#e5e5e5":"white"},onClick:()=>k("next"),onMouseEnter:()=>C("next"),onMouseLeave:()=>C(null),children:(0,R.jsx)(K,{style:{width:"20px",height:"20px"}})})]})};var ce=require("react/jsx-runtime"),Ke={position:"relative",display:"flex",flexDirection:"column",gap:"8px",width:"100%"},be=({filters:e,isSearching:t=!1,onFilterChange:a,customTranslations:i,currency:s="USD",containerStyle:y,style:h})=>{let{t:c,formatCurrency:l}=I(i),m=c("smartFilter.minRating.suffix"),g=c("smartFilter.nav.previous"),x=c("smartFilter.nav.next"),f=c("smartFilter.clearAll"),k=(0,ee.useCallback)(async(v,p)=>{if(!t)try{await a(v)}catch(n){console.error("Filter change error:",n)}},[t,a]),b=(0,ee.useCallback)(()=>{k([])},[k]),C=(0,ee.useCallback)(()=>{k([],!0)},[k]);return(0,ce.jsx)("div",{style:{...Ke,...y},children:e.length>0&&(0,ce.jsx)(J,{filters:e,currency:s,minRatingSuffix:m,clearAllLabel:f,previousFiltersLabel:g,nextFiltersLabel:x,formatCurrency:l,onFilterChange:k,onResetFilters:b,onClearAll:C})})};function $e(e){let t=P.default.useRef(null),[a,i]=P.default.useState(null),s=P.default.useRef(e);P.default.useEffect(()=>{s.current=e}),P.default.useEffect(()=>{let p=s.current,n={adapter:null,...p,callbacks:{...p.callbacks,onPropertiesChange:u=>{var o,d;i(r=>r?{...r,properties:u}:null),(d=(o=s.current.callbacks)==null?void 0:o.onPropertiesChange)==null||d.call(o,u)},onSelectedPropertyChange:u=>{var o,d;i(r=>r?{...r,selectedPropertyId:u}:null),(d=(o=s.current.callbacks)==null?void 0:o.onSelectedPropertyChange)==null||d.call(o,u)},onPrimaryTypeChange:u=>{var o,d;i(r=>r?{...r,primary:u}:null),(d=(o=s.current.callbacks)==null?void 0:o.onPrimaryTypeChange)==null||d.call(o,u)},onFiltersChange:u=>{var o,d;i(r=>r?{...r,filters:u}:null),(d=(o=s.current.callbacks)==null?void 0:o.onFiltersChange)==null||d.call(o,u)},onBoundsChange:u=>{var o,d;i(r=>r?{...r,bounds:u}:null),(d=(o=s.current.callbacks)==null?void 0:o.onBoundsChange)==null||d.call(o,u)},onPendingBoundsChange:u=>{var o,d;i(r=>r?{...r,pendingBounds:u}:null),(d=(o=s.current.callbacks)==null?void 0:o.onPendingBoundsChange)==null||d.call(o,u)},onCenterChange:(u,o)=>{var d,r;i(F=>F?{...F,center:u,zoom:o}:null),(r=(d=s.current.callbacks)==null?void 0:d.onCenterChange)==null||r.call(d,u,o)},onZoomChange:u=>{var o,d;i(r=>r?{...r,zoom:u}:null),(d=(o=s.current.callbacks)==null?void 0:o.onZoomChange)==null||d.call(o,u)},onActiveLocationChange:u=>{var o,d;i(r=>r?{...r,activeLocation:u}:null),(d=(o=s.current.callbacks)==null?void 0:o.onActiveLocationChange)==null||d.call(o,u)},onLoadingStateChange:u=>{var o,d;i(r=>r?{...r,initialLoading:u}:null),(d=(o=s.current.callbacks)==null?void 0:o.onLoadingStateChange)==null||d.call(o,u)},onSearchingStateChange:u=>{var o,d;i(r=>r?{...r,isSearching:u}:null),(d=(o=s.current.callbacks)==null?void 0:o.onSearchingStateChange)==null||d.call(o,u)}}},S=new Ce.MapFirstCore(n);return t.current=S,i(S.getState()),()=>{S.destroy(),t.current=null,i(null)}},[]);let y=P.default.useCallback(p=>{t.current&&t.current.setPrimaryType(p)},[]),h=P.default.useCallback(p=>{t.current&&t.current.setSelectedMarker(p)},[]),c=P.default.useCallback((p,n=!0)=>{t.current&&t.current.setUseApi(p,n)},[]),l=P.default.useMemo(()=>({search:async p=>{if(!t.current)throw new Error("MapFirst instance not available");return await t.current.runPropertiesSearch(p)}}),[]),m=P.default.useMemo(()=>({search:async p=>{if(!t.current)throw new Error("MapFirst instance not available");return await t.current.runSmartFilterSearch(p)}}),[]),g=P.default.useMemo(()=>({perform:async()=>t.current?await t.current.performBoundsSearch():null}),[]),x=P.default.useRef(!1),f=P.default.useCallback((p,n,S)=>{t.current&&p&&!x.current&&(t.current.attachMap(p,{platform:"maplibre",maplibregl:n,onMarkerClick:S==null?void 0:S.onMarkerClick}),x.current=!0)},[]),k=P.default.useRef(!1),b=P.default.useCallback((p,n,S)=>{t.current&&p&&!k.current&&(t.current.attachMap(p,{platform:"google",google:n,onMarkerClick:S==null?void 0:S.onMarkerClick}),k.current=!0)},[]),C=P.default.useRef(!1),v=P.default.useCallback((p,n,S)=>{t.current&&p&&!C.current&&(t.current.attachMap(p,{platform:"mapbox",mapboxgl:n,onMarkerClick:S==null?void 0:S.onMarkerClick}),C.current=!0)},[]);return{instance:t.current,state:a,setPrimaryType:y,setSelectedMarker:h,setUseApi:c,propertiesSearch:l,smartFilterSearch:m,boundsSearch:g,attachMapLibre:f,attachGoogle:b,attachMapbox:v}}0&&(module.exports={Chip,CloseIcon,EditIcon,FilterChips,MinRatingFilterChip,NextIcon,PriceRangeFilterChip,RestaurantPriceLevelChip,SearchIcon,SmartFilter,StarIcon,TransformedQueryChip,convertToApiFilters,createMinRatingFilterLabel,createPriceRangeFilterLabel,formatRatingValue,processApiFilters,renderStars,useFilterScroll,useMapFirst,useTranslation});
|
|
6
6
|
//# sourceMappingURL=index.js.map
|