@mapfirst.ai/react 0.0.20 → 0.0.22
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/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- 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/dist/index.d.mts
CHANGED
|
@@ -242,6 +242,7 @@ declare function useMapFirst(options: BaseMapFirstOptions): {
|
|
|
242
242
|
state: MapState | null;
|
|
243
243
|
setPrimaryType: (type: PropertyType) => void;
|
|
244
244
|
setSelectedMarker: (id: number | null) => void;
|
|
245
|
+
setUseApi: (useApi: boolean, autoLoad?: boolean) => void;
|
|
245
246
|
propertiesSearch: {
|
|
246
247
|
search: (options: {
|
|
247
248
|
body: InitialRequestBody;
|
package/dist/index.d.ts
CHANGED
|
@@ -242,6 +242,7 @@ declare function useMapFirst(options: BaseMapFirstOptions): {
|
|
|
242
242
|
state: MapState | null;
|
|
243
243
|
setPrimaryType: (type: PropertyType) => void;
|
|
244
244
|
setSelectedMarker: (id: number | null) => void;
|
|
245
|
+
setUseApi: (useApi: boolean, autoLoad?: boolean) => void;
|
|
245
246
|
propertiesSearch: {
|
|
246
247
|
search: (options: {
|
|
247
248
|
body: InitialRequestBody;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var Ee=Object.create;var j=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var Ie=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty;var Ne=(e,t)=>{for(var i in t)j(e,i,{get:t[i],enumerable:!0})},be=(e,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Be(t))!Te.call(e,a)&&a!==i&&j(e,a,{get:()=>t[a],enumerable:!(o=Me(t,a))||o.enumerable});return e};var ce=(e,t,i)=>(i=e!=null?Ee(Ie(e)):{},be(t||!e||!e.__esModule?j(i,"default",{value:e,enumerable:!0}):i,e)),De=e=>be(j({},"__esModule",{value:!0}),e);var rt={};Ne(rt,{Chip:()=>J,CloseIcon:()=>ue,EditIcon:()=>U,FilterChips:()=>ae,MinRatingFilterChip:()=>Z,NextIcon:()=>X,PriceRangeFilterChip:()=>re,RestaurantPriceLevelChip:()=>ne,SearchIcon:()=>pe,SmartFilter:()=>Pe,StarIcon:()=>de,TransformedQueryChip:()=>oe,convertToApiFilters:()=>le.convertToApiFilters,createMinRatingFilterLabel:()=>We,createPriceRangeFilterLabel:()=>Qe,formatRatingValue:()=>ee,processApiFilters:()=>le.processApiFilters,renderStars:()=>Ce,useFilterScroll:()=>ie,useMapFirst:()=>tt,useTranslation:()=>D});module.exports=De(rt);var L=ce(require("react")),Le=require("@mapfirst.ai/core"),le=require("@mapfirst.ai/core");var se=require("react");var ye=ce(require("react"));var Se=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"})]}),U=({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"},Ae={width:"17px",height:"17px"},z=({onClick:e,style:t})=>{let[i,o]=Se.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:Ae})})};var K=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,height:"34px"},J=({label:e,icon:t,remove:i,style:o})=>(0,K.jsxs)("div",{style:{...ze,...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)(z,{onClick:i})]});var xe=require("react");var Y=require("react"),Oe={"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"},_e=(e,t="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:0}).format(e),D=(e,t)=>{let[i,o]=(0,Y.useState)("en"),a=(0,Y.useCallback)((b,l)=>{let u={...Oe,...e}[b]||b;return l&&Object.keys(l).forEach(p=>{u=u.replace(new RegExp(`{{${p}}}`,"g"),String(l[p]))}),u},[e]),m=(0,Y.useCallback)((b,l)=>t?t(b,l):_e(b,l),[t]);return{t:a,locale:i,setLocale:o,formatCurrency:m}};var V=require("react/jsx-runtime"),Ce=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 l=Math.max(0,5-Math.ceil(e));for(let s=0;s<l;s+=1)t.push((0,V.jsx)("span",{style:a},`empty-${s}`));return t},We=(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:Ce(e)})," ",t]}),ee=e=>e.toFixed(1),Qe=(e,t,i,o)=>`${o(e,i)} - ${o(t!=null?t:0,i)}`;var T=require("react/jsx-runtime"),Ve={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"},qe={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,xe.useState)(null),{t:b}=D(),l=a!=null?a:e,s=h=>o&&h?h.toString():b("smartFilter.minRating.label",{value:ee(h)}),u=b("smartFilter.minRating.remove"),p=h=>b("smartFilter.minRating.setTo",{rating:ee(h)}),k=h=>{let S=h+1;return l>=S?"full":l>=S-.5?"half":"empty"},y=h=>{m(null),h!==e&&t(h)},F=h=>{var x;let S=h.relatedTarget;(!S||!((x=h.currentTarget.closest("[data-min-rating-chip]"))!=null&&x.contains(S)))&&m(null)};return(0,T.jsxs)("div",{style:Ve,"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:qe,children:Array.from({length:5}).map((h,S)=>{let x=k(S),w=S+1,n=w-.5;if(o)return(0,T.jsxs)("div",{style:{position:"relative",width:"16px",height:"16px"},children:[(0,T.jsx)(de,{fill:l>=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:F,onClick:()=>y(n),"aria-label":p(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:F,onClick:()=>y(w),"aria-label":p(w),title:s(w)})]},S);let N=x==="full"?{...ge,backgroundColor:"#03852e"}:ge,_={...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:x==="half"?_: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:F,onClick:()=>y(n),"aria-label":p(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:F,onClick:()=>y(w),"aria-label":p(w),title:s(w)})]},S)})}),(0,T.jsx)("span",{style:{whiteSpace:"nowrap"},children:s(l)})]}),(0,T.jsx)(z,{onClick:i})]})};var $=require("react");var B=require("react/jsx-runtime"),Ke={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"},$e={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"},ve=({boundary:e,label:t,value:i,placeholder:o,currency:a,isOptional:m=!1,showRemoveButton:b=!1,removeLabel:l,editLabel:s,showAddWhenEmpty:u=!1,onCommit:p,onRemove:k})=>{let[y,F]=(0,$.useState)(i!==void 0?String(i):""),[h,S]=(0,$.useState)(!1),[x,w]=(0,$.useState)(!1),n=i!==void 0;(0,$.useEffect)(()=>{F(i!==void 0?String(i):""),S(!1)},[i]);let N=()=>{F(i!==void 0?String(i):"")},_=()=>{if(y.trim()===""){if(m){p(void 0),F("");return}N();return}let c=Number(y);if(!Number.isFinite(c)){N();return}let R=Math.max(0,c);if(R===i){N();return}p(R)};return(0,B.jsxs)("div",{style:Ke,children:[(0,B.jsx)("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:t}),h?(0,B.jsx)("input",{value:y,onChange:c=>{let R=c.target.value.replace(/[^\d]/g,"");F(R)},onBlur:()=>{_(),S(!1)},onKeyDown:c=>{if(c.key==="Enter"){c.preventDefault(),c.currentTarget.blur(),S(!1);return}if(c.key==="Escape"){c.preventDefault(),N(),c.currentTarget.blur(),S(!1);return}c.key.length===1&&/[0-9]/.test(c.key)||c.key==="Backspace"||c.key==="Delete"||c.key==="Tab"||c.key==="ArrowLeft"||c.key==="ArrowRight"||c.key==="Home"||c.key==="End"||c.preventDefault()},placeholder:o,inputMode:"numeric",pattern:"[0-9]*","aria-label":t,style:$e,autoFocus:!0}):n?(0,B.jsxs)("span",{style:{fontSize:"16px"},children:[a,i]}):u?(0,B.jsx)("button",{type:"button",style:{fontSize:"16px",color:"#737373",cursor:"pointer",border:"none",backgroundColor:"transparent",padding:0},onClick:()=>S(!0),"aria-label":s,children:"+"}):(0,B.jsx)("span",{style:{fontSize:"16px",color:"#737373"},children:"-"}),(!u||u&&h)&&(0,B.jsx)("span",{style:{color:"#737373",fontSize:"12px"},children:a}),!h&&(!u||n)&&(0,B.jsx)("button",{type:"button",style:{...Ge,backgroundColor:x?"#e5e5e5":"transparent"},"aria-label":s,title:s,onClick:()=>S(!0),onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),children:(0,B.jsx)(U,{})}),b&&(0,B.jsx)(z,{onClick:k})]})},re=({priceRange:e,currency:t,onChange:i,onRemove:o})=>{let{t:a}=D(),m="Min",b="Max",l=a("smartFilter.priceRange.remove"),s=a("smartFilter.priceRange.edit"),u=(p,k)=>{let y={min:e.min,max:e.max};p==="min"?(y.min=k,k!==void 0&&e.max!==void 0&&k>e.max&&(y.max=k)):(y.max=k,k!==void 0&&e.min!==void 0&&k<e.min&&(y.min=k)),(y.min!==e.min||y.max!==e.max)&&i(y)};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ve,{boundary:"min",label:m,value:e.min,currency:t,editLabel:s,showRemoveButton:e.min!==void 0&&e.min!==0,onCommit:p=>u("min",p),onRemove:o}),(0,B.jsx)(ve,{boundary:"max",label:b,value:e.max,currency:t,isOptional:!0,showRemoveButton:e.max!==void 0,removeLabel:l,editLabel:s,showAddWhenEmpty:!0,onCommit:p=>u("max",p),onRemove:o})]})};var H=require("react/jsx-runtime"),Ue={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"},ke=[{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}=D(),a=o("smartFilter.restaurantPriceLevel.label"),m=o("smartFilter.restaurantPriceLevel.remove"),b=o("smartFilter.restaurantPriceLevel.none"),l=s=>{let{value:u,checked:p}=s.target,k=u,y=new Set(e);p?y.add(k):y.delete(k);let F=ke.filter(h=>y.has(h.value)).map(h=>h.value);t(F)};return(0,H.jsxs)("div",{style:Ue,children:[(0,H.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[(0,H.jsx)("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:a}),(0,H.jsxs)("div",{style:{display:"flex",gap:"12px"},children:[ke.map(s=>{let u=o(`smartFilter.restaurantPriceLevel.options.${s.key}`),p=`price-level-${s.key}`;return(0,H.jsxs)("label",{htmlFor:p,style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",cursor:"pointer"},children:[(0,H.jsx)("input",{id:p,type:"checkbox",value:s.value,checked:e.includes(s.value),onChange:l,style:{accentColor:"#03852e",cursor:"pointer"}}),(0,H.jsx)("span",{children:u})]},s.value)}),e.length===0&&(0,H.jsx)("span",{style:{fontSize:"12px",color:"#737373"},children:b})]})]}),(0,H.jsx)(z,{onClick:i})]})};var Q=require("react");var W=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:"8px",flexShrink:0,userSelect:"none",height:"34px"},Ze={backgroundColor:"#ececec",borderRadius:"2px",padding:"2px 8px",outline:"none",fontSize:"16px",minWidth:"8ch",border:"none"},je={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,l]=(0,Q.useState)(!1),[s,u]=(0,Q.useState)(!1),{t:p}=D(),k=p("smartFilter.transformedQuery.remove"),y=p("smartFilter.transformedQuery.edit");(0,Q.useEffect)(()=>{m(e),l(!1)},[e]);let F=()=>{let x=a.trim();if(!x.length){m(e);return}x!==e&&t(x)};return(0,W.jsxs)("div",{style:Ye,children:[(0,W.jsx)(pe,{style:{width:"16px",height:"16px",color:"#03852e"}}),b?(0,W.jsx)("input",{ref:o,value:a,onChange:x=>{m(x.target.value)},onBlur:()=>{F(),l(!1)},onKeyDown:x=>{if(x.key==="Enter"){x.preventDefault(),x.currentTarget.blur();return}if(x.key==="Escape"){x.preventDefault(),m(e),x.currentTarget.blur();return}},"aria-label":y,style:Ze,autoFocus:!0}):(0,W.jsx)("span",{style:{fontSize:"16px"},children:e}),!b&&(0,W.jsx)("button",{type:"button",style:{...je,backgroundColor:s?"#e5e5e5":"transparent"},"aria-label":y,title:y,onClick:()=>l(!0),onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),children:(0,W.jsx)(U,{})}),(0,W.jsx)(z,{onClick:i})]})};var O=require("react"),ie=e=>{let t=(0,O.useRef)(null),[i,o]=(0,O.useState)(!0),[a,m]=(0,O.useState)(!0),b=(0,O.useCallback)(()=>{let s=t.current;if(!s){o(!0),m(!0);return}let{scrollLeft:u,scrollWidth:p,clientWidth:k}=s;o(u<=0),m(u+k>=p-1)},[]);(0,O.useEffect)(()=>{let s=t.current;if(b(),!s)return;let u=()=>b();return s.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",b),()=>{s.removeEventListener("scroll",u),window.removeEventListener("resize",b)}},[e,b]);let l=(0,O.useCallback)(s=>{let u=t.current;if(!u)return;let p=u.clientWidth*.7;u.scrollBy({left:s==="next"?p:-p,behavior:"smooth"})},[]);return{scrollerRef:t,atStart:i,atEnd:a,scrollByDir:l}};var E=require("react/jsx-runtime"),Xe={position:"relative",width:"100%"},Je={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"},Re={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:l,onResetFilters:s,onClearAll:u})=>{let{scrollerRef:p,atStart:k,atEnd:y,scrollByDir:F}=ie(e.length),[h,S]=ye.default.useState(null),[x,w]=ye.default.useState(!1);return(0,E.jsxs)("div",{style:Xe,children:[(0,E.jsxs)("div",{ref:p,style:{...Je,padding:"8px",WebkitOverflowScrolling:"touch"},children:[(0,E.jsx)("style",{children:`
|
|
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:`
|
|
2
2
|
div::-webkit-scrollbar {
|
|
3
3
|
display: none;
|
|
4
4
|
}
|
|
5
|
-
`}),e.map(n=>{var
|
|
5
|
+
`}),e.map(n=>{var O,q,U;let N=()=>(0,M.jsx)(J,{label:n.label,icon:n.icon,remove:()=>{c(e.filter(l=>l.id!==n.id))}},n.id);if(n.type==="minRating"){let l=(O=n.numericValue)!=null?O:Number(n.value);return Number.isFinite(l)?(0,M.jsx)(Z,{rating:l,onChange:L=>{let E=e.map(_=>_.id===n.id?{..._,numericValue:L,value:String(L)}:_);c(E)},onRemove:()=>void c(e.filter(L=>L.id!==n.id))},n.id):N()}if(n.type==="starRating"){let l=(q=n.numericValue)!=null?q:Number(n.value);return Number.isFinite(l)?(0,M.jsx)(Z,{star:!0,rating:l,onChange:L=>{let E=e.map(_=>_.id===n.id?{..._,numericValue:L,value:String(L)}:_);c(E)},onRemove:()=>void c(e.filter(L=>L.id!==n.id))},n.id):N()}return n.type==="priceRange"&&n.priceRange?(0,M.jsx)(re,{priceRange:n.priceRange,currency:t,onChange:l=>{let L=e.map(E=>E.id===n.id?{...E,priceRange:l}:E);c(L)},onRemove:()=>void c(e.filter(l=>l.id!==n.id))},n.id):n.type==="transformed_query"?(0,M.jsx)(oe,{value:n.value,onChange:l=>{let L=e.map(E=>E.id===n.id?{...E,value:l}:E);c(L)},onRemove:()=>void c(e.filter(l=>l.id!==n.id))},n.id):n.type==="selected_restaurant_price_levels"?(0,M.jsx)(ne,{values:(U=n.priceLevels)!=null?U:[],onChange:l=>{let L=e.map(E=>E.id===n.id?{...E,priceLevels:l}:E);c(L)},onRemove:()=>void c(e.filter(l=>l.id!==n.id))},n.id):N()}),(0,M.jsx)("button",{style:{flexShrink:0,padding:"4px 16px",borderRadius:"9999px",cursor:"pointer",fontSize:"14px",userSelect:"none",backgroundColor:S?"#eee":"white",color:"black",border:"1px solid #03852e"},onClick:p,onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),children:o})]}),!x&&(0,M.jsx)("div",{"aria-hidden":"true",style:{...Re,left:0,background:"linear-gradient(to right, white, transparent)"}}),!f&&(0,M.jsx)("div",{"aria-hidden":"true",style:{...Re,right:0,background:"linear-gradient(to left, white, transparent)"}}),!x&&(0,M.jsx)("button",{type:"button","aria-label":a,style:{...Pe,left:"4px",transform:"translateY(-50%) rotate(180deg)",backgroundColor:h==="prev"?"#e5e5e5":"white"},onClick:()=>R("prev"),onMouseEnter:()=>v("prev"),onMouseLeave:()=>v(null),children:(0,M.jsx)(X,{style:{width:"20px",height:"20px"}})}),!f&&(0,M.jsx)("button",{type:"button","aria-label":m,style:{...Pe,right:"4px",backgroundColor:h==="next"?"#e5e5e5":"white"},onClick:()=>R("next"),onMouseEnter:()=>v("next"),onMouseLeave:()=>v(null),children:(0,M.jsx)(X,{style:{width:"20px",height:"20px"}})})]})};var fe=require("react/jsx-runtime"),tt={position:"relative",display:"flex",flexDirection:"column",gap:"8px",width:"100%"},Le=({filters:e,isSearching:t=!1,onFilterChange:i,customTranslations:o,currency:a="USD",containerStyle:m,style:b})=>{let{t:c,formatCurrency:s}=A(o),p=c("smartFilter.minRating.suffix"),u=c("smartFilter.nav.previous"),x=c("smartFilter.nav.next"),f=c("smartFilter.clearAll"),R=(0,se.useCallback)(async(S,w)=>{if(!t)try{await i(S)}catch(n){console.error("Filter change error:",n)}},[t,i]),h=(0,se.useCallback)(()=>{R([])},[R]),v=(0,se.useCallback)(()=>{R([],!0)},[R]);return(0,fe.jsx)("div",{style:{...tt,...m},children:e.length>0&&(0,fe.jsx)(ae,{filters:e,currency:a,minRatingSuffix:p,clearAllLabel:f,previousFiltersLabel:u,nextFiltersLabel:x,formatCurrency:s,onFilterChange:R,onResetFilters:h,onClearAll:v})})};function rt(e){let t=P.default.useRef(null),[i,o]=P.default.useState(null),a=P.default.useRef(e);P.default.useEffect(()=>{a.current=e}),P.default.useEffect(()=>{let F=a.current,k={adapter:null,...F,callbacks:{...F.callbacks,onPropertiesChange:d=>{var r,g;o(y=>y?{...y,properties:d}:null),(g=(r=a.current.callbacks)==null?void 0:r.onPropertiesChange)==null||g.call(r,d)},onSelectedPropertyChange:d=>{var r,g;o(y=>y?{...y,selectedPropertyId:d}:null),(g=(r=a.current.callbacks)==null?void 0:r.onSelectedPropertyChange)==null||g.call(r,d)},onPrimaryTypeChange:d=>{var r,g;o(y=>y?{...y,primary:d}:null),(g=(r=a.current.callbacks)==null?void 0:r.onPrimaryTypeChange)==null||g.call(r,d)},onFiltersChange:d=>{var r,g;o(y=>y?{...y,filters:d}:null),(g=(r=a.current.callbacks)==null?void 0:r.onFiltersChange)==null||g.call(r,d)},onBoundsChange:d=>{var r,g;o(y=>y?{...y,bounds:d}:null),(g=(r=a.current.callbacks)==null?void 0:r.onBoundsChange)==null||g.call(r,d)},onPendingBoundsChange:d=>{var r,g;o(y=>y?{...y,pendingBounds:d}:null),(g=(r=a.current.callbacks)==null?void 0:r.onPendingBoundsChange)==null||g.call(r,d)},onCenterChange:(d,r)=>{var g,y;o(be=>be?{...be,center:d,zoom:r}:null),(y=(g=a.current.callbacks)==null?void 0:g.onCenterChange)==null||y.call(g,d,r)},onZoomChange:d=>{var r,g;o(y=>y?{...y,zoom:d}:null),(g=(r=a.current.callbacks)==null?void 0:r.onZoomChange)==null||g.call(r,d)},onActiveLocationChange:d=>{var r,g;o(y=>y?{...y,activeLocation:d}:null),(g=(r=a.current.callbacks)==null?void 0:r.onActiveLocationChange)==null||g.call(r,d)},onLoadingStateChange:d=>{var r,g;o(y=>y?{...y,initialLoading:d}:null),(g=(r=a.current.callbacks)==null?void 0:r.onLoadingStateChange)==null||g.call(r,d)},onSearchingStateChange:d=>{var r,g;o(y=>y?{...y,isSearching:d}:null),(g=(r=a.current.callbacks)==null?void 0:r.onSearchingStateChange)==null||g.call(r,d)}}},C=new we.MapFirstCore(k);return t.current=C,o(C.getState()),()=>{C.destroy(),t.current=null,o(null)}},[]);let m=P.default.useCallback(F=>{t.current&&t.current.setPrimaryType(F)},[]),b=P.default.useCallback(F=>{t.current&&t.current.setSelectedMarker(F)},[]),c=P.default.useCallback((F,k=!0)=>{t.current&&t.current.setUseApi(F,k)},[]),[s,p]=P.default.useState(!1),[u,x]=P.default.useState(null),f=P.default.useMemo(()=>({search:async F=>{if(!t.current){let k=new Error("MapFirst instance not available");throw x(k),k}p(!0),x(null);try{return await t.current.runPropertiesSearch({...F,onError:C=>{let d=C instanceof Error?C:new Error(String(C));x(d)}})}catch(k){let C=k instanceof Error?k:new Error(String(k));throw x(C),C}finally{p(!1)}},isLoading:s,error:u}),[s,u]),[R,h]=P.default.useState(!1),[v,S]=P.default.useState(null),w=P.default.useMemo(()=>({search:async F=>{if(!t.current){let k=new Error("MapFirst instance not available");throw S(k),k}h(!0),S(null);try{return await t.current.runSmartFilterSearch({...F,onError:C=>{let d=C instanceof Error?C:new Error(String(C));S(d)}})}catch(k){let C=k instanceof Error?k:new Error(String(k));throw S(C),C}finally{h(!1)}},isLoading:R,error:v}),[R,v]),[n,N]=P.default.useState(!1),[O,q]=P.default.useState(null),U=P.default.useMemo(()=>({perform:async()=>{if(!t.current)return null;N(!0),q(null);try{return await t.current.performBoundsSearch()}catch(F){let k=F instanceof Error?F:new Error(String(F));throw q(k),k}finally{N(!1)}},isSearching:n,error:O}),[n,O]),l=P.default.useRef(!1),L=P.default.useCallback((F,k,C)=>{t.current&&F&&!l.current&&(t.current.attachMap(F,{platform:"maplibre",maplibregl:k,onMarkerClick:C==null?void 0:C.onMarkerClick}),l.current=!0)},[]),E=P.default.useRef(!1),_=P.default.useCallback((F,k,C)=>{t.current&&F&&!E.current&&(t.current.attachMap(F,{platform:"google",google:k,onMarkerClick:C==null?void 0:C.onMarkerClick}),E.current=!0)},[]),he=P.default.useRef(!1),Ee=P.default.useCallback((F,k,C)=>{t.current&&F&&!he.current&&(t.current.attachMap(F,{platform:"mapbox",mapboxgl:k,onMarkerClick:C==null?void 0:C.onMarkerClick}),he.current=!0)},[]);return{instance:t.current,state:i,setPrimaryType:m,setSelectedMarker:b,setUseApi:c,propertiesSearch:f,smartFilterSearch:w,boundsSearch:U,attachMapLibre:L,attachGoogle:_,attachMapbox:Ee}}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
|